@cube-nl/dmp-sdk 1.1.0-rc.3 → 1.1.0-rc.4
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 +23 -13
- package/dist/app.d.ts +2 -2
- package/dist/app.js +1 -1
- package/dist/cube-sdk.js +20 -20
- package/dist/cube-ui.manifest.json +26 -3
- package/dist/size.json +2 -2
- package/dist/ui/manifest.d.ts +4 -1
- package/dist/ui/manifest.js +12 -3
- package/dist/ui/trial-banner.js +17 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cube-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @cube-nl/dmp-sdk 1.1.0-rc.
|
|
2
|
-
"use strict";(()=>{var to=Object.defineProperty;var no=(e,n,t)=>n in e?to(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var b=(e,n,t)=>no(e,typeof n!="symbol"?n+"":n,t);var P=class extends Error{constructor(t,o,a){let i=a!==null&&typeof a=="object"?a:{},r=oe(i.detail)??oe(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=oe(i.code)??oe(i.error),this.reason=oe(i.reason),this.type=oe(i.type),this.title=oe(i.title),this.detail=r,this.errors=ro(i.errors)?i.errors:null,this.retryAfter=oo(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 N(e){return e instanceof P}function oe(e){return typeof e=="string"?e:null}function ro(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function oo(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??lo(),a=(e.refreshLeewaySeconds??30)*1e3,i=typeof e.scopes=="string"?e.scopes:e.scopes.join(" "),r=e.metadata??{},s=io(r)?Promise.resolve({...r,issuer:r.issuer??e.issuer}):null,l=null,u=()=>(s??(s=so(e.issuer,n).then(f=>({...f,...r}),f=>{throw s=null,f})),s),c=async(f,d)=>{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 P(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:d};return await t.set(S),S},p=()=>(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(d){throw d instanceof P&&d.status>=400&&d.status<500&&await t.set(null),d}})().finally(()=>{l=null})),l),m=async(f={})=>{let d=await u();if(!(d.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(d.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:m,async signIn(f={}){let d=nn();if(d===null)throw new TypeError("signIn() needs a browser; use authorizationUrl() and redirect yourself.");d.assign(await m(f))},async handleCallback(f){let d=f??nn()?.href;if(d===void 0)throw new TypeError("handleCallback() needs the callback URL outside a browser.");let g=new URL(d),w=new URLSearchParams(g.search);if(!uo(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=co(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 P(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:p,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 p()).accessToken}catch{return(await t.get())?.accessToken??null}return f.accessToken},async onUnauthorized(){if((await t.get())?.refreshToken==null)return!1;try{return await p(),!0}catch{return!1}}}}function io(e){return typeof e.authorization_endpoint=="string"&&typeof e.token_endpoint=="string"}async function so(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 P(o.status,o.headers,a);return a}function je(e=null){let n=e;return{get:()=>n,set:t=>{n=t}}}function ao(){let e=new Map;return{getItem:n=>e.get(n)??null,setItem:(n,t)=>{e.set(n,t)},removeItem:n=>{e.delete(n)}}}function lo(){try{let e=globalThis.sessionStorage;if(e!==void 0)return e}catch{}return ao()}function nn(){let e=globalThis.location;return e!==void 0&&typeof e.assign=="function"?e:null}function uo(e,n){let t=new URL(n),o=a=>a.replace(/\/+$/,"")||"/";return e.origin===t.origin&&o(e.pathname)===o(t.pathname)}function co(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 po=new Set(["in","between"]);function ie(e,n={}){let t=new URLSearchParams;mo(t,e,n.fields),fo(t,n.filter),xe(t,"sort",n.sort),xe(t,"include",n.include),xe(t,"with_count",n.withCount),ho(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 mo(e,n,t){if(t===void 0)return;let o=bo(t)?{[n]:t}:t;for(let[a,i]of Object.entries(o))i.length>0&&e.append(`fields[${a}]`,i.join(","))}function fo(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}]`,go(t,a,i))}}function go(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(!po.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 ho(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 bo(e){return Array.isArray(e)}var yo=/^[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:p={},signal:m}={})=>{let f=`${n}${l.startsWith("/")?l:`/${l}`}${u?`?${u}`:""}`,d=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"}:{},...p}};c!==void 0&&(S.body=JSON.stringify(c)),a!==void 0&&(S.cache=a),m!==void 0&&(S.signal=m);let R=Date.now(),L=await t(f,S);return e.onResponse?.({method:s,url:f,status:L.status,ms:Date.now()-R}),L},g=await d();g.status===401&&o?.onUnauthorized!==void 0&&await o.onUnauthorized()&&(await g.body?.cancel().catch(()=>{}),g=await d());let w=await vo(g);if(!g.ok)throw new P(g.status,g.headers,w);let v=ko(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:So(g.headers)}};return{async capabilities(s={}){let l=(await i("GET","/_capabilities",Be({},s))).data;return{...l,resources:l.resources.map(wo)}},resources:s=>{if(!yo.test(s))throw new TypeError(`'${s}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let l=`/${s}`,u=d=>{let g=String(d);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=d=>d===void 0?"":ie(s,{fields:d}),p=async(d={},g={})=>await i("GET",l,Be({query:ie(s,d)},g)),m=async function*(d={},g={}){let w=d.page?.number??1;for(;;){let v=await p({...d,page:{...d.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(d,g,w)=>{let v=await i("POST",d,{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:p,pages:m,async*all(d={},g={}){for await(let w of m(d,g))yield*w.data},get:(d,g={},w={})=>i("GET",u(d),Be({query:ie(s,g)},w)),aggregate:(d,g={})=>i("GET",`${l}/_aggregate`,Be({query:ie(s,d)},g)),create:(d,g={})=>i("POST",l,{query:c(g.fields),body:d,headers:Ie(g)}),update:(d,g,w={})=>i("PATCH",u(d),{query:c(w.fields),body:g,headers:Ie(w)}),delete:async(d,g={})=>({...await i("DELETE",u(d),{headers:Ie(g)}),data:null}),operation:(d,g,w,v={})=>f(`${u(d)}/${encodeURIComponent(un(g))}`,w,v),collectionOperation:(d,g,w={})=>f(`${l}/_operations/${encodeURIComponent(un(d))}`,g,w)}},request:i}}function wo(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 vo(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function ko(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"data"in e}function So(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"],xo=[[">=","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,To=50,At=200,Co="1.0",te=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(Ao(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,Ro(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=>Do(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=>Mo(s,i,r)),aggregate:i=>t("aggregate",r=>Po(r,i)),create:(i,r={})=>t("create",s=>Bo(s,i,r)),update:(i,r,s={})=>t("update",l=>Uo(l,i,r,s)),delete:(i,r={})=>t("delete",s=>Ho(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 Ao(e){let n=e.resources;return Object.keys(e).length===1&&Te(n)&&!("rows"in n)&&!("schema"in n)?n:e}function Ro(e,n){let t=n.schema??{},o=(n.rows??[]).map(p=>Mt(p)),a=new Map,i=Array.isArray(t.fields)?t.fields.map(p=>[p.name,p]):Object.entries(t.fields??{});for(let[p,m]of i)a.set(p,Eo(p,m));for(let p of a.size===0?o:[])for(let m of Object.keys(p))a.has(m)||a.set(m,{name:m,types:[],nullable:!0,format:null,description:null});let r=[...a.keys()],s=(Te(t.choices)?Object.entries(t.choices):[]).filter(p=>Te(p[1])&&Array.isArray(p[1].values)),l=new Set(["id",...t.readonly??[],...i.filter(([,p])=>p.readonly===!0).map(([p])=>p),...s.filter(([,p])=>p.writable===!1).map(([p])=>p)]),u=new Map;for(let[p,m]of i)Array.isArray(m.enum)&&u.set(p,m.enum);for(let[p,m]of s)u.set(p,m.values);let c=p=>Array.isArray(p)?p.filter(m=>typeof m=="string"&&a.has(m)):null;return{name:e,actions:Array.isArray(t.actions)?t.actions.filter(p=>typeof p=="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(([p,m])=>a.has(p)&&Array.isArray(m)).map(([p,m])=>[p,[...m]]):r.map(p=>[p,[...Et]])),choices:u,writable:new Set(r.filter(p=>!l.has(p))),summary:(c(t.summary_fields)??[]).length>0?c(t.summary_fields):r,rows:o,versions:new Map(o.map(p=>[Q(p.id),1])),replays:new Map}}function Eo(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(ie(e.name,n))}function Do(e,n){let t=Ce(e,n),o=Ue(e,t),a=vn(e,t),i=Oo(e,t),{size:r,number:s}=$o(t),l=wn(e,t),u=e.rows.filter(f=>a.every(d=>kn(e,f,d)));i.length>0&&(u=[...u].sort((f,d)=>{for(let{field:g,descending:w}of i){let v=V(f[g],d[g]);if(v!==0)return w?-v:v}return 0}));let c=u.length,p=u.slice((s-1)*r,s*r).map(f=>ze(f,o)),m={size:r,number:s,total:c,pages:Math.max(1,Math.ceil(c/r))};return{...de(200,p,ce(e,m,l)),meta:{...ce(e,m,l),page:m}}}function Mo(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?Lo(s,i):Fo(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 Lo(e,n){for(let[t,o]of xo)if(n.startsWith(t))return{field:e,operator:o,value:n.slice(t.length)};return{field:e,operator:"eq",value:n}}function Fo(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=>qo(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&&V(o,a(t.value))>0;case"gte":return o!=null&&V(o,a(t.value))>=0;case"lt":return o!=null&&V(o,a(t.value))<0;case"lte":return o!=null&&V(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&&V(o,i)>=0&&V(o,r)<=0}case"like":case"ilike":return typeof o=="string"&&_o(o,t.value);case"is":return t.value==="null"?o==null:o!=null;default:return!1}}function _o(e,n){let t=n.split("%").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(t,"iu").test(e)}function Oo(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 $o(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]")??To;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 Po(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=>No(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=>jo(e,f));hn(s,"group");let u=vn(e,t),c=new Map;for(let f of e.rows.filter(d=>u.every(g=>kn(e,d,g)))){let d={};for(let[v,k]of s.entries())d[k]=l[v](f);let g=JSON.stringify(Object.values(d)),w=c.get(g)??{key:d,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 m=[...c.values()].sort((f,d)=>{for(let g of s){let w=V(f.key[g],d.key[g]);if(w!==0)return w}return 0}).map(({key:f,rows:d})=>{let g={...f};for(let[w,v]of a.entries())g[v]=i[w](d);return g});return de(200,m,{...ce(e,null,[]),groups:m.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 No(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)=>V(c,u)<0?c:u);default:return s.length===0?null:s.reduce((u,c)=>V(c,u)>0?c:u)}}}function jo(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=>Io(i[o],a)}function Io(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 Bo(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:Ko(e),...i};for(let l of e.fields.keys())l in r||(r[l]=null);e.rows.push(r),e.versions.set(Q(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 Uo(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(Q(i.id),(e.versions.get(Q(i.id))??1)+1),de(200,ze(i,a),ce(e,null,[]),Ve(e,i))}function Ho(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(Q(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=Vo(l,s)??zo(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 zo(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 Vo(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 Ko(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=Q(n);if(t===""||t==="."||t==="..")throw new TypeError(`${e.name}: '${t}' is not an id.`);let o=e.rows.find(a=>Q(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-${Q(n.id)}-${e.versions.get(Q(n.id))??1}"`}function ce(e,n,t){return{resource:e.name,contract:Co,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 P(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 qo(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 V(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 Q(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 Go(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 p=(1-Math.abs(2*s-1))*c,m=p*(1-Math.abs(u/60%2-1)),f=s-p/2,d=Math.floor(u/60)%6,[g,w,v]=[[p,m,0],[m,p,0],[0,p,m],[0,m,p],[m,0,p],[p,0,m]][d];return $t([g,w,v].map(k=>Math.round((k+f)*255)))}function _t(e){let n=me(e);return n?$t(n):null}function Wo(e){let n=[],t=_t(e.primary_colour);t===null&&(t=_t(Fn.primary_colour),n.push({code:"invalid-primary",message:pe.invalidPrimary}));let o=null;e.accent_colour!==void 0&&e.accent_colour!==null&&(o=_t(e.accent_colour),o===null&&n.push({code:"invalid-accent",message:pe.invalidAccent})),o??(o=Go(t,330)),Re(t,"#ffffff")<3&&n.push({code:"primary-light",message:pe.primaryLight});let a=Ft(t,"#ffffff",.9),i=t;for(let d=0;d<=20&&(i=Ft(t,"#000000",d/20),!(Re(i,An)>=4.5&&Re(i,a)>=4.5));d++);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],p=typeof e.font=="string"&&Object.hasOwn(Ae,e.font)?e.font:"system",m=p==="system"?Cn:`"${Ae[p].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":m},warnings:n}}var Qo=/^#[0-9a-f]{6}$/i,Jo=/^\d+(\.\d+)?(px|rem)$/,Yo=/^data:image\/(svg\+xml|png);/,Xo=/[;{}<>\\\u0000-\u001f]|\/\*/,Dn=/["'()\\\s]/,Mn=String.raw`(?:\s*"[^"]*"\s*|\s*'[^']*'\s*|[^"',]+)`,Zo=new RegExp(`^${Mn}(?:,${Mn})*$`);function Ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ei(e,n){return typeof n!="string"?!1:e.startsWith("color-")?Qo.test(n):e.startsWith("radius")?Jo.test(n):n.length>0&&n.length<=200&&!Xo.test(n)&&Zo.test(n)}function qe(e,n,t){if(typeof e!="string"||e==="")return null;if(t&&Yo.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 ti(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 se(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}=Wo(o);if(Ke(a))for(let c of Ln)Object.hasOwn(a,c)&&ei(c,a[c])&&(r[c]=a[c]);let l=typeof o.font=="string"&&Object.hasOwn(Ae,o.font)?o.font:null,u=ti(i,n);return l!==null&&u.length===0&&!Array.isArray(i)&&(u=Ae[l].files.flatMap(c=>{let p=qe("cube-theme/"+c.file,n,!1);return p===null?[]:[{src:p,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 _n(e){return":where(:root){"+Ln.map(n=>`--cube-${n}:${e.tokens[n]}`).join(";")+"}"}var Ge=null,Ot=new Set;function We(){return Ge??(Ge=se(null,"http://localhost/")),Ge}function Pt(e){Ge=e;for(let n of[...Ot])n(e)}function Qe(e){return Ot.add(e),()=>{Ot.delete(e)}}var On="cube-trial-config",ni=["dmpUrl","apiUrl","token","expiresAt","statusUrl"],Je=null;function ri(e){let n=e?.getElementById(On)??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"||ni.some(i=>typeof t[i]!="string"||t[i]===""))return console.warn(`#${On} 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"&&ri(document);var $n="1.1.0-rc.3";var A=class extends TypeError{};var ne=["number","integer","currency","percent"],In="nl-NL",oi=["day","week","month","quarter","year"],Xe=/^(\d{4})-(\d{2})-(\d{2})$/,ii=/^\s*-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?\s*$/i,si=/^(count|sum|avg|min|max)(?:\(([A-Za-z_][A-Za-z0-9_]*)\))?$/,ai=/^([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 ae(e){return typeof e=="number"?Number.isFinite(e)?e:null:typeof e=="bigint"||typeof e=="string"&&ii.test(e)?Number(e):null}function li(e){return e instanceof Date?Number.isNaN(e.getTime())?null:e:typeof e=="number"?Number.isFinite(e)?new Date(e):null:typeof e=="string"?B(e):null}function I(e,n,t={}){if(e==null||e==="")return y.emptyValue;switch(n){case"number":case"integer":case"currency":case"percent":{let o=ae(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=li(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=>I(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)?B(e):null;return o===null?e:jt({day:"numeric",month:"short"}).format(o)}default:return e}}function Bn(e){let n=si.exec(e.trim()),t=n?.[1];if(t===void 0||t!=="count"&&n?.[2]===void 0)throw new A(y.invalid.measure(e));return{fn:t,field:n?.[2]??null}}function Ze(e){let n=ai.exec(e.trim()),t=n?.[1],o=n?.[2];if(t===void 0||o!==void 0&&!oi.includes(o))throw new A(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)?B(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 K(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 B(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 U(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 ui(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])(ui(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(p=>p.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 ci(e){let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619)>>>0;return n}function di(e,n,t){let{veld:o,type:a,waarden:i}=e,r=ci(`${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 U(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 te({[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(m=>m.resource===a&&m.veld!==void 0).map(m=>[m.veld,m])),r=m=>i.has(/^[-+]?(?:\w+\()?([^.()]*)/.exec(m)?.[1]??""),s=(m={})=>{let f=qn(m,a),d=f?.filter(k=>!i.has(k)),g=Object.entries(m.filter??{}),w=et(m.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:{...m,...d&&{fields:d.includes("id")?d:[...d,"id"]},...v(!1)},local:v(!0),shown:k=>f===void 0||f.includes(k)}},l=(m,f,d=!1)=>{for(let[g,w]of i)(d||f(g))&&(!tt(m,g)||m[g]==null)&&(m[g]=di(w,m.id,o))},u=async(m,{local:f,shown:d})=>{let g=m.data;g.forEach(v=>l(v,d,!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())d(k)||delete v[k];let{meta:w}=m;return{...m,data:g,meta:Object.keys(f.filter).length>0?{...w,page:{...w.page,total:g.length,pages:w.page.number}}:w}},c=async(m,f)=>{let d=s(m);return u(await e.list(d.live,f),d)},p=async function*(m,f){let d=s(m);for await(let g of e.pages(d.live,f))yield await u(g,d)};return{...e,list:c,pages:p,async*all(m,f){for await(let d of p(m,f))yield*d.data},async get(m,f,d){let g=s(f),w=await e.get(m,g.live,d);return l(w.data,g.shown),g.shown("id")||delete w.data.id,w},aggregate:(m,f)=>[et(m.fn).map(d=>d.replace(/^\w+$/,"")),et(m.group),Object.keys(m.filter??{})].flat().some(r)?t.resource(a).aggregate(m):e.aggregate(m,f)}}function Gn(e,n){let t=d=>String(d.id),o=new Map,a=new Map,i=new Set,r=0,s=(d,g)=>({status:d,data:g,meta:null,headers:new Headers,etag:null,recordVersion:null,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}),l=(d,g)=>{let w=qn(g,n);return Object.fromEntries(Object.entries(d).filter(([v])=>w?.includes(v)??!0))},u=async(d,g={})=>{let{page:w}=d.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):[]),R=new Set(d.data.map(t)),L=d.data.filter(D=>!i.has(t(D))&&(!o.has(t(D))||k.has(t(D)))).map(D=>o.get(t(D))??D),j=v.filter(D=>!S.has(t(D))&&!R.has(t(D))),x=w.total-[...S].filter(D=>!k.has(D)).length+j.length,F=w.number===1?[...j,...L]:L,T=et(g.sort).map(D=>[D.replace(/^[-+]/,""),D.startsWith("-")?-1:1]),E=D=>o.has(t(D))&&(!R.has(t(D))||T.some(([$])=>a.get(t(D))?.[$]!==D[$])),z=F.filter(D=>!E(D));if(T.every(([D])=>z.every($=>tt($,D)))){for(let D of F.filter(E)){let $=z.findIndex(Xr=>T.reduce((Zr,[tn,eo])=>Zr||eo*V(D[tn],Xr[tn]),0)<0);z.splice($>>>0,0,D)}F=z}return{...d,data:F.map(D=>l(D,g)),meta:{...d.meta,page:{...w,total:x}}}},c=async(d,g,w)=>{let v=o.get(String(d));if(i.has(String(d))){let k=`No such ${n} record.`;throw new P(404,new Headers,{status:404,code:"not_found",detail:k})}return v===void 0?e.get(d,g,w):s(200,l(v,g))},p=async d=>{let{data:g}=await c(d);return o.has(String(d))||a.set(String(d),g),g},m=async()=>({...s(202,null),accepted:!0}),f=async function*(d,g){for await(let w of e.pages(d,g))yield await u(w,d)};return{...e,get:c,pages:f,operation:m,collectionOperation:m,list:async(d,g)=>u(await e.list(d,g),d),async*all(d,g){for await(let w of f(d,g))yield*w.data},async create(d){let g={...d,id:`voorbeeld-${++r}`};return o.set(g.id,g),s(201,{...g})},async update(d,g){let w=await p(d),v={...w,...g,id:w.id};return o.set(String(d),v),s(200,{...v})},async delete(d){return await p(d),o.delete(String(d)),i.add(String(d)),s(204,null)}}}var mi="./cube-app.config.json",fi="./cube-mock.json",gi="./cube-app.json",hi="./cube-theme.json",bi={id:"preview",name:Lt,scopes:[]},Qn=null,Jn=null,q=null,zt=null,rt=null,Wn=0;function Yn(e={}){let n=q!==null&&q===zt,t=++Wn,o=ki(e,()=>t===Wn);return q=o,zt=null,o.then(()=>{n&&q===o&&vi()},()=>{q===o&&(q=null)}),o}function yi(){return q!==null?q:(rt??(rt=wi().then(()=>{if(rt=null,q!==null)return q;let e=Yn();return zt=e,e})),rt)}function wi(){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 vi(){let e=globalThis.document;if(e===void 0)return;let n=e.defaultView?.CustomEvent??CustomEvent;e.dispatchEvent(new n("cube-session-change"))}async function ki(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(mi,o)):null,Si(e,t,o)]);return n()&&Pt(r),a!==null?Ai(a,e,t,o):i===null?xi(e,t,o):Ti(Di(i),e,t,o)}async function Si(e,n,t){try{if(e.theme===!1)return se(null,t);let o=e.theme??Jn;if(o!==null)return se(o,t);let a=await ot(n,Ee(hi,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 se(a,t)}catch(o){return console.warn(`cube-theme.json could not be used, the neutral theme applies: ${String(o)}`),se(null,t)}}async function Xn(e,n,t){let o=e.mock??Qn??await ot(n,Ee(fi,t))??{},a=e.manifest===!1?null:e.manifest??await ot(n,Ee(gi,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 xi(e,n,t){let[o,a]=await Xn(e,n,t),i=!0,r=()=>{if(!i)throw new P(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 te(o,a,r),u=new te(o,null,r),c=p=>s.isExample(p)?u:l;return{...s,mode:"preview",signInError:null,user:()=>i?{...bi}:null,async signIn(){i=!0},async signOut(){i=!1},resource:er(s.simulatesWrites,p=>{let m=c(p),f=m.resource(p),d=m.describe(p)?.fields??[],g=s.gaps.filter(({resource:w,veld:v})=>w===p&&v!==void 0&&!d.some(k=>k.name===v));return g.length>0?Ht(f,g,u,u.rows(p)):f}),schema:async p=>nt(c(p).describe(p),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 te(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 Ti(e,n,t,o){let a=e.dmpUrl.replace(/\/+$/,""),i=null,r=Mi(n.tokenStorage==="memory"?je():Li(`cube-app.tokens.${e.clientId}`),p=>{i=p}),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(p){u=p instanceof Error?p:new Error(String(p))}return i===null&&u===null&&n.autoSignIn===!0&&await s.signIn(),nr({mode:"live",client:l,signInError:()=>u,user:()=>i===null?null:Ri(i),async signIn(){u=null,await s.signIn()},async signOut(){await s.signOut()}},c)}function Ci(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 Ai(e,n,t,o){let a=e.token,i=St({baseUrl:e.apiUrl,auth:()=>a,fetch:Ci(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 Ri(e){let n=Ei(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 Ei(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 Di(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 Mi(e,n){return{async get(){let t=await e.get();return n(t),t},async set(t){await e.set(t),n(t)}}}function Li(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 Fi(e){Qn=e}function _i(e){Jn=e,Pt(se(e,rr()))}var it=Object.freeze({connect:Yn,ready:yi,mock:Fi,theme:_i,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","detail"],"cube-column":["value","label"],"cube-gap-list":["scherm"]};var Oi="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 H(e,n,t={},...o){let a=e.createElementNS(Oi,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 A(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=`
|
|
1
|
+
/*! @cube-nl/dmp-sdk 1.1.0-rc.4 cube-sdk.js (window.CubeApp) | MIT */
|
|
2
|
+
"use strict";(()=>{var to=Object.defineProperty;var no=(e,n,t)=>n in e?to(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var b=(e,n,t)=>no(e,typeof n!="symbol"?n+"":n,t);var N=class extends Error{constructor(t,o,a){let i=a!==null&&typeof a=="object"?a:{},r=ie(i.detail)??ie(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=ie(i.code)??ie(i.error),this.reason=ie(i.reason),this.type=ie(i.type),this.title=ie(i.title),this.detail=r,this.errors=ro(i.errors)?i.errors:null,this.retryAfter=oo(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 j(e){return e instanceof N}function ie(e){return typeof e=="string"?e:null}function ro(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function oo(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 sn(e){return{async getAccessToken(){let n=typeof e=="function"?await e():e;return n===void 0||n===""?null:n}}}var je="cube-dmp-sdk.pending-login";function an(e){let n=e.fetch??globalThis.fetch.bind(globalThis),t=e.tokenStore??Ie(),o=e.pendingStore??lo(),a=(e.refreshLeewaySeconds??30)*1e3,i=typeof e.scopes=="string"?e.scopes:e.scopes.join(" "),r=e.metadata??{},s=io(r)?Promise.resolve({...r,issuer:r.issuer??e.issuer}):null,l=null,u=()=>(s??(s=so(e.issuer,n).then(f=>({...f,...r}),f=>{throw s=null,f})),s),c=async(f,d)=>{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 ln(v);if(!v.ok||k===null||typeof k!="object"||typeof k.access_token!="string")throw new N(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:d};return await t.set(S),S},p=()=>(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(d){throw d instanceof N&&d.status>=400&&d.status<500&&await t.set(null),d}})().finally(()=>{l=null})),l),m=async(f={})=>{let d=await u();if(!(d.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=on(64),w=f.state??on(32),v=un(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(g))),k={verifier:g,state:w,redirectUri:e.redirectUri,clientId:e.clientId};o.setItem(je,JSON.stringify(k));let S=new URL(d.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:m,async signIn(f={}){let d=rn();if(d===null)throw new TypeError("signIn() needs a browser; use authorizationUrl() and redirect yourself.");d.assign(await m(f))},async handleCallback(f){let d=f??rn()?.href;if(d===void 0)throw new TypeError("handleCallback() needs the callback URL outside a browser.");let g=new URL(d),w=new URLSearchParams(g.search);if(!uo(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=co(o.getItem(je));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(je),w.has("error"))throw new N(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:p,async getTokens(){return t.get()},async setTokens(f){await t.set(f)},async signOut(){await t.set(null),o.removeItem(je)},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 p()).accessToken}catch{return(await t.get())?.accessToken??null}return f.accessToken},async onUnauthorized(){if((await t.get())?.refreshToken==null)return!1;try{return await p(),!0}catch{return!1}}}}function io(e){return typeof e.authorization_endpoint=="string"&&typeof e.token_endpoint=="string"}async function so(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 ln(o);if(!o.ok||a===null||typeof a!="object")throw new N(o.status,o.headers,a);return a}function Ie(e=null){let n=e;return{get:()=>n,set:t=>{n=t}}}function ao(){let e=new Map;return{getItem:n=>e.get(n)??null,setItem:(n,t)=>{e.set(n,t)},removeItem:n=>{e.delete(n)}}}function lo(){try{let e=globalThis.sessionStorage;if(e!==void 0)return e}catch{}return ao()}function rn(){let e=globalThis.location;return e!==void 0&&typeof e.assign=="function"?e:null}function uo(e,n){let t=new URL(n),o=a=>a.replace(/\/+$/,"")||"/";return e.origin===t.origin&&o(e.pathname)===o(t.pathname)}function co(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 ln(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function on(e){return un(crypto.getRandomValues(new Uint8Array(e)))}function un(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 po=new Set(["in","between"]);function se(e,n={}){let t=new URLSearchParams;mo(t,e,n.fields),fo(t,n.filter),Te(t,"sort",n.sort),Te(t,"include",n.include),Te(t,"with_count",n.withCount),ho(t,n.has),Te(t,"fn",n.fn),Te(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 mo(e,n,t){if(t===void 0)return;let o=bo(t)?{[n]:t}:t;for(let[a,i]of Object.entries(o))i.length>0&&e.append(`fields[${a}]`,i.join(","))}function fo(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}]`,kt(o));continue}for(let[a,i]of Object.entries(o))i!==void 0&&e.append(`filter[${t}][${a}]`,go(t,a,i))}}function go(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(!po.has(n))throw new TypeError(`filter.${e}.${n}: takes one value; only 'in' and 'between' take a list.`);return t.map(kt).join(",")}return kt(t)}function ho(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 Te(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 kt(e){return typeof e=="boolean"?e?"1":"0":String(e)}function bo(e){return Array.isArray(e)}var yo=/^[a-z][a-z0-9_]*$/;function xt(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"?sn(e.auth):e.auth,a=e.cache??(typeof document<"u"?"no-cache":void 0),i=async(s,l,{query:u,body:c,headers:p={},signal:m}={})=>{let f=`${n}${l.startsWith("/")?l:`/${l}`}${u?`?${u}`:""}`,d=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"}:{},...p}};c!==void 0&&(S.body=JSON.stringify(c)),a!==void 0&&(S.cache=a),m!==void 0&&(S.signal=m);let D=Date.now(),M=await t(f,S);return e.onResponse?.({method:s,url:f,status:M.status,ms:Date.now()-D}),M},g=await d();g.status===401&&o?.onUnauthorized!==void 0&&await o.onUnauthorized()&&(await g.body?.cancel().catch(()=>{}),g=await d());let w=await vo(g);if(!g.ok)throw new N(g.status,g.headers,w);let v=ko(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:So(g.headers)}};return{async capabilities(s={}){let l=(await i("GET","/_capabilities",Ue({},s))).data;return{...l,resources:l.resources.map(wo)}},resources:s=>{if(!yo.test(s))throw new TypeError(`'${s}' is not a resource name: cube/api names match [a-z][a-z0-9_]*.`);let l=`/${s}`,u=d=>{let g=String(d);if(g==="")throw new TypeError(`${s}: an empty id would address the collection, not a record.`);if(pn(g))throw new TypeError(`${s}: '${g}' is not an id: it would address another path, not a record.`);return`${l}/${encodeURIComponent(g)}`},c=d=>d===void 0?"":se(s,{fields:d}),p=async(d={},g={})=>await i("GET",l,Ue({query:se(s,d)},g)),m=async function*(d={},g={}){let w=d.page?.number??1;for(;;){let v=await p({...d,page:{...d.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(d,g,w)=>{let v=await i("POST",d,{query:c(w.fields),body:g??{},headers:Be(w)});return{...v,data:v.status===204?null:v.data,accepted:v.status===202}};return{name:s,list:p,pages:m,async*all(d={},g={}){for await(let w of m(d,g))yield*w.data},get:(d,g={},w={})=>i("GET",u(d),Ue({query:se(s,g)},w)),aggregate:(d,g={})=>i("GET",`${l}/_aggregate`,Ue({query:se(s,d)},g)),create:(d,g={})=>i("POST",l,{query:c(g.fields),body:d,headers:Be(g)}),update:(d,g,w={})=>i("PATCH",u(d),{query:c(w.fields),body:g,headers:Be(w)}),delete:async(d,g={})=>({...await i("DELETE",u(d),{headers:Be(g)}),data:null}),operation:(d,g,w,v={})=>f(`${u(d)}/${encodeURIComponent(cn(g))}`,w,v),collectionOperation:(d,g,w={})=>f(`${l}/_operations/${encodeURIComponent(cn(d))}`,g,w)}},request:i}}function wo(e){return{...e,operations:(e.operations??[]).map(n=>({...n,input:St(n.input)})),aggregatable:St(e.aggregatable),relations:St(e.relations)}}function St(e){return Array.isArray(e)||e===void 0||e===null?{}:e}function dn(){return crypto.randomUUID()}function cn(e){if(e===""||e.startsWith("_"))throw new TypeError(`'${e}' is not an operation name: the '_' namespace is reserved by the API.`);if(pn(e))throw new TypeError(`'${e}' is not an operation name: it would address another path.`);return e}function pn(e){return e==="."||e===".."}function Be(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 Ue(e,n){return n.signal===void 0?e:{...e,signal:n.signal}}async function vo(e){let n=await e.text();if(n==="")return null;try{return JSON.parse(n)}catch{return n}}function ko(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&"data"in e}function So(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 mn=/^[a-z][a-z0-9_]*$/,fn=["eq","neq","gt","gte","lt","lte","in","like","ilike","is","between"],xo=[[">=","gte"],["<=","lte"],["<>","neq"],[">","gt"],["<","lt"],["=","eq"]],Dt=["count","sum","avg","min","max"],gn=["day","week","month","quarter","year"],Tt=20,Ct=5,hn=1e3,At=200,To=50,Rt=200,Co="1.0",ne=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(Ao(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;mn.test(r)&&this.tables.set(r,Ro(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(!mn.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=>Do(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=>Mo(s,i,r)),aggregate:i=>t("aggregate",r=>Po(r,i)),create:(i,r={})=>t("create",s=>Bo(s,i,r)),update:(i,r,s={})=>t("update",l=>Uo(l,i,r,s)),delete:(i,r={})=>t("delete",s=>Ho(s,i,r)),operation:(i,r,s,l)=>t("get",u=>{throw ze(u,i),wn(r)}),collectionOperation:i=>t("list",()=>{throw wn(i)})}}authorize(n,t){this.guard();let o=this.tables.get(n);if(o===void 0)throw E(404,"not_found",`Unknown API resource [${n}].`);let a=this.manifest?.uses;if(a!==void 0&&!(a[n]??[]).includes(t))throw E(403,"client_scope_exceeded",`This app may not ${t} '${n}': add it to "uses" in cube-app.json.`);return o}};function Ao(e){let n=e.resources;return Object.keys(e).length===1&&Ce(n)&&!("rows"in n)&&!("schema"in n)?n:e}function Ro(e,n){let t=n.schema??{},o=(n.rows??[]).map(p=>Lt(p)),a=new Map,i=Array.isArray(t.fields)?t.fields.map(p=>[p.name,p]):Object.entries(t.fields??{});for(let[p,m]of i)a.set(p,Eo(p,m));for(let p of a.size===0?o:[])for(let m of Object.keys(p))a.has(m)||a.set(m,{name:m,types:[],nullable:!0,format:null,description:null});let r=[...a.keys()],s=(Ce(t.choices)?Object.entries(t.choices):[]).filter(p=>Ce(p[1])&&Array.isArray(p[1].values)),l=new Set(["id",...t.readonly??[],...i.filter(([,p])=>p.readonly===!0).map(([p])=>p),...s.filter(([,p])=>p.writable===!1).map(([p])=>p)]),u=new Map;for(let[p,m]of i)Array.isArray(m.enum)&&u.set(p,m.enum);for(let[p,m]of s)u.set(p,m.values);let c=p=>Array.isArray(p)?p.filter(m=>typeof m=="string"&&a.has(m)):null;return{name:e,actions:Array.isArray(t.actions)?t.actions.filter(p=>typeof p=="string"):["list","get","create","update","delete"],fields:a,filterable:c(t.filters)??r,groupable:c(t.groupable)??r,aggregatable:new Map(Ce(t.aggregatable)?Object.entries(t.aggregatable).filter(([p,m])=>a.has(p)&&Array.isArray(m)).map(([p,m])=>[p,[...m]]):r.map(p=>[p,[...Dt]])),choices:u,writable:new Set(r.filter(p=>!l.has(p))),summary:(c(t.summary_fields)??[]).length>0?c(t.summary_fields):r,rows:o,versions:new Map(o.map(p=>[J(p.id),1])),replays:new Map}}function Eo(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 Ae(e,n){return new URLSearchParams(se(e.name,n))}function Do(e,n){let t=Ae(e,n),o=He(e,t),a=kn(e,t),i=_o(e,t),{size:r,number:s}=$o(t),l=vn(e,t),u=e.rows.filter(f=>a.every(d=>Sn(e,f,d)));i.length>0&&(u=[...u].sort((f,d)=>{for(let{field:g,descending:w}of i){let v=z(f[g],d[g]);if(v!==0)return w?-v:v}return 0}));let c=u.length,p=u.slice((s-1)*r,s*r).map(f=>Ve(f,o)),m={size:r,number:s,total:c,pages:Math.max(1,Math.ceil(c/r))};return{...pe(200,p,de(e,m,l)),meta:{...de(e,m,l),page:m}}}function Mo(e,n,t){let o=Ae(e,t),a=He(e,o),i=vn(e,o),r=ze(e,n);return pe(200,Ve(r,a),de(e,null,i),Ke(e,r))}function He(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 E(422,"query_invalid",`Unknown ${t}: ${i.join(", ")}.`,{[t]:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]});return a}function vn(e,n){let t=o=>(n.get(o)??"").split(",").filter(a=>a!=="");return[...new Set([...t("include"),...t("with_count")])]}function kn(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 E(422,"query_invalid",`Unknown filter: ${s}.`,{filter:[`Allowed values: ${e.filterable.join(", ")}.`]},"not_filterable");t.push(r[2]===void 0?Lo(s,i):Fo(s,r[2],i))}if(t.length>Tt)throw E(422,"query_invalid",`A query takes at most ${Tt} filters.`,{filter:[`Sent ${t.length}; the limit is ${Tt}.`]});return t}function Lo(e,n){for(let[t,o]of xo)if(n.startsWith(t))return{field:e,operator:o,value:n.slice(t.length)};return{field:e,operator:"eq",value:n}}function Fo(e,n,t){if(!fn.includes(n))throw E(422,"query_invalid",`Unknown filter operator: ${n}.`,{filter:[`Allowed operators: ${fn.join(", ")}.`]});if(n==="between"&&t.split(",").length!==2)throw E(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>At)throw E(422,"query_invalid",`filter[${e}][in] takes at most ${At} values.`,{filter:[`Sent ${t.split(",").length}; the limit is ${At}.`]});if(n==="is"&&t!=="null"&&t!=="not_null")throw E(422,"query_invalid",`filter[${e}][is] takes null or not_null.`,{filter:[`Received: ${t}.`]});return{field:e,operator:n,value:t}}function Sn(e,n,t){let o=n[t.field],a=i=>qo(e.fields.get(t.field),i.trim());switch(t.operator){case"eq":return Et(o,a(t.value));case"neq":return o!=null&&!Et(o,a(t.value));case"gt":return o!=null&&z(o,a(t.value))>0;case"gte":return o!=null&&z(o,a(t.value))>=0;case"lt":return o!=null&&z(o,a(t.value))<0;case"lte":return o!=null&&z(o,a(t.value))<=0;case"in":return t.value.split(",").some(i=>Et(o,a(i)));case"between":{let[i,r]=t.value.split(",").map(a);return o!=null&&z(o,i)>=0&&z(o,r)<=0}case"like":case"ilike":return typeof o=="string"&&Oo(o,t.value);case"is":return t.value==="null"?o==null:o!=null;default:return!1}}function Oo(e,n){let t=n.split("%").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(t,"iu").test(e)}function _o(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 E(422,"query_invalid",`Unknown sort: ${a.join(", ")}.`,{sort:[`Allowed values: ${[...e.fields.keys()].join(", ")}.`]},"not_sortable");return o}function $o(e){let n=o=>{let a=e.get(o);if(a===null||a==="")return null;if(!/^\d+$/.test(a))throw E(422,"query_invalid",`${o} must be a positive integer.`,{[o]:["Expected a positive integer."]});return Number(a)},t=n("page[size]")??To;if(t>Rt)throw E(422,"cardinality_exceeded",`page[size] may not exceed ${Rt}.`,{"page.size":[`The maximum page size is ${Rt}.`]});return{size:Math.max(1,t),number:Math.max(1,n("page[number]")??1)}}function Po(e,n){let t=Ae(e,n),o=(t.get("fn")??"").trim();if(o==="")throw E(422,"query_invalid","fn is required: name at least one aggregation function.",{fn:[`Expected e.g. fn=count or fn=sum(field). ${Mt(e)}`]});let a=o.split(",").map(f=>f.trim()),i=a.map(f=>No(e,f));bn(a,"fn");let r=(t.get("group")??"").trim(),s=r===""?[]:r.split(",").map(f=>f.trim());if(s.length>Ct)throw E(422,"cardinality_exceeded",`group may not exceed ${Ct} dimensions, ${s.length} given.`,{group:[`Use at most ${Ct} dimensions.`]});let l=s.map(f=>jo(e,f));bn(s,"group");let u=kn(e,t),c=new Map;for(let f of e.rows.filter(d=>u.every(g=>Sn(e,d,g)))){let d={};for(let[v,k]of s.entries())d[k]=l[v](f);let g=JSON.stringify(Object.values(d)),w=c.get(g)??{key:d,rows:[]};w.rows.push(f),c.set(g,w)}if(s.length===0&&c.size===0&&c.set("[]",{key:{},rows:[]}),c.size>hn)throw E(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 ${hn} groepen.`]},"too_many_groups");let m=[...c.values()].sort((f,d)=>{for(let g of s){let w=z(f.key[g],d.key[g]);if(w!==0)return w}return 0}).map(({key:f,rows:d})=>{let g={...f};for(let[w,v]of a.entries())g[v]=i[w](d);return g});return pe(200,m,{...de(e,null,[]),groups:m.length})}function bn(e,n){let t=[...new Set(e.filter((o,a)=>e.indexOf(o)!==a))];if(t.length>0)throw E(422,"query_invalid",`Duplicate ${n} entry: ${t.join(", ")}.`,{[n]:[`List each ${n} entry once.`]})}function Mt(e){return e.aggregatable.size===0?"This resource has no aggregatable fields; only bare count is available.":`Aggregatable fields: ${[...e.aggregatable.keys()].join(", ")}.`}function No(e,n){let t=/^([a-z]+)\(([a-z0-9_]+)\)$/.exec(n);if(t===null&&!/^[a-z]+$/.test(n))throw E(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(!Dt.includes(o))throw E(422,"query_invalid",`Unknown aggregation function: ${o}.`,{fn:[`Allowed values: ${Dt.join(", ")}.`]});if(a===null){if(o!=="count")throw E(422,"query_invalid",`${o} must be applied to a field, e.g. ${o}(field).`,{fn:[Mt(e)]});return r=>r.length}let i=e.aggregatable.get(a);if(i===void 0)throw E(422,"query_invalid",`Unknown aggregatable field: ${a}.`,{fn:[Mt(e)]});if(!i.includes(o))throw E(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)=>z(c,u)<0?c:u);default:return s.length===0?null:s.reduce((u,c)=>z(c,u)>0?c:u)}}}function jo(e,n){let t=n.split(".");if(t.length>2)throw E(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 E(422,"query_invalid",`Unknown group: ${o}.`,{group:[`Allowed values: ${e.groupable.join(", ")}.`]},"not_groupable");if(a===void 0)return i=>i[o]??null;if(!gn.includes(a))throw E(422,"query_invalid",`Unknown truncation unit: ${a}.`,{group:[`Allowed values: ${gn.join(", ")}.`]});return i=>Io(i[o],a)}function Io(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 Bo(e,n,t){let o=t.fields===void 0?e.summary:He(e,Ae(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 E(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=xn(e,n),r={id:Ko(e),...i};for(let l of e.fields.keys())l in r||(r[l]=null);e.rows.push(r),e.versions.set(J(r.id),1);let s=pe(201,Ve(r,o),de(e,null,[]),Ke(e,r));return t.idempotencyKey!==void 0&&e.replays.set(t.idempotencyKey,{body:a,response:s}),s}function Uo(e,n,t,o){let a=o.fields===void 0?e.summary:He(e,Ae(e,{fields:o.fields})),i=ze(e,n);return Tn(e,i,o.ifMatch),Object.assign(i,xn(e,t)),e.versions.set(J(i.id),(e.versions.get(J(i.id))??1)+1),pe(200,Ve(i,a),de(e,null,[]),Ke(e,i))}function Ho(e,n,t){let o=ze(e,n);return Tn(e,o,t.ifMatch),e.rows.splice(e.rows.indexOf(o),1),e.versions.delete(J(o.id)),pe(204,null,null)}function xn(e,n){let t=[...e.writable],o=t.length===0?"This resource declares no writable fields.":`Writable fields: ${t.join(", ")}.`;if(!Ce(n)||Object.keys(n).length===0)throw E(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 E(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=Vo(l,s)??zo(e,l,r,s);u!==null&&(i[r]=[u])}if(Object.keys(i).length>0)throw E(422,"validation_failed","The request body failed validation.",i);return Lt(n)}function zo(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 Vo(e,n){return e===void 0||e.types.length!==1?null:n===null?e.nullable?null:yn(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:yn(e)}function yn(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 Tn(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=Ke(e,n);if(t!==o)throw E(409,"conflict","The record changed since the version you sent.",void 0,void 0,{"X-Dmp-Record-Version":o})}function Ko(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 ze(e,n){let t=J(n);if(t===""||t==="."||t==="..")throw new TypeError(`${e.name}: '${t}' is not an id.`);let o=e.rows.find(a=>J(a.id)===t);if(o===void 0)throw E(404,"not_found",`No such ${e.name} record.`);return o}function wn(e){return E(404,"not_found",`No such operation [${e}]. The preview runs no custom operations.`)}function Ve(e,n){let t={};for(let o of n)t[o]=o in e?Lt(e[o]):null;return t}function Ke(e,n){return`"preview-${J(n.id)}-${e.versions.get(J(n.id))??1}"`}function de(e,n,t){return{resource:e.name,contract:Co,page:n,groups:null,omitted:t,pruned:[],forbidden_fields:[]}}function pe(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 E(e,n,t,o,a,i={}){return new N(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 qo(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 Et(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 z(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 J(e){return e==null?"":String(e)}function Ce(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Lt(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function Cn(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 Ft="Voorbeeldgebruiker",me={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:Ft,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:me};var Fn=["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"],On={primary_colour:"#475467",corners:"normaal",font:"system"},Re={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"}]}},An='system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',Rn="#f6f8fa";function fe(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 Pt(e){return"#"+e.map(n=>Math.max(0,Math.min(255,n)).toString(16).padStart(2,"0")).join("")}function En(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 Ee(e,n){let t=fe(e),o=fe(n);if(!t||!o)return 1;let a=En(t),i=En(o);return(Math.max(a,i)+.05)/(Math.min(a,i)+.05)}function Ot(e,n,t){let o=fe(e),a=fe(n);return Pt(o.map((i,r)=>Math.round(i*(1-t)+a[r]*t)))}function Dn(e){return Ee(e,"#ffffff")>=Ee(e,"#000000")?"#ffffff":"#000000"}function Go(e,n){let[t,o,a]=fe(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 p=(1-Math.abs(2*s-1))*c,m=p*(1-Math.abs(u/60%2-1)),f=s-p/2,d=Math.floor(u/60)%6,[g,w,v]=[[p,m,0],[m,p,0],[0,p,m],[0,m,p],[m,0,p],[p,0,m]][d];return Pt([g,w,v].map(k=>Math.round((k+f)*255)))}function _t(e){let n=fe(e);return n?Pt(n):null}function Wo(e){let n=[],t=_t(e.primary_colour);t===null&&(t=_t(On.primary_colour),n.push({code:"invalid-primary",message:me.invalidPrimary}));let o=null;e.accent_colour!==void 0&&e.accent_colour!==null&&(o=_t(e.accent_colour),o===null&&n.push({code:"invalid-accent",message:me.invalidAccent})),o??(o=Go(t,330)),Ee(t,"#ffffff")<3&&n.push({code:"primary-light",message:me.primaryLight});let a=Ot(t,"#ffffff",.9),i=t;for(let d=0;d<=20&&(i=Ot(t,"#000000",d/20),!(Ee(i,Rn)>=4.5&&Ee(i,a)>=4.5));d++);i!==t&&n.push({code:"primary-darkened-for-text",message:me.primaryDarkened});let r=Dn(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],p=typeof e.font=="string"&&Object.hasOwn(Re,e.font)?e.font:"system",m=p==="system"?An:`"${Re[p].family}", ${An}`;return{tokens:{"color-primary":t,"color-primary-hover":Ot(t,r==="#ffffff"?"#000000":"#ffffff",.15),"color-primary-subtle":a,"color-primary-text":i,"color-on-primary":r,"color-accent":o,"color-on-accent":Dn(o),"color-text":"#1f2328","color-text-muted":"#59636e","color-bg":"#ffffff","color-surface":Rn,"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":m},warnings:n}}var Qo=/^#[0-9a-f]{6}$/i,Jo=/^\d+(\.\d+)?(px|rem)$/,Yo=/^data:image\/(svg\+xml|png);/,Xo=/[;{}<>\\\u0000-\u001f]|\/\*/,Mn=/["'()\\\s]/,Ln=String.raw`(?:\s*"[^"]*"\s*|\s*'[^']*'\s*|[^"',]+)`,Zo=new RegExp(`^${Ln}(?:,${Ln})*$`);function qe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ei(e,n){return typeof n!="string"?!1:e.startsWith("color-")?Qo.test(n):e.startsWith("radius")?Jo.test(n):n.length>0&&n.length<=200&&!Xo.test(n)&&Zo.test(n)}function Ge(e,n,t){if(typeof e!="string"||e==="")return null;if(t&&Yo.test(e))return Mn.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&&!Mn.test(a.href))return a.href}catch{}return null}function ti(e,n){let t=[];for(let o of Array.isArray(e)?e:[]){if(!qe(o))continue;let a=Ge(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 ae(e,n){let t=e,o=On,a=null,i=null;qe(t)&&(Object.hasOwn(t,"source")&&qe(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}=Wo(o);if(qe(a))for(let c of Fn)Object.hasOwn(a,c)&&ei(c,a[c])&&(r[c]=a[c]);let l=typeof o.font=="string"&&Object.hasOwn(Re,o.font)?o.font:null,u=ti(i,n);return l!==null&&u.length===0&&!Array.isArray(i)&&(u=Re[l].files.flatMap(c=>{let p=Ge("cube-theme/"+c.file,n,!1);return p===null?[]:[{src:p,weight:c.weight,style:c.style}]})),{tokens:r,logo:Ge(o.logo,n,!0),logoDark:Ge(o.logo_dark,n,!0),fontFamily:l===null?null:Re[l].family,fontFiles:u,warnings:s}}function _n(e){return":where(:root){"+Fn.map(n=>`--cube-${n}:${e.tokens[n]}`).join(";")+"}"}var We=null,$t=new Set;function Qe(){return We??(We=ae(null,"http://localhost/")),We}function Nt(e){We=e;for(let n of[...$t])n(e)}function Je(e){return $t.add(e),()=>{$t.delete(e)}}var $n="cube-trial-config",ni=["dmpUrl","apiUrl","token","expiresAt","statusUrl"],Ye=null;function ri(e){let n=e?.getElementById($n)??null;if(n===null)return null;Ye=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"||ni.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 Ye={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"):[]},Ye}function Xe(){return Ye}typeof document<"u"&&ri(document);var Pn="1.1.0-rc.4";var A=class extends TypeError{};var re=["number","integer","currency","percent"],Bn="nl-NL",oi=["day","week","month","quarter","year"],Ze=/^(\d{4})-(\d{2})-(\d{2})$/,ii=/^\s*-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?\s*$/i,si=/^(count|sum|avg|min|max)(?:\(([A-Za-z_][A-Za-z0-9_]*)\))?$/,ai=/^([A-Za-z_][A-Za-z0-9_]*)(?:\.([a-z]+))?$/,Nn=new Map,jn=new Map;function jt(e){let n=JSON.stringify(e),t=Nn.get(n);return t===void 0&&(t=new Intl.NumberFormat(Bn,e),Nn.set(n,t)),t}function It(e){let n=JSON.stringify(e),t=jn.get(n);return t===void 0&&(t=new Intl.DateTimeFormat(Bn,e),jn.set(n,t)),t}function le(e){return typeof e=="number"?Number.isFinite(e)?e:null:typeof e=="bigint"||typeof e=="string"&&ii.test(e)?Number(e):null}function li(e){return e instanceof Date?Number.isNaN(e.getTime())?null:e:typeof e=="number"?Number.isFinite(e)?new Date(e):null:typeof e=="string"?B(e):null}function I(e,n,t={}){if(e==null||e==="")return y.emptyValue;switch(n){case"number":case"integer":case"currency":case"percent":{let o=le(e);if(o===null)return String(e);let a=t.compact===!0?{notation:"compact"}:{};if(n==="currency")return jt({style:"currency",currency:t.currency??"EUR",...a}).format(o);if(n==="percent")return jt({style:"percent",maximumFractionDigits:1}).format(o);let i=n==="integer"?0:t.compact===!0?1:2;return jt({maximumFractionDigits:i,...a}).format(o)}case"date":case"datetime":{let o=li(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"&&Ze.test(e);return t.timeZone!==void 0&&!i&&(a.timeZone=t.timeZone),It(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=>I(o,"text")).join(", "):typeof e=="object"?JSON.stringify(e):String(e)}}function Bt(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=zn(Number(o[1]),Number(o[2])-1,1);return It(t.short===!0?{month:"short"}:{month:"short",year:"numeric"}).format(a)}case"day":{let o=Ze.test(e)?B(e):null;return o===null?e:It({day:"numeric",month:"short"}).format(o)}default:return e}}function Un(e){let n=si.exec(e.trim()),t=n?.[1];if(t===void 0||t!=="count"&&n?.[2]===void 0)throw new A(y.invalid.measure(e));return{fn:t,field:n?.[2]??null}}function et(e){let n=ai.exec(e.trim()),t=n?.[1],o=n?.[2];if(t===void 0||o!==void 0&&!oi.includes(o))throw new A(y.invalid.dimension(e));return{field:t,truncation:o??null}}function Hn(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 In(n)??"text"}return typeof n=="boolean"?"boolean":typeof n=="number"?Number.isInteger(n)?"integer":"number":In(n)??"text"}function In(e){return typeof e!="string"?null:Ze.test(e)?B(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 K(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 B(e){let n=Ze.exec(e);if(n?.[1]!==void 0&&n[2]!==void 0&&n[3]!==void 0){let o=zn(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 zn(e,n,t){let o=new Date(2e3,0,1);return o.setFullYear(e,n,t),o}function U(e){let n=t=>String(t).padStart(2,"0");return`${String(e.getFullYear()).padStart(4,"0")}-${n(e.getMonth()+1)}-${n(e.getDate())}`}var Kn={tekst:"text",getal:"number",bedrag:"currency",datum:"date",keuze:"text","ja/nee":"boolean"},Ut=e=>typeof e=="string"&&e!=="",nt=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),tt=(e=[])=>[e].flat().join(",").split(",").map(n=>n.trim());function ui(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||Ut(n.veld))&&typeof n.type=="string"&&nt(Kn,n.type)&&(t===void 0||Array.isArray(t)&&t.every(o=>typeof o=="string"))&&(n.type!=="keuze"||Array.isArray(t)&&t.length>0)&&Ut(n.scherm)&&Ut(n.reden)}function qn(e){let n=[],t=[];for(let o of Array.isArray(e)?e:e==null?[]:[e])(ui(o)?n:t).push(o);return t.length>0&&console.warn(`cube-app.json ontbreekt: ${t.length} malformed entries ignored`,t),n}function Vn(e){return Kn[e]}function rt(e,n){if(e===null)return null;let t=i=>{let r=Vn(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(p=>p.name===r))return[];let c=Vn(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 ci(e){let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619)>>>0;return n}function di(e,n,t){let{veld:o,type:a,waarden:i}=e,r=ci(`${e.resource}.${o}.${String(n)}`);if(o!==void 0){let s=t.filter(l=>nt(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 U(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 Gn(e,n){let t=e?.fields;return Array.isArray(t)?t:t?.[n]}async function Ht(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 ne({[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 zt(e,n,t,o){let{name:a}=e,i=new Map(n.filter(m=>m.resource===a&&m.veld!==void 0).map(m=>[m.veld,m])),r=m=>i.has(/^[-+]?(?:\w+\()?([^.()]*)/.exec(m)?.[1]??""),s=(m={})=>{let f=Gn(m,a),d=f?.filter(k=>!i.has(k)),g=Object.entries(m.filter??{}),w=tt(m.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:{...m,...d&&{fields:d.includes("id")?d:[...d,"id"]},...v(!1)},local:v(!0),shown:k=>f===void 0||f.includes(k)}},l=(m,f,d=!1)=>{for(let[g,w]of i)(d||f(g))&&(!nt(m,g)||m[g]==null)&&(m[g]=di(w,m.id,o))},u=async(m,{local:f,shown:d})=>{let g=m.data;g.forEach(v=>l(v,d,!0)),g.length>0&&(f.sort.length>0||Object.keys(f.filter).length>0)&&(g=await Ht(a,g,f));for(let v of g)for(let k of i.keys())d(k)||delete v[k];let{meta:w}=m;return{...m,data:g,meta:Object.keys(f.filter).length>0?{...w,page:{...w.page,total:g.length,pages:w.page.number}}:w}},c=async(m,f)=>{let d=s(m);return u(await e.list(d.live,f),d)},p=async function*(m,f){let d=s(m);for await(let g of e.pages(d.live,f))yield await u(g,d)};return{...e,list:c,pages:p,async*all(m,f){for await(let d of p(m,f))yield*d.data},async get(m,f,d){let g=s(f),w=await e.get(m,g.live,d);return l(w.data,g.shown),g.shown("id")||delete w.data.id,w},aggregate:(m,f)=>[tt(m.fn).map(d=>d.replace(/^\w+$/,"")),tt(m.group),Object.keys(m.filter??{})].flat().some(r)?t.resource(a).aggregate(m):e.aggregate(m,f)}}function Wn(e,n){let t=d=>String(d.id),o=new Map,a=new Map,i=new Set,r=0,s=(d,g)=>({status:d,data:g,meta:null,headers:new Headers,etag:null,recordVersion:null,location:null,replayed:!1,rateLimit:{limit:null,remaining:null,reset:null}}),l=(d,g)=>{let w=Gn(g,n);return Object.fromEntries(Object.entries(d).filter(([v])=>w?.includes(v)??!0))},u=async(d,g={})=>{let{page:w}=d.meta,v=o.size>0?await Ht(n,[...o.values()].reverse(),g):[],k=new Set(v.map(t)),S=new Set(a.size>0?(await Ht(n,[...a.values()],g)).map(t):[]),D=new Set(d.data.map(t)),M=d.data.filter(R=>!i.has(t(R))&&(!o.has(t(R))||k.has(t(R)))).map(R=>o.get(t(R))??R),P=v.filter(R=>!S.has(t(R))&&!D.has(t(R))),T=w.total-[...S].filter(R=>!k.has(R)).length+P.length,L=w.number===1?[...P,...M]:M,_=tt(g.sort).map(R=>[R.replace(/^[-+]/,""),R.startsWith("-")?-1:1]),x=R=>o.has(t(R))&&(!D.has(t(R))||_.some(([Q])=>a.get(t(R))?.[Q]!==R[Q])),O=L.filter(R=>!x(R));if(_.every(([R])=>O.every(Q=>nt(Q,R)))){for(let R of L.filter(x)){let Q=O.findIndex(V=>_.reduce((Zr,[nn,eo])=>Zr||eo*z(R[nn],V[nn]),0)<0);O.splice(Q>>>0,0,R)}L=O}return{...d,data:L.map(R=>l(R,g)),meta:{...d.meta,page:{...w,total:T}}}},c=async(d,g,w)=>{let v=o.get(String(d));if(i.has(String(d))){let k=`No such ${n} record.`;throw new N(404,new Headers,{status:404,code:"not_found",detail:k})}return v===void 0?e.get(d,g,w):s(200,l(v,g))},p=async d=>{let{data:g}=await c(d);return o.has(String(d))||a.set(String(d),g),g},m=async()=>({...s(202,null),accepted:!0}),f=async function*(d,g){for await(let w of e.pages(d,g))yield await u(w,d)};return{...e,get:c,pages:f,operation:m,collectionOperation:m,list:async(d,g)=>u(await e.list(d,g),d),async*all(d,g){for await(let w of f(d,g))yield*w.data},async create(d){let g={...d,id:`voorbeeld-${++r}`};return o.set(g.id,g),s(201,{...g})},async update(d,g){let w=await p(d),v={...w,...g,id:w.id};return o.set(String(d),v),s(200,{...v})},async delete(d){return await p(d),o.delete(String(d)),i.add(String(d)),s(204,null)}}}var mi="./cube-app.config.json",fi="./cube-mock.json",gi="./cube-app.json",hi="./cube-theme.json",bi={id:"preview",name:Ft,scopes:[]},Jn=null,Yn=null,q=null,Vt=null,ot=null,Qn=0;function Xn(e={}){let n=q!==null&&q===Vt,t=++Qn,o=ki(e,()=>t===Qn);return q=o,Vt=null,o.then(()=>{n&&q===o&&vi()},()=>{q===o&&(q=null)}),o}function yi(){return q!==null?q:(ot??(ot=wi().then(()=>{if(ot=null,q!==null)return q;let e=Xn();return Vt=e,e})),ot)}function wi(){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 vi(){let e=globalThis.document;if(e===void 0)return;let n=e.defaultView?.CustomEvent??CustomEvent;e.dispatchEvent(new n("cube-session-change"))}async function ki(e,n){let t=e.fetch??globalThis.fetch.bind(globalThis),o=e.pageUrl??or(),a=Xe(),[i,r]=await Promise.all([a===null?it(t,De(mi,o)):null,Si(e,t,o)]);return n()&&Nt(r),a!==null?Ai(a,e,t,o):i===null?xi(e,t,o):Ti(Di(i),e,t,o)}async function Si(e,n,t){try{if(e.theme===!1)return ae(null,t);let o=e.theme??Yn;if(o!==null)return ae(o,t);let a=await it(n,De(hi,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 ae(a,t)}catch(o){return console.warn(`cube-theme.json could not be used, the neutral theme applies: ${String(o)}`),ae(null,t)}}async function Zn(e,n,t){let o=e.mock??Jn??await it(n,De(fi,t))??{},a=e.manifest===!1?null:e.manifest??await it(n,De(gi,t));return[o,a]}function er(e,n){let t=e==="wireframe",o=t?qn(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 tr(e,n){let t=new Map;return e?a=>{let i=t.get(a)??Wn(n(a),a);return t.set(a,i),i}:n}async function xi(e,n,t){let[o,a]=await Zn(e,n,t),i=!0,r=()=>{if(!i)throw new N(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=er(a?.soort,a),l=new ne(o,a,r),u=new ne(o,null,r),c=p=>s.isExample(p)?u:l;return{...s,mode:"preview",signInError:null,user:()=>i?{...bi}:null,async signIn(){i=!0},async signOut(){i=!1},resource:tr(s.simulatesWrites,p=>{let m=c(p),f=m.resource(p),d=m.describe(p)?.fields??[],g=s.gaps.filter(({resource:w,veld:v})=>w===p&&v!==void 0&&!d.some(k=>k.name===v));return g.length>0?zt(f,g,u,u.rows(p)):f}),schema:async p=>rt(c(p).describe(p),s.gaps)}}async function nr(e,n,t,o){let[a,i]=e==="wireframe"?await Zn(n,t,o):[{},null];return{marked:er(e,i),examples:new ne(a)}}function rr(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:tr(n.simulatesWrites,i=>n.isExample(i)?t.resource(i):n.gaps.some(r=>r.resource===i)?zt(o.resources(i),n.gaps,t,t.rows(i)):o.resources(i)),async schema(i){if(n.isExample(i))return rt(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:rt(Cn(r),n.gaps)}catch(r){throw a=null,r}}}}async function Ti(e,n,t,o){let a=e.dmpUrl.replace(/\/+$/,""),i=null,r=Mi(n.tokenStorage==="memory"?Ie():Li(`cube-app.tokens.${e.clientId}`),p=>{i=p}),s=an({issuer:e.issuer??a,clientId:e.clientId,redirectUri:De(e.redirectUri,o),scopes:e.scopes,fetch:t,tokenStore:r,...e.metadata!==void 0?{metadata:e.metadata}:{}}),l=xt({baseUrl:e.apiUrl??`${a}/apps/api/v1`,auth:s,fetch:t}),u=null,c=await nr(e.soort,n,t,o);i=await r.get();try{await s.handleCallback()}catch(p){u=p instanceof Error?p:new Error(String(p))}return i===null&&u===null&&n.autoSignIn===!0&&await s.signIn(),rr({mode:"live",client:l,signInError:()=>u,user:()=>i===null?null:Ri(i),async signIn(){u=null,await s.signIn()},async signOut(){await s.signOut()}},c)}function Ci(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 Ai(e,n,t,o){let a=e.token,i=xt({baseUrl:e.apiUrl,auth:()=>a,fetch:Ci(t)}),r=await nr(e.soort??void 0,n,t,o);return rr({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 Ri(e){let n=Ei(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 Ei(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 Di(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 it(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 Mi(e,n){return{async get(){let t=await e.get();return n(t),t},async set(t){await e.set(t),n(t)}}}function Li(e){let n=(()=>{try{return globalThis.sessionStorage??null}catch{return null}})();return n===null?Ie():{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 or(){let e=globalThis;return e.document?.baseURI??e.location?.href??"http://localhost/"}function De(e,n){return new URL(e,n).href}function Fi(e){Jn=e}function Oi(e){Yn=e,Nt(ae(e,or()))}var st=Object.freeze({connect:Xn,ready:yi,mock:Fi,theme:Oi,version:Pn,sdk:"1"});var ir={"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","detail"],"cube-column":["value","label"],"cube-gap-list":["scherm"]};var _i="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))sr(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 ar(e,a,o),a}function H(e,n,t={},...o){let a=e.createElementNS(_i,n);for(let[i,r]of Object.entries(t))sr(i,!0),a.setAttribute(i,String(r));return ar(e,a,o),a}function sr(e,n){let t=e.toLowerCase();if(t==="style"||n&&t.startsWith("on"))throw new A(y.invalid.attribute(e))}function C(e){for(;e.firstChild!==null;)e.removeChild(e.firstChild)}function ar(e,n,t){for(let o of t)typeof o=="string"?n.appendChild(e.createTextNode(o)):o!=null&&o!==!1&&n.appendChild(o)}var Me=`
|
|
3
3
|
:host{display:block;box-sizing:border-box;min-width:0;font-family:var(--cube-font-family,system-ui,sans-serif);
|
|
4
4
|
color:var(--cube-color-text,#1f2328);font-size:1rem;line-height:1.5}
|
|
5
5
|
:host([hidden]){display:none}
|
|
@@ -29,7 +29,7 @@ td.example,dd.example{text-decoration:underline dashed;text-underline-offset:.25
|
|
|
29
29
|
font-weight:600}
|
|
30
30
|
.row{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}
|
|
31
31
|
@media (max-width:640px){.row{flex-direction:column;align-items:stretch}.row>button{width:100%}}
|
|
32
|
-
`,
|
|
32
|
+
`,lr=new WeakMap;function at(e,n){let t=lr.get(e);t===void 0&&(t=new Map,lr.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 Y=class extends Error{constructor(t){super(t.detail??t.kind);b(this,"state");this.state=t}};function X(e){if(e instanceof Y)return e.state;if(j(e)){if(e.status===401)return{kind:"signed-out",detail:null};if(e.status===403)return{kind:"forbidden",detail:null}}return e instanceof A?{kind:"error",detail:e.message}:{kind:"error",detail:null}}function $i(e){return new Promise(n=>{e.readyState==="loading"?e.addEventListener("DOMContentLoaded",()=>n(),{once:!0}):(e.defaultView?.setTimeout??setTimeout)(n,0)})}function lt(e){return h(e,"span",{class:"badge example"},y.example,h(e,"span",{class:"sr-only"},y.exampleMissing.slice(y.example.length)))}function Pi(e){return e!==null&&typeof e=="object"&&e.name==="AbortError"}function ur(e,n={}){let t=n.session??(()=>st.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===""?[at(e,Me)]:[at(e,Me),at(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[...ir[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 $i(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||Pi(l))return;this.badge?.remove(),this.showState(X(l)),l instanceof TypeError&&!(l instanceof A)&&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 A(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 A(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 Ni=`
|
|
33
33
|
:host{background:var(--cube-color-bg)}
|
|
34
34
|
header{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem 1rem;padding:.75rem 1.5rem;
|
|
35
35
|
border-bottom:1px solid var(--cube-color-border);background:var(--cube-color-surface)}
|
|
@@ -46,12 +46,12 @@ border-bottom-color:var(--cube-color-primary)}
|
|
|
46
46
|
main{padding:1.5rem}
|
|
47
47
|
::slotted(cube-page:not([hidden])){display:flex;flex-direction:column;gap:1.5rem}
|
|
48
48
|
@media (max-width:640px){header{padding:.75rem 1rem}nav{padding:0}main{padding:1rem}}
|
|
49
|
-
`,
|
|
49
|
+
`,Kt="#/";function cr(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=Je(()=>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")??Qe().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(Kt))try{l=decodeURIComponent(s.slice(Kt.length).split("?")[0]??"")}catch{l=""}let u=i.find(p=>p.getAttribute("name")===l)??i[0];for(let p of i)p.hidden=p!==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(p=>[p.getAttribute("name"),p.getAttribute("label")]));if(c!==this.built){C(this.list);for(let p of i){let m=p.getAttribute("name")??"",f=Kt+encodeURIComponent(m),d=h(n.document,"a",{href:f},p.getAttribute("label")??m);this.list.appendChild(h(n.document,"li",{},d))}this.built=c}Array.from(this.list.querySelectorAll("a")).forEach((p,m)=>{i[m]===u?p.setAttribute("aria-current","page"):p.removeAttribute("aria-current")})}}return b(t,"tag","cube-app-shell"),b(t,"css",Ni),t}var ji=/^([a-z][a-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)$/,qt=200;function ge(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 A(y.invalid.json(e.localName,"filter"));return t}function Ii(e){let n=e;return typeof n?.from=="string"&&typeof n.to=="string"&&typeof n.previous?.from=="string"&&typeof n.previous.to=="string"}function ut(e,n){let t=B(n.to);if(t===null)throw new A(y.invalid.periodEnd(n.to));return t.setDate(t.getDate()+1),{[e]:{gte:n.from,lt:U(t)}}}async function ct(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 A(y.invalid.periodSource(n));let a=t;if(await a.updateComplete,!Ii(a.value))throw new A(y.invalid.periodSource(n));return a}function dt(e,n,t){if(e!==null&&e!=="")return e;if(n!==null&&n!==""){let o=et(n);if(o.truncation!==null)return o.field}throw new A(y.invalid.dateField(t))}async function dr(e,n,t,o){let a=ji.exec(n),i=a?.[1],r=a?.[2];if(i===void 0||r===void 0)throw new A(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+=qt){o.throwIfAborted();let c=s.slice(u,u+qt),p;try{let m={filter:{id:{in:c}},fields:["id",r],page:{size:qt}};({data:p}=await e.resource(i).list(m,{signal:o}))}catch(m){if(o.aborted||m?.name==="AbortError")throw m;continue}for(let m of p){let f=m[r];f!=null&&l.set(String(m.id),String(f))}}return l}var Bi=["number","integer","currency","percent"],$=`
|
|
50
50
|
.card{padding:1rem 1.25rem;border:1px solid var(--cube-color-border);border-radius:var(--cube-radius);
|
|
51
51
|
background:var(--cube-color-surface)}
|
|
52
|
-
`,
|
|
52
|
+
`,he=`
|
|
53
53
|
.label{margin:0 0 .5rem;font-weight:600}
|
|
54
|
-
`;function
|
|
54
|
+
`;function F(e,n){let t=e.getAttribute(n)?.trim()??"";if(t==="")throw new A(y.invalid.missing(e.localName,n));return t}function be(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 Le(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 G=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 ye(e,n,t,o=null){let a=Un(F(e,"measure")),i=ge(e),r=e.getAttribute("period"),s=r===null||r===""?null:dt(e.getAttribute("date-field"),o,e.localName),l=await ct(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,...ut(s,u)}})}async function pt(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 j(i)&&i.status===422&&(i.reason==="too_many_groups"||i.code==="cardinality_exceeded")?new Y({kind:"error",detail:y.tooManyGroups,retry:!1}):i}}function Z(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 mt(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:Le(c[o.fn])})).filter(c=>c.value!==null).sort((c,p)=>r*(c.value-p.value)).slice(0,a.limit),l=e.getAttribute("lookup"),u=l===null||l===""||s.length===0?null:await dr(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 we(e,n){let t=e.getAttribute("format"),o=t!==null&&Bi.includes(t)?t:n?"integer":"number",a=e.getAttribute("currency")||"EUR";return(i,r)=>I(i,o,{currency:a,compact:r===!0})}var Fe=Symbol("cube-field hidden");function pr(e){var n,t;return class extends(t=e.HTMLElement,n=Fe,t){constructor(){super(...arguments);b(this,n)}connectedCallback(){this[Fe]===void 0&&(this[Fe]=this.hasAttribute("hidden")),this.hidden=!0}}}function ft(e){let n=e.field?.enum??null;return e.config?.options??(n===null?null:n.map(t=>({value:t,label:t})))}var Ui=["text","number","integer","currency","percent","date","datetime","boolean"];function ee(e){let n=(e??"").split(",").map(t=>t.trim()).filter(t=>t!=="");return n.length>0?n:null}function Gt(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 W(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[Fe];n.set(o,{name:o,label:t.getAttribute("label"),format:a!==null&&Ui.includes(a)?a:null,multiline:t.hasAttribute("multiline"),options:Gt(t.getAttribute("options")),hidden:i??t.hasAttribute("hidden")})}return n}function Oe(e,n){return e.get(n)?.label??K(n)}function te(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:Oe(t,r),format:l?.format??Hn(s,o?.[r]),field:s,config:l}})}var ve=`
|
|
55
55
|
.field{display:flex;flex-direction:column;gap:.25rem;min-width:0}
|
|
56
56
|
.field label{font-weight:600}
|
|
57
57
|
.field .required{font-weight:400;color:var(--cube-color-text-muted)}
|
|
@@ -59,7 +59,7 @@ background:var(--cube-color-surface)}
|
|
|
59
59
|
.field.check input{min-height:auto;width:1.25rem;height:1.25rem}
|
|
60
60
|
.field [aria-invalid=true]{border-color:var(--cube-color-danger,#b42318)}
|
|
61
61
|
.field-error{margin:0;color:var(--cube-color-danger,#b42318);font-size:.875rem}
|
|
62
|
-
`,Hi=/^-?(\d{1,3}(\.\d{3})+|\d*)(,\d+)?$/,zi=/^-?[1-9]\d{0,2}(\.\d{3})+$/,Vi=/^-?(\d+\.?\d*|\.\d+)$/,Ki=0;function qi(e){return e.includes(",")?Hi.test(e)&&/\d/.test(e)?Number(e.replace(/\./g,"").replace(",",".")):null:zi.test(e)?Number(e.replace(/\./g,"")):Vi.test(e)?Number(e):null}var
|
|
62
|
+
`,Hi=/^-?(\d{1,3}(\.\d{3})+|\d*)(,\d+)?$/,zi=/^-?[1-9]\d{0,2}(\.\d{3})+$/,Vi=/^-?(\d+\.?\d*|\.\d+)$/,Ki=0;function qi(e){return e.includes(",")?Hi.test(e)&&/\d/.test(e)?Number(e.replace(/\./g,"").replace(",",".")):null:zi.test(e)?Number(e.replace(/\./g,"")):Vi.test(e)?Number(e):null}var mr=e=>Number(e.toPrecision(12));function _e(e,n){if(e.trim()==="")return{value:null};if(re.includes(n)){let t=qi(e.replace(/[\s €%]/g,""));return t===null||!Number.isFinite(t)?{error:y.notANumber}:n==="integer"&&!Number.isInteger(t)?{error:y.notAnInteger}:{value:n==="percent"?mr(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 fr(e){if(!j(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 Gi(e,n){if(e==null)return"";if(re.includes(n)){let t=typeof e=="number"?e:Number(e);return typeof e=="boolean"||!Number.isFinite(t)?String(e):String(n==="percent"?mr(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`${U(o)}T${a(o.getHours())}:${a(o.getMinutes())}`}return typeof e=="object"?JSON.stringify(e):String(e)}function Wi(e,n,t,o){let a=ft(n),i=Gi(t,n.format);if(a!==null){let u=a.some(m=>m.value===i),c=i===""||u?a:[...a,{value:i,label:i}],p=h(e,"select",{id:o,name:n.name},h(e,"option",{value:""},y.emptyValue),...c.map(m=>h(e,"option",{value:m.value},m.label)));return p.value=i,p}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=re.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 ke(e,n,t,o){let a=`cube-input-${++Ki}`,i=Wi(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}:_e(i.value,n.format)},setError(p){u.textContent=p??"",u.hidden=p===null,p===null?(i.removeAttribute("aria-invalid"),i.removeAttribute("aria-describedby")):(i.setAttribute("aria-invalid","true"),i.setAttribute("aria-describedby",u.id))}}}var Se=`
|
|
63
63
|
form{display:flex;flex-direction:column;gap:1rem}
|
|
64
64
|
.actions{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:1rem}
|
|
65
65
|
.alert{margin:0 0 1rem;padding:.75rem 1rem;border:1px solid var(--cube-color-danger,#b42318);
|
|
@@ -69,7 +69,7 @@ border-radius:var(--cube-radius-small)}
|
|
|
69
69
|
.alert button{margin-top:.5rem}
|
|
70
70
|
.status{margin:.5rem 0 0}
|
|
71
71
|
.status:empty{margin:0}
|
|
72
|
-
`;function
|
|
72
|
+
`;function xe(e,n){return e?.body===n?e:{key:dn(),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 gt(e,n,t,o,a){let i=fr(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=X(t).kind;$e(e,n,r==="forbidden"?y.forbidden:r==="signed-out"?y.signedOut:y.saveFailed)}function ue(e){let n=e?.user()??null;return n===null?null:String(n.id)}var Qi=`${$}${Se}
|
|
73
73
|
.board{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(14rem,1fr);gap:1rem;
|
|
74
74
|
position:relative;overflow-x:auto}
|
|
75
75
|
@media (max-width:640px){.board{grid-auto-flow:row;grid-auto-columns:auto}}
|
|
@@ -89,7 +89,7 @@ dd{margin:0;min-width:0}
|
|
|
89
89
|
.moves button::before{content:"\\2192 "}
|
|
90
90
|
.muted{margin:.5rem 0 0}
|
|
91
91
|
.not-saved{display:inline-block;margin-bottom:.75rem}
|
|
92
|
-
`,
|
|
92
|
+
`,ht=e=>String(e.id);function Ji(e){return e.split(",").map(n=>n.trim()).filter(n=>n!=="").map(n=>({field:n.replace(/^[-+]/,""),descending:n.startsWith("-")}))}function Yi(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 Xi(e,n,t){for(let{field:o,descending:a}of e){let i=Yi(n[o],t[o]);if(i!==0)return a?-i:i}return 0}function gr(e,n){return e.numeric&&Number.isFinite(Number(n))?Number(n):n}function Zi(e){if(j(e)&&(e.status===409||e.status===412))return y.changedMeanwhile;let n=X(e).kind;return n==="forbidden"?y.forbidden:n==="signed-out"?y.signedOut:y.tryAgain}function hr(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);b(this,"shownResource",null);b(this,"chosen",null);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");l!==this.shownResource&&(this.chosen=null,this.shownResource=l),this.detailTarget();let p=ge(this),m=Math.min(Z(this,"page-size",1,50),200),f=this.attr("sort")?.trim()??"",d=Ji(f),g=await s.schema(l);if(r.aborted)return;let w=g?.fields.find(L=>L.name===u),v=g===null||g.fields.some(L=>L.name==="id"),k=ee(this.attr("fields")),S=k===null?[]:te(g,k,W(this)),D={fields:[...new Set([...v?["id"]:[],c,u,...S.map(L=>L.name),...d.map(L=>L.field)])],page:{size:m}};f!==""&&(D.sort=f);let M=s.resource(l),P=await Promise.all(this.columnValues(w?.enum??null).map(async L=>{let{data:_,meta:x}=await M.list({...D,filter:{...p,[u]:L.value}},{signal:r});return{...L,rows:[..._],total:x.page?.total??_.length}}));if(r.aborted)return;let T={session:s,user:ue(s),resource:l,status:u,title:c,fields:S,columns:P,canMove:v&&g!==null&&g.actions.includes("update")&&w?.readonly===!1,order:d,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()||K(c)}}):(r??[]).map(u=>({value:u,label:K(u)}));if(l.length===0)throw new Y({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:p=>{r.canMove&&this.dragged!==null&&p.preventDefault()},ondrop:p=>{p.preventDefault();let m=this.dragged;this.dragged=null,m!==null&&this.move(r,m,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(p=>this.card(r,s,p,l)),c>0?h(t,"p",{class:"muted"},y.more(c)):null)}card(r,s,l,u){let c=ht(l),p=`b${++this.ids}`,m=l.id!=null&&c===this.chosen,f=h(t,"article",{tabindex:"0",draggable:r.canMove?"true":"false","data-id":c,"aria-labelledby":p,class:m?"chosen":null,"aria-current":m?"true":null,onclick:d=>{d.target.closest("button")===null&&this.select(r,l)},onkeydown:(d=>{d.target!==f||d.altKey||d.ctrlKey||d.metaKey||d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),this.select(r,l))}),ondragstart:d=>{this.dragged=c,d.dataTransfer?.setData("text/plain",c)},ondragend:()=>{this.dragged=null}},h(t,"p",{class:"title",id:p},I(l[r.title],"text")),r.fields.length===0?null:h(t,"dl",{},...r.fields.flatMap(d=>[h(t,"dt",{},d.label),h(t,"dd",{},I(l[d.name],d.format))])),r.canMove?h(t,"div",{class:"moves"},...r.columns.filter(d=>d!==s).map(d=>h(t,"button",{type:"button",class:"secondary","aria-label":y.moveTo(d.label),"aria-describedby":p,onclick:()=>this.move(r,c,d.value)},d.label))):null);return u.set(c,f),f}detailTarget(){let r=this.attr("detail")?.trim()??"";if(r==="")return null;try{return t.querySelector(r)}catch{throw new A(y.invalid.selector(this.localName,"detail",r))}}select(r,s){let l=s.id??null;this.chosen=l===null?null:String(l);for(let c of Array.from(this.body.querySelectorAll("article"))){let p=c.getAttribute("data-id")===this.chosen;c.classList.toggle("chosen",p),p?c.setAttribute("aria-current","true"):c.removeAttribute("aria-current")}if(this.emit("cube-select",{resource:r.resource,id:l,row:s}),l===null)return;let u=null;try{u=this.detailTarget()}catch(c){this.showState(X(c));return}u?.setAttribute("record-id",String(l))}place(r,s,l){let u=r.columns.find(c=>c.value===l);for(let c of r.columns){let p=c.rows.findIndex(f=>ht(f)===s),m=c.rows[p];if(!(m===void 0||u===void 0)){if(c.rows.splice(p,1),c.total--,m[r.status]=gr(r,l),r.order.length===0)u.rows.unshift(m);else{let f=u.rows.findIndex(d=>Xi(r.order,d,m)>0);u.rows.splice(f===-1?u.rows.length:f,0,m)}return u.total++,{row:m,from:c.value}}}return null}move(r,s,l){let u=r.columns.find(w=>w.rows.some(v=>ht(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:p,from:m}=c;this.alert.hidden=!0,this.focusKey=s,this.render(r);let f=this.tracks.get(s);f===void 0&&(f={confirmed:m,tail:Promise.resolve(),generation:0},this.tracks.set(s,f));let d=f,g=d.generation;this.pending++,d.tail=d.tail.then(()=>g===d.generation?this.send(r,d,p,m,l):void 0).finally(()=>{--this.pending===0&&this.stale&&this.refresh()})}async send(r,s,l,u,c){let p=ht(l),m={[r.status]:gr(r,c)},f=xe(this.attempt,JSON.stringify([r.resource,p,m]));this.attempt=f;try{let d=await this.session();if(ue(d)!==r.user){s.generation++,this.stale=!0;return}await d.resource(r.resource).update(l.id,m,{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(d){if(j(d)&&this.attempt===f&&(this.attempt=null),s.generation++,j(d)&&(d.status===409||d.status===412)&&(this.stale=!0),this.loaded!==r)return;this.place(r,p,s.confirmed),this.focusKey=p,this.render(r),C(this.alert),this.alert.append(`${y.moveFailed} ${Zi(d)}`),this.alert.hidden=!1}}}return b(o,"tag","cube-board"),b(o,"css",Qi),b(o,"reloadsOnOwnChange",!1),o}var es=`${$}${he}${ve}
|
|
93
93
|
.inputs{display:grid;gap:1rem;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))}
|
|
94
94
|
.inputs:empty{display:none}
|
|
95
95
|
.results{display:flex;flex-wrap:wrap;gap:1rem 2rem;margin-top:1.25rem;padding-top:1rem;
|
|
@@ -101,7 +101,7 @@ border-top:1px solid var(--cube-color-border)}
|
|
|
101
101
|
.result.emphasis output{font-size:2rem;font-weight:700;line-height:1.2}
|
|
102
102
|
.alert{margin:1rem 0 0;color:var(--cube-color-danger,#b42318)}
|
|
103
103
|
.alert:empty{margin:0}
|
|
104
|
-
`,ts=["number","integer","currency","percent","text","select","checkbox"],ns=["number","integer","currency","percent","text"],
|
|
104
|
+
`,ts=["number","integer","currency","percent","text","select","checkbox"],ns=["number","integer","currency","percent","text"],br=0;function yr(e,n,t){let o=e.getAttribute(n)?.trim()??"",a=o===""?t[0]:o;if(!t.includes(a))throw new A(y.invalid.value(e.localName,n,a));return a}function Wt(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 A(y.invalid.number(e.localName,n));return o}var Pe=e=>I(e,"number");function wr(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(Pe(a)):a===null?y.atLeast(Pe(o)):y.range(Pe(o),Pe(a))};if(i!==null){let r=(t-(o??0))/i;if(Math.abs(r-Math.round(r))>1e-9)return{error:y.step(Pe(i))}}return n}function vr(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 Y({kind:"error",detail:y.invalid.formula,retry:!1});let u=Array.from(this.children),c=u.filter(w=>w.localName==="cube-input").map(i),p=u.filter(w=>w.localName==="cube-result").map(r);if(p.length===0)throw new A(y.invalid.missing(this.localName,"cube-result"));a("cube-input",c.map(w=>w.editor.name)),a("cube-result",p.map(w=>w.name));let m=this.attr("label"),f=m===null||m.trim()===""?null:h(t,"p",{class:"label",id:`cube-calc-${++br}`},m),d=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"},...p.map(w=>w.element)),d);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:m,inputs:c,results:p,alert:d},this.showErrors(),this.calculate(!1)}showErrors(){for(let u of this.drawn?.inputs??[]){let c=wr(u);u.shown="error"in c,u.editor.setError("error"in c?c.error:null)}}calculate(u,c=!1){let p=this.drawn;if(p===null)return;let m={};for(let g of p.inputs){let w=wr(g);m[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={},d=!1;try{let g=this.formula,w=g===null?null:g({...m});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&&p.results.length>1){if(c)throw new A(y.invalid.calcSingle);this.drawn=null,this.showState({kind:"error",detail:y.invalid.calcSingle,retry:!1});return}for(let k of p.results){let S=v?w:w[k.name],D=typeof S=="number"&&!Number.isFinite(S)||k.format!=="text"&&typeof S=="object"&&S!==null;d||(d=D),f[k.name]=D||S===void 0?null:S}}catch(g){p.alert.textContent===""&&console.warn(g),d=!0;for(let w of p.results)f[w.name]=null}for(let g of p.results)g.output.textContent=I(f[g.name],g.format,{currency:g.currency});d&&p.alert.textContent===""&&(p.alert.textContent=y.calcFailed),d||(p.alert.textContent=""),this.shownValues=m,this.shownResults=f,u&&this.emit("cube-change",{values:{...m},results:{...f}})}}b(o,"tag","cube-calc"),b(o,"css",es),b(o,"needsSession",!1);function a(s,l){let u=l.find((c,p)=>l.indexOf(c)!==p);if(u!==void 0)throw new A(y.invalid.duplicate(s,u))}function i(s){let l=F(s,"name"),u=F(s,"label"),c=yr(s,"type",ts),p=c==="select"?"text":c==="checkbox"?"boolean":c,m=c==="checkbox"?null:Gt(s.getAttribute("options"));if(c==="select"&&m===null)throw new A(y.invalid.missing(s.localName,"options"));let f=s.getAttribute("value"),d=f===null?{value:null}:_e(f,p);return{editor:ke(t,{name:l,label:u,format:p,field:void 0,config:{name:l,label:u,format:p,multiline:!1,options:m,hidden:!1}},"error"in d?f:d.value,!1),format:p,min:Wt(s,"min"),max:Wt(s,"max"),step:Wt(s,"step"),shown:!1}}function r(s){let l=F(s,"name"),u=F(s,"label"),c=yr(s,"format",ns),p=s.getAttribute("currency")?.trim().toUpperCase()||"EUR";try{I(0,"currency",{currency:p})}catch{throw new A(y.invalid.value(s.localName,"currency",p))}let m=`cube-result-${++br}`,f=h(t,"output",{id:m,name:l}),d=s.hasAttribute("emphasis")&&s.getAttribute("emphasis")!=="false",g=h(t,"div",{class:d?"result emphasis":"result"},h(t,"label",{for:m},u),f);return{name:l,format:c,currency:p,element:g,output:f}}return o}var Ne=56,Qt=8,kr=8,rs=24,Jt=7,Sr=8;function os(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 is(e,n,t,o){let a=Math.max(1,Math.floor(t/Jt)),i=n.length<=a?n:`${n.slice(0,a-1)}\u2026`,r=i.length*Jt/2,s=Math.min(Math.max(o.x,o.left+r),o.right-r),l=H(e,"text",{class:"x",x:s,y:o.y},i);return i!==n&&l.append(H(e,"title",{},n)),l}function xr(e,n,t,o){let{width:a,height:i}=t,r=n.points.map(T=>T.value??0),s=os(Math.min(...r),Math.max(...r)),l=s[0]??0,u=(s.at(-1)??1)-l||1,c=i-kr-rs,p=Math.max(a-Ne-Qt,1),m=n.points.length,f=p/Math.max(m,1),d=T=>kr+c*(1-(T-l)/u),g=T=>Ne+f*(T+.5),w=H(e,"svg",{viewBox:`0 0 ${a} ${i}`,width:"100%",height:i,role:"img","aria-label":`${n.label}, ${y.points(m)}`});for(let T of s)w.append(H(e,"line",{class:"grid",x1:Ne,x2:a-Qt,y1:d(T),y2:d(T)}),H(e,"text",{class:"tick",x:Ne-6,y:d(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(m/Math.max(1,Math.floor(p/(k*Jt+Sr)))),D=n.points.map((T,L)=>L).filter(T=>T%S===0),M=f*S-Sr/2;for(let T of D){let L={x:g(T),y:i-6,left:Ne,right:a-Qt};w.append(is(e,v[T]??"",M,L))}return{root:w,band:f,x:g,y:d,title:T=>H(e,"title",{},`${T.label}: ${T.value===null?y.emptyValue:o(T.value)}`)}}function Tr(e,n,t,o){let{root:a,x:i,y:r,title:s}=xr(e,n,t,o),l="",u="M";return n.points.forEach((c,p)=>{if(c.value===null){u="M";return}l+=`${u}${i(p).toFixed(1)} ${r(c.value).toFixed(1)}`,u="L"}),a.append(H(e,"path",{class:"s1",d:l})),n.points.forEach((c,p)=>{c.value!==null&&a.append(H(e,"circle",{class:"s1",cx:i(p),cy:r(c.value),r:3},s(c)))}),a}function Cr(e,n,t,o){let{root:a,band:i,x:r,y:s,title:l}=xr(e,n,t,o),u=i*.7;return n.points.forEach((c,p)=>{let m=s(Math.max(c.value??0,0)),f=s(Math.min(c.value??0,0));a.append(H(e,"rect",{class:"s1",x:r(p)-u/2,y:m,width:u,height:f-m},l(c)))}),a}var Yt=864e5,ss=600,as=["line","bar"],ls=`${$}${he}
|
|
105
105
|
svg{display:block;overflow:visible}
|
|
106
106
|
.grid{stroke:var(--cube-color-border)}
|
|
107
107
|
.tick,.x{font-size:12px;fill:var(--cube-color-text-muted)}
|
|
@@ -109,11 +109,11 @@ svg{display:block;overflow:visible}
|
|
|
109
109
|
.x{text-anchor:middle}
|
|
110
110
|
rect.s1,circle.s1{fill:var(--cube-color-series-1)}
|
|
111
111
|
path.s1{fill:none;stroke:var(--cube-color-series-1);stroke-width:2}
|
|
112
|
-
`;function us(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)*
|
|
112
|
+
`;function us(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)*Yt),a=o.getUTCFullYear(),i=1+Math.floor((o.getTime()-Date.UTC(a,0,1))/(7*Yt));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 cs(e,n){let t=Bt(e,"month",{short:!0});return n||e.endsWith("-01")?y.monthYear(t,e.slice(0,4)):t}function Ar(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+=Yt)o.add(us(new Date(i),t));return[...o]}function Rr(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new G(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 be(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}=et(l),p=Z(this,"height",80,240),m=Z(this,"limit",1,12),f=await ye(this,this.period,i,l);if(f===null)return;let{fn:d,period:g}=f,{data:w}=await pt(r,s,l,f,i);if(i.aborted)return;let v=w.filter(M=>M[l]!==null&&M[l]!==void 0);if(v.length===0){this.showState("empty");return}let k;if(c!==null){let M=new Map(v.map(_=>[String(_[l]),Le(_[d])])),P=g===null?[...M.keys()].sort():Ar(g.from,g.to,c),T=g?.today??g?.to??"",L=g===null||T<g.from?new Set:new Set(Ar(g.from,T<g.to?T:g.to,c));k=P.map((_,x)=>({key:_,label:Bt(_,c),...c==="month"?{tick:cs(_,x===0)}:{},value:g===null||!L.has(_)?M.get(_)??null:M.get(_)??0}))}else{let M=await mt(this,r,v,{by:l,fn:d},{descending:!0,limit:m},i);if(M===null)return;if(M.length===0){this.showState("empty");return}k=M}let S=this.attr("label")??K(f.field??d),D=this.attr("kind");this.render({label:S,points:k,categories:c===null},p,{line:as.includes(D??"")?D==="line":c!==null,format:we(this,f.count),byLabel:K(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)||ss;this.drawn=u,C(this.plot),this.plot.appendChild((s?Tr:Cr)(n.document,i,{width:u,height:r},l))}}return b(t,"tag","cube-chart"),b(t,"css",ls),t}var ds=`${$}${ve}${Se}
|
|
113
113
|
dl{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.5rem 1rem;margin:0}
|
|
114
114
|
dt{font-weight:600}
|
|
115
115
|
dd{margin:0;min-width:0;overflow-wrap:anywhere}
|
|
116
|
-
`,
|
|
116
|
+
`,Er=e=>e.field!==void 0&&!e.field.readonly;function ps(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 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,"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===ue(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 p=await s.schema(l);if(r.aborted)return;let m=ee(this.attr("fields")),f=await s.resource(l).get(u,m===null?{}:{fields:m},{signal:r});if(r.aborted)return;let d=f.data,g={session:s,resource:l,id:u,columns:te(p,m,W(this),d),row:d,version:f.recordVersion,canEdit:this.flag("editable")&&this.allowsUpdate(p)};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(Er)?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?[" ",lt(t)]:[]),h(t,"dd",{class:l?"example":null},I(r.row[s.name],s.format))]}startEditing(r){this.editing={resource:r.resource,id:r.id,user:ue(r.session)},this.status.textContent="";let s=[],l=r.columns.map(f=>{if(!Er(f))return h(t,"dl",{},...this.pair(r,f));let d=ke(t,f,r.row[f.name],f.field?.nullable===!1);return s.push(d),d.element}),u=h(t,"div",{class:"alert",role:"alert",tabindex:"-1",hidden:!0}),c=h(t,"button",{type:"submit"},y.save),p=h(t,"button",{type:"button",class:"secondary",onclick:()=>{this.editing=null,this.attempt=null,this.renderView(r),this.edit?.focus()}},y.cancel),m=h(t,"form",{novalidate:!0},u,...l,h(t,"div",{class:"actions"},c,p,this.notSaved(r.session)));m.addEventListener("submit",f=>{f.preventDefault(),this.save(r,s,{alert:u,save:c,cancel:p})}),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},m)),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 d=f.read(),g=r.columns.find(w=>w.name===f.name);if("error"in d){f.setError(d.error),c=!0;continue}f.setError(null),ps(g,r.row[f.name],d.value)||(u[f.name]=d.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 p=JSON.stringify([r.resource,r.id,u]);this.attempt=xe(this.attempt,p);let m={idempotencyKey:this.attempt.key};r.version!==null&&(m.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!==ue(f)){this.editing=null,this.refresh();return}let d=await f.resource(r.resource).update(r.id,u,m);this.attempt=null;let g=d.data;if(this.loaded===r&&this.editing!==null){this.editing=null;let w={...r.row,...u,...g},v={...r,row:w,version:d.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(j(r)&&(this.attempt=null),j(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,gt(t,l.alert,r,s,u=>Oe(W(this),u))}}return b(o,"tag","cube-detail"),b(o,"css",ds),o}var ms=`${$}${ve}${Se}`,fs=["resource","fields","submit-label","success-text"];function Lr(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([...fs.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(d=>!d.readonly&&d.name!=="id"),m=(ee(this.attr("fields"))??c.map(d=>d.name)).filter(d=>c.some(g=>g.name===d)),f=te(u,m,W(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(m=>ke(t,m,null,m.field?.nullable===!1&&m.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)),p=h(t,"form",{novalidate:!0},u,...l.map(m=>m.element),h(t,"div",{class:"actions"},c,this.notSaved(s.session)));p.addEventListener("submit",m=>{m.preventDefault(),this.submit(s,l,u,c)}),C(this.body),this.body.appendChild(h(t,"div",{class:"card"},p)),r&&Mr(l[0])?.focus()}async submit(r,s,l,u){if(u.disabled)return;let c={},p=null;for(let f of s){let d=f.read();f.setError("error"in d?d.error:null),"error"in d?p??(p=f):d.value!==null&&(c[f.name]=d.value)}if(p!==null){l.hidden=!0,Mr(p)?.focus();return}this.attempt=xe(this.attempt,JSON.stringify([r.resource,c]));let m=this.attempt.key;u.disabled=!0,l.hidden=!0;try{let d=await(await this.session()).resource(r.resource).create(c,{idempotencyKey:m});this.attempt=null;let g=d.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(j(f)&&(this.attempt=null),this.drawn!==r)return;u.disabled=!1,gt(t,l,f,s,d=>Oe(W(this),d))}}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",ms),o}function Mr(e){return e?.element.querySelector("input,select,textarea")??null}var gs=`${$}
|
|
117
117
|
ul{list-style:none;margin:0;padding:0;display:grid;gap:.75rem}
|
|
118
118
|
h3{margin:0 0 .5rem;font-size:1rem;overflow-wrap:anywhere}
|
|
119
119
|
dl{margin:0;display:grid;gap:.375rem}
|
|
@@ -121,14 +121,14 @@ dl div{display:flex;flex-wrap:wrap;gap:0 .75rem}
|
|
|
121
121
|
dt{flex:0 0 8rem;font-weight:600}
|
|
122
122
|
dd{flex:1 1 12rem;margin:0;min-width:0;overflow-wrap:break-word}
|
|
123
123
|
p{margin:0}
|
|
124
|
-
`;function
|
|
124
|
+
`;function Fr(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,p)=>h(t,"div",{},h(t,"dt",{},c),h(t,"dd",{},p));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",gs),o}var Or=new Intl.NumberFormat("nl-NL",{minimumFractionDigits:1,maximumFractionDigits:1}),hs=`${$}
|
|
125
125
|
.kpi{display:flex;flex-direction:column;gap:.25rem}
|
|
126
126
|
.label{margin:0;font-size:.875rem;font-weight:600;color:var(--cube-color-text-muted)}
|
|
127
127
|
.value{margin:0;font-size:2rem;font-weight:700;line-height:1.2;overflow-wrap:anywhere}
|
|
128
128
|
.compare{margin:0;font-size:.875rem;color:var(--cube-color-text-muted)}
|
|
129
129
|
.compare.up{color:var(--cube-color-success)}
|
|
130
130
|
.compare.down{color:var(--cube-color-danger)}
|
|
131
|
-
`;function _r(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new G(this))}shownFields(){return
|
|
131
|
+
`;function _r(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new G(this))}shownFields(){return be(this)}async load(i,r){if(r===null)return;let s=F(this,"resource");if(this.flag("compare")&&!this.attr("period"))throw new A(y.invalid.compare(this.localName));let l=await ye(this,this.period,i);if(l===null)return;let{fn:u,period:c}=l,p=r.resource(s),m=async w=>{let{data:v}=await p.aggregate({fn:u,filter:l.filterFor(w)},{signal:i});return Le(v[0]?.[u])},f=this.flag("compare")?c?.previous??null:null,[d,g]=await Promise.all([m(c),f===null?null:m(f)]);i.aborted||this.render(d,f===null?void 0:g,l.count)}render(i,r,s){let l=n.document,u=we(this,s),c=this.attr("label"),p=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),p,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=Or.format(Math.abs(l)*100);if(u===Or.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",hs),t}var bs=864e5;function oe(e,n,t){let o=new Date(2e3,0,1);return o.setFullYear(e,n,t),o}function yt(e,n){return{from:U(e),to:U(n)}}function bt(e,n,t){let o=e.getFullYear(),a=e.getMonth()+n;return yt(oe(o,a,1),oe(o,a+t,0))}function ys(e,n){return Math.round((Date.UTC(n.getFullYear(),n.getMonth(),n.getDate())-Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()))/bs)+1}function Xt(e,n,t){switch(e){case"this-month":return{key:e,...bt(n,0,1),previous:bt(n,-1,1)};case"12m":return{key:e,...bt(n,-11,12),previous:bt(n,-23,12)};case"this-year":{let o=n.getFullYear();return{key:e,...yt(oe(o,0,1),oe(o,11,31)),previous:yt(oe(o-1,0,1),oe(o-1,11,31))}}case"custom":{let o=t===void 0?null:B(t.from),a=t===void 0?null:B(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=ys(o,a);return{key:e,from:t.from,to:t.to,previous:yt(oe(o.getFullYear(),o.getMonth(),o.getDate()-i),oe(o.getFullYear(),o.getMonth(),o.getDate()-1))}}}}var Zt=["this-month","12m","this-year","custom"],$r="12m",ws=`
|
|
132
132
|
.picker{display:flex;flex-wrap:wrap;align-items:flex-end;gap:.75rem}
|
|
133
133
|
.field{display:flex;flex-direction:column;gap:.25rem;min-width:0}
|
|
134
134
|
label{font-weight:600;font-size:.875rem}
|
|
@@ -138,15 +138,15 @@ label{font-weight:600;font-size:.875rem}
|
|
|
138
138
|
.custom .error:empty{flex-basis:0}
|
|
139
139
|
input[aria-invalid=true]{border:2px solid var(--cube-color-danger)}
|
|
140
140
|
@media (max-width:640px){.picker,.custom{flex-direction:column;align-items:stretch}}
|
|
141
|
-
`;function
|
|
141
|
+
`;function Pr(e,n,t,o){return h(e,"div",{class:"field"},h(e,"label",{for:n},t),o)}function Nr(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()},...Zt.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},Pr(i,"from",y.period.from,this.from),Pr(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?Xt("custom",r,this.range):Xt(i==="custom"?$r:i,r),today:U(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 Zt.includes(i)?i:$r}today(){let i=this.attr("today");return(i===null?null:B(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;Zt.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=B(i.from),s=B(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",ws),b(t,"needsSession",!1),t}var vs=["loading","empty","error","forbidden","signed-out"],ks={loading:y.loading,empty:y.empty,error:y.error,forbidden:y.forbidden,"signed-out":y.signedOut},Ss=`
|
|
142
142
|
.state{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:1rem;border:1px solid var(--cube-color-border);
|
|
143
143
|
border-radius:var(--cube-radius);background:var(--cube-color-surface)}
|
|
144
144
|
.state[data-kind=error]{border-left:4px solid var(--cube-color-danger)}
|
|
145
145
|
.state[data-kind=forbidden],.state[data-kind=signed-out]{border-left:4px solid var(--cube-color-warning)}
|
|
146
146
|
.state p{margin:0;flex:1 1 12rem}
|
|
147
147
|
.state[data-kind=loading] p,.state[data-kind=empty] p{color:var(--cube-color-text-muted)}
|
|
148
|
-
`,
|
|
149
|
-
`).join("")}`}function
|
|
148
|
+
`,jr=["error","forbidden","signed-out"],wt=new WeakMap;function Ir(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(),wt.get(this.ownerDocument)===this&&wt.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":vs.includes(i)?i:"loading",s=this.ownerDocument;this.kind=r;let l=jr.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")??ks[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=wt.get(i);return r!==void 0&&r!==this&&r.isConnected&&jr.includes(r.kind)?!1:(wt.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",Ss),b(t,"needsSession",!1),t}var xs=/^[=+\-@\t\r]/,Ts=/[;"\r\n]/;function Br(e,n){if(e==null)return"";let t=re.includes(n)?le(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),xs.test(o)&&(o=`'${o}`)),Ts.test(o)?`"${o.replace(/"/g,'""')}"`:o}function Ur(e,n){return`\uFEFF${[e.map(o=>Br(o.label,"text")),...n.map(o=>e.map(a=>Br(o[a.name],a.format)))].map(o=>`${o.join(";")}\r
|
|
149
|
+
`).join("")}`}function Hr(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 Cs=`${$}
|
|
150
150
|
.tools{display:flex;flex-wrap:wrap;align-items:flex-end;gap:.75rem;margin-bottom:.75rem}
|
|
151
151
|
.control{display:flex;flex-direction:column;gap:.25rem;min-width:0;max-width:100%}
|
|
152
152
|
.control>label,legend{font-weight:600}
|
|
@@ -169,7 +169,7 @@ tbody tr.chosen{background:var(--cube-color-primary-subtle);box-shadow:inset 4px
|
|
|
169
169
|
.pager{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.75rem}
|
|
170
170
|
.pager p,.export-status{margin:0;color:var(--cube-color-text-muted)}
|
|
171
171
|
.pager p{margin-inline-end:auto}
|
|
172
|
-
`,wt=ne,Hr=200,As=50,Rs=300,zr=" search";function Es(e){let n=B(e.slice(0,10));return n===null?null:(n.setDate(n.getDate()+1),U(n))}var ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function Vr(e,n,t){let o=e[n];e[n]=ue(o)&&ue(t)?{...o,...t}:t}function Ds(e,n){let t=ae(e),o=ae(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 Kr(e){return e!==void 0&&(!ue(e)||"ilike"in e)}function Ms(e,n){if(!ue(e)||!ue(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]=Ds(r,i)===a?r:i)}return t}function qr(e,n){let t=n.document;class o extends e{constructor(){super(...arguments);b(this,"period",new G(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=_(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),p=fe(this),m=await ut(this,u);if(r.aborted)return;this.period.follow(m);let f=m===null||c===null?p:{...p,...lt(c,m.value)},d=await s.schema(l);if(r.aborted)return;let g=Z(this.attr("fields")),w=d===null||d.fields.some(E=>E.name==="id"),v={session:s,resource:l,columns:[],base:f,fields:g===null?void 0:[...new Set([...w?["id"]:[],...g])],size:Math.min(X(this,"page-size",1,25),Hr)};this.exporting?.abort(),this.exporting=null,r.addEventListener("abort",()=>this.rowsController?.abort(),{once:!0});let k=Z(this.attr("filters"))??[];this.checkFilterable(d,k);let S=k.filter(E=>!(E in p)||ue(p[E]));for(let E of[...this.parts.keys()])S.includes(E)||this.parts.delete(E);let R=W(this);this.context=v;let L=await this.fetchRows(v,this.query(v,v.size,this.page)),j=L===null?null:await this.lastPageIfPast(v,L);if(j===null||r.aborted)return;let x=j.data[0];v.columns=ee(d,g,R,x);let F=new Map([...R].map(([E,z])=>[E,{...z,hidden:!1}])),T=ee(d,S,F,x);this.build(v,d,T),this.renderRows(v,j)}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,p]of u)if(!r.filterable.includes(p))throw new A(y.invalid.notFilterable(this.localName,c,p))}detailTarget(){let r=this.attr("detail")?.trim()??"";if(r==="")return null;try{return t.querySelector(r)}catch{throw new A(y.invalid.selector(this.localName,"detail",r))}}query(r,s,l){let u={},c=this.attr("search")?.trim()??"",p=this.values.get(zr)?.trim()??"";c!==""&&p!==""&&Vr(u,c,{ilike:`%${p}%`});for(let[g,w]of this.parts){let v=w();v!==null&&Vr(u,g,v)}let m={...r.base};for(let[g,w]of Object.entries(u)){let v=m[g];m[g]=v===void 0?w:Ms(v,w)}let f=this.sortBy??(this.attr("sort")?.trim()||null),d={filter:m,page:{size:s,number:l}};return f!==null&&(d.sort=f),r.fields!==void 0&&(d.fields=r.fields),d}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(Y(u))}}later(r){this.stopDebounce(),this.debounce=n.setTimeout(()=>{this.debounce=null,this.update(r)},Rs)}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!==""){Kr(r.base[c])&&this.warnFixed("search",c);let m=h(t,"input",{type:"search"});u.push(this.control(m,zr,y.search,!0))}for(let m of l)u.push(this.filterControl(m,r.base[m.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 p=h(t,"thead",{},h(t,"tr",{},...r.columns.map(m=>{let f=s?.sortable.includes(m.name)===!0,d=h(t,"th",{scope:"col",class:wt.includes(m.format)?"num":null},f?h(t,"button",{type:"button",onclick:()=>this.sortOn(m.name)},m.label,h(t,"span",{class:"arrow","aria-hidden":"true"})):m.label,...this.exampleField(r.session,r.resource,m.name)?[" ",at(t)]:[]);return f&&this.headers.set(m.name,d),d})));this.table=h(t,"table",{},h(t,"caption",{class:"sr-only"},K(r.resource)),p,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 p=`cube-table-${++Ls}`;return r.id=p,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:p},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),p=c===null&&r.format==="boolean";if(c!==null||p){ue(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(R=>h(t,"option",{value:R.value},R.label))),S=wt.includes(r.format);return this.parts.set(l,()=>{let R=u(l);return R===""?null:p?R==="true":S?ae(R)??R:R}),this.control(k,l,r.label,!1)}let m=r.format==="date"||r.format==="datetime";if(!m&&!wt.includes(r.format))return Kr(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=_e(u(v),r.format);return"value"in k&&typeof k.value=="number"?k.value:null},d=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:m?"date":"text",inputmode:m?null:"decimal","aria-label":`${y[v]} (${r.label})`});return this.control(S,k,y[v],!m,m?void 0:d(k))};this.parts.set(l,()=>{let v={},k=m?u(`${l}:min`)||null:f(`${l}:min`),S=m?Es(u(`${l}:max`)):f(`${l}:max`);return k!==null&&(v.gte=k),S!==null&&(v[m?"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,p=c?.total??s.data.length,m=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 d=h(t,"tbody",{},...s.data.map(g=>this.row(r,g)));d.querySelector('tr[tabindex="0"]')===null&&d.firstElementChild?.setAttribute("tabindex","0"),u.replaceChild(d,u.querySelector("tbody")),l.appendChild(u),this.pager!==null&&(this.pager.hidden=!1),this.pagerText!==null&&(this.pagerText.textContent=y.pageOf(this.page,m,p)),this.previous!==null&&(this.previous.disabled=this.page<=1),this.next!==null&&(this.next.disabled=this.page>=m)}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,p),u=m=>this.exampleField(r.session,r.resource,m.name),c=this.chosen!==null&&String(s.id??"")===this.chosen,p=h(t,"tr",{tabindex:c?"0":"-1",class:c?"chosen":null,"aria-current":c?"true":null,onclick:l,onkeydown:(m=>{if(m.altKey||m.ctrlKey||m.metaKey)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),l();return}let f=this.rowFor(p,m.key);f!==void 0&&(m.preventDefault(),f!==null&&(p.setAttribute("tabindex","-1"),f.setAttribute("tabindex","0"),f.focus()))})},...r.columns.map(m=>{let f=[wt.includes(m.format)&&"num",u(m)&&"example"];return h(t,"td",{class:f.filter(Boolean).join(" ")||null},I(s[m.name],m.format))}));return p}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 p of Array.from(l.parentElement?.children??[]))p.classList.toggle("chosen",p===l),p.setAttribute("tabindex",p===l?"0":"-1"),p===l?p.setAttribute("aria-current","true"):p.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(p){this.showState(Y(p));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 p=[],m="";try{let f=0,d=this.query(r,Hr,1);for await(let g of r.session.resource(r.resource).pages(d,{signal:c}))if(c.aborted||(p.push(...g.data),l.textContent=y.exporting(p.length),++f>=As))break;c.aborted||Ur(t,`${r.resource}-${U(new Date)}.csv`,Br(r.columns,p))}catch(f){!c.aborted&&f?.name!=="AbortError"&&(m=y.exportFailed)}finally{this.exporting===u&&(this.exporting=null,s.textContent=y.exportCsv,l.textContent=m)}}}return b(o,"tag","cube-table"),b(o,"css",Cs),o}var Ls=0;var Fs=`${O}${ge}
|
|
172
|
+
`,vt=re,zr=200,As=50,Rs=300,Vr=" search";function Es(e){let n=B(e.slice(0,10));return n===null?null:(n.setDate(n.getDate()+1),U(n))}var ce=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function Kr(e,n,t){let o=e[n];e[n]=ce(o)&&ce(t)?{...o,...t}:t}function Ds(e,n){let t=le(e),o=le(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 qr(e){return e!==void 0&&(!ce(e)||"ilike"in e)}function Ms(e,n){if(!ce(e)||!ce(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]=Ds(r,i)===a?r:i)}return t}function Gr(e,n){let t=n.document;class o extends e{constructor(){super(...arguments);b(this,"period",new G(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:dt(this.attr("date-field"),null,this.localName),p=ge(this),m=await ct(this,u);if(r.aborted)return;this.period.follow(m);let f=m===null||c===null?p:{...p,...ut(c,m.value)},d=await s.schema(l);if(r.aborted)return;let g=ee(this.attr("fields")),w=d===null||d.fields.some(x=>x.name==="id"),v={session:s,resource:l,columns:[],base:f,fields:g===null?void 0:[...new Set([...w?["id"]:[],...g])],size:Math.min(Z(this,"page-size",1,25),zr)};this.exporting?.abort(),this.exporting=null,r.addEventListener("abort",()=>this.rowsController?.abort(),{once:!0});let k=ee(this.attr("filters"))??[];this.checkFilterable(d,k);let S=k.filter(x=>!(x in p)||ce(p[x]));for(let x of[...this.parts.keys()])S.includes(x)||this.parts.delete(x);let D=W(this);this.context=v;let M=await this.fetchRows(v,this.query(v,v.size,this.page)),P=M===null?null:await this.lastPageIfPast(v,M);if(P===null||r.aborted)return;let T=P.data[0];v.columns=te(d,g,D,T);let L=new Map([...D].map(([x,O])=>[x,{...O,hidden:!1}])),_=te(d,S,L,T);this.build(v,d,_),this.renderRows(v,P)}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,p]of u)if(!r.filterable.includes(p))throw new A(y.invalid.notFilterable(this.localName,c,p))}detailTarget(){let r=this.attr("detail")?.trim()??"";if(r==="")return null;try{return t.querySelector(r)}catch{throw new A(y.invalid.selector(this.localName,"detail",r))}}query(r,s,l){let u={},c=this.attr("search")?.trim()??"",p=this.values.get(Vr)?.trim()??"";c!==""&&p!==""&&Kr(u,c,{ilike:`%${p}%`});for(let[g,w]of this.parts){let v=w();v!==null&&Kr(u,g,v)}let m={...r.base};for(let[g,w]of Object.entries(u)){let v=m[g];m[g]=v===void 0?w:Ms(v,w)}let f=this.sortBy??(this.attr("sort")?.trim()||null),d={filter:m,page:{size:s,number:l}};return f!==null&&(d.sort=f),r.fields!==void 0&&(d.fields=r.fields),d}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(X(u))}}later(r){this.stopDebounce(),this.debounce=n.setTimeout(()=>{this.debounce=null,this.update(r)},Rs)}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!==""){qr(r.base[c])&&this.warnFixed("search",c);let m=h(t,"input",{type:"search"});u.push(this.control(m,Vr,y.search,!0))}for(let m of l)u.push(this.filterControl(m,r.base[m.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 p=h(t,"thead",{},h(t,"tr",{},...r.columns.map(m=>{let f=s?.sortable.includes(m.name)===!0,d=h(t,"th",{scope:"col",class:vt.includes(m.format)?"num":null},f?h(t,"button",{type:"button",onclick:()=>this.sortOn(m.name)},m.label,h(t,"span",{class:"arrow","aria-hidden":"true"})):m.label,...this.exampleField(r.session,r.resource,m.name)?[" ",lt(t)]:[]);return f&&this.headers.set(m.name,d),d})));this.table=h(t,"table",{},h(t,"caption",{class:"sr-only"},K(r.resource)),p,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 p=`cube-table-${++Ls}`;return r.id=p,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:p},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=ft(r),p=c===null&&r.format==="boolean";if(c!==null||p){ce(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=vt.includes(r.format);return this.parts.set(l,()=>{let D=u(l);return D===""?null:p?D==="true":S?le(D)??D:D}),this.control(k,l,r.label,!1)}let m=r.format==="date"||r.format==="datetime";if(!m&&!vt.includes(r.format))return qr(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=_e(u(v),r.format);return"value"in k&&typeof k.value=="number"?k.value:null},d=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:m?"date":"text",inputmode:m?null:"decimal","aria-label":`${y[v]} (${r.label})`});return this.control(S,k,y[v],!m,m?void 0:d(k))};this.parts.set(l,()=>{let v={},k=m?u(`${l}:min`)||null:f(`${l}:min`),S=m?Es(u(`${l}:max`)):f(`${l}:max`);return k!==null&&(v.gte=k),S!==null&&(v[m?"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,p=c?.total??s.data.length,m=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 d=h(t,"tbody",{},...s.data.map(g=>this.row(r,g)));d.querySelector('tr[tabindex="0"]')===null&&d.firstElementChild?.setAttribute("tabindex","0"),u.replaceChild(d,u.querySelector("tbody")),l.appendChild(u),this.pager!==null&&(this.pager.hidden=!1),this.pagerText!==null&&(this.pagerText.textContent=y.pageOf(this.page,m,p)),this.previous!==null&&(this.previous.disabled=this.page<=1),this.next!==null&&(this.next.disabled=this.page>=m)}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,p),u=m=>this.exampleField(r.session,r.resource,m.name),c=this.chosen!==null&&String(s.id??"")===this.chosen,p=h(t,"tr",{tabindex:c?"0":"-1",class:c?"chosen":null,"aria-current":c?"true":null,onclick:l,onkeydown:(m=>{if(m.altKey||m.ctrlKey||m.metaKey)return;if(m.key==="Enter"||m.key===" "){m.preventDefault(),l();return}let f=this.rowFor(p,m.key);f!==void 0&&(m.preventDefault(),f!==null&&(p.setAttribute("tabindex","-1"),f.setAttribute("tabindex","0"),f.focus()))})},...r.columns.map(m=>{let f=[vt.includes(m.format)&&"num",u(m)&&"example"];return h(t,"td",{class:f.filter(Boolean).join(" ")||null},I(s[m.name],m.format))}));return p}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 p of Array.from(l.parentElement?.children??[]))p.classList.toggle("chosen",p===l),p.setAttribute("tabindex",p===l?"0":"-1"),p===l?p.setAttribute("aria-current","true"):p.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(p){this.showState(X(p));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 p=[],m="";try{let f=0,d=this.query(r,zr,1);for await(let g of r.session.resource(r.resource).pages(d,{signal:c}))if(c.aborted||(p.push(...g.data),l.textContent=y.exporting(p.length),++f>=As))break;c.aborted||Hr(t,`${r.resource}-${U(new Date)}.csv`,Ur(r.columns,p))}catch(f){!c.aborted&&f?.name!=="AbortError"&&(m=y.exportFailed)}finally{this.exporting===u&&(this.exporting=null,s.textContent=y.exportCsv,l.textContent=m)}}}return b(o,"tag","cube-table"),b(o,"css",Cs),o}var Ls=0;var Fs=`${$}${he}
|
|
173
173
|
ol{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:.25rem}
|
|
174
174
|
button{display:grid;grid-template-columns:1fr auto;gap:.125rem .75rem;width:100%;padding:.5rem .75rem;
|
|
175
175
|
border:0;border-radius:var(--cube-radius);background:none;color:inherit;font:inherit;text-align:start;cursor:pointer}
|
|
@@ -180,10 +180,10 @@ button:focus-visible{outline:2px solid var(--cube-color-focus);outline-offset:2p
|
|
|
180
180
|
svg{grid-column:1/-1;display:block;width:100%;height:.5rem}
|
|
181
181
|
rect.bar{fill:var(--cube-color-series-1)}
|
|
182
182
|
.note{margin:.5rem 0 0;font-size:.875rem;color:var(--cube-color-text-muted)}
|
|
183
|
-
`;function
|
|
183
|
+
`;function Wr(e,n){class t extends e{constructor(){super(...arguments);b(this,"period",new G(this))}shownFields(){return be(this)}async load(i,r){if(r===null)return;let s=F(this,"resource"),l=F(this,"by"),u=Z(this,"limit",1,5),c=await ye(this,this.period,i,l);if(c===null)return;let{data:p,meta:m}=await pt(r,s,l,c,i);if(i.aborted)return;let f={descending:this.attr("order")!=="asc",limit:u},d=await mt(this,r,p,{by:l,fn:c.fn},f,i);if(d===null)return;if(d.length===0){this.showState("empty");return}let g=(m?.groups??0)>p.length;this.render(d,l,we(this,c.count),g)}render(i,r,s,l){let u=n.document,c=Math.max(...i.map(f=>f.value)),p=this.attr("label"),m={};p!==null&&p!==""&&(m["aria-label"]=p),l&&(m["aria-describedby"]="incomplete"),C(this.body),this.body.appendChild(h(u,"div",{class:"card"},...p===null||p===""?[]:[h(u,"p",{class:"label"},p)],h(u,"ol",m,...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 H(n.document,"svg",{viewBox:"0 0 100 4",preserveAspectRatio:"none","aria-hidden":"true",focusable:"false"},H(n.document,"rect",{class:"bar",x:0,y:0,width:s,height:4}))}}return b(t,"tag","cube-top"),b(t,"css",Fs),t}var Os=[["cube-state",Ir],["cube-app-shell",cr],["cube-period-picker",Nr],["cube-kpi",_r],["cube-chart",Rr],["cube-top",Wr],["cube-table",Gr],["cube-detail",Dr],["cube-form",Lr],["cube-calc",vr],["cube-board",hr],["cube-gap-list",Fr]],Qr=new WeakMap;function _s(e){return class extends e.HTMLElement{}}function $s(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 Ps(e){let n=e.document,t=Qr.get(n);t?.stop();let o=new e.CSSStyleSheet,a=t?.fonts??new Set,i=r=>{try{o.replaceSync(_n(r)),$s(e,r,a)}catch{}};i(Qe()),n.adoptedStyleSheets=[...n.adoptedStyleSheets.filter(r=>r!==t?.sheet),o],Qr.set(n,{sheet:o,stop:Je(i),fonts:a})}function en(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;Ps(o);let i=ur(o,n);for(let[r,s]of Os)a.get(r)===void 0&&a.define(r,s(i,o));a.get("cube-page")===void 0&&a.define("cube-page",_s(o));for(let r of["cube-field","cube-input","cube-result","cube-column"])a.get(r)===void 0&&a.define(r,pr(o))}var Ns=5e3,js=6e4,Jr=6e4,Is=1e4,Bs=`
|
|
184
184
|
.banner{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:.5rem 1rem;
|
|
185
185
|
border-bottom:1px solid var(--cube-color-border);border-left:4px solid var(--cube-color-warning);
|
|
186
186
|
background:var(--cube-color-surface);font-size:.875rem}
|
|
187
187
|
.banner p{margin:0;flex:1 1 16rem}
|
|
188
188
|
.banner[data-state=expired],.banner[data-state=closed]{border-left-color:var(--cube-color-danger)}
|
|
189
|
-
`;function
|
|
189
|
+
`;function Yr(e,n){let t=e.document,o=e.now??Date.now,a=Date.parse(n.expiresAt),i=Number.isFinite(a),r={hour:"2-digit",minute:"2-digit",hourCycle:"h23",timeZoneName:"short"},s=null;if(i){let x;try{x=new Intl.DateTimeFormat(t.documentElement.lang||"nl-NL",r)}catch{x=new Intl.DateTimeFormat("nl-NL",r)}s=x.format(new Date(a))}let l=t.createElement("cube-trial-banner"),u=l.attachShadow({mode:"open"}),c=[Me,Bs].map(x=>{let O=new e.CSSStyleSheet;return O.replaceSync(x),O}),p=h(t,"p",{},y.trial.banner(s,n.leest)),m=h(t,"div",{class:"banner",role:"status","aria-live":"polite"},p),f=null,d=!1,g=!1,w=null,v=0;u.adoptedStyleSheets=c,u.appendChild(m);let k=()=>{t.body.insertBefore(l,t.body.firstChild)},S=()=>t.visibilityState!=="hidden",D=()=>{d=!0,w?.abort(),f!==null&&e.clearTimeout(f),f=null,t.removeEventListener("visibilitychange",_)},M=(x,O)=>{D(),!l.isConnected&&t.body!==null&&k(),m.setAttribute("data-state",x),C(p),p.appendChild(t.createTextNode(y.trial[x])),O!==void 0&&m.appendChild(h(t,"button",{type:"button",onclick:O[1]},O[0]))},P=(x=S()?Ns:js)=>{if(d)return;f!==null&&e.clearTimeout(f);let O=Math.max(x,Math.min(Jr,v-o()));f=e.setTimeout(T,i?Math.max(0,Math.min(O,a-o())):O)},T=async()=>{if(f=null,d)return;if(i&&o()>=a){M("expired");return}v=0,g=!0;let x=e.AbortController===void 0?null:new e.AbortController;w=x;let O=x===null?null:e.setTimeout(()=>x.abort(),Is);try{let R=await e.fetch(n.statusUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${n.token}`},cache:"no-store",...x===null?{}:{signal:x.signal}});await L(R)}catch{P()}finally{g=!1,w=null,O!==null&&e.clearTimeout(O)}},L=async x=>{if(d)return;if(x.ok&&(v=0),x.status===429){let V=(x.headers.get("Retry-After")??"").trim();/^\d+$/.test(V)&&(v=o()+Math.min(Jr,Number(V)*1e3))}if(x.ok||x.status===429||x.status>=500){P();return}let O={};try{let V=await x.json();V!==null&&typeof V=="object"&&(O=V)}catch{}let R=O.code,Q=null;if(R==="trial_expired")M("expired");else if(R==="trial_elsewhere")M("elsewhere",[y.trial.reload,()=>e.location.reload()]);else if(R==="trial_replaced"&&(Q=Us(O.newer,n.dmpUrl))!==null){let V=Q.href;O.wider===!1?(M("refreshing"),e.location.assign(V)):M("wider",[y.trial.load,()=>e.location.assign(V)])}else M("closed")};function _(){if(!(d||g)){if(!S()){P();return}if(v>o()){P(0);return}f!==null&&e.clearTimeout(f),T()}}return t.addEventListener("visibilitychange",_),t.body===null?t.addEventListener("DOMContentLoaded",k,{once:!0}):k(),P(),D}function Us(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 Hs=Object.freeze({...st,defineBlocks:en});globalThis.CubeApp=Hs;typeof customElements<"u"&&en();var Xr=Xe(),tn=globalThis;Xr!==null&&tn.document!==void 0&&tn.CSSStyleSheet!==void 0&&Yr(tn,Xr);})();
|