@datawheel/bespoke 0.9.8-rc.1 → 0.9.8-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cms.js CHANGED
@@ -1,5 +1,5 @@
1
- import'path';import'url';import*as MP from'd3-array';import*as BP from'd3-collection';import {nest}from'd3-collection';import*as DP from'd3-format';import {format as format$1}from'd3-format';import*as _P from'd3-time-format';import {formatAbbreviate}from'd3plus-format';import {date}from'd3plus-axis';import {isObject,merge,closest,assign}from'd3plus-common';import {titleCase,strip}from'd3plus-text';import jP from'jsonwebtoken';import {schema,normalize}from'normalizr';import Mu from'axios';import Yl from'yn';import {format}from'pretty-format';import vO from'next/config';import iS from'axios-retry';import TO from'toposort';import {csvParse,csvFormat}from'd3-dsv';import {createSlice,configureStore}from'@reduxjs/toolkit';import {HYDRATE,createWrapper}from'next-redux-wrapper';import {notifications,Notifications}from'@mantine/notifications';import*as In from'react';import In__default,{forwardRef,useState,useEffect,useImperativeHandle,createContext,useCallback,useRef,useMemo,useContext,Fragment as Fragment$2,memo,createElement}from'react';import {useDispatch,useSelector}from'react-redux';import {Group,Stack,Text,ThemeIcon,useMantineTheme,List,UnstyledButton,Center,createStyles,Image,Checkbox,Input,Select,NumberInput,Accordion,TextInput,Badge,rem,ScrollArea,Tooltip,Divider,MultiSelect,Button,Switch,Radio,Title,Box,Anchor,Skeleton,SegmentedControl,Flex,ActionIcon,Popover,px,Modal,CopyButton,Loader,Textarea,Col,Grid,Tabs,Overlay,Collapse,Alert,Breadcrumbs,Menu,Code,packSx,MantineProvider,Navbar,Avatar,AppShell,HoverCard,Paper,Card,Space,Container,LoadingOverlay,Pagination,CloseButton,Drawer,Notification,FileInput,SimpleGrid,Header,Autocomplete,MediaQuery,clsx}from'@mantine/core';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useRouter}from'next/router';import {signOut,useSession}from'next-auth/react';import {saveAs}from'file-saver';import {useListState,useSetState,randomId,useClickOutside,useDisclosure,useFullscreen,useDebouncedValue,getHotkeyHandler,useUncontrolled,useHotkeys,useMergedRef,useMediaQuery}from'@mantine/hooks';import vB from'slugify';import {Prism}from'@mantine/prism';import {IconCirclePlus,IconCircleCheck,IconLogout,IconBraces,IconGripVertical,IconDice,IconBoxMultiple,IconEyeOff,IconFlag,IconChevronDown,IconBallpen,IconDatabase,IconMathFunction,IconNetwork,IconUsers,IconLanguage,IconLanguageOff,IconPhotoFilled,IconFileUpload,IconInfoCircle,IconLogin,IconWorld,IconLock,IconPencil,IconCopy,IconCheck,IconPlus,IconTrash,IconDeviceFloppy,IconCircleX,IconPalette,IconSettings,IconChevronRight,IconCode,IconBold,IconItalic,IconUnderline,IconArrowBackUp,IconArrowForwardUp,IconAlignLeft,IconAlignCenter,IconAlignRight,IconAlignJustified,IconGlobe,IconLinkOff,IconX,IconGitMerge,IconAlertTriangle,IconHelp,IconMinimize,IconMaximize,IconAlertCircle,IconCloudNetwork,IconClockHour2,IconApi,IconAugmentedReality,IconListTree,IconTable,IconPhoto,IconSelector,IconChartBar,IconPercentage,IconHeading,IconCodePlus,IconServer,IconPlayerPlay,IconCircleCheckFilled,IconFileAnalytics,IconCircleDashed,IconHome,IconChevronLeft,IconSearch,IconRefresh,IconQuestionMark,IconGripHorizontal,IconListCheck,IconPolaroid,IconCircleMinus,IconVariable,IconArrowRightCircle,IconSlash,IconHelpCircle,IconCamera,IconShare,IconUpload,IconFileCode,IconWorldUpload,IconSettingsFilled,IconArrowLeft,IconArrowRight,IconIndentIncrease,IconCodeDots,IconBinaryTree,IconLink,IconSparkles,IconClipboardCheck,IconClipboardCopy,IconExternalLink,IconTemplate,IconDownload,IconFileTypeXls,IconFileTypeJs,IconFileTypeCsv,IconChevronUp,IconCircleKey}from'@tabler/icons-react';import AT,{Element as Element$1,domToReact,Text as Text$1}from'html-react-parser';import {dataConcat,dataLoad}from'd3plus-viz';import {MantineReactTable}from'mantine-react-table';import R1 from'jszip';import*as kV from'd3plus-react';import RV from'next/dynamic';import {select}from'd3-selection';import {saveElement}from'd3plus-export';import {FacebookShareButton,FacebookIcon,TwitterShareButton,TwitterIcon,TelegramShareButton,TelegramIcon,WhatsappShareButton,WhatsappIcon,LinkedinShareButton,LinkedinIcon,RedditShareButton,RedditIcon,EmailShareButton,EmailIcon}from'react-share';import'xlsx';import Q8 from'next/head';import TP from'next/link';import {DragDropContext,Droppable,Draggable}from'@hello-pangea/dnd';import $_,{useMonaco}from'@monaco-editor/react';import {EditorProvider,useCurrentEditor,BubbleMenu,ReactRenderer}from'@tiptap/react';import A5 from'@tiptap/extension-underline';import P5 from'@tiptap/starter-kit';import O5 from'@tiptap/extension-mention';import L5 from'@tiptap/extension-hard-break';import {Plugin,PluginKey,Selection,TextSelection,NodeSelection}from'@tiptap/pm/state';import'@tiptap/pm/view';import'@tiptap/pm/keymap';import {Fragment as Fragment$1,Slice,Schema,DOMParser}from'@tiptap/pm/model';import {canSplit,joinPoint,liftTarget,canJoin,ReplaceStep,ReplaceAroundStep}from'@tiptap/pm/transform';import {wrapIn,setBlockType,selectTextblockStart,selectTextblockEnd,selectParentNode,selectNodeForward,selectNodeBackward,newlineInCode,liftEmptyBlock,lift,joinUp,joinTextblockForward,joinTextblockBackward,joinForward,joinDown,joinBackward,exitCode,deleteSelection,createParagraphNear}from'@tiptap/pm/commands';import {wrapInList,sinkListItem,liftListItem}from'@tiptap/pm/schema-list';import M5 from'@tiptap/extension-text-align';import B5 from'@tiptap/extension-placeholder';import j5 from'@tiptap/extension-typography';import*as yr from'd3';import*as Yd from'd3-dag';import {useForm}from'@mantine/form';var yP=Object.defineProperty;var N=(e,t)=>()=>(e&&(t=e(e=0)),t);var bm=(e,t)=>{for(var o in t)yP(e,o,{get:t[o],enumerable:true});};var p=N(()=>{});var IP,je,Go=N(()=>{p();IP=()=>{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}},je=IP;});function Vr(e){if(!e)throw Error("Assertion Error")}function Il(e,t){return +(e<t)-+(e>t)}function mo(e,t,o="ordering"){return Il(t[o],e[o])}function wl(e){if(e===""||e.charCodeAt(e.length-1)==32)return false;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);if(o<32||o>126)return false}return true}function mv(e){Vr(e.length!==0);for(let o=e.length-1;o>=0;o--){let r=e.charCodeAt(o);if(r>33){let n=e.substr(0,o)+String.fromCharCode(r-1);return Vr(wl(n)),n}}let t=e.substr(0,e.length-1)+" ~";return Vr(wl(t)),t}function Rl(e){Vr(e.length!==0);for(let o=e.length-1;o>=0;o--){let r=e.charCodeAt(o);if(r<126){let n=e.substr(0,o)+String.fromCharCode(r+1);return Vr(wl(n)),n}}let t=e+"!";return Vr(wl(t)),t}function fv(e,t){return Math.trunc((e+t)/2)}function gv(e,t){Vr(e<t);let o=false,r="",n=Math.max(e.length,t.length);for(let i=0;i<n;i++){let a=i<e.length?e.charCodeAt(i):32,l=i<t.length&&!o?t.charCodeAt(i):126;if(a===l)r+=String.fromCharCode(a);else if(l-a>1){r+=String.fromCharCode(fv(a,l)),o=false;break}else r+=String.fromCharCode(a),o=true;}return o&&(r+=String.fromCharCode(fv(32,126))),Vr(e<r),Vr(r<t),Vr(wl(r)),r}function hn(e,t,o,r=false,n=true,i="ordering"){if(r)return o===0?e[t[0]]?mv(e[t[0]][i]):"!":o===t.length?Rl(e[t[o-1]][i]):gv(e[t[o-1]][i],e[t[o]][i]);if(o===0)return mv(e[t[o]][i]);if(o===t.length-1)return Rl(e[t[o]][i]);let a=n?o:o-1,l=n?o+1:o;return gv(e[t[a]][i],e[t[l]][i])}function $a(e,t=false){let o=e.reduce((r,n)=>Il(n,r)<0?n:r,"!");return t?Rl(o):o}var Ho=N(()=>{p();});function xm(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 hv(e,t,o){let r=0,n=1,i=1,a=1,l=0,s=0,c;for(;Math.abs((i-s)/i)>1e-5;)s=i,c=-(t+l)*(t+o+l)*e/(t+2*l)/(t+2*l+1),r=i+c*r,n=a+c*n,l+=1,c=l*(o-l)*e/(t+2*l-1)/(t+2*l),i=r+c*i,a=n+c*a,r/=a,n/=a,i/=a,a=1;return i/t}function AP(e,t,o){let r,n;if(e<0)n=0;else if(e>=t)n=1;else {e=Math.floor(e);let i=o,a=e+1,l=t-e,s=a+l,c=Math.exp(xm(s)-xm(l)-xm(a)+a*Math.log(i)+l*Math.log(1-i));i<(a+1)/(s+2)?r=c*hv(i,a,l):r=1-c*hv(1-i,l,a),n=1-r;}return Math.round(n*1e5)/1e5}function PP(e){return {.99999:15.137,.99:6.635,.95:3.841,.9:2.706}[e]}function Al(e,t,o,r){let n=t/(1-t),i=0,a=1,l=0,s=0;for(;i<=e;)s+=a,i>=o&i<=r&&(l+=a),s>1e30&&(l/=1e30,s/=1e30,a/=1e30),i+=1,a=a*n*(e+1-i)/i;return l/s}function OP(e,t,o){let r=e/t,i=(100-o*100)/2,a,l;if(e===0)a=0;else {let s=r/2,c=0,u=r,d=i/100;for(;u-c>1e-5;)Al(t,s,e,e)*.5+Al(t,s,e+1,t)>d?(u=s,s=(c+s)/2):(c=s,s=(u+s)/2);a=s;}if(e===t)l=0;else {let s=(1+r)/2,c=r,u=1,d=i/100;for(;u-c>1e-5;)Al(t,s,e,e)*.5+Al(t,s,0,e-1)<d?(u=s,s=(c+s)/2):(c=s,s=(u+s)/2);l=s;}return {lci:a,uci:l}}function LP(e,t){let o=e,r=t,n=o,i=r,a=95,l=.5,s=.5,u=(100-a)/2/100,d=n;for(;s>1e-5;)s/=2,vu((1+d)*l/(1-l),d+1,1e10)+.5*vu((1+d)*l/(1-l),d,d)>u?l-=s:l+=s;let m=(1+d)*l/(1-l)/i;for(l=.5,s=.5,u=(100-a)/2/100;s>1e-5;)s/=2,vu((1+d)*l/(1-l),0,d-1)+.5*vu((1+d)*l/(1-l),d,d)<u?l-=s:l+=s;let f=(1+d)*l/(1-l)/i;return {lci:m,uci:f}}function vu(e,t,o){let r=1,n=0,i=0,a=0;for(;a<e||r>n*1e-10;)n+=r,a>=t&a<=o&&(i+=r),n>1e30&&(i/=1e30,n/=1e30,r/=1e30),a+=1,r=r*e/a;return i/n}var bv,yv=N(()=>{p();bv={binomialCdf:AP,binP:Al,computeMidP:OP,criticalValue:PP,smr:LP};});function le(e){let t=e.logicFactory(qn);return HP[e.name]={description:e.description,inputType:e.inputType,logic:WP(t),testValue:e.testValue,type:e.type||"formatter"},t}function WP(e){let t=e.toString().trim();if(t.startsWith("function"))return t.replace(/^function(?:\s\w+)?\([^)]\)/,"").trim().replace(/^{([\s\S]+)\}$/,"$1");let o=t.replace(/^.+?=>/,"").trim();return o.startsWith("{")?o.replace(/^{([\s\S]+)\}$/,"$1"):`return ${o}`}var qn,HP,Ce=N(()=>{p();yv();qn={d3:{...MP,...BP,...DP,..._P},d3plus:{assign:assign,closest:closest,date:date,formatAbbreviate:formatAbbreviate,merge:merge,strip:strip,titleCase:titleCase},stats:bv},HP={};});var vv,Sv=N(()=>{p();vv={jwt:jP};});var Ua,Ga,Ha=N(()=>{p();Ce();Sv();Ua=(e,t={},o="en",r={},n={})=>{let i={setVariables:r.onSetVariables?r.onSetVariables:s=>s,openModal:r.onOpenModal?r.onOpenModal:s=>s,formatters:t,libs:qn,locale:o,...n};function a(s){return Function("globals",...s.vars,`with (globals) { ${s.logic} }`).bind(i,i)}function l(s){if(s.vars&&s.logic)return a(s);for(let c in s)Array.isArray(s[c])?s[c]=s[c].map(u=>isObject(u)?l(u):u):isObject(s[c])&&(s[c]=l(s[c]));return s}return l(e)},Ga=(e,t={})=>{let o={libs:vv,...t};function r(i){return Function("globals",...i.vars,`with (globals) { ${i.logic} }`).bind(o,o)}function n(i){if(i.vars&&i.logic)return r(i);for(let a in i)Array.isArray(i[a])?i[a]=i[a].map(l=>isObject(l)?n(l):l):isObject(i[a])&&(i[a]=n(i[a]));return i}return n(e)};});function xu(e,t){let o=QP[e];if(!o)throw new Error(`Invalid entity type: ${e}`);let{entities:r}=normalize(t,[o]);return {report:Di(r,"report"),dimension:Di(r,"dimension"),section:Di(r,"section"),block:Di(r,"block"),variant:Di(r,"variant"),formatter:Di(r,"formatter"),datasource:Di(r,"datasource")}}function Di(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}var qP,Pl,xv,Tv,Cv,YP,XP,JP,QP,kv,Yn,Xn=N(()=>{p();Ho();Ha();Go();(({localeDefault:qP}=je())),Pl=new schema.Entity("block",{},{mergeStrategy(e,t){return t.block_input?e||{}:{...e,...t}}});Pl.define({consumers:[Pl],inputs:[Pl]});xv=new schema.Entity("variant"),Tv=new schema.Entity("dimension",{variants:[xv]},{processStrategy(e){return {...e,variants:"variants"in e?e.variants:[]}}}),Cv=new schema.Entity("section",{blocks:[Pl]}),YP=new schema.Entity("report",{dimensions:[Tv],sections:[Cv]},{processStrategy(e){return {...e,sections:"sections"in e?e.sections.sort(mo):[]}}}),XP=new schema.Entity("formatter"),JP=new schema.Entity("datasource"),QP={report:YP,section:Cv,block:Pl,dimension:Tv,variant:xv,formatter:XP,datasource:JP};kv=(e,t=void 0)=>{let{sid:o,bid:r,previews:n=[],query:i={}}=t||{},a,l,s={};return o?(a=o,s.activeSection=a):a=e.activeSection,n.length>0?(l=n,s.previews=l.filter(Boolean)):l=e.previews,{parsedParams:{sid:a,bid:r,previews:l,query:i},statusPayload:s}},Yn=(e=[],t=qP)=>e.reduce((o,r)=>{let n=Ua({vars:["n"],logic:r.content.logic},{},t,{});return o[r.name]=n,o},{});});function xr(e,t){return e.request(t).then(o=>{let{status:r,data:n}=o;return "error"in n?{ok:false,status:r,error:n.error}:{ok:true,status:r,wrapper:n.wrapper,data:n.data}},o=>{if("isAxiosError"in o){let{status:r,data:n}=o.response||{status:500};return {ok:false,status:r,error:n?.error??o.message}}return {ok:false,status:500,error:o.message}})}function Ze(e,t,o){let r=typeof t=="string"?{url:t}:t;return n=>xr(e,{...r,method:"GET",params:o?o(n):n})}function at(e,t,o){let r=typeof t=="string"?{url:t}:t;return n=>xr(e,{...r,method:"POST",data:n})}function Jn(e,t,o){let r=typeof t=="string"?{url:t}:t;return n=>xr(e,{...r,method:"DELETE",params:o?o(n):n})}var Wa=N(()=>{p();});function Ni(e,t){return o=>xr(e,{method:"POST",url:`images/save/${t}`,params:{prompt:o.prompt,provider:t}})}var Ev=N(()=>{p();Wa();});function ja(e,t){return o=>xr(e,{method:"GET",url:`images/search/${t}`,params:{prompt:o.prompt,page:o.page,provider:t}})}var wv=N(()=>{p();Wa();});function Rv(e,t){return ()=>xr(e,{method:"GET",url:`list/icons/${t}`,params:{provider:t}})}var Iv=N(()=>{p();Wa();});function Av(e,t){return o=>xr(e,{method:"GET",url:`read/icons/${t}/icon.svg`,params:{name:o.name}})}var Pv=N(()=>{p();Wa();});function Ol(e){let t=Mu.create({baseURL:e});return {createBulkBlock:at(t,"create/bulk/block"),createBlock:at(t,"create/block"),createDimension:at(t,"create/dimension"),createFormatter:at(t,"create/formatter"),createReport:at(t,"create/report"),createSection:at(t,"create/section"),createVariant:at(t,"create/variant"),createDatasource:at(t,"create/datasource"),deleteBlock:Jn(t,"delete/block",zi),deleteDimension:Jn(t,"delete/dimension",zi),deleteFormatter:Jn(t,"delete/formatter",zi),deleteReport:Jn(t,"delete/report",zi),deleteSection:Jn(t,"delete/section",zi),deleteVariant:Jn(t,"delete/variant",zi),deleteDatasource:Jn(t,"delete/datasource",zi),readBlock:Ze(t,"read/block"),readDimension:Ze(t,"read/dimension"),readFormatter:Ze(t,"read/formatter"),readReport:Ze(t,"read/report"),readSection:Ze(t,"read/section"),readVariant:Ze(t,"read/variant"),readDatasource:Ze(t,"read/datasource"),updateBulkBlock:at(t,"update/bulk/block"),updateBlock:at(t,"update/block"),updateDimension:at(t,"update/dimension"),updateFormatter:at(t,"update/formatter"),updateReport:at(t,"update/report"),updateSection:at(t,"update/section"),updateVariant:at(t,"update/variant"),updateDatasource:at(t,"update/datasource"),searchReport:Ze(t,"search/reports"),validateVariantSlug:Ze(t,"validate/variant"),readMember:Ze(t,"read/members",eO),readMemberImage:Ze(t,{url:"member/image",responseType:"blob"}),searchMember:Ze(t,"search/members"),updateMember:Ze(t,"update/members"),imageLocalSearch:ja(t,"local"),imageLocalSave:Ni(t,"local"),imageFlickrSearch:ja(t,"flickr"),imageFlickrSave:Ni(t,"flickr"),imageUnsplashSearch:ja(t,"unsplash"),imageUnsplashSave:Ni(t,"unsplash"),imageUploadSave:Ni(t,"upload"),imageAdobeSearch:ja(t,"adobe"),imageAdobeSave:Ni(t,"adobe"),imagePixabaySearch:ja(t,"pixabay"),imagePixabaySave:Ni(t,"pixabay"),readMetadata:Ze(t,"read/metadata"),regenerateSearch:at(t,"search/regenerate"),urlProxy:Ze(t,"url/proxy"),searchRole:Ze(t,"auth/search/roles"),searchUser:Ze(t,"auth/search/users"),readUser:Ze(t,"auth/read/user"),updateUser:at(t,"auth/update/user"),updateMyData:at(t,"auth/update/me"),revalidateReport:Ze(t,"revalidate/report"),revalidateUrl:Ze(t,"revalidate/url"),readPrivateBlocks:at(t,"read/blocks/private"),listTablerIcons:Rv(t,"tabler"),readTablerIcon:Av(t,"tabler"),readEnvSecrets:Ze(t,"read/secrets")}}var zi,eO,Ov=N(()=>{p();Ev();wv();Wa();Iv();Pv();zi=e=>({id:e}),eO=e=>{if(e.mode==="slugs"){let t=e.slugs.map(o=>[o.variantSlug,o.memberSlug].join("/")).join(",");return {...e,slugs:t}}return ["related","whole"].includes(e.mode)?{...e}:{...e,[e.mode]:e[e.mode].join(",")}};});var Tm=N(()=>{p();Ov();});var Fi,Lv,Tu=N(()=>{p();Fi="report",Lv="Report";});var Ll,Bv,km=N(()=>{p();Tu();Ll="section",Bv="Section";});function rr(e){return {variables:e.variables||{},query:e.query||{},locale:e.locale||tO}}var tO,Cu,Nv,Qn=N(()=>{p();km();Go();(({localeDefault:tO}=je())),Cu="block",Nv="Block";});var bn,Uv,Vv,xt,Eu,$v,Em,oO,rO,nO,iO,wm,Rm,E,Ae,Xe,nr,_t,ku,Ka,yn,wu,he=N(()=>{p();bn={REPORT:"report",SECTION:"section",BLOCK:"block",INPUT:"block_input",FORMATTER:"formatter",DATASOURCE:"datasource",DIMENSION:"report_dimension",VARIANT:"report_dimension_variant",SEARCH:"search"},[bn.BLOCK,bn.SEARCH],Uv={report:"Report",section:"Section",block:"Block",block_input:"Input",formatter:"Formatter",datasource:"Data Source",dimension:"Dimension",variant:"Variant",search:"Search"},{[bn.SECTION]:"report_id",[bn.DIMENSION]:"report_id",[bn.VARIANT]:"dimension_id",[bn.BLOCK]:"section_id",[bn.INPUT]:"block_id"},Vv={REPORT:"report",STORY:"story"},xt={SINGLE:"single",MULTI:"multi"},Eu={SEGMENTED_CONTROL:"segmented control",SELECTOR:"selector"},$v={TITLE:"title",SUBTITLE:"subtitle",LABEL:"label"},{[Vv.REPORT]:Object.values($v),[Vv.STORY]:Object.values($v)},Em={ALLOWED:"allowed",ALLOWED_LOGIC:"allowedLogic",IGNORE_CASCADE:"ignoreCascade"},oO={ACCESS:"access",ACCESS_LOGIC:"accessLogic"},rO={DISABLED:"disabled"},nO={FALLBACK:"fallback"},{...Em},{POSITION:"position",ICON:"icon",...Em},iO={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"},wm={GENERATOR:"generator",RELATED:"related",VIZ:"visualization",SECTION_FLAG:"section_flag"},Rm="logic",E={...iO,...wm},[E.GENERATOR,E.SECTION_FLAG,E.SELECTOR,E.VIZ,E.IMAGE,E.TABLE,E.MULTIHIERARCHY_SELECTOR],Ae={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"},[Ae.LOGIC,Ae.SIMPLE,Ae.SIMPLE_ENABLED],Xe={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}}},nr={[E.IMAGE]:[{field:Ae.TITLE,editorConfig:Xe.ENABLE_ALL},{field:Ae.SRC,editorConfig:Xe.DISABLE_ALL},{field:Ae.ALT,editorConfig:Xe.DISABLE_ALL},{field:Ae.DESC,editorConfig:Xe.ENABLE_ALL}],[E.PARAGRAPH]:[{field:E.PARAGRAPH,editorConfig:Xe.ENABLE_ALL},{field:Ae.TOOLTIP,editorConfig:Xe.ENABLE_FORMAT}],[E.SELECTOR]:[{field:Ae.SELECTOR_DEFAULT},{field:Ae.SELECTOR_DYNAMIC},{field:Ae.SELECTOR_NAME,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.SELECTOR_TYPE}],[E.STAT]:[{field:Ae.TITLE,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.SUBTITLE,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.VALUE,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.TOOLTIP,editorConfig:Xe.ENABLE_FORMAT}],[E.SUBTITLE]:[{field:Ae.SUBTITLE,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.TOOLTIP,editorConfig:Xe.ENABLE_FORMAT}],[E.TITLE]:[{field:Ae.TITLE,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.SLUG,editorConfig:Xe.DISABLE_ALL},{field:Ae.TOOLTIP,editorConfig:Xe.ENABLE_FORMAT}],[E.BUTTON]:[{field:Ae.LABEL,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.URL,editorConfig:Xe.ENABLE_FORMAT}],[E.GENERATOR]:[],[E.SECTION_FLAG]:[],[E.VIZ]:[],[E.TABLE]:[],[E.MULTIHIERARCHY_SELECTOR]:[{field:Ae.MULTIHIERARCHY_SELECTOR_NAME,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.MULTIHIERARCHY_SELECTOR_PLACEHOLDER,editorConfig:Xe.DISABLE_ALL},{field:Ae.MULTIHIERARCHY_SELECTOR_ALL_LABEL,editorConfig:Xe.DISABLE_ALL}],[E.NAV]:[{field:Ae.TITLE,editorConfig:Xe.ENABLE_FORMAT},{field:Ae.SHORT_TITLE,editorConfig:Xe.ENABLE_FORMAT}]},_t={NAME:"name",DESCRIPTION:"description",...Em,...oO,...nO,...rO},ku={FORMATTER:"formatter",FUNCTION:"function"},Ka={[ku.FORMATTER]:"Formatter",[ku.FUNCTION]:"Function"},yn={STRING:"string",NUMBER:"number",OBJECT:"object",DATE:"date"},wu={[yn.STRING]:"String",[yn.NUMBER]:"Number",[yn.OBJECT]:"Object/Array",[yn.DATE]:"Date"};});function uO(e,t,o,r,n=void 0,i){let a={},l=[],{locale:s}=rr(i);try{if(t){let c=new Proxy(console,{get(d,m){return pO(m,"log","debug","info","warn","error")?(...g)=>{l.push(`${m} ${Date.now()} - ${g.map(f=>format(f)).join(" ")}`),cO&&d[m](...g);}:d[m]}}),u;return n?u=new Function(e,"console","libs","formatters","locale","variables",o)(t,c,qn,r,s,n):u=new Function(e,"console","libs","formatters","locale",o)(t,c,qn,r,s),typeof u=="object"&&Object.keys(u).length>0&&Object.assign(a,u),{vars:a,error:null,log:l,output:u}}return {vars:a,error:"Invalid API Link",log:l}}catch(c){return {vars:a,error:c.message,log:l}}}function pO(e,...t){return t.includes(e)}var cO,$r,qa=N(()=>{p();Qn();Ce();cO=Yl(process.env.REPORTS_LOGGING),$r=uO;});function Im(e){return e.reduce((t,o,r)=>(r?r===e.length-1&&r===1?t+=` and ${o}`:r===e.length-1?t+=`, and ${o}`:t+=`, ${o}`:t+=o,t),"")}var Gv=N(()=>{p();});function dO(e,t,o,r=false){let{variables:n}=rr(o);if(!e)return e;let i=/([A-z0-9]*)\{\{([^\}]+)\}\}/g;return e.replace(i,(l,s,c)=>{let u=m=>m;if(s){let m=s.replace(/^\w/g,g=>g.toLowerCase());m in t?u=t[m]:u=g=>`${s}${g}`;}let d=Array.isArray(n[c])?Im(n[c]):n[c];if(d===void 0)return r?l:"N/A";try{return u(d,qn,t)}catch(m){return console.error(`Error using formatter ${u.name}
2
- `,`Error message: ${m.message}`),"N/A"}})}var et,Ur=N(()=>{p();Qn();Gv();Ce();et=dO;});var Am,Tr,Vi=N(()=>{p();Ur();Am=(e,t,o)=>{let{variables:r}=o,n=a=>a.allowed==="never"?false:!a.allowed||a.allowed==="always"||r[a.allowed],i={...e};return Object.keys(i).forEach(a=>{typeof i[a]=="string"?i[a]=et(i[a],t,o):Array.isArray(i[a])?i[a]=i[a].filter(n).map(l=>typeof l=="object"?Am(l,t,o):typeof l=="string"?et(l,t,o):l):typeof i[a]=="object"&&i[a]!==null&&!(i[a]instanceof Date)&&(i[a]=Am(i[a],t,o));}),i},Tr=Am;});var Hv,Wv=N(()=>{p();Hv=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];});var mO,$i,Ru=N(()=>{p();he();mO=(e,t,o)=>{if(!o)return false;if(e===xt.SINGLE)return o.find(n=>n.id===t);let r=Array.isArray(t)?t:t.split(",");return Array.isArray(r)&&r.every(n=>o.map(i=>i.id).includes(n))},$i=mO;});function Iu(e,t,o,r,n=false){let{variables:i}=rr(r),a=Tr({logic:t},o,r).logic,l=$r("variables",i,a,o,void 0,r),{vars:s,log:c,error:u}=l,d=s.type||xt.SINGLE,m=s.component||"Selector",g=s.hideLabel||"false",f=s.resetSectionVars||"false",h=s.name||"Unlabeled Selector",v=Hv(s.options||[]),T=w=>d===xt.MULTI&&!Array.isArray(w)?[w]:w,y=s.defaultValue,C;if(y&&(y=T(y),$i(d,y,v)&&(C=y)),!C){let w=v&&v[0]&&v[0].id||v[0]||"";C=T(w);}if(n&&typeof window<"u"){let w=`selector${e}id`,k=new URLSearchParams(window.location.search),O=Object.fromEntries(k)[w];O&&!$i(d,O,v)&&O!==void 0&&(k.delete(w),window.history.replaceState(null,null,`?${k.toString()}`));}return {config:{name:h,type:d,options:v,defaultValue:C,component:m,hideLabel:g,resetSectionVars:f},log:c,error:u}}var Pm=N(()=>{p();Qn();he();qa();Vi();Wv();Ru();});function Om(e,t,o){if(!e)return false;let r=Array.isArray(o)?o:o.split(",");return Array.isArray(r)&&r.every(n=>e.map(i=>`${i[`${t} ID`]}`).includes(n))}var jv=N(()=>{p();});function Au(e,t,o,r,n=false){let{variables:i}=rr(r),a=Tr({logic:t},o,r).logic,l=$r("variables",i,a,o,void 0,r),{vars:s,log:c,error:u}=l;if(n&&typeof window<"u"){let m=`multihierarchySelector${e}-value`,g=`multihierarchySelector${e}-type`,f=new URLSearchParams(window.location.search),h=Object.fromEntries(f),v=h[m],T=h[g];v&&v!==void 0&&T&&T!==void 0&&!Om(s.data,T,v)&&(f.delete(m),f.delete(g),window.history.replaceState(null,null,`?${f.toString()}`));}return {config:s,log:c,error:u}}var Lm=N(()=>{p();jv();Qn();qa();Vi();});var fO,Kv,qv=N(()=>{p();he();fO=(e,t,o)=>{let r=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(r),i=new URLSearchParams(t).get(r),a=n||i;if(o.type===xt.MULTI){let c=a?a.split(","):o.defaultValue,u=o.options.filter(d=>c.includes(d.id));return {[`selector${e}id`]:c,[`selector${e}label`]:(u||[]).map(d=>d.label)}}let l=a&&o.options.find(c=>c.id===a)?a:o.defaultValue,s=o.options.find(c=>c.id===l);return {[`selector${e}id`]:l,[`selector${e}label`]:s&&s.label||void 0}},Kv=fO;});var gO,Yv,Xv=N(()=>{p();gO=(e,t,o)=>{let r=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,i=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(r),a=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),l=new URLSearchParams(t).get(r),s=new URLSearchParams(t).get(n),c=i||l,u=a||s,d=c?c.split(","):o.defaultValue||[],m=u||o.defaultValueType||"",g=o.data?.filter(f=>d.includes(`${f[`${m} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:d,[`multihierarchySelector${e}label`]:[...new Set((g||[]).map(f=>f[m]))],[`multihierarchySelector${e}type`]:m}},Yv=gO;});var Jv,hO,bO,Cr,Eo,Wo=N(()=>{p();he();Go();(({localeDefault:Jv,locales:hO}=je())),bO=Object.values(wm),Cr=(e,t=Jv)=>e&&bO.includes(e.type)?{locale:Rm,locales:[Rm]}:{locale:t,locales:hO},Eo=(e,t=Jv)=>{if(!e)return {};let{locale:o}=Cr(e,t);return e.contentByLocale?.[o]?.content};});function yO(e,t){let o=Object.values(t),r=o.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(o.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(i=>r.includes(i)))).map(n=>[n.id,n]))}var Qv,Zv=N(()=>{p();Qv=yO;});var eS,Pu,Mm=N(()=>{p();eS=e=>{let t=[];if(Array.isArray(e))return [];let o=(r,n="")=>{!r||typeof r!="object"||Object.keys(r).forEach(i=>{if(Array.isArray(r[i]))t.push(`${n?`${n}.`:""}${i}`);else if(typeof r[i]=="object")o(r[i],`${n?`${n}.`:""}${i}`);else return});};return o(e),t},Pu=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((o,r)=>o[r],e):e;});var wo,tS,oS,kr=N(()=>{p();wo="SECTION_ALLOWED",tS=`// const {anotherVariable} = variables; (From context and inputs)
1
+ import'path';import'url';import*as BP from'd3-array';import*as DP from'd3-collection';import {nest}from'd3-collection';import*as _P from'd3-format';import {format as format$1}from'd3-format';import*as NP from'd3-time-format';import {formatAbbreviate}from'd3plus-format';import {date}from'd3plus-axis';import {isObject,merge,closest,assign}from'd3plus-common';import {titleCase,strip}from'd3plus-text';import KP from'jsonwebtoken';import {schema,normalize}from'normalizr';import Mu from'axios';import Yl from'yn';import {format}from'pretty-format';import SO from'next/config';import aS from'axios-retry';import CO from'toposort';import {csvParse,csvFormat}from'd3-dsv';import {createSlice,configureStore}from'@reduxjs/toolkit';import {HYDRATE,createWrapper}from'next-redux-wrapper';import {notifications,Notifications}from'@mantine/notifications';import {signOut,useSession}from'next-auth/react';import*as wn from'react';import wn__default,{forwardRef,useState,useEffect,useImperativeHandle,createContext,useCallback,useRef,useMemo,useContext,Fragment as Fragment$2,memo,createElement}from'react';import {useDispatch,useSelector}from'react-redux';import {Group,Stack,Text,ThemeIcon,useMantineTheme,List,UnstyledButton,Center,createStyles,Image,Checkbox,Input,Select,NumberInput,Accordion,TextInput,Badge,rem,ScrollArea,Tooltip,Divider,MultiSelect,Button,Switch,Radio,Title,Box,Anchor,Skeleton,SegmentedControl,Flex,ActionIcon,Popover,px,Modal,CopyButton,Loader,Textarea,Col,Grid,Tabs,Overlay,Collapse,Alert,Breadcrumbs,Menu,Code,packSx,MantineProvider,Navbar,Avatar,AppShell,HoverCard,Paper,Card,Space,Container,LoadingOverlay,Pagination,CloseButton,Drawer,Notification,FileInput,SimpleGrid,Header,Autocomplete,MediaQuery,clsx}from'@mantine/core';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useRouter}from'next/router';import {saveAs}from'file-saver';import {useListState,useSetState,randomId,useClickOutside,useDisclosure,useFullscreen,useDebouncedValue,getHotkeyHandler,useUncontrolled,useHotkeys,useMergedRef,useMediaQuery}from'@mantine/hooks';import SB from'slugify';import {Prism}from'@mantine/prism';import {IconCirclePlus,IconCircleCheck,IconLogout,IconBraces,IconGripVertical,IconDice,IconBoxMultiple,IconEyeOff,IconFlag,IconChevronDown,IconBallpen,IconDatabase,IconMathFunction,IconNetwork,IconUsers,IconLanguage,IconLanguageOff,IconPhotoFilled,IconFileUpload,IconInfoCircle,IconLogin,IconWorld,IconLock,IconPencil,IconCopy,IconCheck,IconPlus,IconTrash,IconDeviceFloppy,IconCircleX,IconPalette,IconSettings,IconChevronRight,IconCode,IconBold,IconItalic,IconUnderline,IconArrowBackUp,IconArrowForwardUp,IconAlignLeft,IconAlignCenter,IconAlignRight,IconAlignJustified,IconGlobe,IconLinkOff,IconX,IconGitMerge,IconAlertTriangle,IconHelp,IconMinimize,IconMaximize,IconAlertCircle,IconCloudNetwork,IconClockHour2,IconApi,IconAugmentedReality,IconListTree,IconTable,IconPhoto,IconSelector,IconChartBar,IconPercentage,IconHeading,IconCodePlus,IconServer,IconPlayerPlay,IconCircleCheckFilled,IconFileAnalytics,IconCircleDashed,IconHome,IconChevronLeft,IconSearch,IconRefresh,IconQuestionMark,IconGripHorizontal,IconListCheck,IconPolaroid,IconCircleMinus,IconVariable,IconArrowRightCircle,IconSlash,IconHelpCircle,IconCamera,IconShare,IconUpload,IconFileCode,IconWorldUpload,IconSettingsFilled,IconArrowLeft,IconArrowRight,IconIndentIncrease,IconCodeDots,IconBinaryTree,IconLink,IconSparkles,IconClipboardCheck,IconClipboardCopy,IconExternalLink,IconTemplate,IconDownload,IconFileTypeXls,IconFileTypeJs,IconFileTypeCsv,IconChevronUp,IconCircleKey}from'@tabler/icons-react';import PT,{Element as Element$1,domToReact,Text as Text$1}from'html-react-parser';import {dataConcat,dataLoad}from'd3plus-viz';import {MantineReactTable}from'mantine-react-table';import I1 from'jszip';import*as EV from'd3plus-react';import IV from'next/dynamic';import {select}from'd3-selection';import {saveElement}from'd3plus-export';import {FacebookShareButton,FacebookIcon,TwitterShareButton,TwitterIcon,TelegramShareButton,TelegramIcon,WhatsappShareButton,WhatsappIcon,LinkedinShareButton,LinkedinIcon,RedditShareButton,RedditIcon,EmailShareButton,EmailIcon}from'react-share';import'xlsx';import Z8 from'next/head';import CP from'next/link';import {DragDropContext,Droppable,Draggable}from'@hello-pangea/dnd';import U_,{useMonaco}from'@monaco-editor/react';import {EditorProvider,useCurrentEditor,BubbleMenu,ReactRenderer}from'@tiptap/react';import P5 from'@tiptap/extension-underline';import O5 from'@tiptap/starter-kit';import L5 from'@tiptap/extension-mention';import M5 from'@tiptap/extension-hard-break';import {Plugin,PluginKey,Selection,TextSelection,NodeSelection}from'@tiptap/pm/state';import'@tiptap/pm/view';import'@tiptap/pm/keymap';import {Fragment as Fragment$1,Slice,Schema,DOMParser}from'@tiptap/pm/model';import {canSplit,joinPoint,liftTarget,canJoin,ReplaceStep,ReplaceAroundStep}from'@tiptap/pm/transform';import {wrapIn,setBlockType,selectTextblockStart,selectTextblockEnd,selectParentNode,selectNodeForward,selectNodeBackward,newlineInCode,liftEmptyBlock,lift,joinUp,joinTextblockForward,joinTextblockBackward,joinForward,joinDown,joinBackward,exitCode,deleteSelection,createParagraphNear}from'@tiptap/pm/commands';import {wrapInList,sinkListItem,liftListItem}from'@tiptap/pm/schema-list';import B5 from'@tiptap/extension-text-align';import D5 from'@tiptap/extension-placeholder';import K5 from'@tiptap/extension-typography';import*as br from'd3';import*as Xd from'd3-dag';import {useForm}from'@mantine/form';var vP=Object.defineProperty;var D=(e,t)=>()=>(e&&(t=e(e=0)),t);var ym=(e,t)=>{for(var o in t)vP(e,o,{get:t[o],enumerable:true});};var p=D(()=>{});var AP,We,Uo=D(()=>{p();AP=()=>{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}},We=AP;});function zr(e){if(!e)throw Error("Assertion Error")}function Rl(e,t){return +(e<t)-+(e>t)}function po(e,t,o="ordering"){return Rl(t[o],e[o])}function El(e){if(e===""||e.charCodeAt(e.length-1)==32)return false;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);if(o<32||o>126)return false}return true}function fv(e){zr(e.length!==0);for(let o=e.length-1;o>=0;o--){let r=e.charCodeAt(o);if(r>33){let n=e.substr(0,o)+String.fromCharCode(r-1);return zr(El(n)),n}}let t=e.substr(0,e.length-1)+" ~";return zr(El(t)),t}function wl(e){zr(e.length!==0);for(let o=e.length-1;o>=0;o--){let r=e.charCodeAt(o);if(r<126){let n=e.substr(0,o)+String.fromCharCode(r+1);return zr(El(n)),n}}let t=e+"!";return zr(El(t)),t}function gv(e,t){return Math.trunc((e+t)/2)}function hv(e,t){zr(e<t);let o=false,r="",n=Math.max(e.length,t.length);for(let i=0;i<n;i++){let a=i<e.length?e.charCodeAt(i):32,l=i<t.length&&!o?t.charCodeAt(i):126;if(a===l)r+=String.fromCharCode(a);else if(l-a>1){r+=String.fromCharCode(gv(a,l)),o=false;break}else r+=String.fromCharCode(a),o=true;}return o&&(r+=String.fromCharCode(gv(32,126))),zr(e<r),zr(r<t),zr(El(r)),r}function fn(e,t,o,r=false,n=true,i="ordering"){if(r)return o===0?e[t[0]]?fv(e[t[0]][i]):"!":o===t.length?wl(e[t[o-1]][i]):hv(e[t[o-1]][i],e[t[o]][i]);if(o===0)return fv(e[t[o]][i]);if(o===t.length-1)return wl(e[t[o]][i]);let a=n?o:o-1,l=n?o+1:o;return hv(e[t[a]][i],e[t[l]][i])}function Va(e,t=false){let o=e.reduce((r,n)=>Rl(n,r)<0?n:r,"!");return t?wl(o):o}var Go=D(()=>{p();});function Tm(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 bv(e,t,o){let r=0,n=1,i=1,a=1,l=0,s=0,c;for(;Math.abs((i-s)/i)>1e-5;)s=i,c=-(t+l)*(t+o+l)*e/(t+2*l)/(t+2*l+1),r=i+c*r,n=a+c*n,l+=1,c=l*(o-l)*e/(t+2*l-1)/(t+2*l),i=r+c*i,a=n+c*a,r/=a,n/=a,i/=a,a=1;return i/t}function PP(e,t,o){let r,n;if(e<0)n=0;else if(e>=t)n=1;else {e=Math.floor(e);let i=o,a=e+1,l=t-e,s=a+l,c=Math.exp(Tm(s)-Tm(l)-Tm(a)+a*Math.log(i)+l*Math.log(1-i));i<(a+1)/(s+2)?r=c*bv(i,a,l):r=1-c*bv(1-i,l,a),n=1-r;}return Math.round(n*1e5)/1e5}function OP(e){return {.99999:15.137,.99:6.635,.95:3.841,.9:2.706}[e]}function Il(e,t,o,r){let n=t/(1-t),i=0,a=1,l=0,s=0;for(;i<=e;)s+=a,i>=o&i<=r&&(l+=a),s>1e30&&(l/=1e30,s/=1e30,a/=1e30),i+=1,a=a*n*(e+1-i)/i;return l/s}function LP(e,t,o){let r=e/t,i=(100-o*100)/2,a,l;if(e===0)a=0;else {let s=r/2,c=0,u=r,d=i/100;for(;u-c>1e-5;)Il(t,s,e,e)*.5+Il(t,s,e+1,t)>d?(u=s,s=(c+s)/2):(c=s,s=(u+s)/2);a=s;}if(e===t)l=0;else {let s=(1+r)/2,c=r,u=1,d=i/100;for(;u-c>1e-5;)Il(t,s,e,e)*.5+Il(t,s,0,e-1)<d?(u=s,s=(c+s)/2):(c=s,s=(u+s)/2);l=s;}return {lci:a,uci:l}}function MP(e,t){let o=e,r=t,n=o,i=r,a=95,l=.5,s=.5,u=(100-a)/2/100,d=n;for(;s>1e-5;)s/=2,vu((1+d)*l/(1-l),d+1,1e10)+.5*vu((1+d)*l/(1-l),d,d)>u?l-=s:l+=s;let f=(1+d)*l/(1-l)/i;for(l=.5,s=.5,u=(100-a)/2/100;s>1e-5;)s/=2,vu((1+d)*l/(1-l),0,d-1)+.5*vu((1+d)*l/(1-l),d,d)<u?l-=s:l+=s;let m=(1+d)*l/(1-l)/i;return {lci:f,uci:m}}function vu(e,t,o){let r=1,n=0,i=0,a=0;for(;a<e||r>n*1e-10;)n+=r,a>=t&a<=o&&(i+=r),n>1e30&&(i/=1e30,n/=1e30,r/=1e30),a+=1,r=r*e/a;return i/n}var yv,vv=D(()=>{p();yv={binomialCdf:PP,binP:Il,computeMidP:LP,criticalValue:OP,smr:MP};});function ce(e){let t=e.logicFactory(jn);return WP[e.name]={description:e.description,inputType:e.inputType,logic:jP(t),testValue:e.testValue,type:e.type||"formatter"},t}function jP(e){let t=e.toString().trim();if(t.startsWith("function"))return t.replace(/^function(?:\s\w+)?\([^)]\)/,"").trim().replace(/^{([\s\S]+)\}$/,"$1");let o=t.replace(/^.+?=>/,"").trim();return o.startsWith("{")?o.replace(/^{([\s\S]+)\}$/,"$1"):`return ${o}`}var jn,WP,ke=D(()=>{p();vv();jn={d3:{...BP,...DP,..._P,...NP},d3plus:{assign:assign,closest:closest,date:date,formatAbbreviate:formatAbbreviate,merge:merge,strip:strip,titleCase:titleCase},stats:yv},WP={};});var Sv,xv=D(()=>{p();Sv={jwt:KP};});var $a,Ua,Ga=D(()=>{p();ke();xv();$a=(e,t={},o="en",r={},n={})=>{let i={setVariables:r.onSetVariables?r.onSetVariables:s=>s,openModal:r.onOpenModal?r.onOpenModal:s=>s,formatters:t,libs:jn,locale:o,...n};function a(s){return Function("globals",...s.vars,`with (globals) { ${s.logic} }`).bind(i,i)}function l(s){if(s.vars&&s.logic)return a(s);for(let c in s)Array.isArray(s[c])?s[c]=s[c].map(u=>isObject(u)?l(u):u):isObject(s[c])&&(s[c]=l(s[c]));return s}return l(e)},Ua=(e,t={})=>{let o={libs:Sv,...t};function r(i){return Function("globals",...i.vars,`with (globals) { ${i.logic} }`).bind(o,o)}function n(i){if(i.vars&&i.logic)return r(i);for(let a in i)Array.isArray(i[a])?i[a]=i[a].map(l=>isObject(l)?n(l):l):isObject(i[a])&&(i[a]=n(i[a]));return i}return n(e)};});function xu(e,t){let o=ZP[e];if(!o)throw new Error(`Invalid entity type: ${e}`);let{entities:r}=normalize(t,[o]);return {report:Mi(r,"report"),dimension:Mi(r,"dimension"),section:Mi(r,"section"),block:Mi(r,"block"),variant:Mi(r,"variant"),formatter:Mi(r,"formatter"),datasource:Mi(r,"datasource")}}function Mi(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:{}}var YP,Al,Tv,Cv,kv,XP,JP,QP,ZP,Ev,Kn,qn=D(()=>{p();Go();Ga();Uo();(({localeDefault:YP}=We())),Al=new schema.Entity("block",{},{mergeStrategy(e,t){return t.block_input?e||{}:{...e,...t}}});Al.define({consumers:[Al],inputs:[Al]});Tv=new schema.Entity("variant"),Cv=new schema.Entity("dimension",{variants:[Tv]},{processStrategy(e){return {...e,variants:"variants"in e?e.variants:[]}}}),kv=new schema.Entity("section",{blocks:[Al]}),XP=new schema.Entity("report",{dimensions:[Cv],sections:[kv]},{processStrategy(e){return {...e,sections:"sections"in e?e.sections.sort(po):[]}}}),JP=new schema.Entity("formatter"),QP=new schema.Entity("datasource"),ZP={report:XP,section:kv,block:Al,dimension:Cv,variant:Tv,formatter:JP,datasource:QP};Ev=(e,t=void 0)=>{let{sid:o,bid:r,previews:n=[],query:i={}}=t||{},a,l,s={};return o?(a=o,s.activeSection=a):a=e.activeSection,n.length>0?(l=n,s.previews=l.filter(Boolean)):l=e.previews,{parsedParams:{sid:a,bid:r,previews:l,query:i},statusPayload:s}},Kn=(e=[],t=YP)=>e.reduce((o,r)=>{let n=$a({vars:["n"],logic:r.content.logic},{},t,{});return o[r.name]=n,o},{});});function Sr(e,t){return e.request(t).then(o=>{let{status:r,data:n}=o;return "error"in n?{ok:false,status:r,error:n.error}:{ok:true,status:r,wrapper:n.wrapper,data:n.data}},o=>{if("isAxiosError"in o){let{status:r,data:n}=o.response||{status:500};return {ok:false,status:r,error:n?.error??o.message}}return {ok:false,status:500,error:o.message}})}function Ze(e,t,o){let r=typeof t=="string"?{url:t}:t;return n=>Sr(e,{...r,method:"GET",params:o?o(n):n})}function at(e,t,o){let r=typeof t=="string"?{url:t}:t;return n=>Sr(e,{...r,method:"POST",data:n})}function Yn(e,t,o){let r=typeof t=="string"?{url:t}:t;return n=>Sr(e,{...r,method:"DELETE",params:o?o(n):n})}var Ha=D(()=>{p();});function Di(e,t){return o=>Sr(e,{method:"POST",url:`images/save/${t}`,params:{prompt:o.prompt,provider:t}})}var wv=D(()=>{p();Ha();});function Wa(e,t){return o=>Sr(e,{method:"GET",url:`images/search/${t}`,params:{prompt:o.prompt,page:o.page,provider:t}})}var Rv=D(()=>{p();Ha();});function Iv(e,t){return ()=>Sr(e,{method:"GET",url:`list/icons/${t}`,params:{provider:t}})}var Av=D(()=>{p();Ha();});function Pv(e,t){return o=>Sr(e,{method:"GET",url:`read/icons/${t}/icon.svg`,params:{name:o.name}})}var Ov=D(()=>{p();Ha();});function Pl(e){let t=Mu.create({baseURL:e});return {createBulkBlock:at(t,"create/bulk/block"),createBlock:at(t,"create/block"),createDimension:at(t,"create/dimension"),createFormatter:at(t,"create/formatter"),createReport:at(t,"create/report"),createSection:at(t,"create/section"),createVariant:at(t,"create/variant"),createDatasource:at(t,"create/datasource"),deleteBlock:Yn(t,"delete/block",_i),deleteDimension:Yn(t,"delete/dimension",_i),deleteFormatter:Yn(t,"delete/formatter",_i),deleteReport:Yn(t,"delete/report",_i),deleteSection:Yn(t,"delete/section",_i),deleteVariant:Yn(t,"delete/variant",_i),deleteDatasource:Yn(t,"delete/datasource",_i),readBlock:Ze(t,"read/block"),readDimension:Ze(t,"read/dimension"),readFormatter:Ze(t,"read/formatter"),readReport:Ze(t,"read/report"),readSection:Ze(t,"read/section"),readVariant:Ze(t,"read/variant"),readDatasource:Ze(t,"read/datasource"),updateBulkBlock:at(t,"update/bulk/block"),updateBlock:at(t,"update/block"),updateDimension:at(t,"update/dimension"),updateFormatter:at(t,"update/formatter"),updateReport:at(t,"update/report"),updateSection:at(t,"update/section"),updateVariant:at(t,"update/variant"),updateDatasource:at(t,"update/datasource"),searchReport:Ze(t,"search/reports"),validateVariantSlug:Ze(t,"validate/variant"),readMember:Ze(t,"read/members",tO),readMemberImage:Ze(t,{url:"member/image",responseType:"blob"}),searchMember:Ze(t,"search/members"),updateMember:Ze(t,"update/members"),imageLocalSearch:Wa(t,"local"),imageLocalSave:Di(t,"local"),imageFlickrSearch:Wa(t,"flickr"),imageFlickrSave:Di(t,"flickr"),imageUnsplashSearch:Wa(t,"unsplash"),imageUnsplashSave:Di(t,"unsplash"),imageUploadSave:Di(t,"upload"),imageAdobeSearch:Wa(t,"adobe"),imageAdobeSave:Di(t,"adobe"),imagePixabaySearch:Wa(t,"pixabay"),imagePixabaySave:Di(t,"pixabay"),readMetadata:Ze(t,"read/metadata"),regenerateSearch:at(t,"search/regenerate"),urlProxy:Ze(t,"url/proxy"),searchRole:Ze(t,"auth/search/roles"),searchUser:Ze(t,"auth/search/users"),readUser:Ze(t,"auth/read/user"),updateUser:at(t,"auth/update/user"),updateMyData:at(t,"auth/update/me"),revalidateReport:Ze(t,"revalidate/report"),revalidateUrl:Ze(t,"revalidate/url"),readPrivateBlocks:at(t,"read/blocks/private"),listTablerIcons:Iv(t,"tabler"),readTablerIcon:Pv(t,"tabler"),readEnvSecrets:Ze(t,"read/secrets")}}var _i,tO,Lv=D(()=>{p();wv();Rv();Ha();Av();Ov();_i=e=>({id:e}),tO=e=>{if(e.mode==="slugs"){let t=e.slugs.map(o=>[o.variantSlug,o.memberSlug].join("/")).join(",");return {...e,slugs:t}}return ["related","whole"].includes(e.mode)?{...e}:{...e,[e.mode]:e[e.mode].join(",")}};});var Cm=D(()=>{p();Lv();});var Ni,Mv,Tu=D(()=>{p();Ni="report",Mv="Report";});var Ol,Dv,Em=D(()=>{p();Tu();Ol="section",Dv="Section";});function or(e){return {variables:e.variables||{},query:e.query||{},locale:e.locale||oO}}var oO,Cu,zv,Xn=D(()=>{p();Em();Uo();(({localeDefault:oO}=We())),Cu="block",zv="Block";});var gn,Gv,$v,St,Eu,Uv,wm,rO,nO,iO,aO,Rm,Im,E,Pe,Ye,rr,_t,ku,ja,hn,wu,he=D(()=>{p();gn={REPORT:"report",SECTION:"section",BLOCK:"block",INPUT:"block_input",FORMATTER:"formatter",DATASOURCE:"datasource",DIMENSION:"report_dimension",VARIANT:"report_dimension_variant",SEARCH:"search"},[gn.BLOCK,gn.SEARCH],Gv={report:"Report",section:"Section",block:"Block",block_input:"Input",formatter:"Formatter",datasource:"Data Source",dimension:"Dimension",variant:"Variant",search:"Search"},{[gn.SECTION]:"report_id",[gn.DIMENSION]:"report_id",[gn.VARIANT]:"dimension_id",[gn.BLOCK]:"section_id",[gn.INPUT]:"block_id"},$v={REPORT:"report",STORY:"story"},St={SINGLE:"single",MULTI:"multi"},Eu={SEGMENTED_CONTROL:"segmented control",SELECTOR:"selector"},Uv={TITLE:"title",SUBTITLE:"subtitle",LABEL:"label"},{[$v.REPORT]:Object.values(Uv),[$v.STORY]:Object.values(Uv)},wm={ALLOWED:"allowed",ALLOWED_LOGIC:"allowedLogic",IGNORE_CASCADE:"ignoreCascade"},rO={ACCESS:"access",ACCESS_LOGIC:"accessLogic"},nO={DISABLED:"disabled"},iO={FALLBACK:"fallback"},{...wm},{POSITION:"position",ICON:"icon",...wm},aO={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"},Rm={GENERATOR:"generator",RELATED:"related",VIZ:"visualization",SECTION_FLAG:"section_flag"},Im="logic",E={...aO,...Rm},[E.GENERATOR,E.SECTION_FLAG,E.SELECTOR,E.VIZ,E.IMAGE,E.TABLE,E.MULTIHIERARCHY_SELECTOR],Pe={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"},[Pe.LOGIC,Pe.SIMPLE,Pe.SIMPLE_ENABLED],Ye={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}}},rr={[E.IMAGE]:[{field:Pe.TITLE,editorConfig:Ye.ENABLE_ALL},{field:Pe.SRC,editorConfig:Ye.DISABLE_ALL},{field:Pe.ALT,editorConfig:Ye.DISABLE_ALL},{field:Pe.DESC,editorConfig:Ye.ENABLE_ALL}],[E.PARAGRAPH]:[{field:E.PARAGRAPH,editorConfig:Ye.ENABLE_ALL},{field:Pe.TOOLTIP,editorConfig:Ye.ENABLE_FORMAT}],[E.SELECTOR]:[{field:Pe.SELECTOR_DEFAULT},{field:Pe.SELECTOR_DYNAMIC},{field:Pe.SELECTOR_NAME,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.SELECTOR_TYPE}],[E.STAT]:[{field:Pe.TITLE,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.SUBTITLE,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.VALUE,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.TOOLTIP,editorConfig:Ye.ENABLE_FORMAT}],[E.SUBTITLE]:[{field:Pe.SUBTITLE,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.TOOLTIP,editorConfig:Ye.ENABLE_FORMAT}],[E.TITLE]:[{field:Pe.TITLE,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.SLUG,editorConfig:Ye.DISABLE_ALL},{field:Pe.TOOLTIP,editorConfig:Ye.ENABLE_FORMAT}],[E.BUTTON]:[{field:Pe.LABEL,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.URL,editorConfig:Ye.ENABLE_FORMAT}],[E.GENERATOR]:[],[E.SECTION_FLAG]:[],[E.VIZ]:[],[E.TABLE]:[],[E.MULTIHIERARCHY_SELECTOR]:[{field:Pe.MULTIHIERARCHY_SELECTOR_NAME,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.MULTIHIERARCHY_SELECTOR_PLACEHOLDER,editorConfig:Ye.DISABLE_ALL},{field:Pe.MULTIHIERARCHY_SELECTOR_ALL_LABEL,editorConfig:Ye.DISABLE_ALL}],[E.NAV]:[{field:Pe.TITLE,editorConfig:Ye.ENABLE_FORMAT},{field:Pe.SHORT_TITLE,editorConfig:Ye.ENABLE_FORMAT}]},_t={NAME:"name",DESCRIPTION:"description",...wm,...rO,...iO,...nO},ku={FORMATTER:"formatter",FUNCTION:"function"},ja={[ku.FORMATTER]:"Formatter",[ku.FUNCTION]:"Function"},hn={STRING:"string",NUMBER:"number",OBJECT:"object",DATE:"date"},wu={[hn.STRING]:"String",[hn.NUMBER]:"Number",[hn.OBJECT]:"Object/Array",[hn.DATE]:"Date"};});function pO(e,t,o,r,n=void 0,i){let a={},l=[],{locale:s}=or(i);try{if(t){let c=new Proxy(console,{get(d,f){return dO(f,"log","debug","info","warn","error")?(...g)=>{l.push(`${f} ${Date.now()} - ${g.map(m=>format(m)).join(" ")}`),uO&&d[f](...g);}:d[f]}}),u;return n?u=new Function(e,"console","libs","formatters","locale","variables",o)(t,c,jn,r,s,n):u=new Function(e,"console","libs","formatters","locale",o)(t,c,jn,r,s),typeof u=="object"&&Object.keys(u).length>0&&Object.assign(a,u),{vars:a,error:null,log:l,output:u}}return {vars:a,error:"Invalid API Link",log:l}}catch(c){return {vars:a,error:c.message,log:l}}}function dO(e,...t){return t.includes(e)}var uO,Fr,Ka=D(()=>{p();Xn();ke();uO=Yl(process.env.REPORTS_LOGGING),Fr=pO;});function Am(e){return e.reduce((t,o,r)=>(r?r===e.length-1&&r===1?t+=` and ${o}`:r===e.length-1?t+=`, and ${o}`:t+=`, ${o}`:t+=o,t),"")}var Hv=D(()=>{p();});function mO(e,t,o,r=false){let{variables:n}=or(o);if(!e)return e;let i=/([A-z0-9]*)\{\{([^\}]+)\}\}/g;return e.replace(i,(l,s,c)=>{let u=f=>f;if(s){let f=s.replace(/^\w/g,g=>g.toLowerCase());f in t?u=t[f]:u=g=>`${s}${g}`;}let d=Array.isArray(n[c])?Am(n[c]):n[c];if(d===void 0)return r?l:"N/A";try{return u(d,jn,t)}catch(f){return console.error(`Error using formatter ${u.name}
2
+ `,`Error message: ${f.message}`),"N/A"}})}var et,Vr=D(()=>{p();Xn();Hv();ke();et=mO;});var Pm,xr,zi=D(()=>{p();Vr();Pm=(e,t,o)=>{let{variables:r}=o,n=a=>a.allowed==="never"?false:!a.allowed||a.allowed==="always"||r[a.allowed],i={...e};return Object.keys(i).forEach(a=>{typeof i[a]=="string"?i[a]=et(i[a],t,o):Array.isArray(i[a])?i[a]=i[a].filter(n).map(l=>typeof l=="object"?Pm(l,t,o):typeof l=="string"?et(l,t,o):l):typeof i[a]=="object"&&i[a]!==null&&!(i[a]instanceof Date)&&(i[a]=Pm(i[a],t,o));}),i},xr=Pm;});var Wv,jv=D(()=>{p();Wv=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{allowed:"always",label:t,id:t}:{allowed:"always",label:t.id,...t}):[];});var fO,Fi,Ru=D(()=>{p();he();fO=(e,t,o)=>{if(!o)return false;if(e===St.SINGLE)return o.find(n=>n.id===t);let r=Array.isArray(t)?t:t.split(",");return Array.isArray(r)&&r.every(n=>o.map(i=>i.id).includes(n))},Fi=fO;});function Iu(e,t,o,r,n=false){let{variables:i}=or(r),a=xr({logic:t},o,r).logic,l=Fr("variables",i,a,o,void 0,r),{vars:s,log:c,error:u}=l,d=s.type||St.SINGLE,f=s.component||"Selector",g=s.hideLabel||"false",m=s.resetSectionVars||"false",h=s.name||"Unlabeled Selector",y=Wv(s.options||[]),S=k=>d===St.MULTI&&!Array.isArray(k)?[k]:k,v=s.defaultValue,C;if(v&&(v=S(v),Fi(d,v,y)&&(C=v)),!C){let k=y&&y[0]&&y[0].id||y[0]||"";C=S(k);}if(n&&typeof window<"u"){let k=`selector${e}id`,w=new URLSearchParams(window.location.search),O=Object.fromEntries(w)[k];O&&!Fi(d,O,y)&&O!==void 0&&(w.delete(k),window.history.replaceState(null,null,`?${w.toString()}`));}return {config:{name:h,type:d,options:y,defaultValue:C,component:f,hideLabel:g,resetSectionVars:m},log:c,error:u}}var Om=D(()=>{p();Xn();he();Ka();zi();jv();Ru();});function Lm(e,t,o){if(!e)return false;let r=Array.isArray(o)?o:o.split(",");return Array.isArray(r)&&r.every(n=>e.map(i=>`${i[`${t} ID`]}`).includes(n))}var Kv=D(()=>{p();});function Au(e,t,o,r,n=false){let{variables:i}=or(r),a=xr({logic:t},o,r).logic,l=Fr("variables",i,a,o,void 0,r),{vars:s,log:c,error:u}=l;if(n&&typeof window<"u"){let f=`multihierarchySelector${e}-value`,g=`multihierarchySelector${e}-type`,m=new URLSearchParams(window.location.search),h=Object.fromEntries(m),y=h[f],S=h[g];y&&y!==void 0&&S&&S!==void 0&&!Lm(s.data,S,y)&&(m.delete(f),m.delete(g),window.history.replaceState(null,null,`?${m.toString()}`));}return {config:s,log:c,error:u}}var Mm=D(()=>{p();Kv();Xn();Ka();zi();});var gO,qv,Yv=D(()=>{p();he();gO=(e,t,o)=>{let r=`selector${e}id`,n=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(r),i=new URLSearchParams(t).get(r),a=n||i;if(o.type===St.MULTI){let c=a?a.split(","):o.defaultValue,u=o.options.filter(d=>c.includes(d.id));return {[`selector${e}id`]:c,[`selector${e}label`]:(u||[]).map(d=>d.label)}}let l=a&&o.options.find(c=>c.id===a)?a:o.defaultValue,s=o.options.find(c=>c.id===l);return {[`selector${e}id`]:l,[`selector${e}label`]:s&&s.label||void 0}},qv=gO;});var hO,Xv,Jv=D(()=>{p();hO=(e,t,o)=>{let r=`multihierarchySelector${e}-value`,n=`multihierarchySelector${e}-type`,i=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(r),a=new URLSearchParams(typeof location<"u"&&location?.search?location.search:"").get(n),l=new URLSearchParams(t).get(r),s=new URLSearchParams(t).get(n),c=i||l,u=a||s,d=c?c.split(","):o.defaultValue||[],f=u||o.defaultValueType||"",g=o.data?.filter(m=>d.includes(`${m[`${f} ID`]}`))||[];return {[`multihierarchySelector${e}id`]:d,[`multihierarchySelector${e}label`]:[...new Set((g||[]).map(m=>m[f]))],[`multihierarchySelector${e}type`]:f}},Xv=hO;});var Qv,bO,yO,Tr,ko,Ho=D(()=>{p();he();Uo();(({localeDefault:Qv,locales:bO}=We())),yO=Object.values(Rm),Tr=(e,t=Qv)=>e&&yO.includes(e.type)?{locale:Im,locales:[Im]}:{locale:t,locales:bO},ko=(e,t=Qv)=>{if(!e)return {};let{locale:o}=Tr(e,t);return e.contentByLocale?.[o]?.content};});function vO(e,t){let o=Object.values(t),r=o.filter(n=>n.shared&&n.section_id!==e).map(n=>n.id);return Object.fromEntries(o.filter(n=>n.section_id===e&&(n.inputs.length===0||n.inputs.some(i=>r.includes(i)))).map(n=>[n.id,n]))}var Zv,eS=D(()=>{p();Zv=vO;});var tS,Pu,Bm=D(()=>{p();tS=e=>{let t=[];if(Array.isArray(e))return [];let o=(r,n="")=>{!r||typeof r!="object"||Object.keys(r).forEach(i=>{if(Array.isArray(r[i]))t.push(`${n?`${n}.`:""}${i}`);else if(typeof r[i]=="object")o(r[i],`${n?`${n}.`:""}${i}`);else return});};return o(e),t},Pu=(e,t)=>t&&typeof t=="string"?t.split(".").reduce((o,r)=>o[r],e):e;});var Eo,oS,rS,Cr=D(()=>{p();Eo="SECTION_ALLOWED",oS=`// const {anotherVariable} = variables; (From context and inputs)
3
3
  // const {toUpper} = formatters; (Ad-hoc formatters)
4
4
  // const currentLocale = locale;
5
5
  // const {d3} = libs; (Preset libraries)
@@ -8,7 +8,7 @@ return {
8
8
  // propery1: true,
9
9
  // propery2: [1,2,3],
10
10
  // propery3: {innerProperty1: 1, innerProperty2: "text" }
11
- }`,oS=`// const {anotherVariable} = variables; (From context and inputs)
11
+ }`,rS=`// const {anotherVariable} = variables; (From context and inputs)
12
12
  // const {toUpper} = formatters; (Ad-hoc formatters)
13
13
  // const currentLocale = locale;
14
14
  // const {d3} = libs; (Preset libraries)
@@ -28,56 +28,56 @@ return {
28
28
  groupBy: "id",
29
29
  x: "x",
30
30
  y: "y"
31
- }`;});function fo(e){return e.type===E.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var Zn=N(()=>{p();he();});function SO(){let{publicRuntimeConfig:e}=vO(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((o,r)=>(o[`ENV_${r}`]=t[r]||"N/A",o),{})}}var Ro,ei=N(()=>{p();Ro=SO;});function xO(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,o])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:o}),{})}var rS,nS=N(()=>{p();rS=xO;});function Lu(e){return e.ok!==void 0}function Ou(e){this.message=e,this.name="ApiFetchException";}async function Bm(e,t,o="en",r,n,i){let a=Date.now(),l=e,s,c=Ro(),u=rS(),d={envs:{...c,...u}},m=new URL(e),g=new URLSearchParams(m.searchParams.toString());g.has("bespoke_slugs")&&(m.searchParams.delete("bespoke_slugs"),l=m.toString());let f={datasource:void 0};r.find(C=>{if(!C.content?.pattern)return false;try{let b=new RegExp(C.content.pattern,"gm");return b.test(l)?(f.datasource=C,!0):b.test(l)}catch{return false}});let h=n?n.settings:{},v=!!(h&&h.useProxy&&h.useProxy==="true"),T=f.datasource&&typeof f.datasource.content.useProxy=="boolean"?f.datasource.content.useProxy:false,y=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(l)}`;if(typeof window=="object"&&(v||T)){let C=await IO({url:l,timeout:aS});if(C.ok===true)s=C.data;else throw new Ou(C?.error)}else try{let b={url:l,timeout:aS};if(f.datasource){let k=d;i&&(k={...d,session:i});let O=typeof window>"u"&&f.datasource.content.logic_ssr?f.datasource.content.logic_ssr:f.datasource.content.logic,_=await Ga({vars:["url","libs","session"],logic:O},k)(l);if(_.axiosConfig)b=_.axiosConfig;else throw new Ou(`AxiosConfig is missing in Data Source ${f.datasource.name} (ID: ${f.datasource.id}).`)}let w=await Mu(b);if(w.status===200)w.headers["content-type"]==="text/csv"?s=csvParse(w.data):s=w.data;else throw new Ou("No response for: "+l)}catch(C){throw new Ou(C.message)}if(g.has("bespoke_slugs")){let C=g.get("bespoke_slugs");if(C){let b=C.split(",");if(b.length===3){let[w,k,I]=b,O=Pu(s,I);if(O&&Array.isArray(O)){let P=Array.from(new Set(O.map(_=>`${_[k]}`).filter(_=>!["","undefined"].includes(_))));if(P.length>0){let _=P.join("").length>2e3,D=await t({mode:_?"whole":"ids",ids:_?void 0:P,all:false,locale:o,variant:[parseInt(w,10)],output:"lite",limit:P.length+1,allowNulls:true}).then(L=>{let R=[];return Lu(L)?L.ok&&(R=L.data.results):R=L.results,R&&Array.isArray(R)?R:[]}).catch(L=>(console.error(`Error hydrating slugs for Variant: ${w}, Key: ${k}, Accessor: ${I}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(L),[]));if(D){let L=Object.fromEntries(D.map(R=>[R.id,`/${R.variant_slug}/${R.slug}`]));O.map(R=>(R.bespoke_slug=L[R[k]]?L[R[k]]:null,R));}}}}}}return {data:s,requestDuration:Date.now()-a,finalUrl:T||v?y:l,apiDataSource:f.datasource?f.datasource:false}}function AO(e){this.name="BlockException",this.message=e;}async function Ml(e,t,o,r,n,i){let{locale:a,variables:l,query:s}=rr(o),c=PO(e,o,l,t),u=null,d=e.contentByLocale?.logic?.content?.api,m=null,g=null,f=null,h=null,v=null;if(!c)return {outputVariables:{},renderVariables:{},status:{allowed:false,hiddenByCascade:e.id}};if(e.type===E.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:c,hiddenByCascade:e.id}};if(d){f=RO(d,t,o);let O=f.split("|||").filter(D=>D!==""),P=[];for(let D=0;D<O.length;D++){let L=O[D];new RegExp("^(?:[a-z+]+:)?//","i").test(f)||(L=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${L}`.replace(/([^:]\/)\/+/g,"$1")),P.push(Bm(L,r,a,n,e,i).catch(z=>{throw new AO(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${l.report_name} (${l.report_id}) failed.
32
- Error fetching ${L}.
33
- Message: ${z.message}.
34
- `)}));}let _=await Promise.all(P).catch(D=>D.message);if(typeof _=="string"&&_)return {outputVariables:{},renderVariables:{},status:{error:_}};u=_.length===1?_[0].data:_.map(D=>D.data),g=_.reduce((D,L)=>D+JSON.stringify(L.data).length/1024,0),m=Math.max(..._.map(D=>D.requestDuration)),h=_.map(D=>D.apiDataSource?`${D.apiDataSource.name} (${D.apiDataSource.id})`:null),v=_.map(D=>D.finalUrl);}if(e.type===E.SELECTOR){let{config:O,log:P,error:_}=Iu(e.id,e.contentByLocale[a].content.logic,t,o,true);return {outputVariables:Kv(e.id,s,O),renderVariables:O,status:{log:P,error:_,allowed:c}}}if(e.type===E.MULTIHIERARCHY_SELECTOR){let{config:O,log:P,error:_}=Au(e.id,e.contentByLocale[a].content.logic,t,o,true);return {outputVariables:Yv(e.id,s,O),renderVariables:O,status:{log:P,error:_,allowed:c}}}if(e.type===E.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:c}};if(e.type===E.RELATED){let O=e.contentByLocale?.logic?.content?.simple?.compare||"variant",P=e.contentByLocale?.logic?.content?.simple?.limit||4,_=Object.keys(l).filter(U=>U.startsWith("report_id")).map(U=>l[U]),D=Object.keys(l).filter(U=>U.startsWith("dimension_id")).map(U=>l[U]),L=Object.keys(l).filter(U=>U.startsWith("variant_id")).map(U=>l[U]),R=Object.keys(l).filter(U=>U.startsWith("id")).map(U=>l[U]);if(!R.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:false}};let z=await Promise.all(R.map((U,$)=>r({mode:"ids",locale:a,ids:[U],output:"lite",variant:[L[$]]}))).then(U=>U.flatMap($=>{let Y=[];return Lu($)?$.ok&&(Y=$.data.results):Y=$.results,Y&&Array.isArray(Y)?Y:[]})).catch(U=>(console.error("Error getting related members",U),[]));if(D.length>1){let U=Object.keys(l).filter(X=>X.startsWith("variant_slug")).map(X=>l[X]),$=z.map((X,W)=>{let K={mode:"related",locale:a,related:P??4,current_ids:[X.content_id],output:"full",variant_ids:[X.variant_id]};return W===0&&(K.include_ids=[X.content_id]),K}),Y=await Promise.all($.map(X=>r(X))).then(X=>X.flatMap(W=>{let K=[];return Lu(W)?W.ok&&(K=W.data.results):K=W.results,K&&Array.isArray(K)?K:[]})).catch(X=>(console.error("Error getting related members",X),[])),F=Y.reduce((X,W)=>{let K=W.variant_slug;return X[K]||(X[K]=[]),X[K].push(W),X},{}),G=[],J=Object.keys(F),ee=[{combination:[],index:0}];for(;ee.length>0;){let X=ee.pop();if(!X)continue;let{combination:W,index:K}=X;if(K===J.length){G.push(W);continue}let oe=J[K],re=F[oe];for(let ue of re)ee.push({combination:[...W,ue],index:K+1});}return {outputVariables:{related_reports:G.map(X=>{let W=X.sort((K,oe)=>U.indexOf(K.variant_slug)-U.indexOf(oe.variant_slug));return {entities:W,link:"/"+W.map(K=>`${K.variant_slug}/${K.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:Y.length>0}}}let A=z.map(U=>U.content_id),V={mode:"related",locale:a,related:P??4,current_ids:A,output:"full"};O&&(O==="report"?V.report_ids=_:O==="dimension"?V.dimension_ids=D:V.variant_ids=L);let j=await r(V).then(U=>{let $=[];return Lu(U)?U.ok&&($=U.data.results):$=U.results,$&&Array.isArray($)?$:[]}).catch(U=>(console.error("Error getting related members",U),[]));return {outputVariables:{related_reports:j.map(U=>({entities:[U],link:`/${U.variant_slug}/${U.slug}`}))},renderVariables:{},status:{log:[],allowed:j.length>0}}}let{logic:T}=Eo(e,a),y=et(T,t,o),C=$r("resp",u||{},y,t,l,o),{vars:b,error:w,log:k}=C;if(typeof b!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:k,duration:m,responseSize:g,resp:u,api:f,allowed:c,apiFinalUrls:v,apiDataSources:h}};let I=Object.keys(b).reduce((O,P)=>({...O,[`${e.type}${e.id}${P}`]:b[P]}),{});return {renderVariables:b,outputVariables:[E.GENERATOR,E.SECTION_FLAG].includes(e.type)?b:I,status:{log:k,error:w,duration:m,responseSize:g,resp:u,api:f,allowed:c,apiFinalUrls:v,apiDataSources:h}}}function lS(e,t,o,r,n,i,a){return e.consumers.forEach(l=>{if(t[l]){let s=`${o}-${l}`;!r.includes(s)&&(t[l].section_id===t[o].section_id||!n)&&r.push(s),e.consumers.filter(c=>t[c]&&t[c].section_id===t[o].section_id||!n).forEach(c=>Dm(c,t,r,false,i,n,a));}})}var ti,EO,wO,sS,RO,IO,aS,Dm,PO,oi,cS,_m,vn=N(()=>{p();Tm();Qn();he();Pm();Lm();qv();Xv();qa();Ur();Wo();Zv();Mm();kr();Zn();Ha();ei();nS();ti=Yl(process.env.NEXT_PUBLIC_REPORTS_DEBUG),EO=process.env.REPORTS_ORIGIN||"",wO=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,sS=5;try{sS=parseInt(`${wO||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}iS(Mu,{retries:sS,retryDelay:iS.exponentialDelay,onRetry:(e,t,o)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",o.url),console.error(t.message);}});Mu.interceptors.request.use(e=>({...e,requestStart:Date.now()}));Mu.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));RO=(e,t,o)=>{let r=et(e,t,o);return r.startsWith("http")||(r=`${EO}${r.startsWith("/")?"":"/"}${r}`),r},{urlProxy:IO}=Ol("/api/cms");aS=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;Dm=(e,t,o=[],r=true,n=true,i=true,a=[])=>{if(a.includes(e))return [];a.push(e);let l=t[e];return l&&l.inputs.length&&r&&l.inputs.forEach(s=>{let c=`${s}-${e}`;o.includes(c)||o.push(c),l.inputs.forEach(u=>Dm(u,t,o,r,false,i,a));}),l&&l.consumers.length&&n&&lS(l,t,e,o,i,n,a),o},PO=(e,t,o,r)=>{let n=true;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=false;else {let i=rr(t),{error:a,output:l}=$r("variables",o,e.settings.allowedLogic||"return false;",r,void 0,i);a||(n=!!l);}return n},oi=async(e,t,o,r,n,i={},a,l="section",s,c)=>{let u=l==="section",d=rr(n),m=d.variables,g={...i.variables??{}},f={...i.status??{}},h=new Set,v=[],T={};o?T={...T,[o]:e[o]}:t?T=(t??[]).reduce((A,{id:V})=>({...A,...Qv(V,e)}),{}):T=Object.values(e).filter(A=>fo(A)).reduce((A,V)=>({...A,[V.id]:V}),{});let y=Object.values(T).filter(A=>fo(A));if(y.length>0){ti&&console.info("%crunConsumers: calculating section flags","color:purple",y.map(B=>B.id).join(", "));let A=Object.fromEntries(await Promise.all(y.map(async B=>[B.id,await Ml(B,r,{...d,variables:m,locale:m.locale},a,s,c).then(U=>{let{outputVariables:$,status:Y}=U;if(Y.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${B.id}, Section ${B.section_id}) failed with message: ${Y.error}. `);f[B.id]={allowed:false,error:Y.error},g[B.id]={};}return (B.consumers.length>0||[E.GENERATOR,E.SECTION_FLAG,E.RELATED].includes(B.type))&&Y.allowed&&Object.keys($).length>0?g[B.id]=$:g[B.id]={},l==="report"?(f[B.id]={allowed:Y.allowed},[E.GENERATOR,E.SECTION_FLAG].includes(B.type)&&Y.api&&(f[B.id].api=Y.api)):f[B.id]=Y,U})]))),j=Object.entries(A).filter(([,B])=>!B.outputVariables[wo]).map(([B])=>Number(B));h=new Set(j.map(B=>e[B].section_id)),Object.values(T).filter(B=>h.has(B.section_id)).forEach(B=>{v.push(B.id),delete T[B.id];}),ti&&console.info("%crunConsumers: removing sections","color:purple",h.keys());}let C=h.size>0?Object.fromEntries(Object.entries(e).filter(([,A])=>h?.has(A.section_id)?(v.includes(A.id)||v.push(A.id),false):true)):e;if(v.length>0&&(C=Object.fromEntries(Object.entries(C).map(([A,V])=>{let j={...V,inputs:V.inputs.filter(B=>!v.includes(B)),consumers:V.consumers.filter(B=>!v.includes(B))};return [A,j]}))),!o&&!t)return {variables:{...i.variables??{},...g},status:{...i.status??{},...f}};l==="report"&&v.length>0&&v.forEach(A=>{delete g[A],delete f[A],delete e[A];}),ti&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(T));let b=Object.keys(T).reduce((A,V)=>{let j=new Date,B=Dm(Number(V),C,[],!o,true,u).map(Y=>Y.split("-")),$=(new Date().getTime()-j.getTime())/1e3;return ti&&console.info(`%cResolved dependencies for ${V} (${$.toFixed(2)}s)`,"color:blue"),[...A,...B]},[]),w=new Date,k=Object.keys(T).reduce((A,V)=>A.includes(V)?[...A]:[V,...A],TO(b)),O=(new Date().getTime()-w.getTime())/1e3;ti&&console.info(`%cResolved DAG (${O.toFixed(2)}s): `,"color:green",k);let P=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,_=parseInt(`${P||0}`,10);async function D(A,V){let j=new Map,B=[],U=async()=>B.length;for(let $ of A){if(_!==0){let J=await U();for(;J>=_;)ti&&console.info("Too many pending promises, waiting...",J,B),await new Promise(ee=>setTimeout(ee,500)),J=await U();}let Y=V[$],G=Promise.all(Y.inputs.filter(J=>A.includes(String(J))).map(J=>j.get(Number(J)))).then(async()=>{let J=Y.inputs.reduce((re,ue)=>({...re,...g[ue]}),m),ee=Y.inputs.find(re=>(Y.settings?.ignoreCascade?Y.settings?.ignoreCascade:[]).includes(re)||!f[re]?false:!f[re].allowed||f[re].hiddenByCascade);if(ee){f[$]={allowed:false,hiddenByCascade:f[ee].hiddenByCascade||ee},g[$]={},B.splice(B.indexOf(Number($)),1);return}let ne=new Date,X;typeof window<"u"&&[E.SELECTOR,E.MULTIHIERARCHY_SELECTOR].includes(Y.type)&&Y.settings[_t.DISABLED]?X=new Promise(re=>{re({outputVariables:g[$],status:f[$]});}):X=Ml(Y,r,{...d,variables:J,locale:J.locale},a,s,c);let W=await X.then(({outputVariables:re,status:ue})=>{if(ue.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${$}, Section ${Y.section_id}) failed with message: ${ue.error}.`);f[$]={allowed:false,error:ue.error},g[$]={};}(Y.consumers.length>0||[E.GENERATOR,E.SECTION_FLAG,E.RELATED].includes(Y.type))&&ue.allowed&&Object.keys(re).length>0?g[$]=re:g[$]={},l==="report"?(f[$]={allowed:ue.allowed},[E.GENERATOR,E.SECTION_FLAG].includes(Y.type)&&ue.api&&(f[$].api=ue.api)):f[$]=ue;}),oe=(new Date().getTime()-ne.getTime())/1e3;return ti&&console.info(`%cBlock ${Y.id} resolved in ${oe.toFixed(3)}s`,oe>500?"color:red":"color:green"),f[$].duration=f[$].duration?f[$].duration:oe,B.splice(B.indexOf(Number($)),1),W}).catch(J=>{throw B.splice(B.indexOf(Number($)),1),J});B.push(Number($)),j.set(Number($),G);}await Promise.all(Array.from(j.values()));}let L=new Date;await D(k,C);let z=(new Date().getTime()-L.getTime())/1e3;return ti&&console.info(`%cResolved Variables (${z.toFixed(2)}s), ${k.length} blocks`,"color:green"),{variables:{...i.variables??{},...g},status:{...i.status??{},...f}}},cS=e=>e<250?"green":e<1e3?"yellow":"red",_m=e=>e<10?"green":e<100?"yellow":"red";});function OO(e=[]){return e.reduce((t,o,r)=>{if(o){let n=r+1;t[`id${n}`]=o.id,t[`name${n}`]=o.name,t[`slug${n}`]=o.slug,"attributes"in o&&Object.keys(o.attributes).forEach(i=>{t[`attr_${i}${n}`]=o.attributes[i];}),t[`variant_id${n}`]=o.variant_id,t[`variant_name${n}`]=o.variant_name,t[`variant_slug${n}`]=o.variant_slug,t[`dimension_id${n}`]=o.dimension_id,t[`dimension_name${n}`]=o.dimension_name,t.report_id=o.report_id,t.report_name=o.report_name;}return t},{})}var uS,pS=N(()=>{p();uS=OO;});var Er,Bu,Bl=N(()=>{p();Er=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",Bu=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[Er];Bu.includes(Er)||Bu.push(Er);});var BO,Du,Io,Ya=N(()=>{p();Bl();BO={localeDefault:Er,locales:Bu,currentLocale:Er,preferredLocale:Er,showToolbar:false,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:true,settings:false,reportEditor:false},isCMS:false,isRunConsumersRunning:[]},Du=createSlice({name:"status",initialState:BO,reducers:{setStatus:(e,t)=>{Object.assign(e,t.payload);},setPreviews(e,t){e.previews=t.payload;},setCurrentLocale(e,t){e.currentLocale=t.payload;},setPreferredLocale(e,t){e.preferredLocale=t.payload;},setSectionState(e,t){e.sectionState={...e.sectionState,...t.payload};},resetSectionState(e,t){e.sectionState={...e.sectionState,[t.payload]:{}};},setActiveEntity(e,t){e.activeEntity=t.payload;},openSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:true};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:false};},toggleSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!e.sidebarStatus[t.payload]};},addRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.concat(t.payload);},removeRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.filter(o=>!t.payload.includes(o));}},extraReducers:{[HYDRATE]:(e,t)=>({...e,previews:t.payload.status.previews})}}),Io=Du.actions;});var NO,_u,Ui,Xa=N(()=>{p();NO={attributes:{},variables:{},status:{}},_u=createSlice({name:"variables",initialState:NO,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}})}}),Ui=_u.actions;});function Dl(e,t){return Object.fromEntries(Object.keys(e).map(o=>[o,{...e[o],...t[o]}]))}function Nu(e,t){return e.map(n=>t[n]).sort((n,i)=>typeof n.ordering=="string"&&typeof i.ordering=="string"?mo(n,i):typeof n.ordering=="number"&&typeof i.ordering=="number"?n.ordering-i.ordering:String(n.ordering).localeCompare(String(i.ordering))).map(n=>n.id)}function $O(e,t){let o=e.indexOf(t);o>-1&&e.splice(o,1);}var VO,Sn,_l=N(()=>{p();Ho();Xn();VO={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},Sn=createSlice({name:"records",initialState:VO,reducers:{set:(e,t)=>{let o=t.payload;return {entities:Dl(e.entities,o.entities||{}),requests:Dl(e.requests,o.requests||{}),reports:o.reports||e.reports,tree:o.tree||e.tree}},setRequest:(e,t)=>{let o=t.payload;e.requests[o.type][o.key]=o;},setCreateRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let r=Array.isArray(o.data)?o.data:[o.data],n=xu(o.type,r),i=Dl(e.entities,n);if(e.entities=i,o.type==="report"){let a=o.data;e.reports?e.reports.indexOf(a.id)===-1&&(e.reports=[...e.reports,a.id]):e.reports=[a.id];}else if(o.type==="dimension"){let a=o.data;e.entities.report[a.report_id].dimensions.push(a.id),e.entities.report[a.report_id].dimensions=Nu(i.report[a.report_id].dimensions,i.dimension);}else if(o.type==="variant"){let a=o.data;e.entities.dimension[a.dimension_id].variants.push(a.id);}else if(o.type==="section"&&!Array.isArray(o.data)){let a=o.data;e.entities.report[a.report_id].sections.push(a.id),e.entities.report[a.report_id].sections=Nu(i.report[a.report_id].sections,i.section);}else if(o.type==="block")if(Array.isArray(o.data)){let a=o.data,l=a[0],s=a.map(c=>c.id);e.entities.section[l.section_id].blocks.concat(s);}else {let a=o.data;e.entities.section[a.section_id].blocks.push(a.id);}}},setReadRequest(e,t){let o=t.payload;if(o.type!=="report"&&(e.requests[o.type][o.key]=o),o.status==="SUCCESS"){let r=xu(o.type,o.data),n=Dl(e.entities,r);e.entities=n;}},setUpdateRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let r=Array.isArray(o.data)?o.data:[o.data],n=xu(o.type,r),i,a,l;if(o.type==="block"&&!Array.isArray(o.data)){let c=e.entities.block[o.data.id].inputs,u=n.block[o.data.id].inputs;i=c.length!==u.length,i&&(l=c.length>u.length,a=l?c.filter(d=>!u.includes(d))[0]:u.filter(d=>!c.includes(d))[0]),Object.values(n.block).forEach(d=>{d.block_input&&delete n.block[d.id];});}let s=Dl(e.entities,n);if(e.entities=s,o.type==="dimension"){let c=o.data;e.entities.report[c.report_id].dimensions=Nu(s.report[c.report_id].dimensions,s.dimension);}else if(o.type==="section"&&!Array.isArray(o.data)){let c=o.data;e.entities.report[c.report_id].sections=Nu(s.report[c.report_id].sections,s.section);}else if(o.type==="block"&&!Array.isArray(o.data)){let c=o.data;i&&(l?e.entities.block[a].consumers=e.entities.block[a].consumers.filter(u=>u!==c.id):e.entities.block[a].consumers.push(c.id));}}},setDeleteRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let{id:r,parentId:n,parentType:i}=o.data;if(delete e.entities[o.type][r],i&&n!=null){let a=`${o.type}s`;$O(e.entities[i][n][a],r);}}},removeBlocks:(e,t)=>{let o=t.payload,r={...e.entities.block};return o.forEach(n=>{delete r[n];}),{...e,entities:{...e.entities,block:r}}},addBlocks:(e,t)=>{let o=t.payload;return {...e,entities:{...e.entities,block:{...e.entities.block,...o}}}},removeDataSourceLogic:e=>{let t={...e.entities.datasource};Object.keys(t).forEach(o=>{e.entities.datasource[o].content.useProxy&&(delete e.entities.datasource[o].content.logic,delete e.entities.datasource[o].content.logic_ssr,delete e.entities.datasource[o].content.testUrl,delete e.entities.datasource[o].content.access);});}},extraReducers:{[HYDRATE]:(e,t)=>{let o=t.payload.records,r=o.entities;return {entities:r,reports:Object.values(r.report).map(n=>n.id),requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},tree:o.tree}}}});});function UO(e){return {ok:false,status:Gi.is(e)?e.code:500,error:e.message}}function Hi(e,t,o){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${dS(o)}`;return e[n]}let r=`${t}${dS(o)}`;return e[r]}function dS(e){return e[0].toUpperCase()+e.slice(1)}var Gi,zu=N(()=>{p();Gi=class extends Error{constructor(t,o){super(o),this.code=t;}toJSON(){return UO(this)}static is(t){return Object.prototype.hasOwnProperty.call(t,"code")&&typeof t.code=="number"}};});function Nt(e){for(var t=arguments.length,o=Array(t>1?t-1:0),r=1;r<t;r++)o[r-1]=arguments[r];if(process.env.NODE_ENV!=="production"){var n=XO[e],i=n?typeof n=="function"?n.apply(null,o):n:"unknown error nr: "+e;throw Error("[Immer] "+i)}throw Error("[Immer] minified error nr: "+e+(o.length?" "+o.map((function(a){return "'"+a+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Ja(e){return !!e&&!!e[jo]}function ji(e){var t;return !!e&&((function(o){if(!o||typeof o!="object")return false;var r=Object.getPrototypeOf(o);if(r===null)return true;var n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===JO})(e)||Array.isArray(e)||!!e[SS]||!!(!((t=e.constructor)===null||t===void 0)&&t[SS])||jm(e)||Km(e))}function zl(e,t,o){o===void 0&&(o=false),Za(e)===0?(o?Object.keys:Qm)(e).forEach((function(r){o&&typeof r=="symbol"||t(r,e[r],e);})):e.forEach((function(r,n){return t(n,r,e)}));}function Za(e){var t=e[jo];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:jm(e)?2:Km(e)?3:0}function $m(e,t){return Za(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function GO(e,t){return Za(e)===2?e.get(t):e[t]}function xS(e,t,o){var r=Za(e);r===2?e.set(t,o):r===3?e.add(o):e[t]=o;}function HO(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function jm(e){return qO&&e instanceof Map}function Km(e){return YO&&e instanceof Set}function Wi(e){return e.o||e.t}function qm(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=QO(e);delete t[jo];for(var o=Qm(t),r=0;r<o.length;r++){var n=o[r],i=t[n];i.writable===false&&(i.writable=true,i.configurable=true),(i.get||i.set)&&(t[n]={configurable:true,writable:true,enumerable:i.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function Ym(e,t){return t===void 0&&(t=false),Xm(e)||Ja(e)||!ji(e)||(Za(e)>1&&(e.set=e.add=e.clear=e.delete=WO),Object.freeze(e),t&&zl(e,(function(o,r){return Ym(r,true)}),true)),e}function WO(){Nt(2);}function Xm(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function Gr(e){var t=ZO[e];return t||Nt(18,e),t}function mS(){return process.env.NODE_ENV==="production"||Qa||Nt(0),Qa}function Nm(e,t){t&&(Gr("Patches"),e.u=[],e.s=[],e.v=t);}function Fu(e){Um(e),e.p.forEach(jO),e.p=null;}function Um(e){e===Qa&&(Qa=e.l);}function fS(e){return Qa={p:[],l:Qa,h:e,m:true,_:0}}function jO(e){var t=e[jo];t.i===0||t.i===1?t.j():t.g=true;}function zm(e,t){t._=t.p.length;var o=t.p[0],r=e!==void 0&&e!==o;return t.h.O||Gr("ES5").S(t,e,r),r?(o[jo].P&&(Fu(t),Nt(4)),ji(e)&&(e=Vu(t,e),t.l||$u(t,e)),t.u&&Gr("Patches").M(o[jo].t,e,t.u,t.s)):e=Vu(t,o,[]),Fu(t),t.u&&t.v(t.u,t.s),e!==TS?e:void 0}function Vu(e,t,o){if(Xm(t))return t;var r=t[jo];if(!r)return zl(t,(function(l,s){return gS(e,r,t,l,s,o)}),true),t;if(r.A!==e)return t;if(!r.P)return $u(e,r.t,true),r.t;if(!r.I){r.I=true,r.A._--;var n=r.i===4||r.i===5?r.o=qm(r.k):r.o,i=n,a=false;r.i===3&&(i=new Set(n),n.clear(),a=true),zl(i,(function(l,s){return gS(e,r,n,l,s,o,a)})),$u(e,n,false),o&&e.u&&Gr("Patches").N(r,o,e.u,e.s);}return r.o}function gS(e,t,o,r,n,i,a){if(process.env.NODE_ENV!=="production"&&n===o&&Nt(5),Ja(n)){var l=Vu(e,n,i&&t&&t.i!==3&&!$m(t.R,r)?i.concat(r):void 0);if(xS(o,r,l),!Ja(l))return;e.m=false;}else a&&o.add(n);if(ji(n)&&!Xm(n)){if(!e.h.D&&e._<1)return;Vu(e,n),t&&t.A.l||$u(e,n);}}function $u(e,t,o){o===void 0&&(o=false),!e.l&&e.h.D&&e.m&&Ym(t,o);}function Fm(e,t){var o=e[jo];return (o?Wi(o):e)[t]}function hS(e,t){if(t in e)for(var o=Object.getPrototypeOf(e);o;){var r=Object.getOwnPropertyDescriptor(o,t);if(r)return r;o=Object.getPrototypeOf(o);}}function Gm(e){e.P||(e.P=true,e.l&&Gm(e.l));}function Vm(e){e.o||(e.o=qm(e.t));}function Hm(e,t,o){var r=jm(t)?Gr("MapSet").F(t,o):Km(t)?Gr("MapSet").T(t,o):e.O?(function(n,i){var a=Array.isArray(n),l={i:a?1:0,A:i?i.A:mS(),P:false,I:false,R:{},l:i,t:n,k:null,o:null,j:null,C:false},s=l,c=Wm;a&&(s=[l],c=Nl);var u=Proxy.revocable(s,c),d=u.revoke,m=u.proxy;return l.k=m,l.j=d,m})(t,o):Gr("ES5").J(t,o);return (o?o.A:mS()).p.push(r),r}function KO(e){return Ja(e)||Nt(22,e),(function t(o){if(!ji(o))return o;var r,n=o[jo],i=Za(o);if(n){if(!n.P&&(n.i<4||!Gr("ES5").K(n)))return n.t;n.I=true,r=bS(o,i),n.I=false;}else r=bS(o,i);return zl(r,(function(a,l){n&&GO(n.t,a)===l||xS(r,a,t(l));})),i===3?new Set(r):r})(e)}function bS(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return qm(e)}var yS,Qa,Jm,qO,YO,vS,TS,SS,jo,XO,JO,Qm,QO,ZO,Wm,Nl,eL,Ko,tL,Uu,CS=N(()=>{p();Jm=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",qO=typeof Map<"u",YO=typeof Set<"u",vS=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",TS=Jm?Symbol.for("immer-nothing"):((yS={})["immer-nothing"]=true,yS),SS=Jm?Symbol.for("immer-draftable"):"__$immer_draftable",jo=Jm?Symbol.for("immer-state"):"__$immer_state",XO={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"},JO=""+Object.prototype.constructor,Qm=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,QO=Object.getOwnPropertyDescriptors||function(e){var t={};return Qm(e).forEach((function(o){t[o]=Object.getOwnPropertyDescriptor(e,o);})),t},ZO={},Wm={get:function(e,t){if(t===jo)return e;var o=Wi(e);if(!$m(o,t))return (function(n,i,a){var l,s=hS(i,a);return s?"value"in s?s.value:(l=s.get)===null||l===void 0?void 0:l.call(n.k):void 0})(e,o,t);var r=o[t];return e.I||!ji(r)?r:r===Fm(e.t,t)?(Vm(e),e.o[t]=Hm(e.A.h,r,e)):r},has:function(e,t){return t in Wi(e)},ownKeys:function(e){return Reflect.ownKeys(Wi(e))},set:function(e,t,o){var r=hS(Wi(e),t);if(r?.set)return r.set.call(e.k,o),true;if(!e.P){var n=Fm(Wi(e),t),i=n?.[jo];if(i&&i.t===o)return e.o[t]=o,e.R[t]=false,true;if(HO(o,n)&&(o!==void 0||$m(e.t,t)))return true;Vm(e),Gm(e);}return e.o[t]===o&&(o!==void 0||t in e.o)||Number.isNaN(o)&&Number.isNaN(e.o[t])||(e.o[t]=o,e.R[t]=true),true},deleteProperty:function(e,t){return Fm(e.t,t)!==void 0||t in e.t?(e.R[t]=false,Vm(e),Gm(e)):delete e.R[t],e.o&&delete e.o[t],true},getOwnPropertyDescriptor:function(e,t){var o=Wi(e),r=Reflect.getOwnPropertyDescriptor(o,t);return r&&{writable:true,configurable:e.i!==1||t!=="length",enumerable:r.enumerable,value:o[t]}},defineProperty:function(){Nt(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Nt(12);}},Nl={};zl(Wm,(function(e,t){Nl[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};})),Nl.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Nt(13),Nl.set.call(this,e,t,void 0)},Nl.set=function(e,t,o){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Nt(14),Wm.set.call(this,e[0],t,o,e[0])};eL=(function(){function e(o){var r=this;this.O=vS,this.D=true,this.produce=function(n,i,a){if(typeof n=="function"&&typeof i!="function"){var l=i;i=n;var s=r;return function(h){var v=this;h===void 0&&(h=l);for(var T=arguments.length,y=Array(T>1?T-1:0),C=1;C<T;C++)y[C-1]=arguments[C];return s.produce(h,(function(b){var w;return (w=i).call.apply(w,[v,b].concat(y))}))}}var c;if(typeof i!="function"&&Nt(6),a!==void 0&&typeof a!="function"&&Nt(7),ji(n)){var u=fS(r),d=Hm(r,n,void 0),m=true;try{c=i(d),m=!1;}finally{m?Fu(u):Um(u);}return typeof Promise<"u"&&c instanceof Promise?c.then((function(h){return Nm(u,a),zm(h,u)}),(function(h){throw Fu(u),h})):(Nm(u,a),zm(c,u))}if(!n||typeof n!="object"){if((c=i(n))===void 0&&(c=n),c===TS&&(c=void 0),r.D&&Ym(c,true),a){var g=[],f=[];Gr("Patches").M(n,c,g,f),a(g,f);}return c}Nt(21,n);},this.produceWithPatches=function(n,i){if(typeof n=="function")return function(c){for(var u=arguments.length,d=Array(u>1?u-1:0),m=1;m<u;m++)d[m-1]=arguments[m];return r.produceWithPatches(c,(function(g){return n.apply(void 0,[g].concat(d))}))};var a,l,s=r.produce(n,i,(function(c,u){a=c,l=u;}));return typeof Promise<"u"&&s instanceof Promise?s.then((function(c){return [c,a,l]})):[s,a,l]},typeof o?.useProxies=="boolean"&&this.setUseProxies(o.useProxies),typeof o?.autoFreeze=="boolean"&&this.setAutoFreeze(o.autoFreeze);}var t=e.prototype;return t.createDraft=function(o){ji(o)||Nt(8),Ja(o)&&(o=KO(o));var r=fS(this),n=Hm(this,o,void 0);return n[jo].C=true,Um(r),n},t.finishDraft=function(o,r){var n=o&&o[jo];process.env.NODE_ENV!=="production"&&(n&&n.C||Nt(9),n.I&&Nt(10));var i=n.A;return Nm(i,r),zm(void 0,i)},t.setAutoFreeze=function(o){this.D=o;},t.setUseProxies=function(o){o&&!vS&&Nt(20),this.O=o;},t.applyPatches=function(o,r){var n;for(n=r.length-1;n>=0;n--){var i=r[n];if(i.path.length===0&&i.op==="replace"){o=i.value;break}}n>-1&&(r=r.slice(n+1));var a=Gr("Patches").$;return Ja(o)?a(o,r):this.produce(o,(function(l){return a(l,r)}))},e})(),Ko=new eL,tL=Ko.produce,Ko.produceWithPatches.bind(Ko),Ko.setAutoFreeze.bind(Ko),Ko.setUseProxies.bind(Ko),Ko.applyPatches.bind(Ko),Ko.createDraft.bind(Ko),Ko.finishDraft.bind(Ko),Uu=tL;});function Vl(e){return (t,o)=>{let r=e[t];if(!r)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return r(o)}}function Yi(e,t){return (o,r)=>{let i=r().records.requests[e][t],a=!i||i.status==="UNINITIALIZED"?"LOADING":"FETCHING";o(wr.setRequest({key:t,type:e,status:a}));}}function qi(e,t,o,r){return n=>{typeof window=="object"&&notifications.show({autoClose:3e3,color:"red",id:t,message:r,title:"Error"}),n(wr.setRequest({key:t,type:e,status:"FAILURE",error:{code:o,message:r}}));}}function ri(e){return t=>{let o=Zm(e,t);return (r,n,i)=>(r(Yi(e,o)),Hi(i,"create",e)(t).then(l=>(l.ok===true?r(wr.setCreateRequest({key:o,operation:"create",status:"SUCCESS",type:e,data:l.data})):r(qi(e,o,l.status,l.error)),l)))}}function nL(e){return t=>{let o=Zm(e,t[0]);return (r,n,i)=>(r(Yi(e,o)),Hi(i,"createBulk",e)(t).then(l=>(l.ok===true?r(wr.setCreateRequest({key:o,operation:"createBulk",status:"SUCCESS",type:e,data:l.data})):r(qi(e,o,l.status,l.error)),l)))}}function kS(e,t,o){return o.replace(new RegExp(e,"g"),t)}function iL(e){return e.section_id!==void 0}function aL(e){return e.report_id!==void 0}function ES(e){return t=>{let{create:o}=t;return (r,n,i)=>ri(e)(o)(r,n,i).then(async l=>{if(l.ok){let{data:s}=l,{id:c}=s,{update:u}=t,d=MS(e,{id:c});if(r(Yi(e,`${d}`)),e==="block"&&iL(o)){let m=Uu(u,v=>{v.id=c;}),{contentByLocale:g}=m;g&&(m=Uu(m,v=>{v.id=c,v.contentByLocale=Object.keys(g).reduce((T,y)=>{let C=g?g[y]:{};return T[y]={...C,id:c},T},{});}));let h=m.inputs?.map(v=>({type:v.type,id:v.id,inputAction:{operation:"create",input:{input_id:v.id,block_id:m.id}}}));return h&&h.length>0&&wS(e)([m,...h])(r,n,i).then(()=>ni("section")({id:m.section_id,include:true})(r,n,i).then(v=>(v.ok&&r(wr.setRequest({key:d,type:e,status:"SUCCESS",data:v.data})),v))),Hr(e)(m)(r,n,i).then(v=>(v.ok&&r(wr.setRequest({key:d,type:e,status:"SUCCESS",data:v.data})),v))}if(e==="section"&&aL(o)){let{id:m}=s,g=Uu(u,v=>{v.id=m;}),{blocks:f}=g,h=f?.map(v=>({type:v.type,blockcol:v.blockcol,blockrow:v.blockrow,section_id:m,locales:Object.keys(v.contentByLocale).map(T=>T)}));return h&&f&&await nL("block")(h)(r,n,i).then(v=>{if(v.ok){let T=v.data,y=[],C=T.map((b,w)=>{let I={...b},O=I.id,P=f[w];P.contentByLocale&&(I.contentByLocale=Object.keys(P.contentByLocale).reduce((j,B)=>{let U=P.contentByLocale[B];return j[B]={...U,content:{...U.content},id:I.id},j},{}));let{settings:_}=P,{contentByLocale:D,id:L}=I;I.settings=_;let R={id:L,contentByLocale:D,settings:_};return P.inputs.map(j=>j.id).reduce((j,B)=>{let U=f.findIndex($=>$.id===B);return [...j,U]},[]).map(j=>({...T[j],originalBlock:f[j]})).forEach(j=>{let{id:B,type:U,originalBlock:$}=j;if([E.SELECTOR,E.VIZ].includes(U)){if(R.contentByLocale?.logic?.content?.api){let Y=R.contentByLocale?.logic.content.api;R.contentByLocale.logic.content.api=kS(`(selector${$.id}id)`,`selector${B}id`,Y);}if(R.contentByLocale?.logic?.content?.logic){let Y=R.contentByLocale.logic.content.logic;R.contentByLocale.logic.content.logic=kS(`(selector${$.id}id)`,`selector${B}id`,Y);}}y.push({id:B,inputAction:{operation:"create",input:{input_id:B,block_id:O}}});}),R});return wS("block")([...C,...y])(r,n,i)}}),Hr(e)(g)(r,n,i).then(v=>(v.ok&&r(wr.setRequest({key:d,type:e,status:"SUCCESS",data:v.data})),v))}return Hr(e)({...u,id:s.id})(r,n,i)}})}}function ni(e){return t=>{let o=OS(e,t);return (r,n,i)=>{r(Yi(e,o));let a=Hi(i,"read",e);if(typeof a!="function"){let l=`Failed to get valid RPC method for entity "${e}"`;return r(qi(e,o,500,l)),Promise.reject(new Error(l))}return a(t).then(l=>(l.ok===true?r(wr.setReadRequest({key:o,operation:"read",status:"SUCCESS",type:e,data:l.data})):r(qi(e,o,l.status,l.error)),l))}}}function Hr(e){return t=>{let o=ef(e,t);return (r,n,i)=>(r(Yi(e,o)),Hi(i,"update",e)(t).then(l=>(l.ok===true?r(wr.setUpdateRequest({key:o,operation:"update",status:"SUCCESS",type:e,data:l.data})):r(qi(e,o,l.status,l.error)),l)))}}function wS(e){return t=>{let o=ef(e,t[0]);return (r,n,i)=>(r(Yi(e,o)),Hi(i,"updateBulk",e)(t).then(l=>(l.ok===true?r(wr.setUpdateRequest({key:o,operation:"updateBulk",status:"SUCCESS",type:e,data:l.data})):r(qi(e,o,l.status,l.error)),l)))}}function Ki(e){return t=>{let o=LS(e,t);return (r,n,i)=>(r(Yi(e,o)),Hi(i,"delete",e)(t).then(l=>{l.ok===true?r(wr.setDeleteRequest({key:o,operation:"delete",status:"SUCCESS",type:e,data:l.data})):r(qi(e,o,l.status,l.error));}))}}function Zm(e,t){if(e==="variant"){let o=t;return `create(variant, [${o.dimension_id}, ${o.name}])`}return `create(${e}, [${Object.keys(t)}])`}function OS(e,t={}){let o=t.id==null?null:`'${t.id}'`;return `read(${e}, ${o}, ${!!t.include})`}function ef(e,t){let{id:o,...r}=t;return `update(${e}, ${o}, [${Object.keys(r)}])`}function LS(e,t){return `delete(${e}, ${t})`}function MS(e,t){let o=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${o})`}var wr,Gu,RS,Fl,IS,AS,PS,tf=N(()=>{p();zu();_l();CS();he();wr=Sn.actions,Gu={create:Zm,read:OS,update:ef,delete:LS,clone:MS},RS=Vl({block:ri("block"),dimension:ri("dimension"),formatter:ri("formatter"),report:ri("report"),section:ri("section"),variant:ri("variant"),datasource:ri("datasource")}),Fl=Vl({block:ni("block"),dimension:ni("dimension"),formatter:ni("formatter"),report:ni("report"),section:ni("section"),variant:ni("variant"),datasource:ni("datasource")}),IS=Vl({block:Hr("block"),dimension:Hr("dimension"),formatter:Hr("formatter"),report:Hr("report"),section:Hr("section"),variant:Hr("variant"),datasource:Hr("datasource")}),AS=Vl({block:Ki("block"),dimension:Ki("dimension"),formatter:Ki("formatter"),report:Ki("report"),section:Ki("section"),variant:Ki("variant"),datasource:Ki("datasource")}),PS=Vl({block:ES("block"),section:ES("section")});});var Z={};bm(Z,{addBlockToState:()=>TL,addRunConsumersRunning:()=>nf,cloneEntity:()=>PS,createEntity:()=>RS,deleteEntity:()=>AS,deleteQueryParam:()=>sf,readEntity:()=>Fl,readEnvSecrets:()=>wL,readMember:()=>DS,readMetadata:()=>fL,readPrivateBlocks:()=>CL,readUser:()=>yL,recalculateVariables:()=>qt,removeBlocksFromState:()=>xL,removeDataSourceLogic:()=>RL,removeRunConsumersRunning:()=>af,reportSearch:()=>pL,resetSectionState:()=>rf,revalidateReport:()=>EL,revalidateUrl:()=>kL,searchMember:()=>mL,searchRegenerate:()=>dL,searchRole:()=>hL,searchUser:()=>bL,setCurrentLocale:()=>lL,setPreferredLocale:()=>cL,setPreviews:()=>sL,setQueryParam:()=>Xi,setSectionState:()=>of,setStatus:()=>BS,updateEntity:()=>IS,updateMyData:()=>SL,updateUser:()=>vL,urlProxy:()=>gL,variantValidateSlug:()=>uL});function uL(e,t){return async(o,r,n)=>{let i=await n.validateVariantSlug({dimension:e,slug:t});if("error"in i)throw new Error(i.error);return i.data}}function pL(e){return async(t,o,r)=>{let n=await r.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function dL(){return async(e,t,o)=>{let r=await o.regenerateSearch(void 0);if("error"in r)throw new Error(r.error);return r.data}}function DS(e){return async(t,o,r)=>{let n=await r.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function mL(e){return async(t,o,r)=>{let n=await r.searchMember(e);if(n.ok===true)return n.data;throw new Error(n.error)}}async function _S(e,t,o,r){let n=o().status,i={...n,...r},a={...n.query,...r.query};Object.keys(a).forEach(s=>a[s]===void 0&&delete a[s]);let l={...i,query:a};t(BS(l)),n.activeSection&&t(qt(e,{query:a}));}function sf(e,t){return async(o,r)=>_S(e,o,r,{query:{[t]:void 0}})}function Xi(e,t,o){return async(r,n)=>_S(e,r,n,{query:{[t]:o}})}function qt(e,t,o){return async(r,n)=>{let i=n(),{currentLocale:a}=i.status,l=i.records.entities.block,s=e.formatterFunctions[a],c=e.datasourceFunctions,{parsedParams:u,statusPayload:d}=kv(i.status,t),{sid:m,bid:g,previews:f,query:h}=u;Object.keys(d).length&&r(Io.setStatus(d));let v={...uS(f),locale:a,...Ro()},T={variables:v,query:h,locale:a};r(Io.addRunConsumersRunning([m]));let y=i.records.entities.section[m],C=async b=>r(DS(b));try{let b=await oi(l,y&&[y],g,s,T,void 0,C,"section",c,o),{variables:w,status:k}=b;r(Ui.setVariableChange({attributes:v,variables:w,status:k})),r(Io.removeRunConsumersRunning([m]));}catch(b){console.error("Error in runConsumers client side: recalculateVariables",b);}}}function fL(e){return async(t,o,r)=>{let n=await r.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function gL(e){return async(t,o,r)=>{let n=await r.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function hL(){return async(e,t,o)=>{let r=await o.searchRole("");if("error"in r)throw new Error(r.error);return r.data}}function bL(e){return async(t,o,r)=>{let n=await r.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function yL(e){return async(t,o,r)=>{let n=await r.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function vL({user:e}){return async(t,o,r)=>{let n=await r.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function SL(e){return async(t,o,r)=>{let n=await r.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function xL(e){let{removeBlocks:t}=Sn.actions;return async o=>{await o(t(e));}}function TL(e){let{addBlocks:t}=Sn.actions;return async o=>{await o(t(e));}}function CL(e){return async(t,o,r)=>{let n=await r.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function kL(e){return async(t,o,r)=>{let n=await r.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function EL(e){return async(t,o,r)=>{let n=await r.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function wL(){return async(e,t,o)=>{let r=await o.readEnvSecrets({});if("error"in r)throw new Error(r.error);return r.data}}function RL(){let{removeDataSourceLogic:e}=Sn.actions;return async t=>{await t(e());}}var BS,sL,of,rf,lL,cL,nf,af,Rr=N(()=>{p();vn();pS();ei();Xn();Ya();Xa();_l();tf();({setStatus:BS,setPreviews:sL,setSectionState:of,resetSectionState:rf,setCurrentLocale:lL,setPreferredLocale:cL,addRunConsumersRunning:nf,removeRunConsumersRunning:af}=Io);});function Yt(){let e=H(n=>n.status.activeEntity),t=ie();return {activeEntity:e,selectEntity:n=>t(Io.setActiveEntity(n)),unselectEntity:()=>t(Io.setActiveEntity({type:null,id:null}))}}function pt(e){let t=ie(),o=H(i=>i.status.sectionState)[e]||{},r=useCallback(i=>{t(of({[e]:i}));},[e]),n=useCallback(()=>{t(rf(e));},[e]);return {sectionVariables:o,setSectionVariables:r,resetSectionVariables:n}}function Wl(){let e=ie(),t=H(n=>n.status.isRunConsumersRunning),o=useCallback(n=>{e(nf(n));},[]),r=useCallback(n=>{e(af(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:o,removeRunConsumersRunning:r}}function Ft(e){let t=ie();return {opened:H(l=>l.status.sidebarStatus[e]),handlers:{open:()=>t(Io.openSidebar(e)),close:()=>t(Io.closeSidebar(e)),toggle:()=>t(Io.toggleSidebar(e))}}}function rs(){return H(t=>t.status.currentLocale)}function ns(){return H(t=>t.status.preferredLocale)}function oa(e){return t=>{let o=ie(),r=useMemo(()=>Gu.read(e,{include:true}),[]),n=useCallback(a=>{let l=Object.values(a.records.entities[e]),s=a.records.requests[e][r]||{status:l==null?"UNINITIALIZED":"SUCCESS"},c=t?l.filter(u=>t.includes(u.id)):l;return uf(c,s)},[r]),i=H(n);return useEffect(()=>{i.isUninitialized&&o(Fl(e,{id:t,include:true}));},[i.status]),i}}function jl(e,t){let o=useMemo(()=>Gu.clone(e,{id:t}),[t,e]);return H(n=>{let i=n.records.entities[e][t],a=n.records.requests[e][o]||{status:i==null?"UNINITIALIZED":"SUCCESS"};return uf(i,a)})}function ra(e){return t=>{let o=ie(),r=useMemo(()=>Gu.read(e,{id:t,include:true}),[t]),n=useCallback(a=>{let l=a.records.entities[e][t],s=a.records.requests[e][r]||{status:l==null?"UNINITIALIZED":"SUCCESS"};return uf(l,s)},[r]),i=H(n);return useEffect(()=>(i.isUninitialized&&t!==null&&o(Fl(e,{id:t,include:true})),()=>{}),[r,i.isUninitialized,o,t]),i}}function uf(e,t){let o={data:void 0,error:void 0,status:t.status,isUninitialized:t.status==="UNINITIALIZED",isLoading:t.status==="LOADING",isFetching:t.status==="LOADING"||t.status==="FETCHING",isSuccess:t.status==="SUCCESS",isError:t.status==="FAILURE"};return t.status==="UNINITIALIZED"?o:t.status==="LOADING"?{...o,data:e}:t.status==="FETCHING"?{...o,data:e}:t.status==="FAILURE"?{...o,error:t.error}:{...o,data:e}}var PL,ie,H,ts,$l,Ul,Qi,Gl,Zi,Hl,zt,qo,tt,ea,ta,lf,cf,ot,zS,Wu,Ao,xn,os,FS,ju,VS,$S,US,xe=N(()=>{p();Rr();tf();_l();Pt();Go();Ya();(({localeDefault:PL}=je())),ie=useDispatch,H=useSelector,ts=oa("report"),$l=oa("dimension"),Ul=oa("variant"),Qi=oa("section"),Gl=oa("block"),Zi=oa("formatter"),Hl=oa("datasource"),zt=ra("report"),qo=ra("section"),tt=ra("block"),ea=ra("dimension"),ta=ra("variant"),lf=ra("formatter"),cf=ra("datasource");ot=(e,t=void 0,o=void 0)=>{if(!e)return {};let r=tt(e).data,n=H(l=>t||l.variables.variables),i=H(l=>o||l.variables.attributes);return useMemo(()=>r?r.inputs.reduce((l,s)=>({...l,...n[s]}),i):{},[r,i,n])},zS=e=>{let t=tt(e).data,o=H(i=>i.variables.variables),r=H(i=>i.variables.attributes);return t?useMemo(()=>t?Object.keys(o).reduce((i,a)=>({...i,...t.inputs.includes(parseInt(a,10))?{[a]:o[a]}:{}}),{attributes:r}):{attributes:r},[t,o,r]):{}},Wu=e=>H(t=>t.variables.status[e]),Ao=(e=PL)=>useContext(De).formatterFunctions[e],xn=()=>useContext(De).datasourceFunctions,os=()=>useContext(De).profilePrefix,FS=()=>useContext(De).previewPrefix,ju=(e=void 0,t=void 0)=>{let o=H(i=>i.status.localeDefault),r=H(i=>i.status.query);return {variables:ot(e),locale:t||o,query:r}},VS=(e,t)=>Object.values(t).filter(r=>Object.keys(r.contentByLocale).some(n=>{let{logic:i}=r.contentByLocale[n].content;return i&&(`${i}`.includes(`formatters.${e}(`)||`${i}`.includes(`${e}{{`))})).length,$S=e=>{if(!e)return 0;let t=H(r=>r.records.entities.formatter),o=H(r=>r.records.entities.block);return useMemo(()=>VS(e,o),[e,t,o])},US=()=>{let e=H(o=>o.records.entities.formatter),t=H(o=>o.records.entities.block);return useMemo(()=>Object.values(e).reduce((o,r)=>(o[r.name]=VS(r.name,t),o),{}),[e,t])};});var GS,HS=N(()=>{p();Tm();_l();Ya();Xa();GS=()=>configureStore({reducer:{[Sn.name]:Sn.reducer,[Du.name]:Du.reducer,[_u.name]:_u.reducer},middleware(e){return e({thunk:{extraArgument:Ol("/api/cms/")}})}}),createWrapper(GS);});function Xt(e,t){let o=r=>{let{id:n,skelHeight:i,skelWidth:a,...l}=r,s=t(n);return s.isUninitialized||s.isFetching?jsx(Skeleton,{width:a,height:i}):s.isError?null:jsx(e,{...l,for:s.data})};return o.displayName=`withFetcher(${e.displayName||e.name||"Component"})`,o}var jS=N(()=>{p();});var ae=N(()=>{p();Rr();xe();HS();jS();});function qS(e){let {pathSegment:t,profilePrefix:o,previewPrefix:r,siteProps:n}=e,i=Zi();H(d=>d.status.isCMS);let l=Hl(),c={...Ro()},u=useMemo(()=>({profilePrefix:o,previewPrefix:r,pathSegment:t,siteProps:n,formatterFunctions:KS.reduce((d,m)=>({...d,[m]:i.data?Yn(i.data,m):{}}),{}),datasourceFunctions:(l?.data||[]).sort((d,m)=>d.content.order>m.content.order?1:-1).map(d=>({...d,content:{...d.content,pattern:et(d.content.pattern,{},{variables:c})}}))}),[i,t,o,r,n,l]);return jsx(De.Provider,{value:u,children:e.children})}function is(){let e=useContext(De);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var KS,zL,De,Pt=N(()=>{p();Go();Xn();ae();ei();Ur();(({locales:KS}=je())),zL={pathSegment:"path",formatterFunctions:KS.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",previewPrefix:null,siteProps:{}},De=createContext(zL);});function Jt(){let{pathSegment:e}=is(),t=useRouter();return useMemo(()=>{let o=t.pathname.split("/");Object.keys(t.query).length>0&&o.pop();let r=o.join("/"),[n,...i]=[].concat(t.query[e]||[]),a=(...l)=>[r,...l].join("/");return {router:t,page:n,params:i,query:t.query,basePath:r,href:a,setSearchParam(l,s){let c={...t.query};s==null||s===""?delete c[l]:c[l]=[].concat(s).join("!"),t.push({pathname:t.pathname,query:c},void 0,{shallow:true});},matches(...l){return t.asPath===a(...l)},push(l,s,c){let u=a(l);t.push(u,s,c);},replace(l,s,c){let u=a(l);t.replace(u,s,c);}}},[t.asPath])}var pf=N(()=>{p();Pt();});function df(){let e=ie(),{router:t}=Jt(),{asPath:o}=t,[,r]=o.split("?"),n=r?JSON.parse('{"'+decodeURI(r).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'):{},{currentLocale:i,locales:a}=H(s=>s.status),l=n.locale||"";return useEffect(()=>{l&&l!==""&&a.includes(l)&&l!==i&&e(Z.setCurrentLocale(l));},[]),i}var YS=N(()=>{p();ae();pf();});function as(e){return t=>Object.values(t.records.entities[e])}function ls(e){return Object.values(e.records.entities.datasource||[]).sort((t,o)=>t.content.order>o.content.order?1:-1).map(t=>{let o={...GL};return {...t,content:{...t.content,pattern:et(t.content.pattern,{},{variables:o})}}})}var XS,na,Ku,ss,GL,Wr=N(()=>{p();ei();Ur();XS=e=>e.records.entities.section,na=e=>e.records.entities.block;Ku=as("block"),ss=as("formatter"),GL=Ro();});function WL(e,t){let o=[],r={},n=new Set,i=1/0;for(let a of e){let l=parseInt(a.settings.order,10);l<i&&(i=l);}for(let a of e){let{id:l,settings:s}=a,c=parseInt(s.order,10),u=t[l]?t[l]:false,d=HL(u,l),m=a.section_id&&!n.has(a.section_id);a.section_id&&n.add(a.section_id);let g={id:l,order:c,label:t[l]?t[l][`title${l}title`]:`Title ${l}`,iconProps:d,properties:{sectionId:a.section_id,...a.section_id&&{titleType:m?"primary":"secondary"}},children:[]};if(r[l]=g,c===i)o.push(g);else {let f=c-1,h;for(let v=e.indexOf(a)-1;v>=0;v--){let T=e[v],y=parseInt(T.settings.order,10);if(y===f){h=r[T.id];break}else if(y<f){h=r[T.id];break}}h?h.children.push(g):o.push(g);}}return o}function ia(e=1,t=6,o=[]){let r=H(m=>m),n=H(m=>m.variables.variables),i=H(m=>m.variables.status),a=Qi(),l=Ku(r).filter(m=>m.type===E.TITLE&&o.includes(m.id)),s=Object.fromEntries(l.map(m=>[m.id,m])),c=Object.fromEntries(l.map(m=>[m.id,n[m.id]])),u=Object.fromEntries(l.map(m=>[m.id,i[m.id]])),d=useMemo(()=>{if(a.isSuccess&&s){let m=[];return a.data.sort(mo).forEach(g=>{let f=g.blocks.reduce((h,v)=>s[v]&&s[v].type===E.TITLE?h.concat([s[v]]):h,[]);m=m.concat(f.sort((h,v)=>mo(h,v,"blockrow")));}),Object.keys(i).length?m.filter(g=>{let f=parseInt(g.settings.order||"1",10);return f>=e&&f<=t&&u[g.id]?.allowed&&!u[g.id]?.hiddenByCascade}):[]}},[o,a,s,u]);return useMemo(()=>d&&d?.length>0?WL(d,c):[],[d,c])}var HL,mf=N(()=>{p();ae();Wr();Ho();he();HL=(e,t)=>({iconType:e[`title${t}_iconType`],icon:e[`title${t}_icon`],iconSize:e[`title${t}_iconSize`],iconVariant:e[`title${t}_iconVariant`],iconRadius:e[`title${t}_iconRadius`]});});function Ir(){let e=ie();return useMemo(()=>async t=>await e(Z.readMember(t)),[e])}var QS=N(()=>{p();ae();});function qL(e={required:false}){let{update:t,data:o,status:r}=useSession(e);return {update:t,user:o?.user,status:r,isLoading:r==="loading"}}var Pe,dt=N(()=>{p();Pe=qL;});function XL(){let{user:e,update:t,status:o}=Pe(),r=o==="loading",{localeDefault:n}=je(),i=ie();return useEffect(function(){!r&&e&&e.bespoke_user_metadata&&typeof e.bespoke_user_metadata.preferredLocale=="string"&&i(Z.setPreferredLocale(e.bespoke_user_metadata.preferredLocale||n));},[r,e]),{user:e,isLoading:r,update:t,status:o}}var cs,ZS=N(()=>{p();ae();Go();dt();cs=XL;});function ff(){return H(JL)}var JL,ex=N(()=>{p();ae();JL=e=>e.status.locales.map(t=>({value:t,label:t.toUpperCase()}));});var gf,ii,ox=N(()=>{p();dt();gf=(e,t,o,r=null)=>{let[n,i]=useState(false),[a,l]=useState(null);return {print:c=>{i(true),l(null);let u=process.env.NEXT_PUBLIC_REPORTS_BASE_URL,d=new URLSearchParams(window.location.search),m=c?"&transparent=true":"",g=r?`/embeds/${t}/${o}?section=${e}&block=${r}${d.toString()?"&"+d.toString():""}`:`/embeds/${t}/${o}?section=${e}${d.toString()?"&"+d.toString():""}`,f=`${u}${g}&print=true`;Mu.get(`${process.env.NEXT_PUBLIC_PDF_API_URL}/screenshot?url=${encodeURIComponent(f)}${m}`,{responseType:"blob"}).then(h=>{let v=r?`section${e}_block${r}.png`:`section${e}.png`;saveAs(h.data,v);}).catch(h=>{l(h.response?.data?.message||"Failed to download image. Please try again.");}).finally(()=>{i(false);});},downloadLoading:n,error:a}},ii=()=>!!process.env.NEXT_PUBLIC_PDF_API_URL;});var st=N(()=>{p();pf();YS();mf();QS();ZS();ex();ox();});function ps(e){let{user:t}=cs();return useMemo(()=>{if(t&&t.bespoke_app_metadata&&t.bespoke_app_metadata.reports&&Array.isArray(t.bespoke_app_metadata.reports)){let r=t.bespoke_app_metadata.reports.find(n=>n.reportId===e);if(r&&r.favorites)return r.favorites}},[t,e])}var rx=N(()=>{p();st();});function hf(e,t){let o=H(s=>t?s.records.entities[e][t]:null),r=o?.settings,[n,i]=useSetState(o?.settings||{}),a=ie(),l=useCallback((s,c)=>{o&&(i(u=>({...u,[s]:c})),a(Z.updateEntity(e,{id:o.id,settings:{...o.settings,[s]:c}})));},[a,o]);return useEffect(()=>{r&&i(r);},[r,i]),{settings:n,updateSettings:l}}var Ar,Kl,nx=N(()=>{p();ae();Ar=e=>hf("section",e),Kl=e=>hf("report",e);});var ix=N(()=>{p();Ya();ae();});var Tn=N(()=>{p();rx();nx();ix();});function Qt(e){let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),i=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(i)?i.replace(n,a=>t[a]):i}var ds=N(()=>{p();});function Pf(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var Cx=N(()=>{p();});function SB(e){return e?vB(Pf(Qt(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var Tt,jr=N(()=>{p();ds();Cx();Tt=SB;});var Ox=N(()=>{});function Df({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:i=0}){let a=useMantineTheme();if(i===Bf)return null;let l=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),s=Mf(r),c=r,u=JSON.stringify(c),d=100,m=1e3,g=!!(u&&u.length>d),f=10,h={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(s==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:h,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:i+1<Bf?Object.keys(r).sort((v,T)=>{let y=Mf(r[v]),C=Mf(r[T]);return y!==C?Lx.indexOf(y)-Lx.indexOf(C):v.localeCompare(T)}).map(v=>jsx(Df,{root:false,label:v,value:r[v],level:i+1},v)):l})]})});if(s==="array"){let v=r.length>f,T=v?r.slice(0,f):r,y=v?r.length-f:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:h,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,p:0,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[i+1<Bf?T.map((C,b)=>jsx(Df,{root:false,label:b,value:C,level:i+1,parentIsArray:true},b)):l,v&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",y," other elements]"]})]})]})})}return s==="string"?c=g?`"${c.substring(0,d)} ... "`:`"${c}"`:s==="error"?c=`Error: ${c.message}`:s==="undefined"?c=s:c.toString&&(c=c.toString()),jsxs(Group,{noWrap:true,spacing:0,children:[jsx(Text,{color:e?"dimmed":a.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap"},weight:700,children:o?`{{${t}}}`:n?`[${t}]`:t}),jsx(Prism,{className:"cr-variable",language:"jsx",noCopy:true,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:c}),g&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,children:[jsx(HoverCard.Target,{children:jsx(ActionIcon,{children:jsx(IconCodePlus,{})})}),jsx(HoverCard.Dropdown,{w:500,children:jsx(Text,{size:"sm",maw:"100%",style:{wordBreak:"break-all",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:u.substring(0,m)})})]})]})}var Mf,Lx,Bf,sa,op=N(()=>{p();Ox();Mf=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},Lx=["object","array","string","number"],Bf=5;sa=Df;});var rp,_f=N(()=>{p();rp=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function YB({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let i=tt(t==="attributes"?null:t).data,a=i?i.type:"block",l=i?.type&&i?.id?`${i.type}${i.id}`:"",s=Object.keys(o).filter(r?()=>true:c=>!rp(l)(c));return jsx(Stack,{spacing:0,children:s.length?s.map(c=>jsx(sa,{dimmed:e.includes(c),label:c,value:o[c]},c)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${a}`})})})}var Or,Ss=N(()=>{p();op();ae();_f();Or=YB;});var kn,sT,lT,dT,cT,uT,pT,Oo,ro,Is,no=N(()=>{p();he();kn={display:{label:"Size",defaultValue:"block",options:[{label:"Full Width",value:"block"},{label:"Inline",value:"inline"}]}},sT={useProxy:{label:"Use proxy (avoid CORS)",defaultValue:"false",options:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}},lT={[E.IMAGE]:{...kn},[E.PARAGRAPH]:{...kn},[E.SUBTITLE]:{...kn},[E.SELECTOR]:{...kn},[E.STAT]:{...kn},[E.VIZ]:{...kn},[E.TITLE]:{order:{label:"Importance",defaultValue:"1",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},search:{label:"Search on Click",defaultValue:"off",options:[{label:"Off",value:"off"},{label:"Inline",value:"inline"},{label:"Modal",value:"modal"}]},addComparisonName:{label:"Show member name on comparison mode",defaultValue:"no",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]},...kn},[E.GENERATOR]:{...sT},[E.SECTION_FLAG]:{...sT},[E.NAV]:{variant:{label:"Nav variant",defaultValue:"inline",options:[{label:"Inline",value:"inline"},{label:"Fixed",value:"fixed"},{label:"Jump",value:"jump"}]},min:{label:"Min Title level",defaultValue:"1",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},max:{label:"Max Title level",defaultValue:"6",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},icons:{label:"Show icons",defaultValue:"yes",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]},titlePosition:{label:"Title position",defaultValue:"left",options:[{label:"Left",value:"left"},{label:"Top",value:"top"},{label:"Right",value:"right"},{label:"Bottom",value:"bottom"}]}},[E.MULTIHIERARCHY_SELECTOR]:{...kn}},dT=e=>e&&lT[e]?lT[e]:kn,cT={left:"flex-start",right:"flex-end",justify:"stretch"},uT={justify:"apart"},pT={justify:"space-between"},Oo=e=>cT[e]?cT[e]:e,ro=e=>uT[e]?uT[e]:e,Is=e=>pT[e]?pT[e]:e;});var m_,mT,fT=N(()=>{p();m_=({value:e,handleChange:t,position:o="right"})=>jsxs(Group,{position:o,children:[jsx(Text,{size:"xs",children:"Aligment"}),jsx(SegmentedControl,{size:"xs",defaultValue:e,onChange:r=>t("align",r),data:[{label:jsx(IconAlignLeft,{size:"0.7rem"}),value:"left"},{label:jsx(IconAlignCenter,{size:"0.7rem"}),value:"center"},{label:jsx(IconAlignRight,{size:"0.7rem"}),value:"right"},{label:jsx(IconAlignJustified,{size:"0.7rem"}),value:"justify"}]})]}),mT=m_;});function R_({id:e,display:t="button",handleChange:o}){let r=ie(),n=tt(e).data,[i,a]=useState(false),l=w_(n),s=f=>{typeof f=="boolean"?c("width",{...l,...f?{stretch:true}:hT}):c("width",{...l,value:f});},c=(f,h)=>{n&&(o?o(f,h):r(Z.updateEntity("block",{id:e,settings:{...n.settings,[f]:h}})));};if(!n)return null;let u=dT(n.type),d=gT[l.unit],m=f=>{let{defaultValue:h}=gT[f];c("width",{...l,value:h,unit:f});},g=jsxs(Stack,{spacing:"xs",children:[jsx(mT,{value:n.settings.align||"left",handleChange:c,position:"apart"}),Object.entries(u).map(([f,{label:h,defaultValue:v,options:T}])=>jsxs(Group,{spacing:"xs",position:"apart",noWrap:true,style:{width:"100%"},children:[h&&jsx(Text,{size:"xs",children:h}),jsx(SegmentedControl,{defaultValue:String(n.settings[f]||v),onChange:y=>c(f,y),data:T,size:"xs"})]},f)),![E.GENERATOR,E.SECTION_FLAG].includes(n.type)&&jsxs(Group,{spacing:"xs",children:[jsx(Text,{size:"xs",children:"Width"}),jsxs(Group,{spacing:"xs",children:[!l.stretch&&jsxs("div",{children:[jsx(E_,{currUnit:l.unit,changeUnit:m}),jsx(NumberInput,{defaultValue:parseInt(d.defaultValue,10),disabled:l.stretch,onChange:f=>s(f),size:"xs",value:Number.isNaN(l.value)?void 0:parseInt(l.value,10),...d})]}),jsx(Checkbox,{size:"xs",label:"Stretch",checked:l.stretch,onChange:f=>s(f.currentTarget.checked)})]})]},"width")]});return t==="button"?jsxs(Popover,{opened:i,onClose:()=>a(false),position:"bottom-end",withinPortal:true,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{onClick:()=>a(f=>!f),children:jsx(IconPalette,{size:20})})}),jsx(Popover.Dropdown,{children:g})]}):jsx(Paper,{p:"md",children:g})}var k_,nc,gT,hT,E_,w_,up,ic=N(()=>{p();no();ae();fT();he();k_=["px","%"],nc={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,")},gT={px:{defaultValue:400,min:25,step:5,formatter:nc.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:nc["%"]}},hT={stretch:false,unit:"px",value:"400"},E_=({currUnit:e,changeUnit:t})=>jsxs(Group,{position:"apart",children:[jsx(Text,{size:"xs",fw:"bold",children:"Unit"}),jsx(Group,{spacing:3,children:k_.map(o=>jsx(Anchor,{component:"button",size:"xs",td:e===o?"underline":"none",onClick:()=>t(o),children:o},o))})]}),w_=e=>{let t=e?.settings?.width||{};return t&&["stretch","value","unit"].every(o=>Object.prototype.hasOwnProperty.call(t,o))?t:hT};up=R_;});var W_,CT,kT=N(()=>{p();W_=(e,t)=>{let o=e.allLabel||"All",r=e.colorKey||"",n=e.data||[],i=e.hideLabel||"false",a=e.resetSectionVars||"false",l=e.iconKey||"",s=e.label||"Unlabeled Multihierarchy Selector",c=e.levels||[],u=e.limit||void 0,d=e.placeholder||"",m=e.searchIndexKey||"",g=e.searchIndexSeparator||"",f,h;return e.defaultValue&&e.defaultValueType&&(f=e.defaultValue,h=e.defaultValueType),(!f||!h)&&(f=[],h=""),{allLabel:o,colorKey:r,data:n,defaultValue:f,defaultValueType:h,hideLabel:i,resetSectionVars:a,iconKey:l,id:t,label:s,levels:c,limit:u,placeholder:d,searchIndexKey:m,searchIndexSeparator:g}},CT=W_;});var j_,ET,K_,wT,RT=N(()=>{p();he();Ru();j_=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{id:t,label:t}:t):[],ET=(e,t)=>t===xt.MULTI&&!Array.isArray(e)?[e]:e,K_=(e,t)=>{let o=e.type||xt.SINGLE,r=e.component||"Selector",n=e.hideLabel||"false",i=e.resetSectionVars||"false",a=e.name||"Unlabeled Selector",l=j_(e.options||[]),s;if(e.defaultValue){let c=ET(e.defaultValue,o);$i(o,c,l)&&(s=c);}if(!s){let c=l&&l[0]&&l[0].id||l[0]||"";s=ET(c,o);}return {id:t,name:a,type:o,options:l,component:r,defaultValue:s,hideLabel:n,resetSectionVars:i}},wT=K_;});var q_,lr,Yf=N(()=>{p();he();kT();RT();q_={[E.SELECTOR]:wT,[E.MULTIHIERARCHY_SELECTOR]:CT},lr=q_;});var Y_,X_,J_,Q_,He,Kr=N(()=>{p();Y_=e=>typeof e=="string"?e.replace(/&nbsp;<\/p>/g,"</p>"):e,X_=e=>typeof e=="string"&&e==="<p><br></p>"?"":e,J_=e=>typeof e=="string"?e.replace(/^<p>(.*)<\/p>$/,"$1"):e,Q_=e=>e&&J_(X_(Y_(e))),He=Q_;});function ye({id:e="",component:t="p",order:o=1,size:r="md",html:n,style:i={},append:a=jsx(Fragment,{}),isPreview:l=false,lineClamp:s="none"}){let c=tN(n),u=oN(n,l),d=i&&i.align?String(i.align):"left",m=Text,g={};return t==="h"?(m=Title,g={id:e,order:o}):g={component:t,size:r,lineClamp:s},jsxs(m,{align:d||c.align||"left",...g,children:[u,a]})}var tN,oN,ft=N(()=>{p();tN=(e="<></>")=>{let t=null,o={replace:r=>(r instanceof Element$1&&!t&&(t=r.attribs,t.align=r.attribs.style?r.attribs.style.replace("text-align: ",""):"",delete t.children),r)};return e?(AT(e,o),t):{}},oN=(e="",t=false)=>{let o={replace:r=>{let{type:n}=r;if(r instanceof Element$1&&n==="tag"){let{name:i,attribs:a,children:l,parent:s}=r;if(i==="p"&&!s)return jsx(Fragment,{children:domToReact(l,o)});if(i==="a"){let{href:c,target:u}=a,d=c.indexOf("http")===0,m=!!(u&&u==="_blank"),g=jsx(Anchor,{...a,href:a.href,target:"_blank",children:domToReact(l,o)});return d||m||t?g:jsx(Anchor,{...a,href:a.href,children:domToReact(l,o)})}else {if(i==="strong")return jsx(Text,{component:"strong",children:domToReact(l,o)});if(i==="em")return jsx(Text,{component:"em",fs:"italic",children:domToReact(l,o)});if(i==="u")return jsx(Text,{component:"u",td:"underline",children:domToReact(l,o)});if(i==="sup")return jsx(Text,{component:"sup",style:{verticalAlign:"super",fontSize:"0.75em"},children:domToReact(l,o)});if(i==="sub")return jsx(Text,{component:"sub",style:{verticalAlign:"sub",fontSize:"0.75em"},children:domToReact(l,o)});if(i==="span")return jsx(Text,{component:"span",children:domToReact(l,o)});if(i==="br")return jsx("br",{})}return jsx(Fragment,{children:domToReact(l,o)})}else if(r instanceof Text$1&&r.type==="text")return jsx(Fragment,{children:r.data})}};return AT(e,o)};});function Jf({paragraph:e,tooltip:t,settings:o}){let r=He(t);return jsx(ye,{component:"p",html:e,style:o,append:t?jsx(Ut,{content:r,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{})})}var OT=N(()=>{p();Kr();En();ft();});function Ke({iconType:e="none",iconVariant:t="transparent",icon:o="",iconRadius:r="md",iconSize:n="md",iconPadding:i="1",blockType:a}){let[l,s]=useState(void 0),c=e==="custom"?o:`/api/cms/read/icons/${e}/icon.svg?name=${o}`,u=/^.*\.svg*$/.test(c)||e==="tabler";return useEffect(()=>{u&&Mu.get(c,{responseType:"text"}).then(m=>m.data).then(s).catch(()=>{});},[e,u,c]),jsx(Fragment,{children:e!=="none"&&o&&o!==""&&!!(l||!u)&&jsx(ThemeIcon,{className:`bespoke-${a}-icon-wrapper`,variant:t,radius:r,size:n,p:parseInt(i),dangerouslySetInnerHTML:l&&u?{__html:l}:void 0,children:u?null:jsx(Image,{src:c,alt:"Title Icon"})})})}var wn=N(()=>{p();});function Zf({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:c,_iconPadding:u}){if(!t&&!o&&!e)return null;let d=n&&n.align?n.align:"left";return jsxs(Group,{spacing:"md",position:ro(d),children:[jsx(Ke,{blockType:"stat",iconType:i,iconVariant:a,iconRadius:s,iconSize:c,icon:l,iconPadding:u}),jsxs(Stack,{spacing:0,children:[t&&jsx(ye,{component:"div",size:"md",html:t,style:n}),o&&jsx(ye,{component:"div",size:"xl",html:o,style:n}),e&&jsx(ye,{component:"div",size:"sm",html:e,style:n})]},"stat"),r&&jsx(Ut,{content:r})]})}var MT=N(()=>{p();En();wn();ft();no();});function eg({subtitle:e,tooltip:t,settings:o}){let r=e||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{spacing:"sm",position:ro(n),children:[jsx(ye,{size:"sm",html:r}),t&&jsx(Ut,{content:t,style:{display:"inline-flex"}})]})}var DT=N(()=>{p();En();ft();no();});var _T=N(()=>{p();ae();Wr();Wr();Xn();Bl();vn();dt();ae();Xa();st();xe();he();});function Lr(){return useContext(bN)}var bN,li=N(()=>{p();io();bN=createContext({active:false,variables:null,status:null,setComparisonVariables:null,comparisonLoaded:false,loading:false,error:false});});function fp(e,t,o,r=false,n=false){let i=useRouter(),{query:a,locale:l}=i,s=H(L=>L),c=useDispatch(),u=Lr(),d=H(L=>r&&u.variables?u?.variables?.attributes:L.variables.attributes),m=na(s),g=ss(s),f=ls(s),h=Yn(g,l),v=ot(e,r&&u.active?u?.variables.variables:void 0,r&&u.active?u?.variables.attributes:void 0),T=H(L=>r?u.variables.variables:L.variables.variables),y=H(L=>r?u.variables.status:L.variables.status),C=Ir(),{sectionVariables:b,resetSectionVariables:w}=pt(t),{addRunConsumersRunning:k,removeRunConsumersRunning:I}=Wl(),O=Pe(),P=r&&u.active?`${o}Compare`:o,_=r&&u.active?Object.fromEntries(Object.entries(a).filter(([L])=>L.match(TN)).map(([L,R])=>[L.replace("Compare",""),R])):Object.fromEntries(Object.entries(a).filter(([L])=>L.match(CN)).map(([L,R])=>[L.replace("Compare",""),R]));return useCallback(L=>{let R={locale:l,query:{..._,[o]:L},variables:v},z=new URLSearchParams(window.location.search);z.set(P,L),window.history.replaceState(null,null,`?${z.toString()}`),k([t]),oi(m,void 0,e,h,R,{variables:T,status:y},C,"report",f,O).then(A=>{u.active&&r?u.setComparisonVariables({attributes:d,variables:A.variables,status:A.status}):c(Ui.setVariableChange({attributes:d,variables:A.variables,status:A.status})),n&&b&&w(),I([t]);});},[e,t,o,P,a,m,c,h,i,v.attributes,r,n,y,T])}var TN,CN,NT=N(()=>{p();vn();ae();Xn();Wr();Xa();xe();st();li();dt();TN=/\w*Compare\b/,CN=/selector\d+id/;});var zT=N(()=>{p();});var EN,wN,FT,VT,gp,RN,da,cc=N(()=>{p();Ha();ei();EN=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",wN="Error Rendering Visualization",FT={data:[],dataFormat:e=>e,type:"Treemap",noDataHTML:`<p style="font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
35
- <strong>${wN}</strong>
36
- </p>`},VT=(e,t,o)=>{let r=t.find(n=>{let i=n.content?.pattern;if(!i)return false;try{return new RegExp(i,"gm").test(e)}catch{return false}});if(r){if(r.content?.useProxy)return `${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(e)}&wrapper=false`;try{let i={envs:{...Ro()},...o?{session:o}:{}},l=Ga({vars:["url","libs","session"],logic:r.content.logic},i)(e);if(l instanceof Promise)console.warn(`[DataSource] Logic for "${r.name}" is async, which is not supported in this context. Use useProxy=true for async logic.`);else if(l?.axiosConfig?.url!=null){let{url:s,headers:c}=l.axiosConfig;return c&&Object.keys(c).length>0?{url:s,headers:c}:s}}catch(n){console.error(`[DataSource] Failed to apply logic for URL "${e}":`,n.message);}}return e},gp=(e,t,o)=>typeof e=="string"?VT(e,t,o):Array.isArray(e)?e.map(r=>typeof r=="string"?VT(r,t,o):r):e,RN=(e,t,o={},r=EN,n=null,i={},a={},l=[],s)=>{let c;try{c=Ua({vars:["variables"],logic:e},t,r,i,a)(o),c.data=gp(c.data,l,s),c._downloadUrl&&(c.__downloadUrl=gp(c.__downloadUrl,l,s));}catch(f){return console.error(`Parsing Error in propify (ID: ${n})`),console.error(`Error message: ${f.message}`),{error:`${f}`,config:FT}}if(typeof c!="object")return {error:"Visualization JS code must return an object",config:FT};let u=c.dataFormat?c.dataFormat:f=>{let v=Array.isArray(c.data)&&c.data.length>1&&c.data.some(T=>typeof T=="string")?f:[f];return dataConcat(v,"data")};delete c.dataFormat;let d=c.linksFormat||void 0;delete c.linksFormat;let m=c.nodesFormat||void 0;delete c.nodesFormat;let g=c.topojsonFormat||void 0;return delete c.topojsonFormat,{config:c,dataFormat:u,linksFormat:d,nodesFormat:m,topojsonFormat:g}},da=RN;});var $T=N(()=>{p();Ce();le({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 UT=N(()=>{p();Ce();le({name:"abs",description:"Simple Absolute Value.",logicFactory(){return e=>Math.abs(e)},inputType:"number",testValue:"-123",type:"formatter"});});var PN,GT=N(()=>{p();Ce();PN=()=>function(t){let r=new RegExp(/([\$0-9\,]+)[A-z\-\s\&]*([\$0-9\,]*)/g).exec(t);return r?(r=r.slice(1).filter(n=>n.length).map(n=>(n.includes(",")&&(n.indexOf(",")===n.length-4?n=n.replace(/,000$/g,"k").replace(/([0-9]+)(,999$)/g,i=>`${parseInt(i)+1}k`):n.indexOf(",")===n.length-8&&(n=n.replace(/,000,000$/g,"M").replace(/([0-9]+)(,999,999$)/g,i=>`${parseInt(i)+1}M`))),n)),r.length===2?r.join(" - "):t.toLowerCase().match(/under|less|</g)?`< ${r[0]}`:t.toLowerCase().match(/over|more|\+|>/g)?`${r[0]}+`:`${r[0]}`):"None"},le({name:"bucket",description:"Sanitizes bucket strings to '< n', 'n1 - n2', and 'n+'",logicFactory:PN,inputType:"number",testValue:"1234",type:"formatter"});});var HT=N(()=>{p();Ce();le({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 WT=N(()=>{p();Ce();le({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 jT=N(()=>{p();Ce();le({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 KT=N(()=>{p();Ce();le({name:"formatFieldName",description:"Based on field name returns a string",logicFactory(){return e=>{if(e.contentType.toLowerCase()==="stat"){if(e.field==="title")return "Stat label";if(e.field==="value")return "Stat value";if(e.field==="subtitle")return "Stat subtitle";if(e.field==="tooltip")return "Tooltip text"}return e.contentType.toLowerCase()==="section"&&e.field==="short"?"Short title":e.contentType.toLowerCase()==="description"&&e.field==="description"?"Paragraph":e.field}},inputType:"object",testValue:'{"field":"title","contentType":"stat"}',type:"formatter"});});var qT=N(()=>{p();Ce();le({name:"grewTo",description:"Returns the text with grow direction: 'declined from', 'grew to' o 'stayed at'",logicFactory(){return e=>e<0?"declined from":e>0?"grew to":"stayed at"},inputType:"number",testValue:"-1234",type:"formatter"});});var YT=N(()=>{p();Ce();le({name:"grewWord",description:"Returns either 'grew', 'declined', or 'stayed' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declined":e>0?"grew":"stayed"},inputType:"number",testValue:"-1234",type:"formatter"});});var XT=N(()=>{p();Ce();le({name:"growing",description:"Returns either 'declining', 'growing' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declining":"growing"},inputType:"number",testValue:"-1234",type:"formatter"});});var FN,JT=N(()=>{p();Ce();FN=()=>function(t){let{curr:o,currMoe:r=0,prev:n,prevMoe:i=0}=t,a;if(r||i){let l=(-n/o**2)**2*r**2,s=(1/o)**2*i**2;a=Math.sqrt(l+s);}else a=(o-n)/n;return a*100},le({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:FN,inputType:"object",testValue:'{"curr":10,"currMoe":0,"prev":13,"prevMoe":0}',type:"formatter"});});var QT=N(()=>{p();Ce();le({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 ZT=N(()=>{p();Ce();le({name:"growthWord",description:"Returns either 'growth' or 'decline' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decline":"growth"},inputType:"number",testValue:"-1234",type:"formatter"});});var eC=N(()=>{p();Ce();le({name:"highWord",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign.",logicFactory(){return e=>e<0?"lower than":e>0?"higher than":"approximately the same as"},inputType:"number",testValue:"0",type:"formatter"});});var tC=N(()=>{p();Ce();le({name:"increaseWord",description:"Returns either 'increase', 'decrease', or 'change' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decrease":e>0?"increase":"change"},inputType:"number",testValue:"1234",type:"formatter"});});var oC=N(()=>{p();Ce();le({name:"increasedWord",description:"Returns either 'increased', 'decreased', or 'remained the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreased":e>0?"increased":"remained the same"},inputType:"number",testValue:"0",type:"formatter"});});var rC=N(()=>{p();Ce();le({name:"increasing",description:"Returns either 'decreasing', 'increasing' or 'maintaining' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreasing":e>0?"increasing":"maintaining"},inputType:"number",testValue:"-1234",type:"formatter"});});var nC=N(()=>{p();Ce();le({name:"largerThan",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign",logicFactory(){return e=>e<0?"smaller than":e>0?"larger than":"the same as"},inputType:"number",testValue:"-1234",type:"formatter"});});var iC=N(()=>{p();Ce();le({name:"list",description:"Joins an array of strings together, adding commas and 'and' when necessary.",logicFactory(){return e=>e.reduce((t,o,r)=>(r?r===e.length-1&&r===1?t+=` and ${o}`:r===e.length-1?t+=`, and ${o}`:t+=`, ${o}`:t+=o,t),"")},inputType:"object",testValue:'["foo","bar","bee"]',type:"formatter"});});var aC=N(()=>{p();Ce();le({name:"longWord",description:"",logicFactory(){return e=>e<0?"shorter":e>0?"longer":"similar"},inputType:"number",testValue:"5",type:"formatter"});});var sC=N(()=>{p();Ce();le({name:"lowerCaseFirst",description:"Converts the first letter of a string to lowercase",logicFactory(){return e=>typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e},inputType:"string",testValue:"foo",type:"formatter"});});var lC=N(()=>{p();Ce();le({name:"moreFewerWord",description:"",logicFactory(){return e=>e<0?"fewer":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var cC=N(()=>{p();Ce();le({name:"moreLess",description:"Returns either 'more' or 'less' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var uC=N(()=>{p();Ce();le({name:"moreLess",description:"Returns either 'more than', 'less than', or 'approximately the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less than":e>0?"more than":"approximately the same"},inputType:"number",testValue:"-5",type:"formatter"});});var pC=N(()=>{p();Ce();le({name:"olderWord",description:"",logicFactory(){return e=>e<0?"getting younger":e>0?"getting older":"staying the same age"},inputType:"number",testValue:"-5",type:"formatter"});});var dC=N(()=>{p();Ce();le({name:"olderYounger",description:"",logicFactory(){return e=>e<0?"younger than":e>0?"older than":"the same age as"},inputType:"number",testValue:"-5",type:"formatter"});});var mC=N(()=>{p();Ce();le({name:"plural",description:"Pluralizes a word.",logicFactory(){return e=>e.replace(/\w$/g,t=>t==="y"?"ies":`${t}s`)},inputType:"string",testValue:"Foo",type:"formatter"});});var fC=N(()=>{p();Ce();le({name:"pxToInt",description:"Takes a pixel value and converts it to an integer",logicFactory(){return e=>parseInt(e.replace(/\D+/g,""),10)},inputType:"string",testValue:"12px",type:"formatter"});});var gC=N(()=>{p();Ce();le({name:"salary",description:"Displays salary values with proper precision (ie. '$74,200' instead of '$74.2k')",logicFactory(e){return t=>{let o;return t<1e6?o=e.d3.format(",")(t.toFixed(0)):o=e.d3plus.formatAbbreviate(t),`$${o}`}},inputType:"number",testValue:"1000000",type:"formatter"});});var hC=N(()=>{p();Ce();le({name:"stripEntities",description:"Removes non breaking spaces & other html entities from a string",logicFactory(){return e=>typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e},inputType:"string",testValue:"<b>MyText</b>",type:"formatter"});});var yC=N(()=>{p();Ce();le({name:"stripHTML",description:"Converts html tags to spaces, then removes redundant spaces",logicFactory(){return e=>{let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),i=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(i)?i.replace(n,a=>t[a]):i}},inputType:"string",testValue:"<b>My text</b>",type:"formatter"});});var vC=N(()=>{p();Ce();le({name:"stripOL",description:"Removes ordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ol>/g,"").replace(/<\/ol>/g,"")},inputType:"string",testValue:"<ol><li>My list</li></ol>",type:"formatter"});});var SC=N(()=>{p();Ce();le({name:"stripP",description:"Removes all paragraph tags from a string.",logicFactory(){return e=>e.replace(/<p>/g,"").replace(/<\/p>/g,"")},inputType:"string",testValue:"<p>My p</p>",type:"formatter"});});var xC=N(()=>{p();Ce();le({name:"stripUL",description:"Removes unordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ul>/g,"").replace(/<\/ul>/g,"")},inputType:"string",testValue:"<ul><li>My list</li></ul>",type:"formatter"});});var TC=N(()=>{p();Ce();le({name:"toKebabCase",description:"Takes a camelCase or PascalCase string and converts it to kebab-case.",logicFactory(){return e=>typeof e=="string"?(e=e.charAt(0).toLowerCase()+e.substring(1),e.replace(/([A-Z])/g,"-$1").toLowerCase()):"invalid string passed to toKebabCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var CC=N(()=>{p();Ce();le({name:"toSpacedCase",description:"Takes a camelCase or PascalCase string and adds spaces (I know Spaced Case isn't a thing, deal with it).",logicFactory(){return e=>typeof e=="string"?e.replace(/([A-Z])/g," $1").toLowerCase().trim():"invalid string passed to toSpacedCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var kC=N(()=>{p();Ce();le({name:"upperCaseFirst",description:"Converts the first letter of a string to uppercase",logicFactory(){return e=>e.charAt(0).toUpperCase()+e.slice(1)},inputType:"string",testValue:"my name",type:"formatter"});});var EC=N(()=>{p();$T();UT();GT();HT();WT();jT();KT();qT();YT();XT();JT();QT();ZT();eC();tC();oC();rC();nC();iC();aC();sC();lC();cC();uC();pC();dC();mC();fC();gC();hC();yC();vC();SC();xC();TC();CC();kC();});function bo(e){let t=useContext(f1);return e?t[e]??t:t}var f1,Yr=N(()=>{p();f1=createContext({});});function wC({direction:e,onClick:t,visible:o}){return o?jsx(ActionIcon,{className:`bespoke-sortable-table-arrow bespoke-sortable-table-arrow-${e}`,variant:"filled",size:"md",sx:{position:"absolute",top:"50%",[e==="left"?"left":"right"]:"16px",zIndex:10,opacity:.55,"&:hover":{opacity:1}},onClick:t,children:e==="left"?jsx(IconArrowLeft,{size:16}):jsx(IconArrowRight,{size:16})}):null}function hp({data:e}){let t=useRef(null),[o,r]=useState(false),[n,i]=useState(false),[a,l]=useState(false),s=useMemo(()=>(e&&Array.isArray(e)&&e[0]?Object.keys(e[0]):[]).filter(d=>!d.startsWith("_")).map(d=>({accessorKey:d,header:d,enableSorting:true})),[e]);return useEffect(()=>{let c=()=>{if(t.current){let{scrollWidth:u,clientWidth:d,scrollLeft:m}=t.current;r(u>d),i(m>0),l(m+d<u-1);}};return c(),window.addEventListener("resize",c),t.current?.addEventListener("scroll",c),()=>{window.removeEventListener("resize",c),t.current?.removeEventListener("scroll",c);}},[e]),jsxs("div",{className:"bespoke-sortable-table",style:{position:"relative"},children:[jsx(MantineReactTable,{columns:s,data:e,enableBottomToolbar:false,enableColumnActions:false,enablePagination:false,enableSorting:true,enableTopToolbar:false,layoutMode:"grid",enableStickyHeader:true,initialState:{density:"xs"},mantineTableProps:{sx:{tableLayout:"fixed"}},mantineTableContainerProps:{ref:t,sx:{minHeight:100,maxHeight:350,overflowX:"auto"}},mantineTableBodyCellProps:{p:"5px !important",sx:{textWrap:"wrap"}},defaultColumn:{minSize:50,maxSize:150}}),jsx(wC,{direction:"left",visible:o&&n,onClick:()=>{t.current&&t.current.scrollBy({left:-150,behavior:"smooth"});}}),jsx(wC,{direction:"right",visible:o&&a,onClick:()=>{t.current&&t.current.scrollBy({left:150,behavior:"smooth"});}})]})}var og=N(()=>{p();});var ma,bp,yp=N(()=>{p();ma="HTML",bp=({config:e})=>!e||!e.html?null:jsx("div",{className:"bespoke-html",dangerouslySetInnerHTML:{__html:e.html}});});function lg(e){let{section:t}=e,o=Ir(),r=useRouter(),n=H(W=>W.status.isCMS),i=H(W=>W.status.currentLocale),a=r.locale,l=n?i:a,s=50,c=Ao(l),u=xn(),d=Pe(),m=bo("options"),g={...LC,...m.data_tab},[f,h]=useState([]),[v,T]=useState([]),[y,C]=useState(),[b,w]=useState(),[k,I]=useState(false),[O,P]=useState({}),[_,D]=useState(true),[L,R]=useState(true),{sectionVariables:z,setSectionVariables:A,resetSectionVariables:V}=pt(t.id),j=t.blocks||[],B=H(W=>W),U=useMemo(()=>j.reduce((W,K)=>{let oe=B.records.entities.block[K],re=B.variables.variables[K],ue=B.variables.status[K];return oe&&(E.GENERATOR===oe.type&&re._downloadEnabled===true&&ue.allowed||E.VIZ===oe.type&&ue.allowed)&&(W[K]={entity:oe,variables:B.variables.variables[K],status:B.variables.status[K],inputVariablesFlat:oe.inputs.reduce((Ee,q)=>({...Ee,...B.variables.variables[q]}),B.variables.attributes)}),W},{}),[j]),$=W=>{T(K=>K.includes(W)?K:[...K,W]);},Y=W=>{h(K=>(K.find(re=>re.ix===W.ix)?K:[...K,W]).sort((re,ue)=>re.ix>ue.ix?1:-1));};function F(W){!y&&W[0]&&G(W[0]);}function G(W){C(W),w("0");}useEffect(()=>{let W=async(K,oe,re)=>{let ue=dataLoad.bind({});return new Promise((Ee,q)=>{ue(oe,null,null,(ce,de)=>{if(ce)q(ce);else {let Se=re instanceof Function?re(de):de;K.data.unshift(Se),Y(K),Ee(de);}});})};if(f.length===0&&v.length===0){let K=0;for(let oe of Object.values(U)){let re=oe.entity;if([E.GENERATOR,E.SECTION_FLAG].includes(re.type)){let ue=oe.variables._downloadData||oe.variables._downloadUrl||oe.status.api;if(ue){let Ee=[];typeof ue=="string"?Ee=ue.split("|||"):Ee=[ue],Ee=gp(Ee,u,d);let q=oe.variables._downloadTitle||`${g.data_source} ${K+1}`,ce=oe.variables._downloadFileName||q;Y({ix:K,id:re.id,title:Qt(q),fileName:ce,data:Array.isArray(Ee)?Ee:[Ee],loading:false,type:E.GENERATOR}),$(K),K++;}}else if(re.type===E.VIZ){let ue=Eo(re),Ee=oe.inputVariablesFlat,q={variables:Ee},ce=Tr({logic:ue.logic},c,q).logic,de={router:r,section:{variables:z,setVariables:A,resetVariables:V}},Se=da(ce,c,Ee,l,re.id,{},de,u,d),$e=Se.config._downloadTitle||Se.config.title||`${g.viz_source} ${K+1}`,We=Se.config._downloadFileName||$e;if(Se.config._downloadEnabled!==false&&Se.config.type!==ma)try{let Qe=Se.config._downloadUrl||Se.config.data,Co=typeof Qe=="string"?[Qe]:Qe,Uo=Se.dataFormat instanceof Function?Se.dataFormat:!1,po=Se.config._downloadDataFormat instanceof Function?Se.config._downloadDataFormat:!1;W({ix:K,id:re.id,title:Qt($e),fileName:We,data:Co,loading:!1,type:E.VIZ},Qe,po||Uo),$(K),K++;}catch(Qe){console.error("DataLoad catch",Qe);}}}R(false);}},[U]),useEffect(()=>{f.length===v.length&&F(f);},[f]),useEffect(()=>{if(y&&b){let W=parseInt(b,10);if(y.data[W]&&(!O[y.ix]||!O[y.ix][b])){D(true);let K=y.data[b];typeof K=="string"?Bm(K,o,l,[],void 0).then(oe=>{let re=$1(oe);P({...O,[y.ix]:{...O[y.ix],[W]:re}});}).catch(oe=>{console.error(oe);}).finally(()=>{D(false);}):(P({...O,[y.ix]:{...O[y.ix],[W]:K}}),D(false));}}},[b,y]);let J=(W,K)=>{let oe=W===K?"":`-${W}`.toLowerCase();if(y){let re=y.data.length>1&&b?`-${parseInt(b,10)+1}`:"";return `${Tt(y.fileName)}${oe}${re}.${K.toLowerCase()}`}return `${oe}.${K}`},ee=async W=>{if(y){I(true);let K=new R1,oe=J(W,W);try{switch(W){case vp.json.extension:K.file(oe,JSON.stringify(ne));break;case vp.csv.extension:K.file(oe,csvFormat(ne));break;case vp.xlsx.extension:{let{utils:re,write:ue}=await import('xlsx'),Ee=re.book_new();re.book_append_sheet(Ee,re.json_to_sheet(ne),oe.substring(0,30));let q=ue(Ee,{bookType:"xlsx",bookSST:!0,type:"binary"});K.file(oe,q,{binary:!0});break}default:break}K.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(re=>{I(!1),saveAs(re,J(W,"zip"));});}catch(re){console.error(g.error_generating,re),I(false);}}},ne=useMemo(()=>y&&O[y.ix]&&O[y.ix][b]?O[y.ix][b]:[],[O,y,b]),X=useMemo(()=>{if(f&&f.length>0&&f.length===v.length){let W=f.map(K=>({value:`${K.ix}`,label:K.title}));return jsx(Select,{disabled:!y,style:{flex:"1"},value:`${y?.ix}`,onChange:K=>{let oe=f.find(re=>`${re.ix}`===K);G(oe);},data:W,icon:jsx(IconDatabase,{size:16})})}else return ""},[f,y,v]);return jsxs(Stack,{className:"cms-section-options-data",spacing:"xs",children:[jsx(LoadingOverlay,{visible:L,overlayBlur:2}),f.length===0&&!L&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:g.no_data_src}),f.length>1&&f.length===v.length&&!L&&jsx(Input.Wrapper,{label:`${g.choose_data_src}:`,children:jsx(Group,{spacing:"xs",children:X})}),y&&b&&jsx(Stack,{spacing:"xs",children:jsx(Input.Wrapper,{label:`${g.preview}
37
- ${ne.length>s?g.rows_preview.replace("{nrows}",s):""}:`,children:jsxs(Group,{spacing:"xs",children:[jsx(Select,{disabled:!(y.data.length>1),style:{flex:"1"},value:b,onChange:W=>w(W),data:y.data.map((W,K)=>({value:`${K}`,group:typeof W=="string"?g.raw_group:g.formatted_group,label:typeof W=="string"?W:g.formatted_src.replace("{src}",y.title)})),icon:typeof y.data[b]=="string"?jsx(IconLink,{}):jsx(IconSparkles,{})}),jsx(CopyButton,{value:typeof y.data[b]=="string"?y.data[b]:"",timeout:2e3,children:({copied:W,copy:K})=>jsx(Tooltip,{label:W?g.copied:g.copy,withArrow:true,position:"top",children:jsx(ActionIcon,{variant:W?"filled":"subtle",onClick:K,disabled:typeof y.data[b]!="string",children:W?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})]})})}),y&&!_&&ne.length===0&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:g.error_preview}),y&&b&&!_&&ne.length===0&&jsx("a",{href:y.data[b],target:"_blank",rel:"noreferrer",children:jsx(Button,{leftIcon:jsx(IconExternalLink,{size:16}),fullWidth:true,children:g.open_in_window.replace("{src}",y.title)})}),jsxs(Stack,{pos:"relative",mih:"400px",spacing:"xs",children:[jsx(LoadingOverlay,{visible:_&&f.length>0,overlayBlur:2}),y&&!_&&ne.length>0&&jsxs(Fragment,{children:[jsx(hp,{data:ne.slice(0,s)}),jsx(Input.Wrapper,{label:`${g.download}:`,children:jsx(Button.Group,{children:Object.values(vp).map(W=>jsx(Button,{leftIcon:jsx(W.icon,{size:24}),onClick:()=>ee(W.extension),loading:k,fullWidth:true,children:W.extension},`format-${W.extension}`))})})]})]})]})}var vp,LC,$1,cg=N(()=>{p();ae();og();he();cc();jr();ds();Wo();xe();dt();Vi();vn();st();kr();Yr();yp();vp={csv:{extension:"CSV",icon:IconFileTypeCsv},json:{extension:"JSON",icon:IconFileTypeJs},xlsx:{extension:"XLSX",icon:IconFileTypeXls}},LC={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.
38
- 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!"},$1=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};});var H1,xp=N(()=>{p();ae();dt();st();H1={active:false,pdfParam:false,position:"DEFAULT",XlsxVizActive:false,pdfVariants:[],xlsxVariants:[],currentVariantPdfEnabled:false,currentVariantXlsxEnabled:false,isLoading:false,pdfAccessAllowed:false,xlsxAccessAllowed:false,sectionSelection:false,navBlockId:void 0},createContext(H1);});var BC=N(()=>{p();ae();he();Wo();Vi();xe();cc();dt();EC();Yr();cg();xp();Rn();Ho();});var DC=N(()=>{p();ae();});var _C=N(()=>{p();Pt();ae();vn();Xn();Wr();st();dt();});function Tp(e,t,o,r,n=false){let i=useRouter(),{query:a,locale:l}=i,s=H(R=>R),c=useDispatch(),u=Lr(),d=H(R=>r&&u.variables?u?.variables?.attributes:R.variables.attributes),m=na(s),g=ss(s),f=ls(s),h=Yn(g,l),v=ot(e,r&&u.active?u?.variables.variables:void 0,r&&u.active?u?.variables.attributes:void 0),T=H(R=>r?u.variables.variables:R.variables.variables),y=H(R=>r?u.variables.status:R.variables.status),C=Ir(),{sectionVariables:b,resetSectionVariables:w}=pt(t),{addRunConsumersRunning:k,removeRunConsumersRunning:I}=Wl(),O=Pe(),P=r&&u.active?`${o}-valueCompare`:`${o}-value`,_=r&&u.active?`${o}-typeCompare`:`${o}-type`,D=r&&u.active?Object.fromEntries(Object.entries(a).filter(([R])=>R.match(q1)).map(([R,z])=>[R.replace("Compare",""),z])):Object.fromEntries(Object.entries(a).filter(([R])=>R.match(Y1)).map(([R,z])=>[R.replace("Compare",""),z]));return useCallback((R,z)=>{let A={locale:l,query:{...D,[`${o}-type`]:z,[`${o}-value`]:R},variables:v},V=new URLSearchParams(window.location.search);R&&z?(V.set(P,R.join(",")),V.set(_,z)):(V.delete(P),V.delete(_)),window.history.replaceState(null,null,`?${V.toString()}`),k([t]),oi(m,void 0,e,h,A,{variables:T,status:y},C,"report",f,O).then(j=>{n&&b&&w(),u.active&&r?u.setComparisonVariables({attributes:d,variables:j.variables,status:j.status}):c(Ui.setVariableChange({attributes:d,variables:j.variables,status:j.status})),I([t]);});},[r,d,e,m,u,c,h,y,T,l,D,C,o,_,P,v,b,n,w])}var q1,Y1,NC=N(()=>{p();li();st();vn();ae();xe();Xn();Wr();Xa();dt();q1=/\w*Compare\b/,Y1=/multihierarchySelector\d+(id|-(type|value))/;});function Lo(){return useMantineTheme().other.bespokeStyles??{}}var zC=N(()=>{p();});var FC=N(()=>{p();});var Z1,ez,ui,uc=N(()=>{p();Z1={try_another:"Try another search or filter.",search:"Search",filters_all:"All",no_results:"No Results",load_more:"Load more",select_report:"Select Report",select_variant:"Select Variant",count_format:".2s",report:{},dimension:{},variant:{}},ez=createContext({metadata:[],loadingItems:false,setLoadingItems:()=>null,loadingMetadata:false,setLoadingMetadata:()=>null,resultCount:{},totalCount:{},setResultCount:()=>null,activePage:1,setActivePage:()=>null,pageSize:10,results:[],filters:{},doQuery:()=>null,setFilters:()=>null,query:"",setQuery:()=>null,debouncedQuery:"",currentPageTotal:10,selectorStructure:[],translations:Z1,setTranslations:()=>null,showSelectors:true}),ui=()=>useContext(ez);});function oz({translations:e}){let{loadingItems:t,setFilters:o,selectorStructure:r,filters:n,showSelectors:i}=ui(),a=f=>{let h=f===null||Number.isNaN(f)?void 0:parseInt(f,10);h!==n.profile?o({profile:h,variant:void 0}):h&&o({profile:void 0,variant:void 0});},l=f=>{let h=f===null?void 0:typeof f=="string"&&f.includes(",")?f:parseInt(f,10);h!==n.variant?o({...n,variant:h}):h&&o({...n,variant:void 0});},s=f=>f<1e3?f:format$1(e.count_format)(f).replace(/\.0+([a-zA-Z]*)$/,"$1"),c=r.length===2?r[1].id:n.profile,u=c?r.find(f=>f.id===c):void 0,d=u&&u.variants&&n.variant?u.variants.find(f=>f.id===n.variant):void 0,m=useMemo(()=>r.map(f=>({value:String(f.id||""),label:(e?.dimensionIcon?.[f.name]?`${e?.dimensionIcon?.[f.name]} `:"")+(e?.dimension[f.name]||f.name)+(!t&&(!u||f.id===u?.id)?` (${s(f.members_count)})`:"")})),[e,u,r]),g=useMemo(()=>u?.variants?.map(f=>({value:String(f.id||""),label:(e?.variantIcon?.[f.name]?`${e?.variantIcon?.[f.name]} `:"")+(e?.variant[f.name]||f.name)+(!t&&(!d||f.id===d?.id)?` (${s(f.members_count)})`:"")}))??[],[e,d,r]);return jsx(Fragment,{children:i&&jsxs(Fragment,{children:[jsx(MediaQuery,{largerThan:1e3,styles:{display:"none"},children:jsxs(Group,{className:"bespoke-explore-reports-select-container",position:"center",mb:"md",children:[jsx(Select,{className:"bespoke-explore-reports-select",data:m,value:String(u?.id||""),onChange:f=>a(f),label:e.select_report||"Select Report",placeholder:e.select_report||"Select Report",clearable:typeof u?.id<"u",style:{width:"450px"}}),u?.variants&&u.variants.length>2&&jsx(Select,{className:"bespoke-explore-variant-select",data:g,value:String(d?.id||""),onChange:f=>l(f),label:e.select_variant||"Select Variant",placeholder:e.select_variant||"Select Variant",clearable:typeof d?.id<"u",style:{width:"450px"}})]})}),jsx(MediaQuery,{smallerThan:1e3,styles:{display:"none"},children:jsxs("div",{children:[jsx(Group,{position:"center",className:"bespoke-explore-reports-selector",mb:"md",children:r.map(f=>jsxs(Button,{"data-selected":f.id===u?.id?"true":"false","data-report-name":f.name,variant:f.id===u?.id?"outline":"subtle",onClick:()=>a(f.id),rightIcon:f.id&&f.id===u?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.dimensionIcon?.[f.name]??void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-reports-name",dangerouslySetInnerHTML:{__html:e?.dimension[f.name]??f.name}}),!t&&(!u||f.id===u?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-reports-count",children:`(${s(f.members_count)})`})]},`p-${f.id}`))}),u&&u.variants&&u.variants.length>2&&jsx(Group,{position:"center",style:{minHeight:"36px"},className:"bespoke-explore-variant-selector",mb:"md",children:u.variants.map(f=>jsxs(Button,{"data-selected":f.id===d?.id?"true":"false","data-variant-name":f.name,variant:f.id===d?.id?"outline":"subtle",onClick:()=>l(f.id),rightIcon:f.id&&f.id===d?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.variantIcon?.[f.name]?jsx(Text,{span:true,dangerouslySetInnerHTML:{__html:e.variantIcon[f.name]}}):void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-variant-name",dangerouslySetInnerHTML:{__html:e?.variant[f.name]??f.name}}),!t&&(!d||f.id===d?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-variant-count",children:`(${s(f.members_count)})`})]},`v-${f.id}`))})]})})]})})}var jC,KC=N(()=>{p();uc();jC=oz;});function pg({reportId:e,reportName:t,members:o,href:r,onClick:n}){let i=o.map(l=>jsx(Image,{src:l.image.src,height:160,imageProps:{loading:"lazy"},alt:l.name},l.id)),a=o.map(l=>jsxs(Stack,{children:[jsx(Text,{weight:500,children:l.name}),jsx(Badge,{color:"green",variant:"light",w:"fit-content",children:l.variant})]},l.id));return jsxs(Card,{className:`report-${e}-tile`,shadow:"sm",p:"lg",radius:"md",withBorder:true,children:[jsx(Card.Section,{children:jsx(Group,{grow:true,spacing:0,children:i})}),jsx(Group,{position:"apart",mt:"md",mb:"xs",children:a}),jsx("a",{href:r,onClick:n,children:jsx(Button,{variant:"light",color:"blue",fullWidth:true,mt:"md",radius:"md",children:`See ${t} Report`})})]})}function pz({profile:e,profilePrefix:t,onSelect:o,reportTile:r}){let n=useRouter(),i=n.locale,{localeDefault:a}=je(),s=`${i===a?"":`/${i}`}${t}${e.path}`,c=e.members.map(g=>({original_id:g.metadata.id,name:g.name,id:g.id,dimension_id:g.metadata.dimension.id,dimension:g.metadata.dimension.name,variant_id:g.metadata.variant.id,variant:g.metadata.variant.name,image:{src:`/api/cms/member/image?member=${g.id}&size=thumb`,alt:g.name}})),u=g=>{n.push(`${g}`),o&&o();},d=g=>{g.preventDefault(),u(s);},m=uz(r);return jsx(Grid.Col,{xs:12,sm:6,md:4,lg:4,xl:3,children:jsx(m,{reportId:e.report.id,reportName:e.report.name,members:c,href:s,onClick:d})},e.id)}var uz,JC,dg=N(()=>{p();io();Go();uz=e=>{let{components:t}=Lo(),o=pg;return t?.ReportTile&&(o=t?.ReportTile),e&&(o=e),o};JC=pz;});function bz({profilePrefix:e,onSelect:t=()=>{},reportTile:o}){let[r,n]=useState(500),i=useRef(null),{results:a}=ui(),l=i.current?.offsetTop||0,s=50;return useEffect(()=>{let{innerHeight:c}=window;n(c-l-s);},[l]),jsx(ScrollArea,{offsetScrollbars:true,type:"always",h:r,ref:i,children:jsx(Grid,{align:"stretch",children:a.map(c=>jsx(JC,{profile:c,profilePrefix:e,reportTile:o,onSelect:t},c.id))})})}var QC,ZC=N(()=>{p();dg();uc();QC=bz;});function Sz(){let{activePage:e,setActivePage:t,pageSize:o,currentPageTotal:r}=ui();return jsx(Group,{position:"center",children:jsx(Pagination,{value:e,onChange:i=>{t(i);},total:Math.ceil(r/o),size:"sm",py:"xs"})})}var tk,ok=N(()=>{p();uc();tk=Sz;});function Oz({profilePrefix:e,initialReportId:t,initialVariantId:o,translations:r,onSelect:n,reportTile:i,initialQuery:a}){let l=useRef(),s=ui(),{query:c,setQuery:u,results:d,loadingItems:m,loadingMetadata:g,translations:f,setTranslations:h,initExplore:v}=s;useEffect(()=>{v&&v(t,o,a);},[v]),useEffect(()=>{m||l.current?.focus();},[m]),useEffect(()=>{r&&h(r);},[r]);let T=()=>{u("");};return jsxs(Container,{fluid:true,pt:"1em",children:[jsx(TextInput,{placeholder:f.search,mb:"md",size:"xl",onChange:y=>u(y.target.value),readOnly:g||m,icon:jsx(IconSearch,{size:24}),value:c,rightSectionWidth:100,rightSectionProps:{style:{justifyContent:"flex-end",padding:"0 15px 0 0"}},rightSection:jsxs(Group,{align:"center",children:[(g||m)&&jsx(Loader,{size:28}),c&&c!==""&&jsx(ActionIcon,{onClick:T,children:jsx(IconTrash,{size:24})})]}),ref:l}),jsx(jC,{translations:f}),jsx(LoadingOverlay,{visible:g||m}),!m&&d.length===0&&jsx(Alert,{title:f.no_results,color:"blue",children:f.try_another}),jsx(QC,{profilePrefix:e,onSelect:n,reportTile:i}),jsx(tk,{})]})}var nk,ik=N(()=>{p();KC();ZC();ok();uc();nk=Oz;});function Fz({exploreProps:e={profilePrefix:"/",locale:zz},icon:t=jsx(IconSearch,{size:20}),actionIconProps:o={},modalProps:r={},tooltipProps:n={},tooltipText:i="Click to Explore",showIcon:a=true,showTooltip:l=false,children:s}){let[c,u]=useState(false),d={variant:"light",size:"md",radius:"md",...o},m={fullScreen:true,opened:c,onClose:()=>u(false)},g=jsx(ActionIcon,{...d,onClick:()=>u(true),children:t}),f=a?jsxs(Group,{spacing:"sm",style:{cursor:"pointer"},children:[s,g]}):s;return l&&(f=jsx(Tooltip,{label:i,...n,children:f})),jsxs(Fragment,{children:[jsx(Modal,{...m,...r,children:c&&jsx(nk,{...e,onSelect:()=>u(false)})}),jsx("div",{onClick:()=>u(true),children:s?f:jsx(Fragment,{children:g})})]})}var zz,lk,ck=N(()=>{p();ik();Go();({localeDefault:zz}=je());lk=Fz;});var Wz,uk,pk=N(()=>{p();Wz=forwardRef(({id:e,members:t,...o},r)=>{let n=t.map(i=>jsxs(Stack,{align:"center",children:[jsx(Text,{weight:500,children:i.name}),jsx(Badge,{color:"green",variant:"light",children:i.variant})]},i.id));return jsx("div",{ref:r,children:jsx(Group,{position:"apart",grow:true,...o,children:n})},e)}),uk=Wz;});function rF({locale:e,profilePrefix:t="/report",autocompleteProps:o={},tooltipProps:r={},tooltipText:n="Click to search",searchReportParams:i={},callback:a,children:l}){let s=useRouter(),c=s.locale,{localeDefault:u}=je(),d=c===u?"":`/${c}`,m=oF(o?o.itemComponent:null),[g,f]=useState(""),[h,v]=useDebouncedValue(g,500),[T,y]=useState([]),[C,b]=useState(false),[w,k]=useState(false),[I,O]=useState(false),[P,_]=useState(!l),D=()=>{_(false);},L=()=>{_(true),V();},R=useRef(),z=useClickOutside(D),A=o?.searchConfig?.searchLimit??10,V=()=>{b(true);let J={query:h,format:"profiles",locale:e,limit:A,visible:true,includes:true,noImage:false,variant:[],dimension:[],report:[],all:false,...i};Mu.get("/api/cms/search/reports",{params:J}).then(ee=>{ee&&ee.data&&ee.data.data&&ee.data.data.results&&y(ee.data.data.results.map(ne=>({id:ne.id,reportName:ne.report.name,href:`${d}${t}${ne.path}`,reportPath:`${ne.path}`,profilePrefix:t,value:`VALUE: ${ne.id}`,members:ne.members.map(X=>({original_id:X.metadata.id,name:X.name,id:X.id,variant:X.metadata.variant.name,image:{src:`/api/cms/member/image?member=${X.id}&size=thumb`,alt:X.name}}))}))),b(false),R.current?.focus();}).catch(ee=>{console.error(ee),b(false);});};useEffect(()=>{I&&h.length>=(o.searchConfig?.queryThreshold??0)&&V();},[I,h,o.searchConfig?.queryThreshold]),useEffect(()=>{v(),R.current&&P&&O(true);},[]),useEffect(()=>{v(),R.current&&P&&O(true);},[P]);let j=J=>{_(false),a?a(J):(s.push(J.href),k(true));},B=J=>{J.includes("VALUE:")||f(J);},{searchConfig:U,...$}=o,Y={placeholder:"Search",size:"md",icon:jsx(IconSearch,{}),...$,data:T},F=jsx(Autocomplete,{value:g,itemComponent:m,onItemSubmit:j,onChange:B,filter:()=>true,disabled:(C||w)&&!I,limit:A,maxDropdownHeight:250,rightSection:jsx(Group,{spacing:0,position:"right",children:C?jsx(Loader,{size:20}):jsx(Fragment,{})}),rightSectionWidth:50,ref:R,...Y});return l?jsx(Tooltip,{label:n,disabled:P,...r,children:jsxs(Group,{ref:z,spacing:"sm",align:"center",style:{cursor:"pointer"},children:[!P&&jsx("div",{onClick:()=>_(true),children:l}),P&&jsx(Fragment,{children:F}),P?jsx(ActionIcon,{variant:"light",onClick:D,children:jsx(IconX,{size:20})}):jsx(ActionIcon,{variant:"light",onClick:L,children:jsx(IconSearch,{size:20})})]})}):F}var oF,hk,bk=N(()=>{p();io();pk();Go();oF=e=>{let{components:t}=Lo(),o=uk;return t?.ReportItem&&(o=t?.ReportItem),e&&(o=e),o};hk=rF;});function sF(){let{components:e}=Lo(),{modal:t,inline:o}=e?.search??{};return {modal:t,inline:o}}function Ms(e,t,o,r,n){let i=sF(),a=H(d=>({reportId:d.variables.attributes.report_id,variantId:d.variables.attributes.variant_id1,title:d.variables.attributes.name1})),l=useRouter(),s=os(),c=bo();return useMemo(()=>{let d=e;return t==="modal"?d=jsx(lk,{exploreProps:{locale:l.locale||yk,profilePrefix:s,translations:c.explore,initialReportId:a.reportId,initialVariantId:a.variantId,initialQuery:a.title},tooltipText:c.explore?.tooltip,modalProps:i.modal,...n,children:e}):t==="inline"&&(d=jsx(hk,{locale:l.locale||yk,profilePrefix:s,callback:o,tooltipText:c.explore?.tooltip,...r,autocompleteProps:i.inline,children:e})),d},[t,e])}var yk,Sk=N(()=>{p();Yr();ae();xe();ck();bk();Go();io();({localeDefault:yk}=je());});var io=N(()=>{p();_T();NT();zT();BC();mf();DC();_C();NC();zC();FC();Sk();});function bg({title:e,tooltip:t,slug:o,_iconType:r,_iconVariant:n,_icon:i,settings:a,_iconRadius:l,_iconSize:s,_iconPadding:c,asComparison:u=false}){let{print:d}=ur(),m=He(e)||"<span class='cr-block-placeholder'>Title</span>",g=a&&a.order?parseInt(a.order,10):1,f=g<=6?g:1,h=a&&a.search?a.search:"off",v=a&&a.align?a.align:"left",T=Lr(),y=H(O=>O.status.previews),b=(u?T.status.previews:y).map(O=>O.name).join(" | "),w=jsxs(Group,{children:[jsx(Ke,{blockType:"title",iconType:r,iconVariant:n,iconRadius:l,iconSize:s,icon:i,iconPadding:c}),jsx(ye,{id:o||void 0,component:"h",order:f,style:a,html:m})]}),k=Ms(w,h),I=a&&a.addComparisonName==="yes"&&T.active;return jsxs(Group,{spacing:"sm",position:ro(v),children:[jsxs("div",{children:[d?w:k,I&&jsx(Text,{className:"bespoke-comparison-title",children:b})]}),t&&jsx(Ut,{content:t})]})}var Tk=N(()=>{p();Kr();wn();ft();io();li();ae();Rn();En();no();});function xg(e){let{name:t,settings:o,options:r,id:n,defaultValue:i,section:a,component:l,asComparison:s,hideLabel:c,resetSectionVars:u}=e,{print:d}=ur(),m=xF(n),g=fp(n,a,m,s,u==="true"),f=s?`${m}Compare`:m,[h,v]=useState(i),[T,y]=useState(kk(i,[])),C=JSON.stringify(r),b=o[_t.DISABLED]||false,w=useMemo(()=>r?.map(D=>({value:D.id,label:D.label,imageUrl:D.imageUrl})),[C]),k=d?r.filter(D=>T.includes(D.id)).map(D=>D.label).join(", "):"",I=d&&h&&r.find(D=>D.id===h)?.label||"",O=e.hideLabel==="true"?jsx(Fragment,{}):jsx(ye,{component:"div",html:t,size:"sm",style:o});if(useEffect(()=>{if(!b){let L=new URLSearchParams(window.location.search).get(f)||i;L&&(e.type===xt.SINGLE?v(L):y(kk(L,i)));}},[window.location.search,i]),w.length<=1)return jsx(Fragment,{});let P=D=>{y(D),g(D.join(","));},_=D=>{v(D),g(D);};return jsx(Fragment,{children:d?jsxs(Box,{style:{display:"flex",alignItems:"center"},children:[O,jsx(Button,{ml:"sm",radius:"xl",variant:"outline",children:e.type===xt.SINGLE?I:k})]}):jsx(Box,{children:{[xt.SINGLE]:l===Eu.SEGMENTED_CONTROL?jsxs("div",{children:[jsx(Text,{size:"sm",fw:500,display:c==="true"?"none":"block",children:O}),jsx(SegmentedControl,{data:w,disabled:b,value:w.map(D=>D.value).includes(h)?h:"",onChange:_,fullWidth:true})]}):jsx(Select,{label:O,data:w,disabled:b,value:h,itemComponent:TF,onChange:_,styles:{label:{display:c==="true"?"none":"block"}}}),[xt.MULTI]:jsx(MultiSelect,{label:O,data:w,value:T,onChange:P,disabled:b,styles:{label:{display:c==="true"?"none":"block"}}})}[e.type]})})}var xF,kk,TF,wk=N(()=>{p();ft();he();io();Rn();xF=e=>`selector${e}id`,kk=(e,t)=>e&&typeof e=="string"?e.split(","):t,TF=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{noWrap:true,children:[t&&!["","undefined"].includes(t)&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});function Ep(){return jsx("div",{children:"Generator"})}var Rk=N(()=>{p();});function Tg(e){let{alt:t,src:o,desc:r,title:n,settings:i,...a}=e,l=He(t),s=He(o),c=He(r),u=jsx("img",{src:s,alt:l,style:a}),d=i&&i.align?String(i.align):"left";return (c&&c.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Oo(d),spacing:"sm",children:[n&&jsx(ye,{component:"p",html:n,style:i}),u,r&&jsx(ye,{component:"p",size:"sm",html:r,style:i})]})),s&&l?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var Ik=N(()=>{p();Kr();ft();no();});function fc(){return fc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r]);}return e},fc.apply(this,arguments)}var Ak=N(()=>{p();});function gc(){return gc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r]);}return e},gc.apply(this,arguments)}var Pk=N(()=>{p();});function ga(e,t,o){var r,n=(r=o.initialDeps)!=null?r:[],i;return function(){var a;o.key&&o.debug!=null&&o.debug()&&(a=Date.now());var l=e(),s=l.length!==n.length||l.some(function(f,h){return n[h]!==f});if(!s)return i;n=l;var c;if(o.key&&o.debug!=null&&o.debug()&&(c=Date.now()),i=t.apply(void 0,l),o.key&&o.debug!=null&&o.debug()){var u=Math.round((Date.now()-a)*100)/100,d=Math.round((Date.now()-c)*100)/100,m=d/16,g=function(h,v){for(h=String(h);h.length<v;)h=" "+h;return h};console.info("%c\u23F1 "+g(d,5)+" /"+g(u,5)+" ms",`
31
+ }`;});function mo(e){return e.type===E.SECTION_FLAG&&e.inputs.length===0&&e.consumers.length===0}var Jn=D(()=>{p();he();});function xO(){let{publicRuntimeConfig:e}=SO(),t=e.bespoke_report_env_vars||{};return {...Object.keys(t).reduce((o,r)=>(o[`ENV_${r}`]=t[r]||"N/A",o),{})}}var wo,Qn=D(()=>{p();wo=xO;});function TO(){return typeof process>"u"?{}:Object.entries(process.env).filter(([e])=>e.startsWith("BESPOKE_SECRET_")).reduce((e,[t,o])=>({...e,[t.replace("BESPOKE_SECRET_","ENV_SECRET_")]:o}),{})}var nS,iS=D(()=>{p();nS=TO;});function Lu(e){return e.ok!==void 0}function Ou(e){this.message=e,this.name="ApiFetchException";}async function Dm(e,t,o="en",r,n,i){let a=Date.now(),l=e,s,c=wo(),u=nS(),d={envs:{...c,...u}},f=new URL(e),g=new URLSearchParams(f.searchParams.toString());g.has("bespoke_slugs")&&(f.searchParams.delete("bespoke_slugs"),l=f.toString());let m={datasource:void 0};r.find(C=>{if(!C.content?.pattern)return false;try{let b=new RegExp(C.content.pattern,"gm");return b.test(l)?(m.datasource=C,!0):b.test(l)}catch{return false}});let h=n?n.settings:{},y=!!(h&&h.useProxy&&h.useProxy==="true"),S=m.datasource&&typeof m.datasource.content.useProxy=="boolean"?m.datasource.content.useProxy:false,v=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(l)}`;if(typeof window=="object"&&(y||S)){let C=await AO({url:l,timeout:sS});if(C.ok===true)s=C.data;else throw new Ou(C?.error)}else try{let b={url:l,timeout:sS};if(m.datasource){let w=d;i&&(w={...d,session:i});let O=typeof window>"u"&&m.datasource.content.logic_ssr?m.datasource.content.logic_ssr:m.datasource.content.logic,B=await Ua({vars:["url","libs","session"],logic:O},w)(l);if(B.axiosConfig)b=B.axiosConfig;else throw new Ou(`AxiosConfig is missing in Data Source ${m.datasource.name} (ID: ${m.datasource.id}).`)}let k=await Mu(b);if(k.status===200)k.headers["content-type"]==="text/csv"?s=csvParse(k.data):s=k.data;else throw new Ou("No response for: "+l)}catch(C){throw new Ou(C.message)}if(g.has("bespoke_slugs")){let C=g.get("bespoke_slugs");if(C){let b=C.split(",");if(b.length===3){let[k,w,R]=b,O=Pu(s,R);if(O&&Array.isArray(O)){let A=Array.from(new Set(O.map(B=>`${B[w]}`).filter(B=>!["","undefined"].includes(B))));if(A.length>0){let B=A.join("").length>2e3,_=await t({mode:B?"whole":"ids",ids:B?void 0:A,all:false,locale:o,variant:[parseInt(k,10)],output:"lite",limit:A.length+1,allowNulls:true}).then(P=>{let I=[];return Lu(P)?P.ok&&(I=P.data.results):I=P.results,I&&Array.isArray(I)?I:[]}).catch(P=>(console.error(`Error hydrating slugs for Variant: ${k}, Key: ${w}, Accessor: ${R}`),console.error(` Url ${e}`),n&&console.error(` From Section ${n.section_id} and Block ${n.id}`),console.error(P),[]));if(_){let P=Object.fromEntries(_.map(I=>[I.id,`/${I.variant_slug}/${I.slug}`]));O.map(I=>(I.bespoke_slug=P[I[w]]?P[I[w]]:null,I));}}}}}}return {data:s,requestDuration:Date.now()-a,finalUrl:S||y?v:l,apiDataSource:m.datasource?m.datasource:false}}function PO(e){this.name="BlockException",this.message=e;}async function Ll(e,t,o,r,n,i){let{locale:a,variables:l,query:s}=or(o),c=OO(e,o,l,t),u=null,d=e.contentByLocale?.logic?.content?.api,f=null,g=null,m=null,h=null,y=null;if(!c)return {outputVariables:{},renderVariables:{},status:{allowed:false,hiddenByCascade:e.id}};if(e.type===E.FALLBACK)return {outputVariables:{},renderVariables:{},status:{allowed:c,hiddenByCascade:e.id}};if(d){m=IO(d,t,o);let O=m.split("|||").filter(_=>_!==""),A=[];for(let _=0;_<O.length;_++){let P=O[_];new RegExp("^(?:[a-z+]+:)?//","i").test(m)||(P=`${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/${P}`.replace(/([^:]\/)\/+/g,"$1")),A.push(Dm(P,r,a,n,e,i).catch(F=>{throw new PO(` Excecution of ${e.type}-${e.id} in section ${e.section_id} in report ${l.report_name} (${l.report_id}) failed.
32
+ Error fetching ${P}.
33
+ Message: ${F.message}.
34
+ `)}));}let B=await Promise.all(A).catch(_=>_.message);if(typeof B=="string"&&B)return {outputVariables:{},renderVariables:{},status:{error:B}};u=B.length===1?B[0].data:B.map(_=>_.data),g=B.reduce((_,P)=>_+JSON.stringify(P.data).length/1024,0),f=Math.max(...B.map(_=>_.requestDuration)),h=B.map(_=>_.apiDataSource?`${_.apiDataSource.name} (${_.apiDataSource.id})`:null),y=B.map(_=>_.finalUrl);}if(e.type===E.SELECTOR){let{config:O,log:A,error:B}=Iu(e.id,e.contentByLocale[a].content.logic,t,o,true);return {outputVariables:qv(e.id,s,O),renderVariables:O,status:{log:A,error:B,allowed:c}}}if(e.type===E.MULTIHIERARCHY_SELECTOR){let{config:O,log:A,error:B}=Au(e.id,e.contentByLocale[a].content.logic,t,o,true);return {outputVariables:Xv(e.id,s,O),renderVariables:O,status:{log:A,error:B,allowed:c}}}if(e.type===E.VIZ)return {outputVariables:{},renderVariables:e.contentByLocale.logic.content,status:{log:[],allowed:c}};if(e.type===E.RELATED){let O=e.contentByLocale?.logic?.content?.simple?.compare||"variant",A=e.contentByLocale?.logic?.content?.simple?.limit||4,B=Object.keys(l).filter(V=>V.startsWith("report_id")).map(V=>l[V]),_=Object.keys(l).filter(V=>V.startsWith("dimension_id")).map(V=>l[V]),P=Object.keys(l).filter(V=>V.startsWith("variant_id")).map(V=>l[V]),I=Object.keys(l).filter(V=>V.startsWith("id")).map(V=>l[V]);if(!I.length)return {outputVariables:{related_reports:[]},renderVariables:{},status:{log:[],allowed:false}};let F=await Promise.all(I.map((V,z)=>r({mode:"ids",locale:a,ids:[V],output:"lite",variant:[P[z]]}))).then(V=>V.flatMap(z=>{let q=[];return Lu(z)?z.ok&&(q=z.data.results):q=z.results,q&&Array.isArray(q)?q:[]})).catch(V=>(console.error("Error getting related members",V),[]));if(_.length>1){let V=Object.keys(l).filter(J=>J.startsWith("variant_slug")).map(J=>l[J]),z=F.map((J,G)=>{let K={mode:"related",locale:a,related:A??4,current_ids:[J.content_id],output:"full",variant_ids:[J.variant_id]};return G===0&&(K.include_ids=[J.content_id]),K}),q=await Promise.all(z.map(J=>r(J))).then(J=>J.flatMap(G=>{let K=[];return Lu(G)?G.ok&&(K=G.data.results):K=G.results,K&&Array.isArray(K)?K:[]})).catch(J=>(console.error("Error getting related members",J),[])),W=q.reduce((J,G)=>{let K=G.variant_slug;return J[K]||(J[K]=[]),J[K].push(G),J},{}),U=[],Y=Object.keys(W),ne=[{combination:[],index:0}];for(;ne.length>0;){let J=ne.pop();if(!J)continue;let{combination:G,index:K}=J;if(K===Y.length){U.push(G);continue}let ee=Y[K],ae=W[ee];for(let ue of ae)ne.push({combination:[...G,ue],index:K+1});}return {outputVariables:{related_reports:U.map(J=>{let G=J.sort((K,ee)=>V.indexOf(K.variant_slug)-V.indexOf(ee.variant_slug));return {entities:G,link:"/"+G.map(K=>`${K.variant_slug}/${K.slug}`).join("/")}})},renderVariables:{},status:{log:[],allowed:q.length>0}}}let M=F.map(V=>V.content_id),N={mode:"related",locale:a,related:A??4,current_ids:M,output:"full"};O&&(O==="report"?N.report_ids=B:O==="dimension"?N.dimension_ids=_:N.variant_ids=P);let j=await r(N).then(V=>{let z=[];return Lu(V)?V.ok&&(z=V.data.results):z=V.results,z&&Array.isArray(z)?z:[]}).catch(V=>(console.error("Error getting related members",V),[]));return {outputVariables:{related_reports:j.map(V=>({entities:[V],link:`/${V.variant_slug}/${V.slug}`}))},renderVariables:{},status:{log:[],allowed:j.length>0}}}let{logic:S}=ko(e,a),v=et(S,t,o),C=Fr("resp",u||{},v,t,l,o),{vars:b,error:k,log:w}=C;if(typeof b!="object")return {outputVariables:{},renderVariables:{},status:{error:"Configuration did not return an object",log:w,duration:f,responseSize:g,resp:u,api:m,allowed:c,apiFinalUrls:y,apiDataSources:h}};let R=Object.keys(b).reduce((O,A)=>({...O,[`${e.type}${e.id}${A}`]:b[A]}),{});return {renderVariables:b,outputVariables:[E.GENERATOR,E.SECTION_FLAG].includes(e.type)?b:R,status:{log:w,error:k,duration:f,responseSize:g,resp:u,api:m,allowed:c,apiFinalUrls:y,apiDataSources:h}}}function cS(e,t,o,r,n,i,a){return e.consumers.forEach(l=>{if(t[l]){let s=`${o}-${l}`;!r.includes(s)&&(t[l].section_id===t[o].section_id||!n)&&r.push(s),e.consumers.filter(c=>t[c]&&t[c].section_id===t[o].section_id||!n).forEach(c=>_m(c,t,r,false,i,n,a));}})}var Zn,wO,RO,lS,IO,AO,sS,_m,OO,ei,uS,Nm,bn=D(()=>{p();Cm();Xn();he();Om();Mm();Yv();Jv();Ka();Vr();Ho();eS();Bm();Cr();Jn();Ga();Qn();iS();Zn=Yl(process.env.NEXT_PUBLIC_REPORTS_DEBUG),wO=process.env.REPORTS_ORIGIN||"",RO=process.env.NEXT_PUBLIC_REPORTS_AXIOS_RETRIES,lS=5;try{lS=parseInt(`${RO||5}`,10);}catch(e){console.error("Error setting axios retries NEXT_PUBLIC_REPORTS_AXIOS_RETRIES defaults to 5",e);}aS(Mu,{retries:lS,retryDelay:aS.exponentialDelay,onRetry:(e,t,o)=>{console.error("Generator request failed. Retrying... Count: ",e),console.error("URL: ",o.url),console.error(t.message);}});Mu.interceptors.request.use(e=>({...e,requestStart:Date.now()}));Mu.interceptors.response.use(e=>({...e,requestDuration:new Date().getTime()-e.config.requestStart}),e=>Promise.reject(e));IO=(e,t,o)=>{let r=et(e,t,o);return r.startsWith("http")||(r=`${wO}${r.startsWith("/")?"":"/"}${r}`),r},{urlProxy:AO}=Pl("/api/cms");sS=process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT||0;_m=(e,t,o=[],r=true,n=true,i=true,a=[])=>{if(a.includes(e))return [];a.push(e);let l=t[e];return l&&l.inputs.length&&r&&l.inputs.forEach(s=>{let c=`${s}-${e}`;o.includes(c)||o.push(c),l.inputs.forEach(u=>_m(u,t,o,r,false,i,a));}),l&&l.consumers.length&&n&&cS(l,t,e,o,i,n,a),o},OO=(e,t,o,r)=>{let n=true;if(e&&"allowed"in e.settings&&e.settings.allowed!=="always")if(e.settings.allowed==="never")n=false;else {let i=or(t),{error:a,output:l}=Fr("variables",o,e.settings.allowedLogic||"return false;",r,void 0,i);a||(n=!!l);}return n},ei=async(e,t,o,r,n,i={},a,l="section",s,c)=>{let u=l==="section",d=or(n),f=d.variables,g={...i.variables??{}},m={...i.status??{}},h=new Set,y=[],S={};o?S={...S,[o]:e[o]}:t?S=(t??[]).reduce((M,{id:N})=>({...M,...Zv(N,e)}),{}):S=Object.values(e).filter(M=>mo(M)).reduce((M,N)=>({...M,[N.id]:N}),{});let v=Object.values(S).filter(M=>mo(M));if(v.length>0){Zn&&console.info("%crunConsumers: calculating section flags","color:purple",v.map($=>$.id).join(", "));let M=Object.fromEntries(await Promise.all(v.map(async $=>[$.id,await Ll($,r,{...d,variables:f,locale:f.locale},a,s,c).then(V=>{let{outputVariables:z,status:q}=V;if(q.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${$.id}, Section ${$.section_id}) failed with message: ${q.error}. `);m[$.id]={allowed:false,error:q.error},g[$.id]={};}return ($.consumers.length>0||[E.GENERATOR,E.SECTION_FLAG,E.RELATED].includes($.type))&&q.allowed&&Object.keys(z).length>0?g[$.id]=z:g[$.id]={},l==="report"?(m[$.id]={allowed:q.allowed},[E.GENERATOR,E.SECTION_FLAG].includes($.type)&&q.api&&(m[$.id].api=q.api)):m[$.id]=q,V})]))),j=Object.entries(M).filter(([,$])=>!$.outputVariables[Eo]).map(([$])=>Number($));h=new Set(j.map($=>e[$].section_id)),Object.values(S).filter($=>h.has($.section_id)).forEach($=>{y.push($.id),delete S[$.id];}),Zn&&console.info("%crunConsumers: removing sections","color:purple",h.keys());}let C=h.size>0?Object.fromEntries(Object.entries(e).filter(([,M])=>h?.has(M.section_id)?(y.includes(M.id)||y.push(M.id),false):true)):e;if(y.length>0&&(C=Object.fromEntries(Object.entries(C).map(([M,N])=>{let j={...N,inputs:N.inputs.filter($=>!y.includes($)),consumers:N.consumers.filter($=>!y.includes($))};return [M,j]}))),!o&&!t)return {variables:{...i.variables??{},...g},status:{...i.status??{},...m}};l==="report"&&y.length>0&&y.forEach(M=>{delete g[M],delete m[M],delete e[M];}),Zn&&console.info("%crunConsumers: running root blocks","color:purple",Object.keys(S));let b=Object.keys(S).reduce((M,N)=>{let j=new Date,$=_m(Number(N),C,[],!o,true,u).map(q=>q.split("-")),z=(new Date().getTime()-j.getTime())/1e3;return Zn&&console.info(`%cResolved dependencies for ${N} (${z.toFixed(2)}s)`,"color:blue"),[...M,...$]},[]),k=new Date,w=Object.keys(S).reduce((M,N)=>M.includes(N)?[...M]:[N,...M],CO(b)),O=(new Date().getTime()-k.getTime())/1e3;Zn&&console.info(`%cResolved DAG (${O.toFixed(2)}s): `,"color:green",w);let A=process.env.NEXT_PUBLIC_REPORTS_MAX_CONCURRENT_QUERIES_PER_REPORT,B=parseInt(`${A||0}`,10);async function _(M,N){let j=new Map,$=[],V=async()=>$.length;for(let z of M){if(B!==0){let Y=await V();for(;Y>=B;)Zn&&console.info("Too many pending promises, waiting...",Y,$),await new Promise(ne=>setTimeout(ne,500)),Y=await V();}let q=N[z],U=Promise.all(q.inputs.filter(Y=>M.includes(String(Y))).map(Y=>j.get(Number(Y)))).then(async()=>{let Y=q.inputs.reduce((ae,ue)=>({...ae,...g[ue]}),f),ne=q.inputs.find(ae=>(q.settings?.ignoreCascade?q.settings?.ignoreCascade:[]).includes(ae)||!m[ae]?false:!m[ae].allowed||m[ae].hiddenByCascade);if(ne){m[z]={allowed:false,hiddenByCascade:m[ne].hiddenByCascade||ne},g[z]={},$.splice($.indexOf(Number(z)),1);return}let re=new Date,J;typeof window<"u"&&[E.SELECTOR,E.MULTIHIERARCHY_SELECTOR].includes(q.type)&&q.settings[_t.DISABLED]?J=new Promise(ae=>{ae({outputVariables:g[z],status:m[z]});}):J=Ll(q,r,{...d,variables:Y,locale:Y.locale},a,s,c);let G=await J.then(({outputVariables:ae,status:ue})=>{if(ue.error){if(typeof window>"u")throw new Error(`Run consumers (Block: ${z}, Section ${q.section_id}) failed with message: ${ue.error}.`);m[z]={allowed:false,error:ue.error},g[z]={};}(q.consumers.length>0||[E.GENERATOR,E.SECTION_FLAG,E.RELATED].includes(q.type))&&ue.allowed&&Object.keys(ae).length>0?g[z]=ae:g[z]={},l==="report"?(m[z]={allowed:ue.allowed},[E.GENERATOR,E.SECTION_FLAG].includes(q.type)&&ue.api&&(m[z].api=ue.api)):m[z]=ue;}),ee=(new Date().getTime()-re.getTime())/1e3;return Zn&&console.info(`%cBlock ${q.id} resolved in ${ee.toFixed(3)}s`,ee>500?"color:red":"color:green"),m[z].duration=m[z].duration?m[z].duration:ee,$.splice($.indexOf(Number(z)),1),G}).catch(Y=>{throw $.splice($.indexOf(Number(z)),1),Y});$.push(Number(z)),j.set(Number(z),U);}await Promise.all(Array.from(j.values()));}let P=new Date;await _(w,C);let F=(new Date().getTime()-P.getTime())/1e3;return Zn&&console.info(`%cResolved Variables (${F.toFixed(2)}s), ${w.length} blocks`,"color:green"),{variables:{...i.variables??{},...g},status:{...i.status??{},...m}}},uS=e=>e<250?"green":e<1e3?"yellow":"red",Nm=e=>e<10?"green":e<100?"yellow":"red";});function LO(e=[]){return e.reduce((t,o,r)=>{if(o){let n=r+1;t[`id${n}`]=o.id,t[`name${n}`]=o.name,t[`slug${n}`]=o.slug,"attributes"in o&&Object.keys(o.attributes).forEach(i=>{t[`attr_${i}${n}`]=o.attributes[i];}),t[`variant_id${n}`]=o.variant_id,t[`variant_name${n}`]=o.variant_name,t[`variant_slug${n}`]=o.variant_slug,t[`dimension_id${n}`]=o.dimension_id,t[`dimension_name${n}`]=o.dimension_name,t.report_id=o.report_id,t.report_name=o.report_name;}return t},{})}var pS,dS=D(()=>{p();pS=LO;});var kr,Bu,Ml=D(()=>{p();kr=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",Bu=process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",")||[kr];Bu.includes(kr)||Bu.push(kr);});var DO,Du,Ro,qa=D(()=>{p();Ml();DO={localeDefault:kr,locales:Bu,currentLocale:kr,preferredLocale:kr,showToolbar:false,activeSection:null,previews:[],query:{},sectionState:{},activeEntity:{type:null,id:null},sidebarStatus:{tools:true,settings:false,reportEditor:false},isCMS:false,isRunConsumersRunning:[]},Du=createSlice({name:"status",initialState:DO,reducers:{setStatus:(e,t)=>{Object.assign(e,t.payload);},setPreviews(e,t){e.previews=t.payload;},setCurrentLocale(e,t){e.currentLocale=t.payload;},setPreferredLocale(e,t){e.preferredLocale=t.payload;},setSectionState(e,t){e.sectionState={...e.sectionState,...t.payload};},resetSectionState(e,t){e.sectionState={...e.sectionState,[t.payload]:{}};},setActiveEntity(e,t){e.activeEntity=t.payload;},openSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:true};},closeSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:false};},toggleSidebar(e,t){e.sidebarStatus={...e.sidebarStatus,[t.payload]:!e.sidebarStatus[t.payload]};},addRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.concat(t.payload);},removeRunConsumersRunning(e,t){e.isRunConsumersRunning=e.isRunConsumersRunning.filter(o=>!t.payload.includes(o));}},extraReducers:{[HYDRATE]:(e,t)=>({...e,previews:t.payload.status.previews})}}),Ro=Du.actions;});var zO,_u,Vi,Ya=D(()=>{p();zO={attributes:{},variables:{},status:{}},_u=createSlice({name:"variables",initialState:zO,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}})}}),Vi=_u.actions;});function Bl(e,t){return Object.fromEntries(Object.keys(e).map(o=>[o,{...e[o],...t[o]}]))}function Nu(e,t){return e.map(n=>t[n]).sort((n,i)=>typeof n.ordering=="string"&&typeof i.ordering=="string"?po(n,i):typeof n.ordering=="number"&&typeof i.ordering=="number"?n.ordering-i.ordering:String(n.ordering).localeCompare(String(i.ordering))).map(n=>n.id)}function UO(e,t){let o=e.indexOf(t);o>-1&&e.splice(o,1);}var $O,yn,Dl=D(()=>{p();Go();qn();$O={tree:[],reports:null,entities:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}}},yn=createSlice({name:"records",initialState:$O,reducers:{set:(e,t)=>{let o=t.payload;return {entities:Bl(e.entities,o.entities||{}),requests:Bl(e.requests,o.requests||{}),reports:o.reports||e.reports,tree:o.tree||e.tree}},setRequest:(e,t)=>{let o=t.payload;e.requests[o.type][o.key]=o;},setCreateRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let r=Array.isArray(o.data)?o.data:[o.data],n=xu(o.type,r),i=Bl(e.entities,n);if(e.entities=i,o.type==="report"){let a=o.data;e.reports?e.reports.indexOf(a.id)===-1&&(e.reports=[...e.reports,a.id]):e.reports=[a.id];}else if(o.type==="dimension"){let a=o.data;e.entities.report[a.report_id].dimensions.push(a.id),e.entities.report[a.report_id].dimensions=Nu(i.report[a.report_id].dimensions,i.dimension);}else if(o.type==="variant"){let a=o.data;e.entities.dimension[a.dimension_id].variants.push(a.id);}else if(o.type==="section"&&!Array.isArray(o.data)){let a=o.data;e.entities.report[a.report_id].sections.push(a.id),e.entities.report[a.report_id].sections=Nu(i.report[a.report_id].sections,i.section);}else if(o.type==="block")if(Array.isArray(o.data)){let a=o.data,l=a[0],s=a.map(c=>c.id);e.entities.section[l.section_id].blocks.concat(s);}else {let a=o.data;e.entities.section[a.section_id].blocks.push(a.id);}}},setReadRequest(e,t){let o=t.payload;if(o.type!=="report"&&(e.requests[o.type][o.key]=o),o.status==="SUCCESS"){let r=xu(o.type,o.data),n=Bl(e.entities,r);e.entities=n;}},setUpdateRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let r=Array.isArray(o.data)?o.data:[o.data],n=xu(o.type,r),i,a,l;if(o.type==="block"&&!Array.isArray(o.data)){let c=e.entities.block[o.data.id].inputs,u=n.block[o.data.id].inputs;i=c.length!==u.length,i&&(l=c.length>u.length,a=l?c.filter(d=>!u.includes(d))[0]:u.filter(d=>!c.includes(d))[0]),Object.values(n.block).forEach(d=>{d.block_input&&delete n.block[d.id];});}let s=Bl(e.entities,n);if(e.entities=s,o.type==="dimension"){let c=o.data;e.entities.report[c.report_id].dimensions=Nu(s.report[c.report_id].dimensions,s.dimension);}else if(o.type==="section"&&!Array.isArray(o.data)){let c=o.data;e.entities.report[c.report_id].sections=Nu(s.report[c.report_id].sections,s.section);}else if(o.type==="block"&&!Array.isArray(o.data)){let c=o.data;i&&(l?e.entities.block[a].consumers=e.entities.block[a].consumers.filter(u=>u!==c.id):e.entities.block[a].consumers.push(c.id));}}},setDeleteRequest(e,t){let o=t.payload;if(e.requests[o.type][o.key]=o,o.status==="SUCCESS"){let{id:r,parentId:n,parentType:i}=o.data;if(delete e.entities[o.type][r],i&&n!=null){let a=`${o.type}s`;UO(e.entities[i][n][a],r);}}},removeBlocks:(e,t)=>{let o=t.payload,r={...e.entities.block};return o.forEach(n=>{delete r[n];}),{...e,entities:{...e.entities,block:r}}},addBlocks:(e,t)=>{let o=t.payload;return {...e,entities:{...e.entities,block:{...e.entities.block,...o}}}},removeDataSourceLogic:e=>{let t={...e.entities.datasource};Object.keys(t).forEach(o=>{e.entities.datasource[o].content.useProxy&&(delete e.entities.datasource[o].content.logic,delete e.entities.datasource[o].content.logic_ssr,delete e.entities.datasource[o].content.testUrl,delete e.entities.datasource[o].content.access);});}},extraReducers:{[HYDRATE]:(e,t)=>{let o=t.payload.records,r=o.entities;return {entities:r,reports:Object.values(r.report).map(n=>n.id),requests:{block:{},dimension:{},report:{},section:{},variant:{},formatter:{},datasource:{}},tree:o.tree}}}});});function GO(e){return {ok:false,status:$i.is(e)?e.code:500,error:e.message}}function Ui(e,t,o){if(t==="createBulk"||t==="updateBulk"){let n=`${t}${mS(o)}`;return e[n]}let r=`${t}${mS(o)}`;return e[r]}function mS(e){return e[0].toUpperCase()+e.slice(1)}var $i,zu=D(()=>{p();$i=class extends Error{constructor(t,o){super(o),this.code=t;}toJSON(){return GO(this)}static is(t){return Object.prototype.hasOwnProperty.call(t,"code")&&typeof t.code=="number"}};});function Nt(e){for(var t=arguments.length,o=Array(t>1?t-1:0),r=1;r<t;r++)o[r-1]=arguments[r];if(process.env.NODE_ENV!=="production"){var n=JO[e],i=n?typeof n=="function"?n.apply(null,o):n:"unknown error nr: "+e;throw Error("[Immer] "+i)}throw Error("[Immer] minified error nr: "+e+(o.length?" "+o.map((function(a){return "'"+a+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Xa(e){return !!e&&!!e[Wo]}function Hi(e){var t;return !!e&&((function(o){if(!o||typeof o!="object")return false;var r=Object.getPrototypeOf(o);if(r===null)return true;var n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===QO})(e)||Array.isArray(e)||!!e[xS]||!!(!((t=e.constructor)===null||t===void 0)&&t[xS])||Km(e)||qm(e))}function Nl(e,t,o){o===void 0&&(o=false),Qa(e)===0?(o?Object.keys:Zm)(e).forEach((function(r){o&&typeof r=="symbol"||t(r,e[r],e);})):e.forEach((function(r,n){return t(n,r,e)}));}function Qa(e){var t=e[Wo];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:Km(e)?2:qm(e)?3:0}function Um(e,t){return Qa(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function HO(e,t){return Qa(e)===2?e.get(t):e[t]}function TS(e,t,o){var r=Qa(e);r===2?e.set(t,o):r===3?e.add(o):e[t]=o;}function WO(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function Km(e){return YO&&e instanceof Map}function qm(e){return XO&&e instanceof Set}function Gi(e){return e.o||e.t}function Ym(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=ZO(e);delete t[Wo];for(var o=Zm(t),r=0;r<o.length;r++){var n=o[r],i=t[n];i.writable===false&&(i.writable=true,i.configurable=true),(i.get||i.set)&&(t[n]={configurable:true,writable:true,enumerable:i.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function Xm(e,t){return t===void 0&&(t=false),Jm(e)||Xa(e)||!Hi(e)||(Qa(e)>1&&(e.set=e.add=e.clear=e.delete=jO),Object.freeze(e),t&&Nl(e,(function(o,r){return Xm(r,true)}),true)),e}function jO(){Nt(2);}function Jm(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function $r(e){var t=eL[e];return t||Nt(18,e),t}function fS(){return process.env.NODE_ENV==="production"||Ja||Nt(0),Ja}function zm(e,t){t&&($r("Patches"),e.u=[],e.s=[],e.v=t);}function Fu(e){Gm(e),e.p.forEach(KO),e.p=null;}function Gm(e){e===Ja&&(Ja=e.l);}function gS(e){return Ja={p:[],l:Ja,h:e,m:true,_:0}}function KO(e){var t=e[Wo];t.i===0||t.i===1?t.j():t.g=true;}function Fm(e,t){t._=t.p.length;var o=t.p[0],r=e!==void 0&&e!==o;return t.h.O||$r("ES5").S(t,e,r),r?(o[Wo].P&&(Fu(t),Nt(4)),Hi(e)&&(e=Vu(t,e),t.l||$u(t,e)),t.u&&$r("Patches").M(o[Wo].t,e,t.u,t.s)):e=Vu(t,o,[]),Fu(t),t.u&&t.v(t.u,t.s),e!==CS?e:void 0}function Vu(e,t,o){if(Jm(t))return t;var r=t[Wo];if(!r)return Nl(t,(function(l,s){return hS(e,r,t,l,s,o)}),true),t;if(r.A!==e)return t;if(!r.P)return $u(e,r.t,true),r.t;if(!r.I){r.I=true,r.A._--;var n=r.i===4||r.i===5?r.o=Ym(r.k):r.o,i=n,a=false;r.i===3&&(i=new Set(n),n.clear(),a=true),Nl(i,(function(l,s){return hS(e,r,n,l,s,o,a)})),$u(e,n,false),o&&e.u&&$r("Patches").N(r,o,e.u,e.s);}return r.o}function hS(e,t,o,r,n,i,a){if(process.env.NODE_ENV!=="production"&&n===o&&Nt(5),Xa(n)){var l=Vu(e,n,i&&t&&t.i!==3&&!Um(t.R,r)?i.concat(r):void 0);if(TS(o,r,l),!Xa(l))return;e.m=false;}else a&&o.add(n);if(Hi(n)&&!Jm(n)){if(!e.h.D&&e._<1)return;Vu(e,n),t&&t.A.l||$u(e,n);}}function $u(e,t,o){o===void 0&&(o=false),!e.l&&e.h.D&&e.m&&Xm(t,o);}function Vm(e,t){var o=e[Wo];return (o?Gi(o):e)[t]}function bS(e,t){if(t in e)for(var o=Object.getPrototypeOf(e);o;){var r=Object.getOwnPropertyDescriptor(o,t);if(r)return r;o=Object.getPrototypeOf(o);}}function Hm(e){e.P||(e.P=true,e.l&&Hm(e.l));}function $m(e){e.o||(e.o=Ym(e.t));}function Wm(e,t,o){var r=Km(t)?$r("MapSet").F(t,o):qm(t)?$r("MapSet").T(t,o):e.O?(function(n,i){var a=Array.isArray(n),l={i:a?1:0,A:i?i.A:fS(),P:false,I:false,R:{},l:i,t:n,k:null,o:null,j:null,C:false},s=l,c=jm;a&&(s=[l],c=_l);var u=Proxy.revocable(s,c),d=u.revoke,f=u.proxy;return l.k=f,l.j=d,f})(t,o):$r("ES5").J(t,o);return (o?o.A:fS()).p.push(r),r}function qO(e){return Xa(e)||Nt(22,e),(function t(o){if(!Hi(o))return o;var r,n=o[Wo],i=Qa(o);if(n){if(!n.P&&(n.i<4||!$r("ES5").K(n)))return n.t;n.I=true,r=yS(o,i),n.I=false;}else r=yS(o,i);return Nl(r,(function(a,l){n&&HO(n.t,a)===l||TS(r,a,t(l));})),i===3?new Set(r):r})(e)}function yS(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return Ym(e)}var vS,Ja,Qm,YO,XO,SS,CS,xS,Wo,JO,QO,Zm,ZO,eL,jm,_l,tL,jo,oL,Uu,kS=D(()=>{p();Qm=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",YO=typeof Map<"u",XO=typeof Set<"u",SS=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",CS=Qm?Symbol.for("immer-nothing"):((vS={})["immer-nothing"]=true,vS),xS=Qm?Symbol.for("immer-draftable"):"__$immer_draftable",Wo=Qm?Symbol.for("immer-state"):"__$immer_state",JO={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"},QO=""+Object.prototype.constructor,Zm=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,ZO=Object.getOwnPropertyDescriptors||function(e){var t={};return Zm(e).forEach((function(o){t[o]=Object.getOwnPropertyDescriptor(e,o);})),t},eL={},jm={get:function(e,t){if(t===Wo)return e;var o=Gi(e);if(!Um(o,t))return (function(n,i,a){var l,s=bS(i,a);return s?"value"in s?s.value:(l=s.get)===null||l===void 0?void 0:l.call(n.k):void 0})(e,o,t);var r=o[t];return e.I||!Hi(r)?r:r===Vm(e.t,t)?($m(e),e.o[t]=Wm(e.A.h,r,e)):r},has:function(e,t){return t in Gi(e)},ownKeys:function(e){return Reflect.ownKeys(Gi(e))},set:function(e,t,o){var r=bS(Gi(e),t);if(r?.set)return r.set.call(e.k,o),true;if(!e.P){var n=Vm(Gi(e),t),i=n?.[Wo];if(i&&i.t===o)return e.o[t]=o,e.R[t]=false,true;if(WO(o,n)&&(o!==void 0||Um(e.t,t)))return true;$m(e),Hm(e);}return e.o[t]===o&&(o!==void 0||t in e.o)||Number.isNaN(o)&&Number.isNaN(e.o[t])||(e.o[t]=o,e.R[t]=true),true},deleteProperty:function(e,t){return Vm(e.t,t)!==void 0||t in e.t?(e.R[t]=false,$m(e),Hm(e)):delete e.R[t],e.o&&delete e.o[t],true},getOwnPropertyDescriptor:function(e,t){var o=Gi(e),r=Reflect.getOwnPropertyDescriptor(o,t);return r&&{writable:true,configurable:e.i!==1||t!=="length",enumerable:r.enumerable,value:o[t]}},defineProperty:function(){Nt(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Nt(12);}},_l={};Nl(jm,(function(e,t){_l[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};})),_l.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Nt(13),_l.set.call(this,e,t,void 0)},_l.set=function(e,t,o){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Nt(14),jm.set.call(this,e[0],t,o,e[0])};tL=(function(){function e(o){var r=this;this.O=SS,this.D=true,this.produce=function(n,i,a){if(typeof n=="function"&&typeof i!="function"){var l=i;i=n;var s=r;return function(h){var y=this;h===void 0&&(h=l);for(var S=arguments.length,v=Array(S>1?S-1:0),C=1;C<S;C++)v[C-1]=arguments[C];return s.produce(h,(function(b){var k;return (k=i).call.apply(k,[y,b].concat(v))}))}}var c;if(typeof i!="function"&&Nt(6),a!==void 0&&typeof a!="function"&&Nt(7),Hi(n)){var u=gS(r),d=Wm(r,n,void 0),f=true;try{c=i(d),f=!1;}finally{f?Fu(u):Gm(u);}return typeof Promise<"u"&&c instanceof Promise?c.then((function(h){return zm(u,a),Fm(h,u)}),(function(h){throw Fu(u),h})):(zm(u,a),Fm(c,u))}if(!n||typeof n!="object"){if((c=i(n))===void 0&&(c=n),c===CS&&(c=void 0),r.D&&Xm(c,true),a){var g=[],m=[];$r("Patches").M(n,c,g,m),a(g,m);}return c}Nt(21,n);},this.produceWithPatches=function(n,i){if(typeof n=="function")return function(c){for(var u=arguments.length,d=Array(u>1?u-1:0),f=1;f<u;f++)d[f-1]=arguments[f];return r.produceWithPatches(c,(function(g){return n.apply(void 0,[g].concat(d))}))};var a,l,s=r.produce(n,i,(function(c,u){a=c,l=u;}));return typeof Promise<"u"&&s instanceof Promise?s.then((function(c){return [c,a,l]})):[s,a,l]},typeof o?.useProxies=="boolean"&&this.setUseProxies(o.useProxies),typeof o?.autoFreeze=="boolean"&&this.setAutoFreeze(o.autoFreeze);}var t=e.prototype;return t.createDraft=function(o){Hi(o)||Nt(8),Xa(o)&&(o=qO(o));var r=gS(this),n=Wm(this,o,void 0);return n[Wo].C=true,Gm(r),n},t.finishDraft=function(o,r){var n=o&&o[Wo];process.env.NODE_ENV!=="production"&&(n&&n.C||Nt(9),n.I&&Nt(10));var i=n.A;return zm(i,r),Fm(void 0,i)},t.setAutoFreeze=function(o){this.D=o;},t.setUseProxies=function(o){o&&!SS&&Nt(20),this.O=o;},t.applyPatches=function(o,r){var n;for(n=r.length-1;n>=0;n--){var i=r[n];if(i.path.length===0&&i.op==="replace"){o=i.value;break}}n>-1&&(r=r.slice(n+1));var a=$r("Patches").$;return Xa(o)?a(o,r):this.produce(o,(function(l){return a(l,r)}))},e})(),jo=new tL,oL=jo.produce,jo.produceWithPatches.bind(jo),jo.setAutoFreeze.bind(jo),jo.setUseProxies.bind(jo),jo.applyPatches.bind(jo),jo.createDraft.bind(jo),jo.finishDraft.bind(jo),Uu=oL;});function Fl(e){return (t,o)=>{let r=e[t];if(!r)throw new Error(`Attempting to dispatch action for invalid entity type '${t}'`);return r(o)}}function Ki(e,t){return (o,r)=>{let i=r().records.requests[e][t],a=!i||i.status==="UNINITIALIZED"?"LOADING":"FETCHING";o(Er.setRequest({key:t,type:e,status:a}));}}function ji(e,t,o,r){return n=>{typeof window=="object"&&notifications.show({autoClose:3e3,color:"red",id:t,message:r,title:"Error"}),n(Er.setRequest({key:t,type:e,status:"FAILURE",error:{code:o,message:r}}));}}function ti(e){return t=>{let o=ef(e,t);return (r,n,i)=>(r(Ki(e,o)),Ui(i,"create",e)(t).then(l=>(l.ok===true?r(Er.setCreateRequest({key:o,operation:"create",status:"SUCCESS",type:e,data:l.data})):r(ji(e,o,l.status,l.error)),l)))}}function iL(e){return t=>{let o=ef(e,t[0]);return (r,n,i)=>(r(Ki(e,o)),Ui(i,"createBulk",e)(t).then(l=>(l.ok===true?r(Er.setCreateRequest({key:o,operation:"createBulk",status:"SUCCESS",type:e,data:l.data})):r(ji(e,o,l.status,l.error)),l)))}}function ES(e,t,o){return o.replace(new RegExp(e,"g"),t)}function aL(e){return e.section_id!==void 0}function sL(e){return e.report_id!==void 0}function wS(e){return t=>{let{create:o}=t;return (r,n,i)=>ti(e)(o)(r,n,i).then(async l=>{if(l.ok){let{data:s}=l,{id:c}=s,{update:u}=t,d=BS(e,{id:c});if(r(Ki(e,`${d}`)),e==="block"&&aL(o)){let f=Uu(u,y=>{y.id=c;}),{contentByLocale:g}=f;g&&(f=Uu(f,y=>{y.id=c,y.contentByLocale=Object.keys(g).reduce((S,v)=>{let C=g?g[v]:{};return S[v]={...C,id:c},S},{});}));let h=f.inputs?.map(y=>({type:y.type,id:y.id,inputAction:{operation:"create",input:{input_id:y.id,block_id:f.id}}}));return h&&h.length>0&&RS(e)([f,...h])(r,n,i).then(()=>oi("section")({id:f.section_id,include:true})(r,n,i).then(y=>(y.ok&&r(Er.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))),Ur(e)(f)(r,n,i).then(y=>(y.ok&&r(Er.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}if(e==="section"&&sL(o)){let{id:f}=s,g=Uu(u,y=>{y.id=f;}),{blocks:m}=g,h=m?.map(y=>({type:y.type,blockcol:y.blockcol,blockrow:y.blockrow,section_id:f,locales:Object.keys(y.contentByLocale).map(S=>S)}));return h&&m&&await iL("block")(h)(r,n,i).then(y=>{if(y.ok){let S=y.data,v=[],C=S.map((b,k)=>{let R={...b},O=R.id,A=m[k];A.contentByLocale&&(R.contentByLocale=Object.keys(A.contentByLocale).reduce((j,$)=>{let V=A.contentByLocale[$];return j[$]={...V,content:{...V.content},id:R.id},j},{}));let{settings:B}=A,{contentByLocale:_,id:P}=R;R.settings=B;let I={id:P,contentByLocale:_,settings:B};return A.inputs.map(j=>j.id).reduce((j,$)=>{let V=m.findIndex(z=>z.id===$);return [...j,V]},[]).map(j=>({...S[j],originalBlock:m[j]})).forEach(j=>{let{id:$,type:V,originalBlock:z}=j;if([E.SELECTOR,E.VIZ].includes(V)){if(I.contentByLocale?.logic?.content?.api){let q=I.contentByLocale?.logic.content.api;I.contentByLocale.logic.content.api=ES(`(selector${z.id}id)`,`selector${$}id`,q);}if(I.contentByLocale?.logic?.content?.logic){let q=I.contentByLocale.logic.content.logic;I.contentByLocale.logic.content.logic=ES(`(selector${z.id}id)`,`selector${$}id`,q);}}v.push({id:$,inputAction:{operation:"create",input:{input_id:$,block_id:O}}});}),I});return RS("block")([...C,...v])(r,n,i)}}),Ur(e)(g)(r,n,i).then(y=>(y.ok&&r(Er.setRequest({key:d,type:e,status:"SUCCESS",data:y.data})),y))}return Ur(e)({...u,id:s.id})(r,n,i)}})}}function oi(e){return t=>{let o=LS(e,t);return (r,n,i)=>{r(Ki(e,o));let a=Ui(i,"read",e);if(typeof a!="function"){let l=`Failed to get valid RPC method for entity "${e}"`;return r(ji(e,o,500,l)),Promise.reject(new Error(l))}return a(t).then(l=>(l.ok===true?r(Er.setReadRequest({key:o,operation:"read",status:"SUCCESS",type:e,data:l.data})):r(ji(e,o,l.status,l.error)),l))}}}function Ur(e){return t=>{let o=tf(e,t);return (r,n,i)=>(r(Ki(e,o)),Ui(i,"update",e)(t).then(l=>(l.ok===true?r(Er.setUpdateRequest({key:o,operation:"update",status:"SUCCESS",type:e,data:l.data})):r(ji(e,o,l.status,l.error)),l)))}}function RS(e){return t=>{let o=tf(e,t[0]);return (r,n,i)=>(r(Ki(e,o)),Ui(i,"updateBulk",e)(t).then(l=>(l.ok===true?r(Er.setUpdateRequest({key:o,operation:"updateBulk",status:"SUCCESS",type:e,data:l.data})):r(ji(e,o,l.status,l.error)),l)))}}function Wi(e){return t=>{let o=MS(e,t);return (r,n,i)=>(r(Ki(e,o)),Ui(i,"delete",e)(t).then(l=>{l.ok===true?r(Er.setDeleteRequest({key:o,operation:"delete",status:"SUCCESS",type:e,data:l.data})):r(ji(e,o,l.status,l.error));}))}}function ef(e,t){if(e==="variant"){let o=t;return `create(variant, [${o.dimension_id}, ${o.name}])`}return `create(${e}, [${Object.keys(t)}])`}function LS(e,t={}){let o=t.id==null?null:`'${t.id}'`;return `read(${e}, ${o}, ${!!t.include})`}function tf(e,t){let{id:o,...r}=t;return `update(${e}, ${o}, [${Object.keys(r)}])`}function MS(e,t){return `delete(${e}, ${t})`}function BS(e,t){let o=t.id==null?null:`'${t.id}'`;return `clone(${e}, ${o})`}var Er,Gu,IS,zl,AS,PS,OS,of=D(()=>{p();zu();Dl();kS();he();Er=yn.actions,Gu={create:ef,read:LS,update:tf,delete:MS,clone:BS},IS=Fl({block:ti("block"),dimension:ti("dimension"),formatter:ti("formatter"),report:ti("report"),section:ti("section"),variant:ti("variant"),datasource:ti("datasource")}),zl=Fl({block:oi("block"),dimension:oi("dimension"),formatter:oi("formatter"),report:oi("report"),section:oi("section"),variant:oi("variant"),datasource:oi("datasource")}),AS=Fl({block:Ur("block"),dimension:Ur("dimension"),formatter:Ur("formatter"),report:Ur("report"),section:Ur("section"),variant:Ur("variant"),datasource:Ur("datasource")}),PS=Fl({block:Wi("block"),dimension:Wi("dimension"),formatter:Wi("formatter"),report:Wi("report"),section:Wi("section"),variant:Wi("variant"),datasource:Wi("datasource")}),OS=Fl({block:wS("block"),section:wS("section")});});var Z={};ym(Z,{addBlockToState:()=>CL,addRunConsumersRunning:()=>af,cloneEntity:()=>OS,createEntity:()=>IS,deleteEntity:()=>PS,deleteQueryParam:()=>lf,readEntity:()=>zl,readEnvSecrets:()=>RL,readMember:()=>_S,readMetadata:()=>gL,readPrivateBlocks:()=>kL,readUser:()=>vL,recalculateVariables:()=>Hu,removeBlocksFromState:()=>TL,removeDataSourceLogic:()=>IL,removeRunConsumersRunning:()=>sf,reportSearch:()=>dL,resetSectionState:()=>nf,revalidateReport:()=>wL,revalidateUrl:()=>EL,searchMember:()=>fL,searchRegenerate:()=>mL,searchRole:()=>bL,searchUser:()=>yL,setCurrentLocale:()=>cL,setPreferredLocale:()=>uL,setPreviews:()=>lL,setQueryParam:()=>qi,setSectionState:()=>rf,setStatus:()=>DS,updateEntity:()=>AS,updateMyData:()=>xL,updateUser:()=>SL,urlProxy:()=>hL,variantValidateSlug:()=>pL});function pL(e,t){return async(o,r,n)=>{let i=await n.validateVariantSlug({dimension:e,slug:t});if("error"in i)throw new Error(i.error);return i.data}}function dL(e){return async(t,o,r)=>{let n=await r.searchReport(e);if("error"in n)throw new Error(n.error);return n.data}}function mL(){return async(e,t,o)=>{let r=await o.regenerateSearch(void 0);if("error"in r)throw new Error(r.error);return r.data}}function _S(e){return async(t,o,r)=>{let n=await r.readMember(e);if("error"in n)throw new Error(n.error);return n.data}}function fL(e){return async(t,o,r)=>{let n=await r.searchMember(e);if(n.ok===true)return n.data;throw new Error(n.error)}}async function NS(e,t,o,r,n){let i=o().status,a={...i,...r},l={...i.query,...r.query};Object.keys(l).forEach(c=>l[c]===void 0&&delete l[c]);let s={...a,query:l};t(DS(s)),i.activeSection&&t(Hu(e,{query:l},n));}function lf(e,t,o){return async(r,n)=>NS(e,r,n,{query:{[t]:void 0}},o)}function qi(e,t,o,r){return async(n,i)=>NS(e,n,i,{query:{[t]:o}},r)}function Hu(e,t,o){return async(r,n)=>{let i=n(),{currentLocale:a}=i.status,l=i.records.entities.block,s=e.formatterFunctions[a],c=e.datasourceFunctions,{parsedParams:u,statusPayload:d}=Ev(i.status,t),{sid:f,bid:g,previews:m,query:h}=u;Object.keys(d).length&&r(Ro.setStatus(d));let y={...pS(m),locale:a,...wo()},S={variables:y,query:h,locale:a};r(Ro.addRunConsumersRunning([f]));let v=i.records.entities.section[f],C=async b=>r(_S(b));try{let b=await ei(l,v&&[v],g,s,S,void 0,C,"section",c,o),{variables:k,status:w}=b;r(Vi.setVariableChange({attributes:y,variables:k,status:w})),r(Ro.removeRunConsumersRunning([f]));}catch(b){console.error("Error in runConsumers client side: recalculateVariables",b);}}}function gL(e){return async(t,o,r)=>{let n=await r.readMetadata(e);if("error"in n)throw new Error(n.error);return n.data}}function hL(e){return async(t,o,r)=>{let n=await r.urlProxy(e);if("error"in n)throw new Error(n.error);return n.data}}function bL(){return async(e,t,o)=>{let r=await o.searchRole("");if("error"in r)throw new Error(r.error);return r.data}}function yL(e){return async(t,o,r)=>{let n=await r.searchUser(e);if("error"in n)throw new Error(n.error);return n.data}}function vL(e){return async(t,o,r)=>{let n=await r.readUser({user_id:e});if("error"in n)throw new Error(n.error);return n.data}}function SL({user:e}){return async(t,o,r)=>{let n=await r.updateUser(e);if("error"in n)throw new Error(n.error);return n.data}}function xL(e){return async(t,o,r)=>{let n=await r.updateMyData(e);if("error"in n)throw new Error(n.error);return n.data}}function TL(e){let{removeBlocks:t}=yn.actions;return async o=>{await o(t(e));}}function CL(e){let{addBlocks:t}=yn.actions;return async o=>{await o(t(e));}}function kL(e){return async(t,o,r)=>{let n=await r.readPrivateBlocks({...e,roles:[]});if("error"in n)throw new Error(n.error);return n.data}}function EL(e){return async(t,o,r)=>{let n=await r.revalidateUrl({target:e.target});if("error"in n)throw new Error(n.error);return n.data}}function wL(e){return async(t,o,r)=>{let n=await r.revalidateReport({reportId:e.reportId,profilePrefix:e.profilePrefix});if("error"in n)throw new Error(n.error);return n.data}}function RL(){return async(e,t,o)=>{let r=await o.readEnvSecrets({});if("error"in r)throw new Error(r.error);return r.data}}function IL(){let{removeDataSourceLogic:e}=yn.actions;return async t=>{await t(e());}}var DS,lL,rf,nf,cL,uL,af,sf,Vl=D(()=>{p();bn();dS();Qn();qn();qa();Ya();Dl();of();({setStatus:DS,setPreviews:lL,setSectionState:rf,resetSectionState:nf,setCurrentLocale:cL,setPreferredLocale:uL,addRunConsumersRunning:af,removeRunConsumersRunning:sf}=Ro);});function PL(e={required:false}){let{update:t,data:o,status:r}=useSession(e);return {update:t,user:o?.user,status:r,isLoading:r==="loading"}}var we,Xe=D(()=>{p();we=PL;});function qt(){let e=H(n=>n.status.activeEntity),t=ie();return {activeEntity:e,selectEntity:n=>t(Ro.setActiveEntity(n)),unselectEntity:()=>t(Ro.setActiveEntity({type:null,id:null}))}}function pt(e){let t=ie(),o=H(i=>i.status.sectionState)[e]||{},r=useCallback(i=>{t(rf({[e]:i}));},[e]),n=useCallback(()=>{t(nf(e));},[e]);return {sectionVariables:o,setSectionVariables:r,resetSectionVariables:n}}function Wl(){let e=ie(),t=H(n=>n.status.isRunConsumersRunning),o=useCallback(n=>{e(af(n));},[]),r=useCallback(n=>{e(sf(n));},[]);return {isRunConsumersRunning:t,addRunConsumersRunning:o,removeRunConsumersRunning:r}}function At(e){let t=ie(),o=we();return useCallback(r=>t(Hu(e,r,o)),[t,e,o.status])}function Ft(e){let t=ie();return {opened:H(l=>l.status.sidebarStatus[e]),handlers:{open:()=>t(Ro.openSidebar(e)),close:()=>t(Ro.closeSidebar(e)),toggle:()=>t(Ro.toggleSidebar(e))}}}function ts(){return H(t=>t.status.currentLocale)}function os(){return H(t=>t.status.preferredLocale)}function ta(e){return t=>{let o=ie(),r=useMemo(()=>Gu.read(e,{include:true}),[]),n=useCallback(a=>{let l=Object.values(a.records.entities[e]),s=a.records.requests[e][r]||{status:l==null?"UNINITIALIZED":"SUCCESS"},c=t?l.filter(u=>t.includes(u.id)):l;return pf(c,s)},[r]),i=H(n);return useEffect(()=>{i.isUninitialized&&o(zl(e,{id:t,include:true}));},[i.status]),i}}function jl(e,t){let o=useMemo(()=>Gu.clone(e,{id:t}),[t,e]);return H(n=>{let i=n.records.entities[e][t],a=n.records.requests[e][o]||{status:i==null?"UNINITIALIZED":"SUCCESS"};return pf(i,a)})}function oa(e){return t=>{let o=ie(),r=useMemo(()=>Gu.read(e,{id:t,include:true}),[t]),n=useCallback(a=>{let l=a.records.entities[e][t],s=a.records.requests[e][r]||{status:l==null?"UNINITIALIZED":"SUCCESS"};return pf(l,s)},[r]),i=H(n);return useEffect(()=>(i.isUninitialized&&t!==null&&o(zl(e,{id:t,include:true})),()=>{}),[r,i.isUninitialized,o,t]),i}}function pf(e,t){let o={data:void 0,error:void 0,status:t.status,isUninitialized:t.status==="UNINITIALIZED",isLoading:t.status==="LOADING",isFetching:t.status==="LOADING"||t.status==="FETCHING",isSuccess:t.status==="SUCCESS",isError:t.status==="FAILURE"};return t.status==="UNINITIALIZED"?o:t.status==="LOADING"?{...o,data:e}:t.status==="FETCHING"?{...o,data:e}:t.status==="FAILURE"?{...o,error:t.error}:{...o,data:e}}var ML,ie,H,Za,$l,Ul,Ji,Gl,Qi,Hl,zt,Ko,tt,Zi,ea,cf,uf,ot,FS,ju,Io,vn,es,VS,Ku,$S,US,GS,ye=D(()=>{p();Vl();of();Dl();Pt();Uo();qa();Xe();(({localeDefault:ML}=We())),ie=useDispatch,H=useSelector,Za=ta("report"),$l=ta("dimension"),Ul=ta("variant"),Ji=ta("section"),Gl=ta("block"),Qi=ta("formatter"),Hl=ta("datasource"),zt=oa("report"),Ko=oa("section"),tt=oa("block"),Zi=oa("dimension"),ea=oa("variant"),cf=oa("formatter"),uf=oa("datasource");ot=(e,t=void 0,o=void 0)=>{if(!e)return {};let r=tt(e).data,n=H(l=>t||l.variables.variables),i=H(l=>o||l.variables.attributes);return useMemo(()=>r?r.inputs.reduce((l,s)=>({...l,...n[s]}),i):{},[r,i,n])},FS=e=>{let t=tt(e).data,o=H(i=>i.variables.variables),r=H(i=>i.variables.attributes);return t?useMemo(()=>t?Object.keys(o).reduce((i,a)=>({...i,...t.inputs.includes(parseInt(a,10))?{[a]:o[a]}:{}}),{attributes:r}):{attributes:r},[t,o,r]):{}},ju=e=>H(t=>t.variables.status[e]),Io=(e=ML)=>useContext(De).formatterFunctions[e],vn=()=>useContext(De).datasourceFunctions,es=()=>useContext(De).profilePrefix,VS=()=>useContext(De).previewPrefix,Ku=(e=void 0,t=void 0)=>{let o=H(i=>i.status.localeDefault),r=H(i=>i.status.query);return {variables:ot(e),locale:t||o,query:r}},$S=(e,t)=>Object.values(t).filter(r=>Object.keys(r.contentByLocale).some(n=>{let{logic:i}=r.contentByLocale[n].content;return i&&(`${i}`.includes(`formatters.${e}(`)||`${i}`.includes(`${e}{{`))})).length,US=e=>{if(!e)return 0;let t=H(r=>r.records.entities.formatter),o=H(r=>r.records.entities.block);return useMemo(()=>$S(e,o),[e,t,o])},GS=()=>{let e=H(o=>o.records.entities.formatter),t=H(o=>o.records.entities.block);return useMemo(()=>Object.values(e).reduce((o,r)=>(o[r.name]=$S(r.name,t),o),{}),[e,t])};});var HS,WS=D(()=>{p();Cm();Dl();qa();Ya();HS=()=>configureStore({reducer:{[yn.name]:yn.reducer,[Du.name]:Du.reducer,[_u.name]:_u.reducer},middleware(e){return e({thunk:{extraArgument:Pl("/api/cms/")}})}}),createWrapper(HS);});function Yt(e,t){let o=r=>{let{id:n,skelHeight:i,skelWidth:a,...l}=r,s=t(n);return s.isUninitialized||s.isFetching?jsx(Skeleton,{width:a,height:i}):s.isError?null:jsx(e,{...l,for:s.data})};return o.displayName=`withFetcher(${e.displayName||e.name||"Component"})`,o}var KS=D(()=>{p();});var se=D(()=>{p();Vl();ye();WS();KS();});function YS(e){let {pathSegment:t,profilePrefix:o,previewPrefix:r,siteProps:n}=e,i=Qi();H(d=>d.status.isCMS);let l=Hl(),c={...wo()},u=useMemo(()=>({profilePrefix:o,previewPrefix:r,pathSegment:t,siteProps:n,formatterFunctions:qS.reduce((d,f)=>({...d,[f]:i.data?Kn(i.data,f):{}}),{}),datasourceFunctions:(l?.data||[]).sort((d,f)=>d.content.order>f.content.order?1:-1).map(d=>({...d,content:{...d.content,pattern:et(d.content.pattern,{},{variables:c})}}))}),[i,t,o,r,n,l]);return jsx(De.Provider,{value:u,children:e.children})}function rs(){let e=useContext(De);if(e===void 0)throw new Error("useBespoke must be used inside ResourceProvider");return e}var qS,$L,De,Pt=D(()=>{p();Uo();qn();se();Qn();Vr();(({locales:qS}=We())),$L={pathSegment:"path",formatterFunctions:qS.reduce((e,t)=>({...e,[t]:{}}),{}),datasourceFunctions:[],profilePrefix:"path",previewPrefix:null,siteProps:{}},De=createContext($L);});function Xt(){let{pathSegment:e}=rs(),t=useRouter();return useMemo(()=>{let o=t.pathname.split("/");Object.keys(t.query).length>0&&o.pop();let r=o.join("/"),[n,...i]=[].concat(t.query[e]||[]),a=(...l)=>[r,...l].join("/");return {router:t,page:n,params:i,query:t.query,basePath:r,href:a,setSearchParam(l,s){let c={...t.query};s==null||s===""?delete c[l]:c[l]=[].concat(s).join("!"),t.push({pathname:t.pathname,query:c},void 0,{shallow:true});},matches(...l){return t.asPath===a(...l)},push(l,s,c){let u=a(l);t.push(u,s,c);},replace(l,s,c){let u=a(l);t.replace(u,s,c);}}},[t.asPath])}var df=D(()=>{p();Pt();});function mf(){let e=ie(),{router:t}=Xt(),{asPath:o}=t,[,r]=o.split("?"),n=r?JSON.parse('{"'+decodeURI(r).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'):{},{currentLocale:i,locales:a}=H(s=>s.status),l=n.locale||"";return useEffect(()=>{l&&l!==""&&a.includes(l)&&l!==i&&e(Z.setCurrentLocale(l));},[]),i}var XS=D(()=>{p();se();df();});function ns(e){return t=>Object.values(t.records.entities[e])}function as(e){return Object.values(e.records.entities.datasource||[]).sort((t,o)=>t.content.order>o.content.order?1:-1).map(t=>{let o={...jL};return {...t,content:{...t.content,pattern:et(t.content.pattern,{},{variables:o})}}})}var JS,ra,qu,is,jL,Gr=D(()=>{p();Qn();Vr();JS=e=>e.records.entities.section,ra=e=>e.records.entities.block;qu=ns("block"),is=ns("formatter"),jL=wo();});function qL(e,t){let o=[],r={},n=new Set,i=1/0;for(let a of e){let l=parseInt(a.settings.order,10);l<i&&(i=l);}for(let a of e){let{id:l,settings:s}=a,c=parseInt(s.order,10),u=t[l]?t[l]:false,d=KL(u,l),f=a.section_id&&!n.has(a.section_id);a.section_id&&n.add(a.section_id);let g={id:l,order:c,label:t[l]?t[l][`title${l}title`]:`Title ${l}`,iconProps:d,properties:{sectionId:a.section_id,...a.section_id&&{titleType:f?"primary":"secondary"}},children:[]};if(r[l]=g,c===i)o.push(g);else {let m=c-1,h;for(let y=e.indexOf(a)-1;y>=0;y--){let S=e[y],v=parseInt(S.settings.order,10);if(v===m){h=r[S.id];break}else if(v<m){h=r[S.id];break}}h?h.children.push(g):o.push(g);}}return o}function na(e=1,t=6,o=[]){let r=H(f=>f),n=H(f=>f.variables.variables),i=H(f=>f.variables.status),a=Ji(),l=qu(r).filter(f=>f.type===E.TITLE&&o.includes(f.id)),s=Object.fromEntries(l.map(f=>[f.id,f])),c=Object.fromEntries(l.map(f=>[f.id,n[f.id]])),u=Object.fromEntries(l.map(f=>[f.id,i[f.id]])),d=useMemo(()=>{if(a.isSuccess&&s){let f=[];return a.data.sort(po).forEach(g=>{let m=g.blocks.reduce((h,y)=>s[y]&&s[y].type===E.TITLE?h.concat([s[y]]):h,[]);f=f.concat(m.sort((h,y)=>po(h,y,"blockrow")));}),Object.keys(i).length?f.filter(g=>{let m=parseInt(g.settings.order||"1",10);return m>=e&&m<=t&&u[g.id]?.allowed&&!u[g.id]?.hiddenByCascade}):[]}},[o,a,s,u]);return useMemo(()=>d&&d?.length>0?qL(d,c):[],[d,c])}var KL,ff=D(()=>{p();se();Gr();Go();he();KL=(e,t)=>({iconType:e[`title${t}_iconType`],icon:e[`title${t}_icon`],iconSize:e[`title${t}_iconSize`],iconVariant:e[`title${t}_iconVariant`],iconRadius:e[`title${t}_iconRadius`]});});function wr(){let e=ie();return useMemo(()=>async t=>await e(Z.readMember(t)),[e])}var ZS=D(()=>{p();se();});function JL(){let{user:e,update:t,status:o}=we(),r=o==="loading",{localeDefault:n}=We(),i=ie();return useEffect(function(){!r&&e&&e.bespoke_user_metadata&&typeof e.bespoke_user_metadata.preferredLocale=="string"&&i(Z.setPreferredLocale(e.bespoke_user_metadata.preferredLocale||n));},[r,e]),{user:e,isLoading:r,update:t,status:o}}var ss,ex=D(()=>{p();se();Uo();Xe();ss=JL;});function gf(){return H(QL)}var QL,tx=D(()=>{p();se();QL=e=>e.status.locales.map(t=>({value:t,label:t.toUpperCase()}));});var hf,ri,rx=D(()=>{p();Xe();hf=(e,t,o,r=null)=>{let[n,i]=useState(false),[a,l]=useState(null);return {print:c=>{i(true),l(null);let u=process.env.NEXT_PUBLIC_REPORTS_BASE_URL,d=new URLSearchParams(window.location.search),f=c?"&transparent=true":"",g=r?`/embeds/${t}/${o}?section=${e}&block=${r}${d.toString()?"&"+d.toString():""}`:`/embeds/${t}/${o}?section=${e}${d.toString()?"&"+d.toString():""}`,m=`${u}${g}&print=true`;Mu.get(`${process.env.NEXT_PUBLIC_PDF_API_URL}/screenshot?url=${encodeURIComponent(m)}${f}`,{responseType:"blob"}).then(h=>{let y=r?`section${e}_block${r}.png`:`section${e}.png`;saveAs(h.data,y);}).catch(h=>{l(h.response?.data?.message||"Failed to download image. Please try again.");}).finally(()=>{i(false);});},downloadLoading:n,error:a}},ri=()=>!!process.env.NEXT_PUBLIC_PDF_API_URL;});var st=D(()=>{p();df();XS();ff();ZS();ex();tx();rx();});function cs(e){let{user:t}=ss();return useMemo(()=>{if(t&&t.bespoke_app_metadata&&t.bespoke_app_metadata.reports&&Array.isArray(t.bespoke_app_metadata.reports)){let r=t.bespoke_app_metadata.reports.find(n=>n.reportId===e);if(r&&r.favorites)return r.favorites}},[t,e])}var nx=D(()=>{p();st();});function bf(e,t){let o=H(s=>t?s.records.entities[e][t]:null),r=o?.settings,[n,i]=useSetState(o?.settings||{}),a=ie(),l=useCallback((s,c)=>{o&&(i(u=>({...u,[s]:c})),a(Z.updateEntity(e,{id:o.id,settings:{...o.settings,[s]:c}})));},[a,o]);return useEffect(()=>{r&&i(r);},[r,i]),{settings:n,updateSettings:l}}var Rr,Kl,ix=D(()=>{p();se();Rr=e=>bf("section",e),Kl=e=>bf("report",e);});var ax=D(()=>{p();qa();se();});var Sn=D(()=>{p();nx();ix();ax();});function Jt(e){let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),i=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(i)?i.replace(n,a=>t[a]):i}var us=D(()=>{p();});function Of(e){return typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e}var kx=D(()=>{p();});function xB(e){return e?SB(Of(Jt(e)),{replacement:"-",remove:/[*+~.()'"!:@]/g,lower:true,strict:true,trim:true}):""}var xt,Hr=D(()=>{p();us();kx();xt=xB;});var Lx=D(()=>{});function _f({dimmed:e=false,label:t,root:o=true,value:r,parentIsArray:n=false,level:i=0}){let a=useMantineTheme();if(i===Df)return null;let l=jsx(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:"[Max depth hitted for preview]"}),s=Bf(r),c=r,u=JSON.stringify(c),d=100,f=1e3,g=!!(u&&u.length>d),m=10,h={control:{padding:"5px 0px 5px 5px"},label:{padding:"5px 0px"},content:{paddingTop:0,paddingBottom:0,paddingRight:0}};if(s==="object")return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:h,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsx(Accordion.Panel,{children:i+1<Df?Object.keys(r).sort((y,S)=>{let v=Bf(r[y]),C=Bf(r[S]);return v!==C?Mx.indexOf(v)-Mx.indexOf(C):y.localeCompare(S)}).map(y=>jsx(_f,{root:false,label:y,value:r[y],level:i+1},y)):l})]})});if(s==="array"){let y=r.length>m,S=y?r.slice(0,m):r,v=y?r.length-m:0;return jsx(Accordion,{className:"cr-variable-accordion",variant:"contained",styles:h,children:jsxs(Accordion.Item,{value:"label",children:[jsx(Accordion.Control,{children:jsx(Text,{lineClamp:1,size:"xs",weight:700,p:0,color:e?"dimmed":a.primaryColor,children:o?`{{${t}}}`:n?`[${t}]`:t})}),jsxs(Accordion.Panel,{children:[i+1<Df?S.map((C,b)=>jsx(_f,{root:false,label:b,value:C,level:i+1,parentIsArray:true},b)):l,y&&jsxs(Text,{lineClamp:1,size:"xs",variant:"dimmed",p:5,children:["[+ ",v," other elements]"]})]})]})})}return s==="string"?c=g?`"${c.substring(0,d)} ... "`:`"${c}"`:s==="error"?c=`Error: ${c.message}`:s==="undefined"?c=s:c.toString&&(c=c.toString()),jsxs(Group,{noWrap:true,spacing:0,children:[jsx(Text,{color:e?"dimmed":a.primaryColor,lineClamp:1,size:"xs",pl:5,style:{overflow:"visible",wordBreak:"keep-all",whiteSpace:"nowrap"},weight:700,children:o?`{{${t}}}`:n?`[${t}]`:t}),jsx(Prism,{className:"cr-variable",language:"jsx",noCopy:true,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:c}),g&&jsxs(HoverCard,{width:500,shadow:"md",withinPortal:true,children:[jsx(HoverCard.Target,{children:jsx(ActionIcon,{children:jsx(IconCodePlus,{})})}),jsx(HoverCard.Dropdown,{w:500,children:jsx(Text,{size:"sm",maw:"100%",style:{wordBreak:"break-all",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:u.substring(0,f)})})]})]})}var Bf,Mx,Df,aa,rp=D(()=>{p();Lx();Bf=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},Mx=["object","array","string","number"],Df=5;aa=_f;});var np,Nf=D(()=>{p();np=e=>t=>t.replace(new RegExp(`^${e}`),"").startsWith("_");});function XB({reserved:e=[],id:t,variables:o={},showInternal:r=false}){let i=tt(t==="attributes"?null:t).data,a=i?i.type:"block",l=i?.type&&i?.id?`${i.type}${i.id}`:"",s=Object.keys(o).filter(r?()=>true:c=>!np(l)(c));return jsx(Stack,{spacing:0,children:s.length?s.map(c=>jsx(aa,{dimmed:e.includes(c),label:c,value:o[c]},c)):jsx(Text,{color:"dimmed",size:"xs",children:jsx("i",{children:`empty ${a}`})})})}var Ar,ys=D(()=>{p();rp();se();Nf();Ar=XB;});var Tn,lT,cT,mT,uT,pT,dT,Po,oo,ws,ro=D(()=>{p();he();Tn={display:{label:"Size",defaultValue:"block",options:[{label:"Full Width",value:"block"},{label:"Inline",value:"inline"}]}},lT={useProxy:{label:"Use proxy (avoid CORS)",defaultValue:"false",options:[{label:"No",value:"false"},{label:"Yes",value:"true"}]}},cT={[E.IMAGE]:{...Tn},[E.PARAGRAPH]:{...Tn},[E.SUBTITLE]:{...Tn},[E.SELECTOR]:{...Tn},[E.STAT]:{...Tn},[E.VIZ]:{...Tn},[E.TITLE]:{order:{label:"Importance",defaultValue:"1",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},search:{label:"Search on Click",defaultValue:"off",options:[{label:"Off",value:"off"},{label:"Inline",value:"inline"},{label:"Modal",value:"modal"}]},addComparisonName:{label:"Show member name on comparison mode",defaultValue:"no",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]},...Tn},[E.GENERATOR]:{...lT},[E.SECTION_FLAG]:{...lT},[E.NAV]:{variant:{label:"Nav variant",defaultValue:"inline",options:[{label:"Inline",value:"inline"},{label:"Fixed",value:"fixed"},{label:"Jump",value:"jump"}]},min:{label:"Min Title level",defaultValue:"1",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},max:{label:"Max Title level",defaultValue:"6",options:[{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"}]},icons:{label:"Show icons",defaultValue:"yes",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]},titlePosition:{label:"Title position",defaultValue:"left",options:[{label:"Left",value:"left"},{label:"Top",value:"top"},{label:"Right",value:"right"},{label:"Bottom",value:"bottom"}]}},[E.MULTIHIERARCHY_SELECTOR]:{...Tn}},mT=e=>e&&cT[e]?cT[e]:Tn,uT={left:"flex-start",right:"flex-end",justify:"stretch"},pT={justify:"apart"},dT={justify:"space-between"},Po=e=>uT[e]?uT[e]:e,oo=e=>pT[e]?pT[e]:e,ws=e=>dT[e]?dT[e]:e;});var f_,fT,gT=D(()=>{p();f_=({value:e,handleChange:t,position:o="right"})=>jsxs(Group,{position:o,children:[jsx(Text,{size:"xs",children:"Aligment"}),jsx(SegmentedControl,{size:"xs",defaultValue:e,onChange:r=>t("align",r),data:[{label:jsx(IconAlignLeft,{size:"0.7rem"}),value:"left"},{label:jsx(IconAlignCenter,{size:"0.7rem"}),value:"center"},{label:jsx(IconAlignRight,{size:"0.7rem"}),value:"right"},{label:jsx(IconAlignJustified,{size:"0.7rem"}),value:"justify"}]})]}),fT=f_;});function I_({id:e,display:t="button",handleChange:o}){let r=ie(),n=tt(e).data,[i,a]=useState(false),l=R_(n),s=m=>{typeof m=="boolean"?c("width",{...l,...m?{stretch:true}:bT}):c("width",{...l,value:m});},c=(m,h)=>{n&&(o?o(m,h):r(Z.updateEntity("block",{id:e,settings:{...n.settings,[m]:h}})));};if(!n)return null;let u=mT(n.type),d=hT[l.unit],f=m=>{let{defaultValue:h}=hT[m];c("width",{...l,value:h,unit:m});},g=jsxs(Stack,{spacing:"xs",children:[jsx(fT,{value:n.settings.align||"left",handleChange:c,position:"apart"}),Object.entries(u).map(([m,{label:h,defaultValue:y,options:S}])=>jsxs(Group,{spacing:"xs",position:"apart",noWrap:true,style:{width:"100%"},children:[h&&jsx(Text,{size:"xs",children:h}),jsx(SegmentedControl,{defaultValue:String(n.settings[m]||y),onChange:v=>c(m,v),data:S,size:"xs"})]},m)),![E.GENERATOR,E.SECTION_FLAG].includes(n.type)&&jsxs(Group,{spacing:"xs",children:[jsx(Text,{size:"xs",children:"Width"}),jsxs(Group,{spacing:"xs",children:[!l.stretch&&jsxs("div",{children:[jsx(w_,{currUnit:l.unit,changeUnit:f}),jsx(NumberInput,{defaultValue:parseInt(d.defaultValue,10),disabled:l.stretch,onChange:m=>s(m),size:"xs",value:Number.isNaN(l.value)?void 0:parseInt(l.value,10),...d})]}),jsx(Checkbox,{size:"xs",label:"Stretch",checked:l.stretch,onChange:m=>s(m.currentTarget.checked)})]})]},"width")]});return t==="button"?jsxs(Popover,{opened:i,onClose:()=>a(false),position:"bottom-end",withinPortal:true,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{onClick:()=>a(m=>!m),children:jsx(IconPalette,{size:20})})}),jsx(Popover.Dropdown,{children:g})]}):jsx(Paper,{p:"md",children:g})}var E_,nc,hT,bT,w_,R_,pp,ic=D(()=>{p();ro();se();gT();he();E_=["px","%"],nc={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,")},hT={px:{defaultValue:400,min:25,step:5,formatter:nc.px},"%":{defaultValue:50,min:20,max:100,step:5,formatter:nc["%"]}},bT={stretch:false,unit:"px",value:"400"},w_=({currUnit:e,changeUnit:t})=>jsxs(Group,{position:"apart",children:[jsx(Text,{size:"xs",fw:"bold",children:"Unit"}),jsx(Group,{spacing:3,children:E_.map(o=>jsx(Anchor,{component:"button",size:"xs",td:e===o?"underline":"none",onClick:()=>t(o),children:o},o))})]}),R_=e=>{let t=e?.settings?.width||{};return t&&["stretch","value","unit"].every(o=>Object.prototype.hasOwnProperty.call(t,o))?t:bT};pp=I_;});var j_,kT,ET=D(()=>{p();j_=(e,t)=>{let o=e.allLabel||"All",r=e.colorKey||"",n=e.data||[],i=e.hideLabel||"false",a=e.resetSectionVars||"false",l=e.iconKey||"",s=e.label||"Unlabeled Multihierarchy Selector",c=e.levels||[],u=e.limit||void 0,d=e.placeholder||"",f=e.searchIndexKey||"",g=e.searchIndexSeparator||"",m,h;return e.defaultValue&&e.defaultValueType&&(m=e.defaultValue,h=e.defaultValueType),(!m||!h)&&(m=[],h=""),{allLabel:o,colorKey:r,data:n,defaultValue:m,defaultValueType:h,hideLabel:i,resetSectionVars:a,iconKey:l,id:t,label:s,levels:c,limit:u,placeholder:d,searchIndexKey:f,searchIndexSeparator:g}},kT=j_;});var K_,wT,q_,RT,IT=D(()=>{p();he();Ru();K_=e=>Array.isArray(e)?e.map(t=>typeof t=="string"?{id:t,label:t}:t):[],wT=(e,t)=>t===St.MULTI&&!Array.isArray(e)?[e]:e,q_=(e,t)=>{let o=e.type||St.SINGLE,r=e.component||"Selector",n=e.hideLabel||"false",i=e.resetSectionVars||"false",a=e.name||"Unlabeled Selector",l=K_(e.options||[]),s;if(e.defaultValue){let c=wT(e.defaultValue,o);Fi(o,c,l)&&(s=c);}if(!s){let c=l&&l[0]&&l[0].id||l[0]||"";s=wT(c,o);}return {id:t,name:a,type:o,options:l,component:r,defaultValue:s,hideLabel:n,resetSectionVars:i}},RT=q_;});var Y_,sr,Xf=D(()=>{p();he();ET();IT();Y_={[E.SELECTOR]:RT,[E.MULTIHIERARCHY_SELECTOR]:kT},sr=Y_;});var X_,J_,Q_,Z_,He,Wr=D(()=>{p();X_=e=>typeof e=="string"?e.replace(/&nbsp;<\/p>/g,"</p>"):e,J_=e=>typeof e=="string"&&e==="<p><br></p>"?"":e,Q_=e=>typeof e=="string"?e.replace(/^<p>(.*)<\/p>$/,"$1"):e,Z_=e=>e&&Q_(J_(X_(e))),He=Z_;});function ve({id:e="",component:t="p",order:o=1,size:r="md",html:n,style:i={},append:a=jsx(Fragment,{}),isPreview:l=false,lineClamp:s="none"}){let c=oN(n),u=rN(n,l),d=i&&i.align?String(i.align):"left",f=Text,g={};return t==="h"?(f=Title,g={id:e,order:o}):g={component:t,size:r,lineClamp:s},jsxs(f,{align:d||c.align||"left",...g,children:[u,a]})}var oN,rN,mt=D(()=>{p();oN=(e="<></>")=>{let t=null,o={replace:r=>(r instanceof Element$1&&!t&&(t=r.attribs,t.align=r.attribs.style?r.attribs.style.replace("text-align: ",""):"",delete t.children),r)};return e?(PT(e,o),t):{}},rN=(e="",t=false)=>{let o={replace:r=>{let{type:n}=r;if(r instanceof Element$1&&n==="tag"){let{name:i,attribs:a,children:l,parent:s}=r;if(i==="p"&&!s)return jsx(Fragment,{children:domToReact(l,o)});if(i==="a"){let{href:c,target:u}=a,d=c.indexOf("http")===0,f=!!(u&&u==="_blank"),g=jsx(Anchor,{...a,href:a.href,target:"_blank",children:domToReact(l,o)});return d||f||t?g:jsx(Anchor,{...a,href:a.href,children:domToReact(l,o)})}else {if(i==="strong")return jsx(Text,{component:"strong",children:domToReact(l,o)});if(i==="em")return jsx(Text,{component:"em",fs:"italic",children:domToReact(l,o)});if(i==="u")return jsx(Text,{component:"u",td:"underline",children:domToReact(l,o)});if(i==="sup")return jsx(Text,{component:"sup",style:{verticalAlign:"super",fontSize:"0.75em"},children:domToReact(l,o)});if(i==="sub")return jsx(Text,{component:"sub",style:{verticalAlign:"sub",fontSize:"0.75em"},children:domToReact(l,o)});if(i==="span")return jsx(Text,{component:"span",children:domToReact(l,o)});if(i==="br")return jsx("br",{})}return jsx(Fragment,{children:domToReact(l,o)})}else if(r instanceof Text$1&&r.type==="text")return jsx(Fragment,{children:r.data})}};return PT(e,o)};});function Qf({paragraph:e,tooltip:t,settings:o}){let r=He(t);return jsx(ve,{component:"p",html:e,style:o,append:t?jsx(Ut,{content:r,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{})})}var LT=D(()=>{p();Wr();Cn();mt();});function je({iconType:e="none",iconVariant:t="transparent",icon:o="",iconRadius:r="md",iconSize:n="md",iconPadding:i="1",blockType:a}){let[l,s]=useState(void 0),c=e==="custom"?o:`/api/cms/read/icons/${e}/icon.svg?name=${o}`,u=/^.*\.svg*$/.test(c)||e==="tabler";return useEffect(()=>{u&&Mu.get(c,{responseType:"text"}).then(f=>f.data).then(s).catch(()=>{});},[e,u,c]),jsx(Fragment,{children:e!=="none"&&o&&o!==""&&!!(l||!u)&&jsx(ThemeIcon,{className:`bespoke-${a}-icon-wrapper`,variant:t,radius:r,size:n,p:parseInt(i),dangerouslySetInnerHTML:l&&u?{__html:l}:void 0,children:u?null:jsx(Image,{src:c,alt:"Title Icon"})})})}var kn=D(()=>{p();});function eg({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:c,_iconPadding:u}){if(!t&&!o&&!e)return null;let d=n&&n.align?n.align:"left";return jsxs(Group,{spacing:"md",position:oo(d),children:[jsx(je,{blockType:"stat",iconType:i,iconVariant:a,iconRadius:s,iconSize:c,icon:l,iconPadding:u}),jsxs(Stack,{spacing:0,children:[t&&jsx(ve,{component:"div",size:"md",html:t,style:n}),o&&jsx(ve,{component:"div",size:"xl",html:o,style:n}),e&&jsx(ve,{component:"div",size:"sm",html:e,style:n})]},"stat"),r&&jsx(Ut,{content:r})]})}var BT=D(()=>{p();Cn();kn();mt();ro();});function tg({subtitle:e,tooltip:t,settings:o}){let r=e||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{spacing:"sm",position:oo(n),children:[jsx(ve,{size:"sm",html:r}),t&&jsx(Ut,{content:t,style:{display:"inline-flex"}})]})}var _T=D(()=>{p();Cn();mt();ro();});var NT=D(()=>{p();se();Gr();Gr();qn();Ml();bn();Xe();se();Ya();st();ye();he();});function Pr(){return useContext(yN)}var yN,ai=D(()=>{p();no();yN=createContext({active:false,variables:null,status:null,setComparisonVariables:null,comparisonLoaded:false,loading:false,error:false});});function gp(e,t,o,r=false,n=false){let i=useRouter(),{query:a,locale:l}=i,s=H(P=>P),c=useDispatch(),u=Pr(),d=H(P=>r&&u.variables?u?.variables?.attributes:P.variables.attributes),f=ra(s),g=is(s),m=as(s),h=Kn(g,l),y=ot(e,r&&u.active?u?.variables.variables:void 0,r&&u.active?u?.variables.attributes:void 0),S=H(P=>r?u.variables.variables:P.variables.variables),v=H(P=>r?u.variables.status:P.variables.status),C=wr(),{sectionVariables:b,resetSectionVariables:k}=pt(t),{addRunConsumersRunning:w,removeRunConsumersRunning:R}=Wl(),O=we(),A=r&&u.active?`${o}Compare`:o,B=r&&u.active?Object.fromEntries(Object.entries(a).filter(([P])=>P.match(CN)).map(([P,I])=>[P.replace("Compare",""),I])):Object.fromEntries(Object.entries(a).filter(([P])=>P.match(kN)).map(([P,I])=>[P.replace("Compare",""),I]));return useCallback(P=>{let I={locale:l,query:{...B,[o]:P},variables:y},F=new URLSearchParams(window.location.search);F.set(A,P),window.history.replaceState(null,null,`?${F.toString()}`),w([t]),ei(f,void 0,e,h,I,{variables:S,status:v},C,"report",m,O).then(M=>{u.active&&r?u.setComparisonVariables({attributes:d,variables:M.variables,status:M.status}):c(Vi.setVariableChange({attributes:d,variables:M.variables,status:M.status})),n&&b&&k(),R([t]);});},[e,t,o,A,a,f,c,h,i,y.attributes,r,n,v,S])}var CN,kN,zT=D(()=>{p();bn();se();qn();Gr();Ya();ye();st();ai();Xe();CN=/\w*Compare\b/,kN=/selector\d+id/;});var FT=D(()=>{p();});var wN,RN,VT,$T,hp,IN,pa,cc=D(()=>{p();Ga();Qn();wN=process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT||"en",RN="Error Rendering Visualization",VT={data:[],dataFormat:e=>e,type:"Treemap",noDataHTML:`<p style="font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;">
35
+ <strong>${RN}</strong>
36
+ </p>`},$T=(e,t,o)=>{let r=t.find(n=>{let i=n.content?.pattern;if(!i)return false;try{return new RegExp(i,"gm").test(e)}catch{return false}});if(r){if(r.content?.useProxy)return `${process.env.NEXT_PUBLIC_REPORTS_BASE_URL}/api/cms/url/proxy?url=${encodeURIComponent(e)}&wrapper=false`;try{let i={envs:{...wo()},...o?{session:o}:{}},l=Ua({vars:["url","libs","session"],logic:r.content.logic},i)(e);if(l instanceof Promise)console.warn(`[DataSource] Logic for "${r.name}" is async, which is not supported in this context. Use useProxy=true for async logic.`);else if(l?.axiosConfig?.url!=null){let{url:s,headers:c}=l.axiosConfig;return c&&Object.keys(c).length>0?{url:s,headers:c}:s}}catch(n){console.error(`[DataSource] Failed to apply logic for URL "${e}":`,n.message);}}return e},hp=(e,t,o)=>typeof e=="string"?$T(e,t,o):Array.isArray(e)?e.map(r=>typeof r=="string"?$T(r,t,o):r):e,IN=(e,t,o={},r=wN,n=null,i={},a={},l=[],s)=>{let c;try{c=$a({vars:["variables"],logic:e},t,r,i,a)(o),c.data=hp(c.data,l,s),c._downloadUrl&&(c.__downloadUrl=hp(c.__downloadUrl,l,s));}catch(m){return console.error(`Parsing Error in propify (ID: ${n})`),console.error(`Error message: ${m.message}`),{error:`${m}`,config:VT}}if(typeof c!="object")return {error:"Visualization JS code must return an object",config:VT};let u=c.dataFormat?c.dataFormat:m=>{let y=Array.isArray(c.data)&&c.data.length>1&&c.data.some(S=>typeof S=="string")?m:[m];return dataConcat(y,"data")};delete c.dataFormat;let d=c.linksFormat||void 0;delete c.linksFormat;let f=c.nodesFormat||void 0;delete c.nodesFormat;let g=c.topojsonFormat||void 0;return delete c.topojsonFormat,{config:c,dataFormat:u,linksFormat:d,nodesFormat:f,topojsonFormat:g}},pa=IN;});var UT=D(()=>{p();ke();ce({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 GT=D(()=>{p();ke();ce({name:"abs",description:"Simple Absolute Value.",logicFactory(){return e=>Math.abs(e)},inputType:"number",testValue:"-123",type:"formatter"});});var ON,HT=D(()=>{p();ke();ON=()=>function(t){let r=new RegExp(/([\$0-9\,]+)[A-z\-\s\&]*([\$0-9\,]*)/g).exec(t);return r?(r=r.slice(1).filter(n=>n.length).map(n=>(n.includes(",")&&(n.indexOf(",")===n.length-4?n=n.replace(/,000$/g,"k").replace(/([0-9]+)(,999$)/g,i=>`${parseInt(i)+1}k`):n.indexOf(",")===n.length-8&&(n=n.replace(/,000,000$/g,"M").replace(/([0-9]+)(,999,999$)/g,i=>`${parseInt(i)+1}M`))),n)),r.length===2?r.join(" - "):t.toLowerCase().match(/under|less|</g)?`< ${r[0]}`:t.toLowerCase().match(/over|more|\+|>/g)?`${r[0]}+`:`${r[0]}`):"None"},ce({name:"bucket",description:"Sanitizes bucket strings to '< n', 'n1 - n2', and 'n+'",logicFactory:ON,inputType:"number",testValue:"1234",type:"formatter"});});var WT=D(()=>{p();ke();ce({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 jT=D(()=>{p();ke();ce({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 KT=D(()=>{p();ke();ce({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 qT=D(()=>{p();ke();ce({name:"formatFieldName",description:"Based on field name returns a string",logicFactory(){return e=>{if(e.contentType.toLowerCase()==="stat"){if(e.field==="title")return "Stat label";if(e.field==="value")return "Stat value";if(e.field==="subtitle")return "Stat subtitle";if(e.field==="tooltip")return "Tooltip text"}return e.contentType.toLowerCase()==="section"&&e.field==="short"?"Short title":e.contentType.toLowerCase()==="description"&&e.field==="description"?"Paragraph":e.field}},inputType:"object",testValue:'{"field":"title","contentType":"stat"}',type:"formatter"});});var YT=D(()=>{p();ke();ce({name:"grewTo",description:"Returns the text with grow direction: 'declined from', 'grew to' o 'stayed at'",logicFactory(){return e=>e<0?"declined from":e>0?"grew to":"stayed at"},inputType:"number",testValue:"-1234",type:"formatter"});});var XT=D(()=>{p();ke();ce({name:"grewWord",description:"Returns either 'grew', 'declined', or 'stayed' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declined":e>0?"grew":"stayed"},inputType:"number",testValue:"-1234",type:"formatter"});});var JT=D(()=>{p();ke();ce({name:"growing",description:"Returns either 'declining', 'growing' depending on the provided number's sign.",logicFactory(){return e=>e<0?"declining":"growing"},inputType:"number",testValue:"-1234",type:"formatter"});});var VN,QT=D(()=>{p();ke();VN=()=>function(t){let{curr:o,currMoe:r=0,prev:n,prevMoe:i=0}=t,a;if(r||i){let l=(-n/o**2)**2*r**2,s=(1/o)**2*i**2;a=Math.sqrt(l+s);}else a=(o-n)/n;return a*100},ce({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:VN,inputType:"object",testValue:'{"curr":10,"currMoe":0,"prev":13,"prevMoe":0}',type:"formatter"});});var ZT=D(()=>{p();ke();ce({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 eC=D(()=>{p();ke();ce({name:"growthWord",description:"Returns either 'growth' or 'decline' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decline":"growth"},inputType:"number",testValue:"-1234",type:"formatter"});});var tC=D(()=>{p();ke();ce({name:"highWord",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign.",logicFactory(){return e=>e<0?"lower than":e>0?"higher than":"approximately the same as"},inputType:"number",testValue:"0",type:"formatter"});});var oC=D(()=>{p();ke();ce({name:"increaseWord",description:"Returns either 'increase', 'decrease', or 'change' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decrease":e>0?"increase":"change"},inputType:"number",testValue:"1234",type:"formatter"});});var rC=D(()=>{p();ke();ce({name:"increasedWord",description:"Returns either 'increased', 'decreased', or 'remained the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreased":e>0?"increased":"remained the same"},inputType:"number",testValue:"0",type:"formatter"});});var nC=D(()=>{p();ke();ce({name:"increasing",description:"Returns either 'decreasing', 'increasing' or 'maintaining' depending on the provided number's sign.",logicFactory(){return e=>e<0?"decreasing":e>0?"increasing":"maintaining"},inputType:"number",testValue:"-1234",type:"formatter"});});var iC=D(()=>{p();ke();ce({name:"largerThan",description:"Returns either 'higher than', 'lower than', or 'approximately the same as' depending on the provided number's sign",logicFactory(){return e=>e<0?"smaller than":e>0?"larger than":"the same as"},inputType:"number",testValue:"-1234",type:"formatter"});});var aC=D(()=>{p();ke();ce({name:"list",description:"Joins an array of strings together, adding commas and 'and' when necessary.",logicFactory(){return e=>e.reduce((t,o,r)=>(r?r===e.length-1&&r===1?t+=` and ${o}`:r===e.length-1?t+=`, and ${o}`:t+=`, ${o}`:t+=o,t),"")},inputType:"object",testValue:'["foo","bar","bee"]',type:"formatter"});});var sC=D(()=>{p();ke();ce({name:"longWord",description:"",logicFactory(){return e=>e<0?"shorter":e>0?"longer":"similar"},inputType:"number",testValue:"5",type:"formatter"});});var lC=D(()=>{p();ke();ce({name:"lowerCaseFirst",description:"Converts the first letter of a string to lowercase",logicFactory(){return e=>typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e},inputType:"string",testValue:"foo",type:"formatter"});});var cC=D(()=>{p();ke();ce({name:"moreFewerWord",description:"",logicFactory(){return e=>e<0?"fewer":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var uC=D(()=>{p();ke();ce({name:"moreLess",description:"Returns either 'more' or 'less' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less":"more"},inputType:"number",testValue:"-5",type:"formatter"});});var pC=D(()=>{p();ke();ce({name:"moreLess",description:"Returns either 'more than', 'less than', or 'approximately the same' depending on the provided number's sign.",logicFactory(){return e=>e<0?"less than":e>0?"more than":"approximately the same"},inputType:"number",testValue:"-5",type:"formatter"});});var dC=D(()=>{p();ke();ce({name:"olderWord",description:"",logicFactory(){return e=>e<0?"getting younger":e>0?"getting older":"staying the same age"},inputType:"number",testValue:"-5",type:"formatter"});});var mC=D(()=>{p();ke();ce({name:"olderYounger",description:"",logicFactory(){return e=>e<0?"younger than":e>0?"older than":"the same age as"},inputType:"number",testValue:"-5",type:"formatter"});});var fC=D(()=>{p();ke();ce({name:"plural",description:"Pluralizes a word.",logicFactory(){return e=>e.replace(/\w$/g,t=>t==="y"?"ies":`${t}s`)},inputType:"string",testValue:"Foo",type:"formatter"});});var gC=D(()=>{p();ke();ce({name:"pxToInt",description:"Takes a pixel value and converts it to an integer",logicFactory(){return e=>parseInt(e.replace(/\D+/g,""),10)},inputType:"string",testValue:"12px",type:"formatter"});});var hC=D(()=>{p();ke();ce({name:"salary",description:"Displays salary values with proper precision (ie. '$74,200' instead of '$74.2k')",logicFactory(e){return t=>{let o;return t<1e6?o=e.d3.format(",")(t.toFixed(0)):o=e.d3plus.formatAbbreviate(t),`$${o}`}},inputType:"number",testValue:"1000000",type:"formatter"});});var bC=D(()=>{p();ke();ce({name:"stripEntities",description:"Removes non breaking spaces & other html entities from a string",logicFactory(){return e=>typeof e=="string"?String(e).replace(/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});/ig," "):e},inputType:"string",testValue:"<b>MyText</b>",type:"formatter"});});var vC=D(()=>{p();ke();ce({name:"stripHTML",description:"Converts html tags to spaces, then removes redundant spaces",logicFactory(){return e=>{let t={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`","&nbsp;":""},o=`(?:${Object.keys(t).join("|")})`,r=RegExp(o),n=RegExp(o,"g"),i=String(e).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return r.test(i)?i.replace(n,a=>t[a]):i}},inputType:"string",testValue:"<b>My text</b>",type:"formatter"});});var SC=D(()=>{p();ke();ce({name:"stripOL",description:"Removes ordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ol>/g,"").replace(/<\/ol>/g,"")},inputType:"string",testValue:"<ol><li>My list</li></ol>",type:"formatter"});});var xC=D(()=>{p();ke();ce({name:"stripP",description:"Removes all paragraph tags from a string.",logicFactory(){return e=>e.replace(/<p>/g,"").replace(/<\/p>/g,"")},inputType:"string",testValue:"<p>My p</p>",type:"formatter"});});var TC=D(()=>{p();ke();ce({name:"stripUL",description:"Removes unordered list wrapper tags from a string.",logicFactory(){return e=>e.replace(/<ul>/g,"").replace(/<\/ul>/g,"")},inputType:"string",testValue:"<ul><li>My list</li></ul>",type:"formatter"});});var CC=D(()=>{p();ke();ce({name:"toKebabCase",description:"Takes a camelCase or PascalCase string and converts it to kebab-case.",logicFactory(){return e=>typeof e=="string"?(e=e.charAt(0).toLowerCase()+e.substring(1),e.replace(/([A-Z])/g,"-$1").toLowerCase()):"invalid string passed to toKebabCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var kC=D(()=>{p();ke();ce({name:"toSpacedCase",description:"Takes a camelCase or PascalCase string and adds spaces (I know Spaced Case isn't a thing, deal with it).",logicFactory(){return e=>typeof e=="string"?e.replace(/([A-Z])/g," $1").toLowerCase().trim():"invalid string passed to toSpacedCase()"},inputType:"string",testValue:"camelCaseText",type:"formatter"});});var EC=D(()=>{p();ke();ce({name:"upperCaseFirst",description:"Converts the first letter of a string to uppercase",logicFactory(){return e=>e.charAt(0).toUpperCase()+e.slice(1)},inputType:"string",testValue:"my name",type:"formatter"});});var wC=D(()=>{p();UT();GT();HT();WT();jT();KT();qT();YT();XT();JT();QT();ZT();eC();tC();oC();rC();nC();iC();aC();sC();lC();cC();uC();pC();dC();mC();fC();gC();hC();bC();vC();SC();xC();TC();CC();kC();EC();});function ho(e){let t=useContext(g1);return e?t[e]??t:t}var g1,Kr=D(()=>{p();g1=createContext({});});function RC({direction:e,onClick:t,visible:o}){return o?jsx(ActionIcon,{className:`bespoke-sortable-table-arrow bespoke-sortable-table-arrow-${e}`,variant:"filled",size:"md",sx:{position:"absolute",top:"50%",[e==="left"?"left":"right"]:"16px",zIndex:10,opacity:.55,"&:hover":{opacity:1}},onClick:t,children:e==="left"?jsx(IconArrowLeft,{size:16}):jsx(IconArrowRight,{size:16})}):null}function bp({data:e}){let t=useRef(null),[o,r]=useState(false),[n,i]=useState(false),[a,l]=useState(false),s=useMemo(()=>(e&&Array.isArray(e)&&e[0]?Object.keys(e[0]):[]).filter(d=>!d.startsWith("_")).map(d=>({accessorKey:d,header:d,enableSorting:true})),[e]);return useEffect(()=>{let c=()=>{if(t.current){let{scrollWidth:u,clientWidth:d,scrollLeft:f}=t.current;r(u>d),i(f>0),l(f+d<u-1);}};return c(),window.addEventListener("resize",c),t.current?.addEventListener("scroll",c),()=>{window.removeEventListener("resize",c),t.current?.removeEventListener("scroll",c);}},[e]),jsxs("div",{className:"bespoke-sortable-table",style:{position:"relative"},children:[jsx(MantineReactTable,{columns:s,data:e,enableBottomToolbar:false,enableColumnActions:false,enablePagination:false,enableSorting:true,enableTopToolbar:false,layoutMode:"grid",enableStickyHeader:true,initialState:{density:"xs"},mantineTableProps:{sx:{tableLayout:"fixed"}},mantineTableContainerProps:{ref:t,sx:{minHeight:100,maxHeight:350,overflowX:"auto"}},mantineTableBodyCellProps:{p:"5px !important",sx:{textWrap:"wrap"}},defaultColumn:{minSize:50,maxSize:150}}),jsx(RC,{direction:"left",visible:o&&n,onClick:()=>{t.current&&t.current.scrollBy({left:-150,behavior:"smooth"});}}),jsx(RC,{direction:"right",visible:o&&a,onClick:()=>{t.current&&t.current.scrollBy({left:150,behavior:"smooth"});}})]})}var rg=D(()=>{p();});var da,yp,vp=D(()=>{p();da="HTML",yp=({config:e})=>!e||!e.html?null:jsx("div",{className:"bespoke-html",dangerouslySetInnerHTML:{__html:e.html}});});function cg(e){let{section:t}=e,o=wr(),r=useRouter(),n=H(G=>G.status.isCMS),i=H(G=>G.status.currentLocale),a=r.locale,l=n?i:a,s=50,c=Io(l),u=vn(),d=we(),f=ho("options"),g={...MC,...f.data_tab},[m,h]=useState([]),[y,S]=useState([]),[v,C]=useState(),[b,k]=useState(),[w,R]=useState(false),[O,A]=useState({}),[B,_]=useState(true),[P,I]=useState(true),{sectionVariables:F,setSectionVariables:M,resetSectionVariables:N}=pt(t.id),j=t.blocks||[],$=H(G=>G),V=useMemo(()=>j.reduce((G,K)=>{let ee=$.records.entities.block[K],ae=$.variables.variables[K],ue=$.variables.status[K];return ee&&(E.GENERATOR===ee.type&&ae._downloadEnabled===true&&ue.allowed||E.VIZ===ee.type&&ue.allowed)&&(G[K]={entity:ee,variables:$.variables.variables[K],status:$.variables.status[K],inputVariablesFlat:ee.inputs.reduce((Te,X)=>({...Te,...$.variables.variables[X]}),$.variables.attributes)}),G},{}),[j]),z=G=>{S(K=>K.includes(G)?K:[...K,G]);},q=G=>{h(K=>(K.find(ae=>ae.ix===G.ix)?K:[...K,G]).sort((ae,ue)=>ae.ix>ue.ix?1:-1));};function W(G){!v&&G[0]&&U(G[0]);}function U(G){C(G),k("0");}useEffect(()=>{let G=async(K,ee,ae)=>{let ue=dataLoad.bind({});return new Promise((Te,X)=>{ue(ee,null,null,(le,de)=>{if(le)X(le);else {let Ce=ae instanceof Function?ae(de):de;K.data.unshift(Ce),q(K),Te(de);}});})};if(m.length===0&&y.length===0){let K=0;for(let ee of Object.values(V)){let ae=ee.entity;if([E.GENERATOR,E.SECTION_FLAG].includes(ae.type)){let ue=ee.variables._downloadData||ee.variables._downloadUrl||ee.status.api;if(ue){let Te=[];typeof ue=="string"?Te=ue.split("|||"):Te=[ue],Te=hp(Te,u,d);let X=ee.variables._downloadTitle||`${g.data_source} ${K+1}`,le=ee.variables._downloadFileName||X;q({ix:K,id:ae.id,title:Jt(X),fileName:le,data:Array.isArray(Te)?Te:[Te],loading:false,type:E.GENERATOR}),z(K),K++;}}else if(ae.type===E.VIZ){let ue=ko(ae),Te=ee.inputVariablesFlat,X={variables:Te},le=xr({logic:ue.logic},c,X).logic,de={router:r,section:{variables:F,setVariables:M,resetVariables:N}},Ce=pa(le,c,Te,l,ae.id,{},de,u,d),$e=Ce.config._downloadTitle||Ce.config.title||`${g.viz_source} ${K+1}`,Ue=Ce.config._downloadFileName||$e;if(Ce.config._downloadEnabled!==false&&Ce.config.type!==da)try{let Qe=Ce.config._downloadUrl||Ce.config.data,To=typeof Qe=="string"?[Qe]:Qe,$o=Ce.dataFormat instanceof Function?Ce.dataFormat:!1,uo=Ce.config._downloadDataFormat instanceof Function?Ce.config._downloadDataFormat:!1;G({ix:K,id:ae.id,title:Jt($e),fileName:Ue,data:To,loading:!1,type:E.VIZ},Qe,uo||$o),z(K),K++;}catch(Qe){console.error("DataLoad catch",Qe);}}}I(false);}},[V]),useEffect(()=>{m.length===y.length&&W(m);},[m]),useEffect(()=>{if(v&&b){let G=parseInt(b,10);if(v.data[G]&&(!O[v.ix]||!O[v.ix][b])){_(true);let K=v.data[b];typeof K=="string"?Dm(K,o,l,[],void 0).then(ee=>{let ae=U1(ee);A({...O,[v.ix]:{...O[v.ix],[G]:ae}});}).catch(ee=>{console.error(ee);}).finally(()=>{_(false);}):(A({...O,[v.ix]:{...O[v.ix],[G]:K}}),_(false));}}},[b,v]);let Y=(G,K)=>{let ee=G===K?"":`-${G}`.toLowerCase();if(v){let ae=v.data.length>1&&b?`-${parseInt(b,10)+1}`:"";return `${xt(v.fileName)}${ee}${ae}.${K.toLowerCase()}`}return `${ee}.${K}`},ne=async G=>{if(v){R(true);let K=new I1,ee=Y(G,G);try{switch(G){case Sp.json.extension:K.file(ee,JSON.stringify(re));break;case Sp.csv.extension:K.file(ee,csvFormat(re));break;case Sp.xlsx.extension:{let{utils:ae,write:ue}=await import('xlsx'),Te=ae.book_new();ae.book_append_sheet(Te,ae.json_to_sheet(re),ee.substring(0,30));let X=ue(Te,{bookType:"xlsx",bookSST:!0,type:"binary"});K.file(ee,X,{binary:!0});break}default:break}K.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:9}}).then(ae=>{R(!1),saveAs(ae,Y(G,"zip"));});}catch(ae){console.error(g.error_generating,ae),R(false);}}},re=useMemo(()=>v&&O[v.ix]&&O[v.ix][b]?O[v.ix][b]:[],[O,v,b]),J=useMemo(()=>{if(m&&m.length>0&&m.length===y.length){let G=m.map(K=>({value:`${K.ix}`,label:K.title}));return jsx(Select,{disabled:!v,style:{flex:"1"},value:`${v?.ix}`,onChange:K=>{let ee=m.find(ae=>`${ae.ix}`===K);U(ee);},data:G,icon:jsx(IconDatabase,{size:16})})}else return ""},[m,v,y]);return jsxs(Stack,{className:"cms-section-options-data",spacing:"xs",children:[jsx(LoadingOverlay,{visible:P,overlayBlur:2}),m.length===0&&!P&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:g.no_data_src}),m.length>1&&m.length===y.length&&!P&&jsx(Input.Wrapper,{label:`${g.choose_data_src}:`,children:jsx(Group,{spacing:"xs",children:J})}),v&&b&&jsx(Stack,{spacing:"xs",children:jsx(Input.Wrapper,{label:`${g.preview}
37
+ ${re.length>s?g.rows_preview.replace("{nrows}",s):""}:`,children:jsxs(Group,{spacing:"xs",children:[jsx(Select,{disabled:!(v.data.length>1),style:{flex:"1"},value:b,onChange:G=>k(G),data:v.data.map((G,K)=>({value:`${K}`,group:typeof G=="string"?g.raw_group:g.formatted_group,label:typeof G=="string"?G:g.formatted_src.replace("{src}",v.title)})),icon:typeof v.data[b]=="string"?jsx(IconLink,{}):jsx(IconSparkles,{})}),jsx(CopyButton,{value:typeof v.data[b]=="string"?v.data[b]:"",timeout:2e3,children:({copied:G,copy:K})=>jsx(Tooltip,{label:G?g.copied:g.copy,withArrow:true,position:"top",children:jsx(ActionIcon,{variant:G?"filled":"subtle",onClick:K,disabled:typeof v.data[b]!="string",children:G?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})]})})}),v&&!B&&re.length===0&&jsx(Alert,{icon:jsx(IconAlertCircle,{size:"1rem"}),title:"Oops!",children:g.error_preview}),v&&b&&!B&&re.length===0&&jsx("a",{href:v.data[b],target:"_blank",rel:"noreferrer",children:jsx(Button,{leftIcon:jsx(IconExternalLink,{size:16}),fullWidth:true,children:g.open_in_window.replace("{src}",v.title)})}),jsxs(Stack,{pos:"relative",mih:"400px",spacing:"xs",children:[jsx(LoadingOverlay,{visible:B&&m.length>0,overlayBlur:2}),v&&!B&&re.length>0&&jsxs(Fragment,{children:[jsx(bp,{data:re.slice(0,s)}),jsx(Input.Wrapper,{label:`${g.download}:`,children:jsx(Button.Group,{children:Object.values(Sp).map(G=>jsx(Button,{leftIcon:jsx(G.icon,{size:24}),onClick:()=>ne(G.extension),loading:w,fullWidth:true,children:G.extension},`format-${G.extension}`))})})]})]})]})}var Sp,MC,U1,ug=D(()=>{p();se();rg();he();cc();Hr();us();Ho();ye();Xe();zi();bn();st();Cr();Kr();vp();Sp={csv:{extension:"CSV",icon:IconFileTypeCsv},json:{extension:"JSON",icon:IconFileTypeJs},xlsx:{extension:"XLSX",icon:IconFileTypeXls}},MC={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.
38
+ 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!"},U1=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};});var W1,Tp=D(()=>{p();se();Xe();st();W1={active:false,pdfParam:false,position:"DEFAULT",XlsxVizActive:false,pdfVariants:[],xlsxVariants:[],currentVariantPdfEnabled:false,currentVariantXlsxEnabled:false,isLoading:false,pdfAccessAllowed:false,xlsxAccessAllowed:false,sectionSelection:false,navBlockId:void 0},createContext(W1);});var DC=D(()=>{p();se();he();Ho();zi();ye();cc();Xe();wC();Kr();ug();Tp();En();Go();});var _C=D(()=>{p();se();});var NC=D(()=>{p();Pt();se();bn();qn();Gr();st();Xe();});function Cp(e,t,o,r,n=false){let i=useRouter(),{query:a,locale:l}=i,s=H(I=>I),c=useDispatch(),u=Pr(),d=H(I=>r&&u.variables?u?.variables?.attributes:I.variables.attributes),f=ra(s),g=is(s),m=as(s),h=Kn(g,l),y=ot(e,r&&u.active?u?.variables.variables:void 0,r&&u.active?u?.variables.attributes:void 0),S=H(I=>r?u.variables.variables:I.variables.variables),v=H(I=>r?u.variables.status:I.variables.status),C=wr(),{sectionVariables:b,resetSectionVariables:k}=pt(t),{addRunConsumersRunning:w,removeRunConsumersRunning:R}=Wl(),O=we(),A=r&&u.active?`${o}-valueCompare`:`${o}-value`,B=r&&u.active?`${o}-typeCompare`:`${o}-type`,_=r&&u.active?Object.fromEntries(Object.entries(a).filter(([I])=>I.match(Y1)).map(([I,F])=>[I.replace("Compare",""),F])):Object.fromEntries(Object.entries(a).filter(([I])=>I.match(X1)).map(([I,F])=>[I.replace("Compare",""),F]));return useCallback((I,F)=>{let M={locale:l,query:{..._,[`${o}-type`]:F,[`${o}-value`]:I},variables:y},N=new URLSearchParams(window.location.search);I&&F?(N.set(A,I.join(",")),N.set(B,F)):(N.delete(A),N.delete(B)),window.history.replaceState(null,null,`?${N.toString()}`),w([t]),ei(f,void 0,e,h,M,{variables:S,status:v},C,"report",m,O).then(j=>{n&&b&&k(),u.active&&r?u.setComparisonVariables({attributes:d,variables:j.variables,status:j.status}):c(Vi.setVariableChange({attributes:d,variables:j.variables,status:j.status})),R([t]);});},[r,d,e,f,u,c,h,v,S,l,_,C,o,B,A,y,b,n,k])}var Y1,X1,zC=D(()=>{p();ai();st();bn();se();ye();qn();Gr();Ya();Xe();Y1=/\w*Compare\b/,X1=/multihierarchySelector\d+(id|-(type|value))/;});function Oo(){return useMantineTheme().other.bespokeStyles??{}}var FC=D(()=>{p();});var VC=D(()=>{p();});var ez,tz,li,uc=D(()=>{p();ez={try_another:"Try another search or filter.",search:"Search",filters_all:"All",no_results:"No Results",load_more:"Load more",select_report:"Select Report",select_variant:"Select Variant",count_format:".2s",report:{},dimension:{},variant:{}},tz=createContext({metadata:[],loadingItems:false,setLoadingItems:()=>null,loadingMetadata:false,setLoadingMetadata:()=>null,resultCount:{},totalCount:{},setResultCount:()=>null,activePage:1,setActivePage:()=>null,pageSize:10,results:[],filters:{},doQuery:()=>null,setFilters:()=>null,query:"",setQuery:()=>null,debouncedQuery:"",currentPageTotal:10,selectorStructure:[],translations:ez,setTranslations:()=>null,showSelectors:true}),li=()=>useContext(tz);});function rz({translations:e}){let{loadingItems:t,setFilters:o,selectorStructure:r,filters:n,showSelectors:i}=li(),a=m=>{let h=m===null||Number.isNaN(m)?void 0:parseInt(m,10);h!==n.profile?o({profile:h,variant:void 0}):h&&o({profile:void 0,variant:void 0});},l=m=>{let h=m===null?void 0:typeof m=="string"&&m.includes(",")?m:parseInt(m,10);h!==n.variant?o({...n,variant:h}):h&&o({...n,variant:void 0});},s=m=>m<1e3?m:format$1(e.count_format)(m).replace(/\.0+([a-zA-Z]*)$/,"$1"),c=r.length===2?r[1].id:n.profile,u=c?r.find(m=>m.id===c):void 0,d=u&&u.variants&&n.variant?u.variants.find(m=>m.id===n.variant):void 0,f=useMemo(()=>r.map(m=>({value:String(m.id||""),label:(e?.dimensionIcon?.[m.name]?`${e?.dimensionIcon?.[m.name]} `:"")+(e?.dimension[m.name]||m.name)+(!t&&(!u||m.id===u?.id)?` (${s(m.members_count)})`:"")})),[e,u,r]),g=useMemo(()=>u?.variants?.map(m=>({value:String(m.id||""),label:(e?.variantIcon?.[m.name]?`${e?.variantIcon?.[m.name]} `:"")+(e?.variant[m.name]||m.name)+(!t&&(!d||m.id===d?.id)?` (${s(m.members_count)})`:"")}))??[],[e,d,r]);return jsx(Fragment,{children:i&&jsxs(Fragment,{children:[jsx(MediaQuery,{largerThan:1e3,styles:{display:"none"},children:jsxs(Group,{className:"bespoke-explore-reports-select-container",position:"center",mb:"md",children:[jsx(Select,{className:"bespoke-explore-reports-select",data:f,value:String(u?.id||""),onChange:m=>a(m),label:e.select_report||"Select Report",placeholder:e.select_report||"Select Report",clearable:typeof u?.id<"u",style:{width:"450px"}}),u?.variants&&u.variants.length>2&&jsx(Select,{className:"bespoke-explore-variant-select",data:g,value:String(d?.id||""),onChange:m=>l(m),label:e.select_variant||"Select Variant",placeholder:e.select_variant||"Select Variant",clearable:typeof d?.id<"u",style:{width:"450px"}})]})}),jsx(MediaQuery,{smallerThan:1e3,styles:{display:"none"},children:jsxs("div",{children:[jsx(Group,{position:"center",className:"bespoke-explore-reports-selector",mb:"md",children:r.map(m=>jsxs(Button,{"data-selected":m.id===u?.id?"true":"false","data-report-name":m.name,variant:m.id===u?.id?"outline":"subtle",onClick:()=>a(m.id),rightIcon:m.id&&m.id===u?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.dimensionIcon?.[m.name]??void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-reports-name",dangerouslySetInnerHTML:{__html:e?.dimension[m.name]??m.name}}),!t&&(!u||m.id===u?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-reports-count",children:`(${s(m.members_count)})`})]},`p-${m.id}`))}),u&&u.variants&&u.variants.length>2&&jsx(Group,{position:"center",style:{minHeight:"36px"},className:"bespoke-explore-variant-selector",mb:"md",children:u.variants.map(m=>jsxs(Button,{"data-selected":m.id===d?.id?"true":"false","data-variant-name":m.name,variant:m.id===d?.id?"outline":"subtle",onClick:()=>l(m.id),rightIcon:m.id&&m.id===d?.id?jsx(IconX,{size:"1rem"}):void 0,leftIcon:e?.variantIcon?.[m.name]?jsx(Text,{span:true,dangerouslySetInnerHTML:{__html:e.variantIcon[m.name]}}):void 0,children:[jsx(Text,{span:true,className:"bespoke-explore-variant-name",dangerouslySetInnerHTML:{__html:e?.variant[m.name]??m.name}}),!t&&(!d||m.id===d?.id)&&jsx(Text,{span:true,size:"xs",ml:"0.2rem",className:"bespoke-explore-variant-count",children:`(${s(m.members_count)})`})]},`v-${m.id}`))})]})})]})})}var KC,qC=D(()=>{p();uc();KC=rz;});function dg({reportId:e,reportName:t,members:o,href:r,onClick:n}){let i=o.map(l=>jsx(Image,{src:l.image.src,height:160,imageProps:{loading:"lazy"},alt:l.name},l.id)),a=o.map(l=>jsxs(Stack,{children:[jsx(Text,{weight:500,children:l.name}),jsx(Badge,{color:"green",variant:"light",w:"fit-content",children:l.variant})]},l.id));return jsxs(Card,{className:`report-${e}-tile`,shadow:"sm",p:"lg",radius:"md",withBorder:true,children:[jsx(Card.Section,{children:jsx(Group,{grow:true,spacing:0,children:i})}),jsx(Group,{position:"apart",mt:"md",mb:"xs",children:a}),jsx("a",{href:r,onClick:n,children:jsx(Button,{variant:"light",color:"blue",fullWidth:true,mt:"md",radius:"md",children:`See ${t} Report`})})]})}function dz({profile:e,profilePrefix:t,onSelect:o,reportTile:r}){let n=useRouter(),i=n.locale,{localeDefault:a}=We(),s=`${i===a?"":`/${i}`}${t}${e.path}`,c=e.members.map(g=>({original_id:g.metadata.id,name:g.name,id:g.id,dimension_id:g.metadata.dimension.id,dimension:g.metadata.dimension.name,variant_id:g.metadata.variant.id,variant:g.metadata.variant.name,image:{src:`/api/cms/member/image?member=${g.id}&size=thumb`,alt:g.name}})),u=g=>{n.push(`${g}`),o&&o();},d=g=>{g.preventDefault(),u(s);},f=pz(r);return jsx(Grid.Col,{xs:12,sm:6,md:4,lg:4,xl:3,children:jsx(f,{reportId:e.report.id,reportName:e.report.name,members:c,href:s,onClick:d})},e.id)}var pz,QC,mg=D(()=>{p();no();Uo();pz=e=>{let{components:t}=Oo(),o=dg;return t?.ReportTile&&(o=t?.ReportTile),e&&(o=e),o};QC=dz;});function yz({profilePrefix:e,onSelect:t=()=>{},reportTile:o}){let[r,n]=useState(500),i=useRef(null),{results:a}=li(),l=i.current?.offsetTop||0,s=50;return useEffect(()=>{let{innerHeight:c}=window;n(c-l-s);},[l]),jsx(ScrollArea,{offsetScrollbars:true,type:"always",h:r,ref:i,children:jsx(Grid,{align:"stretch",children:a.map(c=>jsx(QC,{profile:c,profilePrefix:e,reportTile:o,onSelect:t},c.id))})})}var ZC,ek=D(()=>{p();mg();uc();ZC=yz;});function xz(){let{activePage:e,setActivePage:t,pageSize:o,currentPageTotal:r}=li();return jsx(Group,{position:"center",children:jsx(Pagination,{value:e,onChange:i=>{t(i);},total:Math.ceil(r/o),size:"sm",py:"xs"})})}var ok,rk=D(()=>{p();uc();ok=xz;});function Lz({profilePrefix:e,initialReportId:t,initialVariantId:o,translations:r,onSelect:n,reportTile:i,initialQuery:a}){let l=useRef(),s=li(),{query:c,setQuery:u,results:d,loadingItems:f,loadingMetadata:g,translations:m,setTranslations:h,initExplore:y}=s;useEffect(()=>{y&&y(t,o,a);},[y]),useEffect(()=>{f||l.current?.focus();},[f]),useEffect(()=>{r&&h(r);},[r]);let S=()=>{u("");};return jsxs(Container,{fluid:true,pt:"1em",children:[jsx(TextInput,{placeholder:m.search,mb:"md",size:"xl",onChange:v=>u(v.target.value),readOnly:g||f,icon:jsx(IconSearch,{size:24}),value:c,rightSectionWidth:100,rightSectionProps:{style:{justifyContent:"flex-end",padding:"0 15px 0 0"}},rightSection:jsxs(Group,{align:"center",children:[(g||f)&&jsx(Loader,{size:28}),c&&c!==""&&jsx(ActionIcon,{onClick:S,children:jsx(IconTrash,{size:24})})]}),ref:l}),jsx(KC,{translations:m}),jsx(LoadingOverlay,{visible:g||f}),!f&&d.length===0&&jsx(Alert,{title:m.no_results,color:"blue",children:m.try_another}),jsx(ZC,{profilePrefix:e,onSelect:n,reportTile:i}),jsx(ok,{})]})}var ik,ak=D(()=>{p();qC();ek();rk();uc();ik=Lz;});function Vz({exploreProps:e={profilePrefix:"/",locale:Fz},icon:t=jsx(IconSearch,{size:20}),actionIconProps:o={},modalProps:r={},tooltipProps:n={},tooltipText:i="Click to Explore",showIcon:a=true,showTooltip:l=false,children:s}){let[c,u]=useState(false),d={variant:"light",size:"md",radius:"md",...o},f={fullScreen:true,opened:c,onClose:()=>u(false)},g=jsx(ActionIcon,{...d,onClick:()=>u(true),children:t}),m=a?jsxs(Group,{spacing:"sm",style:{cursor:"pointer"},children:[s,g]}):s;return l&&(m=jsx(Tooltip,{label:i,...n,children:m})),jsxs(Fragment,{children:[jsx(Modal,{...f,...r,children:c&&jsx(ik,{...e,onSelect:()=>u(false)})}),jsx("div",{onClick:()=>u(true),children:s?m:jsx(Fragment,{children:g})})]})}var Fz,ck,uk=D(()=>{p();ak();Uo();({localeDefault:Fz}=We());ck=Vz;});var jz,pk,dk=D(()=>{p();jz=forwardRef(({id:e,members:t,...o},r)=>{let n=t.map(i=>jsxs(Stack,{align:"center",children:[jsx(Text,{weight:500,children:i.name}),jsx(Badge,{color:"green",variant:"light",children:i.variant})]},i.id));return jsx("div",{ref:r,children:jsx(Group,{position:"apart",grow:true,...o,children:n})},e)}),pk=jz;});function nF({locale:e,profilePrefix:t="/report",autocompleteProps:o={},tooltipProps:r={},tooltipText:n="Click to search",searchReportParams:i={},callback:a,children:l}){let s=useRouter(),c=s.locale,{localeDefault:u}=We(),d=c===u?"":`/${c}`,f=rF(o?o.itemComponent:null),[g,m]=useState(""),[h,y]=useDebouncedValue(g,500),[S,v]=useState([]),[C,b]=useState(false),[k,w]=useState(false),[R,O]=useState(false),[A,B]=useState(!l),_=()=>{B(false);},P=()=>{B(true),N();},I=useRef(),F=useClickOutside(_),M=o?.searchConfig?.searchLimit??10,N=()=>{b(true);let Y={query:h,format:"profiles",locale:e,limit:M,visible:true,includes:true,noImage:false,variant:[],dimension:[],report:[],all:false,...i};Mu.get("/api/cms/search/reports",{params:Y}).then(ne=>{ne&&ne.data&&ne.data.data&&ne.data.data.results&&v(ne.data.data.results.map(re=>({id:re.id,reportName:re.report.name,href:`${d}${t}${re.path}`,reportPath:`${re.path}`,profilePrefix:t,value:`VALUE: ${re.id}`,members:re.members.map(J=>({original_id:J.metadata.id,name:J.name,id:J.id,variant:J.metadata.variant.name,image:{src:`/api/cms/member/image?member=${J.id}&size=thumb`,alt:J.name}}))}))),b(false),I.current?.focus();}).catch(ne=>{console.error(ne),b(false);});};useEffect(()=>{R&&h.length>=(o.searchConfig?.queryThreshold??0)&&N();},[R,h,o.searchConfig?.queryThreshold]),useEffect(()=>{y(),I.current&&A&&O(true);},[]),useEffect(()=>{y(),I.current&&A&&O(true);},[A]);let j=Y=>{B(false),a?a(Y):(s.push(Y.href),w(true));},$=Y=>{Y.includes("VALUE:")||m(Y);},{searchConfig:V,...z}=o,q={placeholder:"Search",size:"md",icon:jsx(IconSearch,{}),...z,data:S},W=jsx(Autocomplete,{value:g,itemComponent:f,onItemSubmit:j,onChange:$,filter:()=>true,disabled:(C||k)&&!R,limit:M,maxDropdownHeight:250,rightSection:jsx(Group,{spacing:0,position:"right",children:C?jsx(Loader,{size:20}):jsx(Fragment,{})}),rightSectionWidth:50,ref:I,...q});return l?jsx(Tooltip,{label:n,disabled:A,...r,children:jsxs(Group,{ref:F,spacing:"sm",align:"center",style:{cursor:"pointer"},children:[!A&&jsx("div",{onClick:()=>B(true),children:l}),A&&jsx(Fragment,{children:W}),A?jsx(ActionIcon,{variant:"light",onClick:_,children:jsx(IconX,{size:20})}):jsx(ActionIcon,{variant:"light",onClick:P,children:jsx(IconSearch,{size:20})})]})}):W}var rF,bk,yk=D(()=>{p();no();dk();Uo();rF=e=>{let{components:t}=Oo(),o=pk;return t?.ReportItem&&(o=t?.ReportItem),e&&(o=e),o};bk=nF;});function lF(){let{components:e}=Oo(),{modal:t,inline:o}=e?.search??{};return {modal:t,inline:o}}function Os(e,t,o,r,n){let i=lF(),a=H(d=>({reportId:d.variables.attributes.report_id,variantId:d.variables.attributes.variant_id1,title:d.variables.attributes.name1})),l=useRouter(),s=es(),c=ho();return useMemo(()=>{let d=e;return t==="modal"?d=jsx(ck,{exploreProps:{locale:l.locale||vk,profilePrefix:s,translations:c.explore,initialReportId:a.reportId,initialVariantId:a.variantId,initialQuery:a.title},tooltipText:c.explore?.tooltip,modalProps:i.modal,...n,children:e}):t==="inline"&&(d=jsx(bk,{locale:l.locale||vk,profilePrefix:s,callback:o,tooltipText:c.explore?.tooltip,...r,autocompleteProps:i.inline,children:e})),d},[t,e])}var vk,xk=D(()=>{p();Kr();se();ye();uk();yk();Uo();no();({localeDefault:vk}=We());});var no=D(()=>{p();NT();zT();FT();DC();ff();_C();NC();zC();FC();VC();xk();});function yg({title:e,tooltip:t,slug:o,_iconType:r,_iconVariant:n,_icon:i,settings:a,_iconRadius:l,_iconSize:s,_iconPadding:c,asComparison:u=false}){let{print:d}=cr(),f=He(e)||"<span class='cr-block-placeholder'>Title</span>",g=a&&a.order?parseInt(a.order,10):1,m=g<=6?g:1,h=a&&a.search?a.search:"off",y=a&&a.align?a.align:"left",S=Pr(),v=H(O=>O.status.previews),b=(u?S.status.previews:v).map(O=>O.name).join(" | "),k=jsxs(Group,{children:[jsx(je,{blockType:"title",iconType:r,iconVariant:n,iconRadius:l,iconSize:s,icon:i,iconPadding:c}),jsx(ve,{id:o||void 0,component:"h",order:m,style:a,html:f})]}),w=Os(k,h),R=a&&a.addComparisonName==="yes"&&S.active;return jsxs(Group,{spacing:"sm",position:oo(y),children:[jsxs("div",{children:[d?k:w,R&&jsx(Text,{className:"bespoke-comparison-title",children:b})]}),t&&jsx(Ut,{content:t})]})}var Ck=D(()=>{p();Wr();kn();mt();no();ai();se();En();Cn();ro();});function Tg(e){let{name:t,settings:o,options:r,id:n,defaultValue:i,section:a,component:l,asComparison:s,hideLabel:c,resetSectionVars:u}=e,{print:d}=cr(),f=TF(n),g=gp(n,a,f,s,u==="true"),m=s?`${f}Compare`:f,[h,y]=useState(i),[S,v]=useState(Ek(i,[])),C=JSON.stringify(r),b=o[_t.DISABLED]||false,k=useMemo(()=>r?.map(_=>({value:_.id,label:_.label,imageUrl:_.imageUrl})),[C]),w=d?r.filter(_=>S.includes(_.id)).map(_=>_.label).join(", "):"",R=d&&h&&r.find(_=>_.id===h)?.label||"",O=e.hideLabel==="true"?jsx(Fragment,{}):jsx(ve,{component:"div",html:t,size:"sm",style:o});if(useEffect(()=>{if(!b){let P=new URLSearchParams(window.location.search).get(m)||i;P&&(e.type===St.SINGLE?y(P):v(Ek(P,i)));}},[window.location.search,i]),k.length<=1)return jsx(Fragment,{});let A=_=>{v(_),g(_.join(","));},B=_=>{y(_),g(_);};return jsx(Fragment,{children:d?jsxs(Box,{style:{display:"flex",alignItems:"center"},children:[O,jsx(Button,{ml:"sm",radius:"xl",variant:"outline",children:e.type===St.SINGLE?R:w})]}):jsx(Box,{children:{[St.SINGLE]:l===Eu.SEGMENTED_CONTROL?jsxs("div",{children:[jsx(Text,{size:"sm",fw:500,display:c==="true"?"none":"block",children:O}),jsx(SegmentedControl,{data:k,disabled:b,value:k.map(_=>_.value).includes(h)?h:"",onChange:B,fullWidth:true})]}):jsx(Select,{label:O,data:k,disabled:b,value:h,itemComponent:CF,onChange:B,styles:{label:{display:c==="true"?"none":"block"}}}),[St.MULTI]:jsx(MultiSelect,{label:O,data:k,value:S,onChange:A,disabled:b,styles:{label:{display:c==="true"?"none":"block"}}})}[e.type]})})}var TF,Ek,CF,Rk=D(()=>{p();mt();he();no();En();TF=e=>`selector${e}id`,Ek=(e,t)=>e&&typeof e=="string"?e.split(","):t,CF=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{noWrap:true,children:[t&&!["","undefined"].includes(t)&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});function wp(){return jsx("div",{children:"Generator"})}var Ik=D(()=>{p();});function Cg(e){let{alt:t,src:o,desc:r,title:n,settings:i,...a}=e,l=He(t),s=He(o),c=He(r),u=jsx("img",{src:s,alt:l,style:a}),d=i&&i.align?String(i.align):"left";return (c&&c.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Po(d),spacing:"sm",children:[n&&jsx(ve,{component:"p",html:n,style:i}),u,r&&jsx(ve,{component:"p",size:"sm",html:r,style:i})]})),s&&l?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var Ak=D(()=>{p();Wr();mt();ro();});function fc(){return fc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r]);}return e},fc.apply(this,arguments)}var Pk=D(()=>{p();});function gc(){return gc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r]);}return e},gc.apply(this,arguments)}var Ok=D(()=>{p();});function fa(e,t,o){var r,n=(r=o.initialDeps)!=null?r:[],i;return function(){var a;o.key&&o.debug!=null&&o.debug()&&(a=Date.now());var l=e(),s=l.length!==n.length||l.some(function(m,h){return n[h]!==m});if(!s)return i;n=l;var c;if(o.key&&o.debug!=null&&o.debug()&&(c=Date.now()),i=t.apply(void 0,l),o.key&&o.debug!=null&&o.debug()){var u=Math.round((Date.now()-a)*100)/100,d=Math.round((Date.now()-c)*100)/100,f=d/16,g=function(h,y){for(h=String(h);h.length<y;)h=" "+h;return h};console.info("%c\u23F1 "+g(d,5)+" /"+g(u,5)+" ms",`
39
39
  font-size: .6rem;
40
40
  font-weight: bold;
41
- color: hsl(`+Math.max(0,Math.min(120-120*m,120))+"deg 100% 31%);",o?.key);}return o==null||o.onChange==null||o.onChange(i),i}}function wp(e,t){if(e===void 0)throw new Error("Unexpected undefined"+(""));return e}var Ok,Lk=N(()=>{p();Ok=function(t,o){return Math.abs(t-o)<1};});function PF(e){for(var t=e.measurements,o=e.outerSize,r=e.scrollOffset,n=t.length-1,i=function(c){return t[c].start},a=Nk(0,n,i,r),l=a;l<n&&t[l].end<r+o;)l++;return {startIndex:a,endIndex:l}}var IF,hc,Mk,Bk,AF,Dk,_k,Nk,Cg=N(()=>{p();Pk();Lk();IF=function(t){return t},hc=function(t){for(var o=Math.max(t.startIndex-t.overscan,0),r=Math.min(t.endIndex+t.overscan,t.count-1),n=[],i=o;i<=r;i++)n.push(i);return n},Mk=function(t,o){var r=t.scrollElement;if(r){var n=function(l){var s=l.width,c=l.height;o({width:Math.round(s),height:Math.round(c)});};n(r.getBoundingClientRect());var i=new ResizeObserver(function(a){var l=a[0];if(l!=null&&l.borderBoxSize){var s=l.borderBoxSize[0];if(s){n({width:s.inlineSize,height:s.blockSize});return}}n(r.getBoundingClientRect());});return i.observe(r,{box:"border-box"}),function(){i.unobserve(r);}}},Bk=function(t,o){var r=t.scrollElement;if(r){var n=function(){o(r[t.options.horizontal?"scrollLeft":"scrollTop"]);};return n(),r.addEventListener("scroll",n,{passive:true}),function(){r.removeEventListener("scroll",n);}}},AF=function(t,o,r){if(o!=null&&o.borderBoxSize){var n=o.borderBoxSize[0];if(n){var i=Math.round(n[r.options.horizontal?"inlineSize":"blockSize"]);return i}}return Math.round(t.getBoundingClientRect()[r.options.horizontal?"width":"height"])},Dk=function(t,o,r){var n,i,a=o.adjustments,l=a===void 0?0:a,s=o.behavior,c=t+l;(n=r.scrollElement)==null||n.scrollTo==null||n.scrollTo((i={},i[r.options.horizontal?"left":"top"]=c,i.behavior=s,i));},_k=function(t){var o=this;this.unsubs=[],this.scrollElement=null,this.isScrolling=false,this.isScrollingTimeoutId=null,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollDirection=null,this.scrollAdjustments=0,this.measureElementCache=new Map,this.observer=(function(){var r=null,n=function(){return r||(typeof ResizeObserver<"u"?r=new ResizeObserver(function(a){a.forEach(function(l){o._measureElement(l.target,l);});}):null)};return {disconnect:function(){var a;return (a=n())==null?void 0:a.disconnect()},observe:function(a){var l;return (l=n())==null?void 0:l.observe(a,{box:"border-box"})},unobserve:function(a){var l;return (l=n())==null?void 0:l.unobserve(a)}}})(),this.range={startIndex:0,endIndex:0},this.setOptions=function(r){Object.entries(r).forEach(function(n){var i=n[0],a=n[1];typeof a>"u"&&delete r[i];}),o.options=gc({debug:false,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:false,getItemKey:IF,rangeExtractor:hc,onChange:function(){},measureElement:AF,initialRect:{width:0,height:0},scrollMargin:0,scrollingDelay:150,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1},r);},this.notify=function(){o.options.onChange==null||o.options.onChange(o);},this.cleanup=function(){o.unsubs.filter(Boolean).forEach(function(r){return r()}),o.unsubs=[],o.scrollElement=null;},this._didMount=function(){return o.measureElementCache.forEach(o.observer.observe),function(){o.observer.disconnect(),o.cleanup();}},this._willUpdate=function(){var r=o.options.getScrollElement();o.scrollElement!==r&&(o.cleanup(),o.scrollElement=r,o._scrollToOffset(o.scrollOffset,{adjustments:void 0,behavior:void 0}),o.unsubs.push(o.options.observeElementRect(o,function(n){var i=o.scrollRect;o.scrollRect=n,(o.options.horizontal?n.width!==i.width:n.height!==i.height)&&o.maybeNotify();})),o.unsubs.push(o.options.observeElementOffset(o,function(n){o.scrollAdjustments=0,o.scrollOffset!==n&&(o.isScrollingTimeoutId!==null&&(clearTimeout(o.isScrollingTimeoutId),o.isScrollingTimeoutId=null),o.isScrolling=true,o.scrollDirection=o.scrollOffset<n?"forward":"backward",o.scrollOffset=n,o.maybeNotify(),o.isScrollingTimeoutId=setTimeout(function(){o.isScrollingTimeoutId=null,o.isScrolling=false,o.scrollDirection=null,o.maybeNotify();},o.options.scrollingDelay));})));},this.getSize=function(){return o.scrollRect[o.options.horizontal?"width":"height"]},this.memoOptions=ga(function(){return [o.options.count,o.options.paddingStart,o.options.scrollMargin,o.options.getItemKey]},function(r,n,i,a){return o.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:n,scrollMargin:i,getItemKey:a}},{key:false}),this.getFurthestMeasurement=function(r,n){for(var i=new Map,a=new Map,l=n-1;l>=0;l--){var s=r[l];if(!i.has(s.lane)){var c=a.get(s.lane);if(c==null||s.end>c.end?a.set(s.lane,s):s.end<c.end&&i.set(s.lane,true),i.size===o.options.lanes)break}}return a.size===o.options.lanes?Array.from(a.values()).sort(function(u,d){return u.end-d.end})[0]:void 0},this.getMeasurements=ga(function(){return [o.memoOptions(),o.itemSizeCache]},function(r,n){var i=r.count,a=r.paddingStart,l=r.scrollMargin,s=r.getItemKey,c=o.pendingMeasuredCacheIndexes.length>0?Math.min.apply(Math,o.pendingMeasuredCacheIndexes):0;o.pendingMeasuredCacheIndexes=[];for(var u=o.measurementsCache.slice(0,c),d=c;d<i;d++){var m=s(d),g=o.options.lanes===1?u[d-1]:o.getFurthestMeasurement(u,d),f=g?g.end:a+l,h=n.get(m),v=typeof h=="number"?h:o.options.estimateSize(d),T=f+v,y=g?g.lane:d%o.options.lanes;u[d]={index:d,start:f,size:v,end:T,key:m,lane:y};}return o.measurementsCache=u,u},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:function(){return o.options.debug}}),this.calculateRange=ga(function(){return [o.getMeasurements(),o.getSize(),o.scrollOffset]},function(r,n,i){return o.range=PF({measurements:r,outerSize:n,scrollOffset:i})},{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:function(){return o.options.debug}}),this.maybeNotify=ga(function(){var r=o.calculateRange();return [r.startIndex,r.endIndex,o.isScrolling]},function(){o.notify();},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:function(){return o.options.debug},initialDeps:[this.range.startIndex,this.range.endIndex,this.isScrolling]}),this.getIndexes=ga(function(){return [o.options.rangeExtractor,o.calculateRange(),o.options.overscan,o.options.count,o.getSize()]},function(r,n,i,a,l){return l===0?[]:r(gc({},n,{overscan:i,count:a}))},{key:process.env.NODE_ENV!=="production"&&"getIndexes",debug:function(){return o.options.debug}}),this.indexFromElement=function(r){var n=o.options.indexAttribute,i=r.getAttribute(n);return i?parseInt(i,10):(console.warn("Missing attribute name '"+n+"={index}' on measured element."),-1)},this._measureElement=function(r,n){var i=o.measurementsCache[o.indexFromElement(r)];if(!i||!r.isConnected){o.measureElementCache.forEach(function(s,c){s===r&&(o.observer.unobserve(r),o.measureElementCache.delete(c));});return}var a=o.measureElementCache.get(i.key);a!==r&&(a&&o.observer.unobserve(a),o.observer.observe(r),o.measureElementCache.set(i.key,r));var l=o.options.measureElement(r,n,o);o.resizeItem(i,l);},this.resizeItem=function(r,n){var i,a=(i=o.itemSizeCache.get(r.key))!=null?i:r.size,l=n-a;l!==0&&(r.start<o.scrollOffset&&(process.env.NODE_ENV!=="production"&&o.options.debug&&console.info("correction",l),o._scrollToOffset(o.scrollOffset,{adjustments:o.scrollAdjustments+=l,behavior:void 0})),o.pendingMeasuredCacheIndexes.push(r.index),o.itemSizeCache=new Map(o.itemSizeCache.set(r.key,n)),o.notify());},this.measureElement=function(r){r&&o._measureElement(r,void 0);},this.getVirtualItems=ga(function(){return [o.getIndexes(),o.getMeasurements()]},function(r,n){for(var i=[],a=0,l=r.length;a<l;a++){var s=r[a],c=n[s];i.push(c);}return i},{key:process.env.NODE_ENV!=="production"&&"getIndexes",debug:function(){return o.options.debug}}),this.getVirtualItemForOffset=function(r){var n=o.getMeasurements();return wp(n[Nk(0,n.length-1,function(i){return wp(n[i]).start},r)])},this.getOffsetForAlignment=function(r,n){var i=o.getSize();n==="auto"&&(r<=o.scrollOffset?n="start":r>=o.scrollOffset+i?n="end":n="start"),n==="start"?r=r:n==="end"?r=r-i:n==="center"&&(r=r-i/2);var a=o.options.horizontal?"scrollWidth":"scrollHeight",l=o.scrollElement?"document"in o.scrollElement?o.scrollElement.document.documentElement[a]:o.scrollElement[a]:0,s=l-o.getSize();return Math.max(Math.min(s,r),0)},this.getOffsetForIndex=function(r,n){n===void 0&&(n="auto"),r=Math.max(0,Math.min(r,o.options.count-1));var i=wp(o.getMeasurements()[r]);if(n==="auto")if(i.end>=o.scrollOffset+o.getSize()-o.options.scrollPaddingEnd)n="end";else if(i.start<=o.scrollOffset+o.options.scrollPaddingStart)n="start";else return [o.scrollOffset,n];var a=n==="end"?i.end+o.options.scrollPaddingEnd:i.start-o.options.scrollPaddingStart;return [o.getOffsetForAlignment(a,n),n]},this.isDynamicMode=function(){return o.measureElementCache.size>0},this.cancelScrollToIndex=function(){o.scrollToIndexTimeoutId!==null&&(clearTimeout(o.scrollToIndexTimeoutId),o.scrollToIndexTimeoutId=null);},this.scrollToOffset=function(r,n){var i=n===void 0?{}:n,a=i.align,l=a===void 0?"start":a,s=i.behavior;o.cancelScrollToIndex(),s==="smooth"&&o.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),o._scrollToOffset(o.getOffsetForAlignment(r,l),{adjustments:void 0,behavior:s});},this.scrollToIndex=function(r,n){var i=n===void 0?{}:n,a=i.align,l=a===void 0?"auto":a,s=i.behavior;r=Math.max(0,Math.min(r,o.options.count-1)),o.cancelScrollToIndex(),s==="smooth"&&o.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");var c=o.getOffsetForIndex(r,l),u=c[0],d=c[1];o._scrollToOffset(u,{adjustments:void 0,behavior:s}),s!=="smooth"&&o.isDynamicMode()&&(o.scrollToIndexTimeoutId=setTimeout(function(){o.scrollToIndexTimeoutId=null;var m=o.measureElementCache.has(o.options.getItemKey(r));if(m){var g=o.getOffsetForIndex(r,d),f=g[0];Ok(f,o.scrollOffset)||o.scrollToIndex(r,{align:d,behavior:s});}else o.scrollToIndex(r,{align:d,behavior:s});}));},this.scrollBy=function(r,n){var i=n===void 0?{}:n,a=i.behavior;o.cancelScrollToIndex(),a==="smooth"&&o.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),o._scrollToOffset(o.scrollOffset+r,{adjustments:void 0,behavior:a});},this.getTotalSize=function(){var r;return (((r=o.getMeasurements()[o.options.count-1])==null?void 0:r.end)||o.options.paddingStart)-o.options.scrollMargin+o.options.paddingEnd},this._scrollToOffset=function(r,n){var i=n.adjustments,a=n.behavior;o.options.scrollToFn(r,{behavior:a,adjustments:i},o);},this.measure=function(){o.itemSizeCache=new Map,o.notify();},this.setOptions(t),this.scrollRect=this.options.initialRect,this.scrollOffset=this.options.initialOffset,this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(function(r){o.itemSizeCache.set(r.key,r.size);}),this.maybeNotify();},Nk=function(t,o,r,n){for(;t<=o;){var i=(t+o)/2|0,a=r(i);if(a<n)t=i+1;else if(a>n)o=i-1;else return i}return t>0?t-1:0};});function LF(e){var t=In.useReducer(function(){return {}},{})[1],o=fc({},e,{onChange:function(a){t(),e.onChange==null||e.onChange(a);}}),r=In.useState(function(){return new _k(o)}),n=r[0];return n.setOptions(o),In.useEffect(function(){return n._didMount()},[]),OF(function(){return n._willUpdate()}),n}function Rp(e){return LF(fc({observeElementRect:Mk,observeElementOffset:Bk,scrollToFn:Dk},e))}var OF,kg=N(()=>{p();Ak();Cg();Cg();OF=typeof document<"u"?In.useLayoutEffect:In.useEffect;});function Rg(e){let{allLabel:t,asComparison:o,colorKey:r,data:n,defaultValue:i,defaultValueType:a,hideLabel:l,resetSectionVars:s,iconKey:c,id:u,levels:d,limit:m,placeholder:g,searchIndexKey:f,searchIndexSeparator:h,section:v,settings:T}=e,{print:y}=ur(),C=jF(u),b=Tp(u,v,C,o,s==="true"),w=o?`${C}-valueCompare`:`${C}-value`,k=o?`${C}-typeCompare`:`${C}-type`,I=useMantineTheme(),[O,P]=useState(false),[_,D]=useState(true),[L,R]=useState(""),[z,A]=useState(false),[V,j]=useState([""].slice(1)),[B,U]=useState([]),[$,Y]=useState(""),F=T[_t.DISABLED]||false,G=useMemo(()=>y?Array.from(new Set(n.filter(Q=>B.includes(Q[`${$} ID`])))).map(Q=>Q?.[$]).join(", "):"",[y]),J=l==="true"||!e.label?jsx(Fragment,{}):jsx(ye,{component:"div",html:e.label,size:"sm",style:T}),ee=useRef(null),ne=useRef(false),X=useRef(!!m&&m<B.length),W=V.length,K=d[W],oe=V.filter(Boolean);V.length>0&&oe.length===0&&oe.push(`${t} ${K?.label}`),useEffect(()=>{if(!F){let M=new URLSearchParams(window.location.search),Q=M.get(w)||i,se=M.get(k)||a;Q&&se?(U(KF(Q,i)),Y(se)):(U([]),Y(""));}},[window.location.search,i,a,F]),useEffect(()=>{let M=()=>{D(true);};return window.addEventListener("touchmove",M),()=>{window.removeEventListener("touchmove",M);}},[]);let re=useMemo(()=>GF(n,d,r,c,f,h),[r,n,c,d,f,h]),ue=useMemo(()=>{let M=HF(L),Q=Array.from(WF(re,M)).reverse();return z?Q:V.reduce((se,Te)=>se.filter(fe=>!Te||fe.searchindex.indexOf(Te)>-1),Q.filter(se=>se.type===K?.value))},[K,re,L,z,V]),Ee=useRef(null),q=Rp({count:O?ue.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>Ee.current,[]),overscan:10,rangeExtractor:useCallback(M=>hc(M),[])}),[ce,de]=useState(-1),Se=Math.min(ce,ue.length-1),$e=useCallback(M=>{let Q=V.concat(M);z&&A(false),j(Q);},[z,V]),We=useCallback(()=>{let M=V.slice(0,W-1);z&&A(false),j(M);},[z,V,W]),Qe=useCallback(M=>{R(M.currentTarget.value),!X.current&&n.length>0&&P(true);},[n,R,X,P]),Co=useCallback(()=>{R(""),b([],""),ee.current?.focus(),m&&(X.current=false);},[R,b,ee,m,X]),Uo=useCallback(M=>{let Q=B.filter(se=>se!==M);Q.length>0?b(Q,$):b([],""),m&&Q.length<m&&(X.current=false);},[B,$,b,m,X]),po=useCallback(M=>{$!==M.type?b([M.value],M.type):B.includes(M.value)?Uo(M.value):m?(B.length<m&&b([...B,M.value],$),B.length===m&&b([...B.slice(1),M.value],$)):b([...B,M.value],$),R("");},[b,$,B,Uo,m]),gn=useCallback(()=>{B.length>0&&L.length===0&&(b(B.slice(0,-1),$),P(true),m&&(X.current=false)),L.length>0&&R(L.slice(0,-1));},[b,B,$,L,R,P,m,X]),Hn=useCallback(()=>{D(M=>M&&(ne.current=M,!M)),de(M=>M+1>=ue.length?M:M+1);},[de,ue]),Wn=useCallback(()=>{let M=ue[Se];M&&po(M);},[ue,Se,po]),jn=useCallback(()=>{P(false);},[P]),Kn=useCallback(()=>{We(),de(0);},[de,We]),Cl=useCallback(()=>{let M=ue[Se];!z&&M&&M.type!==d[d.length-1]?.value&&($e(M.name),de(0));},[ue,Se,z,d,de,$e]),kl=useCallback(()=>{D(M=>M&&(ne.current=M,!M)),de(M=>M-1<0?0:M-1);},[de]),te=({label:M,onRemove:Q,...se})=>jsxs("div",{style:{alignItems:"center",backgroundColor:I.colorScheme==="dark"?I.colors.dark[7]:I.colors.gray[1],borderRadius:I.radius.sm,cursor:"default",color:I.colorScheme==="dark"?I.colors.dark[0]:I.colors.gray[7],display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${I.spacing.xs} / 2 - ${rem(2)}) calc(${I.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${I.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...se,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:Q,radius:2,size:"sm",sx:{color:I.colorScheme==="dark"?I.colors.dark[0]:I.colors.gray[7],marginLeft:`calc(${I.spacing.sm} / 6)`},tabIndex:-1})]}),Oe=useMemo(()=>B.map(M=>re.find(Q=>Q.value===M)).filter(M=>!!M).map((M,Q)=>createElement(te,{...M,index:Q,label:M.label,key:M.value,onRemove:se=>{se.preventDefault(),se.stopPropagation(),Uo(M.value);}})),[B]),Ue=forwardRef(function({color:Q,icon:se,label:Te,value:fe,...St},ko){return jsx("div",{ref:ko,style:{cursor:"pointer",width:"100%"},...St,children:jsxs(Group,{align:"center",noWrap:true,spacing:"xs",w:"100%",children:[se&&jsx(Box,{bg:Q??"transparent",component:"img",w:20,h:20,src:se}),jsx(Text,{lineClamp:1,size:"sm",children:Te||fe})]})})});return jsxs(Fragment,{children:[jsx(MediaQuery,{query:"print",styles:{display:"none"},children:jsx(Input.Wrapper,{label:J,children:jsxs(Popover,{closeOnClickOutside:true,disabled:F,keepMounted:true,opened:O,onChange:P,onClose:()=>{de(0),R("");},onOpen:()=>{ue.length>0&&q.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>de(0),sx:{position:"relative","& .defaultValue":{backgroundColor:I.colorScheme==="dark"?I.colors.dark[5]:I.colors.gray[3],color:I.colorScheme==="dark"?I.colors.dark[1]:I.colors.gray[7]}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:B.join(",")}),jsx(Input,{component:"div",disabled:F,multiline:true,onMouseDown:M=>{M.preventDefault(),!X.current&&n.length>0&&P(!O),ee.current?.focus();},rightSection:B.length>0?jsx(CloseButton,{disabled:F,onClick:Co,onMouseDown:M=>M.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:I.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${I.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:I.colorScheme==="dark"?I.colors.dark[3]:I.colors.gray[5],opacity:1}},children:[Oe,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":O,onChange:Qe,onKeyDown:getHotkeyHandler([["ArrowDown",Hn],["ArrowLeft",Kn],["ArrowRight",Cl],["ArrowUp",kl],["Backspace",gn],["Enter",Wn],["Escape",jn]]),placeholder:B.length===0&&g||"",ref:ee,readOnly:X.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:I.fontSizes.sm,marginLeft:`calc(${I.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:L})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:M=>M.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:M=>M.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",spacing:"xs",w:"100%",children:[d.length>1&&jsxs(Stack,{spacing:"xs",children:[jsxs(Group,{onClick:M=>{M.stopPropagation();},px:"xs",position:"center",spacing:"xs",children:[jsx(Button,{onClick:()=>{de(0),A(true),j([]),ue.length>0&&q.scrollToIndex(0);},size:"xs",variant:z?"filled":"outline",children:t}),d.map((M,Q)=>jsx(Button,{onClick:()=>{z&&A(false);let se=[""].slice(1),Te=Q;for(;Te--;)se[Te]=V[Te]||"";de(0),j(se),ue.length>0&&q.scrollToIndex(0);},size:"xs",variant:!z&&V.length===d.findIndex(se=>se.value===M?.value)?"filled":"outline",children:M?.label},M?.value))]}),jsx(Divider,{})]}),W>0&&jsxs(Group,{align:"center",noWrap:true,px:"xs",children:[jsx(ActionIcon,{onClick:We,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:oe.map(M=>jsx(Text,{lineClamp:1,size:"xs",children:M},`${M}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>D(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:Ee,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${q.getTotalSize()}px`,position:"relative",width:"100%"},children:q.getVirtualItems().map(M=>{let Q=ue[M.index],se=Se===M.index,Te=B.includes(Q.value);return ue.length>0&&se&&!_&&q.scrollToIndex(Se),jsxs(Group,{"aria-selected":se,align:"center","data-hovered":se||void 0,"data-index":M.index,"data-selected":Te,id:Q.vale,noWrap:true,onMouseEnter:fe=>{fe.preventDefault(),fe.stopPropagation(),_&&(de(M.index),D(false));},onMouseMove:fe=>{fe.preventDefault(),fe.stopPropagation(),D(true);},onMouseDown:fe=>{fe.preventDefault(),po(Q);},position:"apart",ref:q.measureElement,role:"option",spacing:"xs",sx:fe=>({borderRadius:fe.radius.xs,padding:"15px 5px 15px",paddingLeft:z&&10*d.findIndex(St=>St?.value===Q.type)||5,position:"absolute",top:0,left:0,height:`${M.size}px`,transform:`translateY(${M.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:fe.colorScheme==="dark"?fe.colors.dark[4]:fe.colors.gray[1]},"&:hover":{backgroundColor:fe.colorScheme==="dark"?fe.colors.dark[4]:fe.colors.gray[1]}}),tabIndex:-1,children:[jsx(Ue,{index:M.index,...Q}),!z&&Q.type!==d[d.length-1]?.value&&jsx(ActionIcon,{onMouseDown:fe=>{fe.preventDefault(),fe.stopPropagation(),$e(Q.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},Q.value)})})})]})})})})]})})}),y&&jsxs(Text,{children:[J,": ",G]})]})}var GF,HF,WF,jF,KF,Wk=N(()=>{p();kg();ft();Rn();io();he();GF=(e=[],t=[],o="",r="",n="",i="|")=>{let a=t.map(h=>h.value).slice(),l=`${a.pop()}`,s=h=>h[o],c=h=>h[r],u=h=>{if(h[n])return typeof h[n]=="string"?h[n].split(i):h[n]},d=new Set,m=[],g=[],f=nest().rollup(h=>{let v=h[0],T=P=>P&&P.value&&!d.has(P.value),y=a.map(P=>v[`${P} ID`]),C=a.map(P=>v[P]),b=a.map((P,_)=>{if(g[_]!==C[_]){g[_]=C[_];let D=s[_]||s[s.length-1]||s,L=c[_]||c[c.length-1]||c,R=u[_]||u[u.length-1]||u;return {color:D(v,P)||void 0,icon:L(v,P)||void 0,value:`${y[_]}`,label:C[_],name:C[_],type:P,searchindex:C.slice(0,_+1).concat(R(v,P)).join("|")}}return {}}).filter(T);b.forEach(P=>d.add(P.value));let w=s[s.length-1]||s,k=c[c.length-1]||c,I=u[u.length-1]||u,O=h.map(P=>({color:w(P,l)||void 0,icon:k(P,l)||void 0,value:`${P[`${l} ID`]}`,label:P[l],name:P[l],type:l,searchindex:C.concat(P[l]).concat(I(P,l)).join("|")}));m.push(...b.concat(O));});return a.forEach(h=>{f.key(v=>`${v[`${h} ID`]}|${v[h]}`);}),f.entries(e),m},HF=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},WF=(e,t)=>{let o=e.length,r,n=l=>r&&r.searchindex.includes(l.searchindex),a={next:()=>{for(let l=o-1;l>-1;l--){let s=e[l];if(t.test(`${s.value} ${s.label} ${s.searchindex}`)||n(s))return r=s,o=l,{done:false,value:s}}return {done:true,value:void 0}},[Symbol.iterator]:()=>a};return a},jF=e=>`multihierarchySelector${e}`,KF=(e,t)=>e&&typeof e=="string"?e.split(","):t;});function Ig({headings:e,settings:t,type:o,title:r,shortTitle:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:c,_iconPadding:u}){let{min:d="1",max:m="6",icons:g="yes"}=t||{},f=ia(parseInt(d,10),parseInt(m,10),e),h=g==="yes",v=He(r)||"",T=He(n||r)||"",y=v&&v.length>0,C=i&&i!=="none",w=`(max-width: ${useMantineTheme().breakpoints.md})`,k=useMediaQuery(w),I=k?T:v,O=t&&t.align?String(t.align):"left",P=Is(O),_=ro(O),D=Oo(O),L=t&&t.titlePosition?String(t.titlePosition):"left",R=useMemo(()=>{let j={right:"left",left:"right"},B=y&&["left","right"].includes(L),U={};if(B){let $=L==="right";U={spacing:"xs",position:$&&j[_]?j[_]:_,style:{flexDirection:$?"row-reverse":"row"},noWrap:true};}else U={spacing:"xs",align:D,justify:"center",style:{flexDirection:L==="bottom"?"column-reverse":"column"}};return {element:B?Group:Stack,props:U}},[y,_,D,L]),z=useMemo(()=>y?jsxs(Group,{spacing:"xs",position:_,noWrap:true,children:[C&&jsx(Ke,{blockType:"title",iconType:i,iconVariant:a,iconRadius:s,iconSize:c,icon:l,iconPadding:u}),jsx(ye,{style:{...t},html:I,lineClamp:1})]}):null,[y,C,_,I]),A=useMemo(()=>k?jsx(eV,{contentOutline:f,showIcons:h,titleElement:z,wrapper:R}):null,[k,z,R]),V=useMemo(()=>k?null:o==="multilevel"?jsx(tV,{contentOutline:f,showIcons:h,align:P}):jsx(ZF,{contentOutline:f,showIcons:h,align:P}),[f,h,P,k]);return jsxs(Fragment,{children:[k&&A,!k&&jsxs(R.element,{pos:"relative",...R.props,children:[y&&z,V]})]})}var Kk,ZF,eE,eV,tV,tE=N(()=>{p();io();wn();no();Kr();wn();ft();Kk=e=>t=>({display:"flex",gap:t.spacing.md,justifyContent:e,listStyleType:"none"}),ZF=({contentOutline:e,showIcons:t,align:o})=>{let[r,n]=useState(null);useEffect(()=>{let a=()=>{let l=document.querySelector(".bespoke-nav");if(!l)return;let s=l.getBoundingClientRect(),c=false;e.forEach(u=>{let d=document.getElementById(`bespoke-title-${u.id}`);d&&d.getBoundingClientRect().top<=s.bottom&&(n(u.id),c=true);}),c||n(null);};return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a);}},[e]);let i=a=>!a||!a?.length?null:jsx(Fragment,{children:a.map(l=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${l.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(Ke,{...l.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:l.label}})]})})}),jsx(Box,{pl:"xs",children:i(l.children)})]},l.id))});return jsx(Fragment,{children:jsx(Box,{component:"nav",className:"bespoke-nav",children:jsx(List,{sx:a=>({display:"flex",gap:a.spacing.md,justifyContent:o,listStyleType:"none"}),children:e?.map(a=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:200,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${a.id}`,"data-active":a.id===r,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(Ke,{...a.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:a.label}})]})})}),a?.children?.length?jsx(Menu.Dropdown,{children:i(a.children)}):null]})},a.id))})})})},eE=({contentOutline:e,closeNav:t,showIcons:o})=>{let[r,n]=useState(null);return jsx(Stack,{children:e.map(i=>i.children.length?jsxs(Fragment,{children:[jsxs(Group,{spacing:0,noWrap:true,children:[jsx(UnstyledButton,{w:"100%",component:"a",onClick:t,href:`#bespoke-title-${i.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[o&&jsx(Ke,{...i.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:i.label}})]})},i.id),jsx(ActionIcon,{component:"a",size:"lg",onClick:()=>n(a=>a===i.id?null:i.id),children:jsx(IconChevronDown,{style:{transition:"transform 0.2s",transform:r===i.id?"rotate(-180deg)":"none"},stroke:1})})]},i.id),jsx(Collapse,{in:r===i.id,pl:"sm",transitionTimingFunction:"linear",transitionDuration:200,children:jsx(eE,{contentOutline:i.children,closeNav:t,showIcons:o})})]}):jsx(Group,{noWrap:true,children:jsx(UnstyledButton,{display:"flex",w:"100%",component:"a",href:`#bespoke-title-${i.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[o&&jsx(Ke,{...i.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:i.label}})]})},i.id)},i.id))})},eV=({contentOutline:e,showIcons:t,titleElement:o,wrapper:r})=>{let[n,{toggle:i}]=useDisclosure(false),a=n?"Close content outline":"Open content outline";return jsxs(Box,{className:"bespoke-mobile-nav",component:"nav",children:[jsxs(r.element,{className:"bespoke-mobile-nav-header",...r.props,onClick:i,children:[o&&o,jsx(ActionIcon,{className:"bespoke-mobile-nav-toggle","aria-label":a,size:"lg",variant:"subtle",children:n?jsx(IconChevronUp,{size:"xl",stroke:1.5}):jsx(IconChevronDown,{size:"xl",stroke:1.5})})]}),jsx(Collapse,{in:n,mt:"md",className:"bespoke-mobile-nav-body",children:jsx(eE,{contentOutline:e,closeNav:i,showIcons:t})})]})},tV=({contentOutline:e,showIcons:t,align:o})=>{let[r,n]=useState(null),[i,a]=useState(null);useEffect(()=>{let s=()=>{let c=document.querySelector(".bespoke-nav");if(!c)return;let u=c.getBoundingClientRect(),d=false;e.forEach(m=>{let g=document.getElementById(`bespoke-title-${m.id}`);g&&(g.getBoundingClientRect().top<=u.bottom&&(n(m.id),a(null),d=true),m.children.forEach(h=>{let v=document.getElementById(`bespoke-title-${h.id}`);v&&v.getBoundingClientRect().top<=u.bottom&&(a(h.id),n(m.id),d=true);}));}),d||(n(null),a(null));};return window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s);}},[e]);let l=s=>!s||!s?.length?null:jsx(Fragment,{children:s.map(c=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${c.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(Ke,{...c.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:c.label}})]})})}),jsx(Box,{pl:"xs",children:l(c.children)})]},c.id))});return jsxs(Box,{component:"nav",className:"bespoke-nav",children:[jsx(List,{className:"bespoke-nav-level1",sx:Kk(o),children:e?.map(s=>jsx(List.Item,{children:jsx(Anchor,{href:`#bespoke-title-${s.id}`,"data-active":r===s.id,onClick:()=>n(s.id),children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(Ke,{...s.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:s.label}})]})})},s.id))}),r&&e.find(s=>s.id===r)?.children.length>0&&jsx(List,{className:"bespoke-nav-level2",sx:Kk(o),children:e.find(s=>s.id===r)?.children.map(s=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:200,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${s.id}`,"data-active":s.id===i,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(Ke,{...s.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:s.label}})]})})}),s?.children?.length?jsx(Menu.Dropdown,{children:l(s.children)}):null]})},s.id))})]})};});function Pg(e){let{related_reports:t,settings:o}=e,r=H(m=>m.status.currentLocale),n=H(m=>m.status.localeDefault),i=os(),a=useRouter(),{components:l}=Lo();if(!t?.length)return;let s=r===n?"":`/${r}`,c=m=>{a.push(`${m}`);},u=l?.ReportTile?l.ReportTile:pg,d=Oo(o&&o.align?String(o.align):"center");return jsx(Grid,{justify:d,children:t.map(m=>{let g=`${s}${i}${m.link}`,f=m.entities.map(C=>({original_id:C.id,name:C.name,id:C.content_id,variant:C.variant_name,variant_id:C.variant_id,dimension:C.dimension_name,dimension_id:C.dimension_id,image:{src:`/api/cms/member/image?member=${C.content_id}&size=thumb`,alt:C.name}})),h=m.entities.map(C=>C.id).join("-"),v=m.entities.map(C=>C.name).join(" & "),T=m.entities[0]?m.entities[0].report_id:null,y=C=>{C.preventDefault(),c(g);};return jsx(Grid.Col,{xs:12,sm:6,md:4,lg:4,xl:3,children:jsx(u,{reportId:T,reportName:v,members:f,href:g,onClick:y})},h)})})}var rE=N(()=>{p();ae();xe();dg();io();no();});function Og({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:i}){let a=tt(e).data,{sectionVariables:l,resetSectionVariables:s}=pt(a?.section_id),c=!!Object.keys(l).length,u=Oo(o&&o.align?o.align:"left");return !c&&!i?null:jsx(Button,{onClick:()=>s(),disabled:!c,fullWidth:n,sx:{justifySelf:u},children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})}var iE=N(()=>{p();xe();no();});function Lg({settings:e,label:t,removeLabel:o,showIcon:r,position:n="center",asComparison:i=false}){let a=H(C=>C.records.entities.report),l=H(C=>C.variables.attributes),s=e&&e.search?e.search:"inline",c=Object.values(a)[0].settings,u=useRouter(),{comparisonLoaded:d,loading:m}=Lr(),g=Object.keys(u.query).includes("compare"),h=d&&g?jsx(Button,{onClick:()=>{let C={...u.query};delete C.compare,u.push({pathname:u.pathname,query:C},void 0,{shallow:true});},rightIcon:jsx(IconX,{}),children:o||"Remove Comparison"}):jsx(Button,{loading:m,children:jsxs(Group,{align:"center",children:[t||"Add Comparison",r&&jsx(IconPlus,{})]})}),v={searchReportParams:{report:[Number(Object.keys(a)[0])],variant:c.compareLevels?[]:[l.variant_id1]}},y=Ms(h,s,C=>{u.push({pathname:u.pathname,query:{...u.query,compare:C.reportPath}});},v);return i?null:jsx(Group,{position:n,children:g?h:y})}var lE=N(()=>{p();io();ae();li();});function Bg({columns:e=[],data:t=[],tableProps:o={},sectionId:r=null}){let[n,i]=useState(false),[a,l]=useState({}),s=useMemo(()=>e.map(m=>m.accessorKey),[e]),c=useMemo(()=>t.filter(m=>typeof m=="object"&&m!==null&&!Array.isArray(m)&&Object.keys(m).some(g=>s.includes(g))),[s,t]),u=useMemo(()=>e.map(m=>({...m,Cell:({renderedCellValue:g})=>jsx(ye,{html:`${g}`}),filterFn:"contains"})),[e]),{locale:d}=useRouter();return useEffect(()=>{(async()=>{try{let g=d||"en",f=`${g.toUpperCase()}`,h=await import(`mantine-react-table/locales/${g}.js`);l(h[`MRT_Localization_${f}`]);}catch(g){console.error("Error loading translations:",g);}})();},[d]),jsx(MantineReactTable,{...o,autoResetPageIndex:false,columns:u,data:c,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",layoutMode:"grid",localization:a,onIsFullScreenChange:m=>{let g=document.getElementById(`section-${r}`);g&&(m?g.style.zIndex="10":g.style.zIndex="1"),i(m);},state:{...o.state,isFullScreen:n}})}var pE=N(()=>{p();ft();});function Dg({label:e,url:t,settings:o}){let{align:r}=o;return e?jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})}):null}var mE=N(()=>{p();});function SV({block:e}){let{id:t}=e;return jsxs(Stack,{align:"center",spacing:"sm",children:[jsx(ThemeIcon,{radius:"md",size:100,children:jsx(IconCircleKey,{size:100})}),jsxs(Title,{order:5,children:["Private content (Block ",t,")"]}),jsx(Text,{children:"Sorry, you do not have sufficient permissions to view this block."}),jsx(Text,{children:"Contact your account manager to check your access role."})]})}function _g(e){let t=xV();return jsx(t,{block:e})}var xV,hE=N(()=>{p();io();xV=()=>{let{components:e}=Lo(),t=SV;return e?.CustomFallback&&(t=e.CustomFallback),t};});var An,Bp=N(()=>{p();An=class extends In__default.Component{constructor(t){super(t),this.state={hasError:false};}static getDerivedStateFromError(t){return console.info("getDerivedStateFromError",t),{hasError:true}}componentDidCatch(t,o){console.error("Error information:",o.componentStack),notifications.show({autoClose:false,color:"red",id:"revalidate-error",message:"Check the console for more details",title:t.message});}render(){return this.state.hasError?this.props.fallback:this.props.children}};});var vE={};bm(vE,{default:()=>yE});function yE(e){let{print:t}=ur(),{block:o,active:r,locale:n,variables:i,configOverride:a={}}=e,l=Eo(o),s=Ao(n),c={variables:i},u=useRouter(),{sectionVariables:d,setSectionVariables:m,resetSectionVariables:g}=pt(o.section_id),f=xn(),h=Pe(),v=JSON.stringify(d),T=useMemo(()=>{if(!l?.logic)return {error:"Add a Configuration"};let I=Tr({logic:l.logic},s,c).logic,O={router:u,section:{variables:d,setVariables:m,resetVariables:g}};return da(I,s,i,n,o.id,{},O,f,h)},[o,r,i,v,h.status]),{type:y}=T.config||{},C=y&&Ng[y]?y:"Treemap";Ng[y]||(T.config={error:`"${y}" is not a valid Visualization Type`});let b=Ng[C],w=useMemo(()=>{let{_data:I,...O}=T.config;return wV(O,t)},[T,t]),k={locale:n,variables:i,...w,...a};return jsx("div",{className:"bespoke-Viz","data-ignore-print":k._printIgnore?"true":void 0,children:jsx("div",{style:{display:"flex",flex:"1 1 100%",minHeight:y===ma?void 0:400},children:jsx(An,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(b,{style:{flex:1},dataFormat:I=>{let O;try{O=T.dataFormat(I);}catch(P){console.error("Error in dataFormat: ",P),O=[];}return O},linksFormat:T.linksFormat,nodesFormat:T.nodesFormat,topojsonFormat:T.topojsonFormat,config:{...k,sectionVariables:v}},"viz-key")})})})}var Ng,wV,SE=N(()=>{p();Wo();cc();Vi();xe();dt();Bp();Rn();yp();Ng={...kV,[ma]:bp},wV=(e,t)=>{let o={...e};return t&&(o.detectResize=false,o.detectResizeDelay=0,o.detectVisible=false,o.detectVisibleInterval=0,o.duration=0,o.shapeConfig={...o.shapeConfig,duration:0}),o};});var IV,xE=N(()=>{p();he();OT();MT();DT();Tk();wk();Rk();Ik();Wk();tE();rE();iE();lE();pE();mE();hE();IV=RV(()=>Promise.resolve().then(()=>(SE(),vE)),{ssr:false}),{[E.PARAGRAPH]:Jf,[E.STAT]:Zf,[E.SUBTITLE]:eg,[E.TITLE]:bg,[E.SELECTOR]:xg,[E.VIZ]:IV,[E.GENERATOR]:Ep,[E.SECTION_FLAG]:Ep,[E.IMAGE]:Tg,[E.NAV]:Ig,[E.RELATED]:Pg,[E.RESET_BUTTON]:Og,[E.COMPARISON_BUTTON]:Lg,[E.TABLE]:Bg,[E.BUTTON]:Dg,[E.MULTIHIERARCHY_SELECTOR]:Rg,[E.FALLBACK]:_g};});var TE=N(()=>{p();he();xE();_s();Wo();xe();Ur();qa();Bl();Pm();Lm();li();});var ba,AV,Dp,Cc=N(()=>{p();ba={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"}]}},AV=Object.keys(ba).reduce((e,t)=>(e[t]=ba[t].defaultValue,e),{}),{memberImageBg:false,optionsMenu:false,optionData:true,optionImage:true,optionShare:true,showAnchor:false,...AV},Dp=e=>({data:typeof e.optionData=="boolean"?e.optionData:true,image:typeof e.optionImage=="boolean"?e.optionImage:true,share:typeof e.optionShare=="boolean"?e.optionShare:true});});function Fg({previews:e}){let t=e.map((o,r)=>({key:o?`bg-${o.content_id}`:`bg-${r}`,src:o?`/api/cms/member/image?member=${o.content_id}&size=splash`:""}));return jsxs(Fragment,{children:[jsx(Group,{className:"cms-section-bg",grow:true,spacing:0,style:{position:"absolute",width:"100%",height:"100%"},children:t.map(o=>jsx("div",{className:"cms-section-member-bg",style:{backgroundImage:`url(${o.src})`,backgroundSize:"cover",backgroundPosition:"center center",height:"100%",width:"100%"}},o.key))}),jsx("div",{className:"cms-section-gradient-bg",style:{background:"white",position:"absolute",width:"100%",height:"100%",opacity:.33}})]})}var Vg=N(()=>{p();});function Ug(e){let{section:t}=e,o=t.blocks||[],r=H(X=>o.map(W=>({...X.records.entities.block[W],status:X.variables.status[W]})).filter(W=>W.type===E.VIZ&&W.status.allowed)),{variant_slug1:n,slug1:i}=H(X=>X.variables.attributes),a=ii(),[l,s]=useState(Br.section),[c,u]=useState(Dr.png),[d,m]=useState(false),[g,f]=useState(false),[h,v]=useState([]),[T,y]=useState(r.length>0?r[0].id:null),C=l!==Br.section,{print:b,downloadLoading:w}=gf(t.id,n,i,C?T:null),[k,I]=useState(true),[O,P]=useState(false),_=bo("options"),D={...JV,..._.image_tab},{siteProps:L}=is(),R=L?.logoSrc&&typeof L.logoSrc=="string",z=useMemo(()=>t?.settings?.name?Tt(t?.settings?.name):`section-${t.id}`,[t.id,t?.settings?.name]),A=`#${z}`,V=useMantineTheme(),j=()=>{let X=$(T);return select(X).select("svg").size()===1},B=()=>`${Tt(z)}`,U=()=>{let X=document.getElementById(z);return select(X).select(".bespoke-section-content").node()},$=X=>{let W=U();return select(W).select(`#bespoke-visualization-${X}.bespoke-block-area`).node()},Y=()=>new Promise(X=>{let W;l===Br.section?W=U():l===Br.viz&&(W=$(T));let K=document.createElement("div");K.style.display="flex",K.style.justifyContent="space-between",K.classList.add("bespoke-share-source"),K.style.padding=V.spacing.xs,K.style.width="100%";let oe=document.createElement("div");if(oe.innerText=D.source.replace("{src}",`${window.location}${A}`),oe.style.fontSize=V.fontSizes.xs,K.appendChild(oe),R){let re=document.createElement("img");re.src=L.logoSrc,re.style.height="30px",re.onload=()=>X(W),re.onerror=()=>{re.remove(),X(W);},K.appendChild(re),W.appendChild(K);}else W.appendChild(K),X(W);}),F=X=>{if(k)return "transparent";let W=select(X).style("background-color");return W!=="rgba(0, 0, 0, 0)"&&W!=="transparent"?W:X===document.body?"white":F(X.parentNode)},G=async(X,W)=>{let{toPng:K}=await import('html-to-image');K(X,{backgroundColor:W.background,cacheBust:true,filter:oe=>oe&&oe.classList?!W.exclusionClasses.some(re=>oe.classList.contains(re)):true}).then(oe=>{let re=document.createElement("a");re.download=`${W.filename}.png`,re.href=oe,re.click();}).catch(oe=>{console.error("Error generating image",oe);}).finally(()=>{XV(),m(false);});},J=(X,W)=>{saveElement(X,{filename:W.filename,type:"svg",callback:()=>m(false)},{background:W.background});},ee=async()=>{m(true);let X=await Y(),W={background:F(X),exclusionClasses:["export-hidden"],filename:B()},K=c===Dr.png?G:J;try{if(X)K(X,W);else throw new Error(D.wrong_node)}catch{m(false);}},ne=async()=>{let{toCanvas:X}=await import('html-to-image');Promise.all(r.map(W=>{let K=$(W.id),oe=K.querySelector("g.d3plus-geomap-tileGroup");oe&&(oe.style.display="none");let re=select(K).select("svg").select("g").size()>0,ue=select(K).select("div.bespoke-html").size()>0,Ee=re||ue?K:QV();return X(Ee).then(q=>(oe&&(oe.style.display="block"),q))})).then(W=>{v(W.map(K=>K.toDataURL())),P(false);});};return useEffect(()=>{l===Br.viz&&r.length>0?(y(r[0].id),P(true),ne()):l===Br.section&&v([]);},[l]),useEffect(()=>{T&&(j()?f(true):(f(false),u(Dr.png)));},[T]),jsxs(Stack,{className:"cms-section-options-image",children:[r.length>0?jsx(Input.Wrapper,{label:`${D.choose_area}:`,children:jsx(SegmentedControl,{fullWidth:true,value:l,data:[{value:Br.section,label:jsxs(Center,{children:[jsx(IconTemplate,{size:"1rem"}),jsx(Box,{ml:10,children:D.entire_section})]})},{value:Br.viz,label:jsxs(Center,{children:[jsx(IconChartBar,{size:"1rem"}),jsx(Box,{ml:10,children:D.viz_only})]})}],onChange:X=>{s(X),X===Br.section&&u(Dr.png);}})}):jsx(Text,{fw:"700",color:"gray.7",children:`${D.entire_section}:`}),l===Br.viz&&r.length>0&&jsxs(Input.Wrapper,{label:`${D.choose_viz}:`,style:{minHeight:"161px",position:"relative"},children:[!O&&h.length>0&&jsx(ScrollArea,{style:{height:250},children:jsx(SimpleGrid,{cols:3,children:r.map((X,W)=>jsx(Image,{alt:`Viz ${X.id}`,onClick:()=>{y(X.id);},style:{cursor:"pointer",border:T===X.id?"4px solid #228be6":"4px solid #eee"},radius:0,src:h[W],withPlaceholder:true,styles:()=>({figure:{height:"100%"},imageWrapper:{height:"100%"}})},`viz-option-${X.id}`))})}),jsx(LoadingOverlay,{visible:O})]}),g&&l!==Br.section&&jsx(Input.Wrapper,{label:`${D.choose_format}:`,children:jsxs(Button.Group,{children:[jsx(Button,{leftIcon:jsx(IconPolaroid,{size:16}),onClick:()=>u(Dr.png),variant:c===Dr.png?"filled":"default",fullWidth:true,children:Dr.png}),jsx(Button,{leftIcon:jsx(IconCode,{size:16}),onClick:()=>u(Dr.svg),variant:c===Dr.svg?"filled":"default",fullWidth:true,children:Dr.svg})]})}),jsx(Checkbox,{checked:k,label:`${D.transparent_bg}`,onChange:()=>I(!k),radius:"xl"}),jsx(Button,{leftIcon:jsx(IconDownload,{size:16}),loading:d||w,onClick:a&&c!==Dr.svg?()=>b(k):ee,fullWidth:true,children:jsx("span",{children:d||w?D.processing:D.download.replace("{imageFormat}",c)})})]})}var Br,Dr,XV,JV,QV,wE=N(()=>{p();jr();ae();Yr();Pt();st();he();Br={viz:"viz",section:"section"},Dr={png:"PNG",svg:"SVG"},XV=()=>{let e=document.getElementsByClassName("bespoke-share-source");Array.from(e).forEach(t=>t.remove());},JV={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}"},QV=()=>document.createElement("div");});function IE(e){let{title:t,url:o,disabled:r=false}=e,n=r?IconCode:IconLink;return jsx(Input.Wrapper,{label:t,children:jsx(Input,{icon:jsx(n,{}),value:o,disabled:r,readOnly:true,rightSection:jsx(CopyButton,{value:o,timeout:2e3,children:({copied:i,copy:a})=>jsx(Tooltip,{label:i?"Copied":"Copy",withArrow:true,position:"right",children:jsx(ActionIcon,{variant:i?"filled":"subtle",onClick:a,disabled:r,children:i?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})})})}var AE=N(()=>{p();});function Hg(e){let{section:t}=e,[o,r]=useState(""),[n,i]=useState(""),[a,l]=useState(true),s=bo("options"),c={...k$,...s.share_tab};return useEffect(()=>{i(document.title);let{origin:u,pathname:d}=window.location,m=`${u}${d}`,g=a?t.settings?.name?.length?`#${Tt(t.settings.name)}`:`#section-${t.id}`:"";r(`${m}${g}`);},[a]),jsxs(Stack,{className:"cms-section-options-share",children:[jsx(IE,{title:`${c.title}: ${n}`,url:o}),jsx(Checkbox,{checked:a,label:c.include_section,onChange:()=>l(!a),radius:"xl"}),jsxs(Group,{position:"center",children:[jsx(FacebookShareButton,{url:o,children:jsx(FacebookIcon,{size:32,round:true})}),jsx(TwitterShareButton,{url:o,title:n,children:jsx(TwitterIcon,{size:32,round:true})}),jsx(TelegramShareButton,{url:o,title:n,children:jsx(TelegramIcon,{size:32,round:true})}),jsx(WhatsappShareButton,{url:o,title:n,separator:":: ",children:jsx(WhatsappIcon,{size:32,round:true})}),jsx(LinkedinShareButton,{url:o,children:jsx(LinkedinIcon,{size:32,round:true})}),jsx(RedditShareButton,{url:o,title:n,windowWidth:660,windowHeight:460,children:jsx(RedditIcon,{size:32,round:true})}),jsx(EmailShareButton,{url:o,subject:n,children:jsx(EmailIcon,{size:32,round:true})})]})]})}var k$,OE=N(()=>{p();AE();Yr();jr();k$={title:"Title",include_section:"Include Section"};});function L$({panels:e,value:t,onTabChange:o}){let r=useRef(null),[n,i]=useState(false),[a,l]=useState(false),s=Object.keys(e),c=()=>{let d=r.current;if(!d)return;let{scrollLeft:m,scrollWidth:g,clientWidth:f}=d;i(m>0),l(m<g-f);};useEffect(()=>{let d=r.current;if(d)return c(),d.addEventListener("scroll",c),()=>{d.removeEventListener("scroll",c);}},[]);let u=d=>{let m=r.current;if(!m)return;let g=d==="left"?-150:150;m.scrollBy({left:g,behavior:"smooth"});};return jsxs(Box,{className:"bespoke-report-modal-tabs-container",pos:"relative",sx:{flexGrow:1,maxWidth:"calc(100% - 38px)"},children:[jsx(Box,{"data-direction":"left",display:n?"flex":"none",sx:ME,children:jsx(ActionIcon,{onClick:()=>u("left"),children:jsx(IconChevronLeft,{size:20})})}),jsx(Tabs,{ref:r,value:t,onTabChange:o,sx:O$,children:jsx(Tabs.List,{className:"bespoke-report-modal-tabs",sx:{flexWrap:"nowrap",width:"fit-content"},children:s.map(d=>jsx(Tabs.Tab,{className:"bespoke-report-modal-tab",value:d,children:e[d].label},d))})}),jsx(Box,{display:a?"flex":"none","data-direction":"right",sx:ME,children:jsx(ActionIcon,{onClick:()=>u("right"),children:jsx(IconChevronRight,{size:20})})})]})}function M$({className:e,opened:t,onClose:o,panels:r}){let[n,i]=useState(Object.keys(r)[0]);return jsxs(Modal.Root,{className:clsx("bespoke-report-modal",e),opened:t,onClose:o,size:"xl",centered:true,children:[jsx(Modal.Overlay,{className:"bespoke-report-modal-overlay"}),jsxs(Modal.Content,{children:[jsx(Modal.Header,{className:"bespoke-report-modal-header",children:jsxs(Group,{w:"100%",position:"apart",spacing:"md",noWrap:true,children:[jsx(L$,{panels:r,value:n,onTabChange:a=>a&&i(a)}),jsx(Modal.CloseButton,{className:"bespoke-report-modal-close-btn",ml:0})]})}),jsx(Modal.Body,{className:"bespoke-report-modal-body",children:r[n].component})]})]})}var O$,ME,qg,Yg=N(()=>{p();O$={overflowX:"auto",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",flexWrap:"nowrap"},ME={height:"100%",zIndex:1,top:0,width:50,position:"absolute",backgroundSize:"cover",display:"flex",alignItems:"center","&[data-direction='left']":{background:"linear-gradient(to right, rgba(255, 255, 255, 1) 15px, rgba(255, 255, 255, 0))",left:0,justifyContent:"flex-start"},"&[data-direction='right']":{background:"linear-gradient(to left, rgba(255, 255, 255, 1) 15px, rgba(255, 255, 255, 0))",right:0,justifyContent:"flex-end"}};qg=M$;});function _E(e){let{section:t,initialMode:o,onEnds:r,open:n,title:i}=e,a=Dp(t.settings),l=useMemo(()=>_$.filter(g=>a[g]),[a]),[s,c]=useState(o||l[0]||"data"),u=bo("options");useEffect(()=>{o!==s&&c(o);},[o]);let d={...Xg,...u};useMemo(()=>jsxs(Fragment,{children:[jsxs(Tabs.List,{children:[a.data&&jsx(Tabs.Tab,{value:"data",children:d.download_title}),a.image&&jsx(Tabs.Tab,{value:"image",children:d.image_title}),a.share&&jsx(Tabs.Tab,{value:"share",children:d.share_title})]}),a.data&&jsx(Tabs.Panel,{value:"data",children:jsx(lg,{section:t})}),a.image&&jsx(Tabs.Panel,{value:"image",children:jsx(Ug,{section:t})}),a.share&&jsx(Tabs.Panel,{value:"share",children:jsx(Hg,{section:t})})]}),[a,t,d]);return jsx(qg,{className:"cms-section-options-modal",opened:n,onClose:()=>r(),panels:{data:{label:d.download_title,component:jsx(lg,{section:t})},image:{label:d.image_title,component:jsx(Ug,{section:t})},share:{label:d.share_title,component:jsx(Hg,{section:t})}}})}var Xg,_$,NE=N(()=>{p();cg();wE();OE();Yr();Cc();Yg();Xg={download_title:"Download Data",image_title:"Save Image",share_title:"Share Link"},_$=["data","image","share"];});function Jg(e){let{sectionId:t,disabled:o=false}=e,[r,n]=useState(false),[i,a]=useState("data"),l=qo(t),s=bo("options"),c={...Xg,...s},u=Dp(l.isSuccess?l.data.settings:{}),d=g=>{a(g),n(true);},m=()=>{n(false);};return jsxs("div",{className:"cms-section-options",children:[jsxs(Button.Group,{children:[u.data&&jsx(Button,{variant:"default",size:"xs",compact:true,onClick:()=>d("data"),"aria-label":c.download_title,disabled:o,children:jsx(IconTable,{size:16})}),u.image&&jsx(Button,{variant:"default",size:"xs",compact:true,onClick:()=>d("image"),"aria-label":c.image_title,disabled:o,children:jsx(IconCamera,{size:16})}),u.share&&jsx(Button,{variant:"default",size:"xs",compact:true,onClick:()=>d("share"),"aria-label":c.share_title,disabled:o,children:jsx(IconShare,{size:16})})]}),l.isSuccess&&jsx(_E,{section:l.data,initialMode:i,open:r,onEnds:m})]})}var Qg=N(()=>{p();NE();ae();Yr();Cc();});function j$({children:e,containerProps:t},o){return jsx(Flex,{ref:o,className:"bespoke-section-content",pos:"relative",align:"stretch",p:0,direction:{base:"column",md:"row"},wrap:"wrap",...t,children:e})}var Zg,UE,eh,th=N(()=>{p();ae();Tn();Zg=In__default.forwardRef(function({children:t,column:o,basis:r,columnSettings:n={},sx:i={},...a},l){let s=Object.values(o).some(m=>m.settings?.display==="inline"),c=n?.width?`${n.width}px`:r,u=n?.width?`${n?.width}px`:"100%",d=n?.full?"100%":u;return jsx(Flex,{ref:l,className:"bespoke-section-col",align:"flex-start",direction:s?"row":"column",wrap:s?"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%":c},...packSx(i)],...a,children:t})}),UE=({sectionId:e,columnIndex:t})=>{let o=ie(),r=qo(e).data,{settings:n,updateSettings:i}=Ar(e);if(!r)return null;let{columnSettings:a={}}=n,{width:l=void 0}=a[t]?a[t]:{},s=d=>{r&&i("columnSettings",{...a,[t]:{width:parseInt(d.target.value,10)}});},c=()=>{r&&o(Z.updateEntity("section",{id:e,settings:{...r.settings,columnSettings:{...a,[t]:{width:void 0}}}}));};return jsxs(Group,{className:"bespoke-resize-col",pos:"absolute",top:-12,left:"50%",sx:{borderRadius:"4px",transform:"translate(-50%, 0%)",zIndex:20},py:0,px:"xs",maw:180,bg:"white",noWrap:true,children:[jsx(Checkbox,{label:"100%",size:"xs",onChange:d=>{i("columnSettings",{...a,[t]:{...a[t]||{},full:d.currentTarget.checked}});},checked:a[t]?.full}),jsx(Input,{placeholder:"auto",w:"fit-content",miw:"none",variant:"filled",type:"number",value:l||"auto",maw:110,onChange:s,size:"xs",p:0,rightSection:jsx(IconX,{onClick:c,size:8})})]})},eh=In__default.forwardRef(j$);});var gi,Fp=N(()=>{p();gi={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}};});var GE=N(()=>{p();Rn();});var HE=N(()=>{p();ae();Wr();TE();Cc();Ho();Vg();Qg();io();he();th();ic();Fp();Rn();Yr();GE();li();jr();Pt();io();});function _o({target:e,dropdown:t}){let[o,{open:r,close:n}]=useDisclosure(false),i=useRef(true),a=()=>{setTimeout(()=>{i.current&&n();},1e3);},l=()=>{i.current=false;},s=()=>{i.current=true,n();};return jsxs(Group,{children:[e,jsxs(Popover,{opened:o,trapFocus:true,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"subtle",color:"blue",onMouseEnter:r,onMouseLeave:a,children:jsx(IconInfoCircle,{})})}),jsx(Popover.Dropdown,{maw:350,onMouseEnter:l,onMouseLeave:s,children:jsxs(Group,{align:"flex-start",noWrap:true,children:[jsx("div",{children:jsx(ThemeIcon,{variant:"outline",sx:{border:"none"},children:jsx(IconInfoCircle,{})})}),jsx("div",{children:t})]})})]})]})}var Vp=N(()=>{p();});function Sa({value:e,onChange:t,item:o="block"}){let r=ie(),[n,i]=useState([]),a=useMemo(()=>[{value:"public",label:`Public ${o}, (all visitors)`,group:"Exclusive"},{value:"guest",label:`Guest only ${o}, (non logged visitors)`,group:"Exclusive"},{value:"private",label:`Private ${o}, (session required, any role)`,group:"Exclusive"}],[o]),l=useMemo(()=>n.map(c=>({value:`role.${c.name}`,label:`Role ${c.name} (${c.type})`,group:`${c.type} Roles`})),[n]);useEffect(()=>{r(Z.searchRole()).then(c=>{i(c.roles);});},[r]);let s=c=>{let u=[];if(c.length===0)u=[a[0].value];else {let d=c.slice(-1)[0],m=a.map(f=>f.value);u=m.includes(d)?[d]:c.filter(f=>!m.includes(f));}t(u);};return jsx(MultiSelect,{label:"Privacy",description:`This ${o} will be shown based on the selected roles.`,data:[...a,...l],value:e,onChange:s})}var $p=N(()=>{p();ae();});function nh(){let e=Jt(),t=Number.parseInt(e.params[0]),o=zt(t).data,n=H(Ku).filter(L=>L.type===E.NAV),{settings:i,updateSettings:a}=Kl(t),{handlers:l}=Ft("reportEditor"),s=ii(),c=o?.dimensions&&o.dimensions.length>0,u=$l(o?.dimensions||[]),d=useMemo(()=>u.isSuccess?u.data.flatMap(L=>L.variants||[]):[],[u.data,u.isSuccess]),m=Ul(d),g=useMemo(()=>{if(!u.isSuccess||!m.isSuccess)return [];let L=u.data,R=m.data;return L.length===1?R.map(z=>({value:z.id.toString(),label:z.name,dimensionName:L[0].name})):L.length>1?L.map(V=>R.filter(j=>V.variants?.includes(j.id)||false)).reduce((V,j)=>V.flatMap(B=>j.map(U=>[...B,U])),[[]]).filter(V=>V.length>0).map(V=>({value:V.map(j=>j.id).join(","),label:V.map(j=>j.name).join(" / "),dimensionName:V.map((j,B)=>`${L[B]?.name}: ${j.name}`).join(" | ")})):[]},[u.data,u.isSuccess,m.data,m.isSuccess]),f=i.pdf?.variants||[],h=i.pdf?.privacy||["public"],v=i.pdf?.navBlockId||(n.length>0?n[0].id:""),T=!!i.pdf?.sectionSelection,y=L=>{a("pdf",{...i.pdf,enabled:true,variants:L});},C=L=>{a("pdf",{...i.pdf,enabled:true,privacy:L});},b=L=>{let R=n.length>0?n[0].id:void 0;a("pdf",{...i.pdf,sectionSelection:L,navBlockId:L?i.pdf?.navBlockId||R:void 0});},w=L=>{a("pdf",{...i.pdf,navBlockId:L?parseInt(L):void 0});},k=L=>{if(L){let R=g.map(z=>z.value);a("pdf",{enabled:true,variants:R,privacy:["public"]});}else a("pdf",{enabled:false,variants:[],privacy:[],sectionSelection:false,navBlockId:void 0});},I=i.xlsx?.variants||[],O=i.xlsx?.privacy||["public"],P=L=>{a("xlsx",{...i.xlsx,enabled:true,variants:L});},_=L=>{a("xlsx",{...i.xlsx,enabled:true,privacy:L});},D=L=>{if(L){let R=g.map(z=>z.value);a("xlsx",{enabled:true,variants:R,privacy:["public"]});}else a("xlsx",{enabled:false,variants:[],privacy:[]});};return jsx(Fragment,{children:jsxs(Stack,{children:[jsx(Button,{variant:"outline",radius:0,onClick:l.open,children:"Edit Report"}),c&&jsxs(Accordion,{children:[jsxs(Accordion.Item,{value:"comparison",children:[jsx(Accordion.Control,{children:"Profile Comparison"}),jsxs(Accordion.Panel,{children:[jsx(_o,{target:jsx(Switch,{label:"Enable comparison",checked:!!i.comparison,onChange:L=>a("comparison",L.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Comparisons"}),jsx(Text,{fw:400,children:"This feature will allow user visiting this profile to compare it side by side to another choosen profile"})]})}),i.comparison&&jsx(_o,{target:jsx(Switch,{label:"With different levels",checked:!!i.compareLevels,onChange:L=>a("compareLevels",L.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Compare with different Levels"}),jsx(Text,{fw:400,children:"Allow users to compare profiles from differet Levels."})]})})]})]}),jsxs(Accordion.Item,{value:"pdf",children:[jsx(Tooltip,{label:"PDF Export is not configured",disabled:s,children:jsx("span",{children:jsx(Accordion.Control,{disabled:!s,children:"PDF Export"})})}),jsxs(Accordion.Panel,{children:[jsx(_o,{target:jsx(Switch,{label:"Enable PDF export",checked:!!i.pdf?.enabled,onChange:L=>k(L.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"PDF Exports"}),jsx(Text,{fw:400,children:"This feature will allow user to download the PDF version of the report with a single click."})]})}),i.pdf?.enabled&&jsxs(Stack,{mt:"md",children:[n.length>0&&jsxs(Fragment,{children:[jsx(Switch,{label:"Enable Section selection in PDF export",checked:T,onChange:L=>b(L.currentTarget.checked)}),T&&jsx(Select,{data:n.map(L=>({value:L.id.toString(),label:`Nav Block #${L.id}`})),label:"Select Navigation Block for PDF sections",description:"The PDF export selection should be based on a Navigation block.",placeholder:"Select Nav Block",ml:"xl",size:"xs",value:v.toString(),onChange:w})]}),jsx(Sa,{value:h,onChange:C,item:"PDF export"}),g.length>0&&jsxs(Fragment,{children:[jsx(Text,{fw:500,size:"sm",children:"Select variants to enable PDF export:"}),jsx(Checkbox.Group,{value:f,onChange:y,children:jsx(Stack,{spacing:"xs",children:g.map(L=>jsx(Checkbox,{value:L.value,label:L.label,description:L.dimensionName,size:"sm"},L.value))})})]})]})]})]}),jsxs(Accordion.Item,{value:"xlsx",children:[jsx(Accordion.Control,{children:"XLSX Export"}),jsxs(Accordion.Panel,{children:[jsx(_o,{target:jsx(Switch,{label:"Enable XLSX export",checked:!!i.xlsx?.enabled,onChange:L=>D(L.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Xlsx Exports"}),jsx(Text,{fw:400,children:"This feature will allow user to download the XlSX version of the report visualizations."})]})}),i.xlsx?.enabled&&jsxs(Stack,{mt:"md",children:[jsx(Sa,{value:O,onChange:_,item:"XLSX export"}),g.length>0&&jsxs(Fragment,{children:[jsx(Text,{fw:500,size:"sm",children:"Select variants to enable XLSX export:"}),jsx(Checkbox.Group,{value:I,onChange:P,children:jsx(Stack,{spacing:"xs",children:g.map(L=>jsx(Checkbox,{value:L.value,label:L.label,description:L.dimensionName,size:"sm"},L.value))})})]})]})]})]})]})]})})}var ih=N(()=>{p();xe();Tn();Vp();st();$p();Wr();he();});var YE=N(()=>{p();Yr();xp();ae();st();io();ds();Yg();});var JE=N(()=>{p();});function ur(){let e=useContext(sU);if(e===void 0)throw new Error("usePrint must be used within a PrintContext");return e}var sU,Rn=N(()=>{p();ae();Ho();HE();li();xp();io();st();ih();YE();JE();sU=createContext({print:false,isEmbed:false});});function Ut(e){let{content:t,style:o={}}=e,{print:r}=ur(),n=jsx(ye,{component:"span",html:t,isPreview:true}),i=useMemo(()=>r?jsx("div",{className:"bespoke-inner-tooltip-notification",children:jsx(Notification,{icon:jsx(IconInfoCircle,{size:"1.1rem"}),withCloseButton:false,withBorder:true,styles:{root:{boxShadow:"none"}},children:n})},"tooltip-notification"):jsx("div",{className:"bespoke-inner-tooltip",style:o,children:jsx(Tooltip,{label:n,withArrow:true,withinPortal:true,multiline:true,maw:220,children:jsx(ActionIcon,{size:"1.5rem",children:jsx(IconInfoCircle,{})})})},"tooltip"),[r,t,o]);return jsx(Fragment,{children:i})}var En=N(()=>{p();Rn();ft();});function sh({paragraph:e,tooltip:t,settings:o}){return jsx(ye,{component:"p",html:e||`Lorem ipsum dolor sit amet,
41
+ color: hsl(`+Math.max(0,Math.min(120-120*f,120))+"deg 100% 31%);",o?.key);}return o==null||o.onChange==null||o.onChange(i),i}}function Rp(e,t){if(e===void 0)throw new Error("Unexpected undefined"+(""));return e}var Lk,Mk=D(()=>{p();Lk=function(t,o){return Math.abs(t-o)<1};});function OF(e){for(var t=e.measurements,o=e.outerSize,r=e.scrollOffset,n=t.length-1,i=function(c){return t[c].start},a=zk(0,n,i,r),l=a;l<n&&t[l].end<r+o;)l++;return {startIndex:a,endIndex:l}}var AF,hc,Bk,Dk,PF,_k,Nk,zk,kg=D(()=>{p();Ok();Mk();AF=function(t){return t},hc=function(t){for(var o=Math.max(t.startIndex-t.overscan,0),r=Math.min(t.endIndex+t.overscan,t.count-1),n=[],i=o;i<=r;i++)n.push(i);return n},Bk=function(t,o){var r=t.scrollElement;if(r){var n=function(l){var s=l.width,c=l.height;o({width:Math.round(s),height:Math.round(c)});};n(r.getBoundingClientRect());var i=new ResizeObserver(function(a){var l=a[0];if(l!=null&&l.borderBoxSize){var s=l.borderBoxSize[0];if(s){n({width:s.inlineSize,height:s.blockSize});return}}n(r.getBoundingClientRect());});return i.observe(r,{box:"border-box"}),function(){i.unobserve(r);}}},Dk=function(t,o){var r=t.scrollElement;if(r){var n=function(){o(r[t.options.horizontal?"scrollLeft":"scrollTop"]);};return n(),r.addEventListener("scroll",n,{passive:true}),function(){r.removeEventListener("scroll",n);}}},PF=function(t,o,r){if(o!=null&&o.borderBoxSize){var n=o.borderBoxSize[0];if(n){var i=Math.round(n[r.options.horizontal?"inlineSize":"blockSize"]);return i}}return Math.round(t.getBoundingClientRect()[r.options.horizontal?"width":"height"])},_k=function(t,o,r){var n,i,a=o.adjustments,l=a===void 0?0:a,s=o.behavior,c=t+l;(n=r.scrollElement)==null||n.scrollTo==null||n.scrollTo((i={},i[r.options.horizontal?"left":"top"]=c,i.behavior=s,i));},Nk=function(t){var o=this;this.unsubs=[],this.scrollElement=null,this.isScrolling=false,this.isScrollingTimeoutId=null,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollDirection=null,this.scrollAdjustments=0,this.measureElementCache=new Map,this.observer=(function(){var r=null,n=function(){return r||(typeof ResizeObserver<"u"?r=new ResizeObserver(function(a){a.forEach(function(l){o._measureElement(l.target,l);});}):null)};return {disconnect:function(){var a;return (a=n())==null?void 0:a.disconnect()},observe:function(a){var l;return (l=n())==null?void 0:l.observe(a,{box:"border-box"})},unobserve:function(a){var l;return (l=n())==null?void 0:l.unobserve(a)}}})(),this.range={startIndex:0,endIndex:0},this.setOptions=function(r){Object.entries(r).forEach(function(n){var i=n[0],a=n[1];typeof a>"u"&&delete r[i];}),o.options=gc({debug:false,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:false,getItemKey:AF,rangeExtractor:hc,onChange:function(){},measureElement:PF,initialRect:{width:0,height:0},scrollMargin:0,scrollingDelay:150,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1},r);},this.notify=function(){o.options.onChange==null||o.options.onChange(o);},this.cleanup=function(){o.unsubs.filter(Boolean).forEach(function(r){return r()}),o.unsubs=[],o.scrollElement=null;},this._didMount=function(){return o.measureElementCache.forEach(o.observer.observe),function(){o.observer.disconnect(),o.cleanup();}},this._willUpdate=function(){var r=o.options.getScrollElement();o.scrollElement!==r&&(o.cleanup(),o.scrollElement=r,o._scrollToOffset(o.scrollOffset,{adjustments:void 0,behavior:void 0}),o.unsubs.push(o.options.observeElementRect(o,function(n){var i=o.scrollRect;o.scrollRect=n,(o.options.horizontal?n.width!==i.width:n.height!==i.height)&&o.maybeNotify();})),o.unsubs.push(o.options.observeElementOffset(o,function(n){o.scrollAdjustments=0,o.scrollOffset!==n&&(o.isScrollingTimeoutId!==null&&(clearTimeout(o.isScrollingTimeoutId),o.isScrollingTimeoutId=null),o.isScrolling=true,o.scrollDirection=o.scrollOffset<n?"forward":"backward",o.scrollOffset=n,o.maybeNotify(),o.isScrollingTimeoutId=setTimeout(function(){o.isScrollingTimeoutId=null,o.isScrolling=false,o.scrollDirection=null,o.maybeNotify();},o.options.scrollingDelay));})));},this.getSize=function(){return o.scrollRect[o.options.horizontal?"width":"height"]},this.memoOptions=fa(function(){return [o.options.count,o.options.paddingStart,o.options.scrollMargin,o.options.getItemKey]},function(r,n,i,a){return o.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:n,scrollMargin:i,getItemKey:a}},{key:false}),this.getFurthestMeasurement=function(r,n){for(var i=new Map,a=new Map,l=n-1;l>=0;l--){var s=r[l];if(!i.has(s.lane)){var c=a.get(s.lane);if(c==null||s.end>c.end?a.set(s.lane,s):s.end<c.end&&i.set(s.lane,true),i.size===o.options.lanes)break}}return a.size===o.options.lanes?Array.from(a.values()).sort(function(u,d){return u.end-d.end})[0]:void 0},this.getMeasurements=fa(function(){return [o.memoOptions(),o.itemSizeCache]},function(r,n){var i=r.count,a=r.paddingStart,l=r.scrollMargin,s=r.getItemKey,c=o.pendingMeasuredCacheIndexes.length>0?Math.min.apply(Math,o.pendingMeasuredCacheIndexes):0;o.pendingMeasuredCacheIndexes=[];for(var u=o.measurementsCache.slice(0,c),d=c;d<i;d++){var f=s(d),g=o.options.lanes===1?u[d-1]:o.getFurthestMeasurement(u,d),m=g?g.end:a+l,h=n.get(f),y=typeof h=="number"?h:o.options.estimateSize(d),S=m+y,v=g?g.lane:d%o.options.lanes;u[d]={index:d,start:m,size:y,end:S,key:f,lane:v};}return o.measurementsCache=u,u},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:function(){return o.options.debug}}),this.calculateRange=fa(function(){return [o.getMeasurements(),o.getSize(),o.scrollOffset]},function(r,n,i){return o.range=OF({measurements:r,outerSize:n,scrollOffset:i})},{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:function(){return o.options.debug}}),this.maybeNotify=fa(function(){var r=o.calculateRange();return [r.startIndex,r.endIndex,o.isScrolling]},function(){o.notify();},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:function(){return o.options.debug},initialDeps:[this.range.startIndex,this.range.endIndex,this.isScrolling]}),this.getIndexes=fa(function(){return [o.options.rangeExtractor,o.calculateRange(),o.options.overscan,o.options.count,o.getSize()]},function(r,n,i,a,l){return l===0?[]:r(gc({},n,{overscan:i,count:a}))},{key:process.env.NODE_ENV!=="production"&&"getIndexes",debug:function(){return o.options.debug}}),this.indexFromElement=function(r){var n=o.options.indexAttribute,i=r.getAttribute(n);return i?parseInt(i,10):(console.warn("Missing attribute name '"+n+"={index}' on measured element."),-1)},this._measureElement=function(r,n){var i=o.measurementsCache[o.indexFromElement(r)];if(!i||!r.isConnected){o.measureElementCache.forEach(function(s,c){s===r&&(o.observer.unobserve(r),o.measureElementCache.delete(c));});return}var a=o.measureElementCache.get(i.key);a!==r&&(a&&o.observer.unobserve(a),o.observer.observe(r),o.measureElementCache.set(i.key,r));var l=o.options.measureElement(r,n,o);o.resizeItem(i,l);},this.resizeItem=function(r,n){var i,a=(i=o.itemSizeCache.get(r.key))!=null?i:r.size,l=n-a;l!==0&&(r.start<o.scrollOffset&&(process.env.NODE_ENV!=="production"&&o.options.debug&&console.info("correction",l),o._scrollToOffset(o.scrollOffset,{adjustments:o.scrollAdjustments+=l,behavior:void 0})),o.pendingMeasuredCacheIndexes.push(r.index),o.itemSizeCache=new Map(o.itemSizeCache.set(r.key,n)),o.notify());},this.measureElement=function(r){r&&o._measureElement(r,void 0);},this.getVirtualItems=fa(function(){return [o.getIndexes(),o.getMeasurements()]},function(r,n){for(var i=[],a=0,l=r.length;a<l;a++){var s=r[a],c=n[s];i.push(c);}return i},{key:process.env.NODE_ENV!=="production"&&"getIndexes",debug:function(){return o.options.debug}}),this.getVirtualItemForOffset=function(r){var n=o.getMeasurements();return Rp(n[zk(0,n.length-1,function(i){return Rp(n[i]).start},r)])},this.getOffsetForAlignment=function(r,n){var i=o.getSize();n==="auto"&&(r<=o.scrollOffset?n="start":r>=o.scrollOffset+i?n="end":n="start"),n==="start"?r=r:n==="end"?r=r-i:n==="center"&&(r=r-i/2);var a=o.options.horizontal?"scrollWidth":"scrollHeight",l=o.scrollElement?"document"in o.scrollElement?o.scrollElement.document.documentElement[a]:o.scrollElement[a]:0,s=l-o.getSize();return Math.max(Math.min(s,r),0)},this.getOffsetForIndex=function(r,n){n===void 0&&(n="auto"),r=Math.max(0,Math.min(r,o.options.count-1));var i=Rp(o.getMeasurements()[r]);if(n==="auto")if(i.end>=o.scrollOffset+o.getSize()-o.options.scrollPaddingEnd)n="end";else if(i.start<=o.scrollOffset+o.options.scrollPaddingStart)n="start";else return [o.scrollOffset,n];var a=n==="end"?i.end+o.options.scrollPaddingEnd:i.start-o.options.scrollPaddingStart;return [o.getOffsetForAlignment(a,n),n]},this.isDynamicMode=function(){return o.measureElementCache.size>0},this.cancelScrollToIndex=function(){o.scrollToIndexTimeoutId!==null&&(clearTimeout(o.scrollToIndexTimeoutId),o.scrollToIndexTimeoutId=null);},this.scrollToOffset=function(r,n){var i=n===void 0?{}:n,a=i.align,l=a===void 0?"start":a,s=i.behavior;o.cancelScrollToIndex(),s==="smooth"&&o.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),o._scrollToOffset(o.getOffsetForAlignment(r,l),{adjustments:void 0,behavior:s});},this.scrollToIndex=function(r,n){var i=n===void 0?{}:n,a=i.align,l=a===void 0?"auto":a,s=i.behavior;r=Math.max(0,Math.min(r,o.options.count-1)),o.cancelScrollToIndex(),s==="smooth"&&o.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");var c=o.getOffsetForIndex(r,l),u=c[0],d=c[1];o._scrollToOffset(u,{adjustments:void 0,behavior:s}),s!=="smooth"&&o.isDynamicMode()&&(o.scrollToIndexTimeoutId=setTimeout(function(){o.scrollToIndexTimeoutId=null;var f=o.measureElementCache.has(o.options.getItemKey(r));if(f){var g=o.getOffsetForIndex(r,d),m=g[0];Lk(m,o.scrollOffset)||o.scrollToIndex(r,{align:d,behavior:s});}else o.scrollToIndex(r,{align:d,behavior:s});}));},this.scrollBy=function(r,n){var i=n===void 0?{}:n,a=i.behavior;o.cancelScrollToIndex(),a==="smooth"&&o.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),o._scrollToOffset(o.scrollOffset+r,{adjustments:void 0,behavior:a});},this.getTotalSize=function(){var r;return (((r=o.getMeasurements()[o.options.count-1])==null?void 0:r.end)||o.options.paddingStart)-o.options.scrollMargin+o.options.paddingEnd},this._scrollToOffset=function(r,n){var i=n.adjustments,a=n.behavior;o.options.scrollToFn(r,{behavior:a,adjustments:i},o);},this.measure=function(){o.itemSizeCache=new Map,o.notify();},this.setOptions(t),this.scrollRect=this.options.initialRect,this.scrollOffset=this.options.initialOffset,this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(function(r){o.itemSizeCache.set(r.key,r.size);}),this.maybeNotify();},zk=function(t,o,r,n){for(;t<=o;){var i=(t+o)/2|0,a=r(i);if(a<n)t=i+1;else if(a>n)o=i-1;else return i}return t>0?t-1:0};});function MF(e){var t=wn.useReducer(function(){return {}},{})[1],o=fc({},e,{onChange:function(a){t(),e.onChange==null||e.onChange(a);}}),r=wn.useState(function(){return new Nk(o)}),n=r[0];return n.setOptions(o),wn.useEffect(function(){return n._didMount()},[]),LF(function(){return n._willUpdate()}),n}function Ip(e){return MF(fc({observeElementRect:Bk,observeElementOffset:Dk,scrollToFn:_k},e))}var LF,Eg=D(()=>{p();Pk();kg();kg();LF=typeof document<"u"?wn.useLayoutEffect:wn.useEffect;});function Ig(e){let{allLabel:t,asComparison:o,colorKey:r,data:n,defaultValue:i,defaultValueType:a,hideLabel:l,resetSectionVars:s,iconKey:c,id:u,levels:d,limit:f,placeholder:g,searchIndexKey:m,searchIndexSeparator:h,section:y,settings:S}=e,{print:v}=cr(),C=KF(u),b=Cp(u,y,C,o,s==="true"),k=o?`${C}-valueCompare`:`${C}-value`,w=o?`${C}-typeCompare`:`${C}-type`,R=useMantineTheme(),[O,A]=useState(false),[B,_]=useState(true),[P,I]=useState(""),[F,M]=useState(false),[N,j]=useState([""].slice(1)),[$,V]=useState([]),[z,q]=useState(""),W=S[_t.DISABLED]||false,U=useMemo(()=>v?Array.from(new Set(n.filter(Q=>$.includes(Q[`${z} ID`])))).map(Q=>Q?.[z]).join(", "):"",[v]),Y=l==="true"||!e.label?jsx(Fragment,{}):jsx(ve,{component:"div",html:e.label,size:"sm",style:S}),ne=useRef(null),re=useRef(false),J=useRef(!!f&&f<$.length),G=N.length,K=d[G],ee=N.filter(Boolean);N.length>0&&ee.length===0&&ee.push(`${t} ${K?.label}`),useEffect(()=>{if(!W){let L=new URLSearchParams(window.location.search),Q=L.get(k)||i,te=L.get(w)||a;Q&&te?(V(qF(Q,i)),q(te)):(V([]),q(""));}},[window.location.search,i,a,W]),useEffect(()=>{let L=()=>{_(true);};return window.addEventListener("touchmove",L),()=>{window.removeEventListener("touchmove",L);}},[]);let ae=useMemo(()=>HF(n,d,r,c,m,h),[r,n,c,d,m,h]),ue=useMemo(()=>{let L=WF(P),Q=Array.from(jF(ae,L)).reverse();return F?Q:N.reduce((te,Se)=>te.filter(fe=>!Se||fe.searchindex.indexOf(Se)>-1),Q.filter(te=>te.type===K?.value))},[K,ae,P,F,N]),Te=useRef(null),X=Ip({count:O?ue.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>Te.current,[]),overscan:10,rangeExtractor:useCallback(L=>hc(L),[])}),[le,de]=useState(-1),Ce=Math.min(le,ue.length-1),$e=useCallback(L=>{let Q=N.concat(L);F&&M(false),j(Q);},[F,N]),Ue=useCallback(()=>{let L=N.slice(0,G-1);F&&M(false),j(L);},[F,N,G]),Qe=useCallback(L=>{I(L.currentTarget.value),!J.current&&n.length>0&&A(true);},[n,I,J,A]),To=useCallback(()=>{I(""),b([],""),ne.current?.focus(),f&&(J.current=false);},[I,b,ne,f,J]),$o=useCallback(L=>{let Q=$.filter(te=>te!==L);Q.length>0?b(Q,z):b([],""),f&&Q.length<f&&(J.current=false);},[$,z,b,f,J]),uo=useCallback(L=>{z!==L.type?b([L.value],L.type):$.includes(L.value)?$o(L.value):f?($.length<f&&b([...$,L.value],z),$.length===f&&b([...$.slice(1),L.value],z)):b([...$,L.value],z),I("");},[b,z,$,$o,f]),mn=useCallback(()=>{$.length>0&&P.length===0&&(b($.slice(0,-1),z),A(true),f&&(J.current=false)),P.length>0&&I(P.slice(0,-1));},[b,$,z,P,I,A,f,J]),Un=useCallback(()=>{_(L=>L&&(re.current=L,!L)),de(L=>L+1>=ue.length?L:L+1);},[de,ue]),Gn=useCallback(()=>{let L=ue[Ce];L&&uo(L);},[ue,Ce,uo]),Hn=useCallback(()=>{A(false);},[A]),Wn=useCallback(()=>{Ue(),de(0);},[de,Ue]),xl=useCallback(()=>{let L=ue[Ce];!F&&L&&L.type!==d[d.length-1]?.value&&($e(L.name),de(0));},[ue,Ce,F,d,de,$e]),Tl=useCallback(()=>{_(L=>L&&(re.current=L,!L)),de(L=>L-1<0?0:L-1);},[de]),Cl=({label:L,onRemove:Q,...te})=>jsxs("div",{style:{alignItems:"center",backgroundColor:R.colorScheme==="dark"?R.colors.dark[7]:R.colors.gray[1],borderRadius:R.radius.sm,cursor:"default",color:R.colorScheme==="dark"?R.colors.dark[0]:R.colors.gray[7],display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${R.spacing.xs} / 2 - ${rem(2)}) calc(${R.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${R.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...te,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:Q,radius:2,size:"sm",sx:{color:R.colorScheme==="dark"?R.colors.dark[0]:R.colors.gray[7],marginLeft:`calc(${R.spacing.sm} / 6)`},tabIndex:-1})]}),oe=useMemo(()=>$.map(L=>ae.find(Q=>Q.value===L)).filter(L=>!!L).map((L,Q)=>createElement(Cl,{...L,index:Q,label:L.label,key:L.value,onRemove:te=>{te.preventDefault(),te.stopPropagation(),$o(L.value);}})),[$]),Oe=forwardRef(function({color:Q,icon:te,label:Se,value:fe,...vt},Co){return jsx("div",{ref:Co,style:{cursor:"pointer",width:"100%"},...vt,children:jsxs(Group,{align:"center",noWrap:true,spacing:"xs",w:"100%",children:[te&&jsx(Box,{bg:Q??"transparent",component:"img",w:20,h:20,src:te}),jsx(Text,{lineClamp:1,size:"sm",children:Se||fe})]})})});return jsxs(Fragment,{children:[jsx(MediaQuery,{query:"print",styles:{display:"none"},children:jsx(Input.Wrapper,{label:Y,children:jsxs(Popover,{closeOnClickOutside:true,disabled:W,keepMounted:true,opened:O,onChange:A,onClose:()=>{de(0),I("");},onOpen:()=>{ue.length>0&&X.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>de(0),sx:{position:"relative","& .defaultValue":{backgroundColor:R.colorScheme==="dark"?R.colors.dark[5]:R.colors.gray[3],color:R.colorScheme==="dark"?R.colors.dark[1]:R.colors.gray[7]}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:$.join(",")}),jsx(Input,{component:"div",disabled:W,multiline:true,onMouseDown:L=>{L.preventDefault(),!J.current&&n.length>0&&A(!O),ne.current?.focus();},rightSection:$.length>0?jsx(CloseButton,{disabled:W,onClick:To,onMouseDown:L=>L.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:R.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${R.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:R.colorScheme==="dark"?R.colors.dark[3]:R.colors.gray[5],opacity:1}},children:[oe,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":O,onChange:Qe,onKeyDown:getHotkeyHandler([["ArrowDown",Un],["ArrowLeft",Wn],["ArrowRight",xl],["ArrowUp",Tl],["Backspace",mn],["Enter",Gn],["Escape",Hn]]),placeholder:$.length===0&&g||"",ref:ne,readOnly:J.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:R.fontSizes.sm,marginLeft:`calc(${R.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:P})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:L=>L.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:L=>L.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",spacing:"xs",w:"100%",children:[d.length>1&&jsxs(Stack,{spacing:"xs",children:[jsxs(Group,{onClick:L=>{L.stopPropagation();},px:"xs",position:"center",spacing:"xs",children:[jsx(Button,{onClick:()=>{de(0),M(true),j([]),ue.length>0&&X.scrollToIndex(0);},size:"xs",variant:F?"filled":"outline",children:t}),d.map((L,Q)=>jsx(Button,{onClick:()=>{F&&M(false);let te=[""].slice(1),Se=Q;for(;Se--;)te[Se]=N[Se]||"";de(0),j(te),ue.length>0&&X.scrollToIndex(0);},size:"xs",variant:!F&&N.length===d.findIndex(te=>te.value===L?.value)?"filled":"outline",children:L?.label},L?.value))]}),jsx(Divider,{})]}),G>0&&jsxs(Group,{align:"center",noWrap:true,px:"xs",children:[jsx(ActionIcon,{onClick:Ue,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:ee.map(L=>jsx(Text,{lineClamp:1,size:"xs",children:L},`${L}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>_(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:Te,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${X.getTotalSize()}px`,position:"relative",width:"100%"},children:X.getVirtualItems().map(L=>{let Q=ue[L.index],te=Ce===L.index,Se=$.includes(Q.value);return ue.length>0&&te&&!B&&X.scrollToIndex(Ce),jsxs(Group,{"aria-selected":te,align:"center","data-hovered":te||void 0,"data-index":L.index,"data-selected":Se,id:Q.vale,noWrap:true,onMouseEnter:fe=>{fe.preventDefault(),fe.stopPropagation(),B&&(de(L.index),_(false));},onMouseMove:fe=>{fe.preventDefault(),fe.stopPropagation(),_(true);},onMouseDown:fe=>{fe.preventDefault(),uo(Q);},position:"apart",ref:X.measureElement,role:"option",spacing:"xs",sx:fe=>({borderRadius:fe.radius.xs,padding:"15px 5px 15px",paddingLeft:F&&10*d.findIndex(vt=>vt?.value===Q.type)||5,position:"absolute",top:0,left:0,height:`${L.size}px`,transform:`translateY(${L.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:fe.colorScheme==="dark"?fe.colors.dark[4]:fe.colors.gray[1]},"&:hover":{backgroundColor:fe.colorScheme==="dark"?fe.colors.dark[4]:fe.colors.gray[1]}}),tabIndex:-1,children:[jsx(Oe,{index:L.index,...Q}),!F&&Q.type!==d[d.length-1]?.value&&jsx(ActionIcon,{onMouseDown:fe=>{fe.preventDefault(),fe.stopPropagation(),$e(Q.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},Q.value)})})})]})})})})]})})}),v&&jsxs(Text,{children:[Y,": ",U]})]})}var HF,WF,jF,KF,qF,jk=D(()=>{p();Eg();mt();En();no();he();HF=(e=[],t=[],o="",r="",n="",i="|")=>{let a=t.map(h=>h.value).slice(),l=`${a.pop()}`,s=h=>h[o],c=h=>h[r],u=h=>{if(h[n])return typeof h[n]=="string"?h[n].split(i):h[n]},d=new Set,f=[],g=[],m=nest().rollup(h=>{let y=h[0],S=A=>A&&A.value&&!d.has(A.value),v=a.map(A=>y[`${A} ID`]),C=a.map(A=>y[A]),b=a.map((A,B)=>{if(g[B]!==C[B]){g[B]=C[B];let _=s[B]||s[s.length-1]||s,P=c[B]||c[c.length-1]||c,I=u[B]||u[u.length-1]||u;return {color:_(y,A)||void 0,icon:P(y,A)||void 0,value:`${v[B]}`,label:C[B],name:C[B],type:A,searchindex:C.slice(0,B+1).concat(I(y,A)).join("|")}}return {}}).filter(S);b.forEach(A=>d.add(A.value));let k=s[s.length-1]||s,w=c[c.length-1]||c,R=u[u.length-1]||u,O=h.map(A=>({color:k(A,l)||void 0,icon:w(A,l)||void 0,value:`${A[`${l} ID`]}`,label:A[l],name:A[l],type:l,searchindex:C.concat(A[l]).concat(R(A,l)).join("|")}));f.push(...b.concat(O));});return a.forEach(h=>{m.key(y=>`${y[`${h} ID`]}|${y[h]}`);}),m.entries(e),f},WF=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},jF=(e,t)=>{let o=e.length,r,n=l=>r&&r.searchindex.includes(l.searchindex),a={next:()=>{for(let l=o-1;l>-1;l--){let s=e[l];if(t.test(`${s.value} ${s.label} ${s.searchindex}`)||n(s))return r=s,o=l,{done:false,value:s}}return {done:true,value:void 0}},[Symbol.iterator]:()=>a};return a},KF=e=>`multihierarchySelector${e}`,qF=(e,t)=>e&&typeof e=="string"?e.split(","):t;});function Ag({headings:e,settings:t,type:o,title:r,shortTitle:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:c,_iconPadding:u}){let{min:d="1",max:f="6",icons:g="yes"}=t||{},m=na(parseInt(d,10),parseInt(f,10),e),h=g==="yes",y=He(r)||"",S=He(n||r)||"",v=y&&y.length>0,C=i&&i!=="none",k=`(max-width: ${useMantineTheme().breakpoints.md})`,w=useMediaQuery(k),R=w?S:y,O=t&&t.align?String(t.align):"left",A=ws(O),B=oo(O),_=Po(O),P=t&&t.titlePosition?String(t.titlePosition):"left",I=useMemo(()=>{let j={right:"left",left:"right"},$=v&&["left","right"].includes(P),V={};if($){let z=P==="right";V={spacing:"xs",position:z&&j[B]?j[B]:B,style:{flexDirection:z?"row-reverse":"row"},noWrap:true};}else V={spacing:"xs",align:_,justify:"center",style:{flexDirection:P==="bottom"?"column-reverse":"column"}};return {element:$?Group:Stack,props:V}},[v,B,_,P]),F=useMemo(()=>v?jsxs(Group,{spacing:"xs",position:B,noWrap:true,children:[C&&jsx(je,{blockType:"title",iconType:i,iconVariant:a,iconRadius:s,iconSize:c,icon:l,iconPadding:u}),jsx(ve,{style:{...t},html:R,lineClamp:1})]}):null,[v,C,B,R]),M=useMemo(()=>w?jsx(tV,{contentOutline:m,showIcons:h,titleElement:F,wrapper:I}):null,[w,F,I]),N=useMemo(()=>w?null:o==="multilevel"?jsx(oV,{contentOutline:m,showIcons:h,align:A}):jsx(eV,{contentOutline:m,showIcons:h,align:A}),[m,h,A,w]);return jsxs(Fragment,{children:[w&&M,!w&&jsxs(I.element,{pos:"relative",...I.props,children:[v&&F,N]})]})}var qk,eV,tE,tV,oV,oE=D(()=>{p();no();kn();ro();Wr();kn();mt();qk=e=>t=>({display:"flex",gap:t.spacing.md,justifyContent:e,listStyleType:"none"}),eV=({contentOutline:e,showIcons:t,align:o})=>{let[r,n]=useState(null);useEffect(()=>{let a=()=>{let l=document.querySelector(".bespoke-nav");if(!l)return;let s=l.getBoundingClientRect(),c=false;e.forEach(u=>{let d=document.getElementById(`bespoke-title-${u.id}`);d&&d.getBoundingClientRect().top<=s.bottom&&(n(u.id),c=true);}),c||n(null);};return window.addEventListener("scroll",a),()=>{window.removeEventListener("scroll",a);}},[e]);let i=a=>!a||!a?.length?null:jsx(Fragment,{children:a.map(l=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${l.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(je,{...l.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:l.label}})]})})}),jsx(Box,{pl:"xs",children:i(l.children)})]},l.id))});return jsx(Fragment,{children:jsx(Box,{component:"nav",className:"bespoke-nav",children:jsx(List,{sx:a=>({display:"flex",gap:a.spacing.md,justifyContent:o,listStyleType:"none"}),children:e?.map(a=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:200,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${a.id}`,"data-active":a.id===r,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(je,{...a.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:a.label}})]})})}),a?.children?.length?jsx(Menu.Dropdown,{children:i(a.children)}):null]})},a.id))})})})},tE=({contentOutline:e,closeNav:t,showIcons:o})=>{let[r,n]=useState(null);return jsx(Stack,{children:e.map(i=>i.children.length?jsxs(Fragment,{children:[jsxs(Group,{spacing:0,noWrap:true,children:[jsx(UnstyledButton,{w:"100%",component:"a",onClick:t,href:`#bespoke-title-${i.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[o&&jsx(je,{...i.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:i.label}})]})},i.id),jsx(ActionIcon,{component:"a",size:"lg",onClick:()=>n(a=>a===i.id?null:i.id),children:jsx(IconChevronDown,{style:{transition:"transform 0.2s",transform:r===i.id?"rotate(-180deg)":"none"},stroke:1})})]},i.id),jsx(Collapse,{in:r===i.id,pl:"sm",transitionTimingFunction:"linear",transitionDuration:200,children:jsx(tE,{contentOutline:i.children,closeNav:t,showIcons:o})})]}):jsx(Group,{noWrap:true,children:jsx(UnstyledButton,{display:"flex",w:"100%",component:"a",href:`#bespoke-title-${i.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[o&&jsx(je,{...i.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:i.label}})]})},i.id)},i.id))})},tV=({contentOutline:e,showIcons:t,titleElement:o,wrapper:r})=>{let[n,{toggle:i}]=useDisclosure(false),a=n?"Close content outline":"Open content outline";return jsxs(Box,{className:"bespoke-mobile-nav",component:"nav",children:[jsxs(r.element,{className:"bespoke-mobile-nav-header",...r.props,onClick:i,children:[o&&o,jsx(ActionIcon,{className:"bespoke-mobile-nav-toggle","aria-label":a,size:"lg",variant:"subtle",children:n?jsx(IconChevronUp,{size:"xl",stroke:1.5}):jsx(IconChevronDown,{size:"xl",stroke:1.5})})]}),jsx(Collapse,{in:n,mt:"md",className:"bespoke-mobile-nav-body",children:jsx(tE,{contentOutline:e,closeNav:i,showIcons:t})})]})},oV=({contentOutline:e,showIcons:t,align:o})=>{let[r,n]=useState(null),[i,a]=useState(null);useEffect(()=>{let s=()=>{let c=document.querySelector(".bespoke-nav");if(!c)return;let u=c.getBoundingClientRect(),d=false;e.forEach(f=>{let g=document.getElementById(`bespoke-title-${f.id}`);g&&(g.getBoundingClientRect().top<=u.bottom&&(n(f.id),a(null),d=true),f.children.forEach(h=>{let y=document.getElementById(`bespoke-title-${h.id}`);y&&y.getBoundingClientRect().top<=u.bottom&&(a(h.id),n(f.id),d=true);}));}),d||(n(null),a(null));};return window.addEventListener("scroll",s),()=>{window.removeEventListener("scroll",s);}},[e]);let l=s=>!s||!s?.length?null:jsx(Fragment,{children:s.map(c=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${c.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(je,{...c.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:c.label}})]})})}),jsx(Box,{pl:"xs",children:l(c.children)})]},c.id))});return jsxs(Box,{component:"nav",className:"bespoke-nav",children:[jsx(List,{className:"bespoke-nav-level1",sx:qk(o),children:e?.map(s=>jsx(List.Item,{children:jsx(Anchor,{href:`#bespoke-title-${s.id}`,"data-active":r===s.id,onClick:()=>n(s.id),children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(je,{...s.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:s.label}})]})})},s.id))}),r&&e.find(s=>s.id===r)?.children.length>0&&jsx(List,{className:"bespoke-nav-level2",sx:qk(o),children:e.find(s=>s.id===r)?.children.map(s=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:200,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${s.id}`,"data-active":s.id===i,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[t&&jsx(je,{...s.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:s.label}})]})})}),s?.children?.length?jsx(Menu.Dropdown,{children:l(s.children)}):null]})},s.id))})]})};});function Og(e){let{related_reports:t,settings:o}=e,r=H(f=>f.status.currentLocale),n=H(f=>f.status.localeDefault),i=es(),a=useRouter(),{components:l}=Oo();if(!t?.length)return;let s=r===n?"":`/${r}`,c=f=>{a.push(`${f}`);},u=l?.ReportTile?l.ReportTile:dg,d=Po(o&&o.align?String(o.align):"center");return jsx(Grid,{justify:d,children:t.map(f=>{let g=`${s}${i}${f.link}`,m=f.entities.map(C=>({original_id:C.id,name:C.name,id:C.content_id,variant:C.variant_name,variant_id:C.variant_id,dimension:C.dimension_name,dimension_id:C.dimension_id,image:{src:`/api/cms/member/image?member=${C.content_id}&size=thumb`,alt:C.name}})),h=f.entities.map(C=>C.id).join("-"),y=f.entities.map(C=>C.name).join(" & "),S=f.entities[0]?f.entities[0].report_id:null,v=C=>{C.preventDefault(),c(g);};return jsx(Grid.Col,{xs:12,sm:6,md:4,lg:4,xl:3,children:jsx(u,{reportId:S,reportName:y,members:m,href:g,onClick:v})},h)})})}var nE=D(()=>{p();se();ye();mg();no();ro();});function Lg({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:i}){let a=tt(e).data,{sectionVariables:l,resetSectionVariables:s}=pt(a?.section_id),c=!!Object.keys(l).length,u=Po(o&&o.align?o.align:"left");return !c&&!i?null:jsx(Button,{onClick:()=>s(),disabled:!c,fullWidth:n,sx:{justifySelf:u},children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})}var aE=D(()=>{p();ye();ro();});function Mg({settings:e,label:t,removeLabel:o,showIcon:r,position:n="center",asComparison:i=false}){let a=H(C=>C.records.entities.report),l=H(C=>C.variables.attributes),s=e&&e.search?e.search:"inline",c=Object.values(a)[0].settings,u=useRouter(),{comparisonLoaded:d,loading:f}=Pr(),g=Object.keys(u.query).includes("compare"),h=d&&g?jsx(Button,{onClick:()=>{let C={...u.query};delete C.compare,u.push({pathname:u.pathname,query:C},void 0,{shallow:true});},rightIcon:jsx(IconX,{}),children:o||"Remove Comparison"}):jsx(Button,{loading:f,children:jsxs(Group,{align:"center",children:[t||"Add Comparison",r&&jsx(IconPlus,{})]})}),y={searchReportParams:{report:[Number(Object.keys(a)[0])],variant:c.compareLevels?[]:[l.variant_id1]}},v=Os(h,s,C=>{u.push({pathname:u.pathname,query:{...u.query,compare:C.reportPath}});},y);return i?null:jsx(Group,{position:n,children:g?h:v})}var cE=D(()=>{p();no();se();ai();});function Dg({columns:e=[],data:t=[],tableProps:o={},sectionId:r=null}){let[n,i]=useState(false),[a,l]=useState({}),s=useMemo(()=>e.map(f=>f.accessorKey),[e]),c=useMemo(()=>t.filter(f=>typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).some(g=>s.includes(g))),[s,t]),u=useMemo(()=>e.map(f=>({...f,Cell:({renderedCellValue:g})=>jsx(ve,{html:`${g}`}),filterFn:"contains"})),[e]),{locale:d}=useRouter();return useEffect(()=>{(async()=>{try{let g=d||"en",m=`${g.toUpperCase()}`,h=await import(`mantine-react-table/locales/${g}.js`);l(h[`MRT_Localization_${m}`]);}catch(g){console.error("Error loading translations:",g);}})();},[d]),jsx(MantineReactTable,{...o,autoResetPageIndex:false,columns:u,data:c,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",layoutMode:"grid",localization:a,onIsFullScreenChange:f=>{let g=document.getElementById(`section-${r}`);g&&(f?g.style.zIndex="10":g.style.zIndex="1"),i(f);},state:{...o.state,isFullScreen:n}})}var dE=D(()=>{p();mt();});function _g({label:e,url:t,settings:o}){let{align:r}=o;return e?jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})}):null}var fE=D(()=>{p();});function xV({block:e}){let{id:t}=e;return jsxs(Stack,{align:"center",spacing:"sm",children:[jsx(ThemeIcon,{radius:"md",size:100,children:jsx(IconCircleKey,{size:100})}),jsxs(Title,{order:5,children:["Private content (Block ",t,")"]}),jsx(Text,{children:"Sorry, you do not have sufficient permissions to view this block."}),jsx(Text,{children:"Contact your account manager to check your access role."})]})}function Ng(e){let t=TV();return jsx(t,{block:e})}var TV,bE=D(()=>{p();no();TV=()=>{let{components:e}=Oo(),t=xV;return e?.CustomFallback&&(t=e.CustomFallback),t};});var Rn,Dp=D(()=>{p();Rn=class extends wn__default.Component{constructor(t){super(t),this.state={hasError:false};}static getDerivedStateFromError(t){return console.info("getDerivedStateFromError",t),{hasError:true}}componentDidCatch(t,o){console.error("Error information:",o.componentStack),notifications.show({autoClose:false,color:"red",id:"revalidate-error",message:"Check the console for more details",title:t.message});}render(){return this.state.hasError?this.props.fallback:this.props.children}};});var SE={};ym(SE,{default:()=>vE});function vE(e){let{print:t}=cr(),{block:o,active:r,locale:n,variables:i,configOverride:a={}}=e,l=ko(o),s=Io(n),c={variables:i},u=useRouter(),{sectionVariables:d,setSectionVariables:f,resetSectionVariables:g}=pt(o.section_id),m=vn(),h=we(),y=JSON.stringify(d),S=useMemo(()=>{if(!l?.logic)return {error:"Add a Configuration"};let R=xr({logic:l.logic},s,c).logic,O={router:u,section:{variables:d,setVariables:f,resetVariables:g}};return pa(R,s,i,n,o.id,{},O,m,h)},[o,r,i,y,h.status]),{type:v}=S.config||{},C=v&&zg[v]?v:"Treemap";zg[v]||(S.config={error:`"${v}" is not a valid Visualization Type`});let b=zg[C],k=useMemo(()=>{let{_data:R,...O}=S.config;return RV(O,t)},[S,t]),w={locale:n,variables:i,...k,...a};return jsx("div",{className:"bespoke-Viz","data-ignore-print":w._printIgnore?"true":void 0,children:jsx("div",{style:{display:"flex",flex:"1 1 100%",minHeight:v===da?void 0:400},children:jsx(Rn,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(b,{style:{flex:1},dataFormat:R=>{let O;try{O=S.dataFormat(R);}catch(A){console.error("Error in dataFormat: ",A),O=[];}return O},linksFormat:S.linksFormat,nodesFormat:S.nodesFormat,topojsonFormat:S.topojsonFormat,config:{...w,sectionVariables:y}},"viz-key")})})})}var zg,RV,xE=D(()=>{p();Ho();cc();zi();ye();Xe();Dp();En();vp();zg={...EV,[da]:yp},RV=(e,t)=>{let o={...e};return t&&(o.detectResize=false,o.detectResizeDelay=0,o.detectVisible=false,o.detectVisibleInterval=0,o.duration=0,o.shapeConfig={...o.shapeConfig,duration:0}),o};});var AV,TE=D(()=>{p();he();LT();BT();_T();Ck();Rk();Ik();Ak();jk();oE();nE();aE();cE();dE();fE();bE();AV=IV(()=>Promise.resolve().then(()=>(xE(),SE)),{ssr:false}),{[E.PARAGRAPH]:Qf,[E.STAT]:eg,[E.SUBTITLE]:tg,[E.TITLE]:yg,[E.SELECTOR]:Tg,[E.VIZ]:AV,[E.GENERATOR]:wp,[E.SECTION_FLAG]:wp,[E.IMAGE]:Cg,[E.NAV]:Ag,[E.RELATED]:Og,[E.RESET_BUTTON]:Lg,[E.COMPARISON_BUTTON]:Mg,[E.TABLE]:Dg,[E.BUTTON]:_g,[E.MULTIHIERARCHY_SELECTOR]:Ig,[E.FALLBACK]:Ng};});var CE=D(()=>{p();he();TE();Bs();Ho();ye();Vr();Ka();Ml();Om();Mm();ai();});var ha,PV,_p,Cc=D(()=>{p();ha={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"}]}},PV=Object.keys(ha).reduce((e,t)=>(e[t]=ha[t].defaultValue,e),{}),{memberImageBg:false,optionsMenu:false,optionData:true,optionImage:true,optionShare:true,showAnchor:false,...PV},_p=e=>({data:typeof e.optionData=="boolean"?e.optionData:true,image:typeof e.optionImage=="boolean"?e.optionImage:true,share:typeof e.optionShare=="boolean"?e.optionShare:true});});function Vg({previews:e}){let t=e.map((o,r)=>({key:o?`bg-${o.content_id}`:`bg-${r}`,src:o?`/api/cms/member/image?member=${o.content_id}&size=splash`:""}));return jsxs(Fragment,{children:[jsx(Group,{className:"cms-section-bg",grow:true,spacing:0,style:{position:"absolute",width:"100%",height:"100%"},children:t.map(o=>jsx("div",{className:"cms-section-member-bg",style:{backgroundImage:`url(${o.src})`,backgroundSize:"cover",backgroundPosition:"center center",height:"100%",width:"100%"}},o.key))}),jsx("div",{className:"cms-section-gradient-bg",style:{background:"white",position:"absolute",width:"100%",height:"100%",opacity:.33}})]})}var $g=D(()=>{p();});function Gg(e){let{section:t}=e,o=t.blocks||[],r=H(J=>o.map(G=>({...J.records.entities.block[G],status:J.variables.status[G]})).filter(G=>G.type===E.VIZ&&G.status.allowed)),{variant_slug1:n,slug1:i}=H(J=>J.variables.attributes),a=ri(),[l,s]=useState(Lr.section),[c,u]=useState(Mr.png),[d,f]=useState(false),[g,m]=useState(false),[h,y]=useState([]),[S,v]=useState(r.length>0?r[0].id:null),C=l!==Lr.section,{print:b,downloadLoading:k}=hf(t.id,n,i,C?S:null),[w,R]=useState(true),[O,A]=useState(false),B=ho("options"),_={...QV,...B.image_tab},{siteProps:P}=rs(),I=P?.logoSrc&&typeof P.logoSrc=="string",F=useMemo(()=>t?.settings?.name?xt(t?.settings?.name):`section-${t.id}`,[t.id,t?.settings?.name]),M=`#${F}`,N=useMantineTheme(),j=()=>{let J=z(S);return select(J).select("svg").size()===1},$=()=>`${xt(F)}`,V=()=>{let J=document.getElementById(F);return select(J).select(".bespoke-section-content").node()},z=J=>{let G=V();return select(G).select(`#bespoke-visualization-${J}.bespoke-block-area`).node()},q=()=>new Promise(J=>{let G;l===Lr.section?G=V():l===Lr.viz&&(G=z(S));let K=document.createElement("div");K.style.display="flex",K.style.justifyContent="space-between",K.classList.add("bespoke-share-source"),K.style.padding=N.spacing.xs,K.style.width="100%";let ee=document.createElement("div");if(ee.innerText=_.source.replace("{src}",`${window.location}${M}`),ee.style.fontSize=N.fontSizes.xs,K.appendChild(ee),I){let ae=document.createElement("img");ae.src=P.logoSrc,ae.style.height="30px",ae.onload=()=>J(G),ae.onerror=()=>{ae.remove(),J(G);},K.appendChild(ae),G.appendChild(K);}else G.appendChild(K),J(G);}),W=J=>{if(w)return "transparent";let G=select(J).style("background-color");return G!=="rgba(0, 0, 0, 0)"&&G!=="transparent"?G:J===document.body?"white":W(J.parentNode)},U=async(J,G)=>{let{toPng:K}=await import('html-to-image');K(J,{backgroundColor:G.background,cacheBust:true,filter:ee=>ee&&ee.classList?!G.exclusionClasses.some(ae=>ee.classList.contains(ae)):true}).then(ee=>{let ae=document.createElement("a");ae.download=`${G.filename}.png`,ae.href=ee,ae.click();}).catch(ee=>{console.error("Error generating image",ee);}).finally(()=>{JV(),f(false);});},Y=(J,G)=>{saveElement(J,{filename:G.filename,type:"svg",callback:()=>f(false)},{background:G.background});},ne=async()=>{f(true);let J=await q(),G={background:W(J),exclusionClasses:["export-hidden"],filename:$()},K=c===Mr.png?U:Y;try{if(J)K(J,G);else throw new Error(_.wrong_node)}catch{f(false);}},re=async()=>{let{toCanvas:J}=await import('html-to-image');Promise.all(r.map(G=>{let K=z(G.id),ee=K.querySelector("g.d3plus-geomap-tileGroup");ee&&(ee.style.display="none");let ae=select(K).select("svg").select("g").size()>0,ue=select(K).select("div.bespoke-html").size()>0,Te=ae||ue?K:ZV();return J(Te).then(X=>(ee&&(ee.style.display="block"),X))})).then(G=>{y(G.map(K=>K.toDataURL())),A(false);});};return useEffect(()=>{l===Lr.viz&&r.length>0?(v(r[0].id),A(true),re()):l===Lr.section&&y([]);},[l]),useEffect(()=>{S&&(j()?m(true):(m(false),u(Mr.png)));},[S]),jsxs(Stack,{className:"cms-section-options-image",children:[r.length>0?jsx(Input.Wrapper,{label:`${_.choose_area}:`,children:jsx(SegmentedControl,{fullWidth:true,value:l,data:[{value:Lr.section,label:jsxs(Center,{children:[jsx(IconTemplate,{size:"1rem"}),jsx(Box,{ml:10,children:_.entire_section})]})},{value:Lr.viz,label:jsxs(Center,{children:[jsx(IconChartBar,{size:"1rem"}),jsx(Box,{ml:10,children:_.viz_only})]})}],onChange:J=>{s(J),J===Lr.section&&u(Mr.png);}})}):jsx(Text,{fw:"700",color:"gray.7",children:`${_.entire_section}:`}),l===Lr.viz&&r.length>0&&jsxs(Input.Wrapper,{label:`${_.choose_viz}:`,style:{minHeight:"161px",position:"relative"},children:[!O&&h.length>0&&jsx(ScrollArea,{style:{height:250},children:jsx(SimpleGrid,{cols:3,children:r.map((J,G)=>jsx(Image,{alt:`Viz ${J.id}`,onClick:()=>{v(J.id);},style:{cursor:"pointer",border:S===J.id?"4px solid #228be6":"4px solid #eee"},radius:0,src:h[G],withPlaceholder:true,styles:()=>({figure:{height:"100%"},imageWrapper:{height:"100%"}})},`viz-option-${J.id}`))})}),jsx(LoadingOverlay,{visible:O})]}),g&&l!==Lr.section&&jsx(Input.Wrapper,{label:`${_.choose_format}:`,children:jsxs(Button.Group,{children:[jsx(Button,{leftIcon:jsx(IconPolaroid,{size:16}),onClick:()=>u(Mr.png),variant:c===Mr.png?"filled":"default",fullWidth:true,children:Mr.png}),jsx(Button,{leftIcon:jsx(IconCode,{size:16}),onClick:()=>u(Mr.svg),variant:c===Mr.svg?"filled":"default",fullWidth:true,children:Mr.svg})]})}),jsx(Checkbox,{checked:w,label:`${_.transparent_bg}`,onChange:()=>R(!w),radius:"xl"}),jsx(Button,{leftIcon:jsx(IconDownload,{size:16}),loading:d||k,onClick:a&&c!==Mr.svg?()=>b(w):ne,fullWidth:true,children:jsx("span",{children:d||k?_.processing:_.download.replace("{imageFormat}",c)})})]})}var Lr,Mr,JV,QV,ZV,RE=D(()=>{p();Hr();se();Kr();Pt();st();he();Lr={viz:"viz",section:"section"},Mr={png:"PNG",svg:"SVG"},JV=()=>{let e=document.getElementsByClassName("bespoke-share-source");Array.from(e).forEach(t=>t.remove());},QV={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}"},ZV=()=>document.createElement("div");});function AE(e){let{title:t,url:o,disabled:r=false}=e,n=r?IconCode:IconLink;return jsx(Input.Wrapper,{label:t,children:jsx(Input,{icon:jsx(n,{}),value:o,disabled:r,readOnly:true,rightSection:jsx(CopyButton,{value:o,timeout:2e3,children:({copied:i,copy:a})=>jsx(Tooltip,{label:i?"Copied":"Copy",withArrow:true,position:"right",children:jsx(ActionIcon,{variant:i?"filled":"subtle",onClick:a,disabled:r,children:i?jsx(IconClipboardCheck,{size:16}):jsx(IconClipboardCopy,{size:16})})})})})})}var PE=D(()=>{p();});function Wg(e){let{section:t}=e,[o,r]=useState(""),[n,i]=useState(""),[a,l]=useState(true),s=ho("options"),c={...E$,...s.share_tab};return useEffect(()=>{i(document.title);let{origin:u,pathname:d}=window.location,f=`${u}${d}`,g=a?t.settings?.name?.length?`#${xt(t.settings.name)}`:`#section-${t.id}`:"";r(`${f}${g}`);},[a]),jsxs(Stack,{className:"cms-section-options-share",children:[jsx(AE,{title:`${c.title}: ${n}`,url:o}),jsx(Checkbox,{checked:a,label:c.include_section,onChange:()=>l(!a),radius:"xl"}),jsxs(Group,{position:"center",children:[jsx(FacebookShareButton,{url:o,children:jsx(FacebookIcon,{size:32,round:true})}),jsx(TwitterShareButton,{url:o,title:n,children:jsx(TwitterIcon,{size:32,round:true})}),jsx(TelegramShareButton,{url:o,title:n,children:jsx(TelegramIcon,{size:32,round:true})}),jsx(WhatsappShareButton,{url:o,title:n,separator:":: ",children:jsx(WhatsappIcon,{size:32,round:true})}),jsx(LinkedinShareButton,{url:o,children:jsx(LinkedinIcon,{size:32,round:true})}),jsx(RedditShareButton,{url:o,title:n,windowWidth:660,windowHeight:460,children:jsx(RedditIcon,{size:32,round:true})}),jsx(EmailShareButton,{url:o,subject:n,children:jsx(EmailIcon,{size:32,round:true})})]})]})}var E$,LE=D(()=>{p();PE();Kr();Hr();E$={title:"Title",include_section:"Include Section"};});function M$({panels:e,value:t,onTabChange:o}){let r=useRef(null),[n,i]=useState(false),[a,l]=useState(false),s=Object.keys(e),c=()=>{let d=r.current;if(!d)return;let{scrollLeft:f,scrollWidth:g,clientWidth:m}=d;i(f>0),l(f<g-m);};useEffect(()=>{let d=r.current;if(d)return c(),d.addEventListener("scroll",c),()=>{d.removeEventListener("scroll",c);}},[]);let u=d=>{let f=r.current;if(!f)return;let g=d==="left"?-150:150;f.scrollBy({left:g,behavior:"smooth"});};return jsxs(Box,{className:"bespoke-report-modal-tabs-container",pos:"relative",sx:{flexGrow:1,maxWidth:"calc(100% - 38px)"},children:[jsx(Box,{"data-direction":"left",display:n?"flex":"none",sx:BE,children:jsx(ActionIcon,{onClick:()=>u("left"),children:jsx(IconChevronLeft,{size:20})})}),jsx(Tabs,{ref:r,value:t,onTabChange:o,sx:L$,children:jsx(Tabs.List,{className:"bespoke-report-modal-tabs",sx:{flexWrap:"nowrap",width:"fit-content"},children:s.map(d=>jsx(Tabs.Tab,{className:"bespoke-report-modal-tab",value:d,children:e[d].label},d))})}),jsx(Box,{display:a?"flex":"none","data-direction":"right",sx:BE,children:jsx(ActionIcon,{onClick:()=>u("right"),children:jsx(IconChevronRight,{size:20})})})]})}function B$({className:e,opened:t,onClose:o,panels:r}){let[n,i]=useState(Object.keys(r)[0]);return jsxs(Modal.Root,{className:clsx("bespoke-report-modal",e),opened:t,onClose:o,size:"xl",centered:true,children:[jsx(Modal.Overlay,{className:"bespoke-report-modal-overlay"}),jsxs(Modal.Content,{children:[jsx(Modal.Header,{className:"bespoke-report-modal-header",children:jsxs(Group,{w:"100%",position:"apart",spacing:"md",noWrap:true,children:[jsx(M$,{panels:r,value:n,onTabChange:a=>a&&i(a)}),jsx(Modal.CloseButton,{className:"bespoke-report-modal-close-btn",ml:0})]})}),jsx(Modal.Body,{className:"bespoke-report-modal-body",children:r[n].component})]})]})}var L$,BE,Yg,Xg=D(()=>{p();L$={overflowX:"auto",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",flexWrap:"nowrap"},BE={height:"100%",zIndex:1,top:0,width:50,position:"absolute",backgroundSize:"cover",display:"flex",alignItems:"center","&[data-direction='left']":{background:"linear-gradient(to right, rgba(255, 255, 255, 1) 15px, rgba(255, 255, 255, 0))",left:0,justifyContent:"flex-start"},"&[data-direction='right']":{background:"linear-gradient(to left, rgba(255, 255, 255, 1) 15px, rgba(255, 255, 255, 0))",right:0,justifyContent:"flex-end"}};Yg=B$;});function NE(e){let{section:t,initialMode:o,onEnds:r,open:n,title:i}=e,a=_p(t.settings),l=useMemo(()=>N$.filter(g=>a[g]),[a]),[s,c]=useState(o||l[0]||"data"),u=ho("options");useEffect(()=>{o!==s&&c(o);},[o]);let d={...Jg,...u};useMemo(()=>jsxs(Fragment,{children:[jsxs(Tabs.List,{children:[a.data&&jsx(Tabs.Tab,{value:"data",children:d.download_title}),a.image&&jsx(Tabs.Tab,{value:"image",children:d.image_title}),a.share&&jsx(Tabs.Tab,{value:"share",children:d.share_title})]}),a.data&&jsx(Tabs.Panel,{value:"data",children:jsx(cg,{section:t})}),a.image&&jsx(Tabs.Panel,{value:"image",children:jsx(Gg,{section:t})}),a.share&&jsx(Tabs.Panel,{value:"share",children:jsx(Wg,{section:t})})]}),[a,t,d]);return jsx(Yg,{className:"cms-section-options-modal",opened:n,onClose:()=>r(),panels:{data:{label:d.download_title,component:jsx(cg,{section:t})},image:{label:d.image_title,component:jsx(Gg,{section:t})},share:{label:d.share_title,component:jsx(Wg,{section:t})}}})}var Jg,N$,zE=D(()=>{p();ug();RE();LE();Kr();Cc();Xg();Jg={download_title:"Download Data",image_title:"Save Image",share_title:"Share Link"},N$=["data","image","share"];});function Qg(e){let{sectionId:t,disabled:o=false}=e,[r,n]=useState(false),[i,a]=useState("data"),l=Ko(t),s=ho("options"),c={...Jg,...s},u=_p(l.isSuccess?l.data.settings:{}),d=g=>{a(g),n(true);},f=()=>{n(false);};return jsxs("div",{className:"cms-section-options",children:[jsxs(Button.Group,{children:[u.data&&jsx(Button,{variant:"default",size:"xs",compact:true,onClick:()=>d("data"),"aria-label":c.download_title,disabled:o,children:jsx(IconTable,{size:16})}),u.image&&jsx(Button,{variant:"default",size:"xs",compact:true,onClick:()=>d("image"),"aria-label":c.image_title,disabled:o,children:jsx(IconCamera,{size:16})}),u.share&&jsx(Button,{variant:"default",size:"xs",compact:true,onClick:()=>d("share"),"aria-label":c.share_title,disabled:o,children:jsx(IconShare,{size:16})})]}),l.isSuccess&&jsx(NE,{section:l.data,initialMode:i,open:r,onEnds:f})]})}var Zg=D(()=>{p();zE();se();Kr();Cc();});function K$({children:e,containerProps:t},o){return jsx(Flex,{ref:o,className:"bespoke-section-content",pos:"relative",align:"stretch",p:0,direction:{base:"column",md:"row"},wrap:"wrap",...t,children:e})}var eh,GE,th,oh=D(()=>{p();se();Sn();eh=wn__default.forwardRef(function({children:t,column:o,basis:r,columnSettings:n={},sx:i={},...a},l){let s=Object.values(o).some(f=>f.settings?.display==="inline"),c=n?.width?`${n.width}px`:r,u=n?.width?`${n?.width}px`:"100%",d=n?.full?"100%":u;return jsx(Flex,{ref:l,className:"bespoke-section-col",align:"flex-start",direction:s?"row":"column",wrap:s?"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%":c},...packSx(i)],...a,children:t})}),GE=({sectionId:e,columnIndex:t})=>{let o=ie(),r=Ko(e).data,{settings:n,updateSettings:i}=Rr(e);if(!r)return null;let{columnSettings:a={}}=n,{width:l=void 0}=a[t]?a[t]:{},s=d=>{r&&i("columnSettings",{...a,[t]:{width:parseInt(d.target.value,10)}});},c=()=>{r&&o(Z.updateEntity("section",{id:e,settings:{...r.settings,columnSettings:{...a,[t]:{width:void 0}}}}));};return jsxs(Group,{className:"bespoke-resize-col",pos:"absolute",top:-12,left:"50%",sx:{borderRadius:"4px",transform:"translate(-50%, 0%)",zIndex:20},py:0,px:"xs",maw:180,bg:"white",noWrap:true,children:[jsx(Checkbox,{label:"100%",size:"xs",onChange:d=>{i("columnSettings",{...a,[t]:{...a[t]||{},full:d.currentTarget.checked}});},checked:a[t]?.full}),jsx(Input,{placeholder:"auto",w:"fit-content",miw:"none",variant:"filled",type:"number",value:l||"auto",maw:110,onChange:s,size:"xs",p:0,rightSection:jsx(IconX,{onClick:c,size:8})})]})},th=wn__default.forwardRef(K$);});var mi,Vp=D(()=>{p();mi={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}};});var HE=D(()=>{p();En();});var WE=D(()=>{p();se();Gr();CE();Cc();Go();$g();Zg();no();he();oh();ic();Vp();En();Kr();HE();ai();Hr();Pt();no();});function Do({target:e,dropdown:t}){let[o,{open:r,close:n}]=useDisclosure(false),i=useRef(true),a=()=>{setTimeout(()=>{i.current&&n();},1e3);},l=()=>{i.current=false;},s=()=>{i.current=true,n();};return jsxs(Group,{children:[e,jsxs(Popover,{opened:o,trapFocus:true,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"subtle",color:"blue",onMouseEnter:r,onMouseLeave:a,children:jsx(IconInfoCircle,{})})}),jsx(Popover.Dropdown,{maw:350,onMouseEnter:l,onMouseLeave:s,children:jsxs(Group,{align:"flex-start",noWrap:true,children:[jsx("div",{children:jsx(ThemeIcon,{variant:"outline",sx:{border:"none"},children:jsx(IconInfoCircle,{})})}),jsx("div",{children:t})]})})]})]})}var $p=D(()=>{p();});function va({value:e,onChange:t,item:o="block"}){let r=ie(),[n,i]=useState([]),a=useMemo(()=>[{value:"public",label:`Public ${o}, (all visitors)`,group:"Exclusive"},{value:"guest",label:`Guest only ${o}, (non logged visitors)`,group:"Exclusive"},{value:"private",label:`Private ${o}, (session required, any role)`,group:"Exclusive"}],[o]),l=useMemo(()=>n.map(c=>({value:`role.${c.name}`,label:`Role ${c.name} (${c.type})`,group:`${c.type} Roles`})),[n]);useEffect(()=>{r(Z.searchRole()).then(c=>{i(c.roles);});},[r]);let s=c=>{let u=[];if(c.length===0)u=[a[0].value];else {let d=c.slice(-1)[0],f=a.map(m=>m.value);u=f.includes(d)?[d]:c.filter(m=>!f.includes(m));}t(u);};return jsx(MultiSelect,{label:"Privacy",description:`This ${o} will be shown based on the selected roles.`,data:[...a,...l],value:e,onChange:s})}var Up=D(()=>{p();se();});function ih(){let e=Xt(),t=Number.parseInt(e.params[0]),o=zt(t).data,n=H(qu).filter(P=>P.type===E.NAV),{settings:i,updateSettings:a}=Kl(t),{handlers:l}=Ft("reportEditor"),s=ri(),c=o?.dimensions&&o.dimensions.length>0,u=$l(o?.dimensions||[]),d=useMemo(()=>u.isSuccess?u.data.flatMap(P=>P.variants||[]):[],[u.data,u.isSuccess]),f=Ul(d),g=useMemo(()=>{if(!u.isSuccess||!f.isSuccess)return [];let P=u.data,I=f.data;return P.length===1?I.map(F=>({value:F.id.toString(),label:F.name,dimensionName:P[0].name})):P.length>1?P.map(N=>I.filter(j=>N.variants?.includes(j.id)||false)).reduce((N,j)=>N.flatMap($=>j.map(V=>[...$,V])),[[]]).filter(N=>N.length>0).map(N=>({value:N.map(j=>j.id).join(","),label:N.map(j=>j.name).join(" / "),dimensionName:N.map((j,$)=>`${P[$]?.name}: ${j.name}`).join(" | ")})):[]},[u.data,u.isSuccess,f.data,f.isSuccess]),m=i.pdf?.variants||[],h=i.pdf?.privacy||["public"],y=i.pdf?.navBlockId||(n.length>0?n[0].id:""),S=!!i.pdf?.sectionSelection,v=P=>{a("pdf",{...i.pdf,enabled:true,variants:P});},C=P=>{a("pdf",{...i.pdf,enabled:true,privacy:P});},b=P=>{let I=n.length>0?n[0].id:void 0;a("pdf",{...i.pdf,sectionSelection:P,navBlockId:P?i.pdf?.navBlockId||I:void 0});},k=P=>{a("pdf",{...i.pdf,navBlockId:P?parseInt(P):void 0});},w=P=>{if(P){let I=g.map(F=>F.value);a("pdf",{enabled:true,variants:I,privacy:["public"]});}else a("pdf",{enabled:false,variants:[],privacy:[],sectionSelection:false,navBlockId:void 0});},R=i.xlsx?.variants||[],O=i.xlsx?.privacy||["public"],A=P=>{a("xlsx",{...i.xlsx,enabled:true,variants:P});},B=P=>{a("xlsx",{...i.xlsx,enabled:true,privacy:P});},_=P=>{if(P){let I=g.map(F=>F.value);a("xlsx",{enabled:true,variants:I,privacy:["public"]});}else a("xlsx",{enabled:false,variants:[],privacy:[]});};return jsx(Fragment,{children:jsxs(Stack,{children:[jsx(Button,{variant:"outline",radius:0,onClick:l.open,children:"Edit Report"}),c&&jsxs(Accordion,{children:[jsxs(Accordion.Item,{value:"comparison",children:[jsx(Accordion.Control,{children:"Profile Comparison"}),jsxs(Accordion.Panel,{children:[jsx(Do,{target:jsx(Switch,{label:"Enable comparison",checked:!!i.comparison,onChange:P=>a("comparison",P.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Comparisons"}),jsx(Text,{fw:400,children:"This feature will allow user visiting this profile to compare it side by side to another choosen profile"})]})}),i.comparison&&jsx(Do,{target:jsx(Switch,{label:"With different levels",checked:!!i.compareLevels,onChange:P=>a("compareLevels",P.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Compare with different Levels"}),jsx(Text,{fw:400,children:"Allow users to compare profiles from differet Levels."})]})})]})]}),jsxs(Accordion.Item,{value:"pdf",children:[jsx(Tooltip,{label:"PDF Export is not configured",disabled:s,children:jsx("span",{children:jsx(Accordion.Control,{disabled:!s,children:"PDF Export"})})}),jsxs(Accordion.Panel,{children:[jsx(Do,{target:jsx(Switch,{label:"Enable PDF export",checked:!!i.pdf?.enabled,onChange:P=>w(P.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"PDF Exports"}),jsx(Text,{fw:400,children:"This feature will allow user to download the PDF version of the report with a single click."})]})}),i.pdf?.enabled&&jsxs(Stack,{mt:"md",children:[n.length>0&&jsxs(Fragment,{children:[jsx(Switch,{label:"Enable Section selection in PDF export",checked:S,onChange:P=>b(P.currentTarget.checked)}),S&&jsx(Select,{data:n.map(P=>({value:P.id.toString(),label:`Nav Block #${P.id}`})),label:"Select Navigation Block for PDF sections",description:"The PDF export selection should be based on a Navigation block.",placeholder:"Select Nav Block",ml:"xl",size:"xs",value:y.toString(),onChange:k})]}),jsx(va,{value:h,onChange:C,item:"PDF export"}),g.length>0&&jsxs(Fragment,{children:[jsx(Text,{fw:500,size:"sm",children:"Select variants to enable PDF export:"}),jsx(Checkbox.Group,{value:m,onChange:v,children:jsx(Stack,{spacing:"xs",children:g.map(P=>jsx(Checkbox,{value:P.value,label:P.label,description:P.dimensionName,size:"sm"},P.value))})})]})]})]})]}),jsxs(Accordion.Item,{value:"xlsx",children:[jsx(Accordion.Control,{children:"XLSX Export"}),jsxs(Accordion.Panel,{children:[jsx(Do,{target:jsx(Switch,{label:"Enable XLSX export",checked:!!i.xlsx?.enabled,onChange:P=>_(P.currentTarget.checked)}),dropdown:jsxs(Fragment,{children:[jsx(Text,{fw:700,children:"Xlsx Exports"}),jsx(Text,{fw:400,children:"This feature will allow user to download the XlSX version of the report visualizations."})]})}),i.xlsx?.enabled&&jsxs(Stack,{mt:"md",children:[jsx(va,{value:O,onChange:B,item:"XLSX export"}),g.length>0&&jsxs(Fragment,{children:[jsx(Text,{fw:500,size:"sm",children:"Select variants to enable XLSX export:"}),jsx(Checkbox.Group,{value:R,onChange:A,children:jsx(Stack,{spacing:"xs",children:g.map(P=>jsx(Checkbox,{value:P.value,label:P.label,description:P.dimensionName,size:"sm"},P.value))})})]})]})]})]})]})]})})}var ah=D(()=>{p();ye();Sn();$p();st();Up();Gr();he();});var XE=D(()=>{p();Kr();Tp();se();st();no();us();Xg();});var QE=D(()=>{p();});function cr(){let e=useContext(lU);if(e===void 0)throw new Error("usePrint must be used within a PrintContext");return e}var lU,En=D(()=>{p();se();Go();WE();ai();Tp();no();st();ah();XE();QE();lU=createContext({print:false,isEmbed:false});});function Ut(e){let{content:t,style:o={}}=e,{print:r}=cr(),n=jsx(ve,{component:"span",html:t,isPreview:true}),i=useMemo(()=>r?jsx("div",{className:"bespoke-inner-tooltip-notification",children:jsx(Notification,{icon:jsx(IconInfoCircle,{size:"1.1rem"}),withCloseButton:false,withBorder:true,styles:{root:{boxShadow:"none"}},children:n})},"tooltip-notification"):jsx("div",{className:"bespoke-inner-tooltip",style:o,children:jsx(Tooltip,{label:n,withArrow:true,withinPortal:true,multiline:true,maw:220,children:jsx(ActionIcon,{size:"1.5rem",children:jsx(IconInfoCircle,{})})})},"tooltip"),[r,t,o]);return jsx(Fragment,{children:i})}var Cn=D(()=>{p();En();mt();});function lh({paragraph:e,tooltip:t,settings:o}){return jsx(ve,{component:"p",html:e||`Lorem ipsum dolor sit amet,
42
42
  consectetur adipiscing elit. Etiam justo purus, placerat ac turpis at,
43
43
  dignissim interdum eros. Curabitur non tincidunt libero.
44
44
  Suspendisse quis nibh in massa tincidunt feugiat sit amet vitae nisl.
45
45
  In pulvinar sapien ut tincidunt volutpat. Donec auctor tellus eu augue feugiat,
46
- a viverra sapien pulvinar.`,style:o,append:t?jsx(Ut,{content:t,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{}),isPreview:true})}var ZE=N(()=>{p();En();ft();});function lh({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:c,_iconPadding:u}){let d=t||"<span class='cr-block-placeholder'>Title</span>",m=o||"<span class='cr-block-placeholder'>Big Stat</span>",g=e||"<span class='cr-block-placeholder'>Subtitle</span>",f=n&&n.align||"left";return jsx("div",{className:"bespoke-Stat-root",children:jsxs(Group,{className:"bespoke-StatGroup-wrapper",position:ro(f),children:[i!=="none"&&i&&jsx(Ke,{blockType:"stat",iconType:i,iconVariant:a,iconRadius:s,iconSize:c,icon:l,iconPadding:u}),jsxs("div",{className:"bespoke-Stat-wrapper",children:[jsx(ye,{component:"div",size:"md",html:d,style:n,isPreview:true}),jsx(ye,{component:"div",size:"xl",html:m,style:n,isPreview:true}),jsx(ye,{component:"div",size:"sm",html:g,style:n,isPreview:true})]},"stat"),r&&jsx(Ut,{content:r})]})})}var tw=N(()=>{p();En();wn();ft();no();});function ch({subtitle:e,tooltip:t,settings:o}){let r=He(e)||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{spacing:"sm",position:ro(n),children:[jsx(ye,{size:"sm",html:r,isPreview:true}),t&&jsx(Ut,{content:t,style:{display:"inline-flex"}})]})}var rw=N(()=>{p();En();Kr();ft();no();});function uh({title:e,tooltip:t,_iconType:o,_iconVariant:r,_icon:n,settings:i,_iconRadius:a,_iconSize:l,_iconPadding:s}){let c=He(e)||"Title",u=i&&i.order?parseInt(i.order,10):1,d=u<=6?u:1,m=!!(i&&i.search&&i.search!=="off"),g=i&&i.search?i.search:"",f=i&&i.align?i.align:"left";return jsxs(Group,{spacing:"sm",position:ro(f),children:[o!=="none"&&o&&jsx(Ke,{blockType:"title",iconType:o,iconVariant:r,iconRadius:a,iconSize:l,icon:n,iconPadding:s}),jsx(ye,{component:"h",order:d,style:i,html:c,isPreview:true}),m&&jsx(Tooltip,{label:`Click will open '${g}' report search`,children:jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})}),t&&jsx(Ut,{content:t})]})}var nw=N(()=>{p();En();Kr();wn();ft();no();});function mh(e){let{id:t,type:o,defaultValue:r,options:n,name:i,settings:a,hideLabel:l,component:s,resetSectionVars:c,section:u}=e,d=useDispatch(),m=useContext(De),g=H(D=>D.status.query),{sectionVariables:f,resetSectionVariables:h}=pt(u),v=OU(t),T=useMemo(()=>g[v]||r,[g[v],o,r]),y=useMemo(()=>LU(g[v],r),[g[v],o,r]),[C,b]=useState(n?.map(D=>({value:D.id,label:D.label,imageUrl:D.imageUrl}))||[]),[w,k]=useState((n||[]).map(D=>D.id).join("-"));useEffect(()=>{let D=n.map(z=>`${z.label}|${z.id}`).join("-");if(w===D)return;k(D);let L=n.map(z=>({value:z.id,label:z.label}));b(L);let R=o===xt.SINGLE?T:y;$i(o,R,n)||d(sf(m,v));},[JSON.stringify(n),t]);let I=()=>{c==="true"&&f&&h();},O=D=>{d(Xi(m,v,D)),I();},P=D=>{d(Xi(m,v,D.join())),I();},_=l==="true"?jsx(Fragment,{}):jsx(ye,{component:"div",html:i,size:"sm",style:a,isPreview:true});return C.length===0?jsx(Text,{c:"dimmed",size:"xs",children:"No options defined yet. Selector hidden in report."}):C.length===1?jsxs(Text,{c:"dimmed",size:"xs",children:["Only one option defined. Selector hidden in report. ",JSON.stringify(C)]}):{[xt.SINGLE]:s===Eu.SEGMENTED_CONTROL?jsxs("div",{children:[_,jsx(SegmentedControl,{data:C,value:C.map(D=>D.value).includes(T)?T:"",onChange:O,fullWidth:true})]}):jsx(Select,{label:_,data:C,value:T,onChange:O,itemComponent:MU,styles:{label:{display:l==="true"?"none":"block"}}}),[xt.MULTI]:jsx(MultiSelect,{label:_,data:C,value:y,onChange:P,styles:{label:{display:l==="true"?"none":"block"}}})}[o]}var OU,LU,MU,sw=N(()=>{p();Rr();Ru();he();ae();Pt();ft();xe();OU=e=>`selector${e}id`,LU=(e,t)=>e&&typeof e=="string"?e.split(","):t,MU=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{noWrap:true,children:[t&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});function GU({outputVariables:e,status:t,hasAPI:o=false,debug:r,type:n}){let[i,a]=useState(false),l=o&&!Object.keys(e).length&&!t.error,s=Object.keys(e).some(u=>u.startsWith("_"));return r?l?jsxs(Stack,{align:"center",children:[jsx(Loader,{}),jsxs(Text,{size:"sm",children:["Loading ",n]})]}):jsxs(Fragment,{children:[jsx(Divider,{label:"Output Variables",labelPosition:"center"}),s&&jsx(Switch,{label:"Show internal variables",mb:"xs",size:"xs",checked:i,onChange:u=>a(u.currentTarget.checked)}),jsx(Or,{variables:e,showInternal:i})]}):jsx(Center,{children:jsx(Badge,{color:"gray",variant:"outline",children:n.toUpperCase()},"type")})}var gh,lw=N(()=>{p();Ss();gh=GU;});function hh(e){let{alt:t,src:o,desc:r,title:n,settings:i,...a}=e,l=He(t),s=He(o),c=He(r),u=jsx("img",{src:s,alt:l,style:a}),d=i&&i.align?String(i.align):"left";return (c&&c.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Oo(d),spacing:"sm",children:[n&&jsx(ye,{component:"p",html:n,style:i,isPreview:true}),u,r&&jsx(ye,{component:"p",size:"sm",html:r,style:i,isPreview:true})]})),s&&l?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var cw=N(()=>{p();Kr();ft();no();});function vh({headings:e,settings:t,title:o,shortTitle:r,_iconType:n,_iconVariant:i,_icon:a,_iconRadius:l,_iconSize:s,_iconPadding:c}){let{min:u="1",max:d="6",icons:m="yes"}=t||{},g=He(o)||"",f=He(r||o)||"",h=g&&g.length>0,v=n&&n!=="none",T=f===g?`${g}`:`${g} (${f})`,y=ia(parseInt(u,10),parseInt(d,10),e),C=m==="yes",b=t&&t.align?String(t.align):"left",w=Is(b),k=ro(b),I=Oo(b),O=t&&t.titlePosition?String(t.titlePosition):"left",P=useMemo(()=>{let D={right:"left",left:"right"},L=h&&["left","right"].includes(O),R={};if(L){let z=O==="right";R={spacing:"xs",position:z&&D[k]?D[k]:k,style:{flexDirection:z?"row-reverse":"row"},noWrap:true};}else R={spacing:"xs",align:I,justify:"center",style:{flexDirection:O==="bottom"?"column-reverse":"column"}};return {element:L?Group:Stack,props:R}},[h,k,I,O]),_=D=>!D||!D?.length?null:jsx(Fragment,{children:D.map(L=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${L.id}`,children:jsxs(Group,{spacing:"sm",children:[C&&jsx(Ke,{...L.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:L.label}})]})})},L.id),jsx(Box,{pl:"xs",children:_(L.children)})]},L.id))});return jsxs(P.element,{pos:"relative",...P.props,children:[h&&jsxs(Group,{spacing:"xs",position:k,noWrap:true,children:[v&&jsx(Ke,{blockType:"title",iconType:n,iconVariant:i,iconRadius:l,iconSize:s,icon:a,iconPadding:c}),jsx(ye,{style:t,html:T,isPreview:true,lineClamp:1})]}),jsxs(List,{sx:D=>({display:"flex",gap:D.spacing.md,justifyContent:w,alignItems:"center",listStyleType:"none"}),children:[y?.map(D=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:400,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${D.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[C&&jsx(Ke,{blockType:"nav",...D.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:D.label}})]})})}),D?.children?.length?jsx(Menu.Dropdown,{children:_(D.children)}):null]})},D.id)),!y||y.length===0&&jsx(List.Item,{children:jsx(Text,{color:"dimmed",children:"- Include some titles as inputs to see the Nav component -"})})]})]})}var pw=N(()=>{p();st();wn();no();ft();wn();Kr();});function xh(e){let{related_reports:t,settings:o}=e;if(!t?.length)return jsx(Text,{children:"There are no available members related to your current selection and report."});let r=Is(o&&o.align?String(o.align):"left");return jsx(List,{sx:()=>({display:"flex",justifyContent:r,"& li":{marginRight:"1rem"}}),children:t.map(n=>jsx(List.Item,{children:n.entities.map(i=>i.name).join(" & ")},n.link))})}var mw=N(()=>{p();no();});function Ch({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:i}){let a=tt(e).data,{sectionVariables:l,resetSectionVariables:s}=pt(a?.section_id),c=!!Object.keys(l).length,u=Oo(o&&o.align?o.align:"left");return jsxs(Stack,{align:u,children:[!c&&!i&&jsx(Text,{size:"xs",ta:o?.align||"left",children:"Reset button will not be shown on its disabled state"}),jsx(Button,{onClick:()=>s(),disabled:!c,fullWidth:n,children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})]})}var gw=N(()=>{p();xe();no();});function kh({settings:e,label:t,showIcon:o,position:r="center"}){let n=e&&e.search?e.search:"";return jsxs(Group,{position:r,children:[jsx(Tooltip,{label:`Click will open '${n}' report search`,children:jsx(Button,{children:jsxs(Group,{align:"center",children:[t||"Comparison Button",o&&jsx(IconPlus,{})]})})}),jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})]})}var yw=N(()=>{p();});function wh({columns:e=[],id:t,data:o=[],tableProps:r={}}){let[n,i]=useState({}),{initialState:a}=r,l=a?.pagination?.pageIndex,s=a?.pagination?.pageSize,c=`table-${[t,l,s].filter(f=>f).join("-")}`,u=useMemo(()=>e.map(f=>f.accessorKey),[e]),d=useMemo(()=>o.filter(f=>typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).some(h=>u.includes(h))),[u,o]),m=useMemo(()=>e.map(f=>({...f,Cell:({renderedCellValue:h})=>jsx(ye,{html:`${h}`,isPreview:true}),filterFn:"contains"})),[e]),g=rs();return useEffect(()=>{(async()=>{try{let h=g||"en",v=`${h.toUpperCase()}`,T=await import(`mantine-react-table/locales/${h}.js`);i(T[`MRT_Localization_${v}`]);}catch(h){console.error("Error loading translations:",h);}})();},[g]),createElement(MantineReactTable,{...r,autoResetPageIndex:false,columns:m,data:d,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",key:c,layoutMode:"grid",localization:n,state:{...r.state,isFullScreen:false}})}var vw=N(()=>{p();ft();xe();});function Rh({label:e,url:t,settings:o}){let{align:r}=o;return jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})})}var xw=N(()=>{p();});function Ah(e){let t=useDispatch(),o=useContext(De),r=H(te=>te.status.query),n=MG(e.id),i=useMantineTheme(),{allLabel:a,colorKey:l,data:s,defaultValue:c,defaultValueType:u,iconKey:d,levels:m,limit:g,placeholder:f,searchIndexKey:h,searchIndexSeparator:v,resetSectionVars:T,section:y}=e,[C,b]=useState(false),[w,k]=useState(true),[I,O]=useState(""),[P,_]=useState(false),[D,L]=useState([""].slice(1)),{sectionVariables:R,resetSectionVariables:z}=pt(y),A=useMemo(()=>BG(r[`${n}-value`],c),[r,c,n]),V=useMemo(()=>r[`${n}-type`]||u,[r,u,n]),j=useCallback(()=>{T==="true"&&R&&z();},[T,R,z]),B=useCallback(te=>{j(),t(Xi(o,`${n}-value`,te.join()));},[t,o,n,j]),U=useCallback(te=>{j(),t(Xi(o,`${n}-type`,te));},[t,o,n,j]),$=useRef(null),Y=useRef(false),F=useRef(!!g&&g<A.length),G=D.length,J=m[G],ee=D.filter(Boolean);D.length>0&&ee.length===0&&ee.push(`${a} ${J?.label}`),useEffect(()=>{let te=()=>{k(true);};return window.addEventListener("touchmove",te),()=>{window.removeEventListener("touchmove",te);}},[]);let ne=useMemo(()=>PG(s,m,l,d,h,v),[l,s,d,m,h,v]),X=useMemo(()=>{let te=OG(I),Oe=Array.from(LG(ne,te)).reverse();return P?Oe:D.reduce((Ue,M)=>Ue.filter(Q=>!M||Q.searchindex.indexOf(M)>-1),Oe.filter(Ue=>Ue.type===J?.value))},[J,ne,I,P,D]),W=useRef(null),K=Rp({count:C?X.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>W.current,[]),overscan:10,rangeExtractor:useCallback(te=>hc(te),[])}),[oe,re]=useState(-1),ue=Math.min(oe,X.length-1),Ee=useCallback(te=>{let Oe=D.concat(te);P&&_(false),L(Oe);},[P,D]),q=useCallback(()=>{let te=D.slice(0,G-1);P&&_(false),L(te);},[P,D,G]),ce=useCallback(te=>{O(te.currentTarget.value),!F.current&&s.length>0&&b(true);},[s,O,F,b]),de=useCallback(()=>{O(""),B([]),$.current?.focus(),g&&(F.current=false);},[O,B,$,g,F]),Se=useCallback(te=>{let Oe=A.filter(Ue=>Ue!==te);B(Oe),g&&Oe.length<g&&(F.current=false);},[A,B,g,F]),$e=useCallback(te=>{V||U(te.type),V!==te.type?(U(te.type),B([te.value])):A.includes(te.value)?Se(te.value):g?(A.length<g&&B([...A,te.value]),A.length===g&&B([...A.slice(1),te.value])):B([...A,te.value]),O("");},[V,U,B,A,Se,g]),We=useCallback(()=>{A.length>0&&I.length===0&&(B(A.slice(0,-1)),b(true),g&&(F.current=false)),I.length>0&&O(I.slice(0,-1));},[A,I,B,O,b,g,F]),Qe=useCallback(()=>{k(te=>te&&(Y.current=te,!te)),re(te=>te+1>=X.length?te:te+1);},[re,X]),Co=useCallback(()=>{let te=X[ue];te&&$e(te);},[X,ue,$e]),Uo=useCallback(()=>{b(false);},[b]),po=useCallback(()=>{q(),re(0);},[re,q]),gn=useCallback(()=>{let te=X[ue];!P&&te&&te.type!==m[m.length-1]?.value&&(Ee(te.name),re(0));},[X,ue,P,m,re,Ee]),Hn=useCallback(()=>{k(te=>te&&(Y.current=te,!te)),re(te=>te-1<0?0:te-1);},[re]),Wn=({label:te,onRemove:Oe,...Ue})=>jsxs("div",{style:{alignItems:"center",backgroundColor:i.colorScheme==="dark"?i.colors.dark[7]:i.colors.gray[1],borderRadius:i.radius.sm,cursor:"default",color:i.colorScheme==="dark"?i.colors.dark[0]:i.colors.gray[7],display:"flex",fontSize:rem(12),fontWeight:500,height:rem(22),margin:`calc(${i.spacing.xs} / 2 - ${rem(2)}) calc(${i.spacing.xs} / 2)`,maxWidth:`calc(100% - ${rem(10)})`,paddingLeft:`calc(${i.spacing.sm} / 1.5)`,paddingRight:0,userSelect:"none"},...Ue,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:te}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:Oe,radius:2,size:"sm",sx:{color:i.colorScheme==="dark"?i.colors.dark[0]:i.colors.gray[7],marginLeft:`calc(${i.spacing.sm} / 6)`},tabIndex:-1})]}),jn=useMemo(()=>A.map(te=>ne.find(Oe=>Oe.value===te)).filter(te=>!!te).map((te,Oe)=>createElement(Wn,{...te,index:Oe,key:te.value,onRemove:Ue=>{Ue.preventDefault(),Ue.stopPropagation(),Se(te.value);}})),[A]),Kn=forwardRef(function({color:Oe,icon:Ue,label:M,value:Q,...se},Te){return jsx("div",{ref:Te,style:{cursor:"pointer",width:"100%"},...se,children:jsxs(Group,{align:"center",noWrap:true,spacing:"xs",w:"100%",children:[Ue&&jsx(Box,{bg:Oe??"transparent",component:"img",w:20,h:20,src:Ue}),jsx(Text,{lineClamp:1,size:"sm",children:M||Q})]})})}),{settings:Cl}=e,kl=e.hideLabel==="true"||!e.label?jsx(Fragment,{}):jsx(ye,{component:"div",html:e.label,size:"sm",style:Cl,isPreview:true});return jsx(Input.Wrapper,{label:kl,children:jsxs(Popover,{closeOnClickOutside:true,keepMounted:true,opened:C,onChange:b,onClose:()=>{re(0),O("");},onOpen:()=>{K.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>re(0),sx:{position:"relative","& .defaultValue":{backgroundColor:i.colorScheme==="dark"?i.colors.dark[5]:i.colors.gray[3],color:i.colorScheme==="dark"?i.colors.dark[1]:i.colors.gray[7]}},tabIndex:-1,children:[jsx("input",{type:"hidden",value:A.join(",")}),jsx(Input,{component:"div",multiline:true,onMouseDown:te=>{te.preventDefault(),!F.current&&s.length>0&&b(!C),$.current?.focus();},rightSection:A.length>0?jsx(CloseButton,{onClick:de,onMouseDown:te=>te.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:i.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${i.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:i.colorScheme==="dark"?i.colors.dark[3]:i.colors.gray[5],opacity:1}},children:[jn,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":C,onChange:ce,onKeyDown:getHotkeyHandler([["ArrowDown",Qe],["ArrowLeft",po],["ArrowRight",gn],["ArrowUp",Hn],["Backspace",We],["Enter",Co],["Escape",Uo]]),placeholder:A.length===0?f:void 0,ref:$,readOnly:F.current,style:{appearance:"none",backgroundColor:"transparent",border:0,color:"inherit",flex:1,fontSize:i.fontSizes.sm,marginLeft:`calc(${i.spacing.xs} / 2)`,maxHeight:rem(22),minWidth:rem(60),outline:0,padding:0},type:"search",value:I})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:te=>te.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:te=>te.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:te=>{te.stopPropagation();},px:"xs",position:"center",spacing:"xs",children:[jsx(Button,{onClick:()=>{re(0),_(true),L([]),X.length>0&&K.scrollToIndex(0);},size:"xs",variant:P?"filled":"outline",children:a}),m.map((te,Oe)=>jsx(Button,{onClick:()=>{P&&_(false);let Ue=[""].slice(1),M=Oe;for(;M--;)Ue[M]=D[M]||"";re(0),L(Ue),X.length>0&&K.scrollToIndex(0);},size:"xs",variant:!P&&D.length===m.findIndex(Ue=>Ue.value===te?.value)?"filled":"outline",children:te?.label},te?.value))]}),jsx(Divider,{})]}),G>0&&jsxs(Group,{align:"center",noWrap:true,px:"xs",children:[jsx(ActionIcon,{onClick:q,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:ee.map(te=>jsx(Text,{lineClamp:1,size:"xs",children:te},`${te}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>k(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:W,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${K.getTotalSize()}px`,position:"relative",width:"100%"},children:K.getVirtualItems().map(te=>{let Oe=X[te.index],Ue=ue===te.index,M=A.includes(Oe.value);return X.length>0&&Ue&&!w&&K.scrollToIndex(ue),jsxs(Group,{"aria-selected":Ue,align:"center","data-hovered":Ue||void 0,"data-index":te.index,"data-selected":M,id:Oe.vale,noWrap:true,onMouseEnter:Q=>{Q.preventDefault(),Q.stopPropagation(),w&&(re(te.index),k(false));},onMouseMove:Q=>{Q.preventDefault(),Q.stopPropagation(),k(true);},onMouseDown:Q=>{Q.preventDefault(),$e(Oe);},position:"apart",ref:K.measureElement,role:"option",spacing:"xs",sx:Q=>({borderRadius:Q.radius.xs,padding:"15px 5px 15px",paddingLeft:P&&10*m.findIndex(se=>se?.value===Oe.type)||5,position:"absolute",top:0,left:0,height:`${te.size}px`,transform:`translateY(${te.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:Q.colorScheme==="dark"?Q.colors.dark[4]:Q.colors.gray[1]},"&:hover":{backgroundColor:Q.colorScheme==="dark"?Q.colors.dark[4]:Q.colors.gray[1]}}),tabIndex:-1,children:[jsx(Kn,{index:te.index,...Oe}),!P&&Oe.type!==m[m.length-1]?.value&&jsx(ActionIcon,{onMouseDown:Q=>{Q.preventDefault(),Q.stopPropagation(),Ee(Oe.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},Oe.value)})})})]})})})})]})})}var PG,OG,LG,MG,BG,Iw=N(()=>{p();kg();ft();Pt();ae();xe();Rr();PG=(e=[],t=[],o="",r="",n="",i="|")=>{let a=t.map(h=>h.value).slice(),l=`${a.pop()}`,s=h=>h[o],c=h=>h[r],u=h=>{if(h[n])return typeof h[n]=="string"?h[n].split(i):h[n]},d=new Set,m=[],g=[],f=nest().rollup(h=>{let v=h[0],T=P=>P&&P.value&&!d.has(P.value),y=a.map(P=>v[`${P} ID`]),C=a.map(P=>v[P]),b=a.map((P,_)=>{if(g[_]!==C[_]){g[_]=C[_];let D=s[_]||s[s.length-1]||s,L=c[_]||c[c.length-1]||c,R=u[_]||u[u.length-1]||u;return {color:D(v,P)||void 0,icon:L(v,P)||void 0,value:`${y[_]}`,label:C[_],name:C[_],type:P,searchindex:C.slice(0,_+1).concat(R(v,P)).join("|")}}return {}}).filter(T);b.forEach(P=>d.add(P.value));let w=s[s.length-1]||s,k=c[c.length-1]||c,I=u[u.length-1]||u,O=h.map(P=>({color:w(P,l)||void 0,icon:k(P,l)||void 0,value:`${P[`${l} ID`]}`,label:P[l],name:P[l],type:l,searchindex:C.concat(P[l]).concat(I(P,l)).join("|")}));m.push(...b.concat(O));});return a.forEach(h=>{f.key(v=>`${v[`${h} ID`]}|${v[h]}`);}),f.entries(e),m},OG=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},LG=(e,t)=>{let o=e.length,r,n=l=>r&&r.searchindex.includes(l.searchindex),a={next:()=>{for(let l=o-1;l>-1;l--){let s=e[l];if(t.test(`${s.value} ${s.label} ${s.searchindex}`)||n(s))return r=s,o=l,{done:false,value:s}}return {done:true,value:void 0}},[Symbol.iterator]:()=>a};return a},MG=e=>`multihierarchySelector${e}`,BG=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var Aw={};bm(Aw,{default:()=>jG});function WG({block:e,active:t,locale:o,variables:r,configOverride:n={}}){let i=GG(),a=Eo(e),l=Ao(o),s={variables:r},c=xn(),u=Pe(),d=useRouter(),{sectionVariables:m,setSectionVariables:g,resetSectionVariables:f}=pt(e.section_id),h=useMemo(()=>{if(!t)return {error:"Activate to View"};if(!a?.logic)return {error:"Add a Configuration"};let I=Tr({logic:a.logic},l,s).logic,O={router:d,section:{variables:m,setVariables:g,resetVariables:f}};return da(I,l,r,o,e.id,{},O,c,u)},[a?.logic,t,r,m,u.status]),{type:v}=h.config||{},T=v&&Ph[v]?v:"Treemap";v||(h.config={error:'Visualization missing "type"'}),Ph[v]||(h.config={error:`"${v}" is not a valid Visualization Type`});let y=Ph[T],C=h.error||h.config?.error||false;if(C)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:C},"type")});let{_data:b,...w}=h.config,k={locale:o,variables:r,...w,...n};return i.print&&(k.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(An,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(y,{style:{flex:1},dataFormat:I=>{let O;try{O=h.dataFormat(I);}catch(P){console.error("Error in dataFormat: ",P),O=[];}return O},linksFormat:h.linksFormat,nodesFormat:h.nodesFormat,topojsonFormat:h.topojsonFormat,config:{...k}},"viz-key")})})}var GG,HG,Ph,jG,Pw=N(()=>{p();Vi();yp();cc();Wo();xe();dt();Bp();GG=()=>({}),HG={},Ph={[ma]:bp,...kV,...HG};jG=memo(WG,(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 qG,Et,Ow=N(()=>{p();he();ZE();tw();rw();nw();sw();lw();cw();pw();mw();gw();yw();vw();xw();Iw();qG=RV(()=>Promise.resolve().then(()=>(Pw(),Aw)),{ssr:false}),Et={[E.PARAGRAPH]:sh,[E.STAT]:lh,[E.SUBTITLE]:ch,[E.TITLE]:uh,[E.SELECTOR]:mh,[E.VIZ]:qG,[E.GENERATOR]:gh,[E.SECTION_FLAG]:gh,[E.IMAGE]:hh,[E.NAV]:vh,[E.RELATED]:xh,[E.RESET_BUTTON]:Ch,[E.COMPARISON_BUTTON]:kh,[E.TABLE]:wh,[E.BUTTON]:Rh,[E.MULTIHIERARCHY_SELECTOR]:Ah};});function Oc(e){return Oh[e]||IconDice}var Oh,Lh=N(()=>{p();he();Oh={[E.TITLE]:IconHeading,[E.GENERATOR]:IconApi,[E.SECTION_FLAG]:IconFlag,[E.STAT]:IconPercentage,[E.VIZ]:IconChartBar,[E.PARAGRAPH]:IconAlignLeft,[E.SELECTOR]:IconSelector,[E.IMAGE]:IconPhoto,[E.TABLE]:IconTable,[E.MULTIHIERARCHY_SELECTOR]:IconListTree};});function Lc(e){return Mh[e]}var Mh,Bh=N(()=>{p();he();Mh={[E.TITLE]:"Title",[E.GENERATOR]:"Data",[E.STAT]:"Stat",[E.VIZ]:"Visualization",[E.PARAGRAPH]:"Paragraph",[E.SELECTOR]:"Selector",[E.SUBTITLE]:"Subtitle",[E.RESET_BUTTON]:"Reset Button",[E.COMPARISON_BUTTON]:"Comparison Button",[E.RELATED]:"Related Reports",[E.NAV]:"Navigation",[E.IMAGE]:"Image",[E.TABLE]:"Table",[E.BUTTON]:"Button",[E.FALLBACK]:"Fallback",[E.SECTION_FLAG]:"Section Flag",[E.MULTIHIERARCHY_SELECTOR]:"Multihierarchy Selector"};});var aH,Ds,_s=N(()=>{p();he();Yf();Ow();Lh();Bh();aH={[E.GENERATOR]:{type:E.GENERATOR,renderer:Et[E.GENERATOR],renderPreviewOnEdit:false},[E.SECTION_FLAG]:{type:E.SECTION_FLAG,renderer:Et[E.SECTION_FLAG],renderPreviewOnEdit:false},[E.IMAGE]:{type:E.IMAGE,renderer:Et[E.IMAGE],renderPreviewOnEdit:false},[E.PARAGRAPH]:{type:E.PARAGRAPH,renderer:Et[E.PARAGRAPH],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.RELATED]:{type:E.RELATED,renderer:Et[E.RELATED],renderPreviewOnEdit:false,evalWhenNonActive:false},[E.SELECTOR]:{type:E.SELECTOR,renderer:Et[E.SELECTOR],adapter:lr[E.SELECTOR],nonActiveAdapter:()=>lr[E.SELECTOR]({name:"Selector Preview"}),renderPreviewOnEdit:false},[E.STAT]:{type:E.STAT,renderer:Et[E.STAT],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.SUBTITLE]:{type:E.SUBTITLE,renderer:Et[E.SUBTITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.TITLE]:{type:E.TITLE,renderer:Et[E.TITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.VIZ]:{type:E.VIZ,renderer:Et[E.VIZ],renderPreviewOnEdit:false},[E.NAV]:{type:E.NAV,renderer:Et[E.NAV],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.RESET_BUTTON]:{type:E.RESET_BUTTON,renderer:Et[E.RESET_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.COMPARISON_BUTTON]:{type:E.COMPARISON_BUTTON,renderer:Et[E.COMPARISON_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.TABLE]:{type:E.TABLE,renderer:Et[E.TABLE],renderPreviewOnEdit:false,evalWhenNonActive:false},[E.BUTTON]:{type:E.BUTTON,renderer:Et[E.BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.MULTIHIERARCHY_SELECTOR]:{type:E.MULTIHIERARCHY_SELECTOR,renderer:Et[E.MULTIHIERARCHY_SELECTOR],adapter:lr[E.MULTIHIERARCHY_SELECTOR],nonActiveAdapter:()=>lr[E.MULTIHIERARCHY_SELECTOR]({label:"Multihierarchy Selector Preview"}),renderPreviewOnEdit:false}},Ds=aH;});p();p();p();function av(e){let{onlyIcon:t,href:o,version:r}=e,n=jsx(Text,{c:"blue.5",ta:"left",children:jsxs(Group,{position:"left",spacing:"xs",children:[jsx(IconCircleDashed,{size:30}),!t&&jsxs(Text,{c:"black",fs:"lg",children:["Bespoke CMS",jsx(Text,{span:true,c:"dimmed",size:"xs",ml:3,children:r})]})]})});return o?jsx(TP,{href:o,passHref:true,children:jsx(UnstyledButton,{p:10,w:"100%",children:n})}):n}p();var pv=In__default.createContext(void 0);function dv(e){let[t,o]=useState(false),[r,n]=useState(null),i=In__default.useMemo(()=>{function c(u,d){return d?{show:()=>c(u)}:new Promise((m,g)=>{n({request:u,onResolve:m,onReject:g}),o(true);})}return {newConfirmation:c}},[]),a=()=>{o(false),setTimeout(()=>n(null),200);},l=useCallback(c=>{!t||!r||(r.onResolve(c),a());},[t,r]),s=useCallback(c=>{!t||!r||(r.onReject(c),a());},[t,r]);return jsxs(pv.Provider,{value:i,children:[r&&jsx(RP,{opened:t,request:r.request,onConfirm:l,onCancel:s}),e.children]})}function RP(e){let{request:t,opened:o,onCancel:r,onConfirm:n}=e,i=useMantineTheme();return jsxs(Modal,{centered:true,zIndex:1002,opened:o,title:t.title,onClose:r,children:[t.message,jsxs(Group,{position:"right",style:{marginTop:i.spacing.sm},children:[jsx(Button,{onClick:r,children:t.cancelText||"Cancel"}),jsx(Button,{color:"red",onClick:n,children:t.confirmText||"Confirm"})]})]})}function Kt(){let e=useContext(pv);if(e===void 0)throw new Error("useConfirmationDialog must be used within ConfirmationDialogProvider.");return e}Pt();st();p();p();p();function us(e){return jsxs("span",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.icon,e.children]})}ae();Pt();xe();st();Tn();p();function ax(e){let{left:t,center:o,right:r}=e;return jsx(Header,{height:50,p:"xs",pos:"sticky",zIndex:98,children:jsxs(Group,{position:"apart",children:[jsx("div",{className:"left",children:t}),jsx("div",{className:"center",children:o}),jsx("div",{className:"right",children:r})]})})}p();st();ae();var gM=e=>({input:{border:"none",background:e.colors.blue[0],borderRadius:e.radius.sm,color:e.colors.blue[7],fontSize:12,fontWeight:700,width:80},item:{fontSize:12},rightSection:{pointerEvents:"none"}});function ql({value:e,onChange:t,defaultValue:o,selectProps:r={},loading:n=false}){let i=ff(),a=H(u=>u.status.localeDefault),[l,s]=useUncontrolled({value:e,defaultValue:o||a,finalValue:a,onChange:t}),c=useMantineTheme();return jsx(Select,{...r,data:i,value:l,onChange:s,styles:{...gM(c),...r?.styles},icon:jsx(IconLanguage,{size:"0.8rem",color:c.colors.blue[7]}),rightSection:n?jsx(Loader,{size:"0.8rem"}):jsx(IconChevronDown,{size:"0.8rem",color:c.colors.blue[7]})})}p();ae();p();p();Go();ds();zu();p();zu();function Zt(e){let t=Number.parseInt(`${e||""}`,10);if(Number.isNaN(t)||!Number.isFinite(t))throw new Gi(400,`Invalid numeric parameter: ${e}`);return t}function Ne(e){return e==null||e===""?[]:Array.isArray(e)?e:e.toString().split(",")}p();var Pr={ADMIN:"Admin",EDITOR:"Editor"};var{localeDefault:ai}=je();function sx(e){let t=Ne(e.locale)[0]||ai||"en",o=t==="all"||Yl(e.all),r=Ne(e.mode)[0],i=(Ne(e.output)[0]||"full")==="lite"?"lite":"full",a=parseInt(Ne(e.related)[0],10)||5,l=Yl(e.allowNulls,{default:false}),s=Ne(e.variant).map(Zt);if(s.length===0&&(s=Ne(e["variant[]"]).map(Zt)),r==="ids")return {all:o,mode:r,variant:s,output:i,locale:o?ai:Qt(t),ids:Ne(e.ids||e["ids[]"]),allowNulls:l};if(r==="content_ids")return {all:o,mode:r,variant:s,output:i,locale:o?ai:Qt(t),content_ids:Ne(e.content_ids||e["content_ids[]"]).map(Zt),allowNulls:false};if(r==="slugs")return {all:o,mode:r,variant:s,output:i,locale:o?ai:Qt(t),slugs:Ne(e.slugs||e["slugs[]"]).map(c=>{let[u,d]=c.split("/");return {variantSlug:u,memberSlug:d}}),allowNulls:false};if(r==="related")return {all:o,mode:r,locale:o?ai:Qt(t),related:a,current_ids:Ne(e.current_ids||e["current_ids[]"]).map(Zt),include_ids:Ne(e.include_ids||e["include_ids[]"]).map(Zt),report_ids:Ne(e.report_ids||e["report_ids[]"]).map(Zt),dimension_ids:Ne(e.dimension_ids||e["dimension_ids[]"]).map(Zt),variant_ids:Ne(e.variant_ids||e["variant_ids[]"]).map(Zt),output:i,allowNulls:false};if(r==="whole")return {all:o,mode:r,variant:s,locale:o?ai:Qt(t),output:i,allowNulls:l};throw new Gi(400,`Invalid mode: '${r}'`)}function Xu(e){let t=Ne(e.locale)[0]||ai||"en",o=t==="all",r=Ne(e.format)[0],n=r?r==="nested":o,i=Ne(e.variant).map(Zt);i.length===0&&(i=Ne(e["variant[]"]).map(Zt));let a=Ne(e.dimension).map(Zt);a.length===0&&(a=Ne(e["dimension[]"]).map(Zt));let l=Ne(e.report).map(Zt);l.length===0&&(l=Ne(e["report[]"]).map(Zt));let s=e.origin==="typesense"?"typesense":"flexsearch";return {query:Ne(e.query||e.q)[0]||"",locale:o?ai:t,preferredLocale:Ne(e.preferredLocale)[0],limit:Ne(e.limit).map(Zt)[0]??5,format:n?"nested":"plain",includes:Yl(e.includes,{default:true}),visible:Yl(e.visible,{default:true}),noImage:Yl(e.noImage,{default:false}),variant:i,dimension:a,report:l,all:o,sort:Ne(e.sort)[0],direction:Ne(e.direction)[0],offset:Number(e.offset||0),origin:s}}ae();p();xe();ae();p();var TM={maxWidth:100,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function Jl({children:e,tooltip:t=false,onClick:o=()=>{},textProps:r={},clickable:n=false}){return jsx(Tooltip,{label:e,disabled:!t,children:jsx(UnstyledButton,{onClick:o,children:jsxs(Group,{spacing:"3px",align:"center",noWrap:true,children:[jsx(Text,{fz:"0.675rem",tt:"uppercase",fw:700,color:"gray.7",sx:TM,...r,children:e}),n&&jsx(ThemeIcon,{color:"gray.7",size:"1rem",bg:"transparent",variant:"default",sx:{border:"none"},children:jsx(IconChevronDown,{size:"xl"})})]})})})}Go();p();var Ju=e=>t=>({input:{border:"none !important",outline:"none",background:t.colors.gray[1]},dropdown:{padding:0,background:t.fn.lighten(t.colors.gray[1],.8),borderColor:t.colors.gray[4],borderRadius:t.radius.md,width:"280px !important",gap:t.spacing.xs,":before":{display:"block",content:`"${e}"`,fontSize:t.fontSizes.xs,color:t.colors.gray[5],paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,paddingBottom:t.spacing.xs,paddingTop:t.spacing.xs}}});function BM(e,t,o){return o===t?e.map(r=>({id:r.id,value:`${r.id}`,name:r.name})):e.map(r=>{let n=r.contentByLocale.find(i=>i.locale===o);return {id:r.id,value:`${r.id}`,name:r.name,refName:n?n.name:null}})}var lx={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},DM=forwardRef(function({id:t,name:o,refName:r,...n},i){return jsxs(Group,{position:"apart",ref:i,...n,children:[jsxs(Stack,{spacing:0,children:[jsx(Text,{maw:"200px",sx:lx,children:o}),r&&jsx(Text,{fz:10,c:"#666",maw:"140px",sx:lx,children:r})]}),jsx(Text,{color:"gray.5",size:"sm",children:t})]},`${t}-${o}`)});function vf(e){let{dimensionId:t,variantId:o,value:r,defaultValue:n,onChange:i,locale:a}=e,l=ie(),{localeDefault:s}=je(),c=ns(),u=a||s,[d,m]=useState([]),[g,f]=useState(""),[h]=useDebouncedValue(g,500),[v,T]=useState(false),[y,C]=useState(false),[b,w]=useUncontrolled({value:r,defaultValue:n,finalValue:void 0,onChange:i?D=>i(D):void 0}),k=useRef(null),I=useClickOutside(()=>C(false)),O=useMergedRef(k,I),P=D=>{let L=d.find(R=>R.id===D.id);L&&(f(L.name?L.name:""),w(L),C(false));};useEffect(function(){T(true);let L={query:h,locale:u===c?u:"all",variant:[o],dimension:[t],limit:5,visible:false,includes:true,noImage:false,format:"plain",all:true,preferredLocale:c,report:[]};l(Z.searchMember(L)).then(R=>{if(R&&R.results){let z=R.results.map(A=>({...A,currentLocale:u,name:(A.contentByLocale&&A.contentByLocale.find(V=>V.locale===u)||A).name}));m(z),T(false),z.length===0&&h===""&&(m([]),T(false));}});},[l,h,u,o,t,c]),useEffect(()=>{d.length&&!b?.id&&i&&i(d[0]);},[d,i]);let _=BM(d,u,c);return useEffect(()=>{setTimeout(()=>{k.current&&k.current.focus();},200);},[y]),y||!b?.name?jsx(Autocomplete,{ref:O,value:g,onChange:f,data:_,itemComponent:DM,placeholder:"Search members.",nothingFound:"No members found.",rightSection:v&&jsx(Loader,{size:"xs"}),filter:()=>true,onItemSubmit:P,size:"xs",w:130,styles:Ju("Members")}):jsx(Jl,{onClick:()=>C(true),textProps:{color:"gray.6"},tooltip:true,clickable:true,children:b.name})}p();ae();function Sf(e){let o=ea(e).data,r=Ul(o?.variants);return r.isSuccess?r.data.map(n=>({value:`${n.id}`,label:n.name})):[]}function xf(e){let{dimension:t,value:o,onChange:r}=e,[n,i]=useState(false),a=Sf(t),l=useClickOutside(()=>i(false)),s=a.length===1||!n,[c,u]=useUncontrolled({value:o?String(o):void 0,defaultValue:a[0]?a[0].value:"",finalValue:void 0,onChange:r?g=>r(Number(g)):void 0}),d=g=>u(g),m=a.find(g=>g.value===c)||a[0];return s?jsx(Jl,{onClick:()=>i(true),clickable:a.length>1,children:m?m.label:"No Variant"}):jsx(Select,{ref:l,data:a,value:c,onChange:d,w:140,size:"xs",styles:Ju("Variants"),initiallyOpened:true})}function Zu(e){let{dimensionId:t,locale:o,onSelect:r,value:n}=e,i=ie(),a=Sf(t),[l,s]=useUncontrolled({defaultValue:n?{id:`${n.memberId}`}:void 0,finalValue:void 0,onChange:r?m=>r(m):void 0}),[c,u]=useUncontrolled({value:void 0,defaultValue:n?.variantId,finalValue:a[0]?Number(a[0].value):0,onChange:()=>{s({});}}),d=n?.memberId;return useEffect(function(){d&&i(Z.readMember(sx({locale:o,content_ids:[`${d}`],all:"false",mode:"content_ids"}))).then(g=>{if(g&&g.results&&g.results[0]){let f=g.results[0];s({...f});}else console.error("default member is not found");});},[d]),jsxs(Flex,{gap:"xs",px:"xs",align:"center",children:[jsx(xf,{dimension:t,value:c,onChange:u},`dimension-${t}`),jsx(Text,{fz:"xs",tt:"uppercase",color:"gray.6",fw:700,children:"/"}),c&&jsx(vf,{variantId:c,dimensionId:t,value:l,onChange:s,locale:o},`variant-${c}`)]})}Pt();st();function kf({report:e,defaultMembers:t,locale:o}){let[r,n]=useState(false),i=ie(),a=Jt(),l=useContext(De),s=e&&e.dimensions?e.dimensions:[],c=H(f=>f.status.previews),u=c.map(f=>({variantId:f.variant_id,memberId:f.content_id})),d=a.query.preview,m=Array.isArray(d)?d.join("!"):d||"",g=f=>{let v=e.dimensions.map(y=>{let C;if(f)if(f.dimension_id===y)C=f;else {let b=c.find(w=>w?w.dimension_id===y:false);b&&(C=b);}return C}).map(y=>y?{...y,report_name:y.report?.name||y.report_name,report_id:y.report?.id||y.report_id,dimension_id:y.dimension?.id||y.dimension_id,dimension_name:y.dimension?.name||y.dimension_name,variant_id:y.variant?.id||y.variant_id,variant_name:y.variant?.name||y.variant_name,variant_slug:y.variant?.slug||y.variant_slug}:{}),T=v.map(XM).join("!");if(T&&m!==T){let y=v.filter(C=>C.content_id).length===s.length;i(Z.setPreviews(v)),y&&(a.setSearchParam("preview",T),i(Z.recalculateVariables(l,{previews:v})));}};return useEffect(function(){let h=m.split("!").filter(Boolean);h.length===s.length&&s.length>0?i(Z.readMember({mode:"slugs",slugs:h.map(v=>{let[T,y]=v.split("/");return {variantSlug:T,memberSlug:y}}),locale:o,output:"full"})).then(v=>i(Z.recalculateVariables(l,{previews:v.results}))).then(()=>n(true)):t&&t.length===s.length?i(Z.readMember({mode:"content_ids",variant:t.map(v=>v.variantId),content_ids:t.map(v=>v.memberId),locale:o,output:"full"})).then(v=>i(Z.recalculateVariables(l,{previews:v.results}))).then(()=>n(true)):n(true);},[]),jsx(Group,{spacing:"xs",children:r&&s.map((f,h)=>jsxs(Fragment$2,{children:[jsx(Text,{fw:700,fz:"xs",children:"/"}),jsx(Zu,{dimensionId:f,onSelect:g,value:u[h]?u[h]:void 0,locale:o},f)]},f))})}function XM(e){return `${"variant_slug"in e?e.variant_slug:e?.variant?.slug}/${e.slug}`}p();ae();p();ae();p();p();Qn();p();Tu();var Ql="dimension",dx="Dimension";p();var Ef="formatter",gx="Formatter";p();Qn();Tu();km();p();var wf="variant",hx="Variant";p();var Rf="datasource",yx="Data Source";var vx={[Cu]:Nv,[Ql]:dx,[Ef]:gx,[Fi]:Lv,[Ll]:Bv,[wf]:hx,[Rf]:yx};ae();function ar({id:e,type:t,warning:o,disabled:r=false}){let n=useDispatch(),{newConfirmation:i}=Kt(),a=useCallback(async()=>{let l=vx[t]||"Entity",s=o||`Delete this ${l} and all its contents? This action cannot be undone.`;try{r||(await i({title:"Are you sure?",message:s,confirmText:"Yes, Delete it."}),n(Z.deleteEntity(t,e)));}catch{console.error(`${l} deletion aborted:`,e);}},[e,t,o,r,n]);return jsx(ActionIcon,{disabled:r,color:"red",variant:"transparent",onClick:a,children:jsx(IconTrash,{size:18})})}p();var fs=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});function hB({for:e,onEdit:t}){let o=useMantineTheme(),{newConfirmation:r}=Kt(),n=o.colorScheme==="dark"?o.colors.dark[1]:o.colors.gray[7],i=useCallback(async()=>{try{await r({title:"Are you sure?",message:"Modifying dimensions can be destructive and break the site. Make sure you know what you're doing!",confirmText:"Continue"}),t(e.id);}catch{console.error("Dimension edition aborted.");}},[t]),{name:a,ordering:l}=e;return jsxs(Card,{shadow:"xs",withBorder:true,style:{margin:o.spacing.sm},children:[jsx(Group,{position:"apart",children:jsxs(Center,{children:[jsx(IconDatabase,{size:22}),jsx(Space,{w:"xs"}),jsx(Text,{weight:"bold",children:a})]})}),jsxs(Text,{size:"sm",style:{color:n,lineHeight:2},children:["Order:",l]}),jsx(Space,{w:"xs"}),jsxs(Group,{position:"apart",children:[jsxs(Center,{children:[jsx(IconServer,{size:22}),jsx(Space,{w:"xs"}),jsx(Text,{weight:"bold",children:"Variants"})]}),jsx(Badge,{variant:"light",children:e.variants.length})]}),jsx("ul",{children:e.variants.map(s=>jsx("li",{style:{color:n},children:jsx(yB,{id:s})},s))}),jsxs(Group,{position:"apart",children:[jsx(Button,{onClick:i,leftIcon:jsx(IconPencil,{}),compact:true,children:"Edit"}),jsx(ar,{id:e.id,type:"dimension",warning:"Deleting dimensions can be destructive and break the site. Make sure you know what you're doing!"})]})]})}var Tx=Xt(hB,ea);function bB({for:e}){let t=fs(e.settings);return jsx(Text,{size:"sm",children:`${e.name}: /${e.slug} - Order: ${t.order}`})}var yB=Xt(bB,ta);p();jr();ae();p();function hs(e){let{target:t,fields:o,onSubmit:r}=e,[n,i,a]=OB(o||[]),[l,s]=useDisclosure(false,{onClose:a}),c=useCallback(u=>{l&&(u.preventDefault(),typeof r=="function"&&r(i),s.close());},[i,l]);return useHotkeys([["enter",c]]),n.length===0?t:jsxs(Popover,{onClose:s.close,opened:l,position:"right",trapFocus:true,withArrow:true,withinPortal:true,zIndex:1001,children:[jsx(Popover.Target,{children:In__default.cloneElement(e.target,{onClick:s.open})}),jsx(Popover.Dropdown,{children:jsxs("form",{onSubmit:c,children:[n,jsx(Button,{type:"submit",children:"Submit"})]})})]})}function OB(e){let[t,o]=useState({}),r=e.map(a=>encodeURIComponent(`${a.name}:${a.type}/${a.label}`)).join("&"),n=useCallback(()=>{o({});},[]);return [useMemo(()=>e.map(a=>{let l=`${t[a.name]??(a.initialValue||"")}`;return a.type==="checkbox"?jsx(Checkbox,{label:a.label,name:a.name,checked:l=="true"},a.name):a.type==="radio"?jsx(Radio.Group,{label:a.label,value:l,children:a.options.map(s=>jsx(Radio,{label:s.label,value:`${s.value}`},s.label))},a.name):a.type==="select"?jsx(Select,{data:a.options.map(s=>({value:`${s.value}`,label:s.label})),label:a.label,onChange:s=>{o({...t,[a.name]:s});},value:l,zIndex:1002},a.name):a.type==="switch"?jsx(Switch,{label:a.label,name:a.name,checked:l=="true"},a.name):a.type==="text"?jsx(TextInput,{label:a.label,onChange:s=>{o({...t,[a.name]:s.target.value});},placeholder:a.placeholder,value:l},a.name):null}),[r,t]),t,n]}p();ae();function VB({for:e,onEdit:t}){let o=useMantineTheme(),{newConfirmation:r}=Kt(),n=useCallback(async()=>{try{await r({title:"Are you sure?",message:"Modifying variants can be destructive and break the site. Make sure you know what you're doing!",confirmText:"Continue"}),t(e.id);}catch{console.error("Variant edition aborted.");}},[t]),{slug:i,name:a,settings:l}=e,s=fs(l);return jsxs(Card,{shadow:"xs",withBorder:true,style:{margin:o.spacing.sm},children:[jsxs(Group,{position:"apart",children:[jsxs(Center,{children:[jsx(IconServer,{size:22}),jsx(Space,{w:"xs"}),jsx(Text,{weight:"bold",children:a}),jsxs(Text,{size:"xs",ml:"xs",children:["Order: ",s.order]})]}),jsxs(Badge,{variant:"light",children:["/",i]})]}),jsx(Space,{h:"xs"}),jsxs(Group,{position:"apart",children:[jsx(Button,{onClick:()=>n(),leftIcon:jsx(IconPencil,{}),compact:true,children:"Edit"}),jsx(ar,{id:e.id,type:"variant",warning:"Deleting variants can be destructive and break the site. Make sure you know what you're doing!"})]})]})}var Px=Xt(VB,ta);p();Mm();p();var $B=e=>e.replace(/^\s+|\s+$/gm,"").replace(/[^a-zA-ZÀ-ž0-9- _]/g,""),tp=$B;ae();Ss();p();function Po({content:e,buttons:t,size:o}){let[r,n]=useState(500);return useEffect(()=>{let{innerHeight:i}=window;n(i-o);},[]),jsxs("div",{style:{height:"100%"},children:[jsx(ScrollArea,{offsetScrollbars:true,type:"always",style:{height:r},styles:{viewport:{"& > div:first-of-type":{display:"block !important"}}},children:e}),jsx(Space,{h:"xs"}),jsx(Divider,{}),jsx(Group,{mt:"xs",grow:true,style:{height:45},children:t})]})}p();p();function nD({member:e,height:t="auto",width:o="100%",size:r="thumb",forceRefreshTimestamp:n=false}){let i="";n&&(i=`&t=${new Date().getTime()}`);let a=e&&e.image_id?`/api/cms/member/image?member=${e.content_id}&size=${r}${i}`:"https://placehold.jp/cccccc/ffffff/900x600.png?text=None";return jsx(Image,{alt:`Image for ${e.id}`,height:t,width:o,radius:"md",src:a})}var Zl=nD;ae();function xs({members:e,onClickEdit:t,onSort:o,colsToRender:r=[],dataTableProps:n={}}){let[i,a]=useState([]),[l,s]=useState([]),{state:c,...u}=n;useEffect(()=>{typeof o<"u"&&i&&i.length&&o(i);},[i]),useEffect(()=>{s(e);},[e]),useEffect(()=>{s(e);},[]);let d=H(f=>f.status.localeDefault),m=jsx(Badge,{color:"gray",children:"None"}),g=[{header:"",accessorKey:"visible",enableResizing:false,enableSorting:false,size:10,Cell:({row:f})=>jsx(Fragment,{children:f.original.visible?jsx("span",{}):jsx(Tooltip,{label:"Visible: false",children:jsx("span",{children:jsx(IconEyeOff,{size:20})})})})},{header:"ID",accessorKey:"id",enableSorting:typeof o<"u",mantineTableHeadCellProps:{align:"right",sx:{"& .mantine-TableHeadCell-Content-Labels":{flexDirection:"row"}}},mantineTableBodyCellProps:{align:"right"},size:100},{header:"Report",accessorKey:"report.name",enableSorting:false,size:100},{header:"Dimension",accessorKey:"dimension.name",enableSorting:false,size:100},{header:"Variant",accessorKey:"variant.name",enableSorting:false,size:100},{header:"Relevance",accessorKey:"zvalue",enableSorting:typeof o<"u",size:100},{header:"Slug",accessorKey:"slug",Cell:({row:f})=>jsxs("span",{children:["/",f.original.variant.slug,"/",f.original.slug]}),enableSorting:false},{header:`Name ${d.toUpperCase()}`,accessorKey:"name",enableSorting:typeof o<"u",Cell:({row:f})=>{let h=f.original.contentByLocale.find(y=>y.locale===d),v=f.original.contentByLocale.filter(y=>y.locale!==d),T=v.reduce((y,C)=>{let b=`${C.locale.toUpperCase()}: ${C.name}`;return `${y}${y!==""?`
47
- `:""}${b}`},"");return jsxs(Group,{children:[jsx("span",{children:h?.name||m}),v.length>0&&jsx(Tooltip,{label:T,children:jsxs(Avatar,{size:"sm",color:"pink",radius:"xl",children:["+",v.length]})})]})}},{header:`Keywords ${d.toUpperCase()}`,accessorKey:"keywords",Cell:({row:f})=>{let h=f.original.contentByLocale.find(C=>C.locale===d),v=f.original.contentByLocale.filter(C=>C.locale!==d),T=(h.keywords?h.keywords:[]).map(C=>jsx(Badge,{children:C},C)),y=v.reduce((C,b)=>{let w=b.keywords||[],k=`${b.locale.toUpperCase()}: ${w.length>0?w.join(","):"None"}`;return `${C}${C!==""?`
48
- `:""}${k}`},"");return jsxs(Group,{children:[jsx("span",{children:T.length>0?T:m}),v.length>0&&jsx(Tooltip,{label:y,children:jsxs(Avatar,{size:"sm",color:"pink",radius:"xl",children:["+",v.length]})})]})},enableSorting:false,size:100},{header:"Image",accessorKey:"image",Cell:({row:f})=>jsx(Zl,{member:f.original,height:"50px",forceRefreshTimestamp:true}),enableSorting:false,size:80},{header:"",accessorKey:"actions",Cell:({row:f})=>jsx(ActionIcon,{onClick:()=>t?t(f.original):false,children:jsx(IconPencil,{size:20})},"edit"),enableResizing:false,enableSorting:false,size:50,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}];return jsx(MantineReactTable,{columns:g.filter(f=>r&&r.length===0||r.includes(f.accessorKey)),data:l,enableBottomToolbar:false,enableColumnActions:false,enableColumnResizing:true,enablePagination:false,enableStickyHeader:true,enableTopToolbar:false,initialState:{density:"xs"},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150,maxHeight:"90vh"}},mantineTableProps:{striped:true},manualSorting:true,onSortingChange:a,state:{sorting:i,...c},...u})}p();function hD({switchProps:e,yesText:t,noText:o}){let r={size:"md",onLabel:"YES",offLabel:"NO",label:"Switch Label",my:"xs",checked:false,onChange:n=>console.info(n.currentTarget.checked),...e};return jsxs(Group,{children:[jsx(Switch,{...r}),jsx(Tooltip,{label:r.checked?t:o,withArrow:true,multiline:true,width:200,children:jsx(ActionIcon,{variant:"filled",radius:"50%",size:"xs",children:jsx(IconQuestionMark,{size:"xs"})})})]})}var tc=hD;p();function Ts(e){try{return new URL(e),!0}catch{return false}}function PD({for:e,onClose:t}){let o=ie(),r=H(q=>q.status.localeDefault),n=H(q=>q.status.locales),i=n.map(q=>({value:q,label:q.toUpperCase()})),[a,l]=useState(),[s,c]=useState(r),[u,d]=useState(()=>{let q={...e};return n.forEach(ce=>{q.config={...q.config,[ce]:{attributes:[],idKey:"",labelKey:"",accessor:"",path:"",...q.config[ce]||{}}};}),q}),[m,g]=useState(false),[f,h]=useState(false),[v,T]=useState(false),[y,C]=useState(false),[b,w]=useState({valid:false,suggestion:""}),[k,I]=useState(),[O,P]=useState([]),[_,D]=useState(false),[L,R]=useState([]),z=q=>{Ts(q)&&(h(true),o(Z.urlProxy({url:q})).then(ce=>{if(I(ce),ce){let de=eS(ce);P(de),u.config[s].accessor&&ce[u.config[s].accessor]?V(ce[u.config[s].accessor][0],u.config[s].accessor):de.length===0&&ce&&ce[0]&&V(ce[0]);}T(false),h(false);}).catch(ce=>{console.error(ce),T(`Fetch error: ${ce.message}`),I(void 0),h(false);}));},A=q=>{D(true);let ce=Xu({variant:q,limit:"5",locale:"all",visible:"true",includes:"true",noImage:"false",format:"plain"});o(Z.searchMember(ce)).then(de=>{if(de&&de.results){let Se=de.results;R(Se),Se.length===0&&J("doIngest",true);}D(false);}).catch(de=>{console.error(de),D(false);});},V=(q,ce="")=>{if(q){let de=Object.keys(q),Se=de.find(We=>We.toLowerCase().includes("id"))||de[0],$e=de.find(We=>!We.toLowerCase().includes("id"))||de[0];(!u.config[s].idKey||u.config[s].idKey===""||!u.config[s].labelKey||u.config[s].labelKey==="")&&d({...u,config:{...u.config,[s]:{...u.config[s],idKey:Se,labelKey:$e,accessor:ce}}});}l(q);};useEffect(()=>{u.id&&A(u.id),Y(u.slug),u.config[s]&&u.config[s].path&&z(u.config[s].path);},[]);let j=q=>{I(void 0),T(false);let ce=[];if(q!==r){let de=u.config[r]?[...u.config[r].attributes].map($e=>{let We={...$e};return We.value="",We}):[];u.config[q]&&u.config[q].attributes?ce=de.map($e=>{let We=u.config[q].attributes.find(Qe=>$e.name===Qe.name);return We&&($e.value=We.value),$e}):ce=de;let Se={...u.config,[q]:{...u.config[q],attributes:ce}};d({...u,config:Se});}u.config[q]&&u.config[q].path&&z(u.config[q].path),c(q);},B=useMemo(()=>fs(u.settings),[u.settings]),U=useMemo(()=>[{label:"Replace names",key:"overrideNames",yesText:"Names from new source will update the previously ingested members.",noText:"Original names will be keep."},{label:"Replace slugs",key:"regenerateSlugs",yesText:"Slugs will be regenerated based on new member's names and updated on previously ingested members.",noText:"Original slugs will be keep.",disabled:!B.overrideNames},{label:"Replace relevance value",key:"overrideRelevance",yesText:"Relevance index will be recalculated and updated on previously ingested members.",noText:"Original numbers will be keep."},{label:"Replace attributes",key:"overrideAttributes",yesText:"Attributes will be regenerated and override the current ones. Different ones will be kept.",noText:"Original attributes will be keep, ignoring the changes"},{label:"Keep all existing members",key:"keepOldMembers",yesText:"All the the existing members will be keep even if they are not in the new API members list",noText:"Members that are not in the API members list will be deleted, keeping both lists on sync."}],[B.overrideNames]),$=q=>{let ce=Pu(k,q);ce[0]&&V(ce[0],q);},Y=q=>{o(Z.variantValidateSlug(u.dimension_id,q)).then(w).then(()=>{C(false);},ce=>{console.error(ce);});},F=(q,ce)=>{let de=ce;q==="slug"&&(de=tp(ce),de&&(C(true),Y(ce))),d({...u,[q]:de});},G=(q,ce)=>{q==="path"&&T(false),d({...u,config:{...u.config,[s]:{...u.config[s],[q]:ce}}});},J=(q,ce)=>{let de=q==="overrideNames"&&!ce?{regenerateSlugs:false}:{};d({...u,settings:{...u.settings,...de,[q]:ce}});},ee=()=>{g(true),o(Z.updateEntity("variant",u)).then(()=>{g(false),t();}).catch(q=>{console.error(q),g(false);});},ne=q=>{d({...u,config:{...u.config,[s]:{...u.config[s],attributes:q}}});},X=()=>{if(a&&Object.keys(a)[0]){let de=u.config[s]?.attributes||[],Se=de.length||0;ne([...de,{type:"constant",name:`attr${Se+1}`,value:""}]);}},W=(q,ce,de)=>{let Se=u.config[s].attributes.map(($e,We)=>We===ce?{...$e,[q]:de}:$e);ne(Se);},K=q=>{let ce=u.config[s].attributes.filter((de,Se)=>Se!==q);ne(ce);},oe=a?Object.keys(a).map(q=>({value:q,label:`${q}: ${a[q]}`})):[],re=O.map(q=>({value:q,label:q})),ue=!Ts(u.config[s].path),Ee=useMemo(()=>v||(ue&&u.config[s].path!==""?"Format error: Invalid URL.":false),[v,ue,u.config,s]);return jsx(Po,{content:jsxs(Fragment,{children:[jsx(Title,{order:2,children:`Editing Variant: ${u.name}`}),jsx(Space,{h:"xs"}),jsxs(Tabs,{defaultValue:"variant",children:[jsxs(Tabs.List,{grow:true,children:[jsx(Tabs.Tab,{value:"variant",children:"Variant"}),jsx(Tabs.Tab,{value:"members",children:"Members"})]}),jsxs(Tabs.Panel,{value:"variant",py:"md",children:[jsx(Title,{order:3,children:"Variant Settings"}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:u.name,label:"Name",onChange:q=>F("name",q.target.value)}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:u.slug,icon:!y&&!b.valid?jsx(IconAlertCircle,{}):jsx(IconCircleCheck,{}),label:"Slug",description:y?"Validating slug...":b.valid?"Valid slug.":"Invalid slug.",error:!y&&!b.valid?jsxs(Text,{children:["Duplicated slug. Suggestion:",jsx(Code,{onClick:()=>F("slug",b.suggestion),style:{cursor:"pointer"},children:b.suggestion})]}):false,onChange:q=>F("slug",q.target.value)}),jsx(Space,{h:"xs"}),jsx(NumberInput,{value:B.order||0,description:"It affects on explore options order",placeholder:"Order",label:"Order",onChange:q=>{J("order",q);}})]}),jsxs(Tabs.Panel,{value:"members",py:"md",children:[jsx(Title,{order:3,children:"Members Settings"}),jsx(Text,{size:"sm",children:"Members, once ingested, become pages for this variant."}),jsx(tc,{switchProps:{label:`${!_&&L.length>0?"Re-":""}Ingest members`,checked:B.doIngest,onChange:q=>J("doIngest",q.currentTarget.checked)},yesText:`Run the ingestion process and save the variant details.
49
- Remember include the ingestion information for all the locales.`,noText:"Ingestion is not going to run and the current members are not going to suffer any change."}),B.doIngest&&!_&&L.length>0&&jsxs(Box,{ml:"lg",children:[jsx(Text,{size:"sm",children:"Settings that are going to be applied for members reingestions and for all available languages, matching by unique identificator. All new members are going to be ingested. Images and tags for existing members will be safe."}),U.map(q=>jsx(tc,{switchProps:{disabled:q.disabled,label:q.label,checked:B[q.key],onChange:ce=>J(q.key,ce.currentTarget.checked)},yesText:q.yesText,noText:q.noText},q.key))]}),!B.doIngest&&jsxs(Fragment,{children:[jsx(Title,{order:2,size:"h4",children:"Ingested members preview"}),jsx(Space,{h:"xs"}),jsxs(Stack,{spacing:0,justify:"center",children:[_&&jsx(Loader,{m:"0 auto"}),!_&&L.length>0&&jsxs(Fragment,{children:[jsx(xs,{members:L,colsToRender:["id","name","slug"]}),jsx(TP,{href:"metadata",passHref:true,children:jsx(Text,{c:"dimmed",align:"center",td:"underline",size:"xs",children:"See the full list in Metadata View"})})]})]}),!_&&L.length===0&&jsx(Text,{c:"dimmed",align:"center",children:"No members ingested yet."}),jsx(Space,{h:"xs"})]}),B.doIngest&&jsxs(Fragment,{children:[jsx(Divider,{my:"sm"}),jsx(Title,{order:2,size:"h4",children:"Members ingestion"}),jsx(Space,{h:"xs"}),jsx(SegmentedControl,{value:s,fullWidth:true,onChange:j,data:i,disabled:f}),u.config[s]&&jsxs(Fragment,{children:[jsx(Space,{h:"lg"}),jsx(Group,{children:jsx(TextInput,{onChange:q=>G("path",q.target.value),title:"Api endpoint",description:"Enter the url to retrieve a member list to ingest. (JSON) and click Fetch.",value:u.config[s].path,error:Ee,rightSectionWidth:"105px",w:"100%",rightSection:f?jsxs(Group,{align:"center",children:[jsx(Loader,{size:"xs"}),jsx(Text,{span:true,variant:"subtle",size:"xs",children:"Fetching..."})]}):jsx(Button,{disabled:f||ue,onClick:()=>z(u.config[s].path),leftIcon:jsx(IconPlayerPlay,{}),children:"Fetch"}),readOnly:f})}),k&&jsxs("div",{children:[jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].accessor,label:"Elements",description:`Choose the key that returns the array of elements that
50
- are going to be ingested as members.`,data:re,disabled:re.length===0,placeholder:re.length===0?"Root is an array":"",onChange:q=>$(q)}),jsx(Divider,{label:"First element preview",labelPosition:"center"}),k[u.config[s].accessor]&&!Array.isArray(k)&&jsx(Or,{variables:k[u.config[s].accessor][0]}),Array.isArray(k)&&k[0]&&jsx(Or,{variables:k[0]}),jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].idKey,label:"Unique identificator",description:"Choose the field that is a unique identification for a single member.",data:oe,onChange:q=>G("idKey",q)}),jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].labelKey,label:"Members' name",description:"Choose the field that contains the members name.",data:oe,onChange:q=>G("labelKey",q)}),jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].zValueKey||"",label:"Member's relevance (optional)",description:`Choose a field that will be converted to a number and
51
- normalized from 0 to 1 to determine the member's relevance.`,data:[{value:"null",label:"None"},...oe],onChange:q=>G("zValueKey",q)}),jsx(Space,{h:"md"}),jsx(Title,{order:3,size:"h5",children:"Attributes"}),jsx(Text,{size:"sm",children:"Attributes are properties to be ingested as metadata with the member element. Could be constants (same value for every member) or dynamic (based on a property of the data)"}),jsx(Space,{h:"xs"}),u.config[s].attributes&&u.config[s].attributes.map((q,ce)=>jsxs(Group,{align:"end",grow:true,children:[jsx(Select,{value:u.config[s].attributes[ce].type,label:"Type",data:[{value:"variable",label:"Data based"},{value:"constant",label:"Constant"}],readOnly:s!==r,disabled:s!==r,onChange:de=>W("type",ce,de)}),jsx(TextInput,{value:u.config[s].attributes[ce].name,label:"Name",readOnly:s!==r,disabled:s!==r,onChange:de=>W("name",ce,de.target.value)}),q.type==="variable"&&jsx(Select,{value:u.config[s].attributes[ce].value,label:"Value",data:oe,onChange:de=>W("value",ce,de)}),q.type==="constant"&&jsx(TextInput,{value:u.config[s].attributes[ce].value,label:"Value",onChange:de=>W("value",ce,de.target.value)}),jsx(ActionIcon,{color:"red",onClick:()=>K(ce),disabled:s!==r,children:jsx(IconTrash,{size:20})})]},ce)),jsx(Space,{h:"md"}),jsx(Button,{onClick:X,leftIcon:"+",disabled:m||s!==r,children:"Add Attribute"})]})]}),jsx(Space,{h:"md"})]})]})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{disabled:m||f||!y&&!b.valid,onClick:t,variant:"outline",children:"Cancel"}),jsx(Button,{disabled:m||f||!y&&!b.valid,loading:m||f,onClick:ee,children:`${B.doIngest?`${!_&&L.length>0?"Re-":""}Ingest & `:""}Save`})]}),size:165})}var Fx=Xt(PD,ta);function jx({id:e,onClose:t}){let o=ie(),r=ea(e),[n,i]=useState({id:e}),[a,l]=useState(null);useEffect(()=>{r.isSuccess&&i(r.data);},[r.status]);let s=useCallback(g=>{o(Z.createEntity("variant",{dimension_id:e,name:g.name,slug:Tt(g.name)}));},[e]),c=useCallback(()=>{o(Z.updateEntity("dimension",{...n,id:e})).then(t);},[n]),u=useCallback((g,f)=>{i({...n,[g]:g==="slug"?Tt(f):f});},[]);if(a)return jsx(Fx,{id:a,onClose:()=>l(null)});let d=r.isFetching,m=r.isSuccess?r.data.variants:[];return jsx(Po,{content:jsxs(Fragment,{children:[jsx(Title,{order:2,children:`Dimension metadata: ${n.name}`}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:n.name,label:"Name",onChange:g=>u("name",g.target.value)}),jsx(Space,{h:"xs"}),jsx(NumberInput,{value:n.ordering?parseInt(`${n.ordering||0}`,10):0,type:"number",label:"Order",onChange:g=>u("ordering",g)}),jsx(Divider,{my:"xl"}),jsx(us,{icon:jsx(IconServer,{size:22}),children:jsx(Title,{order:2,size:"h4",children:"Variants"})}),m.map(g=>jsx(Px,{id:g,onEdit:l},g)),jsx(hs,{fields:[{name:"name",type:"text",label:"Add Variant"}],onSubmit:s,target:jsx(ActionIcon,{size:"xl",radius:"xl",children:jsx(IconCirclePlus,{size:30})})})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:d,loading:d,onClick:t,children:"Cancel"}),jsx(Button,{disabled:d,loading:d,onClick:c,children:"Save Dimension"})]}),size:165})}jr();function Zx({id:e,onClose:t}){let o=ie(),r=zt(e),[n,i]=useState({id:e}),[a,l]=useState(null);useEffect(()=>{r.isSuccess&&i(r.data);},[r.status]);let s=useCallback((T,y)=>{o(Z.createEntity("dimension",{report_id:e,name:T.name,ordering:y.length+1})).then(C=>{C.ok&&o(Z.createEntity("variant",{dimension_id:C.data.id,name:C.data.name,slug:Tt(C.data.name)}));});},[e]),c=useCallback(()=>{o(Z.updateEntity("report",{...n,id:e})).then(t);},[e,n]),u=useCallback((T,y)=>{i({...n,[T]:y});},[]),d=(T,y)=>{i({...n,settings:{...n.settings,[T]:y}});};if(a)return jsx(jx,{id:a,onClose:()=>l(null)});let m=r.isFetching,g=r.isSuccess?r.data.dimensions:[],f=n.settings,h=f&&typeof f.order=="number"?f.order:0,v=f&&typeof f.hide=="boolean"?f.hide:false;return jsx(Po,{content:jsxs(Fragment,{children:[jsx(Title,{order:2,children:`Report metadata: ${n.name}`}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:n.name,label:"Name",onChange:T=>u("name",T.target.value)}),jsx(Space,{h:"xs"}),jsxs(Group,{grow:true,children:[jsx(tc,{switchProps:{label:"Show in Explore & Search",checked:!v,onChange:T=>d("hide",!T.currentTarget.checked)},yesText:"Profile appears in Explore search and members are listed in search results",noText:"Profile is hidden in Explore search and members are not included in search results"}),jsx(NumberInput,{defaultValue:0,value:h,description:"It affects the Explore search options order",placeholder:"Order in Explore",label:"Order",disabled:v,onChange:T=>{d("order",T);}})]}),jsx(Divider,{my:"sm"}),jsx(us,{icon:jsx(IconDatabase,{size:22}),children:jsx(Title,{order:2,size:"h4",children:"Dimensions"})}),jsx(Grid,{children:g.map(T=>jsx(Grid.Col,{span:6,children:jsx(Tx,{id:T,onEdit:l})},T))}),jsx(hs,{fields:[{type:"text",name:"name",label:"Add Dimension"}],onSubmit:(T=>s(T,g)),target:jsx(ActionIcon,{size:"xl",radius:"xl",children:jsx(IconCirclePlus,{size:30})})})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:m,loading:m,onClick:t,children:"Cancel"}),jsx(Button,{disabled:m,loading:m,onClick:c,children:"Save Report"})]}),size:165})}function nT(e){let{report:t}=e,{newConfirmation:o}=Kt(),{selectEntity:r}=Yt(),n=useContext(De),i=ie(),a=H(B=>B.status.previews),l=Jt(),s=Number.parseInt(l.params[0]),c=zt(s),u=os(),d=FS(),m=df(),g=H(B=>B.status.localeDefault),f=Ft("settings"),h=Ft("reportEditor"),v=Ft("tools"),T=Ft("debugView"),y=ps(s),C=t&&t.dimensions?t.dimensions:[],b=C.length>0,w=a.filter(B=>B.variant_slug).reduce((B,U)=>B.concat([U.variant_slug,U.slug]),[]),k=m===g?"":`/${m}`,I=d||u,O=w.length?`${k}${I}/${w.join("/")}`:"",P=w.length?`${k}${u}/${w.join("/")}`:"",[_,D]=useState(null),L=useMemo(()=>{let B=[];return O&&d&&B.push({value:"preview",label:"Open Preview",url:O,Icon:IconFileCode}),P&&B.push({value:"report",label:"Open Report",url:P,Icon:IconFileAnalytics}),B},[O,P,d]);useEffect(()=>{!_&&L.length>0&&D(L[0].value);},[L,_]);let R=useMemo(()=>L.find(B=>B.value===_)||null,[L,_]),z=useCallback(()=>{R?.url&&window.open(R.url,"_blank","noopener,noreferrer");},[R]),A=useCallback(B=>{D(B);},[]),V=B=>{l.setSearchParam("locale",B),i(Z.readMember({mode:"content_ids",variant:a.map(U=>U.variant_id),content_ids:a.map(U=>U.content_id),locale:B,output:"full"})).then(({results:U})=>{i(Z.setCurrentLocale(B)),U&&U.length===C.length&&C.length?i(Z.recalculateVariables(n,{previews:U})):i(Z.recalculateVariables(n,{previews:[]}));});},j=useCallback(async()=>{try{let B=P;await o({title:"Are you sure?",message:`Revalidate action will force to regenerate page: ${B}.`,confirmText:"Revalidate now!"}),await i(Z.revalidateUrl({target:B})).then(U=>{let $=`Revalidated page ${U.target} you will see the changes in the following minutes.`;notifications.show({autoClose:!1,color:"green",id:"revalidate-results",message:$,title:"Revalidate Results"});}).catch(U=>{notifications.show({autoClose:!1,color:"red",id:"revalidate-error",message:U.message,title:"Revalidate Error"});});}catch{console.error("Revalidate error.");}},[O,P,d]);return jsxs(Fragment,{children:[jsx(ax,{left:jsxs(Group,{children:[jsx(ActionIcon,{color:"blue",variant:"filled",onClick:()=>{r({type:"report",id:t.id}),f.handlers.open();},children:jsx(IconSettingsFilled,{size:20})}),jsx(ql,{value:m,onChange:V,selectProps:{size:"xs",maw:80}}),jsx(SegmentedControl,{size:"xs",radius:"sm",sx:B=>({background:B.colors.blue[0]}),data:[{label:"Editor",value:"editor"},{label:"Debug",value:"debug"}],onChange:B=>{B==="editor"?T.handlers.close():(v.handlers.close(),h.handlers.close(),f.handlers.close(),T.handlers.open());}})]}),center:jsxs(Group,{children:[jsx(kf,{report:t,defaultMembers:y?.map(B=>({variantId:B.variantId,memberId:B.contentId})),locale:m}),(O||P)&&L.length>0&&jsxs(Group,{spacing:0,children:[jsx(Button,{onClick:z,disabled:!R,variant:"light",fw:700,radius:"sm",fz:12,pr:10,pl:5,mih:"1.875rem",compact:true,leftIcon:R?.Icon?jsx(R.Icon,{size:14}):null,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:R?.label||"Select view"}),jsxs(Menu,{position:"bottom",withArrow:true,children:[jsx(Menu.Target,{children:jsx(ActionIcon,{variant:"light",radius:"sm",sx:B=>({borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid #fff",backgroundColor:"#e7f5ff",minHeight:"1.875rem",height:"1.875rem",width:"1.875rem",fontSize:"12px"}),children:jsx(IconChevronDown,{size:14,color:"#228be6"})})}),jsx(Menu.Dropdown,{children:L.map(B=>{let U=B.Icon;return jsx(Menu.Item,{onClick:()=>A(B.value),icon:U?jsx(U,{size:20}):null,children:B.label},B.value)})})]})]})]}),right:jsxs(Group,{children:[a.length>0&&_!=="preview"&&jsx(Button,{variant:"light",fw:700,radius:"sm",fz:12,pr:10,pl:5,mih:"1.875rem",onClick:j,leftIcon:jsx(IconWorldUpload,{size:14}),compact:true,children:"Publish"}),!b&&jsx(Button,{size:"xs",variant:"outline",onClick:h.handlers.open,children:"Import Data"})]})}),jsx(Drawer,{opened:h.opened,onClose:h.handlers.close,title:jsx(us,{icon:jsx(IconFileAnalytics,{size:24}),children:`Editing Report: ${c.data?c.data.name:""}`}),size:"50%",padding:"xl",position:"right",children:jsx(Zx,{id:s,onClose:h.handlers.close})})]})}p();p();p();ae();he();function i_({type:e,id:t,warning:o=""}){let r=Uv[e]||"Entity",n=o||`Delete this ${r} and all its contents? This action cannot be undone.`,i=useDispatch(),{newConfirmation:a}=Kt();return jsx(ActionIcon,{color:"red",onClick:async()=>{try{await a({title:"Are you sure?",message:n,confirmText:"Yes, Delete it."}),i(Z.deleteEntity(e,t));}catch{}},children:jsx(IconTrash,{size:20})})}var aT=i_;ic();p();ae();p();he();p();Ur();xe();var vT=e=>!e||e.trim()===""?false:e.trim().startsWith("/")?true:Ts(e);function F_({defaultValue:e,id:t,onChangeAPI:o,onDelete:r,finalUrl:n,dataSource:i,pos:a}){let l=Ao(),s=ju(t),[c,u]=useState(()=>et(e,l,s)),[d,m]=useState(e),[g,f]=useState(false),h=P=>{g&&!I&&(P.preventDefault(),o(d),f(false));},v=P=>{let{value:_}=P.target;u(et(_,l,s)),m(_);},T=()=>{f(false),u(et(e,l,s));},y=()=>{f(!g);},C=()=>{r();},b=useMemo(()=>(c||"").indexOf("bespoke_slugs=")>-1,[c]),w=useMemo(()=>!(c&&(c.trim()===""||vT(c))),[c,vT]),k=useMemo(()=>c.includes("N/A"),[c]),I=useMemo(()=>w||k,[w,k]),O=useMemo(()=>{let P=[];return w&&P.push("Invalid URL format"),k&&P.push("URL contains 'N/A', probably you are using a variable that is not in scope"),P.join(". ")},[w,k]);return jsxs(Stack,{spacing:0,p:g?"xs":0,mb:g?3:0,bg:g?"gray.0":"transparent",children:[jsxs(Group,{noWrap:true,position:"apart",spacing:"xs",children:[jsxs(Text,{lineClamp:1,size:"xs",children:[a,". ",jsx(Anchor,{href:n||c,target:"_blank",rel:"noreferrer",children:n||c||"--Add API Url--"})]}),jsx(Group,{noWrap:true,spacing:0,children:g?jsxs(Fragment,{children:[jsx(Tooltip,{label:I?"Invalid URL format":"Apply changes",children:jsx(ActionIcon,{size:"md",onClick:h,color:"green",sx:{opacity:I?.4:1},children:jsx(IconCheck,{size:rem(20)})})}),jsx(ActionIcon,{size:"md",onClick:T,color:"red",children:jsx(IconX,{size:rem(20)})})]}):jsxs(Fragment,{children:[b&&jsx(Tooltip,{multiline:true,label:"Slugs Interceptor Enabled",children:jsx(IconGitMerge,{size:rem(18),color:"gray"})}),i&&jsx(Tooltip,{multiline:true,label:`Datasource Interceptor Enabled called "${i}"`,children:jsx(IconNetwork,{size:rem(18),color:"gray"})}),k&&jsx(Tooltip,{multiline:true,label:"API URL contains 'N/A', probably you are using a variable that is not in scope",children:jsx(IconAlertTriangle,{size:rem(20),color:"red"})}),jsx(ActionIcon,{size:"md",onClick:y,children:jsx(IconPencil,{size:rem(20)})}),jsx(ActionIcon,{size:"md",onClick:C,children:jsx(IconTrash,{color:"red"})})]})})]}),g&&jsx(Stack,{spacing:"xs",children:jsx(Textarea,{placeholder:"API URL here: https://api.example.com/v1/data?id={{id1}}",defaultValue:d,onChange:v,onKeyDown:getHotkeyHandler([["enter",h]]),size:"sm",minRows:2,maxRows:6,autosize:true,sx:{width:"100%"},error:I?`${O} ${c}`:false},"textarea")})]})}var xT=F_;p();function H_({monacoOptions:e}){let t=useMonaco();return useEffect(()=>{if(t){let o="Monokai";import(`monaco-themes/themes/${o}.json`).then(r=>{t.editor.defineTheme(o,r),t.editor.setTheme(o);}).catch(()=>{throw new Error("Invalid Monaco theme")});}},[t]),jsx(Box,{className:"cr-monaco-container",w:"100%",children:jsx($_,{defaultLanguage:"javascript",theme:"Monokai",...e})})}var ua=H_;p();Wo();_s();Yf();_s();he();ae();xe();vn();Ur();qa();st();Zn();kr();dt();Bh();p();vn();kr();he();Zn();function yH({status:e,block:t,variables:o}){let{settings:r,contentByLocale:n}=t,i=!!(r&&r.useProxy&&r.useProxy==="true"),a=n?.logic?.content?.api&&n.logic.content.api!==""?n.logic.content.api.split("|||").length:0,l=e&&e.apiDataSources?e.apiDataSources.some(g=>g!==false):false,s=useMemo(()=>e.apiFinalUrls?typeof e.apiFinalUrls=="string"?e.apiFinalUrls.includes("N/A")?1:0:Array.isArray(e.apiFinalUrls)?e.apiFinalUrls.filter(g=>g.includes("N/A")).length:0:0,[e.apiFinalUrls]),c=!!([E.GENERATOR,E.SECTION_FLAG].includes(t.type)&&e.api&&e.api.indexOf("bespoke_slugs=")>-1),u=fo(t),d=u?o[wo]:false,m=[E.GENERATOR,E.SECTION_FLAG].includes(t.type)&&o?JSON.stringify(o).length/1024:void 0;return jsxs(Group,{spacing:5,children:[jsx(Tooltip,{multiline:true,label:`Number of requests: ${a}`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(Text,{size:rem(12),span:true,fw:"bold",children:a})})}),s>0&&jsx(Tooltip,{multiline:true,label:`${s} of your URLs in this generator contains 'N/A', probably you are using a variable that is not in scope`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"orange",children:jsx(IconAlertTriangle,{size:rem(12)})})}),i&&jsx(Tooltip,{multiline:true,label:`Use Proxy Setting (avoid CORS): ${i?"YES":"NO"}`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(IconCloudNetwork,{size:rem(12)})})}),l&&jsx(Tooltip,{multiline:true,label:"Data Source Interceptor Active at least in one request",children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(IconNetwork,{size:rem(12)})})}),c&&jsx(Tooltip,{multiline:true,label:"Slugs Interceptor Enabled at least in one request",children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(IconGitMerge,{size:rem(12)})})}),e.duration&&jsx(Tooltip,{multiline:true,label:`Api Call Duration: ${e.duration} ms`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:cS(e.duration),children:jsx(IconClockHour2,{size:rem(12)})})}),e.responseSize&&jsx(Tooltip,{multiline:true,label:`Api Response Size: \u2248${e.responseSize.toFixed(2)} Kb`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:_m(e.responseSize),children:jsx(IconApi,{size:rem(12)})})}),m&&jsx(Tooltip,{multiline:true,label:`Block Output Size: \u2248${m.toFixed(2)} Kb`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:_m(m),children:jsx(IconAugmentedReality,{size:rem(12)})})}),u&&jsx(Tooltip,{multiline:true,label:`Section #${t.section_id} Allowed Flag: ${d?"YES":"NO"}`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:d?"green":"red",children:jsx(IconFlag,{size:rem(12)})})})]})}var qp=yH;var Yp={api:null,duration:null,error:null,log:[],responseSize:null,resp:null,allowed:true};function PH({block:e,status:t,sectionFlag:o,variables:r}){let n=useMemo(()=>o?jsx(ThemeIcon,{variant:"filled",radius:"xl",size:"sm",color:"orange",children:jsx(IconFlag,{size:"0.8rem"})}):jsx(ThemeIcon,{variant:"filled",radius:"xl",size:"sm",color:"yellow",children:jsx(IconBraces,{size:"0.8rem"})}),[o]);return jsxs(Fragment,{children:[jsxs(Group,{position:"left",pt:"xl",children:[jsxs(Group,{children:[n,jsxs(Title,{order:6,children:[Mh[e.type]," ",e.id]})]}),jsx(Group,{my:"xs",children:jsx(qp,{status:t,block:e,variables:r})})]}),jsx(Divider,{})]})}function OH(e){let{active:t,allowed:o,blockStateContent:r,blockStateSettings:n,debug:i,for:a,locale:l,isFetching:s}=e,c=ot(a.id),u=Ao(),d=xn(),m=ju(a.id,l),g=H(z=>z.variables.variables[a.id]||{}),f=H(z=>z.variables.status[a.id]||{}),h=Ds[a.type].renderPreviewOnEdit&&r?r:Eo(a,l),v=Ds[a.type].renderPreviewOnEdit&&n?n:a.settings,[T,y]=useState(null),[C,b]=useState(Yp),w=fo(a),k=Ir(),I=Pe();useEffect(()=>{(async()=>{if(a.type===E.VIZ){y({block:a,locale:l,variables:c,active:t}),b(Yp);return}if(!t&&!Ds[a.type].evalWhenNonActive){let{nonActiveAdapter:$}=Ds[a.type],Y=$&&typeof $=="function"?$():{};y(Y),b(Yp);return}if([E.GENERATOR,E.SECTION_FLAG].includes(a.type)){let $=!!a.contentByLocale?.logic?.content?.api,Y=w?g[wo]:false;y({outputVariables:g,hasAPI:$,sectionAllowed:Y,type:a.type}),b(f);return}if([E.SELECTOR,E.MULTIHIERARCHY_SELECTOR].includes(a.type)){let{renderVariables:$,status:Y}=await Ml(a,u,m,k,d,I),F=lr[a.type]&&typeof lr[a.type]=="function"?lr[a.type]($,a.id):$;y(F),b(Y);return}if(a.type===E.RELATED){let{outputVariables:$}=await Ml(a,u,m,k,d,I),{related_reports:Y}=$;y({related_reports:Y});return}if(a.type===E.RESET_BUTTON||a.type===E.COMPARISON_BUTTON){y(h.simple||{});return}let A=et(h?.logic,u,m),{vars:V,error:j,log:B}=$r("variables",c,A,u,void 0,m),U=lr[a.type]&&typeof lr[a.type]=="function"?lr[a.type](V,a.id):V;if(a.type===E.NAV){y({headings:a.inputs,settings:a.settings,...U});return}y(U),b({...Yp,error:j,log:B});})();},[h,c,w]),useEffect(()=>{f&&f.error&&f.error!==""&&notifications.show({autoClose:1e4,color:"red",id:"block-error",message:f.error,title:`Block error ID: ${a.id}`});},[f.error]);let O=Et[a.type],_=jsx("div",{style:{...{width:"100%",height:"100%",position:"absolute",top:0,left:0,opacity:.9,zIndex:4,pointerEvents:"none"},backgroundColor:"pink"},children:jsx(Center,{h:"100%",children:jsx(Text,{size:"sm",tt:"capitalize",italic:true,children:f.hiddenByCascade===a.id?`${a.type} not allowed`:`${a.type} hidden by block ${f.hiddenByCascade}`})})});if(s)return jsx(Center,{style:{minHeight:100},w:"100%",children:jsx(Loader,{})});if(!T)return null;let{error:D,log:L}=C,R=L?L.join(`
52
- `):"";return jsxs("div",{id:`bespoke-${a.type}-${a.id}`,className:"cms-block-preview bespoke-block-area",style:{width:"100%",minHeight:a.type===E.VIZ?400:"auto"},children:[!o&&_,[E.GENERATOR,E.SECTION_FLAG].includes(a.type)&&jsx(PH,{block:a,status:C,sectionFlag:w,variables:T}),O?jsx(Fragment$2,{children:jsx(O,{id:a.id,debug:i,section:a.section_id,...T,settings:v,status:C})},"renderer"):jsx(Center,{style:{minHeight:100},children:jsx(Badge,{color:"gray",variant:"outline",children:a.type},"type")}),i&&R&&jsx(Textarea,{label:"Console",minRows:3,readOnly:true,autosize:true,maxRows:10,value:R,error:D}),i&&D&&jsx(Textarea,{label:"Error",readOnly:true,autosize:true,minRows:3,maxRows:10,value:D})]})}var Xp=Xt(OH,tt);p();he();ae();xe();$p();function VH({id:e,setBlockSettings:t}){let{newConfirmation:o}=Kt(),r=ie(),n=tt(e).data,[i,a]=useState(n.settings[_t.ACCESS]||["public"]),[l,s]=useState(n.settings[_t.FALLBACK]||false),c=ot(e),u=useMemo(()=>[{value:"always",label:"always",group:"Static"},{value:"never",label:"never",group:"Static"}].concat(Object.keys(c).map(w=>({value:w,label:`${w}: ${c[w]}`,group:"Based on variable"}))),[c]),d=[{label:"Section-wide",value:"false"},{label:"Report-wide",value:"true"}];useEffect(()=>{t({[_t.ACCESS]:i}),i.includes("public")&&s(false);},[i]),useEffect(()=>{t({[_t.FALLBACK]:l});},[l]);let m=async()=>{try{await o({title:"Are you sure?",message:"Delete this block and all its contents? This action cannot be undone.",confirmText:"Yes, Delete it."}),r(Z.deleteEntity("block",e));}catch{}},g=(w,k)=>{t({[w]:k});},f=w=>{let k=`return variables.${w}`;w==="always"&&(k="return true;"),w==="never"&&(k="return false;"),t({[_t.ALLOWED]:w,[_t.ALLOWED_LOGIC]:k});},h=w=>{t({[_t.IGNORE_CASCADE]:w});},v=H(w=>w.records.entities.block),T=n.consumers.filter(w=>v[w].section_id!==n.section_id),y=!!T.length,C=T.slice(0,3).map((w,k)=>jsxs(Fragment,{children:[k===T.length-1&&T.length>1?"and ":"",jsx("strong",{children:`${v[w].type} ${w} [Section ${v[w].section_id}]`},w),k<T.length-1&&T.length>1?", ":""]})),b=n.inputs.map(w=>({label:`${v[w]?.type} - ${v[w]?.id}`,value:w}));return jsx(Group,{grow:true,align:"flex-start",children:jsxs(Stack,{justify:"flex-start",children:[jsx(Title,{order:4,children:"Visibility"}),jsx(Select,{label:"Show",description:"Set visibility setting for this block. A hidden block will not run or export variables to its consumers. As a result, all its consumers will be hidden too.",defaultValue:n.settings[_t.ALLOWED]||"always",onChange:f,data:u}),[E.GENERATOR,E.VIZ,E.SECTION_FLAG].includes(n.type)&&jsx(MultiSelect,{label:"Ignore cascade",description:"Set block as visible even if the selected inputs are hidden.",defaultValue:n.settings[_t.IGNORE_CASCADE]||[],data:b,onChange:h}),jsx(Sa,{value:i,onChange:a}),jsx(Checkbox,{checked:l,disabled:i.includes("public"),label:"Show fallback block when block is not allowed",onChange:w=>s(w.currentTarget.checked)}),jsx(Title,{order:4,children:"Output"}),y&&n.shared&&jsxs(Text,{size:"xs",color:"red.4",sx:{display:"flex",alignItems:"flex-start",gap:"0.4rem"},children:[jsx(IconAlertCircle,{size:"1.2rem"}),jsxs(Text,{color:"black",span:true,inherit:true,children:["This block is being consumed by ",C,T.length>3&&" and others",". Please, make sure you remove this block dependencies before changing this setting."]})]}),jsx(Select,{label:"Block scope",description:"Select the scope for the variables exported by this block. Section-wide (available only to blocks in the same section) or Report-wide (available to any block inside the report).",defaultValue:String(n.shared),disabled:y&&n.shared,onChange:w=>g("shared",w==="true"),data:d}),jsx(Title,{order:4,children:"Danger zone"}),jsx(Button,{variant:"outline",color:"red",onClick:m,children:"Delete Block"})]})})}var Vw=VH;p();Ss();ae();Rr();Pt();he();var Fh={Consumer:jsx(ThemeIcon,{size:"xs",radius:"xl",color:"red",variant:"light",children:jsx(IconLogout,{})}),Input:jsx(ThemeIcon,{size:"xs",radius:"xl",color:"green",children:jsx(IconCircleCheck,{})}),None:jsx(ThemeIcon,{size:"xs",radius:"xl",color:"gray",children:jsx(IconCirclePlus,{})})};function t2({id:e}){let t=ie(),o=useContext(De),[r,n]=useState(""),[i]=useDebouncedValue(r,200),a=H(h=>{if(h.records.reports&&h.records.reports[0]){let v=h.records.reports[0],T=h.records.entities.report[v].sections;return Object.values(h.records.entities.block).filter(y=>T.includes(y.section_id))}return []}),l=tt(e).data,s=H(h=>h.variables.variables),c=useMemo(()=>l?l.inputs.reduce((h,v)=>({...h,[v]:a[v]}),{}):[],[l]),u=(h,v)=>{if(!l)return 0;let T=l.inputs.includes(h.id),y=l.inputs.includes(v.id);if(T!==y)return T?1:-1;let C=Object.keys(s[h.id]||{}).length,b=Object.keys(s[v.id]||{}).length;return C!==b?b-C:h.shared?1:-1},d=useMemo(()=>a.filter(h=>h.id!==l.id&&(h.section_id===l.section_id||h.shared)&&h.type!==E.SECTION_FLAG).sort(u),[a]),m=useMemo(()=>d.filter(h=>{let v=String(h.id).includes(i.trim()),T=Object.keys(s[h.id]||{}).some(y=>y.includes(i.trim()));return v||T}),[d,i,s]),g=h=>{let v=c[h]?"delete":"create";t(Z.updateEntity("block",{id:e,inputAction:{operation:v,input:{input_id:h,block_id:e}}})).then(()=>{t(qt(o));});};if(!l)return null;let f=h=>l.consumers.includes(h)?Fh.Consumer:l.inputs.includes(h)?Fh.Input:Fh.None;return jsxs(Menu,{width:"425px",children:[jsx(Menu.Target,{children:jsx(Button,{fullWidth:true,sx:{marginBottom:"15px"},leftIcon:jsx(IconLogin,{size:"1rem",style:{transform:"scaleX(-1)"}}),children:"Add New Input"})}),jsxs(Menu.Dropdown,{children:[jsx(TextInput,{placeholder:"Search by variable name or block id.",size:"xs",value:r,onChange:h=>n(h.target.value)}),m.map(({id:h,shared:v})=>jsx(Menu.Item,{disabled:l.consumers.includes(h),onClick:()=>g(h),icon:f(h),rightSection:jsxs(Stack,{ml:"xs",spacing:"xs",align:"flex-end",children:[jsxs(Text,{size:"xs",color:"gray.6",children:["[",h,"]"]}),v?jsx(ThemeIcon,{size:"xs",radius:"xl",children:jsx(IconGlobe,{})}):null]}),children:jsx(Box,{style:{maxWidth:"400px"},children:jsx(Or,{id:`${h}`,variables:s[h]})})},h))]})]})}var $w=t2;op();p();xe();he();p();he();p();p();var Vh=e=>`
53
- `.padEnd(e*2+1," "),Uw=(e,t=0)=>{let o=e instanceof Array;return `${o?"[":"{"}${Vh(t+1)}${Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{let n=o?"":`${r}: `,i=e[r];return typeof i=="object"?n+=`${Uw(i,t+1)}`:typeof i=="string"&&(i.includes("=>")||i.startsWith("variables["))?n+=`${i}`:typeof i=="string"&&!i.length?n+="false":i===void 0?n=null:["boolean","number"].includes(typeof i)?n+=i:n+=`"${i}"`,n}).filter(r=>r!==null).join(`,${Vh(t+1)}`)}${Vh(t)}${o?"]":"}"}`},Hs=Uw;xe();p();Kr();p();var Gw=e=>{if(!e)return e;let t=Array.isArray(e)?[]:{};return Object.keys(e).forEach(o=>{t[o]=typeof e[o]=="object"?Gw(e[o]):e[o];}),t},td=Gw;p();var o2=(e,t=false)=>{let o=/([A-z0-9]*)\{\{([^}]+)\}\}/g,r=(a,l,s)=>l?`\${formatters.${l}(variables.${s})}`:`\${variables.${s}}`,n=a=>typeof a=="string"?a.trim()===""?false:t?a.replace(o,r):a:Array.isArray(a)?a.map(l=>n(l)):typeof a=="object"&&a!==null?Object.keys(a).sort((l,s)=>l.localeCompare(s)).reduce((l,s)=>({...l,[s]:n(a[s])}),{}):typeof a=="boolean"||typeof a=="number"?a:JSON.stringify(a),i=n(e);return Array.isArray(e)?`return ${JSON.stringify(i)};`:Object.keys(i).sort((a,l)=>a.localeCompare(l)).reduce((a,l)=>{let s;return typeof i[l]=="string"?i[l].includes("=>")||i[l].startsWith("variables[")?s=i[l]:s=`\`${i[l]}\``:typeof i[l]=="boolean"||typeof i[l]=="number"?s=i[l]:s=JSON.stringify(i[l]),a.concat(`"${l}": ${s},
54
- `)},"return {").concat("};")},nn=o2;p();p();p();function Jw(e){let{state:t,transaction:o}=e,{selection:r}=o,{doc:n}=o,{storedMarks:i}=o;return {...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return n},get tr(){return r=o.selection,n=o.doc,i=o.storedMarks,o}}}var Hh=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state;}get hasCustomState(){return !!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:o,state:r}=this,{view:n}=o,{tr:i}=r,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,s])=>[l,(...u)=>{let d=s(...u)(a);return !i.getMeta("preventDispatch")&&!this.hasCustomState&&n.dispatch(i),d}]))}get chain(){return ()=>this.createChain()}get can(){return ()=>this.createCan()}createChain(t,o=true){let{rawCommands:r,editor:n,state:i}=this,{view:a}=n,l=[],s=!!t,c=t||i.tr,u=()=>(!s&&o&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),l.every(m=>m===true)),d={...Object.fromEntries(Object.entries(r).map(([m,g])=>[m,(...h)=>{let v=this.buildProps(c,o),T=g(...h)(v);return l.push(T),d}])),run:u};return d}createCan(t){let{rawCommands:o,state:r}=this,n=false,i=t||r.tr,a=this.buildProps(i,n);return {...Object.fromEntries(Object.entries(o).map(([s,c])=>[s,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,n)}}buildProps(t,o=true){let{rawCommands:r,editor:n,state:i}=this,{view:a}=n,l={tr:t,editor:n,view:a,state:Jw({state:i,transaction:t}),dispatch:o?()=>{}:void 0,chain:()=>this.createChain(t,o),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([s,c])=>[s,(...u)=>c(...u)(l)]))}};return l}};function So(e,t,o){return e.config[t]===void 0&&e.parent?So(e.parent,t,o):typeof e.config[t]=="function"?e.config[t].bind({...o,parent:e.parent?So(e.parent,t,o):null}):e.config[t]}function A2(e){let t=e.filter(n=>n.type==="extension"),o=e.filter(n=>n.type==="node"),r=e.filter(n=>n.type==="mark");return {baseExtensions:t,nodeExtensions:o,markExtensions:r}}function co(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Qw(...e){return e.filter(t=>!!t).reduce((t,o)=>{let r={...t};return Object.entries(o).forEach(([n,i])=>{if(!r[n]){r[n]=i;return}if(n==="class"){let l=i?i.split(" "):[],s=r[n]?r[n].split(" "):[],c=l.filter(u=>!s.includes(u));r[n]=[...s,...c].join(" ");}else if(n==="style"){let l=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],s=r[n]?r[n].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;s.forEach(u=>{let[d,m]=u.split(":").map(g=>g.trim());c.set(d,m);}),l.forEach(u=>{let[d,m]=u.split(":").map(g=>g.trim());c.set(d,m);}),r[n]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ");}else r[n]=i;}),r},{})}function P2(e){return typeof e=="function"}function lo(e,t=void 0,...o){return P2(e)?t?e.bind(t)(...o):e(...o):e}function O2(e){return Object.prototype.toString.call(e)==="[object RegExp]"}var sd=class{constructor(t){this.find=t.find,this.handler=t.handler;}};var Wh=class{constructor(t){this.find=t.find,this.handler=t.handler;}};function L2(e){return Object.prototype.toString.call(e).slice(8,-1)}function od(e){return L2(e)!=="Object"?false:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function dd(e,t){let o={...e};return od(e)&&od(t)&&Object.keys(t).forEach(r=>{od(t[r])&&od(e[r])?o[r]=dd(e[r],t[r]):o[r]=t[r];}),o}var sn=class e{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=lo(So(this,"addOptions",{name:this.name}))),this.storage=lo(So(this,"addStorage",{name:this.name,options:this.options}))||{};}static create(t={}){return new e(t)}configure(t={}){let o=this.extend({...this.config,addOptions:()=>dd(this.options,t)});return o.name=this.name,o.parent=this.parent,o}extend(t={}){let o=new e({...this.config,...t});return o.parent=this,this.child=o,o.name=t.name?t.name:o.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${o.name}".`),o.options=lo(So(o,"addOptions",{name:o.name})),o.storage=lo(So(o,"addStorage",{name:o.name,options:o.options})),o}};function M2(e,t,o){let{from:r,to:n}=t,{blockSeparator:i=`
46
+ a viverra sapien pulvinar.`,style:o,append:t?jsx(Ut,{content:t,style:{display:"inline-block",verticalAlign:"bottom"}}):jsx(Fragment,{}),isPreview:true})}var ew=D(()=>{p();Cn();mt();});function ch({subtitle:e,title:t,value:o,tooltip:r,settings:n,_iconType:i,_iconVariant:a,_icon:l,_iconRadius:s,_iconSize:c,_iconPadding:u}){let d=t||"<span class='cr-block-placeholder'>Title</span>",f=o||"<span class='cr-block-placeholder'>Big Stat</span>",g=e||"<span class='cr-block-placeholder'>Subtitle</span>",m=n&&n.align||"left";return jsx("div",{className:"bespoke-Stat-root",children:jsxs(Group,{className:"bespoke-StatGroup-wrapper",position:oo(m),children:[i!=="none"&&i&&jsx(je,{blockType:"stat",iconType:i,iconVariant:a,iconRadius:s,iconSize:c,icon:l,iconPadding:u}),jsxs("div",{className:"bespoke-Stat-wrapper",children:[jsx(ve,{component:"div",size:"md",html:d,style:n,isPreview:true}),jsx(ve,{component:"div",size:"xl",html:f,style:n,isPreview:true}),jsx(ve,{component:"div",size:"sm",html:g,style:n,isPreview:true})]},"stat"),r&&jsx(Ut,{content:r})]})})}var ow=D(()=>{p();Cn();kn();mt();ro();});function uh({subtitle:e,tooltip:t,settings:o}){let r=He(e)||"<span class='cr-block-placeholder'>Small subtitle.</span>",n=o&&o.align?o.align:"left";return jsxs(Group,{spacing:"sm",position:oo(n),children:[jsx(ve,{size:"sm",html:r,isPreview:true}),t&&jsx(Ut,{content:t,style:{display:"inline-flex"}})]})}var nw=D(()=>{p();Cn();Wr();mt();ro();});function ph({title:e,tooltip:t,_iconType:o,_iconVariant:r,_icon:n,settings:i,_iconRadius:a,_iconSize:l,_iconPadding:s}){let c=He(e)||"Title",u=i&&i.order?parseInt(i.order,10):1,d=u<=6?u:1,f=!!(i&&i.search&&i.search!=="off"),g=i&&i.search?i.search:"",m=i&&i.align?i.align:"left";return jsxs(Group,{spacing:"sm",position:oo(m),children:[o!=="none"&&o&&jsx(je,{blockType:"title",iconType:o,iconVariant:r,iconRadius:a,iconSize:l,icon:n,iconPadding:s}),jsx(ve,{component:"h",order:d,style:i,html:c,isPreview:true}),f&&jsx(Tooltip,{label:`Click will open '${g}' report search`,children:jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})}),t&&jsx(Ut,{content:t})]})}var iw=D(()=>{p();Cn();Wr();kn();mt();ro();});function fh(e){let{id:t,type:o,defaultValue:r,options:n,name:i,settings:a,hideLabel:l,component:s,resetSectionVars:c,section:u}=e,d=useDispatch(),f=useContext(De),g=we(),m=H(P=>P.status.query),{sectionVariables:h,resetSectionVariables:y}=pt(u),S=LU(t),v=useMemo(()=>m[S]||r,[m[S],o,r]),C=useMemo(()=>MU(m[S],r),[m[S],o,r]),[b,k]=useState(n?.map(P=>({value:P.id,label:P.label,imageUrl:P.imageUrl}))||[]),[w,R]=useState((n||[]).map(P=>P.id).join("-"));useEffect(()=>{let P=n.map(M=>`${M.label}|${M.id}`).join("-");if(w===P)return;R(P);let I=n.map(M=>({value:M.id,label:M.label}));k(I);let F=o===St.SINGLE?v:C;Fi(o,F,n)||d(lf(f,S,g));},[JSON.stringify(n),t]);let O=()=>{c==="true"&&h&&y();},A=P=>{d(qi(f,S,P,g)),O();},B=P=>{d(qi(f,S,P.join(),g)),O();},_=l==="true"?jsx(Fragment,{}):jsx(ve,{component:"div",html:i,size:"sm",style:a,isPreview:true});return b.length===0?jsx(Text,{c:"dimmed",size:"xs",children:"No options defined yet. Selector hidden in report."}):b.length===1?jsxs(Text,{c:"dimmed",size:"xs",children:["Only one option defined. Selector hidden in report. ",JSON.stringify(b)]}):{[St.SINGLE]:s===Eu.SEGMENTED_CONTROL?jsxs("div",{children:[_,jsx(SegmentedControl,{data:b,value:b.map(P=>P.value).includes(v)?v:"",onChange:A,fullWidth:true})]}):jsx(Select,{label:_,data:b,value:v,onChange:A,itemComponent:BU,styles:{label:{display:l==="true"?"none":"block"}}}),[St.MULTI]:jsx(MultiSelect,{label:_,data:b,value:C,onChange:B,styles:{label:{display:l==="true"?"none":"block"}}})}[o]}var LU,MU,BU,lw=D(()=>{p();Vl();Ru();he();se();Pt();mt();ye();Xe();LU=e=>`selector${e}id`,MU=(e,t)=>e&&typeof e=="string"?e.split(","):t,BU=forwardRef(function({imageUrl:t,label:o,...r},n){return jsx("div",{ref:n,...r,children:jsxs(Group,{noWrap:true,children:[t&&jsx(Box,{component:"img",w:25,h:25,src:t}),jsx("div",{children:jsx(Text,{size:"sm",children:o})})]})})});});function HU({outputVariables:e,status:t,hasAPI:o=false,debug:r,type:n}){let[i,a]=useState(false),l=o&&!Object.keys(e).length&&!t.error,s=Object.keys(e).some(u=>u.startsWith("_"));return r?l?jsxs(Stack,{align:"center",children:[jsx(Loader,{}),jsxs(Text,{size:"sm",children:["Loading ",n]})]}):jsxs(Fragment,{children:[jsx(Divider,{label:"Output Variables",labelPosition:"center"}),s&&jsx(Switch,{label:"Show internal variables",mb:"xs",size:"xs",checked:i,onChange:u=>a(u.currentTarget.checked)}),jsx(Ar,{variables:e,showInternal:i})]}):jsx(Center,{children:jsx(Badge,{color:"gray",variant:"outline",children:n.toUpperCase()},"type")})}var hh,cw=D(()=>{p();ys();hh=HU;});function bh(e){let{alt:t,src:o,desc:r,title:n,settings:i,...a}=e,l=He(t),s=He(o),c=He(r),u=jsx("img",{src:s,alt:l,style:a}),d=i&&i.align?String(i.align):"left";return (c&&c.length||n&&n.length)&&(u=jsxs(Stack,{className:"bespoke-Image-wrapper",align:Po(d),spacing:"sm",children:[n&&jsx(ve,{component:"p",html:n,style:i,isPreview:true}),u,r&&jsx(ve,{component:"p",size:"sm",html:r,style:i,isPreview:true})]})),s&&l?u:jsx(Center,{mih:100,bg:"white",children:jsx(Badge,{color:"gray",variant:"outline",children:"IMAGE"},"type")})}var uw=D(()=>{p();Wr();mt();ro();});function Sh({headings:e,settings:t,title:o,shortTitle:r,_iconType:n,_iconVariant:i,_icon:a,_iconRadius:l,_iconSize:s,_iconPadding:c}){let{min:u="1",max:d="6",icons:f="yes"}=t||{},g=He(o)||"",m=He(r||o)||"",h=g&&g.length>0,y=n&&n!=="none",S=m===g?`${g}`:`${g} (${m})`,v=na(parseInt(u,10),parseInt(d,10),e),C=f==="yes",b=t&&t.align?String(t.align):"left",k=ws(b),w=oo(b),R=Po(b),O=t&&t.titlePosition?String(t.titlePosition):"left",A=useMemo(()=>{let _={right:"left",left:"right"},P=h&&["left","right"].includes(O),I={};if(P){let F=O==="right";I={spacing:"xs",position:F&&_[w]?_[w]:w,style:{flexDirection:F?"row-reverse":"row"},noWrap:true};}else I={spacing:"xs",align:R,justify:"center",style:{flexDirection:O==="bottom"?"column-reverse":"column"}};return {element:P?Group:Stack,props:I}},[h,w,R,O]),B=_=>!_||!_?.length?null:jsx(Fragment,{children:_.map(P=>jsxs(Fragment$2,{children:[jsx(Menu.Item,{children:jsx(Anchor,{href:`#bespoke-title-${P.id}`,children:jsxs(Group,{spacing:"sm",children:[C&&jsx(je,{...P.iconProps,iconSize:"sm"}),jsx(Text,{dangerouslySetInnerHTML:{__html:P.label}})]})})},P.id),jsx(Box,{pl:"xs",children:B(P.children)})]},P.id))});return jsxs(A.element,{pos:"relative",...A.props,children:[h&&jsxs(Group,{spacing:"xs",position:w,noWrap:true,children:[y&&jsx(je,{blockType:"title",iconType:n,iconVariant:i,iconRadius:l,iconSize:s,icon:a,iconPadding:c}),jsx(ve,{style:t,html:S,isPreview:true,lineClamp:1})]}),jsxs(List,{sx:_=>({display:"flex",gap:_.spacing.md,justifyContent:k,alignItems:"center",listStyleType:"none"}),children:[v?.map(_=>jsx(List.Item,{children:jsxs(Menu,{trigger:"hover",openDelay:100,closeDelay:400,children:[jsx(Menu.Target,{children:jsx(Anchor,{href:`#bespoke-title-${_.id}`,children:jsxs(Group,{spacing:"sm",noWrap:true,children:[C&&jsx(je,{blockType:"nav",..._.iconProps,iconSize:"sm",iconPadding:"2"}),jsx(Text,{dangerouslySetInnerHTML:{__html:_.label}})]})})}),_?.children?.length?jsx(Menu.Dropdown,{children:B(_.children)}):null]})},_.id)),!v||v.length===0&&jsx(List.Item,{children:jsx(Text,{color:"dimmed",children:"- Include some titles as inputs to see the Nav component -"})})]})]})}var dw=D(()=>{p();st();kn();ro();mt();kn();Wr();});function Th(e){let{related_reports:t,settings:o}=e;if(!t?.length)return jsx(Text,{children:"There are no available members related to your current selection and report."});let r=ws(o&&o.align?String(o.align):"left");return jsx(List,{sx:()=>({display:"flex",justifyContent:r,"& li":{marginRight:"1rem"}}),children:t.map(n=>jsx(List.Item,{children:n.entities.map(i=>i.name).join(" & ")},n.link))})}var fw=D(()=>{p();ro();});function kh({id:e,label:t,settings:o,showIcon:r,fullWidth:n,showWhenDisabled:i}){let a=tt(e).data,{sectionVariables:l,resetSectionVariables:s}=pt(a?.section_id),c=!!Object.keys(l).length,u=Po(o&&o.align?o.align:"left");return jsxs(Stack,{align:u,children:[!c&&!i&&jsx(Text,{size:"xs",ta:o?.align||"left",children:"Reset button will not be shown on its disabled state"}),jsx(Button,{onClick:()=>s(),disabled:!c,fullWidth:n,children:jsxs(Group,{align:"center",children:[t,r&&jsx(IconRefresh,{})]})})]})}var hw=D(()=>{p();ye();ro();});function Eh({settings:e,label:t,showIcon:o,position:r="center"}){let n=e&&e.search?e.search:"";return jsxs(Group,{position:r,children:[jsx(Tooltip,{label:`Click will open '${n}' report search`,children:jsx(Button,{children:jsxs(Group,{align:"center",children:[t||"Comparison Button",o&&jsx(IconPlus,{})]})})}),jsx(ActionIcon,{variant:"light",children:jsx(IconSearch,{size:20})})]})}var vw=D(()=>{p();});function Rh({columns:e=[],id:t,data:o=[],tableProps:r={}}){let[n,i]=useState({}),{initialState:a}=r,l=a?.pagination?.pageIndex,s=a?.pagination?.pageSize,c=`table-${[t,l,s].filter(m=>m).join("-")}`,u=useMemo(()=>e.map(m=>m.accessorKey),[e]),d=useMemo(()=>o.filter(m=>typeof m=="object"&&m!==null&&!Array.isArray(m)&&Object.keys(m).some(h=>u.includes(h))),[u,o]),f=useMemo(()=>e.map(m=>({...m,Cell:({renderedCellValue:h})=>jsx(ve,{html:`${h}`,isPreview:true}),filterFn:"contains"})),[e]),g=ts();return useEffect(()=>{(async()=>{try{let h=g||"en",y=`${h.toUpperCase()}`,S=await import(`mantine-react-table/locales/${h}.js`);i(S[`MRT_Localization_${y}`]);}catch(h){console.error("Error loading translations:",h);}})();},[g]),createElement(MantineReactTable,{...r,autoResetPageIndex:false,columns:f,data:d,enableColumnFilterModes:true,enableFilterMatchHighlighting:false,globalFilterFn:"contains",key:c,layoutMode:"grid",localization:n,state:{...r.state,isFullScreen:false}})}var Sw=D(()=>{p();mt();ye();});function Ih({label:e,url:t,settings:o}){let{align:r}=o;return jsx(Group,{position:r,grow:r==="justify",children:jsx(Button,{component:"a",target:"_blank",href:t||"",children:e||"Button"})})}var Tw=D(()=>{p();});function Ph(e){let t=useDispatch(),o=useContext(De),r=we(),n=H(oe=>oe.status.query),i=BG(e.id),a=useMantineTheme(),{allLabel:l,colorKey:s,data:c,defaultValue:u,defaultValueType:d,iconKey:f,levels:g,limit:m,placeholder:h,searchIndexKey:y,searchIndexSeparator:S,resetSectionVars:v,section:C}=e,[b,k]=useState(false),[w,R]=useState(true),[O,A]=useState(""),[B,_]=useState(false),[P,I]=useState([""].slice(1)),{sectionVariables:F,resetSectionVariables:M}=pt(C),N=useMemo(()=>DG(n[`${i}-value`],u),[n,u,i]),j=useMemo(()=>n[`${i}-type`]||d,[n,d,i]),$=useCallback(()=>{v==="true"&&F&&M();},[v,F,M]),V=useCallback(oe=>{$(),t(qi(o,`${i}-value`,oe.join(),r));},[t,o,i,$,r.status]),z=useCallback(oe=>{$(),t(qi(o,`${i}-type`,oe,r));},[t,o,i,$,r.status]),q=useRef(null),W=useRef(false),U=useRef(!!m&&m<N.length),Y=P.length,ne=g[Y],re=P.filter(Boolean);P.length>0&&re.length===0&&re.push(`${l} ${ne?.label}`),useEffect(()=>{let oe=()=>{R(true);};return window.addEventListener("touchmove",oe),()=>{window.removeEventListener("touchmove",oe);}},[]);let J=useMemo(()=>OG(c,g,s,f,y,S),[s,c,f,g,y,S]),G=useMemo(()=>{let oe=LG(O),Oe=Array.from(MG(J,oe)).reverse();return B?Oe:P.reduce((L,Q)=>L.filter(te=>!Q||te.searchindex.indexOf(Q)>-1),Oe.filter(L=>L.type===ne?.value))},[ne,J,O,B,P]),K=useRef(null),ee=Ip({count:b?G.length:0,estimateSize:()=>30,getScrollElement:useCallback(()=>K.current,[]),overscan:10,rangeExtractor:useCallback(oe=>hc(oe),[])}),[ae,ue]=useState(-1),Te=Math.min(ae,G.length-1),X=useCallback(oe=>{let Oe=P.concat(oe);B&&_(false),I(Oe);},[B,P]),le=useCallback(()=>{let oe=P.slice(0,Y-1);B&&_(false),I(oe);},[B,P,Y]),de=useCallback(oe=>{A(oe.currentTarget.value),!U.current&&c.length>0&&k(true);},[c,A,U,k]),Ce=useCallback(()=>{A(""),V([]),q.current?.focus(),m&&(U.current=false);},[A,V,q,m,U]),$e=useCallback(oe=>{let Oe=N.filter(L=>L!==oe);V(Oe),m&&Oe.length<m&&(U.current=false);},[N,V,m,U]),Ue=useCallback(oe=>{j||z(oe.type),j!==oe.type?(z(oe.type),V([oe.value])):N.includes(oe.value)?$e(oe.value):m?(N.length<m&&V([...N,oe.value]),N.length===m&&V([...N.slice(1),oe.value])):V([...N,oe.value]),A("");},[j,z,V,N,$e,m]),Qe=useCallback(()=>{N.length>0&&O.length===0&&(V(N.slice(0,-1)),k(true),m&&(U.current=false)),O.length>0&&A(O.slice(0,-1));},[N,O,V,A,k,m,U]),To=useCallback(()=>{R(oe=>oe&&(W.current=oe,!oe)),ue(oe=>oe+1>=G.length?oe:oe+1);},[ue,G]),$o=useCallback(()=>{let oe=G[Te];oe&&Ue(oe);},[G,Te,Ue]),uo=useCallback(()=>{k(false);},[k]),mn=useCallback(()=>{le(),ue(0);},[ue,le]),Un=useCallback(()=>{let oe=G[Te];!B&&oe&&oe.type!==g[g.length-1]?.value&&(X(oe.name),ue(0));},[G,Te,B,g,ue,X]),Gn=useCallback(()=>{R(oe=>oe&&(W.current=oe,!oe)),ue(oe=>oe-1<0?0:oe-1);},[ue]),Hn=({label:oe,onRemove:Oe,...L})=>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"},...L,children:[jsx("span",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:oe}),jsx(CloseButton,{"aria-hidden":true,iconSize:"70%",onMouseDown:Oe,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})]}),Wn=useMemo(()=>N.map(oe=>J.find(Oe=>Oe.value===oe)).filter(oe=>!!oe).map((oe,Oe)=>createElement(Hn,{...oe,index:Oe,key:oe.value,onRemove:L=>{L.preventDefault(),L.stopPropagation(),$e(oe.value);}})),[N]),xl=forwardRef(function({color:Oe,icon:L,label:Q,value:te,...Se},fe){return jsx("div",{ref:fe,style:{cursor:"pointer",width:"100%"},...Se,children:jsxs(Group,{align:"center",noWrap:true,spacing:"xs",w:"100%",children:[L&&jsx(Box,{bg:Oe??"transparent",component:"img",w:20,h:20,src:L}),jsx(Text,{lineClamp:1,size:"sm",children:Q||te})]})})}),{settings:Tl}=e,Cl=e.hideLabel==="true"||!e.label?jsx(Fragment,{}):jsx(ve,{component:"div",html:e.label,size:"sm",style:Tl,isPreview:true});return jsx(Input.Wrapper,{label:Cl,children:jsxs(Popover,{closeOnClickOutside:true,keepMounted:true,opened:b,onChange:k,onClose:()=>{ue(0),A("");},onOpen:()=>{ee.scrollToIndex(0);},shadow:"sm",width:"target",withinPortal:true,children:[jsx(Popover.Target,{children:jsxs(Box,{"aria-haspopup":"listbox",component:"div",onMouseLeave:()=>ue(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:N.join(",")}),jsx(Input,{component:"div",multiline:true,onMouseDown:oe=>{oe.preventDefault(),!U.current&&c.length>0&&k(!b),q.current?.focus();},rightSection:N.length>0?jsx(CloseButton,{onClick:Ce,onMouseDown:oe=>oe.preventDefault(),variant:"transparent"}):jsx(IconSelector,{color:a.colors.gray[6],size:18,stroke:1.5}),style:{overflow:"hidden"},w:"100%",children:jsxs(Box,{component:"div","data-clearable":true,sx:{alignItems:"center",boxSizing:"border-box",display:"flex",flexWrap:"wrap",marginLeft:`calc(-${a.spacing.xs} / 2)`,minHeight:`calc(${rem(36)} - ${rem(2)})`,"&[data-clearable]":{marginRight:rem(36)},"&::placeholder":{color:a.colorScheme==="dark"?a.colors.dark[3]:a.colors.gray[5],opacity:1}},children:[Wn,jsx("input",{autoComplete:"off","data-mantine-stop-propagation":b,onChange:de,onKeyDown:getHotkeyHandler([["ArrowDown",To],["ArrowLeft",mn],["ArrowRight",Un],["ArrowUp",Gn],["Backspace",Qe],["Enter",$o],["Escape",uo]]),placeholder:N.length===0?h:void 0,ref:q,readOnly:U.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:O})]})})]})}),jsx(Popover.Dropdown,{onMouseDown:oe=>oe.preventDefault(),p:0,children:jsx("div",{style:{display:"flex",maxHeight:rem(300)},children:jsx(Box,{component:"div","data-combobox-popover":true,onMouseDown:oe=>oe.preventDefault(),role:"listbox",sx:{width:"100%"},tabIndex:-1,children:jsxs(Stack,{h:"100%",py:"xs",spacing:"xs",w:"100%",children:[g.length>1&&jsxs(Stack,{spacing:"xs",children:[jsxs(Group,{onClick:oe=>{oe.stopPropagation();},px:"xs",position:"center",spacing:"xs",children:[jsx(Button,{onClick:()=>{ue(0),_(true),I([]),G.length>0&&ee.scrollToIndex(0);},size:"xs",variant:B?"filled":"outline",children:l}),g.map((oe,Oe)=>jsx(Button,{onClick:()=>{B&&_(false);let L=[""].slice(1),Q=Oe;for(;Q--;)L[Q]=P[Q]||"";ue(0),I(L),G.length>0&&ee.scrollToIndex(0);},size:"xs",variant:!B&&P.length===g.findIndex(L=>L.value===oe?.value)?"filled":"outline",children:oe?.label},oe?.value))]}),jsx(Divider,{})]}),Y>0&&jsxs(Group,{align:"center",noWrap:true,px:"xs",children:[jsx(ActionIcon,{onClick:le,size:"sm",children:jsx(IconChevronLeft,{})}),jsx("div",{children:re.map(oe=>jsx(Text,{lineClamp:1,size:"xs",children:oe},`${oe}`))})]}),jsx(ScrollArea,{mah:250,onWheel:()=>R(true),px:"xs",style:{overflow:"auto",width:"100%"},viewportRef:K,viewportProps:{tabIndex:-1},w:"100%",children:jsx("div",{style:{height:`${ee.getTotalSize()}px`,position:"relative",width:"100%"},children:ee.getVirtualItems().map(oe=>{let Oe=G[oe.index],L=Te===oe.index,Q=N.includes(Oe.value);return G.length>0&&L&&!w&&ee.scrollToIndex(Te),jsxs(Group,{"aria-selected":L,align:"center","data-hovered":L||void 0,"data-index":oe.index,"data-selected":Q,id:Oe.vale,noWrap:true,onMouseEnter:te=>{te.preventDefault(),te.stopPropagation(),w&&(ue(oe.index),R(false));},onMouseMove:te=>{te.preventDefault(),te.stopPropagation(),R(true);},onMouseDown:te=>{te.preventDefault(),Ue(Oe);},position:"apart",ref:ee.measureElement,role:"option",spacing:"xs",sx:te=>({borderRadius:te.radius.xs,padding:"15px 5px 15px",paddingLeft:B&&10*g.findIndex(Se=>Se?.value===Oe.type)||5,position:"absolute",top:0,left:0,height:`${oe.size}px`,transform:`translateY(${oe.start}px)`,width:"100%","&[data-hovered]":{backgroundColor:te.colorScheme==="dark"?te.colors.dark[4]:te.colors.gray[1]},"&:hover":{backgroundColor:te.colorScheme==="dark"?te.colors.dark[4]:te.colors.gray[1]}}),tabIndex:-1,children:[jsx(xl,{index:oe.index,...Oe}),!B&&Oe.type!==g[g.length-1]?.value&&jsx(ActionIcon,{onMouseDown:te=>{te.preventDefault(),te.stopPropagation(),X(Oe.name);},size:"sm",tabIndex:-1,children:jsx(IconChevronRight,{})})]},Oe.value)})})})]})})})})]})})}var OG,LG,MG,BG,DG,Aw=D(()=>{p();Eg();mt();Pt();se();ye();Vl();Xe();OG=(e=[],t=[],o="",r="",n="",i="|")=>{let a=t.map(h=>h.value).slice(),l=`${a.pop()}`,s=h=>h[o],c=h=>h[r],u=h=>{if(h[n])return typeof h[n]=="string"?h[n].split(i):h[n]},d=new Set,f=[],g=[],m=nest().rollup(h=>{let y=h[0],S=A=>A&&A.value&&!d.has(A.value),v=a.map(A=>y[`${A} ID`]),C=a.map(A=>y[A]),b=a.map((A,B)=>{if(g[B]!==C[B]){g[B]=C[B];let _=s[B]||s[s.length-1]||s,P=c[B]||c[c.length-1]||c,I=u[B]||u[u.length-1]||u;return {color:_(y,A)||void 0,icon:P(y,A)||void 0,value:`${v[B]}`,label:C[B],name:C[B],type:A,searchindex:C.slice(0,B+1).concat(I(y,A)).join("|")}}return {}}).filter(S);b.forEach(A=>d.add(A.value));let k=s[s.length-1]||s,w=c[c.length-1]||c,R=u[u.length-1]||u,O=h.map(A=>({color:k(A,l)||void 0,icon:w(A,l)||void 0,value:`${A[`${l} ID`]}`,label:A[l],name:A[l],type:l,searchindex:C.concat(A[l]).concat(R(A,l)).join("|")}));f.push(...b.concat(O));});return a.forEach(h=>{m.key(y=>`${y[`${h} ID`]}|${y[h]}`);}),m.entries(e),f},LG=e=>{if(!e)return /./i;let t=e.normalize("NFD").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g,"[^|]+");return RegExp(t,"i")},MG=(e,t)=>{let o=e.length,r,n=l=>r&&r.searchindex.includes(l.searchindex),a={next:()=>{for(let l=o-1;l>-1;l--){let s=e[l];if(t.test(`${s.value} ${s.label} ${s.searchindex}`)||n(s))return r=s,o=l,{done:false,value:s}}return {done:true,value:void 0}},[Symbol.iterator]:()=>a};return a},BG=e=>`multihierarchySelector${e}`,DG=(e,t)=>e&&typeof e=="string"?e.split(","):t;});var Pw={};ym(Pw,{default:()=>KG});function jG({block:e,active:t,locale:o,variables:r,configOverride:n={}}){let i=HG(),a=ko(e),l=Io(o),s={variables:r},c=vn(),u=we(),d=useRouter(),{sectionVariables:f,setSectionVariables:g,resetSectionVariables:m}=pt(e.section_id),h=useMemo(()=>{if(!t)return {error:"Activate to View"};if(!a?.logic)return {error:"Add a Configuration"};let R=xr({logic:a.logic},l,s).logic,O={router:d,section:{variables:f,setVariables:g,resetVariables:m}};return pa(R,l,r,o,e.id,{},O,c,u)},[a?.logic,t,r,f,u.status]),{type:y}=h.config||{},S=y&&Oh[y]?y:"Treemap";y||(h.config={error:'Visualization missing "type"'}),Oh[y]||(h.config={error:`"${y}" is not a valid Visualization Type`});let v=Oh[S],C=h.error||h.config?.error||false;if(C)return jsx(Center,{style:{height:"100%"},children:jsx(Badge,{color:"gray",variant:"outline",children:C},"type")});let{_data:b,...k}=h.config,w={locale:o,variables:r,...k,...n};return i.print&&(w.detectVisible=false),jsx("div",{style:{display:"flex",flex:"1 1 100%"},children:jsx(Rn,{fallback:jsx("p",{children:"Error in d3plus viz config."}),children:jsx(v,{style:{flex:1},dataFormat:R=>{let O;try{O=h.dataFormat(R);}catch(A){console.error("Error in dataFormat: ",A),O=[];}return O},linksFormat:h.linksFormat,nodesFormat:h.nodesFormat,topojsonFormat:h.topojsonFormat,config:{...w}},"viz-key")})})}var HG,WG,Oh,KG,Ow=D(()=>{p();zi();vp();cc();Ho();ye();Xe();Dp();HG=()=>({}),WG={},Oh={[da]:yp,...EV,...WG};KG=memo(jG,(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 YG,kt,Lw=D(()=>{p();he();ew();ow();nw();iw();lw();cw();uw();dw();fw();hw();vw();Sw();Tw();Aw();YG=IV(()=>Promise.resolve().then(()=>(Ow(),Pw)),{ssr:false}),kt={[E.PARAGRAPH]:lh,[E.STAT]:ch,[E.SUBTITLE]:uh,[E.TITLE]:ph,[E.SELECTOR]:fh,[E.VIZ]:YG,[E.GENERATOR]:hh,[E.SECTION_FLAG]:hh,[E.IMAGE]:bh,[E.NAV]:Sh,[E.RELATED]:Th,[E.RESET_BUTTON]:kh,[E.COMPARISON_BUTTON]:Eh,[E.TABLE]:Rh,[E.BUTTON]:Ih,[E.MULTIHIERARCHY_SELECTOR]:Ph};});function Oc(e){return Lh[e]||IconDice}var Lh,Mh=D(()=>{p();he();Lh={[E.TITLE]:IconHeading,[E.GENERATOR]:IconApi,[E.SECTION_FLAG]:IconFlag,[E.STAT]:IconPercentage,[E.VIZ]:IconChartBar,[E.PARAGRAPH]:IconAlignLeft,[E.SELECTOR]:IconSelector,[E.IMAGE]:IconPhoto,[E.TABLE]:IconTable,[E.MULTIHIERARCHY_SELECTOR]:IconListTree};});function Lc(e){return Bh[e]}var Bh,Dh=D(()=>{p();he();Bh={[E.TITLE]:"Title",[E.GENERATOR]:"Data",[E.STAT]:"Stat",[E.VIZ]:"Visualization",[E.PARAGRAPH]:"Paragraph",[E.SELECTOR]:"Selector",[E.SUBTITLE]:"Subtitle",[E.RESET_BUTTON]:"Reset Button",[E.COMPARISON_BUTTON]:"Comparison Button",[E.RELATED]:"Related Reports",[E.NAV]:"Navigation",[E.IMAGE]:"Image",[E.TABLE]:"Table",[E.BUTTON]:"Button",[E.FALLBACK]:"Fallback",[E.SECTION_FLAG]:"Section Flag",[E.MULTIHIERARCHY_SELECTOR]:"Multihierarchy Selector"};});var sH,Ms,Bs=D(()=>{p();he();Xf();Lw();Mh();Dh();sH={[E.GENERATOR]:{type:E.GENERATOR,renderer:kt[E.GENERATOR],renderPreviewOnEdit:false},[E.SECTION_FLAG]:{type:E.SECTION_FLAG,renderer:kt[E.SECTION_FLAG],renderPreviewOnEdit:false},[E.IMAGE]:{type:E.IMAGE,renderer:kt[E.IMAGE],renderPreviewOnEdit:false},[E.PARAGRAPH]:{type:E.PARAGRAPH,renderer:kt[E.PARAGRAPH],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.RELATED]:{type:E.RELATED,renderer:kt[E.RELATED],renderPreviewOnEdit:false,evalWhenNonActive:false},[E.SELECTOR]:{type:E.SELECTOR,renderer:kt[E.SELECTOR],adapter:sr[E.SELECTOR],nonActiveAdapter:()=>sr[E.SELECTOR]({name:"Selector Preview"}),renderPreviewOnEdit:false},[E.STAT]:{type:E.STAT,renderer:kt[E.STAT],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.SUBTITLE]:{type:E.SUBTITLE,renderer:kt[E.SUBTITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.TITLE]:{type:E.TITLE,renderer:kt[E.TITLE],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.VIZ]:{type:E.VIZ,renderer:kt[E.VIZ],renderPreviewOnEdit:false},[E.NAV]:{type:E.NAV,renderer:kt[E.NAV],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.RESET_BUTTON]:{type:E.RESET_BUTTON,renderer:kt[E.RESET_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.COMPARISON_BUTTON]:{type:E.COMPARISON_BUTTON,renderer:kt[E.COMPARISON_BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.TABLE]:{type:E.TABLE,renderer:kt[E.TABLE],renderPreviewOnEdit:false,evalWhenNonActive:false},[E.BUTTON]:{type:E.BUTTON,renderer:kt[E.BUTTON],renderPreviewOnEdit:true,evalWhenNonActive:true},[E.MULTIHIERARCHY_SELECTOR]:{type:E.MULTIHIERARCHY_SELECTOR,renderer:kt[E.MULTIHIERARCHY_SELECTOR],adapter:sr[E.MULTIHIERARCHY_SELECTOR],nonActiveAdapter:()=>sr[E.MULTIHIERARCHY_SELECTOR]({label:"Multihierarchy Selector Preview"}),renderPreviewOnEdit:false}},Ms=sH;});p();p();p();function sv(e){let{onlyIcon:t,href:o,version:r}=e,n=jsx(Text,{c:"blue.5",ta:"left",children:jsxs(Group,{position:"left",spacing:"xs",children:[jsx(IconCircleDashed,{size:30}),!t&&jsxs(Text,{c:"black",fs:"lg",children:["Bespoke CMS",jsx(Text,{span:true,c:"dimmed",size:"xs",ml:3,children:r})]})]})});return o?jsx(CP,{href:o,passHref:true,children:jsx(UnstyledButton,{p:10,w:"100%",children:n})}):n}p();var dv=wn__default.createContext(void 0);function mv(e){let[t,o]=useState(false),[r,n]=useState(null),i=wn__default.useMemo(()=>{function c(u,d){return d?{show:()=>c(u)}:new Promise((f,g)=>{n({request:u,onResolve:f,onReject:g}),o(true);})}return {newConfirmation:c}},[]),a=()=>{o(false),setTimeout(()=>n(null),200);},l=useCallback(c=>{!t||!r||(r.onResolve(c),a());},[t,r]),s=useCallback(c=>{!t||!r||(r.onReject(c),a());},[t,r]);return jsxs(dv.Provider,{value:i,children:[r&&jsx(IP,{opened:t,request:r.request,onConfirm:l,onCancel:s}),e.children]})}function IP(e){let{request:t,opened:o,onCancel:r,onConfirm:n}=e,i=useMantineTheme();return jsxs(Modal,{centered:true,zIndex:1002,opened:o,title:t.title,onClose:r,children:[t.message,jsxs(Group,{position:"right",style:{marginTop:i.spacing.sm},children:[jsx(Button,{onClick:r,children:t.cancelText||"Cancel"}),jsx(Button,{color:"red",onClick:n,children:t.confirmText||"Confirm"})]})]})}function Kt(){let e=useContext(dv);if(e===void 0)throw new Error("useConfirmationDialog must be used within ConfirmationDialogProvider.");return e}Pt();st();p();p();p();function ls(e){return jsxs("span",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.icon,e.children]})}se();Pt();ye();st();Sn();p();function sx(e){let{left:t,center:o,right:r}=e;return jsx(Header,{height:50,p:"xs",pos:"sticky",zIndex:98,children:jsxs(Group,{position:"apart",children:[jsx("div",{className:"left",children:t}),jsx("div",{className:"center",children:o}),jsx("div",{className:"right",children:r})]})})}p();st();se();var hM=e=>({input:{border:"none",background:e.colors.blue[0],borderRadius:e.radius.sm,color:e.colors.blue[7],fontSize:12,fontWeight:700,width:80},item:{fontSize:12},rightSection:{pointerEvents:"none"}});function ql({value:e,onChange:t,defaultValue:o,selectProps:r={},loading:n=false}){let i=gf(),a=H(u=>u.status.localeDefault),[l,s]=useUncontrolled({value:e,defaultValue:o||a,finalValue:a,onChange:t}),c=useMantineTheme();return jsx(Select,{...r,data:i,value:l,onChange:s,styles:{...hM(c),...r?.styles},icon:jsx(IconLanguage,{size:"0.8rem",color:c.colors.blue[7]}),rightSection:n?jsx(Loader,{size:"0.8rem"}):jsx(IconChevronDown,{size:"0.8rem",color:c.colors.blue[7]})})}p();se();p();p();Uo();us();zu();p();zu();function Qt(e){let t=Number.parseInt(`${e||""}`,10);if(Number.isNaN(t)||!Number.isFinite(t))throw new $i(400,`Invalid numeric parameter: ${e}`);return t}function Ne(e){return e==null||e===""?[]:Array.isArray(e)?e:e.toString().split(",")}p();var Ir={ADMIN:"Admin",EDITOR:"Editor"};var{localeDefault:ni}=We();function lx(e){let t=Ne(e.locale)[0]||ni||"en",o=t==="all"||Yl(e.all),r=Ne(e.mode)[0],i=(Ne(e.output)[0]||"full")==="lite"?"lite":"full",a=parseInt(Ne(e.related)[0],10)||5,l=Yl(e.allowNulls,{default:false}),s=Ne(e.variant).map(Qt);if(s.length===0&&(s=Ne(e["variant[]"]).map(Qt)),r==="ids")return {all:o,mode:r,variant:s,output:i,locale:o?ni:Jt(t),ids:Ne(e.ids||e["ids[]"]),allowNulls:l};if(r==="content_ids")return {all:o,mode:r,variant:s,output:i,locale:o?ni:Jt(t),content_ids:Ne(e.content_ids||e["content_ids[]"]).map(Qt),allowNulls:false};if(r==="slugs")return {all:o,mode:r,variant:s,output:i,locale:o?ni:Jt(t),slugs:Ne(e.slugs||e["slugs[]"]).map(c=>{let[u,d]=c.split("/");return {variantSlug:u,memberSlug:d}}),allowNulls:false};if(r==="related")return {all:o,mode:r,locale:o?ni:Jt(t),related:a,current_ids:Ne(e.current_ids||e["current_ids[]"]).map(Qt),include_ids:Ne(e.include_ids||e["include_ids[]"]).map(Qt),report_ids:Ne(e.report_ids||e["report_ids[]"]).map(Qt),dimension_ids:Ne(e.dimension_ids||e["dimension_ids[]"]).map(Qt),variant_ids:Ne(e.variant_ids||e["variant_ids[]"]).map(Qt),output:i,allowNulls:false};if(r==="whole")return {all:o,mode:r,variant:s,locale:o?ni:Jt(t),output:i,allowNulls:l};throw new $i(400,`Invalid mode: '${r}'`)}function Ju(e){let t=Ne(e.locale)[0]||ni||"en",o=t==="all",r=Ne(e.format)[0],n=r?r==="nested":o,i=Ne(e.variant).map(Qt);i.length===0&&(i=Ne(e["variant[]"]).map(Qt));let a=Ne(e.dimension).map(Qt);a.length===0&&(a=Ne(e["dimension[]"]).map(Qt));let l=Ne(e.report).map(Qt);l.length===0&&(l=Ne(e["report[]"]).map(Qt));let s=e.origin==="typesense"?"typesense":"flexsearch";return {query:Ne(e.query||e.q)[0]||"",locale:o?ni:t,preferredLocale:Ne(e.preferredLocale)[0],limit:Ne(e.limit).map(Qt)[0]??5,format:n?"nested":"plain",includes:Yl(e.includes,{default:true}),visible:Yl(e.visible,{default:true}),noImage:Yl(e.noImage,{default:false}),variant:i,dimension:a,report:l,all:o,sort:Ne(e.sort)[0],direction:Ne(e.direction)[0],offset:Number(e.offset||0),origin:s}}se();p();ye();se();p();var CM={maxWidth:100,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function Jl({children:e,tooltip:t=false,onClick:o=()=>{},textProps:r={},clickable:n=false}){return jsx(Tooltip,{label:e,disabled:!t,children:jsx(UnstyledButton,{onClick:o,children:jsxs(Group,{spacing:"3px",align:"center",noWrap:true,children:[jsx(Text,{fz:"0.675rem",tt:"uppercase",fw:700,color:"gray.7",sx:CM,...r,children:e}),n&&jsx(ThemeIcon,{color:"gray.7",size:"1rem",bg:"transparent",variant:"default",sx:{border:"none"},children:jsx(IconChevronDown,{size:"xl"})})]})})})}Uo();p();var Qu=e=>t=>({input:{border:"none !important",outline:"none",background:t.colors.gray[1]},dropdown:{padding:0,background:t.fn.lighten(t.colors.gray[1],.8),borderColor:t.colors.gray[4],borderRadius:t.radius.md,width:"280px !important",gap:t.spacing.xs,":before":{display:"block",content:`"${e}"`,fontSize:t.fontSizes.xs,color:t.colors.gray[5],paddingLeft:t.spacing.sm,paddingRight:t.spacing.sm,paddingBottom:t.spacing.xs,paddingTop:t.spacing.xs}}});function DM(e,t,o){return o===t?e.map(r=>({id:r.id,value:`${r.id}`,name:r.name})):e.map(r=>{let n=r.contentByLocale.find(i=>i.locale===o);return {id:r.id,value:`${r.id}`,name:r.name,refName:n?n.name:null}})}var cx={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},_M=forwardRef(function({id:t,name:o,refName:r,...n},i){return jsxs(Group,{position:"apart",ref:i,...n,children:[jsxs(Stack,{spacing:0,children:[jsx(Text,{maw:"200px",sx:cx,children:o}),r&&jsx(Text,{fz:10,c:"#666",maw:"140px",sx:cx,children:r})]}),jsx(Text,{color:"gray.5",size:"sm",children:t})]},`${t}-${o}`)});function Sf(e){let{dimensionId:t,variantId:o,value:r,defaultValue:n,onChange:i,locale:a}=e,l=ie(),{localeDefault:s}=We(),c=os(),u=a||s,[d,f]=useState([]),[g,m]=useState(""),[h]=useDebouncedValue(g,500),[y,S]=useState(false),[v,C]=useState(false),[b,k]=useUncontrolled({value:r,defaultValue:n,finalValue:void 0,onChange:i?_=>i(_):void 0}),w=useRef(null),R=useClickOutside(()=>C(false)),O=useMergedRef(w,R),A=_=>{let P=d.find(I=>I.id===_.id);P&&(m(P.name?P.name:""),k(P),C(false));};useEffect(function(){S(true);let P={query:h,locale:u===c?u:"all",variant:[o],dimension:[t],limit:5,visible:false,includes:true,noImage:false,format:"plain",all:true,preferredLocale:c,report:[]};l(Z.searchMember(P)).then(I=>{if(I&&I.results){let F=I.results.map(M=>({...M,currentLocale:u,name:(M.contentByLocale&&M.contentByLocale.find(N=>N.locale===u)||M).name}));f(F),S(false),F.length===0&&h===""&&(f([]),S(false));}});},[l,h,u,o,t,c]),useEffect(()=>{d.length&&!b?.id&&i&&i(d[0]);},[d,i]);let B=DM(d,u,c);return useEffect(()=>{setTimeout(()=>{w.current&&w.current.focus();},200);},[v]),v||!b?.name?jsx(Autocomplete,{ref:O,value:g,onChange:m,data:B,itemComponent:_M,placeholder:"Search members.",nothingFound:"No members found.",rightSection:y&&jsx(Loader,{size:"xs"}),filter:()=>true,onItemSubmit:A,size:"xs",w:130,styles:Qu("Members")}):jsx(Jl,{onClick:()=>C(true),textProps:{color:"gray.6"},tooltip:true,clickable:true,children:b.name})}p();se();function xf(e){let o=Zi(e).data,r=Ul(o?.variants);return r.isSuccess?r.data.map(n=>({value:`${n.id}`,label:n.name})):[]}function Tf(e){let{dimension:t,value:o,onChange:r}=e,[n,i]=useState(false),a=xf(t),l=useClickOutside(()=>i(false)),s=a.length===1||!n,[c,u]=useUncontrolled({value:o?String(o):void 0,defaultValue:a[0]?a[0].value:"",finalValue:void 0,onChange:r?g=>r(Number(g)):void 0}),d=g=>u(g),f=a.find(g=>g.value===c)||a[0];return s?jsx(Jl,{onClick:()=>i(true),clickable:a.length>1,children:f?f.label:"No Variant"}):jsx(Select,{ref:l,data:a,value:c,onChange:d,w:140,size:"xs",styles:Qu("Variants"),initiallyOpened:true})}function ep(e){let{dimensionId:t,locale:o,onSelect:r,value:n}=e,i=ie(),a=xf(t),[l,s]=useUncontrolled({defaultValue:n?{id:`${n.memberId}`}:void 0,finalValue:void 0,onChange:r?f=>r(f):void 0}),[c,u]=useUncontrolled({value:void 0,defaultValue:n?.variantId,finalValue:a[0]?Number(a[0].value):0,onChange:()=>{s({});}}),d=n?.memberId;return useEffect(function(){d&&i(Z.readMember(lx({locale:o,content_ids:[`${d}`],all:"false",mode:"content_ids"}))).then(g=>{if(g&&g.results&&g.results[0]){let m=g.results[0];s({...m});}else console.error("default member is not found");});},[d]),jsxs(Flex,{gap:"xs",px:"xs",align:"center",children:[jsx(Tf,{dimension:t,value:c,onChange:u},`dimension-${t}`),jsx(Text,{fz:"xs",tt:"uppercase",color:"gray.6",fw:700,children:"/"}),c&&jsx(Sf,{variantId:c,dimensionId:t,value:l,onChange:s,locale:o},`variant-${c}`)]})}Pt();ye();st();function Ef({report:e,defaultMembers:t,locale:o}){let[r,n]=useState(false),i=ie(),a=Xt(),l=useContext(De),s=At(l),c=e&&e.dimensions?e.dimensions:[],u=H(h=>h.status.previews),d=u.map(h=>({variantId:h.variant_id,memberId:h.content_id})),f=a.query.preview,g=Array.isArray(f)?f.join("!"):f||"",m=h=>{let S=e.dimensions.map(C=>{let b;if(h)if(h.dimension_id===C)b=h;else {let k=u.find(w=>w?w.dimension_id===C:false);k&&(b=k);}return b}).map(C=>C?{...C,report_name:C.report?.name||C.report_name,report_id:C.report?.id||C.report_id,dimension_id:C.dimension?.id||C.dimension_id,dimension_name:C.dimension?.name||C.dimension_name,variant_id:C.variant?.id||C.variant_id,variant_name:C.variant?.name||C.variant_name,variant_slug:C.variant?.slug||C.variant_slug}:{}),v=S.map(JM).join("!");if(v&&g!==v){let C=S.filter(b=>b.content_id).length===c.length;i(Z.setPreviews(S)),C&&(a.setSearchParam("preview",v),s({previews:S}));}};return useEffect(function(){let y=g.split("!").filter(Boolean);y.length===c.length&&c.length>0?i(Z.readMember({mode:"slugs",slugs:y.map(S=>{let[v,C]=S.split("/");return {variantSlug:v,memberSlug:C}}),locale:o,output:"full"})).then(S=>s({previews:S.results})).then(()=>n(true)):t&&t.length===c.length?i(Z.readMember({mode:"content_ids",variant:t.map(S=>S.variantId),content_ids:t.map(S=>S.memberId),locale:o,output:"full"})).then(S=>s({previews:S.results})).then(()=>n(true)):n(true);},[]),jsx(Group,{spacing:"xs",children:r&&c.map((h,y)=>jsxs(Fragment$2,{children:[jsx(Text,{fw:700,fz:"xs",children:"/"}),jsx(ep,{dimensionId:h,onSelect:m,value:d[y]?d[y]:void 0,locale:o},h)]},h))})}function JM(e){return `${"variant_slug"in e?e.variant_slug:e?.variant?.slug}/${e.slug}`}p();se();p();se();p();p();Xn();p();Tu();var Ql="dimension",mx="Dimension";p();var wf="formatter",hx="Formatter";p();Xn();Tu();Em();p();var Rf="variant",bx="Variant";p();var If="datasource",vx="Data Source";var Sx={[Cu]:zv,[Ql]:mx,[wf]:hx,[Ni]:Mv,[Ol]:Dv,[Rf]:bx,[If]:vx};se();function ir({id:e,type:t,warning:o,disabled:r=false}){let n=useDispatch(),{newConfirmation:i}=Kt(),a=useCallback(async()=>{let l=Sx[t]||"Entity",s=o||`Delete this ${l} and all its contents? This action cannot be undone.`;try{r||(await i({title:"Are you sure?",message:s,confirmText:"Yes, Delete it."}),n(Z.deleteEntity(t,e)));}catch{console.error(`${l} deletion aborted:`,e);}},[e,t,o,r,n]);return jsx(ActionIcon,{disabled:r,color:"red",variant:"transparent",onClick:a,children:jsx(IconTrash,{size:18})})}p();var ds=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});function bB({for:e,onEdit:t}){let o=useMantineTheme(),{newConfirmation:r}=Kt(),n=o.colorScheme==="dark"?o.colors.dark[1]:o.colors.gray[7],i=useCallback(async()=>{try{await r({title:"Are you sure?",message:"Modifying dimensions can be destructive and break the site. Make sure you know what you're doing!",confirmText:"Continue"}),t(e.id);}catch{console.error("Dimension edition aborted.");}},[t]),{name:a,ordering:l}=e;return jsxs(Card,{shadow:"xs",withBorder:true,style:{margin:o.spacing.sm},children:[jsx(Group,{position:"apart",children:jsxs(Center,{children:[jsx(IconDatabase,{size:22}),jsx(Space,{w:"xs"}),jsx(Text,{weight:"bold",children:a})]})}),jsxs(Text,{size:"sm",style:{color:n,lineHeight:2},children:["Order:",l]}),jsx(Space,{w:"xs"}),jsxs(Group,{position:"apart",children:[jsxs(Center,{children:[jsx(IconServer,{size:22}),jsx(Space,{w:"xs"}),jsx(Text,{weight:"bold",children:"Variants"})]}),jsx(Badge,{variant:"light",children:e.variants.length})]}),jsx("ul",{children:e.variants.map(s=>jsx("li",{style:{color:n},children:jsx(vB,{id:s})},s))}),jsxs(Group,{position:"apart",children:[jsx(Button,{onClick:i,leftIcon:jsx(IconPencil,{}),compact:true,children:"Edit"}),jsx(ir,{id:e.id,type:"dimension",warning:"Deleting dimensions can be destructive and break the site. Make sure you know what you're doing!"})]})]})}var Cx=Yt(bB,Zi);function yB({for:e}){let t=ds(e.settings);return jsx(Text,{size:"sm",children:`${e.name}: /${e.slug} - Order: ${t.order}`})}var vB=Yt(yB,ea);p();Hr();se();p();function fs(e){let{target:t,fields:o,onSubmit:r}=e,[n,i,a]=LB(o||[]),[l,s]=useDisclosure(false,{onClose:a}),c=useCallback(u=>{l&&(u.preventDefault(),typeof r=="function"&&r(i),s.close());},[i,l]);return useHotkeys([["enter",c]]),n.length===0?t:jsxs(Popover,{onClose:s.close,opened:l,position:"right",trapFocus:true,withArrow:true,withinPortal:true,zIndex:1001,children:[jsx(Popover.Target,{children:wn__default.cloneElement(e.target,{onClick:s.open})}),jsx(Popover.Dropdown,{children:jsxs("form",{onSubmit:c,children:[n,jsx(Button,{type:"submit",children:"Submit"})]})})]})}function LB(e){let[t,o]=useState({}),r=e.map(a=>encodeURIComponent(`${a.name}:${a.type}/${a.label}`)).join("&"),n=useCallback(()=>{o({});},[]);return [useMemo(()=>e.map(a=>{let l=`${t[a.name]??(a.initialValue||"")}`;return a.type==="checkbox"?jsx(Checkbox,{label:a.label,name:a.name,checked:l=="true"},a.name):a.type==="radio"?jsx(Radio.Group,{label:a.label,value:l,children:a.options.map(s=>jsx(Radio,{label:s.label,value:`${s.value}`},s.label))},a.name):a.type==="select"?jsx(Select,{data:a.options.map(s=>({value:`${s.value}`,label:s.label})),label:a.label,onChange:s=>{o({...t,[a.name]:s});},value:l,zIndex:1002},a.name):a.type==="switch"?jsx(Switch,{label:a.label,name:a.name,checked:l=="true"},a.name):a.type==="text"?jsx(TextInput,{label:a.label,onChange:s=>{o({...t,[a.name]:s.target.value});},placeholder:a.placeholder,value:l},a.name):null}),[r,t]),t,n]}p();se();function $B({for:e,onEdit:t}){let o=useMantineTheme(),{newConfirmation:r}=Kt(),n=useCallback(async()=>{try{await r({title:"Are you sure?",message:"Modifying variants can be destructive and break the site. Make sure you know what you're doing!",confirmText:"Continue"}),t(e.id);}catch{console.error("Variant edition aborted.");}},[t]),{slug:i,name:a,settings:l}=e,s=ds(l);return jsxs(Card,{shadow:"xs",withBorder:true,style:{margin:o.spacing.sm},children:[jsxs(Group,{position:"apart",children:[jsxs(Center,{children:[jsx(IconServer,{size:22}),jsx(Space,{w:"xs"}),jsx(Text,{weight:"bold",children:a}),jsxs(Text,{size:"xs",ml:"xs",children:["Order: ",s.order]})]}),jsxs(Badge,{variant:"light",children:["/",i]})]}),jsx(Space,{h:"xs"}),jsxs(Group,{position:"apart",children:[jsx(Button,{onClick:()=>n(),leftIcon:jsx(IconPencil,{}),compact:true,children:"Edit"}),jsx(ir,{id:e.id,type:"variant",warning:"Deleting variants can be destructive and break the site. Make sure you know what you're doing!"})]})]})}var Ox=Yt($B,ea);p();Bm();p();var UB=e=>e.replace(/^\s+|\s+$/gm,"").replace(/[^a-zA-ZÀ-ž0-9- _]/g,""),op=UB;se();ys();p();function Ao({content:e,buttons:t,size:o}){let[r,n]=useState(500);return useEffect(()=>{let{innerHeight:i}=window;n(i-o);},[]),jsxs("div",{style:{height:"100%"},children:[jsx(ScrollArea,{offsetScrollbars:true,type:"always",style:{height:r},styles:{viewport:{"& > div:first-of-type":{display:"block !important"}}},children:e}),jsx(Space,{h:"xs"}),jsx(Divider,{}),jsx(Group,{mt:"xs",grow:true,style:{height:45},children:t})]})}p();p();function iD({member:e,height:t="auto",width:o="100%",size:r="thumb",forceRefreshTimestamp:n=false}){let i="";n&&(i=`&t=${new Date().getTime()}`);let a=e&&e.image_id?`/api/cms/member/image?member=${e.content_id}&size=${r}${i}`:"https://placehold.jp/cccccc/ffffff/900x600.png?text=None";return jsx(Image,{alt:`Image for ${e.id}`,height:t,width:o,radius:"md",src:a})}var Zl=iD;se();function vs({members:e,onClickEdit:t,onSort:o,colsToRender:r=[],dataTableProps:n={}}){let[i,a]=useState([]),[l,s]=useState([]),{state:c,...u}=n;useEffect(()=>{typeof o<"u"&&i&&i.length&&o(i);},[i]),useEffect(()=>{s(e);},[e]),useEffect(()=>{s(e);},[]);let d=H(m=>m.status.localeDefault),f=jsx(Badge,{color:"gray",children:"None"}),g=[{header:"",accessorKey:"visible",enableResizing:false,enableSorting:false,size:10,Cell:({row:m})=>jsx(Fragment,{children:m.original.visible?jsx("span",{}):jsx(Tooltip,{label:"Visible: false",children:jsx("span",{children:jsx(IconEyeOff,{size:20})})})})},{header:"ID",accessorKey:"id",enableSorting:typeof o<"u",mantineTableHeadCellProps:{align:"right",sx:{"& .mantine-TableHeadCell-Content-Labels":{flexDirection:"row"}}},mantineTableBodyCellProps:{align:"right"},size:100},{header:"Report",accessorKey:"report.name",enableSorting:false,size:100},{header:"Dimension",accessorKey:"dimension.name",enableSorting:false,size:100},{header:"Variant",accessorKey:"variant.name",enableSorting:false,size:100},{header:"Relevance",accessorKey:"zvalue",enableSorting:typeof o<"u",size:100},{header:"Slug",accessorKey:"slug",Cell:({row:m})=>jsxs("span",{children:["/",m.original.variant.slug,"/",m.original.slug]}),enableSorting:false},{header:`Name ${d.toUpperCase()}`,accessorKey:"name",enableSorting:typeof o<"u",Cell:({row:m})=>{let h=m.original.contentByLocale.find(v=>v.locale===d),y=m.original.contentByLocale.filter(v=>v.locale!==d),S=y.reduce((v,C)=>{let b=`${C.locale.toUpperCase()}: ${C.name}`;return `${v}${v!==""?`
47
+ `:""}${b}`},"");return jsxs(Group,{children:[jsx("span",{children:h?.name||f}),y.length>0&&jsx(Tooltip,{label:S,children:jsxs(Avatar,{size:"sm",color:"pink",radius:"xl",children:["+",y.length]})})]})}},{header:`Keywords ${d.toUpperCase()}`,accessorKey:"keywords",Cell:({row:m})=>{let h=m.original.contentByLocale.find(C=>C.locale===d),y=m.original.contentByLocale.filter(C=>C.locale!==d),S=(h.keywords?h.keywords:[]).map(C=>jsx(Badge,{children:C},C)),v=y.reduce((C,b)=>{let k=b.keywords||[],w=`${b.locale.toUpperCase()}: ${k.length>0?k.join(","):"None"}`;return `${C}${C!==""?`
48
+ `:""}${w}`},"");return jsxs(Group,{children:[jsx("span",{children:S.length>0?S:f}),y.length>0&&jsx(Tooltip,{label:v,children:jsxs(Avatar,{size:"sm",color:"pink",radius:"xl",children:["+",y.length]})})]})},enableSorting:false,size:100},{header:"Image",accessorKey:"image",Cell:({row:m})=>jsx(Zl,{member:m.original,height:"50px",forceRefreshTimestamp:true}),enableSorting:false,size:80},{header:"",accessorKey:"actions",Cell:({row:m})=>jsx(ActionIcon,{onClick:()=>t?t(m.original):false,children:jsx(IconPencil,{size:20})},"edit"),enableResizing:false,enableSorting:false,size:50,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}];return jsx(MantineReactTable,{columns:g.filter(m=>r&&r.length===0||r.includes(m.accessorKey)),data:l,enableBottomToolbar:false,enableColumnActions:false,enableColumnResizing:true,enablePagination:false,enableStickyHeader:true,enableTopToolbar:false,initialState:{density:"xs"},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150,maxHeight:"90vh"}},mantineTableProps:{striped:true},manualSorting:true,onSortingChange:a,state:{sorting:i,...c},...u})}p();function bD({switchProps:e,yesText:t,noText:o}){let r={size:"md",onLabel:"YES",offLabel:"NO",label:"Switch Label",my:"xs",checked:false,onChange:n=>console.info(n.currentTarget.checked),...e};return jsxs(Group,{children:[jsx(Switch,{...r}),jsx(Tooltip,{label:r.checked?t:o,withArrow:true,multiline:true,width:200,children:jsx(ActionIcon,{variant:"filled",radius:"50%",size:"xs",children:jsx(IconQuestionMark,{size:"xs"})})})]})}var tc=bD;p();function Ss(e){try{return new URL(e),!0}catch{return false}}function OD({for:e,onClose:t}){let o=ie(),r=H(X=>X.status.localeDefault),n=H(X=>X.status.locales),i=n.map(X=>({value:X,label:X.toUpperCase()})),[a,l]=useState(),[s,c]=useState(r),[u,d]=useState(()=>{let X={...e};return n.forEach(le=>{X.config={...X.config,[le]:{attributes:[],idKey:"",labelKey:"",accessor:"",path:"",...X.config[le]||{}}};}),X}),[f,g]=useState(false),[m,h]=useState(false),[y,S]=useState(false),[v,C]=useState(false),[b,k]=useState({valid:false,suggestion:""}),[w,R]=useState(),[O,A]=useState([]),[B,_]=useState(false),[P,I]=useState([]),F=X=>{Ss(X)&&(h(true),o(Z.urlProxy({url:X})).then(le=>{if(R(le),le){let de=tS(le);A(de),u.config[s].accessor&&le[u.config[s].accessor]?N(le[u.config[s].accessor][0],u.config[s].accessor):de.length===0&&le&&le[0]&&N(le[0]);}S(false),h(false);}).catch(le=>{console.error(le),S(`Fetch error: ${le.message}`),R(void 0),h(false);}));},M=X=>{_(true);let le=Ju({variant:X,limit:"5",locale:"all",visible:"true",includes:"true",noImage:"false",format:"plain"});o(Z.searchMember(le)).then(de=>{if(de&&de.results){let Ce=de.results;I(Ce),Ce.length===0&&Y("doIngest",true);}_(false);}).catch(de=>{console.error(de),_(false);});},N=(X,le="")=>{if(X){let de=Object.keys(X),Ce=de.find(Ue=>Ue.toLowerCase().includes("id"))||de[0],$e=de.find(Ue=>!Ue.toLowerCase().includes("id"))||de[0];(!u.config[s].idKey||u.config[s].idKey===""||!u.config[s].labelKey||u.config[s].labelKey==="")&&d({...u,config:{...u.config,[s]:{...u.config[s],idKey:Ce,labelKey:$e,accessor:le}}});}l(X);};useEffect(()=>{u.id&&M(u.id),q(u.slug),u.config[s]&&u.config[s].path&&F(u.config[s].path);},[]);let j=X=>{R(void 0),S(false);let le=[];if(X!==r){let de=u.config[r]?[...u.config[r].attributes].map($e=>{let Ue={...$e};return Ue.value="",Ue}):[];u.config[X]&&u.config[X].attributes?le=de.map($e=>{let Ue=u.config[X].attributes.find(Qe=>$e.name===Qe.name);return Ue&&($e.value=Ue.value),$e}):le=de;let Ce={...u.config,[X]:{...u.config[X],attributes:le}};d({...u,config:Ce});}u.config[X]&&u.config[X].path&&F(u.config[X].path),c(X);},$=useMemo(()=>ds(u.settings),[u.settings]),V=useMemo(()=>[{label:"Replace names",key:"overrideNames",yesText:"Names from new source will update the previously ingested members.",noText:"Original names will be keep."},{label:"Replace slugs",key:"regenerateSlugs",yesText:"Slugs will be regenerated based on new member's names and updated on previously ingested members.",noText:"Original slugs will be keep.",disabled:!$.overrideNames},{label:"Replace relevance value",key:"overrideRelevance",yesText:"Relevance index will be recalculated and updated on previously ingested members.",noText:"Original numbers will be keep."},{label:"Replace attributes",key:"overrideAttributes",yesText:"Attributes will be regenerated and override the current ones. Different ones will be kept.",noText:"Original attributes will be keep, ignoring the changes"},{label:"Keep all existing members",key:"keepOldMembers",yesText:"All the the existing members will be keep even if they are not in the new API members list",noText:"Members that are not in the API members list will be deleted, keeping both lists on sync."}],[$.overrideNames]),z=X=>{let le=Pu(w,X);le[0]&&N(le[0],X);},q=X=>{o(Z.variantValidateSlug(u.dimension_id,X)).then(k).then(()=>{C(false);},le=>{console.error(le);});},W=(X,le)=>{let de=le;X==="slug"&&(de=op(le),de&&(C(true),q(le))),d({...u,[X]:de});},U=(X,le)=>{X==="path"&&S(false),d({...u,config:{...u.config,[s]:{...u.config[s],[X]:le}}});},Y=(X,le)=>{let de=X==="overrideNames"&&!le?{regenerateSlugs:false}:{};d({...u,settings:{...u.settings,...de,[X]:le}});},ne=()=>{g(true),o(Z.updateEntity("variant",u)).then(()=>{g(false),t();}).catch(X=>{console.error(X),g(false);});},re=X=>{d({...u,config:{...u.config,[s]:{...u.config[s],attributes:X}}});},J=()=>{if(a&&Object.keys(a)[0]){let de=u.config[s]?.attributes||[],Ce=de.length||0;re([...de,{type:"constant",name:`attr${Ce+1}`,value:""}]);}},G=(X,le,de)=>{let Ce=u.config[s].attributes.map(($e,Ue)=>Ue===le?{...$e,[X]:de}:$e);re(Ce);},K=X=>{let le=u.config[s].attributes.filter((de,Ce)=>Ce!==X);re(le);},ee=a?Object.keys(a).map(X=>({value:X,label:`${X}: ${a[X]}`})):[],ae=O.map(X=>({value:X,label:X})),ue=!Ss(u.config[s].path),Te=useMemo(()=>y||(ue&&u.config[s].path!==""?"Format error: Invalid URL.":false),[y,ue,u.config,s]);return jsx(Ao,{content:jsxs(Fragment,{children:[jsx(Title,{order:2,children:`Editing Variant: ${u.name}`}),jsx(Space,{h:"xs"}),jsxs(Tabs,{defaultValue:"variant",children:[jsxs(Tabs.List,{grow:true,children:[jsx(Tabs.Tab,{value:"variant",children:"Variant"}),jsx(Tabs.Tab,{value:"members",children:"Members"})]}),jsxs(Tabs.Panel,{value:"variant",py:"md",children:[jsx(Title,{order:3,children:"Variant Settings"}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:u.name,label:"Name",onChange:X=>W("name",X.target.value)}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:u.slug,icon:!v&&!b.valid?jsx(IconAlertCircle,{}):jsx(IconCircleCheck,{}),label:"Slug",description:v?"Validating slug...":b.valid?"Valid slug.":"Invalid slug.",error:!v&&!b.valid?jsxs(Text,{children:["Duplicated slug. Suggestion:",jsx(Code,{onClick:()=>W("slug",b.suggestion),style:{cursor:"pointer"},children:b.suggestion})]}):false,onChange:X=>W("slug",X.target.value)}),jsx(Space,{h:"xs"}),jsx(NumberInput,{value:$.order||0,description:"It affects on explore options order",placeholder:"Order",label:"Order",onChange:X=>{Y("order",X);}})]}),jsxs(Tabs.Panel,{value:"members",py:"md",children:[jsx(Title,{order:3,children:"Members Settings"}),jsx(Text,{size:"sm",children:"Members, once ingested, become pages for this variant."}),jsx(tc,{switchProps:{label:`${!B&&P.length>0?"Re-":""}Ingest members`,checked:$.doIngest,onChange:X=>Y("doIngest",X.currentTarget.checked)},yesText:`Run the ingestion process and save the variant details.
49
+ Remember include the ingestion information for all the locales.`,noText:"Ingestion is not going to run and the current members are not going to suffer any change."}),$.doIngest&&!B&&P.length>0&&jsxs(Box,{ml:"lg",children:[jsx(Text,{size:"sm",children:"Settings that are going to be applied for members reingestions and for all available languages, matching by unique identificator. All new members are going to be ingested. Images and tags for existing members will be safe."}),V.map(X=>jsx(tc,{switchProps:{disabled:X.disabled,label:X.label,checked:$[X.key],onChange:le=>Y(X.key,le.currentTarget.checked)},yesText:X.yesText,noText:X.noText},X.key))]}),!$.doIngest&&jsxs(Fragment,{children:[jsx(Title,{order:2,size:"h4",children:"Ingested members preview"}),jsx(Space,{h:"xs"}),jsxs(Stack,{spacing:0,justify:"center",children:[B&&jsx(Loader,{m:"0 auto"}),!B&&P.length>0&&jsxs(Fragment,{children:[jsx(vs,{members:P,colsToRender:["id","name","slug"]}),jsx(CP,{href:"metadata",passHref:true,children:jsx(Text,{c:"dimmed",align:"center",td:"underline",size:"xs",children:"See the full list in Metadata View"})})]})]}),!B&&P.length===0&&jsx(Text,{c:"dimmed",align:"center",children:"No members ingested yet."}),jsx(Space,{h:"xs"})]}),$.doIngest&&jsxs(Fragment,{children:[jsx(Divider,{my:"sm"}),jsx(Title,{order:2,size:"h4",children:"Members ingestion"}),jsx(Space,{h:"xs"}),jsx(SegmentedControl,{value:s,fullWidth:true,onChange:j,data:i,disabled:m}),u.config[s]&&jsxs(Fragment,{children:[jsx(Space,{h:"lg"}),jsx(Group,{children:jsx(TextInput,{onChange:X=>U("path",X.target.value),title:"Api endpoint",description:"Enter the url to retrieve a member list to ingest. (JSON) and click Fetch.",value:u.config[s].path,error:Te,rightSectionWidth:"105px",w:"100%",rightSection:m?jsxs(Group,{align:"center",children:[jsx(Loader,{size:"xs"}),jsx(Text,{span:true,variant:"subtle",size:"xs",children:"Fetching..."})]}):jsx(Button,{disabled:m||ue,onClick:()=>F(u.config[s].path),leftIcon:jsx(IconPlayerPlay,{}),children:"Fetch"}),readOnly:m})}),w&&jsxs("div",{children:[jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].accessor,label:"Elements",description:`Choose the key that returns the array of elements that
50
+ are going to be ingested as members.`,data:ae,disabled:ae.length===0,placeholder:ae.length===0?"Root is an array":"",onChange:X=>z(X)}),jsx(Divider,{label:"First element preview",labelPosition:"center"}),w[u.config[s].accessor]&&!Array.isArray(w)&&jsx(Ar,{variables:w[u.config[s].accessor][0]}),Array.isArray(w)&&w[0]&&jsx(Ar,{variables:w[0]}),jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].idKey,label:"Unique identificator",description:"Choose the field that is a unique identification for a single member.",data:ee,onChange:X=>U("idKey",X)}),jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].labelKey,label:"Members' name",description:"Choose the field that contains the members name.",data:ee,onChange:X=>U("labelKey",X)}),jsx(Space,{h:"md"}),jsx(Select,{value:u.config[s].zValueKey||"",label:"Member's relevance (optional)",description:`Choose a field that will be converted to a number and
51
+ normalized from 0 to 1 to determine the member's relevance.`,data:[{value:"null",label:"None"},...ee],onChange:X=>U("zValueKey",X)}),jsx(Space,{h:"md"}),jsx(Title,{order:3,size:"h5",children:"Attributes"}),jsx(Text,{size:"sm",children:"Attributes are properties to be ingested as metadata with the member element. Could be constants (same value for every member) or dynamic (based on a property of the data)"}),jsx(Space,{h:"xs"}),u.config[s].attributes&&u.config[s].attributes.map((X,le)=>jsxs(Group,{align:"end",grow:true,children:[jsx(Select,{value:u.config[s].attributes[le].type,label:"Type",data:[{value:"variable",label:"Data based"},{value:"constant",label:"Constant"}],readOnly:s!==r,disabled:s!==r,onChange:de=>G("type",le,de)}),jsx(TextInput,{value:u.config[s].attributes[le].name,label:"Name",readOnly:s!==r,disabled:s!==r,onChange:de=>G("name",le,de.target.value)}),X.type==="variable"&&jsx(Select,{value:u.config[s].attributes[le].value,label:"Value",data:ee,onChange:de=>G("value",le,de)}),X.type==="constant"&&jsx(TextInput,{value:u.config[s].attributes[le].value,label:"Value",onChange:de=>G("value",le,de.target.value)}),jsx(ActionIcon,{color:"red",onClick:()=>K(le),disabled:s!==r,children:jsx(IconTrash,{size:20})})]},le)),jsx(Space,{h:"md"}),jsx(Button,{onClick:J,leftIcon:"+",disabled:f||s!==r,children:"Add Attribute"})]})]}),jsx(Space,{h:"md"})]})]})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{disabled:f||m||!v&&!b.valid,onClick:t,variant:"outline",children:"Cancel"}),jsx(Button,{disabled:f||m||!v&&!b.valid,loading:f||m,onClick:ne,children:`${$.doIngest?`${!B&&P.length>0?"Re-":""}Ingest & `:""}Save`})]}),size:165})}var Vx=Yt(OD,ea);function Kx({id:e,onClose:t}){let o=ie(),r=Zi(e),[n,i]=useState({id:e}),[a,l]=useState(null);useEffect(()=>{r.isSuccess&&i(r.data);},[r.status]);let s=useCallback(g=>{o(Z.createEntity("variant",{dimension_id:e,name:g.name,slug:xt(g.name)}));},[e]),c=useCallback(()=>{o(Z.updateEntity("dimension",{...n,id:e})).then(t);},[n]),u=useCallback((g,m)=>{i({...n,[g]:g==="slug"?xt(m):m});},[]);if(a)return jsx(Vx,{id:a,onClose:()=>l(null)});let d=r.isFetching,f=r.isSuccess?r.data.variants:[];return jsx(Ao,{content:jsxs(Fragment,{children:[jsx(Title,{order:2,children:`Dimension metadata: ${n.name}`}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:n.name,label:"Name",onChange:g=>u("name",g.target.value)}),jsx(Space,{h:"xs"}),jsx(NumberInput,{value:n.ordering?parseInt(`${n.ordering||0}`,10):0,type:"number",label:"Order",onChange:g=>u("ordering",g)}),jsx(Divider,{my:"xl"}),jsx(ls,{icon:jsx(IconServer,{size:22}),children:jsx(Title,{order:2,size:"h4",children:"Variants"})}),f.map(g=>jsx(Ox,{id:g,onEdit:l},g)),jsx(fs,{fields:[{name:"name",type:"text",label:"Add Variant"}],onSubmit:s,target:jsx(ActionIcon,{size:"xl",radius:"xl",children:jsx(IconCirclePlus,{size:30})})})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:d,loading:d,onClick:t,children:"Cancel"}),jsx(Button,{disabled:d,loading:d,onClick:c,children:"Save Dimension"})]}),size:165})}Hr();function eT({id:e,onClose:t}){let o=ie(),r=zt(e),[n,i]=useState({id:e}),[a,l]=useState(null);useEffect(()=>{r.isSuccess&&i(r.data);},[r.status]);let s=useCallback((S,v)=>{o(Z.createEntity("dimension",{report_id:e,name:S.name,ordering:v.length+1})).then(C=>{C.ok&&o(Z.createEntity("variant",{dimension_id:C.data.id,name:C.data.name,slug:xt(C.data.name)}));});},[e]),c=useCallback(()=>{o(Z.updateEntity("report",{...n,id:e})).then(t);},[e,n]),u=useCallback((S,v)=>{i({...n,[S]:v});},[]),d=(S,v)=>{i({...n,settings:{...n.settings,[S]:v}});};if(a)return jsx(Kx,{id:a,onClose:()=>l(null)});let f=r.isFetching,g=r.isSuccess?r.data.dimensions:[],m=n.settings,h=m&&typeof m.order=="number"?m.order:0,y=m&&typeof m.hide=="boolean"?m.hide:false;return jsx(Ao,{content:jsxs(Fragment,{children:[jsx(Title,{order:2,children:`Report metadata: ${n.name}`}),jsx(Space,{h:"xs"}),jsx(TextInput,{value:n.name,label:"Name",onChange:S=>u("name",S.target.value)}),jsx(Space,{h:"xs"}),jsxs(Group,{grow:true,children:[jsx(tc,{switchProps:{label:"Show in Explore & Search",checked:!y,onChange:S=>d("hide",!S.currentTarget.checked)},yesText:"Profile appears in Explore search and members are listed in search results",noText:"Profile is hidden in Explore search and members are not included in search results"}),jsx(NumberInput,{defaultValue:0,value:h,description:"It affects the Explore search options order",placeholder:"Order in Explore",label:"Order",disabled:y,onChange:S=>{d("order",S);}})]}),jsx(Divider,{my:"sm"}),jsx(ls,{icon:jsx(IconDatabase,{size:22}),children:jsx(Title,{order:2,size:"h4",children:"Dimensions"})}),jsx(Grid,{children:g.map(S=>jsx(Grid.Col,{span:6,children:jsx(Cx,{id:S,onEdit:l})},S))}),jsx(fs,{fields:[{type:"text",name:"name",label:"Add Dimension"}],onSubmit:(S=>s(S,g)),target:jsx(ActionIcon,{size:"xl",radius:"xl",children:jsx(IconCirclePlus,{size:30})})})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:f,loading:f,onClick:t,children:"Cancel"}),jsx(Button,{disabled:f,loading:f,onClick:c,children:"Save Report"})]}),size:165})}function iT(e){let{report:t}=e,{newConfirmation:o}=Kt(),{selectEntity:r}=qt(),n=useContext(De),i=At(n),a=ie(),l=H(V=>V.status.previews),s=Xt(),c=Number.parseInt(s.params[0]),u=zt(c),d=es(),f=VS(),g=mf(),m=H(V=>V.status.localeDefault),h=Ft("settings"),y=Ft("reportEditor"),S=Ft("tools"),v=Ft("debugView"),C=cs(c),b=t&&t.dimensions?t.dimensions:[],k=b.length>0,w=l.filter(V=>V.variant_slug).reduce((V,z)=>V.concat([z.variant_slug,z.slug]),[]),R=g===m?"":`/${g}`,O=f||d,A=w.length?`${R}${O}/${w.join("/")}`:"",B=w.length?`${R}${d}/${w.join("/")}`:"",[_,P]=useState(null),I=useMemo(()=>{let V=[];return A&&f&&V.push({value:"preview",label:"Open Preview",url:A,Icon:IconFileCode}),B&&V.push({value:"report",label:"Open Report",url:B,Icon:IconFileAnalytics}),V},[A,B,f]);useEffect(()=>{!_&&I.length>0&&P(I[0].value);},[I,_]);let F=useMemo(()=>I.find(V=>V.value===_)||null,[I,_]),M=useCallback(()=>{F?.url&&window.open(F.url,"_blank","noopener,noreferrer");},[F]),N=useCallback(V=>{P(V);},[]),j=V=>{s.setSearchParam("locale",V),a(Z.readMember({mode:"content_ids",variant:l.map(z=>z.variant_id),content_ids:l.map(z=>z.content_id),locale:V,output:"full"})).then(({results:z})=>{a(Z.setCurrentLocale(V)),z&&z.length===b.length&&b.length?i({previews:z}):i({previews:[]});});},$=useCallback(async()=>{try{let V=B;await o({title:"Are you sure?",message:`Revalidate action will force to regenerate page: ${V}.`,confirmText:"Revalidate now!"}),await a(Z.revalidateUrl({target:V})).then(z=>{let q=`Revalidated page ${z.target} you will see the changes in the following minutes.`;notifications.show({autoClose:!1,color:"green",id:"revalidate-results",message:q,title:"Revalidate Results"});}).catch(z=>{notifications.show({autoClose:!1,color:"red",id:"revalidate-error",message:z.message,title:"Revalidate Error"});});}catch{console.error("Revalidate error.");}},[A,B,f]);return jsxs(Fragment,{children:[jsx(sx,{left:jsxs(Group,{children:[jsx(ActionIcon,{color:"blue",variant:"filled",onClick:()=>{r({type:"report",id:t.id}),h.handlers.open();},children:jsx(IconSettingsFilled,{size:20})}),jsx(ql,{value:g,onChange:j,selectProps:{size:"xs",maw:80}}),jsx(SegmentedControl,{size:"xs",radius:"sm",sx:V=>({background:V.colors.blue[0]}),data:[{label:"Editor",value:"editor"},{label:"Debug",value:"debug"}],onChange:V=>{V==="editor"?v.handlers.close():(S.handlers.close(),y.handlers.close(),h.handlers.close(),v.handlers.open());}})]}),center:jsxs(Group,{children:[jsx(Ef,{report:t,defaultMembers:C?.map(V=>({variantId:V.variantId,memberId:V.contentId})),locale:g}),(A||B)&&I.length>0&&jsxs(Group,{spacing:0,children:[jsx(Button,{onClick:M,disabled:!F,variant:"light",fw:700,radius:"sm",fz:12,pr:10,pl:5,mih:"1.875rem",compact:true,leftIcon:F?.Icon?jsx(F.Icon,{size:14}):null,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:F?.label||"Select view"}),jsxs(Menu,{position:"bottom",withArrow:true,children:[jsx(Menu.Target,{children:jsx(ActionIcon,{variant:"light",radius:"sm",sx:V=>({borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid #fff",backgroundColor:"#e7f5ff",minHeight:"1.875rem",height:"1.875rem",width:"1.875rem",fontSize:"12px"}),children:jsx(IconChevronDown,{size:14,color:"#228be6"})})}),jsx(Menu.Dropdown,{children:I.map(V=>{let z=V.Icon;return jsx(Menu.Item,{onClick:()=>N(V.value),icon:z?jsx(z,{size:20}):null,children:V.label},V.value)})})]})]})]}),right:jsxs(Group,{children:[l.length>0&&_!=="preview"&&jsx(Button,{variant:"light",fw:700,radius:"sm",fz:12,pr:10,pl:5,mih:"1.875rem",onClick:$,leftIcon:jsx(IconWorldUpload,{size:14}),compact:true,children:"Publish"}),!k&&jsx(Button,{size:"xs",variant:"outline",onClick:y.handlers.open,children:"Import Data"})]})}),jsx(Drawer,{opened:y.opened,onClose:y.handlers.close,title:jsx(ls,{icon:jsx(IconFileAnalytics,{size:24}),children:`Editing Report: ${u.data?u.data.name:""}`}),size:"50%",padding:"xl",position:"right",children:jsx(eT,{id:c,onClose:y.handlers.close})})]})}p();p();p();se();he();function a_({type:e,id:t,warning:o=""}){let r=Gv[e]||"Entity",n=o||`Delete this ${r} and all its contents? This action cannot be undone.`,i=useDispatch(),{newConfirmation:a}=Kt();return jsx(ActionIcon,{color:"red",onClick:async()=>{try{await a({title:"Are you sure?",message:n,confirmText:"Yes, Delete it."}),i(Z.deleteEntity(e,t));}catch{}},children:jsx(IconTrash,{size:20})})}var sT=a_;ic();p();se();p();he();p();Vr();ye();var ST=e=>!e||e.trim()===""?false:e.trim().startsWith("/")?true:Ss(e);function V_({defaultValue:e,id:t,onChangeAPI:o,onDelete:r,finalUrl:n,dataSource:i,pos:a}){let l=Io(),s=Ku(t),[c,u]=useState(()=>et(e,l,s)),[d,f]=useState(e),[g,m]=useState(false),h=A=>{g&&!R&&(A.preventDefault(),o(d),m(false));},y=A=>{let{value:B}=A.target;u(et(B,l,s)),f(B);},S=()=>{m(false),u(et(e,l,s));},v=()=>{m(!g);},C=()=>{r();},b=useMemo(()=>(c||"").indexOf("bespoke_slugs=")>-1,[c]),k=useMemo(()=>!(c&&(c.trim()===""||ST(c))),[c,ST]),w=useMemo(()=>c.includes("N/A"),[c]),R=useMemo(()=>k||w,[k,w]),O=useMemo(()=>{let A=[];return k&&A.push("Invalid URL format"),w&&A.push("URL contains 'N/A', probably you are using a variable that is not in scope"),A.join(". ")},[k,w]);return jsxs(Stack,{spacing:0,p:g?"xs":0,mb:g?3:0,bg:g?"gray.0":"transparent",children:[jsxs(Group,{noWrap:true,position:"apart",spacing:"xs",children:[jsxs(Text,{lineClamp:1,size:"xs",children:[a,". ",jsx(Anchor,{href:n||c,target:"_blank",rel:"noreferrer",children:n||c||"--Add API Url--"})]}),jsx(Group,{noWrap:true,spacing:0,children:g?jsxs(Fragment,{children:[jsx(Tooltip,{label:R?"Invalid URL format":"Apply changes",children:jsx(ActionIcon,{size:"md",onClick:h,color:"green",sx:{opacity:R?.4:1},children:jsx(IconCheck,{size:rem(20)})})}),jsx(ActionIcon,{size:"md",onClick:S,color:"red",children:jsx(IconX,{size:rem(20)})})]}):jsxs(Fragment,{children:[b&&jsx(Tooltip,{multiline:true,label:"Slugs Interceptor Enabled",children:jsx(IconGitMerge,{size:rem(18),color:"gray"})}),i&&jsx(Tooltip,{multiline:true,label:`Datasource Interceptor Enabled called "${i}"`,children:jsx(IconNetwork,{size:rem(18),color:"gray"})}),w&&jsx(Tooltip,{multiline:true,label:"API URL contains 'N/A', probably you are using a variable that is not in scope",children:jsx(IconAlertTriangle,{size:rem(20),color:"red"})}),jsx(ActionIcon,{size:"md",onClick:v,children:jsx(IconPencil,{size:rem(20)})}),jsx(ActionIcon,{size:"md",onClick:C,children:jsx(IconTrash,{color:"red"})})]})})]}),g&&jsx(Stack,{spacing:"xs",children:jsx(Textarea,{placeholder:"API URL here: https://api.example.com/v1/data?id={{id1}}",defaultValue:d,onChange:y,onKeyDown:getHotkeyHandler([["enter",h]]),size:"sm",minRows:2,maxRows:6,autosize:true,sx:{width:"100%"},error:R?`${O} ${c}`:false},"textarea")})]})}var TT=V_;p();function W_({monacoOptions:e}){let t=useMonaco();return useEffect(()=>{if(t){let o="Monokai";import(`monaco-themes/themes/${o}.json`).then(r=>{t.editor.defineTheme(o,r),t.editor.setTheme(o);}).catch(()=>{throw new Error("Invalid Monaco theme")});}},[t]),jsx(Box,{className:"cr-monaco-container",w:"100%",children:jsx(U_,{defaultLanguage:"javascript",theme:"Monokai",...e})})}var ca=W_;p();Ho();Bs();Xf();Bs();he();se();ye();bn();Vr();Ka();st();Jn();Cr();Xe();Dh();p();bn();Cr();he();Jn();function vH({status:e,block:t,variables:o}){let{settings:r,contentByLocale:n}=t,i=!!(r&&r.useProxy&&r.useProxy==="true"),a=n?.logic?.content?.api&&n.logic.content.api!==""?n.logic.content.api.split("|||").length:0,l=e&&e.apiDataSources?e.apiDataSources.some(g=>g!==false):false,s=useMemo(()=>e.apiFinalUrls?typeof e.apiFinalUrls=="string"?e.apiFinalUrls.includes("N/A")?1:0:Array.isArray(e.apiFinalUrls)?e.apiFinalUrls.filter(g=>g.includes("N/A")).length:0:0,[e.apiFinalUrls]),c=!!([E.GENERATOR,E.SECTION_FLAG].includes(t.type)&&e.api&&e.api.indexOf("bespoke_slugs=")>-1),u=mo(t),d=u?o[Eo]:false,f=[E.GENERATOR,E.SECTION_FLAG].includes(t.type)&&o?JSON.stringify(o).length/1024:void 0;return jsxs(Group,{spacing:5,children:[jsx(Tooltip,{multiline:true,label:`Number of requests: ${a}`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(Text,{size:rem(12),span:true,fw:"bold",children:a})})}),s>0&&jsx(Tooltip,{multiline:true,label:`${s} of your URLs in this generator contains 'N/A', probably you are using a variable that is not in scope`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"orange",children:jsx(IconAlertTriangle,{size:rem(12)})})}),i&&jsx(Tooltip,{multiline:true,label:`Use Proxy Setting (avoid CORS): ${i?"YES":"NO"}`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(IconCloudNetwork,{size:rem(12)})})}),l&&jsx(Tooltip,{multiline:true,label:"Data Source Interceptor Active at least in one request",children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(IconNetwork,{size:rem(12)})})}),c&&jsx(Tooltip,{multiline:true,label:"Slugs Interceptor Enabled at least in one request",children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:"blue",children:jsx(IconGitMerge,{size:rem(12)})})}),e.duration&&jsx(Tooltip,{multiline:true,label:`Api Call Duration: ${e.duration} ms`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:uS(e.duration),children:jsx(IconClockHour2,{size:rem(12)})})}),e.responseSize&&jsx(Tooltip,{multiline:true,label:`Api Response Size: \u2248${e.responseSize.toFixed(2)} Kb`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:Nm(e.responseSize),children:jsx(IconApi,{size:rem(12)})})}),f&&jsx(Tooltip,{multiline:true,label:`Block Output Size: \u2248${f.toFixed(2)} Kb`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:Nm(f),children:jsx(IconAugmentedReality,{size:rem(12)})})}),u&&jsx(Tooltip,{multiline:true,label:`Section #${t.section_id} Allowed Flag: ${d?"YES":"NO"}`,children:jsx(ThemeIcon,{size:"sm",radius:"xl",color:d?"green":"red",children:jsx(IconFlag,{size:rem(12)})})})]})}var Yp=vH;var Xp={api:null,duration:null,error:null,log:[],responseSize:null,resp:null,allowed:true};function OH({block:e,status:t,sectionFlag:o,variables:r}){let n=useMemo(()=>o?jsx(ThemeIcon,{variant:"filled",radius:"xl",size:"sm",color:"orange",children:jsx(IconFlag,{size:"0.8rem"})}):jsx(ThemeIcon,{variant:"filled",radius:"xl",size:"sm",color:"yellow",children:jsx(IconBraces,{size:"0.8rem"})}),[o]);return jsxs(Fragment,{children:[jsxs(Group,{position:"left",pt:"xl",children:[jsxs(Group,{children:[n,jsxs(Title,{order:6,children:[Bh[e.type]," ",e.id]})]}),jsx(Group,{my:"xs",children:jsx(Yp,{status:t,block:e,variables:r})})]}),jsx(Divider,{})]})}function LH(e){let{active:t,allowed:o,blockStateContent:r,blockStateSettings:n,debug:i,for:a,locale:l,isFetching:s}=e,c=ot(a.id),u=Io(),d=vn(),f=Ku(a.id,l),g=H(F=>F.variables.variables[a.id]||{}),m=H(F=>F.variables.status[a.id]||{}),h=Ms[a.type].renderPreviewOnEdit&&r?r:ko(a,l),y=Ms[a.type].renderPreviewOnEdit&&n?n:a.settings,[S,v]=useState(null),[C,b]=useState(Xp),k=mo(a),w=wr(),R=we();useEffect(()=>{(async()=>{if(a.type===E.VIZ){v({block:a,locale:l,variables:c,active:t}),b(Xp);return}if(!t&&!Ms[a.type].evalWhenNonActive){let{nonActiveAdapter:z}=Ms[a.type],q=z&&typeof z=="function"?z():{};v(q),b(Xp);return}if([E.GENERATOR,E.SECTION_FLAG].includes(a.type)){let z=!!a.contentByLocale?.logic?.content?.api,q=k?g[Eo]:false;v({outputVariables:g,hasAPI:z,sectionAllowed:q,type:a.type}),b(m);return}if([E.SELECTOR,E.MULTIHIERARCHY_SELECTOR].includes(a.type)){let{renderVariables:z,status:q}=await Ll(a,u,f,w,d,R),W=sr[a.type]&&typeof sr[a.type]=="function"?sr[a.type](z,a.id):z;v(W),b(q);return}if(a.type===E.RELATED){let{outputVariables:z}=await Ll(a,u,f,w,d,R),{related_reports:q}=z;v({related_reports:q});return}if(a.type===E.RESET_BUTTON||a.type===E.COMPARISON_BUTTON){v(h.simple||{});return}let M=et(h?.logic,u,f),{vars:N,error:j,log:$}=Fr("variables",c,M,u,void 0,f),V=sr[a.type]&&typeof sr[a.type]=="function"?sr[a.type](N,a.id):N;if(a.type===E.NAV){v({headings:a.inputs,settings:a.settings,...V});return}v(V),b({...Xp,error:j,log:$});})();},[h,c,k]),useEffect(()=>{m&&m.error&&m.error!==""&&notifications.show({autoClose:1e4,color:"red",id:"block-error",message:m.error,title:`Block error ID: ${a.id}`});},[m.error]);let O=kt[a.type],B=jsx("div",{style:{...{width:"100%",height:"100%",position:"absolute",top:0,left:0,opacity:.9,zIndex:4,pointerEvents:"none"},backgroundColor:"pink"},children:jsx(Center,{h:"100%",children:jsx(Text,{size:"sm",tt:"capitalize",italic:true,children:m.hiddenByCascade===a.id?`${a.type} not allowed`:`${a.type} hidden by block ${m.hiddenByCascade}`})})});if(s)return jsx(Center,{style:{minHeight:100},w:"100%",children:jsx(Loader,{})});if(!S)return null;let{error:_,log:P}=C,I=P?P.join(`
52
+ `):"";return jsxs("div",{id:`bespoke-${a.type}-${a.id}`,className:"cms-block-preview bespoke-block-area",style:{width:"100%",minHeight:a.type===E.VIZ?400:"auto"},children:[!o&&B,[E.GENERATOR,E.SECTION_FLAG].includes(a.type)&&jsx(OH,{block:a,status:C,sectionFlag:k,variables:S}),O?jsx(Fragment$2,{children:jsx(O,{id:a.id,debug:i,section:a.section_id,...S,settings:y,status:C})},"renderer"):jsx(Center,{style:{minHeight:100},children:jsx(Badge,{color:"gray",variant:"outline",children:a.type},"type")}),i&&I&&jsx(Textarea,{label:"Console",minRows:3,readOnly:true,autosize:true,maxRows:10,value:I,error:_}),i&&_&&jsx(Textarea,{label:"Error",readOnly:true,autosize:true,minRows:3,maxRows:10,value:_})]})}var Jp=Yt(LH,tt);p();he();se();ye();Up();function $H({id:e,setBlockSettings:t}){let{newConfirmation:o}=Kt(),r=ie(),n=tt(e).data,[i,a]=useState(n.settings[_t.ACCESS]||["public"]),[l,s]=useState(n.settings[_t.FALLBACK]||false),c=ot(e),u=useMemo(()=>[{value:"always",label:"always",group:"Static"},{value:"never",label:"never",group:"Static"}].concat(Object.keys(c).map(k=>({value:k,label:`${k}: ${c[k]}`,group:"Based on variable"}))),[c]),d=[{label:"Section-wide",value:"false"},{label:"Report-wide",value:"true"}];useEffect(()=>{t({[_t.ACCESS]:i}),i.includes("public")&&s(false);},[i]),useEffect(()=>{t({[_t.FALLBACK]:l});},[l]);let f=async()=>{try{await o({title:"Are you sure?",message:"Delete this block and all its contents? This action cannot be undone.",confirmText:"Yes, Delete it."}),r(Z.deleteEntity("block",e));}catch{}},g=(k,w)=>{t({[k]:w});},m=k=>{let w=`return variables.${k}`;k==="always"&&(w="return true;"),k==="never"&&(w="return false;"),t({[_t.ALLOWED]:k,[_t.ALLOWED_LOGIC]:w});},h=k=>{t({[_t.IGNORE_CASCADE]:k});},y=H(k=>k.records.entities.block),S=n.consumers.filter(k=>y[k].section_id!==n.section_id),v=!!S.length,C=S.slice(0,3).map((k,w)=>jsxs(Fragment,{children:[w===S.length-1&&S.length>1?"and ":"",jsx("strong",{children:`${y[k].type} ${k} [Section ${y[k].section_id}]`},k),w<S.length-1&&S.length>1?", ":""]})),b=n.inputs.map(k=>({label:`${y[k]?.type} - ${y[k]?.id}`,value:k}));return jsx(Group,{grow:true,align:"flex-start",children:jsxs(Stack,{justify:"flex-start",children:[jsx(Title,{order:4,children:"Visibility"}),jsx(Select,{label:"Show",description:"Set visibility setting for this block. A hidden block will not run or export variables to its consumers. As a result, all its consumers will be hidden too.",defaultValue:n.settings[_t.ALLOWED]||"always",onChange:m,data:u}),[E.GENERATOR,E.VIZ,E.SECTION_FLAG].includes(n.type)&&jsx(MultiSelect,{label:"Ignore cascade",description:"Set block as visible even if the selected inputs are hidden.",defaultValue:n.settings[_t.IGNORE_CASCADE]||[],data:b,onChange:h}),jsx(va,{value:i,onChange:a}),jsx(Checkbox,{checked:l,disabled:i.includes("public"),label:"Show fallback block when block is not allowed",onChange:k=>s(k.currentTarget.checked)}),jsx(Title,{order:4,children:"Output"}),v&&n.shared&&jsxs(Text,{size:"xs",color:"red.4",sx:{display:"flex",alignItems:"flex-start",gap:"0.4rem"},children:[jsx(IconAlertCircle,{size:"1.2rem"}),jsxs(Text,{color:"black",span:true,inherit:true,children:["This block is being consumed by ",C,S.length>3&&" and others",". Please, make sure you remove this block dependencies before changing this setting."]})]}),jsx(Select,{label:"Block scope",description:"Select the scope for the variables exported by this block. Section-wide (available only to blocks in the same section) or Report-wide (available to any block inside the report).",defaultValue:String(n.shared),disabled:v&&n.shared,onChange:k=>g("shared",k==="true"),data:d}),jsx(Title,{order:4,children:"Danger zone"}),jsx(Button,{variant:"outline",color:"red",onClick:f,children:"Delete Block"})]})})}var $w=$H;p();ys();se();Pt();ye();he();var Vh={Consumer:jsx(ThemeIcon,{size:"xs",radius:"xl",color:"red",variant:"light",children:jsx(IconLogout,{})}),Input:jsx(ThemeIcon,{size:"xs",radius:"xl",color:"green",children:jsx(IconCircleCheck,{})}),None:jsx(ThemeIcon,{size:"xs",radius:"xl",color:"gray",children:jsx(IconCirclePlus,{})})};function o2({id:e}){let t=ie(),o=useContext(De),r=At(o),[n,i]=useState(""),[a]=useDebouncedValue(n,200),l=H(y=>{if(y.records.reports&&y.records.reports[0]){let S=y.records.reports[0],v=y.records.entities.report[S].sections;return Object.values(y.records.entities.block).filter(C=>v.includes(C.section_id))}return []}),s=tt(e).data,c=H(y=>y.variables.variables),u=useMemo(()=>s?s.inputs.reduce((y,S)=>({...y,[S]:l[S]}),{}):[],[s]),d=(y,S)=>{if(!s)return 0;let v=s.inputs.includes(y.id),C=s.inputs.includes(S.id);if(v!==C)return v?1:-1;let b=Object.keys(c[y.id]||{}).length,k=Object.keys(c[S.id]||{}).length;return b!==k?k-b:y.shared?1:-1},f=useMemo(()=>l.filter(y=>y.id!==s.id&&(y.section_id===s.section_id||y.shared)&&y.type!==E.SECTION_FLAG).sort(d),[l]),g=useMemo(()=>f.filter(y=>{let S=String(y.id).includes(a.trim()),v=Object.keys(c[y.id]||{}).some(C=>C.includes(a.trim()));return S||v}),[f,a,c]),m=y=>{let S=u[y]?"delete":"create";t(Z.updateEntity("block",{id:e,inputAction:{operation:S,input:{input_id:y,block_id:e}}})).then(()=>{r();});};if(!s)return null;let h=y=>s.consumers.includes(y)?Vh.Consumer:s.inputs.includes(y)?Vh.Input:Vh.None;return jsxs(Menu,{width:"425px",children:[jsx(Menu.Target,{children:jsx(Button,{fullWidth:true,sx:{marginBottom:"15px"},leftIcon:jsx(IconLogin,{size:"1rem",style:{transform:"scaleX(-1)"}}),children:"Add New Input"})}),jsxs(Menu.Dropdown,{children:[jsx(TextInput,{placeholder:"Search by variable name or block id.",size:"xs",value:n,onChange:y=>i(y.target.value)}),g.map(({id:y,shared:S})=>jsx(Menu.Item,{disabled:s.consumers.includes(y),onClick:()=>m(y),icon:h(y),rightSection:jsxs(Stack,{ml:"xs",spacing:"xs",align:"flex-end",children:[jsxs(Text,{size:"xs",color:"gray.6",children:["[",y,"]"]}),S?jsx(ThemeIcon,{size:"xs",radius:"xl",children:jsx(IconGlobe,{})}):null]}),children:jsx(Box,{style:{maxWidth:"400px"},children:jsx(Ar,{id:`${y}`,variables:c[y]})})},y))]})]})}var Uw=o2;rp();p();ye();he();p();he();p();p();var $h=e=>`
53
+ `.padEnd(e*2+1," "),Gw=(e,t=0)=>{let o=e instanceof Array;return `${o?"[":"{"}${$h(t+1)}${Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{let n=o?"":`${r}: `,i=e[r];return typeof i=="object"?n+=`${Gw(i,t+1)}`:typeof i=="string"&&(i.includes("=>")||i.startsWith("variables["))?n+=`${i}`:typeof i=="string"&&!i.length?n+="false":i===void 0?n=null:["boolean","number"].includes(typeof i)?n+=i:n+=`"${i}"`,n}).filter(r=>r!==null).join(`,${$h(t+1)}`)}${$h(t)}${o?"]":"}"}`},Us=Gw;ye();p();Wr();p();var Hw=e=>{if(!e)return e;let t=Array.isArray(e)?[]:{};return Object.keys(e).forEach(o=>{t[o]=typeof e[o]=="object"?Hw(e[o]):e[o];}),t},od=Hw;p();var r2=(e,t=false)=>{let o=/([A-z0-9]*)\{\{([^}]+)\}\}/g,r=(a,l,s)=>l?`\${formatters.${l}(variables.${s})}`:`\${variables.${s}}`,n=a=>typeof a=="string"?a.trim()===""?false:t?a.replace(o,r):a:Array.isArray(a)?a.map(l=>n(l)):typeof a=="object"&&a!==null?Object.keys(a).sort((l,s)=>l.localeCompare(s)).reduce((l,s)=>({...l,[s]:n(a[s])}),{}):typeof a=="boolean"||typeof a=="number"?a:JSON.stringify(a),i=n(e);return Array.isArray(e)?`return ${JSON.stringify(i)};`:Object.keys(i).sort((a,l)=>a.localeCompare(l)).reduce((a,l)=>{let s;return typeof i[l]=="string"?i[l].includes("=>")||i[l].startsWith("variables[")?s=i[l]:s=`\`${i[l]}\``:typeof i[l]=="boolean"||typeof i[l]=="number"?s=i[l]:s=JSON.stringify(i[l]),a.concat(`"${l}": ${s},
54
+ `)},"return {").concat("};")},on=r2;p();p();p();function Qw(e){let{state:t,transaction:o}=e,{selection:r}=o,{doc:n}=o,{storedMarks:i}=o;return {...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return n},get tr(){return r=o.selection,n=o.doc,i=o.storedMarks,o}}}var Wh=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state;}get hasCustomState(){return !!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:o,state:r}=this,{view:n}=o,{tr:i}=r,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,s])=>[l,(...u)=>{let d=s(...u)(a);return !i.getMeta("preventDispatch")&&!this.hasCustomState&&n.dispatch(i),d}]))}get chain(){return ()=>this.createChain()}get can(){return ()=>this.createCan()}createChain(t,o=true){let{rawCommands:r,editor:n,state:i}=this,{view:a}=n,l=[],s=!!t,c=t||i.tr,u=()=>(!s&&o&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),l.every(f=>f===true)),d={...Object.fromEntries(Object.entries(r).map(([f,g])=>[f,(...h)=>{let y=this.buildProps(c,o),S=g(...h)(y);return l.push(S),d}])),run:u};return d}createCan(t){let{rawCommands:o,state:r}=this,n=false,i=t||r.tr,a=this.buildProps(i,n);return {...Object.fromEntries(Object.entries(o).map(([s,c])=>[s,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,n)}}buildProps(t,o=true){let{rawCommands:r,editor:n,state:i}=this,{view:a}=n,l={tr:t,editor:n,view:a,state:Qw({state:i,transaction:t}),dispatch:o?()=>{}:void 0,chain:()=>this.createChain(t,o),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([s,c])=>[s,(...u)=>c(...u)(l)]))}};return l}};function vo(e,t,o){return e.config[t]===void 0&&e.parent?vo(e.parent,t,o):typeof e.config[t]=="function"?e.config[t].bind({...o,parent:e.parent?vo(e.parent,t,o):null}):e.config[t]}function P2(e){let t=e.filter(n=>n.type==="extension"),o=e.filter(n=>n.type==="node"),r=e.filter(n=>n.type==="mark");return {baseExtensions:t,nodeExtensions:o,markExtensions:r}}function lo(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Zw(...e){return e.filter(t=>!!t).reduce((t,o)=>{let r={...t};return Object.entries(o).forEach(([n,i])=>{if(!r[n]){r[n]=i;return}if(n==="class"){let l=i?i.split(" "):[],s=r[n]?r[n].split(" "):[],c=l.filter(u=>!s.includes(u));r[n]=[...s,...c].join(" ");}else if(n==="style"){let l=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],s=r[n]?r[n].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;s.forEach(u=>{let[d,f]=u.split(":").map(g=>g.trim());c.set(d,f);}),l.forEach(u=>{let[d,f]=u.split(":").map(g=>g.trim());c.set(d,f);}),r[n]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ");}else r[n]=i;}),r},{})}function O2(e){return typeof e=="function"}function so(e,t=void 0,...o){return O2(e)?t?e.bind(t)(...o):e(...o):e}function L2(e){return Object.prototype.toString.call(e)==="[object RegExp]"}var ld=class{constructor(t){this.find=t.find,this.handler=t.handler;}};var jh=class{constructor(t){this.find=t.find,this.handler=t.handler;}};function M2(e){return Object.prototype.toString.call(e).slice(8,-1)}function rd(e){return M2(e)!=="Object"?false:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function md(e,t){let o={...e};return rd(e)&&rd(t)&&Object.keys(t).forEach(r=>{rd(t[r])&&rd(e[r])?o[r]=md(e[r],t[r]):o[r]=t[r];}),o}var nn=class e{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=so(vo(this,"addOptions",{name:this.name}))),this.storage=so(vo(this,"addStorage",{name:this.name,options:this.options}))||{};}static create(t={}){return new e(t)}configure(t={}){let o=this.extend({...this.config,addOptions:()=>md(this.options,t)});return o.name=this.name,o.parent=this.parent,o}extend(t={}){let o=new e({...this.config,...t});return o.parent=this,this.child=o,o.name=t.name?t.name:o.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${o.name}".`),o.options=so(vo(o,"addOptions",{name:o.name})),o.storage=so(vo(o,"addStorage",{name:o.name,options:o.options})),o}};function B2(e,t,o){let{from:r,to:n}=t,{blockSeparator:i=`
55
55
 
56
- `,textSerializers:a={}}=o||{},l="";return e.nodesBetween(r,n,(s,c,u,d)=>{var m;s.isBlock&&c>r&&(l+=i);let g=a?.[s.type.name];if(g)return u&&(l+=g({node:s,pos:c,parent:u,index:d,range:t})),false;s.isText&&(l+=(m=s?.text)===null||m===void 0?void 0:m.slice(Math.max(r,c)-c,n-c));}),l}function B2(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,o])=>[t,o.spec.toText]))}sn.create({name:"clipboardTextSerializer",addOptions(){return {blockSeparator:void 0}},addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:o}=e,{doc:r,selection:n}=t,{ranges:i}=n,a=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),s=B2(o);return M2(r,{from:a,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:s})}}})]}});var D2=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var o;e.isDestroyed||(t.dom.blur(),(o=window?.getSelection())===null||o===void 0||o.removeAllRanges());}),true),_2=(e=false)=>({commands:t})=>t.setContent("",e),N2=()=>({state:e,tr:t,dispatch:o})=>{let{selection:r}=t,{ranges:n}=r;return o&&n.forEach(({$from:i,$to:a})=>{e.doc.nodesBetween(i.pos,a.pos,(l,s)=>{if(l.type.isText)return;let{doc:c,mapping:u}=t,d=c.resolve(u.map(s)),m=c.resolve(u.map(s+l.nodeSize)),g=d.blockRange(m);if(!g)return;let f=liftTarget(g);if(l.type.isTextblock){let{defaultType:h}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(g.start,h);}(f||f===0)&&t.lift(g,f);});}),true},z2=e=>t=>e(t),F2=()=>({state:e,dispatch:t})=>createParagraphNear(e,t),V2=(e,t)=>({editor:o,tr:r})=>{let{state:n}=o,i=n.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let a=r.mapping.map(t);return r.insert(a,i.content),r.setSelection(new TextSelection(r.doc.resolve(a-1))),true},$2=()=>({tr:e,dispatch:t})=>{let{selection:o}=e,r=o.$anchor.node();if(r.content.size>0)return false;let n=e.selection.$anchor;for(let i=n.depth;i>0;i-=1)if(n.node(i).type===r.type){if(t){let l=n.before(i),s=n.after(i);e.delete(l,s).scrollIntoView();}return true}return false},U2=e=>({tr:t,state:o,dispatch:r})=>{let n=co(e,o.schema),i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===n){if(r){let s=i.before(a),c=i.after(a);t.delete(s,c).scrollIntoView();}return true}return false},G2=e=>({tr:t,dispatch:o})=>{let{from:r,to:n}=e;return o&&t.delete(r,n),true},H2=()=>({state:e,dispatch:t})=>deleteSelection(e,t),W2=()=>({commands:e})=>e.keyboardShortcut("Enter"),j2=()=>({state:e,dispatch:t})=>exitCode(e,t);function ld(e,t,o={strict:true}){let r=Object.keys(t);return r.length?r.every(n=>o.strict?t[n]===e[n]:O2(t[n])?t[n].test(e[n]):t[n]===e[n]):true}function jh(e,t,o={}){return e.find(r=>r.type===t&&ld(r.attrs,o))}function K2(e,t,o={}){return !!jh(e,t,o)}function Kh(e,t,o={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&r.offset!==0&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;let n=jh([...r.node.marks],t,o);if(!n)return;let i=r.index,a=e.start()+r.offset,l=i+1,s=a+r.node.nodeSize;for(jh([...r.node.marks],t,o);i>0&&n.isInSet(e.parent.child(i-1).marks);)i-=1,a-=e.parent.child(i).nodeSize;for(;l<e.parent.childCount&&K2([...e.parent.child(l).marks],t,o);)s+=e.parent.child(l).nodeSize,l+=1;return {from:a,to:s}}function yi(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var q2=(e,t={})=>({tr:o,state:r,dispatch:n})=>{let i=yi(e,r.schema),{doc:a,selection:l}=o,{$from:s,from:c,to:u}=l;if(n){let d=Kh(s,i,t);if(d&&d.from<=c&&d.to>=u){let m=TextSelection.create(a,d.from,d.to);o.setSelection(m);}}return true},Y2=e=>t=>{let o=typeof e=="function"?e(t):e;for(let r=0;r<o.length;r+=1)if(o[r](t))return true;return false};function Zw(e){return e instanceof TextSelection}function Ta(e=0,t=0,o=0){return Math.min(Math.max(e,t),o)}function X2(e,t=null){if(!t)return null;let o=Selection.atStart(e),r=Selection.atEnd(e);if(t==="start"||t===true)return o;if(t==="end")return r;let n=o.from,i=r.to;return t==="all"?TextSelection.create(e,Ta(0,n,i),Ta(e.content.size,n,i)):TextSelection.create(e,Ta(t,n,i),Ta(t,n,i))}function qh(){return ["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var J2=(e=null,t={})=>({editor:o,view:r,tr:n,dispatch:i})=>{t={scrollIntoView:true,...t};let a=()=>{qh()&&r.dom.focus(),requestAnimationFrame(()=>{o.isDestroyed||(r.focus(),t?.scrollIntoView&&o.commands.scrollIntoView());});};if(r.hasFocus()&&e===null||e===false)return true;if(i&&e===null&&!Zw(o.state.selection))return a(),true;let l=X2(n.doc,e)||o.state.selection,s=o.state.selection.eq(l);return i&&(s||n.setSelection(l),s&&n.storedMarks&&n.setStoredMarks(n.storedMarks),a()),true},Q2=(e,t)=>o=>e.every((r,n)=>t(r,{...o,index:n})),Z2=(e,t)=>({tr:o,commands:r})=>r.insertContentAt({from:o.selection.from,to:o.selection.to},e,t),eR=e=>{let t=e.childNodes;for(let o=t.length-1;o>=0;o-=1){let r=t[o];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&eR(r);}return e};function rd(e){let t=`<body>${e}</body>`,o=new window.DOMParser().parseFromString(t,"text/html").body;return eR(o)}function cd(e,t,o){o={slice:true,parseOptions:{},...o};let r=typeof e=="object"&&e!==null,n=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return Fragment$1.fromArray(e.map(l=>t.nodeFromJSON(l)));let a=t.nodeFromJSON(e);return o.errorOnInvalidContent&&a.check(),a}catch(i){if(o.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),cd("",t,o)}if(n){if(o.errorOnInvalidContent){let a=false,l="",s=new Schema({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(a=true,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(o.slice?DOMParser.fromSchema(s).parseSlice(rd(e),o.parseOptions):DOMParser.fromSchema(s).parse(rd(e),o.parseOptions),o.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=DOMParser.fromSchema(t);return o.slice?i.parseSlice(rd(e),o.parseOptions).content:i.parse(rd(e),o.parseOptions)}return cd("",t,o)}function eW(e,t,o){let r=e.steps.length-1;if(r<t)return;let n=e.steps[r];if(!(n instanceof ReplaceStep||n instanceof ReplaceAroundStep))return;let i=e.mapping.maps[r],a=0;i.forEach((l,s,c,u)=>{a===0&&(a=u);}),e.setSelection(Selection.near(e.doc.resolve(a),o));}var tW=e=>!("type"in e),oW=(e,t,o)=>({tr:r,dispatch:n,editor:i})=>{var a;if(n){o={parseOptions:{},updateSelection:true,applyInputRules:false,applyPasteRules:false,...o};let l;try{l=cd(t,i.schema,{parseOptions:{preserveWhitespace:"full",...o.parseOptions},errorOnInvalidContent:(a=o.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});}catch(f){return i.emit("contentError",{editor:i,error:f,disableCollaboration:()=>{console.error("[tiptap error]: Unable to disable collaboration at this point in time");}}),false}let{from:s,to:c}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},u=true,d=true;if((tW(l)?l:[l]).forEach(f=>{f.check(),u=u?f.isText&&f.marks.length===0:false,d=d?f.isBlock:false;}),s===c&&d){let{parent:f}=r.doc.resolve(s);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(s-=1,c+=1);}let g;u?(Array.isArray(t)?g=t.map(f=>f.text||"").join(""):typeof t=="object"&&t&&t.text?g=t.text:g=t,r.insertText(g,s,c)):(g=l,r.replaceWith(s,c,g)),o.updateSelection&&eW(r,r.steps.length-1,-1),o.applyInputRules&&r.setMeta("applyInputRules",{from:s,text:g}),o.applyPasteRules&&r.setMeta("applyPasteRules",{from:s,text:g});}return true},rW=()=>({state:e,dispatch:t})=>joinUp(e,t),nW=()=>({state:e,dispatch:t})=>joinDown(e,t),iW=()=>({state:e,dispatch:t})=>joinBackward(e,t),aW=()=>({state:e,dispatch:t})=>joinForward(e,t),sW=()=>({state:e,dispatch:t,tr:o})=>{try{let r=joinPoint(e.doc,e.selection.$from.pos,-1);return r==null?!1:(o.join(r,2),t&&t(o),!0)}catch{return false}},lW=()=>({state:e,dispatch:t,tr:o})=>{try{let r=joinPoint(e.doc,e.selection.$from.pos,1);return r==null?!1:(o.join(r,2),t&&t(o),!0)}catch{return false}},cW=()=>({state:e,dispatch:t})=>joinTextblockBackward(e,t),uW=()=>({state:e,dispatch:t})=>joinTextblockForward(e,t);function tR(){return typeof navigator<"u"?/Mac/.test(navigator.platform):false}function pW(e){let t=e.split(/-(?!$)/),o=t[t.length-1];o==="Space"&&(o=" ");let r,n,i,a;for(let l=0;l<t.length-1;l+=1){let s=t[l];if(/^(cmd|meta|m)$/i.test(s))a=true;else if(/^a(lt)?$/i.test(s))r=true;else if(/^(c|ctrl|control)$/i.test(s))n=true;else if(/^s(hift)?$/i.test(s))i=true;else if(/^mod$/i.test(s))qh()||tR()?a=true:n=true;else throw new Error(`Unrecognized modifier name: ${s}`)}return r&&(o=`Alt-${o}`),n&&(o=`Ctrl-${o}`),a&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}var dW=e=>({editor:t,view:o,tr:r,dispatch:n})=>{let i=pW(e).split(/-(?!$)/),a=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:true,cancelable:true}),s=t.captureTransaction(()=>{o.someProp("handleKeyDown",c=>c(o,l));});return s?.steps.forEach(c=>{let u=c.map(r.mapping);u&&n&&r.maybeStep(u);}),true};function Yh(e,t,o={}){let{from:r,to:n,empty:i}=e.selection,a=t?co(t,e.schema):null,l=[];e.doc.nodesBetween(r,n,(d,m)=>{if(d.isText)return;let g=Math.max(r,m),f=Math.min(n,m+d.nodeSize);l.push({node:d,from:g,to:f});});let s=n-r,c=l.filter(d=>a?a.name===d.node.type.name:true).filter(d=>ld(d.node.attrs,o,{strict:false}));return i?!!c.length:c.reduce((d,m)=>d+m.to-m.from,0)>=s}var mW=(e,t={})=>({state:o,dispatch:r})=>{let n=co(e,o.schema);return Yh(o,n,t)?lift(o,r):false},fW=()=>({state:e,dispatch:t})=>liftEmptyBlock(e,t),gW=e=>({state:t,dispatch:o})=>{let r=co(e,t.schema);return liftListItem(r)(t,o)},hW=()=>({state:e,dispatch:t})=>newlineInCode(e,t);function oR(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Ww(e,t){let o=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,n)=>(o.includes(n)||(r[n]=e[n]),r),{})}var bW=(e,t)=>({tr:o,state:r,dispatch:n})=>{let i=null,a=null,l=oR(typeof e=="string"?e:e.name,r.schema);return l?(l==="node"&&(i=co(e,r.schema)),l==="mark"&&(a=yi(e,r.schema)),n&&o.selection.ranges.forEach(s=>{r.doc.nodesBetween(s.$from.pos,s.$to.pos,(c,u)=>{i&&i===c.type&&o.setNodeMarkup(u,void 0,Ww(c.attrs,t)),a&&c.marks.length&&c.marks.forEach(d=>{a===d.type&&o.addMark(u,u+c.nodeSize,a.create(Ww(d.attrs,t)));});});}),true):false},yW=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),true),vW=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),SW=()=>({state:e,dispatch:t})=>selectNodeBackward(e,t),xW=()=>({state:e,dispatch:t})=>selectNodeForward(e,t),TW=()=>({state:e,dispatch:t})=>selectParentNode(e,t),CW=()=>({state:e,dispatch:t})=>selectTextblockEnd(e,t),kW=()=>({state:e,dispatch:t})=>selectTextblockStart(e,t);function EW(e,t,o={},r={}){return cd(e,t,{slice:false,parseOptions:o,errorOnInvalidContent:r.errorOnInvalidContent})}var wW=(e,t=false,o={},r={})=>({editor:n,tr:i,dispatch:a,commands:l})=>{var s,c;let{doc:u}=i;if(o.preserveWhitespace!=="full"){let d=EW(e,n.schema,o,{errorOnInvalidContent:(s=r.errorOnInvalidContent)!==null&&s!==void 0?s:n.options.enableContentCheck});return a&&i.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),true}return a&&i.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:u.content.size},e,{parseOptions:o,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:n.options.enableContentCheck})};function RW(e,t){let o=yi(t,e.schema),{from:r,to:n,empty:i}=e.selection,a=[];i?(e.storedMarks&&a.push(...e.storedMarks),a.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,n,s=>{a.push(...s.marks);});let l=a.find(s=>s.type.name===o.name);return l?{...l.attrs}:{}}function IW(e){for(let t=0;t<e.edgeCount;t+=1){let{type:o}=e.edge(t);if(o.isTextblock&&!o.hasRequiredAttrs())return o}return null}function AW(e,t){for(let o=e.depth;o>0;o-=1){let r=e.node(o);if(t(r))return {pos:o>0?e.before(o):0,start:e.start(o),depth:o,node:r}}}function Xh(e){return t=>AW(t.$from,e)}function rR(e,t,o){let r=[];return e===t?o.resolve(e).marks().forEach(n=>{let i=o.resolve(e),a=Kh(i,n.type);a&&r.push({mark:n,...a});}):o.nodesBetween(e,t,(n,i)=>{!n||n?.nodeSize===void 0||r.push(...n.marks.map(a=>({from:i,to:i+n.nodeSize,mark:a})));}),r}function ad(e,t,o){return Object.fromEntries(Object.entries(o).filter(([r])=>{let n=e.find(i=>i.type===t&&i.name===r);return n?n.attribute.keepOnSplit:false}))}function PW(e,t,o={}){let{empty:r,ranges:n}=e.selection,i=t?yi(t,e.schema):null;if(r)return !!(e.storedMarks||e.selection.$from.marks()).filter(d=>i?i.name===d.type.name:true).find(d=>ld(d.attrs,o,{strict:false}));let a=0,l=[];if(n.forEach(({$from:d,$to:m})=>{let g=d.pos,f=m.pos;e.doc.nodesBetween(g,f,(h,v)=>{if(!h.isText&&!h.marks.length)return;let T=Math.max(g,v),y=Math.min(f,v+h.nodeSize),C=y-T;a+=C,l.push(...h.marks.map(b=>({mark:b,from:T,to:y})));});}),a===0)return false;let s=l.filter(d=>i?i.name===d.mark.type.name:true).filter(d=>ld(d.mark.attrs,o,{strict:false})).reduce((d,m)=>d+m.to-m.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):true).reduce((d,m)=>d+m.to-m.from,0);return (s>0?s+c:s)>=a}function jw(e,t){let{nodeExtensions:o}=A2(t),r=o.find(a=>a.name===e);if(!r)return false;let n={name:r.name,options:r.options,storage:r.storage},i=lo(So(r,"group",n));return typeof i!="string"?false:i.split(" ").includes("list")}function nR(e,{checkChildren:t=true,ignoreWhitespace:o=false}={}){var r;if(o){if(e.type.name==="hardBreak")return true;if(e.isText)return /^\s*$/m.test((r=e.text)!==null&&r!==void 0?r:"")}if(e.isText)return !e.text;if(e.isAtom||e.isLeaf)return false;if(e.content.childCount===0)return true;if(t){let n=true;return e.content.forEach(i=>{n!==false&&(nR(i,{ignoreWhitespace:o,checkChildren:t})||(n=false));}),n}return false}function OW(e,t,o){var r;let{selection:n}=t,i=null;if(Zw(n)&&(i=n.$cursor),i){let l=(r=e.storedMarks)!==null&&r!==void 0?r:i.marks();return !!o.isInSet(l)||!l.some(s=>s.type.excludes(o))}let{ranges:a}=n;return a.some(({$from:l,$to:s})=>{let c=l.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(o):false;return e.doc.nodesBetween(l.pos,s.pos,(u,d,m)=>{if(c)return false;if(u.isInline){let g=!m||m.type.allowsMarkType(o),f=!!o.isInSet(u.marks)||!u.marks.some(h=>h.type.excludes(o));c=g&&f;}return !c}),c})}var LW=(e,t={})=>({tr:o,state:r,dispatch:n})=>{let{selection:i}=o,{empty:a,ranges:l}=i,s=yi(e,r.schema);if(n)if(a){let c=RW(r,s);o.addStoredMark(s.create({...c,...t}));}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(m,g)=>{let f=Math.max(g,u),h=Math.min(g+m.nodeSize,d);m.marks.find(T=>T.type===s)?m.marks.forEach(T=>{s===T.type&&o.addMark(f,h,s.create({...T.attrs,...t}));}):o.addMark(f,h,s.create(t));});});return OW(r,o,s)},MW=(e,t)=>({tr:o})=>(o.setMeta(e,t),true),BW=(e,t={})=>({state:o,dispatch:r,chain:n})=>{let i=co(e,o.schema);return i.isTextblock?n().command(({commands:a})=>setBlockType(i,t)(o)?true:a.clearNodes()).command(({state:a})=>setBlockType(i,t)(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),false)},DW=e=>({tr:t,dispatch:o})=>{if(o){let{doc:r}=t,n=Ta(e,0,r.content.size),i=NodeSelection.create(r,n);t.setSelection(i);}return true},_W=e=>({tr:t,dispatch:o})=>{if(o){let{doc:r}=t,{from:n,to:i}=typeof e=="number"?{from:e,to:e}:e,a=TextSelection.atStart(r).from,l=TextSelection.atEnd(r).to,s=Ta(n,a,l),c=Ta(i,a,l),u=TextSelection.create(r,s,c);t.setSelection(u);}return true},NW=e=>({state:t,dispatch:o})=>{let r=co(e,t.schema);return sinkListItem(r)(t,o)};function Kw(e,t){let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(o){let r=o.filter(n=>t?.includes(n.type.name));e.tr.ensureMarks(r);}}var zW=({keepMarks:e=true}={})=>({tr:t,state:o,dispatch:r,editor:n})=>{let{selection:i,doc:a}=t,{$from:l,$to:s}=i,c=n.extensionManager.attributes,u=ad(c,l.node().type.name,l.node().attrs);if(i instanceof NodeSelection&&i.node.isBlock)return !l.parentOffset||!canSplit(a,l.pos)?false:(r&&(e&&Kw(o,n.extensionManager.splittableMarks),t.split(l.pos).scrollIntoView()),true);if(!l.parent.isBlock)return false;let d=s.parentOffset===s.parent.content.size,m=l.depth===0?void 0:IW(l.node(-1).contentMatchAt(l.indexAfter(-1))),g=d&&m?[{type:m,attrs:u}]:void 0,f=canSplit(t.doc,t.mapping.map(l.pos),1,g);if(!g&&!f&&canSplit(t.doc,t.mapping.map(l.pos),1,m?[{type:m}]:void 0)&&(f=true,g=m?[{type:m,attrs:u}]:void 0),r){if(f&&(i instanceof TextSelection&&t.deleteSelection(),t.split(t.mapping.map(l.pos),1,g),m&&!d&&!l.parentOffset&&l.parent.type!==m)){let h=t.mapping.map(l.before()),v=t.doc.resolve(h);l.node(-1).canReplaceWith(v.index(),v.index()+1,m)&&t.setNodeMarkup(t.mapping.map(l.before()),m);}e&&Kw(o,n.extensionManager.splittableMarks),t.scrollIntoView();}return f},FW=(e,t={})=>({tr:o,state:r,dispatch:n,editor:i})=>{var a;let l=co(e,r.schema),{$from:s,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||s.depth<2||!s.sameParent(c))return false;let d=s.node(-1);if(d.type!==l)return false;let m=i.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==l||s.index(-2)!==s.node(-2).childCount-1)return false;if(n){let T=Fragment$1.empty,y=s.index(-1)?1:s.index(-2)?2:3;for(let O=s.depth-y;O>=s.depth-3;O-=1)T=Fragment$1.from(s.node(O).copy(T));let C=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,b={...ad(m,s.node().type.name,s.node().attrs),...t},w=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(b))||void 0;T=T.append(Fragment$1.from(l.createAndFill(null,w)||void 0));let k=s.before(s.depth-(y-1));o.replace(k,s.after(-C),new Slice(T,4-y,0));let I=-1;o.doc.nodesBetween(k,o.doc.content.size,(O,P)=>{if(I>-1)return false;O.isTextblock&&O.content.size===0&&(I=P+1);}),I>-1&&o.setSelection(TextSelection.near(o.doc.resolve(I))),o.scrollIntoView();}return true}let g=c.pos===s.end()?d.contentMatchAt(0).defaultType:null,f={...ad(m,d.type.name,d.attrs),...t},h={...ad(m,s.node().type.name,s.node().attrs),...t};o.delete(s.pos,c.pos);let v=g?[{type:l,attrs:f},{type:g,attrs:h}]:[{type:l,attrs:f}];if(!canSplit(o.doc,s.pos,2))return false;if(n){let{selection:T,storedMarks:y}=r,{splittableMarks:C}=i.extensionManager,b=y||T.$to.parentOffset&&T.$from.marks();if(o.split(s.pos,2,v).scrollIntoView(),!b||!n)return true;let w=b.filter(k=>C.includes(k.type.name));o.ensureMarks(w);}return true},Uh=(e,t)=>{let o=Xh(a=>a.type===t)(e.selection);if(!o)return true;let r=e.doc.resolve(Math.max(0,o.pos-1)).before(o.depth);if(r===void 0)return true;let n=e.doc.nodeAt(r);return o.node.type===n?.type&&canJoin(e.doc,o.pos)&&e.join(o.pos),true},Gh=(e,t)=>{let o=Xh(a=>a.type===t)(e.selection);if(!o)return true;let r=e.doc.resolve(o.start).after(o.depth);if(r===void 0)return true;let n=e.doc.nodeAt(r);return o.node.type===n?.type&&canJoin(e.doc,r)&&e.join(r),true},VW=(e,t,o,r={})=>({editor:n,tr:i,state:a,dispatch:l,chain:s,commands:c,can:u})=>{let{extensions:d,splittableMarks:m}=n.extensionManager,g=co(e,a.schema),f=co(t,a.schema),{selection:h,storedMarks:v}=a,{$from:T,$to:y}=h,C=T.blockRange(y),b=v||h.$to.parentOffset&&h.$from.marks();if(!C)return false;let w=Xh(k=>jw(k.type.name,d))(h);if(C.depth>=1&&w&&C.depth-w.depth<=1){if(w.node.type===g)return c.liftListItem(f);if(jw(w.node.type.name,d)&&g.validContent(w.node.content)&&l)return s().command(()=>(i.setNodeMarkup(w.pos,g),true)).command(()=>Uh(i,g)).command(()=>Gh(i,g)).run()}return !o||!b||!l?s().command(()=>u().wrapInList(g,r)?true:c.clearNodes()).wrapInList(g,r).command(()=>Uh(i,g)).command(()=>Gh(i,g)).run():s().command(()=>{let k=u().wrapInList(g,r),I=b.filter(O=>m.includes(O.type.name));return i.ensureMarks(I),k?true:c.clearNodes()}).wrapInList(g,r).command(()=>Uh(i,g)).command(()=>Gh(i,g)).run()},$W=(e,t={},o={})=>({state:r,commands:n})=>{let{extendEmptyMarkRange:i=false}=o,a=yi(e,r.schema);return PW(r,a,t)?n.unsetMark(a,{extendEmptyMarkRange:i}):n.setMark(a,t)},UW=(e,t,o={})=>({state:r,commands:n})=>{let i=co(e,r.schema),a=co(t,r.schema),l=Yh(r,i,o),s;return r.selection.$anchor.sameParent(r.selection.$head)&&(s=r.selection.$anchor.parent.attrs),l?n.setNode(a,s):n.setNode(i,{...s,...o})},GW=(e,t={})=>({state:o,commands:r})=>{let n=co(e,o.schema);return Yh(o,n,t)?r.lift(n):r.wrapIn(n,t)},HW=()=>({state:e,dispatch:t})=>{let o=e.plugins;for(let r=0;r<o.length;r+=1){let n=o[r],i;if(n.spec.isInputRules&&(i=n.getState(e))){if(t){let a=e.tr,l=i.transform;for(let s=l.steps.length-1;s>=0;s-=1)a.step(l.steps[s].invert(l.docs[s]));if(i.text){let s=a.doc.resolve(i.from).marks();a.replaceWith(i.from,i.to,e.schema.text(i.text,s));}else a.delete(i.from,i.to);}return true}}return false},WW=()=>({tr:e,dispatch:t})=>{let{selection:o}=e,{empty:r,ranges:n}=o;return r||t&&n.forEach(i=>{e.removeMark(i.$from.pos,i.$to.pos);}),true},jW=(e,t={})=>({tr:o,state:r,dispatch:n})=>{var i;let{extendEmptyMarkRange:a=false}=t,{selection:l}=o,s=yi(e,r.schema),{$from:c,empty:u,ranges:d}=l;if(!n)return true;if(u&&a){let{from:m,to:g}=l,f=(i=c.marks().find(v=>v.type===s))===null||i===void 0?void 0:i.attrs,h=Kh(c,s,f);h&&(m=h.from,g=h.to),o.removeMark(m,g,s);}else d.forEach(m=>{o.removeMark(m.$from.pos,m.$to.pos,s);});return o.removeStoredMark(s),true},KW=(e,t={})=>({tr:o,state:r,dispatch:n})=>{let i=null,a=null,l=oR(typeof e=="string"?e:e.name,r.schema);return l?(l==="node"&&(i=co(e,r.schema)),l==="mark"&&(a=yi(e,r.schema)),n&&o.selection.ranges.forEach(s=>{let c=s.$from.pos,u=s.$to.pos;r.doc.nodesBetween(c,u,(d,m)=>{i&&i===d.type&&o.setNodeMarkup(m,void 0,{...d.attrs,...t}),a&&d.marks.length&&d.marks.forEach(g=>{if(a===g.type){let f=Math.max(m,c),h=Math.min(m+d.nodeSize,u);o.addMark(f,h,a.create({...g.attrs,...t}));}});});}),true):false},qW=(e,t={})=>({state:o,dispatch:r})=>{let n=co(e,o.schema);return wrapIn(n,t)(o,r)},YW=(e,t={})=>({state:o,dispatch:r})=>{let n=co(e,o.schema);return wrapInList(n,t)(o,r)},XW=Object.freeze({__proto__:null,blur:D2,clearContent:_2,clearNodes:N2,command:z2,createParagraphNear:F2,cut:V2,deleteCurrentNode:$2,deleteNode:U2,deleteRange:G2,deleteSelection:H2,enter:W2,exitCode:j2,extendMarkRange:q2,first:Y2,focus:J2,forEach:Q2,insertContent:Z2,insertContentAt:oW,joinBackward:iW,joinDown:nW,joinForward:aW,joinItemBackward:sW,joinItemForward:lW,joinTextblockBackward:cW,joinTextblockForward:uW,joinUp:rW,keyboardShortcut:dW,lift:mW,liftEmptyBlock:fW,liftListItem:gW,newlineInCode:hW,resetAttributes:bW,scrollIntoView:yW,selectAll:vW,selectNodeBackward:SW,selectNodeForward:xW,selectParentNode:TW,selectTextblockEnd:CW,selectTextblockStart:kW,setContent:wW,setMark:LW,setMeta:MW,setNode:BW,setNodeSelection:DW,setTextSelection:_W,sinkListItem:NW,splitBlock:zW,splitListItem:FW,toggleList:VW,toggleMark:$W,toggleNode:UW,toggleWrap:GW,undoInputRule:HW,unsetAllMarks:WW,unsetMark:jW,updateAttributes:KW,wrapIn:qW,wrapInList:YW});sn.create({name:"commands",addCommands(){return {...XW}}});sn.create({name:"editable",addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}});sn.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return [new Plugin({key:new PluginKey("focusEvents"),props:{handleDOMEvents:{focus:(t,o)=>{e.isFocused=true;let r=e.state.tr.setMeta("focus",{event:o}).setMeta("addToHistory",false);return t.dispatch(r),false},blur:(t,o)=>{e.isFocused=false;let r=e.state.tr.setMeta("blur",{event:o}).setMeta("addToHistory",false);return t.dispatch(r),false}}}})]}});sn.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:l})=>{let{selection:s,doc:c}=l,{empty:u,$anchor:d}=s,{pos:m,parent:g}=d,f=d.parent.isTextblock&&m>0?l.doc.resolve(m-1):d,h=f.parent.type.spec.isolating,v=d.pos-d.parentOffset,T=h&&f.parent.childCount===1?v===d.pos:Selection.atStart(c).from===m;return !u||!g.type.isTextblock||g.textContent.length||!T||T&&d.parent.type.name==="paragraph"?false:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},n={...r},i={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return qh()||tR()?i:n},addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("clearDocument"),appendTransaction:(e,t,o)=>{let r=e.some(h=>h.docChanged)&&!t.doc.eq(o.doc),n=e.some(h=>h.getMeta("preventClearDocument"));if(!r||n)return;let{empty:i,from:a,to:l}=t.selection,s=Selection.atStart(t.doc).from,c=Selection.atEnd(t.doc).to;if(i||!(a===s&&l===c)||!nR(o.doc))return;let m=o.tr,g=Jw({state:o,transaction:m}),{commands:f}=new Hh({editor:this.editor,state:g});if(f.clearNodes(),!!m.steps.length)return m}})]}});sn.create({name:"tabindex",addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});function Jh(e){return new sd({find:e.find,handler:({state:t,range:o,match:r})=>{let n=lo(e.getAttributes,void 0,r);if(n===false||n===null)return null;let{tr:i}=t,a=r[r.length-1],l=r[0];if(a){let s=l.search(/\S/),c=o.from+l.indexOf(a),u=c+a.length;if(rR(o.from,o.to,t.doc).filter(g=>g.mark.type.excluded.find(h=>h===e.type&&h!==g.mark.type)).filter(g=>g.to>c).length)return null;u<o.to&&i.delete(u,o.to),c>o.from&&i.delete(o.from+s,c);let m=o.from+s+a.length;i.addMark(o.from+s,m,e.type.create(n||{})),i.removeStoredMark(e.type);}}})}function iR(e){return new sd({find:e.find,handler:({state:t,range:o,match:r})=>{let n=lo(e.getAttributes,void 0,r)||{},{tr:i}=t,a=o.from,l=o.to,s=e.type.create(n);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=a+c;u>l?u=l:l=u+r[1].length;let d=r[0][r[0].length-1];i.insertText(d,a+r[0].length-1),i.replaceWith(u,l,s);}else if(r[0]){let c=e.type.isInline?a:a-1;i.insert(c,e.type.create(n)).delete(i.mapping.map(a),i.mapping.map(l));}i.scrollIntoView();}})}var ud=class e{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=lo(So(this,"addOptions",{name:this.name}))),this.storage=lo(So(this,"addStorage",{name:this.name,options:this.options}))||{};}static create(t={}){return new e(t)}configure(t={}){let o=this.extend({...this.config,addOptions:()=>dd(this.options,t)});return o.name=this.name,o.parent=this.parent,o}extend(t={}){let o=new e(t);return o.parent=this,this.child=o,o.name=t.name?t.name:o.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${o.name}".`),o.options=lo(So(o,"addOptions",{name:o.name})),o.storage=lo(So(o,"addStorage",{name:o.name,options:o.options})),o}static handleExit({editor:t,mark:o}){let{tr:r}=t.state,n=t.state.selection.$from;if(n.pos===n.end()){let a=n.marks();if(!!!a.find(c=>c?.type.name===o.name))return false;let s=a.find(c=>c?.type.name===o.name);return s&&r.removeStoredMark(s),r.insertText(" ",n.pos),t.view.dispatch(r),true}return false}},pd=class e{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=lo(So(this,"addOptions",{name:this.name}))),this.storage=lo(So(this,"addStorage",{name:this.name,options:this.options}))||{};}static create(t={}){return new e(t)}configure(t={}){let o=this.extend({...this.config,addOptions:()=>dd(this.options,t)});return o.name=this.name,o.parent=this.parent,o}extend(t={}){let o=new e(t);return o.parent=this,this.child=o,o.name=t.name?t.name:o.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${o.name}".`),o.options=lo(So(o,"addOptions",{name:o.name})),o.storage=lo(So(o,"addStorage",{name:o.name,options:o.options})),o}};function Qh(e){return new Wh({find:e.find,handler:({state:t,range:o,match:r,pasteEvent:n})=>{let i=lo(e.getAttributes,void 0,r,n);if(i===false||i===null)return null;let{tr:a}=t,l=r[r.length-1],s=r[0],c=o.to;if(l){let u=s.search(/\S/),d=o.from+s.indexOf(l),m=d+l.length;if(rR(o.from,o.to,t.doc).filter(f=>f.mark.type.excluded.find(v=>v===e.type&&v!==f.mark.type)).filter(f=>f.to>d).length)return null;m<o.to&&a.delete(m,o.to),d>o.from&&a.delete(o.from+u,d),c=o.from+u+l.length,a.addMark(o.from+u,c,e.type.create(i||{})),a.removeStoredMark(e.type);}}})}var JW=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,QW=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ZW=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ej=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,aR=ud.create({name:"bold",addOptions(){return {HTMLAttributes:{}}},parseHTML(){return [{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return ["strong",Qw(this.options.HTMLAttributes,e),0]},addCommands(){return {setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return {"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return [Jh({find:JW,type:this.type}),Jh({find:ZW,type:this.type})]},addPasteRules(){return [Qh({find:QW,type:this.type}),Qh({find:ej,type:this.type})]}});p();var tj=/(?:^|\s)((?:\{\{)([a-zA-Z0-9]+)(?:\}\}))$/,oj=pd.create({name:"variable",group:"inline",content:"text*",marks:"_",atom:false,inline:true,selectable:true,addAttributes(){return {varName:{default:"",parseHTML:e=>e.innerText}}},addInputRules(){return [iR({find:tj,type:this.type,getAttributes:e=>({varName:e[0]})})]},renderHTML({node:e}){return ["code",{class:"bespoke-var"},e.attrs.varName.trim()]},parseHTML(){return [{tag:'code[class="bespoke-var"]'}]},toDOM(){return ["code",{class:"bespoke-var"},0]}}),sR=oj;p();var lR=sn.create({name:"VariablesStorage",addStorage(){return {suggestions:[]}}});p();p();p();p();var rt="top",Rt="bottom",ht="right",ct="left",md="auto",vi=[rt,Rt,ht,ct],Bn="start",Ca="end",cR="clippingParents",fd="viewport",js="popper",uR="reference",Zh=vi.reduce(function(e,t){return e.concat([t+"-"+Bn,t+"-"+Ca])},[]),gd=[].concat(vi,[md]).reduce(function(e,t){return e.concat([t,t+"-"+Bn,t+"-"+Ca])},[]),rj="beforeRead",nj="read",ij="afterRead",aj="beforeMain",sj="main",lj="afterMain",cj="beforeWrite",uj="write",pj="afterWrite",pR=[rj,nj,ij,aj,sj,lj,cj,uj,pj];p();p();p();function Lt(e){return e?(e.nodeName||"").toLowerCase():null}p();p();function qe(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function mr(e){var t=qe(e).Element;return e instanceof t||e instanceof Element}function It(e){var t=qe(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Ks(e){if(typeof ShadowRoot>"u")return false;var t=qe(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function dj(e){var t=e.state;Object.keys(t.elements).forEach(function(o){var r=t.styles[o]||{},n=t.attributes[o]||{},i=t.elements[o];!It(i)||!Lt(i)||(Object.assign(i.style,r),Object.keys(n).forEach(function(a){var l=n[a];l===false?i.removeAttribute(a):i.setAttribute(a,l===true?"":l);}));});}function mj(e){var t=e.state,o={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,o.popper),t.styles=o,t.elements.arrow&&Object.assign(t.elements.arrow.style,o.arrow),function(){Object.keys(t.elements).forEach(function(r){var n=t.elements[r],i=t.attributes[r]||{},a=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:o[r]),l=a.reduce(function(s,c){return s[c]="",s},{});!It(n)||!Lt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(s){n.removeAttribute(s);}));});}}var _c={name:"applyStyles",enabled:true,phase:"write",fn:dj,effect:mj,requires:["computeStyles"]};p();p();function Mt(e){return e.split("-")[0]}p();p();p();var _r=Math.max,ka=Math.min,Dn=Math.round;p();p();function qs(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Nc(){return !/^((?!chrome|android).)*safari/i.test(qs())}function fr(e,t,o){t===void 0&&(t=false),o===void 0&&(o=false);var r=e.getBoundingClientRect(),n=1,i=1;t&&It(e)&&(n=e.offsetWidth>0&&Dn(r.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Dn(r.height)/e.offsetHeight||1);var a=mr(e)?qe(e):window,l=a.visualViewport,s=!Nc()&&o,c=(r.left+(s&&l?l.offsetLeft:0))/n,u=(r.top+(s&&l?l.offsetTop:0))/i,d=r.width/n,m=r.height/i;return {width:d,height:m,top:u,right:c+d,bottom:u+m,left:c,x:c,y:u}}function Ea(e){var t=fr(e),o=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-o)<=1&&(o=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:o,height:r}}p();function zc(e,t){var o=t.getRootNode&&t.getRootNode();if(e.contains(t))return true;if(o&&Ks(o)){var r=t;do{if(r&&e.isSameNode(r))return true;r=r.parentNode||r.host;}while(r)}return false}p();p();function xo(e){return qe(e).getComputedStyle(e)}p();function eb(e){return ["table","td","th"].indexOf(Lt(e))>=0}p();p();function Ht(e){return ((mr(e)?e.ownerDocument:e.document)||window.document).documentElement}function _n(e){return Lt(e)==="html"?e:e.assignedSlot||e.parentNode||(Ks(e)?e.host:null)||Ht(e)}function dR(e){return !It(e)||xo(e).position==="fixed"?null:e.offsetParent}function fj(e){var t=/firefox/i.test(qs()),o=/Trident/i.test(qs());if(o&&It(e)){var r=xo(e);if(r.position==="fixed")return null}var n=_n(e);for(Ks(n)&&(n=n.host);It(n)&&["html","body"].indexOf(Lt(n))<0;){var i=xo(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode;}return null}function Nr(e){for(var t=qe(e),o=dR(e);o&&eb(o)&&xo(o).position==="static";)o=dR(o);return o&&(Lt(o)==="html"||Lt(o)==="body"&&xo(o).position==="static")?t:o||fj(e)||t}p();function wa(e){return ["top","bottom"].indexOf(e)>=0?"x":"y"}p();function Ra(e,t,o){return _r(e,ka(t,o))}function mR(e,t,o){var r=Ra(e,t,o);return r>o?o:r}p();p();function Fc(){return {top:0,right:0,bottom:0,left:0}}function Vc(e){return Object.assign({},Fc(),e)}p();function $c(e,t){return t.reduce(function(o,r){return o[r]=e,o},{})}var gj=function(t,o){return t=typeof t=="function"?t(Object.assign({},o.rects,{placement:o.placement})):t,Vc(typeof t!="number"?t:$c(t,vi))};function hj(e){var t,o=e.state,r=e.name,n=e.options,i=o.elements.arrow,a=o.modifiersData.popperOffsets,l=Mt(o.placement),s=wa(l),c=[ct,ht].indexOf(l)>=0,u=c?"height":"width";if(!(!i||!a)){var d=gj(n.padding,o),m=Ea(i),g=s==="y"?rt:ct,f=s==="y"?Rt:ht,h=o.rects.reference[u]+o.rects.reference[s]-a[s]-o.rects.popper[u],v=a[s]-o.rects.reference[s],T=Nr(i),y=T?s==="y"?T.clientHeight||0:T.clientWidth||0:0,C=h/2-v/2,b=d[g],w=y-m[u]-d[f],k=y/2-m[u]/2+C,I=Ra(b,k,w),O=s;o.modifiersData[r]=(t={},t[O]=I,t.centerOffset=I-k,t);}}function bj(e){var t=e.state,o=e.options,r=o.element,n=r===void 0?"[data-popper-arrow]":r;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||zc(t.elements.popper,n)&&(t.elements.arrow=n));}var fR={name:"arrow",enabled:true,phase:"main",fn:hj,effect:bj,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};p();p();function gr(e){return e.split("-")[1]}var yj={top:"auto",right:"auto",bottom:"auto",left:"auto"};function vj(e,t){var o=e.x,r=e.y,n=t.devicePixelRatio||1;return {x:Dn(o*n)/n||0,y:Dn(r*n)/n||0}}function gR(e){var t,o=e.popper,r=e.popperRect,n=e.placement,i=e.variation,a=e.offsets,l=e.position,s=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,d=e.isFixed,m=a.x,g=m===void 0?0:m,f=a.y,h=f===void 0?0:f,v=typeof u=="function"?u({x:g,y:h}):{x:g,y:h};g=v.x,h=v.y;var T=a.hasOwnProperty("x"),y=a.hasOwnProperty("y"),C=ct,b=rt,w=window;if(c){var k=Nr(o),I="clientHeight",O="clientWidth";if(k===qe(o)&&(k=Ht(o),xo(k).position!=="static"&&l==="absolute"&&(I="scrollHeight",O="scrollWidth")),k=k,n===rt||(n===ct||n===ht)&&i===Ca){b=Rt;var P=d&&k===w&&w.visualViewport?w.visualViewport.height:k[I];h-=P-r.height,h*=s?1:-1;}if(n===ct||(n===rt||n===Rt)&&i===Ca){C=ht;var _=d&&k===w&&w.visualViewport?w.visualViewport.width:k[O];g-=_-r.width,g*=s?1:-1;}}var D=Object.assign({position:l},c&&yj),L=u===true?vj({x:g,y:h},qe(o)):{x:g,y:h};if(g=L.x,h=L.y,s){var R;return Object.assign({},D,(R={},R[b]=y?"0":"",R[C]=T?"0":"",R.transform=(w.devicePixelRatio||1)<=1?"translate("+g+"px, "+h+"px)":"translate3d("+g+"px, "+h+"px, 0)",R))}return Object.assign({},D,(t={},t[b]=y?h+"px":"",t[C]=T?g+"px":"",t.transform="",t))}function Sj(e){var t=e.state,o=e.options,r=o.gpuAcceleration,n=r===void 0?true:r,i=o.adaptive,a=i===void 0?true:i,l=o.roundOffsets,s=l===void 0?true:l,c={placement:Mt(t.placement),variation:gr(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,gR(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:s})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,gR(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:false,roundOffsets:s})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement});}var hR={name:"computeStyles",enabled:true,phase:"beforeWrite",fn:Sj,data:{}};p();var hd={passive:true};function xj(e){var t=e.state,o=e.instance,r=e.options,n=r.scroll,i=n===void 0?true:n,a=r.resize,l=a===void 0?true:a,s=qe(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&c.forEach(function(u){u.addEventListener("scroll",o.update,hd);}),l&&s.addEventListener("resize",o.update,hd),function(){i&&c.forEach(function(u){u.removeEventListener("scroll",o.update,hd);}),l&&s.removeEventListener("resize",o.update,hd);}}var bR={name:"eventListeners",enabled:true,phase:"write",fn:function(){},effect:xj,data:{}};p();p();var Tj={left:"right",right:"left",bottom:"top",top:"bottom"};function Ys(e){return e.replace(/left|right|bottom|top/g,function(t){return Tj[t]})}p();var Cj={start:"end",end:"start"};function bd(e){return e.replace(/start|end/g,function(t){return Cj[t]})}p();p();p();p();p();function Ia(e){var t=qe(e),o=t.pageXOffset,r=t.pageYOffset;return {scrollLeft:o,scrollTop:r}}function Aa(e){return fr(Ht(e)).left+Ia(e).scrollLeft}function tb(e,t){var o=qe(e),r=Ht(e),n=o.visualViewport,i=r.clientWidth,a=r.clientHeight,l=0,s=0;if(n){i=n.width,a=n.height;var c=Nc();(c||!c&&t==="fixed")&&(l=n.offsetLeft,s=n.offsetTop);}return {width:i,height:a,x:l+Aa(e),y:s}}p();function ob(e){var t,o=Ht(e),r=Ia(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=_r(o.scrollWidth,o.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),a=_r(o.scrollHeight,o.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-r.scrollLeft+Aa(e),s=-r.scrollTop;return xo(n||o).direction==="rtl"&&(l+=_r(o.clientWidth,n?n.clientWidth:0)-i),{width:i,height:a,x:l,y:s}}p();p();p();function Pa(e){var t=xo(e),o=t.overflow,r=t.overflowX,n=t.overflowY;return /auto|scroll|overlay|hidden/.test(o+n+r)}function yd(e){return ["html","body","#document"].indexOf(Lt(e))>=0?e.ownerDocument.body:It(e)&&Pa(e)?e:yd(_n(e))}function Si(e,t){var o;t===void 0&&(t=[]);var r=yd(e),n=r===((o=e.ownerDocument)==null?void 0:o.body),i=qe(r),a=n?[i].concat(i.visualViewport||[],Pa(r)?r:[]):r,l=t.concat(a);return n?l:l.concat(Si(_n(a)))}p();function Xs(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function kj(e,t){var o=fr(e,false,t==="fixed");return o.top=o.top+e.clientTop,o.left=o.left+e.clientLeft,o.bottom=o.top+e.clientHeight,o.right=o.left+e.clientWidth,o.width=e.clientWidth,o.height=e.clientHeight,o.x=o.left,o.y=o.top,o}function yR(e,t,o){return t===fd?Xs(tb(e,o)):mr(t)?kj(t,o):Xs(ob(Ht(e)))}function Ej(e){var t=Si(_n(e)),o=["absolute","fixed"].indexOf(xo(e).position)>=0,r=o&&It(e)?Nr(e):e;return mr(r)?t.filter(function(n){return mr(n)&&zc(n,r)&&Lt(n)!=="body"}):[]}function rb(e,t,o,r){var n=t==="clippingParents"?Ej(e):[].concat(t),i=[].concat(n,[o]),a=i[0],l=i.reduce(function(s,c){var u=yR(e,c,r);return s.top=_r(u.top,s.top),s.right=ka(u.right,s.right),s.bottom=ka(u.bottom,s.bottom),s.left=_r(u.left,s.left),s},yR(e,a,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}p();function Uc(e){var t=e.reference,o=e.element,r=e.placement,n=r?Mt(r):null,i=r?gr(r):null,a=t.x+t.width/2-o.width/2,l=t.y+t.height/2-o.height/2,s;switch(n){case rt:s={x:a,y:t.y-o.height};break;case Rt:s={x:a,y:t.y+t.height};break;case ht:s={x:t.x+t.width,y:l};break;case ct:s={x:t.x-o.width,y:l};break;default:s={x:t.x,y:t.y};}var c=n?wa(n):null;if(c!=null){var u=c==="y"?"height":"width";switch(i){case Bn:s[c]=s[c]-(t[u]/2-o[u]/2);break;case Ca:s[c]=s[c]+(t[u]/2-o[u]/2);break;}}return s}function zr(e,t){t===void 0&&(t={});var o=t,r=o.placement,n=r===void 0?e.placement:r,i=o.strategy,a=i===void 0?e.strategy:i,l=o.boundary,s=l===void 0?cR:l,c=o.rootBoundary,u=c===void 0?fd:c,d=o.elementContext,m=d===void 0?js:d,g=o.altBoundary,f=g===void 0?false:g,h=o.padding,v=h===void 0?0:h,T=Vc(typeof v!="number"?v:$c(v,vi)),y=m===js?uR:js,C=e.rects.popper,b=e.elements[f?y:m],w=rb(mr(b)?b:b.contextElement||Ht(e.elements.popper),s,u,a),k=fr(e.elements.reference),I=Uc({reference:k,element:C,placement:n}),O=Xs(Object.assign({},C,I)),P=m===js?O:k,_={top:w.top-P.top+T.top,bottom:P.bottom-w.bottom+T.bottom,left:w.left-P.left+T.left,right:P.right-w.right+T.right},D=e.modifiersData.offset;if(m===js&&D){var L=D[n];Object.keys(_).forEach(function(R){var z=[ht,Rt].indexOf(R)>=0?1:-1,A=[rt,Rt].indexOf(R)>=0?"y":"x";_[R]+=L[A]*z;});}return _}p();function nb(e,t){t===void 0&&(t={});var o=t,r=o.placement,n=o.boundary,i=o.rootBoundary,a=o.padding,l=o.flipVariations,s=o.allowedAutoPlacements,c=s===void 0?gd:s,u=gr(r),d=u?l?Zh:Zh.filter(function(f){return gr(f)===u}):vi,m=d.filter(function(f){return c.indexOf(f)>=0});m.length===0&&(m=d);var g=m.reduce(function(f,h){return f[h]=zr(e,{placement:h,boundary:n,rootBoundary:i,padding:a})[Mt(h)],f},{});return Object.keys(g).sort(function(f,h){return g[f]-g[h]})}function wj(e){if(Mt(e)===md)return [];var t=Ys(e);return [bd(e),t,bd(t)]}function Rj(e){var t=e.state,o=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var n=o.mainAxis,i=n===void 0?true:n,a=o.altAxis,l=a===void 0?true:a,s=o.fallbackPlacements,c=o.padding,u=o.boundary,d=o.rootBoundary,m=o.altBoundary,g=o.flipVariations,f=g===void 0?true:g,h=o.allowedAutoPlacements,v=t.options.placement,T=Mt(v),y=T===v,C=s||(y||!f?[Ys(v)]:wj(v)),b=[v].concat(C).reduce(function(J,ee){return J.concat(Mt(ee)===md?nb(t,{placement:ee,boundary:u,rootBoundary:d,padding:c,flipVariations:f,allowedAutoPlacements:h}):ee)},[]),w=t.rects.reference,k=t.rects.popper,I=new Map,O=true,P=b[0],_=0;_<b.length;_++){var D=b[_],L=Mt(D),R=gr(D)===Bn,z=[rt,Rt].indexOf(L)>=0,A=z?"width":"height",V=zr(t,{placement:D,boundary:u,rootBoundary:d,altBoundary:m,padding:c}),j=z?R?ht:ct:R?Rt:rt;w[A]>k[A]&&(j=Ys(j));var B=Ys(j),U=[];if(i&&U.push(V[L]<=0),l&&U.push(V[j]<=0,V[B]<=0),U.every(function(J){return J})){P=D,O=false;break}I.set(D,U);}if(O)for(var $=f?3:1,Y=function(ee){var ne=b.find(function(X){var W=I.get(X);if(W)return W.slice(0,ee).every(function(K){return K})});if(ne)return P=ne,"break"},F=$;F>0;F--){var G=Y(F);if(G==="break")break}t.placement!==P&&(t.modifiersData[r]._skip=true,t.placement=P,t.reset=true);}}var vR={name:"flip",enabled:true,phase:"main",fn:Rj,requiresIfExists:["offset"],data:{_skip:false}};p();function SR(e,t,o){return o===void 0&&(o={x:0,y:0}),{top:e.top-t.height-o.y,right:e.right-t.width+o.x,bottom:e.bottom-t.height+o.y,left:e.left-t.width-o.x}}function xR(e){return [rt,ht,Rt,ct].some(function(t){return e[t]>=0})}function Ij(e){var t=e.state,o=e.name,r=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,a=zr(t,{elementContext:"reference"}),l=zr(t,{altBoundary:true}),s=SR(a,r),c=SR(l,n,i),u=xR(s),d=xR(c);t.modifiersData[o]={referenceClippingOffsets:s,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d});}var TR={name:"hide",enabled:true,phase:"main",requiresIfExists:["preventOverflow"],fn:Ij};p();function Aj(e,t,o){var r=Mt(e),n=[ct,rt].indexOf(r)>=0?-1:1,i=typeof o=="function"?o(Object.assign({},t,{placement:e})):o,a=i[0],l=i[1];return a=a||0,l=(l||0)*n,[ct,ht].indexOf(r)>=0?{x:l,y:a}:{x:a,y:l}}function Pj(e){var t=e.state,o=e.options,r=e.name,n=o.offset,i=n===void 0?[0,0]:n,a=gd.reduce(function(u,d){return u[d]=Aj(d,t.rects,i),u},{}),l=a[t.placement],s=l.x,c=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=s,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a;}var CR={name:"offset",enabled:true,phase:"main",requires:["popperOffsets"],fn:Pj};p();function Oj(e){var t=e.state,o=e.name;t.modifiersData[o]=Uc({reference:t.rects.reference,element:t.rects.popper,placement:t.placement});}var kR={name:"popperOffsets",enabled:true,phase:"read",fn:Oj,data:{}};p();p();function ib(e){return e==="x"?"y":"x"}function Lj(e){var t=e.state,o=e.options,r=e.name,n=o.mainAxis,i=n===void 0?true:n,a=o.altAxis,l=a===void 0?false:a,s=o.boundary,c=o.rootBoundary,u=o.altBoundary,d=o.padding,m=o.tether,g=m===void 0?true:m,f=o.tetherOffset,h=f===void 0?0:f,v=zr(t,{boundary:s,rootBoundary:c,padding:d,altBoundary:u}),T=Mt(t.placement),y=gr(t.placement),C=!y,b=wa(T),w=ib(b),k=t.modifiersData.popperOffsets,I=t.rects.reference,O=t.rects.popper,P=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,_=typeof P=="number"?{mainAxis:P,altAxis:P}:Object.assign({mainAxis:0,altAxis:0},P),D=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,L={x:0,y:0};if(k){if(i){var R,z=b==="y"?rt:ct,A=b==="y"?Rt:ht,V=b==="y"?"height":"width",j=k[b],B=j+v[z],U=j-v[A],$=g?-O[V]/2:0,Y=y===Bn?I[V]:O[V],F=y===Bn?-O[V]:-I[V],G=t.elements.arrow,J=g&&G?Ea(G):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Fc(),ne=ee[z],X=ee[A],W=Ra(0,I[V],J[V]),K=C?I[V]/2-$-W-ne-_.mainAxis:Y-W-ne-_.mainAxis,oe=C?-I[V]/2+$+W+X+_.mainAxis:F+W+X+_.mainAxis,re=t.elements.arrow&&Nr(t.elements.arrow),ue=re?b==="y"?re.clientTop||0:re.clientLeft||0:0,Ee=(R=D?.[b])!=null?R:0,q=j+K-Ee-ue,ce=j+oe-Ee,de=Ra(g?ka(B,q):B,j,g?_r(U,ce):U);k[b]=de,L[b]=de-j;}if(l){var Se,$e=b==="x"?rt:ct,We=b==="x"?Rt:ht,Qe=k[w],Co=w==="y"?"height":"width",Uo=Qe+v[$e],po=Qe-v[We],gn=[rt,ct].indexOf(T)!==-1,Hn=(Se=D?.[w])!=null?Se:0,Wn=gn?Uo:Qe-I[Co]-O[Co]-Hn+_.altAxis,jn=gn?Qe+I[Co]+O[Co]-Hn-_.altAxis:po,Kn=g&&gn?mR(Wn,Qe,jn):Ra(g?Wn:Uo,Qe,g?jn:po);k[w]=Kn,L[w]=Kn-Qe;}t.modifiersData[r]=L;}}var ER={name:"preventOverflow",enabled:true,phase:"main",fn:Lj,requiresIfExists:["offset"]};p();p();p();p();function ab(e){return {scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function sb(e){return e===qe(e)||!It(e)?Ia(e):ab(e)}function Mj(e){var t=e.getBoundingClientRect(),o=Dn(t.width)/e.offsetWidth||1,r=Dn(t.height)/e.offsetHeight||1;return o!==1||r!==1}function lb(e,t,o){o===void 0&&(o=false);var r=It(t),n=It(t)&&Mj(t),i=Ht(t),a=fr(e,n,o),l={scrollLeft:0,scrollTop:0},s={x:0,y:0};return (r||!r&&!o)&&((Lt(t)!=="body"||Pa(i))&&(l=sb(t)),It(t)?(s=fr(t,true),s.x+=t.clientLeft,s.y+=t.clientTop):i&&(s.x=Aa(i))),{x:a.left+l.scrollLeft-s.x,y:a.top+l.scrollTop-s.y,width:a.width,height:a.height}}p();function Bj(e){var t=new Map,o=new Set,r=[];e.forEach(function(i){t.set(i.name,i);});function n(i){o.add(i.name);var a=[].concat(i.requires||[],i.requiresIfExists||[]);a.forEach(function(l){if(!o.has(l)){var s=t.get(l);s&&n(s);}}),r.push(i);}return e.forEach(function(i){o.has(i.name)||n(i);}),r}function cb(e){var t=Bj(e);return pR.reduce(function(o,r){return o.concat(t.filter(function(n){return n.phase===r}))},[])}p();function ub(e){var t;return function(){return t||(t=new Promise(function(o){Promise.resolve().then(function(){t=void 0,o(e());});})),t}}p();function pb(e){var t=e.reduce(function(o,r){var n=o[r.name];return o[r.name]=n?Object.assign({},n,r,{options:Object.assign({},n.options,r.options),data:Object.assign({},n.data,r.data)}):r,o},{});return Object.keys(t).map(function(o){return t[o]})}var wR={placement:"bottom",modifiers:[],strategy:"absolute"};function RR(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return !t.some(function(r){return !(r&&typeof r.getBoundingClientRect=="function")})}function IR(e){e===void 0&&(e={});var t=e,o=t.defaultModifiers,r=o===void 0?[]:o,n=t.defaultOptions,i=n===void 0?wR:n;return function(l,s,c){c===void 0&&(c=i);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},wR,i),modifiersData:{},elements:{reference:l,popper:s},attributes:{},styles:{}},d=[],m=false,g={state:u,setOptions:function(T){var y=typeof T=="function"?T(u.options):T;h(),u.options=Object.assign({},i,u.options,y),u.scrollParents={reference:mr(l)?Si(l):l.contextElement?Si(l.contextElement):[],popper:Si(s)};var C=cb(pb([].concat(r,u.options.modifiers)));return u.orderedModifiers=C.filter(function(b){return b.enabled}),f(),g.update()},forceUpdate:function(){if(!m){var T=u.elements,y=T.reference,C=T.popper;if(RR(y,C)){u.rects={reference:lb(y,Nr(C),u.options.strategy==="fixed"),popper:Ea(C)},u.reset=false,u.placement=u.options.placement,u.orderedModifiers.forEach(function(_){return u.modifiersData[_.name]=Object.assign({},_.data)});for(var b=0;b<u.orderedModifiers.length;b++){if(u.reset===true){u.reset=false,b=-1;continue}var w=u.orderedModifiers[b],k=w.fn,I=w.options,O=I===void 0?{}:I,P=w.name;typeof k=="function"&&(u=k({state:u,options:O,name:P,instance:g})||u);}}}},update:ub(function(){return new Promise(function(v){g.forceUpdate(),v(u);})}),destroy:function(){h(),m=true;}};if(!RR(l,s))return g;g.setOptions(c).then(function(v){!m&&c.onFirstUpdate&&c.onFirstUpdate(v);});function f(){u.orderedModifiers.forEach(function(v){var T=v.name,y=v.options,C=y===void 0?{}:y,b=v.effect;if(typeof b=="function"){var w=b({state:u,name:T,instance:g,options:C}),k=function(){};d.push(w||k);}});}function h(){d.forEach(function(v){return v()}),d=[];}return g}}p();var Dj=[bR,kR,hR,_c,CR,vR,ER,fR,TR],db=IR({defaultModifiers:Dj});var _j="tippy-box",FR="tippy-content",Nj="tippy-backdrop",VR="tippy-arrow",$R="tippy-svg-arrow",Oa={passive:true,capture:true},UR=function(){return document.body};function zj(e,t){return {}.hasOwnProperty.call(e,t)}function mb(e,t,o){if(Array.isArray(e)){var r=e[t];return r??(Array.isArray(o)?o[t]:o)}return e}function Sb(e,t){var o={}.toString.call(e);return o.indexOf("[object")===0&&o.indexOf(t+"]")>-1}function GR(e,t){return typeof e=="function"?e.apply(void 0,t):e}function AR(e,t){if(t===0)return e;var o;return function(r){clearTimeout(o),o=setTimeout(function(){e(r);},t);}}function Fj(e,t){var o=Object.assign({},e);return t.forEach(function(r){delete o[r];}),o}function Vj(e){return e.split(/\s+/).filter(Boolean)}function Qs(e){return [].concat(e)}function PR(e,t){e.indexOf(t)===-1&&e.push(t);}function $j(e){return e.filter(function(t,o){return e.indexOf(t)===o})}function Uj(e){return e.split("-")[0]}function Sd(e){return [].slice.call(e)}function OR(e){return Object.keys(e).reduce(function(t,o){return e[o]!==void 0&&(t[o]=e[o]),t},{})}function Gc(){return document.createElement("div")}function Hc(e){return ["Element","Fragment"].some(function(t){return Sb(e,t)})}function Gj(e){return Sb(e,"NodeList")}function Hj(e){return Sb(e,"MouseEvent")}function Wj(e){return !!(e&&e._tippy&&e._tippy.reference===e)}function jj(e){return Hc(e)?[e]:Gj(e)?Sd(e):Array.isArray(e)?e:Sd(document.querySelectorAll(e))}function fb(e,t){e.forEach(function(o){o&&(o.style.transitionDuration=t+"ms");});}function LR(e,t){e.forEach(function(o){o&&o.setAttribute("data-state",t);});}function Kj(e){var t,o=Qs(e),r=o[0];return r!=null&&(t=r.ownerDocument)!=null&&t.body?r.ownerDocument:document}function qj(e,t){var o=t.clientX,r=t.clientY;return e.every(function(n){var i=n.popperRect,a=n.popperState,l=n.props,s=l.interactiveBorder,c=Uj(a.placement),u=a.modifiersData.offset;if(!u)return true;var d=c==="bottom"?u.top.y:0,m=c==="top"?u.bottom.y:0,g=c==="right"?u.left.x:0,f=c==="left"?u.right.x:0,h=i.top-r+d>s,v=r-i.bottom-m>s,T=i.left-o+g>s,y=o-i.right-f>s;return h||v||T||y})}function gb(e,t,o){var r=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[r](n,o);});}function MR(e,t){for(var o=t;o;){var r;if(e.contains(o))return true;o=o.getRootNode==null||(r=o.getRootNode())==null?void 0:r.host;}return false}var ln={isTouch:false},BR=0;function Yj(){ln.isTouch||(ln.isTouch=true,window.performance&&document.addEventListener("mousemove",HR));}function HR(){var e=performance.now();e-BR<20&&(ln.isTouch=false,document.removeEventListener("mousemove",HR)),BR=e;}function Xj(){var e=document.activeElement;if(Wj(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur();}}function Jj(){document.addEventListener("touchstart",Yj,Oa),window.addEventListener("blur",Xj);}var Qj=typeof window<"u"&&typeof document<"u",Zj=Qj?!!window.msCrypto:false;function Js(e){var t=e==="destroy"?"n already-":" ";return [e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function DR(e){var t=/[ \t]{2,}/g,o=/^[ \t]*/gm;return e.replace(t," ").replace(o,"").trim()}function e5(e){return DR(`
56
+ `,textSerializers:a={}}=o||{},l="";return e.nodesBetween(r,n,(s,c,u,d)=>{var f;s.isBlock&&c>r&&(l+=i);let g=a?.[s.type.name];if(g)return u&&(l+=g({node:s,pos:c,parent:u,index:d,range:t})),false;s.isText&&(l+=(f=s?.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,n-c));}),l}function D2(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,o])=>[t,o.spec.toText]))}nn.create({name:"clipboardTextSerializer",addOptions(){return {blockSeparator:void 0}},addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:o}=e,{doc:r,selection:n}=t,{ranges:i}=n,a=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),s=D2(o);return B2(r,{from:a,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:s})}}})]}});var _2=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var o;e.isDestroyed||(t.dom.blur(),(o=window?.getSelection())===null||o===void 0||o.removeAllRanges());}),true),N2=(e=false)=>({commands:t})=>t.setContent("",e),z2=()=>({state:e,tr:t,dispatch:o})=>{let{selection:r}=t,{ranges:n}=r;return o&&n.forEach(({$from:i,$to:a})=>{e.doc.nodesBetween(i.pos,a.pos,(l,s)=>{if(l.type.isText)return;let{doc:c,mapping:u}=t,d=c.resolve(u.map(s)),f=c.resolve(u.map(s+l.nodeSize)),g=d.blockRange(f);if(!g)return;let m=liftTarget(g);if(l.type.isTextblock){let{defaultType:h}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(g.start,h);}(m||m===0)&&t.lift(g,m);});}),true},F2=e=>t=>e(t),V2=()=>({state:e,dispatch:t})=>createParagraphNear(e,t),$2=(e,t)=>({editor:o,tr:r})=>{let{state:n}=o,i=n.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let a=r.mapping.map(t);return r.insert(a,i.content),r.setSelection(new TextSelection(r.doc.resolve(a-1))),true},U2=()=>({tr:e,dispatch:t})=>{let{selection:o}=e,r=o.$anchor.node();if(r.content.size>0)return false;let n=e.selection.$anchor;for(let i=n.depth;i>0;i-=1)if(n.node(i).type===r.type){if(t){let l=n.before(i),s=n.after(i);e.delete(l,s).scrollIntoView();}return true}return false},G2=e=>({tr:t,state:o,dispatch:r})=>{let n=lo(e,o.schema),i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===n){if(r){let s=i.before(a),c=i.after(a);t.delete(s,c).scrollIntoView();}return true}return false},H2=e=>({tr:t,dispatch:o})=>{let{from:r,to:n}=e;return o&&t.delete(r,n),true},W2=()=>({state:e,dispatch:t})=>deleteSelection(e,t),j2=()=>({commands:e})=>e.keyboardShortcut("Enter"),K2=()=>({state:e,dispatch:t})=>exitCode(e,t);function cd(e,t,o={strict:true}){let r=Object.keys(t);return r.length?r.every(n=>o.strict?t[n]===e[n]:L2(t[n])?t[n].test(e[n]):t[n]===e[n]):true}function Kh(e,t,o={}){return e.find(r=>r.type===t&&cd(r.attrs,o))}function q2(e,t,o={}){return !!Kh(e,t,o)}function qh(e,t,o={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&r.offset!==0&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;let n=Kh([...r.node.marks],t,o);if(!n)return;let i=r.index,a=e.start()+r.offset,l=i+1,s=a+r.node.nodeSize;for(Kh([...r.node.marks],t,o);i>0&&n.isInSet(e.parent.child(i-1).marks);)i-=1,a-=e.parent.child(i).nodeSize;for(;l<e.parent.childCount&&q2([...e.parent.child(l).marks],t,o);)s+=e.parent.child(l).nodeSize,l+=1;return {from:a,to:s}}function hi(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var Y2=(e,t={})=>({tr:o,state:r,dispatch:n})=>{let i=hi(e,r.schema),{doc:a,selection:l}=o,{$from:s,from:c,to:u}=l;if(n){let d=qh(s,i,t);if(d&&d.from<=c&&d.to>=u){let f=TextSelection.create(a,d.from,d.to);o.setSelection(f);}}return true},X2=e=>t=>{let o=typeof e=="function"?e(t):e;for(let r=0;r<o.length;r+=1)if(o[r](t))return true;return false};function eR(e){return e instanceof TextSelection}function xa(e=0,t=0,o=0){return Math.min(Math.max(e,t),o)}function J2(e,t=null){if(!t)return null;let o=Selection.atStart(e),r=Selection.atEnd(e);if(t==="start"||t===true)return o;if(t==="end")return r;let n=o.from,i=r.to;return t==="all"?TextSelection.create(e,xa(0,n,i),xa(e.content.size,n,i)):TextSelection.create(e,xa(t,n,i),xa(t,n,i))}function Yh(){return ["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Q2=(e=null,t={})=>({editor:o,view:r,tr:n,dispatch:i})=>{t={scrollIntoView:true,...t};let a=()=>{Yh()&&r.dom.focus(),requestAnimationFrame(()=>{o.isDestroyed||(r.focus(),t?.scrollIntoView&&o.commands.scrollIntoView());});};if(r.hasFocus()&&e===null||e===false)return true;if(i&&e===null&&!eR(o.state.selection))return a(),true;let l=J2(n.doc,e)||o.state.selection,s=o.state.selection.eq(l);return i&&(s||n.setSelection(l),s&&n.storedMarks&&n.setStoredMarks(n.storedMarks),a()),true},Z2=(e,t)=>o=>e.every((r,n)=>t(r,{...o,index:n})),eW=(e,t)=>({tr:o,commands:r})=>r.insertContentAt({from:o.selection.from,to:o.selection.to},e,t),tR=e=>{let t=e.childNodes;for(let o=t.length-1;o>=0;o-=1){let r=t[o];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&tR(r);}return e};function nd(e){let t=`<body>${e}</body>`,o=new window.DOMParser().parseFromString(t,"text/html").body;return tR(o)}function ud(e,t,o){o={slice:true,parseOptions:{},...o};let r=typeof e=="object"&&e!==null,n=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return Fragment$1.fromArray(e.map(l=>t.nodeFromJSON(l)));let a=t.nodeFromJSON(e);return o.errorOnInvalidContent&&a.check(),a}catch(i){if(o.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),ud("",t,o)}if(n){if(o.errorOnInvalidContent){let a=false,l="",s=new Schema({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(a=true,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(o.slice?DOMParser.fromSchema(s).parseSlice(nd(e),o.parseOptions):DOMParser.fromSchema(s).parse(nd(e),o.parseOptions),o.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=DOMParser.fromSchema(t);return o.slice?i.parseSlice(nd(e),o.parseOptions).content:i.parse(nd(e),o.parseOptions)}return ud("",t,o)}function tW(e,t,o){let r=e.steps.length-1;if(r<t)return;let n=e.steps[r];if(!(n instanceof ReplaceStep||n instanceof ReplaceAroundStep))return;let i=e.mapping.maps[r],a=0;i.forEach((l,s,c,u)=>{a===0&&(a=u);}),e.setSelection(Selection.near(e.doc.resolve(a),o));}var oW=e=>!("type"in e),rW=(e,t,o)=>({tr:r,dispatch:n,editor:i})=>{var a;if(n){o={parseOptions:{},updateSelection:true,applyInputRules:false,applyPasteRules:false,...o};let l;try{l=ud(t,i.schema,{parseOptions:{preserveWhitespace:"full",...o.parseOptions},errorOnInvalidContent:(a=o.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});}catch(m){return i.emit("contentError",{editor:i,error:m,disableCollaboration:()=>{console.error("[tiptap error]: Unable to disable collaboration at this point in time");}}),false}let{from:s,to:c}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},u=true,d=true;if((oW(l)?l:[l]).forEach(m=>{m.check(),u=u?m.isText&&m.marks.length===0:false,d=d?m.isBlock:false;}),s===c&&d){let{parent:m}=r.doc.resolve(s);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(s-=1,c+=1);}let g;u?(Array.isArray(t)?g=t.map(m=>m.text||"").join(""):typeof t=="object"&&t&&t.text?g=t.text:g=t,r.insertText(g,s,c)):(g=l,r.replaceWith(s,c,g)),o.updateSelection&&tW(r,r.steps.length-1,-1),o.applyInputRules&&r.setMeta("applyInputRules",{from:s,text:g}),o.applyPasteRules&&r.setMeta("applyPasteRules",{from:s,text:g});}return true},nW=()=>({state:e,dispatch:t})=>joinUp(e,t),iW=()=>({state:e,dispatch:t})=>joinDown(e,t),aW=()=>({state:e,dispatch:t})=>joinBackward(e,t),sW=()=>({state:e,dispatch:t})=>joinForward(e,t),lW=()=>({state:e,dispatch:t,tr:o})=>{try{let r=joinPoint(e.doc,e.selection.$from.pos,-1);return r==null?!1:(o.join(r,2),t&&t(o),!0)}catch{return false}},cW=()=>({state:e,dispatch:t,tr:o})=>{try{let r=joinPoint(e.doc,e.selection.$from.pos,1);return r==null?!1:(o.join(r,2),t&&t(o),!0)}catch{return false}},uW=()=>({state:e,dispatch:t})=>joinTextblockBackward(e,t),pW=()=>({state:e,dispatch:t})=>joinTextblockForward(e,t);function oR(){return typeof navigator<"u"?/Mac/.test(navigator.platform):false}function dW(e){let t=e.split(/-(?!$)/),o=t[t.length-1];o==="Space"&&(o=" ");let r,n,i,a;for(let l=0;l<t.length-1;l+=1){let s=t[l];if(/^(cmd|meta|m)$/i.test(s))a=true;else if(/^a(lt)?$/i.test(s))r=true;else if(/^(c|ctrl|control)$/i.test(s))n=true;else if(/^s(hift)?$/i.test(s))i=true;else if(/^mod$/i.test(s))Yh()||oR()?a=true:n=true;else throw new Error(`Unrecognized modifier name: ${s}`)}return r&&(o=`Alt-${o}`),n&&(o=`Ctrl-${o}`),a&&(o=`Meta-${o}`),i&&(o=`Shift-${o}`),o}var mW=e=>({editor:t,view:o,tr:r,dispatch:n})=>{let i=dW(e).split(/-(?!$)/),a=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:true,cancelable:true}),s=t.captureTransaction(()=>{o.someProp("handleKeyDown",c=>c(o,l));});return s?.steps.forEach(c=>{let u=c.map(r.mapping);u&&n&&r.maybeStep(u);}),true};function Xh(e,t,o={}){let{from:r,to:n,empty:i}=e.selection,a=t?lo(t,e.schema):null,l=[];e.doc.nodesBetween(r,n,(d,f)=>{if(d.isText)return;let g=Math.max(r,f),m=Math.min(n,f+d.nodeSize);l.push({node:d,from:g,to:m});});let s=n-r,c=l.filter(d=>a?a.name===d.node.type.name:true).filter(d=>cd(d.node.attrs,o,{strict:false}));return i?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=s}var fW=(e,t={})=>({state:o,dispatch:r})=>{let n=lo(e,o.schema);return Xh(o,n,t)?lift(o,r):false},gW=()=>({state:e,dispatch:t})=>liftEmptyBlock(e,t),hW=e=>({state:t,dispatch:o})=>{let r=lo(e,t.schema);return liftListItem(r)(t,o)},bW=()=>({state:e,dispatch:t})=>newlineInCode(e,t);function rR(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function jw(e,t){let o=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,n)=>(o.includes(n)||(r[n]=e[n]),r),{})}var yW=(e,t)=>({tr:o,state:r,dispatch:n})=>{let i=null,a=null,l=rR(typeof e=="string"?e:e.name,r.schema);return l?(l==="node"&&(i=lo(e,r.schema)),l==="mark"&&(a=hi(e,r.schema)),n&&o.selection.ranges.forEach(s=>{r.doc.nodesBetween(s.$from.pos,s.$to.pos,(c,u)=>{i&&i===c.type&&o.setNodeMarkup(u,void 0,jw(c.attrs,t)),a&&c.marks.length&&c.marks.forEach(d=>{a===d.type&&o.addMark(u,u+c.nodeSize,a.create(jw(d.attrs,t)));});});}),true):false},vW=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),true),SW=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),xW=()=>({state:e,dispatch:t})=>selectNodeBackward(e,t),TW=()=>({state:e,dispatch:t})=>selectNodeForward(e,t),CW=()=>({state:e,dispatch:t})=>selectParentNode(e,t),kW=()=>({state:e,dispatch:t})=>selectTextblockEnd(e,t),EW=()=>({state:e,dispatch:t})=>selectTextblockStart(e,t);function wW(e,t,o={},r={}){return ud(e,t,{slice:false,parseOptions:o,errorOnInvalidContent:r.errorOnInvalidContent})}var RW=(e,t=false,o={},r={})=>({editor:n,tr:i,dispatch:a,commands:l})=>{var s,c;let{doc:u}=i;if(o.preserveWhitespace!=="full"){let d=wW(e,n.schema,o,{errorOnInvalidContent:(s=r.errorOnInvalidContent)!==null&&s!==void 0?s:n.options.enableContentCheck});return a&&i.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),true}return a&&i.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:u.content.size},e,{parseOptions:o,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:n.options.enableContentCheck})};function IW(e,t){let o=hi(t,e.schema),{from:r,to:n,empty:i}=e.selection,a=[];i?(e.storedMarks&&a.push(...e.storedMarks),a.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,n,s=>{a.push(...s.marks);});let l=a.find(s=>s.type.name===o.name);return l?{...l.attrs}:{}}function AW(e){for(let t=0;t<e.edgeCount;t+=1){let{type:o}=e.edge(t);if(o.isTextblock&&!o.hasRequiredAttrs())return o}return null}function PW(e,t){for(let o=e.depth;o>0;o-=1){let r=e.node(o);if(t(r))return {pos:o>0?e.before(o):0,start:e.start(o),depth:o,node:r}}}function Jh(e){return t=>PW(t.$from,e)}function nR(e,t,o){let r=[];return e===t?o.resolve(e).marks().forEach(n=>{let i=o.resolve(e),a=qh(i,n.type);a&&r.push({mark:n,...a});}):o.nodesBetween(e,t,(n,i)=>{!n||n?.nodeSize===void 0||r.push(...n.marks.map(a=>({from:i,to:i+n.nodeSize,mark:a})));}),r}function sd(e,t,o){return Object.fromEntries(Object.entries(o).filter(([r])=>{let n=e.find(i=>i.type===t&&i.name===r);return n?n.attribute.keepOnSplit:false}))}function OW(e,t,o={}){let{empty:r,ranges:n}=e.selection,i=t?hi(t,e.schema):null;if(r)return !!(e.storedMarks||e.selection.$from.marks()).filter(d=>i?i.name===d.type.name:true).find(d=>cd(d.attrs,o,{strict:false}));let a=0,l=[];if(n.forEach(({$from:d,$to:f})=>{let g=d.pos,m=f.pos;e.doc.nodesBetween(g,m,(h,y)=>{if(!h.isText&&!h.marks.length)return;let S=Math.max(g,y),v=Math.min(m,y+h.nodeSize),C=v-S;a+=C,l.push(...h.marks.map(b=>({mark:b,from:S,to:v})));});}),a===0)return false;let s=l.filter(d=>i?i.name===d.mark.type.name:true).filter(d=>cd(d.mark.attrs,o,{strict:false})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):true).reduce((d,f)=>d+f.to-f.from,0);return (s>0?s+c:s)>=a}function Kw(e,t){let{nodeExtensions:o}=P2(t),r=o.find(a=>a.name===e);if(!r)return false;let n={name:r.name,options:r.options,storage:r.storage},i=so(vo(r,"group",n));return typeof i!="string"?false:i.split(" ").includes("list")}function iR(e,{checkChildren:t=true,ignoreWhitespace:o=false}={}){var r;if(o){if(e.type.name==="hardBreak")return true;if(e.isText)return /^\s*$/m.test((r=e.text)!==null&&r!==void 0?r:"")}if(e.isText)return !e.text;if(e.isAtom||e.isLeaf)return false;if(e.content.childCount===0)return true;if(t){let n=true;return e.content.forEach(i=>{n!==false&&(iR(i,{ignoreWhitespace:o,checkChildren:t})||(n=false));}),n}return false}function LW(e,t,o){var r;let{selection:n}=t,i=null;if(eR(n)&&(i=n.$cursor),i){let l=(r=e.storedMarks)!==null&&r!==void 0?r:i.marks();return !!o.isInSet(l)||!l.some(s=>s.type.excludes(o))}let{ranges:a}=n;return a.some(({$from:l,$to:s})=>{let c=l.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(o):false;return e.doc.nodesBetween(l.pos,s.pos,(u,d,f)=>{if(c)return false;if(u.isInline){let g=!f||f.type.allowsMarkType(o),m=!!o.isInSet(u.marks)||!u.marks.some(h=>h.type.excludes(o));c=g&&m;}return !c}),c})}var MW=(e,t={})=>({tr:o,state:r,dispatch:n})=>{let{selection:i}=o,{empty:a,ranges:l}=i,s=hi(e,r.schema);if(n)if(a){let c=IW(r,s);o.addStoredMark(s.create({...c,...t}));}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,g)=>{let m=Math.max(g,u),h=Math.min(g+f.nodeSize,d);f.marks.find(S=>S.type===s)?f.marks.forEach(S=>{s===S.type&&o.addMark(m,h,s.create({...S.attrs,...t}));}):o.addMark(m,h,s.create(t));});});return LW(r,o,s)},BW=(e,t)=>({tr:o})=>(o.setMeta(e,t),true),DW=(e,t={})=>({state:o,dispatch:r,chain:n})=>{let i=lo(e,o.schema);return i.isTextblock?n().command(({commands:a})=>setBlockType(i,t)(o)?true:a.clearNodes()).command(({state:a})=>setBlockType(i,t)(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),false)},_W=e=>({tr:t,dispatch:o})=>{if(o){let{doc:r}=t,n=xa(e,0,r.content.size),i=NodeSelection.create(r,n);t.setSelection(i);}return true},NW=e=>({tr:t,dispatch:o})=>{if(o){let{doc:r}=t,{from:n,to:i}=typeof e=="number"?{from:e,to:e}:e,a=TextSelection.atStart(r).from,l=TextSelection.atEnd(r).to,s=xa(n,a,l),c=xa(i,a,l),u=TextSelection.create(r,s,c);t.setSelection(u);}return true},zW=e=>({state:t,dispatch:o})=>{let r=lo(e,t.schema);return sinkListItem(r)(t,o)};function qw(e,t){let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(o){let r=o.filter(n=>t?.includes(n.type.name));e.tr.ensureMarks(r);}}var FW=({keepMarks:e=true}={})=>({tr:t,state:o,dispatch:r,editor:n})=>{let{selection:i,doc:a}=t,{$from:l,$to:s}=i,c=n.extensionManager.attributes,u=sd(c,l.node().type.name,l.node().attrs);if(i instanceof NodeSelection&&i.node.isBlock)return !l.parentOffset||!canSplit(a,l.pos)?false:(r&&(e&&qw(o,n.extensionManager.splittableMarks),t.split(l.pos).scrollIntoView()),true);if(!l.parent.isBlock)return false;let d=s.parentOffset===s.parent.content.size,f=l.depth===0?void 0:AW(l.node(-1).contentMatchAt(l.indexAfter(-1))),g=d&&f?[{type:f,attrs:u}]:void 0,m=canSplit(t.doc,t.mapping.map(l.pos),1,g);if(!g&&!m&&canSplit(t.doc,t.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(m=true,g=f?[{type:f,attrs:u}]:void 0),r){if(m&&(i instanceof TextSelection&&t.deleteSelection(),t.split(t.mapping.map(l.pos),1,g),f&&!d&&!l.parentOffset&&l.parent.type!==f)){let h=t.mapping.map(l.before()),y=t.doc.resolve(h);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&t.setNodeMarkup(t.mapping.map(l.before()),f);}e&&qw(o,n.extensionManager.splittableMarks),t.scrollIntoView();}return m},VW=(e,t={})=>({tr:o,state:r,dispatch:n,editor:i})=>{var a;let l=lo(e,r.schema),{$from:s,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||s.depth<2||!s.sameParent(c))return false;let d=s.node(-1);if(d.type!==l)return false;let f=i.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==l||s.index(-2)!==s.node(-2).childCount-1)return false;if(n){let S=Fragment$1.empty,v=s.index(-1)?1:s.index(-2)?2:3;for(let O=s.depth-v;O>=s.depth-3;O-=1)S=Fragment$1.from(s.node(O).copy(S));let C=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,b={...sd(f,s.node().type.name,s.node().attrs),...t},k=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(b))||void 0;S=S.append(Fragment$1.from(l.createAndFill(null,k)||void 0));let w=s.before(s.depth-(v-1));o.replace(w,s.after(-C),new Slice(S,4-v,0));let R=-1;o.doc.nodesBetween(w,o.doc.content.size,(O,A)=>{if(R>-1)return false;O.isTextblock&&O.content.size===0&&(R=A+1);}),R>-1&&o.setSelection(TextSelection.near(o.doc.resolve(R))),o.scrollIntoView();}return true}let g=c.pos===s.end()?d.contentMatchAt(0).defaultType:null,m={...sd(f,d.type.name,d.attrs),...t},h={...sd(f,s.node().type.name,s.node().attrs),...t};o.delete(s.pos,c.pos);let y=g?[{type:l,attrs:m},{type:g,attrs:h}]:[{type:l,attrs:m}];if(!canSplit(o.doc,s.pos,2))return false;if(n){let{selection:S,storedMarks:v}=r,{splittableMarks:C}=i.extensionManager,b=v||S.$to.parentOffset&&S.$from.marks();if(o.split(s.pos,2,y).scrollIntoView(),!b||!n)return true;let k=b.filter(w=>C.includes(w.type.name));o.ensureMarks(k);}return true},Gh=(e,t)=>{let o=Jh(a=>a.type===t)(e.selection);if(!o)return true;let r=e.doc.resolve(Math.max(0,o.pos-1)).before(o.depth);if(r===void 0)return true;let n=e.doc.nodeAt(r);return o.node.type===n?.type&&canJoin(e.doc,o.pos)&&e.join(o.pos),true},Hh=(e,t)=>{let o=Jh(a=>a.type===t)(e.selection);if(!o)return true;let r=e.doc.resolve(o.start).after(o.depth);if(r===void 0)return true;let n=e.doc.nodeAt(r);return o.node.type===n?.type&&canJoin(e.doc,r)&&e.join(r),true},$W=(e,t,o,r={})=>({editor:n,tr:i,state:a,dispatch:l,chain:s,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=n.extensionManager,g=lo(e,a.schema),m=lo(t,a.schema),{selection:h,storedMarks:y}=a,{$from:S,$to:v}=h,C=S.blockRange(v),b=y||h.$to.parentOffset&&h.$from.marks();if(!C)return false;let k=Jh(w=>Kw(w.type.name,d))(h);if(C.depth>=1&&k&&C.depth-k.depth<=1){if(k.node.type===g)return c.liftListItem(m);if(Kw(k.node.type.name,d)&&g.validContent(k.node.content)&&l)return s().command(()=>(i.setNodeMarkup(k.pos,g),true)).command(()=>Gh(i,g)).command(()=>Hh(i,g)).run()}return !o||!b||!l?s().command(()=>u().wrapInList(g,r)?true:c.clearNodes()).wrapInList(g,r).command(()=>Gh(i,g)).command(()=>Hh(i,g)).run():s().command(()=>{let w=u().wrapInList(g,r),R=b.filter(O=>f.includes(O.type.name));return i.ensureMarks(R),w?true:c.clearNodes()}).wrapInList(g,r).command(()=>Gh(i,g)).command(()=>Hh(i,g)).run()},UW=(e,t={},o={})=>({state:r,commands:n})=>{let{extendEmptyMarkRange:i=false}=o,a=hi(e,r.schema);return OW(r,a,t)?n.unsetMark(a,{extendEmptyMarkRange:i}):n.setMark(a,t)},GW=(e,t,o={})=>({state:r,commands:n})=>{let i=lo(e,r.schema),a=lo(t,r.schema),l=Xh(r,i,o),s;return r.selection.$anchor.sameParent(r.selection.$head)&&(s=r.selection.$anchor.parent.attrs),l?n.setNode(a,s):n.setNode(i,{...s,...o})},HW=(e,t={})=>({state:o,commands:r})=>{let n=lo(e,o.schema);return Xh(o,n,t)?r.lift(n):r.wrapIn(n,t)},WW=()=>({state:e,dispatch:t})=>{let o=e.plugins;for(let r=0;r<o.length;r+=1){let n=o[r],i;if(n.spec.isInputRules&&(i=n.getState(e))){if(t){let a=e.tr,l=i.transform;for(let s=l.steps.length-1;s>=0;s-=1)a.step(l.steps[s].invert(l.docs[s]));if(i.text){let s=a.doc.resolve(i.from).marks();a.replaceWith(i.from,i.to,e.schema.text(i.text,s));}else a.delete(i.from,i.to);}return true}}return false},jW=()=>({tr:e,dispatch:t})=>{let{selection:o}=e,{empty:r,ranges:n}=o;return r||t&&n.forEach(i=>{e.removeMark(i.$from.pos,i.$to.pos);}),true},KW=(e,t={})=>({tr:o,state:r,dispatch:n})=>{var i;let{extendEmptyMarkRange:a=false}=t,{selection:l}=o,s=hi(e,r.schema),{$from:c,empty:u,ranges:d}=l;if(!n)return true;if(u&&a){let{from:f,to:g}=l,m=(i=c.marks().find(y=>y.type===s))===null||i===void 0?void 0:i.attrs,h=qh(c,s,m);h&&(f=h.from,g=h.to),o.removeMark(f,g,s);}else d.forEach(f=>{o.removeMark(f.$from.pos,f.$to.pos,s);});return o.removeStoredMark(s),true},qW=(e,t={})=>({tr:o,state:r,dispatch:n})=>{let i=null,a=null,l=rR(typeof e=="string"?e:e.name,r.schema);return l?(l==="node"&&(i=lo(e,r.schema)),l==="mark"&&(a=hi(e,r.schema)),n&&o.selection.ranges.forEach(s=>{let c=s.$from.pos,u=s.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{i&&i===d.type&&o.setNodeMarkup(f,void 0,{...d.attrs,...t}),a&&d.marks.length&&d.marks.forEach(g=>{if(a===g.type){let m=Math.max(f,c),h=Math.min(f+d.nodeSize,u);o.addMark(m,h,a.create({...g.attrs,...t}));}});});}),true):false},YW=(e,t={})=>({state:o,dispatch:r})=>{let n=lo(e,o.schema);return wrapIn(n,t)(o,r)},XW=(e,t={})=>({state:o,dispatch:r})=>{let n=lo(e,o.schema);return wrapInList(n,t)(o,r)},JW=Object.freeze({__proto__:null,blur:_2,clearContent:N2,clearNodes:z2,command:F2,createParagraphNear:V2,cut:$2,deleteCurrentNode:U2,deleteNode:G2,deleteRange:H2,deleteSelection:W2,enter:j2,exitCode:K2,extendMarkRange:Y2,first:X2,focus:Q2,forEach:Z2,insertContent:eW,insertContentAt:rW,joinBackward:aW,joinDown:iW,joinForward:sW,joinItemBackward:lW,joinItemForward:cW,joinTextblockBackward:uW,joinTextblockForward:pW,joinUp:nW,keyboardShortcut:mW,lift:fW,liftEmptyBlock:gW,liftListItem:hW,newlineInCode:bW,resetAttributes:yW,scrollIntoView:vW,selectAll:SW,selectNodeBackward:xW,selectNodeForward:TW,selectParentNode:CW,selectTextblockEnd:kW,selectTextblockStart:EW,setContent:RW,setMark:MW,setMeta:BW,setNode:DW,setNodeSelection:_W,setTextSelection:NW,sinkListItem:zW,splitBlock:FW,splitListItem:VW,toggleList:$W,toggleMark:UW,toggleNode:GW,toggleWrap:HW,undoInputRule:WW,unsetAllMarks:jW,unsetMark:KW,updateAttributes:qW,wrapIn:YW,wrapInList:XW});nn.create({name:"commands",addCommands(){return {...JW}}});nn.create({name:"editable",addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}});nn.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return [new Plugin({key:new PluginKey("focusEvents"),props:{handleDOMEvents:{focus:(t,o)=>{e.isFocused=true;let r=e.state.tr.setMeta("focus",{event:o}).setMeta("addToHistory",false);return t.dispatch(r),false},blur:(t,o)=>{e.isFocused=false;let r=e.state.tr.setMeta("blur",{event:o}).setMeta("addToHistory",false);return t.dispatch(r),false}}}})]}});nn.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:l})=>{let{selection:s,doc:c}=l,{empty:u,$anchor:d}=s,{pos:f,parent:g}=d,m=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,h=m.parent.type.spec.isolating,y=d.pos-d.parentOffset,S=h&&m.parent.childCount===1?y===d.pos:Selection.atStart(c).from===f;return !u||!g.type.isTextblock||g.textContent.length||!S||S&&d.parent.type.name==="paragraph"?false:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},n={...r},i={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Yh()||oR()?i:n},addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("clearDocument"),appendTransaction:(e,t,o)=>{let r=e.some(h=>h.docChanged)&&!t.doc.eq(o.doc),n=e.some(h=>h.getMeta("preventClearDocument"));if(!r||n)return;let{empty:i,from:a,to:l}=t.selection,s=Selection.atStart(t.doc).from,c=Selection.atEnd(t.doc).to;if(i||!(a===s&&l===c)||!iR(o.doc))return;let f=o.tr,g=Qw({state:o,transaction:f}),{commands:m}=new Wh({editor:this.editor,state:g});if(m.clearNodes(),!!f.steps.length)return f}})]}});nn.create({name:"tabindex",addProseMirrorPlugins(){return [new Plugin({key:new PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});function Qh(e){return new ld({find:e.find,handler:({state:t,range:o,match:r})=>{let n=so(e.getAttributes,void 0,r);if(n===false||n===null)return null;let{tr:i}=t,a=r[r.length-1],l=r[0];if(a){let s=l.search(/\S/),c=o.from+l.indexOf(a),u=c+a.length;if(nR(o.from,o.to,t.doc).filter(g=>g.mark.type.excluded.find(h=>h===e.type&&h!==g.mark.type)).filter(g=>g.to>c).length)return null;u<o.to&&i.delete(u,o.to),c>o.from&&i.delete(o.from+s,c);let f=o.from+s+a.length;i.addMark(o.from+s,f,e.type.create(n||{})),i.removeStoredMark(e.type);}}})}function aR(e){return new ld({find:e.find,handler:({state:t,range:o,match:r})=>{let n=so(e.getAttributes,void 0,r)||{},{tr:i}=t,a=o.from,l=o.to,s=e.type.create(n);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=a+c;u>l?u=l:l=u+r[1].length;let d=r[0][r[0].length-1];i.insertText(d,a+r[0].length-1),i.replaceWith(u,l,s);}else if(r[0]){let c=e.type.isInline?a:a-1;i.insert(c,e.type.create(n)).delete(i.mapping.map(a),i.mapping.map(l));}i.scrollIntoView();}})}var pd=class e{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=so(vo(this,"addOptions",{name:this.name}))),this.storage=so(vo(this,"addStorage",{name:this.name,options:this.options}))||{};}static create(t={}){return new e(t)}configure(t={}){let o=this.extend({...this.config,addOptions:()=>md(this.options,t)});return o.name=this.name,o.parent=this.parent,o}extend(t={}){let o=new e(t);return o.parent=this,this.child=o,o.name=t.name?t.name:o.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${o.name}".`),o.options=so(vo(o,"addOptions",{name:o.name})),o.storage=so(vo(o,"addStorage",{name:o.name,options:o.options})),o}static handleExit({editor:t,mark:o}){let{tr:r}=t.state,n=t.state.selection.$from;if(n.pos===n.end()){let a=n.marks();if(!!!a.find(c=>c?.type.name===o.name))return false;let s=a.find(c=>c?.type.name===o.name);return s&&r.removeStoredMark(s),r.insertText(" ",n.pos),t.view.dispatch(r),true}return false}},dd=class e{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=so(vo(this,"addOptions",{name:this.name}))),this.storage=so(vo(this,"addStorage",{name:this.name,options:this.options}))||{};}static create(t={}){return new e(t)}configure(t={}){let o=this.extend({...this.config,addOptions:()=>md(this.options,t)});return o.name=this.name,o.parent=this.parent,o}extend(t={}){let o=new e(t);return o.parent=this,this.child=o,o.name=t.name?t.name:o.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${o.name}".`),o.options=so(vo(o,"addOptions",{name:o.name})),o.storage=so(vo(o,"addStorage",{name:o.name,options:o.options})),o}};function Zh(e){return new jh({find:e.find,handler:({state:t,range:o,match:r,pasteEvent:n})=>{let i=so(e.getAttributes,void 0,r,n);if(i===false||i===null)return null;let{tr:a}=t,l=r[r.length-1],s=r[0],c=o.to;if(l){let u=s.search(/\S/),d=o.from+s.indexOf(l),f=d+l.length;if(nR(o.from,o.to,t.doc).filter(m=>m.mark.type.excluded.find(y=>y===e.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;f<o.to&&a.delete(f,o.to),d>o.from&&a.delete(o.from+u,d),c=o.from+u+l.length,a.addMark(o.from+u,c,e.type.create(i||{})),a.removeStoredMark(e.type);}}})}var QW=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,ZW=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,ej=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,tj=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,sR=pd.create({name:"bold",addOptions(){return {HTMLAttributes:{}}},parseHTML(){return [{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return ["strong",Zw(this.options.HTMLAttributes,e),0]},addCommands(){return {setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return {"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return [Qh({find:QW,type:this.type}),Qh({find:ej,type:this.type})]},addPasteRules(){return [Zh({find:ZW,type:this.type}),Zh({find:tj,type:this.type})]}});p();var oj=/(?:^|\s)((?:\{\{)([a-zA-Z0-9]+)(?:\}\}))$/,rj=dd.create({name:"variable",group:"inline",content:"text*",marks:"_",atom:false,inline:true,selectable:true,addAttributes(){return {varName:{default:"",parseHTML:e=>e.innerText}}},addInputRules(){return [aR({find:oj,type:this.type,getAttributes:e=>({varName:e[0]})})]},renderHTML({node:e}){return ["code",{class:"bespoke-var"},e.attrs.varName.trim()]},parseHTML(){return [{tag:'code[class="bespoke-var"]'}]},toDOM(){return ["code",{class:"bespoke-var"},0]}}),lR=rj;p();var cR=nn.create({name:"VariablesStorage",addStorage(){return {suggestions:[]}}});p();p();p();p();var rt="top",wt="bottom",gt="right",ct="left",fd="auto",bi=[rt,wt,gt,ct],Ln="start",Ta="end",uR="clippingParents",gd="viewport",Hs="popper",pR="reference",eb=bi.reduce(function(e,t){return e.concat([t+"-"+Ln,t+"-"+Ta])},[]),hd=[].concat(bi,[fd]).reduce(function(e,t){return e.concat([t,t+"-"+Ln,t+"-"+Ta])},[]),nj="beforeRead",ij="read",aj="afterRead",sj="beforeMain",lj="main",cj="afterMain",uj="beforeWrite",pj="write",dj="afterWrite",dR=[nj,ij,aj,sj,lj,cj,uj,pj,dj];p();p();p();function Lt(e){return e?(e.nodeName||"").toLowerCase():null}p();p();function Ke(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function dr(e){var t=Ke(e).Element;return e instanceof t||e instanceof Element}function Rt(e){var t=Ke(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Ws(e){if(typeof ShadowRoot>"u")return false;var t=Ke(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function mj(e){var t=e.state;Object.keys(t.elements).forEach(function(o){var r=t.styles[o]||{},n=t.attributes[o]||{},i=t.elements[o];!Rt(i)||!Lt(i)||(Object.assign(i.style,r),Object.keys(n).forEach(function(a){var l=n[a];l===false?i.removeAttribute(a):i.setAttribute(a,l===true?"":l);}));});}function fj(e){var t=e.state,o={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,o.popper),t.styles=o,t.elements.arrow&&Object.assign(t.elements.arrow.style,o.arrow),function(){Object.keys(t.elements).forEach(function(r){var n=t.elements[r],i=t.attributes[r]||{},a=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:o[r]),l=a.reduce(function(s,c){return s[c]="",s},{});!Rt(n)||!Lt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(s){n.removeAttribute(s);}));});}}var _c={name:"applyStyles",enabled:true,phase:"write",fn:mj,effect:fj,requires:["computeStyles"]};p();p();function Mt(e){return e.split("-")[0]}p();p();p();var Br=Math.max,Ca=Math.min,Mn=Math.round;p();p();function js(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Nc(){return !/^((?!chrome|android).)*safari/i.test(js())}function mr(e,t,o){t===void 0&&(t=false),o===void 0&&(o=false);var r=e.getBoundingClientRect(),n=1,i=1;t&&Rt(e)&&(n=e.offsetWidth>0&&Mn(r.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Mn(r.height)/e.offsetHeight||1);var a=dr(e)?Ke(e):window,l=a.visualViewport,s=!Nc()&&o,c=(r.left+(s&&l?l.offsetLeft:0))/n,u=(r.top+(s&&l?l.offsetTop:0))/i,d=r.width/n,f=r.height/i;return {width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function ka(e){var t=mr(e),o=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-o)<=1&&(o=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:o,height:r}}p();function zc(e,t){var o=t.getRootNode&&t.getRootNode();if(e.contains(t))return true;if(o&&Ws(o)){var r=t;do{if(r&&e.isSameNode(r))return true;r=r.parentNode||r.host;}while(r)}return false}p();p();function So(e){return Ke(e).getComputedStyle(e)}p();function tb(e){return ["table","td","th"].indexOf(Lt(e))>=0}p();p();function Ht(e){return ((dr(e)?e.ownerDocument:e.document)||window.document).documentElement}function Bn(e){return Lt(e)==="html"?e:e.assignedSlot||e.parentNode||(Ws(e)?e.host:null)||Ht(e)}function mR(e){return !Rt(e)||So(e).position==="fixed"?null:e.offsetParent}function gj(e){var t=/firefox/i.test(js()),o=/Trident/i.test(js());if(o&&Rt(e)){var r=So(e);if(r.position==="fixed")return null}var n=Bn(e);for(Ws(n)&&(n=n.host);Rt(n)&&["html","body"].indexOf(Lt(n))<0;){var i=So(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode;}return null}function Dr(e){for(var t=Ke(e),o=mR(e);o&&tb(o)&&So(o).position==="static";)o=mR(o);return o&&(Lt(o)==="html"||Lt(o)==="body"&&So(o).position==="static")?t:o||gj(e)||t}p();function Ea(e){return ["top","bottom"].indexOf(e)>=0?"x":"y"}p();function wa(e,t,o){return Br(e,Ca(t,o))}function fR(e,t,o){var r=wa(e,t,o);return r>o?o:r}p();p();function Fc(){return {top:0,right:0,bottom:0,left:0}}function Vc(e){return Object.assign({},Fc(),e)}p();function $c(e,t){return t.reduce(function(o,r){return o[r]=e,o},{})}var hj=function(t,o){return t=typeof t=="function"?t(Object.assign({},o.rects,{placement:o.placement})):t,Vc(typeof t!="number"?t:$c(t,bi))};function bj(e){var t,o=e.state,r=e.name,n=e.options,i=o.elements.arrow,a=o.modifiersData.popperOffsets,l=Mt(o.placement),s=Ea(l),c=[ct,gt].indexOf(l)>=0,u=c?"height":"width";if(!(!i||!a)){var d=hj(n.padding,o),f=ka(i),g=s==="y"?rt:ct,m=s==="y"?wt:gt,h=o.rects.reference[u]+o.rects.reference[s]-a[s]-o.rects.popper[u],y=a[s]-o.rects.reference[s],S=Dr(i),v=S?s==="y"?S.clientHeight||0:S.clientWidth||0:0,C=h/2-y/2,b=d[g],k=v-f[u]-d[m],w=v/2-f[u]/2+C,R=wa(b,w,k),O=s;o.modifiersData[r]=(t={},t[O]=R,t.centerOffset=R-w,t);}}function yj(e){var t=e.state,o=e.options,r=o.element,n=r===void 0?"[data-popper-arrow]":r;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||zc(t.elements.popper,n)&&(t.elements.arrow=n));}var gR={name:"arrow",enabled:true,phase:"main",fn:bj,effect:yj,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};p();p();function fr(e){return e.split("-")[1]}var vj={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Sj(e,t){var o=e.x,r=e.y,n=t.devicePixelRatio||1;return {x:Mn(o*n)/n||0,y:Mn(r*n)/n||0}}function hR(e){var t,o=e.popper,r=e.popperRect,n=e.placement,i=e.variation,a=e.offsets,l=e.position,s=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=a.x,g=f===void 0?0:f,m=a.y,h=m===void 0?0:m,y=typeof u=="function"?u({x:g,y:h}):{x:g,y:h};g=y.x,h=y.y;var S=a.hasOwnProperty("x"),v=a.hasOwnProperty("y"),C=ct,b=rt,k=window;if(c){var w=Dr(o),R="clientHeight",O="clientWidth";if(w===Ke(o)&&(w=Ht(o),So(w).position!=="static"&&l==="absolute"&&(R="scrollHeight",O="scrollWidth")),w=w,n===rt||(n===ct||n===gt)&&i===Ta){b=wt;var A=d&&w===k&&k.visualViewport?k.visualViewport.height:w[R];h-=A-r.height,h*=s?1:-1;}if(n===ct||(n===rt||n===wt)&&i===Ta){C=gt;var B=d&&w===k&&k.visualViewport?k.visualViewport.width:w[O];g-=B-r.width,g*=s?1:-1;}}var _=Object.assign({position:l},c&&vj),P=u===true?Sj({x:g,y:h},Ke(o)):{x:g,y:h};if(g=P.x,h=P.y,s){var I;return Object.assign({},_,(I={},I[b]=v?"0":"",I[C]=S?"0":"",I.transform=(k.devicePixelRatio||1)<=1?"translate("+g+"px, "+h+"px)":"translate3d("+g+"px, "+h+"px, 0)",I))}return Object.assign({},_,(t={},t[b]=v?h+"px":"",t[C]=S?g+"px":"",t.transform="",t))}function xj(e){var t=e.state,o=e.options,r=o.gpuAcceleration,n=r===void 0?true:r,i=o.adaptive,a=i===void 0?true:i,l=o.roundOffsets,s=l===void 0?true:l,c={placement:Mt(t.placement),variation:fr(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,hR(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:s})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,hR(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:false,roundOffsets:s})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement});}var bR={name:"computeStyles",enabled:true,phase:"beforeWrite",fn:xj,data:{}};p();var bd={passive:true};function Tj(e){var t=e.state,o=e.instance,r=e.options,n=r.scroll,i=n===void 0?true:n,a=r.resize,l=a===void 0?true:a,s=Ke(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&c.forEach(function(u){u.addEventListener("scroll",o.update,bd);}),l&&s.addEventListener("resize",o.update,bd),function(){i&&c.forEach(function(u){u.removeEventListener("scroll",o.update,bd);}),l&&s.removeEventListener("resize",o.update,bd);}}var yR={name:"eventListeners",enabled:true,phase:"write",fn:function(){},effect:Tj,data:{}};p();p();var Cj={left:"right",right:"left",bottom:"top",top:"bottom"};function Ks(e){return e.replace(/left|right|bottom|top/g,function(t){return Cj[t]})}p();var kj={start:"end",end:"start"};function yd(e){return e.replace(/start|end/g,function(t){return kj[t]})}p();p();p();p();p();function Ra(e){var t=Ke(e),o=t.pageXOffset,r=t.pageYOffset;return {scrollLeft:o,scrollTop:r}}function Ia(e){return mr(Ht(e)).left+Ra(e).scrollLeft}function ob(e,t){var o=Ke(e),r=Ht(e),n=o.visualViewport,i=r.clientWidth,a=r.clientHeight,l=0,s=0;if(n){i=n.width,a=n.height;var c=Nc();(c||!c&&t==="fixed")&&(l=n.offsetLeft,s=n.offsetTop);}return {width:i,height:a,x:l+Ia(e),y:s}}p();function rb(e){var t,o=Ht(e),r=Ra(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=Br(o.scrollWidth,o.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),a=Br(o.scrollHeight,o.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-r.scrollLeft+Ia(e),s=-r.scrollTop;return So(n||o).direction==="rtl"&&(l+=Br(o.clientWidth,n?n.clientWidth:0)-i),{width:i,height:a,x:l,y:s}}p();p();p();function Aa(e){var t=So(e),o=t.overflow,r=t.overflowX,n=t.overflowY;return /auto|scroll|overlay|hidden/.test(o+n+r)}function vd(e){return ["html","body","#document"].indexOf(Lt(e))>=0?e.ownerDocument.body:Rt(e)&&Aa(e)?e:vd(Bn(e))}function yi(e,t){var o;t===void 0&&(t=[]);var r=vd(e),n=r===((o=e.ownerDocument)==null?void 0:o.body),i=Ke(r),a=n?[i].concat(i.visualViewport||[],Aa(r)?r:[]):r,l=t.concat(a);return n?l:l.concat(yi(Bn(a)))}p();function qs(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function Ej(e,t){var o=mr(e,false,t==="fixed");return o.top=o.top+e.clientTop,o.left=o.left+e.clientLeft,o.bottom=o.top+e.clientHeight,o.right=o.left+e.clientWidth,o.width=e.clientWidth,o.height=e.clientHeight,o.x=o.left,o.y=o.top,o}function vR(e,t,o){return t===gd?qs(ob(e,o)):dr(t)?Ej(t,o):qs(rb(Ht(e)))}function wj(e){var t=yi(Bn(e)),o=["absolute","fixed"].indexOf(So(e).position)>=0,r=o&&Rt(e)?Dr(e):e;return dr(r)?t.filter(function(n){return dr(n)&&zc(n,r)&&Lt(n)!=="body"}):[]}function nb(e,t,o,r){var n=t==="clippingParents"?wj(e):[].concat(t),i=[].concat(n,[o]),a=i[0],l=i.reduce(function(s,c){var u=vR(e,c,r);return s.top=Br(u.top,s.top),s.right=Ca(u.right,s.right),s.bottom=Ca(u.bottom,s.bottom),s.left=Br(u.left,s.left),s},vR(e,a,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}p();function Uc(e){var t=e.reference,o=e.element,r=e.placement,n=r?Mt(r):null,i=r?fr(r):null,a=t.x+t.width/2-o.width/2,l=t.y+t.height/2-o.height/2,s;switch(n){case rt:s={x:a,y:t.y-o.height};break;case wt:s={x:a,y:t.y+t.height};break;case gt:s={x:t.x+t.width,y:l};break;case ct:s={x:t.x-o.width,y:l};break;default:s={x:t.x,y:t.y};}var c=n?Ea(n):null;if(c!=null){var u=c==="y"?"height":"width";switch(i){case Ln:s[c]=s[c]-(t[u]/2-o[u]/2);break;case Ta:s[c]=s[c]+(t[u]/2-o[u]/2);break;}}return s}function _r(e,t){t===void 0&&(t={});var o=t,r=o.placement,n=r===void 0?e.placement:r,i=o.strategy,a=i===void 0?e.strategy:i,l=o.boundary,s=l===void 0?uR:l,c=o.rootBoundary,u=c===void 0?gd:c,d=o.elementContext,f=d===void 0?Hs:d,g=o.altBoundary,m=g===void 0?false:g,h=o.padding,y=h===void 0?0:h,S=Vc(typeof y!="number"?y:$c(y,bi)),v=f===Hs?pR:Hs,C=e.rects.popper,b=e.elements[m?v:f],k=nb(dr(b)?b:b.contextElement||Ht(e.elements.popper),s,u,a),w=mr(e.elements.reference),R=Uc({reference:w,element:C,placement:n}),O=qs(Object.assign({},C,R)),A=f===Hs?O:w,B={top:k.top-A.top+S.top,bottom:A.bottom-k.bottom+S.bottom,left:k.left-A.left+S.left,right:A.right-k.right+S.right},_=e.modifiersData.offset;if(f===Hs&&_){var P=_[n];Object.keys(B).forEach(function(I){var F=[gt,wt].indexOf(I)>=0?1:-1,M=[rt,wt].indexOf(I)>=0?"y":"x";B[I]+=P[M]*F;});}return B}p();function ib(e,t){t===void 0&&(t={});var o=t,r=o.placement,n=o.boundary,i=o.rootBoundary,a=o.padding,l=o.flipVariations,s=o.allowedAutoPlacements,c=s===void 0?hd:s,u=fr(r),d=u?l?eb:eb.filter(function(m){return fr(m)===u}):bi,f=d.filter(function(m){return c.indexOf(m)>=0});f.length===0&&(f=d);var g=f.reduce(function(m,h){return m[h]=_r(e,{placement:h,boundary:n,rootBoundary:i,padding:a})[Mt(h)],m},{});return Object.keys(g).sort(function(m,h){return g[m]-g[h]})}function Rj(e){if(Mt(e)===fd)return [];var t=Ks(e);return [yd(e),t,yd(t)]}function Ij(e){var t=e.state,o=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var n=o.mainAxis,i=n===void 0?true:n,a=o.altAxis,l=a===void 0?true:a,s=o.fallbackPlacements,c=o.padding,u=o.boundary,d=o.rootBoundary,f=o.altBoundary,g=o.flipVariations,m=g===void 0?true:g,h=o.allowedAutoPlacements,y=t.options.placement,S=Mt(y),v=S===y,C=s||(v||!m?[Ks(y)]:Rj(y)),b=[y].concat(C).reduce(function(Y,ne){return Y.concat(Mt(ne)===fd?ib(t,{placement:ne,boundary:u,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:h}):ne)},[]),k=t.rects.reference,w=t.rects.popper,R=new Map,O=true,A=b[0],B=0;B<b.length;B++){var _=b[B],P=Mt(_),I=fr(_)===Ln,F=[rt,wt].indexOf(P)>=0,M=F?"width":"height",N=_r(t,{placement:_,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),j=F?I?gt:ct:I?wt:rt;k[M]>w[M]&&(j=Ks(j));var $=Ks(j),V=[];if(i&&V.push(N[P]<=0),l&&V.push(N[j]<=0,N[$]<=0),V.every(function(Y){return Y})){A=_,O=false;break}R.set(_,V);}if(O)for(var z=m?3:1,q=function(ne){var re=b.find(function(J){var G=R.get(J);if(G)return G.slice(0,ne).every(function(K){return K})});if(re)return A=re,"break"},W=z;W>0;W--){var U=q(W);if(U==="break")break}t.placement!==A&&(t.modifiersData[r]._skip=true,t.placement=A,t.reset=true);}}var SR={name:"flip",enabled:true,phase:"main",fn:Ij,requiresIfExists:["offset"],data:{_skip:false}};p();function xR(e,t,o){return o===void 0&&(o={x:0,y:0}),{top:e.top-t.height-o.y,right:e.right-t.width+o.x,bottom:e.bottom-t.height+o.y,left:e.left-t.width-o.x}}function TR(e){return [rt,gt,wt,ct].some(function(t){return e[t]>=0})}function Aj(e){var t=e.state,o=e.name,r=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,a=_r(t,{elementContext:"reference"}),l=_r(t,{altBoundary:true}),s=xR(a,r),c=xR(l,n,i),u=TR(s),d=TR(c);t.modifiersData[o]={referenceClippingOffsets:s,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d});}var CR={name:"hide",enabled:true,phase:"main",requiresIfExists:["preventOverflow"],fn:Aj};p();function Pj(e,t,o){var r=Mt(e),n=[ct,rt].indexOf(r)>=0?-1:1,i=typeof o=="function"?o(Object.assign({},t,{placement:e})):o,a=i[0],l=i[1];return a=a||0,l=(l||0)*n,[ct,gt].indexOf(r)>=0?{x:l,y:a}:{x:a,y:l}}function Oj(e){var t=e.state,o=e.options,r=e.name,n=o.offset,i=n===void 0?[0,0]:n,a=hd.reduce(function(u,d){return u[d]=Pj(d,t.rects,i),u},{}),l=a[t.placement],s=l.x,c=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=s,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a;}var kR={name:"offset",enabled:true,phase:"main",requires:["popperOffsets"],fn:Oj};p();function Lj(e){var t=e.state,o=e.name;t.modifiersData[o]=Uc({reference:t.rects.reference,element:t.rects.popper,placement:t.placement});}var ER={name:"popperOffsets",enabled:true,phase:"read",fn:Lj,data:{}};p();p();function ab(e){return e==="x"?"y":"x"}function Mj(e){var t=e.state,o=e.options,r=e.name,n=o.mainAxis,i=n===void 0?true:n,a=o.altAxis,l=a===void 0?false:a,s=o.boundary,c=o.rootBoundary,u=o.altBoundary,d=o.padding,f=o.tether,g=f===void 0?true:f,m=o.tetherOffset,h=m===void 0?0:m,y=_r(t,{boundary:s,rootBoundary:c,padding:d,altBoundary:u}),S=Mt(t.placement),v=fr(t.placement),C=!v,b=Ea(S),k=ab(b),w=t.modifiersData.popperOffsets,R=t.rects.reference,O=t.rects.popper,A=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,B=typeof A=="number"?{mainAxis:A,altAxis:A}:Object.assign({mainAxis:0,altAxis:0},A),_=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,P={x:0,y:0};if(w){if(i){var I,F=b==="y"?rt:ct,M=b==="y"?wt:gt,N=b==="y"?"height":"width",j=w[b],$=j+y[F],V=j-y[M],z=g?-O[N]/2:0,q=v===Ln?R[N]:O[N],W=v===Ln?-O[N]:-R[N],U=t.elements.arrow,Y=g&&U?ka(U):{width:0,height:0},ne=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Fc(),re=ne[F],J=ne[M],G=wa(0,R[N],Y[N]),K=C?R[N]/2-z-G-re-B.mainAxis:q-G-re-B.mainAxis,ee=C?-R[N]/2+z+G+J+B.mainAxis:W+G+J+B.mainAxis,ae=t.elements.arrow&&Dr(t.elements.arrow),ue=ae?b==="y"?ae.clientTop||0:ae.clientLeft||0:0,Te=(I=_?.[b])!=null?I:0,X=j+K-Te-ue,le=j+ee-Te,de=wa(g?Ca($,X):$,j,g?Br(V,le):V);w[b]=de,P[b]=de-j;}if(l){var Ce,$e=b==="x"?rt:ct,Ue=b==="x"?wt:gt,Qe=w[k],To=k==="y"?"height":"width",$o=Qe+y[$e],uo=Qe-y[Ue],mn=[rt,ct].indexOf(S)!==-1,Un=(Ce=_?.[k])!=null?Ce:0,Gn=mn?$o:Qe-R[To]-O[To]-Un+B.altAxis,Hn=mn?Qe+R[To]+O[To]-Un-B.altAxis:uo,Wn=g&&mn?fR(Gn,Qe,Hn):wa(g?Gn:$o,Qe,g?Hn:uo);w[k]=Wn,P[k]=Wn-Qe;}t.modifiersData[r]=P;}}var wR={name:"preventOverflow",enabled:true,phase:"main",fn:Mj,requiresIfExists:["offset"]};p();p();p();p();function sb(e){return {scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function lb(e){return e===Ke(e)||!Rt(e)?Ra(e):sb(e)}function Bj(e){var t=e.getBoundingClientRect(),o=Mn(t.width)/e.offsetWidth||1,r=Mn(t.height)/e.offsetHeight||1;return o!==1||r!==1}function cb(e,t,o){o===void 0&&(o=false);var r=Rt(t),n=Rt(t)&&Bj(t),i=Ht(t),a=mr(e,n,o),l={scrollLeft:0,scrollTop:0},s={x:0,y:0};return (r||!r&&!o)&&((Lt(t)!=="body"||Aa(i))&&(l=lb(t)),Rt(t)?(s=mr(t,true),s.x+=t.clientLeft,s.y+=t.clientTop):i&&(s.x=Ia(i))),{x:a.left+l.scrollLeft-s.x,y:a.top+l.scrollTop-s.y,width:a.width,height:a.height}}p();function Dj(e){var t=new Map,o=new Set,r=[];e.forEach(function(i){t.set(i.name,i);});function n(i){o.add(i.name);var a=[].concat(i.requires||[],i.requiresIfExists||[]);a.forEach(function(l){if(!o.has(l)){var s=t.get(l);s&&n(s);}}),r.push(i);}return e.forEach(function(i){o.has(i.name)||n(i);}),r}function ub(e){var t=Dj(e);return dR.reduce(function(o,r){return o.concat(t.filter(function(n){return n.phase===r}))},[])}p();function pb(e){var t;return function(){return t||(t=new Promise(function(o){Promise.resolve().then(function(){t=void 0,o(e());});})),t}}p();function db(e){var t=e.reduce(function(o,r){var n=o[r.name];return o[r.name]=n?Object.assign({},n,r,{options:Object.assign({},n.options,r.options),data:Object.assign({},n.data,r.data)}):r,o},{});return Object.keys(t).map(function(o){return t[o]})}var RR={placement:"bottom",modifiers:[],strategy:"absolute"};function IR(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return !t.some(function(r){return !(r&&typeof r.getBoundingClientRect=="function")})}function AR(e){e===void 0&&(e={});var t=e,o=t.defaultModifiers,r=o===void 0?[]:o,n=t.defaultOptions,i=n===void 0?RR:n;return function(l,s,c){c===void 0&&(c=i);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},RR,i),modifiersData:{},elements:{reference:l,popper:s},attributes:{},styles:{}},d=[],f=false,g={state:u,setOptions:function(S){var v=typeof S=="function"?S(u.options):S;h(),u.options=Object.assign({},i,u.options,v),u.scrollParents={reference:dr(l)?yi(l):l.contextElement?yi(l.contextElement):[],popper:yi(s)};var C=ub(db([].concat(r,u.options.modifiers)));return u.orderedModifiers=C.filter(function(b){return b.enabled}),m(),g.update()},forceUpdate:function(){if(!f){var S=u.elements,v=S.reference,C=S.popper;if(IR(v,C)){u.rects={reference:cb(v,Dr(C),u.options.strategy==="fixed"),popper:ka(C)},u.reset=false,u.placement=u.options.placement,u.orderedModifiers.forEach(function(B){return u.modifiersData[B.name]=Object.assign({},B.data)});for(var b=0;b<u.orderedModifiers.length;b++){if(u.reset===true){u.reset=false,b=-1;continue}var k=u.orderedModifiers[b],w=k.fn,R=k.options,O=R===void 0?{}:R,A=k.name;typeof w=="function"&&(u=w({state:u,options:O,name:A,instance:g})||u);}}}},update:pb(function(){return new Promise(function(y){g.forceUpdate(),y(u);})}),destroy:function(){h(),f=true;}};if(!IR(l,s))return g;g.setOptions(c).then(function(y){!f&&c.onFirstUpdate&&c.onFirstUpdate(y);});function m(){u.orderedModifiers.forEach(function(y){var S=y.name,v=y.options,C=v===void 0?{}:v,b=y.effect;if(typeof b=="function"){var k=b({state:u,name:S,instance:g,options:C}),w=function(){};d.push(k||w);}});}function h(){d.forEach(function(y){return y()}),d=[];}return g}}p();var _j=[yR,ER,bR,_c,kR,SR,wR,gR,CR],mb=AR({defaultModifiers:_j});var Nj="tippy-box",VR="tippy-content",zj="tippy-backdrop",$R="tippy-arrow",UR="tippy-svg-arrow",Pa={passive:true,capture:true},GR=function(){return document.body};function Fj(e,t){return {}.hasOwnProperty.call(e,t)}function fb(e,t,o){if(Array.isArray(e)){var r=e[t];return r??(Array.isArray(o)?o[t]:o)}return e}function xb(e,t){var o={}.toString.call(e);return o.indexOf("[object")===0&&o.indexOf(t+"]")>-1}function HR(e,t){return typeof e=="function"?e.apply(void 0,t):e}function PR(e,t){if(t===0)return e;var o;return function(r){clearTimeout(o),o=setTimeout(function(){e(r);},t);}}function Vj(e,t){var o=Object.assign({},e);return t.forEach(function(r){delete o[r];}),o}function $j(e){return e.split(/\s+/).filter(Boolean)}function Xs(e){return [].concat(e)}function OR(e,t){e.indexOf(t)===-1&&e.push(t);}function Uj(e){return e.filter(function(t,o){return e.indexOf(t)===o})}function Gj(e){return e.split("-")[0]}function xd(e){return [].slice.call(e)}function LR(e){return Object.keys(e).reduce(function(t,o){return e[o]!==void 0&&(t[o]=e[o]),t},{})}function Gc(){return document.createElement("div")}function Hc(e){return ["Element","Fragment"].some(function(t){return xb(e,t)})}function Hj(e){return xb(e,"NodeList")}function Wj(e){return xb(e,"MouseEvent")}function jj(e){return !!(e&&e._tippy&&e._tippy.reference===e)}function Kj(e){return Hc(e)?[e]:Hj(e)?xd(e):Array.isArray(e)?e:xd(document.querySelectorAll(e))}function gb(e,t){e.forEach(function(o){o&&(o.style.transitionDuration=t+"ms");});}function MR(e,t){e.forEach(function(o){o&&o.setAttribute("data-state",t);});}function qj(e){var t,o=Xs(e),r=o[0];return r!=null&&(t=r.ownerDocument)!=null&&t.body?r.ownerDocument:document}function Yj(e,t){var o=t.clientX,r=t.clientY;return e.every(function(n){var i=n.popperRect,a=n.popperState,l=n.props,s=l.interactiveBorder,c=Gj(a.placement),u=a.modifiersData.offset;if(!u)return true;var d=c==="bottom"?u.top.y:0,f=c==="top"?u.bottom.y:0,g=c==="right"?u.left.x:0,m=c==="left"?u.right.x:0,h=i.top-r+d>s,y=r-i.bottom-f>s,S=i.left-o+g>s,v=o-i.right-m>s;return h||y||S||v})}function hb(e,t,o){var r=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[r](n,o);});}function BR(e,t){for(var o=t;o;){var r;if(e.contains(o))return true;o=o.getRootNode==null||(r=o.getRootNode())==null?void 0:r.host;}return false}var an={isTouch:false},DR=0;function Xj(){an.isTouch||(an.isTouch=true,window.performance&&document.addEventListener("mousemove",WR));}function WR(){var e=performance.now();e-DR<20&&(an.isTouch=false,document.removeEventListener("mousemove",WR)),DR=e;}function Jj(){var e=document.activeElement;if(jj(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur();}}function Qj(){document.addEventListener("touchstart",Xj,Pa),window.addEventListener("blur",Jj);}var Zj=typeof window<"u"&&typeof document<"u",e5=Zj?!!window.msCrypto:false;function Ys(e){var t=e==="destroy"?"n already-":" ";return [e+"() was called on a"+t+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function _R(e){var t=/[ \t]{2,}/g,o=/^[ \t]*/gm;return e.replace(t," ").replace(o,"").trim()}function t5(e){return _R(`
57
57
  %ctippy.js
58
58
 
59
- %c`+DR(e)+`
59
+ %c`+_R(e)+`
60
60
 
61
61
  %c\u{1F477}\u200D This is a development-only message. It will be removed in production.
62
- `)}function WR(e){return [e5(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var Wc;process.env.NODE_ENV!=="production"&&t5();function t5(){Wc=new Set;}function Nn(e,t){if(e&&!Wc.has(t)){var o;Wc.add(t),(o=console).warn.apply(o,WR(t));}}function bb(e,t){if(e&&!Wc.has(t)){var o;Wc.add(t),(o=console).error.apply(o,WR(t));}}function o5(e){var t=!e,o=Object.prototype.toString.call(e)==="[object Object]"&&!e.addEventListener;bb(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),bb(o,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "));}var jR={animateFill:false,followCursor:false,inlinePositioning:false,sticky:false},r5={allowHTML:false,animation:"fade",arrow:true,content:"",inertia:false,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Jo=Object.assign({appendTo:UR,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:true,ignoreAttributes:false,interactive:false,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:false,touch:true,trigger:"mouseenter focus",triggerTarget:null},jR,r5),n5=Object.keys(Jo),i5=function(t){process.env.NODE_ENV!=="production"&&qR(t,[]);var o=Object.keys(t);o.forEach(function(r){Jo[r]=t[r];});};function KR(e){var t=e.plugins||[],o=t.reduce(function(r,n){var i=n.name,a=n.defaultValue;if(i){var l;r[i]=e[i]!==void 0?e[i]:(l=Jo[i])!=null?l:a;}return r},{});return Object.assign({},e,o)}function a5(e,t){var o=t?Object.keys(KR(Object.assign({},Jo,{plugins:t}))):n5,r=o.reduce(function(n,i){var a=(e.getAttribute("data-tippy-"+i)||"").trim();if(!a)return n;if(i==="content")n[i]=a;else try{n[i]=JSON.parse(a);}catch{n[i]=a;}return n},{});return r}function _R(e,t){var o=Object.assign({},t,{content:GR(t.content,[e])},t.ignoreAttributes?{}:a5(e,t.plugins));return o.aria=Object.assign({},Jo.aria,o.aria),o.aria={expanded:o.aria.expanded==="auto"?t.interactive:o.aria.expanded,content:o.aria.content==="auto"?t.interactive?null:"describedby":o.aria.content},o}function qR(e,t){e===void 0&&(e={}),t===void 0&&(t=[]);var o=Object.keys(e);o.forEach(function(r){var n=Fj(Jo,Object.keys(jR)),i=!zj(n,r);i&&(i=t.filter(function(a){return a.name===r}).length===0),Nn(i,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
62
+ `)}function jR(e){return [t5(e),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var Wc;process.env.NODE_ENV!=="production"&&o5();function o5(){Wc=new Set;}function Dn(e,t){if(e&&!Wc.has(t)){var o;Wc.add(t),(o=console).warn.apply(o,jR(t));}}function yb(e,t){if(e&&!Wc.has(t)){var o;Wc.add(t),(o=console).error.apply(o,jR(t));}}function r5(e){var t=!e,o=Object.prototype.toString.call(e)==="[object Object]"&&!e.addEventListener;yb(t,["tippy() was passed","`"+String(e)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),yb(o,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "));}var KR={animateFill:false,followCursor:false,inlinePositioning:false,sticky:false},n5={allowHTML:false,animation:"fade",arrow:true,content:"",inertia:false,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Xo=Object.assign({appendTo:GR,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:true,ignoreAttributes:false,interactive:false,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:false,touch:true,trigger:"mouseenter focus",triggerTarget:null},KR,n5),i5=Object.keys(Xo),a5=function(t){process.env.NODE_ENV!=="production"&&YR(t,[]);var o=Object.keys(t);o.forEach(function(r){Xo[r]=t[r];});};function qR(e){var t=e.plugins||[],o=t.reduce(function(r,n){var i=n.name,a=n.defaultValue;if(i){var l;r[i]=e[i]!==void 0?e[i]:(l=Xo[i])!=null?l:a;}return r},{});return Object.assign({},e,o)}function s5(e,t){var o=t?Object.keys(qR(Object.assign({},Xo,{plugins:t}))):i5,r=o.reduce(function(n,i){var a=(e.getAttribute("data-tippy-"+i)||"").trim();if(!a)return n;if(i==="content")n[i]=a;else try{n[i]=JSON.parse(a);}catch{n[i]=a;}return n},{});return r}function NR(e,t){var o=Object.assign({},t,{content:HR(t.content,[e])},t.ignoreAttributes?{}:s5(e,t.plugins));return o.aria=Object.assign({},Xo.aria,o.aria),o.aria={expanded:o.aria.expanded==="auto"?t.interactive:o.aria.expanded,content:o.aria.content==="auto"?t.interactive?null:"describedby":o.aria.content},o}function YR(e,t){e===void 0&&(e={}),t===void 0&&(t=[]);var o=Object.keys(e);o.forEach(function(r){var n=Vj(Xo,Object.keys(KR)),i=!Fj(n,r);i&&(i=t.filter(function(a){return a.name===r}).length===0),Dn(i,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
63
63
 
64
64
  `,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
65
- `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "));});}var s5=function(){return "innerHTML"};function yb(e,t){e[s5()]=t;}function NR(e){var t=Gc();return e===true?t.className=VR:(t.className=$R,Hc(e)?t.appendChild(e):yb(t,e)),t}function zR(e,t){Hc(t.content)?(yb(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?yb(e,t.content):e.textContent=t.content);}function vb(e){var t=e.firstElementChild,o=Sd(t.children);return {box:t,content:o.find(function(r){return r.classList.contains(FR)}),arrow:o.find(function(r){return r.classList.contains(VR)||r.classList.contains($R)}),backdrop:o.find(function(r){return r.classList.contains(Nj)})}}function YR(e){var t=Gc(),o=Gc();o.className=_j,o.setAttribute("data-state","hidden"),o.setAttribute("tabindex","-1");var r=Gc();r.className=FR,r.setAttribute("data-state","hidden"),zR(r,e.props),t.appendChild(o),o.appendChild(r),n(e.props,e.props);function n(i,a){var l=vb(t),s=l.box,c=l.content,u=l.arrow;a.theme?s.setAttribute("data-theme",a.theme):s.removeAttribute("data-theme"),typeof a.animation=="string"?s.setAttribute("data-animation",a.animation):s.removeAttribute("data-animation"),a.inertia?s.setAttribute("data-inertia",""):s.removeAttribute("data-inertia"),s.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?s.setAttribute("role",a.role):s.removeAttribute("role"),(i.content!==a.content||i.allowHTML!==a.allowHTML)&&zR(c,e.props),a.arrow?u?i.arrow!==a.arrow&&(s.removeChild(u),s.appendChild(NR(a.arrow))):s.appendChild(NR(a.arrow)):u&&s.removeChild(u);}return {popper:t,onUpdate:n}}YR.$$tippy=true;var l5=1,vd=[],hb=[];function c5(e,t){var o=_R(e,Object.assign({},Jo,KR(OR(t)))),r,n,i,a=false,l=false,s=false,c=false,u,d,m,g=[],f=AR(q,o.interactiveDebounce),h,v=l5++,T=null,y=$j(o.plugins),C={isEnabled:true,isVisible:false,isDestroyed:false,isMounted:false,isShown:false},b={id:v,reference:e,popper:Gc(),popperInstance:T,props:o,state:C,plugins:y,clearDelayTimeouts:Wn,setProps:jn,setContent:Kn,show:Cl,hide:kl,hideWithInteractivity:te,enable:gn,disable:Hn,unmount:Oe,destroy:Ue};if(!o.render)return process.env.NODE_ENV!=="production"&&bb(true,"render() function has not been supplied."),b;var w=o.render(b),k=w.popper,I=w.onUpdate;k.setAttribute("data-tippy-root",""),k.id="tippy-"+b.id,b.popper=k,e._tippy=b,k._tippy=b;var O=y.map(function(M){return M.fn(b)}),P=e.hasAttribute("aria-expanded");return re(),$(),j(),B("onCreate",[b]),o.showOnCreate&&Uo(),k.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts();}),k.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&z().addEventListener("mousemove",f);}),b;function _(){var M=b.props.touch;return Array.isArray(M)?M:[M,0]}function D(){return _()[0]==="hold"}function L(){var M;return !!((M=b.props.render)!=null&&M.$$tippy)}function R(){return h||e}function z(){var M=R().parentNode;return M?Kj(M):document}function A(){return vb(k)}function V(M){return b.state.isMounted&&!b.state.isVisible||ln.isTouch||u&&u.type==="focus"?0:mb(b.props.delay,M?0:1,Jo.delay)}function j(M){M===void 0&&(M=false),k.style.pointerEvents=b.props.interactive&&!M?"":"none",k.style.zIndex=""+b.props.zIndex;}function B(M,Q,se){if(se===void 0&&(se=true),O.forEach(function(fe){fe[M]&&fe[M].apply(fe,Q);}),se){var Te;(Te=b.props)[M].apply(Te,Q);}}function U(){var M=b.props.aria;if(M.content){var Q="aria-"+M.content,se=k.id,Te=Qs(b.props.triggerTarget||e);Te.forEach(function(fe){var St=fe.getAttribute(Q);if(b.state.isVisible)fe.setAttribute(Q,St?St+" "+se:se);else {var ko=St&&St.replace(se,"").trim();ko?fe.setAttribute(Q,ko):fe.removeAttribute(Q);}});}}function $(){if(!(P||!b.props.aria.expanded)){var M=Qs(b.props.triggerTarget||e);M.forEach(function(Q){b.props.interactive?Q.setAttribute("aria-expanded",b.state.isVisible&&Q===R()?"true":"false"):Q.removeAttribute("aria-expanded");});}}function Y(){z().removeEventListener("mousemove",f),vd=vd.filter(function(M){return M!==f});}function F(M){if(!(ln.isTouch&&(s||M.type==="mousedown"))){var Q=M.composedPath&&M.composedPath()[0]||M.target;if(!(b.props.interactive&&MR(k,Q))){if(Qs(b.props.triggerTarget||e).some(function(se){return MR(se,Q)})){if(ln.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else B("onClickOutside",[b,M]);b.props.hideOnClick===true&&(b.clearDelayTimeouts(),b.hide(),l=true,setTimeout(function(){l=false;}),b.state.isMounted||ne());}}}function G(){s=true;}function J(){s=false;}function ee(){var M=z();M.addEventListener("mousedown",F,true),M.addEventListener("touchend",F,Oa),M.addEventListener("touchstart",J,Oa),M.addEventListener("touchmove",G,Oa);}function ne(){var M=z();M.removeEventListener("mousedown",F,true),M.removeEventListener("touchend",F,Oa),M.removeEventListener("touchstart",J,Oa),M.removeEventListener("touchmove",G,Oa);}function X(M,Q){K(M,function(){!b.state.isVisible&&k.parentNode&&k.parentNode.contains(k)&&Q();});}function W(M,Q){K(M,Q);}function K(M,Q){var se=A().box;function Te(fe){fe.target===se&&(gb(se,"remove",Te),Q());}if(M===0)return Q();gb(se,"remove",d),gb(se,"add",Te),d=Te;}function oe(M,Q,se){se===void 0&&(se=false);var Te=Qs(b.props.triggerTarget||e);Te.forEach(function(fe){fe.addEventListener(M,Q,se),g.push({node:fe,eventType:M,handler:Q,options:se});});}function re(){D()&&(oe("touchstart",Ee,{passive:true}),oe("touchend",ce,{passive:true})),Vj(b.props.trigger).forEach(function(M){if(M!=="manual")switch(oe(M,Ee),M){case "mouseenter":oe("mouseleave",ce);break;case "focus":oe(Zj?"focusout":"blur",de);break;case "focusin":oe("focusout",de);break}});}function ue(){g.forEach(function(M){var Q=M.node,se=M.eventType,Te=M.handler,fe=M.options;Q.removeEventListener(se,Te,fe);}),g=[];}function Ee(M){var Q,se=false;if(!(!b.state.isEnabled||Se(M)||l)){var Te=((Q=u)==null?void 0:Q.type)==="focus";u=M,h=M.currentTarget,$(),!b.state.isVisible&&Hj(M)&&vd.forEach(function(fe){return fe(M)}),M.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||a)&&b.props.hideOnClick!==false&&b.state.isVisible?se=true:Uo(M),M.type==="click"&&(a=!se),se&&!Te&&po(M);}}function q(M){var Q=M.target,se=R().contains(Q)||k.contains(Q);if(!(M.type==="mousemove"&&se)){var Te=Co().concat(k).map(function(fe){var St,ko=fe._tippy,Fa=(St=ko.popperInstance)==null?void 0:St.state;return Fa?{popperRect:fe.getBoundingClientRect(),popperState:Fa,props:o}:null}).filter(Boolean);qj(Te,M)&&(Y(),po(M));}}function ce(M){var Q=Se(M)||b.props.trigger.indexOf("click")>=0&&a;if(!Q){if(b.props.interactive){b.hideWithInteractivity(M);return}po(M);}}function de(M){b.props.trigger.indexOf("focusin")<0&&M.target!==R()||b.props.interactive&&M.relatedTarget&&k.contains(M.relatedTarget)||po(M);}function Se(M){return ln.isTouch?D()!==M.type.indexOf("touch")>=0:false}function $e(){We();var M=b.props,Q=M.popperOptions,se=M.placement,Te=M.offset,fe=M.getReferenceClientRect,St=M.moveTransition,ko=L()?vb(k).arrow:null,Fa=fe?{getBoundingClientRect:fe,contextElement:fe.contextElement||R()}:e,nv={name:"$$tippy",enabled:true,phase:"beforeWrite",requires:["computeStyles"],fn:function(bu){var Va=bu.state;if(L()){var bP=A(),hm=bP.box;["placement","reference-hidden","escaped"].forEach(function(yu){yu==="placement"?hm.setAttribute("data-placement",Va.placement):Va.attributes.popper["data-popper-"+yu]?hm.setAttribute("data-"+yu,""):hm.removeAttribute("data-"+yu);}),Va.attributes.popper={};}}},Bi=[{name:"offset",options:{offset:Te}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!St}},nv];L()&&ko&&Bi.push({name:"arrow",options:{element:ko,padding:3}}),Bi.push.apply(Bi,Q?.modifiers||[]),b.popperInstance=db(Fa,k,Object.assign({},Q,{placement:se,onFirstUpdate:m,modifiers:Bi}));}function We(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null);}function Qe(){var M=b.props.appendTo,Q,se=R();b.props.interactive&&M===UR||M==="parent"?Q=se.parentNode:Q=GR(M,[se]),Q.contains(k)||Q.appendChild(k),b.state.isMounted=true,$e(),process.env.NODE_ENV!=="production"&&Nn(b.props.interactive&&M===Jo.appendTo&&se.nextElementSibling!==k,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
65
+ `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "));});}var l5=function(){return "innerHTML"};function vb(e,t){e[l5()]=t;}function zR(e){var t=Gc();return e===true?t.className=$R:(t.className=UR,Hc(e)?t.appendChild(e):vb(t,e)),t}function FR(e,t){Hc(t.content)?(vb(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?vb(e,t.content):e.textContent=t.content);}function Sb(e){var t=e.firstElementChild,o=xd(t.children);return {box:t,content:o.find(function(r){return r.classList.contains(VR)}),arrow:o.find(function(r){return r.classList.contains($R)||r.classList.contains(UR)}),backdrop:o.find(function(r){return r.classList.contains(zj)})}}function XR(e){var t=Gc(),o=Gc();o.className=Nj,o.setAttribute("data-state","hidden"),o.setAttribute("tabindex","-1");var r=Gc();r.className=VR,r.setAttribute("data-state","hidden"),FR(r,e.props),t.appendChild(o),o.appendChild(r),n(e.props,e.props);function n(i,a){var l=Sb(t),s=l.box,c=l.content,u=l.arrow;a.theme?s.setAttribute("data-theme",a.theme):s.removeAttribute("data-theme"),typeof a.animation=="string"?s.setAttribute("data-animation",a.animation):s.removeAttribute("data-animation"),a.inertia?s.setAttribute("data-inertia",""):s.removeAttribute("data-inertia"),s.style.maxWidth=typeof a.maxWidth=="number"?a.maxWidth+"px":a.maxWidth,a.role?s.setAttribute("role",a.role):s.removeAttribute("role"),(i.content!==a.content||i.allowHTML!==a.allowHTML)&&FR(c,e.props),a.arrow?u?i.arrow!==a.arrow&&(s.removeChild(u),s.appendChild(zR(a.arrow))):s.appendChild(zR(a.arrow)):u&&s.removeChild(u);}return {popper:t,onUpdate:n}}XR.$$tippy=true;var c5=1,Sd=[],bb=[];function u5(e,t){var o=NR(e,Object.assign({},Xo,qR(LR(t)))),r,n,i,a=false,l=false,s=false,c=false,u,d,f,g=[],m=PR(X,o.interactiveDebounce),h,y=c5++,S=null,v=Uj(o.plugins),C={isEnabled:true,isVisible:false,isDestroyed:false,isMounted:false,isShown:false},b={id:y,reference:e,popper:Gc(),popperInstance:S,props:o,state:C,plugins:v,clearDelayTimeouts:Gn,setProps:Hn,setContent:Wn,show:xl,hide:Tl,hideWithInteractivity:Cl,enable:mn,disable:Un,unmount:oe,destroy:Oe};if(!o.render)return process.env.NODE_ENV!=="production"&&yb(true,"render() function has not been supplied."),b;var k=o.render(b),w=k.popper,R=k.onUpdate;w.setAttribute("data-tippy-root",""),w.id="tippy-"+b.id,b.popper=w,e._tippy=b,w._tippy=b;var O=v.map(function(L){return L.fn(b)}),A=e.hasAttribute("aria-expanded");return ae(),z(),j(),$("onCreate",[b]),o.showOnCreate&&$o(),w.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts();}),w.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&F().addEventListener("mousemove",m);}),b;function B(){var L=b.props.touch;return Array.isArray(L)?L:[L,0]}function _(){return B()[0]==="hold"}function P(){var L;return !!((L=b.props.render)!=null&&L.$$tippy)}function I(){return h||e}function F(){var L=I().parentNode;return L?qj(L):document}function M(){return Sb(w)}function N(L){return b.state.isMounted&&!b.state.isVisible||an.isTouch||u&&u.type==="focus"?0:fb(b.props.delay,L?0:1,Xo.delay)}function j(L){L===void 0&&(L=false),w.style.pointerEvents=b.props.interactive&&!L?"":"none",w.style.zIndex=""+b.props.zIndex;}function $(L,Q,te){if(te===void 0&&(te=true),O.forEach(function(fe){fe[L]&&fe[L].apply(fe,Q);}),te){var Se;(Se=b.props)[L].apply(Se,Q);}}function V(){var L=b.props.aria;if(L.content){var Q="aria-"+L.content,te=w.id,Se=Xs(b.props.triggerTarget||e);Se.forEach(function(fe){var vt=fe.getAttribute(Q);if(b.state.isVisible)fe.setAttribute(Q,vt?vt+" "+te:te);else {var Co=vt&&vt.replace(te,"").trim();Co?fe.setAttribute(Q,Co):fe.removeAttribute(Q);}});}}function z(){if(!(A||!b.props.aria.expanded)){var L=Xs(b.props.triggerTarget||e);L.forEach(function(Q){b.props.interactive?Q.setAttribute("aria-expanded",b.state.isVisible&&Q===I()?"true":"false"):Q.removeAttribute("aria-expanded");});}}function q(){F().removeEventListener("mousemove",m),Sd=Sd.filter(function(L){return L!==m});}function W(L){if(!(an.isTouch&&(s||L.type==="mousedown"))){var Q=L.composedPath&&L.composedPath()[0]||L.target;if(!(b.props.interactive&&BR(w,Q))){if(Xs(b.props.triggerTarget||e).some(function(te){return BR(te,Q)})){if(an.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else $("onClickOutside",[b,L]);b.props.hideOnClick===true&&(b.clearDelayTimeouts(),b.hide(),l=true,setTimeout(function(){l=false;}),b.state.isMounted||re());}}}function U(){s=true;}function Y(){s=false;}function ne(){var L=F();L.addEventListener("mousedown",W,true),L.addEventListener("touchend",W,Pa),L.addEventListener("touchstart",Y,Pa),L.addEventListener("touchmove",U,Pa);}function re(){var L=F();L.removeEventListener("mousedown",W,true),L.removeEventListener("touchend",W,Pa),L.removeEventListener("touchstart",Y,Pa),L.removeEventListener("touchmove",U,Pa);}function J(L,Q){K(L,function(){!b.state.isVisible&&w.parentNode&&w.parentNode.contains(w)&&Q();});}function G(L,Q){K(L,Q);}function K(L,Q){var te=M().box;function Se(fe){fe.target===te&&(hb(te,"remove",Se),Q());}if(L===0)return Q();hb(te,"remove",d),hb(te,"add",Se),d=Se;}function ee(L,Q,te){te===void 0&&(te=false);var Se=Xs(b.props.triggerTarget||e);Se.forEach(function(fe){fe.addEventListener(L,Q,te),g.push({node:fe,eventType:L,handler:Q,options:te});});}function ae(){_()&&(ee("touchstart",Te,{passive:true}),ee("touchend",le,{passive:true})),$j(b.props.trigger).forEach(function(L){if(L!=="manual")switch(ee(L,Te),L){case "mouseenter":ee("mouseleave",le);break;case "focus":ee(e5?"focusout":"blur",de);break;case "focusin":ee("focusout",de);break}});}function ue(){g.forEach(function(L){var Q=L.node,te=L.eventType,Se=L.handler,fe=L.options;Q.removeEventListener(te,Se,fe);}),g=[];}function Te(L){var Q,te=false;if(!(!b.state.isEnabled||Ce(L)||l)){var Se=((Q=u)==null?void 0:Q.type)==="focus";u=L,h=L.currentTarget,z(),!b.state.isVisible&&Wj(L)&&Sd.forEach(function(fe){return fe(L)}),L.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||a)&&b.props.hideOnClick!==false&&b.state.isVisible?te=true:$o(L),L.type==="click"&&(a=!te),te&&!Se&&uo(L);}}function X(L){var Q=L.target,te=I().contains(Q)||w.contains(Q);if(!(L.type==="mousemove"&&te)){var Se=To().concat(w).map(function(fe){var vt,Co=fe._tippy,za=(vt=Co.popperInstance)==null?void 0:vt.state;return za?{popperRect:fe.getBoundingClientRect(),popperState:za,props:o}:null}).filter(Boolean);Yj(Se,L)&&(q(),uo(L));}}function le(L){var Q=Ce(L)||b.props.trigger.indexOf("click")>=0&&a;if(!Q){if(b.props.interactive){b.hideWithInteractivity(L);return}uo(L);}}function de(L){b.props.trigger.indexOf("focusin")<0&&L.target!==I()||b.props.interactive&&L.relatedTarget&&w.contains(L.relatedTarget)||uo(L);}function Ce(L){return an.isTouch?_()!==L.type.indexOf("touch")>=0:false}function $e(){Ue();var L=b.props,Q=L.popperOptions,te=L.placement,Se=L.offset,fe=L.getReferenceClientRect,vt=L.moveTransition,Co=P()?Sb(w).arrow:null,za=fe?{getBoundingClientRect:fe,contextElement:fe.contextElement||I()}:e,iv={name:"$$tippy",enabled:true,phase:"beforeWrite",requires:["computeStyles"],fn:function(bu){var Fa=bu.state;if(P()){var yP=M(),bm=yP.box;["placement","reference-hidden","escaped"].forEach(function(yu){yu==="placement"?bm.setAttribute("data-placement",Fa.placement):Fa.attributes.popper["data-popper-"+yu]?bm.setAttribute("data-"+yu,""):bm.removeAttribute("data-"+yu);}),Fa.attributes.popper={};}}},Li=[{name:"offset",options:{offset:Se}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!vt}},iv];P()&&Co&&Li.push({name:"arrow",options:{element:Co,padding:3}}),Li.push.apply(Li,Q?.modifiers||[]),b.popperInstance=mb(za,w,Object.assign({},Q,{placement:te,onFirstUpdate:f,modifiers:Li}));}function Ue(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null);}function Qe(){var L=b.props.appendTo,Q,te=I();b.props.interactive&&L===GR||L==="parent"?Q=te.parentNode:Q=HR(L,[te]),Q.contains(w)||Q.appendChild(w),b.state.isMounted=true,$e(),process.env.NODE_ENV!=="production"&&Dn(b.props.interactive&&L===Xo.appendTo&&te.nextElementSibling!==w,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
66
66
 
67
67
  `,"Using a wrapper <div> or <span> tag around the reference element","solves this by creating a new parentNode context.",`
68
68
 
69
69
  `,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",`
70
70
 
71
- `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "));}function Co(){return Sd(k.querySelectorAll("[data-tippy-root]"))}function Uo(M){b.clearDelayTimeouts(),M&&B("onTrigger",[b,M]),ee();var Q=V(true),se=_(),Te=se[0],fe=se[1];ln.isTouch&&Te==="hold"&&fe&&(Q=fe),Q?r=setTimeout(function(){b.show();},Q):b.show();}function po(M){if(b.clearDelayTimeouts(),B("onUntrigger",[b,M]),!b.state.isVisible){ne();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(M.type)>=0&&a)){var Q=V(false);Q?n=setTimeout(function(){b.state.isVisible&&b.hide();},Q):i=requestAnimationFrame(function(){b.hide();});}}function gn(){b.state.isEnabled=true;}function Hn(){b.hide(),b.state.isEnabled=false;}function Wn(){clearTimeout(r),clearTimeout(n),cancelAnimationFrame(i);}function jn(M){if(process.env.NODE_ENV!=="production"&&Nn(b.state.isDestroyed,Js("setProps")),!b.state.isDestroyed){B("onBeforeUpdate",[b,M]),ue();var Q=b.props,se=_R(e,Object.assign({},Q,OR(M),{ignoreAttributes:true}));b.props=se,re(),Q.interactiveDebounce!==se.interactiveDebounce&&(Y(),f=AR(q,se.interactiveDebounce)),Q.triggerTarget&&!se.triggerTarget?Qs(Q.triggerTarget).forEach(function(Te){Te.removeAttribute("aria-expanded");}):se.triggerTarget&&e.removeAttribute("aria-expanded"),$(),j(),I&&I(Q,se),b.popperInstance&&($e(),Co().forEach(function(Te){requestAnimationFrame(Te._tippy.popperInstance.forceUpdate);})),B("onAfterUpdate",[b,M]);}}function Kn(M){b.setProps({content:M});}function Cl(){process.env.NODE_ENV!=="production"&&Nn(b.state.isDestroyed,Js("show"));var M=b.state.isVisible,Q=b.state.isDestroyed,se=!b.state.isEnabled,Te=ln.isTouch&&!b.props.touch,fe=mb(b.props.duration,0,Jo.duration);if(!(M||Q||se||Te)&&!R().hasAttribute("disabled")&&(B("onShow",[b],false),b.props.onShow(b)!==false)){if(b.state.isVisible=true,L()&&(k.style.visibility="visible"),j(),ee(),b.state.isMounted||(k.style.transition="none"),L()){var St=A(),ko=St.box,Fa=St.content;fb([ko,Fa],0);}m=function(){var Bi;if(!(!b.state.isVisible||c)){if(c=true,k.offsetHeight,k.style.transition=b.props.moveTransition,L()&&b.props.animation){var gm=A(),bu=gm.box,Va=gm.content;fb([bu,Va],fe),LR([bu,Va],"visible");}U(),$(),PR(hb,b),(Bi=b.popperInstance)==null||Bi.forceUpdate(),B("onMount",[b]),b.props.animation&&L()&&W(fe,function(){b.state.isShown=true,B("onShown",[b]);});}},Qe();}}function kl(){process.env.NODE_ENV!=="production"&&Nn(b.state.isDestroyed,Js("hide"));var M=!b.state.isVisible,Q=b.state.isDestroyed,se=!b.state.isEnabled,Te=mb(b.props.duration,1,Jo.duration);if(!(M||Q||se)&&(B("onHide",[b],false),b.props.onHide(b)!==false)){if(b.state.isVisible=false,b.state.isShown=false,c=false,a=false,L()&&(k.style.visibility="hidden"),Y(),ne(),j(true),L()){var fe=A(),St=fe.box,ko=fe.content;b.props.animation&&(fb([St,ko],Te),LR([St,ko],"hidden"));}U(),$(),b.props.animation?L()&&X(Te,b.unmount):b.unmount();}}function te(M){process.env.NODE_ENV!=="production"&&Nn(b.state.isDestroyed,Js("hideWithInteractivity")),z().addEventListener("mousemove",f),PR(vd,f),f(M);}function Oe(){process.env.NODE_ENV!=="production"&&Nn(b.state.isDestroyed,Js("unmount")),b.state.isVisible&&b.hide(),b.state.isMounted&&(We(),Co().forEach(function(M){M._tippy.unmount();}),k.parentNode&&k.parentNode.removeChild(k),hb=hb.filter(function(M){return M!==b}),b.state.isMounted=false,B("onHidden",[b]));}function Ue(){process.env.NODE_ENV!=="production"&&Nn(b.state.isDestroyed,Js("destroy")),!b.state.isDestroyed&&(b.clearDelayTimeouts(),b.unmount(),ue(),delete e._tippy,b.state.isDestroyed=true,B("onDestroy",[b]));}}function jc(e,t){t===void 0&&(t={});var o=Jo.plugins.concat(t.plugins||[]);process.env.NODE_ENV!=="production"&&(o5(e),qR(t,o)),Jj();var r=Object.assign({},t,{plugins:o}),n=jj(e);if(process.env.NODE_ENV!=="production"){var i=Hc(r.content),a=n.length>1;Nn(i&&a,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
71
+ `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "));}function To(){return xd(w.querySelectorAll("[data-tippy-root]"))}function $o(L){b.clearDelayTimeouts(),L&&$("onTrigger",[b,L]),ne();var Q=N(true),te=B(),Se=te[0],fe=te[1];an.isTouch&&Se==="hold"&&fe&&(Q=fe),Q?r=setTimeout(function(){b.show();},Q):b.show();}function uo(L){if(b.clearDelayTimeouts(),$("onUntrigger",[b,L]),!b.state.isVisible){re();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(L.type)>=0&&a)){var Q=N(false);Q?n=setTimeout(function(){b.state.isVisible&&b.hide();},Q):i=requestAnimationFrame(function(){b.hide();});}}function mn(){b.state.isEnabled=true;}function Un(){b.hide(),b.state.isEnabled=false;}function Gn(){clearTimeout(r),clearTimeout(n),cancelAnimationFrame(i);}function Hn(L){if(process.env.NODE_ENV!=="production"&&Dn(b.state.isDestroyed,Ys("setProps")),!b.state.isDestroyed){$("onBeforeUpdate",[b,L]),ue();var Q=b.props,te=NR(e,Object.assign({},Q,LR(L),{ignoreAttributes:true}));b.props=te,ae(),Q.interactiveDebounce!==te.interactiveDebounce&&(q(),m=PR(X,te.interactiveDebounce)),Q.triggerTarget&&!te.triggerTarget?Xs(Q.triggerTarget).forEach(function(Se){Se.removeAttribute("aria-expanded");}):te.triggerTarget&&e.removeAttribute("aria-expanded"),z(),j(),R&&R(Q,te),b.popperInstance&&($e(),To().forEach(function(Se){requestAnimationFrame(Se._tippy.popperInstance.forceUpdate);})),$("onAfterUpdate",[b,L]);}}function Wn(L){b.setProps({content:L});}function xl(){process.env.NODE_ENV!=="production"&&Dn(b.state.isDestroyed,Ys("show"));var L=b.state.isVisible,Q=b.state.isDestroyed,te=!b.state.isEnabled,Se=an.isTouch&&!b.props.touch,fe=fb(b.props.duration,0,Xo.duration);if(!(L||Q||te||Se)&&!I().hasAttribute("disabled")&&($("onShow",[b],false),b.props.onShow(b)!==false)){if(b.state.isVisible=true,P()&&(w.style.visibility="visible"),j(),ne(),b.state.isMounted||(w.style.transition="none"),P()){var vt=M(),Co=vt.box,za=vt.content;gb([Co,za],0);}f=function(){var Li;if(!(!b.state.isVisible||c)){if(c=true,w.offsetHeight,w.style.transition=b.props.moveTransition,P()&&b.props.animation){var hm=M(),bu=hm.box,Fa=hm.content;gb([bu,Fa],fe),MR([bu,Fa],"visible");}V(),z(),OR(bb,b),(Li=b.popperInstance)==null||Li.forceUpdate(),$("onMount",[b]),b.props.animation&&P()&&G(fe,function(){b.state.isShown=true,$("onShown",[b]);});}},Qe();}}function Tl(){process.env.NODE_ENV!=="production"&&Dn(b.state.isDestroyed,Ys("hide"));var L=!b.state.isVisible,Q=b.state.isDestroyed,te=!b.state.isEnabled,Se=fb(b.props.duration,1,Xo.duration);if(!(L||Q||te)&&($("onHide",[b],false),b.props.onHide(b)!==false)){if(b.state.isVisible=false,b.state.isShown=false,c=false,a=false,P()&&(w.style.visibility="hidden"),q(),re(),j(true),P()){var fe=M(),vt=fe.box,Co=fe.content;b.props.animation&&(gb([vt,Co],Se),MR([vt,Co],"hidden"));}V(),z(),b.props.animation?P()&&J(Se,b.unmount):b.unmount();}}function Cl(L){process.env.NODE_ENV!=="production"&&Dn(b.state.isDestroyed,Ys("hideWithInteractivity")),F().addEventListener("mousemove",m),OR(Sd,m),m(L);}function oe(){process.env.NODE_ENV!=="production"&&Dn(b.state.isDestroyed,Ys("unmount")),b.state.isVisible&&b.hide(),b.state.isMounted&&(Ue(),To().forEach(function(L){L._tippy.unmount();}),w.parentNode&&w.parentNode.removeChild(w),bb=bb.filter(function(L){return L!==b}),b.state.isMounted=false,$("onHidden",[b]));}function Oe(){process.env.NODE_ENV!=="production"&&Dn(b.state.isDestroyed,Ys("destroy")),!b.state.isDestroyed&&(b.clearDelayTimeouts(),b.unmount(),ue(),delete e._tippy,b.state.isDestroyed=true,$("onDestroy",[b]));}}function jc(e,t){t===void 0&&(t={});var o=Xo.plugins.concat(t.plugins||[]);process.env.NODE_ENV!=="production"&&(r5(e),YR(t,o)),Qj();var r=Object.assign({},t,{plugins:o}),n=Kj(e);if(process.env.NODE_ENV!=="production"){var i=Hc(r.content),a=n.length>1;Dn(i&&a,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
72
72
 
73
73
  `,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",`
74
74
 
75
75
  `,`1) content: element.innerHTML
76
- `,"2) content: () => element.cloneNode(true)"].join(" "));}var l=n.reduce(function(s,c){var u=c&&c5(c,r);return u&&s.push(u),s},[]);return Hc(e)?l[0]:l}jc.defaultProps=Jo;jc.setDefaultProps=i5;jc.currentInput=ln;Object.assign({},_c,{effect:function(t){var o=t.state,r={popper:{position:o.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(o.elements.popper.style,r.popper),o.styles=r,o.elements.arrow&&Object.assign(o.elements.arrow.style,r.arrow);}});jc.setDefaultProps({render:YR});var XR=jc;p();var S5=forwardRef(function(t,o){let r=useMantineTheme(),[n,i]=useState(0),a=u=>{let d=t.items[u];d&&t.command({id:d});},l=()=>{i((n+t.items.length-1)%t.items.length);},s=()=>{i((n+1)%t.items.length);},c=()=>{a(n);};return useEffect(()=>i(0),[t.items]),useImperativeHandle(o,()=>({onKeyDown:({event:u})=>u.key==="ArrowUp"?(l(),true):u.key==="ArrowDown"?(s(),true):u.key==="Enter"||u.key==="Tab"?(c(),true):false})),jsx(List,{className:"items",bg:"white",listStyleType:"none",styles:u=>({root:{boxShadow:u.shadows.md,borderRadius:u.radius.xs,overflow:"hidden"},item:{span:{display:"block",width:"100%"}},itemWrapper:{display:"block"}}),children:t.items.length?t.items.map((u,d)=>jsx(List.Item,{children:jsx(UnstyledButton,{className:`item ${d===n?"is-selected":""}`,sx:m=>({backgroundColor:d===n?m.colors.blue[0]:"none"}),py:2,px:4,fz:12,w:"100%",onClick:()=>a(d),children:jsxs(Group,{spacing:"xs",children:[jsx(Center,{h:"1rem",w:"1rem",sx:{borderRadius:"100%",background:r.colors.blue[6]},children:jsx(IconBraces,{size:"0.8rem",color:"white"})}),jsx(Text,{ff:"monospace",component:"code",color:"gray.7",children:`${u}`})]})})},d)):null})}),QR=S5;var C5=()=>({char:"{{",allowedPrefixes:[" "],items:({query:e,editor:t})=>t.storage.VariablesStorage.suggestions.filter(o=>o.toLowerCase().startsWith(e.toLowerCase())).slice(0,5),render:()=>{let e,t;return {onStart:o=>{e=new ReactRenderer(QR,{props:o,editor:o.editor}),o.clientRect&&(t=XR("body",{getReferenceClientRect:o.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:true,interactive:true,trigger:"manual",placement:"bottom-start"}));},onUpdate(o){e.updateProps(o),o.clientRect&&t[0].setProps({getReferenceClientRect:o.clientRect});},onKeyDown(o){return o.event.key==="Escape"?(t[0].hide(),true):e.ref?.onKeyDown(o)},onExit(){t[0].destroy(),e.destroy();}}}}),ZR=C5;p();function xb(e){return e.replace(/<code[^>]*>([^<>]*)<\/code>/g,"$1")}p();function Tb(e){return e.replace(/({{.*?}})/g,'<code class="bespoke-var">$1</code>')}var K5=createStyles(e=>({bespokeEditor:{fontSize:14,lineHeight:1.2,backgroundColor:e.fn.lighten(e.colors.gray[0],.3),borderColor:e.colors.gray[4],borderWidth:1,borderStyle:"solid",borderRadius:e.radius.md,paddingLeft:e.spacing.xs,paddingRight:e.spacing.xs,fontWeight:400,"&.disabled":{color:e.colors.gray[7],backgroundColor:e.colors.gray[1]},":focus-visible":{outlineColor:e.colors.blue[5],backgroundColor:e.fn.lighten(e.colors.gray[0],.5)},code:{fontFamily:"monospace",color:e.colors.blue[6],fontWeight:700,letterSpacing:.02},".is-editor-empty:first-of-type::before":{color:e.colors.gray[6],content:"attr(data-placeholder)",float:"left",height:0,pointerEvents:"none"}}})),tI=()=>{let{editor:e}=useCurrentEditor(),t=useMantineTheme();return e?jsxs(Button.Group,{children:[jsx(Button,{onClick:o=>{o.preventDefault(),e.chain().focus().toggleBold().focus().run();},size:"xs",variant:"default",compact:true,children:jsx(IconBold,{size:"0.8rem",stroke:e.isActive("bold")?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().toggleItalic().run(),size:"xs",variant:"default",compact:true,children:jsx(IconItalic,{size:"0.8rem",stroke:e.isActive("italic")?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().toggleUnderline().run(),size:"xs",variant:"default",compact:true,children:jsx(IconUnderline,{size:"0.8rem",stroke:e.isActive("underline")?4:2,color:t.colors.gray[7]})})]}):null},q5=()=>{let{editor:e}=useCurrentEditor();return jsx("div",{children:jsx(BubbleMenu,{tippyOptions:{placement:"bottom"},editor:e,children:jsx(tI,{})})})},Y5=()=>{let{editor:e}=useCurrentEditor(),t=useMantineTheme();return e?jsxs(Button.Group,{children:[jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("left").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignLeft,{size:"0.8rem",stroke:e.isActive({textAlign:"left"})?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("center").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignCenter,{size:"0.8rem",stroke:e.isActive({textAlign:"center"})?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("right").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignRight,{size:"0.8rem",stroke:e.isActive({textAlign:"right"})?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("justify").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignJustified,{size:"0.8rem",stroke:e.isActive({textAlign:"justify"})?4:2,color:t.colors.gray[7]})})]}):null},X5=()=>{let{editor:e}=useCurrentEditor(),t=useMantineTheme();return e?jsxs(Button.Group,{children:[jsx(Button,{onClick:()=>e.commands.undo(),size:"xs",variant:"default",compact:true,children:jsx(IconArrowBackUp,{size:"0.8rem",color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.commands.redo(),size:"xs",variant:"default",compact:true,children:jsx(IconArrowForwardUp,{size:"0.8rem",color:t.colors.gray[7]})})]}):null},J5=({toolbarActive:e=true,toolbarLeftSection:t=null,toolbarRightSection:o=null,toolbarOptions:r={}})=>{let n=r.history??true,i=r.alignment??false,a=r.format??true;return jsxs(Group,{mb:"0.25rem",position:"apart",children:[t,e&&jsxs(Group,{children:[n&&jsx(X5,{}),i&&jsx(Y5,{}),a&&jsx(tI,{})]}),o]})};function Td(e){let{id:t,value:o,onChange:r=()=>{},variables:n,toolbarLeftSection:i,toolbarRightSection:a,toolbarOptions:l={},tipTapExtensions:s=[],bubbleMenu:c=true,disabled:u=false,editorProps:d,placeholder:m="This looks empty! Start writing some content"}=e,[g,f]=useState(false),h=useClickOutside(()=>f(false)),{classes:v}=K5(),T=JSON.stringify(n||{}),y=useMemo(()=>{let w=JSON.parse(T),k=[P5.configure({heading:false,bold:false,history:{depth:20},code:false,hardBreak:false,codeBlock:false}),aR.extend({spanning:true}),L5.extend({addKeyboardShortcuts(){return {Enter:()=>this.editor.commands.setHardBreak()}}}),M5.configure({types:["paragraph"]}),A5,sR,B5.configure({placeholder:m}),j5,...s];return w&&(k.push(lR),k.push(O5.configure({HTMLAttributes:{type:null},renderText({node:I}){return `{{${I.attrs.label??I.attrs.id}}}`},renderHTML({node:I}){return ["code",{},`{{${I.attrs.label??I.attrs.id}}}`]},suggestion:ZR()}))),k},[T,s,m]),C=({editor:w})=>{let k=xb(w.getHTML());r(k);},b=({editor:w})=>{let k=JSON.parse(T);w.storage.VariablesStorage.suggestions=Object.keys(k);};return jsx(Box,{ref:h,className:"bespoke-editor",onClickCapture:()=>f(true),children:jsx(EditorProvider,{extensions:y,content:o?Tb(o):void 0,onUpdate:C,onFocus:b,editable:!u,slotBefore:jsx(J5,{toolbarActive:g,toolbarLeftSection:i,toolbarRightSection:a,toolbarOptions:l}),editorProps:{editable:()=>!u,attributes:{id:t||"",class:`${v.bespokeEditor}${u?" disabled":""}`}},...d,children:c&&jsx(q5,{})})})}p();he();xe();var oI=createContext({mode:"simple",changeEditorMode:()=>{},reference:{locale:void 0,content:{},activate:()=>{},deactivate:()=>{},setActive:()=>{},active:false}});function oK(e){let[t,o]=useState(false),[r,n]=useState({}),i=ns();return useEffect(()=>{if(!t){n(void 0);return}Mu.get(`/api/cms/read/block?&id=${e}&include=true`).then(({data:a})=>{n(a.data[0].contentByLocale[i].content.simple);}).catch(()=>n(void 0));},[t,e,i]),{content:r,locale:i,activate:()=>o(true),deactivate:()=>o(false),setActive:o}}function rI({children:e,buttons:t,blockType:o,blockId:r}){let[n,i]=useState(()=>[E.VIZ,E.GENERATOR,E.SECTION_FLAG].includes(o)?"code":"simple"),a=oK(r),l={mode:n,changeEditorMode:i,reference:a,...t};return jsx(oI.Provider,{value:l,children:e})}function cn(){return useContext(oI)}function bK({locale:e,content:t}){return jsxs(Group,{spacing:"xs",position:"right",children:[jsx(Badge,{variant:"light",size:"xs",rightSection:jsx(Center,{children:jsx(IconLanguage,{size:rem(12)})}),children:e.toUpperCase()}),jsx(aI,{content:t})]})}function aI({content:e}){return jsx(CopyButton,{value:e,timeout:2e3,children:({copied:t,copy:o})=>jsx(Tooltip,{label:t?"Copied":"Copy",withArrow:true,position:"right",children:jsx(ActionIcon,{size:"xs",color:t?"teal":"gray",variant:"subtle",onClick:()=>{o();let r=new Blob([e],{type:"text/html"}),n=new ClipboardItem({"text/html":r});navigator.clipboard.write([n]);},children:t?jsx(IconCheck,{style:{width:rem(16)}}):jsx(IconCopy,{style:{width:rem(16)}})})})})}function yK({referenceLocale:e,referenceContent:t}){return jsx(Stack,{spacing:"xs",children:jsx(Td,{value:t,toolbarLeftSection:jsx(Text,{size:"0.625rem",tt:"uppercase",fw:700,color:"gray",children:"Reference Content"}),toolbarRightSection:jsx(bK,{locale:e,content:t}),toolbarOptions:{history:false,format:false,alignment:false},disabled:true})})}function Qo({field:e,handleEditor:t,value:o,referenceContent:r,referenceLocale:n,variables:i,editorConfig:a={}}){return jsxs(Stack,{spacing:0,children:[jsx(Td,{id:e,onChange:l=>{t(e,He(l));},toolbarLeftSection:jsx(Text,{component:"label",htmlFor:e,size:"xs",transform:"uppercase",weight:"bold",color:"gray",mb:"xs",children:titleCase(e)}),toolbarRightSection:jsx(aI,{content:o}),toolbarOptions:{history:true,alignment:e!=="tooltip",format:true},value:o,variables:i,placeholder:`This looks empty. Start adding content for the ${e}! You can add automated {{variables}}`,...a}),r&&jsx(Box,{mt:"xs",children:jsx(yK,{referenceContent:r[e],referenceLocale:n})})]})}function vK({fields:e,locale:t,defaultContent:o,onChange:r,variables:n}){let[i,a]=useState(()=>td(o)),{reference:l}=cn();useEffect(()=>{r(i,t);},[]);let s=(u,d)=>{a(m=>({...m,[u]:d}));},[c]=useDebouncedValue(i,500);return useEffect(()=>{let u=Object.keys(c).reduce((m,g)=>({...m,[g]:He(c[g])}),{}),d=nn(u);r({simple:u,logic:d},t);},[c,t]),jsx(Stack,{spacing:"xl",children:e.map(({field:u,editorConfig:d})=>jsx(Qo,{field:u,handleEditor:s,value:i[u]||"",referenceContent:l.content,referenceLocale:l.locale,variables:n,editorConfig:d},u))})}var sI=vK;p();function EK({label:e,...t}){return jsxs(Group,{position:"apart",spacing:"lg",py:"xs",...t,children:[jsx(Text,{children:e}),jsx(Tooltip,{label:"This setting will be saved for all languages.",children:jsx(ThemeIcon,{size:"xs",variant:"light",radius:"xl",color:"yellow",children:jsx(IconLanguageOff,{size:"0.75rem"})})})]})}var Wt=EK;he();p();var La={SINGLE:"single",MULTI:"multi"},Rb={SEGMENTED_CONTROL:"segmented control",SELECTOR:"selector"},xi={STATIC:"static",DYNAMIC:"dynamic"},Ib=e=>e&&Array.isArray(e)&&e.length>0,kd=e=>Ib(e)&&["string"].includes(typeof e[0]),cI=e=>{let{name:t,type:o,optionsType:r,options:n}=e;return [t,o,r,n].every(Boolean)?r===xi.STATIC?n.static?.length>0&&n.static?.every(i=>i.id):n.dynamic?.isPrimitiveType?true:!!n.dynamic?.idKey:false},Ed=(e,t,o)=>{let r,n;switch(o){case xi.STATIC:r=e===La.SINGLE?t.static.find(i=>i.isDefault)?.id:t.static.filter(i=>i.isDefault).map(i=>i.id),n=t.static.map(({id:i,label:a})=>({id:i,label:a||i}));break;case xi.DYNAMIC:if(t.dynamic){let{optionsVar:i,idKey:a,labelKey:l,imageKey:s,defaultVar:c,isPrimitiveType:u}=t.dynamic;c&&(r=`variables["${c}"]`),n=u?`variables["${i}"]`:`(variables["${i}"] || []).map(d => ({id: String(d["${a}"]), label: String(d["${l||a}"]), imageUrl: String(d["${s||null}"])}))`;}break;}return {logicOptions:n,defaultValue:r}};function LK({option:e,editOption:t,deleteOption:o}){return jsxs("tr",{className:"reports-selector-static-option",children:[jsx("td",{children:jsx(Checkbox,{checked:e.isDefault,onChange:r=>t({isDefault:r.currentTarget.checked})})}),jsx("td",{children:jsx(TextInput,{placeholder:"Option value",value:e.id,onChange:r=>{t({id:r.currentTarget.value});},error:e.id.indexOf(" ")>-1?"Please, avoid the usage of spaces in the ID":false})}),jsx("td",{children:jsx(TextInput,{placeholder:"Option label",value:e.label,onChange:r=>t({label:r.currentTarget.value})})}),jsx("td",{children:jsx(ActionIcon,{onClick:o,children:jsx(IconTrash,{})})})]})}function MK({staticOptions:e,setStaticOptions:t}){let o=useCallback(()=>t([...e,{isDefault:!e.length,id:"",label:""}]),[e,t]),r=useCallback((i,a)=>{if(!a||i>=e.length||i<0)return;let l=[...e];l.splice(i,1,{...e[i],...a}),t(l);},[e,t]),n=useCallback(i=>{let a=[...e];a.splice(i,1),t(a);},[e,t]);return jsxs(Fragment,{children:[jsx(Input.Wrapper,{required:true,label:"Static Selector Options",children:jsxs("table",{children:[jsx("thead",{children:e.length>0&&jsx("tr",{children:["Default","ID","Label",""].map((i,a)=>jsx("td",{className:`${a===0?"selector-option-default-col":""} ${a===1?"required":""}`,children:i},`heading-${a}`))})}),jsx("tbody",{children:e.map((i,a)=>jsx(LK,{option:i,editOption:l=>r(a,l),deleteOption:()=>n(a)},`option-${a}`))})]})}),jsx(ActionIcon,{onClick:o,children:jsx(IconPlus,{})})]})}function BK({id:e,dynamicOptions:t,setDynamicOptions:o}){let{optionsVar:r,idKey:n,labelKey:i,defaultVar:a,imageKey:l,isPrimitiveType:s}=t,c=ot(e),[u,d]=useState(false),[m,g]=useState({}),[f,h]=useState([]),[v,T]=useState([]);useEffect(()=>{c||(g({}),h([]));let I=Object.entries(c).filter(([,P])=>Ib(P)).reduce((P,[_,D])=>(P[_]=D,P),{});g(I);let O=Object.keys(c);h(O),d(true);},[c]);let y=useCallback((I,O)=>{o({...t,[I]:O});},[t]);useEffect(()=>{if(!Object.keys(m).length)return;let I=kd(m[r]);if(I)T([]),y("idKey",null),y("labelKey",null),y("imageKey",null);else {let O=new Set;(m[t.optionsVar]||[]).forEach(_=>Object.keys(typeof _=="object"?_:{}).forEach(D=>O.add(D)));let P=Array.from(O).sort().map(_=>_);T(P);}y("isPrimitiveType",I);},[m,r]);let C=useCallback(I=>{o({...t,optionsVar:I,idKey:null,labelKey:null,imageKey:null});},[t,o]),b=useMemo(()=>{let I=[];return m&&r&&n&&Array.isArray(m[r])&&(I=m[r].filter(O=>`${O[n]}`.indexOf(" ")>0)),I.length>0?`One or more ID's have spaces on it. (
77
- ${I.map(O=>`"${O[n]}"`).join(",")}
78
- ) Avoid this, please.`:false},[m,r,n]);if(!u)return null;let w=Object.keys(m),k=I=>I&&Array.isArray(I)&&I.length;return jsxs(Fragment,{children:[jsx(Select,{label:"Options List Variable",placeholder:"Pick a variable",value:k(w)&&r,required:true,onChange:C,data:w}),jsx(Select,{label:"Options ID Key",placeholder:"Pick a property key",value:k(v)&&n,required:!s,disabled:s,onChange:I=>y("idKey",I),data:v,error:b}),jsx(Select,{label:"Options Label Key",placeholder:"Pick a property key",disabled:s,clearable:true,value:k(v)&&i,onChange:I=>y("labelKey",I),data:v}),jsx(Select,{label:"Options Image Key",placeholder:"Pick a property key",disabled:s,clearable:true,value:k(v)&&l,onChange:I=>y("imageKey",I),data:v}),jsx(Select,{label:"Default ID Variable",placeholder:"Pick a variable",clearable:true,value:k(f)&&a,onChange:I=>y("defaultVar",I),data:f})]})}function el(e,t,o){return e&&e[t]||o}function DK(e){let{id:t,executeButton:o,onChange:r,simpleState:n,referenceContent:i,referenceLocale:a,variables:l}=e,[s,c]=useState(()=>{let m=n&&n.options&&Object.prototype.hasOwnProperty.call(n?.options,"dynamic")&&Object.prototype.hasOwnProperty.call(n?.options,"static");return {selectorIdentifier:el(n,"name",""),selectorType:el(n,"type",La.SINGLE),selectorComponent:el(n,"component",Rb.SELECTOR),options:n&&m?n.options:{static:[],dynamic:{}},optionsType:el(n,"optionsType","static"),hideLabel:el(n,"hideLabel","false"),resetSectionVars:el(n,"resetSectionVars","false")}});useEffect(()=>{let{selectorIdentifier:m,selectorType:g,selectorComponent:f,options:h,optionsType:v,hideLabel:T,resetSectionVars:y}=s,C={name:m,hideLabel:T,resetSectionVars:y,component:f,type:g},{logicOptions:b,defaultValue:w}=Ed(g,h,v);w&&(C.defaultValue=w),C.options=b;let k=`return ${Hs(C)};`,I={name:m,type:g,component:f,hideLabel:T,resetSectionVars:y,defaultValue:w,optionsType:v,options:h},O=cI(I);r(I,k,O);},[s]);let u=(m,g)=>c(f=>({...f,[m]:g})),d=nr[E.SELECTOR].find(m=>m.field===Ae.SELECTOR_NAME)?.editorConfig;return jsxs(Fragment,{children:[jsxs(Stack,{children:[jsx(Qo,{field:"name",value:s.selectorIdentifier,handleEditor:(m,g)=>u("selectorIdentifier",g),referenceContent:i,referenceLocale:a,variables:l,editorConfig:d}),jsx(Checkbox,{label:jsx(Wt,{label:"Hide Label",py:0}),checked:s.hideLabel==="true",onChange:m=>u("hideLabel",m.currentTarget.checked?"true":"false")})]}),jsx(Select,{label:jsx(Wt,{label:"Selector Type"}),value:s.selectorType,onChange:m=>u("selectorType",m),data:Object.values(La)}),s.selectorType===La.SINGLE&&jsx(Select,{label:jsx(Wt,{label:"Selector Component"}),value:s.selectorComponent,onChange:m=>u("selectorComponent",m),data:Object.values(Rb)}),jsx(Select,{label:jsx(Wt,{label:"Options Type"}),value:s.optionsType,onChange:m=>u("optionsType",m),data:Object.values(xi)}),s.optionsType===xi.STATIC?jsx(MK,{staticOptions:s.options.static,setStaticOptions:m=>u("options",{...s.options,static:m})}):jsx(BK,{dynamicOptions:s.options.dynamic,setDynamicOptions:m=>u("options",{...s.options,dynamic:m}),id:t}),jsx(Checkbox,{my:"md",label:jsx(Wt,{label:"Reset SectionVariables on change",py:0}),checked:s.resetSectionVars==="true",onChange:m=>u("resetSectionVars",m.currentTarget.checked?"true":"false")}),o]})}var dI=DK;p();p();p();var fI=["xs","sm","md","lg","xl"],qK=["0","1","2","3","4","5"],zn={none:{value:"none",label:"No Icon"},tabler:{value:"tabler",label:"Bespoke (Tabler)",link:"https://tablericons.com",text:"Tabler Icons"},custom:{value:"custom",label:"Custom Icon"}},YK=forwardRef(({value:e,iconType:t="tabler",...o},r)=>jsx("div",{ref:r,...o,children:jsxs(Group,{noWrap:true,children:[jsx(Image,{width:20,height:20,src:`/api/cms/read/icons/${t}/icon.svg?name=${e}`,alt:`Icon preview ${e}`}),jsx(Text,{size:"sm",children:e})]})}));function Ma(e){let[t,o]=useState(e?._iconType??"none"),[r,n]=useState(e?._icon??""),[i,a]=useState([]),[l,s]=useState(""),[c,u]=useState(e?._iconVariant??"transparent"),[d,m]=useState(e?._iconSize??"md"),[g,f]=useState(e?._iconRadius??"md"),[h,v]=useState(e?._iconPadding??"1"),T=[zn.none.value,zn.custom.value].includes(t),y=useRef(null),C=useMemo(()=>({_icon:r,_iconType:t,_defaultIcon:l,_iconVariant:c,_iconSize:d,_iconRadius:g,_iconPadding:h}),[r,t,l,c,d,g,h]),b=k=>{n(""),o(k);};useEffect(()=>{T||Mu.get(`/api/cms/list/icons/${t}`).then(k=>{a(k.data.data.results),s(k.data.data.results[0]);});},[t]);let w=jsx(Accordion,{variant:"separated",children:jsxs(Accordion.Item,{value:"icon",children:[jsx(Accordion.Control,{icon:jsx(IconPhotoFilled,{}),children:jsxs(Text,{children:["Icon configuration: ",zn[t]&&jsx("strong",{children:zn[t].label})]})}),jsx(Accordion.Panel,{children:jsxs(Stack,{children:[jsx(Input.Wrapper,{label:"Title's icon",children:jsx(SegmentedControl,{fullWidth:true,value:t,onChange:b,data:Object.values(zn)})}),!T&&jsx(Select,{label:"Choose an icon from the list",searchable:true,description:jsxs(Fragment,{children:["Powered by"," ",jsx("a",{style:{textDecoration:"underline"},href:zn[t].link,target:"_blank",rel:"noreferrer",children:zn[t].text}),"."]}),defaultValue:l,value:r,required:true,onChange:k=>n(k||""),data:i,limit:10,itemComponent:YK,disabled:!i||i.length===0,icon:jsx(Image,{p:5,src:`/api/cms/read/icons/${t}/icon.svg?name=${r||l}`,alt:"Icon preview"})}),t===zn.custom.value&&jsxs(Flex,{align:"flex-end",children:[jsx(TextInput,{ref:y,placeholder:"e.g '/image{{id1}}.png' or 'http://site/image.png'",label:"Enter an icon path",required:true,defaultValue:r,description:"Add an absolute or a relative path url",onBlur:k=>n(k.currentTarget.value),sx:{flexGrow:1}}),jsx(ActionIcon,{maw:36,size:36,onClick:()=>y.current?n(y.current.value??""):void 0,sx:{flexGrow:0},children:jsx(IconFileUpload,{})})]}),t!==zn.none.value&&jsxs(Fragment,{children:[jsx(Select,{label:"Variant design",description:jsxs(Fragment,{children:["We are using"," ",jsx("a",{style:{textDecoration:"underline"},href:"https://mantine.dev/core/theme-icon/",target:"_blank",rel:"noreferrer",children:"ThemeIcon variants"}),"."]}),value:c,required:true,onChange:k=>u(k||"transparent"),data:[{value:"transparent",label:"Transparent"},{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"light",label:"Light"},{value:"filled",label:"Filled"}]}),jsx(Input.Wrapper,{label:"Size",children:jsx(SegmentedControl,{fullWidth:true,value:d,onChange:m,data:fI})}),jsx(Input.Wrapper,{label:"Radius",children:jsx(SegmentedControl,{fullWidth:true,value:g,onChange:f,data:fI})}),jsx(Input.Wrapper,{label:"Padding",children:jsx(SegmentedControl,{fullWidth:true,value:h,onChange:v,data:qK})})]})]})})]})});return {simpleIconState:C,panel:w}}p();function Ei(e,t){let[o,r]=useState({...t,...e});return {state:o,updateState:(i,a)=>{let l={...o,[i]:a};r(l);}}}he();var tq={type:"list",title:"",shotTitle:""},oq=[{value:"list",label:"List"},{value:"multilevel",label:"Multilevel"}];function Bb({simpleState:e,onChange:t,variables:o,referenceContent:r,referenceLocale:n}){let{state:i,updateState:a}=Ei(e,tq),{simpleIconState:l,panel:s}=Ma(e);return useEffect(()=>{let c={...i,...l},u=nn(c);t(c,u);},[i,l]),jsxs(Stack,{children:[jsx(Title,{order:4,children:"Nav UI"}),jsx(Select,{label:"Nav Type",data:oq,value:i.type,defaultValue:"list",onChange:c=>a("type",c)}),nr[E.NAV].map(({field:c,editorConfig:u})=>jsx(Qo,{field:c,value:i[c],handleEditor:a,referenceContent:r,referenceLocale:n,variables:o,editorConfig:u},c)),s]})}p();function Db({executeButton:e,onChange:t,simpleState:o}){let[r,n]=useState(o?.compare??"variant"),[i,a]=useState(o?.limit??4);return useEffect(()=>{t({compare:r,limit:i});},[r,i]),jsxs(Stack,{children:[jsx(Radio.Group,{description:"Valid only for single-dimensional profiles",label:"Compare with members of:",onChange:n,value:r,children:jsxs(Group,{children:[jsx(Radio,{label:"Same report",value:"report"}),jsx(Radio,{label:"Same dimension",value:"dimension"}),jsx(Radio,{label:"Same variant",value:"variant"})]})}),jsx(NumberInput,{label:"Related reports limit",min:1,onChange:l=>a(l),type:"number",value:i}),e]})}p();function Nb({executeButton:e,onChange:t,simpleState:o}){let[r,n]=useState(o?.label??""),[i,a]=useState(o?.showIcon??true),[l,s]=useState(o?.fullWidth??false),[c,u]=useState(o?.showWhenDisabled??false);return useEffect(()=>{t({label:r,showIcon:i,fullWidth:l,showWhenDisabled:c});},[r,i,l,c,t]),jsxs(Stack,{children:[jsx(TextInput,{placeholder:"Label for reset section state button",value:r,onChange:d=>n(d.target.value),label:"Label"}),jsxs(Group,{children:[jsx(Switch,{checked:i,label:"Show icon",onChange:d=>a(d.currentTarget.checked)}),jsx(Switch,{checked:l,label:"Full width",onChange:d=>s(d.currentTarget.checked)}),jsx(Switch,{checked:c,label:"Show when disabled",onChange:d=>u(d.currentTarget.checked)})]}),e]})}p();he();var fq={title:"Title",tooltip:"",slug:""};function zb({onChange:e,simpleState:t,variables:o,referenceContent:r,referenceLocale:n}){let{state:i,updateState:a}=Ei(t,fq),{simpleIconState:l,panel:s}=Ma(t);return useEffect(()=>{let c={...i,...l},u=nn(c);e(c,u);},[l,i]),jsxs(Stack,{children:[nr[E.TITLE].map(({field:c,editorConfig:u})=>jsx(Qo,{field:c,value:i[c],handleEditor:a,referenceContent:r,referenceLocale:n,variables:o,editorConfig:u},c)),s]})}p();var Tq=[{value:"left",label:"Left"},{value:"center",label:"Center"},{value:"right",label:"Right"}];function Fb({executeButton:e,onChange:t,simpleState:o}){let[r,n]=useState(o?.label??""),[i,a]=useState(o?.removeLabel??""),[l,s]=useState(o?.showIcon??true),[c,u]=useState(o?.position??"center");return useEffect(()=>{t({label:r,removeLabel:i,showIcon:l,position:c});},[r,l,i,c,t]),jsxs(Stack,{children:[jsx(TextInput,{placeholder:"Label for comparison button",value:r,onChange:d=>n(d.target.value),label:"Label"}),jsx(TextInput,{placeholder:"Label for remove comparison button",value:i,onChange:d=>a(d.target.value),label:"Remove Label"}),jsx(Group,{children:jsx(Switch,{checked:l,label:"Show icon",onChange:d=>s(d.currentTarget.checked)})}),jsx(Select,{label:"Button position",data:Tq,value:c,onChange:u}),e]})}p();he();function Vb({simpleState:e,onChange:t,variables:o,referenceContent:r,referenceLocale:n}){let{state:i,updateState:a}=Ei(e,{title:"",value:"",subtitle:"",tooltip:""}),{simpleIconState:l,panel:s}=Ma(e);return useEffect(()=>{let c={...i,...l},u=nn(c);t(c,u);},[l,i]),jsxs(Stack,{children:[nr[E.STAT].map(({field:c,editorConfig:u})=>jsx(Qo,{field:c,value:i[c],handleEditor:a,referenceContent:r,referenceLocale:n,variables:o,editorConfig:u},c)),s]})}p();xe();var Wq={enableBottomToolbar:true,enableColumnActions:true,enableColumnFilters:true,enableColumnResizing:true,enableDensityToggle:true,enableFullScreenToggle:false,enableGlobalFilter:true,enableHiding:true,enablePagination:true,enableSorting:true,enableStickyHeader:true,enableTopToolbar:true},kI={enableBottomToolbar:{label:"Enable bottom toolbar",desc:"Show or hide the bottom toolbar. By disabling it, pagination will also be hidden."},enableColumnActions:{label:"Enable column actions",desc:"Enables or disables column actions for all columns. Column actions include sort, filter, show/hide column and reset column size."},enableColumnFilters:{label:"Enable column filters",desc:"Enables or disables the filter options available on columns."},enableColumnResizing:{label:"Enable column resizing",desc:"Enables the column resizing feature for all columns."},enableDensityToggle:{label:"Enable density toggle",desc:"Enable the density toggle that allows users to modify the height of each row. Disabling it will hide the density toggle button in the top toolbar."},enableFullScreenToggle:{label:"Enable full screen toggle",desc:"Enable or disable the full screen toggle feature. Disabling it will hide the full screen toggle button in the top toolbar."},enableGlobalFilter:{label:"Enable global filter",desc:"Enable global filter feature to filter data on all columns and rows. Disabling it will hide the global filter button in the top toolbar."},enableHiding:{label:"Enable hiding",desc:"Enable hiding columns feature. Disabling it will hide the hiding button in the top toolbar."},enablePagination:{label:"Enable pagination",desc:"Enable pagination feature. Disabling it will hide the pagination options in the bottom toolbar."},enableSorting:{label:"Enable sorting",desc:"Enable sorting feature for all columns."},enableStickyHeader:{label:"Enable sticky header",desc:"Allows you to maintain the column headers when scrolling through the rows of the table."},enableTopToolbar:{label:"Enable top toolbar",desc:"Show or hide the top toolbar. By disabling it, globar filter, hiding, density and full screen toggles will also be hidden."}},jq={density:"xs"},EI=["5","10","15","20","25","30","50","100"],wI={pageIndex:0,pageSize:10},RI=e=>e&&Array.isArray(e)&&e.some(t=>typeof t=="object"&&t!==null),Kq=forwardRef(function({customLabels:t,customLabelsHandler:o,index:r,isActiveRefenceContent:n=false,option:i,referenceColumns:a=[],selectedColumnsHandler:l,...s},c){let u=t.find(g=>g.key===i.label)?.label||"",m=a.find(g=>g.accessorKey===i.label)?.header||i.label;return jsxs(Group,{grow:true,ref:c,...s,children:[jsxs(Group,{children:[jsx(IconGripVertical,{}),jsx(Checkbox,{checked:i.checked,label:i.label,onChange:g=>l.setItemProp(r,"checked",g.currentTarget.checked)})]}),jsx(Input,{disabled:!i.checked,onChange:g=>o.setItemProp(r,"label",g.currentTarget.value),value:u}),n&&jsx(Input,{disabled:true,value:m})]},`table-group-${i.label}-${r}`)});function jb(e){let{executeButton:t,id:o,onChange:r,referenceContent:n={},referenceLocale:i,simpleState:a}=e,{columns:l}=n,s=rs(),c=useMemo(()=>s!==i&&n&&Object.keys(n).length>0,[s,n,i]),u=ot(o),[d,m]=useState([]),[g,f]=useListState([]),[h,v]=useState([]),[T,y]=useState(false),[C,b]=useState({}),[w,k]=useState(wI),[I,O]=useState({rowsPerPageOptions:EI}),[P,_]=useListState([]),[D,L]=useState(null),[R,z]=useSetState(Wq),[A,V]=useState(jq),[j,B]=useState({}),U=useMemo(()=>P.every(G=>G.checked),[P]),$=useMemo(()=>P.some(G=>G.checked)&&!U,[U,P]);useEffect(()=>{if(!a||!Object.keys(a).length)return;let G=u[a.variable]||[],J=new Set;G.filter(q=>typeof q=="object"&&q!==null).forEach(q=>{Object.keys(q).forEach(ce=>J.add(ce));});let ee={},ne=[];a.columns&&Object.keys(a.columns)&&a.columns.forEach(q=>{ee[q.accessorKey]=q.header;});let X=[],W=[];Array.from(J).forEach(q=>{W.push({key:q,label:ee[q]||q}),X.push({checked:!!ee[q],key:randomId(),label:q}),ne.push(q);}),f.setState(W),_.setState(X);let{initialState:K={},state:oe={},mantinePaginationProps:re={},...ue}=a.tableProps||{},Ee=oe.columnOrder.filter(q=>ne.includes(q));Ee.push(ne.filter(q=>!oe.columnOrder.includes(q))),m(Ee.flat()||[]),O(re),k(K.pagination),z({...ue}),B(oe),V(K),L(a.variable||"");},[]),useEffect(()=>{if(!u){b({});return}let G=Object.entries(u).filter(([ee,ne])=>RI(ne)).reduce((ee,[ne,X])=>(ee[ne]=X,ee),{});b(G);let J=Object.keys(G);v(J);},[u]);let Y=G=>{if(L(G),!G||!RI(C[G])){y(false),_.setState([]);return}let J=C[G];if(J.every(K=>typeof K=="object"&&K===null)){y(false),_.setState([]);return}J.every(K=>typeof K=="object"&&K!==null)?y(false):y(true);let ee=new Set;J.filter(K=>typeof K=="object"&&K!==null).forEach(K=>{Object.keys(K).forEach(oe=>ee.add(oe));});let ne=[],X=[],W=[];Array.from(ee).forEach(K=>{ne.push({checked:true,key:randomId(),label:K}),X.push({key:K,label:K}),W.push(K);}),_.setState(ne),f.setState(X),m(W);};useEffect(()=>{let G={};g.forEach(oe=>{G[oe.key]=oe.label;});let J=P.filter(oe=>oe.checked).map(oe=>({accessorKey:oe.label,header:G[oe.label]})),ee={...A,pagination:w},ne={...j,columnOrder:d},X={columns:J,data:D?`variables["${D}"]`:[],tableProps:{...R,initialState:ee,state:ne,mantinePaginationProps:I},variable:D||""},W=`return ${Hs(X)};`,K={columns:J,data:D?`variables["${D}"]`:[],tableProps:{...R,initialState:ee,state:ne,mantinePaginationProps:I},variable:D||""};r(K,W);},[d,g,I,w,P,D,R,j,A]);let F=useCallback(G=>{if(!G.destination||G.source.index===G.destination.index)return;let J=[...d],[ee]=J.splice(G.source.index,1);J.splice(G.destination.index,0,ee),m(J),B(ne=>{let X=ne;return X.columnOrder=J,X});},[d]);return jsxs(Fragment,{children:[jsxs(Stack,{mb:"sm",children:[jsx(Select,{clearable:true,data:h,description:"Select an array of data available in the block inputs to use as data input for the table.",label:"Data input",onChange:G=>Y(G),searchable:true,value:D}),D&&C[D]&&P.length>0&&jsxs(Fragment,{children:[jsx(Input.Wrapper,{description:"Select the columns to display in the table.",error:T&&"There is a mix of types in the input data. Only object types rows will be kept.",label:"Selected columns",children:jsxs(Stack,{mt:"xs",children:[jsxs(Group,{grow:true,children:[jsx(Text,{fz:"xs",children:"Selected"}),jsx(Text,{fz:"xs",children:"Label"}),c&&jsxs(Group,{spacing:"xs",children:[jsx(Text,{fz:"xs",children:"Reference Label"}),jsx(Badge,{variant:"light",size:"xs",rightSection:jsx(Center,{children:jsx(IconLanguage,{size:rem(12)})}),children:i.toUpperCase()})]})]}),jsx(Checkbox,{checked:U,indeterminate:$,label:"All",onChange:()=>_.setState(G=>G.map(J=>({...J,checked:!U})))}),jsx(ScrollArea.Autosize,{mah:300,children:jsx(DragDropContext,{onDragEnd:F,children:jsx(Droppable,{droppableId:"columns",children:G=>jsx("div",{ref:G.innerRef,...G.droppableProps,children:d.map((J,ee)=>{let ne=P.findIndex(W=>W.label===J),X=P[ne];return jsx(Draggable,{draggableId:`${X.label}`,index:ee,isDragDisabled:!X.checked,children:W=>jsx(Kq,{customLabels:g,customLabelsHandler:f,index:ne,isActiveRefenceContent:c,option:X,ref:W.innerRef,referenceColumns:l,selectedColumnsHandler:_,...W.draggableProps,...W.dragHandleProps})},X.label)})})})})})]})}),jsx(Accordion,{variant:"separated",children:jsxs(Accordion.Item,{value:"custom-props",children:[jsx(Accordion.Control,{children:"Custom properties"}),jsx(Accordion.Panel,{children:jsx(Stack,{children:jsxs(Input.Wrapper,{description:"Select the needed table options.",label:"Table options",children:[jsx(Group,{mt:"xs",children:Object.keys(R).map(G=>jsx(Checkbox,{checked:R[G],label:jsx(Tooltip,{label:kI[G]?.desc||G,multiline:true,children:jsx(Text,{children:kI[G]?.label||G})}),onChange:()=>z({[G]:!R[G]})},`table-prop-${G}`))}),R?.enablePagination&&jsxs(Fragment,{children:[jsx(Divider,{mt:"xs"}),jsxs(Input.Wrapper,{description:"Customize initial pagination properties.",label:"Pagination props",mt:"xs",children:[jsxs(Group,{grow:true,children:[jsx(NumberInput,{label:"Initial page",min:0,onChange:G=>{k(J=>({...J,pageIndex:G}));},value:w.pageIndex}),jsx(Select,{data:I.rowsPerPageOptions||[],getCreateLabel:G=>`+ Create ${G}`,label:"Initial page size",onChange:G=>{k(J=>({...J,pageSize:parseInt(G,10)}));},searchable:true,value:w.pageSize.toString()})]}),jsxs(Group,{align:"flex-end",grow:true,children:[jsx(MultiSelect,{clearable:true,creatable:true,data:I.rowsPerPageOptions||[],getCreateLabel:G=>`+ Create ${G}`,label:"Page size options",onChange:G=>{O(J=>({...J,rowsPerPageOptions:G.sort((ee,ne)=>parseInt(ee,10)-parseInt(ne,10))})),G&&G.length>0&&!G.includes(w.pageSize.toString())&&k(J=>({...J,pageSize:parseInt(G[0],10)}));},onCreate:G=>(O(J=>({...J,rowsPerPageOptions:[...J.rowsPerPageOptions||[],G].sort((ee,ne)=>parseInt(ee,10)-parseInt(ne,10))})),G),searchable:true,value:I.rowsPerPageOptions||[]}),jsx(Button,{color:"yellow",onClick:()=>{O(G=>({...G,rowsPerPageOptions:EI})),k(wI);},children:"Reset page sizes values"})]})]})]})]})})})]})})]})]}),t]})}p();xe();he();p();var II=e=>{let{dataVar:t,levelsVar:o}=e;return !![t,o].every(Boolean)},Dd=e=>{let t,o,{colorKey:r,dataVar:n,iconKey:i,defaultVar:a,isPrimitiveType:l,levelsVar:s,searchIndexKey:c}=e;a&&typeof a=="string"&&(t=`variables["${a}"].value`,o=`variables["${a}"].type`);let u=l?`variables["${n}"]`:`(variables["${n}"] || []).map((d) => ({...d, colorKey: String(d["${r}"]), iconKey: String(d["${i}"]), searchIndexKey: String(d["${c}"])}))`;return {logicLevels:`variables["${s}"]`,logicOptions:u,defaultValue:t,defaultValueType:o}};ds();var qb=e=>nr[E.MULTIHIERARCHY_SELECTOR].find(t=>t.field===e)?.editorConfig,Xq=e=>e&&Array.isArray(e)&&e.some(t=>typeof t=="object"&&t!==null),Jq=e=>e&&e.type&&e.value,rl=e=>e&&Array.isArray(e)&&e.length;function zo(e,t,o){return e&&e[t]||o}function Yb(e){let{executeButton:t,id:o,onChange:r,referenceContent:n,referenceLocale:i,simpleState:a}=e,l=ot(o),[s,c]=useState(false),[u,d]=useState(()=>({allLabel:zo(a,"allLabel","All"),colorKey:zo(a,"colorKey",""),dataVar:zo(a,"dataVar",""),defaultVar:zo(a,"defaultVar",""),hideLabel:zo(a,"hideLabel","false"),resetSectionVars:zo(a,"resetSectionVars","false"),iconKey:zo(a,"iconKey",""),isPrimitiveType:zo(a,"isPrimiteType",false),levelsVar:zo(a,"levelsVar",""),limit:zo(a,"limit",0),placeholder:zo(a,"placeholder",""),searchIndexKey:zo(a,"searchIndexKey",""),searchIndexSeparator:zo(a,"searchIndexSeparator","|"),selectorIdentifier:zo(a,"label","")})),[m,g]=useState([]),[f,h]=useState([]),[v,T]=useState({}),[y,C]=useState({}),[b,w]=useState([]),k=useCallback((R,z,A=false)=>d(V=>({...V,[R]:!z&&A?"":z})),[]);useEffect(()=>{if(!l){g([]),h([]),T({}),C({});return}let R=Object.entries(l).filter(([j,B])=>Xq(B)).reduce((j,[B,U])=>(j[B]=U,j),{}),z=Object.entries(l).filter(([,j])=>Jq(j)).reduce((j,[B,U])=>(j[B]=U,j),{});C(R),T(z);let A=Object.keys(R),V=Object.keys(z);g(A),h(V),c(true);},[l]),useEffect(()=>{if(!Object.keys(y).length)return;let R=kd(y[u.dataVar]);if(R)w([]),k("colorKey",""),k("iconKey",""),k("searchIndexKey","");else {let z=new Set;(y[u.dataVar]||[]).forEach(V=>Object.keys(typeof V=="object"?V:{}).forEach(j=>z.add(j)));let A=Array.from(z).sort().map(V=>V);w(A);}k("isPrimitiveType",R);},[y,u.dataVar]),useEffect(()=>{let{allLabel:R,colorKey:z,dataVar:A,defaultVar:V,hideLabel:j,resetSectionVars:B,iconKey:U,levelsVar:$,limit:Y,placeholder:F,searchIndexKey:G,searchIndexSeparator:J,selectorIdentifier:ee}=u,ne={allLabel:R,colorKey:z,dataVar:A,defaultVar:V,label:ee,hideLabel:j,resetSectionVars:B,iconKey:U,levelsVar:$,limit:Y,placeholder:F,searchIndexKey:G,searchIndexSeparator:J},{logicOptions:X,logicLevels:W,defaultValue:K,defaultValueType:oe}=Dd(ne);K&&oe&&(ne.defaultValue=K,ne.defaultValueType=oe),ne.data=X,ne.levels=W;let re=`return ${Hs(ne)};`,ue=ne,Ee=II(ue);r(ue,re,Ee);},[u]);let I=useCallback(R=>{k("dataVar",R),k("defaultVar",{}),k("colorKey",""),k("iconKey",""),k("searchIndexKey","");},[k]);if(!s)return null;let O=Object.keys(y),P=Object.keys(v),_=qb(Ae.MULTIHIERARCHY_SELECTOR_ALL_LABEL),D=qb(Ae.MULTIHIERARCHY_SELECTOR_NAME),L=qb(Ae.MULTIHIERARCHY_SELECTOR_PLACEHOLDER);return jsxs(Fragment,{children:[jsxs(Stack,{mb:"sm",spacing:"xs",children:[jsx(Qo,{field:"label",value:u.selectorIdentifier,handleEditor:(R,z)=>{k("selectorIdentifier",z);},referenceContent:n,referenceLocale:i,variables:l,editorConfig:D}),jsx(Checkbox,{label:jsx(Wt,{label:"Hide Label",py:0}),checked:u.hideLabel==="true",onChange:R=>k("hideLabel",R.currentTarget.checked?"true":"false")}),jsx(Select,{data:m,description:"(Required) Select an array of data available in the block inputs to use as data input.",label:jsx(Wt,{label:"Data Input"}),onChange:R=>I(R),value:rl(O)&&u.dataVar}),jsx(Select,{data:m,description:"(Required) Select an array of {label, value} items in the block inputs to use as levels.",label:jsx(Wt,{label:"Levels Input"}),onChange:R=>k("levelsVar",R),value:rl(O)&&u.levelsVar}),jsx(Select,{clearable:true,data:f,description:"(Optional) Select an object with {type, value} keys in the block inputs to use as default value.",label:jsx(Wt,{label:"Default Value"}),onChange:R=>{if(!R){k("defaultVar","");return}k("defaultVar",R);},value:rl(P)&&u.defaultVar}),jsx(NumberInput,{description:"(Optional) Sets a limit for selected values. Set 0 for no limit.",label:jsx(Wt,{label:"Limit"}),min:0,onChange:R=>k("limit",R),value:u.limit}),jsx(Accordion,{mt:"md",variant:"separated",children:jsxs(Accordion.Item,{value:"customization",children:[jsx(Accordion.Control,{children:"Customization"}),jsx(Accordion.Panel,{children:jsxs(Stack,{spacing:"xs",children:[jsx(Qo,{field:"allLabel",value:u.allLabel,handleEditor:(R,z)=>k("allLabel",Qt(z)),referenceContent:n,referenceLocale:i,variables:l,editorConfig:_}),jsx(Qo,{field:"placeholder",value:u.placeholder,handleEditor:(R,z)=>k("placeholder",Qt(z)),referenceContent:n,referenceLocale:i,variables:l,editorConfig:L}),jsx(Select,{clearable:true,data:b,description:"(Optional) Select a property key to use as item's icon background color. Requires defining an icon key.",disabled:u.isPrimitiveType,label:jsx(Wt,{label:"Color property key"}),onChange:R=>k("colorKey",R,true),value:rl(b)&&u.colorKey}),jsx(Select,{clearable:true,data:b,description:"(Optional) Select a property key to use as item's icon src.",disabled:u.isPrimitiveType,label:jsx(Wt,{label:"Icon property key"}),onChange:R=>k("iconKey",R,true),value:rl(b)&&u.iconKey}),jsx(Select,{clearable:true,data:b,description:"(Optional) Select a property key to extend the search functionality. The selected key MUST only contain text elements.",disabled:u.isPrimitiveType,label:jsx(Wt,{label:"Search index key"}),onChange:R=>k("searchIndexKey",R,true),value:rl(b)&&u.searchIndexKey}),jsx(TextInput,{description:'(Optional) Provide a search index separator in case each row contains more than one record. Default: "|".',disabled:!u.searchIndexKey,error:u.searchIndexSeparator===""?"Separator cannot be empty!":"",label:jsx(Wt,{label:"Search index separator"}),onChange:R=>k("searchIndexSeparator",R.currentTarget.value),value:u.searchIndexSeparator})]})})]})})]}),jsx(Checkbox,{my:"md",label:jsx(Wt,{label:"Reset SectionVariables on change",py:0}),checked:u.resetSectionVars==="true",onChange:R=>k("resetSectionVars",R.currentTarget.checked?"true":"false")}),t]})}var Zq={[E.SELECTOR]:dI,[E.NAV]:Bb,[E.RELATED]:Db,[E.RESET_BUTTON]:Nb,[E.COMPARISON_BUTTON]:Fb,[E.TITLE]:zb,[E.STAT]:Vb,[E.TABLE]:jb,[E.MULTIHIERARCHY_SELECTOR]:Yb},LI=Zq;function e3(e){let{blockType:t,id:o,locale:r,setBlockContent:n,simpleState:i}=e,a=cn(),l=ot(o),s=LI[t],c=jsx(sI,{fields:nr[t],locale:r,defaultContent:i,variables:l,onChange:n},"text-editor");return s?jsx(s,{id:o,executeButton:a.executeButton,onChange:(u,d,m=true)=>n({simple:u,logic:d},r,true,m),simpleState:i,richTextEditor:c,variables:l,referenceContent:a.reference.content,referenceLocale:a.reference.locale}):c}var BI=e3;p();Ss();he();ae();xe();Pt();_f();function u3({id:e,variables:t,reserved:o,hasInternalKeys:r}){let[n,i]=useState(false);return jsxs(Fragment,{children:[r&&jsx(Switch,{label:"Show internal variables",size:"xs",checked:n,onChange:a=>i(a.currentTarget.checked)}),jsx(Or,{id:e,variables:t,reserved:o,showInternal:n})]})}function p3({id:e,setInlineId:t}){let o=H(s=>s.records.entities.block),r=ie(),n=zS(e),i=Object.keys(n.attributes),a=useContext(De),l=s=>{r(Z.updateEntity("block",{id:e,inputAction:{operation:"delete",input:{input_id:s,block_id:e}}})).then(()=>{r(Z.recalculateVariables(a));});};return jsx("div",{style:{display:"flex",flex:"1 1 auto",flexDirection:"column",width:"100%"},children:Object.keys(n).sort(s=>s==="attributes"?-1:1).map(s=>{let c=o[s],u=c&&[E.GENERATOR,E.SECTION_FLAG].includes(c.type),d=c?.type&&c?.id?`${c.type}${c.id}`:"",m=Object.keys(n[s]).some(rp(d));return jsxs(Stack,{className:"cr-variable-group",style:{position:"relative"},children:[jsx(Divider,{}),jsxs(Group,{position:"apart",noWrap:true,grow:true,children:[jsx(Title,{order:6,children:c?`${titleCase(c.type)} ${c.id} Variables`:"Dimension Variables"}),c&&jsxs(Group,{position:"right",noWrap:true,children:[u&&jsx(Tooltip,{label:"Edit this generator",children:jsx(ActionIcon,{size:"xs",onClick:()=>t(s),variant:"subtle",color:"gray",children:jsx(IconPencil,{size:15})})}),jsx(Tooltip,{label:"Remove as input",children:jsx(ActionIcon,{size:"xs",onClick:()=>l(s),variant:"light",color:"red",children:jsx(IconLinkOff,{size:15})})})]})]}),jsx(u3,{id:s,variables:n[s],reserved:i,hasInternalKeys:m})]},s)})})}var zI=p3;ic();kr();xe();function R3({blockType:e,fullscreen:t,toggle:o,codeEditor:r}){let n=cn(),i=[E.GENERATOR,E.VIZ].includes(e),[a,{open:l,close:s}]=useDisclosure(false);return jsxs(Fragment,{children:[jsxs(Popover,{width:400,position:"bottom",withArrow:true,shadow:"md",opened:a,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"subtle",color:"blue",size:"sm",onMouseEnter:l,onMouseLeave:s,pos:"absolute",top:3,left:3,style:{zIndex:1},children:jsx(IconHelp,{size:16})})}),jsx(Popover.Dropdown,{children:jsxs(Text,{size:"sm",children:["You can access ",jsx(Code,{children:"variables"}),", ",jsx(Code,{children:"formatters"}),",",jsx(Code,{children:"locale"}),", ",jsx(Code,{children:"libs"}),",",e===E.GENERATOR&&jsxs(Fragment,{children:[jsx(Code,{children:"resp"}),", "]}),e===E.VIZ&&jsxs(Fragment,{children:[jsx(Code,{children:"section"}),", "]}),"and ",jsx(Code,{children:"router"})," in the scope of this generator.",i&&jsxs(Fragment,{children:[" Return a property called",jsx(Code,{children:"_api"})," as string, to let the user download that data and override api value."]})]})})]}),r,jsx(Divider,{my:"sm",color:"gray.8"}),jsxs(Group,{px:"xs",h:"fit-content",position:"right",children:[jsx(Button,{variant:"light",color:"grey",size:"xs",onClick:o,leftIcon:t?jsx(IconMinimize,{size:rem(12)}):jsx(IconMaximize,{size:rem(12)}),compact:true,children:t?"Minimize":"Maximize"}),n.executeButton]})]})}function I3(){let e=cn(),t=rs(),o=ns(),r=t!==o;return jsx(Group,{position:"right",my:"xs",children:jsxs(Stack,{align:"flex-end",spacing:"xs",children:[jsx(Switch,{label:e.mode==="simple"?"Code":"No Code",size:"xs",labelPosition:"left",checked:e.mode==="code",onChange:n=>e.changeEditorMode(n.currentTarget.checked?"code":"simple"),onLabel:jsx(IconCode,{size:rem(12)}),offLabel:jsx(IconCode,{size:rem(12)})}),e.mode!=="code"&&r&&jsx(Switch,{checked:e.reference.active,onChange:n=>e.reference.setActive(n.currentTarget.checked),size:"xs",label:"See reference language",labelPosition:"left",onLabel:jsx(IconLanguage,{size:"0.7rem"}),offLabel:jsx(IconLanguage,{size:"0.7rem"})})]})})}function A3({header:e,blockContent:t,blockSettings:o,blockType:r,id:n,locale:i,onSave:a,setBlockContent:l,setBlockSettings:s,setInlineId:c,sid:u}){let[d,m]=useState("Content"),[g,f]=useState(false),[h,v]=useState(false),T=Wu(n),y=cn(),b=H(F=>F.status.isRunConsumersRunning).includes(u),w=useMemo(()=>{let F={resp:null,apiFinalUrls:null,apiDataSources:void 0};return T&&T.resp&&T.apiFinalUrls&&T.apiDataSources&&(F.resp=T.resp,F.apiFinalUrls=T.apiFinalUrls,F.apiDataSources=T.apiDataSources),F},[T]),k=ot(n),{ref:I,toggle:O,fullscreen:P}=useFullscreen(),_=t&&(t.api||t.api==="")?t.api.split("|||"):[],D=(F,G)=>l({logic:F},G),L=(F,G)=>{let J=[..._];J[G]=F,l({api:J.join("|||")},void 0,void 0,void 0,true);},R=()=>{l({api:[..._,""].join("|||")}),f(true);},z=F=>{l({api:_.length===1&&_[0]===""?null:_.filter((G,J)=>J!==F).join("|||")},void 0,void 0,void 0,true);},A=(F,G)=>{s({[F]:G});},V=()=>{f(!g);},j=()=>{v(!h);},B=jsx(ua,{monacoOptions:{onChange:F=>D(F,i),value:t?.logic||"",height:P?"85vh":"61vh",width:"100%"}},"code-editor"),U=t?.simple||{},$=jsx(BI,{blockType:r,id:n,locale:i,simpleState:U,setBlockContent:l,variables:k}),Y=jsx(Col,{span:4,sx:F=>({display:"flex",flexDirection:"column",borderLeft:`2px solid ${F.colors.gray[0]}`}),children:jsxs(Stack,{children:[jsx(Text,{inline:true,size:"xs",transform:"uppercase",weight:"bold",color:"gray",children:"Preview"}),jsx(Xp,{id:n,active:true,blockStateContent:t,blockStateSettings:o,locale:i,allowed:true,debug:true},"block-preview")]})});return jsxs(Grid,{h:"100%",children:[jsxs(Col,{span:3,sx:{alignSelf:"stretch",display:"flex",flexDirection:"column",height:"100%",position:"relative"},children:[E.SECTION_FLAG!==r&&jsx($w,{id:n}),jsx("div",{style:{width:"100%",maxHeight:"80vh",overflowY:"auto"},children:jsx(zI,{id:n,setInlineId:c})})]}),jsxs(Col,{span:9,sx:F=>({alignSelf:"stretch",display:"flex",flexDirection:"column",height:"100%",borderLeft:`2px solid ${F.colors.gray[0]}`}),children:[e,jsxs(Tabs,{value:d,onTabChange:m,keepMounted:false,styles:{root:{flexGrow:1,display:"flex",flexDirection:"column"},panel:{flexGrow:1}},children:[jsxs(Tabs.List,{position:"left",children:[jsx(Tabs.Tab,{value:"Content",icon:jsx(IconPencil,{}),children:"Edit"}),jsx(Tabs.Tab,{value:"Style",icon:jsx(IconPalette,{}),children:"Style"}),jsx(Tabs.Tab,{value:"Settings",icon:jsx(IconSettings,{}),children:"Settings"})]}),jsx(Tabs.Panel,{value:"Content",children:jsx(Box,{ref:I,pos:"relative",bg:"white",h:"100%",children:jsxs(Grid,{className:"cr-block-output",style:{flex:1,width:"100%",height:P?"100vh":"100%",margin:0},children:[jsxs(Col,{span:8,className:`cr-block-output-editor ${y.mode}`,children:[![E.VIZ,E.GENERATOR,E.SECTION_FLAG].includes(r)&&jsx(I3,{}),[E.GENERATOR,E.SECTION_FLAG].includes(r)&&jsxs(Stack,{mb:5,spacing:4,children:[b&&jsx(Overlay,{children:jsx(Text,{children:"Running..."})}),jsxs(Group,{spacing:"xs",children:[jsx(Button,{size:"sm",variant:"light",color:"blue",leftIcon:g?jsx(IconChevronDown,{size:16}):jsx(IconChevronRight,{size:16}),onClick:V,sx:{flex:1},children:`${_.length} API Request${_.length!==1?"s":""}`}),jsx(Button,{size:"sm",onClick:R,variant:"light",color:"blue",leftIcon:jsx(IconPlus,{size:15}),children:"Add API"})]}),jsxs(Collapse,{in:g,children:[_.map((F,G)=>jsx(xT,{defaultValue:F,pos:G+1,id:n,finalUrl:w.apiFinalUrls&&w.apiFinalUrls[G]?w.apiFinalUrls[G]:null,dataSource:w.apiDataSources&&w.apiDataSources[G]?w.apiDataSources[G]:null,onChangeAPI:J=>L(J,G),onDelete:()=>z(G)},`${n}-${G}-${_.length}`)),w.resp&&jsx(Button,{variant:"light",color:"blue",size:"xs",leftIcon:h?jsx(IconChevronDown,{size:14}):jsx(IconChevronRight,{size:14}),onClick:j,mt:5,children:"Response data preview (resp)"}),w.resp&&jsx(Collapse,{in:h,children:jsx("div",{style:{maxHeight:200,overflowY:"scroll"},children:jsx(sa,{value:w.resp,root:true,label:"resp"})})})]})]}),jsxs(Box,{bg:y.mode==="code"?"#272822":"none",p:"xs",pos:"relative",children:[y.mode==="code"&&jsx(R3,{blockType:r,fullscreen:P,toggle:O,codeEditor:B}),y.mode!=="code"&&$]})]},"content-col"),Y]})})}),jsx(Tabs.Panel,{value:"Style",pt:"xs",children:jsx(Box,{ref:I,pos:"relative",bg:"white",h:"100%",children:jsxs(Grid,{children:[jsxs(Col,{span:8,children:[jsx(Title,{order:4,children:"Style settings"}),jsx(up,{id:n,display:"inline",handleChange:A})]},"content-col"),Y]})})}),jsx(Tabs.Panel,{value:"Settings",pt:"xs",children:jsx(Vw,{id:n,setBlockSettings:s})})]})]})]})}var WI=A3;Wo();Rr();he();Pt();p();var jI=e=>(!e||!e.contentByLocale||Object.keys(e.contentByLocale).forEach(t=>{let o=e.contentByLocale[t]?.content;o&&Object.keys(o).length===0&&(o.simpleEnabled=true,o.simple={});}),e);var sy=["_icon","_iconType","_iconVariant","_iconSize","_iconRadius","_iconPadding"],KI={[E.SELECTOR]:["hideLabel","resetSectionVars","component","optionsType","type"],[E.TITLE]:[...sy],[E.NAV]:[...sy],[E.STAT]:[...sy],[E.TABLE]:["data","tableProps","variable"],[E.MULTIHIERARCHY_SELECTOR]:["colorKey","dataVar","defaultVar","hideLabel","resetSectionVars","iconKey","levelsVar","limit","searchIndexKey","searchIndexSeparator"]},V3=(e,t)=>({...e,[t.locale]:{...t,content:t.content}});function $3({block:e,localeDerived:t}){let o=cn(),r=qo(e.section_id).data,n=zt(r.report_id).data,i=r?.settings.name||`Section ${r?.id}`,a=`${e.type} ${e.id}`,l=n?.name||`Report ${n.id}`;return jsxs(Group,{w:"100%",children:[jsx(Alert,{color:"gray",sx:{flexGrow:1},py:"0.325rem",children:jsxs(Group,{position:"apart",children:[jsxs(Breadcrumbs,{separator:">",children:[jsx(Text,{size:"xs",children:l}),jsx(Text,{size:"xs",children:i}),jsx(Text,{size:"xs",children:a})]}),jsx(Badge,{size:"sm",radius:"sm",rightSection:jsx(Center,{children:t==="logic"?jsx(IconCode,{size:"0.6rem"}):jsx(IconLanguage,{size:"0.6rem"})}),children:t})]})}),jsxs(Group,{children:[o.cancelButton,o.closeAndSaveButton]})]})}function U3({id:e,modified:t,callbacks:o,inline:r}){let n=ie(),i=useContext(De),{setOpened:a,setModified:l,maybeCloseWithoutSaving:s,setInlineId:c}=o,u=tt(e).data,d=H(A=>A.status.currentLocale),m=H(A=>A.status.localeDefault),g=H(A=>A.status.locales),f=Cr(u,d).locale,[h,v]=useState(),[T,y]=useState(false),[C,b]=useState(true);if(useEffect(()=>{v(jI(td(u))),y(true);},[]),!u||!T||!h)return null;let w=Eo(h,d),k=h.settings,I=(A={},V=m,j=true,B=void 0,U=false)=>{let{locale:$}=Cr(u,V);if(j&&!t&&l(true),B!==void 0&&C!==B&&b(B),!A||Object.keys(A).length<1)return;let Y=h.contentByLocale[$]||{id:e,locale:$,content:{}},F={...h,contentByLocale:{...h.contentByLocale,[$]:{...Y,content:{...Y.content,...A}}}};if(v(F),U){let G=P(F);n(Z.updateEntity("block",G)).then(()=>{n(qt(i)),l(false);});}},O=(A,V)=>{if(f!=="logic"&&Object.keys(KI).includes(u.type)){let j={...A},B=A[V].content;return g.forEach(U=>{if(U===f)return;let Y={...A[U].content.simple};Object.keys(B.simple).map(G=>{KI[u.type].includes(G)&&(Y[G]=B.simple[G]);});let F={...Y};if(u.type===E.SELECTOR){let{selectorType:G=La.SINGLE,options:J={static:[]},optionsType:ee=xi.STATIC}=A[U].content.simple,{logicOptions:ne,defaultValue:X}=Ed(G,J,ee);X&&(F.defaultValue=X),F.options=ne;}if(u.type===E.MULTIHIERARCHY_SELECTOR){let G=A[U].content.simple,{logicLevels:J,logicOptions:ee,defaultValue:ne,defaultValueType:X}=Dd(G);ne&&X&&(F.defaultValue=ne,F.defaultValueType=X),F.data=ee,F.levels=J;}j[U].content={...j[U].content,simple:Y,logic:nn(F,false)};}),j}return A},P=(A=null)=>{let V=A||h,{settings:j}=V,B=Object.values(V.contentByLocale).reduce(V3,{}),U=["id","api","shared","type"].reduce((Y,F)=>({...Y,[F]:V[F]}),{}),$=O(B,d);return {...U,id:V.id,contentByLocale:$,settings:j}},_=async A=>{let V=P();n(Z.updateEntity("block",V)).then(()=>{n(qt(i)),l(false),A||(r?c(null):a(false));});},D=A=>{t||l(true),A.type||A.shared!==void 0?v({...h,...A}):v({...h,settings:{...h.settings,...A}});};return jsx(Fragment,{children:jsx(rI,{buttons:{cancelButton:jsx(Button,{leftIcon:jsx(IconCircleX,{size:"0.8rem"}),size:"xs",variant:"outline",onClick:s,color:"red",children:"Cancel"},"cancel"),closeAndSaveButton:jsx(Button,{leftIcon:jsx(IconDeviceFloppy,{size:"0.8rem"}),size:"xs",disabled:!C,onClick:()=>_(false),children:`Save & ${r?"Return":"Close"}`},"save"),executeButton:jsx(Button,{disabled:!C,onClick:()=>_(true),size:"xs",compact:true,children:"Save & Execute"})},blockType:u.type,blockId:u.id,children:jsx(WI,{header:jsx($3,{localeDerived:f,block:u}),blockContent:w,blockSettings:k,blockType:u.type,id:e,sid:u.section_id,locale:d,onSave:_,setBlockContent:I,setBlockSettings:D,setInlineId:c},"be")})})}var qI=U3;Pt();ae();xe();Rr();Fp();he();Ho();function rY({id:e,setHoverBlock:t,isInput:o,isConsumer:r,active:n,showOutline:i=true}){let[a,l]=useState(false),{newConfirmation:s}=Kt(),[c,u]=useState(false),[d,m]=useState(false),[g,f]=useState(null),h=useContext(De),v=useMantineTheme(),T=ot(e),y=Wu(e),C=useCallback(()=>{u(false),m(false),f(null);},[]),b=useDispatch(),w=H(F=>F.status.currentLocale),{data:k}=tt(e),I=H(F=>F.records.entities.block),{isFetching:O}=jl("block",e),{allowed:P,allowedMessage:_}=useMemo(()=>{let F=!y?.hiddenByCascade,G="";return k&&(G=y?.hiddenByCascade===e?`Hidden by ${k.settings.allowed}: ${k.settings.allowed?T[k.settings.allowed]:null}`:`Hidden by ${y?.hiddenByCascade}`),{allowed:F,allowedMessage:G}},[T,y,k,e]);if(!k)return null;let{blockcol:D,type:L,section_id:R,contentByLocale:z,settings:A,inputs:V}=k,j=async()=>{if(d)try{await s({title:"Are you sure?",message:"Close editor without saving?",confirmText:"Yes, abandon changes."}),C();}catch{}else C();},B={centered:true,withCloseButton:false,opened:c,onClose:j,overflow:"inside",padding:v.spacing.sm,size:"95%",styles:{body:{height:"100%"}}},U={onMouseEnter:()=>t(e),onMouseLeave:()=>t(false)},$={setOpened:u,setModified:m,setInlineId:f,maybeCloseWithoutSaving:j},Y=()=>{let F=Object.keys(I).filter(ee=>I[ee].section_id===k.section_id&&I[ee].blockcol===k.blockcol).map(ee=>I[ee].blockrow),G=$a(F),J={create:{blockrow:Rl(G),blockcol:D,locales:Object.keys(z).map(ee=>ee),section_id:R,type:L},update:{contentByLocale:z,settings:A,inputs:V.map(ee=>I[ee])}};b(Z.cloneEntity("block",J)).then(()=>{[E.GENERATOR,E.SECTION_FLAG].includes(k.type)&&b(qt(h,{sid:R}));});};return jsxs(Fragment,{children:[jsxs(Group,{id:`block-${e}`,onMouseOver:()=>l(true),onMouseOut:()=>l(false),className:"cr-section-block",pos:"relative",py:gi.block.padding,...U,sx:F=>({border:"1px solid transparent",resize:"horizontal","&:hover":{border:i?`1px solid ${F.colors.blue[2]}`:"1px solid transparent"},...i?{"&:hover::before":{position:"absolute",top:0,left:0,fontSize:8,color:F.colors.blue[5],transform:"translateY(-100%)",content:`"Block ${e}"`,width:"fit-content"}}:{}}),children:[jsx(Xp,{style:{color:"red"},id:e,debug:[E.VIZ,E.GENERATOR,E.SECTION_FLAG].includes(k.type),active:n,locale:w,allowed:P,isFetching:O},"bp"),(a||o||r)&&jsxs(Group,{spacing:0,className:"cr-block-controls export-hidden",style:{position:"absolute",right:px(v.spacing.xs)/2,top:px(v.spacing.xs)/2,backgroundColor:v.colors.gray[2],borderRadius:v.radius.sm,zIndex:5},children:[o||r?jsx(ActionIcon,{children:o?jsx(IconLogout,{size:20,color:v.colors.red[5]}):jsx(IconLogin,{size:20,color:v.colors.green[5]})},"globe"):null,k.shared&&jsx(Tooltip,{withArrow:true,label:"Sharing: Enabled",children:jsx(ActionIcon,{variant:"transparent",children:jsx(IconWorld,{size:20})},"globe")},"tt"),"access"in k.settings&&!["public","guest"].some(F=>!k.settings.access||k.settings.access.includes(F))&&jsx(Tooltip,{withArrow:true,label:"Private Block",children:jsx(ActionIcon,{variant:"transparent",children:jsx(IconLock,{size:20})},"lock")},"tt"),!P&&jsx(Tooltip,{withArrow:true,label:_,children:jsx(ActionIcon,{variant:"transparent",children:jsx(IconEyeOff,{size:20})})},"allowed"),![E.GENERATOR,E.SECTION_FLAG].includes(k.type)&&jsx(up,{id:e,display:"button"},"design"),jsx(ActionIcon,{onClick:()=>u(true),children:jsx(IconPencil,{size:20})},"edit"),![E.SECTION_FLAG].includes(k.type)&&jsx(ActionIcon,{onClick:Y,children:jsx(IconCopy,{size:20})},"copy"),jsx(aT,{type:bn.BLOCK,id:e},"cog")]},"bc")]},"block"),jsx(Modal,{fullScreen:true,...B,children:jsx(qI,{callbacks:$,id:g||e,inline:g,modified:d},g||e)},"d")]})}var il=rY;Ho();Fp();ae();Wo();p();p();xe();ae();Ho();st();xe();var QI=({id:e,disabled:t=false})=>{let{sectionVariables:o,resetSectionVariables:r}=pt(e);return !Object.keys(o).length?null:jsx(ActionIcon,{disabled:t,onClick:r,variant:"filled",size:"xs",children:jsx(IconRefresh,{size:20})})},uY=({sectionId:e,onActivate:t})=>{let{activeEntity:o}=Yt(),{handlers:r}=Ft("settings");return o.type==="section"&&o.id===e?jsx(Button,{size:"xs",radius:"xl",leftIcon:jsx(IconPencil,{size:14}),fw:400,onClick:r.open,compact:true,children:"Edit"}):jsx(ActionIcon,{variant:"transparent",onClick:()=>{t(),r.open();},children:jsx(IconPencil,{size:18})})};function pY({sectionId:e,onActivate:t,position:o}){let r=useDispatch(),n=qo(e),i=H(m=>m.records.entities.section),{data:a}=n,l=Jt(),s=Number.parseInt(l.params[0]),c=zt(s),u=H(m=>m.records.entities.block);if(!a||!c.data?.sections)return null;let{sections:d}=c.data;return jsxs(Group,{spacing:2,children:[jsx(uY,{sectionId:e,onActivate:t}),jsx(ActionIcon,{variant:"transparent",onClick:()=>{let m={...a,ordering:hn(i,d,o+1,true)},g=dY(m,u);r(Z.cloneEntity("section",g));},children:jsx(IconCopy,{size:18})}),jsx(ar,{type:"section",id:e})]})}function dY(e,t){let{heading:o,report_id:r,ordering:n,settings:i}=e,a=[];return {create:{ordering:n,report_id:r},update:{settings:i,heading:o,report_id:r,blocks:e?.blocks.map(s=>{let c=t[s],{blockcol:u,blockrow:d,contentByLocale:m,type:g,settings:f,section_id:h,shared:v,inputs:T,consumers:y}=c;return {blockcol:u,blockrow:d,contentByLocale:m,id:s,type:g,settings:f,section_id:h,shared:v,inputs:T.map(C=>{let b=t[C],{id:w,section_id:k,blockcol:I,blockrow:O,contentByLocale:P,settings:_,shared:D,type:L}=b;return {id:w,section_id:k,blockcol:I,blockrow:O,contentByLocale:P,settings:_,shared:D,type:L}}),consumers:y.reduce((C,b)=>{let w=t[b];if(w){let{id:k,section_id:I,blockcol:O,blockrow:P,contentByLocale:_,settings:D,shared:L,type:R}=w;return [...C,{id:k,section_id:I,blockcol:O,blockrow:P,contentByLocale:_,settings:D,shared:L,type:R}]}return C},a)}})}}}var ZI=pY;ae();he();Wo();Qg();jr();function o0({active:e,isDragging:t,id:o,dragHandleProps:r,hidden:n="",onActivate:i,sectionSettings:a,position:l}){let s=H(m=>m.records.entities.section[o]||null);if(!s)return null;let c=useMemo(()=>s&&s.settings?.name?.length?s.settings.name:`section-${s.id}`,[s.settings?.name,s.id]),u=useMemo(()=>Tt(c),[c]),d=n!=="";return jsxs(Group,{className:`cms-section-header${e||t?" active":""}`,position:"apart",bg:d?"red.1":"gray.3",sx:{overflow:"hidden",borderRadius:4},children:[jsx(Group,{className:"cms-section-header-editor",spacing:0,children:jsxs(Group,{spacing:0,children:[jsx(ActionIcon,{variant:"transparent",...r,w:16,sx:{cursor:"grab"},children:jsx(IconGripHorizontal,{size:16})},"b1"),jsxs(Text,{size:"xs",fw:400,color:"dark.9",children:[c,u!==c&&jsxs(Text,{span:true,size:"xs",c:"dimmed",children:[" #",u]}),d&&` ${n}`]})]})}),jsxs(Group,{children:[jsxs(Flex,{justify:"flex-end",mx:16,align:"center",gap:"xs",children:[jsx(QI,{id:s.id,disabled:!e}),a.optionsMenu&&jsx(Jg,{sectionId:s.id,disabled:!e})]}),jsx(ZI,{sectionId:o,onActivate:i,position:l})]})]})}Vg();he();ic();th();_s();xe();Tn();Zn();kr();jr();var PY=Object.values(E),c0=({columns:e,columnIndex:t,section:o})=>{let r=ie(),{settings:n}=Kl(o.report_id),[i,a]=useDisclosure(false),l=(c,u=false)=>{let d="!",m="!";typeof u=="string"?(m=u,d=$a(Object.keys(e[u]),true)):Object.keys(e).length>0&&(m=$a(Object.keys(e),true));let{locales:g}=Cr({type:c});r(Z.createEntity("block",{blockrow:d,blockcol:m,type:c,section_id:o.id,locales:g})).then(f=>{c===E.VIZ&&r(Z.updateEntity("block",{id:f.data.id,contentByLocale:{logic:{...f.data.contentByLocale.logic,content:{simpleEnabled:true,simple:{},logic:oS}}}}));});},s=PY.filter(c=>![E.GENERATOR,E.SECTION_FLAG,E.FALLBACK].includes(c)&&(n.comparison?true:c!==E.COMPARISON_BUTTON)).map(c=>{let u=Oc(c);return {label:jsx(UnstyledButton,{p:"xs",w:"100%",onClick:()=>{l(c,t),a.close();},sx:{":hover":{backgroundColor:"#EBEBEB"}},children:jsxs(Group,{spacing:"xs",children:[jsx(ThemeIcon,{color:"blue",variant:"filled",size:"sm",radius:"xl",children:jsx(u,{size:"0.8rem"})}),jsx(Text,{size:"xs",children:Lc(c)||c})]})}),value:c}});return jsx(Center,{w:"100%",py:"sm",children:jsxs(Popover,{position:"right",withinPortal:true,zIndex:100,opened:i,onClose:a.close,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{size:"lg",radius:"xl",variant:"light",bg:"#E5E5E5 !important",onClick:a.toggle,children:jsx(IconPlus,{size:24,color:"white",strokeWidth:1})})}),jsxs(Popover.Dropdown,{p:0,children:[jsx(Text,{bg:"#E5E5E5",size:"xs",p:"xs",children:"Add Block"}),jsx(ScrollArea,{h:230,children:jsx(List,{listStyleType:"none",styles:{itemWrapper:{width:"100%"}},children:s.map(({label:c,value:u})=>jsx(List.Item,{w:"100%",children:c},u))})})]})]})})},OY=({columns:e,section:t,show:o=false})=>o?jsx(Center,{w:"100%",children:jsxs("div",{children:[jsx(Text,{ta:"center",fw:700,size:"sm",color:"gray.8",children:"Add your first block!"}),jsx(c0,{columnIndex:false,columns:e,section:t})]})}):null,LY=({active:e=false})=>jsx(Droppable,{droppableId:"newColumn",children:(t,o)=>jsx(Center,{ref:t.innerRef,pos:"absolute",top:16,right:e?0:-140,bottom:16,w:140,sx:r=>({boxSizing:"border-box",zIndex:99,transition:"right 0.4s",overflow:"hidden",background:o.isDraggingOver?r.colors[r.primaryColor][0]:r.colors.gray[0]}),...t.droppableProps,children:jsxs(Stack,{p:"md",align:"center",children:[jsx(Text,{size:"xs",ta:"center",children:"Drop here to add new column"}),jsx(IconPlus,{})]})})}),MY=({onActivate:e,section:t,show:o=false})=>{let n=H(i=>i.status.isRunConsumersRunning).includes(t.id);return !o&&!n?null:jsxs(Overlay,{className:"cms-section-overlay",onClick:()=>e(t.id),opacity:.6,color:"#E9ECEF",style:{cursor:"pointer",zIndex:3},sx:i=>({transition:"background-color .45s",".bespoke-Section-edit":{opacity:0,transition:"opacity .45s"},"&:hover":{backgroundColor:i.fn.rgba("#E9ECEF",.9),".bespoke-Section-edit":{opacity:1}}}),center:true,children:[!n&&jsxs(Group,{className:"bespoke-Section-edit",align:"center",spacing:"xs",children:[jsx(Text,{fw:700,children:"Click to Edit"}),jsx(IconPencil,{size:"1rem"})]}),n&&jsxs(Stack,{align:"center",spacing:"xs",children:[jsx(Text,{fw:700,children:"Loading dependencies"}),jsx(Loader,{size:"md"})]})]})};function BY({for:e,isDragging:t,onActivate:o,dragHandleProps:r,position:n}){let i=ie(),{activeEntity:a}=Yt(),[l,s]=useState(false),[c,u]=useState(),d=useRef(null),m=H(A=>A.records.entities.block),g=H(A=>A.status.previews),f=jl("section",e.id),{memberImageBg:h,hidden:v,columnSettings:T={}}=e.settings,y=a.type==="section"&&a.id===e.id,{inputs:C,consumers:b}=useMemo(()=>{if(c){let A=m[c],{inputs:V,consumers:j}=A;return {inputs:V,consumers:j}}return {inputs:[],consumers:[]}},[c]),w=Object.values(m||{}).filter(A=>A.section_id===e.id&&![E.GENERATOR,E.SECTION_FLAG].includes(A.type)).reduce((A,V)=>(A[V.blockcol]?A[V.blockcol][V.blockrow]=V:A[V.blockcol]={[V.blockrow]:V},A),{}),k=useMantineTheme(),I=()=>s(true),O=A=>{if(s(false),!A.destination)return;let{source:V,destination:j}=A;if(V.droppableId===j.droppableId&&V.index===j.index)return;let B=j.droppableId==="newColumn",U=Number(A.draggableId),$=V.droppableId,Y=B?$a(Object.keys(w),true):j.droppableId,F={id:U,blockrow:"!",blockcol:"!"},G=$!==Y;F.blockcol=G?Y:$;let J=Object.values(w[F.blockcol]||{}),ee=J.reduce((W,K)=>({...W,[K.id]:K}),{}),ne=J.sort((W,K)=>mo(W,K,"blockrow")).map(W=>W.id),X=j.index>V.index;F.blockrow=hn(ee,ne,j.index,G,X,"blockrow"),i(Z.updateEntity("block",F));},P=useMemo(()=>{let A=Object.values(m||{}).filter(V=>V.section_id===e.id&&fo(V));return A.length>1&&console.error(`Error, there are more than one Section Flag Generator in section ${e.id}`),A.length>0?A[0]:false},[m,y,e.id]),_=H(A=>P&&A.variables.variables[P.id]&&!A.variables.variables[P.id][wo]||false),D=useMemo(()=>{let A="";return _&&P&&(A+=`(Not allowed by Section Flag #${P.id})`),v&&(A+="(Hidden by Section Settings)"),A},[v,_]),L=Object.keys(w).sort((A,V)=>-Il(A,V)),R=Object.keys(w).length,z=useMemo(()=>e?.settings?.name?Tt(e?.settings?.name):`section-${e.id}`,[e.id,e?.settings?.name]);return f.isFetching?jsxs(Box,{p:"lg",m:"lg",bg:gi.section.backgroundColor,sx:A=>({borderRadius:A.radius.md,border:`1px solid ${A.colors.gray[4]}`}),children:[jsx(Skeleton,{height:50,circle:true,mb:"xl"}),jsx(Skeleton,{height:8,radius:"xl"}),jsx(Skeleton,{height:8,mt:6,radius:"xl"}),jsx(Skeleton,{height:8,mt:6,width:"70%",radius:"xl"})]}):jsxs(Box,{px:"md",mt:"md",children:[jsx(o0,{active:y,id:e.id,isDragging:t,hidden:D,dragHandleProps:r,onActivate:()=>o(e.id),sectionSettings:e.settings,position:n}),jsxs(Box,{pos:"relative",sx:A=>({border:y?`1px solid ${A.colors.blue[4]}`:"none",borderRadius:2}),children:[jsx(Paper,{id:z,className:`cms-section${t||y?" active":""}`,bg:e.settings.style==="card"?gi.section.backgroundColor:"transparent",p:0,mih:100,maw:e.settings.width==="center"?k.breakpoints.xl:"none",w:"100%",mx:"auto",pos:"relative",shadow:e.settings.style==="card"?gi.section.boxShadow:"none",radius:gi.section.borderRadius,sx:{overflow:"hidden"},children:jsxs(Box,{pos:"relative",children:[h&&jsx(Fg,{previews:g}),jsx(eh,{ref:d,containerProps:{mih:!y||!R?120:"none",p:e.settings.margin||"md",style:{zIndex:2},gap:e.settings.columnGutter||"md",wrap:"wrap"},children:jsxs(DragDropContext,{onDragEnd:O,onDragStart:I,children:[L.map(A=>{let V=Object.values(w[A]).sort((j,B)=>mo(j,B,"blockrow"));return jsx(Droppable,{droppableId:A,children:(j,B)=>jsxs(Zg,{column:w[A],columnSettings:T[A],ref:j.innerRef,basis:`calc(${100/R}% - (10px * ${R}))`,sx:{background:B.isDraggingOver?k.colors[k.primaryColor][0]:"inherit",border:"1px solid transparent","& .bespoke-resize-col":{visibility:"hidden"},"&:hover .bespoke-resize-col":{visibility:"visible"},"&:hover":{border:`1px solid ${k.colors.teal[1]}`}},...j.droppableProps,children:[jsx(UE,{sectionId:e.id,columnIndex:A}),V.map((U,$)=>{if(!m[U.id])return null;let{settings:Y,type:F}=m[U.id],G=Y.width&&!Y.width.stretch&&Y.width.unit?nc[Y.width.unit](Y.width.value):Y.display==="inline"?"auto":"100%",J={alignSelf:F===E.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:G,minWidth:120};return jsx(Draggable,{draggableId:String(U.id),index:$,children:(ee,ne)=>jsx(Box,{ref:ee.innerRef,...ee.draggableProps,...ee.dragHandleProps,sx:[J,{boxShadow:ne.isDragging?k.shadows.lg:"none",...ee.draggableProps.style}],children:jsx(il,{id:Number(U.id),active:y,isInput:C.includes(Number(U.id)),isConsumer:b.includes(Number(U.id)),setHoverBlock:u},`block-${U.id}`)})},U.id)}),y&&jsx(c0,{section:e,columnIndex:A,columns:w}),j.placeholder]})},A)}),jsx(LY,{active:l&&y})]})}),jsx(OY,{columns:w,section:e,show:y&&!R})]})}),jsx(MY,{onActivate:o,section:e,show:!y})]})]})}var u0=Xt(BY,qo);Pt();Ho();ae();Rr();Wr();p();p();Ho();Ho();ae();p();he();ae();Lh();Tn();Zn();kr();jr();function jY(e,t){let o=document.getElementById(t),r=90;if(o){let i=o.getBoundingClientRect().top+e.current.scrollTop-r;e.current.scrollTo({top:i,behavior:"smooth"});}}function KY(e,t,o){let r=document.getElementById(`bespoke-${t}-${o}`),n=60;if(r){let a=r.getBoundingClientRect().top+e.current.scrollTop-n;e.current.scrollTo({top:a,behavior:"smooth"});}}function qY({section:e,onEnd:t}){let[o,r]=useState(e.settings?.name||`section-${e.id}`),n=a=>{[13,27].includes(a.keyCode)&&t(o);},i=useClickOutside(()=>t(o));return useEffect(()=>{setTimeout(()=>{i?.current&&i?.current?.focus();},200);},[i]),jsx(Input,{ref:i,bg:"gray.3",styles:{input:{display:"block",height:"100%",minHeight:"auto",lineHeight:"1rem",padding:0,boxSizing:"border-box"}},mih:"auto",type:"text",variant:"unstyled",value:o,onChange:a=>r(a.target.value),onKeyDown:n})}var YY=forwardRef(function({scrollContainer:t,section:o,isActive:r,...n},i){let a=H(I=>I?.records.entities.block),{settings:l,updateSettings:s}=Ar(o.id),c=useMantineTheme(),[u,d]=useState(false),[m,g]=useState(false),f=H(I=>{let O=o.blocks.map(P=>I.records.entities.block[P]).filter(P=>fo(P));return O.length>0?I.variables.variables[O[0].id]:false}),h=f?c.colors[f[wo]===false?"red":"green"][3]:"",v=useCallback(I=>{s("name",I),g(false);},[s]),T=useRef(false);useEffect(()=>{d(!!r);},[r]);let y=useMemo(()=>l?.name?Tt(l?.name):`section-${o.id}`,[o.id,l?.name]),C=useMemo(()=>l?.name||`section-${o.id}`,[o.id,l?.name]),b=I=>{I.detail===1&&(T.current=false,setTimeout(()=>{T.current||jY(t,y);},200)),I.detail===2&&(T.current=true,g(O=>!O));},w=r?c.colors.blue[5]:"black",k=o?.blocks.map(I=>a[I]).filter(I=>![E.GENERATOR,E.SECTION_FLAG].includes(I.type)).map(I=>{let O=Oh[I.type]||IconDice;return jsx(List.Item,{pl:"lg",sx:{border:"1px solid transparent","&:hover":{border:"1px solid blue",cursor:"default"}},icon:jsx(O,{size:"0.8rem"}),onClick:()=>KY(t,I.type,I.id),children:jsx(Text,{size:"sm",children:`${I.type} ${I.id}`})},I.id)});return jsxs(List.Item,{ref:i,w:"100%",...n,children:[jsxs(Group,{position:"apart",noWrap:true,px:"sm",bg:r?c.colors.gray[2]:"transparent",sx:I=>({cursor:"default",border:`1px solid ${r?I.colors.gray[2]:"transparent"}`,".section-icon":{color:w},":hover":{border:`1px solid ${I.colors.blue[5]}`}}),children:[jsxs(Group,{spacing:"xs",miw:0,onClick:b,noWrap:true,children:[jsx(IconBoxMultiple,{className:"section-icon",size:"0.8rem",style:{flexShrink:0}}),m?jsx(qY,{section:o,onEnd:v}):jsxs(Group,{spacing:4,align:"flex-end",children:[jsxs(Text,{size:"sm",fw:500,color:"gray.5",span:true,children:[o.id," -"]}),jsx(Text,{size:"sm",c:w,maw:220,sx:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},span:true,children:C})]})]}),jsxs(Group,{spacing:"xs",children:[o.settings.hidden&&jsx(IconEyeOff,{size:"0.8rem",color:c.colors.red[3]}),f&&jsx(IconFlag,{size:"0.8rem",color:h,fill:h}),k.length&&jsx(IconChevronDown,{size:"0.8rem",style:{transform:`rotate(${u?-180:0}deg)`,flexShrink:0},onClick:()=>d(I=>!I)})]})]}),u&&k.length?jsx(List,{listStyleType:"none",children:k}):null]})}),m0=YY;function hy({activeSection:e,scrollContainer:t}){let o=H(l=>l?.records.entities.section),r=ie(),n=Object.values(o).sort(mo),i=n.map(l=>l?.id),a=useCallback(l=>{if(!l.destination||l.source.index===l.destination.index)return;let s=Number.parseInt(l.draggableId,10),c=l.destination.index>l.source.index,u=hn(o,i,l.destination.index,false,c),d=i.slice(),m=d.splice(l.source.index,1);d.splice(l.destination.index,0,...m),r(Z.updateEntity("section",{id:s,ordering:u}));},[r,o,i]);return jsxs(ScrollArea.Autosize,{mah:"80vh",pb:"sm",sx:{borderBottom:"1px solid rgba(0, 0, 0, 0.1)"},children:[jsx(Text,{fw:700,size:"sm",px:"sm",children:jsxs(Center,{inline:true,children:[jsx(IconIndentIncrease,{size:"1rem"}),jsx(Text,{ml:"xs",span:true,children:"Navigation"})]})}),jsx(DragDropContext,{onDragEnd:a,children:jsx(List,{styles:{itemWrapper:{width:"100%"}},mt:"sm",listStyleType:"none",children:jsx(Droppable,{droppableId:"sections",children:l=>jsx("div",{ref:l.innerRef,...l.droppableProps,children:n.map((s,c)=>jsx(Draggable,{draggableId:`${s?.id}`,index:c,children:u=>jsx(m0,{scrollContainer:t,ref:u.innerRef,section:s,isActive:s.id===e,...u.draggableProps,...u.dragHandleProps})},s?.id))})})})})]})}ae();Ss();p();ae();Wo();he();kr();var c4=e=>t=>Object.values(t.records.entities.block||{}).filter(o=>o.section_id===e&&E.GENERATOR===o.type);function by({activeSection:e}){let t=H(c4(e)),o=ie(),r=()=>{let{locales:n}=Cr({type:E.GENERATOR});o(Z.createEntity("block",{blockrow:void 0,blockcol:void 0,type:E.GENERATOR,section_id:e,locales:n})).then(i=>{o(Z.updateEntity("block",{id:i.data.id,contentByLocale:{logic:{...i.data.contentByLocale.logic,content:{simpleEnabled:true,simple:{},logic:tS}}}}));});};return jsx(ScrollArea.Autosize,{mah:"80vh",w:"330px",sx:{borderBottom:"1px solid rgba(0, 0, 0, 0.1)"},children:jsxs(Stack,{pos:"relative",w:330,pr:"md",children:[jsxs(Group,{position:"apart",children:[jsx(Text,{fw:700,children:"Generators"}),jsx(ActionIcon,{c:"black",onClick:r,children:jsx(IconPlus,{})})]}),t.length?t.map(n=>jsx("div",{children:jsx(il,{id:Number(n.id),active:!!e,isInput:false,isConsumer:false,setHoverBlock:()=>{},showOutline:false})},`block-${n.id}`)):jsx(Text,{align:"center",size:"sm",children:"Click '+' to add a generator"})]})})}xe();p();ae();function T0({sectionId:e}){let[t,o]=useState(window.innerWidth-40),[r,n]=useState(window.innerHeight-150);useEffect(()=>{let f=()=>{o(window.innerWidth-40),n(window.innerHeight-120);};return window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f);}},[]);let i=Gl(),a=Qi(),[l,s]=useState(`${e}`),c=useMemo(()=>a.isSuccess?a.data.map(h=>({value:`${h.id}`,label:h.settings.name?`${h.settings.name} (${h.id})`:`Section ${h.id}`})):[],[a.isLoading]),u=useMemo(()=>{if(i.isSuccess&&l){let f={id:"root",label:"section",size:40,parentIds:[]},h={id:"wide",label:"report",size:40,parentIds:[]},v=i.data.filter(y=>`${y.section_id}`==`${l}`),T=v.map(y=>y.id);return [f,h,...v.map(y=>{let C=y.consumers.length>0?y.consumers.length*20:40,b=y.inputs.length>0?y.inputs.map(w=>T.includes(w)?`${w}`:`${h.id}`):[`${f.id}`];return {id:`${y.id}`,label:`${y.type}`,size:C>50?50:C,parentIds:[...Array.from(new Set(b))]}})]}else return []},[i.isLoading,l]),d=useRef(null);return useEffect(()=>{let f=Yd.dagStratify()(u),h=40,v=Yd.sugiyama().nodeSize(z=>{let A=z?z.data:null,V=A?A.size:h;return [(z?3.6:.25)*V,3*V]}),{width:T,height:y}=v(f),C=yr.select(d.current);C.selectAll("*").remove(),C.attr("viewBox",[0,0,T,y].join(" "));let b=C.append("defs"),w=f.size(),k=yr.interpolateRainbow,I=new Map;u.forEach((z,A)=>{I.set(z.id,k(A/w));});let O=yr.line().curve(yr.curveCatmullRom).x(z=>z.x).y(z=>z.y);C.append("g").selectAll("g").data(f.links()).enter().append("g").append("path").attr("class","curve").attr("d",({points:z})=>O(z)).attr("fill","none").attr("stroke-width",3).attr("stroke",({source:z,target:A})=>{let V=encodeURIComponent(`${z.data.id}--${A.data.id}`),j=b.append("linearGradient").attr("id",V).attr("gradientUnits","userSpaceOnUse").attr("x1",z.x).attr("x2",A.x).attr("y1",z.y).attr("y2",A.y);return j.append("stop").attr("offset","0%").attr("stop-color",I.get(z.data.id)),j.append("stop").attr("offset","100%").attr("stop-color",I.get(A.data.id)),`url(#${V})`}),C.append("g").selectAll("g").data(f.descendants()).enter().append("g").attr("transform",({x:z,y:A})=>`translate(${z}, ${A})`).append("circle").attr("r",z=>z.data.size).attr("fill",z=>I.get(z.data.id));let D=C.append("g").selectAll("g").data(f.links()).enter().append("g"),L=yr.symbol().type(yr.symbolTriangle).size(h*1.5);D.append("path").attr("class","arrow").attr("d",L).attr("transform",z=>{let{points:A,target:V}=z,[j,B]=A.reverse(),U=B.x-j.x,$=B.y-j.y,Y=V.data.size*1/Math.sqrt(U*U+$*$),F=Math.atan2(-$,-U)*180/Math.PI+90;return `translate(${j.x+U*Y}, ${j.y+$*Y}) rotate(${F})`}).attr("fill",({target:z})=>I.get(z.data.id)).attr("stroke","white");let R=C.append("g").selectAll("g").data(f.descendants()).enter().append("g").attr("transform",({x:z,y:A})=>`translate(${z}, ${A})`);R.append("text").text(z=>z.data.id).attr("font-weight","bold").attr("font-family","sans-serif").attr("text-anchor","middle").attr("font-size","10px").style("transform","translate(0px,10px)").attr("alignment-baseline","middle").attr("fill","black"),R.append("text").text(z=>z.data.label).attr("font-weight","bold").attr("font-family","sans-serif").attr("font-size","15px").style("transform","translate(0px,-5px)").attr("text-anchor","middle").attr("alignment-baseline","middle").attr("fill","black");},[u]),jsxs(Stack,{spacing:0,children:[jsxs(Group,{align:"flex-end",w:"100%",position:"apart",children:[jsx(Select,{label:"Choose a section",placeholder:"Pick one",value:l,onChange:s,data:c,width:"80%"}),jsxs(Group,{grow:true,maw:100,children:[jsx(ActionIcon,{onClick:()=>{let f=c.findIndex(h=>h.value===l);f>0&&s(c[f-1].value);},variant:"outline",children:jsx(IconChevronLeft,{size:"1.125rem"})}),jsx(ActionIcon,{onClick:()=>{let f=c.findIndex(h=>h.value===l);f<c.length-1&&s(c[f+1].value);},variant:"outline",children:jsx(IconChevronRight,{size:"1.125rem"})})]})]}),jsx("svg",{ref:d,width:t,height:r})]})}function C0({name:e,id:t,variables:o}){return jsxs(Flex,{gap:"xs",children:[jsx(ThemeIcon,{bg:"blue.5",color:"white",size:"sm",radius:"xl",sx:{flexGrow:0},children:jsx(IconCodeDots,{size:"0.8rem"})}),jsxs(Stack,{sx:{flexGrow:1},children:[jsx(Text,{size:"sm",children:e}),jsx(Or,{id:t,variables:o})]})]})}function I4({sectionId:e}){let[t,o]=useDisclosure(false);return jsxs(Fragment,{children:[jsx(Button,{onClick:o.open,variant:"outline",radius:2,leftIcon:jsx(IconBinaryTree,{}),children:"Section Graph"}),jsx(Modal,{opened:t,onClose:o.close,title:"Block Graph",fullScreen:true,children:jsx(T0,{sectionId:e})})]})}function A4({activeSection:e}){let t=H(i=>i.records.entities.block),o=H(i=>i.variables.attributes),r=H(i=>i.variables.variables),n=Object.values(t).filter(i=>(i.section_id===e||i.shared)&&Object.keys(r[i.id]||{}).length);return jsxs(Box,{px:"sm",w:"100%",children:[jsx(Text,{fw:700,size:"sm",children:jsxs(Center,{inline:true,children:[jsx(IconCodeDots,{size:"1rem"}),jsx(Text,{ml:"xs",span:true,children:"Variables"})]})}),jsx(ScrollArea.Autosize,{mah:"40vh",mx:"sm",w:"240px",children:jsxs(Stack,{mt:"sm",children:[jsx(C0,{name:"Report Variables",id:"attributes",variables:o}),n.map(i=>jsx(C0,{id:i.id,name:`${i.type} ${i.id}`,variables:r[i.id]},i.id))]})})]})}function P4(){return jsx(Title,{children:"Formatters"})}var O4={section:[{label:"Navigation",value:"navigation"},{label:"Generators",value:"generators"}]};function Cy({scrollContainer:e}){let{opened:t,handlers:o}=Ft("tools"),{toggle:r}=o,[n,i]=useState("navigation"),{activeEntity:a}=Yt(),l=u=>i(u),s=a.type==="section"?a.id:null,c=t&&jsxs(Fragment,{children:[s&&jsx(SegmentedControl,{sx:{flexShrink:0},data:O4.section,value:n,onChange:l}),jsxs(Stack,{sx:{flexGrow:1},spacing:"sm",mt:32,children:[(n==="navigation"||!s)&&jsx(hy,{activeSection:s,scrollContainer:e}),n==="generators"&&s&&jsx(by,{activeSection:s}),n==="variables"&&jsx(A4,{activeSection:s}),n==="formatters"&&jsx(P4,{})]})]});return jsxs(Flex,{direction:"column",justify:t?"space-between":"flex-end",bg:"white",pb:30,pt:"sm",px:"xs",mah:"100vh",w:t?"350px":"50px",sx:u=>({overflow:"hidden",borderRight:`1px solid ${u.colors.gray[2]}`,flexShrink:0,flexGrow:0}),children:[c,jsxs(Flex,{justify:t?"space-between":"center",px:"sm",children:[a.type==="section"&&t&&jsx(I4,{sectionId:s}),jsx(UnstyledButton,{onClick:r,sx:{transform:`rotate(${t?0:180}deg)`},children:jsx(IconChevronLeft,{size:24})})]})]})}p();p();ae();Vp();Tn();xe();Zn();he();Wo();kr();Rr();Pt();st();function N4({activeSection:e}){let{settings:t,updateSettings:o}=Ar(e),r=t.name||`section-${e}`,[n,i]=useState(r),[a,l]=useState(false);return jsx(TextInput,{label:"Section Name",description:"Section name. Only for organization purposes. Won't be displayed on the final report.",value:a?n:r,onChange:s=>i(s.target.value),onFocusCapture:()=>{i(r),l(true);},onBlurCapture:()=>{o("name",n),l(false);},withAsterisk:true,radius:2})}function z4({activeSection:e}){let{settings:t,updateSettings:o}=Ar(e),r=t.tags,n=H(s=>e&&s.records.entities.section[e]),i=H(s=>e&&n?Object.values(s.records.entities.section).filter(c=>c&&c.report_id===n.report_id):[]),a=useMemo(()=>{let s=new Set;return i.forEach(c=>{let u=c?.settings?.tags;u&&(Array.isArray(u)?u.forEach(d=>d&&s.add(d)):typeof u=="string"&&u.split(/\s+/).forEach(d=>d&&s.add(d)));}),Array.from(s).sort()},[i]),l=useMemo(()=>r?Array.isArray(r)?r:typeof r=="string"?r.split(/\s+/).filter(Boolean):[]:[],[r]);return jsx(MultiSelect,{label:"Section Tags",description:"Section tags. They will be appended to the dom element as data attributes.",placeholder:"Select or create tags",data:a,value:l,onChange:s=>o("tags",s),radius:2,searchable:true,creatable:true,getCreateLabel:s=>`+ Create ${s}`})}function ky(){let{activeEntity:e}=Yt(),t=e.id,o=H(b=>t&&b.records.entities.section[t]),r=H(b=>t&&o&&b.records.entities.report[o.report_id]),n=H(b=>{if(t&&o){let w=o.blocks.map(k=>b.records.entities.block[k]).filter(k=>fo(k));return w.length>1&&console.error(`Error, there is more than one section flag generator in section ${e.id}`),w.length>0?w[0]:false}return false}),i=ie(),a=useContext(De),l=ii(),s=b=>{b==="always"&&n?c(n.id):b==="section-flag"&&u();},c=b=>{i(Z.deleteEntity("block",b)).then(()=>{i(qt(a)),console.info(`Flag generator with ID ${b} deleted.`);});},u=()=>{let{locales:b}=Cr({type:E.SECTION_FLAG});i(Z.createEntity("block",{blockrow:void 0,blockcol:void 0,type:E.SECTION_FLAG,section_id:t,locales:b})).then(w=>{i(Z.updateEntity("block",{id:w.data.id,contentByLocale:{logic:{...w.data.contentByLocale.logic,content:{simpleEnabled:true,simple:{},logic:`return {
79
- ${wo}: true
80
- }`}}}})).then(()=>{i(qt(a));});});},d=r?.settings||{},{settings:m,updateSettings:g}=Ar(t),f=useMemo(()=>[{key:"optionData",label:"Download data (csv, xls, json)"},{key:"optionImage",label:"Save Image"},{key:"optionShare",label:"Share link"}],[]),h=useMemo(()=>f.map(b=>jsxs(List.Item,{children:[b.label,"."]},`item-${b.key}`)),[f]);if(e.type!=="section"||!e.id)return null;let v=useMemo(()=>[{value:"always",label:"Always"},{value:"section-flag",label:"Use Section Flag"}],[]),T=useMemo(()=>[{value:"always",label:"Always"},{value:"never",label:"Never"},{value:"optional",label:"Optional"}],[]),y=n?"section-flag":"always";if(e.type!=="section"||!e.id)return null;let C=m.showInPdf||"optional";return jsxs("div",{children:[jsx(N4,{activeSection:t}),jsx(z4,{activeSection:t}),jsx(Divider,{my:"sm"}),jsxs(Stack,{mt:"sm",children:[jsxs(Stack,{spacing:"0.4rem",children:[jsx(_o,{target:jsx(Switch,{radius:"sm",label:"Show export menu.",checked:m.optionsMenu,onChange:b=>g("optionsMenu",b.currentTarget.checked)}),dropdown:jsxs(Box,{children:[jsx(Text,{size:"sm",fw:700,children:"Export Menu"}),jsx(Text,{size:"sm",children:"The Export Menu will allow users to:"}),jsx(List,{withPadding:true,size:"sm",children:h})]})}),m.optionsMenu&&jsx(Stack,{spacing:"0.5rem",pl:"md",children:f.map(b=>jsx(Switch,{radius:"sm",label:b.label,checked:typeof m[b.key]>"u"?m.optionsMenu:m[b.key],onChange:w=>g(b.key,w.currentTarget.checked)},b.key))})]}),jsx(_o,{target:jsx(Switch,{radius:"sm",label:"Show anchor link.",checked:m.showAnchor,onChange:b=>g("showAnchor",b.currentTarget.checked)}),dropdown:jsx(Text,{size:"sm",maw:200,children:"Show `#` link on top left corner of the section"})}),jsx(_o,{target:jsx(Switch,{radius:"sm",label:"Show section.",checked:!m.hidden,onChange:b=>g("hidden",!b.currentTarget.checked)}),dropdown:jsx(Text,{size:"sm",maw:200,children:"Softly hide or show the section on the rendered report (Still running the queries)"})}),jsx(_o,{target:jsx(Select,{label:"Show in PDF",value:C,data:T,disabled:!l,onChange:b=>g("showInPdf",b)}),dropdown:jsx(Text,{size:"sm",maw:200,children:l?"Hide or show the section in the pdf report.":"PDF API URL is not set."})}),jsx(_o,{target:jsx(Select,{label:"Allow section",placeholder:"Select an option",description:n?`Controlled by Section Flag #${n.id}`:"Section always visible",value:y,data:v,onChange:s}),dropdown:jsx(Text,{size:"sm",maw:200,children:"You can control section visibility (allow) creating a Section Flag Block"})}),n&&jsx(Stack,{spacing:"xs",children:jsx(il,{id:Number(n.id),active:!!t,isInput:false,isConsumer:false,setHoverBlock:()=>{},showOutline:false})}),d.comparison&&jsx(Accordion,{children:jsxs(Accordion.Item,{value:"compare",children:[jsx(Accordion.Control,{children:"Compare Settings"}),jsx(Accordion.Panel,{children:jsxs(Stack,{children:[jsx(Switch,{radius:"sm",label:"Hide on comparison.",checked:m.comparisonHide,onChange:b=>g("comparisonHide",b.currentTarget.checked)}),jsx(Switch,{radius:"sm",label:"Show once in comparison",checked:m.comparisonMerge,onChange:b=>g("comparisonMerge",b.currentTarget.checked)})]})})]})})]})]},`settings-${t}`)}p();p();function Ey(e){let{label:t,labelProps:o,...r}=e;return jsxs(Stack,{spacing:"md",children:[jsx(Text,{...o,children:t}),jsx(SegmentedControl,{...r})]})}Vp();Cc();Tn();xe();function Ry(){let{activeEntity:e}=Yt(),t=e.id,{settings:o,updateSettings:r}=Ar(t);return e.type!=="section"||!e.id?null:jsxs(Fragment,{children:[jsxs(Stack,{spacing:"md",children:[jsx(Text,{children:"Image"}),jsx(_o,{target:jsx(Switch,{radius:"sm",label:"Show image background",checked:o.memberImageBg,onChange:n=>r("memberImageBg",n.currentTarget.checked)}),dropdown:jsxs(Box,{maw:300,children:[jsx(Text,{size:"sm",fw:700,children:"Image Background"}),jsxs(Text,{size:"sm",children:["Set up a background image for every profile on the",jsx(Anchor,{href:"/cms/metadata",color:"blue",fw:700,children:" Metadata "}),"tab."]})]})})]}),Object.keys(ba).map(n=>jsx(Ey,{label:ba[n].label,data:ba[n].options,value:String(o[n]||ba[n].defaultValue),onChange:i=>r(n,i)},n))]})}xe();ih();var O0={report:[{label:"Settings",value:"settings",component:jsx(nh,{})}],section:[{label:"Style",value:"style",component:jsx(Ry,{})},{label:"Settings",value:"settings",component:jsx(ky,{})}],block:[{label:"Content",value:"content",component:null},{label:"Style",value:"style",component:null},{label:"Settings",value:"settings",component:null}]};function Iy(){let{opened:e,handlers:t}=Ft("settings"),[o,r]=useState("settings"),n=s=>r(s),{activeEntity:i}=Yt();if(!i.type)return null;let a=O0[i.type].find(s=>s.value===o)?.component||null,l=e&&jsx(Fragment,{children:jsxs("div",{children:[i.type==="report"?jsx(Text,{children:"Report Settings"}):jsx(SegmentedControl,{value:o,data:O0[i.type],onChange:n,fullWidth:true}),jsx(Stack,{sx:{flexGrow:1},spacing:"sm",mt:32,children:a})]})});return jsxs(Flex,{direction:"column",justify:e?"space-between":"flex-end",bg:"white",pt:"sm",pb:30,p:"sm",w:e?"350px !important":"50px",sx:s=>({overflow:"hidden",borderLeft:`1px solid ${s.colors.gray[2]}`,flexShrink:0,flexGrow:0}),children:[l,jsx(Flex,{justify:e?"flex-start":"center",children:jsx(UnstyledButton,{onClick:t.toggle,sx:{transform:`rotate(${e?0:180}deg)`},children:jsx(IconChevronRight,{size:24})})})]})}xe();p();p();ae();he();Zn();kr();Rr();Pt();_s();function i6({for:e,setSectionTotals:t}){let o=ie(),r=H(y=>y.variables.status),n=H(y=>y.variables.variables),i=Gl(e.blocks),a=useMemo(()=>{if(i.isSuccess){let y=new Map(e.blocks.map((C,b)=>[C,b]));return i.data.slice().filter(C=>[E.GENERATOR,E.SECTION_FLAG].includes(C.type)).sort((C,b)=>{if(C.type===E.SECTION_FLAG&&b.type!==E.SECTION_FLAG)return -1;if(b.type===E.SECTION_FLAG&&C.type!==E.SECTION_FLAG)return 1;let w=y.get(C.id)??Number.MAX_VALUE,k=y.get(b.id)??Number.MAX_VALUE;return w-k})}else return []},[i.isLoading,i.isSuccess,e.blocks]);if(a.length===0)return null;let{hidden:l}=e.settings,s=useContext(De),u=H(y=>y.status.isRunConsumersRunning).includes(e.id),d=H(y=>y.status.previews);useEffect(()=>{o(qt(s,{sid:e.id}));},[e.id,d]);let m=useMemo(()=>{let y=a.filter(C=>C.section_id===e.id&&fo(C));return y.length>1&&console.error(`Error, there are more than one Section Flag Generator in section ${e.id}`),y.length>0?y[0]:false},[i,e.id]),g=H(y=>m&&y.variables.variables[m.id]&&!y.variables.variables[m.id][wo]||false),f=useMemo(()=>{let y="";return g&&m&&(y+=`(Not allowed by Section Flag #${m.id})`),l&&(y+="(Hidden by Section Settings)"),y},[l,g]),h=useMemo(()=>[{accessorKey:"status",header:"",Cell:({cell:y})=>g&&y.row.original.type!==E.SECTION_FLAG?jsx(IconCircleX,{size:"1rem"}):jsx(Fragment,{children:y.getValue()?jsx(Loader,{size:"1rem",color:"blue"}):jsx(IconCircleCheckFilled,{color:"green",size:"1rem"})}),enableSorting:false,size:50,minSize:50,maxSize:50},{accessorKey:"order",header:"Order",size:50,minSize:50,maxSize:50},{accessorKey:"id",header:"ID",size:50,minSize:50,maxSize:50},{accessorKey:"type",header:"Type",size:100,minSize:100,maxSize:100,Cell:({cell:y})=>{let C=Oc(y.getValue());return jsxs(Group,{spacing:0,noWrap:true,children:[jsx(C,{size:16}),jsx(Text,{size:"xs",ml:"xs",children:Lc(y.getValue())})]})}},{accessorKey:"duration",header:"Duration",size:100,minSize:100,maxSize:100,Cell:({cell:y})=>`${y.getValue().toFixed(3)}s`},{accessorKey:"sizeApi",header:"API Size",size:100,minSize:100,maxSize:100,Cell:({cell:y})=>y.getValue()?`\u2248${y.getValue().toFixed(2)} Kb`:""},{accessorKey:"sizeBlock",header:"Block Size",size:100,minSize:100,maxSize:100,Cell:({cell:y})=>`\u2248${y.getValue().toFixed(2)} Kb`},{accessorKey:"data",header:"",enableSorting:false,Cell:({cell:y})=>{let C=y.getValue();return jsx(qp,{block:C.block,status:C.blockStatus,variables:C.blockVariables})}}],[]),v=useMemo(()=>a.map((y,C)=>{let b=!!y.contentByLocale?.logic?.content?.api,w=r[y.id]||{},k=n[y.id]||{},I=w.duration?w.duration/1e3:0,P=(w.api&&w.api!==""?w.api.split("|||"):[]).map((_,D)=>({original:_,swapped:w.apiFinalUrls[D]}));return {order:C+1,id:y.id,type:y.type,duration:I,status:b&&!Object.keys(k).length&&!w.error,sizeBlock:JSON.stringify(k).length/1024,sizeApi:w.responseSize,requests:P,data:{block:y,blockStatus:w,blockVariables:k}}}),[a,r,n]),T=useMemo(()=>{let y={requests:0,blocks:0,totalDuration:0,maxDuration:0,avgDuration:0,avgSizeBlock:0,totalSizeBlock:0,avgSizeApi:0,totalSizeApi:0},C=v.filter(b=>g?b.type===E.SECTION_FLAG:true);return y.requests=C.reduce((b,w)=>b+w.requests.length,0),y.blocks=C.length,C.forEach(b=>{b.duration>y.maxDuration&&(y.maxDuration=b.duration),y.totalDuration+=b.duration,y.totalSizeBlock+=b.sizeBlock||0,y.totalSizeApi+=b.sizeApi||0;}),v.length>0&&(y.avgDuration=y.requests>0?y.totalDuration/y.requests:0,y.avgSizeBlock=y.blocks>0?y.totalSizeBlock/y.blocks:0,y.avgSizeApi=y.requests>0?y.totalSizeApi/y.requests:0),y},[v]);return useEffect(()=>{u||t(e.id,T);},[u]),jsxs(Stack,{px:"md",mt:"md",spacing:0,children:[jsxs(Group,{children:[u&&jsx(Loader,{size:"xs",color:"blue"}),!u&&jsx(IconCircleCheckFilled,{color:"green",size:"1rem"}),jsxs(Title,{order:4,children:["Section #",e.id," ",e.settings?.name," ",f]})]}),jsxs(Stack,{spacing:0,mb:"xs",ml:"2rem",children:[jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Requests: ",T.requests]}),jsxs(Text,{size:"sm",children:["Total Size: ",T.totalSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",T.avgSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Total Duration: ",T.totalDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Max Duration: ",T.maxDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Avg Duration: ",T.avgDuration.toFixed(3),"s"]})]}),jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Blocks: ",T.blocks]}),jsxs(Text,{size:"sm",children:["Total Size: ",T.totalSizeBlock.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",T.avgSizeBlock.toFixed(2)," Kb"]})]})]}),jsx(MantineReactTable,{columns:h,data:v,enablePagination:true,mantinePaginationProps:{showRowsPerPage:false,rowsPerPageOptions:["5","10"],disabled:u},enableBottomToolbar:true,enableColumnActions:false,enableColumnResizing:false,enableEditing:false,enableFullScreenToggle:false,enableGlobalFilter:false,enableRowActions:false,enableRowSelection:false,enableStickyHeader:false,enableStickyFooter:false,enableTopToolbar:false,initialState:{sorting:[{id:"order",desc:false}]},renderDetailPanel:({row:y})=>{let C=y.original.requests;return C.length===0?jsx(Text,{size:"xs",children:"No requests."}):jsx(Stack,{spacing:0,children:C.map((b,w)=>jsxs(Group,{spacing:0,noWrap:true,children:[jsxs(Text,{children:[w+1,"."]}),jsx(Text,{size:"xs",children:jsx("a",{href:b.swapped,target:"_blank",rel:"noopener noreferrer",children:b.original})})]},w))})},positionExpandColumn:"last"})]})}var _0=Xt(i6,qo);ae();function z0(e){let{report:t}=e,o=H(s=>s.status.isRunConsumersRunning.length>0),r=H(s=>s.status.previews),[n,i]=useState({}),a=(s,c)=>{i({...n,[s]:c});},l=useMemo(()=>{let s={requests:0,blocks:0,totalDuration:0,maxDuration:0,avgDuration:0,avgSizeBlock:0,totalSizeBlock:0,avgSizeApi:0,totalSizeApi:0};return Object.values(n).forEach(c=>{s.requests+=c.requests||0,s.blocks+=c.blocks||0,s.totalDuration+=c.totalDuration||0,s.maxDuration=Math.max(s.maxDuration,c.maxDuration||0),s.totalSizeBlock+=c.totalSizeBlock||0,s.totalSizeApi+=c.totalSizeApi||0;}),s.avgDuration=s.requests>0?s.totalDuration/s.requests:0,s.avgSizeBlock=s.blocks>0?s.totalSizeBlock/s.blocks:0,s.avgSizeApi=s.requests>0?s.totalSizeApi/s.requests:0,s},[n]);return jsxs(Box,{children:[jsxs(Stack,{pos:"fixed",bg:o?"#fab005":"#e7f5ff",px:"md",py:"xs",w:"100%",style:{zIndex:20},spacing:0,children:[jsxs(Group,{children:[o&&jsx(Loader,{size:"xs",color:"blue"}),!o&&jsx(IconCircleCheckFilled,{color:"green",size:"1rem"}),jsxs(Title,{order:3,children:[o?"Generating Debug Report. Please wait...":"Debug Report",":"]}),jsx(Title,{order:3,variant:"dimmed",children:r.map(s=>`${s.variant_slug}/${s.slug}`).join("/")})]}),jsxs(Stack,{spacing:0,ml:"2rem",children:[jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Requests: ",l.requests]}),jsxs(Text,{size:"sm",children:["Total Size: ",l.totalSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",l.avgSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Total Duration: ",l.totalDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Max Duration: ",l.maxDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Avg Duration: ",l.avgDuration.toFixed(3),"s"]})]}),jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Blocks: ",l.blocks]}),jsxs(Text,{size:"sm",children:["Total Size: ",l.totalSizeBlock.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",l.avgSizeBlock.toFixed(2)," Kb"]})]})]})]}),jsx(Stack,{mt:"5.5rem",children:t.sections.map(s=>jsx(_0,{id:s,setSectionTotals:a},s))})]})}function G0(e){let{id:t}=e,o=zt(t);return useMemo(()=>o.isError?jsx(Center,{style:{height:300},children:jsx(Alert,{icon:jsx(IconCircleX,{size:20}),title:`Error ${o.error.code}`,color:"red",children:o.error.message})}):o.isUninitialized||!o.data?jsx(Loader,{}):jsx(w6,{report:o.data,locale:e.locale,isLoading:false}),[o.status,o.data?.sections])}function w6(e){let{report:t,isLoading:o}=e,r=useMantineTheme(),n=ie(),i=useContext(De),{newConfirmation:a}=Kt(),l=H(k=>k.status.previews),s=H(XS),{activeEntity:c,selectEntity:u}=Yt(),d=Ft("tools"),m=Ft("settings"),g=Ft("debugView"),f=useMemo(()=>t.sections,[t.sections]),h=useRef(null),v=useCallback(k=>{let I=()=>{u({type:"section",id:k}),n(qt(i,{sid:k}));};l.length<t.dimensions.length?a({title:"You haven't chosen a member!",message:"You may want to choose a member before editing this section.",cancelText:"OK, I'll choose one.",confirmText:"Don't tell me what to do!"}).then(I,()=>{}):I();},[t.dimensions,l]),T=useCallback(k=>{if(!k.destination||k.source.index===k.destination.index)return;let I=Number.parseInt(k.draggableId,10),O=k.destination.index>k.source.index,P=hn(s,f,k.destination.index,false,O),_=f.slice(),D=_.splice(k.source.index,1);_.splice(k.destination.index,0,...D),n(Z.updateEntity("section",{id:I,ordering:P})).then(()=>{n(Z.readEntity("report",{id:t.id,include:true}));});},[s,f]),y=useCallback(k=>jsxs("div",{ref:k.innerRef,className:"cms-droppable-container",...k.droppableProps,children:[f.map((I,O)=>jsx(Draggable,{draggableId:`${I}`,index:O,children:(P,_)=>jsxs("div",{className:`cms-section-container${_.isDragging?" isDragging":""}`,ref:P.innerRef,...P.draggableProps,style:{...P.draggableProps.style,boxShadow:_.isDragging?r.shadows.sm:void 0},children:[jsx(u0,{id:I,isDragging:_.isDragging,onActivate:v,dragHandleProps:P.dragHandleProps,position:O}),jsx(Center,{className:"cms-section-controls",m:"md",children:jsx(V0,{index:O+1,report:t})})]},`section-${I}`)},I)),k.placeholder]}),[f,c.id,v]),b=!!c.id?50:0,w=50+(d.opened?350:50)+(m.opened?350:b);return jsxs(Box,{children:[jsx(nT,{report:t}),jsxs(Flex,{children:[!g.opened&&jsx(Cy,{scrollContainer:h}),jsx(Box,{sx:{flexGrow:1},pos:"relative",children:jsx(ScrollArea,{w:`calc(100vw - ${w}px)`,viewportRef:h,h:"calc(100vh - 50px)",styles:{scrollbar:{zIndex:9999}},offsetScrollbars:true,children:jsxs(Stack,{styles:{backgroundColor:r.colors.gray[2]},spacing:0,children:[g.opened&&jsx(z0,{report:t}),!g.opened&&jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:o}),t.sections.length===0&&jsx(Center,{className:"cms-section-controls",my:"md",children:jsx(V0,{index:0,report:t})}),jsx(DragDropContext,{onDragEnd:T,children:jsx(Droppable,{droppableId:"sections",children:y})})]})]})})}),c.type&&jsx(Iy,{})]})]})}function V0({index:e,report:t}){let o=useMantineTheme(),r=ie(),n=H(a=>a.records.entities.section),i=useCallback(()=>{r(Z.createEntity("section",{report_id:t.id,ordering:hn(n,t.sections,e,true)}));},[e]);return jsx(ActionIcon,{onClick:i,size:"lg",radius:"xl",variant:"light",bg:"#E5E5E5 !important",style:{boxShadow:o.shadows.xs},children:jsx(IconPlus,{size:24,color:"white",strokeWidth:1})})}p();p();ae();he();var j0={value:"all",label:"All"},_6=e=>{if(!e)return [];let t=Object.keys(e).map(o=>({value:String(o),label:String(e[o])}));return [j0,...t]};function K0({onChange:e,loading:t,onEditCreation:o}){let r=ie(),[n,i]=useState(""),[a,l]=useState(false),[s]=useDebouncedValue(n,500),c={type:j0.value},[u,d]=useState(c),m=()=>{i(""),d(c);},g=useMemo(()=>({type:_6(Ka)}),[]);useEffect(()=>{e({...u,query:s});},[u.type,s]);let f=()=>{l(true);let v=Math.random().toString(16).substring(2,10);r(Z.createEntity("formatter",{name:`formatter_${v}`,content:{type:"formatter",logic:"return n;",inputType:"string",testValue:"123456",description:"New formatter"}})).then(T=>{l(false),m(),T.ok&&o(T.data.id);});},h=useCallback((v,T)=>{let y={...u,[v]:T};d(y);},[u]);return jsxs("div",{children:[jsx(TextInput,{label:"Search by name or description",value:n,onChange:v=>i(v.currentTarget.value),disabled:t}),jsx(Select,{label:"Type",data:g.type,value:u.type,onChange:v=>h("type",v),disabled:t}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconCircleX,{}),onClick:m,children:"Clear filters"}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconPlus,{}),onClick:f,variant:"light",loading:a,children:"New formatter"})]})}p();ae();he();Ha();xe();var tA=e=>e?Object.keys(e).map(t=>({value:String(t),label:String(e[t])})):[],G6=(e,t)=>{switch(e){case yn.OBJECT:return JSON.parse(t);default:return `${t}`}};function rA({formatterId:e,onEditEnd:t}){let o=H(R=>R.status.localeDefault),r=!!e,[n,i]=useState(),[a,l]=useState(""),[s,c]=useState([]),[u,d]=useState(true),[m,g]=useState(false),[f,h]=useState(true),[v,T]=useState(true),[y]=useState(false),C=ie(),b=lf(e),w=Zi(),k=$S(b.data?.name),I=u||m;useEffect(()=>{b.isLoading||i(b.data);},[b.isLoading]),useEffect(()=>{if(!b.isLoading&&!w.isLoading){let R=b.isSuccess?b.data:void 0,z=w.isSuccess?w.data:[];if(R){let A=z.filter(V=>V.id!==R.id).map(V=>V.name);c(A);}D(),d(false);}},[b.isLoading,w.isLoading]);let O=n&&!s.includes(n.name)&&n.name!=="",P=R=>{O&&T(false),n&&i({...n,name:tp(R).replace("-","")});},_=(R,z)=>{R!=="description"&&h(true),n&&i({...n,content:{...n.content,[R]:z}});},D=()=>{if(n){let R="";try{let z=Ua({vars:["n"],logic:n.content.logic},{},o,{}),A=G6(n.content.inputType,n.content.testValue);R=z(A),T(!0);}catch(z){R=`ERROR: ${z.message}`,console.error(z),T(false);}h(false),l(`${R}`);}},L=()=>{g(true),v&&O&&C(Z.updateEntity("formatter",n)).then(t);};return jsx(Drawer,{opened:r,onClose:()=>t(),title:`Edit formatter ID ${e}`,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"50%",lockScroll:true,withCloseButton:false,children:jsx(Po,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:u,overlayBlur:2,overlayOpacity:.5}),y&&jsx(Alert,{title:"Formatter Form",color:"red",children:"Error, please try again."}),n&&!y&&jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{grow:true,align:"flex-start",children:[jsx(TextInput,{label:`Name ${O&&k>0?`(Read only, used in ${k} blocks)`:""}`,value:n.name,icon:O?jsx(IconCircleCheck,{}):jsx(IconAlertCircle,{}),readOnly:O&&k>0,disabled:O&&k>0,onChange:R=>P(R.target.value),error:O?false:"Duplicate or empty name, choose a different one."}),jsx(Select,{label:"Type",data:tA(Ka),value:n.content.type,onChange:R=>_("type",R)})]}),jsx(Textarea,{label:"Description",value:n.content.description,onChange:R=>_("description",R.target.value)}),jsx(ua,{monacoOptions:{onChange:R=>_("logic",R),height:"30vh",value:n.content.logic}},"formatter-code-editor"),jsxs(Group,{grow:true,align:"flex-end",children:[jsx(Select,{label:"Input Type",data:tA(wu),value:n.content.inputType,onChange:R=>_("inputType",R)}),jsx(TextInput,{label:"Test Value",value:n.content.testValue,onChange:R=>_("testValue",R.target.value),error:n.content.testValue===""&&!v})]}),jsx(Textarea,{readOnly:true,icon:v?jsx(IconCircleCheck,{}):jsx(IconAlertCircle,{}),label:"Test Results",value:a,error:a.includes("ERROR")&&!v?"There is a problem in the function, input type or test value. Please check and run again.":false})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:I,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:D,disabled:!f,color:f?"blue":v?"green":"red",leftIcon:jsx(IconPlayerPlay,{}),children:"Run Test"}),jsx(Button,{onClick:L,loading:I,disabled:I||!v||f||!O,children:"Save"})]}),size:165})})}p();ae();xe();he();var Z6=(e,t)=>{switch(e){case yn.OBJECT:return JSON.parse(t);default:return `${t}`}};function aA({filters:e,onClickEdit:t}){let[o,r]=useState([]),n=Zi(),i=n.isSuccess?n.data:[],a=Ao(),l=US(),s=useMemo(()=>i.map(d=>{let m=l[d.name]?l[d.name]:0,g="";try{let f=Z6(d.content.inputType,d.content.testValue);g=a[d.name](f);}catch(f){g=`ERROR: ${f.message}`,console.error(`Error in ${d.name}`),console.error(f);}return {...d,result:g,usageCount:m}}),[i]),c=()=>{let d=s.filter(m=>{let g=true,f=true;return e.query&&(g=m.name.toLowerCase().indexOf(e.query.toLowerCase())>-1||m.content.description.indexOf(e.query)>-1),e.type!=="all"&&(f=m.content.type===e.type),g&&f});r(d);};return useEffect(()=>{c();},[e,s]),jsx(MantineReactTable,{columns:[{header:"ID",accessorKey:"id",minSize:55,size:55,maxSize:55},{header:"Name",accessorKey:"name",Cell:({row:d})=>{let m=d.original.content.type===ku.FORMATTER?jsx(IconVariable,{size:"1.3em"}):jsx(IconMathFunction,{size:"1.3em"});return jsxs(Group,{noWrap:true,align:"center",spacing:2,children:[jsx("span",{children:d.original.name}),jsx(Tooltip,{label:Ka[d.original.content.type],children:jsx("span",{children:m})})]})},minSize:80,size:80},{header:"Description",accessorKey:"content.description",enableSorting:false,mantineTableBodyCellProps:{sx:{textWrap:"wrap"}},minSize:100},{header:"Demo",accessorKey:"content.testValue",Cell:({row:d})=>{let m=d.original.content.testValue;d.original.content.inputType===yn.STRING&&(m=`"${m}"`);let g=d.original.result;return typeof d.original.result=="string"&&(g=`"${g}"`),jsxs(Group,{spacing:2,children:[jsx(Tooltip,{label:`Input Type: ${wu[d.original.content.inputType]}`,children:jsx(Code,{color:"blue",children:m})}),jsx(IconArrowRightCircle,{}),jsx(Code,{color:d.original.result&&`${d.original.result}`.includes("ERROR")?"red":"teal",children:g})]})},enableSorting:false,minSize:100,size:100},{header:"Usage",accessorKey:"usageCount",mantineTableHeadCellProps:{align:"right",sx:{"& .mantine-TableHeadCell-Content-Labels":{flexDirection:"row"}}},mantineTableBodyCellProps:{align:"right"},minSize:85,size:85,maxSize:85},{header:"Actions",accessorKey:"actions",Cell:({row:d})=>jsxs(Group,{position:"center",spacing:"xs",noWrap:true,children:[jsx(ActionIcon,{onClick:()=>t(d.original),children:jsx(IconPencil,{size:20})},"edit"),jsx(ar,{id:d.original.id,type:"formatter",disabled:d.original.usageCount>0,warning:`Delete formatter called "${d.original.name}" (id:${d.original.id}) ? It is not used in any block.`})]}),enableSorting:false,minSize:80,size:80,maxSize:80,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}],data:o,enableBottomToolbar:false,enableColumnActions:false,enableColumnResizing:true,enablePagination:false,enableTopToolbar:false,initialState:{density:"xs"},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150}},mantineTableProps:{striped:true}})}function lA(){let[e,t]=useState(null),[o,r]=useState(true),n=s=>{r(s);},i=s=>{t(s);},a=s=>{s&&t(s.id);},l=()=>{t(null);};return jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Formatters"}),jsx(K0,{onChange:n,onEditCreation:i,loading:false})]}),jsxs(Grid.Col,{span:10,style:{height:"100vh"},children:[jsx(Space,{h:"xs"}),jsx(aA,{filters:o,onClickEdit:a})]})]}),e&&jsx(rA,{formatterId:e,onEditEnd:l})]})}p();p();ae();function mA({onChange:e,loading:t,onEditCreation:o}){let r=ie(),[n,i]=useState(""),[a,l]=useState(""),[s,c]=useState(false),[u]=useDebouncedValue(n,500),[d]=useDebouncedValue(a,500),m={query:"",name:""},[g,f]=useState(m),h=()=>{i(""),l(""),f(m);},v=()=>{l(""),f(C=>({...C,name:""}));},T=()=>{i(""),f(C=>({...C,query:""}));};return useEffect(()=>{let C={...g,name:d,query:u,matchPattern:b=>{if(!u)return true;try{return new RegExp(b.patternSwapped).test(u)}catch{return false}}};e(C);},[u,d]),jsxs("div",{children:[jsx(TextInput,{label:"Filter by name",value:a,onChange:C=>l(C.currentTarget.value),disabled:t,rightSection:a?jsx(IconCircleX,{size:16,style:{cursor:"pointer"},onClick:v}):null}),jsx(Space,{h:"md"}),jsx(TextInput,{label:"Test a url here",value:n,onChange:C=>i(C.currentTarget.value),disabled:t,rightSection:n?jsx(IconCircleX,{size:16,style:{cursor:"pointer"},onClick:T}):null}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconPlus,{}),onClick:()=>{c(true);let C=Math.random().toString(16).substring(2,10);r(Z.createEntity("datasource",{name:`datasource_${C}`,description:"New Data Source",content:{pattern:"",logic:`
76
+ `,"2) content: () => element.cloneNode(true)"].join(" "));}var l=n.reduce(function(s,c){var u=c&&u5(c,r);return u&&s.push(u),s},[]);return Hc(e)?l[0]:l}jc.defaultProps=Xo;jc.setDefaultProps=a5;jc.currentInput=an;Object.assign({},_c,{effect:function(t){var o=t.state,r={popper:{position:o.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(o.elements.popper.style,r.popper),o.styles=r,o.elements.arrow&&Object.assign(o.elements.arrow.style,r.arrow);}});jc.setDefaultProps({render:XR});var JR=jc;p();var x5=forwardRef(function(t,o){let r=useMantineTheme(),[n,i]=useState(0),a=u=>{let d=t.items[u];d&&t.command({id:d});},l=()=>{i((n+t.items.length-1)%t.items.length);},s=()=>{i((n+1)%t.items.length);},c=()=>{a(n);};return useEffect(()=>i(0),[t.items]),useImperativeHandle(o,()=>({onKeyDown:({event:u})=>u.key==="ArrowUp"?(l(),true):u.key==="ArrowDown"?(s(),true):u.key==="Enter"||u.key==="Tab"?(c(),true):false})),jsx(List,{className:"items",bg:"white",listStyleType:"none",styles:u=>({root:{boxShadow:u.shadows.md,borderRadius:u.radius.xs,overflow:"hidden"},item:{span:{display:"block",width:"100%"}},itemWrapper:{display:"block"}}),children:t.items.length?t.items.map((u,d)=>jsx(List.Item,{children:jsx(UnstyledButton,{className:`item ${d===n?"is-selected":""}`,sx:f=>({backgroundColor:d===n?f.colors.blue[0]:"none"}),py:2,px:4,fz:12,w:"100%",onClick:()=>a(d),children:jsxs(Group,{spacing:"xs",children:[jsx(Center,{h:"1rem",w:"1rem",sx:{borderRadius:"100%",background:r.colors.blue[6]},children:jsx(IconBraces,{size:"0.8rem",color:"white"})}),jsx(Text,{ff:"monospace",component:"code",color:"gray.7",children:`${u}`})]})})},d)):null})}),ZR=x5;var k5=()=>({char:"{{",allowedPrefixes:[" "],items:({query:e,editor:t})=>t.storage.VariablesStorage.suggestions.filter(o=>o.toLowerCase().startsWith(e.toLowerCase())).slice(0,5),render:()=>{let e,t;return {onStart:o=>{e=new ReactRenderer(ZR,{props:o,editor:o.editor}),o.clientRect&&(t=JR("body",{getReferenceClientRect:o.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:true,interactive:true,trigger:"manual",placement:"bottom-start"}));},onUpdate(o){e.updateProps(o),o.clientRect&&t[0].setProps({getReferenceClientRect:o.clientRect});},onKeyDown(o){return o.event.key==="Escape"?(t[0].hide(),true):e.ref?.onKeyDown(o)},onExit(){t[0].destroy(),e.destroy();}}}}),eI=k5;p();function Tb(e){return e.replace(/<code[^>]*>([^<>]*)<\/code>/g,"$1")}p();function Cb(e){return e.replace(/({{.*?}})/g,'<code class="bespoke-var">$1</code>')}var q5=createStyles(e=>({bespokeEditor:{fontSize:14,lineHeight:1.2,backgroundColor:e.fn.lighten(e.colors.gray[0],.3),borderColor:e.colors.gray[4],borderWidth:1,borderStyle:"solid",borderRadius:e.radius.md,paddingLeft:e.spacing.xs,paddingRight:e.spacing.xs,fontWeight:400,"&.disabled":{color:e.colors.gray[7],backgroundColor:e.colors.gray[1]},":focus-visible":{outlineColor:e.colors.blue[5],backgroundColor:e.fn.lighten(e.colors.gray[0],.5)},code:{fontFamily:"monospace",color:e.colors.blue[6],fontWeight:700,letterSpacing:.02},".is-editor-empty:first-of-type::before":{color:e.colors.gray[6],content:"attr(data-placeholder)",float:"left",height:0,pointerEvents:"none"}}})),oI=()=>{let{editor:e}=useCurrentEditor(),t=useMantineTheme();return e?jsxs(Button.Group,{children:[jsx(Button,{onClick:o=>{o.preventDefault(),e.chain().focus().toggleBold().focus().run();},size:"xs",variant:"default",compact:true,children:jsx(IconBold,{size:"0.8rem",stroke:e.isActive("bold")?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().toggleItalic().run(),size:"xs",variant:"default",compact:true,children:jsx(IconItalic,{size:"0.8rem",stroke:e.isActive("italic")?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().toggleUnderline().run(),size:"xs",variant:"default",compact:true,children:jsx(IconUnderline,{size:"0.8rem",stroke:e.isActive("underline")?4:2,color:t.colors.gray[7]})})]}):null},Y5=()=>{let{editor:e}=useCurrentEditor();return jsx("div",{children:jsx(BubbleMenu,{tippyOptions:{placement:"bottom"},editor:e,children:jsx(oI,{})})})},X5=()=>{let{editor:e}=useCurrentEditor(),t=useMantineTheme();return e?jsxs(Button.Group,{children:[jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("left").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignLeft,{size:"0.8rem",stroke:e.isActive({textAlign:"left"})?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("center").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignCenter,{size:"0.8rem",stroke:e.isActive({textAlign:"center"})?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("right").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignRight,{size:"0.8rem",stroke:e.isActive({textAlign:"right"})?4:2,color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.chain().focus().setTextAlign("justify").run(),size:"xs",variant:"default",compact:true,children:jsx(IconAlignJustified,{size:"0.8rem",stroke:e.isActive({textAlign:"justify"})?4:2,color:t.colors.gray[7]})})]}):null},J5=()=>{let{editor:e}=useCurrentEditor(),t=useMantineTheme();return e?jsxs(Button.Group,{children:[jsx(Button,{onClick:()=>e.commands.undo(),size:"xs",variant:"default",compact:true,children:jsx(IconArrowBackUp,{size:"0.8rem",color:t.colors.gray[7]})}),jsx(Button,{onClick:()=>e.commands.redo(),size:"xs",variant:"default",compact:true,children:jsx(IconArrowForwardUp,{size:"0.8rem",color:t.colors.gray[7]})})]}):null},Q5=({toolbarActive:e=true,toolbarLeftSection:t=null,toolbarRightSection:o=null,toolbarOptions:r={}})=>{let n=r.history??true,i=r.alignment??false,a=r.format??true;return jsxs(Group,{mb:"0.25rem",position:"apart",children:[t,e&&jsxs(Group,{children:[n&&jsx(J5,{}),i&&jsx(X5,{}),a&&jsx(oI,{})]}),o]})};function Cd(e){let{id:t,value:o,onChange:r=()=>{},variables:n,toolbarLeftSection:i,toolbarRightSection:a,toolbarOptions:l={},tipTapExtensions:s=[],bubbleMenu:c=true,disabled:u=false,editorProps:d,placeholder:f="This looks empty! Start writing some content"}=e,[g,m]=useState(false),h=useClickOutside(()=>m(false)),{classes:y}=q5(),S=JSON.stringify(n||{}),v=useMemo(()=>{let k=JSON.parse(S),w=[O5.configure({heading:false,bold:false,history:{depth:20},code:false,hardBreak:false,codeBlock:false}),sR.extend({spanning:true}),M5.extend({addKeyboardShortcuts(){return {Enter:()=>this.editor.commands.setHardBreak()}}}),B5.configure({types:["paragraph"]}),P5,lR,D5.configure({placeholder:f}),K5,...s];return k&&(w.push(cR),w.push(L5.configure({HTMLAttributes:{type:null},renderText({node:R}){return `{{${R.attrs.label??R.attrs.id}}}`},renderHTML({node:R}){return ["code",{},`{{${R.attrs.label??R.attrs.id}}}`]},suggestion:eI()}))),w},[S,s,f]),C=({editor:k})=>{let w=Tb(k.getHTML());r(w);},b=({editor:k})=>{let w=JSON.parse(S);k.storage.VariablesStorage.suggestions=Object.keys(w);};return jsx(Box,{ref:h,className:"bespoke-editor",onClickCapture:()=>m(true),children:jsx(EditorProvider,{extensions:v,content:o?Cb(o):void 0,onUpdate:C,onFocus:b,editable:!u,slotBefore:jsx(Q5,{toolbarActive:g,toolbarLeftSection:i,toolbarRightSection:a,toolbarOptions:l}),editorProps:{editable:()=>!u,attributes:{id:t||"",class:`${y.bespokeEditor}${u?" disabled":""}`}},...d,children:c&&jsx(Y5,{})})})}p();he();ye();var rI=createContext({mode:"simple",changeEditorMode:()=>{},reference:{locale:void 0,content:{},activate:()=>{},deactivate:()=>{},setActive:()=>{},active:false}});function rK(e){let[t,o]=useState(false),[r,n]=useState({}),i=os();return useEffect(()=>{if(!t){n(void 0);return}Mu.get(`/api/cms/read/block?&id=${e}&include=true`).then(({data:a})=>{n(a.data[0].contentByLocale[i].content.simple);}).catch(()=>n(void 0));},[t,e,i]),{content:r,locale:i,activate:()=>o(true),deactivate:()=>o(false),setActive:o}}function nI({children:e,buttons:t,blockType:o,blockId:r}){let[n,i]=useState(()=>[E.VIZ,E.GENERATOR,E.SECTION_FLAG].includes(o)?"code":"simple"),a=rK(r),l={mode:n,changeEditorMode:i,reference:a,...t};return jsx(rI.Provider,{value:l,children:e})}function sn(){return useContext(rI)}function yK({locale:e,content:t}){return jsxs(Group,{spacing:"xs",position:"right",children:[jsx(Badge,{variant:"light",size:"xs",rightSection:jsx(Center,{children:jsx(IconLanguage,{size:rem(12)})}),children:e.toUpperCase()}),jsx(sI,{content:t})]})}function sI({content:e}){return jsx(CopyButton,{value:e,timeout:2e3,children:({copied:t,copy:o})=>jsx(Tooltip,{label:t?"Copied":"Copy",withArrow:true,position:"right",children:jsx(ActionIcon,{size:"xs",color:t?"teal":"gray",variant:"subtle",onClick:()=>{o();let r=new Blob([e],{type:"text/html"}),n=new ClipboardItem({"text/html":r});navigator.clipboard.write([n]);},children:t?jsx(IconCheck,{style:{width:rem(16)}}):jsx(IconCopy,{style:{width:rem(16)}})})})})}function vK({referenceLocale:e,referenceContent:t}){return jsx(Stack,{spacing:"xs",children:jsx(Cd,{value:t,toolbarLeftSection:jsx(Text,{size:"0.625rem",tt:"uppercase",fw:700,color:"gray",children:"Reference Content"}),toolbarRightSection:jsx(yK,{locale:e,content:t}),toolbarOptions:{history:false,format:false,alignment:false},disabled:true})})}function Jo({field:e,handleEditor:t,value:o,referenceContent:r,referenceLocale:n,variables:i,editorConfig:a={}}){return jsxs(Stack,{spacing:0,children:[jsx(Cd,{id:e,onChange:l=>{t(e,He(l));},toolbarLeftSection:jsx(Text,{component:"label",htmlFor:e,size:"xs",transform:"uppercase",weight:"bold",color:"gray",mb:"xs",children:titleCase(e)}),toolbarRightSection:jsx(sI,{content:o}),toolbarOptions:{history:true,alignment:e!=="tooltip",format:true},value:o,variables:i,placeholder:`This looks empty. Start adding content for the ${e}! You can add automated {{variables}}`,...a}),r&&jsx(Box,{mt:"xs",children:jsx(vK,{referenceContent:r[e],referenceLocale:n})})]})}function SK({fields:e,locale:t,defaultContent:o,onChange:r,variables:n}){let[i,a]=useState(()=>od(o)),{reference:l}=sn();useEffect(()=>{r(i,t);},[]);let s=(u,d)=>{a(f=>({...f,[u]:d}));},[c]=useDebouncedValue(i,500);return useEffect(()=>{let u=Object.keys(c).reduce((f,g)=>({...f,[g]:He(c[g])}),{}),d=on(u);r({simple:u,logic:d},t);},[c,t]),jsx(Stack,{spacing:"xl",children:e.map(({field:u,editorConfig:d})=>jsx(Jo,{field:u,handleEditor:s,value:i[u]||"",referenceContent:l.content,referenceLocale:l.locale,variables:n,editorConfig:d},u))})}var lI=SK;p();function wK({label:e,...t}){return jsxs(Group,{position:"apart",spacing:"lg",py:"xs",...t,children:[jsx(Text,{children:e}),jsx(Tooltip,{label:"This setting will be saved for all languages.",children:jsx(ThemeIcon,{size:"xs",variant:"light",radius:"xl",color:"yellow",children:jsx(IconLanguageOff,{size:"0.75rem"})})})]})}var Wt=wK;he();p();var Oa={SINGLE:"single",MULTI:"multi"},Ib={SEGMENTED_CONTROL:"segmented control",SELECTOR:"selector"},vi={STATIC:"static",DYNAMIC:"dynamic"},Ab=e=>e&&Array.isArray(e)&&e.length>0,Ed=e=>Ab(e)&&["string"].includes(typeof e[0]),uI=e=>{let{name:t,type:o,optionsType:r,options:n}=e;return [t,o,r,n].every(Boolean)?r===vi.STATIC?n.static?.length>0&&n.static?.every(i=>i.id):n.dynamic?.isPrimitiveType?true:!!n.dynamic?.idKey:false},wd=(e,t,o)=>{let r,n;switch(o){case vi.STATIC:r=e===Oa.SINGLE?t.static.find(i=>i.isDefault)?.id:t.static.filter(i=>i.isDefault).map(i=>i.id),n=t.static.map(({id:i,label:a})=>({id:i,label:a||i}));break;case vi.DYNAMIC:if(t.dynamic){let{optionsVar:i,idKey:a,labelKey:l,imageKey:s,defaultVar:c,isPrimitiveType:u}=t.dynamic;c&&(r=`variables["${c}"]`),n=u?`variables["${i}"]`:`(variables["${i}"] || []).map(d => ({id: String(d["${a}"]), label: String(d["${l||a}"]), imageUrl: String(d["${s||null}"])}))`;}break;}return {logicOptions:n,defaultValue:r}};function MK({option:e,editOption:t,deleteOption:o}){return jsxs("tr",{className:"reports-selector-static-option",children:[jsx("td",{children:jsx(Checkbox,{checked:e.isDefault,onChange:r=>t({isDefault:r.currentTarget.checked})})}),jsx("td",{children:jsx(TextInput,{placeholder:"Option value",value:e.id,onChange:r=>{t({id:r.currentTarget.value});},error:e.id.indexOf(" ")>-1?"Please, avoid the usage of spaces in the ID":false})}),jsx("td",{children:jsx(TextInput,{placeholder:"Option label",value:e.label,onChange:r=>t({label:r.currentTarget.value})})}),jsx("td",{children:jsx(ActionIcon,{onClick:o,children:jsx(IconTrash,{})})})]})}function BK({staticOptions:e,setStaticOptions:t}){let o=useCallback(()=>t([...e,{isDefault:!e.length,id:"",label:""}]),[e,t]),r=useCallback((i,a)=>{if(!a||i>=e.length||i<0)return;let l=[...e];l.splice(i,1,{...e[i],...a}),t(l);},[e,t]),n=useCallback(i=>{let a=[...e];a.splice(i,1),t(a);},[e,t]);return jsxs(Fragment,{children:[jsx(Input.Wrapper,{required:true,label:"Static Selector Options",children:jsxs("table",{children:[jsx("thead",{children:e.length>0&&jsx("tr",{children:["Default","ID","Label",""].map((i,a)=>jsx("td",{className:`${a===0?"selector-option-default-col":""} ${a===1?"required":""}`,children:i},`heading-${a}`))})}),jsx("tbody",{children:e.map((i,a)=>jsx(MK,{option:i,editOption:l=>r(a,l),deleteOption:()=>n(a)},`option-${a}`))})]})}),jsx(ActionIcon,{onClick:o,children:jsx(IconPlus,{})})]})}function DK({id:e,dynamicOptions:t,setDynamicOptions:o}){let{optionsVar:r,idKey:n,labelKey:i,defaultVar:a,imageKey:l,isPrimitiveType:s}=t,c=ot(e),[u,d]=useState(false),[f,g]=useState({}),[m,h]=useState([]),[y,S]=useState([]);useEffect(()=>{c||(g({}),h([]));let R=Object.entries(c).filter(([,A])=>Ab(A)).reduce((A,[B,_])=>(A[B]=_,A),{});g(R);let O=Object.keys(c);h(O),d(true);},[c]);let v=useCallback((R,O)=>{o({...t,[R]:O});},[t]);useEffect(()=>{if(!Object.keys(f).length)return;let R=Ed(f[r]);if(R)S([]),v("idKey",null),v("labelKey",null),v("imageKey",null);else {let O=new Set;(f[t.optionsVar]||[]).forEach(B=>Object.keys(typeof B=="object"?B:{}).forEach(_=>O.add(_)));let A=Array.from(O).sort().map(B=>B);S(A);}v("isPrimitiveType",R);},[f,r]);let C=useCallback(R=>{o({...t,optionsVar:R,idKey:null,labelKey:null,imageKey:null});},[t,o]),b=useMemo(()=>{let R=[];return f&&r&&n&&Array.isArray(f[r])&&(R=f[r].filter(O=>`${O[n]}`.indexOf(" ")>0)),R.length>0?`One or more ID's have spaces on it. (
77
+ ${R.map(O=>`"${O[n]}"`).join(",")}
78
+ ) Avoid this, please.`:false},[f,r,n]);if(!u)return null;let k=Object.keys(f),w=R=>R&&Array.isArray(R)&&R.length;return jsxs(Fragment,{children:[jsx(Select,{label:"Options List Variable",placeholder:"Pick a variable",value:w(k)&&r,required:true,onChange:C,data:k}),jsx(Select,{label:"Options ID Key",placeholder:"Pick a property key",value:w(y)&&n,required:!s,disabled:s,onChange:R=>v("idKey",R),data:y,error:b}),jsx(Select,{label:"Options Label Key",placeholder:"Pick a property key",disabled:s,clearable:true,value:w(y)&&i,onChange:R=>v("labelKey",R),data:y}),jsx(Select,{label:"Options Image Key",placeholder:"Pick a property key",disabled:s,clearable:true,value:w(y)&&l,onChange:R=>v("imageKey",R),data:y}),jsx(Select,{label:"Default ID Variable",placeholder:"Pick a variable",clearable:true,value:w(m)&&a,onChange:R=>v("defaultVar",R),data:m})]})}function Qs(e,t,o){return e&&e[t]||o}function _K(e){let{id:t,executeButton:o,onChange:r,simpleState:n,referenceContent:i,referenceLocale:a,variables:l}=e,[s,c]=useState(()=>{let f=n&&n.options&&Object.prototype.hasOwnProperty.call(n?.options,"dynamic")&&Object.prototype.hasOwnProperty.call(n?.options,"static");return {selectorIdentifier:Qs(n,"name",""),selectorType:Qs(n,"type",Oa.SINGLE),selectorComponent:Qs(n,"component",Ib.SELECTOR),options:n&&f?n.options:{static:[],dynamic:{}},optionsType:Qs(n,"optionsType","static"),hideLabel:Qs(n,"hideLabel","false"),resetSectionVars:Qs(n,"resetSectionVars","false")}});useEffect(()=>{let{selectorIdentifier:f,selectorType:g,selectorComponent:m,options:h,optionsType:y,hideLabel:S,resetSectionVars:v}=s,C={name:f,hideLabel:S,resetSectionVars:v,component:m,type:g},{logicOptions:b,defaultValue:k}=wd(g,h,y);k&&(C.defaultValue=k),C.options=b;let w=`return ${Us(C)};`,R={name:f,type:g,component:m,hideLabel:S,resetSectionVars:v,defaultValue:k,optionsType:y,options:h},O=uI(R);r(R,w,O);},[s]);let u=(f,g)=>c(m=>({...m,[f]:g})),d=rr[E.SELECTOR].find(f=>f.field===Pe.SELECTOR_NAME)?.editorConfig;return jsxs(Fragment,{children:[jsxs(Stack,{children:[jsx(Jo,{field:"name",value:s.selectorIdentifier,handleEditor:(f,g)=>u("selectorIdentifier",g),referenceContent:i,referenceLocale:a,variables:l,editorConfig:d}),jsx(Checkbox,{label:jsx(Wt,{label:"Hide Label",py:0}),checked:s.hideLabel==="true",onChange:f=>u("hideLabel",f.currentTarget.checked?"true":"false")})]}),jsx(Select,{label:jsx(Wt,{label:"Selector Type"}),value:s.selectorType,onChange:f=>u("selectorType",f),data:Object.values(Oa)}),s.selectorType===Oa.SINGLE&&jsx(Select,{label:jsx(Wt,{label:"Selector Component"}),value:s.selectorComponent,onChange:f=>u("selectorComponent",f),data:Object.values(Ib)}),jsx(Select,{label:jsx(Wt,{label:"Options Type"}),value:s.optionsType,onChange:f=>u("optionsType",f),data:Object.values(vi)}),s.optionsType===vi.STATIC?jsx(BK,{staticOptions:s.options.static,setStaticOptions:f=>u("options",{...s.options,static:f})}):jsx(DK,{dynamicOptions:s.options.dynamic,setDynamicOptions:f=>u("options",{...s.options,dynamic:f}),id:t}),jsx(Checkbox,{my:"md",label:jsx(Wt,{label:"Reset SectionVariables on change",py:0}),checked:s.resetSectionVars==="true",onChange:f=>u("resetSectionVars",f.currentTarget.checked?"true":"false")}),o]})}var mI=_K;p();p();p();var gI=["xs","sm","md","lg","xl"],YK=["0","1","2","3","4","5"],_n={none:{value:"none",label:"No Icon"},tabler:{value:"tabler",label:"Bespoke (Tabler)",link:"https://tablericons.com",text:"Tabler Icons"},custom:{value:"custom",label:"Custom Icon"}},XK=forwardRef(({value:e,iconType:t="tabler",...o},r)=>jsx("div",{ref:r,...o,children:jsxs(Group,{noWrap:true,children:[jsx(Image,{width:20,height:20,src:`/api/cms/read/icons/${t}/icon.svg?name=${e}`,alt:`Icon preview ${e}`}),jsx(Text,{size:"sm",children:e})]})}));function La(e){let[t,o]=useState(e?._iconType??"none"),[r,n]=useState(e?._icon??""),[i,a]=useState([]),[l,s]=useState(""),[c,u]=useState(e?._iconVariant??"transparent"),[d,f]=useState(e?._iconSize??"md"),[g,m]=useState(e?._iconRadius??"md"),[h,y]=useState(e?._iconPadding??"1"),S=[_n.none.value,_n.custom.value].includes(t),v=useRef(null),C=useMemo(()=>({_icon:r,_iconType:t,_defaultIcon:l,_iconVariant:c,_iconSize:d,_iconRadius:g,_iconPadding:h}),[r,t,l,c,d,g,h]),b=w=>{n(""),o(w);};useEffect(()=>{S||Mu.get(`/api/cms/list/icons/${t}`).then(w=>{a(w.data.data.results),s(w.data.data.results[0]);});},[t]);let k=jsx(Accordion,{variant:"separated",children:jsxs(Accordion.Item,{value:"icon",children:[jsx(Accordion.Control,{icon:jsx(IconPhotoFilled,{}),children:jsxs(Text,{children:["Icon configuration: ",_n[t]&&jsx("strong",{children:_n[t].label})]})}),jsx(Accordion.Panel,{children:jsxs(Stack,{children:[jsx(Input.Wrapper,{label:"Title's icon",children:jsx(SegmentedControl,{fullWidth:true,value:t,onChange:b,data:Object.values(_n)})}),!S&&jsx(Select,{label:"Choose an icon from the list",searchable:true,description:jsxs(Fragment,{children:["Powered by"," ",jsx("a",{style:{textDecoration:"underline"},href:_n[t].link,target:"_blank",rel:"noreferrer",children:_n[t].text}),"."]}),defaultValue:l,value:r,required:true,onChange:w=>n(w||""),data:i,limit:10,itemComponent:XK,disabled:!i||i.length===0,icon:jsx(Image,{p:5,src:`/api/cms/read/icons/${t}/icon.svg?name=${r||l}`,alt:"Icon preview"})}),t===_n.custom.value&&jsxs(Flex,{align:"flex-end",children:[jsx(TextInput,{ref:v,placeholder:"e.g '/image{{id1}}.png' or 'http://site/image.png'",label:"Enter an icon path",required:true,defaultValue:r,description:"Add an absolute or a relative path url",onBlur:w=>n(w.currentTarget.value),sx:{flexGrow:1}}),jsx(ActionIcon,{maw:36,size:36,onClick:()=>v.current?n(v.current.value??""):void 0,sx:{flexGrow:0},children:jsx(IconFileUpload,{})})]}),t!==_n.none.value&&jsxs(Fragment,{children:[jsx(Select,{label:"Variant design",description:jsxs(Fragment,{children:["We are using"," ",jsx("a",{style:{textDecoration:"underline"},href:"https://mantine.dev/core/theme-icon/",target:"_blank",rel:"noreferrer",children:"ThemeIcon variants"}),"."]}),value:c,required:true,onChange:w=>u(w||"transparent"),data:[{value:"transparent",label:"Transparent"},{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"light",label:"Light"},{value:"filled",label:"Filled"}]}),jsx(Input.Wrapper,{label:"Size",children:jsx(SegmentedControl,{fullWidth:true,value:d,onChange:f,data:gI})}),jsx(Input.Wrapper,{label:"Radius",children:jsx(SegmentedControl,{fullWidth:true,value:g,onChange:m,data:gI})}),jsx(Input.Wrapper,{label:"Padding",children:jsx(SegmentedControl,{fullWidth:true,value:h,onChange:y,data:YK})})]})]})})]})});return {simpleIconState:C,panel:k}}p();function Ci(e,t){let[o,r]=useState({...t,...e});return {state:o,updateState:(i,a)=>{let l={...o,[i]:a};r(l);}}}he();var oq={type:"list",title:"",shotTitle:""},rq=[{value:"list",label:"List"},{value:"multilevel",label:"Multilevel"}];function Db({simpleState:e,onChange:t,variables:o,referenceContent:r,referenceLocale:n}){let{state:i,updateState:a}=Ci(e,oq),{simpleIconState:l,panel:s}=La(e);return useEffect(()=>{let c={...i,...l},u=on(c);t(c,u);},[i,l]),jsxs(Stack,{children:[jsx(Title,{order:4,children:"Nav UI"}),jsx(Select,{label:"Nav Type",data:rq,value:i.type,defaultValue:"list",onChange:c=>a("type",c)}),rr[E.NAV].map(({field:c,editorConfig:u})=>jsx(Jo,{field:c,value:i[c],handleEditor:a,referenceContent:r,referenceLocale:n,variables:o,editorConfig:u},c)),s]})}p();function _b({executeButton:e,onChange:t,simpleState:o}){let[r,n]=useState(o?.compare??"variant"),[i,a]=useState(o?.limit??4);return useEffect(()=>{t({compare:r,limit:i});},[r,i]),jsxs(Stack,{children:[jsx(Radio.Group,{description:"Valid only for single-dimensional profiles",label:"Compare with members of:",onChange:n,value:r,children:jsxs(Group,{children:[jsx(Radio,{label:"Same report",value:"report"}),jsx(Radio,{label:"Same dimension",value:"dimension"}),jsx(Radio,{label:"Same variant",value:"variant"})]})}),jsx(NumberInput,{label:"Related reports limit",min:1,onChange:l=>a(l),type:"number",value:i}),e]})}p();function zb({executeButton:e,onChange:t,simpleState:o}){let[r,n]=useState(o?.label??""),[i,a]=useState(o?.showIcon??true),[l,s]=useState(o?.fullWidth??false),[c,u]=useState(o?.showWhenDisabled??false);return useEffect(()=>{t({label:r,showIcon:i,fullWidth:l,showWhenDisabled:c});},[r,i,l,c,t]),jsxs(Stack,{children:[jsx(TextInput,{placeholder:"Label for reset section state button",value:r,onChange:d=>n(d.target.value),label:"Label"}),jsxs(Group,{children:[jsx(Switch,{checked:i,label:"Show icon",onChange:d=>a(d.currentTarget.checked)}),jsx(Switch,{checked:l,label:"Full width",onChange:d=>s(d.currentTarget.checked)}),jsx(Switch,{checked:c,label:"Show when disabled",onChange:d=>u(d.currentTarget.checked)})]}),e]})}p();he();var gq={title:"Title",tooltip:"",slug:""};function Fb({onChange:e,simpleState:t,variables:o,referenceContent:r,referenceLocale:n}){let{state:i,updateState:a}=Ci(t,gq),{simpleIconState:l,panel:s}=La(t);return useEffect(()=>{let c={...i,...l},u=on(c);e(c,u);},[l,i]),jsxs(Stack,{children:[rr[E.TITLE].map(({field:c,editorConfig:u})=>jsx(Jo,{field:c,value:i[c],handleEditor:a,referenceContent:r,referenceLocale:n,variables:o,editorConfig:u},c)),s]})}p();var Cq=[{value:"left",label:"Left"},{value:"center",label:"Center"},{value:"right",label:"Right"}];function Vb({executeButton:e,onChange:t,simpleState:o}){let[r,n]=useState(o?.label??""),[i,a]=useState(o?.removeLabel??""),[l,s]=useState(o?.showIcon??true),[c,u]=useState(o?.position??"center");return useEffect(()=>{t({label:r,removeLabel:i,showIcon:l,position:c});},[r,l,i,c,t]),jsxs(Stack,{children:[jsx(TextInput,{placeholder:"Label for comparison button",value:r,onChange:d=>n(d.target.value),label:"Label"}),jsx(TextInput,{placeholder:"Label for remove comparison button",value:i,onChange:d=>a(d.target.value),label:"Remove Label"}),jsx(Group,{children:jsx(Switch,{checked:l,label:"Show icon",onChange:d=>s(d.currentTarget.checked)})}),jsx(Select,{label:"Button position",data:Cq,value:c,onChange:u}),e]})}p();he();function $b({simpleState:e,onChange:t,variables:o,referenceContent:r,referenceLocale:n}){let{state:i,updateState:a}=Ci(e,{title:"",value:"",subtitle:"",tooltip:""}),{simpleIconState:l,panel:s}=La(e);return useEffect(()=>{let c={...i,...l},u=on(c);t(c,u);},[l,i]),jsxs(Stack,{children:[rr[E.STAT].map(({field:c,editorConfig:u})=>jsx(Jo,{field:c,value:i[c],handleEditor:a,referenceContent:r,referenceLocale:n,variables:o,editorConfig:u},c)),s]})}p();ye();var jq={enableBottomToolbar:true,enableColumnActions:true,enableColumnFilters:true,enableColumnResizing:true,enableDensityToggle:true,enableFullScreenToggle:false,enableGlobalFilter:true,enableHiding:true,enablePagination:true,enableSorting:true,enableStickyHeader:true,enableTopToolbar:true},EI={enableBottomToolbar:{label:"Enable bottom toolbar",desc:"Show or hide the bottom toolbar. By disabling it, pagination will also be hidden."},enableColumnActions:{label:"Enable column actions",desc:"Enables or disables column actions for all columns. Column actions include sort, filter, show/hide column and reset column size."},enableColumnFilters:{label:"Enable column filters",desc:"Enables or disables the filter options available on columns."},enableColumnResizing:{label:"Enable column resizing",desc:"Enables the column resizing feature for all columns."},enableDensityToggle:{label:"Enable density toggle",desc:"Enable the density toggle that allows users to modify the height of each row. Disabling it will hide the density toggle button in the top toolbar."},enableFullScreenToggle:{label:"Enable full screen toggle",desc:"Enable or disable the full screen toggle feature. Disabling it will hide the full screen toggle button in the top toolbar."},enableGlobalFilter:{label:"Enable global filter",desc:"Enable global filter feature to filter data on all columns and rows. Disabling it will hide the global filter button in the top toolbar."},enableHiding:{label:"Enable hiding",desc:"Enable hiding columns feature. Disabling it will hide the hiding button in the top toolbar."},enablePagination:{label:"Enable pagination",desc:"Enable pagination feature. Disabling it will hide the pagination options in the bottom toolbar."},enableSorting:{label:"Enable sorting",desc:"Enable sorting feature for all columns."},enableStickyHeader:{label:"Enable sticky header",desc:"Allows you to maintain the column headers when scrolling through the rows of the table."},enableTopToolbar:{label:"Enable top toolbar",desc:"Show or hide the top toolbar. By disabling it, globar filter, hiding, density and full screen toggles will also be hidden."}},Kq={density:"xs"},wI=["5","10","15","20","25","30","50","100"],RI={pageIndex:0,pageSize:10},II=e=>e&&Array.isArray(e)&&e.some(t=>typeof t=="object"&&t!==null),qq=forwardRef(function({customLabels:t,customLabelsHandler:o,index:r,isActiveRefenceContent:n=false,option:i,referenceColumns:a=[],selectedColumnsHandler:l,...s},c){let u=t.find(g=>g.key===i.label)?.label||"",f=a.find(g=>g.accessorKey===i.label)?.header||i.label;return jsxs(Group,{grow:true,ref:c,...s,children:[jsxs(Group,{children:[jsx(IconGripVertical,{}),jsx(Checkbox,{checked:i.checked,label:i.label,onChange:g=>l.setItemProp(r,"checked",g.currentTarget.checked)})]}),jsx(Input,{disabled:!i.checked,onChange:g=>o.setItemProp(r,"label",g.currentTarget.value),value:u}),n&&jsx(Input,{disabled:true,value:f})]},`table-group-${i.label}-${r}`)});function Kb(e){let{executeButton:t,id:o,onChange:r,referenceContent:n={},referenceLocale:i,simpleState:a}=e,{columns:l}=n,s=ts(),c=useMemo(()=>s!==i&&n&&Object.keys(n).length>0,[s,n,i]),u=ot(o),[d,f]=useState([]),[g,m]=useListState([]),[h,y]=useState([]),[S,v]=useState(false),[C,b]=useState({}),[k,w]=useState(RI),[R,O]=useState({rowsPerPageOptions:wI}),[A,B]=useListState([]),[_,P]=useState(null),[I,F]=useSetState(jq),[M,N]=useState(Kq),[j,$]=useState({}),V=useMemo(()=>A.every(U=>U.checked),[A]),z=useMemo(()=>A.some(U=>U.checked)&&!V,[V,A]);useEffect(()=>{if(!a||!Object.keys(a).length)return;let U=u[a.variable]||[],Y=new Set;U.filter(X=>typeof X=="object"&&X!==null).forEach(X=>{Object.keys(X).forEach(le=>Y.add(le));});let ne={},re=[];a.columns&&Object.keys(a.columns)&&a.columns.forEach(X=>{ne[X.accessorKey]=X.header;});let J=[],G=[];Array.from(Y).forEach(X=>{G.push({key:X,label:ne[X]||X}),J.push({checked:!!ne[X],key:randomId(),label:X}),re.push(X);}),m.setState(G),B.setState(J);let{initialState:K={},state:ee={},mantinePaginationProps:ae={},...ue}=a.tableProps||{},Te=ee.columnOrder.filter(X=>re.includes(X));Te.push(re.filter(X=>!ee.columnOrder.includes(X))),f(Te.flat()||[]),O(ae),w(K.pagination),F({...ue}),$(ee),N(K),P(a.variable||"");},[]),useEffect(()=>{if(!u){b({});return}let U=Object.entries(u).filter(([ne,re])=>II(re)).reduce((ne,[re,J])=>(ne[re]=J,ne),{});b(U);let Y=Object.keys(U);y(Y);},[u]);let q=U=>{if(P(U),!U||!II(C[U])){v(false),B.setState([]);return}let Y=C[U];if(Y.every(K=>typeof K=="object"&&K===null)){v(false),B.setState([]);return}Y.every(K=>typeof K=="object"&&K!==null)?v(false):v(true);let ne=new Set;Y.filter(K=>typeof K=="object"&&K!==null).forEach(K=>{Object.keys(K).forEach(ee=>ne.add(ee));});let re=[],J=[],G=[];Array.from(ne).forEach(K=>{re.push({checked:true,key:randomId(),label:K}),J.push({key:K,label:K}),G.push(K);}),B.setState(re),m.setState(J),f(G);};useEffect(()=>{let U={};g.forEach(ee=>{U[ee.key]=ee.label;});let Y=A.filter(ee=>ee.checked).map(ee=>({accessorKey:ee.label,header:U[ee.label]})),ne={...M,pagination:k},re={...j,columnOrder:d},J={columns:Y,data:_?`variables["${_}"]`:[],tableProps:{...I,initialState:ne,state:re,mantinePaginationProps:R},variable:_||""},G=`return ${Us(J)};`,K={columns:Y,data:_?`variables["${_}"]`:[],tableProps:{...I,initialState:ne,state:re,mantinePaginationProps:R},variable:_||""};r(K,G);},[d,g,R,k,A,_,I,j,M]);let W=useCallback(U=>{if(!U.destination||U.source.index===U.destination.index)return;let Y=[...d],[ne]=Y.splice(U.source.index,1);Y.splice(U.destination.index,0,ne),f(Y),$(re=>{let J=re;return J.columnOrder=Y,J});},[d]);return jsxs(Fragment,{children:[jsxs(Stack,{mb:"sm",children:[jsx(Select,{clearable:true,data:h,description:"Select an array of data available in the block inputs to use as data input for the table.",label:"Data input",onChange:U=>q(U),searchable:true,value:_}),_&&C[_]&&A.length>0&&jsxs(Fragment,{children:[jsx(Input.Wrapper,{description:"Select the columns to display in the table.",error:S&&"There is a mix of types in the input data. Only object types rows will be kept.",label:"Selected columns",children:jsxs(Stack,{mt:"xs",children:[jsxs(Group,{grow:true,children:[jsx(Text,{fz:"xs",children:"Selected"}),jsx(Text,{fz:"xs",children:"Label"}),c&&jsxs(Group,{spacing:"xs",children:[jsx(Text,{fz:"xs",children:"Reference Label"}),jsx(Badge,{variant:"light",size:"xs",rightSection:jsx(Center,{children:jsx(IconLanguage,{size:rem(12)})}),children:i.toUpperCase()})]})]}),jsx(Checkbox,{checked:V,indeterminate:z,label:"All",onChange:()=>B.setState(U=>U.map(Y=>({...Y,checked:!V})))}),jsx(ScrollArea.Autosize,{mah:300,children:jsx(DragDropContext,{onDragEnd:W,children:jsx(Droppable,{droppableId:"columns",children:U=>jsx("div",{ref:U.innerRef,...U.droppableProps,children:d.map((Y,ne)=>{let re=A.findIndex(G=>G.label===Y),J=A[re];return jsx(Draggable,{draggableId:`${J.label}`,index:ne,isDragDisabled:!J.checked,children:G=>jsx(qq,{customLabels:g,customLabelsHandler:m,index:re,isActiveRefenceContent:c,option:J,ref:G.innerRef,referenceColumns:l,selectedColumnsHandler:B,...G.draggableProps,...G.dragHandleProps})},J.label)})})})})})]})}),jsx(Accordion,{variant:"separated",children:jsxs(Accordion.Item,{value:"custom-props",children:[jsx(Accordion.Control,{children:"Custom properties"}),jsx(Accordion.Panel,{children:jsx(Stack,{children:jsxs(Input.Wrapper,{description:"Select the needed table options.",label:"Table options",children:[jsx(Group,{mt:"xs",children:Object.keys(I).map(U=>jsx(Checkbox,{checked:I[U],label:jsx(Tooltip,{label:EI[U]?.desc||U,multiline:true,children:jsx(Text,{children:EI[U]?.label||U})}),onChange:()=>F({[U]:!I[U]})},`table-prop-${U}`))}),I?.enablePagination&&jsxs(Fragment,{children:[jsx(Divider,{mt:"xs"}),jsxs(Input.Wrapper,{description:"Customize initial pagination properties.",label:"Pagination props",mt:"xs",children:[jsxs(Group,{grow:true,children:[jsx(NumberInput,{label:"Initial page",min:0,onChange:U=>{w(Y=>({...Y,pageIndex:U}));},value:k.pageIndex}),jsx(Select,{data:R.rowsPerPageOptions||[],getCreateLabel:U=>`+ Create ${U}`,label:"Initial page size",onChange:U=>{w(Y=>({...Y,pageSize:parseInt(U,10)}));},searchable:true,value:k.pageSize.toString()})]}),jsxs(Group,{align:"flex-end",grow:true,children:[jsx(MultiSelect,{clearable:true,creatable:true,data:R.rowsPerPageOptions||[],getCreateLabel:U=>`+ Create ${U}`,label:"Page size options",onChange:U=>{O(Y=>({...Y,rowsPerPageOptions:U.sort((ne,re)=>parseInt(ne,10)-parseInt(re,10))})),U&&U.length>0&&!U.includes(k.pageSize.toString())&&w(Y=>({...Y,pageSize:parseInt(U[0],10)}));},onCreate:U=>(O(Y=>({...Y,rowsPerPageOptions:[...Y.rowsPerPageOptions||[],U].sort((ne,re)=>parseInt(ne,10)-parseInt(re,10))})),U),searchable:true,value:R.rowsPerPageOptions||[]}),jsx(Button,{color:"yellow",onClick:()=>{O(U=>({...U,rowsPerPageOptions:wI})),w(RI);},children:"Reset page sizes values"})]})]})]})]})})})]})})]})]}),t]})}p();ye();he();p();var AI=e=>{let{dataVar:t,levelsVar:o}=e;return !![t,o].every(Boolean)},_d=e=>{let t,o,{colorKey:r,dataVar:n,iconKey:i,defaultVar:a,isPrimitiveType:l,levelsVar:s,searchIndexKey:c}=e;a&&typeof a=="string"&&(t=`variables["${a}"].value`,o=`variables["${a}"].type`);let u=l?`variables["${n}"]`:`(variables["${n}"] || []).map((d) => ({...d, colorKey: String(d["${r}"]), iconKey: String(d["${i}"]), searchIndexKey: String(d["${c}"])}))`;return {logicLevels:`variables["${s}"]`,logicOptions:u,defaultValue:t,defaultValueType:o}};us();var Yb=e=>rr[E.MULTIHIERARCHY_SELECTOR].find(t=>t.field===e)?.editorConfig,Jq=e=>e&&Array.isArray(e)&&e.some(t=>typeof t=="object"&&t!==null),Qq=e=>e&&e.type&&e.value,tl=e=>e&&Array.isArray(e)&&e.length;function No(e,t,o){return e&&e[t]||o}function Xb(e){let{executeButton:t,id:o,onChange:r,referenceContent:n,referenceLocale:i,simpleState:a}=e,l=ot(o),[s,c]=useState(false),[u,d]=useState(()=>({allLabel:No(a,"allLabel","All"),colorKey:No(a,"colorKey",""),dataVar:No(a,"dataVar",""),defaultVar:No(a,"defaultVar",""),hideLabel:No(a,"hideLabel","false"),resetSectionVars:No(a,"resetSectionVars","false"),iconKey:No(a,"iconKey",""),isPrimitiveType:No(a,"isPrimiteType",false),levelsVar:No(a,"levelsVar",""),limit:No(a,"limit",0),placeholder:No(a,"placeholder",""),searchIndexKey:No(a,"searchIndexKey",""),searchIndexSeparator:No(a,"searchIndexSeparator","|"),selectorIdentifier:No(a,"label","")})),[f,g]=useState([]),[m,h]=useState([]),[y,S]=useState({}),[v,C]=useState({}),[b,k]=useState([]),w=useCallback((I,F,M=false)=>d(N=>({...N,[I]:!F&&M?"":F})),[]);useEffect(()=>{if(!l){g([]),h([]),S({}),C({});return}let I=Object.entries(l).filter(([j,$])=>Jq($)).reduce((j,[$,V])=>(j[$]=V,j),{}),F=Object.entries(l).filter(([,j])=>Qq(j)).reduce((j,[$,V])=>(j[$]=V,j),{});C(I),S(F);let M=Object.keys(I),N=Object.keys(F);g(M),h(N),c(true);},[l]),useEffect(()=>{if(!Object.keys(v).length)return;let I=Ed(v[u.dataVar]);if(I)k([]),w("colorKey",""),w("iconKey",""),w("searchIndexKey","");else {let F=new Set;(v[u.dataVar]||[]).forEach(N=>Object.keys(typeof N=="object"?N:{}).forEach(j=>F.add(j)));let M=Array.from(F).sort().map(N=>N);k(M);}w("isPrimitiveType",I);},[v,u.dataVar]),useEffect(()=>{let{allLabel:I,colorKey:F,dataVar:M,defaultVar:N,hideLabel:j,resetSectionVars:$,iconKey:V,levelsVar:z,limit:q,placeholder:W,searchIndexKey:U,searchIndexSeparator:Y,selectorIdentifier:ne}=u,re={allLabel:I,colorKey:F,dataVar:M,defaultVar:N,label:ne,hideLabel:j,resetSectionVars:$,iconKey:V,levelsVar:z,limit:q,placeholder:W,searchIndexKey:U,searchIndexSeparator:Y},{logicOptions:J,logicLevels:G,defaultValue:K,defaultValueType:ee}=_d(re);K&&ee&&(re.defaultValue=K,re.defaultValueType=ee),re.data=J,re.levels=G;let ae=`return ${Us(re)};`,ue=re,Te=AI(ue);r(ue,ae,Te);},[u]);let R=useCallback(I=>{w("dataVar",I),w("defaultVar",{}),w("colorKey",""),w("iconKey",""),w("searchIndexKey","");},[w]);if(!s)return null;let O=Object.keys(v),A=Object.keys(y),B=Yb(Pe.MULTIHIERARCHY_SELECTOR_ALL_LABEL),_=Yb(Pe.MULTIHIERARCHY_SELECTOR_NAME),P=Yb(Pe.MULTIHIERARCHY_SELECTOR_PLACEHOLDER);return jsxs(Fragment,{children:[jsxs(Stack,{mb:"sm",spacing:"xs",children:[jsx(Jo,{field:"label",value:u.selectorIdentifier,handleEditor:(I,F)=>{w("selectorIdentifier",F);},referenceContent:n,referenceLocale:i,variables:l,editorConfig:_}),jsx(Checkbox,{label:jsx(Wt,{label:"Hide Label",py:0}),checked:u.hideLabel==="true",onChange:I=>w("hideLabel",I.currentTarget.checked?"true":"false")}),jsx(Select,{data:f,description:"(Required) Select an array of data available in the block inputs to use as data input.",label:jsx(Wt,{label:"Data Input"}),onChange:I=>R(I),value:tl(O)&&u.dataVar}),jsx(Select,{data:f,description:"(Required) Select an array of {label, value} items in the block inputs to use as levels.",label:jsx(Wt,{label:"Levels Input"}),onChange:I=>w("levelsVar",I),value:tl(O)&&u.levelsVar}),jsx(Select,{clearable:true,data:m,description:"(Optional) Select an object with {type, value} keys in the block inputs to use as default value.",label:jsx(Wt,{label:"Default Value"}),onChange:I=>{if(!I){w("defaultVar","");return}w("defaultVar",I);},value:tl(A)&&u.defaultVar}),jsx(NumberInput,{description:"(Optional) Sets a limit for selected values. Set 0 for no limit.",label:jsx(Wt,{label:"Limit"}),min:0,onChange:I=>w("limit",I),value:u.limit}),jsx(Accordion,{mt:"md",variant:"separated",children:jsxs(Accordion.Item,{value:"customization",children:[jsx(Accordion.Control,{children:"Customization"}),jsx(Accordion.Panel,{children:jsxs(Stack,{spacing:"xs",children:[jsx(Jo,{field:"allLabel",value:u.allLabel,handleEditor:(I,F)=>w("allLabel",Jt(F)),referenceContent:n,referenceLocale:i,variables:l,editorConfig:B}),jsx(Jo,{field:"placeholder",value:u.placeholder,handleEditor:(I,F)=>w("placeholder",Jt(F)),referenceContent:n,referenceLocale:i,variables:l,editorConfig:P}),jsx(Select,{clearable:true,data:b,description:"(Optional) Select a property key to use as item's icon background color. Requires defining an icon key.",disabled:u.isPrimitiveType,label:jsx(Wt,{label:"Color property key"}),onChange:I=>w("colorKey",I,true),value:tl(b)&&u.colorKey}),jsx(Select,{clearable:true,data:b,description:"(Optional) Select a property key to use as item's icon src.",disabled:u.isPrimitiveType,label:jsx(Wt,{label:"Icon property key"}),onChange:I=>w("iconKey",I,true),value:tl(b)&&u.iconKey}),jsx(Select,{clearable:true,data:b,description:"(Optional) Select a property key to extend the search functionality. The selected key MUST only contain text elements.",disabled:u.isPrimitiveType,label:jsx(Wt,{label:"Search index key"}),onChange:I=>w("searchIndexKey",I,true),value:tl(b)&&u.searchIndexKey}),jsx(TextInput,{description:'(Optional) Provide a search index separator in case each row contains more than one record. Default: "|".',disabled:!u.searchIndexKey,error:u.searchIndexSeparator===""?"Separator cannot be empty!":"",label:jsx(Wt,{label:"Search index separator"}),onChange:I=>w("searchIndexSeparator",I.currentTarget.value),value:u.searchIndexSeparator})]})})]})})]}),jsx(Checkbox,{my:"md",label:jsx(Wt,{label:"Reset SectionVariables on change",py:0}),checked:u.resetSectionVars==="true",onChange:I=>w("resetSectionVars",I.currentTarget.checked?"true":"false")}),t]})}var e3={[E.SELECTOR]:mI,[E.NAV]:Db,[E.RELATED]:_b,[E.RESET_BUTTON]:zb,[E.COMPARISON_BUTTON]:Vb,[E.TITLE]:Fb,[E.STAT]:$b,[E.TABLE]:Kb,[E.MULTIHIERARCHY_SELECTOR]:Xb},MI=e3;function t3(e){let{blockType:t,id:o,locale:r,setBlockContent:n,simpleState:i}=e,a=sn(),l=ot(o),s=MI[t],c=jsx(lI,{fields:rr[t],locale:r,defaultContent:i,variables:l,onChange:n},"text-editor");return s?jsx(s,{id:o,executeButton:a.executeButton,onChange:(u,d,f=true)=>n({simple:u,logic:d},r,true,f),simpleState:i,richTextEditor:c,variables:l,referenceContent:a.reference.content,referenceLocale:a.reference.locale}):c}var DI=t3;p();ys();he();se();ye();Pt();Nf();function p3({id:e,variables:t,reserved:o,hasInternalKeys:r}){let[n,i]=useState(false);return jsxs(Fragment,{children:[r&&jsx(Switch,{label:"Show internal variables",size:"xs",checked:n,onChange:a=>i(a.currentTarget.checked)}),jsx(Ar,{id:e,variables:t,reserved:o,showInternal:n})]})}function d3({id:e,setInlineId:t}){let o=H(c=>c.records.entities.block),r=ie(),n=FS(e),i=Object.keys(n.attributes),a=useContext(De),l=At(a),s=c=>{r(Z.updateEntity("block",{id:e,inputAction:{operation:"delete",input:{input_id:c,block_id:e}}})).then(()=>{l();});};return jsx("div",{style:{display:"flex",flex:"1 1 auto",flexDirection:"column",width:"100%"},children:Object.keys(n).sort(c=>c==="attributes"?-1:1).map(c=>{let u=o[c],d=u&&[E.GENERATOR,E.SECTION_FLAG].includes(u.type),f=u?.type&&u?.id?`${u.type}${u.id}`:"",g=Object.keys(n[c]).some(np(f));return jsxs(Stack,{className:"cr-variable-group",style:{position:"relative"},children:[jsx(Divider,{}),jsxs(Group,{position:"apart",noWrap:true,grow:true,children:[jsx(Title,{order:6,children:u?`${titleCase(u.type)} ${u.id} Variables`:"Dimension Variables"}),u&&jsxs(Group,{position:"right",noWrap:true,children:[d&&jsx(Tooltip,{label:"Edit this generator",children:jsx(ActionIcon,{size:"xs",onClick:()=>t(c),variant:"subtle",color:"gray",children:jsx(IconPencil,{size:15})})}),jsx(Tooltip,{label:"Remove as input",children:jsx(ActionIcon,{size:"xs",onClick:()=>s(c),variant:"light",color:"red",children:jsx(IconLinkOff,{size:15})})})]})]}),jsx(p3,{id:c,variables:n[c],reserved:i,hasInternalKeys:g})]},c)})})}var FI=d3;ic();Cr();ye();function I3({blockType:e,fullscreen:t,toggle:o,codeEditor:r}){let n=sn(),i=[E.GENERATOR,E.VIZ].includes(e),[a,{open:l,close:s}]=useDisclosure(false);return jsxs(Fragment,{children:[jsxs(Popover,{width:400,position:"bottom",withArrow:true,shadow:"md",opened:a,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{variant:"subtle",color:"blue",size:"sm",onMouseEnter:l,onMouseLeave:s,pos:"absolute",top:3,left:3,style:{zIndex:1},children:jsx(IconHelp,{size:16})})}),jsx(Popover.Dropdown,{children:jsxs(Text,{size:"sm",children:["You can access ",jsx(Code,{children:"variables"}),", ",jsx(Code,{children:"formatters"}),",",jsx(Code,{children:"locale"}),", ",jsx(Code,{children:"libs"}),",",e===E.GENERATOR&&jsxs(Fragment,{children:[jsx(Code,{children:"resp"}),", "]}),e===E.VIZ&&jsxs(Fragment,{children:[jsx(Code,{children:"section"}),", "]}),"and ",jsx(Code,{children:"router"})," in the scope of this generator.",i&&jsxs(Fragment,{children:[" Return a property called",jsx(Code,{children:"_api"})," as string, to let the user download that data and override api value."]})]})})]}),r,jsx(Divider,{my:"sm",color:"gray.8"}),jsxs(Group,{px:"xs",h:"fit-content",position:"right",children:[jsx(Button,{variant:"light",color:"grey",size:"xs",onClick:o,leftIcon:t?jsx(IconMinimize,{size:rem(12)}):jsx(IconMaximize,{size:rem(12)}),compact:true,children:t?"Minimize":"Maximize"}),n.executeButton]})]})}function A3(){let e=sn(),t=ts(),o=os(),r=t!==o;return jsx(Group,{position:"right",my:"xs",children:jsxs(Stack,{align:"flex-end",spacing:"xs",children:[jsx(Switch,{label:e.mode==="simple"?"Code":"No Code",size:"xs",labelPosition:"left",checked:e.mode==="code",onChange:n=>e.changeEditorMode(n.currentTarget.checked?"code":"simple"),onLabel:jsx(IconCode,{size:rem(12)}),offLabel:jsx(IconCode,{size:rem(12)})}),e.mode!=="code"&&r&&jsx(Switch,{checked:e.reference.active,onChange:n=>e.reference.setActive(n.currentTarget.checked),size:"xs",label:"See reference language",labelPosition:"left",onLabel:jsx(IconLanguage,{size:"0.7rem"}),offLabel:jsx(IconLanguage,{size:"0.7rem"})})]})})}function P3({header:e,blockContent:t,blockSettings:o,blockType:r,id:n,locale:i,onSave:a,setBlockContent:l,setBlockSettings:s,setInlineId:c,sid:u}){let[d,f]=useState("Content"),[g,m]=useState(false),[h,y]=useState(false),S=ju(n),v=sn(),b=H(W=>W.status.isRunConsumersRunning).includes(u),k=useMemo(()=>{let W={resp:null,apiFinalUrls:null,apiDataSources:void 0};return S&&S.resp&&S.apiFinalUrls&&S.apiDataSources&&(W.resp=S.resp,W.apiFinalUrls=S.apiFinalUrls,W.apiDataSources=S.apiDataSources),W},[S]),w=ot(n),{ref:R,toggle:O,fullscreen:A}=useFullscreen(),B=t&&(t.api||t.api==="")?t.api.split("|||"):[],_=(W,U)=>l({logic:W},U),P=(W,U)=>{let Y=[...B];Y[U]=W,l({api:Y.join("|||")},void 0,void 0,void 0,true);},I=()=>{l({api:[...B,""].join("|||")}),m(true);},F=W=>{l({api:B.length===1&&B[0]===""?null:B.filter((U,Y)=>Y!==W).join("|||")},void 0,void 0,void 0,true);},M=(W,U)=>{s({[W]:U});},N=()=>{m(!g);},j=()=>{y(!h);},$=jsx(ca,{monacoOptions:{onChange:W=>_(W,i),value:t?.logic||"",height:A?"85vh":"61vh",width:"100%"}},"code-editor"),V=t?.simple||{},z=jsx(DI,{blockType:r,id:n,locale:i,simpleState:V,setBlockContent:l,variables:w}),q=jsx(Col,{span:4,sx:W=>({display:"flex",flexDirection:"column",borderLeft:`2px solid ${W.colors.gray[0]}`}),children:jsxs(Stack,{children:[jsx(Text,{inline:true,size:"xs",transform:"uppercase",weight:"bold",color:"gray",children:"Preview"}),jsx(Jp,{id:n,active:true,blockStateContent:t,blockStateSettings:o,locale:i,allowed:true,debug:true},"block-preview")]})});return jsxs(Grid,{h:"100%",children:[jsxs(Col,{span:3,sx:{alignSelf:"stretch",display:"flex",flexDirection:"column",height:"100%",position:"relative"},children:[E.SECTION_FLAG!==r&&jsx(Uw,{id:n}),jsx("div",{style:{width:"100%",maxHeight:"80vh",overflowY:"auto"},children:jsx(FI,{id:n,setInlineId:c})})]}),jsxs(Col,{span:9,sx:W=>({alignSelf:"stretch",display:"flex",flexDirection:"column",height:"100%",borderLeft:`2px solid ${W.colors.gray[0]}`}),children:[e,jsxs(Tabs,{value:d,onTabChange:f,keepMounted:false,styles:{root:{flexGrow:1,display:"flex",flexDirection:"column"},panel:{flexGrow:1}},children:[jsxs(Tabs.List,{position:"left",children:[jsx(Tabs.Tab,{value:"Content",icon:jsx(IconPencil,{}),children:"Edit"}),jsx(Tabs.Tab,{value:"Style",icon:jsx(IconPalette,{}),children:"Style"}),jsx(Tabs.Tab,{value:"Settings",icon:jsx(IconSettings,{}),children:"Settings"})]}),jsx(Tabs.Panel,{value:"Content",children:jsx(Box,{ref:R,pos:"relative",bg:"white",h:"100%",children:jsxs(Grid,{className:"cr-block-output",style:{flex:1,width:"100%",height:A?"100vh":"100%",margin:0},children:[jsxs(Col,{span:8,className:`cr-block-output-editor ${v.mode}`,children:[![E.VIZ,E.GENERATOR,E.SECTION_FLAG].includes(r)&&jsx(A3,{}),[E.GENERATOR,E.SECTION_FLAG].includes(r)&&jsxs(Stack,{mb:5,spacing:4,children:[b&&jsx(Overlay,{children:jsx(Text,{children:"Running..."})}),jsxs(Group,{spacing:"xs",children:[jsx(Button,{size:"sm",variant:"light",color:"blue",leftIcon:g?jsx(IconChevronDown,{size:16}):jsx(IconChevronRight,{size:16}),onClick:N,sx:{flex:1},children:`${B.length} API Request${B.length!==1?"s":""}`}),jsx(Button,{size:"sm",onClick:I,variant:"light",color:"blue",leftIcon:jsx(IconPlus,{size:15}),children:"Add API"})]}),jsxs(Collapse,{in:g,children:[B.map((W,U)=>jsx(TT,{defaultValue:W,pos:U+1,id:n,finalUrl:k.apiFinalUrls&&k.apiFinalUrls[U]?k.apiFinalUrls[U]:null,dataSource:k.apiDataSources&&k.apiDataSources[U]?k.apiDataSources[U]:null,onChangeAPI:Y=>P(Y,U),onDelete:()=>F(U)},`${n}-${U}-${B.length}`)),k.resp&&jsx(Button,{variant:"light",color:"blue",size:"xs",leftIcon:h?jsx(IconChevronDown,{size:14}):jsx(IconChevronRight,{size:14}),onClick:j,mt:5,children:"Response data preview (resp)"}),k.resp&&jsx(Collapse,{in:h,children:jsx("div",{style:{maxHeight:200,overflowY:"scroll"},children:jsx(aa,{value:k.resp,root:true,label:"resp"})})})]})]}),jsxs(Box,{bg:v.mode==="code"?"#272822":"none",p:"xs",pos:"relative",children:[v.mode==="code"&&jsx(I3,{blockType:r,fullscreen:A,toggle:O,codeEditor:$}),v.mode!=="code"&&z]})]},"content-col"),q]})})}),jsx(Tabs.Panel,{value:"Style",pt:"xs",children:jsx(Box,{ref:R,pos:"relative",bg:"white",h:"100%",children:jsxs(Grid,{children:[jsxs(Col,{span:8,children:[jsx(Title,{order:4,children:"Style settings"}),jsx(pp,{id:n,display:"inline",handleChange:M})]},"content-col"),q]})})}),jsx(Tabs.Panel,{value:"Settings",pt:"xs",children:jsx($w,{id:n,setBlockSettings:s})})]})]})]})}var jI=P3;Ho();he();Pt();ye();p();var KI=e=>(!e||!e.contentByLocale||Object.keys(e.contentByLocale).forEach(t=>{let o=e.contentByLocale[t]?.content;o&&Object.keys(o).length===0&&(o.simpleEnabled=true,o.simple={});}),e);var ly=["_icon","_iconType","_iconVariant","_iconSize","_iconRadius","_iconPadding"],qI={[E.SELECTOR]:["hideLabel","resetSectionVars","component","optionsType","type"],[E.TITLE]:[...ly],[E.NAV]:[...ly],[E.STAT]:[...ly],[E.TABLE]:["data","tableProps","variable"],[E.MULTIHIERARCHY_SELECTOR]:["colorKey","dataVar","defaultVar","hideLabel","resetSectionVars","iconKey","levelsVar","limit","searchIndexKey","searchIndexSeparator"]},$3=(e,t)=>({...e,[t.locale]:{...t,content:t.content}});function U3({block:e,localeDerived:t}){let o=sn(),r=Ko(e.section_id).data,n=zt(r.report_id).data,i=r?.settings.name||`Section ${r?.id}`,a=`${e.type} ${e.id}`,l=n?.name||`Report ${n.id}`;return jsxs(Group,{w:"100%",children:[jsx(Alert,{color:"gray",sx:{flexGrow:1},py:"0.325rem",children:jsxs(Group,{position:"apart",children:[jsxs(Breadcrumbs,{separator:">",children:[jsx(Text,{size:"xs",children:l}),jsx(Text,{size:"xs",children:i}),jsx(Text,{size:"xs",children:a})]}),jsx(Badge,{size:"sm",radius:"sm",rightSection:jsx(Center,{children:t==="logic"?jsx(IconCode,{size:"0.6rem"}):jsx(IconLanguage,{size:"0.6rem"})}),children:t})]})}),jsxs(Group,{children:[o.cancelButton,o.closeAndSaveButton]})]})}function G3({id:e,modified:t,callbacks:o,inline:r}){let n=ie(),i=useContext(De),a=At(i),{setOpened:l,setModified:s,maybeCloseWithoutSaving:c,setInlineId:u}=o,d=tt(e).data,f=H(N=>N.status.currentLocale),g=H(N=>N.status.localeDefault),m=H(N=>N.status.locales),h=Tr(d,f).locale,[y,S]=useState(),[v,C]=useState(false),[b,k]=useState(true);if(useEffect(()=>{S(KI(od(d))),C(true);},[]),!d||!v||!y)return null;let w=ko(y,f),R=y.settings,O=(N={},j=g,$=true,V=void 0,z=false)=>{let{locale:q}=Tr(d,j);if($&&!t&&s(true),V!==void 0&&b!==V&&k(V),!N||Object.keys(N).length<1)return;let W=y.contentByLocale[q]||{id:e,locale:q,content:{}},U={...y,contentByLocale:{...y.contentByLocale,[q]:{...W,content:{...W.content,...N}}}};if(S(U),z){let Y=B(U);n(Z.updateEntity("block",Y)).then(()=>{a(),s(false);});}},A=(N,j)=>{if(h!=="logic"&&Object.keys(qI).includes(d.type)){let $={...N},V=N[j].content;return m.forEach(z=>{if(z===h)return;let W={...N[z].content.simple};Object.keys(V.simple).map(Y=>{qI[d.type].includes(Y)&&(W[Y]=V.simple[Y]);});let U={...W};if(d.type===E.SELECTOR){let{selectorType:Y=Oa.SINGLE,options:ne={static:[]},optionsType:re=vi.STATIC}=N[z].content.simple,{logicOptions:J,defaultValue:G}=wd(Y,ne,re);G&&(U.defaultValue=G),U.options=J;}if(d.type===E.MULTIHIERARCHY_SELECTOR){let Y=N[z].content.simple,{logicLevels:ne,logicOptions:re,defaultValue:J,defaultValueType:G}=_d(Y);J&&G&&(U.defaultValue=J,U.defaultValueType=G),U.data=re,U.levels=ne;}$[z].content={...$[z].content,simple:W,logic:on(U,false)};}),$}return N},B=(N=null)=>{let j=N||y,{settings:$}=j,V=Object.values(j.contentByLocale).reduce($3,{}),z=["id","api","shared","type"].reduce((W,U)=>({...W,[U]:j[U]}),{}),q=A(V,f);return {...z,id:j.id,contentByLocale:q,settings:$}},_=async N=>{let j=B();n(Z.updateEntity("block",j)).then(()=>{a(),s(false),N||(r?u(null):l(false));});},P=N=>{t||s(true),N.type||N.shared!==void 0?S({...y,...N}):S({...y,settings:{...y.settings,...N}});};return jsx(Fragment,{children:jsx(nI,{buttons:{cancelButton:jsx(Button,{leftIcon:jsx(IconCircleX,{size:"0.8rem"}),size:"xs",variant:"outline",onClick:c,color:"red",children:"Cancel"},"cancel"),closeAndSaveButton:jsx(Button,{leftIcon:jsx(IconDeviceFloppy,{size:"0.8rem"}),size:"xs",disabled:!b,onClick:()=>_(false),children:`Save & ${r?"Return":"Close"}`},"save"),executeButton:jsx(Button,{disabled:!b,onClick:()=>_(true),size:"xs",compact:true,children:"Save & Execute"})},blockType:d.type,blockId:d.id,children:jsx(jI,{header:jsx(U3,{localeDerived:h,block:d}),blockContent:w,blockSettings:R,blockType:d.type,id:e,sid:d.section_id,locale:f,onSave:_,setBlockContent:O,setBlockSettings:P,setInlineId:u},"be")})})}var YI=G3;Pt();se();ye();ye();Vp();he();Go();function nY({id:e,setHoverBlock:t,isInput:o,isConsumer:r,active:n,showOutline:i=true}){let[a,l]=useState(false),{newConfirmation:s}=Kt(),[c,u]=useState(false),[d,f]=useState(false),[g,m]=useState(null),h=useContext(De),y=At(h),S=useMantineTheme(),v=ot(e),C=ju(e),b=useCallback(()=>{u(false),f(false),m(null);},[]),k=useDispatch(),w=H(U=>U.status.currentLocale),{data:R}=tt(e),O=H(U=>U.records.entities.block),{isFetching:A}=jl("block",e),{allowed:B,allowedMessage:_}=useMemo(()=>{let U=!C?.hiddenByCascade,Y="";return R&&(Y=C?.hiddenByCascade===e?`Hidden by ${R.settings.allowed}: ${R.settings.allowed?v[R.settings.allowed]:null}`:`Hidden by ${C?.hiddenByCascade}`),{allowed:U,allowedMessage:Y}},[v,C,R,e]);if(!R)return null;let{blockcol:P,type:I,section_id:F,contentByLocale:M,settings:N,inputs:j}=R,$=async()=>{if(d)try{await s({title:"Are you sure?",message:"Close editor without saving?",confirmText:"Yes, abandon changes."}),b();}catch{}else b();},V={centered:true,withCloseButton:false,opened:c,onClose:$,overflow:"inside",padding:S.spacing.sm,size:"95%",styles:{body:{height:"100%"}}},z={onMouseEnter:()=>t(e),onMouseLeave:()=>t(false)},q={setOpened:u,setModified:f,setInlineId:m,maybeCloseWithoutSaving:$},W=()=>{let U=Object.keys(O).filter(re=>O[re].section_id===R.section_id&&O[re].blockcol===R.blockcol).map(re=>O[re].blockrow),Y=Va(U),ne={create:{blockrow:wl(Y),blockcol:P,locales:Object.keys(M).map(re=>re),section_id:F,type:I},update:{contentByLocale:M,settings:N,inputs:j.map(re=>O[re])}};k(Z.cloneEntity("block",ne)).then(()=>{[E.GENERATOR,E.SECTION_FLAG].includes(R.type)&&y({sid:F});});};return jsxs(Fragment,{children:[jsxs(Group,{id:`block-${e}`,onMouseOver:()=>l(true),onMouseOut:()=>l(false),className:"cr-section-block",pos:"relative",py:mi.block.padding,...z,sx:U=>({border:"1px solid transparent",resize:"horizontal","&:hover":{border:i?`1px solid ${U.colors.blue[2]}`:"1px solid transparent"},...i?{"&:hover::before":{position:"absolute",top:0,left:0,fontSize:8,color:U.colors.blue[5],transform:"translateY(-100%)",content:`"Block ${e}"`,width:"fit-content"}}:{}}),children:[jsx(Jp,{style:{color:"red"},id:e,debug:[E.VIZ,E.GENERATOR,E.SECTION_FLAG].includes(R.type),active:n,locale:w,allowed:B,isFetching:A},"bp"),(a||o||r)&&jsxs(Group,{spacing:0,className:"cr-block-controls export-hidden",style:{position:"absolute",right:px(S.spacing.xs)/2,top:px(S.spacing.xs)/2,backgroundColor:S.colors.gray[2],borderRadius:S.radius.sm,zIndex:5},children:[o||r?jsx(ActionIcon,{children:o?jsx(IconLogout,{size:20,color:S.colors.red[5]}):jsx(IconLogin,{size:20,color:S.colors.green[5]})},"globe"):null,R.shared&&jsx(Tooltip,{withArrow:true,label:"Sharing: Enabled",children:jsx(ActionIcon,{variant:"transparent",children:jsx(IconWorld,{size:20})},"globe")},"tt"),"access"in R.settings&&!["public","guest"].some(U=>!R.settings.access||R.settings.access.includes(U))&&jsx(Tooltip,{withArrow:true,label:"Private Block",children:jsx(ActionIcon,{variant:"transparent",children:jsx(IconLock,{size:20})},"lock")},"tt"),!B&&jsx(Tooltip,{withArrow:true,label:_,children:jsx(ActionIcon,{variant:"transparent",children:jsx(IconEyeOff,{size:20})})},"allowed"),![E.GENERATOR,E.SECTION_FLAG].includes(R.type)&&jsx(pp,{id:e,display:"button"},"design"),jsx(ActionIcon,{onClick:()=>u(true),children:jsx(IconPencil,{size:20})},"edit"),![E.SECTION_FLAG].includes(R.type)&&jsx(ActionIcon,{onClick:W,children:jsx(IconCopy,{size:20})},"copy"),jsx(sT,{type:gn.BLOCK,id:e},"cog")]},"bc")]},"block"),jsx(Modal,{fullScreen:true,...V,children:jsx(YI,{callbacks:q,id:g||e,inline:g,modified:d},g||e)},"d")]})}var rl=nY;Go();Vp();se();Ho();p();p();ye();se();Go();st();ye();var ZI=({id:e,disabled:t=false})=>{let{sectionVariables:o,resetSectionVariables:r}=pt(e);return !Object.keys(o).length?null:jsx(ActionIcon,{disabled:t,onClick:r,variant:"filled",size:"xs",children:jsx(IconRefresh,{size:20})})},pY=({sectionId:e,onActivate:t})=>{let{activeEntity:o}=qt(),{handlers:r}=Ft("settings");return o.type==="section"&&o.id===e?jsx(Button,{size:"xs",radius:"xl",leftIcon:jsx(IconPencil,{size:14}),fw:400,onClick:r.open,compact:true,children:"Edit"}):jsx(ActionIcon,{variant:"transparent",onClick:()=>{t(),r.open();},children:jsx(IconPencil,{size:18})})};function dY({sectionId:e,onActivate:t,position:o}){let r=useDispatch(),n=Ko(e),i=H(f=>f.records.entities.section),{data:a}=n,l=Xt(),s=Number.parseInt(l.params[0]),c=zt(s),u=H(f=>f.records.entities.block);if(!a||!c.data?.sections)return null;let{sections:d}=c.data;return jsxs(Group,{spacing:2,children:[jsx(pY,{sectionId:e,onActivate:t}),jsx(ActionIcon,{variant:"transparent",onClick:()=>{let f={...a,ordering:fn(i,d,o+1,true)},g=mY(f,u);r(Z.cloneEntity("section",g));},children:jsx(IconCopy,{size:18})}),jsx(ir,{type:"section",id:e})]})}function mY(e,t){let{heading:o,report_id:r,ordering:n,settings:i}=e,a=[];return {create:{ordering:n,report_id:r},update:{settings:i,heading:o,report_id:r,blocks:e?.blocks.map(s=>{let c=t[s],{blockcol:u,blockrow:d,contentByLocale:f,type:g,settings:m,section_id:h,shared:y,inputs:S,consumers:v}=c;return {blockcol:u,blockrow:d,contentByLocale:f,id:s,type:g,settings:m,section_id:h,shared:y,inputs:S.map(C=>{let b=t[C],{id:k,section_id:w,blockcol:R,blockrow:O,contentByLocale:A,settings:B,shared:_,type:P}=b;return {id:k,section_id:w,blockcol:R,blockrow:O,contentByLocale:A,settings:B,shared:_,type:P}}),consumers:v.reduce((C,b)=>{let k=t[b];if(k){let{id:w,section_id:R,blockcol:O,blockrow:A,contentByLocale:B,settings:_,shared:P,type:I}=k;return [...C,{id:w,section_id:R,blockcol:O,blockrow:A,contentByLocale:B,settings:_,shared:P,type:I}]}return C},a)}})}}}var e0=dY;se();he();Ho();Zg();Hr();function r0({active:e,isDragging:t,id:o,dragHandleProps:r,hidden:n="",onActivate:i,sectionSettings:a,position:l}){let s=H(f=>f.records.entities.section[o]||null);if(!s)return null;let c=useMemo(()=>s&&s.settings?.name?.length?s.settings.name:`section-${s.id}`,[s.settings?.name,s.id]),u=useMemo(()=>xt(c),[c]),d=n!=="";return jsxs(Group,{className:`cms-section-header${e||t?" active":""}`,position:"apart",bg:d?"red.1":"gray.3",sx:{overflow:"hidden",borderRadius:4},children:[jsx(Group,{className:"cms-section-header-editor",spacing:0,children:jsxs(Group,{spacing:0,children:[jsx(ActionIcon,{variant:"transparent",...r,w:16,sx:{cursor:"grab"},children:jsx(IconGripHorizontal,{size:16})},"b1"),jsxs(Text,{size:"xs",fw:400,color:"dark.9",children:[c,u!==c&&jsxs(Text,{span:true,size:"xs",c:"dimmed",children:[" #",u]}),d&&` ${n}`]})]})}),jsxs(Group,{children:[jsxs(Flex,{justify:"flex-end",mx:16,align:"center",gap:"xs",children:[jsx(ZI,{id:s.id,disabled:!e}),a.optionsMenu&&jsx(Qg,{sectionId:s.id,disabled:!e})]}),jsx(e0,{sectionId:o,onActivate:i,position:l})]})]})}$g();he();ic();oh();Bs();ye();Sn();Jn();Cr();Hr();var OY=Object.values(E),u0=({columns:e,columnIndex:t,section:o})=>{let r=ie(),{settings:n}=Kl(o.report_id),[i,a]=useDisclosure(false),l=(c,u=false)=>{let d="!",f="!";typeof u=="string"?(f=u,d=Va(Object.keys(e[u]),true)):Object.keys(e).length>0&&(f=Va(Object.keys(e),true));let{locales:g}=Tr({type:c});r(Z.createEntity("block",{blockrow:d,blockcol:f,type:c,section_id:o.id,locales:g})).then(m=>{c===E.VIZ&&r(Z.updateEntity("block",{id:m.data.id,contentByLocale:{logic:{...m.data.contentByLocale.logic,content:{simpleEnabled:true,simple:{},logic:rS}}}}));});},s=OY.filter(c=>![E.GENERATOR,E.SECTION_FLAG,E.FALLBACK].includes(c)&&(n.comparison?true:c!==E.COMPARISON_BUTTON)).map(c=>{let u=Oc(c);return {label:jsx(UnstyledButton,{p:"xs",w:"100%",onClick:()=>{l(c,t),a.close();},sx:{":hover":{backgroundColor:"#EBEBEB"}},children:jsxs(Group,{spacing:"xs",children:[jsx(ThemeIcon,{color:"blue",variant:"filled",size:"sm",radius:"xl",children:jsx(u,{size:"0.8rem"})}),jsx(Text,{size:"xs",children:Lc(c)||c})]})}),value:c}});return jsx(Center,{w:"100%",py:"sm",children:jsxs(Popover,{position:"right",withinPortal:true,zIndex:100,opened:i,onClose:a.close,children:[jsx(Popover.Target,{children:jsx(ActionIcon,{size:"lg",radius:"xl",variant:"light",bg:"#E5E5E5 !important",onClick:a.toggle,children:jsx(IconPlus,{size:24,color:"white",strokeWidth:1})})}),jsxs(Popover.Dropdown,{p:0,children:[jsx(Text,{bg:"#E5E5E5",size:"xs",p:"xs",children:"Add Block"}),jsx(ScrollArea,{h:230,children:jsx(List,{listStyleType:"none",styles:{itemWrapper:{width:"100%"}},children:s.map(({label:c,value:u})=>jsx(List.Item,{w:"100%",children:c},u))})})]})]})})},LY=({columns:e,section:t,show:o=false})=>o?jsx(Center,{w:"100%",children:jsxs("div",{children:[jsx(Text,{ta:"center",fw:700,size:"sm",color:"gray.8",children:"Add your first block!"}),jsx(u0,{columnIndex:false,columns:e,section:t})]})}):null,MY=({active:e=false})=>jsx(Droppable,{droppableId:"newColumn",children:(t,o)=>jsx(Center,{ref:t.innerRef,pos:"absolute",top:16,right:e?0:-140,bottom:16,w:140,sx:r=>({boxSizing:"border-box",zIndex:99,transition:"right 0.4s",overflow:"hidden",background:o.isDraggingOver?r.colors[r.primaryColor][0]:r.colors.gray[0]}),...t.droppableProps,children:jsxs(Stack,{p:"md",align:"center",children:[jsx(Text,{size:"xs",ta:"center",children:"Drop here to add new column"}),jsx(IconPlus,{})]})})}),BY=({onActivate:e,section:t,show:o=false})=>{let n=H(i=>i.status.isRunConsumersRunning).includes(t.id);return !o&&!n?null:jsxs(Overlay,{className:"cms-section-overlay",onClick:()=>e(t.id),opacity:.6,color:"#E9ECEF",style:{cursor:"pointer",zIndex:3},sx:i=>({transition:"background-color .45s",".bespoke-Section-edit":{opacity:0,transition:"opacity .45s"},"&:hover":{backgroundColor:i.fn.rgba("#E9ECEF",.9),".bespoke-Section-edit":{opacity:1}}}),center:true,children:[!n&&jsxs(Group,{className:"bespoke-Section-edit",align:"center",spacing:"xs",children:[jsx(Text,{fw:700,children:"Click to Edit"}),jsx(IconPencil,{size:"1rem"})]}),n&&jsxs(Stack,{align:"center",spacing:"xs",children:[jsx(Text,{fw:700,children:"Loading dependencies"}),jsx(Loader,{size:"md"})]})]})};function DY({for:e,isDragging:t,onActivate:o,dragHandleProps:r,position:n}){let i=ie(),{activeEntity:a}=qt(),[l,s]=useState(false),[c,u]=useState(),d=useRef(null),f=H(M=>M.records.entities.block),g=H(M=>M.status.previews),m=jl("section",e.id),{memberImageBg:h,hidden:y,columnSettings:S={}}=e.settings,v=a.type==="section"&&a.id===e.id,{inputs:C,consumers:b}=useMemo(()=>{if(c){let M=f[c],{inputs:N,consumers:j}=M;return {inputs:N,consumers:j}}return {inputs:[],consumers:[]}},[c]),k=Object.values(f||{}).filter(M=>M.section_id===e.id&&![E.GENERATOR,E.SECTION_FLAG].includes(M.type)).reduce((M,N)=>(M[N.blockcol]?M[N.blockcol][N.blockrow]=N:M[N.blockcol]={[N.blockrow]:N},M),{}),w=useMantineTheme(),R=()=>s(true),O=M=>{if(s(false),!M.destination)return;let{source:N,destination:j}=M;if(N.droppableId===j.droppableId&&N.index===j.index)return;let $=j.droppableId==="newColumn",V=Number(M.draggableId),z=N.droppableId,q=$?Va(Object.keys(k),true):j.droppableId,W={id:V,blockrow:"!",blockcol:"!"},U=z!==q;W.blockcol=U?q:z;let Y=Object.values(k[W.blockcol]||{}),ne=Y.reduce((G,K)=>({...G,[K.id]:K}),{}),re=Y.sort((G,K)=>po(G,K,"blockrow")).map(G=>G.id),J=j.index>N.index;W.blockrow=fn(ne,re,j.index,U,J,"blockrow"),i(Z.updateEntity("block",W));},A=useMemo(()=>{let M=Object.values(f||{}).filter(N=>N.section_id===e.id&&mo(N));return M.length>1&&console.error(`Error, there are more than one Section Flag Generator in section ${e.id}`),M.length>0?M[0]:false},[f,v,e.id]),B=H(M=>A&&M.variables.variables[A.id]&&!M.variables.variables[A.id][Eo]||false),_=useMemo(()=>{let M="";return B&&A&&(M+=`(Not allowed by Section Flag #${A.id})`),y&&(M+="(Hidden by Section Settings)"),M},[y,B]),P=Object.keys(k).sort((M,N)=>-Rl(M,N)),I=Object.keys(k).length,F=useMemo(()=>e?.settings?.name?xt(e?.settings?.name):`section-${e.id}`,[e.id,e?.settings?.name]);return m.isFetching?jsxs(Box,{p:"lg",m:"lg",bg:mi.section.backgroundColor,sx:M=>({borderRadius:M.radius.md,border:`1px solid ${M.colors.gray[4]}`}),children:[jsx(Skeleton,{height:50,circle:true,mb:"xl"}),jsx(Skeleton,{height:8,radius:"xl"}),jsx(Skeleton,{height:8,mt:6,radius:"xl"}),jsx(Skeleton,{height:8,mt:6,width:"70%",radius:"xl"})]}):jsxs(Box,{px:"md",mt:"md",children:[jsx(r0,{active:v,id:e.id,isDragging:t,hidden:_,dragHandleProps:r,onActivate:()=>o(e.id),sectionSettings:e.settings,position:n}),jsxs(Box,{pos:"relative",sx:M=>({border:v?`1px solid ${M.colors.blue[4]}`:"none",borderRadius:2}),children:[jsx(Paper,{id:F,className:`cms-section${t||v?" active":""}`,bg:e.settings.style==="card"?mi.section.backgroundColor:"transparent",p:0,mih:100,maw:e.settings.width==="center"?w.breakpoints.xl:"none",w:"100%",mx:"auto",pos:"relative",shadow:e.settings.style==="card"?mi.section.boxShadow:"none",radius:mi.section.borderRadius,sx:{overflow:"hidden"},children:jsxs(Box,{pos:"relative",children:[h&&jsx(Vg,{previews:g}),jsx(th,{ref:d,containerProps:{mih:!v||!I?120:"none",p:e.settings.margin||"md",style:{zIndex:2},gap:e.settings.columnGutter||"md",wrap:"wrap"},children:jsxs(DragDropContext,{onDragEnd:O,onDragStart:R,children:[P.map(M=>{let N=Object.values(k[M]).sort((j,$)=>po(j,$,"blockrow"));return jsx(Droppable,{droppableId:M,children:(j,$)=>jsxs(eh,{column:k[M],columnSettings:S[M],ref:j.innerRef,basis:`calc(${100/I}% - (10px * ${I}))`,sx:{background:$.isDraggingOver?w.colors[w.primaryColor][0]:"inherit",border:"1px solid transparent","& .bespoke-resize-col":{visibility:"hidden"},"&:hover .bespoke-resize-col":{visibility:"visible"},"&:hover":{border:`1px solid ${w.colors.teal[1]}`}},...j.droppableProps,children:[jsx(GE,{sectionId:e.id,columnIndex:M}),N.map((V,z)=>{if(!f[V.id])return null;let{settings:q,type:W}=f[V.id],U=q.width&&!q.width.stretch&&q.width.unit?nc[q.width.unit](q.width.value):q.display==="inline"?"auto":"100%",Y={alignSelf:W===E.VIZ?"stretch":"flex-start",flexGrow:0,margin:"0",width:U,minWidth:120};return jsx(Draggable,{draggableId:String(V.id),index:z,children:(ne,re)=>jsx(Box,{ref:ne.innerRef,...ne.draggableProps,...ne.dragHandleProps,sx:[Y,{boxShadow:re.isDragging?w.shadows.lg:"none",...ne.draggableProps.style}],children:jsx(rl,{id:Number(V.id),active:v,isInput:C.includes(Number(V.id)),isConsumer:b.includes(Number(V.id)),setHoverBlock:u},`block-${V.id}`)})},V.id)}),v&&jsx(u0,{section:e,columnIndex:M,columns:k}),j.placeholder]})},M)}),jsx(MY,{active:l&&v})]})}),jsx(LY,{columns:k,section:e,show:v&&!I})]})}),jsx(BY,{onActivate:o,section:e,show:!v})]})]})}var p0=Yt(DY,Ko);Pt();Go();se();Gr();p();p();Go();Go();se();p();he();se();Mh();Sn();Jn();Cr();Hr();function KY(e,t){let o=document.getElementById(t),r=90;if(o){let i=o.getBoundingClientRect().top+e.current.scrollTop-r;e.current.scrollTo({top:i,behavior:"smooth"});}}function qY(e,t,o){let r=document.getElementById(`bespoke-${t}-${o}`),n=60;if(r){let a=r.getBoundingClientRect().top+e.current.scrollTop-n;e.current.scrollTo({top:a,behavior:"smooth"});}}function YY({section:e,onEnd:t}){let[o,r]=useState(e.settings?.name||`section-${e.id}`),n=a=>{[13,27].includes(a.keyCode)&&t(o);},i=useClickOutside(()=>t(o));return useEffect(()=>{setTimeout(()=>{i?.current&&i?.current?.focus();},200);},[i]),jsx(Input,{ref:i,bg:"gray.3",styles:{input:{display:"block",height:"100%",minHeight:"auto",lineHeight:"1rem",padding:0,boxSizing:"border-box"}},mih:"auto",type:"text",variant:"unstyled",value:o,onChange:a=>r(a.target.value),onKeyDown:n})}var XY=forwardRef(function({scrollContainer:t,section:o,isActive:r,...n},i){let a=H(R=>R?.records.entities.block),{settings:l,updateSettings:s}=Rr(o.id),c=useMantineTheme(),[u,d]=useState(false),[f,g]=useState(false),m=H(R=>{let O=o.blocks.map(A=>R.records.entities.block[A]).filter(A=>mo(A));return O.length>0?R.variables.variables[O[0].id]:false}),h=m?c.colors[m[Eo]===false?"red":"green"][3]:"",y=useCallback(R=>{s("name",R),g(false);},[s]),S=useRef(false);useEffect(()=>{d(!!r);},[r]);let v=useMemo(()=>l?.name?xt(l?.name):`section-${o.id}`,[o.id,l?.name]),C=useMemo(()=>l?.name||`section-${o.id}`,[o.id,l?.name]),b=R=>{R.detail===1&&(S.current=false,setTimeout(()=>{S.current||KY(t,v);},200)),R.detail===2&&(S.current=true,g(O=>!O));},k=r?c.colors.blue[5]:"black",w=o?.blocks.map(R=>a[R]).filter(R=>![E.GENERATOR,E.SECTION_FLAG].includes(R.type)).map(R=>{let O=Lh[R.type]||IconDice;return jsx(List.Item,{pl:"lg",sx:{border:"1px solid transparent","&:hover":{border:"1px solid blue",cursor:"default"}},icon:jsx(O,{size:"0.8rem"}),onClick:()=>qY(t,R.type,R.id),children:jsx(Text,{size:"sm",children:`${R.type} ${R.id}`})},R.id)});return jsxs(List.Item,{ref:i,w:"100%",...n,children:[jsxs(Group,{position:"apart",noWrap:true,px:"sm",bg:r?c.colors.gray[2]:"transparent",sx:R=>({cursor:"default",border:`1px solid ${r?R.colors.gray[2]:"transparent"}`,".section-icon":{color:k},":hover":{border:`1px solid ${R.colors.blue[5]}`}}),children:[jsxs(Group,{spacing:"xs",miw:0,onClick:b,noWrap:true,children:[jsx(IconBoxMultiple,{className:"section-icon",size:"0.8rem",style:{flexShrink:0}}),f?jsx(YY,{section:o,onEnd:y}):jsxs(Group,{spacing:4,align:"flex-end",children:[jsxs(Text,{size:"sm",fw:500,color:"gray.5",span:true,children:[o.id," -"]}),jsx(Text,{size:"sm",c:k,maw:220,sx:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},span:true,children:C})]})]}),jsxs(Group,{spacing:"xs",children:[o.settings.hidden&&jsx(IconEyeOff,{size:"0.8rem",color:c.colors.red[3]}),m&&jsx(IconFlag,{size:"0.8rem",color:h,fill:h}),w.length&&jsx(IconChevronDown,{size:"0.8rem",style:{transform:`rotate(${u?-180:0}deg)`,flexShrink:0},onClick:()=>d(R=>!R)})]})]}),u&&w.length?jsx(List,{listStyleType:"none",children:w}):null]})}),f0=XY;function by({activeSection:e,scrollContainer:t}){let o=H(l=>l?.records.entities.section),r=ie(),n=Object.values(o).sort(po),i=n.map(l=>l?.id),a=useCallback(l=>{if(!l.destination||l.source.index===l.destination.index)return;let s=Number.parseInt(l.draggableId,10),c=l.destination.index>l.source.index,u=fn(o,i,l.destination.index,false,c),d=i.slice(),f=d.splice(l.source.index,1);d.splice(l.destination.index,0,...f),r(Z.updateEntity("section",{id:s,ordering:u}));},[r,o,i]);return jsxs(ScrollArea.Autosize,{mah:"80vh",pb:"sm",sx:{borderBottom:"1px solid rgba(0, 0, 0, 0.1)"},children:[jsx(Text,{fw:700,size:"sm",px:"sm",children:jsxs(Center,{inline:true,children:[jsx(IconIndentIncrease,{size:"1rem"}),jsx(Text,{ml:"xs",span:true,children:"Navigation"})]})}),jsx(DragDropContext,{onDragEnd:a,children:jsx(List,{styles:{itemWrapper:{width:"100%"}},mt:"sm",listStyleType:"none",children:jsx(Droppable,{droppableId:"sections",children:l=>jsx("div",{ref:l.innerRef,...l.droppableProps,children:n.map((s,c)=>jsx(Draggable,{draggableId:`${s?.id}`,index:c,children:u=>jsx(f0,{scrollContainer:t,ref:u.innerRef,section:s,isActive:s.id===e,...u.draggableProps,...u.dragHandleProps})},s?.id))})})})})]})}se();ys();p();se();Ho();he();Cr();var u4=e=>t=>Object.values(t.records.entities.block||{}).filter(o=>o.section_id===e&&E.GENERATOR===o.type);function yy({activeSection:e}){let t=H(u4(e)),o=ie(),r=()=>{let{locales:n}=Tr({type:E.GENERATOR});o(Z.createEntity("block",{blockrow:void 0,blockcol:void 0,type:E.GENERATOR,section_id:e,locales:n})).then(i=>{o(Z.updateEntity("block",{id:i.data.id,contentByLocale:{logic:{...i.data.contentByLocale.logic,content:{simpleEnabled:true,simple:{},logic:oS}}}}));});};return jsx(ScrollArea.Autosize,{mah:"80vh",w:"330px",sx:{borderBottom:"1px solid rgba(0, 0, 0, 0.1)"},children:jsxs(Stack,{pos:"relative",w:330,pr:"md",children:[jsxs(Group,{position:"apart",children:[jsx(Text,{fw:700,children:"Generators"}),jsx(ActionIcon,{c:"black",onClick:r,children:jsx(IconPlus,{})})]}),t.length?t.map(n=>jsx("div",{children:jsx(rl,{id:Number(n.id),active:!!e,isInput:false,isConsumer:false,setHoverBlock:()=>{},showOutline:false})},`block-${n.id}`)):jsx(Text,{align:"center",size:"sm",children:"Click '+' to add a generator"})]})})}ye();p();se();function C0({sectionId:e}){let[t,o]=useState(window.innerWidth-40),[r,n]=useState(window.innerHeight-150);useEffect(()=>{let m=()=>{o(window.innerWidth-40),n(window.innerHeight-120);};return window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m);}},[]);let i=Gl(),a=Ji(),[l,s]=useState(`${e}`),c=useMemo(()=>a.isSuccess?a.data.map(h=>({value:`${h.id}`,label:h.settings.name?`${h.settings.name} (${h.id})`:`Section ${h.id}`})):[],[a.isLoading]),u=useMemo(()=>{if(i.isSuccess&&l){let m={id:"root",label:"section",size:40,parentIds:[]},h={id:"wide",label:"report",size:40,parentIds:[]},y=i.data.filter(v=>`${v.section_id}`==`${l}`),S=y.map(v=>v.id);return [m,h,...y.map(v=>{let C=v.consumers.length>0?v.consumers.length*20:40,b=v.inputs.length>0?v.inputs.map(k=>S.includes(k)?`${k}`:`${h.id}`):[`${m.id}`];return {id:`${v.id}`,label:`${v.type}`,size:C>50?50:C,parentIds:[...Array.from(new Set(b))]}})]}else return []},[i.isLoading,l]),d=useRef(null);return useEffect(()=>{let m=Xd.dagStratify()(u),h=40,y=Xd.sugiyama().nodeSize(F=>{let M=F?F.data:null,N=M?M.size:h;return [(F?3.6:.25)*N,3*N]}),{width:S,height:v}=y(m),C=br.select(d.current);C.selectAll("*").remove(),C.attr("viewBox",[0,0,S,v].join(" "));let b=C.append("defs"),k=m.size(),w=br.interpolateRainbow,R=new Map;u.forEach((F,M)=>{R.set(F.id,w(M/k));});let O=br.line().curve(br.curveCatmullRom).x(F=>F.x).y(F=>F.y);C.append("g").selectAll("g").data(m.links()).enter().append("g").append("path").attr("class","curve").attr("d",({points:F})=>O(F)).attr("fill","none").attr("stroke-width",3).attr("stroke",({source:F,target:M})=>{let N=encodeURIComponent(`${F.data.id}--${M.data.id}`),j=b.append("linearGradient").attr("id",N).attr("gradientUnits","userSpaceOnUse").attr("x1",F.x).attr("x2",M.x).attr("y1",F.y).attr("y2",M.y);return j.append("stop").attr("offset","0%").attr("stop-color",R.get(F.data.id)),j.append("stop").attr("offset","100%").attr("stop-color",R.get(M.data.id)),`url(#${N})`}),C.append("g").selectAll("g").data(m.descendants()).enter().append("g").attr("transform",({x:F,y:M})=>`translate(${F}, ${M})`).append("circle").attr("r",F=>F.data.size).attr("fill",F=>R.get(F.data.id));let _=C.append("g").selectAll("g").data(m.links()).enter().append("g"),P=br.symbol().type(br.symbolTriangle).size(h*1.5);_.append("path").attr("class","arrow").attr("d",P).attr("transform",F=>{let{points:M,target:N}=F,[j,$]=M.reverse(),V=$.x-j.x,z=$.y-j.y,q=N.data.size*1/Math.sqrt(V*V+z*z),W=Math.atan2(-z,-V)*180/Math.PI+90;return `translate(${j.x+V*q}, ${j.y+z*q}) rotate(${W})`}).attr("fill",({target:F})=>R.get(F.data.id)).attr("stroke","white");let I=C.append("g").selectAll("g").data(m.descendants()).enter().append("g").attr("transform",({x:F,y:M})=>`translate(${F}, ${M})`);I.append("text").text(F=>F.data.id).attr("font-weight","bold").attr("font-family","sans-serif").attr("text-anchor","middle").attr("font-size","10px").style("transform","translate(0px,10px)").attr("alignment-baseline","middle").attr("fill","black"),I.append("text").text(F=>F.data.label).attr("font-weight","bold").attr("font-family","sans-serif").attr("font-size","15px").style("transform","translate(0px,-5px)").attr("text-anchor","middle").attr("alignment-baseline","middle").attr("fill","black");},[u]),jsxs(Stack,{spacing:0,children:[jsxs(Group,{align:"flex-end",w:"100%",position:"apart",children:[jsx(Select,{label:"Choose a section",placeholder:"Pick one",value:l,onChange:s,data:c,width:"80%"}),jsxs(Group,{grow:true,maw:100,children:[jsx(ActionIcon,{onClick:()=>{let m=c.findIndex(h=>h.value===l);m>0&&s(c[m-1].value);},variant:"outline",children:jsx(IconChevronLeft,{size:"1.125rem"})}),jsx(ActionIcon,{onClick:()=>{let m=c.findIndex(h=>h.value===l);m<c.length-1&&s(c[m+1].value);},variant:"outline",children:jsx(IconChevronRight,{size:"1.125rem"})})]})]}),jsx("svg",{ref:d,width:t,height:r})]})}function k0({name:e,id:t,variables:o}){return jsxs(Flex,{gap:"xs",children:[jsx(ThemeIcon,{bg:"blue.5",color:"white",size:"sm",radius:"xl",sx:{flexGrow:0},children:jsx(IconCodeDots,{size:"0.8rem"})}),jsxs(Stack,{sx:{flexGrow:1},children:[jsx(Text,{size:"sm",children:e}),jsx(Ar,{id:t,variables:o})]})]})}function A4({sectionId:e}){let[t,o]=useDisclosure(false);return jsxs(Fragment,{children:[jsx(Button,{onClick:o.open,variant:"outline",radius:2,leftIcon:jsx(IconBinaryTree,{}),children:"Section Graph"}),jsx(Modal,{opened:t,onClose:o.close,title:"Block Graph",fullScreen:true,children:jsx(C0,{sectionId:e})})]})}function P4({activeSection:e}){let t=H(i=>i.records.entities.block),o=H(i=>i.variables.attributes),r=H(i=>i.variables.variables),n=Object.values(t).filter(i=>(i.section_id===e||i.shared)&&Object.keys(r[i.id]||{}).length);return jsxs(Box,{px:"sm",w:"100%",children:[jsx(Text,{fw:700,size:"sm",children:jsxs(Center,{inline:true,children:[jsx(IconCodeDots,{size:"1rem"}),jsx(Text,{ml:"xs",span:true,children:"Variables"})]})}),jsx(ScrollArea.Autosize,{mah:"40vh",mx:"sm",w:"240px",children:jsxs(Stack,{mt:"sm",children:[jsx(k0,{name:"Report Variables",id:"attributes",variables:o}),n.map(i=>jsx(k0,{id:i.id,name:`${i.type} ${i.id}`,variables:r[i.id]},i.id))]})})]})}function O4(){return jsx(Title,{children:"Formatters"})}var L4={section:[{label:"Navigation",value:"navigation"},{label:"Generators",value:"generators"}]};function ky({scrollContainer:e}){let{opened:t,handlers:o}=Ft("tools"),{toggle:r}=o,[n,i]=useState("navigation"),{activeEntity:a}=qt(),l=u=>i(u),s=a.type==="section"?a.id:null,c=t&&jsxs(Fragment,{children:[s&&jsx(SegmentedControl,{sx:{flexShrink:0},data:L4.section,value:n,onChange:l}),jsxs(Stack,{sx:{flexGrow:1},spacing:"sm",mt:32,children:[(n==="navigation"||!s)&&jsx(by,{activeSection:s,scrollContainer:e}),n==="generators"&&s&&jsx(yy,{activeSection:s}),n==="variables"&&jsx(P4,{activeSection:s}),n==="formatters"&&jsx(O4,{})]})]});return jsxs(Flex,{direction:"column",justify:t?"space-between":"flex-end",bg:"white",pb:30,pt:"sm",px:"xs",mah:"100vh",w:t?"350px":"50px",sx:u=>({overflow:"hidden",borderRight:`1px solid ${u.colors.gray[2]}`,flexShrink:0,flexGrow:0}),children:[c,jsxs(Flex,{justify:t?"space-between":"center",px:"sm",children:[a.type==="section"&&t&&jsx(A4,{sectionId:s}),jsx(UnstyledButton,{onClick:r,sx:{transform:`rotate(${t?0:180}deg)`},children:jsx(IconChevronLeft,{size:24})})]})]})}p();p();se();$p();Sn();ye();Jn();he();Ho();Cr();Pt();ye();st();function z4({activeSection:e}){let{settings:t,updateSettings:o}=Rr(e),r=t.name||`section-${e}`,[n,i]=useState(r),[a,l]=useState(false);return jsx(TextInput,{label:"Section Name",description:"Section name. Only for organization purposes. Won't be displayed on the final report.",value:a?n:r,onChange:s=>i(s.target.value),onFocusCapture:()=>{i(r),l(true);},onBlurCapture:()=>{o("name",n),l(false);},withAsterisk:true,radius:2})}function F4({activeSection:e}){let{settings:t,updateSettings:o}=Rr(e),r=t.tags,n=H(s=>e&&s.records.entities.section[e]),i=H(s=>e&&n?Object.values(s.records.entities.section).filter(c=>c&&c.report_id===n.report_id):[]),a=useMemo(()=>{let s=new Set;return i.forEach(c=>{let u=c?.settings?.tags;u&&(Array.isArray(u)?u.forEach(d=>d&&s.add(d)):typeof u=="string"&&u.split(/\s+/).forEach(d=>d&&s.add(d)));}),Array.from(s).sort()},[i]),l=useMemo(()=>r?Array.isArray(r)?r:typeof r=="string"?r.split(/\s+/).filter(Boolean):[]:[],[r]);return jsx(MultiSelect,{label:"Section Tags",description:"Section tags. They will be appended to the dom element as data attributes.",placeholder:"Select or create tags",data:a,value:l,onChange:s=>o("tags",s),radius:2,searchable:true,creatable:true,getCreateLabel:s=>`+ Create ${s}`})}function Ey(){let{activeEntity:e}=qt(),t=e.id,o=H(k=>t&&k.records.entities.section[t]),r=H(k=>t&&o&&k.records.entities.report[o.report_id]),n=H(k=>{if(t&&o){let w=o.blocks.map(R=>k.records.entities.block[R]).filter(R=>mo(R));return w.length>1&&console.error(`Error, there is more than one section flag generator in section ${e.id}`),w.length>0?w[0]:false}return false}),i=ie(),a=useContext(De),l=At(a),s=ri(),c=k=>{k==="always"&&n?u(n.id):k==="section-flag"&&d();},u=k=>{i(Z.deleteEntity("block",k)).then(()=>{l(),console.info(`Flag generator with ID ${k} deleted.`);});},d=()=>{let{locales:k}=Tr({type:E.SECTION_FLAG});i(Z.createEntity("block",{blockrow:void 0,blockcol:void 0,type:E.SECTION_FLAG,section_id:t,locales:k})).then(w=>{i(Z.updateEntity("block",{id:w.data.id,contentByLocale:{logic:{...w.data.contentByLocale.logic,content:{simpleEnabled:true,simple:{},logic:`return {
79
+ ${Eo}: true
80
+ }`}}}})).then(()=>{l();});});},f=r?.settings||{},{settings:g,updateSettings:m}=Rr(t),h=useMemo(()=>[{key:"optionData",label:"Download data (csv, xls, json)"},{key:"optionImage",label:"Save Image"},{key:"optionShare",label:"Share link"}],[]),y=useMemo(()=>h.map(k=>jsxs(List.Item,{children:[k.label,"."]},`item-${k.key}`)),[h]);if(e.type!=="section"||!e.id)return null;let S=useMemo(()=>[{value:"always",label:"Always"},{value:"section-flag",label:"Use Section Flag"}],[]),v=useMemo(()=>[{value:"always",label:"Always"},{value:"never",label:"Never"},{value:"optional",label:"Optional"}],[]),C=n?"section-flag":"always";if(e.type!=="section"||!e.id)return null;let b=g.showInPdf||"optional";return jsxs("div",{children:[jsx(z4,{activeSection:t}),jsx(F4,{activeSection:t}),jsx(Divider,{my:"sm"}),jsxs(Stack,{mt:"sm",children:[jsxs(Stack,{spacing:"0.4rem",children:[jsx(Do,{target:jsx(Switch,{radius:"sm",label:"Show export menu.",checked:g.optionsMenu,onChange:k=>m("optionsMenu",k.currentTarget.checked)}),dropdown:jsxs(Box,{children:[jsx(Text,{size:"sm",fw:700,children:"Export Menu"}),jsx(Text,{size:"sm",children:"The Export Menu will allow users to:"}),jsx(List,{withPadding:true,size:"sm",children:y})]})}),g.optionsMenu&&jsx(Stack,{spacing:"0.5rem",pl:"md",children:h.map(k=>jsx(Switch,{radius:"sm",label:k.label,checked:typeof g[k.key]>"u"?g.optionsMenu:g[k.key],onChange:w=>m(k.key,w.currentTarget.checked)},k.key))})]}),jsx(Do,{target:jsx(Switch,{radius:"sm",label:"Show anchor link.",checked:g.showAnchor,onChange:k=>m("showAnchor",k.currentTarget.checked)}),dropdown:jsx(Text,{size:"sm",maw:200,children:"Show `#` link on top left corner of the section"})}),jsx(Do,{target:jsx(Switch,{radius:"sm",label:"Show section.",checked:!g.hidden,onChange:k=>m("hidden",!k.currentTarget.checked)}),dropdown:jsx(Text,{size:"sm",maw:200,children:"Softly hide or show the section on the rendered report (Still running the queries)"})}),jsx(Do,{target:jsx(Select,{label:"Show in PDF",value:b,data:v,disabled:!s,onChange:k=>m("showInPdf",k)}),dropdown:jsx(Text,{size:"sm",maw:200,children:s?"Hide or show the section in the pdf report.":"PDF API URL is not set."})}),jsx(Do,{target:jsx(Select,{label:"Allow section",placeholder:"Select an option",description:n?`Controlled by Section Flag #${n.id}`:"Section always visible",value:C,data:S,onChange:c}),dropdown:jsx(Text,{size:"sm",maw:200,children:"You can control section visibility (allow) creating a Section Flag Block"})}),n&&jsx(Stack,{spacing:"xs",children:jsx(rl,{id:Number(n.id),active:!!t,isInput:false,isConsumer:false,setHoverBlock:()=>{},showOutline:false})}),f.comparison&&jsx(Accordion,{children:jsxs(Accordion.Item,{value:"compare",children:[jsx(Accordion.Control,{children:"Compare Settings"}),jsx(Accordion.Panel,{children:jsxs(Stack,{children:[jsx(Switch,{radius:"sm",label:"Hide on comparison.",checked:g.comparisonHide,onChange:k=>m("comparisonHide",k.currentTarget.checked)}),jsx(Switch,{radius:"sm",label:"Show once in comparison",checked:g.comparisonMerge,onChange:k=>m("comparisonMerge",k.currentTarget.checked)})]})})]})})]})]},`settings-${t}`)}p();p();function wy(e){let{label:t,labelProps:o,...r}=e;return jsxs(Stack,{spacing:"md",children:[jsx(Text,{...o,children:t}),jsx(SegmentedControl,{...r})]})}$p();Cc();Sn();ye();function Iy(){let{activeEntity:e}=qt(),t=e.id,{settings:o,updateSettings:r}=Rr(t);return e.type!=="section"||!e.id?null:jsxs(Fragment,{children:[jsxs(Stack,{spacing:"md",children:[jsx(Text,{children:"Image"}),jsx(Do,{target:jsx(Switch,{radius:"sm",label:"Show image background",checked:o.memberImageBg,onChange:n=>r("memberImageBg",n.currentTarget.checked)}),dropdown:jsxs(Box,{maw:300,children:[jsx(Text,{size:"sm",fw:700,children:"Image Background"}),jsxs(Text,{size:"sm",children:["Set up a background image for every profile on the",jsx(Anchor,{href:"/cms/metadata",color:"blue",fw:700,children:" Metadata "}),"tab."]})]})})]}),Object.keys(ha).map(n=>jsx(wy,{label:ha[n].label,data:ha[n].options,value:String(o[n]||ha[n].defaultValue),onChange:i=>r(n,i)},n))]})}ye();ah();var L0={report:[{label:"Settings",value:"settings",component:jsx(ih,{})}],section:[{label:"Style",value:"style",component:jsx(Iy,{})},{label:"Settings",value:"settings",component:jsx(Ey,{})}],block:[{label:"Content",value:"content",component:null},{label:"Style",value:"style",component:null},{label:"Settings",value:"settings",component:null}]};function Ay(){let{opened:e,handlers:t}=Ft("settings"),[o,r]=useState("settings"),n=s=>r(s),{activeEntity:i}=qt();if(!i.type)return null;let a=L0[i.type].find(s=>s.value===o)?.component||null,l=e&&jsx(Fragment,{children:jsxs("div",{children:[i.type==="report"?jsx(Text,{children:"Report Settings"}):jsx(SegmentedControl,{value:o,data:L0[i.type],onChange:n,fullWidth:true}),jsx(Stack,{sx:{flexGrow:1},spacing:"sm",mt:32,children:a})]})});return jsxs(Flex,{direction:"column",justify:e?"space-between":"flex-end",bg:"white",pt:"sm",pb:30,p:"sm",w:e?"350px !important":"50px",sx:s=>({overflow:"hidden",borderLeft:`1px solid ${s.colors.gray[2]}`,flexShrink:0,flexGrow:0}),children:[l,jsx(Flex,{justify:e?"flex-start":"center",children:jsx(UnstyledButton,{onClick:t.toggle,sx:{transform:`rotate(${e?0:180}deg)`},children:jsx(IconChevronRight,{size:24})})})]})}ye();p();p();se();he();Jn();Cr();Pt();ye();Bs();function a6({for:e,setSectionTotals:t}){let o=H(v=>v.variables.status),r=H(v=>v.variables.variables),n=Gl(e.blocks),i=useMemo(()=>{if(n.isSuccess){let v=new Map(e.blocks.map((C,b)=>[C,b]));return n.data.slice().filter(C=>[E.GENERATOR,E.SECTION_FLAG].includes(C.type)).sort((C,b)=>{if(C.type===E.SECTION_FLAG&&b.type!==E.SECTION_FLAG)return -1;if(b.type===E.SECTION_FLAG&&C.type!==E.SECTION_FLAG)return 1;let k=v.get(C.id)??Number.MAX_VALUE,w=v.get(b.id)??Number.MAX_VALUE;return k-w})}else return []},[n.isLoading,n.isSuccess,e.blocks]);if(i.length===0)return null;let{hidden:a}=e.settings,l=useContext(De),s=At(l),u=H(v=>v.status.isRunConsumersRunning).includes(e.id),d=H(v=>v.status.previews);useEffect(()=>{s({sid:e.id});},[e.id,d]);let f=useMemo(()=>{let v=i.filter(C=>C.section_id===e.id&&mo(C));return v.length>1&&console.error(`Error, there are more than one Section Flag Generator in section ${e.id}`),v.length>0?v[0]:false},[n,e.id]),g=H(v=>f&&v.variables.variables[f.id]&&!v.variables.variables[f.id][Eo]||false),m=useMemo(()=>{let v="";return g&&f&&(v+=`(Not allowed by Section Flag #${f.id})`),a&&(v+="(Hidden by Section Settings)"),v},[a,g]),h=useMemo(()=>[{accessorKey:"status",header:"",Cell:({cell:v})=>g&&v.row.original.type!==E.SECTION_FLAG?jsx(IconCircleX,{size:"1rem"}):jsx(Fragment,{children:v.getValue()?jsx(Loader,{size:"1rem",color:"blue"}):jsx(IconCircleCheckFilled,{color:"green",size:"1rem"})}),enableSorting:false,size:50,minSize:50,maxSize:50},{accessorKey:"order",header:"Order",size:50,minSize:50,maxSize:50},{accessorKey:"id",header:"ID",size:50,minSize:50,maxSize:50},{accessorKey:"type",header:"Type",size:100,minSize:100,maxSize:100,Cell:({cell:v})=>{let C=Oc(v.getValue());return jsxs(Group,{spacing:0,noWrap:true,children:[jsx(C,{size:16}),jsx(Text,{size:"xs",ml:"xs",children:Lc(v.getValue())})]})}},{accessorKey:"duration",header:"Duration",size:100,minSize:100,maxSize:100,Cell:({cell:v})=>`${v.getValue().toFixed(3)}s`},{accessorKey:"sizeApi",header:"API Size",size:100,minSize:100,maxSize:100,Cell:({cell:v})=>v.getValue()?`\u2248${v.getValue().toFixed(2)} Kb`:""},{accessorKey:"sizeBlock",header:"Block Size",size:100,minSize:100,maxSize:100,Cell:({cell:v})=>`\u2248${v.getValue().toFixed(2)} Kb`},{accessorKey:"data",header:"",enableSorting:false,Cell:({cell:v})=>{let C=v.getValue();return jsx(Yp,{block:C.block,status:C.blockStatus,variables:C.blockVariables})}}],[]),y=useMemo(()=>i.map((v,C)=>{let b=!!v.contentByLocale?.logic?.content?.api,k=o[v.id]||{},w=r[v.id]||{},R=k.duration?k.duration/1e3:0,A=(k.api&&k.api!==""?k.api.split("|||"):[]).map((B,_)=>({original:B,swapped:k.apiFinalUrls[_]}));return {order:C+1,id:v.id,type:v.type,duration:R,status:b&&!Object.keys(w).length&&!k.error,sizeBlock:JSON.stringify(w).length/1024,sizeApi:k.responseSize,requests:A,data:{block:v,blockStatus:k,blockVariables:w}}}),[i,o,r]),S=useMemo(()=>{let v={requests:0,blocks:0,totalDuration:0,maxDuration:0,avgDuration:0,avgSizeBlock:0,totalSizeBlock:0,avgSizeApi:0,totalSizeApi:0},C=y.filter(b=>g?b.type===E.SECTION_FLAG:true);return v.requests=C.reduce((b,k)=>b+k.requests.length,0),v.blocks=C.length,C.forEach(b=>{b.duration>v.maxDuration&&(v.maxDuration=b.duration),v.totalDuration+=b.duration,v.totalSizeBlock+=b.sizeBlock||0,v.totalSizeApi+=b.sizeApi||0;}),y.length>0&&(v.avgDuration=v.requests>0?v.totalDuration/v.requests:0,v.avgSizeBlock=v.blocks>0?v.totalSizeBlock/v.blocks:0,v.avgSizeApi=v.requests>0?v.totalSizeApi/v.requests:0),v},[y]);return useEffect(()=>{u||t(e.id,S);},[u]),jsxs(Stack,{px:"md",mt:"md",spacing:0,children:[jsxs(Group,{children:[u&&jsx(Loader,{size:"xs",color:"blue"}),!u&&jsx(IconCircleCheckFilled,{color:"green",size:"1rem"}),jsxs(Title,{order:4,children:["Section #",e.id," ",e.settings?.name," ",m]})]}),jsxs(Stack,{spacing:0,mb:"xs",ml:"2rem",children:[jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Requests: ",S.requests]}),jsxs(Text,{size:"sm",children:["Total Size: ",S.totalSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",S.avgSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Total Duration: ",S.totalDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Max Duration: ",S.maxDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Avg Duration: ",S.avgDuration.toFixed(3),"s"]})]}),jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Blocks: ",S.blocks]}),jsxs(Text,{size:"sm",children:["Total Size: ",S.totalSizeBlock.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",S.avgSizeBlock.toFixed(2)," Kb"]})]})]}),jsx(MantineReactTable,{columns:h,data:y,enablePagination:true,mantinePaginationProps:{showRowsPerPage:false,rowsPerPageOptions:["5","10"],disabled:u},enableBottomToolbar:true,enableColumnActions:false,enableColumnResizing:false,enableEditing:false,enableFullScreenToggle:false,enableGlobalFilter:false,enableRowActions:false,enableRowSelection:false,enableStickyHeader:false,enableStickyFooter:false,enableTopToolbar:false,initialState:{sorting:[{id:"order",desc:false}]},renderDetailPanel:({row:v})=>{let C=v.original.requests;return C.length===0?jsx(Text,{size:"xs",children:"No requests."}):jsx(Stack,{spacing:0,children:C.map((b,k)=>jsxs(Group,{spacing:0,noWrap:true,children:[jsxs(Text,{children:[k+1,"."]}),jsx(Text,{size:"xs",children:jsx("a",{href:b.swapped,target:"_blank",rel:"noopener noreferrer",children:b.original})})]},k))})},positionExpandColumn:"last"})]})}var N0=Yt(a6,Ko);se();function F0(e){let{report:t}=e,o=H(s=>s.status.isRunConsumersRunning.length>0),r=H(s=>s.status.previews),[n,i]=useState({}),a=(s,c)=>{i({...n,[s]:c});},l=useMemo(()=>{let s={requests:0,blocks:0,totalDuration:0,maxDuration:0,avgDuration:0,avgSizeBlock:0,totalSizeBlock:0,avgSizeApi:0,totalSizeApi:0};return Object.values(n).forEach(c=>{s.requests+=c.requests||0,s.blocks+=c.blocks||0,s.totalDuration+=c.totalDuration||0,s.maxDuration=Math.max(s.maxDuration,c.maxDuration||0),s.totalSizeBlock+=c.totalSizeBlock||0,s.totalSizeApi+=c.totalSizeApi||0;}),s.avgDuration=s.requests>0?s.totalDuration/s.requests:0,s.avgSizeBlock=s.blocks>0?s.totalSizeBlock/s.blocks:0,s.avgSizeApi=s.requests>0?s.totalSizeApi/s.requests:0,s},[n]);return jsxs(Box,{children:[jsxs(Stack,{pos:"fixed",bg:o?"#fab005":"#e7f5ff",px:"md",py:"xs",w:"100%",style:{zIndex:20},spacing:0,children:[jsxs(Group,{children:[o&&jsx(Loader,{size:"xs",color:"blue"}),!o&&jsx(IconCircleCheckFilled,{color:"green",size:"1rem"}),jsxs(Title,{order:3,children:[o?"Generating Debug Report. Please wait...":"Debug Report",":"]}),jsx(Title,{order:3,variant:"dimmed",children:r.map(s=>`${s.variant_slug}/${s.slug}`).join("/")})]}),jsxs(Stack,{spacing:0,ml:"2rem",children:[jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Requests: ",l.requests]}),jsxs(Text,{size:"sm",children:["Total Size: ",l.totalSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",l.avgSizeApi.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Total Duration: ",l.totalDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Max Duration: ",l.maxDuration.toFixed(3),"s"]}),jsxs(Text,{size:"sm",children:["Avg Duration: ",l.avgDuration.toFixed(3),"s"]})]}),jsxs(Group,{spacing:"md",children:[jsxs(Text,{size:"sm",children:["Blocks: ",l.blocks]}),jsxs(Text,{size:"sm",children:["Total Size: ",l.totalSizeBlock.toFixed(2)," Kb"]}),jsxs(Text,{size:"sm",children:["Avg Size: ",l.avgSizeBlock.toFixed(2)," Kb"]})]})]})]}),jsx(Stack,{mt:"5.5rem",children:t.sections.map(s=>jsx(N0,{id:s,setSectionTotals:a},s))})]})}function H0(e){let{id:t}=e,o=zt(t);return useMemo(()=>o.isError?jsx(Center,{style:{height:300},children:jsx(Alert,{icon:jsx(IconCircleX,{size:20}),title:`Error ${o.error.code}`,color:"red",children:o.error.message})}):o.isUninitialized||!o.data?jsx(Loader,{}):jsx(R6,{report:o.data,locale:e.locale,isLoading:false}),[o.status,o.data?.sections])}function R6(e){let{report:t,isLoading:o}=e,r=useMantineTheme(),n=ie(),i=useContext(De),a=At(i),{newConfirmation:l}=Kt(),s=H(R=>R.status.previews),c=H(JS),{activeEntity:u,selectEntity:d}=qt(),f=Ft("tools"),g=Ft("settings"),m=Ft("debugView"),h=useMemo(()=>t.sections,[t.sections]),y=useRef(null),S=useCallback(R=>{let O=()=>{d({type:"section",id:R}),a({sid:R});};s.length<t.dimensions.length?l({title:"You haven't chosen a member!",message:"You may want to choose a member before editing this section.",cancelText:"OK, I'll choose one.",confirmText:"Don't tell me what to do!"}).then(O,()=>{}):O();},[t.dimensions,s]),v=useCallback(R=>{if(!R.destination||R.source.index===R.destination.index)return;let O=Number.parseInt(R.draggableId,10),A=R.destination.index>R.source.index,B=fn(c,h,R.destination.index,false,A),_=h.slice(),P=_.splice(R.source.index,1);_.splice(R.destination.index,0,...P),n(Z.updateEntity("section",{id:O,ordering:B})).then(()=>{n(Z.readEntity("report",{id:t.id,include:true}));});},[c,h]),C=useCallback(R=>jsxs("div",{ref:R.innerRef,className:"cms-droppable-container",...R.droppableProps,children:[h.map((O,A)=>jsx(Draggable,{draggableId:`${O}`,index:A,children:(B,_)=>jsxs("div",{className:`cms-section-container${_.isDragging?" isDragging":""}`,ref:B.innerRef,...B.draggableProps,style:{...B.draggableProps.style,boxShadow:_.isDragging?r.shadows.sm:void 0},children:[jsx(p0,{id:O,isDragging:_.isDragging,onActivate:S,dragHandleProps:B.dragHandleProps,position:A}),jsx(Center,{className:"cms-section-controls",m:"md",children:jsx($0,{index:A+1,report:t})})]},`section-${O}`)},O)),R.placeholder]}),[h,u.id,S]),k=!!u.id?50:0,w=50+(f.opened?350:50)+(g.opened?350:k);return jsxs(Box,{children:[jsx(iT,{report:t}),jsxs(Flex,{children:[!m.opened&&jsx(ky,{scrollContainer:y}),jsx(Box,{sx:{flexGrow:1},pos:"relative",children:jsx(ScrollArea,{w:`calc(100vw - ${w}px)`,viewportRef:y,h:"calc(100vh - 50px)",styles:{scrollbar:{zIndex:9999}},offsetScrollbars:true,children:jsxs(Stack,{styles:{backgroundColor:r.colors.gray[2]},spacing:0,children:[m.opened&&jsx(F0,{report:t}),!m.opened&&jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:o}),t.sections.length===0&&jsx(Center,{className:"cms-section-controls",my:"md",children:jsx($0,{index:0,report:t})}),jsx(DragDropContext,{onDragEnd:v,children:jsx(Droppable,{droppableId:"sections",children:C})})]})]})})}),u.type&&jsx(Ay,{})]})]})}function $0({index:e,report:t}){let o=useMantineTheme(),r=ie(),n=H(a=>a.records.entities.section),i=useCallback(()=>{r(Z.createEntity("section",{report_id:t.id,ordering:fn(n,t.sections,e,true)}));},[e]);return jsx(ActionIcon,{onClick:i,size:"lg",radius:"xl",variant:"light",bg:"#E5E5E5 !important",style:{boxShadow:o.shadows.xs},children:jsx(IconPlus,{size:24,color:"white",strokeWidth:1})})}p();p();se();he();var K0={value:"all",label:"All"},N6=e=>{if(!e)return [];let t=Object.keys(e).map(o=>({value:String(o),label:String(e[o])}));return [K0,...t]};function q0({onChange:e,loading:t,onEditCreation:o}){let r=ie(),[n,i]=useState(""),[a,l]=useState(false),[s]=useDebouncedValue(n,500),c={type:K0.value},[u,d]=useState(c),f=()=>{i(""),d(c);},g=useMemo(()=>({type:N6(ja)}),[]);useEffect(()=>{e({...u,query:s});},[u.type,s]);let m=()=>{l(true);let y=Math.random().toString(16).substring(2,10);r(Z.createEntity("formatter",{name:`formatter_${y}`,content:{type:"formatter",logic:"return n;",inputType:"string",testValue:"123456",description:"New formatter"}})).then(S=>{l(false),f(),S.ok&&o(S.data.id);});},h=useCallback((y,S)=>{let v={...u,[y]:S};d(v);},[u]);return jsxs("div",{children:[jsx(TextInput,{label:"Search by name or description",value:n,onChange:y=>i(y.currentTarget.value),disabled:t}),jsx(Select,{label:"Type",data:g.type,value:u.type,onChange:y=>h("type",y),disabled:t}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconCircleX,{}),onClick:f,children:"Clear filters"}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconPlus,{}),onClick:m,variant:"light",loading:a,children:"New formatter"})]})}p();se();he();Ga();ye();var oA=e=>e?Object.keys(e).map(t=>({value:String(t),label:String(e[t])})):[],H6=(e,t)=>{switch(e){case hn.OBJECT:return JSON.parse(t);default:return `${t}`}};function nA({formatterId:e,onEditEnd:t}){let o=H(I=>I.status.localeDefault),r=!!e,[n,i]=useState(),[a,l]=useState(""),[s,c]=useState([]),[u,d]=useState(true),[f,g]=useState(false),[m,h]=useState(true),[y,S]=useState(true),[v]=useState(false),C=ie(),b=cf(e),k=Qi(),w=US(b.data?.name),R=u||f;useEffect(()=>{b.isLoading||i(b.data);},[b.isLoading]),useEffect(()=>{if(!b.isLoading&&!k.isLoading){let I=b.isSuccess?b.data:void 0,F=k.isSuccess?k.data:[];if(I){let M=F.filter(N=>N.id!==I.id).map(N=>N.name);c(M);}_(),d(false);}},[b.isLoading,k.isLoading]);let O=n&&!s.includes(n.name)&&n.name!=="",A=I=>{O&&S(false),n&&i({...n,name:op(I).replace("-","")});},B=(I,F)=>{I!=="description"&&h(true),n&&i({...n,content:{...n.content,[I]:F}});},_=()=>{if(n){let I="";try{let F=$a({vars:["n"],logic:n.content.logic},{},o,{}),M=H6(n.content.inputType,n.content.testValue);I=F(M),S(!0);}catch(F){I=`ERROR: ${F.message}`,console.error(F),S(false);}h(false),l(`${I}`);}},P=()=>{g(true),y&&O&&C(Z.updateEntity("formatter",n)).then(t);};return jsx(Drawer,{opened:r,onClose:()=>t(),title:`Edit formatter ID ${e}`,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"50%",lockScroll:true,withCloseButton:false,children:jsx(Ao,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:u,overlayBlur:2,overlayOpacity:.5}),v&&jsx(Alert,{title:"Formatter Form",color:"red",children:"Error, please try again."}),n&&!v&&jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{grow:true,align:"flex-start",children:[jsx(TextInput,{label:`Name ${O&&w>0?`(Read only, used in ${w} blocks)`:""}`,value:n.name,icon:O?jsx(IconCircleCheck,{}):jsx(IconAlertCircle,{}),readOnly:O&&w>0,disabled:O&&w>0,onChange:I=>A(I.target.value),error:O?false:"Duplicate or empty name, choose a different one."}),jsx(Select,{label:"Type",data:oA(ja),value:n.content.type,onChange:I=>B("type",I)})]}),jsx(Textarea,{label:"Description",value:n.content.description,onChange:I=>B("description",I.target.value)}),jsx(ca,{monacoOptions:{onChange:I=>B("logic",I),height:"30vh",value:n.content.logic}},"formatter-code-editor"),jsxs(Group,{grow:true,align:"flex-end",children:[jsx(Select,{label:"Input Type",data:oA(wu),value:n.content.inputType,onChange:I=>B("inputType",I)}),jsx(TextInput,{label:"Test Value",value:n.content.testValue,onChange:I=>B("testValue",I.target.value),error:n.content.testValue===""&&!y})]}),jsx(Textarea,{readOnly:true,icon:y?jsx(IconCircleCheck,{}):jsx(IconAlertCircle,{}),label:"Test Results",value:a,error:a.includes("ERROR")&&!y?"There is a problem in the function, input type or test value. Please check and run again.":false})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:R,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:_,disabled:!m,color:m?"blue":y?"green":"red",leftIcon:jsx(IconPlayerPlay,{}),children:"Run Test"}),jsx(Button,{onClick:P,loading:R,disabled:R||!y||m||!O,children:"Save"})]}),size:165})})}p();se();ye();he();var eX=(e,t)=>{switch(e){case hn.OBJECT:return JSON.parse(t);default:return `${t}`}};function sA({filters:e,onClickEdit:t}){let[o,r]=useState([]),n=Qi(),i=n.isSuccess?n.data:[],a=Io(),l=GS(),s=useMemo(()=>i.map(d=>{let f=l[d.name]?l[d.name]:0,g="";try{let m=eX(d.content.inputType,d.content.testValue);g=a[d.name](m);}catch(m){g=`ERROR: ${m.message}`,console.error(`Error in ${d.name}`),console.error(m);}return {...d,result:g,usageCount:f}}),[i]),c=()=>{let d=s.filter(f=>{let g=true,m=true;return e.query&&(g=f.name.toLowerCase().indexOf(e.query.toLowerCase())>-1||f.content.description.indexOf(e.query)>-1),e.type!=="all"&&(m=f.content.type===e.type),g&&m});r(d);};return useEffect(()=>{c();},[e,s]),jsx(MantineReactTable,{columns:[{header:"ID",accessorKey:"id",minSize:55,size:55,maxSize:55},{header:"Name",accessorKey:"name",Cell:({row:d})=>{let f=d.original.content.type===ku.FORMATTER?jsx(IconVariable,{size:"1.3em"}):jsx(IconMathFunction,{size:"1.3em"});return jsxs(Group,{noWrap:true,align:"center",spacing:2,children:[jsx("span",{children:d.original.name}),jsx(Tooltip,{label:ja[d.original.content.type],children:jsx("span",{children:f})})]})},minSize:80,size:80},{header:"Description",accessorKey:"content.description",enableSorting:false,mantineTableBodyCellProps:{sx:{textWrap:"wrap"}},minSize:100},{header:"Demo",accessorKey:"content.testValue",Cell:({row:d})=>{let f=d.original.content.testValue;d.original.content.inputType===hn.STRING&&(f=`"${f}"`);let g=d.original.result;return typeof d.original.result=="string"&&(g=`"${g}"`),jsxs(Group,{spacing:2,children:[jsx(Tooltip,{label:`Input Type: ${wu[d.original.content.inputType]}`,children:jsx(Code,{color:"blue",children:f})}),jsx(IconArrowRightCircle,{}),jsx(Code,{color:d.original.result&&`${d.original.result}`.includes("ERROR")?"red":"teal",children:g})]})},enableSorting:false,minSize:100,size:100},{header:"Usage",accessorKey:"usageCount",mantineTableHeadCellProps:{align:"right",sx:{"& .mantine-TableHeadCell-Content-Labels":{flexDirection:"row"}}},mantineTableBodyCellProps:{align:"right"},minSize:85,size:85,maxSize:85},{header:"Actions",accessorKey:"actions",Cell:({row:d})=>jsxs(Group,{position:"center",spacing:"xs",noWrap:true,children:[jsx(ActionIcon,{onClick:()=>t(d.original),children:jsx(IconPencil,{size:20})},"edit"),jsx(ir,{id:d.original.id,type:"formatter",disabled:d.original.usageCount>0,warning:`Delete formatter called "${d.original.name}" (id:${d.original.id}) ? It is not used in any block.`})]}),enableSorting:false,minSize:80,size:80,maxSize:80,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}],data:o,enableBottomToolbar:false,enableColumnActions:false,enableColumnResizing:true,enablePagination:false,enableTopToolbar:false,initialState:{density:"xs"},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150}},mantineTableProps:{striped:true}})}function cA(){let[e,t]=useState(null),[o,r]=useState(true),n=s=>{r(s);},i=s=>{t(s);},a=s=>{s&&t(s.id);},l=()=>{t(null);};return jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Formatters"}),jsx(q0,{onChange:n,onEditCreation:i,loading:false})]}),jsxs(Grid.Col,{span:10,style:{height:"100vh"},children:[jsx(Space,{h:"xs"}),jsx(sA,{filters:o,onClickEdit:a})]})]}),e&&jsx(nA,{formatterId:e,onEditEnd:l})]})}p();p();se();function fA({onChange:e,loading:t,onEditCreation:o}){let r=ie(),[n,i]=useState(""),[a,l]=useState(""),[s,c]=useState(false),[u]=useDebouncedValue(n,500),[d]=useDebouncedValue(a,500),f={query:"",name:""},[g,m]=useState(f),h=()=>{i(""),l(""),m(f);},y=()=>{l(""),m(C=>({...C,name:""}));},S=()=>{i(""),m(C=>({...C,query:""}));};return useEffect(()=>{let C={...g,name:d,query:u,matchPattern:b=>{if(!u)return true;try{return new RegExp(b.patternSwapped).test(u)}catch{return false}}};e(C);},[u,d]),jsxs("div",{children:[jsx(TextInput,{label:"Filter by name",value:a,onChange:C=>l(C.currentTarget.value),disabled:t,rightSection:a?jsx(IconCircleX,{size:16,style:{cursor:"pointer"},onClick:y}):null}),jsx(Space,{h:"md"}),jsx(TextInput,{label:"Test a url here",value:n,onChange:C=>i(C.currentTarget.value),disabled:t,rightSection:n?jsx(IconCircleX,{size:16,style:{cursor:"pointer"},onClick:S}):null}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconPlus,{}),onClick:()=>{c(true);let C=Math.random().toString(16).substring(2,10);r(Z.createEntity("datasource",{name:`datasource_${C}`,description:"New Data Source",content:{pattern:"",logic:`
81
81
  return {
82
82
  axiosConfig: {
83
83
  method: 'get',
@@ -89,9 +89,9 @@ return {
89
89
  method: 'get',
90
90
  url: url,
91
91
  }
92
- };`,testUrl:"",useProxy:true,order:0,access:["public"]}})).then(b=>{c(false),h(),b.ok&&o(b.data.id);});},variant:"light",loading:s,children:"New Data Source"})]})}p();ae();Ha();$p();ei();op();Ur();dt();function vA({dataSourceId:e,onEditEnd:t}){H(F=>F.status.localeDefault);let r=Pe(),n=!!e,[i,a]=useState(),[l,s]=useState(""),[c,u]=useState(""),[d,m]=useState(true),[g,f]=useState(false),[h,v]=useState(true),[T,y]=useState(true),[C]=useState(false),[b,w]=useState(null),[k,I]=useState(null),[O,P]=useState(null),[_,D]=useState({}),L=ie(),R=cf(e),z=d||g,A=Ro();useEffect(()=>{R.isLoading||(a(R.data),U(),m(false)),L(Z.readEnvSecrets()).then(F=>{D(F.secrets);});},[R.isLoading]);let V=F=>{try{return new RegExp(F,"gm"),!0}catch{return false}},j=(F,G)=>{i&&a({...i,[F]:G});},B=(F,G)=>{if(F!=="description"&&v(true),i){if(F==="pattern"){let J=V(G);w(J?null:"Invalid regular expression pattern"),y(J);}F==="order"&&(G=G===""?0:Math.floor(Number(G))),F==="useProxy"&&(G=G==="true"),a({...i,content:{...i.content,[F]:G}});}},U=async()=>{if(i){let F="",G={...A};try{let J;if(i.content.pattern.trim())J=et(i.content.pattern,{},{variables:G}),I(J);else throw new Error("Pattern cannot be empty");let ee;if(i.content.testUrl.trim())ee=et(i.content.testUrl,{},{variables:G}),P(ee);else throw new Error("Test URL cannot be empty");if(!V(J))throw new Error("Invalid regular expression pattern");if(!new RegExp(J,"gm").test(ee))throw new Error("Test URL doesn't match the pattern");if(i.content.useProxy)F=`Config will be processed in the server in /api/cms/url/proxy?url=${ee}`;else {let X={envs:{...A},...r&&r.user?{session:r}:{}},K=Ga({vars:["url","libs","session"],logic:i.content.logic},X)(ee);F=typeof K=="object"?JSON.stringify(K,null,2):String(K);}u(F);}catch(J){console.error(J),u(`ERROR: ${J.message}`);}}},$=async()=>{let F="";if(i&&c!==""){f(true);try{if(i.content.useProxy)await Y(),F=await L(Z.urlProxy({url:`${O}`}));else {let G=JSON.parse(c).axiosConfig,J=await Mu(G).catch(ee=>{throw new Error("ERROR fetching "+G.url+": "+ee.message)});if(J.status===200)J.headers["content-type"]==="text/csv"?F=csvParse(J.data):F=J.data;else throw new Error("No valid response for "+G.url)}s(typeof F=="object"?JSON.stringify(F,null,2):String(F)),f(!1),y(!0),v(!1);}catch(G){console.error(G),y(false),f(false),s(`ERROR: ${G.message}`);}}},Y=async(F=false)=>{f(true),T&&i&&await L(Z.updateEntity("datasource",i)).then(()=>{F&&(f(false),t());});};return jsx(Drawer,{opened:n,onClose:()=>t(),title:`Edit Data Source ID ${e}`,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"90%",lockScroll:true,withCloseButton:false,children:jsx(Po,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:d,overlayBlur:2,overlayOpacity:.5}),C&&jsx(Alert,{title:"Formatter Form",color:"red",children:"Error, please try again."}),i&&!C&&jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{grow:true,align:"top",children:[jsx(TextInput,{label:"Name",description:"Name of the Data Source",value:i.name,onChange:F=>j("name",F.target.value),style:{flex:2}}),jsx(NumberInput,{label:"Execution Order",description:"Lower numbers match first",min:0,defaultValue:0,value:i.content.order||0,onChange:F=>B("order",F),hideControls:false,style:{flex:1}}),jsx(Textarea,{label:"Description",value:i.description,onChange:F=>j("description",F.target.value)})]}),jsx(Divider,{my:"sm"}),jsxs(Group,{grow:true,align:"top",children:[jsx(Input.Wrapper,{label:"Public ENV VARS",description:"You can use them as templates in pattern, logic and testUrl. (Defined in next.config file.)",children:Object.keys(A).map(F=>jsx(sa,{label:F,value:A[F]},F))}),jsx(Input.Wrapper,{label:"Secret ENV VARS",description:"If this datasource is using proxy you can use non-public secrets in the logic. (Defined as BESPOKE_SECRET_*)",children:i.content.useProxy?Object.keys(_).map(F=>jsx(sa,{label:F,value:_[F]},F)):jsx(Text,{m:"xs",size:"sm",align:"center",c:"dimmed",children:"No secrets available if Use Proxy is NO"})})]}),jsxs(Group,{grow:true,align:"top",children:[jsxs(Stack,{children:[jsxs(Stack,{spacing:2,children:[jsx(TextInput,{label:jsxs(Text,{size:"sm",span:true,children:["Regex Pattern ",jsx("a",{href:"https://www.akto.io/tools/javascript-regex-tester",target:"_blank",rel:"noreferrer",children:jsx(IconHelpCircle,{size:"1rem"})})]}),value:i.content.pattern,icon:jsx(IconSlash,{size:"0.8rem"}),rightSection:jsx(Text,{size:"sm",c:"dimmed",span:true,children:"/gm"}),onChange:F=>B("pattern",F.target.value),error:b||i.content.pattern===""&&!T}),k&&jsxs(Text,{size:"xs",children:["Final Regex Pattern: ",`new RegExp(${k}, "gm")`]})]}),jsx(Input.Wrapper,{label:"Use proxy on Client Side",description:"If the datasource has secrets on its logic, set proxy to YES to avoid expose credentials.",children:jsx(SegmentedControl,{fullWidth:true,value:i.content.useProxy?.toString()||"false",onChange:F=>B("useProxy",F),data:[{label:"No",value:"false"},{label:"Yes",value:"true"}]})}),jsx(Sa,{value:i.content.access||["public"],onChange:F=>B("access",F),item:"Data Source"})]}),jsxs(Stack,{spacing:4,children:[jsx(Input.Wrapper,{label:"Client-Side Logic (Variables: url, envs, libs, session)",children:jsx(ua,{monacoOptions:{onChange:F=>B("logic",F),height:"30vh",value:i.content.logic}},"data-source-code-editor")}),jsx(Input.Wrapper,{label:"Server-Side Logic \u2014 SSR/Proxy (Variables: url, envs, libs, session)",description:"Optional. When set, overrides the client-side logic for server-side execution (SSR rendering and proxy requests).",children:jsx(ua,{monacoOptions:{onChange:F=>B("logic_ssr",F),height:"30vh",value:i.content.logic_ssr||""}},"data-source-ssr-code-editor")})]})]}),jsx(Divider,{my:"sm"}),jsxs(Stack,{spacing:2,children:[jsx(TextInput,{label:"Test URL",value:i.content.testUrl,onChange:F=>B("testUrl",F.target.value),error:i.content.testUrl===""&&!T}),O&&jsxs(Text,{size:"xs",children:["Final Test URL: ",O]})]}),jsx(Textarea,{readOnly:true,icon:c.includes("ERROR:")?jsx(IconAlertCircle,{}):jsx(IconCircleCheck,{}),label:"Test Config Results",minRows:7,value:c,error:c.includes("ERROR:")?"There is a problem in the function, pattern or test url. Please check and run again to be able to save it.":false}),jsx(Textarea,{readOnly:true,icon:T?jsx(IconCircleCheck,{}):jsx(IconAlertCircle,{}),label:"Test Response Results",minRows:7,value:l,error:l.includes("ERROR")&&!T?"There is a problem in the request, the server response is not ok. Please check and run again to be able to save it.":false})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:z,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:U,disabled:!h||z,color:h?"blue":T?"green":"red",leftIcon:jsx(IconPlayerPlay,{}),children:"Run Test Config"}),jsxs(Button,{onClick:$,disabled:!h||c.includes("ERROR:")||c===""||z,color:h?"blue":T?"green":"red",leftIcon:jsx(IconPlayerPlay,{}),loading:z,children:[i?.content.useProxy?"Save & ":"","Run Test Request"]}),jsx(Button,{onClick:()=>Y(true),loading:z,disabled:z||!T||h,children:"Save"})]}),size:165})})}p();xe();Ur();ei();function SA({filters:e,onClickEdit:t}){let[o,r]=useState([]),n=Ro(),i=Hl(),a=i.isSuccess?i.data.map(u=>{let d={...n};return {...u,patternSwapped:et(u.content.pattern,{},{variables:d})}}):[],l=useMemo(()=>a,[a]),s=()=>{let u=l.filter(d=>{let m=true;if(e.name&&(m=d.name.toLowerCase().indexOf(e.name.toLowerCase())>-1||d.description.indexOf(e.name)>-1),e.query)try{m=new RegExp(d.patternSwapped).test(e.query);}catch{m=false;}return m});r(u);};return useEffect(()=>{s();},[e,l]),jsx(MantineReactTable,{columns:[{header:"ID",accessorKey:"id",minSize:35,size:35,maxSize:35,mantineTableHeadCellProps:{align:"right"},mantineTableBodyCellProps:{align:"right"}},{header:"Name",accessorKey:"name"},{header:"Use Proxy",accessorKey:"content.useProxy",minSize:70,size:70,maxSize:70,Cell:({row:u})=>u.original.content.useProxy?"YES":"NO"},{header:"REGEX Pattern",accessorKey:"content.pattern"},{header:"REGEX Pattern Swapped",accessorKey:"patternSwapped"},{header:"Order",accessorKey:"content.order",minSize:50,size:50,maxSize:50,mantineTableHeadCellProps:{align:"right"},mantineTableBodyCellProps:{align:"right"}},{header:"Actions",accessorKey:"actions",Cell:({row:u})=>jsxs(Group,{position:"center",spacing:"xs",noWrap:true,children:[jsx(ActionIcon,{onClick:()=>t(u.original),children:jsx(IconPencil,{size:20})},"edit"),jsx(ar,{id:u.original.id,type:"datasource",disabled:u.original.usageCount>0,warning:`Delete Data Source called "${u.original.name}" (id:${u.original.id}) ? It is not used in any block.`})]}),enableSorting:false,minSize:80,size:80,maxSize:80,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}],data:o,enableBottomToolbar:false,enableColumnActions:false,enableColumnResizing:true,enablePagination:false,enableTopToolbar:false,initialState:{density:"xs",sorting:[{id:"content.order",desc:false}]},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150}},mantineTableProps:{striped:true}})}function TA(){let[e,t]=useState(null),[o,r]=useState(true),n=s=>{r(s);},i=s=>{t(s);},a=s=>{s&&t(s.id);},l=()=>{t(null);};return jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Data Sources"}),jsx(mA,{onChange:n,onEditCreation:i,loading:false})]}),jsxs(Grid.Col,{span:10,style:{height:"100vh"},children:[jsx(Space,{h:"xs"}),jsx(SA,{filters:o,onClickEdit:a})]})]}),e&&jsx(vA,{dataSourceId:e,onEditEnd:l})]})}p();dt();function kA(){let{user:e}=Pe();return jsxs(Flex,{mih:"100vh",gap:"md",justify:"center",align:"center",direction:"column",wrap:"wrap",children:[jsxs(Title,{children:["Hi, ",e?.name||e?.email,"!"]}),jsx(Text,{children:"Welcome to Bespoke CMS. Have fun creating some amazing automated reports here!"})]})}p();p();ae();var tr={value:"all",label:"All"},Gy=e=>{if(!e)return [];let t=e.map(o=>({value:String(o.id),label:o.name}));return [tr,...t]};function RA({onChange:e,loading:t}){let o=ie(),r=H(T=>Object.values(T.records.entities.report).map(y=>({id:y.id,name:y.name,dimensions:y.dimensions.map(C=>{let b=T.records.entities.dimension[C];return {id:b.id,name:b.name,variants:b.variants.map(w=>{let k=T.records.entities.variant[w];return {id:k.id,name:k.name}})}})}))),n=H(T=>T.status.localeDefault),[i,a]=useState(""),[l,s]=useState(false),[c]=useDebouncedValue(i,500),u={report:tr.value,dimension:tr.value,variant:tr.value,visible:false,noImage:false,limit:"10",paginationVariants:[]},[d,m]=useState(u),g=useMemo(()=>({report:Gy(r),dimension:Gy(r.filter(T=>d.report===tr.value||d.report===`${T.id}`).reduce((T,y)=>T.concat(y.dimensions),[])),variant:Gy(r.filter(T=>d.report===tr.value||d.report===`${T.id}`).reduce((T,y)=>(y.dimensions.filter(C=>d.dimension===tr.value||d.dimension===`${C.id}`).forEach(C=>{T=T.concat(C.variants);}),T),[])),limit:[10,25,50,100].map(T=>({value:String(T),label:String(T)}))}),[r,d]),f=useCallback((T,y)=>{let C={...d,[T]:y};switch(T){case "report":C.dimension=tr.value,C.variant=tr.value;break;case "dimension":C.variant=tr.value;break;}m(C);},[d]),h=()=>{a(""),m(u);},v=()=>{s(true),o(Z.searchRegenerate()).then(()=>{s(false),e(d);});};return useEffect(()=>{let T=[];if(d.variant!==tr.value)T=[`${d.variant}`];else if(d.dimension!==tr.value)r.forEach(y=>{let C=y.dimensions.find(b=>`${b.id}`===d.dimension);C&&(T=C.variants.map(b=>`${b.id}`));});else if(d.report!==tr.value){let y=r.find(C=>`${C.id}`===d.report);y&&y.dimensions.forEach(C=>{T=[...T,...C.variants.map(b=>`${b.id}`)];});}e({...d,paginationVariants:T,query:c});},[d.report,d.dimension,d.variant,d.visible,d.limit,d.noImage,c]),jsxs("div",{children:[jsx(TextInput,{label:`Search item by name (${n.toUpperCase()})`,value:i,onChange:T=>a(T.currentTarget.value),disabled:t}),jsx(Select,{label:"Reports",data:g.report,value:d.report,onChange:T=>f("report",T),disabled:t}),jsx(Select,{label:"Dimensions",data:g.dimension,value:d.dimension,onChange:T=>f("dimension",T),disabled:t}),jsx(Select,{label:"Variants",data:g.variant,value:d.variant,onChange:T=>f("variant",T),disabled:t}),jsx(Select,{label:"Rows limit",data:g.limit,value:d.limit,onChange:T=>f("limit",T),disabled:t}),jsx(Space,{h:"md"}),jsx(Checkbox,{label:"Show visible members only",checked:d.visible,onChange:T=>f("visible",T.currentTarget.checked)}),jsx(Space,{h:"md"}),jsx(Checkbox,{label:"Show members with no image",checked:d.noImage,onChange:T=>f("noImage",T.currentTarget.checked)}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconCircleX,{}),onClick:h,children:"Clear filters"}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconRefresh,{}),onClick:v,variant:"light",loading:l,children:"Re-Index Search"})]})}p();ae();p();var ZX=e=>{let t=process.env.NEXT_PUBLIC_IMAGE_PROVIDERS?process.env.NEXT_PUBLIC_IMAGE_PROVIDERS.split(","):[];return typeof process.env.NEXT_PUBLIC_IMAGE_PROVIDERS>"u"||t.indexOf(e)>-1};function e7({member:e,onEditEnd:t}){let o=e.contentByLocale&&e.contentByLocale[0]?e.contentByLocale[0].name:"",r=useMemo(()=>({upload:{title:"Upload",key:"upload",input:"file",forceSearch:false,pagination:false,getAxiosSearchConfig:()=>({})},local:{title:"Gallery",key:"local",input:"text",forceSearch:true,pagination:false,getAxiosSearchConfig:(R,z,A)=>({url:"/api/cms/images/search/local",method:"get",params:{prompt:R,page:A}})},flickr:{title:"Flickr",key:"flickr",input:"text",forceSearch:true,pagination:true,getAxiosSearchConfig:(R,z,A)=>({url:"/api/cms/images/search/flickr",method:"get",params:{prompt:R,page:A}})},unsplash:{title:"Unsplash",key:"unsplash",input:"text",forceSearch:true,pagination:true,getAxiosSearchConfig:(R,z,A)=>({url:"/api/cms/images/search/unsplash",method:"get",params:{prompt:R,page:A}})},pixabay:{title:"Pixabay",key:"pixabay",input:"text",forceSearch:true,pagination:true,getAxiosSearchConfig:(R,z,A)=>({url:"/api/cms/images/search/pixabay",method:"get",params:{prompt:R,page:A}})}}),[]),n=useMemo(()=>Object.values(r).filter(R=>ZX(R.key)).map(R=>({value:R.key,label:R.title})),[]),[i,a]=useState(false),[l,s]=useState(Object.values(r)[0]),[c,u]=useState(500),[d,m]=useState(o),[g,f]=useState(),[h,v]=useState([]),[T,y]=useState(),[C,b]=useState(false),[w,k]=useState(1),I=async(R=void 0)=>{if(R&&R!==w)k(1);else {b(false),a(true);let z=l.getAxiosSearchConfig(d,g,R||w),A=await Mu(z).then(V=>V.data.data&&V.data.data.results?V.data.data.results:[]).catch(V=>{console.error(V),b(true);});v(A),A.length>0&&y(A[0]),a(false);}},O=R=>{y(R);},P=async()=>{a(true);let R=new FormData;R.append("content_id",e.content_id),T&&g&&(R.append("file",g),delete T.file),T&&(R.append("image_id",T.id),R.append("image_source",T.source)),await Mu({method:"post",url:`/api/cms/images/save/${l.key}`,data:R}).then(()=>{t(true);}).catch(z=>{console.error(z),b(true);}),a(false);},_=R=>{b(false),s(r[R]),y(void 0),v([]),k(1);};useEffect(()=>{let{innerHeight:R}=window;u(R-280);},[]),useEffect(()=>{!i&&l.forceSearch&&I();},[w,l]);let D=h&&h.length===0&&!i&&l.key!=="upload",L=h&&h.length===0&&!i&&l.key==="upload";return jsx(Drawer,{opened:true,onClose:t,title:`Image selection for ${o} (${e.id}) `,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"left",size:"50%",lockScroll:true,withCloseButton:false,children:jsx("div",{style:{height:"100%"},children:jsxs(Stack,{spacing:"sm",children:[jsxs(Stack,{spacing:"xs",children:[jsx(SegmentedControl,{disabled:i,value:l.key,onChange:R=>_(R),data:n,fullWidth:true}),jsxs(Group,{position:"apart",grow:true,align:"flex-end",children:[l.input==="text"&&jsx(TextInput,{placeholder:"Search term",label:"Search term",value:d,onChange:R=>m(R.target.value),onKeyDown:getHotkeyHandler([["Enter",()=>I(1)]])}),l.input==="file"&&jsx(FileInput,{label:"Upload image",placeholder:"Choose an image from your computer (png, jpg, jpeg, webp)",accept:"image/png,image/jpeg,image/jpg,image/webp",value:g,onChange:R=>{if(y(void 0),R){let A={id:"custom",source:URL.createObjectURL(R),file:R};v([A]),f(R),y(A);}},icon:jsx(IconUpload,{size:14})}),l.forceSearch&&jsx(Button,{fullWidth:true,disabled:i||!d||d==="",onClick:()=>I(1),leftIcon:jsx(IconPlayerPlay,{}),children:"Search"})]})]}),jsx(Group,{mt:"xs",grow:true,children:jsxs(ScrollArea,{offsetScrollbars:true,type:"always",style:{height:c},children:[jsx(LoadingOverlay,{visible:i,overlayBlur:2,overlayOpacity:.5,overlayColor:"#fff"}),C&&jsx(Alert,{title:`${l.title}`,color:"red",children:"Error, please try again."}),D&&jsx(Alert,{title:`${l.title}`,color:"blue",children:"No results, for try another prompt or provider."}),L&&jsx(Alert,{icon:jsx(IconPhoto,{size:"1rem"}),title:"Welcome to image selector!",color:"blue",children:"Upload an image or select a provider."}),h&&h.length>0&&!i&&jsxs(Fragment,{children:[jsx(SimpleGrid,{cols:3,children:h.map(R=>jsx(Image,{alt:`${l.title}-image-${R.id}`,radius:"md",src:R.source,style:{cursor:"pointer",borderRadius:15,border:T&&T.id===R.id?"5px solid black":""},onClick:()=>O(R)},R.id))}),jsx(Space,{h:"md"}),l.pagination&&jsx(Button,{variant:"outline",fullWidth:true,onClick:()=>k(w+1),children:"Load more images"})]})]})}),jsxs(Group,{mt:"xs",grow:true,style:{height:45},children:[jsx(Button,{variant:"outline",disabled:i,onClick:()=>t(false),children:"Cancel"}),jsx(Button,{onClick:P,loading:i,disabled:i||!T,children:"Save"})]})]})})})}var LA=e7;og();function FA({memberId:e,onEditEnd:t}){let o=H($=>$.status.localeDefault),r=H($=>$.status.locales),n=r.map($=>({value:$,label:`${$.toUpperCase()}`})),i=!!e,[a,l]=useState(o),[s,c]=useState(null),[u,d]=useState(true),[m,g]=useState(false),[f,h]=useState(false),[v,T]=useState("member"),[y,C]=useState(false),[b,w]=useState([]),[k,I]=useState({}),O=useForm(),P=r.reduce(($,Y)=>($[Y]=useForm({}),$),{}),_=useForm(),D=r.reduce(($,Y)=>($[Y]=useForm({}),$),{}),L=ie(),R=async()=>{d(true),h(false);let $=await L(Z.readMember({locale:"all",content_ids:[e],all:true,mode:"content_ids",output:"full"})).then(Y=>{let F;return Y.results&&Y.results[0]?(h(false),F=Y.results[0]):h(true),F}).catch(Y=>{console.error(Y),h(true);});$&&(c($),O.setValues($),$.contentByLocale.forEach(Y=>{P[Y.locale].setValues({name:Y.name,keywords:Y.keywords?Y.keywords:[],attributes:Y.attributes?Object.keys(Y.attributes).map(F=>({key:F,value:Y.attributes[F]})):[]});}),$.image&&(_.setValues($.image),$.image.contentByLocale.forEach(Y=>{D[Y.locale].setValues({meta:Y.meta});}))),d(false);},z=async()=>{if(s&&s.contentByLocale){let $=s.contentByLocale.find(Y=>Y.locale===a);if($){C(true);let Y=Xu({q:$.name,limit:"10",locale:a,visible:"true",includes:"true",noImage:"false",format:"plain"});L(Z.searchMember(Y)).then(F=>{if(F&&F.results){let G=F.results.filter(J=>J.content_id!==e);w(G);}C(false);}).catch(F=>{console.error(F),C(false);});}}};useEffect(()=>{e?R():c(null);},[e]),useEffect(()=>{s&&z();},[s,a]);let A=async $=>{$&&R(),g(false);},V=()=>{c({...s,image:null,image_id:null});},j=async()=>{d(true);let $={...O.values,contentByLocale:s.contentByLocale.map(G=>{let J=P[G.locale]?{...P[G.locale].values}:{};return J.keywords=J.keywords&&J.keywords.length>0?J.keywords:null,{...G,...J}}),image:s.image?{..._.values,contentByLocale:r.map(G=>{let J=s.image.contentByLocale.find(ne=>ne.locale===G),ee=D[J.locale]?D[J.locale].values:{};return {...J,...ee}})}:null,image_id:s.image_id},Y=[Mu.post("/api/cms/update/member",$)],F=Object.keys(k);F.length>0&&F.forEach(G=>{Y.push(Mu.post("/api/cms/update/member",{content_id:b[G].content_id,image_id:s.image_id}));}),Promise.all(Y).then(()=>{t();}).catch(G=>{console.error(G),h(true);});},B=Object.keys(P[a].values).length>0,U={state:{rowSelection:k},onRowSelectionChange:I,enableRowSelection:$=>s.image_id&&$.original.image_id!==s.image_id};return jsxs(Fragment,{children:[jsx(Drawer,{opened:i,onClose:()=>t(),title:`Edit member ID ${e}`,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"50%",lockScroll:true,withCloseButton:false,children:jsx(Po,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:u,overlayBlur:2,overlayOpacity:.5}),f&&jsx(Alert,{title:"Member Form",color:"red",children:"Error, please try again."}),s&&!f&&jsxs(Tabs,{defaultValue:"member",value:v,onTabChange:T,children:[jsxs(Tabs.List,{grow:true,children:[jsx(Tabs.Tab,{value:"member",icon:jsx(IconListCheck,{}),children:"Member"}),jsx(Tabs.Tab,{value:"image",icon:jsx(IconPhoto,{}),children:"Image"})]}),jsx(Tabs.Panel,{value:"member",py:"md",children:jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",disabled:true,label:"Original ID",...O.getInputProps("id")}),jsx(TextInput,{mt:"xs",disabled:true,label:"Content ID",...O.getInputProps("content_id")})]}),jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",icon:"/",disabled:true,label:"Variant Slug",...O.getInputProps("variant_slug")}),jsx(TextInput,{mt:"xs",icon:"/",disabled:true,label:"Member Slug",...O.getInputProps("slug")})]}),jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",disabled:true,label:"Report",...O.getInputProps("report_name")}),jsx(TextInput,{mt:"xs",disabled:true,label:"Dimension",...O.getInputProps("dimension_name")}),jsx(TextInput,{mt:"xs",disabled:true,label:"Variant",...O.getInputProps("variant_name")})]}),jsxs(Group,{grow:true,children:[jsxs(Box,{onClick:()=>T("image"),style:{cursor:"pointer"},pos:"relative",children:[jsx(Overlay,{opacity:0,center:true,sx:{backdropFilter:"none","& button":{display:"none"},"&:hover":{backdropFilter:"blur(0.2375rem)",button:{display:"flex"}}},children:jsx(Button,{size:"xs",radius:"sm",variant:"filled",leftIcon:jsx(IconPhoto,{size:"0.9rem"}),children:"Edit"})}),jsx(Zl,{member:s,forceRefreshTimestamp:true})]}),jsx(Input.Wrapper,{label:"Search relevance",description:`
92
+ };`,testUrl:"",useProxy:true,order:0,access:["public"]}})).then(b=>{c(false),h(),b.ok&&o(b.data.id);});},variant:"light",loading:s,children:"New Data Source"})]})}p();se();Ga();Up();Qn();rp();Vr();Xe();function SA({dataSourceId:e,onEditEnd:t}){H(W=>W.status.localeDefault);let r=we(),n=!!e,[i,a]=useState(),[l,s]=useState(""),[c,u]=useState(""),[d,f]=useState(true),[g,m]=useState(false),[h,y]=useState(true),[S,v]=useState(true),[C]=useState(false),[b,k]=useState(null),[w,R]=useState(null),[O,A]=useState(null),[B,_]=useState({}),P=ie(),I=uf(e),F=d||g,M=wo();useEffect(()=>{I.isLoading||(a(I.data),V(),f(false)),P(Z.readEnvSecrets()).then(W=>{_(W.secrets);});},[I.isLoading]);let N=W=>{try{return new RegExp(W,"gm"),!0}catch{return false}},j=(W,U)=>{i&&a({...i,[W]:U});},$=(W,U)=>{if(W!=="description"&&y(true),i){if(W==="pattern"){let Y=N(U);k(Y?null:"Invalid regular expression pattern"),v(Y);}W==="order"&&(U=U===""?0:Math.floor(Number(U))),W==="useProxy"&&(U=U==="true"),a({...i,content:{...i.content,[W]:U}});}},V=async()=>{if(i){let W="",U={...M};try{let Y;if(i.content.pattern.trim())Y=et(i.content.pattern,{},{variables:U}),R(Y);else throw new Error("Pattern cannot be empty");let ne;if(i.content.testUrl.trim())ne=et(i.content.testUrl,{},{variables:U}),A(ne);else throw new Error("Test URL cannot be empty");if(!N(Y))throw new Error("Invalid regular expression pattern");if(!new RegExp(Y,"gm").test(ne))throw new Error("Test URL doesn't match the pattern");if(i.content.useProxy)W=`Config will be processed in the server in /api/cms/url/proxy?url=${ne}`;else {let J={envs:{...M},...r&&r.user?{session:r}:{}},K=Ua({vars:["url","libs","session"],logic:i.content.logic},J)(ne);W=typeof K=="object"?JSON.stringify(K,null,2):String(K);}u(W);}catch(Y){console.error(Y),u(`ERROR: ${Y.message}`);}}},z=async()=>{let W="";if(i&&c!==""){m(true);try{if(i.content.useProxy)await q(),W=await P(Z.urlProxy({url:`${O}`}));else {let U=JSON.parse(c).axiosConfig,Y=await Mu(U).catch(ne=>{throw new Error("ERROR fetching "+U.url+": "+ne.message)});if(Y.status===200)Y.headers["content-type"]==="text/csv"?W=csvParse(Y.data):W=Y.data;else throw new Error("No valid response for "+U.url)}s(typeof W=="object"?JSON.stringify(W,null,2):String(W)),m(!1),v(!0),y(!1);}catch(U){console.error(U),v(false),m(false),s(`ERROR: ${U.message}`);}}},q=async(W=false)=>{m(true),S&&i&&await P(Z.updateEntity("datasource",i)).then(()=>{W&&(m(false),t());});};return jsx(Drawer,{opened:n,onClose:()=>t(),title:`Edit Data Source ID ${e}`,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"90%",lockScroll:true,withCloseButton:false,children:jsx(Ao,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:d,overlayBlur:2,overlayOpacity:.5}),C&&jsx(Alert,{title:"Formatter Form",color:"red",children:"Error, please try again."}),i&&!C&&jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{grow:true,align:"top",children:[jsx(TextInput,{label:"Name",description:"Name of the Data Source",value:i.name,onChange:W=>j("name",W.target.value),style:{flex:2}}),jsx(NumberInput,{label:"Execution Order",description:"Lower numbers match first",min:0,defaultValue:0,value:i.content.order||0,onChange:W=>$("order",W),hideControls:false,style:{flex:1}}),jsx(Textarea,{label:"Description",value:i.description,onChange:W=>j("description",W.target.value)})]}),jsx(Divider,{my:"sm"}),jsxs(Group,{grow:true,align:"top",children:[jsx(Input.Wrapper,{label:"Public ENV VARS",description:"You can use them as templates in pattern, logic and testUrl. (Defined in next.config file.)",children:Object.keys(M).map(W=>jsx(aa,{label:W,value:M[W]},W))}),jsx(Input.Wrapper,{label:"Secret ENV VARS",description:"If this datasource is using proxy you can use non-public secrets in the logic. (Defined as BESPOKE_SECRET_*)",children:i.content.useProxy?Object.keys(B).map(W=>jsx(aa,{label:W,value:B[W]},W)):jsx(Text,{m:"xs",size:"sm",align:"center",c:"dimmed",children:"No secrets available if Use Proxy is NO"})})]}),jsxs(Group,{grow:true,align:"top",children:[jsxs(Stack,{children:[jsxs(Stack,{spacing:2,children:[jsx(TextInput,{label:jsxs(Text,{size:"sm",span:true,children:["Regex Pattern ",jsx("a",{href:"https://www.akto.io/tools/javascript-regex-tester",target:"_blank",rel:"noreferrer",children:jsx(IconHelpCircle,{size:"1rem"})})]}),value:i.content.pattern,icon:jsx(IconSlash,{size:"0.8rem"}),rightSection:jsx(Text,{size:"sm",c:"dimmed",span:true,children:"/gm"}),onChange:W=>$("pattern",W.target.value),error:b||i.content.pattern===""&&!S}),w&&jsxs(Text,{size:"xs",children:["Final Regex Pattern: ",`new RegExp(${w}, "gm")`]})]}),jsx(Input.Wrapper,{label:"Use proxy on Client Side",description:"If the datasource has secrets on its logic, set proxy to YES to avoid expose credentials.",children:jsx(SegmentedControl,{fullWidth:true,value:i.content.useProxy?.toString()||"false",onChange:W=>$("useProxy",W),data:[{label:"No",value:"false"},{label:"Yes",value:"true"}]})}),jsx(va,{value:i.content.access||["public"],onChange:W=>$("access",W),item:"Data Source"})]}),jsxs(Stack,{spacing:4,children:[jsx(Input.Wrapper,{label:"Client-Side Logic (Variables: url, envs, libs, session)",children:jsx(ca,{monacoOptions:{onChange:W=>$("logic",W),height:"30vh",value:i.content.logic}},"data-source-code-editor")}),jsx(Input.Wrapper,{label:"Server-Side Logic \u2014 SSR/Proxy (Variables: url, envs, libs, session)",description:"Optional. When set, overrides the client-side logic for server-side execution (SSR rendering and proxy requests).",children:jsx(ca,{monacoOptions:{onChange:W=>$("logic_ssr",W),height:"30vh",value:i.content.logic_ssr||""}},"data-source-ssr-code-editor")})]})]}),jsx(Divider,{my:"sm"}),jsxs(Stack,{spacing:2,children:[jsx(TextInput,{label:"Test URL",value:i.content.testUrl,onChange:W=>$("testUrl",W.target.value),error:i.content.testUrl===""&&!S}),O&&jsxs(Text,{size:"xs",children:["Final Test URL: ",O]})]}),jsx(Textarea,{readOnly:true,icon:c.includes("ERROR:")?jsx(IconAlertCircle,{}):jsx(IconCircleCheck,{}),label:"Test Config Results",minRows:7,value:c,error:c.includes("ERROR:")?"There is a problem in the function, pattern or test url. Please check and run again to be able to save it.":false}),jsx(Textarea,{readOnly:true,icon:S?jsx(IconCircleCheck,{}):jsx(IconAlertCircle,{}),label:"Test Response Results",minRows:7,value:l,error:l.includes("ERROR")&&!S?"There is a problem in the request, the server response is not ok. Please check and run again to be able to save it.":false})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:F,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:V,disabled:!h||F,color:h?"blue":S?"green":"red",leftIcon:jsx(IconPlayerPlay,{}),children:"Run Test Config"}),jsxs(Button,{onClick:z,disabled:!h||c.includes("ERROR:")||c===""||F,color:h?"blue":S?"green":"red",leftIcon:jsx(IconPlayerPlay,{}),loading:F,children:[i?.content.useProxy?"Save & ":"","Run Test Request"]}),jsx(Button,{onClick:()=>q(true),loading:F,disabled:F||!S||h,children:"Save"})]}),size:165})})}p();ye();Vr();Qn();function xA({filters:e,onClickEdit:t}){let[o,r]=useState([]),n=wo(),i=Hl(),a=i.isSuccess?i.data.map(u=>{let d={...n};return {...u,patternSwapped:et(u.content.pattern,{},{variables:d})}}):[],l=useMemo(()=>a,[a]),s=()=>{let u=l.filter(d=>{let f=true;if(e.name&&(f=d.name.toLowerCase().indexOf(e.name.toLowerCase())>-1||d.description.indexOf(e.name)>-1),e.query)try{f=new RegExp(d.patternSwapped).test(e.query);}catch{f=false;}return f});r(u);};return useEffect(()=>{s();},[e,l]),jsx(MantineReactTable,{columns:[{header:"ID",accessorKey:"id",minSize:35,size:35,maxSize:35,mantineTableHeadCellProps:{align:"right"},mantineTableBodyCellProps:{align:"right"}},{header:"Name",accessorKey:"name"},{header:"Use Proxy",accessorKey:"content.useProxy",minSize:70,size:70,maxSize:70,Cell:({row:u})=>u.original.content.useProxy?"YES":"NO"},{header:"REGEX Pattern",accessorKey:"content.pattern"},{header:"REGEX Pattern Swapped",accessorKey:"patternSwapped"},{header:"Order",accessorKey:"content.order",minSize:50,size:50,maxSize:50,mantineTableHeadCellProps:{align:"right"},mantineTableBodyCellProps:{align:"right"}},{header:"Actions",accessorKey:"actions",Cell:({row:u})=>jsxs(Group,{position:"center",spacing:"xs",noWrap:true,children:[jsx(ActionIcon,{onClick:()=>t(u.original),children:jsx(IconPencil,{size:20})},"edit"),jsx(ir,{id:u.original.id,type:"datasource",disabled:u.original.usageCount>0,warning:`Delete Data Source called "${u.original.name}" (id:${u.original.id}) ? It is not used in any block.`})]}),enableSorting:false,minSize:80,size:80,maxSize:80,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}],data:o,enableBottomToolbar:false,enableColumnActions:false,enableColumnResizing:true,enablePagination:false,enableTopToolbar:false,initialState:{density:"xs",sorting:[{id:"content.order",desc:false}]},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150}},mantineTableProps:{striped:true}})}function CA(){let[e,t]=useState(null),[o,r]=useState(true),n=s=>{r(s);},i=s=>{t(s);},a=s=>{s&&t(s.id);},l=()=>{t(null);};return jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Data Sources"}),jsx(fA,{onChange:n,onEditCreation:i,loading:false})]}),jsxs(Grid.Col,{span:10,style:{height:"100vh"},children:[jsx(Space,{h:"xs"}),jsx(xA,{filters:o,onClickEdit:a})]})]}),e&&jsx(SA,{dataSourceId:e,onEditEnd:l})]})}p();Xe();function EA(){let{user:e}=we();return jsxs(Flex,{mih:"100vh",gap:"md",justify:"center",align:"center",direction:"column",wrap:"wrap",children:[jsxs(Title,{children:["Hi, ",e?.name||e?.email,"!"]}),jsx(Text,{children:"Welcome to Bespoke CMS. Have fun creating some amazing automated reports here!"})]})}p();p();se();var er={value:"all",label:"All"},Hy=e=>{if(!e)return [];let t=e.map(o=>({value:String(o.id),label:o.name}));return [er,...t]};function IA({onChange:e,loading:t}){let o=ie(),r=H(S=>Object.values(S.records.entities.report).map(v=>({id:v.id,name:v.name,dimensions:v.dimensions.map(C=>{let b=S.records.entities.dimension[C];return {id:b.id,name:b.name,variants:b.variants.map(k=>{let w=S.records.entities.variant[k];return {id:w.id,name:w.name}})}})}))),n=H(S=>S.status.localeDefault),[i,a]=useState(""),[l,s]=useState(false),[c]=useDebouncedValue(i,500),u={report:er.value,dimension:er.value,variant:er.value,visible:false,noImage:false,limit:"10",paginationVariants:[]},[d,f]=useState(u),g=useMemo(()=>({report:Hy(r),dimension:Hy(r.filter(S=>d.report===er.value||d.report===`${S.id}`).reduce((S,v)=>S.concat(v.dimensions),[])),variant:Hy(r.filter(S=>d.report===er.value||d.report===`${S.id}`).reduce((S,v)=>(v.dimensions.filter(C=>d.dimension===er.value||d.dimension===`${C.id}`).forEach(C=>{S=S.concat(C.variants);}),S),[])),limit:[10,25,50,100].map(S=>({value:String(S),label:String(S)}))}),[r,d]),m=useCallback((S,v)=>{let C={...d,[S]:v};switch(S){case "report":C.dimension=er.value,C.variant=er.value;break;case "dimension":C.variant=er.value;break;}f(C);},[d]),h=()=>{a(""),f(u);},y=()=>{s(true),o(Z.searchRegenerate()).then(()=>{s(false),e(d);});};return useEffect(()=>{let S=[];if(d.variant!==er.value)S=[`${d.variant}`];else if(d.dimension!==er.value)r.forEach(v=>{let C=v.dimensions.find(b=>`${b.id}`===d.dimension);C&&(S=C.variants.map(b=>`${b.id}`));});else if(d.report!==er.value){let v=r.find(C=>`${C.id}`===d.report);v&&v.dimensions.forEach(C=>{S=[...S,...C.variants.map(b=>`${b.id}`)];});}e({...d,paginationVariants:S,query:c});},[d.report,d.dimension,d.variant,d.visible,d.limit,d.noImage,c]),jsxs("div",{children:[jsx(TextInput,{label:`Search item by name (${n.toUpperCase()})`,value:i,onChange:S=>a(S.currentTarget.value),disabled:t}),jsx(Select,{label:"Reports",data:g.report,value:d.report,onChange:S=>m("report",S),disabled:t}),jsx(Select,{label:"Dimensions",data:g.dimension,value:d.dimension,onChange:S=>m("dimension",S),disabled:t}),jsx(Select,{label:"Variants",data:g.variant,value:d.variant,onChange:S=>m("variant",S),disabled:t}),jsx(Select,{label:"Rows limit",data:g.limit,value:d.limit,onChange:S=>m("limit",S),disabled:t}),jsx(Space,{h:"md"}),jsx(Checkbox,{label:"Show visible members only",checked:d.visible,onChange:S=>m("visible",S.currentTarget.checked)}),jsx(Space,{h:"md"}),jsx(Checkbox,{label:"Show members with no image",checked:d.noImage,onChange:S=>m("noImage",S.currentTarget.checked)}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconCircleX,{}),onClick:h,children:"Clear filters"}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconRefresh,{}),onClick:y,variant:"light",loading:l,children:"Re-Index Search"})]})}p();se();p();var e7=e=>{let t=process.env.NEXT_PUBLIC_IMAGE_PROVIDERS?process.env.NEXT_PUBLIC_IMAGE_PROVIDERS.split(","):[];return typeof process.env.NEXT_PUBLIC_IMAGE_PROVIDERS>"u"||t.indexOf(e)>-1};function t7({member:e,onEditEnd:t}){let o=e.contentByLocale&&e.contentByLocale[0]?e.contentByLocale[0].name:"",r=useMemo(()=>({upload:{title:"Upload",key:"upload",input:"file",forceSearch:false,pagination:false,getAxiosSearchConfig:()=>({})},local:{title:"Gallery",key:"local",input:"text",forceSearch:true,pagination:false,getAxiosSearchConfig:(I,F,M)=>({url:"/api/cms/images/search/local",method:"get",params:{prompt:I,page:M}})},flickr:{title:"Flickr",key:"flickr",input:"text",forceSearch:true,pagination:true,getAxiosSearchConfig:(I,F,M)=>({url:"/api/cms/images/search/flickr",method:"get",params:{prompt:I,page:M}})},unsplash:{title:"Unsplash",key:"unsplash",input:"text",forceSearch:true,pagination:true,getAxiosSearchConfig:(I,F,M)=>({url:"/api/cms/images/search/unsplash",method:"get",params:{prompt:I,page:M}})},pixabay:{title:"Pixabay",key:"pixabay",input:"text",forceSearch:true,pagination:true,getAxiosSearchConfig:(I,F,M)=>({url:"/api/cms/images/search/pixabay",method:"get",params:{prompt:I,page:M}})}}),[]),n=useMemo(()=>Object.values(r).filter(I=>e7(I.key)).map(I=>({value:I.key,label:I.title})),[]),[i,a]=useState(false),[l,s]=useState(Object.values(r)[0]),[c,u]=useState(500),[d,f]=useState(o),[g,m]=useState(),[h,y]=useState([]),[S,v]=useState(),[C,b]=useState(false),[k,w]=useState(1),R=async(I=void 0)=>{if(I&&I!==k)w(1);else {b(false),a(true);let F=l.getAxiosSearchConfig(d,g,I||k),M=await Mu(F).then(N=>N.data.data&&N.data.data.results?N.data.data.results:[]).catch(N=>{console.error(N),b(true);});y(M),M.length>0&&v(M[0]),a(false);}},O=I=>{v(I);},A=async()=>{a(true);let I=new FormData;I.append("content_id",e.content_id),S&&g&&(I.append("file",g),delete S.file),S&&(I.append("image_id",S.id),I.append("image_source",S.source)),await Mu({method:"post",url:`/api/cms/images/save/${l.key}`,data:I}).then(()=>{t(true);}).catch(F=>{console.error(F),b(true);}),a(false);},B=I=>{b(false),s(r[I]),v(void 0),y([]),w(1);};useEffect(()=>{let{innerHeight:I}=window;u(I-280);},[]),useEffect(()=>{!i&&l.forceSearch&&R();},[k,l]);let _=h&&h.length===0&&!i&&l.key!=="upload",P=h&&h.length===0&&!i&&l.key==="upload";return jsx(Drawer,{opened:true,onClose:t,title:`Image selection for ${o} (${e.id}) `,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"left",size:"50%",lockScroll:true,withCloseButton:false,children:jsx("div",{style:{height:"100%"},children:jsxs(Stack,{spacing:"sm",children:[jsxs(Stack,{spacing:"xs",children:[jsx(SegmentedControl,{disabled:i,value:l.key,onChange:I=>B(I),data:n,fullWidth:true}),jsxs(Group,{position:"apart",grow:true,align:"flex-end",children:[l.input==="text"&&jsx(TextInput,{placeholder:"Search term",label:"Search term",value:d,onChange:I=>f(I.target.value),onKeyDown:getHotkeyHandler([["Enter",()=>R(1)]])}),l.input==="file"&&jsx(FileInput,{label:"Upload image",placeholder:"Choose an image from your computer (png, jpg, jpeg, webp)",accept:"image/png,image/jpeg,image/jpg,image/webp",value:g,onChange:I=>{if(v(void 0),I){let M={id:"custom",source:URL.createObjectURL(I),file:I};y([M]),m(I),v(M);}},icon:jsx(IconUpload,{size:14})}),l.forceSearch&&jsx(Button,{fullWidth:true,disabled:i||!d||d==="",onClick:()=>R(1),leftIcon:jsx(IconPlayerPlay,{}),children:"Search"})]})]}),jsx(Group,{mt:"xs",grow:true,children:jsxs(ScrollArea,{offsetScrollbars:true,type:"always",style:{height:c},children:[jsx(LoadingOverlay,{visible:i,overlayBlur:2,overlayOpacity:.5,overlayColor:"#fff"}),C&&jsx(Alert,{title:`${l.title}`,color:"red",children:"Error, please try again."}),_&&jsx(Alert,{title:`${l.title}`,color:"blue",children:"No results, for try another prompt or provider."}),P&&jsx(Alert,{icon:jsx(IconPhoto,{size:"1rem"}),title:"Welcome to image selector!",color:"blue",children:"Upload an image or select a provider."}),h&&h.length>0&&!i&&jsxs(Fragment,{children:[jsx(SimpleGrid,{cols:3,children:h.map(I=>jsx(Image,{alt:`${l.title}-image-${I.id}`,radius:"md",src:I.source,style:{cursor:"pointer",borderRadius:15,border:S&&S.id===I.id?"5px solid black":""},onClick:()=>O(I)},I.id))}),jsx(Space,{h:"md"}),l.pagination&&jsx(Button,{variant:"outline",fullWidth:true,onClick:()=>w(k+1),children:"Load more images"})]})]})}),jsxs(Group,{mt:"xs",grow:true,style:{height:45},children:[jsx(Button,{variant:"outline",disabled:i,onClick:()=>t(false),children:"Cancel"}),jsx(Button,{onClick:A,loading:i,disabled:i||!S,children:"Save"})]})]})})})}var MA=t7;rg();function VA({memberId:e,onEditEnd:t}){let o=H(z=>z.status.localeDefault),r=H(z=>z.status.locales),n=r.map(z=>({value:z,label:`${z.toUpperCase()}`})),i=!!e,[a,l]=useState(o),[s,c]=useState(null),[u,d]=useState(true),[f,g]=useState(false),[m,h]=useState(false),[y,S]=useState("member"),[v,C]=useState(false),[b,k]=useState([]),[w,R]=useState({}),O=useForm(),A=r.reduce((z,q)=>(z[q]=useForm({}),z),{}),B=useForm(),_=r.reduce((z,q)=>(z[q]=useForm({}),z),{}),P=ie(),I=async()=>{d(true),h(false);let z=await P(Z.readMember({locale:"all",content_ids:[e],all:true,mode:"content_ids",output:"full"})).then(q=>{let W;return q.results&&q.results[0]?(h(false),W=q.results[0]):h(true),W}).catch(q=>{console.error(q),h(true);});z&&(c(z),O.setValues(z),z.contentByLocale.forEach(q=>{A[q.locale].setValues({name:q.name,keywords:q.keywords?q.keywords:[],attributes:q.attributes?Object.keys(q.attributes).map(W=>({key:W,value:q.attributes[W]})):[]});}),z.image&&(B.setValues(z.image),z.image.contentByLocale.forEach(q=>{_[q.locale].setValues({meta:q.meta});}))),d(false);},F=async()=>{if(s&&s.contentByLocale){let z=s.contentByLocale.find(q=>q.locale===a);if(z){C(true);let q=Ju({q:z.name,limit:"10",locale:a,visible:"true",includes:"true",noImage:"false",format:"plain"});P(Z.searchMember(q)).then(W=>{if(W&&W.results){let U=W.results.filter(Y=>Y.content_id!==e);k(U);}C(false);}).catch(W=>{console.error(W),C(false);});}}};useEffect(()=>{e?I():c(null);},[e]),useEffect(()=>{s&&F();},[s,a]);let M=async z=>{z&&I(),g(false);},N=()=>{c({...s,image:null,image_id:null});},j=async()=>{d(true);let z={...O.values,contentByLocale:s.contentByLocale.map(U=>{let Y=A[U.locale]?{...A[U.locale].values}:{};return Y.keywords=Y.keywords&&Y.keywords.length>0?Y.keywords:null,{...U,...Y}}),image:s.image?{...B.values,contentByLocale:r.map(U=>{let Y=s.image.contentByLocale.find(re=>re.locale===U),ne=_[Y.locale]?_[Y.locale].values:{};return {...Y,...ne}})}:null,image_id:s.image_id},q=[Mu.post("/api/cms/update/member",z)],W=Object.keys(w);W.length>0&&W.forEach(U=>{q.push(Mu.post("/api/cms/update/member",{content_id:b[U].content_id,image_id:s.image_id}));}),Promise.all(q).then(()=>{t();}).catch(U=>{console.error(U),h(true);});},$=Object.keys(A[a].values).length>0,V={state:{rowSelection:w},onRowSelectionChange:R,enableRowSelection:z=>s.image_id&&z.original.image_id!==s.image_id};return jsxs(Fragment,{children:[jsx(Drawer,{opened:i,onClose:()=>t(),title:`Edit member ID ${e}`,padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"50%",lockScroll:true,withCloseButton:false,children:jsx(Ao,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:u,overlayBlur:2,overlayOpacity:.5}),m&&jsx(Alert,{title:"Member Form",color:"red",children:"Error, please try again."}),s&&!m&&jsxs(Tabs,{defaultValue:"member",value:y,onTabChange:S,children:[jsxs(Tabs.List,{grow:true,children:[jsx(Tabs.Tab,{value:"member",icon:jsx(IconListCheck,{}),children:"Member"}),jsx(Tabs.Tab,{value:"image",icon:jsx(IconPhoto,{}),children:"Image"})]}),jsx(Tabs.Panel,{value:"member",py:"md",children:jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",disabled:true,label:"Original ID",...O.getInputProps("id")}),jsx(TextInput,{mt:"xs",disabled:true,label:"Content ID",...O.getInputProps("content_id")})]}),jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",icon:"/",disabled:true,label:"Variant Slug",...O.getInputProps("variant_slug")}),jsx(TextInput,{mt:"xs",icon:"/",disabled:true,label:"Member Slug",...O.getInputProps("slug")})]}),jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",disabled:true,label:"Report",...O.getInputProps("report_name")}),jsx(TextInput,{mt:"xs",disabled:true,label:"Dimension",...O.getInputProps("dimension_name")}),jsx(TextInput,{mt:"xs",disabled:true,label:"Variant",...O.getInputProps("variant_name")})]}),jsxs(Group,{grow:true,children:[jsxs(Box,{onClick:()=>S("image"),style:{cursor:"pointer"},pos:"relative",children:[jsx(Overlay,{opacity:0,center:true,sx:{backdropFilter:"none","& button":{display:"none"},"&:hover":{backdropFilter:"blur(0.2375rem)",button:{display:"flex"}}},children:jsx(Button,{size:"xs",radius:"sm",variant:"filled",leftIcon:jsx(IconPhoto,{size:"0.9rem"}),children:"Edit"})}),jsx(Zl,{member:s,forceRefreshTimestamp:true})]}),jsx(Input.Wrapper,{label:"Search relevance",description:`
93
93
  Relevance index to be used with search. Values from 0 (less relevant) to 1 (more relevant)
94
- `,children:jsx(NumberInput,{disabled:!O.values.visible,type:"number",precision:4,step:1e-4,removeTrailingZeros:true,min:0,max:1,decimalSeparator:".",...O.getInputProps("zvalue")})}),jsx(Checkbox,{mt:"2.3rem",label:"Visible in search",...O.getInputProps("visible",{type:"checkbox"})})]}),jsx(Group,{mt:"xs",position:"apart",grow:true,children:jsx(SegmentedControl,{value:a,onChange:l,data:n})}),!B&&jsx(Alert,{title:"Unavailable locale",color:"blue",children:"This language was not ingested for the current member. Go to variant editor and provide the members there."}),B&&jsxs(Fragment,{children:[jsx(Group,{mt:"xs",position:"apart",grow:true,children:jsx(TextInput,{label:"Name",...P[a].getInputProps("name")})}),jsx(Group,{mt:"xs",position:"apart",align:"top",grow:true,children:jsx(MultiSelect,{label:"Keywords",data:P[a].values.keywords,placeholder:"Enter keywords",searchable:true,creatable:true,valueComponent:({label:$})=>jsxs(Badge,{onClick:()=>{let Y=P[a].values.keywords;P[a].setFieldValue("keywords",Y.filter(F=>F!==$));},children:[$," ","x"]}),getCreateLabel:$=>`+ Create ${$}`,value:P[a].values.keywords,onCreate:$=>{let Y=P[a].values.keywords;return P[a].setFieldValue("keywords",[...Y,$]),$}})}),jsx(Input.Wrapper,{label:"Attributes",children:jsx(hp,{data:P[a].values.attributes})})]})]})}),jsx(Tabs.Panel,{value:"image",py:"md",children:jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{position:"apart",grow:true,children:[jsxs(Stack,{children:[jsx(Zl,{member:s,forceRefreshTimestamp:true}),jsx(Button,{variant:"outline",disabled:u,leftIcon:jsx(IconPolaroid,{}),onClick:()=>g(true),children:"Change image"}),s&&s.image&&jsx(Button,{variant:"outline",disabled:u,leftIcon:jsx(IconCircleMinus,{}),onClick:()=>V(),children:"Remove image"}),jsx(Space,{h:"md"})]}),jsxs(Stack,{justify:"flex-start",children:[jsx(TextInput,{disabled:!s||!s.image,label:"Source",..._.getInputProps("url")}),jsx(TextInput,{disabled:!s||!s.image,label:"Author",..._.getInputProps("author")}),jsx(TextInput,{disabled:!s||!s.image,label:"License",..._.getInputProps("license")}),jsx(SegmentedControl,{disabled:!s||!s.image,value:a,onChange:l,data:n}),jsx(TextInput,{disabled:!s||!s.image,label:"Alternative image text",...D[a].getInputProps("meta")})]})]}),y&&jsx(Loader,{}),!y&&b.length>0&&jsxs(Fragment,{children:[jsx(Text,{children:"Select the members you want to update with the same image."}),jsx(xs,{members:b,colsToRender:["id","report","name","slug","image"],dataTableProps:U})]})]})})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:u,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:j,loading:u,disabled:u,children:"Save Member"})]}),size:165})}),m&&jsx(LA,{member:s,onEditEnd:A})]})}function VA(){let[e,t]=useState(null),[o,r]=useState([]),[n,i]=useState(true),[a,l]=useState(true),[s,c]=useState(),[u,d]=useState(1),[m,g]=useState(0),f=C=>{l(C),d(1);},h=C=>{C&&C.length&&c(C[0]);},v=C=>{t(C.content_id);},T=()=>{t(null),y();},y=async()=>{i(true);let C=Object.keys({...a}).reduce((w,k)=>(a[k]!=="all"&&(w[k]=a[k]),w),{}),b=await Mu.get("/api/cms/search/members",{params:{...C,offset:(u-1)*parseInt(C.limit||"10",10),locale:"all",includes:true,sort:s?s.id:"zvalue",direction:s?s.desc?"desc":"asc":"desc",origin:"flexsearch"}}).then(w=>{let k=w.data&&w.data.data&&w.data.data.meta?Object.keys(w.data.data.meta.variantCount).reduce((I,O)=>{let P=w.data.data.meta.variantCount[O];return a.paginationVariants&&a.paginationVariants.length>0&&(a.paginationVariants.includes(O)||(P=0)),I+P},0):0;return g(k),w.data&&w.data.data&&w.data.data.results?w.data.data.results:[]});r(b),i(false);};return useEffect(()=>{a.limit&&y();},[a,s,u]),jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Metadata"}),jsx(RA,{onChange:f,loading:n})]}),jsxs(Grid.Col,{span:10,style:{height:"95vh",position:"relative"},children:[jsx(LoadingOverlay,{visible:n,overlayBlur:2,overlayOpacity:.5}),jsx(Space,{h:"xs"}),jsx(xs,{members:o,onClickEdit:v,onSort:h}),jsx(Group,{position:"center",children:jsx(Pagination,{value:u,onChange:d,total:Math.ceil(m/(a.limit||10)),size:"sm",py:"xs"})})]})]}),e&&jsx(FA,{memberId:e,onEditEnd:T})]})}p();dt();function GA(){let{user:e}=Pe(),t={color:"#000"};return jsxs(Flex,{mih:"100vh",gap:"md",justify:"center",align:"center",direction:"column",wrap:"wrap",style:{background:"white"},children:[jsx(Title,{style:t,children:"Not found."}),jsxs(Title,{order:2,style:t,children:["Sorry, ",e?.name,"!"]}),jsx(Text,{style:t,children:"The page you are looking for is not here."}),jsx(Button,{component:"a",href:"/",children:"Back to homepage"})]})}p();p();st();ae();function qy(e){let{for:t,enabled:o}=e,r=useMantineTheme(),n=Jt(),i=r.colorScheme==="dark"?r.colors.dark[1]:r.colors.gray[7];return jsxs(Card,{shadow:"xs",p:"sm",w:"100%",children:[jsxs(Group,{position:"apart",children:[jsxs(Center,{mah:24,children:[jsx(IconFileAnalytics,{size:22}),jsx(Text,{mx:"xs",weight:"bold",children:t.name}),t.type==="report"&&t.settings?.hide&&jsx(Tooltip,{label:"Hidden in explore/search",position:"top",children:jsx(IconEyeOff,{size:16,style:{marginLeft:4,color:i}})})]}),jsx(Badge,{variant:"light",children:t.type})]}),jsxs(Text,{size:"sm",style:{color:i,lineHeight:2},children:["Order in explore/search: ",(t.type==="report"?t.settings?.order:void 0)??0]}),jsx(Space,{w:"xs"}),jsxs(Group,{position:"apart",children:[jsx(TP,{href:n.href("reports",t.id),passHref:true,children:jsx(Button,{leftIcon:jsx(IconPencil,{}),compact:true,children:"Edit"})}),jsx(ar,{type:"report",id:t.id,disabled:!o})]})]})}Xt(qy,zt);ae();xe();dt();p();var jA=e=>(e&&e.bespoke_app_metadata&&e.bespoke_app_metadata.reports&&Array.isArray(e.bespoke_app_metadata.reports)?e.bespoke_app_metadata.reports:[]).map(o=>o.reportId);function XA(){let e=ie(),[t,o]=useState(false),{user:r}=Pe(),n=jA(r),i=ts(),a=useCallback(s=>{o(true),e(Z.createEntity("report",s)).then(c=>{c.ok&&n.length>0||o(false);});},[]),l=useMemo(()=>i.isUninitialized||i.isFetching?jsx(LoadingOverlay,{visible:true,overlayBlur:2}):i.isError?jsx(Alert,{icon:jsx(IconFileAnalytics,{size:22}),title:"Server Error",children:i.error.message}):i.data.length===0?jsx(Alert,{icon:jsx(IconFileAnalytics,{size:22}),title:"No Saved Reports",children:"Please use the button below to create your first report."}):jsx(Stack,{children:i.data.sort((s,c)=>{let u=(s.type==="report"?s.settings?.order:void 0)??0,d=(c.type==="report"?c.settings?.order:void 0)??0;return u-d}).map(s=>jsx(qy,{for:s,enabled:!!(n.length===0||n.includes(s.id))},s.id))}),[i.data,i.error,i.status,n]);return jsxs(Container,{size:"xl",children:[jsx("h1",{children:"Reports"}),jsx(LoadingOverlay,{visible:t,overlayBlur:2,overlayOpacity:.5}),l,jsx(Space,{h:"xl",w:"xl"}),jsx(hs,{fields:[{type:"text",name:"name",label:"Report Name",initialValue:""}],onSubmit:a,target:jsx(ActionIcon,{size:"xl",radius:"xl",children:jsx(IconPlus,{size:30})})})]})}p();dt();function ZA(){let{user:e}=Pe(),t={color:"#000"};return jsxs(Flex,{mih:"100vh",gap:"md",justify:"center",align:"center",direction:"column",wrap:"wrap",style:{background:"white"},children:[jsx(Title,{style:t,children:"Unauthorize or forbidden access."}),jsxs(Title,{style:t,order:2,children:["Sorry, ",e?.name,"!"]}),jsx(Text,{style:t,children:"Your session or your user's roles doesn't satisfy the needs of the requested view. Please, ask your administrator to allow you."}),jsxs(Group,{children:[jsx(Button,{component:"a",href:"/",leftIcon:jsx(IconHome,{size:14}),variant:"outline",color:"dark",children:"Back to homepage"}),jsx(Button,{onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),leftIcon:jsx(IconLogout,{size:14}),variant:"outline",color:"dark",children:"Disconnect"})]})]})}p();ae();p();var eP={value:"all",label:"All"},c8=e=>{if(!e)return [];let t=e.map(o=>({value:String(o.id),label:`${o.name} (${o.type})`}));return [eP,...t]};function tP({onChange:e,loading:t,roles:o}){let r={role_id:eP.value,query:"",page:0},[n,i]=useState(r),[a]=useDebouncedValue(n.query,500),l=useMemo(()=>({roles:c8(o)}),[o]),s=useCallback((u,d)=>{let m={...n,[u]:d};i(m);},[n]),c=()=>{i(r);};return useEffect(()=>{e({...n,query:a});},[n.role_id,n.page,a]),jsxs("div",{children:[jsx(Select,{label:"Roles",data:l.roles,value:n.role_id,onChange:u=>s("role_id",u),disabled:t}),jsx(TextInput,{label:"Search by name or email",value:n.role_id!=="all"?"":n.query,onChange:u=>s("query",u.currentTarget.value),disabled:t||n.role_id!=="all"}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconCircleX,{}),onClick:c,children:"Clear filters"})]})}p();dt();p();ae();Tn();function oP({reportId:e,onSelectFavorites:t,onClickDelete:o}){let r=zt(e),n=ps(e),{data:i}=$l(),a=i?.reduce((m,g)=>(g.report_id===e&&(m[g.id]=g),m),{})||{},l=H(m=>m.status.localeDefault),s=r.data,[c,u]=useState(s?s.dimensions.map(()=>{}):[void 0]),d=(m,g)=>{let f=[...c];f[m]=g?{variantId:parseInt(g.variant_id,10),contentId:parseInt(g.content_id,10)}:void 0,u(f),f.some(h=>typeof h>"u")||t(e,f);};return useEffect(()=>{r.isError&&o(e);},[r.isError]),jsx(Stack,{children:s&&jsxs(Fragment,{children:[jsxs(Group,{spacing:"xl",align:"center",children:[jsxs(Text,{children:["Report: ",s.name]}),jsx(ActionIcon,{size:"md",color:"red",onClick:()=>o(e),children:jsx(IconTrash,{})})]}),s.dimensions.length===0&&jsx(Group,{children:jsxs(Text,{c:"dimmed",fz:"sm",children:["No dimensions created in report ",s.name," yet."]})}),s.dimensions.map((m,g)=>jsxs(Group,{children:[jsxs(Text,{tt:"uppercase",fz:"0.6rem",fw:700,color:"gray.6",children:[a[m].name,":"]}),jsx(Zu,{dimensionId:m,value:n?{variantId:n[g].variantId,memberId:n[g].contentId}:void 0,onSelect:f=>d(g,f),locale:l},m)]},m))]})})}ae();p();ae();function rP({selectedReportId:e="",onChangeReport:t,exclude:o=[]}){let r=ts(),n=l=>{t(l);},a=useMemo(()=>r.isSuccess?r.data.map(l=>({value:`${l.id}`,label:l.name})):[],[r.status]).filter(l=>!o.includes(l.value));return jsx(Select,{style:{width:100},size:"xs",placeholder:"Choose a report",data:a,value:String(e),onChange:n,disabled:a.length===0})}var I8=e=>e?e.map(t=>({value:String(t.id),label:t.name,group:t.type})):[];function lP({userId:e,onEditEnd:t,roles:o}){let r=ie(),{user:n,update:i}=Pe(),[a,l]=useState(null),[s,c]=useState(true),[u,d]=useState(false),[m]=useState(""),[g,f]=useState(true),[h,v]=useState(""),T=useForm(),y=useMemo(()=>!!(n&&n.id===e),[n]),C=!!e,b=useMemo(()=>({roles:I8(o)}),[o]),w=a&&a.app_metadata&&a.app_metadata.reports?a.app_metadata.reports:[],k=w.map(A=>String(A.reportId)),I=async()=>{c(true),d(false);let A=await r(Z.readUser(e)).then(j=>j);l(A),T.setValues(A);let V=A&&A.app_metadata&&A.app_metadata.reports?A.app_metadata.reports:[];f(V.length===0),c(false);};useEffect(()=>{e?I():l(null);},[e]);let O=async()=>{if(c(true),a){let A={roles:a.roles,app_metadata:a.app_metadata};await r(Z.updateUser({user:{user_id:a.user_id,...A}})).then(()=>{y?(console.info("its YOU! Refreshing page to grab new change on session",A),i()):(c(false),t());});}},P=A=>{let V=A.map($=>o.find(Y=>Y.id===$)).filter($=>$),j=V.find($=>$.name===Pr.EDITOR);V.find($=>$.name===Pr.ADMIN);let U=a?a.app_metadata:{};j||(U={...U,reports:[]},f(true)),l({...a,roles:V,app_metadata:U});},_=A=>{v(A);},D=()=>{if(a&&h){let A=a.app_metadata&&a.app_metadata.reports?a.app_metadata.reports:[];A.push({reportId:parseInt(h,10),favorites:[]}),l({...a,app_metadata:{...a.app_metadata,reports:A}}),v("");}},L=A=>{if(a&&A){let V=a.app_metadata&&a.app_metadata.reports?a.app_metadata.reports:[];l({...a,app_metadata:{...a.app_metadata,reports:V.filter(j=>parseInt(`${j.reportId}`,10)!==parseInt(A,10))}});}},R=A=>{f(A.currentTarget.checked),a&&l({...a,app_metadata:{...a.app_metadata,reports:[]}});},z=(A,V)=>{if(a){let B=(a.app_metadata&&a.app_metadata.reports?[...a.app_metadata.reports]:[]).map(U=>(U.reportId===A&&(U.favorites=V),U));l({...a,app_metadata:{...a.app_metadata,reports:B}});}};return jsx(Fragment,{children:jsx(Drawer,{opened:C,onClose:()=>t(),title:jsxs(Fragment,{children:["Edit user ID ",e," ",y?jsx(Badge,{children:"YOU"}):""]}),padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"50%",lockScroll:true,withCloseButton:false,children:jsx(Po,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:s,overlayBlur:2,overlayOpacity:.5}),u&&jsx(Alert,{title:"Member Form",color:"red",children:"Error, please try again."}),n&&!u&&jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",disabled:true,label:"Name",...T.getInputProps("name")}),jsx(TextInput,{mt:"xs",disabled:true,label:"email",...T.getInputProps("email")})]}),jsxs(Stack,{children:[jsx(Title,{order:2,children:"Roles:"}),jsx(MultiSelect,{data:b.roles,onChange:P,value:(a?.roles||[]).map(A=>A.id),error:m})]}),a&&(a.roles||[]).map(A=>A.name).includes(Pr.EDITOR)&&jsxs(Stack,{children:[jsx(Title,{order:4,children:"Editor settings:"}),jsxs(Group,{children:[jsx(Text,{children:"Edit selected reports only"}),jsx(Switch,{label:"",checked:g,onChange:R}),jsx(Text,{children:"Edit all reports"})]}),!g&&jsxs(Fragment,{children:[jsxs(Group,{grow:true,children:[jsx(rP,{selectedReportId:h,onChangeReport:_,exclude:k}),jsx(Button,{variant:"outline",disabled:s||!h&&h==="",onClick:D,children:"Add Report"})]}),w.map(A=>jsx(Stack,{children:jsx(oP,{reportId:A.reportId,initialFavorites:A.favorites,onSelectFavorites:z,onClickDelete:L})},A.reportId))]})]})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:s,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:O,loading:s,disabled:s,children:"Save User"})]}),size:165})})})}p();function cP({response:e,onClickEdit:t,onPageChange:o}){let[r,n]=useState([]),[i,a]=useState({pageIndex:0,pageSize:10}),[l,s]=useState(0);return useEffect(()=>{o(i.pageIndex+1);},[i.pageIndex]),useEffect(()=>{e&&(n(e.users),s(e.total));},[e]),useEffect(()=>{n(e);},[]),jsx(MantineReactTable,{columns:[{header:"",accessorKey:"image",Cell:({row:u})=>jsx(Avatar,{src:u.original.picture,alt:`${u.original.name}`,radius:20}),size:50,mantineTableBodyCellProps:{align:"center"}},{header:"Name",accessorKey:"name"},{header:"Email",accessorKey:"email"},{header:"Actions",accessorKey:"actions",Cell:({row:u})=>jsx(ActionIcon,{onClick:()=>t(u.original),children:jsx(IconPencil,{size:20})},"edit"),size:100,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}],data:r,enableColumnActions:false,enablePagination:true,enableSorting:false,enableTopToolbar:false,initialState:{density:"xs"},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150}},manualPagination:true,onPaginationChange:a,paginationDisplayMode:"pages",rowCount:l,state:{pagination:{pageIndex:i.pageIndex,pageSize:i.pageSize}}})}function pP(){let[e,t]=useState(null),[o,r]=useState([]),[n,i]=useState([]),[a,l]=useState(true),[s,c]=useState({query:""}),u=ie(),d=v=>{c(v);},m=v=>{c({...s,page:v});},g=v=>{t(v.user_id);},f=()=>{t(null),h();},h=async()=>{l(true);let v={query:s.query};s.role_id&&s.role_id!=="all"&&(v.role_id=s.role_id),v.page=s.page?s.page-1:0,u(Z.searchUser(v)).then(T=>{r(T),l(false);});};return useEffect(()=>{l(true),u(Z.searchRole()).then(v=>{i(v.roles),l(false);});},[u]),useEffect(()=>{h();},[s]),jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Users Management"}),jsx(tP,{onChange:d,loading:a,roles:n})]}),jsxs(Grid.Col,{span:10,style:{height:"100vh",position:"relative"},children:[jsx(LoadingOverlay,{visible:a,overlayBlur:2,overlayOpacity:.5}),jsx(Space,{h:"xs"}),jsx(cP,{response:o,onClickEdit:g,onPageChange:m})]})]}),e&&jsx(lP,{userId:e,onEditEnd:f,roles:n})]})}Bp();Bl();Ya();ae();dt();function i9(e){let{title:t="Bespoke CMS",pathSegment:o="bespoke",locale:r=Er,profilePrefix:n="/profilePathManager",previewPrefix:i=null}=e,a={position:"bottom-center",...e.notifications};return l;function l(s){let{bespokeVersion:c}=s;return jsxs(qS,{pathSegment:o,profilePrefix:n,previewPrefix:i,children:[jsx(Q8,{children:jsx("title",{children:t})}),jsxs(MantineProvider,{inherit:false,children:[jsx(Notifications,{...a}),jsx(dv,{children:jsx(An,{fallback:jsx("p",{children:"Client side error in Bespoke. Check the console for details."}),children:jsx(s9,{locale:r,version:c})})})]})]})}}var fP=[{icon:jsx(IconBallpen,{size:24}),color:"blue",label:"Reports Builder",href:"reports",roleRequired:Pr.EDITOR},{icon:jsx(IconDatabase,{size:24}),color:"teal",label:"Metadata Editor",href:"metadata",roleRequired:Pr.EDITOR},{icon:jsx(IconMathFunction,{size:24}),color:"violet",label:"Formatters List",href:"formatters",roleRequired:Pr.EDITOR},{icon:jsx(IconNetwork,{size:24}),color:"violet",label:"Data Sources",href:"datasources",roleRequired:Pr.EDITOR},{icon:jsx(IconUsers,{size:24}),color:"pink",label:"Users Management",href:"users",roleRequired:Pr.ADMIN}];function a9(){let e=ie(),{user:t,isLoading:o}=cs(),r=t.bespoke_user_metadata.preferredLocale,[n,i]=useState("idle"),{update:a}=Pe();return o?null:jsx(ql,{onChange:s=>{let c={user_metadata:{preferredLocale:s}};i("loading"),e(Z.updateMyData(c)).then(u=>{u.ok&&(e(Z.setPreferredLocale(s)),a(),i("idle"));});},defaultValue:r,loading:n==="loading",selectProps:{size:"xs",label:"User Locale",styles:{root:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}}})}function s9(e){let{locale:t,version:o}=e,r=useRef(null),[n,{open:i,close:a}]=useDisclosure(false),{user:l,isLoading:s}=cs(),c=Jt(),u=useCallback(f=>{let h=[];return fP.forEach(v=>{h.push(jsx(l9,{item:v,disabled:f&&Array.isArray(f.bespoke_roles)?!f.bespoke_roles.includes(v.roleRequired):false},v.label));}),h},[]),d=useMemo(()=>{let f=u(l),h=c.page==="welcome"||n;return jsx(Fragment,{children:jsx(Box,{w:h?240:50,sx:{zIndex:99,overflow:"hidden",transition:"width .3s",boxShadow:"0px 4px 15px 5px rgba(0, 0, 0, 0.05)"},h:"100%",top:0,bottom:0,left:0,pos:"fixed",bg:"#F6F6F6",p:0,children:jsxs(Navbar,{p:0,w:240,hiddenBreakpoint:1e5,pos:"relative",pt:40,top:0,pb:30,h:"100vh",width:{base:240},onMouseEnter:()=>{r.current="open",setTimeout(()=>{r.current==="open"&&i();},200);},onMouseLeave:()=>{r.current="close",setTimeout(()=>{r.current==="close"&&a();},350);},withBorder:false,children:[jsx(Navbar.Section,{style:{position:"relative"},children:jsx(av,{href:c.href(""),onlyIcon:!h,version:o})}),jsx(Navbar.Section,{grow:true,component:ScrollArea,children:jsx(Stack,{spacing:0,children:f})}),jsx(Navbar.Section,{children:l&&!s&&jsx(Fragment,{children:jsxs(Stack,{px:13,children:[jsxs(Group,{align:"flex-start",children:[jsx("div",{children:jsx(Avatar,{src:l.picture,radius:"xl",size:"sm"})}),h&&jsxs(Stack,{sx:{flex:1},spacing:"xs",children:[jsxs(Box,{children:[jsx(Text,{size:"sm",weight:500,lh:1,sx:{flexGrow:1},children:l.name}),jsx(Text,{color:"dimmed",size:"xs",children:l.email})]}),jsx(a9,{})]})]}),h&&jsx(Stack,{children:jsx(Button,{px:13,onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),compact:true,size:"xs",variant:"outline",leftIcon:jsx(IconLogout,{size:14}),children:"Disconnect"})})]})})})]})})})},[c,n,l]),m=useMemo(()=>{let f=fP.find(h=>h.href.includes(c.page));if(c.page==="welcome")return jsx(kA,{});if(l&&Array.isArray(l.bespoke_roles)&&l.bespoke_roles.includes(f?.roleRequired)){if(c.page==="metadata")return jsx(VA,{});if(c.page==="formatters")return jsx(lA,{});if(c.page==="datasources")return jsx(TA,{});if(c.page==="reports"){if(c.params.length>0){let h=Number.parseInt(c.params[0]);return jsx(G0,{id:h,locale:t})}return jsx(XA,{})}if(c.page==="users")return jsx(pP,{})}else return jsx(ZA,{});return jsx(GA,{})},[c,l]),g=ie();return useEffect(()=>{g(Io.setStatus({isCMS:true}));},[]),jsx(AppShell,{styles:{main:{background:"#f8f9fa",paddingLeft:50,paddingTop:0}},fixed:true,padding:0,navbar:d,children:m})}function l9({item:e,disabled:t}){let{page:o}=Jt(),r=o&&o.includes(e.href);return jsx(TP,{href:e.href,passHref:true,children:jsx(UnstyledButton,{disabled:t,py:"sm",px:13,bg:r?"blue.1":"transparent",w:"100%",display:"block",sx:{display:"block",width:"100%","&:hover":{backgroundColor:"#f9f9f9"}},children:jsxs(Group,{spacing:24,children:[jsx(ThemeIcon,{size:24,color:r?"blue.5":"gray.6",bg:"transparent",variant:"light",sx:{flexShrink:0},children:e.icon}),jsx(Text,{size:"sm",fw:r?700:500,color:r?"blue.5":"gray.6",children:e.label})]})})},e.label)}/*! Bundled license information:
94
+ `,children:jsx(NumberInput,{disabled:!O.values.visible,type:"number",precision:4,step:1e-4,removeTrailingZeros:true,min:0,max:1,decimalSeparator:".",...O.getInputProps("zvalue")})}),jsx(Checkbox,{mt:"2.3rem",label:"Visible in search",...O.getInputProps("visible",{type:"checkbox"})})]}),jsx(Group,{mt:"xs",position:"apart",grow:true,children:jsx(SegmentedControl,{value:a,onChange:l,data:n})}),!$&&jsx(Alert,{title:"Unavailable locale",color:"blue",children:"This language was not ingested for the current member. Go to variant editor and provide the members there."}),$&&jsxs(Fragment,{children:[jsx(Group,{mt:"xs",position:"apart",grow:true,children:jsx(TextInput,{label:"Name",...A[a].getInputProps("name")})}),jsx(Group,{mt:"xs",position:"apart",align:"top",grow:true,children:jsx(MultiSelect,{label:"Keywords",data:A[a].values.keywords,placeholder:"Enter keywords",searchable:true,creatable:true,valueComponent:({label:z})=>jsxs(Badge,{onClick:()=>{let q=A[a].values.keywords;A[a].setFieldValue("keywords",q.filter(W=>W!==z));},children:[z," ","x"]}),getCreateLabel:z=>`+ Create ${z}`,value:A[a].values.keywords,onCreate:z=>{let q=A[a].values.keywords;return A[a].setFieldValue("keywords",[...q,z]),z}})}),jsx(Input.Wrapper,{label:"Attributes",children:jsx(bp,{data:A[a].values.attributes})})]})]})}),jsx(Tabs.Panel,{value:"image",py:"md",children:jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{position:"apart",grow:true,children:[jsxs(Stack,{children:[jsx(Zl,{member:s,forceRefreshTimestamp:true}),jsx(Button,{variant:"outline",disabled:u,leftIcon:jsx(IconPolaroid,{}),onClick:()=>g(true),children:"Change image"}),s&&s.image&&jsx(Button,{variant:"outline",disabled:u,leftIcon:jsx(IconCircleMinus,{}),onClick:()=>N(),children:"Remove image"}),jsx(Space,{h:"md"})]}),jsxs(Stack,{justify:"flex-start",children:[jsx(TextInput,{disabled:!s||!s.image,label:"Source",...B.getInputProps("url")}),jsx(TextInput,{disabled:!s||!s.image,label:"Author",...B.getInputProps("author")}),jsx(TextInput,{disabled:!s||!s.image,label:"License",...B.getInputProps("license")}),jsx(SegmentedControl,{disabled:!s||!s.image,value:a,onChange:l,data:n}),jsx(TextInput,{disabled:!s||!s.image,label:"Alternative image text",..._[a].getInputProps("meta")})]})]}),v&&jsx(Loader,{}),!v&&b.length>0&&jsxs(Fragment,{children:[jsx(Text,{children:"Select the members you want to update with the same image."}),jsx(vs,{members:b,colsToRender:["id","report","name","slug","image"],dataTableProps:V})]})]})})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:u,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:j,loading:u,disabled:u,children:"Save Member"})]}),size:165})}),f&&jsx(MA,{member:s,onEditEnd:M})]})}function $A(){let[e,t]=useState(null),[o,r]=useState([]),[n,i]=useState(true),[a,l]=useState(true),[s,c]=useState(),[u,d]=useState(1),[f,g]=useState(0),m=C=>{l(C),d(1);},h=C=>{C&&C.length&&c(C[0]);},y=C=>{t(C.content_id);},S=()=>{t(null),v();},v=async()=>{i(true);let C=Object.keys({...a}).reduce((k,w)=>(a[w]!=="all"&&(k[w]=a[w]),k),{}),b=await Mu.get("/api/cms/search/members",{params:{...C,offset:(u-1)*parseInt(C.limit||"10",10),locale:"all",includes:true,sort:s?s.id:"zvalue",direction:s?s.desc?"desc":"asc":"desc",origin:"flexsearch"}}).then(k=>{let w=k.data&&k.data.data&&k.data.data.meta?Object.keys(k.data.data.meta.variantCount).reduce((R,O)=>{let A=k.data.data.meta.variantCount[O];return a.paginationVariants&&a.paginationVariants.length>0&&(a.paginationVariants.includes(O)||(A=0)),R+A},0):0;return g(w),k.data&&k.data.data&&k.data.data.results?k.data.data.results:[]});r(b),i(false);};return useEffect(()=>{a.limit&&v();},[a,s,u]),jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Metadata"}),jsx(IA,{onChange:m,loading:n})]}),jsxs(Grid.Col,{span:10,style:{height:"95vh",position:"relative"},children:[jsx(LoadingOverlay,{visible:n,overlayBlur:2,overlayOpacity:.5}),jsx(Space,{h:"xs"}),jsx(vs,{members:o,onClickEdit:y,onSort:h}),jsx(Group,{position:"center",children:jsx(Pagination,{value:u,onChange:d,total:Math.ceil(f/(a.limit||10)),size:"sm",py:"xs"})})]})]}),e&&jsx(VA,{memberId:e,onEditEnd:S})]})}p();Xe();function HA(){let{user:e}=we(),t={color:"#000"};return jsxs(Flex,{mih:"100vh",gap:"md",justify:"center",align:"center",direction:"column",wrap:"wrap",style:{background:"white"},children:[jsx(Title,{style:t,children:"Not found."}),jsxs(Title,{order:2,style:t,children:["Sorry, ",e?.name,"!"]}),jsx(Text,{style:t,children:"The page you are looking for is not here."}),jsx(Button,{component:"a",href:"/",children:"Back to homepage"})]})}p();p();st();se();function Yy(e){let{for:t,enabled:o}=e,r=useMantineTheme(),n=Xt(),i=r.colorScheme==="dark"?r.colors.dark[1]:r.colors.gray[7];return jsxs(Card,{shadow:"xs",p:"sm",w:"100%",children:[jsxs(Group,{position:"apart",children:[jsxs(Center,{mah:24,children:[jsx(IconFileAnalytics,{size:22}),jsx(Text,{mx:"xs",weight:"bold",children:t.name}),t.type==="report"&&t.settings?.hide&&jsx(Tooltip,{label:"Hidden in explore/search",position:"top",children:jsx(IconEyeOff,{size:16,style:{marginLeft:4,color:i}})})]}),jsx(Badge,{variant:"light",children:t.type})]}),jsxs(Text,{size:"sm",style:{color:i,lineHeight:2},children:["Order in explore/search: ",(t.type==="report"?t.settings?.order:void 0)??0]}),jsx(Space,{w:"xs"}),jsxs(Group,{position:"apart",children:[jsx(CP,{href:n.href("reports",t.id),passHref:true,children:jsx(Button,{leftIcon:jsx(IconPencil,{}),compact:true,children:"Edit"})}),jsx(ir,{type:"report",id:t.id,disabled:!o})]})]})}Yt(Yy,zt);se();ye();Xe();p();var KA=e=>(e&&e.bespoke_app_metadata&&e.bespoke_app_metadata.reports&&Array.isArray(e.bespoke_app_metadata.reports)?e.bespoke_app_metadata.reports:[]).map(o=>o.reportId);function JA(){let e=ie(),[t,o]=useState(false),{user:r}=we(),n=KA(r),i=Za(),a=useCallback(s=>{o(true),e(Z.createEntity("report",s)).then(c=>{c.ok&&n.length>0||o(false);});},[]),l=useMemo(()=>i.isUninitialized||i.isFetching?jsx(LoadingOverlay,{visible:true,overlayBlur:2}):i.isError?jsx(Alert,{icon:jsx(IconFileAnalytics,{size:22}),title:"Server Error",children:i.error.message}):i.data.length===0?jsx(Alert,{icon:jsx(IconFileAnalytics,{size:22}),title:"No Saved Reports",children:"Please use the button below to create your first report."}):jsx(Stack,{children:i.data.sort((s,c)=>{let u=(s.type==="report"?s.settings?.order:void 0)??0,d=(c.type==="report"?c.settings?.order:void 0)??0;return u-d}).map(s=>jsx(Yy,{for:s,enabled:!!(n.length===0||n.includes(s.id))},s.id))}),[i.data,i.error,i.status,n]);return jsxs(Container,{size:"xl",children:[jsx("h1",{children:"Reports"}),jsx(LoadingOverlay,{visible:t,overlayBlur:2,overlayOpacity:.5}),l,jsx(Space,{h:"xl",w:"xl"}),jsx(fs,{fields:[{type:"text",name:"name",label:"Report Name",initialValue:""}],onSubmit:a,target:jsx(ActionIcon,{size:"xl",radius:"xl",children:jsx(IconPlus,{size:30})})})]})}p();Xe();function eP(){let{user:e}=we(),t={color:"#000"};return jsxs(Flex,{mih:"100vh",gap:"md",justify:"center",align:"center",direction:"column",wrap:"wrap",style:{background:"white"},children:[jsx(Title,{style:t,children:"Unauthorize or forbidden access."}),jsxs(Title,{style:t,order:2,children:["Sorry, ",e?.name,"!"]}),jsx(Text,{style:t,children:"Your session or your user's roles doesn't satisfy the needs of the requested view. Please, ask your administrator to allow you."}),jsxs(Group,{children:[jsx(Button,{component:"a",href:"/",leftIcon:jsx(IconHome,{size:14}),variant:"outline",color:"dark",children:"Back to homepage"}),jsx(Button,{onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),leftIcon:jsx(IconLogout,{size:14}),variant:"outline",color:"dark",children:"Disconnect"})]})]})}p();se();p();var tP={value:"all",label:"All"},u8=e=>{if(!e)return [];let t=e.map(o=>({value:String(o.id),label:`${o.name} (${o.type})`}));return [tP,...t]};function oP({onChange:e,loading:t,roles:o}){let r={role_id:tP.value,query:"",page:0},[n,i]=useState(r),[a]=useDebouncedValue(n.query,500),l=useMemo(()=>({roles:u8(o)}),[o]),s=useCallback((u,d)=>{let f={...n,[u]:d};i(f);},[n]),c=()=>{i(r);};return useEffect(()=>{e({...n,query:a});},[n.role_id,n.page,a]),jsxs("div",{children:[jsx(Select,{label:"Roles",data:l.roles,value:n.role_id,onChange:u=>s("role_id",u),disabled:t}),jsx(TextInput,{label:"Search by name or email",value:n.role_id!=="all"?"":n.query,onChange:u=>s("query",u.currentTarget.value),disabled:t||n.role_id!=="all"}),jsx(Space,{h:"md"}),jsx(Button,{fullWidth:true,disabled:t,leftIcon:jsx(IconCircleX,{}),onClick:c,children:"Clear filters"})]})}p();Xe();p();se();Sn();function rP({reportId:e,onSelectFavorites:t,onClickDelete:o}){let r=zt(e),n=cs(e),{data:i}=$l(),a=i?.reduce((f,g)=>(g.report_id===e&&(f[g.id]=g),f),{})||{},l=H(f=>f.status.localeDefault),s=r.data,[c,u]=useState(s?s.dimensions.map(()=>{}):[void 0]),d=(f,g)=>{let m=[...c];m[f]=g?{variantId:parseInt(g.variant_id,10),contentId:parseInt(g.content_id,10)}:void 0,u(m),m.some(h=>typeof h>"u")||t(e,m);};return useEffect(()=>{r.isError&&o(e);},[r.isError]),jsx(Stack,{children:s&&jsxs(Fragment,{children:[jsxs(Group,{spacing:"xl",align:"center",children:[jsxs(Text,{children:["Report: ",s.name]}),jsx(ActionIcon,{size:"md",color:"red",onClick:()=>o(e),children:jsx(IconTrash,{})})]}),s.dimensions.length===0&&jsx(Group,{children:jsxs(Text,{c:"dimmed",fz:"sm",children:["No dimensions created in report ",s.name," yet."]})}),s.dimensions.map((f,g)=>jsxs(Group,{children:[jsxs(Text,{tt:"uppercase",fz:"0.6rem",fw:700,color:"gray.6",children:[a[f].name,":"]}),jsx(ep,{dimensionId:f,value:n?{variantId:n[g].variantId,memberId:n[g].contentId}:void 0,onSelect:m=>d(g,m),locale:l},f)]},f))]})})}se();p();se();function nP({selectedReportId:e="",onChangeReport:t,exclude:o=[]}){let r=Za(),n=l=>{t(l);},a=useMemo(()=>r.isSuccess?r.data.map(l=>({value:`${l.id}`,label:l.name})):[],[r.status]).filter(l=>!o.includes(l.value));return jsx(Select,{style:{width:100},size:"xs",placeholder:"Choose a report",data:a,value:String(e),onChange:n,disabled:a.length===0})}var A8=e=>e?e.map(t=>({value:String(t.id),label:t.name,group:t.type})):[];function cP({userId:e,onEditEnd:t,roles:o}){let r=ie(),{user:n,update:i}=we(),[a,l]=useState(null),[s,c]=useState(true),[u,d]=useState(false),[f]=useState(""),[g,m]=useState(true),[h,y]=useState(""),S=useForm(),v=useMemo(()=>!!(n&&n.id===e),[n]),C=!!e,b=useMemo(()=>({roles:A8(o)}),[o]),k=a&&a.app_metadata&&a.app_metadata.reports?a.app_metadata.reports:[],w=k.map(M=>String(M.reportId)),R=async()=>{c(true),d(false);let M=await r(Z.readUser(e)).then(j=>j);l(M),S.setValues(M);let N=M&&M.app_metadata&&M.app_metadata.reports?M.app_metadata.reports:[];m(N.length===0),c(false);};useEffect(()=>{e?R():l(null);},[e]);let O=async()=>{if(c(true),a){let M={roles:a.roles,app_metadata:a.app_metadata};await r(Z.updateUser({user:{user_id:a.user_id,...M}})).then(()=>{v?(console.info("its YOU! Refreshing page to grab new change on session",M),i()):(c(false),t());});}},A=M=>{let N=M.map(z=>o.find(q=>q.id===z)).filter(z=>z),j=N.find(z=>z.name===Ir.EDITOR);N.find(z=>z.name===Ir.ADMIN);let V=a?a.app_metadata:{};j||(V={...V,reports:[]},m(true)),l({...a,roles:N,app_metadata:V});},B=M=>{y(M);},_=()=>{if(a&&h){let M=a.app_metadata&&a.app_metadata.reports?a.app_metadata.reports:[];M.push({reportId:parseInt(h,10),favorites:[]}),l({...a,app_metadata:{...a.app_metadata,reports:M}}),y("");}},P=M=>{if(a&&M){let N=a.app_metadata&&a.app_metadata.reports?a.app_metadata.reports:[];l({...a,app_metadata:{...a.app_metadata,reports:N.filter(j=>parseInt(`${j.reportId}`,10)!==parseInt(M,10))}});}},I=M=>{m(M.currentTarget.checked),a&&l({...a,app_metadata:{...a.app_metadata,reports:[]}});},F=(M,N)=>{if(a){let $=(a.app_metadata&&a.app_metadata.reports?[...a.app_metadata.reports]:[]).map(V=>(V.reportId===M&&(V.favorites=N),V));l({...a,app_metadata:{...a.app_metadata,reports:$}});}};return jsx(Fragment,{children:jsx(Drawer,{opened:C,onClose:()=>t(),title:jsxs(Fragment,{children:["Edit user ID ",e," ",v?jsx(Badge,{children:"YOU"}):""]}),padding:"lg",closeOnClickOutside:false,closeOnEscape:false,position:"right",size:"50%",lockScroll:true,withCloseButton:false,children:jsx(Ao,{content:jsxs(Fragment,{children:[jsx(LoadingOverlay,{visible:s,overlayBlur:2,overlayOpacity:.5}),u&&jsx(Alert,{title:"Member Form",color:"red",children:"Error, please try again."}),n&&!u&&jsxs(Stack,{justify:"space-between",children:[jsxs(Group,{position:"apart",grow:true,children:[jsx(TextInput,{mt:"xs",disabled:true,label:"Name",...S.getInputProps("name")}),jsx(TextInput,{mt:"xs",disabled:true,label:"email",...S.getInputProps("email")})]}),jsxs(Stack,{children:[jsx(Title,{order:2,children:"Roles:"}),jsx(MultiSelect,{data:b.roles,onChange:A,value:(a?.roles||[]).map(M=>M.id),error:f})]}),a&&(a.roles||[]).map(M=>M.name).includes(Ir.EDITOR)&&jsxs(Stack,{children:[jsx(Title,{order:4,children:"Editor settings:"}),jsxs(Group,{children:[jsx(Text,{children:"Edit selected reports only"}),jsx(Switch,{label:"",checked:g,onChange:I}),jsx(Text,{children:"Edit all reports"})]}),!g&&jsxs(Fragment,{children:[jsxs(Group,{grow:true,children:[jsx(nP,{selectedReportId:h,onChangeReport:B,exclude:w}),jsx(Button,{variant:"outline",disabled:s||!h&&h==="",onClick:_,children:"Add Report"})]}),k.map(M=>jsx(Stack,{children:jsx(rP,{reportId:M.reportId,initialFavorites:M.favorites,onSelectFavorites:F,onClickDelete:P})},M.reportId))]})]})]})]}),buttons:jsxs(Fragment,{children:[jsx(Button,{variant:"outline",disabled:s,onClick:()=>t(),children:"Cancel"}),jsx(Button,{onClick:O,loading:s,disabled:s,children:"Save User"})]}),size:165})})})}p();function uP({response:e,onClickEdit:t,onPageChange:o}){let[r,n]=useState([]),[i,a]=useState({pageIndex:0,pageSize:10}),[l,s]=useState(0);return useEffect(()=>{o(i.pageIndex+1);},[i.pageIndex]),useEffect(()=>{e&&(n(e.users),s(e.total));},[e]),useEffect(()=>{n(e);},[]),jsx(MantineReactTable,{columns:[{header:"",accessorKey:"image",Cell:({row:u})=>jsx(Avatar,{src:u.original.picture,alt:`${u.original.name}`,radius:20}),size:50,mantineTableBodyCellProps:{align:"center"}},{header:"Name",accessorKey:"name"},{header:"Email",accessorKey:"email"},{header:"Actions",accessorKey:"actions",Cell:({row:u})=>jsx(ActionIcon,{onClick:()=>t(u.original),children:jsx(IconPencil,{size:20})},"edit"),size:100,mantineTableHeadCellProps:{align:"center"},mantineTableBodyCellProps:{align:"center"}}],data:r,enableColumnActions:false,enablePagination:true,enableSorting:false,enableTopToolbar:false,initialState:{density:"xs"},layoutMode:"grid",mantineTableContainerProps:{sx:{minHeight:150}},manualPagination:true,onPaginationChange:a,paginationDisplayMode:"pages",rowCount:l,state:{pagination:{pageIndex:i.pageIndex,pageSize:i.pageSize}}})}function dP(){let[e,t]=useState(null),[o,r]=useState([]),[n,i]=useState([]),[a,l]=useState(true),[s,c]=useState({query:""}),u=ie(),d=y=>{c(y);},f=y=>{c({...s,page:y});},g=y=>{t(y.user_id);},m=()=>{t(null),h();},h=async()=>{l(true);let y={query:s.query};s.role_id&&s.role_id!=="all"&&(y.role_id=s.role_id),y.page=s.page?s.page-1:0,u(Z.searchUser(y)).then(S=>{r(S),l(false);});};return useEffect(()=>{l(true),u(Z.searchRole()).then(y=>{i(y.roles),l(false);});},[u]),useEffect(()=>{h();},[s]),jsxs(Container,{fluid:true,children:[jsxs(Grid,{children:[jsxs(Grid.Col,{span:2,children:[jsx(Text,{ml:"xl",my:"sm",weight:"bold",children:"Users Management"}),jsx(oP,{onChange:d,loading:a,roles:n})]}),jsxs(Grid.Col,{span:10,style:{height:"100vh",position:"relative"},children:[jsx(LoadingOverlay,{visible:a,overlayBlur:2,overlayOpacity:.5}),jsx(Space,{h:"xs"}),jsx(uP,{response:o,onClickEdit:g,onPageChange:f})]})]}),e&&jsx(cP,{userId:e,onEditEnd:m,roles:n})]})}Dp();Ml();qa();se();Xe();function a9(e){let{title:t="Bespoke CMS",pathSegment:o="bespoke",locale:r=kr,profilePrefix:n="/profilePathManager",previewPrefix:i=null}=e,a={position:"bottom-center",...e.notifications};return l;function l(s){let{bespokeVersion:c}=s;return jsxs(YS,{pathSegment:o,profilePrefix:n,previewPrefix:i,children:[jsx(Z8,{children:jsx("title",{children:t})}),jsxs(MantineProvider,{inherit:false,children:[jsx(Notifications,{...a}),jsx(mv,{children:jsx(Rn,{fallback:jsx("p",{children:"Client side error in Bespoke. Check the console for details."}),children:jsx(l9,{locale:r,version:c})})})]})]})}}var gP=[{icon:jsx(IconBallpen,{size:24}),color:"blue",label:"Reports Builder",href:"reports",roleRequired:Ir.EDITOR},{icon:jsx(IconDatabase,{size:24}),color:"teal",label:"Metadata Editor",href:"metadata",roleRequired:Ir.EDITOR},{icon:jsx(IconMathFunction,{size:24}),color:"violet",label:"Formatters List",href:"formatters",roleRequired:Ir.EDITOR},{icon:jsx(IconNetwork,{size:24}),color:"violet",label:"Data Sources",href:"datasources",roleRequired:Ir.EDITOR},{icon:jsx(IconUsers,{size:24}),color:"pink",label:"Users Management",href:"users",roleRequired:Ir.ADMIN}];function s9(){let e=ie(),{user:t,isLoading:o}=ss(),r=t.bespoke_user_metadata.preferredLocale,[n,i]=useState("idle"),{update:a}=we();return o?null:jsx(ql,{onChange:s=>{let c={user_metadata:{preferredLocale:s}};i("loading"),e(Z.updateMyData(c)).then(u=>{u.ok&&(e(Z.setPreferredLocale(s)),a(),i("idle"));});},defaultValue:r,loading:n==="loading",selectProps:{size:"xs",label:"User Locale",styles:{root:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}}})}function l9(e){let{locale:t,version:o}=e,r=useRef(null),[n,{open:i,close:a}]=useDisclosure(false),{user:l,isLoading:s}=ss(),c=Xt(),u=useCallback(m=>{let h=[];return gP.forEach(y=>{h.push(jsx(c9,{item:y,disabled:m&&Array.isArray(m.bespoke_roles)?!m.bespoke_roles.includes(y.roleRequired):false},y.label));}),h},[]),d=useMemo(()=>{let m=u(l),h=c.page==="welcome"||n;return jsx(Fragment,{children:jsx(Box,{w:h?240:50,sx:{zIndex:99,overflow:"hidden",transition:"width .3s",boxShadow:"0px 4px 15px 5px rgba(0, 0, 0, 0.05)"},h:"100%",top:0,bottom:0,left:0,pos:"fixed",bg:"#F6F6F6",p:0,children:jsxs(Navbar,{p:0,w:240,hiddenBreakpoint:1e5,pos:"relative",pt:40,top:0,pb:30,h:"100vh",width:{base:240},onMouseEnter:()=>{r.current="open",setTimeout(()=>{r.current==="open"&&i();},200);},onMouseLeave:()=>{r.current="close",setTimeout(()=>{r.current==="close"&&a();},350);},withBorder:false,children:[jsx(Navbar.Section,{style:{position:"relative"},children:jsx(sv,{href:c.href(""),onlyIcon:!h,version:o})}),jsx(Navbar.Section,{grow:true,component:ScrollArea,children:jsx(Stack,{spacing:0,children:m})}),jsx(Navbar.Section,{children:l&&!s&&jsx(Fragment,{children:jsxs(Stack,{px:13,children:[jsxs(Group,{align:"flex-start",children:[jsx("div",{children:jsx(Avatar,{src:l.picture,radius:"xl",size:"sm"})}),h&&jsxs(Stack,{sx:{flex:1},spacing:"xs",children:[jsxs(Box,{children:[jsx(Text,{size:"sm",weight:500,lh:1,sx:{flexGrow:1},children:l.name}),jsx(Text,{color:"dimmed",size:"xs",children:l.email})]}),jsx(s9,{})]})]}),h&&jsx(Stack,{children:jsx(Button,{px:13,onClick:()=>signOut({callbackUrl:process.env.NEXT_PUBLIC_REPORTS_BASE_URL||"/"}),compact:true,size:"xs",variant:"outline",leftIcon:jsx(IconLogout,{size:14}),children:"Disconnect"})})]})})})]})})})},[c,n,l]),f=useMemo(()=>{let m=gP.find(h=>h.href.includes(c.page));if(c.page==="welcome")return jsx(EA,{});if(l&&Array.isArray(l.bespoke_roles)&&l.bespoke_roles.includes(m?.roleRequired)){if(c.page==="metadata")return jsx($A,{});if(c.page==="formatters")return jsx(cA,{});if(c.page==="datasources")return jsx(CA,{});if(c.page==="reports"){if(c.params.length>0){let h=Number.parseInt(c.params[0]);return jsx(H0,{id:h,locale:t})}return jsx(JA,{})}if(c.page==="users")return jsx(dP,{})}else return jsx(eP,{});return jsx(HA,{})},[c,l]),g=ie();return useEffect(()=>{g(Ro.setStatus({isCMS:true}));},[]),jsx(AppShell,{styles:{main:{background:"#f8f9fa",paddingLeft:50,paddingTop:0}},fixed:true,padding:0,navbar:d,children:f})}function c9({item:e,disabled:t}){let{page:o}=Xt(),r=o&&o.includes(e.href);return jsx(CP,{href:e.href,passHref:true,children:jsx(UnstyledButton,{disabled:t,py:"sm",px:13,bg:r?"blue.1":"transparent",w:"100%",display:"block",sx:{display:"block",width:"100%","&:hover":{backgroundColor:"#f9f9f9"}},children:jsxs(Group,{spacing:24,children:[jsx(ThemeIcon,{size:24,color:r?"blue.5":"gray.6",bg:"transparent",variant:"light",sx:{flexShrink:0},children:e.icon}),jsx(Text,{size:"sm",fw:r?700:500,color:r?"blue.5":"gray.6",children:e.label})]})})},e.label)}/*! Bundled license information:
95
95
 
96
96
  @tanstack/react-virtual/build/lib/_virtual/_rollupPluginBabelHelpers.mjs:
97
97
  @tanstack/react-virtual/build/lib/index.mjs:
@@ -119,4 +119,4 @@ return {
119
119
  *
120
120
  * @license MIT
121
121
  *)
122
- */export{i9 as BespokeManager};
122
+ */export{a9 as BespokeManager};