@magicfeedback/popup-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +372 -0
- package/dist/index.css +730 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +190 -0
- package/dist/index.d.ts +190 -0
- package/dist/index.js +2261 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2251 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +61 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js
|
|
34
|
+
var require_magicfeedback_sdk_browser = __commonJS({
|
|
35
|
+
"node_modules/@magicfeedback/native/dist/magicfeedback-sdk.browser.js"(exports, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
!(function(e, t) {
|
|
38
|
+
"object" == typeof exports && "object" == typeof module2 ? module2.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.magicfeedback = t() : e.magicfeedback = t();
|
|
39
|
+
})(self, (() => {
|
|
40
|
+
return e = { 945: function(e2, t2) {
|
|
41
|
+
var i = "undefined" != typeof self ? self : this, n = (function() {
|
|
42
|
+
function e3() {
|
|
43
|
+
this.fetch = false, this.DOMException = i.DOMException;
|
|
44
|
+
}
|
|
45
|
+
return e3.prototype = i, new e3();
|
|
46
|
+
})();
|
|
47
|
+
!(function(e3) {
|
|
48
|
+
!(function(t3) {
|
|
49
|
+
var i2 = "URLSearchParams" in e3, n2 = "Symbol" in e3 && "iterator" in Symbol, a2 = "FileReader" in e3 && "Blob" in e3 && (function() {
|
|
50
|
+
try {
|
|
51
|
+
return new Blob(), true;
|
|
52
|
+
} catch (e4) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
})(), s = "FormData" in e3, r = "ArrayBuffer" in e3;
|
|
56
|
+
if (r) 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) {
|
|
57
|
+
return e4 && o.indexOf(Object.prototype.toString.call(e4)) > -1;
|
|
58
|
+
};
|
|
59
|
+
function d(e4) {
|
|
60
|
+
if ("string" != typeof e4 && (e4 = String(e4)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e4)) throw new TypeError("Invalid character in header field name");
|
|
61
|
+
return e4.toLowerCase();
|
|
62
|
+
}
|
|
63
|
+
function c(e4) {
|
|
64
|
+
return "string" != typeof e4 && (e4 = String(e4)), e4;
|
|
65
|
+
}
|
|
66
|
+
function u(e4) {
|
|
67
|
+
var t4 = { next: function() {
|
|
68
|
+
var t5 = e4.shift();
|
|
69
|
+
return { done: void 0 === t5, value: t5 };
|
|
70
|
+
} };
|
|
71
|
+
return n2 && (t4[Symbol.iterator] = function() {
|
|
72
|
+
return t4;
|
|
73
|
+
}), t4;
|
|
74
|
+
}
|
|
75
|
+
function p(e4) {
|
|
76
|
+
this.map = {}, e4 instanceof p ? e4.forEach((function(e5, t4) {
|
|
77
|
+
this.append(t4, e5);
|
|
78
|
+
}), this) : Array.isArray(e4) ? e4.forEach((function(e5) {
|
|
79
|
+
this.append(e5[0], e5[1]);
|
|
80
|
+
}), this) : e4 && Object.getOwnPropertyNames(e4).forEach((function(t4) {
|
|
81
|
+
this.append(t4, e4[t4]);
|
|
82
|
+
}), this);
|
|
83
|
+
}
|
|
84
|
+
function h(e4) {
|
|
85
|
+
if (e4.bodyUsed) return Promise.reject(new TypeError("Already read"));
|
|
86
|
+
e4.bodyUsed = true;
|
|
87
|
+
}
|
|
88
|
+
function m(e4) {
|
|
89
|
+
return new Promise((function(t4, i3) {
|
|
90
|
+
e4.onload = function() {
|
|
91
|
+
t4(e4.result);
|
|
92
|
+
}, e4.onerror = function() {
|
|
93
|
+
i3(e4.error);
|
|
94
|
+
};
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
function f(e4) {
|
|
98
|
+
var t4 = new FileReader(), i3 = m(t4);
|
|
99
|
+
return t4.readAsArrayBuffer(e4), i3;
|
|
100
|
+
}
|
|
101
|
+
function g(e4) {
|
|
102
|
+
if (e4.slice) return e4.slice(0);
|
|
103
|
+
var t4 = new Uint8Array(e4.byteLength);
|
|
104
|
+
return t4.set(new Uint8Array(e4)), t4.buffer;
|
|
105
|
+
}
|
|
106
|
+
function v() {
|
|
107
|
+
return this.bodyUsed = false, this._initBody = function(e4) {
|
|
108
|
+
var t4;
|
|
109
|
+
this._bodyInit = e4, e4 ? "string" == typeof e4 ? this._bodyText = e4 : a2 && Blob.prototype.isPrototypeOf(e4) ? this._bodyBlob = e4 : s && FormData.prototype.isPrototypeOf(e4) ? this._bodyFormData = e4 : i2 && URLSearchParams.prototype.isPrototypeOf(e4) ? this._bodyText = e4.toString() : r && a2 && (t4 = e4) && DataView.prototype.isPrototypeOf(t4) ? (this._bodyArrayBuffer = g(e4.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : r && (ArrayBuffer.prototype.isPrototypeOf(e4) || l(e4)) ? this._bodyArrayBuffer = g(e4) : this._bodyText = e4 = Object.prototype.toString.call(e4) : this._bodyText = "", this.headers.get("content-type") || ("string" == typeof e4 ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : i2 && URLSearchParams.prototype.isPrototypeOf(e4) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
|
|
110
|
+
}, a2 && (this.blob = function() {
|
|
111
|
+
var e4 = h(this);
|
|
112
|
+
if (e4) return e4;
|
|
113
|
+
if (this._bodyBlob) return Promise.resolve(this._bodyBlob);
|
|
114
|
+
if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer]));
|
|
115
|
+
if (this._bodyFormData) throw new Error("could not read FormData body as blob");
|
|
116
|
+
return Promise.resolve(new Blob([this._bodyText]));
|
|
117
|
+
}, this.arrayBuffer = function() {
|
|
118
|
+
return this._bodyArrayBuffer ? h(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(f);
|
|
119
|
+
}), this.text = function() {
|
|
120
|
+
var e4, t4, i3, n3 = h(this);
|
|
121
|
+
if (n3) return n3;
|
|
122
|
+
if (this._bodyBlob) return e4 = this._bodyBlob, i3 = m(t4 = new FileReader()), t4.readAsText(e4), i3;
|
|
123
|
+
if (this._bodyArrayBuffer) return Promise.resolve((function(e5) {
|
|
124
|
+
for (var t5 = new Uint8Array(e5), i4 = new Array(t5.length), n4 = 0; n4 < t5.length; n4++) i4[n4] = String.fromCharCode(t5[n4]);
|
|
125
|
+
return i4.join("");
|
|
126
|
+
})(this._bodyArrayBuffer));
|
|
127
|
+
if (this._bodyFormData) throw new Error("could not read FormData body as text");
|
|
128
|
+
return Promise.resolve(this._bodyText);
|
|
129
|
+
}, s && (this.formData = function() {
|
|
130
|
+
return this.text().then(b);
|
|
131
|
+
}), this.json = function() {
|
|
132
|
+
return this.text().then(JSON.parse);
|
|
133
|
+
}, this;
|
|
134
|
+
}
|
|
135
|
+
p.prototype.append = function(e4, t4) {
|
|
136
|
+
e4 = d(e4), t4 = c(t4);
|
|
137
|
+
var i3 = this.map[e4];
|
|
138
|
+
this.map[e4] = i3 ? i3 + ", " + t4 : t4;
|
|
139
|
+
}, p.prototype.delete = function(e4) {
|
|
140
|
+
delete this.map[d(e4)];
|
|
141
|
+
}, p.prototype.get = function(e4) {
|
|
142
|
+
return e4 = d(e4), this.has(e4) ? this.map[e4] : null;
|
|
143
|
+
}, p.prototype.has = function(e4) {
|
|
144
|
+
return this.map.hasOwnProperty(d(e4));
|
|
145
|
+
}, p.prototype.set = function(e4, t4) {
|
|
146
|
+
this.map[d(e4)] = c(t4);
|
|
147
|
+
}, p.prototype.forEach = function(e4, t4) {
|
|
148
|
+
for (var i3 in this.map) this.map.hasOwnProperty(i3) && e4.call(t4, this.map[i3], i3, this);
|
|
149
|
+
}, p.prototype.keys = function() {
|
|
150
|
+
var e4 = [];
|
|
151
|
+
return this.forEach((function(t4, i3) {
|
|
152
|
+
e4.push(i3);
|
|
153
|
+
})), u(e4);
|
|
154
|
+
}, p.prototype.values = function() {
|
|
155
|
+
var e4 = [];
|
|
156
|
+
return this.forEach((function(t4) {
|
|
157
|
+
e4.push(t4);
|
|
158
|
+
})), u(e4);
|
|
159
|
+
}, p.prototype.entries = function() {
|
|
160
|
+
var e4 = [];
|
|
161
|
+
return this.forEach((function(t4, i3) {
|
|
162
|
+
e4.push([i3, t4]);
|
|
163
|
+
})), u(e4);
|
|
164
|
+
}, n2 && (p.prototype[Symbol.iterator] = p.prototype.entries);
|
|
165
|
+
var y = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
|
|
166
|
+
function E(e4, t4) {
|
|
167
|
+
var i3, n3, a3 = (t4 = t4 || {}).body;
|
|
168
|
+
if (e4 instanceof E) {
|
|
169
|
+
if (e4.bodyUsed) throw new TypeError("Already read");
|
|
170
|
+
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, a3 || null == e4._bodyInit || (a3 = e4._bodyInit, e4.bodyUsed = true);
|
|
171
|
+
} else this.url = String(e4);
|
|
172
|
+
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) && a3) throw new TypeError("Body not allowed for GET or HEAD requests");
|
|
173
|
+
this._initBody(a3);
|
|
174
|
+
}
|
|
175
|
+
function b(e4) {
|
|
176
|
+
var t4 = new FormData();
|
|
177
|
+
return e4.trim().split("&").forEach((function(e5) {
|
|
178
|
+
if (e5) {
|
|
179
|
+
var i3 = e5.split("="), n3 = i3.shift().replace(/\+/g, " "), a3 = i3.join("=").replace(/\+/g, " ");
|
|
180
|
+
t4.append(decodeURIComponent(n3), decodeURIComponent(a3));
|
|
181
|
+
}
|
|
182
|
+
})), t4;
|
|
183
|
+
}
|
|
184
|
+
function A(e4, t4) {
|
|
185
|
+
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);
|
|
186
|
+
}
|
|
187
|
+
E.prototype.clone = function() {
|
|
188
|
+
return new E(this, { body: this._bodyInit });
|
|
189
|
+
}, v.call(E.prototype), v.call(A.prototype), A.prototype.clone = function() {
|
|
190
|
+
return new A(this._bodyInit, { status: this.status, statusText: this.statusText, headers: new p(this.headers), url: this.url });
|
|
191
|
+
}, A.error = function() {
|
|
192
|
+
var e4 = new A(null, { status: 0, statusText: "" });
|
|
193
|
+
return e4.type = "error", e4;
|
|
194
|
+
};
|
|
195
|
+
var k = [301, 302, 303, 307, 308];
|
|
196
|
+
A.redirect = function(e4, t4) {
|
|
197
|
+
if (-1 === k.indexOf(t4)) throw new RangeError("Invalid status code");
|
|
198
|
+
return new A(null, { status: t4, headers: { location: e4 } });
|
|
199
|
+
}, t3.DOMException = e3.DOMException;
|
|
200
|
+
try {
|
|
201
|
+
new t3.DOMException();
|
|
202
|
+
} catch (e4) {
|
|
203
|
+
t3.DOMException = function(e5, t4) {
|
|
204
|
+
this.message = e5, this.name = t4;
|
|
205
|
+
var i3 = Error(e5);
|
|
206
|
+
this.stack = i3.stack;
|
|
207
|
+
}, t3.DOMException.prototype = Object.create(Error.prototype), t3.DOMException.prototype.constructor = t3.DOMException;
|
|
208
|
+
}
|
|
209
|
+
function C(e4, i3) {
|
|
210
|
+
return new Promise((function(n3, s2) {
|
|
211
|
+
var r2 = new E(e4, i3);
|
|
212
|
+
if (r2.signal && r2.signal.aborted) return s2(new t3.DOMException("Aborted", "AbortError"));
|
|
213
|
+
var o2 = new XMLHttpRequest();
|
|
214
|
+
function l2() {
|
|
215
|
+
o2.abort();
|
|
216
|
+
}
|
|
217
|
+
o2.onload = function() {
|
|
218
|
+
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) {
|
|
219
|
+
var i5 = e6.split(":"), n4 = i5.shift().trim();
|
|
220
|
+
if (n4) {
|
|
221
|
+
var a4 = i5.join(":").trim();
|
|
222
|
+
t4.append(n4, a4);
|
|
223
|
+
}
|
|
224
|
+
})), t4) };
|
|
225
|
+
i4.url = "responseURL" in o2 ? o2.responseURL : i4.headers.get("X-Request-URL");
|
|
226
|
+
var a3 = "response" in o2 ? o2.response : o2.responseText;
|
|
227
|
+
n3(new A(a3, i4));
|
|
228
|
+
}, o2.onerror = function() {
|
|
229
|
+
s2(new TypeError("Network request failed"));
|
|
230
|
+
}, o2.ontimeout = function() {
|
|
231
|
+
s2(new TypeError("Network request failed"));
|
|
232
|
+
}, o2.onabort = function() {
|
|
233
|
+
s2(new t3.DOMException("Aborted", "AbortError"));
|
|
234
|
+
}, o2.open(r2.method, r2.url, true), "include" === r2.credentials ? o2.withCredentials = true : "omit" === r2.credentials && (o2.withCredentials = false), "responseType" in o2 && a2 && (o2.responseType = "blob"), r2.headers.forEach((function(e5, t4) {
|
|
235
|
+
o2.setRequestHeader(t4, e5);
|
|
236
|
+
})), r2.signal && (r2.signal.addEventListener("abort", l2), o2.onreadystatechange = function() {
|
|
237
|
+
4 === o2.readyState && r2.signal.removeEventListener("abort", l2);
|
|
238
|
+
}), o2.send(void 0 === r2._bodyInit ? null : r2._bodyInit);
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
C.polyfill = true, e3.fetch || (e3.fetch = C, e3.Headers = p, e3.Request = E, e3.Response = A), t3.Headers = p, t3.Request = E, t3.Response = A, t3.fetch = C, Object.defineProperty(t3, "__esModule", { value: true });
|
|
242
|
+
})({});
|
|
243
|
+
})(n), n.fetch.ponyfill = true, delete n.fetch.polyfill;
|
|
244
|
+
var a = n;
|
|
245
|
+
(t2 = a.fetch).default = a.fetch, t2.fetch = a.fetch, t2.Headers = a.Headers, t2.Request = a.Request, t2.Response = a.Response, e2.exports = t2;
|
|
246
|
+
}, 317: (e2, t2) => {
|
|
247
|
+
"use strict";
|
|
248
|
+
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/";
|
|
249
|
+
}, 156: function(e2, t2, i) {
|
|
250
|
+
"use strict";
|
|
251
|
+
var n = this && this.__importDefault || function(e3) {
|
|
252
|
+
return e3 && e3.__esModule ? e3 : { default: e3 };
|
|
253
|
+
};
|
|
254
|
+
Object.defineProperty(t2, "__esModule", { value: true });
|
|
255
|
+
const a = n(i(927));
|
|
256
|
+
let s = null;
|
|
257
|
+
s || (s = (0, a.default)()), t2.default = s;
|
|
258
|
+
}, 927: function(e2, t2, i) {
|
|
259
|
+
"use strict";
|
|
260
|
+
var n = this && this.__awaiter || function(e3, t3, i2, n2) {
|
|
261
|
+
return new (i2 || (i2 = Promise))((function(a2, s2) {
|
|
262
|
+
function r2(e4) {
|
|
263
|
+
try {
|
|
264
|
+
l2(n2.next(e4));
|
|
265
|
+
} catch (e5) {
|
|
266
|
+
s2(e5);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function o2(e4) {
|
|
270
|
+
try {
|
|
271
|
+
l2(n2.throw(e4));
|
|
272
|
+
} catch (e5) {
|
|
273
|
+
s2(e5);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function l2(e4) {
|
|
277
|
+
var t4;
|
|
278
|
+
e4.done ? a2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
|
|
279
|
+
e5(t4);
|
|
280
|
+
}))).then(r2, o2);
|
|
281
|
+
}
|
|
282
|
+
l2((n2 = n2.apply(e3, t3 || [])).next());
|
|
283
|
+
}));
|
|
284
|
+
};
|
|
285
|
+
Object.defineProperty(t2, "__esModule", { value: true });
|
|
286
|
+
const a = i(57), s = i(665), r = i(256), o = i(313), l = i(317);
|
|
287
|
+
t2.default = function() {
|
|
288
|
+
const e3 = new s.Config();
|
|
289
|
+
let t3;
|
|
290
|
+
return { init: function(i2) {
|
|
291
|
+
(null == i2 ? void 0 : i2.debug) && e3.set("debug", null == i2 ? void 0 : i2.debug), 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 = new r.Log(e3), t3.log("Initialized Magicfeedback", e3);
|
|
292
|
+
}, send: function(i2, a2, s2, r2 = true, l2, d) {
|
|
293
|
+
return n(this, void 0, void 0, (function* () {
|
|
294
|
+
i2 || t3.err("No appID provided"), a2 || 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");
|
|
295
|
+
const n2 = e3.get("url"), c = { integration: i2, publicKey: a2, privateKey: d, completed: r2, id: l2, feedback: s2 };
|
|
296
|
+
try {
|
|
297
|
+
const e4 = yield (0, o.sendFeedback)(n2, c, t3);
|
|
298
|
+
return t3.log("sent native feedback"), e4;
|
|
299
|
+
} catch (e4) {
|
|
300
|
+
return t3.err("error native feedback", e4), false;
|
|
301
|
+
}
|
|
302
|
+
}));
|
|
303
|
+
}, form: function(i2, n2) {
|
|
304
|
+
return i2 || t3.err("No appID provided"), n2 || t3.err("No publicKey provided"), new a.Form(e3, i2, n2);
|
|
305
|
+
}, session: function(i2) {
|
|
306
|
+
return i2 || t3.err("No sessionId provided"), new a.Form(e3, i2);
|
|
307
|
+
} };
|
|
308
|
+
};
|
|
309
|
+
}, 79: (e2, t2) => {
|
|
310
|
+
"use strict";
|
|
311
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.History = void 0, t2.History = class {
|
|
312
|
+
constructor() {
|
|
313
|
+
this.items = [];
|
|
314
|
+
}
|
|
315
|
+
enqueue(e3) {
|
|
316
|
+
this.items.push(e3);
|
|
317
|
+
}
|
|
318
|
+
dequeue() {
|
|
319
|
+
return this.items.shift();
|
|
320
|
+
}
|
|
321
|
+
rollback() {
|
|
322
|
+
return this.items.pop();
|
|
323
|
+
}
|
|
324
|
+
front() {
|
|
325
|
+
return this.items[0];
|
|
326
|
+
}
|
|
327
|
+
back() {
|
|
328
|
+
return this.items[this.items.length - 1];
|
|
329
|
+
}
|
|
330
|
+
isEmpty() {
|
|
331
|
+
return 0 === this.items.length;
|
|
332
|
+
}
|
|
333
|
+
size() {
|
|
334
|
+
return this.items.length;
|
|
335
|
+
}
|
|
336
|
+
get(e3) {
|
|
337
|
+
return this.items[e3];
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
}, 665: (e2, t2) => {
|
|
341
|
+
"use strict";
|
|
342
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.Config = void 0, t2.Config = class {
|
|
343
|
+
constructor() {
|
|
344
|
+
this.variables = {}, this.variables.env = "prod", this.variables.debug = false;
|
|
345
|
+
}
|
|
346
|
+
get(e3) {
|
|
347
|
+
return this.variables[e3];
|
|
348
|
+
}
|
|
349
|
+
set(e3, t3) {
|
|
350
|
+
this.variables[e3] = t3;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}, 57: function(e2, t2, i) {
|
|
354
|
+
"use strict";
|
|
355
|
+
var n = this && this.__awaiter || function(e3, t3, i2, n2) {
|
|
356
|
+
return new (i2 || (i2 = Promise))((function(a2, s2) {
|
|
357
|
+
function r2(e4) {
|
|
358
|
+
try {
|
|
359
|
+
l2(n2.next(e4));
|
|
360
|
+
} catch (e5) {
|
|
361
|
+
s2(e5);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function o2(e4) {
|
|
365
|
+
try {
|
|
366
|
+
l2(n2.throw(e4));
|
|
367
|
+
} catch (e5) {
|
|
368
|
+
s2(e5);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function l2(e4) {
|
|
372
|
+
var t4;
|
|
373
|
+
e4.done ? a2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
|
|
374
|
+
e5(t4);
|
|
375
|
+
}))).then(r2, o2);
|
|
376
|
+
}
|
|
377
|
+
l2((n2 = n2.apply(e3, t3 || [])).next());
|
|
378
|
+
}));
|
|
379
|
+
};
|
|
380
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.Form = void 0;
|
|
381
|
+
const a = i(558), s = i(256), r = i(313), o = i(213), l = i(217), d = i(700), c = i(591), u = i(79), p = i(636);
|
|
382
|
+
t2.Form = class {
|
|
383
|
+
constructor(e3, t3, i2) {
|
|
384
|
+
this.config = e3, this.log = new s.Log(e3), this.formOptionsConfig = { addButton: true, sendButtonText: "Send", backButtonText: "Back", nextButtonText: "Next", addSuccessScreen: true, getMetaData: true, 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: [], metrics: [], metadata: [] }, this.history = new u.History(), this.graph = new l.PageGraph([]), this.progress = 0, this.total = 0, this.completed = false, this.timeToCompleted = 0;
|
|
385
|
+
}
|
|
386
|
+
generate(e3, t3) {
|
|
387
|
+
var i2, a2, s2, o2, l2, d2, c2;
|
|
388
|
+
return n(this, void 0, void 0, (function* () {
|
|
389
|
+
try {
|
|
390
|
+
this.formOptionsConfig = Object.assign(Object.assign({}, this.formOptionsConfig), t3), this.selector = e3;
|
|
391
|
+
let n2 = this.formData;
|
|
392
|
+
if (void 0 !== this.formData && this.formData || (n2 = "" !== this.publicKey ? yield (0, r.getForm)(this.url, this.appId, this.publicKey, this.log) : yield (0, r.getSessionForm)(this.url, this.appId, this.log)), void 0 === n2 || !n2) throw new Error(`No data for app ${this.appId}`);
|
|
393
|
+
if (null === (i2 = n2.error) || void 0 === i2 ? void 0 : i2.message) throw new Error(n2.error.message);
|
|
394
|
+
if (n2.questions = (null === (a2 = n2.questions) || void 0 === a2 ? void 0 : a2.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) => {
|
|
395
|
+
var t4;
|
|
396
|
+
return e4.integrationQuestions = null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.filter(((e5) => "ACTIVE" === e5.status));
|
|
397
|
+
})), 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}`);
|
|
398
|
+
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) => {
|
|
399
|
+
var t4;
|
|
400
|
+
return (null === (t4 = e4.integrationQuestions) || void 0 === t4 ? void 0 : t4.length) > 0;
|
|
401
|
+
})), 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();
|
|
402
|
+
} catch (e4) {
|
|
403
|
+
return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 })));
|
|
404
|
+
}
|
|
405
|
+
}));
|
|
406
|
+
}
|
|
407
|
+
formatPages() {
|
|
408
|
+
var e3;
|
|
409
|
+
if (this.formData) switch (this.formData.identity) {
|
|
410
|
+
case "MAGICSURVEY":
|
|
411
|
+
this.formData.pages = [], null === (e3 = this.formData.questions) || void 0 === e3 || e3.forEach(((e4) => {
|
|
412
|
+
var t4, i2;
|
|
413
|
+
const n2 = new c.PageRoute(e4.id, e4.ref, c.OperatorType.NOEQUAL, [], c.TransitionType.PAGE, (e4.position + 1).toString(), e4.position.toString()), a2 = new d.Page(e4.position.toString(), e4.position, this.appId, [e4], [n2]);
|
|
414
|
+
null === (i2 = null === (t4 = this.formData) || void 0 === t4 ? void 0 : t4.pages) || void 0 === i2 || i2.push(a2);
|
|
415
|
+
}));
|
|
416
|
+
break;
|
|
417
|
+
case "MAGICFORM":
|
|
418
|
+
const t3 = new d.Page("1", 1, this.appId, this.formData.questions, []);
|
|
419
|
+
this.formData.pages = [t3];
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
generateContainer() {
|
|
423
|
+
let e3 = document.getElementById(this.selector);
|
|
424
|
+
if (!e3 && (e3 = document.getElementById("magicfeedback-container-" + this.appId), !e3)) throw new Error(`Element with ID '${this.selector}' not found.`);
|
|
425
|
+
return e3.classList.add("magicfeedback-container"), e3.id = "magicfeedback-container-" + this.appId, e3.innerHTML = "", e3;
|
|
426
|
+
}
|
|
427
|
+
generateForm() {
|
|
428
|
+
var e3, t3, i2, a2;
|
|
429
|
+
return n(this, void 0, void 0, (function* () {
|
|
430
|
+
try {
|
|
431
|
+
if (console.log("Generating form for appId:", this.appId), !this.formData || !this.formData.pages || 0 === this.formData.pages.length) throw new Error("No form data");
|
|
432
|
+
this.graph = new l.PageGraph(this.formData.pages.sort(((e4, t4) => e4.position - t4.position)));
|
|
433
|
+
let n2 = this.generateContainer();
|
|
434
|
+
const s2 = document.createElement("form");
|
|
435
|
+
s2.classList.add("magicfeedback-form"), s2.id = "magicfeedback-" + this.appId, s2.addEventListener("submit", ((e4) => e4.preventDefault()));
|
|
436
|
+
const r2 = document.createElement("div");
|
|
437
|
+
r2.classList.add("magicfeedback-questions"), r2.id = "magicfeedback-questions-" + this.appId;
|
|
438
|
+
const d2 = this.graph.getFirstPage();
|
|
439
|
+
if (!d2) throw new Error("No page found");
|
|
440
|
+
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) => r2.appendChild(e4))), s2.appendChild(r2), this.history.enqueue(d2), n2.appendChild(s2), this.progress = this.total - this.graph.findMaxDepth(d2), this.formOptionsConfig.addButton) {
|
|
441
|
+
const e4 = (0, o.renderActions)(null === (a2 = this.formData) || void 0 === a2 ? void 0 : a2.identity, (() => this.back()), this.formOptionsConfig.sendButtonText, this.formOptionsConfig.backButtonText, this.formOptionsConfig.nextButtonText);
|
|
442
|
+
s2.appendChild(e4);
|
|
443
|
+
}
|
|
444
|
+
this.formOptionsConfig.addButton && s2.addEventListener("submit", ((e4) => {
|
|
445
|
+
e4.preventDefault(), this.send();
|
|
446
|
+
})), this.timeToCompleted = (/* @__PURE__ */ new Date()).getTime() / 1e3, this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, progress: this.progress, total: this.total, formData: this.formData }));
|
|
447
|
+
} catch (e4) {
|
|
448
|
+
return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
|
|
449
|
+
}
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
startForm() {
|
|
453
|
+
this.generateForm();
|
|
454
|
+
}
|
|
455
|
+
generateWelcomeMessage(e3) {
|
|
456
|
+
return n(this, void 0, void 0, (function* () {
|
|
457
|
+
try {
|
|
458
|
+
const t3 = this.generateContainer(), i2 = (0, o.renderStartMessage)(e3, this.formOptionsConfig.addButton, this.formOptionsConfig.startButtonText, (() => this.startForm()));
|
|
459
|
+
t3.appendChild(i2), this.formOptionsConfig.onLoadedEvent && (yield this.formOptionsConfig.onLoadedEvent({ loading: false, formData: this.formData }));
|
|
460
|
+
} catch (e4) {
|
|
461
|
+
return this.log.err(e4), void (this.formOptionsConfig.onLoadedEvent && this.formOptionsConfig.onLoadedEvent({ loading: false, error: e4 }));
|
|
462
|
+
}
|
|
463
|
+
}));
|
|
464
|
+
}
|
|
465
|
+
getMetaData() {
|
|
466
|
+
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] }), 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 && ![a.FEEDBACKAPPANSWERTYPE.CONSENT, a.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
|
+
}
|
|
483
|
+
const r2 = yield this.pushAnswers(false);
|
|
484
|
+
if (!r2) throw new Error("No response");
|
|
485
|
+
this.id = r2, yield this.processNextQuestion(n2);
|
|
486
|
+
} catch (e4) {
|
|
487
|
+
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 }));
|
|
488
|
+
}
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
answer() {
|
|
492
|
+
const e3 = document.getElementById("magicfeedback-" + this.appId);
|
|
493
|
+
if (!e3) return this.log.err(`Form "${e3}" not found.`), void (this.feedback.answers = []);
|
|
494
|
+
const t3 = this.history.back();
|
|
495
|
+
if (!t3) throw new Error("No page found");
|
|
496
|
+
const i2 = [];
|
|
497
|
+
let n2 = false;
|
|
498
|
+
if (e3.querySelectorAll(".magicfeedback-input").forEach(((e4) => {
|
|
499
|
+
const s2 = t3.questions.find(((t4) => {
|
|
500
|
+
var i3;
|
|
501
|
+
return null === (i3 = e4.name) || void 0 === i3 ? void 0 : i3.includes(t4.ref);
|
|
502
|
+
})), o2 = e4.type, l2 = e4.classList[0], d2 = { key: e4.name, value: [] }, c2 = "magicfeedback-consent" === l2 ? e4.checked.toString() : e4.value;
|
|
503
|
+
if (d2.key && "" !== d2.key) {
|
|
504
|
+
switch (null == s2 ? void 0 : s2.type) {
|
|
505
|
+
case a.FEEDBACKAPPANSWERTYPE.EMAIL:
|
|
506
|
+
case a.FEEDBACKAPPANSWERTYPE.TEXT:
|
|
507
|
+
case a.FEEDBACKAPPANSWERTYPE.LONGTEXT:
|
|
508
|
+
case a.FEEDBACKAPPANSWERTYPE.NUMBER:
|
|
509
|
+
case a.FEEDBACKAPPANSWERTYPE.DATE:
|
|
510
|
+
case a.FEEDBACKAPPANSWERTYPE.CONTACT:
|
|
511
|
+
if ("" !== c2) {
|
|
512
|
+
if ("email" === o2) {
|
|
513
|
+
if (!(0, r.validateEmail)(c2)) {
|
|
514
|
+
this.log.err("Invalid email"), n2 = true;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
this.feedback.profile.push({ key: "email", value: [c2] });
|
|
518
|
+
}
|
|
519
|
+
d2.value.push(c2);
|
|
520
|
+
}
|
|
521
|
+
break;
|
|
522
|
+
case a.FEEDBACKAPPANSWERTYPE.CONSENT:
|
|
523
|
+
d2.value.push(String(e4.checked));
|
|
524
|
+
break;
|
|
525
|
+
case a.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
|
|
526
|
+
const t4 = e4.id;
|
|
527
|
+
d2.value.push(`${t4}:${c2}%`);
|
|
528
|
+
break;
|
|
529
|
+
case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
|
|
530
|
+
case a.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
|
|
531
|
+
case a.FEEDBACKAPPANSWERTYPE.RATING_STAR:
|
|
532
|
+
case a.FEEDBACKAPPANSWERTYPE.RADIO:
|
|
533
|
+
case a.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
|
|
534
|
+
case a.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
|
|
535
|
+
(e4.checked || e4.id.includes("extra-option-")) && d2.value.push(c2);
|
|
536
|
+
break;
|
|
537
|
+
case a.FEEDBACKAPPANSWERTYPE.SELECT:
|
|
538
|
+
d2.value.push(c2);
|
|
539
|
+
break;
|
|
540
|
+
case a.FEEDBACKAPPANSWERTYPE.BOOLEAN:
|
|
541
|
+
case a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
|
|
542
|
+
e4.checked && d2.value.push(c2);
|
|
543
|
+
break;
|
|
544
|
+
case a.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
|
|
545
|
+
d2.value.push(c2);
|
|
546
|
+
}
|
|
547
|
+
if ((null == i2 ? void 0 : i2.length) > 0 && (null == i2 ? void 0 : i2.find(((e5) => e5.key === d2.key)))) {
|
|
548
|
+
const e5 = i2.findIndex(((e6) => e6.key === d2.key));
|
|
549
|
+
i2[e5].value = [...i2[e5].value, ...d2.value];
|
|
550
|
+
} else i2.push(d2);
|
|
551
|
+
}
|
|
552
|
+
})), n2) return this.feedback.answers = [], void t3.setAnswer([]);
|
|
553
|
+
try {
|
|
554
|
+
t3.questions.filter(((e4) => e4.type === a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX)).forEach(((e4) => {
|
|
555
|
+
const t4 = e4.ref + "-", n3 = i2.filter(((e5) => e5.key.startsWith(t4)));
|
|
556
|
+
if (0 === n3.length) return;
|
|
557
|
+
const a2 = n3.map(((e5) => ({ key: e5.key.substring(t4.length), value: e5.value }))), s2 = { key: e4.ref, value: [JSON.stringify(a2)] };
|
|
558
|
+
for (const e5 of n3) {
|
|
559
|
+
const t5 = i2.findIndex(((t6) => t6.key === e5.key));
|
|
560
|
+
-1 !== t5 && i2.splice(t5, 1);
|
|
561
|
+
}
|
|
562
|
+
const r2 = i2.findIndex(((t5) => t5.key === e4.ref));
|
|
563
|
+
-1 !== r2 ? i2[r2] = s2 : i2.push(s2);
|
|
564
|
+
}));
|
|
565
|
+
} catch (e4) {
|
|
566
|
+
this.log.err("Error agrupando MULTI_QUESTION_MATRIX", e4);
|
|
567
|
+
}
|
|
568
|
+
this.feedback.answers = i2, t3.setAnswer(i2);
|
|
569
|
+
}
|
|
570
|
+
finish() {
|
|
571
|
+
return n(this, void 0, void 0, (function* () {
|
|
572
|
+
if (this.completed = true, this.timeToCompleted = (/* @__PURE__ */ new Date()).getTime() - this.timeToCompleted, this.feedback.metadata.push({ key: "time-to-complete", value: [this.timeToCompleted.toString()] }), this.formOptionsConfig.addSuccessScreen) {
|
|
573
|
+
const e3 = document.getElementById("magicfeedback-container-" + this.appId);
|
|
574
|
+
e3.childNodes.length > 0 && e3.removeChild(e3.childNodes[0]);
|
|
575
|
+
const t3 = (0, o.renderSuccess)(this.formOptionsConfig.successMessage || "Thank you for your feedback!");
|
|
576
|
+
e3.appendChild(t3);
|
|
577
|
+
}
|
|
578
|
+
this.answer();
|
|
579
|
+
try {
|
|
580
|
+
const e3 = yield this.pushAnswers(true);
|
|
581
|
+
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}:");
|
|
582
|
+
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 }));
|
|
583
|
+
} catch (e3) {
|
|
584
|
+
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 }));
|
|
585
|
+
}
|
|
586
|
+
}));
|
|
587
|
+
}
|
|
588
|
+
pushAnswers(e3 = false) {
|
|
589
|
+
return n(this, void 0, void 0, (function* () {
|
|
590
|
+
try {
|
|
591
|
+
const t3 = this.config.get("url"), i2 = { integration: this.appId, publicKey: this.publicKey, feedback: this.feedback, completed: e3 };
|
|
592
|
+
return yield (0, r.sendFeedback)(t3, this.id ? Object.assign(Object.assign({}, i2), { sessionId: this.id }) : i2, this.log);
|
|
593
|
+
} catch (e4) {
|
|
594
|
+
return this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), "";
|
|
595
|
+
}
|
|
596
|
+
}));
|
|
597
|
+
}
|
|
598
|
+
callFollowUpQuestion(e3) {
|
|
599
|
+
var t3;
|
|
600
|
+
return n(this, void 0, void 0, (function* () {
|
|
601
|
+
if (!(null == e3 ? void 0 : e3.followup)) return null;
|
|
602
|
+
try {
|
|
603
|
+
if (0 === this.feedback.answers.length) throw new Error("No answers provided");
|
|
604
|
+
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 });
|
|
605
|
+
return yield (0, r.getFollowUpQuestion)(i2, n2, this.log);
|
|
606
|
+
} catch (e4) {
|
|
607
|
+
throw this.log.err(`An error occurred while submitting the form ${this.appId}:`, e4), e4;
|
|
608
|
+
}
|
|
609
|
+
}));
|
|
610
|
+
}
|
|
611
|
+
processNextQuestion(e3) {
|
|
612
|
+
var t3, i2, a2;
|
|
613
|
+
return n(this, void 0, void 0, (function* () {
|
|
614
|
+
const n2 = this.history.back();
|
|
615
|
+
if (!n2) throw new Error("No page found");
|
|
616
|
+
const s2 = n2.getFollowupQuestions();
|
|
617
|
+
if (0 === (null == s2 ? void 0 : s2.length)) return void (yield this.renderNextQuestion(e3, n2));
|
|
618
|
+
const r2 = [];
|
|
619
|
+
for (const e4 of s2) {
|
|
620
|
+
const t4 = n2.questions.find(((t5) => t5.ref === e4));
|
|
621
|
+
if (t4) {
|
|
622
|
+
const e5 = yield this.callFollowUpQuestion(t4);
|
|
623
|
+
e5 && r2.push(e5);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (0 === r2.length) return void (yield this.renderNextQuestion(e3, n2));
|
|
627
|
+
const l2 = new d.Page(n2.id, n2.position, this.appId, r2, n2.edges), c2 = new p.PageNode(n2.id, n2.position, n2.edges, l2, r2, true);
|
|
628
|
+
c2.elements = (0, o.renderQuestions)(r2, 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 === (a2 = c2.elements) || void 0 === a2 || a2.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 }));
|
|
629
|
+
}));
|
|
630
|
+
}
|
|
631
|
+
renderNextQuestion(e3, t3) {
|
|
632
|
+
var i2, s2, r2, l2, d2;
|
|
633
|
+
return n(this, void 0, void 0, (function* () {
|
|
634
|
+
let n2 = this.graph.getNextPage(t3, this.feedback.answers);
|
|
635
|
+
if (!n2) return void this.finish();
|
|
636
|
+
const u2 = n2.edges.filter(((e4) => "PRECONDITIONAL" === e4.typeCondition)).sort(((e4, t4) => e4.position < t4.position ? -1 : e4.position > t4.position ? 1 : 0));
|
|
637
|
+
if ((null == u2 ? void 0 : u2.length) > 0) {
|
|
638
|
+
let t4 = null;
|
|
639
|
+
const r3 = u2.map(((e4) => e4.questionRef));
|
|
640
|
+
for (let e4 = this.history.size() - 1; e4 >= 0; e4--) {
|
|
641
|
+
const n3 = this.history.get(e4);
|
|
642
|
+
if (n3 && (t4 = null === (i2 = n3.answers) || void 0 === i2 ? void 0 : i2.find(((e5) => r3.includes(e5.key))), t4)) break;
|
|
643
|
+
}
|
|
644
|
+
let o2 = !u2.some(((e4) => e4.transition === c.TransitionType.ALLOW));
|
|
645
|
+
if (t4) for (const i3 of u2) {
|
|
646
|
+
let r4 = false;
|
|
647
|
+
const l3 = null === (s2 = this.formData) || void 0 === s2 ? void 0 : s2.questions.find(((e4) => e4.ref === i3.questionRef)), d3 = Array.isArray(t4.value) ? t4.value : [t4.value], u3 = Array.isArray(i3.value) ? i3.value : [i3.value];
|
|
648
|
+
if ((null == l3 ? void 0 : l3.type) === a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) r4 = this.evaluateMatrixPreconditional(i3, t4);
|
|
649
|
+
else switch (i3.typeOperator) {
|
|
650
|
+
case "EQUAL":
|
|
651
|
+
case "INQ":
|
|
652
|
+
r4 = d3.some(((e4) => u3.includes(e4)));
|
|
653
|
+
break;
|
|
654
|
+
case "NOEQUAL":
|
|
655
|
+
case "NINQ":
|
|
656
|
+
r4 = d3.every(((e4) => !u3.includes(e4)));
|
|
657
|
+
break;
|
|
658
|
+
case "GREATER":
|
|
659
|
+
r4 = d3.some(((e4) => Number(e4) > Number(u3[0])));
|
|
660
|
+
break;
|
|
661
|
+
case "LESS":
|
|
662
|
+
r4 = d3.some(((e4) => Number(e4) < Number(u3[0])));
|
|
663
|
+
break;
|
|
664
|
+
case "GREATEREQUAL":
|
|
665
|
+
r4 = d3.some(((e4) => Number(e4) >= Number(u3[0])));
|
|
666
|
+
break;
|
|
667
|
+
case "LESSEQUAL":
|
|
668
|
+
r4 = d3.some(((e4) => Number(e4) <= Number(u3[0])));
|
|
669
|
+
}
|
|
670
|
+
if (r4) switch (this.feedback.answers = [], i3.transition) {
|
|
671
|
+
case c.TransitionType.NEXT:
|
|
672
|
+
return void (n2 && (yield this.renderNextQuestion(e3, n2)));
|
|
673
|
+
case c.TransitionType.ALLOW:
|
|
674
|
+
o2 = true;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (!o2) return this.feedback.answers = [], void (n2 && (yield this.renderNextQuestion(e3, n2)));
|
|
678
|
+
}
|
|
679
|
+
n2.elements = (0, o.renderQuestions)(n2.questions, this.formOptionsConfig.questionFormat, null === (r2 = this.formData) || void 0 === r2 ? void 0 : r2.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 }));
|
|
680
|
+
}));
|
|
681
|
+
}
|
|
682
|
+
back() {
|
|
683
|
+
var e3;
|
|
684
|
+
return n(this, void 0, void 0, (function* () {
|
|
685
|
+
if (0 === this.history.size()) return;
|
|
686
|
+
const t3 = document.getElementById("magicfeedback-questions-" + this.appId);
|
|
687
|
+
t3 && t3.childNodes.length > 0 && (t3.innerHTML = ""), this.history.rollback();
|
|
688
|
+
const i2 = this.history.back();
|
|
689
|
+
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" }));
|
|
690
|
+
}));
|
|
691
|
+
}
|
|
692
|
+
previewQuestion(e3, t3, i2) {
|
|
693
|
+
var n2, a2;
|
|
694
|
+
const s2 = Array.isArray(t3) ? t3 : [t3];
|
|
695
|
+
if (!s2 || 0 === s2.length) throw new Error("[MagicFeedback] No question provided for preview");
|
|
696
|
+
const r2 = document.getElementById(e3);
|
|
697
|
+
if (!r2) throw new Error(`[MagicFeedback] Element with ID '${e3}' not found.`);
|
|
698
|
+
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 === (a2 = this.formData) || void 0 === a2 ? void 0 : a2.product) || { customIcons: false }, clearContainer: u2 = true, wrap: p2 = true } = i2 || {};
|
|
699
|
+
u2 && (r2.innerHTML = "");
|
|
700
|
+
let h = [];
|
|
701
|
+
try {
|
|
702
|
+
h = (0, o.renderQuestions)(s2, l2, d2, c2);
|
|
703
|
+
} catch (e4) {
|
|
704
|
+
throw this.log.err(e4), e4;
|
|
705
|
+
}
|
|
706
|
+
let m = r2;
|
|
707
|
+
if (p2) {
|
|
708
|
+
const e4 = document.createElement("div");
|
|
709
|
+
e4.classList.add("magicfeedback-preview-question"), m.appendChild(e4), m = e4;
|
|
710
|
+
}
|
|
711
|
+
return h.forEach(((e4) => m.appendChild(e4))), r2;
|
|
712
|
+
}
|
|
713
|
+
parseMatrixAnswerPre(e3) {
|
|
714
|
+
if (!e3 || !e3.value) return [];
|
|
715
|
+
if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
|
|
716
|
+
const t3 = JSON.parse(e3.value[0]);
|
|
717
|
+
if (Array.isArray(t3)) return t3;
|
|
718
|
+
} catch (e4) {
|
|
719
|
+
return [];
|
|
720
|
+
}
|
|
721
|
+
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 : [];
|
|
722
|
+
}
|
|
723
|
+
evaluateMatrixPreconditional(e3, t3) {
|
|
724
|
+
const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), a2 = this.parseMatrixAnswerPre(t3);
|
|
725
|
+
if (!a2.length) return false;
|
|
726
|
+
const s2 = n2.size > 0 ? a2.filter(((e4) => n2.has(e4.key))) : a2;
|
|
727
|
+
if (!s2.length) return false;
|
|
728
|
+
switch (e3.typeOperator) {
|
|
729
|
+
case "EQUAL":
|
|
730
|
+
case "INQ":
|
|
731
|
+
return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
|
|
732
|
+
case "NOEQUAL":
|
|
733
|
+
case "NINQ":
|
|
734
|
+
return s2.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
|
|
735
|
+
case "GREATER":
|
|
736
|
+
return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
|
|
737
|
+
case "LESS":
|
|
738
|
+
return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
|
|
739
|
+
case "GREATEREQUAL":
|
|
740
|
+
return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
|
|
741
|
+
case "LESSEQUAL":
|
|
742
|
+
return s2.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
|
|
743
|
+
default:
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}, 700: (e2, t2) => {
|
|
749
|
+
"use strict";
|
|
750
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.Page = void 0, t2.Page = class {
|
|
751
|
+
constructor(e3, t3, i, n, a) {
|
|
752
|
+
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 = a;
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
}, 217: (e2, t2, i) => {
|
|
756
|
+
"use strict";
|
|
757
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.PageGraph = void 0;
|
|
758
|
+
const n = i(636), a = i(558), s = i(591);
|
|
759
|
+
t2.PageGraph = class {
|
|
760
|
+
constructor(e3) {
|
|
761
|
+
this.nodes = /* @__PURE__ */ new Map(), this.buildGraph(e3);
|
|
762
|
+
}
|
|
763
|
+
buildGraph(e3) {
|
|
764
|
+
e3.forEach(((e4) => {
|
|
765
|
+
var t3;
|
|
766
|
+
e4.integrationPageRoutes && (e4.integrationPageRoutes = (null === (t3 = e4.integrationPageRoutes) || void 0 === t3 ? void 0 : t3.sort(((e5, t4) => new Date((null == e5 ? void 0 : e5.generatedAt) || "").getTime() - new Date((null == t4 ? void 0 : t4.generatedAt) || "").getTime() ? "DIRECT" === e5.typeCondition ? 1 : -1 : 0))) || []);
|
|
767
|
+
const i2 = new n.PageNode(e4.id, e4.position, e4.integrationPageRoutes || [], e4, e4.integrationQuestions);
|
|
768
|
+
this.nodes.set(i2.id, i2);
|
|
769
|
+
}));
|
|
770
|
+
}
|
|
771
|
+
getNodeById(e3) {
|
|
772
|
+
return this.nodes.get(e3);
|
|
773
|
+
}
|
|
774
|
+
getNextEdgeByDefault(e3) {
|
|
775
|
+
if (!e3) return;
|
|
776
|
+
const t3 = e3.edges.find(((e4) => e4.typeCondition === s.ConditionType.DIRECT));
|
|
777
|
+
if (!t3 || ![s.TransitionType.FINISH, s.TransitionType.REDIRECT].includes(t3.transition)) {
|
|
778
|
+
if (t3 && t3.transitionDestiny) return t3.transitionDestiny;
|
|
779
|
+
for (const t4 of this.nodes.values()) if (t4.position === e3.position + 1) return t4.id;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
getFirstPage() {
|
|
783
|
+
let e3, t3 = Number.MAX_VALUE;
|
|
784
|
+
for (const i2 of this.nodes.values()) i2.position < t3 && (t3 = i2.position, e3 = i2);
|
|
785
|
+
return e3;
|
|
786
|
+
}
|
|
787
|
+
getNextPage(e3, t3) {
|
|
788
|
+
var i2;
|
|
789
|
+
if (!e3) return;
|
|
790
|
+
e3.edges.sort(((e4, t4) => "DIRECT" === e4.typeCondition ? 1 : "DIRECT" === t4.typeCondition ? -1 : 0));
|
|
791
|
+
const n2 = e3.edges.find(((i3) => {
|
|
792
|
+
const n3 = e3.questions.find(((e4) => e4.ref === i3.questionRef)), r = null == t3 ? void 0 : t3.filter(((e4) => e4.key === i3.questionRef));
|
|
793
|
+
if ("DIRECT" === i3.typeCondition) return true;
|
|
794
|
+
if (!r || 0 === r.length) return false;
|
|
795
|
+
if ((null == n3 ? void 0 : n3.type) === a.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX) return this.evaluateMatrixCondition(i3, r);
|
|
796
|
+
const o = Array.isArray(i3.value) ? i3.value : [i3.value];
|
|
797
|
+
switch (i3.typeOperator) {
|
|
798
|
+
case s.OperatorType.EQUAL:
|
|
799
|
+
return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
|
|
800
|
+
case s.OperatorType.NOEQUAL:
|
|
801
|
+
return r.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
|
|
802
|
+
case s.OperatorType.GREATER:
|
|
803
|
+
return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) > Number(t4)))))));
|
|
804
|
+
case s.OperatorType.LESS:
|
|
805
|
+
return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) < Number(t4)))))));
|
|
806
|
+
case s.OperatorType.GREATEREQUAL:
|
|
807
|
+
return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) >= Number(t4)))))));
|
|
808
|
+
case s.OperatorType.LESSEQUAL:
|
|
809
|
+
return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.some(((t4) => Number(e5) <= Number(t4)))))));
|
|
810
|
+
case s.OperatorType.INQ:
|
|
811
|
+
return r.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => o.includes(e5)))));
|
|
812
|
+
case s.OperatorType.NINQ:
|
|
813
|
+
return r.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !o.includes(e5)))));
|
|
814
|
+
default:
|
|
815
|
+
return false;
|
|
816
|
+
}
|
|
817
|
+
}));
|
|
818
|
+
if (!n2) {
|
|
819
|
+
const t4 = this.getNextEdgeByDefault(e3);
|
|
820
|
+
if (!t4) return;
|
|
821
|
+
return this.getNodeById(t4);
|
|
822
|
+
}
|
|
823
|
+
switch (n2.transition) {
|
|
824
|
+
case s.TransitionType.PAGE:
|
|
825
|
+
if (!n2.transitionDestiny) return;
|
|
826
|
+
return this.getNodeById(n2.transitionDestiny);
|
|
827
|
+
case s.TransitionType.FINISH:
|
|
828
|
+
return;
|
|
829
|
+
case s.TransitionType.REDIRECT:
|
|
830
|
+
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}`);
|
|
831
|
+
default:
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
findDepth(e3) {
|
|
836
|
+
const t3 = this.getNodeById(e3);
|
|
837
|
+
if (!t3) return 0;
|
|
838
|
+
const i2 = /* @__PURE__ */ new Set();
|
|
839
|
+
return this.DFSUtil(t3, i2, 0);
|
|
840
|
+
}
|
|
841
|
+
findMaxDepth(e3) {
|
|
842
|
+
if (e3 || (e3 = this.getFirstPage()), !e3) return 0;
|
|
843
|
+
const t3 = /* @__PURE__ */ new Set();
|
|
844
|
+
let i2 = 1;
|
|
845
|
+
return i2 = Math.max(i2, this.DFSUtil(e3, t3, i2)), i2;
|
|
846
|
+
}
|
|
847
|
+
DFSUtil(e3, t3, i2) {
|
|
848
|
+
t3.add(e3);
|
|
849
|
+
let n2 = i2;
|
|
850
|
+
const a2 = [...e3.edges.filter(((e4) => e4.typeCondition !== s.ConditionType.PRECONDITIONAL)) || []], r = this.getNextEdgeByDefault(e3);
|
|
851
|
+
if (r) {
|
|
852
|
+
const i3 = this.getNodeById(r);
|
|
853
|
+
i3 && !t3.has(i3) && a2.push(new s.PageRoute(i3.id, "", s.OperatorType.DEFAULT, [""], s.TransitionType.PAGE, i3.id, e3.id));
|
|
854
|
+
}
|
|
855
|
+
for (const e4 of a2) {
|
|
856
|
+
if (!e4.transitionDestiny) continue;
|
|
857
|
+
const a3 = this.getNodeById(e4.transitionDestiny);
|
|
858
|
+
if (a3 && !t3.has(a3)) {
|
|
859
|
+
const e5 = a3.questions.find(((e6) => e6.followup)) ? i2 + 2 : i2 + 1, s2 = new Set(t3), r2 = this.DFSUtil(a3, s2, e5);
|
|
860
|
+
n2 = Math.max(n2, r2);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return n2;
|
|
864
|
+
}
|
|
865
|
+
parseMatrixAnswer(e3) {
|
|
866
|
+
if (!e3 || !e3.value) return [];
|
|
867
|
+
if (1 === e3.value.length && "string" == typeof e3.value[0] && e3.value[0].trim().startsWith("[")) try {
|
|
868
|
+
const t3 = JSON.parse(e3.value[0]);
|
|
869
|
+
if (Array.isArray(t3)) return t3;
|
|
870
|
+
} catch (e4) {
|
|
871
|
+
return [];
|
|
872
|
+
}
|
|
873
|
+
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 : [];
|
|
874
|
+
}
|
|
875
|
+
evaluateMatrixCondition(e3, t3) {
|
|
876
|
+
const i2 = Array.isArray(e3.value) ? e3.value : [e3.value], n2 = new Set(e3.option || []), a2 = t3[0], r = this.parseMatrixAnswer(a2);
|
|
877
|
+
if (!r.length) return false;
|
|
878
|
+
const o = n2.size > 0 ? r.filter(((e4) => n2.has(e4.key))) : r;
|
|
879
|
+
if (!o.length) return false;
|
|
880
|
+
switch (e3.typeOperator) {
|
|
881
|
+
case s.OperatorType.EQUAL:
|
|
882
|
+
case s.OperatorType.INQ:
|
|
883
|
+
return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.includes(e5)))));
|
|
884
|
+
case s.OperatorType.NOEQUAL:
|
|
885
|
+
case s.OperatorType.NINQ:
|
|
886
|
+
return o.every(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).every(((e5) => !i2.includes(e5)))));
|
|
887
|
+
case s.OperatorType.GREATER:
|
|
888
|
+
return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) > Number(t4)))))));
|
|
889
|
+
case s.OperatorType.LESS:
|
|
890
|
+
return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) < Number(t4)))))));
|
|
891
|
+
case s.OperatorType.GREATEREQUAL:
|
|
892
|
+
return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) >= Number(t4)))))));
|
|
893
|
+
case s.OperatorType.LESSEQUAL:
|
|
894
|
+
return o.some(((e4) => (Array.isArray(e4.value) ? e4.value : [e4.value]).some(((e5) => i2.some(((t4) => Number(e5) <= Number(t4)))))));
|
|
895
|
+
default:
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
}, 636: (e2, t2) => {
|
|
901
|
+
"use strict";
|
|
902
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.PageNode = void 0, t2.PageNode = class {
|
|
903
|
+
constructor(e3, t3, i, n, a, s = false) {
|
|
904
|
+
this.answers = [], this.id = e3, this.position = t3, this.edges = i, this.data = n, this.questions = a.sort(((e4, t4) => e4.position - t4.position)), this.elements = [], this.isFollowup = s;
|
|
905
|
+
}
|
|
906
|
+
getFollowupQuestions() {
|
|
907
|
+
return this.questions.filter(((e3) => e3.followup)).map(((e3) => e3.ref));
|
|
908
|
+
}
|
|
909
|
+
getRequiredQuestions() {
|
|
910
|
+
return this.questions.filter(((e3) => e3.require)).map(((e3) => e3.ref));
|
|
911
|
+
}
|
|
912
|
+
setAnswer(e3) {
|
|
913
|
+
this.answers = e3;
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
}, 591: (e2, t2) => {
|
|
917
|
+
"use strict";
|
|
918
|
+
var i, n, a, s;
|
|
919
|
+
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) {
|
|
920
|
+
e3.LOGICAL = "LOGICAL", e3.DIRECT = "DIRECT", e3.PRECONDITIONAL = "PRECONDITIONAL";
|
|
921
|
+
})(i = t2.ConditionType || (t2.ConditionType = {})), (a = t2.OperatorType || (t2.OperatorType = {})).EQUAL = "EQUAL", a.NOEQUAL = "NOEQUAL", a.GREATER = "GREATER", a.LESS = "LESS", a.GREATEREQUAL = "GREATEREQUAL", a.LESSEQUAL = "LESSEQUAL", a.INQ = "INQ", a.NINQ = "NINQ", a.DEFAULT = "DEFAULT", (function(e3) {
|
|
922
|
+
e3.ACTIVE = "ACTIVE", e3.DEPRECATED = "DEPRECATED", e3.DELETE = "DELETE";
|
|
923
|
+
})(n = t2.StatusType || (t2.StatusType = {})), t2.PageRoute = class {
|
|
924
|
+
constructor(e3, t3, a2, s2, r, o, l, d, c, u) {
|
|
925
|
+
this.id = e3, this.questionRef = t3, this.typeCondition = d || i.LOGICAL, this.typeOperator = a2, this.value = s2 || [], this.transition = r, 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 || [];
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
}, 558: (e2, t2) => {
|
|
929
|
+
"use strict";
|
|
930
|
+
var i, n;
|
|
931
|
+
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 {
|
|
932
|
+
}, (function(e3) {
|
|
933
|
+
e3.FORM = "form", e3.DIV = "div";
|
|
934
|
+
})(i || (i = {}));
|
|
935
|
+
}, 857: (e2, t2) => {
|
|
936
|
+
"use strict";
|
|
937
|
+
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" } };
|
|
938
|
+
}, 784: (e2, t2) => {
|
|
939
|
+
"use strict";
|
|
940
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.placeholder = void 0, t2.placeholder = { answer: (e3) => {
|
|
941
|
+
switch (e3) {
|
|
942
|
+
case "en":
|
|
943
|
+
default:
|
|
944
|
+
return "Write your answer here...";
|
|
945
|
+
case "es":
|
|
946
|
+
return "Escribe tu respuesta aqu\xED...";
|
|
947
|
+
case "da":
|
|
948
|
+
return "Skriv dit svar her...";
|
|
949
|
+
case "fi":
|
|
950
|
+
return "Kirjoita vastauksesi t\xE4h\xE4n...";
|
|
951
|
+
case "sv":
|
|
952
|
+
return "Skriv ditt svar h\xE4r...";
|
|
953
|
+
case "no":
|
|
954
|
+
return "Skriv svaret ditt her...";
|
|
955
|
+
case "ar":
|
|
956
|
+
return "\u0627\u0643\u062A\u0628 \u0625\u062C\u0627\u0628\u062A\u0643 \u0647\u0646\u0627...";
|
|
957
|
+
case "bn":
|
|
958
|
+
return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
|
|
959
|
+
}
|
|
960
|
+
}, number: (e3) => {
|
|
961
|
+
switch (e3) {
|
|
962
|
+
case "en":
|
|
963
|
+
default:
|
|
964
|
+
return "Write your number here...";
|
|
965
|
+
case "es":
|
|
966
|
+
return "Escribe tu n\xFAmero aqu\xED...";
|
|
967
|
+
case "da":
|
|
968
|
+
return "Skriv dit nummer her...";
|
|
969
|
+
case "fi":
|
|
970
|
+
return "Kirjoita numerosi t\xE4h\xE4n...";
|
|
971
|
+
case "sv":
|
|
972
|
+
return "Skriv ditt nummer h\xE4r...";
|
|
973
|
+
case "no":
|
|
974
|
+
return "Skriv nummeret ditt her...";
|
|
975
|
+
case "ar":
|
|
976
|
+
return "\u0627\u0643\u062A\u0628 \u0631\u0642\u0645\u0643 \u0647\u0646\u0627...";
|
|
977
|
+
case "bn":
|
|
978
|
+
return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
|
|
979
|
+
}
|
|
980
|
+
}, email: (e3) => {
|
|
981
|
+
switch (e3) {
|
|
982
|
+
case "en":
|
|
983
|
+
default:
|
|
984
|
+
return "Write your email here...";
|
|
985
|
+
case "es":
|
|
986
|
+
return "Escribe tu correo electr\xF3nico aqu\xED...";
|
|
987
|
+
case "da":
|
|
988
|
+
return "Skriv din e-mail her...";
|
|
989
|
+
case "fi":
|
|
990
|
+
return "Kirjoita s\xE4hk\xF6postiosoitteesi t\xE4h\xE4n...";
|
|
991
|
+
case "sv":
|
|
992
|
+
return "Skriv din e-post h\xE4r...";
|
|
993
|
+
case "no":
|
|
994
|
+
return "Skriv e-posten din her...";
|
|
995
|
+
case "ar":
|
|
996
|
+
return "\u0627\u0643\u062A\u0628 \u0628\u0631\u064A\u062F\u0643 \u0627\u0644\u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A \u0647\u0646\u0627...";
|
|
997
|
+
case "bn":
|
|
998
|
+
return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
|
|
999
|
+
}
|
|
1000
|
+
}, date: (e3) => {
|
|
1001
|
+
switch (e3) {
|
|
1002
|
+
case "en":
|
|
1003
|
+
default:
|
|
1004
|
+
return "Write your date here...";
|
|
1005
|
+
case "es":
|
|
1006
|
+
return "Escribe tu fecha aqu\xED...";
|
|
1007
|
+
case "da":
|
|
1008
|
+
return "Skriv din dato her...";
|
|
1009
|
+
case "fi":
|
|
1010
|
+
return "Kirjoita p\xE4iv\xE4m\xE4\xE4r\xE4si t\xE4h\xE4n...";
|
|
1011
|
+
case "sv":
|
|
1012
|
+
return "Skriv ditt datum h\xE4r...";
|
|
1013
|
+
case "no":
|
|
1014
|
+
return "Skriv datoen din her...";
|
|
1015
|
+
case "ar":
|
|
1016
|
+
return "\u0627\u0643\u062A\u0628 \u062A\u0627\u0631\u064A\u062E\u0643 \u0647\u0646\u0627...";
|
|
1017
|
+
case "bn":
|
|
1018
|
+
return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
|
|
1019
|
+
}
|
|
1020
|
+
}, password: (e3) => {
|
|
1021
|
+
switch (e3) {
|
|
1022
|
+
case "en":
|
|
1023
|
+
default:
|
|
1024
|
+
return "Write your password here...";
|
|
1025
|
+
case "es":
|
|
1026
|
+
return "Escribe tu contrase\xF1a aqu\xED...";
|
|
1027
|
+
case "da":
|
|
1028
|
+
return "Skriv dit kodeord her...";
|
|
1029
|
+
case "fi":
|
|
1030
|
+
return "Kirjoita salasanasi t\xE4h\xE4n...";
|
|
1031
|
+
case "sv":
|
|
1032
|
+
return "Skriv ditt l\xF6senord h\xE4r...";
|
|
1033
|
+
case "no":
|
|
1034
|
+
return "Skriv passordet ditt her...";
|
|
1035
|
+
case "ar":
|
|
1036
|
+
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...";
|
|
1037
|
+
case "bn":
|
|
1038
|
+
return "\u098F\u0996\u09BE\u09A8\u09C7 \u0986\u09AA\u09A8\u09BE\u09B0";
|
|
1039
|
+
}
|
|
1040
|
+
}, pointsystemerror: (e3) => {
|
|
1041
|
+
switch (e3) {
|
|
1042
|
+
case "en":
|
|
1043
|
+
default:
|
|
1044
|
+
return "The total points must be 100 %";
|
|
1045
|
+
case "es":
|
|
1046
|
+
return "El total de puntos debe ser 100 %";
|
|
1047
|
+
case "da":
|
|
1048
|
+
return "Samlet antal point skal v\xE6re 100 %";
|
|
1049
|
+
case "fi":
|
|
1050
|
+
return "Kokonaispisteiden on oltava 100 %";
|
|
1051
|
+
case "sv":
|
|
1052
|
+
return "Totala po\xE4ng m\xE5ste vara 100 %";
|
|
1053
|
+
case "no":
|
|
1054
|
+
return "Totalt antall poeng m\xE5 v\xE6re 100 %";
|
|
1055
|
+
case "ar":
|
|
1056
|
+
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 %";
|
|
1057
|
+
case "bn":
|
|
1058
|
+
return "\u09AE\u09CB\u099F \u09AA\u09AF\u09BC\u09C7\u09A8\u09CD\u099F 100 % \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7";
|
|
1059
|
+
}
|
|
1060
|
+
} };
|
|
1061
|
+
}, 213: (e2, t2, i) => {
|
|
1062
|
+
"use strict";
|
|
1063
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.renderStartMessage = t2.renderSuccess = t2.renderError = t2.renderActions = t2.renderQuestions = void 0;
|
|
1064
|
+
const n = i(558), a = i(784), s = "https://survey-dev.magicfeedback.io/assets/emojis";
|
|
1065
|
+
function r(e3, t3) {
|
|
1066
|
+
return e3 ? "object" == typeof e3 ? e3[t3] || e3.en : e3 : "";
|
|
1067
|
+
}
|
|
1068
|
+
function o(e3, t3, i2, n2, a2, s2 = true, r2 = "ltr", o2 = "row") {
|
|
1069
|
+
const l = document.createElement("div");
|
|
1070
|
+
l.classList.add("magicfeedback-rating-placeholder"), l.style.display = "flex", l.style.flexDirection = o2, l.style.alignItems = "center", l.style.justifyContent = "space-between", l.style.width = a2 ? `calc(100% - (100% / ${t3 + 1}))` : "100%", l.style.marginRight = "auto", s2 && window.innerWidth < 600 && (l.style.flexDirection = "column");
|
|
1071
|
+
const d = document.createElement("span");
|
|
1072
|
+
d.textContent = i2, d.classList.add("magicfeedback-rating-placeholder-value"), d.style.fontSize = "15px", d.style.textAlign = "ltr" === r2 ? "left" : "right", d.style.width = "50%", (s2 && window.innerWidth < 600 || "column" === o2) && (d.textContent = `${e3} = ${i2}`, d.style.width = "100%", d.style.textAlign = "left", d.style.marginBottom = "5px");
|
|
1073
|
+
const c = document.createElement("span");
|
|
1074
|
+
return c.textContent = n2, c.classList.add("magicfeedback-rating-placeholder-value"), c.style.fontSize = "15px", c.style.textAlign = "ltr" === r2 ? "right" : "left", c.style.width = "50%", (s2 && window.innerWidth < 600 || "column" === o2) && (c.textContent = `${t3} = ${n2}`, c.style.width = "100%", c.style.textAlign = "left", c.style.marginBottom = "5px"), "ltr" === r2 ? (i2 && l.appendChild(d), n2 && l.appendChild(c)) : (n2 && l.appendChild(c), i2 && l.appendChild(d)), l;
|
|
1075
|
+
}
|
|
1076
|
+
t2.renderQuestions = function e3(t3, i2 = "standard", l = "en", d = { customIcons: false }, c) {
|
|
1077
|
+
if (!t3) throw new Error("[MagicFeedback] No questions provided");
|
|
1078
|
+
const u = [], { customIcons: p, id: h } = d;
|
|
1079
|
+
return t3.forEach(((m) => {
|
|
1080
|
+
var f, g;
|
|
1081
|
+
if ((null === (g = null === (f = null == m ? void 0 : m.questionType) || void 0 === f ? void 0 : f.conf) || void 0 === g ? void 0 : g.length) > 0) {
|
|
1082
|
+
let t4 = document.createElement("div");
|
|
1083
|
+
t4.classList.add("magicfeedback-div");
|
|
1084
|
+
const n2 = document.createElement("label");
|
|
1085
|
+
n2.setAttribute("for", `magicfeedback-${m.id}`), n2.textContent = r(m.title, l), n2.classList.add("magicfeedback-label"), t4.appendChild(n2), m.questionType.conf.forEach(((e4) => {
|
|
1086
|
+
e4.ref = m.ref, m.assets[e4.id] && (e4.assets = { placeholder: m.assets[e4.id] });
|
|
1087
|
+
})), e3(m.questionType.conf, i2, l, d, c).forEach(((e4) => {
|
|
1088
|
+
t4.appendChild(e4);
|
|
1089
|
+
})), u.push(t4);
|
|
1090
|
+
} else {
|
|
1091
|
+
const e4 = (function(e5, t4, i3, l2, d2) {
|
|
1092
|
+
var c2, u2, p2;
|
|
1093
|
+
let h2, m2, { id: f2, title: g2, type: v, ref: y, require: E, value: b, defaultValue: A, assets: k } = e5, C = document.createElement("div");
|
|
1094
|
+
C.classList.add("magicfeedback-div");
|
|
1095
|
+
const T = window.innerWidth < 600, x = "slim" === t4 ? r(g2, i3) : null == k ? void 0 : k.placeholder, w = (N = y, new URLSearchParams(window.location.search).get(N)), L = (null == k ? void 0 : k.maxCharacters) || 0, P = void 0 !== (null == k ? void 0 : k.randomPosition) && (null == k ? void 0 : k.randomPosition), S = (null == k ? void 0 : k.direction) || "row", O = (null == k ? void 0 : k.order) || "ltr";
|
|
1096
|
+
var N;
|
|
1097
|
+
switch (v) {
|
|
1098
|
+
case n.FEEDBACKAPPANSWERTYPE.TEXT:
|
|
1099
|
+
h2 = document.createElement("input"), h2.type = "text", h2.placeholder = x || a.placeholder.answer(i3 || "en"), w && (h2.value = w), h2.addEventListener("keyup", ((e6) => {
|
|
1100
|
+
e6.preventDefault(), console.log(e6.key, e6), "Enter" === e6.key && d2 && d2();
|
|
1101
|
+
})), m2 = "magicfeedback-text";
|
|
1102
|
+
break;
|
|
1103
|
+
case n.FEEDBACKAPPANSWERTYPE.LONGTEXT:
|
|
1104
|
+
h2 = document.createElement("textarea"), h2.rows = 3, L > 0 && (h2.maxLength = L), h2.placeholder = x || a.placeholder.answer(i3 || "en"), w && (h2.value = w), m2 = "magicfeedback-longtext";
|
|
1105
|
+
break;
|
|
1106
|
+
case n.FEEDBACKAPPANSWERTYPE.NUMBER:
|
|
1107
|
+
h2 = document.createElement("input"), h2.type = "number", h2.placeholder = "slim" === t4 ? r(g2, i3) : a.placeholder.number(i3 || "en"), m2 = "magicfeedback-number", b.length && (b.sort(((e6, t5) => Number(e6) - Number(t5))), h2.max = b[b.length - 1], h2.min = b[0], h2.value = b[0]), w && !isNaN(Number(w)) && (h2.value = w);
|
|
1108
|
+
break;
|
|
1109
|
+
case n.FEEDBACKAPPANSWERTYPE.RADIO:
|
|
1110
|
+
case n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE:
|
|
1111
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-" + ("MULTIPLECHOICE" === v ? "checkbox" : "radio");
|
|
1112
|
+
let R = b || [];
|
|
1113
|
+
P && (R = R.sort((() => Math.random() - 0.5)));
|
|
1114
|
+
let $ = (null == k ? void 0 : k.exclusiveAnswers) || [];
|
|
1115
|
+
(null == k ? void 0 : k.extraOption) && ($ = $.filter(((e6) => e6 !== k.extraOptionText))), $.length > 0 && (null == $ || $.forEach(((e6) => {
|
|
1116
|
+
R.includes(e6) || R.push(e6);
|
|
1117
|
+
}))), (null == k ? void 0 : k.extraOption) && !R.includes(null == k ? void 0 : k.extraOptionText) && R.push(null == k ? void 0 : k.extraOptionText), R.forEach(((e6, t5) => {
|
|
1118
|
+
const s2 = document.createElement("div");
|
|
1119
|
+
s2.classList.add(`magicfeedback-${"MULTIPLECHOICE" === v ? "checkbox" : "radio"}-container`);
|
|
1120
|
+
const r2 = document.createElement("label"), o2 = document.createElement("input");
|
|
1121
|
+
if (o2.id = `rating-${y}-${t5}`, o2.type = "MULTIPLECHOICE" === v ? "checkbox" : "radio", o2.name = y, o2.value = e6, o2.classList.add(m2), o2.classList.add("magicfeedback-input"), v === n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE && (null == k ? void 0 : k.maxOptions) && (null == k ? void 0 : k.maxOptions) > 0 && o2.addEventListener("change", (() => {
|
|
1122
|
+
document.querySelectorAll(`input[name="${y}"]:checked`).length > (null == k ? void 0 : k.maxOptions) && (o2.checked = false);
|
|
1123
|
+
})), v === n.FEEDBACKAPPANSWERTYPE.RADIO && d2 && (!(null == k ? void 0 : k.extraOptionText) || (null == k ? void 0 : k.extraOptionText) && e6 !== (null == k ? void 0 : k.extraOptionText)) && o2.addEventListener("change", (() => {
|
|
1124
|
+
d2();
|
|
1125
|
+
})), e6 !== A && e6 !== w || (o2.checked = true), r2.textContent = e6, r2.htmlFor = `rating-${y}-${t5}`, o2.addEventListener("change", ((t6) => {
|
|
1126
|
+
const i4 = document.getElementById(`extra-option-${y}`);
|
|
1127
|
+
t6.target.checked && $.includes(e6) ? (console.log("exclusiveAnswers", $, e6), R.forEach(((t7) => {
|
|
1128
|
+
t7 !== e6 && (document.querySelector(`input[value="${t7}"]`).checked = false);
|
|
1129
|
+
})), i4 && (i4.style.display = "none")) : $.forEach(((t7) => {
|
|
1130
|
+
t7 !== e6 && (document.querySelector(`input[value="${t7}"]`).checked = false);
|
|
1131
|
+
})), (null == k ? void 0 : k.extraOption) && e6 === (null == k ? void 0 : k.extraOptionText) && i4 && (i4.style.display = t6.target.checked ? "block" : "none");
|
|
1132
|
+
})), s2.appendChild(o2), s2.appendChild(r2), h2.appendChild(s2), (null == k ? void 0 : k.extraOption) && e6 === (null == k ? void 0 : k.extraOptionText)) {
|
|
1133
|
+
const e7 = document.createElement("input");
|
|
1134
|
+
e7.type = "text", e7.placeholder = (null == k ? void 0 : k.extraOptionPlaceholder) || a.placeholder.answer(i3 || "en"), e7.classList.add("magicfeedback-extra-option"), e7.classList.add("magicfeedback-input"), e7.id = `extra-option-${y}`, e7.name = `extra-option-${y}`, e7.style.display = "none", h2.appendChild(e7);
|
|
1135
|
+
}
|
|
1136
|
+
}));
|
|
1137
|
+
break;
|
|
1138
|
+
case n.FEEDBACKAPPANSWERTYPE.BOOLEAN:
|
|
1139
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-radio";
|
|
1140
|
+
const _ = document.createElement("div");
|
|
1141
|
+
_.classList.add("magicfeedback-boolean-container"), _.style.display = "flex", _.style.flexDirection = "row", _.style.justifyContent = "space-between", _.style.width = "70%", _.style.margin = "auto", ((null == k ? void 0 : k.addIcon) ? ["\u{1F44D}", "\u{1F44E}"] : (function(e6) {
|
|
1142
|
+
switch (e6) {
|
|
1143
|
+
case "es":
|
|
1144
|
+
return ["S\xED", "No"];
|
|
1145
|
+
case "fr":
|
|
1146
|
+
return ["Oui", "Non"];
|
|
1147
|
+
case "de":
|
|
1148
|
+
return ["Ja", "Nein"];
|
|
1149
|
+
case "it":
|
|
1150
|
+
return ["S\xEC", "No"];
|
|
1151
|
+
case "pt":
|
|
1152
|
+
return ["Sim", "N\xE3o"];
|
|
1153
|
+
case "nl":
|
|
1154
|
+
return ["Ja", "Nee"];
|
|
1155
|
+
case "pl":
|
|
1156
|
+
return ["Tak", "Nie"];
|
|
1157
|
+
case "ru":
|
|
1158
|
+
return ["\u0414\u0430", "\u041D\u0435\u0442"];
|
|
1159
|
+
case "ja":
|
|
1160
|
+
return ["\u306F\u3044", "\u3044\u3044\u3048"];
|
|
1161
|
+
case "zh":
|
|
1162
|
+
return ["\u662F", "\u4E0D"];
|
|
1163
|
+
case "ko":
|
|
1164
|
+
return ["\uC608", "\uC544\uB2C8"];
|
|
1165
|
+
case "da":
|
|
1166
|
+
case "sv":
|
|
1167
|
+
return ["Ja", "Nej"];
|
|
1168
|
+
case "fi":
|
|
1169
|
+
return ["Kyll\xE4", "Ei"];
|
|
1170
|
+
case "no":
|
|
1171
|
+
return ["Ja", "Nei"];
|
|
1172
|
+
case "ar":
|
|
1173
|
+
return ["\u0646\u0639\u0645", "\u0644\u0627"];
|
|
1174
|
+
case "bn":
|
|
1175
|
+
return ["\u09B9\u09CD\u09AF\u09BE\u0981", "\u09A8\u09BE"];
|
|
1176
|
+
default:
|
|
1177
|
+
return ["Yes", "No"];
|
|
1178
|
+
}
|
|
1179
|
+
})(i3)).forEach(((e6, t5) => {
|
|
1180
|
+
const i4 = document.createElement("label");
|
|
1181
|
+
i4.classList.add("magicfeedback-boolean-option"), i4.htmlFor = `rating-${y}-${t5}`, i4.style.cursor = "pointer", i4.style.border = "1px solid #000", i4.style.display = "flex", i4.style.justifyContent = "center", i4.style.alignItems = "center", i4.style.margin = "auto", i4.style.padding = "0", i4.style.width = "45%", i4.style.height = "38px";
|
|
1182
|
+
const n2 = document.createElement("label");
|
|
1183
|
+
n2.htmlFor = `rating-${y}-${t5}`, n2.textContent = e6, n2.style.margin = "0", n2.style.padding = "0";
|
|
1184
|
+
const a2 = document.createElement("input");
|
|
1185
|
+
a2.id = `rating-${y}-${t5}`, a2.type = "radio", a2.name = y, a2.value = ["Yes", "No"][t5], a2.classList.add(m2), a2.classList.add("magicfeedback-input"), a2.style.position = "absolute", a2.style.opacity = "0", a2.style.width = "0", a2.style.height = "0", a2.style.margin = "0", a2.addEventListener("change", (() => {
|
|
1186
|
+
d2 && d2();
|
|
1187
|
+
})), w && w.toLowerCase() === a2.value.toLowerCase() && (a2.checked = true), i4.appendChild(a2), i4.appendChild(n2), _.appendChild(i4);
|
|
1188
|
+
})), h2.appendChild(_);
|
|
1189
|
+
break;
|
|
1190
|
+
case n.FEEDBACKAPPANSWERTYPE.RATING_EMOJI:
|
|
1191
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-rating";
|
|
1192
|
+
const F = document.createElement("div");
|
|
1193
|
+
F.classList.add("magicfeedback-rating-container");
|
|
1194
|
+
const M = (null == k ? void 0 : k.max) ? Number(null == k ? void 0 : k.max) : 5, B = (null == k ? void 0 : k.min) ? Number(null == k ? void 0 : k.min) : 1, U = o(B, M, null == k ? void 0 : k.minPlaceholder, null == k ? void 0 : k.maxPlaceholder, null == k ? void 0 : k.extraOption);
|
|
1195
|
+
for (let ce = B; ce <= M; ce++) {
|
|
1196
|
+
const ue = document.createElement("div");
|
|
1197
|
+
ue.classList.add("magicfeedback-rating-option");
|
|
1198
|
+
const pe = document.createElement("label");
|
|
1199
|
+
pe.htmlFor = `rating-${y}-${ce}`, pe.classList.add("magicfeedback-rating-option-label-container");
|
|
1200
|
+
const he = document.createElement("label");
|
|
1201
|
+
he.htmlFor = `rating-${y}-${ce}`, he.textContent = ce.toString();
|
|
1202
|
+
const me = document.createElement("img");
|
|
1203
|
+
if (me.alt = `face-${y}-${ce}`, me.className = `rating-image${ce}`, 0 === B && 10 === M) me.src = `${l2}/${ce}.svg`, me.onerror = () => me.src = `${s}/${ce}.svg`;
|
|
1204
|
+
else if (1 === B && 5 === M) switch (ce) {
|
|
1205
|
+
case 1:
|
|
1206
|
+
me.src = `${l2}/1.svg`, me.onerror = () => me.src = `${s}/1.svg`;
|
|
1207
|
+
break;
|
|
1208
|
+
case 2:
|
|
1209
|
+
me.src = `${l2}/2.svg`, me.onerror = () => me.src = `${s}/2.svg`;
|
|
1210
|
+
break;
|
|
1211
|
+
case 3:
|
|
1212
|
+
me.src = `${l2}/6.svg`, me.onerror = () => me.src = `${s}/6.svg`;
|
|
1213
|
+
break;
|
|
1214
|
+
case 4:
|
|
1215
|
+
me.src = `${l2}/9.svg`, me.onerror = () => me.src = `${s}/9.svg`;
|
|
1216
|
+
break;
|
|
1217
|
+
case 5:
|
|
1218
|
+
me.src = `${l2}/10.svg`, me.onerror = () => me.src = `${s}/10.svg`;
|
|
1219
|
+
}
|
|
1220
|
+
else {
|
|
1221
|
+
const ge = Math.round(10 / (M - B) * (ce - B));
|
|
1222
|
+
me.src = `${l2}/${ge}.svg`, me.onerror = () => me.src = `${s}/${ge}.svg`;
|
|
1223
|
+
}
|
|
1224
|
+
const fe = document.createElement("input");
|
|
1225
|
+
fe.id = `rating-${y}-${ce}`, fe.type = "radio", fe.name = y, fe.value = ce.toString(), fe.classList.add(m2), fe.classList.add("magicfeedback-input"), d2 && fe.addEventListener("change", (() => {
|
|
1226
|
+
d2();
|
|
1227
|
+
})), w && w === fe.value && (fe.checked = true), pe.appendChild(fe), pe.appendChild(me), pe.appendChild(he), ue.appendChild(pe), F.appendChild(ue);
|
|
1228
|
+
}
|
|
1229
|
+
if ((null == k ? void 0 : k.extraOption) && (null == k ? void 0 : k.extraOptionText)) {
|
|
1230
|
+
const ve = document.createElement("div");
|
|
1231
|
+
ve.classList.add("magicfeedback-rating-option");
|
|
1232
|
+
const ye = document.createElement("label");
|
|
1233
|
+
ye.htmlFor = `rating-${y}-extra`, ye.classList.add("magicfeedback-rating-option-label-container");
|
|
1234
|
+
const Ee = document.createElement("label");
|
|
1235
|
+
Ee.htmlFor = `rating-${y}-extra`, Ee.textContent = null == k ? void 0 : k.extraOptionText;
|
|
1236
|
+
const be = document.createElement("img");
|
|
1237
|
+
be.src = "https://magicfeedback-c6458-dev.web.app/assets/question.svg", be.alt = `face-${y}-extra`, be.className = "magicfeedback-rating-image-extra";
|
|
1238
|
+
const Ae = document.createElement("input");
|
|
1239
|
+
Ae.id = `rating-${y}-extra`, Ae.type = "radio", Ae.name = y, Ae.value = "-", Ae.classList.add(m2), Ae.classList.add("magicfeedback-input"), d2 && Ae.addEventListener("change", (() => {
|
|
1240
|
+
d2();
|
|
1241
|
+
})), ye.appendChild(Ae), ye.appendChild(be), ye.appendChild(Ee), ve.appendChild(ye), F.appendChild(ve);
|
|
1242
|
+
}
|
|
1243
|
+
h2.appendChild(U), h2.appendChild(F);
|
|
1244
|
+
break;
|
|
1245
|
+
case n.FEEDBACKAPPANSWERTYPE.RATING_NUMBER:
|
|
1246
|
+
m2 = "magicfeedback-rating-number", h2 = (function(e6, t5, i4, n2, a2, s2, r2, o2) {
|
|
1247
|
+
const l3 = document.createElement("div");
|
|
1248
|
+
l3.classList.add("magicfeedback-rating-number");
|
|
1249
|
+
const d3 = "ltr" === i4 ? n2 : `${n2}-reverse`, c3 = document.createElement("div");
|
|
1250
|
+
c3.classList.add("magicfeedback-rating-number-container"), c3.classList.add(`magicfeedback-rating-number-container-${i4}`), c3.classList.add(`magicfeedback-rating-number-container-${n2}`), c3.style.display = "flex", c3.style.flexDirection = d3, c3.setAttribute("role", "radiogroup"), c3.setAttribute("aria-label", (null == t5 ? void 0 : t5.ariaLabel) || "Rating");
|
|
1251
|
+
const u3 = (null == t5 ? void 0 : t5.max) ? Number(null == t5 ? void 0 : t5.max) : 10, p3 = (null == t5 ? void 0 : t5.min) ? Number(null == t5 ? void 0 : t5.min) : 0, h3 = !(a2 || "column" === n2);
|
|
1252
|
+
for (let i5 = p3; i5 <= u3; i5++) {
|
|
1253
|
+
const a3 = document.createElement("div");
|
|
1254
|
+
a3.classList.add("magicfeedback-rating-number-option"), a3.classList.add(`magicfeedback-rating-number-option-${n2}`);
|
|
1255
|
+
const l4 = document.createElement("label");
|
|
1256
|
+
if (l4.htmlFor = `rating-${e6}-${i5}`, l4.classList.add("magicfeedback-rating-number-option-label-container"), h3 && (l4.style.position = "relative", l4.style.overflow = "visible"), h3) {
|
|
1257
|
+
const e7 = document.createElement("span");
|
|
1258
|
+
e7.classList.add("magicfeedback-rating-number-cap"), e7.classList.add("magicfeedback-rating-placeholder-value"), e7.style.fontSize = "14px", e7.style.whiteSpace = "nowrap", e7.style.wordBreak = "normal", i5 === p3 && (null == t5 ? void 0 : t5.minPlaceholder) ? (e7.textContent = t5.minPlaceholder, e7.dataset.capType = "min") : i5 === u3 && (null == t5 ? void 0 : t5.maxPlaceholder) ? (e7.textContent = t5.maxPlaceholder, e7.dataset.capType = "max") : e7.dataset.capType = "mid", l4.appendChild(e7);
|
|
1259
|
+
}
|
|
1260
|
+
let d4 = i5.toString();
|
|
1261
|
+
h3 || (i5 === p3 && (null == t5 ? void 0 : t5.minPlaceholder) && (d4 += ` = ${null == t5 ? void 0 : t5.minPlaceholder}`), i5 === u3 && (null == t5 ? void 0 : t5.maxPlaceholder) && (d4 += ` = ${null == t5 ? void 0 : t5.maxPlaceholder}`));
|
|
1262
|
+
const m3 = document.createElement("input");
|
|
1263
|
+
m3.id = `rating-${e6}-${i5}`, m3.type = "radio", m3.name = e6, m3.value = i5.toString(), m3.classList.add(s2), m3.classList.add("magicfeedback-input"), m3.setAttribute("aria-label", `${i5}`), r2 && m3.addEventListener("change", (() => r2())), o2 && o2 === m3.value && (m3.checked = true);
|
|
1264
|
+
const f3 = document.createElement("label");
|
|
1265
|
+
f3.htmlFor = `rating-${e6}-${i5}`, f3.textContent = d4, f3.classList.add("magicfeedback-rating-number-value"), l4.appendChild(m3), l4.appendChild(f3), a3.appendChild(l4), c3.appendChild(a3);
|
|
1266
|
+
}
|
|
1267
|
+
if ((null == t5 ? void 0 : t5.extraOption) && (null == t5 ? void 0 : t5.extraOptionText)) {
|
|
1268
|
+
const n3 = document.createElement("div");
|
|
1269
|
+
n3.classList.add("magicfeedback-rating-number-option");
|
|
1270
|
+
const a3 = document.createElement("label");
|
|
1271
|
+
if (a3.htmlFor = `rating-${e6}-extra`, a3.classList.add("magicfeedback-rating-number-option-label-container"), h3 && (a3.style.position = "relative", a3.style.overflow = "visible"), h3) {
|
|
1272
|
+
const e7 = document.createElement("span");
|
|
1273
|
+
e7.classList.add("magicfeedback-rating-number-cap"), e7.dataset.capType = "extra", e7.style.fontSize = "12px", e7.style.whiteSpace = "nowrap", e7.style.wordBreak = "normal", a3.appendChild(e7);
|
|
1274
|
+
}
|
|
1275
|
+
const o3 = document.createElement("input");
|
|
1276
|
+
o3.id = `rating-${e6}-extra`, o3.type = "radio", o3.name = e6, o3.value = "-", o3.classList.add(s2), o3.classList.add("magicfeedback-input"), o3.setAttribute("aria-label", null == t5 ? void 0 : t5.extraOptionText), r2 && o3.addEventListener("change", (() => r2()));
|
|
1277
|
+
const l4 = document.createElement("label");
|
|
1278
|
+
l4.htmlFor = `rating-${e6}-extra`, l4.textContent = null == t5 ? void 0 : t5.extraOptionText, l4.classList.add("magicfeedback-rating-number-value"), a3.appendChild(o3), a3.appendChild(l4), n3.appendChild(a3), "ltr" === i4 ? c3.appendChild(n3) : c3.insertBefore(n3, c3.firstChild);
|
|
1279
|
+
}
|
|
1280
|
+
return l3.appendChild(c3), h3 && requestAnimationFrame((() => {
|
|
1281
|
+
const e7 = Array.from(c3.querySelectorAll(".magicfeedback-rating-number-cap"));
|
|
1282
|
+
if (0 === e7.length) return;
|
|
1283
|
+
let t6 = 0;
|
|
1284
|
+
e7.forEach(((e8) => {
|
|
1285
|
+
var i5;
|
|
1286
|
+
if (null === (i5 = e8.textContent) || void 0 === i5 ? void 0 : i5.trim()) {
|
|
1287
|
+
const i6 = e8.getBoundingClientRect().height || 0;
|
|
1288
|
+
i6 > t6 && (t6 = i6);
|
|
1289
|
+
}
|
|
1290
|
+
})), c3.style.position = "relative", c3.style.paddingTop = `${0 === t6 ? "42" : t6 + 6}px`, e7.forEach(((e8) => {
|
|
1291
|
+
const n3 = e8.getBoundingClientRect().height || 0;
|
|
1292
|
+
console.log(t6, n3, 6), e8.style.position = "absolute", e8.style.top = `-${0 === t6 ? "42" : t6 + n3}px`, e8.style.zIndex = "1", e8.style.pointerEvents = "none", e8.style.padding = "0", e8.style.boxSizing = "border-box", e8.style.whiteSpace = "nowrap", e8.style.wordBreak = "normal", e8.style.maxWidth = "none", e8.style.width = "max-content";
|
|
1293
|
+
const a3 = e8.dataset.capType;
|
|
1294
|
+
"min" === a3 ? ("ltr" === i4 ? (e8.style.left = "10px", e8.style.textAlign = "left") : (e8.style.right = "10px", e8.style.textAlign = "right"), e8.style.transform = "none") : "max" === a3 ? ("ltr" === i4 ? (e8.style.right = "10px", e8.style.textAlign = "right") : (e8.style.left = "10px", e8.style.textAlign = "left"), e8.style.transform = "none") : (e8.style.left = "50%", e8.style.transform = "translateX(-50%)", e8.style.textAlign = "center");
|
|
1295
|
+
})), c3.style.overflow = "visible";
|
|
1296
|
+
})), l3;
|
|
1297
|
+
})(y, k, O, S, T, m2, d2, w);
|
|
1298
|
+
break;
|
|
1299
|
+
case n.FEEDBACKAPPANSWERTYPE.RATING_STAR:
|
|
1300
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-rating-star";
|
|
1301
|
+
const q = (function(e6, t5, i4, n2 = () => {
|
|
1302
|
+
}, a2) {
|
|
1303
|
+
const s2 = "magicfeedback-rating-star-selected", r2 = document.createElement("div");
|
|
1304
|
+
r2.classList.add("magicfeedback-rating-star-container"), r2.style.maxWidth = "300px", r2.style.margin = "auto", r2.dataset.originalSelection = "0";
|
|
1305
|
+
for (let t6 = 1; t6 <= 5; t6++) {
|
|
1306
|
+
const i5 = document.createElement("label");
|
|
1307
|
+
i5.classList.add("magicfeedback-rating-star-option");
|
|
1308
|
+
const o2 = document.createElement("input");
|
|
1309
|
+
o2.id = `rating-${e6}-${t6}`, o2.type = "radio", o2.name = e6, o2.value = t6.toString(), o2.style.position = "absolute", o2.style.opacity = "0", o2.style.width = "0", o2.style.height = "0", o2.classList.add("magicfeedback-input"), a2 && a2 === o2.value && (o2.checked = true), o2.addEventListener("change", (() => {
|
|
1310
|
+
const e7 = r2.querySelectorAll(".rating__star");
|
|
1311
|
+
for (let t7 = 0; t7 < e7.length; t7++) t7 + 1 <= Number(o2.value) ? e7[t7].classList.contains(s2) || e7[t7].classList.add(s2) : e7[t7].classList.contains(s2) && e7[t7].classList.remove(s2);
|
|
1312
|
+
r2.dataset.originalSelection = o2.value, n2 && n2();
|
|
1313
|
+
})), i5.appendChild(o2);
|
|
1314
|
+
const l3 = document.createElement("label");
|
|
1315
|
+
l3.htmlFor = `rating-${e6}-${t6}`, l3.classList.add("rating__star"), l3.textContent = "\u2605", l3.style.fontSize = "40px", l3.style.color = "#CCCCCC", l3.style.cursor = "pointer", l3.addEventListener("mouseenter", (() => {
|
|
1316
|
+
const e7 = r2.querySelectorAll(".rating__star"), i6 = t6 - 1;
|
|
1317
|
+
e7.forEach(((e8, t7) => {
|
|
1318
|
+
t7 <= i6 ? e8.classList.contains(s2) || e8.classList.add(s2) : e8.classList.contains(s2) && e8.classList.remove(s2);
|
|
1319
|
+
}));
|
|
1320
|
+
})), l3.addEventListener("mouseleave", (() => {
|
|
1321
|
+
const e7 = Number(r2.dataset.originalSelection || "0");
|
|
1322
|
+
r2.querySelectorAll(".rating__star").forEach(((t7, i6) => {
|
|
1323
|
+
i6 < e7 ? t7.classList.contains(s2) || t7.classList.add(s2) : t7.classList.contains(s2) && t7.classList.remove(s2);
|
|
1324
|
+
}));
|
|
1325
|
+
})), i5.appendChild(l3), r2.appendChild(i5);
|
|
1326
|
+
}
|
|
1327
|
+
return r2.appendChild(o(1, 5, t5, i4, false, false)), r2;
|
|
1328
|
+
})(y, null == k ? void 0 : k.minPlaceholder, null == k ? void 0 : k.maxPlaceholder, d2, w);
|
|
1329
|
+
h2.appendChild(q);
|
|
1330
|
+
break;
|
|
1331
|
+
case n.FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE:
|
|
1332
|
+
let V = function(e6) {
|
|
1333
|
+
try {
|
|
1334
|
+
const { position: t5, url: i4, value: n2 } = e6, a2 = document.createElement("label");
|
|
1335
|
+
a2.classList.add("magicfeedback-multiple-choice-image-option"), a2.style.width = `calc( ${100 / W}% - 10px)`, a2.style.height = `calc( ${100 / K}% - 10px)`, a2.style.margin = "5px";
|
|
1336
|
+
const s2 = document.createElement("label");
|
|
1337
|
+
s2.htmlFor = `rating-${y}-${t5}`, s2.classList.add("magicfeedback-image-option-label-container"), s2.style.display = "flex", s2.style.flexDirection = "column", s2.addEventListener("mouseover", (() => {
|
|
1338
|
+
s2.style.border = "2px solid #000";
|
|
1339
|
+
})), s2.addEventListener("mouseout", (() => {
|
|
1340
|
+
s2.style.border = "none";
|
|
1341
|
+
})), s2.addEventListener("click", (() => {
|
|
1342
|
+
s2.style.border = "2px solid #000";
|
|
1343
|
+
}));
|
|
1344
|
+
const r2 = document.createElement("label");
|
|
1345
|
+
r2.textContent = n2, r2.classList.add("magicfeedback-multiple-choice-image-label");
|
|
1346
|
+
const o2 = document.createElement("input");
|
|
1347
|
+
o2.id = `rating-${y}-${t5}`, o2.type = Y ? "checkbox" : "radio", o2.name = y, o2.value = n2, o2.style.position = "absolute", o2.style.opacity = "0", o2.style.width = "0", o2.style.height = "0", o2.classList.add("magicfeedback-input"), w && w === o2.value && (o2.checked = true), !Y && d2 && o2.addEventListener("change", (() => {
|
|
1348
|
+
console.log("send"), d2();
|
|
1349
|
+
}));
|
|
1350
|
+
const l3 = document.createElement("img");
|
|
1351
|
+
l3.classList.add("magicfeedback-multiple-choice-image-image"), l3.src = i4, l3.style.cursor = "pointer", l3.style.backgroundSize = "cover", l3.style.backgroundPosition = "center", l3.style.width = "100%", l3.style.height = "100%", l3.style.objectFit = "cover", l3.style.margin = "auto", s2.appendChild(o2), s2.appendChild(l3), G && s2.appendChild(r2), a2.appendChild(s2), j.appendChild(a2);
|
|
1352
|
+
} catch (e7) {
|
|
1353
|
+
console.error(e7);
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-multiple-choice-image";
|
|
1357
|
+
const j = document.createElement("div");
|
|
1358
|
+
j.classList.add("magicfeedback-multiple-choice-image-container"), j.style.display = "flex", j.style.flexDirection = "row", j.style.flexWrap = "wrap", j.style.justifyContent = "center";
|
|
1359
|
+
const Q = b.length;
|
|
1360
|
+
let W = 1, K = 1;
|
|
1361
|
+
if (window.innerWidth < 600) W = 1, K = Q;
|
|
1362
|
+
else switch (Q) {
|
|
1363
|
+
case 1:
|
|
1364
|
+
case 2:
|
|
1365
|
+
case 3:
|
|
1366
|
+
W = Q, K = 1;
|
|
1367
|
+
break;
|
|
1368
|
+
case 4:
|
|
1369
|
+
case 5:
|
|
1370
|
+
case 6:
|
|
1371
|
+
K = 2, W = Math.ceil(Q / K);
|
|
1372
|
+
break;
|
|
1373
|
+
case 7:
|
|
1374
|
+
case 8:
|
|
1375
|
+
case 9:
|
|
1376
|
+
K = 3, W = Math.ceil(Q / K);
|
|
1377
|
+
break;
|
|
1378
|
+
default:
|
|
1379
|
+
K = 4, W = Math.ceil(Q / K);
|
|
1380
|
+
}
|
|
1381
|
+
const G = void 0 !== (null == k ? void 0 : k.addTitle) && (null == k ? void 0 : k.addTitle), Y = void 0 !== (null == k ? void 0 : k.multiOption) && (null == k ? void 0 : k.multiOption), H = void 0 !== (null == k ? void 0 : k.extraOption) && (null == k ? void 0 : k.extraOption);
|
|
1382
|
+
P && (b = b.sort((() => Math.random() - 0.5))), b.forEach(((e6) => V(JSON.parse(e6)))), H && (null == k ? void 0 : k.extraOptionValue) && (null == k ? void 0 : k.extraOptionValue.length) > 0 && V(null == k ? void 0 : k.extraOptionValue[0]), h2.appendChild(j);
|
|
1383
|
+
break;
|
|
1384
|
+
case n.FEEDBACKAPPANSWERTYPE.SELECT:
|
|
1385
|
+
h2 = document.createElement("select"), m2 = "magicfeedback-select";
|
|
1386
|
+
const X = document.createElement("option");
|
|
1387
|
+
X.value = "", X.text = "slim" === t4 ? r(g2, i3) : A || "Select an option", X.disabled = true, X.selected = true, h2.appendChild(X), b.forEach(((e6) => {
|
|
1388
|
+
const t5 = document.createElement("option");
|
|
1389
|
+
t5.value = e6, t5.text = e6, h2.appendChild(t5);
|
|
1390
|
+
})), w && b.includes(w) && (h2.value = w), d2 && h2.addEventListener("change", (() => {
|
|
1391
|
+
d2();
|
|
1392
|
+
}));
|
|
1393
|
+
break;
|
|
1394
|
+
case n.FEEDBACKAPPANSWERTYPE.DATE:
|
|
1395
|
+
h2 = document.createElement("input"), h2.type = "date", h2.required = E, h2.placeholder = x || a.placeholder.date(i3 || "en"), m2 = "magicfeedback-date", w && (h2.value = w);
|
|
1396
|
+
break;
|
|
1397
|
+
case n.FEEDBACKAPPANSWERTYPE.CONSENT:
|
|
1398
|
+
h2 = document.createElement("input"), m2 = "magicfeedback-consent", h2.type = "checkbox", h2.id = `magicfeedback-${f2}`, h2.name = y, h2.value = "true", h2.required = E, h2.classList.add("magicfeedback-consent"), h2.classList.add("magicfeedback-input"), w && b.includes(w) && (h2.checked = true), d2 && h2.addEventListener("change", (() => {
|
|
1399
|
+
d2();
|
|
1400
|
+
}));
|
|
1401
|
+
break;
|
|
1402
|
+
case n.FEEDBACKAPPANSWERTYPE.EMAIL:
|
|
1403
|
+
h2 = document.createElement("input"), h2.type = "email", h2.required = E, h2.placeholder = x || "you@example.com", m2 = "magicfeedback-email", w && (h2.value = w);
|
|
1404
|
+
break;
|
|
1405
|
+
case n.FEEDBACKAPPANSWERTYPE.PASSWORD:
|
|
1406
|
+
h2 = document.createElement("input"), h2.type = "password", h2.required = E, h2.placeholder = x || a.placeholder.password(i3 || "en"), m2 = "magicfeedback-password", w && (h2.value = w);
|
|
1407
|
+
break;
|
|
1408
|
+
case n.FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX:
|
|
1409
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-multi-question-matrix";
|
|
1410
|
+
const z = document.createElement("div");
|
|
1411
|
+
z.classList.add("magicfeedback-multi-question-matrix-container");
|
|
1412
|
+
let J = (null == k ? void 0 : k.options) || [], Z = [...b], ee = [];
|
|
1413
|
+
if (P && (J = null == J ? void 0 : J.sort((() => Math.random() - 0.5)), Z = [...Z].sort((() => Math.random() - 0.5))), (null == k ? void 0 : k.exclusiveAnswers) && (ee = null == k ? void 0 : k.exclusiveAnswers, null == ee || ee.forEach(((e6) => {
|
|
1414
|
+
Z.includes(e6) || Z.push(e6);
|
|
1415
|
+
}))), window.innerWidth < 600) {
|
|
1416
|
+
const ke = document.createElement("div");
|
|
1417
|
+
ke.classList.add("magicfeedback-multi-question-matrix-list"), null == J || J.forEach(((e6) => {
|
|
1418
|
+
const t5 = document.createElement("div");
|
|
1419
|
+
t5.classList.add("magicfeedback-multi-question-matrix-list-item"), t5.style.display = "flex", t5.style.flexDirection = "column", t5.style.alignItems = "flex-start", t5.style.marginBottom = "10px";
|
|
1420
|
+
const i4 = document.createElement("label");
|
|
1421
|
+
i4.classList.add("magicfeedback-multi-question-matrix-label"), i4.style.paddingBottom = "10px", i4.textContent = e6, t5.appendChild(i4), Z.forEach(((i5) => {
|
|
1422
|
+
const n2 = document.createElement("div");
|
|
1423
|
+
n2.classList.add("magicfeedback-radio-container"), n2.style.display = "flex", n2.style.alignItems = "center", n2.style.justifyContent = "flex-start", n2.style.width = "99%", n2.style.margin = "5px auto";
|
|
1424
|
+
const a2 = document.createElement("label"), s2 = document.createElement("input");
|
|
1425
|
+
s2.id = `${y}-${e6}-${i5}`, s2.type = "radio", s2.name = `${y}-${e6}`, s2.value = i5, s2.classList.add("magicfeedback-input"), a2.textContent = i5, a2.htmlFor = `${y}-${e6}-${i5}`, n2.appendChild(s2), n2.appendChild(a2), t5.appendChild(n2);
|
|
1426
|
+
})), ke.appendChild(t5);
|
|
1427
|
+
})), z.appendChild(ke);
|
|
1428
|
+
} else {
|
|
1429
|
+
const Ce = document.createElement("table");
|
|
1430
|
+
Ce.classList.add("magicfeedback-multi-question-matrix-table");
|
|
1431
|
+
const Te = document.createElement("thead");
|
|
1432
|
+
Te.classList.add("magicfeedback-multi-question-matrix-header"), Te.style.paddingBottom = "15px";
|
|
1433
|
+
const xe = document.createElement("tr"), we = document.createElement("th");
|
|
1434
|
+
xe.appendChild(we), Z.forEach(((e6) => {
|
|
1435
|
+
const t5 = document.createElement("th");
|
|
1436
|
+
t5.textContent = e6, xe.appendChild(t5);
|
|
1437
|
+
})), Te.appendChild(xe), Ce.appendChild(Te);
|
|
1438
|
+
const Le = document.createElement("tbody");
|
|
1439
|
+
null == J || J.forEach(((e6) => {
|
|
1440
|
+
const t5 = document.createElement("tr");
|
|
1441
|
+
t5.classList.add("magicfeedback-multi-question-matrix-row-tr");
|
|
1442
|
+
const i4 = document.createElement("td");
|
|
1443
|
+
i4.style.minWidth = "200px";
|
|
1444
|
+
const n2 = document.createElement("label");
|
|
1445
|
+
n2.classList.add("magicfeedback-multi-question-matrix-label"), n2.style.paddingRight = "20px", n2.textContent = e6, i4.appendChild(n2), t5.appendChild(i4), Z.forEach(((i5) => {
|
|
1446
|
+
const n3 = document.createElement("td"), a2 = document.createElement("input");
|
|
1447
|
+
a2.type = "radio", a2.name = `${y}-${e6}`, a2.value = i5, a2.id = `${y}-${e6}-${i5}`, a2.classList.add("magicfeedback-input"), n3.appendChild(a2), t5.appendChild(n3);
|
|
1448
|
+
})), Le.appendChild(t5);
|
|
1449
|
+
})), Ce.appendChild(Le), z.appendChild(Ce);
|
|
1450
|
+
}
|
|
1451
|
+
h2.appendChild(z);
|
|
1452
|
+
break;
|
|
1453
|
+
case n.FEEDBACKAPPANSWERTYPE.PRIORITY_LIST:
|
|
1454
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-priority-list";
|
|
1455
|
+
const te = document.createElement("div");
|
|
1456
|
+
te.classList.add("magicfeedback-priority-list-container");
|
|
1457
|
+
const ie = document.createElement("ul");
|
|
1458
|
+
ie.classList.add("magicfeedback-priority-list-list"), P && (b = b.sort((() => Math.random() - 0.5))), b.forEach(((e6, t5) => {
|
|
1459
|
+
const i4 = document.createElement("li");
|
|
1460
|
+
i4.classList.add("magicfeedback-priority-list-item"), i4.style.display = "flex", i4.style.justifyContent = "space-between", i4.style.alignItems = "center", i4.style.margin = "5px";
|
|
1461
|
+
const n2 = document.createElement("input");
|
|
1462
|
+
n2.classList.add("magicfeedback-input-magicfeedback-priority-list"), n2.classList.add("magicfeedback-input"), n2.type = "hidden", n2.id = `priority-list-${y}`, n2.name = y, n2.value = `${t5 + 1}. ${e6}`, i4.appendChild(n2);
|
|
1463
|
+
const a2 = document.createElement("label");
|
|
1464
|
+
a2.classList.add("magicfeedback-priority-list-item-label"), a2.textContent = `${t5 + 1}. ${e6}`, i4.appendChild(a2);
|
|
1465
|
+
const s2 = document.createElement("div");
|
|
1466
|
+
s2.style.display = "flex", s2.style.alignItems = "center", s2.style.justifyContent = "space-between";
|
|
1467
|
+
const r2 = document.createElement("img");
|
|
1468
|
+
r2.classList.add("magicfeedback-priority-list-arrow-up"), r2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", r2.style.width = "20px", r2.style.height = "20px", r2.style.cursor = "pointer", r2.style.margin = "0 5px", r2.style.color = "#000", r2.style.visibility = 0 === t5 ? "hidden" : "visible", r2.addEventListener("click", (() => {
|
|
1469
|
+
var t6, s3, l3, d3;
|
|
1470
|
+
const c3 = i4.previousElementSibling;
|
|
1471
|
+
if (c3) {
|
|
1472
|
+
const u3 = Number(null === (t6 = n2.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) - 1;
|
|
1473
|
+
n2.value = `${u3}. ${e6}`, a2.textContent = `${u3}. ${e6}`, r2.style.visibility = 1 === u3 ? "hidden" : "visible", o2.style.visibility = u3 === b.length ? "hidden" : "visible";
|
|
1474
|
+
const p3 = c3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), h3 = c3.querySelector(".magicfeedback-priority-list-item-label"), m3 = c3.querySelector(".magicfeedback-priority-list-arrow-up"), f3 = c3.querySelector(".magicfeedback-priority-list-arrow-down");
|
|
1475
|
+
if (p3 && h3 && m3 && f3) {
|
|
1476
|
+
const e7 = Number(null === (s3 = p3.value) || void 0 === s3 ? void 0 : s3.split(".")[0]) + 1;
|
|
1477
|
+
p3.value = `${e7}.${null === (l3 = h3.textContent) || void 0 === l3 ? void 0 : l3.split(".")[1]}`, h3.textContent = `${e7}.${null === (d3 = h3.textContent) || void 0 === d3 ? void 0 : d3.split(".")[1]}`, m3.style.visibility = 1 === e7 ? "hidden" : "visible", f3.style.visibility = e7 === b.length ? "hidden" : "visible";
|
|
1478
|
+
}
|
|
1479
|
+
ie.insertBefore(i4, c3);
|
|
1480
|
+
}
|
|
1481
|
+
})), s2.appendChild(r2);
|
|
1482
|
+
const o2 = document.createElement("img");
|
|
1483
|
+
o2.classList.add("magicfeedback-priority-list-arrow-down"), o2.src = "https://magicfeedback-c6458-dev.web.app/assets/arrow.svg", o2.style.width = "20px", o2.style.height = "20px", o2.style.cursor = "pointer", o2.style.margin = "0 5px", o2.style.color = "#000", o2.style.transform = "rotate(180deg)", o2.style.visibility = t5 === b.length - 1 ? "hidden" : "visible", o2.addEventListener("click", (() => {
|
|
1484
|
+
var t6, s3, l3;
|
|
1485
|
+
const d3 = i4.nextElementSibling;
|
|
1486
|
+
if (d3) {
|
|
1487
|
+
const c3 = Number(null === (t6 = n2.value) || void 0 === t6 ? void 0 : t6.split(".")[0]) + 1;
|
|
1488
|
+
n2.value = c3.toString(), a2.textContent = `${c3.toString()}. ${e6}`, r2.style.visibility = 1 === c3 ? "hidden" : "visible", o2.style.visibility = c3 === b.length ? "hidden" : "visible";
|
|
1489
|
+
const u3 = d3.querySelector(".magicfeedback-input-magicfeedback-priority-list"), p3 = d3.querySelector(".magicfeedback-priority-list-item-label"), h3 = d3.querySelector(".magicfeedback-priority-list-arrow-up"), m3 = d3.querySelector(".magicfeedback-priority-list-arrow-down");
|
|
1490
|
+
if (u3 && p3 && h3 && m3) {
|
|
1491
|
+
const e7 = Number(u3.value.split(".")[0]) - 1;
|
|
1492
|
+
u3.value = `${e7}.${null === (s3 = p3.textContent) || void 0 === s3 ? void 0 : s3.split(".")[1]}`, p3.textContent = `${e7}.${null === (l3 = p3.textContent) || void 0 === l3 ? void 0 : l3.split(".")[1]}`, h3.style.visibility = 1 === e7 ? "hidden" : "visible", m3.style.visibility = e7 === b.length ? "hidden" : "visible";
|
|
1493
|
+
}
|
|
1494
|
+
ie.insertBefore(d3, i4);
|
|
1495
|
+
}
|
|
1496
|
+
})), s2.appendChild(o2), i4.appendChild(s2), ie.appendChild(i4);
|
|
1497
|
+
})), te.appendChild(ie), h2.appendChild(te);
|
|
1498
|
+
break;
|
|
1499
|
+
case n.FEEDBACKAPPANSWERTYPE.POINT_SYSTEM:
|
|
1500
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-point-system";
|
|
1501
|
+
const ne = document.createElement("div");
|
|
1502
|
+
ne.classList.add("magicfeedback-point-system-container");
|
|
1503
|
+
const ae = document.createElement("ul");
|
|
1504
|
+
ae.classList.add("magicfeedback-point-system-list"), ae.style.padding = "0";
|
|
1505
|
+
const se = 100, re = se / b.length, oe = document.createElement("div");
|
|
1506
|
+
oe.classList.add("magicfeedback-error"), oe.textContent = a.placeholder.pointsystemerror(i3 || "en"), oe.style.color = "#C70039", oe.style.fontSize = "14px", oe.style.textAlign = "right", oe.style.width = "100%", oe.style.display = "none";
|
|
1507
|
+
const le = document.createElement("div");
|
|
1508
|
+
le.classList.add("magicfeedback-point-system-total"), le.textContent = "0 / 100 %", le.style.textAlign = "right", le.style.fontSize = "15px", le.style.marginTop = "5px", b.forEach(((e6, t5) => {
|
|
1509
|
+
const i4 = document.createElement("li");
|
|
1510
|
+
i4.classList.add("magicfeedback-point-system-item"), i4.style.display = "flex", i4.style.justifyContent = "space-between", i4.style.alignItems = "center", i4.style.margin = "5px";
|
|
1511
|
+
const n2 = document.createElement("label");
|
|
1512
|
+
n2.textContent = e6, n2.style.fontSize = "15px", i4.appendChild(n2);
|
|
1513
|
+
const a2 = document.createElement("span");
|
|
1514
|
+
a2.classList.add("magicfeedback-point-system-input-container");
|
|
1515
|
+
const s2 = document.createElement("input");
|
|
1516
|
+
s2.name = y, s2.id = `${e6}`, s2.type = "number", s2.min = "0", s2.max = `${se}`, s2.value = "0", s2.classList.add("magicfeedback-input"), s2.style.width = "40px", s2.style.border = "0", s2.style.textAlign = "center", s2.style.margin = "0 5px", s2.autofocus = 0 === t5;
|
|
1517
|
+
const r2 = document.createElement("span");
|
|
1518
|
+
r2.textContent = "%", r2.style.color = "#000", s2.addEventListener("input", (() => {
|
|
1519
|
+
const e7 = ae.querySelectorAll("input");
|
|
1520
|
+
let t6 = 0;
|
|
1521
|
+
e7.forEach(((e8) => {
|
|
1522
|
+
t6 += Number(e8.value);
|
|
1523
|
+
})), t6 > se && (s2.value = `${re}%`, t6 -= Number(s2.value));
|
|
1524
|
+
const i5 = document.getElementById("magicfeedback-submit");
|
|
1525
|
+
i5 && (t6 < 100 ? (le.style.color = "orange", i5.setAttribute("disabled", "true")) : (oe.style.display = "none", le.style.color = "green", i5.removeAttribute("disabled"))), le.textContent = `${t6} / 100 %`;
|
|
1526
|
+
})), s2.addEventListener("focus", (() => {
|
|
1527
|
+
const e7 = document.getElementById("magicfeedback-submit");
|
|
1528
|
+
e7 && (e7.setAttribute("disabled", "true"), e7.addEventListener("pointerover", (() => {
|
|
1529
|
+
const e8 = ae.querySelectorAll("input");
|
|
1530
|
+
let t6 = 0;
|
|
1531
|
+
e8.forEach(((e9) => {
|
|
1532
|
+
t6 += Number(e9.value);
|
|
1533
|
+
})), t6 < 100 && (oe.style.display = "block");
|
|
1534
|
+
})));
|
|
1535
|
+
})), a2.appendChild(s2), a2.appendChild(r2), i4.appendChild(a2), ae.appendChild(i4);
|
|
1536
|
+
})), ne.appendChild(ae), ne.appendChild(le), ne.appendChild(oe), h2.appendChild(ne);
|
|
1537
|
+
break;
|
|
1538
|
+
case n.FEEDBACKAPPANSWERTYPE.INFO_PAGE:
|
|
1539
|
+
h2 = document.createElement("div"), m2 = "magicfeedback-info-page";
|
|
1540
|
+
const de = document.createElement("div");
|
|
1541
|
+
de.classList.add("magicfeedback-info-message"), de.innerHTML = x, h2.appendChild(de);
|
|
1542
|
+
break;
|
|
1543
|
+
case n.FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE:
|
|
1544
|
+
h2 = document.createElement("input"), h2.type = "file", h2.accept = "image/*", h2.required = E, h2.multiple = (null == k ? void 0 : k.multiple) || false, h2.maxLength = (null == k ? void 0 : k.maxFiles) || 1, m2 = "magicfeedback-upload-image";
|
|
1545
|
+
break;
|
|
1546
|
+
case n.FEEDBACKAPPANSWERTYPE.UPLOAD_FILE:
|
|
1547
|
+
h2 = document.createElement("input"), h2.type = "file", h2.required = E, h2.multiple = (null == k ? void 0 : k.multiple) || false, h2.maxLength = (null == k ? void 0 : k.maxFiles) || 1, m2 = "magicfeedback-upload-file";
|
|
1548
|
+
break;
|
|
1549
|
+
default:
|
|
1550
|
+
return C;
|
|
1551
|
+
}
|
|
1552
|
+
h2.id = `magicfeedback-${f2}`, h2.setAttribute("name", y), h2.classList.add(m2), (void 0 !== A || null !== w) && (h2.value = w || A), ["RADIO", "MULTIPLECHOICE"].includes(v) || (h2.classList.add("magicfeedback-input"), h2.required = E);
|
|
1553
|
+
const I = document.createElement("label");
|
|
1554
|
+
I.setAttribute("for", `magicfeedback-${f2}`), I.textContent = r(g2, i3), I.classList.add("magicfeedback-label");
|
|
1555
|
+
const D = document.createElement("label");
|
|
1556
|
+
if (D.textContent = r(null == k ? void 0 : k.subtitle, i3), D.classList.add("magicfeedback-sublabel"), (null === (c2 = null == k ? void 0 : k.subtitleStyle) || void 0 === c2 ? void 0 : c2.includes("italic")) && (D.style.fontStyle = "italic"), (null === (u2 = null == k ? void 0 : k.subtitleStyle) || void 0 === u2 ? void 0 : u2.includes("bold")) && (D.style.fontWeight = "bold"), (null === (p2 = null == k ? void 0 : k.subtitleStyle) || void 0 === p2 ? void 0 : p2.includes("underline")) && (D.style.textDecoration = "underline"), ["CONSENT"].includes(v)) C.classList.add("magicfeedback-consent-container"), C.appendChild(h2), C.appendChild(I), C.appendChild(D);
|
|
1557
|
+
else {
|
|
1558
|
+
if ("slim" !== t4 && (C.appendChild(I), C.appendChild(D), void 0 !== (null == k ? void 0 : k.general) && "" !== (null == k ? void 0 : k.general))) {
|
|
1559
|
+
const Pe = document.createElement("img");
|
|
1560
|
+
Pe.src = null == k ? void 0 : k.general, Pe.classList.add("magicfeedback-image"), Pe.style.maxWidth = "auto", Pe.style.height = "400px", Pe.style.margin = "10px 0", C.appendChild(Pe);
|
|
1561
|
+
}
|
|
1562
|
+
if ("LONGTEXT" === v && L > 0) {
|
|
1563
|
+
const Se = document.createElement("div");
|
|
1564
|
+
if (Se.classList.add("magicfeedback-counter"), Se.textContent = `${h2.value.length}/${L}`, Se.style.textAlign = "right", Se.style.fontSize = "15px", Se.style.marginTop = "5px", h2.addEventListener("input", (() => {
|
|
1565
|
+
Se.textContent = `${h2.value.length}/${L}`;
|
|
1566
|
+
})), C.appendChild(h2), C.appendChild(Se), (null == k ? void 0 : k.extraOption) && (null == k ? void 0 : k.extraOptionText)) {
|
|
1567
|
+
const Oe = document.createElement("div");
|
|
1568
|
+
Oe.classList.add("magicfeedback-skip-container"), Oe.classList.add("magicfeedback-checkbox-container"), Oe.style.display = "flex", Oe.style.justifyContent = "flex-start";
|
|
1569
|
+
const Ne = document.createElement("input");
|
|
1570
|
+
Ne.classList.add("magicfeedback-skip"), Ne.type = "checkbox", Ne.id = `skip-${y}`, Ne.name = y, Ne.value = "-", Ne.style.cursor = "pointer";
|
|
1571
|
+
const Ie = document.createElement("label");
|
|
1572
|
+
Ie.htmlFor = `skip-${y}`, Ie.textContent = null == k ? void 0 : k.extraOptionText, Ie.style.fontSize = "15px", Ie.style.cursor = "pointer", Ie.style.margin = "0 5px", Ne.addEventListener("click", (() => {
|
|
1573
|
+
h2.value = "-", d2 && d2();
|
|
1574
|
+
})), Oe.appendChild(Ne), Oe.appendChild(Ie), C.appendChild(Oe);
|
|
1575
|
+
}
|
|
1576
|
+
} else C.appendChild(h2);
|
|
1577
|
+
}
|
|
1578
|
+
return C;
|
|
1579
|
+
})(m, i2, l, `${s}${p ? `/${h}` : ""}`, 1 === t3.length ? c : void 0);
|
|
1580
|
+
u.push(e4);
|
|
1581
|
+
}
|
|
1582
|
+
})), u;
|
|
1583
|
+
}, t2.renderActions = function(e3 = "", t3, i2 = "Submit", n2 = "Back", a2 = "Next") {
|
|
1584
|
+
const s2 = document.createElement("div");
|
|
1585
|
+
s2.classList.add("magicfeedback-action-container");
|
|
1586
|
+
const r2 = document.createElement("button");
|
|
1587
|
+
r2.id = "magicfeedback-submit", r2.type = "submit", r2.classList.add("magicfeedback-submit"), r2.textContent = "MAGICSURVEY" === e3 ? a2 || "Next" : i2 || "Submit";
|
|
1588
|
+
const o2 = document.createElement("button");
|
|
1589
|
+
return o2.id = "magicfeedback-back", o2.type = "button", o2.classList.add("magicfeedback-back"), o2.textContent = n2 || "Back", o2.addEventListener("click", t3), o2.addEventListener("click", (() => {
|
|
1590
|
+
r2.removeAttribute("disabled");
|
|
1591
|
+
})), "MAGICSURVEY" === e3 && s2.appendChild(o2), s2.appendChild(r2), s2;
|
|
1592
|
+
}, t2.renderError = function(e3) {
|
|
1593
|
+
const t3 = document.createElement("div");
|
|
1594
|
+
return t3.classList.add("magicfeedback-error"), t3.textContent = e3, t3;
|
|
1595
|
+
}, t2.renderSuccess = function(e3) {
|
|
1596
|
+
const t3 = document.createElement("div");
|
|
1597
|
+
return t3.classList.add("magicfeedback-success"), t3.textContent = e3, t3;
|
|
1598
|
+
}, t2.renderStartMessage = function(e3, t3 = false, i2 = "Go!", n2 = () => {
|
|
1599
|
+
}) {
|
|
1600
|
+
const a2 = document.createElement("div");
|
|
1601
|
+
a2.classList.add("magicfeedback-start-message-container");
|
|
1602
|
+
const s2 = document.createElement("div");
|
|
1603
|
+
if (s2.classList.add("magicfeedback-start-message"), s2.innerHTML = e3, a2.appendChild(s2), t3) {
|
|
1604
|
+
const e4 = document.createElement("button");
|
|
1605
|
+
e4.id = "magicfeedback-start-message-button", e4.classList.add("magicfeedback-start-message-button"), e4.textContent = i2, e4.addEventListener("click", (() => n2())), a2.appendChild(e4);
|
|
1606
|
+
}
|
|
1607
|
+
return a2;
|
|
1608
|
+
};
|
|
1609
|
+
}, 313: function(e2, t2, i) {
|
|
1610
|
+
"use strict";
|
|
1611
|
+
var n = this && this.__awaiter || function(e3, t3, i2, n2) {
|
|
1612
|
+
return new (i2 || (i2 = Promise))((function(a2, s2) {
|
|
1613
|
+
function r2(e4) {
|
|
1614
|
+
try {
|
|
1615
|
+
l2(n2.next(e4));
|
|
1616
|
+
} catch (e5) {
|
|
1617
|
+
s2(e5);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function o2(e4) {
|
|
1621
|
+
try {
|
|
1622
|
+
l2(n2.throw(e4));
|
|
1623
|
+
} catch (e5) {
|
|
1624
|
+
s2(e5);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
function l2(e4) {
|
|
1628
|
+
var t4;
|
|
1629
|
+
e4.done ? a2(e4.value) : (t4 = e4.value, t4 instanceof i2 ? t4 : new i2((function(e5) {
|
|
1630
|
+
e5(t4);
|
|
1631
|
+
}))).then(r2, o2);
|
|
1632
|
+
}
|
|
1633
|
+
l2((n2 = n2.apply(e3, t3 || [])).next());
|
|
1634
|
+
}));
|
|
1635
|
+
}, a = this && this.__importDefault || function(e3) {
|
|
1636
|
+
return e3 && e3.__esModule ? e3 : { default: e3 };
|
|
1637
|
+
};
|
|
1638
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.getFollowUpQuestion = t2.sendFeedback = t2.getQuestions = t2.getSessionForm = t2.getForm = t2.validateEmail = void 0;
|
|
1639
|
+
const s = a(i(945)), r = a(i(330)), o = i(857), l = { Accept: "application/json", "Magicfeedback-Sdk-Version": r.default.version, "x-magicfeedback-parameters": window.location.search || "" };
|
|
1640
|
+
t2.validateEmail = function(e3) {
|
|
1641
|
+
return /\S+@\S+\.\S+/.test(e3);
|
|
1642
|
+
}, t2.getForm = function(e3, t3, i2, a2) {
|
|
1643
|
+
return n(this, void 0, void 0, (function* () {
|
|
1644
|
+
try {
|
|
1645
|
+
const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.app_info(t3, i2), { method: "GET", headers: l });
|
|
1646
|
+
return yield n2.json();
|
|
1647
|
+
} catch (e4) {
|
|
1648
|
+
a2.err(e4);
|
|
1649
|
+
}
|
|
1650
|
+
}));
|
|
1651
|
+
}, t2.getSessionForm = function(e3, t3, i2) {
|
|
1652
|
+
return n(this, void 0, void 0, (function* () {
|
|
1653
|
+
try {
|
|
1654
|
+
const i3 = yield (0, s.default)(e3 + o.endpoints.sdk.session(t3), { method: "GET", headers: l });
|
|
1655
|
+
return yield i3.json();
|
|
1656
|
+
} catch (e4) {
|
|
1657
|
+
i2.err(e4);
|
|
1658
|
+
}
|
|
1659
|
+
}));
|
|
1660
|
+
}, t2.getQuestions = function(e3, t3, i2, a2) {
|
|
1661
|
+
return n(this, void 0, void 0, (function* () {
|
|
1662
|
+
try {
|
|
1663
|
+
const n2 = yield (0, s.default)(e3 + o.endpoints.sdk.app(t3, i2), { method: "GET", headers: l });
|
|
1664
|
+
if (n2.ok) {
|
|
1665
|
+
const e4 = yield n2.json();
|
|
1666
|
+
return a2.log(`Received questions for app ${t3}`, e4), e4;
|
|
1667
|
+
}
|
|
1668
|
+
throw a2.err(`Failed to get questions for app ${t3}:`, n2.status, n2.statusText), new Error("[MagicFeedback] Bad response from server");
|
|
1669
|
+
} catch (e4) {
|
|
1670
|
+
return a2.err(e4), [];
|
|
1671
|
+
}
|
|
1672
|
+
}));
|
|
1673
|
+
}, t2.sendFeedback = function(e3, t3, i2) {
|
|
1674
|
+
return n(this, void 0, void 0, (function* () {
|
|
1675
|
+
try {
|
|
1676
|
+
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) });
|
|
1677
|
+
if (n2.ok) return i2.log(`Form ${t3.integration} submitted successfully!`), (yield n2.json()).sessionId;
|
|
1678
|
+
throw i2.err(`Failed to submit form ${t3.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
|
|
1679
|
+
} catch (e4) {
|
|
1680
|
+
return i2.err(e4), "";
|
|
1681
|
+
}
|
|
1682
|
+
}));
|
|
1683
|
+
}, t2.getFollowUpQuestion = function(e3, t3, i2) {
|
|
1684
|
+
return n(this, void 0, void 0, (function* () {
|
|
1685
|
+
try {
|
|
1686
|
+
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) });
|
|
1687
|
+
if (n2.ok) return i2.log(`Received follow up question for form ${t3.integration}`), (yield n2.json()) || "";
|
|
1688
|
+
throw i2.err(`Failed to get follow up question for form ${t3.integration}:`, n2.status, n2.statusText), new Error(n2.statusText);
|
|
1689
|
+
} catch (e4) {
|
|
1690
|
+
return i2.err(e4), "";
|
|
1691
|
+
}
|
|
1692
|
+
}));
|
|
1693
|
+
};
|
|
1694
|
+
}, 256: (e2, t2) => {
|
|
1695
|
+
"use strict";
|
|
1696
|
+
Object.defineProperty(t2, "__esModule", { value: true }), t2.Log = void 0, t2.Log = class {
|
|
1697
|
+
constructor(e3) {
|
|
1698
|
+
this.config = e3;
|
|
1699
|
+
}
|
|
1700
|
+
log(...e3) {
|
|
1701
|
+
this.config.get("debug") && console.log("[MagicFeedback]:", ...e3);
|
|
1702
|
+
}
|
|
1703
|
+
err(...e3) {
|
|
1704
|
+
console.error("[MagicFeedback]:", ...e3);
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
}, 330: (e2) => {
|
|
1708
|
+
"use strict";
|
|
1709
|
+
e2.exports = JSON.parse('{"name":"@magicfeedback/native","version":"2.1.2-beta.2","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","publish":"npm publish --access public","publish:beta":"npm publish --access public --tag beta","publish:alpha":"npm publish --access public --tag alpha","test":"jest","test:watch":"jest --watchAll","coverage":"vitest run --coverage"},"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"}');
|
|
1710
|
+
} }, t = {}, (function i(n) {
|
|
1711
|
+
var a = t[n];
|
|
1712
|
+
if (void 0 !== a) return a.exports;
|
|
1713
|
+
var s = t[n] = { exports: {} };
|
|
1714
|
+
return e[n].call(s.exports, s, s.exports, i), s.exports;
|
|
1715
|
+
})(156).default;
|
|
1716
|
+
var e, t;
|
|
1717
|
+
}));
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
|
|
1721
|
+
// src/index.ts
|
|
1722
|
+
var index_exports = {};
|
|
1723
|
+
__export(index_exports, {
|
|
1724
|
+
DeepdotsPopups: () => DeepdotsPopups
|
|
1725
|
+
});
|
|
1726
|
+
module.exports = __toCommonJS(index_exports);
|
|
1727
|
+
|
|
1728
|
+
// src/ui/renderPopup.ts
|
|
1729
|
+
var import_native = __toESM(require_magicfeedback_sdk_browser());
|
|
1730
|
+
async function renderPopup(container, surveyId, productId, data, emit, onClose) {
|
|
1731
|
+
console.log("[MagicFeedback] Rendering popup for survey:", surveyId);
|
|
1732
|
+
const popup = document.createElement("div");
|
|
1733
|
+
popup.className = "deepdots-popup";
|
|
1734
|
+
popup.style.cssText = `
|
|
1735
|
+
background: white;
|
|
1736
|
+
border-radius: 8px;
|
|
1737
|
+
padding: 24px;
|
|
1738
|
+
max-width: 600px;
|
|
1739
|
+
width: 90%;
|
|
1740
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
1741
|
+
position: relative;
|
|
1742
|
+
`;
|
|
1743
|
+
const closeButton = document.createElement("button");
|
|
1744
|
+
closeButton.innerHTML = "×";
|
|
1745
|
+
closeButton.style.cssText = `
|
|
1746
|
+
position: absolute;
|
|
1747
|
+
top: 8px;
|
|
1748
|
+
right: 12px;
|
|
1749
|
+
border: none;
|
|
1750
|
+
background: none;
|
|
1751
|
+
font-size: 24px;
|
|
1752
|
+
cursor: pointer;
|
|
1753
|
+
color: #666;
|
|
1754
|
+
`;
|
|
1755
|
+
closeButton.onclick = () => onClose();
|
|
1756
|
+
const content = document.createElement("div");
|
|
1757
|
+
const formDivId = `magicfeedback-form-${surveyId}`;
|
|
1758
|
+
content.innerHTML = `
|
|
1759
|
+
<div id="${formDivId}" style="margin-top: 12px; width: 100%"></div>
|
|
1760
|
+
`;
|
|
1761
|
+
let surveyCompletedEmitted = false;
|
|
1762
|
+
const submitButton = document.createElement("button");
|
|
1763
|
+
submitButton.textContent = "Complete Survey";
|
|
1764
|
+
submitButton.style.cssText = `
|
|
1765
|
+
background: #4CAF50;
|
|
1766
|
+
color: white;
|
|
1767
|
+
border: none;
|
|
1768
|
+
padding: 12px 24px;
|
|
1769
|
+
border-radius: 4px;
|
|
1770
|
+
cursor: pointer;
|
|
1771
|
+
font-size: 14px;
|
|
1772
|
+
margin-top: 16px;
|
|
1773
|
+
`;
|
|
1774
|
+
submitButton.onclick = () => {
|
|
1775
|
+
if (!surveyCompletedEmitted) {
|
|
1776
|
+
emit("popup_clicked", surveyId, data);
|
|
1777
|
+
emit("survey_completed", surveyId, data);
|
|
1778
|
+
surveyCompletedEmitted = true;
|
|
1779
|
+
}
|
|
1780
|
+
onClose();
|
|
1781
|
+
};
|
|
1782
|
+
popup.appendChild(closeButton);
|
|
1783
|
+
popup.appendChild(content);
|
|
1784
|
+
popup.appendChild(submitButton);
|
|
1785
|
+
container.innerHTML = "";
|
|
1786
|
+
container.appendChild(popup);
|
|
1787
|
+
container.style.display = "flex";
|
|
1788
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
try {
|
|
1792
|
+
if (!import_native.default || typeof import_native.default.form !== "function") {
|
|
1793
|
+
console.warn("[MagicFeedback] form() no disponible. Se usa fallback manual.");
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
import_native.default.init({ debug: true, env: "prod" });
|
|
1797
|
+
const formInstance = import_native.default.form(surveyId, productId);
|
|
1798
|
+
formInstance.generate(formDivId, {
|
|
1799
|
+
addButton: true,
|
|
1800
|
+
// permitir que el propio formulario gestione avance
|
|
1801
|
+
getMetaData: true,
|
|
1802
|
+
onLoadedEvent: () => {
|
|
1803
|
+
emit("popup_clicked", surveyId, data);
|
|
1804
|
+
},
|
|
1805
|
+
onFinishEvent: () => {
|
|
1806
|
+
if (!surveyCompletedEmitted) {
|
|
1807
|
+
emit("survey_completed", surveyId, data);
|
|
1808
|
+
surveyCompletedEmitted = true;
|
|
1809
|
+
}
|
|
1810
|
+
onClose();
|
|
1811
|
+
},
|
|
1812
|
+
afterSubmitEvent: ({ progress: _progress, total: _total }) => {
|
|
1813
|
+
}
|
|
1814
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1815
|
+
}).catch((err) => {
|
|
1816
|
+
console.error("[MagicFeedback] Error generating form:", err);
|
|
1817
|
+
});
|
|
1818
|
+
} catch (e) {
|
|
1819
|
+
console.error("[MagicFeedback] Exception initializing form:", e);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
// src/triggers/index.ts
|
|
1824
|
+
function setupTrigger(popups, trigger) {
|
|
1825
|
+
switch (trigger.type) {
|
|
1826
|
+
case "time":
|
|
1827
|
+
setupTimeTrigger(popups, trigger);
|
|
1828
|
+
break;
|
|
1829
|
+
case "scroll":
|
|
1830
|
+
setupScrollTrigger(popups, trigger);
|
|
1831
|
+
break;
|
|
1832
|
+
case "exit":
|
|
1833
|
+
setupExitTrigger(popups, trigger);
|
|
1834
|
+
break;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
function setupTimeTrigger(popups, trigger) {
|
|
1838
|
+
const delay = trigger.value || 5e3;
|
|
1839
|
+
setTimeout(() => {
|
|
1840
|
+
popups.triggerSurvey(trigger.surveyId);
|
|
1841
|
+
}, delay);
|
|
1842
|
+
popups.debug(`Time trigger set for ${delay}ms`);
|
|
1843
|
+
}
|
|
1844
|
+
function setupScrollTrigger(popups, trigger) {
|
|
1845
|
+
const threshold = trigger.value || 50;
|
|
1846
|
+
const handler = () => {
|
|
1847
|
+
const scrollPercentage = window.scrollY / (document.documentElement.scrollHeight - window.innerHeight) * 100;
|
|
1848
|
+
if (scrollPercentage >= threshold) {
|
|
1849
|
+
popups.triggerSurvey(trigger.surveyId);
|
|
1850
|
+
window.removeEventListener("scroll", handler);
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
window.addEventListener("scroll", handler);
|
|
1854
|
+
popups.debug(`Scroll trigger set for ${threshold}%`);
|
|
1855
|
+
}
|
|
1856
|
+
function setupExitTrigger(popups, trigger) {
|
|
1857
|
+
const handler = (e) => {
|
|
1858
|
+
if (e.clientY <= 0) {
|
|
1859
|
+
popups.triggerSurvey(trigger.surveyId);
|
|
1860
|
+
document.removeEventListener("mouseout", handler);
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
document.addEventListener("mouseout", handler);
|
|
1864
|
+
popups.debug("Exit intent trigger set");
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
// src/config/env.ts
|
|
1868
|
+
var ENVIRONMENT_MAP = {
|
|
1869
|
+
development: {
|
|
1870
|
+
apiBaseUrl: "https://api-dev.magicfeedback.com"
|
|
1871
|
+
},
|
|
1872
|
+
production: {
|
|
1873
|
+
apiBaseUrl: "https://api.magicfeedback.com"
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
function resolveEnvironment(nodeEnv) {
|
|
1877
|
+
return ENVIRONMENT_MAP[nodeEnv || "production"];
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// src/platform/react-native-renderer.ts
|
|
1881
|
+
var ReactNativePopupRenderer = class {
|
|
1882
|
+
constructor() {
|
|
1883
|
+
this.mounted = false;
|
|
1884
|
+
this.lastSurveyId = null;
|
|
1885
|
+
this.emitFn = null;
|
|
1886
|
+
this.onCloseFn = null;
|
|
1887
|
+
this.completed = false;
|
|
1888
|
+
}
|
|
1889
|
+
init() {
|
|
1890
|
+
}
|
|
1891
|
+
show(surveyId, productId, data, emit, onClose) {
|
|
1892
|
+
this.mounted = true;
|
|
1893
|
+
this.lastSurveyId = surveyId;
|
|
1894
|
+
this.emitFn = emit;
|
|
1895
|
+
this.onCloseFn = onClose;
|
|
1896
|
+
this.completed = false;
|
|
1897
|
+
queueMicrotask(() => emit("popup_clicked", surveyId, data));
|
|
1898
|
+
console.log("[ReactNativePopupRenderer] (stub) show survey:", { surveyId, productId, data });
|
|
1899
|
+
}
|
|
1900
|
+
/** Completar la encuesta desde la capa nativa */
|
|
1901
|
+
completeSurvey(data) {
|
|
1902
|
+
if (!this.mounted || this.completed || !this.lastSurveyId || !this.emitFn) return;
|
|
1903
|
+
this.completed = true;
|
|
1904
|
+
this.emitFn("survey_completed", this.lastSurveyId, data);
|
|
1905
|
+
this.onCloseFn?.();
|
|
1906
|
+
this.mounted = false;
|
|
1907
|
+
console.log("[ReactNativePopupRenderer] (stub) survey completed:", { surveyId: this.lastSurveyId, data });
|
|
1908
|
+
this.lastSurveyId = null;
|
|
1909
|
+
}
|
|
1910
|
+
hide() {
|
|
1911
|
+
if (!this.mounted) return;
|
|
1912
|
+
this.mounted = false;
|
|
1913
|
+
console.log("[ReactNativePopupRenderer] (stub) hide survey:", this.lastSurveyId);
|
|
1914
|
+
this.lastSurveyId = null;
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
function isReactNativeEnv() {
|
|
1918
|
+
return typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
1919
|
+
}
|
|
1920
|
+
function createReactNativeRenderer() {
|
|
1921
|
+
return new ReactNativePopupRenderer();
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
// src/platform/renderer.ts
|
|
1925
|
+
var NoopPopupRenderer = class {
|
|
1926
|
+
show() {
|
|
1927
|
+
}
|
|
1928
|
+
hide() {
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
var BrowserPopupRenderer = class {
|
|
1932
|
+
constructor() {
|
|
1933
|
+
this.container = null;
|
|
1934
|
+
}
|
|
1935
|
+
init() {
|
|
1936
|
+
if (typeof document === "undefined") return;
|
|
1937
|
+
if (!this.container) {
|
|
1938
|
+
this.container = document.createElement("div");
|
|
1939
|
+
this.container.id = "deepdots-popup-container";
|
|
1940
|
+
this.container.style.cssText = `
|
|
1941
|
+
position: fixed;
|
|
1942
|
+
top: 0;
|
|
1943
|
+
left: 0;
|
|
1944
|
+
width: 100%;
|
|
1945
|
+
height: 100%;
|
|
1946
|
+
display: none;
|
|
1947
|
+
z-index: 999999;
|
|
1948
|
+
background: rgba(0, 0, 0, 0.5);
|
|
1949
|
+
justify-content: center;
|
|
1950
|
+
align-items: center;
|
|
1951
|
+
`;
|
|
1952
|
+
document.body.appendChild(this.container);
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
show(surveyId, productId, data, emit, onClose) {
|
|
1956
|
+
if (!this.container) this.init();
|
|
1957
|
+
if (!this.container) return;
|
|
1958
|
+
renderPopup(this.container, surveyId, productId, data, emit, onClose);
|
|
1959
|
+
}
|
|
1960
|
+
hide() {
|
|
1961
|
+
if (this.container) {
|
|
1962
|
+
this.container.style.display = "none";
|
|
1963
|
+
this.container.innerHTML = "";
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1967
|
+
function createDefaultRenderer() {
|
|
1968
|
+
if (typeof document === "undefined") {
|
|
1969
|
+
if (isReactNativeEnv()) return createReactNativeRenderer();
|
|
1970
|
+
return new NoopPopupRenderer();
|
|
1971
|
+
}
|
|
1972
|
+
if (isReactNativeEnv()) return createReactNativeRenderer();
|
|
1973
|
+
return new BrowserPopupRenderer();
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// src/core/deepdots-popups.ts
|
|
1977
|
+
var DeepdotsPopups = class {
|
|
1978
|
+
constructor() {
|
|
1979
|
+
this.config = null;
|
|
1980
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
1981
|
+
this.triggers = [];
|
|
1982
|
+
this.initialized = false;
|
|
1983
|
+
this.renderer = createDefaultRenderer();
|
|
1984
|
+
this.popupContainer = null;
|
|
1985
|
+
// deprecated: mantenido para compatibilidad interna
|
|
1986
|
+
this.popupDefinitions = [];
|
|
1987
|
+
this.popupsLoaded = false;
|
|
1988
|
+
this.pendingAutoLaunch = false;
|
|
1989
|
+
this.answeredSurveys = /* @__PURE__ */ new Set();
|
|
1990
|
+
this.lastShown = /* @__PURE__ */ new Map();
|
|
1991
|
+
}
|
|
1992
|
+
// popupId -> timestamp mostrado
|
|
1993
|
+
/** Initialize the SDK with configuration */
|
|
1994
|
+
init(config) {
|
|
1995
|
+
if (this.initialized) {
|
|
1996
|
+
this.log("SDK already initialized");
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
const env = resolveEnvironment(config.nodeEnv);
|
|
2000
|
+
this.config = {
|
|
2001
|
+
apiKey: config.apiKey || void 0,
|
|
2002
|
+
baseUrl: env.apiBaseUrl,
|
|
2003
|
+
mode: config.mode || "client",
|
|
2004
|
+
debug: config.debug || false,
|
|
2005
|
+
popups: config.popups || []
|
|
2006
|
+
};
|
|
2007
|
+
this.initialized = true;
|
|
2008
|
+
this.log("SDK initialized", this.config);
|
|
2009
|
+
if (this.renderer.init) this.renderer.init();
|
|
2010
|
+
this.setupPopupContainer();
|
|
2011
|
+
if (this.config.mode === "client") {
|
|
2012
|
+
this.popupDefinitions = this.config.popups || [];
|
|
2013
|
+
this.popupsLoaded = true;
|
|
2014
|
+
this.configureTriggersFromDefinitions();
|
|
2015
|
+
} else {
|
|
2016
|
+
this.fetchPopupsFromServer().then((defs) => {
|
|
2017
|
+
this.popupDefinitions = defs;
|
|
2018
|
+
this.popupsLoaded = true;
|
|
2019
|
+
this.log("Popups loaded from server (fake)", defs);
|
|
2020
|
+
this.configureTriggersFromDefinitions();
|
|
2021
|
+
if (this.pendingAutoLaunch) {
|
|
2022
|
+
this.startTriggers();
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
/** Enable auto-launch functionality with configured triggers */
|
|
2028
|
+
autoLaunch() {
|
|
2029
|
+
if (!this.initialized) {
|
|
2030
|
+
throw new Error("SDK not initialized. Call init() first.");
|
|
2031
|
+
}
|
|
2032
|
+
if (!this.popupsLoaded) {
|
|
2033
|
+
this.pendingAutoLaunch = true;
|
|
2034
|
+
this.log("Auto-launch deferred until popups are loaded");
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
this.startTriggers();
|
|
2038
|
+
}
|
|
2039
|
+
/** Inicia los triggers configurados */
|
|
2040
|
+
startTriggers() {
|
|
2041
|
+
this.log("Auto-launch enabled");
|
|
2042
|
+
this.triggers.forEach((trigger) => setupTrigger(this, trigger));
|
|
2043
|
+
}
|
|
2044
|
+
/** Show a popup immediately (by surveyId) */
|
|
2045
|
+
show(options) {
|
|
2046
|
+
console.log("Show popup called with options:", options);
|
|
2047
|
+
if (!this.initialized) {
|
|
2048
|
+
throw new Error("SDK not initialized. Call init() first.");
|
|
2049
|
+
}
|
|
2050
|
+
this.log("Showing popup", options);
|
|
2051
|
+
this.renderPopup(options.surveyId, options.productId, options.data);
|
|
2052
|
+
this.emitEvent("popup_shown", options.surveyId, options.data);
|
|
2053
|
+
}
|
|
2054
|
+
/** Mostrar popup por id de definición (usa surveyId interno) */
|
|
2055
|
+
showByPopupId(popupId) {
|
|
2056
|
+
const def = this.popupDefinitions.find((p) => p.id === popupId);
|
|
2057
|
+
if (!def) {
|
|
2058
|
+
this.log("Popup definition not found", popupId);
|
|
2059
|
+
return;
|
|
2060
|
+
}
|
|
2061
|
+
this.show({ surveyId: def.surveyId, productId: def.productId });
|
|
2062
|
+
}
|
|
2063
|
+
/** Configure triggers for auto-launching popups (manual) */
|
|
2064
|
+
configureTriggers(triggers) {
|
|
2065
|
+
if (!this.initialized) {
|
|
2066
|
+
throw new Error("SDK not initialized. Call init() first.");
|
|
2067
|
+
}
|
|
2068
|
+
this.triggers = triggers;
|
|
2069
|
+
this.log("Triggers configured", triggers);
|
|
2070
|
+
}
|
|
2071
|
+
/** Deriva triggers desde las definiciones de popup */
|
|
2072
|
+
configureTriggersFromDefinitions() {
|
|
2073
|
+
const derived = [];
|
|
2074
|
+
const validDefs = this.validatePopupDefinitions(this.popupDefinitions);
|
|
2075
|
+
validDefs.forEach((def) => {
|
|
2076
|
+
if (!def.trigger) return;
|
|
2077
|
+
const t = def.trigger;
|
|
2078
|
+
let type;
|
|
2079
|
+
switch (t.type) {
|
|
2080
|
+
case "time_on_page":
|
|
2081
|
+
type = "time";
|
|
2082
|
+
break;
|
|
2083
|
+
case "scroll":
|
|
2084
|
+
type = "scroll";
|
|
2085
|
+
break;
|
|
2086
|
+
case "exit":
|
|
2087
|
+
type = "exit";
|
|
2088
|
+
break;
|
|
2089
|
+
default:
|
|
2090
|
+
this.debug("Unsupported trigger type", t.type);
|
|
2091
|
+
return;
|
|
2092
|
+
}
|
|
2093
|
+
const value = type === "time" ? t.value * 1e3 : t.value;
|
|
2094
|
+
derived.push({ type, value, surveyId: def.surveyId });
|
|
2095
|
+
});
|
|
2096
|
+
if (derived.length) {
|
|
2097
|
+
this.configureTriggers(derived);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
/** Lógica para evaluar condiciones antes de mostrar una encuesta */
|
|
2101
|
+
triggerSurvey(surveyId) {
|
|
2102
|
+
const def = this.popupDefinitions.find((p) => p.surveyId === surveyId);
|
|
2103
|
+
if (!def) {
|
|
2104
|
+
this.debug("No popup definition for surveyId", surveyId);
|
|
2105
|
+
return;
|
|
2106
|
+
}
|
|
2107
|
+
if (!this.shouldShow(def)) {
|
|
2108
|
+
this.debug("Conditions prevented showing popup", def.id);
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
this.show({ surveyId: def.surveyId, productId: def.productId });
|
|
2112
|
+
this.lastShown.set(def.id, Date.now());
|
|
2113
|
+
}
|
|
2114
|
+
shouldShow(def) {
|
|
2115
|
+
const conditions = def.trigger.condition || [];
|
|
2116
|
+
if (!conditions.length) return true;
|
|
2117
|
+
return conditions.every((c) => this.evaluateCondition(def, c));
|
|
2118
|
+
}
|
|
2119
|
+
evaluateCondition(def, condition) {
|
|
2120
|
+
if (condition.answered === false && this.answeredSurveys.has(def.surveyId)) {
|
|
2121
|
+
return false;
|
|
2122
|
+
}
|
|
2123
|
+
if (condition.cooldownDays) {
|
|
2124
|
+
const last = this.lastShown.get(def.id);
|
|
2125
|
+
if (last) {
|
|
2126
|
+
const msSince = Date.now() - last;
|
|
2127
|
+
const required = condition.cooldownDays * 24 * 60 * 60 * 1e3;
|
|
2128
|
+
if (msSince < required) return false;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
return true;
|
|
2132
|
+
}
|
|
2133
|
+
/** Marcar encuesta como contestada externamente */
|
|
2134
|
+
markSurveyAnswered(surveyId) {
|
|
2135
|
+
this.answeredSurveys.add(surveyId);
|
|
2136
|
+
}
|
|
2137
|
+
/** Simula fetch al servidor para obtener popups */
|
|
2138
|
+
async fetchPopupsFromServer() {
|
|
2139
|
+
await new Promise((res) => setTimeout(res, 50));
|
|
2140
|
+
return this.generateFakePopups();
|
|
2141
|
+
}
|
|
2142
|
+
/** Genera datos fake para pruebas en modo server */
|
|
2143
|
+
generateFakePopups() {
|
|
2144
|
+
return [
|
|
2145
|
+
{
|
|
2146
|
+
id: "popup-123",
|
|
2147
|
+
title: "Would you like to help us improve?",
|
|
2148
|
+
message: "<p>Take a quick survey and share your thoughts.</p>",
|
|
2149
|
+
trigger: { type: "time_on_page", value: 1, condition: [{ answered: false, cooldownDays: 7 }] },
|
|
2150
|
+
actions: {
|
|
2151
|
+
accept: { label: "Take Survey", surveyId: "survey-abc" },
|
|
2152
|
+
decline: { label: "Not Now", cooldownDays: 7 }
|
|
2153
|
+
},
|
|
2154
|
+
surveyId: "survey-abc",
|
|
2155
|
+
productId: "product-xyz",
|
|
2156
|
+
style: { theme: "light", position: "bottom-right", imageUrl: null },
|
|
2157
|
+
segments: { lang: ["en"], path: ["/checkout"] }
|
|
2158
|
+
}
|
|
2159
|
+
];
|
|
2160
|
+
}
|
|
2161
|
+
/** Add an event listener */
|
|
2162
|
+
on(eventType, listener) {
|
|
2163
|
+
if (!this.listeners.has(eventType)) {
|
|
2164
|
+
this.listeners.set(eventType, /* @__PURE__ */ new Set());
|
|
2165
|
+
}
|
|
2166
|
+
this.listeners.get(eventType).add(listener);
|
|
2167
|
+
}
|
|
2168
|
+
/** Remove an event listener */
|
|
2169
|
+
off(eventType, listener) {
|
|
2170
|
+
const listeners = this.listeners.get(eventType);
|
|
2171
|
+
if (listeners) {
|
|
2172
|
+
listeners.delete(listener);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
/** Setup popup container element */
|
|
2176
|
+
setupPopupContainer() {
|
|
2177
|
+
if (typeof document === "undefined") {
|
|
2178
|
+
return;
|
|
2179
|
+
}
|
|
2180
|
+
this.popupContainer = document.createElement("div");
|
|
2181
|
+
this.popupContainer.id = "deepdots-popup-container";
|
|
2182
|
+
this.popupContainer.style.cssText = `
|
|
2183
|
+
position: fixed;
|
|
2184
|
+
top: 0;
|
|
2185
|
+
left: 0;
|
|
2186
|
+
width: 100%;
|
|
2187
|
+
height: 100%;
|
|
2188
|
+
display: none;
|
|
2189
|
+
z-index: 999999;
|
|
2190
|
+
background: rgba(0, 0, 0, 0.5);
|
|
2191
|
+
justify-content: center;
|
|
2192
|
+
align-items: center;
|
|
2193
|
+
`;
|
|
2194
|
+
document.body.appendChild(this.popupContainer);
|
|
2195
|
+
}
|
|
2196
|
+
/** Render the popup UI */
|
|
2197
|
+
renderPopup(surveyId, productId, data) {
|
|
2198
|
+
if (this.renderer) {
|
|
2199
|
+
this.renderer.show(surveyId, productId, data, (type, id, payload) => this.emitEvent(type, id, payload), () => this.hidePopup());
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2202
|
+
if (!this.popupContainer) return;
|
|
2203
|
+
renderPopup(this.popupContainer, surveyId, productId, data, (type, id, payload) => this.emitEvent(type, id, payload), () => this.hidePopup());
|
|
2204
|
+
}
|
|
2205
|
+
/** Hide the popup */
|
|
2206
|
+
hidePopup() {
|
|
2207
|
+
if (this.renderer) {
|
|
2208
|
+
this.renderer.hide();
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
if (this.popupContainer) {
|
|
2212
|
+
this.popupContainer.style.display = "none";
|
|
2213
|
+
this.popupContainer.innerHTML = "";
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
/** Emit an event */
|
|
2217
|
+
emitEvent(type, surveyId, data) {
|
|
2218
|
+
const event = { type, surveyId, timestamp: Date.now(), data };
|
|
2219
|
+
this.log("Event emitted", event);
|
|
2220
|
+
if (type === "survey_completed") {
|
|
2221
|
+
this.markSurveyAnswered(surveyId);
|
|
2222
|
+
}
|
|
2223
|
+
const listeners = this.listeners.get(type);
|
|
2224
|
+
if (listeners) {
|
|
2225
|
+
listeners.forEach((listener) => {
|
|
2226
|
+
try {
|
|
2227
|
+
listener(event);
|
|
2228
|
+
} catch (error) {
|
|
2229
|
+
console.error("Error in event listener:", error);
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
/** Log debug messages */
|
|
2235
|
+
log(...args) {
|
|
2236
|
+
if (this.config?.debug) {
|
|
2237
|
+
console.log("[DeepdotsPopups]", ...args);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
/** External debug method for triggers */
|
|
2241
|
+
debug(...args) {
|
|
2242
|
+
this.log(...args);
|
|
2243
|
+
}
|
|
2244
|
+
/** Set a custom renderer */
|
|
2245
|
+
setRenderer(renderer) {
|
|
2246
|
+
this.renderer = renderer;
|
|
2247
|
+
if (this.initialized && this.renderer.init) {
|
|
2248
|
+
this.renderer.init();
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
// Type guards
|
|
2252
|
+
isPopupDefinition(value) {
|
|
2253
|
+
if (typeof value !== "object" || value === null) return false;
|
|
2254
|
+
const v = value;
|
|
2255
|
+
return typeof v.id === "string" && typeof v.title === "string" && typeof v.message === "string" && typeof v.surveyId === "string" && typeof v.productId === "string" && !!v.trigger && typeof v.trigger.type === "string";
|
|
2256
|
+
}
|
|
2257
|
+
validatePopupDefinitions(defs) {
|
|
2258
|
+
return defs.filter((d) => this.isPopupDefinition(d));
|
|
2259
|
+
}
|
|
2260
|
+
};
|
|
2261
|
+
//# sourceMappingURL=index.js.map
|