@datawheel/bespoke 0.7.15-rc.5 → 0.7.15-rc.7

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.
Files changed (2) hide show
  1. package/dist/report.js +1 -1
  2. package/package.json +1 -1
package/dist/report.js CHANGED
@@ -59,7 +59,7 @@ var Qf=Object.defineProperty;var v=(e,t)=>()=>(e&&(t=e(e=0)),t);var Pa=(e,t)=>{f
59
59
  In pulvinar sapien ut tincidunt volutpat. Donec auctor tellus eu augue feugiat,
60
60
  a viverra sapien pulvinar.`,style:r,append:t?jsx(Be,{content:t,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{}),isPreview:!0})}var ad=v(()=>{c();qt();we();});function hi({subtitle:e,title:t,value:r,tooltip:o,settings:n,_iconType:a,_iconVariant:s,_icon:i,_iconRadius:l,_iconSize:u,_iconPadding:p}){let d=t||"<span class='cr-block-placeholder'>Title</span>",m=r||"<span class='cr-block-placeholder'>Big Stat</span>",b=e||"<span class='cr-block-placeholder'>Subtitle</span>",f=n&&n.align||"left";return jsx("div",{className:"bespoke-Stat-root",children:jsxs(Group,{className:"bespoke-StatGroup-wrapper",position:at(f),children:[a!=="none"&&a&&jsx(Re,{blockType:"stat",iconType:a,iconVariant:s,iconRadius:l,iconSize:u,icon:i,iconPadding:p}),jsxs("div",{className:"bespoke-Stat-wrapper",children:[jsx(se,{component:"div",size:"md",html:d,style:n,isPreview:!0}),jsx(se,{component:"div",size:"xl",html:m,style:n,isPreview:!0}),jsx(se,{component:"div",size:"sm",html:b,style:n,isPreview:!0})]},"stat"),o&&jsx(Be,{content:o})]})})}var id=v(()=>{c();qt();Lr();we();ze();});function yi({subtitle:e,tooltip:t,settings:r}){let o=Ve(e)||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=r&&r.align?r.align:"left";return jsxs(Group,{spacing:"sm",position:at(n),children:[jsx(se,{size:"sm",html:o,isPreview:!0}),t&&jsx(Be,{content:t,style:{display:"inline-flex"}})]})}var cd=v(()=>{c();qt();wr();we();ze();});function bi({title:e,tooltip:t,_iconType:r,_iconVariant:o,_icon:n,settings:a,_iconRadius:s,_iconSize:i,_iconPadding:l}){let u=Ve(e)||"Title",p=a&&a.order?parseInt(a.order,10):1,d=p<=6?p:1,m=!!(a&&a.search&&a.search!=="off"),b=a&&a.search?a.search:"",f=a&&a.align?a.align:"left";return jsxs(Group,{spacing:"sm",position:at(f),children:[r!=="none"&&r&&jsx(Re,{blockType:"title",iconType:r,iconVariant:o,iconRadius:s,iconSize:i,icon:n,iconPadding:l}),jsx(se,{component:"h",order:d,style:a,html:u,isPreview:!0}),m&&jsx(Tooltip,{label:`Click will open '${b}' report search`,children:jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})}),t&&jsx(Be,{content:t})]})}var ud=v(()=>{c();qt();wr();Lr();we();ze();});function Ti(e){let{id:t,type:r,defaultValue:o,options:n,name:a,settings:s,hideLabel:i,component:l,resetSectionVars:u,section:p}=e,d=useDispatch(),m=useContext($t),b=X(x=>x.status.query),{sectionVariables:f,resetSectionVariables:y}=Ae(p),h=ET(t),w=useMemo(()=>b[h]||o,[b[h],r,o]),I=useMemo(()=>kT(b[h],o),[b[h],r,o]),[A,k]=useState(n?.map(x=>({value:x.id,label:x.label,imageUrl:x.imageUrl}))||[]),[N,z]=useState((n||[]).map(x=>x.id).join("-"));useEffect(()=>{let x=n.map(O=>`${O.label}|${O.id}`).join("-");if(N===x)return;z(x);let L=n.map(O=>({value:O.id,label:O.label}));k(L);let D=r===ke.SINGLE?w:I;yr(r,D,n)||d(ms(m,h));},[JSON.stringify(n),t]);let E=()=>{u==="true"&&f&&y();},F=x=>{d(Pr(m,h,x)),E();},C=x=>{d(Pr(m,h,x.join())),E();},R=i==="true"?jsx(Fragment,{}):jsx(se,{component:"div",html:a,size:"sm",style:s,isPreview:!0});return A.length===0?jsx(Text,{c:"dimmed",size:"xs",children:"No options defined yet. Selector hidden in report."}):A.length===1?jsxs(Text,{c:"dimmed",size:"xs",children:["Only one option defined. Selector hidden in report. ",JSON.stringify(A)]}):{[ke.SINGLE]:l===yn.SEGMENTED_CONTROL?jsxs("div",{children:[R,jsx(SegmentedControl,{data:A,value:A.map(x=>x.value).includes(w)?w:"",onChange:F,fullWidth:!0})]}):jsx(Select,{label:R,data:A,value:w,onChange:F,itemComponent:CT,styles:{label:{display:i==="true"?"none":"block"}}}),[ke.MULTI]:jsx(MultiSelect,{label:R,data:A,value:I,onChange:C,styles:{label:{display:i==="true"?"none":"block"}}})}[r]}var ET,kT,CT,md=v(()=>{c();Vo();vn();ye();he();Ut();we();Se();ET=e=>`selector${e}id`,kT=(e,t)=>e&&typeof e=="string"?e.split(","):t,CT=forwardRef(function({imageUrl:t,label:r,...o},n){return jsx("div",{ref:n,...o,children:jsxs(Group,{noWrap:!0,children:[t&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:r})})]})})});});var fd=v(()=>{});function ki({dimmed:e=!1,label:t,root:r=!0,value:o,parentIsArray:n=!1,level:a=0}){let s=useMantineTheme();if(a===Ei)return null;let i=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),l=Ri(o),u=o,p=JSON.stringify(o),d=!!(p&&p.length>50),m=!!(p&&p.length>1e3),b=10,f={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(l==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:f,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,color:e?"dimmed":s.primaryColor,children:r?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:a+1<Ei?Object.keys(o).sort((y,h)=>{let w=Ri(o[y]),I=Ri(o[h]);return w!==I?gd.indexOf(w)-gd.indexOf(I):y.localeCompare(h)}).map(y=>jsx(ki,{root:!1,label:y,value:o[y],level:a+1},y)):i})]})});if(l==="array"){let y=o.length>b,h=y?o.slice(0,b):o,w=y?o.length-b:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:f,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,p:0,color:e?"dimmed":s.primaryColor,children:r?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[a+1<Ei?h.map((I,A)=>jsx(ki,{root:!1,label:A,value:I,level:a+1,parentIsArray:!0},A)):i,y&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",w," other elements]"]})]})]})})}return l==="string"?u=m?`"${u.substring(0,1e3)} ... "`:`"${u}"`:l==="error"?u=`Error: ${u.message}`:l==="undefined"?u=l:u.toString&&(u=u.toString()),jsxs(Group,{noWrap:!0,spacing:0,children:[jsx(Text,{color:e?"dimmed":s.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap"},weight:700,children:r?`{{${t}}}`:n?`[${t}]`:t}),jsx(Prism,{className:"cr-variable",language:"jsx",noCopy:!0,scrollAreaComponent:"div",styles:{root:{flex:"1 1 100%",textAlign:"right",overflow:"hidden"},code:{padding:"5px 0 5px 5px"},scrollArea:{marginLeft:"5px"},line:{paddingRight:"5px"}},children:u}),d&&jsxs(HoverCard,{width:400,shadow:"md",withinPortal:!0,children:[jsx(HoverCard.Target,{children:jsx(ActionIcon,{children:jsx(IconCodePlus,{})})}),jsx(HoverCard.Dropdown,{children:jsx(Text,{size:"sm",children:JSON.stringify(o).substring(0,5e3)})})]})]})}var Ri,gd,Ei,hd,yd=v(()=>{c();fd();Ri=e=>{let t=typeof e;if(t==="object"){if(e===null)return "undefined";Array.isArray(e)?t="array":["Error","EvalError","ReferenceError","SyntaxError"].includes(e.constructor.name)&&(t="error");}return t},gd=["object","array","string","number"],Ei=5;hd=ki;});var bd,vd=v(()=>{c();bd=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function MT({reserved:e=[],id:t,variables:r={},showInternal:o=!1}){let a=ft(t==="attributes"?null:t).data,s=a?a.type:"block",i=a?.type&&a?.id?`${a.type}${a.id}`:"",l=Object.keys(r).filter(o?()=>!0:u=>!bd(i)(u));return jsx(Stack,{spacing:0,children:l.length?l.map(u=>jsx(hd,{dimmed:e.includes(u),label:u,value:r[u]},u)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${s}`})})})}var Sd,Td=v(()=>{c();yd();he();vd();Sd=MT;});function HT({outputVariables:e,status:t,hasAPI:r=!1,debug:o,type:n}){let[a,s]=useState(!1),i=r&&!Object.keys(e).length&&!t.error,l=Object.keys(e).some(p=>p.startsWith("_"));return o?i?jsxs(Stack,{align:"center",children:[jsx(Loader,{}),jsxs(Text,{size:"sm",children:["Loading ",n]})]}):jsxs(Fragment,{children:[jsx(Divider,{label:"Output Variables",labelPosition:"center"}),l&&jsx(Switch,{label:"Show internal variables",mb:"xs",size:"xs",checked:a,onChange:p=>s(p.currentTarget.checked)}),jsx(Sd,{variables:e,showInternal:a})]}):jsx(Center,{children:jsx(Badge,{color:"gray",variant:"outline",children:n.toUpperCase()},"type")})}var Pi,xd=v(()=>{c();Td();Pi=HT;});function Ai(e){let{alt:t,src:r,desc:o,title:n,settings:a,...s}=e,i=Ve(t),l=Ve(r),u=Ve(o),p=jsx("img",{src:l,alt:i,style:s}),d=a&&a.align?String(a.align):"left";return (u&&u.length||n&&n.length)&&(p=jsxs(Stack,{className:"bespoke-Image-wrapper",align:wt(d),spacing:"sm",children:[n&&jsx(se,{component:"p",html:n,style:a,isPreview:!0}),p,o&&jsx(se,{component:"p",size:"sm",html:o,style:a,isPreview:!0})]})),l&&i?p:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var Rd=v(()=>{c();wr();we();ze();});function Li({headings:e,settings:t}){let{min:r="1",max:o="6",icons:n="yes"}=t||{},a=mo(parseInt(r,10),parseInt(o,10),e),s=n==="yes",i=lo(t&&t.align?String(t.align):"left"),l=u=>!u||!u?.length?null:jsx(Fragment,{children:u.map(p=>jsxs(Fragment$1,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${p.id}`,children:jsxs(Group,{spacing:"sm",children:[s&&jsx(Re,{...p.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:p.label}})]})})},p.id),jsx(Box,{pl:"xs",children:l(p.children)})]},p.id))});return jsx(Box,{pos:"relative",children:jsxs(List,{sx:u=>({display:"flex",gap:u.spacing.md,justifyContent:i,listStyleType:"none"}),children:[a?.map(u=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:400,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${u.id}`,children:jsxs(Group,{spacing:"sm",noWrap:!0,children:[s&&jsx(Re,{blockType:"nav",...u.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:u.label}})]})})}),u?.children?.length?jsx(Menu.Dropdown,{children:l(u.children)}):null]})},u.id)),!a||a.length===0&&jsx(List.Item,{children:jsx(Text,{color:"dimmed",children:"- Include some titles as inputs to see the Nav component -"})})]})})}var Pd=v(()=>{c();Zs();Lr();ze();});function _i(e){let{related_reports:t,settings:r}=e;if(!t?.length)return jsx(Text,{children:"There are no available members related to your current selection and report."});let o=lo(r&&r.align?String(r.align):"left");return jsx(List,{sx:()=>({display:"flex",justifyContent:o,"& li":{marginRight:"1rem"}}),children:t.map(n=>jsx(List.Item,{children:n.entities.map(a=>a.name).join(" & ")},n.link))})}var wd=v(()=>{c();ze();});function Mi({id:e,label:t,settings:r,showIcon:o,fullWidth:n,showWhenDisabled:a}){let s=ft(e).data,{sectionVariables:i,resetSectionVariables:l}=Ae(s?.section_id),u=!!Object.keys(i).length,p=wt(r&&r.align?r.align:"left");return jsxs(Stack,{align:p,children:[!u&&!a&&jsx(Text,{size:"xs",ta:r?.align||"left",children:"Reset button will not be shown on its disabled state"}),jsx(Button,{onClick:()=>l(),disabled:!u,fullWidth:n,children:jsxs(Group,{align:"center",children:[t,o&&jsx(IconRefresh,{})]})})]})}var Ld=v(()=>{c();Se();Se();ze();});function Ni({settings:e,label:t,showIcon:r,position:o="center"}){let n=e&&e.search?e.search:"";return jsxs(Group,{position:o,children:[jsx(Tooltip,{label:`Click will open '${n}' report search`,children:jsx(Button,{children:jsxs(Group,{align:"center",children:[t||"Comparison Button",r&&jsx(IconPlus,{})]})})}),jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})]})}var Bd=v(()=>{c();});function Di({columns:e=[],id:t,data:r=[],tableProps:o={}}){let[n,a]=useState({}),{initialState:s}=o,i=s?.pagination?.pageIndex,l=s?.pagination?.pageSize,u=`table-${[t,i,l].filter(f=>f).join("-")}`,p=useMemo(()=>e.map(f=>f.accessorKey),[e]),d=useMemo(()=>r.filter(f=>typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).some(y=>p.includes(y))),[p,r]),m=useMemo(()=>e.map(f=>({...f,Cell:({renderedCellValue:y})=>jsx(se,{html:`${y}`,isPreview:!0}),filterFn:"contains"})),[e]),b=wc();return useEffect(()=>{(async()=>{try{let y=b||"en",h=`${y.toUpperCase()}`,w=await import(`mantine-react-table/locales/${y}.js`);a(w[`MRT_Localization_${h}`]);}catch(y){console.error("Error loading translations:",y);}})();},[b]),createElement(MantineReactTable,{...o,autoResetPageIndex:!1,columns:m,data:d,enableColumnFilterModes:!0,enableFilterMatchHighlighting:!1,globalFilterFn:"contains",key:u,layoutMode:"grid",localization:n,state:{...o.state,isFullScreen:!1}})}var Md=v(()=>{c();we();Se();});function Vi({label:e,url:t,settings:r}){let{align:o}=r;return jsx(Group,{position:o,grow:o==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})})}var Fd=v(()=>{c();});function $i(e){let t=useDispatch(),r=useContext($t),o=X(V=>V.status.query),n=Lx(e.id),a=useMantineTheme(),{allLabel:s,colorKey:i,data:l,defaultValue:u,defaultValueType:p,iconKey:d,levels:m,limit:b,placeholder:f,searchIndexKey:y,searchIndexSeparator:h,resetSectionVars:w,section:I}=e,[A,k]=useState(!1),[N,z]=useState(!0),[E,F]=useState(""),[C,R]=useState(!1),[x,L]=useState([""].slice(1)),{sectionVariables:D,resetSectionVariables:O}=Ae(I),P=useMemo(()=>Ox(o[`${n}-value`],u),[o,u,n]),j=useMemo(()=>o[`${n}-type`]||p,[o,p,n]),K=useCallback(()=>{w==="true"&&D&&O();},[w,D,O]),q=useCallback(V=>{K(),t(Pr(r,`${n}-value`,V.join()));},[t,r,n,K]),ee=useCallback(V=>{K(),t(Pr(r,`${n}-type`,V));},[t,r,n,K]),oe=useRef(null),ce=useRef(!1),G=useRef(!!b&&b<P.length),Y=x.length,H=m[Y],$=x.filter(Boolean);x.length>0&&$.length===0&&$.push(`${s} ${H?.label}`),useEffect(()=>{let V=()=>{z(!0);};return window.addEventListener("touchmove",V),()=>{window.removeEventListener("touchmove",V);}},[]);let M=useMemo(()=>Ax(l,m,i,d,y,h),[i,l,d,m,y,h]),_=useMemo(()=>{let V=wx(E),ue=Array.from(Ix(M,V)).reverse();return C?ue:x.reduce((B,ne)=>B.filter(re=>!ne||re.searchindex.indexOf(ne)>-1),ue.filter(B=>B.type===H?.value))},[H,M,E,C,x]),te=useRef(null),U=Gn({count:A?_.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>te.current,[]),overscan:10,rangeExtractor:useCallback(V=>Yo(V),[])}),[J,Q]=useState(-1),ie=Math.min(J,_.length-1),le=useCallback(V=>{let ue=x.concat(V);C&&R(!1),L(ue);},[C,x]),ct=useCallback(()=>{let V=x.slice(0,Y-1);C&&R(!1),L(V);},[C,x,Y]),fe=useCallback(V=>{F(V.currentTarget.value),!G.current&&l.length>0&&k(!0);},[l,F,G,k]),ut=useCallback(()=>{F(""),q([]),oe.current?.focus(),b&&(G.current=!1);},[F,q,oe,b,G]),Dt=useCallback(V=>{let ue=P.filter(B=>B!==V);q(ue),b&&ue.length<b&&(G.current=!1);},[P,q,b,G]),He=useCallback(V=>{j||ee(V.type),j!==V.type?(ee(V.type),q([V.value])):P.includes(V.value)?Dt(V.value):b?(P.length<b&&q([...P,V.value]),P.length===b&&q([...P.slice(1),V.value])):q([...P,V.value]),F("");},[j,ee,q,P,Dt,b]),Eo=useCallback(()=>{P.length>0&&E.length===0&&(q(P.slice(0,-1)),k(!0),b&&(G.current=!1)),E.length>0&&F(E.slice(0,-1));},[P,E,q,F,k,b,G]),ko=useCallback(()=>{z(V=>V&&(ce.current=V,!V)),Q(V=>V+1>=_.length?V:V+1);},[Q,_]),mr=useCallback(()=>{let V=_[ie];V&&He(V);},[_,ie,He]),Co=useCallback(()=>{k(!1);},[k]),ba=useCallback(()=>{ct(),Q(0);},[Q,ct]),va=useCallback(()=>{let V=_[ie];!C&&V&&V.type!==m[m.length-1]?.value&&(le(V.name),Q(0));},[_,ie,C,m,Q,le]),Sa=useCallback(()=>{z(V=>V&&(ce.current=V,!V)),Q(V=>V-1<0?0:V-1);},[Q]),Ta=({label:V,onRemove:ue,...B})=>jsxs("div",{style:{alignItems:"center",backgroundColor:a.colorScheme==="dark"?a.colors.dark[7]:a.colors.gray[1],borderRadius:a.radius.sm,cursor:"default",color:a.colorScheme==="dark"?a.colors.dark[0]:a.colors.gray[7],display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${a.spacing.xs} / 2 - ${rem(2)}) calc(${a.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${a.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...B,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V}),jsx(CloseButton,{"aria-hidden":!0,iconSize:"70%",onMouseDown:ue,radius:2,size:"sm",sx:{color:a.colorScheme==="dark"?a.colors.dark[0]:a.colors.gray[7],marginLeft:`calc(${a.spacing.sm} / 6)`},tabIndex:-1})]}),xa=useMemo(()=>P.map(V=>M.find(ue=>ue.value===V)).filter(V=>!!V).map((V,ue)=>createElement(Ta,{...V,index:ue,key:V.value,onRemove:B=>{B.preventDefault(),B.stopPropagation(),Dt(V.value);}})),[P]),Ra=forwardRef(function({color:ue,icon:B,label:ne,value:re,...qe},be){return jsx("div",{ref:be,style:{cursor:"pointer",width:"100%"},...qe,children:jsxs(Group,{align:"center",noWrap:!0,spacing:"xs",w:"100%",children:[B&&jsx(Box,{bg:ue??"transparent",component:"img",w:20,h:20,src:B}),jsx(Text,{lineClamp:1,size:"sm",children:ne||re})]})})}),{settings:Ea}=e,ka=e.hideLabel==="true"||!e.label?jsx(Fragment,{}):jsx(se,{component:"div",html:e.label,size:"sm",style:Ea,isPreview:!0});return jsx(Input.Wrapper,{label:ka,children:jsxs(Popover,{closeOnClickOutside:!0,keepMounted:!0,opened:A,onChange:k,onClose:()=>{Q(0),F("");},onOpen:()=>{U.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:!0,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>Q(0),sx:{position:"relative","& .defaultValue":{backgroundColor:a.colorScheme==="dark"?a.colors.dark[5]:a.colors.gray[3],color:a.colorScheme==="dark"?a.colors.dark[1]:a.colors.gray[7]}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:P.join(",")}),jsx(Input,{component:"div",multiline:!0,onMouseDown:V=>{V.preventDefault(),!G.current&&l.length>0&&k(!A),oe.current?.focus();},rightSection:P.length>0?jsx(CloseButton,{onClick:ut,onMouseDown:V=>V.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:a.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":!0,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${a.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:a.colorScheme==="dark"?a.colors.dark[3]:a.colors.gray[5],opacity:1}},children:[xa,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":A,onChange:fe,onKeyDown:getHotkeyHandler([["ArrowDown",ko],["ArrowLeft",ba],["ArrowRight",va],["ArrowUp",Sa],["Backspace",Eo],["Enter",mr],["Escape",Co]]),placeholder:P.length===0?f:void 0,ref:oe,readOnly:G.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:a.fontSizes.sm,marginLeft:`calc(${a.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:E})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:V=>V.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":!0,onMouseDown:V=>V.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",spacing:"xs",w:"100%",children:[m.length>1&&jsxs(Stack,{spacing:"xs",children:[jsxs(Group,{onClick:V=>{V.stopPropagation();},px:"xs",position:"center",spacing:"xs",children:[jsx(Button,{onClick:()=>{Q(0),R(!0),L([]),_.length>0&&U.scrollToIndex(0);},size:"xs",variant:C?"filled":"outline",children:s}),m.map((V,ue)=>jsx(Button,{onClick:()=>{C&&R(!1);let B=[""].slice(1),ne=ue;for(;ne--;)B[ne]=x[ne]||"";Q(0),L(B),_.length>0&&U.scrollToIndex(0);},size:"xs",variant:!C&&x.length===m.findIndex(B=>B.value===V?.value)?"filled":"outline",children:V?.label},V?.value))]}),jsx(Divider,{})]}),Y>0&&jsxs(Group,{align:"center",noWrap:!0,px:"xs",children:[jsx(ActionIcon,{onClick:ct,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:$.map(V=>jsx(Text,{lineClamp:1,size:"xs",children:V},`${V}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>z(!0),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:te,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${U.getTotalSize()}px`,position:"relative",width:"100%"},children:U.getVirtualItems().map(V=>{let ue=_[V.index],B=ie===V.index,ne=P.includes(ue.value);return _.length>0&&B&&!N&&U.scrollToIndex(ie),jsxs(Group,{"aria-selected":B,align:"center","data-hovered":B||void 0,"data-index":V.index,"data-selected":ne,id:ue.vale,noWrap:!0,onMouseEnter:re=>{re.preventDefault(),re.stopPropagation(),N&&(Q(V.index),z(!1));},onMouseMove:re=>{re.preventDefault(),re.stopPropagation(),z(!0);},onMouseDown:re=>{re.preventDefault(),He(ue);},position:"apart",ref:U.measureElement,role:"option",spacing:"xs",sx:re=>({borderRadius:re.radius.xs,padding:"15px 5px 15px",paddingLeft:C&&10*m.findIndex(qe=>qe?.value===ue.type)||5,position:"absolute",top:0,left:0,height:`${V.size}px`,transform:`translateY(${V.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:re.colorScheme==="dark"?re.colors.dark[4]:re.colors.gray[1]},"&:hover":{backgroundColor:re.colorScheme==="dark"?re.colors.dark[4]:re.colors.gray[1]}}),tabIndex:-1,children:[jsx(Ra,{index:V.index,...ue}),!C&&ue.type!==m[m.length-1]?.value&&jsx(ActionIcon,{onMouseDown:re=>{re.preventDefault(),re.stopPropagation(),le(ue.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},ue.value)})})})]})})})})]})})}var Ax,wx,Ix,Lx,Ox,Hd=v(()=>{c();$s();we();Ut();he();Se();Vo();Ax=(e=[],t=[],r="",o="",n="",a="|")=>{let s=t.map(y=>y.value).slice(),i=`${s.pop()}`,l=y=>y[r],u=y=>y[o],p=y=>{if(y[n])return typeof y[n]=="string"?y[n].split(a):y[n]},d=new Set,m=[],b=[],f=nest().rollup(y=>{let h=y[0],w=C=>C&&C.value&&!d.has(C.value),I=s.map(C=>h[`${C} ID`]),A=s.map(C=>h[C]),k=s.map((C,R)=>{if(b[R]!==A[R]){b[R]=A[R];let x=l[R]||l[l.length-1]||l,L=u[R]||u[u.length-1]||u,D=p[R]||p[p.length-1]||p;return {color:x(h,C)||void 0,icon:L(h,C)||void 0,value:`${I[R]}`,label:A[R],name:A[R],type:C,searchindex:A.slice(0,R+1).concat(D(h,C)).join("|")}}return {}}).filter(w);k.forEach(C=>d.add(C.value));let N=l[l.length-1]||l,z=u[u.length-1]||u,E=p[p.length-1]||p,F=y.map(C=>({color:N(C,i)||void 0,icon:z(C,i)||void 0,value:`${C[`${i} ID`]}`,label:C[i],name:C[i],type:i,searchindex:A.concat(C[i]).concat(E(C,i)).join("|")}));m.push(...k.concat(F));});return s.forEach(y=>{f.key(h=>`${h[`${y} ID`]}|${h[y]}`);}),f.entries(e),m},wx=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},Ix=(e,t)=>{let r=e.length,o,n=i=>o&&o.searchindex.includes(i.searchindex),s={next:()=>{for(let i=r-1;i>-1;i--){let l=e[i];if(t.test(`${l.value} ${l.label} ${l.searchindex}`)||n(l))return o=l,r=i,{done:!1,value:l}}return {done:!0,value:void 0}},[Symbol.iterator]:()=>s};return s},Lx=e=>`multihierarchySelector${e}`,Ox=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var jd={};Pa(jd,{default:()=>Gx});function Ux({block:e,active:t,locale:r,variables:o,debug:n,configOverride:a={}}){let s=zx(),i=Oe(e),l=Pt(r),u={variables:o},p=useRouter(),{sectionVariables:d,setSectionVariables:m,resetSectionVariables:b}=Ae(e.section_id),f=useMemo(()=>{if(!t)return {error:"Activate to View"};if(!i?.logic)return {error:"Add a Configuration"};let C=ot({logic:i.logic},l,u).logic,R={router:p,section:{variables:d,setVariables:m,resetVariables:b}};return ir(C,l,o,r,e.id,{},R)},[i?.logic,t,o,d]);useMemo(()=>{if(!t||!i?.logic)return {};let{logic:C}=i,{vars:R}=rt("variables",o,C,l,void 0,u);return R},[e,t]);let {type:h}=f.config||{},w=h&&Ui[h]?h:"Treemap";h||(f.config={error:'Visualization missing "type"'}),Ui[h]||(f.config={error:`"${h}" is not a valid Visualization Type`});let I=Ui[w],A=f.error||f.config?.error||!1;if(A)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:A},"type")});let{_data:k,...N}=f.config,z={locale:r,variables:o,...N,...a};console.log(s.print,"print aca viz"),s.print&&(z.detectVisible=!1);!s.print&&h!=="Graphic"&&h!=="HTML";return jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(Fr,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(I,{style:{flex:1},dataFormat:C=>{f.data&&Array.isArray(f.data)&&f.data.length>1&&f.data.some(D=>typeof D=="string")?C:[C];let L;try{L=f.dataFormat(C);}catch(D){console.log("Error in dataFormat: ",D),L=[];}return L},linksFormat:f.linksFormat,nodesFormat:f.nodesFormat,topojsonFormat:f.topojsonFormat,config:{...z}},"viz-key")})})}var zx,$x,Ui,Gx,Wd=v(()=>{c();hr();Wr();di();Jo();br();Se();pi();zx=()=>({}),$x={},Ui={HTML:en,...XS,...$x};Gx=memo(Ux,(e,t)=>e.block.contentByLocale.logic.content===t.block.contentByLocale.logic.content&&e.active===t.active&&e.locale===t.locale&&JSON.stringify(e.variables)===JSON.stringify(t.variables)&&JSON.stringify(e.configOverride)===JSON.stringify(t.configOverride));});var qx,Fe,Kd=v(()=>{c();ye();ad();id();cd();ud();md();xd();Rd();Pd();wd();Ld();Bd();Md();Fd();Hd();qx=JS(()=>Promise.resolve().then(()=>(Wd(),jd)),{ssr:!1}),Fe={[g.PARAGRAPH]:gi,[g.STAT]:hi,[g.SUBTITLE]:yi,[g.TITLE]:bi,[g.SELECTOR]:Ti,[g.VIZ]:qx,[g.GENERATOR]:Pi,[g.SECTION_FLAG]:Pi,[g.IMAGE]:Ai,[g.NAV]:Li,[g.RELATED]:_i,[g.RESET_BUTTON]:Mi,[g.COMPARISON_BUTTON]:Ni,[g.TABLE]:Di,[g.BUTTON]:Vi,[g.MULTIHIERARCHY_SELECTOR]:$i};});var Yd=v(()=>{c();ye();({[g.TITLE]:IconHeading,[g.GENERATOR]:IconApi,[g.SECTION_FLAG]:IconFlag,[g.STAT]:IconPercentage,[g.VIZ]:IconChartBar,[g.PARAGRAPH]:IconAlignLeft,[g.SELECTOR]:IconSelector,[g.IMAGE]:IconPhoto,[g.TABLE]:IconTable,[g.MULTIHIERARCHY_SELECTOR]:IconListTree});});var Xd=v(()=>{c();ye();({[g.TITLE]:"Title",[g.GENERATOR]:"Data",[g.STAT]:"Stat",[g.VIZ]:"Visualization",[g.PARAGRAPH]:"Paragraph",[g.SELECTOR]:"Selector",[g.SUBTITLE]:"Subtitle",[g.RESET_BUTTON]:"Reset Button",[g.COMPARISON_BUTTON]:"Comparison Button",[g.RELATED]:"Related Reports",[g.NAV]:"Navigation",[g.IMAGE]:"Image",[g.TABLE]:"Table",[g.BUTTON]:"Button",[g.FALLBACK]:"Fallback",[g.SECTION_FLAG]:"Section Flag",[g.MULTIHIERARCHY_SELECTOR]:"Multihierarchy Selector"});});var rR,Gi,Qd=v(()=>{c();ye();nd();Kd();Yd();Xd();rR={[g.GENERATOR]:{type:g.GENERATOR,renderer:Fe[g.GENERATOR],renderPreviewOnEdit:!1},[g.SECTION_FLAG]:{type:g.SECTION_FLAG,renderer:Fe[g.SECTION_FLAG],renderPreviewOnEdit:!1},[g.IMAGE]:{type:g.IMAGE,renderer:Fe[g.IMAGE],renderPreviewOnEdit:!1},[g.PARAGRAPH]:{type:g.PARAGRAPH,renderer:Fe[g.PARAGRAPH],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.RELATED]:{type:g.RELATED,renderer:Fe[g.RELATED],renderPreviewOnEdit:!1,evalWhenNonActive:!1},[g.SELECTOR]:{type:g.SELECTOR,renderer:Fe[g.SELECTOR],adapter:rn[g.SELECTOR],nonActiveAdapter:()=>rn[g.SELECTOR]({name:"Selector Preview"}),renderPreviewOnEdit:!1},[g.STAT]:{type:g.STAT,renderer:Fe[g.STAT],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.SUBTITLE]:{type:g.SUBTITLE,renderer:Fe[g.SUBTITLE],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.TITLE]:{type:g.TITLE,renderer:Fe[g.TITLE],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.VIZ]:{type:g.VIZ,renderer:Fe[g.VIZ],renderPreviewOnEdit:!1},[g.NAV]:{type:g.NAV,renderer:Fe[g.NAV],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.RESET_BUTTON]:{type:g.RESET_BUTTON,renderer:Fe[g.RESET_BUTTON],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.COMPARISON_BUTTON]:{type:g.COMPARISON_BUTTON,renderer:Fe[g.COMPARISON_BUTTON],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.TABLE]:{type:g.TABLE,renderer:Fe[g.TABLE],renderPreviewOnEdit:!1,evalWhenNonActive:!1},[g.BUTTON]:{type:g.BUTTON,renderer:Fe[g.BUTTON],renderPreviewOnEdit:!0,evalWhenNonActive:!0},[g.MULTIHIERARCHY_SELECTOR]:{type:g.MULTIHIERARCHY_SELECTOR,renderer:Fe[g.MULTIHIERARCHY_SELECTOR],adapter:rn[g.MULTIHIERARCHY_SELECTOR],nonActiveAdapter:()=>rn[g.MULTIHIERARCHY_SELECTOR]({label:"Multihierarchy Selector Preview"}),renderPreviewOnEdit:!1}},Gi=rR;});function sa({blockId:e,active:t=!0,asComparison:r=!1}){let{query:o,locale:n=dt}=useRouter(),a=Ke(),s=ft(e).data,i=oo(e,r&&a.active?a?.variables.variables:void 0,r&&a.active?a?.variables.attributes:void 0),l=Oe(s,n),u=Pt(n),p={variables:i,query:o,locale:n},d=X(w=>w.variables.variables[s.id]||{}),m=X(w=>w.variables.status[s.id]||{}),[b,f]=useState(()=>{if(![g.GENERATOR,g.VIZ,g.NAV].includes(s.type)){if(s?.type===g.SELECTOR){let A=Oe(s,n),{config:k}=Kr(s.id,A?.logic,u,p);return {...k,id:s.id,section:s.section_id}}if(s?.type===g.MULTIHIERARCHY_SELECTOR){let A=Oe(s,n),{config:k}=Yr(s.id,A.logic,u,p);return {...k,id:s.id,section:s.section_id}}let w=Vt(l?.logic,u,p),{vars:I}=rt("variables",i,w,u,void 0,p);return I}return null});useEffect(()=>{(async()=>{if(!s||s.type===g.GENERATOR)return;if(s.type===g.VIZ){f({block:s,locale:n,variables:i,active:t});return}if(!t&&!Gi[s.type].evalWhenNonActive){let{nonActiveAdapter:k}=Gi[s.type],N=k&&typeof k=="function"?k():{};f(N);return}if(s.type===g.GENERATOR){f({outputVariables:d});return}if(g.SELECTOR===s.type){let k=Oe(s,n),{config:N}=Kr(s.id,k.logic,u,p);f({...N,id:s.id,section:s.section_id});return}if(g.MULTIHIERARCHY_SELECTOR===s.type){let k=Oe(s,n),{config:N}=Yr(s.id,k.logic,u,p);f({...N,id:s.id,section:s.section_id});return}if(s.type===g.NAV){let k=Oe(s,n).simple;f({id:s.id,headings:s.inputs,type:k?.type,section:s.section_id,settings:s.settings});return}if(s.type===g.RELATED){let{related_reports:k}=d;f({related_reports:k});return}if(s.type===g.RESET_BUTTON){f({id:s.id,...l.simple});return}if(s.type===g.COMPARISON_BUTTON){f({id:s.id,...l.simple});return}if(s.type===g.FALLBACK){f({id:s.id,type:s.original_type,roles:s.settings.access});return}let I=Vt(l?.logic,u,p),{vars:A}=rt("variables",i,I,u,void 0,p);if(s.type===g.TABLE){f({sectionId:s.section_id,...A});return}f(A);})();},[l,i]);let y=m.allowed||s?.type===g.NAV;if(!s||!b||!y)return null;let h=Qp[s.type];return jsx("div",{id:`bespoke-${s.type}-${s.id}`,className:`cms-block-wrapper bespoke-block-area cms-block-${e}`,children:jsx(h,{...b,settings:s.settings,asComparison:r})})}var Jd=v(()=>{c();ye();Zp();Qd();br();Se();bn();Wr();kn();Fa();Va();Wt();});var em,sR,tm,ia,la=v(()=>{c();em={margin:{label:"Content Margin",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},columnGutter:{label:"Column Gutter",defaultValue:"md",options:[{label:"None",value:"0px"},{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}]},width:{label:"Width",defaultValue:"full",options:[{label:"Full Width",value:"full"},{label:"Center",value:"center"}]},position:{label:"Position",defaultValue:"normal",options:[{label:"Normal",value:"normal"},{label:"Sticky",value:"sticky"}]},style:{label:"Style",defaultValue:"none",options:[{label:"None",value:"none"},{label:"Card",value:"card"}]}},sR=Object.keys(em).reduce((e,t)=>(e[t]=em[t].defaultValue,e),{}),tm={memberImageBg:!1,optionsMenu:!1,optionData:!0,optionImage:!0,optionShare:!0,showAnchor:!1,...sR},ia=e=>({data:typeof e.optionData=="boolean"?e.optionData:!0,image:typeof e.optionImage=="boolean"?e.optionImage:!0,share:typeof e.optionShare=="boolean"?e.optionShare:!0});});function rm({previews:e}){let t=e.map((r,o)=>({key:r?`bg-${r.content_id}`:`bg-${o}`,src:r?`/api/cms/member/image?member=${r.content_id}&size=splash`:""}));return jsxs(Fragment,{children:[jsx(Group,{className:"cms-section-bg",grow:!0,spacing:0,style:{position:"absolute",width:"100%",height:"100%"},children:t.map(r=>jsx("div",{className:"cms-section-member-bg",style:{backgroundImage:`url(${r.src})`,backgroundSize:"cover",backgroundPosition:"center center",height:"100%",width:"100%"}},r.key))}),jsx("div",{className:"cms-section-gradient-bg",style:{background:"white",position:"absolute",width:"100%",height:"100%",opacity:.33}})]})}var om=v(()=>{c();});function nm({data:e}){let o=(e&&Array.isArray(e)&&e[0]?Object.keys(e[0]):[]).filter(n=>!n.startsWith("_")).map(n=>({accessorKey:n,header:n,enableSorting:!0,mantineTableBodyCellProps:{sx:{textWrap:"wrap"}}}));return jsx(MantineReactTable,{columns:o,data:e,enableBottomToolbar:!1,enableColumnActions:!1,enablePagination:!1,enableSorting:!0,enableTopToolbar:!1,initialState:{density:"xs"},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:100,maxHeight:350}}})}var am=v(()=>{c();});function xo(e){let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},r=`(?:${Object.keys(t).join("|")})`,o=RegExp(r),n=RegExp(r,"g"),a=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return o.test(a)?a.replace(n,s=>t[s]):a}var qi=v(()=>{c();});function ji(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var sm=v(()=>{c();});function mR(e){return e?dR(ji(xo(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:!0,strict:!0,trim:!0}):""}var Xt,ln=v(()=>{c();qi();sm();Xt=mR;});function pm(e){let{section:t}=e,r=Ot(),o=useRouter(),n=X(M=>M.status.isCMS),a=X(M=>M.status.currentLocale),s=o.locale,i=n?a:s,l=50,u=Pt(i),p=Ie("options"),d={...Qi,...p.data_tab},[m,b]=useState([]),[f,y]=useState([]),[h,w]=useState(),[I,A]=useState(),[k,N]=useState(!1),[z,E]=useState({}),[F,C]=useState(!0),[R,x]=useState(!0),{sectionVariables:L,setSectionVariables:D,resetSectionVariables:O}=Ae(t.id),P=t.blocks||[],j=X(M=>M),K=useMemo(()=>P.reduce((M,_)=>{let te=j.records.entities.block[_],U=j.variables.variables[_],J=j.variables.status[_];return (g.GENERATOR===te.type&&U._downloadEnabled===!0&&J.allowed||g.VIZ===te.type&&J.allowed)&&(M[_]={entity:te,variables:j.variables.variables[_],status:j.variables.status[_],inputVariablesFlat:te.inputs.reduce((Q,ie)=>({...Q,...j.variables.variables[ie]}),j.variables.attributes)}),M},{}),[P]),q=M=>{y(_=>_.includes(M)?_:[..._,M]);},ee=M=>{b(_=>(_.find(U=>U.ix===M.ix)?_:[..._,M]).sort((U,J)=>U.ix>J.ix?1:-1));};function oe(M){!h&&M[0]&&ce(M[0]);}function ce(M){w(M),A("0");}useEffect(()=>{let M=async(_,te,U)=>{let J=dataLoad.bind({});return new Promise((Q,ie)=>{J(te,null,null,(le,ct)=>{if(le)ie(le);else {let fe=U instanceof Function?U(ct):ct;_.data.unshift(fe),ee(_),Q(ct);}});})};if(m.length===0&&f.length===0){let _=0;for(let te of Object.values(K)){let U=te.entity;if([g.GENERATOR,g.SECTION_FLAG].includes(U.type)){let J=te.variables._downloadData||te.variables._downloadUrl||te.status.api;if(J){let Q=[];typeof J=="string"?Q=J.split(Sn):Q=[J];let ie=te.variables._downloadTitle||`${d.data_source} ${_+1}`,le=te.variables._downloadFileName||ie;ee({ix:_,id:U.id,title:xo(ie),fileName:le,data:Array.isArray(Q)?Q:[Q],loading:!1,type:g.GENERATOR}),q(_),_++;}}else if(U.type===g.VIZ){let J=Oe(U),Q=te.inputVariablesFlat,ie={variables:Q},le=ot({logic:J.logic},u,ie).logic,ct={router:o,section:{variables:L,setVariables:D,resetVariables:O}},fe=ir(le,u,Q,i,U.id,{},ct),ut=fe.config._downloadTitle||fe.config.title||`${d.viz_source} ${_+1}`,Dt=fe.config._downloadFileName||ut;if(fe.config._downloadEnabled!==!1)try{let He=fe.config._downloadUrl||fe.config.data,Eo=typeof He=="string"?[He]:He,ko=fe.dataFormat instanceof Function?fe.dataFormat:!1,mr=fe.config._downloadDataFormat instanceof Function?fe.config._downloadDataFormat:!1;M({ix:_,id:U.id,title:xo(ut),fileName:Dt,data:Eo,loading:!1,type:g.VIZ},He,mr||ko),q(_),_++;}catch(He){console.error("DataLoad catch",He);}}}x(!1);}},[K]),useEffect(()=>{m.length===f.length&&oe(m);},[m]),useEffect(()=>{if(h&&I){let M=parseInt(I,10);if(h.data[M]&&(!z[h.ix]||!z[h.ix][I])){C(!0);let _=h.data[I];typeof _=="string"?Ga(_,r,i).then(te=>{let U=BR(te);E({...z,[h.ix]:{...z[h.ix],[M]:U}});}).catch(te=>{console.error(te);}).finally(()=>{C(!1);}):(E({...z,[h.ix]:{...z[h.ix],[M]:_}}),C(!1));}}},[I,h]);let G=(M,_)=>{let te=M===_?"":`-${M}`.toLowerCase();if(h){let U=h.data.length>1&&I?`-${parseInt(I,10)+1}`:"";return `${Xt(h.fileName)}${te}${U}.${_.toLowerCase()}`}return `${te}.${_}`},Y=async M=>{if(h){N(!0);let _=new SR,te=G(M,M);try{switch(M){case ua.json.extension:_.file(te,JSON.stringify(H));break;case ua.csv.extension:_.file(te,csvFormat(H));break;case ua.xlsx.extension:let{utils:U,write:J}=await import('xlsx'),Q=U.book_new();U.book_append_sheet(Q,U.json_to_sheet(H),te.substring(0,30));let ie=J(Q,{bookType:"xlsx",bookSST:!0,type:"binary"});_.file(te,ie,{binary:!0});break;default:break}_.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(U=>{N(!1),saveAs(U,G(M,"zip"));});}catch(U){console.error(d.error_generating,U),N(!1);}}},H=useMemo(()=>h&&z[h.ix]&&z[h.ix][I]?z[h.ix][I]:[],[z,h,I]),$=useMemo(()=>m&&m.length>0&&m.length===f.length&&m.map((M,_)=>jsx(Button,{leftIcon:jsx(IconDatabase,{size:16}),onClick:()=>ce(M),variant:h?.ix===_?"filled":"default",loading:M.loading,disabled:M.loading,children:M.title},`source-${M.id}-${_}`)),[m,h,f]);return jsxs(Stack,{className:"cms-section-options-data",children:[jsx(Space,{h:"xs"}),jsx(LoadingOverlay,{visible:R,overlayBlur:2}),m.length===0&&!R&&jsxs(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:[d.no_data_src," awa"]}),m.length>1&&m.length===f.length&&!R&&jsx(Input.Wrapper,{label:`${d.choose_data_src}:`,children:jsx(Group,{spacing:"xs",children:$})}),h&&I&&jsx(Stack,{spacing:"xs",children:jsx(Input.Wrapper,{label:`${d.preview}
61
61
  ${H.length>l?d.rows_preview.replace("{nrows}",l):""}:`,children:jsxs(Group,{spacing:"xs",children:[jsx(Select,{disabled:!(h.data.length>1),style:{flex:"1"},value:I,onChange:M=>A(M),data:h.data.map((M,_)=>({value:`${_}`,group:typeof M=="string"?d.raw_group:d.formatted_group,label:typeof M=="string"?M:d.formatted_src.replace("{src}",h.title)})),icon:typeof h.data[I]=="string"?jsx(IconLink,{}):jsx(IconSparkles,{})}),jsx(CopyButton,{value:typeof h.data[I]=="string"?h.data[I]:"",timeout:2e3,children:({copied:M,copy:_})=>jsx(Tooltip,{label:M?d.copied:d.copy,withArrow:!0,position:"top",children:jsx(ActionIcon,{variant:M?"filled":"subtle",onClick:_,disabled:typeof h.data[I]!="string",children:M?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})]})})}),h&&!F&&H.length===0&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:d.error_preview}),h&&I&&!F&&H.length===0&&jsx("a",{href:h.data[I],target:"_blank",rel:"noreferrer",children:jsx(Button,{leftIcon:jsx(IconExternalLink,{size:16}),fullWidth:!0,children:d.open_in_window.replace("{src}",h.title)})}),jsxs(Stack,{pos:"relative",mih:"430px",children:[jsx(LoadingOverlay,{visible:F&&m.length>0,overlayBlur:2}),h&&!F&&H.length>0&&jsxs(Fragment,{children:[jsx(Box,{h:"350px",children:jsx(nm,{data:H.slice(0,l)})}),jsx(Input.Wrapper,{label:`${d.download}:`,children:jsx(Button.Group,{children:Object.values(ua).map(M=>jsx(Button,{leftIcon:jsx(M.icon,{size:24}),onClick:()=>Y(M.extension),loading:k,fullWidth:!0,children:M.extension},`format-${M.extension}`))})})]})]})]})}var ua,Qi,BR,Zi=v(()=>{c();he();am();ye();Jo();ln();qi();br();Se();hr();Sr();po();za();gt();ua={csv:{extension:"CSV",icon:IconFileTypeCsv},json:{extension:"JSON",icon:IconFileTypeJs},xlsx:{extension:"XLSX",icon:IconFileTypeXls}},Qi={data_source:"Data Source",no_data_src:"No data sources defined",viz_source:"Visualization Source",error_generating:"Error generating file.",choose_data_src:"Choose data source",original_src:"Original {src}",loading:"Loading...",error_preview:`Sorry. We could not generate the data preview as a table.
62
- Try to open the source and check the data directly.`,open_in_window:"Open {src} response in a new window",formatted_src:"Formatted {src}",formatted_group:"Formatted Data",raw_group:"Raw Data",rows_preview:"(First {nrows} rows as preview)",choose_format:"Choose format",processing_file:"Processing file...",download:"Download data as",preview:"Preview",copy:"Click to copy",copied:"Copied!"},BR=e=>{let t=[];return e&&e.data&&(e.data&&Array.isArray(e.data)?t=e.data:e.data&&e.data.data&&Array.isArray(e.data.data)?t=e.data.data:e.data&&e.data.data&&e.data.data.results&&Array.isArray(e.data.data.results)?t=e.data.data.results:e.data&&e.data.results&&Array.isArray(e.data.results)&&(t=e.data.results)),t};});function gm(e){let{section:t}=e,r=t.blocks||[],o=X(U=>r.map(J=>U.records.entities.block[J]).filter(J=>J.type===g.VIZ&&U.variables.status[J.id].allowed)),{variant_slug1:n,slug1:a}=X(U=>U.variables.attributes),s=xp(),[i,l]=useState(vt.section),[u,p]=useState(St.png),[d,m]=useState(!1),[b,f]=useState(!1),[y,h]=useState([]),[w,I]=useState(o.length>0?o[0].id:null),A=i!==vt.section,{print:k,downloadLoading:N,error:z}=Tp(t.id,n,a,A?w:null),[E,F]=useState(!0),[C,R]=useState(!1),x=Ie("options"),L={...eE,...x.image_tab},{siteProps:D}=Ar(),O=D?.logoSrc&&typeof D.logoSrc=="string",P=t?.settings?.name||`section-${t.id}`,j=`#${P}`,K=useMantineTheme(),q=()=>{let U=ce(w);return select(U).select("svg").size()===1},ee=()=>`${Xt(P)}`,oe=()=>{let U=document.getElementById(P);return select(U).select(".bespoke-section-content").node()},ce=U=>{let J=oe();return select(J).select(`#bespoke-visualization-${U}.bespoke-block-area`).node()},G=()=>new Promise(U=>{let J;i===vt.section?J=oe():i===vt.viz&&(J=ce(w));let Q=document.createElement("div");Q.style.display="flex",Q.style.justifyContent="space-between",Q.classList.add("bespoke-Viz-source"),Q.style.padding=K.spacing.xs,Q.style.width="100%";let ie=document.createElement("div");if(ie.innerText=L.source.replace("{src}",`${window.location}${j}`),ie.style.fontSize=K.fontSizes.xs,Q.appendChild(ie),O){let le=document.createElement("img");le.src=D.logoSrc,le.style.height="30px",le.onload=()=>U(J),le.onerror=()=>{le.remove(),U(J);},Q.appendChild(le),J.appendChild(Q);}else J.appendChild(Q),U(J);}),Y=U=>{if(E)return "transparent";let J=select(U).style("background-color");return J!=="rgba(0, 0, 0, 0)"&&J!=="transparent"?J:U===document.body?"white":Y(U.parentNode)},H=async(U,J)=>{let{toPng:Q}=await import('html-to-image');Q(U,{backgroundColor:J.background,cacheBust:!0,filter:ie=>ie&&ie.classList?!J.exclusionClasses.some(le=>ie.classList.contains(le)):!0}).then(ie=>{let le=document.createElement("a");le.download=`${J.filename}.png`,le.href=ie,le.click(),JR(),m(!1);}).catch(ie=>{console.log(ie);});},$=(U,J)=>{saveElement(U,{filename:J.filename,type:"svg",callback:()=>m(!1)},{background:J.background});},M=async()=>{m(!0);let U=await G(),J={background:Y(U),exclusionClasses:["export-hidden"],filename:ee()},Q=u===St.png?H:$;try{if(U)Q(U,J);else throw new Error(L.wrong_node)}catch{m(!1);}},_=async()=>{let{toCanvas:U}=await import('html-to-image');Promise.all(o.map(J=>{let Q=ce(J.id),ie=Q.querySelector("g.d3plus-geomap-tileGroup");return ie.style.display="none",U(Q).then(le=>(ie.style.display="block",le))})).then(J=>{h(J.map(Q=>Q.toDataURL())),R(!1);});};useEffect(()=>{i===vt.viz&&o.length>0?(I(o[0].id),R(!0),_()):i===vt.section&&h([]);},[i]),useEffect(()=>{w&&(q()?f(!0):(f(!1),p(St.png)));},[w]);useRouter();return jsxs(Stack,{className:"cms-section-options-image",children:[jsx(Space,{h:"xs"}),o.length>0?jsx(Input.Wrapper,{label:`${L.choose_area}:`,children:jsx(SegmentedControl,{fullWidth:!0,value:i,data:[{value:vt.section,label:jsxs(Center,{children:[jsx(IconTemplate,{size:"1rem"}),jsx(Box,{ml:10,children:L.entire_section})]})},{value:vt.viz,label:jsxs(Center,{children:[jsx(IconChartBar,{size:"1rem"}),jsx(Box,{ml:10,children:L.viz_only})]})}],onChange:U=>{l(U),U===vt.section&&p(St.png);}})}):jsx(Text,{fw:"700",color:"gray.7",children:`${L.entire_section}:`}),i===vt.viz&&o.length>0&&jsxs(Input.Wrapper,{label:`${L.choose_viz}:`,style:{minHeight:"161px",position:"relative"},children:[!C&&y.length>0&&jsx(ScrollArea,{style:{height:250},children:jsx(SimpleGrid,{cols:3,children:o.map((U,J)=>jsx(Image,{alt:`Viz ${U.id}`,onClick:()=>{I(U.id);},style:{cursor:"pointer",border:w===U.id?"4px solid #228be6":"4px solid #eee"},radius:0,src:y[J],withPlaceholder:!0},`viz-option-${U.id}`))})}),jsx(LoadingOverlay,{visible:C})]}),b&&i!==vt.section&&jsx(Input.Wrapper,{label:`${L.choose_format}:`,children:jsxs(Button.Group,{children:[jsx(Button,{leftIcon:jsx(IconPolaroid,{size:16}),onClick:()=>p(St.png),variant:u===St.png?"filled":"default",fullWidth:!0,children:St.png}),jsx(Button,{leftIcon:jsx(IconCode,{size:16}),onClick:()=>p(St.svg),variant:u===St.svg?"filled":"default",fullWidth:!0,children:St.svg})]})}),jsx(Checkbox,{checked:E,label:`${L.transparent_bg}`,onChange:()=>F(!E),radius:"xl"}),jsx(Button,{leftIcon:jsx(IconDownload,{size:16}),loading:d||N,onClick:s&&u!==St.svg?()=>k(E):M,fullWidth:!0,children:jsx("span",{children:d||N?L.processing:L.download.replace("{imageFormat}",u)})})]})}var vt,St,JR,eE,hm=v(()=>{c();ln();he();gt();Ut();ea();ye();vt={viz:"viz",section:"section"},St={png:"PNG",svg:"SVG"},JR=()=>{let e=document.getElementsByClassName("bespoke-Viz-source");Array.from(e).forEach(t=>t.remove());},eE={wrong_node:"Wrong node in export",choose_area:"Choose image area",choose_viz:"Choose visualization",choose_format:"Choose format",transparent_bg:"Transparent background",processing:"Processing image...",download:"Download {imageFormat}",entire_section:"Entire section",viz_only:"Visualization only",source:"Source: {src}"};});function bm(e){let{title:t,url:r,disabled:o=!1}=e,n=o?IconCode:IconLink;return jsx(Input.Wrapper,{label:t,children:jsx(Input,{icon:jsx(n,{}),value:r,disabled:o,readOnly:!0,rightSection:jsx(CopyButton,{value:r,timeout:2e3,children:({copied:a,copy:s})=>jsx(Tooltip,{label:a?"Copied":"Copy",withArrow:!0,position:"right",children:jsx(ActionIcon,{variant:a?"filled":"subtle",onClick:s,disabled:o,children:a?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})})})}var vm=v(()=>{c();});function Tm(e){let{section:t}=e,[r,o]=useState(""),[n,a]=useState(""),[s,i]=useState(!0),l=Ie("options"),u={...PE,...l.share_tab};return useEffect(()=>{a(document.title);let{origin:p,pathname:d}=window.location,m=`${p}${d}`,b=s?t.settings?.name?.length?`#${Xt(t.settings.name)}`:`#section-${t.id}`:"";o(`${m}${b}`);},[s]),jsxs(Stack,{className:"cms-section-options-share",children:[jsx(Space,{h:"xs"}),jsx(bm,{title:`${u.title}: ${n}`,url:r}),jsx(Checkbox,{checked:s,label:u.include_section,onChange:()=>i(!s),radius:"xl"}),jsxs(Group,{position:"center",children:[jsx(FacebookShareButton,{url:r,quote:n,children:jsx(FacebookIcon,{size:32,round:!0})}),jsx(TwitterShareButton,{url:r,title:n,children:jsx(TwitterIcon,{size:32,round:!0})}),jsx(TelegramShareButton,{url:r,title:n,children:jsx(TelegramIcon,{size:32,round:!0})}),jsx(WhatsappShareButton,{url:r,title:n,separator:":: ",children:jsx(WhatsappIcon,{size:32,round:!0})}),jsx(LinkedinShareButton,{url:r,children:jsx(LinkedinIcon,{size:32,round:!0})}),jsx(RedditShareButton,{url:r,title:n,windowWidth:660,windowHeight:460,children:jsx(RedditIcon,{size:32,round:!0})}),jsx(EmailShareButton,{url:r,subject:n,children:jsx(EmailIcon,{size:32,round:!0})})]})]})}var PE,xm=v(()=>{c();vm();gt();ln();PE={title:"Title",include_section:"Include Section"};});function km(e){let{section:t,initialMode:r,onEnds:o,open:n,title:a}=e,s=ia(t.settings),i=useMemo(()=>LE.filter(b=>s[b]),[s]),[l,u]=useState(r||i[0]||"data"),p=Ie("options");useEffect(()=>{r!==l&&u(r);},[r]);let d={...tl,...p},m=useMemo(()=>jsxs(Fragment,{children:[jsxs(Tabs.List,{children:[s.data&&jsx(Tabs.Tab,{value:"data",children:d.download_title}),s.image&&jsx(Tabs.Tab,{value:"image",children:d.image_title}),s.share&&jsx(Tabs.Tab,{value:"share",children:d.share_title})]}),s.data&&jsx(Tabs.Panel,{value:"data",children:jsx(pm,{section:t})}),s.image&&jsx(Tabs.Panel,{value:"image",children:jsx(gm,{section:t})}),s.share&&jsx(Tabs.Panel,{value:"share",children:jsx(Tm,{section:t})})]}),[s,t,d]);return jsx("div",{className:"cms-section-options-modal",children:n&&jsx(Modal,{className:"bespoke-options-modal",opened:!0,onClose:()=>o(),size:"xl",title:a,children:jsx(Tabs,{onTabChange:u,value:l,keepMounted:!1,children:m})})})}var tl,LE,Cm=v(()=>{c();Zi();hm();xm();gt();la();tl={download_title:"Download Data",image_title:"Save Image",share_title:"Share Link"},LE=["data","image","share"];});function wm(e){let{sectionId:t,disabled:r=!1}=e,[o,n]=useState(!1),[a,s]=useState("data"),i=Mn(t),l=Ie("options"),u={...tl,...l},p=ia(i.isSuccess?i.data.settings:{}),d=b=>{s(b),n(!0);},m=()=>{n(!1);};return jsxs("div",{className:"cms-section-options",children:[jsxs(Button.Group,{children:[p.data&&jsx(Button,{variant:"default",size:"xs",compact:!0,onClick:()=>d("data"),"aria-label":u.download_title,disabled:r,children:jsx(IconTable,{size:16})}),p.image&&jsx(Button,{variant:"default",size:"xs",compact:!0,onClick:()=>d("image"),"aria-label":u.image_title,disabled:r,children:jsx(IconCamera,{size:16})}),p.share&&jsx(Button,{variant:"default",size:"xs",compact:!0,onClick:()=>d("share"),"aria-label":u.share_title,disabled:r,children:jsx(IconShare,{size:16})})]}),i.isSuccess&&jsx(km,{section:i.data,initialMode:a,open:o,onEnds:m})]})}var Im=v(()=>{c();Cm();he();gt();la();});function FE({children:e,containerProps:t},r){return jsx(Flex,{ref:r,className:"bespoke-section-content",pos:"relative",align:"stretch",p:0,direction:{base:"column",md:"row"},wrap:"wrap",...t,children:e})}var fa,_m,Mm=v(()=>{c();he();Xs();fa=Kt__default.forwardRef(function({children:t,column:r,basis:o,columnSettings:n={},sx:a={},...s},i){let l=Object.values(r).some(m=>m.settings?.display==="inline"),u=n?.width?`${n.width}px`:o,p=n?.width?`${n?.width}px`:"100%",d=n?.full?"100%":p;return jsx(Flex,{ref:i,className:"bespoke-section-col",align:"flex-start",direction:l?"row":"column",wrap:l?"wrap":"nowrap",maw:{base:"100%",md:d},miw:{base:"none",md:300},p:0,pos:"relative",sx:[{flexGrow:1,flexShrink:n?.full?0:1,flexBasis:n?.full?"100%":u},...packSx(a)],...s,children:t})}),_m=Kt__default.forwardRef(FE);});var Nm=v(()=>{c();});var pn,Fm=v(()=>{c();ze();he();Nm();ye();pn={px:e=>Number.isNaN(parseFloat(e))?"px":`${e}px`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),"%":e=>Number.isNaN(parseFloat(e))?"%":`${e}%`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")},{px:{defaultValue:400,min:25,step:5,formatter:pn.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:pn["%"]}};});var rl,Dm=v(()=>{c();rl={backgroundColor:"#fafafa",block:{padding:10},column:{padding:12},section:{backgroundColor:"white",borderRadius:10,boxShadow:"0px 6px 10px rgba(12, 32, 50, 0.14), 0px 1px 15px rgba(12, 32, 50, 0.12), 0px 3px 5px rgba(12, 32, 50, 0.15)",margin:8,padding:32}};});function nl({previews:e,translations:t}){let{print:r}=$e(),o=useMemo(()=>e.map(({image:n,name:a},s)=>(n?.author||n?.url)&&jsxs(Stack,{spacing:0,children:[n.author&&jsxs(Text,{size:"xs",children:[a," ",t.image_by," ",jsx("strong",{children:n.author})]}),n.url&&jsxs(Text,{size:"xs",children:["URL: "," ",jsx(Anchor,{href:n.url,target:"_blank",children:n.url})]}),s+1<e.length&&jsx(Divider,{})]},n.id)),[e]);return jsx(Fragment,{children:r?jsx(Fragment,{children:o}):jsxs(Popover,{position:"right",children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"light",radius:"xl",children:jsx(IconPhoto,{size:20})})}),jsx(Popover.Dropdown,{children:o})]})})}var $m=v(()=>{c();jt();});function Um(){let{locales:e}=useRouter(),t=location&&location.pathname.split("/").filter(r=>r.length>0)[0];return e?.includes(t)}var Gm=v(()=>{c();});function ZE({name:e,children:t,id:r,sectionSettings:o,sectionStyles:n,previews:a,translations:s}){let{print:i}=$e(),l=o.memberImageBg&&a.some(({image:p})=>p&&(p.url||p.author)),u=useMemo(()=>o.showAnchor&&o.optionsMenu?"apart":!o.showAnchor&&o.optionsMenu?"right":o.showAnchor&&!o.optionsMenu?"left":"right",[o.showAnchor,o.optionsMenu]);return jsxs(YE,{className:`bespoke-Section-${r} bespoke-Section-root `,settings:o,styles:n?.root||void 0,print:i,children:[o.memberImageBg&&jsx(rm,{previews:a}),jsxs(XE,{className:`bespoke-Section-${r} bespoke-Section-container `,settings:o,styles:n?.container,id:e?.length?Xt(e):`section-${r}`,pos:"relative",children:[!i&&jsxs(Group,{position:u,mb:"xs",children:[o.showAnchor&&jsxs(Anchor,{className:"cms-section-anchor",href:`#${o.name?Xt(o.name):"section-"+r}`,sx:{"&:hover .cms-section-name":{visibility:"visible",opacity:1}},children:[jsx(Text,{span:!0,size:"small",children:"#"}),jsx(Text,{span:!0,size:"small",className:"cms-section-name",sx:{visibility:"hidden",opacity:0,transition:"visibility 0s, opacity 0.2s ease-in-out"},children:o.name||"section-"+r})]}),o.optionsMenu&&jsx(wm,{sectionId:r,disabled:!1})]}),jsxs(QE,{print:i,className:`bespoke-Section-${r} bespoke-Section-container`,settings:o,styles:n?.content,children:[t,l&&jsx(nl,{previews:a,translations:s})]})]})]})}function ek({section:e,sectionLoader:t}){let{isEmbed:r}=$e(),{id:o,settings:n}=e,a={...tm,...n},s=Ke(),i=X(E=>E),l=X(E=>E.variables.status),{previews:u,isRunConsumersRunning:p}=X(E=>E.status),d=s.active&&s.status?u.concat(s.status?.previews||[]):u,m=et().Section,b=At(i),f=Object.values(b||{}).filter(E=>E.section_id===o),y=Ie("sections"),h={...KE,...y},w=f.some(E=>{try{return l[E.id].allowed&&![g.GENERATOR,g.SECTION_FLAG].includes(E.type)||E.type===g.NAV}catch{return E.settings.allowed==="always"}}),I=f.filter(E=>![g.GENERATOR,g.SECTION_FLAG].includes(E.type)).reduce((E,F)=>(E[F.blockcol]?E[F.blockcol][F.blockrow]=F:E[F.blockcol]={[F.blockrow]:F},E),{}),A=Object.keys(f).length>0&&!n.hidden&&w,k=Object.keys(I).length;if(!A||s.active&&n.comparisonHide)return null;let N=(E,F=!1)=>{let C=Array.from(new Set(E.map(x=>x.blockcol))).map(x=>({blockcol:x})).sort((x,L)=>Xe(x,L,"blockcol")),R=[];return C.forEach(({blockcol:x})=>{let L=E.filter(D=>D.blockcol===x).sort((D,O)=>Xe(D,O,"blockrow")).map(D=>{if(!D.id||!l[D.id]?.allowed&&D.type!==g.NAV)return null;let{settings:O,type:P}=b[D.id],j=O.width&&!O.width.stretch&&O.width.unit?pn[O.width.unit](O.width.value):O.display==="inline"?"auto":"100%",K={alignSelf:P===g.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:j,minWidth:300};return jsx(Box,{className:"bespoke-Block-wrapper",id:`bespoke-Block-${D.id}`,sx:K,py:rl.block.padding,children:jsx(sa,{blockId:D.id,asComparison:F},D.id)},D.id)});R.push(L);}),R.flat()},z=[];if(s.active&&!n.comparisonMerge){let E=f.filter(F=>![g.GENERATOR,g.SECTION_FLAG].includes(F.type)).reduce((F,C)=>({...F,[C.id]:C}),{});z=[jsx(fa,{column:E,basis:"50%",children:N(Object.values(f.filter(F=>![g.GENERATOR,g.SECTION_FLAG].includes(F.type))))},"original"),jsx(fa,{column:E,basis:"50%",children:N(Object.values(f.filter(F=>![g.GENERATOR,g.SECTION_FLAG].includes(F.type))),!0)},"comparison")];}else z=Object.keys(I).sort((E,F)=>-Aa(E,F)).map(E=>{let F=I[E],C=n.columnSettings?n.columnSettings[E]:{},R=Object.values(F).sort((x,L)=>Xe(x,L,"blockrow"));return R.some(x=>!l[x.id]||l[x.id].allowed||x.type===g.NAV)?jsx(fa,{column:F,columnSettings:C,basis:`calc(${100/k}% - (10px * ${k}))`,children:R.map(x=>{if(!x.id||!l[x.id]?.allowed&&x.type!==g.NAV)return null;let{settings:L,type:D}=b[x.id],O=L.width&&!L.width.stretch&&L.width.unit?pn[L.width.unit](L.width.value):L.display==="inline"?"auto":"100%",P={alignSelf:D===g.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:O,minWidth:300};return jsx(Box,{className:`bespoke-Block-wrapper bespoke-${x.type}-wrapper`,id:`bespoke-Block-${x.id}`,sx:P,py:rl.block.padding,children:jsx(sa,{blockId:x.id},x.id)},x.id)})},E):null});return jsxs(ZE,{id:o,name:e?.settings?.name,previews:d,sectionSettings:a,sectionStyles:m,translations:h,children:[p.includes(o)&&t,jsx(_m,{containerProps:{gap:a.columnGutter||"md",wrap:s.active?"nowrap":"wrap",sx:{zIndex:20}},children:z}),r&&jsx(JE,{})]})}var KE,al,YE,XE,QE,JE,Ym,Xm=v(()=>{c();he();or();Jd();la();zr();om();Im();Or();ye();Mm();Fm();Dm();jt();gt();$m();Wt();ln();Ut();Gm();KE={image_by:"image by"},al=(e,t)=>r=>e?e(r,t):{},YE=({settings:e,styles:t,print:r,children:o,...n})=>{let{position:a,shouldBreak:s}=e,i={normal:{position:"relative",backgroundColor:r?"transparent":"initial",borderRadius:0},sticky:{position:"sticky",zIndex:2,top:0,borderRadius:0,borderTop:r?"none":"initial",borderLeft:r?"none":"initial",borderRight:r?"none":"initial"}},l={normal:{radius:0},sticky:{radius:0,withBorder:!0}},u=[i[a],al(t,e),s?{pageBreakBefore:"always"}:{}];return jsx(Paper,{component:"section",sx:u,...l[a],...n,children:o})},XE=({settings:e,styles:t,children:r,...o})=>{let{width:n}=e,a={center:{zIndex:1},full:{zIndex:1}},s={center:{size:"lg",p:"sm",fluid:!1},full:{fluid:!0,p:"md"}},i=[a[n],al(t,e)];return jsx(Container,{sx:i,...s[n],...o,children:r})},QE=({settings:e,styles:t,print:r,children:o,...n})=>{let{style:a}=e,s={none:{},card:{boxShadow:r?"none":"initial"}},i={none:{bg:"transparent"},card:{shadow:r?"none":"lg",p:"md",radius:"md"}},l=[s[a],al(t,e)];return jsx(Paper,{sx:l,...i[a],...n,"data-screenshot-target":"true",children:o})};JE=()=>{let e=useRouter(),{query:t,locale:r}=e,{siteProps:o={logoSrc:""},profilePrefix:n,pathSegment:a}=Ar(),s=t[a],i=Array.isArray(s)?s.join("/"):[],u=Um()?`/${r}`:"";u+=`${n}/${i}/`;let p=new URL(u,window.location.href).href;return jsxs(Group,{position:"apart",noWrap:!0,sx:{flexGrow:1},children:[jsx(Anchor,{href:p,target:"_blank",children:p}),jsx("img",{src:o.logoSrc,height:40,width:"auto",alt:"Site Logo"})]})};Ym=ek;});var Qm=v(()=>{c();ae();W({name:"abbreviate",description:"Abbreviates a number into a smaller more human-readable number.",logicFactory(e){return t=>e.d3plus.formatAbbreviate(t)},inputType:"number",testValue:"123456",type:"formatter"});});var Zm=v(()=>{c();ae();W({name:"abs",description:"Simple Absolute Value.",logicFactory(e){return t=>Math.abs(t)},inputType:"number",testValue:"-123",type:"formatter"});});var ok,Jm=v(()=>{c();ae();ok=()=>function(t){let o=new RegExp(/([\$0-9\,]+)[A-z\-\s\&]*([\$0-9\,]*)/g).exec(t);return o?(o=o.slice(1).filter(n=>n.length).map(n=>(n.includes(",")&&(n.indexOf(",")===n.length-4?n=n.replace(/,000$/g,"k").replace(/([0-9]+)(,999$)/g,a=>`${parseInt(a)+1}k`):n.indexOf(",")===n.length-8&&(n=n.replace(/,000,000$/g,"M").replace(/([0-9]+)(,999,999$)/g,a=>`${parseInt(a)+1}M`))),n)),o.length===2?o.join(" - "):t.toLowerCase().match(/under|less|\</g)?`< ${o[0]}`:t.toLowerCase().match(/over|more|\+|\>/g)?`${o[0]}+`:`${o[0]}`):"None"},W({name:"bucket",description:"Sanitizes bucket strings to '< n', 'n1 - n2', and 'n+'",logicFactory:ok,inputType:"number",testValue:"1234",type:"formatter"});});var ef=v(()=>{c();ae();W({name:"commas",description:"* Rounds to nearest whole number and adds commas.",logicFactory(e){return t=>e.d3.format(",")(Math.round(t))},inputType:"number",testValue:"1234.6",type:"formatter"});});var tf=v(()=>{c();ae();W({name:"date",description:"Formats a date into '%B %d, %Y' format.",logicFactory(e){return t=>(typeof t=="string"&&(t=e.d3plus.date(t)),e.d3.timeFormat("%B %d, %Y")(t))},inputType:"date",testValue:"2022-01-01",type:"formatter"});});var rf=v(()=>{c();ae();W({name:"dollar",description:"Adds a US dollar sign to the beginning of a String or Number.",logicFactory(e){return t=>(typeof t=="number"&&(t=e.d3plus.formatAbbreviate(t)),t.charAt(0)==="-"?t.replace("-","-$"):`$${t}`)},inputType:"number",testValue:"123",type:"formatter"});});var of=v(()=>{c();ae();W({name:"formatFieldName",description:"Based on field name returns a string",logicFactory(e){return t=>{if(t.contentType.toLowerCase()==="stat"){if(t.field==="title")return "Stat label";if(t.field==="value")return "Stat value";if(t.field==="subtitle")return "Stat subtitle";if(t.field==="tooltip")return "Tooltip text"}return t.contentType.toLowerCase()==="section"&&t.field==="short"?"Short title":t.contentType.toLowerCase()==="description"&&t.field==="description"?"Paragraph":t.field}},inputType:"object",testValue:'{"field":"title","contentType":"stat"}',type:"formatter"});});var nf=v(()=>{c();ae();W({name:"grewTo",description:"Returns the text with grow direction: 'declined from', 'grew to' o 'stayed at'",logicFactory(e){return t=>t<0?"declined from":t>0?"grew to":"stayed at"},inputType:"number",testValue:"-1234",type:"formatter"});});var af=v(()=>{c();ae();W({name:"grewWord",description:"Returns either 'grew', 'declined', or 'stayed' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"declined":t>0?"grew":"stayed"},inputType:"number",testValue:"-1234",type:"formatter"});});var sf=v(()=>{c();ae();W({name:"growing",description:"Returns either 'declining', 'growing' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"declining":"growing"},inputType:"number",testValue:"-1234",type:"formatter"});});var dk,lf=v(()=>{c();ae();dk=()=>function(t){let{curr:r,currMoe:o=0,prev:n,prevMoe:a=0}=t,s;if(o||a){let i=(-n/r**2)**2*o**2,l=(1/r)**2*a**2;s=Math.sqrt(i+l);}else s=(r-n)/n;return s*100},W({name:"growth",description:"Calculates the growth percentage between two numbers provided the following object format: {curr, prev}. Also supports calculating the growth between two margin of errors using this format: {curr, currMoe, prev, prevMoe}",logicFactory:dk,inputType:"object",testValue:'{"curr":10,"currMoe":0,"prev":13,"prevMoe":0}',type:"formatter"});});var cf=v(()=>{c();ae();W({name:"growthPct",description:"Abbreviates a growth value, turns it absolute, and adds a percent sign.",logicFactory(e){return t=>`${e.d3plus.formatAbbreviate(Math.abs(t))}%`},inputType:"number",testValue:"12345",type:"formatter"});});var uf=v(()=>{c();ae();W({name:"growthWord",description:"Returns either 'growth' or 'decline' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decline":"growth"},inputType:"number",testValue:"-1234",type:"formatter"});});var pf=v(()=>{c();ae();W({name:"highWord",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"lower than":t>0?"higher than":"approximately the same as"},inputType:"number",testValue:"0",type:"formatter"});});var df=v(()=>{c();ae();W({name:"increaseWord",description:"Returns either 'increase', 'decrease', or 'change' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decrease":t>0?"increase":"change"},inputType:"number",testValue:"1234",type:"formatter"});});var mf=v(()=>{c();ae();W({name:"increasedWord",description:"Returns either 'increased', 'decreased', or 'remained the same' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decreased":t>0?"increased":"remained the same"},inputType:"number",testValue:"0",type:"formatter"});});var ff=v(()=>{c();ae();W({name:"increasing",description:"Returns either 'decreasing', 'increasing' or 'maintaining' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decreasing":t>0?"increasing":"maintaining"},inputType:"number",testValue:"-1234",type:"formatter"});});var gf=v(()=>{c();ae();W({name:"largerThan",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign",logicFactory(e){return t=>t<0?"smaller than":t>0?"larger than":"the same as"},inputType:"number",testValue:"-1234",type:"formatter"});});var hf=v(()=>{c();ae();W({name:"list",description:"Joins an array of strings together, adding commas and 'and' when necessary.",logicFactory(e){return t=>t.reduce((r,o,n)=>(n?n===t.length-1&&n===1?r+=` and ${o}`:n===t.length-1?r+=`, and ${o}`:r+=`, ${o}`:r+=o,r),"")},inputType:"object",testValue:'["foo","bar","bee"]',type:"formatter"});});var yf=v(()=>{c();ae();W({name:"longWord",description:"",logicFactory(e){return t=>t<0?"shorter":t>0?"longer":"similar"},inputType:"number",testValue:"5",type:"formatter"});});var bf=v(()=>{c();ae();W({name:"lowerCaseFirst",description:"Converts the first letter of a string to lowercase",logicFactory(e){return t=>typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t},inputType:"string",testValue:"foo",type:"formatter"});});var vf=v(()=>{c();ae();W({name:"moreFewerWord",description:"",logicFactory(e){return t=>t<0?"fewer":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var Sf=v(()=>{c();ae();W({name:"moreLess",description:"Returns either 'more' or 'less' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"less":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var Tf=v(()=>{c();ae();W({name:"moreLess",description:"Returns either 'more than', 'less than', or 'approximately the same' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"less than":t>0?"more than":"approximately the same"},inputType:"number",testValue:"-5",type:"formatter"});});var xf=v(()=>{c();ae();W({name:"olderWord",description:"",logicFactory(e){return t=>t<0?"getting younger":t>0?"getting older":"staying the same age"},inputType:"number",testValue:"-5",type:"formatter"});});var Rf=v(()=>{c();ae();W({name:"olderYounger",description:"",logicFactory(e){return t=>t<0?"younger than":t>0?"older than":"the same age as"},inputType:"number",testValue:"-5",type:"formatter"});});var Ef=v(()=>{c();ae();W({name:"plural",description:"Pluralizes a word.",logicFactory(e){return t=>t.replace(/\w$/g,r=>r==="y"?"ies":`${r}s`)},inputType:"string",testValue:"Foo",type:"formatter"});});var kf=v(()=>{c();ae();W({name:"pxToInt",description:"Takes a pixel value and converts it to an integer",logicFactory(e){return t=>parseInt(t.replace(/\D+/g,""),10)},inputType:"string",testValue:"12px",type:"formatter"});});var Cf=v(()=>{c();ae();W({name:"salary",description:"Displays salary values with proper precision (ie. '$74,200' instead of '$74.2k')",logicFactory(e){return t=>{let r;return t<1e6?r=e.d3.format(",")(t.toFixed(0)):r=e.d3plus.formatAbbreviate(t),`$${r}`}},inputType:"number",testValue:"1000000",type:"formatter"});});var Pf=v(()=>{c();ae();W({name:"stripEntities",description:"Removes non breaking spaces & other html entities from a string",logicFactory(e){return t=>typeof t=="string"?String(t).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):t},inputType:"string",testValue:"<b>MyText</b>",type:"formatter"});});var sl,Af=v(()=>{c();ae();sl=W({name:"stripHTML",description:"Converts html tags to spaces, then removes redundant spaces",logicFactory(e){return t=>{let r={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(r).join("|")})`,n=RegExp(o),a=RegExp(o,"g"),s=String(t).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return n.test(s)?s.replace(a,i=>r[i]):s}},inputType:"string",testValue:"<b>My text</b>",type:"formatter"});});var wf=v(()=>{c();ae();W({name:"stripOL",description:"Removes ordered list wrapper tags from a string.",logicFactory(e){return t=>t.replace(/<ol>/g,"").replace(/<\/ol>/g,"")},inputType:"string",testValue:"<ol><li>My list</li></ol>",type:"formatter"});});var If=v(()=>{c();ae();W({name:"stripP",description:"Removes all paragraph tags from a string.",logicFactory(e){return t=>t.replace(/<p>/g,"").replace(/<\/p>/g,"")},inputType:"string",testValue:"<p>My p</p>",type:"formatter"});});var Lf=v(()=>{c();ae();W({name:"stripUL",description:"Removes unordered list wrapper tags from a string.",logicFactory(e){return t=>t.replace(/<ul>/g,"").replace(/<\/ul>/g,"")},inputType:"string",testValue:"<ul><li>My list</li></ul>",type:"formatter"});});var Of=v(()=>{c();ae();W({name:"toKebabCase",description:"Takes a camelCase or PascalCase string and converts it to kebab-case.",logicFactory(e){return t=>typeof t=="string"?(t=t.charAt(0).toLowerCase()+t.substring(1),t.replace(/([A-Z])/g,"-$1").toLowerCase()):"invalid string passed to toKebabCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var _f=v(()=>{c();ae();W({name:"toSpacedCase",description:"Takes a camelCase or PascalCase string and adds spaces (I know Spaced Case isn't a thing, deal with it).",logicFactory(e){return t=>typeof t=="string"?t.replace(/([A-Z])/g," $1").toLowerCase().trim():"invalid string passed to toSpacedCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var Bf=v(()=>{c();ae();W({name:"upperCaseFirst",description:"Converts the first letter of a string to uppercase",logicFactory(e){return t=>t.charAt(0).toUpperCase()+t.slice(1)},inputType:"string",testValue:"my name",type:"formatter"});});var Mf=v(()=>{c();Qm();Zm();Jm();ef();tf();rf();of();nf();af();sf();lf();cf();uf();pf();df();mf();ff();gf();hf();yf();bf();vf();Sf();Tf();xf();Rf();Ef();kf();Cf();Pf();Af();wf();If();Lf();Of();_f();Bf();});function Vf({onDownloadPDF:e,onDownloadCSV:t}){let[r,o]=useState(!1),[n,a]=useState(!1),[s,i]=useState(!1),l=useMediaQuery("(max-width: 768px)"),u=Ie("export"),p={...jk,...u},d=async()=>{if(e){o(!0);try{await e();}finally{o(!1),i(!1);}}},m=async()=>{if(t){a(!0);try{await t();}finally{a(!1),i(!1);}}},b=(h,w,I,A,k,N)=>jsx(Button,{id:N,size:"sm",onClick:h,disabled:w,fullWidth:!0,variant:"subtle",h:"auto",px:"xs",w:"100%",styles:z=>({inner:{width:"100%",display:"block"}}),children:jsxs(Group,{noWrap:!0,position:"left",spacing:"xs",w:"100%",children:[w?jsx(Loader,{size:"1.75rem"}):I,jsxs(Stack,{spacing:0,w:"100%",py:"0.5rem",className:"bespoke-report-download-btn-text-container",children:[jsx(Text,{w:"100%",size:"sm",lineClamp:1,className:"bespoke-report-download-btn-text-container-cta",children:A}),k&&jsx(Text,{size:"xs",w:"100%",lineClamp:2,maw:"100%",style:{wordWrap:"break-word",whiteSpace:"normal"},variant:"dimmed",lh:"0.9rem",h:"1.9rem",className:"bespoke-report-download-btn-text-desc",children:k})]})]})}),f=e&&b(d,r,jsx(IconFileTypePdf,{size:"1.75rem"}),p.pdf.label,p.pdf.desc,"bespoke-download-pdf-btn"),y=t&&b(m,n,jsx(IconFileTypeXls,{size:"1.75rem"}),p.xlsx.label,p.xlsx.desc,"bespoke-download-xlsx-btn");return e||t?jsx(Affix,{position:{bottom:l?rem(0):rem(20),right:l?rem(0):rem(20)},id:"bespoke-report-download-affix",style:{width:l?"100%":"auto",boxShadow:l?"0px -2px 6px rgba(0, 0, 0, 0.1)":"0px 2px 6px rgba(0, 0, 0, 0.1)",borderRadius:"0.25rem",background:"white"},p:"xs",children:jsxs(Popover,{opened:s,onChange:i,position:"top",shadow:"md",width:l?"100%":250,id:"bespoke-report-download-popover",children:[jsx(Popover.Target,{children:jsx(Button,{id:"bespoke-report-download-btn",size:"sm",onClick:()=>i(h=>!h),leftIcon:jsx(IconDownload,{size:"1.2rem"}),variant:"subtle",loading:r||n,fullWidth:l,children:p.export})}),jsx(Popover.Dropdown,{p:"0.5rem",children:jsxs(Stack,{spacing:"xs",children:[f,y]})})]})}):null}var jk,zf=v(()=>{"use client";c();gt();jk={export:"Export",pdf:{label:"Download PDF",desc:"Generates a printable version of the report page in PDF format."},xlsx:{label:"Download XLSX",desc:"Creates a downloadable spreadsheet of the report page data."}};});function Xk(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o)&255;return t}function $f(e){return `data_export_${new Date().toISOString()}`}var Yk,Qk,Uf,Gf=v(()=>{c();Yk=e=>new Promise((t,r)=>{let o="xlsx";if(!e||e.length===0){r(new Error("No data provided"));return}try{let n=Ro.utils.book_new();e.forEach((l,u)=>{if(l.data&&l.data.length>0){let p=l.data[0],d=Ro.utils.json_to_sheet(p),m=(l.fileName||`Sheet${u+1}`).slice(0,31),b=1;for(;n.SheetNames.includes(m);){let f=` (${b})`;m=`${m.slice(0,31-f.length)}${f}`,b++;}Ro.utils.book_append_sheet(n,d,m);}});let a=Ro.write(n,{bookType:"xlsx",type:"binary"}),s=new Blob([Xk(a)],{type:"application/octet-stream"}),i=new SR;i.file(`${$f(o)}.xlsx`,s),i.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(l=>{t(l);}).catch(r);}catch(n){r(n);}});Qk=async e=>{try{let t=await Yk(e);saveAs(t,`${$f("xlsx")}.zip`);}catch(t){console.error("Error generating file:",t);}},Uf=Qk;});function $e(){let e=useContext(Wf);if(e===void 0)throw new Error("usePrint must be used within a PrintContext");return e}function iC(e){return useMemo(()=>e.data.reduce((r,o)=>(o.blocks&&o.blocks.forEach(n=>{r[n]=o.id;}),r),{}),[e.data])}function lC({pathSegmentsKey:e="bespoke",sectionLoader:t,mode:r}){let{asPath:o,query:n}=useRouter(),a=zo(),s=Ke(),i=Xo(),l=wg(n.print)??!1,u=r==="embed",{printReport:p,error:d,setError:m}=Jn();Yn();let b=qf.locale,f=Pt(b),y=useMemo(()=>a.data.flatMap(R=>R.blocks||[]),[a.data]),h=iC({data:a.data||[]}),{sectionsVariables:w,resetSectionVariables:I,setSectionVariables:A}=Ac(a.data?.map(R=>R.id)||[]),k=X(R=>R),N=Ie("options"),z={...Qi,...N.data_tab},E=useMemo(()=>y.reduce((R,x)=>{let L=k.records.entities.block[x],D=k.variables.status[x];return g.VIZ===L?.type&&D.allowed&&R.push({id:x,entity:L,variables:k.variables.variables[x],status:k.variables.status[x],inputVariablesFlat:L.inputs.reduce((O,P)=>({...O,...k.variables.variables[P]}),k.variables.attributes)}),R},[]),[y,k.records.entities.block,k.variables.attributes,k.variables.status,k.variables.variables]),F=async(R,x,L)=>{let D=dataLoad.bind({});return new Promise((O,P)=>{D(x,null,null,(j,K)=>{if(j)P(j);else try{R||(R={data:[]}),Array.isArray(R.data)||(R.data=[]);let q=L instanceof Function?L(K):K;R.data.unshift(q),R.rawData=K,O(R);}catch(q){P(q);}});})},C=async()=>{if(!i.XlsxVizActive)return;let R=[],x=[],L=0;for(let P of E){let j=P.entity,K=Oe(j),q=P.inputVariablesFlat,ee={variables:q},oe=ot({logic:K.logic},f,ee).logic,ce={router:qf,section:{variables:w[h[j.id]],setVariables:A(w[h[j.id]]),resetVariables:I(w[h[j.id]])}},G=ir(oe,f,q,b,j.id,{},ce),Y=G.config._downloadTitle||G.config.title||`${z.viz_source} ${L+1}`,H=G.config._downloadFileName||Y;if(G.config._downloadEnabled!==!1){let $=G.config._downloadUrl||G.config.data;if(!$){console.error("API is undefined for block:",j.id);continue}let M=typeof $=="string"?[$]:$,_=G.dataFormat instanceof Function?G.dataFormat:!1,te=G.config._downloadDataFormat instanceof Function?G.config._downloadDataFormat:!1;try{let U=await F({ix:L,id:j.id,title:sl(Y),fileName:H,data:M,loading:!1,type:g.VIZ},$,te||_),J="Section A",Q="Source XYZ";x.push({"File Name":`${J} ${H}`,source:Q}),R.push(U),L++;}catch(U){console.error(`Error loading data for block ${j.id}:`,U);}}}let D=R,O={fileName:"Metadata",data:x};return D.unshift(O)};return jsxs(Wf.Provider,{value:{print:l,isEmbed:u},children:[jsxs(Container,{id:"bespoke-report",className:s.comparisonLoaded?"compare":"",p:0,pos:"relative",fluid:!0,children:[a.isSuccess&&a.data.sort(Xe).map(R=>jsx(Ym,{section:R,sectionLoader:t},R.id)),cC({pdf:i,print:l,printReport:p,downloadCSV:Uf,isPosition:Qn,handleLoadData:C})]}),d&&jsx(Affix,{position:{bottom:rem(80),right:rem(20)},children:jsx(Notification,{title:"Error",color:"red",onClose:()=>m(null),icon:jsx(IconX,{size:"1.1rem"}),children:d})})]})}function cC({pdf:e,print:t,printReport:r,downloadCSV:o,isPosition:n,handleLoadData:a}){return t||!n(e.position,"DEFAULT")?null:e.active||e.XlsxVizActive?jsx(Vf,{onDownloadPDF:e.active?r:void 0,onDownloadCSV:e.XlsxVizActive?async()=>{let s=await a();s&&s.length>0?await o(s):console.error("No data loaded for CSV download");}:void 0}):null}var Wf,Kf,jt=v(()=>{c();he();zr();Xm();Wt();Xn();js();ea();Js();ye();br();hr();Se();Jo();Mf();gt();zf();Gf();Zi();Wf=createContext({print:!1,isEmbed:!1});Kf=lC;});c();c();Ut();jt();Ks();gt();Wt();Xn();co();function pC({pathSegmentsKey:e="bespoke",translations:t,bespokeStyles:r,buildTime:o,siteProps:n,profilePrefix:a="/defaultPath",loader:s=jsx(LoadingOverlay,{visible:!0}),sectionLoader:i=jsx(LoadingOverlay,{visible:!0}),mantineProviderProps:l={},mode:u}){return Kn(e)?jsx(Fragment,{children:s}):jsx(MantineProvider,{...l,theme:{other:{bespokeStyles:r}},inherit:!0,children:jsxs(Mc,{pathSegment:"bespoke",profilePrefix:a,siteProps:n,children:[jsx(Ts,{translations:t,children:jsx(Ls,{children:jsx(Ys,{children:jsx(eu,{pageSize:12,children:jsx(Kf,{sectionLoader:i||s,mode:u})})})})}),jsx("small",{className:"bespoke-timestamp",children:o})]})})}/*! Bundled license information:
62
+ Try to open the source and check the data directly.`,open_in_window:"Open {src} response in a new window",formatted_src:"Formatted {src}",formatted_group:"Formatted Data",raw_group:"Raw Data",rows_preview:"(First {nrows} rows as preview)",choose_format:"Choose format",processing_file:"Processing file...",download:"Download data as",preview:"Preview",copy:"Click to copy",copied:"Copied!"},BR=e=>{let t=[];return e&&e.data&&(e.data&&Array.isArray(e.data)?t=e.data:e.data&&e.data.data&&Array.isArray(e.data.data)?t=e.data.data:e.data&&e.data.data&&e.data.data.results&&Array.isArray(e.data.data.results)?t=e.data.data.results:e.data&&e.data.results&&Array.isArray(e.data.results)&&(t=e.data.results)),t};});function gm(e){let{section:t}=e,r=t.blocks||[],o=X(U=>r.map(J=>U.records.entities.block[J]).filter(J=>J.type===g.VIZ&&U.variables.status[J.id].allowed)),{variant_slug1:n,slug1:a}=X(U=>U.variables.attributes),s=xp(),[i,l]=useState(vt.section),[u,p]=useState(St.png),[d,m]=useState(!1),[b,f]=useState(!1),[y,h]=useState([]),[w,I]=useState(o.length>0?o[0].id:null),A=i!==vt.section,{print:k,downloadLoading:N,error:z}=Tp(t.id,n,a,A?w:null),[E,F]=useState(!0),[C,R]=useState(!1),x=Ie("options"),L={...eE,...x.image_tab},{siteProps:D}=Ar(),O=D?.logoSrc&&typeof D.logoSrc=="string",P=t?.settings?.name||`section-${t.id}`,j=`#${P}`,K=useMantineTheme(),q=()=>{let U=ce(w);return select(U).select("svg").size()===1},ee=()=>`${Xt(P)}`,oe=()=>{let U=document.getElementById(P);return select(U).select(".bespoke-section-content").node()},ce=U=>{let J=oe();return select(J).select(`#bespoke-visualization-${U}.bespoke-block-area`).node()},G=()=>new Promise(U=>{let J;i===vt.section?J=oe():i===vt.viz&&(J=ce(w));let Q=document.createElement("div");Q.style.display="flex",Q.style.justifyContent="space-between",Q.classList.add("bespoke-Viz-source"),Q.style.padding=K.spacing.xs,Q.style.width="100%";let ie=document.createElement("div");if(ie.innerText=L.source.replace("{src}",`${window.location}${j}`),ie.style.fontSize=K.fontSizes.xs,Q.appendChild(ie),O){let le=document.createElement("img");le.src=D.logoSrc,le.style.height="30px",le.onload=()=>U(J),le.onerror=()=>{le.remove(),U(J);},Q.appendChild(le),J.appendChild(Q);}else J.appendChild(Q),U(J);}),Y=U=>{if(E)return "transparent";let J=select(U).style("background-color");return J!=="rgba(0, 0, 0, 0)"&&J!=="transparent"?J:U===document.body?"white":Y(U.parentNode)},H=async(U,J)=>{let{toPng:Q}=await import('html-to-image');Q(U,{backgroundColor:J.background,cacheBust:!0,filter:ie=>ie&&ie.classList?!J.exclusionClasses.some(le=>ie.classList.contains(le)):!0}).then(ie=>{let le=document.createElement("a");le.download=`${J.filename}.png`,le.href=ie,le.click(),JR(),m(!1);}).catch(ie=>{console.log(ie);});},$=(U,J)=>{saveElement(U,{filename:J.filename,type:"svg",callback:()=>m(!1)},{background:J.background});},M=async()=>{m(!0);let U=await G(),J={background:Y(U),exclusionClasses:["export-hidden"],filename:ee()},Q=u===St.png?H:$;try{if(U)Q(U,J);else throw new Error(L.wrong_node)}catch{m(!1);}},_=async()=>{let{toCanvas:U}=await import('html-to-image');Promise.all(o.map(J=>{let Q=ce(J.id),ie=Q.querySelector("g.d3plus-geomap-tileGroup");return ie.style.display="none",U(Q).then(le=>(ie.style.display="block",le))})).then(J=>{h(J.map(Q=>Q.toDataURL())),R(!1);});};useEffect(()=>{i===vt.viz&&o.length>0?(I(o[0].id),R(!0),_()):i===vt.section&&h([]);},[i]),useEffect(()=>{w&&(q()?f(!0):(f(!1),p(St.png)));},[w]);useRouter();return jsxs(Stack,{className:"cms-section-options-image",children:[jsx(Space,{h:"xs"}),o.length>0?jsx(Input.Wrapper,{label:`${L.choose_area}:`,children:jsx(SegmentedControl,{fullWidth:!0,value:i,data:[{value:vt.section,label:jsxs(Center,{children:[jsx(IconTemplate,{size:"1rem"}),jsx(Box,{ml:10,children:L.entire_section})]})},{value:vt.viz,label:jsxs(Center,{children:[jsx(IconChartBar,{size:"1rem"}),jsx(Box,{ml:10,children:L.viz_only})]})}],onChange:U=>{l(U),U===vt.section&&p(St.png);}})}):jsx(Text,{fw:"700",color:"gray.7",children:`${L.entire_section}:`}),i===vt.viz&&o.length>0&&jsxs(Input.Wrapper,{label:`${L.choose_viz}:`,style:{minHeight:"161px",position:"relative"},children:[!C&&y.length>0&&jsx(ScrollArea,{style:{height:250},children:jsx(SimpleGrid,{cols:3,children:o.map((U,J)=>jsx(Image,{alt:`Viz ${U.id}`,onClick:()=>{I(U.id);},style:{cursor:"pointer",border:w===U.id?"4px solid #228be6":"4px solid #eee"},radius:0,src:y[J],withPlaceholder:!0},`viz-option-${U.id}`))})}),jsx(LoadingOverlay,{visible:C})]}),b&&i!==vt.section&&jsx(Input.Wrapper,{label:`${L.choose_format}:`,children:jsxs(Button.Group,{children:[jsx(Button,{leftIcon:jsx(IconPolaroid,{size:16}),onClick:()=>p(St.png),variant:u===St.png?"filled":"default",fullWidth:!0,children:St.png}),jsx(Button,{leftIcon:jsx(IconCode,{size:16}),onClick:()=>p(St.svg),variant:u===St.svg?"filled":"default",fullWidth:!0,children:St.svg})]})}),jsx(Checkbox,{checked:E,label:`${L.transparent_bg}`,onChange:()=>F(!E),radius:"xl"}),jsx(Button,{leftIcon:jsx(IconDownload,{size:16}),loading:d||N,onClick:s&&u!==St.svg?()=>k(E):M,fullWidth:!0,children:jsx("span",{children:d||N?L.processing:L.download.replace("{imageFormat}",u)})})]})}var vt,St,JR,eE,hm=v(()=>{c();ln();he();gt();Ut();ea();ye();vt={viz:"viz",section:"section"},St={png:"PNG",svg:"SVG"},JR=()=>{let e=document.getElementsByClassName("bespoke-Viz-source");Array.from(e).forEach(t=>t.remove());},eE={wrong_node:"Wrong node in export",choose_area:"Choose image area",choose_viz:"Choose visualization",choose_format:"Choose format",transparent_bg:"Transparent background",processing:"Processing image...",download:"Download {imageFormat}",entire_section:"Entire section",viz_only:"Visualization only",source:"Source: {src}"};});function bm(e){let{title:t,url:r,disabled:o=!1}=e,n=o?IconCode:IconLink;return jsx(Input.Wrapper,{label:t,children:jsx(Input,{icon:jsx(n,{}),value:r,disabled:o,readOnly:!0,rightSection:jsx(CopyButton,{value:r,timeout:2e3,children:({copied:a,copy:s})=>jsx(Tooltip,{label:a?"Copied":"Copy",withArrow:!0,position:"right",children:jsx(ActionIcon,{variant:a?"filled":"subtle",onClick:s,disabled:o,children:a?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})})})}var vm=v(()=>{c();});function Tm(e){let{section:t}=e,[r,o]=useState(""),[n,a]=useState(""),[s,i]=useState(!0),l=Ie("options"),u={...PE,...l.share_tab};return useEffect(()=>{a(document.title);let{origin:p,pathname:d}=window.location,m=`${p}${d}`,b=s?t.settings?.name?.length?`#${Xt(t.settings.name)}`:`#section-${t.id}`:"";o(`${m}${b}`);},[s]),jsxs(Stack,{className:"cms-section-options-share",children:[jsx(Space,{h:"xs"}),jsx(bm,{title:`${u.title}: ${n}`,url:r}),jsx(Checkbox,{checked:s,label:u.include_section,onChange:()=>i(!s),radius:"xl"}),jsxs(Group,{position:"center",children:[jsx(FacebookShareButton,{url:r,quote:n,children:jsx(FacebookIcon,{size:32,round:!0})}),jsx(TwitterShareButton,{url:r,title:n,children:jsx(TwitterIcon,{size:32,round:!0})}),jsx(TelegramShareButton,{url:r,title:n,children:jsx(TelegramIcon,{size:32,round:!0})}),jsx(WhatsappShareButton,{url:r,title:n,separator:":: ",children:jsx(WhatsappIcon,{size:32,round:!0})}),jsx(LinkedinShareButton,{url:r,children:jsx(LinkedinIcon,{size:32,round:!0})}),jsx(RedditShareButton,{url:r,title:n,windowWidth:660,windowHeight:460,children:jsx(RedditIcon,{size:32,round:!0})}),jsx(EmailShareButton,{url:r,subject:n,children:jsx(EmailIcon,{size:32,round:!0})})]})]})}var PE,xm=v(()=>{c();vm();gt();ln();PE={title:"Title",include_section:"Include Section"};});function km(e){let{section:t,initialMode:r,onEnds:o,open:n,title:a}=e,s=ia(t.settings),i=useMemo(()=>LE.filter(b=>s[b]),[s]),[l,u]=useState(r||i[0]||"data"),p=Ie("options");useEffect(()=>{r!==l&&u(r);},[r]);let d={...tl,...p},m=useMemo(()=>jsxs(Fragment,{children:[jsxs(Tabs.List,{children:[s.data&&jsx(Tabs.Tab,{value:"data",children:d.download_title}),s.image&&jsx(Tabs.Tab,{value:"image",children:d.image_title}),s.share&&jsx(Tabs.Tab,{value:"share",children:d.share_title})]}),s.data&&jsx(Tabs.Panel,{value:"data",children:jsx(pm,{section:t})}),s.image&&jsx(Tabs.Panel,{value:"image",children:jsx(gm,{section:t})}),s.share&&jsx(Tabs.Panel,{value:"share",children:jsx(Tm,{section:t})})]}),[s,t,d]);return jsx("div",{className:"cms-section-options-modal",children:n&&jsx(Modal,{className:"bespoke-options-modal",opened:!0,onClose:()=>o(),size:"xl",title:a,children:jsx(Tabs,{onTabChange:u,value:l,keepMounted:!1,children:m})})})}var tl,LE,Cm=v(()=>{c();Zi();hm();xm();gt();la();tl={download_title:"Download Data",image_title:"Save Image",share_title:"Share Link"},LE=["data","image","share"];});function wm(e){let{sectionId:t,disabled:r=!1}=e,[o,n]=useState(!1),[a,s]=useState("data"),i=Mn(t),l=Ie("options"),u={...tl,...l},p=ia(i.isSuccess?i.data.settings:{}),d=b=>{s(b),n(!0);},m=()=>{n(!1);};return jsxs("div",{className:"cms-section-options",children:[jsxs(Button.Group,{children:[p.data&&jsx(Button,{variant:"default",size:"xs",compact:!0,onClick:()=>d("data"),"aria-label":u.download_title,disabled:r,children:jsx(IconTable,{size:16})}),p.image&&jsx(Button,{variant:"default",size:"xs",compact:!0,onClick:()=>d("image"),"aria-label":u.image_title,disabled:r,children:jsx(IconCamera,{size:16})}),p.share&&jsx(Button,{variant:"default",size:"xs",compact:!0,onClick:()=>d("share"),"aria-label":u.share_title,disabled:r,children:jsx(IconShare,{size:16})})]}),i.isSuccess&&jsx(km,{section:i.data,initialMode:a,open:o,onEnds:m})]})}var Im=v(()=>{c();Cm();he();gt();la();});function FE({children:e,containerProps:t},r){return jsx(Flex,{ref:r,className:"bespoke-section-content",pos:"relative",align:"stretch",p:0,direction:{base:"column",md:"row"},wrap:"wrap",...t,children:e})}var fa,_m,Mm=v(()=>{c();he();Xs();fa=Kt__default.forwardRef(function({children:t,column:r,basis:o,columnSettings:n={},sx:a={},...s},i){let l=Object.values(r).some(m=>m.settings?.display==="inline"),u=n?.width?`${n.width}px`:o,p=n?.width?`${n?.width}px`:"100%",d=n?.full?"100%":p;return jsx(Flex,{ref:i,className:"bespoke-section-col",align:"flex-start",direction:l?"row":"column",wrap:l?"wrap":"nowrap",maw:{base:"100%",md:d},miw:{base:"none",md:300},p:0,pos:"relative",sx:[{flexGrow:1,flexShrink:n?.full?0:1,flexBasis:n?.full?"100%":u},...packSx(a)],...s,children:t})}),_m=Kt__default.forwardRef(FE);});var Nm=v(()=>{c();});var pn,Fm=v(()=>{c();ze();he();Nm();ye();pn={px:e=>Number.isNaN(parseFloat(e))?"px":`${e}px`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),"%":e=>Number.isNaN(parseFloat(e))?"%":`${e}%`.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")},{px:{defaultValue:400,min:25,step:5,formatter:pn.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:pn["%"]}};});var rl,Dm=v(()=>{c();rl={backgroundColor:"#fafafa",block:{padding:10},column:{padding:12},section:{backgroundColor:"white",borderRadius:10,boxShadow:"0px 6px 10px rgba(12, 32, 50, 0.14), 0px 1px 15px rgba(12, 32, 50, 0.12), 0px 3px 5px rgba(12, 32, 50, 0.15)",margin:8,padding:32}};});function nl({previews:e,translations:t}){let{print:r}=$e(),o=useMemo(()=>e.map(({image:n,name:a},s)=>(n?.author||n?.url)&&jsxs(Stack,{spacing:0,children:[n.author&&jsxs(Text,{size:"xs",children:[a," ",t.image_by," ",jsx("strong",{children:n.author})]}),n.url&&jsxs(Text,{size:"xs",children:["URL: "," ",jsx(Anchor,{href:n.url,target:"_blank",children:n.url})]}),s+1<e.length&&jsx(Divider,{})]},n.id)),[e]);return jsx(Fragment,{children:r?jsx(Fragment,{children:o}):jsxs(Popover,{position:"right",children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"light",radius:"xl",children:jsx(IconPhoto,{size:20})})}),jsx(Popover.Dropdown,{children:o})]})})}var $m=v(()=>{c();jt();});function Um(){let{locales:e}=useRouter(),t=location&&location.pathname.split("/").filter(r=>r.length>0)[0];return e?.includes(t)}var Gm=v(()=>{c();});function ZE({name:e,children:t,id:r,sectionSettings:o,sectionStyles:n,previews:a,translations:s}){let{print:i}=$e(),l=o.memberImageBg&&a.some(({image:p})=>p&&(p.url||p.author)),u=useMemo(()=>o.showAnchor&&o.optionsMenu?"apart":!o.showAnchor&&o.optionsMenu?"right":o.showAnchor&&!o.optionsMenu?"left":"right",[o.showAnchor,o.optionsMenu]);return jsxs(YE,{className:`bespoke-Section-${r} bespoke-Section-root `,settings:o,styles:n?.root||void 0,print:i,children:[o.memberImageBg&&jsx(rm,{previews:a}),jsxs(XE,{className:`bespoke-Section-${r} bespoke-Section-container `,settings:o,styles:n?.container,id:e?.length?Xt(e):`section-${r}`,pos:"relative",children:[!i&&jsxs(Group,{position:u,mb:"xs",children:[o.showAnchor&&jsxs(Anchor,{className:"cms-section-anchor",href:`#${o.name?Xt(o.name):"section-"+r}`,sx:{"&:hover .cms-section-name":{visibility:"visible",opacity:1}},children:[jsx(Text,{span:!0,size:"small",children:"#"}),jsx(Text,{span:!0,size:"small",className:"cms-section-name",sx:{visibility:"hidden",opacity:0,transition:"visibility 0s, opacity 0.2s ease-in-out"},children:o.name||"section-"+r})]}),o.optionsMenu&&jsx(wm,{sectionId:r,disabled:!1})]}),jsxs(QE,{print:i,className:`bespoke-Section-${r} bespoke-Section-container`,settings:o,styles:n?.content,children:[t,l&&jsx(nl,{previews:a,translations:s})]})]})]})}function ek({section:e,sectionLoader:t}){let{isEmbed:r}=$e(),{id:o,settings:n}=e,a={...tm,...n},s=Ke(),i=X(E=>E),l=X(E=>E.variables.status),{previews:u,isRunConsumersRunning:p}=X(E=>E.status),d=s.active&&s.status?u.concat(s.status?.previews||[]):u,m=et().Section,b=At(i),f=Object.values(b||{}).filter(E=>E.section_id===o),y=Ie("sections"),h={...KE,...y},w=f.some(E=>{try{return l[E.id].allowed&&![g.GENERATOR,g.SECTION_FLAG].includes(E.type)||E.type===g.NAV}catch{return E.settings.allowed==="always"}}),I=f.filter(E=>![g.GENERATOR,g.SECTION_FLAG].includes(E.type)).reduce((E,F)=>(E[F.blockcol]?E[F.blockcol][F.blockrow]=F:E[F.blockcol]={[F.blockrow]:F},E),{}),A=Object.keys(f).length>0&&!n.hidden&&w,k=Object.keys(I).length;if(!A||s.active&&n.comparisonHide)return null;let N=(E,F=!1)=>{let C=Array.from(new Set(E.map(x=>x.blockcol))).map(x=>({blockcol:x})).sort((x,L)=>Xe(x,L,"blockcol")),R=[];return C.forEach(({blockcol:x})=>{let L=E.filter(D=>D.blockcol===x).sort((D,O)=>Xe(D,O,"blockrow")).map(D=>{if(!D.id||!l[D.id]?.allowed&&D.type!==g.NAV)return null;let{settings:O,type:P}=b[D.id],j=O.width&&!O.width.stretch&&O.width.unit?pn[O.width.unit](O.width.value):O.display==="inline"?"auto":"100%",K={alignSelf:P===g.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:j,minWidth:300};return jsx(Box,{className:"bespoke-Block-wrapper",id:`bespoke-Block-${D.id}`,sx:K,py:rl.block.padding,children:jsx(sa,{blockId:D.id,asComparison:F},D.id)},D.id)});R.push(L);}),R.flat()},z=[];if(s.active&&!n.comparisonMerge){let E=f.filter(F=>![g.GENERATOR,g.SECTION_FLAG].includes(F.type)).reduce((F,C)=>({...F,[C.id]:C}),{});z=[jsx(fa,{column:E,basis:"50%",children:N(Object.values(f.filter(F=>![g.GENERATOR,g.SECTION_FLAG].includes(F.type))))},"original"),jsx(fa,{column:E,basis:"50%",children:N(Object.values(f.filter(F=>![g.GENERATOR,g.SECTION_FLAG].includes(F.type))),!0)},"comparison")];}else z=Object.keys(I).sort((E,F)=>-Aa(E,F)).map(E=>{let F=I[E],C=n.columnSettings?n.columnSettings[E]:{},R=Object.values(F).sort((x,L)=>Xe(x,L,"blockrow"));return R.some(x=>!l[x.id]||l[x.id].allowed||x.type===g.NAV)?jsx(fa,{column:F,columnSettings:C,basis:`calc(${100/k}% - (10px * ${k}))`,children:R.map(x=>{if(!x.id||!l[x.id]?.allowed&&x.type!==g.NAV)return null;let{settings:L,type:D}=b[x.id],O=L.width&&!L.width.stretch&&L.width.unit?pn[L.width.unit](L.width.value):L.display==="inline"?"auto":"100%",P={alignSelf:D===g.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:O,minWidth:300};return jsx(Box,{className:`bespoke-Block-wrapper bespoke-${x.type}-wrapper`,id:`bespoke-Block-${x.id}`,sx:P,py:rl.block.padding,children:jsx(sa,{blockId:x.id},x.id)},x.id)})},E):null});return jsxs(ZE,{id:o,name:e?.settings?.name,previews:d,sectionSettings:a,sectionStyles:m,translations:h,children:[p.includes(o)&&t,jsx(_m,{containerProps:{gap:a.columnGutter||"md",wrap:s.active?"nowrap":"wrap",sx:{zIndex:20}},children:z}),r&&jsx(JE,{})]})}var KE,al,YE,XE,QE,JE,Ym,Xm=v(()=>{c();he();or();Jd();la();zr();om();Im();Or();ye();Mm();Fm();Dm();jt();gt();$m();Wt();ln();Ut();Gm();KE={image_by:"image by"},al=(e,t)=>r=>e?e(r,t):{},YE=({settings:e,styles:t,print:r,children:o,...n})=>{let{position:a,shouldBreak:s}=e,i={normal:{position:"relative",backgroundColor:r?"transparent":"initial",borderRadius:0},sticky:{position:"sticky",zIndex:2,top:0,borderRadius:0,borderTop:r?"none":"initial",borderLeft:r?"none":"initial",borderRight:r?"none":"initial"}},l={normal:{radius:0},sticky:{radius:0,withBorder:!0}},u=[i[a],al(t,e),s?{pageBreakBefore:"always"}:{}];return jsx(Paper,{component:"section",sx:u,...l[a],...n,children:o})},XE=({settings:e,styles:t,children:r,...o})=>{let{width:n}=e,a={center:{zIndex:1},full:{zIndex:1}},s={center:{size:"lg",p:"sm",fluid:!1},full:{fluid:!0,p:"md"}},i=[a[n],al(t,e)];return jsx(Container,{sx:i,...s[n],...o,children:r})},QE=({settings:e,styles:t,print:r,children:o,...n})=>{let{style:a}=e,s={none:{},card:{boxShadow:r?"none":"initial"}},i={none:{bg:"transparent"},card:{shadow:r?"none":"lg",p:"md",radius:"md"}},l=[s[a],al(t,e)];return jsx(Paper,{sx:l,...i[a],...n,"data-screenshot-target":"true",children:o})};JE=()=>{let e=useRouter(),{query:t,locale:r}=e,{siteProps:o={logoSrc:""},profilePrefix:n,pathSegment:a}=Ar(),s=t[a],i=Array.isArray(s)?s.join("/"):[],u=Um()?`/${r}`:"";u+=`${n}/${i}/`;let p=new URL(u,window.location.href).href;return jsxs(Group,{position:"apart",noWrap:!0,sx:{flexGrow:1},children:[jsx(Anchor,{href:p,target:"_blank",children:p}),jsx("img",{src:o.logoSrc,height:40,width:"auto",alt:"Site Logo"})]})};Ym=ek;});var Qm=v(()=>{c();ae();W({name:"abbreviate",description:"Abbreviates a number into a smaller more human-readable number.",logicFactory(e){return t=>e.d3plus.formatAbbreviate(t)},inputType:"number",testValue:"123456",type:"formatter"});});var Zm=v(()=>{c();ae();W({name:"abs",description:"Simple Absolute Value.",logicFactory(e){return t=>Math.abs(t)},inputType:"number",testValue:"-123",type:"formatter"});});var ok,Jm=v(()=>{c();ae();ok=()=>function(t){let o=new RegExp(/([\$0-9\,]+)[A-z\-\s\&]*([\$0-9\,]*)/g).exec(t);return o?(o=o.slice(1).filter(n=>n.length).map(n=>(n.includes(",")&&(n.indexOf(",")===n.length-4?n=n.replace(/,000$/g,"k").replace(/([0-9]+)(,999$)/g,a=>`${parseInt(a)+1}k`):n.indexOf(",")===n.length-8&&(n=n.replace(/,000,000$/g,"M").replace(/([0-9]+)(,999,999$)/g,a=>`${parseInt(a)+1}M`))),n)),o.length===2?o.join(" - "):t.toLowerCase().match(/under|less|\</g)?`< ${o[0]}`:t.toLowerCase().match(/over|more|\+|\>/g)?`${o[0]}+`:`${o[0]}`):"None"},W({name:"bucket",description:"Sanitizes bucket strings to '< n', 'n1 - n2', and 'n+'",logicFactory:ok,inputType:"number",testValue:"1234",type:"formatter"});});var ef=v(()=>{c();ae();W({name:"commas",description:"* Rounds to nearest whole number and adds commas.",logicFactory(e){return t=>e.d3.format(",")(Math.round(t))},inputType:"number",testValue:"1234.6",type:"formatter"});});var tf=v(()=>{c();ae();W({name:"date",description:"Formats a date into '%B %d, %Y' format.",logicFactory(e){return t=>(typeof t=="string"&&(t=e.d3plus.date(t)),e.d3.timeFormat("%B %d, %Y")(t))},inputType:"date",testValue:"2022-01-01",type:"formatter"});});var rf=v(()=>{c();ae();W({name:"dollar",description:"Adds a US dollar sign to the beginning of a String or Number.",logicFactory(e){return t=>(typeof t=="number"&&(t=e.d3plus.formatAbbreviate(t)),t.charAt(0)==="-"?t.replace("-","-$"):`$${t}`)},inputType:"number",testValue:"123",type:"formatter"});});var of=v(()=>{c();ae();W({name:"formatFieldName",description:"Based on field name returns a string",logicFactory(e){return t=>{if(t.contentType.toLowerCase()==="stat"){if(t.field==="title")return "Stat label";if(t.field==="value")return "Stat value";if(t.field==="subtitle")return "Stat subtitle";if(t.field==="tooltip")return "Tooltip text"}return t.contentType.toLowerCase()==="section"&&t.field==="short"?"Short title":t.contentType.toLowerCase()==="description"&&t.field==="description"?"Paragraph":t.field}},inputType:"object",testValue:'{"field":"title","contentType":"stat"}',type:"formatter"});});var nf=v(()=>{c();ae();W({name:"grewTo",description:"Returns the text with grow direction: 'declined from', 'grew to' o 'stayed at'",logicFactory(e){return t=>t<0?"declined from":t>0?"grew to":"stayed at"},inputType:"number",testValue:"-1234",type:"formatter"});});var af=v(()=>{c();ae();W({name:"grewWord",description:"Returns either 'grew', 'declined', or 'stayed' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"declined":t>0?"grew":"stayed"},inputType:"number",testValue:"-1234",type:"formatter"});});var sf=v(()=>{c();ae();W({name:"growing",description:"Returns either 'declining', 'growing' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"declining":"growing"},inputType:"number",testValue:"-1234",type:"formatter"});});var dk,lf=v(()=>{c();ae();dk=()=>function(t){let{curr:r,currMoe:o=0,prev:n,prevMoe:a=0}=t,s;if(o||a){let i=(-n/r**2)**2*o**2,l=(1/r)**2*a**2;s=Math.sqrt(i+l);}else s=(r-n)/n;return s*100},W({name:"growth",description:"Calculates the growth percentage between two numbers provided the following object format: {curr, prev}. Also supports calculating the growth between two margin of errors using this format: {curr, currMoe, prev, prevMoe}",logicFactory:dk,inputType:"object",testValue:'{"curr":10,"currMoe":0,"prev":13,"prevMoe":0}',type:"formatter"});});var cf=v(()=>{c();ae();W({name:"growthPct",description:"Abbreviates a growth value, turns it absolute, and adds a percent sign.",logicFactory(e){return t=>`${e.d3plus.formatAbbreviate(Math.abs(t))}%`},inputType:"number",testValue:"12345",type:"formatter"});});var uf=v(()=>{c();ae();W({name:"growthWord",description:"Returns either 'growth' or 'decline' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decline":"growth"},inputType:"number",testValue:"-1234",type:"formatter"});});var pf=v(()=>{c();ae();W({name:"highWord",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"lower than":t>0?"higher than":"approximately the same as"},inputType:"number",testValue:"0",type:"formatter"});});var df=v(()=>{c();ae();W({name:"increaseWord",description:"Returns either 'increase', 'decrease', or 'change' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decrease":t>0?"increase":"change"},inputType:"number",testValue:"1234",type:"formatter"});});var mf=v(()=>{c();ae();W({name:"increasedWord",description:"Returns either 'increased', 'decreased', or 'remained the same' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decreased":t>0?"increased":"remained the same"},inputType:"number",testValue:"0",type:"formatter"});});var ff=v(()=>{c();ae();W({name:"increasing",description:"Returns either 'decreasing', 'increasing' or 'maintaining' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"decreasing":t>0?"increasing":"maintaining"},inputType:"number",testValue:"-1234",type:"formatter"});});var gf=v(()=>{c();ae();W({name:"largerThan",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign",logicFactory(e){return t=>t<0?"smaller than":t>0?"larger than":"the same as"},inputType:"number",testValue:"-1234",type:"formatter"});});var hf=v(()=>{c();ae();W({name:"list",description:"Joins an array of strings together, adding commas and 'and' when necessary.",logicFactory(e){return t=>t.reduce((r,o,n)=>(n?n===t.length-1&&n===1?r+=` and ${o}`:n===t.length-1?r+=`, and ${o}`:r+=`, ${o}`:r+=o,r),"")},inputType:"object",testValue:'["foo","bar","bee"]',type:"formatter"});});var yf=v(()=>{c();ae();W({name:"longWord",description:"",logicFactory(e){return t=>t<0?"shorter":t>0?"longer":"similar"},inputType:"number",testValue:"5",type:"formatter"});});var bf=v(()=>{c();ae();W({name:"lowerCaseFirst",description:"Converts the first letter of a string to lowercase",logicFactory(e){return t=>typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t},inputType:"string",testValue:"foo",type:"formatter"});});var vf=v(()=>{c();ae();W({name:"moreFewerWord",description:"",logicFactory(e){return t=>t<0?"fewer":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var Sf=v(()=>{c();ae();W({name:"moreLess",description:"Returns either 'more' or 'less' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"less":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var Tf=v(()=>{c();ae();W({name:"moreLess",description:"Returns either 'more than', 'less than', or 'approximately the same' depending on the provided number's sign.",logicFactory(e){return t=>t<0?"less than":t>0?"more than":"approximately the same"},inputType:"number",testValue:"-5",type:"formatter"});});var xf=v(()=>{c();ae();W({name:"olderWord",description:"",logicFactory(e){return t=>t<0?"getting younger":t>0?"getting older":"staying the same age"},inputType:"number",testValue:"-5",type:"formatter"});});var Rf=v(()=>{c();ae();W({name:"olderYounger",description:"",logicFactory(e){return t=>t<0?"younger than":t>0?"older than":"the same age as"},inputType:"number",testValue:"-5",type:"formatter"});});var Ef=v(()=>{c();ae();W({name:"plural",description:"Pluralizes a word.",logicFactory(e){return t=>t.replace(/\w$/g,r=>r==="y"?"ies":`${r}s`)},inputType:"string",testValue:"Foo",type:"formatter"});});var kf=v(()=>{c();ae();W({name:"pxToInt",description:"Takes a pixel value and converts it to an integer",logicFactory(e){return t=>parseInt(t.replace(/\D+/g,""),10)},inputType:"string",testValue:"12px",type:"formatter"});});var Cf=v(()=>{c();ae();W({name:"salary",description:"Displays salary values with proper precision (ie. '$74,200' instead of '$74.2k')",logicFactory(e){return t=>{let r;return t<1e6?r=e.d3.format(",")(t.toFixed(0)):r=e.d3plus.formatAbbreviate(t),`$${r}`}},inputType:"number",testValue:"1000000",type:"formatter"});});var Pf=v(()=>{c();ae();W({name:"stripEntities",description:"Removes non breaking spaces & other html entities from a string",logicFactory(e){return t=>typeof t=="string"?String(t).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):t},inputType:"string",testValue:"<b>MyText</b>",type:"formatter"});});var sl,Af=v(()=>{c();ae();sl=W({name:"stripHTML",description:"Converts html tags to spaces, then removes redundant spaces",logicFactory(e){return t=>{let r={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(r).join("|")})`,n=RegExp(o),a=RegExp(o,"g"),s=String(t).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return n.test(s)?s.replace(a,i=>r[i]):s}},inputType:"string",testValue:"<b>My text</b>",type:"formatter"});});var wf=v(()=>{c();ae();W({name:"stripOL",description:"Removes ordered list wrapper tags from a string.",logicFactory(e){return t=>t.replace(/<ol>/g,"").replace(/<\/ol>/g,"")},inputType:"string",testValue:"<ol><li>My list</li></ol>",type:"formatter"});});var If=v(()=>{c();ae();W({name:"stripP",description:"Removes all paragraph tags from a string.",logicFactory(e){return t=>t.replace(/<p>/g,"").replace(/<\/p>/g,"")},inputType:"string",testValue:"<p>My p</p>",type:"formatter"});});var Lf=v(()=>{c();ae();W({name:"stripUL",description:"Removes unordered list wrapper tags from a string.",logicFactory(e){return t=>t.replace(/<ul>/g,"").replace(/<\/ul>/g,"")},inputType:"string",testValue:"<ul><li>My list</li></ul>",type:"formatter"});});var Of=v(()=>{c();ae();W({name:"toKebabCase",description:"Takes a camelCase or PascalCase string and converts it to kebab-case.",logicFactory(e){return t=>typeof t=="string"?(t=t.charAt(0).toLowerCase()+t.substring(1),t.replace(/([A-Z])/g,"-$1").toLowerCase()):"invalid string passed to toKebabCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var _f=v(()=>{c();ae();W({name:"toSpacedCase",description:"Takes a camelCase or PascalCase string and adds spaces (I know Spaced Case isn't a thing, deal with it).",logicFactory(e){return t=>typeof t=="string"?t.replace(/([A-Z])/g," $1").toLowerCase().trim():"invalid string passed to toSpacedCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var Bf=v(()=>{c();ae();W({name:"upperCaseFirst",description:"Converts the first letter of a string to uppercase",logicFactory(e){return t=>t.charAt(0).toUpperCase()+t.slice(1)},inputType:"string",testValue:"my name",type:"formatter"});});var Mf=v(()=>{c();Qm();Zm();Jm();ef();tf();rf();of();nf();af();sf();lf();cf();uf();pf();df();mf();ff();gf();hf();yf();bf();vf();Sf();Tf();xf();Rf();Ef();kf();Cf();Pf();Af();wf();If();Lf();Of();_f();Bf();});function Vf({onDownloadPDF:e,onDownloadCSV:t}){let[r,o]=useState(!1),[n,a]=useState(!1),[s,i]=useState(!1),l=useMediaQuery("(max-width: 768px)"),u=Ie("export"),p={...jk,...u},d=async()=>{if(e){o(!0);try{await e();}finally{o(!1),i(!1);}}},m=async()=>{if(t){a(!0);try{await t();}finally{a(!1),i(!1);}}},b=(h,w,I,A,k,N)=>jsx(Button,{id:N,size:"sm",onClick:h,disabled:w,fullWidth:!0,variant:"subtle",h:"auto",px:"xs",w:"100%",styles:z=>({inner:{width:"100%",display:"block"}}),children:jsxs(Group,{noWrap:!0,position:"left",spacing:"xs",w:"100%",children:[w?jsx(Loader,{size:"1.75rem"}):I,jsxs(Stack,{spacing:0,w:"100%",py:"0.5rem",className:"bespoke-report-download-btn-text-container",children:[jsx(Text,{w:"100%",size:"sm",lineClamp:1,className:"bespoke-report-download-btn-text-container-cta",children:A}),k&&jsx(Text,{size:"xs",w:"100%",lineClamp:2,maw:"100%",style:{wordWrap:"break-word",whiteSpace:"normal"},variant:"dimmed",lh:"0.9rem",h:"1.9rem",className:"bespoke-report-download-btn-text-desc",children:k})]})]})}),f=e&&b(d,r,jsx(IconFileTypePdf,{size:"1.75rem"}),p.pdf.label,p.pdf.desc,"bespoke-download-pdf-btn"),y=t&&b(m,n,jsx(IconFileTypeXls,{size:"1.75rem"}),p.xlsx.label,p.xlsx.desc,"bespoke-download-xlsx-btn");return e||t?jsx(Affix,{position:{bottom:l?rem(0):rem(20),right:l?rem(0):rem(20)},id:"bespoke-report-download-affix",style:{width:l?"100%":"auto",boxShadow:l?"0px -2px 6px rgba(0, 0, 0, 0.1)":"0px 2px 6px rgba(0, 0, 0, 0.1)",borderRadius:"0.25rem",background:"white"},p:"xs",children:jsxs(Popover,{opened:s,onChange:i,position:"top",shadow:"md",width:l?"100%":250,id:"bespoke-report-download-popover",children:[jsx(Popover.Target,{children:jsx(Button,{id:"bespoke-report-download-btn",size:"sm",onClick:()=>i(h=>!h),leftIcon:jsx(IconDownload,{size:"1.2rem"}),variant:"subtle",loading:r||n,fullWidth:l,children:p.export})}),jsx(Popover.Dropdown,{p:"0.5rem",children:jsxs(Stack,{spacing:"xs",children:[f,y]})})]})}):null}var jk,zf=v(()=>{"use client";c();gt();jk={export:"Export",pdf:{label:"Download PDF",desc:"Generates a printable version of the report page in PDF format."},xlsx:{label:"Download XLSX",desc:"Creates a downloadable spreadsheet of the report page data."}};});function Xk(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o)&255;return t}function $f(e){return `data_export_${new Date().toISOString()}`}var Yk,Qk,Uf,Gf=v(()=>{c();Yk=e=>new Promise((t,r)=>{let o="xlsx";if(!e||e.length===0){r(new Error("No data provided"));return}try{let n=Ro.utils.book_new();e.forEach((l,u)=>{if(l.data&&l.data.length>0){let p=l.data[0],d=Ro.utils.json_to_sheet(p),m=(l.fileName||`Sheet${u+1}`).slice(0,31),b=1;for(;n.SheetNames.includes(m);){let f=` (${b})`;m=`${m.slice(0,31-f.length)}${f}`,b++;}Ro.utils.book_append_sheet(n,d,m);}});let a=Ro.write(n,{bookType:"xlsx",type:"binary"}),s=new Blob([Xk(a)],{type:"application/octet-stream"}),i=new SR;i.file(`${$f(o)}.xlsx`,s),i.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(l=>{t(l);}).catch(r);}catch(n){r(n);}});Qk=async e=>{try{let t=await Yk(e);saveAs(t,`${$f("xlsx")}.zip`);}catch(t){console.error("Error generating file:",t);}},Uf=Qk;});function $e(){let e=useContext(Wf);if(e===void 0)throw new Error("usePrint must be used within a PrintContext");return e}function iC(e){return useMemo(()=>e.data.reduce((r,o)=>(o.blocks&&o.blocks.forEach(n=>{r[n]=o.id;}),r),{}),[e.data])}function lC({pathSegmentsKey:e="bespoke",sectionLoader:t,mode:r}){let{asPath:o,query:n}=useRouter(),a=zo(),s=Ke(),i=Xo(),l=wg(n.print)??!1,u=r==="embed",{printReport:p,error:d,setError:m}=Jn();Yn();let b=qf.locale,f=Pt(b),y=useMemo(()=>a.data.flatMap(R=>R.blocks||[]),[a.data]),h=iC({data:a.data||[]}),{sectionsVariables:w,resetSectionVariables:I,setSectionVariables:A}=Ac(a.data?.map(R=>R.id)||[]),k=X(R=>R),N=Ie("options"),z={...Qi,...N.data_tab},E=useMemo(()=>y.reduce((R,x)=>{let L=k.records.entities.block[x],D=k.variables.status[x];return g.VIZ===L?.type&&D.allowed&&R.push({id:x,entity:L,variables:k.variables.variables[x],status:k.variables.status[x],inputVariablesFlat:L.inputs.reduce((O,P)=>({...O,...k.variables.variables[P]}),k.variables.attributes)}),R},[]),[y,k.records.entities.block,k.variables.attributes,k.variables.status,k.variables.variables]),F=async(R,x,L)=>{let D=dataLoad.bind({});return new Promise((O,P)=>{D(x,null,null,(j,K)=>{if(j)P(j);else try{R||(R={data:[]}),Array.isArray(R.data)||(R.data=[]);let q=L instanceof Function?L(K):K;R.data.unshift(q),R.rawData=K,O(R);}catch(q){P(q);}});})},C=async()=>{if(!i.XlsxVizActive)return;let R=[],x=[],L=0;for(let P of E){let j=P.entity,K=Oe(j),q=P.inputVariablesFlat,ee={variables:q},oe=ot({logic:K.logic},f,ee).logic,ce={router:qf,section:{variables:w[h[j.id]],setVariables:A(w[h[j.id]]),resetVariables:I(w[h[j.id]])}},G=ir(oe,f,q,b,j.id,{},ce),Y=G.config._downloadTitle||G.config.title||`${z.viz_source} ${L+1}`,H=G.config._downloadFileName||Y;if(G.config._downloadEnabled!==!1){let $=G.config._downloadUrl||G.config.data;if(!$){console.error("API is undefined for block:",j.id);continue}let M=typeof $=="string"?[$]:$,_=G.dataFormat instanceof Function?G.dataFormat:!1,te=G.config._downloadDataFormat instanceof Function?G.config._downloadDataFormat:!1;try{let U=await F({ix:L,id:j.id,title:sl(Y),fileName:H,data:M,loading:!1,type:g.VIZ},$,te||_),J="Section A",Q="Source XYZ";x.push({"File Name":`${J} ${H}`,source:Q}),R.push(U),L++;}catch(U){console.error(`Error loading data for block ${j.id}:`,U);}}}let D=R,O={fileName:"Metadata",data:x};return D.unshift(O),D};return jsxs(Wf.Provider,{value:{print:l,isEmbed:u},children:[jsxs(Container,{id:"bespoke-report",className:s.comparisonLoaded?"compare":"",p:0,pos:"relative",fluid:!0,children:[a.isSuccess&&a.data.sort(Xe).map(R=>jsx(Ym,{section:R,sectionLoader:t},R.id)),cC({pdf:i,print:l,printReport:p,downloadCSV:Uf,isPosition:Qn,handleLoadData:C})]}),d&&jsx(Affix,{position:{bottom:rem(80),right:rem(20)},children:jsx(Notification,{title:"Error",color:"red",onClose:()=>m(null),icon:jsx(IconX,{size:"1.1rem"}),children:d})})]})}function cC({pdf:e,print:t,printReport:r,downloadCSV:o,isPosition:n,handleLoadData:a}){return t||!n(e.position,"DEFAULT")?null:e.active||e.XlsxVizActive?jsx(Vf,{onDownloadPDF:e.active?r:void 0,onDownloadCSV:e.XlsxVizActive?async()=>{let s=await a();s&&s.length>0?await o(s):console.error("No data loaded for CSV download");}:void 0}):null}var Wf,Kf,jt=v(()=>{c();he();zr();Xm();Wt();Xn();js();ea();Js();ye();br();hr();Se();Jo();Mf();gt();zf();Gf();Zi();Wf=createContext({print:!1,isEmbed:!1});Kf=lC;});c();c();Ut();jt();Ks();gt();Wt();Xn();co();function pC({pathSegmentsKey:e="bespoke",translations:t,bespokeStyles:r,buildTime:o,siteProps:n,profilePrefix:a="/defaultPath",loader:s=jsx(LoadingOverlay,{visible:!0}),sectionLoader:i=jsx(LoadingOverlay,{visible:!0}),mantineProviderProps:l={},mode:u}){return Kn(e)?jsx(Fragment,{children:s}):jsx(MantineProvider,{...l,theme:{other:{bespokeStyles:r}},inherit:!0,children:jsxs(Mc,{pathSegment:"bespoke",profilePrefix:a,siteProps:n,children:[jsx(Ts,{translations:t,children:jsx(Ls,{children:jsx(Ys,{children:jsx(eu,{pageSize:12,children:jsx(Kf,{sectionLoader:i||s,mode:u})})})})}),jsx("small",{className:"bespoke-timestamp",children:o})]})})}/*! Bundled license information:
63
63
 
64
64
  @tanstack/react-virtual/build/lib/_virtual/_rollupPluginBabelHelpers.mjs:
65
65
  (**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.7.15-rc.5",
3
+ "version": "0.7.15-rc.7",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {