@datawheel/bespoke 0.9.9 → 0.9.11

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.
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-7K6SKRXP.js';import {K}from'./chunk-PGBDZWWY.js';import {b as b$1,d as d$1,c}from'./chunk-2D75X364.js';import'./chunk-JU4YILPF.js';import {O,Oa,Va,Pa,J as J$1}from'./chunk-EYRXKCMJ.js';import {a}from'./chunk-P6ORTCRN.js';import {b}from'./chunk-QZ5NBDGE.js';import*as J from'd3plus-react';import {useMemo}from'react';import {useRouter}from'next/router';import {jsx}from'react/jsx-runtime';var d={...J,[c]:d$1},Z=(c,n)=>{let o={...c};return n&&(o.detectResize=false,o.detectResizeDelay=0,o.detectVisible=false,o.detectVisibleInterval=0,o.duration=0,o.shapeConfig={...o.shapeConfig,duration:0}),o};function $(c$1){let{print:n}=K(),{block:o,active:h,locale:l,variables:s,configOverride:x={}}=c$1,m=O(o),u=Oa(l),L={variables:s},N=useRouter(),{sectionVariables:g,setSectionVariables:O$1,resetSectionVariables:H}=Va(o.section_id),M=Pa(),v=a(),y=b(),b$2=JSON.stringify(g),e=useMemo(()=>{if(!m?.logic)return {error:"Add a Configuration"};let a=J$1({logic:m.logic},u,L).logic,t={router:N,section:{variables:g,setVariables:O$1,resetVariables:H},events:{fire:(p,w={})=>y("viz_interaction",{name:p,...w},{component:"Viz",blockId:o.id,sectionId:o.section_id})}};return b$1(a,u,s,l,o.id,{},t,M,v)},[o,h,s,b$2,v.status,y]),{type:r}=e.config||{},A=r&&d[r]?r:"Treemap";d[r]||(e.config={error:`"${r}" is not a valid Visualization Type`});let D=d[A],j=useMemo(()=>{let{_data:a,...t}=e.config;return Z(t,n)},[e,n]),V={locale:l,variables:s,...j,...x};return jsx("div",{className:"bespoke-Viz","data-ignore-print":V._printIgnore?"true":void 0,children:jsx("div",{style:{display:"flex",flex:"1 1 100%",minHeight:r===c?void 0:400},children:jsx(a$1,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(D,{style:{flex:1},dataFormat:a=>{let t;try{t=e.dataFormat(a);}catch(p){console.error("Error in dataFormat: ",p),t=[];}return t},linksFormat:e.linksFormat,nodesFormat:e.nodesFormat,topojsonFormat:e.topojsonFormat,config:{...V,sectionVariables:b$2}},"viz-key")})})})}export{$ as default};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-7K6SKRXP.js';import {b as b$1,d,c}from'./chunk-2D75X364.js';import {O,Oa,Pa,Va,J}from'./chunk-EYRXKCMJ.js';import {a}from'./chunk-P6ORTCRN.js';import {b}from'./chunk-QZ5NBDGE.js';import {memo,useMemo}from'react';import {Center,Badge}from'@mantine/core';import*as Z from'd3plus-react';import {useRouter}from'next/router';import {jsx}from'react/jsx-runtime';var q=()=>({}),G={},m={[c]:d,...Z,...G};function K({block:o,active:e,locale:a$2,variables:s,configOverride:L={}}){let N=q(),c=O(o),u=Oa(a$2),I={variables:s},A=Pa(),g=a(),J$1=useRouter(),{sectionVariables:d,setSectionVariables:M,resetSectionVariables:R}=Va(o.section_id),p=b(),t=useMemo(()=>{if(!e)return {error:"Activate to View"};if(!c?.logic)return {error:"Add a Configuration"};let f=J({logic:c.logic},u,I).logic,n={router:J$1,section:{variables:d,setVariables:M,resetVariables:R},events:{fire:(l,x={})=>p("viz_interaction",{name:l,...x},{component:"Viz",blockId:o.id,sectionId:o.section_id})}};return b$1(f,u,s,a$2,o.id,{},n,A,g)},[c?.logic,e,s,d,g.status,p]),{type:i}=t.config||{},_=i&&m[i]?i:"Treemap";i||(t.config={error:'Visualization missing "type"'}),m[i]||(t.config={error:`"${i}" is not a valid Visualization Type`});let h=m[_],y=t.error||t.config?.error||false;if(y)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:y},"type")});let{_data:Q,...w}=t.config,V={locale:a$2,variables:s,...w,...L};return N.print&&(V.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(a$1,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(h,{style:{flex:1},dataFormat:f=>{let n;try{n=t.dataFormat(f);}catch(l){console.error("Error in dataFormat: ",l),n=[];}return n},linksFormat:t.linksFormat,nodesFormat:t.nodesFormat,topojsonFormat:t.topojsonFormat,config:{...V}},"viz-key")})})}var mo=memo(K,(o,e)=>o.block.contentByLocale.logic.content===e.block.contentByLocale.logic.content&&o.active===e.active&&o.locale===e.locale&&JSON.stringify(o.variables)===JSON.stringify(e.variables)&&JSON.stringify(o.configOverride)===JSON.stringify(e.configOverride));export{mo as default};
@@ -0,0 +1 @@
1
+ .mantine-Prism-root.cr-variable{font-size:11px;padding:0}.mantine-Prism-root.cr-variable .mantine-Prism-code{background-color:transparent!important;padding:0}.cr-variable-accordion .mantine-Accordion-item{border-bottom:0}.cr-variable-accordion .mantine-Accordion-control{padding:2px}.cr-variable-accordion .mantine-Accordion-contentInner{padding:0}.cr-variable-accordion .mantine-Accordion-icon{margin-right:4px}
package/dist/auth.js CHANGED
@@ -1 +1 @@
1
- import {useRouter}from'next/router';import {useEffect,useMemo}from'react';import {SessionProvider,useSession,signIn,signOut}from'next-auth/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {Menu,Button,Text,Avatar}from'@mantine/core';import {IconUserCircle,IconLogout,IconEdit}from'@tabler/icons-react';import $ from'next/link';function T(o={required:false}){let{update:i,data:s,status:a}=useSession(o);return {update:i,user:s?.user,status:a,isLoading:a==="loading"}}var g=T;function w(o){let{SuccessComponent:i,FailureComponent:s}=o,a=new Set(o.allowedRoles);return function(n){let{user:m,status:r}=g(),l=useRouter();if(useEffect(()=>{r==="unauthenticated"&&signIn();},[r,l]),r==="loading")return jsx("div",{children:"Loading..."});if(!m)return jsx(s,{...n});let y=m.bespoke_roles||[];return a.size===0||y.some(t=>a.has(t))?jsx(i,{user:m,...n}):jsx(s,{...n})}}var N=SessionProvider;var p={ADMIN:"Admin",EDITOR:"Editor",WRITER:"Writer"},h={APP:"App",USER:"User"},z=o=>{let i=Object.values(p);return o?o.map(s=>({...s,type:i.includes(s.name)?h.APP:h.USER})):[]};function J({buttonProps:o={},editorMenuItemProps:i={},editorMenuItemRoute:s="/cms",logoutButtonProps:a={},menuProps:U={},options:n="",optionsPosition:m="bottom",translations:r={},withEditorMenuItem:l=true,withSession:y=true}){let{user:t,isLoading:P}=g(),b=useMemo(()=>t?.bespoke_roles||[],[t]),k=useMemo(()=>p&&Object.keys(p).length>0&&Object.keys(p).some(R=>b.includes(p[R])),[b]),x={leftIcon:jsx(IconUserCircle,{}),...o};if(t&&!P){let R={...i},M={color:"red",fullWidth:true,leftIcon:jsx(IconLogout,{size:14}),size:"xs",variant:"subtle",...a},v={shadow:"md",width:"auto",position:"bottom",...U},I=jsx($,{href:s,passHref:true,children:jsx(Menu.Item,{icon:jsx(IconEdit,{size:14}),...R,children:r["Go to editor"]||"Go to editor"})});return jsxs(Menu,{...v,children:[jsx(Menu.Target,{children:jsx(Button,{...x,children:`${r["Welcome message"]||`Hi, ${t.name||t.email}`}`})}),jsxs(Menu.Dropdown,{children:[m==="top"&&jsxs(Fragment,{children:[l&&k&&I,n,(n||l&&k)&&jsx(Menu.Divider,{})]}),y&&jsxs(Menu.Item,{component:"span",style:{pointerEvents:"none"},icon:jsx(Avatar,{src:t.picture,radius:"md"}),children:[jsx(Text,{size:"sm",weight:500,children:t.name}),jsx(Text,{color:"dimmed",size:"xs",children:t.email})]}),jsx(Button,{onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),...M,children:r.Disconnect||"Disconnect"}),m==="bottom"&&jsxs(Fragment,{children:[(n||l&&k)&&jsx(Menu.Divider,{}),l&&k&&I,n]})]})]})}return jsx(Button,{onClick:()=>signIn(),loading:P,...x,children:P?r["Signing in"]||"Signing in...":r["Sign in"]||"Sign in"})}var X=J;export{X as BespokeLoginBtn,N as BespokeUserProvider,w as BespokeWithPageRoleAuthRequired,p as CMS_ROLES,z as addRoleTypes,g as useBespokeUser};
1
+ import {a as a$1}from'./chunk-5NVVEPZQ.js';export{a as CMS_ROLES,b as addRoleTypes}from'./chunk-5NVVEPZQ.js';import {a}from'./chunk-P6ORTCRN.js';export{a as useBespokeUser}from'./chunk-P6ORTCRN.js';import {b}from'./chunk-QZ5NBDGE.js';import {useRouter}from'next/router';import {useEffect,useMemo}from'react';import {SessionProvider,signIn,signOut}from'next-auth/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {Menu,Button,Text,Avatar}from'@mantine/core';import {IconUserCircle,IconLogout,IconEdit}from'@tabler/icons-react';import V from'next/link';function D(c){let{SuccessComponent:d,FailureComponent:u}=c,l=new Set(c.allowedRoles);return function(n){let{user:r,status:t}=a(),i=useRouter();if(useEffect(()=>{t==="unauthenticated"&&signIn();},[t,i]),t==="loading")return jsx("div",{children:"Loading..."});if(!r)return jsx(u,{...n});let B=r.bespoke_roles||[];return l.size===0||B.some(o=>l.has(o))?jsx(d,{user:r,...n}):jsx(u,{...n})}}var G=SessionProvider;function X({buttonProps:c={},editorMenuItemProps:d={},editorMenuItemRoute:u="/cms",logoutButtonProps:l={},menuProps:h={},options:n="",optionsPosition:r="bottom",translations:t={},withEditorMenuItem:i=true,withSession:B=true}){let{user:o,isLoading:k}=a(),P=b(),L=useMemo(()=>o?.bespoke_roles||[],[o]),g=useMemo(()=>a$1&&Object.keys(a$1).length>0&&Object.keys(a$1).some(R=>L.includes(a$1[R])),[L]),C={leftIcon:jsx(IconUserCircle,{}),...c};if(o&&!k){let R={...d},v={color:"red",fullWidth:true,leftIcon:jsx(IconLogout,{size:14}),size:"xs",variant:"subtle",...l},E={shadow:"md",width:"auto",position:"bottom",...h},M=jsx(V,{href:u,passHref:true,children:jsx(Menu.Item,{icon:jsx(IconEdit,{size:14}),onClick:()=>P("navigate_editor",{route:u},{component:"LoginButton"}),...R,children:t["Go to editor"]||"Go to editor"})});return jsxs(Menu,{...E,children:[jsx(Menu.Target,{children:jsx(Button,{...C,children:`${t["Welcome message"]||`Hi, ${o.name||o.email}`}`})}),jsxs(Menu.Dropdown,{children:[r==="top"&&jsxs(Fragment,{children:[i&&g&&M,n,(n||i&&g)&&jsx(Menu.Divider,{})]}),B&&jsxs(Menu.Item,{component:"span",style:{pointerEvents:"none"},icon:jsx(Avatar,{src:o.picture,radius:"md"}),children:[jsx(Text,{size:"sm",weight:500,children:o.name}),jsx(Text,{color:"dimmed",size:"xs",children:o.email})]}),jsx(Button,{onClick:()=>{P("user_logout",{userId:o.id,email:o.email},{component:"LoginButton"}),signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"});},...v,children:t.Disconnect||"Disconnect"}),r==="bottom"&&jsxs(Fragment,{children:[(n||i&&g)&&jsx(Menu.Divider,{}),i&&g&&M,n]})]})]})}return jsx(Button,{onClick:()=>{P("user_login",{},{component:"LoginButton"}),signIn();},loading:k,...C,children:k?t["Signing in"]||"Signing in...":t["Sign in"]||"Sign in"})}var j=X;export{j as BespokeLoginBtn,G as BespokeUserProvider,D as BespokeWithPageRoleAuthRequired};
@@ -0,0 +1,3 @@
1
+ import {i,X,j}from'./chunk-EYRXKCMJ.js';import {dataConcat}from'd3plus-viz';import {jsx}from'react/jsx-runtime';var x=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",L="Error Rendering Visualization",d={data:[],dataFormat:r=>r,type:"Treemap",noDataHTML:`<p style="font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
2
+ <strong>${L}</strong>
3
+ </p>`},y=(r,n,o)=>{let t=n.find(a=>{let s=a.content?.pattern;if(!s)return false;try{return new RegExp(s,"gm").test(r)}catch{return false}});if(t){if(t.content?.useProxy)return `${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(r)}&wrapper=false`;try{let s={envs:{...X()},...o?{session:o}:{}},i=j({vars:["url","libs","session"],logic:t.content.logic},s)(r);if(i instanceof Promise)console.warn(`[DataSource] Logic for "${t.name}" is async, which is not supported in this context. Use useProxy=true for async logic.`);else if(i?.axiosConfig?.url!=null){let{url:c,headers:e}=i.axiosConfig;return e&&Object.keys(e).length>0?{url:c,headers:e}:c}}catch(a){console.error(`[DataSource] Failed to apply logic for URL "${r}":`,a.message);}}return r},g=(r,n,o)=>typeof r=="string"?y(r,n,o):Array.isArray(r)?r.map(t=>typeof t=="string"?y(t,n,o):t):r,T=(r,n,o={},t=x,a=null,s={},u={},i$1=[],c)=>{let e;try{e=i({vars:["variables"],logic:r},n,t,s,u)(o),e.data=g(e.data,i$1,c),e._downloadUrl&&(e.__downloadUrl=g(e.__downloadUrl,i$1,c));}catch(l){return console.error(`Parsing Error in propify (ID: ${a})`),console.error(`Error message: ${l.message}`),{error:`${l}`,config:d}}if(typeof e!="object")return {error:"Visualization JS code must return an object",config:d};let F=e.dataFormat?e.dataFormat:l=>{let U=Array.isArray(e.data)&&e.data.length>1&&e.data.some(E=>typeof E=="string")?l:[l];return dataConcat(U,"data")};delete e.dataFormat;let h=e.linksFormat||void 0;delete e.linksFormat;let D=e.nodesFormat||void 0;delete e.nodesFormat;let S=e.topojsonFormat||void 0;return delete e.topojsonFormat,{config:e,dataFormat:F,linksFormat:h,nodesFormat:D,topojsonFormat:S}},P=T;var B="HTML",H=({config:r})=>!r||!r.html?null:jsx("div",{className:"bespoke-html",dangerouslySetInnerHTML:{__html:r.html}});export{g as a,P as b,B as c,H as d};
@@ -0,0 +1 @@
1
+ var n={ADMIN:"Admin",EDITOR:"Editor",WRITER:"Writer"},t={APP:"App",USER:"User"},i=e=>{let s=Object.values(n);return e?e.map(r=>({...r,type:s.includes(r.name)?t.APP:t.USER})):[]};export{n as a,i as b};
@@ -0,0 +1 @@
1
+ import t from'react';import {notifications}from'@mantine/notifications';var e=class extends t.Component{constructor(r){super(r),this.state={hasError:false};}static getDerivedStateFromError(r){return console.info("getDerivedStateFromError",r),{hasError:true}}componentDidCatch(r,o){console.error("Error information:",o.componentStack),notifications.show({autoClose:false,color:"red",id:"revalidate-error",message:"Check the console for more details",title:r.message});}render(){return this.state.hasError?this.props.fallback:this.props.children}};export{e as a};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-5NVVEPZQ.js';import {g}from'./chunk-JU4YILPF.js';import {a,ha}from'./chunk-EYRXKCMJ.js';import u from'yn';function c(e,a,n,o){return {method:e,path:a,handler:n,roleRequired:o}}function s(e){let a=Number.parseInt(`${e||""}`,10);if(Number.isNaN(a)||!Number.isFinite(a))throw new ha(400,`Invalid numeric parameter: ${e}`);return a}function r(e){return e==null||e===""?[]:Array.isArray(e)?e:e.toString().split(",")}var{localeDefault:d}=a();function z(e){let{readMember:a,searchMember:n,updateMember:o,readMemberImage:b}=e;return [c("GET","read/members",async i=>{let t=S(i.query),m=t[t.mode]||[],l=t.mode==="whole";if(!l&&m.length===0)throw new ha(400,`The request is missing the '${t.mode}' parameter.`);if(!l&&m.length>20&&!t.variant)throw new ha(400,`You can look for up to 20 '${t.mode}' in a single request.`);return a(t)}),c("GET","search/members",i=>{let t=w(i.query);return n(t)}),c("POST","update/member",i=>{let{body:t}=i;return o(t)},[a$1.EDITOR]),c("GET","member/image",i=>{let t=r(i.query.size)[0];return b({member:s(i.query.member),size:t&&t==="splash"?"splash":"thumb"})})]}function S(e){let a=r(e.locale)[0]||d||"en",n=a==="all"||u(e.all),o=r(e.mode)[0],i=(r(e.output)[0]||"full")==="lite"?"lite":"full",t=parseInt(r(e.related)[0],10)||5,m=u(e.allowNulls,{default:false}),l=r(e.variant).map(s);if(l.length===0&&(l=r(e["variant[]"]).map(s)),o==="ids")return {all:n,mode:o,variant:l,output:i,locale:n?d:g(a),ids:r(e.ids||e["ids[]"]),allowNulls:m};if(o==="content_ids")return {all:n,mode:o,variant:l,output:i,locale:n?d:g(a),content_ids:r(e.content_ids||e["content_ids[]"]).map(s),allowNulls:false};if(o==="slugs")return {all:n,mode:o,variant:l,output:i,locale:n?d:g(a),slugs:r(e.slugs||e["slugs[]"]).map(_=>{let[M,P]=_.split("/");return {variantSlug:M,memberSlug:P}}),allowNulls:false};if(o==="related")return {all:n,mode:o,locale:n?d:g(a),related:t,current_ids:r(e.current_ids||e["current_ids[]"]).map(s),include_ids:r(e.include_ids||e["include_ids[]"]).map(s),report_ids:r(e.report_ids||e["report_ids[]"]).map(s),dimension_ids:r(e.dimension_ids||e["dimension_ids[]"]).map(s),variant_ids:r(e.variant_ids||e["variant_ids[]"]).map(s),output:i,allowNulls:false};if(o==="whole")return {all:n,mode:o,variant:l,locale:n?d:g(a),output:i,allowNulls:m};throw new ha(400,`Invalid mode: '${o}'`)}function w(e){let a=r(e.locale)[0]||d||"en",n=a==="all",o=r(e.format)[0],b=o?o==="nested":n,i=r(e.variant).map(s);i.length===0&&(i=r(e["variant[]"]).map(s));let t=r(e.dimension).map(s);t.length===0&&(t=r(e["dimension[]"]).map(s));let m=r(e.report).map(s);m.length===0&&(m=r(e["report[]"]).map(s));let l=e.origin==="typesense"?"typesense":"flexsearch";return {query:r(e.query||e.q)[0]||"",locale:n?d:a,preferredLocale:r(e.preferredLocale)[0],limit:r(e.limit).map(s)[0]??5,format:b?"nested":"plain",includes:u(e.includes,{default:true}),visible:u(e.visible,{default:true}),noImage:u(e.noImage,{default:false}),variant:i,dimension:t,report:m,all:n,sort:r(e.sort)[0],direction:r(e.direction)[0],offset:Number(e.offset||0),origin:l}}var D=e=>({overrideNames:e&&typeof e.overrideNames<"u"?e.overrideNames:false,overrideRelevance:e&&typeof e.overrideRelevance<"u"?e.overrideRelevance:false,regenerateSlugs:e&&typeof e.regenerateSlugs<"u"?e.regenerateSlugs:false,keepOldMembers:e&&typeof e.keepOldMembers<"u"?e.keepOldMembers:true,doIngest:e&&typeof e.doIngest<"u"?e.doIngest:false,overrideAttributes:e&&typeof e.overrideAttributes<"u"?e.overrideAttributes:false,order:e&&typeof e.order<"u"?e.order:0});export{c as a,s as b,r as c,z as d,S as e,w as f,D as g};
@@ -0,0 +1,35 @@
1
+ import {a as a$1}from'./chunk-P6ORTCRN.js';import {a,b}from'./chunk-QZ5NBDGE.js';import*as wo from'd3-array';import*as No from'd3-collection';import*as Mo from'd3-format';import*as Do from'd3-time-format';import {formatAbbreviate}from'd3plus-format';import {date}from'd3plus-axis';import {merge,closest,assign,isObject}from'd3plus-common';import {titleCase,strip}from'd3plus-text';import it from'axios';import Ir from'axios-retry';import nn from'yn';import {format}from'pretty-format';import hn from'toposort';import {csvParse}from'd3-dsv';import mn from'jsonwebtoken';import yn from'next/config';import {schema,normalize}from'normalizr';import {createSlice,configureStore}from'@reduxjs/toolkit';import {HYDRATE,createWrapper}from'next-redux-wrapper';import {notifications}from'@mantine/notifications';import {createContext,useMemo,useContext,useRef,useCallback,useEffect}from'react';import {useDispatch,useSelector}from'react-redux';import {Skeleton}from'@mantine/core';import {jsx}from'react/jsx-runtime';var lr="report",ca="Report",ua=null;var pr="section",pa="Section",da=lr;var Po=()=>{let e=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",t=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[e];return t.includes(e)||t.push(e),{localeDefault:e,locales:t}},se=Po;var {localeDefault:Lo}=se(),ga="block",Ea="Block",ha=pr;function ee(e){return {variables:e.variables||{},query:e.query||{},locale:e.locale||Lo}}function bt(e){return e.reduce((t,r,o)=>(o?o===e.length-1&&o===1?t+=` and ${r}`:o===e.length-1?t+=`, and ${r}`:t+=`, ${r}`:t+=r,t),"")}function At(e){let t=1+76.18009173/e-86.50532033/(e+1)+24.01409822/(e+2)-1.231739516/(e+3)+.00120858003/(e+4)-536382e-11/(e+5);return (e-.5)*Math.log(e+4.5)-(e+4.5)+Math.log(t*2.50662827465)}function dr(e,t,r){let o=0,n=1,s=1,i=1,a=0,c=0,u;for(;Math.abs((s-c)/s)>1e-5;)c=s,u=-(t+a)*(t+r+a)*e/(t+2*a)/(t+2*a+1),o=s+u*o,n=i+u*n,a+=1,u=a*(r-a)*e/(t+2*a-1)/(t+2*a),s=o+u*s,i=n+u*i,o/=i,n/=i,s/=i,i=1;return s/t}function _o(e,t,r){let o,n;if(e<0)n=0;else if(e>=t)n=1;else {e=Math.floor(e);let s=r,i=e+1,a=t-e,c=i+a,u=Math.exp(At(c)-At(a)-At(i)+i*Math.log(s)+a*Math.log(1-s));s<(i+1)/(c+2)?o=u*dr(s,i,a):o=1-u*dr(1-s,a,i),n=1-o;}return Math.round(n*1e5)/1e5}function Oo(e){return {.99999:15.137,.99:6.635,.95:3.841,.9:2.706}[e]}function ze(e,t,r,o){let n=t/(1-t),s=0,i=1,a=0,c=0;for(;s<=e;)c+=i,s>=r&s<=o&&(a+=i),c>1e30&&(a/=1e30,c/=1e30,i/=1e30),s+=1,i=i*n*(e+1-s)/s;return a/c}function Io(e,t,r){let o=e/t,s=(100-r*100)/2,i,a;if(e===0)i=0;else {let c=o/2,u=0,p=o,l=s/100;for(;p-u>1e-5;)ze(t,c,e,e)*.5+ze(t,c,e+1,t)>l?(p=c,c=(u+c)/2):(u=c,c=(p+c)/2);i=c;}if(e===t)a=0;else {let c=(1+o)/2,u=o,p=1,l=s/100;for(;p-u>1e-5;)ze(t,c,e,e)*.5+ze(t,c,0,e-1)<l?(p=c,c=(u+c)/2):(u=c,c=(p+c)/2);a=c;}return {lci:i,uci:a}}function Bo(e,t){let r=e,o=t,n=r,s=o,i=95,a=.5,c=.5,p=(100-i)/2/100,l=n;for(;c>1e-5;)c/=2,tt((1+l)*a/(1-a),l+1,1e10)+.5*tt((1+l)*a/(1-a),l,l)>p?a-=c:a+=c;let d=(1+l)*a/(1-a)/s;for(a=.5,c=.5,p=(100-i)/2/100;c>1e-5;)c/=2,tt((1+l)*a/(1-a),0,l-1)+.5*tt((1+l)*a/(1-a),l,l)<p?a-=c:a+=c;let f=(1+l)*a/(1-a)/s;return {lci:d,uci:f}}function tt(e,t,r){let o=1,n=0,s=0,i=0;for(;i<e||o>n*1e-10;)n+=o,i>=t&i<=r&&(s+=o),n>1e30&&(s/=1e30,n/=1e30,o/=1e30),i+=1,o=o*e/i;return s/n}var fr={binomialCdf:_o,binP:ze,computeMidP:Io,criticalValue:Oo,smr:Bo};var de={d3:{...wo,...No,...Mo,...Do},d3plus:{assign:assign,closest:closest,date:date,formatAbbreviate:formatAbbreviate,merge:merge,strip:strip,titleCase:titleCase},stats:fr},Go={};function Oa(e){let t=e.logicFactory(de);return Go[e.name]={description:e.description,inputType:e.inputType,logic:Ho(t),testValue:e.testValue,type:e.type||"formatter"},t}function Ho(e){let t=e.toString().trim();if(t.startsWith("function"))return t.replace(/^function(?:\s\w+)?\([^)]\)/,"").trim().replace(/^{([\s\S]+)\}$/,"$1");let r=t.replace(/^.+?=>/,"").trim();return r.startsWith("{")?r.replace(/^{([\s\S]+)\}$/,"$1"):`return ${r}`}var fe=Ko;function Ko(e,t,r,o=false){let{variables:n}=ee(r);if(!e)return e;let s=/([A-z0-9]*)\{\{([^\}]+)\}\}/g;return e.replace(s,(a,c,u)=>{let p=d=>d;if(c){let d=c.replace(/^\w/g,g=>g.toLowerCase());d in t?p=t[d]:p=g=>`${c}${g}`;}let l=Array.isArray(n[u])?bt(n[u]):n[u];if(l===void 0)return o?a:"N/A";try{return p(l,de,t)}catch(d){return console.error(`Error using formatter ${p.name}
2
+ `,`Error message: ${d.message}`),"N/A"}})}var vt=(e,t,r)=>{let{variables:o}=r,n=i=>i.allowed==="never"?false:!i.allowed||i.allowed==="always"||o[i.allowed],s={...e};return Object.keys(s).forEach(i=>{typeof s[i]=="string"?s[i]=fe(s[i],t,r):Array.isArray(s[i])?s[i]=s[i].filter(n).map(a=>typeof a=="object"?vt(a,t,r):typeof a=="string"?fe(a,t,r):a):typeof s[i]=="object"&&s[i]!==null&&!(s[i]instanceof Date)&&(s[i]=vt(s[i],t,r));}),s},rt=vt;var Te={REPORT:"report",SECTION:"section",BLOCK:"block",INPUT:"block_input",FORMATTER:"formatter",DATASOURCE:"datasource",DIMENSION:"report_dimension",VARIANT:"report_dimension_variant",SEARCH:"search"};[Te.BLOCK,Te.SEARCH];var Ga={report:"Report",section:"Section",block:"Block",block_input:"Input",formatter:"Formatter",datasource:"Data Source",dimension:"Dimension",variant:"Variant",search:"Search"};({[Te.SECTION]:"report_id",[Te.DIMENSION]:"report_id",[Te.VARIANT]:"dimension_id",[Te.BLOCK]:"section_id",[Te.INPUT]:"block_id"});var Ka={UNILATERAL:"uni",MULTILATERAL:"multi"},be={SINGLE:"single",MULTI:"multi"},Ya={SEGMENTED_CONTROL:"segmented control",SELECTOR:"selector"},xt={ALLOWED:"allowed",ALLOWED_LOGIC:"allowedLogic",IGNORE_CASCADE:"ignoreCascade"},Yo={ACCESS:"access",ACCESS_LOGIC:"accessLogic"},Wo={DISABLED:"disabled"},Qo={FALLBACK:"fallback"};var Xo={IMAGE:"image",PARAGRAPH:"paragraph",SELECTOR:"selector",STAT:"stat",SUBTITLE:"subtitle",TITLE:"title",NAV:"nav",RESET_BUTTON:"reset_button",COMPARISON_BUTTON:"comparison_button",TABLE:"table",BUTTON:"button",MULTIHIERARCHY_SELECTOR:"multihierarchy_selector",FALLBACK:"fallback"},Ct={GENERATOR:"generator",RELATED:"related",VIZ:"visualization",SECTION_FLAG:"section_flag"},kt="logic",T={...Xo,...Ct};[T.GENERATOR,T.SECTION_FLAG,T.SELECTOR,T.VIZ,T.IMAGE,T.TABLE,T.MULTIHIERARCHY_SELECTOR];var O={ALT:"alt",AUTHOR:"author",DESC:"desc",FOOTNOTE:"footnote",BIO:"bio",IMAGE:"image",LABEL:"label",LOGIC:"logic",MULTIHIERARCHY_SELECTOR:"multihierarchySelector",MULTIHIERARCHY_SELECTOR_ALL_LABEL:"multihierarchySelectorAllLabel",MULTIHIERARCHY_SELECTOR_NAME:"multihierarchySelectorName",MULTIHIERARCHY_SELECTOR_PLACEHOLDER:"multihierarchySelectorPlaceholder",SIMPLE:"simple",SIMPLE_ENABLED:"simpleEnabled",PARAGRAPH:"paragraph",SELECTOR_DEFAULT:"selectorDefault",SELECTOR_DYNAMIC:"selectorDynamic",SELECTOR_NAME:"selectorName",SELECTOR_TYPE:"selectorType",SRC:"src",SLUG:"slug",SUBTITLE:"subtitle",TABLE:"table",TITLE:"title",SHORT_TITLE:"shortTitle",TOOLTIP:"tooltip",TWITTER:"twitter",URL:"url",VALUE:"value"};[O.LOGIC,O.SIMPLE,O.SIMPLE_ENABLED];var q={ENABLE_ALL:{bubbleMenu:true,toolbarOptions:{history:true,alignment:false,format:true}},DISABLE_ALL:{bubbleMenu:false,toolbarOptions:{history:false,alignment:false,format:false}},ENABLE_FORMAT:{bubbleMenu:true,toolbarOptions:{history:true,alignment:false,format:true}}},Ja={[T.IMAGE]:[{field:O.TITLE,editorConfig:q.ENABLE_ALL},{field:O.SRC,editorConfig:q.DISABLE_ALL},{field:O.ALT,editorConfig:q.DISABLE_ALL},{field:O.DESC,editorConfig:q.ENABLE_ALL}],[T.PARAGRAPH]:[{field:T.PARAGRAPH,editorConfig:q.ENABLE_ALL},{field:O.TOOLTIP,editorConfig:q.ENABLE_FORMAT}],[T.SELECTOR]:[{field:O.SELECTOR_DEFAULT},{field:O.SELECTOR_DYNAMIC},{field:O.SELECTOR_NAME,editorConfig:q.ENABLE_FORMAT},{field:O.SELECTOR_TYPE}],[T.STAT]:[{field:O.TITLE,editorConfig:q.ENABLE_FORMAT},{field:O.SUBTITLE,editorConfig:q.ENABLE_FORMAT},{field:O.VALUE,editorConfig:q.ENABLE_FORMAT},{field:O.TOOLTIP,editorConfig:q.ENABLE_FORMAT}],[T.SUBTITLE]:[{field:O.SUBTITLE,editorConfig:q.ENABLE_FORMAT},{field:O.TOOLTIP,editorConfig:q.ENABLE_FORMAT}],[T.TITLE]:[{field:O.TITLE,editorConfig:q.ENABLE_FORMAT},{field:O.SLUG,editorConfig:q.DISABLE_ALL},{field:O.TOOLTIP,editorConfig:q.ENABLE_FORMAT}],[T.BUTTON]:[{field:O.LABEL,editorConfig:q.ENABLE_FORMAT},{field:O.URL,editorConfig:q.ENABLE_FORMAT}],[T.GENERATOR]:[],[T.SECTION_FLAG]:[],[T.VIZ]:[],[T.TABLE]:[],[T.MULTIHIERARCHY_SELECTOR]:[{field:O.MULTIHIERARCHY_SELECTOR_NAME,editorConfig:q.ENABLE_FORMAT},{field:O.MULTIHIERARCHY_SELECTOR_PLACEHOLDER,editorConfig:q.DISABLE_ALL},{field:O.MULTIHIERARCHY_SELECTOR_ALL_LABEL,editorConfig:q.DISABLE_ALL}],[T.NAV]:[{field:O.TITLE,editorConfig:q.ENABLE_FORMAT},{field:O.SHORT_TITLE,editorConfig:q.ENABLE_FORMAT}]},gr={NAME:"name",DESCRIPTION:"description",...xt,...Yo,...Qo,...Wo};var Rr={FORMATTER:"formatter",FUNCTION:"function"},ei={[Rr.FORMATTER]:"Formatter",[Rr.FUNCTION]:"Function"},ot={STRING:"string",NUMBER:"number",OBJECT:"object",DATE:"date"},ti={[ot.STRING]:"String",[ot.NUMBER]:"Number",[ot.OBJECT]:"Object/Array",[ot.DATE]:"Date"};var {localeDefault:Er,locales:Jo}=se(),en=Object.values(Ct),tn=(e,t=Er)=>e&&en.includes(e.type)?{locale:kt,locales:[kt]}:{locale:t,locales:Jo},hr=(e,t=Er)=>{if(!e)return {};let{locale:r}=tn(e,t);return e.contentByLocale?.[r]?.content};var rr={};a(rr,{addBlockToState:()=>Ls,addRunConsumersRunning:()=>er,cloneEntity:()=>fo,createEntity:()=>uo,deleteEntity:()=>po,deleteQueryParam:()=>hs,readEntity:()=>Qe,readEnvSecrets:()=>Bs,readMember:()=>Eo,readMetadata:()=>Ts,readPrivateBlocks:()=>_s,readUser:()=>xs,recalculateVariables:()=>ht,removeBlocksFromState:()=>Ps,removeDataSourceLogic:()=>ws,removeRunConsumersRunning:()=>tr,reportSearch:()=>Rs,resetSectionState:()=>Je,revalidateReport:()=>Is,revalidateUrl:()=>Os,searchMember:()=>Es,searchRegenerate:()=>gs,searchRole:()=>As,searchUser:()=>vs,setCurrentLocale:()=>fs,setPreferredLocale:()=>ms,setPreviews:()=>ds,setQueryParam:()=>Ss,setSectionState:()=>Ze,setStatus:()=>go,updateEntity:()=>lo,updateMyData:()=>ks,updateUser:()=>Cs,urlProxy:()=>bs,variantValidateSlug:()=>ys});function te(e,t){return e.request(t).then(r=>{let{status:o,data:n}=r;return "error"in n?{ok:false,status:o,error:n.error}:{ok:true,status:o,wrapper:n.wrapper,data:n.data}},r=>{if("isAxiosError"in r){let{status:o,data:n}=r.response||{status:500};return {ok:false,status:o,error:n?.error??r.message}}return {ok:false,status:500,error:r.message}})}function z(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>te(e,{...o,method:"GET",params:r?r(n):n})}function G(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>te(e,{...o,method:"POST",data:n})}function me(e,t,r){let o=typeof t=="string"?{url:t}:t;return n=>te(e,{...o,method:"DELETE",params:r?r(n):n})}function Ae(e,t){return r=>te(e,{method:"POST",url:`images/save/${t}`,params:{prompt:r.prompt,provider:t}})}function Ue(e,t){return r=>te(e,{method:"GET",url:`images/search/${t}`,params:{prompt:r.prompt,page:r.page,provider:t}})}function Sr(e,t){return ()=>te(e,{method:"GET",url:`list/icons/${t}`,params:{provider:t}})}function Tr(e,t){return r=>te(e,{method:"GET",url:`read/icons/${t}/icon.svg`,params:{name:r.name}})}var ve=e=>({id:e}),on=e=>{if(e.mode==="slugs"){let t=e.slugs.map(r=>[r.variantSlug,r.memberSlug].join("/")).join(",");return {...e,slugs:t}}return ["related","whole"].includes(e.mode)?{...e}:{...e,[e.mode]:e[e.mode].join(",")}};function je(e){let t=it.create({baseURL:e});return {createBulkBlock:G(t,"create/bulk/block"),createBlock:G(t,"create/block"),createDimension:G(t,"create/dimension"),createFormatter:G(t,"create/formatter"),createReport:G(t,"create/report"),createSection:G(t,"create/section"),createVariant:G(t,"create/variant"),createDatasource:G(t,"create/datasource"),deleteBlock:me(t,"delete/block",ve),deleteDimension:me(t,"delete/dimension",ve),deleteFormatter:me(t,"delete/formatter",ve),deleteReport:me(t,"delete/report",ve),deleteSection:me(t,"delete/section",ve),deleteVariant:me(t,"delete/variant",ve),deleteDatasource:me(t,"delete/datasource",ve),readBlock:z(t,"read/block"),readDimension:z(t,"read/dimension"),readFormatter:z(t,"read/formatter"),readReport:z(t,"read/report"),readSection:z(t,"read/section"),readVariant:z(t,"read/variant"),readDatasource:z(t,"read/datasource"),updateBulkBlock:G(t,"update/bulk/block"),updateBlock:G(t,"update/block"),updateDimension:G(t,"update/dimension"),updateFormatter:G(t,"update/formatter"),updateReport:G(t,"update/report"),updateSection:G(t,"update/section"),updateVariant:G(t,"update/variant"),updateDatasource:G(t,"update/datasource"),searchReport:z(t,"search/reports"),validateVariantSlug:z(t,"validate/variant"),readMember:z(t,"read/members",on),readMemberImage:z(t,{url:"member/image",responseType:"blob"}),searchMember:z(t,"search/members"),updateMember:z(t,"update/members"),imageLocalSearch:Ue(t,"local"),imageLocalSave:Ae(t,"local"),imageFlickrSearch:Ue(t,"flickr"),imageFlickrSave:Ae(t,"flickr"),imageUnsplashSearch:Ue(t,"unsplash"),imageUnsplashSave:Ae(t,"unsplash"),imageUploadSave:Ae(t,"upload"),imageAdobeSearch:Ue(t,"adobe"),imageAdobeSave:Ae(t,"adobe"),imagePixabaySearch:Ue(t,"pixabay"),imagePixabaySave:Ae(t,"pixabay"),readMetadata:z(t,"read/metadata"),regenerateSearch:G(t,"search/regenerate"),urlProxy:z(t,"url/proxy"),searchRole:z(t,"auth/search/roles"),searchUser:z(t,"auth/search/users"),readUser:z(t,"auth/read/user"),updateUser:G(t,"auth/update/user"),updateMyData:G(t,"auth/update/me"),revalidateReport:z(t,"revalidate/report"),revalidateUrl:z(t,"revalidate/url"),readPrivateBlocks:G(t,"read/blocks/private"),listTablerIcons:Sr(t,"tabler"),readTablerIcon:Tr(t,"tabler"),readEnvSecrets:z(t,"read/secrets")}}var an=nn(process.env.REPORTS_LOGGING),xe=cn;function cn(e,t,r,o,n=void 0,s){let i={},a=[],{locale:c}=ee(s);try{if(t){let u=new Proxy(console,{get(l,d){return un(d,"log","debug","info","warn","error")?(...g)=>{a.push(`${d} ${Date.now()} - ${g.map(f=>format(f)).join(" ")}`),an&&l[d](...g);}:l[d]}}),p;return n?p=new Function(e,"console","libs","formatters","locale","variables",r)(t,u,de,o,c,n):p=new Function(e,"console","libs","formatters","locale",r)(t,u,de,o,c),typeof p=="object"&&Object.keys(p).length>0&&Object.assign(i,p),{vars:i,error:null,log:a,output:p}}return {vars:i,error:"Invalid API Link",log:a}}catch(u){return {vars:i,error:u.message,log:a}}}function un(e,...t){return t.includes(e)}var br=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];var ln=(e,t,r)=>{if(!r)return false;if(e===be.SINGLE)return r.find(n=>n.id===t);let o=Array.isArray(t)?t:t.split(",");return Array.isArray(o)&&o.every(n=>r.map(s=>s.id).includes(n))},Pt=ln;function Lt(e,t,r,o,n=false){let{variables:s}=ee(o),i=rt({logic:t},r,o).logic,a=xe("variables",s,i,r,void 0,o),{vars:c,log:u,error:p}=a,l=c.type||be.SINGLE,d=c.component||"Selector",g=c.hideLabel||"false",f=c.resetSectionVars||"false",x=c.name||"Unlabeled Selector",m=br(c.options||[]),A=I=>l===be.MULTI&&!Array.isArray(I)?[I]:I,M=c.defaultValue,v;if(M&&(M=A(M),Pt(l,M,m)&&(v=M)),!v){let I=m&&m[0]&&m[0].id||m[0]||"";v=A(I);}if(n&&typeof window<"u"){let I=`selector${e}id`,j=new URLSearchParams(window.location.search),P=Object.fromEntries(j)[I];P&&!Pt(l,P,m)&&P!==void 0&&(j.delete(I),window.history.replaceState(null,null,`?${j.toString()}`));}return {config:{name:x,type:l,options:m,defaultValue:v,component:d,hideLabel:g,resetSectionVars:f},log:u,error:p}}function _t(e,t,r){if(!e)return false;let o=Array.isArray(r)?r:r.split(",");return Array.isArray(o)&&o.every(n=>e.map(s=>`${s[`${t} ID`]}`).includes(n))}function Ot(e,t,r,o,n=false){let{variables:s}=ee(o),i=rt({logic:t},r,o).logic,a=xe("variables",s,i,r,void 0,o),{vars:c,log:u,error:p}=a;if(n&&typeof window<"u"){let d=`multihierarchySelector${e}-value`,g=`multihierarchySelector${e}-type`,f=new URLSearchParams(window.location.search),x=Object.fromEntries(f),m=x[d],A=x[g];m&&m!==void 0&&A&&A!==void 0&&!_t(c.data,A,m)&&(f.delete(d),f.delete(g),window.history.replaceState(null,null,`?${f.toString()}`));}return {config:c,log:u,error:p}}var pn=(e,t,r)=>{let o=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),s=new URLSearchParams(t).get(o),i=n||s;if(r.type===be.MULTI){let u=i?i.split(","):r.defaultValue,p=r.options.filter(l=>u.includes(l.id));return {[`selector${e}id`]:u,[`selector${e}label`]:(p||[]).map(l=>l.label)}}let a=i&&r.options.find(u=>u.id===i)?i:r.defaultValue,c=r.options.find(u=>u.id===a);return {[`selector${e}id`]:a,[`selector${e}label`]:c&&c.label||void 0}},Ar=pn;var dn=(e,t,r)=>{let o=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,s=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(o),i=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),a=new URLSearchParams(t).get(o),c=new URLSearchParams(t).get(n),u=s||a,p=i||c,l=u?u.split(","):r.defaultValue||[],d=p||r.defaultValueType||"",g=r.data?.filter(f=>l.includes(`${f[`${d} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:l,[`multihierarchySelector${e}label`]:[...new Set((g||[]).map(f=>f[d]))],[`multihierarchySelector${e}type`]:d}},vr=dn;function fn(e,t){let r=Object.values(t),o=r.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(r.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(s=>o.includes(s)))).map(n=>[n.id,n]))}var xr=fn;var mc=e=>{let t=[];if(Array.isArray(e))return [];let r=(o,n="")=>{!o||typeof o!="object"||Object.keys(o).forEach(s=>{if(Array.isArray(o[s]))t.push(`${n?`${n}.`:""}${s}`);else if(typeof o[s]=="object")r(o[s],`${n?`${n}.`:""}${s}`);else return});};return r(e),t},Cr=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((r,o)=>r[o],e):e;function yc(e,t){return e.some(r=>t.includes(r))}function Rc(e){return e.filter((t,r,o)=>o.indexOf(t)===r)}var kr="SECTION_ALLOWED",hc=`// const {anotherVariable} = variables; (From context and inputs)
3
+ // const {toUpper} = formatters; (Ad-hoc formatters)
4
+ // const currentLocale = locale;
5
+ // const {d3} = libs; (Preset libraries)
6
+ // const {data} = resp; (Response from API)
7
+ return {
8
+ // propery1: true,
9
+ // propery2: [1,2,3],
10
+ // propery3: {innerProperty1: 1, innerProperty2: "text" }
11
+ }`,Sc=`// const {anotherVariable} = variables; (From context and inputs)
12
+ // const {toUpper} = formatters; (Ad-hoc formatters)
13
+ // const currentLocale = locale;
14
+ // const {d3} = libs; (Preset libraries)
15
+ // const {setVariables, resetVariables} = section;
16
+ // const {myCustomSectionVariable} = section.variables;
17
+ return {
18
+ type: "LinePlot",
19
+ title: "New d3plus chart",
20
+ data: [
21
+ {id: "alpha", x: 4, y: 7},
22
+ {id: "alpha", x: 5, y: 25},
23
+ {id: "alpha", x: 6, y: 13},
24
+ {id: "beta", x: 4, y: 17},
25
+ {id: "beta", x: 5, y: 8},
26
+ {id: "beta", x: 6, y: 16}
27
+ ],
28
+ groupBy: "id",
29
+ x: "x",
30
+ y: "y"
31
+ }`;function It(e){return e.type===T.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var Pr={jwt:mn};var Lr=(e,t={},r="en",o={},n={})=>{let s={setVariables:o.onSetVariables?o.onSetVariables:c=>c,openModal:o.onOpenModal?o.onOpenModal:c=>c,formatters:t,libs:de,locale:r,...n};function i(c){return Function("globals",...c.vars,`with (globals) { ${c.logic} }`).bind(s,s)}function a(c){if(c.vars&&c.logic)return i(c);for(let u in c)Array.isArray(c[u])?c[u]=c[u].map(p=>isObject(p)?a(p):p):isObject(c[u])&&(c[u]=a(c[u]));return c}return a(e)},_r=(e,t={})=>{let r={libs:Pr,...t};function o(s){return Function("globals",...s.vars,`with (globals) { ${s.logic} }`).bind(r,r)}function n(s){if(s.vars&&s.logic)return o(s);for(let i in s)Array.isArray(s[i])?s[i]=s[i].map(a=>isObject(a)?n(a):a):isObject(s[i])&&(s[i]=n(s[i]));return s}return n(e)};function Rn(){let{publicRuntimeConfig:e}=yn(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((r,o)=>(r[`ENV_${o}`]=t[o]||"N/A",r),{})}}var Fe=Rn;function gn(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,r])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:r}),{})}var Or=gn;var ye=nn(process.env.NEXT_PUBLIC_REPORTS_DEBUG),bn=process.env.REPORTS_ORIGIN||"",An=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,Nr=5;try{Nr=parseInt(`${An||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}Ir(it,{retries:Nr,retryDelay:Ir.exponentialDelay,onRetry:(e,t,r)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",r.url),console.error(t.message);}});it.interceptors.request.use(e=>({...e,requestStart:Date.now()}));it.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));var vn=(e,t,r)=>{let o=fe(e,t,r);return o.startsWith("http")||(o=`${bn}${o.startsWith("/")?"":"/"}${o}`),o},{urlProxy:xn}=je("/api/cms");function at(e){return e.ok!==void 0}function st(e){this.message=e,this.name="ApiFetchException";}var Br=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;async function Cn(e,t,r="en",o,n,s){let i=Date.now(),a=e,c,u=Fe(),p=Or(),l={envs:{...u,...p}},d=new URL(e),g=new URLSearchParams(d.searchParams.toString());g.has("bespoke_slugs")&&(d.searchParams.delete("bespoke_slugs"),a=d.toString());let f={datasource:void 0};o.find(v=>{if(!v.content?.pattern)return false;try{let _=new RegExp(v.content.pattern,"gm");return _.test(a)?(f.datasource=v,!0):_.test(a)}catch{return false}});let x=n?n.settings:{},m=!!(x&&x.useProxy&&x.useProxy==="true"),A=f.datasource&&typeof f.datasource.content.useProxy=="boolean"?f.datasource.content.useProxy:false,M=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(a)}`;if(typeof window=="object"&&(m||A)){let v=await xn({url:a,timeout:Br});if(v.ok===true)c=v.data;else throw new st(v?.error)}else try{let _={url:a,timeout:Br};if(f.datasource){let j=l;s&&(j={...l,session:s});let P=typeof window>"u"&&f.datasource.content.logic_ssr?f.datasource.content.logic_ssr:f.datasource.content.logic,C=await _r({vars:["url","libs","session"],logic:P},j)(a);if(C.axiosConfig)_=C.axiosConfig;else throw new st(`AxiosConfig is missing in Data Source ${f.datasource.name} (ID: ${f.datasource.id}).`)}let I=await it(_);if(I.status===200)I.headers["content-type"]==="text/csv"?c=csvParse(I.data):c=I.data;else throw new st("No response for: "+a)}catch(v){throw new st(v.message)}if(g.has("bespoke_slugs")){let v=g.get("bespoke_slugs");if(v){let _=v.split(",");if(_.length===3){let[I,j,W]=_,P=Cr(c,W);if(P&&Array.isArray(P)){let N=Array.from(new Set(P.map(C=>`${C[j]}`).filter(C=>!["","undefined"].includes(C))));if(N.length>0){let C=N.join("").length>2e3,L=await t({mode:C?"whole":"ids",ids:C?void 0:N,all:false,locale:r,variant:[parseInt(I,10)],output:"lite",limit:N.length+1,allowNulls:true}).then(F=>{let B=[];return at(F)?F.ok&&(B=F.data.results):B=F.results,B&&Array.isArray(B)?B:[]}).catch(F=>(console.error(`Error hydrating slugs for Variant: ${I}, Key: ${j}, Accessor: ${W}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(F),[]));if(L){let F=Object.fromEntries(L.map(B=>[B.id,`/${B.variant_slug}/${B.slug}`]));P.map(B=>(B.bespoke_slug=F[B[j]]?F[B[j]]:null,B));}}}}}}return {data:c,requestDuration:Date.now()-i,finalUrl:A||m?M:a,apiDataSource:f.datasource?f.datasource:false}}function kn(e){this.name="BlockException",this.message=e;}async function wr(e,t,r,o,n,s){let{locale:i,variables:a,query:c}=ee(r),u=Ln(e,r,a,t),p=null,l=e.contentByLocale?.logic?.content?.api,d=null,g=null,f=null,x=null,m=null;if(!u)return {outputVariables:{},renderVariables:{},status:{allowed:false,hiddenByCascade:e.id}};if(e.type===T.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:u,hiddenByCascade:e.id}};if(l){f=vn(l,t,r);let P=f.split("|||").filter(L=>L!==""),N=[];for(let L=0;L<P.length;L++){let F=P[L];new RegExp("^(?:[a-z+]+:)?//","i").test(f)||(F=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${F}`.replace(/([^:]\/)\/+/g,"$1")),N.push(Cn(F,o,i,n,e,s).catch(he=>{throw new kn(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${a.report_name} (${a.report_id}) failed.
32
+ Error fetching ${F}.
33
+ Message: ${he.message}.
34
+ `)}));}let C=await Promise.all(N).catch(L=>L.message);if(typeof C=="string"&&C)return {outputVariables:{},renderVariables:{},status:{error:C}};p=C.length===1?C[0].data:C.map(L=>L.data),g=C.reduce((L,F)=>L+JSON.stringify(F.data).length/1024,0),d=Math.max(...C.map(L=>L.requestDuration)),x=C.map(L=>L.apiDataSource?`${L.apiDataSource.name} (${L.apiDataSource.id})`:null),m=C.map(L=>L.finalUrl);}if(e.type===T.SELECTOR){let{config:P,log:N,error:C}=Lt(e.id,e.contentByLocale[i].content.logic,t,r,true);return {outputVariables:Ar(e.id,c,P),renderVariables:P,status:{log:N,error:C,allowed:u}}}if(e.type===T.MULTIHIERARCHY_SELECTOR){let{config:P,log:N,error:C}=Ot(e.id,e.contentByLocale[i].content.logic,t,r,true);return {outputVariables:vr(e.id,c,P),renderVariables:P,status:{log:N,error:C,allowed:u}}}if(e.type===T.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:u}};if(e.type===T.RELATED){let P=e.contentByLocale?.logic?.content?.simple?.compare||"variant",N=e.contentByLocale?.logic?.content?.simple?.limit||4,C=Object.keys(a).filter(R=>R.startsWith("report_id")).map(R=>a[R]),L=Object.keys(a).filter(R=>R.startsWith("dimension_id")).map(R=>a[R]),F=Object.keys(a).filter(R=>R.startsWith("variant_id")).map(R=>a[R]),B=Object.keys(a).filter(R=>R.startsWith("id")).map(R=>a[R]);if(!B.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:false}};let he=await Promise.all(B.map((R,S)=>o({mode:"ids",locale:i,ids:[R],output:"lite",variant:[F[S]]}))).then(R=>R.flatMap(S=>{let b=[];return at(S)?S.ok&&(b=S.data.results):b=S.results,b&&Array.isArray(b)?b:[]})).catch(R=>(console.error("Error getting related members",R),[]));if(L.length>1){let R=Object.keys(a).filter(w=>w.startsWith("variant_slug")).map(w=>a[w]),S=he.map((w,H)=>{let $={mode:"related",locale:i,related:N??4,current_ids:[w.content_id],output:"full",variant_ids:[w.variant_id]};return H===0&&($.include_ids=[w.content_id]),$}),b=await Promise.all(S.map(w=>o(w))).then(w=>w.flatMap(H=>{let $=[];return at(H)?H.ok&&($=H.data.results):$=H.results,$&&Array.isArray($)?$:[]})).catch(w=>(console.error("Error getting related members",w),[])),Tt=b.reduce((w,H)=>{let $=H.variant_slug;return w[$]||(w[$]=[]),w[$].push(H),w},{}),et=[],Y=Object.keys(Tt),ue=[{combination:[],index:0}];for(;ue.length>0;){let w=ue.pop();if(!w)continue;let{combination:H,index:$}=w;if($===Y.length){et.push(H);continue}let Se=Y[$],Q=Tt[Se];for(let X of Q)ue.push({combination:[...H,X],index:$+1});}return {outputVariables:{related_reports:et.map(w=>{let H=w.sort(($,Se)=>R.indexOf($.variant_slug)-R.indexOf(Se.variant_slug));return {entities:H,link:"/"+H.map($=>`${$.variant_slug}/${$.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:b.length>0}}}let k=he.map(R=>R.content_id),V={mode:"related",locale:i,related:N??4,current_ids:k,output:"full"};P&&(P==="report"?V.report_ids=C:P==="dimension"?V.dimension_ids=L:V.variant_ids=F);let D=await o(V).then(R=>{let S=[];return at(R)?R.ok&&(S=R.data.results):S=R.results,S&&Array.isArray(S)?S:[]}).catch(R=>(console.error("Error getting related members",R),[]));return {outputVariables:{related_reports:D.map(R=>({entities:[R],link:`/${R.variant_slug}/${R.slug}`}))},renderVariables:{},status:{log:[],allowed:D.length>0}}}let{logic:A}=hr(e,i),M=fe(A,t,r),v=xe("resp",p||{},M,t,a,r),{vars:_,error:I,log:j}=v;if(typeof _!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:j,duration:d,responseSize:g,resp:p,api:f,allowed:u,apiFinalUrls:m,apiDataSources:x}};let W=Object.keys(_).reduce((P,N)=>({...P,[`${e.type}${e.id}${N}`]:_[N]}),{});return {renderVariables:_,outputVariables:[T.GENERATOR,T.SECTION_FLAG].includes(e.type)?_:W,status:{log:j,error:I,duration:d,responseSize:g,resp:p,api:f,allowed:u,apiFinalUrls:m,apiDataSources:x}}}function Pn(e,t,r,o,n,s,i){return e.consumers.forEach(a=>{if(t[a]){let c=`${r}-${a}`;!o.includes(c)&&(t[a].section_id===t[r].section_id||!n)&&o.push(c),e.consumers.filter(u=>t[u]&&t[u].section_id===t[r].section_id||!n).forEach(u=>Bt(u,t,o,false,s,n,i));}})}var Bt=(e,t,r=[],o=true,n=true,s=true,i=[])=>{if(i.includes(e))return [];i.push(e);let a=t[e];return a&&a.inputs.length&&o&&a.inputs.forEach(c=>{let u=`${c}-${e}`;r.includes(u)||r.push(u),a.inputs.forEach(p=>Bt(p,t,r,o,false,s,i));}),a&&a.consumers.length&&n&&Pn(a,t,e,r,s,n,i),r},Ln=(e,t,r,o)=>{let n=true;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=false;else {let s=ee(t),{error:i,output:a}=xe("variables",r,e.settings.allowedLogic||"return false;",o,void 0,s);i||(n=!!a);}return n},Mr=async(e,t,r,o,n,s={},i,a="section",c,u)=>{let p=a==="section",l=ee(n),d=l.variables,g={...s.variables??{}},f={...s.status??{}},x=new Set,m=[],A={};r?A={...A,[r]:e[r]}:t?A=(t??[]).reduce((k,{id:V})=>({...k,...xr(V,e)}),{}):A=Object.values(e).filter(k=>It(k)).reduce((k,V)=>({...k,[V.id]:V}),{});let M=Object.values(A).filter(k=>It(k));if(M.length>0){ye&&console.info("%crunConsumers: calculating section flags","color:purple",M.map(y=>y.id).join(", "));let k=Object.fromEntries(await Promise.all(M.map(async y=>[y.id,await wr(y,o,{...l,variables:d,locale:d.locale},i,c,u).then(R=>{let{outputVariables:S,status:b}=R;if(b.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${y.id}, Section ${y.section_id}) failed with message: ${b.error}. `);f[y.id]={allowed:false,error:b.error},g[y.id]={};}return (y.consumers.length>0||[T.GENERATOR,T.SECTION_FLAG,T.RELATED].includes(y.type))&&b.allowed&&Object.keys(S).length>0?g[y.id]=S:g[y.id]={},a==="report"?(f[y.id]={allowed:b.allowed},[T.GENERATOR,T.SECTION_FLAG].includes(y.type)&&b.api&&(f[y.id].api=b.api)):f[y.id]=b,R})]))),D=Object.entries(k).filter(([,y])=>!y.outputVariables[kr]).map(([y])=>Number(y));x=new Set(D.map(y=>e[y].section_id)),Object.values(A).filter(y=>x.has(y.section_id)).forEach(y=>{m.push(y.id),delete A[y.id];}),ye&&console.info("%crunConsumers: removing sections","color:purple",x.keys());}let v=x.size>0?Object.fromEntries(Object.entries(e).filter(([,k])=>x?.has(k.section_id)?(m.includes(k.id)||m.push(k.id),false):true)):e;if(m.length>0&&(v=Object.fromEntries(Object.entries(v).map(([k,V])=>{let D={...V,inputs:V.inputs.filter(y=>!m.includes(y)),consumers:V.consumers.filter(y=>!m.includes(y))};return [k,D]}))),!r&&!t)return {variables:{...s.variables??{},...g},status:{...s.status??{},...f}};a==="report"&&m.length>0&&m.forEach(k=>{delete g[k],delete f[k],delete e[k];}),ye&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(A));let _=Object.keys(A).reduce((k,V)=>{let D=new Date,y=Bt(Number(V),v,[],!r,true,p).map(b=>b.split("-")),S=(new Date().getTime()-D.getTime())/1e3;return ye&&console.info(`%cResolved dependencies for ${V} (${S.toFixed(2)}s)`,"color:blue"),[...k,...y]},[]),I=new Date,j=Object.keys(A).reduce((k,V)=>k.includes(V)?[...k]:[V,...k],hn(_)),P=(new Date().getTime()-I.getTime())/1e3;ye&&console.info(`%cResolved DAG (${P.toFixed(2)}s): `,"color:green",j);let N=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,C=parseInt(`${N||0}`,10);async function L(k,V){let D=new Map,y=[],R=async()=>y.length;for(let S of k){if(C!==0){let Y=await R();for(;Y>=C;)ye&&console.info("Too many pending promises, waiting...",Y,y),await new Promise(ue=>setTimeout(ue,500)),Y=await R();}let b=V[S],et=Promise.all(b.inputs.filter(Y=>k.includes(String(Y))).map(Y=>D.get(Number(Y)))).then(async()=>{let Y=b.inputs.reduce((Q,X)=>({...Q,...g[X]}),d),ue=b.inputs.find(Q=>(b.settings?.ignoreCascade?b.settings?.ignoreCascade:[]).includes(Q)||!f[Q]?false:!f[Q].allowed||f[Q].hiddenByCascade);if(ue){f[S]={allowed:false,hiddenByCascade:f[ue].hiddenByCascade||ue},g[S]={},y.splice(y.indexOf(Number(S)),1);return}let ir=new Date,w;typeof window<"u"&&[T.SELECTOR,T.MULTIHIERARCHY_SELECTOR].includes(b.type)&&b.settings[gr.DISABLED]?w=new Promise(Q=>{Q({outputVariables:g[S],status:f[S]});}):w=wr(b,o,{...l,variables:Y,locale:Y.locale},i,c,u);let H=await w.then(({outputVariables:Q,status:X})=>{if(X.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${S}, Section ${b.section_id}) failed with message: ${X.error}.`);f[S]={allowed:false,error:X.error},g[S]={};}(b.consumers.length>0||[T.GENERATOR,T.SECTION_FLAG,T.RELATED].includes(b.type))&&X.allowed&&Object.keys(Q).length>0?g[S]=Q:g[S]={},a==="report"?(f[S]={allowed:X.allowed},[T.GENERATOR,T.SECTION_FLAG].includes(b.type)&&X.api&&(f[S].api=X.api)):f[S]=X;}),Se=(new Date().getTime()-ir.getTime())/1e3;return ye&&console.info(`%cBlock ${b.id} resolved in ${Se.toFixed(3)}s`,Se>500?"color:red":"color:green"),f[S].duration=f[S].duration?f[S].duration:Se,y.splice(y.indexOf(Number(S)),1),H}).catch(Y=>{throw y.splice(y.indexOf(Number(S)),1),Y});y.push(Number(S)),D.set(Number(S),et);}await Promise.all(Array.from(D.values()));}let F=new Date;await L(j,v);let he=(new Date().getTime()-F.getTime())/1e3;return ye&&console.info(`%cResolved Variables (${he.toFixed(2)}s), ${j.length} blocks`,"color:green"),{variables:{...s.variables??{},...g},status:{...s.status??{},...f}}},du=e=>e<250?"green":e<1e3?"yellow":"red",fu=e=>e<10?"green":e<100?"yellow":"red";function _n(e=[]){return e.reduce((t,r,o)=>{if(r){let n=o+1;t[`id${n}`]=r.id,t[`name${n}`]=r.name,t[`slug${n}`]=r.slug,"attributes"in r&&Object.keys(r.attributes).forEach(s=>{t[`attr_${s}${n}`]=r.attributes[s];}),t[`variant_id${n}`]=r.variant_id,t[`variant_name${n}`]=r.variant_name,t[`variant_slug${n}`]=r.variant_slug,t[`dimension_id${n}`]=r.dimension_id,t[`dimension_name${n}`]=r.dimension_name,t.report_id=r.report_id,t.report_name=r.report_name;}return t},{})}var Dr=_n;function ae(e){if(!e)throw Error("Assertion Error")}function qr(e,t){return +(e<t)-+(e>t)}function ct(e,t,r="ordering"){return qr(t[r],e[r])}function Ge(e){if(e===""||e.charCodeAt(e.length-1)==32)return false;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<32||r>126)return false}return true}function Ur(e){ae(e.length!==0);for(let r=e.length-1;r>=0;r--){let o=e.charCodeAt(r);if(o>33){let n=e.substr(0,r)+String.fromCharCode(o-1);return ae(Ge(n)),n}}let t=e.substr(0,e.length-1)+" ~";return ae(Ge(t)),t}function wt(e){ae(e.length!==0);for(let r=e.length-1;r>=0;r--){let o=e.charCodeAt(r);if(o<126){let n=e.substr(0,r)+String.fromCharCode(o+1);return ae(Ge(n)),n}}let t=e+"!";return ae(Ge(t)),t}function Fr(e,t){return Math.trunc((e+t)/2)}function Vr(e,t){ae(e<t);let r=false,o="",n=Math.max(e.length,t.length);for(let s=0;s<n;s++){let i=s<e.length?e.charCodeAt(s):32,a=s<t.length&&!r?t.charCodeAt(s):126;if(i===a)o+=String.fromCharCode(i);else if(a-i>1){o+=String.fromCharCode(Fr(i,a)),r=false;break}else o+=String.fromCharCode(i),r=true;}return r&&(o+=String.fromCharCode(Fr(32,126))),ae(e<o),ae(o<t),ae(Ge(o)),o}function Eu(e,t,r,o=false,n=true,s="ordering"){if(o)return r===0?e[t[0]]?Ur(e[t[0]][s]):"!":r===t.length?wt(e[t[r-1]][s]):Vr(e[t[r-1]][s],e[t[r]][s]);if(r===0)return Ur(e[t[r]][s]);if(r===t.length-1)return wt(e[t[r]][s]);let i=n?r:r-1,a=n?r+1:r;return Vr(e[t[i]][s],e[t[a]][s])}function hu(e,t=false){let r=e.reduce((o,n)=>qr(n,o)<0?n:o,"!");return t?wt(r):r}var{localeDefault:In}=se();var He=new schema.Entity("block",{},{mergeStrategy(e,t){return t.block_input?e||{}:{...e,...t}}});He.define({consumers:[He],inputs:[He]});var $r=new schema.Entity("variant"),zr=new schema.Entity("dimension",{variants:[$r]},{processStrategy(e){return {...e,variants:"variants"in e?e.variants:[]}}}),jr=new schema.Entity("section",{blocks:[He]}),Bn=new schema.Entity("report",{dimensions:[zr],sections:[jr]},{processStrategy(e){return {...e,sections:"sections"in e?e.sections.sort(ct):[]}}}),wn=new schema.Entity("formatter"),Nn=new schema.Entity("datasource"),Mn={report:Bn,section:jr,block:He,dimension:zr,variant:$r,formatter:wn,datasource:Nn};function ut(e,t){let r=Mn[e];if(!r)throw new Error(`Invalid entity type: ${e}`);let{entities:o}=normalize(t,[r]);return {report:Ce(o,"report"),dimension:Ce(o,"dimension"),section:Ce(o,"section"),block:Ce(o,"block"),variant:Ce(o,"variant"),formatter:Ce(o,"formatter"),datasource:Ce(o,"datasource")}}function Ce(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}var Gr=(e,t=void 0)=>{let{sid:r,bid:o,previews:n=[],query:s={}}=t||{},i,a,c={};return r?(i=r,c.activeSection=i):i=e.activeSection,n.length>0?(a=n,c.previews=a.filter(Boolean)):a=e.previews,{parsedParams:{sid:i,bid:o,previews:a,query:s},statusPayload:c}},Hr=(e=[],t=In)=>e.reduce((r,o)=>{let n=Lr({vars:["n"],logic:o.content.logic},{},t,{});return r[o.name]=n,r},{});var Pe=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",lt=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[Pe];lt.includes(Pe)||lt.push(Pe);var Fn={localeDefault:Pe,locales:lt,currentLocale:Pe,preferredLocale:Pe,showToolbar:false,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:true,settings:false,reportEditor:false},isCMS:false,isRunConsumersRunning:[]},pt=createSlice({name:"status",initialState:Fn,reducers:{setStatus:(e,t)=>{Object.assign(e,t.payload);},setPreviews(e,t){e.previews=t.payload;},setCurrentLocale(e,t){e.currentLocale=t.payload;},setPreferredLocale(e,t){e.preferredLocale=t.payload;},setSectionState(e,t){e.sectionState={...e.sectionState,...t.payload};},resetSectionState(e,t){e.sectionState={...e.sectionState,[t.payload]:{}};},setActiveEntity(e,t){e.activeEntity=t.payload;},openSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:true};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:false};},toggleSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!e.sidebarStatus[t.payload]};},addRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.concat(t.payload);},removeRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.filter(r=>!t.payload.includes(r));}},extraReducers:{[HYDRATE]:(e,t)=>({...e,previews:t.payload.status.previews})}}),re=pt.actions;var $n={attributes:{},variables:{},status:{}},dt=createSlice({name:"variables",initialState:$n,reducers:{setVariableChange:(e,t)=>{e.attributes={...e.attributes,...t.payload.attributes},e.variables={...e.variables,...t.payload.variables},e.status={...e.status,...t.payload.status};}},extraReducers:{[HYDRATE]:(e,t)=>({attributes:{...e.attributes,...t.payload.variables.attributes},status:{...e.status,...t.payload.variables.status},variables:{...e.variables,...t.payload.variables.variables}})}}),Kr=dt.actions;var Gn={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},le=createSlice({name:"records",initialState:Gn,reducers:{set:(e,t)=>{let r=t.payload;return {entities:Ke(e.entities,r.entities||{}),requests:Ke(e.requests,r.requests||{}),reports:r.reports||e.reports,tree:r.tree||e.tree}},setRequest:(e,t)=>{let r=t.payload;e.requests[r.type][r.key]=r;},setCreateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=ut(r.type,o),s=Ke(e.entities,n);if(e.entities=s,r.type==="report"){let i=r.data;e.reports?e.reports.indexOf(i.id)===-1&&(e.reports=[...e.reports,i.id]):e.reports=[i.id];}else if(r.type==="dimension"){let i=r.data;e.entities.report[i.report_id].dimensions.push(i.id),e.entities.report[i.report_id].dimensions=ft(s.report[i.report_id].dimensions,s.dimension);}else if(r.type==="variant"){let i=r.data;e.entities.dimension[i.dimension_id].variants.push(i.id);}else if(r.type==="section"&&!Array.isArray(r.data)){let i=r.data;e.entities.report[i.report_id].sections.push(i.id),e.entities.report[i.report_id].sections=ft(s.report[i.report_id].sections,s.section);}else if(r.type==="block")if(Array.isArray(r.data)){let i=r.data,a=i[0],c=i.map(u=>u.id);e.entities.section[a.section_id].blocks.concat(c);}else {let i=r.data;e.entities.section[i.section_id].blocks.push(i.id);}}},setReadRequest(e,t){let r=t.payload;if(r.type!=="report"&&(e.requests[r.type][r.key]=r),r.status==="SUCCESS"){let o=ut(r.type,r.data),n=Ke(e.entities,o);e.entities=n;}},setUpdateRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let o=Array.isArray(r.data)?r.data:[r.data],n=ut(r.type,o),s,i,a;if(r.type==="block"&&!Array.isArray(r.data)){let u=e.entities.block[r.data.id].inputs,p=n.block[r.data.id].inputs;s=u.length!==p.length,s&&(a=u.length>p.length,i=a?u.filter(l=>!p.includes(l))[0]:p.filter(l=>!u.includes(l))[0]),Object.values(n.block).forEach(l=>{l.block_input&&delete n.block[l.id];});}let c=Ke(e.entities,n);if(e.entities=c,r.type==="dimension"){let u=r.data;e.entities.report[u.report_id].dimensions=ft(c.report[u.report_id].dimensions,c.dimension);}else if(r.type==="section"&&!Array.isArray(r.data)){let u=r.data;e.entities.report[u.report_id].sections=ft(c.report[u.report_id].sections,c.section);}else if(r.type==="block"&&!Array.isArray(r.data)){let u=r.data;s&&(a?e.entities.block[i].consumers=e.entities.block[i].consumers.filter(p=>p!==u.id):e.entities.block[i].consumers.push(u.id));}}},setDeleteRequest(e,t){let r=t.payload;if(e.requests[r.type][r.key]=r,r.status==="SUCCESS"){let{id:o,parentId:n,parentType:s}=r.data;if(delete e.entities[r.type][o],s&&n!=null){let i=`${r.type}s`;Hn(e.entities[s][n][i],o);}}},removeBlocks:(e,t)=>{let r=t.payload,o={...e.entities.block};return r.forEach(n=>{delete o[n];}),{...e,entities:{...e.entities,block:o}}},addBlocks:(e,t)=>{let r=t.payload;return {...e,entities:{...e.entities,block:{...e.entities.block,...r}}}},removeDataSourceLogic:e=>{let t={...e.entities.datasource};Object.keys(t).forEach(r=>{e.entities.datasource[r].content.useProxy&&(delete e.entities.datasource[r].content.logic,delete e.entities.datasource[r].content.logic_ssr,delete e.entities.datasource[r].content.testUrl,delete e.entities.datasource[r].content.access);});}},extraReducers:{[HYDRATE]:(e,t)=>{let r=t.payload.records,o=r.entities;return {entities:o,reports:Object.values(o.report).map(n=>n.id),requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},tree:r.tree}}}});function Ke(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,{...e[r],...t[r]}]))}function ft(e,t){return e.map(n=>t[n]).sort((n,s)=>typeof n.ordering=="string"&&typeof s.ordering=="string"?ct(n,s):typeof n.ordering=="number"&&typeof s.ordering=="number"?n.ordering-s.ordering:String(n.ordering).localeCompare(String(s.ordering))).map(n=>n.id)}function Hn(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1);}var Nt=class extends Error{constructor(t,r){super(r),this.code=t;}toJSON(){return Wr(this)}static is(t){return Object.prototype.hasOwnProperty.call(t,"code")&&typeof t.code=="number"}};function Kn(e){return {ok:true,status:200,wrapper:true,data:e}}function Wr(e){return {ok:false,status:Nt.is(e)?e.code:500,error:e.message}}function Yu(e){return t=>e(t).then(Kn,Wr)}function Le(e,t,r){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${Yr(r)}`;return e[n]}let o=`${t}${Yr(r)}`;return e[o]}function Yr(e){return e[0].toUpperCase()+e.slice(1)}function K(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];if(process.env.NODE_ENV!=="production"){var n=ts[e],s=n?typeof n=="function"?n.apply(null,r):n:"unknown error nr: "+e;throw Error("[Immer] "+s)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map((function(i){return "'"+i+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Ve(e){return !!e&&!!e[Z]}function Oe(e){var t;return !!e&&((function(r){if(!r||typeof r!="object")return false;var o=Object.getPrototypeOf(r);if(o===null)return true;var n=Object.hasOwnProperty.call(o,"constructor")&&o.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===rs})(e)||Array.isArray(e)||!!e[oo]||!!(!((t=e.constructor)===null||t===void 0)&&t[oo])||Gt(e)||Ht(e))}function We(e,t,r){r===void 0&&(r=false),$e(e)===0?(r?Object.keys:Xt)(e).forEach((function(o){r&&typeof o=="symbol"||t(o,e[o],e);})):e.forEach((function(o,n){return t(n,o,e)}));}function $e(e){var t=e[Z];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:Gt(e)?2:Ht(e)?3:0}function Vt(e,t){return $e(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Yn(e,t){return $e(e)===2?e.get(t):e[t]}function no(e,t,r){var o=$e(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r;}function Wn(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function Gt(e){return Jn&&e instanceof Map}function Ht(e){return es&&e instanceof Set}function _e(e){return e.o||e.t}function Kt(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=os(e);delete t[Z];for(var r=Xt(t),o=0;o<r.length;o++){var n=r[o],s=t[n];s.writable===false&&(s.writable=true,s.configurable=true),(s.get||s.set)&&(t[n]={configurable:true,writable:true,enumerable:s.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function Yt(e,t){return t===void 0&&(t=false),Wt(e)||Ve(e)||!Oe(e)||($e(e)>1&&(e.set=e.add=e.clear=e.delete=Qn),Object.freeze(e),t&&We(e,(function(r,o){return Yt(o,true)}),true)),e}function Qn(){K(2);}function Wt(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function ie(e){var t=ns[e];return t||K(18,e),t}function Qr(){return process.env.NODE_ENV==="production"||qe||K(0),qe}function Mt(e,t){t&&(ie("Patches"),e.u=[],e.s=[],e.v=t);}function mt(e){qt(e),e.p.forEach(Xn),e.p=null;}function qt(e){e===qe&&(qe=e.l);}function Xr(e){return qe={p:[],l:qe,h:e,m:true,_:0}}function Xn(e){var t=e[Z];t.i===0||t.i===1?t.j():t.g=true;}function Dt(e,t){t._=t.p.length;var r=t.p[0],o=e!==void 0&&e!==r;return t.h.O||ie("ES5").S(t,e,o),o?(r[Z].P&&(mt(t),K(4)),Oe(e)&&(e=yt(t,e),t.l||Rt(t,e)),t.u&&ie("Patches").M(r[Z].t,e,t.u,t.s)):e=yt(t,r,[]),mt(t),t.u&&t.v(t.u,t.s),e!==so?e:void 0}function yt(e,t,r){if(Wt(t))return t;var o=t[Z];if(!o)return We(t,(function(a,c){return Zr(e,o,t,a,c,r)}),true),t;if(o.A!==e)return t;if(!o.P)return Rt(e,o.t,true),o.t;if(!o.I){o.I=true,o.A._--;var n=o.i===4||o.i===5?o.o=Kt(o.k):o.o,s=n,i=false;o.i===3&&(s=new Set(n),n.clear(),i=true),We(s,(function(a,c){return Zr(e,o,n,a,c,r,i)})),Rt(e,n,false),r&&e.u&&ie("Patches").N(o,r,e.u,e.s);}return o.o}function Zr(e,t,r,o,n,s,i){if(process.env.NODE_ENV!=="production"&&n===r&&K(5),Ve(n)){var a=yt(e,n,s&&t&&t.i!==3&&!Vt(t.R,o)?s.concat(o):void 0);if(no(r,o,a),!Ve(a))return;e.m=false;}else i&&r.add(n);if(Oe(n)&&!Wt(n)){if(!e.h.D&&e._<1)return;yt(e,n),t&&t.A.l||Rt(e,n);}}function Rt(e,t,r){r===void 0&&(r=false),!e.l&&e.h.D&&e.m&&Yt(t,r);}function Ut(e,t){var r=e[Z];return (r?_e(r):e)[t]}function Jr(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Object.getPrototypeOf(r);}}function $t(e){e.P||(e.P=true,e.l&&$t(e.l));}function Ft(e){e.o||(e.o=Kt(e.t));}function zt(e,t,r){var o=Gt(t)?ie("MapSet").F(t,r):Ht(t)?ie("MapSet").T(t,r):e.O?(function(n,s){var i=Array.isArray(n),a={i:i?1:0,A:s?s.A:Qr(),P:false,I:false,R:{},l:s,t:n,k:null,o:null,j:null,C:false},c=a,u=jt;i&&(c=[a],u=Ye);var p=Proxy.revocable(c,u),l=p.revoke,d=p.proxy;return a.k=d,a.j=l,d})(t,r):ie("ES5").J(t,r);return (r?r.A:Qr()).p.push(o),o}function Zn(e){return Ve(e)||K(22,e),(function t(r){if(!Oe(r))return r;var o,n=r[Z],s=$e(r);if(n){if(!n.P&&(n.i<4||!ie("ES5").K(n)))return n.t;n.I=true,o=eo(r,s),n.I=false;}else o=eo(r,s);return We(o,(function(i,a){n&&Yn(n.t,i)===a||no(o,i,t(a));})),s===3?new Set(o):o})(e)}function eo(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Kt(e)}var to,qe,Qt=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",Jn=typeof Map<"u",es=typeof Set<"u",ro=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",so=Qt?Symbol.for("immer-nothing"):((to={})["immer-nothing"]=true,to),oo=Qt?Symbol.for("immer-draftable"):"__$immer_draftable",Z=Qt?Symbol.for("immer-state"):"__$immer_state";var ts={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return "Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return "Unsupported patch operation: "+e},18:function(e){return "The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return "'current' expects a draft, got: "+e},23:function(e){return "'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},rs=""+Object.prototype.constructor,Xt=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,os=Object.getOwnPropertyDescriptors||function(e){var t={};return Xt(e).forEach((function(r){t[r]=Object.getOwnPropertyDescriptor(e,r);})),t},ns={},jt={get:function(e,t){if(t===Z)return e;var r=_e(e);if(!Vt(r,t))return (function(n,s,i){var a,c=Jr(s,i);return c?"value"in c?c.value:(a=c.get)===null||a===void 0?void 0:a.call(n.k):void 0})(e,r,t);var o=r[t];return e.I||!Oe(o)?o:o===Ut(e.t,t)?(Ft(e),e.o[t]=zt(e.A.h,o,e)):o},has:function(e,t){return t in _e(e)},ownKeys:function(e){return Reflect.ownKeys(_e(e))},set:function(e,t,r){var o=Jr(_e(e),t);if(o?.set)return o.set.call(e.k,r),true;if(!e.P){var n=Ut(_e(e),t),s=n?.[Z];if(s&&s.t===r)return e.o[t]=r,e.R[t]=false,true;if(Wn(r,n)&&(r!==void 0||Vt(e.t,t)))return true;Ft(e),$t(e);}return e.o[t]===r&&(r!==void 0||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=true),true},deleteProperty:function(e,t){return Ut(e.t,t)!==void 0||t in e.t?(e.R[t]=false,Ft(e),$t(e)):delete e.R[t],e.o&&delete e.o[t],true},getOwnPropertyDescriptor:function(e,t){var r=_e(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:true,configurable:e.i!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty:function(){K(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){K(12);}},Ye={};We(jt,(function(e,t){Ye[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};})),Ye.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&K(13),Ye.set.call(this,e,t,void 0)},Ye.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&K(14),jt.set.call(this,e[0],t,r,e[0])};var ss=(function(){function e(r){var o=this;this.O=ro,this.D=true,this.produce=function(n,s,i){if(typeof n=="function"&&typeof s!="function"){var a=s;s=n;var c=o;return function(x){var m=this;x===void 0&&(x=a);for(var A=arguments.length,M=Array(A>1?A-1:0),v=1;v<A;v++)M[v-1]=arguments[v];return c.produce(x,(function(_){var I;return (I=s).call.apply(I,[m,_].concat(M))}))}}var u;if(typeof s!="function"&&K(6),i!==void 0&&typeof i!="function"&&K(7),Oe(n)){var p=Xr(o),l=zt(o,n,void 0),d=true;try{u=s(l),d=!1;}finally{d?mt(p):qt(p);}return typeof Promise<"u"&&u instanceof Promise?u.then((function(x){return Mt(p,i),Dt(x,p)}),(function(x){throw mt(p),x})):(Mt(p,i),Dt(u,p))}if(!n||typeof n!="object"){if((u=s(n))===void 0&&(u=n),u===so&&(u=void 0),o.D&&Yt(u,true),i){var g=[],f=[];ie("Patches").M(n,u,g,f),i(g,f);}return u}K(21,n);},this.produceWithPatches=function(n,s){if(typeof n=="function")return function(u){for(var p=arguments.length,l=Array(p>1?p-1:0),d=1;d<p;d++)l[d-1]=arguments[d];return o.produceWithPatches(u,(function(g){return n.apply(void 0,[g].concat(l))}))};var i,a,c=o.produce(n,s,(function(u,p){i=u,a=p;}));return typeof Promise<"u"&&c instanceof Promise?c.then((function(u){return [u,i,a]})):[c,i,a]},typeof r?.useProxies=="boolean"&&this.setUseProxies(r.useProxies),typeof r?.autoFreeze=="boolean"&&this.setAutoFreeze(r.autoFreeze);}var t=e.prototype;return t.createDraft=function(r){Oe(r)||K(8),Ve(r)&&(r=Zn(r));var o=Xr(this),n=zt(this,r,void 0);return n[Z].C=true,qt(o),n},t.finishDraft=function(r,o){var n=r&&r[Z];process.env.NODE_ENV!=="production"&&(n&&n.C||K(9),n.I&&K(10));var s=n.A;return Mt(s,o),Dt(void 0,s)},t.setAutoFreeze=function(r){this.D=r;},t.setUseProxies=function(r){r&&!ro&&K(20),this.O=r;},t.applyPatches=function(r,o){var n;for(n=o.length-1;n>=0;n--){var s=o[n];if(s.path.length===0&&s.op==="replace"){r=s.value;break}}n>-1&&(o=o.slice(n+1));var i=ie("Patches").$;return Ve(r)?i(r,o):this.produce(r,(function(a){return i(a,o)}))},e})(),J=new ss,as=J.produce;J.produceWithPatches.bind(J);J.setAutoFreeze.bind(J);J.setUseProxies.bind(J);J.applyPatches.bind(J);J.createDraft.bind(J);J.finishDraft.bind(J);var gt=as;var oe=le.actions,Et={create:Zt,read:mo,update:Jt,delete:yo,clone:Ro},uo=Xe({block:Re("block"),dimension:Re("dimension"),formatter:Re("formatter"),report:Re("report"),section:Re("section"),variant:Re("variant"),datasource:Re("datasource")}),Qe=Xe({block:ge("block"),dimension:ge("dimension"),formatter:ge("formatter"),report:ge("report"),section:ge("section"),variant:ge("variant"),datasource:ge("datasource")}),lo=Xe({block:ce("block"),dimension:ce("dimension"),formatter:ce("formatter"),report:ce("report"),section:ce("section"),variant:ce("variant"),datasource:ce("datasource")}),po=Xe({block:Ie("block"),dimension:Ie("dimension"),formatter:Ie("formatter"),report:Ie("report"),section:Ie("section"),variant:Ie("variant"),datasource:Ie("datasource")}),fo=Xe({block:io("block"),section:io("section")});function Xe(e){return (t,r)=>{let o=e[t];if(!o)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return o(r)}}function we(e,t){return (r,o)=>{let s=o().records.requests[e][t],i=!s||s.status==="UNINITIALIZED"?"LOADING":"FETCHING";r(oe.setRequest({key:t,type:e,status:i}));}}function Be(e,t,r,o){return n=>{typeof window=="object"&&notifications.show({autoClose:3e3,color:"red",id:t,message:o,title:"Error"}),n(oe.setRequest({key:t,type:e,status:"FAILURE",error:{code:r,message:o}}));}}function Re(e){return t=>{let r=Zt(e,t);return (o,n,s)=>(o(we(e,r)),Le(s,"create",e)(t).then(a=>(a.ok===true?o(oe.setCreateRequest({key:r,operation:"create",status:"SUCCESS",type:e,data:a.data})):o(Be(e,r,a.status,a.error)),a)))}}function us(e){return t=>{let r=Zt(e,t[0]);return (o,n,s)=>(o(we(e,r)),Le(s,"createBulk",e)(t).then(a=>(a.ok===true?o(oe.setCreateRequest({key:r,operation:"createBulk",status:"SUCCESS",type:e,data:a.data})):o(Be(e,r,a.status,a.error)),a)))}}function ao(e,t,r){return r.replace(new RegExp(e,"g"),t)}function ls(e){return e.section_id!==void 0}function ps(e){return e.report_id!==void 0}function io(e){return t=>{let{create:r}=t;return (o,n,s)=>Re(e)(r)(o,n,s).then(async a=>{if(a.ok){let{data:c}=a,{id:u}=c,{update:p}=t,l=Ro(e,{id:u});if(o(we(e,`${l}`)),e==="block"&&ls(r)){let d=gt(p,m=>{m.id=u;}),{contentByLocale:g}=d;g&&(d=gt(d,m=>{m.id=u,m.contentByLocale=Object.keys(g).reduce((A,M)=>{let v=g?g[M]:{};return A[M]={...v,id:u},A},{});}));let x=d.inputs?.map(m=>({type:m.type,id:m.id,inputAction:{operation:"create",input:{input_id:m.id,block_id:d.id}}}));return x&&x.length>0&&co(e)([d,...x])(o,n,s).then(()=>ge("section")({id:d.section_id,include:true})(o,n,s).then(m=>(m.ok&&o(oe.setRequest({key:l,type:e,status:"SUCCESS",data:m.data})),m))),ce(e)(d)(o,n,s).then(m=>(m.ok&&o(oe.setRequest({key:l,type:e,status:"SUCCESS",data:m.data})),m))}if(e==="section"&&ps(r)){let{id:d}=c,g=gt(p,m=>{m.id=d;}),{blocks:f}=g,x=f?.map(m=>({type:m.type,blockcol:m.blockcol,blockrow:m.blockrow,section_id:d,locales:Object.keys(m.contentByLocale).map(A=>A)}));return x&&f&&await us("block")(x)(o,n,s).then(m=>{if(m.ok){let A=m.data,M=[],v=A.map((_,I)=>{let W={..._},P=W.id,N=f[I];N.contentByLocale&&(W.contentByLocale=Object.keys(N.contentByLocale).reduce((D,y)=>{let R=N.contentByLocale[y];return D[y]={...R,content:{...R.content},id:W.id},D},{}));let{settings:C}=N,{contentByLocale:L,id:F}=W;W.settings=C;let B={id:F,contentByLocale:L,settings:C};return N.inputs.map(D=>D.id).reduce((D,y)=>{let R=f.findIndex(S=>S.id===y);return [...D,R]},[]).map(D=>({...A[D],originalBlock:f[D]})).forEach(D=>{let{id:y,type:R,originalBlock:S}=D;if([T.SELECTOR,T.VIZ].includes(R)){if(B.contentByLocale?.logic?.content?.api){let b=B.contentByLocale?.logic.content.api;B.contentByLocale.logic.content.api=ao(`(selector${S.id}id)`,`selector${y}id`,b);}if(B.contentByLocale?.logic?.content?.logic){let b=B.contentByLocale.logic.content.logic;B.contentByLocale.logic.content.logic=ao(`(selector${S.id}id)`,`selector${y}id`,b);}}M.push({id:y,inputAction:{operation:"create",input:{input_id:y,block_id:P}}});}),B});return co("block")([...v,...M])(o,n,s)}}),ce(e)(g)(o,n,s).then(m=>(m.ok&&o(oe.setRequest({key:l,type:e,status:"SUCCESS",data:m.data})),m))}return ce(e)({...p,id:c.id})(o,n,s)}})}}function ge(e){return t=>{let r=mo(e,t);return (o,n,s)=>{o(we(e,r));let i=Le(s,"read",e);if(typeof i!="function"){let a=`Failed to get valid RPC method for entity "${e}"`;return o(Be(e,r,500,a)),Promise.reject(new Error(a))}return i(t).then(a=>(a.ok===true?o(oe.setReadRequest({key:r,operation:"read",status:"SUCCESS",type:e,data:a.data})):o(Be(e,r,a.status,a.error)),a))}}}function ce(e){return t=>{let r=Jt(e,t);return (o,n,s)=>(o(we(e,r)),Le(s,"update",e)(t).then(a=>(a.ok===true?o(oe.setUpdateRequest({key:r,operation:"update",status:"SUCCESS",type:e,data:a.data})):o(Be(e,r,a.status,a.error)),a)))}}function co(e){return t=>{let r=Jt(e,t[0]);return (o,n,s)=>(o(we(e,r)),Le(s,"updateBulk",e)(t).then(a=>(a.ok===true?o(oe.setUpdateRequest({key:r,operation:"updateBulk",status:"SUCCESS",type:e,data:a.data})):o(Be(e,r,a.status,a.error)),a)))}}function Ie(e){return t=>{let r=yo(e,t);return (o,n,s)=>(o(we(e,r)),Le(s,"delete",e)(t).then(a=>{a.ok===true?o(oe.setDeleteRequest({key:r,operation:"delete",status:"SUCCESS",type:e,data:a.data})):o(Be(e,r,a.status,a.error));}))}}function Zt(e,t){if(e==="variant"){let r=t;return `create(variant, [${r.dimension_id}, ${r.name}])`}return `create(${e}, [${Object.keys(t)}])`}function mo(e,t={}){let r=t.id==null?null:`'${t.id}'`;return `read(${e}, ${r}, ${!!t.include})`}function Jt(e,t){let{id:r,...o}=t;return `update(${e}, ${r}, [${Object.keys(o)}])`}function yo(e,t){return `delete(${e}, ${t})`}function Ro(e,t){let r=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${r})`}var{setStatus:go,setPreviews:ds,setSectionState:Ze,resetSectionState:Je,setCurrentLocale:fs,setPreferredLocale:ms,addRunConsumersRunning:er,removeRunConsumersRunning:tr}=re;function ys(e,t){return async(r,o,n)=>{let s=await n.validateVariantSlug({dimension:e,slug:t});if("error"in s)throw new Error(s.error);return s.data}}function Rs(e){return async(t,r,o)=>{let n=await o.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function gs(){return async(e,t,r)=>{let o=await r.regenerateSearch(void 0);if("error"in o)throw new Error(o.error);return o.data}}function Eo(e){return async(t,r,o)=>{let n=await o.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function Es(e){return async(t,r,o)=>{let n=await o.searchMember(e);if(n.ok===true)return n.data;throw new Error(n.error)}}async function ho(e,t,r,o,n){let s=r().status,i={...s,...o},a={...s.query,...o.query};Object.keys(a).forEach(u=>a[u]===void 0&&delete a[u]);let c={...i,query:a};t(go(c)),s.activeSection&&t(ht(e,{query:a},n));}function hs(e,t,r){return async(o,n)=>ho(e,o,n,{query:{[t]:void 0}},r)}function Ss(e,t,r,o){return async(n,s)=>ho(e,n,s,{query:{[t]:r}},o)}function ht(e,t,r){return async(o,n)=>{let s=n(),{currentLocale:i}=s.status,a=s.records.entities.block,c=e.formatterFunctions[i],u=e.datasourceFunctions,{parsedParams:p,statusPayload:l}=Gr(s.status,t),{sid:d,bid:g,previews:f,query:x}=p;Object.keys(l).length&&o(re.setStatus(l));let m={...Dr(f),locale:i,...Fe()},A={variables:m,query:x,locale:i};o(re.addRunConsumersRunning([d]));let M=s.records.entities.section[d],v=async _=>o(Eo(_));try{let _=await Mr(a,M&&[M],g,c,A,void 0,v,"section",u,r),{variables:I,status:j}=_;o(Kr.setVariableChange({attributes:m,variables:I,status:j})),o(re.removeRunConsumersRunning([d]));}catch(_){console.error("Error in runConsumers client side: recalculateVariables",_);}}}function Ts(e){return async(t,r,o)=>{let n=await o.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function bs(e){return async(t,r,o)=>{let n=await o.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function As(){return async(e,t,r)=>{let o=await r.searchRole("");if("error"in o)throw new Error(o.error);return o.data}}function vs(e){return async(t,r,o)=>{let n=await o.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function xs(e){return async(t,r,o)=>{let n=await o.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function Cs({user:e}){return async(t,r,o)=>{let n=await o.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function ks(e){return async(t,r,o)=>{let n=await o.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function Ps(e){let{removeBlocks:t}=le.actions;return async r=>{await r(t(e));}}function Ls(e){let{addBlocks:t}=le.actions;return async r=>{await r(t(e));}}function _s(e){return async(t,r,o)=>{let n=await o.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function Os(e){return async(t,r,o)=>{let n=await o.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function Is(e){return async(t,r,o)=>{let n=await o.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function Bs(){return async(e,t,r)=>{let o=await r.readEnvSecrets({});if("error"in o)throw new Error(o.error);return o.data}}function ws(){let{removeDataSourceLogic:e}=le.actions;return async t=>{await t(e());}}var So=()=>configureStore({reducer:{[le.name]:le.reducer,[pt.name]:pt.reducer,[dt.name]:dt.reducer},middleware(e){return e({thunk:{extraArgument:je("/api/cms/")}})}}),Ds=createWrapper(So);function Fs(e,t){let r=o=>{let{id:n,skelHeight:s,skelWidth:i,...a}=o,c=t(n);return c.isUninitialized||c.isFetching?jsx(Skeleton,{width:i,height:s}):c.isError?null:jsx(e,{...a,for:c.data})};return r.displayName=`withFetcher(${e.displayName||e.name||"Component"})`,r}var {locales:bo}=se(),ta={pathSegment:"path",formatterFunctions:bo.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",previewPrefix:null,siteProps:{}},Ne=createContext(ta);function Jl(e){let {pathSegment:t,profilePrefix:r,previewPrefix:o,siteProps:n}=e,s=or();U(l=>l.status.isCMS);let a=nr(),u={...Fe()},p=useMemo(()=>({profilePrefix:r,previewPrefix:o,pathSegment:t,siteProps:n,formatterFunctions:bo.reduce((l,d)=>({...l,[d]:s.data?Hr(s.data,d):{}}),{}),datasourceFunctions:(a?.data||[]).sort((l,d)=>l.content.order>d.content.order?1:-1).map(l=>({...l,content:{...l.content,pattern:fe(l.content.pattern,{},{variables:u})}}))}),[s,t,r,o,n,a]);return jsx(Ne.Provider,{value:p,children:e.children})}function ep(){let e=useContext(Ne);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var {localeDefault:aa}=se(),pe=useDispatch,U=useSelector,Vs=Me("report"),qs=Me("dimension"),$s=Me("variant"),zs=Me("section"),js=Me("block"),or=Me("formatter"),nr=Me("datasource"),Gs=De("report"),Hs=De("section"),sr=De("block"),Ks=De("dimension"),Ys=De("variant"),Ws=De("formatter"),Qs=De("datasource");function Ep(){let e=U(n=>n.status.activeEntity),t=pe();return {activeEntity:e,selectEntity:n=>t(re.setActiveEntity(n)),unselectEntity:()=>t(re.setActiveEntity({type:null,id:null}))}}var ia=(e,t=void 0,r=void 0)=>{if(!e)return {};let o=sr(e).data,n=U(a=>t||a.variables.variables),s=U(a=>r||a.variables.attributes);return useMemo(()=>o?o.inputs.reduce((a,c)=>({...a,...n[c]}),s):{},[o,s,n])},hp=e=>{let t=sr(e).data,r=U(s=>s.variables.variables),o=U(s=>s.variables.attributes);return t?useMemo(()=>t?Object.keys(r).reduce((s,i)=>({...s,...t.inputs.includes(parseInt(i,10))?{[i]:r[i]}:{}}),{attributes:o}):{attributes:o},[t,r,o]):{}};var Sp=e=>U(t=>t.variables.status[e]),Tp=(e=aa)=>useContext(Ne).formatterFunctions[e],bp=()=>useContext(Ne).datasourceFunctions,Ap=()=>useContext(Ne).profilePrefix,vp=()=>useContext(Ne).previewPrefix,xp=(e=void 0,t=void 0)=>{let r=U(s=>s.status.localeDefault),o=U(s=>s.status.query);return {variables:ia(e),locale:t||r,query:o}},vo=(e,t)=>Object.values(t).filter(o=>Object.keys(o.contentByLocale).some(n=>{let{logic:s}=o.contentByLocale[n].content;return s&&(`${s}`.includes(`formatters.${e}(`)||`${s}`.includes(`${e}{{`))})).length,Cp=e=>{if(!e)return 0;let t=U(o=>o.records.entities.formatter),r=U(o=>o.records.entities.block);return useMemo(()=>vo(e,r),[e,t,r])},kp=()=>{let e=U(r=>r.records.entities.formatter),t=U(r=>r.records.entities.block);return useMemo(()=>Object.values(e).reduce((r,o)=>(r[o.name]=vo(o.name,t),r),{}),[e,t])};function Pp(e){let t=pe(),r=U(a=>a.status.sectionState)[e]||{},o=b(),n=useRef(r);n.current=r;let s=useCallback(a=>{let c=n.current,u={},p=Array.from(new Set([...Object.keys(c),...Object.keys(a)]));for(let l of p)c[l]!==a[l]&&(u[l]={from:c[l],to:a[l]});o("section_variables_change",{sectionId:e,prev:{...c},next:{...a},changes:u}),t(Ze({[e]:a}));},[e,o]),i=useCallback(()=>{t(Je(e));},[e]);return {sectionVariables:r,setSectionVariables:s,resetSectionVariables:i}}function Lp(e){let t=pe(),r=U(c=>c.status.sectionState),o=useMemo(()=>e.reduce((c,u)=>(c[u]=r[u]||{},c),{}),[e,r]),n=useCallback(c=>{t(Ze(c));},[]),s=useCallback(()=>{e.map(u=>Je(u)).forEach(u=>t(u));},[e]),i=useCallback(c=>u=>{t(Ze({[c]:u}));},[]),a=useCallback(c=>()=>{t(Je(c));},[]);return {sectionsVariables:o,setSectionsVariables:n,resetSectionsVariables:s,setSectionVariables:i,resetSectionVariables:a}}function _p(){let e=pe(),t=U(n=>n.status.isRunConsumersRunning),r=useCallback(n=>{e(er(n));},[]),o=useCallback(n=>{e(tr(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:r,removeRunConsumersRunning:o}}function Op(e){let t=pe(),r=a$1();return useCallback(o=>t(ht(e,o,r)),[t,e,r.status])}function Ip(e){let t=pe();return {opened:U(a=>a.status.sidebarStatus[e]),handlers:{open:()=>t(re.openSidebar(e)),close:()=>t(re.closeSidebar(e)),toggle:()=>t(re.toggleSidebar(e))}}}function Bp(){return U(t=>t.status.currentLocale)}function wp(){return U(t=>t.status.preferredLocale)}function Me(e){return t=>{let r=pe(),o=useMemo(()=>Et.read(e,{include:true}),[]),n=useCallback(i=>{let a=Object.values(i.records.entities[e]),c=i.records.requests[e][o]||{status:a==null?"UNINITIALIZED":"SUCCESS"},u=t?a.filter(p=>t.includes(p.id)):a;return ar(u,c)},[o]),s=U(n);return useEffect(()=>{s.isUninitialized&&r(Qe(e,{id:t,include:true}));},[s.status]),s}}function Xs(e,t){let r=useMemo(()=>Et.clone(e,{id:t}),[t,e]);return U(n=>{let s=n.records.entities[e][t],i=n.records.requests[e][r]||{status:s==null?"UNINITIALIZED":"SUCCESS"};return ar(s,i)})}function De(e){return t=>{let r=pe(),o=useMemo(()=>Et.read(e,{id:t,include:true}),[t]),n=useCallback(i=>{let a=i.records.entities[e][t],c=i.records.requests[e][o]||{status:a==null?"UNINITIALIZED":"SUCCESS"};return ar(a,c)},[o]),s=U(n);return useEffect(()=>(s.isUninitialized&&t!==null&&r(Qe(e,{id:t,include:true})),()=>{}),[o,s.isUninitialized,r,t]),s}}function ar(e,t){let r={data:void 0,error:void 0,status:t.status,isUninitialized:t.status==="UNINITIALIZED",isLoading:t.status==="LOADING",isFetching:t.status==="LOADING"||t.status==="FETCHING",isSuccess:t.status==="SUCCESS",isError:t.status==="FAILURE"};return t.status==="UNINITIALIZED"?r:t.status==="LOADING"?{...r,data:e}:t.status==="FETCHING"?{...r,data:e}:t.status==="FAILURE"?{...r,error:t.error}:{...r,data:e}}
35
+ export{Pn as $,wp as $a,O as A,js as Aa,Ja as B,or as Ba,gr as C,nr as Ca,Rr as D,Gs as Da,ei as E,Hs as Ea,ot as F,sr as Fa,ti as G,Ks as Ga,xe as H,Ys as Ha,fe as I,Ws as Ia,rt as J,Qs as Ja,Pt as K,Ep as Ka,Lt as L,ia as La,Ot as M,hp as Ma,tn as N,Sp as Na,hr as O,Tp as Oa,mc as P,bp as Pa,Cr as Q,Ap as Qa,yc as R,vp as Ra,Rc as S,xp as Sa,kr as T,Cp as Ta,hc as U,kp as Ua,Sc as V,Pp as Va,It as W,Lp as Wa,Fe as X,_p as Xa,Or as Y,Op as Ya,Cn as Z,Ip as Za,wr as _,Bp as _a,se as a,Mr as aa,Xs as ab,qr as b,du as ba,Ds as bb,ct as c,fu as ca,Fs as cb,wt as d,Dr as da,Ne as db,Eu as e,Pe as ea,Jl as eb,hu as f,re as fa,ep as fb,Go as g,Kr as ga,Oa as h,Nt as ha,Lr as i,Yu as ia,_r as j,Le as ja,Hr as k,Yr as ka,lr as l,Qe as la,ca as m,Eo as ma,ua as n,hs as na,pr as o,Ss as oa,pa as p,Ts as pa,da as q,Ps as qa,ga as r,Ls as ra,Ea as s,ws as sa,ha as t,rr as ta,Te as u,pe as ua,Ga as v,U as va,Ka as w,Vs as wa,be as x,qs as xa,Ya as y,$s as ya,T as z,zs as za};
@@ -0,0 +1 @@
1
+ import {useMantineTheme,Modal,Group,Button}from'@mantine/core';import p,{useState,useCallback,useContext}from'react';import {jsxs,jsx}from'react/jsx-runtime';var C=p.createContext(void 0);function B(n){let[o,r]=useState(false),[e,i]=useState(null),s=p.useMemo(()=>{function t(d,v){return v?{show:()=>t(d)}:new Promise((y,T)=>{i({request:d,onResolve:y,onReject:T}),r(true);})}return {newConfirmation:t}},[]),u=()=>{r(false),setTimeout(()=>i(null),200);},P=useCallback(t=>{!o||!e||(e.onResolve(t),u());},[o,e]),g=useCallback(t=>{!o||!e||(e.onReject(t),u());},[o,e]);return jsxs(C.Provider,{value:s,children:[e&&jsx(w,{opened:o,request:e.request,onConfirm:P,onCancel:g}),n.children]})}function w(n){let{request:o,opened:r,onCancel:e,onConfirm:i}=n,s=useMantineTheme();return jsxs(Modal,{centered:true,zIndex:1002,opened:r,title:o.title,onClose:e,children:[o.message,jsxs(Group,{position:"right",style:{marginTop:s.spacing.sm},children:[jsx(Button,{onClick:e,children:o.cancelText||"Cancel"}),jsx(Button,{color:"red",onClick:i,children:o.confirmText||"Confirm"})]})]})}function j(){let n=useContext(C);if(n===void 0)throw new Error("useConfirmationDialog must be used within ConfirmationDialogProvider.");return n}export{B as a,j as b};
@@ -0,0 +1 @@
1
+ import {X,I}from'./chunk-EYRXKCMJ.js';import f from'slugify';var y=t=>t.records.entities.section,A=t=>t.records.entities.block;function o(t){return e=>Object.values(e.records.entities[t])}var E=o("section"),T=o("block"),k=o("formatter"),x=X();function j(t){return Object.values(t.records.entities.datasource||[]).sort((e,r)=>e.content.order>r.content.order?1:-1).map(e=>{let r={...x};return {...e,content:{...e.content,pattern:I(e.content.pattern,{},{variables:r})}}})}function i(t){let e={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},r=`(?:${Object.keys(e).join("|")})`,u=RegExp(r),m=RegExp(r,"g"),s=String(t).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return u.test(s)?s.replace(m,d=>e[d]):s}function p(t){return typeof t=="string"?String(t).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):t}function S(t){return t?f(p(i(t)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var z=S;export{y as a,A as b,E as c,T as d,k as e,j as f,i as g,p as h,z as i};
@@ -0,0 +1 @@
1
+ import {useSession}from'next-auth/react';function i(s={required:false}){let{update:o,data:t,status:e}=useSession(s);return {update:o,user:t?.user,status:e,isLoading:e==="loading"}}var d=i;export{d as a};