@olenbetong/appframe-core 2.11.6 → 2.11.8
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 +63 -67
- package/dist/esm/af.common.legacy.js +67 -74
- 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 +67 -72
- package/dist/iife/af.common.legacy.js +71 -79
- 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.d.ts +1 -1
- package/es/alert.js +3 -1
- package/es/date.test.js +1 -1
- package/es/downloadBlob.js +2 -2
- package/es/downloadRequest.js +3 -3
- package/es/expose.d.ts +1 -1
- package/es/expose.js +1 -1
- package/es/expose.test.d.ts +1 -1
- package/es/expose.test.js +13 -13
- package/es/getLocalizedString.js +1 -1
- package/es/getUserImage.test.js +2 -2
- package/es/index.d.ts +11 -11
- package/es/index.js +5 -4
- package/es/invariant.test.js +2 -2
- package/es/localize.js +2 -2
- package/es/log.js +1 -1
- package/es/parseFunc.d.ts +1 -1
- package/es/parseFunc.js +1 -1
- package/es/parseFunc.test.js +2 -2
- package/es/test/setup.d.ts +0 -0
- package/es/test/setup.js +3 -0
- package/package.json +53 -53
- package/src/SessionHandler.ts +2 -2
- package/src/UserSession.ts +10 -10
- package/src/alert.ts +8 -6
- package/src/date.test.ts +1 -1
- package/src/date.ts +1 -1
- package/src/downloadBlob.ts +2 -2
- package/src/downloadRequest.ts +3 -3
- package/src/expose.test.ts +14 -15
- package/src/expose.ts +4 -4
- package/src/getLocalizedString.ts +1 -1
- package/src/getUserImage.test.ts +2 -2
- package/src/index.ts +12 -11
- package/src/invariant.test.ts +2 -2
- package/src/invariant.ts +3 -3
- package/src/localize.ts +2 -2
- package/src/log.ts +2 -2
- package/src/parseFunc.test.ts +2 -2
- package/src/parseFunc.ts +2 -2
- package/src/test/setup.ts +2 -0
- package/LICENSE +0 -21
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
af.common = (() => {
|
|
1
|
+
var af_common = (() => {
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -34,14 +33,11 @@ af.common = (() => {
|
|
|
34
33
|
return to;
|
|
35
34
|
};
|
|
36
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var __publicField = (obj, key, value) =>
|
|
38
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
39
|
-
return value;
|
|
40
|
-
};
|
|
36
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
41
37
|
|
|
42
38
|
// src/index.ts
|
|
43
|
-
var
|
|
44
|
-
__export(
|
|
39
|
+
var index_exports = {};
|
|
40
|
+
__export(index_exports, {
|
|
45
41
|
ConfirmButtons: () => ConfirmButtons,
|
|
46
42
|
SessionHandler: () => SessionHandler,
|
|
47
43
|
UserSession: () => UserSession,
|
|
@@ -211,7 +207,7 @@ af.common = (() => {
|
|
|
211
207
|
console.error("".concat(response.status, " ").concat(response.statusText));
|
|
212
208
|
}
|
|
213
209
|
}
|
|
214
|
-
} catch (
|
|
210
|
+
} catch (e) {
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
213
|
function startActivity(activity, startParameters = {}) {
|
|
@@ -226,8 +222,7 @@ af.common = (() => {
|
|
|
226
222
|
async function logError(error) {
|
|
227
223
|
var _a3;
|
|
228
224
|
try {
|
|
229
|
-
if (!error)
|
|
230
|
-
return;
|
|
225
|
+
if (!error) return;
|
|
231
226
|
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
232
227
|
error: error.message,
|
|
233
228
|
stack: (_a3 = error.stack) != null ? _a3 : null
|
|
@@ -374,7 +369,7 @@ af.common = (() => {
|
|
|
374
369
|
|
|
375
370
|
// src/downloadBlob.ts
|
|
376
371
|
function downloadBlob(blob, fileName) {
|
|
377
|
-
return new Promise(
|
|
372
|
+
return new Promise((resolve, reject) => {
|
|
378
373
|
try {
|
|
379
374
|
const url = URL.createObjectURL(blob);
|
|
380
375
|
const parent = document.body;
|
|
@@ -384,7 +379,7 @@ af.common = (() => {
|
|
|
384
379
|
parent.append(anchor);
|
|
385
380
|
anchor.click();
|
|
386
381
|
parent.removeChild(anchor);
|
|
387
|
-
setTimeout(
|
|
382
|
+
setTimeout(() => {
|
|
388
383
|
URL.revokeObjectURL(url);
|
|
389
384
|
resolve();
|
|
390
385
|
}, 250);
|
|
@@ -420,9 +415,9 @@ af.common = (() => {
|
|
|
420
415
|
try {
|
|
421
416
|
const reader = response.body.getReader();
|
|
422
417
|
const stream = new ReadableStream({
|
|
423
|
-
start:
|
|
418
|
+
start: (controller) => {
|
|
424
419
|
function pump() {
|
|
425
|
-
return reader.read().then(
|
|
420
|
+
return reader.read().then((read) => {
|
|
426
421
|
if (read.done) {
|
|
427
422
|
controller.close();
|
|
428
423
|
return;
|
|
@@ -437,7 +432,7 @@ af.common = (() => {
|
|
|
437
432
|
}
|
|
438
433
|
});
|
|
439
434
|
response = new Response(stream);
|
|
440
|
-
} catch (
|
|
435
|
+
} catch (e) {
|
|
441
436
|
}
|
|
442
437
|
const blob = await response.blob();
|
|
443
438
|
onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloaded" });
|
|
@@ -456,7 +451,7 @@ af.common = (() => {
|
|
|
456
451
|
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)*)\}$/;
|
|
457
452
|
function parseFunc(func) {
|
|
458
453
|
var _a3;
|
|
459
|
-
|
|
454
|
+
const match = func.toString().match(funcRegex);
|
|
460
455
|
invariant(match, "Unable to parse function!");
|
|
461
456
|
return { name: (_a3 = func.name) != null ? _a3 : match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
|
|
462
457
|
}
|
|
@@ -513,32 +508,13 @@ af.common = (() => {
|
|
|
513
508
|
invariant(false, "Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
514
509
|
}
|
|
515
510
|
if (Object.hasOwn(namespace, keyName) && (options == null ? void 0 : options.overwrite) !== true) {
|
|
516
|
-
console.warn([name, keyName].join(".")
|
|
511
|
+
console.warn("".concat([name, keyName].join("."), " is already defined!"));
|
|
517
512
|
} else {
|
|
518
513
|
namespace[keyName] = value;
|
|
519
514
|
}
|
|
520
515
|
}
|
|
521
516
|
}
|
|
522
517
|
|
|
523
|
-
// src/getUserImage.ts
|
|
524
|
-
var sizeMap = {
|
|
525
|
-
xs: 64,
|
|
526
|
-
sm: 128,
|
|
527
|
-
md: 256,
|
|
528
|
-
lg: 512,
|
|
529
|
-
xl: void 0
|
|
530
|
-
};
|
|
531
|
-
function getUserImage(primKeyOrOptions, login, hash, size = "xs") {
|
|
532
|
-
if (primKeyOrOptions && typeof primKeyOrOptions === "object") {
|
|
533
|
-
return getUserImage(primKeyOrOptions.primKey, primKeyOrOptions.login, primKeyOrOptions.hash, primKeyOrOptions.size);
|
|
534
|
-
}
|
|
535
|
-
if (!primKeyOrOptions || !hash) {
|
|
536
|
-
return "";
|
|
537
|
-
}
|
|
538
|
-
let sizePx = sizeMap[size];
|
|
539
|
-
return "/api/data/blob/EmployeesLookup/".concat(primKeyOrOptions, "/Image/").concat(encodeURIComponent(login != null ? login : "")).concat(login ? "." : "").concat(encodeURIComponent(hash), ".jpg").concat(sizePx ? "?width=".concat(sizePx) : "");
|
|
540
|
-
}
|
|
541
|
-
|
|
542
518
|
// src/getLocalizedString.ts
|
|
543
519
|
async function fetchLocalizedString(text) {
|
|
544
520
|
try {
|
|
@@ -554,7 +530,7 @@ af.common = (() => {
|
|
|
554
530
|
if (response.ok) {
|
|
555
531
|
return await response.json();
|
|
556
532
|
}
|
|
557
|
-
} catch (
|
|
533
|
+
} catch (e) {
|
|
558
534
|
}
|
|
559
535
|
return text;
|
|
560
536
|
}
|
|
@@ -583,6 +559,25 @@ af.common = (() => {
|
|
|
583
559
|
}
|
|
584
560
|
}
|
|
585
561
|
|
|
562
|
+
// src/getUserImage.ts
|
|
563
|
+
var sizeMap = {
|
|
564
|
+
xs: 64,
|
|
565
|
+
sm: 128,
|
|
566
|
+
md: 256,
|
|
567
|
+
lg: 512,
|
|
568
|
+
xl: void 0
|
|
569
|
+
};
|
|
570
|
+
function getUserImage(primKeyOrOptions, login, hash, size = "xs") {
|
|
571
|
+
if (primKeyOrOptions && typeof primKeyOrOptions === "object") {
|
|
572
|
+
return getUserImage(primKeyOrOptions.primKey, primKeyOrOptions.login, primKeyOrOptions.hash, primKeyOrOptions.size);
|
|
573
|
+
}
|
|
574
|
+
if (!primKeyOrOptions || !hash) {
|
|
575
|
+
return "";
|
|
576
|
+
}
|
|
577
|
+
let sizePx = sizeMap[size];
|
|
578
|
+
return "/api/data/blob/EmployeesLookup/".concat(primKeyOrOptions, "/Image/").concat(encodeURIComponent(login != null ? login : "")).concat(login ? "." : "").concat(encodeURIComponent(hash), ".jpg").concat(sizePx ? "?width=".concat(sizePx) : "");
|
|
579
|
+
}
|
|
580
|
+
|
|
586
581
|
// src/localize.ts
|
|
587
582
|
function localize(stringParts, ...args) {
|
|
588
583
|
invariant(
|
|
@@ -592,42 +587,11 @@ af.common = (() => {
|
|
|
592
587
|
let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s : "".concat(s, "$").concat(i)).join("");
|
|
593
588
|
let localized = getLocalizedString(stringToLocalize);
|
|
594
589
|
args.forEach((arg, index) => {
|
|
595
|
-
localized = localized.replace("$"
|
|
590
|
+
localized = localized.replace("$".concat(index), arg);
|
|
596
591
|
});
|
|
597
592
|
return localized;
|
|
598
593
|
}
|
|
599
594
|
|
|
600
|
-
// src/settings.ts
|
|
601
|
-
function getKey(article2) {
|
|
602
|
-
var _a3, _b2, _c2, _d2, _e, _f;
|
|
603
|
-
const articleKey = (_d2 = article2 != null ? article2 : (_b2 = (_a3 = window.af) == null ? void 0 : _a3.article) == null ? void 0 : _b2.id) != null ? _d2 : (_c2 = window.window) == null ? void 0 : _c2.location.pathname.substring(1).split("/")[0];
|
|
604
|
-
return "".concat(articleKey, ".").concat((_f = (_e = window.af) == null ? void 0 : _e.userSession.login) != null ? _f : "anonymous");
|
|
605
|
-
}
|
|
606
|
-
function getSettings(setting, article2) {
|
|
607
|
-
var _a3;
|
|
608
|
-
if (!((_a3 = window.af) == null ? void 0 : _a3.userSession))
|
|
609
|
-
return null;
|
|
610
|
-
const key = getKey(article2);
|
|
611
|
-
const settings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
612
|
-
if (setting) {
|
|
613
|
-
return settings[setting] || null;
|
|
614
|
-
}
|
|
615
|
-
return settings;
|
|
616
|
-
}
|
|
617
|
-
function saveSettings(setting, value, article2) {
|
|
618
|
-
var _a3;
|
|
619
|
-
if (!((_a3 = window.af) == null ? void 0 : _a3.userSession))
|
|
620
|
-
return;
|
|
621
|
-
const key = getKey(article2);
|
|
622
|
-
let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
623
|
-
if (typeof value !== "undefined") {
|
|
624
|
-
userSettings[setting] = value;
|
|
625
|
-
} else {
|
|
626
|
-
userSettings = setting;
|
|
627
|
-
}
|
|
628
|
-
localStorage.setItem(key, JSON.stringify(userSettings));
|
|
629
|
-
}
|
|
630
|
-
|
|
631
595
|
// src/alert.ts
|
|
632
596
|
var template = '\n <dialog class="alert-dialog">\n <form method="dialog">\n <article></article>\n <footer>\n <menu></menu>\n </footer>\n </form>\n </dialog>\n';
|
|
633
597
|
if (window.document && !document.querySelector("#AlertDialogTemplate")) {
|
|
@@ -664,15 +628,15 @@ af.common = (() => {
|
|
|
664
628
|
return await alertDialogPromiseMap.get(id);
|
|
665
629
|
}
|
|
666
630
|
let $template = document.querySelector("#AlertDialogTemplate");
|
|
667
|
-
if (!$template)
|
|
668
|
-
throw Error("No alert dialog template found");
|
|
631
|
+
if (!$template) throw Error("No alert dialog template found");
|
|
669
632
|
let $dialog = (_a3 = $template.content.firstElementChild) == null ? void 0 : _a3.cloneNode(true);
|
|
670
633
|
let $content = $dialog == null ? void 0 : $dialog.querySelector("article");
|
|
671
634
|
let $menu = $dialog == null ? void 0 : $dialog.querySelector("footer menu");
|
|
672
|
-
if (!$dialog || !$content || !$menu)
|
|
673
|
-
throw Error("Invalid alert dialog template");
|
|
635
|
+
if (!$dialog || !$content || !$menu) throw Error("Invalid alert dialog template");
|
|
674
636
|
if (className) {
|
|
675
|
-
className.split(/\s+/)
|
|
637
|
+
for (const className_ of className.split(/\s+/)) {
|
|
638
|
+
$dialog == null ? void 0 : $dialog.classList.add(className_);
|
|
639
|
+
}
|
|
676
640
|
}
|
|
677
641
|
if (title) {
|
|
678
642
|
let $header = document.createElement("header");
|
|
@@ -697,8 +661,7 @@ af.common = (() => {
|
|
|
697
661
|
if (id && alertDialogPromiseMap.has(id)) {
|
|
698
662
|
alertDialogPromiseMap.delete(id);
|
|
699
663
|
}
|
|
700
|
-
if ($dialog)
|
|
701
|
-
document.body.removeChild($dialog);
|
|
664
|
+
if ($dialog) document.body.removeChild($dialog);
|
|
702
665
|
return returnValue;
|
|
703
666
|
});
|
|
704
667
|
if (id) {
|
|
@@ -731,7 +694,36 @@ af.common = (() => {
|
|
|
731
694
|
}, options));
|
|
732
695
|
}
|
|
733
696
|
|
|
697
|
+
// src/settings.ts
|
|
698
|
+
function getKey(article2) {
|
|
699
|
+
var _a3, _b2, _c2, _d2, _e, _f;
|
|
700
|
+
const articleKey = (_d2 = article2 != null ? article2 : (_b2 = (_a3 = window.af) == null ? void 0 : _a3.article) == null ? void 0 : _b2.id) != null ? _d2 : (_c2 = window.window) == null ? void 0 : _c2.location.pathname.substring(1).split("/")[0];
|
|
701
|
+
return "".concat(articleKey, ".").concat((_f = (_e = window.af) == null ? void 0 : _e.userSession.login) != null ? _f : "anonymous");
|
|
702
|
+
}
|
|
703
|
+
function getSettings(setting, article2) {
|
|
704
|
+
var _a3;
|
|
705
|
+
if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return null;
|
|
706
|
+
const key = getKey(article2);
|
|
707
|
+
const settings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
708
|
+
if (setting) {
|
|
709
|
+
return settings[setting] || null;
|
|
710
|
+
}
|
|
711
|
+
return settings;
|
|
712
|
+
}
|
|
713
|
+
function saveSettings(setting, value, article2) {
|
|
714
|
+
var _a3;
|
|
715
|
+
if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return;
|
|
716
|
+
const key = getKey(article2);
|
|
717
|
+
let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
718
|
+
if (typeof value !== "undefined") {
|
|
719
|
+
userSettings[setting] = value;
|
|
720
|
+
} else {
|
|
721
|
+
userSettings = setting;
|
|
722
|
+
}
|
|
723
|
+
localStorage.setItem(key, JSON.stringify(userSettings));
|
|
724
|
+
}
|
|
725
|
+
|
|
734
726
|
// src/index.ts
|
|
735
|
-
var version = "2.11.
|
|
736
|
-
return __toCommonJS(
|
|
727
|
+
var version = "2.11.8";
|
|
728
|
+
return __toCommonJS(index_exports);
|
|
737
729
|
})();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var af=af||{};af.common=(()=>{var A=Object.defineProperty,ye=Object.defineProperties,he=Object.getOwnPropertyDescriptor,be=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,xe=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,m=(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))xe.call(t,n)&&j(e,n,t[n]);return e},B=(e,t)=>ye(e,be(t));var we=(e,t)=>{for(var n in t)A(e,n,{get:t[n],enumerable:!0})},ve=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Se(t))!k.call(e,r)&&r!==n&&A(e,r,{get:()=>t[r],enumerable:!(o=he(t,r))||o.enumerable});return e};var De=e=>ve(A({},"__esModule",{value:!0}),e);var l=(e,t,n)=>(j(e,typeof t!="symbol"?t+"":t,n),n);var ze={};we(ze,{ConfirmButtons:()=>M,SessionHandler:()=>g,UserSession:()=>L,alert:()=>fe,confirm:()=>de,downloadBlob:()=>z,downloadRequest:()=>re,expose:()=>U,getLocalizedString:()=>u,getSessionData:()=>E,getSettings:()=>ce,getUserImage:()=>_,invariant:()=>c,localStorage:()=>te,localize:()=>le,logActivity:()=>T,logError:()=>w,mitt:()=>I,openAlertDialog:()=>O,saveSettings:()=>ue,startActivity:()=>X,time:()=>G,toLocalDateTime:()=>oe,toLocalISODate:()=>ne,toLocalISODateTime:()=>R,version:()=>Ee,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 g=class{constructor(){l(this,"eventHandler",I())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,n){try{let o=new Promise(i=>{let a=()=>{this.eventHandler.off("onAuthenticated",a),t==null||t(),i()};this.eventHandler.on("onAuthenticated",a)}),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 i="/login?ReturnUrl=%2fapi/sessionexpired/remove";n!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):i="/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(i,'" 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 g{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)}};var J,K,V,Z,Y=(Z=(K=(J=window.af)==null?void 0:J.article)==null?void 0:K.id)!=null?Z:(V=window.window)==null?void 0:V.location.pathname.substring(1).split("/")[0];async function T(e,t={},n=0){var o;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:Y,timeElapsed:n,action:e,parameters:B(m({},t),{_session:E()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((o=r.headers.get("Content-Type"))!=null&&o.includes("application/json")){let i=await r.json();console.error(i.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function X(e,t={}){let n=performance.now();return(o={})=>T(e,m(m({},t),o),performance.now()-n)}async function G(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 W(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var F=Date.now(),Q=W(),S="",x="";if("document"in window){let e=()=>{var t,n,o,r,i,a;return T("AfSessionInit",{"appframe-core":(n=(t=window.af)==null?void 0:t.common)==null?void 0:n.version,"appframe-data":(r=(o=window.af)==null?void 0:o.data)==null?void 0:r.version,"app-version":(a=(i=window.af)==null?void 0:i.article)==null?void 0:a.version})};document.addEventListener("DOMContentLoaded",()=>{S=localStorage.getItem("_afDeviceId"),x=sessionStorage.getItem("_afSessionId"),S||(S=W(),localStorage.setItem("_afDeviceId",S)),x||(x=Q,sessionStorage.setItem("_afSessionId",x)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:Y,action:"AfSessionEnd",parameters:{_session:E()}})):e()})}function E(){return{browserSessionId:x,sessionStart:F,sessionLength:Date.now()-F,sessionId:Q,deviceId:S}}var P;(P=window.window)==null||P.addEventListener("error",e=>{typeof e=="object"&&"error"in e?w(e.error):typeof e=="object"&&"message"in e&&w(e)});function ee(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("."):ee(t)}get(t,n,o){let r=this.getLocalStorageKey(t,o),i=localStorage.getItem(r);return i!==null?JSON.parse(i):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=ee("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},te=new N;function ne(e){return e?R(e).substring(0,10):null}function p(e,t=2){return String(e).padStart(t,"0")}function R(e){return e?"".concat(e.getFullYear(),"-").concat(p(e.getMonth()+1),"-").concat(p(e.getDate()),"T").concat(p(e.getHours()),":").concat(p(e.getMinutes()),":").concat(p(e.getSeconds()),".").concat(p(e.getMilliseconds(),3)):null}function oe(e){return e?e.toISOString().substring(0,16):""}function z(e,t){return new Promise(function(n,o){try{let r=URL.createObjectURL(e),i=document.body,a=document.createElement("a");a.setAttribute("download",t),a.href=r,i.append(a),a.click(),i.removeChild(a),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 re(e,{fileName:t,signal:n,onProgress:o}){var i;let r=0;o==null||o({status:"requested"});try{let a=await fetch(e);if(!a.ok||!a.body){if((i=a.headers.get("content-type"))!=null&&i.includes("application/json")){let f=await a.json();c(!f.error,f.error)}throw new Error("".concat(a.status," ").concat(a.statusText))}try{let f=a.body.getReader(),D=new ReadableStream({start:function(y){function h(){return f.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),h()})}return h()}});a=new Response(D)}catch(f){}let d=await a.blob();o==null||o({bytesReceived:r,status:"downloaded"}),await z(d,t),o==null||o({bytesReceived:r,status:"completed"})}catch(a){n!=null&&n.aborted?o==null||o({status:"cancelled"}):o==null||o({error:a.message,status:"error"})}}var Ae=/^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(Ae);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 ie(){}ie.prototype=Object.create(null);var ae=ie;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 ae;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 i=e.split(".");o||(o=i[i.length-1],i=i.slice(0,i.length-1)),r=C(window,i)}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 Ie={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=Ie[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 Le(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=Le(e).then(i=>(af.article.i18n[e]=i,i));if(t)return r}return af.article.i18n[e]}else return e}function le(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,i)=>i===e.length-1?r:"".concat(r,"$").concat(i)).join(""),o=u(n);return t.forEach((r,i)=>{o=o.replace("$"+i,r)}),o}function se(e){var n,o,r,i,a,d;let t=(i=e!=null?e:(o=(n=window.af)==null?void 0:n.article)==null?void 0:o.id)!=null?i:(r=window.window)==null?void 0:r.location.pathname.substring(1).split("/")[0];return"".concat(t,".").concat((d=(a=window.af)==null?void 0:a.userSession.login)!=null?d:"anonymous")}function ce(e,t){var r;if(!((r=window.af)!=null&&r.userSession))return null;let n=se(t),o=JSON.parse(localStorage.getItem(n)||"{}");return e?o[e]||null:o}function ue(e,t,n){var i;if(!((i=window.af)!=null&&i.userSession))return;let o=se(n),r=JSON.parse(localStorage.getItem(o)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(o,JSON.stringify(r))}var Te='\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=Te,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,h;if(o&&v.has(o))return await v.get(o);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=(y=i.content.firstElementChild)==null?void 0:y.cloneNode(!0),d=a==null?void 0:a.querySelector("article"),f=a==null?void 0:a.querySelector("footer menu");if(!a||!d||!f)throw Error("Invalid alert dialog template");if(n&&n.split(/\s+/).forEach(s=>a==null?void 0:a.classList.add(s)),r){let s=document.createElement("header");s.append(r),(h=d.parentNode)==null||h.insertBefore(s,d)}d.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:ge,primary:me}of e){let pe=document.createElement("li"),b=document.createElement("button");b.value=ge,me&&b.classList.add("primary"),b.textContent=s,pe.appendChild(b),f.appendChild(b)}document.body.appendChild(a),a.showModal();let D=H(a).then(s=>(o&&v.has(o)&&v.delete(o),a&&document.body.removeChild(a),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 de(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 fe(e,t={}){await O(m({content:e,className:"alert-dialog-alert",buttons:[{label:u("OK"),value:"ok",primary:!0}]},t))}var Ee="2.11.6";return De(ze);})();
|
|
1
|
+
var af_common=(()=>{var A=Object.defineProperty,ye=Object.defineProperties,he=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable;var O=(e,t,o)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))k.call(t,o)&&O(e,o,t[o]);if(q)for(var o of q(t))xe.call(t,o)&&O(e,o,t[o]);return e},B=(e,t)=>ye(e,Se(t));var we=(e,t)=>{for(var o in t)A(e,o,{get:t[o],enumerable:!0})},ve=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of be(t))!k.call(e,r)&&r!==o&&A(e,r,{get:()=>t[r],enumerable:!(n=he(t,r))||n.enumerable});return e};var De=e=>ve(A({},"__esModule",{value:!0}),e);var l=(e,t,o)=>O(e,typeof t!="symbol"?t+"":t,o);var je={};we(je,{ConfirmButtons:()=>M,SessionHandler:()=>p,UserSession:()=>L,alert:()=>ce,confirm:()=>se,downloadBlob:()=>j,downloadRequest:()=>re,expose:()=>_,getLocalizedString:()=>u,getSessionData:()=>E,getSettings:()=>de,getUserImage:()=>U,invariant:()=>c,localStorage:()=>te,localize:()=>le,logActivity:()=>T,logError:()=>w,mitt:()=>I,openAlertDialog:()=>z,saveSettings:()=>fe,startActivity:()=>X,time:()=>G,toLocalDateTime:()=>oe,toLocalISODate:()=>ne,toLocalISODateTime:()=>$,version:()=>Ee,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(i=>{let a=()=>{this.eventHandler.off("onAuthenticated",a),t==null||t(),i()};this.eventHandler.on("onAuthenticated",a)}),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 i="/login?ReturnUrl=%2fapi/sessionexpired/remove";o!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):i="/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(i,'" 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 J,K,V,Z,Y=(Z=(K=(J=window.af)==null?void 0:J.article)==null?void 0:K.id)!=null?Z:(V=window.window)==null?void 0:V.location.pathname.substring(1).split("/")[0];async function T(e,t={},o=0){var n;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:Y,timeElapsed:o,action:e,parameters:B(g({},t),{_session:E()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((n=r.headers.get("Content-Type"))!=null&&n.includes("application/json")){let i=await r.json();console.error(i.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function X(e,t={}){let o=performance.now();return(n={})=>T(e,g(g({},t),n),performance.now()-o)}async function G(e){let t=performance.now();return[await e(),performance.now()-t]}async function w(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 W(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var F=Date.now(),Q=W(),b="",x="";if("document"in window){let e=()=>{var t,o,n,r,i,a;return T("AfSessionInit",{"appframe-core":(o=(t=window.af)==null?void 0:t.common)==null?void 0:o.version,"appframe-data":(r=(n=window.af)==null?void 0:n.data)==null?void 0:r.version,"app-version":(a=(i=window.af)==null?void 0:i.article)==null?void 0:a.version})};document.addEventListener("DOMContentLoaded",()=>{b=localStorage.getItem("_afDeviceId"),x=sessionStorage.getItem("_afSessionId"),b||(b=W(),localStorage.setItem("_afDeviceId",b)),x||(x=Q,sessionStorage.setItem("_afSessionId",x)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:Y,action:"AfSessionEnd",parameters:{_session:E()}})):e()})}function E(){return{browserSessionId:x,sessionStart:F,sessionLength:Date.now()-F,sessionId:Q,deviceId:b}}var P;(P=window.window)==null||P.addEventListener("error",e=>{typeof e=="object"&&"error"in e?w(e.error):typeof e=="object"&&"message"in e&&w(e)});function ee(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("."):ee(t)}get(t,o,n){let r=this.getLocalStorageKey(t,n),i=localStorage.getItem(r);return i!==null?JSON.parse(i):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=ee("");for(let o in localStorage)o.slice(0,t.length)===t&&localStorage.removeItem(o)}},te=new N;function ne(e){return e?$(e).substring(0,10):null}function m(e,t=2){return String(e).padStart(t,"0")}function $(e){return e?"".concat(e.getFullYear(),"-").concat(m(e.getMonth()+1),"-").concat(m(e.getDate()),"T").concat(m(e.getHours()),":").concat(m(e.getMinutes()),":").concat(m(e.getSeconds()),".").concat(m(e.getMilliseconds(),3)):null}function oe(e){return e?e.toISOString().substring(0,16):""}function j(e,t){return new Promise((o,n)=>{try{let r=URL.createObjectURL(e),i=document.body,a=document.createElement("a");a.setAttribute("download",t),a.href=r,i.append(a),a.click(),i.removeChild(a),setTimeout(()=>{URL.revokeObjectURL(r),o()},250)}catch(r){n(r)}})}function c(e,t){if(e)return;let o=typeof t=="function"?t():t;throw new Error(o!=null?o:"Invariant failed")}async function re(e,{fileName:t,signal:o,onProgress:n}){var i;let r=0;n==null||n({status:"requested"});try{let a=await fetch(e);if(!a.ok||!a.body){if((i=a.headers.get("content-type"))!=null&&i.includes("application/json")){let f=await a.json();c(!f.error,f.error)}throw new Error("".concat(a.status," ").concat(a.statusText))}try{let f=a.body.getReader(),D=new ReadableStream({start:y=>{function h(){return f.read().then(s=>{if(s.done){y.close();return}return r+=s.value.length,n==null||n({bytesReceived:r,status:"downloading"}),y.enqueue(s.value),h()})}return h()}});a=new Response(D)}catch(f){}let d=await a.blob();n==null||n({bytesReceived:r,status:"downloaded"}),await j(d,t),n==null||n({bytesReceived:r,status:"completed"})}catch(a){o!=null&&o.aborted?n==null||n({status:"cancelled"}):n==null||n({error:a.message,status:"error"})}}var Ae=/^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 R(e){var o;let t=e.toString().match(Ae);return c(t,"Unable to parse function!"),{name:(o=e.name)!=null?o:t[1],args:t[2].split(",").map(n=>n.trim()),body:t[3]}}function ie(){}ie.prototype=Object.create(null);var ae=ie;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 ae;return o}}}function _(e,t,o={}){if(Array.isArray(t))for(let n of t){let{name:r}=R(n);c(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),_(e,n)}else{let n,r;if(typeof t=="function"&&(n=R(t).name),typeof e=="string"){let i=e.split(".");n||(n=i[i.length-1],i=i.slice(0,i.length-1)),r=C(window,i)}else n&&(typeof e=="object"||typeof e=="function")?r=e:c(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");Object.hasOwn(r,n)&&(o==null?void 0:o.overwrite)!==!0?console.warn("".concat([e,n].join(".")," is already defined!")):r[n]=t}}async function Ie(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 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(!Object.hasOwn(af.article.i18n,e)){af.article.i18n[e]=e;let r=Ie(e).then(i=>(af.article.i18n[e]=i,i));if(t)return r}return af.article.i18n[e]}else return e}var Le={xs:64,sm:128,md:256,lg:512,xl:void 0};function U(e,t,o,n="xs"){if(e&&typeof e=="object")return U(e.primKey,e.login,e.hash,e.size);if(!e||!o)return"";let r=Le[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):"")}function le(e,...t){c(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let o=e.map((r,i)=>i===e.length-1?r:"".concat(r,"$").concat(i)).join(""),n=u(o);return t.forEach((r,i)=>{n=n.replace("$".concat(i),r)}),n}var Te='\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=Te,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 v=new Map;async function z({buttons:e,content:t,className:o,id:n,title:r}){var y,h;if(n&&v.has(n))return await v.get(n);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=(y=i.content.firstElementChild)==null?void 0:y.cloneNode(!0),d=a==null?void 0:a.querySelector("article"),f=a==null?void 0:a.querySelector("footer menu");if(!a||!d||!f)throw Error("Invalid alert dialog template");if(o)for(let s of o.split(/\s+/))a==null||a.classList.add(s);if(r){let s=document.createElement("header");s.append(r),(h=d.parentNode)==null||h.insertBefore(s,d)}d.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:pe,primary:ge}of e){let me=document.createElement("li"),S=document.createElement("button");S.value=pe,ge&&S.classList.add("primary"),S.textContent=s,me.appendChild(S),f.appendChild(S)}document.body.appendChild(a),a.showModal();let D=H(a).then(s=>(n&&v.has(n)&&v.delete(n),a&&document.body.removeChild(a),s));return n&&v.set(n,D),await D}var M=(o=>(o[o.YesNo=0]="YesNo",o[o.OkCancel=1]="OkCancel",o))(M||{});async function se(e,t={}){let{buttons:o=0,title:n}=t,r=o===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 z({content:e,buttons:r,className:"alert-dialog-confirm",title:n})==="yes"}async function ce(e,t={}){await z(g({content:e,className:"alert-dialog-alert",buttons:[{label:u("OK"),value:"ok",primary:!0}]},t))}function ue(e){var o,n,r,i,a,d;let t=(i=e!=null?e:(n=(o=window.af)==null?void 0:o.article)==null?void 0:n.id)!=null?i:(r=window.window)==null?void 0:r.location.pathname.substring(1).split("/")[0];return"".concat(t,".").concat((d=(a=window.af)==null?void 0:a.userSession.login)!=null?d:"anonymous")}function de(e,t){var r;if(!((r=window.af)!=null&&r.userSession))return null;let o=ue(t),n=JSON.parse(localStorage.getItem(o)||"{}");return e?n[e]||null:n}function fe(e,t,o){var i;if(!((i=window.af)!=null&&i.userSession))return;let n=ue(o),r=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(n,JSON.stringify(r))}var Ee="2.11.8";return De(je);})();
|
|
2
2
|
//# sourceMappingURL=af.common.legacy.min.js.map
|