@olenbetong/appframe-core 2.16.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/af.common.js +24 -12
- package/dist/esm/af.common.legacy.js +15 -3
- package/dist/esm/af.common.legacy.min.js +3 -3
- package/dist/esm/af.common.legacy.min.js.map +1 -1
- package/dist/esm/af.common.min.js +3 -3
- package/dist/esm/af.common.min.js.map +1 -1
- package/dist/iife/af.common.js +24 -12
- package/dist/iife/af.common.legacy.js +15 -3
- package/dist/iife/af.common.legacy.min.js +3 -3
- package/dist/iife/af.common.legacy.min.js.map +1 -1
- package/dist/iife/af.common.min.js +3 -3
- package/dist/iife/af.common.min.js.map +1 -1
- package/es/index.js +1 -1
- package/es/report/recordSource.d.ts +1 -1
- package/es/report/recordSource.js +16 -2
- package/es/report/report.test.js +36 -0
- package/package.json +2 -2
- package/src/report/recordSource.ts +17 -2
- package/src/report/report.test.ts +39 -0
package/dist/iife/af.common.js
CHANGED
|
@@ -25,7 +25,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// \0@oxc-project+runtime@0.
|
|
28
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
29
29
|
function _typeof(o) {
|
|
30
30
|
"@babel/helpers - typeof";
|
|
31
31
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -35,25 +35,25 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
35
35
|
}, _typeof(o);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// \0@oxc-project+runtime@0.
|
|
39
|
-
function toPrimitive(t,
|
|
38
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
39
|
+
function toPrimitive(t, e) {
|
|
40
40
|
if ("object" != _typeof(t) || !t) return t;
|
|
41
|
-
var
|
|
42
|
-
if (void 0 !==
|
|
43
|
-
var i =
|
|
41
|
+
var r;
|
|
42
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
43
|
+
var i = r.call(t, e || "default");
|
|
44
44
|
if ("object" != _typeof(i)) return i;
|
|
45
45
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
46
46
|
}
|
|
47
|
-
return ("string" ===
|
|
47
|
+
return ("string" === e ? String : Number)(t);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// \0@oxc-project+runtime@0.
|
|
50
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
51
51
|
function toPropertyKey(t) {
|
|
52
52
|
var i = toPrimitive(t, "string");
|
|
53
53
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// \0@oxc-project+runtime@0.
|
|
56
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
57
57
|
function _defineProperty(e, r, t) {
|
|
58
58
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
59
59
|
value: t,
|
|
@@ -1596,14 +1596,26 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1596
1596
|
return columns;
|
|
1597
1597
|
}
|
|
1598
1598
|
/**
|
|
1599
|
+
* The record source a document holds. Parameter lookups store one `<afRecordSource>`; a report
|
|
1600
|
+
* stores its record sources as `<ArrayOfAfReportRecordSource>` with one `<afReportRecordSource>`
|
|
1601
|
+
* per data source, of which the one with the ID `Master` feeds the report (else the first).
|
|
1602
|
+
*/
|
|
1603
|
+
function pickRecordSource(document) {
|
|
1604
|
+
if (!document) return null;
|
|
1605
|
+
let sources = [...document.matchAll(/<(afRecordSource|afReportRecordSource)(?:\s[^>]*)?>([\s\S]*?)<\/\1>/g)].map((match) => match[2]);
|
|
1606
|
+
if (sources.length === 0) return null;
|
|
1607
|
+
return sources.find((source) => readElement(source, "ID") === "Master") ?? sources[0];
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1599
1610
|
* Reads the parts of an `afRecordSource` a web client can act on: the view, the
|
|
1600
1611
|
* selected columns and the design-time filter.
|
|
1601
1612
|
*
|
|
1602
1613
|
* Returns `null` for anything that is not a record source, so a missing or
|
|
1603
1614
|
* empty `RecordSource` column simply means "no lookup".
|
|
1604
1615
|
*/
|
|
1605
|
-
function parseRecordSource(
|
|
1606
|
-
|
|
1616
|
+
function parseRecordSource(document) {
|
|
1617
|
+
let xml = pickRecordSource(document);
|
|
1618
|
+
if (!xml) return null;
|
|
1607
1619
|
let viewName = readElement(xml, "ViewName");
|
|
1608
1620
|
if (!viewName) return null;
|
|
1609
1621
|
let maxRecords = readElement(xml, "MaxRecords");
|
|
@@ -2211,7 +2223,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2211
2223
|
}
|
|
2212
2224
|
|
|
2213
2225
|
// src/index.ts
|
|
2214
|
-
const version = "2.
|
|
2226
|
+
const version = "2.16.1";
|
|
2215
2227
|
|
|
2216
2228
|
exports.ConfirmButtons = ConfirmButtons;
|
|
2217
2229
|
exports.NO_FILTER_ID = NO_FILTER_ID;
|
|
@@ -1554,14 +1554,26 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1554
1554
|
return columns;
|
|
1555
1555
|
}
|
|
1556
1556
|
/**
|
|
1557
|
+
* The record source a document holds. Parameter lookups store one `<afRecordSource>`; a report
|
|
1558
|
+
* stores its record sources as `<ArrayOfAfReportRecordSource>` with one `<afReportRecordSource>`
|
|
1559
|
+
* per data source, of which the one with the ID `Master` feeds the report (else the first).
|
|
1560
|
+
*/
|
|
1561
|
+
function pickRecordSource(document) {
|
|
1562
|
+
if (!document) return null;
|
|
1563
|
+
let sources = [...document.matchAll(/<(afRecordSource|afReportRecordSource)(?:\s[^>]*)?>([\s\S]*?)<\/\1>/g)].map((match) => match[2]);
|
|
1564
|
+
if (sources.length === 0) return null;
|
|
1565
|
+
return sources.find((source) => readElement(source, "ID") === "Master") ?? sources[0];
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1557
1568
|
* Reads the parts of an `afRecordSource` a web client can act on: the view, the
|
|
1558
1569
|
* selected columns and the design-time filter.
|
|
1559
1570
|
*
|
|
1560
1571
|
* Returns `null` for anything that is not a record source, so a missing or
|
|
1561
1572
|
* empty `RecordSource` column simply means "no lookup".
|
|
1562
1573
|
*/
|
|
1563
|
-
function parseRecordSource(
|
|
1564
|
-
|
|
1574
|
+
function parseRecordSource(document) {
|
|
1575
|
+
let xml = pickRecordSource(document);
|
|
1576
|
+
if (!xml) return null;
|
|
1565
1577
|
let viewName = readElement(xml, "ViewName");
|
|
1566
1578
|
if (!viewName) return null;
|
|
1567
1579
|
let maxRecords = readElement(xml, "MaxRecords");
|
|
@@ -2169,7 +2181,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2169
2181
|
}
|
|
2170
2182
|
|
|
2171
2183
|
// src/index.ts
|
|
2172
|
-
const version = "2.
|
|
2184
|
+
const version = "2.16.1";
|
|
2173
2185
|
|
|
2174
2186
|
exports.ConfirmButtons = ConfirmButtons;
|
|
2175
2187
|
exports.NO_FILTER_ID = NO_FILTER_ID;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
this.af=this.af||{},this.af.common=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return{all:e||=/* @__PURE__ */ new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}var n=class{eventHandler=t();authenticated(){this.eventHandler.emit(`onAuthenticated`)}async expired(e,t){try{let n=new Promise(t=>{let n=()=>{this.eventHandler.off(`onAuthenticated`,n),e?.(),t()};this.eventHandler.on(`onAuthenticated`,n)}),r=document.querySelector(`dialog.session-expired-dialog`);if(r)await n;else{r=document.createElement(`dialog`),r.className=`session-expired-dialog`,r.style.display=`flex`,r.style.padding=`0`,r.style.left=`50%`,r.style.transform=`translateX(-50%)`;let e=`/login?ReturnUrl=%2fapi/sessionexpired/remove`;t===`RequireTwoFactor`?e=`/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove`:await fetch(`/logout`,{method:`POST`}),r.innerHTML=`<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${e}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(r),r.showModal(),await n,r.remove()}}catch{window.location.href=`/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`}}attachEvent(e,t){return this.eventHandler.on(e,t)}detachEvent(e,t){return this.eventHandler.off(e,t)}},r=class extends n{amDesignator=`a.m.`;dayNames=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`];dayNamesShort=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];decimalSeparator=`.`;domain=`OB`;email;formats;groupSeparator=null;integratedSecurity=!1;isDeveloper=!1;login=``;loginType;monthNames=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`,``];monthNamesShort=[`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`augt`,`sep`,`oct`,`nov`,`dec`,``];name;pmDesignator=`p.m.`;shortDateFormat=`dd.MM.yyyy`;culture=`en-GB`;uiculture=`en-GB`;constructor(e){super(),this.formats={},Object.assign(this,e)}};let i=window.af?.article?.id??window.window?.location.pathname.substring(1).split(`/`)[0];async function a(e,t={},n=0){try{let r=await fetch(`/api/logging/log-activity`,{method:`POST`,body:JSON.stringify({article:i,timeElapsed:n,action:e,parameters:{...t,_session:g()}}),headers:{"Content-Type":`application/json`,Accept:`application/json`}});if(!r.ok){if(r.headers.get(`Content-Type`)?.includes(`application/json`)){let e=await r.json();console.error(e.error)}else console.error(`${r.status} ${r.statusText}`)}}catch{}}function o(e,t={}){let n=performance.now();return(r={})=>a(e,{...t,...r},performance.now()-n)}async function s(e){let t=performance.now();return[await e(),performance.now()-t]}async function c(e){try{if(!e)return;let t=typeof e==`string`?{error:e}:typeof e==`object`?`message`in e?{error:e.message,stack:e.stack??null}:{error:e.toString()}:{error:`Unspecified error`};console.error(e);let n=await fetch(`/data/Logger/LogError`,{method:`POST`,body:JSON.stringify(t),headers:{"Content-Type":`application/json; charset=utf-8`}});if(n.ok)return await n.json();console.error(Error(`Failed to log error`))}catch{}}function l(){return crypto.randomUUID?.()}function u(e,t){let n=RegExp(`/lib/@olenbetong/${e}/([^/]+)/`);for(let e of t){let t=typeof e==`string`?n.exec(e):null;if(t)return t[1]}}function d(){let e={};try{let t=document.querySelector(`script[type="importmap"]`),n=t?u(`synergi-platform`,Object.values(JSON.parse(t.textContent??`{}`).imports??{})):void 0;n&&(e[`synergi-platform`]=n)}catch{}let t=u(`synergi-chrome`,Array.from(document.scripts,e=>e.src))??window.ob?.chrome?.version;return t&&(e[`synergi-chrome`]=t),e}let f=Date.now(),p=l(),m=``,h=``;if(`document`in window){let e=()=>a(`AfSessionInit`,{"appframe-core":window.af?.common?.version,"appframe-data":window.af?.data?.version,"app-version":window.af?.article?.version,...d()});document.addEventListener(`DOMContentLoaded`,()=>{m=localStorage.getItem(`_afDeviceId`),h=sessionStorage.getItem(`_afSessionId`),m||(m=l(),localStorage.setItem(`_afDeviceId`,m)),h||(h=p,sessionStorage.setItem(`_afSessionId`,h)),e()}),document.addEventListener(`visibilitychange`,function(){document.visibilityState===`hidden`?navigator.sendBeacon(`/api/logging/log-activity`,JSON.stringify({article:i,action:`AfSessionEnd`,parameters:{_session:g()}})):e()})}function g(){return{browserSessionId:h,sessionStart:f,sessionLength:Date.now()-f,sessionId:p,deviceId:m}}window.window?.addEventListener(`error`,e=>{typeof e==`object`&&`error`in e?c(e.error):typeof e==`object`&&`message`in e&&c(e)});function ee(e){return[af?.article?.id||``,`common`,e].join(`.`)}var te=new class{isPersisted=()=>!0;getLocalStorageKey(e,t){return t?[`common`,e].join(`.`):ee(e)}get(e,t,n){let r=this.getLocalStorageKey(e,n),i=localStorage.getItem(r);return i===null?t:JSON.parse(i)}set(e,t,n){localStorage.setItem(this.getLocalStorageKey(e,n),JSON.stringify(t))}remove(e,t){let n=this.getLocalStorageKey(e,t);return localStorage.getItem(n)!==null&&(localStorage.removeItem(n),!0)}clear(){let e=ee(``);for(let t in localStorage)t.slice(0,e.length)===e&&localStorage.removeItem(t)}};function ne(e){return e?re(e).substring(0,10):null}function _(e,t=2){return String(e).padStart(t,`0`)}function re(e){return e?`${e.getFullYear()}-${_(e.getMonth()+1)}-${_(e.getDate())}T${_(e.getHours())}:${_(e.getMinutes())}:${_(e.getSeconds())}.${_(e.getMilliseconds(),3)}`:null}function ie(e){return e?e.toISOString().substring(0,16):``}function ae(e,t){return new Promise((n,r)=>{try{let r=URL.createObjectURL(e),i=document.body,a=document.createElement(`a`);a.setAttribute(`download`,t),a.href=r,i.append(a),a.click(),i.removeChild(a),setTimeout(()=>{URL.revokeObjectURL(r),n()},250)}catch(e){r(e)}})}function v(e,t){if(e)return;let n=typeof t==`function`?t():t;throw Error(n??`Invariant failed`)}async function oe(e,{fileName:t,signal:n,onProgress:r}){let i=0;r?.({status:`requested`});try{let n=await fetch(e);if(!n.ok||!n.body){if(n.headers.get(`content-type`)?.includes(`application/json`)){let e=await n.json();v(!e.error,e.error)}throw Error(`${n.status} ${n.statusText}`)}try{let e=n.body.getReader(),t=new ReadableStream({start:t=>{function n(){return e.read().then(e=>{if(e.done)t.close();else return i+=e.value.length,r?.({bytesReceived:i,status:`downloading`}),t.enqueue(e.value),n()})}return n()}});n=new Response(t)}catch{}let a=await n.blob();r?.({bytesReceived:i,status:`downloaded`}),await ae(a,t),r?.({bytesReceived:i,status:`completed`})}catch(e){n?.aborted?r?.({status:`cancelled`}):r?.({error:e.message,status:`error`})}}let se=/^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)*)\}$/,ce=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*\{([\s\S]*)\}$/,le=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*([\s\S]+)$/,y=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function ue(e){let t=e.toString(),n=t.match(ce);if(n){let t=y(n[1]??n[2]??``);return{name:e.name,args:t,body:n[3]}}let r=t.match(le);if(r){let t=y(r[1]??r[2]??``);return{name:e.name,args:t,body:r[3]}}let i=t.match(se);return v(i,`Unable to parse function!`),{name:e.name??i[1],args:y(i[2]),body:i[3]}}function de(){}de.prototype=Object.create(null);function fe(e,t){if(typeof e==`object`){if(typeof t==`string`)return fe(e,t.split(`.`));if(Array.isArray(t)){let n=e;for(let e=0;e<t.length;e++)n=n[t[e]]=n[t[e]]||new de;return n}}}function pe(e,t,n={}){if(Array.isArray(t))for(let n of t){let{name:t}=ue(n);v(t,`Unable to detect name of function! Name it, or only supply one function and include name in first parameter.`),pe(e,n)}else{let r,i;if(typeof t==`function`&&(r=ue(t).name),typeof e==`string`){let t=e.split(`.`);r||(r=t[t.length-1],t=t.slice(0,t.length-1)),i=fe(window,t)}else r&&(typeof e==`object`||typeof e==`function`)?i=e:v(!1,`Invalid typeof parameter 'name', or unable to parse pValue!`);Object.hasOwn(i,r)&&n?.overwrite!==!0?console.warn(`${[e,r].join(`.`)} is already defined!`):i[r]=t}}async function me(e,t){try{let n=await fetch(`/api/user/localize/new/${encodeURIComponent(t)}`,{body:JSON.stringify({text:e}),headers:{Accept:`application/json; */*`,"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`});if(n.ok)return await n.json()}catch{}return e}function he(e){let t=window.af;if(!t)return;if(e){let n=t.i18n?.[e];if(n)return{dictionary:n,harvestAs:e}}let n=t.article;if(n?.i18n)return{dictionary:n.i18n,harvestAs:n.id}}function b(e,t){if(typeof e==`string`&&e.trim().length===0)return e;if(e===void 0||e===``||e===null)return;let{project:n,wait:r}=typeof t==`object`?t:{wait:t},i=he(n);if(i===void 0)return e;let{dictionary:a,harvestAs:o}=i;if(!Object.hasOwn(a,e)){a[e]=e;let t=me(e,o).then(t=>(a[e]=t,t));if(r)return t}return a[e]}function ge(e){function t(t,n){return b(t,{project:e,wait:n})}function n(e,...n){let r=t(e.map((t,n)=>n===e.length-1?t:`${t}$${n}`).join(``));return n.forEach((e,t)=>{r=r.replace(`$${t}`,String(e))}),r}return{project:e,getLocalizedString:t,localize:n}}let _e=[`isnull`,`isnotnull`,`istrue`,`isfalse`,`isblank`,`isnotblank`],x=[`isbeyondthisyear`,`islaterthisyear`,`islaterthismonth`,`isnextweek`,`islaterthisweek`,`istomorrow`,`istoday`,`isyesterday`,`isearlierthisweek`,`islastweek`,`isearlierthismonth`,`isearlierthisyear`,`ispriorthisyear`],ve=[`between`,`notbetween`,`datebetween`,`datenotbetween`],ye=[`inlist`,`notinlist`];function S(e){return _e.includes(e)||x.includes(e)?`none`:ve.includes(e)?`pair`:ye.includes(e)?`list`:`single`}let be={equals:`Equal to`,notequals:`Not equal to`,greaterthan:`Greater than`,greaterthanorequal:`Greater than or equal to`,lessthan:`Less than`,lessthanorequal:`Less than or equal to`,beginswith:`Begins with`,notbeginswith:`Does not begin with`,endswith:`Ends with`,notendswith:`Does not end with`,contains:`Contains`,notcontains:`Does not contain`,like:`Like`,notlike:`Not like`,isnull:`Is null`,isnotnull:`Is not null`,isblank:`Is empty`,isnotblank:`Is not empty`,istrue:`Is true`,isfalse:`Is false`,inlist:`In list`,notinlist:`Not in list`,between:`Between`,notbetween:`Not between`,dateequals:`Equal to`,notdatequals:`Not equal to`,dategreaterthan:`After`,dategreaterthanorequal:`On or after`,datelessthan:`Before`,datelessthanorequal:`Up to`,datebetween:`Between`,datenotbetween:`Not between`,isbeyondthisyear:`Is beyond this year`,islaterthisyear:`Is later this year`,islaterthismonth:`Is later this month`,isnextweek:`Is next week`,islaterthisweek:`Is later this week`,istomorrow:`Is tomorrow`,istoday:`Is today`,isyesterday:`Is yesterday`,isearlierthisweek:`Is earlier this week`,islastweek:`Is last week`,isearlierthismonth:`Is earlier this month`,isearlierthisyear:`Is earlier this year`,ispriorthisyear:`Is prior to this year`},xe={greaterthan:`After`,greaterthanorequal:`On or after`,lessthan:`Before`,lessthanorequal:`Up to`};function Se(e,t){return b((t===`date`||t===`datetime`?xe[e]:void 0)??be[e]??e)}let C=[`equals`,`notequals`],w=[`inlist`,`notinlist`],T=[`between`,`notbetween`],E=[`greaterthan`,`greaterthanorequal`,`lessthan`,`lessthanorequal`],Ce=[`contains`,`notcontains`,`beginswith`,`notbeginswith`,`endswith`,`notendswith`,`isblank`,`isnotblank`],we={date:[...C,...w,...T,...E,...x],datetime:[...C,...w,...T,...E,...x],number:[...C,...w,...T,...E],boolean:[`istrue`,`isfalse`],string:[...C,...Ce,...w,...T,...E],uniqueidentifier:[...C,...Ce,...w,...T,...E]},Te={date:`equals`,datetime:`equals`,number:`equals`,boolean:`istrue`,string:`contains`,uniqueidentifier:`beginswith`};function Ee(e){let t=[...we[e.type]??we.string];return e.nullable&&e.type!==`boolean`&&t.push(`isnull`,`isnotnull`),t}function De(e){return Te[e.type]??`equals`}function D(e,t){if(S(t)===`none`)return`null`;switch(e.type){case`number`:return`number`;case`boolean`:return`boolean`;case`date`:case`datetime`:return`datetime`;case`uniqueidentifier`:return`uniqueidentifier`;default:return`string`}}let Oe=[`Yesterday`,`Today`,`Now`,`Tomorrow`,`DayAfterTomorrow`,`TwoWeeksAway`,`ThisWeek`,`ThisMonth`,`ThisYear`,`LastWeek`,`LastMonth`,`LastYear`,`NextWeek`,`NextMonth`,`NextYear`],ke={CurrentUser:`Current user`,Yesterday:`Yesterday`,Today:`Today`,Now:`Now`,Tomorrow:`Tomorrow`,DayAfterTomorrow:`Day after tomorrow`,TwoWeeksAway:`Two weeks away`,ThisWeek:`This week`,ThisMonth:`This month`,ThisYear:`This year`,LastWeek:`Last week`,LastMonth:`Last month`,LastYear:`Last year`,NextWeek:`Next week`,NextMonth:`Next month`,NextYear:`Next year`,UserYesterday:`Yesterday`,UserToday:`Today`,UserTomorrow:`Tomorrow`,UserThisWeek:`This week`,UserThisMonth:`This month`,UserThisYear:`This year`,UserLastWeek:`Last week`,UserLastMonth:`Last month`,UserLastYear:`Last year`,UserNextWeek:`Next week`,UserNextMonth:`Next month`,UserNextYear:`Next year`};function Ae(e){return b(ke[e]??e)}function je(e){return e.type===`date`||e.type===`datetime`?[...Oe]:e.type===`string`?[`CurrentUser`]:[]}let Me=[...C,...T,...E];function Ne(e){return Me.includes(e)}function Pe(e){return e===`datetime`?`date`:e}function Fe(e,t){if(e.type===`boolean`)return[];let n=Pe(e.type);return t.filter(t=>t.name!==e.name&&!t.excludeFromFilter&&Pe(t.type)===n)}let Ie={not:`notequals`,tweens:`notbetween`,notdate:`notdatequals`,notdateequals:`notdatequals`};function O(e){let t=e.toLowerCase().replace(/[\s,]/g,``);return Ie[t]??t}function k(){return A(`and`)}function A(e=`and`){return{type:`group`,mode:e,items:[]}}function j(e){return e.type===`group`}function M(e){return e.type===`expression`}function Le(e){return e?M(e)?{type:`group`,mode:`and`,items:[e]}:e:k()}function Re(e){if(e.mode!==`or`||e.items.length!==1)return e;let[t]=e.items;return j(t)&&t.mode===`and`?t:e}function ze(e){return N(e)===0}function N(e){return e?M(e)?1:e.items.reduce((e,t)=>e+N(t),0):0}function Be(e){if(!e)return null;if(M(e))return P(e)?{type:`group`,mode:`and`,items:[e]}:null;let t=e.items.map(e=>j(e)?Be(e):P(e)?e:null).filter(e=>e!==null);return t.length===0?null:{...e,items:t}}function P(e){if(j(e))return e.items.some(P);if(!e.column||!e.operator)return!1;let t=S(O(e.operator));return t===`none`?!0:e.value===null||e.value===void 0||e.value===``?!1:t===`pair`?Array.isArray(e.value)&&e.value.length===2&&e.value.every(e=>{let t=F(e)?e.value:e;return t!==``&&t!=null}):t!==`list`||Array.isArray(e.value)&&e.value.length>0}function F(e){return typeof e==`object`&&!!e&&!(e instanceof Date)&&`valueType`in e}let Ve=/* @__PURE__ */ new Set([`Now`,`DayAfterTomorrow`,`TwoWeeksAway`]);function He(e,t){return e===`column`||e===`special`&&typeof t==`string`&&Ve.has(t)}function Ue(e){return e?j(e)?e.items.some(Ue):x.includes(O(e.operator))||He(e.valueType,e.value)?!0:Array.isArray(e.value)&&e.value.some(e=>F(e)):!1}function We(e,t){let n=t??De(e);return{type:`expression`,column:e.name,operator:n,value:Ge(n),valueType:D(e,n)}}function Ge(e){switch(S(e)){case`none`:return null;case`pair`:return[``,``];case`list`:return[];default:return``}}function Ke(e,t,n){let r=S(O(e.operator)),i=S(t),a=e.value,o=e.valueType===`column`||Array.isArray(a)&&a.some(e=>F(e)&&e.valueType===`column`);(i!==r||o&&!Ne(t))&&(a=Ge(t));let s=(e.valueType===`special`||e.valueType===`column`)&&a===e.value?e.valueType:D(n,t);return{...e,operator:t,value:a,valueType:s}}function qe(e,t){let n=e;for(let e of t){if(!n||!j(n))return null;n=n.items[e]}return n??null}function I(e,t,n){if(t.length===0)return n(e)??e;if(!j(e))return e;let[r,...i]=t,a=e.items[r];if(!a)return e;let o=[...e.items];if(i.length===0){let e=n(a);e===null?o.splice(r,1):o[r]=e}else o[r]=I(a,i,n);return{...e,items:o}}function Je(e,t,n){return I(e,t,e=>j(e)?{...e,items:[...e.items,n]}:e)}function Ye(e,t){return t.length===0?k():I(e,t,()=>null)}function Xe(e,t,n){return I(e,t,e=>j(e)?{...e,mode:n}:e)}function Ze(e,t=[]){let n=qe(e,t);return Je(e,t,A(n&&j(n)&&n.mode===`and`?`or`:`and`))}async function Qe(e,t){let n=await fetch(`/api/filter/convert`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t});if(!n.ok)throw Error(`Failed to convert filter: ${n.status} ${n.statusText}`);let r=await n.json();return{...r,filterObject:r.filterObject?Le(r.filterObject):null}}function $e(e,t={}){return e?et(e,new Map((t.fields??[]).map(e=>[e.name.toLowerCase(),e])),0):``}function et(e,t,n){if(M(e))return tt(e,t);let r=e.items.map(e=>et(e,t,n+1)).filter(e=>e!==``);if(r.length===0)return``;if(r.length===1)return r[0];let i=e.mode===`or`?` OR `:` AND `,a=r.join(i);return n===0?a:`(${a})`}function tt(e,t){if(!e.column||!e.operator)return``;let n=t.get(e.column.toLowerCase()),r=n?.caption??e.column,i=O(e.operator),a=Se(i,n?.type),o=S(i);return o===`none`?`[${r}] ${a}`:`[${r}] ${a} ${nt(e,o,t)}`}function nt(e,t,n){let{value:r,valueType:i}=e;if(Array.isArray(r)){let e=r.map(e=>F(e)?L(e.value,e.valueType,n):L(e,i,n));return t===`pair`?e.join(` - `):`(${e.join(`, `)})`}return L(r,i,n)}function L(e,t,n){return t===`special`&&typeof e==`string`?Ae(e):t===`column`&&typeof e==`string`?`[${n.get(e.toLowerCase())?.caption??e}]`:e==null?``:e instanceof Date?e.toISOString().slice(0,10):typeof e==`number`||typeof e==`boolean`||t===`number`||t===`boolean`?String(e):`'${String(e)}'`}let rt=[`string`,`number`,`boolean`,`date`,`datetime`,`uniqueidentifier`];function it(e){let t=e?.trim().toLowerCase();return rt.find(e=>e===t)??`string`}function at(e){return e===!0||e===1}function ot(e){return{name:e.FieldName??``,type:it(e.DataType),nullable:at(e.Nullable),excludeFromFilter:at(e.ExcludeFromFilter),valueListRecordSource:e.ValueListRecordSource||void 0}}function st(e){return e.map(ot).filter(e=>e.name!==``&&!e.excludeFromFilter).sort((e,t)=>e.name.localeCompare(t.name))}function ct(e){return!e||M(e)||e.mode!==`or`?!1:e.items.every(e=>j(e)&&e.mode===`and`&&e.items.every(M))}function lt(e){if(!e)return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[]}]};if(M(e))return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[e]}]};if(e.mode===`or`){let t=e.items.map(e=>{let t=[];return R(e,t),{type:`group`,mode:`and`,items:t}});return{type:`group`,mode:`or`,items:t.length>0?t:[{type:`group`,mode:`and`,items:[]}]}}let t=[];return R(e,t),{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:t}]}}function R(e,t){if(M(e))t.push(e);else for(let n of e.items)R(n,t)}function ut(e){return{filterId:e.FilterID??-1,primKey:e.PrimKey??``,name:e.FilterName??``,criteria:e.FilterCriteria??``,dbObjectId:e.DBObjectID??``,accessLevel:dt(e.AccessLevel),createdByUser:z(e.CreatedByUser),createdBy:e.CreatedBy??``,domain:e.Domain??null,crossDomain:z(e.CrossDomain),isPersonallyShared:z(e.IsPersonallyShared),hideCriteria:z(e.HideFilterCriteria),headerText:e.OptionalHeaderText||null,comment:e.OptionalComment||null,parameters:e.Parameters||null,reportTitle:e.ReportTitle||null,created:ft(e.Created),updated:ft(e.Updated)}}function dt(e){return e===`Manager`||e===`Editor`?e:`Reader`}function z(e){return typeof e==`string`?e.toLowerCase()===`true`:!!e}function ft(e){if(!e)return null;if(e instanceof Date)return e;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function pt(e){return e.filter(e=>(e.FilterID??-1)!==-1).map(ut).sort((e,t)=>e.name.localeCompare(t.name))}function mt(e){let t=[],n=[];for(let r of e)r.createdByUser?t.push(r):n.push(r);return{mine:t,shared:n}}function ht(e,t){if(t!=null)return e.find(e=>e.filterId===t)}function gt(e){return e.accessLevel===`Editor`||e.accessLevel===`Manager`}function _t(e){return e.accessLevel===`Manager`}function B(e){return e.createdByUser}let vt=B,yt=B,bt={xs:64,sm:128,md:256,lg:512,xl:void 0};function xt(e,t,n,r=`xs`){if(e&&typeof e==`object`)return xt(e.primKey,e.login,e.hash,e.size);if(!e||!n)return``;let i=bt[r];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t??``)}${t?`.`:``}${encodeURIComponent(n)}.jpg${i?`?width=${i}`:``}`}function St(e,...t){v(Array.isArray(e)&&e.length===t.length+1,`Method 'localize' must be used as a tag function`);let n=b(e.map((t,n)=>n===e.length-1?t:`${t}$${n}`).join(``));return t.forEach((e,t)=>{n=n.replace(`$${t}`,e)}),n}let Ct={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`};function V(e){return e.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi,(e,t)=>t.startsWith(`#x`)||t.startsWith(`#X`)?String.fromCodePoint(Number.parseInt(t.slice(2),16)):t.startsWith(`#`)?String.fromCodePoint(Number.parseInt(t.slice(1),10)):Ct[t.toLowerCase()]??e)}function H(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function U(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`).exec(e);if(!n)return null;let r=V(n[1]).trim();return r===``?null:r}function wt(e,t){return[...e.matchAll(RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`))].map(e=>V(e[1]).trim())}let Tt={Byte:`number`,Decimal:`number`,Double:`number`,Int16:`number`,Int32:`number`,Int64:`number`,Single:`number`,Boolean:`boolean`,DateTime:`date`};function Et(e){let t=/<SelectColumns>([\s\S]*?)<\/SelectColumns>/.exec(e)?.[1]??``,n=[];for(let e of t.matchAll(/<afSelectColumn>([\s\S]*?)<\/afSelectColumn>/g)){let t=U(e[1],`Name`);t&&n.push({name:t,type:Tt[U(e[1],`DataType`)??``]??`string`})}return n}function W(e){if(!e||!e.includes(`<afRecordSource`))return null;let t=U(e,`ViewName`);if(!t)return null;let n=U(e,`MaxRecords`);return{viewName:t,columns:Et(e),whereClause:U(e,`WhereClause`),filterString:U(e,`FilterString`),maxRecords:n===null||n===`0`?null:Number(n)}}let Dt=[`String`,`Integer`,`Double`,`Date`,`Boolean`],Ot=/^[a-z]stp_/i;function G(e){return typeof e==`string`&&Ot.test(e.trim())}function kt(e){return e?e.split(/\r\n|\r|\n/).map(e=>e.trim()).filter(e=>e!==``):[]}function At(e){return Dt.find(t=>t.toLowerCase()===e?.trim().toLowerCase())??`String`}function jt(e,t,n){if(t)return`lookup`;if(n)return`select`;switch(e){case`Integer`:case`Double`:return`number`;case`Date`:return`date`;case`Boolean`:return`boolean`;default:return`text`}}function Mt(e){let t=e.Name??``,n=At(e.DataType),r=kt(e.Items),i=W(e.RecordSource),a=e.ValueMember??null;i&&!a&&(a=i.columns[0]?.name??null);let o=i?.columns.find(e=>e.name!==a)?.name??null,s=!!(i&&a);return{name:t,label:e.Label?.trim()||t,description:e.Description?.trim()||null,type:n,editor:jt(n,s,r.length>0),defaultValue:e.DefaultValue??null,items:r,recordSource:s?i:null,valueMember:s?a:null,displayMember:s?o:null,sortOrder:e.SortOrder??0,lookupWidth:e.LookupWidth??null,lookupHeight:e.LookupHeight??null}}function Nt(e){return e.filter(e=>e.Name).map(Mt).sort((e,t)=>e.sortOrder-t.sortOrder||e.label.localeCompare(t.label))}function K(e,t){if(t==null||t===``)return e.type!==`Boolean`&&null;switch(e.type){case`Boolean`:return typeof t==`boolean`?t:/^(true|1|ja|yes)$/i.test(String(t));case`Integer`:{let e=Number.parseInt(String(t),10);return Number.isNaN(e)?null:e}case`Double`:{let e=Number(String(t).replace(`,`,`.`));return Number.isNaN(e)?null:e}default:return String(t)}}function Pt(e){let t={};for(let n of e)t[n.name]=G(n.defaultValue)?K(n,null):K(n,n.defaultValue);return t}function Ft(e,t){return t==null?``:typeof t==`boolean`?t?`True`:`False`:String(t)}function It(e,t){return`<Parameters Version="1">\n${e.map(e=>{let n=Ft(e,t[e.name]??null);return` <Parameter Name="${H(e.name)}" Type="${e.type}">${H(n)}</Parameter>`}).join(`
|
|
2
|
-
`)}\n</Parameters>`}function
|
|
1
|
+
this.af=this.af||{},this.af.common=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return{all:e||=/* @__PURE__ */ new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}var n=class{eventHandler=t();authenticated(){this.eventHandler.emit(`onAuthenticated`)}async expired(e,t){try{let n=new Promise(t=>{let n=()=>{this.eventHandler.off(`onAuthenticated`,n),e?.(),t()};this.eventHandler.on(`onAuthenticated`,n)}),r=document.querySelector(`dialog.session-expired-dialog`);if(r)await n;else{r=document.createElement(`dialog`),r.className=`session-expired-dialog`,r.style.display=`flex`,r.style.padding=`0`,r.style.left=`50%`,r.style.transform=`translateX(-50%)`;let e=`/login?ReturnUrl=%2fapi/sessionexpired/remove`;t===`RequireTwoFactor`?e=`/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove`:await fetch(`/logout`,{method:`POST`}),r.innerHTML=`<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${e}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(r),r.showModal(),await n,r.remove()}}catch{window.location.href=`/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`}}attachEvent(e,t){return this.eventHandler.on(e,t)}detachEvent(e,t){return this.eventHandler.off(e,t)}},r=class extends n{amDesignator=`a.m.`;dayNames=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`];dayNamesShort=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];decimalSeparator=`.`;domain=`OB`;email;formats;groupSeparator=null;integratedSecurity=!1;isDeveloper=!1;login=``;loginType;monthNames=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`,``];monthNamesShort=[`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`augt`,`sep`,`oct`,`nov`,`dec`,``];name;pmDesignator=`p.m.`;shortDateFormat=`dd.MM.yyyy`;culture=`en-GB`;uiculture=`en-GB`;constructor(e){super(),this.formats={},Object.assign(this,e)}};let i=window.af?.article?.id??window.window?.location.pathname.substring(1).split(`/`)[0];async function a(e,t={},n=0){try{let r=await fetch(`/api/logging/log-activity`,{method:`POST`,body:JSON.stringify({article:i,timeElapsed:n,action:e,parameters:{...t,_session:g()}}),headers:{"Content-Type":`application/json`,Accept:`application/json`}});if(!r.ok){if(r.headers.get(`Content-Type`)?.includes(`application/json`)){let e=await r.json();console.error(e.error)}else console.error(`${r.status} ${r.statusText}`)}}catch{}}function o(e,t={}){let n=performance.now();return(r={})=>a(e,{...t,...r},performance.now()-n)}async function s(e){let t=performance.now();return[await e(),performance.now()-t]}async function c(e){try{if(!e)return;let t=typeof e==`string`?{error:e}:typeof e==`object`?`message`in e?{error:e.message,stack:e.stack??null}:{error:e.toString()}:{error:`Unspecified error`};console.error(e);let n=await fetch(`/data/Logger/LogError`,{method:`POST`,body:JSON.stringify(t),headers:{"Content-Type":`application/json; charset=utf-8`}});if(n.ok)return await n.json();console.error(Error(`Failed to log error`))}catch{}}function l(){return crypto.randomUUID?.()}function u(e,t){let n=RegExp(`/lib/@olenbetong/${e}/([^/]+)/`);for(let e of t){let t=typeof e==`string`?n.exec(e):null;if(t)return t[1]}}function d(){let e={};try{let t=document.querySelector(`script[type="importmap"]`),n=t?u(`synergi-platform`,Object.values(JSON.parse(t.textContent??`{}`).imports??{})):void 0;n&&(e[`synergi-platform`]=n)}catch{}let t=u(`synergi-chrome`,Array.from(document.scripts,e=>e.src))??window.ob?.chrome?.version;return t&&(e[`synergi-chrome`]=t),e}let f=Date.now(),p=l(),m=``,h=``;if(`document`in window){let e=()=>a(`AfSessionInit`,{"appframe-core":window.af?.common?.version,"appframe-data":window.af?.data?.version,"app-version":window.af?.article?.version,...d()});document.addEventListener(`DOMContentLoaded`,()=>{m=localStorage.getItem(`_afDeviceId`),h=sessionStorage.getItem(`_afSessionId`),m||(m=l(),localStorage.setItem(`_afDeviceId`,m)),h||(h=p,sessionStorage.setItem(`_afSessionId`,h)),e()}),document.addEventListener(`visibilitychange`,function(){document.visibilityState===`hidden`?navigator.sendBeacon(`/api/logging/log-activity`,JSON.stringify({article:i,action:`AfSessionEnd`,parameters:{_session:g()}})):e()})}function g(){return{browserSessionId:h,sessionStart:f,sessionLength:Date.now()-f,sessionId:p,deviceId:m}}window.window?.addEventListener(`error`,e=>{typeof e==`object`&&`error`in e?c(e.error):typeof e==`object`&&`message`in e&&c(e)});function ee(e){return[af?.article?.id||``,`common`,e].join(`.`)}var te=new class{isPersisted=()=>!0;getLocalStorageKey(e,t){return t?[`common`,e].join(`.`):ee(e)}get(e,t,n){let r=this.getLocalStorageKey(e,n),i=localStorage.getItem(r);return i===null?t:JSON.parse(i)}set(e,t,n){localStorage.setItem(this.getLocalStorageKey(e,n),JSON.stringify(t))}remove(e,t){let n=this.getLocalStorageKey(e,t);return localStorage.getItem(n)!==null&&(localStorage.removeItem(n),!0)}clear(){let e=ee(``);for(let t in localStorage)t.slice(0,e.length)===e&&localStorage.removeItem(t)}};function ne(e){return e?re(e).substring(0,10):null}function _(e,t=2){return String(e).padStart(t,`0`)}function re(e){return e?`${e.getFullYear()}-${_(e.getMonth()+1)}-${_(e.getDate())}T${_(e.getHours())}:${_(e.getMinutes())}:${_(e.getSeconds())}.${_(e.getMilliseconds(),3)}`:null}function ie(e){return e?e.toISOString().substring(0,16):``}function ae(e,t){return new Promise((n,r)=>{try{let r=URL.createObjectURL(e),i=document.body,a=document.createElement(`a`);a.setAttribute(`download`,t),a.href=r,i.append(a),a.click(),i.removeChild(a),setTimeout(()=>{URL.revokeObjectURL(r),n()},250)}catch(e){r(e)}})}function v(e,t){if(e)return;let n=typeof t==`function`?t():t;throw Error(n??`Invariant failed`)}async function oe(e,{fileName:t,signal:n,onProgress:r}){let i=0;r?.({status:`requested`});try{let n=await fetch(e);if(!n.ok||!n.body){if(n.headers.get(`content-type`)?.includes(`application/json`)){let e=await n.json();v(!e.error,e.error)}throw Error(`${n.status} ${n.statusText}`)}try{let e=n.body.getReader(),t=new ReadableStream({start:t=>{function n(){return e.read().then(e=>{if(e.done)t.close();else return i+=e.value.length,r?.({bytesReceived:i,status:`downloading`}),t.enqueue(e.value),n()})}return n()}});n=new Response(t)}catch{}let a=await n.blob();r?.({bytesReceived:i,status:`downloaded`}),await ae(a,t),r?.({bytesReceived:i,status:`completed`})}catch(e){n?.aborted?r?.({status:`cancelled`}):r?.({error:e.message,status:`error`})}}let se=/^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)*)\}$/,ce=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*\{([\s\S]*)\}$/,le=/^(?:\(([^)]*)\)|([a-zA-Z$_][a-zA-Z0-9$_]*))\s*=>\s*([\s\S]+)$/,y=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function ue(e){let t=e.toString(),n=t.match(ce);if(n){let t=y(n[1]??n[2]??``);return{name:e.name,args:t,body:n[3]}}let r=t.match(le);if(r){let t=y(r[1]??r[2]??``);return{name:e.name,args:t,body:r[3]}}let i=t.match(se);return v(i,`Unable to parse function!`),{name:e.name??i[1],args:y(i[2]),body:i[3]}}function de(){}de.prototype=Object.create(null);function fe(e,t){if(typeof e==`object`){if(typeof t==`string`)return fe(e,t.split(`.`));if(Array.isArray(t)){let n=e;for(let e=0;e<t.length;e++)n=n[t[e]]=n[t[e]]||new de;return n}}}function pe(e,t,n={}){if(Array.isArray(t))for(let n of t){let{name:t}=ue(n);v(t,`Unable to detect name of function! Name it, or only supply one function and include name in first parameter.`),pe(e,n)}else{let r,i;if(typeof t==`function`&&(r=ue(t).name),typeof e==`string`){let t=e.split(`.`);r||(r=t[t.length-1],t=t.slice(0,t.length-1)),i=fe(window,t)}else r&&(typeof e==`object`||typeof e==`function`)?i=e:v(!1,`Invalid typeof parameter 'name', or unable to parse pValue!`);Object.hasOwn(i,r)&&n?.overwrite!==!0?console.warn(`${[e,r].join(`.`)} is already defined!`):i[r]=t}}async function me(e,t){try{let n=await fetch(`/api/user/localize/new/${encodeURIComponent(t)}`,{body:JSON.stringify({text:e}),headers:{Accept:`application/json; */*`,"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`});if(n.ok)return await n.json()}catch{}return e}function he(e){let t=window.af;if(!t)return;if(e){let n=t.i18n?.[e];if(n)return{dictionary:n,harvestAs:e}}let n=t.article;if(n?.i18n)return{dictionary:n.i18n,harvestAs:n.id}}function b(e,t){if(typeof e==`string`&&e.trim().length===0)return e;if(e===void 0||e===``||e===null)return;let{project:n,wait:r}=typeof t==`object`?t:{wait:t},i=he(n);if(i===void 0)return e;let{dictionary:a,harvestAs:o}=i;if(!Object.hasOwn(a,e)){a[e]=e;let t=me(e,o).then(t=>(a[e]=t,t));if(r)return t}return a[e]}function ge(e){function t(t,n){return b(t,{project:e,wait:n})}function n(e,...n){let r=t(e.map((t,n)=>n===e.length-1?t:`${t}$${n}`).join(``));return n.forEach((e,t)=>{r=r.replace(`$${t}`,String(e))}),r}return{project:e,getLocalizedString:t,localize:n}}let _e=[`isnull`,`isnotnull`,`istrue`,`isfalse`,`isblank`,`isnotblank`],x=[`isbeyondthisyear`,`islaterthisyear`,`islaterthismonth`,`isnextweek`,`islaterthisweek`,`istomorrow`,`istoday`,`isyesterday`,`isearlierthisweek`,`islastweek`,`isearlierthismonth`,`isearlierthisyear`,`ispriorthisyear`],ve=[`between`,`notbetween`,`datebetween`,`datenotbetween`],ye=[`inlist`,`notinlist`];function S(e){return _e.includes(e)||x.includes(e)?`none`:ve.includes(e)?`pair`:ye.includes(e)?`list`:`single`}let be={equals:`Equal to`,notequals:`Not equal to`,greaterthan:`Greater than`,greaterthanorequal:`Greater than or equal to`,lessthan:`Less than`,lessthanorequal:`Less than or equal to`,beginswith:`Begins with`,notbeginswith:`Does not begin with`,endswith:`Ends with`,notendswith:`Does not end with`,contains:`Contains`,notcontains:`Does not contain`,like:`Like`,notlike:`Not like`,isnull:`Is null`,isnotnull:`Is not null`,isblank:`Is empty`,isnotblank:`Is not empty`,istrue:`Is true`,isfalse:`Is false`,inlist:`In list`,notinlist:`Not in list`,between:`Between`,notbetween:`Not between`,dateequals:`Equal to`,notdatequals:`Not equal to`,dategreaterthan:`After`,dategreaterthanorequal:`On or after`,datelessthan:`Before`,datelessthanorequal:`Up to`,datebetween:`Between`,datenotbetween:`Not between`,isbeyondthisyear:`Is beyond this year`,islaterthisyear:`Is later this year`,islaterthismonth:`Is later this month`,isnextweek:`Is next week`,islaterthisweek:`Is later this week`,istomorrow:`Is tomorrow`,istoday:`Is today`,isyesterday:`Is yesterday`,isearlierthisweek:`Is earlier this week`,islastweek:`Is last week`,isearlierthismonth:`Is earlier this month`,isearlierthisyear:`Is earlier this year`,ispriorthisyear:`Is prior to this year`},xe={greaterthan:`After`,greaterthanorequal:`On or after`,lessthan:`Before`,lessthanorequal:`Up to`};function Se(e,t){return b((t===`date`||t===`datetime`?xe[e]:void 0)??be[e]??e)}let C=[`equals`,`notequals`],w=[`inlist`,`notinlist`],T=[`between`,`notbetween`],E=[`greaterthan`,`greaterthanorequal`,`lessthan`,`lessthanorequal`],Ce=[`contains`,`notcontains`,`beginswith`,`notbeginswith`,`endswith`,`notendswith`,`isblank`,`isnotblank`],we={date:[...C,...w,...T,...E,...x],datetime:[...C,...w,...T,...E,...x],number:[...C,...w,...T,...E],boolean:[`istrue`,`isfalse`],string:[...C,...Ce,...w,...T,...E],uniqueidentifier:[...C,...Ce,...w,...T,...E]},Te={date:`equals`,datetime:`equals`,number:`equals`,boolean:`istrue`,string:`contains`,uniqueidentifier:`beginswith`};function Ee(e){let t=[...we[e.type]??we.string];return e.nullable&&e.type!==`boolean`&&t.push(`isnull`,`isnotnull`),t}function De(e){return Te[e.type]??`equals`}function D(e,t){if(S(t)===`none`)return`null`;switch(e.type){case`number`:return`number`;case`boolean`:return`boolean`;case`date`:case`datetime`:return`datetime`;case`uniqueidentifier`:return`uniqueidentifier`;default:return`string`}}let Oe=[`Yesterday`,`Today`,`Now`,`Tomorrow`,`DayAfterTomorrow`,`TwoWeeksAway`,`ThisWeek`,`ThisMonth`,`ThisYear`,`LastWeek`,`LastMonth`,`LastYear`,`NextWeek`,`NextMonth`,`NextYear`],ke={CurrentUser:`Current user`,Yesterday:`Yesterday`,Today:`Today`,Now:`Now`,Tomorrow:`Tomorrow`,DayAfterTomorrow:`Day after tomorrow`,TwoWeeksAway:`Two weeks away`,ThisWeek:`This week`,ThisMonth:`This month`,ThisYear:`This year`,LastWeek:`Last week`,LastMonth:`Last month`,LastYear:`Last year`,NextWeek:`Next week`,NextMonth:`Next month`,NextYear:`Next year`,UserYesterday:`Yesterday`,UserToday:`Today`,UserTomorrow:`Tomorrow`,UserThisWeek:`This week`,UserThisMonth:`This month`,UserThisYear:`This year`,UserLastWeek:`Last week`,UserLastMonth:`Last month`,UserLastYear:`Last year`,UserNextWeek:`Next week`,UserNextMonth:`Next month`,UserNextYear:`Next year`};function Ae(e){return b(ke[e]??e)}function je(e){return e.type===`date`||e.type===`datetime`?[...Oe]:e.type===`string`?[`CurrentUser`]:[]}let Me=[...C,...T,...E];function Ne(e){return Me.includes(e)}function Pe(e){return e===`datetime`?`date`:e}function Fe(e,t){if(e.type===`boolean`)return[];let n=Pe(e.type);return t.filter(t=>t.name!==e.name&&!t.excludeFromFilter&&Pe(t.type)===n)}let Ie={not:`notequals`,tweens:`notbetween`,notdate:`notdatequals`,notdateequals:`notdatequals`};function O(e){let t=e.toLowerCase().replace(/[\s,]/g,``);return Ie[t]??t}function k(){return A(`and`)}function A(e=`and`){return{type:`group`,mode:e,items:[]}}function j(e){return e.type===`group`}function M(e){return e.type===`expression`}function Le(e){return e?M(e)?{type:`group`,mode:`and`,items:[e]}:e:k()}function Re(e){if(e.mode!==`or`||e.items.length!==1)return e;let[t]=e.items;return j(t)&&t.mode===`and`?t:e}function ze(e){return N(e)===0}function N(e){return e?M(e)?1:e.items.reduce((e,t)=>e+N(t),0):0}function Be(e){if(!e)return null;if(M(e))return P(e)?{type:`group`,mode:`and`,items:[e]}:null;let t=e.items.map(e=>j(e)?Be(e):P(e)?e:null).filter(e=>e!==null);return t.length===0?null:{...e,items:t}}function P(e){if(j(e))return e.items.some(P);if(!e.column||!e.operator)return!1;let t=S(O(e.operator));return t===`none`?!0:e.value===null||e.value===void 0||e.value===``?!1:t===`pair`?Array.isArray(e.value)&&e.value.length===2&&e.value.every(e=>{let t=F(e)?e.value:e;return t!==``&&t!=null}):t!==`list`||Array.isArray(e.value)&&e.value.length>0}function F(e){return typeof e==`object`&&!!e&&!(e instanceof Date)&&`valueType`in e}let Ve=/* @__PURE__ */ new Set([`Now`,`DayAfterTomorrow`,`TwoWeeksAway`]);function He(e,t){return e===`column`||e===`special`&&typeof t==`string`&&Ve.has(t)}function Ue(e){return e?j(e)?e.items.some(Ue):x.includes(O(e.operator))||He(e.valueType,e.value)?!0:Array.isArray(e.value)&&e.value.some(e=>F(e)):!1}function We(e,t){let n=t??De(e);return{type:`expression`,column:e.name,operator:n,value:Ge(n),valueType:D(e,n)}}function Ge(e){switch(S(e)){case`none`:return null;case`pair`:return[``,``];case`list`:return[];default:return``}}function Ke(e,t,n){let r=S(O(e.operator)),i=S(t),a=e.value,o=e.valueType===`column`||Array.isArray(a)&&a.some(e=>F(e)&&e.valueType===`column`);(i!==r||o&&!Ne(t))&&(a=Ge(t));let s=(e.valueType===`special`||e.valueType===`column`)&&a===e.value?e.valueType:D(n,t);return{...e,operator:t,value:a,valueType:s}}function qe(e,t){let n=e;for(let e of t){if(!n||!j(n))return null;n=n.items[e]}return n??null}function I(e,t,n){if(t.length===0)return n(e)??e;if(!j(e))return e;let[r,...i]=t,a=e.items[r];if(!a)return e;let o=[...e.items];if(i.length===0){let e=n(a);e===null?o.splice(r,1):o[r]=e}else o[r]=I(a,i,n);return{...e,items:o}}function Je(e,t,n){return I(e,t,e=>j(e)?{...e,items:[...e.items,n]}:e)}function Ye(e,t){return t.length===0?k():I(e,t,()=>null)}function Xe(e,t,n){return I(e,t,e=>j(e)?{...e,mode:n}:e)}function Ze(e,t=[]){let n=qe(e,t);return Je(e,t,A(n&&j(n)&&n.mode===`and`?`or`:`and`))}async function Qe(e,t){let n=await fetch(`/api/filter/convert`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t});if(!n.ok)throw Error(`Failed to convert filter: ${n.status} ${n.statusText}`);let r=await n.json();return{...r,filterObject:r.filterObject?Le(r.filterObject):null}}function $e(e,t={}){return e?et(e,new Map((t.fields??[]).map(e=>[e.name.toLowerCase(),e])),0):``}function et(e,t,n){if(M(e))return tt(e,t);let r=e.items.map(e=>et(e,t,n+1)).filter(e=>e!==``);if(r.length===0)return``;if(r.length===1)return r[0];let i=e.mode===`or`?` OR `:` AND `,a=r.join(i);return n===0?a:`(${a})`}function tt(e,t){if(!e.column||!e.operator)return``;let n=t.get(e.column.toLowerCase()),r=n?.caption??e.column,i=O(e.operator),a=Se(i,n?.type),o=S(i);return o===`none`?`[${r}] ${a}`:`[${r}] ${a} ${nt(e,o,t)}`}function nt(e,t,n){let{value:r,valueType:i}=e;if(Array.isArray(r)){let e=r.map(e=>F(e)?L(e.value,e.valueType,n):L(e,i,n));return t===`pair`?e.join(` - `):`(${e.join(`, `)})`}return L(r,i,n)}function L(e,t,n){return t===`special`&&typeof e==`string`?Ae(e):t===`column`&&typeof e==`string`?`[${n.get(e.toLowerCase())?.caption??e}]`:e==null?``:e instanceof Date?e.toISOString().slice(0,10):typeof e==`number`||typeof e==`boolean`||t===`number`||t===`boolean`?String(e):`'${String(e)}'`}let rt=[`string`,`number`,`boolean`,`date`,`datetime`,`uniqueidentifier`];function it(e){let t=e?.trim().toLowerCase();return rt.find(e=>e===t)??`string`}function at(e){return e===!0||e===1}function ot(e){return{name:e.FieldName??``,type:it(e.DataType),nullable:at(e.Nullable),excludeFromFilter:at(e.ExcludeFromFilter),valueListRecordSource:e.ValueListRecordSource||void 0}}function st(e){return e.map(ot).filter(e=>e.name!==``&&!e.excludeFromFilter).sort((e,t)=>e.name.localeCompare(t.name))}function ct(e){return!e||M(e)||e.mode!==`or`?!1:e.items.every(e=>j(e)&&e.mode===`and`&&e.items.every(M))}function lt(e){if(!e)return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[]}]};if(M(e))return{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:[e]}]};if(e.mode===`or`){let t=e.items.map(e=>{let t=[];return R(e,t),{type:`group`,mode:`and`,items:t}});return{type:`group`,mode:`or`,items:t.length>0?t:[{type:`group`,mode:`and`,items:[]}]}}let t=[];return R(e,t),{type:`group`,mode:`or`,items:[{type:`group`,mode:`and`,items:t}]}}function R(e,t){if(M(e))t.push(e);else for(let n of e.items)R(n,t)}function ut(e){return{filterId:e.FilterID??-1,primKey:e.PrimKey??``,name:e.FilterName??``,criteria:e.FilterCriteria??``,dbObjectId:e.DBObjectID??``,accessLevel:dt(e.AccessLevel),createdByUser:z(e.CreatedByUser),createdBy:e.CreatedBy??``,domain:e.Domain??null,crossDomain:z(e.CrossDomain),isPersonallyShared:z(e.IsPersonallyShared),hideCriteria:z(e.HideFilterCriteria),headerText:e.OptionalHeaderText||null,comment:e.OptionalComment||null,parameters:e.Parameters||null,reportTitle:e.ReportTitle||null,created:ft(e.Created),updated:ft(e.Updated)}}function dt(e){return e===`Manager`||e===`Editor`?e:`Reader`}function z(e){return typeof e==`string`?e.toLowerCase()===`true`:!!e}function ft(e){if(!e)return null;if(e instanceof Date)return e;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function pt(e){return e.filter(e=>(e.FilterID??-1)!==-1).map(ut).sort((e,t)=>e.name.localeCompare(t.name))}function mt(e){let t=[],n=[];for(let r of e)r.createdByUser?t.push(r):n.push(r);return{mine:t,shared:n}}function ht(e,t){if(t!=null)return e.find(e=>e.filterId===t)}function gt(e){return e.accessLevel===`Editor`||e.accessLevel===`Manager`}function _t(e){return e.accessLevel===`Manager`}function B(e){return e.createdByUser}let vt=B,yt=B,bt={xs:64,sm:128,md:256,lg:512,xl:void 0};function xt(e,t,n,r=`xs`){if(e&&typeof e==`object`)return xt(e.primKey,e.login,e.hash,e.size);if(!e||!n)return``;let i=bt[r];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t??``)}${t?`.`:``}${encodeURIComponent(n)}.jpg${i?`?width=${i}`:``}`}function St(e,...t){v(Array.isArray(e)&&e.length===t.length+1,`Method 'localize' must be used as a tag function`);let n=b(e.map((t,n)=>n===e.length-1?t:`${t}$${n}`).join(``));return t.forEach((e,t)=>{n=n.replace(`$${t}`,e)}),n}let Ct={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`};function V(e){return e.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi,(e,t)=>t.startsWith(`#x`)||t.startsWith(`#X`)?String.fromCodePoint(Number.parseInt(t.slice(2),16)):t.startsWith(`#`)?String.fromCodePoint(Number.parseInt(t.slice(1),10)):Ct[t.toLowerCase()]??e)}function H(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function U(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`).exec(e);if(!n)return null;let r=V(n[1]).trim();return r===``?null:r}function wt(e,t){return[...e.matchAll(RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`))].map(e=>V(e[1]).trim())}let Tt={Byte:`number`,Decimal:`number`,Double:`number`,Int16:`number`,Int32:`number`,Int64:`number`,Single:`number`,Boolean:`boolean`,DateTime:`date`};function Et(e){let t=/<SelectColumns>([\s\S]*?)<\/SelectColumns>/.exec(e)?.[1]??``,n=[];for(let e of t.matchAll(/<afSelectColumn>([\s\S]*?)<\/afSelectColumn>/g)){let t=U(e[1],`Name`);t&&n.push({name:t,type:Tt[U(e[1],`DataType`)??``]??`string`})}return n}function Dt(e){if(!e)return null;let t=[...e.matchAll(/<(afRecordSource|afReportRecordSource)(?:\s[^>]*)?>([\s\S]*?)<\/\1>/g)].map(e=>e[2]);return t.length===0?null:t.find(e=>U(e,`ID`)===`Master`)??t[0]}function W(e){let t=Dt(e);if(!t)return null;let n=U(t,`ViewName`);if(!n)return null;let r=U(t,`MaxRecords`);return{viewName:n,columns:Et(t),whereClause:U(t,`WhereClause`),filterString:U(t,`FilterString`),maxRecords:r===null||r===`0`?null:Number(r)}}let Ot=[`String`,`Integer`,`Double`,`Date`,`Boolean`],kt=/^[a-z]stp_/i;function G(e){return typeof e==`string`&&kt.test(e.trim())}function At(e){return e?e.split(/\r\n|\r|\n/).map(e=>e.trim()).filter(e=>e!==``):[]}function jt(e){return Ot.find(t=>t.toLowerCase()===e?.trim().toLowerCase())??`String`}function Mt(e,t,n){if(t)return`lookup`;if(n)return`select`;switch(e){case`Integer`:case`Double`:return`number`;case`Date`:return`date`;case`Boolean`:return`boolean`;default:return`text`}}function Nt(e){let t=e.Name??``,n=jt(e.DataType),r=At(e.Items),i=W(e.RecordSource),a=e.ValueMember??null;i&&!a&&(a=i.columns[0]?.name??null);let o=i?.columns.find(e=>e.name!==a)?.name??null,s=!!(i&&a);return{name:t,label:e.Label?.trim()||t,description:e.Description?.trim()||null,type:n,editor:Mt(n,s,r.length>0),defaultValue:e.DefaultValue??null,items:r,recordSource:s?i:null,valueMember:s?a:null,displayMember:s?o:null,sortOrder:e.SortOrder??0,lookupWidth:e.LookupWidth??null,lookupHeight:e.LookupHeight??null}}function Pt(e){return e.filter(e=>e.Name).map(Nt).sort((e,t)=>e.sortOrder-t.sortOrder||e.label.localeCompare(t.label))}function K(e,t){if(t==null||t===``)return e.type!==`Boolean`&&null;switch(e.type){case`Boolean`:return typeof t==`boolean`?t:/^(true|1|ja|yes)$/i.test(String(t));case`Integer`:{let e=Number.parseInt(String(t),10);return Number.isNaN(e)?null:e}case`Double`:{let e=Number(String(t).replace(`,`,`.`));return Number.isNaN(e)?null:e}default:return String(t)}}function Ft(e){let t={};for(let n of e)t[n.name]=G(n.defaultValue)?K(n,null):K(n,n.defaultValue);return t}function It(e,t){return t==null?``:typeof t==`boolean`?t?`True`:`False`:String(t)}function Lt(e,t){return`<Parameters Version="1">\n${e.map(e=>{let n=It(e,t[e.name]??null);return` <Parameter Name="${H(e.name)}" Type="${e.type}">${H(n)}</Parameter>`}).join(`
|
|
2
|
+
`)}\n</Parameters>`}function Rt(e){if(!e)return{};let t={};for(let n of e.matchAll(/<Parameter\s+([^>]*?)\/?>(?:([\s\S]*?)<\/Parameter>)?/g)){let e=/Name\s*=\s*"([^"]*)"/.exec(n[1])?.[1];e&&(t[e]=U(n[0],`Parameter`)??``)}return t}function zt(e,t){let n=Rt(t),r=Ft(e);for(let t of e)t.name in n&&(r[t.name]=K(t,n[t.name]));return r}async function Bt(e,t,n){if(!t.defaultValue||!G(t.defaultValue))return null;let r=await fetch(`/api/reporting/filters/${encodeURIComponent(e)}/GetParameterDefaultValue`,{body:JSON.stringify({parameterName:t.name}),credentials:`same-origin`,headers:{"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`,signal:n});if(!r.ok)throw Error(`${r.status} ${r.statusText}`);return Ht(await r.json())}async function Vt(e,t,n,r){let i=t.filter(e=>G(e.defaultValue??``));if(i.length===0)return n;let a=await Promise.all(i.map(async t=>{try{return[t.name,await Bt(e,t,r)]}catch{return[t.name,null]}})),o={...n};for(let[e,t]of a)t!==null&&(o[e]=t);return o}function Ht(e){let t=(Array.isArray(e)?e:Object.values(e).find(e=>Array.isArray(e)))?.[0];return t==null?null:Array.isArray(t)?t[0]??null:typeof t==`object`?Object.values(t)[0]??null:t}let Ut={CSV:`csv`,HTML:`html`,IMAGE:`xbm`,MHT:`mht`,PDF:`pdf`,RTF:`rtf`,TEXT:`txt`,XLS:`xls`,XLSX:`xlsx`},Wt={CSV:`text/csv`,HTML:`text/html`,IMAGE:`image/x-xbitmap`,MHT:`message/rfc822`,PDF:`application/pdf`,RTF:`text/enriched`,TEXT:`text/plain`,XLS:`application/vnd.ms-excel`,XLSX:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`};function Gt(e){return Ut[e]}function q(e){return Wt[e]}let Kt=/[\\/:*?"<>|.#&+%\u0000-\u001f]/g;function J(e){let t=(e.fileName??e.reportId).trim().replace(Kt,`-`).replace(/-{2,}/g,`-`).replace(/^-|-$/g,``).trim();return`${t===``?e.reportId:t}.${Gt(e.format)}`}function qt(e){let t=window.location?.href;return t?new URL(e,t).toString():e}function Y(e){let{domain:t,filter:n,headerText:r,hideFilterString:i,parameters:a,reportId:o,signal:s,timezone:c}=e,l=J(e),u=`/api/report/${encodeURIComponent(o)}/${encodeURIComponent(l)}`,d=new URLSearchParams,f=Xt(a),p=f.length>0||!!r||i===!0;if(t&&d.set(`Domain`,t),d.set(`timezone`,String(c??-(/* @__PURE__ */ new Date()).getTimezoneOffset()/60)),!p)return n&&d.set(`Filter`,n),new Request(qt(`${u}?${d}`),{credentials:`same-origin`,signal:s});let m={filter:n??``,parameters:f};return r&&(m.optionalheader=r),i===!0&&(m.showfiltercriteria=`true`),new Request(qt(`${u}?${d}`),{body:JSON.stringify(m),credentials:`same-origin`,headers:{"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`},method:`POST`,signal:s})}async function X(e){let t=await fetch(Y(e));if((t.headers.get(`content-type`)??``).includes(`application/json`)){let e=await t.json();throw Error(e.error??`Failed to render report`)}if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.blob()}function Jt(e){return oe(Y(e),{fileName:J(e),onProgress:e.onProgress,signal:e.signal})}async function Z(e){let t=await X(e),n=URL.createObjectURL(t.type?t:new Blob([t],{type:q(e.format)})),r=window.open(n,`_blank`);if(!r)throw URL.revokeObjectURL(n),Error(`The report could not be opened. Allow pop-ups for this site and try again.`);r.opener=null,window.setTimeout(()=>URL.revokeObjectURL(n),6e4)}async function Yt(e){let t=window.document;if(!t?.body)return Z(e);let n=await X(e),r=URL.createObjectURL(n.type?n:new Blob([n],{type:q(e.format)})),i=t.createElement(`iframe`);i.setAttribute(`aria-hidden`,`true`),i.style.cssText=`position:fixed;inset-block-start:0;inset-inline-start:0;inline-size:1px;block-size:1px;border:0;visibility:hidden`;let a=()=>{i.remove(),URL.revokeObjectURL(r)};try{await new Promise((e,n)=>{i.addEventListener(`load`,()=>e(),{once:!0}),i.addEventListener(`error`,()=>n(/* @__PURE__ */ Error(`The report could not be loaded for printing`)),{once:!0}),i.src=r,t.body.append(i)}),i.contentWindow?.focus(),i.contentWindow?.print()}catch{return a(),Z(e)}window.setTimeout(a,6e4)}function Xt(e){return e?Object.entries(e).filter(([,e])=>e!=null&&e!==``).map(([e,t])=>({name:e,value:typeof t==`boolean`?String(t):t})):[]}function Q(e){return e===!0||e===1}function Zt(e){let t=[];return Q(e.FormatPDF)&&t.push(`PDF`),Q(e.FormatCSV)&&t.push(`XLSX`,`XLS`,`CSV`),Q(e.FormatHTML)&&t.push(`HTML`),Q(e.FormatRTF)&&t.push(`RTF`),Q(e.FormatMHT)&&t.push(`MHT`),Q(e.FormatTEXT)&&t.push(`TEXT`),Q(e.FormatIMAGE)&&t.push(`IMAGE`),t}function Qt(e){let t=W(e.RecordSource);return{reportId:e.ReportID??``,shortId:e.ShortID??null,title:e.Title?.trim()||null,description:e.Description?.trim()||null,viewName:t?.viewName??null,initialFilter:t?.filterString??null,hasTitle:Q(e.HasTitle),hasHeader:Q(e.HasHeader),formats:Zt(e),timeout:e.Timeout??null}}function $t(){if(document.querySelector(`#AlertDialogTemplate`))return;let e=document.createElement(`template`);e.id=`AlertDialogTemplate`,e.innerHTML=`
|
|
3
3
|
<dialog class="alert-dialog">
|
|
4
4
|
<form method="dialog">
|
|
5
5
|
<article></article>
|
|
@@ -8,5 +8,5 @@ this.af=this.af||{},this.af.common=(function(e){Object.defineProperty(e,Symbol.t
|
|
|
8
8
|
</footer>
|
|
9
9
|
</form>
|
|
10
10
|
</dialog>
|
|
11
|
-
`,document.body.append(e)}window.document&&(document.body
|
|
11
|
+
`,document.body.append(e)}window.document&&(document.body?$t():document.addEventListener(`DOMContentLoaded`,$t,{once:!0}));function en(e,t=`No`){return new Promise(n=>{let r=new AbortController;e.addEventListener(`close`,()=>{n(e.returnValue),r.abort()},{signal:r.signal}),e.addEventListener(`cancel`,()=>{n(t),r.abort()},{signal:r.signal})})}let $=/* @__PURE__ */ new Map;async function tn({buttons:e,content:t,className:n,id:r,title:i}){if(r&&$.has(r))return await $.get(r);let a=document.querySelector(`#AlertDialogTemplate`);if(!a)throw Error(`No alert dialog template found`);let o=a.content.firstElementChild?.cloneNode(!0),s=o?.querySelector(`article`),c=o?.querySelector(`footer menu`);if(!o||!s||!c)throw Error(`Invalid alert dialog template`);if(n)for(let e of n.split(/\s+/))o?.classList.add(e);if(i){let e=document.createElement(`header`);e.append(i),s.parentNode?.insertBefore(e,s)}s.appendChild(typeof t==`string`?document.createTextNode(t):t);for(let{label:t,value:n,primary:r}of e){let e=document.createElement(`li`),i=document.createElement(`button`);i.value=n,r&&i.classList.add(`primary`),i.textContent=t,e.appendChild(i),c.appendChild(i)}document.body.appendChild(o),o.showModal();let l=en(o).then(e=>(r&&$.has(r)&&$.delete(r),o&&document.body.removeChild(o),e));return r&&$.set(r,l),await l}let nn=/* @__PURE__ */ function(e){return e[e.YesNo=0]=`YesNo`,e[e.OkCancel=1]=`OkCancel`,e}({});async function rn(e,t={}){let{buttons:n=0,title:r}=t;return await tn({content:e,buttons:n===1?[{label:b(`OK`),value:`yes`,primary:!0},{label:b(`Cancel`),value:`no`}]:[{label:b(`Yes`),value:`yes`,primary:!0},{label:b(`No`),value:`no`}],className:`alert-dialog-confirm`,title:r})===`yes`}async function an(e,t={}){await tn({content:e,className:`alert-dialog-alert`,buttons:[{label:b(`OK`),value:`ok`,primary:!0}],...t})}function on(e){return`${e??window.af?.article?.id??window.window?.location.pathname.substring(1).split(`/`)[0]}.${window.af?.userSession.login??`anonymous`}`}function sn(e,t){if(!window.af?.userSession)return null;let n=on(t),r=JSON.parse(localStorage.getItem(n)||`{}`);return e?r[e]||null:r}function cn(e,t,n){if(!window.af?.userSession)return;let r=on(n),i=JSON.parse(localStorage.getItem(r)||`{}`);t===void 0?i=e:i[e]=t,localStorage.setItem(r,JSON.stringify(i))}return e.ConfirmButtons=nn,e.NO_FILTER_ID=-1,e.PERIOD_OPERATORS=x,e.RELATIVE_DATE_VALUES=Oe,e.SessionHandler=n,e.UserSession=r,e.addGroupAtPath=Ze,e.alert=an,e.canDeleteSavedFilter=vt,e.canEditSavedFilter=gt,e.canRenameSavedFilter=B,e.canSetCrossDomain=yt,e.canShareSavedFilter=_t,e.changeOperator=Ke,e.coerceParameterValue=K,e.coerceToStandardLayout=lt,e.confirm=rn,e.convertFilter=Qe,e.countExpressions=N,e.createEmptyFilter=k,e.createEmptyGroup=A,e.createExpression=We,e.createLocalizer=ge,e.decodeXml=V,e.describeFilter=$e,e.downloadBlob=ae,e.downloadReport=Jt,e.downloadRequest=oe,e.encodeXml=H,e.expose=pe,e.fetchParameterDefault=Bt,e.findSavedFilter=ht,e.getColumnsForField=Fe,e.getDefaultOperator=De,e.getDefaultParameterValues=Ft,e.getDynamicValueLabel=Ae,e.getDynamicValuesForField=je,e.getLocalizedString=b,e.getNodeAtPath=qe,e.getOperatorArity=S,e.getOperatorLabel=Se,e.getOperatorsForField=Ee,e.getReportExtension=Gt,e.getReportFileName=J,e.getReportFormats=Zt,e.getReportMediaType=q,e.getReportRequest=Y,e.getSessionData=g,e.getSettings=sn,e.getUserImage=xt,e.getValueType=D,e.insertNodeAtPath=Je,e.invariant=v,e.isCompleteExpression=P,e.isEmptyFilter=ze,e.isExpression=M,e.isGroup=j,e.isProcedureDefault=G,e.isRangeEnd=F,e.isStandardLayout=ct,e.localStorage=te,e.localize=St,e.logActivity=a,e.logError=c,e.mitt=t,e.needsFilterString=Ue,e.normalizeOperator=O,e.openAlertDialog=tn,e.openReport=Z,e.parseParameterItems=At,e.parseParameters=Rt,e.parseRecordSource=W,e.partitionSavedFilters=mt,e.printReport=Yt,e.pruneFilter=Be,e.readElement=U,e.readElements=wt,e.removeNodeAtPath=Ye,e.renderReport=X,e.resolveParameterDefaults=Vt,e.restoreParameterValues=zt,e.saveSettings=cn,e.serializeParameters=Lt,e.setGroupMode=Xe,e.startActivity=o,e.supportsColumnValue=Ne,e.time=s,e.toFieldMetadata=ot,e.toFieldMetadataList=st,e.toFilterFieldType=it,e.toFilterTree=Le,e.toLocalDateTime=ie,e.toLocalISODate=ne,e.toLocalISODateTime=re,e.toReport=Qt,e.toReportParameter=Nt,e.toReportParameters=Pt,e.toSavedFilter=ut,e.toSavedFilters=pt,e.unwrapSingleAndGroup=Re,e.updateNodeAtPath=I,e.version=`2.16.1`,e.waitForDialog=en,e})({});
|
|
12
12
|
//# sourceMappingURL=af.common.legacy.min.js.map
|