@cube-nl/dmp-sdk 1.0.0-rc.4 → 1.1.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +372 -9
- package/dist/app.d.ts +41 -4
- package/dist/app.js +252 -14
- package/dist/browser.js +14 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.js +5 -1
- package/dist/cube-sdk.js +186 -2
- package/dist/cube-ui.manifest.json +971 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/preview.d.ts +11 -0
- package/dist/preview.js +60 -7
- package/dist/size.json +6 -0
- package/dist/trial.d.ts +32 -0
- package/dist/trial.js +55 -0
- package/dist/ui/aggregate-block.d.ts +73 -0
- package/dist/ui/aggregate-block.js +139 -0
- package/dist/ui/attributes.d.ts +5 -0
- package/dist/ui/attributes.js +72 -0
- package/dist/ui/author-error.d.ts +3 -0
- package/dist/ui/author-error.js +3 -0
- package/dist/ui/block.d.ts +69 -0
- package/dist/ui/block.js +238 -0
- package/dist/ui/blocks/app-shell.d.ts +4 -0
- package/dist/ui/blocks/app-shell.js +167 -0
- package/dist/ui/blocks/board.d.ts +8 -0
- package/dist/ui/blocks/board.js +333 -0
- package/dist/ui/blocks/calc.d.ts +9 -0
- package/dist/ui/blocks/calc.js +263 -0
- package/dist/ui/blocks/chart.d.ts +7 -0
- package/dist/ui/blocks/chart.js +166 -0
- package/dist/ui/blocks/detail.d.ts +8 -0
- package/dist/ui/blocks/detail.js +270 -0
- package/dist/ui/blocks/field.d.ts +8 -0
- package/dist/ui/blocks/field.js +16 -0
- package/dist/ui/blocks/form.d.ts +8 -0
- package/dist/ui/blocks/form.js +153 -0
- package/dist/ui/blocks/gap-list.d.ts +4 -0
- package/dist/ui/blocks/gap-list.js +36 -0
- package/dist/ui/blocks/kpi.d.ts +4 -0
- package/dist/ui/blocks/kpi.js +75 -0
- package/dist/ui/blocks/period-picker.d.ts +4 -0
- package/dist/ui/blocks/period-picker.js +155 -0
- package/dist/ui/blocks/state.d.ts +4 -0
- package/dist/ui/blocks/state.js +135 -0
- package/dist/ui/blocks/table.d.ts +8 -0
- package/dist/ui/blocks/table.js +666 -0
- package/dist/ui/blocks/top.d.ts +4 -0
- package/dist/ui/blocks/top.js +67 -0
- package/dist/ui/chart-svg.d.ts +28 -0
- package/dist/ui/chart-svg.js +111 -0
- package/dist/ui/csv.d.ts +9 -0
- package/dist/ui/csv.js +55 -0
- package/dist/ui/define.d.ts +24 -0
- package/dist/ui/define.js +107 -0
- package/dist/ui/dom.d.ts +12 -0
- package/dist/ui/dom.js +58 -0
- package/dist/ui/fields.d.ts +39 -0
- package/dist/ui/fields.js +73 -0
- package/dist/ui/format.d.ts +44 -0
- package/dist/ui/format.js +215 -0
- package/dist/ui/inputs.d.ts +35 -0
- package/dist/ui/inputs.js +161 -0
- package/dist/ui/manifest.d.ts +40 -0
- package/dist/ui/manifest.js +880 -0
- package/dist/ui/period.d.ts +18 -0
- package/dist/ui/period.js +52 -0
- package/dist/ui/query.d.ts +26 -0
- package/dist/ui/query.js +99 -0
- package/dist/ui/schema.d.ts +23 -0
- package/dist/ui/schema.js +21 -0
- package/dist/ui/styles.d.ts +8 -0
- package/dist/ui/styles.js +51 -0
- package/dist/ui/texts.d.ts +146 -0
- package/dist/ui/texts.js +138 -0
- package/dist/ui/theme.d.ts +58 -0
- package/dist/ui/theme.js +311 -0
- package/dist/ui/trial-banner.d.ts +25 -0
- package/dist/ui/trial-banner.js +180 -0
- package/dist/ui/write.d.ts +20 -0
- package/dist/ui/write.js +54 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wireframe.d.ts +37 -0
- package/dist/wireframe.js +352 -0
- package/fonts/OFL-albert-sans.txt +93 -0
- package/fonts/OFL-ibm-plex-sans.txt +93 -0
- package/fonts/OFL-inter.txt +93 -0
- package/fonts/OFL-nunito-sans.txt +93 -0
- package/fonts/OFL-source-sans-3.txt +93 -0
- package/fonts/albert-sans.woff2 +0 -0
- package/fonts/ibm-plex-sans.woff2 +0 -0
- package/fonts/inter.woff2 +0 -0
- package/fonts/nunito-sans.woff2 +0 -0
- package/fonts/source-sans-3.woff2 +0 -0
- package/package.json +12 -4
package/dist/cube-sdk.js
CHANGED
|
@@ -1,2 +1,186 @@
|
|
|
1
|
-
/*! @cube-nl/dmp-sdk 1.
|
|
2
|
-
"use strict";(()=>{var Ae=Object.defineProperty;var ve=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var k=(e,t,n)=>ve(e,typeof t!="symbol"?t+"":t,n);var R=class extends Error{constructor(n,r,s){let i=s!==null&&typeof s=="object"?s:{},o=A(i.detail)??A(i.error_description);super(o??`HTTP ${n}`);k(this,"status");k(this,"code");k(this,"reason");k(this,"type");k(this,"title");k(this,"detail");k(this,"errors");k(this,"retryAfter");k(this,"recordVersion");k(this,"allow");k(this,"headers");k(this,"body");this.name="DmpError",this.status=n,this.code=A(i.code)??A(i.error),this.reason=A(i.reason),this.type=A(i.type),this.title=A(i.title),this.detail=o,this.errors=$e(i.errors)?i.errors:null,this.retryAfter=De(r.get("Retry-After")),this.recordVersion=r.get("X-Dmp-Record-Version"),this.allow=r.has("Allow")?(r.get("Allow")??"").split(",").map(a=>a.trim()).filter(a=>a!==""):null,this.headers=r,this.body=s}get isProblem(){return this.code!==null}};function A(e){return typeof e=="string"?e:null}function $e(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function De(e){if(e===null||e.trim()==="")return null;let t=Number(e);if(Number.isFinite(t))return t;let n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,Math.ceil((n-Date.now())/1e3))}function te(e){return{async getAccessToken(){let t=typeof e=="function"?await e():e;return t===void 0||t===""?null:t}}}var U="cube-dmp-sdk.pending-login";function re(e){let t=e.fetch??globalThis.fetch.bind(globalThis),n=e.tokenStore??M(),r=e.pendingStore??Ue(),s=(e.refreshLeewaySeconds??30)*1e3,i=typeof e.scopes=="string"?e.scopes:e.scopes.join(" "),o=e.metadata??{},a=Oe(o)?Promise.resolve({...o,issuer:o.issuer??e.issuer}):null,p=null,d=()=>(a??(a=xe(e.issuer,t).then(c=>({...c,...o}),c=>{throw a=null,c})),a),m=async(c,u)=>{let{token_endpoint:l}=await d(),f=new URLSearchParams(c);e.clientSecret!==void 0&&f.set("client_secret",e.clientSecret);let y=await t(l,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:f.toString()}),b=await ie(y);if(!y.ok||b===null||typeof b!="object"||typeof b.access_token!="string")throw new R(y.status,y.headers,b);let T={accessToken:b.access_token,refreshToken:typeof b.refresh_token=="string"?b.refresh_token:null,expiresAt:typeof b.expires_in=="number"?Date.now()+b.expires_in*1e3:null,scope:typeof b.scope=="string"?b.scope:u};return await n.set(T),T},g=()=>(p??(p=(async()=>{let c=await n.get();if(c?.refreshToken==null)throw new TypeError("No refresh token: sign in again.");try{return await m({grant_type:"refresh_token",refresh_token:c.refreshToken,client_id:e.clientId},c.scope)}catch(u){throw u instanceof R&&u.status>=400&&u.status<500&&await n.set(null),u}})().finally(()=>{p=null})),p),h=async(c={})=>{let u=await d();if(!(u.code_challenge_methods_supported??[]).includes("S256"))throw new TypeError("The authorization server does not offer PKCE S256; this SDK will not sign in without it.");let l=ne(64),f=c.state??ne(32),y=se(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(l))),b={verifier:l,state:f,redirectUri:e.redirectUri,clientId:e.clientId};r.setItem(U,JSON.stringify(b));let T=new URL(u.authorization_endpoint);return T.search=new URLSearchParams({...c.extraParams,response_type:"code",client_id:e.clientId,redirect_uri:e.redirectUri,scope:i,state:f,code_challenge:y,code_challenge_method:"S256"}).toString(),T.toString()};return{discover:d,authorizationUrl:h,async signIn(c={}){let u=ee();if(u===null)throw new TypeError("signIn() needs a browser; use authorizationUrl() and redirect yourself.");u.assign(await h(c))},async handleCallback(c){let u=c??ee()?.href;if(u===void 0)throw new TypeError("handleCallback() needs the callback URL outside a browser.");let l=new URL(u),f=new URLSearchParams(l.search);if(!Me(l,e.redirectUri)||!f.has("code")&&!f.has("error"))return null;if(c===void 0){for(let b of["code","state","error","error_description","iss"])l.searchParams.delete(b);globalThis.history?.replaceState(null,"",l.pathname+l.search+l.hash)}let y=Ee(r.getItem(U));if(y===null||f.get("state")!==y.state)throw new TypeError("The state does not match: this callback does not belong to a sign-in started here.");if(r.removeItem(U),f.has("error"))throw new R(400,new Headers,{error:f.get("error")??"access_denied",error_description:f.get("error_description")??void 0});return m({grant_type:"authorization_code",code:f.get("code")??"",redirect_uri:y.redirectUri,client_id:y.clientId,code_verifier:y.verifier},i)},refresh:g,async getTokens(){return n.get()},async setTokens(c){await n.set(c)},async signOut(){await n.set(null),r.removeItem(U)},async getAccessToken(){let c=await n.get();if(c===null)return null;if(c.expiresAt!==null&&c.expiresAt-s<=Date.now()&&c.refreshToken!==null)try{return(await g()).accessToken}catch{return(await n.get())?.accessToken??null}return c.accessToken},async onUnauthorized(){if((await n.get())?.refreshToken==null)return!1;try{return await g(),!0}catch{return!1}}}}function Oe(e){return typeof e.authorization_endpoint=="string"&&typeof e.token_endpoint=="string"}async function xe(e,t=globalThis.fetch.bind(globalThis)){let n=`${e.replace(/\/+$/,"")}/.well-known/oauth-authorization-server`,r=await t(n,{headers:{Accept:"application/json"}}),s=await ie(r);if(!r.ok||s===null||typeof s!="object")throw new R(r.status,r.headers,s);return s}function M(e=null){let t=e;return{get:()=>t,set:n=>{t=n}}}function Pe(){let e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>{e.set(t,n)},removeItem:t=>{e.delete(t)}}}function Ue(){try{let e=globalThis.sessionStorage;if(e!==void 0)return e}catch{}return Pe()}function ee(){let e=globalThis.location;return e!==void 0&&typeof e.assign=="function"?e:null}function Me(e,t){let n=new URL(t),r=s=>s.replace(/\/+$/,"")||"/";return e.origin===n.origin&&r(e.pathname)===r(n.pathname)}function Ee(e){if(e===null)return null;try{let t=JSON.parse(e);return typeof t.verifier=="string"&&typeof t.state=="string"&&typeof t.redirectUri=="string"&&typeof t.clientId=="string"?t:null}catch{return null}}async function ie(e){let t=await e.text();if(t==="")return null;try{return JSON.parse(t)}catch{return t}}function ne(e){return se(crypto.getRandomValues(new Uint8Array(e)))}function se(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n="";for(let r of t)n+=String.fromCharCode(r);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var Ce=new Set(["in","between"]);function v(e,t={}){let n=new URLSearchParams;je(n,e,t.fields),Ie(n,t.filter),O(n,"sort",t.sort),O(n,"include",t.include),O(n,"with_count",t.withCount),Ne(n,t.has),O(n,"fn",t.fn),O(n,"group",t.group),t.page?.size!==void 0&&n.append("page[size]",String(t.page.size)),t.page?.number!==void 0&&n.append("page[number]",String(t.page.number));for(let[r,s]of Object.entries(t.params??{}))n.append(r,s);return n.toString().replace(/%5B/gi,"[").replace(/%5D/gi,"]").replace(/%2C/gi,",").replace(/%28/gi,"(").replace(/%29/gi,")")}function je(e,t,n){if(n===void 0)return;let r=ze(n)?{[t]:n}:n;for(let[s,i]of Object.entries(r))i.length>0&&e.append(`fields[${s}]`,i.join(","))}function Ie(e,t){for(let[n,r]of Object.entries(t??{})){if(Array.isArray(r))throw new TypeError(`filter.${n}: a bare list names no operator and cube/api refuses it. Write { in: [...] } (or { between: [from, to] }).`);if(r==null)throw new TypeError(`filter.${n}: write { is: 'null' } or { is: 'not_null' } to filter on null.`);if(typeof r!="object"){e.append(`filter[${n}]`,q(r));continue}for(let[s,i]of Object.entries(r))i!==void 0&&e.append(`filter[${n}][${s}]`,Le(n,s,i))}}function Le(e,t,n){if(n===null){if(t!=="is")throw new TypeError(`filter.${e}.${t}: null is only meaningful under 'is'.`);return"null"}if(Array.isArray(n)){if(!Ce.has(t))throw new TypeError(`filter.${e}.${t}: takes one value; only 'in' and 'between' take a list.`);return n.map(q).join(",")}return q(n)}function Ne(e,t){for(let[n,r]of Object.entries(t??{}))r===!0?e.append(`has[${n}]`,"1"):typeof r=="number"?e.append(`has[${n}][min]`,String(r)):(r.min!==void 0&&e.append(`has[${n}][min]`,String(r.min)),r.max!==void 0&&e.append(`has[${n}][max]`,String(r.max)))}function O(e,t,n){if(n===void 0)return;let r=typeof n=="string"?n:n.filter(s=>s!=="").join(",");r!==""&&e.append(t,r)}function q(e){return typeof e=="boolean"?e?"1":"0":String(e)}function ze(e){return Array.isArray(e)}var Fe=/^[a-z][a-z0-9_]*$/;function ae(e){let t=e.baseUrl.replace(/\/+$/,""),n=e.fetch??globalThis.fetch.bind(globalThis),r=e.auth===void 0?null:typeof e.auth=="string"||typeof e.auth=="function"?te(e.auth):e.auth,s=e.cache??(typeof document<"u"?"no-cache":void 0),i=async(a,p,{query:d,body:m,headers:g={},signal:h}={})=>{let c=`${t}${p.startsWith("/")?p:`/${p}`}${d?`?${d}`:""}`,u=async()=>{let b=r===null?null:await r.getAccessToken(),T={method:a,headers:{Accept:"application/json",...e.headers,...b!==null?{Authorization:`Bearer ${b}`}:{},...m!==void 0?{"Content-Type":"application/json"}:{},...g}};m!==void 0&&(T.body=JSON.stringify(m)),s!==void 0&&(T.cache=s),h!==void 0&&(T.signal=h);let Se=Date.now(),Z=await n(c,T);return e.onResponse?.({method:a,url:c,status:Z.status,ms:Date.now()-Se}),Z},l=await u();l.status===401&&r?.onUnauthorized!==void 0&&await r.onUnauthorized()&&(await l.body?.cancel().catch(()=>{}),l=await u());let f=await Qe(l);if(!l.ok)throw new R(l.status,l.headers,f);let y=Ve(f)?f:null;return{status:l.status,data:y!==null?y.data:f,meta:y?.meta??null,headers:l.headers,etag:l.headers.get("ETag"),recordVersion:l.headers.get("X-Dmp-Record-Version"),location:l.headers.get("Location"),replayed:l.headers.get("Idempotency-Replayed")==="true",rateLimit:Ke(l.headers)}};return{async capabilities(a={}){let p=(await i("GET","/_capabilities",C({},a))).data;return{...p,resources:p.resources.map(qe)}},resources:a=>{if(!Fe.test(a))throw new TypeError(`'${a}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let p=`/${a}`,d=u=>{let l=String(u);if(l==="")throw new TypeError(`${a}: an empty id would address the collection, not a record.`);if(le(l))throw new TypeError(`${a}: '${l}' is not an id: it would address another path, not a record.`);return`${p}/${encodeURIComponent(l)}`},m=u=>u===void 0?"":v(a,{fields:u}),g=async(u={},l={})=>await i("GET",p,C({query:v(a,u)},l)),h=async function*(u={},l={}){let f=u.page?.number??1;for(;;){let y=await g({...u,page:{...u.page,number:f}},l);yield y;let b=y.meta.page;if(b==null||b.number>=b.pages||y.data.length===0)return;f=b.number+1}},c=async(u,l,f)=>{let y=await i("POST",u,{query:m(f.fields),body:l??{},headers:E(f)});return{...y,data:y.status===204?null:y.data,accepted:y.status===202}};return{name:a,list:g,pages:h,async*all(u={},l={}){for await(let f of h(u,l))yield*f.data},get:(u,l={},f={})=>i("GET",d(u),C({query:v(a,l)},f)),aggregate:(u,l={})=>i("GET",`${p}/_aggregate`,C({query:v(a,u)},l)),create:(u,l={})=>i("POST",p,{query:m(l.fields),body:u,headers:E(l)}),update:(u,l,f={})=>i("PATCH",d(u),{query:m(f.fields),body:l,headers:E(f)}),delete:async(u,l={})=>({...await i("DELETE",d(u),{headers:E(l)}),data:null}),operation:(u,l,f,y={})=>c(`${d(u)}/${encodeURIComponent(oe(l))}`,f,y),collectionOperation:(u,l,f={})=>c(`${p}/_operations/${encodeURIComponent(oe(u))}`,l,f)}},request:i}}function qe(e){return{...e,operations:(e.operations??[]).map(t=>({...t,input:Q(t.input)})),aggregatable:Q(e.aggregatable),relations:Q(e.relations)}}function Q(e){return Array.isArray(e)||e===void 0||e===null?{}:e}function oe(e){if(e===""||e.startsWith("_"))throw new TypeError(`'${e}' is not an operation name: the '_' namespace is reserved by the API.`);if(le(e))throw new TypeError(`'${e}' is not an operation name: it would address another path.`);return e}function le(e){return e==="."||e===".."}function E(e){let t={};if(e.idempotencyKey!==void 0&&(t["Idempotency-Key"]=e.idempotencyKey),e.ifMatch!==void 0){if(e.ifMatch.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");t["If-Match"]=e.ifMatch}return t}function C(e,t){return t.signal===void 0?e:{...e,signal:t.signal}}async function Qe(e){let t=await e.text();if(t==="")return null;try{return JSON.parse(t)}catch{return t}}function Ve(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"data"in e}function Ke(e){let t=n=>{let r=e.get(n);return r===null||r===""||!Number.isFinite(Number(r))?null:Number(r)};return{limit:t("X-RateLimit-Limit"),remaining:t("X-RateLimit-Remaining"),reset:t("X-RateLimit-Reset")}}var ue=/^[a-z][a-z0-9_]*$/,ce=["eq","neq","gt","gte","lt","lte","in","like","ilike","is","between"],Ge=[[">=","gte"],["<=","lte"],["<>","neq"],[">","gt"],["<","lt"],["=","eq"]],H=["count","sum","avg","min","max"],de=["day","week","month","quarter","year"],V=20,K=5,ge=1e3,G=200,We=50,W=200,Je="1.0",j=class{constructor(t,n=null,r=()=>{}){k(this,"manifest",n);k(this,"guard",r);k(this,"tables",new Map);for(let[s,i]of Object.entries(He(t))){if(typeof i!="object"||i===null||Array.isArray(i))continue;let o=typeof i.schema?.name=="string"&&i.schema.name!==""?i.schema.name:s;ue.test(o)&&this.tables.set(o,Xe(o,i))}}resourceNames(){return[...this.tables.keys()]}resource(t){if(!ue.test(t))throw new TypeError(`'${t}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let n=(i,o)=>Promise.resolve().then(()=>o(this.authorize(t,i))),r=(i={})=>n("list",o=>Ye(o,i)),s=async function*(i={}){let o=i.page?.number??1;for(;;){let a=await r({...i,page:{...i.page,number:o}});if(yield a,a.meta.page.number>=a.meta.page.pages||a.data.length===0)return;o=a.meta.page.number+1}};return{name:t,list:r,pages:s,async*all(i={}){for await(let o of s(i))yield*o.data},get:(i,o={})=>n("get",a=>Ze(a,i,o)),aggregate:i=>n("aggregate",o=>on(o,i)),create:(i,o={})=>n("create",a=>cn(a,i,o)),update:(i,o,a={})=>n("update",p=>dn(p,i,o,a)),delete:(i,o={})=>n("delete",a=>gn(a,i,o)),operation:(i,o,a,p)=>n("get",d=>{throw L(d,i),me(o)}),collectionOperation:i=>n("list",()=>{throw me(i)})}}authorize(t,n){this.guard();let r=this.tables.get(t);if(r===void 0)throw w(404,"not_found",`Unknown API resource [${t}].`);let s=this.manifest?.uses;if(s!==void 0&&!(s[t]??[]).includes(n))throw w(403,"client_scope_exceeded",`This app may not ${n} '${t}': add it to "uses" in cube-app.json.`);return r}};function He(e){let t=e.resources;return Object.keys(e).length===1&&x(t)&&!("rows"in t)&&!("schema"in t)?t:e}function Xe(e,t){let n=t.schema??{},r=(t.rows??[]).map(g=>B(g)),s=new Map,i=Array.isArray(n.fields)?n.fields.map(g=>[g.name,g]):Object.entries(n.fields??{});for(let[g,h]of i)s.set(g,Be(g,h));for(let g of s.size===0?r:[])for(let h of Object.keys(g))s.has(h)||s.set(h,{name:h,types:[],nullable:!0});let o=[...s.keys()],a=(x(n.choices)?Object.entries(n.choices):[]).filter(g=>x(g[1])&&Array.isArray(g[1].values)),p=new Set(["id",...n.readonly??[],...i.filter(([,g])=>g.readonly===!0).map(([g])=>g),...a.filter(([,g])=>g.writable===!1).map(([g])=>g)]),d=new Map;for(let[g,h]of i)Array.isArray(h.enum)&&d.set(g,h.enum);for(let[g,h]of a)d.set(g,h.values);let m=g=>Array.isArray(g)?g.filter(h=>typeof h=="string"&&s.has(h)):null;return{name:e,fields:s,filterable:m(n.filters)??o,groupable:m(n.groupable)??o,aggregatable:new Map(x(n.aggregatable)?Object.entries(n.aggregatable).filter(([g,h])=>s.has(g)&&Array.isArray(h)).map(([g,h])=>[g,[...h]]):o.map(g=>[g,[...H]])),choices:d,writable:new Set(o.filter(g=>!p.has(g))),summary:(m(n.summary_fields)??[]).length>0?m(n.summary_fields):o,rows:r,versions:new Map(r.map(g=>[S(g.id),1])),replays:new Map}}function Be(e,t){let n=t.type,r=typeof n=="string"?n.split("|"):Array.isArray(n)?[...n]:[];return{name:e,types:r.filter(s=>s!=="null"&&s!==""),nullable:t.nullable===!0||r.includes("null")}}function P(e,t){return new URLSearchParams(v(e.name,t))}function Ye(e,t){let n=P(e,t),r=I(e,n),s=he(e,n),i=rn(e,n),{size:o,number:a}=sn(n),p=ye(e,n),d=e.rows.filter(c=>s.every(u=>we(e,c,u)));i.length>0&&(d=[...d].sort((c,u)=>{for(let{field:l,descending:f}of i){let y=_(c[l],u[l]);if(y!==0)return f?-y:y}return 0}));let m=d.length,g=d.slice((a-1)*o,a*o).map(c=>N(c,r)),h={size:o,number:a,total:m,pages:Math.max(1,Math.ceil(m/o))};return{...D(200,g,$(e,h,p)),meta:{...$(e,h,p),page:h}}}function Ze(e,t,n){let r=P(e,n),s=I(e,r),i=ye(e,r),o=L(e,t);return D(200,N(o,s),$(e,null,i),z(e,o))}function I(e,t){let n=`fields[${e.name}]`,r=t.get(n);if(r===null||r==="")return e.summary;let s=r.split(",").map(o=>o.trim()),i=s.filter(o=>!e.fields.has(o));if(i.length>0)throw w(422,"query_invalid",`Unknown ${n}: ${i.join(", ")}.`,{[n]:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]});return s}function ye(e,t){let n=r=>(t.get(r)??"").split(",").filter(s=>s!=="");return[...new Set([...n("include"),...n("with_count")])]}function he(e,t){let n=[],r=[];t.forEach((s,i)=>r.push([i,s]));for(let[s,i]of r){let o=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/.exec(s);if(o===null)continue;let a=o[1];if(!e.filterable.includes(a))throw w(422,"query_invalid",`Unknown filter: ${a}.`,{filter:[`Allowed values: ${e.filterable.join(", ")}.`]},"not_filterable");n.push(o[2]===void 0?en(a,i):nn(a,o[2],i))}if(n.length>V)throw w(422,"query_invalid",`A query takes at most ${V} filters.`,{filter:[`Sent ${n.length}; the limit is ${V}.`]});return n}function en(e,t){for(let[n,r]of Ge)if(t.startsWith(n))return{field:e,operator:r,value:t.slice(n.length)};return{field:e,operator:"eq",value:t}}function nn(e,t,n){if(!ce.includes(t))throw w(422,"query_invalid",`Unknown filter operator: ${t}.`,{filter:[`Allowed operators: ${ce.join(", ")}.`]});if(t==="between"&&n.split(",").length!==2)throw w(422,"query_invalid",`filter[${e}][between] takes exactly 2 values.`,{filter:[`Write filter[${e}][between]=low,high. Received ${n.split(",").length} value(s).`]});if(t==="in"&&n.split(",").length>G)throw w(422,"query_invalid",`filter[${e}][in] takes at most ${G} values.`,{filter:[`Sent ${n.split(",").length}; the limit is ${G}.`]});if(t==="is"&&n!=="null"&&n!=="not_null")throw w(422,"query_invalid",`filter[${e}][is] takes null or not_null.`,{filter:[`Received: ${n}.`]});return{field:e,operator:t,value:n}}function we(e,t,n){let r=t[n.field],s=i=>yn(e.fields.get(n.field),i.trim());switch(n.operator){case"eq":return J(r,s(n.value));case"neq":return r!=null&&!J(r,s(n.value));case"gt":return r!=null&&_(r,s(n.value))>0;case"gte":return r!=null&&_(r,s(n.value))>=0;case"lt":return r!=null&&_(r,s(n.value))<0;case"lte":return r!=null&&_(r,s(n.value))<=0;case"in":return n.value.split(",").some(i=>J(r,s(i)));case"between":{let[i,o]=n.value.split(",").map(s);return r!=null&&_(r,i)>=0&&_(r,o)<=0}case"like":case"ilike":return typeof r=="string"&&tn(r,n.value);case"is":return n.value==="null"?r==null:r!=null;default:return!1}}function tn(e,t){let n=t.split("%").map(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(n,"iu").test(e)}function rn(e,t){let n=t.get("sort");if(n===null||n==="")return[];let r=n.split(",").map(i=>i.trim()).filter(i=>i!=="").map(i=>({field:i.replace(/^[-+]/,""),descending:i.startsWith("-")})),s=r.map(i=>i.field).filter(i=>!e.fields.has(i));if(s.length>0)throw w(422,"query_invalid",`Unknown sort: ${s.join(", ")}.`,{sort:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]},"not_sortable");return r}function sn(e){let t=r=>{let s=e.get(r);if(s===null||s==="")return null;if(!/^\d+$/.test(s))throw w(422,"query_invalid",`${r} must be a positive integer.`,{[r]:["Expected a positive integer."]});return Number(s)},n=t("page[size]")??We;if(n>W)throw w(422,"cardinality_exceeded",`page[size] may not exceed ${W}.`,{"page.size":[`The maximum page size is ${W}.`]});return{size:Math.max(1,n),number:Math.max(1,t("page[number]")??1)}}function on(e,t){let n=P(e,t),r=(n.get("fn")??"").trim();if(r==="")throw w(422,"query_invalid","fn is required: name at least one aggregation function.",{fn:[`Expected e.g. fn=count or fn=sum(field). ${X(e)}`]});let s=r.split(",").map(c=>c.trim()),i=s.map(c=>an(e,c));pe(s,"fn");let o=(n.get("group")??"").trim(),a=o===""?[]:o.split(",").map(c=>c.trim());if(a.length>K)throw w(422,"cardinality_exceeded",`group may not exceed ${K} dimensions, ${a.length} given.`,{group:[`Use at most ${K} dimensions.`]});let p=a.map(c=>ln(e,c));pe(a,"group");let d=he(e,n),m=new Map;for(let c of e.rows.filter(u=>d.every(l=>we(e,u,l)))){let u={};for(let[y,b]of a.entries())u[b]=p[y](c);let l=JSON.stringify(Object.values(u)),f=m.get(l)??{key:u,rows:[]};f.rows.push(c),m.set(l,f)}if(a.length===0&&m.size===0&&m.set("[]",{key:{},rows:[]}),m.size>ge)throw w(422,"cardinality_exceeded","The grouping produces more groups than the configured maximum.",{groepen:["The grouping produces more groups than the configured maximum.",`Allowed values: groepeer grover, of filter eerst; maximaal ${ge} groepen.`]},"too_many_groups");let h=[...m.values()].sort((c,u)=>{for(let l of a){let f=_(c.key[l],u.key[l]);if(f!==0)return f}return 0}).map(({key:c,rows:u})=>{let l={...c};for(let[f,y]of s.entries())l[y]=i[f](u);return l});return D(200,h,{...$(e,null,[]),groups:h.length})}function pe(e,t){let n=[...new Set(e.filter((r,s)=>e.indexOf(r)!==s))];if(n.length>0)throw w(422,"query_invalid",`Duplicate ${t} entry: ${n.join(", ")}.`,{[t]:[`List each ${t} entry once.`]})}function X(e){return e.aggregatable.size===0?"This resource has no aggregatable fields; only bare count is available.":`Aggregatable fields: ${[...e.aggregatable.keys()].join(", ")}.`}function an(e,t){let n=/^([a-z]+)\(([a-z0-9_]+)\)$/.exec(t);if(n===null&&!/^[a-z]+$/.test(t))throw w(422,"query_invalid",`Unparseable fn entry: ${t}.`,{fn:["Expected `count` or `function(field)`, e.g. sum(field)."]});let r=n===null?t:n[1],s=n===null?null:n[2];if(!H.includes(r))throw w(422,"query_invalid",`Unknown aggregation function: ${r}.`,{fn:[`Allowed values: ${H.join(", ")}.`]});if(s===null){if(r!=="count")throw w(422,"query_invalid",`${r} must be applied to a field, e.g. ${r}(field).`,{fn:[X(e)]});return o=>o.length}let i=e.aggregatable.get(s);if(i===void 0)throw w(422,"query_invalid",`Unknown aggregatable field: ${s}.`,{fn:[X(e)]});if(!i.includes(r))throw w(422,"query_invalid",`${r} is not allowed on ${s}.`,{fn:[`Allowed functions for ${s}: ${i.join(", ")}.`]});return o=>{let a=o.map(d=>d[s]).filter(d=>d!=null),p=a.map(Number).filter(d=>Number.isFinite(d));switch(r){case"count":return o.length;case"sum":return p.length===0?null:p.reduce((d,m)=>d+m,0);case"avg":return p.length===0?null:p.reduce((d,m)=>d+m,0)/p.length;case"min":return a.length===0?null:a.reduce((d,m)=>_(m,d)<0?m:d);default:return a.length===0?null:a.reduce((d,m)=>_(m,d)>0?m:d)}}}function ln(e,t){let n=t.split(".");if(n.length>2)throw w(422,"query_invalid",`Unparseable group entry: ${t}.`,{group:["Expected `field` or `field.unit`, e.g. published_at.month."]});let[r,s]=n;if(!e.groupable.includes(r))throw w(422,"query_invalid",`Unknown group: ${r}.`,{group:[`Allowed values: ${e.groupable.join(", ")}.`]},"not_groupable");if(s===void 0)return i=>i[r]??null;if(!de.includes(s))throw w(422,"query_invalid",`Unknown truncation unit: ${s}.`,{group:[`Allowed values: ${de.join(", ")}.`]});return i=>un(i[r],s)}function un(e,t){let n=typeof e=="string"?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null;if(n===null)return null;let[r,s,i]=[Number(n[1]),Number(n[2]),Number(n[3])],o=new Date(Date.UTC(r,s-1,i));if(o.getUTCFullYear()!==r||o.getUTCMonth()!==s-1||o.getUTCDate()!==i)return null;switch(t){case"day":return n[0];case"week":{let a=new Date(o.getTime()+(3-(o.getUTCDay()+6)%7)*864e5),p=a.getUTCFullYear(),d=1+Math.floor((a.getTime()-Date.UTC(p,0,1))/(7*864e5));return`${p}-W${String(d).padStart(2,"0")}`}case"month":return n[0].slice(0,7);case"quarter":return`${n[1]}-Q${Math.ceil(s/3)}`;case"year":return n[1];default:return null}}function cn(e,t,n){let r=n.fields===void 0?e.summary:I(e,P(e,{fields:n.fields})),s=JSON.stringify([t,n.fields??null]);if(n.idempotencyKey!==void 0){let p=e.replays.get(n.idempotencyKey);if(p!==void 0){if(p.body!==s)throw w(422,"validation_failed","This Idempotency-Key was already used with a different request body. Use a new key, or resend the original body.");return{...p.response,replayed:!0}}}let i=be(e,t),o={id:mn(e),...i};for(let p of e.fields.keys())p in o||(o[p]=null);e.rows.push(o),e.versions.set(S(o.id),1);let a=D(201,N(o,r),$(e,null,[]),z(e,o));return n.idempotencyKey!==void 0&&e.replays.set(n.idempotencyKey,{body:s,response:a}),a}function dn(e,t,n,r){let s=r.fields===void 0?e.summary:I(e,P(e,{fields:r.fields})),i=L(e,t);return ke(e,i,r.ifMatch),Object.assign(i,be(e,n)),e.versions.set(S(i.id),(e.versions.get(S(i.id))??1)+1),D(200,N(i,s),$(e,null,[]),z(e,i))}function gn(e,t,n){let r=L(e,t);return ke(e,r,n.ifMatch),e.rows.splice(e.rows.indexOf(r),1),e.versions.delete(S(r.id)),D(204,null,null)}function be(e,t){let n=[...e.writable],r=n.length===0?"This resource declares no writable fields.":`Writable fields: ${n.join(", ")}.`;if(!x(t)||Object.keys(t).length===0)throw w(422,"validation_failed","The request body must be a JSON object naming at least one writable field.",{body:[r]});let s=Object.keys(t).filter(o=>!e.writable.has(o));if(s.length>0)throw w(422,"query_invalid",`Unknown or read-only fields: ${s.join(", ")}.`,Object.fromEntries(s.map(o=>[o,[r]])));let i={};for(let[o,a]of Object.entries(t)){let p=e.fields.get(o),d=fn(p,a)??pn(e,p,o,a);d!==null&&(i[o]=[d])}if(Object.keys(i).length>0)throw w(422,"validation_failed","The request body failed validation.",i);return B(t)}function pn(e,t,n,r){let s=e.choices.get(n);return s===void 0||r===null&&t?.nullable===!0||s.includes(r)?null:`The selected ${n.replace(/_/g," ")} is invalid.`}function fn(e,t){return e===void 0||e.types.length!==1?null:t===null?e.nullable?null:fe(e):(()=>{switch(e.types[0]){case"string":return typeof t=="string";case"integer":return typeof t=="number"&&Number.isInteger(t)||typeof t=="string"&&/^[+-]?\d+$/.test(t.trim());case"number":return typeof t=="number"&&Number.isFinite(t)||typeof t=="string"&&t.trim()!==""&&Number.isFinite(Number(t));case"boolean":return[!0,!1,0,1,"0","1"].includes(t);case"array":case"object":return typeof t=="object";default:return!0}})()?null:fe(e)}function fe(e){return`The ${e.name.replace(/_/g," ")} field must be ${{string:"a string",integer:"an integer",number:"a number",boolean:"true or false",array:"an array",object:"an array"}[e.types[0]]??"valid"}.`}function ke(e,t,n){if(n===void 0)return;if(n.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");let r=z(e,t);if(n!==r)throw w(409,"conflict","The record changed since the version you sent.",void 0,void 0,{"X-Dmp-Record-Version":r})}function mn(e){let t=e.rows.map(n=>n.id);return t.length>0&&t.every(n=>typeof n=="string")&&t.some(n=>!/^\d+$/.test(n))?crypto.randomUUID():t.reduce((n,r)=>Math.max(n,Number(r)||0),0)+1}function L(e,t){let n=S(t);if(n===""||n==="."||n==="..")throw new TypeError(`${e.name}: '${n}' is not an id.`);let r=e.rows.find(s=>S(s.id)===n);if(r===void 0)throw w(404,"not_found",`No such ${e.name} record.`);return r}function me(e){return w(404,"not_found",`No such operation [${e}]. The preview runs no custom operations.`)}function N(e,t){let n={};for(let r of t)n[r]=r in e?B(e[r]):null;return n}function z(e,t){return`"preview-${S(t.id)}-${e.versions.get(S(t.id))??1}"`}function $(e,t,n){return{resource:e.name,contract:Je,page:t,groups:null,omitted:n,pruned:[],forbidden_fields:[]}}function D(e,t,n,r=null){let s=new Headers({"X-Dmp-Preview":"true"});return r!==null&&s.set("X-Dmp-Record-Version",r),{status:e,data:t,meta:n,headers:s,etag:null,recordVersion:r,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}}function w(e,t,n,r,s,i={}){return new R(e,new Headers({"Content-Type":"application/problem+json",...i}),{type:`https://docs.cube.nl/dmp-api/problems/${t}`,title:t.replace(/_/g," "),status:e,code:t,...s!==void 0?{reason:s}:{},detail:n,...r!==void 0?{errors:r}:{}})}function yn(e,t){let n=e?.types[0];if((n==="integer"||n==="number")&&t!==""&&Number.isFinite(Number(t)))return Number(t);if(n==="boolean"){if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1}return t}function J(e,t){return e==null?!1:typeof e=="boolean"&&typeof t!="boolean"?(e?"1":"0")===String(t)||String(e)===String(t):typeof e=="number"&&typeof t=="string"?String(e)===t:e===t||typeof e!="object"&&String(e)===String(t)}function _(e,t){if(e==null||t==null)return e==null?t==null?0:-1:1;if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="boolean"||typeof t=="boolean")return+(e===!0||e===1||e==="1")-+(t===!0||t===1||t==="1");let n=String(e),r=String(t);return n<r?-1:n>r?1:0}function S(e){return e==null?"":String(e)}function x(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function B(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}var Re="1.0.0-rc.4";var wn="./cube-app.config.json",bn="./cube-mock.json",kn="./cube-app.json",Rn={id:"preview",name:"Voorbeeldgebruiker",scopes:[]},Te=null;async function Tn(e={}){let t=e.fetch??globalThis.fetch.bind(globalThis),n=e.pageUrl??xn(),r=await Y(t,F(wn,n));return r===null?_n(e,t,n):Sn($n(r),e,t,n)}async function _n(e,t,n){let r=e.mock??Te??await Y(t,F(bn,n))??{},s=e.manifest===!1?null:e.manifest??await Y(t,F(kn,n)),i=!0,o=new j(r,s,()=>{if(!i)throw new R(401,new Headers({"Content-Type":"application/problem+json"}),{type:"https://docs.cube.nl/dmp-api/problems/token_invalid",title:"token invalid",status:401,code:"token_invalid",detail:"Unauthenticated."})});return{mode:"preview",signInError:null,user:()=>i?{...Rn}:null,async signIn(){i=!0},async signOut(){i=!1},resource:a=>o.resource(a)}}async function Sn(e,t,n,r){let s=e.dmpUrl.replace(/\/+$/,""),i=null,o=Dn(t.tokenStorage==="memory"?M():On(`cube-app.tokens.${e.clientId}`),m=>{i=m}),a=re({issuer:e.issuer??s,clientId:e.clientId,redirectUri:F(e.redirectUri,r),scopes:e.scopes,fetch:n,tokenStore:o,...e.metadata!==void 0?{metadata:e.metadata}:{}}),p=ae({baseUrl:e.apiUrl??`${s}/apps/api/v1`,auth:a,fetch:n}),d=null;i=await o.get();try{await a.handleCallback()}catch(m){d=m instanceof Error?m:new Error(String(m))}return i===null&&d===null&&t.autoSignIn===!0&&await a.signIn(),{mode:"live",get signInError(){return d},user:()=>i===null?null:An(i),async signIn(){d=null,await a.signIn()},async signOut(){await a.signOut()},resource:m=>p.resources(m)}}function An(e){let t=vn(e.accessToken),n=t?.sub,r=Array.isArray(t?.scopes)?t.scopes.map(String):null;return{id:typeof n=="string"||typeof n=="number"?String(n):null,name:null,scopes:r??(e.scope??"").split(" ").filter(s=>s!=="")}}function vn(e){let t=e.split(".")[1];if(t===void 0)return null;try{let n=t.replace(/-/g,"+").replace(/_/g,"/"),r=atob(n.padEnd(n.length+(4-n.length%4)%4,"=")),s=new TextDecoder().decode(Uint8Array.from(r,o=>o.charCodeAt(0))),i=JSON.parse(s);return i!==null&&typeof i=="object"?i:null}catch{return null}}function $n(e){let t=["dmpUrl","clientId","redirectUri"].filter(r=>typeof e[r]!="string"||e[r]===""),n=e.scopes;if(typeof n=="string"||Array.isArray(n)&&n.every(r=>typeof r=="string")||t.push("scopes"),t.length>0)throw new TypeError(`cube-app.config.json is incomplete: ${t.join(", ")} missing or not a string.`);return e}async function Y(e,t){let n;try{n=await e(t,{headers:{Accept:"application/json"},...typeof document<"u"?{cache:"no-store"}:{}})}catch{return null}if(n.status===404||n.status===410)return null;if(!n.ok)throw new Error(`${t} answered ${n.status}.`);try{let r=JSON.parse(await n.text());return r!==null&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function Dn(e,t){return{async get(){let n=await e.get();return t(n),n},async set(n){await e.set(n),t(n)}}}function On(e){let t=(()=>{try{return globalThis.sessionStorage??null}catch{return null}})();return t===null?M():{get(){try{let n=t.getItem(e);return n===null?null:JSON.parse(n)}catch{return null}},set(n){try{n===null?t.removeItem(e):t.setItem(e,JSON.stringify(n))}catch{}}}}function xn(){let e=globalThis;return e.document?.baseURI??e.location?.href??"http://localhost/"}function F(e,t){return new URL(e,t).href}function Pn(e){Te=e}var _e=Object.freeze({connect:Tn,mock:Pn,version:Re,sdk:"1"});globalThis.CubeApp=_e;})();
|
|
1
|
+
/*! @cube-nl/dmp-sdk 1.1.0-rc.2 cube-sdk.js (window.CubeApp) | MIT */
|
|
2
|
+
"use strict";(()=>{var Zr=Object.defineProperty;var eo=(e,n,t)=>n in e?Zr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var b=(e,n,t)=>eo(e,typeof n!="symbol"?n+"":n,t);var $=class extends Error{constructor(t,o,a){let i=a!==null&&typeof a=="object"?a:{},r=re(i.detail)??re(i.error_description);super(r??`HTTP ${t}`);b(this,"status");b(this,"code");b(this,"reason");b(this,"type");b(this,"title");b(this,"detail");b(this,"errors");b(this,"retryAfter");b(this,"recordVersion");b(this,"allow");b(this,"headers");b(this,"body");this.name="DmpError",this.status=t,this.code=re(i.code)??re(i.error),this.reason=re(i.reason),this.type=re(i.type),this.title=re(i.title),this.detail=r,this.errors=to(i.errors)?i.errors:null,this.retryAfter=no(o.get("Retry-After")),this.recordVersion=o.get("X-Dmp-Record-Version"),this.allow=o.has("Allow")?(o.get("Allow")??"").split(",").map(s=>s.trim()).filter(s=>s!==""):null,this.headers=o,this.body=a}get isProblem(){return this.code!==null}};function P(e){return e instanceof $}function re(e){return typeof e=="string"?e:null}function to(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function no(e){if(e===null||e.trim()==="")return null;let n=Number(e);if(Number.isFinite(n))return n;let t=Date.parse(e);return Number.isNaN(t)?null:Math.max(0,Math.ceil((t-Date.now())/1e3))}function on(e){return{async getAccessToken(){let n=typeof e=="function"?await e():e;return n===void 0||n===""?null:n}}}var Ne="cube-dmp-sdk.pending-login";function sn(e){let n=e.fetch??globalThis.fetch.bind(globalThis),t=e.tokenStore??je(),o=e.pendingStore??so(),a=(e.refreshLeewaySeconds??30)*1e3,i=typeof e.scopes=="string"?e.scopes:e.scopes.join(" "),r=e.metadata??{},s=ro(r)?Promise.resolve({...r,issuer:r.issuer??e.issuer}):null,l=null,u=()=>(s??(s=oo(e.issuer,n).then(f=>({...f,...r}),f=>{throw s=null,f})),s),c=async(f,m)=>{let{token_endpoint:g}=await u(),w=new URLSearchParams(f);e.clientSecret!==void 0&&w.set("client_secret",e.clientSecret);let v=await n(g,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"},body:w.toString()}),k=await an(v);if(!v.ok||k===null||typeof k!="object"||typeof k.access_token!="string")throw new $(v.status,v.headers,k);let S={accessToken:k.access_token,refreshToken:typeof k.refresh_token=="string"?k.refresh_token:null,expiresAt:typeof k.expires_in=="number"?Date.now()+k.expires_in*1e3:null,scope:typeof k.scope=="string"?k.scope:m};return await t.set(S),S},d=()=>(l??(l=(async()=>{let f=await t.get();if(f?.refreshToken==null)throw new TypeError("No refresh token: sign in again.");try{return await c({grant_type:"refresh_token",refresh_token:f.refreshToken,client_id:e.clientId},f.scope)}catch(m){throw m instanceof $&&m.status>=400&&m.status<500&&await t.set(null),m}})().finally(()=>{l=null})),l),p=async(f={})=>{let m=await u();if(!(m.code_challenge_methods_supported??[]).includes("S256"))throw new TypeError("The authorization server does not offer PKCE S256; this SDK will not sign in without it.");let g=rn(64),w=f.state??rn(32),v=ln(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(g))),k={verifier:g,state:w,redirectUri:e.redirectUri,clientId:e.clientId};o.setItem(Ne,JSON.stringify(k));let S=new URL(m.authorization_endpoint);return S.search=new URLSearchParams({...f.extraParams,response_type:"code",client_id:e.clientId,redirect_uri:e.redirectUri,scope:i,state:w,code_challenge:v,code_challenge_method:"S256"}).toString(),S.toString()};return{discover:u,authorizationUrl:p,async signIn(f={}){let m=nn();if(m===null)throw new TypeError("signIn() needs a browser; use authorizationUrl() and redirect yourself.");m.assign(await p(f))},async handleCallback(f){let m=f??nn()?.href;if(m===void 0)throw new TypeError("handleCallback() needs the callback URL outside a browser.");let g=new URL(m),w=new URLSearchParams(g.search);if(!ao(g,e.redirectUri)||!w.has("code")&&!w.has("error"))return null;if(f===void 0){for(let k of["code","state","error","error_description","iss"])g.searchParams.delete(k);globalThis.history?.replaceState(null,"",g.pathname+g.search+g.hash)}let v=lo(o.getItem(Ne));if(v===null||w.get("state")!==v.state)throw new TypeError("The state does not match: this callback does not belong to a sign-in started here.");if(o.removeItem(Ne),w.has("error"))throw new $(400,new Headers,{error:w.get("error")??"access_denied",error_description:w.get("error_description")??void 0});return c({grant_type:"authorization_code",code:w.get("code")??"",redirect_uri:v.redirectUri,client_id:v.clientId,code_verifier:v.verifier},i)},refresh:d,async getTokens(){return t.get()},async setTokens(f){await t.set(f)},async signOut(){await t.set(null),o.removeItem(Ne)},async getAccessToken(){let f=await t.get();if(f===null)return null;if(f.expiresAt!==null&&f.expiresAt-a<=Date.now()&&f.refreshToken!==null)try{return(await d()).accessToken}catch{return(await t.get())?.accessToken??null}return f.accessToken},async onUnauthorized(){if((await t.get())?.refreshToken==null)return!1;try{return await d(),!0}catch{return!1}}}}function ro(e){return typeof e.authorization_endpoint=="string"&&typeof e.token_endpoint=="string"}async function oo(e,n=globalThis.fetch.bind(globalThis)){let t=`${e.replace(/\/+$/,"")}/.well-known/oauth-authorization-server`,o=await n(t,{headers:{Accept:"application/json"}}),a=await an(o);if(!o.ok||a===null||typeof a!="object")throw new $(o.status,o.headers,a);return a}function je(e=null){let n=e;return{get:()=>n,set:t=>{n=t}}}function io(){let e=new Map;return{getItem:n=>e.get(n)??null,setItem:(n,t)=>{e.set(n,t)},removeItem:n=>{e.delete(n)}}}function so(){try{let e=globalThis.sessionStorage;if(e!==void 0)return e}catch{}return io()}function nn(){let e=globalThis.location;return e!==void 0&&typeof e.assign=="function"?e:null}function ao(e,n){let t=new URL(n),o=a=>a.replace(/\/+$/,"")||"/";return e.origin===t.origin&&o(e.pathname)===o(t.pathname)}function lo(e){if(e===null)return null;try{let n=JSON.parse(e);return typeof n.verifier=="string"&&typeof n.state=="string"&&typeof n.redirectUri=="string"&&typeof n.clientId=="string"?n:null}catch{return null}}async function an(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function rn(e){return ln(crypto.getRandomValues(new Uint8Array(e)))}function ln(e){let n=e instanceof Uint8Array?e:new Uint8Array(e),t="";for(let o of n)t+=String.fromCharCode(o);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var uo=new Set(["in","between"]);function oe(e,n={}){let t=new URLSearchParams;co(t,e,n.fields),po(t,n.filter),xe(t,"sort",n.sort),xe(t,"include",n.include),xe(t,"with_count",n.withCount),fo(t,n.has),xe(t,"fn",n.fn),xe(t,"group",n.group),n.page?.size!==void 0&&t.append("page[size]",String(n.page.size)),n.page?.number!==void 0&&t.append("page[number]",String(n.page.number));for(let[o,a]of Object.entries(n.params??{}))t.append(o,a);return t.toString().replace(/%5B/gi,"[").replace(/%5D/gi,"]").replace(/%2C/gi,",").replace(/%28/gi,"(").replace(/%29/gi,")")}function co(e,n,t){if(t===void 0)return;let o=go(t)?{[n]:t}:t;for(let[a,i]of Object.entries(o))i.length>0&&e.append(`fields[${a}]`,i.join(","))}function po(e,n){for(let[t,o]of Object.entries(n??{})){if(Array.isArray(o))throw new TypeError(`filter.${t}: a bare list names no operator and cube/api refuses it. Write { in: [...] } (or { between: [from, to] }).`);if(o==null)throw new TypeError(`filter.${t}: write { is: 'null' } or { is: 'not_null' } to filter on null.`);if(typeof o!="object"){e.append(`filter[${t}]`,vt(o));continue}for(let[a,i]of Object.entries(o))i!==void 0&&e.append(`filter[${t}][${a}]`,mo(t,a,i))}}function mo(e,n,t){if(t===null){if(n!=="is")throw new TypeError(`filter.${e}.${n}: null is only meaningful under 'is'.`);return"null"}if(Array.isArray(t)){if(!uo.has(n))throw new TypeError(`filter.${e}.${n}: takes one value; only 'in' and 'between' take a list.`);return t.map(vt).join(",")}return vt(t)}function fo(e,n){for(let[t,o]of Object.entries(n??{}))o===!0?e.append(`has[${t}]`,"1"):typeof o=="number"?e.append(`has[${t}][min]`,String(o)):(o.min!==void 0&&e.append(`has[${t}][min]`,String(o.min)),o.max!==void 0&&e.append(`has[${t}][max]`,String(o.max)))}function xe(e,n,t){if(t===void 0)return;let o=typeof t=="string"?t:t.filter(a=>a!=="").join(",");o!==""&&e.append(n,o)}function vt(e){return typeof e=="boolean"?e?"1":"0":String(e)}function go(e){return Array.isArray(e)}var ho=/^[a-z][a-z0-9_]*$/;function St(e){let n=e.baseUrl.replace(/\/+$/,""),t=e.fetch??globalThis.fetch.bind(globalThis),o=e.auth===void 0?null:typeof e.auth=="string"||typeof e.auth=="function"?on(e.auth):e.auth,a=e.cache??(typeof document<"u"?"no-cache":void 0),i=async(s,l,{query:u,body:c,headers:d={},signal:p}={})=>{let f=`${n}${l.startsWith("/")?l:`/${l}`}${u?`?${u}`:""}`,m=async()=>{let k=o===null?null:await o.getAccessToken(),S={method:s,headers:{Accept:"application/json",...e.headers,...k!==null?{Authorization:`Bearer ${k}`}:{},...c!==void 0?{"Content-Type":"application/json"}:{},...d}};c!==void 0&&(S.body=JSON.stringify(c)),a!==void 0&&(S.cache=a),p!==void 0&&(S.signal=p);let D=Date.now(),L=await t(f,S);return e.onResponse?.({method:s,url:f,status:L.status,ms:Date.now()-D}),L},g=await m();g.status===401&&o?.onUnauthorized!==void 0&&await o.onUnauthorized()&&(await g.body?.cancel().catch(()=>{}),g=await m());let w=await yo(g);if(!g.ok)throw new $(g.status,g.headers,w);let v=wo(w)?w:null;return{status:g.status,data:v!==null?v.data:w,meta:v?.meta??null,headers:g.headers,etag:g.headers.get("ETag"),recordVersion:g.headers.get("X-Dmp-Record-Version"),location:g.headers.get("Location"),replayed:g.headers.get("Idempotency-Replayed")==="true",rateLimit:vo(g.headers)}};return{async capabilities(s={}){let l=(await i("GET","/_capabilities",Be({},s))).data;return{...l,resources:l.resources.map(bo)}},resources:s=>{if(!ho.test(s))throw new TypeError(`'${s}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let l=`/${s}`,u=m=>{let g=String(m);if(g==="")throw new TypeError(`${s}: an empty id would address the collection, not a record.`);if(dn(g))throw new TypeError(`${s}: '${g}' is not an id: it would address another path, not a record.`);return`${l}/${encodeURIComponent(g)}`},c=m=>m===void 0?"":oe(s,{fields:m}),d=async(m={},g={})=>await i("GET",l,Be({query:oe(s,m)},g)),p=async function*(m={},g={}){let w=m.page?.number??1;for(;;){let v=await d({...m,page:{...m.page,number:w}},g);yield v;let k=v.meta.page;if(k==null||k.number>=k.pages||v.data.length===0)return;w=k.number+1}},f=async(m,g,w)=>{let v=await i("POST",m,{query:c(w.fields),body:g??{},headers:Ie(w)});return{...v,data:v.status===204?null:v.data,accepted:v.status===202}};return{name:s,list:d,pages:p,async*all(m={},g={}){for await(let w of p(m,g))yield*w.data},get:(m,g={},w={})=>i("GET",u(m),Be({query:oe(s,g)},w)),aggregate:(m,g={})=>i("GET",`${l}/_aggregate`,Be({query:oe(s,m)},g)),create:(m,g={})=>i("POST",l,{query:c(g.fields),body:m,headers:Ie(g)}),update:(m,g,w={})=>i("PATCH",u(m),{query:c(w.fields),body:g,headers:Ie(w)}),delete:async(m,g={})=>({...await i("DELETE",u(m),{headers:Ie(g)}),data:null}),operation:(m,g,w,v={})=>f(`${u(m)}/${encodeURIComponent(un(g))}`,w,v),collectionOperation:(m,g,w={})=>f(`${l}/_operations/${encodeURIComponent(un(m))}`,g,w)}},request:i}}function bo(e){return{...e,operations:(e.operations??[]).map(n=>({...n,input:kt(n.input)})),aggregatable:kt(e.aggregatable),relations:kt(e.relations)}}function kt(e){return Array.isArray(e)||e===void 0||e===null?{}:e}function cn(){return crypto.randomUUID()}function un(e){if(e===""||e.startsWith("_"))throw new TypeError(`'${e}' is not an operation name: the '_' namespace is reserved by the API.`);if(dn(e))throw new TypeError(`'${e}' is not an operation name: it would address another path.`);return e}function dn(e){return e==="."||e===".."}function Ie(e){let n={};if(e.idempotencyKey!==void 0&&(n["Idempotency-Key"]=e.idempotencyKey),e.ifMatch!==void 0){if(e.ifMatch.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");n["If-Match"]=e.ifMatch}return n}function Be(e,n){return n.signal===void 0?e:{...e,signal:n.signal}}async function yo(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function wo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"data"in e}function vo(e){let n=t=>{let o=e.get(t);return o===null||o===""||!Number.isFinite(Number(o))?null:Number(o)};return{limit:n("X-RateLimit-Limit"),remaining:n("X-RateLimit-Remaining"),reset:n("X-RateLimit-Reset")}}var pn=/^[a-z][a-z0-9_]*$/,mn=["eq","neq","gt","gte","lt","lte","in","like","ilike","is","between"],ko=[[">=","gte"],["<=","lte"],["<>","neq"],[">","gt"],["<","lt"],["=","eq"]],Et=["count","sum","avg","min","max"],fn=["day","week","month","quarter","year"],xt=20,Tt=5,gn=1e3,Ct=200,So=50,At=200,xo="1.0",Z=class{constructor(n,t=null,o=()=>{}){b(this,"manifest",t);b(this,"guard",o);b(this,"tables",new Map);for(let[a,i]of Object.entries(To(n))){if(typeof i!="object"||i===null||Array.isArray(i))continue;let r=typeof i.schema?.name=="string"&&i.schema.name!==""?i.schema.name:a;pn.test(r)&&this.tables.set(r,Co(r,i))}}rows(n){return this.tables.get(n)?.rows??[]}resourceNames(){return[...this.tables.keys()]}describe(n){let t=this.tables.get(n);return t===void 0?null:{name:n,actions:[...t.actions],fields:[...t.fields.values()].map(o=>{let a=t.choices.get(o.name);return{name:o.name,type:o.types.join("|"),format:o.format,nullable:o.nullable,readonly:!t.writable.has(o.name),enum:a===void 0?null:a.map(String),description:o.description}}),summary:[...t.summary],filterable:[...t.filterable],sortable:[...t.fields.keys()],groupable:[...t.groupable],aggregatable:Object.fromEntries([...t.aggregatable].map(([o,a])=>[o,a.filter(i=>i!=="count")]))}}resource(n){if(!pn.test(n))throw new TypeError(`'${n}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let t=(i,r)=>Promise.resolve().then(()=>r(this.authorize(n,i))),o=(i={})=>t("list",r=>Ro(r,i)),a=async function*(i={}){let r=i.page?.number??1;for(;;){let s=await o({...i,page:{...i.page,number:r}});if(yield s,s.meta.page.number>=s.meta.page.pages||s.data.length===0)return;r=s.meta.page.number+1}};return{name:n,list:o,pages:a,async*all(i={}){for await(let r of a(i))yield*r.data},get:(i,r={})=>t("get",s=>Eo(s,i,r)),aggregate:i=>t("aggregate",r=>_o(r,i)),create:(i,r={})=>t("create",s=>jo(s,i,r)),update:(i,r,s={})=>t("update",l=>Io(l,i,r,s)),delete:(i,r={})=>t("delete",s=>Bo(s,i,r)),operation:(i,r,s,l)=>t("get",u=>{throw He(u,i),yn(r)}),collectionOperation:i=>t("list",()=>{throw yn(i)})}}authorize(n,t){this.guard();let o=this.tables.get(n);if(o===void 0)throw M(404,"not_found",`Unknown API resource [${n}].`);let a=this.manifest?.uses;if(a!==void 0&&!(a[n]??[]).includes(t))throw M(403,"client_scope_exceeded",`This app may not ${t} '${n}': add it to "uses" in cube-app.json.`);return o}};function To(e){let n=e.resources;return Object.keys(e).length===1&&Te(n)&&!("rows"in n)&&!("schema"in n)?n:e}function Co(e,n){let t=n.schema??{},o=(n.rows??[]).map(d=>Mt(d)),a=new Map,i=Array.isArray(t.fields)?t.fields.map(d=>[d.name,d]):Object.entries(t.fields??{});for(let[d,p]of i)a.set(d,Ao(d,p));for(let d of a.size===0?o:[])for(let p of Object.keys(d))a.has(p)||a.set(p,{name:p,types:[],nullable:!0,format:null,description:null});let r=[...a.keys()],s=(Te(t.choices)?Object.entries(t.choices):[]).filter(d=>Te(d[1])&&Array.isArray(d[1].values)),l=new Set(["id",...t.readonly??[],...i.filter(([,d])=>d.readonly===!0).map(([d])=>d),...s.filter(([,d])=>d.writable===!1).map(([d])=>d)]),u=new Map;for(let[d,p]of i)Array.isArray(p.enum)&&u.set(d,p.enum);for(let[d,p]of s)u.set(d,p.values);let c=d=>Array.isArray(d)?d.filter(p=>typeof p=="string"&&a.has(p)):null;return{name:e,actions:Array.isArray(t.actions)?t.actions.filter(d=>typeof d=="string"):["list","get","create","update","delete"],fields:a,filterable:c(t.filters)??r,groupable:c(t.groupable)??r,aggregatable:new Map(Te(t.aggregatable)?Object.entries(t.aggregatable).filter(([d,p])=>a.has(d)&&Array.isArray(p)).map(([d,p])=>[d,[...p]]):r.map(d=>[d,[...Et]])),choices:u,writable:new Set(r.filter(d=>!l.has(d))),summary:(c(t.summary_fields)??[]).length>0?c(t.summary_fields):r,rows:o,versions:new Map(o.map(d=>[W(d.id),1])),replays:new Map}}function Ao(e,n){let t=n.type,o=typeof t=="string"?t.split("|"):Array.isArray(t)?[...t]:[];return{name:e,types:o.filter(a=>a!=="null"&&a!==""),nullable:n.nullable===!0||o.includes("null"),format:typeof n.format=="string"?n.format:null,description:typeof n.description=="string"?n.description:null}}function Ce(e,n){return new URLSearchParams(oe(e.name,n))}function Ro(e,n){let t=Ce(e,n),o=Ue(e,t),a=vn(e,t),i=Fo(e,t),{size:r,number:s}=Oo(t),l=wn(e,t),u=e.rows.filter(f=>a.every(m=>kn(e,f,m)));i.length>0&&(u=[...u].sort((f,m)=>{for(let{field:g,descending:w}of i){let v=H(f[g],m[g]);if(v!==0)return w?-v:v}return 0}));let c=u.length,d=u.slice((s-1)*r,s*r).map(f=>ze(f,o)),p={size:r,number:s,total:c,pages:Math.max(1,Math.ceil(c/r))};return{...de(200,d,ce(e,p,l)),meta:{...ce(e,p,l),page:p}}}function Eo(e,n,t){let o=Ce(e,t),a=Ue(e,o),i=wn(e,o),r=He(e,n);return de(200,ze(r,a),ce(e,null,i),Ve(e,r))}function Ue(e,n){let t=`fields[${e.name}]`,o=n.get(t);if(o===null||o==="")return e.summary;let a=o.split(",").map(r=>r.trim()),i=a.filter(r=>!e.fields.has(r));if(i.length>0)throw M(422,"query_invalid",`Unknown ${t}: ${i.join(", ")}.`,{[t]:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]});return a}function wn(e,n){let t=o=>(n.get(o)??"").split(",").filter(a=>a!=="");return[...new Set([...t("include"),...t("with_count")])]}function vn(e,n){let t=[],o=[];n.forEach((a,i)=>o.push([i,a]));for(let[a,i]of o){let r=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/.exec(a);if(r===null)continue;let s=r[1];if(!e.filterable.includes(s))throw M(422,"query_invalid",`Unknown filter: ${s}.`,{filter:[`Allowed values: ${e.filterable.join(", ")}.`]},"not_filterable");t.push(r[2]===void 0?Do(s,i):Mo(s,r[2],i))}if(t.length>xt)throw M(422,"query_invalid",`A query takes at most ${xt} filters.`,{filter:[`Sent ${t.length}; the limit is ${xt}.`]});return t}function Do(e,n){for(let[t,o]of ko)if(n.startsWith(t))return{field:e,operator:o,value:n.slice(t.length)};return{field:e,operator:"eq",value:n}}function Mo(e,n,t){if(!mn.includes(n))throw M(422,"query_invalid",`Unknown filter operator: ${n}.`,{filter:[`Allowed operators: ${mn.join(", ")}.`]});if(n==="between"&&t.split(",").length!==2)throw M(422,"query_invalid",`filter[${e}][between] takes exactly 2 values.`,{filter:[`Write filter[${e}][between]=low,high. Received ${t.split(",").length} value(s).`]});if(n==="in"&&t.split(",").length>Ct)throw M(422,"query_invalid",`filter[${e}][in] takes at most ${Ct} values.`,{filter:[`Sent ${t.split(",").length}; the limit is ${Ct}.`]});if(n==="is"&&t!=="null"&&t!=="not_null")throw M(422,"query_invalid",`filter[${e}][is] takes null or not_null.`,{filter:[`Received: ${t}.`]});return{field:e,operator:n,value:t}}function kn(e,n,t){let o=n[t.field],a=i=>Vo(e.fields.get(t.field),i.trim());switch(t.operator){case"eq":return Rt(o,a(t.value));case"neq":return o!=null&&!Rt(o,a(t.value));case"gt":return o!=null&&H(o,a(t.value))>0;case"gte":return o!=null&&H(o,a(t.value))>=0;case"lt":return o!=null&&H(o,a(t.value))<0;case"lte":return o!=null&&H(o,a(t.value))<=0;case"in":return t.value.split(",").some(i=>Rt(o,a(i)));case"between":{let[i,r]=t.value.split(",").map(a);return o!=null&&H(o,i)>=0&&H(o,r)<=0}case"like":case"ilike":return typeof o=="string"&&Lo(o,t.value);case"is":return t.value==="null"?o==null:o!=null;default:return!1}}function Lo(e,n){let t=n.split("%").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(t,"iu").test(e)}function Fo(e,n){let t=n.get("sort");if(t===null||t==="")return[];let o=t.split(",").map(i=>i.trim()).filter(i=>i!=="").map(i=>({field:i.replace(/^[-+]/,""),descending:i.startsWith("-")})),a=o.map(i=>i.field).filter(i=>!e.fields.has(i));if(a.length>0)throw M(422,"query_invalid",`Unknown sort: ${a.join(", ")}.`,{sort:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]},"not_sortable");return o}function Oo(e){let n=o=>{let a=e.get(o);if(a===null||a==="")return null;if(!/^\d+$/.test(a))throw M(422,"query_invalid",`${o} must be a positive integer.`,{[o]:["Expected a positive integer."]});return Number(a)},t=n("page[size]")??So;if(t>At)throw M(422,"cardinality_exceeded",`page[size] may not exceed ${At}.`,{"page.size":[`The maximum page size is ${At}.`]});return{size:Math.max(1,t),number:Math.max(1,n("page[number]")??1)}}function _o(e,n){let t=Ce(e,n),o=(t.get("fn")??"").trim();if(o==="")throw M(422,"query_invalid","fn is required: name at least one aggregation function.",{fn:[`Expected e.g. fn=count or fn=sum(field). ${Dt(e)}`]});let a=o.split(",").map(f=>f.trim()),i=a.map(f=>$o(e,f));hn(a,"fn");let r=(t.get("group")??"").trim(),s=r===""?[]:r.split(",").map(f=>f.trim());if(s.length>Tt)throw M(422,"cardinality_exceeded",`group may not exceed ${Tt} dimensions, ${s.length} given.`,{group:[`Use at most ${Tt} dimensions.`]});let l=s.map(f=>Po(e,f));hn(s,"group");let u=vn(e,t),c=new Map;for(let f of e.rows.filter(m=>u.every(g=>kn(e,m,g)))){let m={};for(let[v,k]of s.entries())m[k]=l[v](f);let g=JSON.stringify(Object.values(m)),w=c.get(g)??{key:m,rows:[]};w.rows.push(f),c.set(g,w)}if(s.length===0&&c.size===0&&c.set("[]",{key:{},rows:[]}),c.size>gn)throw M(422,"cardinality_exceeded","The grouping produces more groups than the configured maximum.",{groepen:["The grouping produces more groups than the configured maximum.",`Allowed values: groepeer grover, of filter eerst; maximaal ${gn} groepen.`]},"too_many_groups");let p=[...c.values()].sort((f,m)=>{for(let g of s){let w=H(f.key[g],m.key[g]);if(w!==0)return w}return 0}).map(({key:f,rows:m})=>{let g={...f};for(let[w,v]of a.entries())g[v]=i[w](m);return g});return de(200,p,{...ce(e,null,[]),groups:p.length})}function hn(e,n){let t=[...new Set(e.filter((o,a)=>e.indexOf(o)!==a))];if(t.length>0)throw M(422,"query_invalid",`Duplicate ${n} entry: ${t.join(", ")}.`,{[n]:[`List each ${n} entry once.`]})}function Dt(e){return e.aggregatable.size===0?"This resource has no aggregatable fields; only bare count is available.":`Aggregatable fields: ${[...e.aggregatable.keys()].join(", ")}.`}function $o(e,n){let t=/^([a-z]+)\(([a-z0-9_]+)\)$/.exec(n);if(t===null&&!/^[a-z]+$/.test(n))throw M(422,"query_invalid",`Unparseable fn entry: ${n}.`,{fn:["Expected `count` or `function(field)`, e.g. sum(field)."]});let o=t===null?n:t[1],a=t===null?null:t[2];if(!Et.includes(o))throw M(422,"query_invalid",`Unknown aggregation function: ${o}.`,{fn:[`Allowed values: ${Et.join(", ")}.`]});if(a===null){if(o!=="count")throw M(422,"query_invalid",`${o} must be applied to a field, e.g. ${o}(field).`,{fn:[Dt(e)]});return r=>r.length}let i=e.aggregatable.get(a);if(i===void 0)throw M(422,"query_invalid",`Unknown aggregatable field: ${a}.`,{fn:[Dt(e)]});if(!i.includes(o))throw M(422,"query_invalid",`${o} is not allowed on ${a}.`,{fn:[`Allowed functions for ${a}: ${i.join(", ")}.`]});return r=>{let s=r.map(u=>u[a]).filter(u=>u!=null),l=s.map(Number).filter(u=>Number.isFinite(u));switch(o){case"count":return r.length;case"sum":return l.length===0?null:l.reduce((u,c)=>u+c,0);case"avg":return l.length===0?null:l.reduce((u,c)=>u+c,0)/l.length;case"min":return s.length===0?null:s.reduce((u,c)=>H(c,u)<0?c:u);default:return s.length===0?null:s.reduce((u,c)=>H(c,u)>0?c:u)}}}function Po(e,n){let t=n.split(".");if(t.length>2)throw M(422,"query_invalid",`Unparseable group entry: ${n}.`,{group:["Expected `field` or `field.unit`, e.g. published_at.month."]});let[o,a]=t;if(!e.groupable.includes(o))throw M(422,"query_invalid",`Unknown group: ${o}.`,{group:[`Allowed values: ${e.groupable.join(", ")}.`]},"not_groupable");if(a===void 0)return i=>i[o]??null;if(!fn.includes(a))throw M(422,"query_invalid",`Unknown truncation unit: ${a}.`,{group:[`Allowed values: ${fn.join(", ")}.`]});return i=>No(i[o],a)}function No(e,n){let t=typeof e=="string"?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null;if(t===null)return null;let[o,a,i]=[Number(t[1]),Number(t[2]),Number(t[3])],r=new Date(Date.UTC(o,a-1,i));if(r.getUTCFullYear()!==o||r.getUTCMonth()!==a-1||r.getUTCDate()!==i)return null;switch(n){case"day":return t[0];case"week":{let s=new Date(r.getTime()+(3-(r.getUTCDay()+6)%7)*864e5),l=s.getUTCFullYear(),u=1+Math.floor((s.getTime()-Date.UTC(l,0,1))/(7*864e5));return`${l}-W${String(u).padStart(2,"0")}`}case"month":return t[0].slice(0,7);case"quarter":return`${t[1]}-Q${Math.ceil(a/3)}`;case"year":return t[1];default:return null}}function jo(e,n,t){let o=t.fields===void 0?e.summary:Ue(e,Ce(e,{fields:t.fields})),a=JSON.stringify([n,t.fields??null]);if(t.idempotencyKey!==void 0){let l=e.replays.get(t.idempotencyKey);if(l!==void 0){if(l.body!==a)throw M(422,"validation_failed","This Idempotency-Key was already used with a different request body. Use a new key, or resend the original body.");return{...l.response,replayed:!0}}}let i=Sn(e,n),r={id:zo(e),...i};for(let l of e.fields.keys())l in r||(r[l]=null);e.rows.push(r),e.versions.set(W(r.id),1);let s=de(201,ze(r,o),ce(e,null,[]),Ve(e,r));return t.idempotencyKey!==void 0&&e.replays.set(t.idempotencyKey,{body:a,response:s}),s}function Io(e,n,t,o){let a=o.fields===void 0?e.summary:Ue(e,Ce(e,{fields:o.fields})),i=He(e,n);return xn(e,i,o.ifMatch),Object.assign(i,Sn(e,t)),e.versions.set(W(i.id),(e.versions.get(W(i.id))??1)+1),de(200,ze(i,a),ce(e,null,[]),Ve(e,i))}function Bo(e,n,t){let o=He(e,n);return xn(e,o,t.ifMatch),e.rows.splice(e.rows.indexOf(o),1),e.versions.delete(W(o.id)),de(204,null,null)}function Sn(e,n){let t=[...e.writable],o=t.length===0?"This resource declares no writable fields.":`Writable fields: ${t.join(", ")}.`;if(!Te(n)||Object.keys(n).length===0)throw M(422,"validation_failed","The request body must be a JSON object naming at least one writable field.",{body:[o]});let a=Object.keys(n).filter(r=>!e.writable.has(r));if(a.length>0)throw M(422,"query_invalid",`Unknown or read-only fields: ${a.join(", ")}.`,Object.fromEntries(a.map(r=>[r,[o]])));let i={};for(let[r,s]of Object.entries(n)){let l=e.fields.get(r),u=Ho(l,s)??Uo(e,l,r,s);u!==null&&(i[r]=[u])}if(Object.keys(i).length>0)throw M(422,"validation_failed","The request body failed validation.",i);return Mt(n)}function Uo(e,n,t,o){let a=e.choices.get(t);return a===void 0||o===null&&n?.nullable===!0||a.includes(o)?null:`The selected ${t.replace(/_/g," ")} is invalid.`}function Ho(e,n){return e===void 0||e.types.length!==1?null:n===null?e.nullable?null:bn(e):(()=>{switch(e.types[0]){case"string":return typeof n=="string";case"integer":return typeof n=="number"&&Number.isInteger(n)||typeof n=="string"&&/^[+-]?\d+$/.test(n.trim());case"number":return typeof n=="number"&&Number.isFinite(n)||typeof n=="string"&&n.trim()!==""&&Number.isFinite(Number(n));case"boolean":return[!0,!1,0,1,"0","1"].includes(n);case"array":case"object":return typeof n=="object";default:return!0}})()?null:bn(e)}function bn(e){return`The ${e.name.replace(/_/g," ")} field must be ${{string:"a string",integer:"an integer",number:"a number",boolean:"true or false",array:"an array",object:"an array"}[e.types[0]]??"valid"}.`}function xn(e,n,t){if(t===void 0)return;if(t.startsWith("W/"))throw new TypeError("ifMatch takes recordVersion (X-Dmp-Record-Version), not the weak ETag.");let o=Ve(e,n);if(t!==o)throw M(409,"conflict","The record changed since the version you sent.",void 0,void 0,{"X-Dmp-Record-Version":o})}function zo(e){let n=e.rows.map(t=>t.id);return n.length>0&&n.every(t=>typeof t=="string")&&n.some(t=>!/^\d+$/.test(t))?crypto.randomUUID():n.reduce((t,o)=>Math.max(t,Number(o)||0),0)+1}function He(e,n){let t=W(n);if(t===""||t==="."||t==="..")throw new TypeError(`${e.name}: '${t}' is not an id.`);let o=e.rows.find(a=>W(a.id)===t);if(o===void 0)throw M(404,"not_found",`No such ${e.name} record.`);return o}function yn(e){return M(404,"not_found",`No such operation [${e}]. The preview runs no custom operations.`)}function ze(e,n){let t={};for(let o of n)t[o]=o in e?Mt(e[o]):null;return t}function Ve(e,n){return`"preview-${W(n.id)}-${e.versions.get(W(n.id))??1}"`}function ce(e,n,t){return{resource:e.name,contract:xo,page:n,groups:null,omitted:t,pruned:[],forbidden_fields:[]}}function de(e,n,t,o=null){let a=new Headers({"X-Dmp-Preview":"true"});return o!==null&&a.set("X-Dmp-Record-Version",o),{status:e,data:n,meta:t,headers:a,etag:null,recordVersion:o,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}}function M(e,n,t,o,a,i={}){return new $(e,new Headers({"Content-Type":"application/problem+json",...i}),{type:`https://docs.cube.nl/dmp-api/problems/${n}`,title:n.replace(/_/g," "),status:e,code:n,...a!==void 0?{reason:a}:{},detail:t,...o!==void 0?{errors:o}:{}})}function Vo(e,n){let t=e?.types[0];if((t==="integer"||t==="number")&&n!==""&&Number.isFinite(Number(n)))return Number(n);if(t==="boolean"){if(n==="1"||n==="true")return!0;if(n==="0"||n==="false")return!1}return n}function Rt(e,n){return e==null?!1:typeof e=="boolean"&&typeof n!="boolean"?(e?"1":"0")===String(n)||String(e)===String(n):typeof e=="number"&&typeof n=="string"?String(e)===n:e===n||typeof e!="object"&&String(e)===String(n)}function H(e,n){if(e==null||n==null)return e==null?n==null?0:-1:1;if(typeof e=="number"&&typeof n=="number")return e-n;if(typeof e=="boolean"||typeof n=="boolean")return+(e===!0||e===1||e==="1")-+(n===!0||n===1||n==="1");let t=String(e),o=String(n);return t<o?-1:t>o?1:0}function W(e){return e==null?"":String(e)}function Te(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mt(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function Tn(e){return{name:e.name,actions:[...e.actions],fields:e.fields.map(n=>({name:n.name,type:n.type,format:null,nullable:n.nullable,readonly:n.readonly,enum:null,description:n.description??null})),summary:[...e.summary],filterable:[...e.filterable],sortable:[...e.sortable],groupable:[...e.groupable],aggregatable:Object.fromEntries(Object.entries(e.aggregatable).map(([n,t])=>[n,[...t]]))}}var Lt="Voorbeeldgebruiker",pe={invalidPrimary:"De hoofdkleur is geen geldige hexkleur; de neutrale standaardkleur wordt gebruikt.",invalidAccent:"De accentkleur is geen geldige hexkleur; er wordt een accentkleur afgeleid.",primaryLight:"De hoofdkleur is erg licht; witte tekst erop heeft weinig contrast.",primaryDarkened:"De hoofdkleur is voor tekst donkerder gemaakt om voldoende contrast te houden."},y={loading:"Laden\u2026",empty:"Er is hier nog niets te tonen.",error:"Er ging iets mis bij het laden.",retry:"Opnieuw proberen",forbidden:"Je hebt geen toegang tot deze gegevens.",signedOut:"Je bent niet ingelogd.",signIn:"Inloggen",signOut:"Uitloggen",signedIn:"Ingelogd",previewUser:Lt,pages:"Pagina's",yes:"Ja",no:"Nee",emptyValue:"\u2014",quarter:(e,n)=>`K${e} ${n}`,week:(e,n)=>`week ${e}, ${n}`,monthYear:(e,n)=>`${e} '${n.slice(-2)}`,period:{label:"Periode","this-month":"Deze maand","12m":"Laatste 12 maanden","this-year":"Dit jaar",custom:"Zelf kiezen",from:"Van",to:"Tot en met",invalidRange:"De einddatum ligt v\xF3\xF3r de begindatum.",incompleteDate:"Vul bij Van en Tot en met een volledige datum in."},noData:"geen gegevens",comparedTo:"t.o.v. vorige periode",newValue:"nieuw",higher:"hoger",lower:"lager",incomplete:"Mogelijk niet compleet: er zijn meer groepen dan de DMP in \xE9\xE9n keer teruggeeft.",asTable:"Gegevens van de grafiek",tooManyGroups:"Te veel groepen om te tonen (meer dan 1000). Kies een kortere periode of een filter.",points:e=>`${e} ${e===1?"punt":"punten"}`,change:(e,n)=>`${e} procent ${n} dan de vorige periode`,search:"Zoeken",all:"Alle",min:"Vanaf",max:"Tot en met",previous:"Vorige",next:"Volgende",pageOf:(e,n,t)=>`Pagina ${e} van ${n} \xB7 ${t} rijen`,exportCsv:"Exporteren (CSV)",exporting:e=>`${e} rijen opgehaald\u2026`,chooseRow:"Kies een rij om de details te zien.",edit:"Bewerken",save:"Opslaan",cancel:"Annuleren",saved:"Opgeslagen.",formSaved:"Opgeslagen. Dank je wel!",another:"Nog een invullen",required:"Vul dit veld in.",requiredMark:" (verplicht)",notANumber:"Vul een getal in.",notAnInteger:"Vul een geheel getal in.",conflict:"Iemand anders heeft deze rij intussen gewijzigd. Laad de nieuwste versie en probeer het opnieuw.",reload:"Opnieuw laden",saveFailed:"Opslaan is niet gelukt. Probeer het opnieuw.",exportFailed:"Exporteren is niet gelukt. Probeer het opnieuw.",formInvalid:"Niet alles is goed ingevuld.",noWritableFields:"Dit formulier heeft geen invulbare velden.",calcFailed:"De berekening lukt niet met deze invoer.",moveTo:e=>`Verplaats naar ${e}`,moveFailed:"Verplaatsen lukte niet.",tryAgain:"Probeer het opnieuw.",changedMeanwhile:"Iemand anders heeft dit intussen gewijzigd; de nieuwste stand is geladen.",more:e=>`en nog ${e}`,noColumns:'Geef de kolommen op met <cube-column value="\u2026">.',emptyColumn:"Leeg",range:(e,n)=>`Kies een waarde van ${e} tot en met ${n}.`,atLeast:e=>`Kies een waarde van ${e} of meer.`,atMost:e=>`Kies een waarde van ten hoogste ${e}.`,step:e=>`Kies een waarde in stappen van ${e}.`,example:"Voorbeeld",exampleMissing:"Voorbeeld \u2014 bestaat nog niet",exampleNotSaved:"Voorbeeld \u2014 wordt niet opgeslagen",gaps:{screen:"Scherm",what:"Wat ontbreekt",type:"Soort gegeven",why:"Waarom",none:"Er ontbreekt niets: alles in dit voorstel bestaat al in de DMP.",types:{tekst:"Tekst",getal:"Getal",bedrag:"Bedrag",datum:"Datum",keuze:"Keuze","ja/nee":"Ja/nee"}},trial:{banner:(e,n)=>["Proefversie","alleen jij","alleen lezen"].concat(e===null?[]:[`verloopt om ${e}`]).concat(n.length===0?[]:[`leest: ${n.join(", ")}`]).concat("Plak geen gegevens uit deze proefversie in je AI-gesprek.").join(" \xB7 "),expired:"Deze proefversie is verlopen. Vraag in je gesprek om een nieuwe.",closed:"Deze proefversie is gesloten.",refreshing:"Nieuwe versie wordt geladen\u2026",wider:"Er is een nieuwe versie die meer gegevens leest.",load:"Laden",elsewhere:"Laad de pagina opnieuw.",reload:"Opnieuw laden"},invalid:{json:(e,n)=>`${e}: ${n} is geen geldige JSON`,number:(e,n)=>`${e}: ${n} is geen geldig getal`,attribute:e=>`${e} mag geen attribuut zijn: geen inline stijl of script`,measure:e=>`"${e}" is geen geldige meting: gebruik count of count/sum/avg/min/max(veld)`,missing:(e,n)=>`${e}: ${n} ontbreekt`,value:(e,n,t)=>`${e}: ${n} "${t}" is geen geldige waarde`,formula:"cube-calc: formula moet een functie zijn",calcSingle:"cube-calc: formula gaf \xE9\xE9n waarde, maar er zijn meer cube-results; geef een object met hun namen",duplicate:(e,n)=>`${e}: name "${n}" komt twee keer voor`,calcAsync:"cube-calc: formula gaf een Promise; geef de uitkomst direct terug, niet async",dateField:e=>`${e}: date-field ontbreekt bij period`,compare:e=>`${e}: compare werkt alleen samen met period`,periodSource:e=>`Geen periodekiezer gevonden voor "${e}"`,periodEnd:e=>`"${e}" is geen geldige einddatum van de periode`,notFilterable:(e,n,t)=>`${e}: ${n} noemt "${t}", maar daarop kan niet gefilterd worden`,selector:(e,n,t)=>`${e}: ${n} "${t}" is geen geldige selector`,lookup:e=>`"${e}" is geen geldige opzoeking: gebruik resource.veld`,dimension:e=>`"${e}" is geen geldige indeling: gebruik veld of veld.day/week/month/quarter/year`},theme:pe};var Ln=["color-primary","color-primary-hover","color-primary-subtle","color-primary-text","color-on-primary","color-accent","color-on-accent","color-text","color-text-muted","color-bg","color-surface","color-border","color-focus","color-danger","color-success","color-warning","color-example-bg","color-example-text","color-series-1","color-series-2","color-series-3","color-series-4","color-series-5","color-series-6","radius","radius-small","font-family"],Fn={primary_colour:"#475467",corners:"normaal",font:"system"},Ae={inter:{family:"Inter",files:[{file:"inter.woff2",weight:"100 900",style:"normal"}]},"albert-sans":{family:"Albert Sans",files:[{file:"albert-sans.woff2",weight:"100 900",style:"normal"}]},"source-sans-3":{family:"Source Sans 3",files:[{file:"source-sans-3.woff2",weight:"200 900",style:"normal"}]},"nunito-sans":{family:"Nunito Sans",files:[{file:"nunito-sans.woff2",weight:"200 1000",style:"normal"}]},"ibm-plex-sans":{family:"IBM Plex Sans",files:[{file:"ibm-plex-sans.woff2",weight:"100 700",style:"normal"}]}},Cn='system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',An="#f6f8fa";function me(e){if(typeof e!="string")return null;let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e);if(!n||n[1]===void 0)return null;let t=n[1].toLowerCase();return t.length===3&&(t=[...t].map(o=>o+o).join("")),[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function $t(e){return"#"+e.map(n=>Math.max(0,Math.min(255,n)).toString(16).padStart(2,"0")).join("")}function Rn(e){let[n,t,o]=e.map(a=>{let i=a/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4});return .2126*n+.7152*t+.0722*o}function Re(e,n){let t=me(e),o=me(n);if(!t||!o)return 1;let a=Rn(t),i=Rn(o);return(Math.max(a,i)+.05)/(Math.min(a,i)+.05)}function Ft(e,n,t){let o=me(e),a=me(n);return $t(o.map((i,r)=>Math.round(i*(1-t)+a[r]*t)))}function En(e){return Re(e,"#ffffff")>=Re(e,"#000000")?"#ffffff":"#000000"}function Ko(e,n){let[t,o,a]=me(e).map(k=>k/255),i=Math.max(t,o,a),r=Math.min(t,o,a),s=(i+r)/2,l=i-r,u=0,c=0;l!==0&&(c=l/(1-Math.abs(2*s-1)),i===t?u=(o-a)/l%6:i===o?u=(a-t)/l+2:u=(t-o)/l+4,u*=60),u=((u+n)%360+360)%360;let d=(1-Math.abs(2*s-1))*c,p=d*(1-Math.abs(u/60%2-1)),f=s-d/2,m=Math.floor(u/60)%6,[g,w,v]=[[d,p,0],[p,d,0],[0,d,p],[0,p,d],[p,0,d],[d,0,p]][m];return $t([g,w,v].map(k=>Math.round((k+f)*255)))}function Ot(e){let n=me(e);return n?$t(n):null}function qo(e){let n=[],t=Ot(e.primary_colour);t===null&&(t=Ot(Fn.primary_colour),n.push({code:"invalid-primary",message:pe.invalidPrimary}));let o=null;e.accent_colour!==void 0&&e.accent_colour!==null&&(o=Ot(e.accent_colour),o===null&&n.push({code:"invalid-accent",message:pe.invalidAccent})),o??(o=Ko(t,330)),Re(t,"#ffffff")<3&&n.push({code:"primary-light",message:pe.primaryLight});let a=Ft(t,"#ffffff",.9),i=t;for(let m=0;m<=20&&(i=Ft(t,"#000000",m/20),!(Re(i,An)>=4.5&&Re(i,a)>=4.5));m++);i!==t&&n.push({code:"primary-darkened-for-text",message:pe.primaryDarkened});let r=En(t),s={scherp:["0px","0px"],normaal:["6px","4px"],rond:["12px","8px"]},l=typeof e.corners=="string"&&Object.hasOwn(s,e.corners)?e.corners:"normaal",[u,c]=s[l],d=typeof e.font=="string"&&Object.hasOwn(Ae,e.font)?e.font:"system",p=d==="system"?Cn:`"${Ae[d].family}", ${Cn}`;return{tokens:{"color-primary":t,"color-primary-hover":Ft(t,r==="#ffffff"?"#000000":"#ffffff",.15),"color-primary-subtle":a,"color-primary-text":i,"color-on-primary":r,"color-accent":o,"color-on-accent":En(o),"color-text":"#1f2328","color-text-muted":"#59636e","color-bg":"#ffffff","color-surface":An,"color-border":"#d1d9e0","color-focus":i,"color-danger":"#b42318","color-success":"#067647","color-warning":"#b54708","color-example-bg":"#fef0c7","color-example-text":"#7a2e0e","color-series-1":t,"color-series-2":o,"color-series-3":"#0e9384","color-series-4":"#dc6803","color-series-5":"#7a5af8","color-series-6":"#475467",radius:u,"radius-small":c,"font-family":p},warnings:n}}var Go=/^#[0-9a-f]{6}$/i,Wo=/^\d+(\.\d+)?(px|rem)$/,Qo=/^data:image\/(svg\+xml|png);/,Jo=/[;{}<>\\\u0000-\u001f]|\/\*/,Dn=/["'()\\\s]/,Mn=String.raw`(?:\s*"[^"]*"\s*|\s*'[^']*'\s*|[^"',]+)`,Yo=new RegExp(`^${Mn}(?:,${Mn})*$`);function Ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Xo(e,n){return typeof n!="string"?!1:e.startsWith("color-")?Go.test(n):e.startsWith("radius")?Wo.test(n):n.length>0&&n.length<=200&&!Jo.test(n)&&Yo.test(n)}function qe(e,n,t){if(typeof e!="string"||e==="")return null;if(t&&Qo.test(e))return Dn.test(e)?null:e;try{let o=new URL(n),a=new URL(e,o);if((a.protocol==="https:"||a.protocol==="http:")&&a.origin===o.origin&&!Dn.test(a.href))return a.href}catch{}return null}function Zo(e,n){let t=[];for(let o of Array.isArray(e)?e:[]){if(!Ke(o))continue;let a=qe(o.src,n,!1);if(a===null)continue;let i=typeof o.weight=="string"&&/^\d{1,4}( \d{1,4})?$/.test(o.weight)?o.weight:"400";t.push({src:a,weight:i,style:o.style==="italic"?"italic":"normal"})}return t}function ie(e,n){let t=e,o=Fn,a=null,i=null;Ke(t)&&(Object.hasOwn(t,"source")&&Ke(t.source)?(o=t.source,a=Object.hasOwn(t,"tokens")?t.tokens:null,i=Object.hasOwn(t,"font_files")?t.font_files:null):Object.hasOwn(t,"primary_colour")&&(o=t));let{tokens:r,warnings:s}=qo(o);if(Ke(a))for(let c of Ln)Object.hasOwn(a,c)&&Xo(c,a[c])&&(r[c]=a[c]);let l=typeof o.font=="string"&&Object.hasOwn(Ae,o.font)?o.font:null,u=Zo(i,n);return l!==null&&u.length===0&&!Array.isArray(i)&&(u=Ae[l].files.flatMap(c=>{let d=qe("cube-theme/"+c.file,n,!1);return d===null?[]:[{src:d,weight:c.weight,style:c.style}]})),{tokens:r,logo:qe(o.logo,n,!0),logoDark:qe(o.logo_dark,n,!0),fontFamily:l===null?null:Ae[l].family,fontFiles:u,warnings:s}}function On(e){return":where(:root){"+Ln.map(n=>`--cube-${n}:${e.tokens[n]}`).join(";")+"}"}var Ge=null,_t=new Set;function We(){return Ge??(Ge=ie(null,"http://localhost/")),Ge}function Pt(e){Ge=e;for(let n of[..._t])n(e)}function Qe(e){return _t.add(e),()=>{_t.delete(e)}}var _n="cube-trial-config",ei=["dmpUrl","apiUrl","token","expiresAt","statusUrl"],Je=null;function ti(e){let n=e?.getElementById(_n)??null;if(n===null)return null;Je=null,n.remove();let t=null;try{let i=JSON.parse(n.textContent??"");t=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:null}catch{}if(t?.mode!=="trial"||ei.some(i=>typeof t[i]!="string"||t[i]===""))return console.warn(`#${_n} is not a complete trial config; the app starts without it.`),null;let o=i=>typeof t[i]=="string"?t[i]:null,a=t.leest;return Je={mode:"trial",dmpUrl:t.dmpUrl,apiUrl:t.apiUrl,token:t.token,expiresAt:t.expiresAt,statusUrl:t.statusUrl,version:o("version"),soort:o("soort"),userId:o("userId"),leest:Array.isArray(a)?a.filter(i=>typeof i=="string"):[]},Je}function Ye(){return Je}typeof document<"u"&&ti(document);var $n="1.1.0-rc.2";var R=class extends TypeError{};var ee=["number","integer","currency","percent"],In="nl-NL",ni=["day","week","month","quarter","year"],Xe=/^(\d{4})-(\d{2})-(\d{2})$/,ri=/^\s*-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?\s*$/i,oi=/^(count|sum|avg|min|max)(?:\(([A-Za-z_][A-Za-z0-9_]*)\))?$/,ii=/^([A-Za-z_][A-Za-z0-9_]*)(?:\.([a-z]+))?$/,Pn=new Map,Nn=new Map;function Nt(e){let n=JSON.stringify(e),t=Pn.get(n);return t===void 0&&(t=new Intl.NumberFormat(In,e),Pn.set(n,t)),t}function jt(e){let n=JSON.stringify(e),t=Nn.get(n);return t===void 0&&(t=new Intl.DateTimeFormat(In,e),Nn.set(n,t)),t}function se(e){return typeof e=="number"?Number.isFinite(e)?e:null:typeof e=="bigint"||typeof e=="string"&&ri.test(e)?Number(e):null}function si(e){return e instanceof Date?Number.isNaN(e.getTime())?null:e:typeof e=="number"?Number.isFinite(e)?new Date(e):null:typeof e=="string"?j(e):null}function N(e,n,t={}){if(e==null||e==="")return y.emptyValue;switch(n){case"number":case"integer":case"currency":case"percent":{let o=se(e);if(o===null)return String(e);let a=t.compact===!0?{notation:"compact"}:{};if(n==="currency")return Nt({style:"currency",currency:t.currency??"EUR",...a}).format(o);if(n==="percent")return Nt({style:"percent",maximumFractionDigits:1}).format(o);let i=n==="integer"?0:t.compact===!0?1:2;return Nt({maximumFractionDigits:i,...a}).format(o)}case"date":case"datetime":{let o=si(e);if(o===null)return String(e);let a={day:"numeric",month:"short",year:"numeric"};n==="datetime"&&Object.assign(a,{hour:"2-digit",minute:"2-digit"});let i=typeof e=="string"&&Xe.test(e);return t.timeZone!==void 0&&!i&&(a.timeZone=t.timeZone),jt(a).format(o)}case"boolean":return e===!0||e==="true"||e===1?y.yes:e===!1||e==="false"||e===0?y.no:String(e);default:return Array.isArray(e)?e.map(o=>N(o,"text")).join(", "):typeof e=="object"?JSON.stringify(e):String(e)}}function It(e,n,t={}){switch(n){case"year":return e;case"quarter":{let o=/^(\d{4})-Q([1-4])$/.exec(e);return o?.[1]!==void 0&&o[2]!==void 0?y.quarter(o[2],o[1]):e}case"week":{let o=/^(\d{4})-W(\d{2})$/.exec(e);return o?.[1]!==void 0&&o[2]!==void 0?y.week(Number(o[2]),o[1]):e}case"month":{let o=/^(\d{4})-(\d{2})$/.exec(e);if(o?.[1]===void 0||o[2]===void 0)return e;let a=Hn(Number(o[1]),Number(o[2])-1,1);return jt(t.short===!0?{month:"short"}:{month:"short",year:"numeric"}).format(a)}case"day":{let o=Xe.test(e)?j(e):null;return o===null?e:jt({day:"numeric",month:"short"}).format(o)}default:return e}}function Bn(e){let n=oi.exec(e.trim()),t=n?.[1];if(t===void 0||t!=="count"&&n?.[2]===void 0)throw new R(y.invalid.measure(e));return{fn:t,field:n?.[2]??null}}function Ze(e){let n=ii.exec(e.trim()),t=n?.[1],o=n?.[2];if(t===void 0||o!==void 0&&!ni.includes(o))throw new R(y.invalid.dimension(e));return{field:t,truncation:o??null}}function Un(e,n){if(e?.format==="date")return"date";if(e?.format==="date-time")return"datetime";if(e?.format==="currency")return"currency";switch(e?.type){case"integer":return"integer";case"number":return"number";case"boolean":return"boolean";case"string":return jn(n)??"text"}return typeof n=="boolean"?"boolean":typeof n=="number"?Number.isInteger(n)?"integer":"number":jn(n)??"text"}function jn(e){return typeof e!="string"?null:Xe.test(e)?j(e)===null?null:"date":/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(e)&&!Number.isNaN(Date.parse(e))?"datetime":null}function z(e){let n=e.replace(/_id$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return n===""?e:n.charAt(0).toUpperCase()+n.slice(1)}function j(e){let n=Xe.exec(e);if(n?.[1]!==void 0&&n[2]!==void 0&&n[3]!==void 0){let o=Hn(Number(n[1]),Number(n[2])-1,Number(n[3]));return o.getMonth()===Number(n[2])-1?o:null}let t=Date.parse(e);return Number.isNaN(t)?null:new Date(t)}function Hn(e,n,t){let o=new Date(2e3,0,1);return o.setFullYear(e,n,t),o}function I(e){let n=t=>String(t).padStart(2,"0");return`${String(e.getFullYear()).padStart(4,"0")}-${n(e.getMonth()+1)}-${n(e.getDate())}`}var Vn={tekst:"text",getal:"number",bedrag:"currency",datum:"date",keuze:"text","ja/nee":"boolean"},Bt=e=>typeof e=="string"&&e!=="",tt=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),et=(e=[])=>[e].flat().join(",").split(",").map(n=>n.trim());function ai(e){if(typeof e!="object"||e===null)return!1;let n=e,t=n.waarden;return typeof n.resource=="string"&&/^[a-z][a-z0-9_]*$/.test(n.resource)&&(n.veld===void 0||Bt(n.veld))&&typeof n.type=="string"&&tt(Vn,n.type)&&(t===void 0||Array.isArray(t)&&t.every(o=>typeof o=="string"))&&(n.type!=="keuze"||Array.isArray(t)&&t.length>0)&&Bt(n.scherm)&&Bt(n.reden)}function Kn(e){let n=[],t=[];for(let o of Array.isArray(e)?e:e==null?[]:[e])(ai(o)?n:t).push(o);return t.length>0&&console.warn(`cube-app.json ontbreekt: ${t.length} malformed entries ignored`,t),n}function zn(e){return Vn[e]}function nt(e,n){if(e===null)return null;let t=i=>{let r=zn(i);return r==="date"||r==="currency"?r:null},o=n.flatMap(({resource:i,veld:r,type:s,waarden:l,reden:u})=>{if(i!==e.name||r===void 0||e.fields.some(d=>d.name===r))return[];let c=zn(s);return[{name:r,type:c==="boolean"?c:c==="number"||c==="currency"?"number":"string",format:t(s),nullable:!0,readonly:!1,enum:l??null,description:u}]}),a=o.map(i=>i.name);return{...e,fields:[...e.fields.map(i=>n.find(({resource:s,veld:l})=>s===e.name&&l===i.name)?.type==="bedrag"&&i.format==null?{...i,format:"currency"}:i),...o],summary:e.summary.length>0?[...e.summary,...a]:e.summary,filterable:[...e.filterable,...a],sortable:[...e.sortable,...a]}}function li(e){let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619)>>>0;return n}function ui(e,n,t){let{veld:o,type:a,waarden:i}=e,r=li(`${e.resource}.${o}.${String(n)}`);if(o!==void 0){let s=t.filter(l=>tt(l,o)&&l[o]!==void 0);if(s.length>0)return s[r%s.length]?.[o]}switch(a){case"tekst":return`Voorbeeld ${r%100+1}`;case"getal":return r%1e3;case"bedrag":return r%1e5/100;case"datum":return I(new Date(2026,0,1+r%365));case"keuze":return i!==void 0&&i.length>0?i[r%i.length]:null;case"ja/nee":return r%2===0}}function qn(e,n){let t=e?.fields;return Array.isArray(t)?t:t?.[n]}async function Ut(e,n,{filter:t={},sort:o=[]}){let a=[o].flat().join(",").split(",").map(u=>u.replace(/^[-+]/,"")),i=Object.fromEntries([...n.flatMap(Object.keys),...Object.keys(t),...a].filter(u=>u!=="").map(u=>[u,{type:typeof n.find(c=>c[u]!=null)?.[u]}])),r=new Map(n.map(u=>[String(u.id),u])),s=new Z({[e]:{schema:{fields:i},rows:n}}),{data:l}=await s.resource(e).list({filter:t,sort:o,page:{size:200}});return l.map(u=>r.get(String(u.id)))}function Ht(e,n,t,o){let{name:a}=e,i=new Map(n.filter(p=>p.resource===a&&p.veld!==void 0).map(p=>[p.veld,p])),r=p=>i.has(/^[-+]?(?:\w+\()?([^.()]*)/.exec(p)?.[1]??""),s=(p={})=>{let f=qn(p,a),m=f?.filter(k=>!i.has(k)),g=Object.entries(p.filter??{}),w=et(p.sort).filter(k=>k!==""),v=k=>({filter:Object.fromEntries(g.filter(([S])=>i.has(S)===k)),sort:w.filter(S=>r(S)===k)});return{live:{...p,...m&&{fields:m.includes("id")?m:[...m,"id"]},...v(!1)},local:v(!0),shown:k=>f===void 0||f.includes(k)}},l=(p,f,m=!1)=>{for(let[g,w]of i)(m||f(g))&&(!tt(p,g)||p[g]==null)&&(p[g]=ui(w,p.id,o))},u=async(p,{local:f,shown:m})=>{let g=p.data;g.forEach(v=>l(v,m,!0)),g.length>0&&(f.sort.length>0||Object.keys(f.filter).length>0)&&(g=await Ut(a,g,f));for(let v of g)for(let k of i.keys())m(k)||delete v[k];let{meta:w}=p;return{...p,data:g,meta:Object.keys(f.filter).length>0?{...w,page:{...w.page,total:g.length,pages:w.page.number}}:w}},c=async(p,f)=>{let m=s(p);return u(await e.list(m.live,f),m)},d=async function*(p,f){let m=s(p);for await(let g of e.pages(m.live,f))yield await u(g,m)};return{...e,list:c,pages:d,async*all(p,f){for await(let m of d(p,f))yield*m.data},async get(p,f,m){let g=s(f),w=await e.get(p,g.live,m);return l(w.data,g.shown),g.shown("id")||delete w.data.id,w},aggregate:(p,f)=>[et(p.fn).map(m=>m.replace(/^\w+$/,"")),et(p.group),Object.keys(p.filter??{})].flat().some(r)?t.resource(a).aggregate(p):e.aggregate(p,f)}}function Gn(e,n){let t=m=>String(m.id),o=new Map,a=new Map,i=new Set,r=0,s=(m,g)=>({status:m,data:g,meta:null,headers:new Headers,etag:null,recordVersion:null,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}),l=(m,g)=>{let w=qn(g,n);return Object.fromEntries(Object.entries(m).filter(([v])=>w?.includes(v)??!0))},u=async(m,g={})=>{let{page:w}=m.meta,v=o.size>0?await Ut(n,[...o.values()].reverse(),g):[],k=new Set(v.map(t)),S=new Set(a.size>0?(await Ut(n,[...a.values()],g)).map(t):[]),D=new Set(m.data.map(t)),L=m.data.filter(A=>!i.has(t(A))&&(!o.has(t(A))||k.has(t(A)))).map(A=>o.get(t(A))??A),B=v.filter(A=>!S.has(t(A))&&!D.has(t(A))),T=w.total-[...S].filter(A=>!k.has(A)).length+B.length,x=w.number===1?[...B,...L]:L,E=et(g.sort).map(A=>[A.replace(/^[-+]/,""),A.startsWith("-")?-1:1]),O=A=>o.has(t(A))&&(!D.has(t(A))||E.some(([ue])=>a.get(t(A))?.[ue]!==A[ue])),G=x.filter(A=>!O(A));if(E.every(([A])=>G.every(ue=>tt(ue,A)))){for(let A of x.filter(O)){let ue=G.findIndex(Jr=>E.reduce((Yr,[tn,Xr])=>Yr||Xr*H(A[tn],Jr[tn]),0)<0);G.splice(ue>>>0,0,A)}x=G}return{...m,data:x.map(A=>l(A,g)),meta:{...m.meta,page:{...w,total:T}}}},c=async(m,g,w)=>{let v=o.get(String(m));if(i.has(String(m))){let k=`No such ${n} record.`;throw new $(404,new Headers,{status:404,code:"not_found",detail:k})}return v===void 0?e.get(m,g,w):s(200,l(v,g))},d=async m=>{let{data:g}=await c(m);return o.has(String(m))||a.set(String(m),g),g},p=async()=>({...s(202,null),accepted:!0}),f=async function*(m,g){for await(let w of e.pages(m,g))yield await u(w,m)};return{...e,get:c,pages:f,operation:p,collectionOperation:p,list:async(m,g)=>u(await e.list(m,g),m),async*all(m,g){for await(let w of f(m,g))yield*w.data},async create(m){let g={...m,id:`voorbeeld-${++r}`};return o.set(g.id,g),s(201,{...g})},async update(m,g){let w=await d(m),v={...w,...g,id:w.id};return o.set(String(m),v),s(200,{...v})},async delete(m){return await d(m),o.delete(String(m)),i.add(String(m)),s(204,null)}}}var di="./cube-app.config.json",pi="./cube-mock.json",mi="./cube-app.json",fi="./cube-theme.json",gi={id:"preview",name:Lt,scopes:[]},Qn=null,Jn=null,V=null,zt=null,rt=null,Wn=0;function Yn(e={}){let n=V!==null&&V===zt,t=++Wn,o=wi(e,()=>t===Wn);return V=o,zt=null,o.then(()=>{n&&V===o&&yi()},()=>{V===o&&(V=null)}),o}function hi(){return V!==null?V:(rt??(rt=bi().then(()=>{if(rt=null,V!==null)return V;let e=Yn();return zt=e,e})),rt)}function bi(){let e=globalThis;return new Promise(n=>{let t=()=>{setTimeout(n,0)};e.document===void 0||e.document.readyState==="complete"||e.addEventListener===void 0?t():e.addEventListener("load",t,{once:!0})})}function yi(){let e=globalThis.document;if(e===void 0)return;let n=e.defaultView?.CustomEvent??CustomEvent;e.dispatchEvent(new n("cube-session-change"))}async function wi(e,n){let t=e.fetch??globalThis.fetch.bind(globalThis),o=e.pageUrl??rr(),a=Ye(),[i,r]=await Promise.all([a===null?ot(t,Ee(di,o)):null,vi(e,t,o)]);return n()&&Pt(r),a!==null?Ti(a,e,t,o):i===null?ki(e,t,o):Si(Ri(i),e,t,o)}async function vi(e,n,t){try{if(e.theme===!1)return ie(null,t);let o=e.theme??Jn;if(o!==null)return ie(o,t);let a=await ot(n,Ee(fi,t));if(a!==null&&(a.theme!==1||typeof a.source!="object"||a.source===null))throw new TypeError("cube-theme.json is not a theme file.");return ie(a,t)}catch(o){return console.warn(`cube-theme.json could not be used, the neutral theme applies: ${String(o)}`),ie(null,t)}}async function Xn(e,n,t){let o=e.mock??Qn??await ot(n,Ee(pi,t))??{},a=e.manifest===!1?null:e.manifest??await ot(n,Ee(mi,t));return[o,a]}function Zn(e,n){let t=e==="wireframe",o=t?Kn(n?.ontbreekt):[];return{soort:e??null,gaps:o,simulatesWrites:t,isExample:(a,i)=>o.some(r=>r.resource===a&&(r.veld===void 0||r.veld===i))}}function er(e,n){let t=new Map;return e?a=>{let i=t.get(a)??Gn(n(a),a);return t.set(a,i),i}:n}async function ki(e,n,t){let[o,a]=await Xn(e,n,t),i=!0,r=()=>{if(!i)throw new $(401,new Headers({"Content-Type":"application/problem+json"}),{type:"https://docs.cube.nl/dmp-api/problems/token_invalid",title:"token invalid",status:401,code:"token_invalid",detail:"Unauthenticated."})},s=Zn(a?.soort,a),l=new Z(o,a,r),u=new Z(o,null,r),c=d=>s.isExample(d)?u:l;return{...s,mode:"preview",signInError:null,user:()=>i?{...gi}:null,async signIn(){i=!0},async signOut(){i=!1},resource:er(s.simulatesWrites,d=>{let p=c(d),f=p.resource(d),m=p.describe(d)?.fields??[],g=s.gaps.filter(({resource:w,veld:v})=>w===d&&v!==void 0&&!m.some(k=>k.name===v));return g.length>0?Ht(f,g,u,u.rows(d)):f}),schema:async d=>nt(c(d).describe(d),s.gaps)}}async function tr(e,n,t,o){let[a,i]=e==="wireframe"?await Xn(n,t,o):[{},null];return{marked:Zn(e,i),examples:new Z(a)}}function nr(e,{marked:n,examples:t}){let{client:o}=e,a=null;return{...n,mode:e.mode,get signInError(){return e.signInError()},user:e.user,signIn:e.signIn,signOut:e.signOut,resource:er(n.simulatesWrites,i=>n.isExample(i)?t.resource(i):n.gaps.some(r=>r.resource===i)?Ht(o.resources(i),n.gaps,t,t.rows(i)):o.resources(i)),async schema(i){if(n.isExample(i))return nt(t.describe(i),n.gaps);a??(a=o.capabilities());try{let r=(await a).resources.find(s=>s.name===i);return r===void 0?null:nt(Tn(r),n.gaps)}catch(r){throw a=null,r}}}}async function Si(e,n,t,o){let a=e.dmpUrl.replace(/\/+$/,""),i=null,r=Ei(n.tokenStorage==="memory"?je():Di(`cube-app.tokens.${e.clientId}`),d=>{i=d}),s=sn({issuer:e.issuer??a,clientId:e.clientId,redirectUri:Ee(e.redirectUri,o),scopes:e.scopes,fetch:t,tokenStore:r,...e.metadata!==void 0?{metadata:e.metadata}:{}}),l=St({baseUrl:e.apiUrl??`${a}/apps/api/v1`,auth:s,fetch:t}),u=null,c=await tr(e.soort,n,t,o);i=await r.get();try{await s.handleCallback()}catch(d){u=d instanceof Error?d:new Error(String(d))}return i===null&&u===null&&n.autoSignIn===!0&&await s.signIn(),nr({mode:"live",client:l,signInError:()=>u,user:()=>i===null?null:Ci(i),async signIn(){u=null,await s.signIn()},async signOut(){await s.signOut()}},c)}function xi(e){return async(n,t)=>{let o=(t?.method??"GET").toUpperCase();return o==="GET"||o==="HEAD"?e(n,t):new Response(JSON.stringify({status:403,code:"insufficient_scope"}),{status:403,headers:{"Content-Type":"application/problem+json"}})}}async function Ti(e,n,t,o){let a=e.token,i=St({baseUrl:e.apiUrl,auth:()=>a,fetch:xi(t)}),r=await tr(e.soort??void 0,n,t,o);return nr({mode:"trial",client:i,signInError:()=>null,user:()=>a===null?null:{id:e.userId,name:null,scopes:["api:read"]},async signIn(){globalThis.location?.reload()},async signOut(){a=null}},r)}function Ci(e){let n=Ai(e.accessToken),t=n?.sub,o=Array.isArray(n?.scopes)?n.scopes.map(String):null;return{id:typeof t=="string"||typeof t=="number"?String(t):null,name:null,scopes:o??(e.scope??"").split(" ").filter(a=>a!=="")}}function Ai(e){let n=e.split(".")[1];if(n===void 0)return null;try{let t=n.replace(/-/g,"+").replace(/_/g,"/"),o=atob(t.padEnd(t.length+(4-t.length%4)%4,"=")),a=new TextDecoder().decode(Uint8Array.from(o,r=>r.charCodeAt(0))),i=JSON.parse(a);return i!==null&&typeof i=="object"?i:null}catch{return null}}function Ri(e){let n=["dmpUrl","clientId","redirectUri"].filter(o=>typeof e[o]!="string"||e[o]===""),t=e.scopes;if(typeof t=="string"||Array.isArray(t)&&t.every(o=>typeof o=="string")||n.push("scopes"),n.length>0)throw new TypeError(`cube-app.config.json is incomplete: ${n.join(", ")} missing or not a string.`);return e}async function ot(e,n){let t;try{t=await e(n,{headers:{Accept:"application/json"},...typeof document<"u"?{cache:"no-store"}:{}})}catch{return null}if(t.status===404||t.status===410)return null;if(!t.ok)throw new Error(`${n} answered ${t.status}.`);try{let o=JSON.parse(await t.text());return o!==null&&typeof o=="object"&&!Array.isArray(o)?o:null}catch{return null}}function Ei(e,n){return{async get(){let t=await e.get();return n(t),t},async set(t){await e.set(t),n(t)}}}function Di(e){let n=(()=>{try{return globalThis.sessionStorage??null}catch{return null}})();return n===null?je():{get(){try{let t=n.getItem(e);return t===null?null:JSON.parse(t)}catch{return null}},set(t){try{t===null?n.removeItem(e):n.setItem(e,JSON.stringify(t))}catch{}}}}function rr(){let e=globalThis;return e.document?.baseURI??e.location?.href??"http://localhost/"}function Ee(e,n){return new URL(e,n).href}function Mi(e){Qn=e}function Li(e){Jn=e,Pt(ie(e,rr()))}var it=Object.freeze({connect:Yn,ready:hi,mock:Mi,theme:Li,version:$n,sdk:"1"});var or={"cube-state":["kind","message","retry"],"cube-app-shell":["name","logo","logo-alt"],"cube-page":["name","label"],"cube-field":["name","label","format","multiline","options","hidden"],"cube-period-picker":["default","label","today"],"cube-kpi":["resource","measure","label","format","currency","filter","period","date-field","compare"],"cube-chart":["resource","measure","by","kind","label","format","currency","filter","period","date-field","lookup","height","limit"],"cube-top":["resource","measure","by","limit","order","label","format","currency","filter","period","date-field","lookup"],"cube-table":["resource","fields","search","filters","sort","page-size","export","detail","filter","period","date-field"],"cube-detail":["resource","record-id","fields","editable"],"cube-form":["resource","fields","submit-label","success-text"],"cube-calc":["label"],"cube-input":["name","label","type","value","min","max","step","options"],"cube-result":["name","label","format","currency","emphasis"],"cube-board":["resource","status-field","title-field","fields","sort","filter","page-size"],"cube-column":["value","label"],"cube-gap-list":["scherm"]};var Fi="http://www.w3.org/2000/svg";function h(e,n,t={},...o){let a=e.createElement(n);for(let[i,r]of Object.entries(t))ir(i,r===!0||typeof r=="string"),typeof r=="function"?a.addEventListener(i.replace(/^on/,""),r):r===!0?a.setAttribute(i,""):typeof r=="string"&&a.setAttribute(i,r);return sr(e,a,o),a}function U(e,n,t={},...o){let a=e.createElementNS(Fi,n);for(let[i,r]of Object.entries(t))ir(i,!0),a.setAttribute(i,String(r));return sr(e,a,o),a}function ir(e,n){let t=e.toLowerCase();if(t==="style"||n&&t.startsWith("on"))throw new R(y.invalid.attribute(e))}function C(e){for(;e.firstChild!==null;)e.removeChild(e.firstChild)}function sr(e,n,t){for(let o of t)typeof o=="string"?n.appendChild(e.createTextNode(o)):o!=null&&o!==!1&&n.appendChild(o)}var De=`
|
|
3
|
+
:host{display:block;box-sizing:border-box;min-width:0;font-family:var(--cube-font-family,system-ui,sans-serif);
|
|
4
|
+
color:var(--cube-color-text,#1f2328);font-size:1rem;line-height:1.5}
|
|
5
|
+
:host([hidden]){display:none}
|
|
6
|
+
*,*::before,*::after{box-sizing:inherit}
|
|
7
|
+
.cube-body{display:block;min-width:0}
|
|
8
|
+
button{font:inherit;font-weight:600;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
|
|
9
|
+
gap:.375rem;min-height:2.5rem;padding:.5rem 1rem;border:1px solid var(--cube-color-primary);
|
|
10
|
+
border-radius:var(--cube-radius-small);background:var(--cube-color-primary);color:var(--cube-color-on-primary)}
|
|
11
|
+
button:hover{background:var(--cube-color-primary-hover);border-color:var(--cube-color-primary-hover)}
|
|
12
|
+
button.secondary{background:var(--cube-color-bg);color:var(--cube-color-primary-text);
|
|
13
|
+
border-color:var(--cube-color-border)}
|
|
14
|
+
button.secondary:hover{background:var(--cube-color-primary-subtle)}
|
|
15
|
+
button:disabled{cursor:not-allowed;opacity:.6}
|
|
16
|
+
input,select,textarea{font:inherit;color:inherit;max-width:100%;min-height:2.5rem;padding:.5rem .75rem;
|
|
17
|
+
border:1px solid var(--cube-color-text-muted);border-radius:var(--cube-radius-small);background:var(--cube-color-bg)}
|
|
18
|
+
a{color:var(--cube-color-primary-text)}
|
|
19
|
+
:focus-visible{outline:3px solid var(--cube-color-focus);outline-offset:2px}
|
|
20
|
+
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);
|
|
21
|
+
white-space:nowrap;border:0}
|
|
22
|
+
.badge{display:inline-block;padding:.125rem .5rem;border-radius:999px;font-size:.875rem;font-weight:600;
|
|
23
|
+
background:var(--cube-color-primary-subtle);color:var(--cube-color-primary-text)}
|
|
24
|
+
.muted{color:var(--cube-color-text-muted)}
|
|
25
|
+
.example.badge,.not-saved{background:var(--cube-color-example-bg);color:var(--cube-color-example-text)}
|
|
26
|
+
p.example{margin:0 0 .5rem}
|
|
27
|
+
td.example,dd.example{text-decoration:underline dashed;text-underline-offset:.25em}
|
|
28
|
+
.not-saved{margin:0;align-self:center;padding:.125rem .5rem;border-radius:var(--cube-radius-small);font-size:.875rem;
|
|
29
|
+
font-weight:600}
|
|
30
|
+
.row{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}
|
|
31
|
+
@media (max-width:640px){.row{flex-direction:column;align-items:stretch}.row>button{width:100%}}
|
|
32
|
+
`,ar=new WeakMap;function st(e,n){let t=ar.get(e);t===void 0&&(t=new Map,ar.set(e,t));let o=t.get(n);return o===void 0&&(o=new e.CSSStyleSheet,o.replaceSync(n),t.set(n,o)),o}var Q=class extends Error{constructor(t){super(t.detail??t.kind);b(this,"state");this.state=t}};function te(e){if(e instanceof Q)return e.state;if(P(e)){if(e.status===401)return{kind:"signed-out",detail:null};if(e.status===403)return{kind:"forbidden",detail:null}}return e instanceof R?{kind:"error",detail:e.message}:{kind:"error",detail:null}}function Oi(e){return new Promise(n=>{e.readyState==="loading"?e.addEventListener("DOMContentLoaded",()=>n(),{once:!0}):(e.defaultView?.setTimeout??setTimeout)(n,0)})}function at(e){return h(e,"span",{class:"badge example"},y.example,h(e,"span",{class:"sr-only"},y.exampleMissing.slice(y.example.length)))}function _i(e){return e!==null&&typeof e=="object"&&e.name==="AbortError"}function lr(e,n={}){let t=n.session??(()=>it.ready());class o extends e.HTMLElement{constructor(){super();b(this,"body");b(this,"current",Promise.resolve());b(this,"scheduled",!1);b(this,"controller",null);b(this,"badge",null);b(this,"onSessionChange",()=>this.schedule());b(this,"onDataChange",r=>{if(r.composedPath()[0]===this&&!this.constructor.reloadsOnOwnChange)return;let s=r.detail?.resource,l=this.getAttribute("resource")?.trim()??"";typeof s=="string"&&l!==""&&s.trim()===l&&this.schedule()});let r=this.constructor,s=this.attachShadow({mode:"open"});s.adoptedStyleSheets=r.css===""?[st(e,De)]:[st(e,De),st(e,r.css)],this.body=h(e.document,"div",{class:"cube-body",part:"body"}),s.appendChild(this.body),s.addEventListener("cube-retry",l=>{l.stopPropagation(),this.schedule()})}static get observedAttributes(){return[...or[this.tag]??[]]}get updateComplete(){return(async()=>{let r;do r=this.current,await r;while(r!==this.current)})()}connectedCallback(){this.ownerDocument.addEventListener("cube-session-change",this.onSessionChange),this.ownerDocument.addEventListener("cube-data-change",this.onDataChange),this.schedule()}disconnectedCallback(){this.ownerDocument.removeEventListener("cube-session-change",this.onSessionChange),this.ownerDocument.removeEventListener("cube-data-change",this.onDataChange),this.controller?.abort(),this.controller=null,this.removeAttribute("aria-busy")}attributeChangedCallback(r,s,l){s!==l&&this.schedule()}refresh(){if(!this.isConnected)return this.current;this.controller?.abort();let r=new AbortController;this.controller=r;let s=this.run(r.signal);return this.current=s,s}schedule(){this.scheduled||!this.isConnected||(this.scheduled=!0,this.current=new Promise(r=>{queueMicrotask(()=>{this.scheduled=!1,r(this.isConnected?this.refresh():void 0)})}))}async run(r){let s=this.constructor;this.showState("loading");try{if(await Oi(this.ownerDocument),r.aborted)return;let l=s.needsSession?await this.session():null;if(r.aborted)return;await this.load(r,l),r.aborted||this.mark(l)}catch(l){if(r.aborted||_i(l))return;this.badge?.remove(),this.showState(te(l)),l instanceof TypeError&&!(l instanceof R)&&console.warn(`${this.localName}:`,l)}finally{r.aborted||this.removeAttribute("aria-busy")}}session(){return t()}shownFields(){return[]}exampleField(r,s,l){return r.isExample?.(s,l)===!0&&!r.isExample(s)}notSaved(r){return r.simulatesWrites===!0?h(this.ownerDocument,"p",{class:"note not-saved"},y.exampleNotSaved):null}mark(r){let s=this.getAttribute("resource")?.trim()??"";if(!(r?.isExample!==void 0&&s!==""&&(r.isExample(s)||this.shownFields().some(u=>r.isExample(s,u))))){this.badge?.remove();return}this.badge??(this.badge=h(this.ownerDocument,"p",{class:"badge example",role:"note"},y.exampleMissing)),this.shadowRoot?.insertBefore(this.badge,this.body)}showState(r,s=null){let{kind:l,detail:u,retry:c}=typeof r=="string"?{kind:r,detail:s}:r;l==="loading"&&this.setAttribute("aria-busy","true"),C(this.body),this.body.appendChild(h(this.ownerDocument,"cube-state",{kind:l,message:u,retry:c===!1?"false":null}))}attr(r){return this.getAttribute(r)}flag(r){return this.hasAttribute(r)&&this.getAttribute(r)!=="false"}num(r,s){let l=this.getAttribute(r);if(l===null||l.trim()==="")return s;let u=Number(l);if(!Number.isFinite(u))throw new R(y.invalid.number(this.localName,r));return u}json(r){let s=this.getAttribute(r);if(s===null||s.trim()==="")return null;try{return JSON.parse(s)}catch{throw new R(y.invalid.json(this.localName,r))}}emit(r,s=null){let l=this.ownerDocument.defaultView?.CustomEvent??CustomEvent;return this.dispatchEvent(new l(r,{detail:s,bubbles:!0,composed:!0}))}}return b(o,"tag",""),b(o,"css",""),b(o,"needsSession",!0),b(o,"reloadsOnOwnChange",!0),o}var $i=`
|
|
33
|
+
:host{background:var(--cube-color-bg)}
|
|
34
|
+
header{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem 1rem;padding:.75rem 1.5rem;
|
|
35
|
+
border-bottom:1px solid var(--cube-color-border);background:var(--cube-color-surface)}
|
|
36
|
+
.logo{display:block;height:2rem;width:auto;max-width:10rem;object-fit:contain}
|
|
37
|
+
h1{flex:1 1 auto;min-width:0;margin:0;font-size:1.25rem;line-height:1.3;overflow-wrap:anywhere}
|
|
38
|
+
.user{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;margin-left:auto}
|
|
39
|
+
nav{border-bottom:1px solid var(--cube-color-border);padding:0 1.5rem}
|
|
40
|
+
nav ul{display:flex;gap:.25rem;margin:0;padding:0;list-style:none;position:relative;overflow-x:auto}
|
|
41
|
+
nav a{display:block;padding:.75rem 1rem;white-space:nowrap;text-decoration:none;color:var(--cube-color-text-muted);
|
|
42
|
+
border-bottom:3px solid transparent}
|
|
43
|
+
nav a:hover{color:var(--cube-color-primary-text)}
|
|
44
|
+
nav a[aria-current=page]{font-weight:600;color:var(--cube-color-primary-text);
|
|
45
|
+
border-bottom-color:var(--cube-color-primary)}
|
|
46
|
+
main{padding:1.5rem}
|
|
47
|
+
::slotted(cube-page:not([hidden])){display:flex;flex-direction:column;gap:1.5rem}
|
|
48
|
+
@media (max-width:640px){header{padding:.75rem 1rem}nav{padding:0}main{padding:1rem}}
|
|
49
|
+
`,Vt="#/";function ur(e,n){class t extends e{constructor(){super();b(this,"header");b(this,"heading");b(this,"user");b(this,"nav");b(this,"list");b(this,"main");b(this,"built","");b(this,"stopTheme",null);b(this,"onHash",()=>this.updatePages());let i=n.document;this.heading=h(i,"h1"),this.user=h(i,"div",{class:"user"}),this.header=h(i,"header",{},this.heading,this.user),this.list=h(i,"ul"),this.nav=h(i,"nav",{"aria-label":y.pages},this.list);let r=h(i,"slot",{onslotchange:()=>this.updatePages()});this.main=h(i,"main",{},r),this.body.append(this.header,this.main),this.renderHeader()}connectedCallback(){super.connectedCallback(),this.ownerDocument.defaultView?.addEventListener("hashchange",this.onHash),this.stopTheme?.(),this.stopTheme=Qe(()=>this.renderHeader()),this.renderHeader(),this.updatePages()}disconnectedCallback(){super.disconnectedCallback(),this.ownerDocument.defaultView?.removeEventListener("hashchange",this.onHash),this.stopTheme?.(),this.stopTheme=null}async load(i,r){this.renderHeader(),this.updatePages(),r!==null&&this.renderUser(r)}showState(i){let r=typeof i=="string"?i:i.kind;C(this.user),r==="signed-out"&&this.user.appendChild(this.signInButton())}renderHeader(){let i=this.attr("name")??"",r=this.attr("logo")??We().logo,s=this.header.querySelector(".logo");if(this.heading.textContent=i,r===null||r===""){s?.remove();return}let l=h(n.document,"img",{class:"logo",src:r,alt:this.attr("logo-alt")??i});s===null?this.header.prepend(l):s.replaceWith(l)}renderUser(i){let r=n.document,s=i.user();if(C(this.user),s===null){this.user.appendChild(this.signInButton());return}this.user.append(h(r,"span",{},s.name!==null&&s.name!==""?s.name:y.signedIn),h(r,"button",{type:"button",class:"secondary",onclick:()=>{this.change(l=>l.signOut())}},y.signOut))}signInButton(){return h(n.document,"button",{type:"button",onclick:()=>{this.change(i=>i.signIn())}},y.signIn)}async change(i){try{await i(await this.session())}catch{this.refresh();return}let r=this.ownerDocument.defaultView?.CustomEvent??CustomEvent;this.ownerDocument.dispatchEvent(new r("cube-session-change"))}pages(){return Array.from(this.children).filter(i=>i.localName==="cube-page")}updatePages(){let i=this.pages(),s=(n.location??this.ownerDocument.defaultView?.location)?.hash??"",l="";if(s.startsWith(Vt))try{l=decodeURIComponent(s.slice(Vt.length).split("?")[0]??"")}catch{l=""}let u=i.find(d=>d.getAttribute("name")===l)??i[0];for(let d of i)d.hidden=d!==u;if(i.length<2){this.nav.remove(),C(this.list),this.built="";return}this.nav.parentNode!==this.body&&this.body.insertBefore(this.nav,this.main);let c=JSON.stringify(i.map(d=>[d.getAttribute("name"),d.getAttribute("label")]));if(c!==this.built){C(this.list);for(let d of i){let p=d.getAttribute("name")??"",f=Vt+encodeURIComponent(p),m=h(n.document,"a",{href:f},d.getAttribute("label")??p);this.list.appendChild(h(n.document,"li",{},m))}this.built=c}Array.from(this.list.querySelectorAll("a")).forEach((d,p)=>{i[p]===u?d.setAttribute("aria-current","page"):d.removeAttribute("aria-current")})}}return b(t,"tag","cube-app-shell"),b(t,"css",$i),t}var Pi=/^([a-z][a-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)$/,Kt=200;function fe(e){let n=e.getAttribute("filter");if(n===null||n.trim()==="")return{};let t;try{t=JSON.parse(n)}catch{t=null}if(t===null||typeof t!="object"||Array.isArray(t))throw new R(y.invalid.json(e.localName,"filter"));return t}function Ni(e){let n=e;return typeof n?.from=="string"&&typeof n.to=="string"&&typeof n.previous?.from=="string"&&typeof n.previous.to=="string"}function lt(e,n){let t=j(n.to);if(t===null)throw new R(y.invalid.periodEnd(n.to));return t.setDate(t.getDate()+1),{[e]:{gte:n.from,lt:I(t)}}}async function ut(e,n){if(n===null||n==="")return null;let t=e.ownerDocument.querySelector(n),o=(e.ownerDocument.defaultView??window).customElements;if(t===null||o.get(t.localName)===void 0)throw new R(y.invalid.periodSource(n));let a=t;if(await a.updateComplete,!Ni(a.value))throw new R(y.invalid.periodSource(n));return a}function ct(e,n,t){if(e!==null&&e!=="")return e;if(n!==null&&n!==""){let o=Ze(n);if(o.truncation!==null)return o.field}throw new R(y.invalid.dateField(t))}async function cr(e,n,t,o){let a=Pi.exec(n),i=a?.[1],r=a?.[2];if(i===void 0||r===void 0)throw new R(y.invalid.lookup(n));let s=[...new Set(t.filter(u=>u!=null).map(u=>u))],l=new Map;for(let u=0;u<s.length;u+=Kt){o.throwIfAborted();let c=s.slice(u,u+Kt),d;try{let p={filter:{id:{in:c}},fields:["id",r],page:{size:Kt}};({data:d}=await e.resource(i).list(p,{signal:o}))}catch(p){if(o.aborted||p?.name==="AbortError")throw p;continue}for(let p of d){let f=p[r];f!=null&&l.set(String(p.id),String(f))}}return l}var ji=["number","integer","currency","percent"],_=`
|
|
50
|
+
.card{padding:1rem 1.25rem;border:1px solid var(--cube-color-border);border-radius:var(--cube-radius);
|
|
51
|
+
background:var(--cube-color-surface)}
|
|
52
|
+
`,ge=`
|
|
53
|
+
.label{margin:0 0 .5rem;font-weight:600}
|
|
54
|
+
`;function F(e,n){let t=e.getAttribute(n)?.trim()??"";if(t==="")throw new R(y.invalid.missing(e.localName,n));return t}function he(e){let n=/\(([^)]+)\)/.exec(e.getAttribute("measure")??"")?.[1]?.trim(),t=e.getAttribute("by")?.split(".")[0];return[n,t,e.getAttribute("date-field")].filter(o=>!!o)}function Me(e){if(typeof e=="string"&&e.trim()==="")return null;let n=typeof e=="number"||typeof e=="string"?Number(e):NaN;return Number.isFinite(n)?n:null}var K=class{constructor(n){b(this,"block",n);b(this,"source",null);b(this,"onChange",()=>{this.block.isConnected?this.block.refresh():this.follow(null)})}follow(n){n!==this.source&&(this.source?.removeEventListener("cube-change",this.onChange),this.source=n,n?.addEventListener("cube-change",this.onChange))}};async function be(e,n,t,o=null){let a=Bn(F(e,"measure")),i=fe(e),r=e.getAttribute("period"),s=r===null||r===""?null:ct(e.getAttribute("date-field"),o,e.localName),l=await ut(e,r);return t.aborted?null:(n.follow(l),{fn:a.field===null?a.fn:`${a.fn}(${a.field})`,field:a.field,count:a.fn==="count",period:l?.value??null,filterFor:u=>u===null||s===null?i:{...i,...lt(s,u)}})}async function dt(e,n,t,o,a){try{return await e.resource(n).aggregate({fn:o.fn,group:t,filter:o.filterFor(o.period)},{signal:a})}catch(i){throw P(i)&&i.status===422&&(i.reason==="too_many_groups"||i.code==="cardinality_exceeded")?new Q({kind:"error",detail:y.tooManyGroups,retry:!1}):i}}function J(e,n,t,o){let a=e.getAttribute(n),i=a===null||a.trim()===""?NaN:Number(a);return Number.isFinite(i)&&i>=t?Math.floor(i):o}async function pt(e,n,t,o,a,i){let r=a.descending?-1:1,s=t.filter(c=>c[o.by]!==null&&c[o.by]!==void 0).map(c=>({key:String(c[o.by]),value:Me(c[o.fn])})).filter(c=>c.value!==null).sort((c,d)=>r*(c.value-d.value)).slice(0,a.limit),l=e.getAttribute("lookup"),u=l===null||l===""||s.length===0?null:await cr(n,l,s.map(c=>c.key),i);return i.aborted?null:s.map(c=>({...c,label:u===null?c.key:u.get(c.key)??`#${c.key}`}))}function ye(e,n){let t=e.getAttribute("format"),o=t!==null&&ji.includes(t)?t:n?"integer":"number",a=e.getAttribute("currency")||"EUR";return(i,r)=>N(i,o,{currency:a,compact:r===!0})}var Le=Symbol("cube-field hidden");function dr(e){var n,t;return class extends(t=e.HTMLElement,n=Le,t){constructor(){super(...arguments);b(this,n)}connectedCallback(){this[Le]===void 0&&(this[Le]=this.hasAttribute("hidden")),this.hidden=!0}}}function mt(e){let n=e.field?.enum??null;return e.config?.options??(n===null?null:n.map(t=>({value:t,label:t})))}var Ii=["text","number","integer","currency","percent","date","datetime","boolean"];function Y(e){let n=(e??"").split(",").map(t=>t.trim()).filter(t=>t!=="");return n.length>0?n:null}function qt(e){if(e===null)return null;let n=e.split(",").map(t=>{let o=t.indexOf("="),a=(o<0?t:t.slice(0,o)).trim(),i=o<0?a:t.slice(o+1).trim();return{value:a,label:i===""?a:i}}).filter(t=>t.value!=="");return n.length>0?n:null}function q(e){let n=new Map;for(let t of Array.from(e.children)){let o=t.getAttribute("name")?.trim()??"";if(t.localName!=="cube-field"||o==="")continue;let a=t.getAttribute("format"),i=t[Le];n.set(o,{name:o,label:t.getAttribute("label"),format:a!==null&&Ii.includes(a)?a:null,multiline:t.hasAttribute("multiline"),options:qt(t.getAttribute("options")),hidden:i??t.hasAttribute("hidden")})}return n}function Fe(e,n){return e.get(n)?.label??z(n)}function X(e,n,t,o){let a=e!==null&&e.summary.length>0?e.summary:null;return(n??a??(o===void 0?[]:Object.keys(o))).filter(r=>t.get(r)?.hidden!==!0).map(r=>{let s=e?.fields.find(u=>u.name===r),l=t.get(r);return{name:r,label:Fe(t,r),format:l?.format??Un(s,o?.[r]),field:s,config:l}})}var we=`
|
|
55
|
+
.field{display:flex;flex-direction:column;gap:.25rem;min-width:0}
|
|
56
|
+
.field label{font-weight:600}
|
|
57
|
+
.field .required{font-weight:400;color:var(--cube-color-text-muted)}
|
|
58
|
+
.field.check{flex-direction:row;align-items:center;gap:.5rem}
|
|
59
|
+
.field.check input{min-height:auto;width:1.25rem;height:1.25rem}
|
|
60
|
+
.field [aria-invalid=true]{border-color:var(--cube-color-danger,#b42318)}
|
|
61
|
+
.field-error{margin:0;color:var(--cube-color-danger,#b42318);font-size:.875rem}
|
|
62
|
+
`,Bi=/^-?(\d{1,3}(\.\d{3})+|\d*)(,\d+)?$/,Ui=/^-?[1-9]\d{0,2}(\.\d{3})+$/,Hi=/^-?(\d+\.?\d*|\.\d+)$/,zi=0;function Vi(e){return e.includes(",")?Bi.test(e)&&/\d/.test(e)?Number(e.replace(/\./g,"").replace(",",".")):null:Ui.test(e)?Number(e.replace(/\./g,"")):Hi.test(e)?Number(e):null}var pr=e=>Number(e.toPrecision(12));function Oe(e,n){if(e.trim()==="")return{value:null};if(ee.includes(n)){let t=Vi(e.replace(/[\s €%]/g,""));return t===null||!Number.isFinite(t)?{error:y.notANumber}:n==="integer"&&!Number.isInteger(t)?{error:y.notAnInteger}:{value:n==="percent"?pr(t/100):t}}if(n==="boolean")return{value:e==="true"||e==="1"};if(n==="datetime"){let t=Date.parse(e);return{value:Number.isNaN(t)?e:new Date(t).toISOString()}}return{value:e}}function mr(e){if(!P(e)||e.status!==422||e.errors===null)return null;let n={};for(let[t,o]of Object.entries(e.errors)){let a=Array.isArray(o)?o.find(i=>typeof i=="string"):void 0;a!==void 0&&(n[t]=a)}return Object.keys(n).length>0?n:null}function Ki(e,n){if(e==null)return"";if(ee.includes(n)){let t=typeof e=="number"?e:Number(e);return typeof e=="boolean"||!Number.isFinite(t)?String(e):String(n==="percent"?pr(t*100):t).replace(".",",")}if(n==="date"&&typeof e=="string")return e.slice(0,10);if(n==="datetime"&&typeof e=="string"){let t=Date.parse(e);if(Number.isNaN(t))return e;let o=new Date(t),a=i=>String(i).padStart(2,"0");return`${I(o)}T${a(o.getHours())}:${a(o.getMinutes())}`}return typeof e=="object"?JSON.stringify(e):String(e)}function qi(e,n,t,o){let a=mt(n),i=Ki(t,n.format);if(a!==null){let u=a.some(p=>p.value===i),c=i===""||u?a:[...a,{value:i,label:i}],d=h(e,"select",{id:o,name:n.name},h(e,"option",{value:""},y.emptyValue),...c.map(p=>h(e,"option",{value:p.value},p.label)));return d.value=i,d}if(n.format==="text"&&n.config?.multiline===!0){let u=h(e,"textarea",{id:o,name:n.name,rows:"4"});return u.value=i,u}let r=ee.includes(n.format),s=n.format==="date"?"date":n.format==="datetime"?"datetime-local":"text",l=h(e,"input",{id:o,name:n.name,type:n.format==="boolean"?"checkbox":s,inputmode:r?"decimal":null});return n.format==="boolean"?l.checked=t===!0||t==="true"||t===1:l.value=i,l}function ve(e,n,t,o){let a=`cube-input-${++zi}`,i=qi(e,n,t,a),r=i.getAttribute("type")==="checkbox";o&&!r&&i.setAttribute("aria-required","true");let s=o&&!r?h(e,"span",{class:"required","aria-hidden":"true"},y.requiredMark):null,l=h(e,"label",{for:a},n.label,s),u=h(e,"p",{id:`${a}-error`,class:"field-error",hidden:!0});return{element:h(e,"div",{class:r?"field check":"field"},...r?[i,l]:[l,i],u),name:n.name,read(){return r?{value:i.checked}:o&&i.value.trim()===""?{error:y.required}:Oe(i.value,n.format)},setError(d){u.textContent=d??"",u.hidden=d===null,d===null?(i.removeAttribute("aria-invalid"),i.removeAttribute("aria-describedby")):(i.setAttribute("aria-invalid","true"),i.setAttribute("aria-describedby",u.id))}}}var ke=`
|
|
63
|
+
form{display:flex;flex-direction:column;gap:1rem}
|
|
64
|
+
.actions{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:1rem}
|
|
65
|
+
.alert{margin:0 0 1rem;padding:.75rem 1rem;border:1px solid var(--cube-color-danger,#b42318);
|
|
66
|
+
border-radius:var(--cube-radius-small)}
|
|
67
|
+
.alert p{margin:0}
|
|
68
|
+
.alert ul{margin:.5rem 0 0;padding-inline-start:1.25rem}
|
|
69
|
+
.alert button{margin-top:.5rem}
|
|
70
|
+
.status{margin:.5rem 0 0}
|
|
71
|
+
.status:empty{margin:0}
|
|
72
|
+
`;function Se(e,n){return e?.body===n?e:{key:cn(),body:n}}function _e(e,n,t,o){C(n),n.append(h(e,"p",{},t),...o==null?[]:[o]),n.hidden=!1,n.focus()}function ft(e,n,t,o,a){let i=mr(t);if(i!==null){for(let u of o)u.setError(i[u.name]??null);let s=Object.entries(i).filter(([u])=>!o.some(c=>c.name===u)),l=s.length===0?null:h(e,"ul",{},...s.map(([u,c])=>h(e,"li",{},`${a(u)}: ${c}`)));_e(e,n,y.formInvalid,l);return}let r=te(t).kind;_e(e,n,r==="forbidden"?y.forbidden:r==="signed-out"?y.signedOut:y.saveFailed)}function ae(e){let n=e?.user()??null;return n===null?null:String(n.id)}var Gi=`${_}${ke}
|
|
73
|
+
.board{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(14rem,1fr);gap:1rem;
|
|
74
|
+
position:relative;overflow-x:auto}
|
|
75
|
+
@media (max-width:640px){.board{grid-auto-flow:row;grid-auto-columns:auto}}
|
|
76
|
+
section{min-width:0}
|
|
77
|
+
h3{margin:0 0 .5rem;font-size:1rem}
|
|
78
|
+
article{margin-top:.5rem;padding:.75rem;border:1px solid var(--cube-color-border);
|
|
79
|
+
border-radius:var(--cube-radius-small);background:var(--cube-color-bg);overflow-wrap:anywhere}
|
|
80
|
+
article[draggable=true]{cursor:grab}
|
|
81
|
+
.title{margin:0;font-weight:600}
|
|
82
|
+
dl{display:grid;grid-template-columns:auto 1fr;gap:0 .5rem;margin:.25rem 0 0;font-size:.875rem}
|
|
83
|
+
dd{margin:0;min-width:0}
|
|
84
|
+
.moves{display:flex;flex-wrap:wrap;gap:.25rem;margin-top:.5rem}
|
|
85
|
+
.moves button{min-height:2rem;padding:.25rem .5rem;font-size:.875rem}
|
|
86
|
+
.moves button::before{content:"\\2192 "}
|
|
87
|
+
.muted{margin:.5rem 0 0}
|
|
88
|
+
.not-saved{display:inline-block;margin-bottom:.75rem}
|
|
89
|
+
`,gt=e=>String(e.id);function Wi(e){return e.split(",").map(n=>n.trim()).filter(n=>n!=="").map(n=>({field:n.replace(/^[-+]/,""),descending:n.startsWith("-")}))}function Qi(e,n){if(e==null||n==null)return e==null?n==null?0:-1:1;if(typeof e=="number"&&typeof n=="number")return e-n;if(typeof e=="boolean"||typeof n=="boolean")return+(e===!0||e===1||e==="1")-+(n===!0||n===1||n==="1");let t=String(e),o=String(n);return t<o?-1:t>o?1:0}function Ji(e,n,t){for(let{field:o,descending:a}of e){let i=Qi(n[o],t[o]);if(i!==0)return a?-i:i}return 0}function Yi(e){if(P(e)&&(e.status===409||e.status===412))return y.changedMeanwhile;let n=te(e).kind;return n==="forbidden"?y.forbidden:n==="signed-out"?y.signedOut:y.tryAgain}function fr(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"alert",h(t,"div",{class:"alert",role:"alert",hidden:!0}));b(this,"loaded",null);b(this,"tracks",new Map);b(this,"pending",0);b(this,"stale",!1);b(this,"dragged",null);b(this,"focusKey",null);b(this,"attempt",null);b(this,"ids",0);this.shadowRoot?.insertBefore(this.alert,this.body)}shownFields(){let r=this.loaded;return r===null?[]:[r.status,r.title,...r.fields.map(s=>s.name)]}refresh(){if(this.pending>0)return this.stale=!0,Promise.resolve();this.stale=!1;let r=this.shadowRoot?.activeElement?.closest("article")?.getAttribute("data-id");return r!=null&&(this.focusKey=r),super.refresh()}async load(r,s){if(s===null)return;this.loaded=null;let l=F(this,"resource"),u=F(this,"status-field"),c=F(this,"title-field"),d=fe(this),p=Math.min(J(this,"page-size",1,50),200),f=this.attr("sort")?.trim()??"",m=Wi(f),g=await s.schema(l);if(r.aborted)return;let w=g?.fields.find(x=>x.name===u),v=g===null||g.fields.some(x=>x.name==="id"),k=Y(this.attr("fields")),S=k===null?[]:X(g,k,q(this)),D={fields:[...new Set([...v?["id"]:[],c,u,...S.map(x=>x.name),...m.map(x=>x.field)])],page:{size:p}};f!==""&&(D.sort=f);let L=s.resource(l),B=await Promise.all(this.columnValues(w?.enum??null).map(async x=>{let{data:E,meta:O}=await L.list({...D,filter:{...d,[u]:x.value}},{signal:r});return{...x,rows:[...E],total:O.page?.total??E.length}}));if(r.aborted)return;let T={session:s,user:ae(s),resource:l,status:u,title:c,fields:S,columns:B,canMove:v&&g!==null&&g.actions.includes("update")&&w?.readonly===!1,order:m,numeric:w?.type==="integer"||w?.type==="number"};this.loaded=T,this.tracks.clear(),this.render(T)}columnValues(r){let s=Array.from(this.children).filter(u=>u.localName==="cube-column"),l=s.length>0?s.map(u=>{let c=F(u,"value");return{value:c,label:u.getAttribute("label")?.trim()||z(c)}}):(r??[]).map(u=>({value:u,label:z(u)}));if(l.length===0)throw new Q({kind:"error",detail:y.noColumns,retry:!1});return l}render(r){let s=new Map;C(this.body),this.body.append(...[r.canMove&&this.notSaved(r.session),h(t,"div",{class:"board"},...r.columns.map(u=>this.column(r,u,s)))].filter(u=>!!u));let l=this.focusKey;this.focusKey=null,l!==null&&s.get(l)?.focus()}column(r,s,l){let u=`b${++this.ids}`,c=s.total-s.rows.length;return h(t,"section",{class:"card",role:"group","aria-labelledby":u,ondragover:d=>{r.canMove&&this.dragged!==null&&d.preventDefault()},ondrop:d=>{d.preventDefault();let p=this.dragged;this.dragged=null,p!==null&&this.move(r,p,s.value)}},h(t,"h3",{id:u},s.label," ",h(t,"span",{class:"badge"},`${s.total}`)),...s.rows.length===0?[h(t,"p",{class:"muted"},y.emptyColumn)]:s.rows.map(d=>this.card(r,s,d,l)),c>0?h(t,"p",{class:"muted"},y.more(c)):null)}card(r,s,l,u){let c=gt(l),d=`b${++this.ids}`,p=h(t,"article",{tabindex:"0",draggable:r.canMove?"true":"false","data-id":c,"aria-labelledby":d,ondragstart:f=>{this.dragged=c,f.dataTransfer?.setData("text/plain",c)},ondragend:()=>{this.dragged=null}},h(t,"p",{class:"title",id:d},N(l[r.title],"text")),r.fields.length===0?null:h(t,"dl",{},...r.fields.flatMap(f=>[h(t,"dt",{},f.label),h(t,"dd",{},N(l[f.name],f.format))])),r.canMove?h(t,"div",{class:"moves"},...r.columns.filter(f=>f!==s).map(f=>h(t,"button",{type:"button",class:"secondary","aria-label":y.moveTo(f.label),"aria-describedby":d,onclick:()=>this.move(r,c,f.value)},f.label))):null);return u.set(c,p),p}place(r,s,l){let u=r.columns.find(c=>c.value===l);for(let c of r.columns){let d=c.rows.findIndex(f=>gt(f)===s),p=c.rows[d];if(!(p===void 0||u===void 0)){if(c.rows.splice(d,1),c.total--,r.order.length===0)u.rows.unshift(p);else{let f=u.rows.findIndex(m=>Ji(r.order,m,p)>0);u.rows.splice(f===-1?u.rows.length:f,0,p)}return u.total++,{row:p,from:c.value}}}return null}move(r,s,l){let u=r.columns.find(w=>w.rows.some(v=>gt(v)===s));if(!r.canMove||this.loaded!==r||u===void 0||u.value===l)return;let c=this.place(r,s,l);if(c===null)return;let{row:d,from:p}=c;this.alert.hidden=!0,this.focusKey=s,this.render(r);let f=this.tracks.get(s);f===void 0&&(f={confirmed:p,tail:Promise.resolve(),generation:0},this.tracks.set(s,f));let m=f,g=m.generation;this.pending++,m.tail=m.tail.then(()=>g===m.generation?this.send(r,m,d,p,l):void 0).finally(()=>{--this.pending===0&&this.stale&&this.refresh()})}async send(r,s,l,u,c){let d=gt(l),p={[r.status]:r.numeric&&Number.isFinite(Number(c))?Number(c):c},f=Se(this.attempt,JSON.stringify([r.resource,d,p]));this.attempt=f;try{let m=await this.session();if(ae(m)!==r.user){s.generation++,this.stale=!0;return}await m.resource(r.resource).update(l.id,p,{idempotencyKey:f.key}),this.attempt===f&&(this.attempt=null),s.confirmed=c,this.emit("cube-move",{resource:r.resource,id:l.id,from:u,to:c}),this.emit("cube-data-change",{resource:r.resource})}catch(m){if(P(m)&&this.attempt===f&&(this.attempt=null),s.generation++,P(m)&&(m.status===409||m.status===412)&&(this.stale=!0),this.loaded!==r)return;this.place(r,d,s.confirmed),this.focusKey=d,this.render(r),C(this.alert),this.alert.append(`${y.moveFailed} ${Yi(m)}`),this.alert.hidden=!1}}}return b(o,"tag","cube-board"),b(o,"css",Gi),b(o,"reloadsOnOwnChange",!1),o}var Xi=`${_}${ge}${we}
|
|
90
|
+
.inputs{display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))}
|
|
91
|
+
.inputs:empty{display:none}
|
|
92
|
+
.results{display:flex;flex-wrap:wrap;gap:1rem 2rem;margin-top:1.25rem;padding-top:1rem;
|
|
93
|
+
border-top:1px solid var(--cube-color-border)}
|
|
94
|
+
.inputs:empty+.results{margin-top:0;padding-top:0;border-top:0}
|
|
95
|
+
.result{display:flex;flex-direction:column;min-width:0}
|
|
96
|
+
.result label{font-size:.875rem;font-weight:600;color:var(--cube-color-text-muted)}
|
|
97
|
+
.result output{font-size:1.25rem;font-weight:600;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
|
|
98
|
+
.result.emphasis output{font-size:2rem;font-weight:700;line-height:1.2}
|
|
99
|
+
.alert{margin:1rem 0 0;color:var(--cube-color-danger,#b42318)}
|
|
100
|
+
.alert:empty{margin:0}
|
|
101
|
+
`,Zi=["number","integer","currency","percent","text","select","checkbox"],es=["number","integer","currency","percent","text"],gr=0;function hr(e,n,t){let o=e.getAttribute(n)?.trim()??"",a=o===""?t[0]:o;if(!t.includes(a))throw new R(y.invalid.value(e.localName,n,a));return a}function Gt(e,n){let t=e.getAttribute(n)?.trim()??"";if(t==="")return null;let o=Number(t);if(!Number.isFinite(o)||n==="step"&&o<=0)throw new R(y.invalid.number(e.localName,n));return o}var $e=e=>N(e,"number");function br(e){let n=e.editor.read();if("error"in n||typeof n.value!="number")return n;let t=e.format==="percent"?Number((n.value*100).toPrecision(12)):n.value,{min:o,max:a,step:i}=e;if(o!==null&&t<o||a!==null&&t>a)return{error:o===null?y.atMost($e(a)):a===null?y.atLeast($e(o)):y.range($e(o),$e(a))};if(i!==null){let r=(t-(o??0))/i;if(Math.abs(r-Math.round(r))>1e-9)return{error:y.step($e(i))}}return n}function yr(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"fn",null);b(this,"drawn",null);b(this,"shownValues",{});b(this,"shownResults",{});let u=Object.getOwnPropertyDescriptor(this,"formula");u!==void 0&&(delete this.formula,this.fn=u.value)}get formula(){return typeof this.fn=="function"?this.fn:null}set formula(u){this.fn=u,this.drawn!==null&&(u===null||typeof u=="function")?this.calculate(!0):(this.drawn=null,this.refresh())}get values(){return{...this.shownValues}}get results(){return{...this.shownResults}}refresh(){return this.drawn!==null&&this.drawn.label===this.attr("label")?Promise.resolve():(this.drawn=null,super.refresh())}async load(){if(this.drawn=null,this.fn!==null&&typeof this.fn!="function")throw new Q({kind:"error",detail:y.invalid.formula,retry:!1});let u=Array.from(this.children),c=u.filter(w=>w.localName==="cube-input").map(i),d=u.filter(w=>w.localName==="cube-result").map(r);if(d.length===0)throw new R(y.invalid.missing(this.localName,"cube-result"));a("cube-input",c.map(w=>w.editor.name)),a("cube-result",d.map(w=>w.name));let p=this.attr("label"),f=p===null||p.trim()===""?null:h(t,"p",{class:"label",id:`cube-calc-${++gr}`},p),m=h(t,"p",{class:"alert",role:"alert"}),g=h(t,"form",{novalidate:!0,"aria-labelledby":f?.id??null},h(t,"div",{class:"inputs"},...c.map(w=>w.editor.element)),h(t,"div",{class:"results","aria-live":"polite"},...d.map(w=>w.element)),m);g.addEventListener("submit",w=>w.preventDefault()),g.addEventListener("input",()=>this.calculate(!0,!0)),g.addEventListener("change",()=>this.showErrors()),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},f,g)),this.drawn={label:p,inputs:c,results:d,alert:m},this.showErrors(),this.calculate(!1)}showErrors(){for(let u of this.drawn?.inputs??[]){let c=br(u);u.shown="error"in c,u.editor.setError("error"in c?c.error:null)}}calculate(u,c=!1){let d=this.drawn;if(d===null)return;let p={};for(let g of d.inputs){let w=br(g);p[g.editor.name]="error"in w?null:w.value,g.shown&&(g.shown="error"in w,g.editor.setError("error"in w?w.error:null))}let f={},m=!1;try{let g=this.formula,w=g===null?null:g({...p});if((typeof w=="object"||typeof w=="function")&&w!==null&&typeof w.then=="function"){this.drawn=null,this.showState({kind:"error",detail:y.invalid.calcAsync,retry:!1});return}let v=w===null||typeof w!="object";if(v&&w!==null&&w!==void 0&&d.results.length>1){if(c)throw new R(y.invalid.calcSingle);this.drawn=null,this.showState({kind:"error",detail:y.invalid.calcSingle,retry:!1});return}for(let k of d.results){let S=v?w:w[k.name],D=typeof S=="number"&&!Number.isFinite(S)||k.format!=="text"&&typeof S=="object"&&S!==null;m||(m=D),f[k.name]=D||S===void 0?null:S}}catch(g){d.alert.textContent===""&&console.warn(g),m=!0;for(let w of d.results)f[w.name]=null}for(let g of d.results)g.output.textContent=N(f[g.name],g.format,{currency:g.currency});m&&d.alert.textContent===""&&(d.alert.textContent=y.calcFailed),m||(d.alert.textContent=""),this.shownValues=p,this.shownResults=f,u&&this.emit("cube-change",{values:{...p},results:{...f}})}}b(o,"tag","cube-calc"),b(o,"css",Xi),b(o,"needsSession",!1);function a(s,l){let u=l.find((c,d)=>l.indexOf(c)!==d);if(u!==void 0)throw new R(y.invalid.duplicate(s,u))}function i(s){let l=F(s,"name"),u=F(s,"label"),c=hr(s,"type",Zi),d=c==="select"?"text":c==="checkbox"?"boolean":c,p=c==="checkbox"?null:qt(s.getAttribute("options"));if(c==="select"&&p===null)throw new R(y.invalid.missing(s.localName,"options"));let f=s.getAttribute("value"),m=f===null?{value:null}:Oe(f,d);return{editor:ve(t,{name:l,label:u,format:d,field:void 0,config:{name:l,label:u,format:d,multiline:!1,options:p,hidden:!1}},"error"in m?f:m.value,!1),format:d,min:Gt(s,"min"),max:Gt(s,"max"),step:Gt(s,"step"),shown:!1}}function r(s){let l=F(s,"name"),u=F(s,"label"),c=hr(s,"format",es),d=s.getAttribute("currency")?.trim().toUpperCase()||"EUR";try{N(0,"currency",{currency:d})}catch{throw new R(y.invalid.value(s.localName,"currency",d))}let p=`cube-result-${++gr}`,f=h(t,"output",{id:p,name:l}),m=s.hasAttribute("emphasis")&&s.getAttribute("emphasis")!=="false",g=h(t,"div",{class:m?"result emphasis":"result"},h(t,"label",{for:p},u),f);return{name:l,format:c,currency:d,element:g,output:f}}return o}var Pe=56,Wt=8,wr=8,ts=24,Qt=7,vr=8;function ns(e,n,t=4){let o=Math.min(e,0),a=Math.max(n,0);if(a<=o)return[0,1];let i=(a-o)/t,r=10**Math.floor(Math.log10(i)),s=i/r,l=(s<=1?1:s<=2?2:s<=5?5:10)*r,u=[];for(let c=Math.floor(o/l);c<=Math.ceil(a/l);c++)u.push(Number((c*l).toPrecision(12)));return u}function rs(e,n,t,o){let a=Math.max(1,Math.floor(t/Qt)),i=n.length<=a?n:`${n.slice(0,a-1)}\u2026`,r=i.length*Qt/2,s=Math.min(Math.max(o.x,o.left+r),o.right-r),l=U(e,"text",{class:"x",x:s,y:o.y},i);return i!==n&&l.append(U(e,"title",{},n)),l}function kr(e,n,t,o){let{width:a,height:i}=t,r=n.points.map(T=>T.value??0),s=ns(Math.min(...r),Math.max(...r)),l=s[0]??0,u=(s.at(-1)??1)-l||1,c=i-wr-ts,d=Math.max(a-Pe-Wt,1),p=n.points.length,f=d/Math.max(p,1),m=T=>wr+c*(1-(T-l)/u),g=T=>Pe+f*(T+.5),w=U(e,"svg",{viewBox:`0 0 ${a} ${i}`,width:"100%",height:i,role:"img","aria-label":`${n.label}, ${y.points(p)}`});for(let T of s)w.append(U(e,"line",{class:"grid",x1:Pe,x2:a-Wt,y1:m(T),y2:m(T)}),U(e,"text",{class:"tick",x:Pe-6,y:m(T)+4},o(T,!0)));let v=n.points.map(T=>T.tick??T.label),k=Math.max(1,...v.map(T=>T.length)),S=n.categories===!0?1:Math.ceil(p/Math.max(1,Math.floor(d/(k*Qt+vr)))),D=n.points.map((T,x)=>x).filter(T=>T%S===0),L=f*S-vr/2;for(let T of D){let x={x:g(T),y:i-6,left:Pe,right:a-Wt};w.append(rs(e,v[T]??"",L,x))}return{root:w,band:f,x:g,y:m,title:T=>U(e,"title",{},`${T.label}: ${T.value===null?y.emptyValue:o(T.value)}`)}}function Sr(e,n,t,o){let{root:a,x:i,y:r,title:s}=kr(e,n,t,o),l="",u="M";return n.points.forEach((c,d)=>{if(c.value===null){u="M";return}l+=`${u}${i(d).toFixed(1)} ${r(c.value).toFixed(1)}`,u="L"}),a.append(U(e,"path",{class:"s1",d:l})),n.points.forEach((c,d)=>{c.value!==null&&a.append(U(e,"circle",{class:"s1",cx:i(d),cy:r(c.value),r:3},s(c)))}),a}function xr(e,n,t,o){let{root:a,band:i,x:r,y:s,title:l}=kr(e,n,t,o),u=i*.7;return n.points.forEach((c,d)=>{let p=s(Math.max(c.value??0,0)),f=s(Math.min(c.value??0,0));a.append(U(e,"rect",{class:"s1",x:r(d)-u/2,y:p,width:u,height:f-p},l(c)))}),a}var Jt=864e5,os=600,is=["line","bar"],ss=`${_}${ge}
|
|
102
|
+
svg{display:block;overflow:visible}
|
|
103
|
+
.grid{stroke:var(--cube-color-border)}
|
|
104
|
+
.tick,.x{font-size:12px;fill:var(--cube-color-text-muted)}
|
|
105
|
+
.tick{text-anchor:end}
|
|
106
|
+
.x{text-anchor:middle}
|
|
107
|
+
rect.s1,circle.s1{fill:var(--cube-color-series-1)}
|
|
108
|
+
path.s1{fill:none;stroke:var(--cube-color-series-1);stroke-width:2}
|
|
109
|
+
`;function as(e,n){let t=e.toISOString().slice(0,10);switch(n){case"day":return t;case"week":{let o=new Date(e.getTime()+(3-(e.getUTCDay()+6)%7)*Jt),a=o.getUTCFullYear(),i=1+Math.floor((o.getTime()-Date.UTC(a,0,1))/(7*Jt));return`${a}-W${String(i).padStart(2,"0")}`}case"month":return t.slice(0,7);case"quarter":return`${t.slice(0,4)}-Q${Math.ceil((e.getUTCMonth()+1)/3)}`;case"year":return t.slice(0,4)}}function ls(e,n){let t=It(e,"month",{short:!0});return n||e.endsWith("-01")?y.monthYear(t,e.slice(0,4)):t}function Tr(e,n,t){let o=new Set,a=Date.parse(`${n}T00:00:00Z`);for(let i=Date.parse(`${e}T00:00:00Z`);i<=a;i+=Jt)o.add(as(new Date(i),t));return[...o]}function Cr(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new K(this));b(this,"plot",h(n.document,"div",{class:"plot"}));b(this,"observer",null);b(this,"observed",0);b(this,"drawn",0);b(this,"drawing",null)}shownFields(){return he(this)}connectedCallback(){super.connectedCallback(),!(this.observer!==null||n.ResizeObserver===void 0)&&(this.observer=new n.ResizeObserver(i=>{let r=Math.round(i.at(-1)?.contentRect.width??0);r<=0||(this.observed=r,r!==this.drawn&&this.draw())}),this.observer.observe(this.plot))}disconnectedCallback(){super.disconnectedCallback(),this.observer?.disconnect(),this.observer=null}async load(i,r){if(r===null)return;let s=F(this,"resource"),l=F(this,"by"),{field:u,truncation:c}=Ze(l),d=J(this,"height",80,240),p=J(this,"limit",1,12),f=await be(this,this.period,i,l);if(f===null)return;let{fn:m,period:g}=f,{data:w}=await dt(r,s,l,f,i);if(i.aborted)return;let v=w.filter(L=>L[l]!==null&&L[l]!==void 0);if(v.length===0){this.showState("empty");return}let k;if(c!==null){let L=new Map(v.map(E=>[String(E[l]),Me(E[m])])),B=g===null?[...L.keys()].sort():Tr(g.from,g.to,c),T=g?.today??g?.to??"",x=g===null||T<g.from?new Set:new Set(Tr(g.from,T<g.to?T:g.to,c));k=B.map((E,O)=>({key:E,label:It(E,c),...c==="month"?{tick:ls(E,O===0)}:{},value:g===null||!x.has(E)?L.get(E)??null:L.get(E)??0}))}else{let L=await pt(this,r,v,{by:l,fn:m},{descending:!0,limit:p},i);if(L===null)return;if(L.length===0){this.showState("empty");return}k=L}let S=this.attr("label")??z(f.field??m),D=this.attr("kind");this.render({label:S,points:k,categories:c===null},d,{line:is.includes(D??"")?D==="line":c!==null,format:ye(this,f.count),byLabel:z(u)})}render(i,r,s){let l=n.document;this.drawing={series:i,height:r,line:s.line,format:s.format};let u=c=>c===null?y.emptyValue:s.format(c);C(this.body),this.body.appendChild(h(l,"div",{class:"card"},this.attr("label")===null?"":h(l,"p",{class:"label","aria-hidden":"true"},i.label),this.plot,h(l,"div",{class:"sr-only"},h(l,"table",{},h(l,"caption",{},y.asTable),h(l,"thead",{},h(l,"tr",{},h(l,"th",{scope:"col"},s.byLabel),h(l,"th",{scope:"col"},i.label))),h(l,"tbody",{},...i.points.map(c=>h(l,"tr",{},h(l,"th",{scope:"row"},c.label),h(l,"td",{},u(c.value))))))))),this.draw()}draw(){if(this.drawing===null)return;let{series:i,height:r,line:s,format:l}=this.drawing,u=this.observed||Math.round(this.plot.clientWidth)||os;this.drawn=u,C(this.plot),this.plot.appendChild((s?Sr:xr)(n.document,i,{width:u,height:r},l))}}return b(t,"tag","cube-chart"),b(t,"css",ss),t}var us=`${_}${we}${ke}
|
|
110
|
+
dl{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.5rem 1rem;margin:0}
|
|
111
|
+
dt{font-weight:600}
|
|
112
|
+
dd{margin:0;min-width:0;overflow-wrap:anywhere}
|
|
113
|
+
`,Ar=e=>e.field!==void 0&&!e.field.readonly;function cs(e,n,t){let o=n===void 0||n===""?null:n;if(o===t||o===null&&t===!1&&e.format==="boolean")return!0;if(o===null||t===null)return!1;if(e.format==="date"&&typeof o=="string"&&typeof t=="string")return o.slice(0,10)===t;if(typeof t=="number"&&typeof o=="string")return Number(o)===t;if(typeof t=="string"&&typeof o=="number")return String(o)===t;if(e.format==="datetime"&&typeof o=="string"&&typeof t=="string"){let a=i=>Math.floor(Date.parse(i)/6e4);return a(o)===a(t)}return typeof o=="object"&&JSON.stringify(o)===JSON.stringify(t)}function Rr(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"status",h(t,"p",{class:"status",role:"status"}));b(this,"loaded",null);b(this,"editing",null);b(this,"attempt",null);b(this,"saved",null);b(this,"edit",null);this.shadowRoot?.appendChild(this.status)}disconnectedCallback(){super.disconnectedCallback(),this.editing=null}refresh(){let r=this.editing;return r!==null&&r.resource===this.attr("resource")?.trim()&&r.id===this.recordId()&&r.user===ae(this.loaded?.session)?Promise.resolve():(this.editing=null,super.refresh())}shownFields(){return this.loaded?.columns.map(r=>r.name)??[]}recordId(){let r=this.attr("record-id")?.trim()??"";return r===""?null:r}async load(r,s){if(s===null)return;this.loaded=null;let l=F(this,"resource"),u=this.recordId(),c=this.saved!==null&&this.saved.resource===l&&this.saved.id===u;if(this.saved=null,c||(this.status.textContent=""),u===null){this.showState("empty",y.chooseRow);return}let d=await s.schema(l);if(r.aborted)return;let p=Y(this.attr("fields")),f=await s.resource(l).get(u,p===null?{}:{fields:p},{signal:r});if(r.aborted)return;let m=f.data,g={session:s,resource:l,id:u,columns:X(d,p,q(this),m),row:m,version:f.recordVersion,canEdit:this.flag("editable")&&this.allowsUpdate(d)};this.loaded=g,this.renderView(g),c&&this.edit?.focus()}allowsUpdate(r){return r!==null&&r.actions.includes("update")}renderView(r){this.edit=r.canEdit&&r.columns.some(Ar)?h(t,"button",{type:"button",onclick:()=>this.startEditing(r)},y.edit):null,C(this.body),this.body.appendChild(h(t,"div",{class:"card"},h(t,"dl",{},...r.columns.flatMap(s=>this.pair(r,s))),this.edit===null?null:h(t,"div",{class:"actions"},this.edit,this.notSaved(r.session))))}pair(r,s){let l=this.exampleField(r.session,r.resource,s.name);return[h(t,"dt",{},s.label,...l?[" ",at(t)]:[]),h(t,"dd",{class:l?"example":null},N(r.row[s.name],s.format))]}startEditing(r){this.editing={resource:r.resource,id:r.id,user:ae(r.session)},this.status.textContent="";let s=[],l=r.columns.map(f=>{if(!Ar(f))return h(t,"dl",{},...this.pair(r,f));let m=ve(t,f,r.row[f.name],f.field?.nullable===!1);return s.push(m),m.element}),u=h(t,"div",{class:"alert",role:"alert",tabindex:"-1",hidden:!0}),c=h(t,"button",{type:"submit"},y.save),d=h(t,"button",{type:"button",class:"secondary",onclick:()=>{this.editing=null,this.attempt=null,this.renderView(r),this.edit?.focus()}},y.cancel),p=h(t,"form",{novalidate:!0},u,...l,h(t,"div",{class:"actions"},c,d,this.notSaved(r.session)));p.addEventListener("submit",f=>{f.preventDefault(),this.save(r,s,{alert:u,save:c,cancel:d})}),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},p)),s[0]?.element.querySelector("input,select,textarea")?.focus()}async save(r,s,l){if(l.save.disabled)return;let u={},c=!1;for(let f of s){let m=f.read(),g=r.columns.find(w=>w.name===f.name);if("error"in m){f.setError(m.error),c=!0;continue}f.setError(null),cs(g,r.row[f.name],m.value)||(u[f.name]=m.value)}if(c){_e(t,l.alert,y.formInvalid);return}if(Object.keys(u).length===0){this.editing=null,this.renderView(r),this.edit?.focus();return}let d=JSON.stringify([r.resource,r.id,u]);this.attempt=Se(this.attempt,d);let p={idempotencyKey:this.attempt.key};r.version!==null&&(p.ifMatch=r.version),l.save.disabled=!0,l.cancel.disabled=!0,l.alert.hidden=!0;try{let f=await this.session();if(this.editing!==null&&this.editing.user!==ae(f)){this.editing=null,this.refresh();return}let m=await f.resource(r.resource).update(r.id,u,p);this.attempt=null;let g=m.data;if(this.loaded===r&&this.editing!==null){this.editing=null;let w={...r.row,...u,...g},v={...r,row:w,version:m.recordVersion};this.loaded=v,this.saved={resource:r.resource,id:r.id},this.renderView(v),this.status.textContent=y.saved,this.edit?.focus()}this.emit("cube-saved",{resource:r.resource,id:g.id??r.id,row:g}),this.emit("cube-data-change",{resource:r.resource})}catch(f){if(this.loaded!==r||this.editing===null)return;l.cancel.disabled=!1,this.failed(f,s,l)}}failed(r,s,l){if(P(r)&&(this.attempt=null),P(r)&&(r.status===409||r.status===412)){let u=h(t,"button",{type:"button",class:"secondary",onclick:()=>{this.editing=null,this.refresh()}},y.reload);_e(t,l.alert,y.conflict,u);return}l.save.disabled=!1,ft(t,l.alert,r,s,u=>Fe(q(this),u))}}return b(o,"tag","cube-detail"),b(o,"css",us),o}var ds=`${_}${we}${ke}`,ps=["resource","fields","submit-label","success-text"];function Dr(e,n){let t=n.document;class o extends e{constructor(){super();b(this,"status",h(t,"p",{class:"status",role:"status"}));b(this,"drawn",null);b(this,"shown",null);b(this,"attempt",null);this.shadowRoot?.appendChild(this.status)}shownFields(){return this.drawn?.columns.map(r=>r.name)??[]}key(){let r=this.drawn?.session.user()?.id??null;return JSON.stringify([...ps.map(s=>this.attr(s)),r])}text(r,s){let l=this.attr(r)?.trim()??"";return l===""?s:l}refresh(){return this.shown===this.key()?Promise.resolve():(this.shown=null,super.refresh())}async load(r,s){if(s===null)return;this.drawn=null,this.attempt=null;let l=F(this,"resource"),u=await s.schema(l);if(r.aborted)return;if(u===null||!u.actions.includes("create")){this.showState({kind:"forbidden",detail:null,retry:!1});return}let c=u.fields.filter(m=>!m.readonly&&m.name!=="id"),p=(Y(this.attr("fields"))??c.map(m=>m.name)).filter(m=>c.some(g=>g.name===m)),f=X(u,p,q(this));if(f.length===0){this.showState({kind:"error",detail:y.noWritableFields,retry:!1});return}this.drawn={session:s,resource:l,columns:f},this.shown=this.key(),this.renderForm(!1)}renderForm(r){let s=this.drawn;this.status.textContent="";let l=s.columns.map(p=>ve(t,p,null,p.field?.nullable===!1&&p.format!=="boolean")),u=h(t,"div",{class:"alert",role:"alert",tabindex:"-1",hidden:!0}),c=h(t,"button",{type:"submit"},this.text("submit-label",y.save)),d=h(t,"form",{novalidate:!0},u,...l.map(p=>p.element),h(t,"div",{class:"actions"},c,this.notSaved(s.session)));d.addEventListener("submit",p=>{p.preventDefault(),this.submit(s,l,u,c)}),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},d)),r&&Er(l[0])?.focus()}async submit(r,s,l,u){if(u.disabled)return;let c={},d=null;for(let f of s){let m=f.read();f.setError("error"in m?m.error:null),"error"in m?d??(d=f):m.value!==null&&(c[f.name]=m.value)}if(d!==null){l.hidden=!0,Er(d)?.focus();return}this.attempt=Se(this.attempt,JSON.stringify([r.resource,c]));let p=this.attempt.key;u.disabled=!0,l.hidden=!0;try{let m=await(await this.session()).resource(r.resource).create(c,{idempotencyKey:p});this.attempt=null;let g=m.data;this.drawn===r&&this.done(),this.emit("cube-created",{resource:r.resource,row:g}),this.emit("cube-data-change",{resource:r.resource})}catch(f){if(P(f)&&(this.attempt=null),this.drawn!==r)return;u.disabled=!1,ft(t,l,f,s,m=>Fe(q(this),m))}}done(){let r=h(t,"button",{type:"button",onclick:()=>this.renderForm(!0)},y.another);C(this.body);let s=this.drawn===null?null:this.notSaved(this.drawn.session);this.body.appendChild(h(t,"div",{class:"card"},h(t,"div",{class:"actions"},r,s))),this.status.textContent=this.text("success-text",y.formSaved),n.setTimeout(()=>{r.isConnected&&r.focus()},0)}}return b(o,"tag","cube-form"),b(o,"css",ds),o}function Er(e){return e?.element.querySelector("input,select,textarea")??null}var ms=`${_}
|
|
114
|
+
ul{list-style:none;margin:0;padding:0;display:grid;gap:.75rem}
|
|
115
|
+
h3{margin:0 0 .5rem;font-size:1rem;overflow-wrap:anywhere}
|
|
116
|
+
dl{margin:0;display:grid;gap:.375rem}
|
|
117
|
+
dl div{display:flex;flex-wrap:wrap;gap:0 .75rem}
|
|
118
|
+
dt{flex:0 0 8rem;font-weight:600}
|
|
119
|
+
dd{flex:1 1 12rem;margin:0;min-width:0;overflow-wrap:break-word}
|
|
120
|
+
p{margin:0}
|
|
121
|
+
`;function Mr(e,n){let t=n.document;class o extends e{async load(i,r){if(r===null||i.aborted)return;let s=this.attr("scherm")?.trim()??"",l=(r.gaps??[]).filter(c=>s===""||c.scherm===s),u=(c,d)=>h(t,"div",{},h(t,"dt",{},c),h(t,"dd",{},d));C(this.body),this.body.appendChild(l.length===0?h(t,"div",{class:"card"},h(t,"p",{},y.gaps.none)):h(t,"ul",{role:"list","aria-label":y.gaps.what},...l.map(c=>h(t,"li",{class:"card"},h(t,"h3",{},c.veld===void 0?c.resource:`${c.resource}.${c.veld}`),h(t,"dl",{},u(y.gaps.screen,c.scherm),u(y.gaps.type,c.type==="keuze"?`${y.gaps.types.keuze}: ${(c.waarden??[]).join(", ")}`:y.gaps.types[c.type]),u(y.gaps.why,c.reden))))))}}return b(o,"tag","cube-gap-list"),b(o,"css",ms),o}var Lr=new Intl.NumberFormat("nl-NL",{minimumFractionDigits:1,maximumFractionDigits:1}),fs=`${_}
|
|
122
|
+
.kpi{display:flex;flex-direction:column;gap:.25rem}
|
|
123
|
+
.label{margin:0;font-size:.875rem;font-weight:600;color:var(--cube-color-text-muted)}
|
|
124
|
+
.value{margin:0;font-size:2rem;font-weight:700;line-height:1.2;overflow-wrap:anywhere}
|
|
125
|
+
.compare{margin:0;font-size:.875rem;color:var(--cube-color-text-muted)}
|
|
126
|
+
.compare.up{color:var(--cube-color-success)}
|
|
127
|
+
.compare.down{color:var(--cube-color-danger)}
|
|
128
|
+
`;function Fr(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new K(this))}shownFields(){return he(this)}async load(i,r){if(r===null)return;let s=F(this,"resource");if(this.flag("compare")&&!this.attr("period"))throw new R(y.invalid.compare(this.localName));let l=await be(this,this.period,i);if(l===null)return;let{fn:u,period:c}=l,d=r.resource(s),p=async w=>{let{data:v}=await d.aggregate({fn:u,filter:l.filterFor(w)},{signal:i});return Me(v[0]?.[u])},f=this.flag("compare")?c?.previous??null:null,[m,g]=await Promise.all([p(c),f===null?null:p(f)]);i.aborted||this.render(m,f===null?void 0:g,l.count)}render(i,r,s){let l=n.document,u=ye(this,s),c=this.attr("label"),d=i===null?h(l,"p",{class:"value"},h(l,"span",{"aria-hidden":"true"},y.emptyValue),h(l,"span",{class:"sr-only"},y.noData)):h(l,"p",{class:"value"},h(l,"data",{value:String(i)},u(i)));C(this.body),this.body.appendChild(h(l,"div",{class:"card kpi"},c===null||c===""?null:h(l,"p",{class:"label"},c),d,r===void 0||i===null?null:this.compareLine(i,r)))}compareLine(i,r){let s=n.document;if(r===null||r===0)return h(s,"p",{class:"compare new"},y.newValue);let l=(i-r)/Math.abs(r),u=Lr.format(Math.abs(l)*100);if(u===Lr.format(0))return h(s,"p",{class:"compare same"},`${u}% ${y.comparedTo}`);let c=l>0;return h(s,"p",{class:c?"compare up":"compare down",role:"img","aria-label":y.change(u,c?y.higher:y.lower)},`${c?"\u25B2":"\u25BC"} ${u}% ${y.comparedTo}`)}}return b(t,"tag","cube-kpi"),b(t,"css",fs),t}var gs=864e5;function ne(e,n,t){let o=new Date(2e3,0,1);return o.setFullYear(e,n,t),o}function bt(e,n){return{from:I(e),to:I(n)}}function ht(e,n,t){let o=e.getFullYear(),a=e.getMonth()+n;return bt(ne(o,a,1),ne(o,a+t,0))}function hs(e,n){return Math.round((Date.UTC(n.getFullYear(),n.getMonth(),n.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()))/gs)+1}function Yt(e,n,t){switch(e){case"this-month":return{key:e,...ht(n,0,1),previous:ht(n,-1,1)};case"12m":return{key:e,...ht(n,-11,12),previous:ht(n,-23,12)};case"this-year":{let o=n.getFullYear();return{key:e,...bt(ne(o,0,1),ne(o,11,31)),previous:bt(ne(o-1,0,1),ne(o-1,11,31))}}case"custom":{let o=t===void 0?null:j(t.from),a=t===void 0?null:j(t.to);if(t===void 0||o===null||a===null||a<o)throw new TypeError("A custom period needs a valid from and to, from not after to.");let i=hs(o,a);return{key:e,from:t.from,to:t.to,previous:bt(ne(o.getFullYear(),o.getMonth(),o.getDate()-i),ne(o.getFullYear(),o.getMonth(),o.getDate()-1))}}}}var Xt=["this-month","12m","this-year","custom"],Or="12m",bs=`
|
|
129
|
+
.picker{display:flex;flex-wrap:wrap;align-items:flex-end;gap:.75rem}
|
|
130
|
+
.field{display:flex;flex-direction:column;gap:.25rem;min-width:0}
|
|
131
|
+
label{font-weight:600;font-size:.875rem}
|
|
132
|
+
.custom{display:flex;flex-wrap:wrap;gap:.75rem}
|
|
133
|
+
.custom[hidden]{display:none}
|
|
134
|
+
.custom .error{flex-basis:100%;margin:0;font-weight:600;color:var(--cube-color-danger)}
|
|
135
|
+
.custom .error:empty{flex-basis:0}
|
|
136
|
+
input[aria-invalid=true]{border:2px solid var(--cube-color-danger)}
|
|
137
|
+
@media (max-width:640px){.picker,.custom{flex-direction:column;align-items:stretch}}
|
|
138
|
+
`;function _r(e,n,t,o){return h(e,"div",{class:"field"},h(e,"label",{for:n},t),o)}function $r(e,n){class t extends e{constructor(){super();b(this,"select");b(this,"label");b(this,"custom");b(this,"from");b(this,"to");b(this,"error");b(this,"chosen",null);b(this,"range",null);b(this,"announced",null);let i=n.document;this.select=h(i,"select",{id:"period",onchange:()=>this.onSelect()},...Xt.map(l=>h(i,"option",{value:l},y.period[l]))),this.label=h(i,"label",{for:"period"});let r=l=>h(i,"input",{type:"date",id:l,onchange:()=>this.onDates()});this.from=r("from"),this.to=r("to"),this.error=h(i,"p",{id:"range-error",class:"error","aria-live":"polite"}),this.custom=h(i,"div",{class:"custom",hidden:!0},_r(i,"from",y.period.from,this.from),_r(i,"to",y.period.to,this.to),this.error);let s=h(i,"div",{class:"field"},this.label,this.select);this.body.appendChild(h(i,"div",{class:"picker"},s,this.custom))}get value(){let i=this.key(),r=this.today();return{...i==="custom"&&this.range!==null?Yt("custom",r,this.range):Yt(i==="custom"?Or:i,r),today:I(r)}}refresh(){return this.render(),this.changed(),Promise.resolve()}async load(){this.render()}showState(){this.render()}key(){if(this.chosen!==null)return this.chosen;let i=this.attr("default");return Xt.includes(i)?i:Or}today(){let i=this.attr("today");return(i===null?null:j(i))??new Date}render(){let i=this.key();this.label.textContent=this.attr("label")??y.period.label,this.select.value=i,this.custom.hidden=i!=="custom",i==="custom"&&this.range===null&&this.fillDates()}fillDates(){let{from:i,to:r}=this.value;this.range={from:i,to:r},this.from.value=i,this.to.value=r,this.explain(null)}onSelect(){let i=this.select.value;Xt.includes(i)&&(i==="custom"&&this.key()!=="custom"&&(this.range=null,this.fillDates()),this.chosen=i,this.render(),this.changed())}onDates(){let i={from:this.from.value,to:this.to.value},r=j(i.from),s=j(i.to);if(r===null||s===null){this.explain(y.period.incompleteDate);return}if(s<r){this.explain(y.period.invalidRange);return}this.explain(null),this.range=i,this.changed()}changed(){let i=this.value,r=JSON.stringify(i),s=this.announced;this.announced=r,s!==null&&s!==r&&this.emit("cube-change",i)}explain(i){this.error.textContent=i??"";for(let r of[this.from,this.to])i===null?(r.removeAttribute("aria-invalid"),r.removeAttribute("aria-describedby")):(r.setAttribute("aria-invalid","true"),r.setAttribute("aria-describedby",this.error.id))}}return b(t,"tag","cube-period-picker"),b(t,"css",bs),b(t,"needsSession",!1),t}var ys=["loading","empty","error","forbidden","signed-out"],ws={loading:y.loading,empty:y.empty,error:y.error,forbidden:y.forbidden,"signed-out":y.signedOut},vs=`
|
|
139
|
+
.state{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:1rem;border:1px solid var(--cube-color-border);
|
|
140
|
+
border-radius:var(--cube-radius);background:var(--cube-color-surface)}
|
|
141
|
+
.state[data-kind=error]{border-left:4px solid var(--cube-color-danger)}
|
|
142
|
+
.state[data-kind=forbidden],.state[data-kind=signed-out]{border-left:4px solid var(--cube-color-warning)}
|
|
143
|
+
.state p{margin:0;flex:1 1 12rem}
|
|
144
|
+
.state[data-kind=loading] p,.state[data-kind=empty] p{color:var(--cube-color-text-muted)}
|
|
145
|
+
`,Pr=["error","forbidden","signed-out"],yt=new WeakMap;function Nr(e,n){class t extends e{constructor(){super();b(this,"failed",!1);b(this,"kind","loading");b(this,"region");b(this,"message");b(this,"action",null);b(this,"announce",null);this.message=h(n.document,"p"),this.region=h(n.document,"div",{class:"state"},this.message)}disconnectedCallback(){super.disconnectedCallback(),yt.get(this.ownerDocument)===this&&yt.delete(this.ownerDocument),this.announce!==null&&n.clearTimeout(this.announce),this.announce=null}refresh(){return this.failed=!1,this.render(),Promise.resolve()}async load(){this.render()}showState(){this.render()}render(){let i=this.attr("kind"),r=this.failed?"error":ys.includes(i)?i:"loading",s=this.ownerDocument;this.kind=r;let l=Pr.includes(r)&&this.claimAlert();this.action?.remove(),this.action=null,r==="signed-out"?this.action=h(s,"button",{type:"button",onclick:()=>{this.signIn()}},y.signIn):r==="error"&&(this.failed||this.attr("retry")!=="false")&&(this.action=h(s,"button",{type:"button",class:"secondary",onclick:()=>{this.emit("cube-retry")}},y.retry)),this.region.setAttribute("data-kind",r),r==="loading"?this.region.removeAttribute("role"):this.region.setAttribute("role",l?"alert":"status"),l?this.region.removeAttribute("aria-live"):this.region.setAttribute("aria-live",r==="loading"?"off":"polite"),this.action!==null&&this.region.appendChild(this.action),this.region.parentNode!==this.body&&(C(this.body),this.body.appendChild(this.region));let u=this.failed?y.error:this.attr("message")??ws[r];if(this.announce!==null&&n.clearTimeout(this.announce),this.announce=null,this.message.textContent!==u){if(r==="loading"){this.message.textContent=u;return}this.message.textContent="",this.announce=n.setTimeout(()=>{this.announce=null,this.message.textContent=u},0)}}claimAlert(){let i=this.ownerDocument,r=yt.get(i);return r!==void 0&&r!==this&&r.isConnected&&Pr.includes(r.kind)?!1:(yt.set(i,this),!0)}async signIn(){try{await(await this.session()).signIn()}catch{this.failed=!0,this.render();return}let i=this.ownerDocument.defaultView?.CustomEvent??CustomEvent;this.ownerDocument.dispatchEvent(new i("cube-session-change"))}}return b(t,"tag","cube-state"),b(t,"css",vs),b(t,"needsSession",!1),t}var ks=/^[=+\-@\t\r]/,Ss=/[;"\r\n]/;function jr(e,n){if(e==null)return"";let t=ee.includes(n)?se(e):null,o;return t!==null?o=(String(t).includes("e")?t.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20}):String(t)).replace(".",","):(typeof e=="boolean"?o=e?y.yes.toLowerCase():y.no.toLowerCase():typeof e=="object"?o=JSON.stringify(e):o=String(e),ks.test(o)&&(o=`'${o}`)),Ss.test(o)?`"${o.replace(/"/g,'""')}"`:o}function Ir(e,n){return`\uFEFF${[e.map(o=>jr(o.label,"text")),...n.map(o=>e.map(a=>jr(o[a.name],a.format)))].map(o=>`${o.join(";")}\r
|
|
146
|
+
`).join("")}`}function Br(e,n,t){let o=e.defaultView,a=new(o?.Blob??Blob)([t],{type:"text/csv;charset=utf-8"}),i=(o?.URL??URL).createObjectURL(a),r=h(e,"a",{href:i,download:n,hidden:!0});e.body.appendChild(r),r.click(),r.remove(),(o?.setTimeout??setTimeout)(()=>(o?.URL??URL).revokeObjectURL(i),0)}var xs=`${_}
|
|
147
|
+
.tools{display:flex;flex-wrap:wrap;align-items:flex-end;gap:.75rem;margin-bottom:.75rem}
|
|
148
|
+
.control{display:flex;flex-direction:column;gap:.25rem;min-width:0;max-width:100%}
|
|
149
|
+
.control>label,legend{font-weight:600}
|
|
150
|
+
fieldset{display:flex;flex-wrap:wrap;gap:.5rem;min-width:0;margin:0;padding:0;border:0}
|
|
151
|
+
fieldset legend{padding:0;margin-bottom:.25rem}
|
|
152
|
+
fieldset.control{flex-direction:row;align-items:flex-end}
|
|
153
|
+
.scroll{position:relative;overflow-x:auto;max-width:100%}
|
|
154
|
+
table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}
|
|
155
|
+
th,td{padding:.5rem .75rem;text-align:start;border-bottom:1px solid var(--cube-color-border)}
|
|
156
|
+
th{font-weight:600;white-space:nowrap}
|
|
157
|
+
th button{min-height:auto;padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:600}
|
|
158
|
+
th button:hover{background:none;text-decoration:underline}
|
|
159
|
+
th[aria-sort=ascending] .arrow::after{content:" \u25B2"}
|
|
160
|
+
th[aria-sort=descending] .arrow::after{content:" \u25BC"}
|
|
161
|
+
.num{text-align:end;white-space:nowrap}
|
|
162
|
+
tbody tr{cursor:pointer}
|
|
163
|
+
tbody tr:hover{background:var(--cube-color-primary-subtle)}
|
|
164
|
+
tbody tr:focus-visible{outline:3px solid var(--cube-color-focus);outline-offset:-3px}
|
|
165
|
+
tbody tr.chosen{background:var(--cube-color-primary-subtle);box-shadow:inset 4px 0 0 var(--cube-color-primary)}
|
|
166
|
+
.pager{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.75rem}
|
|
167
|
+
.pager p,.export-status{margin:0;color:var(--cube-color-text-muted)}
|
|
168
|
+
.pager p{margin-inline-end:auto}
|
|
169
|
+
`,wt=ee,Ur=200,Ts=50,Cs=300,Hr=" search";function As(e){let n=j(e.slice(0,10));return n===null?null:(n.setDate(n.getDate()+1),I(n))}var le=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function zr(e,n,t){let o=e[n];e[n]=le(o)&&le(t)?{...o,...t}:t}function Rs(e,n){let t=se(e),o=se(n);if(t!==null&&o!==null)return Math.sign(t-o);let a=String(e),i=String(n);return a<i?-1:a>i?1:0}function Vr(e){return e!==void 0&&(!le(e)||"ilike"in e)}function Es(e,n){if(!le(e)||!le(n))return e;let t={...n,...e};for(let[o,a]of[["gte",1],["gt",1],["lte",-1],["lt",-1]]){let i=e[o],r=n[o];i!=null&&r!==void 0&&r!==null&&(t[o]=Rs(r,i)===a?r:i)}return t}function Kr(e,n){let t=n.document;class o extends e{constructor(){super(...arguments);b(this,"period",new K(this));b(this,"context",null);b(this,"parts",new Map);b(this,"values",new Map);b(this,"sortBy",null);b(this,"page",1);b(this,"requests",0);b(this,"rowsController",null);b(this,"debounce",null);b(this,"exporting",null);b(this,"headers",new Map);b(this,"frame",null);b(this,"table",null);b(this,"pagerText",null);b(this,"previous",null);b(this,"next",null);b(this,"pager",null);b(this,"exportButton",null);b(this,"exportStatus",null);b(this,"shownResource",null);b(this,"chosen",null);b(this,"shownIds",null);b(this,"updates",0);b(this,"warned",new Set)}shownFields(){return this.context?.columns.map(r=>r.name)??[]}disconnectedCallback(){super.disconnectedCallback(),this.stopDebounce(),this.rowsController?.abort(),this.exporting?.abort(),this.exporting=null}async load(r,s){if(s===null)return;this.stopDebounce(),this.context=null,this.rowsController?.abort();let l=F(this,"resource");++this.updates,l!==this.shownResource&&(this.values.clear(),this.sortBy=null,this.page=1,this.chosen=null,this.shownIds=null,this.shownResource=l),this.detailTarget();let u=this.attr("period"),c=u===null||u===""?null:ct(this.attr("date-field"),null,this.localName),d=fe(this),p=await ut(this,u);if(r.aborted)return;this.period.follow(p);let f=p===null||c===null?d:{...d,...lt(c,p.value)},m=await s.schema(l);if(r.aborted)return;let g=Y(this.attr("fields")),w=m===null||m.fields.some(O=>O.name==="id"),v={session:s,resource:l,columns:[],base:f,fields:g===null?void 0:[...new Set([...w?["id"]:[],...g])],size:Math.min(J(this,"page-size",1,25),Ur)};this.exporting?.abort(),this.exporting=null,r.addEventListener("abort",()=>this.rowsController?.abort(),{once:!0});let k=Y(this.attr("filters"))??[];this.checkFilterable(m,k);let S=k.filter(O=>!(O in d)||le(d[O]));for(let O of[...this.parts.keys()])S.includes(O)||this.parts.delete(O);let D=q(this);this.context=v;let L=await this.fetchRows(v,this.query(v,v.size,this.page)),B=L===null?null:await this.lastPageIfPast(v,L);if(B===null||r.aborted)return;let T=B.data[0];v.columns=X(m,g,D,T);let x=new Map([...D].map(([O,G])=>[O,{...G,hidden:!1}])),E=X(m,S,x,T);this.build(v,m,E),this.renderRows(v,B)}checkFilterable(r,s){if(r===null)return;let l=this.attr("search")?.trim()??"",u=s.map(c=>["filters",c]);l!==""&&u.push(["search",l]);for(let[c,d]of u)if(!r.filterable.includes(d))throw new R(y.invalid.notFilterable(this.localName,c,d))}detailTarget(){let r=this.attr("detail")?.trim()??"";if(r==="")return null;try{return t.querySelector(r)}catch{throw new R(y.invalid.selector(this.localName,"detail",r))}}query(r,s,l){let u={},c=this.attr("search")?.trim()??"",d=this.values.get(Hr)?.trim()??"";c!==""&&d!==""&&zr(u,c,{ilike:`%${d}%`});for(let[g,w]of this.parts){let v=w();v!==null&&zr(u,g,v)}let p={...r.base};for(let[g,w]of Object.entries(u)){let v=p[g];p[g]=v===void 0?w:Es(v,w)}let f=this.sortBy??(this.attr("sort")?.trim()||null),m={filter:p,page:{size:s,number:l}};return f!==null&&(m.sort=f),r.fields!==void 0&&(m.fields=r.fields),m}async fetchRows(r,s){let l=++this.requests;this.rowsController?.abort();let u=new AbortController;this.rowsController=u,this.setAttribute("aria-busy","true");try{let c=await r.session.resource(r.resource).list(s,{signal:u.signal});return l===this.requests&&!u.signal.aborted?c:null}finally{l===this.requests&&this.removeAttribute("aria-busy")}}async lastPageIfPast(r,s){let l=s.meta.page;return s.data.length>0||this.page<=1||l===void 0||l===null||l.total===0?s:(this.page=Math.max(1,l.pages),this.fetchRows(r,this.query(r,r.size,this.page)))}async update(r){let s=this.context;if(s===null||!this.isConnected)return;r&&(this.page=1);let l=++this.updates;try{let u=await this.fetchRows(s,this.query(s,s.size,this.page)),c=u===null?null:await this.lastPageIfPast(s,u);c!==null&&this.renderRows(s,c)}catch(u){if(l!==this.updates||u?.name==="AbortError")return;this.showRowsState(te(u))}}later(r){this.stopDebounce(),this.debounce=n.setTimeout(()=>{this.debounce=null,this.update(r)},Cs)}stopDebounce(){this.debounce!==null&&n.clearTimeout(this.debounce),this.debounce=null}build(r,s,l){this.parts=new Map;let u=[],c=this.attr("search")?.trim()??"";if(c!==""){Vr(r.base[c])&&this.warnFixed("search",c);let p=h(t,"input",{type:"search"});u.push(this.control(p,Hr,y.search,!0))}for(let p of l)u.push(this.filterControl(p,r.base[p.name]));this.flag("export")?(this.exportButton=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.toggleExport()},y.exportCsv),this.exportStatus=h(t,"p",{class:"export-status",role:"status"}),u.push(this.exportButton,this.exportStatus)):(this.exportButton=null,this.exportStatus=null),this.headers=new Map,this.frame=h(t,"div",{class:"scroll"}),this.pagerText=h(t,"p",{"aria-live":"polite"}),this.previous=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.go(-1)},y.previous),this.next=h(t,"button",{type:"button",class:"secondary",onclick:()=>this.go(1)},y.next),this.pager=h(t,"div",{class:"pager"},this.pagerText,this.previous,this.next);let d=h(t,"thead",{},h(t,"tr",{},...r.columns.map(p=>{let f=s?.sortable.includes(p.name)===!0,m=h(t,"th",{scope:"col",class:wt.includes(p.format)?"num":null},f?h(t,"button",{type:"button",onclick:()=>this.sortOn(p.name)},p.label,h(t,"span",{class:"arrow","aria-hidden":"true"})):p.label,...this.exampleField(r.session,r.resource,p.name)?[" ",at(t)]:[]);return f&&this.headers.set(p.name,m),m})));this.table=h(t,"table",{},h(t,"caption",{class:"sr-only"},z(r.resource)),d,h(t,"tbody")),this.markSort(),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},u.length>0?h(t,"div",{class:"tools"},...u):null,this.frame,this.pager))}control(r,s,l,u,c){let d=`cube-table-${++Ds}`;return r.id=d,r.value=this.values.get(s)??"",c?.(r),r.addEventListener(u?"input":"change",()=>{this.values.set(s,r.value),c?.(r),u?this.later(!0):this.update(!0)}),h(t,"div",{class:"control"},h(t,"label",{for:d},l),r)}warnFixed(r,s){let u=`${this.localName}: filter already fixes "${s}", so ${r} on it changes nothing.`;this.warned.has(u)||(this.warned.add(u),console.warn(u))}filterControl(r,s){let l=r.name,u=v=>this.values.get(v)?.trim()??"",c=mt(r),d=c===null&&r.format==="boolean";if(c!==null||d){le(s)&&this.warnFixed("filters",l);let v=c??[{value:"true",label:y.yes},{value:"false",label:y.no}],k=h(t,"select",{},h(t,"option",{value:""},y.all),...v.map(D=>h(t,"option",{value:D.value},D.label))),S=wt.includes(r.format);return this.parts.set(l,()=>{let D=u(l);return D===""?null:d?D==="true":S?se(D)??D:D}),this.control(k,l,r.label,!1)}let p=r.format==="date"||r.format==="datetime";if(!p&&!wt.includes(r.format))return Vr(s)&&this.warnFixed("filters",l),this.parts.set(l,()=>u(l)===""?null:{ilike:`%${u(l)}%`}),this.control(h(t,"input",{type:"text"}),l,r.label,!0);let f=v=>{let k=Oe(u(v),r.format);return"value"in k&&typeof k.value=="number"?k.value:null},m=v=>k=>{u(v)!==""&&f(v)===null?k.setAttribute("aria-invalid","true"):k.removeAttribute("aria-invalid")},g=v=>{let k=`${l}:${v}`,S=h(t,"input",{type:p?"date":"text",inputmode:p?null:"decimal","aria-label":`${y[v]} (${r.label})`});return this.control(S,k,y[v],!p,p?void 0:m(k))};this.parts.set(l,()=>{let v={},k=p?u(`${l}:min`)||null:f(`${l}:min`),S=p?As(u(`${l}:max`)):f(`${l}:max`);return k!==null&&(v.gte=k),S!==null&&(v[p?"lt":"lte"]=S),Object.keys(v).length>0?v:null});let w=h(t,"legend",{},r.label);return h(t,"fieldset",{class:"control"},w,g("min"),g("max"))}sortOn(r){let s=this.sortBy??(this.attr("sort")?.trim()||null);this.sortBy=s===r?`-${r}`:r,this.markSort(),this.update(!0)}markSort(){let r=this.sortBy??(this.attr("sort")?.trim()||""),s=r.replace(/^-/,"");for(let[l,u]of this.headers)l===s?u.setAttribute("aria-sort",r.startsWith("-")?"descending":"ascending"):u.removeAttribute("aria-sort")}go(r){this.page=Math.max(1,this.page+r),this.update(!1)}renderRows(r,s){let l=this.frame,u=this.table;if(l===null||u===null)return;let c=s.meta.page,d=c?.total??s.data.length,p=Math.max(1,c?.pages??1);this.page=c?.number??this.page,C(l);let f=JSON.stringify(s.data.map(g=>g.id??null));if(f!==this.shownIds&&(this.chosen=null),this.shownIds=f,s.data.length===0){this.showRowsState({kind:"empty",detail:null});return}let m=h(t,"tbody",{},...s.data.map(g=>this.row(r,g)));m.querySelector('tr[tabindex="0"]')===null&&m.firstElementChild?.setAttribute("tabindex","0"),u.replaceChild(m,u.querySelector("tbody")),l.appendChild(u),this.pager!==null&&(this.pager.hidden=!1),this.pagerText!==null&&(this.pagerText.textContent=y.pageOf(this.page,p,d)),this.previous!==null&&(this.previous.disabled=this.page<=1),this.next!==null&&(this.next.disabled=this.page>=p)}showRowsState(r){this.frame!==null&&(C(this.frame),this.frame.appendChild(h(t,"cube-state",{kind:r.kind,message:r.detail,retry:r.retry===!1?"false":null})),this.pager!==null&&(this.pager.hidden=!0))}row(r,s){let l=()=>this.select(r,s,d),u=p=>this.exampleField(r.session,r.resource,p.name),c=this.chosen!==null&&String(s.id??"")===this.chosen,d=h(t,"tr",{tabindex:c?"0":"-1",class:c?"chosen":null,"aria-current":c?"true":null,onclick:l,onkeydown:(p=>{if(p.altKey||p.ctrlKey||p.metaKey)return;if(p.key==="Enter"||p.key===" "){p.preventDefault(),l();return}let f=this.rowFor(d,p.key);f!==void 0&&(p.preventDefault(),f!==null&&(d.setAttribute("tabindex","-1"),f.setAttribute("tabindex","0"),f.focus()))})},...r.columns.map(p=>{let f=[wt.includes(p.format)&&"num",u(p)&&"example"];return h(t,"td",{class:f.filter(Boolean).join(" ")||null},N(s[p.name],p.format))}));return d}rowFor(r,s){let l=r.parentElement;switch(s){case"ArrowDown":return r.nextElementSibling;case"ArrowUp":return r.previousElementSibling;case"Home":return l?.firstElementChild;case"End":return l?.lastElementChild;default:return}}select(r,s,l){let u=s.id??null;this.chosen=u===null?null:String(u);for(let d of Array.from(l.parentElement?.children??[]))d.classList.toggle("chosen",d===l),d.setAttribute("tabindex",d===l?"0":"-1"),d===l?d.setAttribute("aria-current","true"):d.removeAttribute("aria-current");if(this.emit("cube-select",{resource:r.resource,id:u,row:s}),u===null)return;let c=null;try{c=this.detailTarget()}catch(d){this.showState(te(d));return}c?.setAttribute("record-id",String(u))}toggleExport(){if(this.exporting!==null){this.exporting.abort(),this.exporting=null,this.exportButton!==null&&(this.exportButton.textContent=y.exportCsv),this.exportStatus!==null&&(this.exportStatus.textContent="");return}this.runExport()}async runExport(){let r=this.context,s=this.exportButton,l=this.exportStatus;if(r===null||s===null||l===null)return;let u=new AbortController;this.exporting=u;let{signal:c}=u;s.textContent=y.cancel,l.textContent=y.exporting(0);let d=[],p="";try{let f=0,m=this.query(r,Ur,1);for await(let g of r.session.resource(r.resource).pages(m,{signal:c}))if(c.aborted||(d.push(...g.data),l.textContent=y.exporting(d.length),++f>=Ts))break;c.aborted||Br(t,`${r.resource}-${I(new Date)}.csv`,Ir(r.columns,d))}catch(f){!c.aborted&&f?.name!=="AbortError"&&(p=y.exportFailed)}finally{this.exporting===u&&(this.exporting=null,s.textContent=y.exportCsv,l.textContent=p)}}}return b(o,"tag","cube-table"),b(o,"css",xs),o}var Ds=0;var Ms=`${_}${ge}
|
|
170
|
+
ol{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:.25rem}
|
|
171
|
+
button{display:grid;grid-template-columns:1fr auto;gap:.125rem .75rem;width:100%;padding:.5rem .75rem;
|
|
172
|
+
border:0;border-radius:var(--cube-radius);background:none;color:inherit;font:inherit;text-align:start;cursor:pointer}
|
|
173
|
+
button:hover{background:var(--cube-color-primary-subtle)}
|
|
174
|
+
button:focus-visible{outline:2px solid var(--cube-color-focus);outline-offset:2px}
|
|
175
|
+
.name{overflow-wrap:anywhere}
|
|
176
|
+
.value{font-weight:600;font-variant-numeric:tabular-nums}
|
|
177
|
+
svg{grid-column:1/-1;display:block;width:100%;height:.5rem}
|
|
178
|
+
rect.bar{fill:var(--cube-color-series-1)}
|
|
179
|
+
.note{margin:.5rem 0 0;font-size:.875rem;color:var(--cube-color-text-muted)}
|
|
180
|
+
`;function qr(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new K(this))}shownFields(){return he(this)}async load(i,r){if(r===null)return;let s=F(this,"resource"),l=F(this,"by"),u=J(this,"limit",1,5),c=await be(this,this.period,i,l);if(c===null)return;let{data:d,meta:p}=await dt(r,s,l,c,i);if(i.aborted)return;let f={descending:this.attr("order")!=="asc",limit:u},m=await pt(this,r,d,{by:l,fn:c.fn},f,i);if(m===null)return;if(m.length===0){this.showState("empty");return}let g=(p?.groups??0)>d.length;this.render(m,l,ye(this,c.count),g)}render(i,r,s,l){let u=n.document,c=Math.max(...i.map(f=>f.value)),d=this.attr("label"),p={};d!==null&&d!==""&&(p["aria-label"]=d),l&&(p["aria-describedby"]="incomplete"),C(this.body),this.body.appendChild(h(u,"div",{class:"card"},...d===null||d===""?[]:[h(u,"p",{class:"label"},d)],h(u,"ol",p,...i.map(f=>h(u,"li",{},h(u,"button",{type:"button",onclick:()=>{this.emit("cube-select",{by:r,key:f.key})}},h(u,"span",{class:"name"},f.label)," ",h(u,"span",{class:"value"},s(f.value)),this.bar(f.value,c))))),...l?[h(u,"p",{class:"note",id:"incomplete",role:"note"},y.incomplete)]:[]))}bar(i,r){let s=r>0&&i>0?i/r*100:0;return U(n.document,"svg",{viewBox:"0 0 100 4",preserveAspectRatio:"none","aria-hidden":"true",focusable:"false"},U(n.document,"rect",{class:"bar",x:0,y:0,width:s,height:4}))}}return b(t,"tag","cube-top"),b(t,"css",Ms),t}var Ls=[["cube-state",Nr],["cube-app-shell",ur],["cube-period-picker",$r],["cube-kpi",Fr],["cube-chart",Cr],["cube-top",qr],["cube-table",Kr],["cube-detail",Rr],["cube-form",Dr],["cube-calc",yr],["cube-board",fr],["cube-gap-list",Mr]],Gr=new WeakMap;function Fs(e){return class extends e.HTMLElement{}}function Os(e,n,t){let o=e.document.fonts;if(!(n.fontFamily===null||e.FontFace===void 0||o===void 0))for(let a of n.fontFiles){let i=`${n.fontFamily}|${a.src}|${a.weight??""}|${a.style??""}`;if(!t.has(i)){t.add(i);try{let r={style:a.style??"normal"};a.weight!==void 0&&(r.weight=a.weight);let s=new e.FontFace(n.fontFamily,`url("${a.src}")`,r);o.add(s),s.load().catch(()=>{})}catch{}}}}function _s(e){let n=e.document,t=Gr.get(n);t?.stop();let o=new e.CSSStyleSheet,a=t?.fonts??new Set,i=r=>{try{o.replaceSync(On(r)),Os(e,r,a)}catch{}};i(We()),n.adoptedStyleSheets=[...n.adoptedStyleSheets.filter(r=>r!==t?.sheet),o],Gr.set(n,{sheet:o,stop:Qe(i),fonts:a})}function Zt(e,n={}){let t=e??globalThis;if(t.customElements===void 0||t.HTMLElement===void 0||t.document===void 0)return;let o=t,a=o.customElements;_s(o);let i=lr(o,n);for(let[r,s]of Ls)a.get(r)===void 0&&a.define(r,s(i,o));a.get("cube-page")===void 0&&a.define("cube-page",Fs(o));for(let r of["cube-field","cube-input","cube-result","cube-column"])a.get(r)===void 0&&a.define(r,dr(o))}var $s=5e3,Ps=6e4,Ns=1e4,js=`
|
|
181
|
+
.banner{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:.5rem 1rem;
|
|
182
|
+
border-bottom:1px solid var(--cube-color-border);border-left:4px solid var(--cube-color-warning);
|
|
183
|
+
background:var(--cube-color-surface);font-size:.875rem}
|
|
184
|
+
.banner p{margin:0;flex:1 1 16rem}
|
|
185
|
+
.banner[data-state=expired],.banner[data-state=closed]{border-left-color:var(--cube-color-danger)}
|
|
186
|
+
`;function Wr(e,n){let t=e.document,o=e.now??Date.now,a=Date.parse(n.expiresAt),i=Number.isFinite(a),r=i?new Intl.DateTimeFormat("nl-NL",{hour:"2-digit",minute:"2-digit"}).format(new Date(a)):null,s=t.createElement("cube-trial-banner"),l=s.attachShadow({mode:"open"}),u=[De,js].map(x=>{let E=new e.CSSStyleSheet;return E.replaceSync(x),E}),c=h(t,"p",{},y.trial.banner(r,n.leest)),d=h(t,"div",{class:"banner",role:"status","aria-live":"polite"},c),p=null,f=!1,m=!1,g=null;l.adoptedStyleSheets=u,l.appendChild(d);let w=()=>{t.body.insertBefore(s,t.body.firstChild)},v=()=>t.visibilityState!=="hidden",k=()=>{f=!0,g?.abort(),p!==null&&e.clearTimeout(p),p=null,t.removeEventListener("visibilitychange",T)},S=(x,E)=>{k(),!s.isConnected&&t.body!==null&&w(),d.setAttribute("data-state",x),C(c),c.appendChild(t.createTextNode(y.trial[x])),E!==void 0&&d.appendChild(h(t,"button",{type:"button",onclick:E[1]},E[0]))},D=()=>{if(f)return;p!==null&&e.clearTimeout(p);let x=v()?$s:Ps;p=e.setTimeout(L,i?Math.max(0,Math.min(x,a-o())):x)},L=async()=>{if(p=null,f)return;if(i&&o()>=a){S("expired");return}m=!0;let x=e.AbortController===void 0?null:new e.AbortController;g=x;let E=x===null?null:e.setTimeout(()=>x.abort(),Ns);try{let O=await e.fetch(n.statusUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${n.token}`},cache:"no-store",...x===null?{}:{signal:x.signal}});await B(O)}catch{D()}finally{m=!1,g=null,E!==null&&e.clearTimeout(E)}},B=async x=>{if(f)return;if(x.ok||x.status===429||x.status>=500){D();return}let E={};try{let A=await x.json();A!==null&&typeof A=="object"&&(E=A)}catch{}let O=E.code,G=null;if(O==="trial_expired")S("expired");else if(O==="trial_elsewhere")S("elsewhere",[y.trial.reload,()=>e.location.reload()]);else if(O==="trial_replaced"&&(G=Is(E.newer,n.dmpUrl))!==null){let A=G.href;E.wider===!1?(S("refreshing"),e.location.assign(A)):S("wider",[y.trial.load,()=>e.location.assign(A)])}else S("closed")};function T(){if(!(f||m)){if(!v()){D();return}p!==null&&e.clearTimeout(p),L()}}return t.addEventListener("visibilitychange",T),t.body===null?t.addEventListener("DOMContentLoaded",w,{once:!0}):w(),D(),k}function Is(e,n){if(typeof e!="string")return null;try{let t=new URL(e);return t.origin===new URL(n).origin&&t.pathname.startsWith("/apps/proef/")?t:null}catch{return null}}var Bs=Object.freeze({...it,defineBlocks:Zt});globalThis.CubeApp=Bs;typeof customElements<"u"&&Zt();var Qr=Ye(),en=globalThis;Qr!==null&&en.document!==void 0&&en.CSSStyleSheet!==void 0&&Wr(en,Qr);})();
|