@datawheel/bespoke 1.0.0-rc.3 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cms.js +1 -1
- package/dist/report.js +1 -1
- package/package.json +1 -1
package/dist/cms.js
CHANGED
|
@@ -31,7 +31,7 @@ return {
|
|
|
31
31
|
}`;});function mo(e){return e.type===w.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var ni=D(()=>{u();be();});function XO(){let{publicRuntimeConfig:e}=YO(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((o,r)=>(o[`ENV_${r}`]=t[r]||"N/A",o),{})}}var rr,Ki=D(()=>{u();rr=XO;});function JO(){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 NS,zS=D(()=>{u();NS=JO;});function Jp(e){return e.ok!==void 0}function Xp(e){this.message=e,this.name="ApiFetchException";}async function rf(e,t,o="en",r,n){let i=Date.now(),a=e,l,s=rr(),p=NS(),c={envs:{...s,...p}},d=new URL(e),m=new URLSearchParams(d.searchParams.toString());m.has("bespoke_slugs")&&(d.searchParams.delete("bespoke_slugs"),a=d.toString());let f={datasource:void 0};r.find(S=>{if(!S.content?.pattern)return false;try{let E=new RegExp(S.content.pattern,"gm");return E.test(a)?(f.datasource=S,!0):E.test(a)}catch{return false}});let g=n?n.settings:{},h=!!(g&&g.useProxy&&g.useProxy==="true"),y=f.datasource&&typeof f.datasource.content.useProxy=="boolean"?f.datasource.content.useProxy:false,b=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(a)}`;if(typeof window=="object"&&(h||y)){let S=await iL({url:a,timeout:VS});if(S.ok===true)l=S.data;else throw new Xp(S?.error)}else try{let E={url:a,timeout:VS};if(f.datasource){let C=c;if(typeof window<"u")try{let L=await getSession();if(L){let I={user:L.user,status:"authenticated",isLoading:!1,update:async()=>L};C={...c,session:I};}}catch(L){console.warn("Could not retrieve user session:",L);}let R=await Fp({vars:["url","libs","session"],logic:f.datasource.content.logic},C)(a);if(R.axiosConfig)E=R.axiosConfig;else throw new Xp(`AxiosConfig is missing in Data Source ${f.datasource.name} (ID: ${f.datasource.id}).`)}let v=await Qp(E);if(v.status===200)v.headers["content-type"]==="text/csv"?l=csvParse(v.data):l=v.data;else throw new Xp("No response for: "+a)}catch(S){throw new Xp(S.message)}if(m.has("bespoke_slugs")){let S=m.get("bespoke_slugs");if(S){let E=S.split(",");if(E.length===3){let[v,C,k]=E,R=Yp(l,k);if(R&&Array.isArray(R)){let L=Array.from(new Set(R.map(I=>`${I[C]}`).filter(I=>!["","undefined"].includes(I))));if(L.length>0){let I=L.join("").length>2e3,P=await t({mode:I?"whole":"ids",ids:I?void 0:L,all:false,locale:o,variant:[parseInt(v,10)],output:"lite",limit:L.length+1,allowNulls:true}).then(O=>{let F=[];return Jp(O)?O.ok&&(F=O.data.results):F=O.results,F&&Array.isArray(F)?F:[]}).catch(O=>(console.error(`Error hydrating slugs for Variant: ${v}, Key: ${C}, Accessor: ${k}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(O),[]));if(P){let O=Object.fromEntries(P.map(F=>[F.id,`/${F.variant_slug}/${F.slug}`]));R.map(F=>(F.bespoke_slug=O[F[C]]?O[F[C]]:null,F));}}}}}}return {data:l,requestDuration:Date.now()-i,finalUrl:y||h?b:a,apiDataSource:f.datasource?f.datasource:false}}function aL(e){this.name="BlockException",this.message=e;}async function Kl(e,t,o,r,n){let{locale:i,variables:a,query:l}=tr(o),s=sL(e,o,a,t),p=null,c=e.contentByLocale?.logic?.content?.api,d=null,m=null,f=null,g,h;if(!s)return {outputVariables:{},renderVariables:{},status:{allowed:false,hiddenByCascade:e.id}};if(e.type===w.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:s,hiddenByCascade:e.id}};if(c){f=nL(c,t,o);let R=f.split("|||").filter(P=>P!==""),L=[];for(let P=0;P<R.length;P++){let O=R[P];new RegExp("^(?:[a-z+]+:)?//","i").test(f)||(O=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${O}`.replace(/([^:]\/)\/+/g,"$1")),L.push(rf(O,r,i,n,e).catch(A=>{throw new aL(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${a.report_name} (${a.report_id}) failed.
|
|
32
32
|
Error fetching ${O}.
|
|
33
33
|
Message: ${A.message}.
|
|
34
|
-
`)}));}let I=await Promise.all(L).catch(P=>P.message);if(typeof I=="string"&&I)return {outputVariables:{},renderVariables:{},status:{error:I}};p=I.length===1?I[0].data:I.map(P=>P.data),m=I.reduce((P,O)=>P+JSON.stringify(O.data).length/1024,0),d=Math.max(...I.map(P=>P.requestDuration)),g=I.map(P=>P.apiDataSource?`${P.apiDataSource.name} (${P.apiDataSource.id})`:null),h=I.map(P=>P.finalUrl);}if(e.type===w.SELECTOR){let{config:R,log:L,error:I}=Kp(e.id,e.contentByLocale[i].content.logic,t,o,true);return {outputVariables:RS(e.id,l,R),renderVariables:R,status:{log:L,error:I,allowed:s}}}if(e.type===w.MULTIHIERARCHY_SELECTOR){let{config:R,log:L,error:I}=qp(e.id,e.contentByLocale[i].content.logic,t,o,true);return {outputVariables:IS(e.id,l,R),renderVariables:R,status:{log:L,error:I,allowed:s}}}if(e.type===w.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:s}};if(e.type===w.RELATED){let R=e.contentByLocale?.logic?.content?.simple?.compare||"variant",L=e.contentByLocale?.logic?.content?.simple?.limit||4,I=Object.keys(a).filter(K=>K.startsWith("report_id")).map(K=>a[K]),P=Object.keys(a).filter(K=>K.startsWith("dimension_id")).map(K=>a[K]),O=Object.keys(a).filter(K=>K.startsWith("variant_id")).map(K=>a[K]),F=Object.keys(a).filter(K=>K.startsWith("id")).map(K=>a[K]);if(!F.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:false}};let A=await Promise.all(F.map((K,V)=>r({mode:"ids",locale:i,ids:[K],output:"lite",variant:[O[V]]}))).then(K=>K.flatMap(V=>{let j=[];return Jp(V)?V.ok&&(j=V.data.results):j=V.results,j&&Array.isArray(j)?j:[]})).catch(K=>(console.error("Error getting related members",K),[]));if(P.length>1){let K=Object.keys(a).filter(te=>te.startsWith("variant_slug")).map(te=>a[te]),V=A.map((te,U)=>{let z={mode:"related",locale:i,related:L??4,current_ids:[te.content_id],output:"full",variant_ids:[te.variant_id]};return U===0&&(z.include_ids=[te.content_id]),z}),j=await Promise.all(V.map(te=>r(te))).then(te=>te.flatMap(U=>{let z=[];return Jp(U)?U.ok&&(z=U.data.results):z=U.results,z&&Array.isArray(z)?z:[]})).catch(te=>(console.error("Error getting related members",te),[])),H=j.reduce((te,U)=>{let z=U.variant_slug;return te[z]||(te[z]=[]),te[z].push(U),te},{}),Y=[],_=Object.keys(H),Z=[{combination:[],index:0}];for(;Z.length>0;){let te=Z.pop();if(!te)continue;let{combination:U,index:z}=te;if(z===_.length){Y.push(U);continue}let Q=_[z],J=H[Q];for(let se of J)Z.push({combination:[...U,se],index:z+1});}return {outputVariables:{related_reports:Y.map(te=>{let U=te.sort((z,Q)=>K.indexOf(z.variant_slug)-K.indexOf(Q.variant_slug));return {entities:U,link:"/"+U.map(z=>`${z.variant_slug}/${z.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:j.length>0}}}let M=A.map(K=>K.content_id),B={mode:"related",locale:i,related:L??4,current_ids:M,output:"full"};R&&(R==="report"?B.report_ids=I:R==="dimension"?B.dimension_ids=P:B.variant_ids=O);let W=await r(B).then(K=>{let V=[];return Jp(K)?K.ok&&(V=K.data.results):V=K.results,V&&Array.isArray(V)?V:[]}).catch(K=>(console.error("Error getting related members",K),[]));return {outputVariables:{related_reports:W.map(K=>({entities:[K],link:`/${K.variant_slug}/${K.slug}`}))},renderVariables:{},status:{log:[],allowed:W.length>0}}}let{logic:y}=wo(e,i),b=et(y,t,o),S=Yr("resp",p||{},b,t,a,o),{vars:E,error:v,log:C}=S;if(typeof E!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:C,duration:d,responseSize:m,resp:p,api:f,allowed:s,apiFinalUrls:h,apiDataSources:g}};let k=Object.keys(E).reduce((R,L)=>({...R,[`${e.type}${e.id}${L}`]:E[L]}),{});return {renderVariables:E,outputVariables:[w.GENERATOR,w.SECTION_FLAG].includes(e.type)?E:k,status:{log:C,error:v,duration:d,responseSize:m,resp:p,api:f,allowed:s,apiFinalUrls:h,apiDataSources:g}}}function US(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(p=>t[p]&&t[p].section_id===t[o].section_id||!n).forEach(p=>nf(p,t,r,false,i,n,a));}})}var ii,oL,rL,$S,nL,iL,VS,nf,sL,ai,GS,af,xn=D(()=>{u();jm();ri();be();Zm();tf();AS();PS();us();Xr();$o();MS();of();Pr();ni();ss();Ki();zS();ii=uc(process.env.NEXT_PUBLIC_REPORTS_DEBUG),oL=process.env.REPORTS_ORIGIN||"",rL=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,$S=5;try{$S=parseInt(`${rL||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}FS(Qp,{retries:$S,retryDelay:FS.exponentialDelay,onRetry:(e,t,o)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",o.url),console.error(t.message);}});Qp.interceptors.request.use(e=>({...e,requestStart:Date.now()}));Qp.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));nL=(e,t,o)=>{let r=et(e,t,o);return r.startsWith("http")||(r=`${oL}${r.startsWith("/")?"":"/"}${r}`),r},{urlProxy:iL}=jl("/api/cms");VS=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;nf=(e,t,o=[],r=true,n=true,i=true,a=[])=>{if(a.includes(e))return [];a.push(e);let l=t[e];return l&&l.inputs.length&&r&&l.inputs.forEach(s=>{let p=`${s}-${e}`;o.includes(p)||o.push(p),l.inputs.forEach(c=>nf(c,t,o,r,false,i,a));}),l&&l.consumers.length&&n&&US(l,t,e,o,i,n,a),o},sL=(e,t,o,r)=>{let n=true;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=false;else {let i=tr(t),{error:a,output:l}=Yr("variables",o,e.settings.allowedLogic||"return false;",r,void 0,i);a||(n=!!l);}return n},ai=async(e,t,o,r,n,i={},a,l="section",s)=>{let p=l==="section",c=tr(n),d=c.variables,m={...i.variables??{}},f={...i.status??{}},g=new Set,h=[],y={};o?y={...y,[o]:e[o]}:t?y=(t??[]).reduce((M,{id:B})=>({...M,...LS(B,e)}),{}):y=Object.values(e).filter(M=>mo(M)).reduce((M,B)=>({...M,[B.id]:B}),{});let b=Object.values(y).filter(M=>mo(M));if(b.length>0){ii&&console.info("%crunConsumers: calculating section flags","color:purple",b.map(N=>N.id).join(", "));let M=Object.fromEntries(await Promise.all(b.map(async N=>[N.id,await Kl(N,r,{...c,variables:d,locale:d.locale},a,s).then(K=>{let{outputVariables:V,status:j}=K;if(j.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${N.id}, Section ${N.section_id}) failed with message: ${j.error}. `);f[N.id]={allowed:false,error:j.error},m[N.id]={};}return (N.consumers.length>0||[w.GENERATOR,w.SECTION_FLAG,w.RELATED].includes(N.type))&&j.allowed&&Object.keys(V).length>0?m[N.id]=V:m[N.id]={},l==="report"?(f[N.id]={allowed:j.allowed},[w.GENERATOR,w.SECTION_FLAG].includes(N.type)&&j.api&&(f[N.id].api=j.api)):f[N.id]=j,K})]))),W=Object.entries(M).filter(([,N])=>!N.outputVariables[Ro]).map(([N])=>Number(N));g=new Set(W.map(N=>e[N].section_id)),Object.values(y).filter(N=>g.has(N.section_id)).forEach(N=>{h.push(N.id),delete y[N.id];}),ii&&console.info("%crunConsumers: removing sections","color:purple",g.keys());}let S=g.size>0?Object.fromEntries(Object.entries(e).filter(([,M])=>g?.has(M.section_id)?(h.includes(M.id)||h.push(M.id),false):true)):e;if(h.length>0&&(S=Object.fromEntries(Object.entries(S).map(([M,B])=>{let W={...B,inputs:B.inputs.filter(N=>!h.includes(N)),consumers:B.consumers.filter(N=>!h.includes(N))};return [M,W]}))),!o&&!t)return {variables:{...i.variables??{},...m},status:{...i.status??{},...f}};l==="report"&&h.length>0&&h.forEach(M=>{delete m[M],delete f[M],delete e[M];}),ii&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(y));let E=Object.keys(y).reduce((M,B)=>{let W=new Date,N=nf(Number(B),S,[],!o,true,p).map(j=>j.split("-")),V=(new Date().getTime()-W.getTime())/1e3;return ii&&console.info(`%cResolved dependencies for ${B} (${V.toFixed(2)}s)`,"color:blue"),[...M,...N]},[]),v=new Date,C=Object.keys(y).reduce((M,B)=>M.includes(B)?[...M]:[B,...M],QO(E)),R=(new Date().getTime()-v.getTime())/1e3;ii&&console.info(`%cResolved DAG (${R.toFixed(2)}s): `,"color:green",C);let L=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,I=parseInt(`${L||0}`,10);async function P(M,B){let W=new Map,N=[],K=async()=>N.length;for(let V of M){if(I!==0){let _=await K();for(;_>=I;)ii&&console.info("Too many pending promises, waiting...",_,N),await new Promise(Z=>setTimeout(Z,500)),_=await K();}let j=B[V],Y=Promise.all(j.inputs.filter(_=>M.includes(String(_))).map(_=>W.get(Number(_)))).then(async()=>{let _=j.inputs.reduce((J,se)=>({...J,...m[se]}),d),Z=j.inputs.find(J=>(j.settings?.ignoreCascade?j.settings?.ignoreCascade:[]).includes(J)||!f[J]?false:!f[J].allowed||f[J].hiddenByCascade);if(Z){f[V]={allowed:false,hiddenByCascade:f[Z].hiddenByCascade||Z},m[V]={},N.splice(N.indexOf(Number(V)),1);return}let ae=new Date,te;typeof window<"u"&&[w.SELECTOR,w.MULTIHIERARCHY_SELECTOR].includes(j.type)&&j.settings[Nt.DISABLED]?te=new Promise(J=>{J({outputVariables:m[V],status:f[V]});}):te=Kl(j,r,{...c,variables:_,locale:_.locale},a,s);let U=await te.then(({outputVariables:J,status:se})=>{if(se.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${V}, Section ${j.section_id}) failed with message: ${se.error}.`);f[V]={allowed:false,error:se.error},m[V]={};}(j.consumers.length>0||[w.GENERATOR,w.SECTION_FLAG,w.RELATED].includes(j.type))&&se.allowed&&Object.keys(J).length>0?m[V]=J:m[V]={},l==="report"?(f[V]={allowed:se.allowed},[w.GENERATOR,w.SECTION_FLAG].includes(j.type)&&se.api&&(f[V].api=se.api)):f[V]=se;}),Q=(new Date().getTime()-ae.getTime())/1e3;return ii&&console.info(`%cBlock ${j.id} resolved in ${Q.toFixed(3)}s`,Q>500?"color:red":"color:green"),f[V].duration=f[V].duration?f[V].duration:Q,N.splice(N.indexOf(Number(V)),1),U}).catch(_=>{throw N.splice(N.indexOf(Number(V)),1),_});N.push(Number(V)),W.set(Number(V),Y);}await Promise.all(Array.from(W.values()));}let O=new Date;await P(C,S);let A=(new Date().getTime()-O.getTime())/1e3;return ii&&console.info(`%cResolved Variables (${A.toFixed(2)}s), ${C.length} blocks`,"color:green"),{variables:{...i.variables??{},...m},status:{...i.status??{},...f}}},GS=e=>e<250?"green":e<1e3?"yellow":"red",af=e=>e<10?"green":e<100?"yellow":"red";});function lL(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 HS,jS=D(()=>{u();HS=lL;});var Or,Zp,ql=D(()=>{u();Or=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",Zp=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[Or];Zp.includes(Or)||Zp.push(Or);});var uL,eu,Uo,Yl=D(()=>{u();ql();uL={localeDefault:Or,locales:Zp,currentLocale:Or,preferredLocale:Or,showToolbar:false,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:true,settings:false,reportEditor:false},isCMS:false,isRunConsumersRunning:[]},eu=createSlice({name:"status",initialState:uL,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]:true};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:false};},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:e=>{e.addCase(HYDRATE,(t,o)=>{t.previews=o.payload.status.previews;});}}),Uo=eu.actions;});var fL,tu,qi,ds=D(()=>{u();fL={attributes:{},variables:{},status:{}},tu=createSlice({name:"variables",initialState:fL,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:e=>{e.addCase(HYDRATE,(t,o)=>{let r=o.payload.variables;t.attributes={...t.attributes,...r.attributes},t.status={...t.status,...r.status},t.variables={...t.variables,...r.variables};});}}),qi=tu.actions;});function Xl(e,t){return Object.fromEntries(Object.keys(e).map(o=>[o,{...e[o],...t[o]}]))}function ou(e,t){return e.map(n=>t[n]).sort((n,i)=>typeof n.ordering=="string"&&typeof i.ordering=="string"?Eo(n,i):typeof n.ordering=="number"&&typeof i.ordering=="number"?n.ordering-i.ordering:String(n.ordering).localeCompare(String(i.ordering))).map(n=>n.id)}function yL(e,t){let o=e.indexOf(t);o>-1&&e.splice(o,1);}var bL,Tn,Jl=D(()=>{u();wr();ti();bL={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},Tn=createSlice({name:"records",initialState:bL,reducers:{set:(e,t)=>{let o=t.payload;return {entities:Xl(e.entities,o.entities||{}),requests:Xl(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=Vp(o.type,r),i=Xl(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=ou(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=ou(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(p=>p.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=Vp(o.type,o.data),n=Xl(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=Vp(o.type,r),i,a,l;if(o.type==="block"&&!Array.isArray(o.data)){let p=e.entities.block[o.data.id].inputs,c=n.block[o.data.id].inputs;i=p.length!==c.length,i&&(l=p.length>c.length,a=l?p.filter(d=>!c.includes(d))[0]:c.filter(d=>!p.includes(d))[0]),Object.values(n.block).forEach(d=>{d.block_input&&delete n.block[d.id];});}let s=Xl(e.entities,n);if(e.entities=s,o.type==="dimension"){let p=o.data;e.entities.report[p.report_id].dimensions=ou(s.report[p.report_id].dimensions,s.dimension);}else if(o.type==="section"&&!Array.isArray(o.data)){let p=o.data;e.entities.report[p.report_id].sections=ou(s.report[p.report_id].sections,s.section);}else if(o.type==="block"&&!Array.isArray(o.data)){let p=o.data;i&&(l?e.entities.block[a].consumers=e.entities.block[a].consumers.filter(c=>c!==p.id):e.entities.block[a].consumers.push(p.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`;yL(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:e=>{e.addCase(HYDRATE,(t,o)=>{let r=o.payload.records,n=r.entities;t.entities=n,t.reports=Object.values(n.report).map(i=>i.id),t.requests={block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},t.tree=r.tree;});}});});function vL(e){return {ok:false,status:Yi.is(e)?e.code:500,error:e.message}}function Xi(e,t,o){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${WS(o)}`;return e[n]}let r=`${t}${WS(o)}`;return e[r]}function WS(e){return e[0].toUpperCase()+e.slice(1)}var Yi,ru=D(()=>{u();Yi=class extends Error{constructor(t,o){super(o),this.code=t;}toJSON(){return vL(this)}static is(t){return Object.prototype.hasOwnProperty.call(t,"code")&&typeof t.code=="number"}};});function Zl(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 Zi(e,t){return (o,r)=>{let i=r().records.requests[e][t],a=!i||i.status==="UNINITIALIZED"?"LOADING":"FETCHING";o(Lr.setRequest({key:t,type:e,status:a}));}}function Qi(e,t,o,r){return n=>{typeof window=="object"&¬ifications.show({autoClose:3e3,color:"red",id:t,message:r,title:"Error"}),n(Lr.setRequest({key:t,type:e,status:"FAILURE",error:{code:o,message:r}}));}}function si(e){return t=>{let o=lf(e,t);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"create",e)(t).then(l=>(l.ok===true?r(Lr.setCreateRequest({key:o,operation:"create",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function TL(e){return t=>{let o=lf(e,t[0]);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"createBulk",e)(t).then(l=>(l.ok===true?r(Lr.setCreateRequest({key:o,operation:"createBulk",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function KS(e,t,o){return o.replace(new RegExp(e,"g"),t)}function kL(e){return e.section_id!==void 0}function CL(e){return e.report_id!==void 0}function qS(e){return t=>{let{create:o}=t;return (r,n,i)=>si(e)(o)(r,n,i).then(async l=>{if(l.ok){let{data:s}=l,{id:p}=s,{update:c}=t,d=ox(e,{id:p});if(r(Zi(e,`${d}`)),e==="block"&&kL(o)){let m=produce(c,y=>{y.id=p;}),{contentByLocale:f}=m;f&&(m=produce(m,y=>{y.id=p,y.contentByLocale=Object.keys(f).reduce((b,S)=>{let E=f?f[S]:{};return b[S]={...E,id:p},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&&YS(e)([m,...h])(r,n,i).then(()=>li("section")({id:m.section_id,include:true})(r,n,i).then(y=>(y.ok&&r(Lr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))),Jr(e)(m)(r,n,i).then(y=>(y.ok&&r(Lr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}if(e==="section"&&CL(o)){let{id:m}=s,f=produce(c,y=>{y.id=m;}),{blocks:g}=f,h=g?.map(y=>({type:y.type,blockcol:y.blockcol,blockrow:y.blockrow,section_id:m,locales:Object.keys(y.contentByLocale).map(b=>b)}));return h&&g&&await TL("block")(h)(r,n,i).then(y=>{if(y.ok){let b=y.data,S=[],E=b.map((v,C)=>{let R={...v},L=R.id,I=g[C];I.contentByLocale&&(R.contentByLocale=Object.keys(I.contentByLocale).reduce((N,K)=>{let V=I.contentByLocale[K];return N[K]={...V,content:{...V.content},id:R.id},N},{}));let{settings:P}=I,{contentByLocale:O,id:F}=R;R.settings=P;let A={id:F,contentByLocale:O,settings:P};return I.inputs.map(N=>N.id).reduce((N,K)=>{let V=g.findIndex(j=>j.id===K);return [...N,V]},[]).map(N=>({...b[N],originalBlock:g[N]})).forEach(N=>{let{id:K,type:V,originalBlock:j}=N;if([w.SELECTOR,w.VIZ].includes(V)){if(A.contentByLocale?.logic?.content?.api){let H=A.contentByLocale?.logic.content.api;A.contentByLocale.logic.content.api=KS(`(selector${j.id}id)`,`selector${K}id`,H);}if(A.contentByLocale?.logic?.content?.logic){let H=A.contentByLocale.logic.content.logic;A.contentByLocale.logic.content.logic=KS(`(selector${j.id}id)`,`selector${K}id`,H);}}S.push({id:K,inputAction:{operation:"create",input:{input_id:K,block_id:L}}});}),A});return YS("block")([...E,...S])(r,n,i)}}),Jr(e)(f)(r,n,i).then(y=>(y.ok&&r(Lr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}return Jr(e)({...c,id:s.id})(r,n,i)}})}}function li(e){return t=>{let o=ex(e,t);return (r,n,i)=>{r(Zi(e,o));let a=Xi(i,"read",e);if(typeof a!="function"){let l=`Failed to get valid RPC method for entity "${e}"`;return r(Qi(e,o,500,l)),Promise.reject(new Error(l))}return a(t).then(l=>(l.ok===true?r(Lr.setReadRequest({key:o,operation:"read",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l))}}}function Jr(e){return t=>{let o=cf(e,t);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"update",e)(t).then(l=>(l.ok===true?r(Lr.setUpdateRequest({key:o,operation:"update",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function YS(e){return t=>{let o=cf(e,t[0]);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"updateBulk",e)(t).then(l=>(l.ok===true?r(Lr.setUpdateRequest({key:o,operation:"updateBulk",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function Ji(e){return t=>{let o=tx(e,t);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"delete",e)(t).then(l=>{l.ok===true?r(Lr.setDeleteRequest({key:o,operation:"delete",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error));}))}}function lf(e,t){if(e==="variant"){let o=t;return `create(variant, [${o.dimension_id}, ${o.name}])`}return `create(${e}, [${Object.keys(t)}])`}function ex(e,t={}){let o=t.id==null?null:`'${t.id}'`;return `read(${e}, ${o}, ${!!t.include})`}function cf(e,t){let{id:o,...r}=t;return `update(${e}, ${o}, [${Object.keys(r)}])`}function tx(e,t){return `delete(${e}, ${t})`}function ox(e,t){let o=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${o})`}var Lr,nu,XS,Ql,JS,QS,ZS,pf=D(()=>{u();ru();Jl();be();Lr=Tn.actions,nu={create:lf,read:ex,update:cf,delete:tx,clone:ox},XS=Zl({block:si("block"),dimension:si("dimension"),formatter:si("formatter"),report:si("report"),section:si("section"),variant:si("variant"),datasource:si("datasource")}),Ql=Zl({block:li("block"),dimension:li("dimension"),formatter:li("formatter"),report:li("report"),section:li("section"),variant:li("variant"),datasource:li("datasource")}),JS=Zl({block:Jr("block"),dimension:Jr("dimension"),formatter:Jr("formatter"),report:Jr("report"),section:Jr("section"),variant:Jr("variant"),datasource:Jr("datasource")}),QS=Zl({block:Ji("block"),dimension:Ji("dimension"),formatter:Ji("formatter"),report:Ji("report"),section:Ji("section"),variant:Ji("variant"),datasource:Ji("datasource")}),ZS=Zl({block:qS("block"),section:qS("section")});});var ee={};Mm(ee,{addBlockToState:()=>VL,addRunConsumersRunning:()=>mf,cloneEntity:()=>ZS,createEntity:()=>XS,deleteEntity:()=>QS,deleteQueryParam:()=>gf,readEntity:()=>Ql,readEnvSecrets:()=>HL,readMember:()=>nx,readMetadata:()=>LL,readPrivateBlocks:()=>$L,readUser:()=>_L,recalculateVariables:()=>qt,removeBlocksFromState:()=>FL,removeDataSourceLogic:()=>jL,removeRunConsumersRunning:()=>ff,reportSearch:()=>IL,resetSectionState:()=>df,revalidateReport:()=>GL,revalidateUrl:()=>UL,searchMember:()=>OL,searchRegenerate:()=>PL,searchRole:()=>BL,searchUser:()=>DL,setCurrentLocale:()=>wL,setPreferredLocale:()=>RL,setPreviews:()=>EL,setQueryParam:()=>ea,setSectionState:()=>uf,setStatus:()=>rx,updateEntity:()=>JS,updateMyData:()=>zL,updateUser:()=>NL,urlProxy:()=>ML,variantValidateSlug:()=>AL});function AL(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 IL(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 PL(){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 nx(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 OL(e){return async(t,o,r)=>{let n=await r.searchMember(e);if(n.ok===true)return n.data;throw new Error(n.error)}}async function ix(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(rx(l)),n.activeSection&&t(qt(e,{query:a}));}function gf(e,t){return async(o,r)=>ix(e,o,r,{query:{[t]:void 0}})}function ea(e,t,o){return async(r,n)=>ix(e,r,n,{query:{[t]:o}})}function qt(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:p,statusPayload:c}=nS(n.status,t),{sid:d,bid:m,previews:f,query:g}=p;Object.keys(c).length&&o(Uo.setStatus(c));let h={...HS(f),locale:i,...rr()},y={variables:h,query:g,locale:i};o(Uo.addRunConsumersRunning([d]));let b=n.records.entities.section[d],S=async E=>o(nx(E));try{let E=await ai(a,b&&[b],m,l,y,void 0,S,"section",s),{variables:v,status:C}=E;o(qi.setVariableChange({attributes:h,variables:v,status:C})),o(Uo.removeRunConsumersRunning([d]));}catch(E){console.error("Error in runConsumers client side: recalculateVariables",E);}}}function LL(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 ML(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 BL(){return async(e,t,o)=>{let r=await o.searchRole("");if("error"in r)throw new Error(r.error);return r.data}}function DL(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 _L(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 NL({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 zL(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 FL(e){let{removeBlocks:t}=Tn.actions;return async o=>{await o(t(e));}}function VL(e){let{addBlocks:t}=Tn.actions;return async o=>{await o(t(e));}}function $L(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 UL(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 GL(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 HL(){return async(e,t,o)=>{let r=await o.readEnvSecrets({});if("error"in r)throw new Error(r.error);return r.data}}function jL(){let{removeDataSourceLogic:e}=Tn.actions;return async t=>{await t(e());}}var rx,EL,uf,df,wL,RL,mf,ff,Mr=D(()=>{u();xn();jS();Ki();ti();Yl();ds();Jl();pf();({setStatus:rx,setPreviews:EL,setSectionState:uf,resetSectionState:df,setCurrentLocale:wL,setPreferredLocale:RL,addRunConsumersRunning:mf,removeRunConsumersRunning:ff}=Uo);});var Go,ec,ir,ax,ta=D(()=>{u();Go=(e={},t={})=>JSON.stringify(e)===JSON.stringify(t),ec=(e=[],t=[])=>JSON.stringify(e.map(o=>o.id).sort())===JSON.stringify(t.map(o=>o.id).sort()),ir=(e={},t={})=>JSON.stringify(Object.keys(e).sort())===JSON.stringify(Object.keys(t).sort()),ax=(e,t)=>typeof e.data!=typeof t.data?false:Array.isArray(e.data)&&Array.isArray(t.data)?ec(e.data,t.data)&&e.status===t.status:ir(e.data||{},t.data||{})||e.status===t.status;});function Yt(){let e=G(n=>n.status.activeEntity),t=re();return {activeEntity:e,selectEntity:n=>t(Uo.setActiveEntity(n)),unselectEntity:()=>t(Uo.setActiveEntity({type:null,id:null}))}}function mt(e){let t=re(),o=G(i=>i.status.sectionState[e]||qL,Go),r=useCallback(i=>{t(uf({[e]:i}));},[e]),n=useCallback(()=>{t(df(e));},[e]);return {sectionVariables:o,setSectionVariables:r,resetSectionVariables:n}}function ic(){let e=re(),t=G(n=>n.status.isRunConsumersRunning),o=useCallback(n=>{e(mf(n));},[]),r=useCallback(n=>{e(ff(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:o,removeRunConsumersRunning:r}}function zt(e){let t=re();return {opened:G(l=>l.status.sidebarStatus[e]),handlers:{open:()=>t(Uo.openSidebar(e)),close:()=>t(Uo.closeSidebar(e)),toggle:()=>t(Uo.toggleSidebar(e))}}}function hs(){return G(t=>t.status.currentLocale)}function bs(){return G(t=>t.status.preferredLocale)}function ia(e){return t=>{let o=re(),r=useMemo(()=>nu.read(e,{include:true}),[e]),n=useMemo(()=>createSelector([a=>a.records.entities[e],a=>a.records.requests[e][r]],(a,l)=>{let s=Object.values(a),p=l||{status:s==null?"UNINITIALIZED":"SUCCESS"},c=t?s.filter(d=>t.includes(d.id)):s;return Sf(c,p)}),[e,r,t]),i=G(n,ax);return useEffect(()=>{i.isUninitialized&&o(Ql(e,{id:t,include:true}));},[i.status]),i}}function ac(e,t){let o=useMemo(()=>nu.clone(e,{id:t}),[t,e]),r=useMemo(()=>createSelector([n=>n.records.entities[e][t],n=>n.records.requests[e][o]],(n,i)=>{let a=i||{status:n==null?"UNINITIALIZED":"SUCCESS"};return Sf(n,a)}),[o,e,t]);return G(r)}function aa(e){return t=>{let o=re(),r=useMemo(()=>nu.read(e,{id:t,include:true}),[t]),n=useMemo(()=>createSelector([a=>a.records.entities[e][t],a=>a.records.requests[e][r]],(a,l)=>{let s=l||{status:a==null?"UNINITIALIZED":"SUCCESS"};return Sf(a,s)}),[r,e,t]),i=G(n);return useEffect(()=>(i.isUninitialized&&t!==null&&o(Ql(e,{id:t,include:true})),()=>{}),[r,i.isUninitialized,o,t]),i}}function Sf(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 qL,YL,re,G,ms,tc,oc,fs,rc,oa,nc,fo,Ho,tt,ra,na,yf,vf,ot,lx,au,Ao,kn,gs,su,cx,px,ux,Te=D(()=>{u();Mr();pf();Jl();Pt();Vo();Yl();ta();qL={},{localeDefault:YL}=qe(),re=useDispatch,G=useSelector,ms=ia("report"),tc=ia("dimension"),oc=ia("variant"),fs=ia("section"),rc=ia("block"),oa=ia("formatter"),nc=ia("datasource"),fo=aa("report"),Ho=aa("section"),tt=aa("block"),ra=aa("dimension"),na=aa("variant"),yf=aa("formatter"),vf=aa("datasource");ot=(e,t=void 0,o=void 0)=>{if(!e)return {};let r=tt(e).data,n=G(p=>p.variables.variables,Go),i=G(p=>p.variables.attributes,Go),a=t||n,l=o||i;return useMemo(()=>r?r.inputs.reduce((p,c)=>({...p,...a[c]}),l):{},[r,l,a])},lx=e=>{let t=tt(e).data,o=G(i=>i.variables.variables,Go),r=G(i=>i.variables.attributes,Go);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]):{}},au=e=>G(t=>t.variables.status[e],Go),Ao=(e=YL)=>useContext($e).formatterFunctions[e],kn=()=>useContext($e).datasourceFunctions,gs=()=>useContext($e).profilePrefix,su=(e=void 0,t=void 0)=>{let o=G(i=>i.status.localeDefault),r=G(i=>i.status.query,Go);return {variables:ot(e),locale:t||o,query:r}},cx=(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,px=e=>{if(!e)return 0;let t=G(r=>r.records.entities.formatter,ir),o=G(r=>r.records.entities.block,ir);return useMemo(()=>cx(e,o),[e,t,o])},ux=()=>{let e=G(o=>o.records.entities.formatter,ir),t=G(o=>o.records.entities.block,ir);return useMemo(()=>Object.values(e).reduce((o,r)=>(o[r.name]=cx(r.name,t),o),{}),[e,t])};});var dx,xf=D(()=>{u();jm();Jl();Yl();ds();dx=()=>configureStore({reducer:{[Tn.name]:Tn.reducer,[eu.name]:eu.reducer,[tu.name]:tu.reducer},middleware(e){return e({thunk:{extraArgument:jl("/api/cms/")}})}}),createWrapper(dx);});function Xt(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 gx=D(()=>{u();});var hx=D(()=>{u();xf();});var le=D(()=>{u();Mr();Te();xf();gx();hx();});function yx(e){let {pathSegment:t,profilePrefix:o,siteProps:r}=e,n=oa();G(c=>c.status.isCMS);let a=nc(),s={...rr()},p=useMemo(()=>({profilePrefix:o,pathSegment:t,siteProps:r,formatterFunctions:bx.reduce((c,d)=>({...c,[d]:n.data?ei(n.data,d):{}}),{}),datasourceFunctions:(a?.data||[]).sort((c,d)=>c.content.order>d.content.order?1:-1).map(c=>({...c,content:{...c.content,pattern:et(c.content.pattern,{},{variables:s})}}))}),[n,t,o,r,a]);return jsx($e.Provider,{value:p,children:e.children})}function ys(){let e=useContext($e);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var bx,oM,$e,Pt=D(()=>{u();Vo();ti();le();Ki();Xr();(({locales:bx}=qe())),oM={pathSegment:"path",formatterFunctions:bx.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",siteProps:{}},$e=createContext(oM);});function Io(){let{pathSegment:e}=ys(),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 p={...t.query};s==null||s===""?delete p[l]:p[l]=[].concat(s).join("!"),t.push({pathname:t.pathname,query:p},void 0,{shallow:true});},matches(...l){return t.asPath===a(...l)},push(l,s,p){let c=a(l);t.push(c,s,p);},replace(l,s,p){let c=a(l);t.replace(c,s,p);}}},[t.asPath])}var lu=D(()=>{u();Pt();});function Tf(){let e=re(),{router:t}=Io(),{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(ee.setCurrentLocale(l));},[]),i}var vx=D(()=>{u();le();lu();});function Ss(e){return createSelector([t=>t.records.entities[e]],t=>Object.values(t))}var lM,Sx,ci,cM,xx,xs,pM,uM,Ts,Br=D(()=>{u();Ki();Xr();lM=e=>e.records.entities.report,Sx=e=>e.records.entities.section,ci=e=>e.records.entities.block,cM=e=>e.records.entities.datasource;Ss("report"),Ss("dimension"),Ss("variant"),Ss("section"),xx=Ss("block"),xs=Ss("formatter"),createSelector([lM],e=>Object.values(e)[0]),pM=rr(),uM=[],Ts=createSelector([cM],e=>e?Object.values(e).sort((t,o)=>t.content.order>o.content.order?1:-1).map(t=>{let o={...pM};return {...t,content:{...t.content,pattern:et(t.content.pattern,{},{variables:o})}}}):uM);});function mM(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),p=t[a]?t[a]:false,c=dM(p,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,f;for(let g=e.indexOf(i)-1;g>=0;g--){let h=e[g],y=parseInt(h.settings.order);if(y===m){f=r[h.id];break}else if(y<m){f=r[h.id];break}}f?f.children.push(d):o.push(d);}}return o}function ks(e=1,t=6,o=[]){let r=G(xx),n=G(m=>m.variables.variables),i=G(m=>m.variables.status),a=fs(),l=r.filter(m=>m.type===w.TITLE&&o.includes(m.id)),s=Object.fromEntries(l.map(m=>[m.id,m])),p=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(Eo).forEach(f=>{let g=f.blocks.reduce((h,y)=>s[y]&&s[y].type===w.TITLE?h.concat([s[y]]):h,[]);m=m.concat(g.sort((h,y)=>Eo(h,y,"blockrow")));}),Object.keys(i).length?m.filter(f=>{let g=parseInt(f.settings.order||"1",10);return g>=e&&g<=t&&c[f.id]?.allowed&&!c[f.id]?.hiddenByCascade}):[]}},[o,a,s,c]);return useMemo(()=>d&&d?.length>0?mM(d,p):[],[d,p])}var dM,Cf=D(()=>{u();le();Br();wr();be();dM=(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 sa=D(()=>{u();lu();vx();Cf();});function gM(e={required:false}){let{update:t,data:o,status:r}=useSession(e);return {update:t,user:o?.user,status:r,isLoading:r==="loading"}}var ft,ar=D(()=>{u();ft=gM;});function go(e){let t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"," ":""},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 pc=D(()=>{u();});function Ff(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var Ux=D(()=>{u();});function LB(e){return e?OB(Ff(go(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var Po,ui=D(()=>{u();pc();Ux();Po=LB;});var Xx=D(()=>{});function Hf({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:i=0}){let a=useMantineTheme(),[l,s]=useState(false);if(i===Gf)return null;let p=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),c=Uf(r),d=r,m=JSON.stringify(d),f=100,g=1e3,h=!!(m&&m.length>f),y=10,b={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(c==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:b,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,c:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:i+1<Gf?Object.keys(r).sort((S,E)=>{let v=Uf(r[S]),C=Uf(r[E]);return v!==C?Qx.indexOf(v)-Qx.indexOf(C):S.localeCompare(E)}).map(S=>jsx(Hf,{root:false,label:S,value:r[S],level:i+1},S)):p})]})});if(c==="array"){let S=r.length>y,E=S?r.slice(0,y):r,v=S?r.length-y:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:b,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,p:0,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[i+1<Gf?E.map((C,k)=>jsx(Hf,{root:false,label:k,value:C,level:i+1,parentIsArray:true},k)):p,S&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",v," other elements]"]})]})]})})}return c==="string"?d=h?`"${d.substring(0,f)} ... "`:`"${d}"`:c==="error"?d=`Error: ${d.message}`:c==="undefined"?d=c:d.toString&&(d=d.toString()),jsxs(Group,{wrap:"nowrap",gap:0,justify:"space-between",children:[jsx(Tooltip,{label:"Copied!",opened:l,closeDelay:1e3,children:jsx(Text,{c:e?"dimmed":a.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap",cursor:"pointer"},onClick:()=>{let S=o?`{{${t}}}`:n?`[${t}]`:t;navigator.clipboard.writeText(S),s(true),setTimeout(()=>s(false),1e3);},fw:700,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Tooltip,{label:d,children:jsx(CodeHighlight,{className:"cr-variable",code:d,language:"jsx",withCopyButton:false,styles:S=>({codeHighlight:{textAlign:"right",overflow:"hidden",width:"fit-content",flex:"0 1 auto"},code:{padding:"5px 0 5px 5px",fontSize:S.fontSizes.xs},pre:{marginLeft:"5px"}})})}),h&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,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:m.substring(0,g)})})]})]})}var Uf,Qx,Gf,ca,bu=D(()=>{u();Xx();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},Qx=["object","array","string","number"],Gf=5;ca=Hf;});var yu,jf=D(()=>{u();yu=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function lD({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let i=tt(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?()=>true:p=>!yu(l)(p));return jsx(Stack,{gap:0,children:s.length?s.map(p=>jsx(ca,{dimmed:e.includes(p),label:p,value:o[p]},p)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${a}`})})})}var _r,Os=D(()=>{u();bu();le();jf();_r=lD;});var En,wT,RT,OT,AT,IT,PT,Lo,oo,Fs,ro=D(()=>{u();be();En={display:{label:"Size",defaultValue:"block",options:[{label:"Full Width",value:"block"},{label:"Inline",value:"inline"}]}},wT={useProxy:{label:"Use proxy (avoid CORS)",defaultValue:"false",options:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}},RT={[w.IMAGE]:{...En},[w.PARAGRAPH]:{...En},[w.SUBTITLE]:{...En},[w.SELECTOR]:{...En},[w.STAT]:{...En},[w.VIZ]:{...En},[w.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"}]},...En},[w.GENERATOR]:{...wT},[w.SECTION_FLAG]:{...wT},[w.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"}]},titlePosition:{label:"Title position",defaultValue:"left",options:[{label:"Left",value:"left"},{label:"Top",value:"top"},{label:"Right",value:"right"},{label:"Bottom",value:"bottom"}]}},[w.MULTIHIERARCHY_SELECTOR]:{...En}},OT=e=>e&&RT[e]?RT[e]:En,AT={left:"flex-start",right:"flex-end",justify:"stretch"},IT={justify:"space-between"},PT={justify:"space-between"},Lo=e=>AT[e]?AT[e]:e,oo=e=>IT[e]?IT[e]:e,Fs=e=>PT[e]?PT[e]:e;});var A_,LT,MT=D(()=>{u();A_=({value:e,handleChange:t,justify:o="right"})=>jsxs(Group,{justify: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"}]})]}),LT=A_;});function U_({id:e,display:t="button",handleChange:o}){let r=re(),n=tt(e).data,[i,a]=useState(false),l=$_(n),s=g=>{typeof g=="boolean"?p("width",{...l,...g?{stretch:true}:DT}):p("width",{...l,value:g});},p=(g,h)=>{n&&(o?o(g,h):r(ee.updateEntity("block",{id:e,settings:{...n.settings,[g]:h}})));};if(!n)return null;let c=OT(n.type),d=BT[l.unit],m=g=>{let{defaultValue:h}=BT[g];p("width",{...l,value:h,unit:g});},f=jsxs(Stack,{gap:"xs",children:[jsx(LT,{value:n.settings.align||"left",handleChange:p,justify:"space-between"}),Object.entries(c).map(([g,{label:h,defaultValue:y,options:b}])=>jsxs(Group,{gap:"xs",justify:"space-between",wrap:"nowrap",style:{width:"100%"},children:[h&&jsx(Text,{size:"xs",children:h}),jsx(SegmentedControl,{defaultValue:String(n.settings[g]||y),onChange:S=>p(g,S),data:b,size:"xs"})]},g)),![w.GENERATOR,w.SECTION_FLAG].includes(n.type)&&jsxs(Group,{gap:"xs",children:[jsx(Text,{size:"xs",children:"Width"}),jsxs(Group,{gap:"xs",children:[!l.stretch&&jsxs("div",{children:[jsx(V_,{currUnit:l.unit,changeUnit:m}),jsx(NumberInput,{defaultValue:parseInt(d.defaultValue,10),disabled:l.stretch,onChange:g=>s(g),size:"xs",value:Number.isNaN(l.value)?void 0:parseInt(l.value,10),...d})]}),jsx(Checkbox,{size:"xs",label:"Stretch",checked:l.stretch,onChange:g=>s(g.currentTarget.checked)})]})]},"width")]});return t==="button"?jsxs(Popover,{opened:i,onClose:()=>a(false),position:"bottom-end",withinPortal:true,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{onClick:()=>a(g=>!g),size:"md",variant:"transparent",children:jsx(IconPalette,{size:15})})}),jsx(Popover.Dropdown,{children:f})]}):jsx(Paper,{p:"md",children:f})}var F_,Sc,BT,DT,V_,$_,Cu,xc=D(()=>{u();ro();le();MT();be();F_=["px","%"],Sc={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,")},BT={px:{defaultValue:400,min:25,step:5,formatter:Sc.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:Sc["%"]}},DT={stretch:false,unit:"px",value:"400"},V_=({currUnit:e,changeUnit:t})=>jsxs(Group,{justify:"space-between",children:[jsx(Text,{size:"xs",fw:"bold",children:"Unit"}),jsx(Group,{gap:3,children:F_.map(o=>jsx(Anchor,{component:"button",size:"xs",td:e===o?"underline":"none",onClick:()=>t(o),children:o},o))})]}),$_=e=>{let t=e?.settings?.width||{};return t&&["stretch","value","unit"].every(o=>Object.prototype.hasOwnProperty.call(t,o))?t:DT};Cu=U_;});var aN,$T,UT=D(()=>{u();aN=(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",p=e.levels||[],c=e.limit||void 0,d=e.placeholder||"",m=e.searchIndexKey||"",f=e.searchIndexSeparator||"",g,h;return e.defaultValue&&e.defaultValueType&&(g=e.defaultValue,h=e.defaultValueType),(!g||!h)&&(g=[],h=""),{allLabel:o,colorKey:r,data:n,defaultValue:g,defaultValueType:h,hideLabel:i,resetSectionVars:a,iconKey:l,id:t,label:s,levels:p,limit:c,placeholder:d,searchIndexKey:m,searchIndexSeparator:f}},$T=aN;});var sN,GT,lN,HT,jT=D(()=>{u();be();Wp();sN=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{id:t,label:t}:t):[],GT=(e,t)=>t===Tt.MULTI&&!Array.isArray(e)?[e]:e,lN=(e,t)=>{let o=e.type||Tt.SINGLE,r=e.component||"Selector",n=e.hideLabel||"false",i=e.resetSectionVars||"false",a=e.name||"Unlabeled Selector",l=sN(e.options||[]),s;if(e.defaultValue){let p=GT(e.defaultValue,o);Wi(o,p,l)&&(s=p);}if(!s){let p=l&&l[0]&&l[0].id||l[0]||"";s=GT(p,o);}return {id:t,name:a,type:o,options:l,component:r,defaultValue:s,hideLabel:n,resetSectionVars:i}},HT=lN;});var cN,cr,ng=D(()=>{u();be();UT();jT();cN={[w.SELECTOR]:HT,[w.MULTIHIERARCHY_SELECTOR]:$T},cr=cN;});var pN,uN,dN,mN,We,Zr=D(()=>{u();pN=e=>typeof e=="string"?e.replace(/ <\/p>/g,"</p>"):e,uN=e=>typeof e=="string"&&e==="<p><br></p>"?"":e,dN=e=>typeof e=="string"?e.replace(/^<p>(.*)<\/p>$/,"$1"):e,mN=e=>e&&dN(uN(pN(e))),We=mN;});function xe({id:e="",component:t="p",order:o=1,size:r="md",html:n,style:i={},append:a=jsx(Fragment,{}),isPreview:l=false,lineClamp:s="none"}){let p=hN(n),c=bN(n,l),d=i&&i.align?String(i.align):"left",m=Text,f={};return t==="h"?(m=Title,f={id:e,order:o}):f={component:t,size:r,lineClamp:s},jsxs(m,{align:d||p.align||"left",...f,children:[c,a]})}var hN,bN,ht=D(()=>{u();hN=(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?(KT(e,o),t):{}},bN=(e="",t=false)=>{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:p,target:c}=a,d=p.indexOf("http")===0,m=!!(c&&c==="_blank"),f=jsx(Anchor,{...a,href:a.href,target:"_blank",children:domToReact(l,o)});return d||m||t?f: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 KT(e,o)};});function ag({paragraph:e,tooltip:t,settings:o}){let r=We(t);return jsx(xe,{component:"p",html:e,style:o,append:t?jsx(Vt,{content:r,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{})})}var YT=D(()=>{u();Zr();wn();ht();});function Ye({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),p=e==="custom"?o:`/api/cms/read/icons/${e}/icon.svg?name=${o}`,c=/^.*\.svg*$/.test(p)||e==="tabler";return useEffect(()=>{c&&Qp.get(p,{responseType:"text"}).then(m=>m.data).then(s).catch(()=>{});},[e,c,p]),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:p,alt:"Title Icon"})})})}var Rn=D(()=>{u();});function lg({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:p,_iconPadding:c}){if(!t&&!o&&!e)return null;let d=n&&n.align?n.align:"left";return jsxs(Group,{gap:"md",justify:oo(d),children:[jsx(Ye,{blockType:"stat",iconType:i,iconVariant:a,iconRadius:s,iconSize:p,icon:l,iconPadding:c}),jsxs(Stack,{gap:0,children:[t&&jsx(xe,{component:"div",size:"md",html:t,style:n}),o&&jsx(xe,{component:"div",size:"xl",html:o,style:n}),e&&jsx(xe,{component:"div",size:"sm",html:e,style:n})]},"stat"),r&&jsx(Vt,{content:r})]})}var JT=D(()=>{u();wn();Rn();ht();ro();});function cg({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,{gap:"sm",justify:oo(n),children:[jsx(xe,{size:"sm",html:r}),t&&jsx(Vt,{content:t,style:{display:"inline-flex"}})]})}var ZT=D(()=>{u();wn();ht();ro();});function $t(e){let t=useContext(LN);return e?t[e]??t:t}var LN,Nr=D(()=>{u();LN=createContext({});});var DN,_N,mi,Cc=D(()=>{u();DN={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:{}},_N=createContext({metadata:[],loadingItems:false,setLoadingItems:()=>null,loadingMetadata:false,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:DN,setTranslations:()=>null,showSelectors:true}),mi=()=>useContext(_N);});function zN({translations:e}){let{loadingItems:t,setFilters:o,selectorStructure:r,filters:n,showSelectors:i}=mi(),a=g=>{let h=g===null||Number.isNaN(g)?void 0:parseInt(g,10);h!==n.profile?o({profile:h,variant:void 0}):h&&o({profile:void 0,variant:void 0});},l=g=>{let h=g===null?void 0:typeof g=="string"&&g.includes(",")?g:parseInt(g,10);h!==n.variant?o({...n,variant:h}):h&&o({...n,variant:void 0});},s=g=>g<1e3?g:format$1(e.count_format)(g).replace(/\.0+([a-zA-Z]*)$/,"$1"),p=r.length===2?r[1].id:n.profile,c=p?r.find(g=>g.id===p):void 0,d=c&&c.variants&&n.variant?c.variants.find(g=>g.id===n.variant):void 0,m=useMemo(()=>r.map(g=>({value:String(g.id||""),label:(e?.dimensionIcon?.[g.name]?`${e?.dimensionIcon?.[g.name]} `:"")+(e?.dimension[g.name]||g.name)+(!t&&(!c||g.id===c?.id)?` (${s(g.members_count)})`:"")})),[e,c,r]),f=useMemo(()=>c?.variants?.map(g=>({value:String(g.id||""),label:(e?.variantIcon?.[g.name]?`${e?.variantIcon?.[g.name]} `:"")+(e?.variant[g.name]||g.name)+(!t&&(!d||g.id===d?.id)?` (${s(g.members_count)})`:"")}))??[],[e,d,r]);return jsx(Fragment,{children:i&&jsxs(Fragment,{children:[jsx(Box,{className:"bespoke-explore-reports-select-container",mb:"md",sx:{display:"block","@media (min-width: 1000px)":{display:"none"}},children:jsxs(Group,{justify:"center",children:[jsx(Select,{className:"bespoke-explore-reports-select",data:m,value:String(c?.id||""),onChange:g=>a(g),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:f,value:String(d?.id||""),onChange:g=>l(g),label:e.select_variant||"Select Variant",placeholder:e.select_variant||"Select Variant",clearable:typeof d?.id<"u",style:{width:"450px"}})]})}),jsx(Box,{sx:{display:"none","@media (min-width: 1000px)":{display:"block"}},children:jsxs("div",{children:[jsx(Group,{justify:"center",className:"bespoke-explore-reports-selector",mb:"md",children:r.map(g=>jsxs(Button,{"data-selected":g.id===c?.id?"true":"false","data-report-name":g.name,variant:g.id===c?.id?"outline":"subtle",onClick:()=>a(g.id),rightSection:g.id&&g.id===c?.id?jsx(IconX,{size:"1rem"}):void 0,leftSection:e?.dimensionIcon?.[g.name]??void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-reports-name",dangerouslySetInnerHTML:{__html:e?.dimension[g.name]??g.name}}),!t&&(!c||g.id===c?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-reports-count",children:`(${s(g.members_count)})`})]},`p-${g.id}`))}),c&&c.variants&&c.variants.length>2&&jsx(Group,{justify:"center",style:{minHeight:"36px"},className:"bespoke-explore-variant-selector",mb:"md",children:c.variants.map(g=>jsxs(Button,{"data-selected":g.id===d?.id?"true":"false","data-variant-name":g.name,variant:g.id===d?.id?"outline":"subtle",onClick:()=>l(g.id),rightSection:g.id&&g.id===d?.id?jsx(IconX,{size:"1rem"}):void 0,leftSection:e?.variantIcon?.[g.name]?jsx(Text,{span:true,dangerouslySetInnerHTML:{__html:e.variantIcon[g.name]}}):void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-variant-name",dangerouslySetInnerHTML:{__html:e?.variant[g.name]??g.name}}),!t&&(!d||g.id===d?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-variant-count",children:`(${s(g.members_count)})`})]},`v-${g.id}`))})]})})]})})}var ak,sk=D(()=>{u();Cc();ak=zN;});function zr(e){let t=useContext($N);if(t==null)throw new Error("useBespokeStyles must be used within a BespokeStylesProvider");return e?t[e]:t}var $N,fa=D(()=>{u();$N=createContext({});});function ug({reportId:e,reportName:t,members:o,href:r,onClick:n}){let i=o.map(l=>jsx(Image,{src:l.image.src,height:160,loading:"lazy",alt:l.name},l.id)),a=o.map(l=>jsxs(Stack,{children:[jsx(Text,{fw: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:true,children:[jsx(Card.Section,{children:jsx(Group,{grow:true,gap:0,children:i})}),jsx(Group,{justify:"space-between",mt:"md",mb:"xs",children:a}),jsx("a",{href:r,onClick:n,children:jsx(Button,{variant:"light",color:"blue",fullWidth:true,mt:"md",radius:"md",children:`See ${t} Report`})})]})}function XN({profile:e,profilePrefix:t,onSelect:o,reportTile:r}){let n=useRouter(),i=n.locale,{localeDefault:a}=qe(),s=`${i===a?"":`/${i}`}${t}${e.path}`,p=e.members.map(f=>({original_id:f.metadata.id,name:f.name,id:f.id,dimension_id:f.metadata.dimension.id,dimension:f.metadata.dimension.name,variant_id:f.metadata.variant.id,variant:f.metadata.variant.name,image:{src:`/api/cms/member/image?member=${f.id}&size=thumb`,alt:f.name}})),c=f=>{n.push(`${f}`),o&&o();},d=f=>{f.preventDefault(),c(s);},m=YN(r);return jsx(Grid.Col,{span:{base:12,sm:6,md:4,lg:4,xl:3},children:jsx(m,{reportId:e.report.id,reportName:e.report.name,members:p,href:s,onClick:d})},e.id)}var YN,uk,dg=D(()=>{u();fa();Vo();YN=e=>{let{components:t}=zr(),o=ug;return t?.ReportTile&&(o=t?.ReportTile),e&&(o=e),o};uk=XN;});function o1({profilePrefix:e,onSelect:t=()=>{},reportTile:o}){let[r,n]=useState(500),i=useRef(null),{results:a}=mi(),l=i.current?.offsetTop||0,s=50;return useEffect(()=>{let{innerHeight:p}=window;n(p-l-s);},[l]),jsx(ScrollArea,{offsetScrollbars:true,type:"always",h:r,ref:i,children:jsx(Grid,{align:"stretch",children:a.map(p=>jsx(uk,{profile:p,profilePrefix:e,reportTile:o,onSelect:t},p.id))})})}var dk,mk=D(()=>{u();dg();Cc();dk=o1;});function i1(){let{activePage:e,setActivePage:t,pageSize:o,currentPageTotal:r}=mi();return jsx(Group,{justify:"center",children:jsx(Pagination,{value:e,onChange:i=>{t(i);},total:Math.ceil(r/o),size:"sm",py:"xs"})})}var gk,hk=D(()=>{u();Cc();gk=i1;});function h1({profilePrefix:e,initialReportId:t,initialVariantId:o,translations:r,onSelect:n,reportTile:i,initialQuery:a}){let l=useRef(),s=mi(),{query:p,setQuery:c,results:d,loadingItems:m,loadingMetadata:f,translations:g,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:true,pt:"1em",children:[jsx(TextInput,{placeholder:g.search,mb:"md",size:"xl",onChange:S=>c(S.target.value),readOnly:f||m,leftSection:jsx(IconSearch,{size:24}),value:p,rightSectionWidth:100,rightSectionProps:{style:{justifyContent:"flex-end",padding:"0 15px 0 0"}},rightSection:jsxs(Group,{align:"center",children:[(f||m)&&jsx(Loader,{size:28}),p&&p!==""&&jsx(ActionIcon,{variant:"transparent",onClick:b,children:jsx(IconTrash,{size:24})})]}),ref:l}),jsx(ak,{translations:g}),jsx(LoadingOverlay,{visible:f||m}),!m&&d.length===0&&jsx(Alert,{title:g.no_results,color:"blue",children:g.try_another}),jsx(dk,{profilePrefix:e,onSelect:n,reportTile:i}),jsx(gk,{})]})}var yk,vk=D(()=>{u();sk();mk();hk();Cc();yk=h1;});function C1({exploreProps:e={profilePrefix:"/",locale:k1},icon:t=jsx(IconSearch,{size:20}),actionIconProps:o={},modalProps:r={},tooltipProps:n={},tooltipText:i="Click to Explore",showIcon:a=true,showTooltip:l=false,children:s}){let[p,c]=useState(false),d={variant:"light",size:"md",radius:"md",...o},m={fullScreen:true,opened:p,onClose:()=>c(false)},f=jsx(ActionIcon,{...d,onClick:()=>c(true),children:t}),g=a?jsxs(Group,{gap:"sm",style:{cursor:"pointer"},children:[s,f]}):s;return l&&(g=jsx(Tooltip,{label:i,...n,children:g})),jsxs(Fragment,{children:[jsx(Modal,{...m,...r,children:p&&jsx(yk,{...e,onSelect:()=>c(false)})}),jsx("div",{onClick:()=>c(true),children:s?g:jsx(Fragment,{children:f})})]})}var k1,Tk,kk=D(()=>{u();vk();Vo();({localeDefault:k1}=qe());Tk=C1;});var P1,Ck,Ek=D(()=>{u();P1=forwardRef(({id:e,members:t=[],...o},r)=>{let n=t.map(i=>jsxs(Stack,{align:"center",children:[jsx(Text,{fw:500,children:i.name}),jsx(Badge,{color:"green",variant:"light",children:i.variant})]},i.id));return jsx("div",{ref:r,style:{width:"100%"},children:jsx(Group,{justify:"space-between",grow:true,children:n})},e)}),Ck=P1;});function U1({locale:e,profilePrefix:t="/report",autocompleteProps:o={},tooltipProps:r={},tooltipText:n="Click to search",searchReportParams:i={},callback:a,children:l}){let s=useRouter(),p=s.locale,{localeDefault:c}=qe(),d=p===c?"":`/${p}`,m=$1(null),[f,g]=useState(""),[h,y]=useDebouncedValue(f,500),[b,S]=useState([]),[E,v]=useState(false),[C,k]=useState(false),[R,L]=useState(false),[I,P]=useState(!l),O=()=>{P(false);},F=()=>{P(true),W();},A=useRef(),M=useClickOutside(O),B=o?.searchConfig?.searchLimit??10,W=()=>{v(true);let Q={query:h,format:"profiles",locale:e,limit:B,visible:true,includes:true,noImage:false,variant:[],dimension:[],report:[],all:false,...i};Qp.get("/api/cms/search/reports",{params:Q}).then(J=>{J&&J.data&&J.data.data&&J.data.data.results&&S(J.data.data.results.map(se=>{let ge=se.report?.name??se.name??`${se.id}`;return {id:se.id,reportName:ge,label:ge,href:`${d}${t}${se.path}`,reportPath:`${se.path}`,profilePrefix:t,value:se.id,members:(se.members||[]).map(he=>({original_id:String(he?.metadata?.id??he.id),name:he?.name??"",id:he.id??0,variant:he?.metadata?.variant?.name??"",image:{src:`/api/cms/member/image?member=${he.id}&size=thumb`,alt:he?.name??""}}))}})),v(false),A.current?.focus();}).catch(J=>{console.error(J),v(false);});};useEffect(()=>{R&&h.length>=(o.searchConfig?.queryThreshold??0)&&W();},[R,h,o.searchConfig?.queryThreshold]),useEffect(()=>{y(),I&&L(true);},[]),useEffect(()=>{y(),I&&L(true);},[I]);let N=Q=>{P(false),a?a(Q):(s.push(Q.href),k(true));},K=Q=>{g(Q);},{searchConfig:V,renderOption:j,data:H,...Y}=o??{},_=useMemo(()=>b.map(Q=>({value:Q.value,label:Q.reportName})),[b]),Z=useMemo(()=>Object.fromEntries(b.map(Q=>[Q.value,Q])),[b]),ae=useMemo(()=>j||m,[j,m]),te=useMemo(()=>({placeholder:"Search",size:"md",leftSection:jsx(IconSearch,{}),value:f,onChange:K,disabled:(E||C)&&!R,limit:B,maxDropdownHeight:250,filter:Q=>Q.options,rightSection:jsx(Group,{gap:0,justify:"right",children:E?jsx(Loader,{size:20}):jsx(Fragment,{})}),renderOption:Q=>{let J=Q.option,se=Z[J.value];return se?jsx(ae,{...se}):J.label},onOptionSubmit:Q=>{let J=Z[Q];J&&N(J);},comboboxProps:{withinPortal:false},...Y,data:_}),[f,E,C,R,B,_,Z,j,N,Y]),U=jsx(Autocomplete,{ref:A,...te});return l?jsx(Tooltip,{label:n,disabled:I,...r,children:jsxs(Group,{ref:M,gap:"sm",align:"center",style:{cursor:"pointer"},children:[!I&&jsx("div",{onClick:()=>P(true),children:l}),I&&jsx(Fragment,{children:U}),I?jsx(ActionIcon,{variant:"light",onClick:O,children:jsx(IconX,{size:20})}):jsx(ActionIcon,{variant:"light",onClick:F,children:jsx(IconSearch,{size:20})})]})}):U}var $1,Pk,Ok=D(()=>{u();fa();Ek();Vo();$1=e=>{let{components:t}=zr(),o=Ck;return t?.ReportItem&&(o=t?.ReportItem),e&&(o=e),o};Pk=U1;});function j1(){let e=zr("components");return useMemo(()=>{let{modal:t,inline:o}=e?.search??{};return {modal:t,inline:o}},[e?.search])}function Rc(e,t,o,r,n){let i=j1(),a=G(g=>g.variables.attributes.report_id),l=G(g=>g.variables.attributes.variant_id1),s=G(g=>g.variables.attributes.name1),p=useMemo(()=>({reportId:a,variantId:l,title:s}),[a,l,s]),c=useRouter(),d=gs(),m=$t();return useMemo(()=>{let g=e;return t==="modal"?g=jsx(Tk,{exploreProps:{locale:c.locale||Lk,profilePrefix:d,translations:m.explore,initialReportId:p.reportId,initialVariantId:p.variantId,initialQuery:p.title},tooltipText:m.explore?.tooltip,modalProps:i.modal,...n,children:e}):t==="inline"&&(g=jsx(Pk,{locale:c.locale||Lk,profilePrefix:d,callback:o,tooltipText:m.explore?.tooltip,...r,autocompleteProps:i.inline,children:e})),g},[t,e,c.locale,d,m,p,i,o,r,n])}var Lk,bg=D(()=>{u();Nr();le();Te();kk();Ok();Vo();fa();({localeDefault:Lk}=qe());});function rn(){let e=re();return useMemo(()=>async t=>await e(ee.readMember(t)),[e])}var ha=D(()=>{u();le();});var Bk=D(()=>{u();Pt();le();xn();ti();Br();ha();});function Fr(){return useContext(Y1)}var Y1,fi=D(()=>{u();Bk();Y1=createContext({active:false,variables:null,status:null,setComparisonVariables:null,comparisonLoaded:false,loading:false,error:false});});function vg({title:e,tooltip:t,slug:o,_iconType:r,_iconVariant:n,_icon:i,settings:a,_iconRadius:l,_iconSize:s,_iconPadding:p,asComparison:c=false}){let{print:d}=pr(),m=We(e)||"<span class='cr-block-placeholder'>Title</span>",f=a&&a.order?parseInt(a.order,10):1,g=f<=6?f:1,h=a&&a.search?a.search:"off",y=a&&a.align?a.align:"left",b=Fr(),S=G(L=>L.status.previews),v=(c?b.status.previews:S).map(L=>L.name).join(" | "),C=jsxs(Group,{children:[jsx(Ye,{blockType:"title",iconType:r,iconVariant:n,iconRadius:l,iconSize:s,icon:i,iconPadding:p}),jsx(xe,{id:o||void 0,component:"h",order:g,style:a,html:m})]}),k=Rc(C,h),R=a&&a.addComparisonName==="yes"&&b.active;return jsxs(Group,{gap:"sm",justify:oo(y),children:[jsxs("div",{children:[d?C:k,R&&jsx(Text,{className:"bespoke-comparison-title",children:v})]}),t&&jsx(Vt,{content:t})]})}var _k=D(()=>{u();Zr();Rn();ht();bg();fi();le();gi();wn();ro();});function Ou(e,t,o,r=false,n=false){let i=useRouter(),{query:a,locale:l}=i,s=re(),p=Fr(),c=G(P=>r&&p.variables?p?.variables?.attributes:P.variables.attributes,Go),d=G(ci,ir),m=G(xs,ec),f=G(Ts,ec),g=useMemo(()=>ei(m,l),[m,l]),h=ot(e,r&&p.active?p?.variables.variables:void 0,r&&p.active?p?.variables.attributes:void 0),y=G(P=>r?p.variables.variables:P.variables.variables),b=G(P=>r?p.variables.status:P.variables.status),S=rn(),{sectionVariables:E,resetSectionVariables:v}=mt(t),{addRunConsumersRunning:C,removeRunConsumersRunning:k}=ic(),R=r&&p.active?`${o}Compare`:o,L=r&&p.active?Object.fromEntries(Object.entries(a).filter(([P])=>P.match(ez)).map(([P,O])=>[P.replace("Compare",""),O])):Object.fromEntries(Object.entries(a).filter(([P])=>P.match(tz)).map(([P,O])=>[P.replace("Compare",""),O]));return useCallback(P=>{let O={locale:l,query:{...L,[o]:P},variables:h},F=new URLSearchParams(window.location.search);F.set(R,P),window.history.replaceState(null,null,`?${F.toString()}`),C([t]),ai(d,void 0,e,g,O,{variables:y,status:b},S,"report",f).then(A=>{p.active&&r?p.setComparisonVariables({attributes:c,variables:A.variables,status:A.status}):s(qi.setVariableChange({attributes:c,variables:A.variables,status:A.status})),n&&E&&v(),k([t]);});},[e,t,o,R,a,d,s,g,i,h.attributes,r,n,b,y])}var ez,tz,Sg=D(()=>{u();xn();le();ti();Br();ds();Te();ha();fi();ta();ez=/\w*Compare\b/,tz=/selector\d+id/;});function Cg(e){let{name:t,settings:o,options:r,id:n,defaultValue:i,section:a,component:l,asComparison:s,hideLabel:p,resetSectionVars:c}=e,{print:d}=pr(),m=pz(n),f=Ou(n,a,m,s,c==="true"),g=s?`${m}Compare`:m,[h,y]=useState(i),[b,S]=useState(zk(i,[])),E=JSON.stringify(r),v=o[Nt.DISABLED]||false,C=useMemo(()=>r?.map(O=>({value:O.id,label:O.label,imageUrl:O.imageUrl}))||[],[E]),k=d?r.filter(O=>b.includes(O.id)).map(O=>O.label).join(", "):"",R=d&&h&&r.find(O=>O.id===h)?.label||"",L=e.hideLabel==="true"?jsx(Fragment,{}):jsx(xe,{component:"span",html:t,size:"sm",style:o});if(useEffect(()=>{if(!v){let F=new URLSearchParams(window.location.search).get(g)||i;F&&(e.type===Tt.SINGLE?y(F):S(zk(F,i)));}},[window.location.search,i]),C.length<=1)return jsx(Fragment,{});let I=O=>{S(O),f(O.join(","));},P=O=>{y(O),f(O);};return jsx(Fragment,{children:d?jsxs(Box,{style:{display:"flex",alignItems:"center"},children:[L,jsx(Button,{ml:"sm",radius:"xl",variant:"outline",children:e.type===Tt.SINGLE?R:k})]}):jsx(Box,{children:{[Tt.SINGLE]:l===Hp.SEGMENTED_CONTROL?jsxs("div",{children:[jsx(Text,{size:"sm",fw:500,display:p==="true"?"none":"block",children:L}),jsx(SegmentedControl,{data:C,disabled:v,value:C.map(O=>O.value).includes(h)?h:"",onChange:P,fullWidth:true})]}):jsx(Select,{label:L,data:C,disabled:v,value:h,renderOption:O=>jsx(uz,{...O}),onChange:P,styles:{label:{display:p==="true"?"none":"block"}}}),[Tt.MULTI]:jsx(MultiSelect,{label:L,data:C,value:b,onChange:I,disabled:v,styles:{label:{display:p==="true"?"none":"block"}}})}[e.type]})})}var pz,zk,uz,Vk=D(()=>{u();ht();be();Sg();gi();pz=e=>`selector${e}id`,zk=(e,t)=>e&&typeof e=="string"?e.split(","):t,uz=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{wrap:"nowrap",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 Lu(){return jsx("div",{children:"Generator"})}var $k=D(()=>{u();});function Eg(e){let{alt:t,src:o,desc:r,title:n,settings:i,...a}=e,l=We(t),s=We(o),p=We(r),c=jsx("img",{src:s,alt:l,style:a}),d=i&&i.align?String(i.align):"left";return (p&&p.length||n&&n.length)&&(c=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Lo(d),gap:"sm",children:[n&&jsx(xe,{component:"p",html:n,style:i}),c,r&&jsx(xe,{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 Uk=D(()=>{u();Zr();ht();ro();});function ba(e,t,o){let r=o.initialDeps??[],n;return ()=>{var i,a,l,s;let p;o.key&&((i=o.debug)!=null&&i.call(o))&&(p=Date.now());let c=e();if(!(c.length!==r.length||c.some((f,g)=>r[g]!==f)))return n;r=c;let m;if(o.key&&((a=o.debug)!=null&&a.call(o))&&(m=Date.now()),n=t(...c),o.key&&((l=o.debug)!=null&&l.call(o))){let f=Math.round((Date.now()-p)*100)/100,g=Math.round((Date.now()-m)*100)/100,h=g/16,y=(b,S)=>{for(b=String(b);b.length<S;)b=" "+b;return b};console.info(`%c\u23F1 ${y(g,5)} /${y(f,5)} ms`,`
|
|
34
|
+
`)}));}let I=await Promise.all(L).catch(P=>P.message);if(typeof I=="string"&&I)return {outputVariables:{},renderVariables:{},status:{error:I}};p=I.length===1?I[0].data:I.map(P=>P.data),m=I.reduce((P,O)=>P+JSON.stringify(O.data).length/1024,0),d=Math.max(...I.map(P=>P.requestDuration)),g=I.map(P=>P.apiDataSource?`${P.apiDataSource.name} (${P.apiDataSource.id})`:null),h=I.map(P=>P.finalUrl);}if(e.type===w.SELECTOR){let{config:R,log:L,error:I}=Kp(e.id,e.contentByLocale[i].content.logic,t,o,true);return {outputVariables:RS(e.id,l,R),renderVariables:R,status:{log:L,error:I,allowed:s}}}if(e.type===w.MULTIHIERARCHY_SELECTOR){let{config:R,log:L,error:I}=qp(e.id,e.contentByLocale[i].content.logic,t,o,true);return {outputVariables:IS(e.id,l,R),renderVariables:R,status:{log:L,error:I,allowed:s}}}if(e.type===w.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:s}};if(e.type===w.RELATED){let R=e.contentByLocale?.logic?.content?.simple?.compare||"variant",L=e.contentByLocale?.logic?.content?.simple?.limit||4,I=Object.keys(a).filter(K=>K.startsWith("report_id")).map(K=>a[K]),P=Object.keys(a).filter(K=>K.startsWith("dimension_id")).map(K=>a[K]),O=Object.keys(a).filter(K=>K.startsWith("variant_id")).map(K=>a[K]),F=Object.keys(a).filter(K=>K.startsWith("id")).map(K=>a[K]);if(!F.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:false}};let A=await Promise.all(F.map((K,V)=>r({mode:"ids",locale:i,ids:[K],output:"lite",variant:[O[V]]}))).then(K=>K.flatMap(V=>{let j=[];return Jp(V)?V.ok&&(j=V.data.results):j=V.results,j&&Array.isArray(j)?j:[]})).catch(K=>(console.error("Error getting related members",K),[]));if(P.length>1){let K=Object.keys(a).filter(te=>te.startsWith("variant_slug")).map(te=>a[te]),V=A.map((te,U)=>{let z={mode:"related",locale:i,related:L??4,current_ids:[te.content_id],output:"full",variant_ids:[te.variant_id]};return U===0&&(z.include_ids=[te.content_id]),z}),j=await Promise.all(V.map(te=>r(te))).then(te=>te.flatMap(U=>{let z=[];return Jp(U)?U.ok&&(z=U.data.results):z=U.results,z&&Array.isArray(z)?z:[]})).catch(te=>(console.error("Error getting related members",te),[])),H=j.reduce((te,U)=>{let z=U.variant_slug;return te[z]||(te[z]=[]),te[z].push(U),te},{}),Y=[],_=Object.keys(H),Z=[{combination:[],index:0}];for(;Z.length>0;){let te=Z.pop();if(!te)continue;let{combination:U,index:z}=te;if(z===_.length){Y.push(U);continue}let Q=_[z],J=H[Q];for(let se of J)Z.push({combination:[...U,se],index:z+1});}return {outputVariables:{related_reports:Y.map(te=>{let U=te.sort((z,Q)=>K.indexOf(z.variant_slug)-K.indexOf(Q.variant_slug));return {entities:U,link:"/"+U.map(z=>`${z.variant_slug}/${z.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:j.length>0}}}let M=A.map(K=>K.content_id),B={mode:"related",locale:i,related:L??4,current_ids:M,output:"full"};R&&(R==="report"?B.report_ids=I:R==="dimension"?B.dimension_ids=P:B.variant_ids=O);let W=await r(B).then(K=>{let V=[];return Jp(K)?K.ok&&(V=K.data.results):V=K.results,V&&Array.isArray(V)?V:[]}).catch(K=>(console.error("Error getting related members",K),[]));return {outputVariables:{related_reports:W.map(K=>({entities:[K],link:`/${K.variant_slug}/${K.slug}`}))},renderVariables:{},status:{log:[],allowed:W.length>0}}}let{logic:y}=wo(e,i),b=et(y,t,o),S=Yr("resp",p||{},b,t,a,o),{vars:E,error:v,log:C}=S;if(typeof E!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:C,duration:d,responseSize:m,resp:p,api:f,allowed:s,apiFinalUrls:h,apiDataSources:g}};let k=Object.keys(E).reduce((R,L)=>({...R,[`${e.type}${e.id}${L}`]:E[L]}),{});return {renderVariables:E,outputVariables:[w.GENERATOR,w.SECTION_FLAG].includes(e.type)?E:k,status:{log:C,error:v,duration:d,responseSize:m,resp:p,api:f,allowed:s,apiFinalUrls:h,apiDataSources:g}}}function US(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(p=>t[p]&&t[p].section_id===t[o].section_id||!n).forEach(p=>nf(p,t,r,false,i,n,a));}})}var ii,oL,rL,$S,nL,iL,VS,nf,sL,ai,GS,af,xn=D(()=>{u();jm();ri();be();Zm();tf();AS();PS();us();Xr();$o();MS();of();Pr();ni();ss();Ki();zS();ii=uc(process.env.NEXT_PUBLIC_REPORTS_DEBUG),oL=process.env.REPORTS_ORIGIN||"",rL=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,$S=5;try{$S=parseInt(`${rL||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}FS(Qp,{retries:$S,retryDelay:FS.exponentialDelay,onRetry:(e,t,o)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",o.url),console.error(t.message);}});Qp.interceptors.request.use(e=>({...e,requestStart:Date.now()}));Qp.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));nL=(e,t,o)=>{let r=et(e,t,o);return r.startsWith("http")||(r=`${oL}${r.startsWith("/")?"":"/"}${r}`),r},{urlProxy:iL}=jl("/api/cms");VS=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;nf=(e,t,o=[],r=true,n=true,i=true,a=[])=>{if(a.includes(e))return [];a.push(e);let l=t[e];return l&&l.inputs.length&&r&&l.inputs.forEach(s=>{let p=`${s}-${e}`;o.includes(p)||o.push(p),l.inputs.forEach(c=>nf(c,t,o,r,false,i,a));}),l&&l.consumers.length&&n&&US(l,t,e,o,i,n,a),o},sL=(e,t,o,r)=>{let n=true;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=false;else {let i=tr(t),{error:a,output:l}=Yr("variables",o,e.settings.allowedLogic||"return false;",r,void 0,i);a||(n=!!l);}return n},ai=async(e,t,o,r,n,i={},a,l="section",s)=>{let p=l==="section",c=tr(n),d=c.variables,m={...i.variables??{}},f={...i.status??{}},g=new Set,h=[],y={};o?y={...y,[o]:e[o]}:t?y=(t??[]).reduce((M,{id:B})=>({...M,...LS(B,e)}),{}):y=Object.values(e).filter(M=>mo(M)).reduce((M,B)=>({...M,[B.id]:B}),{});let b=Object.values(y).filter(M=>mo(M));if(b.length>0){ii&&console.info("%crunConsumers: calculating section flags","color:purple",b.map(N=>N.id).join(", "));let M=Object.fromEntries(await Promise.all(b.map(async N=>[N.id,await Kl(N,r,{...c,variables:d,locale:d.locale},a,s).then(K=>{let{outputVariables:V,status:j}=K;if(j.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${N.id}, Section ${N.section_id}) failed with message: ${j.error}. `);f[N.id]={allowed:false,error:j.error},m[N.id]={};}return (N.consumers.length>0||[w.GENERATOR,w.SECTION_FLAG,w.RELATED].includes(N.type))&&j.allowed&&Object.keys(V).length>0?m[N.id]=V:m[N.id]={},l==="report"?(f[N.id]={allowed:j.allowed},[w.GENERATOR,w.SECTION_FLAG].includes(N.type)&&j.api&&(f[N.id].api=j.api)):f[N.id]=j,K})]))),W=Object.entries(M).filter(([,N])=>!N.outputVariables[Ro]).map(([N])=>Number(N));g=new Set(W.map(N=>e[N].section_id)),Object.values(y).filter(N=>g.has(N.section_id)).forEach(N=>{h.push(N.id),delete y[N.id];}),ii&&console.info("%crunConsumers: removing sections","color:purple",g.keys());}let S=g.size>0?Object.fromEntries(Object.entries(e).filter(([,M])=>g?.has(M.section_id)?(h.includes(M.id)||h.push(M.id),false):true)):e;if(h.length>0&&(S=Object.fromEntries(Object.entries(S).map(([M,B])=>{let W={...B,inputs:B.inputs.filter(N=>!h.includes(N)),consumers:B.consumers.filter(N=>!h.includes(N))};return [M,W]}))),!o&&!t)return {variables:{...i.variables??{},...m},status:{...i.status??{},...f}};l==="report"&&h.length>0&&h.forEach(M=>{delete m[M],delete f[M],delete e[M];}),ii&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(y));let E=Object.keys(y).reduce((M,B)=>{let W=new Date,N=nf(Number(B),S,[],!o,true,p).map(j=>j.split("-")),V=(new Date().getTime()-W.getTime())/1e3;return ii&&console.info(`%cResolved dependencies for ${B} (${V.toFixed(2)}s)`,"color:blue"),[...M,...N]},[]),v=new Date,C=Object.keys(y).reduce((M,B)=>M.includes(B)?[...M]:[B,...M],QO(E)),R=(new Date().getTime()-v.getTime())/1e3;ii&&console.info(`%cResolved DAG (${R.toFixed(2)}s): `,"color:green",C);let L=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,I=parseInt(`${L||0}`,10);async function P(M,B){let W=new Map,N=[],K=async()=>N.length;for(let V of M){if(I!==0){let _=await K();for(;_>=I;)ii&&console.info("Too many pending promises, waiting...",_,N),await new Promise(Z=>setTimeout(Z,500)),_=await K();}let j=B[V],Y=Promise.all(j.inputs.filter(_=>M.includes(String(_))).map(_=>W.get(Number(_)))).then(async()=>{let _=j.inputs.reduce((J,se)=>({...J,...m[se]}),d),Z=j.inputs.find(J=>(j.settings?.ignoreCascade?j.settings?.ignoreCascade:[]).includes(J)||!f[J]?false:!f[J].allowed||f[J].hiddenByCascade);if(Z){f[V]={allowed:false,hiddenByCascade:f[Z].hiddenByCascade||Z},m[V]={},N.splice(N.indexOf(Number(V)),1);return}let ae=new Date,te;typeof window<"u"&&[w.SELECTOR,w.MULTIHIERARCHY_SELECTOR].includes(j.type)&&j.settings[Nt.DISABLED]?te=new Promise(J=>{J({outputVariables:m[V],status:f[V]});}):te=Kl(j,r,{...c,variables:_,locale:_.locale},a,s);let U=await te.then(({outputVariables:J,status:se})=>{if(se.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${V}, Section ${j.section_id}) failed with message: ${se.error}.`);f[V]={allowed:false,error:se.error},m[V]={};}(j.consumers.length>0||[w.GENERATOR,w.SECTION_FLAG,w.RELATED].includes(j.type))&&se.allowed&&Object.keys(J).length>0?m[V]=J:m[V]={},l==="report"?(f[V]={allowed:se.allowed},[w.GENERATOR,w.SECTION_FLAG].includes(j.type)&&se.api&&(f[V].api=se.api)):f[V]=se;}),Q=(new Date().getTime()-ae.getTime())/1e3;return ii&&console.info(`%cBlock ${j.id} resolved in ${Q.toFixed(3)}s`,Q>500?"color:red":"color:green"),f[V].duration=f[V].duration?f[V].duration:Q,N.splice(N.indexOf(Number(V)),1),U}).catch(_=>{throw N.splice(N.indexOf(Number(V)),1),_});N.push(Number(V)),W.set(Number(V),Y);}await Promise.all(Array.from(W.values()));}let O=new Date;await P(C,S);let A=(new Date().getTime()-O.getTime())/1e3;return ii&&console.info(`%cResolved Variables (${A.toFixed(2)}s), ${C.length} blocks`,"color:green"),{variables:{...i.variables??{},...m},status:{...i.status??{},...f}}},GS=e=>e<250?"green":e<1e3?"yellow":"red",af=e=>e<10?"green":e<100?"yellow":"red";});function lL(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 HS,jS=D(()=>{u();HS=lL;});var Or,Zp,ql=D(()=>{u();Or=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",Zp=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[Or];Zp.includes(Or)||Zp.push(Or);});var uL,eu,Uo,Yl=D(()=>{u();ql();uL={localeDefault:Or,locales:Zp,currentLocale:Or,preferredLocale:Or,showToolbar:false,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:true,settings:false,reportEditor:false},isCMS:false,isRunConsumersRunning:[]},eu=createSlice({name:"status",initialState:uL,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]:true};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:false};},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:e=>{e.addCase(HYDRATE,(t,o)=>{t.previews=o.payload.status.previews;});}}),Uo=eu.actions;});var fL,tu,qi,ds=D(()=>{u();fL={attributes:{},variables:{},status:{}},tu=createSlice({name:"variables",initialState:fL,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:e=>{e.addCase(HYDRATE,(t,o)=>{let r=o.payload.variables;t.attributes={...t.attributes,...r.attributes},t.status={...t.status,...r.status},t.variables={...t.variables,...r.variables};});}}),qi=tu.actions;});function Xl(e,t){return Object.fromEntries(Object.keys(e).map(o=>[o,{...e[o],...t[o]}]))}function ou(e,t){return e.map(n=>t[n]).sort((n,i)=>typeof n.ordering=="string"&&typeof i.ordering=="string"?Eo(n,i):typeof n.ordering=="number"&&typeof i.ordering=="number"?n.ordering-i.ordering:String(n.ordering).localeCompare(String(i.ordering))).map(n=>n.id)}function yL(e,t){let o=e.indexOf(t);o>-1&&e.splice(o,1);}var bL,Tn,Jl=D(()=>{u();wr();ti();bL={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},Tn=createSlice({name:"records",initialState:bL,reducers:{set:(e,t)=>{let o=t.payload;return {entities:Xl(e.entities,o.entities||{}),requests:Xl(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=Vp(o.type,r),i=Xl(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=ou(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=ou(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(p=>p.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=Vp(o.type,o.data),n=Xl(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=Vp(o.type,r),i,a,l;if(o.type==="block"&&!Array.isArray(o.data)){let p=e.entities.block[o.data.id].inputs,c=n.block[o.data.id].inputs;i=p.length!==c.length,i&&(l=p.length>c.length,a=l?p.filter(d=>!c.includes(d))[0]:c.filter(d=>!p.includes(d))[0]),Object.values(n.block).forEach(d=>{d.block_input&&delete n.block[d.id];});}let s=Xl(e.entities,n);if(e.entities=s,o.type==="dimension"){let p=o.data;e.entities.report[p.report_id].dimensions=ou(s.report[p.report_id].dimensions,s.dimension);}else if(o.type==="section"&&!Array.isArray(o.data)){let p=o.data;e.entities.report[p.report_id].sections=ou(s.report[p.report_id].sections,s.section);}else if(o.type==="block"&&!Array.isArray(o.data)){let p=o.data;i&&(l?e.entities.block[a].consumers=e.entities.block[a].consumers.filter(c=>c!==p.id):e.entities.block[a].consumers.push(p.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`;yL(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:e=>{e.addCase(HYDRATE,(t,o)=>{let r=o.payload.records,n=r.entities;t.entities=n,t.reports=Object.values(n.report).map(i=>i.id),t.requests={block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},t.tree=r.tree;});}});});function vL(e){return {ok:false,status:Yi.is(e)?e.code:500,error:e.message}}function Xi(e,t,o){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${WS(o)}`;return e[n]}let r=`${t}${WS(o)}`;return e[r]}function WS(e){return e[0].toUpperCase()+e.slice(1)}var Yi,ru=D(()=>{u();Yi=class extends Error{constructor(t,o){super(o),this.code=t;}toJSON(){return vL(this)}static is(t){return Object.prototype.hasOwnProperty.call(t,"code")&&typeof t.code=="number"}};});function Zl(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 Zi(e,t){return (o,r)=>{let i=r().records.requests[e][t],a=!i||i.status==="UNINITIALIZED"?"LOADING":"FETCHING";o(Lr.setRequest({key:t,type:e,status:a}));}}function Qi(e,t,o,r){return n=>{typeof window=="object"&¬ifications.show({autoClose:3e3,color:"red",id:t,message:r,title:"Error"}),n(Lr.setRequest({key:t,type:e,status:"FAILURE",error:{code:o,message:r}}));}}function si(e){return t=>{let o=lf(e,t);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"create",e)(t).then(l=>(l.ok===true?r(Lr.setCreateRequest({key:o,operation:"create",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function TL(e){return t=>{let o=lf(e,t[0]);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"createBulk",e)(t).then(l=>(l.ok===true?r(Lr.setCreateRequest({key:o,operation:"createBulk",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function KS(e,t,o){return o.replace(new RegExp(e,"g"),t)}function kL(e){return e.section_id!==void 0}function CL(e){return e.report_id!==void 0}function qS(e){return t=>{let{create:o}=t;return (r,n,i)=>si(e)(o)(r,n,i).then(async l=>{if(l.ok){let{data:s}=l,{id:p}=s,{update:c}=t,d=ox(e,{id:p});if(r(Zi(e,`${d}`)),e==="block"&&kL(o)){let m=produce(c,y=>{y.id=p;}),{contentByLocale:f}=m;f&&(m=produce(m,y=>{y.id=p,y.contentByLocale=Object.keys(f).reduce((b,S)=>{let E=f?f[S]:{};return b[S]={...E,id:p},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&&YS(e)([m,...h])(r,n,i).then(()=>li("section")({id:m.section_id,include:true})(r,n,i).then(y=>(y.ok&&r(Lr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))),Jr(e)(m)(r,n,i).then(y=>(y.ok&&r(Lr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}if(e==="section"&&CL(o)){let{id:m}=s,f=produce(c,y=>{y.id=m;}),{blocks:g}=f,h=g?.map(y=>({type:y.type,blockcol:y.blockcol,blockrow:y.blockrow,section_id:m,locales:Object.keys(y.contentByLocale).map(b=>b)}));return h&&g&&await TL("block")(h)(r,n,i).then(y=>{if(y.ok){let b=y.data,S=[],E=b.map((v,C)=>{let R={...v},L=R.id,I=g[C];I.contentByLocale&&(R.contentByLocale=Object.keys(I.contentByLocale).reduce((N,K)=>{let V=I.contentByLocale[K];return N[K]={...V,content:{...V.content},id:R.id},N},{}));let{settings:P}=I,{contentByLocale:O,id:F}=R;R.settings=P;let A={id:F,contentByLocale:O,settings:P};return I.inputs.map(N=>N.id).reduce((N,K)=>{let V=g.findIndex(j=>j.id===K);return [...N,V]},[]).map(N=>({...b[N],originalBlock:g[N]})).forEach(N=>{let{id:K,type:V,originalBlock:j}=N;if([w.SELECTOR,w.VIZ].includes(V)){if(A.contentByLocale?.logic?.content?.api){let H=A.contentByLocale?.logic.content.api;A.contentByLocale.logic.content.api=KS(`(selector${j.id}id)`,`selector${K}id`,H);}if(A.contentByLocale?.logic?.content?.logic){let H=A.contentByLocale.logic.content.logic;A.contentByLocale.logic.content.logic=KS(`(selector${j.id}id)`,`selector${K}id`,H);}}S.push({id:K,inputAction:{operation:"create",input:{input_id:K,block_id:L}}});}),A});return YS("block")([...E,...S])(r,n,i)}}),Jr(e)(f)(r,n,i).then(y=>(y.ok&&r(Lr.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}return Jr(e)({...c,id:s.id})(r,n,i)}})}}function li(e){return t=>{let o=ex(e,t);return (r,n,i)=>{r(Zi(e,o));let a=Xi(i,"read",e);if(typeof a!="function"){let l=`Failed to get valid RPC method for entity "${e}"`;return r(Qi(e,o,500,l)),Promise.reject(new Error(l))}return a(t).then(l=>(l.ok===true?r(Lr.setReadRequest({key:o,operation:"read",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l))}}}function Jr(e){return t=>{let o=cf(e,t);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"update",e)(t).then(l=>(l.ok===true?r(Lr.setUpdateRequest({key:o,operation:"update",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function YS(e){return t=>{let o=cf(e,t[0]);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"updateBulk",e)(t).then(l=>(l.ok===true?r(Lr.setUpdateRequest({key:o,operation:"updateBulk",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error)),l)))}}function Ji(e){return t=>{let o=tx(e,t);return (r,n,i)=>(r(Zi(e,o)),Xi(i,"delete",e)(t).then(l=>{l.ok===true?r(Lr.setDeleteRequest({key:o,operation:"delete",status:"SUCCESS",type:e,data:l.data})):r(Qi(e,o,l.status,l.error));}))}}function lf(e,t){if(e==="variant"){let o=t;return `create(variant, [${o.dimension_id}, ${o.name}])`}return `create(${e}, [${Object.keys(t)}])`}function ex(e,t={}){let o=t.id==null?null:`'${t.id}'`;return `read(${e}, ${o}, ${!!t.include})`}function cf(e,t){let{id:o,...r}=t;return `update(${e}, ${o}, [${Object.keys(r)}])`}function tx(e,t){return `delete(${e}, ${t})`}function ox(e,t){let o=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${o})`}var Lr,nu,XS,Ql,JS,QS,ZS,pf=D(()=>{u();ru();Jl();be();Lr=Tn.actions,nu={create:lf,read:ex,update:cf,delete:tx,clone:ox},XS=Zl({block:si("block"),dimension:si("dimension"),formatter:si("formatter"),report:si("report"),section:si("section"),variant:si("variant"),datasource:si("datasource")}),Ql=Zl({block:li("block"),dimension:li("dimension"),formatter:li("formatter"),report:li("report"),section:li("section"),variant:li("variant"),datasource:li("datasource")}),JS=Zl({block:Jr("block"),dimension:Jr("dimension"),formatter:Jr("formatter"),report:Jr("report"),section:Jr("section"),variant:Jr("variant"),datasource:Jr("datasource")}),QS=Zl({block:Ji("block"),dimension:Ji("dimension"),formatter:Ji("formatter"),report:Ji("report"),section:Ji("section"),variant:Ji("variant"),datasource:Ji("datasource")}),ZS=Zl({block:qS("block"),section:qS("section")});});var ee={};Mm(ee,{addBlockToState:()=>VL,addRunConsumersRunning:()=>mf,cloneEntity:()=>ZS,createEntity:()=>XS,deleteEntity:()=>QS,deleteQueryParam:()=>gf,readEntity:()=>Ql,readEnvSecrets:()=>HL,readMember:()=>nx,readMetadata:()=>LL,readPrivateBlocks:()=>$L,readUser:()=>_L,recalculateVariables:()=>qt,removeBlocksFromState:()=>FL,removeDataSourceLogic:()=>jL,removeRunConsumersRunning:()=>ff,reportSearch:()=>IL,resetSectionState:()=>df,revalidateReport:()=>GL,revalidateUrl:()=>UL,searchMember:()=>OL,searchRegenerate:()=>PL,searchRole:()=>BL,searchUser:()=>DL,setCurrentLocale:()=>wL,setPreferredLocale:()=>RL,setPreviews:()=>EL,setQueryParam:()=>ea,setSectionState:()=>uf,setStatus:()=>rx,updateEntity:()=>JS,updateMyData:()=>zL,updateUser:()=>NL,urlProxy:()=>ML,variantValidateSlug:()=>AL});function AL(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 IL(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 PL(){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 nx(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 OL(e){return async(t,o,r)=>{let n=await r.searchMember(e);if(n.ok===true)return n.data;throw new Error(n.error)}}async function ix(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(rx(l)),n.activeSection&&t(qt(e,{query:a}));}function gf(e,t){return async(o,r)=>ix(e,o,r,{query:{[t]:void 0}})}function ea(e,t,o){return async(r,n)=>ix(e,r,n,{query:{[t]:o}})}function qt(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:p,statusPayload:c}=nS(n.status,t),{sid:d,bid:m,previews:f,query:g}=p;Object.keys(c).length&&o(Uo.setStatus(c));let h={...HS(f),locale:i,...rr()},y={variables:h,query:g,locale:i};o(Uo.addRunConsumersRunning([d]));let b=n.records.entities.section[d],S=async E=>o(nx(E));try{let E=await ai(a,b&&[b],m,l,y,void 0,S,"section",s),{variables:v,status:C}=E;o(qi.setVariableChange({attributes:h,variables:v,status:C})),o(Uo.removeRunConsumersRunning([d]));}catch(E){console.error("Error in runConsumers client side: recalculateVariables",E);}}}function LL(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 ML(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 BL(){return async(e,t,o)=>{let r=await o.searchRole("");if("error"in r)throw new Error(r.error);return r.data}}function DL(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 _L(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 NL({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 zL(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 FL(e){let{removeBlocks:t}=Tn.actions;return async o=>{await o(t(e));}}function VL(e){let{addBlocks:t}=Tn.actions;return async o=>{await o(t(e));}}function $L(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 UL(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 GL(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 HL(){return async(e,t,o)=>{let r=await o.readEnvSecrets({});if("error"in r)throw new Error(r.error);return r.data}}function jL(){let{removeDataSourceLogic:e}=Tn.actions;return async t=>{await t(e());}}var rx,EL,uf,df,wL,RL,mf,ff,Mr=D(()=>{u();xn();jS();Ki();ti();Yl();ds();Jl();pf();({setStatus:rx,setPreviews:EL,setSectionState:uf,resetSectionState:df,setCurrentLocale:wL,setPreferredLocale:RL,addRunConsumersRunning:mf,removeRunConsumersRunning:ff}=Uo);});var Go,ec,ir,ax,ta=D(()=>{u();Go=(e={},t={})=>JSON.stringify(e)===JSON.stringify(t),ec=(e=[],t=[])=>JSON.stringify(e.map(o=>o.id).sort())===JSON.stringify(t.map(o=>o.id).sort()),ir=(e={},t={})=>JSON.stringify(Object.keys(e).sort())===JSON.stringify(Object.keys(t).sort()),ax=(e,t)=>typeof e.data!=typeof t.data?false:Array.isArray(e.data)&&Array.isArray(t.data)?ec(e.data,t.data)&&e.status===t.status:ir(e.data||{},t.data||{})||e.status===t.status;});function Yt(){let e=G(n=>n.status.activeEntity),t=re();return {activeEntity:e,selectEntity:n=>t(Uo.setActiveEntity(n)),unselectEntity:()=>t(Uo.setActiveEntity({type:null,id:null}))}}function mt(e){let t=re(),o=G(i=>i.status.sectionState[e]||qL,Go),r=useCallback(i=>{t(uf({[e]:i}));},[e]),n=useCallback(()=>{t(df(e));},[e]);return {sectionVariables:o,setSectionVariables:r,resetSectionVariables:n}}function ic(){let e=re(),t=G(n=>n.status.isRunConsumersRunning),o=useCallback(n=>{e(mf(n));},[]),r=useCallback(n=>{e(ff(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:o,removeRunConsumersRunning:r}}function zt(e){let t=re();return {opened:G(l=>l.status.sidebarStatus[e]),handlers:{open:()=>t(Uo.openSidebar(e)),close:()=>t(Uo.closeSidebar(e)),toggle:()=>t(Uo.toggleSidebar(e))}}}function hs(){return G(t=>t.status.currentLocale)}function bs(){return G(t=>t.status.preferredLocale)}function ia(e){return t=>{let o=re(),r=useMemo(()=>nu.read(e,{include:true}),[e]),n=useMemo(()=>createSelector([a=>a.records.entities[e],a=>a.records.requests[e][r]],(a,l)=>{let s=Object.values(a),p=l||{status:s==null?"UNINITIALIZED":"SUCCESS"},c=t?s.filter(d=>t.includes(d.id)):s;return Sf(c,p)}),[e,r,t]),i=G(n,ax);return useEffect(()=>{i.isUninitialized&&o(Ql(e,{id:t,include:true}));},[i.status]),i}}function ac(e,t){let o=useMemo(()=>nu.clone(e,{id:t}),[t,e]),r=useMemo(()=>createSelector([n=>n.records.entities[e][t],n=>n.records.requests[e][o]],(n,i)=>{let a=i||{status:n==null?"UNINITIALIZED":"SUCCESS"};return Sf(n,a)}),[o,e,t]);return G(r)}function aa(e){return t=>{let o=re(),r=useMemo(()=>nu.read(e,{id:t,include:true}),[t]),n=useMemo(()=>createSelector([a=>a.records.entities[e][t],a=>a.records.requests[e][r]],(a,l)=>{let s=l||{status:a==null?"UNINITIALIZED":"SUCCESS"};return Sf(a,s)}),[r,e,t]),i=G(n);return useEffect(()=>(i.isUninitialized&&t!==null&&o(Ql(e,{id:t,include:true})),()=>{}),[r,i.isUninitialized,o,t]),i}}function Sf(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 qL,YL,re,G,ms,tc,oc,fs,rc,oa,nc,fo,Ho,tt,ra,na,yf,vf,ot,lx,au,Ao,kn,gs,su,cx,px,ux,Te=D(()=>{u();Mr();pf();Jl();Pt();Vo();Yl();ta();qL={},{localeDefault:YL}=qe(),re=useDispatch,G=useSelector,ms=ia("report"),tc=ia("dimension"),oc=ia("variant"),fs=ia("section"),rc=ia("block"),oa=ia("formatter"),nc=ia("datasource"),fo=aa("report"),Ho=aa("section"),tt=aa("block"),ra=aa("dimension"),na=aa("variant"),yf=aa("formatter"),vf=aa("datasource");ot=(e,t=void 0,o=void 0)=>{if(!e)return {};let r=tt(e).data,n=G(p=>p.variables.variables,Go),i=G(p=>p.variables.attributes,Go),a=t||n,l=o||i;return useMemo(()=>r?r.inputs.reduce((p,c)=>({...p,...a[c]}),l):{},[r,l,a])},lx=e=>{let t=tt(e).data,o=G(i=>i.variables.variables,Go),r=G(i=>i.variables.attributes,Go);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]):{}},au=e=>G(t=>t.variables.status[e],Go),Ao=(e=YL)=>useContext($e).formatterFunctions[e],kn=()=>useContext($e).datasourceFunctions,gs=()=>useContext($e).profilePrefix,su=(e=void 0,t=void 0)=>{let o=G(i=>i.status.localeDefault),r=G(i=>i.status.query,Go);return {variables:ot(e),locale:t||o,query:r}},cx=(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,px=e=>{if(!e)return 0;let t=G(r=>r.records.entities.formatter,ir),o=G(r=>r.records.entities.block,ir);return useMemo(()=>cx(e,o),[e,t,o])},ux=()=>{let e=G(o=>o.records.entities.formatter,ir),t=G(o=>o.records.entities.block,ir);return useMemo(()=>Object.values(e).reduce((o,r)=>(o[r.name]=cx(r.name,t),o),{}),[e,t])};});var dx,xf=D(()=>{u();jm();Jl();Yl();ds();dx=()=>configureStore({reducer:{[Tn.name]:Tn.reducer,[eu.name]:eu.reducer,[tu.name]:tu.reducer},middleware(e){return e({thunk:{extraArgument:jl("/api/cms/")}})}}),createWrapper(dx);});function Xt(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 gx=D(()=>{u();});var hx=D(()=>{u();xf();});var le=D(()=>{u();Mr();Te();xf();gx();hx();});function yx(e){let {pathSegment:t,profilePrefix:o,siteProps:r}=e,n=oa();G(c=>c.status.isCMS);let a=nc(),s={...rr()},p=useMemo(()=>({profilePrefix:o,pathSegment:t,siteProps:r,formatterFunctions:bx.reduce((c,d)=>({...c,[d]:n.data?ei(n.data,d):{}}),{}),datasourceFunctions:(a?.data||[]).sort((c,d)=>c.content.order>d.content.order?1:-1).map(c=>({...c,content:{...c.content,pattern:et(c.content.pattern,{},{variables:s})}}))}),[n,t,o,r,a]);return jsx($e.Provider,{value:p,children:e.children})}function ys(){let e=useContext($e);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var bx,oM,$e,Pt=D(()=>{u();Vo();ti();le();Ki();Xr();(({locales:bx}=qe())),oM={pathSegment:"path",formatterFunctions:bx.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",siteProps:{}},$e=createContext(oM);});function Io(){let{pathSegment:e}=ys(),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 p={...t.query};s==null||s===""?delete p[l]:p[l]=[].concat(s).join("!"),t.push({pathname:t.pathname,query:p},void 0,{shallow:true});},matches(...l){return t.asPath===a(...l)},push(l,s,p){let c=a(l);t.push(c,s,p);},replace(l,s,p){let c=a(l);t.replace(c,s,p);}}},[t.asPath])}var lu=D(()=>{u();Pt();});function Tf(){let e=re(),{router:t}=Io(),{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(ee.setCurrentLocale(l));},[]),i}var vx=D(()=>{u();le();lu();});function Ss(e){return createSelector([t=>t.records.entities[e]],t=>Object.values(t))}var lM,Sx,ci,cM,xx,xs,pM,uM,Ts,Br=D(()=>{u();Ki();Xr();lM=e=>e.records.entities.report,Sx=e=>e.records.entities.section,ci=e=>e.records.entities.block,cM=e=>e.records.entities.datasource;Ss("report"),Ss("dimension"),Ss("variant"),Ss("section"),xx=Ss("block"),xs=Ss("formatter"),createSelector([lM],e=>Object.values(e)[0]),pM=rr(),uM=[],Ts=createSelector([cM],e=>e?Object.values(e).sort((t,o)=>t.content.order>o.content.order?1:-1).map(t=>{let o={...pM};return {...t,content:{...t.content,pattern:et(t.content.pattern,{},{variables:o})}}}):uM);});function mM(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),p=t[a]?t[a]:false,c=dM(p,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,f;for(let g=e.indexOf(i)-1;g>=0;g--){let h=e[g],y=parseInt(h.settings.order);if(y===m){f=r[h.id];break}else if(y<m){f=r[h.id];break}}f?f.children.push(d):o.push(d);}}return o}function ks(e=1,t=6,o=[]){let r=G(xx),n=G(m=>m.variables.variables),i=G(m=>m.variables.status),a=fs(),l=r.filter(m=>m.type===w.TITLE&&o.includes(m.id)),s=Object.fromEntries(l.map(m=>[m.id,m])),p=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(Eo).forEach(f=>{let g=f.blocks.reduce((h,y)=>s[y]&&s[y].type===w.TITLE?h.concat([s[y]]):h,[]);m=m.concat(g.sort((h,y)=>Eo(h,y,"blockrow")));}),Object.keys(i).length?m.filter(f=>{let g=parseInt(f.settings.order||"1",10);return g>=e&&g<=t&&c[f.id]?.allowed&&!c[f.id]?.hiddenByCascade}):[]}},[o,a,s,c]);return useMemo(()=>d&&d?.length>0?mM(d,p):[],[d,p])}var dM,Cf=D(()=>{u();le();Br();wr();be();dM=(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 sa=D(()=>{u();lu();vx();Cf();});function gM(e={required:false}){let{update:t,data:o,status:r}=useSession(e);return {update:t,user:o?.user,status:r,isLoading:r==="loading"}}var ft,ar=D(()=>{u();ft=gM;});function go(e){let t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"," ":""},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 pc=D(()=>{u();});function Ff(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var Ux=D(()=>{u();});function LB(e){return e?OB(Ff(go(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var Po,ui=D(()=>{u();pc();Ux();Po=LB;});var Xx=D(()=>{});function Hf({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:i=0}){let a=useMantineTheme(),[l,s]=useState(false);if(i===Gf)return null;let p=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),c=Uf(r),d=r,m=JSON.stringify(d),f=100,g=1e3,h=!!(m&&m.length>f),y=10,b={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(c==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:b,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,c:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:i+1<Gf?Object.keys(r).sort((S,E)=>{let v=Uf(r[S]),C=Uf(r[E]);return v!==C?Qx.indexOf(v)-Qx.indexOf(C):S.localeCompare(E)}).map(S=>jsx(Hf,{root:false,label:S,value:r[S],level:i+1},S)):p})]})});if(c==="array"){let S=r.length>y,E=S?r.slice(0,y):r,v=S?r.length-y:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:b,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,p:0,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[i+1<Gf?E.map((C,k)=>jsx(Hf,{root:false,label:k,value:C,level:i+1,parentIsArray:true},k)):p,S&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",v," other elements]"]})]})]})})}return c==="string"?d=h?`"${d.substring(0,f)} ... "`:`"${d}"`:c==="error"?d=`Error: ${d.message}`:c==="undefined"?d=c:d.toString&&(d=d.toString()),jsxs(Group,{wrap:"nowrap",gap:0,justify:"space-between",children:[jsx(Tooltip,{label:"Copied!",opened:l,closeDelay:1e3,children:jsx(Text,{c:e?"dimmed":a.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap",cursor:"pointer"},onClick:()=>{let S=o?`{{${t}}}`:n?`[${t}]`:t;navigator.clipboard.writeText(S),s(true),setTimeout(()=>s(false),1e3);},fw:700,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Tooltip,{label:d,children:jsx(CodeHighlight,{className:"cr-variable",code:d,language:"jsx",withCopyButton:false,styles:S=>({codeHighlight:{textAlign:"right",overflow:"hidden",width:"fit-content",flex:"0 1 auto"},code:{padding:"5px 0 5px 5px",fontSize:S.fontSizes.xs},pre:{marginLeft:"5px",marginTop:"0px",marginBottom:"0px"},showCodeButton:{display:"none"}})})}),h&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,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:m.substring(0,g)})})]})]})}var Uf,Qx,Gf,ca,bu=D(()=>{u();Xx();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},Qx=["object","array","string","number"],Gf=5;ca=Hf;});var yu,jf=D(()=>{u();yu=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function lD({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let i=tt(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?()=>true:p=>!yu(l)(p));return jsx(Stack,{gap:0,children:s.length?s.map(p=>jsx(ca,{dimmed:e.includes(p),label:p,value:o[p]},p)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${a}`})})})}var _r,Os=D(()=>{u();bu();le();jf();_r=lD;});var En,wT,RT,OT,AT,IT,PT,Lo,oo,Fs,ro=D(()=>{u();be();En={display:{label:"Size",defaultValue:"block",options:[{label:"Full Width",value:"block"},{label:"Inline",value:"inline"}]}},wT={useProxy:{label:"Use proxy (avoid CORS)",defaultValue:"false",options:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}},RT={[w.IMAGE]:{...En},[w.PARAGRAPH]:{...En},[w.SUBTITLE]:{...En},[w.SELECTOR]:{...En},[w.STAT]:{...En},[w.VIZ]:{...En},[w.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"}]},...En},[w.GENERATOR]:{...wT},[w.SECTION_FLAG]:{...wT},[w.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"}]},titlePosition:{label:"Title position",defaultValue:"left",options:[{label:"Left",value:"left"},{label:"Top",value:"top"},{label:"Right",value:"right"},{label:"Bottom",value:"bottom"}]}},[w.MULTIHIERARCHY_SELECTOR]:{...En}},OT=e=>e&&RT[e]?RT[e]:En,AT={left:"flex-start",right:"flex-end",justify:"stretch"},IT={justify:"space-between"},PT={justify:"space-between"},Lo=e=>AT[e]?AT[e]:e,oo=e=>IT[e]?IT[e]:e,Fs=e=>PT[e]?PT[e]:e;});var A_,LT,MT=D(()=>{u();A_=({value:e,handleChange:t,justify:o="right"})=>jsxs(Group,{justify: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"}]})]}),LT=A_;});function U_({id:e,display:t="button",handleChange:o}){let r=re(),n=tt(e).data,[i,a]=useState(false),l=$_(n),s=g=>{typeof g=="boolean"?p("width",{...l,...g?{stretch:true}:DT}):p("width",{...l,value:g});},p=(g,h)=>{n&&(o?o(g,h):r(ee.updateEntity("block",{id:e,settings:{...n.settings,[g]:h}})));};if(!n)return null;let c=OT(n.type),d=BT[l.unit],m=g=>{let{defaultValue:h}=BT[g];p("width",{...l,value:h,unit:g});},f=jsxs(Stack,{gap:"xs",children:[jsx(LT,{value:n.settings.align||"left",handleChange:p,justify:"space-between"}),Object.entries(c).map(([g,{label:h,defaultValue:y,options:b}])=>jsxs(Group,{gap:"xs",justify:"space-between",wrap:"nowrap",style:{width:"100%"},children:[h&&jsx(Text,{size:"xs",children:h}),jsx(SegmentedControl,{defaultValue:String(n.settings[g]||y),onChange:S=>p(g,S),data:b,size:"xs"})]},g)),![w.GENERATOR,w.SECTION_FLAG].includes(n.type)&&jsxs(Group,{gap:"xs",children:[jsx(Text,{size:"xs",children:"Width"}),jsxs(Group,{gap:"xs",children:[!l.stretch&&jsxs("div",{children:[jsx(V_,{currUnit:l.unit,changeUnit:m}),jsx(NumberInput,{defaultValue:parseInt(d.defaultValue,10),disabled:l.stretch,onChange:g=>s(g),size:"xs",value:Number.isNaN(l.value)?void 0:parseInt(l.value,10),...d})]}),jsx(Checkbox,{size:"xs",label:"Stretch",checked:l.stretch,onChange:g=>s(g.currentTarget.checked)})]})]},"width")]});return t==="button"?jsxs(Popover,{opened:i,onClose:()=>a(false),position:"bottom-end",withinPortal:true,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{onClick:()=>a(g=>!g),size:"md",variant:"transparent",children:jsx(IconPalette,{size:15})})}),jsx(Popover.Dropdown,{children:f})]}):jsx(Paper,{p:"md",children:f})}var F_,Sc,BT,DT,V_,$_,Cu,xc=D(()=>{u();ro();le();MT();be();F_=["px","%"],Sc={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,")},BT={px:{defaultValue:400,min:25,step:5,formatter:Sc.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:Sc["%"]}},DT={stretch:false,unit:"px",value:"400"},V_=({currUnit:e,changeUnit:t})=>jsxs(Group,{justify:"space-between",children:[jsx(Text,{size:"xs",fw:"bold",children:"Unit"}),jsx(Group,{gap:3,children:F_.map(o=>jsx(Anchor,{component:"button",size:"xs",td:e===o?"underline":"none",onClick:()=>t(o),children:o},o))})]}),$_=e=>{let t=e?.settings?.width||{};return t&&["stretch","value","unit"].every(o=>Object.prototype.hasOwnProperty.call(t,o))?t:DT};Cu=U_;});var aN,$T,UT=D(()=>{u();aN=(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",p=e.levels||[],c=e.limit||void 0,d=e.placeholder||"",m=e.searchIndexKey||"",f=e.searchIndexSeparator||"",g,h;return e.defaultValue&&e.defaultValueType&&(g=e.defaultValue,h=e.defaultValueType),(!g||!h)&&(g=[],h=""),{allLabel:o,colorKey:r,data:n,defaultValue:g,defaultValueType:h,hideLabel:i,resetSectionVars:a,iconKey:l,id:t,label:s,levels:p,limit:c,placeholder:d,searchIndexKey:m,searchIndexSeparator:f}},$T=aN;});var sN,GT,lN,HT,jT=D(()=>{u();be();Wp();sN=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{id:t,label:t}:t):[],GT=(e,t)=>t===Tt.MULTI&&!Array.isArray(e)?[e]:e,lN=(e,t)=>{let o=e.type||Tt.SINGLE,r=e.component||"Selector",n=e.hideLabel||"false",i=e.resetSectionVars||"false",a=e.name||"Unlabeled Selector",l=sN(e.options||[]),s;if(e.defaultValue){let p=GT(e.defaultValue,o);Wi(o,p,l)&&(s=p);}if(!s){let p=l&&l[0]&&l[0].id||l[0]||"";s=GT(p,o);}return {id:t,name:a,type:o,options:l,component:r,defaultValue:s,hideLabel:n,resetSectionVars:i}},HT=lN;});var cN,cr,ng=D(()=>{u();be();UT();jT();cN={[w.SELECTOR]:HT,[w.MULTIHIERARCHY_SELECTOR]:$T},cr=cN;});var pN,uN,dN,mN,We,Zr=D(()=>{u();pN=e=>typeof e=="string"?e.replace(/ <\/p>/g,"</p>"):e,uN=e=>typeof e=="string"&&e==="<p><br></p>"?"":e,dN=e=>typeof e=="string"?e.replace(/^<p>(.*)<\/p>$/,"$1"):e,mN=e=>e&&dN(uN(pN(e))),We=mN;});function xe({id:e="",component:t="p",order:o=1,size:r="md",html:n,style:i={},append:a=jsx(Fragment,{}),isPreview:l=false,lineClamp:s="none"}){let p=hN(n),c=bN(n,l),d=i&&i.align?String(i.align):"left",m=Text,f={};return t==="h"?(m=Title,f={id:e,order:o}):f={component:t,size:r,lineClamp:s},jsxs(m,{align:d||p.align||"left",...f,children:[c,a]})}var hN,bN,ht=D(()=>{u();hN=(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?(KT(e,o),t):{}},bN=(e="",t=false)=>{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:p,target:c}=a,d=p.indexOf("http")===0,m=!!(c&&c==="_blank"),f=jsx(Anchor,{...a,href:a.href,target:"_blank",children:domToReact(l,o)});return d||m||t?f: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 KT(e,o)};});function ag({paragraph:e,tooltip:t,settings:o}){let r=We(t);return jsx(xe,{component:"p",html:e,style:o,append:t?jsx(Vt,{content:r,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{})})}var YT=D(()=>{u();Zr();wn();ht();});function Ye({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),p=e==="custom"?o:`/api/cms/read/icons/${e}/icon.svg?name=${o}`,c=/^.*\.svg*$/.test(p)||e==="tabler";return useEffect(()=>{c&&Qp.get(p,{responseType:"text"}).then(m=>m.data).then(s).catch(()=>{});},[e,c,p]),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:p,alt:"Title Icon"})})})}var Rn=D(()=>{u();});function lg({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:p,_iconPadding:c}){if(!t&&!o&&!e)return null;let d=n&&n.align?n.align:"left";return jsxs(Group,{gap:"md",justify:oo(d),children:[jsx(Ye,{blockType:"stat",iconType:i,iconVariant:a,iconRadius:s,iconSize:p,icon:l,iconPadding:c}),jsxs(Stack,{gap:0,children:[t&&jsx(xe,{component:"div",size:"md",html:t,style:n}),o&&jsx(xe,{component:"div",size:"xl",html:o,style:n}),e&&jsx(xe,{component:"div",size:"sm",html:e,style:n})]},"stat"),r&&jsx(Vt,{content:r})]})}var JT=D(()=>{u();wn();Rn();ht();ro();});function cg({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,{gap:"sm",justify:oo(n),children:[jsx(xe,{size:"sm",html:r}),t&&jsx(Vt,{content:t,style:{display:"inline-flex"}})]})}var ZT=D(()=>{u();wn();ht();ro();});function $t(e){let t=useContext(LN);return e?t[e]??t:t}var LN,Nr=D(()=>{u();LN=createContext({});});var DN,_N,mi,Cc=D(()=>{u();DN={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:{}},_N=createContext({metadata:[],loadingItems:false,setLoadingItems:()=>null,loadingMetadata:false,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:DN,setTranslations:()=>null,showSelectors:true}),mi=()=>useContext(_N);});function zN({translations:e}){let{loadingItems:t,setFilters:o,selectorStructure:r,filters:n,showSelectors:i}=mi(),a=g=>{let h=g===null||Number.isNaN(g)?void 0:parseInt(g,10);h!==n.profile?o({profile:h,variant:void 0}):h&&o({profile:void 0,variant:void 0});},l=g=>{let h=g===null?void 0:typeof g=="string"&&g.includes(",")?g:parseInt(g,10);h!==n.variant?o({...n,variant:h}):h&&o({...n,variant:void 0});},s=g=>g<1e3?g:format$1(e.count_format)(g).replace(/\.0+([a-zA-Z]*)$/,"$1"),p=r.length===2?r[1].id:n.profile,c=p?r.find(g=>g.id===p):void 0,d=c&&c.variants&&n.variant?c.variants.find(g=>g.id===n.variant):void 0,m=useMemo(()=>r.map(g=>({value:String(g.id||""),label:(e?.dimensionIcon?.[g.name]?`${e?.dimensionIcon?.[g.name]} `:"")+(e?.dimension[g.name]||g.name)+(!t&&(!c||g.id===c?.id)?` (${s(g.members_count)})`:"")})),[e,c,r]),f=useMemo(()=>c?.variants?.map(g=>({value:String(g.id||""),label:(e?.variantIcon?.[g.name]?`${e?.variantIcon?.[g.name]} `:"")+(e?.variant[g.name]||g.name)+(!t&&(!d||g.id===d?.id)?` (${s(g.members_count)})`:"")}))??[],[e,d,r]);return jsx(Fragment,{children:i&&jsxs(Fragment,{children:[jsx(Box,{className:"bespoke-explore-reports-select-container",mb:"md",sx:{display:"block","@media (min-width: 1000px)":{display:"none"}},children:jsxs(Group,{justify:"center",children:[jsx(Select,{className:"bespoke-explore-reports-select",data:m,value:String(c?.id||""),onChange:g=>a(g),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:f,value:String(d?.id||""),onChange:g=>l(g),label:e.select_variant||"Select Variant",placeholder:e.select_variant||"Select Variant",clearable:typeof d?.id<"u",style:{width:"450px"}})]})}),jsx(Box,{sx:{display:"none","@media (min-width: 1000px)":{display:"block"}},children:jsxs("div",{children:[jsx(Group,{justify:"center",className:"bespoke-explore-reports-selector",mb:"md",children:r.map(g=>jsxs(Button,{"data-selected":g.id===c?.id?"true":"false","data-report-name":g.name,variant:g.id===c?.id?"outline":"subtle",onClick:()=>a(g.id),rightSection:g.id&&g.id===c?.id?jsx(IconX,{size:"1rem"}):void 0,leftSection:e?.dimensionIcon?.[g.name]??void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-reports-name",dangerouslySetInnerHTML:{__html:e?.dimension[g.name]??g.name}}),!t&&(!c||g.id===c?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-reports-count",children:`(${s(g.members_count)})`})]},`p-${g.id}`))}),c&&c.variants&&c.variants.length>2&&jsx(Group,{justify:"center",style:{minHeight:"36px"},className:"bespoke-explore-variant-selector",mb:"md",children:c.variants.map(g=>jsxs(Button,{"data-selected":g.id===d?.id?"true":"false","data-variant-name":g.name,variant:g.id===d?.id?"outline":"subtle",onClick:()=>l(g.id),rightSection:g.id&&g.id===d?.id?jsx(IconX,{size:"1rem"}):void 0,leftSection:e?.variantIcon?.[g.name]?jsx(Text,{span:true,dangerouslySetInnerHTML:{__html:e.variantIcon[g.name]}}):void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-variant-name",dangerouslySetInnerHTML:{__html:e?.variant[g.name]??g.name}}),!t&&(!d||g.id===d?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-variant-count",children:`(${s(g.members_count)})`})]},`v-${g.id}`))})]})})]})})}var ak,sk=D(()=>{u();Cc();ak=zN;});function zr(e){let t=useContext($N);if(t==null)throw new Error("useBespokeStyles must be used within a BespokeStylesProvider");return e?t[e]:t}var $N,fa=D(()=>{u();$N=createContext({});});function ug({reportId:e,reportName:t,members:o,href:r,onClick:n}){let i=o.map(l=>jsx(Image,{src:l.image.src,height:160,loading:"lazy",alt:l.name},l.id)),a=o.map(l=>jsxs(Stack,{children:[jsx(Text,{fw: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:true,children:[jsx(Card.Section,{children:jsx(Group,{grow:true,gap:0,children:i})}),jsx(Group,{justify:"space-between",mt:"md",mb:"xs",children:a}),jsx("a",{href:r,onClick:n,children:jsx(Button,{variant:"light",color:"blue",fullWidth:true,mt:"md",radius:"md",children:`See ${t} Report`})})]})}function XN({profile:e,profilePrefix:t,onSelect:o,reportTile:r}){let n=useRouter(),i=n.locale,{localeDefault:a}=qe(),s=`${i===a?"":`/${i}`}${t}${e.path}`,p=e.members.map(f=>({original_id:f.metadata.id,name:f.name,id:f.id,dimension_id:f.metadata.dimension.id,dimension:f.metadata.dimension.name,variant_id:f.metadata.variant.id,variant:f.metadata.variant.name,image:{src:`/api/cms/member/image?member=${f.id}&size=thumb`,alt:f.name}})),c=f=>{n.push(`${f}`),o&&o();},d=f=>{f.preventDefault(),c(s);},m=YN(r);return jsx(Grid.Col,{span:{base:12,sm:6,md:4,lg:4,xl:3},children:jsx(m,{reportId:e.report.id,reportName:e.report.name,members:p,href:s,onClick:d})},e.id)}var YN,uk,dg=D(()=>{u();fa();Vo();YN=e=>{let{components:t}=zr(),o=ug;return t?.ReportTile&&(o=t?.ReportTile),e&&(o=e),o};uk=XN;});function o1({profilePrefix:e,onSelect:t=()=>{},reportTile:o}){let[r,n]=useState(500),i=useRef(null),{results:a}=mi(),l=i.current?.offsetTop||0,s=50;return useEffect(()=>{let{innerHeight:p}=window;n(p-l-s);},[l]),jsx(ScrollArea,{offsetScrollbars:true,type:"always",h:r,ref:i,children:jsx(Grid,{align:"stretch",children:a.map(p=>jsx(uk,{profile:p,profilePrefix:e,reportTile:o,onSelect:t},p.id))})})}var dk,mk=D(()=>{u();dg();Cc();dk=o1;});function i1(){let{activePage:e,setActivePage:t,pageSize:o,currentPageTotal:r}=mi();return jsx(Group,{justify:"center",children:jsx(Pagination,{value:e,onChange:i=>{t(i);},total:Math.ceil(r/o),size:"sm",py:"xs"})})}var gk,hk=D(()=>{u();Cc();gk=i1;});function h1({profilePrefix:e,initialReportId:t,initialVariantId:o,translations:r,onSelect:n,reportTile:i,initialQuery:a}){let l=useRef(),s=mi(),{query:p,setQuery:c,results:d,loadingItems:m,loadingMetadata:f,translations:g,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:true,pt:"1em",children:[jsx(TextInput,{placeholder:g.search,mb:"md",size:"xl",onChange:S=>c(S.target.value),readOnly:f||m,leftSection:jsx(IconSearch,{size:24}),value:p,rightSectionWidth:100,rightSectionProps:{style:{justifyContent:"flex-end",padding:"0 15px 0 0"}},rightSection:jsxs(Group,{align:"center",children:[(f||m)&&jsx(Loader,{size:28}),p&&p!==""&&jsx(ActionIcon,{variant:"transparent",onClick:b,children:jsx(IconTrash,{size:24})})]}),ref:l}),jsx(ak,{translations:g}),jsx(LoadingOverlay,{visible:f||m}),!m&&d.length===0&&jsx(Alert,{title:g.no_results,color:"blue",children:g.try_another}),jsx(dk,{profilePrefix:e,onSelect:n,reportTile:i}),jsx(gk,{})]})}var yk,vk=D(()=>{u();sk();mk();hk();Cc();yk=h1;});function C1({exploreProps:e={profilePrefix:"/",locale:k1},icon:t=jsx(IconSearch,{size:20}),actionIconProps:o={},modalProps:r={},tooltipProps:n={},tooltipText:i="Click to Explore",showIcon:a=true,showTooltip:l=false,children:s}){let[p,c]=useState(false),d={variant:"light",size:"md",radius:"md",...o},m={fullScreen:true,opened:p,onClose:()=>c(false)},f=jsx(ActionIcon,{...d,onClick:()=>c(true),children:t}),g=a?jsxs(Group,{gap:"sm",style:{cursor:"pointer"},children:[s,f]}):s;return l&&(g=jsx(Tooltip,{label:i,...n,children:g})),jsxs(Fragment,{children:[jsx(Modal,{...m,...r,children:p&&jsx(yk,{...e,onSelect:()=>c(false)})}),jsx("div",{onClick:()=>c(true),children:s?g:jsx(Fragment,{children:f})})]})}var k1,Tk,kk=D(()=>{u();vk();Vo();({localeDefault:k1}=qe());Tk=C1;});var P1,Ck,Ek=D(()=>{u();P1=forwardRef(({id:e,members:t=[],...o},r)=>{let n=t.map(i=>jsxs(Stack,{align:"center",children:[jsx(Text,{fw:500,children:i.name}),jsx(Badge,{color:"green",variant:"light",children:i.variant})]},i.id));return jsx("div",{ref:r,style:{width:"100%"},children:jsx(Group,{justify:"space-between",grow:true,children:n})},e)}),Ck=P1;});function U1({locale:e,profilePrefix:t="/report",autocompleteProps:o={},tooltipProps:r={},tooltipText:n="Click to search",searchReportParams:i={},callback:a,children:l}){let s=useRouter(),p=s.locale,{localeDefault:c}=qe(),d=p===c?"":`/${p}`,m=$1(null),[f,g]=useState(""),[h,y]=useDebouncedValue(f,500),[b,S]=useState([]),[E,v]=useState(false),[C,k]=useState(false),[R,L]=useState(false),[I,P]=useState(!l),O=()=>{P(false);},F=()=>{P(true),W();},A=useRef(),M=useClickOutside(O),B=o?.searchConfig?.searchLimit??10,W=()=>{v(true);let Q={query:h,format:"profiles",locale:e,limit:B,visible:true,includes:true,noImage:false,variant:[],dimension:[],report:[],all:false,...i};Qp.get("/api/cms/search/reports",{params:Q}).then(J=>{J&&J.data&&J.data.data&&J.data.data.results&&S(J.data.data.results.map(se=>{let ge=se.report?.name??se.name??`${se.id}`;return {id:se.id,reportName:ge,label:ge,href:`${d}${t}${se.path}`,reportPath:`${se.path}`,profilePrefix:t,value:se.id,members:(se.members||[]).map(he=>({original_id:String(he?.metadata?.id??he.id),name:he?.name??"",id:he.id??0,variant:he?.metadata?.variant?.name??"",image:{src:`/api/cms/member/image?member=${he.id}&size=thumb`,alt:he?.name??""}}))}})),v(false),A.current?.focus();}).catch(J=>{console.error(J),v(false);});};useEffect(()=>{R&&h.length>=(o.searchConfig?.queryThreshold??0)&&W();},[R,h,o.searchConfig?.queryThreshold]),useEffect(()=>{y(),I&&L(true);},[]),useEffect(()=>{y(),I&&L(true);},[I]);let N=Q=>{P(false),a?a(Q):(s.push(Q.href),k(true));},K=Q=>{g(Q);},{searchConfig:V,renderOption:j,data:H,...Y}=o??{},_=useMemo(()=>b.map(Q=>({value:Q.value,label:Q.reportName})),[b]),Z=useMemo(()=>Object.fromEntries(b.map(Q=>[Q.value,Q])),[b]),ae=useMemo(()=>j||m,[j,m]),te=useMemo(()=>({placeholder:"Search",size:"md",leftSection:jsx(IconSearch,{}),value:f,onChange:K,disabled:(E||C)&&!R,limit:B,maxDropdownHeight:250,filter:Q=>Q.options,rightSection:jsx(Group,{gap:0,justify:"right",children:E?jsx(Loader,{size:20}):jsx(Fragment,{})}),renderOption:Q=>{let J=Q.option,se=Z[J.value];return se?jsx(ae,{...se}):J.label},onOptionSubmit:Q=>{let J=Z[Q];J&&N(J);},comboboxProps:{withinPortal:false},...Y,data:_}),[f,E,C,R,B,_,Z,j,N,Y]),U=jsx(Autocomplete,{ref:A,...te});return l?jsx(Tooltip,{label:n,disabled:I,...r,children:jsxs(Group,{ref:M,gap:"sm",align:"center",style:{cursor:"pointer"},children:[!I&&jsx("div",{onClick:()=>P(true),children:l}),I&&jsx(Fragment,{children:U}),I?jsx(ActionIcon,{variant:"light",onClick:O,children:jsx(IconX,{size:20})}):jsx(ActionIcon,{variant:"light",onClick:F,children:jsx(IconSearch,{size:20})})]})}):U}var $1,Pk,Ok=D(()=>{u();fa();Ek();Vo();$1=e=>{let{components:t}=zr(),o=Ck;return t?.ReportItem&&(o=t?.ReportItem),e&&(o=e),o};Pk=U1;});function j1(){let e=zr("components");return useMemo(()=>{let{modal:t,inline:o}=e?.search??{};return {modal:t,inline:o}},[e?.search])}function Rc(e,t,o,r,n){let i=j1(),a=G(g=>g.variables.attributes.report_id),l=G(g=>g.variables.attributes.variant_id1),s=G(g=>g.variables.attributes.name1),p=useMemo(()=>({reportId:a,variantId:l,title:s}),[a,l,s]),c=useRouter(),d=gs(),m=$t();return useMemo(()=>{let g=e;return t==="modal"?g=jsx(Tk,{exploreProps:{locale:c.locale||Lk,profilePrefix:d,translations:m.explore,initialReportId:p.reportId,initialVariantId:p.variantId,initialQuery:p.title},tooltipText:m.explore?.tooltip,modalProps:i.modal,...n,children:e}):t==="inline"&&(g=jsx(Pk,{locale:c.locale||Lk,profilePrefix:d,callback:o,tooltipText:m.explore?.tooltip,...r,autocompleteProps:i.inline,children:e})),g},[t,e,c.locale,d,m,p,i,o,r,n])}var Lk,bg=D(()=>{u();Nr();le();Te();kk();Ok();Vo();fa();({localeDefault:Lk}=qe());});function rn(){let e=re();return useMemo(()=>async t=>await e(ee.readMember(t)),[e])}var ha=D(()=>{u();le();});var Bk=D(()=>{u();Pt();le();xn();ti();Br();ha();});function Fr(){return useContext(Y1)}var Y1,fi=D(()=>{u();Bk();Y1=createContext({active:false,variables:null,status:null,setComparisonVariables:null,comparisonLoaded:false,loading:false,error:false});});function vg({title:e,tooltip:t,slug:o,_iconType:r,_iconVariant:n,_icon:i,settings:a,_iconRadius:l,_iconSize:s,_iconPadding:p,asComparison:c=false}){let{print:d}=pr(),m=We(e)||"<span class='cr-block-placeholder'>Title</span>",f=a&&a.order?parseInt(a.order,10):1,g=f<=6?f:1,h=a&&a.search?a.search:"off",y=a&&a.align?a.align:"left",b=Fr(),S=G(L=>L.status.previews),v=(c?b.status.previews:S).map(L=>L.name).join(" | "),C=jsxs(Group,{children:[jsx(Ye,{blockType:"title",iconType:r,iconVariant:n,iconRadius:l,iconSize:s,icon:i,iconPadding:p}),jsx(xe,{id:o||void 0,component:"h",order:g,style:a,html:m})]}),k=Rc(C,h),R=a&&a.addComparisonName==="yes"&&b.active;return jsxs(Group,{gap:"sm",justify:oo(y),children:[jsxs("div",{children:[d?C:k,R&&jsx(Text,{className:"bespoke-comparison-title",children:v})]}),t&&jsx(Vt,{content:t})]})}var _k=D(()=>{u();Zr();Rn();ht();bg();fi();le();gi();wn();ro();});function Ou(e,t,o,r=false,n=false){let i=useRouter(),{query:a,locale:l}=i,s=re(),p=Fr(),c=G(P=>r&&p.variables?p?.variables?.attributes:P.variables.attributes,Go),d=G(ci,ir),m=G(xs,ec),f=G(Ts,ec),g=useMemo(()=>ei(m,l),[m,l]),h=ot(e,r&&p.active?p?.variables.variables:void 0,r&&p.active?p?.variables.attributes:void 0),y=G(P=>r?p.variables.variables:P.variables.variables),b=G(P=>r?p.variables.status:P.variables.status),S=rn(),{sectionVariables:E,resetSectionVariables:v}=mt(t),{addRunConsumersRunning:C,removeRunConsumersRunning:k}=ic(),R=r&&p.active?`${o}Compare`:o,L=r&&p.active?Object.fromEntries(Object.entries(a).filter(([P])=>P.match(ez)).map(([P,O])=>[P.replace("Compare",""),O])):Object.fromEntries(Object.entries(a).filter(([P])=>P.match(tz)).map(([P,O])=>[P.replace("Compare",""),O]));return useCallback(P=>{let O={locale:l,query:{...L,[o]:P},variables:h},F=new URLSearchParams(window.location.search);F.set(R,P),window.history.replaceState(null,null,`?${F.toString()}`),C([t]),ai(d,void 0,e,g,O,{variables:y,status:b},S,"report",f).then(A=>{p.active&&r?p.setComparisonVariables({attributes:c,variables:A.variables,status:A.status}):s(qi.setVariableChange({attributes:c,variables:A.variables,status:A.status})),n&&E&&v(),k([t]);});},[e,t,o,R,a,d,s,g,i,h.attributes,r,n,b,y])}var ez,tz,Sg=D(()=>{u();xn();le();ti();Br();ds();Te();ha();fi();ta();ez=/\w*Compare\b/,tz=/selector\d+id/;});function Cg(e){let{name:t,settings:o,options:r,id:n,defaultValue:i,section:a,component:l,asComparison:s,hideLabel:p,resetSectionVars:c}=e,{print:d}=pr(),m=pz(n),f=Ou(n,a,m,s,c==="true"),g=s?`${m}Compare`:m,[h,y]=useState(i),[b,S]=useState(zk(i,[])),E=JSON.stringify(r),v=o[Nt.DISABLED]||false,C=useMemo(()=>r?.map(O=>({value:O.id,label:O.label,imageUrl:O.imageUrl}))||[],[E]),k=d?r.filter(O=>b.includes(O.id)).map(O=>O.label).join(", "):"",R=d&&h&&r.find(O=>O.id===h)?.label||"",L=e.hideLabel==="true"?jsx(Fragment,{}):jsx(xe,{component:"span",html:t,size:"sm",style:o});if(useEffect(()=>{if(!v){let F=new URLSearchParams(window.location.search).get(g)||i;F&&(e.type===Tt.SINGLE?y(F):S(zk(F,i)));}},[window.location.search,i]),C.length<=1)return jsx(Fragment,{});let I=O=>{S(O),f(O.join(","));},P=O=>{y(O),f(O);};return jsx(Fragment,{children:d?jsxs(Box,{style:{display:"flex",alignItems:"center"},children:[L,jsx(Button,{ml:"sm",radius:"xl",variant:"outline",children:e.type===Tt.SINGLE?R:k})]}):jsx(Box,{children:{[Tt.SINGLE]:l===Hp.SEGMENTED_CONTROL?jsxs("div",{children:[jsx(Text,{size:"sm",fw:500,display:p==="true"?"none":"block",children:L}),jsx(SegmentedControl,{data:C,disabled:v,value:C.map(O=>O.value).includes(h)?h:"",onChange:P,fullWidth:true})]}):jsx(Select,{label:L,data:C,disabled:v,value:h,renderOption:O=>jsx(uz,{...O}),onChange:P,styles:{label:{display:p==="true"?"none":"block"}}}),[Tt.MULTI]:jsx(MultiSelect,{label:L,data:C,value:b,onChange:I,disabled:v,styles:{label:{display:p==="true"?"none":"block"}}})}[e.type]})})}var pz,zk,uz,Vk=D(()=>{u();ht();be();Sg();gi();pz=e=>`selector${e}id`,zk=(e,t)=>e&&typeof e=="string"?e.split(","):t,uz=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{wrap:"nowrap",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 Lu(){return jsx("div",{children:"Generator"})}var $k=D(()=>{u();});function Eg(e){let{alt:t,src:o,desc:r,title:n,settings:i,...a}=e,l=We(t),s=We(o),p=We(r),c=jsx("img",{src:s,alt:l,style:a}),d=i&&i.align?String(i.align):"left";return (p&&p.length||n&&n.length)&&(c=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Lo(d),gap:"sm",children:[n&&jsx(xe,{component:"p",html:n,style:i}),c,r&&jsx(xe,{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 Uk=D(()=>{u();Zr();ht();ro();});function ba(e,t,o){let r=o.initialDeps??[],n;return ()=>{var i,a,l,s;let p;o.key&&((i=o.debug)!=null&&i.call(o))&&(p=Date.now());let c=e();if(!(c.length!==r.length||c.some((f,g)=>r[g]!==f)))return n;r=c;let m;if(o.key&&((a=o.debug)!=null&&a.call(o))&&(m=Date.now()),n=t(...c),o.key&&((l=o.debug)!=null&&l.call(o))){let f=Math.round((Date.now()-p)*100)/100,g=Math.round((Date.now()-m)*100)/100,h=g/16,y=(b,S)=>{for(b=String(b);b.length<S;)b=" "+b;return b};console.info(`%c\u23F1 ${y(g,5)} /${y(f,5)} ms`,`
|
|
35
35
|
font-size: .6rem;
|
|
36
36
|
font-weight: bold;
|
|
37
37
|
color: hsl(${Math.max(0,Math.min(120-120*h,120))}deg 100% 31%);`,o?.key);}return (s=o?.onChange)==null||s.call(o,n),n}}function Mu(e,t){if(e===void 0)throw new Error(`Unexpected undefined${""}`);return e}var Gk,Hk,jk=D(()=>{u();Gk=(e,t)=>Math.abs(e-t)<1,Hk=(e,t,o)=>{let r;return function(...n){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,n),o);}};});function Sz({measurements:e,outerSize:t,scrollOffset:o}){let r=e.length-1,i=Xk(0,r,l=>e[l].start,o),a=i;for(;a<r&&e[a].end<o+t;)a++;return {startIndex:i,endIndex:a}}var bz,Ic,Kk,Wk,yz,qk,vz,Yk,Bu,Xk,wg=D(()=>{u();jk();bz=e=>e,Ic=e=>{let t=Math.max(e.startIndex-e.overscan,0),o=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let n=t;n<=o;n++)r.push(n);return r},Kk=(e,t)=>{let o=e.scrollElement;if(!o)return;let r=e.targetWindow;if(!r)return;let n=a=>{let{width:l,height:s}=a;t({width:Math.round(l),height:Math.round(s)});};if(n(o.getBoundingClientRect()),!r.ResizeObserver)return ()=>{};let i=new r.ResizeObserver(a=>{let l=a[0];if(l?.borderBoxSize){let s=l.borderBoxSize[0];if(s){n({width:s.inlineSize,height:s.blockSize});return}}n(o.getBoundingClientRect());});return i.observe(o,{box:"border-box"}),()=>{i.unobserve(o);}},Wk={passive:true},yz=typeof window>"u"?true:"onscrollend"in window,qk=(e,t)=>{let o=e.scrollElement;if(!o)return;let r=e.targetWindow;if(!r)return;let n=0,i=e.options.useScrollendEvent&&yz?()=>{}:Hk(r,()=>{t(n,false);},e.options.isScrollingResetDelay),a=p=>()=>{let{horizontal:c,isRtl:d}=e.options;n=c?o.scrollLeft*(d&&-1||1):o.scrollTop,i(),t(n,p);},l=a(true),s=a(false);return s(),o.addEventListener("scroll",l,Wk),o.addEventListener("scrollend",s,Wk),()=>{o.removeEventListener("scroll",l),o.removeEventListener("scrollend",s);}},vz=(e,t,o)=>{if(t?.borderBoxSize){let r=t.borderBoxSize[0];if(r)return Math.round(r[o.options.horizontal?"inlineSize":"blockSize"])}return Math.round(e.getBoundingClientRect()[o.options.horizontal?"width":"height"])},Yk=(e,{adjustments:t=0,behavior:o},r)=>{var n,i;let a=e+t;(i=(n=r.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[r.options.horizontal?"left":"top"]:a,behavior:o});},Bu=class{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=false,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let o=null,r=()=>o||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:o=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{this._measureElement(i.target,i);});}));return {disconnect:()=>{var n;(n=r())==null||n.disconnect(),o=null;},observe:n=>{var i;return (i=r())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return (i=r())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=o=>{Object.entries(o).forEach(([r,n])=>{typeof n>"u"&&delete o[r];}),this.options={debug:false,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:false,getItemKey:bz,rangeExtractor:Ic,onChange:()=>{},measureElement:vz,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:true,isRtl:false,useScrollendEvent:true,...o};},this.notify=o=>{var r,n;(n=(r=this.options).onChange)==null||n.call(r,this,o);},this.maybeNotify=ba(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),o=>{this.notify(o);},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(o=>o()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null;},this._didMount=()=>()=>{this.cleanup();},this._willUpdate=()=>{var o;let r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((o=this.scrollElement)==null?void 0:o.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n);}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify();})),this.unsubs.push(this.options.observeElementOffset(this,(n,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=i,this.maybeNotify();}));}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(o,r)=>{let n=new Map,i=new Map;for(let a=r-1;a>=0;a--){let l=o[a];if(n.has(l.lane))continue;let s=i.get(l.lane);if(s==null||l.end>s.end?i.set(l.lane,l):l.end<s.end&&n.set(l.lane,true),n.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((a,l)=>a.end===l.end?a.index-l.index:a.end-l.end)[0]:void 0},this.getMeasurementOptions=ba(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(o,r,n,i,a)=>(this.pendingMeasuredCacheIndexes=[],{count:o,paddingStart:r,scrollMargin:n,getItemKey:i,enabled:a}),{key:false}),this.getMeasurements=ba(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:o,paddingStart:r,scrollMargin:n,getItemKey:i,enabled:a},l)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size);}));let s=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];let p=this.measurementsCache.slice(0,s);for(let c=s;c<o;c++){let d=i(c),m=this.options.lanes===1?p[c-1]:this.getFurthestMeasurement(p,c),f=m?m.end+this.options.gap:r+n,g=l.get(d),h=typeof g=="number"?g:this.options.estimateSize(c),y=f+h,b=m?m.lane:c%this.options.lanes;p[c]={index:c,start:f,size:h,end:y,key:d,lane:b};}return this.measurementsCache=p,p},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=ba(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset()],(o,r,n)=>this.range=o.length>0&&r>0?Sz({measurements:o,outerSize:r,scrollOffset:n}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getIndexes=ba(()=>[this.options.rangeExtractor,this.calculateRange(),this.options.overscan,this.options.count],(o,r,n,i)=>r===null?[]:o({startIndex:r.startIndex,endIndex:r.endIndex,overscan:n,count:i}),{key:process.env.NODE_ENV!=="production"&&"getIndexes",debug:()=>this.options.debug}),this.indexFromElement=o=>{let r=this.options.indexAttribute,n=o.getAttribute(r);return n?parseInt(n,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(o,r)=>{let n=this.indexFromElement(o),i=this.measurementsCache[n];if(!i)return;let a=i.key,l=this.elementsCache.get(a);l!==o&&(l&&this.observer.unobserve(l),this.observer.observe(o),this.elementsCache.set(a,o)),o.isConnected&&this.resizeItem(n,this.options.measureElement(o,r,this));},this.resizeItem=(o,r)=>{let n=this.measurementsCache[o];if(!n)return;let i=this.itemSizeCache.get(n.key)??n.size,a=r-i;a!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,a,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",a),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,r)),this.notify(false));},this.measureElement=o=>{if(!o){this.elementsCache.forEach((r,n)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(n));});return}this._measureElement(o,void 0);},this.getVirtualItems=ba(()=>[this.getIndexes(),this.getMeasurements()],(o,r)=>{let n=[];for(let i=0,a=o.length;i<a;i++){let l=o[i],s=r[l];n.push(s);}return n},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=o=>{let r=this.getMeasurements();if(r.length!==0)return Mu(r[Xk(0,r.length-1,n=>Mu(r[n]).start,o)])},this.getOffsetForAlignment=(o,r)=>{let n=this.getSize(),i=this.getScrollOffset();r==="auto"&&o>=i+n&&(r="end"),r==="end"&&(o-=n);let a=this.options.horizontal?"scrollWidth":"scrollHeight",s=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[a]:this.scrollElement[a]:0)-n;return Math.max(Math.min(s,o),0)},this.getOffsetForIndex=(o,r="auto")=>{o=Math.max(0,Math.min(o,this.options.count-1));let n=this.measurementsCache[o];if(!n)return;let i=this.getSize(),a=this.getScrollOffset();if(r==="auto")if(n.end>=a+i-this.options.scrollPaddingEnd)r="end";else if(n.start<=a+this.options.scrollPaddingStart)r="start";else return [a,r];let l=n.start-this.options.scrollPaddingStart+(n.size-i)/2;switch(r){case "center":return [this.getOffsetForAlignment(l,r),r];case "end":return [this.getOffsetForAlignment(n.end+this.options.scrollPaddingEnd,r),r];default:return [this.getOffsetForAlignment(n.start-this.options.scrollPaddingStart,r),r]}},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null);},this.scrollToOffset=(o,{align:r="start",behavior:n}={})=>{this.cancelScrollToIndex(),n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(o,r),{adjustments:void 0,behavior:n});},this.scrollToIndex=(o,{align:r="auto",behavior:n}={})=>{o=Math.max(0,Math.min(o,this.options.count-1)),this.cancelScrollToIndex(),n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");let i=this.getOffsetForIndex(o,r);if(!i)return;let[a,l]=i;this._scrollToOffset(a,{adjustments:void 0,behavior:n}),n!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(o))){let[p]=Mu(this.getOffsetForIndex(o,l));Gk(p,this.getScrollOffset())||this.scrollToIndex(o,{align:l,behavior:n});}else this.scrollToIndex(o,{align:l,behavior:n});}));},this.scrollBy=(o,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+o,{adjustments:void 0,behavior:r});},this.getTotalSize=()=>{var o;let r=this.getMeasurements(),n;return r.length===0?n=this.options.paddingStart:n=this.options.lanes===1?((o=r[r.length-1])==null?void 0:o.end)??0:Math.max(...r.slice(-this.options.lanes).map(i=>i.end)),Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(o,{adjustments:r,behavior:n})=>{this.options.scrollToFn(o,{behavior:n,adjustments:r},this);},this.measure=()=>{this.itemSizeCache=new Map,this.notify(false);},this.setOptions(t);}},Xk=(e,t,o,r)=>{for(;e<=t;){let n=(e+t)/2|0,i=o(n);if(i<r)e=n+1;else if(i>r)t=n-1;else return n}return e>0?e-1:0};});function Tz(e){let t=hi.useReducer(()=>({}),{})[1],o={...e,onChange:(n,i)=>{var a;i?flushSync(t):t(),(a=e.onChange)==null||a.call(e,n,i);}},[r]=hi.useState(()=>new Bu(o));return r.setOptions(o),Jk(()=>r._didMount(),[]),Jk(()=>r._willUpdate()),r}function Du(e){return Tz({observeElementRect:Kk,observeElementOffset:qk,scrollToFn:Yk,...e})}var Jk,Rg=D(()=>{u();wg();wg();Jk=typeof document<"u"?hi.useLayoutEffect:hi.useEffect;});function Ag(e,t,o,r,n=false){let i=useRouter(),{query:a,locale:l}=i,s=re(),p=Fr(),c=G(O=>r&&p.variables?p?.variables?.attributes:O.variables.attributes),d=G(ci),m=G(xs),f=G(Ts),g=useMemo(()=>ei(m,l),[m,l]),h=ot(e,r&&p.active?p?.variables.variables:void 0,r&&p.active?p?.variables.attributes:void 0),y=G(O=>r?p.variables.variables:O.variables.variables),b=G(O=>r?p.variables.status:O.variables.status),S=rn(),{sectionVariables:E,resetSectionVariables:v}=mt(t),{addRunConsumersRunning:C,removeRunConsumersRunning:k}=ic(),R=r&&p.active?`${o}-valueCompare`:`${o}-value`,L=r&&p.active?`${o}-typeCompare`:`${o}-type`,I=r&&p.active?Object.fromEntries(Object.entries(a).filter(([O])=>O.match(wz)).map(([O,F])=>[O.replace("Compare",""),F])):Object.fromEntries(Object.entries(a).filter(([O])=>O.match(Rz)).map(([O,F])=>[O.replace("Compare",""),F]));return useCallback((O,F)=>{let A={locale:l,query:{...I,[`${o}-type`]:F,[`${o}-value`]:O},variables:h},M=new URLSearchParams(window.location.search);O&&F?(M.set(R,O.join(",")),M.set(L,F)):(M.delete(R),M.delete(L)),window.history.replaceState(null,null,`?${M.toString()}`),C([t]),ai(d,void 0,e,g,A,{variables:y,status:b},S,"report",f).then(B=>{n&&E&&v(),p.active&&r?p.setComparisonVariables({attributes:c,variables:B.variables,status:B.status}):s(qi.setVariableChange({attributes:c,variables:B.variables,status:B.status})),k([t]);});},[r,c,e,d,p,s,g,b,y,l,I,S,o,L,R,h,E,n,v])}var wz,Rz,Qk=D(()=>{u();fi();ha();xn();le();Te();ti();Br();ds();wz=/\w*Compare\b/,Rz=/multihierarchySelector\d+(id|-(type|value))/;});function Og(e){let{allLabel:t,asComparison:o,colorKey:r,data:n,defaultValue:i,defaultValueType:a,hideLabel:l,resetSectionVars:s,iconKey:p,id:c,levels:d,limit:m,placeholder:f,searchIndexKey:g,searchIndexSeparator:h,section:y,settings:b}=e,{print:S}=pr(),E=$z(c),v=Ag(c,y,E,o,s==="true"),C=o?`${E}-valueCompare`:`${E}-value`,k=o?`${E}-typeCompare`:`${E}-type`,R=useMantineTheme(),{colorScheme:L}=useMantineColorScheme(),[I,P]=useState(false),[O,F]=useState(true),[A,M]=useState(""),[B,W]=useState(false),[N,K]=useState([""].slice(1)),[V,j]=useState([]),[H,Y]=useState(""),_=b[Nt.DISABLED]||false,Z=useMemo(()=>S?Array.from(new Set(n.filter(oe=>V.includes(oe[`${H} ID`])))).map(oe=>oe?.[H]).join(", "):"",[S]),ae=l==="true"||!e.label?jsx(Fragment,{}):jsx(xe,{component:"div",html:e.label,size:"sm",style:b}),te=useRef(null),U=useRef(false),z=useRef(!!m&&m<V.length),Q=N.length,J=d[Q],se=N.filter(Boolean);N.length>0&&se.length===0&&se.push(`${t} ${J?.label}`),useEffect(()=>{if(!_){let $=new URLSearchParams(window.location.search),oe=$.get(C)||i,fe=$.get(k)||a;oe&&fe?(j(Uz(oe,i)),Y(fe)):(j([]),Y(""));}},[window.location.search,i,a,_]),useEffect(()=>{let $=()=>{F(true);};return window.addEventListener("touchmove",$),()=>{window.removeEventListener("touchmove",$);}},[]);let ge=useMemo(()=>zz(n,d,r,p,g,h),[r,n,p,d,g,h]),he=useMemo(()=>{let $=Fz(A),oe=Array.from(Vz(ge,$)).reverse();return B?oe:N.reduce((fe,ve)=>fe.filter(Oe=>!ve||Oe.searchindex.indexOf(ve)>-1),oe.filter(fe=>fe.type===J?.value))},[J,ge,A,B,N]),X=useRef(null),ie=Du({count:I?he.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>X.current,[]),overscan:10,rangeExtractor:useCallback($=>Ic($),[])}),[me,Ee]=useState(-1),Ve=Math.min(me,he.length-1),Be=useCallback($=>{let oe=N.concat($);B&&W(false),K(oe);},[B,N]),xt=useCallback(()=>{let $=N.slice(0,Q-1);B&&W(false),K($);},[B,N,Q]),Co=useCallback($=>{M($.currentTarget.value),!z.current&&n.length>0&&P(true);},[n,M,z,P]),Cr=useCallback(()=>{M(""),v([],""),te.current?.focus(),m&&(z.current=false);},[M,v,te,m,z]),Fo=useCallback($=>{let oe=V.filter(fe=>fe!==$);oe.length>0?v(oe,H):v([],""),m&&oe.length<m&&(z.current=false);},[V,H,v,m,z]),Er=useCallback($=>{H!==$.type?v([$.value],$.type):V.includes($.value)?Fo($.value):m?(V.length<m&&v([...V,$.value],H),V.length===m&&v([...V.slice(1),$.value],H)):v([...V,$.value],H),M("");},[v,H,V,Fo,m]),Wn=useCallback(()=>{V.length>0&&A.length===0&&(v(V.slice(0,-1),H),P(true),m&&(z.current=false)),A.length>0&&M(A.slice(0,-1));},[v,V,H,A,M,P,m,z]),Kn=useCallback(()=>{F($=>$&&(U.current=$,!$)),Ee($=>$+1>=he.length?$:$+1);},[Ee,he]),qn=useCallback(()=>{let $=he[Ve];$&&Er($);},[he,Ve,Er]),Yn=useCallback(()=>{P(false);},[P]),Ol=useCallback(()=>{xt(),Ee(0);},[Ee,xt]),Ll=useCallback(()=>{let $=he[Ve];!B&&$&&$.type!==d[d.length-1]?.value&&(Be($.name),Ee(0));},[he,Ve,B,d,Ee,Be]),Ml=useCallback(()=>{F($=>$&&(U.current=$,!$)),Ee($=>$-1<0?0:$-1);},[Ee]),ne=({label:$,onRemove:oe,...fe})=>jsxs("div",{style:{alignItems:"center",backgroundColor:L==="dark"?"var(--mantine-color-dark-7)":"var(--mantine-color-gray-1)",borderRadius:R.radius.sm,cursor:"default",color:L==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${R.spacing.xs} / 2 - ${rem(2)}) calc(${R.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${R.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...fe,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:oe,radius:2,size:"sm",sx:{color:L==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",marginLeft:`calc(${R.spacing.sm} / 6)`},tabIndex:-1})]}),Pe=useMemo(()=>V.map($=>ge.find(oe=>oe.value===$)).filter($=>!!$).map(($,oe)=>createElement(ne,{...$,index:oe,label:$.label,key:$.value,onRemove:fe=>{fe.preventDefault(),fe.stopPropagation(),Fo($.value);}})),[V]),q=forwardRef(function({color:oe,icon:fe,label:ve,value:Oe,...Wt},Xn){return jsx("div",{ref:Xn,style:{cursor:"pointer",width:"100%"},...Wt,children:jsxs(Group,{align:"center",wrap:"nowrap",gap:"xs",w:"100%",children:[fe&&jsx(Box,{bg:oe??"transparent",component:"img",w:20,h:20,src:fe}),jsx(Text,{lineClamp:1,size:"sm",children:ve||Oe})]})})});return jsxs(Fragment,{children:[jsx("div",{className:"no-print",children:jsx(Input.Wrapper,{label:ae,children:jsxs(Popover,{closeOnClickOutside:true,disabled:_,keepMounted:true,opened:I,onChange:P,onClose:()=>{Ee(0),M("");},onOpen:()=>{he.length>0&&ie.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>Ee(0),sx:{position:"relative","& .defaultValue":{backgroundColor:L==="dark"?"var(--mantine-color-dark-5)":"var(--mantine-color-gray-3)",color:L==="dark"?"var(--mantine-color-dark-1)":"var(--mantine-color-gray-7)"}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:V.join(",")}),jsx(Input,{component:"div",disabled:_,multiline:true,onMouseDown:$=>{$.preventDefault(),!z.current&&n.length>0&&P(!I),te.current?.focus();},rightSection:V.length>0?jsx(CloseButton,{disabled:_,onClick:Cr,onMouseDown:$=>$.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:R.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${R.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:L==="dark"?"var(--mantine-color-dark-3)":"var(--mantine-color-gray-5)",opacity:1}},children:[Pe,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":I,onChange:Co,onKeyDown:getHotkeyHandler([["ArrowDown",Kn],["ArrowLeft",Ol],["ArrowRight",Ll],["ArrowUp",Ml],["Backspace",Wn],["Enter",qn],["Escape",Yn]]),placeholder:V.length===0&&f||"",ref:te,readOnly:z.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:R.fontSizes.sm,marginLeft:`calc(${R.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:A})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:$=>$.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:$=>$.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",gap:"xs",w:"100%",children:[d.length>1&&jsxs(Stack,{gap:"xs",children:[jsxs(Group,{onClick:$=>{$.stopPropagation();},px:"xs",justify:"center",gap:"xs",children:[jsx(Button,{onClick:()=>{Ee(0),W(true),K([]),he.length>0&&ie.scrollToIndex(0);},size:"xs",variant:B?"filled":"outline",children:t}),d.map(($,oe)=>jsx(Button,{onClick:()=>{B&&W(false);let fe=[""].slice(1),ve=oe;for(;ve--;)fe[ve]=N[ve]||"";Ee(0),K(fe),he.length>0&&ie.scrollToIndex(0);},size:"xs",variant:!B&&N.length===d.findIndex(fe=>fe.value===$?.value)?"filled":"outline",children:$?.label},$?.value))]}),jsx(Divider,{})]}),Q>0&&jsxs(Group,{align:"center",wrap:"nowrap",px:"xs",children:[jsx(ActionIcon,{onClick:xt,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:se.map($=>jsx(Text,{lineClamp:1,size:"xs",children:$},`${$}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>F(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:X,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${ie.getTotalSize()}px`,position:"relative",width:"100%"},children:ie.getVirtualItems().map($=>{let oe=he[$.index],fe=Ve===$.index,ve=V.includes(oe.value);return he.length>0&&fe&&!O&&ie.scrollToIndex(Ve),jsxs(Group,{"aria-selected":fe,align:"center","data-hovered":fe||void 0,"data-index":$.index,"data-selected":ve,id:oe.vale,wrap:"nowrap",onMouseEnter:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),O&&(Ee($.index),F(false));},onMouseMove:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),F(true);},onMouseDown:Oe=>{Oe.preventDefault(),Er(oe);},justify:"space-between",ref:ie.measureElement,role:"option",gap:"xs",sx:Oe=>({borderRadius:Oe.radius.xs,padding:"15px 5px 15px",paddingLeft:B&&10*d.findIndex(Wt=>Wt?.value===oe.type)||5,position:"absolute",top:0,left:0,height:`${$.size}px`,transform:`translateY(${$.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:L==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"},"&:hover":{backgroundColor:L==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"}}),tabIndex:-1,children:[jsx(q,{index:$.index,...oe}),!B&&oe.type!==d[d.length-1]?.value&&jsx(ActionIcon,{onMouseDown:Oe=>{Oe.preventDefault(),Oe.stopPropagation(),Be(oe.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},oe.value)})})})]})})})})]})})}),S&&jsxs(Text,{children:[ae,": ",Z]})]})}var zz,Fz,Vz,$z,Uz,aC=D(()=>{u();Rg();ht();gi();Qk();be();zz=(e=[],t=[],o="",r="",n="",i="|")=>{let a=t.map(h=>h.value).slice(),l=`${a.pop()}`,s=h=>h[o],p=h=>h[r],c=h=>{if(h[n])return typeof h[n]=="string"?h[n].split(i):h[n]},d=new Set,m=[],f=[],g=nest().rollup(h=>{let y=h[0],b=I=>I&&I.value&&!d.has(I.value),S=a.map(I=>y[`${I} ID`]),E=a.map(I=>y[I]),v=a.map((I,P)=>{if(f[P]!==E[P]){f[P]=E[P];let O=s[P]||s[s.length-1]||s,F=p[P]||p[p.length-1]||p,A=c[P]||c[c.length-1]||c;return {color:O(y,I)||void 0,icon:F(y,I)||void 0,value:`${S[P]}`,label:E[P],name:E[P],type:I,searchindex:E.slice(0,P+1).concat(A(y,I)).join("|")}}return {}}).filter(b);v.forEach(I=>d.add(I.value));let C=s[s.length-1]||s,k=p[p.length-1]||p,R=c[c.length-1]||c,L=h.map(I=>({color:C(I,l)||void 0,icon:k(I,l)||void 0,value:`${I[`${l} ID`]}`,label:I[l],name:I[l],type:l,searchindex:E.concat(I[l]).concat(R(I,l)).join("|")}));m.push(...v.concat(L));});return a.forEach(h=>{g.key(y=>`${y[`${h} ID`]}|${y[h]}`);}),g.entries(e),m},Fz=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},Vz=(e,t)=>{let o=e.length,r,n=l=>r&&r.searchindex.includes(l.searchindex),a={next:()=>{for(let l=o-1;l>-1;l--){let s=e[l];if(t.test(`${s.value} ${s.label} ${s.searchindex}`)||n(s))return r=s,o=l,{done:false,value:s}}return {done:true,value:void 0}},[Symbol.iterator]:()=>a};return a},$z=e=>`multihierarchySelector${e}`,Uz=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var sC=D(()=>{u();le();Br();Br();ti();ql();xn();ar();le();ds();ha();Te();be();ta();});var Lg=D(()=>{u();});var lC=D(()=>{u();sC();Sg();Lg();Cf();});function Vu(){let e=useContext(qz);if(e===void 0)throw new Error("usePdf must be used within a PdfProvider");return e}var Kz,qz,Mg=D(()=>{u();le();Br();ar();Kz={active:false,pdfParam:false,position:"DEFAULT",XlsxVizActive:false,pdfVariants:[],xlsxVariants:[],currentVariantPdfEnabled:false,currentVariantXlsxEnabled:false,isLoading:false,pdfAccessAllowed:false,xlsxAccessAllowed:false},qz=createContext(Kz);});function Bg(e,t){let o=G(s=>t?s.records.entities[e][t]:null),r=o?.settings,[n,i]=useSetState(o?.settings||{}),a=re(),l=useCallback((s,p)=>{o&&(i(c=>({...c,[s]:p})),a(ee.updateEntity(e,{id:o.id,settings:{...o.settings,[s]:p}})));},[a,o]);return useEffect(()=>{r&&i(r);},[r,i]),{settings:n,updateSettings:l}}var An,$u,ya=D(()=>{u();le();An=e=>Bg("section",e),$u=e=>Bg("report",e);});function Bo({target:e,dropdown:t}){let[o,{open:r,close:n}]=useDisclosure(false),i=useRef(true),a=()=>{setTimeout(()=>{i.current&&n();},1e3);},l=()=>{i.current=false;},s=()=>{i.current=true,n();};return jsxs(Group,{children:[e,jsxs(Popover,{opened:o,trapFocus:true,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"subtle",color:"blue",onMouseEnter:r,onMouseLeave:a,children:jsx(IconInfoCircle,{})})}),jsx(Popover.Dropdown,{maw:350,onMouseEnter:l,onMouseLeave:s,children:jsxs(Group,{align:"flex-start",wrap:"nowrap",children:[jsx("div",{children:jsx(ThemeIcon,{variant:"outline",sx:{border:"none"},children:jsx(IconInfoCircle,{})})}),jsx("div",{children:t})]})})]})]})}var Uu=D(()=>{u();});function va({value:e,onChange:t,item:o="block"}){let r=re(),[n,i]=useState([]),a=useMemo(()=>[{value:"public",label:`Public ${o}, (all visitors)`},{value:"guest",label:`Guest only ${o}, (non logged visitors)`},{value:"private",label:`Private ${o}, (session required, any role)`}],[o]),l=useMemo(()=>{let p=[{group:"Exclusive",items:a}],c=n.reduce((d,m)=>{let f=`${m.type} Roles`;return d[f]||(d[f]=[]),d[f].push({value:`role.${m.name}`,label:`Role ${m.name} (${m.type})`}),d},{});return Object.entries(c).forEach(([d,m])=>{p.push({group:d,items:m});}),p},[a,n]);useEffect(()=>{r(ee.searchRole()).then(p=>{i(p.roles);});},[r]);let s=p=>{let c=[];if(p.length===0)c=[a[0].value];else {let d=p.slice(-1)[0],m=a.map(g=>g.value);c=m.includes(d)?[d]:p.filter(g=>!m.includes(g));}t(c);};return jsx(MultiSelect,{label:"Privacy",description:`This ${o} will be shown based on the selected roles.`,data:l,value:e,onChange:s})}var Gu=D(()=>{u();le();});function Ng(e,t){return e===t}function zg(){let e=Io(),t=Number.parseInt(e.params[0]),o=fo(t).data,{settings:r,updateSettings:n}=$u(t),{handlers:i}=zt("reportEditor"),a=o?.dimensions&&o.dimensions.length>0,l=tc(o?.dimensions||[]),s=useMemo(()=>l.isSuccess?l.data.flatMap(C=>C.variants||[]):[],[l.data,l.isSuccess]),p=oc(s),c=useMemo(()=>{if(!l.isSuccess||!p.isSuccess)return [];let C=l.data,k=p.data;return C.length===1?k.map(R=>({value:R.id.toString(),label:R.name,dimensionName:C[0].name})):C.length>1?C.map(I=>k.filter(P=>I.variants?.includes(P.id)||false)).reduce((I,P)=>I.flatMap(O=>P.map(F=>[...O,F])),[[]]).filter(I=>I.length>0).map(I=>({value:I.map(P=>P.id).join(","),label:I.map(P=>P.name).join(" / "),dimensionName:I.map((P,O)=>`${C[O]?.name}: ${P.name}`).join(" | ")})):[]},[l.data,l.isSuccess,p.data,p.isSuccess]),d=r.pdf?.variants||[],m=r.pdf?.privacy||["public"],f=C=>{n("pdf",{...r.pdf,enabled:true,variants:C});},g=C=>{n("pdf",{...r.pdf,enabled:true,privacy:C});},h=C=>{if(C){let k=c.map(R=>R.value);n("pdf",{enabled:true,variants:k,privacy:["public"]});}else n("pdf",{enabled:false,variants:[],privacy:[]});},y=r.xlsx?.variants||[],b=r.xlsx?.privacy||["public"],S=C=>{n("xlsx",{...r.xlsx,enabled:true,variants:C});},E=C=>{n("xlsx",{...r.xlsx,enabled:true,privacy:C});},v=C=>{if(C){let k=c.map(R=>R.value);n("xlsx",{enabled:true,variants:k,privacy:["public"]});}else n("xlsx",{enabled:false,variants:[],privacy:[]});};return jsx(Fragment,{children:jsxs(Stack,{children:[jsx(Button,{variant:"outline",radius:0,onClick:i.open,children:"Edit Report"}),a&&jsxs(Accordion,{children:[jsxs(Accordion.Item,{value:"comparison",children:[jsx(Accordion.Control,{children:"Profile Comparison"}),jsxs(Accordion.Panel,{children:[jsx(Bo,{target:jsx(Switch,{label:"Enable comparison",checked:!!r.comparison,onChange:C=>n("comparison",C.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Comparisons"}),jsx(Text,{fw:400,children:"This feature will allow user visiting this profile to compare it side by side to another choosen profile"})]})}),r.comparison&&jsx(Bo,{target:jsx(Switch,{label:"With different levels",checked:!!r.compareLevels,onChange:C=>n("compareLevels",C.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Compare with different Levels"}),jsx(Text,{fw:400,children:"Allow users to compare profiles from differet Levels."})]})})]})]}),jsxs(Accordion.Item,{value:"pdf",children:[jsx(Accordion.Control,{children:"PDF Export"}),jsxs(Accordion.Panel,{children:[jsx(Bo,{target:jsx(Switch,{label:"Enable PDF export",checked:!!r.pdf?.enabled,onChange:C=>h(C.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"PDF Exports"}),jsx(Text,{fw:400,children:"This feature will allow user to download the PDF version of the report with a single click."})]})}),r.pdf?.enabled&&jsxs(Stack,{mt:"md",children:[jsx(va,{value:m,onChange:g,item:"PDF export"}),c.length>0&&jsxs(Fragment,{children:[jsx(Text,{fw:500,size:"sm",children:"Select variants to enable PDF export:"}),jsx(Checkbox.Group,{value:d,onChange:f,children:jsx(Stack,{spacing:"xs",children:c.map(C=>jsx(Checkbox,{value:C.value,label:C.label,description:C.dimensionName,size:"sm"},C.value))})})]})]})]})]}),jsxs(Accordion.Item,{value:"xlsx",children:[jsx(Accordion.Control,{children:"XLSX Export"}),jsxs(Accordion.Panel,{children:[jsx(Bo,{target:jsx(Switch,{label:"Enable XLSX export",checked:!!r.xlsx?.enabled,onChange:C=>v(C.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Xlsx Exports"}),jsx(Text,{fw:400,children:"This feature will allow user to download the XlSX version of the report visualizations."})]})}),r.xlsx?.enabled&&jsxs(Stack,{mt:"md",children:[jsx(va,{value:b,onChange:E,item:"XLSX export"}),c.length>0&&jsxs(Fragment,{children:[jsx(Text,{fw:500,size:"sm",children:"Select variants to enable XLSX export:"}),jsx(Checkbox.Group,{value:y,onChange:S,children:jsx(Stack,{spacing:"xs",children:c.map(C=>jsx(Checkbox,{value:C.value,label:C.label,description:C.dimensionName,size:"sm"},C.value))})})]})]})]})]})]})]})})}var Wu=D(()=>{u();Te();ya();Uu();sa();Gu();});var fC,Vg,gC,qu=D(()=>{u();ar();fC=(e,t,o,r=null)=>{let[n,i]=useState(false),[a,l]=useState(null);return {print:p=>{i(true),l(null);let c=process.env.NEXT_PUBLIC_REPORTS_BASE_URL,d=new URLSearchParams(window.location.search),m=p?"&transparent=true":"",f=r?`/embeds/${t}/${o}?section=${e}&block=${r}${d.toString()?"&"+d.toString():""}`:`/embeds/${t}/${o}?section=${e}${d.toString()?"&"+d.toString():""}`,g=encodeURIComponent(`${c}${f}&print=true`);Qp.get(`${process.env.NEXT_PUBLIC_PDF_API_URL}/screenshot?url=${g}${m}`,{responseType:"blob"}).then(h=>{let y=r?`section${e}_block${r}.png`:`section${e}.png`;saveAs(h.data,y);}).catch(h=>{l(h.response?.data?.message||"Failed to download image. Please try again.");}).finally(()=>{i(false);});},downloadLoading:n,error:a}},Vg=()=>{let{asPath:e}=useRouter(),[t,o]=useState(false),[r,n]=useState(null),{user:i}=ft();return {printReport:async()=>{let l=null;if(o(true),n(null),i)try{l=(await Qp.post("/api/cms/users/generate-token")).data.token;}catch(m){n("Failed to generate user token. Generating PDF without user information."),console.error("Error generating user token:",m);}let s=process.env.NEXT_PUBLIC_REPORTS_BASE_URL,p=e.replace(/[&?]printBtn=[^&]+/,""),c=p.includes("?")?"&":"?",d=encodeURIComponent(`${s}${p}${c}print=true${l?`&user_token=${l}`:""}`);return Qp.get(`${process.env.NEXT_PUBLIC_PDF_API_URL}/pdf?url=${d}`,{responseType:"blob"}).then(m=>{let g=m.headers["content-disposition"]?.match(/filename[^;=\n]*=(['"]?)(.*?)\1/),h=g&&g[2]?g[2]:"report.pdf";saveAs(m.data,h);}).catch(m=>{n(m.response?.data?.message||"Failed to generate PDF. Please try again.");}).finally(()=>{o(false);})},error:r,setError:n,downloadLoading:t}},gC=()=>!!process.env.NEXT_PUBLIC_PDF_API_URL;});function kC({contentOutline:e=[]}){return jsx(Menu,{children:CC(e)})}function CC(e,t=true){return e.map((o,r)=>t?jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${o.id}`,children:jsx(Group,{children:jsx(Text,{dangerouslySetInnerHTML:{__html:o.label}})})})}),o.children.length?jsx(Box,{ml:"md",children:CC(o.children,false)}):null]},r):jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${o.id}`,children:jsx(Text,{dangerouslySetInnerHTML:{__html:o.label}})})},r))}function Ug({headings:e,settings:t,type:o,title:r,shortTitle:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:p,_iconPadding:c}){let{min:d="1",max:m="6",icons:f="yes"}=t||{},g=ks(parseInt(d,10),parseInt(m,10),e),h=f==="yes",y=We(r)||"",b=We(n||r)||"",S=y&&y.length>0,E=i&&i!=="none",C=`(max-width: ${useMantineTheme().breakpoints.md})`,k=useMediaQuery(C),R=k?b:y,L=t&&t.align?String(t.align):"left",I=Fs(L),P=oo(L),O=Lo(L),F=t&&t.titlePosition?String(t.titlePosition):"left",A=useMemo(()=>{let N={right:"left",left:"right"},K=S&&["left","right"].includes(F),V={};if(K){let j=F==="right";V={gap:"xs",justify:j&&N[P]?N[P]:P,style:{flexDirection:j?"row-reverse":"row"},wrap:"nowrap"};}else V={gap:"xs",align:O,justify:"center",style:{flexDirection:F==="bottom"?"column-reverse":"column"}};return {element:K?Group:Stack,props:V}},[S,P,O,F]),M=useMemo(()=>S?jsxs(Group,{gap:"xs",justify:P,wrap:"nowrap",children:[E&&jsx(Ye,{blockType:"title",iconType:i,iconVariant:a,iconRadius:s,iconSize:p,icon:l,iconPadding:c}),jsx(xe,{style:{...t},html:R,lineClamp:1})]}):null,[S,E,P,R]),B=useMemo(()=>k?jsx(fF,{contentOutline:g,showIcons:h,titleElement:M,wrapper:A}):null,[k,M,A]),W=useMemo(()=>k?null:o==="multilevel"?jsx(gF,{contentOutline:g,showIcons:h,align:I}):jsx(mF,{contentOutline:g,showIcons:h,align:I}),[g,h,I,k]);return jsxs(Fragment,{children:[k&&B,!k&&jsxs(A.element,{pos:"relative",...A.props,children:[S&&M,W]})]})}var bC,mF,EC,fF,gF,wC=D(()=>{u();lC();Rn();ro();Mg();Wu();qu();Zr();Rn();ht();bC=e=>t=>({display:"flex",gap:t.spacing.md,justifyContent:e,listStyleType:"none"});mF=({contentOutline:e,showIcons:t,align:o})=>{let{active:r,position:n,pdfParam:i}=Vu(),{downloadLoading:a,printReport:l}=Vg(),[s,p]=useState(null);if(useEffect(()=>{let d=()=>{let m=document.querySelector(".bespoke-nav");if(!m)return;let f=m.getBoundingClientRect(),g=false;e.forEach(h=>{let y=document.getElementById(`bespoke-title-${h.id}`);y&&y.getBoundingClientRect().top<=f.bottom&&(p(h.id),g=true);}),g||p(null);};return window.addEventListener("scroll",d),()=>{window.removeEventListener("scroll",d);}},[e]),r&&i)return jsx(kC,{contentOutline:e});let c=d=>!d||!d?.length?null:jsx(Fragment,{children:d.map(m=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${m.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[t&&jsx(Ye,{...m.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:m.label}})]})})}),jsx(Box,{pl:"xs",children:c(m.children)})]},m.id))});return jsxs(Box,{component:"nav",className:"bespoke-nav",children:[jsx(List,{sx:d=>({display:"flex",gap:d.spacing.md,justifyContent:o,listStyleType:"none"}),children:e?.map(d=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:200,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${d.id}`,"data-active":d.id===s,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[t&&jsx(Ye,{...d.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:d.label}})]})})}),d?.children?.length?jsx(Menu.Dropdown,{children:c(d.children)}):null]})},d.id))}),Ng(n,"NAV")&&r&&e.length>=1&&jsx(List.Item,{children:jsx(Button,{variant:"outline",onClick:l,children:a?"Downloading":"Download PDF"})})]})},EC=({contentOutline:e,closeNav:t,showIcons:o})=>{let[r,n]=useState(null);return jsx(Stack,{children:e.map(i=>i.children.length?jsxs(Fragment,{children:[jsxs(Group,{gap:0,wrap:"nowrap",children:[jsx(UnstyledButton,{w:"100%",component:"a",onClick:t,href:`#bespoke-title-${i.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[o&&jsx(Ye,{...i.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:i.label}})]})},i.id),jsx(ActionIcon,{component:"a",size:"lg",onClick:()=>n(a=>a===i.id?null:i.id),children:jsx(IconChevronDown,{style:{transition:"transform 0.2s",transform:r===i.id?"rotate(-180deg)":"none"},stroke:1})})]},i.id),jsx(Collapse,{in:r===i.id,pl:"sm",transitionTimingFunction:"linear",transitionDuration:200,children:jsx(EC,{contentOutline:i.children,closeNav:t,showIcons:o})})]}):jsx(Group,{wrap:"nowrap",children:jsx(UnstyledButton,{display:"flex",w:"100%",component:"a",href:`#bespoke-title-${i.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[o&&jsx(Ye,{...i.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:i.label}})]})},i.id)},i.id))})},fF=({contentOutline:e,showIcons:t,titleElement:o,wrapper:r})=>{let[n,{toggle:i}]=useDisclosure(false),a=n?"Close content outline":"Open content outline",{active:l,pdfParam:s}=Vu();return l&&s?jsx(kC,{contentOutline:e}):jsxs(Box,{className:"bespoke-mobile-nav",component:"nav",children:[jsxs(r.element,{className:"bespoke-mobile-nav-header",...r.props,onClick:i,children:[o&&o,jsx(ActionIcon,{className:"bespoke-mobile-nav-toggle","aria-label":a,size:"lg",variant:"subtle",children:n?jsx(IconChevronUp,{size:"xl",stroke:1.5}):jsx(IconChevronDown,{size:"xl",stroke:1.5})})]}),jsx(Collapse,{in:n,mt:"md",className:"bespoke-mobile-nav-body",children:jsx(EC,{contentOutline:e,closeNav:i,showIcons:t})})]})},gF=({contentOutline:e,showIcons:t,align:o})=>{let[r,n]=useState(null),[i,a]=useState(null);useEffect(()=>{let s=()=>{let p=document.querySelector(".bespoke-nav");if(!p)return;let c=p.getBoundingClientRect(),d=false;e.forEach(m=>{let f=document.getElementById(`bespoke-title-${m.id}`);f&&(f.getBoundingClientRect().top<=c.bottom&&(n(m.id),a(null),d=true),m.children.forEach(h=>{let y=document.getElementById(`bespoke-title-${h.id}`);y&&y.getBoundingClientRect().top<=c.bottom&&(a(h.id),n(m.id),d=true);}));}),d||(n(null),a(null));};return window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s);}},[e]);let l=s=>!s||!s?.length?null:jsx(Fragment,{children:s.map(p=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${p.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[t&&jsx(Ye,{...p.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:p.label}})]})})}),jsx(Box,{pl:"xs",children:l(p.children)})]},p.id))});return jsxs(Box,{component:"nav",className:"bespoke-nav",children:[jsx(List,{className:"bespoke-nav-level1",sx:bC(o),children:e?.map(s=>jsx(List.Item,{children:jsx(Anchor,{href:`#bespoke-title-${s.id}`,"data-active":r===s.id,onClick:()=>n(s.id),children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[t&&jsx(Ye,{...s.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:s.label}})]})})},s.id))}),r&&e.find(s=>s.id===r)?.children.length>0&&jsx(List,{className:"bespoke-nav-level2",sx:bC(o),children:e.find(s=>s.id===r)?.children.map(s=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:200,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${s.id}`,"data-active":s.id===i,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[t&&jsx(Ye,{...s.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:s.label}})]})})}),s?.children?.length?jsx(Menu.Dropdown,{children:l(s.children)}):null]})},s.id))})]})};});function Hg(e){let{related_reports:t,settings:o}=e,r=G(m=>m.status.currentLocale),n=G(m=>m.status.localeDefault),i=gs(),a=useRouter(),l=zr("components");if(!t?.length)return;let s=r===n?"":`/${r}`,p=m=>{a.push(`${m}`);},c=l?.ReportTile?l.ReportTile:ug,d=Lo(o&&o.align?String(o.align):"center");return jsx(Grid,{justify:d,children:t.map(m=>{let f=`${s}${i}${m.link}`,g=m.entities.map(E=>({original_id:E.id,name:E.name,id:E.content_id,variant:E.variant_name,variant_id:E.variant_id,dimension:E.dimension_name,dimension_id:E.dimension_id,image:{src:`/api/cms/member/image?member=${E.content_id}&size=thumb`,alt:E.name}})),h=m.entities.map(E=>E.id).join("-"),y=m.entities.map(E=>E.name).join(" & "),b=m.entities[0]?m.entities[0].report_id:null,S=E=>{E.preventDefault(),p(f);};return jsx(Grid.Col,{xs:12,sm:6,md:4,lg:4,xl:3,children:jsx(c,{reportId:b,reportName:y,members:g,href:f,onClick:S})},h)})})}var AC=D(()=>{u();le();Te();dg();fa();ro();});function jg({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:i}){let a=tt(e).data,{sectionVariables:l,resetSectionVariables:s}=mt(a?.section_id),p=!!Object.keys(l).length,c=Lo(o&&o.align?o.align:"left");return !p&&!i?null:jsx(Button,{onClick:()=>s(),disabled:!p,fullWidth:n,sx:{justifySelf:c},children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})}var PC=D(()=>{u();Te();Te();ro();});function Wg({settings:e,label:t,removeLabel:o,showIcon:r,position:n="center",asComparison:i=false}){let a=G(E=>E.records.entities.report),l=G(E=>E.variables.attributes),s=e&&e.search?e.search:"inline",p=Object.values(a)[0].settings,c=useRouter(),{comparisonLoaded:d,loading:m}=Fr(),f=Object.keys(c.query).includes("compare"),h=d&&f?jsx(Button,{onClick:()=>{let E={...c.query};delete E.compare,c.push({pathname:c.pathname,query:E},void 0,{shallow:true});},rightIcon:jsx(IconX,{}),children:o||"Remove Comparison"}):jsx(Button,{loading:m,children:jsxs(Group,{align:"center",children:[t||"Add Comparison",r&&jsx(IconPlus,{})]})}),y={searchReportParams:{report:[Number(Object.keys(a)[0])],variant:p.compareLevels?[]:[l.variant_id1]}},S=Rc(h,s,E=>{c.push({pathname:c.pathname,query:{...c.query,compare:E.reportPath}});},y);return i?null:jsx(Group,{position:n,children:f?h:S})}var MC=D(()=>{u();bg();le();fi();});function qg({columns:e=[],data:t=[],tableProps:o={},sectionId:r=null}){let[n,i]=useState(false),a=useMemo(()=>e.map(d=>d.accessorKey),[e]),l=useMemo(()=>t.filter(d=>typeof d=="object"&&d!==null&&!Array.isArray(d)&&Object.keys(d).some(m=>a.includes(m))),[a,t]),s=useMemo(()=>e.map(d=>({...d,Cell:({renderedCellValue:m})=>jsx(xe,{html:`${m}`}),filterFn:"contains"})),[e]),p=$t("table"),c={...MRT_Localization_EN,...p};return jsx(MantineReactTable,{...o,autoResetPageIndex:false,columns:s,data:l,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",layoutMode:"grid",localization:c,onIsFullScreenChange:d=>{let m=document.getElementById(`section-${r}`);m&&(d?m.style.zIndex="10":m.style.zIndex="1"),i(d);},state:{...o.state,isFullScreen:n}})}var DC=D(()=>{u();ht();Nr();});function Yg({label:e,url:t,settings:o}){let{align:r}=o;return e?jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})}):null}var NC=D(()=>{u();});function BF({block:e}){let{id:t}=e;return jsxs(Stack,{align:"center",gap:"sm",children:[jsx(ThemeIcon,{radius:"md",size:100,children:jsx(IconCircleKey,{size:100})}),jsxs(Title,{order:5,children:["Private content (Block ",t,")"]}),jsx(Text,{children:"Sorry, you do not have sufficient permissions to view this block."}),jsx(Text,{children:"Contact your account manager to check your access role."})]})}function Xg(e){let t=DF();return jsx(t,{block:e})}var DF,VC=D(()=>{u();fa();DF=()=>{let e=zr("components"),t=BF;return e?.CustomFallback&&(t=e.CustomFallback),t};});var NF,zF,$C,UC,Qu,FF,ka,Mc=D(()=>{u();ss();NF=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",zF="Error Rendering Visualization",$C={data:[],dataFormat:e=>e,type:"Treemap",noDataHTML:`<p style="font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
|
package/dist/report.js
CHANGED
|
@@ -12,7 +12,7 @@ import'path';import'url';import*as sg from'd3-array';import*as ag from'd3-collec
|
|
|
12
12
|
dignissim interdum eros. Curabitur non tincidunt libero.
|
|
13
13
|
Suspendisse quis nibh in massa tincidunt feugiat sit amet vitae nisl.
|
|
14
14
|
In pulvinar sapien ut tincidunt volutpat. Donec auctor tellus eu augue feugiat,
|
|
15
|
-
a viverra sapien pulvinar.`,style:o,append:t?jsx($e,{content:t,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{}),isPreview:true})}var id=b(()=>{c();Qt();Ie();});function gi({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:a,_iconVariant:s,_icon:i,_iconRadius:l,_iconSize:p,_iconPadding:u}){let d=t||"<span class='cr-block-placeholder'>Title</span>",m=o||"<span class='cr-block-placeholder'>Big Stat</span>",g=e||"<span class='cr-block-placeholder'>Subtitle</span>",f=n&&n.align||"left";return jsx("div",{className:"bespoke-Stat-root",children:jsxs(Group,{className:"bespoke-StatGroup-wrapper",position:We(f),children:[a!=="none"&&a&&jsx(be,{blockType:"stat",iconType:a,iconVariant:s,iconRadius:l,iconSize:p,icon:i,iconPadding:u}),jsxs("div",{className:"bespoke-Stat-wrapper",children:[jsx(se,{component:"div",size:"md",html:d,style:n,isPreview:true}),jsx(se,{component:"div",size:"xl",html:m,style:n,isPreview:true}),jsx(se,{component:"div",size:"sm",html:g,style:n,isPreview:true})]},"stat"),r&&jsx($e,{content:r})]})})}var cd=b(()=>{c();Qt();Jt();Ie();je();});function hi({subtitle:e,tooltip:t,settings:o}){let r=ve(e)||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{gap:"sm",position:We(n),children:[jsx(se,{size:"sm",html:r,isPreview:true}),t&&jsx($e,{content:t,style:{display:"inline-flex"}})]})}var ud=b(()=>{c();Qt();Yt();Ie();je();});function yi({title:e,tooltip:t,_iconType:o,_iconVariant:r,_icon:n,settings:a,_iconRadius:s,_iconSize:i,_iconPadding:l}){let p=ve(e)||"Title",u=a&&a.order?parseInt(a.order,10):1,d=u<=6?u:1,m=!!(a&&a.search&&a.search!=="off"),g=a&&a.search?a.search:"",f=a&&a.align?a.align:"left";return jsxs(Group,{gap:"sm",justify:We(f),children:[o!=="none"&&o&&jsx(be,{blockType:"title",iconType:o,iconVariant:r,iconRadius:s,iconSize:i,icon:n,iconPadding:l}),jsx(se,{component:"h",order:d,style:a,html:p,isPreview:true}),m&&jsx(Tooltip,{label:`Click will open '${g}' report search`,children:jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})}),t&&jsx($e,{content:t})]})}var dd=b(()=>{c();Qt();Yt();Jt();Ie();je();});function Ti(e){let{id:t,type:o,defaultValue:r,options:n,name:a,settings:s,hideLabel:i,component:l,resetSectionVars:p,section:u}=e,d=Te(),m=useContext(Mt),g=K(v=>v.status.query),{sectionVariables:f,resetSectionVariables:x}=De(u),y=Rx(t),E=useMemo(()=>g[y]||r,[g[y],o,r]),L=useMemo(()=>Ex(g[y],r),[g[y],o,r]),[k,O]=useState(n?.map(v=>({value:v.id,label:v.label,imageUrl:v.imageUrl}))||[]),[F,W]=useState((n||[]).map(v=>v.id).join("-"));useEffect(()=>{let v=(n||[]).map(N=>`${N.label}|${N.id}`).join("-");if(F===v)return;W(v);let P=(n||[]).map(N=>({value:N.id,label:N.label}));O(P);let D=o===Be.SINGLE?E:L;Vo(o,D,n||[])||d(sa(m,y));},[JSON.stringify(n),t]);let A=()=>{p==="true"&&f&&x();},B=v=>{d(Wo(m,y,v)),A();},w=v=>{d(Wo(m,y,v.join())),A();},C=i==="true"?jsx(Fragment,{}):jsx(se,{component:"div",html:a,size:"sm",style:s,isPreview:true});return k.length===0?jsx(Text,{c:"dimmed",size:"xs",children:"No options defined yet. Selector hidden in report."}):k.length===1?jsxs(Text,{c:"dimmed",size:"xs",children:["Only one option defined. Selector hidden in report. ",JSON.stringify(k)]}):{[Be.SINGLE]:l===Ln.SEGMENTED_CONTROL?jsxs("div",{children:[C,jsx(SegmentedControl,{data:k,value:k.map(v=>v.value).includes(E)?E:"",onChange:B,fullWidth:true})]}):jsx(Select,{label:C,data:k,value:E,onChange:B,renderOption:v=>jsx(kx,{...v}),styles:{label:{display:i==="true"?"none":"block"}}}),[Be.MULTI]:jsx(MultiSelect,{label:C,data:k,value:L,onChange:w,styles:{label:{display:i==="true"?"none":"block"}}})}[o]}var Rx,Ex,kx,gd=b(()=>{c();Jr();_n();ge();he();Kt();Ie();Pe();Rx=e=>`selector${e}id`,Ex=(e,t)=>e&&typeof e=="string"?e.split(","):t,kx=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{wrap:"nowrap",children:[t&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});var hd=b(()=>{});function Ei({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:a=0}){let s=useMantineTheme(),[i,l]=useState(false);if(a===Ri)return null;let p=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),u=vi(r),d=r,m=JSON.stringify(d),g=100,f=1e3,x=!!(m&&m.length>g),y=10,E={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(u==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,c:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:a+1<Ri?Object.keys(r).sort((L,k)=>{let O=vi(r[L]),F=vi(r[k]);return O!==F?bd.indexOf(O)-bd.indexOf(F):L.localeCompare(k)}).map(L=>jsx(Ei,{root:false,label:L,value:r[L],level:a+1},L)):p})]})});if(u==="array"){let L=r.length>y,k=L?r.slice(0,y):r,O=L?r.length-y:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,p:0,color:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[a+1<Ri?k.map((F,W)=>jsx(Ei,{root:false,label:W,value:F,level:a+1,parentIsArray:true},W)):p,L&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",O," other elements]"]})]})]})})}return u==="string"?d=x?`"${d.substring(0,g)} ... "`:`"${d}"`:u==="error"?d=`Error: ${d.message}`:u==="undefined"?d=u:d.toString&&(d=d.toString()),jsxs(Group,{wrap:"nowrap",gap:0,justify:"space-between",children:[jsx(Tooltip,{label:"Copied!",opened:i,closeDelay:1e3,children:jsx(Text,{c:e?"dimmed":s.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap",cursor:"pointer"},onClick:()=>{let L=o?`{{${t}}}`:n?`[${t}]`:t;navigator.clipboard.writeText(L),l(true),setTimeout(()=>l(false),1e3);},fw:700,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Tooltip,{label:d,children:jsx(CodeHighlight,{className:"cr-variable",code:d,language:"jsx",withCopyButton:false,styles:L=>({codeHighlight:{textAlign:"right",overflow:"hidden",width:"fit-content",flex:"0 1 auto"},code:{padding:"5px 0 5px 5px",fontSize:L.fontSizes.xs},pre:{marginLeft:"5px"}})})}),x&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,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:m.substring(0,f)})})]})]})}var vi,bd,Ri,Sd,Td=b(()=>{c();hd();vi=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},bd=["object","array","string","number"],Ri=5;Sd=Ei;});var xd,vd=b(()=>{c();xd=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function Mx({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let a=Tt(t==="attributes"?null:t).data,s=a?a.type:"block",i=a?.type&&a?.id?`${a.type}${a.id}`:"",l=Object.keys(o).filter(r?()=>true:p=>!xd(i)(p));return jsx(Stack,{gap:0,children:l.length?l.map(p=>jsx(Sd,{dimmed:e.includes(p),label:p,value:o[p]},p)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${s}`})})})}var Rd,Ed=b(()=>{c();Td();he();vd();Rd=Mx;});function Hx({outputVariables:e,status:t,hasAPI:o=false,debug:r,type:n}){let[a,s]=useState(false),i=o&&!Object.keys(e).length&&!t.error,l=Object.keys(e).some(u=>u.startsWith("_"));return r?i?jsxs(Stack,{align:"center",children:[jsx(Loader,{}),jsxs(Text,{size:"sm",children:["Loading ",n]})]}):jsxs(Fragment,{children:[jsx(Divider,{label:"Output Variables",labelPosition:"center"}),l&&jsx(Switch,{label:"Show internal variables",mb:"xs",size:"xs",checked:a,onChange:u=>s(u.currentTarget.checked)}),jsx(Rd,{variables:e,showInternal:a})]}):jsx(Center,{children:jsx(Badge,{color:"gray",variant:"outline",children:n.toUpperCase()},"type")})}var Ci,kd=b(()=>{c();Ed();Ci=Hx;});function wi(e){let{alt:t,src:o,desc:r,title:n,settings:a,...s}=e,i=ve(t),l=ve(o),p=ve(r),u=jsx("img",{src:l,alt:i,style:s}),d=a&&a.align?String(a.align):"left";return (p&&p.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:ot(d),gap:"sm",children:[n&&jsx(se,{component:"p",html:n,style:a,isPreview:true}),u,r&&jsx(se,{component:"p",size:"sm",html:r,style:a,isPreview:true})]})),l&&i?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var Cd=b(()=>{c();Yt();Ie();je();});function Ii({headings:e,settings:t,title:o,shortTitle:r,_iconType:n,_iconVariant:a,_icon:s,_iconRadius:i,_iconSize:l,_iconPadding:p}){let{min:u="1",max:d="6",icons:m="yes"}=t||{},g=ve(o)||"",f=ve(r||o)||"",x=g&&g.length>0,y=n&&n!=="none",E=f===g?`${g}`:`${g} (${f})`,L=Pr(parseInt(u,10),parseInt(d,10),e),k=m==="yes",O=t&&t.align?String(t.align):"left",F=Rr(O),W=We(O),A=ot(O),B=t&&t.titlePosition?String(t.titlePosition):"left",w=useMemo(()=>{let v={right:"left",left:"right"},P=x&&["left","right"].includes(B),D={};if(P){let N=B==="right";D={gap:"xs",justify:N&&v[W]?v[W]:W,style:{flexDirection:N?"row-reverse":"row"},wrap:"nowrap"};}else D={gap:"xs",align:A,justify:"center",style:{flexDirection:B==="bottom"?"column-reverse":"column"}};return {element:P?Group:Stack,props:D}},[x,W,A,B]),C=v=>!v||!v?.length?null:jsx(Fragment,{children:v.map(P=>jsxs(Fragment$1,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${P.id}`,children:jsxs(Group,{gap:"sm",children:[k&&jsx(be,{...P.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:P.label}})]})})},P.id),jsx(Box,{pl:"xs",children:C(P.children)})]},P.id))});return jsxs(w.element,{pos:"relative",...w.props,children:[x&&jsxs(Group,{gap:"xs",position:W,wrap:"nowrap",children:[y&&jsx(be,{blockType:"title",iconType:n,iconVariant:a,iconRadius:i,iconSize:l,icon:s,iconPadding:p}),jsx(se,{style:t,html:E,isPreview:true,lineClamp:1})]}),jsxs(List,{sx:v=>({display:"flex",gap:v.spacing.md,justifyContent:F,alignItems:"center",listStyleType:"none"}),children:[L?.map(v=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:400,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${v.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[k&&jsx(be,{blockType:"nav",...v.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:v.label}})]})})}),v?.children?.length?jsx(Menu.Dropdown,{children:C(v.children)}):null]})},v.id)),!L||L.length===0&&jsx(List.Item,{children:jsx(Text,{color:"dimmed",children:"- Include some titles as inputs to see the Nav component -"})})]})]})}var Ad=b(()=>{c();Qa();Jt();je();Ie();Jt();Yt();});function _i(e){let{related_reports:t,settings:o}=e;if(!t?.length)return jsx(Text,{children:"There are no available members related to your current selection and report."});let r=Rr(o&&o.align?String(o.align):"left");return jsx(List,{sx:()=>({display:"flex",justifyContent:r,"& li":{marginRight:"1rem"}}),children:t.map(n=>jsx(List.Item,{children:n.entities.map(a=>a.name).join(" & ")},n.link))})}var Id=b(()=>{c();je();});function Oi({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:a}){let s=Tt(e).data,{sectionVariables:i,resetSectionVariables:l}=De(s?.section_id),p=!!Object.keys(i).length,u=ot(o&&o.align?o.align:"left");return jsxs(Stack,{align:u,children:[!p&&!a&&jsx(Text,{size:"xs",ta:o?.align||"left",children:"Reset button will not be shown on its disabled state"}),jsx(Button,{onClick:()=>l(),disabled:!p,fullWidth:n,children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})]})}var _d=b(()=>{c();Pe();Pe();je();});function Mi({settings:e,label:t,showIcon:o,position:r="center"}){let n=e&&e.search?e.search:"";return jsxs(Group,{position:r,children:[jsx(Tooltip,{label:`Click will open '${n}' report search`,children:jsx(Button,{children:jsxs(Group,{align:"center",children:[t||"Comparison Button",o&&jsx(IconPlus,{})]})})}),jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})]})}var Md=b(()=>{c();});function Fi({columns:e=[],id:t,data:o=[],tableProps:r={}}){let[n,a]=useState({}),{initialState:s}=r,i=s?.pagination?.pageIndex,l=s?.pagination?.pageSize,p=`table-${[t,i,l].filter(f=>f).join("-")}`,u=useMemo(()=>e.map(f=>f.accessorKey),[e]),d=useMemo(()=>o.filter(f=>typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).some(x=>u.includes(x))),[u,o]),m=useMemo(()=>e.map(f=>({...f,Cell:({renderedCellValue:x})=>jsx(se,{html:`${x}`,isPreview:true}),filterFn:"contains"})),[e]),g=kc();return useEffect(()=>{(async()=>{try{let y=`${(g||"en").toUpperCase()}`;a({});}catch(x){console.error("Error loading translations:",x);}})();},[g]),createElement(MantineReactTable,{...r,autoResetPageIndex:false,columns:m,data:d,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",key:p,layoutMode:"grid",localization:n,state:{...r.state,isFullScreen:false}})}var Nd=b(()=>{c();Ie();Pe();});function Di({label:e,url:t,settings:o}){let{align:r}=o;return jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})})}var Dd=b(()=>{c();});function zi(e){let t=Te(),o=useContext(Mt),r=K($=>$.status.query),n=Ov(e.id),a=useMantineTheme(),{colorScheme:s}=useMantineColorScheme(),{allLabel:i,colorKey:l,data:p,defaultValue:u,defaultValueType:d,iconKey:m,levels:g,limit:f,placeholder:x,searchIndexKey:y,searchIndexSeparator:E,resetSectionVars:L,section:k}=e,[O,F]=useState(false),[W,A]=useState(true),[B,w]=useState(""),[C,v]=useState(false),[P,D]=useState([""].slice(1)),{sectionVariables:N,resetSectionVariables:H}=De(k),X=useMemo(()=>Mv(r[`${n}-value`],u),[r,u,n]),M=useMemo(()=>r[`${n}-type`]||d,[r,d,n]),U=useCallback(()=>{L==="true"&&N&&H();},[L,N,H]),_=useCallback($=>{U(),t(Wo(o,`${n}-value`,$.join()));},[t,o,n,U]),j=useCallback($=>{U(),t(Wo(o,`${n}-type`,$));},[t,o,n,U]),ie=useRef(null),le=useRef(false),q=useRef(!!f&&f<X.length),oe=P.length,ee=g[oe],Q=P.filter(Boolean);P.length>0&&Q.length===0&&Q.push(`${i} ${ee?.label}`),useEffect(()=>{let $=()=>{A(true);};return window.addEventListener("touchmove",$),()=>{window.removeEventListener("touchmove",$);}},[]);let I=useMemo(()=>Lv(p,g,l,m,y,E),[l,p,m,g,y,E]),R=useMemo(()=>{let $=_v(B),ce=Array.from(Bv(I,$)).reverse();return C?ce:P.reduce((ye,V)=>ye.filter(te=>!V||te.searchindex.indexOf(V)>-1),ce.filter(ye=>ye.type===ee?.value))},[ee,I,B,C,P]),z=useRef(null),G=es({count:O?R.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>z.current,[]),overscan:10,rangeExtractor:useCallback($=>ln($),[])}),[J,re]=useState(-1),ne=Math.min(J,R.length-1),we=useCallback($=>{let ce=P.concat($);C&&v(false),D(ce);},[C,P]),Re=useCallback(()=>{let $=P.slice(0,oe-1);C&&v(false),D($);},[C,P,oe]),_e=useCallback($=>{w($.currentTarget.value),!q.current&&p.length>0&&F(true);},[p,w,q,F]),Ae=useCallback(()=>{w(""),_([]),ie.current?.focus(),f&&(q.current=false);},[w,_,ie,f,q]),Ye=useCallback($=>{let ce=X.filter(ye=>ye!==$);_(ce),f&&ce.length<f&&(q.current=false);},[X,_,f,q]),Ne=useCallback($=>{M||j($.type),M!==$.type?(j($.type),_([$.value])):X.includes($.value)?Ye($.value):f?(X.length<f&&_([...X,$.value]),X.length===f&&_([...X.slice(1),$.value])):_([...X,$.value]),w("");},[M,j,_,X,Ye,f]),qt=useCallback(()=>{X.length>0&&B.length===0&&(_(X.slice(0,-1)),F(true),f&&(q.current=false)),B.length>0&&w(B.slice(0,-1));},[X,B,_,w,F,f,q]),Lo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$+1>=R.length?$:$+1);},[re,R]),_o=useCallback(()=>{let $=R[ne];$&&Ne($);},[R,ne,Ne]),wt=useCallback(()=>{F(false);},[F]),At=useCallback(()=>{Re(),re(0);},[re,Re]),no=useCallback(()=>{let $=R[ne];!C&&$&&$.type!==g[g.length-1]?.value&&(we($.name),re(0));},[R,ne,C,g,re,we]),Bo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$-1<0?0:$-1);},[re]),ar=({label:$,onRemove:ce,...ye})=>jsxs("div",{style:{alignItems:"center",backgroundColor:s==="dark"?"var(--mantine-color-dark-7)":"var(--mantine-color-gray-1)",borderRadius:a.radius.sm,cursor:"default",color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${a.spacing.xs} / 2 - ${rem(2)}) calc(${a.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${a.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...ye,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:ce,radius:2,size:"sm",sx:{color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",marginLeft:`calc(${a.spacing.sm} / 6)`},tabIndex:-1})]}),ze=useMemo(()=>X.map($=>I.find(ce=>ce.value===$)).filter($=>!!$).map(($,ce)=>createElement(ar,{...$,index:ce,key:$.value,onRemove:ye=>{ye.preventDefault(),ye.stopPropagation(),Ye($.value);}})),[X]),ir=forwardRef(function({color:ce,icon:ye,label:V,value:te,...ue},lt){return jsx("div",{ref:lt,style:{cursor:"pointer",width:"100%"},...ue,children:jsxs(Group,{align:"center",wrap:"nowrap",gap:"xs",w:"100%",children:[ye&&jsx(Box,{bg:ce??"transparent",component:"img",w:20,h:20,src:ye}),jsx(Text,{lineClamp:1,size:"sm",children:V||te})]})})}),{settings:lr}=e,so=e.hideLabel==="true"||!e.label?jsx(Fragment,{}):jsx(se,{component:"div",html:e.label,size:"sm",style:lr,isPreview:true});return jsx(Input.Wrapper,{label:so,children:jsxs(Popover,{closeOnClickOutside:true,keepMounted:true,opened:O,onChange:F,onClose:()=>{re(0),w("");},onOpen:()=>{G.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>re(0),sx:{position:"relative","& .defaultValue":{backgroundColor:s==="dark"?"var(--mantine-color-dark-5)":"var(--mantine-color-gray-3)",color:s==="dark"?"var(--mantine-color-dark-1)":"var(--mantine-color-gray-7)"}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:X.join(",")}),jsx(Input,{component:"div",multiline:true,onMouseDown:$=>{$.preventDefault(),!q.current&&p.length>0&&F(!O),ie.current?.focus();},rightSection:X.length>0?jsx(CloseButton,{onClick:Ae,onMouseDown:$=>$.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:a.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${a.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:s==="dark"?"var(--mantine-color-dark-3)":"var(--mantine-color-gray-5)",opacity:1}},children:[ze,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":O,onChange:_e,onKeyDown:getHotkeyHandler([["ArrowDown",Lo],["ArrowLeft",At],["ArrowRight",no],["ArrowUp",Bo],["Backspace",qt],["Enter",_o],["Escape",wt]]),placeholder:X.length===0?x:void 0,ref:ie,readOnly:q.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:a.fontSizes.sm,marginLeft:`calc(${a.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:B})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:$=>$.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:$=>$.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",gap:"xs",w:"100%",children:[g.length>1&&jsxs(Stack,{gap:"xs",children:[jsxs(Group,{onClick:$=>{$.stopPropagation();},px:"xs",justify:"center",gap:"xs",children:[jsx(Button,{onClick:()=>{re(0),v(true),D([]),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:C?"filled":"outline",children:i}),g.map(($,ce)=>jsx(Button,{onClick:()=>{C&&v(false);let ye=[""].slice(1),V=ce;for(;V--;)ye[V]=P[V]||"";re(0),D(ye),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:!C&&P.length===g.findIndex(ye=>ye.value===$?.value)?"filled":"outline",children:$?.label},$?.value))]}),jsx(Divider,{})]}),oe>0&&jsxs(Group,{align:"center",wrap:"nowrap",px:"xs",children:[jsx(ActionIcon,{onClick:Re,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:Q.map($=>jsx(Text,{lineClamp:1,size:"xs",children:$},`${$}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>A(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:z,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${G.getTotalSize()}px`,position:"relative",width:"100%"},children:G.getVirtualItems().map($=>{let ce=R[$.index],ye=ne===$.index,V=X.includes(ce.value);return R.length>0&&ye&&!W&&G.scrollToIndex(ne),jsxs(Group,{"aria-selected":ye,align:"center","data-hovered":ye||void 0,"data-index":$.index,"data-selected":V,id:ce.vale,wrap:"nowrap",onMouseEnter:te=>{te.preventDefault(),te.stopPropagation(),W&&(re($.index),A(false));},onMouseMove:te=>{te.preventDefault(),te.stopPropagation(),A(true);},onMouseDown:te=>{te.preventDefault(),Ne(ce);},justify:"space-between",ref:G.measureElement,role:"option",gap:"xs",sx:te=>({borderRadius:te.radius.xs,padding:"15px 5px 15px",paddingLeft:C&&10*g.findIndex(ue=>ue?.value===ce.type)||5,position:"absolute",top:0,left:0,height:`${$.size}px`,transform:`translateY(${$.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"},"&:hover":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"}}),tabIndex:-1,children:[jsx(ir,{index:$.index,...ce}),!C&&ce.type!==g[g.length-1]?.value&&jsx(ActionIcon,{onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),we(ce.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},ce.value)})})})]})})})})]})})}var Lv,_v,Bv,Ov,Mv,qd=b(()=>{c();Va();Ie();Kt();he();Pe();Jr();Lv=(e=[],t=[],o="",r="",n="",a="|")=>{let s=t.map(x=>x.value).slice(),i=`${s.pop()}`,l=x=>x[o],p=x=>x[r],u=x=>{if(x[n])return typeof x[n]=="string"?x[n].split(a):x[n]},d=new Set,m=[],g=[],f=nest().rollup(x=>{let y=x[0],E=w=>w&&w.value&&!d.has(w.value),L=s.map(w=>y[`${w} ID`]),k=s.map(w=>y[w]),O=s.map((w,C)=>{if(g[C]!==k[C]){g[C]=k[C];let v=l[C]||l[l.length-1]||l,P=p[C]||p[p.length-1]||p,D=u[C]||u[u.length-1]||u;return {color:v(y,w)||void 0,icon:P(y,w)||void 0,value:`${L[C]}`,label:k[C],name:k[C],type:w,searchindex:k.slice(0,C+1).concat(D(y,w)).join("|")}}return {}}).filter(E);O.forEach(w=>d.add(w.value));let F=l[l.length-1]||l,W=p[p.length-1]||p,A=u[u.length-1]||u,B=x.map(w=>({color:F(w,i)||void 0,icon:W(w,i)||void 0,value:`${w[`${i} ID`]}`,label:w[i],name:w[i],type:i,searchindex:k.concat(w[i]).concat(A(w,i)).join("|")}));m.push(...O.concat(B));});return s.forEach(x=>{f.key(y=>`${y[`${x} ID`]}|${y[x]}`);}),f.entries(e),m},_v=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},Bv=(e,t)=>{let o=e.length,r,n=i=>r&&r.searchindex.includes(i.searchindex),s={next:()=>{for(let i=o-1;i>-1;i--){let l=e[i];if(t.test(`${l.value} ${l.label} ${l.searchindex}`)||n(l))return r=l,o=i,{done:false,value:l}}return {done:true,value:void 0}},[Symbol.iterator]:()=>s};return s},Ov=e=>`multihierarchySelector${e}`,Mv=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var Wd={};Ms(Wd,{default:()=>jv});function Wv({block:e,active:t,locale:o,variables:r,configOverride:n={}}){let a=Hv(),s=qe(e),i=Ot(o),l={variables:r},p=yo(),u=useRouter(),{sectionVariables:d,setSectionVariables:m,resetSectionVariables:g}=De(e.section_id),f=useMemo(()=>{if(!t)return {error:"Activate to View"};if(!s?.logic)return {error:"Add a Configuration"};let W=pt({logic:s.logic},i,l).logic,A={router:u,section:{variables:d,setVariables:m,resetVariables:g}};return ko(W,i,r,o,e.id,{},A,p)},[s?.logic,t,r,d]),{type:x}=f.config||{},y=x&&$i[x]?x:"Treemap";x||(f.config={error:'Visualization missing "type"'}),$i[x]||(f.config={error:`"${x}" is not a valid Visualization Type`});let E=$i[y],L=f.error||f.config?.error||false;if(L)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:L},"type")});let{_data:k,...O}=f.config,F={locale:o,variables:r,...O,...n};return a.print&&(F.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(or,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(E,{style:{flex:1},dataFormat:W=>{let A;try{A=f.dataFormat(W);}catch(B){console.error("Error in dataFormat: ",B),A=[];}return A},linksFormat:f.linksFormat,nodesFormat:f.nodesFormat,topojsonFormat:f.topojsonFormat,config:{...F}},"viz-key")})})}var Hv,qv,$i,jv,jd=b(()=>{c();Do();ui();mn();zo();Pe();pi();Hv=()=>({}),qv={},$i={HTML:fn,...XT,...qv};jv=memo(Wv,(e,t)=>e.block.contentByLocale.logic.content===t.block.contentByLocale.logic.content&&e.active===t.active&&e.locale===t.locale&&JSON.stringify(e.variables)===JSON.stringify(t.variables)&&JSON.stringify(e.configOverride)===JSON.stringify(t.configOverride));});var Yv,Ue,Kd=b(()=>{c();ge();id();cd();ud();dd();gd();kd();Cd();Ad();Id();_d();Md();Nd();Dd();qd();Yv=JT(()=>Promise.resolve().then(()=>(jd(),Wd)),{ssr:false}),Ue={[h.PARAGRAPH]:fi,[h.STAT]:gi,[h.SUBTITLE]:hi,[h.TITLE]:yi,[h.SELECTOR]:Ti,[h.VIZ]:Yv,[h.GENERATOR]:Ci,[h.SECTION_FLAG]:Ci,[h.IMAGE]:wi,[h.NAV]:Ii,[h.RELATED]:_i,[h.RESET_BUTTON]:Oi,[h.COMPARISON_BUTTON]:Mi,[h.TABLE]:Fi,[h.BUTTON]:Di,[h.MULTIHIERARCHY_SELECTOR]:zi};});var Yd=b(()=>{c();ge();({[h.TITLE]:IconHeading,[h.GENERATOR]:IconApi,[h.SECTION_FLAG]:IconFlag,[h.STAT]:IconPercentage,[h.VIZ]:IconChartBar,[h.PARAGRAPH]:IconAlignLeft,[h.SELECTOR]:IconSelector,[h.IMAGE]:IconPhoto,[h.TABLE]:IconTable,[h.MULTIHIERARCHY_SELECTOR]:IconListTree});});var Xd=b(()=>{c();ge();({[h.TITLE]:"Title",[h.GENERATOR]:"Data",[h.STAT]:"Stat",[h.VIZ]:"Visualization",[h.PARAGRAPH]:"Paragraph",[h.SELECTOR]:"Selector",[h.SUBTITLE]:"Subtitle",[h.RESET_BUTTON]:"Reset Button",[h.COMPARISON_BUTTON]:"Comparison Button",[h.RELATED]:"Related Reports",[h.NAV]:"Navigation",[h.IMAGE]:"Image",[h.TABLE]:"Table",[h.BUTTON]:"Button",[h.FALLBACK]:"Fallback",[h.SECTION_FLAG]:"Section Flag",[h.MULTIHIERARCHY_SELECTOR]:"Multihierarchy Selector"});});var aR,Ui,Qd=b(()=>{c();ge();ad();Kd();Yd();Xd();aR={[h.GENERATOR]:{type:h.GENERATOR,renderer:Ue[h.GENERATOR],renderPreviewOnEdit:false},[h.SECTION_FLAG]:{type:h.SECTION_FLAG,renderer:Ue[h.SECTION_FLAG],renderPreviewOnEdit:false},[h.IMAGE]:{type:h.IMAGE,renderer:Ue[h.IMAGE],renderPreviewOnEdit:false},[h.PARAGRAPH]:{type:h.PARAGRAPH,renderer:Ue[h.PARAGRAPH],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RELATED]:{type:h.RELATED,renderer:Ue[h.RELATED],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.SELECTOR]:{type:h.SELECTOR,renderer:Ue[h.SELECTOR],adapter:hn[h.SELECTOR],nonActiveAdapter:()=>hn[h.SELECTOR]({name:"Selector Preview"}),renderPreviewOnEdit:false},[h.STAT]:{type:h.STAT,renderer:Ue[h.STAT],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.SUBTITLE]:{type:h.SUBTITLE,renderer:Ue[h.SUBTITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TITLE]:{type:h.TITLE,renderer:Ue[h.TITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.VIZ]:{type:h.VIZ,renderer:Ue[h.VIZ],renderPreviewOnEdit:false},[h.NAV]:{type:h.NAV,renderer:Ue[h.NAV],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RESET_BUTTON]:{type:h.RESET_BUTTON,renderer:Ue[h.RESET_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.COMPARISON_BUTTON]:{type:h.COMPARISON_BUTTON,renderer:Ue[h.COMPARISON_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TABLE]:{type:h.TABLE,renderer:Ue[h.TABLE],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.BUTTON]:{type:h.BUTTON,renderer:Ue[h.BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.MULTIHIERARCHY_SELECTOR]:{type:h.MULTIHIERARCHY_SELECTOR,renderer:Ue[h.MULTIHIERARCHY_SELECTOR],adapter:hn[h.MULTIHIERARCHY_SELECTOR],nonActiveAdapter:()=>hn[h.MULTIHIERARCHY_SELECTOR]({label:"Multihierarchy Selector Preview"}),renderPreviewOnEdit:false}},Ui=aR;});function Rs({blockId:e,active:t=true,asComparison:o=false}){let{query:r,locale:n=bt}=useRouter(),a=nt(),s=Tt(e).data,i=Tr(e,o&&a.active?a?.variables.variables:void 0,o&&a.active?a?.variables.attributes:void 0),l=qe(s,n),p=Ot(n),u={variables:i,query:r,locale:n},d=K(E=>E.variables.variables[s.id]||{}),m=K(E=>E.variables.status[s.id]||{}),[g,f]=useState(()=>{if(![h.GENERATOR,h.VIZ,h.NAV].includes(s.type)){if(s?.type===h.SELECTOR){let k=qe(s,n),{config:O}=fr(s.id,k?.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.MULTIHIERARCHY_SELECTOR){let k=qe(s,n),{config:O}=gr(s.id,k.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.RESET_BUTTON)return {...l.simple,id:s.id,section:s.section_id};if(s?.type===h.COMPARISON_BUTTON)return {...l.simple,id:s.id,section:s.section_id};let E=st(l?.logic,p,u),{vars:L}=Lt("variables",i,E,p,void 0,u);return L}return null});useEffect(()=>{(async()=>{if(!s||s.type===h.GENERATOR)return;if(s.type===h.VIZ){f({block:s,locale:n,variables:i,active:t});return}if(!t&&!Ui[s.type].evalWhenNonActive){let{nonActiveAdapter:O}=Ui[s.type],F=O&&typeof O=="function"?O():{};f(F);return}if(s.type===h.GENERATOR){f({outputVariables:d});return}if(h.SELECTOR===s.type){let O=qe(s,n),{config:F}=fr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(h.MULTIHIERARCHY_SELECTOR===s.type){let O=qe(s,n),{config:F}=gr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(s.type===h.RELATED){let{related_reports:O}=d;f({related_reports:O});return}if(s.type===h.RESET_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.COMPARISON_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.FALLBACK){f({id:s.id,type:s.original_type,roles:s.settings.access});return}let L=st(l?.logic,p,u),{vars:k}=Lt("variables",i,L,p,void 0,u);if(s.type===h.TABLE){f({sectionId:s.section_id,...k});return}if(s.type===h.NAV){f({id:s.id,headings:s.inputs,section:s.section_id,settings:s.settings,...k});return}f(k);})();},[l,i]);let x=m.allowed||s?.type===h.NAV;if(!s||!g||!x)return null;let y=Ju[s.type];return jsx("div",{id:`bespoke-${s.type}-${s.id}`,className:`cms-block-wrapper bespoke-block-area cms-block-${e}`,children:jsx(y,{...g,settings:s.settings,asComparison:o})})}var Jd=b(()=>{c();ge();ed();Qd();zo();Pe();mr();qr();Dn();Hs();Ws();eo();});var em,pR,tm,Es,ks=b(()=>{c();em={margin:{label:"Content Margin",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},columnGutter:{label:"Column Gutter",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},width:{label:"Width",defaultValue:"full",options:[{label:"Full Width",value:"full"},{label:"Center",value:"center"}]},position:{label:"Position",defaultValue:"normal",options:[{label:"Normal",value:"normal"},{label:"Sticky",value:"sticky"}]},style:{label:"Style",defaultValue:"none",options:[{label:"None",value:"none"},{label:"Card",value:"card"}]}},pR=Object.keys(em).reduce((e,t)=>(e[t]=em[t].defaultValue,e),{}),tm={memberImageBg:false,optionsMenu:false,optionData:true,optionImage:true,optionShare:true,showAnchor:false,...pR},Es=e=>({data:typeof e.optionData=="boolean"?e.optionData:true,image:typeof e.optionImage=="boolean"?e.optionImage:true,share:typeof e.optionShare=="boolean"?e.optionShare:true});});function om({previews:e}){let t=e.map((o,r)=>({key:o?`bg-${o.content_id}`:`bg-${r}`,src:o?`/api/cms/member/image?member=${o.content_id}&size=splash`:""}));return jsxs(Fragment,{children:[jsx(Group,{className:"cms-section-bg",grow:true,gap:0,style:{position:"absolute",width:"100%",height:"100%"},children:t.map(o=>jsx("div",{className:"cms-section-member-bg",style:{backgroundImage:`url(${o.src})`,backgroundSize:"cover",backgroundPosition:"center center",height:"100%",width:"100%"}},o.key))}),jsx("div",{className:"cms-section-gradient-bg",style:{background:"white",position:"absolute",width:"100%",height:"100%",opacity:.33}})]})}var rm=b(()=>{c();});function nm({direction:e,onClick:t,visible:o}){return o?jsx(ActionIcon,{className:`bespoke-sortable-table-arrow bespoke-sortable-table-arrow-${e}`,variant:"filled",size:"md",sx:{position:"absolute",top:"50%",[e==="left"?"left":"right"]:"16px",zIndex:10,opacity:.55,"&:hover":{opacity:1}},onClick:t,children:e==="left"?jsx(IconArrowLeft,{size:16}):jsx(IconArrowRight,{size:16})}):null}function sm({data:e}){let t=useRef(null),[o,r]=useState(false),[n,a]=useState(false),[s,i]=useState(false),l=useMemo(()=>(e&&Array.isArray(e)&&e[0]?Object.keys(e[0]):[]).filter(d=>!d.startsWith("_")).map(d=>({accessorKey:d,header:d,enableSorting:true})),[e]);return useEffect(()=>{let p=()=>{if(t.current){let{scrollWidth:u,clientWidth:d,scrollLeft:m}=t.current;r(u>d),a(m>0),i(m+d<u-1);}};return p(),window.addEventListener("resize",p),t.current?.addEventListener("scroll",p),()=>{window.removeEventListener("resize",p),t.current?.removeEventListener("scroll",p);}},[e]),jsxs("div",{className:"bespoke-sortable-table",style:{position:"relative"},children:[jsx(MantineReactTable,{columns:l,data:e,enableBottomToolbar:false,enableColumnActions:false,enablePagination:false,enableSorting:true,enableTopToolbar:false,layoutMode:"grid",enableStickyHeader:true,initialState:{density:"xs"},mantineTableProps:{sx:{tableLayout:"fixed"}},mantineTableContainerProps:{ref:t,sx:{minHeight:100,maxHeight:350,overflowX:"auto"}},mantineTableBodyCellProps:{p:"5px !important",sx:{textWrap:"wrap"}},defaultColumn:{minSize:50,maxSize:150}}),jsx(nm,{direction:"left",visible:o&&n,onClick:()=>{t.current&&t.current.scrollBy({left:-150,behavior:"smooth"});}}),jsx(nm,{direction:"right",visible:o&&s,onClick:()=>{t.current&&t.current.scrollBy({left:150,behavior:"smooth"});}})]})}var am=b(()=>{c();});function Vr(e){let t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"," ":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),a=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(a)?a.replace(n,s=>t[s]):a}var qi=b(()=>{c();});function Wi(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var im=b(()=>{c();});function RR(e){return e?vR(Wi(Vr(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var oo,Tn=b(()=>{c();qi();im();oo=RR;});function mm(e){let{section:t}=e,o=zt(),r=useRouter(),n=K(I=>I.status.isCMS),a=K(I=>I.status.currentLocale),s=r.locale,i=n?a:s,l=50,p=Ot(i),u=yo(),d=Le("options"),m={...Zi,...d.data_tab},[g,f]=useState([]),[x,y]=useState([]),[E,L]=useState(),[k,O]=useState(),[F,W]=useState(false),[A,B]=useState({}),[w,C]=useState(true),[v,P]=useState(true),{sectionVariables:D,setSectionVariables:N,resetSectionVariables:H}=De(t.id),X=t.blocks||[],M=K(I=>({records:I.records,variables:I.variables})),U=useMemo(()=>X.reduce((I,R)=>{let z=M.records.entities.block[R],G=M.variables.variables[R],J=M.variables.status[R];return (h.GENERATOR===z.type&&G._downloadEnabled===true&&J.allowed||h.VIZ===z.type&&J.allowed)&&(I[R]={entity:z,variables:M.variables.variables[R],status:M.variables.status[R],inputVariablesFlat:z.inputs.reduce((re,ne)=>({...re,...M.variables.variables[ne]}),M.variables.attributes)}),I},{}),[X]),_=I=>{y(R=>R.includes(I)?R:[...R,I]);},j=I=>{f(R=>(R.find(G=>G.ix===I.ix)?R:[...R,I]).sort((G,J)=>G.ix>J.ix?1:-1));};function ie(I){!E&&I[0]&&le(I[0]);}function le(I){L(I),O("0");}useEffect(()=>{let I=async(R,z,G)=>{let J=dataLoad.bind({});return new Promise((re,ne)=>{J(z,null,null,(we,Re)=>{if(we)ne(we);else {let _e=G instanceof Function?G(Re):Re;R.data.unshift(_e),j(R),re(Re);}});})};if(g.length===0&&x.length===0){let R=0;for(let z of Object.values(U)){let G=z.entity;if([h.GENERATOR,h.SECTION_FLAG].includes(G.type)){let J=z.variables._downloadData||z.variables._downloadUrl||z.status.api;if(J){let re=[];typeof J=="string"?re=J.split("|||"):re=[J],re=hs(re,u);let ne=z.variables._downloadTitle||`${m.data_source} ${R+1}`,we=z.variables._downloadFileName||ne;j({ix:R,id:G.id,title:Vr(ne),fileName:we,data:Array.isArray(re)?re:[re],loading:false,type:h.GENERATOR}),_(R),R++;}}else if(G.type===h.VIZ){let J=qe(G),re=z.inputVariablesFlat,ne={variables:re},we=pt({logic:J.logic},p,ne).logic,Re={router:r,section:{variables:D,setVariables:N,resetVariables:H}},_e=ko(we,p,re,i,G.id,{},Re,u),Ae=_e.config._downloadTitle||_e.config.title||`${m.viz_source} ${R+1}`,Ye=_e.config._downloadFileName||Ae;if(_e.config._downloadEnabled!==false)try{let Ne=_e.config._downloadUrl||_e.config.data,qt=typeof Ne=="string"?[Ne]:Ne,Lo=_e.dataFormat instanceof Function?_e.dataFormat:!1,_o=_e.config._downloadDataFormat instanceof Function?_e.config._downloadDataFormat:!1;I({ix:R,id:G.id,title:Vr(Ae),fileName:Ye,data:qt,loading:!1,type:h.VIZ},Ne,_o||Lo),_(R),R++;}catch(Ne){console.error("DataLoad catch",Ne);}}}P(false);}},[U]),useEffect(()=>{g.length===x.length&&ie(g);},[g]),useEffect(()=>{if(E&&k){let I=parseInt(k,10);if(E.data[I]&&(!A[E.ix]||!A[E.ix][k])){C(true);let R=E.data[k];typeof R=="string"?Xs(R,o,i,[],void 0).then(z=>{let G=UR(z);B({...A,[E.ix]:{...A[E.ix],[I]:G}});}).catch(z=>{console.error(z);}).finally(()=>{C(false);}):(B({...A,[E.ix]:{...A[E.ix],[I]:R}}),C(false));}}},[k,E]);let q=(I,R)=>{let z=I===R?"":`-${I}`.toLowerCase();if(E){let G=E.data.length>1&&k?`-${parseInt(k,10)+1}`:"";return `${oo(E.fileName)}${z}${G}.${R.toLowerCase()}`}return `${z}.${R}`},oe=async I=>{if(E){W(true);let R=new AR,z=q(I,I);try{switch(I){case Cs.json.extension:R.file(z,JSON.stringify(ee));break;case Cs.csv.extension:R.file(z,csvFormat(ee));break;case Cs.xlsx.extension:{let{utils:G,write:J}=await import('xlsx'),re=G.book_new();G.book_append_sheet(re,G.json_to_sheet(ee),z.substring(0,30));let ne=J(re,{bookType:"xlsx",bookSST:!0,type:"binary"});R.file(z,ne,{binary:!0});break}default:break}R.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(G=>{W(!1),saveAs(G,q(I,"zip"));});}catch(G){console.error(m.error_generating,G),W(false);}}},ee=useMemo(()=>E&&A[E.ix]&&A[E.ix][k]?A[E.ix][k]:[],[A,E,k]),Q=useMemo(()=>{if(g&&g.length>0&&g.length===x.length){let I=g.map(R=>({value:`${R.ix}`,label:R.title}));return jsx(Select,{disabled:!E,style:{flex:"1"},value:`${E?.ix}`,onChange:R=>{let z=g.find(G=>`${G.ix}`===R);le(z);},data:I,icon:jsx(IconDatabase,{size:16})})}else return ""},[g,E,x]);return jsxs(Stack,{className:"cms-section-options-data",gap:"xs",py:"xs",children:[jsx(LoadingOverlay,{visible:v,overlayProps:{blur:2}}),g.length===0&&!v&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:m.no_data_src}),g.length>1&&g.length===x.length&&!v&&jsx(Input.Wrapper,{label:`${m.choose_data_src}:`,children:jsx(Group,{gap:"xs",children:Q})}),E&&k&&jsx(Stack,{gap:"xs",children:jsx(Input.Wrapper,{label:`${m.preview}
|
|
15
|
+
a viverra sapien pulvinar.`,style:o,append:t?jsx($e,{content:t,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{}),isPreview:true})}var id=b(()=>{c();Qt();Ie();});function gi({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:a,_iconVariant:s,_icon:i,_iconRadius:l,_iconSize:p,_iconPadding:u}){let d=t||"<span class='cr-block-placeholder'>Title</span>",m=o||"<span class='cr-block-placeholder'>Big Stat</span>",g=e||"<span class='cr-block-placeholder'>Subtitle</span>",f=n&&n.align||"left";return jsx("div",{className:"bespoke-Stat-root",children:jsxs(Group,{className:"bespoke-StatGroup-wrapper",position:We(f),children:[a!=="none"&&a&&jsx(be,{blockType:"stat",iconType:a,iconVariant:s,iconRadius:l,iconSize:p,icon:i,iconPadding:u}),jsxs("div",{className:"bespoke-Stat-wrapper",children:[jsx(se,{component:"div",size:"md",html:d,style:n,isPreview:true}),jsx(se,{component:"div",size:"xl",html:m,style:n,isPreview:true}),jsx(se,{component:"div",size:"sm",html:g,style:n,isPreview:true})]},"stat"),r&&jsx($e,{content:r})]})})}var cd=b(()=>{c();Qt();Jt();Ie();je();});function hi({subtitle:e,tooltip:t,settings:o}){let r=ve(e)||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{gap:"sm",position:We(n),children:[jsx(se,{size:"sm",html:r,isPreview:true}),t&&jsx($e,{content:t,style:{display:"inline-flex"}})]})}var ud=b(()=>{c();Qt();Yt();Ie();je();});function yi({title:e,tooltip:t,_iconType:o,_iconVariant:r,_icon:n,settings:a,_iconRadius:s,_iconSize:i,_iconPadding:l}){let p=ve(e)||"Title",u=a&&a.order?parseInt(a.order,10):1,d=u<=6?u:1,m=!!(a&&a.search&&a.search!=="off"),g=a&&a.search?a.search:"",f=a&&a.align?a.align:"left";return jsxs(Group,{gap:"sm",justify:We(f),children:[o!=="none"&&o&&jsx(be,{blockType:"title",iconType:o,iconVariant:r,iconRadius:s,iconSize:i,icon:n,iconPadding:l}),jsx(se,{component:"h",order:d,style:a,html:p,isPreview:true}),m&&jsx(Tooltip,{label:`Click will open '${g}' report search`,children:jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})}),t&&jsx($e,{content:t})]})}var dd=b(()=>{c();Qt();Yt();Jt();Ie();je();});function Ti(e){let{id:t,type:o,defaultValue:r,options:n,name:a,settings:s,hideLabel:i,component:l,resetSectionVars:p,section:u}=e,d=Te(),m=useContext(Mt),g=K(v=>v.status.query),{sectionVariables:f,resetSectionVariables:x}=De(u),y=Rx(t),E=useMemo(()=>g[y]||r,[g[y],o,r]),L=useMemo(()=>Ex(g[y],r),[g[y],o,r]),[k,O]=useState(n?.map(v=>({value:v.id,label:v.label,imageUrl:v.imageUrl}))||[]),[F,W]=useState((n||[]).map(v=>v.id).join("-"));useEffect(()=>{let v=(n||[]).map(N=>`${N.label}|${N.id}`).join("-");if(F===v)return;W(v);let P=(n||[]).map(N=>({value:N.id,label:N.label}));O(P);let D=o===Be.SINGLE?E:L;Vo(o,D,n||[])||d(sa(m,y));},[JSON.stringify(n),t]);let A=()=>{p==="true"&&f&&x();},B=v=>{d(Wo(m,y,v)),A();},w=v=>{d(Wo(m,y,v.join())),A();},C=i==="true"?jsx(Fragment,{}):jsx(se,{component:"div",html:a,size:"sm",style:s,isPreview:true});return k.length===0?jsx(Text,{c:"dimmed",size:"xs",children:"No options defined yet. Selector hidden in report."}):k.length===1?jsxs(Text,{c:"dimmed",size:"xs",children:["Only one option defined. Selector hidden in report. ",JSON.stringify(k)]}):{[Be.SINGLE]:l===Ln.SEGMENTED_CONTROL?jsxs("div",{children:[C,jsx(SegmentedControl,{data:k,value:k.map(v=>v.value).includes(E)?E:"",onChange:B,fullWidth:true})]}):jsx(Select,{label:C,data:k,value:E,onChange:B,renderOption:v=>jsx(kx,{...v}),styles:{label:{display:i==="true"?"none":"block"}}}),[Be.MULTI]:jsx(MultiSelect,{label:C,data:k,value:L,onChange:w,styles:{label:{display:i==="true"?"none":"block"}}})}[o]}var Rx,Ex,kx,gd=b(()=>{c();Jr();_n();ge();he();Kt();Ie();Pe();Rx=e=>`selector${e}id`,Ex=(e,t)=>e&&typeof e=="string"?e.split(","):t,kx=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{wrap:"nowrap",children:[t&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});var hd=b(()=>{});function Ei({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:a=0}){let s=useMantineTheme(),[i,l]=useState(false);if(a===Ri)return null;let p=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),u=vi(r),d=r,m=JSON.stringify(d),g=100,f=1e3,x=!!(m&&m.length>g),y=10,E={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(u==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,c:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:a+1<Ri?Object.keys(r).sort((L,k)=>{let O=vi(r[L]),F=vi(r[k]);return O!==F?bd.indexOf(O)-bd.indexOf(F):L.localeCompare(k)}).map(L=>jsx(Ei,{root:false,label:L,value:r[L],level:a+1},L)):p})]})});if(u==="array"){let L=r.length>y,k=L?r.slice(0,y):r,O=L?r.length-y:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:E,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",fw:700,p:0,color:e?"dimmed":s.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[a+1<Ri?k.map((F,W)=>jsx(Ei,{root:false,label:W,value:F,level:a+1,parentIsArray:true},W)):p,L&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",O," other elements]"]})]})]})})}return u==="string"?d=x?`"${d.substring(0,g)} ... "`:`"${d}"`:u==="error"?d=`Error: ${d.message}`:u==="undefined"?d=u:d.toString&&(d=d.toString()),jsxs(Group,{wrap:"nowrap",gap:0,justify:"space-between",children:[jsx(Tooltip,{label:"Copied!",opened:i,closeDelay:1e3,children:jsx(Text,{c:e?"dimmed":s.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap",cursor:"pointer"},onClick:()=>{let L=o?`{{${t}}}`:n?`[${t}]`:t;navigator.clipboard.writeText(L),l(true),setTimeout(()=>l(false),1e3);},fw:700,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Tooltip,{label:d,children:jsx(CodeHighlight,{className:"cr-variable",code:d,language:"jsx",withCopyButton:false,styles:L=>({codeHighlight:{textAlign:"right",overflow:"hidden",width:"fit-content",flex:"0 1 auto"},code:{padding:"5px 0 5px 5px",fontSize:L.fontSizes.xs},pre:{marginLeft:"5px",marginTop:"0px",marginBottom:"0px"},showCodeButton:{display:"none"}})})}),x&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,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:m.substring(0,f)})})]})]})}var vi,bd,Ri,Sd,Td=b(()=>{c();hd();vi=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},bd=["object","array","string","number"],Ri=5;Sd=Ei;});var xd,vd=b(()=>{c();xd=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function Mx({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let a=Tt(t==="attributes"?null:t).data,s=a?a.type:"block",i=a?.type&&a?.id?`${a.type}${a.id}`:"",l=Object.keys(o).filter(r?()=>true:p=>!xd(i)(p));return jsx(Stack,{gap:0,children:l.length?l.map(p=>jsx(Sd,{dimmed:e.includes(p),label:p,value:o[p]},p)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${s}`})})})}var Rd,Ed=b(()=>{c();Td();he();vd();Rd=Mx;});function Hx({outputVariables:e,status:t,hasAPI:o=false,debug:r,type:n}){let[a,s]=useState(false),i=o&&!Object.keys(e).length&&!t.error,l=Object.keys(e).some(u=>u.startsWith("_"));return r?i?jsxs(Stack,{align:"center",children:[jsx(Loader,{}),jsxs(Text,{size:"sm",children:["Loading ",n]})]}):jsxs(Fragment,{children:[jsx(Divider,{label:"Output Variables",labelPosition:"center"}),l&&jsx(Switch,{label:"Show internal variables",mb:"xs",size:"xs",checked:a,onChange:u=>s(u.currentTarget.checked)}),jsx(Rd,{variables:e,showInternal:a})]}):jsx(Center,{children:jsx(Badge,{color:"gray",variant:"outline",children:n.toUpperCase()},"type")})}var Ci,kd=b(()=>{c();Ed();Ci=Hx;});function wi(e){let{alt:t,src:o,desc:r,title:n,settings:a,...s}=e,i=ve(t),l=ve(o),p=ve(r),u=jsx("img",{src:l,alt:i,style:s}),d=a&&a.align?String(a.align):"left";return (p&&p.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:ot(d),gap:"sm",children:[n&&jsx(se,{component:"p",html:n,style:a,isPreview:true}),u,r&&jsx(se,{component:"p",size:"sm",html:r,style:a,isPreview:true})]})),l&&i?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var Cd=b(()=>{c();Yt();Ie();je();});function Ii({headings:e,settings:t,title:o,shortTitle:r,_iconType:n,_iconVariant:a,_icon:s,_iconRadius:i,_iconSize:l,_iconPadding:p}){let{min:u="1",max:d="6",icons:m="yes"}=t||{},g=ve(o)||"",f=ve(r||o)||"",x=g&&g.length>0,y=n&&n!=="none",E=f===g?`${g}`:`${g} (${f})`,L=Pr(parseInt(u,10),parseInt(d,10),e),k=m==="yes",O=t&&t.align?String(t.align):"left",F=Rr(O),W=We(O),A=ot(O),B=t&&t.titlePosition?String(t.titlePosition):"left",w=useMemo(()=>{let v={right:"left",left:"right"},P=x&&["left","right"].includes(B),D={};if(P){let N=B==="right";D={gap:"xs",justify:N&&v[W]?v[W]:W,style:{flexDirection:N?"row-reverse":"row"},wrap:"nowrap"};}else D={gap:"xs",align:A,justify:"center",style:{flexDirection:B==="bottom"?"column-reverse":"column"}};return {element:P?Group:Stack,props:D}},[x,W,A,B]),C=v=>!v||!v?.length?null:jsx(Fragment,{children:v.map(P=>jsxs(Fragment$1,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${P.id}`,children:jsxs(Group,{gap:"sm",children:[k&&jsx(be,{...P.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:P.label}})]})})},P.id),jsx(Box,{pl:"xs",children:C(P.children)})]},P.id))});return jsxs(w.element,{pos:"relative",...w.props,children:[x&&jsxs(Group,{gap:"xs",position:W,wrap:"nowrap",children:[y&&jsx(be,{blockType:"title",iconType:n,iconVariant:a,iconRadius:i,iconSize:l,icon:s,iconPadding:p}),jsx(se,{style:t,html:E,isPreview:true,lineClamp:1})]}),jsxs(List,{sx:v=>({display:"flex",gap:v.spacing.md,justifyContent:F,alignItems:"center",listStyleType:"none"}),children:[L?.map(v=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:400,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${v.id}`,children:jsxs(Group,{gap:"sm",wrap:"nowrap",children:[k&&jsx(be,{blockType:"nav",...v.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:v.label}})]})})}),v?.children?.length?jsx(Menu.Dropdown,{children:C(v.children)}):null]})},v.id)),!L||L.length===0&&jsx(List.Item,{children:jsx(Text,{color:"dimmed",children:"- Include some titles as inputs to see the Nav component -"})})]})]})}var Ad=b(()=>{c();Qa();Jt();je();Ie();Jt();Yt();});function _i(e){let{related_reports:t,settings:o}=e;if(!t?.length)return jsx(Text,{children:"There are no available members related to your current selection and report."});let r=Rr(o&&o.align?String(o.align):"left");return jsx(List,{sx:()=>({display:"flex",justifyContent:r,"& li":{marginRight:"1rem"}}),children:t.map(n=>jsx(List.Item,{children:n.entities.map(a=>a.name).join(" & ")},n.link))})}var Id=b(()=>{c();je();});function Oi({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:a}){let s=Tt(e).data,{sectionVariables:i,resetSectionVariables:l}=De(s?.section_id),p=!!Object.keys(i).length,u=ot(o&&o.align?o.align:"left");return jsxs(Stack,{align:u,children:[!p&&!a&&jsx(Text,{size:"xs",ta:o?.align||"left",children:"Reset button will not be shown on its disabled state"}),jsx(Button,{onClick:()=>l(),disabled:!p,fullWidth:n,children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})]})}var _d=b(()=>{c();Pe();Pe();je();});function Mi({settings:e,label:t,showIcon:o,position:r="center"}){let n=e&&e.search?e.search:"";return jsxs(Group,{position:r,children:[jsx(Tooltip,{label:`Click will open '${n}' report search`,children:jsx(Button,{children:jsxs(Group,{align:"center",children:[t||"Comparison Button",o&&jsx(IconPlus,{})]})})}),jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})]})}var Md=b(()=>{c();});function Fi({columns:e=[],id:t,data:o=[],tableProps:r={}}){let[n,a]=useState({}),{initialState:s}=r,i=s?.pagination?.pageIndex,l=s?.pagination?.pageSize,p=`table-${[t,i,l].filter(f=>f).join("-")}`,u=useMemo(()=>e.map(f=>f.accessorKey),[e]),d=useMemo(()=>o.filter(f=>typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).some(x=>u.includes(x))),[u,o]),m=useMemo(()=>e.map(f=>({...f,Cell:({renderedCellValue:x})=>jsx(se,{html:`${x}`,isPreview:true}),filterFn:"contains"})),[e]),g=kc();return useEffect(()=>{(async()=>{try{let y=`${(g||"en").toUpperCase()}`;a({});}catch(x){console.error("Error loading translations:",x);}})();},[g]),createElement(MantineReactTable,{...r,autoResetPageIndex:false,columns:m,data:d,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",key:p,layoutMode:"grid",localization:n,state:{...r.state,isFullScreen:false}})}var Nd=b(()=>{c();Ie();Pe();});function Di({label:e,url:t,settings:o}){let{align:r}=o;return jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})})}var Dd=b(()=>{c();});function zi(e){let t=Te(),o=useContext(Mt),r=K($=>$.status.query),n=Ov(e.id),a=useMantineTheme(),{colorScheme:s}=useMantineColorScheme(),{allLabel:i,colorKey:l,data:p,defaultValue:u,defaultValueType:d,iconKey:m,levels:g,limit:f,placeholder:x,searchIndexKey:y,searchIndexSeparator:E,resetSectionVars:L,section:k}=e,[O,F]=useState(false),[W,A]=useState(true),[B,w]=useState(""),[C,v]=useState(false),[P,D]=useState([""].slice(1)),{sectionVariables:N,resetSectionVariables:H}=De(k),X=useMemo(()=>Mv(r[`${n}-value`],u),[r,u,n]),M=useMemo(()=>r[`${n}-type`]||d,[r,d,n]),U=useCallback(()=>{L==="true"&&N&&H();},[L,N,H]),_=useCallback($=>{U(),t(Wo(o,`${n}-value`,$.join()));},[t,o,n,U]),j=useCallback($=>{U(),t(Wo(o,`${n}-type`,$));},[t,o,n,U]),ie=useRef(null),le=useRef(false),q=useRef(!!f&&f<X.length),oe=P.length,ee=g[oe],Q=P.filter(Boolean);P.length>0&&Q.length===0&&Q.push(`${i} ${ee?.label}`),useEffect(()=>{let $=()=>{A(true);};return window.addEventListener("touchmove",$),()=>{window.removeEventListener("touchmove",$);}},[]);let I=useMemo(()=>Lv(p,g,l,m,y,E),[l,p,m,g,y,E]),R=useMemo(()=>{let $=_v(B),ce=Array.from(Bv(I,$)).reverse();return C?ce:P.reduce((ye,V)=>ye.filter(te=>!V||te.searchindex.indexOf(V)>-1),ce.filter(ye=>ye.type===ee?.value))},[ee,I,B,C,P]),z=useRef(null),G=es({count:O?R.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>z.current,[]),overscan:10,rangeExtractor:useCallback($=>ln($),[])}),[J,re]=useState(-1),ne=Math.min(J,R.length-1),we=useCallback($=>{let ce=P.concat($);C&&v(false),D(ce);},[C,P]),Re=useCallback(()=>{let $=P.slice(0,oe-1);C&&v(false),D($);},[C,P,oe]),_e=useCallback($=>{w($.currentTarget.value),!q.current&&p.length>0&&F(true);},[p,w,q,F]),Ae=useCallback(()=>{w(""),_([]),ie.current?.focus(),f&&(q.current=false);},[w,_,ie,f,q]),Ye=useCallback($=>{let ce=X.filter(ye=>ye!==$);_(ce),f&&ce.length<f&&(q.current=false);},[X,_,f,q]),Ne=useCallback($=>{M||j($.type),M!==$.type?(j($.type),_([$.value])):X.includes($.value)?Ye($.value):f?(X.length<f&&_([...X,$.value]),X.length===f&&_([...X.slice(1),$.value])):_([...X,$.value]),w("");},[M,j,_,X,Ye,f]),qt=useCallback(()=>{X.length>0&&B.length===0&&(_(X.slice(0,-1)),F(true),f&&(q.current=false)),B.length>0&&w(B.slice(0,-1));},[X,B,_,w,F,f,q]),Lo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$+1>=R.length?$:$+1);},[re,R]),_o=useCallback(()=>{let $=R[ne];$&&Ne($);},[R,ne,Ne]),wt=useCallback(()=>{F(false);},[F]),At=useCallback(()=>{Re(),re(0);},[re,Re]),no=useCallback(()=>{let $=R[ne];!C&&$&&$.type!==g[g.length-1]?.value&&(we($.name),re(0));},[R,ne,C,g,re,we]),Bo=useCallback(()=>{A($=>$&&(le.current=$,!$)),re($=>$-1<0?0:$-1);},[re]),ar=({label:$,onRemove:ce,...ye})=>jsxs("div",{style:{alignItems:"center",backgroundColor:s==="dark"?"var(--mantine-color-dark-7)":"var(--mantine-color-gray-1)",borderRadius:a.radius.sm,cursor:"default",color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${a.spacing.xs} / 2 - ${rem(2)}) calc(${a.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${a.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...ye,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:ce,radius:2,size:"sm",sx:{color:s==="dark"?"var(--mantine-color-dark-0)":"var(--mantine-color-gray-7)",marginLeft:`calc(${a.spacing.sm} / 6)`},tabIndex:-1})]}),ze=useMemo(()=>X.map($=>I.find(ce=>ce.value===$)).filter($=>!!$).map(($,ce)=>createElement(ar,{...$,index:ce,key:$.value,onRemove:ye=>{ye.preventDefault(),ye.stopPropagation(),Ye($.value);}})),[X]),ir=forwardRef(function({color:ce,icon:ye,label:V,value:te,...ue},lt){return jsx("div",{ref:lt,style:{cursor:"pointer",width:"100%"},...ue,children:jsxs(Group,{align:"center",wrap:"nowrap",gap:"xs",w:"100%",children:[ye&&jsx(Box,{bg:ce??"transparent",component:"img",w:20,h:20,src:ye}),jsx(Text,{lineClamp:1,size:"sm",children:V||te})]})})}),{settings:lr}=e,so=e.hideLabel==="true"||!e.label?jsx(Fragment,{}):jsx(se,{component:"div",html:e.label,size:"sm",style:lr,isPreview:true});return jsx(Input.Wrapper,{label:so,children:jsxs(Popover,{closeOnClickOutside:true,keepMounted:true,opened:O,onChange:F,onClose:()=>{re(0),w("");},onOpen:()=>{G.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>re(0),sx:{position:"relative","& .defaultValue":{backgroundColor:s==="dark"?"var(--mantine-color-dark-5)":"var(--mantine-color-gray-3)",color:s==="dark"?"var(--mantine-color-dark-1)":"var(--mantine-color-gray-7)"}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:X.join(",")}),jsx(Input,{component:"div",multiline:true,onMouseDown:$=>{$.preventDefault(),!q.current&&p.length>0&&F(!O),ie.current?.focus();},rightSection:X.length>0?jsx(CloseButton,{onClick:Ae,onMouseDown:$=>$.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:a.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${a.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:s==="dark"?"var(--mantine-color-dark-3)":"var(--mantine-color-gray-5)",opacity:1}},children:[ze,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":O,onChange:_e,onKeyDown:getHotkeyHandler([["ArrowDown",Lo],["ArrowLeft",At],["ArrowRight",no],["ArrowUp",Bo],["Backspace",qt],["Enter",_o],["Escape",wt]]),placeholder:X.length===0?x:void 0,ref:ie,readOnly:q.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:a.fontSizes.sm,marginLeft:`calc(${a.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:B})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:$=>$.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:$=>$.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",gap:"xs",w:"100%",children:[g.length>1&&jsxs(Stack,{gap:"xs",children:[jsxs(Group,{onClick:$=>{$.stopPropagation();},px:"xs",justify:"center",gap:"xs",children:[jsx(Button,{onClick:()=>{re(0),v(true),D([]),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:C?"filled":"outline",children:i}),g.map(($,ce)=>jsx(Button,{onClick:()=>{C&&v(false);let ye=[""].slice(1),V=ce;for(;V--;)ye[V]=P[V]||"";re(0),D(ye),R.length>0&&G.scrollToIndex(0);},size:"xs",variant:!C&&P.length===g.findIndex(ye=>ye.value===$?.value)?"filled":"outline",children:$?.label},$?.value))]}),jsx(Divider,{})]}),oe>0&&jsxs(Group,{align:"center",wrap:"nowrap",px:"xs",children:[jsx(ActionIcon,{onClick:Re,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:Q.map($=>jsx(Text,{lineClamp:1,size:"xs",children:$},`${$}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>A(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:z,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${G.getTotalSize()}px`,position:"relative",width:"100%"},children:G.getVirtualItems().map($=>{let ce=R[$.index],ye=ne===$.index,V=X.includes(ce.value);return R.length>0&&ye&&!W&&G.scrollToIndex(ne),jsxs(Group,{"aria-selected":ye,align:"center","data-hovered":ye||void 0,"data-index":$.index,"data-selected":V,id:ce.vale,wrap:"nowrap",onMouseEnter:te=>{te.preventDefault(),te.stopPropagation(),W&&(re($.index),A(false));},onMouseMove:te=>{te.preventDefault(),te.stopPropagation(),A(true);},onMouseDown:te=>{te.preventDefault(),Ne(ce);},justify:"space-between",ref:G.measureElement,role:"option",gap:"xs",sx:te=>({borderRadius:te.radius.xs,padding:"15px 5px 15px",paddingLeft:C&&10*g.findIndex(ue=>ue?.value===ce.type)||5,position:"absolute",top:0,left:0,height:`${$.size}px`,transform:`translateY(${$.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"},"&:hover":{backgroundColor:s==="dark"?"var(--mantine-color-dark-4)":"var(--mantine-color-gray-1)"}}),tabIndex:-1,children:[jsx(ir,{index:$.index,...ce}),!C&&ce.type!==g[g.length-1]?.value&&jsx(ActionIcon,{onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),we(ce.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},ce.value)})})})]})})})})]})})}var Lv,_v,Bv,Ov,Mv,qd=b(()=>{c();Va();Ie();Kt();he();Pe();Jr();Lv=(e=[],t=[],o="",r="",n="",a="|")=>{let s=t.map(x=>x.value).slice(),i=`${s.pop()}`,l=x=>x[o],p=x=>x[r],u=x=>{if(x[n])return typeof x[n]=="string"?x[n].split(a):x[n]},d=new Set,m=[],g=[],f=nest().rollup(x=>{let y=x[0],E=w=>w&&w.value&&!d.has(w.value),L=s.map(w=>y[`${w} ID`]),k=s.map(w=>y[w]),O=s.map((w,C)=>{if(g[C]!==k[C]){g[C]=k[C];let v=l[C]||l[l.length-1]||l,P=p[C]||p[p.length-1]||p,D=u[C]||u[u.length-1]||u;return {color:v(y,w)||void 0,icon:P(y,w)||void 0,value:`${L[C]}`,label:k[C],name:k[C],type:w,searchindex:k.slice(0,C+1).concat(D(y,w)).join("|")}}return {}}).filter(E);O.forEach(w=>d.add(w.value));let F=l[l.length-1]||l,W=p[p.length-1]||p,A=u[u.length-1]||u,B=x.map(w=>({color:F(w,i)||void 0,icon:W(w,i)||void 0,value:`${w[`${i} ID`]}`,label:w[i],name:w[i],type:i,searchindex:k.concat(w[i]).concat(A(w,i)).join("|")}));m.push(...O.concat(B));});return s.forEach(x=>{f.key(y=>`${y[`${x} ID`]}|${y[x]}`);}),f.entries(e),m},_v=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},Bv=(e,t)=>{let o=e.length,r,n=i=>r&&r.searchindex.includes(i.searchindex),s={next:()=>{for(let i=o-1;i>-1;i--){let l=e[i];if(t.test(`${l.value} ${l.label} ${l.searchindex}`)||n(l))return r=l,o=i,{done:false,value:l}}return {done:true,value:void 0}},[Symbol.iterator]:()=>s};return s},Ov=e=>`multihierarchySelector${e}`,Mv=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var Wd={};Ms(Wd,{default:()=>jv});function Wv({block:e,active:t,locale:o,variables:r,configOverride:n={}}){let a=Hv(),s=qe(e),i=Ot(o),l={variables:r},p=yo(),u=useRouter(),{sectionVariables:d,setSectionVariables:m,resetSectionVariables:g}=De(e.section_id),f=useMemo(()=>{if(!t)return {error:"Activate to View"};if(!s?.logic)return {error:"Add a Configuration"};let W=pt({logic:s.logic},i,l).logic,A={router:u,section:{variables:d,setVariables:m,resetVariables:g}};return ko(W,i,r,o,e.id,{},A,p)},[s?.logic,t,r,d]),{type:x}=f.config||{},y=x&&$i[x]?x:"Treemap";x||(f.config={error:'Visualization missing "type"'}),$i[x]||(f.config={error:`"${x}" is not a valid Visualization Type`});let E=$i[y],L=f.error||f.config?.error||false;if(L)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:L},"type")});let{_data:k,...O}=f.config,F={locale:o,variables:r,...O,...n};return a.print&&(F.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(or,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(E,{style:{flex:1},dataFormat:W=>{let A;try{A=f.dataFormat(W);}catch(B){console.error("Error in dataFormat: ",B),A=[];}return A},linksFormat:f.linksFormat,nodesFormat:f.nodesFormat,topojsonFormat:f.topojsonFormat,config:{...F}},"viz-key")})})}var Hv,qv,$i,jv,jd=b(()=>{c();Do();ui();mn();zo();Pe();pi();Hv=()=>({}),qv={},$i={HTML:fn,...XT,...qv};jv=memo(Wv,(e,t)=>e.block.contentByLocale.logic.content===t.block.contentByLocale.logic.content&&e.active===t.active&&e.locale===t.locale&&JSON.stringify(e.variables)===JSON.stringify(t.variables)&&JSON.stringify(e.configOverride)===JSON.stringify(t.configOverride));});var Yv,Ue,Kd=b(()=>{c();ge();id();cd();ud();dd();gd();kd();Cd();Ad();Id();_d();Md();Nd();Dd();qd();Yv=JT(()=>Promise.resolve().then(()=>(jd(),Wd)),{ssr:false}),Ue={[h.PARAGRAPH]:fi,[h.STAT]:gi,[h.SUBTITLE]:hi,[h.TITLE]:yi,[h.SELECTOR]:Ti,[h.VIZ]:Yv,[h.GENERATOR]:Ci,[h.SECTION_FLAG]:Ci,[h.IMAGE]:wi,[h.NAV]:Ii,[h.RELATED]:_i,[h.RESET_BUTTON]:Oi,[h.COMPARISON_BUTTON]:Mi,[h.TABLE]:Fi,[h.BUTTON]:Di,[h.MULTIHIERARCHY_SELECTOR]:zi};});var Yd=b(()=>{c();ge();({[h.TITLE]:IconHeading,[h.GENERATOR]:IconApi,[h.SECTION_FLAG]:IconFlag,[h.STAT]:IconPercentage,[h.VIZ]:IconChartBar,[h.PARAGRAPH]:IconAlignLeft,[h.SELECTOR]:IconSelector,[h.IMAGE]:IconPhoto,[h.TABLE]:IconTable,[h.MULTIHIERARCHY_SELECTOR]:IconListTree});});var Xd=b(()=>{c();ge();({[h.TITLE]:"Title",[h.GENERATOR]:"Data",[h.STAT]:"Stat",[h.VIZ]:"Visualization",[h.PARAGRAPH]:"Paragraph",[h.SELECTOR]:"Selector",[h.SUBTITLE]:"Subtitle",[h.RESET_BUTTON]:"Reset Button",[h.COMPARISON_BUTTON]:"Comparison Button",[h.RELATED]:"Related Reports",[h.NAV]:"Navigation",[h.IMAGE]:"Image",[h.TABLE]:"Table",[h.BUTTON]:"Button",[h.FALLBACK]:"Fallback",[h.SECTION_FLAG]:"Section Flag",[h.MULTIHIERARCHY_SELECTOR]:"Multihierarchy Selector"});});var aR,Ui,Qd=b(()=>{c();ge();ad();Kd();Yd();Xd();aR={[h.GENERATOR]:{type:h.GENERATOR,renderer:Ue[h.GENERATOR],renderPreviewOnEdit:false},[h.SECTION_FLAG]:{type:h.SECTION_FLAG,renderer:Ue[h.SECTION_FLAG],renderPreviewOnEdit:false},[h.IMAGE]:{type:h.IMAGE,renderer:Ue[h.IMAGE],renderPreviewOnEdit:false},[h.PARAGRAPH]:{type:h.PARAGRAPH,renderer:Ue[h.PARAGRAPH],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RELATED]:{type:h.RELATED,renderer:Ue[h.RELATED],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.SELECTOR]:{type:h.SELECTOR,renderer:Ue[h.SELECTOR],adapter:hn[h.SELECTOR],nonActiveAdapter:()=>hn[h.SELECTOR]({name:"Selector Preview"}),renderPreviewOnEdit:false},[h.STAT]:{type:h.STAT,renderer:Ue[h.STAT],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.SUBTITLE]:{type:h.SUBTITLE,renderer:Ue[h.SUBTITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TITLE]:{type:h.TITLE,renderer:Ue[h.TITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.VIZ]:{type:h.VIZ,renderer:Ue[h.VIZ],renderPreviewOnEdit:false},[h.NAV]:{type:h.NAV,renderer:Ue[h.NAV],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.RESET_BUTTON]:{type:h.RESET_BUTTON,renderer:Ue[h.RESET_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.COMPARISON_BUTTON]:{type:h.COMPARISON_BUTTON,renderer:Ue[h.COMPARISON_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.TABLE]:{type:h.TABLE,renderer:Ue[h.TABLE],renderPreviewOnEdit:false,evalWhenNonActive:false},[h.BUTTON]:{type:h.BUTTON,renderer:Ue[h.BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[h.MULTIHIERARCHY_SELECTOR]:{type:h.MULTIHIERARCHY_SELECTOR,renderer:Ue[h.MULTIHIERARCHY_SELECTOR],adapter:hn[h.MULTIHIERARCHY_SELECTOR],nonActiveAdapter:()=>hn[h.MULTIHIERARCHY_SELECTOR]({label:"Multihierarchy Selector Preview"}),renderPreviewOnEdit:false}},Ui=aR;});function Rs({blockId:e,active:t=true,asComparison:o=false}){let{query:r,locale:n=bt}=useRouter(),a=nt(),s=Tt(e).data,i=Tr(e,o&&a.active?a?.variables.variables:void 0,o&&a.active?a?.variables.attributes:void 0),l=qe(s,n),p=Ot(n),u={variables:i,query:r,locale:n},d=K(E=>E.variables.variables[s.id]||{}),m=K(E=>E.variables.status[s.id]||{}),[g,f]=useState(()=>{if(![h.GENERATOR,h.VIZ,h.NAV].includes(s.type)){if(s?.type===h.SELECTOR){let k=qe(s,n),{config:O}=fr(s.id,k?.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.MULTIHIERARCHY_SELECTOR){let k=qe(s,n),{config:O}=gr(s.id,k.logic,p,u);return {...O,id:s.id,section:s.section_id}}if(s?.type===h.RESET_BUTTON)return {...l.simple,id:s.id,section:s.section_id};if(s?.type===h.COMPARISON_BUTTON)return {...l.simple,id:s.id,section:s.section_id};let E=st(l?.logic,p,u),{vars:L}=Lt("variables",i,E,p,void 0,u);return L}return null});useEffect(()=>{(async()=>{if(!s||s.type===h.GENERATOR)return;if(s.type===h.VIZ){f({block:s,locale:n,variables:i,active:t});return}if(!t&&!Ui[s.type].evalWhenNonActive){let{nonActiveAdapter:O}=Ui[s.type],F=O&&typeof O=="function"?O():{};f(F);return}if(s.type===h.GENERATOR){f({outputVariables:d});return}if(h.SELECTOR===s.type){let O=qe(s,n),{config:F}=fr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(h.MULTIHIERARCHY_SELECTOR===s.type){let O=qe(s,n),{config:F}=gr(s.id,O.logic,p,u);f({...F,id:s.id,section:s.section_id});return}if(s.type===h.RELATED){let{related_reports:O}=d;f({related_reports:O});return}if(s.type===h.RESET_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.COMPARISON_BUTTON){f({id:s.id,...l.simple});return}if(s.type===h.FALLBACK){f({id:s.id,type:s.original_type,roles:s.settings.access});return}let L=st(l?.logic,p,u),{vars:k}=Lt("variables",i,L,p,void 0,u);if(s.type===h.TABLE){f({sectionId:s.section_id,...k});return}if(s.type===h.NAV){f({id:s.id,headings:s.inputs,section:s.section_id,settings:s.settings,...k});return}f(k);})();},[l,i]);let x=m.allowed||s?.type===h.NAV;if(!s||!g||!x)return null;let y=Ju[s.type];return jsx("div",{id:`bespoke-${s.type}-${s.id}`,className:`cms-block-wrapper bespoke-block-area cms-block-${e}`,children:jsx(y,{...g,settings:s.settings,asComparison:o})})}var Jd=b(()=>{c();ge();ed();Qd();zo();Pe();mr();qr();Dn();Hs();Ws();eo();});var em,pR,tm,Es,ks=b(()=>{c();em={margin:{label:"Content Margin",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},columnGutter:{label:"Column Gutter",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},width:{label:"Width",defaultValue:"full",options:[{label:"Full Width",value:"full"},{label:"Center",value:"center"}]},position:{label:"Position",defaultValue:"normal",options:[{label:"Normal",value:"normal"},{label:"Sticky",value:"sticky"}]},style:{label:"Style",defaultValue:"none",options:[{label:"None",value:"none"},{label:"Card",value:"card"}]}},pR=Object.keys(em).reduce((e,t)=>(e[t]=em[t].defaultValue,e),{}),tm={memberImageBg:false,optionsMenu:false,optionData:true,optionImage:true,optionShare:true,showAnchor:false,...pR},Es=e=>({data:typeof e.optionData=="boolean"?e.optionData:true,image:typeof e.optionImage=="boolean"?e.optionImage:true,share:typeof e.optionShare=="boolean"?e.optionShare:true});});function om({previews:e}){let t=e.map((o,r)=>({key:o?`bg-${o.content_id}`:`bg-${r}`,src:o?`/api/cms/member/image?member=${o.content_id}&size=splash`:""}));return jsxs(Fragment,{children:[jsx(Group,{className:"cms-section-bg",grow:true,gap:0,style:{position:"absolute",width:"100%",height:"100%"},children:t.map(o=>jsx("div",{className:"cms-section-member-bg",style:{backgroundImage:`url(${o.src})`,backgroundSize:"cover",backgroundPosition:"center center",height:"100%",width:"100%"}},o.key))}),jsx("div",{className:"cms-section-gradient-bg",style:{background:"white",position:"absolute",width:"100%",height:"100%",opacity:.33}})]})}var rm=b(()=>{c();});function nm({direction:e,onClick:t,visible:o}){return o?jsx(ActionIcon,{className:`bespoke-sortable-table-arrow bespoke-sortable-table-arrow-${e}`,variant:"filled",size:"md",sx:{position:"absolute",top:"50%",[e==="left"?"left":"right"]:"16px",zIndex:10,opacity:.55,"&:hover":{opacity:1}},onClick:t,children:e==="left"?jsx(IconArrowLeft,{size:16}):jsx(IconArrowRight,{size:16})}):null}function sm({data:e}){let t=useRef(null),[o,r]=useState(false),[n,a]=useState(false),[s,i]=useState(false),l=useMemo(()=>(e&&Array.isArray(e)&&e[0]?Object.keys(e[0]):[]).filter(d=>!d.startsWith("_")).map(d=>({accessorKey:d,header:d,enableSorting:true})),[e]);return useEffect(()=>{let p=()=>{if(t.current){let{scrollWidth:u,clientWidth:d,scrollLeft:m}=t.current;r(u>d),a(m>0),i(m+d<u-1);}};return p(),window.addEventListener("resize",p),t.current?.addEventListener("scroll",p),()=>{window.removeEventListener("resize",p),t.current?.removeEventListener("scroll",p);}},[e]),jsxs("div",{className:"bespoke-sortable-table",style:{position:"relative"},children:[jsx(MantineReactTable,{columns:l,data:e,enableBottomToolbar:false,enableColumnActions:false,enablePagination:false,enableSorting:true,enableTopToolbar:false,layoutMode:"grid",enableStickyHeader:true,initialState:{density:"xs"},mantineTableProps:{sx:{tableLayout:"fixed"}},mantineTableContainerProps:{ref:t,sx:{minHeight:100,maxHeight:350,overflowX:"auto"}},mantineTableBodyCellProps:{p:"5px !important",sx:{textWrap:"wrap"}},defaultColumn:{minSize:50,maxSize:150}}),jsx(nm,{direction:"left",visible:o&&n,onClick:()=>{t.current&&t.current.scrollBy({left:-150,behavior:"smooth"});}}),jsx(nm,{direction:"right",visible:o&&s,onClick:()=>{t.current&&t.current.scrollBy({left:150,behavior:"smooth"});}})]})}var am=b(()=>{c();});function Vr(e){let t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"," ":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),a=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(a)?a.replace(n,s=>t[s]):a}var qi=b(()=>{c();});function Wi(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var im=b(()=>{c();});function RR(e){return e?vR(Wi(Vr(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var oo,Tn=b(()=>{c();qi();im();oo=RR;});function mm(e){let{section:t}=e,o=zt(),r=useRouter(),n=K(I=>I.status.isCMS),a=K(I=>I.status.currentLocale),s=r.locale,i=n?a:s,l=50,p=Ot(i),u=yo(),d=Le("options"),m={...Zi,...d.data_tab},[g,f]=useState([]),[x,y]=useState([]),[E,L]=useState(),[k,O]=useState(),[F,W]=useState(false),[A,B]=useState({}),[w,C]=useState(true),[v,P]=useState(true),{sectionVariables:D,setSectionVariables:N,resetSectionVariables:H}=De(t.id),X=t.blocks||[],M=K(I=>({records:I.records,variables:I.variables})),U=useMemo(()=>X.reduce((I,R)=>{let z=M.records.entities.block[R],G=M.variables.variables[R],J=M.variables.status[R];return (h.GENERATOR===z.type&&G._downloadEnabled===true&&J.allowed||h.VIZ===z.type&&J.allowed)&&(I[R]={entity:z,variables:M.variables.variables[R],status:M.variables.status[R],inputVariablesFlat:z.inputs.reduce((re,ne)=>({...re,...M.variables.variables[ne]}),M.variables.attributes)}),I},{}),[X]),_=I=>{y(R=>R.includes(I)?R:[...R,I]);},j=I=>{f(R=>(R.find(G=>G.ix===I.ix)?R:[...R,I]).sort((G,J)=>G.ix>J.ix?1:-1));};function ie(I){!E&&I[0]&&le(I[0]);}function le(I){L(I),O("0");}useEffect(()=>{let I=async(R,z,G)=>{let J=dataLoad.bind({});return new Promise((re,ne)=>{J(z,null,null,(we,Re)=>{if(we)ne(we);else {let _e=G instanceof Function?G(Re):Re;R.data.unshift(_e),j(R),re(Re);}});})};if(g.length===0&&x.length===0){let R=0;for(let z of Object.values(U)){let G=z.entity;if([h.GENERATOR,h.SECTION_FLAG].includes(G.type)){let J=z.variables._downloadData||z.variables._downloadUrl||z.status.api;if(J){let re=[];typeof J=="string"?re=J.split("|||"):re=[J],re=hs(re,u);let ne=z.variables._downloadTitle||`${m.data_source} ${R+1}`,we=z.variables._downloadFileName||ne;j({ix:R,id:G.id,title:Vr(ne),fileName:we,data:Array.isArray(re)?re:[re],loading:false,type:h.GENERATOR}),_(R),R++;}}else if(G.type===h.VIZ){let J=qe(G),re=z.inputVariablesFlat,ne={variables:re},we=pt({logic:J.logic},p,ne).logic,Re={router:r,section:{variables:D,setVariables:N,resetVariables:H}},_e=ko(we,p,re,i,G.id,{},Re,u),Ae=_e.config._downloadTitle||_e.config.title||`${m.viz_source} ${R+1}`,Ye=_e.config._downloadFileName||Ae;if(_e.config._downloadEnabled!==false)try{let Ne=_e.config._downloadUrl||_e.config.data,qt=typeof Ne=="string"?[Ne]:Ne,Lo=_e.dataFormat instanceof Function?_e.dataFormat:!1,_o=_e.config._downloadDataFormat instanceof Function?_e.config._downloadDataFormat:!1;I({ix:R,id:G.id,title:Vr(Ae),fileName:Ye,data:qt,loading:!1,type:h.VIZ},Ne,_o||Lo),_(R),R++;}catch(Ne){console.error("DataLoad catch",Ne);}}}P(false);}},[U]),useEffect(()=>{g.length===x.length&&ie(g);},[g]),useEffect(()=>{if(E&&k){let I=parseInt(k,10);if(E.data[I]&&(!A[E.ix]||!A[E.ix][k])){C(true);let R=E.data[k];typeof R=="string"?Xs(R,o,i,[],void 0).then(z=>{let G=UR(z);B({...A,[E.ix]:{...A[E.ix],[I]:G}});}).catch(z=>{console.error(z);}).finally(()=>{C(false);}):(B({...A,[E.ix]:{...A[E.ix],[I]:R}}),C(false));}}},[k,E]);let q=(I,R)=>{let z=I===R?"":`-${I}`.toLowerCase();if(E){let G=E.data.length>1&&k?`-${parseInt(k,10)+1}`:"";return `${oo(E.fileName)}${z}${G}.${R.toLowerCase()}`}return `${z}.${R}`},oe=async I=>{if(E){W(true);let R=new AR,z=q(I,I);try{switch(I){case Cs.json.extension:R.file(z,JSON.stringify(ee));break;case Cs.csv.extension:R.file(z,csvFormat(ee));break;case Cs.xlsx.extension:{let{utils:G,write:J}=await import('xlsx'),re=G.book_new();G.book_append_sheet(re,G.json_to_sheet(ee),z.substring(0,30));let ne=J(re,{bookType:"xlsx",bookSST:!0,type:"binary"});R.file(z,ne,{binary:!0});break}default:break}R.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(G=>{W(!1),saveAs(G,q(I,"zip"));});}catch(G){console.error(m.error_generating,G),W(false);}}},ee=useMemo(()=>E&&A[E.ix]&&A[E.ix][k]?A[E.ix][k]:[],[A,E,k]),Q=useMemo(()=>{if(g&&g.length>0&&g.length===x.length){let I=g.map(R=>({value:`${R.ix}`,label:R.title}));return jsx(Select,{disabled:!E,style:{flex:"1"},value:`${E?.ix}`,onChange:R=>{let z=g.find(G=>`${G.ix}`===R);le(z);},data:I,icon:jsx(IconDatabase,{size:16})})}else return ""},[g,E,x]);return jsxs(Stack,{className:"cms-section-options-data",gap:"xs",py:"xs",children:[jsx(LoadingOverlay,{visible:v,overlayProps:{blur:2}}),g.length===0&&!v&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:m.no_data_src}),g.length>1&&g.length===x.length&&!v&&jsx(Input.Wrapper,{label:`${m.choose_data_src}:`,children:jsx(Group,{gap:"xs",children:Q})}),E&&k&&jsx(Stack,{gap:"xs",children:jsx(Input.Wrapper,{label:`${m.preview}
|
|
16
16
|
${ee.length>l?m.rows_preview.replace("{nrows}",l):""}:`,children:jsxs(Group,{gap:"xs",children:[jsx(Select,{disabled:!(E.data.length>1),style:{flex:"1"},value:k,onChange:I=>O(I),data:E.data.map((I,R)=>({value:`${R}`,group:typeof I=="string"?m.raw_group:m.formatted_group,label:typeof I=="string"?I:m.formatted_src.replace("{src}",E.title)})),icon:typeof E.data[k]=="string"?jsx(IconLink,{}):jsx(IconSparkles,{})}),jsx(CopyButton,{value:typeof E.data[k]=="string"?E.data[k]:"",timeout:2e3,children:({copied:I,copy:R})=>jsx(Tooltip,{label:I?m.copied:m.copy,withArrow:true,position:"top",children:jsx(ActionIcon,{variant:I?"filled":"subtle",onClick:R,disabled:typeof E.data[k]!="string",children:I?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})]})})}),E&&!w&&ee.length===0&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:m.error_preview}),E&&k&&!w&&ee.length===0&&jsx("a",{href:E.data[k],target:"_blank",rel:"noreferrer",children:jsx(Button,{leftSection:jsx(IconExternalLink,{size:16}),fullWidth:true,children:m.open_in_window.replace("{src}",E.title)})}),jsxs(Stack,{pos:"relative",mih:"430px",gap:"xs",children:[jsx(LoadingOverlay,{visible:w&&g.length>0,overlayProps:{blur:2}}),E&&!w&&ee.length>0&&jsxs(Fragment,{children:[jsx(Box,{h:"350px",children:jsx(sm,{data:ee.slice(0,l)})}),jsx(Input.Wrapper,{label:`${m.download}:`,children:jsx(Button.Group,{children:Object.values(Cs).map(I=>jsx(Button,{leftSection:jsx(I.icon,{size:24}),onClick:()=>oe(I.extension),loading:F,fullWidth:true,children:I.extension},`format-${I.extension}`))})})]})]})]})}var Cs,Zi,UR,Ji=b(()=>{c();he();am();ge();mn();Tn();qi();zo();Pe();Do();$o();Cr();js();dt();Cs={csv:{extension:"CSV",icon:IconFileTypeCsv},json:{extension:"JSON",icon:IconFileTypeJs},xlsx:{extension:"XLSX",icon:IconFileTypeXls}},Zi={data_source:"Data Source",no_data_src:"No data sources defined",viz_source:"Visualization Source",error_generating:"Error generating file.",choose_data_src:"Choose data source",original_src:"Original {src}",loading:"Loading...",error_preview:`Sorry. We could not generate the data preview as a table.
|
|
17
17
|
Try to open the source and check the data directly.`,open_in_window:"Open {src} response in a new window",formatted_src:"Formatted {src}",formatted_group:"Formatted Data",raw_group:"Raw Data",rows_preview:"(First {nrows} rows as preview)",choose_format:"Choose format",processing_file:"Processing file...",download:"Download data as",preview:"Preview",copy:"Click to copy",copied:"Copied!"},UR=e=>{let t=[];return e&&e.data&&(e.data&&Array.isArray(e.data)?t=e.data:e.data&&e.data.data&&Array.isArray(e.data.data)?t=e.data.data:e.data&&e.data.data&&e.data.data.results&&Array.isArray(e.data.data.results)?t=e.data.data.results:e.data&&e.data.results&&Array.isArray(e.data.results)&&(t=e.data.results)),t};});function ym(e){let{section:t}=e,o=t.blocks||[],r=K(I=>o.map(R=>({...I.records.entities.block[R],status:I.variables.status[R]})).filter(R=>R.type===h.VIZ&&R.status.allowed)),{variant_slug1:n,slug1:a}=K(I=>I.variables.attributes),s=xu(),[i,l]=useState(Et.section),[p,u]=useState(kt.png),[d,m]=useState(false),[g,f]=useState(false),[x,y]=useState([]),[E,L]=useState(r.length>0?r[0].id:null),k=i!==Et.section,{print:O,downloadLoading:F}=Tu(t.id,n,a,k?E:null),[W,A]=useState(true),[B,w]=useState(false),C=Le("options"),v={...iE,...C.image_tab},{siteProps:P}=Xo(),D=P?.logoSrc&&typeof P.logoSrc=="string",N=t?.settings?.name||`section-${t.id}`,H=`#${N}`,X=useMantineTheme(),M=()=>{let I=j(E);return select(I).select("svg").size()===1},U=()=>`${oo(N)}`,_=()=>{let I=document.getElementById(N);return select(I).select(".bespoke-section-content").node()},j=I=>{let R=_();return select(R).select(`#bespoke-visualization-${I}.bespoke-block-area`).node()},ie=()=>new Promise(I=>{let R;i===Et.section?R=_():i===Et.viz&&(R=j(E));let z=document.createElement("div");z.style.display="flex",z.style.justifyContent="space-between",z.classList.add("bespoke-share-source"),z.style.padding=X.spacing.xs,z.style.width="100%";let G=document.createElement("div");if(G.innerText=v.source.replace("{src}",`${window.location}${H}`),G.style.fontSize=X.fontSizes.xs,z.appendChild(G),D){let J=document.createElement("img");J.src=P.logoSrc,J.style.height="30px",J.onload=()=>I(R),J.onerror=()=>{J.remove(),I(R);},z.appendChild(J),R.appendChild(z);}else R.appendChild(z),I(R);}),le=I=>{if(W)return "transparent";let R=select(I).style("background-color");return R!=="rgba(0, 0, 0, 0)"&&R!=="transparent"?R:I===document.body?"white":le(I.parentNode)},q=async(I,R)=>{let{toPng:z}=await import('html-to-image');z(I,{backgroundColor:R.background,cacheBust:true,filter:G=>G&&G.classList?!R.exclusionClasses.some(J=>G.classList.contains(J)):true}).then(G=>{let J=document.createElement("a");J.download=`${R.filename}.png`,J.href=G,J.click();}).catch(G=>{console.error("Error generating image",G);}).finally(()=>{aE(),m(false);});},oe=(I,R)=>{saveElement(I,{filename:R.filename,type:"svg",callback:()=>m(false)},{background:R.background});},ee=async()=>{m(true);let I=await ie(),R={background:le(I),exclusionClasses:["export-hidden"],filename:U()},z=p===kt.png?q:oe;try{if(I)z(I,R);else throw new Error(v.wrong_node)}catch{m(false);}},Q=async()=>{let{toCanvas:I}=await import('html-to-image');Promise.all(r.map(R=>{let z=j(R.id),G=z.querySelector("g.d3plus-geomap-tileGroup");G&&(G.style.display="none");let re=select(z).select("svg").select("g").size()>0?z:lE();return I(re).then(ne=>(G&&(G.style.display="block"),ne))})).then(R=>{y(R.map(z=>z.toDataURL())),w(false);});};return useEffect(()=>{i===Et.viz&&r.length>0?(L(r[0].id),w(true),Q()):i===Et.section&&y([]);},[i]),useEffect(()=>{E&&(M()?f(true):(f(false),u(kt.png)));},[E]),jsxs(Stack,{className:"cms-section-options-image",children:[jsx(Space,{h:"xs"}),r.length>0?jsx(Input.Wrapper,{label:`${v.choose_area}:`,children:jsx(SegmentedControl,{fullWidth:true,value:i,data:[{value:Et.section,label:jsxs(Center,{children:[jsx(IconTemplate,{size:"1rem"}),jsx(Box,{ml:10,children:v.entire_section})]})},{value:Et.viz,label:jsxs(Center,{children:[jsx(IconChartBar,{size:"1rem"}),jsx(Box,{ml:10,children:v.viz_only})]})}],onChange:I=>{l(I),I===Et.section&&u(kt.png);}})}):jsx(Text,{fw:"700",color:"gray.7",children:`${v.entire_section}:`}),i===Et.viz&&r.length>0&&jsxs(Input.Wrapper,{label:`${v.choose_viz}:`,style:{minHeight:"161px",position:"relative"},children:[!B&&x.length>0&&jsx(ScrollArea,{style:{height:250},children:jsx(SimpleGrid,{cols:3,children:r.map((I,R)=>jsx(Image,{alt:`Viz ${I.id}`,onClick:()=>{L(I.id);},style:{cursor:"pointer",border:E===I.id?"4px solid #228be6":"4px solid #eee"},radius:0,src:x[R],withPlaceholder:true,styles:()=>({figure:{height:"100%"},imageWrapper:{height:"100%"}})},`viz-option-${I.id}`))})}),jsx(LoadingOverlay,{visible:B})]}),g&&i!==Et.section&&jsx(Input.Wrapper,{label:`${v.choose_format}:`,children:jsxs(Button.Group,{children:[jsx(Button,{leftSection:jsx(IconPolaroid,{size:16}),onClick:()=>u(kt.png),variant:p===kt.png?"filled":"default",fullWidth:true,children:kt.png}),jsx(Button,{leftSection:jsx(IconCode,{size:16}),onClick:()=>u(kt.svg),variant:p===kt.svg?"filled":"default",fullWidth:true,children:kt.svg})]})}),jsx(Checkbox,{checked:W,label:`${v.transparent_bg}`,onChange:()=>A(!W),radius:"xl"}),jsx(Button,{leftSection:jsx(IconDownload,{size:16}),loading:d||F,onClick:s&&p!==kt.svg?()=>O(W):ee,fullWidth:true,children:jsx("span",{children:d||F?v.processing:v.download.replace("{imageFormat}",p)})})]})}var Et,kt,aE,iE,lE,bm=b(()=>{c();Tn();he();dt();Kt();ds();ge();Et={viz:"viz",section:"section"},kt={png:"PNG",svg:"SVG"},aE=()=>{let e=document.getElementsByClassName("bespoke-share-source");Array.from(e).forEach(t=>t.remove());},iE={wrong_node:"Wrong node in export",choose_area:"Choose image area",choose_viz:"Choose visualization",choose_format:"Choose format",transparent_bg:"Transparent background",processing:"Processing image...",download:"Download {imageFormat}",entire_section:"Entire section",viz_only:"Visualization only",source:"Source: {src}"},lE=()=>document.createElement("div");});function Tm(e){let{title:t,url:o,disabled:r=false}=e,n=r?IconCode:IconLink;return jsx(Input.Wrapper,{label:t,children:jsx(Input,{icon:jsx(n,{}),value:o,disabled:r,readOnly:true,rightSection:jsx(CopyButton,{value:o,timeout:2e3,children:({copied:a,copy:s})=>jsx(Tooltip,{label:a?"Copied":"Copy",withArrow:true,position:"right",children:jsx(ActionIcon,{variant:a?"filled":"subtle",onClick:s,disabled:r,children:a?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})})})}var xm=b(()=>{c();});function Rm(e){let{section:t}=e,[o,r]=useState(""),[n,a]=useState(""),[s,i]=useState(true),l=Le("options"),p={...ME,...l.share_tab};return useEffect(()=>{a(document.title);let{origin:u,pathname:d}=window.location,m=`${u}${d}`,g=s?t.settings?.name?.length?`#${oo(t.settings.name)}`:`#section-${t.id}`:"";r(`${m}${g}`);},[s]),jsxs(Stack,{className:"cms-section-options-share",children:[jsx(Space,{h:"xs"}),jsx(Tm,{title:`${p.title}: ${n}`,url:o}),jsx(Checkbox,{checked:s,label:p.include_section,onChange:()=>i(!s),radius:"xl"}),jsxs(Group,{justify:"center",children:[jsx(FacebookShareButton,{url:o,children:jsx(FacebookIcon,{size:32,round:true})}),jsx(TwitterShareButton,{url:o,title:n,children:jsx(TwitterIcon,{size:32,round:true})}),jsx(TelegramShareButton,{url:o,title:n,children:jsx(TelegramIcon,{size:32,round:true})}),jsx(WhatsappShareButton,{url:o,title:n,separator:":: ",children:jsx(WhatsappIcon,{size:32,round:true})}),jsx(LinkedinShareButton,{url:o,children:jsx(LinkedinIcon,{size:32,round:true})}),jsx(RedditShareButton,{url:o,title:n,windowWidth:660,windowHeight:460,children:jsx(RedditIcon,{size:32,round:true})}),jsx(EmailShareButton,{url:o,subject:n,children:jsx(EmailIcon,{size:32,round:true})})]})]})}var ME,Em=b(()=>{c();xm();dt();Tn();ME={title:"Title",include_section:"Include Section"};});function wm(e){let{section:t,initialMode:o,onEnds:r,open:n,title:a}=e,s=Es(t.settings),i=useMemo(()=>VE.filter(g=>s[g]),[s]),[l,p]=useState(o||i[0]||"data"),u=Le("options");useEffect(()=>{o!==l&&p(o);},[o]);let d={...ol,...u},m=useMemo(()=>jsxs(Fragment,{children:[jsxs(Tabs.List,{children:[s.data&&jsx(Tabs.Tab,{value:"data",children:d.download_title}),s.image&&jsx(Tabs.Tab,{value:"image",children:d.image_title}),s.share&&jsx(Tabs.Tab,{value:"share",children:d.share_title})]}),s.data&&jsx(Tabs.Panel,{value:"data",children:jsx(mm,{section:t})}),s.image&&jsx(Tabs.Panel,{value:"image",children:jsx(ym,{section:t})}),s.share&&jsx(Tabs.Panel,{value:"share",children:jsx(Rm,{section:t})})]}),[s,t,d]);return jsx("div",{className:"cms-section-options-modal",children:n&&jsx(Modal,{styles:{inner:{"@media (max-width: 768px)":{padding:0}}},className:"bespoke-options-modal",opened:true,onClose:()=>r(),size:"100%",title:a,children:jsx(Tabs,{onTabChange:p,value:l,keepMounted:false,children:m})})})}var ol,VE,Am=b(()=>{c();Ji();bm();Em();dt();ks();ol={download_title:"Download Data",image_title:"Save Image",share_title:"Share Link"},VE=["data","image","share"];});function Lm(e){let{sectionId:t,disabled:o=false}=e,[r,n]=useState(false),[a,s]=useState("data"),i=Gn(t),l=Le("options"),p={...ol,...l},u=Es(i.isSuccess?i.data.settings:{}),d=g=>{s(g),n(true);},m=()=>{n(false);};return jsxs("div",{className:"cms-section-options",children:[jsxs(Button.Group,{children:[u.data&&jsx(Button,{variant:"default",size:"compact-xs",onClick:()=>d("data"),"aria-label":p.download_title,disabled:o,children:jsx(IconTable,{size:16})}),u.image&&jsx(Button,{variant:"default",size:"compact-xs",onClick:()=>d("image"),"aria-label":p.image_title,disabled:o,children:jsx(IconCamera,{size:16})}),u.share&&jsx(Button,{variant:"default",size:"compact-xs",onClick:()=>d("share"),"aria-label":p.share_title,disabled:o,children:jsx(IconShare,{size:16})})]}),i.isSuccess&&jsx(wm,{section:i.data,initialMode:a,open:r,onEnds:m})]})}var _m=b(()=>{c();Am();he();dt();ks();});function HE({children:e,containerProps:t},o){return jsx(Flex,{ref:o,className:"bespoke-section-content",pos:"relative",align:"stretch",p:0,direction:{base:"column",md:"row"},wrap:"wrap",...t,children:e})}var Is,Mm,Fm=b(()=>{c();he();Ya();Is=Ro__default.forwardRef(function({children:t,column:o,basis:r,columnSettings:n={},sx:a={},...s},i){let l=Object.values(o).some(m=>m.settings?.display==="inline"),p=n?.width?`${n.width}px`:r,u=n?.width?`${n?.width}px`:"100%",d=n?.full?"100%":u;return jsx(Flex,{ref:i,className:"bespoke-section-col",align:"flex-start",direction:l?"row":"column",wrap:l?"wrap":"nowrap",maw:{base:"100%",md:d},miw:{base:"none",md:300},p:0,pos:"relative",sx:[{flexGrow:1,flexShrink:n?.full?0:1,flexBasis:n?.full?"100%":p},...Array.isArray(a)?a:a?[a]:[]],...s,children:t})}),Mm=Ro__default.forwardRef(HE);});var Dm=b(()=>{c();});var Rn,Vm=b(()=>{c();je();he();Dm();ge();Rn={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,")},{px:{defaultValue:400,min:25,step:5,formatter:Rn.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:Rn["%"]}};});var rl,zm=b(()=>{c();rl={backgroundColor:"#fafafa",block:{padding:10},column:{padding:12},section:{backgroundColor:"white",borderRadius:10,boxShadow:"0px 6px 10px rgba(12, 32, 50, 0.14), 0px 1px 15px rgba(12, 32, 50, 0.12), 0px 3px 5px rgba(12, 32, 50, 0.15)",margin:8,padding:32}};});function sl({previews:e,translations:t}){let{print:o}=Qe(),r=useMemo(()=>e.map(({image:n,name:a},s)=>(n?.author||n?.url)&&jsxs(Stack,{gap:0,children:[n.author&&jsxs(Text,{size:"xs",children:[a," ",t.image_by," ",jsx("strong",{children:n.author})]}),n.url&&jsxs(Text,{size:"xs",children:["URL: "," ",jsx(Anchor,{href:n.url,target:"_blank",children:n.url})]}),s+1<e.length&&jsx(Divider,{})]},n.id)),[e]);return jsx(Fragment,{children:o?jsx(Fragment,{children:r}):jsxs(Popover,{position:"right",children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"light",radius:"xl",children:jsx(IconPhoto,{size:20})})}),jsx(Popover.Dropdown,{children:r})]})})}var Gm=b(()=>{c();Zt();});function Hm(){let{locales:e}=useRouter(),t=location&&location.pathname.split("/").filter(o=>o.length>0)[0];return e?.includes(t)}var qm=b(()=>{c();});function sk({name:e,children:t,id:o,sectionSettings:r,sectionStyles:n,previews:a,translations:s}){let{print:i}=Qe(),l=r.memberImageBg&&a.some(({image:u})=>u&&(u.url||u.author)),p=useMemo(()=>r.showAnchor&&r.optionsMenu?"space-between":!r.showAnchor&&r.optionsMenu?"flex-end":r.showAnchor&&!r.optionsMenu?"flex-start":"flex-end",[r.showAnchor,r.optionsMenu]);return jsxs(ok,{className:`bespoke-Section-${o} bespoke-Section-root `,settings:r,bespokeStyles:n?.root||void 0,print:i,children:[r.memberImageBg&&jsx(om,{previews:a}),jsxs(rk,{className:`bespoke-Section-${o} bespoke-Section-container `,settings:r,bespokeStyles:n?.container,id:e?.length?oo(e):`section-${o}`,pos:"relative",children:[!i&&jsxs(Group,{justify:p,mb:"xs",children:[r.showAnchor&&jsxs(Anchor,{className:"cms-section-anchor",href:`#${r.name?oo(r.name):"section-"+o}`,sx:{"&:hover .cms-section-name":{visibility:"visible",opacity:1}},children:[jsx(Text,{span:true,size:"small",children:"#"}),jsx(Text,{span:true,size:"small",className:"cms-section-name",sx:{visibility:"hidden",opacity:0,transition:"visibility 0s, opacity 0.2s ease-in-out"},children:r.name||"section-"+o})]}),r.optionsMenu&&jsx(Lm,{sectionId:o,disabled:false})]}),jsxs(nk,{print:i,className:`bespoke-Section-${o} bespoke-Section-container`,settings:r,bespokeStyles:n?.content,children:[t,l&&jsx(sl,{previews:a,translations:s})]})]})]})}function ik({section:e,sectionLoader:t,print:o}){let{id:r,settings:n}=e,a={...tm,...n},{isEmbed:s}=Qe(),i=nt(),l=mt("Section"),p=Le("sections"),u=K(ut),d=K(A=>A.variables.status),{previews:m,isRunConsumersRunning:g}=K(A=>A.status,Xe),f={...tk,...p},x=i.active&&i.status?m.concat(i.status?.previews||[]):m,y=Object.values(u||{}).filter(A=>A.section_id===r),E=y.some(A=>{try{return d[A.id].allowed&&![h.GENERATOR,h.SECTION_FLAG].includes(A.type)||A.type===h.NAV}catch{return A.settings.allowed==="always"}}),L=y.filter(A=>![h.GENERATOR,h.SECTION_FLAG].includes(A.type)).reduce((A,B)=>(A[B.blockcol]?A[B.blockcol][B.blockrow]=B:A[B.blockcol]={[B.blockrow]:B},A),{}),k=Object.keys(y).length>0&&!n.hidden&&E;o&&(k=k&&!n.pdfHidden);let O=Object.keys(L).length;if(!k||i.active&&n.comparisonHide)return null;let F=(A,B=false)=>{let w=Array.from(new Set(A.map(v=>v.blockcol))).map(v=>({blockcol:v})).sort((v,P)=>et(v,P,"blockcol")),C=[];return w.forEach(({blockcol:v})=>{let P=A.filter(D=>D.blockcol===v).sort((D,N)=>et(D,N,"blockrow")).map(D=>{if(!D.id||!d[D.id]?.allowed&&D.type!==h.NAV)return null;let{settings:N,type:H}=u[D.id],X=N.width&&!N.width.stretch&&N.width.unit?Rn[N.width.unit](N.width.value):N.display==="inline"?"auto":"100%",M={alignSelf:H===h.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:X,minWidth:300};return jsx(Box,{className:"bespoke-Block-wrapper",id:`bespoke-Block-${D.id}`,sx:M,py:rl.block.padding,children:jsx(Rs,{blockId:D.id,asComparison:B},D.id)},D.id)});C.push(P);}),C.flat()},W=[];if(i.active&&!n.comparisonMerge){let A=y.filter(B=>![h.GENERATOR,h.SECTION_FLAG].includes(B.type)).reduce((B,w)=>({...B,[w.id]:w}),{});W=[jsx(Is,{column:A,basis:"50%",children:F(Object.values(y.filter(B=>![h.GENERATOR,h.SECTION_FLAG].includes(B.type))))},"original"),jsx(Is,{column:A,basis:"50%",children:F(Object.values(y.filter(B=>![h.GENERATOR,h.SECTION_FLAG].includes(B.type))),true)},"comparison")];}else W=Object.keys(L).sort((A,B)=>-Ns(A,B)).map(A=>{let B=L[A],w=n.columnSettings?n.columnSettings[A]:{},C=Object.values(B).sort((v,P)=>et(v,P,"blockrow"));return C.some(v=>!d[v.id]||d[v.id].allowed||v.type===h.NAV)?jsx(Is,{column:B,columnSettings:w,basis:`calc(${100/O}% - (10px * ${O}))`,children:C.map(v=>{if(!v.id||!d[v.id]?.allowed&&v.type!==h.NAV)return null;let{settings:P,type:D}=u[v.id],N=P.width&&!P.width.stretch&&P.width.unit?Rn[P.width.unit](P.width.value):P.display==="inline"?"auto":"100%",H={alignSelf:D===h.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:N,minWidth:300};return jsx(Box,{className:`bespoke-Block-wrapper bespoke-${v.type}-wrapper`,id:`bespoke-Block-${v.id}`,sx:H,py:rl.block.padding,children:jsx(Rs,{blockId:v.id},v.id)},v.id)})},A):null});return jsxs(sk,{id:r,name:e?.settings?.name,previews:x,sectionSettings:a,sectionStyles:l,translations:f,children:[g.includes(r)&&t,jsx(Mm,{containerProps:{gap:a.columnGutter||"md",wrap:i.active?"nowrap":"wrap",sx:{zIndex:20}},children:W}),s&&jsx(ak,{})]})}var tk,al,ok,rk,nk,ak,Qm,Zm=b(()=>{c();he();Nt();Jd();ks();cr();rm();_m();vo();ge();Fm();Vm();zm();Zt();dt();Gm();eo();Tn();Kt();qm();br();tk={image_by:"image by"},al=(e,t)=>o=>e?e(o,t):{},ok=({settings:e,bespokeStyles:t,print:o,children:r,...n})=>{let{position:a,shouldBreak:s}=e,i={normal:{position:"relative",backgroundColor:o?"transparent":"initial",borderRadius:0},sticky:{position:"sticky",zIndex:2,top:0,borderRadius:0,borderTop:o?"none":"initial",borderLeft:o?"none":"initial",borderRight:o?"none":"initial"}};return jsx(Paper,{component:"section",sx:u=>({...i[a],...al(t,e)(u),pageBreakBefore:s?"always":void 0}),...{normal:{radius:0},sticky:{radius:0,withBorder:true}}[a],...n,children:r})},rk=({settings:e,bespokeStyles:t,children:o,...r})=>{let{width:n}=e,a={center:{zIndex:1},full:{zIndex:1}};return jsx(Container,{sx:l=>({...a[n],...al(t,e)(l)}),...{center:{size:"lg",p:"sm",fluid:false},full:{fluid:true,p:"md"}}[n],...r,children:o})},nk=({settings:e,bespokeStyles:t,print:o,children:r,...n})=>{let{style:a}=e,s={none:{},card:{boxShadow:o?"none":"initial"}};return jsx(Paper,{sx:p=>({...s[a],...al(t,e)(p)}),...{none:{bg:"transparent"},card:{shadow:o?"none":"lg",p:"md",radius:"md"}}[a],...n,"data-screenshot-target":"true",children:r})};ak=()=>{let e=useRouter(),{query:t,locale:o}=e,{siteProps:r={logoSrc:""},profilePrefix:n,pathSegment:a}=Xo(),s=t[a],i=Array.isArray(s)?s.join("/"):[],p=Hm()?`/${o}`:"";p+=`${n}/${i}/`;let u=new URL(p,window.location.href).href;return jsxs(Group,{justify:"space-between",wrap:"nowrap",sx:{flexGrow:1},children:[jsx(Anchor,{href:u,target:"_blank",children:u}),jsx("img",{src:r.logoSrc,height:40,width:"auto",alt:"Site Logo"})]})};Qm=ik;});var Jm=b(()=>{c();ae();Y({name:"abbreviate",description:"Abbreviates a number into a smaller more human-readable number.",logicFactory(e){return t=>e.d3plus.formatAbbreviate(t)},inputType:"number",testValue:"123456",type:"formatter"});});var ef=b(()=>{c();ae();Y({name:"abs",description:"Simple Absolute Value.",logicFactory(){return e=>Math.abs(e)},inputType:"number",testValue:"-123",type:"formatter"});});var pk,tf=b(()=>{c();ae();pk=()=>function(t){let r=new RegExp(/([\$0-9\,]+)[A-z\-\s\&]*([\$0-9\,]*)/g).exec(t);return r?(r=r.slice(1).filter(n=>n.length).map(n=>(n.includes(",")&&(n.indexOf(",")===n.length-4?n=n.replace(/,000$/g,"k").replace(/([0-9]+)(,999$)/g,a=>`${parseInt(a)+1}k`):n.indexOf(",")===n.length-8&&(n=n.replace(/,000,000$/g,"M").replace(/([0-9]+)(,999,999$)/g,a=>`${parseInt(a)+1}M`))),n)),r.length===2?r.join(" - "):t.toLowerCase().match(/under|less|</g)?`< ${r[0]}`:t.toLowerCase().match(/over|more|\+|>/g)?`${r[0]}+`:`${r[0]}`):"None"},Y({name:"bucket",description:"Sanitizes bucket strings to '< n', 'n1 - n2', and 'n+'",logicFactory:pk,inputType:"number",testValue:"1234",type:"formatter"});});var of=b(()=>{c();ae();Y({name:"commas",description:"* Rounds to nearest whole number and adds commas.",logicFactory(e){return t=>e.d3.format(",")(Math.round(t))},inputType:"number",testValue:"1234.6",type:"formatter"});});var rf=b(()=>{c();ae();Y({name:"date",description:"Formats a date into '%B %d, %Y' format.",logicFactory(e){return t=>(typeof t=="string"&&(t=e.d3plus.date(t)),e.d3.timeFormat("%B %d, %Y")(t))},inputType:"date",testValue:"2022-01-01",type:"formatter"});});var nf=b(()=>{c();ae();Y({name:"dollar",description:"Adds a US dollar sign to the beginning of a String or Number.",logicFactory(e){return t=>(typeof t=="number"&&(t=e.d3plus.formatAbbreviate(t)),t.charAt(0)==="-"?t.replace("-","-$"):`$${t}`)},inputType:"number",testValue:"123",type:"formatter"});});var sf=b(()=>{c();ae();Y({name:"formatFieldName",description:"Based on field name returns a string",logicFactory(){return e=>{if(e.contentType.toLowerCase()==="stat"){if(e.field==="title")return "Stat label";if(e.field==="value")return "Stat value";if(e.field==="subtitle")return "Stat subtitle";if(e.field==="tooltip")return "Tooltip text"}return e.contentType.toLowerCase()==="section"&&e.field==="short"?"Short title":e.contentType.toLowerCase()==="description"&&e.field==="description"?"Paragraph":e.field}},inputType:"object",testValue:'{"field":"title","contentType":"stat"}',type:"formatter"});});var af=b(()=>{c();ae();Y({name:"grewTo",description:"Returns the text with grow direction: 'declined from', 'grew to' o 'stayed at'",logicFactory(){return e=>e<0?"declined from":e>0?"grew to":"stayed at"},inputType:"number",testValue:"-1234",type:"formatter"});});var lf=b(()=>{c();ae();Y({name:"grewWord",description:"Returns either 'grew', 'declined', or 'stayed' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declined":e>0?"grew":"stayed"},inputType:"number",testValue:"-1234",type:"formatter"});});var cf=b(()=>{c();ae();Y({name:"growing",description:"Returns either 'declining', 'growing' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declining":"growing"},inputType:"number",testValue:"-1234",type:"formatter"});});var Sk,pf=b(()=>{c();ae();Sk=()=>function(t){let{curr:o,currMoe:r=0,prev:n,prevMoe:a=0}=t,s;if(r||a){let i=(-n/o**2)**2*r**2,l=(1/o)**2*a**2;s=Math.sqrt(i+l);}else s=(o-n)/n;return s*100},Y({name:"growth",description:"Calculates the growth percentage between two numbers provided the following object format: {curr, prev}. Also supports calculating the growth between two margin of errors using this format: {curr, currMoe, prev, prevMoe}",logicFactory:Sk,inputType:"object",testValue:'{"curr":10,"currMoe":0,"prev":13,"prevMoe":0}',type:"formatter"});});var uf=b(()=>{c();ae();Y({name:"growthPct",description:"Abbreviates a growth value, turns it absolute, and adds a percent sign.",logicFactory(e){return t=>`${e.d3plus.formatAbbreviate(Math.abs(t))}%`},inputType:"number",testValue:"12345",type:"formatter"});});var df=b(()=>{c();ae();Y({name:"growthWord",description:"Returns either 'growth' or 'decline' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decline":"growth"},inputType:"number",testValue:"-1234",type:"formatter"});});var mf=b(()=>{c();ae();Y({name:"highWord",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign.",logicFactory(){return e=>e<0?"lower than":e>0?"higher than":"approximately the same as"},inputType:"number",testValue:"0",type:"formatter"});});var ff=b(()=>{c();ae();Y({name:"increaseWord",description:"Returns either 'increase', 'decrease', or 'change' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decrease":e>0?"increase":"change"},inputType:"number",testValue:"1234",type:"formatter"});});var gf=b(()=>{c();ae();Y({name:"increasedWord",description:"Returns either 'increased', 'decreased', or 'remained the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreased":e>0?"increased":"remained the same"},inputType:"number",testValue:"0",type:"formatter"});});var hf=b(()=>{c();ae();Y({name:"increasing",description:"Returns either 'decreasing', 'increasing' or 'maintaining' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreasing":e>0?"increasing":"maintaining"},inputType:"number",testValue:"-1234",type:"formatter"});});var yf=b(()=>{c();ae();Y({name:"largerThan",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign",logicFactory(){return e=>e<0?"smaller than":e>0?"larger than":"the same as"},inputType:"number",testValue:"-1234",type:"formatter"});});var bf=b(()=>{c();ae();Y({name:"list",description:"Joins an array of strings together, adding commas and 'and' when necessary.",logicFactory(){return e=>e.reduce((t,o,r)=>(r?r===e.length-1&&r===1?t+=` and ${o}`:r===e.length-1?t+=`, and ${o}`:t+=`, ${o}`:t+=o,t),"")},inputType:"object",testValue:'["foo","bar","bee"]',type:"formatter"});});var Sf=b(()=>{c();ae();Y({name:"longWord",description:"",logicFactory(){return e=>e<0?"shorter":e>0?"longer":"similar"},inputType:"number",testValue:"5",type:"formatter"});});var Tf=b(()=>{c();ae();Y({name:"lowerCaseFirst",description:"Converts the first letter of a string to lowercase",logicFactory(){return e=>typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e},inputType:"string",testValue:"foo",type:"formatter"});});var xf=b(()=>{c();ae();Y({name:"moreFewerWord",description:"",logicFactory(){return e=>e<0?"fewer":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var vf=b(()=>{c();ae();Y({name:"moreLess",description:"Returns either 'more' or 'less' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var Rf=b(()=>{c();ae();Y({name:"moreLess",description:"Returns either 'more than', 'less than', or 'approximately the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less than":e>0?"more than":"approximately the same"},inputType:"number",testValue:"-5",type:"formatter"});});var Ef=b(()=>{c();ae();Y({name:"olderWord",description:"",logicFactory(){return e=>e<0?"getting younger":e>0?"getting older":"staying the same age"},inputType:"number",testValue:"-5",type:"formatter"});});var kf=b(()=>{c();ae();Y({name:"olderYounger",description:"",logicFactory(){return e=>e<0?"younger than":e>0?"older than":"the same age as"},inputType:"number",testValue:"-5",type:"formatter"});});var Cf=b(()=>{c();ae();Y({name:"plural",description:"Pluralizes a word.",logicFactory(){return e=>e.replace(/\w$/g,t=>t==="y"?"ies":`${t}s`)},inputType:"string",testValue:"Foo",type:"formatter"});});var wf=b(()=>{c();ae();Y({name:"pxToInt",description:"Takes a pixel value and converts it to an integer",logicFactory(){return e=>parseInt(e.replace(/\D+/g,""),10)},inputType:"string",testValue:"12px",type:"formatter"});});var Af=b(()=>{c();ae();Y({name:"salary",description:"Displays salary values with proper precision (ie. '$74,200' instead of '$74.2k')",logicFactory(e){return t=>{let o;return t<1e6?o=e.d3.format(",")(t.toFixed(0)):o=e.d3plus.formatAbbreviate(t),`$${o}`}},inputType:"number",testValue:"1000000",type:"formatter"});});var Pf=b(()=>{c();ae();Y({name:"stripEntities",description:"Removes non breaking spaces & other html entities from a string",logicFactory(){return e=>typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e},inputType:"string",testValue:"<b>MyText</b>",type:"formatter"});});var il,If=b(()=>{c();ae();il=Y({name:"stripHTML",description:"Converts html tags to spaces, then removes redundant spaces",logicFactory(){return e=>{let t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"," ":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),a=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(a)?a.replace(n,s=>t[s]):a}},inputType:"string",testValue:"<b>My text</b>",type:"formatter"});});var Lf=b(()=>{c();ae();Y({name:"stripOL",description:"Removes ordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ol>/g,"").replace(/<\/ol>/g,"")},inputType:"string",testValue:"<ol><li>My list</li></ol>",type:"formatter"});});var _f=b(()=>{c();ae();Y({name:"stripP",description:"Removes all paragraph tags from a string.",logicFactory(){return e=>e.replace(/<p>/g,"").replace(/<\/p>/g,"")},inputType:"string",testValue:"<p>My p</p>",type:"formatter"});});var Bf=b(()=>{c();ae();Y({name:"stripUL",description:"Removes unordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ul>/g,"").replace(/<\/ul>/g,"")},inputType:"string",testValue:"<ul><li>My list</li></ul>",type:"formatter"});});var Of=b(()=>{c();ae();Y({name:"toKebabCase",description:"Takes a camelCase or PascalCase string and converts it to kebab-case.",logicFactory(){return e=>typeof e=="string"?(e=e.charAt(0).toLowerCase()+e.substring(1),e.replace(/([A-Z])/g,"-$1").toLowerCase()):"invalid string passed to toKebabCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var Mf=b(()=>{c();ae();Y({name:"toSpacedCase",description:"Takes a camelCase or PascalCase string and adds spaces (I know Spaced Case isn't a thing, deal with it).",logicFactory(){return e=>typeof e=="string"?e.replace(/([A-Z])/g," $1").toLowerCase().trim():"invalid string passed to toSpacedCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var Nf=b(()=>{c();ae();Y({name:"upperCaseFirst",description:"Converts the first letter of a string to uppercase",logicFactory(){return e=>e.charAt(0).toUpperCase()+e.slice(1)},inputType:"string",testValue:"my name",type:"formatter"});});var Ff=b(()=>{c();Jm();ef();tf();of();rf();nf();sf();af();lf();cf();pf();uf();df();mf();ff();gf();hf();yf();bf();Sf();Tf();xf();vf();Rf();Ef();kf();Cf();wf();Af();Pf();If();Lf();_f();Bf();Of();Mf();Nf();});function $f({onDownloadPDF:e,onDownloadCSV:t}){let[o,r]=useState(false),[n,a]=useState(false),[s,i]=useState(false),l=useMediaQuery("(max-width: 768px)"),p=Le("export"),u={...Jk,...p},d=async()=>{if(e){r(true);try{await e();}finally{r(false),i(false);}}},m=async()=>{if(t){a(true);try{await t();}finally{a(false),i(false);}}},g=(y,E,L,k,O,F)=>jsx(Button,{id:F,size:"sm",onClick:y,disabled:E,fullWidth:true,variant:"subtle",h:"auto",px:"xs",w:"100%",styles:()=>({inner:{width:"100%",display:"block"}}),children:jsxs(Group,{wrap:"nowrap",justify:"flex-start",gap:"xs",w:"100%",children:[E?jsx(Loader,{size:"1.75rem"}):L,jsxs(Stack,{gap:0,w:"100%",py:"0.5rem",className:"bespoke-report-download-btn-text-container",children:[jsx(Text,{w:"100%",size:"sm",lineClamp:1,className:"bespoke-report-download-btn-text-container-cta",children:k}),O&&jsx(Text,{size:"xs",w:"100%",lineClamp:2,maw:"100%",style:{wordWrap:"break-word",whiteSpace:"normal"},variant:"dimmed",lh:"0.9rem",h:"1.9rem",className:"bespoke-report-download-btn-text-desc",children:O})]})]})}),f=e&&g(d,o,jsx(IconFileTypePdf,{size:"1.75rem"}),u.pdf.label,u.pdf.desc,"bespoke-download-pdf-btn"),x=t&&g(m,n,jsx(IconFileTypeXls,{size:"1.75rem"}),u.xlsx.label,u.xlsx.desc,"bespoke-download-xlsx-btn");return e||t?jsx(Affix,{position:{bottom:l?rem(0):rem(20),right:l?rem(0):rem(20)},id:"bespoke-report-download-affix",style:{width:l?"100%":"auto",boxShadow:l?"0px -2px 6px rgba(0, 0, 0, 0.1)":"0px 2px 6px rgba(0, 0, 0, 0.1)",borderRadius:"0.25rem",background:"white"},p:"xs",children:jsxs(Popover,{opened:s,onChange:i,position:"top",shadow:"md",width:l?"100%":250,id:"bespoke-report-download-popover",children:[jsx(Popover.Target,{children:jsx(Button,{id:"bespoke-report-download-btn",size:"sm",onClick:()=>i(y=>!y),leftSection:jsx(IconDownload,{size:"1.2rem"}),variant:"subtle",loading:o||n,fullWidth:l,children:u.export})}),jsx(Popover.Dropdown,{p:"0.5rem",children:jsxs(Stack,{gap:"xs",children:[f,x]})})]})}):null}var Jk,Uf=b(()=>{"use client";c();dt();Jk={export:"Export",pdf:{label:"Download PDF",desc:"Generates a printable version of the report page in PDF format."},xlsx:{label:"Download XLSX",desc:"Creates a downloadable spreadsheet of the report page data."}};});function rC(e,t){let o=e.replace(/[:\\/?*[\]]/g,"");return o.trim().length===0&&(o=`Sheet${t+1}`),o.slice(0,31)}function nC(e){let t=new ArrayBuffer(e.length),o=new Uint8Array(t);for(let r=0;r<e.length;r++)o[r]=e.charCodeAt(r)&255;return t}function Gf(){let e=window.document.querySelector("title")?.textContent;return e||`data_export_${new Date().toISOString()}`}var oC,sC,Hf,qf=b(()=>{c();oC=e=>new Promise((t,o)=>{if(!e||e.length===0){o(new Error("No data provided"));return}try{let r=zr.utils.book_new();e.forEach((i,l)=>{if(i.data&&i.data.length>0){let p=i.data[0],u=zr.utils.json_to_sheet(p),d=rC(i.fileName||`Sheet${l+1}`,l),m=1;for(;r.SheetNames.includes(d);){let g=` (${m})`;d=`${d.slice(0,31-g.length)}${g}`,m++;}zr.utils.book_append_sheet(r,u,d);}});let n=zr.write(r,{bookType:"xlsx",type:"binary"}),a=new Blob([nC(n)],{type:"application/octet-stream"}),s=new AR;s.file(`${Gf()}.xlsx`,a),s.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(i=>{t(i);}).catch(o);}catch(r){o(r);}});sC=async e=>{try{let t=await oC(e);saveAs(t,`${Gf()}.zip`);}catch(t){console.error("Error generating file:",t);}},Hf=sC;});function Qe(){let e=useContext(Yf);if(e===void 0)throw new Error("usePrint must be used within a PrintContext");return e}function gC(e){return useMemo(()=>e.data.reduce((o,r)=>(r.blocks&&r.blocks.forEach(n=>{o[n]=r.id;}),o),{}),[e.data])}function hC({pathSegmentsKey:e="bespoke",sectionLoader:t,mode:o}){let{query:r}=useRouter(),n=en(),a=nt(),s=pn(),i=Mg(r.print)??false,l=o==="embed",{printReport:p,error:u,setError:d}=us();is();let m=jf.locale,g=Ot(m),f=useMemo(()=>n.data?.sort(et).filter(P=>P.settings?.hidden!==true).filter(P=>P.settings?.pdfHidden!==true).reduce((P,D)=>(D.blocks&&D.blocks.length>0&&P.push(...D.blocks),P),[])??[],[n.data]),x=gC({data:n.data||[]}),{sectionsVariables:y,resetSectionVariables:E,setSectionVariables:L}=Ec(n.data?.map(P=>P.id)||[]),k=K(ut,go),O=K(P=>P.variables,Xe),F=Le("options"),W={...Zi,...F.data_tab},A=useMemo(()=>f.reduce((P,D)=>{let N=k[D],H=O.status[D];return h.VIZ===N?.type&&H.allowed&&P.push({id:D,entity:N,variables:O.variables[D],status:O.status[D],inputVariablesFlat:N.inputs.reduce((X,M)=>({...X,...O.variables[M]}),O.attributes)}),P},[]),[f,k,O.attributes,O.status,O.variables]);function B(P){return P=P.replace(/<p>/g,""),P=P.replace(/<\/p>/g,""),P}let w=async(P,D,N)=>{let H=dataLoad.bind({});return new Promise((X,M)=>{H(D,null,null,(U,_)=>{if(U)M(U);else try{P||(P={data:[]}),Array.isArray(P.data)||(P.data=[]);let j=N instanceof Function?N(_):_;P.data.unshift(j),P.rawData=_,X(P);}catch(j){M(j);}});})},C=yo(),v=async()=>{if(!s.XlsxVizActive)return;let P=[],D=[],N=0,H=1;for(let U of A){let _=U.entity,j=qe(_),ie=U.inputVariablesFlat,le={variables:ie},q=pt({logic:j.logic},g,le).logic,oe={router:jf,section:{variables:y[x[_.id]],setVariables:L(y[x[_.id]]),resetVariables:E(y[x[_.id]])}},ee=ko(q,g,ie,m,_.id,{},oe,C),Q=ee.config._downloadTitle||ee.config.title||`${W.viz_source} ${N+1}`,I=ee.config._downloadFileName||Q;if(ee.config._downloadEnabled!==false){let R=ee.config._downloadUrl||ee.config.data;if(!R){console.error("API is undefined for block:",_.id);continue}let z=typeof R=="string"?[R]:R,G=ee.dataFormat instanceof Function?ee.dataFormat:false,J=ee.config._downloadDataFormat instanceof Function?ee.config._downloadDataFormat:false,re=ee.config._downloadSectionName,ne=ee.config._downloadSource;try{let we=await w({ix:N,id:_.id,title:il(Q),fileName:ne?re?`${H} ${B(re)}`:`${H} ${I}`:re?B(re):I,data:z,loading:!1,type:h.VIZ},R,J||G);if(ne){let Re=Array.isArray(we.rawData)?we.rawData:[we.rawData],_e=new Set;Re.forEach((Ae,Ye)=>{let Ne=ne(Ae),qt=Ne.name.trim().split(`
|
|
18
18
|
`),Lo=Ne.description.trim().split(`
|