@olenbetong/appframe-core 2.11.0 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/af.common.js +123 -143
- package/dist/esm/af.common.legacy.js +129 -149
- package/dist/esm/af.common.legacy.min.js +1 -1
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +2 -2
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +123 -143
- package/dist/iife/af.common.legacy.js +129 -149
- package/dist/iife/af.common.legacy.min.js +1 -1
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +2 -2
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/SessionHandler.js +1 -3
- package/es/UserSession.js +33 -29
- package/es/date.js +3 -3
- package/es/date.test.d.ts +1 -0
- package/es/date.test.js +23 -0
- package/es/errorHandler.d.ts +1 -0
- package/es/errorHandler.js +5 -21
- package/es/expose.d.ts +1 -1
- package/es/expose.js +1 -2
- package/es/expose.test.d.ts +10 -0
- package/es/expose.test.js +36 -0
- package/es/getLocalizedString.js +1 -2
- package/es/getUserImage.test.d.ts +1 -0
- package/es/getUserImage.test.js +30 -0
- package/es/index.d.ts +0 -1
- package/es/index.js +1 -2
- package/es/invariant.d.ts +8 -0
- package/es/invariant.js +8 -0
- package/es/invariant.test.d.ts +1 -0
- package/es/invariant.test.js +19 -0
- package/es/localStorage.js +1 -3
- package/es/parseFunc.js +1 -1
- package/es/parseFunc.test.d.ts +1 -0
- package/es/parseFunc.test.js +14 -0
- package/package.json +5 -3
- package/src/date.test.ts +27 -0
- package/src/date.ts +3 -3
- package/src/errorHandler.ts +6 -21
- package/src/expose.test.ts +59 -0
- package/src/expose.ts +2 -3
- package/src/getLocalizedString.ts +1 -3
- package/src/getUserImage.test.ts +50 -0
- package/src/index.ts +0 -1
- package/src/invariant.test.ts +23 -0
- package/src/invariant.ts +8 -0
- package/src/parseFunc.test.ts +17 -0
- package/src/parseFunc.ts +1 -1
- package/es/has.d.ts +0 -1
- package/es/has.js +0 -3
- package/src/has.ts +0 -3
|
@@ -54,7 +54,6 @@ af.common = (() => {
|
|
|
54
54
|
getSessionData: () => getSessionData,
|
|
55
55
|
getSettings: () => getSettings,
|
|
56
56
|
getUserImage: () => getUserImage,
|
|
57
|
-
has: () => has,
|
|
58
57
|
invariant: () => invariant,
|
|
59
58
|
localStorage: () => localStorage_default,
|
|
60
59
|
localize: () => localize,
|
|
@@ -186,29 +185,131 @@ af.common = (() => {
|
|
|
186
185
|
}
|
|
187
186
|
};
|
|
188
187
|
|
|
188
|
+
// src/log.ts
|
|
189
|
+
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
190
|
+
var _a2;
|
|
191
|
+
try {
|
|
192
|
+
let response = await fetch("/api/logging/log-activity", {
|
|
193
|
+
method: "POST",
|
|
194
|
+
body: JSON.stringify({
|
|
195
|
+
article: af.article.id,
|
|
196
|
+
timeElapsed,
|
|
197
|
+
action: activity,
|
|
198
|
+
parameters: __spreadProps(__spreadValues({}, parameters), {
|
|
199
|
+
_session: getSessionData()
|
|
200
|
+
})
|
|
201
|
+
}),
|
|
202
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
203
|
+
});
|
|
204
|
+
if (!response.ok) {
|
|
205
|
+
if ((_a2 = response.headers.get("Content-Type")) == null ? void 0 : _a2.includes("application/json")) {
|
|
206
|
+
let data = await response.json();
|
|
207
|
+
console.error(data.error);
|
|
208
|
+
} else {
|
|
209
|
+
console.error("".concat(response.status, " ").concat(response.statusText));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
} catch (error) {
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function startActivity(activity, startParameters = {}) {
|
|
216
|
+
let start = performance.now();
|
|
217
|
+
return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
|
|
218
|
+
}
|
|
219
|
+
async function time(callback) {
|
|
220
|
+
let start = performance.now();
|
|
221
|
+
let returnValue = await callback();
|
|
222
|
+
return [returnValue, performance.now() - start];
|
|
223
|
+
}
|
|
224
|
+
async function logError(error) {
|
|
225
|
+
var _a2;
|
|
226
|
+
try {
|
|
227
|
+
if (!error)
|
|
228
|
+
return;
|
|
229
|
+
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
230
|
+
error: error.message,
|
|
231
|
+
stack: (_a2 = error.stack) != null ? _a2 : null
|
|
232
|
+
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
233
|
+
console.error(error);
|
|
234
|
+
let result = await fetch("/data/Logger/LogError", {
|
|
235
|
+
method: "POST",
|
|
236
|
+
body: JSON.stringify(data),
|
|
237
|
+
headers: {
|
|
238
|
+
"Content-Type": "application/json; charset=utf-8"
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
if (result.ok) {
|
|
242
|
+
return await result.json();
|
|
243
|
+
}
|
|
244
|
+
console.error(Error("Failed to log error"));
|
|
245
|
+
} catch (e) {
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function getSessionId() {
|
|
249
|
+
var _a2;
|
|
250
|
+
return (_a2 = crypto.randomUUID) == null ? void 0 : _a2.call(crypto);
|
|
251
|
+
}
|
|
252
|
+
var sessionStart = Date.now();
|
|
253
|
+
var sessionId = getSessionId();
|
|
254
|
+
var deviceId = "";
|
|
255
|
+
var browserSessionId = "";
|
|
256
|
+
if ("document" in window) {
|
|
257
|
+
let startSession = () => {
|
|
258
|
+
var _a2;
|
|
259
|
+
return logActivity("AfSessionInit", {
|
|
260
|
+
"appframe-core": af.common.version,
|
|
261
|
+
"appframe-data": (_a2 = af.data) == null ? void 0 : _a2.version,
|
|
262
|
+
"app-version": af.article.version
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
266
|
+
deviceId = localStorage.getItem("_afDeviceId");
|
|
267
|
+
browserSessionId = sessionStorage.getItem("_afSessionId");
|
|
268
|
+
if (!deviceId) {
|
|
269
|
+
deviceId = getSessionId();
|
|
270
|
+
localStorage.setItem("_afDeviceId", deviceId);
|
|
271
|
+
}
|
|
272
|
+
if (!browserSessionId) {
|
|
273
|
+
browserSessionId = sessionId;
|
|
274
|
+
sessionStorage.setItem("_afSessionId", browserSessionId);
|
|
275
|
+
}
|
|
276
|
+
startSession();
|
|
277
|
+
});
|
|
278
|
+
document.addEventListener("visibilitychange", function logData() {
|
|
279
|
+
if (document.visibilityState === "hidden") {
|
|
280
|
+
navigator.sendBeacon(
|
|
281
|
+
"/api/logging/log-activity",
|
|
282
|
+
JSON.stringify({
|
|
283
|
+
article: af.article.id,
|
|
284
|
+
action: "AfSessionEnd",
|
|
285
|
+
parameters: {
|
|
286
|
+
_session: getSessionData()
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
);
|
|
290
|
+
} else {
|
|
291
|
+
startSession();
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
function getSessionData() {
|
|
296
|
+
return {
|
|
297
|
+
browserSessionId,
|
|
298
|
+
sessionStart,
|
|
299
|
+
sessionLength: Date.now() - sessionStart,
|
|
300
|
+
sessionId,
|
|
301
|
+
deviceId
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
189
305
|
// src/errorHandler.ts
|
|
190
306
|
var _a;
|
|
191
307
|
if (true) {
|
|
192
308
|
(_a = window.window) == null ? void 0 : _a.addEventListener("error", (event) => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
file: event.filename,
|
|
198
|
-
line: (_d = event.lineno) != null ? _d : 0,
|
|
199
|
-
column: (_e = event.colno) != null ? _e : 0,
|
|
200
|
-
stack: (_g = (_f = event.error) == null ? void 0 : _f.stack) != null ? _g : null
|
|
201
|
-
};
|
|
202
|
-
fetch("/data/Logger/LogError", {
|
|
203
|
-
body: JSON.stringify(data),
|
|
204
|
-
headers: {
|
|
205
|
-
Accept: "application/json",
|
|
206
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
207
|
-
"X-Requested-With": "XMLHttpRequest"
|
|
208
|
-
},
|
|
209
|
-
method: "POST"
|
|
210
|
-
});
|
|
211
|
-
} catch (ex) {
|
|
309
|
+
if (typeof event === "object" && "error" in event) {
|
|
310
|
+
logError(event.error);
|
|
311
|
+
} else if (typeof event === "object" && "message" in event) {
|
|
312
|
+
logError(event);
|
|
212
313
|
}
|
|
213
314
|
});
|
|
214
315
|
}
|
|
@@ -257,13 +358,13 @@ af.common = (() => {
|
|
|
257
358
|
function toLocalISODate(date) {
|
|
258
359
|
return date ? toLocalISODateTime(date).substring(0, 10) : null;
|
|
259
360
|
}
|
|
260
|
-
function pad(num) {
|
|
261
|
-
return String(num).padStart(
|
|
361
|
+
function pad(num, digits = 2) {
|
|
362
|
+
return String(num).padStart(digits, "0");
|
|
262
363
|
}
|
|
263
364
|
function toLocalISODateTime(date) {
|
|
264
365
|
return date ? "".concat(date.getFullYear(), "-").concat(pad(date.getMonth() + 1), "-").concat(pad(date.getDate()), "T").concat(pad(date.getHours()), ":").concat(pad(
|
|
265
366
|
date.getMinutes()
|
|
266
|
-
), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds())) : null;
|
|
367
|
+
), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds(), 3)) : null;
|
|
267
368
|
}
|
|
268
369
|
function toLocalDateTime(date) {
|
|
269
370
|
return date ? date.toISOString().substring(0, 16) : "";
|
|
@@ -349,17 +450,13 @@ af.common = (() => {
|
|
|
349
450
|
}
|
|
350
451
|
}
|
|
351
452
|
|
|
352
|
-
// src/has.ts
|
|
353
|
-
function has(obj, key) {
|
|
354
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
453
|
// src/parseFunc.ts
|
|
358
454
|
var funcRegex = /^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;
|
|
359
455
|
function parseFunc(func) {
|
|
456
|
+
var _a2;
|
|
360
457
|
var match = func.toString().match(funcRegex);
|
|
361
458
|
invariant(match, "Unable to parse function!");
|
|
362
|
-
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
459
|
+
return { name: (_a2 = func.name) != null ? _a2 : match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
|
|
363
460
|
}
|
|
364
461
|
|
|
365
462
|
// src/Namespace.ts
|
|
@@ -413,7 +510,7 @@ af.common = (() => {
|
|
|
413
510
|
} else {
|
|
414
511
|
invariant(false, "Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
415
512
|
}
|
|
416
|
-
if (
|
|
513
|
+
if (Object.hasOwn(namespace, keyName) && (options == null ? void 0 : options.overwrite) !== true) {
|
|
417
514
|
console.warn([name, keyName].join(".") + " is already defined!");
|
|
418
515
|
} else {
|
|
419
516
|
namespace[keyName] = value;
|
|
@@ -468,7 +565,7 @@ af.common = (() => {
|
|
|
468
565
|
return;
|
|
469
566
|
}
|
|
470
567
|
if (((_b = (_a2 = window.af) == null ? void 0 : _a2.article) == null ? void 0 : _b.i18n) !== void 0) {
|
|
471
|
-
if (!
|
|
568
|
+
if (!Object.hasOwn(af.article.i18n, string)) {
|
|
472
569
|
af.article.i18n[string] = string;
|
|
473
570
|
let promise = fetchLocalizedString(string).then((text) => {
|
|
474
571
|
af.article.i18n[string] = text;
|
|
@@ -498,123 +595,6 @@ af.common = (() => {
|
|
|
498
595
|
return localized;
|
|
499
596
|
}
|
|
500
597
|
|
|
501
|
-
// src/log.ts
|
|
502
|
-
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
503
|
-
var _a2;
|
|
504
|
-
try {
|
|
505
|
-
let response = await fetch("/api/logging/log-activity", {
|
|
506
|
-
method: "POST",
|
|
507
|
-
body: JSON.stringify({
|
|
508
|
-
article: af.article.id,
|
|
509
|
-
timeElapsed,
|
|
510
|
-
action: activity,
|
|
511
|
-
parameters: __spreadProps(__spreadValues({}, parameters), {
|
|
512
|
-
_session: getSessionData()
|
|
513
|
-
})
|
|
514
|
-
}),
|
|
515
|
-
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
516
|
-
});
|
|
517
|
-
if (!response.ok) {
|
|
518
|
-
if ((_a2 = response.headers.get("Content-Type")) == null ? void 0 : _a2.includes("application/json")) {
|
|
519
|
-
let data = await response.json();
|
|
520
|
-
console.error(data.error);
|
|
521
|
-
} else {
|
|
522
|
-
console.error("".concat(response.status, " ").concat(response.statusText));
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
} catch (error) {
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
function startActivity(activity, startParameters = {}) {
|
|
529
|
-
let start = performance.now();
|
|
530
|
-
return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
|
|
531
|
-
}
|
|
532
|
-
async function time(callback) {
|
|
533
|
-
let start = performance.now();
|
|
534
|
-
let returnValue = await callback();
|
|
535
|
-
return [returnValue, performance.now() - start];
|
|
536
|
-
}
|
|
537
|
-
async function logError(error) {
|
|
538
|
-
var _a2;
|
|
539
|
-
try {
|
|
540
|
-
if (!error)
|
|
541
|
-
return;
|
|
542
|
-
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
543
|
-
error: error.message,
|
|
544
|
-
stack: (_a2 = error.stack) != null ? _a2 : null
|
|
545
|
-
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
546
|
-
console.error(error);
|
|
547
|
-
let result = await fetch("/data/Logger/LogError", {
|
|
548
|
-
method: "POST",
|
|
549
|
-
body: JSON.stringify(data),
|
|
550
|
-
headers: {
|
|
551
|
-
"Content-Type": "application/json; charset=utf-8"
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
if (result.ok) {
|
|
555
|
-
return await result.json();
|
|
556
|
-
}
|
|
557
|
-
console.error(Error("Failed to log error"));
|
|
558
|
-
} catch (e) {
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
function getSessionId() {
|
|
562
|
-
var _a2;
|
|
563
|
-
return (_a2 = crypto.randomUUID) == null ? void 0 : _a2.call(crypto);
|
|
564
|
-
}
|
|
565
|
-
var sessionStart = Date.now();
|
|
566
|
-
var sessionId = getSessionId();
|
|
567
|
-
var deviceId = "";
|
|
568
|
-
var browserSessionId = "";
|
|
569
|
-
if ("document" in window) {
|
|
570
|
-
let startSession = () => {
|
|
571
|
-
var _a2;
|
|
572
|
-
return logActivity("AfSessionInit", {
|
|
573
|
-
"appframe-core": af.common.version,
|
|
574
|
-
"appframe-data": (_a2 = af.data) == null ? void 0 : _a2.version,
|
|
575
|
-
"app-version": af.article.version
|
|
576
|
-
});
|
|
577
|
-
};
|
|
578
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
579
|
-
deviceId = localStorage.getItem("_afDeviceId");
|
|
580
|
-
browserSessionId = sessionStorage.getItem("_afSessionId");
|
|
581
|
-
if (!deviceId) {
|
|
582
|
-
deviceId = getSessionId();
|
|
583
|
-
localStorage.setItem("_afDeviceId", deviceId);
|
|
584
|
-
}
|
|
585
|
-
if (!browserSessionId) {
|
|
586
|
-
browserSessionId = sessionId;
|
|
587
|
-
sessionStorage.setItem("_afSessionId", browserSessionId);
|
|
588
|
-
}
|
|
589
|
-
startSession();
|
|
590
|
-
});
|
|
591
|
-
document.addEventListener("visibilitychange", function logData() {
|
|
592
|
-
if (document.visibilityState === "hidden") {
|
|
593
|
-
navigator.sendBeacon(
|
|
594
|
-
"/api/logging/log-activity",
|
|
595
|
-
JSON.stringify({
|
|
596
|
-
article: af.article.id,
|
|
597
|
-
action: "AfSessionEnd",
|
|
598
|
-
parameters: {
|
|
599
|
-
_session: getSessionData()
|
|
600
|
-
}
|
|
601
|
-
})
|
|
602
|
-
);
|
|
603
|
-
} else {
|
|
604
|
-
startSession();
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
function getSessionData() {
|
|
609
|
-
return {
|
|
610
|
-
browserSessionId,
|
|
611
|
-
sessionStart,
|
|
612
|
-
sessionLength: Date.now() - sessionStart,
|
|
613
|
-
sessionId,
|
|
614
|
-
deviceId
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
|
|
618
598
|
// src/settings.ts
|
|
619
599
|
function getKey(article) {
|
|
620
600
|
const articleKey = article || af.article.id;
|
|
@@ -747,6 +727,6 @@ af.common = (() => {
|
|
|
747
727
|
}
|
|
748
728
|
|
|
749
729
|
// src/index.ts
|
|
750
|
-
var version = "2.11.
|
|
730
|
+
var version = "2.11.2";
|
|
751
731
|
return __toCommonJS(src_exports);
|
|
752
732
|
})();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var af=af||{};af.common=(()=>{var D=Object.defineProperty,fe=Object.defineProperties,pe=Object.getOwnPropertyDescriptor,me=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var j=(e,t,o)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,m=(e,t)=>{for(var o in t||(t={}))k.call(t,o)&&j(e,o,t[o]);if(q)for(var o of q(t))ye.call(t,o)&&j(e,o,t[o]);return e},B=(e,t)=>fe(e,me(t));var he=(e,t)=>{for(var o in t)D(e,o,{get:t[o],enumerable:!0})},Se=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ge(t))!k.call(e,r)&&r!==o&&D(e,r,{get:()=>t[r],enumerable:!(n=pe(t,r))||n.enumerable});return e};var xe=e=>Se(D({},"__esModule",{value:!0}),e);var l=(e,t,o)=>(j(e,typeof t!="symbol"?t+"":t,o),o);var Ie={};he(Ie,{ConfirmButtons:()=>M,SessionHandler:()=>p,UserSession:()=>L,alert:()=>se,confirm:()=>le,downloadBlob:()=>E,downloadRequest:()=>X,expose:()=>U,getLocalizedString:()=>d,getSessionData:()=>z,getSettings:()=>ie,getUserImage:()=>_,has:()=>y,invariant:()=>u,localStorage:()=>K,localize:()=>G,logActivity:()=>T,logError:()=>te,mitt:()=>I,openAlertDialog:()=>O,saveSettings:()=>ae,startActivity:()=>P,time:()=>ee,toLocalDateTime:()=>Z,toLocalISODate:()=>V,toLocalISODateTime:()=>R,version:()=>De,waitForDialog:()=>H});function I(e){return{all:e=e||new Map,on:function(t,o){var n=e.get(t);n?n.push(o):e.set(t,[o])},off:function(t,o){var n=e.get(t);n&&(o?n.splice(n.indexOf(o)>>>0,1):e.set(t,[]))},emit:function(t,o){var n=e.get(t);n&&n.slice().map(function(r){r(o)}),(n=e.get("*"))&&n.slice().map(function(r){r(t,o)})}}}var p=class{constructor(){l(this,"eventHandler",I())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,o){try{let n=new Promise(a=>{let i=()=>{this.eventHandler.off("onAuthenticated",i),t==null||t(),a()};this.eventHandler.on("onAuthenticated",i)}),r=document.querySelector("dialog.session-expired-dialog");if(r)await n;else{r=document.createElement("dialog"),r.className="session-expired-dialog",r.style.display="flex",r.style.padding="0",r.style.left="50%",r.style.transform="translateX(-50%)";let a="/login?ReturnUrl=%2fapi/sessionexpired/remove";o!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):a="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",r.innerHTML='<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="'.concat(a,'" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>'),document.body.append(r),r.showModal(),await n,r.remove()}}catch(n){window.location.href="/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(window.location.search))}}attachEvent(t,o){return this.eventHandler.on(t,o)}detachEvent(t,o){return this.eventHandler.off(t,o)}};var L=class extends p{constructor(o){super();l(this,"amDesignator","a.m.");l(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);l(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);l(this,"decimalSeparator",".");l(this,"domain","OB");l(this,"email");l(this,"formats");l(this,"groupSeparator",null);l(this,"integratedSecurity",!1);l(this,"isDeveloper",!1);l(this,"login","");l(this,"loginType");l(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);l(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);l(this,"name");l(this,"pmDesignator","p.m.");l(this,"shortDateFormat","dd.MM.yyyy");l(this,"culture","en-GB");l(this,"uiculture","en-GB");this.formats={},Object.assign(this,o)}};var F;(F=window.window)==null||F.addEventListener("error",e=>{var t,o,n,r,a,i,f;try{let c={error:(n=(o=(t=e.error)==null?void 0:t.message)!=null?o:e.message)!=null?n:null,file:e.filename,line:(r=e.lineno)!=null?r:0,column:(a=e.colno)!=null?a:0,stack:(f=(i=e.error)==null?void 0:i.stack)!=null?f:null};fetch("/data/Logger/LogError",{body:JSON.stringify(c),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(c){}});function J(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var N=class{constructor(){l(this,"isPersisted",()=>!0)}getLocalStorageKey(t,o){return o?["common",t].join("."):J(t)}get(t,o,n){let r=this.getLocalStorageKey(t,n),a=localStorage.getItem(r);return a!==null?JSON.parse(a):o}set(t,o,n){localStorage.setItem(this.getLocalStorageKey(t,n),JSON.stringify(o))}remove(t,o){let n=this.getLocalStorageKey(t,o);return localStorage.getItem(n)!==null?(localStorage.removeItem(n),!0):!1}clear(){let t=J("");for(let o in localStorage)o.slice(0,t.length)===t&&localStorage.removeItem(o)}},K=new N;function V(e){return e?R(e).substring(0,10):null}function g(e){return String(e).padStart(2,"0")}function R(e){return e?"".concat(e.getFullYear(),"-").concat(g(e.getMonth()+1),"-").concat(g(e.getDate()),"T").concat(g(e.getHours()),":").concat(g(e.getMinutes()),":").concat(g(e.getSeconds()),".").concat(g(e.getMilliseconds())):null}function Z(e){return e?e.toISOString().substring(0,16):""}function E(e,t){return new Promise(function(o,n){try{let r=URL.createObjectURL(e),a=document.body,i=document.createElement("a");i.setAttribute("download",t),i.href=r,a.append(i),i.click(),a.removeChild(i),setTimeout(function(){URL.revokeObjectURL(r),o()},250)}catch(r){n(r)}})}function u(e,t){if(e)return;let o=typeof t=="function"?t():t;throw new Error(o!=null?o:"Invariant failed")}async function X(e,{fileName:t,signal:o,onProgress:n}){var a;let r=0;n==null||n({status:"requested"});try{let i=await fetch(e);if(!i.ok||!i.body){if((a=i.headers.get("content-type"))!=null&&a.includes("application/json")){let c=await i.json();u(!c.error,c.error)}throw new Error("".concat(i.status," ").concat(i.statusText))}try{let c=i.body.getReader(),A=new ReadableStream({start:function(h){function S(){return c.read().then(function(s){if(s.done){h.close();return}return r+=s.value.length,n==null||n({bytesReceived:r,status:"downloading"}),h.enqueue(s.value),S()})}return S()}});i=new Response(A)}catch(c){}let f=await i.blob();n==null||n({bytesReceived:r,status:"downloaded"}),await E(f,t),n==null||n({bytesReceived:r,status:"completed"})}catch(i){o!=null&&o.aborted?n==null||n({status:"cancelled"}):n==null||n({error:i.message,status:"error"})}}function y(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var be=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;function $(e){var t=e.toString().match(be);return u(t,"Unable to parse function!"),{name:t[1],args:t[2].split(","),body:t[3]}}function Y(){}Y.prototype=Object.create(null);var W=Y;function C(e,t){if(typeof e=="object"){if(typeof t=="string"){let o=t.split(".");return C(e,o)}else if(Array.isArray(t)){let o=e;for(let n=0;n<t.length;n++)o=o[t[n]]=o[t[n]]||new W;return o}}}function U(e,t,o={}){if(Array.isArray(t))for(let n of t){let{name:r}=$(n);u(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),U(e,n)}else{let n,r;if(typeof t=="function"&&(n=$(t).name),typeof e=="string"){let a=e.split(".");n||(n=a[a.length-1],a=a.slice(0,a.length-1)),r=C(window,a)}else n&&(typeof e=="object"||typeof e=="function")?r=e:u(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");y(r,n)&&(o==null?void 0:o.overwrite)!==!0?console.warn([e,n].join(".")+" is already defined!"):r[n]=t}}var ve={xs:64,sm:128,md:256,lg:512,xl:void 0};function _(e,t,o,n="xs"){if(e&&typeof e=="object")return _(e.primKey,e.login,e.hash,e.size);if(!e||!o)return"";let r=ve[n];return"/api/data/blob/EmployeesLookup/".concat(e,"/Image/").concat(encodeURIComponent(t!=null?t:"")).concat(t?".":"").concat(encodeURIComponent(o),".jpg").concat(r?"?width=".concat(r):"")}async function we(e){try{let t=await fetch("/api/user/localize/new/".concat(af.article.id),{body:JSON.stringify({text:e}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(t.ok)return await t.json()}catch(t){}return e}function d(e,t){var o,n;if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(((n=(o=window.af)==null?void 0:o.article)==null?void 0:n.i18n)!==void 0){if(!y(af.article.i18n,e)){af.article.i18n[e]=e;let r=we(e).then(a=>(af.article.i18n[e]=a,a));if(t)return r}return af.article.i18n[e]}else return e}function G(e,...t){u(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let o=e.map((r,a)=>a===e.length-1?r:"".concat(r,"$").concat(a)).join(""),n=d(o);return t.forEach((r,a)=>{n=n.replace("$"+a,r)}),n}async function T(e,t={},o=0){var n;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:af.article.id,timeElapsed:o,action:e,parameters:B(m({},t),{_session:z()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((n=r.headers.get("Content-Type"))!=null&&n.includes("application/json")){let a=await r.json();console.error(a.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function P(e,t={}){let o=performance.now();return(n={})=>T(e,m(m({},t),n),performance.now()-o)}async function ee(e){let t=performance.now();return[await e(),performance.now()-t]}async function te(e){var t;try{if(!e)return;let o=typeof e=="string"?{error:e}:typeof e=="object"?"message"in e?{error:e.message,stack:(t=e.stack)!=null?t:null}:{error:e.toString()}:{error:"Unspecified error"};console.error(e);let n=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json; charset=utf-8"}});if(n.ok)return await n.json();console.error(Error("Failed to log error"))}catch(o){}}function ne(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var Q=Date.now(),oe=ne(),b="",v="";if("document"in window){let e=()=>{var t;return T("AfSessionInit",{"appframe-core":af.common.version,"appframe-data":(t=af.data)==null?void 0:t.version,"app-version":af.article.version})};document.addEventListener("DOMContentLoaded",()=>{b=localStorage.getItem("_afDeviceId"),v=sessionStorage.getItem("_afSessionId"),b||(b=ne(),localStorage.setItem("_afDeviceId",b)),v||(v=oe,sessionStorage.setItem("_afSessionId",v)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:af.article.id,action:"AfSessionEnd",parameters:{_session:z()}})):e()})}function z(){return{browserSessionId:v,sessionStart:Q,sessionLength:Date.now()-Q,sessionId:oe,deviceId:b}}function re(e){let t=e||af.article.id;return"".concat(t,".").concat(af.userSession.login)}function ie(e,t){if(!(af!=null&&af.userSession))return null;let o=re(t),n=JSON.parse(localStorage.getItem(o)||"{}");return e?n[e]||null:n}function ae(e,t,o){if(!(af!=null&&af.userSession))return;let n=re(o),r=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(n,JSON.stringify(r))}var Ae='\n <dialog class="alert-dialog">\n <form method="dialog">\n <article></article>\n <footer>\n <menu></menu>\n </footer>\n </form>\n </dialog>\n';if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=Ae,document.body.append(e)}function H(e,t="No"){return new Promise(o=>{let n=new AbortController;e.addEventListener("close",()=>{o(e.returnValue),n.abort()},{signal:n.signal}),e.addEventListener("cancel",()=>{o(t),n.abort()},{signal:n.signal})})}var w=new Map;async function O({buttons:e,content:t,className:o,id:n,title:r}){var h,S;if(n&&w.has(n))return await w.get(n);let a=document.querySelector("#AlertDialogTemplate");if(!a)throw Error("No alert dialog template found");let i=(h=a.content.firstElementChild)==null?void 0:h.cloneNode(!0),f=i==null?void 0:i.querySelector("article"),c=i==null?void 0:i.querySelector("footer menu");if(!i||!f||!c)throw Error("Invalid alert dialog template");if(o&&o.split(/\s+/).forEach(s=>i==null?void 0:i.classList.add(s)),r){let s=document.createElement("header");s.append(r),(S=f.parentNode)==null||S.insertBefore(s,f)}f.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:ce,primary:ue}of e){let de=document.createElement("li"),x=document.createElement("button");x.value=ce,ue&&x.classList.add("primary"),x.textContent=s,de.appendChild(x),c.appendChild(x)}document.body.appendChild(i),i.showModal();let A=H(i).then(s=>(n&&w.has(n)&&w.delete(n),i&&document.body.removeChild(i),s));return n&&w.set(n,A),await A}var M=(o=>(o[o.YesNo=0]="YesNo",o[o.OkCancel=1]="OkCancel",o))(M||{});async function le(e,t={}){let{buttons:o=0,title:n}=t,r=o===1?[{label:d("OK"),value:"yes",primary:!0},{label:d("Cancel"),value:"no"}]:[{label:d("Yes"),value:"yes",primary:!0},{label:d("No"),value:"no"}];return await O({content:e,buttons:r,className:"alert-dialog-confirm",title:n})==="yes"}async function se(e,t={}){await O(m({content:e,className:"alert-dialog-alert",buttons:[{label:d("OK"),value:"ok",primary:!0}]},t))}var De="2.11.0";return xe(Ie);})();
|
|
1
|
+
var af=af||{};af.common=(()=>{var A=Object.defineProperty,de=Object.defineProperties,fe=Object.getOwnPropertyDescriptor,me=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var j=(e,t,n)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))k.call(t,n)&&j(e,n,t[n]);if(q)for(var n of q(t))ge.call(t,n)&&j(e,n,t[n]);return e},B=(e,t)=>de(e,me(t));var ye=(e,t)=>{for(var n in t)A(e,n,{get:t[n],enumerable:!0})},Se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pe(t))!k.call(e,r)&&r!==n&&A(e,r,{get:()=>t[r],enumerable:!(o=fe(t,r))||o.enumerable});return e};var he=e=>Se(A({},"__esModule",{value:!0}),e);var l=(e,t,n)=>(j(e,typeof t!="symbol"?t+"":t,n),n);var Ae={};ye(Ae,{ConfirmButtons:()=>M,SessionHandler:()=>f,UserSession:()=>L,alert:()=>le,confirm:()=>ae,downloadBlob:()=>z,downloadRequest:()=>P,expose:()=>U,getLocalizedString:()=>u,getSessionData:()=>T,getSettings:()=>re,getUserImage:()=>_,invariant:()=>c,localStorage:()=>G,localize:()=>ne,logActivity:()=>E,logError:()=>w,mitt:()=>I,openAlertDialog:()=>O,saveSettings:()=>ie,startActivity:()=>J,time:()=>K,toLocalDateTime:()=>Q,toLocalISODate:()=>W,toLocalISODateTime:()=>R,version:()=>De,waitForDialog:()=>H});function I(e){return{all:e=e||new Map,on:function(t,n){var o=e.get(t);o?o.push(n):e.set(t,[n])},off:function(t,n){var o=e.get(t);o&&(n?o.splice(o.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var o=e.get(t);o&&o.slice().map(function(r){r(n)}),(o=e.get("*"))&&o.slice().map(function(r){r(t,n)})}}}var f=class{constructor(){l(this,"eventHandler",I())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,n){try{let o=new Promise(a=>{let i=()=>{this.eventHandler.off("onAuthenticated",i),t==null||t(),a()};this.eventHandler.on("onAuthenticated",i)}),r=document.querySelector("dialog.session-expired-dialog");if(r)await o;else{r=document.createElement("dialog"),r.className="session-expired-dialog",r.style.display="flex",r.style.padding="0",r.style.left="50%",r.style.transform="translateX(-50%)";let a="/login?ReturnUrl=%2fapi/sessionexpired/remove";n!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):a="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",r.innerHTML='<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="'.concat(a,'" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>'),document.body.append(r),r.showModal(),await o,r.remove()}}catch(o){window.location.href="/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(window.location.search))}}attachEvent(t,n){return this.eventHandler.on(t,n)}detachEvent(t,n){return this.eventHandler.off(t,n)}};var L=class extends f{constructor(n){super();l(this,"amDesignator","a.m.");l(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);l(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);l(this,"decimalSeparator",".");l(this,"domain","OB");l(this,"email");l(this,"formats");l(this,"groupSeparator",null);l(this,"integratedSecurity",!1);l(this,"isDeveloper",!1);l(this,"login","");l(this,"loginType");l(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);l(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);l(this,"name");l(this,"pmDesignator","p.m.");l(this,"shortDateFormat","dd.MM.yyyy");l(this,"culture","en-GB");l(this,"uiculture","en-GB");this.formats={},Object.assign(this,n)}};async function E(e,t={},n=0){var o;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:af.article.id,timeElapsed:n,action:e,parameters:B(p({},t),{_session:T()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((o=r.headers.get("Content-Type"))!=null&&o.includes("application/json")){let a=await r.json();console.error(a.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function J(e,t={}){let n=performance.now();return(o={})=>E(e,p(p({},t),o),performance.now()-n)}async function K(e){let t=performance.now();return[await e(),performance.now()-t]}async function w(e){var t;try{if(!e)return;let n=typeof e=="string"?{error:e}:typeof e=="object"?"message"in e?{error:e.message,stack:(t=e.stack)!=null?t:null}:{error:e.toString()}:{error:"Unspecified error"};console.error(e);let o=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json; charset=utf-8"}});if(o.ok)return await o.json();console.error(Error("Failed to log error"))}catch(n){}}function V(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var F=Date.now(),Z=V(),b="",x="";if("document"in window){let e=()=>{var t;return E("AfSessionInit",{"appframe-core":af.common.version,"appframe-data":(t=af.data)==null?void 0:t.version,"app-version":af.article.version})};document.addEventListener("DOMContentLoaded",()=>{b=localStorage.getItem("_afDeviceId"),x=sessionStorage.getItem("_afSessionId"),b||(b=V(),localStorage.setItem("_afDeviceId",b)),x||(x=Z,sessionStorage.setItem("_afSessionId",x)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:af.article.id,action:"AfSessionEnd",parameters:{_session:T()}})):e()})}function T(){return{browserSessionId:x,sessionStart:F,sessionLength:Date.now()-F,sessionId:Z,deviceId:b}}var Y;(Y=window.window)==null||Y.addEventListener("error",e=>{typeof e=="object"&&"error"in e?w(e.error):typeof e=="object"&&"message"in e&&w(e)});function X(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var N=class{constructor(){l(this,"isPersisted",()=>!0)}getLocalStorageKey(t,n){return n?["common",t].join("."):X(t)}get(t,n,o){let r=this.getLocalStorageKey(t,o),a=localStorage.getItem(r);return a!==null?JSON.parse(a):n}set(t,n,o){localStorage.setItem(this.getLocalStorageKey(t,o),JSON.stringify(n))}remove(t,n){let o=this.getLocalStorageKey(t,n);return localStorage.getItem(o)!==null?(localStorage.removeItem(o),!0):!1}clear(){let t=X("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},G=new N;function W(e){return e?R(e).substring(0,10):null}function g(e,t=2){return String(e).padStart(t,"0")}function R(e){return e?"".concat(e.getFullYear(),"-").concat(g(e.getMonth()+1),"-").concat(g(e.getDate()),"T").concat(g(e.getHours()),":").concat(g(e.getMinutes()),":").concat(g(e.getSeconds()),".").concat(g(e.getMilliseconds(),3)):null}function Q(e){return e?e.toISOString().substring(0,16):""}function z(e,t){return new Promise(function(n,o){try{let r=URL.createObjectURL(e),a=document.body,i=document.createElement("a");i.setAttribute("download",t),i.href=r,a.append(i),i.click(),a.removeChild(i),setTimeout(function(){URL.revokeObjectURL(r),n()},250)}catch(r){o(r)}})}function c(e,t){if(e)return;let n=typeof t=="function"?t():t;throw new Error(n!=null?n:"Invariant failed")}async function P(e,{fileName:t,signal:n,onProgress:o}){var a;let r=0;o==null||o({status:"requested"});try{let i=await fetch(e);if(!i.ok||!i.body){if((a=i.headers.get("content-type"))!=null&&a.includes("application/json")){let d=await i.json();c(!d.error,d.error)}throw new Error("".concat(i.status," ").concat(i.statusText))}try{let d=i.body.getReader(),D=new ReadableStream({start:function(y){function S(){return d.read().then(function(s){if(s.done){y.close();return}return r+=s.value.length,o==null||o({bytesReceived:r,status:"downloading"}),y.enqueue(s.value),S()})}return S()}});i=new Response(D)}catch(d){}let m=await i.blob();o==null||o({bytesReceived:r,status:"downloaded"}),await z(m,t),o==null||o({bytesReceived:r,status:"completed"})}catch(i){n!=null&&n.aborted?o==null||o({status:"cancelled"}):o==null||o({error:i.message,status:"error"})}}var be=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;function $(e){var n;var t=e.toString().match(be);return c(t,"Unable to parse function!"),{name:(n=e.name)!=null?n:t[1],args:t[2].split(",").map(o=>o.trim()),body:t[3]}}function ee(){}ee.prototype=Object.create(null);var te=ee;function C(e,t){if(typeof e=="object"){if(typeof t=="string"){let n=t.split(".");return C(e,n)}else if(Array.isArray(t)){let n=e;for(let o=0;o<t.length;o++)n=n[t[o]]=n[t[o]]||new te;return n}}}function U(e,t,n={}){if(Array.isArray(t))for(let o of t){let{name:r}=$(o);c(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),U(e,o)}else{let o,r;if(typeof t=="function"&&(o=$(t).name),typeof e=="string"){let a=e.split(".");o||(o=a[a.length-1],a=a.slice(0,a.length-1)),r=C(window,a)}else o&&(typeof e=="object"||typeof e=="function")?r=e:c(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");Object.hasOwn(r,o)&&(n==null?void 0:n.overwrite)!==!0?console.warn([e,o].join(".")+" is already defined!"):r[o]=t}}var xe={xs:64,sm:128,md:256,lg:512,xl:void 0};function _(e,t,n,o="xs"){if(e&&typeof e=="object")return _(e.primKey,e.login,e.hash,e.size);if(!e||!n)return"";let r=xe[o];return"/api/data/blob/EmployeesLookup/".concat(e,"/Image/").concat(encodeURIComponent(t!=null?t:"")).concat(t?".":"").concat(encodeURIComponent(n),".jpg").concat(r?"?width=".concat(r):"")}async function we(e){try{let t=await fetch("/api/user/localize/new/".concat(af.article.id),{body:JSON.stringify({text:e}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(t.ok)return await t.json()}catch(t){}return e}function u(e,t){var n,o;if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(((o=(n=window.af)==null?void 0:n.article)==null?void 0:o.i18n)!==void 0){if(!Object.hasOwn(af.article.i18n,e)){af.article.i18n[e]=e;let r=we(e).then(a=>(af.article.i18n[e]=a,a));if(t)return r}return af.article.i18n[e]}else return e}function ne(e,...t){c(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let n=e.map((r,a)=>a===e.length-1?r:"".concat(r,"$").concat(a)).join(""),o=u(n);return t.forEach((r,a)=>{o=o.replace("$"+a,r)}),o}function oe(e){let t=e||af.article.id;return"".concat(t,".").concat(af.userSession.login)}function re(e,t){if(!(af!=null&&af.userSession))return null;let n=oe(t),o=JSON.parse(localStorage.getItem(n)||"{}");return e?o[e]||null:o}function ie(e,t,n){if(!(af!=null&&af.userSession))return;let o=oe(n),r=JSON.parse(localStorage.getItem(o)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(o,JSON.stringify(r))}var ve='\n <dialog class="alert-dialog">\n <form method="dialog">\n <article></article>\n <footer>\n <menu></menu>\n </footer>\n </form>\n </dialog>\n';if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=ve,document.body.append(e)}function H(e,t="No"){return new Promise(n=>{let o=new AbortController;e.addEventListener("close",()=>{n(e.returnValue),o.abort()},{signal:o.signal}),e.addEventListener("cancel",()=>{n(t),o.abort()},{signal:o.signal})})}var v=new Map;async function O({buttons:e,content:t,className:n,id:o,title:r}){var y,S;if(o&&v.has(o))return await v.get(o);let a=document.querySelector("#AlertDialogTemplate");if(!a)throw Error("No alert dialog template found");let i=(y=a.content.firstElementChild)==null?void 0:y.cloneNode(!0),m=i==null?void 0:i.querySelector("article"),d=i==null?void 0:i.querySelector("footer menu");if(!i||!m||!d)throw Error("Invalid alert dialog template");if(n&&n.split(/\s+/).forEach(s=>i==null?void 0:i.classList.add(s)),r){let s=document.createElement("header");s.append(r),(S=m.parentNode)==null||S.insertBefore(s,m)}m.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:se,primary:ce}of e){let ue=document.createElement("li"),h=document.createElement("button");h.value=se,ce&&h.classList.add("primary"),h.textContent=s,ue.appendChild(h),d.appendChild(h)}document.body.appendChild(i),i.showModal();let D=H(i).then(s=>(o&&v.has(o)&&v.delete(o),i&&document.body.removeChild(i),s));return o&&v.set(o,D),await D}var M=(n=>(n[n.YesNo=0]="YesNo",n[n.OkCancel=1]="OkCancel",n))(M||{});async function ae(e,t={}){let{buttons:n=0,title:o}=t,r=n===1?[{label:u("OK"),value:"yes",primary:!0},{label:u("Cancel"),value:"no"}]:[{label:u("Yes"),value:"yes",primary:!0},{label:u("No"),value:"no"}];return await O({content:e,buttons:r,className:"alert-dialog-confirm",title:o})==="yes"}async function le(e,t={}){await O(p({content:e,className:"alert-dialog-alert",buttons:[{label:u("OK"),value:"ok",primary:!0}]},t))}var De="2.11.2";return he(Ae);})();
|
|
2
2
|
//# sourceMappingURL=af.common.legacy.min.js.map
|