(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,50929,e=>{"use strict";var t=e.i(113919);e.s(["Tooltip",()=>t.default])},144232,e=>{"use strict";var t=e.i(843476),r=e.i(335590);function s(e){let{className:s,...a}=e;return(0,t.jsx)("label",{className:(0,r.default)("text-default text-emphasis mb-2 block text-sm font-medium leading-none",s),...a,children:e.children})}e.s(["Label",()=>s])},973895,562187,e=>{"use strict";var t=e.i(843476),r=e.i(210850),s=e.i(271645),a=e.i(12346),n=e.i(335590),i=e.i(941739),l=e.i(653145);let o=({message:e})=>(0,t.jsxs)("div",{"data-testid":"field-error",className:"text-error mt-2 flex items-center gap-x-2 text-sm",children:[(0,t.jsx)("div",{children:(0,t.jsx)(i.Icon,{name:"info",className:"h-3 w-3"})}),(0,t.jsx)("p",{children:e})]});function c({hintErrors:e,fieldName:r,t:s}){let a=(0,l.useFormContext)();if(!a)return null;let{formState:n}=a,c=n.errors[r];return e||!c||c.message?e&&c?(0,t.jsx)("div",{className:"text-gray text-default mt-2 flex items-center text-sm",children:(0,t.jsx)("ul",{className:"ml-2",children:e.map(e=>{let a=n.isSubmitted,l=c[e]||c.message;return(0,t.jsxs)("li",{"data-testid":"hint-error",className:void 0!==l?a?"text-error":"":"text-green-600",children:[void 0!==l?a?(0,t.jsx)(i.Icon,{name:"x",size:"12",strokeWidth:"3",className:"-ml-1 inline-block ltr:mr-2 rtl:ml-2"}):(0,t.jsx)(i.Icon,{name:"circle",fill:"currentColor",size:"5",className:"inline-block ltr:mr-2 rtl:ml-2"}):(0,t.jsx)(i.Icon,{name:"check",size:"12",strokeWidth:"3",className:"-ml-1 inline-block ltr:mr-2 rtl:ml-2"}),s(`${r}_hint_${e}`)]},e)})})}):c?(0,t.jsx)(o,{message:c.message}):e?(0,t.jsx)("div",{className:"text-gray text-default mt-2 flex items-center text-sm",children:(0,t.jsx)("ul",{className:"ml-2",children:e.map(e=>{let a=n.dirtyFields[r];return(0,t.jsxs)("li",{className:a?"text-green-600":"",children:[a?(0,t.jsx)(i.Icon,{name:"check",size:"12",strokeWidth:"3",className:"-ml-1 inline-block ltr:mr-2 rtl:ml-2"}):(0,t.jsx)(i.Icon,{name:"circle",fill:"currentColor",size:"5",className:"inline-block ltr:mr-2 rtl:ml-2"}),s(`${r}_hint_${e}`)]},e)})})}):null:(0,t.jsx)("div",{className:"text-gray text-default mt-2 flex items-center text-sm",children:(0,t.jsx)("ul",{className:"ml-2",children:Object.keys(c).map(e=>(0,t.jsx)("li",{className:"text-blue-700",children:s(`${r}_hint_${e}`)},e))})})}e.s(["InputError",0,o],562187);var d=e.i(144232);let u=(0,r.cva)(["rounded-[10px] border","leading-none font-normal","bg-default","border-default","text-default","placeholder:text-muted","hover:border-emphasis","focus:border-emphasis","focus:ring-0","focus:shadow-outline-gray-focused","disabled:bg-subtle","disabled:hover:border-default","disabled:cursor-not-allowed","shadow-outline-gray-rested","transition-all"],{variants:{size:{sm:"h-7 px-2 py-1 text-xs",md:"h-8 px-3 py-2 text-sm"}},defaultVariants:{size:"md"}}),m=(0,s.forwardRef)(function({isFullWidth:e=!0,size:r="md",className:s,...a},i){return(0,t.jsx)("input",{...a,ref:i,className:(0,n.default)(u({size:r}),e&&"w-full",s)})}),f=({children:e,className:r,error:s,onClickAddon:a,size:i="md",position:l="start"})=>(0,t.jsx)("div",{onClick:a&&a,className:(0,n.default)("flex shrink-0 items-center justify-center whitespace-nowrap",a&&"pointer-events-auto cursor-pointer disabled:hover:cursor-not-allowed",r),children:(0,t.jsx)("span",{className:(0,n.default)("text-sm font-medium leading-none",s?"text-error":"text-muted peer-disabled:opacity-50"),children:e})}),x=(0,s.forwardRef)(function(e,r){let l=(0,s.useId)(),{t:o,isLocaleReady:x,i18n:h}=(0,a.useLocale)(),p=e.t||o,g=e.name||"",{label:b=p(g),labelProps:v,labelClassName:w,disabled:j,LockedIcon:N,placeholder:y=x&&h.exists(`${g}_placeholder`)?p(`${g}_placeholder`):"",className:_,addOnLeading:k,addOnSuffix:C,addOnClassname:I,inputIsFullWidth:S,hint:E,type:A,hintErrors:F,labelSrOnly:R,noLabel:L,containerClassName:T,readOnly:P,showAsteriskIndicator:$,onClickAddon:z,t:U,dataTestid:B,size:V,...q}=e,[M,D]=(0,s.useState)(""),O=e=>{e.currentTarget.parentElement?.querySelector("input")?.focus()};return(0,t.jsxs)("div",{className:(0,n.default)(T),children:[!!g&&!L&&(0,t.jsxs)(d.Label,{htmlFor:l,...v,className:(0,n.default)(w,R&&"sr-only",e.error&&"text-error"),children:[b,$&&!P&&q.required?(0,t.jsx)("span",{className:"text-default ml-1 font-medium",children:"*"}):null,N]}),k||C?(0,t.jsxs)("div",{dir:"ltr",className:(0,n.default)(u({size:V}),"group relative mb-1 flex min-w-0 items-center gap-1","focus-within:shadow-outline-gray-focused focus-within:border-emphasis","[&:has(:disabled)]:bg-subtle [&:has(:disabled)]:hover:border-default [&:has(:disabled)]:cursor-not-allowed",S&&"w-full"),children:[k&&(0,t.jsx)(f,{size:V??"md",position:"start",className:(0,n.default)(I),onClickAddon:O,children:k}),(0,t.jsx)("input",{"data-testid":B?`${B}-input`:"input-field",id:l,type:A,placeholder:y,className:(0,n.default)("w-full min-w-0 truncate border-0 bg-transparent focus:outline-none focus:ring-0","text-default rounded-lg text-sm font-medium leading-none","placeholder:text-muted disabled:cursor-not-allowed disabled:bg-transparent",k&&"rounded-none pl-0.5 pr-0",C&&"pl-0",_),...q,..."search"==A&&{onChange:t=>{D(t.target.value),e.onChange?.(t)},value:M},disabled:P||j,ref:r}),C&&(0,t.jsx)(f,{size:V??"md",position:"end",onClickAddon:e=>{O(e),z?.(e)},className:(0,n.default)(I),children:C}),"search"===A&&M?.toString().length>0&&(0,t.jsx)(i.Icon,{name:"x",className:"text-subtle absolute top-2.5 h-4 w-4 cursor-pointer ltr:right-2 rtl:left-2",onClick:t=>{D(""),e.onChange?.(t)}})]}):(0,t.jsx)(m,{id:l,type:A,placeholder:y,size:V,className:(0,n.default)("w-full min-w-0 truncate focus:outline-none focus:ring-0","text-default rounded-lg text-sm font-medium leading-none","placeholder:text-muted disabled:cursor-not-allowed",k&&"rounded-none pl-0.5 pr-0",C&&!k&&"pl-0.5",_),...q,readOnly:P,ref:r,isFullWidth:S,disabled:P||j}),(0,t.jsx)(c,{hintErrors:F,fieldName:g,t:p}),E&&(0,t.jsxs)("div",{className:"text-muted mt-2 flex items-center text-sm",children:[(0,t.jsx)(i.Icon,{name:"info",className:"text-muted h-4 w-4 mr-1"}),E]})]})}),h=(0,s.forwardRef)(function(e,r){return(0,t.jsx)(x,{ref:r,...e})});e.s(["Input",0,m,"InputField",0,x,"TextField",0,h,"inputStyles",0,u],973895)},939988,e=>{"use strict";var t=e.i(843476),r=e.i(210850),s=e.i(978802),a=e.i(271645),n=e.i(941739);let i=(0,r.cva)("rounded-[10px] p-3",{variants:{severity:{neutral:"bg-default border-subtle border text-default",info:"bg-semantic-info-subtle text-semantic-info",warning:"bg-semantic-attention-subtle text-semantic-attention",error:"bg-semantic-error-subtle text-semantic-error"}},defaultVariants:{severity:"neutral"}}),l=(0,a.forwardRef)((e,r)=>{let{severity:a,iconClassName:l,CustomIcon:o,customIconColor:c}=e;return(0,t.jsx)("div",{"data-testid":"alert",ref:r,className:i({severity:a,className:e.className}),children:(0,t.jsxs)("div",{className:"relative flex md:flex-row",children:[o?(0,t.jsx)("div",{className:"shrink-0",children:(0,t.jsx)(n.Icon,{name:o,"data-testid":"custom-icon","aria-hidden":"true",className:(0,s.default)("h4 mr-2 w-4",l,c??"text-default")})}):(0,t.jsxs)("div",{className:(0,s.default)("mr-2 shrink-0",e.title?"":"mt-0.5"),children:["error"===a&&(0,t.jsx)(n.Icon,{name:"circle-x","data-testid":"circle-x",className:(0,s.default)("h4 w-4",l),"aria-hidden":"true"}),"warning"===a&&(0,t.jsx)(n.Icon,{name:"triangle-alert","data-testid":"alert-triangle",className:(0,s.default)("h4 w-4",l),"aria-hidden":"true"}),"info"===a&&(0,t.jsx)(n.Icon,{name:"info","data-testid":"info",className:(0,s.default)("h4 w-4",l),"aria-hidden":"true"}),"neutral"===a&&(0,t.jsx)(n.Icon,{name:"info","data-testid":"neutral",className:(0,s.default)("text-default h4 w-4 fill-transparent",l),"aria-hidden":"true"})]}),(0,t.jsxs)("div",{className:"flex grow flex-col sm:flex-row",children:[(0,t.jsxs)("div",{className:"stack-y-1 ltr:ml-3 rtl:mr-3",children:[e.title&&(0,t.jsx)("h3",{className:"text-sm font-medium leading-none",children:e.title}),e.message&&(0,t.jsx)("div",{className:"text-sm leading-5",children:e.message})]}),e.actions&&(0,t.jsx)("div",{className:"ml-auto mt-auto text-sm sm:mt-0 md:relative",children:e.actions})]})]})})});l.displayName="Alert",e.s(["Alert",0,l])},258618,e=>{"use strict";var t=e.i(843476),r=e.i(271645),s=e.i(653145),a=e.i(12346),n=e.i(335590),i=e.i(939988),l=e.i(941739),o=e.i(50929),c=e.i(973895),d=e.i(144232);let u=(0,r.forwardRef)(function(e,s){let{t:i}=(0,a.useLocale)(),[d,u]=(0,r.useState)(!1),m=(0,r.useCallback)(()=>u(!d),[d,u]),f=i(d?"hide_password":"show_password");return(0,t.jsx)(c.InputField,{type:d?"text":"password",placeholder:e.placeholder||"•••••••••••••",ref:s,...e,className:(0,n.default)("addon-wrapper mb-0 ltr:border-r-0 ltr:pr-10 rtl:border-l-0 rtl:pl-10",e.className),addOnSuffix:(0,t.jsx)(o.Tooltip,{content:f,children:(0,t.jsxs)("button",{className:"text-emphasis h-9",tabIndex:-1,type:"button",onClick:()=>m(),children:[d?(0,t.jsx)(l.Icon,{name:"eye-off",className:"h-4 w-4 stroke-[2.5px]"}):(0,t.jsx)(l.Icon,{name:"eye",className:"h-4 w-4 stroke-[2.5px]"}),(0,t.jsx)("span",{className:"sr-only",children:f})]})})})}),m=(0,r.forwardRef)(function(e,r){return(0,t.jsx)(c.Input,{ref:r,type:"email",autoCapitalize:"none",autoComplete:"email",autoCorrect:"off",inputMode:"email",...e})}),f=(0,r.forwardRef)(function(e,r){return(0,t.jsx)(c.InputField,{ref:r,type:"email",autoCapitalize:"none",autoComplete:"email",autoCorrect:"off",inputMode:"email",...e})}),x=(0,r.forwardRef)(function(e,r){return(0,t.jsx)("textarea",{...e,ref:r,className:(0,n.default)((0,c.inputStyles)(),"min-h-[80px] w-full",e.className)})}),h=(0,r.forwardRef)(function(e,n){let l=(0,r.useId)(),{t:o}=(0,a.useLocale)(),c=e.t||o,u=(0,s.useFormContext)(),{label:m=c(e.name),labelProps:f,placeholder:h=c(`${e.name}_placeholder`)!==`${e.name}_placeholder`?`${e.name}_placeholder`:"",...p}=e;return(0,t.jsxs)("div",{children:[!!e.name&&(0,t.jsx)(d.Label,{htmlFor:l,...f,children:m}),(0,t.jsx)(x,{ref:n,placeholder:h,...p}),u?.formState?.errors[e.name]?.message&&(0,t.jsx)(i.Alert,{className:"mt-1",severity:"error",message:(0,t.jsx)(t.Fragment,{children:u.formState.errors[e.name]?.message})})]})}),p=(0,r.forwardRef)(function(e,r){return(0,t.jsx)(c.Input,{ref:r,type:"number",autoCapitalize:"none",autoComplete:"numeric",autoCorrect:"off",inputMode:"numeric",...e})}),g=(0,r.forwardRef)(function(e,r){return(0,t.jsx)(c.InputField,{ref:r,addOnLeading:(0,t.jsx)(l.Icon,{name:"search",className:"h-4 w-4 stroke-[2.5px]","data-testid":"search-icon"}),placeholder:"Search",containerClassName:"mt-1",...e})});e.s(["EmailField",0,f,"EmailInput",0,m,"FilterSearchField",0,g,"NumberInput",0,p,"PasswordField",0,u,"TextArea",0,x,"TextAreaField",0,h])},207597,e=>{"use strict";e.s(["localStorage",0,{getItem(e){try{return window.localStorage.getItem(e)}catch{return null}},setItem(e,t){try{window.localStorage.setItem(e,t)}catch{return}},removeItem:e=>{try{window.localStorage.removeItem(e)}catch{return}}},"sessionStorage",0,{getItem(e){try{return window.sessionStorage.getItem(e)}catch{return null}},setItem(e,t){try{window.sessionStorage.setItem(e,t)}catch{return}},removeItem:e=>{try{window.sessionStorage.removeItem(e)}catch{return}}}])},894706,e=>{"use strict";var t=e.i(788685);e.s(["default",0,t])},343794,(e,t,r)=>{!function(){"use strict";var r={}.hasOwnProperty;function s(){for(var e=[],t=0;t{"use strict";var t=e.i(843476),r=e.i(335590);function s({small:e,icon:s,inline:a=!0,className:n,src:i="/api/logo"}){return(0,t.jsx)("h3",{className:(0,r.default)("logo",a&&"inline",n),children:(0,t.jsx)("strong",{children:s?(0,t.jsx)("img",{className:"mx-auto w-9 dark:invert",alt:"Cal",title:"Cal",src:`${i}?type=icon`}):(0,t.jsx)("img",{className:(0,r.default)(e?"h-4 w-auto":"h-5 w-auto","dark:invert"),alt:"Cal",title:"Cal",src:i})})})}e.s(["Logo",()=>s])},994814,e=>{"use strict";var t=e.i(653145),r=function(e,r,s){if(e&&"reportValidity"in e){var a=(0,t.get)(s,r);e.setCustomValidity(a&&a.message||""),e.reportValidity()}},s=function(e,t){var s=function(s){var a=t.fields[s];a&&a.ref&&"reportValidity"in a.ref?r(a.ref,s,e):a.refs&&a.refs.forEach(function(t){return r(t,s,e)})};for(var a in t.fields)s(a)},a=function(e,r){r.shouldUseNativeValidation&&s(e,r);var a={};for(var n in e){var i=(0,t.get)(r.fields,n);(0,t.set)(a,n,Object.assign(e[n],{ref:i&&i.ref}))}return a},n=function(e,r){for(var s={};e.length;){var a=e[0],n=a.code,i=a.message,l=a.path.join(".");if(!s[l])if("unionErrors"in a){var o=a.unionErrors[0].errors[0];s[l]={message:o.message,type:o.code}}else s[l]={message:i,type:n};if("unionErrors"in a&&a.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),r){var c=s[l].types,d=c&&c[a.code];s[l]=(0,t.appendErrors)(l,r,s,n,d?[].concat(d,a.message):a.message)}e.shift()}return s},i=function(e,t,r){return void 0===r&&(r={}),function(i,l,o){try{return Promise.resolve(function(a,n){try{var l=Promise.resolve(e["sync"===r.mode?"parse":"parseAsync"](i,t)).then(function(e){return o.shouldUseNativeValidation&&s({},o),{errors:{},values:r.rawValues?i:e}})}catch(e){return n(e)}return l&&l.then?l.then(void 0,n):l}(0,function(e){return{values:{},errors:e.isEmpty?{}:a(n(e.errors,!o.shouldUseNativeValidation&&"all"===o.criteriaMode),o)}}))}catch(e){return Promise.reject(e)}}};e.s(["zodResolver",()=>i],994814)},89237,e=>{"use strict";var t=e.i(843476);function r(){return(0,t.jsx)("div",{className:"loader border-brand-default dark:border-darkmodebrand",children:(0,t.jsx)("span",{className:"loader-inner bg-brand dark:bg-darkmodebrand"})})}e.s(["default",()=>r])},833875,(e,t,r)=>{"use strict";r.__esModule=!0;var s=e.r(271645);r.default=function(e){for(var t=e.acceptedCharacters,r=e.length,a=e.value,n=e.onChange,i=function(e,t){for(;e.length0){n(i.substring(0,e-1)+" "+i.substring(e));var o=l.current[e-1];o&&o.focus()}break;case"ArrowUp":case"ArrowLeft":if(s.preventDefault(),e>0){var c=l.current[e-1];c&&(c.focus(),window.requestAnimationFrame(function(){c.setSelectionRange(0,1)}))}break;case"ArrowDown":case"ArrowRight":if(s.preventDefault(),e+1{"use strict";var t=e.i(50270);let r=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.']*)[A-Z0-9_+'-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,s=t.z.string().max(254,{message:"Email address is too long"}).regex(r);e.s(["domainRegex",0,/^[a-zA-Z0-9\u00a1-\uffff]([a-zA-Z0-9\u00a1-\uffff-]*[a-zA-Z0-9\u00a1-\uffff])?(\.[a-zA-Z0-9\u00a1-\uffff]([a-zA-Z0-9\u00a1-\uffff-]*[a-zA-Z0-9\u00a1-\uffff])?)*$/,"emailRegex",0,r,"emailSchema",0,s])},85578,e=>{"use strict";var t=e.i(843476),r=e.i(343794),s=e.i(851693),a=e.i(89237);function n(e){return(0,t.jsxs)("div",{className:"bg-subtle dark:bg-default flex min-h-screen flex-col justify-center py-12 sm:px-6 lg:px-8",children:[e.showLogo&&(0,t.jsx)(s.Logo,{small:!0,inline:!1,className:"mx-auto mb-auto"}),(0,t.jsx)("div",{className:(0,r.default)(e.showLogo?"text-center":"","sm:mx-auto sm:w-full sm:max-w-md"),children:e.heading&&(0,t.jsx)("h2",{className:"font-cal text-emphasis text-center text-3xl",children:e.heading})}),e.loading&&(0,t.jsx)("div",{className:"bg-cal-muted absolute z-50 flex h-screen w-full items-center",children:(0,t.jsx)(a.default,{})}),(0,t.jsxs)("div",{className:"mb-auto mt-8 sm:mx-auto sm:w-full sm:max-w-md",children:[(0,t.jsx)("div",{className:"bg-default dark:bg-cal-muted border-subtle mx-2 rounded-md border px-4 py-10 sm:px-10",children:e.children}),(0,t.jsx)("div",{className:"text-default mt-8 text-center text-sm",children:e.footerText})]})]})}e.s(["default",()=>n],85578)},622921,111195,e=>{"use strict";var t,r=((t={}).IncorrectEmailPassword="incorrect-email-password",t.UserNotFound="user-not-found",t.IncorrectPassword="incorrect-password",t.UserMissingPassword="missing-password",t.TwoFactorDisabled="two-factor-disabled",t.TwoFactorAlreadyEnabled="two-factor-already-enabled",t.TwoFactorSetupRequired="two-factor-setup-required",t.SecondFactorRequired="second-factor-required",t.IncorrectTwoFactorCode="incorrect-two-factor-code",t.IncorrectBackupCode="incorrect-backup-code",t.MissingBackupCodes="missing-backup-codes",t.IncorrectEmailVerificationCode="incorrect_email_verification_code",t.InternalServerError="internal-server-error",t.NewPasswordMatchesOld="new-password-matches-old",t.ThirdPartyIdentityProviderEnabled="third-party-identity-provider-enabled",t.RateLimitExceeded="rate-limit-exceeded",t.SocialIdentityProviderRequired="social-identity-provider-required",t.UserAccountLocked="user-account-locked",t);e.s(["ErrorCode",()=>r],622921);var s=e.i(843476),a=e.i(271645),n=e.i(833875),i=e.i(653145),l=e.i(12346),o=e.i(973895),c=e.i(144232);function d({center:e=!0,autoFocus:t=!0}){let[r,d]=(0,a.useState)(""),{t:u}=(0,l.useLocale)(),m=(0,i.useFormContext)(),f=(0,n.default)({acceptedCharacters:/^[0-9]$/,length:6,value:r,onChange:d});return(0,a.useEffect)(()=>{r&&m.setValue("totpCode",r)},[r]),(0,s.jsxs)("div",{className:e?"mx-auto mt-0! max-w-sm":"mt-0! max-w-sm",children:[(0,s.jsx)(c.Label,{className:"mt-4",children:u("2fa_code")}),(0,s.jsx)("p",{className:"text-subtle mb-4 text-sm",children:u("2fa_enabled_instructions")}),(0,s.jsx)("input",{type:"hidden",value:r,...m.register("totpCode")}),(0,s.jsx)("div",{className:"flex flex-row justify-between",children:f.map((e,r)=>(0,s.jsx)(o.Input,{className:"h-12 w-12 text-xl! text-center",name:`2fa${r+1}`,inputMode:"decimal",...e,autoFocus:t&&0===r,autoComplete:"one-time-code"},`2fa${r}`))})]})}e.s(["default",()=>d],111195)},322381,e=>{"use strict";var t=e.i(843476),r=e.i(653145),s=e.i(12346),a=e.i(144232),n=e.i(973895);function i({center:e=!0}){let{t:i}=(0,s.useLocale)(),l=(0,r.useFormContext)();return(0,t.jsxs)("div",{className:e?"mx-auto mt-0! max-w-sm":"mt-0! max-w-sm",children:[(0,t.jsx)(a.Label,{className:"mt-4",children:i("backup_code")}),(0,t.jsx)("p",{className:"text-subtle mb-4 text-sm",children:i("backup_code_instructions")}),(0,t.jsx)(n.TextField,{id:"backup-code",label:"",defaultValue:"",placeholder:"XXXXX-XXXXX",minLength:10,maxLength:11,required:!0,...l.register("backupCode")})]})}e.s(["default",()=>i])},819369,e=>{"use strict";var t=e.i(247167),r=e.i(843476),s=e.i(994814),a=e.i(343794),n=e.i(217255),i=e.i(522016),l=e.i(618566),o=e.i(271645),c=e.i(653145),d=e.i(50270),u=e.i(894706),m=e.i(12346),f=e.i(207597),x=e.i(335590);function h(){let[e,t]=(0,o.useState)();return(0,o.useEffect)(()=>{let e=f.localStorage.getItem("last_cal_login");e&&t(e)},[]),(0,o.useEffect)(()=>{e?f.localStorage.setItem("last_cal_login",e):f.localStorage.removeItem("last_cal_login")},[e]),[e,t]}let p=({className:e})=>{let{t}=(0,m.useLocale)();return(0,r.jsx)("span",{className:(0,x.default)("text-subtle absolute right-3 text-xs",e),children:t("last_used")})};var g=e.i(24509),b=e.i(141424),v=e.i(273446),w=e.i(857739);let j=u.default.object({email:u.default.string().regex(b.emailRegex,{message:"Please enter a valid email"})});function N({samlTenantID:e,samlProductID:t,setErrorMessage:s,...a}){let{t:i}=(0,m.useLocale)(),l=(0,c.useFormContext)(),[o,d]=h(),u=v.trpc.viewer.public.samlTenantProduct.useMutation({onSuccess:async e=>{d("saml"),await (0,n.signIn)("saml",{},{tenant:e.tenant,product:e.product})},onError:e=>{s(i(e.message))}});return(0,r.jsxs)(w.Button,{StartIcon:"lock",color:"secondary","data-testid":"samlAndOidc",className:"flex w-full justify-center",onClick:async r=>{if(r.preventDefault(),!g.HOSTED_CAL_FEATURES)return void await (0,n.signIn)("saml",{},{tenant:e,product:t});let a=l.getValues("email"),i=j.safeParse({email:a});if(!i.success){let{fieldErrors:{email:e}}=i.error.flatten();s(e?e[0]:null);return}u.mutate({email:a})},...a,children:[(0,r.jsx)("span",{children:i("signin_with_saml_oidc")}),"saml"===o&&(0,r.jsx)(p,{})]})}var y=e.i(622921),_=e.i(347637),k=e.i(939988),C=e.i(258618),I=e.i(941739);function S(){let{t:e}=(0,m.useLocale)(),[t,s]=(0,o.useState)(!1);return window.matchMedia("(display-mode: standalone)").matches||t?null:(0,r.jsx)("div",{className:"fixed inset-x-0 bottom-0 pb-2 sm:hidden sm:pb-5",children:(0,r.jsx)("div",{className:"mx-auto max-w-7xl px-2 sm:px-6 lg:px-8",children:(0,r.jsx)("div",{className:"rounded-lg p-2 shadow-lg sm:p-3",style:{background:"#2F333D"},children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex w-0 flex-1 items-center",children:[(0,r.jsx)("span",{className:"text-brandcontrast dark:bg-darkmodebrand/30 dark:text-darkmodebrandcontrast flex rounded-lg p-2",children:(0,r.jsxs)("svg",{className:"h-7 w-7 fill-current text-[#5B93F9]",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 50 50",enableBackground:"new 0 0 50 50",children:[(0,r.jsx)("path",{d:"M30.3 13.7L25 8.4l-5.3 5.3-1.4-1.4L25 5.6l6.7 6.7z"}),(0,r.jsx)("path",{d:"M24 7h2v21h-2z"}),(0,r.jsx)("path",{d:"M35 40H15c-1.7 0-3-1.3-3-3V19c0-1.7 1.3-3 3-3h7v2h-7c-.6 0-1 .4-1 1v18c0 .6.4 1 1 1h20c.6 0 1-.4 1-1V19c0-.6-.4-1-1-1h-7v-2h7c1.7 0 3 1.3 3 3v18c0 1.7-1.3 3-3 3z"})]})}),(0,r.jsx)("p",{className:"text-inverted ms-3 text-xs font-medium dark:text-white",children:(0,r.jsx)("span",{className:"inline",children:e("add_to_homescreen")})})]}),(0,r.jsx)("div",{className:"order-2 shrink-0 sm:order-3",children:(0,r.jsxs)("button",{onClick:()=>s(!0),type:"button",className:"-mr-1 flex rounded-md p-2 hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-white",children:[(0,r.jsx)("span",{className:"sr-only",children:e("dismiss")}),(0,r.jsx)(I.Icon,{name:"x",className:"text-inverted h-6 w-6 dark:text-white","aria-hidden":"true"})]})})]})})})})}var E=e.i(322381),A=e.i(111195),F=e.i(85578);let R=()=>(0,r.jsx)("img",{className:"mr-2 w-4 h-4 text-subtle",src:"/google-icon-colored.svg",alt:"Continue with Google Icon"});function L({csrfToken:e,isGoogleLoginEnabled:u,isSAMLLoginEnabled:f,samlTenantID:x,samlProductID:j,totpEmail:I}){let L=(0,_.useCompatSearchParams)(),{t:T}=(0,m.useLocale)(),P=(0,l.useRouter)(),$=d.z.object({email:d.z.string().min(1,`${T("error_required_field")}`).regex(b.emailRegex,`${T("enter_valid_email")}`),...I?{}:{password:d.z.string().min(1,`${T("error_required_field")}`)}}).passthrough(),z=(0,c.useForm)({resolver:(0,s.zodResolver)($)}),{register:U,formState:B}=z,[V,q]=(0,o.useState)(!!I),[M,D]=(0,o.useState)(!1),[O,X]=(0,o.useState)(null),[Z,W]=h(),K={[y.ErrorCode.IncorrectEmailPassword]:T("incorrect_email_password"),[y.ErrorCode.IncorrectTwoFactorCode]:`${T("incorrect_2fa_code")} ${T("please_try_again")}`,[y.ErrorCode.InternalServerError]:`${T("something_went_wrong")} ${T("please_try_again_and_contact_us")}`,[y.ErrorCode.ThirdPartyIdentityProviderEnabled]:T("account_created_with_identity_provider")},H=L?.get("callbackUrl")||"";/"\//.test(H)&&(H=H.substring(1)),/^https?:\/\//.test(H)||(H=`${g.WEBAPP_URL}/${H}`);let G=(H=((e="")=>{if(!e)return null;if(-1===e.search(/^https?:\/\//))throw Error("Pass an absolute URL");let t=new URL(e);return[g.CONSOLE_URL,g.WEBAPP_URL,g.WEBSITE_URL].some(e=>new URL(e).origin===t.origin)||(e=`${g.WEBAPP_URL}/`),e})(H)||"")?`${g.WEBSITE_URL}/signup?redirect=${encodeURIComponent(H)}`:`${g.WEBSITE_URL}/signup`,Q=(0,r.jsx)(i.default,{href:G,className:"font-medium text-brand-500",children:T("dont_have_an_account")}),J=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w.Button,{onClick:()=>{M?(D(!1),z.setValue("backupCode","")):(q(!1),z.setValue("totpCode","")),X(null)},StartIcon:"arrow-left",color:"minimal",children:T("go_back")}),M?null:(0,r.jsx)(w.Button,{onClick:()=>{D(!0),X(null),z.setValue("totpCode","")},StartIcon:"lock",color:"minimal",children:T("lost_access")})]}),Y=(0,r.jsx)(w.Button,{onClick:()=>{window.location.replace("/")},color:"minimal",children:T("cancel")}),ee=async e=>{X(null);let t=await (0,n.signIn)("credentials",{...e,callbackUrl:H,redirect:!1});t?t.error?t.error===y.ErrorCode.SecondFactorRequired?q(!0):t.error===y.ErrorCode.IncorrectBackupCode?X(T("incorrect_backup_code")):t.error===y.ErrorCode.MissingBackupCodes?X(T("missing_backup_codes")):X(K[t.error]||T("something_went_wrong")):(W("credentials"),P.push(H)):X(K[y.ErrorCode.InternalServerError])},{data:et,isPending:er,error:es}=v.trpc.viewer.public.ssoConnections.useQuery();(0,o.useEffect)(function(){es&&X(es.message)},[es]);let ea=!!g.HOSTED_CAL_FEATURES||f&&!er&&et?.connectionExists;return(0,r.jsxs)("div",{className:"text-emphasis min-h-screen [--cal-brand-emphasis:#101010] [--cal-brand-subtle:#9CA3AF] [--cal-brand-text:white] [--cal-brand:#111827] dark:[--cal-brand-emphasis:#e1e1e1] dark:[--cal-brand-text:black] dark:[--cal-brand:white]",children:[(0,r.jsx)(F.default,{showLogo:!0,heading:V?T("2fa_code"):T("welcome_back"),footerText:V?I?Y:J:"true"!==t.default.env.NEXT_PUBLIC_DISABLE_SIGNUP&&L?.get("register")!=="false"?Q:null,children:(0,r.jsxs)(c.FormProvider,{...z,children:[!V&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"stack-y-3",children:[u&&(0,r.jsxs)(w.Button,{color:"primary",className:"justify-center w-full",disabled:B.isSubmitting,"data-testid":"google",CustomStartIcon:(0,r.jsx)(R,{}),onClick:async e=>{e.preventDefault(),W("google"),await (0,n.signIn)("google",{callbackUrl:H})},children:[(0,r.jsx)("span",{children:T("signin_with_google")}),"google"===Z&&(0,r.jsx)(p,{})]}),ea&&(0,r.jsx)(N,{disabled:B.isSubmitting,samlTenantID:x,samlProductID:j,setErrorMessage:X})]}),(u||ea)&&(0,r.jsx)("div",{className:"my-8",children:(0,r.jsxs)("div",{className:"flex relative items-center",children:[(0,r.jsx)("div",{className:"border-t border-subtle grow"}),(0,r.jsx)("span",{className:"mx-2 text-sm font-normal leading-none text-subtle shrink",children:T("or").toLocaleLowerCase()}),(0,r.jsx)("div",{className:"border-t border-subtle grow"})]})})]}),(0,r.jsxs)("form",{onSubmit:z.handleSubmit(ee),noValidate:!0,"data-testid":"login-form",children:[(0,r.jsx)("div",{children:(0,r.jsx)("input",{defaultValue:e||void 0,type:"hidden",hidden:!0,...U("csrfToken")})}),(0,r.jsxs)("div",{className:"stack-y-6",children:[(0,r.jsxs)("div",{className:(0,a.default)("stack-y-6",{hidden:V}),children:[(0,r.jsx)(C.EmailField,{id:"email",label:T("email_address"),defaultValue:I||L?.get("email"),placeholder:"john.doe@example.com",required:!0,autoComplete:"email",...U("email")}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(C.PasswordField,{id:"password",autoComplete:"current-password",required:!I,className:"mb-0",...U("password")}),(0,r.jsx)("div",{className:"absolute -top-[2px] ltr:right-0 rtl:left-0",children:(0,r.jsx)(i.default,{href:"/auth/forgot-password",tabIndex:-1,className:"text-sm font-medium text-default",children:T("forgot")})})]})]}),V?M?(0,r.jsx)(E.default,{center:!0}):(0,r.jsx)(A.default,{center:!0}):null,O&&(0,r.jsx)(k.Alert,{severity:"error",title:O}),(0,r.jsxs)(w.Button,{type:"submit",color:"secondary",disabled:B.isSubmitting,className:"justify-center w-full",children:[(0,r.jsx)("span",{children:V?T("submit"):T("sign_in")}),"credentials"===Z&&!V&&(0,r.jsx)(p,{className:"text-gray-600"})]})]})]})]})}),(0,r.jsx)(S,{})]})}e.s(["default",()=>L],819369)}]); //# sourceMappingURL=d9291f36df00ff2c.js.map