@olenbetong/appframe-core 2.0.0 → 2.0.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.
@@ -1,3 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
3
+ var __publicField = (obj, key2, value) => {
4
+ __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
5
+ return value;
6
+ };
7
+
1
8
  // src/errorHandler.ts
2
9
  window.addEventListener("error", (event) => {
3
10
  try {
@@ -42,8 +49,8 @@ function mitt_default(n) {
42
49
  // src/getLocalizedString.ts
43
50
  async function getLocalizedStringAsync(string) {
44
51
  try {
45
- let response = await fetch("/api/user/localize", {
46
- body: JSON.stringify({ string }),
52
+ let response = await fetch(`/api/user/localize`, {
53
+ body: JSON.stringify({ string, ArticleID: af.article.id }),
47
54
  headers: {
48
55
  Accept: "application/json; */*",
49
56
  "Content-Type": "application/json",
@@ -113,17 +120,11 @@ function addDeveloperUtils() {
113
120
  if (string) {
114
121
  const escaped = string.replace(/'/g, "\\'");
115
122
  if (forCustomRoute) {
116
- const localized = afGetLocalizedString(string).replaceAll(
117
- /'/g,
118
- "\\'"
119
- );
123
+ const localized = afGetLocalizedString(string).replaceAll(/'/g, "\\'");
120
124
  strings.push(`'${escaped}': '${localized}',`);
121
125
  } else {
122
126
  strings.push(
123
- `s['${escaped}'] = @Html(@context.AddLocalizableString("${string.replaceAll(
124
- '"',
125
- '\\"'
126
- )}"));`
127
+ `s['${escaped}'] = @Html(@context.AddLocalizableString("${string.replaceAll('"', '\\"')}"));`
127
128
  );
128
129
  }
129
130
  }
@@ -162,11 +163,9 @@ function getLocalizedString(string) {
162
163
 
163
164
  // src/SessionHandler.ts
164
165
  var _SessionHandler = class {
165
- constructor() {
166
- this.eventHandler = mitt_default();
167
- this.showingDialog = false;
168
- this.dialog = null;
169
- }
166
+ eventHandler = mitt_default();
167
+ showingDialog = false;
168
+ dialog = null;
170
169
  expired(callback) {
171
170
  af.userSession = af.userSession || {
172
171
  login: null
@@ -299,24 +298,35 @@ var _SessionHandler = class {
299
298
  }
300
299
  };
301
300
  var SessionHandler = _SessionHandler;
302
- SessionHandler.messages = {
301
+ __publicField(SessionHandler, "messages", {
303
302
  login: "Log in",
304
303
  relog: "Session expired - log in"
305
- };
304
+ });
306
305
 
307
306
  // src/UserSession.ts
308
307
  var UserSession = class extends SessionHandler {
308
+ amDesignator = "a.m.";
309
+ dayNames = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
310
+ dayNamesShort = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
311
+ decimalSeparator = ".";
312
+ domain = "OB";
313
+ email;
314
+ formats;
315
+ groupSeparator = null;
316
+ integratedSecurity = false;
317
+ isDeveloper = false;
318
+ login = "";
319
+ loginType;
320
+ monthNames = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", ""];
321
+ monthNamesShort = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""];
322
+ name;
323
+ pmDesignator = "p.m.";
324
+ shortDateFormat = "dd.MM.yyyy";
325
+ culture = "en-GB";
326
+ uiculture = "en-GB";
327
+ expired = () => null;
309
328
  constructor(userData) {
310
329
  super();
311
- this.decimalSeparator = ".";
312
- this.domain = "OB";
313
- this.groupSeparator = null;
314
- this.shortDateFormat = "dd.MM.yyyy";
315
- this.login = "";
316
- this.isDeveloper = false;
317
- this.culture = "en-GB";
318
- this.uiculture = "en-GB";
319
- this.expired = () => null;
320
330
  this.formats = {};
321
331
  Object.assign(this, userData);
322
332
  }
@@ -559,7 +569,7 @@ function saveSettings(setting, value, article) {
559
569
  }
560
570
 
561
571
  // src/index.ts
562
- var version = "2.0.0";
572
+ var version = "2.0.2";
563
573
  export {
564
574
  SessionHandler,
565
575
  UserSession,
@@ -14,6 +14,10 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
+ var __publicField = (obj, key2, value) => {
18
+ __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
19
+ return value;
20
+ };
17
21
 
18
22
  // src/errorHandler.ts
19
23
  window.addEventListener("error", (event) => {
@@ -60,8 +64,8 @@ function mitt_default(n) {
60
64
  // src/getLocalizedString.ts
61
65
  async function getLocalizedStringAsync(string) {
62
66
  try {
63
- let response = await fetch("/api/user/localize", {
64
- body: JSON.stringify({ string }),
67
+ let response = await fetch(`/api/user/localize`, {
68
+ body: JSON.stringify({ string, ArticleID: af.article.id }),
65
69
  headers: {
66
70
  Accept: "application/json; */*",
67
71
  "Content-Type": "application/json",
@@ -132,17 +136,11 @@ function addDeveloperUtils() {
132
136
  if (string) {
133
137
  const escaped = string.replace(/'/g, "\\'");
134
138
  if (forCustomRoute) {
135
- const localized = afGetLocalizedString(string).replaceAll(
136
- /'/g,
137
- "\\'"
138
- );
139
+ const localized = afGetLocalizedString(string).replaceAll(/'/g, "\\'");
139
140
  strings.push(`'${escaped}': '${localized}',`);
140
141
  } else {
141
142
  strings.push(
142
- `s['${escaped}'] = @Html(@context.AddLocalizableString("${string.replaceAll(
143
- '"',
144
- '\\"'
145
- )}"));`
143
+ `s['${escaped}'] = @Html(@context.AddLocalizableString("${string.replaceAll('"', '\\"')}"));`
146
144
  );
147
145
  }
148
146
  }
@@ -182,9 +180,9 @@ function getLocalizedString(string) {
182
180
  // src/SessionHandler.ts
183
181
  var _SessionHandler = class {
184
182
  constructor() {
185
- this.eventHandler = mitt_default();
186
- this.showingDialog = false;
187
- this.dialog = null;
183
+ __publicField(this, "eventHandler", mitt_default());
184
+ __publicField(this, "showingDialog", false);
185
+ __publicField(this, "dialog", null);
188
186
  }
189
187
  expired(callback) {
190
188
  af.userSession = af.userSession || {
@@ -318,24 +316,35 @@ var _SessionHandler = class {
318
316
  }
319
317
  };
320
318
  var SessionHandler = _SessionHandler;
321
- SessionHandler.messages = {
319
+ __publicField(SessionHandler, "messages", {
322
320
  login: "Log in",
323
321
  relog: "Session expired - log in"
324
- };
322
+ });
325
323
 
326
324
  // src/UserSession.ts
327
325
  var UserSession = class extends SessionHandler {
328
326
  constructor(userData) {
329
327
  super();
330
- this.decimalSeparator = ".";
331
- this.domain = "OB";
332
- this.groupSeparator = null;
333
- this.shortDateFormat = "dd.MM.yyyy";
334
- this.login = "";
335
- this.isDeveloper = false;
336
- this.culture = "en-GB";
337
- this.uiculture = "en-GB";
338
- this.expired = () => null;
328
+ __publicField(this, "amDesignator", "a.m.");
329
+ __publicField(this, "dayNames", ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]);
330
+ __publicField(this, "dayNamesShort", ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]);
331
+ __publicField(this, "decimalSeparator", ".");
332
+ __publicField(this, "domain", "OB");
333
+ __publicField(this, "email");
334
+ __publicField(this, "formats");
335
+ __publicField(this, "groupSeparator", null);
336
+ __publicField(this, "integratedSecurity", false);
337
+ __publicField(this, "isDeveloper", false);
338
+ __publicField(this, "login", "");
339
+ __publicField(this, "loginType");
340
+ __publicField(this, "monthNames", ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", ""]);
341
+ __publicField(this, "monthNamesShort", ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""]);
342
+ __publicField(this, "name");
343
+ __publicField(this, "pmDesignator", "p.m.");
344
+ __publicField(this, "shortDateFormat", "dd.MM.yyyy");
345
+ __publicField(this, "culture", "en-GB");
346
+ __publicField(this, "uiculture", "en-GB");
347
+ __publicField(this, "expired", () => null);
339
348
  this.formats = {};
340
349
  Object.assign(this, userData);
341
350
  }
@@ -580,7 +589,7 @@ function saveSettings(setting, value, article) {
580
589
  }
581
590
 
582
591
  // src/index.ts
583
- var version = "2.0.0";
592
+ var version = "2.0.2";
584
593
  export {
585
594
  SessionHandler,
586
595
  UserSession,
@@ -1,4 +1,4 @@
1
- var D=Object.defineProperty;var N=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var j=(t,e,n)=>e in t?D(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,T=(t,e)=>{for(var n in e||(e={}))C.call(e,n)&&j(t,n,e[n]);if(N)for(var n of N(e))P.call(e,n)&&j(t,n,e[n]);return t};window.addEventListener("error",t=>{var e,n,r,o,a,s,i;try{let u={error:(r=(n=(e=t.error)==null?void 0:e.message)!=null?n:t.message)!=null?r:null,file:t.filename,line:(o=t.lineno)!=null?o:0,column:(a=t.colno)!=null?a:0,stack:(i=(s=t.error)==null?void 0:s.stack)!=null?i:null};fetch("/data/Logger/LogError",{body:JSON.stringify(u),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(u){}});function x(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(o){o(n)}),(r=t.get("*"))&&r.slice().map(function(o){o(e,n)})}}}async function M(t){try{let e=await fetch("/api/user/localize",{body:JSON.stringify({string:t}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(e.ok)return await e.json()}catch(e){}return t}function O(t,e){var n;if(((n=af==null?void 0:af.article)==null?void 0:n.i18n)!==void 0){if(!Object.prototype.hasOwnProperty.call(af.article.i18n,t)){af.article.i18n[t]=t;let r=M(t).then(o=>(af.article.i18n[t]=o,o));if(e)return r}return af.article.i18n[t]}else return t}var h="__UNLOCALIZED_STRINGS__",m=window[h]||new Set;window[h]||(window[h]=m);function k(){document.readyState!=="loading"&&(R(),document.removeEventListener("readystatechange",k))}document.readyState!=="loading"?R():document.addEventListener("readystatechange",k);function U(){let{af:t}=window;return t&&t.userSession&&t.userSession.isDeveloper}function R(){if(U()){if(typeof window.__doNothingWithStrings=="function"){let t=window.__doNothingWithStrings();for(let e of Object.keys(t))m.add(e)}window[h]||(window[h]=m),window.__getUnlocalizedStrings||(window.__getUnlocalizedStrings=function(t){let e=[];for(let n of m)if(n){let r=n.replace(/'/g,"\\'");if(t){let o=O(n).replaceAll(/'/g,"\\'");e.push(`'${r}': '${o}',`)}else e.push(`s['${r}'] = @Html(@context.AddLocalizableString("${n.replaceAll('"','\\"')}"));`)}return t?`// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used
1
+ var C=Object.defineProperty;var T=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var E=(t,e,n)=>e in t?C(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,O=(t,e)=>{for(var n in e||(e={}))P.call(e,n)&&E(t,n,e[n]);if(T)for(var n of T(e))M.call(e,n)&&E(t,n,e[n]);return t};var i=(t,e,n)=>(E(t,typeof e!="symbol"?e+"":e,n),n);window.addEventListener("error",t=>{var e,n,r,o,l,a,s;try{let f={error:(r=(n=(e=t.error)==null?void 0:e.message)!=null?n:t.message)!=null?r:null,file:t.filename,line:(o=t.lineno)!=null?o:0,column:(l=t.colno)!=null?l:0,stack:(s=(a=t.error)==null?void 0:a.stack)!=null?s:null};fetch("/data/Logger/LogError",{body:JSON.stringify(f),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(f){}});function L(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(o){o(n)}),(r=t.get("*"))&&r.slice().map(function(o){o(e,n)})}}}async function U(t){try{let e=await fetch("/api/user/localize",{body:JSON.stringify({string:t,ArticleID:af.article.id}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(e.ok)return await e.json()}catch(e){}return t}function R(t,e){var n;if(((n=af==null?void 0:af.article)==null?void 0:n.i18n)!==void 0){if(!Object.prototype.hasOwnProperty.call(af.article.i18n,t)){af.article.i18n[t]=t;let r=U(t).then(o=>(af.article.i18n[t]=o,o));if(e)return r}return af.article.i18n[t]}else return t}var w="__UNLOCALIZED_STRINGS__",y=window[w]||new Set;window[w]||(window[w]=y);function k(){document.readyState!=="loading"&&(z(),document.removeEventListener("readystatechange",k))}document.readyState!=="loading"?z():document.addEventListener("readystatechange",k);function K(){let{af:t}=window;return t&&t.userSession&&t.userSession.isDeveloper}function z(){if(K()){if(typeof window.__doNothingWithStrings=="function"){let t=window.__doNothingWithStrings();for(let e of Object.keys(t))y.add(e)}window[w]||(window[w]=y),window.__getUnlocalizedStrings||(window.__getUnlocalizedStrings=function(t){let e=[];for(let n of y)if(n){let r=n.replace(/'/g,"\\'");if(t){let o=R(n).replaceAll(/'/g,"\\'");e.push(`'${r}': '${o}',`)}else e.push(`s['${r}'] = @Html(@context.AddLocalizableString("${n.replaceAll('"','\\"')}"));`)}return t?`// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used
2
2
  if (af.userSession.uiculture === 'nb-NO') {
3
3
  const strings = {
4
4
  ${e.join(`
@@ -16,23 +16,23 @@ ${e.join(`
16
16
  `)}
17
17
  return s;
18
18
  }
19
- <\/script>`})}}function y(t){let e=O(t);return e===t&&!m.has(t)&&m.add(t),e}var w=class{constructor(){this.eventHandler=x();this.showingDialog=!1;this.dialog=null}expired(e){if(af.userSession=af.userSession||{login:null},typeof e!="function")throw new TypeError("Parameter pCallback passed to the expired function must be a function!");let n=()=>{this.detachEvent("onAuthenticated",n),e()};if(this.attachEvent("onAuthenticated",n),this.showingDialog!==!0){this.showingDialog=!0;let r=document.createElement("div");r.className="session-expired-container",r.innerHTML=`
19
+ <\/script>`})}}function h(t){let e=R(t);return e===t&&!y.has(t)&&y.add(t),e}var b=class{constructor(){i(this,"eventHandler",L());i(this,"showingDialog",!1);i(this,"dialog",null)}expired(e){if(af.userSession=af.userSession||{login:null},typeof e!="function")throw new TypeError("Parameter pCallback passed to the expired function must be a function!");let n=()=>{this.detachEvent("onAuthenticated",n),e()};if(this.attachEvent("onAuthenticated",n),this.showingDialog!==!0){this.showingDialog=!0;let r=document.createElement("div");r.className="session-expired-container",r.innerHTML=`
20
20
  <div class="session-expired-log-in" style="margin-top: 20px;">
21
21
  <div class="row">
22
22
  <div class="sessionExpired">
23
23
  <h4 class="message">Frakoblet - tidsavbrudd</h4>
24
24
  <div class="form-group">
25
- <label for="username">${y("Username")}</label>
25
+ <label for="username">${h("Username")}</label>
26
26
  <input type="text" class="form-control" id="username" autofocus>
27
27
  </div>
28
28
  <div class="form-group">
29
- <label for="password">${y("Password")}</label>
29
+ <label for="password">${h("Password")}</label>
30
30
  <input type="password" autocomplete="password" class="form-control" id="password" >
31
31
  </div>
32
32
  <div class="form-group">
33
33
  <div>
34
34
  <button type="submit" class="btn btn-default sign-in">
35
- ${y("Log in")}
35
+ ${h("Log in")}
36
36
  </button>
37
37
  </div>
38
38
  </div>
@@ -44,5 +44,5 @@ return s;
44
44
  </div>
45
45
  </div>
46
46
  </div>
47
- `;let o=af.userSession.login?w.messages.relog:w.messages.login,a=r.querySelector(".message"),s=r.querySelector(".alert-warning"),i=r.querySelector("input[type=text]"),u=r.querySelector(".sign-in"),l=r.querySelector("input[type=password]");if(a!==null&&i!==null&&s!==null&&i!==null&&u!==null&&l!==null){a.innerText=y(o),i.value=af.userSession.login||"",i.disabled=!!af.userSession.login,i.readOnly=!!af.userSession.login,document.body.appendChild(r);let f=async()=>{l.disabled=!0;let c=new Request("/login",{body:JSON.stringify({username:i.value,password:l.value,remember:!1}),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"});try{let d=await(await fetch(c)).json();if(d.success)document.body.removeChild(r),this.showingDialog=!1,this.eventHandler.emit("onAuthenticated"),s.parentNode&&(s.parentNode.style.display="none");else throw new Error(d.error)}catch(p){if(p&&typeof p=="object"){let d=p;l.disabled=!1,l.classList.toggle("invalid",!0),l.value="",l.focus(),s.innerText=d.message?d.message:String(d),s.parentNode&&(s.parentNode.style.display="initial")}}};u.addEventListener("click",f),l.addEventListener("keyup",c=>{c.key==="Enter"&&f()}),l.addEventListener("change",c=>{c.key==="Enter"&&f()}),i.addEventListener("keyup",c=>{c.key==="Enter"&&f()}),i.addEventListener("change",c=>{c.key==="Enter"&&f()}),l.focus()}}}attachEvent(e,n){return this.eventHandler.on(e,n)}detachEvent(e,n){return this.eventHandler.off(e,n)}},g=w;g.messages={login:"Log in",relog:"Session expired - log in"};var S=class extends g{constructor(n){super();this.decimalSeparator=".";this.domain="OB";this.groupSeparator=null;this.shortDateFormat="dd.MM.yyyy";this.login="";this.isDeveloper=!1;this.culture="en-GB";this.uiculture="en-GB";this.expired=()=>null;this.formats={},Object.assign(this,n)}};function E(t,e){return new Promise(function(n,r){try{let o=URL.createObjectURL(t),a=document.body,s=document.createElement("a");s.setAttribute("download",e),s.href=o,a.append(s),s.click(),a.removeChild(s),setTimeout(function(){URL.revokeObjectURL(o),n()},250)}catch(o){r(o)}})}async function re(t,{fileName:e,signal:n,onProgress:r}){var s;function o(i){typeof r=="function"&&r(T({},i))}let a=0;o({status:"requested"});try{let i=await fetch(t);if(!i.ok||!i.body){if((s=i.headers.get("content-type"))!=null&&s.includes("application/json")){let l=await i.json();if(l.error)throw new Error(l.error)}throw new Error(`${i.status} ${i.statusText}`)}try{let l=i.body.getReader(),f=new ReadableStream({start:function(c){function p(){return l.read().then(function(d){if(d.done){c.close();return}return a+=d.value.length,o({bytesReceived:a,status:"downloading"}),c.enqueue(d.value),p()})}return p()}});i=new Response(f)}catch(l){console.warn("Failed to replace response stream to log download progress.")}let u=await i.blob();o({bytesReceived:a,status:"downloaded"}),await E(u,e),o({bytesReceived:a,status:"completed"})}catch(i){n!=null&&n.aborted?o({status:"cancelled"}):o({error:i.message,status:"error"})}}function z(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var K=/^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 b(t){var e=t.toString().match(K);if(e===null)throw new TypeError("Unable to parse function!");return{name:e[1],args:e[2].split(","),body:e[3]}}function I(){}I.prototype=Object.create(null);var H=I;function v(t,e){if(typeof t=="object")if(typeof e=="string"){let n=e.split(".");return v(t,n)}else if(Array.isArray(e)){let n=t;for(let r=0;r<e.length;r++)n=n[e[r]]=n[e[r]]||new H;return n}else throw new TypeError("Invalid type of parameter 'namespace'");else throw new TypeError("Invalid type of parameter 'root'")}function L(t,e){console.warn(t)}function _(t,e){if(arguments.length!==2)throw new Error("Incorrect number of arguments passed to the expose function!");if(Array.isArray(e))for(let n of e){let{name:r}=b(n);if(r)_(t,n);else throw new Error("Unable to detect name of function! Name it, or only supply one function and include name in first parameter.")}else{let n,r;if(typeof e=="function"&&(n=b(e).name),typeof t=="string"){let o=t.split(".");n||(n=o[o.length-1],o=o.slice(0,o.length-1)),r=v(window,o)}else if(n&&(typeof t=="object"||typeof t=="function"))r=t;else throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");z(r,n)?L([t,n].join(".")+" is already defined!"):r[n]=e}}function q(t){var e;return[((e=af==null?void 0:af.article)==null?void 0:e.id)||"","common",t].join(".")}var A=class{isPersisted(){return!0}getLocalStorageKey(e,n){return n?["common",e].join("."):q(e)}get(e,n,r){let o=this.getLocalStorageKey(e,r),a=localStorage.getItem(o);return a!==null?JSON.parse(a):n}set(e,n,r){localStorage.setItem(this.getLocalStorageKey(e,r),JSON.stringify(n))}remove(e,n){let r=this.getLocalStorageKey(e,n);return localStorage.getItem(r)!==null?(localStorage.removeItem(r),!0):!1}clear(){let e=q("");for(let n in localStorage)n.slice(0,e.length)===e&&localStorage.removeItem(n)}},W=new A;function $(t){return`${t||af.article.id}.${af.userSession.login}`}function we(t,e){if(!(af!=null&&af.userSession))return null;let n=$(e),r=JSON.parse(localStorage.getItem(n)||"{}");return t?r[t]||null:r}function Se(t,e,n){if(!(af!=null&&af.userSession))return;let r=$(n),o=JSON.parse(localStorage.getItem(r)||"{}");typeof e<"u"?o[t]=e:o=t,localStorage.setItem(r,JSON.stringify(o))}var Ee="2.0.0";export{g as SessionHandler,S as UserSession,E as downloadBlob,re as downloadRequest,_ as expose,y as getLocalizedString,we as getSettings,z as has,W as localStorage,x as mitt,Se as saveSettings,Ee as version};
47
+ `;let o=af.userSession.login?b.messages.relog:b.messages.login,l=r.querySelector(".message"),a=r.querySelector(".alert-warning"),s=r.querySelector("input[type=text]"),f=r.querySelector(".sign-in"),c=r.querySelector("input[type=password]");if(l!==null&&s!==null&&a!==null&&s!==null&&f!==null&&c!==null){l.innerText=h(o),s.value=af.userSession.login||"",s.disabled=!!af.userSession.login,s.readOnly=!!af.userSession.login,document.body.appendChild(r);let g=async()=>{c.disabled=!0;let d=new Request("/login",{body:JSON.stringify({username:s.value,password:c.value,remember:!1}),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"});try{let u=await(await fetch(d)).json();if(u.success)document.body.removeChild(r),this.showingDialog=!1,this.eventHandler.emit("onAuthenticated"),a.parentNode&&(a.parentNode.style.display="none");else throw new Error(u.error)}catch(p){if(p&&typeof p=="object"){let u=p;c.disabled=!1,c.classList.toggle("invalid",!0),c.value="",c.focus(),a.innerText=u.message?u.message:String(u),a.parentNode&&(a.parentNode.style.display="initial")}}};f.addEventListener("click",g),c.addEventListener("keyup",d=>{d.key==="Enter"&&g()}),c.addEventListener("change",d=>{d.key==="Enter"&&g()}),s.addEventListener("keyup",d=>{d.key==="Enter"&&g()}),s.addEventListener("change",d=>{d.key==="Enter"&&g()}),c.focus()}}}attachEvent(e,n){return this.eventHandler.on(e,n)}detachEvent(e,n){return this.eventHandler.off(e,n)}},m=b;i(m,"messages",{login:"Log in",relog:"Session expired - log in"});var S=class extends m{constructor(n){super();i(this,"amDesignator","a.m.");i(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);i(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);i(this,"decimalSeparator",".");i(this,"domain","OB");i(this,"email");i(this,"formats");i(this,"groupSeparator",null);i(this,"integratedSecurity",!1);i(this,"isDeveloper",!1);i(this,"login","");i(this,"loginType");i(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);i(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);i(this,"name");i(this,"pmDesignator","p.m.");i(this,"shortDateFormat","dd.MM.yyyy");i(this,"culture","en-GB");i(this,"uiculture","en-GB");i(this,"expired",()=>null);this.formats={},Object.assign(this,n)}};function _(t,e){return new Promise(function(n,r){try{let o=URL.createObjectURL(t),l=document.body,a=document.createElement("a");a.setAttribute("download",e),a.href=o,l.append(a),a.click(),l.removeChild(a),setTimeout(function(){URL.revokeObjectURL(o),n()},250)}catch(o){r(o)}})}async function se(t,{fileName:e,signal:n,onProgress:r}){var a;function o(s){typeof r=="function"&&r(O({},s))}let l=0;o({status:"requested"});try{let s=await fetch(t);if(!s.ok||!s.body){if((a=s.headers.get("content-type"))!=null&&a.includes("application/json")){let c=await s.json();if(c.error)throw new Error(c.error)}throw new Error(`${s.status} ${s.statusText}`)}try{let c=s.body.getReader(),g=new ReadableStream({start:function(d){function p(){return c.read().then(function(u){if(u.done){d.close();return}return l+=u.value.length,o({bytesReceived:l,status:"downloading"}),d.enqueue(u.value),p()})}return p()}});s=new Response(g)}catch(c){console.warn("Failed to replace response stream to log download progress.")}let f=await s.blob();o({bytesReceived:l,status:"downloaded"}),await _(f,e),o({bytesReceived:l,status:"completed"})}catch(s){n!=null&&n.aborted?o({status:"cancelled"}):o({error:s.message,status:"error"})}}function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var W=/^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 v(t){var e=t.toString().match(W);if(e===null)throw new TypeError("Unable to parse function!");return{name:e[1],args:e[2].split(","),body:e[3]}}function H(){}H.prototype=Object.create(null);var q=H;function x(t,e){if(typeof t=="object")if(typeof e=="string"){let n=e.split(".");return x(t,n)}else if(Array.isArray(e)){let n=t;for(let r=0;r<e.length;r++)n=n[e[r]]=n[e[r]]||new q;return n}else throw new TypeError("Invalid type of parameter 'namespace'");else throw new TypeError("Invalid type of parameter 'root'")}function A(t,e){console.warn(t)}function N(t,e){if(arguments.length!==2)throw new Error("Incorrect number of arguments passed to the expose function!");if(Array.isArray(e))for(let n of e){let{name:r}=v(n);if(r)N(t,n);else throw new Error("Unable to detect name of function! Name it, or only supply one function and include name in first parameter.")}else{let n,r;if(typeof e=="function"&&(n=v(e).name),typeof t=="string"){let o=t.split(".");n||(n=o[o.length-1],o=o.slice(0,o.length-1)),r=x(window,o)}else if(n&&(typeof t=="object"||typeof t=="function"))r=t;else throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");I(r,n)?A([t,n].join(".")+" is already defined!"):r[n]=e}}function D(t){var e;return[((e=af==null?void 0:af.article)==null?void 0:e.id)||"","common",t].join(".")}var j=class{isPersisted(){return!0}getLocalStorageKey(e,n){return n?["common",e].join("."):D(e)}get(e,n,r){let o=this.getLocalStorageKey(e,r),l=localStorage.getItem(o);return l!==null?JSON.parse(l):n}set(e,n,r){localStorage.setItem(this.getLocalStorageKey(e,r),JSON.stringify(n))}remove(e,n){let r=this.getLocalStorageKey(e,n);return localStorage.getItem(r)!==null?(localStorage.removeItem(r),!0):!1}clear(){let e=D("");for(let n in localStorage)n.slice(0,e.length)===e&&localStorage.removeItem(n)}},F=new j;function $(t){return`${t||af.article.id}.${af.userSession.login}`}function ve(t,e){if(!(af!=null&&af.userSession))return null;let n=$(e),r=JSON.parse(localStorage.getItem(n)||"{}");return t?r[t]||null:r}function xe(t,e,n){if(!(af!=null&&af.userSession))return;let r=$(n),o=JSON.parse(localStorage.getItem(r)||"{}");typeof e<"u"?o[t]=e:o=t,localStorage.setItem(r,JSON.stringify(o))}var Ae="2.0.2";export{m as SessionHandler,S as UserSession,_ as downloadBlob,se as downloadRequest,N as expose,h as getLocalizedString,ve as getSettings,I as has,F as localStorage,L as mitt,xe as saveSettings,Ae as version};
48
48
  //# sourceMappingURL=af.common.legacy.min.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errorHandler.ts", "../../../../node_modules/mitt/src/index.ts", "../../src/getLocalizedString.ts", "../../src/SessionHandler.ts", "../../src/UserSession.ts", "../../src/downloadBlob.ts", "../../src/downloadRequest.ts", "../../src/has.ts", "../../src/parseFunc.ts", "../../src/Namespace.ts", "../../src/requireNamespace.ts", "../../src/warn.ts", "../../src/expose.ts", "../../src/localStorage.ts", "../../src/settings.ts", "../../src/index.ts"],
4
- "sourcesContent": ["window.addEventListener(\"error\", (event) => {\n try {\n // Try to avoid error-logging-loop\n const data = {\n error: event.error?.message ?? event.message ?? null,\n file: event.filename,\n line: event.lineno ?? 0,\n column: event.colno ?? 0,\n stack: event.error?.stack ?? null,\n };\n\n fetch(\"/data/Logger/LogError\", {\n body: JSON.stringify(data),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"X-Requested-With\": \"XMLHttpRequest\",\n },\n method: \"POST\",\n });\n } catch (ex) {\n // ignore\n }\n});\n", "export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = unknown> = (event: T) => void;\nexport type WildcardHandler<T = Record<string, unknown>> = (\n\ttype: keyof T,\n\tevent: T[keyof T]\n) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList<T = unknown> = Array<Handler<T>>;\nexport type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<\n\tkeyof Events | '*',\n\tEventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>\n>;\n\nexport interface Emitter<Events extends Record<EventType, unknown>> {\n\tall: EventHandlerMap<Events>;\n\n\ton<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;\n\ton(type: '*', handler: WildcardHandler<Events>): void;\n\n\toff<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;\n\toff(type: '*', handler: WildcardHandler<Events>): void;\n\n\temit<Key extends keyof Events>(type: Key, event: Events[Key]): void;\n\temit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt<Events extends Record<EventType, unknown>>(\n\tall?: EventHandlerMap<Events>\n): Emitter<Events> {\n\ttype GenericEventHandler =\n\t\t| Handler<Events[keyof Events]>\n\t\t| WildcardHandler<Events>;\n\tall = all || new Map();\n\n\treturn {\n\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `'*'` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<Key extends keyof Events>(type: Key, handler: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.push(handler);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tall!.set(type, [handler] as EventHandlerList<Events[keyof Events]>);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * If `handler` is omitted, all handlers of the given type are removed.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from, or `'*'`\n\t\t * @param {Function} [handler] Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<Key extends keyof Events>(type: Key, handler?: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\tif (handler) {\n\t\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tall!.set(type, []);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `'*'` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing '*' handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<Key extends keyof Events>(type: Key, evt?: Events[Key]) {\n\t\t\tlet handlers = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as EventHandlerList<Events[keyof Events]>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(evt!);\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\thandlers = all!.get('*');\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as WildCardEventHandlerList<Events>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(type, evt!);\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n}\n", "async function getLocalizedStringAsync(string: string) {\n try {\n let response = await fetch(\"/api/user/localize\", {\n body: JSON.stringify({ string }),\n headers: {\n Accept: \"application/json; */*\",\n \"Content-Type\": \"application/json\",\n \"X-Requested-With\": \"XMLHttpRequest\",\n },\n method: \"POST\",\n });\n\n if (response.ok) {\n return (await response.json()) as string;\n }\n } catch (error) {}\n\n return string;\n}\n\nfunction afGetLocalizedString(string: string): string;\nfunction afGetLocalizedString(string: string, wait: false): string;\nfunction afGetLocalizedString(string: string, wait: true): Promise<string>;\nfunction afGetLocalizedString(\n string: string,\n wait?: boolean\n): string | Promise<string> {\n if (af?.article?.i18n !== undefined) {\n if (!Object.prototype.hasOwnProperty.call(af.article.i18n, string)) {\n af.article.i18n[string] = string;\n\n let promise = getLocalizedStringAsync(string).then((text) => {\n af.article.i18n[string] = text;\n return text;\n });\n\n if (wait) {\n return promise;\n }\n }\n\n return af.article.i18n[string];\n } else {\n return string;\n }\n}\n\ndeclare global {\n interface Window {\n __UNLOCALIZED_STRINGS__: Set<string>;\n __doNothingWithStrings?: () => Record<string, string>;\n __getUnlocalizedStrings?: (forCustomRoute?: boolean) => string;\n }\n}\n\nconst key = \"__UNLOCALIZED_STRINGS__\";\nconst localizeSet = window[key] || new Set();\n\nif (!window[key]) {\n window[key] = localizeSet;\n}\n\nfunction handleReadyStateChange() {\n if (document.readyState !== \"loading\") {\n addDeveloperUtils();\n document.removeEventListener(\"readystatechange\", handleReadyStateChange);\n }\n}\n\nif (document.readyState !== \"loading\") {\n addDeveloperUtils();\n} else {\n document.addEventListener(\"readystatechange\", handleReadyStateChange);\n}\n\nfunction isDeveloper() {\n const { af } = window;\n\n return af && af.userSession && af.userSession.isDeveloper;\n}\n\nfunction addDeveloperUtils() {\n if (isDeveloper()) {\n if (typeof window.__doNothingWithStrings === \"function\") {\n const addedStrings = window.__doNothingWithStrings();\n\n for (let string of Object.keys(addedStrings)) {\n localizeSet.add(string);\n }\n }\n\n if (!window[key]) {\n window[key] = localizeSet;\n }\n\n if (!window.__getUnlocalizedStrings) {\n window.__getUnlocalizedStrings = function (forCustomRoute) {\n const strings = [];\n\n for (let string of localizeSet) {\n if (string) {\n const escaped = string.replace(/'/g, \"\\\\'\");\n if (forCustomRoute) {\n const localized = afGetLocalizedString(string).replaceAll(\n /'/g,\n \"\\\\'\"\n );\n strings.push(`'${escaped}': '${localized}',`);\n } else {\n strings.push(\n `s['${escaped}'] = @Html(@context.AddLocalizableString(\"${string.replaceAll(\n '\"',\n '\\\\\"'\n )}\"));`\n );\n }\n }\n }\n\n if (forCustomRoute) {\n return `// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used\nif (af.userSession.uiculture === 'nb-NO') {\n\tconst strings = {\n\t\t${strings.join(\"\\n\\t\\t\")}\n\t};\n\taf.article.i18n = af.article.i18n || {};\n\tObject.assign(af.article.i18n, strings);\n}`;\n }\n\n return `<script type=\"text/javascript\">\nfunction __doNothingWithStrings() {\n@{\n\tvar context = @Appframe.Web.Context.RequestContext.Current;\n}\nlet s = {};\n${strings.join(\"\\n\")}\nreturn s;\n}\n</script>`;\n };\n }\n }\n}\n\nexport function getLocalizedString(string: string) {\n const localized = afGetLocalizedString(string);\n if (localized === string && !localizeSet.has(string)) {\n localizeSet.add(string);\n }\n\n return localized;\n}\n", "import mitt, { Emitter, Handler } from \"mitt\";\nimport { getLocalizedString } from \"./getLocalizedString.js\";\n\ntype SessionHandlerEvent = \"onExpired\" | \"onAuthenticated\";\n\nexport default class SessionHandler {\n static messages = {\n login: \"Log in\",\n relog: \"Session expired - log in\"\n };\n\n private eventHandler: Emitter<{ onAuthenticated: void; onExpired: void }> = mitt();\n private showingDialog = false;\n private dialog = null;\n\n expired(callback: Function) {\n af.userSession = af.userSession || {\n login: null\n };\n\n if (typeof callback !== \"function\") {\n throw new TypeError(\"Parameter pCallback passed to the expired function must be a function!\");\n }\n\n const once = () => {\n this.detachEvent(\"onAuthenticated\", once);\n callback();\n };\n\n this.attachEvent(\"onAuthenticated\", once);\n\n if (this.showingDialog !== true) {\n this.showingDialog = true;\n const contentContainer = document.createElement(\"div\");\n contentContainer.className = \"session-expired-container\";\n contentContainer.innerHTML = `\n<div class=\"session-expired-log-in\" style=\"margin-top: 20px;\">\n <div class=\"row\">\n <div class=\"sessionExpired\">\n <h4 class=\"message\">Frakoblet - tidsavbrudd</h4>\n <div class=\"form-group\">\n <label for=\"username\">${getLocalizedString(\"Username\")}</label>\n <input type=\"text\" class=\"form-control\" id=\"username\" autofocus>\n </div>\n <div class=\"form-group\">\n <label for=\"password\">${getLocalizedString(\"Password\")}</label>\n <input type=\"password\" autocomplete=\"password\" class=\"form-control\" id=\"password\" >\n </div>\n <div class=\"form-group\">\n <div>\n <button type=\"submit\" class=\"btn btn-default sign-in\">\n ${getLocalizedString(\"Log in\")}\n </button>\n </div>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"\" style=\"display:none; margin: 0px 30px;\">\n <div class=\"alert alert-warning\" role=\"alert\" style=\"margin-top:10px;\"></div> \n </div>\n </div>\n</div>\n`;\n const message = af.userSession.login ? SessionHandler.messages.relog : SessionHandler.messages.login;\n\n const messageElem = contentContainer.querySelector(\".message\") as HTMLHeadingElement;\n const statusElem = contentContainer.querySelector(\".alert-warning\") as HTMLDivElement;\n const userElem = contentContainer.querySelector(\"input[type=text]\") as HTMLInputElement;\n const signInElem = contentContainer.querySelector(\".sign-in\") as HTMLButtonElement;\n const passwordElem = contentContainer.querySelector(\"input[type=password]\") as HTMLInputElement;\n\n if (\n messageElem !== null &&\n userElem !== null &&\n statusElem !== null &&\n userElem !== null &&\n signInElem !== null &&\n passwordElem !== null\n ) {\n messageElem.innerText = getLocalizedString(message);\n\n userElem.value = af.userSession.login || \"\";\n userElem.disabled = !!af.userSession.login;\n userElem.readOnly = !!af.userSession.login;\n\n document.body.appendChild(contentContainer);\n\n const doLogin = async () => {\n passwordElem.disabled = true;\n\n const request = new Request(\"/login\", {\n body: JSON.stringify({\n username: userElem.value,\n password: passwordElem.value,\n remember: false\n }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"X-Requested-With\": \"XMLHttpRequest\"\n },\n method: \"POST\"\n });\n\n try {\n const response = await fetch(request);\n const json = await response.json();\n\n if (json.success) {\n document.body.removeChild(contentContainer);\n this.showingDialog = false;\n this.eventHandler.emit(\"onAuthenticated\");\n\n if (statusElem.parentNode) {\n (statusElem.parentNode as HTMLElement).style.display = \"none\";\n }\n } else {\n throw new Error(json.error);\n }\n } catch (err) {\n if (err && typeof err === \"object\") {\n let error = err as Error;\n passwordElem.disabled = false;\n passwordElem.classList.toggle(\"invalid\", true);\n passwordElem.value = \"\";\n passwordElem.focus();\n statusElem.innerText = error.message ? error.message : String(error);\n\n if (statusElem.parentNode) {\n (statusElem.parentNode as HTMLElement).style.display = \"initial\";\n }\n }\n }\n };\n\n signInElem.addEventListener(\"click\", doLogin);\n\n passwordElem.addEventListener(\"keyup\", evt => {\n if (evt.key === \"Enter\") {\n doLogin();\n }\n });\n\n passwordElem.addEventListener(\"change\", evt => {\n if ((evt as KeyboardEvent).key === \"Enter\") {\n doLogin();\n }\n });\n\n userElem.addEventListener(\"keyup\", evt => {\n if (evt.key === \"Enter\") {\n doLogin();\n }\n });\n\n userElem.addEventListener(\"change\", evt => {\n if ((evt as KeyboardEvent).key === \"Enter\") {\n doLogin();\n }\n });\n\n passwordElem.focus();\n }\n }\n }\n\n attachEvent(eventName: SessionHandlerEvent, handler: Handler) {\n return this.eventHandler.on(eventName, handler);\n }\n\n detachEvent(eventName: SessionHandlerEvent, handler: Handler) {\n return this.eventHandler.off(eventName, handler);\n }\n}\n", "import SessionHandler from \"./SessionHandler.js\";\n\nexport default class UserSession extends SessionHandler {\n decimalSeparator: string = \".\";\n domain: string = \"OB\";\n formats: any;\n groupSeparator: string | null = null;\n shortDateFormat: string = \"dd.MM.yyyy\";\n login: string = \"\";\n isDeveloper: boolean = false;\n culture: string = \"en-GB\";\n uiculture: string = \"en-GB\";\n expired: (callback: () => void) => void = () => null;\n\n constructor(userData: any) {\n super();\n this.formats = {};\n Object.assign(this, userData);\n }\n}\n", "export function downloadBlob(blob: Blob | MediaSource, fileName: string) {\n return new Promise<void>(function (resolve, reject) {\n try {\n const url = URL.createObjectURL(blob);\n const parent = document.body;\n const anchor = document.createElement(\"a\");\n anchor.setAttribute(\"download\", fileName);\n anchor.href = url;\n parent.append(anchor);\n anchor.click();\n parent.removeChild(anchor);\n\n setTimeout(function () {\n URL.revokeObjectURL(url);\n resolve();\n }, 250);\n } catch (ex) {\n reject(ex);\n }\n });\n}\n", "import { downloadBlob } from \"./downloadBlob.js\";\n\nexport type DownloadItem = {\n status: \"cancelled\" | \"error\" | \"requested\" | \"downloading\" | \"downloaded\" | \"completed\";\n bytesReceived?: number;\n error?: string;\n};\n\nexport type DownloadParameters = {\n signal?: AbortSignal;\n fileName: string;\n onProgress?: (progress: DownloadItem) => void;\n};\n\nexport async function downloadRequest(request: Request, { fileName, signal, onProgress }: DownloadParameters) {\n function reportProgress(progress: DownloadItem) {\n if (typeof onProgress === \"function\") {\n onProgress({ ...progress });\n }\n }\n\n let bytesReceived = 0;\n\n reportProgress({ status: \"requested\" });\n\n try {\n let response = await fetch(request);\n\n if (!response.ok || !response.body) {\n if (response.headers.get(\"content-type\")?.includes(\"application/json\")) {\n let data = await response.json();\n if (data.error) {\n throw new Error(data.error);\n }\n }\n throw new Error(`${response.status} ${response.statusText}`);\n }\n\n try {\n const reader = response.body.getReader();\n const stream = new ReadableStream({\n start: function (controller) {\n function pump(): Promise<void> {\n return reader.read().then(function (read) {\n if (read.done) {\n controller.close();\n return;\n }\n\n bytesReceived += read.value.length;\n reportProgress({ bytesReceived, status: \"downloading\" });\n controller.enqueue(read.value);\n\n return pump();\n });\n }\n\n return pump();\n },\n });\n\n response = new Response(stream);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn(\"Failed to replace response stream to log download progress.\");\n }\n\n const blob = await response.blob();\n\n reportProgress({ bytesReceived, status: \"downloaded\" });\n\n await downloadBlob(blob, fileName);\n\n reportProgress({ bytesReceived, status: \"completed\" });\n } catch (err) {\n if (signal?.aborted) {\n reportProgress({ status: \"cancelled\" });\n } else {\n reportProgress({ error: (err as Error).message, status: \"error\" });\n }\n }\n}\n", "export function has(\n obj: any,\n key: string | number | symbol\n): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n", "const 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)*)\\}$/;\n\nexport default function parseFunc(func: Function) {\n var match = func.toString().match(funcRegex);\n if (match === null) {\n throw new TypeError(\"Unable to parse function!\");\n }\n return { name: match[1], args: match[2].split(\",\"), body: match[3] };\n}\n", "function Namespace() {}\nNamespace.prototype = Object.create(null);\n\nexport default Namespace;\n", "import Namespace from \"./Namespace.js\";\n\nexport default function requireNamespace(\n root: any,\n namespace: string | Array<string>\n): any {\n if (typeof root === \"object\") {\n if (typeof namespace === \"string\") {\n let path = namespace.split(\".\");\n\n return requireNamespace(root, path);\n } else if (Array.isArray(namespace)) {\n let current: any = root;\n for (let i = 0; i < namespace.length; i++) {\n current = current[namespace[i]] =\n current[namespace[i]] || new (Namespace as any)();\n }\n\n return current;\n } else {\n throw new TypeError(\"Invalid type of parameter 'namespace'\");\n }\n } else {\n throw new TypeError(\"Invalid type of parameter 'root'\");\n }\n}\n", "/* eslint-disable no-console */\nexport default function warn(message: string, fallbackToAlert?: boolean) {\n console.warn(message);\n}\n", "import { has } from \"./has.js\";\nimport parseFunc from \"./parseFunc.js\";\nimport requireNamespace from \"./requireNamespace.js\";\nimport warn from \"./warn.js\";\n\n/**\n * Expose a value to a potentially deeply nested global variable\n * @param name {string | object} Either a dot-separated path to the global variable, or an object to expose the value on\n * @param value {object | Function | Function[]} The value(s) to expose\n */\nexport default function expose(name: object | string, value: object | Function | Function[]): void {\n if (arguments.length !== 2) {\n throw new Error(\"Incorrect number of arguments passed to the expose function!\");\n }\n\n if (Array.isArray(value)) {\n for (let func of value) {\n const { name: funcName } = parseFunc(func);\n\n if (funcName) {\n expose(name, func); // Expose func on namespace found in pName\n } else {\n throw new Error(\n \"Unable to detect name of function! Name it, or only supply one function and include name in first parameter.\"\n );\n }\n }\n } else {\n let keyName: string | undefined;\n let namespace;\n\n if (typeof value === \"function\") {\n keyName = parseFunc(value).name;\n }\n\n if (typeof name === \"string\") {\n let pathParts = name.split(\".\");\n\n if (!keyName) {\n keyName = pathParts[pathParts.length - 1];\n pathParts = pathParts.slice(0, pathParts.length - 1);\n }\n\n namespace = requireNamespace(window, pathParts);\n } else if (keyName && (typeof name === \"object\" || typeof name === \"function\")) {\n namespace = name;\n } else {\n throw new TypeError(\"Invalid typeof parameter 'name', or unable to parse pValue!\");\n }\n\n if (has(namespace, keyName)) {\n // If class is already defined, warn or show an alert\n warn([name, keyName].join(\".\") + \" is already defined!\");\n } else {\n namespace[keyName] = value;\n }\n }\n}\n", "function getLocalKey(key: string): string {\n return [af?.article?.id || \"\", \"common\", key].join(\".\");\n}\n\nclass LocalStorage {\n isPersisted() {\n return true;\n }\n\n getLocalStorageKey(key: string, global?: boolean) {\n return global ? [\"common\", key].join(\".\") : getLocalKey(key);\n }\n\n get(key: string, defaultValue: unknown, global?: boolean) {\n const lsKey = this.getLocalStorageKey(key, global);\n const value = localStorage.getItem(lsKey);\n\n return value !== null ? JSON.parse(value) : defaultValue;\n }\n\n set(key: string, value: unknown, global?: boolean) {\n localStorage.setItem(\n this.getLocalStorageKey(key, global),\n JSON.stringify(value)\n );\n }\n\n remove(key: string, global?: boolean) {\n const lsKey = this.getLocalStorageKey(key, global);\n if (localStorage.getItem(lsKey) !== null) {\n localStorage.removeItem(lsKey);\n return true;\n } else {\n return false;\n }\n }\n\n clear() {\n const baseKey = getLocalKey(\"\");\n\n for (let key in localStorage) {\n if (key.slice(0, baseKey.length) === baseKey) {\n localStorage.removeItem(key);\n }\n }\n }\n}\n\nexport default new LocalStorage();\n", "function getKey(article?: string) {\n const articleKey = article || af.article.id;\n return `${articleKey}.${af.userSession.login}`;\n}\n\nexport function getSettings<T>(setting: string, article?: string): T | null {\n if (!af?.userSession) return null;\n\n const key = getKey(article);\n const settings = JSON.parse(localStorage.getItem(key) || \"{}\");\n\n if (setting) {\n return settings[setting] || null;\n }\n\n return settings;\n}\n\nexport function saveSettings<T>(\n setting: string,\n value: T | null,\n article?: string\n): void {\n if (!af?.userSession) return;\n\n const key = getKey(article);\n let userSettings = JSON.parse(localStorage.getItem(key) || \"{}\");\n\n if (typeof value !== \"undefined\") {\n userSettings[setting] = value;\n } else {\n userSettings = setting;\n }\n\n localStorage.setItem(key, JSON.stringify(userSettings));\n}\n", "import \"./errorHandler.js\";\n\nimport UserSession from \"./UserSession.js\";\n\nexport { default as mitt } from \"mitt\";\nexport { downloadBlob } from \"./downloadBlob.js\";\nexport * from \"./downloadRequest.js\";\nexport { default as expose } from \"./expose.js\";\nexport { getLocalizedString } from \"./getLocalizedString.js\";\nexport * from \"./has.js\";\nexport { default as localStorage } from \"./localStorage.js\";\nexport { default as SessionHandler } from \"./SessionHandler.js\";\nexport { UserSession };\nexport * from \"./settings.js\";\n\nexport const version = __VERSION__;\n\ndeclare global {\n var __VERSION__: string;\n var __DEV__: number;\n var af: AfCore;\n\n interface Window {\n af: AfCore;\n }\n}\n\nexport interface AfArticle {\n hostName: string;\n i18n: Record<string, string>;\n id: string;\n}\n\nexport interface AfCore {\n article: AfArticle;\n common?: {\n getLocalizedString?: (string: string) => string;\n };\n controls?: {\n alert?: (message: string, callback?: () => void) => void;\n confirm?: (options: {\n title: string;\n message: string;\n buttons: string[];\n callback: (button: number) => void;\n }) => void;\n };\n userSession: UserSession;\n}\n"],
5
- "mappings": "yVAAA,OAAO,iBAAiB,QAAUA,GAAU,CAA5C,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACE,GAAI,CAEF,IAAMC,EAAO,CACX,OAAOL,GAAAD,GAAAD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Aa,QAAQJ,CAAG,GAAK,IAAI,EAE3D,OAAOG,EAAU,IACnBC,EAAaL,GAAWI,EAExBC,EAAeL,EAGjB,aAAa,QAAQC,EAAK,KAAK,UAAUI,CAAY,CAAC,CACxD,CCpBO,IAAMC,GAAU",
6
- "names": ["event", "_a", "_b", "_c", "_d", "_e", "_f", "_g", "data", "ex", "all", "Map", "on", "type", "handler", "handlers", "get", "push", "set", "off", "splice", "indexOf", "emit", "evt", "slice", "map", "getLocalizedStringAsync", "string", "response", "error", "afGetLocalizedString", "wait", "_a", "promise", "text", "key", "localizeSet", "handleReadyStateChange", "addDeveloperUtils", "isDeveloper", "af", "addedStrings", "forCustomRoute", "strings", "escaped", "localized", "getLocalizedString", "_SessionHandler", "mitt_default", "callback", "once", "contentContainer", "getLocalizedString", "message", "messageElem", "statusElem", "userElem", "signInElem", "passwordElem", "doLogin", "request", "json", "err", "error", "evt", "eventName", "handler", "SessionHandler", "UserSession", "SessionHandler", "userData", "downloadBlob", "blob", "fileName", "resolve", "reject", "url", "parent", "anchor", "ex", "downloadRequest", "request", "fileName", "signal", "onProgress", "_a", "reportProgress", "progress", "__spreadValues", "bytesReceived", "response", "data", "reader", "stream", "controller", "pump", "read", "error", "blob", "downloadBlob", "err", "has", "obj", "key", "funcRegex", "parseFunc", "func", "match", "Namespace", "Namespace_default", "requireNamespace", "root", "namespace", "path", "current", "i", "Namespace_default", "warn", "message", "fallbackToAlert", "expose", "name", "value", "func", "funcName", "parseFunc", "keyName", "namespace", "pathParts", "requireNamespace", "has", "warn", "getLocalKey", "key", "_a", "LocalStorage", "global", "defaultValue", "lsKey", "value", "baseKey", "localStorage_default", "getKey", "article", "getSettings", "setting", "key", "settings", "saveSettings", "value", "userSettings", "version"]
4
+ "sourcesContent": ["window.addEventListener(\"error\", (event) => {\n try {\n // Try to avoid error-logging-loop\n const data = {\n error: event.error?.message ?? event.message ?? null,\n file: event.filename,\n line: event.lineno ?? 0,\n column: event.colno ?? 0,\n stack: event.error?.stack ?? null,\n };\n\n fetch(\"/data/Logger/LogError\", {\n body: JSON.stringify(data),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"X-Requested-With\": \"XMLHttpRequest\",\n },\n method: \"POST\",\n });\n } catch (ex) {\n // ignore\n }\n});\n", "export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = unknown> = (event: T) => void;\nexport type WildcardHandler<T = Record<string, unknown>> = (\n\ttype: keyof T,\n\tevent: T[keyof T]\n) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList<T = unknown> = Array<Handler<T>>;\nexport type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<\n\tkeyof Events | '*',\n\tEventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>\n>;\n\nexport interface Emitter<Events extends Record<EventType, unknown>> {\n\tall: EventHandlerMap<Events>;\n\n\ton<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;\n\ton(type: '*', handler: WildcardHandler<Events>): void;\n\n\toff<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;\n\toff(type: '*', handler: WildcardHandler<Events>): void;\n\n\temit<Key extends keyof Events>(type: Key, event: Events[Key]): void;\n\temit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt<Events extends Record<EventType, unknown>>(\n\tall?: EventHandlerMap<Events>\n): Emitter<Events> {\n\ttype GenericEventHandler =\n\t\t| Handler<Events[keyof Events]>\n\t\t| WildcardHandler<Events>;\n\tall = all || new Map();\n\n\treturn {\n\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `'*'` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<Key extends keyof Events>(type: Key, handler: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.push(handler);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tall!.set(type, [handler] as EventHandlerList<Events[keyof Events]>);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * If `handler` is omitted, all handlers of the given type are removed.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from, or `'*'`\n\t\t * @param {Function} [handler] Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<Key extends keyof Events>(type: Key, handler?: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\tif (handler) {\n\t\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tall!.set(type, []);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `'*'` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing '*' handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<Key extends keyof Events>(type: Key, evt?: Events[Key]) {\n\t\t\tlet handlers = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as EventHandlerList<Events[keyof Events]>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(evt!);\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\thandlers = all!.get('*');\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as WildCardEventHandlerList<Events>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(type, evt!);\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n}\n", "async function getLocalizedStringAsync(string: string) {\n try {\n let response = await fetch(`/api/user/localize`, {\n body: JSON.stringify({ string, ArticleID: af.article.id }),\n headers: {\n Accept: \"application/json; */*\",\n \"Content-Type\": \"application/json\",\n \"X-Requested-With\": \"XMLHttpRequest\",\n },\n method: \"POST\",\n });\n\n if (response.ok) {\n return (await response.json()) as string;\n }\n } catch (error) {}\n\n return string;\n}\n\nfunction afGetLocalizedString(string: string): string;\nfunction afGetLocalizedString(string: string, wait: false): string;\nfunction afGetLocalizedString(string: string, wait: true): Promise<string>;\nfunction afGetLocalizedString(string: string, wait?: boolean): string | Promise<string> {\n if (af?.article?.i18n !== undefined) {\n if (!Object.prototype.hasOwnProperty.call(af.article.i18n, string)) {\n af.article.i18n[string] = string;\n\n let promise = getLocalizedStringAsync(string).then((text) => {\n af.article.i18n[string] = text;\n return text;\n });\n\n if (wait) {\n return promise;\n }\n }\n\n return af.article.i18n[string];\n } else {\n return string;\n }\n}\n\ndeclare global {\n interface Window {\n __UNLOCALIZED_STRINGS__: Set<string>;\n __doNothingWithStrings?: () => Record<string, string>;\n __getUnlocalizedStrings?: (forCustomRoute?: boolean) => string;\n }\n}\n\nconst key = \"__UNLOCALIZED_STRINGS__\";\nconst localizeSet = window[key] || new Set();\n\nif (!window[key]) {\n window[key] = localizeSet;\n}\n\nfunction handleReadyStateChange() {\n if (document.readyState !== \"loading\") {\n addDeveloperUtils();\n document.removeEventListener(\"readystatechange\", handleReadyStateChange);\n }\n}\n\nif (document.readyState !== \"loading\") {\n addDeveloperUtils();\n} else {\n document.addEventListener(\"readystatechange\", handleReadyStateChange);\n}\n\nfunction isDeveloper() {\n const { af } = window;\n\n return af && af.userSession && af.userSession.isDeveloper;\n}\n\nfunction addDeveloperUtils() {\n if (isDeveloper()) {\n if (typeof window.__doNothingWithStrings === \"function\") {\n const addedStrings = window.__doNothingWithStrings();\n\n for (let string of Object.keys(addedStrings)) {\n localizeSet.add(string);\n }\n }\n\n if (!window[key]) {\n window[key] = localizeSet;\n }\n\n if (!window.__getUnlocalizedStrings) {\n window.__getUnlocalizedStrings = function (forCustomRoute) {\n const strings = [];\n\n for (let string of localizeSet) {\n if (string) {\n const escaped = string.replace(/'/g, \"\\\\'\");\n if (forCustomRoute) {\n const localized = afGetLocalizedString(string).replaceAll(/'/g, \"\\\\'\");\n strings.push(`'${escaped}': '${localized}',`);\n } else {\n strings.push(\n `s['${escaped}'] = @Html(@context.AddLocalizableString(\"${string.replaceAll('\"', '\\\\\"')}\"));`\n );\n }\n }\n }\n\n if (forCustomRoute) {\n return `// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used\nif (af.userSession.uiculture === 'nb-NO') {\n\tconst strings = {\n\t\t${strings.join(\"\\n\\t\\t\")}\n\t};\n\taf.article.i18n = af.article.i18n || {};\n\tObject.assign(af.article.i18n, strings);\n}`;\n }\n\n return `<script type=\"text/javascript\">\nfunction __doNothingWithStrings() {\n@{\n\tvar context = @Appframe.Web.Context.RequestContext.Current;\n}\nlet s = {};\n${strings.join(\"\\n\")}\nreturn s;\n}\n</script>`;\n };\n }\n }\n}\n\nexport function getLocalizedString(string: string) {\n const localized = afGetLocalizedString(string);\n if (localized === string && !localizeSet.has(string)) {\n localizeSet.add(string);\n }\n\n return localized;\n}\n", "import mitt, { Emitter, Handler } from \"mitt\";\nimport { getLocalizedString } from \"./getLocalizedString.js\";\n\ntype SessionHandlerEvent = \"onExpired\" | \"onAuthenticated\";\n\nexport default class SessionHandler {\n static messages = {\n login: \"Log in\",\n relog: \"Session expired - log in\"\n };\n\n private eventHandler: Emitter<{ onAuthenticated: void; onExpired: void }> = mitt();\n private showingDialog = false;\n private dialog = null;\n\n expired(callback: Function) {\n af.userSession = af.userSession || {\n login: null\n };\n\n if (typeof callback !== \"function\") {\n throw new TypeError(\"Parameter pCallback passed to the expired function must be a function!\");\n }\n\n const once = () => {\n this.detachEvent(\"onAuthenticated\", once);\n callback();\n };\n\n this.attachEvent(\"onAuthenticated\", once);\n\n if (this.showingDialog !== true) {\n this.showingDialog = true;\n const contentContainer = document.createElement(\"div\");\n contentContainer.className = \"session-expired-container\";\n contentContainer.innerHTML = `\n<div class=\"session-expired-log-in\" style=\"margin-top: 20px;\">\n <div class=\"row\">\n <div class=\"sessionExpired\">\n <h4 class=\"message\">Frakoblet - tidsavbrudd</h4>\n <div class=\"form-group\">\n <label for=\"username\">${getLocalizedString(\"Username\")}</label>\n <input type=\"text\" class=\"form-control\" id=\"username\" autofocus>\n </div>\n <div class=\"form-group\">\n <label for=\"password\">${getLocalizedString(\"Password\")}</label>\n <input type=\"password\" autocomplete=\"password\" class=\"form-control\" id=\"password\" >\n </div>\n <div class=\"form-group\">\n <div>\n <button type=\"submit\" class=\"btn btn-default sign-in\">\n ${getLocalizedString(\"Log in\")}\n </button>\n </div>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"\" style=\"display:none; margin: 0px 30px;\">\n <div class=\"alert alert-warning\" role=\"alert\" style=\"margin-top:10px;\"></div> \n </div>\n </div>\n</div>\n`;\n const message = af.userSession.login ? SessionHandler.messages.relog : SessionHandler.messages.login;\n\n const messageElem = contentContainer.querySelector(\".message\") as HTMLHeadingElement;\n const statusElem = contentContainer.querySelector(\".alert-warning\") as HTMLDivElement;\n const userElem = contentContainer.querySelector(\"input[type=text]\") as HTMLInputElement;\n const signInElem = contentContainer.querySelector(\".sign-in\") as HTMLButtonElement;\n const passwordElem = contentContainer.querySelector(\"input[type=password]\") as HTMLInputElement;\n\n if (\n messageElem !== null &&\n userElem !== null &&\n statusElem !== null &&\n userElem !== null &&\n signInElem !== null &&\n passwordElem !== null\n ) {\n messageElem.innerText = getLocalizedString(message);\n\n userElem.value = af.userSession.login || \"\";\n userElem.disabled = !!af.userSession.login;\n userElem.readOnly = !!af.userSession.login;\n\n document.body.appendChild(contentContainer);\n\n const doLogin = async () => {\n passwordElem.disabled = true;\n\n const request = new Request(\"/login\", {\n body: JSON.stringify({\n username: userElem.value,\n password: passwordElem.value,\n remember: false\n }),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"X-Requested-With\": \"XMLHttpRequest\"\n },\n method: \"POST\"\n });\n\n try {\n const response = await fetch(request);\n const json = await response.json();\n\n if (json.success) {\n document.body.removeChild(contentContainer);\n this.showingDialog = false;\n this.eventHandler.emit(\"onAuthenticated\");\n\n if (statusElem.parentNode) {\n (statusElem.parentNode as HTMLElement).style.display = \"none\";\n }\n } else {\n throw new Error(json.error);\n }\n } catch (err) {\n if (err && typeof err === \"object\") {\n let error = err as Error;\n passwordElem.disabled = false;\n passwordElem.classList.toggle(\"invalid\", true);\n passwordElem.value = \"\";\n passwordElem.focus();\n statusElem.innerText = error.message ? error.message : String(error);\n\n if (statusElem.parentNode) {\n (statusElem.parentNode as HTMLElement).style.display = \"initial\";\n }\n }\n }\n };\n\n signInElem.addEventListener(\"click\", doLogin);\n\n passwordElem.addEventListener(\"keyup\", evt => {\n if (evt.key === \"Enter\") {\n doLogin();\n }\n });\n\n passwordElem.addEventListener(\"change\", evt => {\n if ((evt as KeyboardEvent).key === \"Enter\") {\n doLogin();\n }\n });\n\n userElem.addEventListener(\"keyup\", evt => {\n if (evt.key === \"Enter\") {\n doLogin();\n }\n });\n\n userElem.addEventListener(\"change\", evt => {\n if ((evt as KeyboardEvent).key === \"Enter\") {\n doLogin();\n }\n });\n\n passwordElem.focus();\n }\n }\n }\n\n attachEvent(eventName: SessionHandlerEvent, handler: Handler) {\n return this.eventHandler.on(eventName, handler);\n }\n\n detachEvent(eventName: SessionHandlerEvent, handler: Handler) {\n return this.eventHandler.off(eventName, handler);\n }\n}\n", "import SessionHandler from \"./SessionHandler.js\";\n\nexport default class UserSession extends SessionHandler {\n amDesignator: string = \"a.m.\";\n dayNames: string[] = [\"sunday\", \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\"];\n dayNamesShort: string[] = [\"sun\", \"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\"];\n decimalSeparator: string = \".\";\n domain: string = \"OB\";\n email: string | null | undefined;\n formats: undefined | Record<string, string>;\n groupSeparator: string | null = null;\n integratedSecurity: boolean = false;\n isDeveloper: boolean = false;\n login: string = \"\";\n loginType: string | undefined;\n monthNames: string[] = [\"january\", \"february\", \"march\", \"april\", \"may\", \"june\", \"july\", \"august\", \"september\", \"october\", \"november\", \"december\", \"\"];\n monthNamesShort: string[] = [\"jan\", \"feb\", \"mar\", \"apr\", \"may\", \"jun\", \"jul\", \"augt\", \"sep\", \"oct\", \"nov\", \"dec\", \"\"];\n name: string | undefined;\n pmDesignator: string = \"p.m.\";\n shortDateFormat: string = \"dd.MM.yyyy\";\n culture: string = \"en-GB\";\n uiculture: string = \"en-GB\";\n expired: (callback: () => void) => void = () => null;\n\n constructor(userData: any) {\n super();\n this.formats = {};\n Object.assign(this, userData);\n }\n}\n", "export function downloadBlob(blob: Blob | MediaSource, fileName: string) {\n return new Promise<void>(function (resolve, reject) {\n try {\n const url = URL.createObjectURL(blob);\n const parent = document.body;\n const anchor = document.createElement(\"a\");\n anchor.setAttribute(\"download\", fileName);\n anchor.href = url;\n parent.append(anchor);\n anchor.click();\n parent.removeChild(anchor);\n\n setTimeout(function () {\n URL.revokeObjectURL(url);\n resolve();\n }, 250);\n } catch (ex) {\n reject(ex);\n }\n });\n}\n", "import { downloadBlob } from \"./downloadBlob.js\";\n\nexport type DownloadItem = {\n status: \"cancelled\" | \"error\" | \"requested\" | \"downloading\" | \"downloaded\" | \"completed\";\n bytesReceived?: number;\n error?: string;\n};\n\nexport type DownloadParameters = {\n signal?: AbortSignal;\n fileName: string;\n onProgress?: (progress: DownloadItem) => void;\n};\n\nexport async function downloadRequest(request: Request, { fileName, signal, onProgress }: DownloadParameters) {\n function reportProgress(progress: DownloadItem) {\n if (typeof onProgress === \"function\") {\n onProgress({ ...progress });\n }\n }\n\n let bytesReceived = 0;\n\n reportProgress({ status: \"requested\" });\n\n try {\n let response = await fetch(request);\n\n if (!response.ok || !response.body) {\n if (response.headers.get(\"content-type\")?.includes(\"application/json\")) {\n let data = await response.json();\n if (data.error) {\n throw new Error(data.error);\n }\n }\n throw new Error(`${response.status} ${response.statusText}`);\n }\n\n try {\n const reader = response.body.getReader();\n const stream = new ReadableStream({\n start: function (controller) {\n function pump(): Promise<void> {\n return reader.read().then(function (read) {\n if (read.done) {\n controller.close();\n return;\n }\n\n bytesReceived += read.value.length;\n reportProgress({ bytesReceived, status: \"downloading\" });\n controller.enqueue(read.value);\n\n return pump();\n });\n }\n\n return pump();\n },\n });\n\n response = new Response(stream);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn(\"Failed to replace response stream to log download progress.\");\n }\n\n const blob = await response.blob();\n\n reportProgress({ bytesReceived, status: \"downloaded\" });\n\n await downloadBlob(blob, fileName);\n\n reportProgress({ bytesReceived, status: \"completed\" });\n } catch (err) {\n if (signal?.aborted) {\n reportProgress({ status: \"cancelled\" });\n } else {\n reportProgress({ error: (err as Error).message, status: \"error\" });\n }\n }\n}\n", "export function has(\n obj: any,\n key: string | number | symbol\n): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n", "const 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)*)\\}$/;\n\nexport default function parseFunc(func: Function) {\n var match = func.toString().match(funcRegex);\n if (match === null) {\n throw new TypeError(\"Unable to parse function!\");\n }\n return { name: match[1], args: match[2].split(\",\"), body: match[3] };\n}\n", "function Namespace() {}\nNamespace.prototype = Object.create(null);\n\nexport default Namespace;\n", "import Namespace from \"./Namespace.js\";\n\nexport default function requireNamespace(\n root: any,\n namespace: string | Array<string>\n): any {\n if (typeof root === \"object\") {\n if (typeof namespace === \"string\") {\n let path = namespace.split(\".\");\n\n return requireNamespace(root, path);\n } else if (Array.isArray(namespace)) {\n let current: any = root;\n for (let i = 0; i < namespace.length; i++) {\n current = current[namespace[i]] =\n current[namespace[i]] || new (Namespace as any)();\n }\n\n return current;\n } else {\n throw new TypeError(\"Invalid type of parameter 'namespace'\");\n }\n } else {\n throw new TypeError(\"Invalid type of parameter 'root'\");\n }\n}\n", "/* eslint-disable no-console */\nexport default function warn(message: string, fallbackToAlert?: boolean) {\n console.warn(message);\n}\n", "import { has } from \"./has.js\";\nimport parseFunc from \"./parseFunc.js\";\nimport requireNamespace from \"./requireNamespace.js\";\nimport warn from \"./warn.js\";\n\n/**\n * Expose a value to a potentially deeply nested global variable\n * @param name {string | object} Either a dot-separated path to the global variable, or an object to expose the value on\n * @param value {object | Function | Function[]} The value(s) to expose\n */\nexport default function expose(name: object | string, value: object | Function | Function[]): void {\n if (arguments.length !== 2) {\n throw new Error(\"Incorrect number of arguments passed to the expose function!\");\n }\n\n if (Array.isArray(value)) {\n for (let func of value) {\n const { name: funcName } = parseFunc(func);\n\n if (funcName) {\n expose(name, func); // Expose func on namespace found in pName\n } else {\n throw new Error(\n \"Unable to detect name of function! Name it, or only supply one function and include name in first parameter.\"\n );\n }\n }\n } else {\n let keyName: string | undefined;\n let namespace;\n\n if (typeof value === \"function\") {\n keyName = parseFunc(value).name;\n }\n\n if (typeof name === \"string\") {\n let pathParts = name.split(\".\");\n\n if (!keyName) {\n keyName = pathParts[pathParts.length - 1];\n pathParts = pathParts.slice(0, pathParts.length - 1);\n }\n\n namespace = requireNamespace(window, pathParts);\n } else if (keyName && (typeof name === \"object\" || typeof name === \"function\")) {\n namespace = name;\n } else {\n throw new TypeError(\"Invalid typeof parameter 'name', or unable to parse pValue!\");\n }\n\n if (has(namespace, keyName)) {\n // If class is already defined, warn or show an alert\n warn([name, keyName].join(\".\") + \" is already defined!\");\n } else {\n namespace[keyName] = value;\n }\n }\n}\n", "function getLocalKey(key: string): string {\n return [af?.article?.id || \"\", \"common\", key].join(\".\");\n}\n\nclass LocalStorage {\n isPersisted() {\n return true;\n }\n\n getLocalStorageKey(key: string, global?: boolean) {\n return global ? [\"common\", key].join(\".\") : getLocalKey(key);\n }\n\n get(key: string, defaultValue: unknown, global?: boolean) {\n const lsKey = this.getLocalStorageKey(key, global);\n const value = localStorage.getItem(lsKey);\n\n return value !== null ? JSON.parse(value) : defaultValue;\n }\n\n set(key: string, value: unknown, global?: boolean) {\n localStorage.setItem(\n this.getLocalStorageKey(key, global),\n JSON.stringify(value)\n );\n }\n\n remove(key: string, global?: boolean) {\n const lsKey = this.getLocalStorageKey(key, global);\n if (localStorage.getItem(lsKey) !== null) {\n localStorage.removeItem(lsKey);\n return true;\n } else {\n return false;\n }\n }\n\n clear() {\n const baseKey = getLocalKey(\"\");\n\n for (let key in localStorage) {\n if (key.slice(0, baseKey.length) === baseKey) {\n localStorage.removeItem(key);\n }\n }\n }\n}\n\nexport default new LocalStorage();\n", "function getKey(article?: string) {\n const articleKey = article || af.article.id;\n return `${articleKey}.${af.userSession.login}`;\n}\n\nexport function getSettings<T>(setting: string, article?: string): T | null {\n if (!af?.userSession) return null;\n\n const key = getKey(article);\n const settings = JSON.parse(localStorage.getItem(key) || \"{}\");\n\n if (setting) {\n return settings[setting] || null;\n }\n\n return settings;\n}\n\nexport function saveSettings<T>(\n setting: string,\n value: T | null,\n article?: string\n): void {\n if (!af?.userSession) return;\n\n const key = getKey(article);\n let userSettings = JSON.parse(localStorage.getItem(key) || \"{}\");\n\n if (typeof value !== \"undefined\") {\n userSettings[setting] = value;\n } else {\n userSettings = setting;\n }\n\n localStorage.setItem(key, JSON.stringify(userSettings));\n}\n", "import \"./errorHandler.js\";\n\nimport UserSession from \"./UserSession.js\";\n\nexport { default as mitt } from \"mitt\";\nexport { downloadBlob } from \"./downloadBlob.js\";\nexport * from \"./downloadRequest.js\";\nexport { default as expose } from \"./expose.js\";\nexport { getLocalizedString } from \"./getLocalizedString.js\";\nexport * from \"./has.js\";\nexport { default as localStorage } from \"./localStorage.js\";\nexport { default as SessionHandler } from \"./SessionHandler.js\";\nexport { UserSession };\nexport * from \"./settings.js\";\n\nexport const version = __VERSION__;\n\ndeclare global {\n var __VERSION__: string;\n var __DEV__: number;\n var af: AfCore;\n\n interface Window {\n af: AfCore;\n }\n}\n\nexport interface AfArticle {\n hostName: string;\n i18n: Record<string, string>;\n id: string;\n}\n\nexport interface AfCore {\n article: AfArticle;\n common?: {\n getLocalizedString?: (string: string) => string;\n };\n controls?: {\n alert?: (message: string, callback?: () => void) => void;\n confirm?: (options: {\n title: string;\n message: string;\n buttons: string[];\n callback: (button: number) => void;\n }) => void;\n };\n userSession: UserSession;\n}\n"],
5
+ "mappings": "6YAAA,OAAO,iBAAiB,QAAUA,GAAU,CAA5C,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACE,GAAI,CAEF,IAAMC,EAAO,CACX,OAAOL,GAAAD,GAAAD,EAAAD,EAAM,QAAN,YAAAC,EAAa,UAAb,KAAAC,EAAwBF,EAAM,UAA9B,KAAAG,EAAyC,KAChD,KAAMH,EAAM,SACZ,MAAMI,EAAAJ,EAAM,SAAN,KAAAI,EAAgB,EACtB,QAAQC,EAAAL,EAAM,QAAN,KAAAK,EAAe,EACvB,OAAOE,GAAAD,EAAAN,EAAM,QAAN,YAAAM,EAAa,QAAb,KAAAC,EAAsB,IAC/B,EAEA,MAAM,wBAAyB,CAC7B,KAAM,KAAK,UAAUC,CAAI,EACzB,QAAS,CACP,OAAQ,mBACR,eAAgB,kCAChB,mBAAoB,gBACtB,EACA,OAAQ,MACV,CAAC,CACH,OAASC,EAAP,CAEF,CACF,CAAC,aCgBAC,EAAAA,CAOA,MAAO,CAKNA,IAPDA,EAAMA,GAAO,IAAIC,IAehBC,GAAAA,SAA6BC,EAAW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AAa,OAEtB,IAAMG,EAAMJ,EAAOC,CAAO,EACtBO,EAAe,KAAK,MAAM,aAAa,QAAQJ,CAAG,GAAK,IAAI,EAE3D,OAAOG,EAAU,IACnBC,EAAaL,GAAWI,EAExBC,EAAeL,EAGjB,aAAa,QAAQC,EAAK,KAAK,UAAUI,CAAY,CAAC,CACxD,CCpBO,IAAMC,GAAU",
6
+ "names": ["event", "_a", "_b", "_c", "_d", "_e", "_f", "_g", "data", "ex", "all", "Map", "on", "type", "handler", "handlers", "get", "push", "set", "off", "splice", "indexOf", "emit", "evt", "slice", "map", "getLocalizedStringAsync", "string", "response", "error", "afGetLocalizedString", "wait", "_a", "promise", "text", "key", "localizeSet", "handleReadyStateChange", "addDeveloperUtils", "isDeveloper", "af", "addedStrings", "forCustomRoute", "strings", "escaped", "localized", "getLocalizedString", "_SessionHandler", "__publicField", "mitt_default", "callback", "once", "contentContainer", "getLocalizedString", "message", "messageElem", "statusElem", "userElem", "signInElem", "passwordElem", "doLogin", "request", "json", "err", "error", "evt", "eventName", "handler", "SessionHandler", "UserSession", "SessionHandler", "userData", "__publicField", "downloadBlob", "blob", "fileName", "resolve", "reject", "url", "parent", "anchor", "ex", "downloadRequest", "request", "fileName", "signal", "onProgress", "_a", "reportProgress", "progress", "__spreadValues", "bytesReceived", "response", "data", "reader", "stream", "controller", "pump", "read", "error", "blob", "downloadBlob", "err", "has", "obj", "key", "funcRegex", "parseFunc", "func", "match", "Namespace", "Namespace_default", "requireNamespace", "root", "namespace", "path", "current", "i", "Namespace_default", "warn", "message", "fallbackToAlert", "expose", "name", "value", "func", "funcName", "parseFunc", "keyName", "namespace", "pathParts", "requireNamespace", "has", "warn", "getLocalKey", "key", "_a", "LocalStorage", "global", "defaultValue", "lsKey", "value", "baseKey", "localStorage_default", "getKey", "article", "getSettings", "setting", "key", "settings", "saveSettings", "value", "userSettings", "version"]
7
7
  }
@@ -1,4 +1,4 @@
1
- window.addEventListener("error",t=>{try{let e={error:t.error?.message??t.message??null,file:t.filename,line:t.lineno??0,column:t.colno??0,stack:t.error?.stack??null};fetch("/data/Logger/LogError",{body:JSON.stringify(e),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch{}});function x(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(o){o(n)}),(r=t.get("*"))&&r.slice().map(function(o){o(e,n)})}}}async function H(t){try{let e=await fetch("/api/user/localize",{body:JSON.stringify({string:t}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(e.ok)return await e.json()}catch{}return t}function N(t,e){if(af?.article?.i18n!==void 0){if(!Object.prototype.hasOwnProperty.call(af.article.i18n,t)){af.article.i18n[t]=t;let n=H(t).then(r=>(af.article.i18n[t]=r,r));if(e)return n}return af.article.i18n[t]}else return t}var h="__UNLOCALIZED_STRINGS__",m=window[h]||new Set;window[h]||(window[h]=m);function j(){document.readyState!=="loading"&&(T(),document.removeEventListener("readystatechange",j))}document.readyState!=="loading"?T():document.addEventListener("readystatechange",j);function q(){let{af:t}=window;return t&&t.userSession&&t.userSession.isDeveloper}function T(){if(q()){if(typeof window.__doNothingWithStrings=="function"){let t=window.__doNothingWithStrings();for(let e of Object.keys(t))m.add(e)}window[h]||(window[h]=m),window.__getUnlocalizedStrings||(window.__getUnlocalizedStrings=function(t){let e=[];for(let n of m)if(n){let r=n.replace(/'/g,"\\'");if(t){let o=N(n).replaceAll(/'/g,"\\'");e.push(`'${r}': '${o}',`)}else e.push(`s['${r}'] = @Html(@context.AddLocalizableString("${n.replaceAll('"','\\"')}"));`)}return t?`// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used
1
+ var q=Object.defineProperty;var D=(t,e,n)=>e in t?q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var N=(t,e,n)=>(D(t,typeof e!="symbol"?e+"":e,n),n);window.addEventListener("error",t=>{try{let e={error:t.error?.message??t.message??null,file:t.filename,line:t.lineno??0,column:t.colno??0,stack:t.error?.stack??null};fetch("/data/Logger/LogError",{body:JSON.stringify(e),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch{}});function x(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(o){o(n)}),(r=t.get("*"))&&r.slice().map(function(o){o(e,n)})}}}async function $(t){try{let e=await fetch("/api/user/localize",{body:JSON.stringify({string:t,ArticleID:af.article.id}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(e.ok)return await e.json()}catch{}return t}function j(t,e){if(af?.article?.i18n!==void 0){if(!Object.prototype.hasOwnProperty.call(af.article.i18n,t)){af.article.i18n[t]=t;let n=$(t).then(r=>(af.article.i18n[t]=r,r));if(e)return n}return af.article.i18n[t]}else return t}var h="__UNLOCALIZED_STRINGS__",m=window[h]||new Set;window[h]||(window[h]=m);function T(){document.readyState!=="loading"&&(O(),document.removeEventListener("readystatechange",T))}document.readyState!=="loading"?O():document.addEventListener("readystatechange",T);function C(){let{af:t}=window;return t&&t.userSession&&t.userSession.isDeveloper}function O(){if(C()){if(typeof window.__doNothingWithStrings=="function"){let t=window.__doNothingWithStrings();for(let e of Object.keys(t))m.add(e)}window[h]||(window[h]=m),window.__getUnlocalizedStrings||(window.__getUnlocalizedStrings=function(t){let e=[];for(let n of m)if(n){let r=n.replace(/'/g,"\\'");if(t){let o=j(n).replaceAll(/'/g,"\\'");e.push(`'${r}': '${o}',`)}else e.push(`s['${r}'] = @Html(@context.AddLocalizableString("${n.replaceAll('"','\\"')}"));`)}return t?`// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used
2
2
  if (af.userSession.uiculture === 'nb-NO') {
3
3
  const strings = {
4
4
  ${e.join(`
@@ -16,7 +16,7 @@ ${e.join(`
16
16
  `)}
17
17
  return s;
18
18
  }
19
- <\/script>`})}}function y(t){let e=N(t);return e===t&&!m.has(t)&&m.add(t),e}var w=class{constructor(){this.eventHandler=x();this.showingDialog=!1;this.dialog=null}expired(e){if(af.userSession=af.userSession||{login:null},typeof e!="function")throw new TypeError("Parameter pCallback passed to the expired function must be a function!");let n=()=>{this.detachEvent("onAuthenticated",n),e()};if(this.attachEvent("onAuthenticated",n),this.showingDialog!==!0){this.showingDialog=!0;let r=document.createElement("div");r.className="session-expired-container",r.innerHTML=`
19
+ <\/script>`})}}function y(t){let e=j(t);return e===t&&!m.has(t)&&m.add(t),e}var w=class{eventHandler=x();showingDialog=!1;dialog=null;expired(e){if(af.userSession=af.userSession||{login:null},typeof e!="function")throw new TypeError("Parameter pCallback passed to the expired function must be a function!");let n=()=>{this.detachEvent("onAuthenticated",n),e()};if(this.attachEvent("onAuthenticated",n),this.showingDialog!==!0){this.showingDialog=!0;let r=document.createElement("div");r.className="session-expired-container",r.innerHTML=`
20
20
  <div class="session-expired-log-in" style="margin-top: 20px;">
21
21
  <div class="row">
22
22
  <div class="sessionExpired">
@@ -44,5 +44,5 @@ return s;
44
44
  </div>
45
45
  </div>
46
46
  </div>
47
- `;let o=af.userSession.login?w.messages.relog:w.messages.login,s=r.querySelector(".message"),i=r.querySelector(".alert-warning"),c=r.querySelector("input[type=text]"),d=r.querySelector(".sign-in"),a=r.querySelector("input[type=password]");if(s!==null&&c!==null&&i!==null&&c!==null&&d!==null&&a!==null){s.innerText=y(o),c.value=af.userSession.login||"",c.disabled=!!af.userSession.login,c.readOnly=!!af.userSession.login,document.body.appendChild(r);let u=async()=>{a.disabled=!0;let l=new Request("/login",{body:JSON.stringify({username:c.value,password:a.value,remember:!1}),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"});try{let g=await(await fetch(l)).json();if(g.success)document.body.removeChild(r),this.showingDialog=!1,this.eventHandler.emit("onAuthenticated"),i.parentNode&&(i.parentNode.style.display="none");else throw new Error(g.error)}catch(f){if(f&&typeof f=="object"){let g=f;a.disabled=!1,a.classList.toggle("invalid",!0),a.value="",a.focus(),i.innerText=g.message?g.message:String(g),i.parentNode&&(i.parentNode.style.display="initial")}}};d.addEventListener("click",u),a.addEventListener("keyup",l=>{l.key==="Enter"&&u()}),a.addEventListener("change",l=>{l.key==="Enter"&&u()}),c.addEventListener("keyup",l=>{l.key==="Enter"&&u()}),c.addEventListener("change",l=>{l.key==="Enter"&&u()}),a.focus()}}}attachEvent(e,n){return this.eventHandler.on(e,n)}detachEvent(e,n){return this.eventHandler.off(e,n)}},p=w;p.messages={login:"Log in",relog:"Session expired - log in"};var S=class extends p{constructor(n){super();this.decimalSeparator=".";this.domain="OB";this.groupSeparator=null;this.shortDateFormat="dd.MM.yyyy";this.login="";this.isDeveloper=!1;this.culture="en-GB";this.uiculture="en-GB";this.expired=()=>null;this.formats={},Object.assign(this,n)}};function E(t,e){return new Promise(function(n,r){try{let o=URL.createObjectURL(t),s=document.body,i=document.createElement("a");i.setAttribute("download",e),i.href=o,s.append(i),i.click(),s.removeChild(i),setTimeout(function(){URL.revokeObjectURL(o),n()},250)}catch(o){r(o)}})}async function X(t,{fileName:e,signal:n,onProgress:r}){function o(i){typeof r=="function"&&r({...i})}let s=0;o({status:"requested"});try{let i=await fetch(t);if(!i.ok||!i.body){if(i.headers.get("content-type")?.includes("application/json")){let d=await i.json();if(d.error)throw new Error(d.error)}throw new Error(`${i.status} ${i.statusText}`)}try{let d=i.body.getReader(),a=new ReadableStream({start:function(u){function l(){return d.read().then(function(f){if(f.done){u.close();return}return s+=f.value.length,o({bytesReceived:s,status:"downloading"}),u.enqueue(f.value),l()})}return l()}});i=new Response(a)}catch{console.warn("Failed to replace response stream to log download progress.")}let c=await i.blob();o({bytesReceived:s,status:"downloaded"}),await E(c,e),o({bytesReceived:s,status:"completed"})}catch(i){n?.aborted?o({status:"cancelled"}):o({error:i.message,status:"error"})}}function O(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var $=/^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 b(t){var e=t.toString().match($);if(e===null)throw new TypeError("Unable to parse function!");return{name:e[1],args:e[2].split(","),body:e[3]}}function k(){}k.prototype=Object.create(null);var R=k;function v(t,e){if(typeof t=="object")if(typeof e=="string"){let n=e.split(".");return v(t,n)}else if(Array.isArray(e)){let n=t;for(let r=0;r<e.length;r++)n=n[e[r]]=n[e[r]]||new R;return n}else throw new TypeError("Invalid type of parameter 'namespace'");else throw new TypeError("Invalid type of parameter 'root'")}function L(t,e){console.warn(t)}function _(t,e){if(arguments.length!==2)throw new Error("Incorrect number of arguments passed to the expose function!");if(Array.isArray(e))for(let n of e){let{name:r}=b(n);if(r)_(t,n);else throw new Error("Unable to detect name of function! Name it, or only supply one function and include name in first parameter.")}else{let n,r;if(typeof e=="function"&&(n=b(e).name),typeof t=="string"){let o=t.split(".");n||(n=o[o.length-1],o=o.slice(0,o.length-1)),r=v(window,o)}else if(n&&(typeof t=="object"||typeof t=="function"))r=t;else throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");O(r,n)?L([t,n].join(".")+" is already defined!"):r[n]=e}}function z(t){return[af?.article?.id||"","common",t].join(".")}var A=class{isPersisted(){return!0}getLocalStorageKey(e,n){return n?["common",e].join("."):z(e)}get(e,n,r){let o=this.getLocalStorageKey(e,r),s=localStorage.getItem(o);return s!==null?JSON.parse(s):n}set(e,n,r){localStorage.setItem(this.getLocalStorageKey(e,r),JSON.stringify(n))}remove(e,n){let r=this.getLocalStorageKey(e,n);return localStorage.getItem(r)!==null?(localStorage.removeItem(r),!0):!1}clear(){let e=z("");for(let n in localStorage)n.slice(0,e.length)===e&&localStorage.removeItem(n)}},D=new A;function I(t){return`${t||af.article.id}.${af.userSession.login}`}function de(t,e){if(!af?.userSession)return null;let n=I(e),r=JSON.parse(localStorage.getItem(n)||"{}");return t?r[t]||null:r}function ue(t,e,n){if(!af?.userSession)return;let r=I(n),o=JSON.parse(localStorage.getItem(r)||"{}");typeof e<"u"?o[t]=e:o=t,localStorage.setItem(r,JSON.stringify(o))}var me="2.0.0";export{p as SessionHandler,S as UserSession,E as downloadBlob,X as downloadRequest,_ as expose,y as getLocalizedString,de as getSettings,O as has,D as localStorage,x as mitt,ue as saveSettings,me as version};
47
+ `;let o=af.userSession.login?w.messages.relog:w.messages.login,s=r.querySelector(".message"),i=r.querySelector(".alert-warning"),c=r.querySelector("input[type=text]"),d=r.querySelector(".sign-in"),a=r.querySelector("input[type=password]");if(s!==null&&c!==null&&i!==null&&c!==null&&d!==null&&a!==null){s.innerText=y(o),c.value=af.userSession.login||"",c.disabled=!!af.userSession.login,c.readOnly=!!af.userSession.login,document.body.appendChild(r);let u=async()=>{a.disabled=!0;let l=new Request("/login",{body:JSON.stringify({username:c.value,password:a.value,remember:!1}),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"});try{let p=await(await fetch(l)).json();if(p.success)document.body.removeChild(r),this.showingDialog=!1,this.eventHandler.emit("onAuthenticated"),i.parentNode&&(i.parentNode.style.display="none");else throw new Error(p.error)}catch(f){if(f&&typeof f=="object"){let p=f;a.disabled=!1,a.classList.toggle("invalid",!0),a.value="",a.focus(),i.innerText=p.message?p.message:String(p),i.parentNode&&(i.parentNode.style.display="initial")}}};d.addEventListener("click",u),a.addEventListener("keyup",l=>{l.key==="Enter"&&u()}),a.addEventListener("change",l=>{l.key==="Enter"&&u()}),c.addEventListener("keyup",l=>{l.key==="Enter"&&u()}),c.addEventListener("change",l=>{l.key==="Enter"&&u()}),a.focus()}}}attachEvent(e,n){return this.eventHandler.on(e,n)}detachEvent(e,n){return this.eventHandler.off(e,n)}},g=w;N(g,"messages",{login:"Log in",relog:"Session expired - log in"});var b=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";expired=()=>null;constructor(e){super(),this.formats={},Object.assign(this,e)}};function E(t,e){return new Promise(function(n,r){try{let o=URL.createObjectURL(t),s=document.body,i=document.createElement("a");i.setAttribute("download",e),i.href=o,s.append(i),i.click(),s.removeChild(i),setTimeout(function(){URL.revokeObjectURL(o),n()},250)}catch(o){r(o)}})}async function te(t,{fileName:e,signal:n,onProgress:r}){function o(i){typeof r=="function"&&r({...i})}let s=0;o({status:"requested"});try{let i=await fetch(t);if(!i.ok||!i.body){if(i.headers.get("content-type")?.includes("application/json")){let d=await i.json();if(d.error)throw new Error(d.error)}throw new Error(`${i.status} ${i.statusText}`)}try{let d=i.body.getReader(),a=new ReadableStream({start:function(u){function l(){return d.read().then(function(f){if(f.done){u.close();return}return s+=f.value.length,o({bytesReceived:s,status:"downloading"}),u.enqueue(f.value),l()})}return l()}});i=new Response(a)}catch{console.warn("Failed to replace response stream to log download progress.")}let c=await i.blob();o({bytesReceived:s,status:"downloaded"}),await E(c,e),o({bytesReceived:s,status:"completed"})}catch(i){n?.aborted?o({status:"cancelled"}):o({error:i.message,status:"error"})}}function R(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var P=/^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 S(t){var e=t.toString().match(P);if(e===null)throw new TypeError("Unable to parse function!");return{name:e[1],args:e[2].split(","),body:e[3]}}function k(){}k.prototype=Object.create(null);var z=k;function v(t,e){if(typeof t=="object")if(typeof e=="string"){let n=e.split(".");return v(t,n)}else if(Array.isArray(e)){let n=t;for(let r=0;r<e.length;r++)n=n[e[r]]=n[e[r]]||new z;return n}else throw new TypeError("Invalid type of parameter 'namespace'");else throw new TypeError("Invalid type of parameter 'root'")}function L(t,e){console.warn(t)}function _(t,e){if(arguments.length!==2)throw new Error("Incorrect number of arguments passed to the expose function!");if(Array.isArray(e))for(let n of e){let{name:r}=S(n);if(r)_(t,n);else throw new Error("Unable to detect name of function! Name it, or only supply one function and include name in first parameter.")}else{let n,r;if(typeof e=="function"&&(n=S(e).name),typeof t=="string"){let o=t.split(".");n||(n=o[o.length-1],o=o.slice(0,o.length-1)),r=v(window,o)}else if(n&&(typeof t=="object"||typeof t=="function"))r=t;else throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");R(r,n)?L([t,n].join(".")+" is already defined!"):r[n]=e}}function I(t){return[af?.article?.id||"","common",t].join(".")}var A=class{isPersisted(){return!0}getLocalStorageKey(e,n){return n?["common",e].join("."):I(e)}get(e,n,r){let o=this.getLocalStorageKey(e,r),s=localStorage.getItem(o);return s!==null?JSON.parse(s):n}set(e,n,r){localStorage.setItem(this.getLocalStorageKey(e,r),JSON.stringify(n))}remove(e,n){let r=this.getLocalStorageKey(e,n);return localStorage.getItem(r)!==null?(localStorage.removeItem(r),!0):!1}clear(){let e=I("");for(let n in localStorage)n.slice(0,e.length)===e&&localStorage.removeItem(n)}},M=new A;function H(t){return`${t||af.article.id}.${af.userSession.login}`}function me(t,e){if(!af?.userSession)return null;let n=H(e),r=JSON.parse(localStorage.getItem(n)||"{}");return t?r[t]||null:r}function ye(t,e,n){if(!af?.userSession)return;let r=H(n),o=JSON.parse(localStorage.getItem(r)||"{}");typeof e<"u"?o[t]=e:o=t,localStorage.setItem(r,JSON.stringify(o))}var Se="2.0.2";export{g as SessionHandler,b as UserSession,E as downloadBlob,te as downloadRequest,_ as expose,y as getLocalizedString,me as getSettings,R as has,M as localStorage,x as mitt,ye as saveSettings,Se as version};
48
48
  //# sourceMappingURL=af.common.min.js.map