@magicfeedback/popup-sdk 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3329 +1,17 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js
28
- var require_magicfeedback_sdk_browser = __commonJS({
29
- "node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js"(exports, module) {
30
- "use strict";
31
- !(function(e, t) {
32
- "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();
33
- })(self, (() => {
34
- return e = { 945: function(e2, t2) {
35
- var i = "undefined" != typeof self ? self : this, n = (function() {
36
- function e3() {
37
- this.fetch = false, this.DOMException = i.DOMException;
38
- }
39
- return e3.prototype = i, new e3();
40
- })();
41
- !(function(e3) {
42
- !(function(t3) {
43
- var i2 = "URLSearchParams" in e3, n2 = "Symbol" in e3 && "iterator" in Symbol, r2 = "FileReader" in e3 && "Blob" in e3 && (function() {
44
- try {
45
- return new Blob(), true;
46
- } catch (e4) {
47
- return false;
48
- }
49
- })(), s = "FormData" in e3, a = "ArrayBuffer" in e3;
50
- if (a) var o = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"], l = ArrayBuffer.isView || function(e4) {
51
- return e4 && o.indexOf(Object.prototype.toString.call(e4)) > -1;
52
- };
53
- function d(e4) {
54
- if ("string" != typeof e4 && (e4 = String(e4)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e4)) throw new TypeError("Invalid character in header field name");
55
- return e4.toLowerCase();
56
- }
57
- function c(e4) {
58
- return "string" != typeof e4 && (e4 = String(e4)), e4;
59
- }
60
- function u(e4) {
61
- var t4 = { next: function() {
62
- var t5 = e4.shift();
63
- return { done: void 0 === t5, value: t5 };
64
- } };
65
- return n2 && (t4[Symbol.iterator] = function() {
66
- return t4;
67
- }), t4;
68
- }
69
- function p(e4) {
70
- this.map = {}, e4 instanceof p ? e4.forEach((function(e5, t4) {
71
- this.append(t4, e5);
72
- }), this) : Array.isArray(e4) ? e4.forEach((function(e5) {
73
- this.append(e5[0], e5[1]);
74
- }), this) : e4 && Object.getOwnPropertyNames(e4).forEach((function(t4) {
75
- this.append(t4, e4[t4]);
76
- }), this);
77
- }
78
- function m(e4) {
79
- if (e4.bodyUsed) return Promise.reject(new TypeError("Already read"));
80
- e4.bodyUsed = true;
81
- }
82
- function h(e4) {
83
- return new Promise((function(t4, i3) {
84
- e4.onload = function() {
85
- t4(e4.result);
86
- }, e4.onerror = function() {
87
- i3(e4.error);
88
- };
89
- }));
90
- }
91
- function f(e4) {
92
- var t4 = new FileReader(), i3 = h(t4);
93
- return t4.readAsArrayBuffer(e4), i3;
94
- }
95
- function v(e4) {
96
- if (e4.slice) return e4.slice(0);
97
- var t4 = new Uint8Array(e4.byteLength);
98
- return t4.set(new Uint8Array(e4)), t4.buffer;
99
- }
100
- function g() {
101
- return this.bodyUsed = false, this._initBody = function(e4) {
102
- var t4;
103
- 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() : a && r2 && (t4 = e4) && DataView.prototype.isPrototypeOf(t4) ? (this._bodyArrayBuffer = v(e4.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a && (ArrayBuffer.prototype.isPrototypeOf(e4) || l(e4)) ? this._bodyArrayBuffer = v(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"));
104
- }, r2 && (this.blob = function() {
105
- var e4 = m(this);
106
- if (e4) return e4;
107
- if (this._bodyBlob) return Promise.resolve(this._bodyBlob);
108
- if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer]));
109
- if (this._bodyFormData) throw new Error("could not read FormData body as blob");
110
- return Promise.resolve(new Blob([this._bodyText]));
111
- }, this.arrayBuffer = function() {
112
- return this._bodyArrayBuffer ? m(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(f);
113
- }), this.text = function() {
114
- var e4, t4, i3, n3 = m(this);
115
- if (n3) return n3;
116
- if (this._bodyBlob) return e4 = this._bodyBlob, i3 = h(t4 = new FileReader()), t4.readAsText(e4), i3;
117
- if (this._bodyArrayBuffer) return Promise.resolve((function(e5) {
118
- for (var t5 = new Uint8Array(e5), i4 = new Array(t5.length), n4 = 0; n4 < t5.length; n4++) i4[n4] = String.fromCharCode(t5[n4]);
119
- return i4.join("");
120
- })(this._bodyArrayBuffer));
121
- if (this._bodyFormData) throw new Error("could not read FormData body as text");
122
- return Promise.resolve(this._bodyText);
123
- }, s && (this.formData = function() {
124
- return this.text().then(E);
125
- }), this.json = function() {
126
- return this.text().then(JSON.parse);
127
- }, this;
128
- }
129
- p.prototype.append = function(e4, t4) {
130
- e4 = d(e4), t4 = c(t4);
131
- var i3 = this.map[e4];
132
- this.map[e4] = i3 ? i3 + ", " + t4 : t4;
133
- }, p.prototype.delete = function(e4) {
134
- delete this.map[d(e4)];
135
- }, p.prototype.get = function(e4) {
136
- return e4 = d(e4), this.has(e4) ? this.map[e4] : null;
137
- }, p.prototype.has = function(e4) {
138
- return this.map.hasOwnProperty(d(e4));
139
- }, p.prototype.set = function(e4, t4) {
140
- this.map[d(e4)] = c(t4);
141
- }, p.prototype.forEach = function(e4, t4) {
142
- for (var i3 in this.map) this.map.hasOwnProperty(i3) && e4.call(t4, this.map[i3], i3, this);
143
- }, p.prototype.keys = function() {
144
- var e4 = [];
145
- return this.forEach((function(t4, i3) {
146
- e4.push(i3);
147
- })), u(e4);
148
- }, p.prototype.values = function() {
149
- var e4 = [];
150
- return this.forEach((function(t4) {
151
- e4.push(t4);
152
- })), u(e4);
153
- }, p.prototype.entries = function() {
154
- var e4 = [];
155
- return this.forEach((function(t4, i3) {
156
- e4.push([i3, t4]);
157
- })), u(e4);
158
- }, n2 && (p.prototype[Symbol.iterator] = p.prototype.entries);
159
- var y = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
160
- function b(e4, t4) {
161
- var i3, n3, r3 = (t4 = t4 || {}).body;
162
- if (e4 instanceof b) {
163
- if (e4.bodyUsed) throw new TypeError("Already read");
164
- 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);
165
- } else this.url = String(e4);
166
- 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");
167
- this._initBody(r3);
168
- }
169
- function E(e4) {
170
- var t4 = new FormData();
171
- return e4.trim().split("&").forEach((function(e5) {
172
- if (e5) {
173
- var i3 = e5.split("="), n3 = i3.shift().replace(/\+/g, " "), r3 = i3.join("=").replace(/\+/g, " ");
174
- t4.append(decodeURIComponent(n3), decodeURIComponent(r3));
175
- }
176
- })), t4;
177
- }
178
- function k(e4, t4) {
179
- 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);
180
- }
181
- b.prototype.clone = function() {
182
- return new b(this, { body: this._bodyInit });
183
- }, g.call(b.prototype), g.call(k.prototype), k.prototype.clone = function() {
184
- return new k(this._bodyInit, { status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url });
185
- }, k.error = function() {
186
- var e4 = new k(null, { status: 0, statusText: "" });
187
- return e4.type = "error", e4;
188
- };
189
- var A = [301, 302, 303, 307, 308];
190
- k.redirect = function(e4, t4) {
191
- if (-1 === A.indexOf(t4)) throw new RangeError("Invalid status code");
192
- return new k(null, { status: t4, headers: { location: e4 } });
193
- }, t3.DOMException = e3.DOMException;
194
- try {
195
- new t3.DOMException();
196
- } catch (e4) {
197
- t3.DOMException = function(e5, t4) {
198
- this.message = e5, this.name = t4;
199
- var i3 = Error(e5);
200
- this.stack = i3.stack;
201
- }, t3.DOMException.prototype = Object.create(Error.prototype), t3.DOMException.prototype.constructor = t3.DOMException;
202
- }
203
- function C(e4, i3) {
204
- return new Promise((function(n3, s2) {
205
- var a2 = new b(e4, i3);
206
- if (a2.signal && a2.signal.aborted) return s2(new t3.DOMException("Aborted", "AbortError"));
207
- var o2 = new XMLHttpRequest();
208
- function l2() {
209
- o2.abort();
210
- }
211
- o2.onload = function() {
212
- var e5, t4, i4 = { status: o2.status, statusText: o2.statusText, headers: (e5 = o2.getAllResponseHeaders() || "", t4 = new p(), e5.replace(/\r?\n[\t ]+/g, " ").split(/\r?\n/).forEach((function(e6) {
213
- var i5 = e6.split(":"), n4 = i5.shift().trim();
214
- if (n4) {
215
- var r4 = i5.join(":").trim();
216
- t4.append(n4, r4);
217
- }
218
- })), t4) };
219
- i4.url = "responseURL" in o2 ? o2.responseURL : i4.headers.get("X-Request-URL");
220
- var r3 = "response" in o2 ? o2.response : o2.responseText;
221
- n3(new k(r3, i4));
222
- }, o2.onerror = function() {
223
- s2(new TypeError("Network request failed"));
224
- }, o2.ontimeout = function() {
225
- s2(new TypeError("Network request failed"));
226
- }, o2.onabort = function() {
227
- s2(new t3.DOMException("Aborted", "AbortError"));
228
- }, o2.open(a2.method, a2.url, true), "include" === a2.credentials ? o2.withCredentials = true : "omit" === a2.credentials && (o2.withCredentials = false), "responseType" in o2 && r2 && (o2.responseType = "blob"), a2.headers.forEach((function(e5, t4) {
229
- o2.setRequestHeader(t4, e5);
230
- })), a2.signal && (a2.signal.addEventListener("abort", l2), o2.onreadystatechange = function() {
231
- 4 === o2.readyState && a2.signal.removeEventListener("abort", l2);
232
- }), o2.send(void 0 === a2._bodyInit ? null : a2._bodyInit);
233
- }));
234
- }
235
- C.polyfill = true, e3.fetch || (e3.fetch = C, e3.Headers = p, e3.Request = b, e3.Response = k), t3.Headers = p, t3.Request = b, t3.Response = k, t3.fetch = C, Object.defineProperty(t3, "__esModule", { value: true });
236
- })({});
237
- })(n), n.fetch.ponyfill = true, delete n.fetch.polyfill;
238
- var r = n;
239
- (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;
240
- }, 317: (e2, t2) => {
241
- "use strict";
242
- 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/";
243
- }, 156: function(e2, t2, i) {
244
- "use strict";
245
- var n = this && this.__importDefault || function(e3) {
246
- return e3 && e3.__esModule ? e3 : { default: e3 };
247
- };
248
- Object.defineProperty(t2, "__esModule", { value: true });
249
- const r = n(i(927));
250
- let s = null;
251
- s || (s = (0, r.default)()), t2.default = s;
252
- }, 927: function(e2, t2, i) {
253
- "use strict";
254
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
255
- return new (i2 || (i2 = Promise))((function(r2, s2) {
256
- function a2(e4) {
257
- try {
258
- l2(n2.next(e4));
259
- } catch (e5) {
260
- s2(e5);
261
- }
262
- }
263
- function o2(e4) {
264
- try {
265
- l2(n2.throw(e4));
266
- } catch (e5) {
267
- s2(e5);
268
- }
269
- }
270
- function l2(e4) {
271
- var t4;
272
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
273
- e5(t4);
274
- }))).then(a2, o2);
275
- }
276
- l2((n2 = n2.apply(e3, t3 || [])).next());
277
- }));
278
- };
279
- Object.defineProperty(t2, "__esModule", { value: true });
280
- const r = i(57), s = i(665), a = i(256), o = i(313), l = i(317);
281
- t2.default = function() {
282
- const e3 = new s.Config();
283
- let t3 = new a.Log(e3);
284
- return { init: function(i2) {
285
- "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) ? l.HOST_API_URL_DEV : l.HOST_API_URL), e3.set("env", null == i2 ? void 0 : i2.env), t3.log("Initialized Magicfeedback", e3);
286
- }, send: function(i2, r2, s2, a2 = true, l2, d) {
287
- return n(this, void 0, void 0, (function* () {
288
- 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");
289
- const n2 = e3.get("url"), c = { integration: i2, publicKey: r2, privateKey: d, completed: a2, id: l2, feedback: s2 };
290
- try {
291
- if (e3.get("dryRun")) return t3.log("Dry run enabled: skipping native feedback submit"), `dry-run-${Date.now()}`;
292
- const i3 = yield (0, o.sendFeedback)(n2, c, t3);
293
- return t3.log("sent native feedback"), i3;
294
- } catch (e4) {
295
- return t3.err("error native feedback", e4), false;
296
- }
297
- }));
298
- }, form: function(i2, n2, s2, a2) {
299
- return i2 || t3.err("No appID provided"), n2 || t3.err("No publicKey provided"), new r.Form(e3, i2, n2, s2, a2);
300
- }, session: function(i2) {
301
- return i2 || t3.err("No sessionId provided"), new r.Form(e3, i2);
302
- } };
303
- };
304
- }, 79: (e2, t2) => {
305
- "use strict";
306
- Object.defineProperty(t2, "__esModule", { value: true }), t2.History = void 0, t2.History = class {
307
- constructor() {
308
- this.items = [];
309
- }
310
- enqueue(e3) {
311
- this.items.push(e3);
312
- }
313
- dequeue() {
314
- return this.items.shift();
315
- }
316
- rollback() {
317
- return this.items.pop();
318
- }
319
- front() {
320
- return this.items[0];
321
- }
322
- back() {
323
- return this.items[this.items.length - 1];
324
- }
325
- isEmpty() {
326
- return 0 === this.items.length;
327
- }
328
- size() {
329
- return this.items.length;
330
- }
331
- get(e3) {
332
- return this.items[e3];
333
- }
334
- };
335
- }, 665: (e2, t2) => {
336
- "use strict";
337
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Config = void 0, t2.Config = class {
338
- constructor() {
339
- this.variables = {}, this.variables.env = "prod", this.variables.debug = false, this.variables.dryRun = false;
340
- }
341
- get(e3) {
342
- return this.variables[e3];
343
- }
344
- set(e3, t3) {
345
- this.variables[e3] = t3;
346
- }
347
- };
348
- }, 57: function(e2, t2, i) {
349
- "use strict";
350
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
351
- return new (i2 || (i2 = Promise))((function(r2, s2) {
352
- function a2(e4) {
353
- try {
354
- l2(n2.next(e4));
355
- } catch (e5) {
356
- s2(e5);
357
- }
358
- }
359
- function o2(e4) {
360
- try {
361
- l2(n2.throw(e4));
362
- } catch (e5) {
363
- s2(e5);
364
- }
365
- }
366
- function l2(e4) {
367
- var t4;
368
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
369
- e5(t4);
370
- }))).then(a2, o2);
371
- }
372
- l2((n2 = n2.apply(e3, t3 || [])).next());
373
- }));
374
- };
375
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Form = void 0;
376
- const r = i(558), s = i(256), a = i(313), o = i(213), l = i(989), d = i(700), c = i(591), u = i(79), p = i(636);
377
- t2.Form = class {
378
- constructor(e3, t3, i2, n2, r2) {
379
- this.config = e3, this.log = new s.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 u.History(), this.graph = new l.PageGraph([]), this.progress = 0, this.total = 0, this.completed = false, this.timeToCompleted = 0;
380
- }
381
- generate(e3, t3) {
382
- var i2, r2, s2, o2, l2, d2, c2;
383
- return n(this, void 0, void 0, (function* () {
384
- try {
385
- this.formOptionsConfig = Object.assign(Object.assign({}, this.formOptionsConfig), t3), this.selector = e3;
386
- let n2 = this.formData;
387
- 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}`);
388
- if (null === (i2 = n2.error) || void 0 === i2 ? void 0 : i2.message) throw new Error(n2.error.message);
389
- if (n2.questions = (null === (r2 = n2.questions) || void 0 === r2 ? void 0 : r2.filter(((e4) => "ACTIVE" === e4.status))) || [], n2.pages = (null === (s2 = n2.pages) || void 0 === s2 ? void 0 : s2.filter(((e4) => "ACTIVE" === e4.status))) || [], null === (o2 = n2.pages) || void 0 === o2 || o2.forEach(((e4) => {
390
- var t4;
391
- return e4.integrationQuestions = null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.filter(((e5) => "ACTIVE" === e5.status));
392
- })), 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}`);
393
- this.formData.pages && 0 !== (null === (l2 = this.formData.pages) || void 0 === l2 ? void 0 : l2.length) || this.formatPages(), null === (d2 = this.formData.questions) || void 0 === d2 || d2.sort(((e4, t4) => e4.position - t4.position)), this.formData.pages = this.formData.pages.filter(((e4) => {
394
- var t4;
395
- return (null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.length) > 0;
396
- })), this.formOptionsConfig.getMetaData && this.getMetaData(), (null === (c2 = this.formData.style) || void 0 === c2 ? void 0 : c2.startMessage) ? yield this.generateWelcomeMessage(this.formData.style.startMessage) : this.startForm();
397
- } catch (e4) {
398
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 })));
399
- }
400
- }));
401
- }
402
- formatPages() {
403
- var e3;
404
- if (this.formData) switch (this.formData.identity) {
405
- case "MAGICSURVEY":
406
- this.formData.pages = [], null === (e3 = this.formData.questions) || void 0 === e3 || e3.forEach(((e4) => {
407
- var t4, i2;
408
- const n2 = new c.PageRoute(e4.id, e4.ref, c.OperatorType.NOEQUAL, [], c.TransitionType.PAGE, (e4.position + 1).toString(), e4.position.toString()), r2 = new d.Page(e4.position.toString(), e4.position, this.appId, [e4], [n2]);
409
- null === (i2 = null === (t4 = this.formData) || void 0 === t4 ? void 0 : t4.pages) || void 0 === i2 || i2.push(r2);
410
- }));
411
- break;
412
- case "MAGICFORM":
413
- const t3 = new d.Page("1", 1, this.appId, this.formData.questions, []);
414
- this.formData.pages = [t3];
415
- }
416
- }
417
- generateContainer() {
418
- let e3 = document.getElementById(this.selector);
419
- if (!e3 && (e3 = document.getElementById("magicfeedback-container-" + this.appId), !e3)) throw new Error(`Element with ID '${this.selector}' not found.`);
420
- return e3.classList.add("magicfeedback-container"), e3.id = "magicfeedback-container-" + this.appId, e3.innerHTML = "", e3;
421
- }
422
- generateForm() {
423
- var e3, t3, i2, r2;
424
- return n(this, void 0, void 0, (function* () {
425
- try {
426
- if (!this.formData || !this.formData.pages || 0 === this.formData.pages.length) throw new Error("No form data");
427
- this.graph = new l.PageGraph(this.formData.pages.sort(((e4, t4) => e4.position - t4.position)));
428
- let n2 = this.generateContainer();
429
- const s2 = document.createElement("form");
430
- s2.classList.add("magicfeedback-form"), s2.id = "magicfeedback-" + this.appId, s2.addEventListener("submit", ((e4) => e4.preventDefault()));
431
- const a2 = document.createElement("div");
432
- a2.classList.add("magicfeedback-questions"), a2.id = "magicfeedback-questions-" + this.appId;
433
- const d2 = this.graph.getFirstPage();
434
- if (!d2) throw new Error("No page found");
435
- if (this.total = this.graph.findMaxDepth(), d2.elements = (0, o.renderQuestions)(d2.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 = d2.elements) || void 0 === i2 || i2.forEach(((e4) => a2.appendChild(e4))), s2.appendChild(a2), this.history.enqueue(d2), n2.appendChild(s2), this.progress = this.total - this.graph.findMaxDepth(d2), this.formOptionsConfig.addButton) {
436
- const e4 = (0, o.renderActions)(null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.identity, (() => this.back()), this.formOptionsConfig.sendButtonText, this.formOptionsConfig.backButtonText, this.formOptionsConfig.nextButtonText);
437
- s2.appendChild(e4);
438
- }
439
- this.formOptionsConfig.addButton && s2.addEventListener("submit", ((e4) => {
440
- e4.preventDefault(), this.send();
441
- })), 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 }));
442
- } catch (e4) {
443
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
444
- }
445
- }));
446
- }
447
- startForm() {
448
- this.generateForm();
449
- }
450
- generateWelcomeMessage(e3) {
451
- return n(this, void 0, void 0, (function* () {
452
- try {
453
- const t3 = this.generateContainer(), i2 = (0, o.renderStartMessage)(e3, this.formOptionsConfig.addButton, this.formOptionsConfig.startButtonText, (() => this.startForm()));
454
- t3.appendChild(i2), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, formData: this.formData }));
455
- } catch (e4) {
456
- return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
457
- }
458
- }));
459
- }
460
- getMetaData() {
461
- 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] });
462
- const e3 = new URLSearchParams(window.location.search);
463
- Array.from(new Set(e3.keys())).forEach(((t3) => {
464
- const i2 = e3.getAll(t3);
465
- i2.length > 0 && this.feedback.metadata.push({ key: `query-${t3}`, value: i2 });
466
- })), 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] });
467
- }
468
- send(e3, t3, i2) {
469
- return n(this, void 0, void 0, (function* () {
470
- const n2 = document.getElementById("magicfeedback-questions-" + this.appId);
471
- try {
472
- i2 && (this.feedback.profile = [...this.feedback.profile, ...i2]), t3 && (this.feedback.metrics = [...this.feedback.metrics, ...t3]), e3 && (this.feedback.metadata = [...this.feedback.metadata, ...e3]), this.answer(), this.formOptionsConfig.beforeSubmitEvent && (yield this.formOptionsConfig.beforeSubmitEvent({ loading: true, progress: this.progress, total: this.total }));
473
- const s2 = this.history.back();
474
- if (!s2) throw new Error("No page found");
475
- for (const e4 of s2.questions.filter(((e5) => e5.require && ![r.FEEDBACKAPPANSWERTYPE.CONSENT, r.FEEDBACKAPPANSWERTYPE.INFO_PAGE].includes(e5.type)))) {
476
- const t4 = e4.assets, i3 = this.feedback.answers.filter(((t5) => t5.key.includes(e4.ref) && !t5.key.includes("extra-option")));
477
- 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");
478
- if (null == t4 ? void 0 : t4.minOptions) {
479
- let n3 = [];
480
- 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");
481
- }
482
- if (e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) {
483
- const i4 = this.feedback.answers.find(((t5) => t5.key === e4.ref));
484
- if (!i4) throw this.log.err(`The matrix question ${e4.ref} is required`), new Error("No response");
485
- const n3 = this.parseMatrixAnswerPre(i4), r2 = Array.isArray(null == t4 ? void 0 : t4.options) ? t4.options : [];
486
- if (r2.length > 0) {
487
- if (r2.find(((e5) => {
488
- const t5 = n3.find(((t6) => t6.key === e5));
489
- return !t5 || !Array.isArray(t5.value) || 0 === t5.value.length;
490
- }))) throw this.log.err(`The matrix question ${e4.ref} requires an answer in every row`), new Error("No response");
491
- } 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");
492
- }
493
- }
494
- const a2 = yield this.pushAnswers(false);
495
- if (!a2) throw new Error("No response");
496
- this.id = a2, yield this.processNextQuestion(n2);
497
- } catch (e4) {
498
- 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 }));
499
- }
500
- }));
501
- }
502
- answer() {
503
- const e3 = document.getElementById("magicfeedback-" + this.appId);
504
- if (!e3) return this.log.err(`Form "${e3}" not found.`), this.feedback.answers = [], [];
505
- const t3 = this.history.back();
506
- if (!t3) {
507
- const t4 = e3.querySelectorAll(".magicfeedback-input"), i3 = [], n3 = {};
508
- return t4.forEach(((e4) => {
509
- var t5;
510
- const r2 = e4, s3 = r2.name;
511
- if (!s3) return;
512
- const a2 = r2.type;
513
- if (("radio" === a2 || "checkbox" === a2) && !r2.checked) return;
514
- const o3 = r2.value, l3 = r2.classList[0];
515
- if ((null == l3 ? void 0 : l3.includes("magicfeedback-priority-list")) || (null === (t5 = r2.id) || void 0 === t5 ? void 0 : t5.startsWith("priority-list-"))) return n3[s3] || (n3[s3] = []), void n3[s3].push(o3);
516
- const d3 = "magicfeedback-consent" === l3 ? r2.checked.toString() : o3;
517
- if (null == d3) return;
518
- const c2 = { key: s3, value: [d3] };
519
- i3.push(c2);
520
- })), Object.entries(n3).forEach((([e4, t5]) => {
521
- const n4 = t5.slice().sort(((e5, t6) => Number(e5.split(".")[0]) - Number(t6.split(".")[0])));
522
- i3.push({ key: e4, value: n4 });
523
- })), this.feedback.answers = i3, i3;
524
- }
525
- const i2 = [];
526
- let n2 = false;
527
- const s2 = e3.querySelectorAll(".magicfeedback-input"), o2 = {}, l2 = {}, d2 = {};
528
- if (s2.forEach(((e4) => {
529
- const s3 = e4, c2 = t3.questions.find(((e5) => {
530
- var t4;
531
- return null === (t4 = s3.name) || void 0 === t4 ? void 0 : t4.includes(e5.ref);
532
- })), u2 = s3.type, p2 = s3.classList[0], m = { key: s3.name, value: [] }, h = "magicfeedback-consent" === p2 ? s3.checked.toString() : s3.value;
533
- if (m.key && "" !== m.key) if (m.key.startsWith("extra-option-")) "" !== h && (m.value.push(h), i2.push(m));
534
- else switch (null == c2 ? void 0 : c2.type) {
535
- case r.FEEDBACKAPPANSWERTYPE.EMAIL:
536
- case r.FEEDBACKAPPANSWERTYPE.TEXT:
537
- case r.FEEDBACKAPPANSWERTYPE.LONGTEXT:
538
- case r.FEEDBACKAPPANSWERTYPE.NUMBER:
539
- case r.FEEDBACKAPPANSWERTYPE.DATE:
540
- case r.FEEDBACKAPPANSWERTYPE.CONTACT:
541
- case r.FEEDBACKAPPANSWERTYPE.PASSWORD:
542
- "" !== h && ("email" === u2 ? (0, a.validateEmail)(h) ? (this.feedback.profile.push({ key: "email", value: [h] }), m.value.push(h), i2.push(m)) : (this.log.err("Invalid email"), n2 = true) : (m.value.push(h), i2.push(m)));
543
- break;
544
- case r.FEEDBACKAPPANSWERTYPE.RADIO:
545
- s3.checked && (m.value.push(h), i2.push(m));
546
- break;
547
- case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
548
- case r.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
549
- s3.checked && (l2[m.key] || (l2[m.key] = []), l2[m.key].push(h));
550
- break;
551
- case r.FEEDBACKAPPANSWERTYPE.BOOLEAN:
552
- s3.checked && (m.value.push(h), i2.push(m));
553
- break;
554
- case r.FEEDBACKAPPANSWERTYPE.CONSENT:
555
- m.value.push(s3.checked.toString()), i2.push(m);
556
- break;
557
- case r.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
558
- case r.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
559
- case r.FEEDBACKAPPANSWERTYPE.RATING_STAR:
560
- s3.checked && (m.value.push(h), i2.push(m));
561
- break;
562
- case r.FEEDBACKAPPANSWERTYPE.SELECT:
563
- "" !== h && (m.value.push(h), i2.push(m));
564
- break;
565
- case r.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
566
- "number" === u2 && s3.id && (d2[m.key] || (d2[m.key] = []), "" !== h && d2[m.key].push(`${s3.id}:${h}%`));
567
- break;
568
- case r.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
569
- "hidden" === u2 && (o2[m.key] || (o2[m.key] = []), o2[m.key].push(h));
570
- break;
571
- case r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
572
- e4.checked && (m.value.push(h), i2.push(m));
573
- case r.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE:
574
- case r.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE:
575
- }
576
- })), n2) return [];
577
- Object.entries(l2).forEach((([e4, t4]) => {
578
- t4 && 0 !== t4.length && i2.push({ key: e4, value: t4 });
579
- })), Object.entries(d2).forEach((([e4, t4]) => {
580
- t4 && 0 !== t4.length && i2.push({ key: e4, value: t4 });
581
- })), Object.entries(o2).forEach((([e4, t4]) => {
582
- if (!t4 || 0 === t4.length) return;
583
- const n3 = t4.slice().sort(((e5, t5) => Number(e5.split(".")[0]) - Number(t5.split(".")[0])));
584
- i2.push({ key: e4, value: n3 });
585
- }));
586
- try {
587
- t3.questions.filter(((e4) => e4.type === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX)).forEach(((e4) => {
588
- const t4 = e4.ref + "-", n3 = i2.filter(((e5) => e5.key.startsWith(t4)));
589
- if (0 === n3.length) return;
590
- const r2 = n3.map(((e5) => ({ key: e5.key.substring(t4.length), value: e5.value }))), s3 = { key: e4.ref, value: [JSON.stringify(r2)] };
591
- for (const e5 of n3) {
592
- const t5 = i2.findIndex(((t6) => t6.key === e5.key));
593
- -1 !== t5 && i2.splice(t5, 1);
594
- }
595
- const a2 = i2.findIndex(((t5) => t5.key === e4.ref));
596
- -1 !== a2 ? i2[a2] = s3 : i2.push(s3);
597
- }));
598
- } catch (e4) {
599
- this.log.err("Error agrupando MULTI_QUESTION_MATRIX", e4);
600
- }
601
- return this.feedback.answers = i2, t3.setAnswer(i2), i2;
602
- }
603
- finish() {
604
- return n(this, void 0, void 0, (function* () {
605
- 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) {
606
- const e3 = document.getElementById("magicfeedback-container-" + this.appId);
607
- e3.childNodes.length > 0 && e3.removeChild(e3.childNodes[0]);
608
- const t3 = (0, o.renderSuccess)(this.formOptionsConfig.successMessage || "Thank you for your feedback!");
609
- e3.appendChild(t3);
610
- }
611
- this.answer();
612
- try {
613
- const e3 = yield this.pushAnswers(true);
614
- 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}:");
615
- 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 }));
616
- } catch (e3) {
617
- 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 }));
618
- }
619
- }));
620
- }
621
- pushAnswers(e3 = false) {
622
- return n(this, void 0, void 0, (function* () {
623
- try {
624
- if (this.config.get("dryRun")) {
625
- const e4 = this.id || `dry-run-${this.appId}-${Date.now()}`;
626
- return this.log.log(`Dry run enabled: skipping feedback submit for form ${this.appId}`), e4;
627
- }
628
- const t3 = this.config.get("url"), i2 = { integration: this.appId, publicKey: this.publicKey, feedback: this.feedback, completed: e3 };
629
- return yield (0, a.sendFeedback)(t3, this.id ? Object.assign(Object.assign({}, i2), { sessionId: this.id }) : i2, this.log);
630
- } catch (e4) {
631
- return this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), "";
632
- }
633
- }));
634
- }
635
- callFollowUpQuestion(e3) {
636
- var t3;
637
- return n(this, void 0, void 0, (function* () {
638
- if (!(null == e3 ? void 0 : e3.followup)) return null;
639
- try {
640
- if (this.config.get("dryRun")) return this.log.log(`Dry run enabled: skipping follow up API for question ${e3.ref}`), null;
641
- if (0 === this.feedback.answers.length) throw new Error("No answers provided");
642
- 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 });
643
- return yield (0, a.getFollowUpQuestion)(i2, n2, this.log);
644
- } catch (e4) {
645
- throw this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), e4;
646
- }
647
- }));
648
- }
649
- processNextQuestion(e3) {
650
- var t3, i2, r2;
651
- return n(this, void 0, void 0, (function* () {
652
- const n2 = this.history.back();
653
- if (!n2) throw new Error("No page found");
654
- const s2 = n2.getFollowupQuestions();
655
- if (0 === (null == s2 ? void 0 : s2.length)) return void (yield this.renderNextQuestion(e3, n2));
656
- const a2 = [];
657
- for (const e4 of s2) {
658
- const t4 = n2.questions.find(((t5) => t5.ref === e4));
659
- if (t4) {
660
- const e5 = yield this.callFollowUpQuestion(t4);
661
- e5 && a2.push(e5);
662
- }
663
- }
664
- if (0 === a2.length) return void (yield this.renderNextQuestion(e3, n2));
665
- const l2 = new d.Page(n2.id, n2.position, this.appId, a2, n2.edges), c2 = new p.PageNode(n2.id, n2.position, n2.edges, l2, a2, true);
666
- c2.elements = (0, o.renderQuestions)(a2, 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(c2), this.progress += 0.5, e3.innerHTML = "", null === (r2 = c2.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: c2.isFollowup, completed: this.completed, error: null }));
667
- }));
668
- }
669
- renderNextQuestion(e3, t3) {
670
- var i2, s2, a2, l2, d2;
671
- return n(this, void 0, void 0, (function* () {
672
- let n2 = this.graph.getNextPage(t3, this.feedback.answers);
673
- if (!n2) return void this.finish();
674
- const u2 = n2.edges.filter(((e4) => "PRECONDITIONAL" === e4.typeCondition)).sort(((e4, t4) => e4.position < t4.position ? -1 : e4.position > t4.position ? 1 : 0));
675
- if ((null == u2 ? void 0 : u2.length) > 0) {
676
- const t4 = u2.some(((e4) => e4.transition === c.TransitionType.ALLOW));
677
- let a3 = t4;
678
- for (const t5 of u2) {
679
- let o2;
680
- for (let e4 = this.history.size() - 1; e4 >= 0; e4--) {
681
- const n3 = this.history.get(e4);
682
- if (n3 && (o2 = null === (i2 = n3.answers) || void 0 === i2 ? void 0 : i2.find(((e5) => e5.key === t5.questionRef)), o2)) break;
683
- }
684
- let l3 = false;
685
- if (o2) {
686
- const e4 = null === (s2 = this.formData) || void 0 === s2 ? void 0 : s2.questions.find(((e5) => e5.ref === t5.questionRef)), i3 = Array.isArray(o2.value) ? o2.value : [o2.value], n3 = Array.isArray(t5.value) ? t5.value : [t5.value];
687
- if ((null == e4 ? void 0 : e4.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) l3 = this.evaluateMatrixPreconditional(t5, o2);
688
- else switch (t5.typeOperator) {
689
- case "EQUAL":
690
- case "INQ":
691
- l3 = i3.some(((e5) => n3.includes(e5)));
692
- break;
693
- case "NOEQUAL":
694
- case "NINQ":
695
- l3 = i3.every(((e5) => !n3.includes(e5)));
696
- break;
697
- case "GREATER":
698
- l3 = i3.some(((e5) => Number(e5) > Number(n3[0])));
699
- break;
700
- case "LESS":
701
- l3 = i3.some(((e5) => Number(e5) < Number(n3[0])));
702
- break;
703
- case "GREATEREQUAL":
704
- l3 = i3.some(((e5) => Number(e5) >= Number(n3[0])));
705
- break;
706
- case "LESSEQUAL":
707
- l3 = i3.some(((e5) => Number(e5) <= Number(n3[0])));
708
- }
709
- }
710
- if (t5.transition === c.TransitionType.ALLOW) l3 || (a3 = false);
711
- else if (t5.transition === c.TransitionType.NEXT && l3) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
712
- }
713
- if (t4 && !a3) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
714
- }
715
- n2.elements = (0, o.renderQuestions)(n2.questions, this.formOptionsConfig.questionFormat, null === (a2 = this.formData) || void 0 === a2 ? void 0 : a2.lang[0], null === (l2 = this.formData) || void 0 === l2 ? void 0 : l2.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 }));
716
- }));
717
- }
718
- back() {
719
- var e3;
720
- return n(this, void 0, void 0, (function* () {
721
- if (0 === this.history.size()) return;
722
- const t3 = document.getElementById("magicfeedback-questions-" + this.appId);
723
- t3 && t3.childNodes.length > 0 && (t3.innerHTML = ""), this.history.rollback();
724
- const i2 = this.history.back();
725
- 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" }));
726
- }));
727
- }
728
- previewQuestion(e3, t3, i2) {
729
- var n2, r2;
730
- const s2 = Array.isArray(t3) ? t3 : [t3];
731
- if (!s2 || 0 === s2.length) throw new Error("[MagicFeedback] No question provided for preview");
732
- const a2 = document.getElementById(e3);
733
- if (!a2) throw new Error(`[MagicFeedback] Element with ID '${e3}' not found.`);
734
- const { format: l2 = this.formOptionsConfig.questionFormat || "standard", language: d2 = (null === (n2 = this.formData) || void 0 === n2 ? void 0 : n2.lang) && this.formData.lang[0] || "en", product: c2 = (null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.product) || { customIcons: false }, clearContainer: u2 = true, wrap: p2 = true } = i2 || {};
735
- u2 && (a2.innerHTML = "");
736
- let m = [];
737
- try {
738
- m = (0, o.renderQuestions)(s2, l2, d2, c2);
739
- } catch (e4) {
740
- throw this.log.err(e4), e4;
741
- }
742
- let h = a2;
743
- if (p2) {
744
- const e4 = document.createElement("div");
745
- e4.classList.add("magicfeedback-preview-question"), h.appendChild(e4), h = e4;
746
- }
747
- return m.forEach(((e4) => h.appendChild(e4))), a2;
748
- }
749
- parseMatrixAnswerPre(e3) {
750
- if (!e3 || !e3.value) return [];
751
- if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
752
- const t3 = JSON.parse(e3.value[0]);
753
- if (Array.isArray(t3)) return t3;
754
- } catch (e4) {
755
- return [];
756
- }
757
- 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 : [];
758
- }
759
- evaluateMatrixPreconditional(e3, t3) {
760
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = this.parseMatrixAnswerPre(t3);
761
- if (!r2.length) return false;
762
- const s2 = n2.size > 0 ? r2.filter(((e4) => n2.has(e4.key))) : r2;
763
- if (!s2.length) return false;
764
- switch (e3.typeOperator) {
765
- case "EQUAL":
766
- case "INQ":
767
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
768
- case "NOEQUAL":
769
- case "NINQ":
770
- return s2.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
771
- case "GREATER":
772
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
773
- case "LESS":
774
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
775
- case "GREATEREQUAL":
776
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
777
- case "LESSEQUAL":
778
- return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
779
- default:
780
- return false;
781
- }
782
- }
783
- };
784
- }, 700: (e2, t2) => {
785
- "use strict";
786
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Page = void 0, t2.Page = class {
787
- constructor(e3, t3, i, n, r) {
788
- 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;
789
- }
790
- };
791
- }, 989: (e2, t2, i) => {
792
- "use strict";
793
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageGraph = void 0;
794
- const n = i(636), r = i(558), s = i(591);
795
- t2.PageGraph = class {
796
- constructor(e3) {
797
- this.nodes = /* @__PURE__ */ new Map(), this.buildGraph(e3);
798
- }
799
- buildGraph(e3) {
800
- e3.forEach(((e4) => {
801
- var t3;
802
- e4.integrationPageRoutes && (e4.integrationPageRoutes = (null === (t3 = e4.integrationPageRoutes) || void 0 === t3 ? void 0 : t3.sort(((e5, t4) => {
803
- const i3 = new Date((null == e5 ? void 0 : e5.generatedAt) || 0).getTime(), n2 = new Date((null == t4 ? void 0 : t4.generatedAt) || 0).getTime();
804
- return i3 !== n2 ? i3 - n2 : "DIRECT" === e5.typeCondition && "DIRECT" !== t4.typeCondition ? 1 : "DIRECT" !== e5.typeCondition && "DIRECT" === t4.typeCondition ? -1 : 0;
805
- }))) || []);
806
- const i2 = new n.PageNode(e4.id, e4.position, e4.integrationPageRoutes || [], e4, e4.integrationQuestions);
807
- this.nodes.set(i2.id, i2);
808
- }));
809
- }
810
- getNodeById(e3) {
811
- return this.nodes.get(e3);
812
- }
813
- getNextEdgeByDefault(e3) {
814
- if (!e3) return;
815
- const t3 = e3.edges.find(((e4) => e4.typeCondition === s.ConditionType.DIRECT));
816
- if (!t3 || ![s.TransitionType.FINISH, s.TransitionType.REDIRECT].includes(t3.transition)) {
817
- if (t3 && t3.transitionDestiny) return t3.transitionDestiny;
818
- for (const t4 of this.nodes.values()) if (t4.position === e3.position + 1) return t4.id;
819
- }
820
- }
821
- getFirstPage() {
822
- let e3, t3 = Number.MAX_VALUE;
823
- for (const i2 of this.nodes.values()) i2.position < t3 && (t3 = i2.position, e3 = i2);
824
- return e3;
825
- }
826
- getNextPage(e3, t3) {
827
- var i2;
828
- if (!e3) return;
829
- e3.edges.sort(((e4, t4) => "DIRECT" === e4.typeCondition ? 1 : "DIRECT" === t4.typeCondition ? -1 : 0));
830
- const n2 = e3.edges.find(((i3) => {
831
- const n3 = e3.questions.find(((e4) => e4.ref === i3.questionRef)), a = null == t3 ? void 0 : t3.filter(((e4) => e4.key === i3.questionRef));
832
- if ("DIRECT" === i3.typeCondition) return true;
833
- if (!a || 0 === a.length) return false;
834
- if ((null == n3 ? void 0 : n3.type) === r.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) return this.evaluateMatrixCondition(i3, a);
835
- const o = Array.isArray(i3.value) ? i3.value : [i3.value];
836
- switch (i3.typeOperator) {
837
- case s.OperatorType.EQUAL:
838
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
839
- case s.OperatorType.NOEQUAL:
840
- return a.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
841
- case s.OperatorType.GREATER:
842
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) > Number(t4)))))));
843
- case s.OperatorType.LESS:
844
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) < Number(t4)))))));
845
- case s.OperatorType.GREATEREQUAL:
846
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) >= Number(t4)))))));
847
- case s.OperatorType.LESSEQUAL:
848
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) <= Number(t4)))))));
849
- case s.OperatorType.INQ:
850
- return a.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
851
- case s.OperatorType.NINQ:
852
- return a.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
853
- default:
854
- return false;
855
- }
856
- }));
857
- if (!n2) {
858
- const t4 = this.getNextEdgeByDefault(e3);
859
- if (!t4) return;
860
- return this.getNodeById(t4);
861
- }
862
- switch (n2.transition) {
863
- case s.TransitionType.PAGE:
864
- if (!n2.transitionDestiny) return;
865
- return this.getNodeById(n2.transitionDestiny);
866
- case s.TransitionType.FINISH:
867
- return;
868
- case s.TransitionType.REDIRECT:
869
- 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}`);
870
- default:
871
- return;
872
- }
873
- }
874
- findDepth(e3) {
875
- const t3 = this.getNodeById(e3);
876
- if (!t3) return 0;
877
- const i2 = /* @__PURE__ */ new Set();
878
- return this.DFSUtil(t3, i2, 0);
879
- }
880
- findMaxDepth(e3) {
881
- if (e3 || (e3 = this.getFirstPage()), !e3) return 0;
882
- const t3 = /* @__PURE__ */ new Set();
883
- let i2 = 1;
884
- return i2 = Math.max(i2, this.DFSUtil(e3, t3, i2)), i2;
885
- }
886
- DFSUtil(e3, t3, i2) {
887
- t3.add(e3);
888
- let n2 = i2;
889
- const r2 = [...e3.edges.filter(((e4) => e4.typeCondition !== s.ConditionType.PRECONDITIONAL)) || []], a = this.getNextEdgeByDefault(e3);
890
- if (a) {
891
- const i3 = this.getNodeById(a);
892
- i3 && !t3.has(i3) && r2.push(new s.PageRoute(i3.id, "", s.OperatorType.DEFAULT, [""], s.TransitionType.PAGE, i3.id, e3.id));
893
- }
894
- for (const e4 of r2) {
895
- if (!e4.transitionDestiny) continue;
896
- const r3 = this.getNodeById(e4.transitionDestiny);
897
- if (r3 && !t3.has(r3)) {
898
- const e5 = i2 + 1, s2 = new Set(t3), a2 = this.DFSUtil(r3, s2, e5);
899
- n2 = Math.max(n2, a2);
900
- }
901
- }
902
- return n2;
903
- }
904
- parseMatrixAnswer(e3) {
905
- if (!e3 || !e3.value) return [];
906
- if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
907
- const t3 = JSON.parse(e3.value[0]);
908
- if (Array.isArray(t3)) return t3;
909
- } catch (e4) {
910
- return [];
911
- }
912
- 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 : [];
913
- }
914
- evaluateMatrixCondition(e3, t3) {
915
- const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), r2 = t3[0], a = this.parseMatrixAnswer(r2);
916
- if (!a.length) return false;
917
- const o = n2.size > 0 ? a.filter(((e4) => n2.has(e4.key))) : a;
918
- if (!o.length) return false;
919
- switch (e3.typeOperator) {
920
- case s.OperatorType.EQUAL:
921
- case s.OperatorType.INQ:
922
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
923
- case s.OperatorType.NOEQUAL:
924
- case s.OperatorType.NINQ:
925
- return o.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
926
- case s.OperatorType.GREATER:
927
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
928
- case s.OperatorType.LESS:
929
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
930
- case s.OperatorType.GREATEREQUAL:
931
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
932
- case s.OperatorType.LESSEQUAL:
933
- return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
934
- default:
935
- return false;
936
- }
937
- }
938
- };
939
- }, 636: (e2, t2) => {
940
- "use strict";
941
- Object.defineProperty(t2, "__esModule", { value: true }), t2.PageNode = void 0, t2.PageNode = class {
942
- constructor(e3, t3, i, n, r, s = false) {
943
- 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;
944
- }
945
- getFollowupQuestions() {
946
- return this.questions.filter(((e3) => e3.followup)).map(((e3) => e3.ref));
947
- }
948
- getRequiredQuestions() {
949
- return this.questions.filter(((e3) => e3.require)).map(((e3) => e3.ref));
950
- }
951
- setAnswer(e3) {
952
- this.answers = e3;
953
- }
954
- };
955
- }, 591: (e2, t2) => {
956
- "use strict";
957
- var i, n, r, s;
958
- 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) {
959
- e3.LOGICAL = "LOGICAL", e3.DIRECT = "DIRECT", e3.PRECONDITIONAL = "PRECONDITIONAL";
960
- })(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) {
961
- e3.ACTIVE = "ACTIVE", e3.DEPRECATED = "DEPRECATED", e3.DELETE = "DELETE";
962
- })(n = t2.StatusType || (t2.StatusType = {})), t2.PageRoute = class {
963
- constructor(e3, t3, r2, s2, a, o, l, d, c, u) {
964
- this.id = e3, this.questionRef = t3, this.typeCondition = d || i.LOGICAL, this.typeOperator = r2, this.value = s2 || [], this.transition = a, this.transitionDestiny = o, this.status = n.ACTIVE, this.generatedAt = /* @__PURE__ */ new Date(), this.updatedAt = /* @__PURE__ */ new Date(), this.integrationPageId = l, this.position = c || 0, this.option = u || [];
965
- }
966
- };
967
- }, 558: (e2, t2) => {
968
- "use strict";
969
- var i, n;
970
- Object.defineProperty(t2, "__esModule", { value: true }), 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 {
971
- }, (function(e3) {
972
- e3.FORM = "form", e3.DIV = "div";
973
- })(i || (i = {}));
974
- }, 516: (e2, t2) => {
975
- "use strict";
976
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getUrlParam = t2.getBooleanOptions = t2.parseTitle = void 0, t2.parseTitle = function(e3, t3) {
977
- return e3 ? "object" == typeof e3 ? e3[t3] || e3.en : e3 : "";
978
- }, t2.getBooleanOptions = function(e3) {
979
- switch (e3) {
980
- case "es":
981
- return ["S\xED", "No"];
982
- case "fr":
983
- return ["Oui", "Non"];
984
- case "de":
985
- return ["Ja", "Nein"];
986
- case "it":
987
- return ["S\xEC", "No"];
988
- case "pt":
989
- return ["Sim", "N\xE3o"];
990
- case "nl":
991
- return ["Ja", "Nee"];
992
- case "pl":
993
- return ["Tak", "Nie"];
994
- case "ru":
995
- return ["\u0414\u0430", "\u041D\u0435\u0442"];
996
- case "ja":
997
- return ["\u306F\u3044", "\u3044\u3044\u3048"];
998
- case "zh":
999
- return ["\u662F", "\u4E0D"];
1000
- case "ko":
1001
- return ["\uC608", "\uC544\uB2C8"];
1002
- case "da":
1003
- case "sv":
1004
- return ["Ja", "Nej"];
1005
- case "fi":
1006
- return ["Kyll\xE4", "Ei"];
1007
- case "no":
1008
- return ["Ja", "Nei"];
1009
- case "ar":
1010
- return ["\u0646\u0639\u0645", "\u0644\u0627"];
1011
- case "bn":
1012
- return ["\u09B9\u09CD\u09AF\u09BE\u0981", "\u09A8\u09BE"];
1013
- default:
1014
- return ["Yes", "No"];
1015
- }
1016
- }, t2.getUrlParam = function(e3) {
1017
- return new URLSearchParams(window.location.search).get(e3);
1018
- };
1019
- }, 559: (e2, t2) => {
1020
- "use strict";
1021
- function i(e3, t3, i2, n, r = false, s = true, a = "ltr", o = "row") {
1022
- const l = document.createElement("div");
1023
- l.classList.add("magicfeedback-rating-placeholder"), l.style.display = "flex", l.style.flexDirection = o, l.style.alignItems = "center", l.style.justifyContent = "space-between", l.style.width = r ? `calc(100% - (100% / ${t3 + 1}))` : "100%", l.style.marginRight = "auto", s && window.innerWidth < 600 && (l.style.flexDirection = "column");
1024
- const d = document.createElement("span");
1025
- d.textContent = null != i2 ? i2 : null, d.classList.add("magicfeedback-rating-placeholder-value"), d.style.fontSize = "15px", d.style.display = "block", d.style.minWidth = "0", d.style.overflowWrap = "anywhere", d.style.wordBreak = "break-word", d.style.textAlign = "ltr" === a ? "left" : "right", d.style.width = "50%", (s && window.innerWidth < 600 || "column" === o) && (d.textContent = `${e3} = ${i2}`, d.style.width = "100%", d.style.textAlign = "left", d.style.marginBottom = "5px");
1026
- const c = document.createElement("span");
1027
- return c.textContent = null != n ? n : null, c.classList.add("magicfeedback-rating-placeholder-value"), c.style.fontSize = "15px", c.style.display = "block", c.style.minWidth = "0", c.style.overflowWrap = "anywhere", c.style.wordBreak = "break-word", c.style.textAlign = "ltr" === a ? "right" : "left", c.style.width = "50%", (s && window.innerWidth < 600 || "column" === o) && (c.textContent = `${t3} = ${n}`, c.style.width = "100%", c.style.textAlign = "left", c.style.marginBottom = "5px"), "ltr" === a ? (i2 && l.appendChild(d), n && l.appendChild(c)) : (n && l.appendChild(c), i2 && l.appendChild(d)), l;
1028
- }
1029
- Object.defineProperty(t2, "__esModule", { value: true }), t2.createRatingNumberElement = t2.createStarRating = t2.createRatingPlaceholder = void 0, t2.createRatingPlaceholder = i, t2.createStarRating = function(e3, t3, n, r = () => {
1030
- }, s) {
1031
- const a = "magicfeedback-rating-star-selected", o = document.createElement("div");
1032
- o.classList.add("magicfeedback-rating-star-container"), o.style.maxWidth = "300px", o.style.margin = "auto", o.dataset.originalSelection = "0";
1033
- for (let t4 = 1; t4 <= 5; t4++) {
1034
- const i2 = document.createElement("label");
1035
- i2.classList.add("magicfeedback-rating-star-option");
1036
- const n2 = document.createElement("input");
1037
- 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", (() => {
1038
- const e4 = o.querySelectorAll(".rating__star");
1039
- for (let t5 = 0; t5 < e4.length; t5++) t5 + 1 <= Number(n2.value) ? e4[t5].classList.contains(a) || e4[t5].classList.add(a) : e4[t5].classList.contains(a) && e4[t5].classList.remove(a);
1040
- o.dataset.originalSelection = n2.value, r && r();
1041
- })), i2.appendChild(n2);
1042
- const l2 = document.createElement("label");
1043
- 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", (() => {
1044
- const e4 = o.querySelectorAll(".rating__star"), i3 = t4 - 1;
1045
- e4.forEach(((e5, t5) => {
1046
- t5 <= i3 ? e5.classList.contains(a) || e5.classList.add(a) : e5.classList.contains(a) && e5.classList.remove(a);
1047
- }));
1048
- })), l2.addEventListener("mouseleave", (() => {
1049
- const e4 = Number(o.dataset.originalSelection || "0");
1050
- o.querySelectorAll(".rating__star").forEach(((t5, i3) => {
1051
- i3 < e4 ? t5.classList.contains(a) || t5.classList.add(a) : t5.classList.contains(a) && t5.classList.remove(a);
1052
- }));
1053
- })), i2.appendChild(l2), o.appendChild(i2);
1054
- }
1055
- const l = i(1, 5, t3, n, false, false);
1056
- return l.childElementCount > 0 && (o.classList.add("magicfeedback-rating-container--with-placeholder"), o.insertBefore(l, o.firstChild)), o;
1057
- }, t2.createRatingNumberElement = function(e3, t3, n, r, s, a, o, l) {
1058
- var d;
1059
- const c = document.createElement("div");
1060
- c.classList.add("magicfeedback-rating-number");
1061
- const u = "ltr" === n ? r : `${r}-reverse`, p = document.createElement("div");
1062
- p.classList.add("magicfeedback-rating-number-container"), p.classList.add(`magicfeedback-rating-number-container-${n}`), p.classList.add(`magicfeedback-rating-number-container-${r}`), p.style.display = "flex", p.style.flexDirection = u, p.setAttribute("role", "radiogroup"), p.setAttribute("aria-label", (null == t3 ? void 0 : t3.ariaLabel) || "Rating");
1063
- const m = (null == t3 ? void 0 : t3.max) ? Number(null == t3 ? void 0 : t3.max) : 10, h = (null == t3 ? void 0 : t3.min) ? Number(null == t3 ? void 0 : t3.min) : 0, f = (null == t3 ? void 0 : t3.numberPlaceholders) || null, v = !(s || "column" === r) && ((null == t3 ? void 0 : t3.minPlaceholder) || (null == t3 ? void 0 : t3.maxPlaceholder));
1064
- if (v) {
1065
- const e4 = i(h, m, null == t3 ? void 0 : t3.minPlaceholder, null == t3 ? void 0 : t3.maxPlaceholder, null !== (d = null == t3 ? void 0 : t3.extraOption) && void 0 !== d && d, false, n, "row");
1066
- e4.childElementCount > 0 && (p.classList.add("magicfeedback-rating-number-container--with-placeholder"), p.insertBefore(e4, p.firstChild));
1067
- }
1068
- for (let i2 = h; i2 <= m; i2++) {
1069
- const n2 = document.createElement("div");
1070
- n2.classList.add("magicfeedback-rating-number-option"), n2.classList.add(`magicfeedback-rating-number-option-${r}`);
1071
- const d2 = document.createElement("label");
1072
- d2.htmlFor = `rating-${e3}-${i2}`, d2.classList.add("magicfeedback-rating-number-option-label-container");
1073
- let c2 = i2.toString();
1074
- v ? f && f[i2] && !s && (d2.title = f[i2]) : f && f[i2] ? c2 += ` = ${f[i2]}` : i2 === h && (null == t3 ? void 0 : t3.minPlaceholder) ? c2 += ` = ${null == t3 ? void 0 : t3.minPlaceholder}` : i2 === m && (null == t3 ? void 0 : t3.maxPlaceholder) && (c2 += ` = ${null == t3 ? void 0 : t3.maxPlaceholder}`);
1075
- const u2 = document.createElement("input");
1076
- u2.id = `rating-${e3}-${i2}`, u2.type = "radio", u2.name = e3, u2.value = i2.toString(), u2.classList.add(a), u2.classList.add("magicfeedback-input"), u2.setAttribute("aria-label", `${i2}`), o && u2.addEventListener("change", (() => o())), l && l === u2.value && (u2.checked = true);
1077
- const g = document.createElement("label");
1078
- g.htmlFor = `rating-${e3}-${i2}`, g.textContent = c2, g.classList.add("magicfeedback-rating-number-value"), d2.appendChild(u2), d2.appendChild(g), n2.appendChild(d2), p.appendChild(n2);
1079
- }
1080
- if ((null == t3 ? void 0 : t3.extraOption) && (null == t3 ? void 0 : t3.extraOptionText)) {
1081
- const i2 = document.createElement("div");
1082
- i2.classList.add("magicfeedback-rating-number-option");
1083
- const r2 = document.createElement("label");
1084
- r2.htmlFor = `rating-${e3}-extra`, r2.classList.add("magicfeedback-rating-number-option-label-container");
1085
- const s2 = document.createElement("input");
1086
- s2.id = `rating-${e3}-extra`, s2.type = "radio", s2.name = e3, s2.value = "-", s2.classList.add(a), s2.classList.add("magicfeedback-input"), s2.setAttribute("aria-label", null == t3 ? void 0 : t3.extraOptionText), o && s2.addEventListener("change", (() => o()));
1087
- const l2 = document.createElement("label");
1088
- l2.htmlFor = `rating-${e3}-extra`, l2.textContent = null == t3 ? void 0 : t3.extraOptionText, l2.classList.add("magicfeedback-rating-number-value"), r2.appendChild(s2), r2.appendChild(l2), i2.appendChild(r2), "ltr" === n ? p.appendChild(i2) : p.insertBefore(i2, p.firstChild);
1089
- }
1090
- return c.appendChild(p), c;
1091
- };
1092
- }, 42: (e2, t2, i) => {
1093
- "use strict";
1094
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getQuestionRenderer = void 0;
1095
- const n = i(558), r = i(998), s = i(72), a = i(732), o = i(90), l = i(65), d = i(85), c = i(817), u = i(965), p = i(180), m = i(991), h = i(152), f = i(917), v = i(452), g = i(644), y = i(773), b = i(66), E = i(843), k = i(250), A = i(409), C = i(282), T = /* @__PURE__ */ new Map([[n.FEEDBACKAPPANSWERTYPE.TEXT, o.renderText], [n.FEEDBACKAPPANSWERTYPE.LONGTEXT, s.renderLongText], [n.FEEDBACKAPPANSWERTYPE.NUMBER, a.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, m.renderConsent], [n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI, h.renderRatingEmoji], [n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER, f.renderRatingNumber], [n.FEEDBACKAPPANSWERTYPE.RATING_STAR, v.renderRatingStar], [n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX, g.renderMatrix], [n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST, y.renderPriorityList], [n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM, b.renderPointSystem], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE, E.renderUploadImage], [n.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE, k.renderUploadFile], [n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE, A.renderMultipleChoiceImage], [n.FEEDBACKAPPANSWERTYPE.INFO_PAGE, C.renderInfoPage]]);
1096
- t2.getQuestionRenderer = function(e3) {
1097
- return T.get(e3);
1098
- };
1099
- }, 65: (e2, t2, i) => {
1100
- "use strict";
1101
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderBoolean = void 0;
1102
- const n = i(516);
1103
- t2.renderBoolean = ({ question: e3, language: t3, urlParamValue: i2, send: r }) => {
1104
- const { ref: s, assets: a } = e3, o = document.createElement("div"), l = "magicfeedback-radio", d = document.createElement("div");
1105
- 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 == a ? void 0 : a.addIcon) ? ["\u{1F44D}", "\u{1F44E}"] : (0, n.getBooleanOptions)(t3)).forEach(((e4, t4) => {
1106
- const n2 = document.createElement("label");
1107
- 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";
1108
- const a2 = document.createElement("label");
1109
- a2.htmlFor = `rating-${s}-${t4}`, a2.textContent = e4, a2.style.margin = "0", a2.style.padding = "0";
1110
- const o2 = document.createElement("input");
1111
- o2.id = `rating-${s}-${t4}`, o2.type = "radio", o2.name = s, o2.value = ["Yes", "No"][t4], o2.classList.add(l), o2.classList.add("magicfeedback-input"), o2.style.position = "absolute", o2.style.opacity = "0", o2.style.width = "0", o2.style.height = "0", o2.style.margin = "0", o2.addEventListener("change", (() => {
1112
- r && r();
1113
- })), i2 && i2.toLowerCase() === o2.value.toLowerCase() && (o2.checked = true), n2.appendChild(o2), n2.appendChild(a2), d.appendChild(n2);
1114
- })), o.appendChild(d), { element: o, elementTypeClass: l };
1115
- };
1116
- }, 998: (e2, t2, i) => {
1117
- "use strict";
1118
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderChoice = void 0;
1119
- const n = i(558), r = i(784);
1120
- t2.renderChoice = ({ question: e3, language: t3, urlParamValue: i2, randomPosition: s, send: a }) => {
1121
- const { type: o, ref: l, value: d, defaultValue: c, assets: u } = e3, p = document.createElement("div"), m = "magicfeedback-" + ("MULTIPLECHOICE" === o ? "checkbox" : "radio");
1122
- let h = d || [];
1123
- s && (h = h.sort((() => Math.random() - 0.5)));
1124
- let f = (null == u ? void 0 : u.exclusiveAnswers) || [];
1125
- (null == u ? void 0 : u.extraOption) && (f = f.filter(((e4) => e4 !== u.extraOptionText))), f.length > 0 && (null == f || f.forEach(((e4) => {
1126
- h.includes(e4) || h.push(e4);
1127
- })));
1128
- const v = null == u ? void 0 : u.extraOptionText;
1129
- return (null == u ? void 0 : u.extraOption) && v && !h.includes(v) && h.push(v), h.forEach(((e4, s2) => {
1130
- const d2 = document.createElement("div");
1131
- d2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === o ? "checkbox" : "radio"}-container`);
1132
- const v2 = document.createElement("label"), g = document.createElement("input");
1133
- if (g.id = `rating-${l}-${s2}`, g.type = "MULTIPLECHOICE" === o ? "checkbox" : "radio", g.name = l, g.value = e4, g.classList.add(m), g.classList.add("magicfeedback-input"), o === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == u ? void 0 : u.maxOptions) && (null == u ? void 0 : u.maxOptions) > 0 && g.addEventListener("change", (() => {
1134
- document.querySelectorAll(`input[name="${l}"]:checked`).length > (null == u ? void 0 : u.maxOptions) && (g.checked = false);
1135
- })), o === n.FEEDBACKAPPANSWERTYPE.RADIO && a && (!(null == u ? void 0 : u.extraOptionText) || (null == u ? void 0 : u.extraOptionText) && e4 !== (null == u ? void 0 : u.extraOptionText)) && g.addEventListener("change", (() => {
1136
- a();
1137
- })), e4 !== c && e4 !== i2 || (g.checked = true), v2.textContent = e4, v2.htmlFor = `rating-${l}-${s2}`, g.addEventListener("change", ((t4) => {
1138
- const i3 = document.getElementById(`extra-option-${l}`);
1139
- t4.target.checked && f.includes(e4) ? (h.forEach(((t5) => {
1140
- t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1141
- })), i3 && (i3.style.display = "none")) : f.forEach(((t5) => {
1142
- t5 !== e4 && (document.querySelector(`input[value="${t5}"]`).checked = false);
1143
- })), (null == u ? void 0 : u.extraOption) && e4 === (null == u ? void 0 : u.extraOptionText) && i3 && (i3.style.display = t4.target.checked ? "block" : "none");
1144
- })), d2.appendChild(g), d2.appendChild(v2), p.appendChild(d2), (null == u ? void 0 : u.extraOption) && e4 === (null == u ? void 0 : u.extraOptionText)) {
1145
- const e5 = document.createElement("input");
1146
- 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);
1147
- }
1148
- })), { element: p, elementTypeClass: m };
1149
- };
1150
- }, 991: (e2, t2) => {
1151
- "use strict";
1152
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderConsent = void 0, t2.renderConsent = ({ question: e3, urlParamValue: t3, send: i }) => {
1153
- const { id: n, ref: r, value: s, require: a } = e3, o = document.createElement("input");
1154
- return o.type = "checkbox", o.id = `magicfeedback-${n}`, o.name = r, o.value = "true", o.required = a, o.classList.add("magicfeedback-consent"), o.classList.add("magicfeedback-input"), t3 && s.includes(t3) && (o.checked = true), i && o.addEventListener("change", (() => {
1155
- i();
1156
- })), { element: o, elementTypeClass: "magicfeedback-consent" };
1157
- };
1158
- }, 817: (e2, t2, i) => {
1159
- "use strict";
1160
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderDate = void 0;
1161
- const n = i(784);
1162
- t2.renderDate = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1163
- const r = document.createElement("input");
1164
- return r.type = "date", r.placeholder = t3 || n.placeholder.date(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-date" };
1165
- };
1166
- }, 965: (e2, t2) => {
1167
- "use strict";
1168
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderEmail = void 0, t2.renderEmail = ({ placeholderText: e3, urlParamValue: t3 }) => {
1169
- const i = document.createElement("input");
1170
- return i.type = "email", i.placeholder = e3 || "you@example.com", t3 && (i.value = t3), { element: i, elementTypeClass: "magicfeedback-email" };
1171
- };
1172
- }, 282: (e2, t2) => {
1173
- "use strict";
1174
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderInfoPage = void 0, t2.renderInfoPage = ({ question: e3, placeholderText: t3 }) => {
1175
- var i, n;
1176
- const r = document.createElement("div");
1177
- 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)) {
1178
- const e4 = document.createElement("div");
1179
- e4.classList.add("magicfeedback-info-message"), e4.innerHTML = t3 || "", r.appendChild(e4);
1180
- }
1181
- return { element: r, elementTypeClass: "magicfeedback-info-page" };
1182
- };
1183
- }, 72: (e2, t2, i) => {
1184
- "use strict";
1185
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderLongText = void 0;
1186
- const n = i(784);
1187
- t2.renderLongText = ({ language: e3, placeholderText: t3, urlParamValue: i2, maxCharacters: r }) => {
1188
- const s = document.createElement("textarea");
1189
- 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" };
1190
- };
1191
- }, 644: (e2, t2) => {
1192
- "use strict";
1193
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMatrix = void 0, t2.renderMatrix = ({ question: e3, isPhone: t3, randomPosition: i }) => {
1194
- const { ref: n, value: r, assets: s } = e3, a = document.createElement("div"), o = document.createElement("div");
1195
- o.classList.add("magicfeedback-multi-question-matrix-container");
1196
- let l = (null == s ? void 0 : s.options) || [], d = [...r], c = [];
1197
- 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) => {
1198
- d.includes(e4) || d.push(e4);
1199
- }))), t3) {
1200
- const e4 = document.createElement("div");
1201
- e4.classList.add("magicfeedback-multi-question-matrix-list"), null == l || l.forEach(((t4) => {
1202
- const i2 = document.createElement("div");
1203
- 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";
1204
- const r2 = document.createElement("label");
1205
- r2.classList.add("magicfeedback-multi-question-matrix-label"), r2.style.paddingBottom = "10px", r2.textContent = t4, i2.appendChild(r2), d.forEach(((e5) => {
1206
- const r3 = document.createElement("div");
1207
- 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";
1208
- const s2 = document.createElement("label"), a2 = document.createElement("input");
1209
- a2.id = `${n}-${t4}-${e5}`, a2.type = "radio", a2.name = `${n}-${t4}`, a2.value = e5, a2.classList.add("magicfeedback-input"), s2.textContent = e5, s2.htmlFor = `${n}-${t4}-${e5}`, r3.appendChild(a2), r3.appendChild(s2), i2.appendChild(r3);
1210
- })), e4.appendChild(i2);
1211
- })), o.appendChild(e4);
1212
- } else {
1213
- const e4 = document.createElement("table");
1214
- e4.classList.add("magicfeedback-multi-question-matrix-table");
1215
- const t4 = document.createElement("thead");
1216
- t4.classList.add("magicfeedback-multi-question-matrix-header"), t4.style.paddingBottom = "15px";
1217
- const i2 = document.createElement("tr"), r2 = document.createElement("th");
1218
- i2.appendChild(r2), d.forEach(((e5) => {
1219
- const t5 = document.createElement("th");
1220
- t5.textContent = e5, i2.appendChild(t5);
1221
- })), t4.appendChild(i2), e4.appendChild(t4);
1222
- const s2 = document.createElement("tbody");
1223
- null == l || l.forEach(((e5) => {
1224
- const t5 = document.createElement("tr");
1225
- t5.classList.add("magicfeedback-multi-question-matrix-row-tr");
1226
- const i3 = document.createElement("td");
1227
- i3.style.minWidth = "200px", i3.style.padding = "10px";
1228
- const r3 = document.createElement("label");
1229
- r3.classList.add("magicfeedback-multi-question-matrix-label"), r3.textContent = e5, i3.appendChild(r3), t5.appendChild(i3), d.forEach(((i4) => {
1230
- const r4 = document.createElement("td"), s3 = document.createElement("input");
1231
- 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);
1232
- })), s2.appendChild(t5);
1233
- })), e4.appendChild(s2), o.appendChild(e4);
1234
- }
1235
- return a.appendChild(o), { element: a, elementTypeClass: "magicfeedback-multi-question-matrix" };
1236
- };
1237
- }, 409: (e2, t2) => {
1238
- "use strict";
1239
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderMultipleChoiceImage = void 0, t2.renderMultipleChoiceImage = ({ question: e3, randomPosition: t3, urlParamValue: i, send: n }) => {
1240
- const r = document.createElement("div"), { ref: s, assets: a } = e3;
1241
- let o = [...e3.value];
1242
- const l = document.createElement("div");
1243
- l.classList.add("magicfeedback-multiple-choice-image-container"), l.style.display = "flex", l.style.flexDirection = "row", l.style.flexWrap = "wrap", l.style.justifyContent = "center";
1244
- const d = o.length;
1245
- let c = 1, u = 1;
1246
- if (window.innerWidth < 600) c = 1, u = d;
1247
- else switch (d) {
1248
- case 1:
1249
- case 2:
1250
- case 3:
1251
- c = d, u = 1;
1252
- break;
1253
- case 4:
1254
- case 5:
1255
- case 6:
1256
- u = 2, c = Math.ceil(d / u);
1257
- break;
1258
- case 7:
1259
- case 8:
1260
- case 9:
1261
- u = 3, c = Math.ceil(d / u);
1262
- break;
1263
- default:
1264
- u = 4, c = Math.ceil(d / u);
1265
- }
1266
- const p = void 0 !== (null == a ? void 0 : a.addTitle) && (null == a ? void 0 : a.addTitle), m = void 0 !== (null == a ? void 0 : a.multiOption) && (null == a ? void 0 : a.multiOption), h = void 0 !== (null == a ? void 0 : a.extraOption) && (null == a ? void 0 : a.extraOption);
1267
- function f(e4) {
1268
- try {
1269
- const { position: t4, url: r2, value: a2 } = e4, o2 = document.createElement("div");
1270
- o2.classList.add("magicfeedback-multiple-choice-image-option"), o2.style.width = `calc(100% / ${c} - 2px)`, o2.style.height = `calc(100% / ${u} - 2px)`, o2.style.padding = "8px", o2.style.margin = "0";
1271
- const d2 = document.createElement("label");
1272
- d2.classList.add("magicfeedback-image-option-label-container"), d2.htmlFor = `rating-${s}-${t4}`, d2.style.cursor = "pointer", d2.addEventListener("click", (() => {
1273
- d2.style.border = "2px solid #000";
1274
- }));
1275
- const h2 = document.createElement("label");
1276
- h2.textContent = a2, h2.classList.add("magicfeedback-multiple-choice-image-label");
1277
- const f2 = document.createElement("input");
1278
- f2.id = `rating-${s}-${t4}`, f2.type = m ? "checkbox" : "radio", f2.name = s, f2.value = a2, 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), !m && n && f2.addEventListener("change", (() => {
1279
- n();
1280
- }));
1281
- const v = document.createElement("img");
1282
- v.classList.add("magicfeedback-multiple-choice-image-image"), v.src = r2, v.style.cursor = "pointer", v.style.backgroundSize = "cover", v.style.backgroundPosition = "center", v.style.width = "100%", v.style.height = "100%", v.style.objectFit = "cover", v.style.margin = "auto", d2.appendChild(f2), d2.appendChild(v), p && d2.appendChild(h2), o2.appendChild(d2), l.appendChild(o2);
1283
- } catch (e5) {
1284
- console.error(e5);
1285
- }
1286
- }
1287
- return t3 && (o = o.sort((() => Math.random() - 0.5))), o.forEach(((e4) => f(JSON.parse(e4)))), h && (null == a ? void 0 : a.extraOptionValue) && (null == a ? void 0 : a.extraOptionValue.length) > 0 && f(null == a ? void 0 : a.extraOptionValue[0]), r.appendChild(l), { element: r, elementTypeClass: "magicfeedback-multiple-choice-image" };
1288
- };
1289
- }, 732: (e2, t2, i) => {
1290
- "use strict";
1291
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderNumber = void 0;
1292
- const n = i(784), r = i(516);
1293
- t2.renderNumber = ({ question: e3, format: t3, language: i2, urlParamValue: s }) => {
1294
- const a = document.createElement("input");
1295
- a.type = "number", a.placeholder = "slim" === t3 ? (0, r.parseTitle)(e3.title, i2) : n.placeholder.number(i2 || "en");
1296
- const { value: o } = e3;
1297
- return o.length && (o.sort(((e4, t4) => Number(e4) - Number(t4))), a.max = o[o.length - 1], a.min = o[0], a.value = o[0]), s && !isNaN(Number(s)) && (a.value = s), { element: a, elementTypeClass: "magicfeedback-number" };
1298
- };
1299
- }, 180: (e2, t2, i) => {
1300
- "use strict";
1301
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPassword = void 0;
1302
- const n = i(784);
1303
- t2.renderPassword = ({ language: e3, placeholderText: t3, urlParamValue: i2 }) => {
1304
- const r = document.createElement("input");
1305
- return r.type = "password", r.placeholder = t3 || n.placeholder.password(e3 || "en"), i2 && (r.value = i2), { element: r, elementTypeClass: "magicfeedback-password" };
1306
- };
1307
- }, 66: (e2, t2, i) => {
1308
- "use strict";
1309
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPointSystem = void 0;
1310
- const n = i(784);
1311
- t2.renderPointSystem = ({ question: e3, language: t3 }) => {
1312
- const { ref: i2, value: r } = e3, s = document.createElement("div"), a = document.createElement("div");
1313
- a.classList.add("magicfeedback-point-system-container");
1314
- const o = document.createElement("ul");
1315
- o.classList.add("magicfeedback-point-system-list"), o.style.padding = "0";
1316
- const l = 100 / r.length, d = document.createElement("div");
1317
- 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";
1318
- const c = document.createElement("div");
1319
- 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) => {
1320
- const n2 = document.createElement("li");
1321
- n2.classList.add("magicfeedback-point-system-item"), n2.style.display = "flex", n2.style.justifyContent = "space-between", n2.style.alignItems = "center", n2.style.margin = "5px";
1322
- const r2 = document.createElement("label");
1323
- r2.textContent = e4, r2.style.fontSize = "15px", n2.appendChild(r2);
1324
- const s2 = document.createElement("span");
1325
- s2.classList.add("magicfeedback-point-system-input-container");
1326
- const a2 = document.createElement("input");
1327
- a2.name = i2, a2.id = `${e4}`, a2.type = "number", a2.min = "0", a2.max = "100", a2.value = "0", a2.classList.add("magicfeedback-input"), a2.style.width = "40px", a2.style.border = "0", a2.style.textAlign = "center", a2.style.margin = "0 5px", a2.autofocus = 0 === t4;
1328
- const u = document.createElement("span");
1329
- u.textContent = "%", u.style.color = "#000", a2.addEventListener("input", (() => {
1330
- const e5 = o.querySelectorAll("input");
1331
- let t5 = 0;
1332
- e5.forEach(((e6) => {
1333
- t5 += Number(e6.value);
1334
- })), t5 > 100 && (a2.value = `${l}%`, t5 -= Number(a2.value));
1335
- const i3 = document.getElementById("magicfeedback-submit");
1336
- 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 %`;
1337
- })), a2.addEventListener("focus", (() => {
1338
- const e5 = document.getElementById("magicfeedback-submit");
1339
- e5 && (e5.setAttribute("disabled", "true"), e5.addEventListener("pointerover", (() => {
1340
- const e6 = o.querySelectorAll("input");
1341
- let t5 = 0;
1342
- e6.forEach(((e7) => {
1343
- t5 += Number(e7.value);
1344
- })), t5 < 100 && (d.style.display = "block");
1345
- })));
1346
- })), s2.appendChild(a2), s2.appendChild(u), n2.appendChild(s2), o.appendChild(n2);
1347
- })), a.appendChild(o), a.appendChild(c), a.appendChild(d), s.appendChild(a), { element: s, elementTypeClass: "magicfeedback-point-system" };
1348
- };
1349
- }, 773: (e2, t2) => {
1350
- "use strict";
1351
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderPriorityList = void 0, t2.renderPriorityList = ({ question: e3, randomPosition: t3, language: i }) => {
1352
- var n, r, s;
1353
- const a = document.createElement("div"), o = (function(e4) {
1354
- const { value: t4, ref: i2, randomPosition: n2 = false, limitPriority: r2 = false, maxPriority: s2 = 0, language: a2 = "en", placeholder: o2 = "" } = e4, l = (e5) => {
1355
- 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.' } };
1356
- return t5[t5[a2] ? a2 : "en"][e5];
1357
- }, d = document.createElement("div");
1358
- if (d.classList.add("magicfeedback-priority-list-container"), r2 && s2 && s2 > 0) {
1359
- const e5 = [], r3 = document.createElement("div");
1360
- r3.classList.add("magicfeedback-priority-list-header");
1361
- const a3 = document.createElement("div");
1362
- a3.classList.add("magicfeedback-priority-list-instruction"), a3.textContent = "" !== o2 ? o2 : `${l("instruction")}`, a3.style.display = "none";
1363
- const c2 = document.createElement("button");
1364
- 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(a3);
1365
- const u2 = document.createElement("div");
1366
- u2.classList.add("magicfeedback-priority-list-reorder");
1367
- const p = document.createElement("ul");
1368
- p.classList.add("magicfeedback-priority-list-list"), u2.appendChild(p);
1369
- const m = () => {
1370
- p.innerHTML = "", e5.forEach(((t5, n3) => {
1371
- const r4 = document.createElement("li");
1372
- r4.classList.add("magicfeedback-priority-list-item");
1373
- const s3 = document.createElement("input");
1374
- 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);
1375
- const a4 = document.createElement("label");
1376
- a4.classList.add("magicfeedback-priority-list-item-label"), a4.textContent = `${n3 + 1}. ${t5}`, r4.appendChild(a4);
1377
- const o3 = document.createElement("div");
1378
- o3.classList.add("magicfeedback-priority-list-arrows");
1379
- const l2 = document.createElement("img");
1380
- 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";
1381
- const d2 = document.createElement("img");
1382
- 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", (() => {
1383
- var i3, n4, o4, c3;
1384
- const u3 = r4.previousElementSibling;
1385
- if (u3) {
1386
- const m2 = Number(null === (i3 = s3.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) - 1;
1387
- s3.value = `${m2}. ${t5}`, a4.textContent = `${m2}. ${t5}`, l2.style.visibility = 1 === m2 ? "hidden" : "visible", d2.style.visibility = m2 === e5.length ? "hidden" : "visible";
1388
- const h2 = u3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f2 = u3.querySelector(".magicfeedback-priority-list-item-label"), v2 = u3.querySelector(".magicfeedback-priority-list-arrow-up"), g2 = u3.querySelector(".magicfeedback-priority-list-arrow-down");
1389
- if (h2 && f2 && v2 && g2) {
1390
- const t6 = Number(null === (n4 = h2.value) || void 0 === n4 ? void 0 : n4.split(".")[0]) + 1;
1391
- h2.value = `${t6}.${null === (o4 = f2.textContent) || void 0 === o4 ? void 0 : o4.split(".")[1]}`, f2.textContent = `${t6}.${null === (c3 = f2.textContent) || void 0 === c3 ? void 0 : c3.split(".")[1]}`, v2.style.visibility = 1 === t6 ? "hidden" : "visible", g2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1392
- }
1393
- p.insertBefore(r4, u3);
1394
- }
1395
- })), d2.addEventListener("click", (() => {
1396
- var i3, n4, o4;
1397
- const c3 = r4.nextElementSibling;
1398
- if (c3) {
1399
- const u3 = Number(null === (i3 = s3.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) + 1;
1400
- s3.value = `${u3}. ${t5}`, a4.textContent = `${u3}. ${t5}`, l2.style.visibility = 1 === u3 ? "hidden" : "visible", d2.style.visibility = u3 === e5.length ? "hidden" : "visible";
1401
- const m2 = c3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), h2 = c3.querySelector(".magicfeedback-priority-list-item-label"), f2 = c3.querySelector(".magicfeedback-priority-list-arrow-up"), v2 = c3.querySelector(".magicfeedback-priority-list-arrow-down");
1402
- if (m2 && h2 && f2 && v2) {
1403
- const t6 = Number(m2.value.split(".")[0]) - 1;
1404
- m2.value = `${t6}.${null === (n4 = h2.textContent) || void 0 === n4 ? void 0 : n4.split(".")[1]}`, h2.textContent = `${t6}.${null === (o4 = h2.textContent) || void 0 === o4 ? void 0 : o4.split(".")[1]}`, f2.style.visibility = 1 === t6 ? "hidden" : "visible", v2.style.visibility = t6 === e5.length ? "hidden" : "visible";
1405
- }
1406
- p.insertBefore(c3, r4);
1407
- }
1408
- })), o3.appendChild(l2), o3.appendChild(d2), r4.appendChild(o3), p.appendChild(r4);
1409
- }));
1410
- }, h = document.createElement("div");
1411
- h.classList.add("magicfeedback-modal-backdrop"), h.style.position = "fixed", h.style.top = "0", h.style.left = "0", h.style.width = "100vw", h.style.height = "100vh", h.style.background = "rgba(0,0,0,0.4)", h.style.display = "none", h.style.alignItems = "center", h.style.justifyContent = "center", h.style.zIndex = "9999";
1412
- const f = document.createElement("div");
1413
- 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.overflow = "auto", f.style.padding = "16px", f.style.position = "relative";
1414
- const v = document.createElement("h5");
1415
- v.classList.add("magicfeedback-modal-title");
1416
- const g = () => Math.min(e5.length + 1, s2), y = () => {
1417
- v.textContent = `${l("selectOptionNumber")}${g()}`;
1418
- };
1419
- y();
1420
- const b = document.createElement("div");
1421
- b.classList.add("magicfeedback-modal-list"), (n2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4]).forEach(((t5) => {
1422
- const n3 = document.createElement("label");
1423
- n3.classList.add("magicfeedback-modal-row");
1424
- const r4 = document.createElement("input");
1425
- r4.type = "checkbox", r4.classList.add("magicfeedback-input"), r4.name = `${i2}-selection`, r4.value = t5;
1426
- const a4 = document.createElement("span");
1427
- a4.textContent = t5, r4.addEventListener("change", (() => {
1428
- if (r4.checked) {
1429
- if (e5.length >= s2) return r4.checked = false, n3.classList.add("magicfeedback-warning"), void setTimeout((() => {
1430
- n3.classList.remove("magicfeedback-warning");
1431
- }), 800);
1432
- e5.push(t5);
1433
- } else {
1434
- const i3 = e5.indexOf(t5);
1435
- -1 !== i3 && e5.splice(i3, 1);
1436
- }
1437
- y(), A();
1438
- })), n3.appendChild(r4), n3.appendChild(a4), b.appendChild(n3);
1439
- }));
1440
- const E = document.createElement("div");
1441
- E.classList.add("magicfeedback-modal-actions");
1442
- const k = document.createElement("div");
1443
- k.classList.add("magicfeedback-modal-counter");
1444
- const A = () => {
1445
- const t5 = l("of");
1446
- k.textContent = `${l("prioritized")} ${e5.length} ${t5} ${s2}`, a3.style.display = e5.length > 0 ? "block" : "none";
1447
- };
1448
- A();
1449
- const C = document.createElement("button");
1450
- 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", C.addEventListener("click", (() => {
1451
- h.style.display = "none";
1452
- }));
1453
- const T = document.createElement("button");
1454
- return T.type = "button", T.textContent = l("confirm"), T.classList.add("magicfeedback-button"), T.classList.add("magicfeedback-button-primary"), T.addEventListener("click", (() => {
1455
- h.style.display = "none", m();
1456
- })), E.appendChild(k), E.appendChild(T), f.appendChild(C), f.appendChild(v), f.appendChild(b), f.appendChild(E), h.appendChild(f), c2.addEventListener("click", (() => {
1457
- h.style.display = "flex", y(), A();
1458
- })), h.addEventListener("click", ((e6) => {
1459
- e6.target === h && (h.style.display = "none");
1460
- })), d.appendChild(r3), d.appendChild(u2), d.appendChild(h), m(), d;
1461
- }
1462
- const c = document.createElement("ul");
1463
- c.classList.add("magicfeedback-priority-list-list");
1464
- const u = n2 ? [...t4].sort((() => Math.random() - 0.5)) : [...t4];
1465
- return u.forEach(((e5, t5) => {
1466
- const n3 = document.createElement("li");
1467
- n3.classList.add("magicfeedback-priority-list-item"), n3.style.display = "flex", n3.style.justifyContent = "space-between", n3.style.alignItems = "center", n3.style.margin = "5px";
1468
- const r3 = document.createElement("input");
1469
- 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);
1470
- const s3 = document.createElement("label");
1471
- s3.classList.add("magicfeedback-priority-list-item-label"), s3.textContent = `${t5 + 1}. ${e5}`, n3.appendChild(s3);
1472
- const a3 = document.createElement("div");
1473
- a3.style.display = "flex", a3.style.alignItems = "center", a3.style.justifyContent = "space-between";
1474
- const o3 = document.createElement("img");
1475
- o3.classList.add("magicfeedback-priority-list-arrow-up"), o3.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", o3.style.width = "20px", o3.style.height = "20px", o3.style.cursor = "pointer", o3.style.margin = "0 5px", o3.style.color = "#000", o3.style.visibility = 0 === t5 ? "hidden" : "visible", o3.addEventListener("click", (() => {
1476
- var t6, i3, a4, d2;
1477
- const p = n3.previousElementSibling;
1478
- if (p) {
1479
- const m = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) - 1;
1480
- r3.value = `${m}. ${e5}`, s3.textContent = `${m}. ${e5}`, o3.style.visibility = 1 === m ? "hidden" : "visible", l2.style.visibility = m === u.length ? "hidden" : "visible";
1481
- const h = p.querySelector(".magicfeedback-input-magicfeedback-priority-list"), f = p.querySelector(".magicfeedback-priority-list-item-label"), v = p.querySelector(".magicfeedback-priority-list-arrow-up"), g = p.querySelector(".magicfeedback-priority-list-arrow-down");
1482
- if (h && f && v && g) {
1483
- const e6 = Number(null === (i3 = h.value) || void 0 === i3 ? void 0 : i3.split(".")[0]) + 1;
1484
- h.value = `${e6}.${null === (a4 = f.textContent) || void 0 === a4 ? void 0 : a4.split(".")[1]}`, f.textContent = `${e6}.${null === (d2 = f.textContent) || void 0 === d2 ? void 0 : d2.split(".")[1]}`, v.style.visibility = 1 === e6 ? "hidden" : "visible", g.style.visibility = e6 === u.length ? "hidden" : "visible";
1485
- }
1486
- c.insertBefore(n3, p);
1487
- }
1488
- }));
1489
- const l2 = document.createElement("img");
1490
- 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", (() => {
1491
- var t6, i3, a4;
1492
- const d2 = n3.nextElementSibling;
1493
- if (d2) {
1494
- const p = Number(null === (t6 = r3.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) + 1;
1495
- r3.value = `${p}. ${e5}`, s3.textContent = `${p}. ${e5}`, o3.style.visibility = 1 === p ? "hidden" : "visible", l2.style.visibility = p === u.length ? "hidden" : "visible";
1496
- const m = d2.querySelector(".magicfeedback-input-magicfeedback-priority-list"), h = d2.querySelector(".magicfeedback-priority-list-item-label"), f = d2.querySelector(".magicfeedback-priority-list-arrow-up"), v = d2.querySelector(".magicfeedback-priority-list-arrow-down");
1497
- if (m && h && f && v) {
1498
- const e6 = Number(m.value.split(".")[0]) - 1;
1499
- m.value = `${e6}.${null === (i3 = h.textContent) || void 0 === i3 ? void 0 : i3.split(".")[1]}`, h.textContent = `${e6}.${null === (a4 = h.textContent) || void 0 === a4 ? void 0 : a4.split(".")[1]}`, f.style.visibility = 1 === e6 ? "hidden" : "visible", v.style.visibility = e6 === u.length ? "hidden" : "visible";
1500
- }
1501
- c.insertBefore(d2, n3);
1502
- }
1503
- })), a3.appendChild(o3), a3.appendChild(l2), n3.appendChild(a3), c.appendChild(n3);
1504
- })), d.appendChild(c), d;
1505
- })({ 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" });
1506
- return a.appendChild(o), { element: a, elementTypeClass: "magicfeedback-priority-list" };
1507
- };
1508
- }, 152: (e2, t2, i) => {
1509
- "use strict";
1510
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingEmoji = void 0;
1511
- const n = i(559), r = "https://survey-dev.magicfeedback.io/assets/emojis";
1512
- t2.renderRatingEmoji = ({ question: e3, url: t3, send: i2, urlParamValue: s }) => {
1513
- var a;
1514
- const { ref: o, assets: l } = e3, d = document.createElement("div"), c = "magicfeedback-rating", u = document.createElement("div");
1515
- u.classList.add("magicfeedback-rating-container");
1516
- const p = (null == l ? void 0 : l.max) ? Number(null == l ? void 0 : l.max) : 5, m = (null == l ? void 0 : l.min) ? Number(null == l ? void 0 : l.min) : 1, h = (0, n.createRatingPlaceholder)(m, p, null == l ? void 0 : l.minPlaceholder, null == l ? void 0 : l.maxPlaceholder, null !== (a = null == l ? void 0 : l.extraOption) && void 0 !== a && a);
1517
- for (let e4 = m; e4 <= p; e4++) {
1518
- const n2 = document.createElement("div");
1519
- n2.classList.add("magicfeedback-rating-option");
1520
- const a2 = document.createElement("label");
1521
- a2.htmlFor = `rating-${o}-${e4}`, a2.classList.add("magicfeedback-rating-option-label-container");
1522
- const l2 = document.createElement("label");
1523
- l2.htmlFor = `rating-${o}-${e4}`, l2.textContent = e4.toString();
1524
- const d2 = document.createElement("img");
1525
- if (d2.alt = `face-${o}-${e4}`, d2.className = `rating-image${e4}`, 0 === m && 10 === p) d2.src = `${t3}/${e4}.svg`, d2.onerror = () => d2.src = `${r}/${e4}.svg`;
1526
- else if (1 === m && 5 === p) switch (e4) {
1527
- case 1:
1528
- d2.src = `${t3}/1.svg`, d2.onerror = () => d2.src = `${r}/1.svg`;
1529
- break;
1530
- case 2:
1531
- d2.src = `${t3}/2.svg`, d2.onerror = () => d2.src = `${r}/2.svg`;
1532
- break;
1533
- case 3:
1534
- d2.src = `${t3}/6.svg`, d2.onerror = () => d2.src = `${r}/6.svg`;
1535
- break;
1536
- case 4:
1537
- d2.src = `${t3}/9.svg`, d2.onerror = () => d2.src = `${r}/9.svg`;
1538
- break;
1539
- case 5:
1540
- d2.src = `${t3}/10.svg`, d2.onerror = () => d2.src = `${r}/10.svg`;
1541
- }
1542
- else {
1543
- const i3 = Math.round(10 / (p - m) * (e4 - m));
1544
- d2.src = `${t3}/${i3}.svg`, d2.onerror = () => d2.src = `${r}/${i3}.svg`;
1545
- }
1546
- const h2 = document.createElement("input");
1547
- h2.id = `rating-${o}-${e4}`, h2.type = "radio", h2.name = o, h2.value = e4.toString(), h2.classList.add(c), h2.classList.add("magicfeedback-input"), i2 && h2.addEventListener("change", (() => {
1548
- i2();
1549
- })), s && s === h2.value && (h2.checked = true), a2.appendChild(h2), a2.appendChild(d2), a2.appendChild(l2), n2.appendChild(a2), u.appendChild(n2);
1550
- }
1551
- if ((null == l ? void 0 : l.extraOption) && (null == l ? void 0 : l.extraOptionText)) {
1552
- const e4 = document.createElement("div");
1553
- e4.classList.add("magicfeedback-rating-option");
1554
- const t4 = document.createElement("label");
1555
- t4.htmlFor = `rating-${o}-extra`, t4.classList.add("magicfeedback-rating-option-label-container");
1556
- const n2 = document.createElement("label");
1557
- n2.htmlFor = `rating-${o}-extra`, n2.textContent = null == l ? void 0 : l.extraOptionText;
1558
- const r2 = document.createElement("img");
1559
- r2.src = "https://magicfeedback-c6458-dev.web.app/assets/question.svg", r2.alt = `face-${o}-extra`, r2.className = "magicfeedback-rating-image-extra";
1560
- const s2 = document.createElement("input");
1561
- s2.id = `rating-${o}-extra`, s2.type = "radio", s2.name = o, s2.value = "-", s2.classList.add(c), s2.classList.add("magicfeedback-input"), i2 && s2.addEventListener("change", (() => {
1562
- i2();
1563
- })), t4.appendChild(s2), t4.appendChild(r2), t4.appendChild(n2), e4.appendChild(t4), u.appendChild(e4);
1564
- }
1565
- return h.childElementCount > 0 && (u.classList.add("magicfeedback-rating-container--with-placeholder"), u.insertBefore(h, u.firstChild)), d.appendChild(u), { element: d, elementTypeClass: c };
1566
- };
1567
- }, 917: (e2, t2, i) => {
1568
- "use strict";
1569
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingNumber = void 0;
1570
- const n = i(559);
1571
- t2.renderRatingNumber = ({ question: e3, order: t3, direction: i2, isPhone: r, send: s, urlParamValue: a }) => {
1572
- const o = "magicfeedback-rating-number";
1573
- return { element: (0, n.createRatingNumberElement)(e3.ref, e3.assets, t3, i2, r, o, s, a), elementTypeClass: o };
1574
- };
1575
- }, 452: (e2, t2, i) => {
1576
- "use strict";
1577
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderRatingStar = void 0;
1578
- const n = i(559);
1579
- t2.renderRatingStar = ({ question: e3, send: t3, urlParamValue: i2 }) => {
1580
- var r, s;
1581
- const a = document.createElement("div"), o = (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);
1582
- return a.appendChild(o), { element: a, elementTypeClass: "magicfeedback-rating-star" };
1583
- };
1584
- }, 85: (e2, t2, i) => {
1585
- "use strict";
1586
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderSelect = void 0;
1587
- const n = i(516);
1588
- t2.renderSelect = ({ question: e3, format: t3, language: i2, urlParamValue: r, send: s }) => {
1589
- const { title: a, value: o, defaultValue: l } = e3, d = document.createElement("select"), c = document.createElement("option");
1590
- return c.value = "", c.text = "slim" === t3 ? (0, n.parseTitle)(a, i2) : l || "Select an option", c.disabled = true, c.selected = true, d.appendChild(c), o.forEach(((e4) => {
1591
- const t4 = document.createElement("option");
1592
- t4.value = e4, t4.text = e4, d.appendChild(t4);
1593
- })), r && o.includes(r) && (d.value = r), s && d.addEventListener("change", (() => {
1594
- s();
1595
- })), { element: d, elementTypeClass: "magicfeedback-select" };
1596
- };
1597
- }, 90: (e2, t2, i) => {
1598
- "use strict";
1599
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderText = void 0;
1600
- const n = i(784);
1601
- t2.renderText = ({ language: e3, placeholderText: t3, urlParamValue: i2, send: r }) => {
1602
- const s = document.createElement("input");
1603
- return s.type = "text", s.placeholder = t3 || n.placeholder.answer(e3 || "en"), i2 && (s.value = i2), s.addEventListener("keyup", ((e4) => {
1604
- e4.preventDefault(), "Enter" === e4.key && r && r();
1605
- })), { element: s, elementTypeClass: "magicfeedback-text" };
1606
- };
1607
- }, 250: (e2, t2) => {
1608
- "use strict";
1609
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadFile = void 0, t2.renderUploadFile = ({ question: e3 }) => {
1610
- var t3, i;
1611
- const n = document.createElement("input");
1612
- return n.type = "file", n.required = e3.require, n.multiple = (null === (t3 = e3.assets) || void 0 === t3 ? void 0 : t3.multiple) || false, n.maxLength = (null === (i = e3.assets) || void 0 === i ? void 0 : i.maxFiles) || 1, { element: n, elementTypeClass: "magicfeedback-upload-file" };
1613
- };
1614
- }, 843: (e2, t2) => {
1615
- "use strict";
1616
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderUploadImage = void 0, t2.renderUploadImage = ({ question: e3 }) => {
1617
- var t3, i;
1618
- const n = document.createElement("input");
1619
- return n.type = "file", n.accept = "image/*", n.required = e3.require, n.multiple = (null === (t3 = e3.assets) || void 0 === t3 ? void 0 : t3.multiple) || false, n.maxLength = (null === (i = e3.assets) || void 0 === i ? void 0 : i.maxFiles) || 1, { element: n, elementTypeClass: "magicfeedback-upload-image" };
1620
- };
1621
- }, 857: (e2, t2) => {
1622
- "use strict";
1623
- 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" } };
1624
- }, 784: (e2, t2) => {
1625
- "use strict";
1626
- Object.defineProperty(t2, "__esModule", { value: true }), t2.placeholder = void 0, t2.placeholder = { answer: (e3) => {
1627
- switch (e3) {
1628
- case "en":
1629
- default:
1630
- return "Write your answer here...";
1631
- case "es":
1632
- return "Escribe tu respuesta aqu\xED...";
1633
- case "da":
1634
- return "Skriv dit svar her...";
1635
- case "fi":
1636
- return "Kirjoita vastauksesi t\xE4h\xE4n...";
1637
- case "sv":
1638
- return "Skriv ditt svar h\xE4r...";
1639
- case "no":
1640
- return "Skriv svaret ditt her...";
1641
- case "ar":
1642
- return "\u0627\u0643\u062A\u0628 \u0625\u062C\u0627\u0628\u062A\u0643 \u0647\u0646\u0627...";
1643
- case "bn":
1644
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
1645
- }
1646
- }, number: (e3) => {
1647
- switch (e3) {
1648
- case "en":
1649
- default:
1650
- return "Write your number here...";
1651
- case "es":
1652
- return "Escribe tu n\xFAmero aqu\xED...";
1653
- case "da":
1654
- return "Skriv dit nummer her...";
1655
- case "fi":
1656
- return "Kirjoita numerosi t\xE4h\xE4n...";
1657
- case "sv":
1658
- return "Skriv ditt nummer h\xE4r...";
1659
- case "no":
1660
- return "Skriv nummeret ditt her...";
1661
- case "ar":
1662
- return "\u0627\u0643\u062A\u0628 \u0631\u0642\u0645\u0643 \u0647\u0646\u0627...";
1663
- case "bn":
1664
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
1665
- }
1666
- }, email: (e3) => {
1667
- switch (e3) {
1668
- case "en":
1669
- default:
1670
- return "Write your email here...";
1671
- case "es":
1672
- return "Escribe tu correo electr\xF3nico aqu\xED...";
1673
- case "da":
1674
- return "Skriv din e-mail her...";
1675
- case "fi":
1676
- return "Kirjoita s\xE4hk\xF6postiosoitteesi t\xE4h\xE4n...";
1677
- case "sv":
1678
- return "Skriv din e-post h\xE4r...";
1679
- case "no":
1680
- return "Skriv e-posten din her...";
1681
- case "ar":
1682
- return "\u0627\u0643\u062A\u0628 \u0628\u0631\u064A\u062F\u0643 \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A \u0647\u0646\u0627...";
1683
- case "bn":
1684
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
1685
- }
1686
- }, date: (e3) => {
1687
- switch (e3) {
1688
- case "en":
1689
- default:
1690
- return "Write your date here...";
1691
- case "es":
1692
- return "Escribe tu fecha aqu\xED...";
1693
- case "da":
1694
- return "Skriv din dato her...";
1695
- case "fi":
1696
- return "Kirjoita p\xE4iv\xE4m\xE4\xE4r\xE4si t\xE4h\xE4n...";
1697
- case "sv":
1698
- return "Skriv ditt datum h\xE4r...";
1699
- case "no":
1700
- return "Skriv datoen din her...";
1701
- case "ar":
1702
- return "\u0627\u0643\u062A\u0628 \u062A\u0627\u0631\u064A\u062E\u0643 \u0647\u0646\u0627...";
1703
- case "bn":
1704
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
1705
- }
1706
- }, password: (e3) => {
1707
- switch (e3) {
1708
- case "en":
1709
- default:
1710
- return "Write your password here...";
1711
- case "es":
1712
- return "Escribe tu contrase\xF1a aqu\xED...";
1713
- case "da":
1714
- return "Skriv dit kodeord her...";
1715
- case "fi":
1716
- return "Kirjoita salasanasi t\xE4h\xE4n...";
1717
- case "sv":
1718
- return "Skriv ditt l\xF6senord h\xE4r...";
1719
- case "no":
1720
- return "Skriv passordet ditt her...";
1721
- case "ar":
1722
- 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...";
1723
- case "bn":
1724
- return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
1725
- }
1726
- }, pointsystemerror: (e3) => {
1727
- switch (e3) {
1728
- case "en":
1729
- default:
1730
- return "The total points must be 100 %";
1731
- case "es":
1732
- return "El total de puntos debe ser 100 %";
1733
- case "da":
1734
- return "Samlet antal point skal v\xE6re 100 %";
1735
- case "fi":
1736
- return "Kokonaispisteiden on oltava 100 %";
1737
- case "sv":
1738
- return "Totala po\xE4ng m\xE5ste vara 100 %";
1739
- case "no":
1740
- return "Totalt antall poeng m\xE5 v\xE6re 100 %";
1741
- case "ar":
1742
- 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 %";
1743
- case "bn":
1744
- return "\u09AE\u09CB\u099F \u09AA\u09AF\u09BC\u09C7\u09A8\u09CD\u099F 100 % \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7";
1745
- }
1746
- } };
1747
- }, 213: (e2, t2, i) => {
1748
- "use strict";
1749
- Object.defineProperty(t2, "__esModule", { value: true }), t2.renderStartMessage = t2.renderSuccess = t2.renderError = t2.renderActions = t2.renderQuestions = void 0;
1750
- const n = i(42), r = i(516), s = { small: "1rem", medium: "1.2rem", large: "1.5rem" };
1751
- t2.renderQuestions = function e3(t3, i2 = "standard", a = "en", o = { customIcons: false }, l) {
1752
- if (!t3) throw new Error("[MagicFeedback] No questions provided");
1753
- const d = [], { customIcons: c, id: u } = o;
1754
- return t3.forEach(((p) => {
1755
- var m, h;
1756
- if ((null === (h = null === (m = null == p ? void 0 : p.questionType) || void 0 === m ? void 0 : m.conf) || void 0 === h ? void 0 : h.length) > 0) {
1757
- let t4 = document.createElement("div");
1758
- t4.classList.add("magicfeedback-div");
1759
- const n2 = document.createElement("label");
1760
- n2.setAttribute("for", `magicfeedback-${p.id}`), n2.textContent = (0, r.parseTitle)(p.title, a), n2.classList.add("magicfeedback-label"), t4.appendChild(n2), p.questionType.conf.forEach(((e4) => {
1761
- e4.ref = p.ref, p.assets[e4.id] && (e4.assets = { placeholder: p.assets[e4.id] });
1762
- })), e3(p.questionType.conf, i2, a, o, l).forEach(((e4) => {
1763
- t4.appendChild(e4);
1764
- })), d.push(t4);
1765
- } else {
1766
- const e4 = (function(e5, t4, i3, a2, o2) {
1767
- var l2, d2, c2;
1768
- let u2, p2, { id: m2, title: h2, type: f, ref: v, require: g, defaultValue: y, assets: b } = e5, E = document.createElement("div");
1769
- E.classList.add("magicfeedback-div");
1770
- const k = window.innerWidth < 600, A = "slim" === t4 ? (0, r.parseTitle)(h2, i3) : null == b ? void 0 : b.placeholder, C = (0, r.getUrlParam)(v), T = (null == b ? void 0 : b.maxCharacters) || 0, P = void 0 !== (null == b ? void 0 : b.randomPosition) && (null == b ? void 0 : b.randomPosition), w = (null == b ? void 0 : b.direction) || "row", x = (null == b ? void 0 : b.order) || "ltr", O = (0, n.getQuestionRenderer)(f);
1771
- if (!O) return E;
1772
- {
1773
- const n2 = O({ question: e5, format: t4, language: i3, url: a2, send: o2, isPhone: k, urlParamValue: C, placeholderText: A, maxCharacters: T, randomPosition: P, direction: w, order: x });
1774
- u2 = n2.element, p2 = n2.elementTypeClass;
1775
- }
1776
- u2.id = `magicfeedback-${m2}`, u2.setAttribute("name", v), u2.classList.add(p2), (void 0 !== y || null !== C) && (u2.value = C || y), ["RADIO", "MULTIPLECHOICE"].includes(f) || (u2.classList.add("magicfeedback-input"), u2.required = g);
1777
- const L = document.createElement("label");
1778
- L.setAttribute("for", `magicfeedback-${m2}`), L.textContent = (0, r.parseTitle)(h2, i3), L.classList.add("magicfeedback-label"), (function(e6, t5) {
1779
- if ("INFO_PAGE" !== t5.type) return;
1780
- const { assets: i4 } = t5, n2 = (function(e7) {
1781
- if (e7) return s[e7] || e7;
1782
- })(null == i4 ? void 0 : i4.titleSize), r2 = (a3 = null == i4 ? void 0 : i4.titleStyle, Array.isArray(a3) ? a3 : a3 ? [a3] : []);
1783
- var a3;
1784
- 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");
1785
- })(L, e5);
1786
- const S = document.createElement("label");
1787
- 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);
1788
- else {
1789
- 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))) {
1790
- const e6 = document.createElement("img");
1791
- 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);
1792
- }
1793
- if ("LONGTEXT" === f && T > 0) {
1794
- const e6 = document.createElement("div");
1795
- 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", (() => {
1796
- e6.textContent = `${u2.value.length}/${T}`;
1797
- })), E.appendChild(u2), E.appendChild(e6), (null == b ? void 0 : b.extraOption) && (null == b ? void 0 : b.extraOptionText)) {
1798
- const e7 = document.createElement("div");
1799
- e7.classList.add("magicfeedback-skip-container"), e7.classList.add("magicfeedback-checkbox-container"), e7.style.display = "flex", e7.style.justifyContent = "flex-start";
1800
- const t5 = document.createElement("input");
1801
- t5.classList.add("magicfeedback-skip"), t5.type = "checkbox", t5.id = `skip-${v}`, t5.name = v, t5.value = "-", t5.style.cursor = "pointer";
1802
- const i4 = document.createElement("label");
1803
- i4.htmlFor = `skip-${v}`, i4.textContent = null == b ? void 0 : b.extraOptionText, i4.style.fontSize = "15px", i4.style.cursor = "pointer", i4.style.margin = "0 5px", t5.addEventListener("click", (() => {
1804
- u2.value = "-", o2 && o2();
1805
- })), e7.appendChild(t5), e7.appendChild(i4), E.appendChild(e7);
1806
- }
1807
- } else E.appendChild(u2);
1808
- }
1809
- return E;
1810
- })(p, i2, a, "https://survey-dev.magicfeedback.io/assets/emojis" + (c ? `/${u}` : ""), 1 === t3.length ? l : void 0);
1811
- d.push(e4);
1812
- }
1813
- })), d;
1814
- }, t2.renderActions = function(e3 = "", t3, i2 = "Submit", n2 = "Back", r2 = "Next") {
1815
- const s2 = document.createElement("div");
1816
- s2.classList.add("magicfeedback-action-container");
1817
- const a = document.createElement("button");
1818
- a.id = "magicfeedback-submit", a.type = "submit", a.classList.add("magicfeedback-submit"), a.textContent = "MAGICSURVEY" === e3 ? r2 || "Next" : i2 || "Submit";
1819
- const o = document.createElement("button");
1820
- return o.id = "magicfeedback-back", o.type = "button", o.classList.add("magicfeedback-back"), o.textContent = n2 || "Back", o.addEventListener("click", t3), o.addEventListener("click", (() => {
1821
- a.removeAttribute("disabled");
1822
- })), "MAGICSURVEY" === e3 && s2.appendChild(o), s2.appendChild(a), s2;
1823
- }, t2.renderError = function(e3) {
1824
- const t3 = document.createElement("div");
1825
- return t3.classList.add("magicfeedback-error"), t3.textContent = e3, t3;
1826
- }, t2.renderSuccess = function(e3) {
1827
- const t3 = document.createElement("div");
1828
- return t3.classList.add("magicfeedback-success"), t3.textContent = e3, t3;
1829
- }, t2.renderStartMessage = function(e3, t3 = false, i2 = "Go!", n2 = () => {
1830
- }) {
1831
- const r2 = document.createElement("div");
1832
- r2.classList.add("magicfeedback-start-message-container");
1833
- const s2 = document.createElement("div");
1834
- if (s2.classList.add("magicfeedback-start-message"), s2.innerHTML = e3, r2.appendChild(s2), t3) {
1835
- const e4 = document.createElement("button");
1836
- e4.id = "magicfeedback-start-message-button", e4.classList.add("magicfeedback-start-message-button"), e4.textContent = i2, e4.addEventListener("click", (() => n2())), r2.appendChild(e4);
1837
- }
1838
- return r2;
1839
- };
1840
- }, 313: function(e2, t2, i) {
1841
- "use strict";
1842
- var n = this && this.__awaiter || function(e3, t3, i2, n2) {
1843
- return new (i2 || (i2 = Promise))((function(r2, s2) {
1844
- function a2(e4) {
1845
- try {
1846
- l2(n2.next(e4));
1847
- } catch (e5) {
1848
- s2(e5);
1849
- }
1850
- }
1851
- function o2(e4) {
1852
- try {
1853
- l2(n2.throw(e4));
1854
- } catch (e5) {
1855
- s2(e5);
1856
- }
1857
- }
1858
- function l2(e4) {
1859
- var t4;
1860
- e4.done ? r2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
1861
- e5(t4);
1862
- }))).then(a2, o2);
1863
- }
1864
- l2((n2 = n2.apply(e3, t3 || [])).next());
1865
- }));
1866
- }, r = this && this.__importDefault || function(e3) {
1867
- return e3 && e3.__esModule ? e3 : { default: e3 };
1868
- };
1869
- Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.validateEmail = void 0;
1870
- const s = r(i(945)), a = r(i(330)), o = i(857), l = { Accept: "application/json", "Magicfeedback-Sdk-Version": a.default.version, "x-magicfeedback-parameters": window.location.search || "" };
1871
- t2.validateEmail = function(e3) {
1872
- return /\S+@\S+\.\S+/.test(e3);
1873
- }, t2.getForm = function(e3, t3, i2, r2) {
1874
- return n(this, void 0, void 0, (function* () {
1875
- try {
1876
- const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.app_info(t3, i2), { method: "GET", headers: l });
1877
- return yield n2.json();
1878
- } catch (e4) {
1879
- r2.err(e4);
1880
- }
1881
- }));
1882
- }, t2.getSessionForm = function(e3, t3, i2) {
1883
- return n(this, void 0, void 0, (function* () {
1884
- try {
1885
- const i3 = yield (0, s.default)(e3 + o.endpoints.sdk.session(t3), { method: "GET", headers: l });
1886
- return yield i3.json();
1887
- } catch (e4) {
1888
- i2.err(e4);
1889
- }
1890
- }));
1891
- }, t2.getQuestions = function(e3, t3, i2, r2) {
1892
- return n(this, void 0, void 0, (function* () {
1893
- try {
1894
- const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.app(t3, i2), { method: "GET", headers: l });
1895
- if (n2.ok) {
1896
- const e4 = yield n2.json();
1897
- return r2.log(`Received questions for app ${t3}`, e4), e4;
1898
- }
1899
- throw r2.err(`Failed to get questions for app ${t3}:`, n2.status, n2.statusText), new Error("[MagicFeedback] Bad response from server");
1900
- } catch (e4) {
1901
- return r2.err(e4), [];
1902
- }
1903
- }));
1904
- }, t2.sendFeedback = function(e3, t3, i2) {
1905
- return n(this, void 0, void 0, (function* () {
1906
- try {
1907
- const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.feedback, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, l), body: JSON.stringify(t3) });
1908
- if (n2.ok) return i2.log(`Form ${t3.integration} submitted successfully!`), (yield n2.json()).sessionId;
1909
- throw i2.err(`Failed to submit form ${t3.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
1910
- } catch (e4) {
1911
- return i2.err(e4), "";
1912
- }
1913
- }));
1914
- }, t2.getFollowUpQuestion = function(e3, t3, i2) {
1915
- return n(this, void 0, void 0, (function* () {
1916
- try {
1917
- const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.followUpQuestion, { method: "POST", headers: Object.assign({ "Content-Type": "application/json" }, l), body: JSON.stringify(t3) });
1918
- if (n2.ok) return i2.log(`Received follow up question for form ${t3.integration}`), (yield n2.json()) || "";
1919
- throw i2.err(`Failed to get follow up question for form ${t3.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
1920
- } catch (e4) {
1921
- return i2.err(e4), "";
1922
- }
1923
- }));
1924
- };
1925
- }, 256: (e2, t2) => {
1926
- "use strict";
1927
- Object.defineProperty(t2, "__esModule", { value: true }), t2.Log = void 0, t2.Log = class {
1928
- constructor(e3) {
1929
- this.config = e3;
1930
- }
1931
- log(...e3) {
1932
- this.config.get("debug") && console.log("[MagicFeedback]:", ...e3);
1933
- }
1934
- err(...e3) {
1935
- console.error("[MagicFeedback]:", ...e3);
1936
- }
1937
- };
1938
- }, 330: (e2) => {
1939
- "use strict";
1940
- e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.2.1","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"}');
1941
- } }, t = {}, (function i(n) {
1942
- var r = t[n];
1943
- if (void 0 !== r) return r.exports;
1944
- var s = t[n] = { exports: {} };
1945
- return e[n].call(s.exports, s, s.exports, i), s.exports;
1946
- })(156).default;
1947
- var e, t;
1948
- }));
1949
- }
1950
- });
1951
-
1952
- // src/types/index.ts
1953
- var POPUP_TRIGGER_CONDITION_STATUSES = [
1954
- "SHOWED",
1955
- "PARTIAL",
1956
- "COMPLETED"
1957
- ];
1958
-
1959
- // src/ui/renderPopup.ts
1960
- var import_native = __toESM(require_magicfeedback_sdk_browser());
1961
-
1962
- // src/assets/style.css
1963
- var style_default = `.magicfeedback-container {
1964
- width: 100%;
1965
- }
1966
-
1967
-
1968
- .magicfeedback-success-message,
1969
- .magicfeedback-info-message,
1970
- .magicfeedback-start-message,
1971
- .magicfeedback-container{
1972
- animation-duration: 0.5s;
1973
- animation-name: animate-fade;
1974
- animation-delay: 0.25s;
1975
- animation-fill-mode: backwards;
1976
-
1977
- font-style: normal;
1978
- text-align: justify;
1979
- font-weight: 400;
1980
- font-size: 1.2rem;
1981
- color: #475569;
1982
- line-height: 1.5;
1983
- }
1984
-
1985
- @keyframes animate-fade {
1986
- 0% { opacity: 0; }
1987
- 100% { opacity: 1; }
1988
- }
1989
-
1990
- .magicfeedback-form {
1991
- display: flex;
1992
- flex-direction: column;
1993
- justify-content: flex-start;
1994
- align-items: center;
1995
- width: 100%;
1996
- }
1997
- .magicfeedback-questions {
1998
- display: flex;
1999
- flex-direction: column;
2000
- justify-content: flex-start;
2001
- align-items: flex-start;
2002
- width: 100%;
2003
- }
2004
-
2005
- .magicfeedback-div {
2006
- display: flex;
2007
- flex-direction: column;
2008
- justify-content: flex-start;
2009
- align-items: flex-start;
2010
- margin-bottom: 10px;
2011
- width: 100%;
2012
- }
2013
-
2014
- .magicfeedback-label {
2015
- margin-bottom: 25px;
2016
- margin-top: 20px;
2017
- font-weight: 400;
2018
- font-family: inherit;
2019
- font-size: 1.2rem;
2020
- color: #212529;
2021
- text-align: start;
2022
- word-wrap: break-word;
2023
- white-space: normal;
2024
-
2025
- }
2026
-
2027
- .magicfeedback-checkbox {
2028
- display: flex;
2029
- flex-direction: column;
2030
- flex-wrap: wrap;
2031
- width: 100%;
2032
- }
2033
-
2034
- .magicfeedback-checkbox-container {
2035
- display: flex;
2036
- flex-direction: row;
2037
- justify-content: flex-start;
2038
- align-items: center;
2039
- margin-bottom: 5px;
2040
- margin-top: 5px;
2041
- }
2042
-
2043
- .magicfeedback-radio {
2044
- display: flex;
2045
- flex-direction: column;
2046
- justify-content: flex-start;
2047
- flex-wrap: wrap;
2048
- width: 100%;
2049
- margin-right: 5px;
2050
- padding: 5px;
2051
- }
2052
-
2053
- .magicfeedback-checkbox-container,
2054
- .magicfeedback-radio-container {
2055
- display: flex;
2056
- flex-direction: row;
2057
- justify-content: flex-start;
2058
- align-items: center;
2059
- margin: 5px;
2060
- padding: 5px 0;
2061
- background-color: #fff;
2062
- border-radius: 5px;
2063
- box-shadow: 0 0 3px #ccc;
2064
- }
2065
-
2066
- .deepdots-popup input::-webkit-outer-spin-button,
2067
- .deepdots-popup input::-webkit-inner-spin-button {
2068
- -webkit-appearance: none;
2069
- -moz-appearance: textfield;
2070
- }
2071
-
2072
- .magicfeedback-checkbox input[type="checkbox"] {
2073
- margin-right: 5px;
2074
- margin-left: 5px;
2075
- width: 20px;
2076
- height: 20px;
2077
- cursor: pointer;
2078
- }
2079
-
2080
-
2081
- .magicfeedback-checkbox label,
2082
- .magicfeedback-radio-container label {
2083
- margin-left: 5px;
2084
- font-weight: 400;
2085
- font-family: inherit;
2086
- font-size: 16px;
2087
- color: #212529;
2088
- text-align: start;
2089
- width: 100%;
2090
- }
2091
-
2092
- .deepdots-popup p {
2093
- margin-bottom: 0px;
2094
- font-size: 12px;
2095
- }
2096
-
2097
- .deepdots-popup h2 {
2098
- line-height: 1.66;
2099
- margin: 0;
2100
- padding: 0;
2101
- font-weight: 900;
2102
- color: #222;
2103
- font-family: 'Montserrat';
2104
- font-size: 18px;
2105
- text-transform: uppercase;
2106
- text-align: center;
2107
- margin-bottom: 40px;
2108
- }
2109
-
2110
- .deepdots-popup h6 {
2111
- margin-bottom: 1rem;
2112
- }
2113
-
2114
- .deepdots-popup input[type="date"],
2115
- .deepdots-popup input[type="text"],
2116
- .deepdots-popup input[type="number"],
2117
- .deepdots-popup input[type="email"],
2118
- .deepdots-popup input[type="password"],
2119
- .deepdots-popup textarea,
2120
- .deepdots-popup select {
2121
- box-sizing: border-box;
2122
- padding: 10px;
2123
- margin: 10px 0;
2124
- width: 100%;
2125
- border: 2px solid #ccc; /* Default border color - you can customize this */
2126
- border-radius: 5px;
2127
- font-size: 18px;
2128
- outline: none;
2129
- transition: border-color 0.3s ease;
2130
- min-height: 50px;
2131
- font-family: inherit;
2132
- -webkit-appearance: none;
2133
- }
2134
-
2135
- .deepdots-popup select {
2136
- background-image: linear-gradient(45deg, transparent 50%, gray 50%),
2137
- linear-gradient(135deg, gray 50%, transparent 50%),
2138
- linear-gradient(to right, #ccc, #ccc);
2139
- background-position: calc(100% - 20px) calc(1em + 2px),
2140
- calc(100% - 15px) calc(1em + 2px),
2141
- calc(100% - 2.5em) 0.5em;
2142
- background-size: 5px 5px,
2143
- 5px 5px,
2144
- 1px 1.5em;
2145
- background-repeat: no-repeat;
2146
- }
2147
-
2148
- .magicfeedback-boolean-container {
2149
- display: flex;
2150
- flex-direction: row;
2151
- justify-content: flex-start;
2152
- align-items: center;
2153
- margin: 10px 0;
2154
- width: 100%;
2155
- }
2156
-
2157
- .magicfeedback-boolean-container label {
2158
- margin-left: 10px;
2159
- font-weight: 400;
2160
- font-size: 16px;
2161
- width: 100%;
2162
- padding-top: 5px;
2163
- }
2164
-
2165
- .magicfeedback-boolean-option {
2166
- margin-right: 10px;
2167
- margin-left: 10px;
2168
- width: 100%;
2169
- height: 38px;
2170
- border-radius: 8px;
2171
- font-size: 16px;
2172
- cursor: pointer;
2173
- border: 1px solid #ced4da !important;
2174
- }
2175
-
2176
- .magicfeedback-boolean-option label {
2177
- font-weight: 400;
2178
- font-size: 16px;
2179
- color: #475569;
2180
- cursor: pointer;
2181
- width: 100%;
2182
- height: 100%;
2183
- display: flex;
2184
- justify-content: center;
2185
- align-items: center;
2186
- border-radius: inherit;
2187
- }
2188
-
2189
- .magicfeedback-boolean-option input[type=radio] + label:hover {
2190
- color: #007bff;
2191
- }
2192
-
2193
- .magicfeedback-boolean-option input[type=radio]:checked + label {
2194
- color: #007bff;
2195
- background-color: #cadff8;
2196
- }
2197
-
2198
- .deepdots-popup input[type="radio"] {
2199
- padding: 20px;
2200
- margin: 10px 0 10px 15px;
2201
- width: 40px;
2202
- background-color: #fff;
2203
- box-shadow: none;
2204
- }
2205
-
2206
- /* Style for focused input/select */
2207
- .deepdots-popup input:focus, .deepdots-popup select:focus {
2208
- border-color: #4CAF50; /* Highlight color when focused - you can customize this */
2209
- }
2210
-
2211
- /* Style for invalid input (example: validation error) */
2212
- .deepdots-popup input.error, .deepdots-popup select.error {
2213
- border-color: #ff3333; /* Red color for error state - you can customize this */
2214
- }
2215
-
2216
- .magicfeedback-action-container {
2217
- display: flex;
2218
- flex-direction: row;
2219
- justify-content: space-between;
2220
- align-items: center;
2221
- margin-top: 10px;
2222
- width: 100%;
2223
- }
2224
-
2225
- .magicfeedback-action-container .magicfeedback-submit {
2226
- cursor: pointer;
2227
- padding: 10px;
2228
- margin: 10px 0;
2229
- width: 100px;
2230
- border-radius: 8px;
2231
- font-size: 16px;
2232
- outline: none;
2233
- transition: border-color 0.3s ease;
2234
- background-color: #1E293B;
2235
- color: white;
2236
- }
2237
-
2238
- .magicfeedback-action-container .magicfeedback-back {
2239
- cursor: pointer;
2240
- padding: 10px;
2241
- margin: 10px 0;
2242
- width: 100px;
2243
- border: 0;
2244
- border-radius: 8px;
2245
- font-size: 16px;
2246
- outline: none;
2247
- transition: border-color 0.3s ease;
2248
- background-color: transparent;
2249
- color: #212529;
2250
- }
2251
-
2252
-
2253
-
2254
- /* Rating styles */
2255
- .magicfeedback-rating {
2256
- width: 100%;
2257
- }
2258
-
2259
- .magicfeedback-rating-container {
2260
- display: flex;
2261
- flex-direction: row;
2262
- justify-content: space-around;
2263
- flex-wrap: wrap;
2264
- align-items: center;
2265
-
2266
- margin: 15px 5px;
2267
- padding: 0;
2268
-
2269
- list-style: none;
2270
- font-size: 1.5rem;
2271
- cursor: pointer;
2272
- user-select: none;
2273
- -webkit-user-select: none;
2274
- -moz-user-select: none;
2275
- -ms-user-select: none;
2276
- }
2277
-
2278
- .magicfeedback-rating-placeholder-value,
2279
- .magicfeedback-rating-placeholder{
2280
- text-align: center;
2281
- align-content: center;
2282
- justify-content: center;
2283
- text-wrap: wrap;
2284
- }
2285
-
2286
- .magicfeedback-rating-option {
2287
- margin: 0 0.5rem;
2288
- padding: 0;
2289
- }
2290
-
2291
- @media (max-width: 1024px) {
2292
- .magicfeedback-rating-option {
2293
- margin: 10px 0;
2294
- padding: 0;
2295
- width: 20%;
2296
- display: flex;
2297
- justify-content: center;
2298
- }
2299
-
2300
- .magicfeedback-rating-placeholder-value {
2301
- font-size: 0.75rem;
2302
- margin-bottom: 1px;
2303
- }
2304
- .magicfeedback-rating-placeholder{
2305
- justify-content: center;
2306
- }
2307
-
2308
- .magicfeedback-rating-container {
2309
- flex-wrap: wrap;
2310
- justify-content: flex-start;
2311
- }
2312
- }
2313
-
2314
-
2315
- .magicfeedback-rating-option-label-container {
2316
- display: flex;
2317
- flex-direction: column;
2318
- }
2319
-
2320
-
2321
- .magicfeedback-rating-option-label-container label {
2322
- display: inline-block;
2323
- text-align: center;
2324
- margin-bottom: 0;
2325
- font-weight: 600;
2326
- font-size: 18px;
2327
- color: #475569;
2328
- }
2329
-
2330
- .magicfeedback-rating-option-label-container input[type=radio] {
2331
- position: absolute;
2332
- opacity: 0;
2333
- width: 0;
2334
- height: 0;
2335
- }
2336
-
2337
- /* IMAGE STYLES */
2338
- .magicfeedback-rating-option-label-container input[type=radio] + img {
2339
- cursor: pointer;
2340
- height: 48px;
2341
- width: 48px;
2342
- }
2343
-
2344
- /* LABEL STYLES */
2345
- .magicfeedback-rating-option-label-container input[type=radio] + label {
2346
- cursor: pointer;
2347
- }
2348
-
2349
- /* CHECKED STYLES */
2350
- .magicfeedback-rating-option-label-container input[type=radio]:checked + img {
2351
- box-shadow: #007bff 0px 1px 4px, #007BFFA0 0px 0px 0px 2px;
2352
- border-radius: 50%;
2353
- }
2354
-
2355
- .magicfeedback-rating-number {
2356
- width: 100%;
2357
- }
2358
- .magicfeedback-rating-container,
2359
- .magicfeedback-rating-number-container {
2360
- display: flex;
2361
- flex-direction: row;
2362
- justify-content: space-between;
2363
- align-items: center;
2364
-
2365
- margin: 15px 0;
2366
- padding: 0;
2367
-
2368
- list-style: none;
2369
- font-size: 1.5rem;
2370
- cursor: pointer;
2371
- user-select: none;
2372
- -webkit-user-select: none;
2373
- -moz-user-select: none;
2374
- -ms-user-select: none;
2375
- }
2376
-
2377
- /* Cuando hay placeholders (Very bad / Very good), el placeholder ocupa
2378
- el 100% de la primera l\xEDnea y los boxes bajan a la siguiente */
2379
- .magicfeedback-rating-number-container--with-placeholder {
2380
- flex-wrap: wrap;
2381
- align-items: flex-start;
2382
- }
2383
-
2384
- .magicfeedback-rating-number-container--with-placeholder .magicfeedback-rating-placeholder {
2385
- width: 100%;
2386
- margin-bottom: 8px;
2387
- }
2388
-
2389
- .magicfeedback-rating-number-container--with-placeholder .magicfeedback-rating-number-option {
2390
- width: auto;
2391
- flex: 1;
2392
- }
2393
-
2394
- .magicfeedback-rating-number-option {
2395
- display: flex;
2396
- flex-direction: row;
2397
- justify-content: flex-start;
2398
- align-items: center;
2399
- margin: 5px;
2400
- padding: 0;
2401
- list-style: none;
2402
- font-size: 1.5rem;
2403
- cursor: pointer;
2404
- user-select: none;
2405
- -webkit-user-select: none;
2406
- -moz-user-select: none;
2407
- -ms-user-select: none;
2408
- width: 100%;
2409
- }
2410
-
2411
- .magicfeedback-rating-number-option-row{
2412
- max-width: 100% !important;
2413
- }
2414
-
2415
- .magicfeedback-rating-number-top-placeholder,
2416
- .magicfeedback-rating-number-bottom-placeholder{
2417
- text-align: center !important;
2418
- align-content: center;
2419
- justify-content: center;
2420
- text-wrap: wrap;
2421
-
2422
- font-size: 15px;
2423
- color: #475569;
2424
-
2425
- width: 100%;
2426
- margin: auto;
2427
- }
2428
-
2429
- @media (min-width: 650px) {
2430
- .magicfeedback-rating-number-option-row +.magicfeedback-rating-number-container-ltr:first-child,
2431
- .magicfeedback-rating-number-option-row + +.magicfeedback-rating-number-container-rtl:last-child {
2432
- margin-left: 0;
2433
- width: calc(100% - 10px);
2434
- }
2435
-
2436
- .magicfeedback-rating-number-option-row +.magicfeedback-rating-number-container-rtl:first-child,
2437
- .magicfeedback-rating-number-option-row + +.magicfeedback-rating-number-container-ltr:last-child {
2438
- margin-right: 0;
2439
- width: calc(100% - 10px);
2440
- }
2441
- }
2442
-
2443
-
2444
- .magicfeedback-rating-number-option-label-container {
2445
- display: flex;
2446
- flex-direction: column;
2447
- align-items: center;
2448
- justify-content: center;
2449
- width: 100%;
2450
- height: 100%;
2451
- }
2452
-
2453
- .magicfeedback-rating-number-option-label-container label {
2454
- display: flex;
2455
- align-items: center;
2456
- justify-content: center;
2457
- white-space: nowrap;
2458
- overflow: hidden;
2459
- text-overflow: ellipsis;
2460
- margin: 0 10px;
2461
- font-weight: 600;
2462
- font-size: 14px;
2463
- color: #475569;
2464
- cursor: pointer;
2465
- width: 100%;
2466
- height: 100%;
2467
- min-height: 50px;
2468
- text-align: center;
2469
- padding: 0;
2470
- border-radius: 4px;
2471
- border: 1px solid #ced4da;
2472
- background-color: rgba(246, 246, 246, 0.3);
2473
- transition: background-color 0.15s ease-in-out;
2474
- }
2475
-
2476
- .magicfeedback-rating-number-option-label-container input[type=radio] {
2477
- position: absolute;
2478
- opacity: 0;
2479
- width: 0;
2480
- height: 0;
2481
- }
2482
-
2483
- .magicfeedback-rating-number-option-label-container input[type=radio] + label {
2484
- cursor: pointer;
2485
- }
2486
-
2487
- .magicfeedback-rating-number-option-label-container input[type=radio] + label:hover,
2488
- .magicfeedback-rating-number-option-label-container input[type=radio]:checked + label {
2489
- color: #007bff;
2490
- border: 1px solid #007bff;
2491
- background-color: rgba(86, 168, 253, 0.29);
2492
- }
2493
-
2494
- .magicfeedback-rating-number-container-column{
2495
- align-items: flex-start !important;
2496
- }
2497
-
2498
- @media (max-width: 650px) {
2499
- .magicfeedback-rating-number-container-ltr {
2500
- justify-content: center;
2501
- flex-wrap: wrap;
2502
- }
2503
-
2504
- .magicfeedback-rating-number-container-rtl {
2505
- justify-content: center;
2506
- flex-wrap: wrap-reverse;
2507
- }
2508
-
2509
- .magicfeedback-rating-number-option {
2510
- max-width: 100%;
2511
- height: 55px;
2512
- margin: 5px 0;
2513
- }
2514
- }
2515
-
2516
- .magicfeedback-rating-star {
2517
- width: 100%;
2518
- }
2519
-
2520
- .magicfeedback-rating-star-container {
2521
- display: flex !important;
2522
- flex-direction: row !important;
2523
- justify-content: center !important;
2524
- align-items: center !important;
2525
- flex-wrap: wrap;
2526
- margin: 15px 5px;
2527
- padding: 0;
2528
- list-style: none;
2529
- font-size: 1.5rem;
2530
- cursor: pointer;
2531
- user-select: none;
2532
- -webkit-user-select: none;
2533
- -moz-user-select: none;
2534
- -ms-user-select: none;
2535
- }
2536
-
2537
- .magicfeedback-rating-star-option:not(:checked) > .rating__star {
2538
- float: right;
2539
- width: 1em;
2540
- overflow: hidden;
2541
- white-space: nowrap;
2542
- cursor: pointer;
2543
- font-size: 30px;
2544
- color: #ccc;
2545
- margin: 0 10px;
2546
- }
2547
-
2548
- .magicfeedback-rating-star-option:not(:checked) > .rating__star:hover,
2549
- .magicfeedback-rating-star-option:not(:checked) > .rating__star:hover ~ span {
2550
- color: #deb217 !important;
2551
- }
2552
-
2553
- .magicfeedback-rating-star-selected {
2554
- color: #ffc700 !important;
2555
- }
2556
-
2557
-
2558
- /* Style for multiple choice image */
2559
- .magicfeedback-image-option-label-container:hover {
2560
- cursor: pointer;
2561
- border: 0 !important;
2562
- }
2563
-
2564
- .magicfeedback-image-option-label-container input[type=radio]:checked + img,
2565
- .magicfeedback-image-option-label-container input[type=checkbox]:checked + img {
2566
- border: 1px solid #007bff !important;
2567
- box-shadow: 0 0 3px #007bff !important;
2568
- }
2569
-
2570
- .magicfeedback-image-option-label-container input[type=radio] + img,
2571
- .magicfeedback-image-option-label-container input[type=checkbox] + img {
2572
- border: 1px solid transparent !important;
2573
- }
2574
-
2575
- .magicfeedback-image-option-label-container{
2576
- margin: 10px !important;
2577
- height: calc(100% - 20px) !important;
2578
- width: calc(100% - 20px) !important;
2579
- }
2580
-
2581
- .magicfeedback-multiple-choice-image-option {
2582
- display: flex;
2583
- height: auto !important;
2584
- box-shadow: 0 0 3px #ccc;
2585
- }
2586
-
2587
- .magicfeedback-multiple-choice-image-label {
2588
- font-size: 1rem;
2589
- }
2590
-
2591
- .magicfeedback-consent-container {
2592
- display: flex;
2593
- flex-direction: row;
2594
- justify-content: flex-start;
2595
- align-items: center;
2596
- margin: 10px 0;
2597
- width: 100%;
2598
- }
2599
-
2600
- .magicfeedback-consent-container label {
2601
- margin-left: 10px;
2602
- }
2603
-
2604
- .magicfeedback-start-message-container {
2605
- /* ... add your start message container styles here ... */
2606
- }
2607
-
2608
- .magicfeedback-success-message,
2609
- .magicfeedback-info-message,
2610
- .magicfeedback-start-message {
2611
- margin: 35px 5px;
2612
- }
2613
-
2614
- .magicfeedback-success-message p,
2615
- .magicfeedback-info-message p,
2616
- .magicfeedback-start-message p {
2617
- font-style: normal;
2618
- text-align: start;
2619
- font-weight: 400;
2620
- font-size: 16px;
2621
- color: #475569;
2622
- line-height: 1.5;
2623
- }
2624
-
2625
- .magicfeedback-success-message img,
2626
- .magicfeedback-info-message img,
2627
- .magicfeedback-start-message img {
2628
- width: 400px;
2629
- max-width: 80%;
2630
- height: auto;
2631
- margin: 10px auto;
2632
- }
2633
-
2634
- .magicfeedback-counter,
2635
- .magicfeedback-point-system-total {
2636
- margin: 10px 0 0 0 !important;
2637
- display: flex !important;
2638
- justify-content: right !important;
2639
- align-items: center !important;
2640
- width: 100%;
2641
- }
2642
-
2643
- .magicfeedback-skip-container {
2644
- background-color: transparent !important;
2645
- border: 0 !important;
2646
- color: #999999FF !important;
2647
- padding: 0 !important;
2648
- margin: 0 !important;
2649
- cursor: pointer !important;
2650
- font-size: 0.5em !important;
2651
- font-weight: 400 !important;
2652
- box-shadow: 0 0 0 !important;
2653
-
2654
- &:hover {
2655
- color: #0066ff;
2656
- }
2657
- }
2658
-
2659
- .magicfeedback-skip-container input[type=checkbox] {
2660
- border-color: #999999FF !important;
2661
- border: 0 !important;
2662
- cursor: pointer !important;
2663
-
2664
- }
2665
-
2666
- .magicfeedback-multi-question-matrix,
2667
- .magicfeedback-point-system,
2668
- .magicfeedback-priority-list {
2669
- width: 100% !important;
2670
- }
1
+ import {
2
+ InMemoryStorage,
3
+ STORAGE_KEYS,
4
+ TrackingManager,
5
+ buildSurveyIdentity,
6
+ createDefaultStorage
7
+ } from "./chunk-6WTOQGET.mjs";
2671
8
 
2672
- .magicfeedback-multi-question-matrix-container,
2673
- .magicfeedback-point-system-container,
2674
- .magicfeedback-priority-list-container {
2675
- width: 100% !important;
2676
- overflow-x: auto;
2677
- }
2678
-
2679
- .magicfeedback-point-system-list,
2680
- .magicfeedback-priority-list-list,
2681
- .magicfeedback-multi-question-matrix-table {
2682
- width: 100% !important;
2683
- padding: 0 !important;
2684
- overflow-x: auto;
2685
- }
2686
-
2687
- .magicfeedback-multi-question-matrix {
2688
- position: relative !important;
2689
- }
2690
-
2691
- .magicfeedback-multi-question-matrix-container {
2692
- overflow: auto !important;
2693
- padding-bottom: 10px;
2694
- }
2695
-
2696
- .magicfeedback-multi-question-matrix-label{
2697
- text-align: left !important;
2698
- }
2699
- .magicfeedback-priority-list-item {
2700
- display: flex;
2701
- flex-direction: row;
2702
- justify-content: space-between;
2703
- align-items: center;
2704
- padding: 10px 0 10px 10px;
2705
-
2706
- border: 1px solid #ced4da;
2707
- border-radius: 5px;
2708
- margin: 10px 0 !important;
2709
- }
2710
-
2711
- .magicfeedback-point-system-item {
2712
- height: 45px;
2713
- margin: 5px 0 !important;
2714
- }
2715
-
2716
- .magicfeedback-point-system-item label,
2717
- .magicfeedback-priority-list-item-label {
2718
- font-family: inherit;
2719
- font-size: 18px !important;
2720
- color: #212529;
2721
- text-align: start;
2722
- word-wrap: break-word;
2723
- white-space: normal;
2724
- padding: 0 10px 0 0;
2725
- }
2726
-
2727
- .magicfeedback-point-system-input-container {
2728
- padding: 0 10px 0 0;
2729
- border-radius: 5px;
2730
- font-size: 14px;
2731
- border: 1px solid #ced4da;
2732
- height: 42px;
2733
- margin: auto 0;
2734
- }
2735
-
2736
- .magicfeedback-multi-question-matrix-table thead {
2737
- margin-bottom: 20px;
2738
- }
2739
-
2740
- .magicfeedback-multi-question-matrix-table th{
2741
- text-align: center;
2742
- font-weight: 400 !important;
2743
- font-size: 1rem !important;
2744
- padding: 0 10px !important;
2745
- }
2746
-
2747
- .magicfeedback-multi-question-matrix-table th,
2748
- .magicfeedback-multi-question-matrix-table td label,
2749
- .magicfeedback-priority-list-arrow-up,
2750
- .magicfeedback-priority-list-arrow-down {
2751
- font-style: normal !important;
2752
- font-weight: 400 !important;
2753
- font-size: 1rem !important;
2754
- color: #475569 !important;
2755
- cursor: pointer !important;
2756
- margin: 0 !important;
2757
- line-height: inherit;
2758
- }
2759
-
2760
- .magicfeedback-multi-question-matrix-table tr {
2761
- align-items: center;
2762
- margin: 5px 0;
2763
- }
2764
-
2765
- .magicfeedback-multi-question-matrix-row-tr{
2766
- border-radius: 5px;
2767
- margin: 10px 0 !important;
2768
- }
2769
-
2770
- .magicfeedback-multi-question-matrix-row-tr:nth-child(odd) {
2771
- background-color: #f1f6f6; /* Light gray background for odd rows */
2772
- }
2773
-
2774
- .magicfeedback-multi-question-matrix-row-tr:nth-child(even) {
2775
- background-color: #ffffff; /* White background for even rows */
2776
- }
2777
-
2778
- .magicfeedback-multi-question-matrix-row-label {
2779
- text-align: left !important;
2780
- }
2781
-
2782
- .magicfeedback-point-system-item span {
2783
- color: #475569 !important;
2784
- }
2785
-
2786
- .magicfeedback-point-system-item input {
2787
- padding: 0;
2788
- margin: 0 !important;
2789
- width: auto !important;
2790
- min-width: 100px !important;
2791
- height: auto !important;
2792
- min-height: 42px;
2793
- cursor: pointer;
2794
- font-size: 14px;
2795
- text-align: center !important;
2796
- }
2797
-
2798
- .magicfeedback-multi-question-matrix-table input {
2799
- margin: auto !important;
2800
- padding: 20px !important;
2801
- width: 100% !important;
2802
- height: 15px;
2803
- border: 1px solid #ced4da;
2804
- cursor: pointer;
2805
- }
2806
-
2807
- .magicfeedback-image{
2808
- max-height: 400px !important;
2809
- height: auto !important;
2810
- max-width: 100% !important;
2811
- margin: 10px auto !important;
2812
- }
2813
-
2814
- .magicfeedback-error{
2815
- margin-top: 5px;
2816
- }`;
2817
-
2818
- // src/ui/renderPopup.ts
2819
- function ensureMagicFeedbackStyles(_popup) {
2820
- const STYLE_ID = "magicfeedback-sdk-styles";
2821
- if (document.getElementById(STYLE_ID)) return;
2822
- const style = document.createElement("style");
2823
- style.id = STYLE_ID;
2824
- style.textContent = style_default;
2825
- document.head.appendChild(style);
2826
- }
2827
- function ensureSpinnerStyles(_popup) {
2828
- if (document.getElementById("deepdots-spinner-styles")) return;
2829
- const style = document.createElement("style");
2830
- style.id = "deepdots-spinner-styles";
2831
- style.textContent = `
2832
- @keyframes ddspin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
2833
- .mf-spinner { display:flex; justify-content:center; align-items:center; padding:8px 0; }
2834
- .mf-spinner-circle { width:28px; height:28px; border:3px solid #e0e6ed; border-top-color:#1E293B; border-radius:50%; animation: ddspin 0.9s linear infinite; }
2835
- `;
2836
- document.head.appendChild(style);
2837
- }
2838
- function ensureResponsiveStyles(_popup) {
2839
- if (document.getElementById("deepdots-responsive-styles")) return;
2840
- const style = document.createElement("style");
2841
- style.id = "deepdots-responsive-styles";
2842
- style.textContent = `
2843
- /* Responsive adjustments */
2844
- @media (max-width: 640px) {
2845
- .deepdots-popup {
2846
- width: calc(100% - 24px) !important;
2847
- max-width: calc(100% - 24px) !important;
2848
- height: auto !important;
2849
- max-height: 90vh !important;
2850
- border-radius: 12px !important;
2851
- padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px !important;
2852
- box-sizing: border-box;
2853
- }
2854
- .deepdots-popup .mf-spinner-circle { width: 32px; height: 32px; border-width: 4px; }
2855
- .deepdots-popup button { font-size: 16px !important; }
2856
- .deepdots-popup-header button { width:48px; height:48px; }
2857
- .deepdots-popup-header button svg { width:26px; height:26px; }
2858
- .deepdots-popup-footer { flex-direction: column-reverse !important; gap: 12px !important; }
2859
- .deepdots-popup-footer button { width: 100%; }
2860
- }
2861
- @media (max-width: 400px) {
2862
- .deepdots-popup { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)) 12px !important; }
2863
- .deepdots-popup-header button { width:48px; height:48px; }
2864
- .deepdots-popup-header button svg { width:26px; height:26px; }
2865
- }
2866
- @media (orientation: landscape) and (max-height: 480px) {
2867
- .deepdots-popup {
2868
- height: 100vh !important;
2869
- max-height: 100vh !important;
2870
- overflow-y: auto !important;
2871
- }
2872
- }
2873
- `;
2874
- document.head.appendChild(style);
2875
- }
2876
- async function renderPopup(container, surveyId, productId, actions, emit, onClose, env = "production", userId, style) {
2877
- let surveyCompletedEmitted = false;
2878
- let stylesInjected = false;
2879
- const isDark = style?.theme === "dark";
2880
- const theme = {
2881
- popupBg: isDark ? "#1e1e1e" : "#fff",
2882
- textPrimary: isDark ? "#f0f0f0" : "#111",
2883
- closeBtnHoverBg: isDark ? "rgba(255,255,255,0.10)" : "rgba(0,0,0,0.06)",
2884
- closeBtnHoverColor: isDark ? "#fff" : "#000000"
2885
- };
2886
- const positionMap = {
2887
- "center": { justifyContent: "center", alignItems: "center", background: "rgba(0,0,0,0.5)" },
2888
- "bottom": { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
2889
- "bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
2890
- "bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
2891
- "top": { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
2892
- "top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
2893
- "top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
2894
- };
2895
- const pos = positionMap[style?.position ?? "center"] ?? positionMap["center"];
2896
- const popup = document.createElement("div");
2897
- popup.className = "deepdots-popup";
2898
- popup.style.cssText = `
2899
- position: relative;
2900
- display: flex;
2901
- flex-direction: column;
2902
- justify-content: flex-start;
2903
- background: ${theme.popupBg};
2904
- border-radius: 8px;
2905
- padding: 24px;
2906
- box-shadow: 0 4px 6px rgba(0,0,0,0.1);
2907
- max-width: 600px;
2908
- width: 90%;
2909
- min-height: 200px;
2910
- `;
2911
- const header = document.createElement("div");
2912
- header.className = "deepdots-popup-header";
2913
- header.style.cssText = "display:flex; justify-content:flex-end; align-items:center; width:100%;";
2914
- const closeBtn = document.createElement("button");
2915
- closeBtn.type = "button";
2916
- closeBtn.setAttribute("aria-label", "Close popup");
2917
- closeBtn.innerHTML = `
2918
- <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2919
- <path d="M6 6L18 18M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
2920
- </svg>
2921
- `;
2922
- closeBtn.style.cssText = `
2923
- background:transparent;
2924
- border:none;
2925
- width:32px;
2926
- height:32px;
2927
- display:flex;
2928
- align-items:center;
2929
- justify-content:center;
2930
- border-radius: 8px;
2931
- cursor:pointer;
2932
- color:${theme.textPrimary};
2933
- padding:4px;
2934
- transition: color .15s ease, transform .15s ease, background .15s ease;
2935
- box-shadow: none !important;
2936
- `;
2937
- closeBtn.onmouseenter = () => {
2938
- closeBtn.style.color = theme.closeBtnHoverColor;
2939
- closeBtn.style.background = theme.closeBtnHoverBg;
2940
- closeBtn.style.transform = "scale(1.06)";
2941
- };
2942
- closeBtn.onmouseleave = () => {
2943
- closeBtn.style.color = theme.textPrimary;
2944
- closeBtn.style.background = "transparent";
2945
- closeBtn.style.transform = "scale(1)";
2946
- };
2947
- closeBtn.onclick = () => {
2948
- emit("popup_clicked", surveyId, { action: "close_icon" });
2949
- onClose();
2950
- };
2951
- header.appendChild(closeBtn);
2952
- ensureMagicFeedbackStyles(popup);
2953
- ensureSpinnerStyles(popup);
2954
- ensureResponsiveStyles(popup);
2955
- const containerContent = document.createElement("div");
2956
- containerContent.className = "deepdots-popup-container-conetent";
2957
- containerContent.style.cssText = `
2958
- display:flex;
2959
- flex-direction:column;
2960
- padding: 0 20px 12px 20px;
2961
- max-height: 80vh; /* l\xEDmite general del popup */
2962
- overflow: hidden; /* quita scroll del contenedor principal */
2963
- `;
2964
- const main = document.createElement("div");
2965
- main.className = "deepdots-popup-main";
2966
- main.style.cssText = "display:flex; flex-direction:column; width:100%; max-height:80vh; overflow-y:auto;";
2967
- const formWrapper = document.createElement("div");
2968
- formWrapper.style.cssText = "width:100%; flex: 1 1 auto;";
2969
- const errorHint = document.createElement("div");
2970
- errorHint.className = "deepdots-error-hint";
2971
- errorHint.style.cssText = `
2972
- display: none;
2973
- margin: 12px 0 0 0;
2974
- padding: 10px 12px;
2975
- border-radius: 6px;
2976
- background: #FEF3C7; /* amber-100 */
2977
- color: #92400E; /* amber-700 */
2978
- border: 1px solid #FCD34D; /* amber-300 */
2979
- font-size: 13px;
2980
- `;
2981
- errorHint.setAttribute("role", "alert");
2982
- errorHint.setAttribute("aria-live", "polite");
2983
- const spinnerEl = document.createElement("div");
2984
- spinnerEl.className = "mf-spinner";
2985
- spinnerEl.setAttribute("role", "status");
2986
- spinnerEl.setAttribute("aria-label", "Loading survey");
2987
- spinnerEl.innerHTML = '<div class="mf-spinner-circle"></div>';
2988
- spinnerEl.style.cssText = "position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);";
2989
- const formDivId = `magicfeedback-form-${surveyId}`;
2990
- const formHost = document.createElement("div");
2991
- formHost.id = formDivId;
2992
- formHost.style.cssText = "width:100%; visibility:hidden;";
2993
- formWrapper.appendChild(spinnerEl);
2994
- formWrapper.appendChild(formHost);
2995
- main.appendChild(formWrapper);
2996
- main.appendChild(errorHint);
2997
- const footer = document.createElement("div");
2998
- footer.className = "deepdots-popup-footer";
2999
- footer.setAttribute("data-actions-wrapper", "true");
3000
- footer.style.cssText = "display:flex; flex-direction: row-reverse ;justify-content:space-between; align-items:center; gap:8px; margin-top:auto; width:100%; padding-top:16px;";
3001
- const backButton = document.createElement("button");
3002
- backButton.textContent = actions?.back ? actions.back.label : "Back";
3003
- backButton.style.cssText = `
3004
- background: transparent;
3005
- color: #333;
3006
- border: 1px solid #999;
3007
- padding: 12px 24px;
3008
- border-radius: 4px;
3009
- cursor: pointer;
3010
- font-size: 14px;
3011
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3012
- transition: filter .15s ease;
3013
- display: inline-flex;
3014
- align-items: center;
3015
- justify-content: center;
3016
- text-align: center;
3017
- `;
3018
- backButton.onmouseenter = () => {
3019
- backButton.style.filter = "brightness(0.9)";
3020
- };
3021
- backButton.onmouseleave = () => {
3022
- backButton.style.filter = "brightness(1)";
3023
- };
3024
- backButton.onclick = () => {
3025
- emit("popup_clicked", surveyId, { action: "back" });
3026
- formInstance?.back?.();
3027
- };
3028
- const startButton = document.createElement("button");
3029
- startButton.textContent = actions?.start ? actions.start.label : "Start survey";
3030
- startButton.style.cssText = `
3031
- background: #1E293B;
3032
- color: #fff;
3033
- border: none;
3034
- padding: 12px 24px;
3035
- border-radius: 4px;
3036
- cursor: pointer;
3037
- font-size: 14px;
3038
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3039
- transition: filter .15s ease;
3040
- display: inline-flex;
3041
- align-items: center;
3042
- justify-content: center;
3043
- text-align: center;
3044
- `;
3045
- startButton.onclick = () => {
3046
- emit("popup_clicked", surveyId, { action: "start_survey" });
3047
- formInstance?.startForm?.();
3048
- };
3049
- const closeButton = document.createElement("button");
3050
- closeButton.textContent = actions?.complete ? actions.complete.label : "Complete survey";
3051
- closeButton.style.cssText = `
3052
- background: #1E293B;
3053
- color: #fff;
3054
- border: none;
3055
- padding: 12px 24px;
3056
- border-radius: 4px;
3057
- cursor: pointer;
3058
- font-size: 14px;
3059
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3060
- transition: filter .15s ease;
3061
- display: inline-flex;
3062
- align-items: center;
3063
- justify-content: center;
3064
- text-align: center;
3065
- `;
3066
- closeButton.onmouseenter = () => {
3067
- closeButton.style.filter = "brightness(0.9)";
3068
- };
3069
- closeButton.onmouseleave = () => {
3070
- closeButton.style.filter = "brightness(1)";
3071
- };
3072
- closeButton.onclick = () => {
3073
- emit("popup_clicked", surveyId, { action: "complete" });
3074
- onClose();
3075
- };
3076
- const submitButton = document.createElement("button");
3077
- submitButton.textContent = actions?.accept ? actions.accept.label : "Send";
3078
- submitButton.style.cssText = `
3079
- background: #1E293B;
3080
- color: #fff;
3081
- border: none;
3082
- padding: 12px 24px;
3083
- border-radius: 4px;
3084
- cursor: pointer;
3085
- font-size: 14px;
3086
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
3087
- transition: filter .15s ease;
3088
- display: inline-flex;
3089
- align-items: center;
3090
- justify-content: center;
3091
- text-align: center;
3092
- `;
3093
- submitButton.onclick = () => {
3094
- if (!surveyCompletedEmitted) {
3095
- emit("popup_clicked", surveyId, { action: "manual_send" });
3096
- formInstance?.send?.();
3097
- }
3098
- };
3099
- backButton.style.display = "none";
3100
- startButton.style.display = "none";
3101
- submitButton.style.display = "none";
3102
- closeButton.style.display = "none";
3103
- footer.appendChild(submitButton);
3104
- footer.appendChild(backButton);
3105
- footer.appendChild(closeButton);
3106
- footer.appendChild(startButton);
3107
- main.appendChild(footer);
3108
- containerContent.appendChild(main);
3109
- function updateButtons(state) {
3110
- backButton.style.display = "none";
3111
- startButton.style.display = "none";
3112
- submitButton.style.display = "none";
3113
- closeButton.style.display = "none";
3114
- backButton.style.width = "";
3115
- startButton.style.width = "";
3116
- submitButton.style.width = "";
3117
- closeButton.style.width = "";
3118
- switch (state) {
3119
- case "loading":
3120
- break;
3121
- case "start":
3122
- startButton.style.display = "inline-flex";
3123
- startButton.style.width = "100%";
3124
- break;
3125
- case "in_progress_first":
3126
- submitButton.style.display = "inline-flex";
3127
- submitButton.style.width = "";
3128
- setLoading(false);
3129
- break;
3130
- case "in_progress_next":
3131
- backButton.style.display = "inline-flex";
3132
- submitButton.style.display = "inline-flex";
3133
- setLoading(false);
3134
- break;
3135
- case "completed":
3136
- closeButton.style.display = "inline-flex";
3137
- closeButton.style.width = "100%";
3138
- setLoading(false);
3139
- break;
3140
- case "error":
3141
- setLoading(false);
3142
- break;
3143
- }
3144
- }
3145
- popup.appendChild(header);
3146
- popup.appendChild(containerContent);
3147
- container.innerHTML = "";
3148
- container.appendChild(popup);
3149
- container.style.display = "flex";
3150
- container.style.justifyContent = pos.justifyContent;
3151
- container.style.alignItems = pos.alignItems;
3152
- container.style.background = pos.background;
3153
- if (pos.padding) container.style.padding = pos.padding;
3154
- function setLoading(isLoading) {
3155
- spinnerEl.style.display = isLoading ? "flex" : "none";
3156
- if (!isLoading) {
3157
- formHost.style.visibility = "visible";
3158
- }
3159
- footer.style.display = isLoading ? "none" : "flex";
3160
- backButton.disabled = isLoading;
3161
- startButton.disabled = isLoading;
3162
- closeButton.disabled = isLoading;
3163
- submitButton.disabled = isLoading;
3164
- submitButton.style.opacity = isLoading ? "0.6" : "1";
3165
- submitButton.style.cursor = isLoading ? "not-allowed" : "pointer";
3166
- if (isLoading) {
3167
- updateButtons("loading");
3168
- }
3169
- }
3170
- setLoading(true);
3171
- if (typeof window === "undefined" || typeof document === "undefined") {
3172
- return;
3173
- }
3174
- let formInstance = null;
3175
- try {
3176
- if (!import_native.default || typeof import_native.default.form !== "function") {
3177
- console.warn("[MagicFeedback] form() no disponible. Fallback manual.");
3178
- setLoading(false);
3179
- return;
3180
- }
3181
- import_native.default.init(
3182
- {
3183
- debug: true,
3184
- env: env === "production" ? "prod" : "dev"
3185
- }
3186
- );
3187
- const profile = userId ? [{ key: "external-user-id", value: [userId] }] : [];
3188
- formInstance = import_native.default.form(surveyId, productId, profile, profile);
3189
- const generateOptions = {
3190
- addButton: false,
3191
- getMetaData: true
3192
- };
3193
- generateOptions.onLoadedEvent = ({ formData }) => {
3194
- try {
3195
- } catch (e) {
3196
- }
3197
- const s = formData?.style;
3198
- if (s && !stylesInjected) {
3199
- stylesInjected = true;
3200
- if (s.boxBackgroundColor) {
3201
- popup.style.background = s.boxBackgroundColor;
3202
- }
3203
- if (s.contentAlign) {
3204
- main.style.justifyContent = s.contentAlign === "center" ? "center" : "flex-start";
3205
- }
3206
- if (s.buttonPrimaryColor) {
3207
- submitButton.style.background = s.buttonPrimaryColor;
3208
- submitButton.style.border = "none";
3209
- submitButton.style.color = "#fff";
3210
- startButton.style.background = s.buttonPrimaryColor;
3211
- startButton.style.border = "none";
3212
- startButton.style.color = "#fff";
3213
- closeButton.style.background = s.buttonPrimaryColor;
3214
- closeButton.style.border = "none";
3215
- closeButton.style.color = "#fff";
3216
- }
3217
- if (s.buttonSecondaryColor) {
3218
- backButton.style.background = "#fff";
3219
- backButton.style.color = s.buttonSecondaryColor;
3220
- backButton.style.border = `1px solid ${s.buttonSecondaryColor}`;
3221
- }
3222
- if (s.logo) {
3223
- if (!document.getElementById("deepdots-popup-logo")) {
3224
- const logoImg = document.createElement("img");
3225
- logoImg.id = "deepdots-popup-logo";
3226
- logoImg.src = s.logo;
3227
- logoImg.alt = "Logo";
3228
- logoImg.style.cssText = "max-height:40px; max-width:100%; object-fit:contain;";
3229
- if (s.logoSize) {
3230
- switch (s.logoSize) {
3231
- case "small":
3232
- logoImg.style.maxHeight = "30px";
3233
- break;
3234
- case "medium":
3235
- logoImg.style.maxHeight = "50px";
3236
- break;
3237
- case "large":
3238
- logoImg.style.maxHeight = "70px";
3239
- break;
3240
- }
3241
- }
3242
- if (s.logoPosition) {
3243
- switch (s.logoPosition) {
3244
- case "left":
3245
- logoImg.style.margin = "0 16px 42px 0";
3246
- logoImg.style.display = "block";
3247
- logoImg.style.marginLeft = "0";
3248
- break;
3249
- case "right":
3250
- logoImg.style.margin = "0 0 42px 16px";
3251
- logoImg.style.display = "block";
3252
- logoImg.style.marginLeft = "auto";
3253
- break;
3254
- case "center":
3255
- logoImg.style.margin = "0 auto 42px auto";
3256
- logoImg.style.display = "block";
3257
- break;
3258
- }
3259
- }
3260
- containerContent.insertBefore(logoImg, main);
3261
- }
3262
- }
3263
- if (s.startMessage && s.startMessage !== "") {
3264
- console.log(s.startMessage);
3265
- updateButtons("start");
3266
- } else {
3267
- updateButtons("in_progress_first");
3268
- }
3269
- } else {
3270
- updateButtons("in_progress_first");
3271
- }
3272
- emit("popup_clicked", surveyId, { action: "loaded" });
3273
- setLoading(false);
3274
- };
3275
- generateOptions.beforeSubmitEvent = () => {
3276
- setLoading(true);
3277
- emit("popup_clicked", surveyId, { action: "before_submit" });
3278
- };
3279
- generateOptions.afterSubmitEvent = ({ error, completed, total, progress }) => {
3280
- const errText = error ? typeof error === "string" ? error : error.message ?? String(error) : "";
3281
- if (errText) {
3282
- setLoading(false);
3283
- if (errText.toLowerCase().includes("no response")) {
3284
- errorHint.textContent = "Please answer the required question to continue.";
3285
- errorHint.style.display = "block";
3286
- emit("popup_clicked", surveyId, { action: "validation_error_required" });
3287
- updateButtons("in_progress_next");
3288
- return;
3289
- }
3290
- errorHint.textContent = "An error occurred while submitting. Please try again or close the popup.";
3291
- errorHint.style.display = "block";
3292
- emit("popup_clicked", surveyId, { action: "submit_error", error: errText });
3293
- return;
3294
- }
3295
- errorHint.style.display = "none";
3296
- setLoading(false);
3297
- if (completed) {
3298
- emit("survey_completed", surveyId, { action: "completed" });
3299
- surveyCompletedEmitted = true;
3300
- updateButtons("completed");
3301
- return;
3302
- }
3303
- emit("popup_clicked", surveyId, { action: "partial" });
3304
- if (total > 1 && progress > 0 && progress < total) {
3305
- updateButtons("in_progress_next");
3306
- } else {
3307
- updateButtons("in_progress_first");
3308
- }
3309
- };
3310
- generateOptions.onBackEvent = ({ progress }) => {
3311
- emit("popup_clicked", surveyId, { action: "back" });
3312
- if (progress === 0) {
3313
- updateButtons("in_progress_first");
3314
- } else {
3315
- updateButtons("in_progress_next");
3316
- }
3317
- };
3318
- formInstance.generate(formDivId, generateOptions).catch((err) => {
3319
- console.error("[MagicFeedback] Error generating form:", err);
3320
- setLoading(false);
3321
- });
3322
- } catch (e) {
3323
- console.error("[MagicFeedback] Exception initializing form:", e);
3324
- setLoading(false);
3325
- }
3326
- }
9
+ // src/types/index.ts
10
+ var POPUP_TRIGGER_CONDITION_STATUSES = [
11
+ "SHOWED",
12
+ "PARTIAL",
13
+ "COMPLETED"
14
+ ];
3327
15
 
3328
16
  // src/triggers/index.ts
3329
17
  function setupTrigger(popups, trigger) {
@@ -3502,41 +190,122 @@ function resolveEnvironment(nodeEnv) {
3502
190
  return ENVIRONMENT_MAP[nodeEnv || "production"];
3503
191
  }
3504
192
 
193
+ // src/ui/surveyHtml.ts
194
+ function buildSurveyHtml(opts) {
195
+ const env = opts.env === "development" ? "dev" : "prod";
196
+ const version = opts.version ?? "2.2.4";
197
+ const cdn = `https://cdn.jsdelivr.net/npm/@magicfeedback/native@${version}/dist/magicfeedback-sdk.browser.js`;
198
+ const sid = JSON.stringify(opts.surveyId);
199
+ const pid = JSON.stringify(opts.productId);
200
+ const profileJson = JSON.stringify(opts.profile ?? []);
201
+ const metaJson = JSON.stringify(opts.metadata ?? []);
202
+ return `<!DOCTYPE html><html><head>
203
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
204
+ <meta name="color-scheme" content="light"/>
205
+ <style>html,body{margin:0;padding:0;background:transparent;font-family:-apple-system,system-ui,sans-serif}#mf{width:100%;box-sizing:border-box}#mf *{max-width:100%;box-sizing:border-box}</style>
206
+ </head><body>
207
+ <div id="mf"></div>
208
+ <script>
209
+ (function(){
210
+ function emit(s){ try{ if(window.ReactNativeWebView){ window.ReactNativeWebView.postMessage(s); } }catch(e){} }
211
+ function emitJSON(n,p){ try{ emit(JSON.stringify({name:n,payload:p||{}})); }catch(e){} }
212
+ window.DeepdotsClose = function(){ emitJSON('popup_close'); };
213
+ var initialized=false;
214
+ function initMF(){
215
+ if(initialized || !window.magicfeedback) return initialized;
216
+ initialized=true;
217
+ try{
218
+ window.magicfeedback.init({ debug:false, env:'${env}' });
219
+ var form = window.magicfeedback.form(${sid}, ${pid}, ${profileJson}, ${metaJson});
220
+ window.DeepdotsForm = form;
221
+ form.generate('mf', {
222
+ addButton:false,
223
+ getMetaData:true,
224
+ onLoadedEvent:function(){ emitJSON('loaded'); },
225
+ beforeSubmitEvent:function(){ emitJSON('before_submit'); },
226
+ afterSubmitEvent:function(p){
227
+ try{ if(p && p.completed){ emitJSON('survey_completed', p); } else { emitJSON('after_submit', p); } }
228
+ catch(e){ emitJSON('after_submit'); }
229
+ },
230
+ onBackEvent:function(p){ emitJSON('back', p); }
231
+ }).catch(function(e){ emit('error:init'); });
232
+ }catch(e){ emit('error:exception'); }
233
+ return true;
234
+ }
235
+ var s=document.createElement('script'); s.src=${JSON.stringify(cdn)}; s.async=true;
236
+ s.onload=function(){ initMF(); };
237
+ s.onerror=function(){ emit('error:load'); };
238
+ document.head.appendChild(s);
239
+ var tries=0, t=setInterval(function(){ if(initMF()||++tries>40){ clearInterval(t); } },150);
240
+ })();
241
+ <\/script>
242
+ </body></html>`;
243
+ }
244
+
3505
245
  // src/platform/react-native-renderer.ts
3506
246
  var ReactNativePopupRenderer = class {
3507
- constructor() {
3508
- this.mounted = false;
3509
- this.lastSurveyId = null;
247
+ constructor(options = {}) {
248
+ this.options = options;
3510
249
  this.emitFn = null;
3511
250
  this.onCloseFn = null;
3512
- this.completed = false;
251
+ this.currentSurveyId = null;
252
+ this.partialEmitted = false;
3513
253
  }
3514
254
  init() {
3515
255
  }
3516
- show(surveyId, productId, data, emit, onClose) {
3517
- this.mounted = true;
3518
- this.lastSurveyId = surveyId;
256
+ show(surveyId, productId, _actions, emit, onClose, env = "production", userId, _style, sessionId, miniService, analyticsFeedbackSessionId) {
3519
257
  this.emitFn = emit;
3520
258
  this.onCloseFn = onClose;
3521
- this.completed = false;
3522
- queueMicrotask(() => emit("popup_clicked", surveyId, data));
3523
- console.log("[ReactNativePopupRenderer] (stub) show survey:", { surveyId, productId, data });
3524
- }
3525
- /** Completar la encuesta desde la capa nativa */
3526
- completeSurvey(data) {
3527
- if (!this.mounted || this.completed || !this.lastSurveyId || !this.emitFn) return;
3528
- this.completed = true;
3529
- this.emitFn("survey_completed", this.lastSurveyId, data);
3530
- this.onCloseFn?.();
3531
- this.mounted = false;
3532
- console.log("[ReactNativePopupRenderer] (stub) survey completed:", { surveyId: this.lastSurveyId, data });
3533
- this.lastSurveyId = null;
259
+ this.currentSurveyId = surveyId;
260
+ this.partialEmitted = false;
261
+ const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);
262
+ const html = buildSurveyHtml({ surveyId, productId, env, profile, metadata });
263
+ if (this.options.onShow) {
264
+ this.options.onShow({ surveyId, productId, html });
265
+ } else {
266
+ console.warn(
267
+ "[Deepdots] ReactNativePopupRenderer sin onShow: pasa { onShow } a new ReactNativePopupRenderer({...}) para montar el WebView del survey."
268
+ );
269
+ }
3534
270
  }
3535
271
  hide() {
3536
- if (!this.mounted) return;
3537
- this.mounted = false;
3538
- console.log("[ReactNativePopupRenderer] (stub) hide survey:", this.lastSurveyId);
3539
- this.lastSurveyId = null;
272
+ this.options.onHide?.();
273
+ this.currentSurveyId = null;
274
+ }
275
+ /**
276
+ * El host la conecta al `onMessage` del WebView. Traduce los mensajes del survey a
277
+ * eventos del SDK: primera interacción → `popup_clicked` (PARTIAL), completado →
278
+ * `survey_completed` (COMPLETED) y cierra el popup.
279
+ */
280
+ handleMessage(raw) {
281
+ const surveyId = this.currentSurveyId;
282
+ if (!surveyId || !this.emitFn) return;
283
+ let name;
284
+ try {
285
+ name = JSON.parse(raw).name;
286
+ } catch {
287
+ name = raw;
288
+ }
289
+ switch (name) {
290
+ case "loaded":
291
+ case "before_submit":
292
+ case "after_submit":
293
+ case "back":
294
+ if (!this.partialEmitted) {
295
+ this.partialEmitted = true;
296
+ this.emitFn("popup_clicked", surveyId, { action: "partial" });
297
+ }
298
+ break;
299
+ case "survey_completed":
300
+ this.emitFn("survey_completed", surveyId);
301
+ this.onCloseFn?.();
302
+ break;
303
+ case "popup_close":
304
+ this.onCloseFn?.();
305
+ break;
306
+ default:
307
+ break;
308
+ }
3540
309
  }
3541
310
  };
3542
311
  function isReactNativeEnv() {
@@ -3580,12 +349,15 @@ var BrowserPopupRenderer = class {
3580
349
  document.body.appendChild(this.container);
3581
350
  }
3582
351
  }
3583
- show(surveyId, productId, actions, emit, onClose, env = "production", userId, style) {
352
+ show(surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId) {
3584
353
  if (this.visible) return;
3585
354
  if (!this.container || !document.body.contains(this.container)) this.init();
3586
355
  if (!this.container) return;
3587
356
  this.visible = true;
3588
- renderPopup(this.container, surveyId, productId, actions, emit, onClose, env, userId, style);
357
+ const container = this.container;
358
+ void import("./renderPopup-YLFRGPQN.mjs").then(({ renderPopup }) => {
359
+ renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId);
360
+ });
3589
361
  }
3590
362
  hide() {
3591
363
  this.visible = false;
@@ -3604,9 +376,414 @@ function createDefaultRenderer() {
3604
376
  return new BrowserPopupRenderer();
3605
377
  }
3606
378
 
379
+ // src/analytics/analytics-manager.ts
380
+ var dryRunSink = (payload) => {
381
+ console.log(
382
+ "[DeepdotsAnalytics] (dry-run \xB7 NO enviado \xB7 sin init.analytics) POST /sdk/feedback \u2192",
383
+ JSON.stringify(payload, null, 2)
384
+ );
385
+ };
386
+ var AnalyticsManager = class {
387
+ constructor(options = {}) {
388
+ this.events = [];
389
+ this.attributes = {};
390
+ this.miniService = null;
391
+ this.miniServiceEnteredAt = 0;
392
+ this.sink = options.sink ?? dryRunSink;
393
+ this.now = options.now ?? (() => Date.now());
394
+ this.publicKey = options.publicKey;
395
+ this.language = options.language;
396
+ this.device = options.device;
397
+ this.platform = options.platform ?? "web";
398
+ this.maxBatchSize = options.maxBatchSize ?? 20;
399
+ this.onFlushNeeded = options.onFlushNeeded;
400
+ }
401
+ /** Actualiza campos de device en runtime (p.ej. country/city tras resolver geo). */
402
+ updateDevice(partial) {
403
+ this.device = { ...this.device, ...partial };
404
+ }
405
+ /** Mezcla user attributes (se coercionan a string). Mutable en runtime. */
406
+ setUserAttributes(attrs) {
407
+ for (const [k, v] of Object.entries(attrs)) {
408
+ if (!k) continue;
409
+ this.attributes[k] = String(v);
410
+ }
411
+ }
412
+ /** Marca el inicio de un mini-service; etiqueta los eventos siguientes con `mini_service`. */
413
+ enterMiniService(name, entryPointType) {
414
+ this.miniService = name;
415
+ this.miniServiceEnteredAt = this.now();
416
+ this.track("mini_service_enter", { entry_point_type: entryPointType ?? null });
417
+ }
418
+ /** Cierra el mini-service activo emitiendo `mini_service_exit` con su duración (#27). No-op si no hay ninguno. */
419
+ exitMiniService() {
420
+ const name = this.miniService;
421
+ if (name == null) return;
422
+ const durationSeconds = Math.max(0, Math.round((this.now() - this.miniServiceEnteredAt) / 1e3));
423
+ this.miniService = null;
424
+ this.track("mini_service_exit", { mini_service: name, duration_seconds: durationSeconds });
425
+ }
426
+ /** Registra un evento de analítica (modelo GA: nombre + params). */
427
+ track(name, params) {
428
+ const merged = {
429
+ ...this.miniService ? { mini_service: this.miniService } : {},
430
+ ...params ?? {}
431
+ };
432
+ this.events.push({
433
+ name,
434
+ timestamp: this.now(),
435
+ params: Object.keys(merged).length ? merged : void 0
436
+ });
437
+ if (this.events.length >= this.maxBatchSize) {
438
+ this.onFlushNeeded?.();
439
+ }
440
+ }
441
+ /** Mini-service activo (para inyectarlo en la metadata del survey, #33). */
442
+ getMiniService() {
443
+ return this.miniService;
444
+ }
445
+ /** Nº de eventos pendientes de flush. */
446
+ pending() {
447
+ return this.events.length;
448
+ }
449
+ /** Construye el envelope que se enviaría al endpoint de analytics. */
450
+ buildPayload(identity) {
451
+ return {
452
+ publicKey: this.publicKey,
453
+ userId: identity.userId,
454
+ sessionId: identity.sessionId,
455
+ context: {
456
+ platform: this.platform,
457
+ language: this.language,
458
+ device: this.device,
459
+ attributes: { ...this.attributes }
460
+ },
461
+ events: [...this.events]
462
+ };
463
+ }
464
+ /** Envía (vía sink) el lote acumulado y vacía el buffer. No-op si no hay eventos. */
465
+ flush(identity) {
466
+ if (this.events.length === 0) return null;
467
+ const payload = this.buildPayload(identity);
468
+ this.sink(payload);
469
+ this.events = [];
470
+ return payload;
471
+ }
472
+ };
473
+
474
+ // src/analytics/feedback-payload.ts
475
+ function pushKV(list, key, value) {
476
+ if (value === void 0 || value === null || value === "") return;
477
+ list.push({ key, value: [String(value)] });
478
+ }
479
+ function buildAnalyticsFeedbackBody(envelope, keys, feedbackSessionId) {
480
+ const { context } = envelope;
481
+ const profile = [];
482
+ pushKV(profile, "external-user-id", envelope.userId);
483
+ const metadata = [];
484
+ pushKV(metadata, "deepdots_user_id", envelope.userId);
485
+ pushKV(metadata, "deepdots_session_id", envelope.sessionId);
486
+ pushKV(metadata, "deepdots_platform", context.platform);
487
+ pushKV(metadata, "deepdots_language", context.language);
488
+ if (context.device) {
489
+ const d = context.device;
490
+ pushKV(metadata, "deepdots_device_type", d.device_type);
491
+ pushKV(metadata, "deepdots_os_version", d.os_version);
492
+ pushKV(metadata, "deepdots_device_model", d.device_model);
493
+ pushKV(metadata, "deepdots_app_version", d.app_version);
494
+ pushKV(metadata, "deepdots_user_agent", d.user_agent);
495
+ pushKV(metadata, "deepdots_timezone", d.timezone);
496
+ pushKV(metadata, "deepdots_referrer", d.referrer);
497
+ pushKV(metadata, "deepdots_viewport_size", d.viewport_size);
498
+ pushKV(metadata, "deepdots_screen_resolution", d.screen_resolution);
499
+ pushKV(metadata, "deepdots_pixel_ratio", d.pixel_ratio);
500
+ pushKV(metadata, "deepdots_entry_type", d.entry_type);
501
+ pushKV(metadata, "deepdots_page_load_ms", d.page_load_ms);
502
+ pushKV(metadata, "deepdots_connection_type", d.connection_type);
503
+ pushKV(metadata, "deepdots_country", d.country);
504
+ pushKV(metadata, "deepdots_city", d.city);
505
+ }
506
+ for (const [k, v] of Object.entries(context.attributes ?? {})) {
507
+ pushKV(metadata, k, v);
508
+ }
509
+ for (const e of envelope.events) {
510
+ metadata.push({
511
+ key: e.name,
512
+ value: [JSON.stringify({ timestamp: e.timestamp, ...e.params ?? {} })]
513
+ });
514
+ }
515
+ return {
516
+ feedback: {
517
+ text: "",
518
+ answers: [],
519
+ metadata,
520
+ profile,
521
+ finished: false
522
+ },
523
+ publicKey: keys.publicKey,
524
+ integration: keys.integration,
525
+ completed: false,
526
+ ...feedbackSessionId ? { sessionId: feedbackSessionId } : {}
527
+ };
528
+ }
529
+ function createFeedbackSink(options) {
530
+ let feedbackSessionId;
531
+ return (envelope) => {
532
+ const body = buildAnalyticsFeedbackBody(envelope, options.keys, feedbackSessionId);
533
+ const f = options.fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
534
+ if (!f) {
535
+ options.log?.("[DeepdotsAnalytics] no fetch disponible; payload no enviado", body);
536
+ return;
537
+ }
538
+ options.log?.("[DeepdotsAnalytics] POST /sdk/feedback \u2192", body);
539
+ f(`${options.baseUrl}/sdk/feedback`, {
540
+ method: "POST",
541
+ headers: { "Content-Type": "application/json" },
542
+ body: JSON.stringify(body)
543
+ }).then(async (res) => {
544
+ if (res.ok) {
545
+ try {
546
+ const data = await res.json();
547
+ if (data?.sessionId && data.sessionId !== feedbackSessionId) {
548
+ feedbackSessionId = data.sessionId;
549
+ options.log?.("[DeepdotsAnalytics] feedbackSessionId cacheado:", feedbackSessionId);
550
+ options.onSessionId?.(feedbackSessionId);
551
+ }
552
+ } catch {
553
+ }
554
+ }
555
+ }).catch((err) => options.log?.("[DeepdotsAnalytics] error enviando feedback", err));
556
+ };
557
+ }
558
+
559
+ // src/tracking/navigation-observer.ts
560
+ var UUID_PREFIX = /^[0-9a-f]{8}-[0-9a-f]{4}-/i;
561
+ function normalizeScreen(href) {
562
+ let pathAndHash;
563
+ try {
564
+ const u = new URL(href, "http://deepdots.local");
565
+ pathAndHash = u.pathname + (u.hash || "");
566
+ } catch {
567
+ pathAndHash = href;
568
+ }
569
+ pathAndHash = pathAndHash.replace(/\?[^#]*/g, "");
570
+ const collapsed = pathAndHash.split("/").map((seg) => /^[0-9]+$/.test(seg) || UUID_PREFIX.test(seg) ? ":id" : seg).join("/");
571
+ return collapsed || "/";
572
+ }
573
+ var NavigationObserver = class {
574
+ constructor(options = {}) {
575
+ this.listeners = /* @__PURE__ */ new Set();
576
+ this.currentScreen = null;
577
+ this.entryAt = 0;
578
+ this.installed = false;
579
+ this.domHandlers = [];
580
+ this.now = options.now ?? (() => Date.now());
581
+ }
582
+ onVisit(listener) {
583
+ this.listeners.add(listener);
584
+ }
585
+ /** Fija la pantalla inicial (sin emitir visita; su duración se cierra al salir). */
586
+ begin(href) {
587
+ this.currentScreen = normalizeScreen(href);
588
+ this.entryAt = this.now();
589
+ }
590
+ /** Navega a una pantalla nueva: cierra la anterior (emite visita) y abre la nueva. */
591
+ visit(href) {
592
+ const next = normalizeScreen(href);
593
+ if (next === this.currentScreen) return;
594
+ this.closeCurrent();
595
+ this.currentScreen = next;
596
+ this.entryAt = this.now();
597
+ }
598
+ /** Cierra la pantalla actual emitiendo su visita (p. ej. al cerrar la app/pestaña). */
599
+ stop() {
600
+ this.closeCurrent();
601
+ this.currentScreen = null;
602
+ }
603
+ closeCurrent() {
604
+ if (this.currentScreen == null) return;
605
+ const exit = this.now();
606
+ const visit = {
607
+ screen: this.currentScreen,
608
+ entry: this.entryAt,
609
+ exit,
610
+ durationSeconds: Math.max(0, Math.round((exit - this.entryAt) / 1e3))
611
+ };
612
+ this.listeners.forEach((l) => {
613
+ try {
614
+ l(visit);
615
+ } catch {
616
+ }
617
+ });
618
+ }
619
+ /** Instala los hooks de History en el navegador y registra la pantalla actual. */
620
+ install() {
621
+ if (this.installed || typeof window === "undefined" || typeof history === "undefined") return;
622
+ this.installed = true;
623
+ const handle = () => this.visit(window.location.href);
624
+ const originalPush = history.pushState.bind(history);
625
+ const originalReplace = history.replaceState.bind(history);
626
+ history.pushState = (data, unused, url) => {
627
+ const r = originalPush(data, unused, url);
628
+ handle();
629
+ return r;
630
+ };
631
+ history.replaceState = (data, unused, url) => {
632
+ const r = originalReplace(data, unused, url);
633
+ handle();
634
+ return r;
635
+ };
636
+ window.addEventListener("popstate", handle);
637
+ window.addEventListener("hashchange", handle);
638
+ this.domHandlers.push(() => {
639
+ history.pushState = originalPush;
640
+ history.replaceState = originalReplace;
641
+ window.removeEventListener("popstate", handle);
642
+ window.removeEventListener("hashchange", handle);
643
+ });
644
+ this.begin(window.location.href);
645
+ }
646
+ uninstall() {
647
+ this.domHandlers.forEach((off) => off());
648
+ this.domHandlers = [];
649
+ this.installed = false;
650
+ }
651
+ };
652
+
653
+ // src/analytics/device-info.ts
654
+ function parseDeviceType(ua) {
655
+ const s = (ua || "").toLowerCase();
656
+ if (/ipad|tablet|playbook|silk/.test(s) || /android/.test(s) && !/mobile/.test(s)) {
657
+ return "tablet";
658
+ }
659
+ if (/mobi|iphone|ipod|windows phone/.test(s) || /android/.test(s) && /mobile/.test(s)) {
660
+ return "mobile";
661
+ }
662
+ return "desktop";
663
+ }
664
+ function getEntryType() {
665
+ if (typeof performance === "undefined") return void 0;
666
+ const entries = performance.getEntriesByType("navigation");
667
+ if (!entries.length) return void 0;
668
+ return entries[0].type;
669
+ }
670
+ function getPageLoadMs() {
671
+ if (typeof performance === "undefined") return void 0;
672
+ const entries = performance.getEntriesByType("navigation");
673
+ if (!entries.length) return void 0;
674
+ const load = entries[0].loadEventEnd;
675
+ return load > 0 ? Math.round(load) : void 0;
676
+ }
677
+ function getConnectionType() {
678
+ if (typeof navigator === "undefined") return void 0;
679
+ return navigator.connection?.effectiveType ?? void 0;
680
+ }
681
+ function collectDeviceInfo(appVersion) {
682
+ const ua = typeof navigator !== "undefined" ? navigator.userAgent : "";
683
+ return {
684
+ device_type: parseDeviceType(ua),
685
+ user_agent: ua || void 0,
686
+ app_version: appVersion,
687
+ timezone: typeof Intl !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().timeZone : void 0,
688
+ referrer: typeof document !== "undefined" && document.referrer ? document.referrer : void 0,
689
+ viewport_size: typeof window !== "undefined" ? `${window.innerWidth}x${window.innerHeight}` : void 0,
690
+ screen_resolution: typeof screen !== "undefined" ? `${screen.width}x${screen.height}` : void 0,
691
+ pixel_ratio: typeof window !== "undefined" ? window.devicePixelRatio : void 0,
692
+ entry_type: getEntryType(),
693
+ page_load_ms: getPageLoadMs(),
694
+ connection_type: getConnectionType()
695
+ };
696
+ }
697
+
698
+ // src/analytics/geo-info.ts
699
+ async function collectGeoInfo(fetchImpl) {
700
+ const f = fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
701
+ if (!f) return null;
702
+ try {
703
+ const res = await f("https://ipapi.co/json/");
704
+ if (!res.ok) return null;
705
+ const data = await res.json();
706
+ const country = data.country_code || void 0;
707
+ const city = data.city || void 0;
708
+ if (!country && !city) return null;
709
+ return { country, city };
710
+ } catch {
711
+ return null;
712
+ }
713
+ }
714
+
715
+ // src/analytics/engagement-tracker.ts
716
+ var EngagementTracker = class {
717
+ constructor(now = () => Date.now()) {
718
+ this.activeMs = 0;
719
+ this.lastResumeAt = null;
720
+ this.now = now;
721
+ }
722
+ /** Reanuda el conteo (pestaña visible / app en foreground). Idempotente. */
723
+ resume() {
724
+ if (this.lastResumeAt === null) this.lastResumeAt = this.now();
725
+ }
726
+ /** Pausa el conteo (pestaña oculta / app en background), acumulando el tramo activo. */
727
+ pause() {
728
+ if (this.lastResumeAt !== null) {
729
+ this.activeMs += this.now() - this.lastResumeAt;
730
+ this.lastResumeAt = null;
731
+ }
732
+ }
733
+ /** Devuelve los ms activos acumulados desde la última lectura y reinicia (sin parar el timer). */
734
+ consume() {
735
+ if (this.lastResumeAt !== null) {
736
+ const t = this.now();
737
+ this.activeMs += t - this.lastResumeAt;
738
+ this.lastResumeAt = t;
739
+ }
740
+ const ms = this.activeMs;
741
+ this.activeMs = 0;
742
+ return ms;
743
+ }
744
+ isActive() {
745
+ return this.lastResumeAt !== null;
746
+ }
747
+ };
748
+
749
+ // src/contact/contact-manager.ts
750
+ function stableSerialize(attrs) {
751
+ const sorted = {};
752
+ for (const key of Object.keys(attrs).sort()) {
753
+ sorted[key] = attrs[key];
754
+ }
755
+ return JSON.stringify(sorted);
756
+ }
757
+ var ContactManager = class {
758
+ constructor(options) {
759
+ this.storage = options.storage;
760
+ this.publicKey = options.publicKey;
761
+ this.userId = options.userId;
762
+ this.post = options.post;
763
+ }
764
+ /**
765
+ * Envía los atributos si cambiaron respecto a lo último enviado.
766
+ * @returns `true` si se envió, `false` si no hubo cambios.
767
+ */
768
+ async setAttributes(attributes) {
769
+ const serialized = stableSerialize(attributes);
770
+ const last = this.storage.getItem(STORAGE_KEYS.contactAttributes);
771
+ if (last === serialized) return false;
772
+ await this.post({
773
+ publicKey: this.publicKey,
774
+ userId: this.userId,
775
+ userAttributes: attributes
776
+ });
777
+ this.storage.setItem(STORAGE_KEYS.contactAttributes, serialized);
778
+ return true;
779
+ }
780
+ };
781
+
3607
782
  // src/core/deepdots-popups.ts
3608
783
  var EXIT_QUEUE_STORAGE_KEY = "__deepdots_exit_popup_queue__";
3609
784
  var DAY_IN_MS = 24 * 60 * 60 * 1e3;
785
+ var ANALYTICS_MAX_BATCH_SIZE = 20;
786
+ var ANALYTICS_FLUSH_INTERVAL_MS = 3e4;
3610
787
  var DeepdotsPopups = class {
3611
788
  constructor() {
3612
789
  this.config = null;
@@ -3628,6 +805,22 @@ var DeepdotsPopups = class {
3628
805
  this.deferredExitTimers = [];
3629
806
  this.baseUrl = "";
3630
807
  this.env = "production";
808
+ /** Identidad + sesión (Fase 1 tracking). Null hasta init(). */
809
+ this.tracking = null;
810
+ /** Capa de analytics (canal separado del feedback). Null hasta init(). */
811
+ this.analytics = null;
812
+ /** feedbackSessionId cacheado del canal de analytics (devuelto por POST /sdk/feedback). */
813
+ this.analyticsFeedbackSessionId = void 0;
814
+ /** Timer del flush periódico de analytics (cada ANALYTICS_FLUSH_INTERVAL_MS). */
815
+ this.analyticsFlushTimer = void 0;
816
+ /** Observador de navegación (Fase 2): emite page_view por el canal de analytics. */
817
+ this.navObserver = null;
818
+ /** Tiempo activo (engagement time, #8). */
819
+ this.engagement = null;
820
+ /** Atributos internos del usuario identificado → POST /sdk/popups/contact. Null si no hay userId. */
821
+ this.contact = null;
822
+ /** Marca si ya se inició la navegación manual (setScreen) — para RN sin History API. */
823
+ this.navStarted = false;
3631
824
  }
3632
825
  /** Initialize the SDK with configuration */
3633
826
  init(config) {
@@ -3640,32 +833,206 @@ var DeepdotsPopups = class {
3640
833
  this.env = config.nodeEnv || "production";
3641
834
  this.config = {
3642
835
  apiKey: config.apiKey || void 0,
3643
- mode: config.mode || "client",
3644
836
  debug: config.debug || false,
3645
- popups: config.popups || [],
3646
837
  userId: config.userId || void 0
3647
838
  };
839
+ const storage = config.storage ?? createDefaultStorage();
840
+ this.tracking = new TrackingManager({
841
+ storage,
842
+ clientUserId: this.config.userId,
843
+ enabled: config.trackingEnabled ?? true
844
+ });
845
+ if (this.config.userId) {
846
+ const userId = this.config.userId;
847
+ const publicKey = this.config.apiKey ?? "";
848
+ this.contact = new ContactManager({
849
+ storage,
850
+ publicKey,
851
+ userId,
852
+ post: (body) => this.postContact(body)
853
+ });
854
+ if (config.contactAttributes) {
855
+ void this.setContactAttributes(config.contactAttributes);
856
+ }
857
+ }
858
+ this.log("tracking \xB7 user_id:", this.tracking.getUserId(), "\xB7 new_user:", this.tracking.isNewUser(), "\xB7 enabled:", this.tracking.isTrackingEnabled());
859
+ const analyticsSink = config.analytics ? createFeedbackSink({
860
+ baseUrl: this.baseUrl,
861
+ keys: config.analytics,
862
+ log: (...a) => this.log(...a),
863
+ onSessionId: (id) => {
864
+ this.analyticsFeedbackSessionId = id;
865
+ }
866
+ }) : void 0;
867
+ this.analytics = new AnalyticsManager({
868
+ sink: analyticsSink,
869
+ publicKey: config.analytics?.publicKey ?? this.config.apiKey,
870
+ language: typeof navigator !== "undefined" ? navigator.language : void 0,
871
+ platform: config.platform ?? "web",
872
+ device: config.device ?? collectDeviceInfo(config.appVersion),
873
+ maxBatchSize: ANALYTICS_MAX_BATCH_SIZE,
874
+ onFlushNeeded: () => this.flushAnalytics()
875
+ });
876
+ collectGeoInfo().then((geo) => {
877
+ if (geo) this.analytics?.updateDevice(geo);
878
+ }).catch(() => {
879
+ });
880
+ this.navObserver = new NavigationObserver();
881
+ this.navObserver.onVisit((v) => this.track("page_view", { screen: v.screen, duration_seconds: v.durationSeconds }));
882
+ this.navObserver.install();
883
+ this.engagement = new EngagementTracker();
884
+ this.engagement.resume();
885
+ this.setupAnalyticsFlush();
3648
886
  this.initialized = true;
3649
887
  this.log("SDK initialized", this.config);
3650
888
  if (this.renderer.init) this.renderer.init();
3651
889
  this.setupPopupContainer();
3652
- if (this.config.mode === "client") {
3653
- this.popupDefinitions = this.validatePopupDefinitions(this.config.popups || []);
890
+ this.fetchPopupsFromServer().then((defs) => {
891
+ this.popupDefinitions = this.validatePopupDefinitions(defs);
3654
892
  this.popupsLoaded = true;
893
+ this.log("Popups loaded from API", this.popupDefinitions);
3655
894
  this.configureTriggersFromDefinitions();
3656
895
  this.processDeferredExitQueue();
896
+ if (this.pendingAutoLaunch) {
897
+ this.startTriggers();
898
+ }
899
+ });
900
+ }
901
+ /** User id actual (generado por el SDK o provisto por el cliente). Null si tracking off. */
902
+ getUserId() {
903
+ return this.tracking?.getUserId() ?? null;
904
+ }
905
+ /** Session id de navegación actual. Null si tracking off. */
906
+ getSessionId() {
907
+ return this.tracking?.getSessionId() ?? null;
908
+ }
909
+ /** Activa/desactiva el tracking (identidad + sesión + analytics). Kill-switch del contrato §7bis. */
910
+ setTrackingEnabled(enabled) {
911
+ this.tracking?.setTrackingEnabled(enabled);
912
+ this.log("tracking \xB7 setTrackingEnabled:", enabled, "\xB7 session_id:", this.tracking?.getSessionId() ?? null);
913
+ }
914
+ // ───────── Analytics (canal separado del feedback, vinculado por user_id) ─────────
915
+ /** Registra un evento de analítica (modelo GA: nombre + params). No-op si tracking off. */
916
+ track(name, params) {
917
+ if (!this.tracking?.isTrackingEnabled()) return;
918
+ this.analytics?.track(name, params);
919
+ this.log("analytics \xB7 track:", name, params ?? {});
920
+ }
921
+ /** User attributes para breakdowns (registration_status, pass_type, sector, pass_status…). */
922
+ setUserAttributes(attributes) {
923
+ if (!this.tracking?.isTrackingEnabled()) return;
924
+ this.analytics?.setUserAttributes(attributes);
925
+ }
926
+ /**
927
+ * Info interna del usuario que solo conoce el host (idioma, edad, plan…), persistida en el
928
+ * Contact del backend para segmentación/targeting de popups. Identificada por el `userId` del
929
+ * init. Solo envía si los atributos cambiaron (diff en storage). No-op si tracking off o sin userId.
930
+ * @returns `true` si se envió al backend, `false` si no hubo cambios o está deshabilitado.
931
+ */
932
+ async setContactAttributes(attributes) {
933
+ if (!this.tracking?.isTrackingEnabled()) return false;
934
+ if (!this.contact) return false;
935
+ return this.contact.setAttributes(attributes);
936
+ }
937
+ /** Marca el inicio de un mini-service; etiqueta los eventos siguientes. No-op si tracking off. */
938
+ enterMiniService(name, entryPointType) {
939
+ if (!this.tracking?.isTrackingEnabled()) return;
940
+ this.analytics?.enterMiniService(name, entryPointType);
941
+ this.log("analytics \xB7 enterMiniService:", name, entryPointType ?? "");
942
+ }
943
+ /** Cierra el mini-service activo (emite `mini_service_exit` con duración, #27). No-op si tracking off. */
944
+ exitMiniService() {
945
+ if (!this.tracking?.isTrackingEnabled()) return;
946
+ this.analytics?.exitMiniService();
947
+ this.log("analytics \xB7 exitMiniService");
948
+ }
949
+ /** Findability (#31/#35): registra una búsqueda. `has_results` se deriva de `resultsCount`. */
950
+ trackSearch(query, resultsCount, params) {
951
+ this.track("search", { query, results_count: resultsCount, has_results: resultsCount > 0, ...params ?? {} });
952
+ }
953
+ /** Findability friction (#34/#35): señal de fricción con su `friction_topic`. */
954
+ trackFindabilityFriction(frictionTopic, params) {
955
+ this.track("findability_friction", { friction_topic: frictionTopic, ...params ?? {} });
956
+ }
957
+ /** Funnel: un paso del embudo, correlacionado por `taskId`. El backend reconstruye conversión/drop-off/tiempo. */
958
+ trackFunnelStep(funnel, step, taskId, params) {
959
+ this.track("funnel_step", { funnel, step, task_id: taskId, ...params ?? {} });
960
+ }
961
+ /**
962
+ * Navegación MANUAL (entornos sin History API, p. ej. React Native con React Navigation).
963
+ * El host la llama en cada cambio de pantalla; emite `page_view` al salir de la anterior.
964
+ */
965
+ setScreen(name) {
966
+ if (!this.navObserver) return;
967
+ if (!this.navStarted) {
968
+ this.navObserver.begin(name);
969
+ this.navStarted = true;
3657
970
  } else {
3658
- this.fetchPopupsFromServer().then((defs) => {
3659
- this.popupDefinitions = this.validatePopupDefinitions(defs);
3660
- this.popupsLoaded = true;
3661
- this.log("Popups loaded from server (fake)", this.popupDefinitions);
3662
- this.configureTriggersFromDefinitions();
3663
- this.processDeferredExitQueue();
3664
- if (this.pendingAutoLaunch) {
3665
- this.startTriggers();
3666
- }
3667
- });
3668
- }
971
+ this.navObserver.visit(name);
972
+ }
973
+ }
974
+ /** App a foreground (RN: AppState 'active'): reanuda el engagement time. */
975
+ onForeground() {
976
+ this.engagement?.resume();
977
+ }
978
+ /**
979
+ * App a background (RN: AppState 'background'): cierra pantalla actual (page_view),
980
+ * mini-service (mini_service_exit), emite engagement y hace flush del lote.
981
+ */
982
+ onBackground() {
983
+ this.navObserver?.stop();
984
+ this.navStarted = false;
985
+ this.exitMiniService();
986
+ this.flushEngagement();
987
+ this.engagement?.pause();
988
+ this.flushAnalytics();
989
+ }
990
+ /** Payload que se ENVIARÍA al endpoint de analytics (no envía ni vacía el buffer). */
991
+ previewAnalytics() {
992
+ return this.analytics?.buildPayload(this.analyticsIdentity()) ?? {
993
+ userId: null,
994
+ sessionId: null,
995
+ context: { platform: "web", attributes: {} },
996
+ events: []
997
+ };
998
+ }
999
+ /** Envía (hoy dry-run → console.log) el lote acumulado de analytics y vacía el buffer. */
1000
+ flushAnalytics() {
1001
+ if (!this.tracking?.isTrackingEnabled()) return;
1002
+ this.analytics?.flush(this.analyticsIdentity());
1003
+ }
1004
+ /** Emite un evento `user_engagement` con el tiempo activo acumulado (#8). */
1005
+ flushEngagement() {
1006
+ if (!this.tracking?.isTrackingEnabled()) return;
1007
+ const ms = this.engagement?.consume() ?? 0;
1008
+ if (ms > 0) this.track("user_engagement", { engagement_time_msec: ms });
1009
+ }
1010
+ analyticsIdentity() {
1011
+ return {
1012
+ userId: this.tracking?.getUserId() ?? null,
1013
+ sessionId: this.tracking?.getSessionId() ?? null
1014
+ };
1015
+ }
1016
+ /** Flush automático al ocultar/cerrar la página (no perder el lote pendiente). */
1017
+ setupAnalyticsFlush() {
1018
+ if (typeof document === "undefined" || typeof window === "undefined") return;
1019
+ this.analyticsFlushTimer = setInterval(() => this.flushAnalytics(), ANALYTICS_FLUSH_INTERVAL_MS);
1020
+ window.addEventListener("pagehide", () => {
1021
+ clearInterval(this.analyticsFlushTimer);
1022
+ this.navObserver?.stop();
1023
+ this.exitMiniService();
1024
+ this.flushEngagement();
1025
+ this.flushAnalytics();
1026
+ });
1027
+ document.addEventListener("visibilitychange", () => {
1028
+ if (document.visibilityState === "hidden") {
1029
+ this.flushEngagement();
1030
+ this.engagement?.pause();
1031
+ this.flushAnalytics();
1032
+ } else if (document.visibilityState === "visible") {
1033
+ this.engagement?.resume();
1034
+ }
1035
+ });
3669
1036
  }
3670
1037
  /** Enable auto-launch functionality with configured triggers */
3671
1038
  autoLaunch() {
@@ -3684,35 +1051,6 @@ var DeepdotsPopups = class {
3684
1051
  this.log("Auto-launch enabled");
3685
1052
  this.triggers.forEach((trigger) => setupTrigger(this, trigger));
3686
1053
  }
3687
- /** Show a popup immediately (supports legacy ShowOptions and new PopupDefinition) */
3688
- show(options) {
3689
- if (!this.initialized) {
3690
- throw new Error("SDK not initialized. Call init() first.");
3691
- }
3692
- const isDefinition = options.id !== void 0;
3693
- if (isDefinition) {
3694
- const def = options;
3695
- this.log("Showing popup (definition)", def);
3696
- this.surveyToPopupId.set(def.surveyId, def.id);
3697
- this.lastShown.set(def.id, Date.now());
3698
- this.renderPopup(def.surveyId, def.productId, def.actions, def.style);
3699
- this.emitEvent("popup_shown", def.surveyId, { popupId: def.id });
3700
- } else {
3701
- const opt = options;
3702
- this.log("Showing popup (legacy options)", opt);
3703
- this.renderPopup(opt.surveyId, opt.productId, void 0);
3704
- this.emitEvent("popup_shown", opt.surveyId);
3705
- }
3706
- }
3707
- /** Mostrar popup por id de definición (usa surveyId interno) */
3708
- showByPopupId(popupId) {
3709
- const def = this.popupDefinitions.find((popup) => popup.id === popupId);
3710
- if (!def) {
3711
- this.log("Popup definition not found", popupId);
3712
- return;
3713
- }
3714
- this.show(def);
3715
- }
3716
1054
  /** Configure triggers for auto-launching popups (manual) */
3717
1055
  configureTriggers(triggers) {
3718
1056
  if (!this.initialized) {
@@ -3781,7 +1119,11 @@ var DeepdotsPopups = class {
3781
1119
  this.showDefinition(matched);
3782
1120
  }
3783
1121
  showDefinition(def) {
3784
- this.show(def);
1122
+ this.log("Showing popup (definition)", def);
1123
+ this.surveyToPopupId.set(def.surveyId, def.id);
1124
+ this.lastShown.set(def.id, Date.now());
1125
+ this.renderPopup(def.surveyId, def.productId, def.actions, def.style);
1126
+ this.emitEvent("popup_shown", def.surveyId, { popupId: def.id });
3785
1127
  }
3786
1128
  shouldShow(def, pathUrl, skipPathCheck = false) {
3787
1129
  if (!skipPathCheck && !this.matchesSegmentsPath(def, pathUrl)) {
@@ -4025,6 +1367,26 @@ var DeepdotsPopups = class {
4025
1367
  return [];
4026
1368
  }
4027
1369
  }
1370
+ /** Envía los atributos de contact a la API (`POST /sdk/popups/contact`). */
1371
+ async postContact(body) {
1372
+ const baseUrl = this.baseUrl;
1373
+ if (!baseUrl) return;
1374
+ const endpoint = `${baseUrl}/sdk/popups/contact`;
1375
+ try {
1376
+ const response = await fetch(endpoint, {
1377
+ method: "POST",
1378
+ headers: { "Content-Type": "application/json" },
1379
+ body: JSON.stringify(body)
1380
+ });
1381
+ if (!response.ok) {
1382
+ this.log("Failed to post contact", response.status, response.statusText);
1383
+ return;
1384
+ }
1385
+ this.log("contact \xB7 sent attributes for user:", body.userId);
1386
+ } catch (error) {
1387
+ this.log("Error posting contact", error);
1388
+ }
1389
+ }
4028
1390
  /** Notifica eventos de popup a la API */
4029
1391
  async postPopupEvent(status, popupId, userId) {
4030
1392
  const apiKey = this.config?.apiKey;
@@ -4046,6 +1408,15 @@ var DeepdotsPopups = class {
4046
1408
  });
4047
1409
  if (!response.ok) {
4048
1410
  this.log("Failed to post popup event", response.status, response.statusText);
1411
+ return;
1412
+ }
1413
+ try {
1414
+ const data = await response.json();
1415
+ if (data && typeof data.sessionId === "string") {
1416
+ this.tracking?.setSessionId(data.sessionId);
1417
+ this.log("tracking \xB7 session_id from backend:", data.sessionId);
1418
+ }
1419
+ } catch {
4049
1420
  }
4050
1421
  } catch (error) {
4051
1422
  this.log("Error posting popup event", error);
@@ -4088,7 +1459,11 @@ var DeepdotsPopups = class {
4088
1459
  }
4089
1460
  /** Render the popup UI */
4090
1461
  renderPopup(surveyId, productId, actions, style) {
4091
- const userId = this.config?.userId;
1462
+ const userId = this.tracking?.getUserId() ?? this.config?.userId;
1463
+ const sessionId = this.tracking?.getSessionId() ?? void 0;
1464
+ const miniService = this.analytics?.getMiniService() ?? void 0;
1465
+ const analyticsFeedbackSessionId = this.analyticsFeedbackSessionId;
1466
+ this.log("tracking \xB7 survey identity \u2192", { userId: userId ?? null, sessionId: sessionId ?? null, miniService: miniService ?? null, analyticsFeedbackSessionId: analyticsFeedbackSessionId ?? null });
4092
1467
  if (this.renderer) {
4093
1468
  this.renderer.show(
4094
1469
  surveyId,
@@ -4098,22 +1473,31 @@ var DeepdotsPopups = class {
4098
1473
  () => this.hidePopup(),
4099
1474
  this.env,
4100
1475
  userId,
4101
- style
1476
+ style,
1477
+ sessionId,
1478
+ miniService,
1479
+ analyticsFeedbackSessionId
4102
1480
  );
4103
1481
  return;
4104
1482
  }
4105
1483
  if (!this.popupContainer) return;
4106
- renderPopup(
4107
- this.popupContainer,
4108
- surveyId,
4109
- productId,
4110
- actions,
4111
- (type, id, payload) => this.emitEvent(type, id, payload),
4112
- () => this.hidePopup(),
4113
- this.env,
4114
- userId,
4115
- style
4116
- );
1484
+ const container = this.popupContainer;
1485
+ void import("./renderPopup-YLFRGPQN.mjs").then(({ renderPopup }) => {
1486
+ renderPopup(
1487
+ container,
1488
+ surveyId,
1489
+ productId,
1490
+ actions,
1491
+ (type, id, payload) => this.emitEvent(type, id, payload),
1492
+ () => this.hidePopup(),
1493
+ this.env,
1494
+ userId,
1495
+ style,
1496
+ sessionId,
1497
+ miniService,
1498
+ analyticsFeedbackSessionId
1499
+ );
1500
+ });
4117
1501
  }
4118
1502
  /** Hide the popup */
4119
1503
  hidePopup() {
@@ -4143,7 +1527,7 @@ var DeepdotsPopups = class {
4143
1527
  if (popupId) {
4144
1528
  const userIdFromData = data?.userId;
4145
1529
  const status = type === "popup_shown" ? "SHOWED" /* SHOWED */ : type === "survey_completed" ? "COMPLETED" /* COMPLETED */ : "PARTIAL" /* PARTIAL */;
4146
- void this.postPopupEvent(status, popupId, userIdFromData || this.config?.userId);
1530
+ void this.postPopupEvent(status, popupId, userIdFromData || this.tracking?.getUserId() || this.config?.userId);
4147
1531
  } else {
4148
1532
  this.debug("No popupId available to post event", { type, surveyId });
4149
1533
  }
@@ -4279,8 +1663,54 @@ var DeepdotsPopups = class {
4279
1663
  return defs.map((def) => this.normalizePopupDefinition(def)).filter((def) => !!def && this.isPopupDefinition(def));
4280
1664
  }
4281
1665
  };
1666
+
1667
+ // src/react-native/setup.ts
1668
+ function mmkvStorage(mmkv) {
1669
+ return {
1670
+ getItem: (k) => mmkv.getString(k) ?? null,
1671
+ setItem: (k, v) => mmkv.set(k, v),
1672
+ removeItem: (k) => mmkv.delete(k)
1673
+ };
1674
+ }
1675
+ function collectRnDevice(d) {
1676
+ return {
1677
+ device_type: d.isTablet?.() ? "tablet" : "mobile",
1678
+ os_version: d.getSystemVersion?.(),
1679
+ device_model: d.getDeviceId?.(),
1680
+ app_version: d.getVersion?.()
1681
+ };
1682
+ }
1683
+ function setupReactNative(sdk, config, deps = {}) {
1684
+ if (deps.renderer) sdk.setRenderer(deps.renderer);
1685
+ const storage = deps.mmkv ? mmkvStorage(deps.mmkv) : config.storage;
1686
+ const device = deps.deviceInfo ? collectRnDevice(deps.deviceInfo) : config.device;
1687
+ const platform = deps.platform ?? config.platform;
1688
+ sdk.init({ ...config, storage, device, platform });
1689
+ let subscription;
1690
+ if (deps.appState?.addEventListener) {
1691
+ subscription = deps.appState.addEventListener("change", (state) => {
1692
+ if (state === "active") sdk.onForeground();
1693
+ else sdk.onBackground();
1694
+ });
1695
+ }
1696
+ return () => {
1697
+ if (subscription && typeof subscription.remove === "function") subscription.remove();
1698
+ };
1699
+ }
4282
1700
  export {
1701
+ BrowserPopupRenderer,
1702
+ ContactManager,
4283
1703
  DeepdotsPopups,
4284
- POPUP_TRIGGER_CONDITION_STATUSES
1704
+ InMemoryStorage,
1705
+ NoopPopupRenderer,
1706
+ POPUP_TRIGGER_CONDITION_STATUSES,
1707
+ ReactNativePopupRenderer,
1708
+ buildAnalyticsFeedbackBody,
1709
+ buildSurveyHtml,
1710
+ collectRnDevice,
1711
+ createDefaultRenderer,
1712
+ createFeedbackSink,
1713
+ mmkvStorage,
1714
+ setupReactNative
4285
1715
  };
4286
1716
  //# sourceMappingURL=index.mjs.map