'use client';
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),T=require("react"),y=require("@heroui/react"),x=require("@heroicons/react/24/outline"),N=require("./sign-up-modal.cjs"),G=require("../../../hooks/use-auth.cjs"),H=require("../../../hooks/use-config.cjs");function J({children:h,variant:U="solid",color:d="primary",size:l="md",fullWidth:j=!1,startContent:w,endContent:b,className:f="",modalMode:t=!1,modalProps:q={},href:u="/auth/sign-up",onClick:r,onSuccess:p,onError:B,disabled:i=!1,loading:o=!1,showAuthenticatedState:C=!0,iconOnly:e=!1,redirectAfterSignUp:n,autoRedirect:a=!0}){const{isSignedIn:P,user:g,isLoading:c}=G.useAuth(),{components:D,features:L}=H.useConfig(),{isOpen:$,open:S,close:v}=N.useSignUpModal(),I=D.SignUpButton;if(I)return s.jsx(I,{children:h,variant:U,color:d,size:l,fullWidth:j,startContent:w,endContent:b,className:f,modalMode:t,modalProps:q,href:u,onClick:r,onSuccess:p,onError:B,disabled:i,loading:o,showAuthenticatedState:C,iconOnly:e,redirectAfterSignUp:n,autoRedirect:a});if(!L.signUp)return null;const F=T.useCallback(m=>{if(p?.(m),a&&n)setTimeout(()=>{window.location.href=n},1e3);else if(a&&m.user){const k=m.user.userType||"external",E={internal:"/admin/dashboard",external:"/dashboard",end_user:"/app"}[k]||"/dashboard";setTimeout(()=>{window.location.href=E},1e3)}},[p,a,n]),M=T.useCallback(()=>{if(!(i||o||c)){if(r){r();return}if(t){S();return}u&&(window.location.href=u)}},[i,o,c,r,t,S,u]);if(C&&P&&g)return s.jsx(y.Button,{variant:"light",size:l,className:`${f} text-success-600`,startContent:s.jsx(x.UserIcon,{className:"w-4 h-4"}),isDisabled:!0,children:e?null:`Welcome, ${g.firstName||g.primaryEmailAddress||"User"}`});const R=w||(e?s.jsx(x.UserPlusIcon,{className:"w-4 h-4"}):s.jsx(x.UserPlusIcon,{className:"w-4 h-4"})),_=h||(e?null:"Sign Up");return s.jsxs(s.Fragment,{children:[s.jsx(y.Button,{variant:U,color:d,size:l,fullWidth:j,startContent:R,endContent:b,className:f,onPress:M,isDisabled:i||c,isLoading:o||c,isIconOnly:e,children:_}),t&&s.jsx(N.SignUpModal,{isOpen:$,onClose:v,onSuccess:F,onError:B,redirectUrl:n,...q})]})}exports.SignUpButton=J;
//# sourceMappingURL=sign-up-button.cjs.map
