1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3510],{33510:function(e,a,i){i.r(a);var l=i(26705),r=i(84639),s=i(52679),t=i(37948),o=i(61718),n=i(69571),c=i(62812),d=i(69845),u=i(20718),v=i(2913),f=i(29420),p=i(4043),m=i(67972),h=i(28956),g=i(74530),x=i(5589),b=i(20955),y=i(14059),j=i(70782),w=i(21525),C=i(71424),P=i(36662),N=i(61374),S=i(97018);a.default=e=>{let{isOpen:a,profiles:i,title:k="Profiles",onClose:A}=e,[z,M]=(0,b.useState)(null),{switchProfile:T}=(0,w.a)(),{user:E}=(0,P.B)(),U=j.S.useUtils(),[O,Z]=(0,b.useState)(!1),R=(0,N.Kw)(e=>e.globalModel.hasUnsavedChanges),{triggerNavigationAttempt:D}=(0,S.U)({enabled:R,onNavigate:async()=>!0}),F=j.S.profile.selectProfile.useMutation({onSuccess:e=>{T(e.token),U.profile.getActiveProfile.invalidate(),Z(!1),A()},onError:()=>{C.Am.error("Failed to change profile"),Z(!1)}}),I=e=>{O||M(e)},K=e=>{O||(D(),Z(!0),F.mutate({profileId:e.id,workspaceId:e.workspaceId}))},B=()=>{z&&!O&&K(z)},L=()=>{O||A()},W=e=>{switch(e){case y.AccountType.CREATOR:return(0,l.jsx)(r.e,{content:"Creator",children:(0,l.jsx)(p.Z,{size:14})});case y.AccountType.GUEST:return(0,l.jsx)(r.e,{content:"Guest",children:(0,l.jsx)(m.Z,{size:14})});default:return(0,l.jsx)(h.Z,{size:14})}};return(0,l.jsx)(s.R,{isOpen:a,onClose:L,size:"lg",scrollBehavior:"inside",isDismissable:!O,isKeyboardDismissDisabled:O,classNames:{header:"border-b border-default",footer:"border-t border-default"},children:(0,l.jsx)(t.A,{children:()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.k,{className:"flex flex-col gap-1",children:[R?"This action will cause losing of unsaved changes":"",k," (",i.length,")",O&&(0,l.jsx)("div",{className:"text-sm text-default-400",children:"Switching profile..."})]}),(0,l.jsx)(n.I,{className:"py-2",children:(0,l.jsx)(c.o,{className:"w-full",style:{maxHeight:"".concat(360,"px")},hideScrollBar:!0,children:(0,l.jsx)("div",{className:"flex flex-col gap-2",children:i.length>0?i.map(e=>{var a;let i=e.id===(null==E?void 0:E.activeProfile.id);return(0,l.jsxs)("div",{className:"flex items-center p-3 rounded-lg ".concat(O||i?"cursor-not-allowed":"cursor-pointer"," transition-colors ").concat(i?"":(null==z?void 0:z.id)===e.id?"bg-primary/20 border border-primary/40":"hover:bg-primary/10"),onClick:O||i?void 0:()=>I(e),children:[(0,l.jsx)(d.z,{name:(0,l.jsxs)("p",{className:"flex gap-2 items-center",children:[e.name," ",W(e.accountType)]}),description:e.username?"@".concat(e.username):"No username",avatarProps:{src:e.avatar||void 0,showFallback:!0,fallback:(null===(a=e.name)||void 0===a?void 0:a[0])||"?",className:"".concat((null==z?void 0:z.id)===e.id?"bg-primary/40 text-primary":"bg-primary/20 text-primary")},classNames:{description:"text-default-800"}}),(0,l.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[i&&(0,l.jsx)(u.z,{className:"pl-2",startContent:(0,l.jsx)(g.Z,{size:14}),variant:"flat",color:"success",size:"sm",children:"Active"}),e.isPubliclyVisible?(0,l.jsx)(u.z,{className:"pl-2",startContent:(0,l.jsx)(h.Z,{size:14}),variant:"flat",color:"primary",size:"sm",children:"Public"}):(0,l.jsx)(u.z,{className:"pl-2",startContent:(0,l.jsx)(x.Z,{size:14}),variant:"flat",color:"warning",size:"sm",children:"Private"})]})]},e.id)}):(0,l.jsx)("div",{className:"py-8 text-center text-zinc-500",children:"No profiles available"})})})}),(0,l.jsxs)(v.R,{children:[(0,l.jsx)(f.A,{color:"default",variant:"light",onPress:L,isDisabled:O,children:"Close"}),z&&(0,l.jsx)(f.A,{color:"primary",onPress:B,isLoading:O,isDisabled:O,children:"Switch"})]})]})})})}},97018:function(e,a,i){i.d(a,{U:function(){return t},w:function(){return o}});var l=i(61374),r=i(20955),s=i(96396);function t(e){let{onConfirm:a}=e,i=(0,l.WX)(e=>e.globalModel.setHasUnsavedChanges),t=(0,l.WX)(e=>e.globalModel.setOnConfirmNavigation);(0,r.useEffect)(()=>{if(t)return t(a),()=>t(null)},[a,t]);let o=(0,r.useCallback)(()=>l.ZP.getState().globalModel.hasUnsavedChanges,[]);(0,s.Ox)({enabled:o,confirm:async()=>{let e=l.ZP.getState().globalModel.hasUnsavedChanges;if(!e)return!0;let r=await a();return r&&i(!1),r}})}function o(){let e=(0,l.Kw)(e=>e.globalModel.hasUnsavedChanges),a=(0,l.Kw)(e=>e.globalModel.onConfirmNavigation),i=(0,l.WX)(e=>e.globalModel.setHasUnsavedChanges);return async l=>{if(!e)return l&&await l(),!0;if(!a)return!1;let r=await a();return!!r&&(i(!1),l&&await l(),!0)}}},36662:function(e,a,i){i.d(a,{B:function(){return u}});var l=i(61374),r=i(21525),s=i(70782),t=i(80045),o=i(14059),n=i(20955),c=i(71424),d=i(65496);let u=e=>{var a;let i=s.S.useUtils(),u=(0,l.Kw)(e=>e.auth.profileToken),{switchProfile:v}=(0,r.a)(),{data:f,isLoading:p,isError:m,error:h}=s.S.me.useQuery(void 0,{enabled:!!u}),g=s.S.profile.getOrCreateCreatorProfile.useQuery({profileId:f&&f.accountType===o.AccountType.CREATOR?f.activeProfile.id:void 0},{enabled:!!(null==f?void 0:null===(a=f.activeProfile)||void 0===a?void 0:a.id)&&!!u&&!p&&(null==f?void 0:f.accountType)===o.AccountType.CREATOR}),{data:x,isLoading:b,isError:y}=s.S.workspace.getCurrentWorkspace.useQuery(void 0,{enabled:!!f}),j=s.S.profile.selectProfile.useMutation({onSuccess:e=>
1{v(e.token),i.profile.getActiveProfile.invalidate()},onError:()=>{c.Am.error("Failed to change profile")},onSettled:(e,a,i)=>{if(i.skipMainOnboarding){let e=new d.Z;e.remove(t.PD,{path:"/"})}}}),w=(0,n.useMemo)(()=>x?x.profiles:void 0,[x]),C=(0,n.useMemo)(()=>{var e;if(w&&!p&&(null==f?void 0:null===(e=f.activeProfile)||void 0===e?void 0:e.id))return null==w?void 0:w.filter(e=>{var a;return e.id!==(null==f?void 0:null===(a=f.activeProfile)||void 0===a?void 0:a.id)})},[w,f,p]),P=(0,n.useCallback)(()=>(i.profile.getActiveProfile.invalidate(),i.me.invalidate()),[i]),N=s.S.updateProfile.useMutation({onSuccess:async()=>{await i.me.invalidate(),await i.profile.invalidate(),(null==e?void 0:e.hideToastOnProfileUpdateSuccess)||c.Am.success("Saved successfully")},onError(a){var i;let l=null==a?void 0:null===(i=a.shape)||void 0===i?void 0:i.message;(null==e?void 0:e.hideToastOnProfileUpdateError)||c.Am.error(l||"Failed to update profile")}}),S=!!u&&(p||b),k=m||y;return(0,n.useMemo)(()=>({user:f,creatorProfile:g,workspaceProfiles:w,currentWorkspace:x,isLoading:S,isError:k,error:h,updateProfileMutation:N,refetchUser:P,changeProfileMutation:j,allProfilesWithoutSelected:C}),[f,g,w,x,S,k,h,N,P,j,C])}}}]);
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.