@datawheel/bespoke 0.8.0-rc.29 → 0.8.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cms.js +1 -1
- package/dist/redux-store.js +2 -2
- package/dist/report.js +1 -1
- package/dist/server.js +3 -3
- package/package.json +2 -2
package/dist/report.js
CHANGED
|
@@ -44,7 +44,7 @@ import { FacebookShareButton, FacebookIcon, TwitterShareButton, TwitterIcon, Tel
|
|
|
44
44
|
import * as Vo from 'xlsx';
|
|
45
45
|
|
|
46
46
|
var mg=Object.defineProperty;var b=(e,t)=>()=>(e&&(t=e(e=0)),t);var Fa=(e,t)=>{for(var r in t)mg(e,r,{get:t[r],enumerable:!0});};var c=b(()=>{});var fg,Pe,wt=b(()=>{c();fg=()=>{let e=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",t=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[e];return t.includes(e)||t.push(e),{localeDefault:e,locales:t}},Pe=fg;});function Va(e,t){return +(e<t)-+(e>t)}function Ye(e,t,r="ordering"){return Va(t[r],e[r])}var co=b(()=>{c();});function $a(e){let t=1+76.18009173/e-86.50532033/(e+1)+24.01409822/(e+2)-1.231739516/(e+3)+.00120858003/(e+4)-536382e-11/(e+5);return (e-.5)*Math.log(e+4.5)-(e+4.5)+Math.log(t*2.50662827465)}function Tl(e,t,r){let o=0,n=1,a=1,s=1,i=0,l=0,u;for(;Math.abs((a-l)/a)>1e-5;)l=a,u=-(t+i)*(t+r+i)*e/(t+2*i)/(t+2*i+1),o=a+u*o,n=s+u*n,i+=1,u=i*(r-i)*e/(t+2*i-1)/(t+2*i),a=o+u*a,s=n+u*s,o/=s,n/=s,a/=s,s=1;return a/t}function gg(e,t,r){let o,n;if(e<0)n=0;else if(e>=t)n=1;else {e=Math.floor(e);let a=r,s=e+1,i=t-e,l=s+i,u=Math.exp($a(l)-$a(i)-$a(s)+s*Math.log(a)+i*Math.log(1-a));a<(s+1)/(l+2)?o=u*Tl(a,s,i):o=1-u*Tl(1-a,i,s),n=1-o;}return Math.round(n*1e5)/1e5}function hg(e){return {.99999:15.137,.99:6.635,.95:3.841,.9:2.706}[e]}function $o(e,t,r,o){let n=t/(1-t),a=0,s=1,i=0,l=0;for(;a<=e;)l+=s,a>=r&a<=o&&(i+=s),l>1e30&&(i/=1e30,l/=1e30,s/=1e30),a+=1,s=s*n*(e+1-a)/a;return i/l}function yg(e,t,r){let o=e/t,a=(100-r*100)/2,s,i;if(e===0)s=0;else {let l=o/2,u=0,p=o,m=a/100;for(;p-u>1e-5;)$o(t,l,e,e)*.5+$o(t,l,e+1,t)>m?(p=l,l=(u+l)/2):(u=l,l=(p+l)/2);s=l;}if(e===t)i=0;else {let l=(1+o)/2,u=o,p=1,m=a/100;for(;p-u>1e-5;)$o(t,l,e,e)*.5+$o(t,l,0,e-1)<m?(p=l,l=(u+l)/2):(u=l,l=(p+l)/2);i=l;}return {lci:s,uci:i}}function bg(e,t){let r=e,o=t,n=r,a=o,s=95,i=.5,l=.5,p=(100-s)/2/100,m=n;for(;l>1e-5;)l/=2,An((1+m)*i/(1-i),m+1,1e10)+.5*An((1+m)*i/(1-i),m,m)>p?i-=l:i+=l;let d=(1+m)*i/(1-i)/a;for(i=.5,l=.5,p=(100-s)/2/100;l>1e-5;)l/=2,An((1+m)*i/(1-i),0,m-1)+.5*An((1+m)*i/(1-i),m,m)<p?i-=l:i+=l;let g=(1+m)*i/(1-i)/a;return {lci:d,uci:g}}function An(e,t,r){let o=1,n=0,a=0,s=0;for(;s<e||o>n*1e-10;)n+=o,s>=t&s<=r&&(a+=o),n>1e30&&(a/=1e30,n/=1e30,o/=1e30),s+=1,o=o*e/s;return a/n}var xl,Rl=b(()=>{c();xl={binomialCdf:gg,binP:$o,computeMidP:yg,criticalValue:hg,smr:bg};});function W(e){let t=e.logicFactory(ir);return Ig[e.name]={description:e.description,inputType:e.inputType,logic:Lg(t),testValue:e.testValue,type:e.type||"formatter"},t}function Lg(e){let t=e.toString().trim();if(t.startsWith("function"))return t.replace(/^function(?:\s\w+)?\([^)]\)/,"").trim().replace(/^{([\s\S]+)\}$/,"$1");let r=t.replace(/^.+?=>/,"").trim();return r.startsWith("{")?r.replace(/^{([\s\S]+)\}$/,"$1"):`return ${r}`}var ir,Ig,ae=b(()=>{c();Rl();ir={d3:{...vg,...Sg,...Tg,...xg},d3plus:{assign:assign,closest:closest,date:date,formatAbbreviate:formatAbbreviate,merge:merge,strip:strip,titleCase:titleCase},stats:xl},Ig={};});var El,Cl=b(()=>{c();El={jwt:Og};});var Pn,kl,In=b(()=>{c();ae();Cl();Pn=(e,t={},r="en",o={},n={})=>{let a={setVariables:o.onSetVariables?o.onSetVariables:l=>l,openModal:o.onOpenModal?o.onOpenModal:l=>l,formatters:t,libs:ir,locale:r,...n};function s(l){return Function("globals",...l.vars,`with (globals) { ${l.logic} }`).bind(a,a)}function i(l){if(l.vars&&l.logic)return s(l);for(let u in l)Array.isArray(l[u])?l[u]=l[u].map(p=>isObject(p)?i(p):p):isObject(l[u])&&(l[u]=i(l[u]));return l}return i(e)},kl=(e,t={})=>{let r={libs:El,...t};function o(a){return Function("globals",...a.vars,`with (globals) { ${a.logic} }`).bind(r,r)}function n(a){if(a.vars&&a.logic)return o(a);for(let s in a)Array.isArray(a[s])?a[s]=a[s].map(i=>isObject(i)?n(i):i):isObject(a[s])&&(a[s]=n(a[s]));return a}return n(e)};});function Ln(e,t){let r=Fg[e];if(!r)throw new Error(`Invalid entity type: ${e}`);let{entities:o}=normalize(t,[r]);return {report:Lr(o,"report"),dimension:Lr(o,"dimension"),section:Lr(o,"section"),block:Lr(o,"block"),variant:Lr(o,"variant"),formatter:Lr(o,"formatter"),datasource:Lr(o,"datasource")}}function Lr(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}var Bg,zo,Al,wl,Pl,Mg,Ng,Dg,Fg,Il,Pt,lr=b(()=>{c();co();In();wt();(({localeDefault:Bg}=Pe())),zo=new schema.Entity("block",{},{mergeStrategy(e,t){return t.block_input?e||{}:{...e,...t}}});zo.define({consumers:[zo],inputs:[zo]});Al=new schema.Entity("variant"),wl=new schema.Entity("dimension",{variants:[Al]},{processStrategy(e){return {...e,variants:"variants"in e?e.variants:[]}}}),Pl=new schema.Entity("section",{blocks:[zo]}),Mg=new schema.Entity("report",{dimensions:[wl],sections:[Pl]},{processStrategy(e){return {...e,sections:"sections"in e?e.sections.sort(Ye):[]}}}),Ng=new schema.Entity("formatter"),Dg=new schema.Entity("datasource"),Fg={report:Mg,section:Pl,block:zo,dimension:wl,variant:Al,formatter:Ng,datasource:Dg};Il=(e,t=void 0)=>{let{sid:r,bid:o,previews:n=[],query:a={}}=t||{},s,i,l={};return r?(s=r,l.activeSection=s):s=e.activeSection,n.length>0?(i=n,l.previews=i.filter(Boolean)):i=e.previews,{parsedParams:{sid:s,bid:o,previews:i,query:a},statusPayload:l}},Pt=(e=[],t=Bg)=>e.reduce((r,o)=>{let n=Pn({vars:["n"],logic:o.content.logic},{},t,{});return r[o.name]=n,r},{});});function ht(e,t){return e.request(t).then(r=>{let{status:o,data:n}=r;return "error"in n?{ok:!1,status:o,error:n.error}:{ok:!0,status:o,wrapper:n.wrapper,data:n.data}},r=>{if("isAxiosError"in r){let{status:o,data:n}=r.response||{status:500};return {ok:!1,status:o,error:n?.error??r.message}}return {ok:!1,status:500,error:r.message}})}function Te(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>ht(e,{...o,method:"GET",params:r?r(n):n})}function xe(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>ht(e,{...o,method:"POST",data:r?r(n):n})}function cr(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>ht(e,{...o,method:"DELETE",params:r?r(n):n})}var uo=b(()=>{c();});function po(e,t){return r=>ht(e,{method:"POST",url:`images/save/${t}`,params:{prompt:r.prompt,provider:t}})}var Ll=b(()=>{c();uo();});function Uo(e,t){return r=>ht(e,{method:"GET",url:`images/search/${t}`,params:{prompt:r.prompt,page:r.page,provider:t}})}var Ol=b(()=>{c();uo();});function _l(e,t){return ()=>ht(e,{method:"GET",url:`list/icons/${t}`,params:{provider:t}})}var Bl=b(()=>{c();uo();});function Ml(e,t){return r=>ht(e,{method:"GET",url:`read/icons/${t}/icon.svg`,params:{name:r.name}})}var Nl=b(()=>{c();uo();});function Go(e){let t=Fn.create({baseURL:e});return {createBulkBlock:xe(t,"create/bulk/block"),createBlock:xe(t,"create/block"),createDimension:xe(t,"create/dimension"),createFormatter:xe(t,"create/formatter"),createReport:xe(t,"create/report"),createSection:xe(t,"create/section"),createVariant:xe(t,"create/variant"),createDatasource:xe(t,"create/datasource"),deleteBlock:cr(t,"delete/block",_r),deleteDimension:cr(t,"delete/dimension",_r),deleteFormatter:cr(t,"delete/formatter",_r),deleteReport:cr(t,"delete/report",_r),deleteSection:cr(t,"delete/section",_r),deleteVariant:cr(t,"delete/variant",_r),deleteDatasource:cr(t,"delete/datasource",_r),readBlock:Te(t,"read/block"),readDimension:Te(t,"read/dimension"),readFormatter:Te(t,"read/formatter"),readReport:Te(t,"read/report"),readSection:Te(t,"read/section"),readVariant:Te(t,"read/variant"),readDatasource:Te(t,"read/datasource"),updateBulkBlock:xe(t,"update/bulk/block"),updateBlock:xe(t,"update/block"),updateDimension:xe(t,"update/dimension"),updateFormatter:xe(t,"update/formatter"),updateReport:xe(t,"update/report"),updateSection:xe(t,"update/section"),updateVariant:xe(t,"update/variant"),updateDatasource:xe(t,"update/datasource"),searchReport:Te(t,"search/reports"),validateVariantSlug:Te(t,"validate/variant"),readMember:Te(t,"read/members",$g),readMemberImage:Te(t,{url:"member/image",responseType:"blob"}),searchMember:Te(t,"search/members"),updateMember:Te(t,"update/members"),imageLocalSearch:Uo(t,"local"),imageLocalSave:po(t,"local"),imageFlickrSearch:Uo(t,"flickr"),imageFlickrSave:po(t,"flickr"),imageUnsplashSearch:Uo(t,"unsplash"),imageUnsplashSave:po(t,"unsplash"),imageUploadSave:po(t,"upload"),imageAdobeSearch:Uo(t,"adobe"),imageAdobeSave:po(t,"adobe"),readMetadata:Te(t,"read/metadata"),regenerateSearch:xe(t,"search/regenerate"),urlProxy:Te(t,"url/proxy"),searchRole:Te(t,"auth/search/roles"),searchUser:Te(t,"auth/search/users"),readUser:Te(t,"auth/read/user"),updateUser:xe(t,"auth/update/user"),updateMyData:xe(t,"auth/update/me"),revalidateReport:Te(t,"revalidate/report"),revalidateUrl:Te(t,"revalidate/url"),readPrivateBlocks:xe(t,"read/blocks/private"),listTablerIcons:_l(t,"tabler"),readTablerIcon:Ml(t,"tabler"),readEnvSecrets:Te(t,"read/secrets")}}var _r,$g,Dl=b(()=>{c();Ll();Ol();uo();Bl();Nl();_r=e=>({id:e}),$g=e=>{if(e.mode==="slugs"){let t=e.slugs.map(r=>[r.variantSlug,r.memberSlug].join("/")).join(",");return {...e,slugs:t}}return ["related","whole"].includes(e.mode)?{...e}:{...e,[e.mode]:e[e.mode].join(",")}};});var za=b(()=>{c();Dl();});var Fl=b(()=>{c();});var Vl=b(()=>{c();Fl();});function ut(e){return {variables:e.variables||{},query:e.query||{},locale:e.locale||Gg}}var Gg,mo=b(()=>{c();Vl();wt();({localeDefault:Gg}=Pe());});var Br,$l,Ae,_n,zl,Ua,qg,Hg,jg,Wg,Ga,qa,h,ge,Re,Kt,Ul,On,fe=b(()=>{c();Br={REPORT:"report",SECTION:"section",BLOCK:"block",INPUT:"block_input",FORMATTER:"formatter",DATASOURCE:"datasource",DIMENSION:"report_dimension",VARIANT:"report_dimension_variant",SEARCH:"search"},[Br.BLOCK,Br.SEARCH],{[Br.SECTION]:"report_id",[Br.DIMENSION]:"report_id",[Br.VARIANT]:"dimension_id",[Br.BLOCK]:"section_id",[Br.INPUT]:"block_id"},$l={REPORT:"report",STORY:"story"},Ae={SINGLE:"single",MULTI:"multi"},_n={SEGMENTED_CONTROL:"segmented control",SELECTOR:"selector"},zl={TITLE:"title",SUBTITLE:"subtitle",LABEL:"label"},{[$l.REPORT]:Object.values(zl),[$l.STORY]:Object.values(zl)},Ua={ALLOWED:"allowed",ALLOWED_LOGIC:"allowedLogic",IGNORE_CASCADE:"ignoreCascade"},qg={ACCESS:"access",ACCESS_LOGIC:"accessLogic"},Hg={DISABLED:"disabled"},jg={FALLBACK:"fallback"},{...Ua},{POSITION:"position",ICON:"icon",...Ua},Wg={IMAGE:"image",PARAGRAPH:"paragraph",SELECTOR:"selector",STAT:"stat",SUBTITLE:"subtitle",TITLE:"title",NAV:"nav",RESET_BUTTON:"reset_button",COMPARISON_BUTTON:"comparison_button",TABLE:"table",BUTTON:"button",MULTIHIERARCHY_SELECTOR:"multihierarchy_selector",FALLBACK:"fallback"},Ga={GENERATOR:"generator",RELATED:"related",VIZ:"visualization",SECTION_FLAG:"section_flag"},qa="logic",h={...Wg,...Ga},[h.GENERATOR,h.SECTION_FLAG,h.SELECTOR,h.VIZ,h.IMAGE,h.TABLE,h.MULTIHIERARCHY_SELECTOR],ge={ALT:"alt",AUTHOR:"author",DESC:"desc",FOOTNOTE:"footnote",BIO:"bio",IMAGE:"image",LABEL:"label",LOGIC:"logic",MULTIHIERARCHY_SELECTOR:"multihierarchySelector",MULTIHIERARCHY_SELECTOR_ALL_LABEL:"multihierarchySelectorAllLabel",MULTIHIERARCHY_SELECTOR_NAME:"multihierarchySelectorName",MULTIHIERARCHY_SELECTOR_PLACEHOLDER:"multihierarchySelectorPlaceholder",SIMPLE:"simple",SIMPLE_ENABLED:"simpleEnabled",PARAGRAPH:"paragraph",SELECTOR_DEFAULT:"selectorDefault",SELECTOR_DYNAMIC:"selectorDynamic",SELECTOR_NAME:"selectorName",SELECTOR_TYPE:"selectorType",SRC:"src",SLUG:"slug",SUBTITLE:"subtitle",TABLE:"table",TITLE:"title",TOOLTIP:"tooltip",TWITTER:"twitter",URL:"url",VALUE:"value"},[ge.LOGIC,ge.SIMPLE,ge.SIMPLE_ENABLED],Re={ENABLE_ALL:{bubbleMenu:!0,toolbarOptions:{history:!0,alignment:!1,format:!0}},DISABLE_ALL:{bubbleMenu:!1,toolbarOptions:{history:!1,alignment:!1,format:!1}},ENABLE_FORMAT:{bubbleMenu:!0,toolbarOptions:{history:!0,alignment:!1,format:!0}}},{[h.IMAGE]:[{field:ge.TITLE,editorConfig:Re.ENABLE_ALL},{field:ge.SRC,editorConfig:Re.DISABLE_ALL},{field:ge.ALT,editorConfig:Re.DISABLE_ALL},{field:ge.DESC,editorConfig:Re.ENABLE_ALL}],[h.PARAGRAPH]:[{field:h.PARAGRAPH,editorConfig:Re.ENABLE_ALL},{field:ge.TOOLTIP,editorConfig:Re.ENABLE_FORMAT}],[h.SELECTOR]:[{field:ge.SELECTOR_DEFAULT},{field:ge.SELECTOR_DYNAMIC},{field:ge.SELECTOR_NAME,editorConfig:Re.ENABLE_FORMAT},{field:ge.SELECTOR_TYPE}],[h.STAT]:[{field:ge.TITLE,editorConfig:Re.ENABLE_FORMAT},{field:ge.SUBTITLE,editorConfig:Re.ENABLE_FORMAT},{field:ge.VALUE,editorConfig:Re.ENABLE_FORMAT},{field:ge.TOOLTIP,editorConfig:Re.ENABLE_FORMAT}],[h.SUBTITLE]:[{field:ge.SUBTITLE,editorConfig:Re.ENABLE_FORMAT},{field:ge.TOOLTIP,editorConfig:Re.ENABLE_FORMAT}],[h.TITLE]:[{field:ge.TITLE,editorConfig:Re.ENABLE_FORMAT},{field:ge.SLUG,editorConfig:Re.DISABLE_ALL},{field:ge.TOOLTIP,editorConfig:Re.ENABLE_FORMAT}],[h.BUTTON]:[{field:ge.LABEL,editorConfig:Re.ENABLE_FORMAT},{field:ge.URL,editorConfig:Re.ENABLE_FORMAT}],[h.GENERATOR]:[],[h.SECTION_FLAG]:[],[h.VIZ]:[],[h.TABLE]:[],[h.MULTIHIERARCHY_SELECTOR]:[{field:ge.MULTIHIERARCHY_SELECTOR_NAME,editorConfig:Re.ENABLE_FORMAT},{field:ge.MULTIHIERARCHY_SELECTOR_PLACEHOLDER,editorConfig:Re.DISABLE_ALL},{field:ge.MULTIHIERARCHY_SELECTOR_ALL_LABEL,editorConfig:Re.DISABLE_ALL}]},Kt={NAME:"name",DESCRIPTION:"description",...Ua,...qg,...jg,...Hg},Ul={FORMATTER:"formatter",FUNCTION:"function"},{[Ul.FORMATTER]:"Formatter",[Ul.FUNCTION]:"Function"},On={STRING:"string",NUMBER:"number",OBJECT:"object",DATE:"date"},{[On.STRING]:"String",[On.NUMBER]:"Number",[On.OBJECT]:"Object/Array",[On.DATE]:"Date"};});function Zg(e,t,r,o,n=void 0,a){let s={},i=[],{locale:l}=ut(a);try{if(t){let u=new Proxy(console,{get(m,d){return Jg(d,"log","debug","info","warn","error")?(...f)=>{i.push(`${d} ${Date.now()} - ${f.map(g=>format(g)).join(" ")}`),Qg&&m[d](...f);}:m[d]}}),p;return n?p=new Function(e,"console","libs","formatters","locale","variables",r)(t,u,ir,o,l,n):p=new Function(e,"console","libs","formatters","locale",r)(t,u,ir,o,l),typeof p=="object"&&Object.keys(p).length>0&&Object.assign(s,p),{vars:s,error:null,log:i,output:p}}return {vars:s,error:"Invalid API Link",log:i}}catch(u){return {vars:s,error:u.message,log:i}}}function Jg(e,...t){return t.includes(e)}var Qg,It,qo=b(()=>{c();mo();ae();Qg=Yg(process.env.REPORTS_LOGGING),It=Zg;});function Ha(e){return e.reduce((t,r,o)=>(o?o===e.length-1&&o===1?t+=` and ${r}`:o===e.length-1?t+=`, and ${r}`:t+=`, ${r}`:t+=r,t),"")}var Gl=b(()=>{c();});function eh(e,t,r,o=!1){let{variables:n}=ut(r);if(!e)return e;let a=/([A-z0-9]*)\{\{([^\}]+)\}\}/g;return e.replace(a,(i,l,u)=>{let p=d=>d;if(l){let d=l.replace(/^\w/g,f=>f.toLowerCase());d in t?p=t[d]:p=f=>`${l}${f}`;}let m=Array.isArray(n[u])?Ha(n[u]):n[u];if(m===void 0)return o?i:"N/A";try{return p(m,ir,t)}catch(d){return console.error(`Error using formatter ${p.name}
|
|
47
|
-
`,`Error message: ${d.message}`),"N/A"}})}var tt,fo=b(()=>{c();mo();Gl();ae();tt=eh;});var ja,pt,Mr=b(()=>{c();fo();ja=(e,t,r)=>{let{variables:o}=r,n=s=>s.allowed==="never"?!1:!s.allowed||s.allowed==="always"||o[s.allowed],a={...e};return Object.keys(a).forEach(s=>{typeof a[s]=="string"?a[s]=tt(a[s],t,r):Array.isArray(a[s])?a[s]=a[s].filter(n).map(i=>typeof i=="object"?ja(i,t,r):typeof i=="string"?tt(i,t,r):i):typeof a[s]=="object"&&a[s]!==null&&!(a[s]instanceof Date)&&(a[s]=ja(a[s],t,r));}),a},pt=ja;});var ql,Hl=b(()=>{c();ql=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];});var th,Nr,Bn=b(()=>{c();fe();th=(e,t,r)=>{if(!r)return !1;if(e===Ae.SINGLE)return r.find(n=>n.id===t);let o=Array.isArray(t)?t:t.split(",");return Array.isArray(o)&&o.every(n=>r.map(a=>a.id).includes(n))},Nr=th;});function go(e,t,r,o,n=!1){let{variables:a}=ut(o),s=pt({logic:t},r,o).logic,i=It("variables",a,s,r,void 0,o),{vars:l,log:u,error:p}=i,m=l.type||Ae.SINGLE,d=l.component||"Selector",f=l.hideLabel||"false",g=l.resetSectionVars||"false",y=l.name||"Unlabeled Selector",T=ql(l.options||[]),C=z=>m===Ae.MULTI&&!Array.isArray(z)?[z]:z,B=l.defaultValue,E;if(B&&(B=C(B),Nr(m,B,T)&&(E=B)),!E){let z=T&&T[0]&&T[0].id||T[0]||"";E=C(z);}if(n&&typeof window<"u"){let z=`selector${e}id`,K=new URLSearchParams(window.location.search),I=Object.fromEntries(K)[z];I&&!Nr(m,I,T)&&I!==void 0&&(K.delete(z),window.history.replaceState(null,null,`?${K.toString()}`));}return {config:{name:y,type:m,options:T,defaultValue:E,component:d,hideLabel:f,resetSectionVars:g},log:u,error:p}}var Wa=b(()=>{c();mo();fe();qo();Mr();Hl();Bn();});function Ka(e,t,r){if(!e)return !1;let o=Array.isArray(r)?r:r.split(",");return Array.isArray(o)&&o.every(n=>e.map(a=>`${a[`${t} ID`]}`).includes(n))}var jl=b(()=>{c();});function ho(e,t,r,o,n=!1){let{variables:a}=ut(o),s=pt({logic:t},r,o).logic,i=It("variables",a,s,r,void 0,o),{vars:l,log:u,error:p}=i;if(n&&typeof window<"u"){let d=`multihierarchySelector${e}-value`,f=`multihierarchySelector${e}-type`,g=new URLSearchParams(window.location.search),y=Object.fromEntries(g),T=y[d],C=y[f];T&&T!==void 0&&C&&C!==void 0&&!Ka(l.data,C,T)&&(g.delete(d),g.delete(f),window.history.replaceState(null,null,`?${g.toString()}`));}return {config:l,log:u,error:p}}var Ya=b(()=>{c();jl();mo();qo();Mr();});var rh,Wl,Kl=b(()=>{c();fe();rh=(e,t,r)=>{let o=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),a=new URLSearchParams(t).get(o),s=n||a;if(r.type===Ae.MULTI){let u=s?s.split(","):r.defaultValue,p=r.options.filter(m=>u.includes(m.id));return {[`selector${e}id`]:u,[`selector${e}label`]:(p||[]).map(m=>m.label)}}let i=s&&r.options.find(u=>u.id===s)?s:r.defaultValue,l=r.options.find(u=>u.id===i);return {[`selector${e}id`]:i,[`selector${e}label`]:l&&l.label||void 0}},Wl=rh;});var oh,Yl,Xl=b(()=>{c();oh=(e,t,r)=>{let o=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,a=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),s=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),i=new URLSearchParams(t).get(o),l=new URLSearchParams(t).get(n),u=a||i,p=s||l,m=u?u.split(","):r.defaultValue||[],d=p||r.defaultValueType||"",f=r.data?.filter(g=>m.includes(`${g[`${d} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:m,[`multihierarchySelector${e}label`]:[...new Set((f||[]).map(g=>g[d]))],[`multihierarchySelector${e}type`]:d}},Yl=oh;});var Ql,nh,ah,sh,Me,Dr=b(()=>{c();fe();wt();(({localeDefault:Ql,locales:nh}=Pe())),ah=Object.values(Ga),sh=(e,t=Ql)=>e&&ah.includes(e.type)?{locale:qa,locales:[qa]}:{locale:t,locales:nh},Me=(e,t=Ql)=>{if(!e)return {};let{locale:r}=sh(e,t);return e.contentByLocale?.[r]?.content};});function ih(e,t){let r=Object.values(t),o=r.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(r.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(a=>o.includes(a)))).map(n=>[n.id,n]))}var Zl,Jl=b(()=>{c();Zl=ih;});var ec,tc=b(()=>{c();ec=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((r,o)=>r[o],e):e;});var Mn,rc,Xa=b(()=>{c();Mn="|||",rc="SECTION_ALLOWED";});function Qa(e){return e.type===h.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var oc=b(()=>{c();fe();});function ch(){let{publicRuntimeConfig:e}=lh(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((r,o)=>(r[`ENV_${o}`]=t[o]||"N/A",r),{})}}var ur,Ho=b(()=>{c();ur=ch;});function uh(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,r])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:r}),{})}var nc,ac=b(()=>{c();nc=uh;});function Dn(e){return e.ok!==void 0}function Nn(e){this.message=e,this.name="ApiFetchException";}async function Za(e,t,r="en",o,n){let a=Date.now(),s=e,i,l=ur(),u=nc(),p={envs:{...l,...u}},
|
|
47
|
+
`,`Error message: ${d.message}`),"N/A"}})}var tt,fo=b(()=>{c();mo();Gl();ae();tt=eh;});var ja,pt,Mr=b(()=>{c();fo();ja=(e,t,r)=>{let{variables:o}=r,n=s=>s.allowed==="never"?!1:!s.allowed||s.allowed==="always"||o[s.allowed],a={...e};return Object.keys(a).forEach(s=>{typeof a[s]=="string"?a[s]=tt(a[s],t,r):Array.isArray(a[s])?a[s]=a[s].filter(n).map(i=>typeof i=="object"?ja(i,t,r):typeof i=="string"?tt(i,t,r):i):typeof a[s]=="object"&&a[s]!==null&&!(a[s]instanceof Date)&&(a[s]=ja(a[s],t,r));}),a},pt=ja;});var ql,Hl=b(()=>{c();ql=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];});var th,Nr,Bn=b(()=>{c();fe();th=(e,t,r)=>{if(!r)return !1;if(e===Ae.SINGLE)return r.find(n=>n.id===t);let o=Array.isArray(t)?t:t.split(",");return Array.isArray(o)&&o.every(n=>r.map(a=>a.id).includes(n))},Nr=th;});function go(e,t,r,o,n=!1){let{variables:a}=ut(o),s=pt({logic:t},r,o).logic,i=It("variables",a,s,r,void 0,o),{vars:l,log:u,error:p}=i,m=l.type||Ae.SINGLE,d=l.component||"Selector",f=l.hideLabel||"false",g=l.resetSectionVars||"false",y=l.name||"Unlabeled Selector",T=ql(l.options||[]),C=z=>m===Ae.MULTI&&!Array.isArray(z)?[z]:z,B=l.defaultValue,E;if(B&&(B=C(B),Nr(m,B,T)&&(E=B)),!E){let z=T&&T[0]&&T[0].id||T[0]||"";E=C(z);}if(n&&typeof window<"u"){let z=`selector${e}id`,K=new URLSearchParams(window.location.search),I=Object.fromEntries(K)[z];I&&!Nr(m,I,T)&&I!==void 0&&(K.delete(z),window.history.replaceState(null,null,`?${K.toString()}`));}return {config:{name:y,type:m,options:T,defaultValue:E,component:d,hideLabel:f,resetSectionVars:g},log:u,error:p}}var Wa=b(()=>{c();mo();fe();qo();Mr();Hl();Bn();});function Ka(e,t,r){if(!e)return !1;let o=Array.isArray(r)?r:r.split(",");return Array.isArray(o)&&o.every(n=>e.map(a=>`${a[`${t} ID`]}`).includes(n))}var jl=b(()=>{c();});function ho(e,t,r,o,n=!1){let{variables:a}=ut(o),s=pt({logic:t},r,o).logic,i=It("variables",a,s,r,void 0,o),{vars:l,log:u,error:p}=i;if(n&&typeof window<"u"){let d=`multihierarchySelector${e}-value`,f=`multihierarchySelector${e}-type`,g=new URLSearchParams(window.location.search),y=Object.fromEntries(g),T=y[d],C=y[f];T&&T!==void 0&&C&&C!==void 0&&!Ka(l.data,C,T)&&(g.delete(d),g.delete(f),window.history.replaceState(null,null,`?${g.toString()}`));}return {config:l,log:u,error:p}}var Ya=b(()=>{c();jl();mo();qo();Mr();});var rh,Wl,Kl=b(()=>{c();fe();rh=(e,t,r)=>{let o=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),a=new URLSearchParams(t).get(o),s=n||a;if(r.type===Ae.MULTI){let u=s?s.split(","):r.defaultValue,p=r.options.filter(m=>u.includes(m.id));return {[`selector${e}id`]:u,[`selector${e}label`]:(p||[]).map(m=>m.label)}}let i=s&&r.options.find(u=>u.id===s)?s:r.defaultValue,l=r.options.find(u=>u.id===i);return {[`selector${e}id`]:i,[`selector${e}label`]:l&&l.label||void 0}},Wl=rh;});var oh,Yl,Xl=b(()=>{c();oh=(e,t,r)=>{let o=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,a=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),s=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),i=new URLSearchParams(t).get(o),l=new URLSearchParams(t).get(n),u=a||i,p=s||l,m=u?u.split(","):r.defaultValue||[],d=p||r.defaultValueType||"",f=r.data?.filter(g=>m.includes(`${g[`${d} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:m,[`multihierarchySelector${e}label`]:[...new Set((f||[]).map(g=>g[d]))],[`multihierarchySelector${e}type`]:d}},Yl=oh;});var Ql,nh,ah,sh,Me,Dr=b(()=>{c();fe();wt();(({localeDefault:Ql,locales:nh}=Pe())),ah=Object.values(Ga),sh=(e,t=Ql)=>e&&ah.includes(e.type)?{locale:qa,locales:[qa]}:{locale:t,locales:nh},Me=(e,t=Ql)=>{if(!e)return {};let{locale:r}=sh(e,t);return e.contentByLocale?.[r]?.content};});function ih(e,t){let r=Object.values(t),o=r.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(r.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(a=>o.includes(a)))).map(n=>[n.id,n]))}var Zl,Jl=b(()=>{c();Zl=ih;});var ec,tc=b(()=>{c();ec=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((r,o)=>r[o],e):e;});var Mn,rc,Xa=b(()=>{c();Mn="|||",rc="SECTION_ALLOWED";});function Qa(e){return e.type===h.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var oc=b(()=>{c();fe();});function ch(){let{publicRuntimeConfig:e}=lh(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((r,o)=>(r[`ENV_${o}`]=t[o]||"N/A",r),{})}}var ur,Ho=b(()=>{c();ur=ch;});function uh(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,r])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:r}),{})}var nc,ac=b(()=>{c();nc=uh;});function Dn(e){return e.ok!==void 0}function Nn(e){this.message=e,this.name="ApiFetchException";}async function Za(e,t,r="en",o,n){let a=Date.now(),s=e,i,l=ur(),u=nc(),p={envs:{...l,...u}},m=new URL(e),d=new URLSearchParams(m.searchParams.toString());d.has("bespoke_slugs")&&(m.searchParams.delete("bespoke_slugs"),s=m.toString());let f={datasource:void 0};o.find(B=>{if(!B.content?.pattern)return !1;try{let E=new RegExp(B.content.pattern,"gm");return E.test(s)?(f.datasource=B,!0):E.test(s)}catch{return !1}});let g=n?n.settings:{},y=!!(g&&g.useProxy&&g.useProxy==="true"),T=f.datasource&&typeof f.datasource.content.useProxy=="boolean"?f.datasource.content.useProxy:!1,C=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(s)}`;if(typeof window=="object"&&(y||T)){let B=await yh({url:s,timeout:ic});if(B.ok===!0)i=B.data;else throw new Nn(B?.error)}else try{let E={url:s,timeout:ic};if(f.datasource){let K=await kl({vars:["url","libs"],logic:f.datasource.content.logic},p)(s);if(K.axiosConfig)E=K.axiosConfig;else throw new Nn(`AxiosConfig is missing in Data Source ${f.datasource.name} (ID: ${f.datasource.id}).`)}let _=await Fn(E);if(_.status===200)_.headers["content-type"]==="text/csv"?i=csvParse(_.data):i=_.data;else throw new Nn("No response for: "+s)}catch(B){throw new Nn(B.message)}if(d.has("bespoke_slugs")){let B=d.get("bespoke_slugs");if(B){let E=B.split(",");if(E.length===3){let[_,z,K]=E,w=ec(i,K);if(w&&Array.isArray(w)){let I=Array.from(new Set(w.map(k=>`${k[z]}`).filter(k=>!["","undefined"].includes(k))));if(I.length>0){let k=I.join("").length>2e3,M=await t({mode:k?"whole":"ids",ids:k?void 0:I,all:!1,locale:r,variant:[parseInt(_,10)],output:"lite",limit:I.length+1,allowNulls:!0}).then(x=>{let A=[];return Dn(x)?x.ok&&(A=x.data.results):A=x.results,A&&Array.isArray(A)?A:[]}).catch(x=>(console.error(`Error hydrating slugs for Variant: ${_}, Key: ${z}, Accessor: ${K}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(x),[]));if(M){let x=Object.fromEntries(M.map(A=>[A.id,`/${A.variant_slug}/${A.slug}`]));w.map(A=>(A.bespoke_slug=x[A[z]]?x[A[z]]:null,A));}}}}}}return {data:i,requestDuration:Date.now()-a,finalUrl:T||y?C:s,apiDataSource:f.datasource?f.datasource:!1}}function bh(e){this.name="BlockException",this.message=e;}async function lc(e,t,r,o,n){let{locale:a,variables:s,query:i}=ut(r),l=vh(e,r,s,t),u=null,p=e.contentByLocale?.logic?.content?.api,m=null,d=null,f=null,g=null,y=null;if(!l)return {outputVariables:{},renderVariables:{},status:{allowed:!1,hiddenByCascade:e.id}};if(e.type===h.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:l,hiddenByCascade:e.id}};if(p){f=hh(p,t,r);let w=f.split(Mn).filter(M=>M!==""),I=[];for(let M=0;M<w.length;M++){let x=w[M];new RegExp("^(?:[a-z+]+:)?//","i").test(f)||(x=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${x}`.replace(/([^:]\/)\/+/g,"$1")),I.push(Za(x,o,a,n,e).catch(U=>{throw new bh(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${s.report_name} (${s.report_id}) failed.
|
|
48
48
|
Error fetching ${x}.
|
|
49
49
|
Message: ${U.message}.
|
|
50
50
|
`)}));}let k=await Promise.all(I).catch(M=>M.message);if(typeof k=="string"&&k)return {outputVariables:{},renderVariables:{},status:{error:k}};u=k.length===1?k[0].data:k.map(M=>M.data),d=k.reduce((M,x)=>M+JSON.stringify(x.data).length/1024,0),m=Math.max(...k.map(M=>M.requestDuration)),g=k.map(M=>M.apiDataSource?`${M.apiDataSource.name} (${M.apiDataSource.id})`:!1),y=k.map(M=>M.finalUrl);}if(e.type===h.SELECTOR){let{config:w,log:I,error:k}=go(e.id,e.contentByLocale[a].content.logic,t,r,!0);return {outputVariables:Wl(e.id,i,w),renderVariables:w,status:{log:I,error:k,allowed:l}}}if(e.type===h.MULTIHIERARCHY_SELECTOR){let{config:w,log:I,error:k}=ho(e.id,e.contentByLocale[a].content.logic,t,r,!0);return {outputVariables:Yl(e.id,i,w),renderVariables:w,status:{log:I,error:k,allowed:l}}}if(e.type===h.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:l}};if(e.type===h.RELATED){let w=e.contentByLocale?.logic?.content?.simple?.compare||"variant",I=e.contentByLocale?.logic?.content?.simple?.limit||4,k=Object.keys(s).filter(L=>L.startsWith("report_id")).map(L=>s[L]),M=Object.keys(s).filter(L=>L.startsWith("dimension_id")).map(L=>s[L]),x=Object.keys(s).filter(L=>L.startsWith("variant_id")).map(L=>s[L]),A=Object.keys(s).filter(L=>L.startsWith("id")).map(L=>s[L]);if(!A.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:!1}};let U=await Promise.all(A.map((L,G)=>o({mode:"ids",locale:a,ids:[L],output:"lite",variant:[x[G]]}))).then(L=>L.flatMap(G=>{let V=[];return Dn(G)?G.ok&&(V=G.data.results):V=G.results,V&&Array.isArray(V)?V:[]})).catch(L=>(console.error("Error getting related members",L),[]));if(M.length>1){let L=Object.keys(s).filter(Y=>Y.startsWith("variant_slug")).map(Y=>s[Y]),G=U.map((Y,R)=>{let P={mode:"related",locale:a,related:I??4,current_ids:[Y.content_id],output:"full",variant_ids:[Y.variant_id]};return R===0&&(P.include_ids=[Y.content_id]),P}),V=await Promise.all(G.map(Y=>o(Y))).then(Y=>Y.flatMap(R=>{let P=[];return Dn(R)?R.ok&&(P=R.data.results):P=R.results,P&&Array.isArray(P)?P:[]})).catch(Y=>(console.error("Error getting related members",Y),[])),ie=V.reduce((Y,R)=>{let P=R.variant_slug;return Y[P]||(Y[P]=[]),Y[P].push(R),Y},{}),H=[],oe=Object.keys(ie),J=[{combination:[],index:0}];for(;J.length>0;){let Y=J.pop();if(!Y)continue;let{combination:R,index:P}=Y;if(P===oe.length){H.push(R);continue}let j=oe[P],Z=ie[j];for(let X of Z)J.push({combination:[...R,X],index:P+1});}return {outputVariables:{related_reports:H.map(Y=>{let R=Y.sort((P,j)=>L.indexOf(P.variant_slug)-L.indexOf(j.variant_slug));return {entities:R,link:"/"+R.map(P=>`${P.variant_slug}/${P.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:V.length>0}}}let O=U.map(L=>L.content_id),D={mode:"related",locale:a,related:I??4,current_ids:O,output:"full"};w&&(w==="report"?D.report_ids=k:w==="dimension"?D.dimension_ids=M:D.variant_ids=x);let q=await o(D).then(L=>{let G=[];return Dn(L)?L.ok&&(G=L.data.results):G=L.results,G&&Array.isArray(G)?G:[]}).catch(L=>(console.error("Error getting related members",L),[]));return {outputVariables:{related_reports:q.map(L=>({entities:[L],link:`/${L.variant_slug}/${L.slug}`}))},renderVariables:{},status:{log:[],allowed:q.length>0}}}let{logic:T}=Me(e,a),C=tt(T,t,r),B=It("resp",u||{},C,t,s,r),{vars:E,error:_,log:z}=B;if(typeof E!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:z,duration:m,responseSize:d,resp:u,api:f,allowed:l,apiFinalUrls:y,apiDataSources:g}};let K=Object.keys(E).reduce((w,I)=>({...w,[`${e.type}${e.id}${I}`]:E[I]}),{});return {renderVariables:E,outputVariables:[h.GENERATOR,h.SECTION_FLAG].includes(e.type)?E:K,status:{log:z,error:_,duration:m,responseSize:d,resp:u,api:f,allowed:l,apiFinalUrls:y,apiDataSources:g}}}function Vn(e,t,r,o,n,a,s){return e.consumers.forEach(i=>{if(t[i]){let l=`${r}-${i}`;!o.includes(l)&&(t[i].section_id===t[r].section_id||!n)&&o.push(l),e.consumers.filter(u=>t[u]&&t[u].section_id===t[r].section_id||!n).forEach(u=>Ja(u,t,o,!1,a,n,s));}})}var pr,fh,gh,cc,hh,yh,ic,Ja,vh,Lt,Fr=b(()=>{c();za();mo();fe();Wa();Ya();Kl();Xl();qo();fo();Dr();Jl();tc();Xa();oc();In();Ho();ac();pr=Yg(process.env.NEXT_PUBLIC_REPORTS_DEBUG),fh=process.env.REPORTS_ORIGIN||"",gh=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,cc=5;try{cc=parseInt(`${gh||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}sc(Fn,{retries:cc,retryDelay:sc.exponentialDelay,onRetry:(e,t,r)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",r.url),console.error(t.message);}});Fn.interceptors.request.use(e=>({...e,requestStart:Date.now()}));Fn.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));hh=(e,t,r)=>{let o=tt(e,t,r);return o.startsWith("http")||(o=`${fh}${o.startsWith("/")?"":"/"}${o}`),o},{urlProxy:yh}=Go("/api/cms");ic=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;Ja=(e,t,r=[],o=!0,n=!0,a=!0,s=[])=>{if(s.includes(e))return [];s.push(e);let i=t[e];return i&&i.inputs.length&&o&&i.inputs.forEach(l=>{let u=`${l}-${e}`;r.includes(u)||r.push(u),i.inputs.forEach(p=>Ja(p,t,r,o,!1,a,s));}),i&&i.consumers.length&&n&&Vn(i,t,e,r,a,n,s),r},vh=(e,t,r,o)=>{let n=!0;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=!1;else {let a=ut(t),{error:s,output:i}=It("variables",r,e.settings.allowedLogic||"return false;",o,void 0,a);s||(n=!!i);}return n},Lt=async(e,t,r,o,n,a={},s,i="section",l)=>{let u=i==="section",p=ut(n),m=p.variables,d={...a.variables??{}},f={...a.status??{}},g=new Set,y=[],T={};r?T={...T,[r]:e[r]}:t?T=(t??[]).reduce((O,{id:D})=>({...O,...Zl(D,e)}),{}):T=Object.values(e).filter(O=>Qa(O)).reduce((O,D)=>({...O,[D.id]:D}),{});let C=Object.values(T).filter(O=>Qa(O));if(C.length>0){pr&&console.info("%crunConsumers: calculating section flags","color:purple",C.map(F=>F.id).join(", "));let O=Object.fromEntries(await Promise.all(C.map(async F=>[F.id,await lc(F,o,{...p,variables:m,locale:m.locale},s,l).then(L=>{let{outputVariables:G,status:V}=L;if(V.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${F.id}, Section ${F.section_id}) failed with message: ${V.error}. `);f[F.id]={allowed:!1,error:V.error},d[F.id]={};}return (F.consumers.length>0||[h.GENERATOR,h.SECTION_FLAG,h.RELATED].includes(F.type))&&V.allowed&&Object.keys(G).length>0?d[F.id]=G:d[F.id]={},i==="report"?(f[F.id]={allowed:V.allowed},[h.GENERATOR,h.SECTION_FLAG].includes(F.type)&&V.api&&(f[F.id].api=V.api)):f[F.id]=V,L})]))),q=Object.entries(O).filter(([,F])=>!F.outputVariables[rc]).map(([F])=>Number(F));g=new Set(q.map(F=>e[F].section_id)),Object.values(T).filter(F=>g.has(F.section_id)).forEach(F=>{y.push(F.id),delete T[F.id];}),pr&&console.info("%crunConsumers: removing sections","color:purple",g.keys());}let B=g.size>0?Object.fromEntries(Object.entries(e).filter(([,O])=>g?.has(O.section_id)?(y.includes(O.id)||y.push(O.id),!1):!0)):e;if(y.length>0&&(B=Object.fromEntries(Object.entries(B).map(([O,D])=>{let q={...D,inputs:D.inputs.filter(F=>!y.includes(F)),consumers:D.consumers.filter(F=>!y.includes(F))};return [O,q]}))),!r&&!t)return {variables:{...a.variables??{},...d},status:{...a.status??{},...f}};i==="report"&&y.length>0&&y.forEach(O=>{delete d[O],delete f[O],delete e[O];}),pr&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(T));let E=Object.keys(T).reduce((O,D)=>{let q=new Date,F=Ja(Number(D),B,[],!r,!0,u).map(V=>V.split("-")),G=(new Date().getTime()-q.getTime())/1e3;return pr&&console.info(`%cResolved dependencies for ${D} (${G.toFixed(2)}s)`,"color:blue"),[...O,...F]},[]),_=new Date,z=Object.keys(T).reduce((O,D)=>O.includes(D)?[...O]:[D,...O],ph(E)),w=(new Date().getTime()-_.getTime())/1e3;pr&&console.info(`%cResolved DAG (${w.toFixed(2)}s): `,"color:green",z);let I=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,k=parseInt(`${I||0}`,10);async function M(O,D){let q=new Map,F=[],L=async()=>F.length;for(let G of O){if(k!==0){let oe=await L();for(;oe>=k;)pr&&console.info("Too many pending promises, waiting...",oe,F),await new Promise(J=>setTimeout(J,500)),oe=await L();}let V=D[G],H=Promise.all(V.inputs.filter(oe=>O.includes(String(oe))).map(oe=>q.get(Number(oe)))).then(async()=>{let oe=V.inputs.reduce((Z,X)=>({...Z,...d[X]}),m),J=V.inputs.find(Z=>(V.settings?.ignoreCascade?V.settings?.ignoreCascade:[]).includes(Z)||!f[Z]?!1:!f[Z].allowed||f[Z].hiddenByCascade);if(J){f[G]={allowed:!1,hiddenByCascade:f[J].hiddenByCascade||J},d[G]={},F.splice(F.indexOf(Number(G)),1);return}let te=new Date,Y;typeof window<"u"&&[h.SELECTOR,h.MULTIHIERARCHY_SELECTOR].includes(V.type)&&V.settings[Kt.DISABLED]?Y=new Promise(Z=>{Z({outputVariables:d[G],status:f[G]});}):Y=lc(V,o,{...p,variables:oe,locale:oe.locale},s,l);let R=await Y.then(({outputVariables:Z,status:X})=>{if(X.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${G}, Section ${V.section_id}) failed with message: ${X.error}.`);f[G]={allowed:!1,error:X.error},d[G]={};}(V.consumers.length>0||[h.GENERATOR,h.SECTION_FLAG,h.RELATED].includes(V.type))&&X.allowed&&Object.keys(Z).length>0?d[G]=Z:d[G]={},i==="report"?(f[G]={allowed:X.allowed},[h.GENERATOR,h.SECTION_FLAG].includes(V.type)&&X.api&&(f[G].api=X.api)):f[G]=X;}),j=(new Date().getTime()-te.getTime())/1e3;return pr&&console.info(`%cBlock ${V.id} resolved in ${j.toFixed(3)}s`,j>500?"color:red":"color:green"),f[G].duration=f[G].duration?f[G].duration:j,F.splice(F.indexOf(Number(G)),1),R}).catch(oe=>{throw F.splice(F.indexOf(Number(G)),1),oe});F.push(Number(G)),q.set(Number(G),H);}await Promise.all(Array.from(q.values()));}let x=new Date;await M(z,B);let U=(new Date().getTime()-x.getTime())/1e3;return pr&&console.info(`%cResolved Variables (${U.toFixed(2)}s), ${z.length} blocks`,"color:green"),{variables:{...a.variables??{},...d},status:{...a.status??{},...f}}};});function Sh(e=[]){return e.reduce((t,r,o)=>{if(r){let n=o+1;t[`id${n}`]=r.id,t[`name${n}`]=r.name,t[`slug${n}`]=r.slug,"attributes"in r&&Object.keys(r.attributes).forEach(a=>{t[`attr_${a}${n}`]=r.attributes[a];}),t[`variant_id${n}`]=r.variant_id,t[`variant_name${n}`]=r.variant_name,t[`variant_slug${n}`]=r.variant_slug,t[`dimension_id${n}`]=r.dimension_id,t[`dimension_name${n}`]=r.dimension_name,t.report_id=r.report_id,t.report_name=r.report_name;}return t},{})}var uc,pc=b(()=>{c();uc=Sh;});var yt,$n,zn=b(()=>{c();yt=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",$n=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[yt];$n.includes(yt)||$n.push(yt);});var Rh,Un,yo,Gn=b(()=>{c();zn();Rh={localeDefault:yt,locales:$n,currentLocale:yt,preferredLocale:yt,showToolbar:!1,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:!0,settings:!1,reportEditor:!1},isCMS:!1,isRunConsumersRunning:[]},Un=createSlice({name:"status",initialState:Rh,reducers:{setStatus:(e,t)=>{Object.assign(e,t.payload);},setPreviews(e,t){e.previews=t.payload;},setCurrentLocale(e,t){e.currentLocale=t.payload;},setPreferredLocale(e,t){e.preferredLocale=t.payload;},setSectionState(e,t){e.sectionState={...e.sectionState,...t.payload};},resetSectionState(e,t){e.sectionState={...e.sectionState,[t.payload]:{}};},setActiveEntity(e,t){e.activeEntity=t.payload;},openSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!0};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!1};},toggleSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!e.sidebarStatus[t.payload]};},addRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.concat(t.payload);},removeRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.filter(r=>!t.payload.includes(r));}},extraReducers:{[HYDRATE]:(e,t)=>({...e,previews:t.payload.status.previews})}}),yo=Un.actions;});var kh,qn,dr,bo=b(()=>{c();kh={attributes:{},variables:{},status:{}},qn=createSlice({name:"variables",initialState:kh,reducers:{setVariableChange:(e,t)=>{e.attributes={...e.attributes,...t.payload.attributes},e.variables={...e.variables,...t.payload.variables},e.status={...e.status,...t.payload.status};}},extraReducers:{[HYDRATE]:(e,t)=>({attributes:{...e.attributes,...t.payload.variables.attributes},status:{...e.status,...t.payload.variables.status},variables:{...e.variables,...t.payload.variables.variables}})}}),dr=qn.actions;});function jo(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,{...e[r],...t[r]}]))}function Hn(e,t){return e.map(n=>t[n]).sort(Ye).map(n=>n.id)}function Ih(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1);}var Ph,Yt,Wo=b(()=>{c();co();lr();Ph={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},Yt=createSlice({name:"records",initialState:Ph,reducers:{set:(e,t)=>{let r=t.payload;return {entities:jo(e.entities,r.entities||{}),requests:jo(e.requests,r.requests||{}),reports:r.reports||e.reports,tree:r.tree||e.tree}},setRequest:(e,t)=>{let r=t.payload;e.requests[r.type][r.key]=r;},setCreateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=Ln(r.type,o),a=jo(e.entities,n);if(e.entities=a,r.type==="report"){let s=r.data;e.reports?e.reports.indexOf(s.id)===-1&&(e.reports=[...e.reports,s.id]):e.reports=[s.id];}else if(r.type==="dimension"){let s=r.data;e.entities.report[s.report_id].dimensions.push(s.id),e.entities.report[s.report_id].dimensions=Hn(a.report[s.report_id].dimensions,a.dimension);}else if(r.type==="variant"){let s=r.data;e.entities.dimension[s.dimension_id].variants.push(s.id);}else if(r.type==="section"&&!Array.isArray(r.data)){let s=r.data;e.entities.report[s.report_id].sections.push(s.id),e.entities.report[s.report_id].sections=Hn(a.report[s.report_id].sections,a.section);}else if(r.type==="block")if(Array.isArray(r.data)){let s=r.data,i=s[0],l=s.map(u=>u.id);e.entities.section[i.section_id].blocks.concat(l);}else {let s=r.data;e.entities.section[s.section_id].blocks.push(s.id);}}},setReadRequest(e,t){let r=t.payload;if(r.type!=="report"&&(e.requests[r.type][r.key]=r),r.status==="SUCCESS"){let o=Ln(r.type,r.data),n=jo(e.entities,o);e.entities=n;}},setUpdateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=Ln(r.type,o),a,s,i;if(r.type==="block"&&!Array.isArray(r.data)){let u=e.entities.block[r.data.id].inputs,p=n.block[r.data.id].inputs;a=u.length!==p.length,a&&(i=u.length>p.length,s=i?u.filter(m=>!p.includes(m))[0]:p.filter(m=>!u.includes(m))[0]),Object.values(n.block).forEach(m=>{m.block_input&&delete n.block[m.id];});}let l=jo(e.entities,n);if(e.entities=l,r.type==="dimension"){let u=r.data;e.entities.report[u.report_id].dimensions=Hn(l.report[u.report_id].dimensions,l.dimension);}else if(r.type==="section"&&!Array.isArray(r.data)){let u=r.data;e.entities.report[u.report_id].sections=Hn(l.report[u.report_id].sections,l.section);}else if(r.type==="block"&&!Array.isArray(r.data)){let u=r.data;a&&(i?e.entities.block[s].consumers=e.entities.block[s].consumers.filter(p=>p!==u.id):e.entities.block[s].consumers.push(u.id));}}},setDeleteRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let{id:o,parentId:n,parentType:a}=r.data;if(delete e.entities[r.type][o],a&&n!=null){let s=`${r.type}s`;Ih(e.entities[a][n][s],o);}}},removeBlocks:(e,t)=>{let r=t.payload,o={...e.entities.block};return r.forEach(n=>{delete o[n];}),{...e,entities:{...e.entities,block:o}}},addBlocks:(e,t)=>{let r=t.payload;return {...e,entities:{...e.entities,block:{...e.entities.block,...r}}}},removeDataSourceLogic:e=>{let t={...e.entities.datasource};Object.keys(t).forEach(r=>{e.entities.datasource[r].content.useProxy&&(delete e.entities.datasource[r].content.logic,delete e.entities.datasource[r].content.testUrl,delete e.entities.datasource[r].content.access);});}},extraReducers:{[HYDRATE]:(e,t)=>{let r=t.payload.records,o=r.entities;return {entities:o,reports:Object.values(o.report).map(n=>n.id),requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},tree:r.tree}}}});});function Vr(e,t,r){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${dc(r)}`;return e[n]}let o=`${t}${dc(r)}`;return e[o]}function dc(e){return e[0].toUpperCase()+e.slice(1)}var mc=b(()=>{c();});function Ne(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];if(process.env.NODE_ENV!=="production"){var n=Fh[e],a=n?typeof n=="function"?n.apply(null,r):n:"unknown error nr: "+e;throw Error("[Immer] "+a)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map(function(s){return "'"+s+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function vo(e){return !!e&&!!e[rt]}function zr(e){var t;return !!e&&(function(r){if(!r||typeof r!="object")return !1;var o=Object.getPrototypeOf(r);if(o===null)return !0;var n=Object.hasOwnProperty.call(o,"constructor")&&o.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===Vh}(e)||Array.isArray(e)||!!e[Tc]||!!(!((t=e.constructor)===null||t===void 0)&&t[Tc])||cs(e)||us(e))}function Yo(e,t,r){r===void 0&&(r=!1),To(e)===0?(r?Object.keys:gs)(e).forEach(function(o){r&&typeof o=="symbol"||t(o,e[o],e);}):e.forEach(function(o,n){return t(n,o,e)});}function To(e){var t=e[rt];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:cs(e)?2:us(e)?3:0}function ns(e,t){return To(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Lh(e,t){return To(e)===2?e.get(t):e[t]}function xc(e,t,r){var o=To(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r;}function Oh(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function cs(e){return Nh&&e instanceof Map}function us(e){return Dh&&e instanceof Set}function $r(e){return e.o||e.t}function ps(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=$h(e);delete t[rt];for(var r=gs(t),o=0;o<r.length;o++){var n=r[o],a=t[n];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(t[n]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function ds(e,t){return t===void 0&&(t=!1),ms(e)||vo(e)||!zr(e)||(To(e)>1&&(e.set=e.add=e.clear=e.delete=_h),Object.freeze(e),t&&Yo(e,function(r,o){return ds(o,!0)},!0)),e}function _h(){Ne(2);}function ms(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function Ot(e){var t=zh[e];return t||Ne(18,e),t}function fc(){return process.env.NODE_ENV==="production"||So||Ne(0),So}function es(e,t){t&&(Ot("Patches"),e.u=[],e.s=[],e.v=t);}function jn(e){as(e),e.p.forEach(Bh),e.p=null;}function as(e){e===So&&(So=e.l);}function gc(e){return So={p:[],l:So,h:e,m:!0,_:0}}function Bh(e){var t=e[rt];t.i===0||t.i===1?t.j():t.g=!0;}function ts(e,t){t._=t.p.length;var r=t.p[0],o=e!==void 0&&e!==r;return t.h.O||Ot("ES5").S(t,e,o),o?(r[rt].P&&(jn(t),Ne(4)),zr(e)&&(e=Wn(t,e),t.l||Kn(t,e)),t.u&&Ot("Patches").M(r[rt].t,e,t.u,t.s)):e=Wn(t,r,[]),jn(t),t.u&&t.v(t.u,t.s),e!==Rc?e:void 0}function Wn(e,t,r){if(ms(t))return t;var o=t[rt];if(!o)return Yo(t,function(i,l){return hc(e,o,t,i,l,r)},!0),t;if(o.A!==e)return t;if(!o.P)return Kn(e,o.t,!0),o.t;if(!o.I){o.I=!0,o.A._--;var n=o.i===4||o.i===5?o.o=ps(o.k):o.o,a=n,s=!1;o.i===3&&(a=new Set(n),n.clear(),s=!0),Yo(a,function(i,l){return hc(e,o,n,i,l,r,s)}),Kn(e,n,!1),r&&e.u&&Ot("Patches").N(o,r,e.u,e.s);}return o.o}function hc(e,t,r,o,n,a,s){if(process.env.NODE_ENV!=="production"&&n===r&&Ne(5),vo(n)){var i=Wn(e,n,a&&t&&t.i!==3&&!ns(t.R,o)?a.concat(o):void 0);if(xc(r,o,i),!vo(i))return;e.m=!1;}else s&&r.add(n);if(zr(n)&&!ms(n)){if(!e.h.D&&e._<1)return;Wn(e,n),t&&t.A.l||Kn(e,n);}}function Kn(e,t,r){r===void 0&&(r=!1),!e.l&&e.h.D&&e.m&&ds(t,r);}function rs(e,t){var r=e[rt];return (r?$r(r):e)[t]}function yc(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Object.getPrototypeOf(r);}}function ss(e){e.P||(e.P=!0,e.l&&ss(e.l));}function os(e){e.o||(e.o=ps(e.t));}function is(e,t,r){var o=cs(t)?Ot("MapSet").F(t,r):us(t)?Ot("MapSet").T(t,r):e.O?function(n,a){var s=Array.isArray(n),i={i:s?1:0,A:a?a.A:fc(),P:!1,I:!1,R:{},l:a,t:n,k:null,o:null,j:null,C:!1},l=i,u=ls;s&&(l=[i],u=Ko);var p=Proxy.revocable(l,u),m=p.revoke,d=p.proxy;return i.k=d,i.j=m,d}(t,r):Ot("ES5").J(t,r);return (r?r.A:fc()).p.push(o),o}function Mh(e){return vo(e)||Ne(22,e),function t(r){if(!zr(r))return r;var o,n=r[rt],a=To(r);if(n){if(!n.P&&(n.i<4||!Ot("ES5").K(n)))return n.t;n.I=!0,o=bc(r,a),n.I=!1;}else o=bc(r,a);return Yo(o,function(s,i){n&&Lh(n.t,s)===i||xc(o,s,t(i));}),a===3?new Set(o):o}(e)}function bc(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return ps(e)}var vc,So,fs,Nh,Dh,Sc,Rc,Tc,rt,Fh,Vh,gs,$h,zh,ls,Ko,Uh,ot,Gh,Yn,Ec=b(()=>{c();fs=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",Nh=typeof Map<"u",Dh=typeof Set<"u",Sc=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",Rc=fs?Symbol.for("immer-nothing"):((vc={})["immer-nothing"]=!0,vc),Tc=fs?Symbol.for("immer-draftable"):"__$immer_draftable",rt=fs?Symbol.for("immer-state"):"__$immer_state",Fh={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return "Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return "Unsupported patch operation: "+e},18:function(e){return "The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return "'current' expects a draft, got: "+e},23:function(e){return "'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Vh=""+Object.prototype.constructor,gs=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,$h=Object.getOwnPropertyDescriptors||function(e){var t={};return gs(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r);}),t},zh={},ls={get:function(e,t){if(t===rt)return e;var r=$r(e);if(!ns(r,t))return function(n,a,s){var i,l=yc(a,s);return l?"value"in l?l.value:(i=l.get)===null||i===void 0?void 0:i.call(n.k):void 0}(e,r,t);var o=r[t];return e.I||!zr(o)?o:o===rs(e.t,t)?(os(e),e.o[t]=is(e.A.h,o,e)):o},has:function(e,t){return t in $r(e)},ownKeys:function(e){return Reflect.ownKeys($r(e))},set:function(e,t,r){var o=yc($r(e),t);if(o?.set)return o.set.call(e.k,r),!0;if(!e.P){var n=rs($r(e),t),a=n?.[rt];if(a&&a.t===r)return e.o[t]=r,e.R[t]=!1,!0;if(Oh(r,n)&&(r!==void 0||ns(e.t,t)))return !0;os(e),ss(e);}return e.o[t]===r&&(r!==void 0||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=!0),!0},deleteProperty:function(e,t){return rs(e.t,t)!==void 0||t in e.t?(e.R[t]=!1,os(e),ss(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=$r(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty:function(){Ne(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Ne(12);}},Ko={};Yo(ls,function(e,t){Ko[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};}),Ko.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Ne(13),Ko.set.call(this,e,t,void 0)},Ko.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Ne(14),ls.set.call(this,e[0],t,r,e[0])};Uh=function(){function e(r){var o=this;this.O=Sc,this.D=!0,this.produce=function(n,a,s){if(typeof n=="function"&&typeof a!="function"){var i=a;a=n;var l=o;return function(y){var T=this;y===void 0&&(y=i);for(var C=arguments.length,B=Array(C>1?C-1:0),E=1;E<C;E++)B[E-1]=arguments[E];return l.produce(y,function(_){var z;return (z=a).call.apply(z,[T,_].concat(B))})}}var u;if(typeof a!="function"&&Ne(6),s!==void 0&&typeof s!="function"&&Ne(7),zr(n)){var p=gc(o),m=is(o,n,void 0),d=!0;try{u=a(m),d=!1;}finally{d?jn(p):as(p);}return typeof Promise<"u"&&u instanceof Promise?u.then(function(y){return es(p,s),ts(y,p)},function(y){throw jn(p),y}):(es(p,s),ts(u,p))}if(!n||typeof n!="object"){if((u=a(n))===void 0&&(u=n),u===Rc&&(u=void 0),o.D&&ds(u,!0),s){var f=[],g=[];Ot("Patches").M(n,u,f,g),s(f,g);}return u}Ne(21,n);},this.produceWithPatches=function(n,a){if(typeof n=="function")return function(u){for(var p=arguments.length,m=Array(p>1?p-1:0),d=1;d<p;d++)m[d-1]=arguments[d];return o.produceWithPatches(u,function(f){return n.apply(void 0,[f].concat(m))})};var s,i,l=o.produce(n,a,function(u,p){s=u,i=p;});return typeof Promise<"u"&&l instanceof Promise?l.then(function(u){return [u,s,i]}):[l,s,i]},typeof r?.useProxies=="boolean"&&this.setUseProxies(r.useProxies),typeof r?.autoFreeze=="boolean"&&this.setAutoFreeze(r.autoFreeze);}var t=e.prototype;return t.createDraft=function(r){zr(r)||Ne(8),vo(r)&&(r=Mh(r));var o=gc(this),n=is(this,r,void 0);return n[rt].C=!0,as(o),n},t.finishDraft=function(r,o){var n=r&&r[rt];process.env.NODE_ENV!=="production"&&(n&&n.C||Ne(9),n.I&&Ne(10));var a=n.A;return es(a,o),ts(void 0,a)},t.setAutoFreeze=function(r){this.D=r;},t.setUseProxies=function(r){r&&!Sc&&Ne(20),this.O=r;},t.applyPatches=function(r,o){var n;for(n=o.length-1;n>=0;n--){var a=o[n];if(a.path.length===0&&a.op==="replace"){r=a.value;break}}n>-1&&(o=o.slice(n+1));var s=Ot("Patches").$;return vo(r)?s(r,o):this.produce(r,function(i){return s(i,o)})},e}(),ot=new Uh,Gh=ot.produce,ot.produceWithPatches.bind(ot),ot.setAutoFreeze.bind(ot),ot.setUseProxies.bind(ot),ot.applyPatches.bind(ot),ot.createDraft.bind(ot),ot.finishDraft.bind(ot),Yn=Gh;});function Qo(e){return (t,r)=>{let o=e[t];if(!o)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return o(r)}}function qr(e,t){return (r,o)=>{let a=o().records.requests[e][t],s=!a||a.status==="UNINITIALIZED"?"LOADING":"FETCHING";r(bt.setRequest({key:t,type:e,status:s}));}}function Gr(e,t,r,o){return n=>{typeof window=="object"&¬ifications.show({autoClose:3e3,color:"red",id:t,message:o,title:"Error"}),n(bt.setRequest({key:t,type:e,status:"FAILURE",error:{code:r,message:o}}));}}function mr(e){return t=>{let r=ys(e,t);return (o,n,a)=>(o(qr(e,r)),Vr(a,"create",e)(t).then(i=>(i.ok===!0?o(bt.setCreateRequest({key:r,operation:"create",status:"SUCCESS",type:e,data:i.data})):o(Gr(e,r,i.status,i.error)),i)))}}function jh(e){return t=>{let r=ys(e,t[0]);return (o,n,a)=>(o(qr(e,r)),Vr(a,"createBulk",e)(t).then(i=>(i.ok===!0?o(bt.setCreateRequest({key:r,operation:"createBulk",status:"SUCCESS",type:e,data:i.data})):o(Gr(e,r,i.status,i.error)),i)))}}function Cc(e,t,r){return r.replace(new RegExp(e,"g"),t)}function Wh(e){return e.section_id!==void 0}function Kh(e){return e.report_id!==void 0}function kc(e){return t=>{let{create:r}=t;return (o,n,a)=>mr(e)(r)(o,n,a).then(async i=>{if(i.ok){let{data:l}=i,{id:u}=l,{update:p}=t,m=Bc(e,{id:u});if(o(qr(e,`${m}`)),e==="block"&&Wh(r)){let d=Yn(p,T=>{T.id=u;}),{contentByLocale:f}=d;f&&(d=Yn(d,T=>{T.id=u,T.contentByLocale=Object.keys(f).reduce((C,B)=>{let E=f?f[B]:{};return C[B]={...E,id:u},C},{});}));let y=d.inputs?.map(T=>({type:T.type,id:T.id,inputAction:{operation:"create",input:{input_id:T.id,block_id:d.id}}}));return y&&y.length>0&&Ac(e)([d,...y])(o,n,a).then(()=>fr("section")({id:d.section_id,include:!0})(o,n,a).then(T=>(T.ok&&o(bt.setRequest({key:m,type:e,status:"SUCCESS",data:T.data})),T))),_t(e)(d)(o,n,a).then(T=>(T.ok&&o(bt.setRequest({key:m,type:e,status:"SUCCESS",data:T.data})),T))}if(e==="section"&&Kh(r)){let{id:d}=l,f=Yn(p,T=>{T.id=d;}),{blocks:g}=f,y=g?.map(T=>({type:T.type,blockcol:T.blockcol,blockrow:T.blockrow,section_id:d,locales:Object.keys(T.contentByLocale).map(C=>C)}));return y&&g&&await jh("block")(y)(o,n,a).then(T=>{if(T.ok){let C=T.data,B=[],E=C.map((_,z)=>{let w={..._},I=w.id,k=g[z];k.contentByLocale&&(w.contentByLocale=Object.keys(k.contentByLocale).reduce((F,L)=>{let G=k.contentByLocale[L];return F[L]={...G,content:{...G.content},id:w.id},F},{}));let{settings:M}=k,{contentByLocale:x,id:A}=w;w.settings=M;let U={id:A,contentByLocale:x,settings:M};return k.inputs.map(F=>F.id).reduce((F,L)=>{let G=g.findIndex(V=>V.id===L);return [...F,G]},[]).map(F=>({...C[F],originalBlock:g[F]})).forEach(F=>{let{id:L,type:G,originalBlock:V}=F;if([h.SELECTOR,h.VIZ].includes(G)){if(U.contentByLocale?.logic?.content?.api){let ie=U.contentByLocale?.logic.content.api;U.contentByLocale.logic.content.api=Cc(`(selector${V.id}id)`,`selector${L}id`,ie);}if(U.contentByLocale?.logic?.content?.logic){let ie=U.contentByLocale.logic.content.logic;U.contentByLocale.logic.content.logic=Cc(`(selector${V.id}id)`,`selector${L}id`,ie);}}B.push({id:L,inputAction:{operation:"create",input:{input_id:L,block_id:I}}});}),U});return Ac("block")([...E,...B])(o,n,a)}}),_t(e)(f)(o,n,a).then(T=>(T.ok&&o(bt.setRequest({key:m,type:e,status:"SUCCESS",data:T.data})),T))}return _t(e)({...p,id:l.id})(o,n,a)}})}}function fr(e){return t=>{let r=Oc(e,t);return (o,n,a)=>{o(qr(e,r));let s=Vr(a,"read",e);if(typeof s!="function"){let i=`Failed to get valid RPC method for entity "${e}"`;return o(Gr(e,r,500,i)),Promise.reject(new Error(i))}return s(t).then(i=>(i.ok===!0?o(bt.setReadRequest({key:r,operation:"read",status:"SUCCESS",type:e,data:i.data})):o(Gr(e,r,i.status,i.error)),i))}}}function _t(e){return t=>{let r=bs(e,t);return (o,n,a)=>(o(qr(e,r)),Vr(a,"update",e)(t).then(i=>(i.ok===!0?o(bt.setUpdateRequest({key:r,operation:"update",status:"SUCCESS",type:e,data:i.data})):o(Gr(e,r,i.status,i.error)),i)))}}function Ac(e){return t=>{let r=bs(e,t[0]);return (o,n,a)=>(o(qr(e,r)),Vr(a,"updateBulk",e)(t).then(i=>(i.ok===!0?o(bt.setUpdateRequest({key:r,operation:"updateBulk",status:"SUCCESS",type:e,data:i.data})):o(Gr(e,r,i.status,i.error)),i)))}}function Ur(e){return t=>{let r=_c(e,t);return (o,n,a)=>(o(qr(e,r)),Vr(a,"delete",e)(t).then(i=>{i.ok===!0?o(bt.setDeleteRequest({key:r,operation:"delete",status:"SUCCESS",type:e,data:i.data})):o(Gr(e,r,i.status,i.error));}))}}function ys(e,t){if(e==="variant"){let r=t;return `create(variant, [${r.dimension_id}, ${r.name}])`}return `create(${e}, [${Object.keys(t)}])`}function Oc(e,t={}){let r=t.id==null?null:`'${t.id}'`;return `read(${e}, ${r}, ${!!t.include})`}function bs(e,t){let{id:r,...o}=t;return `update(${e}, ${r}, [${Object.keys(o)}])`}function _c(e,t){return `delete(${e}, ${t})`}function Bc(e,t){let r=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${r})`}var bt,hs,wc,Xo,Pc,Ic,Lc,vs=b(()=>{c();mc();Wo();Ec();fe();bt=Yt.actions,hs={create:ys,read:Oc,update:bs,delete:_c,clone:Bc},wc=Qo({block:mr("block"),dimension:mr("dimension"),formatter:mr("formatter"),report:mr("report"),section:mr("section"),variant:mr("variant"),datasource:mr("datasource")}),Xo=Qo({block:fr("block"),dimension:fr("dimension"),formatter:fr("formatter"),report:fr("report"),section:fr("section"),variant:fr("variant"),datasource:fr("datasource")}),Pc=Qo({block:_t("block"),dimension:_t("dimension"),formatter:_t("formatter"),report:_t("report"),section:_t("section"),variant:_t("variant"),datasource:_t("datasource")}),Ic=Qo({block:Ur("block"),dimension:Ur("dimension"),formatter:Ur("formatter"),report:Ur("report"),section:Ur("section"),variant:Ur("variant"),datasource:Ur("datasource")}),Lc=Qo({block:kc("block"),section:kc("section")});});var nt={};Fa(nt,{addBlockToState:()=>uy,addRunConsumersRunning:()=>Ss,cloneEntity:()=>Lc,createEntity:()=>wc,deleteEntity:()=>Ic,deleteQueryParam:()=>xs,readEntity:()=>Xo,readEnvSecrets:()=>fy,readMember:()=>Nc,readMetadata:()=>ry,readPrivateBlocks:()=>py,readUser:()=>sy,recalculateVariables:()=>Fc,removeBlocksFromState:()=>cy,removeDataSourceLogic:()=>gy,removeRunConsumersRunning:()=>Ts,reportSearch:()=>Jh,resetSectionState:()=>Jo,revalidateReport:()=>my,revalidateUrl:()=>dy,searchMember:()=>ty,searchRegenerate:()=>ey,searchRole:()=>ny,searchUser:()=>ay,setCurrentLocale:()=>Xh,setPreferredLocale:()=>Qh,setPreviews:()=>Yh,setQueryParam:()=>Hr,setSectionState:()=>Zo,setStatus:()=>Mc,updateEntity:()=>Pc,updateMyData:()=>ly,updateUser:()=>iy,urlProxy:()=>oy,variantValidateSlug:()=>Zh});function Zh(e,t){return async(r,o,n)=>{let a=await n.validateVariantSlug({dimension:e,slug:t});if("error"in a)throw new Error(a.error);return a.data}}function Jh(e){return async(t,r,o)=>{let n=await o.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function ey(){return async(e,t,r)=>{let o=await r.regenerateSearch(void 0);if("error"in o)throw new Error(o.error);return o.data}}function Nc(e){return async(t,r,o)=>{let n=await o.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function ty(e){return async(t,r,o)=>{let n=await o.searchMember(e);if(n.ok===!0)return n.data;throw new Error(n.error)}}async function Dc(e,t,r,o){let n=r().status,a={...n,...o},s={...n.query,...o.query};Object.keys(s).forEach(l=>s[l]===void 0&&delete s[l]);let i={...a,query:s};t(Mc(i)),n.activeSection&&t(Fc(e,{query:s}));}function xs(e,t){return async(r,o)=>Dc(e,r,o,{query:{[t]:void 0}})}function Hr(e,t,r){return async(o,n)=>Dc(e,o,n,{query:{[t]:r}})}function Fc(e,t){return async(r,o)=>{let n=o(),{currentLocale:a}=n.status,s=n.records.entities.block,i=e.formatterFunctions[a],l=e.datasourceFunctions,{parsedParams:u,statusPayload:p}=Il(n.status,t),{sid:m,bid:d,previews:f,query:g}=u;Object.keys(p).length&&r(yo.setStatus(p));let y={...uc(f),locale:a,...ur()},T={variables:y,query:g,locale:a};r(yo.addRunConsumersRunning([m]));let C=n.records.entities.section[m],B=async E=>r(Nc(E));try{let E=await Lt(s,C&&[C],d,i,T,void 0,B,"section",l),{variables:_,status:z}=E;r(dr.setVariableChange({attributes:y,variables:_,status:z})),r(yo.removeRunConsumersRunning([m]));}catch(E){console.error("Error in runConsumers client side: recalculateVariables",E);}}}function ry(e){return async(t,r,o)=>{let n=await o.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function oy(e){return async(t,r,o)=>{let n=await o.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function ny(){return async(e,t,r)=>{let o=await r.searchRole("");if("error"in o)throw new Error(o.error);return o.data}}function ay(e){return async(t,r,o)=>{let n=await o.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function sy(e){return async(t,r,o)=>{let n=await o.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function iy({user:e}){return async(t,r,o)=>{let n=await o.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function ly(e){return async(t,r,o)=>{let n=await o.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function cy(e){let{removeBlocks:t}=Yt.actions;return async r=>{await r(t(e));}}function uy(e){let{addBlocks:t}=Yt.actions;return async r=>{await r(t(e));}}function py(e){return async(t,r,o)=>{let n=await o.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function dy(e){return async(t,r,o)=>{let n=await o.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function my(e){return async(t,r,o)=>{let n=await o.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function fy(){return async(e,t,r)=>{let o=await r.readEnvSecrets({});if("error"in o)throw new Error(o.error);return o.data}}function gy(){let{removeDataSourceLogic:e}=Yt.actions;return async t=>{await t(e());}}var Mc,Yh,Zo,Jo,Xh,Qh,Ss,Ts,en=b(()=>{c();Fr();pc();Ho();lr();Gn();bo();Wo();vs();({setStatus:Mc,setPreviews:Yh,setSectionState:Zo,resetSectionState:Jo,setCurrentLocale:Xh,setPreferredLocale:Qh,addRunConsumersRunning:Ss,removeRunConsumersRunning:Ts}=yo);});function Ie(e){let t=Xe(),r=Q(a=>a.status.sectionState)[e]||{},o=useCallback(a=>{t(Zo({[e]:a}));},[e]),n=useCallback(()=>{t(Jo(e));},[e]);return {sectionVariables:r,setSectionVariables:o,resetSectionVariables:n}}function zc(e){let t=Xe(),r=Q(l=>l.status.sectionState),o=useMemo(()=>e.reduce((l,u)=>(l[u]=r[u]||{},l),{}),[e,r]),n=useCallback(l=>{t(Zo(l));},[]),a=useCallback(()=>{e.map(u=>Jo(u)).forEach(u=>t(u));},[e]),s=useCallback(l=>u=>{t(Zo({[l]:u}));},[]),i=useCallback(l=>()=>{t(Jo(l));},[]);return {sectionsVariables:o,setSectionsVariables:n,resetSectionsVariables:a,setSectionVariables:s,resetSectionVariables:i}}function Ro(){let e=Xe(),t=Q(n=>n.status.isRunConsumersRunning),r=useCallback(n=>{e(Ss(n));},[]),o=useCallback(n=>{e(Ts(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:r,removeRunConsumersRunning:o}}function Uc(){return Q(t=>t.status.currentLocale)}function jr(e){return t=>{let r=Xe(),o=useMemo(()=>hs.read(e,{include:!0}),[]),n=useCallback(s=>{let i=Object.values(s.records.entities[e]),l=s.records.requests[e][o]||{key:o,type:e,status:i==null?"UNINITIALIZED":"SUCCESS"},u=t?i.filter(p=>t.includes(p.id)):i;return Gc(u,l)},[o]),a=Q(n);return useEffect(()=>{a.isUninitialized&&r(Xo(e,{id:t,include:!0}));},[a.status]),a}}function Wr(e){return t=>{let r=Xe(),o=useMemo(()=>hs.read(e,{id:t,include:!0}),[t]),n=useCallback(s=>{let i=s.records.entities[e][t],l=s.records.requests[e][o]||{key:o,type:e,status:i==null?"UNINITIALIZED":"SUCCESS"};return Gc(i,l)},[o]),a=Q(n);return useEffect(()=>(a.isUninitialized&&t!==null&&r(Xo(e,{id:t,include:!0})),()=>{}),[o,a.isUninitialized,r,t]),a}}function Gc(e,t){let r={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"?r:t.status==="LOADING"?{...r,data:e}:t.status==="FETCHING"?{...r,data:e}:t.status==="FAILURE"?{...r,error:t.error}:{...r,data:e}}var by,Xe,Q,Es,tn,Cs,ks,Qn,vt,xo,Mt,gr,Zn,Ce=b(()=>{c();en();vs();Wo();Xt();wt();Gn();(({localeDefault:by}=Pe())),Xe=useDispatch,Q=useSelector,Es=jr("report"),tn=jr("section"),Cs=jr("formatter"),ks=jr("datasource"),Qn=Wr("section"),vt=Wr("block"),xo=(e,t=void 0,r=void 0)=>{if(!e)return {};let o=vt(e).data,n=Q(i=>t||i.variables.variables),a=Q(i=>r||i.variables.attributes);return useMemo(()=>o?o.inputs.reduce((i,l)=>({...i,...n[l]}),a):{},[o,a,n])},Mt=(e=by)=>useContext(Nt).formatterFunctions[e],gr=()=>useContext(Nt).datasourceFunctions,Zn=()=>useContext(Nt).profilePrefix;});var qc,Hc=b(()=>{c();za();Wo();Gn();bo();qc=()=>configureStore({reducer:{[Yt.name]:Yt.reducer,[Un.name]:Un.reducer,[qn.name]:qn.reducer},middleware(e){return e({thunk:{extraArgument:Go("/api/cms/")}})}}),createWrapper(qc);});var jc=b(()=>{c();});var he=b(()=>{c();en();Ce();Hc();jc();});function Kc(e){let {pathSegment:t,profilePrefix:r,siteProps:o}=e,n=Cs();Q(p=>p.status.isCMS);let s=ks(),l={...ur()},u=useMemo(()=>({profilePrefix:r,pathSegment:t,siteProps:o,formatterFunctions:Wc.reduce((p,m)=>({...p,[m]:n.data?Pt(n.data,m):{}}),{}),datasourceFunctions:(s?.data||[]).sort((p,m)=>p.content.order>m.content.order?1:-1).map(p=>({...p,content:{...p.content,pattern:tt(p.content.pattern,{},{variables:l})}}))}),[n,t,r,o,s]);return jsx(Nt.Provider,{value:u,children:e.children})}function Kr(){let e=useContext(Nt);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var Wc,Oy,Nt,Xt=b(()=>{c();wt();lr();he();Ho();fo();(({locales:Wc}=Pe())),Oy={pathSegment:"path",formatterFunctions:Wc.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",siteProps:{}},Nt=createContext(Oy);});function Eo(e){return t=>Object.values(t.records.entities[e])}function yr(e){return Object.values(e.records.entities.datasource||[]).sort((t,r)=>t.content.order>r.content.order?1:-1).map(t=>{let r={...By};return {...t,content:{...t.content,pattern:tt(t.content.pattern,{},{variables:r})}}})}var Dt,Yc,hr,By,br=b(()=>{c();Ho();fo();Dt=e=>e.records.entities.block;Yc=Eo("block"),hr=Eo("formatter"),By=ur();});var My,Ny,Dy,Fy,Ge,Yr=b(()=>{c();My=e=>typeof e=="string"?e.replace(/ <\/p>/g,"</p>"):e,Ny=e=>typeof e=="string"&&e==="<p><br></p>"?"":e,Dy=e=>typeof e=="string"?e.replace(/^<p>(.*)<\/p>$/,"$1"):e,Fy=e=>e&&Dy(Ny(My(e))),Ge=Fy;});function se({id:e="",component:t="p",order:r=1,size:o="md",html:n,style:a={},append:s=jsx(Fragment,{}),isPreview:i=!1}){let l=zy(n),u=Uy(n,i),p=a&&a.align?String(a.align):"left",m=Text,d={};return t==="h"?(m=Title,d={id:e,order:r}):d={component:t,size:o},jsxs(m,{align:p||l.align||"left",...d,children:[u,s]})}var zy,Uy,Le=b(()=>{c();zy=(e="<></>")=>{let t=null,r={replace:o=>(o instanceof Element&&!t&&(t=o.attribs,t.align=o.attribs.style?o.attribs.style.replace("text-align: ",""):"",delete t.children),o)};return e?(Qc(e,r),t):{}},Uy=(e="",t=!1)=>{let r={replace:o=>{let{type:n}=o;if(o instanceof Element&&n==="tag"){let{name:a,attribs:s,children:i,parent:l}=o;if(a==="p"&&!l)return jsx(Fragment,{children:domToReact(i,r)});if(a==="a"){let{href:u,target:p}=s,m=u.indexOf("http")===0,d=!!(p&&p==="_blank"),f=jsx(Anchor,{...s,href:s.href,target:"_blank",children:domToReact(i,r)});return m||d||t?f:jsx(Anchor,{...s,href:s.href,children:domToReact(i,r)})}else {if(a==="strong")return jsx(Text,{component:"strong",children:domToReact(i,r)});if(a==="em")return jsx(Text,{component:"em",fs:"italic",children:domToReact(i,r)});if(a==="u")return jsx(Text,{component:"u",td:"underline",children:domToReact(i,r)});if(a==="sup")return jsx(Text,{component:"sup",style:{verticalAlign:"super",fontSize:"0.75em"},children:domToReact(i,r)});if(a==="sub")return jsx(Text,{component:"sub",style:{verticalAlign:"sub",fontSize:"0.75em"},children:domToReact(i,r)});if(a==="span")return jsx(Text,{component:"span",children:domToReact(i,r)});if(a==="br")return jsx("br",{})}return jsx(Fragment,{children:domToReact(i,r)})}else if(o instanceof Text$1&&o.type==="text")return jsx(Fragment,{children:o.data})}};return Qc(e,r)};});function De(e){let{content:t,style:r={}}=e,{print:o}=He(),n=jsx(se,{component:"span",html:t,isPreview:!0}),a=useMemo(()=>o?jsx("div",{className:"bespoke-inner-tooltip-notification",children:jsx(Notification,{icon:jsx(IconInfoCircle,{size:"1.1rem"}),withCloseButton:!1,withBorder:!0,styles:{root:{boxShadow:"none"}},children:n})},"tooltip-notification"):jsx("div",{className:"bespoke-inner-tooltip",style:r,children:jsx(Tooltip,{label:n,withArrow:!0,withinPortal:!0,multiline:!0,maw:220,children:jsx(ActionIcon,{size:"1.5rem",children:jsx(IconInfoCircle,{})})})},"tooltip"),[o,t,r]);return jsx(Fragment,{children:a})}var Zt=b(()=>{c();Jt();Le();});function ws({paragraph:e,tooltip:t,settings:r}){let o=Ge(t);return jsx(se,{component:"p",html:e,style:r,append:t?jsx(De,{content:o,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{})})}var eu=b(()=>{c();Yr();Zt();Le();});function ke({iconType:e="none",iconVariant:t="transparent",icon:r="",iconRadius:o="md",iconSize:n="md",iconPadding:a="1",blockType:s}){let[i,l]=useState(void 0),u=e==="custom"?r:`/api/cms/read/icons/${e}/icon.svg?name=${r}`,p=/^.*\.svg*$/.test(u)||e==="tabler";return useEffect(()=>{p&&Fn.get(u,{responseType:"text"}).then(d=>d.data).then(l).catch(()=>{});},[e,p,u]),jsx(Fragment,{children:e!=="none"&&r&&r!==""&&!!(i||!p)&&jsx(ThemeIcon,{className:`bespoke-${s}-icon-wrapper`,variant:t,radius:o,size:n,p:parseInt(a),dangerouslySetInnerHTML:i&&p?{__html:i}:void 0,children:p?null:jsx(Image,{src:u,alt:"Title Icon"})})})}var Qr=b(()=>{c();});var vr,tu,ru,ou,nu,Vt,dt,Co,qe=b(()=>{c();fe();vr={display:{label:"Size",defaultValue:"block",options:[{label:"Full Width",value:"block"},{label:"Inline",value:"inline"}]}},tu={useProxy:{label:"Use proxy (avoid CORS)",defaultValue:"false",options:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}},{[h.IMAGE]:{...vr},[h.PARAGRAPH]:{...vr},[h.SUBTITLE]:{...vr},[h.SELECTOR]:{...vr},[h.STAT]:{...vr},[h.VIZ]:{...vr},[h.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"}]},...vr},[h.GENERATOR]:{...tu},[h.SECTION_FLAG]:{...tu},[h.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"}]}},[h.MULTIHIERARCHY_SELECTOR]:{...vr}},ru={left:"flex-start",right:"flex-end",justify:"stretch"},ou={justify:"apart"},nu={justify:"space-between"},Vt=e=>ru[e]?ru[e]:e,dt=e=>ou[e]?ou[e]:e,Co=e=>nu[e]?nu[e]:e;});function Is({subtitle:e,title:t,value:r,tooltip:o,settings:n,_iconType:a,_iconVariant:s,_icon:i,_iconRadius:l,_iconSize:u,_iconPadding:p}){if(!t&&!r&&!e)return null;let m=n&&n.align?n.align:"left";return jsxs(Group,{spacing:"md",position:dt(m),children:[jsx(ke,{blockType:"stat",iconType:a,iconVariant:s,iconRadius:l,iconSize:u,icon:i,iconPadding:p}),jsxs(Stack,{spacing:0,children:[t&&jsx(se,{component:"div",size:"md",html:t,style:n}),r&&jsx(se,{component:"div",size:"xl",html:r,style:n}),e&&jsx(se,{component:"div",size:"sm",html:e,style:n})]},"stat"),o&&jsx(De,{content:o})]})}var su=b(()=>{c();Zt();Qr();Le();qe();});function Ls({subtitle:e,tooltip:t,settings:r}){let o=e||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=r&&r.align?r.align:"left";return jsxs(Group,{spacing:"sm",position:dt(n),children:[jsx(se,{size:"sm",html:o}),t&&jsx(De,{content:t,style:{display:"inline-flex"}})]})}var lu=b(()=>{c();Zt();Le();qe();});function Oe(e){let t=useContext(cu);return e?t[e]??t:t}function Os({translations:e,children:t}){return jsx(cu.Provider,{value:e||{},children:t})}var cu,St=b(()=>{c();cu=createContext({});});function fu({children:e,pageSize:t=10}){let r={profile:void 0,variant:void 0},[o,n]=useState([]),[a,s]=useState(!1),[i,l]=useState(!1),[u,p]=useState({}),[m,d]=useState({}),[f,g]=useState(1),[y,T]=useState(r),[C,B]=useState(""),[E]=useDebouncedValue(C,750),[_,z]=useState([]),[K,w]=useState(_s),[I,k]=useState(!1),{locale:M}=useRouter(),x=async()=>{try{l(!0),Fn.get("/api/cms/read/metadata").then(H=>{if(H&&H.data&&H.data.data&&H.data.data.data){let oe=H.data.data.data.reduce((J,te)=>(te.dimensions&&te.dimensions.forEach(Y=>{Y.variants&&Y.variants.forEach(R=>{J[R.id]=R.members_count||0;});}),J),{});n(H.data.data.data),p(oe),d(oe);}l(!1),k(!0);}).catch(H=>{console.error(H);});}catch(H){console.error("Error fetching metadata:",H),n([]),l(!1),p({}),d({});}},A=H=>{p(H||m);},U=useCallback(async(H,oe,J)=>{!I&&o.length===0&&await x(),T({profile:H,variant:oe}),J!==""&&B(J);},[]);useEffect(()=>{let H=!1;return I&&(s(!0),g(1),O(H,0)),()=>{H=!1;}},[E,y,I]),useEffect(()=>{if(I){s(!0);let H=(f-1)*t;O(!1,H);}},[f]);let O=async(H,oe)=>{let J=y.profile&&!Number.isNaN(y.profile)?[y.profile]:[],te=y.variant?typeof y.variant=="string"&&y.variant.includes(",")?y.variant.split(",").map(R=>parseInt(R,10)):[parseInt(y.variant,10)]:[],Y={query:E,format:"profiles",locale:M,limit:t,offset:oe,visible:!0,includes:!0,noImage:!1,variant:te,dimension:[],report:J,all:!1,origin:"typesense"};Fn.get("/api/cms/search/reports",{params:Y}).then(R=>{if(R&&R.data&&R.data.data&&R.data.data.results&&!H){let P=R.data.data.results;z(P),p(!C||C===""?!1:R.data.data.meta.variantCount);}s(!1);}).catch(R=>{console.error(R),s(!1);});},D=u||m,q={id:void 0,name:K.filters_all||"ALL"},F=H=>{let oe=H.reduce((te,Y)=>te.reduce((R,P)=>R.concat(Y.map(j=>[].concat(P,j))),[])).map(te=>{let Y;return Array.isArray(te)?Y={id:te.map(R=>R.id).join(","),name:te.map(R=>R.name).join(" / "),members_count:te.reduce((R,P)=>R*(D[P.id]||1),1),ordering:te.reduce((R,P)=>R+P.ordering,0)}:(te.members_count=D[te.id]||0,Y={...te,members_count:D[te.id]||0}),Y}),J=oe.reduce((te,Y)=>te+(Y.members_count||0),0);return [{...q,members_count:J},...oe]},L=o.length>1,G=useMemo(()=>{let H=[];if(!i&&o.length>0&&D){let oe=o.filter(J=>J.dimensions.length>0).map(J=>{let te=!1,Y=F(J.dimensions.map(R=>R.variants));return Y&&Y.length>2&&(te=!0),{id:J.id,name:J.dimensions.map(R=>R.name).join(" / "),variants:Y,members_count:Y.filter(R=>R.id).reduce((R,P)=>R+(P.members_count||0),0),show:te}});H=[{...q,members_count:oe.reduce((J,te)=>J+(te.members_count||0),0)},...oe];}return H},[i,D,o,q]),V=useMemo(()=>{let H;return G&&(y.profile?y.profile&&(H=G.find(oe=>oe.id===y.profile),H&&y.variant&&H.variants&&(H=H.variants.find(oe=>oe.id===y.variant))):H=G.find(oe=>!oe.id)),H?H.members_count:t},[y,G]),ie={metadata:o,loadingMetadata:i,setLoadingMetadata:l,loadingItems:a,setLoadingItems:s,resultCount:u,totalCount:m,setResultCount:A,activePage:f,setActivePage:g,pageSize:t,filters:y,setFilters:T,doQuery:O,query:C,setQuery:B,debouncedQuery:E,results:_,currentPageTotal:V,selectorStructure:G,translations:K,setTranslations:H=>w({..._s,...H}),showSelectors:L,initExplore:U};return jsx(mu.Provider,{value:ie,children:e})}var _s,mu,Sr,ko=b(()=>{c();_s={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:{}},mu=createContext({metadata:[],loadingItems:!1,setLoadingItems:()=>null,loadingMetadata:!1,setLoadingMetadata:()=>null,resultCount:{},totalCount:{},setResultCount:()=>null,activePage:1,setActivePage:()=>null,pageSize:10,results:[],filters:{},doQuery:()=>null,setFilters:()=>null,query:"",setQuery:()=>null,debouncedQuery:"",currentPageTotal:10,selectorStructure:[],translations:_s,setTranslations:()=>null,showSelectors:!0}),Sr=()=>useContext(mu);});function hb({translations:e}){let{loadingItems:t,setFilters:r,selectorStructure:o,filters:n,showSelectors:a}=Sr(),s=g=>{let y=g===null||Number.isNaN(g)?void 0:parseInt(g,10);y!==n.profile?r({profile:y,variant:void 0}):y&&r({profile:void 0,variant:void 0});},i=g=>{let y=g===null?void 0:typeof g=="string"&&g.includes(",")?g:parseInt(g,10);y!==n.variant?r({...n,variant:y}):y&&r({...n,variant:void 0});},l=g=>g<1e3?g:format$1(e.count_format)(g).replace(/\.0+([a-zA-Z]*)$/,"$1"),u=o.length===2?o[1].id:n.profile,p=u?o.find(g=>g.id===u):void 0,m=p&&p.variants&&n.variant?p.variants.find(g=>g.id===n.variant):void 0,d=useMemo(()=>o.map(g=>({value:String(g.id||""),label:(e?.dimensionIcon?.[g.name]?`${e?.dimensionIcon?.[g.name]} `:"")+(e?.dimension[g.name]||g.name)+(!t&&(!p||g.id===p?.id)?` (${l(g.members_count)})`:"")})),[e,p,o]),f=useMemo(()=>p?.variants?.map(g=>({value:String(g.id||""),label:(e?.variantIcon?.[g.name]?`${e?.variantIcon?.[g.name]} `:"")+(e?.variant[g.name]||g.name)+(!t&&(!m||g.id===m?.id)?` (${l(g.members_count)})`:"")}))??[],[e,m,o]);return jsx(Fragment,{children:a&&jsxs(Fragment,{children:[jsx(MediaQuery,{largerThan:1e3,styles:{display:"none"},children:jsxs(Group,{className:"bespoke-explore-reports-select-container",position:"center",mb:"md",children:[jsx(Select,{className:"bespoke-explore-reports-select",data:d,value:String(p?.id||""),onChange:g=>s(g),label:e.select_report||"Select Report",placeholder:e.select_report||"Select Report",clearable:typeof p?.id<"u",style:{width:"450px"}}),p?.variants&&p.variants.length>2&&jsx(Select,{className:"bespoke-explore-variant-select",data:f,value:String(m?.id||""),onChange:g=>i(g),label:e.select_variant||"Select Variant",placeholder:e.select_variant||"Select Variant",clearable:typeof m?.id<"u",style:{width:"450px"}})]})}),jsx(MediaQuery,{smallerThan:1e3,styles:{display:"none"},children:jsxs("div",{children:[jsx(Group,{position:"center",className:"bespoke-explore-reports-selector",mb:"md",children:o.map(g=>jsxs(Button,{"data-selected":g.id===p?.id?"true":"false","data-report-name":g.name,variant:g.id===p?.id?"outline":"subtle",onClick:()=>s(g.id),rightIcon:g.id&&g.id===p?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.dimensionIcon?.[g.name]??void 0,children:[jsx(Text,{span:!0,className:"bespoke-explore-reports-name",dangerouslySetInnerHTML:{__html:e?.dimension[g.name]??g.name}}),!t&&(!p||g.id===p?.id)&&jsx(Text,{span:!0,size:"xs",ml:"0.2rem",className:"bespoke-explore-reports-count",children:`(${l(g.members_count)})`})]},`p-${g.id}`))}),p&&p.variants&&p.variants.length>2&&jsx(Group,{position:"center",style:{minHeight:"36px"},className:"bespoke-explore-variant-selector",mb:"md",children:p.variants.map(g=>jsxs(Button,{"data-selected":g.id===m?.id?"true":"false","data-variant-name":g.name,variant:g.id===m?.id?"outline":"subtle",onClick:()=>i(g.id),rightIcon:g.id&&g.id===m?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.variantIcon?.[g.name]?jsx(Text,{span:!0,dangerouslySetInnerHTML:{__html:e.variantIcon[g.name]}}):void 0,children:[jsx(Text,{span:!0,className:"bespoke-explore-variant-name",dangerouslySetInnerHTML:{__html:e?.variant[g.name]??g.name}}),!t&&(!m||g.id===m?.id)&&jsx(Text,{span:!0,size:"xs",ml:"0.2rem",className:"bespoke-explore-variant-count",children:`(${l(g.members_count)})`})]},`v-${g.id}`))})]})})]})})}var Tu,xu=b(()=>{c();ko();Tu=hb;});function st(){return useMantineTheme().other.bespokeStyles??{}}var Zr=b(()=>{c();});function Ms({reportId:e,reportName:t,members:r,href:o,onClick:n}){let a=r.map(i=>jsx(Image,{src:i.image.src,height:160,imageProps:{loading:"lazy"},alt:i.name},i.id)),s=r.map(i=>jsxs(Stack,{children:[jsx(Text,{weight:500,children:i.name}),jsx(Badge,{color:"green",variant:"light",w:"fit-content",children:i.variant})]},i.id));return jsxs(Card,{className:`report-${e}-tile`,shadow:"sm",p:"lg",radius:"md",withBorder:!0,children:[jsx(Card.Section,{children:jsx(Group,{grow:!0,spacing:0,children:a})}),jsx(Group,{position:"apart",mt:"md",mb:"xs",children:s}),jsx("a",{href:o,onClick:n,children:jsx(Button,{variant:"light",color:"blue",fullWidth:!0,mt:"md",radius:"md",children:`See ${t} Report`})})]})}function kb({profile:e,profilePrefix:t,onSelect:r,reportTile:o}){let n=useRouter(),a=n.locale,{localeDefault:s}=Pe(),l=`${a===s?"":`/${a}`}${t}${e.path}`,u=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}})),p=f=>{n.push(`${f}`),r&&r();},m=f=>{f.preventDefault(),p(l);},d=Cb(o);return jsx(Grid.Col,{xs:12,sm:6,md:4,lg:4,xl:3,children:jsx(d,{reportId:e.report.id,reportName:e.report.name,members:u,href:l,onClick:m})},e.id)}var Cb,ku,Ns=b(()=>{c();Zr();wt();Cb=e=>{let{components:t}=st(),r=Ms;return t?.ReportTile&&(r=t?.ReportTile),e&&(r=e),r};ku=kb;});function Ob({profilePrefix:e,onSelect:t=()=>{},reportTile:r}){let[o,n]=useState(500),a=useRef(null),{results:s}=Sr(),i=a.current?.offsetTop||0,l=50;return useEffect(()=>{let{innerHeight:u}=window;n(u-i-l);},[i]),jsx(ScrollArea,{offsetScrollbars:!0,type:"always",h:o,ref:a,children:jsx(Grid,{align:"stretch",children:s.map(u=>jsx(ku,{profile:u,profilePrefix:e,reportTile:r,onSelect:t},u.id))})})}var Au,wu=b(()=>{c();Ns();ko();Au=Ob;});function Mb(){let{activePage:e,setActivePage:t,pageSize:r,currentPageTotal:o}=Sr();return jsx(Group,{position:"center",children:jsx(Pagination,{value:e,onChange:a=>{t(a);},total:Math.ceil(o/r),size:"sm",py:"xs"})})}var Iu,Lu=b(()=>{c();ko();Iu=Mb;});function jb({profilePrefix:e,initialReportId:t,initialVariantId:r,translations:o,onSelect:n,reportTile:a,initialQuery:s}){let i=useRef(),l=Sr(),{query:u,setQuery:p,results:m,loadingItems:d,loadingMetadata:f,translations:g,setTranslations:y,initExplore:T}=l;useEffect(()=>{T&&T(t,r,s);},[T]),useEffect(()=>{d||i.current?.focus();},[d]),useEffect(()=>{o&&y(o);},[o]);let C=()=>{p("");};return jsxs(Container,{fluid:!0,pt:"1em",children:[jsx(TextInput,{placeholder:g.search,mb:"md",size:"xl",onChange:B=>p(B.target.value),readOnly:f||d,icon:jsx(IconSearch,{size:24}),value:u,rightSectionWidth:100,rightSectionProps:{style:{justifyContent:"flex-end",padding:"0 15px 0 0"}},rightSection:jsxs(Group,{align:"center",children:[(f||d)&&jsx(Loader,{size:28}),u&&u!==""&&jsx(ActionIcon,{onClick:C,children:jsx(IconTrash,{size:24})})]}),ref:i}),jsx(Tu,{translations:g}),jsx(LoadingOverlay,{visible:f||d}),!d&&m.length===0&&jsx(Alert,{title:g.no_results,color:"blue",children:g.try_another}),jsx(Au,{profilePrefix:e,onSelect:n,reportTile:a}),jsx(Iu,{})]})}var _u,Bu=b(()=>{c();xu();wu();Lu();ko();_u=jb;});function ev({exploreProps:e={profilePrefix:"/",locale:Jb},icon:t=jsx(IconSearch,{size:20}),actionIconProps:r={},modalProps:o={},tooltipProps:n={},tooltipText:a="Click to Explore",showIcon:s=!0,showTooltip:i=!1,children:l}){let[u,p]=useState(!1),m={variant:"light",size:"md",radius:"md",...r},d={fullScreen:!0,opened:u,onClose:()=>p(!1)},f=jsx(ActionIcon,{...m,onClick:()=>p(!0),children:t}),g=s?jsxs(Group,{spacing:"sm",style:{cursor:"pointer"},children:[l,f]}):l;return i&&(g=jsx(Tooltip,{label:a,...n,children:g})),jsxs(Fragment,{children:[jsx(Modal,{...d,...o,children:u&&jsx(_u,{...e,onSelect:()=>p(!1)})}),jsx("div",{onClick:()=>p(!0),children:l?g:jsx(Fragment,{children:f})})]})}var Jb,Du,Fu=b(()=>{c();Bu();wt();({localeDefault:Jb}=Pe());Du=ev;});var sv,Vu,$u=b(()=>{c();sv=forwardRef(({id:e,members:t,...r},o)=>{let n=t.map(a=>jsxs(Stack,{align:"center",children:[jsx(Text,{weight:500,children:a.name}),jsx(Badge,{color:"green",variant:"light",children:a.variant})]},a.id));return jsx("div",{ref:o,children:jsx(Group,{position:"apart",grow:!0,...r,children:n})},e)}),Vu=sv;});function bv({locale:e,profilePrefix:t="/report",autocompleteProps:r={},tooltipProps:o={},tooltipText:n="Click to search",searchReportParams:a={},callback:s,children:i}){let l=useRouter(),u=l.locale,{localeDefault:p}=Pe(),m=u===p?"":`/${u}`,d=yv(r?r.itemComponent:null),[f,g]=useState(""),[y,T]=useDebouncedValue(f,500),[C,B]=useState([]),[E,_]=useState(!1),[z,K]=useState(!1),[w,I]=useState(!1),[k,M]=useState(!i),x=()=>{M(!1);},A=()=>{M(!0),q();},U=useRef(),O=useClickOutside(x),D=r?.searchConfig?.searchLimit??10,q=()=>{_(!0);let J={query:y,format:"profiles",locale:e,limit:D,visible:!0,includes:!0,noImage:!1,variant:[],dimension:[],report:[],all:!1,...a};Fn.get("/api/cms/search/reports",{params:J}).then(te=>{te&&te.data&&te.data.data&&te.data.data.results&&B(te.data.data.results.map(Y=>({id:Y.id,reportName:Y.report.name,href:`${m}${t}${Y.path}`,reportPath:`${Y.path}`,profilePrefix:t,value:`VALUE: ${Y.id}`,members:Y.members.map(R=>({original_id:R.metadata.id,name:R.name,id:R.id,variant:R.metadata.variant.name,image:{src:`/api/cms/member/image?member=${R.id}&size=thumb`,alt:R.name}}))}))),_(!1),U.current?.focus();}).catch(te=>{console.error(te),_(!1);});};useEffect(()=>{w&&y.length>=(r.searchConfig?.queryThreshold??0)&&q();},[w,y,r.searchConfig?.queryThreshold]),useEffect(()=>{T(),U.current&&k&&I(!0);},[]),useEffect(()=>{T(),U.current&&k&&I(!0);},[k]);let F=J=>{M(!1),s?s(J):(l.push(J.href),K(!0));},L=J=>{J.includes("VALUE:")||g(J);},{searchConfig:G,...V}=r,ie={placeholder:"Search",size:"md",icon:jsx(IconSearch,{}),...V,data:C},H=jsx(Autocomplete,{value:f,itemComponent:d,onItemSubmit:F,onChange:L,filter:()=>!0,disabled:(E||z)&&!w,limit:D,maxDropdownHeight:250,rightSection:jsx(Group,{spacing:0,position:"right",children:E?jsx(Loader,{size:20}):jsx(Fragment,{})}),rightSectionWidth:50,ref:U,...ie});return i?jsx(Tooltip,{label:n,disabled:k,...o,children:jsxs(Group,{ref:O,spacing:"sm",align:"center",style:{cursor:"pointer"},children:[!k&&jsx("div",{onClick:()=>M(!0),children:i}),k&&jsx(Fragment,{children:H}),k?jsx(ActionIcon,{variant:"light",onClick:x,children:jsx(IconX,{size:20})}):jsx(ActionIcon,{variant:"light",onClick:A,children:jsx(IconSearch,{size:20})})]})}):H}var yv,Hu,ju=b(()=>{c();Zr();$u();wt();yv=e=>{let{components:t}=st(),r=Vu;return t?.ReportItem&&(r=t?.ReportItem),e&&(r=e),r};Hu=bv;});function xv(){let{components:e}=st(),{modal:t,inline:r}=e?.search??{};return {modal:t,inline:r}}function an(e,t,r,o,n){let a=xv(),s=Q(m=>({reportId:m.variables.attributes.report_id,variantId:m.variables.attributes.variant_id1,title:m.variables.attributes.name1})),i=useRouter(),l=Zn(),u=Oe();return useMemo(()=>{let m=e;return t==="modal"?m=jsx(Du,{exploreProps:{locale:i.locale||Wu,profilePrefix:l,translations:u.explore,initialReportId:s.reportId,initialVariantId:s.variantId,initialQuery:s.title},tooltipText:u.explore?.tooltip,modalProps:a.modal,...n,children:e}):t==="inline"&&(m=jsx(Hu,{locale:i.locale||Wu,profilePrefix:l,callback:r,tooltipText:u.explore?.tooltip,...o,autocompleteProps:a.inline,children:e})),m},[t,e])}var Wu,$s=b(()=>{c();St();he();Ce();Fu();ju();wt();Zr();({localeDefault:Wu}=Pe());});function Ut(){let e=Xe();return useMemo(()=>async t=>await e(nt.readMember(t)),[e])}var wo=b(()=>{c();he();});function zs(){let{query:e,locale:t,asPath:r}=useRouter(),{profilePrefix:o}=Kr(),{compare:n}=e,a=Q(w=>Object.values(w.records.entities.report)[0]),s=Q(w=>w),i=Dt(s),l=hr(s),u=yr(s),p=Pt(l,t),m=Ut(),[d,f]=useState(null),[g,y]=useState(null),[T,C]=useState(!!n),[B,E]=useState(!1),[_,z]=useState(!1),K=a.settings;return useEffect(()=>{let w=!1,I=Fn.CancelToken.source();if(K.comparison&&n&&!B){C(!0);let k={cancelToken:I.token};Fn.get(`/api/cms/report?report=${n}&locale=${t}&prefix=${o}`,k).then(M=>{if(!w){let[,x]=r.split("?"),A=x?JSON.parse('{"'+decodeURI(x).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'):{},U=Object.fromEntries(Object.entries(A).filter(([q])=>q.match(Xu)).map(([q,F])=>[q.replace("Compare",""),F])),O=Object.entries(A).filter(([q])=>q.match(Xu)).map(([q])=>Number(q.match(/\d+/))),D=M.data.data.variables;O.length?Promise.all(O.map(q=>{let L=i[q].consumers.reduce((V,ie)=>({...V,...D.variables[ie]}),{}),G={locale:t,query:U,variables:{...L,...D.attributes}};return Lt(i,void 0,q,p,G,{variables:D.variables,status:D.status},m,"report",u)})).then(q=>{let F=Object.assign({},...q.map(G=>G.variables)),L=Object.assign({},...q.map(G=>G.status));z(!1),C(!1),E(!0),f({variables:F,attributes:D.attributes,status:L}),y(M.data.data.status);}):(z(!1),C(!1),E(!0),f(M.data.data.variables),y(M.data.data.status));}}).catch(()=>{w||(z(!0),E(!1),C(!1),f(null));});}return n||(f(null),y(null),E(!1)),()=>{w=!0,I.cancel();}},[n,t,o,K.comparison,r,B,m]),{active:!!d,variables:d,status:g,setComparisonVariables:f,comparisonLoaded:B,loading:T,error:_}}var Xu,Qu=b(()=>{c();Xt();he();Fr();lr();br();wo();Xu=/\w*Compare\b/;});function Ze(){return useContext(Zu)}function Us({children:e}){let t=zs();return jsx(Zu.Provider,{value:t,children:e})}var Zu,er=b(()=>{c();Qu();Zu=createContext({active:!1,variables:null,status:null,setComparisonVariables:null,comparisonLoaded:!1,loading:!1,error:!1});});function qs({title:e,tooltip:t,slug:r,_iconType:o,_iconVariant:n,_icon:a,settings:s,_iconRadius:i,_iconSize:l,_iconPadding:u,asComparison:p=!1}){let{print:m}=He(),d=Ge(e)||"<span class='cr-block-placeholder'>Title</span>",f=s&&s.order?parseInt(s.order,10):1,g=f<=6?f:1,y=s&&s.search?s.search:"off",T=s&&s.align?s.align:"left",C=Ze(),B=Q(I=>I.status.previews),_=(p?C.status.previews:B).map(I=>I.name).join(" | "),z=jsxs(Group,{children:[jsx(ke,{blockType:"title",iconType:o,iconVariant:n,iconRadius:i,iconSize:l,icon:a,iconPadding:u}),jsx(se,{id:r||void 0,component:"h",order:g,style:s,html:d})]}),K=an(z,y),w=s&&s.addComparisonName==="yes"&&C.active;return jsxs(Group,{spacing:"sm",position:dt(T),children:[jsxs("div",{children:[m?z:K,w&&jsx(Text,{className:"bespoke-comparison-title",children:_})]}),t&&jsx(De,{content:t})]})}var ep=b(()=>{c();Yr();Qr();Le();$s();er();he();Jt();Zt();qe();});function ra(e,t,r,o=!1,n=!1){let a=useRouter(),{query:s,locale:i}=a,l=Q(x=>x),u=useDispatch(),p=Ze(),m=Q(x=>o&&p.variables?p?.variables?.attributes:x.variables.attributes),d=Dt(l),f=hr(l),g=yr(l),y=Pt(f,i),T=xo(e,o&&p.active?p?.variables.variables:void 0,o&&p.active?p?.variables.attributes:void 0),C=Q(x=>o?p.variables.variables:x.variables.variables),B=Q(x=>o?p.variables.status:x.variables.status),E=Ut(),{sectionVariables:_,resetSectionVariables:z}=Ie(t),{addRunConsumersRunning:K,removeRunConsumersRunning:w}=Ro(),I=o&&p.active?`${r}Compare`:r,k=o&&p.active?Object.fromEntries(Object.entries(s).filter(([x])=>x.match(_v)).map(([x,A])=>[x.replace("Compare",""),A])):Object.fromEntries(Object.entries(s).filter(([x])=>x.match(Bv)).map(([x,A])=>[x.replace("Compare",""),A]));return useCallback(x=>{let A={locale:i,query:{...k,[r]:x},variables:T},U=new URLSearchParams(window.location.search);U.set(I,x),window.history.replaceState(null,null,`?${U.toString()}`),K([t]),Lt(d,void 0,e,y,A,{variables:C,status:B},E,"report",g).then(O=>{p.active&&o?p.setComparisonVariables({attributes:m,variables:O.variables,status:O.status}):u(dr.setVariableChange({attributes:m,variables:O.variables,status:O.status})),n&&_&&z(),w([t]);});},[e,t,r,I,s,d,u,y,a,T.attributes,o,n,B,C])}var _v,Bv,Hs=b(()=>{c();Fr();he();lr();br();bo();Ce();wo();er();_v=/\w*Compare\b/,Bv=/selector\d+id/;});function Ys(e){let{name:t,settings:r,options:o,id:n,defaultValue:a,section:s,component:i,asComparison:l,hideLabel:u,resetSectionVars:p}=e,{print:m}=He(),d=Gv(n),f=ra(n,s,d,l,p==="true"),g=l?`${d}Compare`:d,[y,T]=useState(a),[C,B]=useState(rp(a,[])),E=JSON.stringify(o),_=r[Kt.DISABLED]||!1,z=useMemo(()=>o?.map(x=>({value:x.id,label:x.label,imageUrl:x.imageUrl})),[E]),K=m?o.filter(x=>C.includes(x.id)).map(x=>x.label).join(", "):"",w=m&&y&&o.find(x=>x.id===y)?.label||"",I=e.hideLabel==="true"?jsx(Fragment,{}):jsx(se,{component:"div",html:t,size:"sm",style:r});if(useEffect(()=>{if(!_){let A=new URLSearchParams(window.location.search).get(g)||a;A&&(e.type===Ae.SINGLE?T(A):B(rp(A,a)));}},[window.location.search,a]),z.length<=1)return jsx(Fragment,{});let k=x=>{B(x),f(x.join(","));},M=x=>{T(x),f(x);};return jsx(Fragment,{children:m?jsxs(Box,{style:{display:"flex",alignItems:"center"},children:[I,jsx(Button,{ml:"sm",radius:"xl",variant:"outline",children:e.type===Ae.SINGLE?w:K})]}):jsx(Box,{children:{[Ae.SINGLE]:i===_n.SEGMENTED_CONTROL?jsxs("div",{children:[jsx(Text,{size:"sm",fw:500,display:u==="true"?"none":"block",children:I}),jsx(SegmentedControl,{data:z,disabled:_,value:z.map(x=>x.value).includes(y)?y:"",onChange:M,fullWidth:!0})]}):jsx(Select,{label:I,data:z,disabled:_,value:y,itemComponent:qv,onChange:M,styles:{label:{display:u==="true"?"none":"block"}}}),[Ae.MULTI]:jsx(MultiSelect,{label:I,data:z,value:C,onChange:k,disabled:_,styles:{label:{display:u==="true"?"none":"block"}}})}[e.type]})})}var Gv,rp,qv,np=b(()=>{c();Le();fe();Hs();Jt();Gv=e=>`selector${e}id`,rp=(e,t)=>e&&typeof e=="string"?e.split(","):t,qv=forwardRef(function({imageUrl:t,label:r,...o},n){return jsx("div",{ref:n,...o,children:jsxs(Group,{noWrap:!0,children:[t&&!["","undefined"].includes(t)&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:r})})]})})});});function oa(){return jsx("div",{children:"Generator"})}var ap=b(()=>{c();});function Xs(e){let{alt:t,src:r,desc:o,title:n,settings:a,...s}=e,i=Ge(t),l=Ge(r),u=Ge(o),p=jsx("img",{src:l,alt:i,style:s}),m=a&&a.align?String(a.align):"left";return (u&&u.length||n&&n.length)&&(p=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Vt(m),spacing:"sm",children:[n&&jsx(se,{component:"p",html:n,style:a}),p,o&&jsx(se,{component:"p",size:"sm",html:o,style:a})]})),l&&i?p:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var sp=b(()=>{c();Yr();Le();qe();});function cn(){return cn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);}return e},cn.apply(this,arguments)}var ip=b(()=>{c();});function un(){return un=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);}return e},un.apply(this,arguments)}var lp=b(()=>{c();});function eo(e,t,r){var o,n=(o=r.initialDeps)!=null?o:[],a;return function(){var s;r.key&&r.debug!=null&&r.debug()&&(s=Date.now());var i=e(),l=i.length!==n.length||i.some(function(g,y){return n[y]!==g});if(!l)return a;n=i;var u;if(r.key&&r.debug!=null&&r.debug()&&(u=Date.now()),a=t.apply(void 0,i),r.key&&r.debug!=null&&r.debug()){var p=Math.round((Date.now()-s)*100)/100,m=Math.round((Date.now()-u)*100)/100,d=m/16,f=function(y,T){for(y=String(y);y.length<T;)y=" "+y;return y};console.info("%c\u23F1 "+f(m,5)+" /"+f(p,5)+" ms",`
|