PageSourceSearch

https://facilitatethefuture.com/assets/SpaceSettings-CWLOBgUK.js

js facilitatethefuture.com collected 2026-10-01 01:45:29 UTC 196,425 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.esm-bundler-Bigc3wbW.js","assets/react-CiToEmDU.js","assets/utils-D0PJbLwx.js","assets/css/react-BONEgNez.css","assets/css/style-B3TEaj-8.css","assets/index-czRBcvnS.js","assets/ResourceNode-OBIHQGrc.js","assets/tiptap-nRqHaR__.js","assets/faPencil-i7LcEqDF.js","assets/index-BYjFgc3L.js","assets/media-CVQTa9EZ.js","assets/css/media-B5me1yE1.css","assets/analytics-BXHdaAVG.js","assets/css/index-_446ohur.css","assets/index-VeBbZI0v.js","assets/faArrowRight-4u0hryvz.js","assets/ui-RDrFZQ6P.js","assets/faXmark-B7G55HuF.js","assets/faListCheck-DLKcNtcQ.js","assets/faScaleBalanced-D5aakmWf.js","assets/faClipboardCheck-S11E7M81.js","assets/faHouse-U1l3zx8N.js","assets/default-COrDvlHP.js","assets/TrackMixpanel-C5L6PEAt.js","assets/module-xE8hoDfr.js","assets/css/ResourceNode-DSsmZg0c.css","assets/Helmet-Dnl5bqjF.js"])))=>i.map(i=>d[i]);
2var Un=Object.defineProperty;var Vn=(t,s,l)=>s in t?Un(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l;var Te=(t,s,l)=>Vn(t,typeof s!="symbol"?s+"":s,l);import{o as we,r as a,j as e,T as v,_ as Qe,e as M,a7 as Mn,G as Z,B as V,m as Le,E as Je,a9 as Ws,k as ge,S as fe,Q as Ze,a0 as is,X as Re,L as Oe,z as it,aG as Hn,u as Ie,K as je,U as ie,a6 as ws,a$ as Wn,b0 as Gn,ad as qn,C as $e,aa as gt,n as Ue,I as ms,ai as ps,i as Fe,h as Q,p as Kn,N as Yn,y as Zn,q as se,Z as ot,t as Se,O as gs,b1 as Rt,b2 as hs,A as fs,H as Xn,aP as Qn,Y as Jn}from"./react-CiToEmDU.js";import{b as xt,f as ee,L as Gs,e as zt,a as Pe,w as pe,C as st,p as ct,G as Cs,d as bt,v as ht,S as qs,u as ei,R as ti,c as De,N as si,H as yt,I as St}from"./index-BYjFgc3L.js";import{c as xs}from"./coboltSpaceSettingsEnabled-Co6E_Sts.js";import{u as ne,P as ke,q as nt,h as Ks,i as Ys,j as Zs,d as Xs,D as Qs,e as Js,S as en,v as tn,b as sn,C as nn,c as jt,f as Nt,o as an,a as ni,M as on}from"./faPencil-i7LcEqDF.js";import{B as ii,O as ai,s as bs,S as oi}from"./SpaceSwitcher-DkckGBDj.js";import{m as js,k as ze,o as ri,I as rn,i as as,M as Ve,p as _e,q as li,t as ci,v as di,w as mt,h as vt,x as ui,y as mi}from"./App-Brufidul.js";import pi from"./Scheduling-CyJczP0z.js";import{A as gi,s as wt}from"./Additional-BkbTK10g.js";import hi from"./Seo-Bb_i_eQw.js";import fi from"./Registration-Zw_RDlWd.js";import{U as ln,C as ft,aH as xi,cI as Ts,h as He,g6 as bi,ah as ji,S as Ae,R as cn,t as dn,v as un,a7 as Ot,g7 as mn,aE as pn,q as _s,a4 as _i,j as Ft,g8 as yi,g9 as Si,Y as vi,m as gn,ga as wi,gb as Ci,aC as os,n as Ti,aB as ki,cv as pt,gc as hn,gd as fn,b as Ei,ge as Ii,e as Ct,cS as dt,K as Di,g as xn,L as Fi,gf as Bi,aj as $i}from"./ResourceNode-OBIHQGrc.js";import{F as C}from"./index-VeBbZI0v.js";import{S as oe}from"./ui-RDrFZQ6P.js";import{M as ve}from"./Member-BNvCtcRV.js";import{W as Pi,E as Ai}from"./EditLinkDrawer-Cc4OATtb.js";import{O as ks,P as Ri}from"./Private-6yEsyod8.js";import{_ as rs}from"./media-CVQTa9EZ.js";import{g as zi}from"./faScaleBalanced-D5aakmWf.js";import Ni from"./OnboardingSettings-C6NiVktA.js";import{T as ls,E as Es,g as Kt,a as Yt}from"./triggerLabels-CHhHnSt2.js";import{D as Me}from"./utils-D0PJbLwx.js";import{o as Oi,g as Li,m as Zt,S as bn,a as Xe,A as Ui,R as Is,W as Vi,G as Mi,b as Hi,c as Wi,d as Gi,e as qi,f as Ki,h as Yi,i as Zi,j as Xi,E as Qi,k as Ji,l as ea,n as Xt,p as ta}from"./AutomationBuilder-DdzlFkUq.js";import{B as he}from"./Broadcast-AiR3CPIY.js";import{f as ue,a as jn}from"./faXmark-B7G55HuF.js";import Lt from"./EmailBuilder-B0dhujUf.js";import{T as sa}from"./trash-BpQe4NH1.js";import na from"./AddTrigger-Cf9mTsi5.js";import{b as Be,f as ia}from"./ParticipationThresholdForm-Bat5PCX1.js";import{V as aa}from"./faFileLines-D3zdxiD5.js";import{C as oa}from"./Summary-DYvDEkHw.js";import{m as ra,T as la}from"./TimeInputCompat-Bc7wtmWs.js";import{P as ca,E as da,C as ua}from"./PresetCard-DwaDohyt.js";import{c as ys,d as ma}from"./faListCheck-DLKcNtcQ.js";import{f as Ss}from"./faEllipsis-HcBaDDIO.js";import{u as pa}from"./FrequencyOptions-Bqa4YGHe.js";import{u as _n,F as yn}from"./useFilterPanel-DvJbAqEk.js";import{o as ga}from"./UserMenu-B_jYy3Li.js";
2import ha from"./ContactProfileDrawer-tWbC384m.js";import fa from"./CsvImportModal-DOFJptKF.js";import xa from"./SourcesTab-D7Xqw3W5.js";import Sn from"./ComposeBroadcast-dZXQYALa.js";import ba from"./Broadcast-BZ_5jI6t.js";import{s as Qt,S as ja,f as _a}from"./SuppressedDrawer-DF8Luquq.js";import{S as Ds}from"./broadcastSuccessTitle-DWRNydzu.js";import{u as ya}from"./useChannel-DYxj2c-Y.js";import{f as vn}from"./faArrowRight-4u0hryvz.js";import{f as vs}from"./faTriangleExclamation-CpsCKtGj.js";import{f as Fs}from"./faRotateRight-BshwWwZ3.js";import{c as Y,D as Sa}from"./DnsRecordsTable-Gt21EymH.js";import{g as va,a as wa,n as wn,O as Bs}from"./domainDns-DrsCW81g.js";import{S as Ca}from"./membersMapEnabled-Br6JLAyx.js";import{c as Ta,A as ka}from"./AdvancedParticipationExportDrawer-D_iOMjaY.js";import{a as Ea,P as Ia}from"./accountTypeFeatures-BoLpqHdi.js";import Da from"./ParticipationGrid-D5jfnNrt.js";import Fa from"./Premium-DcDahN5O.js";import Ba from"./ThemesSettings-Dxs6zeeB.js";import"./analytics-BXHdaAVG.js";import"./faLayerGroup-CAxQFcBF.js";import"./headerLayout-oz_V-s5H.js";import"./Helmet-Dnl5bqjF.js";import"./tiptap-nRqHaR__.js";import"./TrackMixpanel-C5L6PEAt.js";import"./module-xE8hoDfr.js";import"./SutraLogo-Bi9M0uSf.js";import"./faBoxArchive-tpsCW6hI.js";import"./faArrowUpRightFromSquare-DxPh7tzK.js";import"./default-COrDvlHP.js";import"./faHouse-CoXf9sah.js";import"./faHouse-U1l3zx8N.js";import"./FontDropdown-CVwK6Nll.js";import"./UploadedFilesList-sj2xJC_U.js";import"./faCloudArrowUp-C66WGIf9.js";import"./CoboltLauncher-CbQFsgoE.js";import"./AuthUser-CvWiDbrb.js";import"./EventSeries-DmSVyZVF.js";import"./RepeatRuleFields-DRgoN5nG.js";import"./SeriesScopeDialog-wHZM2bKY.js";import"./Tag-a0JWmFjH.js";import"./faArrowUpFromBracket-4NAnt_1P.js";import"./faClipboardCheck-S11E7M81.js";import"./spaceLoader-DAPDVVZ2.js";import"./OnboardingStep-BHc4FI2w.js";import"./OnboardingContentField-fiqeJcDA.js";import"./OnboardingHeroMedia-TiQY7Ja3.js";import"./VisionBuildLanding-CImE_0Fb.js";import"./constants-Mz1HL_HC.js";import"./visionBuildDraftStorage-DClO8FMV.js";import"./faTableColumns-BglpCiEA.js";import"./TiptapNoHP-CWUji5-D.js";import"./ContentModalCloseButton-Bpq97Y4C.js";import"./contentModalCloseButton-BwZ_2Bxs.js";import"./BroadcastTemplatesModal-kJsmlvF1.js";import"./index-BUlGFdfv.js";import"./TemplatesModal-BJT36X0w.js";import"./index-kYyH7WkA.js";import"./index-CeFHoo7x.js";import"./emailBuilderDirtyState-Ca3Gunyh.js";import"./charts-llrkN2aQ.js";import"./TagsChips-BbpjpQ_G.js";import"./faFeather-DbrqrO0S.js";import"./MembersMap-g6BPpLaz.js";import"./initialsUtils-XSGRZNrV.js";(function(){try{var t=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:{};t.SENTRY_RELEASE={id:"e15ff996bbe7105fef2b7e48186cc5ea2cf1c022"};var s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="58ba4b62-0f45-4e9b-a6e2-09c79039a1d6",t._sentryDebugIdIdentifier="sentry-dbid-58ba4b62-0f45-4e9b-a6e2-09c79039a1d6")}catch{}})();const $a="_navLink_1tce5_1",Pa={navLink:$a},Aa=["main","members","broadcast","surveys","participation"],Ra=["members","participation"],Cn=["overview","main","members","automation","broadcast","surveys","admin","scheduled","participation","domains","cobolt"];function Tn({space:t,user:s,role:l}={}){const n=l||(typeof window!="undefined"?window.$currentRole:void 0),i=xs({user:s,role:n}),d=["moderator","editor"].includes(n)?Ra:Cn,r=Array.isArray(t==null?void 0:t.settings_tabs)&&t.settings_tabs.length>0?t.settings_tabs:Array.isArray(s==null?void 0:s.settings_tabs)&&s.settings_tabs.length>0?s.settings_tabs:Aa,u=["overview",...i?["automation","domains","cobolt"]:["automation","domains"]].reduce((p,f)=>p.indexOf(f)<0?[...p,f]:p,r);return d.filter(p=>u.indexOf(p)>=0)}const za=t=>({settingsNav:{paddingTop:20,height:`calc(var(--app-height, 100vh) - ${t.other.headerHeight}px)`},link:{color:"#fff",display:"block",padding:"10px 25px",marginLeft:"15px",textDecoration:"none",fontSize:t.fontSizes.lg,fontWeight:500,borderTopLeftRadius:t.radius.xl,borderBottomLeftRadius:t.radius.xl},active:{color:"#000",backgroundColor:"#fff"}});function Na(){const{t}=ne(),s=we(),l=za(s),n=xt(),i=ee(g=>g.space),o=ee(g=>g.user),d=xs({user:o}),[r,m]=a.useState("main"),c=[{value:"overview",label:"Overview",to:`/s
2pace/${i.slug}/settings/overview`},{value:"main",label:t("spaces.settings.layout.navbarContent.mainSettings"),to:`/space/${i.slug}/settings/main`},{value:"members",label:t("spaces.settings.layout.navbarContent.members"),to:`/space/${i.slug}/settings/members`},{value:"automation",label:t("spaces.settings.layout.navbarContent.automation"),to:`/space/${i.slug}/settings/automation`},{value:"broadcast",label:t("spaces.settings.layout.navbarContent.broadcast"),to:`/space/${i.slug}/settings/broadcast`},{value:"surveys",label:t("spaces.settings.layout.navbarContent.surveys"),to:`/space/${i.slug}/settings/surveys`},{value:"admin",label:t("spaces.settings.layout.navbarContent.sutraAdmin"),to:`/space/${i.slug}/settings/admin`},{value:"scheduled",label:t("spaces.settings.layout.navbarContent.scheduled"),to:`/space/${i.slug}/settings/scheduled`},{value:"participation",label:t("spaces.settings.layout.navbarContent.participation"),to:`/space/${i.slug}/settings/participation`},{value:"domains",label:"Domains",to:`/space/${i.slug}/settings/domains`},{value:"cobolt",label:"Cobolt AI",to:`/space/${i.slug}/settings/cobolt`,hidden:!d}],u=[{value:"members",label:t("spaces.settings.layout.navbarContent.members"),to:`/space/${i.slug}/settings/members`},{value:"participation",label:t("spaces.settings.layout.navbarContent.participation"),to:`/space/${i.slug}/settings/participation`}],p=["moderator","editor"].includes(window.$currentRole)?u:c,f=Tn({space:i,user:o});return a.useEffect(()=>{m(n.pathname.split("/").pop())},[n]),e.jsx("div",{style:l.settingsNav,children:p.map(g=>!g.hidden&&f.indexOf(g.value)>=0&&e.jsx(v,{component:Gs,style:{...l.link,...r==g.value?l.active:{}},className:Pa.navLink,to:g.to,children:g.label},g.value))})}function Oa(){const t=zt(),s=ee(c=>c.space),[l,n]=a.useState("30d"),[i,o]=a.useState(null),[d,r]=a.useState(null);a.useEffect(()=>{s!=null&&s.slug&&(o(null),r(null),ii.fetchForSpace(s.slug,l,o,r))},[s==null?void 0:s.slug,l]);const m=c=>{!(s!=null&&s.slug)||!(c!=null&&c.id)||t(js("broadcast",{space:s.slug,ret:s.slug,broadcast:c.id}))};return e.jsx(ai,{data:i,error:d,range:l,onRangeChange:n,title:"Overview",onViewBroadcast:m})}const La="_inviteButton_19nqk_1",Ua="_metricItem_19nqk_5",$s={inviteButton:La,metricItem:Ua},Va=t=>({card:{backgroundColor:t.colors.gray[0]},metricItem:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center",borderRadius:t.radius.md,padding:10,backgroundColor:t.colors.gray[0],cursor:"pointer",transition:"box-shadow 150ms ease, transform 100ms ease"},customLinkRight:{backgroundColor:t.colors.gray[2],display:"flex",alignItems:"center",paddingLeft:5,paddingRight:5,height:36,borderTopLeftRadius:5,borderBottomLeftRadius:5,borderTop:`1px solid ${t.colors.gray[4]}`,borderBottom:`1px solid ${t.colors.gray[4]}`,borderLeft:`1px solid ${t.colors.gray[4]}`,color:t.colors.gray[7]},customLinkLeft:{backgroundColor:t.colors.gray[2],display:"flex",alignItems:"center",paddingLeft:5,paddingRight:5,height:36,borderTopRightRadius:5,borderBottomRightRadius:5,borderTop:`1px solid ${t.colors.gray[4]}`,borderBottom:`1px solid ${t.colors.gray[4]}`,borderRight:`1px solid ${t.colors.gray[4]}`,color:t.colors.gray[7]}});function Ma({setInviteOpened:t}){const s=zt(),{t:l}=ne(),n=we(),i=Va(n),o=ee(z=>z.space),[d,r]=a.useState(!1),[m,c]=a.useState(!1),[u,p]=a.useState(!1),[f,g]=a.useState(null),[w,x]=a.useState(0),h=f&&f.slug===o.slug&&f.topSlug===o.top_space_slug?f.url:o.shareble_link;a.useEffect(()=>{let z=!1;return g(null),o.slug&&Pi.fetch(o.slug,{topSlug:o.top_space_slug}).then(N=>{var b,k;z||((b=N==null?void 0:N.serving)!=null?b:N!=null&&N.enabled)&&((k=N==null?void 0:N.current_page)!=null&&k.id)&&N.current_page.public_url&&g({slug:o.slug,topSlug:o.top_space_slug,url:N.current_page.public_url})}).catch(()=>{}),()=>{z=!0}},[o.slug,o.top_space_slug,o.shareble_link,w]);const j=Qe(`(max-width: ${n.other.breakpoints.xl}px)`),[L,I]=a.useState({all:0,active:0,pending:0,managers:0,interested:0,invitations:0,payments:0,earnings:0,formatted_earnings:"$0"});a.useEffect(()=>{o.settings&&_()},[o]);const E=()=>{p(!0),setTimeout(()=>{p(!1)},2e3)},P=z=>{const N={registered:"members",pending:"members",interested:"contacts",invited:"invited",payments:"paying"},b={pending:"pending"};s(js("members",{space:o.slug,ret:o.slug,tab:N[z.section]||"members",segment:b[z.section]}))},_=()=>{ve.onFetchCounts(o.slug,z=>{I(z)},z=>{})},$=()=>[{label:l("spaces.settings.main.main.label11"),value:L.active,section:"registered",
2scope:"all"},{label:l("spaces.settings.main.main.label12"),value:L.pending,section:"pending",scope:"pending"},{label:l("spaces.settings.main.main.label13"),value:L.interested,section:"interested"},{label:l("spaces.settings.main.main.label14"),value:L.invitations,section:"invited"},{label:l("spaces.settings.main.main.label15"),value:L.payments,section:"payments"}].filter(z=>Number(z.value)>0);return e.jsxs(e.Fragment,{children:[e.jsx(ze,{spaceId:o.slug,spaceVersion:o.version,spaceName:o.name,title:l("spaces.settings.main.title"),rightSide:e.jsx(M,{variant:"filled",radius:"xl",onClick:z=>t(!0),leftSection:e.jsx(C,{icon:ln.faUserPlus}),style:{cursor:"pointer",backgroundColor:"var(--mantine-color-sutrablue-3)"},className:$s.inviteButton,children:l("spaces.settings.main.main.invite")})}),e.jsx(Mn,{withBorder:!0,p:"lg",mb:10,radius:"md",style:i.card,children:e.jsx("div",{children:e.jsxs(Z,{justify:j?"center":"space-between",style:{width:"100%",alignItems:"center"},children:[e.jsxs(V,{children:[e.jsxs(Z,{justify:"space-between",wrap:"nowrap",children:[e.jsx(v,{fw:500,ta:j?"center":"left",children:l("spaces.settings.main.main.shareableLink")}),e.jsx(M,{variant:"outline",color:"dark",radius:"xl",size:"xs",compact:!0,onClick:()=>r(!0),children:l("spaces.settings.main.main.editLinkButton")})]}),e.jsx(Le,{disabled:window.$isTouchDevice&&window.$isTouchDevice(),label:l("spaces.settings.main.main.label1"),opened:u,position:"bottom",withArrow:!0,children:e.jsx(ft,{onCopy:()=>E(),text:h,children:e.jsx(v,{size:"lg",c:"dimmed",ta:j?"center":"left",children:`${h}`})})})]}),j?e.jsx(Je,{style:{borderTopColor:n.colors.gray[2],width:"100%"}}):"",e.jsx(Z,{gap:5,justify:j?"center":"flex-end",children:$().map(z=>e.jsxs(Ws,{style:i.metricItem,className:$s.metricItem,onClick:()=>P(z),"aria-label":`View ${z.label}`,children:[e.jsx(v,{fw:700,ta:"center",children:z.value}),e.jsx(v,{size:"sm",c:"dimmed",children:z.label})]},z.label))})]})})}),e.jsx(ke,{opened:m,setOpened:c}),e.jsx(Ai,{opened:d,onClose:()=>r(!1),space:o,onLinkUpdated:()=>x(z=>z+1)})]})}const Ha="_privacySelectOption_17jsv_1",Wa={privacySelectOption:Ha},Ga=t=>({itemTitle:{fontSize:16,fontWeight:500,color:"#1F2937"},itemDescription:{fontSize:14,color:"#6B7280"}});function qa({onUpdate:t,privacyOptions:s,privacySelection:l,setPrivacySelection:n}){const{t:i}=ne();we();const o=Ga(),d=Pe(),r=ee(x=>x.space),[m,c]=a.useState(),[u,p]=a.useState(!1),f=a.useRef(),g=()=>{r!=null&&r.slug&&pe.onFetch({id:r.slug,type:"new_space"},x=>{d(st({...x,permissions:r.permissions}))},()=>{})},w=()=>l=="open"?e.jsx(ks,{settings:r}):l=="private"?e.jsx(Ri,{settings:r}):l=="payment"?e.jsx(ri,{showDisconnect:!0,settings:r,onUpdate:t,onRefresh:g,space:r,options:["paid","flexible","recurring","plans"]}):e.jsx(ks,{settings:r});return a.useEffect(()=>{r.settings&&(f.current=!1,n(r.privacy_level),c(r.visibility=="public"),setTimeout(()=>{f.current=!0},1e3))},[r]),a.useEffect(()=>{f.current&&t({visibility:m?"public":""})},[m]),a.useEffect(()=>{f.current&&t({privacy_level:l})},[l]),e.jsxs(V,{mb:20,children:[e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(fe,{value:l,onChange:x=>{var h;if(x==="private"&&Array.isArray((h=r==null?void 0:r.permissions)==null?void 0:h.can_set_private)&&!r.permissions.can_set_private[0]){p([!0,r.permissions.can_set_private[1],r.permissions.can_set_private[2]]);return}n(x)},placeholder:i("spaces.settings.main.main.privacySetting"),renderOption:({option:x})=>e.jsx(Z,{wrap:"nowrap",children:e.jsxs("div",{children:[e.jsx(v,{size:"lg",fw:600,children:x.label}),e.jsx(v,{size:"md",c:"dimmed",children:x.description})]})}),data:s,classNames:{option:Wa.privacySelectOption},maxDropdownHeight:400,radius:"md",size:"lg"})}),l!="private"&&r.slug&&r.belongs_to_private_or_paid_circles&&e.jsxs(Z,{justify:"space-between",wrap:"nowrap",gap:"xl",mb:20,mt:20,children:[e.jsxs("div",{children:[e.jsx(v,{style:o.itemTitle,children:i("spaces.settings.main.main.title1")}),e.jsx(v,{style:o.itemDescription,children:i("spaces.settings.main.main.description1")})]}),e.jsx(Ze,{onLabel:i("spaces.settings.main.main.on"),offLabel:i("spaces.settings.main.main.off"),size:"lg",checked:m,onChange:x=>c(x.currentTarget.checked)})]}),w(),e.jsx(ke,{opened:u,setOpened:p})]})}const Ka="_accordionItem_6g2yh_1",Ya="_accordionControl_6g2yh_2",Za="_mediaRow_6g2yh_8",Xa="_mediaBlock_6g2yh_15",Qa="_mediaBlockLogo_6g2yh_21",Ja="_mediaLabel_6g2yh_27",eo="_mediaCard_6g2yh_36",to="_mediaPreview_6g2yh_43",s
2o="_coverImg_6g2yh_47",no="_logoTile_6g2yh_54",io="_mediaOverlay_6g2yh_70",ao="_overlayBtn_6g2yh_87",oo="_overlayBtnGhost_6g2yh_88",ro="_mediaFooter_6g2yh_109",lo="_dropzone_6g2yh_118",co="_dropzoneIcon_6g2yh_139",uo="_dropzoneTitle_6g2yh_145",mo="_dropzoneHint_6g2yh_151",po="_themeTile_6g2yh_158",go="_themeTileSelected_6g2yh_170",ho="_themePreview_6g2yh_175",fo="_themePreviewHeader_6g2yh_183",xo="_themePreviewBody_6g2yh_187",bo="_themePreviewSidebar_6g2yh_192",jo="_themePreviewContent_6g2yh_207",re={accordionItem:Ka,accordionControl:Ya,mediaRow:Za,mediaBlock:Xa,mediaBlockLogo:Qa,mediaLabel:Ja,mediaCard:eo,mediaPreview:to,coverImg:so,logoTile:no,mediaOverlay:io,overlayBtn:ao,overlayBtnGhost:oo,mediaFooter:ro,dropzone:lo,dropzoneIcon:co,dropzoneTitle:uo,dropzoneHint:mo,themeTile:po,themeTileSelected:go,themePreview:ho,themePreviewHeader:fo,themePreviewBody:xo,themePreviewSidebar:bo,themePreviewContent:jo},_o=({imageSrc:t,targetWidth:s=360,targetHeight:l=120,onSave:n,onClose:i,uploading:o})=>{const d=a.useRef(null),r=a.useRef(1),m=a.useRef(!1),[c,u]=a.useState(null),[p,f]=a.useState(1),[g,w]=a.useState(1),[x,h]=a.useState(!1),j=Math.max(.01,g*.05),L=g*2,I=g*.05;a.useEffect(()=>{E()},[]);const E=async()=>{try{const D=await rs(()=>import("./index.esm-bundler-Bigc3wbW.js"),__vite__mapDeps([0,1,2,3]));await rs(()=>Promise.resolve({}),__vite__mapDeps([4])),u({FixedCropper:D.FixedCropper})}catch(D){console.warn("[advanced-cropper] failed to load",D)}},P=a.useCallback(D=>Math.min(L,Math.max(j,D)),[j,L]),_=a.useCallback((D,T={})=>{const B=d.current;if(!B)return;const y=P(D),R=r.current||1,S=y/R;B.zoomImage(S,{immediately:!0,transitions:!1,normalize:!1,...T}),r.current=y,f(y)},[P]),$=a.useCallback(D=>{_(D)},[_]),z=()=>{_(r.current+I,{transitions:!0})},N=()=>{_(r.current-I,{transitions:!0})},b=a.useCallback(()=>{const D=d.current;if(!D)return;const T=D.getState();if(!(T!=null&&T.imageSize))return;const{width:B,height:y}=T.imageSize,R=Math.max(s/B,l/y);D.reset(),requestAnimationFrame(()=>{w(R),r.current=R,f(R)})},[s,l]),k=a.useCallback(()=>{if(!d.current)return;const D=d.current.getCanvas({width:s,height:l});if(!D)return;const T=document.createElement("canvas");T.width=s,T.height=l;const B=T.getContext("2d");B&&(B.clearRect(0,0,s,l),B.drawImage(D,0,0),n({imageBase64:T.toDataURL("image/png")}))},[s,l,n]),U=a.useCallback(()=>{m.current||setTimeout(()=>{const D=d.current;!D||m.current||(typeof D.refresh=="function"&&D.refresh(),b(),m.current=!0,setTimeout(()=>{h(!0)},300))},150)},[b]);if(o)return e.jsx(Re,{children:e.jsx(Oe,{})});const H=c==null?void 0:c.FixedCropper;return!H||!t?e.jsx(Re,{children:e.jsx(Oe,{})}):e.jsxs(it,{gap:"md",children:[e.jsxs(V,{style:{height:400,position:"relative",background:"#fff",overflow:"hidden"},children:[!x&&e.jsx(Re,{style:{position:"absolute",inset:0,zIndex:100,background:"#fff"},children:e.jsx(Oe,{})}),e.jsx(H,{ref:d,src:t,onReady:U,stencilSize:{width:s,height:l},stencilProps:{movable:!1,resizable:!1},imageRestriction:"none",style:{background:"#fff"}})]}),e.jsxs(Z,{justify:"center",gap:"md",children:[e.jsx(M,{size:"sm",variant:"light",radius:"xl",onClick:N,children:e.jsx(C,{icon:zi.faMinus})}),e.jsx(V,{style:{width:240},children:e.jsx(Hn,{value:p,onChange:$,min:j,max:L,step:.01,label:D=>`${Math.round(D/g*100)}%`})}),e.jsx(M,{size:"sm",variant:"light",radius:"xl",onClick:z,children:e.jsx(C,{icon:He.faPlus})}),e.jsx(M,{size:"sm",variant:"light",radius:"xl",onClick:b,children:"Reset"})]}),e.jsxs(Z,{justify:"flex-end",px:"md",pb:"md",children:[e.jsx(M,{variant:"default",onClick:i,children:"Cancel"}),e.jsx(M,{onClick:k,loading:o,children:"Save"})]})]})},yo=.95;function So(t){var be,Ee;const{t:s}=ne(),l=Pe(),n=ee(F=>F.space),[i,o]=a.useState([]),[d,r]=a.useState([]),[m,c]=a.useState([]),[u,p]=a.useState(!1),[f,g]=a.useState(!1),[w,x]=a.useState(!1),[h,j]=a.useState(!1),L=a.useRef(),I=a.useRef(),E=a.useRef(),[P,_]=a.useState(null),[$,z]=a.useState(null),N=a.useCallback(async()=>{if(P)return P;try{const F=await rs(()=>import("./index-czRBcvnS.js"),__vite__mapDeps([5,1,2,3,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])),q={Component:F.default,TABS:F.TABS,TOOLS:F.TOOLS};return _(q),q}catch{return null}},[P]);a.useEffect(()=>{r(n&&n.permissions&&n.permissions.can_upload_cover),c(n&&n.permissions&&n.permissions.can_upload_logo),j(typeof(n==null?void 0:n.is_cover_full_width)=="boolean"?n.is_cover_full_width:!0)},[n]);const b=F=>{const q=F.target.files[0];if(T(q,F.target))if(L.current=document.createElement("img"),q){const O=new FileReader;O.addEventListener("load",function(){L.current.src=O.result,U()}
2),O.readAsDataURL(q)}else I.current&&(I.current.value="")},k=F=>{const q=F.target.files[0];if(T(q,F.target))if(q){const O=new FileReader;O.addEventListener("load",function(){z(O.result),g(!0)}),O.readAsDataURL(q)}else E.current&&(E.current.value="")},U=()=>{N(),p(!0)},H=()=>{p(!1),I.current&&(I.current.value="")},D=()=>{g(!1),z(null),E.current&&(E.current.value="")},T=(F,q)=>!F||F.size>5242880?(oe.fire("","Your image must be less than 5MB","info"),q.value="",!1):!0,B=F=>{x(!0),pe.onUploadHeader(n.slug,F.imageBase64,q=>{R(q.url),setTimeout(()=>{x(!1)},500)},q=>{})},y=F=>{x(!0),pe.onUploadLogo(n.slug,F.imageBase64,q=>{S(q.url),setTimeout(()=>{x(!1)},500)},q=>{})},R=F=>{const q={...n};q.header.url=F,l(st(q)),H()},S=F=>{const q={...n};q.logo.url=F,l(st(q)),D()},W=()=>{pe.onRemoveHeader(n.slug,F=>{R(null)},F=>{})},te=()=>{pe.onRemoveLogo(n.slug,F=>{S(null)},F=>{})},A=()=>{var F;d!=null&&d[0]?(F=I.current)==null||F.click():o([!0,d==null?void 0:d[1],d==null?void 0:d[2]])},J=()=>{var F;m!=null&&m[0]?(F=E.current)==null||F.click():o([!0,m==null?void 0:m[1],m==null?void 0:m[2]])},ae=({is_cover_full_width:F})=>{j(F);const q={...n};q.is_cover_full_width=F,l(st(q)),pe.onUpdate(n.slug,{is_cover_full_width:F},()=>{},()=>{})};return e.jsxs(V,{children:[e.jsx("input",{ref:I,type:"file",style:{display:"none"},accept:"image/*",onChange:b}),e.jsx("input",{ref:E,type:"file",style:{display:"none"},accept:"image/*",onChange:k}),e.jsxs("div",{className:re.mediaRow,children:[e.jsxs("div",{className:re.mediaBlock,children:[e.jsx("div",{className:re.mediaLabel,children:"Cover image"}),(be=n==null?void 0:n.header)!=null&&be.url?e.jsxs("div",{className:re.mediaCard,children:[e.jsxs("div",{className:re.mediaPreview,children:[e.jsx(xi,{imageData:n.header,className:re.coverImg}),e.jsxs("div",{className:re.mediaOverlay,children:[e.jsx("button",{type:"button",className:re.overlayBtn,onClick:A,children:"Replace"}),e.jsx("button",{type:"button",className:re.overlayBtnGhost,onClick:()=>W(),children:s("spaces.colors.headerAndLogo.removeCover")})]})]}),e.jsxs("div",{className:re.mediaFooter,children:[e.jsx(v,{size:"sm",c:"dimmed",children:"Display full width"}),e.jsx(Ze,{checked:h,onChange:F=>ae({is_cover_full_width:F.currentTarget.checked}),size:"md"})]})]}):e.jsxs("button",{type:"button",className:re.dropzone,onClick:A,children:[e.jsx(C,{icon:d!=null&&d[0]?Ts.faImage:nt.faStar,className:re.dropzoneIcon}),e.jsx("span",{className:re.dropzoneTitle,children:s("spaces.colors.headerAndLogo.addCover")}),e.jsx("span",{className:re.dropzoneHint,children:s("spaces.colors.headerAndLogo.dimensions")})]})]}),e.jsxs("div",{className:`${re.mediaBlock} ${re.mediaBlockLogo}`,children:[e.jsx("div",{className:re.mediaLabel,children:"Logo"}),(Ee=n==null?void 0:n.logo)!=null&&Ee.url?e.jsx("div",{className:re.mediaCard,children:e.jsxs("div",{className:re.mediaPreview,children:[e.jsx("div",{className:re.logoTile,children:e.jsx("img",{src:n.logo.url,alt:"Space logo"})}),e.jsxs("div",{className:re.mediaOverlay,children:[e.jsx("button",{type:"button",className:re.overlayBtn,onClick:J,children:"Replace"}),e.jsx("button",{type:"button",className:re.overlayBtnGhost,onClick:()=>te(),children:s("spaces.colors.headerAndLogo.removeLogo")})]})]})}):e.jsxs("button",{type:"button",className:re.dropzone,onClick:J,children:[e.jsx(C,{icon:m!=null&&m[0]?Ts.faImage:nt.faStar,className:re.dropzoneIcon}),e.jsx("span",{className:re.dropzoneTitle,children:s("spaces.colors.headerAndLogo.changeLogo")}),e.jsx("span",{className:re.dropzoneHint,children:s("spaces.colors.headerAndLogo.dimensions2")})]})]})]}),e.jsx(ke,{opened:i,setOpened:o}),e.jsx(is,{withCloseButton:!1,size:"xl",opened:u,onClose:()=>p(!1),title:"",zIndex:999999,children:(()=>{if(w)return e.jsx(Re,{children:e.jsx(Oe,{})});const F=P,q=F==null?void 0:F.Component,O=F==null?void 0:F.TABS,ce=F==null?void 0:F.TOOLS;return!q||!O||!ce?e.jsx(Re,{children:e.jsx(Oe,{})}):e.jsx(q,{source:L.current,onSave:(me,We)=>B(me),onClose:H,Rotate:{angle:90,componentType:"slider"},Crop:{noPresets:!0,autoResize:!0},defaultSavedImageQuality:yo,defaultSavedImageName:"profileImage",savingPixelRatio:4,tabsIds:[O.ADJUST],defaultTabId:O.ADJUST,defaultToolId:ce.TEXT,onBeforeSave:()=>!1,confirmationModalZIndex:9999999})})()}),e.jsx(is,{withCloseButton:!1,size:"xl",opened:f,onClose:D,title:"",zIndex:999999,children:e.jsx(_o,{imageSrc:$,targetWidth:360,targetHeight:120,onSave:y,onClose:D,uploading:w,opened:f})})]})}function vo(t){const{t:s,i18n:l}=ne(),[n,i]=a.useState(),o=ee(g=>g.space);Pe();const[d,r]=a.useState(!1),[m,c]=a.useState(!1),u=a.useRef();a.useEffect(()=>{o&&o.slug&&i(o.version),c(o&&o.permissions&&o.permissions.can_set_format)},[o]),a.useEffect(()=>{if(!u.current){u.current=!0;return}p()},[n]);const p=()=>
2{if(o&&n&&n!=o.version){if(!m[0]){r([!0,m[1],m[2]]);return}pe.onUpdate(o.slug,{version:n},g=>{t.setOpened(!1),bi("spaces",o.slug),setTimeout(()=>{window.location.href=`/space/${o.slug}/${n}`},1e3)},g=>{})}},f=()=>{const g=[];return o.version!="list"&&g.push({value:"list",label:s("spaces.colors.pageFormat.listLabel"),description:s("spaces.colors.pageFormat.listDescription")}),(Array.isArray(o.version_history)&&o.version_history.indexOf("content")>=0&&["list","events","showcase","course","section"].indexOf(o.version)>=0||o.version=="discussion")&&g.push({value:"content",label:s("spaces.colors.pageFormat.contentLabel"),description:s("spaces.colors.pageFormat.contentDescription")}),o.version!="discussion"&&g.push({value:"discussion",label:s("spaces.colors.pageFormat.discussionLabel"),description:s("spaces.colors.pageFormat.discussionDescription")}),o.version!="events"&&g.push({value:"events",label:s("spaces.colors.pageFormat.eventsLabel"),description:s("spaces.colors.pageFormat.eventsDescription")}),o.version!="showcase"&&g.push({value:"showcase",label:s("spaces.colors.pageFormat.showcaseLabel"),description:s("spaces.colors.pageFormat.showcaseDescription")}),g};return e.jsxs(ge,{withCssVariables:!1,theme:{primaryShade:6},children:[e.jsx(v,{size:"sm",c:"dimmed",mb:15,children:s("spaces.colors.pageFormat.description")}),e.jsx(fe,{value:n,onChange:i,placeholder:"Pick one",renderOption:({option:g})=>e.jsx(Z,{wrap:"nowrap",children:e.jsxs("div",{children:[e.jsx(v,{size:"sm",children:g.label}),e.jsx(v,{size:"xs",c:"dimmed",children:g.description})]})}),comboboxProps:{maxDropdownHeight:400,zIndex:99999},defaultValue:"content",data:f()}),e.jsx(ke,{opened:d,setOpened:r})]})}const wo=t=>({item:{paddingBottom:16,marginBottom:18,borderBottom:`1px solid ${t.colors.gray[2]}`},itemLast:{paddingBottom:16,marginBottom:18},itemTitle:{fontSize:16,fontWeight:500,color:"#1F2937"},itemDescription:{fontSize:14,color:"#6B7280"}});function Co(){const{t}=ne(),s=Pe(),l=we(),n=wo(l),i=ee(E=>E.space),o=a.useRef([]),d=a.useRef(!1),r=a.useRef(!1),m=a.useRef(!1),c=a.useRef("narrow"),[u,p]=a.useState({sidebar:!1,header:!1,cover:!1,title:!1,breadcrumbs:!0,width:!1,show_page_icon:!1,apply_to_sub_spaces:!1}),[f,g]=a.useState(!1),[w,x]=a.useState(!1);a.useEffect(()=>{var E;i&&i.slug&&(d.current=!0,o.current=window.$hiddenLayoutElements?[...window.$hiddenLayoutElements]:[...i.hidden_layout_elements],p({sidebar:o.current.includes("sidebar"),header:o.current.includes("header"),cover:o.current.includes("cover"),title:o.current.includes("title"),breadcrumbs:o.current.includes("breadcrumbs"),width:i.space_width==="wide"||i.space_width==="full",show_page_icon:i.show_page_icon,apply_to_sub_spaces:i.apply_to_sub_spaces}),r.current=i.show_page_icon,m.current=i.apply_to_sub_spaces,c.current=i.space_width||"narrow",x(((E=i==null?void 0:i.permissions)==null?void 0:E.can_set_layout)||!1),setTimeout(()=>d.current=!1,1e3))},[i]),a.useEffect(()=>{if(!d.current){const E={...i,space_width:c.current};s(st(E)),ji(c.current),L()}},[u.width]);const h=E=>P=>{if(!w[0]&&!d.current){p(_=>({..._,[E]:!1})),g([!0,w[1],w[2]]);return}p(_=>({..._,[E]:P})),E==="show_page_icon"&&(r.current=P),E==="apply_to_sub_spaces"&&(m.current=P),E==="width"&&(c.current=P?"wide":"narrow"),P&&!o.current.includes(E)?o.current.push(E):!P&&o.current.includes(E)&&(o.current=o.current.filter(_=>_!==E)),j(),E==="apply_to_sub_spaces"&&L()},j=()=>{d.current||(window.$hiddenLayoutElements=[...o.current],pe.onUpdate(i.slug,{hidden_layout_elements:[...o.current],space_width:c.current,show_page_icon:r.current,apply_to_sub_spaces:m.current},()=>{},()=>{}))},L=()=>{Ae.onUpdate(i.slug,{pod_settings_attributes:{space_width:c.current,show_page_icon:r.current,apply_to_sub_spaces:m.current}},()=>{},()=>{})},I=[{key:"show_page_icon",title:"Show space icon on content page",desc:"The sidebar icon will be displayed next to the title on this page."},{key:"width",title:t("spaces.colors.pageLayout.widePage"),desc:"Content on this page will display wider."}
2,{key:"sidebar",title:t("spaces.colors.pageLayout.hideSidebar"),desc:"The sidebar will no longer be accessible on this page."},{key:"header",title:t("spaces.colors.pageLayout.hideHeader"),desc:"The header on this page will only be visible to managers."},{key:"cover",title:t("spaces.colors.pageLayout.hideCoverImage"),desc:"The cover image will not be visible on this page."},{key:"title",title:t("spaces.colors.pageLayout.hidePageTitle"),desc:"The page title will not show up at the top of the page."},{key:"breadcrumbs",title:t("spaces.colors.pageLayout.hideBreadcrumbs"),desc:"The breadcrumb navigation links will not be visible at the top of this page."},{key:"apply_to_sub_spaces",title:"Apply changes to all sub spaces",desc:"When this setting is checked, any layout changes above will also be applied to all sub spaces."}];return e.jsxs(e.Fragment,{children:[I.map(({key:E,title:P,desc:_},$)=>e.jsxs(Z,{justify:"space-between",style:$===I.length-1?n.itemLast:n.item,wrap:"nowrap",gap:"xl",children:[e.jsxs("div",{children:[e.jsx(v,{style:n.itemTitle,children:P}),e.jsx(v,{style:n.itemDescription,children:_})]}),e.jsx(Ze,{checked:u[E],onChange:z=>h(E)(z.currentTarget.checked),onLabel:"ON",offLabel:"OFF",style:n.switch,size:"lg"})]},E)),e.jsx(ke,{opened:f,setOpened:g})]})}const To=["header_color","sidebar_background_color","background_color","secondary_background_color","primary_button_background_color","default_text_color"];function Ke(t,s,l){var n;return((n=t==null?void 0:t.palette)==null?void 0:n[s])||(t==null?void 0:t[s])||l}function ko(t){return To.some(s=>!!Ke(t,s,null))}function Eo(t){return t?/^(https?:)?\/\//.test(t)||t.startsWith("/")?t:`/themes/${t}`:null}function Io({theme:t}){const s=ko(t)?null:Eo(t==null?void 0:t.file_name);if(s)return e.jsx(qn,{radius:"md",src:s,alt:t.title});const l=Ke(t,"header_color","#1f2937"),n=Ke(t,"sidebar_background_color","#f4f6f8"),i=Ke(t,"background_color","#ffffff"),o=Ke(t,"secondary_background_color","#f7f7f7"),d=Ke(t,"primary_button_background_color","#7950f2"),r=Ke(t,"default_text_color","#1f2937"),m=(t==null?void 0:t.corner_style)==="sharp"?2:(t==null?void 0:t.corner_style)==="rounded"?12:7;return e.jsxs(V,{className:re.themePreview,role:"img","aria-label":t.title,style:{backgroundColor:i,
2color:r,borderRadius:m},children:[e.jsx(V,{className:re.themePreviewHeader,style:{backgroundColor:l}}),e.jsxs(V,{className:re.themePreviewBody,children:[e.jsxs(V,{className:re.themePreviewSidebar,style:{backgroundColor:n},children:[e.jsx("span",{style:{backgroundColor:d}}),e.jsx("span",{style:{backgroundColor:o}}),e.jsx("span",{style:{backgroundColor:o}})]}),e.jsxs(V,{className:re.themePreviewContent,children:[e.jsx("span",{style:{backgroundColor:r}}),e.jsx("span",{style:{backgroundColor:o}}),e.jsx("span",{style:{backgroundColor:o}}),e.jsx("span",{style:{backgroundColor:d}})]})]})]})}function Do(t){const s=Pe(),{t:l}=ne(),n=ee(_=>_.space),i=ee(_=>_.colors),[o,d]=a.useState({}),[r,m]=a.useState(null),[c,u]=a.useState(!1),[p,f]=a.useState(!1),[g,w]=a.useState(!1),[x,h]=a.useState(!1);a.useEffect(()=>{L()},[]),a.useEffect(()=>{I(i)},[i]),a.useEffect(()=>{f(n&&n.permissions&&n.permissions.can_set_theme||[!1]),w(n&&n.permissions&&n.permissions.can_set_layout||[!1]),h(n&&n.permissions&&n.permissions.can_set_format||[!1])},[n]);const j=Ie({initialValues:{...ct}}),L=()=>{pe.onFetchThemes(_=>{d(_)},_=>{})},I=_=>{m(_.id),j.setFieldValue("header_color",_.header_color),j.setFieldValue("header_link_color",_.header_link_color),j.setFieldValue("primary_button_background_color",_.primary_button_background_color),j.setFieldValue("primary_button_text_color",_.primary_button_text_color),j.setFieldValue("secondary_button_background_color",_.secondary_button_background_color),j.setFieldValue("secondary_button_text_color",_.secondary_button_text_color),j.setFieldValue("background_color",_.background_color),j.setFieldValue("default_text_color",_.default_text_color),j.setFieldValue("secondary_background_color",_.secondary_background_color),j.setFieldValue("sub_header_text_color",_.sub_header_text_color),j.setFieldValue("sidebar_background_color",_.sidebar_background_color),j.setFieldValue("sidebar_text_color",_.sidebar_text_color),j.setFieldValue("default_link_color",_.default_link_color),j.setFieldValue("default_badge_color",_.default_badge_color),j.setFieldValue("default_badge_text_color",_.default_badge_text_color)},E=_=>{if(!p[0]){u([!0,p[1],p[2]]);return}const $={};for(const z of Object.keys(_))z.startsWith("registration_page_")||($[z]=_[z]);pe.onSaveColors(n.slug,$,z=>{s(Cs({...i,...$})),oe.fire("Success","Your theme has been updated","success")},z=>{oe.fire(z.title,z.message,"error")})},P=()=>{const _={};for(const $ of Object.keys(ct))$.startsWith("registration_page_")||(_[$]=ct[$]);pe.onSaveColors(n.slug,_,$=>{s(Cs({...i,..._})),oe.fire("Success","Your theme has been updated","success")},$=>{oe.fire($.title,$.message,"error")})};return e.jsxs(V,{style:{height:"100%",paddingBottom:"40px"},children:[e.jsx("form",{onSubmit:j.onSubmit(_=>E(_)),style:{height:"100%"},children:e.jsx(it,{gap:0,style:{height:"100%"},children:e.jsx(je,{style:{height:"100%"},children:e.jsxs(ie,{multiple:!0,chevronPosition:"right",chevron:e.jsx(C,{icon:He.faPlus}),classNames:{item:re.accordionItem,control:re.accordionControl},styles:{item:{border:"1px solid #dee2e6",marginBottom:"10px",borderRadius:"10px"},content:{padding:"10px 20px 20px 20px"}},children:[e.jsxs(ie.Item,{value:"cover-image-and-logo",children:[e.jsx(ie.Control,{children:"Cover image and logo"}),e.jsx(ie.Panel,{children:e.jsx(So,{})})]}),e.jsxs(ie.Item,{value:"color-theme",children:[e.jsx(ie.Control,{children:p[0]?e.jsx(v,{children:l("spaces.colors.form.colorTheme")}):e.jsxs(Z,{gap:10,children:[e.jsx(v,{children:l("spaces.colors.form.colorTheme")}),e.jsx(V,{style:{padding:"3px 3px",backgroundColor:"var(--mantine-color-green-6)",color:"#fff",borderRadius:10,fontSize:10},children:e.jsx(C,{icon:nt.faStar})})]})}),e.jsxs(ie.Panel,{children:[e.jsx(ws,{children:Object.values(o).map(_=>e.jsx(ws.Col,{span:{xs:4},children:e.jsxs(V,{className:`${re.themeTile} ${r==_.id?`${re.themeTileSelected} theme-selected`:""}`,onClick:()=>I(_),children:[e.jsx(Io,{theme:_}),e.jsx(v,{children:_.title})]})},_.id||_.title))}),e.jsx(ie,{mt:20,style:{borderRadius:10,borderBottom:"none",border:"solid 1px #f1f1f1"},styles:{item:{borderBottom:"none"},control:{borderRadius:10}},children:e.jsxs(ie.Item,{value:"customize",children:[e.jsx(ie.Control,{children:l("spaces.colors.form.customize")}),e.jsx(ie.Panel,{children:e.jsx(V,{style:{paddingBottom:"20px"},children:Object.keys(ct).filter(_=>_.startsWith("registration_page_")||["gradients","accents","heading_font","body_font"].includes(_)?!1:typeof ct[_]=="string").map(_=>e.jsx(Wn,{mt:10,id:"input-demo",label:l(`spaces.colors.${_}.label`),children:e.jsx(Gn,{popoverProps:{zIndex:9999},...j.getInputProps(_)})}))})})]})}),e.jsx(V,{mt:20,children:e.jsxs(Z,{children:[e.jsx(M,{radius:"xl",type:"submit",children:l("spaces.colors.form.saveTheme")}),e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(M,{radius:"xl",color:"gray.6",onClick:()=>P(),children:l("spaces.colors.form.resetColor")})})]})})]})]}),e.jsxs(ie.Item,{value:"page-layout",children:[e.jsx(ie.Control,{children:g[0]?e.jsx(v,{children:l("spaces.colors.form.pageLayout")}):e.jsxs(Z,{gap:10,children:[e.jsx(v,{children:l("spaces.colors.form.pageLayout")}),e.jsx(V,{style:{padding:"3px 3px",backgroundColor:"var(--mantine-color-green-6)",color:"#fff",borderRadius:10,fontSize:10},children:e.jsx(C,{icon:nt.faStar})})]})}),e.jsx(ie.Panel,{children:e.jsx(Co,{})})]}),e.jsxs(ie.Item,{value:"page-format",children:[e.jsx(ie.Control,{children:x[0]?e.jsx(v,{children:l("spaces.colors.form.pageFormat")}):e.jsxs(Z,{gap:10,children:[e.jsx(v,{children:l("spaces.colors.form.pageFormat")}),e.jsx(V,{style:{padding:"3px 3px",backgroundColor:"var(--mantine-color-green-6)",color:"#fff",borderRadius:10,fontSize:10},children:e.jsx(C,{icon:nt.faStar})})]})}),e.jsx(ie.Panel,{children:e.jsx(vo,{setOpened:t.setOpened})})]})]})})})}),e.jsx(ke,{opened:c,setOpened:u})]})}const Bt=[0,1,2,3,4,5,6,8],Fo={1:{eventName:"space.settings.registration.expanded",section:"registration"},3:{eventName:"space.settings.scheduling.expanded",section:"scheduling"},4:{eventName:"space.settings.advanced.expanded",section:"advanced"},6:{eventName:"space.settings.seo.expanded",section:"seo"},8:{eventName:"space.settings.member_onboarding.expanded",section:"member_onboarding"}},Ps=()=>Bt.reduce((t,s)=>(t[s]=!1,t),{});function Bo(){const{t}=ne(),s=bt(),l=xt(),n=ee(N=>
2N.space),[i,o]=a.useState("open"),[d,r]=a.useState(),[m,c]=a.useState(Ps),[u,p]=a.useState(!1),[f,g]=a.useState(!1),[w]=a.useState(!1),x=a.useRef();a.useEffect(()=>{x.current&&localStorage.setItem("lastOpenedSettingsTabs",JSON.stringify(m))},[m]),a.useEffect(()=>{const N=window.location.search,b=new URLSearchParams(N).get("section");if(b){const k=Ps(),U=Number(b);Bt.includes(U)&&(k[U]=!0),c(k)}else{const k=localStorage.getItem("lastOpenedSettingsTabs","");k&&k!="null"&&c(JSON.parse(k))}x.current=!0},[s]);const h={0:{label:t("spaces.settings.main.main.label2"),index:0},1:{label:t("spaces.settings.main.main.label3"),description:t("spaces.settings.main.main.description4"),index:1},2:{label:t("spaces.settings.main.main.label4"),description:t("spaces.settings.main.main.description5")},3:{label:t("spaces.settings.main.main.label5"),description:t("spaces.settings.main.main.description6"),index:3},4:{label:t("spaces.settings.main.main.label6"),description:t("spaces.settings.main.main.description7"),index:4},5:{label:t("spaces.settings.main.main.label16"),description:"Change the look and feel of your space with custom covers, logos, page layouts and color themes",index:5},6:{label:t("spaces.settings.main.main.label7"),description:t("spaces.settings.main.main.description8"),index:6},8:{label:t("spaces.settings.main.main.onboardingLabel"),description:t("spaces.settings.main.main.onboardingDescription"),index:8}},j=[{label:t("spaces.settings.main.main.label8"),value:"open",description:t("spaces.settings.main.main.description9")},{label:t("spaces.settings.main.main.label9"),value:"private",description:t("spaces.settings.main.main.description10")},{label:t("spaces.settings.main.main.label10"),value:"payment",description:t("spaces.settings.main.main.description11")}],L=[{value:"open and on",description:t("spaces.settings.main.main.description12")},{value:"open and off",description:t("spaces.settings.main.main.description13")},{value:"private and on",description:t("spaces.settings.main.main.description14")},{value:"private and off",description:t("spaces.settings.main.main.description15")},{value:"payment and on",description:t("spaces.settings.main.main.description16")},{value:"payment and off",description:t("spaces.settings.main.main.description17")}],I=({label:N,description:b,index:k})=>e.jsx(Z,{wrap:"nowrap",children:e.jsxs("div",{children:[e.jsx(v,{size:"lg",fw:700,children:N}),m[k]?"":e.jsx(v,{size:"sm",c:"dimmed",fw:400,children:b})]})}),E=(N,{onSuccess:b,onError:k}={})=>{Object.keys(N).length!==0&&Ae.onUpdate(s.slug,N,U=>b==null?void 0:b(U),U=>k==null?void 0:k(U))},P=()=>{var b;const N=s.slug||(n==null?void 0:n.slug);!N||!((b=n==null?void 0:n.permissions)!=null&&b.can_manage)||as.record("space.settings.privacy_payments.expanded",{space_slug:N,properties:{section:"privacy_payments",privacy_level:i},context:{path:l.pathname,top_space_slug:(n==null?void 0:n.top_space_slug)||(n==null?void 0:n.slug)||N}}).catch(()=>{})},_=N=>{var U;const b=Fo[N],k=s.slug||(n==null?void 0:n.slug);!b||!k||!((U=n==null?void 0:n.permissions)!=null&&U.can_manage)||as.record(b.eventName,{space_slug:k,properties:{section:b.section},context:{path:l.pathname,top_space_slug:(n==null?void 0:n.top_space_slug)||(n==null?void 0:n.slug)||k}}).catch(()=>{})},$=()=>{const N=j.filter(b=>b.value==i)[0];return N?`${N.label} - ${N.description}`:""},z=()=>{const b=`${i} and ${d?"on":"off"}`,k=L.filter(U=>U.value==b)[0];return k?k.description:""};return w?e.jsxs($e,{style:{height:"100%"},children:[e.jsx(gt,{height:25,width:"40%",mt:30,ml:30}),e.jsx(gt,{height:40,width:"60%",mt:20,mb:20,ml:30})]}):e.jsx(je,{style:{height:"100%"},children:e.jsxs($e,{pt:20,pb:40,pl:40,pr:40,children:[e.jsx(Ma,{setInviteOpened:p}),e.jsxs(ie,{defaultValue:["section-1"],chevronPosition:"right",multiple:!0,pl:5,value:Object.entries(m).filter(([,N])=>N).map(([N])=>`section-${N}`),onChange:N=>{const b={};Bt.forEach(k=>{b[k]=N.includes(`section-${k}`)}),Bt.forEach(k=>{m[k]||!b[k]||(k===0?P():_(k))}),c(b)},children:[e.jsxs(ie.Item,{value:"section-0",children:[e.jsx(ie.Control,{children:a.createElement(I,{...h[0],key:h[0].label,description:`${$()}`})}),e.jsx(ie.Panel,{children:e.jsx(qa,{privacyOptions:j,onUpdate:E,privacySelection:i,setPrivacySelection:o})})]}),e.jsxs(ie.Item,{value:"section-1",children:[e.jsx(ie.Control,{children:a.createElement(I,{...h[1],key:h[1].label,description:`${z()}`})}),e.jsx(ie.Panel,{children:e.jsx(fi,{onUpdate:E,setBlockUntilRegistered:r})})]}),e.jsxs(ie.Item,{value:"section-4",children:[e.jsx(ie.Control,{children:e.jsx(I,{...h[4]})}),e.jsx(ie.Panel,{children:e.jsx(gi,{onUpdate:E})})]},h[4].label),e.jsxs(ie.Item,{value:"section-8",children:[e.jsx(ie.Control,{children:e.jsx(I,{...h[8]})}),e.jsx(ie.Panel,{children:e.jsx(Ni,{onUpdate:E})})]},h[8].label),e.jsxs(ie.Item,{value:"section-3",children:[e.jsx(ie.Control,{children:e.jsx(I,{...h[3]})}),e.jsx(ie.Panel,{children:e.jsx(pi,{onUpdate:E})})]},h[3].label),e.jsxs(ie.Item,{value:"section-5",children:[e.jsx(ie.Control,{children:e.jsx(I,{...h[5]})}),e.jsx(ie.Panel,{children:e.jsx(Do,{})})]},h[5].label),e.jsxs(ie.Item,{value:"section-6",children:[e.jsx(ie.Control,{children:e.jsx(I,{...h[6]})}),e.jsx(ie.Panel,{children:e.jsx(hi,{onUpdate:E,pageUrlsActive:!!m[6]})})]},h[6].label)]}),e.jsx(V,{mb:50}),u&&e.jsx(rn,{opened:u,setOpened:p}),e.jsx(ke,{opened:f,setOpened:g})]})})}const $o="_accordionItem_a8mq8_1",Po="_accordionControl_a8mq8_2",As={accordionItem:$o,accordionControl:Po},Ao="_addStepHover_1tix3_1",Ro="_addStepButtonHover_1tix3_7",zo="_settings_1tix3_
213",No="_dragHandle_1tix3_23",Tt={addStepHover:Ao,addStepButtonHover:Ro,settings:zo,dragHandle:No};function Oo(t){const[s,l]=a.useState([]),[n,i]=a.useState([]),o=ee(f=>f.space),d=ee(f=>f.user),{t:r}=ne();a.useEffect(()=>{o&&o.slug&&u()},[o]);const m=()=>{if(t.trigger==="interested")return"interested";if(t.trigger==="registered")return"members";switch(t.functionSlug){case"sutraautofunction1":return"interested";case"sutraautofunction2":return"members";case"sutraautofunction3":return"interested-members";default:return"members"}},c=Ie({initialValues:{object_type:"broadcast",send_email_to:m(),send_as:d!=null&&d.id?`${d.id}`:"",email_address:"",object_id:""},validate:{send_email_to:f=>f.length>0?null:"Please select a value",send_as:f=>f.length>0?null:"Please select a sender",object_id:f=>f.length>0?null:"Please select an email"}}),u=()=>{he.onFetchSimple(o.slug,{page:1,per:100},f=>{const g=f.map(w=>({value:`${w.id}`,label:w.title}));l([{group:"New email",items:[{value:"new_email",label:"Write a new email"}]},{group:"Select a previously drafted broadcast",items:g}])},()=>{}),Ve.onFetch(o.slug,{page:1,per:1e3},{scope:"",term:""},f=>{i(f.data.map(g=>({value:`${g.user_id}`,label:`${g.full_name} (${g.username})`})))},()=>{})},p=()=>{t.onCreate(c.values)};return e.jsx(V,{children:e.jsxs("form",{onSubmit:c.onSubmit(f=>p()),children:[e.jsxs(ge,{withCssVariables:!1,theme:{primaryShade:6},children:[e.jsx(fe,{label:r("spaces.settings.registration.steps.sendEmail.label1"),placeholder:r("spaces.settings.registration.steps.sendEmail.placeholder1"),comboboxProps:{maxDropdownHeight:400,withinPortal:!0,zIndex:999999},radius:"sm",size:"md",mt:20,data:s,...c.getInputProps("object_id")}),e.jsx(fe,{label:r("spaces.settings.registration.steps.sendEmail.label2"),placeholder:r("spaces.settings.registration.steps.sendEmail.placeholder2"),comboboxProps:{maxDropdownHeight:400,withinPortal:!0,zIndex:999999},radius:"sm",size:"md",mt:20,data:n,...c.getInputProps("send_as")}),e.jsx(fe,{label:r("spaces.settings.registration.steps.sendEmail.label3"),placeholder:r("spaces.settings.registration.steps.sendEmail.placeholder3"),comboboxProps:{maxDropdownHeight:400,withinPortal:!0,zIndex:999999},radius:"sm",size:"md",mt:20,data:[{value:m(),label:m().split("-").reverse().join(" or ").charAt(0).toUpperCase()+m().split("-").reverse().join(" or ").slice(1)},{value:"managers",label:r("spaces.settings.registration.steps.sendEmail.label5")},{value:"custom",label:r("spaces.settings.registration.steps.sendEmail.label6")}],...c.getInputProps("send_email_to")}),c.values.send_email_to==="custom"&&e.jsx(Ue,{mt:20,placeholder:r("spaces.settings.registration.steps.sendEmail.placeholder4"),label:r("spaces.settings.registration.steps.sendEmail.label4"),radius:"sm",size:"md",...c.getInputProps("email_address")})]}),e.jsx(M,{color:"sutrablue",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:r("spaces.settings.registration.steps.sendEmail.saveButton")})]})})}const Lo=520;function Uo(t){const{t:s,i18n:l}=ne(),[n,i]=a.useState(null),[o,d]=a.useState([]),[r,m]=a.useState(!1),[c,u]=a.useState(!1),[p,f]=a.useState(!1),[g,w]=a.useState([]),[x,h]=a.useState([]),[j,L]=a.useState([]),[I,E]=a.useState([]),[P,_]=a.useState([]),[$,z]=a.useState([]),[N,b]=a.useState(!1);a.useRef(!1);const k=ee(S=>S.space);a.useEffect(()=>{if(t.functionSlug&&t.functions){const S=t.functions.filter(W=>W.slug==t.functionSlug)[0];S&&S.actions&&d(Oi(S.actions).map(W=>({label:W.name,value:W.slug,description:W.selection_description,icon:W.type})))}t.selectedStep?i(t.selectedStep.action_slug):i()},[t]),a.useEffect(()=>{m(k&&k.permissions&&k.permissions.can_add_step_send_to_pending),u(k&&k.permissions&&k.permissions.can_add_add_to_existing_space),f(k&&k.permissions&&k.permissions.can_add_step_wait),w(k&&k.permissions&&k.permissions.can_add_step_survey_person),w(k&&k.permissions&&k.permissions.can_add_step_survey_person),h(k&&k.permissions&&k.permissions.can_add_step_send_email),z(k&&k.permissions&&k.permissions.can_add_step_webhook),L(k&&k.permissions&&k.permissions.can_send_message),E(k&&k.permissions&&k.permissions.can_add_from_children),_(k&&k.permissions&&k.permissions.can_add_to_direct_open_children)},[k]),a.useEffect(()=>{const S=Li({slug:n,steps:t.steps,permissions:k==null?void 0:k.permissions,selectedStep:t.selectedStep});if(S){b(Zt(S)),i(null);return}
2H(n)=="set_to_pending"&&!r[0]&&(b([!0,r[1],r[2]]),i(null)),H(n)=="add_to_existing_space"&&!c[0]&&(b([!0,c[1],c[2]]),i(null)),H(n)=="wait"&&!p[0]&&(b([!0,p[1],p[2]]),i(null)),H(n)=="survey_person"&&!g[0]&&(b([!0,g[1],g[2]]),i(null)),H(n)=="send_email"&&!x[0]&&(b([!0,x[1],x[2]]),i(null)),H(n)=="send_message"&&!j[0]&&(b([!0,j[1],j[2]]),i(null)),["add_from_children","add_from_sub_space"].includes(H(n))&&!I[0]&&(b([!0,I[1],I[2]]),i(null)),H(n)=="add_to_direct_open_children"&&!P[0]&&(b([!0,P[1],P[2]]),i(null)),H(n)=="webhook"&&!$[0]&&(b([!0,$[1],$[2]]),i(null))},[n]);const U=()=>{t.selectedStep?T():D()},H=S=>{const W=o.filter(te=>te.value==S)[0];return W?W.icon:""},D=S=>{Xe.onCreate(k.slug,t.triggerId,{action_slug:n,position:t.position,params:S},W=>{H(n)=="send_email"||H(n)=="send_message"&&S.object_id=="new_message"||H(n)=="survey_person"&&S.object_id=="new_survey"?t.setTriggerEdit(W.data.id):t.onUpdate(),setTimeout(()=>{t.setOpened(!1)},200)},W=>{W!=null&&W.permissions&&b(Zt(W.permissions))})},T=()=>{Xe.onUpdate(t.selectedStep.id,k.slug,t.triggerId,{action_slug:n,position:t.position},S=>{t.onUpdate(),t.setOpened(!1)},S=>{S!=null&&S.permissions&&b(Zt(S.permissions))})},B=()=>{Xe.onDestroy(t.selectedStep.id,k.slug,t.triggerId,S=>{t.onUpdate(),t.setOpened(!1)},S=>{})},y=()=>{switch(H(n)){case"send_email":return e.jsx(Oo,{onCreate:D,mode:"add",trigger:t.trigger,functionSlug:t.functionSlug,settings:t.settings,onSettingsChange:t.onSettingsChange});case"send_message":return e.jsx(Qi,{onCreate:D,mode:"add",trigger:t.trigger,settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_to_existing_space":return e.jsx(Xi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_to_direct_open_children":return e.jsx(Zi,{onCreate:D,mode:"add"});case"add_to_new_space":return e.jsx(Yi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_from_sub_space":return e.jsx(Ki,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"apply_template":return e.jsx(qi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"set_to_pending":return e.jsx(Gi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"survey_person":return e.jsx(Wi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"webhook":return e.jsx(Hi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"google_calendar_invite":return e.jsx(Mi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"wait":return e.jsx(Vi,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"remove_from_space":return e.jsx(Is,{onCreate:D,mode:"remove"});case"remove_contact_from_space":return e.jsx(Is,{onCreate:D,mode:"remove",translationScope:"remove_contact_from_space"});default:return n&&e.jsx(Ui,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange})}},R=e.jsxs(e.Fragment,{children:[e.jsx(fe,{label:s("spaces.settings.registration.addStep.addStep.label"),value:n,onChange:i,placeholder:s("spaces.settings.registration.addStep.addStep.placeholder"),renderOption:({option:S})=>e.jsxs(Z,{wrap:"nowrap",children:[e.jsx(bn,{icon:S.icon}),e.jsxs("div",{children:[e.jsx(v,{size:"lg",fw:600,children:S.label}),e.jsx(v,{size:"md",c:"dimmed",children:S.description})]})]}),data:o,comboboxProps:{withinPortal:!0,zIndex:999999},maxDropdownHeight:Lo,radius:"sm",size:"md"}),y(),!t.functionsType&&e.jsxs(Z,{justify:"space-between",mt:20,children:[e.jsx(M,{radius:"xl",onClick:()=>U(),children:"Save"}),t.selectedStep&&t.selectedStep.id&&e.jsx(M,{radius:"xl",color:"red",onClick:()=>B(),children:"Delete"})]}),e.jsx(V,{mt:100})]});return e.jsxs(e.Fragment,{children:[e.jsx(ms,{opened:t.opened,onClose:()=>{t.setOpened(!1),i(null)},title:e.jsx(v,{size:"xl",fw:"800",children:t.selectedStep?t.selectedStep.action:s("spaces.settings.registration.addStep.addStep.description")}),padding:"xl",size:600,zIndex:t.zIndex,offsetScrollbars:!0,closeOnEscape:!1,children:e.jsx(je,{style:{height:"100%"},children:R})}),e.jsx(ke,{opened:N,setOpened:b})]})}const Vo=t=>({item:{display:"flex",alignItems:"center",gap:t.spacing.md,borderRadius:t.radius.md,border:`1px solid ${t.colors.gray[4]}`,padding:"15px 20px 15px 5px",backgroundColor:"#fff"},itemDragging:{boxShadow:t.shadows.sm},stepFooterPadding:{display:"flex",flexFlow:"row",justifyContent:"spaceBetween"},stepFooterLeft:{borderRight:`1px solid ${t.colors.gray[4]}`,height:10,width:"100%"},stepFooterRight:{borderLeft:`1px solid ${t.colors.gray[4]}`,height:10,width:"100%"},stepFooterAddStep:{display:"flex",justifyContent:"center",fontSize:16},addStepHidden:{visibility:"hidden"},bottomConnector:{fontSize:20,color:t.colors.gray[4],marginTop:-15,textAlign:"center",height:20},addStepButtonWrap:{width:"100%",display:"flex",justifyContent:"center",marginTop:5}}),Mo=({id:t,children:s})=>{const{attributes:l,listeners:n,setNodeRef:i,transform:o,transition:d,isDragging:r}=sn({id:t}),m={transform:nn.Transform.toString(o),transition:d};return e.jsx("div",{ref:i,style:m,...l,children:s({listeners:n,isDragging:r})})};function Ho({trigger:t,onUpdateTriggers:s,functions:l,functionsType:n,setOpenAddStep:i,openAddStep:o}){const{t:d}=ne(),r=we(),m=Vo(r),c=ee(F=>
2F.space),[u,p]=a.useState(!1),[f,g]=a.useState(!1),[w,x]=a.useState(!1),[h,j]=ps([]),L=Ks(Ys(Zs,{activationConstraint:{distance:5}})),[I,E]=a.useState(""),[P,_]=a.useState(null),[$,z]=a.useState(null),[N,b]=a.useState(!1),[k,U]=a.useState(null),[H,D]=a.useState(null),T=a.useRef(!1);a.useEffect(()=>{o==t.id&&(p(!0),i(!1))},[o]),a.useEffect(()=>{B()},[t]),a.useEffect(()=>{I&&(I.type==="send_email"?S(I):g(!0))},[I]),a.useEffect(()=>{f||E("")},[f]),a.useEffect(()=>{N||(U(null),D(null),(I==null?void 0:I.type)==="send_email"&&E(""))},[N]),a.useEffect(()=>{},[u]),a.useEffect(()=>{$&&B($)},[$]),a.useEffect(()=>{T.current?ae():T.current=!0},[h]);const B=(F=null)=>{c.slug&&Xe.onFetch(c.slug,t.id,q=>{if(j.setState(q),T.current=!0,F){const O=q.filter(ce=>ce.id===F)[0];E(O)}z(null)},q=>{})},y=()=>{B()},R=()=>{switch(t.function_slug){case"sutraautofunction1":return"interested";case"sutraautofunction2":return"members";case"sutraautofunction3":return"interested-members";default:return"members"}},S=F=>{var O;U(F),D(null);const q=(O=F==null?void 0:F.params)==null?void 0:O.object_id;q&&`${q}`!="0"&&`${q}`!="new_email"?he.onFetchById(q,c.slug,ce=>{D(ce),b(!0)},()=>{b(!0)}):b(!0)},W=(F,q)=>{const O=k||I;if(!(O!=null&&O.id)){typeof q=="function"&&q();return}Xe.onUpdate(O.id,c.slug,t.id,{action_slug:O.action_slug,position:O.position,params:F},()=>{B(),typeof q=="function"&&q(!0)},()=>{oe.fire("Error","Could not save the automation step.","error"),typeof q=="function"&&q(!1)})},te=()=>{const F=k||I;F!=null&&F.id&&oe.fire({title:"Are you sure?",html:"This step will be permanently deleted",showDenyButton:!0,confirmButtonText:"Delete step",denyButtonText:"Cancel",confirmButtonColor:r.colors.red[8],denyButtonColor:r.colors.gray[6]}).then(q=>{q.isConfirmed&&Xe.onDestroy(F.id,c.slug,t.id,()=>{b(!1),B()},()=>{oe.fire("Error","Could not delete the automation step.","error")})})},A=F=>{var q;if(((q=F==null?void 0:F.params)==null?void 0:q.action)==="wait_until"){const O=Me.fromISO(F.params.wait_until,{zone:"utc"}).toLocal().toFormat("EEE, MMM dd yyyy, h:mm a");return`${F.name} ${O}`}return F.name},J=F=>e.jsx("div",{children:e.jsx("div",{style:w?m.addStepHidden:{},children:e.jsxs("div",{children:[e.jsxs("div",{style:m.stepFooterPadding,children:[e.jsx("div",{style:m.stepFooterLeft}),e.jsx("div",{style:m.stepFooterRight})]}),e.jsx("div",{style:m.stepFooterAddStep,children:e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:5},children:e.jsx(Fe,{size:"sm",radius:"xl",variant:"outline",color:"gray",onClick:()=>{E(""),p(!0),_(F)},className:Tt.addStepHover,children:e.jsx(C,{icon:He.faPlus})})})}),e.jsxs("div",{style:m.stepFooterPadding,children:[e.jsx("div",{style:m.stepFooterLeft}),e.jsx("div",{style:m.stepFooterRight})]}),e.jsx("div",{style:m.bottomConnector,children:e.jsx(C,{icon:mn.faCaretDown})})]})})}),ae=()=>{if(h.length==0)return;const F=h.map((q,O)=>({id:q.id,position:O+1}));Xe.onReorder(c.slug,t.id,F,q=>{},q=>{})},be=()=>{ls.onDestroy(t.id,c.slug,F=>{s()},F=>{})},Ee=h.map((F,q)=>e.jsx(Mo,{id:F.id.toString(),children:({listeners:O,isDragging:ce})=>e.jsxs("div",{children:[e.jsxs("div",{style:ce?{...m.item,...m.itemDragging}:{...m.item},...O,children:[e.jsx(bn,{icon:F.type}),e.jsxs(V,{style:{flex:1,minWidth:0},children:[e.jsx(v,{fw:600,children:A(F)}),e.jsx(v,{c:"dimmed",size:"sm",children:F.description})]}),e.jsxs(Z,{gap:0,wrap:"nowrap",children:[e.jsx(Fe,{size:"sm",radius:"xl",onClick:()=>E(F),className:Tt.settings,children:e.jsx(C,{icon:cn.faCog})}),e.jsx("div",{className:Tt.dragHandle,children:e.jsx(C,{icon:Xs.faGripVertical})})]})]}),J(q+1)]})},F.id.toString()));return e.jsxs(V,{pt:20,children:[e.jsx(Qs,{sensors:L,collisionDetection:Js,modifiers:[dn,un],onDragStart:()=>x(!0),onDragEnd:({active:F,over:q})=>{if(x(!1),!q||F.id===q.id)return;const O=h.findIndex(me=>me.id.toString()===F.id),ce=h.findIndex(me=>me.id.toString()===q.id);O===-1||ce===-1||j.reorder({from:O,to:ce})},children:e.jsx(en,{items:h.map(F=>F.id.toString()),strategy:tn,children:Ee})}),e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:5},children:e.jsx("div",{style:m.addStepButtonWrap,children:e.jsx(M,{onClick:()=>{E(""),p(!0),_(null)},className:Tt.addStepButtonHover,variant:"outline",color:"gray",radius:"xl",children:d("space
2s.settings.registration.registrationFlow.registration.addButton")})})}),e.jsx(Z,{justify:"flex-end",children:e.jsxs(Q,{position:"bottom-end",withArrow:!0,children:[e.jsx(Q.Target,{children:e.jsx(Fe,{variant:"subtle",color:"gray","aria-label":"Step actions",children:e.jsx(C,{icon:Ot.faEllipsisVertical})})}),e.jsx(Q.Dropdown,{children:e.jsx(Q.Item,{color:"red",leftSection:e.jsx(sa,{size:14}),onClick:()=>be(),children:"Delete"})})]})}),e.jsx(Ji,{opened:f,setOpened:g,step:I,allSteps:h,triggerId:t.id,trigger:t,settings:c,onUpdate:y,functions:l,functionsType:n,functionSlug:t.function_slug}),e.jsx(Uo,{opened:u,setOpened:p,position:P,settings:c,triggerId:t.id,onUpdate:y,selectedStep:I,steps:h,setTriggerEdit:z,functions:l,functionsType:n,functionSlug:t.function_slug}),e.jsx(Lt,{opened:N,setOpened:b,mode:"automation",broadcast:H,automationStep:k,automationDefaultSendEmailTo:R(),automationPersonLabel:"Person",onAutomationSave:W,onAutomationDestroy:te,onUpdate:y,parentName:c.name,isTopLevel:c.is_top_level,isEmailReady:window.$fetchedTopSpace.is_email_ready})]})}function Wo({onUpdate:t,functionsType:s,addTriggerOpened:l,setAddTriggerOpened:n,showAddTriggerButton:i=!0}){const o=we();pn();const d=ee(A=>A.space),{t:r,i18n:m}=ne(),[c,u]=a.useState([]),[p,f]=a.useState(!1),[g,w]=a.useState(!1),[x,h]=ps([]),[j,L]=a.useState(""),[I,E]=a.useState(null),[P,_]=a.useState([]),[$,z]=a.useState([]),[N,b]=a.useState(!1),[k,U]=a.useState({}),[H,D]=a.useState(null),T=s==="automation",B=A=>A.function_slug!=="participation_threshold"?A.active===!1?"Inactive":"Active":A.setup_status==="preparing"?"Preparing":A.setup_status==="failed"?"Setup failed":A.active!==!1&&A.setup_status==="ready"?"Active":"Inactive";a.useEffect(()=>{y()},[]),a.useEffect(()=>{R()},[d]);const y=()=>{Es.onFetch(s,A=>{_(A.map(J=>({label:J.name,value:J.slug}))),z(A)},A=>{})},R=(A=!1)=>{d.slug&&ls.onFetch(d.slug,s,J=>{const ae={};for(let be=0;be<J.length;be++)ae[be]=!1;u(J),h.setState(J),setTimeout(()=>{A&&(ae[J.length-1]=!0),U(ae)},500)},J=>{})},S=()=>{d.slug&&Es.onMigrate(d.slug,A=>{R(!0),alert("Migrated")},A=>{})},W=(A,J)=>{A.stopPropagation(),oe.fire({title:"Delete this automation?",html:"This automation and all of its steps will be permanently deleted. This can't be undone.",showDenyButton:!0,confirmButtonText:"Delete automation",denyButtonText:"Cancel",confirmButtonColor:o.colors.red[8],denyButtonColor:o.colors.gray[6]}).then(ae=>{ae.isConfirmed&&ls.onDestroy(J.id,d.slug,()=>{R()},()=>{})})},te=({label:A,description:J,index:ae})=>e.jsx(Z,{wrap:"nowrap",children:e.jsxs("div",{children:[e.jsx(v,{size:"lg",fw:700,children:A}),k[ae]?"":e.jsx(v,{size:"sm",c:"dimmed",fw:400,children:J})]})});return e.jsxs(e.Fragment,{children:[s?e.jsx(v,{size:"sm",c:"dimmed",mb:20,children:"This section allows you to sequence automated actions that are triggered based on various events that you can configure. Here you can do things like schedule emails and automatically add people to select spaces when they register."}):e.jsxs(e.Fragment,{children:[e.jsx(v,{size:"sm",c:"dimmed",mb:20,children:r("spaces.settings.registration.registrationFlow.registration.description1")}),e.jsx(v,{size:"lg",mb:5,children:r("spaces.settings.registration.registrationFlow.registration.description2")})]}),T?e.jsx(V,{children:c.map((A,J)=>e.jsxs("div",{className:Be.launchCard,onClick:()=>D(A),children:[e.jsxs("div",{children:[e.jsx("div",{className:Be.launchTitle,children:A.name_with_variable}),e.jsx("div",{className:Be.launchSub,children:Yt(A)}),Kt(A)&&e.jsx("div",{className:Be.launchDetails,children:e.jsx("span",{className:Be.triggerDetailBadge,children:Kt(A)})})]}),e.jsxs("div",{className:Be.launchMeta,children:[e.jsx("span",{className:B(A)==="Active"?Be.launchBadgeActive:B(A)==="Preparing"?Be.launchBadgePreparing:B(A)==="Setup failed"?Be.launchBadgeFailed:Be.launchBadgeInactive,children:B(A)}),A.steps_count!=null&&e.jsxs("span",{className:Be.launchBadge,children:[A.steps_count," ",A.steps_count===1?"step":"steps"]}),e.jsxs(Q,{position:"bottom-end",withinPortal:!0,shadow:"md",width:210,children:[e.jsx(Q.Target,{children:e.jsx(Fe,{variant:"subtle",color:"gray","aria-label":"Automation actions",onClick:ae=>ae.stopPropagation(),children:e.jsx(C,{icon:Ot.faEllipsisVertical})})}),e.jsx(Q.Dropdown,{children:e.jsx(Q.Item,{color:"red",leftSection:e.jsx(C,{icon:jt.faTrash}),onClick:ae=>W(ae,A),children:"Delete automation"})})]})]})]},A.id||`trigger-${J}`))}):e.jsx(ie,{chevronPosition:"right",chevron:e.jsx(C,{icon:He.faPlus}),classNames:{item:As.accordionItem,control:As.accordionControl},styles:{item:{border:"1px solid #dee2e6",marginBottom:"10px",borderRadius:"10px"},content:{padding:"10px 20px 20px 20px"}},multiple:!0,value:c.map((A,J)=>
2({key:A.slug||(A.id?String(A.id):`trigger-${J}`),open:k[J]})).filter(A=>A.open).map(A=>A.key),onChange:A=>{const J={};c.forEach((ae,be)=>{const Ee=ae.slug||(ae.id?String(ae.id):`trigger-${be}`);J[be]=A.includes(Ee)}),U(J)},children:c.map((A,J)=>e.jsxs(ie.Item,{value:A.slug||(A.id?String(A.id):`trigger-${J}`),children:[e.jsx(ie.Control,{children:e.jsx(te,{label:A.name_with_variable,description:Yt(A),index:J})}),e.jsx(ie.Panel,{children:e.jsx(Ho,{trigger:A,onUpdateTriggers:R,functions:$,functionsType:s,openAddStep:N,setOpenAddStep:b})})]}))}),e.jsxs(Z,{justify:"space-between",children:[e.jsx(na,{onUpdateTriggers:R,functions:P,oriFunctions:$,functionsType:s,opened:l,setOpened:n,showButton:i}),window.$currentRole=="admin"&&s=="automation"&&!window.$spaceIsMigrated&&e.jsx(V,{mt:25,children:e.jsx(M,{color:"gray.6",radius:"xl",onClick:()=>S(),children:"Migrate legacy"})})]}),e.jsx(ea,{opened:!!H,trigger:H,functions:$,triggerDescription:H?Yt(H):"",triggerDetailLabel:H?Kt(H):null,onClose:()=>D(null),onTriggerUpdated:A=>{A!=null&&A.id&&(u(J=>J.map(ae=>ae.id===A.id?{...ae,...A}:ae)),D(J=>(J==null?void 0:J.id)===A.id?{...J,...A}:J))}})]})}const Ne=class Ne{constructor(){if(this instanceof Ne)throw Error("Journey class cannot be instantiated.")}};Te(Ne,"onFetch",async(s,l,n,i)=>{const o={locale:window.$currentUserLanguage,...l};await window.$api.get(`/api/v4/spaces/${s}/journeys.json`,{params:o}).then(d=>{n(d.data)}).catch(d=>{try{i(d.response.data)}catch{}})}),Te(Ne,"onFetchById",async(s,l,n,i)=>{const o={locale:window.$currentUserLanguage};await window.$api.get(`/api/v4/spaces/${l}/journeys/${s}.json`,{params:o}).then(d=>{n(d.data)}).catch(d=>{try{i(d.response.data)}catch{}})}),Te(Ne,"onFetchByTrigger",async(s,l,n,i)=>{const o={locale:window.$currentUserLanguage,trigger:s};await window.$api.get(`/api/v4/spaces/${l}/journeys/trigger.json`,{params:o}).then(d=>{n(d.data)}).catch(d=>{try{i(d.response.data)}catch{}})}),Te(Ne,"onFetchActions",async(s,l,n,i,o)=>{const d={locale:window.$currentUserLanguage,trigger:s,position:l};await window.$api.get(`/api/v4/spaces/${n}/journeys/actions.json`,{params:d}).then(r=>{i(r.data)}).catch(r=>{try{o(r.response.data)}catch{}})}),Te(Ne,"onCreate",async(s,l,n,i)=>{const o={locale:window.$currentUserLanguage,journey:l};await window.$api.post(`/api/v4/spaces/${s}/journey.json`,o).then(d=>{n(d.data)}).catch(d=>{try{i(d.response.data)}catch{}})}),Te(Ne,"onUpdate",async(s,l,n,i,o)=>{const d={locale:window.$currentUserLanguage,journey:n};await window.$api.put(`/api/v4/spaces/${l}/journeys/${s}.json`,d).then(r=>{i(r.data)}).catch(r=>{try{o(r.response.data)}catch{}})});let $t=Ne;const Ye=class Ye{constructor(){if(this instanceof Ye)throw Error("Step class cannot be instantiated.")}};Te(Ye,"onCreate",async(s,l,n,i,o)=>{const d={locale:window.$currentUserLanguage,step:n};await window.$api.post(`/api/v4/spaces/${s}/journeys/${l}/steps.json`,d).then(r=>{i(r.data)}).catch(r=>{try{o(r.response.data)}catch{}})}),Te(Ye,"onUpdate",async(s,l,n,i,o,d)=>{const r={locale:window.$currentUserLanguage,step:i};await window.$api.put(`/api/v4/spaces/${l}/journeys/${n}/steps/${s}.json`,r).then(m=>{o(m.data)}).catch(m=>{try{d(m.response.data)}catch{}})}),Te(Ye,"onReorder",async(s,l,n,i,o)=>{const d={locale:window.$currentUserLanguage,steps:n};await window.$api.post(`/api/v4/spaces/${s}/journeys/${l}/steps/reorder.json`,d).then(r=>{i(r.data)}).catch(r=>{try{o(r.response.data)}catch{}})}),Te(Ye,"onDestroy",async(s,l,n,i,o)=>{const d={locale:window.$currentUserLanguage};await window.$api.delete(`/api/v4/spaces/${l}/journeys/${n}/steps/${s}.json`,{params:d}).then(r=>{i(r.data)}).catch(r=>{try{o(r.response.data)}catch{}})});let at=Ye;function kn(t){const s=ee(r=>r.space),[l,n]=a.useState(null),{t:i,i18n:o}=ne(),d=()=>{t.mode==="edit"?t.onUpdate({object_type:"pod",object_id:s.id}):t.onCreate({object_type:"pod",object_id:s.id})};return e.jsx(V,{children:t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",onClick:r=>d(),type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:i("spaces.settings.registration.steps.addToNewSpace.saveButton1")}),e.jsx(M,{onClick:r=>t.onDestroy(r),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:i("spaces.settings.registration.steps.addToNewSpace.deleteButton")})]}
2):e.jsx(M,{type:"submit",onClick:r=>d(),leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:i("spaces.settings.registration.steps.addToNewSpace.saveButton2")})})}function Go(t){const[s,l]=a.useState(),[n,i]=a.useState([]),{t:o,i18n:d}=ne(),r=ee(h=>h.space),m=a.useRef(!1);a.useEffect(()=>{t.step&&p()},[t]);const c=()=>t.trigger==="interested"?"interested":t.trigger==="registered"?"members":"interested-members",u=Ie({initialValues:{title:"",content:"",content_json:"",send_as:"",send_email_to:c(),email_address:"",status:"journey_draft"},validate:{title:h=>h.length>0?null:"Write a title",content:h=>h.length>0?null:"Add some content"}}),p=()=>{u.setFieldValue("send_as",t.step.send_as),u.setFieldValue("send_email_to",t.step.send_email_to),u.setFieldValue("email_address",t.step.email_address),t.step.object_id?he.onFetchById(t.step.object_id,r.slug,h=>{m.current=!0,l({...h}),u.setFieldValue("title",h.title),u.setFieldValue("content",h.content),u.setFieldValue("content_json",h.content_json)},h=>{}):m.current=!0,Ve.onFetch(r.slug,{page:1,per:1e3},{scope:"",term:""},h=>{const j=h.data.map((L,I)=>({value:`${L.user_id}`,label:`${L.full_name} (${L.username})`}));i(j)},h=>{})},f=(h=null)=>{const j={title:u.values.title,content:u.values.content,content_json:u.values.content_json,user_id:u.values.send_as,status:u.values.status},L={send_as:u.values.send_as,send_email_to:u.values.send_email_to,email_address:u.values.email_address};t.step&&t.step.object_id?(he.onUpdate(t.step.object_id,r.slug,j,I=>{},I=>{}),t.onUpdate(L)):he.onCreate(r.slug,j,I=>{const E={...L,object_id:I.id};t.onUpdate(E)},I=>{})},g=()=>{f("")},w=h=>{t.onDestroy(h)},x=(h,j,L,I)=>{u.setFieldValue("content_json",h.content),u.setFieldValue("content",j)};return m.current?e.jsx(V,{children:e.jsxs("form",{onSubmit:u.onSubmit(h=>g()),children:[e.jsxs(ge,{withCssVariables:!1,theme:{primaryShade:6},children:[e.jsx(Ue,{...u.getInputProps("title"),mt:30,mb:20,placeholder:o("spaces.settings.registration.steps.editEmail.placeholder1"),radius:"sm",size:"md"}),e.jsx(_s,{editable:!0,content:s?s.content_json:"",modals:!0,onUpdate:x,exclude:["video","embed","link-action","link-format"],mediaLibraryEnabled:!0}),e.jsx(v,{mt:10,size:"xs",children:"Use {{first_name}}, {{last_name}}, {{username}}, {{start_date}}, {{event_link}}, {{space_name}}, {{space_link}}, and {{space_name_link}} to autopopulate the corresponding information"}),e.jsx(fe,{label:o("spaces.settings.registration.steps.editEmail.label1"),placeholder:o("spaces.settings.registration.steps.editEmail.placeholder2"),comboboxProps:{maxDropdownHeight:400},radius:"sm",size:"md",mt:20,data:n,...u.getInputProps("send_as")}),e.jsx(fe,{label:o("spaces.settings.registration.steps.editEmail.label2"),placeholder:o("spaces.settings.registration.steps.editEmail.placeholder3"),comboboxProps:{maxDropdownHeight:400},radius:"sm",size:"md",mt:20,data:[{value:c(),label:c().split("-").reverse().join(" or ").charAt(0).toUpperCase()+c().split("-").reverse().join(" or ").slice(1)},{value:"managers",label:"Managers"},{value:"custom",label:"Custom email address"}],...u.getInputProps("send_email_to")}),u.values.send_email_to=="custom"&&e.jsx(Ue,{mt:20,placeholder:o("spaces.settings.registration.steps.editEmail.placeholder4"),label:o("spaces.settings.registration.steps.editEmail.label3"),radius:"sm",size:"md",...u.getInputProps("email_address")})]}),e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:o("spaces.settings.registration.steps.editEmail.saveButton")}),e.jsx(M,{onClick:h=>w(h),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:o("spaces.settings.registration.steps.editEmail.deleteButton")})]})]})}):null}function En(t){const[s,l]=a.useState(),[n,i]=a.useState([]),{t:o,i18n:d}=ne(),r=ee(j=>j.space),m=ee(j=>j.user),c=a.useRef(!1);a.useEffect(()=>{f()},[t]);const p=Ie({initialValues:{title:"",content:"",content_json:"",send_as:"",send_email_to:"registered",email_address:"",status:"journey_draft"},validate:{title:j=>j.length>0?null:"Write a title",content:j=>j.length>0?null:"Add some content"}}),f=()=>{t.step&&t.step.object_id?he.onFetchById(t.step.object_id,r.slug,j=>{c.current=!0,l({...j}),p.setFieldValue("title",j.title),p.setFieldValue("content",j.content),p.setFieldValue("content_json",j.content_json)},j=>{}):(p.setFieldValue("title","Automated direct message"),p.setFieldValue("send_as",m.id),c.current=!0),Ve.onFetch(r.slug,{page:1,per:1e3},{scope:"",term:""},j=>{const L=j.data.map((I,E)=>({value:`${I.user_id}`,label:I.full_name}));i(L)},j=>{})},g=(j=null)=>{const L={title:p.values.title,content:p.values.content,content_json:p.values.content_json,user_id:p.values.send_as,status:p.values.status},I={send_as:p.values.send_as,send_email_to:p.values.send_email_to,email_address:p.values.email_address};t.step&&t.step.object_id?(he.onUpdate(t.step.object_id,r.slug,L,E=>{},E=>{}),t.onUpdate(I)):he.onCreate(r.slug,L,E=>{const P={...I,object_id:E.id};t.onCreate(P)},E=>{})},w=()=>{g("")},x=j=>
2{t.onDestroy(j)},h=(j,L,I,E)=>{p.setFieldValue("content_json",j.content),p.setFieldValue("content",L)};return c.current?e.jsx(V,{mt:20,children:e.jsxs("form",{onSubmit:p.onSubmit(j=>w()),children:[e.jsxs(ge,{withCssVariables:!1,theme:{primaryShade:6},children:[e.jsx(_s,{editable:!0,content:s?s.content_json:"",modals:!0,onUpdate:h,exclude:["video","embed","link-action","link-format"],mediaLibraryEnabled:!0}),e.jsx(v,{mt:10,size:"xs",children:"Use {{first_name}}, {{last_name}}, {{start_date}}, {{event_link}}, {{space_name}}, {{space_link}}, and {{space_name_link}} to autopopulate the corresponding information"})]}),e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:o("spaces.settings.registration.steps.editEmail.saveButton")}),e.jsx(M,{onClick:j=>x(j),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:o("spaces.settings.registration.steps.editEmail.deleteButton")})]})]})}):null}const Jt=t=>t!=null&&t.id?{value:`${t.id}`,label:`${t.name} (${t.slug})`}:null,Rs=t=>t.map(s=>({...s,items:[...s.items]})),qo=(t,s)=>t.some(l=>l.items.some(n=>n.value===s)),Ko=(t,s)=>{t.forEach(l=>{l.items=l.items.filter(n=>n.value!==s)})},kt=(t,s,l,{preferGroup:n=!1}={})=>{if(l){if(n)Ko(t,l.value);else if(qo(t,l.value))return;t[s].items.push(l)}},zs=50,Yo=400,Ns=()=>[{group:"Sub spaces",items:[]}
2,{group:"All spaces",items:[]}];function In(t){var E;const s=ee(P=>P.space),[l,n]=a.useState([]),[i,o]=a.useState(""),[d,r]=a.useState(!1),{t:m}=ne(),c=a.useRef(),u=a.useRef(0),p=a.useRef(null),f=t.mode==="edit"&&((E=t==null?void 0:t.step)!=null&&E.object_id)?`${t.step.object_id}`:"",g=Ie({initialValues:{object_type:"pod",object_id:""},validate:{object_id:P=>P.length>0?null:"Please select a space"}}),w=g.getInputProps("object_id");a.useEffect(()=>{x(),f&&g.setFieldValue("object_id",f)},[s==null?void 0:s.slug,t.mode,f]),a.useEffect(()=>{f&&pe.onFetchSimple(f,"simple",P=>{const _=Jt(P);_&&(p.current=_,o(_.label),n($=>{const z=$.length>0?Rs($):Ns();return kt(z,1,_),z}))},()=>{})},[f]),a.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const x=(P=null)=>{if(!(s!=null&&s.slug)){n([]),r(!1);return}const _=u.current+1;u.current=_;const $=Ns(),z=()=>{if(u.current===_){const b=Rs($);kt(b,1,p.current),n(b),r(!1)}},N=["members","simple"];P&&N.push(`q=${P}`),pe.onFetchDeepChildren(s.slug,[...N,"order=name_asc"],{page:1,per:zs},["active_or_pending"],b=>{(Array.isArray(b==null?void 0:b.data)?b.data:[]).forEach(U=>kt($,0,Jt(U),{preferGroup:!0})),z()},()=>{z()}),pe.onFetchManaged([],N,{page:1,per:zs},b=>{(Array.isArray(b)?b:Array.isArray(b==null?void 0:b.data)?b.data:[]).forEach(U=>kt($,1,Jt(U))),z()},()=>{z()})},h=()=>{t.mode==="edit"?t.onUpdate(g.values):t.onCreate(g.values)},j=P=>{var z;const _=(z=p.current)==null?void 0:z.label;if(_&&P===_){o(P);return}const $=_&&P.startsWith(_)?P.slice(_.length):P;o($),r(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{x($)},Yo)},L=P=>{var _;i&&(o(""),c.current&&clearTimeout(c.current),x()),(_=w.onFocus)==null||_.call(w,P)},I=(P,_)=>{p.current=_!=null&&_.value?{value:_.value,label:_.label}:null,o((_==null?void 0:_.label)||""),w.onChange(P)};return e.jsx(V,{children:e.jsxs("form",{onSubmit:g.onSubmit(P=>h()),children:[e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(fe,{leftSection:d?e.jsx(Oe,{size:"xs"}):e.jsx(C,{icon:Nt.faSearch}),label:m("spaces.settings.registration.steps.addToExistingSpace.label"),searchable:!0,mt:20,data:l,placeholder:m("spaces.settings.registration.steps.addToExistingSpace.placeholder"),...w,onChange:I,onFocus:L,searchValue:i,comboboxProps:{maxDropdownHeight:400},radius:"sm",size:"md",onSearchChange:j})}),t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:m("spaces.settings.registration.steps.addToExistingSpace.saveButton1")}),e.jsx(M,{onClick:P=>t.onDestroy(P),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:m("spaces.settings.registration.steps.addToExistingSpace.deleteButton")})]}):e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:m("spaces.settings.registration.steps.addToExistingSpace.saveButton2")})]})})}function Dn(t){const s=ee(c=>c.space),[l,n]=a.useState(null),{t:i}=ne(),o=Ie({initialValues:{intention:"",version:"discussion",privacy_level:"private",pod_state:"model"},validate:{intention:c=>c.length>0?null:"Please add a name for your space"}});a.useEffect(()=>{t.mode==="edit"&&d()},[t]);const d=()=>{t.step&&pe.onFetchSimple(t.step.object_id,"basic",c=>{o.setFieldValue("intention",c.name),n(c.slug)},c=>{})},r=()=>{t.mode==="edit"?pe.onUpdate(l,o.values,c=>{t.onUpdate({object_type:"pod",object_id:t.step.object_id})},c=>{}):pe.onCreate(o.values,s.id,c=>{t.onCreate({object_type:"pod",object_id:c.id})},c=>{})},m=c=>{pe.onDestroy(l,u=>{t.onDestroy(c)},u=>{_i(u,"delete",i)})};return e.jsx(V,{children:e.jsxs("form",{onSubmit:o.onSubmit(c=>r()),children:[e.jsx(Ue,{mt:20,placeholder:i("spaces.settings.registration.steps.addToNewSpace.placeholder"),description:"Add a naming pattern for your space. You can use {{first_name}} and {{last_name}} to insert the person's name.",label:i("spaces.settings.registration.steps.addToNewSpace.label"),value:`${s.name} - {{first_name}} {{last_name}}`,radius:"sm",size:"md",...o.getInputProps("intention")}),t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:i("spaces.settings.registration.steps.addToNewSpace.saveButton1")}),e.jsx(M,{onClick:c=>m(c),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:i("spaces.settings.registration.steps.addToNewSpace.deleteButton")})]}
2):e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:i("spaces.settings.registration.steps.addToNewSpace.saveButton2")})]})})}function Fn(t){const s=ee(g=>g.space),[l,n]=a.useState([]),[i,o]=a.useState(!1),d=a.useRef(),{t:r,i18n:m}=ne(),c=Ie({initialValues:{object_type:"pod",object_id:""},validate:{object_id:g=>g.length>0?null:"Please select a space"}});a.useEffect(()=>{u()},[]);const u=()=>{const g=[],w=[];pe.onFetchChildren(s.slug,["members"],{page:1,per:50},["active"],x=>{for(let h=0;h<x.data.length;h++)g.push({value:`${x.data[h].id}`,label:`${x.data[h].name} (${x.data[h].slug})`});t.mode==="edit"&&c.setFieldValue("object_id",`${t.step.object_id}`)},x=>{}),pe.onFetchByScope("managed",["members","simple"],{page:1,per:100},x=>{for(let j=0;j<x.length;j++){var h=w.findIndex(L=>L.value==x[j].id);h===-1&&w.push({value:`${x[j].id}`,label:`${x[j].name} (${x[j].slug})`})}t.mode==="edit"&&c.setFieldValue("object_id",`${t.step.object_id}`)},x=>{}),n([{group:"Sub spaces",items:g}
2,{group:"All spaces",items:w}])},p=()=>{t.mode==="edit"?t.onUpdate(c.values):t.onCreate(c.values)},f=g=>{o(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{u(),o(!1)},1e3)};return e.jsx(V,{children:e.jsxs("form",{onSubmit:c.onSubmit(g=>p()),children:[e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(fe,{leftSection:i?e.jsx(Oe,{size:"xs"}):e.jsx(C,{icon:Nt.faSearch}),label:r("spaces.settings.registration.steps.addFromSubSpace.label"),description:r("spaces.settings.registration.steps.addFromSubSpace.description"),searchable:!0,mt:20,data:l,placeholder:r("spaces.settings.registration.steps.addFromSubSpace.placeholder"),...c.getInputProps("object_id"),comboboxProps:{maxDropdownHeight:400},radius:"sm",size:"md",onSearchChange:g=>f()})}),t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:r("spaces.settings.registration.steps.addFromSubSpace.saveButton")}),e.jsx(M,{onClick:g=>t.onDestroy(g),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:r("spaces.settings.registration.steps.addFromSubSpace.deleteButton")})]}):e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:r("spaces.settings.registration.steps.addFromSubSpace.saveButton2")})]})})}function Bn(t){const s=ee(c=>c.space),[l,n]=a.useState([]),{t:i,i18n:o}=ne(),d=Ie({initialValues:{object_type:"pod",object_id:""},validate:{object_id:c=>c.length>0?null:"Please select a space"}});a.useEffect(()=>{r()},[]);const r=()=>{const c=[],u=[];pe.onFetchChildren(s.slug,["members"],{page:1,per:50},["active"],p=>{for(let f=0;f<p.data.length;f++)c.push({value:`${p.data[f].id}`,label:`${p.data[f].name} (${p.data[f].slug})`});t.mode==="edit"&&d.setFieldValue("object_id",`${t.step.object_id}`)},p=>{}),pe.onFetchByScope("managed",["members","simple"],{page:1,per:100},p=>{for(let g=0;g<p.length;g++){var f=u.findIndex(w=>w.value==p[g].id);f===-1&&u.push({value:`${p[g].id}`,label:`${p[g].name} (${p[g].slug})`})}t.mode==="edit"&&d.setFieldValue("object_id",`${t.step.object_id}`)},p=>{}),n([{group:"Sub spaces",items:c}
2,{group:"All spaces",items:u}])},m=()=>{t.mode==="edit"?t.onUpdate(d.values):t.onCreate(d.values)};return e.jsx(V,{children:e.jsxs("form",{onSubmit:d.onSubmit(c=>m()),children:[e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(fe,{label:i("spaces.settings.registration.steps.applyTemplate.label"),description:i("spaces.settings.registration.steps.applyTemplate.description"),searchable:!0,mt:20,data:l,placeholder:"Select a space",...d.getInputProps("object_id"),comboboxProps:{maxDropdownHeight:400},radius:"sm",size:"md"})}),t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:i("spaces.settings.registration.steps.applyTemplate.saveButton1")}),e.jsx(M,{onClick:c=>t.onDestroy(c),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:i("spaces.settings.registration.steps.applyTemplate.deleteButton")})]}):e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:i("spaces.settings.registration.steps.applyTemplate.saveButton2")})]})})}function $n(t){const s=we(),[l,n]=a.useState(null),[i,o]=a.useState(""),{t:d,i18n:r}=ne(),m=ee(g=>g.space),c=Ie({initialValues:{pending_message:""}});a.useEffect(()=>{console.log(i)},[i]),a.useEffect(()=>{t.settings&&t.settings.slug&&(aa.onFetchRaw("pending_member_view",m.slug,g=>{const w=g.content?g.content:"";o([...w]),c.setFieldValue("pending_message",[...w])},g=>{}),n({...t.settings}))},[t]);const u=()=>{const g={pod_settings_attributes:{pending_message:c.values.pending_message}};Ae.onUpdate(m.slug,g,w=>{t.mode==="edit"?t.onUpdate():t.onCreate()},w=>{})},p=g=>{t.onDestroy(g)},f=(g,w,x,h)=>{c.setFieldValue("pending_message",g.content)};return e.jsx(V,{children:e.jsxs("form",{onSubmit:c.onSubmit(g=>u()),children:[e.jsxs(ge,{withCssVariables:!1,theme:{primaryShade:6},children:[e.jsx(v,{mt:20,size:16,fw:500,c:s.colors.gray[9],children:d("spaces.settings.registration.steps.setToPending.title")}),e.jsx(v,{size:"sm",c:"dimmed",style:{lineHeight:1.2},mb:15,children:d("spaces.settings.registration.steps.setToPending.description")}),(i||t.mode!="edit")&&e.jsx(_s,{editable:!0,content:[...i],modals:!0,onUpdate:f,exclude:[],mediaLibraryEnabled:!0}),e.jsx(v,{mt:10,size:"xs",c:"dimmed",children:"Use {{first_name}}, {{last_name}}, {{space_name}}, {{space_link}}, and {{space_name_link}} to autopopulate the corresponding information"})]}),t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:d("spaces.settings.registration.steps.setToPending.saveButton1")}),e.jsx(M,{onClick:g=>p(g),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:d("spaces.settings.registration.steps.setToPending.deleteButton")})]}):e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:d("spaces.settings.registration.steps.setToPending.saveButton2")})]})})}function Zo(t){const{t:s,i18n:l}=ne(),n=ee(w=>w.space),[i,o]=a.useState(null),[d,r]=a.useState(""),[m,c]=a.useState(!1),u=a.useRef(!1);a.useEffect(()=>{t.step&&!m&&!u.current&&(r(t.step.object_id),c(!0),p(),u.current=!0)},[t]);const p=()=>{if(t.step&&t.step.object_id)Ft.onFetchById(t.step.object_id,n.slug,w=>{o(w),c(!1)},w=>{});else if(!m&&!t.step.object_id){const w={title:"New survey"};Ft.onCreate(n.slug,w,x=>{Ft.onFetchById(x.id,n.slug,h=>{o(h),c(!1)},h=>{}),t.onUpdate({object_id:x.id},!1)},x=>{})}},f=()=>{},g=w=>{t.onDestroy(w)};return m?null:e.jsx(V,{mt:20,children:e.jsx(oa,{opened:t.opened,setOpened:t.setOpened,survey:i,spaceId:n.slug,onUpdate:f,acceptPayments:!1,extraButton:e.jsx(M,{onClick:w=>g(w),mt:15,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:s("spaces.settings.registration.steps.editSurvey.deleteButton")})})})}function Pn(t){const s=ee(r=>r.space);ee(r=>r.user);const{t:l,i18n:n}=ne();a.useEffect(()=>{console.log("trigger: ",t.trigger),t.webhookId&&s&&s.slug&&o(),s&&s.slug&&i.setFieldValue("name",`Webhook ${s.slug}`)},[t]);const i=Ie({initialValues:{name:"",url:"",params:["first_name","last_name","email","username","created_at"]},validate:{name:r=>r.length>0?null:"Please write a name for this webhook",url:r=>r.length>0?null:"Please add a webhook url",params:r=>r.length>0?null:"Please select at least one parameter for this webhook"}}),o=()=>{Xt.onFetchById(t.webhookId,s.slug,r=>{i.setFieldValue("name",r.name),i.setFieldValue("url",r.url),i.setFieldValue("params",r.params)},r=>{})},d=()=>{t.webhookId?Xt.onUpdate(t.webhookId,s.slug,{...i.values},r=>{t.onUpdate({object_type:"webhook"})},r=>{}):Xt.onCreate(s.slug,{...i.values},r=>{t.onCreate({object_type:"webhook",object_id:r.id})},r=>{})};return e.jsx(V,{children:e.jsxs("form",{onSubmit:i.onSubmit(r=>d()),children:[e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(Ue,{mt:20,placeholder:"https://example.com/hooks/12345",label:l("spaces.settings.registration.steps.webhook.label"),radius:"sm",size:"md",...i.getInputProps("url")})}
2),e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!t.webhookId,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:l("spaces.settings.registration.steps.webhook.saveButton")}),t.webhookId&&e.jsx(M,{onClick:r=>t.onDestroy(r),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:l("spaces.settings.registration.steps.webhook.deleteButton")})]})]})})}const Xo="_wrapper_19000_1",Qo="_control_19000_15",Jo="_input_19000_26",Et={wrapper:Xo,control:Qo,input:Jo};function cs(t){const[s,l]=a.useState(""),[n,i]=a.useState(""),o=we(),{colorScheme:d}=Kn(),{t:r}=ne(),m=1,c=1e3,u=Ie({initialValues:{action:"",wait:1,wait_until:null},validate:{action:x=>x.length>0?null:"Please select a wait condition"}});a.useEffect(()=>{if(t.mode=="edit"&&t.step&&(u.setFieldValue("action",t.step.action),u.setFieldValue("wait",t.step.wait/24),t.step.action=="wait_until")){const x=new Date(t.step.wait_until);l(x),i(x)}},[]),a.useEffect(()=>{if(s&&n){const x=ra(s,n);x&&u.setFieldValue("wait_until",x.toISOString())}},[s,n]);const p=()=>{t.mode==="edit"?t.onUpdate(u.values):t.onCreate(u.values)},f=Number(u.values.wait)||m,g=x=>{u.setFieldValue("wait",Math.max(m,Math.min(c,x)))},w={"--control-bg-color":d==="dark"?o.colors.dark[7]:o.white,"--control-border-color":d==="dark"?"transparent":o.colors.gray[3],"--control-disabled-border-color":d==="dark"?"transparent":o.colors.gray[3]};return e.jsx(V,{children:e.jsxs("form",{onSubmit:u.onSubmit(x=>p()),children:[e.jsxs(ge,{withCssVariables:!1,theme:{primaryShade:6},children:[e.jsx(fe,{...u.getInputProps("action"),label:r("spaces.settings.registration.steps.wait.label1"),placeholder:r("spaces.settings.registration.steps.wait.placeholder"),comboboxProps:{maxDropdownHeight:400},radius:"sm",size:"md",mt:20,data:[{value:"wait",label:r("spaces.settings.registration.steps.wait.label2")},{value:"wait_until",label:r("spaces.settings.registration.steps.wait.label3")}]}),u.values.action==="wait"&&u.values.action!==null&&e.jsxs(V,{children:[e.jsx(v,{mt:20,mb:5,style:{fontSize:18,fontWeight:500,color:o.colors.gray[9]},children:r("spaces.settings.registration.steps.wait.description1")}),e.jsxs("div",{className:Et.wrapper,children:[e.jsx(Fe,{"aria-label":"Decrease wait days",size:28,variant:"transparent",onClick:()=>g(f-1),disabled:f<=m,className:Et.control,style:w,onMouseDown:x=>x.preventDefault(),children:e.jsx(li,{size:16})}),e.jsx(Yn,{size:"lg",variant:"unstyled",hideControls:!0,min:m,max:c,...u.getInputProps("wait"),classNames:{input:Et.input}}),e.jsx(Fe,{"aria-label":"Increase wait days",size:28,variant:"transparent",onClick:()=>g(f+1),disabled:f>=c,className:Et.control,style:w,onMouseDown:x=>x.preventDefault(),children:e.jsx(ca,{size:16})})]})]}),u.values.action==="wait_until"&&u.values.action!==null&&e.jsxs(V,{mt:10,children:[e.jsx(v,{mt:20,mb:5,style:{fontSize:18,fontWeight:500,color:o.colors.gray[9]},children:r("spaces.settings.registration.steps.wait.description2")}),e.jsxs(Z,{children:[e.jsx(Zn,{radius:"sm",size:"md",value:s,placeholder:r("spaces.settings.registration.steps.wait.label4"),onChange:x=>l(x)}),e.jsx(la,{radius:"sm",size:"md",value:n,onChange:x=>i(x)})]})]})]}),t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:r("spaces.settings.registration.steps.wait.saveButton")}),e.jsx(M,{onClick:x=>t.onDestroy(x),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:r("spaces.settings.registration.steps.wait.deleteButton")})]}):e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:r("spaces.settings.registration.steps.wait.saveButton2")})]})})}function er(t){const{t:s,i18n:l}=ne(),n=ee(u=>u.space),[i,o]=a.useState(""),[d,r]=a.useState("");a.useEffect(()=>{t&&t.step&&(o(t.step.action),r(t.step.name))},[t]);const m=(u,p=!0)=>{at.onUpdate(t.step.id,n.slug,t.step.journey_id,{action:t.step.action,position:t.step.position,...u},f=>{p&&(t.setOpened(!1),setTimeout(()=>t.onSettingsChange(),1e3))},f=>{})},c=()=>{switch(i){case"send_email":return e.jsx(Go,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",trigger:t.trigger,settings:t.settings,onSettingsChange:t.onSettingsChange});case"send_message":return e.jsx(En,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",trigger:t.trigger,settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_to_existing_space":return e.jsx(In,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_to_new_space":return e.jsx(Dn,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_from_sub_space":return e.jsx(Fn,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});case"apply_template":return e.jsx(Bn,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});
2case"set_to_pending":return e.jsx($n,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});case"survey_person":return e.jsx(Zo,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",opened:t.opened,setOpened:t.setOpened,settings:t.settings,onSettingsChange:t.onSettingsChange});case"webhook":return e.jsx(Pn,{webhookId:t.step&&t.step.object_id,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});case"wait":return e.jsx(cs,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});case"wait_until":return e.jsx(cs,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange});default:return e.jsx(kn,{step:t.step,onUpdate:m,onDestroy:u=>t.onDestroy(u,t.step),mode:"edit",settings:t.settings,onSettingsChange:t.onSettingsChange})}};return e.jsx(ms,{opened:t.opened,onClose:()=>t.setOpened(!1),title:e.jsx(v,{size:"xl",fw:"800",children:d}),padding:"xl",size:600,offsetScrollbars:!0,children:e.jsxs(je,{style:{marginTop:-20,height:"100%"},children:[c(),e.jsx(V,{mt:100})]})})}function tr(t){const[s,l]=a.useState([]),[n,i]=a.useState([]),[o,d]=a.useState({}),r=ee(x=>x.space),m=ee(x=>x.user),{t:c,i18n:u}=ne();a.useEffect(()=>{console.log("trigger: ",t.trigger),r&&r.slug&&g()},[r]);const p=()=>t.trigger==="interested"?"interested":t.trigger==="registered"?"members":"interested-members",f=Ie({initialValues:{object_type:"broadcast",send_email_to:p(),send_as:`${m.id}`,email_address:"",object_id:""},validate:{send_email_to:x=>x.length>0?null:"Please select a value",send_as:x=>x.length>0?null:"Please select a sender",object_id:x=>x.length>0?null:"Please select an email"}}),g=()=>{he.onFetchSimple(r.slug,{page:1,per:100},x=>{const h=x.map((j,L)=>({value:`${j.id}`,label:j.title}));l([{group:"New email",items:[{value:"new_email",label:"Write a new email"}]},{group:"Select a previously drafted broadcast",items:h}])},x=>{}),Ve.onFetch(r.slug,{page:1,per:1e3},{scope:"",term:""},x=>{const h=x.data.map((j,L)=>({value:`${j.user_id}`,label:`${j.full_name} (${j.username})`}));i(h)},x=>{})},w=()=>{t.onCreate(f.values)};return e.jsx(V,{children:e.jsxs("form",{onSubmit:f.onSubmit(x=>w()),children:[e.jsxs(ge,{withCssVariables:!1,theme:{primaryShade:6},children:[e.jsx(fe,{label:c("spaces.settings.registration.steps.sendEmail.label1"),placeholder:c("spaces.settings.registration.steps.sendEmail.placeholder1"),comboboxProps:{maxDropdownHeight:400,withinPortal:!0,zIndex:1e5},radius:"sm",size:"md",mt:20,data:s,...f.getInputProps("object_id")}),e.jsx(fe,{label:c("spaces.settings.registration.steps.sendEmail.label2"),placeholder:c("spaces.settings.registration.steps.sendEmail.placeholder2"),comboboxProps:{maxDropdownHeight:400,withinPortal:!0,zIndex:1e5},radius:"sm",size:"md",mt:20,data:n,...f.getInputProps("send_as")}),e.jsx(fe,{label:c("spaces.settings.registration.steps.sendEmail.label3"),placeholder:c("spaces.settings.registration.steps.sendEmail.placeholder3"),comboboxProps:{maxDropdownHeight:400,withinPortal:!0,zIndex:1e5},radius:"sm",size:"md",mt:20,data:[{value:p(),label:p().split("-").reverse().join(" or ").charAt(0).toUpperCase()+p().split("-").reverse().join(" or ").slice(1)},{value:"managers",label:c("spaces.settings.registration.steps.sendEmail.label5")},{value:"custom",label:c("spaces.settings.registration.steps.sendEmail.label6")}],...f.getInputProps("send_email_to")}),f.values.send_email_to=="custom"&&e.jsx(Ue,{mt:20,placeholder:c("spaces.settings.registration.steps.sendEmail.placeholder4"),label:c("spaces.settings.registration.steps.sendEmail.label4"),radius:"sm",size:"md",...f.getInputProps("email_address")})]}),e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:c("spaces.settings.registration.steps.sendEmail.saveButton")})]})})}function sr(t){const s=ee(m=>m.space),[l,n]=a.useState([]),{t:i}=ne(),o=Ie({initialValues:{object_type:"survey",object_id:""},validate:{object_id:m=>m.length>0?null:"Please select a survey or quiz"}}
2);a.useEffect(()=>{d()},[t]);const d=()=>{Ft.onFetch(s.slug,{page:1,per:100},m=>{const c=m.data.map(u=>({value:`${u.id}`,label:u.title}));n([{group:"New survey or quiz",items:[{value:"new_survey",label:"Create a new survey or quiz"}]},{group:"Select an existing survey or quiz",items:c}])},()=>{})},r=()=>{t.onCreate(o.values)};return e.jsx(V,{children:e.jsxs("form",{onSubmit:o.onSubmit(m=>r()),children:[e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(fe,{label:i("spaces.settings.registration.steps.surveyPerson.label"),placeholder:i("spaces.settings.registration.steps.surveyPerson.placeholder"),comboboxProps:{withinPortal:!0,maxDropdownHeight:400,zIndex:1e5},radius:"sm",size:"md",mt:20,data:l,...o.getInputProps("object_id")})}),t.mode==="edit"?e.jsxs(Z,{justify:"space-between",children:[e.jsx(M,{mt:25,radius:"xl",type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),children:i("spaces.settings.registration.steps.surveyPerson.saveButton1")}),e.jsx(M,{onClick:m=>t.onDestroy(m),mt:25,radius:"xl",color:"dark",leftSection:e.jsx(C,{icon:_e.faTrashCan}),children:i("spaces.settings.registration.steps.surveyPerson.deleteButton")})]}):e.jsx(M,{type:"submit",leftSection:e.jsx(C,{icon:ue.faCheck}),mt:25,radius:"xl",size:"md",fullWidth:!0,styles:{root:{paddingInlineStart:"var(--button-padding-x)"}},children:i("spaces.settings.registration.steps.surveyPerson.saveButton2")})]})})}const nr=t=>({symbol:{textAlign:"center",fontSize:30,fontWeight:700,width:60}});function An(t){we();const s=nr(),l=()=>{const n=t.value;if(n=="send_email"||n=="send_message")return e.jsx(v,{style:{...s.symbol,color:"var(--mantine-color-blue-5)"},children:e.jsx(C,{icon:ys.faEnvelope})});if(n=="add_to_existing_space"||n=="add_to_new_space"||n=="add_from_sub_space"||n=="add_from_children"||n=="add_to_direct_open_children"||n=="add_sub_circle_members")return e.jsx(v,{style:{...s.symbol,color:"var(--mantine-color-green-5)"},children:e.jsx(C,{icon:yi.faUser})});if(n=="survey_person")return e.jsx(v,{style:{...s.symbol,color:"var(--mantine-color-violet-5)"},children:e.jsx(C,{icon:ia.faSquarePollHorizontal})});
2if(n=="set_to_pending")return e.jsx(v,{style:{...s.symbol,color:"var(--mantine-color-red-5)"},children:e.jsx(C,{icon:ta.faCirclePause})});if(n=="wait"||n=="wait_until")return e.jsx(v,{style:{...s.symbol,color:"var(--mantine-color-gray-5)"},children:e.jsx(C,{icon:Si.faClock})});if(n=="apply_template")return e.jsx(v,{style:{...s.symbol,color:"var(--mantine-color-yellow-5)"},children:e.jsx(C,{icon:vi.faMap})});if(n=="webhook")return e.jsx(v,{style:{...s.symbol,color:"var(--mantine-color-yellow-5)"},children:e.jsx(C,{icon:gn.faLink})})};return e.jsx("div",{children:l()})}function ir(t){const{t:s,i18n:l}=ne(),[n,i]=a.useState(null),[o,d]=a.useState([]),[r,m]=a.useState(!1),[c,u]=a.useState(!1),[p,f]=a.useState(!1),[g,w]=a.useState([]),[x,h]=a.useState([]),[j,L]=a.useState([]),[I,E]=a.useState([]),[P,_]=a.useState([]),[$,z]=a.useState([]),[N,b]=a.useState(!1),k=a.useRef(!1),U=ee(B=>B.space);a.useEffect(()=>{},[]),a.useEffect(()=>{m(U&&U.permissions&&U.permissions.can_add_step_send_to_pending),u(U&&U.permissions&&U.permissions.can_add_add_to_existing_space),f(U&&U.permissions&&U.permissions.can_add_step_wait),w(U&&U.permissions&&U.permissions.can_add_step_survey_person),w(U&&U.permissions&&U.permissions.can_add_step_survey_person),h(U&&U.permissions&&U.permissions.can_add_step_send_email),z(U&&U.permissions&&U.permissions.can_add_step_webhook),L(U&&U.permissions&&U.permissions.can_send_message),E(U&&U.permissions&&U.permissions.can_add_from_children),_(U&&U.permissions&&U.permissions.can_add_to_direct_open_children)},[U]),a.useEffect(()=>{t.opened==!0&&!k.current&&H(),k.current=t.opened},[t]),a.useEffect(()=>
2{n=="set_to_pending"&&!r[0]&&(b([!0,r[1],r[2]]),i(null)),n=="add_to_existing_space"&&!c[0]&&(b([!0,c[1],c[2]]),i(null)),n=="wait"&&!p[0]&&(b([!0,p[1],p[2]]),i(null)),n=="survey_person"&&!g[0]&&(b([!0,g[1],g[2]]),i(null)),n=="send_email"&&!x[0]&&(b([!0,x[1],x[2]]),i(null)),n=="send_message"&&!j[0]&&(b([!0,j[1],j[2]]),i(null)),["add_from_children","add_from_sub_space"].includes(n)&&!I[0]&&(b([!0,I[1],I[2]]),i(null)),n=="add_to_direct_open_children"&&!P[0]&&(b([!0,P[1],P[2]]),i(null)),n=="webhook"&&!$[0]&&(b([!0,$[1],$[2]]),i(null))},[n]);const H=()=>{$t.onFetchActions(t.trigger,t.position,U.slug,B=>{d(B.actions)},B=>{})},D=B=>{at.onCreate(U.slug,t.journey,{action:n,position:t.position,...B},y=>{(n=="send_email"&&B.object_id=="new_email"||n=="send_message"&&B.object_id=="new_message"||n=="survey_person"&&B.object_id=="new_survey")&&t.setTriggerEdit(y.id),t.setOpened(!1),i(null),setTimeout(()=>t.onSettingsChange(),1e3)},y=>{})},T=()=>{switch(n){case"send_email":return e.jsx(tr,{onCreate:D,mode:"add",trigger:t.trigger,settings:t.settings,onSettingsChange:t.onSettingsChange});case"send_message":return e.jsx(En,{onCreate:D,mode:"add",trigger:t.trigger,settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_to_existing_space":return e.jsx(In,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_to_new_space":return e.jsx(Dn,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"add_from_sub_space":return e.jsx(Fn,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"apply_template":return e.jsx(Bn,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"set_to_pending":return e.jsx($n,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"survey_person":return e.jsx(sr,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"webhook":return e.jsx(Pn,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});case"wait":return e.jsx(cs,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange});default:return n&&e.jsx(kn,{onCreate:D,mode:"add",settings:t.settings,onSettingsChange:t.onSettingsChange})}};return e.jsxs(e.Fragment,{children:[e.jsx(ms,{opened:t.opened,onClose:()=>{t.setOpened(!1),i(null)},title:e.jsx(v,{size:"xl",fw:"800",children:s("spaces.settings.registration.addStep.addStep.description")}),padding:"xl",size:600,offsetScrollbars:!0,children:e.jsxs(je,{style:{height:"100%"},children:[e.jsx(fe,{label:s("spaces.settings.registration.addStep.addStep.label"),value:n,onChange:i,placeholder:s("spaces.settings.registration.addStep.addStep.placeholder"),renderOption:({option:B})=>e.jsxs(Z,{wrap:"nowrap",children:[e.jsx(An,{value:B.value}),e.jsxs("div",{children:[e.jsx(v,{size:"lg",fw:600,children:B.label}),e.jsx(v,{size:"md",c:"dimmed",children:B.description})]})]}),data:o,comboboxProps:{withinPortal:!0,zIndex:1e5,maxDropdownHeight:400},radius:"sm",size:"md"}),T(),e.jsx(V,{mt:100})]})}),e.jsx(ke,{opened:N,setOpened:b})]})}const ar="_settings_ryfbh_1",or="_dragHandle_ryfbh_11",rr="_addStepHover_ryfbh_25",lr="_addStepButtonHover_ryfbh_35",It={settings:ar,dragHandle:or,addStepHover:rr,addStepButtonHover:lr},cr=t=>({item:{display:"flex",alignItems:"center",borderRadius:t.radius.md,border:`1px solid ${t.colors.gray[4]}`,padding:"15px 20px 15px 5px",backgroundColor:"#fff"},itemDragging:{boxShadow:t.shadows.sm},symbol:{textAlign:"center",fontSize:30,fontWeight:700,width:80},stepFooterPadding:{display:"flex",flexFlow:"row",justifyContent:"spaceBetween"},stepFooterLeft:{borderRight:`1px solid ${t.colors.gray[4]}`,height:10,width:"100%"},stepFooterRight:{borderLeft:`1px solid ${t.colors.gray[4]}`,height:10,width:"100%"},stepFooterAddStep:{display:"flex",justifyContent:"center",fontSize:16},addStepHidden:{visibility:"hidden"},bottomConnector:{fontSize:20,color:t.colors.gray[4],marginTop:-15,textAlign:"center",height:20},addStepButtonWrap:{width:"100%",display:"flex",justifyContent:"center",marginTop:5}}),dr=({id:t,children:s})=>{const{attributes:l,listeners:n,setNodeRef:i,transform:o,transition:d,isDragging:r}=sn({id:t}),m={transform:nn.Transform.toString(o),transition:d};return e.jsx("div",{ref:i,style:m,...l,children:s({listeners:n,isDragging:r})})};function Os({onUpdate:t}){const s=we(),l=cr(s),{language:n}=pn(),i=ee(S=>S.space),{t:o,i18n:d}=ne(),[r,m]=a.useState(null),[c,u]=ps([]),p=a.useRef(!1),[f,g]=a.useState(!1),w=Ks(Ys(Zs,{activationConstraint:{distance:5}}
2)),[x,h]=a.useState(!1),[j,L]=a.useState(!1),[I,E]=a.useState(""),[P,_]=a.useState(null),[$,z]=a.useState(null),[N,b]=a.useState("interested-registered");a.useEffect(()=>{i.settings&&(D(),i.journeys&&i.journeys.length>0&&b(i.journeys[0].trigger))},[i]),a.useEffect(()=>{i&&i.slug&&D()},[j]),a.useEffect(()=>{!j&&!x&&(D(),E(null))},[j,x]),a.useEffect(()=>{p.current?k():p.current=!0},[c]),a.useEffect(()=>{i&&i.slug&&D()},[N]);const k=()=>{if(c.length==0)return;const S=c.map((W,te)=>({id:W.id,position:te+1}));at.onReorder(i.slug,r,S,W=>{},W=>{})},U=(S,W)=>{S.preventDefault(),oe.fire({title:"Are you sure?",html:"This step will be permanently deleted",showDenyButton:!0,confirmButtonText:"Delete step",denyButtonText:"Cancel",confirmButtonColor:s.colors.red[8],denyButtonColor:s.colors.gray[6]}).then(te=>{te.isConfirmed?at.onDestroy(W.id,i.slug,W.journey_id,A=>{h(!1)},A=>{}):te.isDenied})},H=[{label:o("spaces.settings.registration.registrationFlow.registration.label1"),value:"interested-registered",description:o("spaces.settings.registration.registrationFlow.registration.description3")},{label:o("spaces.settings.registration.registrationFlow.registration.label2"),value:"registered",description:o("spaces.settings.registration.registrationFlow.registration.description4")},{label:o("spaces.settings.registration.registrationFlow.registration.label3"),value:"interested",description:o("spaces.settings.registration.registrationFlow.registration.description5")}],D=()=>{$t.onFetchByTrigger(N,i.slug,S=>{m(S.id),u.setState(S.steps),P&&(E(S.steps.filter(W=>W.id===P)[0]),h(!0),_(null))},S=>{})},T=S=>{if(S.action=="wait_until"&&S.wait_until){const W=new Date(S.wait_until).toISOString();return`${S.name} ${Me.fromISO(W).setLocale(n).toFormat("EEE, MMM d y, h:mm a")}`}else return S.name},B=S=>e.jsx("div",{children:e.jsx("div",{style:f?l.addStepHidden:{},children:e.jsxs("div",{children:[e.jsxs("div",{style:l.stepFooterPadding,children:[e.jsx("div",{style:l.stepFooterLeft}),e.jsx("div",{style:l.stepFooterRight})]}),e.jsx("div",{style:l.stepFooterAddStep,children:e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:5},children:e.jsx(Fe,{size:"sm",radius:"xl",variant:"outline",color:"gray",onClick:()=>{L(!0),z(S)},classNames:{root:It.addStepHover},children:e.jsx(C,{icon:He.faPlus})})})}),e.jsxs("div",{style:l.stepFooterPadding,children:[e.jsx("div",{style:l.stepFooterLeft}),e.jsx("div",{style:l.stepFooterRight})]}),e.jsx("div",{style:l.bottomConnector,children:e.jsx(C,{icon:mn.faCaretDown})})]})})}),y=c.map((S,W)=>e.jsx(dr,{id:S.id.toString(),children:({listeners:te,isDragging:A})=>e.jsxs("div",{children:[e.jsxs("div",{style:{...l.item||{},...A?l.itemDragging:{}},children:[e.jsx(An,{value:S.action}),e.jsxs(Z,{justify:"space-between",style:{width:"100%"},wrap:"nowrap",children:[e.jsxs(V,{style:{width:"90%"},children:[e.jsx(v,{fw:600,children:T(S)}),e.jsx(v,{c:"dimmed",size:"sm",children:S.description})]}),e.jsxs(Z,{gap:0,wrap:"nowrap",children:[e.jsx(Fe,{size:"sm",radius:"xl",onClick:()=>{E(S),h(!0)},className:It.settings,children:e.jsx(C,{icon:cn.faCog})}),e.jsx("div",{...te,className:It.dragHandle,children:e.jsx(C,{icon:Xs.faGripVertical})})]})]})]}),B(W+1)]})},S.id.toString())),R=()=>{};return e.jsxs(e.Fragment,{children:[window.$currentRole=="admin"?e.jsx(V,{mt:40}):e.jsxs(e.Fragment,{children:[e.jsx(v,{size:"sm",c:"dimmed",mb:20,children:o("spaces.settings.registration.registrationFlow.registration.description1")}),e.jsx(v,{size:"lg",mb:5,children:o("spaces.settings.registration.registrationFlow.registration.description2")})]}),e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(fe,{value:N,onChange:b,placeholder:o("spaces.settings.registration.registrationFlow.registration.placeholder1"),renderOption:({option:S})=>e.jsx(Z,{wrap:"nowrap",children:e.jsxs("div",{children:[e.jsx(v,{size:"lg",fw:600,children:S.label}),e.jsx(v,{size:"md",c:"dimmed",children:S.description})]})}),data:H,comboboxProps:{maxDropdownHeight:400},radius:"md",size:"lg"})}),B(0),e.jsx(Qs,{sensors:w,collisionDetection:Js,modifiers:[dn,un],onDragStart:()=>{g(!0)},onDragEnd:({active:S,over:W})=>{if(g(!1),!W||S.id===W.id)return;const te=c.findIndex(J=>J.id.toString()===S.id),A=c.findIndex(J=>J.id.toString()===W.id);te===-1||A===-1||u.reorder({from:te,to:A})},children:e.jsx(en,{items:c.map(S=>S.id.toString()),strategy:tn,children:y})}),e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:5},children:e.jsx("div",{style:l.addStepButtonWrap,children:e.jsx(M,{onClick:()=>{L(!0),z(null)},classNames:{root:It.addStepButtonHover}
2,variant:"outline",color:"gray",radius:"xl",children:o("spaces.settings.registration.registrationFlow.registration.addButton")})})}),e.jsx(er,{opened:x,setOpened:h,step:I,journey:r,onDestroy:U,trigger:N,settings:i,onSettingsChange:R}),e.jsx(ir,{opened:j,setOpened:L,position:$,journey:r,setTriggerEdit:_,trigger:N,settings:i,onSettingsChange:R})]})}const ur="_addTriggerButton_3r9wg_1",mr={addTriggerButton:ur};function pr(){const{t}=ne(),s=bt(),l=ee(u=>u.space),[n,i]=a.useState(!1),o=new Date(l==null?void 0:l.created_at)>new Date("2025-01-01"),d=window.$currentRole=="admin",r=d||window.$spaceIsMigrated,m=u=>{Object.keys(u).length!==0&&Ae.onUpdate(s.slug,u,()=>null,()=>null)},c=e.jsx(Wo,{onUpdate:m,functionsType:"automation",addTriggerOpened:n,setAddTriggerOpened:i,showAddTriggerButton:!1});return e.jsx(je,{style:{height:"100%"},children:e.jsxs($e,{style:{marginBottom:"50px"},pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceId:l.slug,spaceVersion:l.version,spaceName:l.name,title:t("spaces.settings.main.main.label4"),rightSide:r?e.jsx(M,{variant:"filled",radius:"xl",leftSection:e.jsx(C,{icon:He.faPlus}),className:mr.addTriggerButton,onClick:()=>i(!0),children:"Add trigger"}):null}),d?e.jsxs(e.Fragment,{children:[c,!o&&e.jsx(Os,{onUpdate:m})]}):window.$spaceIsMigrated?c:e.jsx(Os,{onUpdate:m})]})})}const gr="_inviteButton_12z7w_1",hr={inviteButton:gr};var Rn=wi(),fr=Ci();const xr="_noHoverUnderline_1m7sc_1",br="_option_1m7sc_9",ds={noHoverUnderline:xr,option:br},jr={active:"green",pending:"orange",deleted:"red",registration_survey:"blue",survey_payment:"yellow",processing:"gray"},_r={active:"Active",pending:"Pending approval",deleted:"Removed",registration_survey:"Survey required",survey_payment:"Payment incomplete",processing:"Processing"},yr={active:"This member is active and has access to all space features",pending:"This member is currently pending and must be approved to access the space",deleted:"You removed this member from this space",registration_survey:"This member has registered but hasn't completed the registration survey",survey_payment:"This member has registered but hasn't completed the survey payment",processing:"This membership is still being initialized"};function Sr(t){const s=Pe(),l=we(),{t:n}=ne(),{frequencyOptions:i}=pa(),[o,d]=a.useState({}),[r,m]=a.useState(null),[c,u]=a.useState(!1),[p,f]=a.useState(!1),[g,w]=a.useState(!1),[x,h]=a.useState("member"),j=ee(T=>T.user),L=[{value:"member",label:n("spaces.presentations.settings.role.member.label"),description:n("spaces.presentations.settings.role.member.description")},{value:"moderator",label:n("spaces.presentations.settings.role.moderator.label"),description:n("spaces.presentations.settings.role.moderator.description")},{value:"editor",label:n("spaces.presentations.settings.role.editor.label"),description:n("spaces.presentations.settings.role.editor.description")},{value:"manager",label:n("spaces.presentations.settings.role.manager.label"),description:n("spaces.presentations.settings.role.manager.description")}],I=L.find(T=>T.value==r);a.useEffect(()=>{(!o.id||o.id!=t.member.id||o.status=="deleted"||o.status!="active"&&t.member.status=="active")&&(d(t.member),m(t.member.role),h(window.$currentRole))},[t]),a.useEffect(()=>{r&&(o.role!="member"&&r=="member"||o.role!="manager"&&r=="manager"||o.role!="editor"&&r=="editor"||o.role!="moderator"&&r=="moderator")&&_(r)},[r]);const E=T=>{(T=="member"||T=="editor"||T=="moderator"||T=="manager"&&t.canAddNewManagers())&&m(T)},P=()=>{f(!0),setTimeout(()=>{f(!1)},2e3)},_=T=>{const B=o.user_id,y=t.spaceId,R=()=>t.onUpdate(o),S=W=>oe.fire("Could not change role",(W==null?void 0:W.message)||"Please try again.","error");T=="manager"?Ve.onCreate(y,B,R,S):T==="editor"||T==="moderator"?ve.onUpdateRole(B,y,T,R,S):o.role=="manager"?Ve.onDestroy(B,y,R,S):ve.onUpdateRole(B,y,"member",R,S)},$=T=>{const B={...o};B.email_frequency=T,ve.onEmailFrequency(o.user_id,t.spaceId,T,y=>d(B),y=>{})},z=()=>{const T={...o};T.status="active",ve.onApprove(o.user_id,t.spaceId,B=>{t.onUpdate(o),d(T)},B=>{})},N=()=>{const T={...o,status:"active"};ve.onSkipSurvey(o.user_id,t.spaceId,()=>{t.onUpdate(T),d(T)},()=>{})},b=()=>{oe.fire({title:"Are you sure?",html:"You are about to remove this member",showDenyButton:!0,confirmButtonText:"Remove member",denyButtonText:"Cancel",confirmButtonColor:l.colors.red[8],denyButtonColor:l.colors.gray[6]}).then(T=>{T.isConfirmed&&k()})},k=()=>
2{if(c)return;u(!0),(t.scope!="managers"?ve:Ve).onDestroy(o.user_id,t.spaceId,B=>{u(!1);const y={...o,status:"deleted"};d(y),t.onUpdate(y),(B!=null&&B.billing_pending||B!=null&&B.billing_failed)&&oe.fire("Membership removed",B.billing_failed?"Billing cancellation needs attention. Please check the member's subscription.":"Billing cancellation is still processing.","info")},B=>{u(!1),oe.fire("Could not remove member",(B==null?void 0:B.message)||(B==null?void 0:B.error)||"Please try again.","error")})},U=()=>{ki.onFetchOrCreate(o.user_id,T=>{s(ht({opened:"direct",option:T.space.slug,allow_reflections:!0}))},T=>{})},H=()=>{s(ht({opened:"profile",option:o.username,unthemed:!0}))},D=()=>{oe.fire({title:"Are you sure?",html:"You are about to cancel this subscription",showDenyButton:!0,confirmButtonText:"Delete subscription",denyButtonText:"Cancel",confirmButtonColor:l.colors.red[8],denyButtonColor:l.colors.gray[6]}).then(T=>{T.isConfirmed?qs.onCancelSubscription(o.user_id,t.spaceId,B=>{const y={...o,is_subscribed:!1};d(y),t.onUpdate(y),oe.fire(B.title,B.message,"success")},B=>{oe.fire(B.title,B.message,"error")}):T.isDenied})};return e.jsxs(e.Fragment,{children:[e.jsxs(se.Tr,{children:[e.jsx(se.Td,{style:{width:"20px"},children:window.$currentUserId!=o.user_id&&e.jsx(ot,{checked:t.isSelected(o.username),onChange:T=>t.onSelect(o.username)})}),e.jsx(se.Td,{children:e.jsxs(Z,{gap:"sm",onClick:()=>H(),style:{color:"#000"},className:ds.noHoverUnderline,wrap:"nowrap",children:[e.jsx(os,{size:30,src:o&&o.avatar?o.avatar.url:"",radius:30}),e.jsxs(it,{gap:"0",style:{minWidth:0,flex:"0 1 auto",maxWidth:"16em"},children:[e.jsx(v,{size:"sm",fw:500,truncate:!0,children:o.full_name}),e.jsxs(v,{size:"xs",c:"dimmed",mt:-3,truncate:!0,children:["@",o.username]})]})]})}),e.jsx(se.Td,{children:e.jsx(Le,{disabled:window.$isTouchDevice&&window.$isTouchDevice(),label:"Email copied to clipboard",opened:p,position:"bottom",withArrow:!0,children:e.jsx(ft,{onCopy:()=>P(),text:o.email,children:e.jsx(v,{style:{overflowWrap:"anywhere"},size:"sm",fw:500,children:o.email})})})}),e.jsx(se.Td,{children:e.jsx(Le,{disabled:window.$isTouchDevice&&window.$isTouchDevice(),multiline:!0,styles:{tooltip:{width:220}},label:yr[o.status],withArrow:!0,children:e.jsx(Se,{color:jr[o.status],variant:"light",styles:{root:{maxWidth:"none"},label:{overflow:"visible"}},children:_r[o.status]})})}),e.jsx(se.Td,{children:["moderator","editor"].includes(x)||x==="manager"&&(j==null?void 0:j.id)===(o==null?void 0:o.user_id)?e.jsx(v,{size:"sm",fw:500,children:I==null?void 0:I.label}):e.jsx(fe,{data:L,value:r,onChange:E,variant:"unstyled",classNames:{option:ds.option},renderOption:({option:T})=>e.jsxs("div",{children:[e.jsx(v,{size:"sm",fw:500,children:T.label}),e.jsx(v,{size:"xs",c:"dimmed",lineClamp:1,children:T.description})]}),comboboxProps:{width:280,maxDropdownHeight:600,middlewares:{flip:!0,shift:!0},withinPortal:!0}})}),e.jsx(se.Td,{children:e.jsxs(Z,{gap:"sm",justify:"flex-end",wrap:"nowrap",children:[o.status==="pending"&&["admin","manager"].includes(x)?e.jsx(M,{color:"#201A32",radius:"xl",size:"compact-xs",variant:"outline",onClick:()=>z(),children:n("spaces.settings.members.registeredRow.registered.roleApprove")}):o.status==="registration_survey"&&["admin","manager"].includes(x)?e.jsx(M,{color:"#1f6bd6",radius:"xl",size:"compact-xs",variant:"outline",onClick:()=>N(),children:"Skip survey"}):"",e.jsxs(Q,{transitionProps:{transition:"pop"},withArrow:!0,position:"bottom-end",children:[e.jsx(Q.Target,{children:e.jsx(Fe,{variant:"subtle",color:"gray",size:"lg",radius:"xl",children:e.jsx(C,{icon:Ss.faEllipsis,style:{fontSize:14}})})}),e.jsxs(Q.Dropdown,{children:[e.jsxs(Q.Label,{children:[n("spaces.settings.members.registeredRow.registered.joined")," ",new Date(o.joined).toLocaleString(Me.DATE_MED)]}),e.jsx(Q.Divider,{}),!!(o!=null&&o.pod_survey_id)&&e.jsx(Q.Item,{leftSection:e.jsx(C,{icon:Ti.faList}),onClick:()=>w(!0),children:"View survey"}),e.jsx(Q.Item,{onClick:()=>U(),leftSection:e.jsx(C,{icon:ci.faMessage}),children:n("spaces.settings.members.registeredRow.registered.sendMessage")}),!["moderator","editor"].includes(x)&&e.jsx(Q.Item,{onClick:()=>E(r=="manager"?"member":"manager"),leftSection:e.jsx(C,{icon:fr.faCircleUser}),children:r=="manager"?"Remove manager":"Make manager"}),t.hasSubscriptions&&o.is_subscribed?e.jsx(Q.Item,{onClick:()=>D(),leftSection:e.jsx(C,{icon:Rn.faCircleStop}),children:n("spaces.settings.members.registeredRow.registered.stopCharging")}):"",e.jsxs(Q,{trigger:"hover",position:"left-start",offset:4,withArrow:!0,closeOnItemClick:!1,children:[e.jsx(Q.Target,{children:e.jsx(Q.Item,{leftSection:e.jsx(C,{icon:an.faEnvelope}),closeMenuOnClick:!1,children:n("spaces.settings.members.registeredRow.registered.emailPreferences")})}),e.jsx(Q.Dropdown,{children:i.map(T=>e.jsx(Q.Item,{leftSection:T.value==o.email_frequency?e.jsx(C,{icon:ue.faCheck}):"",onClick:B=>$(T.value),children:T.label},T.value))})]}),["admin","manager"].includes(x)&&!(r==="manager"&&["moderator","editor"].includes(x))?e.jsxs(e.Fragment,{children:[e.jsx(Q.Divider,{}),e.jsx(Q.Item,{onClick:b,disabled:c,leftSection:e.jsx(C,{icon:_e.faTrashCan}),color:"red",children:n("spaces.settings.members.registeredRow.registered.removeMember")})]}):null]})]})]})})]}),g&&e.jsx(di,{opened:!0,setOpened:()=>w(!1),survey:{id:o.pod_survey_id},spaceId:t.spaceId,userId:[o.user_id]})]})}const vr="_emptyBox_1f5gx_1",wr="_countBadge_1f5gx_13",ut={emptyBox:vr,countBadge:wr},Ge={page:1,per:30},Ls={oldScope:"all"};function Us(t){const s=t.theme,l=Pe(),{t:n}=ne(),{term:i,setTerm:o,sortSelected:d,filtersSelected:r,isFilterVisible:m,setIsFilterVisible:c}=_n(),u=ee(K=>
2K.space),p=ee(K=>K.tiptapSidemenu),[f,g]=a.useState({total:0,page:1,pages:1,data:[]}),[w,x]=a.useState({all:0,active:0,pending:0,managers:0}),[h,j]=a.useState(()=>sessionStorage.getItem("sutra_settingsRegisteredScope")||"all"),[L,I]=a.useState(!1),[E,P]=a.useState([]),[_,$]=a.useState(!1),[z,N]=a.useState([]),[b,k]=a.useState(0),[U,H]=a.useState({}),[D,T]=a.useState([]),[B,y]=a.useState([]),R=a.useRef(),S=a.useRef(!1),W=K=>{const le=[...E],xe=E.indexOf(K);xe>=0?le.splice(xe,1):le.push(K),P(le)},te=K=>{const le=[];if(K)for(let xe=0;xe<f.data.length;xe++)le.push(f.data[xe].username);P(le)},A=()=>f.data.length==E.length,J=()=>E.length>0,ae=()=>!A()&&E.length>0,be=K=>E.indexOf(K)>=0,Ee=()=>{const K=w.managers<u.permissions.max_allowed_managers[0]||u.permissions.max_allowed_managers[0]==-1;return K||I([!0,u.permissions.max_allowed_managers[1],u.permissions.max_allowed_managers[2]]),K};a.useEffect(()=>{t.scope&&t.scope!=="all"&&j(t.scope)},[t.scope]),a.useEffect(()=>{h&&sessionStorage.setItem("sutra_settingsRegisteredScope",h)},[h]),a.useEffect(()=>{u&&u.slug&&(Ge.page=1,F())},[u,i,h]),a.useEffect(()=>{u&&u.slug&&(q(),O(),ce(),me(),We())},[u,h]),a.useEffect(()=>{p&&p.opened=="filter-members-close"&&(l(ht({opened:null})),O(),F(),me(),We())},[p]);const F=()=>{$(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{Ls.oldScope!=h&&(Ge.page=1,Ls.oldScope=h);const K=Array.isArray(r.current)?r.current:[],xe=K.filter(X=>!["bundle","coupon","payment_survey"].includes(X.id)).map(X=>({id:X.id,values:X.selectedOptions||[],condition:X.condition})),Ce=K.filter(X=>X.id==="bundle").map(X=>({id:X.id,values:X.selectedOptions||[],condition:X.condition})),Wt=K.filter(X=>X.id==="coupon").map(X=>({id:X.id,values:X.selectedOptions||[],condition:X.condition})),Gt=K.filter(X=>X.id==="payment_survey").map(X=>({id:X.id,values:X.selectedOptions||[],condition:X.condition})),qt=Array.isArray(d.current)?d.current.map(X=>({id:X.id,value:X.value,sort_order:X.sort_order})):[];(h!="managers"?ve:Ve).onFetch(u.slug,Ge,{scope:h,term:i,filter_ids:xe,sort:qt,bundle_ids:Ce,coupon_ids:Wt,flexible_ids:Gt},X=>{$(!1),g(X)},X=>{$(!1)})},1e3)},q=()=>{ve.onFetchCounts(u.slug,K=>{x(K)},K=>{})},O=()=>{window.$fetchedTopSlug&&pt.onFetch(window.$fetchedTopSlug,K=>{if(Array.isArray(K)){N(K);const le=["admin","manager"].includes(window.$currentRole);(Array.isArray(K)?K.filter(Ce=>Array.isArray(Ce.visibility)&&Ce.visibility.includes("panel")&&(le||!Ce.visibility.includes("managers"))):[]).length>0&&typeof c=="function"&&!S.current&&c(!0),S.current=!0}},K=>{})},ce=()=>{u.slug&&pt.onFetchPaymentFilters(u.slug,K=>H(K),K=>{})},me=()=>{u.slug&&pt.onGetOptionCounts(u.slug,K=>{Array.isArray(K)&&T(K)},K=>{})},We=()=>{u.slug&&pt.onGetTopLocations(u.slug,K=>{Array.isArray(K)&&y(K)},K=>{})},rt=K=>{window.$dropdownFilterId=K.id,r.current=Array.isArray(r.current)?[...r.current,K]:[K],k(le=>le+1)},lt=K=>{let le=[];Array.isArray(r.current)&&K&&(Array.isArray(K)?le=K:r.current.length===0?le=[K]:le=r.current.find(Ce=>Ce.id===K.id)?r.current.map(Ce=>Ce.id===K.id?K:Ce):[...r.current,K]),r.current=le,Ge.page=1,F()},Ut=K=>{d.current=K||[],Ge.page=1,F(),k(le=>le+1)},Vt=K=>{Ge.page=K,F()},Mt=()=>{ve.onApproveAll(u.slug,K=>{F(),q()},K=>{})},Ht=()=>{oe.fire({title:"Are you sure?",html:"You are about to remove the selected members",showDenyButton:!0,confirmButtonText:"Remove the selected members",denyButtonText:"Cancel",confirmButtonColor:s.colors.red[8],denyButtonColor:s.colors.gray[6]}).then(K=>{K.isConfirmed&&_t()})},_t=()=>{const K=E.map(le=>{var xe;return((xe=f.data.find(Ce=>Ce.username==le))==null?void 0:xe.user_id)||null}).filter(le=>le!=null);$(!0),ve.onDestroyAllSelected(u.slug,K,()=>{P([]),F(),q()},le=>{F(),q(),oe.fire("Could not remove selected members",(le==null?void 0:le.message)||(le==null?void 0:le.error)||"Please try again.","error")})};return e.jsxs("div",{children:[e.jsx(yn,{type:"filter-members",section:"members-settings",loading:_,term:i,filters:z,filtersSelected:r.current,sortSelected:d.current,paymentFilters:U,optionCounts:D,topLocations:B,isFilterVisible:m,setTerm:o,onSelectFilter:rt,onUpdateFilter:lt,onUpdateSort:Ut,setIsFilterVisible:c,RightComponent:()=>e.jsxs(Z,{justify:"flex-end",gap:"xs",children:[!J()&&e.jsx(gs,{value:h,onChange:j,radius:"xl",style:{backgroundColor:"var(--mantine-color-gray-0)"},styles:{label:{fontSize:12,padding:"3px 10px"},root:{minHeight:28}},data:[{label:e.jsxs(Re,{children:[e.jsx(V,{mr:6,fz:12,children:n("spaces.settings.members.registered.registered.all")}),e.jsx(Se,{color:"gray",variant:"filled",size:"xs",className:ut.countBadge,children:w.all})]}),value:"all"},{label:e.jsxs(Re,{children:[e.jsx(V,{mr:6,fz:12,children:n("spaces.settings.members.registered.registered.active")}),e.jsx(Se,{color:"gray",variant:"filled",size:"xs",className:ut.countBadge,children:w.active})]}),value:"active"},{label:e.jsxs(Re,{children:[e.jsx(V,{mr:6,fz:12,children:n("spaces.settings.members.registered.registered.pending")}),e.jsx(Se,{color:"gray",variant:"filled",size:"xs",className:ut.countBadge,children:w.pending})]}),value:"pending"},{label:e.jsxs(Re,{children:[e.jsx(V,{mr:6,fz:12,children:n("spaces.settings.members.registered.registered.manager")}),e.jsx(Se,{color:"gray",variant:"filled",size:"xs",className:ut.countBadge,children:w.managers})]}),value:"managers"}]}),J()&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{transitionProps:{transition:"pop"},withArrow:!0,position:"bottom-end",children:[e.jsx(Q.Target,{children:e.jsx(M,{radius:"xl",style:{backgroundColor:s.colors.sutrablue[3]},leftSection:e.jsx(C,{icon:hn.faPaperPlane}),children:"Send broadcast"})}),e.jsxs(Q.Dropdown,{children:[e.jsx(Q.Item,{onClick:()=>t.onSendBroadcast("email",f.data,E),leftSection:e.jsx(C,{icon:ys.faEnvelope}),children:"Send email"}),e.jsx(Q.Item,{onClick:()=>t.onSendBroadcast("message",f.data,E),leftSection:e.jsx(C,{icon:fn.faComment}),children:"Send message"})]})]}),e.jsx(M,{radius:"xl",variant:"outline",color:"red",leftSection:e.jsx(C,{icon:jt.faTrash}),onClick:Ht,children:"Delete"})]})]})}),e.jsx(je,{mt:10,children:f.data.length==0?e.jsx(V,{className:ut.emptyBox,children:n("spaces.settings.members.registered.registered.noRecordFound")}):e.jsxs(se,{className:bs.stickyActionsTable,verticalSpacing:"xs",highlightOnHover:!0,children:[e.jsx(se.Thead,{children:e.jsxs(se.Tr,{children:[e.jsx(se.Th,{children:e.jsx(ot,{checked:A(),indeterminate:ae(),onChange:K=>te(K.currentTarget.checked)})}),e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",tt:"uppercase",children:n("spaces.settings.members.registered.registeredTable.member")})}),e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",tt:"uppercase",children:n("spaces.settings.members.registered.registeredTable.email")})}),e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",tt:"uppercase",children:n("spaces.settings.members.registered.registeredTable.status")})}),e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",tt:"uppercase",children:n("spaces.settings.members.registered.registeredTable.role")})}),e.jsx(se.Th,{children:e.jsx(M,{color:"green.7",variant:"outline",radiu
2s:"xl",size:"compact-xs",onClick:()=>Mt(),children:n("spaces.settings.members.registered.registeredTable.roleApproveAll")})})]})}),e.jsx(se.Tbody,{children:f.data.map((K,le)=>{var xe;return e.jsx(Sr,{hasSubscriptions:!!((xe=u==null?void 0:u.permissions)!=null&&xe.can_accept_charges),spaceId:u.slug,onUpdate:q,member:K,canAddNewManagers:Ee,isSelected:be,onSelect:W,scope:h},(K==null?void 0:K.id)||`new-member-${le}`)})})]})}),e.jsx(Je,{style:{borderTopColor:"var(--mantine-color-gray-2)"}}),e.jsx(V,{style:{width:"100%",display:"flex",marginTop:20,justifyContent:"center"},children:e.jsx(Rt,{color:"gray.6",value:Ge.page,onChange:Vt,total:f.pages})}),e.jsx(ke,{opened:L,setOpened:I})]})}const Cr="_emailText_1qm5v_1",Tr="_linkText_1qm5v_10",kr="_planBadge_1qm5v_25",es={emailText:Cr,linkText:Tr,planBadge:kr};function Er(t){const[s,l]=a.useState({}),[n,i]=a.useState(!1),[o,d]=a.useState(!1),{t:r,i18n:m}=ne();a.useEffect(()=>{(!s.id||s.id!=t.invitation.id)&&l(t.invitation)},[t]);const c=()=>{mt.onResend(s.id,t.spaceId,g=>{oe.fire("Invitation sent","Your invitation has been resent","success")},g=>{oe.fire(g.title,g.message,"info")})},u=()=>{i(!0),setTimeout(()=>{i(!1)},2e3)},p=()=>{d(!0),setTimeout(()=>{d(!1)},2e3)},f=()=>s.billing_type==="standard_checkout"?t.isPaid?"Standard":null:s.billing_type==="free"?"Free":(s.billing_type==="specific_plan"||s.billing_type==="custom_plan")&&s.plan_label?`${s.plan_label} — ${s.plan_price}`:t.isPaid?"—":null;return e.jsxs(V,{children:[e.jsx(Je,{style:{borderTopColor:"var(--mantine-color-gray-2)"}}),e.jsxs(V,{pt:10,pb:14,children:[e.jsxs(Z,{justify:"space-between",wrap:"nowrap",children:[e.jsxs(Z,{gap:12,wrap:"nowrap",style:{minWidth:0},children:[t.onSelect&&e.jsx(ot,{checked:t.isSelected?t.isSelected(s.id):!1,onChange:()=>t.onSelect(s.id)}),e.jsx(Le,{disabled:window.$isTouchDevice&&window.$isTouchDevice(),label:o?"Copied!":"Copy email",position:"bottom",withArrow:!0,children:e.jsx(ft,{onCopy:()=>p(),text:s.email,children:e.jsx(v,{size:"sm",fw:500,className:es.emailText,children:s.email})})}),f()&&e.jsx(v,{size:"xs",fw:500,className:es.planBadge,children:f()})]}),e.jsxs(Z,{gap:12,wrap:"nowrap",style:{flexShrink:0},children:[e.jsx(v,{size:"xs",c:"dimmed",style:{whiteSpace:"nowrap"},children:new Date(s.sent_at).toLocaleString(Me.DATE_MED)}),e.jsxs(Q,{transitionProps:{transition:"pop"},withArrow:!0,position:"bottom-end",children:[e.jsx(Q.Target,{children:e.jsx(Fe,{variant:"subtle",color:"gray","aria-label":"Invitation actions",children:e.jsx(C,{icon:Ot.faEllipsisVertical})})}),e.jsxs(Q.Dropdown,{children:[e.jsx(Q.Item,{onClick:()=>c(),leftSection:e.jsx(C,{icon:an.faEnvelope}),children:r("spaces.settings.members.invitedrow.invitation.resend")}),e.jsx(Q.Divider,{}),e.jsx(Q.Item,{onClick:()=>t.onDestroy(s),leftSection:e.jsx(C,{icon:_e.faTrashCan}),color:"red",children:r("spaces.settings.members.invitedrow.invitation.cancel")})]})]})]})]}),e.jsx(V,{mt:6,ml:t.onSelect?28:0,children:e.jsx(Le,{disabled:window.$isTouchDevice&&window.$isTouchDevice(),label:n?"Copied!":"Click to copy link",position:"bottom",withArrow:!0,children:e.jsx(ft,{onCopy:()=>u(),text:s.link,children:e.jsxs(v,{size:"xs",c:"dimmed",className:es.linkText,children:[s.link,e.jsx(C,{icon:Ei.faCopy,style:{flexShrink:0,fontSize:12}})]})})})})]})]})}const Ir="_emptyBox_1okr7_1",Dr={emptyBox:Ir},ts={page:1,per:30};function Fr(t){const{t:s,i18n:l}=ne(),n=ee(y=>y.space),i=t.theme,{height:o,width:d}=hs(),[r,m]=a.useState({total:0,page:1,pages:1,data:[]}),[c,u]=a.useState(null),[p,f]=a.useState(!1),[g,w]=a.useState([]),x=a.useRef();Qe(`(max-width: ${i.other.breakpoints.lg}px)`),Qe(`(max-width: ${i.other.breakpoints.xl}px)`),a.useEffect(()=>{n&&n.slug&&h()},[n]),a.useEffect(()=>{n&&n.slug&&h()},[c]),a.useEffect(()=>{t.refresh&&(h(),t.setRefresh(!1))},[t]);const h=()=>{f(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{mt.onFetch(n.slug,ts,{term:c},y=>{console.log("invitations: ",y),m(y),f(!1)},y=>{f(!1)})},1e3)},j=y=>{mt.onDestroy(y.id,n.slug,R=>{const S={...r};for(var W=0;W<S.data.length;W++)if(S.data[W].id==y.id){S.data.splice(W,1);break}m(S)},R=>{})},L=y=>{E(y)},I=y=>{E(y)},E=y=>{y.which==13&&(y.preventDefault(),P())},P=()=>{u(document.getElementById("search-input").value)},_=()=>{document.getElementById("search-input").value="",u("")},$=y=>{ts.page=y,h()},z=y=>{const R=[...g],S=g.indexOf(y);S>=0?R.splice(S,1):R.push(y),w(R)},N=y=>{w(y?r.data.map(R=>R.id):[])},b=()=>r.data.length>0&&r.data.length===g.length,k=()=>!b()&&g.length>0,U=()=>g.length>0,H=y=>g.indexOf(y)>=0,D=()=>{let y=0;const R=g.length;g.forEach(S=>{mt.onResend(S,n.slug,()=>{y++,y===R&&(w([]),oe.fire("Invitations sent",`${R} invitation(s) have been resent`,"success"))},W=>{y++,y===R&&w([])})})},T=()=>{oe.fire({title:"Are you sure?",html:`You are about to cancel ${g.length} invitation(s)`,showDenyButton:!0,confirmButtonText:"Cancel invitations",denyButtonText:"Go back",confirmButtonColor:i.colors.red[8],denyButtonColor:i.colors.gray[6]}).then(y=>{y.isConfirmed&&B()})},B=()=>{let y=0;const R=g.length,S=[...g];
2S.forEach(W=>{mt.onDestroy(W,n.slug,()=>{if(y++,y===R){const te={...r};te.data=te.data.filter(A=>!S.includes(A.id)),m(te),w([]),t.onFetchCounts&&t.onFetchCounts()}},()=>{y++,y===R&&(h(),w([]))})})};return e.jsxs("div",{children:[e.jsxs(Z,{justify:"space-between",mt:20,children:[e.jsxs(Z,{justify:"flex-start",gap:"xs",children:[e.jsx(Ue,{leftSection:e.jsx(C,{icon:Nt.faSearch}),placeholder:s("spaces.settings.members.invited.invited.placeholder"),id:"search-input",radius:"xl",onKeyPress:y=>L(y),onKeyDown:y=>I(y),rightSection:c?e.jsx(v,{style:{cursor:"pointer"},onClick:()=>_(),children:e.jsx(C,{icon:jn.faXmark})}):e.jsx(v,{children:"  "})}),e.jsx(M,{variant:"filled",radius:"xl",onClick:y=>P(),style:{backgroundColor:i.colors.sutrablue[3]},children:s("spaces.settings.members.invited.invited.button")}),p&&e.jsx(Oe,{size:"xs"})]}),U()&&e.jsxs(Z,{justify:"flex-end",gap:"xs",children:[e.jsx(M,{radius:"xl",style:{backgroundColor:i.colors.sutrablue[3]},onClick:D,children:"Resend"}),e.jsx(M,{radius:"xl",variant:"outline",color:"red",leftSection:e.jsx(C,{icon:jt.faTrash}),onClick:T,children:"Delete"})]})]}),e.jsx(je,{mt:10,children:r.data.length==0?e.jsx(V,{className:Dr.emptyBox,children:s("spaces.settings.members.invited.invited.noRecordFound")}):e.jsxs(V,{children:[e.jsxs(Z,{justify:"space-between",wrap:"nowrap",px:0,py:8,children:[e.jsxs(Z,{gap:12,wrap:"nowrap",children:[e.jsx(ot,{checked:b(),indeterminate:k(),onChange:y=>N(y.currentTarget.checked)}),e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:"Email"})]}),e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",mr:40,children:"Date Sent"})]}),e.jsx(Je,{style:{borderTopColor:"var(--mantine-color-gray-2)"}}),r.data.map(y=>e.jsx(Er,{spaceId:n.slug,invitation:y,onDestroy:j,isPaid:n.is_paid,isSelected:H,onSelect:z},y.id))]})}),e.jsx(Je,{style:{borderTopColor:"var(--mantine-color-gray-2)"}}),e.jsx(V,{style:{width:"100%",display:"flex",marginTop:20,justifyContent:"center"},children:e.jsx(Rt,{color:"gray.6",value:ts.page,onChange:$,total:r.pages})})]})}const tt=class tt{constructor(){if(this instanceof tt)throw Error("Payment class cannot be instantiated.")}};Te(tt,"onFetch",async(s,l,{term:n},i,o)=>{const d={locale:window.$currentUserLanguage,term:n,...l};await window.$api.get(`/api/v4/spaces/${s}/payments.json`,{params:d}).then(r=>{i(r.data)}).catch(r=>{try{o(r.response.data)}catch{}})}),Te(tt,"onLinkAccount",async(s,l,n,i)=>{const o={locale:window.$currentUserLanguage};await window.$api.post(`/api/v4/spaces/${s}/payments/${l}/link_account.json`,o).then(d=>{n(d.data)}).catch(d=>{try{i(d.response.data)}catch{}})}),Te(tt,"onDestroy",async(s,l,n,i)=>{const o={locale:window.$currentUserLanguage};await window.$api.delete(`/api/v4/spaces/${l}/payments/${s}.json`,{params:o}).then(d=>{n(d.data)}).catch(d=>{try{i(d.response.data)}catch{}})});let Pt=tt;const Br={paid:"green",refunded:"red",partial_refund:"orange",failed:"yellow",pending:"yellow",trial:"gray",free_trial:"blue"},$r={paid:"Paid",refunded:"Refunded",partial_refund:"Partial refund",failed:"Failed",pending:"Pending",trial:"Incomplete",free_trial:"Free trial"},Pr={paid:"This payment is complete",refunded:"This payment has been refunded",partial_refund:"This payment has been partially refunded",failed:"This payment has not been processed",pending:"This payment has not been processed",trial:"This payment is incomplete",free_trial:"This payment is incomplete"};function Ar(t){const{t:s}=ne(),l=Pe(),[n,i]=a.useState({user:{avatar:{}}});a.useEffect(()=>{var u;(!(n!=null&&n.id)||n.id!=((u=t.payment)==null?void 0:u.id))&&i(t.payment)},[t]);const o=()=>{oe.fire({title:"Are you sure?",html:"You are about to refund the full amount of this payment",showDenyButton:!0,confirmButtonText:"Yes, refund",denyButtonText:"No",confirmButtonColor:Ct.red,denyButtonColor:Ct.gray}).then(u=>{u.isConfirmed&&qs.onRefund(t.spaceId,n.id,p=>{i(f=>({...f,status:"refunded"})),oe.fire(p.title,p.message,"success")},p=>{oe.fire(p.title,p.message,"error")})})},d=()=>{n.user&&l(ht({opened:"profile",option:n.user.username,unthemed:!0}))},r=!(n!=null&&n.user),m=()=>{oe.fire({title:s("spaces.settings.members.paymentRow.payment.linkConfirmTitle"),html:s("spaces.settings.members.paymentRow.payment.linkConfirmBody",{email:n.payer_email}),showDenyButton:!0,confirmButtonText:s("spaces.settings.members.paymentRow.payment.linkConfirm"),denyButtonText:s("spaces.settings.members.paymentRow.payment.cancel"),confirmButtonColor:Ct.blue,denyButtonColor:Ct.gray}).then(u=>{u.isConfirmed&&Pt.onLinkAccount(t.spaceId,n.id,p=>{p.payment&&i(p.payment),t.onChange&&t.onChange(),oe.fire(p.title,p.message,"success")},p=>{oe.fire(p.title,p.message,"error")})})};if(!n)return null;const c=typeof n.formatted_amount=="string"?n.formatted_amount.replace(/,/g,""):0;return e.jsxs(se.Tr,{children:[e.jsx(se.Td,{children:r?e.jsxs(Z,{gap:"sm",wrap:"nowrap",children:[e.jsx(os,{size:30,radius:30,children:e.jsx(C,{icon:ga.faCircleQuestion})}),e.jsxs(it,{gap:"0",children:[e.jsx(v,{size:"sm",fw:500,children:n.payer_email||s("space
2s.settings.members.paymentRow.payment.noEmail")}),e.jsx(v,{size:"xs",c:"orange",mt:-3,children:s("spaces.settings.members.paymentRow.payment.notLinked")})]})]}):e.jsxs(Z,{gap:"sm",onClick:()=>d(),style:{color:"#000"},className:ds.noHoverUnderline,wrap:"nowrap",children:[e.jsx(os,{size:30,src:n.user.avatar.url,radius:30}),e.jsxs(it,{gap:"0",children:[e.jsx(v,{size:"sm",fw:500,children:n.user.full_name}),e.jsxs(v,{size:"xs",c:"dimmed",mt:-3,children:["@",n.user.username]})]})]})}),e.jsxs(se.Td,{children:[vt(n.currency),n.formatted_amount]}),e.jsx(se.Td,{children:new Date(n.date||n.created_at).toLocaleString(Me.DATE_MED)}),e.jsx(se.Td,{children:e.jsx(Le,{disabled:window.$isTouchDevice&&window.$isTouchDevice(),multiline:!0,styles:{tooltip:{width:220}},label:n.status==="partial_refund"&&n.refunded_amount?`${vt(n.currency)}${(n.refunded_amount/100).toFixed(2)} was refunded`:Pr[n.status],withArrow:!0,children:e.jsx(Se,{color:Br[n.status],variant:"light",children:$r[n.status]})})}),e.jsx(se.Td,{children:!!(n.bundle||n.coupon||r||n.status==="paid"&&Number(c)>0)&&e.jsx(Z,{gap:"sm",justify:"flex-end",children:e.jsxs(Q,{transitionProps:{transition:"pop"},withArrow:!0,position:"bottom-end",children:[e.jsx(Q.Target,{children:e.jsx(Fe,{variant:"subtle",color:"gray",children:e.jsx(C,{icon:Ss.faEllipsis})})}),e.jsxs(Q.Dropdown,{children:[!!n.bundle&&e.jsxs(Q.Label,{children:["Bundle:"," ",n.bundle.name+" ","(",n.bundle.default_payment_amount,vt(n.bundle.currency)," - ",n.bundle.default_payment_frequency,")"]}),!!n.coupon&&e.jsxs(e.Fragment,{children:[!!n.bundle&&e.jsx(Q.Divider,{}),e.jsxs(Q.Label,{children:["Coupon:"," ",n.coupon.code+" ","(",n.coupon.discount_type==="percent"?`${n.coupon.value}%`:`${vt(n.coupon.payment_currency)}${((n.coupon.effective_amount_off||0)/100).toFixed(2)} ${n.coupon.payment_currency.toUpperCase()}`,")"]})]}),r&&!!n.payer_email&&e.jsxs(e.Fragment,{children:[!!(n.bundle||n.coupon)&&e.jsx(Q.Divider,{}),e.jsx(Q.Item,{leftSection:e.jsx(C,{icon:gn.faLink}),onClick:()=>m(),children:s("spaces.settings.members.paymentRow.payment.linkAccount")})]}),n.status==="paid"&&Number(c)>0&&e.jsxs(e.Fragment,{children:[!!(n.bundle||n.coupon||r)&&e.jsx(Q.Divider,{}),e.jsx(Q.Item,{leftSection:e.jsx(C,{icon:Ii.faCreditCard}),color:"red",onClick:()=>o(),children:s("spaces.settings.members.paymentRow.payment.refundPayment")})]})]})]})})})]})}const Rr="_emptyBox_1okr7_1",zr={emptyBox:Rr},ss={page:1,per:30};function Nr(t){const{t:s,i18n:l}=ne(),n=ee(b=>b.space),i=t.theme,{height:o,width:d}=hs(),[r,m]=a.useState({total:0,page:1,pages:1,data:[]}),[c,u]=a.useState(null),[p,f]=a.useState(null),[g,w]=a.useState({all:0,active:0,pending:0,managers:0});Qe(`(max-width: ${i.other.breakpoints.lg}px)`),Qe(`(max-width: ${i.other.breakpoints.xl}px)`);const[x,h]=a.useState(!1),j=a.useRef();a.useEffect(()=>{n&&n.slug&&(I(),L())},[n,c]),a.useEffect(()=>{n&&n.slug&&I()},[p]);const L=()=>{ve.onFetchCounts(n.slug,b=>{w(b)},b=>{})},I=()=>{h(!0),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{Pt.onFetch(n.slug,ss,{scope:c,term:p},b=>{m(b),h(!1)},b=>{h(!1)})},1e3)},E=b=>{_(b)},P=b=>{_(b)},_=b=>{b.which==13&&(b.preventDefault(),$())},$=()=>{f(document.getElementById("search-input").value)},z=()=>{document.getElementById("search-input").value="",f("")},N=b=>{ss.page=b,I()};return e.jsxs("div",{children:[e.jsxs(Z,{justify:"space-between",mt:20,children:[e.jsxs(Z,{justify:"flex-start",gap:"xs",children:[e.jsx(Ue,{leftSection:e.jsx(C,{icon:Nt.faSearch}),placeholder:s("spaces.settings.members.payments.payment.searchPlaceholder"),id:"search-input",radius:"xl",onKeyPress:b=>E(b),onKeyDown:b=>P(b),rightSection:p?e.jsx(v,{style:{cursor:"pointer"},onClick:()=>z(),children:e.jsx(C,{icon:jn.faXmark})}):e.jsx(v,{children:"  "})}),e.jsx(M,{variant:"filled",radius:"xl",onClick:b=>$(),style:{backgroundColor:i.colors.sutrablue[3]},children:s("spaces.settings.members.payments.payment.searchButton")}),x&&e.jsx(Oe,{size:"xs"})]}),e.jsx(Z,{justify:"flex-end",gap:"xs",children:e.jsx(gs,{radius:"xl",style:{backgroundColor:"var(--mantine-color-gray-0)"},data:[{label:`${g.formatted_earnings}`,value:"all"}]})})]}),e.jsx(je,{mt:10,children:r.data.length==0?e.jsx(V,{className:zr.emptyBox,children:s("spaces.settings.members.payments.payment.no
2RecordFound")}):e.jsxs(se,{className:bs.stickyActionsTable,verticalSpacing:"xs",highlightOnHover:!0,children:[e.jsx(se.Thead,{children:e.jsxs(se.Tr,{children:[e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:s("spaces.settings.members.payments.paymentTable.member")})}),e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:s("spaces.settings.members.payments.paymentTable.amount")})}),e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:s("spaces.settings.members.payments.paymentTable.date")})}),e.jsx(se.Th,{children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:s("spaces.settings.members.payments.paymentTable.status")})}),e.jsx(se.Th,{})]})}),e.jsx(se.Tbody,{children:r.data.map(b=>e.jsx(Ar,{spaceId:n.slug,payment:b}))})]})}),e.jsx(Je,{style:{borderTopColor:"var(--mantine-color-gray-2)"}}),e.jsx(V,{style:{width:"100%",display:"flex",marginTop:20,justifyContent:"center"},children:e.jsx(Rt,{color:"gray.6",value:ss.page,onChange:N,total:r.pages})})]})}function Or(t){const[s,l]=a.useState({}),{t:n,i18n:i}=ne();return a.useEffect(()=>{(!s.id||s.id!=t.interest.id)&&l(t.interest)},[t]),e.jsxs(se.Tr,{style:{cursor:"pointer"},onClick:()=>t.onOpenProfile&&t.onOpenProfile(s),children:[e.jsx(se.Td,{onClick:o=>o.stopPropagation(),children:e.jsx(ot,{checked:t.isSelected?t.isSelected(s.id):!1,onChange:()=>t.onSelect&&t.onSelect(s.id)})}),e.jsx(se.Td,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"sm",fw:500,children:s.first_name})}),e.jsx(se.Td,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"sm",fw:500,children:s.last_name})}),e.jsx(se.Td,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"sm",fw:500,children:s.email})}),e.jsx(se.Td,{style:{whiteSpace:"nowrap"},children:new Date(s.created_at).toLocaleString(Me.DATE_MED)}),e.jsx(se.Td,{style:{whiteSpace:"nowrap"},children:s.referred_by?e.jsxs(v,{size:"sm",c:"dimmed",children:[s.referred_by.name||(s.referred_by.username?`@${s.referred_by.username}`:"—"),s.referred_by.custom_link?` · ${s.referred_by.custom_link}`:""]}):e.jsx(v,{size:"sm",c:"dimmed",children:"—"})}),e.jsx(se.Td,{onClick:o=>o.stopPropagation(),children:e.jsx(Z,{gap:"sm",justify:"flex-end",children:e.jsxs(Q,{transitionProps:{transition:"pop"},withArrow:!0,position:"bottom-end",children:[e.jsx(Q.Target,{children:e.jsx(Fe,{variant:"subtle",color:"gray","aria-label":"Row actions",children:e.jsx(C,{icon:Ot.faEllipsisVertical})})}),e.jsx(Q.Dropdown,{children:e.jsx(Q.Item,{onClick:()=>t.onDestroy(s),leftSection:e.jsx(C,{icon:_e.faTrashCan}),color:"red",children:n("spaces.settings.members.interested.interestedrow.removeFromList")})})]})})})]},s.full_name)}const Lr="_emptyBox_1okr7_1",Ur={emptyBox:Lr},qe={page:1,per:30};function Vr(t){const{t:s}=ne(),l=Pe(),n=ee(G=>G.space),i=ee(G=>G.tiptapSidemenu),o=t.theme,{height:d,width:r}=hs(),{term:m,setTerm:c,sortSelected:u,filtersSelected:p,isFilterVisible:f,setIsFilterVisible:g}=_n(),[w,x]=a.useState({total:0,page:1,pages:1,data:[]}),[h,j]=a.useState(!1),[L,I]=a.useState([]),[E,P]=a.useState(!1),[_,$]=a.useState([]),[z,N]=a.useState(0),[b,k]=a.useState([]),[U,H]=a.useState([]),[D,T]=a.useState([]),[B,y]=a.useState(null),[R,S]=a.useState(!1),[W,te]=a.useState(!1),A=a.useRef(),J=a.useRef(!1),ae=G=>{const X=[...D],ye=D.indexOf(G);ye>=0?X.splice(ye,1):X.push(G),T(X)},be=G=>{T(G?w.data.map(X=>X.id):[])},Ee=()=>w.data.length>0&&w.data.length===D.length,F=()=>!Ee()&&D.length>0,q=()=>D.length>0,O=G=>D.indexOf(G)>=0,ce=()=>{const G=w.data.filter(X=>D.indexOf(X.id)>=0).map(X=>({...X,username:X.email,full_name:X.email}));I(G),j(!0)};Qe(`(max-width: ${o.other.breakpoints.lg}px)`),Qe(`(max-width: ${o.other.breakpoints.xl}px)`),a.useEffect(()=>{n&&n.slug&&(qe.page=1,me())},[n,m]),a.useEffect(()=>{n&&n.slug&&(We(),rt(),lt())},[n]),a.useEffect(()=>{t.refresh&&(me(),t.setRefresh(!1))},[t]),a.useEffect(()=>{i&&i.opened=="filter-members-close"&&(l(ht({opened:null})),We(),me(),rt(),lt())},[i]);const me=()=>{P(!0),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{const X=(Array.isArray(p.current)?p.current:[]).map(de=>({id:de.id,values:de.selectedOptions||[],condition:de.condition})),ye=Array.isArray(u.current)?u.current.map(de=>({id:de.id,value:de.value,sort_order:de.sort_order})):[];dt.onFetch(n.slug,qe,{term:m,filter_ids:X,sort:ye},de=>{x(de),P(!1)},de=>{P(!1)})},1e3)},We=()=>{window.$fetchedTopSlug&&pt.onFetch(window.$fetchedTopSlug,G=>{if(Array.isArray(G)){$(G);const X=["admin","manager"].includes(window.$currentRole);G.filter(de=>Array.isArray(de.visibility)&&de.visibility.includes("panel")&&(X||!de.visibility.includes("managers"))).length>0&&typeof g=="function"&&!J.current&&g(!0),J.current=!0}},G=>{})},rt=()=>{n.slug&&dt.onFetchOptionCounts(n.slug,G=>{Array.isArray(G)&&k(G)},G=>{})},lt=()=>{n.slug&&dt.onFetchTopLocations(n.slug,G=>{Array.isArray(G)&&H(G)},G=>{})},Ut=({targetSpaceSlug:G}={})=>{G&&n.slug&&G!==n.slug||(T([]),qe.page=1,me(),We(),rt(),lt())},Vt=G=>{window.$dropdownFilterId=G.id,p.current=Array.isArray(p.current)?[...p.current,G]:[G],N(X=>X+1)},Mt=G=>{let X=[];Array.isArray(p.current)&&G&&(Array.isArray(G)?X=G:p.current.length===0?X=[G]:X=p.current.find(de=>de.id===G.id)?p.current.map(de=>de.id===G.id?G:de):[...p.current,G]),p.current=X,qe.page=1,me()},Ht=G=>{u.current=G||[],qe.page=1,me(),N(X=>X+1)},_t=G=>{dt.onDestroy(G.id,n.slug,X=>{const ye={...w};for(var de=0;de<ye.data.length;de++)if(ye.data[de].id==G.id){ye.data.splice(de,1);break}x(ye)},X=>{})},K=G=>{y(G),S(!0)},le=()=>{var X;const G=w.data.filter(ye=>D.indexOf(ye.id)>=0).map(ye=>
2ye.email).filter(Boolean).join(", ");(X=t.onOpenInvite)==null||X.call(t,G)},xe=()=>{if(D.length===0)return;const G=D.length;window.confirm(`Are you sure you want to delete ${G} contact${G>1?"s":""}?`)&&(D.forEach(X=>{dt.onDestroy(X,n.slug,()=>{},()=>{})}),T([]),setTimeout(()=>me(),500))},Ce=G=>{S(!1);const X={...G,username:G.email,full_name:G.email};I([X]),j(!0)},Wt=G=>{var X;G!=null&&G.email&&(S(!1),(X=t.onOpenInvite)==null||X.call(t,G.email))},Gt=G=>{qe.page=G,me()},qt=()=>{};return e.jsxs("div",{children:[e.jsx(yn,{type:"filter-members",section:"contacts-settings",loading:E,term:m,filters:_,filtersSelected:p.current,sortSelected:u.current,optionCounts:b,topLocations:U,isFilterVisible:f,setTerm:c,onSelectFilter:Vt,onUpdateFilter:Mt,onUpdateSort:Ht,setIsFilterVisible:g,RightComponent:()=>e.jsxs(Z,{justify:"flex-end",gap:"xs",children:[!q()&&e.jsxs(e.Fragment,{children:[e.jsx(M,{variant:"outline",radius:"xl",onClick:()=>te(!0),style:{borderColor:o.colors.sutrablue[3],color:o.colors.sutrablue[3]},children:"Import"}),e.jsx(M,{variant:"filled",radius:"xl",style:{backgroundColor:o.colors.sutrablue[3]},leftSection:e.jsx(C,{icon:hn.faPaperPlane}),onClick:()=>{I([]),j(!0)},children:s("spaces.settings.members.interested.interested.broadcast")})]}),q()&&e.jsxs(e.Fragment,{children:[e.jsx(M,{radius:"xl",style:{backgroundColor:o.colors.sutrablue[3]},onClick:()=>ce(),children:s("spaces.settings.members.registered.registered.email")}),e.jsx(M,{radius:"xl",style:{backgroundColor:o.colors.sutrablue[3]},onClick:le,children:"Invite"}),e.jsx(M,{radius:"xl",variant:"outline",color:"red",leftSection:e.jsx(C,{icon:jt.faTrash}),onClick:xe,children:"Delete"})]})]})}),e.jsx(je,{mt:10,children:w.data.length==0?e.jsx(V,{className:Ur.emptyBox,children:s("spaces.settings.members.interested.interested.noRecordFound")}):e.jsxs(se,{className:bs.stickyActionsTable,verticalSpacing:"xs",highlightOnHover:!0,children:[e.jsx(se.Thead,{children:e.jsxs(se.Tr,{children:[e.jsx(se.Th,{children:e.jsx(ot,{checked:Ee(),indeterminate:F(),onChange:G=>be(G.currentTarget.checked)})}),e.jsx(se.Th,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:s("spaces.settings.members.interested.table.firstname")})}),e.jsx(se.Th,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:s("spaces.settings.members.interested.table.lastname")})}),e.jsx(se.Th,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:s("spaces.settings.members.interested.table.email")})}),e.jsx(se.Th,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:"Date added"})}),e.jsx(se.Th,{style:{whiteSpace:"nowrap"},children:e.jsx(v,{size:"xs",fw:600,c:"dimmed",transform:"uppercase",children:"Referred by"})}),e.jsx(se.Th,{})]})}),e.jsx(se.Tbody,{children:w.data.map(G=>e.jsx(Or,{spaceId:n.slug,interest:G,isSelected:O,onSelect:ae,onDestroy:_t,onOpenProfile:K},G.id))})]})}),e.jsx(Je,{style:{borderTopColor:"var(--mantine-color-gray-2)"}}),e.jsx(V,{style:{width:"100%",display:"flex",marginTop:20,justifyContent:"center"},children:e.jsx(Rt,{color:"gray.6",value:qe.page,onChange:Gt,total:w.pages})}),e.jsx(Lt,{opened:h,setOpened:j,sendToUsers:L.length>0?L:void 0,defaultTarget:L.length===0?["interested"]:void 0,onUpdate:qt,parentName:n.name,isTopLevel:n.is_top_level,isEmailReady:window.$fetchedTopSpace.is_email_ready}),e.jsx(fa,{opened:W,setOpened:te,onComplete:Ut}),e.jsx(ha,{spaceContactId:B==null?void 0:B.space_contact_id,interest:B,opened:R,setOpened:S,onDestroy:G=>{_t(G),S(!1)},onSendEmail:Ce,onInvite:Wt})]})}function Mr(){const{t}=ne(),s=xt(),l=we(),n=ee(te=>te.space),[i,o]=a.useState(()=>sessionStorage.getItem("sutra_settingsMembersSection")||"registered"),[d,r]=a.useState("all"),[m,c]=a.useState(!1),[u,p]=a.useState(""),[f,g]=a.useState(!1),[w,x]=a.useState(!1),[h,j]=a.useState(!1),[L,I]=a.useState(!1),[E,P]=a.useState([]),[_,$]=a.useState("member"),[z,N]=a.useState(!1),b=a.useRef([]),k=a.useRef("email");a.useEffect(()=>{T()},[s]),a.useEffect(()=>{sessionStorage.setItem("sutra_settingsMembersSection",i)},[i]),a.useEffect(()=>{$(window.$currentRole),f&&(S(),g(!1))},[f]),a.useEffect(()=>{P(n&&n.permissions&&n.permissions.can_send_selective_broadcast),i==="payments"&&!["admin","manager"].includes(window.$currentRole)&&o("registered"),S()},[n]);const U=te=>{p(te||""),c(!0)},H=()=>{},D=(te,A,J)=>{if(!E[0]){I([!0,E[1],E[2]]);return}b.current=[];for(let ae=0;ae<A.length;ae++)J.indexOf(A[ae].username)>=0&&window.$currentUserId!=A[ae].user_id&&b.current.push({...A[ae]});te==="email"?(k.current=te,N(!0)):(k.current=te,j(!0))},T=()=>{const te=s.search,A=new URLSearchParams(te).get("section"),J=new URLSearchParams(te).get("scope");A&&o(A),J&&r(J)},B=()=>i=="registered"?e.jsx(Us,{theme:l,refresh:f,scope:d,setRefresh:g,onSendBroadcast:D,onFetchCounts:S}):i=="invited"?e.jsx(Fr,{theme:l,refresh:f,setRefresh:g,onFetchCounts:S}):i=="interested"?e.jsx(Vr,{theme:l,refresh:f,setRefresh:g,onFetchCounts:S,onOpenInvite:U}):i=="sources"?e.jsx(xa,{}):i=="payments"?e.jsx(Nr,{theme:l,refresh:f,setRefresh:g,onFetchCounts:S}):e.jsx(Us,{theme:l,refresh:f,setRefresh:g,onFetchCounts:S}),y=()=>
2{ve.onDownloadExcel(n.slug)},R=()=>{ve.onDownloadCsv(n.slug,i)},S=()=>{ve.onFetchCounts(n.slug,te=>{x(te)},te=>{})},W=(te,A)=>e.jsxs(Re,{children:[e.jsx(V,{mr:6,fz:13,children:te}),e.jsx(Se,{color:"dark",variant:"outline",size:"xs",children:w[A]})]});return e.jsxs(je,{style:{height:"100%"},children:[e.jsxs($e,{style:{marginBottom:"50px",width:"850px",maxWidth:"850px"},pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceId:n.slug,spaceVersion:n.version,spaceName:n.name,title:t("spaces.settings.members.title"),rightSide:e.jsxs(Z,{children:[e.jsxs(Q,{transitionProps:{transition:"pop"},withArrow:!0,position:"bottom-end",size:"sm",children:[e.jsx(Q.Target,{children:e.jsx(M,{variant:"light",color:"gray",radius:"xl",style:{backgroundColor:"var(--mantine-color-gray-1)",color:"var(--mantine-color-gray-8)"},children:t("spaces.settings.members.members.download")})}),e.jsxs(Q.Dropdown,{children:[e.jsx(Q.Item,{onClick:()=>y(),children:t("spaces.settings.members.members.downloadXls")}),e.jsx(Q.Item,{onClick:()=>R(),children:t("spaces.settings.members.members.downloadCsv")})]})]}),e.jsx(M,{variant:"filled",radius:"xl",onClick:()=>{p(""),c(!0)},leftSection:e.jsx(C,{icon:ln.faUserPlus}),className:hr.inviteButton,children:t("spaces.settings.members.members.invite")})]})}),e.jsx(gs,{fullWidth:!0,value:i,onChange:te=>o(te),styles:{label:{fontSize:13,padding:"4px 10px"},root:{minHeight:32}},data:[{label:W(t("spaces.settings.members.members.member"),"all"),value:"registered"},{label:W(t("spaces.settings.members.members.invited"),"invitations"),value:"invited"},{label:W(t("spaces.settings.members.members.interested"),"interested"),value:"interested"},{label:"Sources",value:"sources"},...["admin","manager"].includes(_)?[{label:W(t("spaces.settings.members.members.payment"),"payments"),value:"payments"}]:[]]}),e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:B()}),m&&e.jsx(rn,{opened:m,setOpened:c,setRefresh:g,prefillEmails:u})]}),e.jsx(Sn,{opened:h,setOpened:j,onUpdate:H,sendToUsers:b.current,broadcastType:k.current,parentName:n.name,isTopLevel:n.is_top_level,isEmailReady:window.$fetchedTopSpace.is_email_ready}),e.jsx(Lt,{opened:z,setOpened:N,sendToUsers:b.current,onUpdate:H,parentName:n.name,isTopLevel:n.is_top_level,isEmailReady:window.$fetchedTopSpace.is_email_ready}),e.jsx(ke,{opened:L,setOpened:I})]})}const Hr="_broadcastButton_1ohwx_1",Wr={broadcastButton:Hr},Gr="_ellipsisButton_6d4vt_1",qr="_statRow_6d4vt_5",Kr="_statSegment_6d4vt_11",Yr="_statusRow_6d4vt_20",et={ellipsisButton:Gr,statRow:qr,statSegment:Kr,statusRow:Yr};function Zr(t){var k,U,H,D,T,B,y;const{t:s,i18n:l}=ne(),n=we(),[i,o]=a.useState({user:{}}),[d,r]=a.useState(null);a.useEffect(()=>{t.broadcast&&t.broadcast.id!=i.id&&o(t.broadcast)},[t]),a.useEffect(()=>{if(!i.is_sending)return;const R=setInterval(()=>{he.onFetchSendProgress(i.id,t.spaceId,S=>{r(S),S.is_sending||(clearInterval(R),t.onUpdate())},()=>{})},5e3);return()=>clearInterval(R)},[i.id,i.is_sending]);const m=()=>{oe.fire({title:s("spaces.settings.broadcast.cancel_send.confirm_title"),text:s("spaces.settings.broadcast.cancel_send.confirm_message"),showDenyButton:!0,confirmButtonText:s("spaces.settings.broadcast.cancel_send.confirm_button"),denyButtonText:s("spaces.settings.broadcast.cancel_send.dismiss_button"),icon:"warning"}).then(R=>{R.isConfirmed&&he.onCancelSend(i.id,t.spaceId,()=>{oe.fire(s("spaces.settings.broadcast.cancel_send.success_title"),s("spaces.settings.broadcast.cancel_send.success_message"),"success"),t.onUpdate()},S=>{oe.fire(s("spaces.settings.broadcast.cancel_send.error_title"),
2(S==null?void 0:S.message)||"","error")})})},c=()=>{t.onEdit(i)},u=()=>{he.onDuplicate(i.id,t.spaceId,R=>{t.onUpdate()},R=>{oe.fire((R==null?void 0:R.title)||"Unable to duplicate broadcast",(R==null?void 0:R.message)||"","error")})},p=()=>{oe.fire({title:s("spaces.settings.broadcast.onDestroy.alertTitle"),html:s("spaces.settings.broadcast.onDestroy.alertMessage"),showDenyButton:!0,confirmButtonText:s("spaces.settings.broadcast.onDestroy.confirm"),denyButtonText:s("spaces.settings.broadcast.onDestroy.deny"),confirmButtonColor:n.colors.red[8],denyButtonColor:n.colors.gray[6]}).then(R=>{R.isConfirmed?he.onDestroy(i.id,t.spaceId,S=>{t.onUpdate()},S=>{}):R.isDenied})},f=i.is_sent&&i.analytics&&i.analytics.total_recipients>0,g=Number(i.send_count)>0,w=i.is_scheduled&&!i.is_sent&&i.send_time,x=i.is_sent,h=i.is_errored&&!i.is_sent,j=i.is_sent,L=i.is_scheduled&&!i.is_sent&&!i.is_errored,I=i.is_draft&&!i.is_scheduled&&!i.is_sent,E=i.is_sending,P=i.is_cancelled,_=i.is_halted,$=i.is_processing&&!E,z=h||j||L||I||$||E||P||_,N=(U=d==null?void 0:d.recipients_total)!=null?U:(k=i.send_progress)==null?void 0:k.recipients_total,b=(T=(H=d==null?void 0:d.recipients_sent)!=null?H:d==null?void 0:d.recipients_enqueued)!=null?T:(D=i.send_progress)==null?void 0:D.recipients_enqueued;return e.jsxs(V,{mb:17,pb:20,style:{borderBottom:"1px solid var(--mantine-color-gray-2)"},children:[e.jsxs(Z,{justify:"space-between",wrap:"nowrap",style:{height:"100%",display:"flex",alignItems:"flex-start"},children:[e.jsx(V,{children:e.jsx(v,{component:Gs,to:"",style:{color:"var(--mantine-color-sutrablue-3)",fontWeight:500,fontSize:20},onClick:()=>c(),children:i.title})}),e.jsx(V,{children:e.jsx(it,{justify:"flex-start",children:e.jsxs(Q,{transitionProps:{transition:"pop"},position:"bottom-end",children:[e.jsx(Q.Target,{children:e.jsx(M,{compact:!0,variant:"subtle",color:"dark",className:et.ellipsisButton,children:e.jsx(C,{icon:Ss.faEllipsis})})}),e.jsxs(Q.Dropdown,{children:[!i.is_sent&&!i.is_sending&&e.jsx(Q.Item,{onClick:()=>c(),leftSection:e.jsx(da,{size:18,strokeWidth:2,color:"black"}),children:s("spaces.settings.broadcast.actions.edit")}),i.is_sending&&e.jsx(Q.Item,{onClick:()=>m(),leftSection:e.jsx(C,{icon:Rn.faCircleStop}),color:"red",children:s("spaces.settings.broadcast.actions.cancel_send")}),e.jsx(Q.Item,{onClick:()=>u(),leftSection:e.jsx(ua,{size:18,strokeWidth:2,color:"black"}),children:s("spaces.settings.broadcast.actions.duplicate")}),e.jsx(Q.Divider,{}),e.jsx(Q.Item,{onClick:()=>p(),leftSection:e.jsx(C,{icon:_e.faTrashCan}),color:"red",children:s("spaces.settings.broadcast.actions.delete")})]})]})})})]}),!I&&e.jsxs(Z,{mt:3,gap:"sm",className:et.statRow,style:{color:"var(--mantine-color-gray-6)"},children:[e.jsx(v,{children:i.user.full_name}),(w||x||g)&&e.jsx(v,{children:"•"}),w&&e.jsxs(Z,{gap:"sm",className:et.statSegment,children:[e.jsx(v,{children:Me.fromSQL(i.send_time).toFormat("LLL d, yyyy, h:mm a")}),g&&e.jsx(v,{children:"•"})]}),x&&e.jsxs(Z,{gap:"sm",className:et.statSegment,children:[e.jsx(v,{children:Me.fromSQL(i.sent_on).toFormat("LLL d, yyyy, h:mm a")}),g&&e.jsx(v,{children:"•"})]}),g&&e.jsx(Z,{gap:"sm",className:et.statSegment,children:e.jsx(v,{ta:"right",children:i.send_to_text})})]}),z&&e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsxs(Z,{mt:I?8:10,gap:"lg",className:et.statusRow,children:[h&&(()=>{var J,ae;const R=i.error_details,W=`spaces.settings.broadcast.errors.${(R==null?void 0:R.category)||"unknown"}.title`,te=(J=R==null?void 0:R.attempts)!=null?J:0,A=(ae=R==null?void 0:R.max_attempts)!=null?ae:5;return e.jsx(Le,{label:e.jsxs(V,{children:[e.jsx(v,{size:"xs",fw:700,children:s(W)}),e.jsx(v,{size:"xs",mt:2,children:s("spaces.settings.broadcast.errors.attempts",{n:te,max:A})})]}),withArrow:!0,multiline:!0,width:240,position:"top",children:e.jsx(Se,{color:"red",style:{cursor:"help"},children:s("spaces.settings.broadcast.statuses.error")})})})(),j&&e.jsx(Se,{color:"green",children:s("spaces.settings.broadcast.statuses.sent")}),L&&e.jsx(Se,{color:"grape",children:s("spaces.settings.broadcast.statuses.scheduled")}),I&&e.jsx(Se,{color:"orange",children:s("spaces.settings.broadcast.statuses.draft")}),$&&e.jsx(Se,{color:"grape",children:s("spaces.settings.broadcast.statuses.procesing")}),E&&e.jsxs(Z,{gap:"xs",children:[e.jsx(Se,{color:"blue",children:s("spaces.settings.broadcast.statuses.sending")}),N>0&&e.jsx(v,{size:"xs",c:"dimmed",children:s("spaces.settings.broadcast.statuses.sending_progress",{enqueued:b!=null?b:0,total:N})})]}),P&&e.jsx(Se,{color:"gray",children:s("spaces.settings.broadcast.statuses.cancelled")}),_&&e.jsx(Le,{label:s("spaces.settings.broadcast.statuses.halted_hint"),withArrow:!0,multiline:!0,width:240,position:"top",children:e.jsx(Se,{color:"red",style:{cursor:"help"},children:s("spaces.settings.broadcast.statuses.halted")})}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(v,{size:"xs",c:"dimmed",children:[e.jsxs(v,{component:"span",fw:700,c:"dark",children:[Math.round(((B=i.analytics.unique_opened)!=null?B:i.analytics.total_opened)/i.analytics.total_recipients*100),"%"]})," ","opened"]}),e.jsxs(v,{size:"xs",c:"dimmed",children:[e.jsxs(v,{component:"span",fw:700,c:"dark",children:[Math.round(((y=i.analytics.unique_clicked)!=null?y:i.analytics.total_clicked)/i.analytics.total_recipients*100),"%"]})," ","clicked"]})]})]})})]})}const Xr="Add a mailing address to your footer before your next send — it's legally required and improves email deliverability.";function At({mailingAddress:t,onAdd:s}){return At.isVisible(t)?e.jsx(V,{mb:16,mt:10,children:e.jsxs(fs,{color:"orange",radius:"sm",styles:{root:{padding:"10px 14px"},message:{fontSize:13,display:"flex",justifyContent:"space-between",alignItems:"center",gap:12}},children:[e.jsx("span",{children:Xr}),s&&e.jsx(M,{onClick:s,size:"compact-xs",radius:"xl",color:"orange",variant:"filled",style:{flexShrink:0,fontSize:11},children:"Add address"})]})}):null}At.isVisible=t=>!t||!t.trim();function Qr(){const{t,i18n:s}=ne(),[l,n]=ei(),i=ee(O=>
2O.space),[o,d]=a.useState(!1),[r,m]=a.useState(!1),[c,u]=a.useState({total:0,page:1,pages:1,data:[]}),[p,f]=a.useState(null),[g,w]=a.useState(!1),[x,h]=a.useState(!1),[j,L]=a.useState("email"),[I,E]=a.useState(!1),[P,_]=a.useState(null),[$,z]=a.useState(!1),[N,b]=a.useState(0),[k,U]=a.useState(""),[H,D]=a.useState(!1),[T,B]=a.useState({active_total:0,spam_complaint:0}),y=Array.isArray(c==null?void 0:c.data)?[...c.data].sort((O,ce)=>O.is_processing&&!ce.is_processing?-1:!O.is_processing&&ce.is_processing?1:0):[],R=a.useCallback(()=>{const O=new URLSearchParams(l);O.delete("broadcast"),n(O,{replace:!0})},[l,n]),S=a.useCallback(O=>{O&&(f(O),O.is_sent?m(!0):(O.broadcast_type||"email")==="email"?E(!0):(L(O.broadcast_type||"email"),d(!0)))},[]);a.useEffect(()=>{i&&i.slug&&(A(),he.onFilterCount(i.slug,{target:["active"]},O=>_(O.send_cap||null),()=>{}),W(),te()),h(i&&i.permissions&&i.permissions.can_broadcast)},[i]),a.useEffect(()=>{!$&&(i!=null&&i.slug)&&(W(),te())},[$]);const W=()=>{i!=null&&i.slug&&he.onFetchSuppressions(i.slug,{per:1,page:1},O=>{O!=null&&O.counts&&B({active_total:O.counts.active_total||0,spam_complaint:O.counts.spam_complaint||0})},()=>{})},te=()=>{i!=null&&i.slug&&he.onFetchFooterSettings(i.slug,O=>{U((O==null?void 0:O.mailing_address)||""),D(!0)},()=>{})};a.useEffect(()=>{typeof window!="undefined"&&new URLSearchParams(window.location.search).get("footer")&&z(!0)},[]),a.useEffect(()=>{const O=l.get("broadcast");if(!O||!(i!=null&&i.slug))return;let ce=!1;return he.onFetchById(O,i.slug,me=>{ce||(S(me),R())},()=>{ce||R()}),()=>{ce=!0}},[R,S,l,i==null?void 0:i.slug]),a.useEffect(()=>{if(i&&o&&!x[0]){d(!1),w([!0,x[1],x[2]]);return}o||(f(null),A())},[o]),a.useEffect(()=>{r||f(null)},[r]),a.useEffect(()=>{I||f(null)},[I]),ya(i!=null&&i.slug?{channel:"BroadcastsChannel",space_slug:i.slug}:null,{received:O=>{O.action==="broadcast_sent"&&u(ce=>({...ce,data:(ce.data||[]).map(me=>me.id===O.broadcast_id?{...me,is_processing:!1,is_sent:!0,sent_on:O.sent_on}:me)}))}},[i==null?void 0:i.slug]);const A=()=>{he.onFetch(i.slug,{page:1,per:100},O=>{u(O)},O=>{})},J=()=>{u({data:[]}),f(null),A(),i!=null&&i.slug&&he.onFilterCount(i.slug,{target:["active"]},O=>_(O.send_cap||null),()=>{})},ae=()=>{b(O=>O+1),z(!0)},be=O=>{S(O)},Ee=O=>{f(null),L(O),d(!0)},F=Ds.isVisible(P,!0),q=H&&At.isVisible(k);return e.jsx(je,{style:{height:"100%",width:"100%"},children:e.jsxs($e,{pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceId:i.slug,spaceVersion:i.version,spaceName:i.name,title:t("spaces.settings.broadcast.title"),hideDivider:F||q,rightSide:e.jsxs(Z,{gap:8,wrap:"nowrap",children:[e.jsxs("button",{type:"button",className:Qt.suppressedButton,onClick:()=>z(!0),"aria-label":"Open broadcast settings",children:[e.jsx(C,{icon:Di.faGear,style:{fontSize:12}}),"Settings",T.active_total>0&&e.jsx("span",{className:`${Qt.suppressedCount} ${T.spam_complaint>0?Qt.suppressedCountAttention:""}`,title:`${T.active_total} suppressed`,children:T.active_total})]}),e.jsxs(Q,{transitionProps:{transition:"pop"},withArrow:!0,position:"bottom-end",children:[e.jsx(Q.Target,{children:e.jsx(M,{variant:"filled",radius:"xl",leftSection:e.jsx(C,{icon:ni.faPencil}),className:Wr.broadcastButton,children:t("spaces.settings.broadcast.broadcastButton")})}),e.jsxs(Q.Dropdown,{children:[e.jsx(Q.Item,{onClick:()=>{x&&!x[0]?w([!0,x[1],x[2]]):E(!0)},leftSection:e.jsx(C,{icon:ys.faEnvelope}),children:"Send email"}),e.jsx(Q.Item,{onClick:()=>Ee("message"),leftSection:e.jsx(C,{icon:fn.faComment}),children:"Send message"})]})]})]})}),q&&e.jsx(At,{mailingAddress:k,onAdd:()=>z(!0)}),e.jsx(Ds,{sendCap:P,warningOnly:!0}),y.map(O=>e.jsx(Zr,{onEdit:be,onUpdate:J,spaceId:i.slug,broadcast:O})),e.jsx(Sn,{opened:o,setOpened:d,broadcast:p,onUpdate:J,parentName:i.name,isTopLevel:i.is_top_level,isEmailReady:window.$fetchedTopSpace.is_email_ready,broadcastType:j}),e.jsx(ba,{opened:r,setOpened:m,broadcast:p}),e.jsx(Lt,{opened:I,setOpened:E,broadcast:p,onUpdate:J,parentName:i.name,isTopLevel:i.is_top_level,isEmailReady:window.$fetchedTopSpace.is_email_ready,onOpenSenderSettings:ae,onOpenFooterSettings:()=>z(!0)}),e.jsx(ja,{opened:$,setOpened:z,initialTab:"settings",emailSendersSetupSignal:N,onCountsChange:O=>B({active_total:O.active_total||0,spam_complaint:O.spam_complaint||0})}),e.jsx(ke,{opened:g,setOpened:w})]})})}const Vs={active:{label:"Active",className:"activeBadge"},pending:{label:"Pending DNS",className:"pendingBadge"},pending_dns:{label:"Pending DNS",className:"pendingBadge"},pending_verification:{label:"Verifying DNS",className:"pendingBadge"},ssl_pending:{label:"Pending SSL",className:"sslBadge"},pending_ssl:{label:"Pending SSL",className:"sslBadge"},failed:{label:"Failed",className:"failedBadge"},disabled:{label:"Disabled",className:"disabledBadge"}};function Jr(t){return String(t||"pending_dns").toLowerCase().replace(/-/g,"_")}
2function el(t){const s=String(t||"").split(".").filter(Boolean);return s.length<=2?s.join("."):s.slice(-2).join(".")}function us(t){return String(t||"").trim().replace(/^https?:\/\//i,"").replace(/\/.*$/,"").toLowerCase()}function Ms(t){if(!t)return null;const s=new Date(t);return Number.isNaN(s.getTime())?null:s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function zn(t){if(!t)return null;const s=new Date(t);if(Number.isNaN(s.getTime()))return null;const l=Math.max(0,Math.floor((Date.now()-s.getTime())/1e3));if(l<60)return`${l}s ago`;const n=Math.floor(l/60);if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function tl(t){return!!(Array.isArray(t)||t!=null&&t.custom_domains||t!=null&&t.domains||t!=null&&t.space_custom_domains||t!=null&&t.data)}function sl(t){return Array.isArray(t)?t:(t==null?void 0:t.custom_domains)||(t==null?void 0:t.domains)||(t==null?void 0:t.space_custom_domains)||(t==null?void 0:t.data)||[]}function nl(t,s){var i,o,d;const l=us(t.host||t.hostname||t.space_host||t.custom_host||t.name||t.domain),n=us(t.root_domain||t.registrable_domain||t.domain_root||((i=t.custom_domain)==null?void 0:i.domain)||t.custom_domain_domain||el(l));return{...t,id:t.id||t.space_custom_domain_id||l||s,host:l,root_domain:n,status:Jr(t.status||t.state),is_primary:!!(t.is_primary||t.primary||t.primary_domain),url:t.url||t.public_url||t.live_url||t.served_from_url,active_at:t.active_at||t.activated_at||t.verified_at,ssl_expires_at:t.ssl_expires_at||t.certificate_expires_at,last_checked_at:t.last_checked_at||t.checked_at,error_message:t.error_message||t.error||t.failure_message,dns_diagnostic:t.dns_diagnostic||t.dnsDiagnostic||((o=t.verification)==null?void 0:o.dns_diagnostic)||((d=t.verification)==null?void 0:d.dnsDiagnostic)||null}}function il(t,s){const l=Array.isArray(s==null?void 0:s.path)&&s.path.length>0?s.path[0]:null;return(t==null?void 0:t.top_level_space)||(t==null?void 0:t.top_level)||(t==null?void 0:t.root_space)||(t==null?void 0:t.network)||l||{name:s==null?void 0:s.name,slug:s==null?void 0:s.slug}}function al(t,s){var d,r,m,c,u;const l=sl(t).map((p,f)=>nl(p,f)),n=il(t,s),i=(m=(d=t==null?void 0:t.is_sub_space)!=null?d:t==null?void 0:t.is_descendant)!=null?m:(r=t==null?void 0:t.scope)==null?void 0:r.is_sub_space,o=typeof i=="boolean"?i:n!=null&&n.slug&&(s!=null&&s.slug)?n.slug!==s.slug:(s==null?void 0:s.is_top_level)===!1;return{domains:l,readOnly:!!(t!=null&&t.read_only||t!=null&&t.readOnly),topLevelSpace:n,servedFromUrl:(t==null?void 0:t.served_from_url)||(t==null?void 0:t.servedFromUrl)||((c=t==null?void 0:t.scope)==null?void 0:c.served_from_url)||((u=t==null?void 0:t.scope)==null?void 0:u.servedFromUrl)||null,customLinksAvailable:(t==null?void 0:t.custom_links_available)===!0,customLinksEnabled:(t==null?void 0:t.custom_links_enabled)===!0,customLinksHomeUrl:(t==null?void 0:t.custom_links_home_url)||null,isSubSpace:o,domainPermissions:Nn((t==null?void 0:t.domain_permissions)||(t==null?void 0:t.domainPermissions))}}function Nn(t){var s,l,n;return t?{allowed:t.allowed!==!1,reason:t.reason||null,message:t.message||null,premiumMessageKey:t.premium_message_key||t.premiumMessageKey||null,planTier:t.plan_tier||t.planTier||null,limit:(s=t.limit)!=null?s:null,used:(l=t.used)!=null?l:0,remaining:(n=t.remaining)!=null?n:null}:{allowed:!0}}function ns(t,s="Something went wrong. Please try again."){return t?Array.isArray(t.errors)&&t.errors.length>0?t.errors.join(", "):t.message||t.error||t.title||s:s}function ol(t){var s,l;return(t==null?void 0:t.premium_message_key)||(t==null?void 0:t.premiumMessageKey)||((s=t==null?void 0:t.domain_permissions)==null?void 0:s.premium_message_key)||((l=t==null?void 0:t.domainPermissions)==null?void 0:l.premiumMessageKey)||null}function On(t,s){if(t.url)return t.url;if(!t.host)return"";const l=(s==null?void 0:s.version)||"content";return`https://${t.host}/space/${s==null?void 0:s.slug}/${l}`}function rl({servedFromUrl:t,domains:s,space:l}){if(t)return t;const n=s.find(i=>i.is_primary&&i.status==="active")||s.find(i=>i.status==="active");return n?On(n,l):(l==null?void 0:l.shareble_link)||""}function ll(t){const s=zn(t.last_checked_at),l=s?`Last checked ${s}`:null;if(t.status==="active"){const n=[],i=Ms(t.active_at),o=Ms(t.ssl_expires_at);return i&&n.push(`Live since ${i}`),o&&n.push(`SSL valid through ${o}`),n.length>0?n.join(" - "):"Ready to use."}return t.status==="ssl_pending"||t.status==="pending_ssl"?l?`DNS verified, certificate provisioning. ${l}.`:"DNS verified, certificate provisioning.":wn(t)?l?`${Bs} ${l}.`:Bs:t.status==="pending_verification"?l?`DNS verification is running. ${l}.`:"DNS verification is running.":t.status==="failed"?t.error_message||"Verification failed. Check your DNS records and retry.":t.status==="disabled"?"This domain is disabled and will not route visitors.":l?`Awaiting DNS record. ${l}.`:"Add the DNS record below at your registrar. Usually live within 5-30 minutes."}function cl(t){const s=t.status,l=["ssl_pending","pending_ssl","active"].includes(s),n=s==="active",i=["pending","pending_dns","pending_verification","failed"].includes(s),o=["ssl_pending","pending_ssl"].includes(s);return[{label:"Domain added to Sutra",done:!0}
2,{label:"Add a DNS record at your registrar",description:wn(t)?"Sign in to wherever you bought this domain and add all records below, including the TXT record.":"Sign in to wherever you bought this domain and add the record below.",done:l,active:i},{label:"Wait for SSL certificate",description:"Once DNS is verified, Sutra issues a certificate automatically.",done:n,active:o}]}function dl({status:t}){const s=Vs[t]||Vs.pending_dns;return e.jsxs("span",{className:`${Y.badge} ${Y[s.className]}`,children:[e.jsx("span",{className:Y.badgeDot}),s.label]})}function ul(){return e.jsxs("span",{className:`${Y.badge} ${Y.primaryBadge}`,children:[e.jsx("span",{className:Y.badgeDot}),"Primary"]})}function ml({severity:t}){return t==="error"?e.jsx(C,{icon:vs.faTriangleExclamation}):t==="warning"?e.jsx(C,{icon:Bi.faCircleExclamation}):e.jsx(C,{icon:on.faCircleInfo})}function pl({diagnostic:t}){var l;if(!((l=t==null?void 0:t.findings)!=null&&l.length))return null;const s=n=>n==="error"?Y.dnsDiagnosticError:n==="warning"?Y.dnsDiagnosticWarning:Y.dnsDiagnosticInfo;return e.jsxs("div",{className:Y.dnsDiagnostic,children:[e.jsx("h5",{className:Y.dnsDiagnosticTitle,children:"DNS check"}),e.jsx("div",{className:Y.dnsDiagnosticFindings,children:t.findings.map((n,i)=>e.jsxs("div",{className:`${Y.dnsDiagnosticFinding} ${s(n.severity)}`,children:[e.jsx("div",{className:Y.dnsDiagnosticIcon,children:e.jsx(ml,{severity:n.severity})}),e.jsxs("div",{className:Y.dnsDiagnosticBody,children:[e.jsx("div",{children:n.message}),n.expected||n.actual?e.jsxs("div",{className:Y.dnsDiagnosticMeta,children:[n.expected?e.jsxs("span",{children:["Expected: ",n.expected]}):null,n.actual?e.jsxs("span",{children:["Current: ",n.actual]}):null]}):null]})]},`${n.host||"domain"}-${n.severity||"info"}-${i}`))})]})}function gl({text:t,label:s="Copy",onClick:l,compact:n=!1}){const[i,o]=a.useState(!1);return t?e.jsx(Le,{label:i?"Copied":s,withArrow:!0,position:"bottom",children:e.jsx(ft,{text:t,onCopy:()=>{o(!0),setTimeout(()=>o(!1),1600)},children:e.jsx(M,{variant:"outline",size:n?"xs":"sm",className:`${Y.button} ${Y.outlineButton}`,onClick:l,leftSection:e.jsx(C,{icon:i?ue.faCheck:Fi.faCopy}),children:s})})}):null}function hl({domain:t,readOnly:s,space:l,actionLoading:n,onCheck:i,onMakePrimary:o,onRemove:d,customLinksAvailable:r,customLinksEnabled:m,customLinksHomeUrl:c,topLevelSpace:u}){const p=!s&&["pending","pending_dns","failed"].includes(t.status),[f,g]=a.useState(p),w=m&&c?c:On(t,l),x=u!=null&&u.slug?js("main",{space:u.slug,ret:u.slug,section:"seo"}):null,h=va(t),j=wa(t),L=cl(t),I=t.status==="active",E=$=>n===`${$}:${t.id}`,P=!s,_=()=>{s||g($=>!$)};return e.jsxs("div",{className:`${Y.domain} ${f?Y.domainExpanded:""}`,children:[e.jsxs("div",{className:`${Y.domainHead} ${s?Y.domainHeadReadonly:""}`,onClick:_,children:[e.jsx("div",{className:Y.domainIcon,children:e.jsx(C,{icon:vn.faGlobe})}),e.jsxs("div",{className:Y.domainMeta,children:[e.jsxs("div",{className:Y.domainHost,children:[I&&w?e.jsx("a",{href:w,target:"_blank",rel:"noreferrer",onClick:$=>$.stopPropagation(),children:t.host}):e.jsx("span",{children:t.host}),t.is_primary?e.jsx(ul,{}):null]}),e.jsxs("div",{className:Y.domainStatusLine,children:[e.jsx(dl,{status:t.status}),e.jsx("span",{children:ll(t)})]})]}),e.jsxs("div",{className:Y.domainActions,children:[I&&w?e.jsx(gl,{text:w,label:"Copy URL",compact:!0,onClick:$=>$.stopPropagation()}):null,P&&!f&&!I?e.jsx(M,{variant:"outline",size:"xs",loading:E("check"),className:`${Y.button} ${Y.outlineButton}`,onClick:$=>{$.stopPropagation(),i(t)},leftSection:e.jsx(C,{icon:Fs.faRotateRight}),children:"Check status"}):null,s?null:e.jsx(C,{icon:xn.faChevronRight,className:`${Y.chevron} ${f?Y.chevronExpanded:""}`})]})]}),f?e.jsxs("div",{className:Y.domainBody,children:[e.jsxs("div",{className:Y.bodySection,children:[e.jsx("h4",{className:Y.sectionLabel,children:"Status"}),L.map(($,z)=>e.jsxs("div",{className:`${Y.step} ${$.done?Y.stepDone:""} ${$.active?Y.stepActive:""}`,children:[e.jsx("div",{className:Y.stepNum,children:$.done?e.jsx(C,{icon:ue.faCheck}):z+1}),e.jsxs("div",{children:[e.jsx("strong",{children:$.label}),$.description?e.jsx("div",{className:Y.stepDescription,children:$.description}):null]})]},$.label))]}),e.jsxs("div",{className:Y.bodySection,children:[e.jsx("h4",{className:Y.sectionLabel,children:"DNS Records"}),e.jsx(Sa,{records:h}),e.jsx(pl,{diagnostic:j})]}),t.error_message&&t.status==="failed"?e.jsx(fs,{color:"red",mb:"sm",icon:e.jsx(C,{icon:vs.faTriangleExclamation}),children:t.error_message}):null,P?e.jsxs("div",{className:Y.bodyActions,children:[e.jsx(M,{variant:"filled",size:"xs",loading:E("check"),className:`${Y.button} ${Y.primaryButton}`,onClick:()=>i(t),leftSection:e.jsx(C,{icon:Fs.faRotateRight}),children:"Check status"}),t.last_checked_at?e.jsxs(v,{size:"xs",c:"dimmed",children:["Last checked ",zn(t.last_checked_at)]}):null,e.jsxs("div",{className:Y.bodyActionsRight,children:[r&&x?e.jsx(M,{variant:"outline",size:"xs",className:`${Y.button} ${Y.outlineButton}`,onClick:()=>window.location.assign(x),children:m?"Manage page URLs":"Set up page URLs"}):null,I&&!t.is_primary?e.jsx(M,{variant:"outline",size:"xs",loading:E("primary"),className:`${Y.button} ${Y.outlineButton}`,onClick:()=>o(t),leftSection:e.jsx(C,{icon:nt.faStar}),children:"Make primary"}):null,e.jsx(M,{variant:"subtle",size:"xs",loading:E("remove"),className:`${Y.button} ${Y.subtleButton}`,onClick:()=>d(t),leftSection:e.jsx(C,{icon:jt.faTrash}),children:"Remove"})]})]}):null]}):null]})}function fl({opened:t,onClose:s,onSubmit:l,submitting:n}
2){const[i,o]=a.useState(""),[d,r]=a.useState(null);a.useEffect(()=>{t&&(o(""),r(null))},[t]);const m=c=>{c.preventDefault();const u=us(i);if(!u||u.includes(" ")||u.split(".").length<2){r("Enter a full web address, like yourdomain.com or learn.yourdomain.com.");return}l(u,r)};return e.jsx(is,{opened:t,onClose:n?()=>{}:s,title:e.jsx(v,{fw:700,children:"Add domain"}),centered:!0,children:e.jsxs("form",{onSubmit:m,children:[e.jsx(v,{className:Y.modalHint,children:"Enter the web address you want members to visit, such as yourdomain.com or learn.yourdomain.com. To add it, you must own the domain and be able to update its DNS records with the service where you bought it."}),e.jsx(Ue,{label:"Web address",placeholder:"learn.yourdomain.com",value:i,onChange:c=>{o(c.currentTarget.value),r(null)},error:d,disabled:n,autoFocus:!0}),e.jsxs(Z,{justify:"flex-end",mt:"lg",children:[e.jsx(M,{variant:"subtle",className:`${Y.button} ${Y.subtleButton}`,onClick:s,disabled:n,children:"Cancel"}),e.jsx(M,{type:"submit",loading:n,className:`${Y.button} ${Y.primaryButton}`,leftSection:e.jsx(C,{icon:He.faPlus}),children:"Add domain"})]})]})})}function xl(){const t=ee(y=>y.space),[s,l]=a.useState({loading:!0,error:null,domains:[],readOnly:!1,topLevelSpace:null,servedFromUrl:null,isSubSpace:!1,domainPermissions:{allowed:!0},customLinksAvailable:!1,customLinksEnabled:!1,customLinksHomeUrl:null}),[n,i]=a.useState(!1),[o,d]=a.useState(!1),[r,m]=a.useState(!1),[c,u]=a.useState(null),p=a.useCallback(y=>{l(R=>({...R,...al(y||{},t),loading:!1,error:null}))},[t]),f=a.useCallback(()=>{t!=null&&t.slug&&(l(y=>({...y,loading:!0,error:null})),Ae.onFetchCustomDomains(t.slug,p,y=>{l(R=>({...R,loading:!1,error:ns(y,"Could not load custom domains.")}))}))},[p,t==null?void 0:t.slug]);a.useEffect(()=>{f()},[f]);const g=y=>{tl(y)?p(y):f()},w=a.useCallback((y="can_add_custom_domain")=>{d([!0,y])},[]),x=y=>{const R=(y==null?void 0:y.domain_permissions)||(y==null?void 0:y.domainPermissions);R&&l(S=>({...S,domainPermissions:Nn(R)}))},h=(y,R)=>{m(!0),Ae.onCreateCustomDomain(t.slug,y,S=>{m(!1),i(!1),g(S),oe.fire("Domain added","Add the DNS record shown in Sutra to verify this domain.","success")},S=>{m(!1),x(S);const W=ol(S);if(W){i(!1),w(W);return}R(ns(S,"Could not add this domain."))})},j=(y,R,S,W)=>{u(`${y}:${R.id}`),S(t.slug,R.id,te=>{u(null),g(te),W&&oe.fire(W.title,W.message,"success")},te=>{u(null),oe.fire("Domain update failed",ns(te),"error")})},L=y=>{j("check",y,Ae.onCheckCustomDomain)},I=y=>{j("primary",y,Ae.onMakePrimaryCustomDomain,{title:"Primary domain updated",message:`${y.host} is now the primary custom domain.`})},E=y=>{oe.fire({title:"Remove this domain?",text:`${y.host} will stop routing to this Sutra space once it is removed.`,icon:"warning",showCancelButton:!0,confirmButtonText:"Remove domain",cancelButtonText:"Cancel",confirmButtonColor:"#c92a2a"}).then(R=>{R.isConfirmed&&j("remove",y,Ae.onRemoveCustomDomain,{title:"Domain removed",message:`${y.host} is no longer connected.`})})},{domains:P,readOnly:_,topLevelSpace:$,servedFromUrl:z,isSubSpace:N,domainPermissions:b,customLinksAvailable:k,customLinksEnabled:U,customLinksHomeUrl:H}=s,D=($==null?void 0:$.name)||(t==null?void 0:t.name)||"this space network",T=a.useMemo(()=>rl({servedFromUrl:z,domains:P,space:t}),[P,z,t]),B=e.jsx(M,{variant:"filled",radius:"xl",disabled:_||s.loading,className:Y.domainButton,onClick:()=>{if((b==null?void 0:b.allowed)===!1){if(b.reason==="custom_limit_reached"){oe.fire("Custom domain limit reached",b.message,"info");return}w(b.premiumMessageKey||"can_add_custom_domain");return}i(!0)},leftSection:e.jsx(C,{icon:He.faPlus}),children:"Add domain"});return e.jsx(je,{style:{height:"100%",width:"100%"},children:e.jsxs($e,{pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceId:t.slug,spaceVersion:t.version,spaceName:t.name,title:"Domains",rightSide:B}),s.loading?e.jsxs(V,{children:[e.jsx(gt,{height:42,width:"45%",mb:"md"}),e.jsx(gt,{height:76,mb:"sm"}),e.jsx(gt,{height:76,mb:"sm"})]}):s.error?e.jsxs(fs,{color:"red",icon:e.jsx(C,{icon:vs.faTriangleExclamation}),title:"Could not load domains",children:[e.jsx(v,{mb:"sm",children:s.error}),e.jsx(M,{size:"xs",className:`${Y.button} ${Y.outlineButton}`,onClick:f,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[N?e.jsxs("div",{className:Y.scopeBanner,children:[e.jsx("div",{className:Y.bannerIcon,children:e.jsx(C,{icon:on.faCircleInfo})}),e.jsxs("div",{className:Y.bannerBody,children:["Domain settings apply to your entire space network. This space is part of"," ",e.jsx("strong",{children:D}),T?e.jsxs(e.Fragment,{children:[" ","and is served at ",e.jsx("code",{className:Y.bannerCode,children:T}),"."]}):"."]})]}):null,_?e.jsxs("div",{className:Y.permissionBanner,children:[e.jsx("div",{className:Y.bannerIcon,children:e.jsx(C,{icon:ma.faLock})}),e.jsxs("div",{className:Y.bannerBody,children:[e.jsx("strong",{children:"You can view but not edit these settings."}),e.jsx("br",{}),"Only managers of ",e.jsx("strong",{children:D})," can add, change, or remove custom domains. Ask a top-level manager if you need a change here."]})]}):null,P.length===0?e.jsxs("div",{className:Y.empty,children:[e.jsx("div",{className:Y.emptyIcon,
2children:e.jsx(C,{icon:vn.faGlobe})}),e.jsx(Xn,{order:3,size:"h4",mb:6,children:"Connect your domain"}),e.jsx(v,{className:Y.emptyText,children:"Connect a custom domain so members can visit this space at a website address of your choice."})]}):e.jsx("div",{className:Y.domains,children:P.map(y=>e.jsx(hl,{domain:y,readOnly:_,space:t,actionLoading:c,onCheck:L,onMakePrimary:I,onRemove:E,customLinksAvailable:k,customLinksEnabled:U,customLinksHomeUrl:H,topLevelSpace:$},y.id))})]}),e.jsx(fl,{opened:n,onClose:()=>i(!1),onSubmit:h,submitting:r}),e.jsx(ke,{opened:o,setOpened:d})]})})}function bl(){const{t}=ne(),s=ee(l=>l.space);return e.jsx($e,{pt:20,pb:40,pl:40,pr:40,children:e.jsx(ze,{spaceName:s.name,spaceId:s.slug,spaceVersion:s.version,title:t("spaces.settings.sutraAdmin.title")})})}const Hs={per:10,page:1},Dt=[];function Ln(t){const{t:s,i18n:l}=ne();zt(),bt();const n=a.useRef(!1),[i,o]=a.useState([]),[d,r]=a.useState(!1),[m,c]=a.useState(!0),u=a.useRef();a.useEffect(()=>{!n.current&&t.spaceId&&(n.current=!0,p())},[t]);const p=()=>{r(!0),pe.onFetchChildren(t.spaceId,["members"],Hs,[t.scope],h=>{o(h.data)},h=>{r(!1)})},f=h=>{const j=u.current;if(g(),h.y+j.clientHeight>=j.scrollHeight-50){console.log("On bottom");const L=setTimeout(()=>{console.log("On bottom timer"),w()},1e3);Dt.push(L)}else if(h.y==0){const L=setTimeout(()=>{},1e3);Dt.push(L)}},g=()=>{for(let h=0;h<Dt.length;h++){const j=Dt[h];clearTimeout(j)}},w=()=>{d||(Hs.page++,p())},x=()=>{const h=t.scope?t.scope:"top";if(h=="top")return s("home.spacesList.topTitle");if(h=="managed")return s("home.spacesList.managedTitle");if(h=="pending")return s("home.spacesList.managedTitle");if(h=="all")return s("home.spacesList.allTitle");if(h=="direct")return s("home.spacesList.directMessagesTitle");if(h=="archived")return s("home.spacesList.archivedTitle");if(h=="deleted")return s("home.spacesList.deletedTitle");if(h=="invitations")return s("home.spacesList.invitations")};return e.jsxs(je,{style:{height:"100%"},onScrollPositionChange:f,viewportRef:u,children:[i.map(h=>e.jsx(V,{style:{margin:"15px 0px"},children:e.jsx(Ca,{space:h},`space-list-item-${h.slug}`)})),i.length==0&&!d?e.jsxs(V,{mt:30,style:{backgroundColor:"var(--mantine-color-gray-0)",textAlign:"center",padding:"var(--mantine-spacing-xl)",borderRadius:"var(--mantine-radius-md)"},children:["You don't have any ",e.jsx("b",{children:x().toLowerCase()})]}):"",t.addMargin&&e.jsx(V,{mb:300})]})}function jl(){const{t}=ne(),s=ee(l=>l.space);return e.jsxs($e,{pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceId:s.slug,spaceVersion:s.version,spaceName:s.name,title:t("spaces.settings.scheduled.title")}),e.jsx(Ln,{spaceId:s.slug,scope:"pending"})]})}function _l(){const{t}=ne(),s=ee(l=>l.space);return e.jsxs($e,{pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceName:s.name,spaceId:s.slug,spaceVersion:s.version,title:t("spaces.settings.archived.title")}),e.jsx(Ln,{spaceId:s.slug,scope:"archived",addMargin:!0})]})}const yl=[!1,"can_export_participation_data"];function Sl(t){return Array.isArray(t)?!!t[0]:typeof t=="boolean"?t:null}function vl(){var $,z,N;const{t}=ne(),s=ee(b=>b.space),l=ee(b=>b.user),n=we(),[i,o]=a.useState(!1),[d,r]=a.useState(!1),[m,c]=a.useState(null),[u,p]=a.useState({}),[f,g]=a.useState(null),[w,x]=a.useState(!1),h=(($=s==null?void 0:s.permissions)==null?void 0:$.can_see_participation_tab)||[],j=(b={})=>{if(!(!s||!s.slug||d)){r(!0),c(null);try{Ia.onDownloadAdvancedExport(s.slug,{...u,...b}),c({kind:"ok",title:"Export started",message:"Your participation report XLS download should start shortly."}),x(!1)}catch{c({kind:"error",title:"Export failed",message:"Please try again in a moment."})}finally{setTimeout(()=>r(!1),3e3),setTimeout(()=>c(null),8e3)}}},L=a.useCallback(b=>{const k=Array.isArray(b)?b:[!1,"can_use_advanced_participation_analytics"];o([!0,k[1]||"can_use_advanced_participation_analytics",k[2]])},[]),I=Sl((z=s==null?void 0:s.permissions)==null?void 0:z.can_use_advanced_participation_analytics),E=Array.isArray((N=s==null?void 0:s.permissions)==null?void 0:N.top_account_type)?s.permissions.top_account_type:[],P=I!==null?I:!!(l!=null&&l.is_admin||l!=null&&l.is_organization||Ea(E)),_=()=>{if(!P){L(yl);return}x(!0)};return h[0]?e.jsxs(je,{style:{height:"100%"},children:[e.jsxs($e,{style:{marginBottom:"50px"},pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceId:s.slug,spaceVersion:s.version,spaceName:s.name,title:t("spaces.settings.layout.navbarContent.participation"),rightSide:e.jsx(Z,{gap:8,children:e.jsx(M,{variant:"filled",radius:"xl",leftSection:e.jsx(C,{icon:_a.faFileExport}),loading:d,onClick:_,className:Ta.exportButton,children:"Export"})})}),m&&e.jsx(Qn,{color:m.kind==="error"?"red":"blue",title:m.title,onClose:()=>c(null),mb:16,children:m.message}),e.jsx(ge,{withCssVariables:!1,theme:{primaryShade:6},children:e.jsx(Da,{theme:n,onExportParamsChange:p,onExportContextChange:g,onOpenPremium:L})})]}),e.jsx(ke,{opened:i,setOpened:o}),e.jsx(ka,{opened:w,onClose:()=>x(!1),onExport:j,exportBusy:d,exportContext:f})]}):e.jsx(Fa,{opened:[!0,h[1],h[2]]})}function wl({onUpdate:t=()=>{}}){var P,_,$,z,N,b,k,U;const s=ee(H=>H.space),l=(s==null?void 0:s.is_top_level)!==!1,n=(_=(P=s==null?void 0:s.settings)==null?void 0:P.members_map_interests_enabled)!=null?_:s==null?void 0:s.members_map_interests_enabled,i=(z=($=s==null?void 0:s.settings)==null?void 0:$.cobolt_indexing_excluded)!=null?z:s==null?void 0:s.cobolt_indexing_excluded,o=(b=(N=s==null?void 0:s.settings)==null?void 0:N.members_map_show_ai_interests)!=null?b:s==null?void 0:s.members_map_show_ai_interests,d=(U=(k=s==null?void 0:s.settings)==null?void 0:k.cobolt_interest_auto_update)!=null?U:s==null?void 0:s.cobolt_interest_auto_update,[r,m]=a.useState(!0),[c,u]=a.useState(i===!0),[p,f]=a.useState(n!==!1),[g,w]=a.useState(o!==!1),[x,h]=a.use
2State(d!==!1);a.useEffect(()=>{u(i===!0)},[i]),a.useEffect(()=>{f(n!==!1)},[n]),a.useEffect(()=>{w(o!==!1)},[o]),a.useEffect(()=>{h(d!==!1)},[d]);const j=H=>{var B;const D=c;u(H);const T=t({pod_settings_attributes:{cobolt_indexing_excluded:H}});(B=T==null?void 0:T.catch)==null||B.call(T,()=>u(D))},L=H=>{var B;const D=p;f(H);const T=t({pod_settings_attributes:{members_map_interests_enabled:H}});(B=T==null?void 0:T.catch)==null||B.call(T,()=>f(D))},I=H=>{var B;const D=g;w(H);const T=t({pod_settings_attributes:{members_map_show_ai_interests:H}});(B=T==null?void 0:T.catch)==null||B.call(T,()=>w(D))},E=H=>{var B;const D=x;h(H);const T=t({pod_settings_attributes:{cobolt_interest_auto_update:H}});(B=T==null?void 0:T.catch)==null||B.call(T,()=>h(D))};return e.jsxs(V,{children:[e.jsx(V,{style:{paddingBottom:20,marginBottom:20,borderBottom:"1px solid #E9ECEF"},children:e.jsxs(Z,{justify:"space-between",wrap:"nowrap",gap:"xl",children:[e.jsxs(V,{children:[e.jsx(v,{style:{fontSize:16,fontWeight:500,color:"#1F2937"},children:"Exclude from Cobolt indexing"}),e.jsx(v,{style:{fontSize:14,color:"#6B7280",lineHeight:1.5},children:"Prevent Cobolt from indexing this space. When turned on, this setting is also turned on for all subspaces."})]}),e.jsx(Ze,{"aria-label":"Exclude from Cobolt indexing",checked:c,onChange:H=>j(H.currentTarget.checked),onLabel:"ON",offLabel:"OFF",classNames:{root:wt.switch},size:"lg"})]})}),e.jsxs(V,{style:{paddingBottom:16,marginBottom:2,borderBottom:"1px solid #E9ECEF"},children:[l&&e.jsxs(Z,{justify:"space-between",wrap:"nowrap",gap:"xl",children:[e.jsxs(V,{children:[e.jsx(v,{style:{fontSize:16,fontWeight:500,color:"#1F2937"},children:"Interests"}),e.jsx(v,{style:{fontSize:14,color:"#6B7280",lineHeight:1.5},children:"Show the interests panel in the Members Map and manage the interests Cobolt has discovered in this space. When off, the Map tab still shows, just without the panel."})]}),e.jsx(Ze,{"aria-label":"Show interests panel",checked:p,onChange:H=>L(H.currentTarget.checked),onLabel:"ON",offLabel:"OFF",classNames:{root:wt.switch},size:"lg"})]}),l&&p&&e.jsxs(Z,{justify:"space-between",wrap:"nowrap",gap:"xl",mt:16,children:[e.jsxs(V,{children:[e.jsx(v,{style:{fontSize:16,fontWeight:500,color:"#1F2937"},children:"Include Cobolt-discovered interests"}),e.jsx(v,{style:{fontSize:14,color:"#6B7280",lineHeight:1.5},children:"Show the interests Cobolt finds alongside the ones you add. The interests you add always show."})]}),e.jsx(Ze,{"aria-label":"Include Cobolt-discovered interests",checked:g,onChange:H=>I(H.currentTarget.checked),onLabel:"ON",offLabel:"OFF",classNames:{root:wt.switch},size:"lg"})]}),l&&p&&e.jsxs(Z,{justify:"space-between",wrap:"nowrap",gap:"xl",mt:16,children:[e.jsxs(V,{children:[e.jsx(v,{style:{fontSize:16,fontWeight:500,color:"#1F2937"},children:"Auto-update interests daily"}),e.jsx(v,{style:{fontSize:14,color:"#6B7280",lineHeight:1.5},children:"Refresh discovered interests automatically as new contributions come in. Runs at most once a day, and only when there is new activity. The Generate interests button always works."})]}),e.jsx(Ze,{"aria-label":"Auto-update interests daily",checked:x,onChange:H=>E(H.currentTarget.checked),onLabel:"ON",offLabel:"OFF",classNames:{root:wt.switch},size:"lg"})]}),(!l||p)&&e.jsxs(V,{style:{border:"1px solid #E5E7EB",borderRadius:8,overflow:"hidden",marginTop:16},children:[e.jsxs(Ws,{onClick:()=>m(H=>!H),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"10px 14px",backgroundColor:r?"#F9FAFB":"transparent"},children:[e.jsx(v,{style:{fontSize:14,fontWeight:500,color:"#1F2937"},children:"Manage interests"}),r?e.jsx(C,{icon:$i.faChevronDown,size:"xs",color:"#9CA3AF"}):e.jsx(C,{icon:xn.faChevronRight,size:"xs",color:"#9CA3AF"})]}),e.jsx(Jn,{expanded:r,children:e.jsxs(V,{style:{padding:"8px 14px 14px"},children:[e.jsx(v,{style:{fontSize:12,color:"#9CA3AF",marginBottom:12,lineHeight:1.5},children:"Add your own interests to steer what Cobolt looks for, and manage the ones it discovers from what your members have written. Your edits stay in place across re-clustering."}),e.jsx(Ba,{})]})})]})]})]})}function Cl(){const t=bt(),s=ee(o=>o.space),l=ee(o=>o.user),n=Pe();if(!xs({user:l}))return null;const i=o=>!o||Object.keys(o).length===0?Promise.resolve(null):new Promise((d,r)=>{Ae.onUpdate(t.slug||s.slug,o,m=>{const c=o.pod_settings_attributes||{};c&&Object.keys(c).length>0&&n(st({...s,...c,settings:{...(s==null?void 0:s.settings)||{},...c}})),d(m)},m=>r(m))});return e.jsx(je,{style:{height:"100%"},children:e.jsxs($e,{pt:20,pb:40,pl:40,pr:40,children:[e.jsx(ze,{spaceName:s.name,spaceId:s.slug,spaceVersion:s.version,title:"Cobolt AI"}
2),e.jsx(wl,{onUpdate:i})]})})}const Tl={members:"manage.people.opened",automation:"manage.automations.opened",broadcast:"manage.broadcasts.opened",surveys:"manage.surveys.opened",participation:"manage.engagement.opened",domains:"manage.domains.opened",cobolt:"manage.cobolt_ai.opened"};function kl(){const t=ee(d=>d.space),s=ee(d=>d.user),l=xt(),n=zt(),i=a.useRef(null),o=(l.pathname.split("/settings/")[1]||"").split("/")[0];return a.useEffect(()=>{if(!(t!=null&&t.slug)||!o||!Cn.includes(o))return;const d=Tn({space:t,user:s});d.length&&!d.includes(o)&&n(`/space/${t.slug}/settings/${d[0]}`,{replace:!0})},[t==null?void 0:t.slug,o,s]),a.useEffect(()=>{const d=Tl[o];if(!d||!(s!=null&&s.id)){i.current=null;return}i.current!==o&&(i.current=o,as.record(d,{properties:{section:o,...t!=null&&t.slug?{selected_space_slug:t.slug}:{}},context:{path:l.pathname}}).catch(()=>{}))},[o,s==null?void 0:s.id,t==null?void 0:t.slug,l.pathname]),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column"},children:[e.jsx(oi,{}),e.jsx("div",{style:{flex:1,minHeight:0},children:e.jsxs(ti,{children:[e.jsx(De,{path:"overview",element:e.jsx(Oa,{})}),e.jsx(De,{path:"main",element:e.jsx(Bo,{})}),e.jsx(De,{path:"automation",element:e.jsx(pr,{})}),e.jsx(De,{path:"domains",element:e.jsx(xl,{})}),e.jsx(De,{path:"members",element:e.jsx(Mr,{})}),e.jsx(De,{path:"broadcast",element:e.jsx(Qr,{})}),e.jsx(De,{path:"surveys",element:e.jsx(ui,{})}),e.jsx(De,{path:"admin",element:e.jsx(bl,{})}),e.jsx(De,{path:"scheduled",element:e.jsx(jl,{})}),e.jsx(De,{path:"archived",element:e.jsx(_l,{})}),e.jsx(De,{path:"participation",element:e.jsx(vl,{})}),e.jsx(De,{path:"cobolt",element:e.jsx(Cl,{})})]})})]})}const El=t=>({container:{display:"flex",flexFlow:"row",height:"100%"},sidebar:{width:"230px",boxSizing:"border-box",overflow:"hidden",backgroundColor:t.colors.gray[7]}});function Il(){const t=a.useRef(),s=we(),l=El(s),n=Pe();return a.useEffect(()=>(n(yt({hidden:!1})),n(St({hidden:!1})),t.current=setTimeout(()=>{t.current=null,n(yt({hidden:!1})),n(St({hidden:!1}))},1e3),()=>{t.current&&clearTimeout(t.current),window.$hiddenLayoutElements?(n(yt({hidden:window.$hiddenLayoutElements.indexOf("sidebar")>=0})),n(St({hidden:window.$hiddenLayoutElements.indexOf("header")>=0}))):(n(yt({hidden:!1})),n(St({hidden:!1}))),localStorage.removeItem("lastOpenedSettingsTabs")}),[]),e.jsxs("div",{style:l.container,children:[e.jsx("div",{style:l.sidebar,children:e.jsx(Na,{})}),e.jsx(kl,{})]})}function Cd(){const t=bt(),s=xt(),l=t.slug||(s.pathname.match(/^\/space\/([^/]+)\/settings(?:\/|$)/)||[])[1],n=(s.pathname.split("/settings/")[1]||"").split("/")[0],i=mi({slug:l,section:n,search:s.search,hash:s.hash});return i?e.jsx(si,{to:i,replace:!0}):e.jsx(Il,{})}export{Cd as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.