@datawheel/bespoke 0.8.0-rc.29 → 0.8.0-rc.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cms.js CHANGED
@@ -95,7 +95,7 @@ return {
95
95
  groupBy: "id",
96
96
  x: "x",
97
97
  y: "y"
98
- }`;});function Qt(e){return e.type===E.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var Un=B(()=>{p();ge();});function DP(){let{publicRuntimeConfig:e}=BP(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((o,r)=>(o[`ENV_${r}`]=t[r]||"N/A",o),{})}}var qo,Di=B(()=>{p();qo=DP;});function _P(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,o])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:o}),{})}var Pv,Ov=B(()=>{p();Pv=_P;});function fu(e){return e.ok!==void 0}function mu(e){this.message=e,this.name="ApiFetchException";}async function dm(e,t,o="en",r,n){let i=Date.now(),a=e,l,s=qo(),u=Pv(),c={envs:{...s,...u}},m=new URL(e).searchParams;if(m.has("bespoke_slugs")){let S=new RegExp(`[?&]bespoke_slugs=${m.get("bespoke_slugs")}`,"g");a=a.replace(S,"");}let g={datasource:void 0};r.find(S=>{if(!S.content?.pattern)return !1;try{let C=new RegExp(S.content.pattern,"gm");return C.test(a)?(g.datasource=S,!0):C.test(a)}catch{return !1}});let f=n?n.settings:{},h=!!(f&&f.useProxy&&f.useProxy==="true"),y=g.datasource&&typeof g.datasource.content.useProxy=="boolean"?g.datasource.content.useProxy:!1,b=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(a)}`;if(typeof window=="object"&&(h||y)){let S=await GP({url:a,timeout:Mv});if(S.ok===!0)l=S.data;else throw new mu(S?.error)}else try{let C={url:a,timeout:Mv};if(g.datasource){let k=await ou({vars:["url","libs"],logic:g.datasource.content.logic},c)(a);if(k.axiosConfig)C=k.axiosConfig;else throw new mu(`AxiosConfig is missing in Data Source ${g.datasource.name} (ID: ${g.datasource.id}).`)}let v=await gu(C);if(v.status===200)v.headers["content-type"]==="text/csv"?l=csvParse(v.data):l=v.data;else throw new mu("No response for: "+a)}catch(S){throw new mu(S.message)}if(m.has("bespoke_slugs")){let S=m.get("bespoke_slugs");if(S){let C=S.split(",");if(C.length===3){let[v,w,k]=C,I=du(l,k);if(I&&Array.isArray(I)){let D=Array.from(new Set(I.map(A=>`${A[w]}`).filter(A=>!["","undefined"].includes(A))));if(D.length>0){let A=D.join("").length>2e3,_=await t({mode:A?"whole":"ids",ids:A?void 0:D,all:!1,locale:o,variant:[parseInt(v,10)],output:"lite",limit:D.length+1,allowNulls:!0}).then(M=>{let $=[];return fu(M)?M.ok&&($=M.data.results):$=M.results,$&&Array.isArray($)?$:[]}).catch(M=>(console.error(`Error hydrating slugs for Variant: ${v}, Key: ${w}, Accessor: ${k}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(M),[]));if(_){let M=Object.fromEntries(_.map($=>[$.id,`/${$.variant_slug}/${$.slug}`]));I.map($=>($.bespoke_slug=M[$[w]]?M[$[w]]:null,$));}}}}}}return {data:l,requestDuration:Date.now()-i,finalUrl:y||h?b:a,apiDataSource:g.datasource?g.datasource:!1}}function HP(e){this.name="BlockException",this.message=e;}async function bl(e,t,o,r,n){let{locale:i,variables:a,query:l}=Ko(o),s=jP(e,o,a,t),u=null,c=e.contentByLocale?.logic?.content?.api,d=null,m=null,g=null,f=null,h=null;if(!s)return {outputVariables:{},renderVariables:{},status:{allowed:!1,hiddenByCascade:e.id}};if(e.type===E.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:s,hiddenByCascade:e.id}};if(c){g=UP(c,t,o);let I=g.split(Bo).filter(_=>_!==""),D=[];for(let _=0;_<I.length;_++){let M=I[_];new RegExp("^(?:[a-z+]+:)?//","i").test(g)||(M=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${M}`.replace(/([^:]\/)\/+/g,"$1")),D.push(dm(M,r,i,n,e).catch(R=>{throw new HP(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${a.report_name} (${a.report_id}) failed.
98
+ }`;});function Qt(e){return e.type===E.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var Un=B(()=>{p();ge();});function DP(){let{publicRuntimeConfig:e}=BP(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((o,r)=>(o[`ENV_${r}`]=t[r]||"N/A",o),{})}}var qo,Di=B(()=>{p();qo=DP;});function _P(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,o])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:o}),{})}var Pv,Ov=B(()=>{p();Pv=_P;});function fu(e){return e.ok!==void 0}function mu(e){this.message=e,this.name="ApiFetchException";}async function dm(e,t,o="en",r,n){let i=Date.now(),a=e,l,s=qo(),u=Pv(),c={envs:{...s,...u}},d=new URL(e),m=new URLSearchParams(d.searchParams.toString());m.has("bespoke_slugs")&&(d.searchParams.delete("bespoke_slugs"),a=d.toString());let g={datasource:void 0};r.find(S=>{if(!S.content?.pattern)return !1;try{let C=new RegExp(S.content.pattern,"gm");return C.test(a)?(g.datasource=S,!0):C.test(a)}catch{return !1}});let f=n?n.settings:{},h=!!(f&&f.useProxy&&f.useProxy==="true"),y=g.datasource&&typeof g.datasource.content.useProxy=="boolean"?g.datasource.content.useProxy:!1,b=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(a)}`;if(typeof window=="object"&&(h||y)){let S=await GP({url:a,timeout:Mv});if(S.ok===!0)l=S.data;else throw new mu(S?.error)}else try{let C={url:a,timeout:Mv};if(g.datasource){let k=await ou({vars:["url","libs"],logic:g.datasource.content.logic},c)(a);if(k.axiosConfig)C=k.axiosConfig;else throw new mu(`AxiosConfig is missing in Data Source ${g.datasource.name} (ID: ${g.datasource.id}).`)}let v=await gu(C);if(v.status===200)v.headers["content-type"]==="text/csv"?l=csvParse(v.data):l=v.data;else throw new mu("No response for: "+a)}catch(S){throw new mu(S.message)}if(m.has("bespoke_slugs")){let S=m.get("bespoke_slugs");if(S){let C=S.split(",");if(C.length===3){let[v,w,k]=C,I=du(l,k);if(I&&Array.isArray(I)){let D=Array.from(new Set(I.map(A=>`${A[w]}`).filter(A=>!["","undefined"].includes(A))));if(D.length>0){let A=D.join("").length>2e3,_=await t({mode:A?"whole":"ids",ids:A?void 0:D,all:!1,locale:o,variant:[parseInt(v,10)],output:"lite",limit:D.length+1,allowNulls:!0}).then(M=>{let $=[];return fu(M)?M.ok&&($=M.data.results):$=M.results,$&&Array.isArray($)?$:[]}).catch(M=>(console.error(`Error hydrating slugs for Variant: ${v}, Key: ${w}, Accessor: ${k}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(M),[]));if(_){let M=Object.fromEntries(_.map($=>[$.id,`/${$.variant_slug}/${$.slug}`]));I.map($=>($.bespoke_slug=M[$[w]]?M[$[w]]:null,$));}}}}}}return {data:l,requestDuration:Date.now()-i,finalUrl:y||h?b:a,apiDataSource:g.datasource?g.datasource:!1}}function HP(e){this.name="BlockException",this.message=e;}async function bl(e,t,o,r,n){let{locale:i,variables:a,query:l}=Ko(o),s=jP(e,o,a,t),u=null,c=e.contentByLocale?.logic?.content?.api,d=null,m=null,g=null,f=null,h=null;if(!s)return {outputVariables:{},renderVariables:{},status:{allowed:!1,hiddenByCascade:e.id}};if(e.type===E.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:s,hiddenByCascade:e.id}};if(c){g=UP(c,t,o);let I=g.split(Bo).filter(_=>_!==""),D=[];for(let _=0;_<I.length;_++){let M=I[_];new RegExp("^(?:[a-z+]+:)?//","i").test(g)||(M=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${M}`.replace(/([^:]\/)\/+/g,"$1")),D.push(dm(M,r,i,n,e).catch(R=>{throw new HP(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${a.report_name} (${a.report_id}) failed.
99
99
  Error fetching ${M}.
100
100
  Message: ${R.message}.
101
101
  `)}));}let A=await Promise.all(D).catch(_=>_.message);if(typeof A=="string"&&A)return {outputVariables:{},renderVariables:{},status:{error:A}};u=A.length===1?A[0].data:A.map(_=>_.data),m=A.reduce((_,M)=>_+JSON.stringify(M.data).length/1024,0),d=Math.max(...A.map(_=>_.requestDuration)),f=A.map(_=>_.apiDataSource?`${_.apiDataSource.name} (${_.apiDataSource.id})`:!1),h=A.map(_=>_.finalUrl);}if(e.type===E.SELECTOR){let{config:I,log:D,error:A}=uu(e.id,e.contentByLocale[i].content.logic,t,o,!0);return {outputVariables:Sv(e.id,l,I),renderVariables:I,status:{log:D,error:A,allowed:s}}}if(e.type===E.MULTIHIERARCHY_SELECTOR){let{config:I,log:D,error:A}=pu(e.id,e.contentByLocale[i].content.logic,t,o,!0);return {outputVariables:Tv(e.id,l,I),renderVariables:I,status:{log:D,error:A,allowed:s}}}if(e.type===E.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:s}};if(e.type===E.RELATED){let I=e.contentByLocale?.logic?.content?.simple?.compare||"variant",D=e.contentByLocale?.logic?.content?.simple?.limit||4,A=Object.keys(a).filter(z=>z.startsWith("report_id")).map(z=>a[z]),_=Object.keys(a).filter(z=>z.startsWith("dimension_id")).map(z=>a[z]),M=Object.keys(a).filter(z=>z.startsWith("variant_id")).map(z=>a[z]),$=Object.keys(a).filter(z=>z.startsWith("id")).map(z=>a[z]);if(!$.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:!1}};let R=await Promise.all($.map((z,j)=>r({mode:"ids",locale:i,ids:[z],output:"lite",variant:[M[j]]}))).then(z=>z.flatMap(j=>{let V=[];return fu(j)?j.ok&&(V=j.data.results):V=j.results,V&&Array.isArray(V)?V:[]})).catch(z=>(console.error("Error getting related members",z),[]));if(_.length>1){let z=Object.keys(a).filter(Z=>Z.startsWith("variant_slug")).map(Z=>a[Z]),j=R.map((Z,N)=>{let H={mode:"related",locale:i,related:D??4,current_ids:[Z.content_id],output:"full",variant_ids:[Z.variant_id]};return N===0&&(H.include_ids=[Z.content_id]),H}),V=await Promise.all(j.map(Z=>r(Z))).then(Z=>Z.flatMap(N=>{let H=[];return fu(N)?N.ok&&(H=N.data.results):H=N.results,H&&Array.isArray(H)?H:[]})).catch(Z=>(console.error("Error getting related members",Z),[])),W=V.reduce((Z,N)=>{let H=N.variant_slug;return Z[H]||(Z[H]=[]),Z[H].push(N),Z},{}),X=[],U=Object.keys(W),Q=[{combination:[],index:0}];for(;Q.length>0;){let Z=Q.pop();if(!Z)continue;let{combination:N,index:H}=Z;if(H===U.length){X.push(N);continue}let ee=U[H],te=W[ee];for(let ie of te)Q.push({combination:[...N,ie],index:H+1});}return {outputVariables:{related_reports:X.map(Z=>{let N=Z.sort((H,ee)=>z.indexOf(H.variant_slug)-z.indexOf(ee.variant_slug));return {entities:N,link:"/"+N.map(H=>`${H.variant_slug}/${H.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:V.length>0}}}let L=R.map(z=>z.content_id),O={mode:"related",locale:i,related:D??4,current_ids:L,output:"full"};I&&(I==="report"?O.report_ids=A:I==="dimension"?O.dimension_ids=_:O.variant_ids=M);let q=await r(O).then(z=>{let j=[];return fu(z)?z.ok&&(j=z.data.results):j=z.results,j&&Array.isArray(j)?j:[]}).catch(z=>(console.error("Error getting related members",z),[]));return {outputVariables:{related_reports:q.map(z=>({entities:[z],link:`/${z.variant_slug}/${z.slug}`}))},renderVariables:{},status:{log:[],allowed:q.length>0}}}let{logic:y}=ho(e,i),b=tt(y,t,o),S=Dr("resp",u||{},b,t,a,o),{vars:C,error:v,log:w}=S;if(typeof C!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:w,duration:d,responseSize:m,resp:u,api:g,allowed:s,apiFinalUrls:h,apiDataSources:f}};let k=Object.keys(C).reduce((I,D)=>({...I,[`${e.type}${e.id}${D}`]:C[D]}),{});return {renderVariables:C,outputVariables:[E.GENERATOR,E.SECTION_FLAG].includes(e.type)?C:k,status:{log:w,error:v,duration:d,responseSize:m,resp:u,api:g,allowed:s,apiFinalUrls:h,apiDataSources:f}}}function Dv(e,t,o,r,n,i,a){return e.consumers.forEach(l=>{if(t[l]){let s=`${o}-${l}`;!r.includes(s)&&(t[l].section_id===t[o].section_id||!n)&&r.push(s),e.consumers.filter(u=>t[u]&&t[u].section_id===t[o].section_id||!n).forEach(u=>mm(u,t,r,!1,i,n,a));}})}var Gn,VP,$P,Bv,UP,GP,Mv,mm,jP,Hn,_v,fm,cn=B(()=>{p();em();$n();ge();lm();um();xv();Cv();Ga();_r();Mo();Rv();pm();br();Un();Fa();Di();Ov();Gn=Bl(process.env.NEXT_PUBLIC_REPORTS_DEBUG),VP=process.env.REPORTS_ORIGIN||"",$P=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,Bv=5;try{Bv=parseInt(`${$P||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}Lv(gu,{retries:Bv,retryDelay:Lv.exponentialDelay,onRetry:(e,t,o)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",o.url),console.error(t.message);}});gu.interceptors.request.use(e=>({...e,requestStart:Date.now()}));gu.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));UP=(e,t,o)=>{let r=tt(e,t,o);return r.startsWith("http")||(r=`${VP}${r.startsWith("/")?"":"/"}${r}`),r},{urlProxy:GP}=gl("/api/cms");Mv=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;mm=(e,t,o=[],r=!0,n=!0,i=!0,a=[])=>{if(a.includes(e))return [];a.push(e);let l=t[e];return l&&l.inputs.length&&r&&l.inputs.forEach(s=>{let u=`${s}-${e}`;o.includes(u)||o.push(u),l.inputs.forEach(c=>mm(c,t,o,r,!1,i,a));}),l&&l.consumers.length&&n&&Dv(l,t,e,o,i,n,a),o},jP=(e,t,o,r)=>{let n=!0;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=!1;else {let i=Ko(t),{error:a,output:l}=Dr("variables",o,e.settings.allowedLogic||"return false;",r,void 0,i);a||(n=!!l);}return n},Hn=async(e,t,o,r,n,i={},a,l="section",s)=>{let u=l==="section",c=Ko(n),d=c.variables,m={...i.variables??{}},g={...i.status??{}},f=new Set,h=[],y={};o?y={...y,[o]:e[o]}:t?y=(t??[]).reduce((L,{id:O})=>({...L,...Ev(O,e)}),{}):y=Object.values(e).filter(L=>Qt(L)).reduce((L,O)=>({...L,[O.id]:O}),{});let b=Object.values(y).filter(L=>Qt(L));if(b.length>0){Gn&&console.info("%crunConsumers: calculating section flags","color:purple",b.map(F=>F.id).join(", "));let L=Object.fromEntries(await Promise.all(b.map(async F=>[F.id,await bl(F,r,{...c,variables:d,locale:d.locale},a,s).then(z=>{let{outputVariables:j,status:V}=z;if(V.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${F.id}, Section ${F.section_id}) failed with message: ${V.error}. `);g[F.id]={allowed:!1,error:V.error},m[F.id]={};}return (F.consumers.length>0||[E.GENERATOR,E.SECTION_FLAG,E.RELATED].includes(F.type))&&V.allowed&&Object.keys(j).length>0?m[F.id]=j:m[F.id]={},l==="report"?(g[F.id]={allowed:V.allowed},[E.GENERATOR,E.SECTION_FLAG].includes(F.type)&&V.api&&(g[F.id].api=V.api)):g[F.id]=V,z})]))),q=Object.entries(L).filter(([,F])=>!F.outputVariables[bo]).map(([F])=>Number(F));f=new Set(q.map(F=>e[F].section_id)),Object.values(y).filter(F=>f.has(F.section_id)).forEach(F=>{h.push(F.id),delete y[F.id];}),Gn&&console.info("%crunConsumers: removing sections","color:purple",f.keys());}let S=f.size>0?Object.fromEntries(Object.entries(e).filter(([,L])=>f?.has(L.section_id)?(h.includes(L.id)||h.push(L.id),!1):!0)):e;if(h.length>0&&(S=Object.fromEntries(Object.entries(S).map(([L,O])=>{let q={...O,inputs:O.inputs.filter(F=>!h.includes(F)),consumers:O.consumers.filter(F=>!h.includes(F))};return [L,q]}))),!o&&!t)return {variables:{...i.variables??{},...m},status:{...i.status??{},...g}};l==="report"&&h.length>0&&h.forEach(L=>{delete m[L],delete g[L],delete e[L];}),Gn&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(y));let C=Object.keys(y).reduce((L,O)=>{let q=new Date,F=mm(Number(O),S,[],!o,!0,u).map(V=>V.split("-")),j=(new Date().getTime()-q.getTime())/1e3;return Gn&&console.info(`%cResolved dependencies for ${O} (${j.toFixed(2)}s)`,"color:blue"),[...L,...F]},[]),v=new Date,w=Object.keys(y).reduce((L,O)=>L.includes(O)?[...L]:[O,...L],NP(C)),I=(new Date().getTime()-v.getTime())/1e3;Gn&&console.info(`%cResolved DAG (${I.toFixed(2)}s): `,"color:green",w);let D=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,A=parseInt(`${D||0}`,10);async function _(L,O){let q=new Map,F=[],z=async()=>F.length;for(let j of L){if(A!==0){let U=await z();for(;U>=A;)Gn&&console.info("Too many pending promises, waiting...",U,F),await new Promise(Q=>setTimeout(Q,500)),U=await z();}let V=O[j],X=Promise.all(V.inputs.filter(U=>L.includes(String(U))).map(U=>q.get(Number(U)))).then(async()=>{let U=V.inputs.reduce((te,ie)=>({...te,...m[ie]}),d),Q=V.inputs.find(te=>(V.settings?.ignoreCascade?V.settings?.ignoreCascade:[]).includes(te)||!g[te]?!1:!g[te].allowed||g[te].hiddenByCascade);if(Q){g[j]={allowed:!1,hiddenByCascade:g[Q].hiddenByCascade||Q},m[j]={},F.splice(F.indexOf(Number(j)),1);return}let re=new Date,Z;typeof window<"u"&&[E.SELECTOR,E.MULTIHIERARCHY_SELECTOR].includes(V.type)&&V.settings[At.DISABLED]?Z=new Promise(te=>{te({outputVariables:m[j],status:g[j]});}):Z=bl(V,r,{...c,variables:U,locale:U.locale},a,s);let N=await Z.then(({outputVariables:te,status:ie})=>{if(ie.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${j}, Section ${V.section_id}) failed with message: ${ie.error}.`);g[j]={allowed:!1,error:ie.error},m[j]={};}(V.consumers.length>0||[E.GENERATOR,E.SECTION_FLAG,E.RELATED].includes(V.type))&&ie.allowed&&Object.keys(te).length>0?m[j]=te:m[j]={},l==="report"?(g[j]={allowed:ie.allowed},[E.GENERATOR,E.SECTION_FLAG].includes(V.type)&&ie.api&&(g[j].api=ie.api)):g[j]=ie;}),ee=(new Date().getTime()-re.getTime())/1e3;return Gn&&console.info(`%cBlock ${V.id} resolved in ${ee.toFixed(3)}s`,ee>500?"color:red":"color:green"),g[j].duration=g[j].duration?g[j].duration:ee,F.splice(F.indexOf(Number(j)),1),N}).catch(U=>{throw F.splice(F.indexOf(Number(j)),1),U});F.push(Number(j)),q.set(Number(j),X);}await Promise.all(Array.from(q.values()));}let M=new Date;await _(w,S);let R=(new Date().getTime()-M.getTime())/1e3;return Gn&&console.info(`%cResolved Variables (${R.toFixed(2)}s), ${w.length} blocks`,"color:green"),{variables:{...i.variables??{},...m},status:{...i.status??{},...g}}},_v=e=>e<250?"green":e<1e3?"yellow":"red",fm=e=>e<10?"green":e<100?"yellow":"red";});function WP(e=[]){return e.reduce((t,o,r)=>{if(o){let n=r+1;t[`id${n}`]=o.id,t[`name${n}`]=o.name,t[`slug${n}`]=o.slug,"attributes"in o&&Object.keys(o.attributes).forEach(i=>{t[`attr_${i}${n}`]=o.attributes[i];}),t[`variant_id${n}`]=o.variant_id,t[`variant_name${n}`]=o.variant_name,t[`variant_slug${n}`]=o.variant_slug,t[`dimension_id${n}`]=o.dimension_id,t[`dimension_name${n}`]=o.dimension_name,t.report_id=o.report_id,t.report_name=o.report_name;}return t},{})}var Nv,zv=B(()=>{p();Nv=WP;});var yr,hu,yl=B(()=>{p();yr=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",hu=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[yr];hu.includes(yr)||hu.push(yr);});var YP,bu,Do,vl=B(()=>{p();yl();YP={localeDefault:yr,locales:hu,currentLocale:yr,preferredLocale:yr,showToolbar:!1,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:!0,settings:!1,reportEditor:!1},isCMS:!1,isRunConsumersRunning:[]},bu=createSlice({name:"status",initialState:YP,reducers:{setStatus:(e,t)=>{Object.assign(e,t.payload);},setPreviews(e,t){e.previews=t.payload;},setCurrentLocale(e,t){e.currentLocale=t.payload;},setPreferredLocale(e,t){e.preferredLocale=t.payload;},setSectionState(e,t){e.sectionState={...e.sectionState,...t.payload};},resetSectionState(e,t){e.sectionState={...e.sectionState,[t.payload]:{}};},setActiveEntity(e,t){e.activeEntity=t.payload;},openSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!0};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!1};},toggleSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!e.sidebarStatus[t.payload]};},addRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.concat(t.payload);},removeRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.filter(o=>!t.payload.includes(o));}},extraReducers:{[HYDRATE]:(e,t)=>({...e,previews:t.payload.status.previews})}}),Do=bu.actions;});var QP,yu,_i,Ha=B(()=>{p();QP={attributes:{},variables:{},status:{}},yu=createSlice({name:"variables",initialState:QP,reducers:{setVariableChange:(e,t)=>{e.attributes={...e.attributes,...t.payload.attributes},e.variables={...e.variables,...t.payload.variables},e.status={...e.status,...t.payload.status};}},extraReducers:{[HYDRATE]:(e,t)=>({attributes:{...e.attributes,...t.payload.variables.attributes},status:{...e.status,...t.payload.variables.status},variables:{...e.variables,...t.payload.variables.variables}})}}),_i=yu.actions;});function Sl(e,t){return Object.fromEntries(Object.keys(e).map(o=>[o,{...e[o],...t[o]}]))}function vu(e,t){return e.map(n=>t[n]).sort(go).map(n=>n.id)}function oO(e,t){let o=e.indexOf(t);o>-1&&e.splice(o,1);}var tO,un,xl=B(()=>{p();mr();Fn();tO={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},un=createSlice({name:"records",initialState:tO,reducers:{set:(e,t)=>{let o=t.payload;return {entities:Sl(e.entities,o.entities||{}),requests:Sl(e.requests,o.requests||{}),reports:o.reports||e.reports,tree:o.tree||e.tree}},setRequest:(e,t)=>{let o=t.payload;e.requests[o.type][o.key]=o;},setCreateRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let r=Array.isArray(o.data)?o.data:[o.data],n=ru(o.type,r),i=Sl(e.entities,n);if(e.entities=i,o.type==="report"){let a=o.data;e.reports?e.reports.indexOf(a.id)===-1&&(e.reports=[...e.reports,a.id]):e.reports=[a.id];}else if(o.type==="dimension"){let a=o.data;e.entities.report[a.report_id].dimensions.push(a.id),e.entities.report[a.report_id].dimensions=vu(i.report[a.report_id].dimensions,i.dimension);}else if(o.type==="variant"){let a=o.data;e.entities.dimension[a.dimension_id].variants.push(a.id);}else if(o.type==="section"&&!Array.isArray(o.data)){let a=o.data;e.entities.report[a.report_id].sections.push(a.id),e.entities.report[a.report_id].sections=vu(i.report[a.report_id].sections,i.section);}else if(o.type==="block")if(Array.isArray(o.data)){let a=o.data,l=a[0],s=a.map(u=>u.id);e.entities.section[l.section_id].blocks.concat(s);}else {let a=o.data;e.entities.section[a.section_id].blocks.push(a.id);}}},setReadRequest(e,t){let o=t.payload;if(o.type!=="report"&&(e.requests[o.type][o.key]=o),o.status==="SUCCESS"){let r=ru(o.type,o.data),n=Sl(e.entities,r);e.entities=n;}},setUpdateRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let r=Array.isArray(o.data)?o.data:[o.data],n=ru(o.type,r),i,a,l;if(o.type==="block"&&!Array.isArray(o.data)){let u=e.entities.block[o.data.id].inputs,c=n.block[o.data.id].inputs;i=u.length!==c.length,i&&(l=u.length>c.length,a=l?u.filter(d=>!c.includes(d))[0]:c.filter(d=>!u.includes(d))[0]),Object.values(n.block).forEach(d=>{d.block_input&&delete n.block[d.id];});}let s=Sl(e.entities,n);if(e.entities=s,o.type==="dimension"){let u=o.data;e.entities.report[u.report_id].dimensions=vu(s.report[u.report_id].dimensions,s.dimension);}else if(o.type==="section"&&!Array.isArray(o.data)){let u=o.data;e.entities.report[u.report_id].sections=vu(s.report[u.report_id].sections,s.section);}else if(o.type==="block"&&!Array.isArray(o.data)){let u=o.data;i&&(l?e.entities.block[a].consumers=e.entities.block[a].consumers.filter(c=>c!==u.id):e.entities.block[a].consumers.push(u.id));}}},setDeleteRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let{id:r,parentId:n,parentType:i}=o.data;if(delete e.entities[o.type][r],i&&n!=null){let a=`${o.type}s`;oO(e.entities[i][n][a],r);}}},removeBlocks:(e,t)=>{let o=t.payload,r={...e.entities.block};return o.forEach(n=>{delete r[n];}),{...e,entities:{...e.entities,block:r}}},addBlocks:(e,t)=>{let o=t.payload;return {...e,entities:{...e.entities,block:{...e.entities.block,...o}}}},removeDataSourceLogic:e=>{let t={...e.entities.datasource};Object.keys(t).forEach(o=>{e.entities.datasource[o].content.useProxy&&(delete e.entities.datasource[o].content.logic,delete e.entities.datasource[o].content.testUrl,delete e.entities.datasource[o].content.access);});}},extraReducers:{[HYDRATE]:(e,t)=>{let o=t.payload.records,r=o.entities;return {entities:r,reports:Object.values(r.report).map(n=>n.id),requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},tree:o.tree}}}});});function rO(e){return {ok:!1,status:Ni.is(e)?e.code:500,error:e.message}}function zi(e,t,o){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${Fv(o)}`;return e[n]}let r=`${t}${Fv(o)}`;return e[r]}function Fv(e){return e[0].toUpperCase()+e.slice(1)}var Ni,Su=B(()=>{p();Ni=class extends Error{constructor(o,r){super(r);this.code=o;}toJSON(){return rO(this)}static is(o){return Object.prototype.hasOwnProperty.call(o,"code")&&typeof o.code=="number"}};});function Pt(e){for(var t=arguments.length,o=Array(t>1?t-1:0),r=1;r<t;r++)o[r-1]=arguments[r];if(process.env.NODE_ENV!=="production"){var n=pO[e],i=n?typeof n=="function"?n.apply(null,o):n:"unknown error nr: "+e;throw Error("[Immer] "+i)}throw Error("[Immer] minified error nr: "+e+(o.length?" "+o.map(function(a){return "'"+a+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function ja(e){return !!e&&!!e[_o]}function Vi(e){var t;return !!e&&(function(o){if(!o||typeof o!="object")return !1;var r=Object.getPrototypeOf(o);if(r===null)return !0;var n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===dO}(e)||Array.isArray(e)||!!e[Kv]||!!(!((t=e.constructor)===null||t===void 0)&&t[Kv])||km(e)||Em(e))}function Cl(e,t,o){o===void 0&&(o=!1),Ka(e)===0?(o?Object.keys:Pm)(e).forEach(function(r){o&&typeof r=="symbol"||t(r,e[r],e);}):e.forEach(function(r,n){return t(n,r,e)});}function Ka(e){var t=e[_o];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:km(e)?2:Em(e)?3:0}function vm(e,t){return Ka(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function nO(e,t){return Ka(e)===2?e.get(t):e[t]}function qv(e,t,o){var r=Ka(e);r===2?e.set(t,o):r===3?e.add(o):e[t]=o;}function iO(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function km(e){return cO&&e instanceof Map}function Em(e){return uO&&e instanceof Set}function Fi(e){return e.o||e.t}function Rm(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=mO(e);delete t[_o];for(var o=Pm(t),r=0;r<o.length;r++){var n=o[r],i=t[n];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(t[n]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function wm(e,t){return t===void 0&&(t=!1),Im(e)||ja(e)||!Vi(e)||(Ka(e)>1&&(e.set=e.add=e.clear=e.delete=aO),Object.freeze(e),t&&Cl(e,function(o,r){return wm(r,!0)},!0)),e}function aO(){Pt(2);}function Im(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function Nr(e){var t=fO[e];return t||Pt(18,e),t}function Vv(){return process.env.NODE_ENV==="production"||Wa||Pt(0),Wa}function gm(e,t){t&&(Nr("Patches"),e.u=[],e.s=[],e.v=t);}function xu(e){Sm(e),e.p.forEach(sO),e.p=null;}function Sm(e){e===Wa&&(Wa=e.l);}function $v(e){return Wa={p:[],l:Wa,h:e,m:!0,_:0}}function sO(e){var t=e[_o];t.i===0||t.i===1?t.j():t.g=!0;}function hm(e,t){t._=t.p.length;var o=t.p[0],r=e!==void 0&&e!==o;return t.h.O||Nr("ES5").S(t,e,r),r?(o[_o].P&&(xu(t),Pt(4)),Vi(e)&&(e=Tu(t,e),t.l||Cu(t,e)),t.u&&Nr("Patches").M(o[_o].t,e,t.u,t.s)):e=Tu(t,o,[]),xu(t),t.u&&t.v(t.u,t.s),e!==Yv?e:void 0}function Tu(e,t,o){if(Im(t))return t;var r=t[_o];if(!r)return Cl(t,function(l,s){return Uv(e,r,t,l,s,o)},!0),t;if(r.A!==e)return t;if(!r.P)return Cu(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var n=r.i===4||r.i===5?r.o=Rm(r.k):r.o,i=n,a=!1;r.i===3&&(i=new Set(n),n.clear(),a=!0),Cl(i,function(l,s){return Uv(e,r,n,l,s,o,a)}),Cu(e,n,!1),o&&e.u&&Nr("Patches").N(r,o,e.u,e.s);}return r.o}function Uv(e,t,o,r,n,i,a){if(process.env.NODE_ENV!=="production"&&n===o&&Pt(5),ja(n)){var l=Tu(e,n,i&&t&&t.i!==3&&!vm(t.R,r)?i.concat(r):void 0);if(qv(o,r,l),!ja(l))return;e.m=!1;}else a&&o.add(n);if(Vi(n)&&!Im(n)){if(!e.h.D&&e._<1)return;Tu(e,n),t&&t.A.l||Cu(e,n);}}function Cu(e,t,o){o===void 0&&(o=!1),!e.l&&e.h.D&&e.m&&wm(t,o);}function bm(e,t){var o=e[_o];return (o?Fi(o):e)[t]}function Gv(e,t){if(t in e)for(var o=Object.getPrototypeOf(e);o;){var r=Object.getOwnPropertyDescriptor(o,t);if(r)return r;o=Object.getPrototypeOf(o);}}function xm(e){e.P||(e.P=!0,e.l&&xm(e.l));}function ym(e){e.o||(e.o=Rm(e.t));}function Tm(e,t,o){var r=km(t)?Nr("MapSet").F(t,o):Em(t)?Nr("MapSet").T(t,o):e.O?function(n,i){var a=Array.isArray(n),l={i:a?1:0,A:i?i.A:Vv(),P:!1,I:!1,R:{},l:i,t:n,k:null,o:null,j:null,C:!1},s=l,u=Cm;a&&(s=[l],u=Tl);var c=Proxy.revocable(s,u),d=c.revoke,m=c.proxy;return l.k=m,l.j=d,m}(t,o):Nr("ES5").J(t,o);return (o?o.A:Vv()).p.push(r),r}function lO(e){return ja(e)||Pt(22,e),function t(o){if(!Vi(o))return o;var r,n=o[_o],i=Ka(o);if(n){if(!n.P&&(n.i<4||!Nr("ES5").K(n)))return n.t;n.I=!0,r=Hv(o,i),n.I=!1;}else r=Hv(o,i);return Cl(r,function(a,l){n&&nO(n.t,a)===l||qv(r,a,t(l));}),i===3?new Set(r):r}(e)}function Hv(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Rm(e)}var jv,Wa,Am,cO,uO,Wv,Yv,Kv,_o,pO,dO,Pm,mO,fO,Cm,Tl,gO,No,hO,ku,Xv=B(()=>{p();Am=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",cO=typeof Map<"u",uO=typeof Set<"u",Wv=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",Yv=Am?Symbol.for("immer-nothing"):((jv={})["immer-nothing"]=!0,jv),Kv=Am?Symbol.for("immer-draftable"):"__$immer_draftable",_o=Am?Symbol.for("immer-state"):"__$immer_state",pO={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return "Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return "Unsupported patch operation: "+e},18:function(e){return "The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return "'current' expects a draft, got: "+e},23:function(e){return "'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},dO=""+Object.prototype.constructor,Pm=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,mO=Object.getOwnPropertyDescriptors||function(e){var t={};return Pm(e).forEach(function(o){t[o]=Object.getOwnPropertyDescriptor(e,o);}),t},fO={},Cm={get:function(e,t){if(t===_o)return e;var o=Fi(e);if(!vm(o,t))return function(n,i,a){var l,s=Gv(i,a);return s?"value"in s?s.value:(l=s.get)===null||l===void 0?void 0:l.call(n.k):void 0}(e,o,t);var r=o[t];return e.I||!Vi(r)?r:r===bm(e.t,t)?(ym(e),e.o[t]=Tm(e.A.h,r,e)):r},has:function(e,t){return t in Fi(e)},ownKeys:function(e){return Reflect.ownKeys(Fi(e))},set:function(e,t,o){var r=Gv(Fi(e),t);if(r?.set)return r.set.call(e.k,o),!0;if(!e.P){var n=bm(Fi(e),t),i=n?.[_o];if(i&&i.t===o)return e.o[t]=o,e.R[t]=!1,!0;if(iO(o,n)&&(o!==void 0||vm(e.t,t)))return !0;ym(e),xm(e);}return e.o[t]===o&&(o!==void 0||t in e.o)||Number.isNaN(o)&&Number.isNaN(e.o[t])||(e.o[t]=o,e.R[t]=!0),!0},deleteProperty:function(e,t){return bm(e.t,t)!==void 0||t in e.t?(e.R[t]=!1,ym(e),xm(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var o=Fi(e),r=Reflect.getOwnPropertyDescriptor(o,t);return r&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:r.enumerable,value:o[t]}},defineProperty:function(){Pt(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Pt(12);}},Tl={};Cl(Cm,function(e,t){Tl[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};}),Tl.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Pt(13),Tl.set.call(this,e,t,void 0)},Tl.set=function(e,t,o){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Pt(14),Cm.set.call(this,e[0],t,o,e[0])};gO=function(){function e(o){var r=this;this.O=Wv,this.D=!0,this.produce=function(n,i,a){if(typeof n=="function"&&typeof i!="function"){var l=i;i=n;var s=r;return function(h){var y=this;h===void 0&&(h=l);for(var b=arguments.length,S=Array(b>1?b-1:0),C=1;C<b;C++)S[C-1]=arguments[C];return s.produce(h,function(v){var w;return (w=i).call.apply(w,[y,v].concat(S))})}}var u;if(typeof i!="function"&&Pt(6),a!==void 0&&typeof a!="function"&&Pt(7),Vi(n)){var c=$v(r),d=Tm(r,n,void 0),m=!0;try{u=i(d),m=!1;}finally{m?xu(c):Sm(c);}return typeof Promise<"u"&&u instanceof Promise?u.then(function(h){return gm(c,a),hm(h,c)},function(h){throw xu(c),h}):(gm(c,a),hm(u,c))}if(!n||typeof n!="object"){if((u=i(n))===void 0&&(u=n),u===Yv&&(u=void 0),r.D&&wm(u,!0),a){var g=[],f=[];Nr("Patches").M(n,u,g,f),a(g,f);}return u}Pt(21,n);},this.produceWithPatches=function(n,i){if(typeof n=="function")return function(u){for(var c=arguments.length,d=Array(c>1?c-1:0),m=1;m<c;m++)d[m-1]=arguments[m];return r.produceWithPatches(u,function(g){return n.apply(void 0,[g].concat(d))})};var a,l,s=r.produce(n,i,function(u,c){a=u,l=c;});return typeof Promise<"u"&&s instanceof Promise?s.then(function(u){return [u,a,l]}):[s,a,l]},typeof o?.useProxies=="boolean"&&this.setUseProxies(o.useProxies),typeof o?.autoFreeze=="boolean"&&this.setAutoFreeze(o.autoFreeze);}var t=e.prototype;return t.createDraft=function(o){Vi(o)||Pt(8),ja(o)&&(o=lO(o));var r=$v(this),n=Tm(this,o,void 0);return n[_o].C=!0,Sm(r),n},t.finishDraft=function(o,r){var n=o&&o[_o];process.env.NODE_ENV!=="production"&&(n&&n.C||Pt(9),n.I&&Pt(10));var i=n.A;return gm(i,r),hm(void 0,i)},t.setAutoFreeze=function(o){this.D=o;},t.setUseProxies=function(o){o&&!Wv&&Pt(20),this.O=o;},t.applyPatches=function(o,r){var n;for(n=r.length-1;n>=0;n--){var i=r[n];if(i.path.length===0&&i.op==="replace"){o=i.value;break}}n>-1&&(r=r.slice(n+1));var a=Nr("Patches").$;return ja(o)?a(o,r):this.produce(o,function(l){return a(l,r)})},e}(),No=new gO,hO=No.produce,No.produceWithPatches.bind(No),No.setAutoFreeze.bind(No),No.setUseProxies.bind(No),No.applyPatches.bind(No),No.createDraft.bind(No),No.finishDraft.bind(No),ku=hO;});function El(e){return (t,o)=>{let r=e[t];if(!r)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return r(o)}}function Gi(e,t){return (o,r)=>{let i=r().records.requests[e][t],a=!i||i.status==="UNINITIALIZED"?"LOADING":"FETCHING";o(vr.setRequest({key:t,type:e,status:a}));}}function Ui(e,t,o,r){return n=>{typeof window=="object"&&notifications.show({autoClose:3e3,color:"red",id:t,message:r,title:"Error"}),n(vr.setRequest({key:t,type:e,status:"FAILURE",error:{code:o,message:r}}));}}function jn(e){return t=>{let o=Om(e,t);return (r,n,i)=>(r(Gi(e,o)),zi(i,"create",e)(t).then(l=>(l.ok===!0?r(vr.setCreateRequest({key:o,operation:"create",status:"SUCCESS",type:e,data:l.data})):r(Ui(e,o,l.status,l.error)),l)))}}function vO(e){return t=>{let o=Om(e,t[0]);return (r,n,i)=>(r(Gi(e,o)),zi(i,"createBulk",e)(t).then(l=>(l.ok===!0?r(vr.setCreateRequest({key:o,operation:"createBulk",status:"SUCCESS",type:e,data:l.data})):r(Ui(e,o,l.status,l.error)),l)))}}function Jv(e,t,o){return o.replace(new RegExp(e,"g"),t)}function SO(e){return e.section_id!==void 0}function xO(e){return e.report_id!==void 0}function Qv(e){return t=>{let{create:o}=t;return (r,n,i)=>jn(e)(o)(r,n,i).then(async l=>{if(l.ok){let{data:s}=l,{id:u}=s,{update:c}=t,d=aS(e,{id:u});if(r(Gi(e,`${d}`)),e==="block"&&SO(o)){let m=ku(c,y=>{y.id=u;}),{contentByLocale:g}=m;g&&(m=ku(m,y=>{y.id=u,y.contentByLocale=Object.keys(g).reduce((b,S)=>{let C=g?g[S]:{};return b[S]={...C,id:u},b},{});}));let h=m.inputs?.map(y=>({type:y.type,id:y.id,inputAction:{operation:"create",input:{input_id:y.id,block_id:m.id}}}));return h&&h.length>0&&Zv(e)([m,...h])(r,n,i).then(()=>Wn("section")({id:m.section_id,include:!0})(r,n,i).then(y=>(y.ok&&r(vr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))),zr(e)(m)(r,n,i).then(y=>(y.ok&&r(vr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}if(e==="section"&&xO(o)){let{id:m}=s,g=ku(c,y=>{y.id=m;}),{blocks:f}=g,h=f?.map(y=>({type:y.type,blockcol:y.blockcol,blockrow:y.blockrow,section_id:m,locales:Object.keys(y.contentByLocale).map(b=>b)}));return h&&f&&await vO("block")(h)(r,n,i).then(y=>{if(y.ok){let b=y.data,S=[],C=b.map((v,w)=>{let I={...v},D=I.id,A=f[w];A.contentByLocale&&(I.contentByLocale=Object.keys(A.contentByLocale).reduce((F,z)=>{let j=A.contentByLocale[z];return F[z]={...j,content:{...j.content},id:I.id},F},{}));let{settings:_}=A,{contentByLocale:M,id:$}=I;I.settings=_;let R={id:$,contentByLocale:M,settings:_};return A.inputs.map(F=>F.id).reduce((F,z)=>{let j=f.findIndex(V=>V.id===z);return [...F,j]},[]).map(F=>({...b[F],originalBlock:f[F]})).forEach(F=>{let{id:z,type:j,originalBlock:V}=F;if([E.SELECTOR,E.VIZ].includes(j)){if(R.contentByLocale?.logic?.content?.api){let W=R.contentByLocale?.logic.content.api;R.contentByLocale.logic.content.api=Jv(`(selector${V.id}id)`,`selector${z}id`,W);}if(R.contentByLocale?.logic?.content?.logic){let W=R.contentByLocale.logic.content.logic;R.contentByLocale.logic.content.logic=Jv(`(selector${V.id}id)`,`selector${z}id`,W);}}S.push({id:z,inputAction:{operation:"create",input:{input_id:z,block_id:D}}});}),R});return Zv("block")([...C,...S])(r,n,i)}}),zr(e)(g)(r,n,i).then(y=>(y.ok&&r(vr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}return zr(e)({...c,id:s.id})(r,n,i)}})}}function Wn(e){return t=>{let o=nS(e,t);return (r,n,i)=>{r(Gi(e,o));let a=zi(i,"read",e);if(typeof a!="function"){let l=`Failed to get valid RPC method for entity "${e}"`;return r(Ui(e,o,500,l)),Promise.reject(new Error(l))}return a(t).then(l=>(l.ok===!0?r(vr.setReadRequest({key:o,operation:"read",status:"SUCCESS",type:e,data:l.data})):r(Ui(e,o,l.status,l.error)),l))}}}function zr(e){return t=>{let o=Lm(e,t);return (r,n,i)=>(r(Gi(e,o)),zi(i,"update",e)(t).then(l=>(l.ok===!0?r(vr.setUpdateRequest({key:o,operation:"update",status:"SUCCESS",type:e,data:l.data})):r(Ui(e,o,l.status,l.error)),l)))}}function Zv(e){return t=>{let o=Lm(e,t[0]);return (r,n,i)=>(r(Gi(e,o)),zi(i,"updateBulk",e)(t).then(l=>(l.ok===!0?r(vr.setUpdateRequest({key:o,operation:"updateBulk",status:"SUCCESS",type:e,data:l.data})):r(Ui(e,o,l.status,l.error)),l)))}}function $i(e){return t=>{let o=iS(e,t);return (r,n,i)=>(r(Gi(e,o)),zi(i,"delete",e)(t).then(l=>{l.ok===!0?r(vr.setDeleteRequest({key:o,operation:"delete",status:"SUCCESS",type:e,data:l.data})):r(Ui(e,o,l.status,l.error));}))}}function Om(e,t){if(e==="variant"){let o=t;return `create(variant, [${o.dimension_id}, ${o.name}])`}return `create(${e}, [${Object.keys(t)}])`}function nS(e,t={}){let o=t.id==null?null:`'${t.id}'`;return `read(${e}, ${o}, ${!!t.include})`}function Lm(e,t){let{id:o,...r}=t;return `update(${e}, ${o}, [${Object.keys(r)}])`}function iS(e,t){return `delete(${e}, ${t})`}function aS(e,t){let o=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${o})`}var vr,Eu,eS,kl,tS,oS,rS,Mm=B(()=>{p();Su();xl();Xv();ge();vr=un.actions,Eu={create:Om,read:nS,update:Lm,delete:iS,clone:aS},eS=El({block:jn("block"),dimension:jn("dimension"),formatter:jn("formatter"),report:jn("report"),section:jn("section"),variant:jn("variant"),datasource:jn("datasource")}),kl=El({block:Wn("block"),dimension:Wn("dimension"),formatter:Wn("formatter"),report:Wn("report"),section:Wn("section"),variant:Wn("variant"),datasource:Wn("datasource")}),tS=El({block:zr("block"),dimension:zr("dimension"),formatter:zr("formatter"),report:zr("report"),section:zr("section"),variant:zr("variant"),datasource:zr("datasource")}),oS=El({block:$i("block"),dimension:$i("dimension"),formatter:$i("formatter"),report:$i("report"),section:$i("section"),variant:$i("variant"),datasource:$i("datasource")}),rS=El({block:Qv("block"),section:Qv("section")});});var J={};Yd(J,{addBlockToState:()=>NO,addRunConsumersRunning:()=>_m,cloneEntity:()=>rS,createEntity:()=>eS,deleteEntity:()=>oS,deleteQueryParam:()=>zm,readEntity:()=>kl,readEnvSecrets:()=>$O,readMember:()=>lS,readMetadata:()=>AO,readPrivateBlocks:()=>zO,readUser:()=>MO,recalculateVariables:()=>Zt,removeBlocksFromState:()=>_O,removeDataSourceLogic:()=>UO,removeRunConsumersRunning:()=>Nm,reportSearch:()=>RO,resetSectionState:()=>Dm,revalidateReport:()=>VO,revalidateUrl:()=>FO,searchMember:()=>IO,searchRegenerate:()=>wO,searchRole:()=>OO,searchUser:()=>LO,setCurrentLocale:()=>CO,setPreferredLocale:()=>kO,setPreviews:()=>TO,setQueryParam:()=>Hi,setSectionState:()=>Bm,setStatus:()=>sS,updateEntity:()=>tS,updateMyData:()=>DO,updateUser:()=>BO,urlProxy:()=>PO,variantValidateSlug:()=>EO});function EO(e,t){return async(o,r,n)=>{let i=await n.validateVariantSlug({dimension:e,slug:t});if("error"in i)throw new Error(i.error);return i.data}}function RO(e){return async(t,o,r)=>{let n=await r.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function wO(){return async(e,t,o)=>{let r=await o.regenerateSearch(void 0);if("error"in r)throw new Error(r.error);return r.data}}function lS(e){return async(t,o,r)=>{let n=await r.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function IO(e){return async(t,o,r)=>{let n=await r.searchMember(e);if(n.ok===!0)return n.data;throw new Error(n.error)}}async function cS(e,t,o,r){let n=o().status,i={...n,...r},a={...n.query,...r.query};Object.keys(a).forEach(s=>a[s]===void 0&&delete a[s]);let l={...i,query:a};t(sS(l)),n.activeSection&&t(Zt(e,{query:a}));}function zm(e,t){return async(o,r)=>cS(e,o,r,{query:{[t]:void 0}})}function Hi(e,t,o){return async(r,n)=>cS(e,r,n,{query:{[t]:o}})}function Zt(e,t){return async(o,r)=>{let n=r(),{currentLocale:i}=n.status,a=n.records.entities.block,l=e.formatterFunctions[i],s=e.datasourceFunctions,{parsedParams:u,statusPayload:c}=Jy(n.status,t),{sid:d,bid:m,previews:g,query:f}=u;Object.keys(c).length&&o(Do.setStatus(c));let h={...Nv(g),locale:i,...qo()},y={variables:h,query:f,locale:i};o(Do.addRunConsumersRunning([d]));let b=n.records.entities.section[d],S=async C=>o(lS(C));try{let C=await Hn(a,b&&[b],m,l,y,void 0,S,"section",s),{variables:v,status:w}=C;o(_i.setVariableChange({attributes:h,variables:v,status:w})),o(Do.removeRunConsumersRunning([d]));}catch(C){console.error("Error in runConsumers client side: recalculateVariables",C);}}}function AO(e){return async(t,o,r)=>{let n=await r.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function PO(e){return async(t,o,r)=>{let n=await r.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function OO(){return async(e,t,o)=>{let r=await o.searchRole("");if("error"in r)throw new Error(r.error);return r.data}}function LO(e){return async(t,o,r)=>{let n=await r.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function MO(e){return async(t,o,r)=>{let n=await r.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function BO({user:e}){return async(t,o,r)=>{let n=await r.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function DO(e){return async(t,o,r)=>{let n=await r.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function _O(e){let{removeBlocks:t}=un.actions;return async o=>{await o(t(e));}}function NO(e){let{addBlocks:t}=un.actions;return async o=>{await o(t(e));}}function zO(e){return async(t,o,r)=>{let n=await r.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function FO(e){return async(t,o,r)=>{let n=await r.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function VO(e){return async(t,o,r)=>{let n=await r.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function $O(){return async(e,t,o)=>{let r=await o.readEnvSecrets({});if("error"in r)throw new Error(r.error);return r.data}}function UO(){let{removeDataSourceLogic:e}=un.actions;return async t=>{await t(e());}}var sS,TO,Bm,Dm,CO,kO,_m,Nm,Sr=B(()=>{p();cn();zv();Di();Fn();vl();Ha();xl();Mm();({setStatus:sS,setPreviews:TO,setSectionState:Bm,resetSectionState:Dm,setCurrentLocale:CO,setPreferredLocale:kO,addRunConsumersRunning:_m,removeRunConsumersRunning:Nm}=Do);});function $t(){let e=G(n=>n.status.activeEntity),t=ne();return {activeEntity:e,selectEntity:n=>t(Do.setActiveEntity(n)),unselectEntity:()=>t(Do.setActiveEntity({type:null,id:null}))}}function it(e){let t=ne(),o=G(i=>i.status.sectionState)[e]||{},r=useCallback(i=>{t(Bm({[e]:i}));},[e]),n=useCallback(()=>{t(Dm(e));},[e]);return {sectionVariables:o,setSectionVariables:r,resetSectionVariables:n}}function Il(){let e=ne(),t=G(n=>n.status.isRunConsumersRunning),o=useCallback(n=>{e(_m(n));},[]),r=useCallback(n=>{e(Nm(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:o,removeRunConsumersRunning:r}}function Ot(e){let t=ne();return {opened:G(l=>l.status.sidebarStatus[e]),handlers:{open:()=>t(Do.openSidebar(e)),close:()=>t(Do.closeSidebar(e)),toggle:()=>t(Do.toggleSidebar(e))}}}function Qa(){return G(t=>t.status.currentLocale)}function Za(){return G(t=>t.status.preferredLocale)}function Yi(e){return t=>{let o=ne(),r=useMemo(()=>Eu.read(e,{include:!0}),[]),n=useCallback(a=>{let l=Object.values(a.records.entities[e]),s=a.records.requests[e][r]||{key:r,type:e,status:l==null?"UNINITIALIZED":"SUCCESS"},u=t?l.filter(c=>t.includes(c.id)):l;return Hm(u,s)},[r]),i=G(n);return useEffect(()=>{i.isUninitialized&&o(kl(e,{id:t,include:!0}));},[i.status]),i}}function Al(e,t){let o=useMemo(()=>Eu.clone(e,{id:t}),[t,e]);return G(n=>{let i=n.records.entities[e][t],a=n.records.requests[e][o]||{key:o,type:e,status:i==null?"UNINITIALIZED":"SUCCESS"};return Hm(i,a)})}function Xi(e){return t=>{let o=ne(),r=useMemo(()=>Eu.read(e,{id:t,include:!0}),[t]),n=useCallback(a=>{let l=a.records.entities[e][t],s=a.records.requests[e][r]||{key:r,type:e,status:l==null?"UNINITIALIZED":"SUCCESS"};return Hm(l,s)},[r]),i=G(n);return useEffect(()=>(i.isUninitialized&&t!==null&&o(kl(e,{id:t,include:!0})),()=>{}),[r,i.isUninitialized,o,t]),i}}function Hm(e,t){let o={data:void 0,error:void 0,status:t.status,isUninitialized:t.status==="UNINITIALIZED",isLoading:t.status==="LOADING",isFetching:t.status==="LOADING"||t.status==="FETCHING",isSuccess:t.status==="SUCCESS",isError:t.status==="FAILURE"};return t.status==="UNINITIALIZED"?o:t.status==="LOADING"?{...o,data:e}:t.status==="FETCHING"?{...o,data:e}:t.status==="FAILURE"?{...o,error:t.error}:{...o,data:e}}var jO,ne,G,Ya,Vm,$m,Xa,Rl,Wi,wl,eo,zo,Ye,Ki,qi,Um,Gm,Xe,pS,Ru,yo,pn,Ja,wu,dS,mS,fS,ye=B(()=>{p();Sr();Mm();xl();xt();Lo();vl();(({localeDefault:jO}=Ue())),ne=useDispatch,G=useSelector,Ya=Yi("report"),Vm=Yi("dimension"),$m=Yi("variant"),Xa=Yi("section"),Rl=Yi("block"),Wi=Yi("formatter"),wl=Yi("datasource"),eo=Xi("report"),zo=Xi("section"),Ye=Xi("block"),Ki=Xi("dimension"),qi=Xi("variant"),Um=Xi("formatter"),Gm=Xi("datasource");Xe=(e,t=void 0,o=void 0)=>{if(!e)return {};let r=Ye(e).data,n=G(l=>t||l.variables.variables),i=G(l=>o||l.variables.attributes);return useMemo(()=>r?r.inputs.reduce((l,s)=>({...l,...n[s]}),i):{},[r,i,n])},pS=e=>{let t=Ye(e).data,o=G(i=>i.variables.variables),r=G(i=>i.variables.attributes);return t?useMemo(()=>t?Object.keys(o).reduce((i,a)=>({...i,...t.inputs.includes(parseInt(a,10))?{[a]:o[a]}:{}}),{attributes:r}):{attributes:r},[t,o,r]):{}},Ru=e=>G(t=>t.variables.status[e]),yo=(e=jO)=>useContext(_e).formatterFunctions[e],pn=()=>useContext(_e).datasourceFunctions,Ja=()=>useContext(_e).profilePrefix,wu=(e=void 0,t=void 0)=>{let o=G(i=>i.status.localeDefault),r=G(i=>i.status.query);return {variables:Xe(e),locale:t||o,query:r}},dS=(e,t)=>Object.values(t).filter(r=>Object.keys(r.contentByLocale).some(n=>{let{logic:i}=r.contentByLocale[n].content;return i&&(`${i}`.includes(`formatters.${e}(`)||`${i}`.includes(`${e}{{`))})).length,mS=e=>{if(!e)return 0;let t=G(r=>r.records.entities.formatter),o=G(r=>r.records.entities.block);return useMemo(()=>dS(e,o),[e,t,o])},fS=()=>{let e=G(o=>o.records.entities.formatter),t=G(o=>o.records.entities.block);return useMemo(()=>Object.values(e).reduce((o,r)=>(o[r.name]=dS(r.name,t),o),{}),[e,t])};});var gS,hS=B(()=>{p();em();xl();vl();Ha();gS=()=>configureStore({reducer:{[un.name]:un.reducer,[bu.name]:bu.reducer,[yu.name]:yu.reducer},middleware(e){return e({thunk:{extraArgument:gl("/api/cms/")}})}}),createWrapper(gS);});function Ut(e,t){let o=r=>{let{id:n,skelHeight:i,skelWidth:a,...l}=r,s=t(n);return s.isUninitialized||s.isFetching?jsx(Skeleton,{width:a,height:i}):s.isError?null:jsx(e,{...l,for:s.data})};return o.displayName=`withFetcher(${e.displayName||e.name||"Component"})`,o}var yS=B(()=>{p();});var se=B(()=>{p();Sr();ye();hS();yS();});function SS(e){let {pathSegment:t,profilePrefix:o,siteProps:r}=e,n=Wi();G(c=>c.status.isCMS);let a=wl(),s={...qo()},u=useMemo(()=>({profilePrefix:o,pathSegment:t,siteProps:r,formatterFunctions:vS.reduce((c,d)=>({...c,[d]:n.data?zn(n.data,d):{}}),{}),datasourceFunctions:(a?.data||[]).sort((c,d)=>c.content.order>d.content.order?1:-1).map(c=>({...c,content:{...c.content,pattern:tt(c.content.pattern,{},{variables:s})}}))}),[n,t,o,r,a]);return jsx(_e.Provider,{value:u,children:e.children})}function es(){let e=useContext(_e);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var vS,ZO,_e,xt=B(()=>{p();Lo();Fn();se();Di();_r();(({locales:vS}=Ue())),ZO={pathSegment:"path",formatterFunctions:vS.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",siteProps:{}},_e=createContext(ZO);});function vo(){let{pathSegment:e}=es(),t=useRouter();return useMemo(()=>{let o=t.pathname.split("/");Object.keys(t.query).length>0&&o.pop();let r=o.join("/"),[n,...i]=[].concat(t.query[e]||[]),a=(...l)=>[r,...l].join("/");return {router:t,page:n,params:i,query:t.query,basePath:r,href:a,setSearchParam(l,s){let u={...t.query};s==null||s===""?delete u[l]:u[l]=[].concat(s).join("!"),t.push({pathname:t.pathname,query:u},void 0,{shallow:!0});},matches(...l){return t.asPath===a(...l)},push(l,s,u){let c=a(l);t.push(c,s,u);},replace(l,s,u){let c=a(l);t.replace(c,s,u);}}},[t.asPath])}var Iu=B(()=>{p();xt();});function jm(){let e=ne(),{router:t}=vo(),{asPath:o}=t,[,r]=o.split("?"),n=r?JSON.parse('{"'+decodeURI(r).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'):{},{currentLocale:i,locales:a}=G(s=>s.status),l=n.locale||"";return useEffect(()=>{l&&l!==""&&a.includes(l)&&l!==i&&e(J.setCurrentLocale(l));},[]),i}var xS=B(()=>{p();se();Iu();});function os(e){return t=>Object.values(t.records.entities[e])}function ns(e){return Object.values(e.records.entities.datasource||[]).sort((t,o)=>t.content.order>o.content.order?1:-1).map(t=>{let o={...iL};return {...t,content:{...t.content,pattern:tt(t.content.pattern,{},{variables:o})}}})}var TS,Ji,CS,rs,iL,dn=B(()=>{p();Di();_r();TS=e=>e.records.entities.section,Ji=e=>e.records.entities.block;CS=os("block"),rs=os("formatter"),iL=qo();});function sL(e,t){let o=[],r={},n=1/0;for(let i of e){let a=parseInt(i.settings.order);a<n&&(n=a);}for(let i of e){let{id:a,settings:l}=i,s=parseInt(l.order),u=t[a]?t[a]:!1,c=aL(u,a),d={id:a,order:s,label:t[a]?t[a][`title${a}title`]:`Title ${a}`,iconProps:c,children:[]};if(r[a]=d,s===n)o.push(d);else {let m=s-1,g;for(let f=e.indexOf(i)-1;f>=0;f--){let h=e[f],y=parseInt(h.settings.order);if(y===m){g=r[h.id];break}else if(y<m){g=r[h.id];break}}g?g.children.push(d):o.push(d);}}return o}function is(e=1,t=6,o=[]){let r=G(m=>m),n=G(m=>m.variables.variables),i=G(m=>m.variables.status),a=Xa(),l=CS(r).filter(m=>m.type===E.TITLE&&o.includes(m.id)),s=Object.fromEntries(l.map(m=>[m.id,m])),u=Object.fromEntries(l.map(m=>[m.id,n[m.id]])),c=Object.fromEntries(l.map(m=>[m.id,i[m.id]])),d=useMemo(()=>{if(a.isSuccess&&s){let m=[];return a.data.sort(go).forEach(g=>{let f=g.blocks.reduce((h,y)=>s[y]&&s[y].type===E.TITLE?h.concat([s[y]]):h,[]);m=m.concat(f.sort((h,y)=>go(h,y,"blockrow")));}),Object.keys(i).length?m.filter(g=>{let f=parseInt(g.settings.order||"1",10);return f>=e&&f<=t&&c[g.id]?.allowed&&!c[g.id]?.hiddenByCascade}):[]}},[o,a,s,c]);return useMemo(()=>d&&d?.length>0?sL(d,u):[],[d,u])}var aL,Wm=B(()=>{p();se();dn();mr();ge();aL=(e,t)=>({iconType:e[`title${t}_iconType`],icon:e[`title${t}_icon`],iconSize:e[`title${t}_iconSize`],iconVariant:e[`title${t}_iconVariant`],iconRadius:e[`title${t}_iconRadius`]});});var Qi=B(()=>{p();Iu();xS();Wm();});function cL(e={required:!1}){let{update:t,data:o,status:r}=useSession(e);return {update:t,user:o?.user,status:r,isLoading:r==="loading"}}var to,mn=B(()=>{p();to=cL;});function oo(e){let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),i=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(i)?i.replace(n,a=>t[a]):i}var Ml=B(()=>{p();});function sf(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var GS=B(()=>{p();});function IM(e){return e?wM(sf(oo(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:!0,strict:!0,trim:!0}):""}var So,qn=B(()=>{p();Ml();GS();So=IM;});var JS=B(()=>{});function df({dimmed:e=!1,label:t,root:o=!0,value:r,parentIsArray:n=!1,level:i=0}){let a=useMantineTheme();if(i===pf)return null;let l=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),s=uf(r),u=r,c=JSON.stringify(u),d=100,m=1e3,g=!!(c&&c.length>d),f=10,h={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(s==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:h,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:i+1<pf?Object.keys(r).sort((y,b)=>{let S=uf(r[y]),C=uf(r[b]);return S!==C?QS.indexOf(S)-QS.indexOf(C):y.localeCompare(b)}).map(y=>jsx(df,{root:!1,label:y,value:r[y],level:i+1},y)):l})]})});if(s==="array"){let y=r.length>f,b=y?r.slice(0,f):r,S=y?r.length-f:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:h,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,p:0,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[i+1<pf?b.map((C,v)=>jsx(df,{root:!1,label:v,value:C,level:i+1,parentIsArray:!0},v)):l,y&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",S," other elements]"]})]})]})})}return s==="string"?u=g?`"${u.substring(0,d)} ... "`:`"${u}"`:s==="error"?u=`Error: ${u.message}`:s==="undefined"?u=s:u.toString&&(u=u.toString()),jsxs(Group,{noWrap:!0,spacing:0,children:[jsx(Text,{color:e?"dimmed":a.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap"},weight:700,children:o?`{{${t}}}`:n?`[${t}]`:t}),jsx(Prism,{className:"cr-variable",language:"jsx",noCopy:!0,scrollAreaComponent:"div",styles:{root:{flex:"1 1 100%",textAlign:"right",overflow:"hidden"},code:{padding:"5px 0 5px 5px"},scrollArea:{marginLeft:"5px"},line:{paddingRight:"5px"}},children:u}),g&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:!0,children:[jsx(HoverCard.Target,{children:jsx(ActionIcon,{children:jsx(IconCodePlus,{})})}),jsx(HoverCard.Dropdown,{w:500,children:jsx(Text,{size:"sm",maw:"100%",style:{wordBreak:"break-all",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:c.substring(0,m)})})]})]})}var uf,QS,pf,ea,zu=B(()=>{p();JS();uf=e=>{let t=typeof e;if(t==="object"){if(e===null)return "undefined";Array.isArray(e)?t="array":["Error","EvalError","ReferenceError","SyntaxError"].includes(e.constructor.name)&&(t="error");}return t},QS=["object","array","string","number"],pf=5;ea=df;});var Fu,mf=B(()=>{p();Fu=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function rB({reserved:e=[],id:t,variables:o={},showInternal:r=!1}){let i=Ye(t==="attributes"?null:t).data,a=i?i.type:"block",l=i?.type&&i?.id?`${i.type}${i.id}`:"",s=Object.keys(o).filter(r?()=>!0:u=>!Fu(l)(u));return jsx(Stack,{spacing:0,children:s.length?s.map(u=>jsx(ea,{dimmed:e.includes(u),label:u,value:o[u]},u)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${a}`})})})}var Tr,ds=B(()=>{p();zu();se();mf();Tr=rB;});var gn,Rx,wx,Ox,Ix,Ax,Px,Fr,Jo,ys,qt=B(()=>{p();ge();gn={display:{label:"Size",defaultValue:"block",options:[{label:"Full Width",value:"block"},{label:"Inline",value:"inline"}]}},Rx={useProxy:{label:"Use proxy (avoid CORS)",defaultValue:"false",options:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}},wx={[E.IMAGE]:{...gn},[E.PARAGRAPH]:{...gn},[E.SUBTITLE]:{...gn},[E.SELECTOR]:{...gn},[E.STAT]:{...gn},[E.VIZ]:{...gn},[E.TITLE]:{order:{label:"Importance",defaultValue:"1",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},search:{label:"Search on Click",defaultValue:"off",options:[{label:"Off",value:"off"},{label:"Inline",value:"inline"},{label:"Modal",value:"modal"}]},addComparisonName:{label:"Show member name on comparison mode",defaultValue:"no",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]},...gn},[E.GENERATOR]:{...Rx},[E.SECTION_FLAG]:{...Rx},[E.NAV]:{variant:{label:"Nav variant",defaultValue:"inline",options:[{label:"Inline",value:"inline"},{label:"Fixed",value:"fixed"},{label:"Jump",value:"jump"}]},min:{label:"Min Title level",defaultValue:"1",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},max:{label:"Max Title level",defaultValue:"6",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},icons:{label:"Show icons",defaultValue:"yes",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]}},[E.MULTIHIERARCHY_SELECTOR]:{...gn}},Ox=e=>e&&wx[e]?wx[e]:gn,Ix={left:"flex-start",right:"flex-end",justify:"stretch"},Ax={justify:"apart"},Px={justify:"space-between"},Fr=e=>Ix[e]?Ix[e]:e,Jo=e=>Ax[e]?Ax[e]:e,ys=e=>Px[e]?Px[e]:e;});var xD,Lx,Mx=B(()=>{p();xD=({value:e,handleChange:t,position:o="right"})=>jsxs(Group,{position:o,children:[jsx(Text,{size:"xs",children:"Aligment"}),jsx(SegmentedControl,{size:"xs",defaultValue:e,onChange:r=>t("align",r),data:[{label:jsx(IconAlignLeft,{size:"0.7rem"}),value:"left"},{label:jsx(IconAlignCenter,{size:"0.7rem"}),value:"center"},{label:jsx(IconAlignRight,{size:"0.7rem"}),value:"right"},{label:jsx(IconAlignJustified,{size:"0.7rem"}),value:"justify"}]})]}),Lx=xD;});function DD({id:e,display:t="button",handleChange:o}){let r=ne(),n=Ye(e).data,[i,a]=useState(!1),l=BD(n),s=f=>{typeof f=="boolean"?u("width",{...l,...f?{stretch:!0}:Dx}):u("width",{...l,value:f});},u=(f,h)=>{n&&(o?o(f,h):r(J.updateEntity("block",{id:e,settings:{...n.settings,[f]:h}})));};if(!n)return null;let c=Ox(n.type),d=Bx[l.unit],m=f=>{let{defaultValue:h}=Bx[f];u("width",{...l,value:h,unit:f});},g=jsxs(Stack,{spacing:"xs",children:[jsx(Lx,{value:n.settings.align||"left",handleChange:u,position:"apart"}),Object.entries(c).map(([f,{label:h,defaultValue:y,options:b}])=>jsxs(Group,{spacing:"xs",position:"apart",noWrap:!0,style:{width:"100%"},children:[h&&jsx(Text,{size:"xs",children:h}),jsx(SegmentedControl,{defaultValue:String(n.settings[f]||y),onChange:S=>u(f,S),data:b,size:"xs"})]},f)),![E.GENERATOR,E.SECTION_FLAG].includes(n.type)&&jsxs(Group,{spacing:"xs",children:[jsx(Text,{size:"xs",children:"Width"}),jsxs(Group,{spacing:"xs",children:[!l.stretch&&jsxs("div",{children:[jsx(MD,{currUnit:l.unit,changeUnit:m}),jsx(NumberInput,{defaultValue:parseInt(d.defaultValue,10),disabled:l.stretch,onChange:f=>s(f),size:"xs",value:Number.isNaN(l.value)?void 0:parseInt(l.value,10),...d})]}),jsx(Checkbox,{size:"xs",label:"Stretch",checked:l.stretch,onChange:f=>s(f.currentTarget.checked)})]})]},"width")]});return t==="button"?jsxs(Popover,{opened:i,onClose:()=>a(!1),position:"bottom-end",withinPortal:!0,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{onClick:()=>a(f=>!f),children:jsx(IconPalette,{size:20})})}),jsx(Popover.Dropdown,{children:g})]}):jsx(Paper,{p:"md",children:g})}var LD,Gl,Bx,Dx,MD,BD,Wu,Hl=B(()=>{p();qt();se();Mx();ge();LD=["px","%"],Gl={px:e=>Number.isNaN(parseFloat(e))?"px":`${e}px`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),"%":e=>Number.isNaN(parseFloat(e))?"%":`${e}%`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")},Bx={px:{defaultValue:400,min:25,step:5,formatter:Gl.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:Gl["%"]}},Dx={stretch:!1,unit:"px",value:"400"},MD=({currUnit:e,changeUnit:t})=>jsxs(Group,{position:"apart",children:[jsx(Text,{size:"xs",fw:"bold",children:"Unit"}),jsx(Group,{spacing:3,children:LD.map(o=>jsx(Anchor,{component:"button",size:"xs",td:e===o?"underline":"none",onClick:()=>t(o),children:o},o))})]}),BD=e=>{let t=e?.settings?.width||{};return t&&["stretch","value","unit"].every(o=>Object.prototype.hasOwnProperty.call(t,o))?t:Dx};Wu=DD;});var JD,Gx,Hx=B(()=>{p();JD=(e,t)=>{let o=e.allLabel||"All",r=e.colorKey||"",n=e.data||[],i=e.hideLabel||"false",a=e.resetSectionVars||"false",l=e.iconKey||"",s=e.label||"Unlabeled Multihierarchy Selector",u=e.levels||[],c=e.limit||void 0,d=e.placeholder||"",m=e.searchIndexKey||"",g=e.searchIndexSeparator||"",f,h;return e.defaultValue&&e.defaultValueType&&(f=e.defaultValue,h=e.defaultValueType),(!f||!h)&&(f=[],h=""),{allLabel:o,colorKey:r,data:n,defaultValue:f,defaultValueType:h,hideLabel:i,resetSectionVars:a,iconKey:l,id:t,label:s,levels:u,limit:c,placeholder:d,searchIndexKey:m,searchIndexSeparator:g}},Gx=JD;});var QD,jx,ZD,Wx,Kx=B(()=>{p();ge();cu();QD=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{id:t,label:t}:t):[],jx=(e,t)=>t===ft.MULTI&&!Array.isArray(e)?[e]:e,ZD=(e,t)=>{let o=e.type||ft.SINGLE,r=e.component||"Selector",n=e.hideLabel||"false",i=e.resetSectionVars||"false",a=e.name||"Unlabeled Selector",l=QD(e.options||[]),s;if(e.defaultValue){let u=jx(e.defaultValue,o);Bi(o,u,l)&&(s=u);}if(!s){let u=l&&l[0]&&l[0].id||l[0]||"";s=jx(u,o);}return {id:t,name:a,type:o,options:l,component:r,defaultValue:s,hideLabel:n,resetSectionVars:i}},Wx=ZD;});var e_,Qo,Rf=B(()=>{p();ge();Hx();Kx();e_={[E.SELECTOR]:Wx,[E.MULTIHIERARCHY_SELECTOR]:Gx},Qo=e_;});var t_,o_,r_,n_,gt,Xn=B(()=>{p();t_=e=>typeof e=="string"?e.replace(/&nbsp;<\/p>/g,"</p>"):e,o_=e=>typeof e=="string"&&e==="<p><br></p>"?"":e,r_=e=>typeof e=="string"?e.replace(/^<p>(.*)<\/p>$/,"$1"):e,n_=e=>e&&r_(o_(t_(e))),gt=n_;});function Te({id:e="",component:t="p",order:o=1,size:r="md",html:n,style:i={},append:a=jsx(Fragment,{}),isPreview:l=!1}){let s=s_(n),u=l_(n,l),c=i&&i.align?String(i.align):"left",d=Text,m={};return t==="h"?(d=Title,m={id:e,order:o}):m={component:t,size:r},jsxs(d,{align:c||s.align||"left",...m,children:[u,a]})}var s_,l_,Tt=B(()=>{p();s_=(e="<></>")=>{let t=null,o={replace:r=>(r instanceof Element$1&&!t&&(t=r.attribs,t.align=r.attribs.style?r.attribs.style.replace("text-align: ",""):"",delete t.children),r)};return e?(Yx(e,o),t):{}},l_=(e="",t=!1)=>{let o={replace:r=>{let{type:n}=r;if(r instanceof Element$1&&n==="tag"){let{name:i,attribs:a,children:l,parent:s}=r;if(i==="p"&&!s)return jsx(Fragment,{children:domToReact(l,o)});if(i==="a"){let{href:u,target:c}=a,d=u.indexOf("http")===0,m=!!(c&&c==="_blank"),g=jsx(Anchor,{...a,href:a.href,target:"_blank",children:domToReact(l,o)});return d||m||t?g:jsx(Anchor,{...a,href:a.href,children:domToReact(l,o)})}else {if(i==="strong")return jsx(Text,{component:"strong",children:domToReact(l,o)});if(i==="em")return jsx(Text,{component:"em",fs:"italic",children:domToReact(l,o)});if(i==="u")return jsx(Text,{component:"u",td:"underline",children:domToReact(l,o)});if(i==="sup")return jsx(Text,{component:"sup",style:{verticalAlign:"super",fontSize:"0.75em"},children:domToReact(l,o)});if(i==="sub")return jsx(Text,{component:"sub",style:{verticalAlign:"sub",fontSize:"0.75em"},children:domToReact(l,o)});if(i==="span")return jsx(Text,{component:"span",children:domToReact(l,o)});if(i==="br")return jsx("br",{})}return jsx(Fragment,{children:domToReact(l,o)})}else if(r instanceof Text$1&&r.type==="text")return jsx(Fragment,{children:r.data})}};return Yx(e,o)};});function If({paragraph:e,tooltip:t,settings:o}){let r=gt(t);return jsx(Te,{component:"p",html:e,style:o,append:t?jsx(Bt,{content:r,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{})})}var Jx=B(()=>{p();Xn();hn();Tt();});function st({iconType:e="none",iconVariant:t="transparent",icon:o="",iconRadius:r="md",iconSize:n="md",iconPadding:i="1",blockType:a}){let[l,s]=useState(void 0),u=e==="custom"?o:`/api/cms/read/icons/${e}/icon.svg?name=${o}`,c=/^.*\.svg*$/.test(u)||e==="tabler";return useEffect(()=>{c&&gu.get(u,{responseType:"text"}).then(m=>m.data).then(s).catch(()=>{});},[e,c,u]),jsx(Fragment,{children:e!=="none"&&o&&o!==""&&!!(l||!c)&&jsx(ThemeIcon,{className:`bespoke-${a}-icon-wrapper`,variant:t,radius:r,size:n,p:parseInt(i),dangerouslySetInnerHTML:l&&c?{__html:l}:void 0,children:c?null:jsx(Image,{src:u,alt:"Title Icon"})})})}var na=B(()=>{p();});function Pf({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:u,_iconPadding:c}){if(!t&&!o&&!e)return null;let d=n&&n.align?n.align:"left";return jsxs(Group,{spacing:"md",position:Jo(d),children:[jsx(st,{blockType:"stat",iconType:i,iconVariant:a,iconRadius:s,iconSize:u,icon:l,iconPadding:c}),jsxs(Stack,{spacing:0,children:[t&&jsx(Te,{component:"div",size:"md",html:t,style:n}),o&&jsx(Te,{component:"div",size:"xl",html:o,style:n}),e&&jsx(Te,{component:"div",size:"sm",html:e,style:n})]},"stat"),r&&jsx(Bt,{content:r})]})}var Zx=B(()=>{p();hn();na();Tt();qt();});function Of({subtitle:e,tooltip:t,settings:o}){let r=e||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{spacing:"sm",position:Jo(n),children:[jsx(Te,{size:"sm",html:r}),t&&jsx(Bt,{content:t,style:{display:"inline-flex"}})]})}var tT=B(()=>{p();hn();Tt();qt();});function io(e){let t=useContext(C_);return e?t[e]??t:t}var C_,$r=B(()=>{p();C_=createContext({});});var R_,w_,Jn,Wl=B(()=>{p();R_={try_another:"Try another search or filter.",search:"Search",filters_all:"All",no_results:"No Results",load_more:"Load more",select_report:"Select Report",select_variant:"Select Variant",count_format:".2s",report:{},dimension:{},variant:{}},w_=createContext({metadata:[],loadingItems:!1,setLoadingItems:()=>null,loadingMetadata:!1,setLoadingMetadata:()=>null,resultCount:{},totalCount:{},setResultCount:()=>null,activePage:1,setActivePage:()=>null,pageSize:10,results:[],filters:{},doQuery:()=>null,setFilters:()=>null,query:"",setQuery:()=>null,debouncedQuery:"",currentPageTotal:10,selectorStructure:[],translations:R_,setTranslations:()=>null,showSelectors:!0}),Jn=()=>useContext(w_);});function A_({translations:e}){let{loadingItems:t,setFilters:o,selectorStructure:r,filters:n,showSelectors:i}=Jn(),a=f=>{let h=f===null||Number.isNaN(f)?void 0:parseInt(f,10);h!==n.profile?o({profile:h,variant:void 0}):h&&o({profile:void 0,variant:void 0});},l=f=>{let h=f===null?void 0:typeof f=="string"&&f.includes(",")?f:parseInt(f,10);h!==n.variant?o({...n,variant:h}):h&&o({...n,variant:void 0});},s=f=>f<1e3?f:format$1(e.count_format)(f).replace(/\.0+([a-zA-Z]*)$/,"$1"),u=r.length===2?r[1].id:n.profile,c=u?r.find(f=>f.id===u):void 0,d=c&&c.variants&&n.variant?c.variants.find(f=>f.id===n.variant):void 0,m=useMemo(()=>r.map(f=>({value:String(f.id||""),label:(e?.dimensionIcon?.[f.name]?`${e?.dimensionIcon?.[f.name]} `:"")+(e?.dimension[f.name]||f.name)+(!t&&(!c||f.id===c?.id)?` (${s(f.members_count)})`:"")})),[e,c,r]),g=useMemo(()=>c?.variants?.map(f=>({value:String(f.id||""),label:(e?.variantIcon?.[f.name]?`${e?.variantIcon?.[f.name]} `:"")+(e?.variant[f.name]||f.name)+(!t&&(!d||f.id===d?.id)?` (${s(f.members_count)})`:"")}))??[],[e,d,r]);return jsx(Fragment,{children:i&&jsxs(Fragment,{children:[jsx(MediaQuery,{largerThan:1e3,styles:{display:"none"},children:jsxs(Group,{className:"bespoke-explore-reports-select-container",position:"center",mb:"md",children:[jsx(Select,{className:"bespoke-explore-reports-select",data:m,value:String(c?.id||""),onChange:f=>a(f),label:e.select_report||"Select Report",placeholder:e.select_report||"Select Report",clearable:typeof c?.id<"u",style:{width:"450px"}}),c?.variants&&c.variants.length>2&&jsx(Select,{className:"bespoke-explore-variant-select",data:g,value:String(d?.id||""),onChange:f=>l(f),label:e.select_variant||"Select Variant",placeholder:e.select_variant||"Select Variant",clearable:typeof d?.id<"u",style:{width:"450px"}})]})}),jsx(MediaQuery,{smallerThan:1e3,styles:{display:"none"},children:jsxs("div",{children:[jsx(Group,{position:"center",className:"bespoke-explore-reports-selector",mb:"md",children:r.map(f=>jsxs(Button,{"data-selected":f.id===c?.id?"true":"false","data-report-name":f.name,variant:f.id===c?.id?"outline":"subtle",onClick:()=>a(f.id),rightIcon:f.id&&f.id===c?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.dimensionIcon?.[f.name]??void 0,children:[jsx(Text,{span:!0,className:"bespoke-explore-reports-name",dangerouslySetInnerHTML:{__html:e?.dimension[f.name]??f.name}}),!t&&(!c||f.id===c?.id)&&jsx(Text,{span:!0,size:"xs",ml:"0.2rem",className:"bespoke-explore-reports-count",children:`(${s(f.members_count)})`})]},`p-${f.id}`))}),c&&c.variants&&c.variants.length>2&&jsx(Group,{position:"center",style:{minHeight:"36px"},className:"bespoke-explore-variant-selector",mb:"md",children:c.variants.map(f=>jsxs(Button,{"data-selected":f.id===d?.id?"true":"false","data-variant-name":f.name,variant:f.id===d?.id?"outline":"subtle",onClick:()=>l(f.id),rightIcon:f.id&&f.id===d?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.variantIcon?.[f.name]?jsx(Text,{span:!0,dangerouslySetInnerHTML:{__html:e.variantIcon[f.name]}}):void 0,children:[jsx(Text,{span:!0,className:"bespoke-explore-variant-name",dangerouslySetInnerHTML:{__html:e?.variant[f.name]??f.name}}),!t&&(!d||f.id===d?.id)&&jsx(Text,{span:!0,size:"xs",ml:"0.2rem",className:"bespoke-explore-variant-count",children:`(${s(f.members_count)})`})]},`v-${f.id}`))})]})})]})})}var lT,cT=B(()=>{p();Wl();lT=A_;});function Zo(){return useMantineTheme().other.bespokeStyles??{}}var ia=B(()=>{p();});function Mf({reportId:e,reportName:t,members:o,href:r,onClick:n}){let i=o.map(l=>jsx(Image,{src:l.image.src,height:160,imageProps:{loading:"lazy"},alt:l.name},l.id)),a=o.map(l=>jsxs(Stack,{children:[jsx(Text,{weight:500,children:l.name}),jsx(Badge,{color:"green",variant:"light",w:"fit-content",children:l.variant})]},l.id));return jsxs(Card,{className:`report-${e}-tile`,shadow:"sm",p:"lg",radius:"md",withBorder:!0,children:[jsx(Card.Section,{children:jsx(Group,{grow:!0,spacing:0,children:i})}),jsx(Group,{position:"apart",mt:"md",mb:"xs",children:a}),jsx("a",{href:r,onClick:n,children:jsx(Button,{variant:"light",color:"blue",fullWidth:!0,mt:"md",radius:"md",children:`See ${t} Report`})})]})}function F_({profile:e,profilePrefix:t,onSelect:o,reportTile:r}){let n=useRouter(),i=n.locale,{localeDefault:a}=Ue(),s=`${i===a?"":`/${i}`}${t}${e.path}`,u=e.members.map(g=>({original_id:g.metadata.id,name:g.name,id:g.id,dimension_id:g.metadata.dimension.id,dimension:g.metadata.dimension.name,variant_id:g.metadata.variant.id,variant:g.metadata.variant.name,image:{src:`/api/cms/member/image?member=${g.id}&size=thumb`,alt:g.name}})),c=g=>{n.push(`${g}`),o&&o();},d=g=>{g.preventDefault(),c(s);},m=z_(r);return jsx(Grid.Col,{xs:12,sm:6,md:4,lg:4,xl:3,children:jsx(m,{reportId:e.report.id,reportName:e.report.name,members:u,href:s,onClick:d})},e.id)}var z_,mT,Bf=B(()=>{p();ia();Lo();z_=e=>{let{components:t}=Zo(),o=Mf;return t?.ReportTile&&(o=t?.ReportTile),e&&(o=e),o};mT=F_;});function j_({profilePrefix:e,onSelect:t=()=>{},reportTile:o}){let[r,n]=useState(500),i=useRef(null),{results:a}=Jn(),l=i.current?.offsetTop||0,s=50;return useEffect(()=>{let{innerHeight:u}=window;n(u-l-s);},[l]),jsx(ScrollArea,{offsetScrollbars:!0,type:"always",h:r,ref:i,children:jsx(Grid,{align:"stretch",children:a.map(u=>jsx(mT,{profile:u,profilePrefix:e,reportTile:o,onSelect:t},u.id))})})}var fT,gT=B(()=>{p();Bf();Wl();fT=j_;});function q_(){let{activePage:e,setActivePage:t,pageSize:o,currentPageTotal:r}=Jn();return jsx(Group,{position:"center",children:jsx(Pagination,{value:e,onChange:i=>{t(i);},total:Math.ceil(r/o),size:"sm",py:"xs"})})}var bT,yT=B(()=>{p();Wl();bT=q_;});function iN({profilePrefix:e,initialReportId:t,initialVariantId:o,translations:r,onSelect:n,reportTile:i,initialQuery:a}){let l=useRef(),s=Jn(),{query:u,setQuery:c,results:d,loadingItems:m,loadingMetadata:g,translations:f,setTranslations:h,initExplore:y}=s;useEffect(()=>{y&&y(t,o,a);},[y]),useEffect(()=>{m||l.current?.focus();},[m]),useEffect(()=>{r&&h(r);},[r]);let b=()=>{c("");};return jsxs(Container,{fluid:!0,pt:"1em",children:[jsx(TextInput,{placeholder:f.search,mb:"md",size:"xl",onChange:S=>c(S.target.value),readOnly:g||m,icon:jsx(IconSearch,{size:24}),value:u,rightSectionWidth:100,rightSectionProps:{style:{justifyContent:"flex-end",padding:"0 15px 0 0"}},rightSection:jsxs(Group,{align:"center",children:[(g||m)&&jsx(Loader,{size:28}),u&&u!==""&&jsx(ActionIcon,{onClick:b,children:jsx(IconTrash,{size:24})})]}),ref:l}),jsx(lT,{translations:f}),jsx(LoadingOverlay,{visible:g||m}),!m&&d.length===0&&jsx(Alert,{title:f.no_results,color:"blue",children:f.try_another}),jsx(fT,{profilePrefix:e,onSelect:n,reportTile:i}),jsx(bT,{})]})}var ST,xT=B(()=>{p();cT();gT();yT();Wl();ST=iN;});function mN({exploreProps:e={profilePrefix:"/",locale:dN},icon:t=jsx(IconSearch,{size:20}),actionIconProps:o={},modalProps:r={},tooltipProps:n={},tooltipText:i="Click to Explore",showIcon:a=!0,showTooltip:l=!1,children:s}){let[u,c]=useState(!1),d={variant:"light",size:"md",radius:"md",...o},m={fullScreen:!0,opened:u,onClose:()=>c(!1)},g=jsx(ActionIcon,{...d,onClick:()=>c(!0),children:t}),f=a?jsxs(Group,{spacing:"sm",style:{cursor:"pointer"},children:[s,g]}):s;return l&&(f=jsx(Tooltip,{label:i,...n,children:f})),jsxs(Fragment,{children:[jsx(Modal,{...m,...r,children:u&&jsx(ST,{...e,onSelect:()=>c(!1)})}),jsx("div",{onClick:()=>c(!0),children:s?f:jsx(Fragment,{children:g})})]})}var dN,kT,ET=B(()=>{p();xT();Lo();({localeDefault:dN}=Ue());kT=mN;});var vN,RT,wT=B(()=>{p();vN=forwardRef(({id:e,members:t,...o},r)=>{let n=t.map(i=>jsxs(Stack,{align:"center",children:[jsx(Text,{weight:500,children:i.name}),jsx(Badge,{color:"green",variant:"light",children:i.variant})]},i.id));return jsx("div",{ref:r,children:jsx(Group,{position:"apart",grow:!0,...o,children:n})},e)}),RT=vN;});function ON({locale:e,profilePrefix:t="/report",autocompleteProps:o={},tooltipProps:r={},tooltipText:n="Click to search",searchReportParams:i={},callback:a,children:l}){let s=useRouter(),u=s.locale,{localeDefault:c}=Ue(),d=u===c?"":`/${u}`,m=PN(o?o.itemComponent:null),[g,f]=useState(""),[h,y]=useDebouncedValue(g,500),[b,S]=useState([]),[C,v]=useState(!1),[w,k]=useState(!1),[I,D]=useState(!1),[A,_]=useState(!l),M=()=>{_(!1);},$=()=>{_(!0),q();},R=useRef(),L=useClickOutside(M),O=o?.searchConfig?.searchLimit??10,q=()=>{v(!0);let Q={query:h,format:"profiles",locale:e,limit:O,visible:!0,includes:!0,noImage:!1,variant:[],dimension:[],report:[],all:!1,...i};gu.get("/api/cms/search/reports",{params:Q}).then(re=>{re&&re.data&&re.data.data&&re.data.data.results&&S(re.data.data.results.map(Z=>({id:Z.id,reportName:Z.report.name,href:`${d}${t}${Z.path}`,reportPath:`${Z.path}`,profilePrefix:t,value:`VALUE: ${Z.id}`,members:Z.members.map(N=>({original_id:N.metadata.id,name:N.name,id:N.id,variant:N.metadata.variant.name,image:{src:`/api/cms/member/image?member=${N.id}&size=thumb`,alt:N.name}}))}))),v(!1),R.current?.focus();}).catch(re=>{console.error(re),v(!1);});};useEffect(()=>{I&&h.length>=(o.searchConfig?.queryThreshold??0)&&q();},[I,h,o.searchConfig?.queryThreshold]),useEffect(()=>{y(),R.current&&A&&D(!0);},[]),useEffect(()=>{y(),R.current&&A&&D(!0);},[A]);let F=Q=>{_(!1),a?a(Q):(s.push(Q.href),k(!0));},z=Q=>{Q.includes("VALUE:")||f(Q);},{searchConfig:j,...V}=o,W={placeholder:"Search",size:"md",icon:jsx(IconSearch,{}),...V,data:b},X=jsx(Autocomplete,{value:g,itemComponent:m,onItemSubmit:F,onChange:z,filter:()=>!0,disabled:(C||w)&&!I,limit:O,maxDropdownHeight:250,rightSection:jsx(Group,{spacing:0,position:"right",children:C?jsx(Loader,{size:20}):jsx(Fragment,{})}),rightSectionWidth:50,ref:R,...W});return l?jsx(Tooltip,{label:n,disabled:A,...r,children:jsxs(Group,{ref:L,spacing:"sm",align:"center",style:{cursor:"pointer"},children:[!A&&jsx("div",{onClick:()=>_(!0),children:l}),A&&jsx(Fragment,{children:X}),A?jsx(ActionIcon,{variant:"light",onClick:M,children:jsx(IconX,{size:20})}):jsx(ActionIcon,{variant:"light",onClick:$,children:jsx(IconSearch,{size:20})})]})}):X}var PN,LT,MT=B(()=>{p();ia();wT();Lo();PN=e=>{let{components:t}=Zo(),o=RT;return t?.ReportItem&&(o=t?.ReportItem),e&&(o=e),o};LT=ON;});function DN(){let{components:e}=Zo(),{modal:t,inline:o}=e?.search??{};return {modal:t,inline:o}}function Yl(e,t,o,r,n){let i=DN(),a=G(d=>({reportId:d.variables.attributes.report_id,variantId:d.variables.attributes.variant_id1,title:d.variables.attributes.name1})),l=useRouter(),s=Ja(),u=io();return useMemo(()=>{let d=e;return t==="modal"?d=jsx(kT,{exploreProps:{locale:l.locale||BT,profilePrefix:s,translations:u.explore,initialReportId:a.reportId,initialVariantId:a.variantId,initialQuery:a.title},tooltipText:u.explore?.tooltip,modalProps:i.modal,...n,children:e}):t==="inline"&&(d=jsx(LT,{locale:l.locale||BT,profilePrefix:s,callback:o,tooltipText:u.explore?.tooltip,...r,autocompleteProps:i.inline,children:e})),d},[t,e])}var BT,zf=B(()=>{p();$r();se();ye();ET();MT();Lo();ia();({localeDefault:BT}=Ue());});function Hr(){let e=ne();return useMemo(()=>async t=>await e(J.readMember(t)),[e])}var sa=B(()=>{p();se();});var _T=B(()=>{p();xt();se();cn();Fn();dn();sa();});function Cr(){return useContext(FN)}var FN,Qn=B(()=>{p();_T();FN=createContext({active:!1,variables:null,status:null,setComparisonVariables:null,comparisonLoaded:!1,loading:!1,error:!1});});function Vf({title:e,tooltip:t,slug:o,_iconType:r,_iconVariant:n,_icon:i,settings:a,_iconRadius:l,_iconSize:s,_iconPadding:u,asComparison:c=!1}){let{print:d}=tr(),m=gt(e)||"<span class='cr-block-placeholder'>Title</span>",g=a&&a.order?parseInt(a.order,10):1,f=g<=6?g:1,h=a&&a.search?a.search:"off",y=a&&a.align?a.align:"left",b=Cr(),S=G(D=>D.status.previews),v=(c?b.status.previews:S).map(D=>D.name).join(" | "),w=jsxs(Group,{children:[jsx(st,{blockType:"title",iconType:r,iconVariant:n,iconRadius:l,iconSize:s,icon:i,iconPadding:u}),jsx(Te,{id:o||void 0,component:"h",order:f,style:a,html:m})]}),k=Yl(w,h),I=a&&a.addComparisonName==="yes"&&b.active;return jsxs(Group,{spacing:"sm",position:Jo(y),children:[jsxs("div",{children:[d?w:k,I&&jsx(Text,{className:"bespoke-comparison-title",children:v})]}),t&&jsx(Bt,{content:t})]})}var zT=B(()=>{p();Xn();na();Tt();zf();Qn();se();Zn();hn();qt();});function Xu(e,t,o,r=!1,n=!1){let i=useRouter(),{query:a,locale:l}=i,s=G(M=>M),u=useDispatch(),c=Cr(),d=G(M=>r&&c.variables?c?.variables?.attributes:M.variables.attributes),m=Ji(s),g=rs(s),f=ns(s),h=zn(g,l),y=Xe(e,r&&c.active?c?.variables.variables:void 0,r&&c.active?c?.variables.attributes:void 0),b=G(M=>r?c.variables.variables:M.variables.variables),S=G(M=>r?c.variables.status:M.variables.status),C=Hr(),{sectionVariables:v,resetSectionVariables:w}=it(t),{addRunConsumersRunning:k,removeRunConsumersRunning:I}=Il(),D=r&&c.active?`${o}Compare`:o,A=r&&c.active?Object.fromEntries(Object.entries(a).filter(([M])=>M.match(HN)).map(([M,$])=>[M.replace("Compare",""),$])):Object.fromEntries(Object.entries(a).filter(([M])=>M.match(jN)).map(([M,$])=>[M.replace("Compare",""),$]));return useCallback(M=>{let $={locale:l,query:{...A,[o]:M},variables:y},R=new URLSearchParams(window.location.search);R.set(D,M),window.history.replaceState(null,null,`?${R.toString()}`),k([t]),Hn(m,void 0,e,h,$,{variables:b,status:S},C,"report",f).then(L=>{c.active&&r?c.setComparisonVariables({attributes:d,variables:L.variables,status:L.status}):u(_i.setVariableChange({attributes:d,variables:L.variables,status:L.status})),n&&v&&w(),I([t]);});},[e,t,o,D,a,m,u,h,i,y.attributes,r,n,S,b])}var HN,jN,$f=B(()=>{p();cn();se();Fn();dn();Ha();ye();sa();Qn();HN=/\w*Compare\b/,jN=/selector\d+id/;});function jf(e){let{name:t,settings:o,options:r,id:n,defaultValue:i,section:a,component:l,asComparison:s,hideLabel:u,resetSectionVars:c}=e,{print:d}=tr(),m=e1(n),g=Xu(n,a,m,s,c==="true"),f=s?`${m}Compare`:m,[h,y]=useState(i),[b,S]=useState(VT(i,[])),C=JSON.stringify(r),v=o[At.DISABLED]||!1,w=useMemo(()=>r?.map(M=>({value:M.id,label:M.label,imageUrl:M.imageUrl})),[C]),k=d?r.filter(M=>b.includes(M.id)).map(M=>M.label).join(", "):"",I=d&&h&&r.find(M=>M.id===h)?.label||"",D=e.hideLabel==="true"?jsx(Fragment,{}):jsx(Te,{component:"div",html:t,size:"sm",style:o});if(useEffect(()=>{if(!v){let $=new URLSearchParams(window.location.search).get(f)||i;$&&(e.type===ft.SINGLE?y($):S(VT($,i)));}},[window.location.search,i]),w.length<=1)return jsx(Fragment,{});let A=M=>{S(M),g(M.join(","));},_=M=>{y(M),g(M);};return jsx(Fragment,{children:d?jsxs(Box,{style:{display:"flex",alignItems:"center"},children:[D,jsx(Button,{ml:"sm",radius:"xl",variant:"outline",children:e.type===ft.SINGLE?I:k})]}):jsx(Box,{children:{[ft.SINGLE]:l===su.SEGMENTED_CONTROL?jsxs("div",{children:[jsx(Text,{size:"sm",fw:500,display:u==="true"?"none":"block",children:D}),jsx(SegmentedControl,{data:w,disabled:v,value:w.map(M=>M.value).includes(h)?h:"",onChange:_,fullWidth:!0})]}):jsx(Select,{label:D,data:w,disabled:v,value:h,itemComponent:t1,onChange:_,styles:{label:{display:u==="true"?"none":"block"}}}),[ft.MULTI]:jsx(MultiSelect,{label:D,data:w,value:b,onChange:A,disabled:v,styles:{label:{display:u==="true"?"none":"block"}}})}[e.type]})})}var e1,VT,t1,UT=B(()=>{p();Tt();ge();$f();Zn();e1=e=>`selector${e}id`,VT=(e,t)=>e&&typeof e=="string"?e.split(","):t,t1=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{noWrap:!0,children:[t&&!["","undefined"].includes(t)&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});function Ju(){return jsx("div",{children:"Generator"})}var GT=B(()=>{p();});function Wf(e){let{alt:t,src:o,desc:r,title:n,settings:i,...a}=e,l=gt(t),s=gt(o),u=gt(r),c=jsx("img",{src:s,alt:l,style:a}),d=i&&i.align?String(i.align):"left";return (u&&u.length||n&&n.length)&&(c=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Fr(d),spacing:"sm",children:[n&&jsx(Te,{component:"p",html:n,style:i}),c,r&&jsx(Te,{component:"p",size:"sm",html:r,style:i})]})),s&&l?c:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var HT=B(()=>{p();Xn();Tt();qt();});function Jl(){return Jl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r]);}return e},Jl.apply(this,arguments)}var jT=B(()=>{p();});function Ql(){return Ql=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r]);}return e},Ql.apply(this,arguments)}var WT=B(()=>{p();});function la(e,t,o){var r,n=(r=o.initialDeps)!=null?r:[],i;return function(){var a;o.key&&o.debug!=null&&o.debug()&&(a=Date.now());var l=e(),s=l.length!==n.length||l.some(function(f,h){return n[h]!==f});if(!s)return i;n=l;var u;if(o.key&&o.debug!=null&&o.debug()&&(u=Date.now()),i=t.apply(void 0,l),o.key&&o.debug!=null&&o.debug()){var c=Math.round((Date.now()-a)*100)/100,d=Math.round((Date.now()-u)*100)/100,m=d/16,g=function(h,y){for(h=String(h);h.length<y;)h=" "+h;return h};console.info("%c\u23F1 "+g(d,5)+" /"+g(c,5)+" ms",`
@@ -24,9 +24,9 @@ import 'react/jsx-runtime';
24
24
  import '@mantine/core';
25
25
 
26
26
  var no=Object.defineProperty;var so=(e,t)=>{for(var r in t)no(e,r,{get:t[r],enumerable:!0});};function ee(e,t){return e.request(t).then(r=>{let{status:o,data:n}=r;return "error"in n?{ok:!1,status:o,error:n.error}:{ok:!0,status:o,wrapper:n.wrapper,data:n.data}},r=>{if("isAxiosError"in r){let{status:o,data:n}=r.response||{status:500};return {ok:!1,status:o,error:n?.error??r.message}}return {ok:!1,status:500,error:r.message}})}function U(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>ee(e,{...o,method:"GET",params:r?r(n):n})}function V(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>ee(e,{...o,method:"POST",data:r?r(n):n})}function ie(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>ee(e,{...o,method:"DELETE",params:r?r(n):n})}function Le(e,t){return r=>ee(e,{method:"POST",url:`images/save/${t}`,params:{prompt:r.prompt,provider:t}})}function Ne(e,t){return r=>ee(e,{method:"GET",url:`images/search/${t}`,params:{prompt:r.prompt,page:r.page,provider:t}})}function zt(e,t){return ()=>ee(e,{method:"GET",url:`list/icons/${t}`,params:{provider:t}})}function jt(e,t){return r=>ee(e,{method:"GET",url:`read/icons/${t}/icon.svg`,params:{name:r.name}})}var fe=e=>({id:e}),io=e=>{if(e.mode==="slugs"){let t=e.slugs.map(r=>[r.variantSlug,r.memberSlug].join("/")).join(",");return {...e,slugs:t}}return ["related","whole"].includes(e.mode)?{...e}:{...e,[e.mode]:e[e.mode].join(",")}};function Me(e){let t=nt.create({baseURL:e});return {createBulkBlock:V(t,"create/bulk/block"),createBlock:V(t,"create/block"),createDimension:V(t,"create/dimension"),createFormatter:V(t,"create/formatter"),createReport:V(t,"create/report"),createSection:V(t,"create/section"),createVariant:V(t,"create/variant"),createDatasource:V(t,"create/datasource"),deleteBlock:ie(t,"delete/block",fe),deleteDimension:ie(t,"delete/dimension",fe),deleteFormatter:ie(t,"delete/formatter",fe),deleteReport:ie(t,"delete/report",fe),deleteSection:ie(t,"delete/section",fe),deleteVariant:ie(t,"delete/variant",fe),deleteDatasource:ie(t,"delete/datasource",fe),readBlock:U(t,"read/block"),readDimension:U(t,"read/dimension"),readFormatter:U(t,"read/formatter"),readReport:U(t,"read/report"),readSection:U(t,"read/section"),readVariant:U(t,"read/variant"),readDatasource:U(t,"read/datasource"),updateBulkBlock:V(t,"update/bulk/block"),updateBlock:V(t,"update/block"),updateDimension:V(t,"update/dimension"),updateFormatter:V(t,"update/formatter"),updateReport:V(t,"update/report"),updateSection:V(t,"update/section"),updateVariant:V(t,"update/variant"),updateDatasource:V(t,"update/datasource"),searchReport:U(t,"search/reports"),validateVariantSlug:U(t,"validate/variant"),readMember:U(t,"read/members",io),readMemberImage:U(t,{url:"member/image",responseType:"blob"}),searchMember:U(t,"search/members"),updateMember:U(t,"update/members"),imageLocalSearch:Ne(t,"local"),imageLocalSave:Le(t,"local"),imageFlickrSearch:Ne(t,"flickr"),imageFlickrSave:Le(t,"flickr"),imageUnsplashSearch:Ne(t,"unsplash"),imageUnsplashSave:Le(t,"unsplash"),imageUploadSave:Le(t,"upload"),imageAdobeSearch:Ne(t,"adobe"),imageAdobeSave:Le(t,"adobe"),readMetadata:U(t,"read/metadata"),regenerateSearch:V(t,"search/regenerate"),urlProxy:U(t,"url/proxy"),searchRole:U(t,"auth/search/roles"),searchUser:U(t,"auth/search/users"),readUser:U(t,"auth/read/user"),updateUser:V(t,"auth/update/user"),updateMyData:V(t,"auth/update/me"),revalidateReport:U(t,"revalidate/report"),revalidateUrl:U(t,"revalidate/url"),readPrivateBlocks:V(t,"read/blocks/private"),listTablerIcons:zt(t,"tabler"),readTablerIcon:jt(t,"tabler"),readEnvSecrets:U(t,"read/secrets")}}function co(e,t){return +(e<t)-+(e>t)}function Ke(e,t,r="ordering"){return co(t[r],e[r])}function pt(e){let t=1+76.18009173/e-86.50532033/(e+1)+24.01409822/(e+2)-1.231739516/(e+3)+.00120858003/(e+4)-536382e-11/(e+5);return (e-.5)*Math.log(e+4.5)-(e+4.5)+Math.log(t*2.50662827465)}function Gt(e,t,r){let o=0,n=1,s=1,a=1,i=0,c=0,u;for(;Math.abs((s-c)/s)>1e-5;)c=s,u=-(t+i)*(t+r+i)*e/(t+2*i)/(t+2*i+1),o=s+u*o,n=a+u*n,i+=1,u=i*(r-i)*e/(t+2*i-1)/(t+2*i),s=o+u*s,a=n+u*a,o/=a,n/=a,s/=a,a=1;return s/t}function uo(e,t,r){let o,n;if(e<0)n=0;else if(e>=t)n=1;else {e=Math.floor(e);let s=r,a=e+1,i=t-e,c=a+i,u=Math.exp(pt(c)-pt(i)-pt(a)+a*Math.log(s)+i*Math.log(1-s));s<(a+1)/(c+2)?o=u*Gt(s,a,i):o=1-u*Gt(1-s,i,a),n=1-o;}return Math.round(n*1e5)/1e5}function lo(e){return {.99999:15.137,.99:6.635,.95:3.841,.9:2.706}[e]}function De(e,t,r,o){let n=t/(1-t),s=0,a=1,i=0,c=0;for(;s<=e;)c+=a,s>=r&s<=o&&(i+=a),c>1e30&&(i/=1e30,c/=1e30,a/=1e30),s+=1,a=a*n*(e+1-s)/s;return i/c}function po(e,t,r){let o=e/t,s=(100-r*100)/2,a,i;if(e===0)a=0;else {let c=o/2,u=0,l=o,p=s/100;for(;l-u>1e-5;)De(t,c,e,e)*.5+De(t,c,e+1,t)>p?(l=c,c=(u+c)/2):(u=c,c=(l+c)/2);a=c;}if(e===t)i=0;else {let c=(1+o)/2,u=o,l=1,p=s/100;for(;l-u>1e-5;)De(t,c,e,e)*.5+De(t,c,0,e-1)<p?(l=c,c=(u+c)/2):(u=c,c=(l+c)/2);i=c;}return {lci:a,uci:i}}function fo(e,t){let r=e,o=t,n=r,s=o,a=95,i=.5,c=.5,l=(100-a)/2/100,p=n;for(;c>1e-5;)c/=2,Ye((1+p)*i/(1-i),p+1,1e10)+.5*Ye((1+p)*i/(1-i),p,p)>l?i-=c:i+=c;let d=(1+p)*i/(1-i)/s;for(i=.5,c=.5,l=(100-a)/2/100;c>1e-5;)c/=2,Ye((1+p)*i/(1-i),0,p-1)+.5*Ye((1+p)*i/(1-i),p,p)<l?i-=c:i+=c;let b=(1+p)*i/(1-i)/s;return {lci:d,uci:b}}function Ye(e,t,r){let o=1,n=0,s=0,a=0;for(;a<e||o>n*1e-10;)n+=o,a>=t&a<=r&&(s+=o),n>1e30&&(s/=1e30,n/=1e30,o/=1e30),a+=1,o=o*e/a;return s/n}var Ht={binomialCdf:uo,binP:De,computeMidP:po,criticalValue:lo,smr:fo};var _e={d3:{...mo,...yo,...Ro,...go},d3plus:{assign:assign,closest:closest,date:date,formatAbbreviate:formatAbbreviate,merge:merge,strip:strip,titleCase:titleCase},stats:Ht};var Kt={jwt:xo};var Wt=(e,t={})=>{let r={libs:Kt,...t};function o(s){return Function("globals",...s.vars,`with (globals) { ${s.logic} }`).bind(r,r)}function n(s){if(s.vars&&s.logic)return o(s);for(let a in s)Array.isArray(s[a])?s[a]=s[a].map(i=>isObject(i)?n(i):i):isObject(s[a])&&(s[a]=n(s[a]));return s}return n(e)};var Co=()=>{let e=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",t=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[e];return t.includes(e)||t.push(e),{localeDefault:e,locales:t}},re=Co;re();var Ue=new schema.Entity("block",{},{mergeStrategy(e,t){return t.block_input?e||{}:{...e,...t}}});Ue.define({consumers:[Ue],inputs:[Ue]});var Qt=new schema.Entity("variant"),Xt=new schema.Entity("dimension",{variants:[Qt]},{processStrategy(e){return {...e,variants:"variants"in e?e.variants:[]}}}),Zt=new schema.Entity("section",{blocks:[Ue]}),Po=new schema.Entity("report",{dimensions:[Xt],sections:[Zt]},{processStrategy(e){return {...e,sections:"sections"in e?e.sections.sort(Ke):[]}}}),Lo=new schema.Entity("formatter"),_o=new schema.Entity("datasource"),Oo={report:Po,section:Zt,block:Ue,dimension:Xt,variant:Qt,formatter:Lo,datasource:_o};function We(e,t){let r=Oo[e];if(!r)throw new Error(`Invalid entity type: ${e}`);let{entities:o}=normalize(t,[r]);return {report:me(o,"report"),dimension:me(o,"dimension"),section:me(o,"section"),block:me(o,"block"),variant:me(o,"variant"),formatter:me(o,"formatter"),datasource:me(o,"datasource")}}function me(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}var Jt=(e,t=void 0)=>{let{sid:r,bid:o,previews:n=[],query:s={}}=t||{},a,i,c={};return r?(a=r,c.activeSection=a):a=e.activeSection,n.length>0?(i=n,c.previews=i.filter(Boolean)):i=e.previews,{parsedParams:{sid:a,bid:o,previews:i,query:s},statusPayload:c}};var wo={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},ae=createSlice({name:"records",initialState:wo,reducers:{set:(e,t)=>{let r=t.payload;return {entities:Fe(e.entities,r.entities||{}),requests:Fe(e.requests,r.requests||{}),reports:r.reports||e.reports,tree:r.tree||e.tree}},setRequest:(e,t)=>{let r=t.payload;e.requests[r.type][r.key]=r;},setCreateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=We(r.type,o),s=Fe(e.entities,n);if(e.entities=s,r.type==="report"){let a=r.data;e.reports?e.reports.indexOf(a.id)===-1&&(e.reports=[...e.reports,a.id]):e.reports=[a.id];}else if(r.type==="dimension"){let a=r.data;e.entities.report[a.report_id].dimensions.push(a.id),e.entities.report[a.report_id].dimensions=Qe(s.report[a.report_id].dimensions,s.dimension);}else if(r.type==="variant"){let a=r.data;e.entities.dimension[a.dimension_id].variants.push(a.id);}else if(r.type==="section"&&!Array.isArray(r.data)){let a=r.data;e.entities.report[a.report_id].sections.push(a.id),e.entities.report[a.report_id].sections=Qe(s.report[a.report_id].sections,s.section);}else if(r.type==="block")if(Array.isArray(r.data)){let a=r.data,i=a[0],c=a.map(u=>u.id);e.entities.section[i.section_id].blocks.concat(c);}else {let a=r.data;e.entities.section[a.section_id].blocks.push(a.id);}}},setReadRequest(e,t){let r=t.payload;if(r.type!=="report"&&(e.requests[r.type][r.key]=r),r.status==="SUCCESS"){let o=We(r.type,r.data),n=Fe(e.entities,o);e.entities=n;}},setUpdateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=We(r.type,o),s,a,i;if(r.type==="block"&&!Array.isArray(r.data)){let u=e.entities.block[r.data.id].inputs,l=n.block[r.data.id].inputs;s=u.length!==l.length,s&&(i=u.length>l.length,a=i?u.filter(p=>!l.includes(p))[0]:l.filter(p=>!u.includes(p))[0]),Object.values(n.block).forEach(p=>{p.block_input&&delete n.block[p.id];});}let c=Fe(e.entities,n);if(e.entities=c,r.type==="dimension"){let u=r.data;e.entities.report[u.report_id].dimensions=Qe(c.report[u.report_id].dimensions,c.dimension);}else if(r.type==="section"&&!Array.isArray(r.data)){let u=r.data;e.entities.report[u.report_id].sections=Qe(c.report[u.report_id].sections,c.section);}else if(r.type==="block"&&!Array.isArray(r.data)){let u=r.data;s&&(i?e.entities.block[a].consumers=e.entities.block[a].consumers.filter(l=>l!==u.id):e.entities.block[a].consumers.push(u.id));}}},setDeleteRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let{id:o,parentId:n,parentType:s}=r.data;if(delete e.entities[r.type][o],s&&n!=null){let a=`${r.type}s`;No(e.entities[s][n][a],o);}}},removeBlocks:(e,t)=>{let r=t.payload,o={...e.entities.block};return r.forEach(n=>{delete o[n];}),{...e,entities:{...e.entities,block:o}}},addBlocks:(e,t)=>{let r=t.payload;return {...e,entities:{...e.entities,block:{...e.entities.block,...r}}}},removeDataSourceLogic:e=>{let t={...e.entities.datasource};Object.keys(t).forEach(r=>{e.entities.datasource[r].content.useProxy&&(delete e.entities.datasource[r].content.logic,delete e.entities.datasource[r].content.testUrl,delete e.entities.datasource[r].content.access);});}},extraReducers:{[HYDRATE]:(e,t)=>{let r=t.payload.records,o=r.entities;return {entities:o,reports:Object.values(o.report).map(n=>n.id),requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},tree:r.tree}}}});function Fe(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,{...e[r],...t[r]}]))}function Qe(e,t){return e.map(n=>t[n]).sort(Ke).map(n=>n.id)}function No(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1);}var Re=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",Xe=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[Re];Xe.includes(Re)||Xe.push(Re);var Uo={localeDefault:Re,locales:Xe,currentLocale:Re,preferredLocale:Re,showToolbar:!1,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:!0,settings:!1,reportEditor:!1},isCMS:!1,isRunConsumersRunning:[]},Ze=createSlice({name:"status",initialState:Uo,reducers:{setStatus:(e,t)=>{Object.assign(e,t.payload);},setPreviews(e,t){e.previews=t.payload;},setCurrentLocale(e,t){e.currentLocale=t.payload;},setPreferredLocale(e,t){e.preferredLocale=t.payload;},setSectionState(e,t){e.sectionState={...e.sectionState,...t.payload};},resetSectionState(e,t){e.sectionState={...e.sectionState,[t.payload]:{}};},setActiveEntity(e,t){e.activeEntity=t.payload;},openSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!0};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!1};},toggleSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!e.sidebarStatus[t.payload]};},addRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.concat(t.payload);},removeRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.filter(r=>!t.payload.includes(r));}},extraReducers:{[HYDRATE]:(e,t)=>({...e,previews:t.payload.status.previews})}}),Oe=Ze.actions;var qo={attributes:{},variables:{},status:{}},Je=createSlice({name:"variables",initialState:qo,reducers:{setVariableChange:(e,t)=>{e.attributes={...e.attributes,...t.payload.attributes},e.variables={...e.variables,...t.payload.variables},e.status={...e.status,...t.payload.status};}},extraReducers:{[HYDRATE]:(e,t)=>({attributes:{...e.attributes,...t.payload.variables.attributes},status:{...e.status,...t.payload.variables.status},variables:{...e.variables,...t.payload.variables.variables}})}}),er=Je.actions;var tr=()=>configureStore({reducer:{[ae.name]:ae.reducer,[Ze.name]:Ze.reducer,[Je.name]:Je.reducer},middleware(e){return e({thunk:{extraArgument:Me("/api/cms/")}})}}),rr=createWrapper(tr);var ut={};so(ut,{addBlockToState:()=>cs,addRunConsumersRunning:()=>Kr,cloneEntity:()=>Vr,createEntity:()=>Dr,deleteEntity:()=>Fr,deleteQueryParam:()=>Zn,readEntity:()=>ze,readEnvSecrets:()=>ds,readMember:()=>Wr,readMetadata:()=>es,readPrivateBlocks:()=>us,readUser:()=>ns,recalculateVariables:()=>Xr,removeBlocksFromState:()=>is,removeDataSourceLogic:()=>fs,removeRunConsumersRunning:()=>Yr,reportSearch:()=>Wn,resetSectionState:()=>Hr,revalidateReport:()=>ps,revalidateUrl:()=>ls,searchMember:()=>Xn,searchRegenerate:()=>Qn,searchRole:()=>rs,searchUser:()=>os,setCurrentLocale:()=>Hn,setPreferredLocale:()=>Kn,setPreviews:()=>Gn,setQueryParam:()=>Jn,setSectionState:()=>Gr,setStatus:()=>jr,updateEntity:()=>Ur,updateMyData:()=>as,updateUser:()=>ss,urlProxy:()=>ts,variantValidateSlug:()=>Yn});var{localeDefault:Ho}=re();function J(e){return {variables:e.variables||{},query:e.query||{},locale:e.locale||Ho}}var Ee={SINGLE:"single",MULTI:"multi"};var dt={ALLOWED:"allowed",ALLOWED_LOGIC:"allowedLogic",IGNORE_CASCADE:"ignoreCascade"},Ko={ACCESS:"access",ACCESS_LOGIC:"accessLogic"},Yo={DISABLED:"disabled"},Wo={FALLBACK:"fallback"};var Qo={IMAGE:"image",PARAGRAPH:"paragraph",SELECTOR:"selector",STAT:"stat",SUBTITLE:"subtitle",TITLE:"title",NAV:"nav",RESET_BUTTON:"reset_button",COMPARISON_BUTTON:"comparison_button",TABLE:"table",BUTTON:"button",MULTIHIERARCHY_SELECTOR:"multihierarchy_selector",FALLBACK:"fallback"},ft={GENERATOR:"generator",RELATED:"related",VIZ:"visualization",SECTION_FLAG:"section_flag"},mt="logic",S={...Qo,...ft},ar={NAME:"name",DESCRIPTION:"description",...dt,...Ko,...Wo,...Yo};var en=Zo(process.env.REPORTS_LOGGING),he=tn;function tn(e,t,r,o,n=void 0,s){let a={},i=[],{locale:c}=J(s);try{if(t){let u=new Proxy(console,{get(p,d){return rn(d,"log","debug","info","warn","error")?(...f)=>{i.push(`${d} ${Date.now()} - ${f.map(b=>format(b)).join(" ")}`),en&&p[d](...f);}:p[d]}}),l;return n?l=new Function(e,"console","libs","formatters","locale","variables",r)(t,u,_e,o,c,n):l=new Function(e,"console","libs","formatters","locale",r)(t,u,_e,o,c),typeof l=="object"&&Object.keys(l).length>0&&Object.assign(a,l),{vars:a,error:null,log:i,output:l}}return {vars:a,error:"Invalid API Link",log:i}}catch(u){return {vars:a,error:u.message,log:i}}}function rn(e,...t){return t.includes(e)}function yt(e){return e.reduce((t,r,o)=>(o?o===e.length-1&&o===1?t+=` and ${r}`:o===e.length-1?t+=`, and ${r}`:t+=`, ${r}`:t+=r,t),"")}var Se=on;function on(e,t,r,o=!1){let{variables:n}=J(r);if(!e)return e;let s=/([A-z0-9]*)\{\{([^\}]+)\}\}/g;return e.replace(s,(i,c,u)=>{let l=d=>d;if(c){let d=c.replace(/^\w/g,f=>f.toLowerCase());d in t?l=t[d]:l=f=>`${c}${f}`;}let p=Array.isArray(n[u])?yt(n[u]):n[u];if(p===void 0)return o?i:"N/A";try{return l(p,_e,t)}catch(d){return console.error(`Error using formatter ${l.name}
27
- `,`Error message: ${d.message}`),"N/A"}})}var Rt=(e,t,r)=>{let{variables:o}=r,n=a=>a.allowed==="never"?!1:!a.allowed||a.allowed==="always"||o[a.allowed],s={...e};return Object.keys(s).forEach(a=>{typeof s[a]=="string"?s[a]=Se(s[a],t,r):Array.isArray(s[a])?s[a]=s[a].filter(n).map(i=>typeof i=="object"?Rt(i,t,r):typeof i=="string"?Se(i,t,r):i):typeof s[a]=="object"&&s[a]!==null&&!(s[a]instanceof Date)&&(s[a]=Rt(s[a],t,r));}),s},tt=Rt;var ir=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];var nn=(e,t,r)=>{if(!r)return !1;if(e===Ee.SINGLE)return r.find(n=>n.id===t);let o=Array.isArray(t)?t:t.split(",");return Array.isArray(o)&&o.every(n=>r.map(s=>s.id).includes(n))},gt=nn;function Et(e,t,r,o,n=!1){let{variables:s}=J(o),a=tt({logic:t},r,o).logic,i=he("variables",s,a,r,void 0,o),{vars:c,log:u,error:l}=i,p=c.type||Ee.SINGLE,d=c.component||"Selector",f=c.hideLabel||"false",b=c.resetSectionVars||"false",A=c.name||"Unlabeled Selector",m=ir(c.options||[]),L=_=>p===Ee.MULTI&&!Array.isArray(_)?[_]:_,T=c.defaultValue,x;if(T&&(T=L(T),gt(p,T,m)&&(x=T)),!x){let _=m&&m[0]&&m[0].id||m[0]||"";x=L(_);}if(n&&typeof window<"u"){let _=`selector${e}id`,K=new URLSearchParams(window.location.search),w=Object.fromEntries(K)[_];w&&!gt(p,w,m)&&w!==void 0&&(K.delete(_),window.history.replaceState(null,null,`?${K.toString()}`));}return {config:{name:A,type:p,options:m,defaultValue:x,component:d,hideLabel:f,resetSectionVars:b},log:u,error:l}}function ht(e,t,r){if(!e)return !1;let o=Array.isArray(r)?r:r.split(",");return Array.isArray(o)&&o.every(n=>e.map(s=>`${s[`${t} ID`]}`).includes(n))}function St(e,t,r,o,n=!1){let{variables:s}=J(o),a=tt({logic:t},r,o).logic,i=he("variables",s,a,r,void 0,o),{vars:c,log:u,error:l}=i;if(n&&typeof window<"u"){let d=`multihierarchySelector${e}-value`,f=`multihierarchySelector${e}-type`,b=new URLSearchParams(window.location.search),A=Object.fromEntries(b),m=A[d],L=A[f];m&&m!==void 0&&L&&L!==void 0&&!ht(c.data,L,m)&&(b.delete(d),b.delete(f),window.history.replaceState(null,null,`?${b.toString()}`));}return {config:c,log:u,error:l}}var sn=(e,t,r)=>{let o=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),s=new URLSearchParams(t).get(o),a=n||s;if(r.type===Ee.MULTI){let u=a?a.split(","):r.defaultValue,l=r.options.filter(p=>u.includes(p.id));return {[`selector${e}id`]:u,[`selector${e}label`]:(l||[]).map(p=>p.label)}}let i=a&&r.options.find(u=>u.id===a)?a:r.defaultValue,c=r.options.find(u=>u.id===i);return {[`selector${e}id`]:i,[`selector${e}label`]:c&&c.label||void 0}},cr=sn;var an=(e,t,r)=>{let o=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,s=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),a=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),i=new URLSearchParams(t).get(o),c=new URLSearchParams(t).get(n),u=s||i,l=a||c,p=u?u.split(","):r.defaultValue||[],d=l||r.defaultValueType||"",f=r.data?.filter(b=>p.includes(`${b[`${d} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:p,[`multihierarchySelector${e}label`]:[...new Set((f||[]).map(b=>b[d]))],[`multihierarchySelector${e}type`]:d}},ur=an;var{localeDefault:lr,locales:cn}=re(),un=Object.values(ft),ln=(e,t=lr)=>e&&un.includes(e.type)?{locale:mt,locales:[mt]}:{locale:t,locales:cn},pr=(e,t=lr)=>{if(!e)return {};let{locale:r}=ln(e,t);return e.contentByLocale?.[r]?.content};function pn(e,t){let r=Object.values(t),o=r.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(r.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(s=>o.includes(s)))).map(n=>[n.id,n]))}var dr=pn;var fr=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((r,o)=>r[o],e):e;var mr="|||";var yr="SECTION_ALLOWED";function bt(e){return e.type===S.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}function fn(){let{publicRuntimeConfig:e}=dn(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((r,o)=>(r[`ENV_${o}`]=t[o]||"N/A",r),{})}}var Ve=fn;function mn(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,r])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:r}),{})}var Rr=mn;var ce=Zo(process.env.NEXT_PUBLIC_REPORTS_DEBUG),En=process.env.REPORTS_ORIGIN||"",hn=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,Sr=5;try{Sr=parseInt(`${hn||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}gr(nt,{retries:Sr,retryDelay:gr.exponentialDelay,onRetry:(e,t,r)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",r.url),console.error(t.message);}});nt.interceptors.request.use(e=>({...e,requestStart:Date.now()}));nt.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));var Sn=(e,t,r)=>{let o=Se(e,t,r);return o.startsWith("http")||(o=`${En}${o.startsWith("/")?"":"/"}${o}`),o},{urlProxy:bn}=Me("/api/cms");function ot(e){return e.ok!==void 0}function rt(e){this.message=e,this.name="ApiFetchException";}var Er=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;async function Tn(e,t,r="en",o,n){let s=Date.now(),a=e,i,c=Ve(),u=Rr(),l={envs:{...c,...u}},d=new URL(e).searchParams;if(d.has("bespoke_slugs")){let T=new RegExp(`[?&]bespoke_slugs=${d.get("bespoke_slugs")}`,"g");a=a.replace(T,"");}let f={datasource:void 0};o.find(T=>{if(!T.content?.pattern)return !1;try{let x=new RegExp(T.content.pattern,"gm");return x.test(a)?(f.datasource=T,!0):x.test(a)}catch{return !1}});let b=n?n.settings:{},A=!!(b&&b.useProxy&&b.useProxy==="true"),m=f.datasource&&typeof f.datasource.content.useProxy=="boolean"?f.datasource.content.useProxy:!1,L=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(a)}`;if(typeof window=="object"&&(A||m)){let T=await bn({url:a,timeout:Er});if(T.ok===!0)i=T.data;else throw new rt(T?.error)}else try{let x={url:a,timeout:Er};if(f.datasource){let K=await Wt({vars:["url","libs"],logic:f.datasource.content.logic},l)(a);if(K.axiosConfig)x=K.axiosConfig;else throw new rt(`AxiosConfig is missing in Data Source ${f.datasource.name} (ID: ${f.datasource.id}).`)}let $=await nt(x);if($.status===200)$.headers["content-type"]==="text/csv"?i=csvParse($.data):i=$.data;else throw new rt("No response for: "+a)}catch(T){throw new rt(T.message)}if(d.has("bespoke_slugs")){let T=d.get("bespoke_slugs");if(T){let x=T.split(",");if(x.length===3){let[$,_,K]=x,O=fr(i,K);if(O&&Array.isArray(O)){let w=Array.from(new Set(O.map(C=>`${C[_]}`).filter(C=>!["","undefined"].includes(C))));if(w.length>0){let C=w.join("").length>2e3,P=await t({mode:C?"whole":"ids",ids:C?void 0:w,all:!1,locale:r,variant:[parseInt($,10)],output:"lite",limit:w.length+1,allowNulls:!0}).then(N=>{let F=[];return ot(N)?N.ok&&(F=N.data.results):F=N.results,F&&Array.isArray(F)?F:[]}).catch(N=>(console.error(`Error hydrating slugs for Variant: ${$}, Key: ${_}, Accessor: ${K}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(N),[]));if(P){let N=Object.fromEntries(P.map(F=>[F.id,`/${F.variant_slug}/${F.slug}`]));O.map(F=>(F.bespoke_slug=N[F[_]]?N[F[_]]:null,F));}}}}}}return {data:i,requestDuration:Date.now()-s,finalUrl:m||A?L:a,apiDataSource:f.datasource?f.datasource:!1}}function An(e){this.name="BlockException",this.message=e;}async function hr(e,t,r,o,n){let{locale:s,variables:a,query:i}=J(r),c=xn(e,r,a,t),u=null,l=e.contentByLocale?.logic?.content?.api,p=null,d=null,f=null,b=null,A=null;if(!c)return {outputVariables:{},renderVariables:{},status:{allowed:!1,hiddenByCascade:e.id}};if(e.type===S.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:c,hiddenByCascade:e.id}};if(l){f=Sn(l,t,r);let O=f.split(mr).filter(P=>P!==""),w=[];for(let P=0;P<O.length;P++){let N=O[P];new RegExp("^(?:[a-z+]+:)?//","i").test(f)||(N=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${N}`.replace(/([^:]\/)\/+/g,"$1")),w.push(Tn(N,o,s,n,e).catch(H=>{throw new An(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${a.report_name} (${a.report_id}) failed.
27
+ `,`Error message: ${d.message}`),"N/A"}})}var Rt=(e,t,r)=>{let{variables:o}=r,n=a=>a.allowed==="never"?!1:!a.allowed||a.allowed==="always"||o[a.allowed],s={...e};return Object.keys(s).forEach(a=>{typeof s[a]=="string"?s[a]=Se(s[a],t,r):Array.isArray(s[a])?s[a]=s[a].filter(n).map(i=>typeof i=="object"?Rt(i,t,r):typeof i=="string"?Se(i,t,r):i):typeof s[a]=="object"&&s[a]!==null&&!(s[a]instanceof Date)&&(s[a]=Rt(s[a],t,r));}),s},tt=Rt;var ir=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];var nn=(e,t,r)=>{if(!r)return !1;if(e===Ee.SINGLE)return r.find(n=>n.id===t);let o=Array.isArray(t)?t:t.split(",");return Array.isArray(o)&&o.every(n=>r.map(s=>s.id).includes(n))},gt=nn;function Et(e,t,r,o,n=!1){let{variables:s}=J(o),a=tt({logic:t},r,o).logic,i=he("variables",s,a,r,void 0,o),{vars:c,log:u,error:l}=i,p=c.type||Ee.SINGLE,d=c.component||"Selector",f=c.hideLabel||"false",b=c.resetSectionVars||"false",T=c.name||"Unlabeled Selector",m=ir(c.options||[]),L=_=>p===Ee.MULTI&&!Array.isArray(_)?[_]:_,v=c.defaultValue,x;if(v&&(v=L(v),gt(p,v,m)&&(x=v)),!x){let _=m&&m[0]&&m[0].id||m[0]||"";x=L(_);}if(n&&typeof window<"u"){let _=`selector${e}id`,K=new URLSearchParams(window.location.search),w=Object.fromEntries(K)[_];w&&!gt(p,w,m)&&w!==void 0&&(K.delete(_),window.history.replaceState(null,null,`?${K.toString()}`));}return {config:{name:T,type:p,options:m,defaultValue:x,component:d,hideLabel:f,resetSectionVars:b},log:u,error:l}}function ht(e,t,r){if(!e)return !1;let o=Array.isArray(r)?r:r.split(",");return Array.isArray(o)&&o.every(n=>e.map(s=>`${s[`${t} ID`]}`).includes(n))}function St(e,t,r,o,n=!1){let{variables:s}=J(o),a=tt({logic:t},r,o).logic,i=he("variables",s,a,r,void 0,o),{vars:c,log:u,error:l}=i;if(n&&typeof window<"u"){let d=`multihierarchySelector${e}-value`,f=`multihierarchySelector${e}-type`,b=new URLSearchParams(window.location.search),T=Object.fromEntries(b),m=T[d],L=T[f];m&&m!==void 0&&L&&L!==void 0&&!ht(c.data,L,m)&&(b.delete(d),b.delete(f),window.history.replaceState(null,null,`?${b.toString()}`));}return {config:c,log:u,error:l}}var sn=(e,t,r)=>{let o=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),s=new URLSearchParams(t).get(o),a=n||s;if(r.type===Ee.MULTI){let u=a?a.split(","):r.defaultValue,l=r.options.filter(p=>u.includes(p.id));return {[`selector${e}id`]:u,[`selector${e}label`]:(l||[]).map(p=>p.label)}}let i=a&&r.options.find(u=>u.id===a)?a:r.defaultValue,c=r.options.find(u=>u.id===i);return {[`selector${e}id`]:i,[`selector${e}label`]:c&&c.label||void 0}},cr=sn;var an=(e,t,r)=>{let o=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,s=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),a=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),i=new URLSearchParams(t).get(o),c=new URLSearchParams(t).get(n),u=s||i,l=a||c,p=u?u.split(","):r.defaultValue||[],d=l||r.defaultValueType||"",f=r.data?.filter(b=>p.includes(`${b[`${d} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:p,[`multihierarchySelector${e}label`]:[...new Set((f||[]).map(b=>b[d]))],[`multihierarchySelector${e}type`]:d}},ur=an;var{localeDefault:lr,locales:cn}=re(),un=Object.values(ft),ln=(e,t=lr)=>e&&un.includes(e.type)?{locale:mt,locales:[mt]}:{locale:t,locales:cn},pr=(e,t=lr)=>{if(!e)return {};let{locale:r}=ln(e,t);return e.contentByLocale?.[r]?.content};function pn(e,t){let r=Object.values(t),o=r.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(r.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(s=>o.includes(s)))).map(n=>[n.id,n]))}var dr=pn;var fr=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((r,o)=>r[o],e):e;var mr="|||";var yr="SECTION_ALLOWED";function bt(e){return e.type===S.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}function fn(){let{publicRuntimeConfig:e}=dn(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((r,o)=>(r[`ENV_${o}`]=t[o]||"N/A",r),{})}}var Ve=fn;function mn(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,r])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:r}),{})}var Rr=mn;var ce=Zo(process.env.NEXT_PUBLIC_REPORTS_DEBUG),En=process.env.REPORTS_ORIGIN||"",hn=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,Sr=5;try{Sr=parseInt(`${hn||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}gr(nt,{retries:Sr,retryDelay:gr.exponentialDelay,onRetry:(e,t,r)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",r.url),console.error(t.message);}});nt.interceptors.request.use(e=>({...e,requestStart:Date.now()}));nt.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));var Sn=(e,t,r)=>{let o=Se(e,t,r);return o.startsWith("http")||(o=`${En}${o.startsWith("/")?"":"/"}${o}`),o},{urlProxy:bn}=Me("/api/cms");function ot(e){return e.ok!==void 0}function rt(e){this.message=e,this.name="ApiFetchException";}var Er=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;async function Tn(e,t,r="en",o,n){let s=Date.now(),a=e,i,c=Ve(),u=Rr(),l={envs:{...c,...u}},p=new URL(e),d=new URLSearchParams(p.searchParams.toString());d.has("bespoke_slugs")&&(p.searchParams.delete("bespoke_slugs"),a=p.toString());let f={datasource:void 0};o.find(v=>{if(!v.content?.pattern)return !1;try{let x=new RegExp(v.content.pattern,"gm");return x.test(a)?(f.datasource=v,!0):x.test(a)}catch{return !1}});let b=n?n.settings:{},T=!!(b&&b.useProxy&&b.useProxy==="true"),m=f.datasource&&typeof f.datasource.content.useProxy=="boolean"?f.datasource.content.useProxy:!1,L=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(a)}`;if(typeof window=="object"&&(T||m)){let v=await bn({url:a,timeout:Er});if(v.ok===!0)i=v.data;else throw new rt(v?.error)}else try{let x={url:a,timeout:Er};if(f.datasource){let K=await Wt({vars:["url","libs"],logic:f.datasource.content.logic},l)(a);if(K.axiosConfig)x=K.axiosConfig;else throw new rt(`AxiosConfig is missing in Data Source ${f.datasource.name} (ID: ${f.datasource.id}).`)}let $=await nt(x);if($.status===200)$.headers["content-type"]==="text/csv"?i=csvParse($.data):i=$.data;else throw new rt("No response for: "+a)}catch(v){throw new rt(v.message)}if(d.has("bespoke_slugs")){let v=d.get("bespoke_slugs");if(v){let x=v.split(",");if(x.length===3){let[$,_,K]=x,O=fr(i,K);if(O&&Array.isArray(O)){let w=Array.from(new Set(O.map(C=>`${C[_]}`).filter(C=>!["","undefined"].includes(C))));if(w.length>0){let C=w.join("").length>2e3,P=await t({mode:C?"whole":"ids",ids:C?void 0:w,all:!1,locale:r,variant:[parseInt($,10)],output:"lite",limit:w.length+1,allowNulls:!0}).then(N=>{let F=[];return ot(N)?N.ok&&(F=N.data.results):F=N.results,F&&Array.isArray(F)?F:[]}).catch(N=>(console.error(`Error hydrating slugs for Variant: ${$}, Key: ${_}, Accessor: ${K}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(N),[]));if(P){let N=Object.fromEntries(P.map(F=>[F.id,`/${F.variant_slug}/${F.slug}`]));O.map(F=>(F.bespoke_slug=N[F[_]]?N[F[_]]:null,F));}}}}}}return {data:i,requestDuration:Date.now()-s,finalUrl:m||T?L:a,apiDataSource:f.datasource?f.datasource:!1}}function An(e){this.name="BlockException",this.message=e;}async function hr(e,t,r,o,n){let{locale:s,variables:a,query:i}=J(r),c=xn(e,r,a,t),u=null,l=e.contentByLocale?.logic?.content?.api,p=null,d=null,f=null,b=null,T=null;if(!c)return {outputVariables:{},renderVariables:{},status:{allowed:!1,hiddenByCascade:e.id}};if(e.type===S.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:c,hiddenByCascade:e.id}};if(l){f=Sn(l,t,r);let O=f.split(mr).filter(P=>P!==""),w=[];for(let P=0;P<O.length;P++){let N=O[P];new RegExp("^(?:[a-z+]+:)?//","i").test(f)||(N=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${N}`.replace(/([^:]\/)\/+/g,"$1")),w.push(Tn(N,o,s,n,e).catch(H=>{throw new An(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${a.report_name} (${a.report_id}) failed.
28
28
  Error fetching ${N}.
29
29
  Message: ${H.message}.
30
- `)}));}let C=await Promise.all(w).catch(P=>P.message);if(typeof C=="string"&&C)return {outputVariables:{},renderVariables:{},status:{error:C}};u=C.length===1?C[0].data:C.map(P=>P.data),d=C.reduce((P,N)=>P+JSON.stringify(N.data).length/1024,0),p=Math.max(...C.map(P=>P.requestDuration)),b=C.map(P=>P.apiDataSource?`${P.apiDataSource.name} (${P.apiDataSource.id})`:!1),A=C.map(P=>P.finalUrl);}if(e.type===S.SELECTOR){let{config:O,log:w,error:C}=Et(e.id,e.contentByLocale[s].content.logic,t,r,!0);return {outputVariables:cr(e.id,i,O),renderVariables:O,status:{log:w,error:C,allowed:c}}}if(e.type===S.MULTIHIERARCHY_SELECTOR){let{config:O,log:w,error:C}=St(e.id,e.contentByLocale[s].content.logic,t,r,!0);return {outputVariables:ur(e.id,i,O),renderVariables:O,status:{log:w,error:C,allowed:c}}}if(e.type===S.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:c}};if(e.type===S.RELATED){let O=e.contentByLocale?.logic?.content?.simple?.compare||"variant",w=e.contentByLocale?.logic?.content?.simple?.limit||4,C=Object.keys(a).filter(R=>R.startsWith("report_id")).map(R=>a[R]),P=Object.keys(a).filter(R=>R.startsWith("dimension_id")).map(R=>a[R]),N=Object.keys(a).filter(R=>R.startsWith("variant_id")).map(R=>a[R]),F=Object.keys(a).filter(R=>R.startsWith("id")).map(R=>a[R]);if(!F.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:!1}};let H=await Promise.all(F.map((R,h)=>o({mode:"ids",locale:s,ids:[R],output:"lite",variant:[N[h]]}))).then(R=>R.flatMap(h=>{let v=[];return ot(h)?h.ok&&(v=h.data.results):v=h.results,v&&Array.isArray(v)?v:[]})).catch(R=>(console.error("Error getting related members",R),[]));if(P.length>1){let R=Object.keys(a).filter(I=>I.startsWith("variant_slug")).map(I=>a[I]),h=H.map((I,z)=>{let D={mode:"related",locale:s,related:w??4,current_ids:[I.content_id],output:"full",variant_ids:[I.variant_id]};return z===0&&(D.include_ids=[I.content_id]),D}),v=await Promise.all(h.map(I=>o(I))).then(I=>I.flatMap(z=>{let D=[];return ot(z)?z.ok&&(D=z.data.results):D=z.results,D&&Array.isArray(D)?D:[]})).catch(I=>(console.error("Error getting related members",I),[])),pe=v.reduce((I,z)=>{let D=z.variant_slug;return I[D]||(I[D]=[]),I[D].push(z),I},{}),He=[],G=Object.keys(pe),se=[{combination:[],index:0}];for(;se.length>0;){let I=se.pop();if(!I)continue;let{combination:z,index:D}=I;if(D===G.length){He.push(z);continue}let de=G[D],W=pe[de];for(let Q of W)se.push({combination:[...z,Q],index:D+1});}return {outputVariables:{related_reports:He.map(I=>{let z=I.sort((D,de)=>R.indexOf(D.variant_slug)-R.indexOf(de.variant_slug));return {entities:z,link:"/"+z.map(D=>`${D.variant_slug}/${D.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:v.length>0}}}let k=H.map(R=>R.content_id),M={mode:"related",locale:s,related:w??4,current_ids:k,output:"full"};O&&(O==="report"?M.report_ids=C:O==="dimension"?M.dimension_ids=P:M.variant_ids=N);let Y=await o(M).then(R=>{let h=[];return ot(R)?R.ok&&(h=R.data.results):h=R.results,h&&Array.isArray(h)?h:[]}).catch(R=>(console.error("Error getting related members",R),[]));return {outputVariables:{related_reports:Y.map(R=>({entities:[R],link:`/${R.variant_slug}/${R.slug}`}))},renderVariables:{},status:{log:[],allowed:Y.length>0}}}let{logic:m}=pr(e,s),L=Se(m,t,r),T=he("resp",u||{},L,t,a,r),{vars:x,error:$,log:_}=T;if(typeof x!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:_,duration:p,responseSize:d,resp:u,api:f,allowed:c,apiFinalUrls:A,apiDataSources:b}};let K=Object.keys(x).reduce((O,w)=>({...O,[`${e.type}${e.id}${w}`]:x[w]}),{});return {renderVariables:x,outputVariables:[S.GENERATOR,S.SECTION_FLAG].includes(e.type)?x:K,status:{log:_,error:$,duration:p,responseSize:d,resp:u,api:f,allowed:c,apiFinalUrls:A,apiDataSources:b}}}function vn(e,t,r,o,n,s,a){return e.consumers.forEach(i=>{if(t[i]){let c=`${r}-${i}`;!o.includes(c)&&(t[i].section_id===t[r].section_id||!n)&&o.push(c),e.consumers.filter(u=>t[u]&&t[u].section_id===t[r].section_id||!n).forEach(u=>Tt(u,t,o,!1,s,n,a));}})}var Tt=(e,t,r=[],o=!0,n=!0,s=!0,a=[])=>{if(a.includes(e))return [];a.push(e);let i=t[e];return i&&i.inputs.length&&o&&i.inputs.forEach(c=>{let u=`${c}-${e}`;r.includes(u)||r.push(u),i.inputs.forEach(l=>Tt(l,t,r,o,!1,s,a));}),i&&i.consumers.length&&n&&vn(i,t,e,r,s,n,a),r},xn=(e,t,r,o)=>{let n=!0;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=!1;else {let s=J(t),{error:a,output:i}=he("variables",r,e.settings.allowedLogic||"return false;",o,void 0,s);a||(n=!!i);}return n},br=async(e,t,r,o,n,s={},a,i="section",c)=>{let u=i==="section",l=J(n),p=l.variables,d={...s.variables??{}},f={...s.status??{}},b=new Set,A=[],m={};r?m={...m,[r]:e[r]}:t?m=(t??[]).reduce((k,{id:M})=>({...k,...dr(M,e)}),{}):m=Object.values(e).filter(k=>bt(k)).reduce((k,M)=>({...k,[M.id]:M}),{});let L=Object.values(m).filter(k=>bt(k));if(L.length>0){ce&&console.info("%crunConsumers: calculating section flags","color:purple",L.map(y=>y.id).join(", "));let k=Object.fromEntries(await Promise.all(L.map(async y=>[y.id,await hr(y,o,{...l,variables:p,locale:p.locale},a,c).then(R=>{let{outputVariables:h,status:v}=R;if(v.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${y.id}, Section ${y.section_id}) failed with message: ${v.error}. `);f[y.id]={allowed:!1,error:v.error},d[y.id]={};}return (y.consumers.length>0||[S.GENERATOR,S.SECTION_FLAG,S.RELATED].includes(y.type))&&v.allowed&&Object.keys(h).length>0?d[y.id]=h:d[y.id]={},i==="report"?(f[y.id]={allowed:v.allowed},[S.GENERATOR,S.SECTION_FLAG].includes(y.type)&&v.api&&(f[y.id].api=v.api)):f[y.id]=v,R})]))),Y=Object.entries(k).filter(([,y])=>!y.outputVariables[yr]).map(([y])=>Number(y));b=new Set(Y.map(y=>e[y].section_id)),Object.values(m).filter(y=>b.has(y.section_id)).forEach(y=>{A.push(y.id),delete m[y.id];}),ce&&console.info("%crunConsumers: removing sections","color:purple",b.keys());}let T=b.size>0?Object.fromEntries(Object.entries(e).filter(([,k])=>b?.has(k.section_id)?(A.includes(k.id)||A.push(k.id),!1):!0)):e;if(A.length>0&&(T=Object.fromEntries(Object.entries(T).map(([k,M])=>{let Y={...M,inputs:M.inputs.filter(y=>!A.includes(y)),consumers:M.consumers.filter(y=>!A.includes(y))};return [k,Y]}))),!r&&!t)return {variables:{...s.variables??{},...d},status:{...s.status??{},...f}};i==="report"&&A.length>0&&A.forEach(k=>{delete d[k],delete f[k],delete e[k];}),ce&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(m));let x=Object.keys(m).reduce((k,M)=>{let Y=new Date,y=Tt(Number(M),T,[],!r,!0,u).map(v=>v.split("-")),h=(new Date().getTime()-Y.getTime())/1e3;return ce&&console.info(`%cResolved dependencies for ${M} (${h.toFixed(2)}s)`,"color:blue"),[...k,...y]},[]),$=new Date,_=Object.keys(m).reduce((k,M)=>k.includes(M)?[...k]:[M,...k],yn(x)),O=(new Date().getTime()-$.getTime())/1e3;ce&&console.info(`%cResolved DAG (${O.toFixed(2)}s): `,"color:green",_);let w=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,C=parseInt(`${w||0}`,10);async function P(k,M){let Y=new Map,y=[],R=async()=>y.length;for(let h of k){if(C!==0){let G=await R();for(;G>=C;)ce&&console.info("Too many pending promises, waiting...",G,y),await new Promise(se=>setTimeout(se,500)),G=await R();}let v=M[h],He=Promise.all(v.inputs.filter(G=>k.includes(String(G))).map(G=>Y.get(Number(G)))).then(async()=>{let G=v.inputs.reduce((W,Q)=>({...W,...d[Q]}),p),se=v.inputs.find(W=>(v.settings?.ignoreCascade?v.settings?.ignoreCascade:[]).includes(W)||!f[W]?!1:!f[W].allowed||f[W].hiddenByCascade);if(se){f[h]={allowed:!1,hiddenByCascade:f[se].hiddenByCascade||se},d[h]={},y.splice(y.indexOf(Number(h)),1);return}let $t=new Date,I;typeof window<"u"&&[S.SELECTOR,S.MULTIHIERARCHY_SELECTOR].includes(v.type)&&v.settings[ar.DISABLED]?I=new Promise(W=>{W({outputVariables:d[h],status:f[h]});}):I=hr(v,o,{...l,variables:G,locale:G.locale},a,c);let z=await I.then(({outputVariables:W,status:Q})=>{if(Q.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${h}, Section ${v.section_id}) failed with message: ${Q.error}.`);f[h]={allowed:!1,error:Q.error},d[h]={};}(v.consumers.length>0||[S.GENERATOR,S.SECTION_FLAG,S.RELATED].includes(v.type))&&Q.allowed&&Object.keys(W).length>0?d[h]=W:d[h]={},i==="report"?(f[h]={allowed:Q.allowed},[S.GENERATOR,S.SECTION_FLAG].includes(v.type)&&Q.api&&(f[h].api=Q.api)):f[h]=Q;}),de=(new Date().getTime()-$t.getTime())/1e3;return ce&&console.info(`%cBlock ${v.id} resolved in ${de.toFixed(3)}s`,de>500?"color:red":"color:green"),f[h].duration=f[h].duration?f[h].duration:de,y.splice(y.indexOf(Number(h)),1),z}).catch(G=>{throw y.splice(y.indexOf(Number(h)),1),G});y.push(Number(h)),Y.set(Number(h),He);}await Promise.all(Array.from(Y.values()));}let N=new Date;await P(_,T);let H=(new Date().getTime()-N.getTime())/1e3;return ce&&console.info(`%cResolved Variables (${H.toFixed(2)}s), ${_.length} blocks`,"color:green"),{variables:{...s.variables??{},...d},status:{...s.status??{},...f}}};function Cn(e=[]){return e.reduce((t,r,o)=>{if(r){let n=o+1;t[`id${n}`]=r.id,t[`name${n}`]=r.name,t[`slug${n}`]=r.slug,"attributes"in r&&Object.keys(r.attributes).forEach(s=>{t[`attr_${s}${n}`]=r.attributes[s];}),t[`variant_id${n}`]=r.variant_id,t[`variant_name${n}`]=r.variant_name,t[`variant_slug${n}`]=r.variant_slug,t[`dimension_id${n}`]=r.dimension_id,t[`dimension_name${n}`]=r.dimension_name,t.report_id=r.report_id,t.report_name=r.report_name;}return t},{})}var Tr=Cn;function be(e,t,r){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${Ar(r)}`;return e[n]}let o=`${t}${Ar(r)}`;return e[o]}function Ar(e){return e[0].toUpperCase()+e.slice(1)}function j(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];if(process.env.NODE_ENV!=="production"){var n=wn[e],s=n?typeof n=="function"?n.apply(null,r):n:"unknown error nr: "+e;throw Error("[Immer] "+s)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map(function(a){return "'"+a+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Ie(e){return !!e&&!!e[X]}function Ae(e){var t;return !!e&&(function(r){if(!r||typeof r!="object")return !1;var o=Object.getPrototypeOf(r);if(o===null)return !0;var n=Object.hasOwnProperty.call(o,"constructor")&&o.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===Nn}(e)||Array.isArray(e)||!!e[Or]||!!(!((t=e.constructor)===null||t===void 0)&&t[Or])||It(e)||Bt(e))}function $e(e,t,r){r===void 0&&(r=!1),we(e)===0?(r?Object.keys:Ut)(e).forEach(function(o){r&&typeof o=="symbol"||t(o,e[o],e);}):e.forEach(function(o,n){return t(n,o,e)});}function we(e){var t=e[X];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:It(e)?2:Bt(e)?3:0}function kt(e,t){return we(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function kn(e,t){return we(e)===2?e.get(t):e[t]}function Ir(e,t,r){var o=we(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r;}function Pn(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function It(e){return In&&e instanceof Map}function Bt(e){return Bn&&e instanceof Set}function Te(e){return e.o||e.t}function wt(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Mn(e);delete t[X];for(var r=Ut(t),o=0;o<r.length;o++){var n=r[o],s=t[n];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(t[n]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function Nt(e,t){return t===void 0&&(t=!1),Mt(e)||Ie(e)||!Ae(e)||(we(e)>1&&(e.set=e.add=e.clear=e.delete=Ln),Object.freeze(e),t&&$e(e,function(r,o){return Nt(o,!0)},!0)),e}function Ln(){j(2);}function Mt(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function oe(e){var t=Dn[e];return t||j(18,e),t}function vr(){return process.env.NODE_ENV==="production"||Be||j(0),Be}function At(e,t){t&&(oe("Patches"),e.u=[],e.s=[],e.v=t);}function st(e){Pt(e),e.p.forEach(_n),e.p=null;}function Pt(e){e===Be&&(Be=e.l);}function xr(e){return Be={p:[],l:Be,h:e,m:!0,_:0}}function _n(e){var t=e[X];t.i===0||t.i===1?t.j():t.g=!0;}function vt(e,t){t._=t.p.length;var r=t.p[0],o=e!==void 0&&e!==r;return t.h.O||oe("ES5").S(t,e,o),o?(r[X].P&&(st(t),j(4)),Ae(e)&&(e=at(t,e),t.l||it(t,e)),t.u&&oe("Patches").M(r[X].t,e,t.u,t.s)):e=at(t,r,[]),st(t),t.u&&t.v(t.u,t.s),e!==Br?e:void 0}function at(e,t,r){if(Mt(t))return t;var o=t[X];if(!o)return $e(t,function(i,c){return Cr(e,o,t,i,c,r)},!0),t;if(o.A!==e)return t;if(!o.P)return it(e,o.t,!0),o.t;if(!o.I){o.I=!0,o.A._--;var n=o.i===4||o.i===5?o.o=wt(o.k):o.o,s=n,a=!1;o.i===3&&(s=new Set(n),n.clear(),a=!0),$e(s,function(i,c){return Cr(e,o,n,i,c,r,a)}),it(e,n,!1),r&&e.u&&oe("Patches").N(o,r,e.u,e.s);}return o.o}function Cr(e,t,r,o,n,s,a){if(process.env.NODE_ENV!=="production"&&n===r&&j(5),Ie(n)){var i=at(e,n,s&&t&&t.i!==3&&!kt(t.R,o)?s.concat(o):void 0);if(Ir(r,o,i),!Ie(i))return;e.m=!1;}else a&&r.add(n);if(Ae(n)&&!Mt(n)){if(!e.h.D&&e._<1)return;at(e,n),t&&t.A.l||it(e,n);}}function it(e,t,r){r===void 0&&(r=!1),!e.l&&e.h.D&&e.m&&Nt(t,r);}function xt(e,t){var r=e[X];return (r?Te(r):e)[t]}function kr(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Object.getPrototypeOf(r);}}function Lt(e){e.P||(e.P=!0,e.l&&Lt(e.l));}function Ct(e){e.o||(e.o=wt(e.t));}function _t(e,t,r){var o=It(t)?oe("MapSet").F(t,r):Bt(t)?oe("MapSet").T(t,r):e.O?function(n,s){var a=Array.isArray(n),i={i:a?1:0,A:s?s.A:vr(),P:!1,I:!1,R:{},l:s,t:n,k:null,o:null,j:null,C:!1},c=i,u=Ot;a&&(c=[i],u=qe);var l=Proxy.revocable(c,u),p=l.revoke,d=l.proxy;return i.k=d,i.j=p,d}(t,r):oe("ES5").J(t,r);return (r?r.A:vr()).p.push(o),o}function On(e){return Ie(e)||j(22,e),function t(r){if(!Ae(r))return r;var o,n=r[X],s=we(r);if(n){if(!n.P&&(n.i<4||!oe("ES5").K(n)))return n.t;n.I=!0,o=Pr(r,s),n.I=!1;}else o=Pr(r,s);return $e(o,function(a,i){n&&kn(n.t,a)===i||Ir(o,a,t(i));}),s===3?new Set(o):o}(e)}function Pr(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return wt(e)}var Lr,Be,Dt=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",In=typeof Map<"u",Bn=typeof Set<"u",_r=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",Br=Dt?Symbol.for("immer-nothing"):((Lr={})["immer-nothing"]=!0,Lr),Or=Dt?Symbol.for("immer-draftable"):"__$immer_draftable",X=Dt?Symbol.for("immer-state"):"__$immer_state";var wn={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return "Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return "Unsupported patch operation: "+e},18:function(e){return "The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return "'current' expects a draft, got: "+e},23:function(e){return "'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Nn=""+Object.prototype.constructor,Ut=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Mn=Object.getOwnPropertyDescriptors||function(e){var t={};return Ut(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r);}),t},Dn={},Ot={get:function(e,t){if(t===X)return e;var r=Te(e);if(!kt(r,t))return function(n,s,a){var i,c=kr(s,a);return c?"value"in c?c.value:(i=c.get)===null||i===void 0?void 0:i.call(n.k):void 0}(e,r,t);var o=r[t];return e.I||!Ae(o)?o:o===xt(e.t,t)?(Ct(e),e.o[t]=_t(e.A.h,o,e)):o},has:function(e,t){return t in Te(e)},ownKeys:function(e){return Reflect.ownKeys(Te(e))},set:function(e,t,r){var o=kr(Te(e),t);if(o?.set)return o.set.call(e.k,r),!0;if(!e.P){var n=xt(Te(e),t),s=n?.[X];if(s&&s.t===r)return e.o[t]=r,e.R[t]=!1,!0;if(Pn(r,n)&&(r!==void 0||kt(e.t,t)))return !0;Ct(e),Lt(e);}return e.o[t]===r&&(r!==void 0||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=!0),!0},deleteProperty:function(e,t){return xt(e.t,t)!==void 0||t in e.t?(e.R[t]=!1,Ct(e),Lt(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=Te(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty:function(){j(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){j(12);}},qe={};$e(Ot,function(e,t){qe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};}),qe.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&j(13),qe.set.call(this,e,t,void 0)},qe.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&j(14),Ot.set.call(this,e[0],t,r,e[0])};var Un=function(){function e(r){var o=this;this.O=_r,this.D=!0,this.produce=function(n,s,a){if(typeof n=="function"&&typeof s!="function"){var i=s;s=n;var c=o;return function(A){var m=this;A===void 0&&(A=i);for(var L=arguments.length,T=Array(L>1?L-1:0),x=1;x<L;x++)T[x-1]=arguments[x];return c.produce(A,function($){var _;return (_=s).call.apply(_,[m,$].concat(T))})}}var u;if(typeof s!="function"&&j(6),a!==void 0&&typeof a!="function"&&j(7),Ae(n)){var l=xr(o),p=_t(o,n,void 0),d=!0;try{u=s(p),d=!1;}finally{d?st(l):Pt(l);}return typeof Promise<"u"&&u instanceof Promise?u.then(function(A){return At(l,a),vt(A,l)},function(A){throw st(l),A}):(At(l,a),vt(u,l))}if(!n||typeof n!="object"){if((u=s(n))===void 0&&(u=n),u===Br&&(u=void 0),o.D&&Nt(u,!0),a){var f=[],b=[];oe("Patches").M(n,u,f,b),a(f,b);}return u}j(21,n);},this.produceWithPatches=function(n,s){if(typeof n=="function")return function(u){for(var l=arguments.length,p=Array(l>1?l-1:0),d=1;d<l;d++)p[d-1]=arguments[d];return o.produceWithPatches(u,function(f){return n.apply(void 0,[f].concat(p))})};var a,i,c=o.produce(n,s,function(u,l){a=u,i=l;});return typeof Promise<"u"&&c instanceof Promise?c.then(function(u){return [u,a,i]}):[c,a,i]},typeof r?.useProxies=="boolean"&&this.setUseProxies(r.useProxies),typeof r?.autoFreeze=="boolean"&&this.setAutoFreeze(r.autoFreeze);}var t=e.prototype;return t.createDraft=function(r){Ae(r)||j(8),Ie(r)&&(r=On(r));var o=xr(this),n=_t(this,r,void 0);return n[X].C=!0,Pt(o),n},t.finishDraft=function(r,o){var n=r&&r[X];process.env.NODE_ENV!=="production"&&(n&&n.C||j(9),n.I&&j(10));var s=n.A;return At(s,o),vt(void 0,s)},t.setAutoFreeze=function(r){this.D=r;},t.setUseProxies=function(r){r&&!_r&&j(20),this.O=r;},t.applyPatches=function(r,o){var n;for(n=o.length-1;n>=0;n--){var s=o[n];if(s.path.length===0&&s.op==="replace"){r=s.value;break}}n>-1&&(o=o.slice(n+1));var a=oe("Patches").$;return Ie(r)?a(r,o):this.produce(r,function(i){return a(i,o)})},e}(),Z=new Un,Fn=Z.produce;Z.produceWithPatches.bind(Z);Z.setAutoFreeze.bind(Z);Z.setUseProxies.bind(Z);Z.applyPatches.bind(Z);Z.createDraft.bind(Z);Z.finishDraft.bind(Z);var ct=Fn;var te=ae.actions,Dr=je({block:ue("block"),dimension:ue("dimension"),formatter:ue("formatter"),report:ue("report"),section:ue("section"),variant:ue("variant"),datasource:ue("datasource")}),ze=je({block:le("block"),dimension:le("dimension"),formatter:le("formatter"),report:le("report"),section:le("section"),variant:le("variant"),datasource:le("datasource")}),Ur=je({block:ne("block"),dimension:ne("dimension"),formatter:ne("formatter"),report:ne("report"),section:ne("section"),variant:ne("variant"),datasource:ne("datasource")}),Fr=je({block:ve("block"),dimension:ve("dimension"),formatter:ve("formatter"),report:ve("report"),section:ve("section"),variant:ve("variant"),datasource:ve("datasource")}),Vr=je({block:Nr("block"),section:Nr("section")});function je(e){return (t,r)=>{let o=e[t];if(!o)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return o(r)}}function Ce(e,t){return (r,o)=>{let s=o().records.requests[e][t],a=!s||s.status==="UNINITIALIZED"?"LOADING":"FETCHING";r(te.setRequest({key:t,type:e,status:a}));}}function xe(e,t,r,o){return n=>{typeof window=="object"&&notifications.show({autoClose:3e3,color:"red",id:t,message:o,title:"Error"}),n(te.setRequest({key:t,type:e,status:"FAILURE",error:{code:r,message:o}}));}}function ue(e){return t=>{let r=Vt(e,t);return (o,n,s)=>(o(Ce(e,r)),be(s,"create",e)(t).then(i=>(i.ok===!0?o(te.setCreateRequest({key:r,operation:"create",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function $n(e){return t=>{let r=Vt(e,t[0]);return (o,n,s)=>(o(Ce(e,r)),be(s,"createBulk",e)(t).then(i=>(i.ok===!0?o(te.setCreateRequest({key:r,operation:"createBulk",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function wr(e,t,r){return r.replace(new RegExp(e,"g"),t)}function zn(e){return e.section_id!==void 0}function jn(e){return e.report_id!==void 0}function Nr(e){return t=>{let{create:r}=t;return (o,n,s)=>ue(e)(r)(o,n,s).then(async i=>{if(i.ok){let{data:c}=i,{id:u}=c,{update:l}=t,p=zr(e,{id:u});if(o(Ce(e,`${p}`)),e==="block"&&zn(r)){let d=ct(l,m=>{m.id=u;}),{contentByLocale:f}=d;f&&(d=ct(d,m=>{m.id=u,m.contentByLocale=Object.keys(f).reduce((L,T)=>{let x=f?f[T]:{};return L[T]={...x,id:u},L},{});}));let A=d.inputs?.map(m=>({type:m.type,id:m.id,inputAction:{operation:"create",input:{input_id:m.id,block_id:d.id}}}));return A&&A.length>0&&Mr(e)([d,...A])(o,n,s).then(()=>le("section")({id:d.section_id,include:!0})(o,n,s).then(m=>(m.ok&&o(te.setRequest({key:p,type:e,status:"SUCCESS",data:m.data})),m))),ne(e)(d)(o,n,s).then(m=>(m.ok&&o(te.setRequest({key:p,type:e,status:"SUCCESS",data:m.data})),m))}if(e==="section"&&jn(r)){let{id:d}=c,f=ct(l,m=>{m.id=d;}),{blocks:b}=f,A=b?.map(m=>({type:m.type,blockcol:m.blockcol,blockrow:m.blockrow,section_id:d,locales:Object.keys(m.contentByLocale).map(L=>L)}));return A&&b&&await $n("block")(A)(o,n,s).then(m=>{if(m.ok){let L=m.data,T=[],x=L.map(($,_)=>{let O={...$},w=O.id,C=b[_];C.contentByLocale&&(O.contentByLocale=Object.keys(C.contentByLocale).reduce((y,R)=>{let h=C.contentByLocale[R];return y[R]={...h,content:{...h.content},id:O.id},y},{}));let{settings:P}=C,{contentByLocale:N,id:F}=O;O.settings=P;let H={id:F,contentByLocale:N,settings:P};return C.inputs.map(y=>y.id).reduce((y,R)=>{let h=b.findIndex(v=>v.id===R);return [...y,h]},[]).map(y=>({...L[y],originalBlock:b[y]})).forEach(y=>{let{id:R,type:h,originalBlock:v}=y;if([S.SELECTOR,S.VIZ].includes(h)){if(H.contentByLocale?.logic?.content?.api){let pe=H.contentByLocale?.logic.content.api;H.contentByLocale.logic.content.api=wr(`(selector${v.id}id)`,`selector${R}id`,pe);}if(H.contentByLocale?.logic?.content?.logic){let pe=H.contentByLocale.logic.content.logic;H.contentByLocale.logic.content.logic=wr(`(selector${v.id}id)`,`selector${R}id`,pe);}}T.push({id:R,inputAction:{operation:"create",input:{input_id:R,block_id:w}}});}),H});return Mr("block")([...x,...T])(o,n,s)}}),ne(e)(f)(o,n,s).then(m=>(m.ok&&o(te.setRequest({key:p,type:e,status:"SUCCESS",data:m.data})),m))}return ne(e)({...l,id:c.id})(o,n,s)}})}}function le(e){return t=>{let r=qr(e,t);return (o,n,s)=>{o(Ce(e,r));let a=be(s,"read",e);if(typeof a!="function"){let i=`Failed to get valid RPC method for entity "${e}"`;return o(xe(e,r,500,i)),Promise.reject(new Error(i))}return a(t).then(i=>(i.ok===!0?o(te.setReadRequest({key:r,operation:"read",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i))}}}function ne(e){return t=>{let r=qt(e,t);return (o,n,s)=>(o(Ce(e,r)),be(s,"update",e)(t).then(i=>(i.ok===!0?o(te.setUpdateRequest({key:r,operation:"update",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function Mr(e){return t=>{let r=qt(e,t[0]);return (o,n,s)=>(o(Ce(e,r)),be(s,"updateBulk",e)(t).then(i=>(i.ok===!0?o(te.setUpdateRequest({key:r,operation:"updateBulk",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function ve(e){return t=>{let r=$r(e,t);return (o,n,s)=>(o(Ce(e,r)),be(s,"delete",e)(t).then(i=>{i.ok===!0?o(te.setDeleteRequest({key:r,operation:"delete",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error));}))}}function Vt(e,t){if(e==="variant"){let r=t;return `create(variant, [${r.dimension_id}, ${r.name}])`}return `create(${e}, [${Object.keys(t)}])`}function qr(e,t={}){let r=t.id==null?null:`'${t.id}'`;return `read(${e}, ${r}, ${!!t.include})`}function qt(e,t){let{id:r,...o}=t;return `update(${e}, ${r}, [${Object.keys(o)}])`}function $r(e,t){return `delete(${e}, ${t})`}function zr(e,t){let r=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${r})`}var{setStatus:jr,setPreviews:Gn,setSectionState:Gr,resetSectionState:Hr,setCurrentLocale:Hn,setPreferredLocale:Kn,addRunConsumersRunning:Kr,removeRunConsumersRunning:Yr}=Oe;function Yn(e,t){return async(r,o,n)=>{let s=await n.validateVariantSlug({dimension:e,slug:t});if("error"in s)throw new Error(s.error);return s.data}}function Wn(e){return async(t,r,o)=>{let n=await o.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function Qn(){return async(e,t,r)=>{let o=await r.regenerateSearch(void 0);if("error"in o)throw new Error(o.error);return o.data}}function Wr(e){return async(t,r,o)=>{let n=await o.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function Xn(e){return async(t,r,o)=>{let n=await o.searchMember(e);if(n.ok===!0)return n.data;throw new Error(n.error)}}async function Qr(e,t,r,o){let n=r().status,s={...n,...o},a={...n.query,...o.query};Object.keys(a).forEach(c=>a[c]===void 0&&delete a[c]);let i={...s,query:a};t(jr(i)),n.activeSection&&t(Xr(e,{query:a}));}function Zn(e,t){return async(r,o)=>Qr(e,r,o,{query:{[t]:void 0}})}function Jn(e,t,r){return async(o,n)=>Qr(e,o,n,{query:{[t]:r}})}function Xr(e,t){return async(r,o)=>{let n=o(),{currentLocale:s}=n.status,a=n.records.entities.block,i=e.formatterFunctions[s],c=e.datasourceFunctions,{parsedParams:u,statusPayload:l}=Jt(n.status,t),{sid:p,bid:d,previews:f,query:b}=u;Object.keys(l).length&&r(Oe.setStatus(l));let A={...Tr(f),locale:s,...Ve()},m={variables:A,query:b,locale:s};r(Oe.addRunConsumersRunning([p]));let L=n.records.entities.section[p],T=async x=>r(Wr(x));try{let x=await br(a,L&&[L],d,i,m,void 0,T,"section",c),{variables:$,status:_}=x;r(er.setVariableChange({attributes:A,variables:$,status:_})),r(Oe.removeRunConsumersRunning([p]));}catch(x){console.error("Error in runConsumers client side: recalculateVariables",x);}}}function es(e){return async(t,r,o)=>{let n=await o.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function ts(e){return async(t,r,o)=>{let n=await o.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function rs(){return async(e,t,r)=>{let o=await r.searchRole("");if("error"in o)throw new Error(o.error);return o.data}}function os(e){return async(t,r,o)=>{let n=await o.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function ns(e){return async(t,r,o)=>{let n=await o.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function ss({user:e}){return async(t,r,o)=>{let n=await o.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function as(e){return async(t,r,o)=>{let n=await o.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function is(e){let{removeBlocks:t}=ae.actions;return async r=>{await r(t(e));}}function cs(e){let{addBlocks:t}=ae.actions;return async r=>{await r(t(e));}}function us(e){return async(t,r,o)=>{let n=await o.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function ls(e){return async(t,r,o)=>{let n=await o.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function ps(e){return async(t,r,o)=>{let n=await o.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function ds(){return async(e,t,r)=>{let o=await r.readEnvSecrets({});if("error"in o)throw new Error(o.error);return o.data}}function fs(){let{removeDataSourceLogic:e}=ae.actions;return async t=>{await t(e());}}var {locales:ys}=re(),Rs={pathSegment:"path",formatterFunctions:ys.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",siteProps:{}};createContext(Rs);re();var lt=useDispatch,Ge=useSelector;
30
+ `)}));}let C=await Promise.all(w).catch(P=>P.message);if(typeof C=="string"&&C)return {outputVariables:{},renderVariables:{},status:{error:C}};u=C.length===1?C[0].data:C.map(P=>P.data),d=C.reduce((P,N)=>P+JSON.stringify(N.data).length/1024,0),p=Math.max(...C.map(P=>P.requestDuration)),b=C.map(P=>P.apiDataSource?`${P.apiDataSource.name} (${P.apiDataSource.id})`:!1),T=C.map(P=>P.finalUrl);}if(e.type===S.SELECTOR){let{config:O,log:w,error:C}=Et(e.id,e.contentByLocale[s].content.logic,t,r,!0);return {outputVariables:cr(e.id,i,O),renderVariables:O,status:{log:w,error:C,allowed:c}}}if(e.type===S.MULTIHIERARCHY_SELECTOR){let{config:O,log:w,error:C}=St(e.id,e.contentByLocale[s].content.logic,t,r,!0);return {outputVariables:ur(e.id,i,O),renderVariables:O,status:{log:w,error:C,allowed:c}}}if(e.type===S.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:c}};if(e.type===S.RELATED){let O=e.contentByLocale?.logic?.content?.simple?.compare||"variant",w=e.contentByLocale?.logic?.content?.simple?.limit||4,C=Object.keys(a).filter(R=>R.startsWith("report_id")).map(R=>a[R]),P=Object.keys(a).filter(R=>R.startsWith("dimension_id")).map(R=>a[R]),N=Object.keys(a).filter(R=>R.startsWith("variant_id")).map(R=>a[R]),F=Object.keys(a).filter(R=>R.startsWith("id")).map(R=>a[R]);if(!F.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:!1}};let H=await Promise.all(F.map((R,h)=>o({mode:"ids",locale:s,ids:[R],output:"lite",variant:[N[h]]}))).then(R=>R.flatMap(h=>{let A=[];return ot(h)?h.ok&&(A=h.data.results):A=h.results,A&&Array.isArray(A)?A:[]})).catch(R=>(console.error("Error getting related members",R),[]));if(P.length>1){let R=Object.keys(a).filter(I=>I.startsWith("variant_slug")).map(I=>a[I]),h=H.map((I,z)=>{let D={mode:"related",locale:s,related:w??4,current_ids:[I.content_id],output:"full",variant_ids:[I.variant_id]};return z===0&&(D.include_ids=[I.content_id]),D}),A=await Promise.all(h.map(I=>o(I))).then(I=>I.flatMap(z=>{let D=[];return ot(z)?z.ok&&(D=z.data.results):D=z.results,D&&Array.isArray(D)?D:[]})).catch(I=>(console.error("Error getting related members",I),[])),pe=A.reduce((I,z)=>{let D=z.variant_slug;return I[D]||(I[D]=[]),I[D].push(z),I},{}),He=[],G=Object.keys(pe),se=[{combination:[],index:0}];for(;se.length>0;){let I=se.pop();if(!I)continue;let{combination:z,index:D}=I;if(D===G.length){He.push(z);continue}let de=G[D],W=pe[de];for(let Q of W)se.push({combination:[...z,Q],index:D+1});}return {outputVariables:{related_reports:He.map(I=>{let z=I.sort((D,de)=>R.indexOf(D.variant_slug)-R.indexOf(de.variant_slug));return {entities:z,link:"/"+z.map(D=>`${D.variant_slug}/${D.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:A.length>0}}}let k=H.map(R=>R.content_id),M={mode:"related",locale:s,related:w??4,current_ids:k,output:"full"};O&&(O==="report"?M.report_ids=C:O==="dimension"?M.dimension_ids=P:M.variant_ids=N);let Y=await o(M).then(R=>{let h=[];return ot(R)?R.ok&&(h=R.data.results):h=R.results,h&&Array.isArray(h)?h:[]}).catch(R=>(console.error("Error getting related members",R),[]));return {outputVariables:{related_reports:Y.map(R=>({entities:[R],link:`/${R.variant_slug}/${R.slug}`}))},renderVariables:{},status:{log:[],allowed:Y.length>0}}}let{logic:m}=pr(e,s),L=Se(m,t,r),v=he("resp",u||{},L,t,a,r),{vars:x,error:$,log:_}=v;if(typeof x!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:_,duration:p,responseSize:d,resp:u,api:f,allowed:c,apiFinalUrls:T,apiDataSources:b}};let K=Object.keys(x).reduce((O,w)=>({...O,[`${e.type}${e.id}${w}`]:x[w]}),{});return {renderVariables:x,outputVariables:[S.GENERATOR,S.SECTION_FLAG].includes(e.type)?x:K,status:{log:_,error:$,duration:p,responseSize:d,resp:u,api:f,allowed:c,apiFinalUrls:T,apiDataSources:b}}}function vn(e,t,r,o,n,s,a){return e.consumers.forEach(i=>{if(t[i]){let c=`${r}-${i}`;!o.includes(c)&&(t[i].section_id===t[r].section_id||!n)&&o.push(c),e.consumers.filter(u=>t[u]&&t[u].section_id===t[r].section_id||!n).forEach(u=>Tt(u,t,o,!1,s,n,a));}})}var Tt=(e,t,r=[],o=!0,n=!0,s=!0,a=[])=>{if(a.includes(e))return [];a.push(e);let i=t[e];return i&&i.inputs.length&&o&&i.inputs.forEach(c=>{let u=`${c}-${e}`;r.includes(u)||r.push(u),i.inputs.forEach(l=>Tt(l,t,r,o,!1,s,a));}),i&&i.consumers.length&&n&&vn(i,t,e,r,s,n,a),r},xn=(e,t,r,o)=>{let n=!0;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=!1;else {let s=J(t),{error:a,output:i}=he("variables",r,e.settings.allowedLogic||"return false;",o,void 0,s);a||(n=!!i);}return n},br=async(e,t,r,o,n,s={},a,i="section",c)=>{let u=i==="section",l=J(n),p=l.variables,d={...s.variables??{}},f={...s.status??{}},b=new Set,T=[],m={};r?m={...m,[r]:e[r]}:t?m=(t??[]).reduce((k,{id:M})=>({...k,...dr(M,e)}),{}):m=Object.values(e).filter(k=>bt(k)).reduce((k,M)=>({...k,[M.id]:M}),{});let L=Object.values(m).filter(k=>bt(k));if(L.length>0){ce&&console.info("%crunConsumers: calculating section flags","color:purple",L.map(y=>y.id).join(", "));let k=Object.fromEntries(await Promise.all(L.map(async y=>[y.id,await hr(y,o,{...l,variables:p,locale:p.locale},a,c).then(R=>{let{outputVariables:h,status:A}=R;if(A.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${y.id}, Section ${y.section_id}) failed with message: ${A.error}. `);f[y.id]={allowed:!1,error:A.error},d[y.id]={};}return (y.consumers.length>0||[S.GENERATOR,S.SECTION_FLAG,S.RELATED].includes(y.type))&&A.allowed&&Object.keys(h).length>0?d[y.id]=h:d[y.id]={},i==="report"?(f[y.id]={allowed:A.allowed},[S.GENERATOR,S.SECTION_FLAG].includes(y.type)&&A.api&&(f[y.id].api=A.api)):f[y.id]=A,R})]))),Y=Object.entries(k).filter(([,y])=>!y.outputVariables[yr]).map(([y])=>Number(y));b=new Set(Y.map(y=>e[y].section_id)),Object.values(m).filter(y=>b.has(y.section_id)).forEach(y=>{T.push(y.id),delete m[y.id];}),ce&&console.info("%crunConsumers: removing sections","color:purple",b.keys());}let v=b.size>0?Object.fromEntries(Object.entries(e).filter(([,k])=>b?.has(k.section_id)?(T.includes(k.id)||T.push(k.id),!1):!0)):e;if(T.length>0&&(v=Object.fromEntries(Object.entries(v).map(([k,M])=>{let Y={...M,inputs:M.inputs.filter(y=>!T.includes(y)),consumers:M.consumers.filter(y=>!T.includes(y))};return [k,Y]}))),!r&&!t)return {variables:{...s.variables??{},...d},status:{...s.status??{},...f}};i==="report"&&T.length>0&&T.forEach(k=>{delete d[k],delete f[k],delete e[k];}),ce&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(m));let x=Object.keys(m).reduce((k,M)=>{let Y=new Date,y=Tt(Number(M),v,[],!r,!0,u).map(A=>A.split("-")),h=(new Date().getTime()-Y.getTime())/1e3;return ce&&console.info(`%cResolved dependencies for ${M} (${h.toFixed(2)}s)`,"color:blue"),[...k,...y]},[]),$=new Date,_=Object.keys(m).reduce((k,M)=>k.includes(M)?[...k]:[M,...k],yn(x)),O=(new Date().getTime()-$.getTime())/1e3;ce&&console.info(`%cResolved DAG (${O.toFixed(2)}s): `,"color:green",_);let w=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,C=parseInt(`${w||0}`,10);async function P(k,M){let Y=new Map,y=[],R=async()=>y.length;for(let h of k){if(C!==0){let G=await R();for(;G>=C;)ce&&console.info("Too many pending promises, waiting...",G,y),await new Promise(se=>setTimeout(se,500)),G=await R();}let A=M[h],He=Promise.all(A.inputs.filter(G=>k.includes(String(G))).map(G=>Y.get(Number(G)))).then(async()=>{let G=A.inputs.reduce((W,Q)=>({...W,...d[Q]}),p),se=A.inputs.find(W=>(A.settings?.ignoreCascade?A.settings?.ignoreCascade:[]).includes(W)||!f[W]?!1:!f[W].allowed||f[W].hiddenByCascade);if(se){f[h]={allowed:!1,hiddenByCascade:f[se].hiddenByCascade||se},d[h]={},y.splice(y.indexOf(Number(h)),1);return}let $t=new Date,I;typeof window<"u"&&[S.SELECTOR,S.MULTIHIERARCHY_SELECTOR].includes(A.type)&&A.settings[ar.DISABLED]?I=new Promise(W=>{W({outputVariables:d[h],status:f[h]});}):I=hr(A,o,{...l,variables:G,locale:G.locale},a,c);let z=await I.then(({outputVariables:W,status:Q})=>{if(Q.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${h}, Section ${A.section_id}) failed with message: ${Q.error}.`);f[h]={allowed:!1,error:Q.error},d[h]={};}(A.consumers.length>0||[S.GENERATOR,S.SECTION_FLAG,S.RELATED].includes(A.type))&&Q.allowed&&Object.keys(W).length>0?d[h]=W:d[h]={},i==="report"?(f[h]={allowed:Q.allowed},[S.GENERATOR,S.SECTION_FLAG].includes(A.type)&&Q.api&&(f[h].api=Q.api)):f[h]=Q;}),de=(new Date().getTime()-$t.getTime())/1e3;return ce&&console.info(`%cBlock ${A.id} resolved in ${de.toFixed(3)}s`,de>500?"color:red":"color:green"),f[h].duration=f[h].duration?f[h].duration:de,y.splice(y.indexOf(Number(h)),1),z}).catch(G=>{throw y.splice(y.indexOf(Number(h)),1),G});y.push(Number(h)),Y.set(Number(h),He);}await Promise.all(Array.from(Y.values()));}let N=new Date;await P(_,v);let H=(new Date().getTime()-N.getTime())/1e3;return ce&&console.info(`%cResolved Variables (${H.toFixed(2)}s), ${_.length} blocks`,"color:green"),{variables:{...s.variables??{},...d},status:{...s.status??{},...f}}};function Cn(e=[]){return e.reduce((t,r,o)=>{if(r){let n=o+1;t[`id${n}`]=r.id,t[`name${n}`]=r.name,t[`slug${n}`]=r.slug,"attributes"in r&&Object.keys(r.attributes).forEach(s=>{t[`attr_${s}${n}`]=r.attributes[s];}),t[`variant_id${n}`]=r.variant_id,t[`variant_name${n}`]=r.variant_name,t[`variant_slug${n}`]=r.variant_slug,t[`dimension_id${n}`]=r.dimension_id,t[`dimension_name${n}`]=r.dimension_name,t.report_id=r.report_id,t.report_name=r.report_name;}return t},{})}var Tr=Cn;function be(e,t,r){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${Ar(r)}`;return e[n]}let o=`${t}${Ar(r)}`;return e[o]}function Ar(e){return e[0].toUpperCase()+e.slice(1)}function j(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];if(process.env.NODE_ENV!=="production"){var n=wn[e],s=n?typeof n=="function"?n.apply(null,r):n:"unknown error nr: "+e;throw Error("[Immer] "+s)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map(function(a){return "'"+a+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Ie(e){return !!e&&!!e[X]}function Ae(e){var t;return !!e&&(function(r){if(!r||typeof r!="object")return !1;var o=Object.getPrototypeOf(r);if(o===null)return !0;var n=Object.hasOwnProperty.call(o,"constructor")&&o.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===Nn}(e)||Array.isArray(e)||!!e[Or]||!!(!((t=e.constructor)===null||t===void 0)&&t[Or])||It(e)||Bt(e))}function $e(e,t,r){r===void 0&&(r=!1),we(e)===0?(r?Object.keys:Ut)(e).forEach(function(o){r&&typeof o=="symbol"||t(o,e[o],e);}):e.forEach(function(o,n){return t(n,o,e)});}function we(e){var t=e[X];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:It(e)?2:Bt(e)?3:0}function kt(e,t){return we(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function kn(e,t){return we(e)===2?e.get(t):e[t]}function Ir(e,t,r){var o=we(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r;}function Pn(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function It(e){return In&&e instanceof Map}function Bt(e){return Bn&&e instanceof Set}function Te(e){return e.o||e.t}function wt(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=Mn(e);delete t[X];for(var r=Ut(t),o=0;o<r.length;o++){var n=r[o],s=t[n];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(t[n]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function Nt(e,t){return t===void 0&&(t=!1),Mt(e)||Ie(e)||!Ae(e)||(we(e)>1&&(e.set=e.add=e.clear=e.delete=Ln),Object.freeze(e),t&&$e(e,function(r,o){return Nt(o,!0)},!0)),e}function Ln(){j(2);}function Mt(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function oe(e){var t=Dn[e];return t||j(18,e),t}function vr(){return process.env.NODE_ENV==="production"||Be||j(0),Be}function At(e,t){t&&(oe("Patches"),e.u=[],e.s=[],e.v=t);}function st(e){Pt(e),e.p.forEach(_n),e.p=null;}function Pt(e){e===Be&&(Be=e.l);}function xr(e){return Be={p:[],l:Be,h:e,m:!0,_:0}}function _n(e){var t=e[X];t.i===0||t.i===1?t.j():t.g=!0;}function vt(e,t){t._=t.p.length;var r=t.p[0],o=e!==void 0&&e!==r;return t.h.O||oe("ES5").S(t,e,o),o?(r[X].P&&(st(t),j(4)),Ae(e)&&(e=at(t,e),t.l||it(t,e)),t.u&&oe("Patches").M(r[X].t,e,t.u,t.s)):e=at(t,r,[]),st(t),t.u&&t.v(t.u,t.s),e!==Br?e:void 0}function at(e,t,r){if(Mt(t))return t;var o=t[X];if(!o)return $e(t,function(i,c){return Cr(e,o,t,i,c,r)},!0),t;if(o.A!==e)return t;if(!o.P)return it(e,o.t,!0),o.t;if(!o.I){o.I=!0,o.A._--;var n=o.i===4||o.i===5?o.o=wt(o.k):o.o,s=n,a=!1;o.i===3&&(s=new Set(n),n.clear(),a=!0),$e(s,function(i,c){return Cr(e,o,n,i,c,r,a)}),it(e,n,!1),r&&e.u&&oe("Patches").N(o,r,e.u,e.s);}return o.o}function Cr(e,t,r,o,n,s,a){if(process.env.NODE_ENV!=="production"&&n===r&&j(5),Ie(n)){var i=at(e,n,s&&t&&t.i!==3&&!kt(t.R,o)?s.concat(o):void 0);if(Ir(r,o,i),!Ie(i))return;e.m=!1;}else a&&r.add(n);if(Ae(n)&&!Mt(n)){if(!e.h.D&&e._<1)return;at(e,n),t&&t.A.l||it(e,n);}}function it(e,t,r){r===void 0&&(r=!1),!e.l&&e.h.D&&e.m&&Nt(t,r);}function xt(e,t){var r=e[X];return (r?Te(r):e)[t]}function kr(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Object.getPrototypeOf(r);}}function Lt(e){e.P||(e.P=!0,e.l&&Lt(e.l));}function Ct(e){e.o||(e.o=wt(e.t));}function _t(e,t,r){var o=It(t)?oe("MapSet").F(t,r):Bt(t)?oe("MapSet").T(t,r):e.O?function(n,s){var a=Array.isArray(n),i={i:a?1:0,A:s?s.A:vr(),P:!1,I:!1,R:{},l:s,t:n,k:null,o:null,j:null,C:!1},c=i,u=Ot;a&&(c=[i],u=qe);var l=Proxy.revocable(c,u),p=l.revoke,d=l.proxy;return i.k=d,i.j=p,d}(t,r):oe("ES5").J(t,r);return (r?r.A:vr()).p.push(o),o}function On(e){return Ie(e)||j(22,e),function t(r){if(!Ae(r))return r;var o,n=r[X],s=we(r);if(n){if(!n.P&&(n.i<4||!oe("ES5").K(n)))return n.t;n.I=!0,o=Pr(r,s),n.I=!1;}else o=Pr(r,s);return $e(o,function(a,i){n&&kn(n.t,a)===i||Ir(o,a,t(i));}),s===3?new Set(o):o}(e)}function Pr(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return wt(e)}var Lr,Be,Dt=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",In=typeof Map<"u",Bn=typeof Set<"u",_r=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",Br=Dt?Symbol.for("immer-nothing"):((Lr={})["immer-nothing"]=!0,Lr),Or=Dt?Symbol.for("immer-draftable"):"__$immer_draftable",X=Dt?Symbol.for("immer-state"):"__$immer_state";var wn={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return "Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return "Unsupported patch operation: "+e},18:function(e){return "The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return "'current' expects a draft, got: "+e},23:function(e){return "'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Nn=""+Object.prototype.constructor,Ut=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,Mn=Object.getOwnPropertyDescriptors||function(e){var t={};return Ut(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r);}),t},Dn={},Ot={get:function(e,t){if(t===X)return e;var r=Te(e);if(!kt(r,t))return function(n,s,a){var i,c=kr(s,a);return c?"value"in c?c.value:(i=c.get)===null||i===void 0?void 0:i.call(n.k):void 0}(e,r,t);var o=r[t];return e.I||!Ae(o)?o:o===xt(e.t,t)?(Ct(e),e.o[t]=_t(e.A.h,o,e)):o},has:function(e,t){return t in Te(e)},ownKeys:function(e){return Reflect.ownKeys(Te(e))},set:function(e,t,r){var o=kr(Te(e),t);if(o?.set)return o.set.call(e.k,r),!0;if(!e.P){var n=xt(Te(e),t),s=n?.[X];if(s&&s.t===r)return e.o[t]=r,e.R[t]=!1,!0;if(Pn(r,n)&&(r!==void 0||kt(e.t,t)))return !0;Ct(e),Lt(e);}return e.o[t]===r&&(r!==void 0||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=!0),!0},deleteProperty:function(e,t){return xt(e.t,t)!==void 0||t in e.t?(e.R[t]=!1,Ct(e),Lt(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=Te(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty:function(){j(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){j(12);}},qe={};$e(Ot,function(e,t){qe[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};}),qe.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&j(13),qe.set.call(this,e,t,void 0)},qe.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&j(14),Ot.set.call(this,e[0],t,r,e[0])};var Un=function(){function e(r){var o=this;this.O=_r,this.D=!0,this.produce=function(n,s,a){if(typeof n=="function"&&typeof s!="function"){var i=s;s=n;var c=o;return function(T){var m=this;T===void 0&&(T=i);for(var L=arguments.length,v=Array(L>1?L-1:0),x=1;x<L;x++)v[x-1]=arguments[x];return c.produce(T,function($){var _;return (_=s).call.apply(_,[m,$].concat(v))})}}var u;if(typeof s!="function"&&j(6),a!==void 0&&typeof a!="function"&&j(7),Ae(n)){var l=xr(o),p=_t(o,n,void 0),d=!0;try{u=s(p),d=!1;}finally{d?st(l):Pt(l);}return typeof Promise<"u"&&u instanceof Promise?u.then(function(T){return At(l,a),vt(T,l)},function(T){throw st(l),T}):(At(l,a),vt(u,l))}if(!n||typeof n!="object"){if((u=s(n))===void 0&&(u=n),u===Br&&(u=void 0),o.D&&Nt(u,!0),a){var f=[],b=[];oe("Patches").M(n,u,f,b),a(f,b);}return u}j(21,n);},this.produceWithPatches=function(n,s){if(typeof n=="function")return function(u){for(var l=arguments.length,p=Array(l>1?l-1:0),d=1;d<l;d++)p[d-1]=arguments[d];return o.produceWithPatches(u,function(f){return n.apply(void 0,[f].concat(p))})};var a,i,c=o.produce(n,s,function(u,l){a=u,i=l;});return typeof Promise<"u"&&c instanceof Promise?c.then(function(u){return [u,a,i]}):[c,a,i]},typeof r?.useProxies=="boolean"&&this.setUseProxies(r.useProxies),typeof r?.autoFreeze=="boolean"&&this.setAutoFreeze(r.autoFreeze);}var t=e.prototype;return t.createDraft=function(r){Ae(r)||j(8),Ie(r)&&(r=On(r));var o=xr(this),n=_t(this,r,void 0);return n[X].C=!0,Pt(o),n},t.finishDraft=function(r,o){var n=r&&r[X];process.env.NODE_ENV!=="production"&&(n&&n.C||j(9),n.I&&j(10));var s=n.A;return At(s,o),vt(void 0,s)},t.setAutoFreeze=function(r){this.D=r;},t.setUseProxies=function(r){r&&!_r&&j(20),this.O=r;},t.applyPatches=function(r,o){var n;for(n=o.length-1;n>=0;n--){var s=o[n];if(s.path.length===0&&s.op==="replace"){r=s.value;break}}n>-1&&(o=o.slice(n+1));var a=oe("Patches").$;return Ie(r)?a(r,o):this.produce(r,function(i){return a(i,o)})},e}(),Z=new Un,Fn=Z.produce;Z.produceWithPatches.bind(Z);Z.setAutoFreeze.bind(Z);Z.setUseProxies.bind(Z);Z.applyPatches.bind(Z);Z.createDraft.bind(Z);Z.finishDraft.bind(Z);var ct=Fn;var te=ae.actions,Dr=je({block:ue("block"),dimension:ue("dimension"),formatter:ue("formatter"),report:ue("report"),section:ue("section"),variant:ue("variant"),datasource:ue("datasource")}),ze=je({block:le("block"),dimension:le("dimension"),formatter:le("formatter"),report:le("report"),section:le("section"),variant:le("variant"),datasource:le("datasource")}),Ur=je({block:ne("block"),dimension:ne("dimension"),formatter:ne("formatter"),report:ne("report"),section:ne("section"),variant:ne("variant"),datasource:ne("datasource")}),Fr=je({block:ve("block"),dimension:ve("dimension"),formatter:ve("formatter"),report:ve("report"),section:ve("section"),variant:ve("variant"),datasource:ve("datasource")}),Vr=je({block:Nr("block"),section:Nr("section")});function je(e){return (t,r)=>{let o=e[t];if(!o)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return o(r)}}function Ce(e,t){return (r,o)=>{let s=o().records.requests[e][t],a=!s||s.status==="UNINITIALIZED"?"LOADING":"FETCHING";r(te.setRequest({key:t,type:e,status:a}));}}function xe(e,t,r,o){return n=>{typeof window=="object"&&notifications.show({autoClose:3e3,color:"red",id:t,message:o,title:"Error"}),n(te.setRequest({key:t,type:e,status:"FAILURE",error:{code:r,message:o}}));}}function ue(e){return t=>{let r=Vt(e,t);return (o,n,s)=>(o(Ce(e,r)),be(s,"create",e)(t).then(i=>(i.ok===!0?o(te.setCreateRequest({key:r,operation:"create",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function $n(e){return t=>{let r=Vt(e,t[0]);return (o,n,s)=>(o(Ce(e,r)),be(s,"createBulk",e)(t).then(i=>(i.ok===!0?o(te.setCreateRequest({key:r,operation:"createBulk",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function wr(e,t,r){return r.replace(new RegExp(e,"g"),t)}function zn(e){return e.section_id!==void 0}function jn(e){return e.report_id!==void 0}function Nr(e){return t=>{let{create:r}=t;return (o,n,s)=>ue(e)(r)(o,n,s).then(async i=>{if(i.ok){let{data:c}=i,{id:u}=c,{update:l}=t,p=zr(e,{id:u});if(o(Ce(e,`${p}`)),e==="block"&&zn(r)){let d=ct(l,m=>{m.id=u;}),{contentByLocale:f}=d;f&&(d=ct(d,m=>{m.id=u,m.contentByLocale=Object.keys(f).reduce((L,v)=>{let x=f?f[v]:{};return L[v]={...x,id:u},L},{});}));let T=d.inputs?.map(m=>({type:m.type,id:m.id,inputAction:{operation:"create",input:{input_id:m.id,block_id:d.id}}}));return T&&T.length>0&&Mr(e)([d,...T])(o,n,s).then(()=>le("section")({id:d.section_id,include:!0})(o,n,s).then(m=>(m.ok&&o(te.setRequest({key:p,type:e,status:"SUCCESS",data:m.data})),m))),ne(e)(d)(o,n,s).then(m=>(m.ok&&o(te.setRequest({key:p,type:e,status:"SUCCESS",data:m.data})),m))}if(e==="section"&&jn(r)){let{id:d}=c,f=ct(l,m=>{m.id=d;}),{blocks:b}=f,T=b?.map(m=>({type:m.type,blockcol:m.blockcol,blockrow:m.blockrow,section_id:d,locales:Object.keys(m.contentByLocale).map(L=>L)}));return T&&b&&await $n("block")(T)(o,n,s).then(m=>{if(m.ok){let L=m.data,v=[],x=L.map(($,_)=>{let O={...$},w=O.id,C=b[_];C.contentByLocale&&(O.contentByLocale=Object.keys(C.contentByLocale).reduce((y,R)=>{let h=C.contentByLocale[R];return y[R]={...h,content:{...h.content},id:O.id},y},{}));let{settings:P}=C,{contentByLocale:N,id:F}=O;O.settings=P;let H={id:F,contentByLocale:N,settings:P};return C.inputs.map(y=>y.id).reduce((y,R)=>{let h=b.findIndex(A=>A.id===R);return [...y,h]},[]).map(y=>({...L[y],originalBlock:b[y]})).forEach(y=>{let{id:R,type:h,originalBlock:A}=y;if([S.SELECTOR,S.VIZ].includes(h)){if(H.contentByLocale?.logic?.content?.api){let pe=H.contentByLocale?.logic.content.api;H.contentByLocale.logic.content.api=wr(`(selector${A.id}id)`,`selector${R}id`,pe);}if(H.contentByLocale?.logic?.content?.logic){let pe=H.contentByLocale.logic.content.logic;H.contentByLocale.logic.content.logic=wr(`(selector${A.id}id)`,`selector${R}id`,pe);}}v.push({id:R,inputAction:{operation:"create",input:{input_id:R,block_id:w}}});}),H});return Mr("block")([...x,...v])(o,n,s)}}),ne(e)(f)(o,n,s).then(m=>(m.ok&&o(te.setRequest({key:p,type:e,status:"SUCCESS",data:m.data})),m))}return ne(e)({...l,id:c.id})(o,n,s)}})}}function le(e){return t=>{let r=qr(e,t);return (o,n,s)=>{o(Ce(e,r));let a=be(s,"read",e);if(typeof a!="function"){let i=`Failed to get valid RPC method for entity "${e}"`;return o(xe(e,r,500,i)),Promise.reject(new Error(i))}return a(t).then(i=>(i.ok===!0?o(te.setReadRequest({key:r,operation:"read",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i))}}}function ne(e){return t=>{let r=qt(e,t);return (o,n,s)=>(o(Ce(e,r)),be(s,"update",e)(t).then(i=>(i.ok===!0?o(te.setUpdateRequest({key:r,operation:"update",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function Mr(e){return t=>{let r=qt(e,t[0]);return (o,n,s)=>(o(Ce(e,r)),be(s,"updateBulk",e)(t).then(i=>(i.ok===!0?o(te.setUpdateRequest({key:r,operation:"updateBulk",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error)),i)))}}function ve(e){return t=>{let r=$r(e,t);return (o,n,s)=>(o(Ce(e,r)),be(s,"delete",e)(t).then(i=>{i.ok===!0?o(te.setDeleteRequest({key:r,operation:"delete",status:"SUCCESS",type:e,data:i.data})):o(xe(e,r,i.status,i.error));}))}}function Vt(e,t){if(e==="variant"){let r=t;return `create(variant, [${r.dimension_id}, ${r.name}])`}return `create(${e}, [${Object.keys(t)}])`}function qr(e,t={}){let r=t.id==null?null:`'${t.id}'`;return `read(${e}, ${r}, ${!!t.include})`}function qt(e,t){let{id:r,...o}=t;return `update(${e}, ${r}, [${Object.keys(o)}])`}function $r(e,t){return `delete(${e}, ${t})`}function zr(e,t){let r=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${r})`}var{setStatus:jr,setPreviews:Gn,setSectionState:Gr,resetSectionState:Hr,setCurrentLocale:Hn,setPreferredLocale:Kn,addRunConsumersRunning:Kr,removeRunConsumersRunning:Yr}=Oe;function Yn(e,t){return async(r,o,n)=>{let s=await n.validateVariantSlug({dimension:e,slug:t});if("error"in s)throw new Error(s.error);return s.data}}function Wn(e){return async(t,r,o)=>{let n=await o.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function Qn(){return async(e,t,r)=>{let o=await r.regenerateSearch(void 0);if("error"in o)throw new Error(o.error);return o.data}}function Wr(e){return async(t,r,o)=>{let n=await o.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function Xn(e){return async(t,r,o)=>{let n=await o.searchMember(e);if(n.ok===!0)return n.data;throw new Error(n.error)}}async function Qr(e,t,r,o){let n=r().status,s={...n,...o},a={...n.query,...o.query};Object.keys(a).forEach(c=>a[c]===void 0&&delete a[c]);let i={...s,query:a};t(jr(i)),n.activeSection&&t(Xr(e,{query:a}));}function Zn(e,t){return async(r,o)=>Qr(e,r,o,{query:{[t]:void 0}})}function Jn(e,t,r){return async(o,n)=>Qr(e,o,n,{query:{[t]:r}})}function Xr(e,t){return async(r,o)=>{let n=o(),{currentLocale:s}=n.status,a=n.records.entities.block,i=e.formatterFunctions[s],c=e.datasourceFunctions,{parsedParams:u,statusPayload:l}=Jt(n.status,t),{sid:p,bid:d,previews:f,query:b}=u;Object.keys(l).length&&r(Oe.setStatus(l));let T={...Tr(f),locale:s,...Ve()},m={variables:T,query:b,locale:s};r(Oe.addRunConsumersRunning([p]));let L=n.records.entities.section[p],v=async x=>r(Wr(x));try{let x=await br(a,L&&[L],d,i,m,void 0,v,"section",c),{variables:$,status:_}=x;r(er.setVariableChange({attributes:T,variables:$,status:_})),r(Oe.removeRunConsumersRunning([p]));}catch(x){console.error("Error in runConsumers client side: recalculateVariables",x);}}}function es(e){return async(t,r,o)=>{let n=await o.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function ts(e){return async(t,r,o)=>{let n=await o.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function rs(){return async(e,t,r)=>{let o=await r.searchRole("");if("error"in o)throw new Error(o.error);return o.data}}function os(e){return async(t,r,o)=>{let n=await o.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function ns(e){return async(t,r,o)=>{let n=await o.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function ss({user:e}){return async(t,r,o)=>{let n=await o.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function as(e){return async(t,r,o)=>{let n=await o.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function is(e){let{removeBlocks:t}=ae.actions;return async r=>{await r(t(e));}}function cs(e){let{addBlocks:t}=ae.actions;return async r=>{await r(t(e));}}function us(e){return async(t,r,o)=>{let n=await o.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function ls(e){return async(t,r,o)=>{let n=await o.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function ps(e){return async(t,r,o)=>{let n=await o.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function ds(){return async(e,t,r)=>{let o=await r.readEnvSecrets({});if("error"in o)throw new Error(o.error);return o.data}}function fs(){let{removeDataSourceLogic:e}=ae.actions;return async t=>{await t(e());}}var {locales:ys}=re(),Rs={pathSegment:"path",formatterFunctions:ys.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",siteProps:{}};createContext(Rs);re();var lt=useDispatch,Ge=useSelector;
31
31
 
32
32
  export { ut as actions, rr as storeWrapper, lt as useBespokeDispatch, Ge as useBespokeSelector };