@olenbetong/appframe-core 2.11.8 → 2.11.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,9 @@
1
- var af_common = (() => {
1
+ var af;
2
+ (af ||= {}).common = (() => {
2
3
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
7
  var __export = (target, all) => {
24
8
  for (var name in all)
25
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -33,7 +17,6 @@ var af_common = (() => {
33
17
  return to;
34
18
  };
35
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
20
 
38
21
  // src/index.ts
39
22
  var index_exports = {};
@@ -87,9 +70,7 @@ var af_common = (() => {
87
70
 
88
71
  // src/SessionHandler.ts
89
72
  var SessionHandler = class {
90
- constructor() {
91
- __publicField(this, "eventHandler", mitt_default());
92
- }
73
+ eventHandler = mitt_default();
93
74
  authenticated() {
94
75
  this.eventHandler.emit("onAuthenticated");
95
76
  }
@@ -98,7 +79,7 @@ var af_common = (() => {
98
79
  let authPromise = new Promise((resolve) => {
99
80
  let eventHandler = () => {
100
81
  this.eventHandler.off("onAuthenticated", eventHandler);
101
- callback == null ? void 0 : callback();
82
+ callback?.();
102
83
  resolve();
103
84
  };
104
85
  this.eventHandler.on("onAuthenticated", eventHandler);
@@ -117,7 +98,7 @@ var af_common = (() => {
117
98
  } else {
118
99
  link = "/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove";
119
100
  }
120
- dialog.innerHTML = '<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="'.concat(link, '" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>');
101
+ dialog.innerHTML = `<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${link}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`;
121
102
  document.body.append(dialog);
122
103
  dialog.showModal();
123
104
  await authPromise;
@@ -126,9 +107,9 @@ var af_common = (() => {
126
107
  await authPromise;
127
108
  }
128
109
  } catch (_) {
129
- window.location.href = "/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(
110
+ window.location.href = `/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(
130
111
  window.location.search
131
- ));
112
+ )}`;
132
113
  }
133
114
  }
134
115
  attachEvent(eventName, handler) {
@@ -141,51 +122,49 @@ var af_common = (() => {
141
122
 
142
123
  // src/UserSession.ts
143
124
  var UserSession = class extends SessionHandler {
125
+ amDesignator = "a.m.";
126
+ dayNames = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
127
+ dayNamesShort = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
128
+ decimalSeparator = ".";
129
+ domain = "OB";
130
+ email;
131
+ formats;
132
+ groupSeparator = null;
133
+ integratedSecurity = false;
134
+ isDeveloper = false;
135
+ login = "";
136
+ loginType;
137
+ monthNames = [
138
+ "january",
139
+ "february",
140
+ "march",
141
+ "april",
142
+ "may",
143
+ "june",
144
+ "july",
145
+ "august",
146
+ "september",
147
+ "october",
148
+ "november",
149
+ "december",
150
+ ""
151
+ ];
152
+ monthNamesShort = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""];
153
+ name;
154
+ pmDesignator = "p.m.";
155
+ shortDateFormat = "dd.MM.yyyy";
156
+ culture = "en-GB";
157
+ uiculture = "en-GB";
144
158
  constructor(userData) {
145
159
  super();
146
- __publicField(this, "amDesignator", "a.m.");
147
- __publicField(this, "dayNames", ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]);
148
- __publicField(this, "dayNamesShort", ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]);
149
- __publicField(this, "decimalSeparator", ".");
150
- __publicField(this, "domain", "OB");
151
- __publicField(this, "email");
152
- __publicField(this, "formats");
153
- __publicField(this, "groupSeparator", null);
154
- __publicField(this, "integratedSecurity", false);
155
- __publicField(this, "isDeveloper", false);
156
- __publicField(this, "login", "");
157
- __publicField(this, "loginType");
158
- __publicField(this, "monthNames", [
159
- "january",
160
- "february",
161
- "march",
162
- "april",
163
- "may",
164
- "june",
165
- "july",
166
- "august",
167
- "september",
168
- "october",
169
- "november",
170
- "december",
171
- ""
172
- ]);
173
- __publicField(this, "monthNamesShort", ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""]);
174
- __publicField(this, "name");
175
- __publicField(this, "pmDesignator", "p.m.");
176
- __publicField(this, "shortDateFormat", "dd.MM.yyyy");
177
- __publicField(this, "culture", "en-GB");
178
- __publicField(this, "uiculture", "en-GB");
179
160
  this.formats = {};
180
161
  Object.assign(this, userData);
181
162
  }
182
163
  };
183
164
 
184
165
  // src/log.ts
185
- var _a, _b, _c, _d;
186
- var article = (_d = (_b = (_a = window.af) == null ? void 0 : _a.article) == null ? void 0 : _b.id) != null ? _d : (_c = window.window) == null ? void 0 : _c.location.pathname.substring(1).split("/")[0];
166
+ var article = window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
187
167
  async function logActivity(activity, parameters = {}, timeElapsed = 0) {
188
- var _a3;
189
168
  try {
190
169
  let response = await fetch("/api/logging/log-activity", {
191
170
  method: "POST",
@@ -193,26 +172,27 @@ var af_common = (() => {
193
172
  article,
194
173
  timeElapsed,
195
174
  action: activity,
196
- parameters: __spreadProps(__spreadValues({}, parameters), {
175
+ parameters: {
176
+ ...parameters,
197
177
  _session: getSessionData()
198
- })
178
+ }
199
179
  }),
200
180
  headers: { "Content-Type": "application/json", Accept: "application/json" }
201
181
  });
202
182
  if (!response.ok) {
203
- if ((_a3 = response.headers.get("Content-Type")) == null ? void 0 : _a3.includes("application/json")) {
183
+ if (response.headers.get("Content-Type")?.includes("application/json")) {
204
184
  let data = await response.json();
205
185
  console.error(data.error);
206
186
  } else {
207
- console.error("".concat(response.status, " ").concat(response.statusText));
187
+ console.error(`${response.status} ${response.statusText}`);
208
188
  }
209
189
  }
210
- } catch (e) {
190
+ } catch {
211
191
  }
212
192
  }
213
193
  function startActivity(activity, startParameters = {}) {
214
194
  let start = performance.now();
215
- return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
195
+ return (endParameters = {}) => logActivity(activity, { ...startParameters, ...endParameters }, performance.now() - start);
216
196
  }
217
197
  async function time(callback) {
218
198
  let start = performance.now();
@@ -220,12 +200,11 @@ var af_common = (() => {
220
200
  return [returnValue, performance.now() - start];
221
201
  }
222
202
  async function logError(error) {
223
- var _a3;
224
203
  try {
225
204
  if (!error) return;
226
205
  let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
227
206
  error: error.message,
228
- stack: (_a3 = error.stack) != null ? _a3 : null
207
+ stack: error.stack ?? null
229
208
  } : { error: error.toString() } : { error: "Unspecified error" };
230
209
  console.error(error);
231
210
  let result = await fetch("/data/Logger/LogError", {
@@ -239,26 +218,22 @@ var af_common = (() => {
239
218
  return await result.json();
240
219
  }
241
220
  console.error(Error("Failed to log error"));
242
- } catch (e) {
221
+ } catch {
243
222
  }
244
223
  }
245
224
  function getSessionId() {
246
- var _a3;
247
- return (_a3 = crypto.randomUUID) == null ? void 0 : _a3.call(crypto);
225
+ return crypto.randomUUID?.();
248
226
  }
249
227
  var sessionStart = Date.now();
250
228
  var sessionId = getSessionId();
251
229
  var deviceId = "";
252
230
  var browserSessionId = "";
253
231
  if ("document" in window) {
254
- let startSession = () => {
255
- var _a3, _b2, _c2, _d2, _e, _f;
256
- return logActivity("AfSessionInit", {
257
- "appframe-core": (_b2 = (_a3 = window.af) == null ? void 0 : _a3.common) == null ? void 0 : _b2.version,
258
- "appframe-data": (_d2 = (_c2 = window.af) == null ? void 0 : _c2.data) == null ? void 0 : _d2.version,
259
- "app-version": (_f = (_e = window.af) == null ? void 0 : _e.article) == null ? void 0 : _f.version
260
- });
261
- };
232
+ let startSession = () => logActivity("AfSessionInit", {
233
+ "appframe-core": window.af?.common?.version,
234
+ "appframe-data": window.af?.data?.version,
235
+ "app-version": window.af?.article?.version
236
+ });
262
237
  document.addEventListener("DOMContentLoaded", () => {
263
238
  deviceId = localStorage.getItem("_afDeviceId");
264
239
  browserSessionId = sessionStorage.getItem("_afSessionId");
@@ -300,9 +275,8 @@ var af_common = (() => {
300
275
  }
301
276
 
302
277
  // src/errorHandler.ts
303
- var _a2;
304
278
  if (true) {
305
- (_a2 = window.window) == null ? void 0 : _a2.addEventListener("error", (event) => {
279
+ window.window?.addEventListener("error", (event) => {
306
280
  if (typeof event === "object" && "error" in event) {
307
281
  logError(event.error);
308
282
  } else if (typeof event === "object" && "message" in event) {
@@ -313,13 +287,10 @@ var af_common = (() => {
313
287
 
314
288
  // src/localStorage.ts
315
289
  function getLocalKey(key) {
316
- var _a3;
317
- return [((_a3 = af == null ? void 0 : af.article) == null ? void 0 : _a3.id) || "", "common", key].join(".");
290
+ return [af?.article?.id || "", "common", key].join(".");
318
291
  }
319
292
  var LocalStorage = class {
320
- constructor() {
321
- __publicField(this, "isPersisted", () => true);
322
- }
293
+ isPersisted = () => true;
323
294
  getLocalStorageKey(key, global) {
324
295
  return global ? ["common", key].join(".") : getLocalKey(key);
325
296
  }
@@ -359,9 +330,9 @@ var af_common = (() => {
359
330
  return String(num).padStart(digits, "0");
360
331
  }
361
332
  function toLocalISODateTime(date) {
362
- return date ? "".concat(date.getFullYear(), "-").concat(pad(date.getMonth() + 1), "-").concat(pad(date.getDate()), "T").concat(pad(date.getHours()), ":").concat(pad(
333
+ return date ? `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(
363
334
  date.getMinutes()
364
- ), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds(), 3)) : null;
335
+ )}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}` : null;
365
336
  }
366
337
  function toLocalDateTime(date) {
367
338
  return date ? date.toISOString().substring(0, 16) : "";
@@ -395,22 +366,21 @@ var af_common = (() => {
395
366
  return;
396
367
  }
397
368
  const provided = typeof message === "function" ? message() : message;
398
- throw new Error(provided != null ? provided : "Invariant failed");
369
+ throw new Error(provided ?? "Invariant failed");
399
370
  }
400
371
 
401
372
  // src/downloadRequest.ts
402
373
  async function downloadRequest(request, { fileName, signal, onProgress }) {
403
- var _a3;
404
374
  let bytesReceived = 0;
405
- onProgress == null ? void 0 : onProgress({ status: "requested" });
375
+ onProgress?.({ status: "requested" });
406
376
  try {
407
377
  let response = await fetch(request);
408
378
  if (!response.ok || !response.body) {
409
- if ((_a3 = response.headers.get("content-type")) == null ? void 0 : _a3.includes("application/json")) {
379
+ if (response.headers.get("content-type")?.includes("application/json")) {
410
380
  let data = await response.json();
411
381
  invariant(!data.error, data.error);
412
382
  }
413
- throw new Error("".concat(response.status, " ").concat(response.statusText));
383
+ throw new Error(`${response.status} ${response.statusText}`);
414
384
  }
415
385
  try {
416
386
  const reader = response.body.getReader();
@@ -423,7 +393,7 @@ var af_common = (() => {
423
393
  return;
424
394
  }
425
395
  bytesReceived += read.value.length;
426
- onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloading" });
396
+ onProgress?.({ bytesReceived, status: "downloading" });
427
397
  controller.enqueue(read.value);
428
398
  return pump();
429
399
  });
@@ -432,17 +402,17 @@ var af_common = (() => {
432
402
  }
433
403
  });
434
404
  response = new Response(stream);
435
- } catch (e) {
405
+ } catch {
436
406
  }
437
407
  const blob = await response.blob();
438
- onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloaded" });
408
+ onProgress?.({ bytesReceived, status: "downloaded" });
439
409
  await downloadBlob(blob, fileName);
440
- onProgress == null ? void 0 : onProgress({ bytesReceived, status: "completed" });
410
+ onProgress?.({ bytesReceived, status: "completed" });
441
411
  } catch (err) {
442
- if (signal == null ? void 0 : signal.aborted) {
443
- onProgress == null ? void 0 : onProgress({ status: "cancelled" });
412
+ if (signal?.aborted) {
413
+ onProgress?.({ status: "cancelled" });
444
414
  } else {
445
- onProgress == null ? void 0 : onProgress({ error: err.message, status: "error" });
415
+ onProgress?.({ error: err.message, status: "error" });
446
416
  }
447
417
  }
448
418
  }
@@ -450,10 +420,9 @@ var af_common = (() => {
450
420
  // src/parseFunc.ts
451
421
  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)*)\}$/;
452
422
  function parseFunc(func) {
453
- var _a3;
454
423
  const match = func.toString().match(funcRegex);
455
424
  invariant(match, "Unable to parse function!");
456
- return { name: (_a3 = func.name) != null ? _a3 : match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
425
+ return { name: func.name ?? match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
457
426
  }
458
427
 
459
428
  // src/Namespace.ts
@@ -507,8 +476,8 @@ var af_common = (() => {
507
476
  } else {
508
477
  invariant(false, "Invalid typeof parameter 'name', or unable to parse pValue!");
509
478
  }
510
- if (Object.hasOwn(namespace, keyName) && (options == null ? void 0 : options.overwrite) !== true) {
511
- console.warn("".concat([name, keyName].join("."), " is already defined!"));
479
+ if (Object.hasOwn(namespace, keyName) && options?.overwrite !== true) {
480
+ console.warn(`${[name, keyName].join(".")} is already defined!`);
512
481
  } else {
513
482
  namespace[keyName] = value;
514
483
  }
@@ -518,7 +487,7 @@ var af_common = (() => {
518
487
  // src/getLocalizedString.ts
519
488
  async function fetchLocalizedString(text) {
520
489
  try {
521
- let response = await fetch("/api/user/localize/new/".concat(af.article.id), {
490
+ let response = await fetch(`/api/user/localize/new/${af.article.id}`, {
522
491
  body: JSON.stringify({ text }),
523
492
  headers: {
524
493
  Accept: "application/json; */*",
@@ -530,19 +499,18 @@ var af_common = (() => {
530
499
  if (response.ok) {
531
500
  return await response.json();
532
501
  }
533
- } catch (e) {
502
+ } catch {
534
503
  }
535
504
  return text;
536
505
  }
537
506
  function getLocalizedString(string, wait) {
538
- var _a3, _b2;
539
507
  if (typeof string === "string" && string.trim().length === 0) {
540
508
  return string;
541
509
  }
542
510
  if (string === void 0 || string === "" || string === null) {
543
511
  return;
544
512
  }
545
- if (((_b2 = (_a3 = window.af) == null ? void 0 : _a3.article) == null ? void 0 : _b2.i18n) !== void 0) {
513
+ if (window.af?.article?.i18n !== void 0) {
546
514
  if (!Object.hasOwn(af.article.i18n, string)) {
547
515
  af.article.i18n[string] = string;
548
516
  let promise = fetchLocalizedString(string).then((text) => {
@@ -575,7 +543,7 @@ var af_common = (() => {
575
543
  return "";
576
544
  }
577
545
  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) : "");
546
+ return `/api/data/blob/EmployeesLookup/${primKeyOrOptions}/Image/${encodeURIComponent(login ?? "")}${login ? "." : ""}${encodeURIComponent(hash)}.jpg${sizePx ? `?width=${sizePx}` : ""}`;
579
547
  }
580
548
 
581
549
  // src/localize.ts
@@ -584,16 +552,25 @@ var af_common = (() => {
584
552
  Array.isArray(stringParts) && stringParts.length === args.length + 1,
585
553
  "Method 'localize' must be used as a tag function"
586
554
  );
587
- let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s : "".concat(s, "$").concat(i)).join("");
555
+ let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s : `${s}$${i}`).join("");
588
556
  let localized = getLocalizedString(stringToLocalize);
589
557
  args.forEach((arg, index) => {
590
- localized = localized.replace("$".concat(index), arg);
558
+ localized = localized.replace(`$${index}`, arg);
591
559
  });
592
560
  return localized;
593
561
  }
594
562
 
595
563
  // src/alert.ts
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';
564
+ var template = `
565
+ <dialog class="alert-dialog">
566
+ <form method="dialog">
567
+ <article></article>
568
+ <footer>
569
+ <menu></menu>
570
+ </footer>
571
+ </form>
572
+ </dialog>
573
+ `;
597
574
  if (window.document && !document.querySelector("#AlertDialogTemplate")) {
598
575
  let $template = document.createElement("template");
599
576
  $template.id = "AlertDialogTemplate";
@@ -623,25 +600,24 @@ var af_common = (() => {
623
600
  }
624
601
  var alertDialogPromiseMap = /* @__PURE__ */ new Map();
625
602
  async function openAlertDialog({ buttons, content, className, id, title }) {
626
- var _a3, _b2;
627
603
  if (id && alertDialogPromiseMap.has(id)) {
628
604
  return await alertDialogPromiseMap.get(id);
629
605
  }
630
606
  let $template = document.querySelector("#AlertDialogTemplate");
631
607
  if (!$template) throw Error("No alert dialog template found");
632
- let $dialog = (_a3 = $template.content.firstElementChild) == null ? void 0 : _a3.cloneNode(true);
633
- let $content = $dialog == null ? void 0 : $dialog.querySelector("article");
634
- let $menu = $dialog == null ? void 0 : $dialog.querySelector("footer menu");
608
+ let $dialog = $template.content.firstElementChild?.cloneNode(true);
609
+ let $content = $dialog?.querySelector("article");
610
+ let $menu = $dialog?.querySelector("footer menu");
635
611
  if (!$dialog || !$content || !$menu) throw Error("Invalid alert dialog template");
636
612
  if (className) {
637
613
  for (const className_ of className.split(/\s+/)) {
638
- $dialog == null ? void 0 : $dialog.classList.add(className_);
614
+ $dialog?.classList.add(className_);
639
615
  }
640
616
  }
641
617
  if (title) {
642
618
  let $header = document.createElement("header");
643
619
  $header.append(title);
644
- (_b2 = $content.parentNode) == null ? void 0 : _b2.insertBefore($header, $content);
620
+ $content.parentNode?.insertBefore($header, $content);
645
621
  }
646
622
  $content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
647
623
  for (let { label, value, primary } of buttons) {
@@ -687,22 +663,21 @@ var af_common = (() => {
687
663
  return result === "yes";
688
664
  }
689
665
  async function alert(prompt, options = {}) {
690
- await openAlertDialog(__spreadValues({
666
+ await openAlertDialog({
691
667
  content: prompt,
692
668
  className: "alert-dialog-alert",
693
- buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }]
694
- }, options));
669
+ buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }],
670
+ ...options
671
+ });
695
672
  }
696
673
 
697
674
  // src/settings.ts
698
675
  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");
676
+ const articleKey = article2 ?? window.af?.article?.id ?? window.window?.location.pathname.substring(1).split("/")[0];
677
+ return `${articleKey}.${window.af?.userSession.login ?? "anonymous"}`;
702
678
  }
703
679
  function getSettings(setting, article2) {
704
- var _a3;
705
- if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return null;
680
+ if (!window.af?.userSession) return null;
706
681
  const key = getKey(article2);
707
682
  const settings = JSON.parse(localStorage.getItem(key) || "{}");
708
683
  if (setting) {
@@ -711,8 +686,7 @@ var af_common = (() => {
711
686
  return settings;
712
687
  }
713
688
  function saveSettings(setting, value, article2) {
714
- var _a3;
715
- if (!((_a3 = window.af) == null ? void 0 : _a3.userSession)) return;
689
+ if (!window.af?.userSession) return;
716
690
  const key = getKey(article2);
717
691
  let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
718
692
  if (typeof value !== "undefined") {
@@ -724,6 +698,6 @@ var af_common = (() => {
724
698
  }
725
699
 
726
700
  // src/index.ts
727
- var version = "2.11.8";
701
+ var version = "2.11.9";
728
702
  return __toCommonJS(index_exports);
729
703
  })();
@@ -1,2 +1,11 @@
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);})();
1
+ var af;(af||={}).common=(()=>{var T=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var n in t)T(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of re(t))!ie.call(e,r)&&r!==n&&T(e,r,{get:()=>t[r],enumerable:!(o=ne(t,r))||o.enumerable});return e};var se=e=>le(T({},"__esModule",{value:!0}),e);var fe={};ae(fe,{ConfirmButtons:()=>C,SessionHandler:()=>g,UserSession:()=>v,alert:()=>G,confirm:()=>X,downloadBlob:()=>I,downloadRequest:()=>K,expose:()=>O,getLocalizedString:()=>c,getSessionData:()=>A,getSettings:()=>Q,getUserImage:()=>N,invariant:()=>s,localStorage:()=>B,localize:()=>Y,logActivity:()=>D,logError:()=>b,mitt:()=>w,openAlertDialog:()=>L,saveSettings:()=>ee,startActivity:()=>H,time:()=>M,toLocalDateTime:()=>J,toLocalISODate:()=>F,toLocalISODateTime:()=>j,version:()=>pe,waitForDialog:()=>R});function w(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{eventHandler=w();authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,n){try{let o=new Promise(i=>{let a=()=>{this.eventHandler.off("onAuthenticated",a),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="${i}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(r),r.showModal(),await o,r.remove()}}catch{window.location.href=`/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`}}attachEvent(t,n){return this.eventHandler.on(t,n)}detachEvent(t,n){return this.eventHandler.off(t,n)}};var v=class extends g{amDesignator="a.m.";dayNames=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];dayNamesShort=["sun","mon","tue","wed","thu","fri","sat"];decimalSeparator=".";domain="OB";email;formats;groupSeparator=null;integratedSecurity=!1;isDeveloper=!1;login="";loginType;monthNames=["january","february","march","april","may","june","july","august","september","october","november","december",""];monthNamesShort=["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""];name;pmDesignator="p.m.";shortDateFormat="dd.MM.yyyy";culture="en-GB";uiculture="en-GB";constructor(t){super(),this.formats={},Object.assign(this,t)}};var U=window.af?.article?.id??window.window?.location.pathname.substring(1).split("/")[0];async function D(e,t={},n=0){try{let o=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:U,timeElapsed:n,action:e,parameters:{...t,_session:A()}}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!o.ok)if(o.headers.get("Content-Type")?.includes("application/json")){let r=await o.json();console.error(r.error)}else console.error(`${o.status} ${o.statusText}`)}catch{}}function H(e,t={}){let n=performance.now();return(o={})=>D(e,{...t,...o},performance.now()-n)}async function M(e){let t=performance.now();return[await e(),performance.now()-t]}async function b(e){try{if(!e)return;let t=typeof e=="string"?{error:e}:typeof e=="object"?"message"in e?{error:e.message,stack:e.stack??null}:{error:e.toString()}:{error:"Unspecified error"};console.error(e);let n=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json; charset=utf-8"}});if(n.ok)return await n.json();console.error(Error("Failed to log error"))}catch{}}function k(){return crypto.randomUUID?.()}var _=Date.now(),P=k(),y="",h="";if("document"in window){let e=()=>D("AfSessionInit",{"appframe-core":window.af?.common?.version,"appframe-data":window.af?.data?.version,"app-version":window.af?.article?.version});document.addEventListener("DOMContentLoaded",()=>{y=localStorage.getItem("_afDeviceId"),h=sessionStorage.getItem("_afSessionId"),y||(y=k(),localStorage.setItem("_afDeviceId",y)),h||(h=P,sessionStorage.setItem("_afSessionId",h)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:U,action:"AfSessionEnd",parameters:{_session:A()}})):e()})}function A(){return{browserSessionId:h,sessionStart:_,sessionLength:Date.now()-_,sessionId:P,deviceId:y}}window.window?.addEventListener("error",e=>{typeof e=="object"&&"error"in e?b(e.error):typeof e=="object"&&"message"in e&&b(e)});function q(e){return[af?.article?.id||"","common",e].join(".")}var E=class{isPersisted=()=>!0;getLocalStorageKey(t,n){return n?["common",t].join("."):q(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=q("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},B=new E;function F(e){return e?j(e).substring(0,10):null}function d(e,t=2){return String(e).padStart(t,"0")}function j(e){return e?`${e.getFullYear()}-${d(e.getMonth()+1)}-${d(e.getDate())}T${d(e.getHours())}:${d(e.getMinutes())}:${d(e.getSeconds())}.${d(e.getMilliseconds(),3)}`:null}function J(e){return e?e.toISOString().substring(0,16):""}function I(e,t){return new Promise((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(()=>{URL.revokeObjectURL(r),n()},250)}catch(r){o(r)}})}function s(e,t){if(e)return;let n=typeof t=="function"?t():t;throw new Error(n??"Invariant failed")}async function K(e,{fileName:t,signal:n,onProgress:o}){let r=0;o?.({status:"requested"});try{let i=await fetch(e);if(!i.ok||!i.body){if(i.headers.get("content-type")?.includes("application/json")){let u=await i.json();s(!u.error,u.error)}throw new Error(`${i.status} ${i.statusText}`)}try{let u=i.body.getReader(),x=new ReadableStream({start:p=>{function l(){return u.read().then(f=>{if(f.done){p.close();return}return r+=f.value.length,o?.({bytesReceived:r,status:"downloading"}),p.enqueue(f.value),l()})}return l()}});i=new Response(x)}catch{}let a=await i.blob();o?.({bytesReceived:r,status:"downloaded"}),await I(a,t),o?.({bytesReceived:r,status:"completed"})}catch(i){n?.aborted?o?.({status:"cancelled"}):o?.({error:i.message,status:"error"})}}var ce=/^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 z(e){let t=e.toString().match(ce);return s(t,"Unable to parse function!"),{name:e.name??t[1],args:t[2].split(",").map(n=>n.trim()),body:t[3]}}function V(){}V.prototype=Object.create(null);var Z=V;function $(e,t){if(typeof e=="object"){if(typeof t=="string"){let n=t.split(".");return $(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 Z;return n}}}function O(e,t,n={}){if(Array.isArray(t))for(let o of t){let{name:r}=z(o);s(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),O(e,o)}else{let o,r;if(typeof t=="function"&&(o=z(t).name),typeof e=="string"){let i=e.split(".");o||(o=i[i.length-1],i=i.slice(0,i.length-1)),r=$(window,i)}else o&&(typeof e=="object"||typeof e=="function")?r=e:s(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");Object.hasOwn(r,o)&&n?.overwrite!==!0?console.warn(`${[e,o].join(".")} is already defined!`):r[o]=t}}async function ue(e){try{let t=await fetch(`/api/user/localize/new/${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{}return e}function c(e,t){if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(window.af?.article?.i18n!==void 0){if(!Object.hasOwn(af.article.i18n,e)){af.article.i18n[e]=e;let n=ue(e).then(o=>(af.article.i18n[e]=o,o));if(t)return n}return af.article.i18n[e]}else return e}var ge={xs:64,sm:128,md:256,lg:512,xl:void 0};function N(e,t,n,o="xs"){if(e&&typeof e=="object")return N(e.primKey,e.login,e.hash,e.size);if(!e||!n)return"";let r=ge[o];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t??"")}${t?".":""}${encodeURIComponent(n)}.jpg${r?`?width=${r}`:""}`}function Y(e,...t){s(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:`${r}$${i}`).join(""),o=c(n);return t.forEach((r,i)=>{o=o.replace(`$${i}`,r)}),o}var de=`
2
+ <dialog class="alert-dialog">
3
+ <form method="dialog">
4
+ <article></article>
5
+ <footer>
6
+ <menu></menu>
7
+ </footer>
8
+ </form>
9
+ </dialog>
10
+ `;if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=de,document.body.append(e)}function R(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 S=new Map;async function L({buttons:e,content:t,className:n,id:o,title:r}){if(o&&S.has(o))return await S.get(o);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=i.content.firstElementChild?.cloneNode(!0),u=a?.querySelector("article"),x=a?.querySelector("footer menu");if(!a||!u||!x)throw Error("Invalid alert dialog template");if(n)for(let l of n.split(/\s+/))a?.classList.add(l);if(r){let l=document.createElement("header");l.append(r),u.parentNode?.insertBefore(l,u)}u.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:l,value:f,primary:te}of e){let oe=document.createElement("li"),m=document.createElement("button");m.value=f,te&&m.classList.add("primary"),m.textContent=l,oe.appendChild(m),x.appendChild(m)}document.body.appendChild(a),a.showModal();let p=R(a).then(l=>(o&&S.has(o)&&S.delete(o),a&&document.body.removeChild(a),l));return o&&S.set(o,p),await p}var C=(n=>(n[n.YesNo=0]="YesNo",n[n.OkCancel=1]="OkCancel",n))(C||{});async function X(e,t={}){let{buttons:n=0,title:o}=t,r=n===1?[{label:c("OK"),value:"yes",primary:!0},{label:c("Cancel"),value:"no"}]:[{label:c("Yes"),value:"yes",primary:!0},{label:c("No"),value:"no"}];return await L({content:e,buttons:r,className:"alert-dialog-confirm",title:o})==="yes"}async function G(e,t={}){await L({content:e,className:"alert-dialog-alert",buttons:[{label:c("OK"),value:"ok",primary:!0}],...t})}function W(e){return`${e??window.af?.article?.id??window.window?.location.pathname.substring(1).split("/")[0]}.${window.af?.userSession.login??"anonymous"}`}function Q(e,t){if(!window.af?.userSession)return null;let n=W(t),o=JSON.parse(localStorage.getItem(n)||"{}");return e?o[e]||null:o}function ee(e,t,n){if(!window.af?.userSession)return;let o=W(n),r=JSON.parse(localStorage.getItem(o)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(o,JSON.stringify(r))}var pe="2.11.9";return se(fe);})();
2
11
  //# sourceMappingURL=af.common.legacy.min.js.map