@wacht/jsx 1.0.0-beta.61 → 1.0.0-beta.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -99,13 +99,13 @@ Read more about this at https://styled-components.com/docs/basics#react-native`)
99
99
  See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page for more info.`),window[$s]+=1);const i4='.wacht-root{--wa-surface: var(--wa-ov-light-surface, #ffffff);--wa-surface-subtle: var(--wa-ov-light-surface_subtle, #fafaf8);--wa-background: var(--wa-ov-light-background, #f5f5f2);--wa-canvas: var(--wa-ov-light-canvas, #ebebe7);--wa-text: var(--wa-ov-light-text, #161618);--wa-text-secondary: var(--wa-ov-light-text_secondary, #3b3b3f);--wa-text-muted: var(--wa-ov-light-text_muted, #76767c);--wa-text-faint: var(--wa-ov-light-text_faint, #a8a8ad);--wa-border: var(--wa-ov-light-border, rgba(20, 20, 22, .08));--wa-border-strong: var(--wa-ov-light-border_strong, rgba(20, 20, 22, .14));--wa-primary: var(--wa-ov-light-primary, #6b3df5);--wa-primary-soft: var(--wa-ov-light-primary_soft, rgba(107, 61, 245, .1));--wa-primary-foreground: var(--wa-ov-light-primary_foreground, #ffffff);--wa-success: var(--wa-ov-light-success, #0f8a4a);--wa-success-soft: var(--wa-ov-light-success_soft, rgba(15, 138, 74, .12));--wa-info: var(--wa-ov-light-info, #2f6fdb);--wa-info-soft: var(--wa-ov-light-info_soft, rgba(47, 111, 219, .1));--wa-warning: var(--wa-ov-light-warning, #a8650a);--wa-warning-soft: var(--wa-ov-light-warning_soft, rgba(168, 101, 10, .12));--wa-error: var(--wa-ov-light-error, #c4271f);--wa-error-soft: var(--wa-ov-light-error_soft, rgba(196, 39, 31, .1));--wa-radius: var(--wa-ov-light-radius, 6px);--wa-radius-lg: var(--wa-ov-light-radius_lg, 10px);--wa-font-sans: var(--wa-ov-light-font_sans, "Geist", "Inter"), system-ui, -apple-system, sans-serif;--wa-font-mono: var(--wa-ov-light-font_mono, "Geist Mono"), ui-monospace, SFMono-Regular, Menlo, monospace;font-family:var(--wa-font-sans)}.dark .wacht-root,.wacht-root.dark{--wa-surface: var(--wa-ov-dark-surface, #131318);--wa-surface-subtle: var(--wa-ov-dark-surface_subtle, #101015);--wa-background: var(--wa-ov-dark-background, #0d0d10);--wa-canvas: var(--wa-ov-dark-canvas, #050507);--wa-text: var(--wa-ov-dark-text, #ececef);--wa-text-secondary: var(--wa-ov-dark-text_secondary, #c5c5cb);--wa-text-muted: var(--wa-ov-dark-text_muted, #8a8a92);--wa-text-faint: var(--wa-ov-dark-text_faint, #57575e);--wa-border: var(--wa-ov-dark-border, rgba(255, 255, 255, .07));--wa-border-strong: var(--wa-ov-dark-border_strong, rgba(255, 255, 255, .14));--wa-primary: var(--wa-ov-dark-primary, #9277ff);--wa-primary-soft: var(--wa-ov-dark-primary_soft, rgba(146, 119, 255, .16));--wa-primary-foreground: var(--wa-ov-dark-primary_foreground, #ffffff);--wa-success: var(--wa-ov-dark-success, #0f8a4a);--wa-success-soft: var(--wa-ov-dark-success_soft, rgba(15, 138, 74, .18));--wa-info: var(--wa-ov-dark-info, #2f6fdb);--wa-info-soft: var(--wa-ov-dark-info_soft, rgba(47, 111, 219, .18));--wa-warning: var(--wa-ov-dark-warning, #a8650a);--wa-warning-soft: var(--wa-ov-dark-warning_soft, rgba(168, 101, 10, .18));--wa-error: var(--wa-ov-dark-error, #c4271f);--wa-error-soft: var(--wa-ov-dark-error_soft, rgba(196, 39, 31, .18));--wa-radius: var(--wa-ov-dark-radius, 6px);--wa-radius-lg: var(--wa-ov-dark-radius_lg, 10px);--wa-font-sans: var(--wa-ov-dark-font_sans, "Geist", "Inter"), system-ui, -apple-system, sans-serif;--wa-font-mono: var(--wa-ov-dark-font_mono, "Geist Mono"), ui-monospace, SFMono-Regular, Menlo, monospace}.wacht-root *{box-sizing:border-box}',o4='.w-flex-col{display:flex;flex-direction:column}.w-inline{display:inline-flex;align-items:center}.w-wrap{flex-wrap:wrap}.w-grow{flex:1 1 auto;min-width:0}.w-none{flex:none}.w-full{width:100%}.w-gap-1{gap:4px}.w-gap-2{gap:8px}.w-gap-3{gap:12px}.w-gap-4{gap:16px}.w-gap-5{gap:20px}.w-gap-6{gap:24px}.w-truncate{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-contents{display:contents}.w-h-full{height:100%}.w-minh-full{min-height:100%}.w-mono-sm{font:400 12px/1.4 var(--wa-font-mono);color:var(--wa-text-muted)}.w-text-primary{color:var(--wa-primary)}.w-text-secondary{color:var(--wa-text-secondary)}.w-text-muted{color:var(--wa-text-muted)}.w-text-faint{color:var(--wa-text-faint)}.w-text-error{color:var(--wa-error)}.w-text-success{color:var(--wa-success)}.w-text-warning{color:var(--wa-warning)}.w-mb-4{margin-bottom:16px}.w-mt-6{margin-top:24px}.w-maxw-sm{max-width:340px}.w-rolepick-btn{min-width:120px}.w-combo-menu--pop{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:60}.w-relative{position:relative}.w-card{background:var(--wa-surface);border:0;border-radius:var(--wa-radius-lg);box-shadow:0 0 0 .5px var(--wa-border),0 1px 1px #1414160a,0 4px 8px -4px #14141614,0 24px 48px -16px #14141629;overflow:hidden}.w-eyebrow{font:400 10px/1 var(--wa-font-mono);letter-spacing:.12em;text-transform:uppercase;color:var(--wa-text-faint)}.w-title{font:400 17px/1.25 var(--wa-font-sans);letter-spacing:-.02em;color:var(--wa-text);margin:0}.w-title-lg{font:400 19px/1.2 var(--wa-font-sans);letter-spacing:-.022em;color:var(--wa-text);margin:0}.w-sub{font:400 13px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);margin:0}.w-sec{font:400 13px/1.3 var(--wa-font-sans);color:var(--wa-text);margin:0}.w-secsub{font:400 12px/1.45 var(--wa-font-sans);color:var(--wa-text-muted);margin:0}.w-btn{height:32px;padding:0 13px;border-radius:var(--wa-radius);border:.5px solid transparent;font:400 12.5px/1 var(--wa-font-sans);display:inline-flex;align-items:center;justify-content:center;gap:7px;cursor:pointer;white-space:nowrap;-webkit-user-select:none;user-select:none;transition:background .14s ease,border-color .14s ease,filter .14s ease,box-shadow .14s ease;background:transparent;color:var(--wa-text)}.w-btn:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-btn:disabled{opacity:.6;cursor:not-allowed}.w-btn svg{width:14px;height:14px;flex:none}.w-btn.w-notif-bell{width:32px;height:32px}.w-btn.w-notif-bell svg{width:18px;height:18px}.w-btn--primary{background:var(--wa-primary);color:var(--wa-primary-foreground);box-shadow:inset 0 1px #ffffff2e,0 1px 2px #1414161f,0 2px 8px -2px color-mix(in srgb,var(--wa-primary) 50%,transparent);background-image:linear-gradient(180deg,#ffffff1a,#fff0 42%)}.w-btn--primary:active:not(:disabled){filter:brightness(.97);box-shadow:inset 0 1px 2px #14141633}.w-btn--block{width:100%;height:38px;font-size:13px}.w-btn--secondary{background:var(--wa-surface);border-color:var(--wa-border-strong);color:var(--wa-text);box-shadow:inset 0 1px #ffffff80,0 1px 1.5px #1414160a}.w-btn--ghost{background:transparent;color:var(--wa-text-secondary)}.w-btn--danger{background:transparent;color:var(--wa-error);border-color:color-mix(in srgb,var(--wa-error) 26%,transparent)}.w-btn--danger-solid{background:var(--wa-error);color:#fff}.w-btn--sm{height:26px;padding:0 9px;font-size:11.5px}.w-btn--lg{height:42px;padding:0 18px;font-size:13.5px}.w-btn--icon{height:28px;width:28px;padding:0;color:var(--wa-text-muted)}.w-btn--icon:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-social{height:40px;width:100%;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);color:var(--wa-text);font:400 13px/1 var(--wa-font-sans);display:flex;align-items:center;justify-content:center;gap:10px;padding:0 14px;cursor:pointer;position:relative;box-shadow:inset 0 1px #ffffff80,0 1px 1.5px #1414160a;transition:background .14s ease,border-color .14s ease,box-shadow .14s ease,transform .1s ease}.w-social:active{transform:translateY(.5px)}.w-social:focus-visible{outline:none;box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-social svg,.w-social img{width:17px;height:17px;flex:none}.w-social .w-social-label{flex:none}.w-social .w-lastused{position:absolute;top:-9px;right:12px;white-space:nowrap;font:400 9.5px/1 var(--wa-font-mono);letter-spacing:.04em;color:var(--wa-text-muted);background:var(--wa-surface);border:.5px solid var(--wa-border);padding:3px 6px;border-radius:5px}.w-field{display:flex;flex-direction:column;gap:7px}.w-label{font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);display:flex;align-items:center;gap:4px;letter-spacing:-.005em;white-space:nowrap}.w-req{color:var(--wa-error);font-size:12px}.w-input{height:34px;padding:0 12px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);color:var(--wa-text);font:400 13px/1 var(--wa-font-sans);width:100%;box-shadow:inset 0 1px 2px #1414160d;transition:border-color .14s ease,box-shadow .14s ease}.w-input::placeholder{color:var(--wa-text-faint)}.w-input:focus{outline:none;border-color:var(--wa-primary);box-shadow:inset 0 1px 2px #1414160a,0 0 0 3px var(--wa-primary-soft)}.w-input-row{display:flex;align-items:center;gap:6px}.w-input-trail{margin-left:-34px;z-index:1}.w-input-wrap{position:relative}.w-input--valid:focus{border-color:var(--wa-success);box-shadow:0 0 0 3px var(--wa-success-soft)}.w-input--invalid,.w-input[aria-invalid=true]{border-color:color-mix(in srgb,var(--wa-error) 55%,var(--wa-border-strong))}.w-input--invalid:focus,.w-input[aria-invalid=true]:focus{border-color:var(--wa-error);box-shadow:0 0 0 3px var(--wa-error-soft)}.w-input:disabled,.w-input[data-disabled]{opacity:.55;cursor:not-allowed}.w-input-err{font:400 11.5px/1.3 var(--wa-font-sans);color:var(--wa-error)}.w-input-ok{font:400 11.5px/1.3 var(--wa-font-sans);color:var(--wa-success)}.w-input-eye{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:28px;height:28px;display:grid;place-items:center;border:0;background:none;cursor:pointer;color:var(--wa-text-faint);border-radius:6px}.w-input-eye:hover{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-input-eye svg{width:15px;height:15px}.w-avatar{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;font:400 var(--av-fs, 13px)/1 var(--wa-font-sans);color:#fff;flex:none;background:var( --av-bg, linear-gradient( 135deg, var(--wa-primary), var( --wa-primary-tint, color-mix(in srgb, var(--wa-primary), #fff 25%) ) ) );box-shadow:inset 0 0 0 .5px #ffffff29;letter-spacing:.01em;overflow:hidden}.w-avatar img{width:100%;height:100%;object-fit:cover}.w-avatar--square{border-radius:var(--wa-radius)}.w-avatar--sm{width:20px;height:20px;font-size:10px}.w-avatar--md{width:28px;height:28px;font-size:11px}.w-avatar--lg{width:44px;height:44px;font-size:15px}.w-avatar--xl{width:80px;height:80px;font-size:24px}.w-avatar-edit{position:relative;cursor:pointer;border:0;padding:0}.w-avatar-edit .w-avatar-veil{position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;display:grid;place-items:center;color:#fff;background:color-mix(in srgb,#000 45%,transparent);opacity:0;transition:opacity .15s ease;font:400 11px/1.2 var(--wa-font-sans);text-align:center;padding:0 6px}.w-avatar-edit:hover .w-avatar-veil,.w-avatar-edit[data-busy] .w-avatar-veil{opacity:1}.w-avatar-veil svg{width:18px;height:18px}.w-pill{display:inline-flex;align-items:center;gap:6px;height:21px;padding:0 8px;border-radius:4px;font:400 10.5px/1 var(--wa-font-mono);text-transform:lowercase;letter-spacing:.01em;background:var(--wa-surface-subtle);color:var(--wa-text-muted);border:.5px solid var(--wa-border);white-space:nowrap;flex:none}.w-pill .w-dot{width:5px;height:5px;border-radius:999px;background:var(--wa-text-faint)}.w-pill--success{background:var(--wa-success-soft);color:var(--wa-success);border-color:color-mix(in srgb,var(--wa-success) 26%,transparent)}.w-pill--success .w-dot{background:var(--wa-success)}.w-pill--warning{background:var(--wa-warning-soft);color:var(--wa-warning);border-color:color-mix(in srgb,var(--wa-warning) 26%,transparent)}.w-pill--warning .w-dot{background:var(--wa-warning)}.w-pill--info{background:var(--wa-info-soft);color:var(--wa-info);border-color:color-mix(in srgb,var(--wa-info) 26%,transparent)}.w-pill--info .w-dot{background:var(--wa-info)}.w-pill--current{background:var(--wa-primary-soft);color:var(--wa-primary);border-color:color-mix(in srgb,var(--wa-primary) 26%,transparent)}.w-pill--error{background:var(--wa-error-soft);color:var(--wa-error);border-color:color-mix(in srgb,var(--wa-error) 26%,transparent)}.w-pill--error .w-dot{background:var(--wa-error)}.w-pill--pending{background:transparent;color:var(--wa-warning);border:.5px dashed color-mix(in srgb,var(--wa-warning) 55%,transparent)}.w-pill--pending .w-dot{background:var(--wa-warning)}.w-chip{display:inline-flex;align-items:center;gap:7px;height:24px;padding:0 5px 0 9px;border-radius:var(--wa-radius);background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);font:400 12px/1 var(--wa-font-mono);color:var(--wa-text-secondary)}.w-chip-x{display:grid;place-items:center;width:16px;height:16px;border-radius:3px;color:var(--wa-text-faint);cursor:pointer}.w-chip-x:hover{background:var(--wa-border);color:var(--wa-text)}.w-chip-x svg{width:11px;height:11px}.w-or{display:flex;align-items:center;gap:14px;margin:18px 0}.w-or:before,.w-or:after{content:"";height:.5px;background:var(--wa-border);flex:1}.w-or span{font:400 10px/1 var(--wa-font-mono);letter-spacing:.14em;color:var(--wa-text-faint)}.w-hr{height:.5px;background:var(--wa-border);border:0;margin:0;width:100%}.w-list{display:flex;flex-direction:column}.w-listhead{display:grid;align-items:center;padding:0 2px 8px;font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);border-bottom:.5px solid var(--wa-border)}.w-row{display:grid;align-items:center;padding:13px 2px;border-bottom:.5px solid var(--wa-border)}.w-row:last-child{border-bottom:0}.w-row--hover{border-radius:var(--wa-radius);margin:0 -8px;padding:11px 10px;border-bottom:0;transition:background .12s ease}.w-row--hover:hover{background:var(--wa-surface-subtle)}.w-acct{display:flex;align-items:center;gap:13px;width:100%;text-align:left;padding:11px 12px;border:.5px solid transparent;border-radius:var(--wa-radius-lg);background:none;cursor:pointer;transition:background .13s ease,border-color .13s ease}.w-acct:hover{background:var(--wa-surface-subtle)}.w-acct[data-active]{background:var(--wa-surface-subtle);border-color:var(--wa-border)}.w-acct .w-acct-go{color:var(--wa-text-faint);flex:none;opacity:0;transform:translate(-4px);transition:opacity .13s ease,transform .13s ease}.w-acct:hover .w-acct-go{opacity:1;transform:none;color:var(--wa-text-muted)}.w-acct[data-busy]{opacity:.55;pointer-events:none}.w-acct-list{border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);overflow:hidden;margin-bottom:18px}.w-acct-list-head{padding:11px 14px;border-bottom:.5px solid var(--wa-border)}.w-acct-list-body{padding:6px}.w-acct-text{flex:1;min-width:0;text-align:left}.w-acct-name{display:block;font:400 13px/1.3 var(--wa-font-sans);color:var(--wa-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-acct-text .w-secsub{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-acct .w-avatar{width:34px;height:34px;flex:none}.w-acct[data-active] .w-avatar{width:40px;height:40px}.w-acct-add-ic{width:36px;height:36px;border-radius:50%;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);display:grid;place-items:center;color:var(--wa-text-muted);flex:none;transition:color .13s ease,border-color .13s ease}.w-acct--add:hover .w-acct-add-ic{color:var(--wa-text);border-color:var(--wa-text-muted)}.w-acct-out{color:var(--wa-text-faint);flex:none;margin-right:-6px}.w-acct-out:hover{color:var(--wa-error);background:var(--wa-error-soft)}.w-acct--add:hover{background:var(--wa-surface-subtle)}.w-acct-foot{margin-top:8px;padding-top:10px}.w-acct-add{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;height:36px;border:0;background:none;cursor:pointer;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-muted);transition:background .13s ease,color .13s ease}.w-acct-add svg{width:15px;height:15px}.w-acct-add:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-tabs{display:flex;gap:2px}.w-tab{display:inline-flex;align-items:center;gap:7px;height:30px;flex:none;white-space:nowrap;padding:0 12px;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-muted);background:none;border:0;cursor:pointer;transition:color .14s ease,background .14s ease}.w-tab svg{width:14px;height:14px}.w-tab:hover,.w-tab--active{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-tab--active svg{color:var(--wa-primary)}.w-menu{width:264px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;padding:4px;overflow:hidden}.w-menu-head{display:flex;align-items:center;gap:11px;padding:11px 9px}.w-menu-item{display:flex;align-items:center;justify-content:flex-start;gap:10px;height:32px;padding:0 8px;border-radius:var(--wa-radius);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);cursor:pointer;transition:background .12s ease;width:100%;border:0;background:none;text-align:left;white-space:nowrap}.w-menu-item:hover{background:var(--wa-surface-subtle)}.w-menu-item svg{width:15px;height:15px;color:var(--wa-text-muted);flex:none}.w-menu-item .w-avatar svg{color:inherit}.w-menu-item--danger{color:var(--wa-error)}.w-menu-item--danger svg{color:var(--wa-error)}.w-menu-item--danger:hover{background:var(--wa-error-soft)}.w-menu-trail{margin-left:auto;font:400 10.5px/1 var(--wa-font-mono);color:var(--wa-text-faint)}.w-menu-label{font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);padding:10px 9px 5px}.w-orgtrigger{display:flex;align-items:center;gap:9px;width:100%;height:40px;padding:0 9px;border:0;border-radius:var(--wa-radius);background:transparent;color:var(--wa-text);cursor:pointer;font:400 13px/1 var(--wa-font-sans);text-align:left;transition:background .12s ease}.w-orgtrigger:hover,.w-orgtrigger[data-open]{background:var(--wa-surface-subtle)}.w-orgtrigger:disabled{opacity:.6;cursor:default}.w-orgtrigger>svg{color:var(--wa-text-faint);flex:none}.w-switch-body{overflow-y:auto;padding:4px 0}.w-switch-banner{margin:8px 8px 0}.w-switch-nest{display:flex;flex-direction:column;margin:2px 0 6px 24px;padding-left:8px;border-left:.5px solid var(--wa-border)}.w-menu-item--muted{color:var(--wa-text-muted)}.w-menu-item--muted svg{color:var(--wa-text-muted)}.w-rowact{display:inline-grid;place-items:center;width:22px;height:22px;border-radius:5px;color:var(--wa-text-muted);cursor:pointer}.w-rowact:hover{color:var(--wa-text);background:var(--wa-border)}.w-rowact svg{width:13px;height:13px}.w-danger{border:.5px solid color-mix(in srgb,var(--wa-error) 30%,transparent);background:var(--wa-error-soft);border-radius:var(--wa-radius);padding:14px 16px;display:flex;align-items:center;justify-content:space-between;gap:20px}.w-link{color:var(--wa-text);font-weight:400;cursor:pointer;text-decoration:none}.w-link--sm{font-size:12px}.w-link:hover{text-decoration:underline}.w-link--muted{color:var(--wa-text-muted)}.w-mono-faint{font:400 12px/1.4 var(--wa-font-mono);color:var(--wa-text-faint)}@keyframes w-spin{to{transform:rotate(360deg)}}.w-spin{display:inline-block;border-radius:50%;border:2px solid var(--wa-border-strong);border-top-color:var(--wa-primary);animation:w-spin .7s linear infinite}.w-spin--on-accent{border-color:#ffffff59;border-top-color:#fff}.w-loading{display:grid;place-items:center;gap:14px;padding:40px;text-align:center}.w-otp{display:flex;gap:8px}.w-otp .w-otp-cell{width:42px;height:48px;text-align:center;font:400 20px/1 var(--wa-font-mono);color:var(--wa-text);border:.5px solid var(--wa-border-strong);border-radius:var(--wa-radius);background:var(--wa-surface);display:grid;place-items:center}.w-otp .w-otp-cell[data-active],.w-otp .w-otp-cell:focus{outline:none;border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-otp .w-otp-cell[data-filled]{border-color:var(--wa-text-muted)}.w-otp[data-error] .w-otp-cell{border-color:color-mix(in srgb,var(--wa-error) 50%,var(--wa-border-strong))}.w-otp-caret{width:1.5px;height:22px;background:var(--wa-primary);animation:w-blink 1s steps(1) infinite}@keyframes w-blink{50%{opacity:0}}.w-addr-badge{display:inline-flex;align-items:center;gap:8px;height:30px;padding:0 6px 0 12px;border-radius:999px;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text-secondary)}.w-addr-badge button{border:0;background:none;cursor:pointer;color:var(--wa-primary);font:400 12px/1 var(--wa-font-sans);padding:4px 8px;border-radius:6px}.w-addr-badge button:hover{background:var(--wa-primary-soft)}.w-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px;padding:48px 24px}.w-empty .w-empty-ic{display:grid;place-items:center;width:44px;height:44px;border-radius:var(--wa-radius-lg);background:var(--wa-primary-soft);color:var(--wa-primary)}.w-empty .w-empty-ic svg{width:20px;height:20px;color:var(--wa-primary)}.w-empty-text{display:flex;flex-direction:column;gap:4px}.w-empty h4{margin:0;font:500 14px/1.4 var(--wa-font-sans);color:var(--wa-text)}.w-empty p{margin:0;font:400 12px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);max-width:384px;text-wrap:pretty}.w-empty-action{margin-top:4px}.w-empty--fill{height:100%}.w-empty-ic--accent{width:44px;height:44px}.w-toast{display:inline-flex;align-items:center;gap:11px;padding:11px 13px 11px 14px;border-radius:var(--wa-radius-lg);background:var(--wa-surface);border:.5px solid var(--wa-border);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;min-width:280px;max-width:380px}.w-toast .w-toast-ic{width:20px;height:20px;border-radius:50%;display:grid;place-items:center;flex:none}.w-toast .w-toast-ic svg{width:12px;height:12px}.w-toast--success .w-toast-ic{background:var(--wa-success-soft);color:var(--wa-success)}.w-toast--error .w-toast-ic{background:var(--wa-error-soft);color:var(--wa-error)}.w-toast-msg{flex:1;font:400 13px/1.35 var(--wa-font-sans);color:var(--wa-text)}.w-toast-x{border:0;background:none;cursor:pointer;color:var(--wa-text-faint);width:22px;height:22px;border-radius:6px;display:grid;place-items:center;flex:none}.w-toast-x:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-toast-x svg{width:12px;height:12px}.w-pop{width:320px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;overflow:hidden}.w-pop-body{padding:15px 15px 13px;display:flex;flex-direction:column;gap:11px}.w-pop-title{margin:0;font:400 13.5px/1.3 var(--wa-font-sans);letter-spacing:-.01em;color:var(--wa-text)}.w-pop-sub{margin:0;font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);text-wrap:pretty}.w-pop-title+.w-pop-sub{margin-top:-7px}.w-pop-foot{display:flex;gap:8px;justify-content:flex-end;padding:10px 14px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-pop-foot .w-btn{width:auto}.w-pop-icon{width:38px;height:38px;border-radius:var(--wa-radius);display:grid;place-items:center;flex:none}.w-pop-icon--danger{background:var(--wa-error-soft);color:var(--wa-error)}.w-pop-icon--warn{background:var(--wa-warning-soft);color:var(--wa-warning)}.w-pop-icon svg{width:18px;height:18px}.w-locked{display:flex;align-items:center;gap:10px;height:38px;padding:0 8px 0 13px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-locked .w-locked-ic{color:var(--wa-text-faint);flex:none}.w-locked .w-locked-ic svg{width:15px;height:15px;display:block}.w-locked .w-locked-val{flex:1;font:400 13.5px/1 var(--wa-font-sans);color:var(--wa-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-restricted{opacity:.55;cursor:not-allowed}.w-restricted *{pointer-events:none}.w-warn-ic{color:var(--wa-warning);display:inline-grid;place-items:center}.w-warn-ic svg{width:15px;height:15px}.w-codes{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:14px;border-radius:var(--wa-radius);background:var(--wa-surface-subtle);border:.5px solid var(--wa-border)}.w-codes span{font:400 13px/1.6 var(--wa-font-mono);color:var(--wa-text);text-align:center;letter-spacing:.04em}.w-qr{width:148px;height:148px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface);display:grid;place-items:center;color:var(--wa-text)}.w-banner{display:flex;gap:11px;padding:12px 14px;border-radius:var(--wa-radius);align-items:flex-start}.w-banner svg{width:16px;height:16px;flex:none;margin-top:1px}.w-banner-txt{font:400 12.5px/1.5 var(--wa-font-sans);text-wrap:pretty;color:var(--wa-text-secondary)}.w-banner--error{background:var(--wa-error-soft)}.w-banner--warn{background:var(--wa-warning-soft)}.w-banner--info{background:var(--wa-info-soft)}.w-banner--error svg{color:var(--wa-error)}.w-banner--warn svg{color:var(--wa-warning)}.w-banner--info svg{color:var(--wa-info)}.w-seg{display:inline-flex;padding:3px;gap:2px;background:var(--wa-surface-subtle);border:.5px solid var(--wa-border);border-radius:var(--wa-radius)}.w-seg button{height:28px;padding:0 12px;border:0;background:none;cursor:pointer;border-radius:4px;font:400 12px/1 var(--wa-font-sans);color:var(--wa-text-muted);white-space:nowrap}.w-seg button[data-on]{background:var(--wa-surface);color:var(--wa-text);box-shadow:0 0 0 .5px var(--wa-border)}.w-steps{display:flex;gap:6px;justify-content:center}.w-steps i{width:5px;height:5px;border-radius:999px;background:var(--wa-border-strong);transition:background .2s ease,width .2s ease}.w-steps i[data-on]{background:var(--wa-primary);width:16px}.w-ibadge{display:grid;place-items:center;width:48px;height:48px;flex:none;border-radius:var(--wa-radius-lg);background:var(--wa-primary-soft);color:var(--wa-primary);overflow:hidden}.w-ibadge svg{width:24px;height:24px}.w-ibadge img{width:100%;height:100%;object-fit:cover}.w-ibadge--done{width:52px;height:52px;border-radius:999px;background:var(--wa-success-soft);color:var(--wa-success)}.w-ibadge--done svg{width:26px;height:26px}.w-ibadge-wrap{position:relative}.w-ibadge-x{position:absolute;top:-6px;right:-6px;width:20px;height:20px;display:grid;place-items:center;border-radius:999px;border:.5px solid var(--wa-border);background:var(--wa-surface);color:var(--wa-text-muted);cursor:pointer;box-shadow:0 1px 2px #1414161f}.w-ibadge-x svg{width:11px;height:11px}.w-create-foot{padding:13px 32px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle);text-align:center}.w-create-summary{display:flex;align-items:center;justify-content:center;gap:12px;width:100%;padding:12px 16px;border:.5px solid var(--wa-border);border-radius:var(--wa-radius)}.w-auth-card{width:min(440px,100%)}.w-auth-head{display:flex;flex-direction:column;align-items:center;gap:14px;margin-bottom:24px}.w-auth-head-text{display:flex;flex-direction:column;gap:6px;text-align:center}.w-auth-title{margin:0;font:400 21px/1.2 var(--wa-font-sans);letter-spacing:-.025em;color:var(--wa-text)}.w-auth-sub{margin:0;font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted);text-wrap:pretty}.w-auth-status{display:flex;flex-direction:column;align-items:center;gap:16px;padding-top:4px;text-align:center}.w-auth-foot{font:400 12.5px/1.5 var(--wa-font-sans);color:var(--wa-text-muted)}.w-fineprint{margin:2px 2px 0;font:400 11px/1.5 var(--wa-font-sans);color:var(--wa-text-faint);text-align:center;text-wrap:pretty}.w-switch{display:inline-flex;align-items:center;gap:10px;cursor:pointer;-webkit-user-select:none;user-select:none}.w-switch .w-switch-track{width:36px;height:20px;border-radius:999px;background:var(--wa-border-strong);border:.5px solid transparent;position:relative;transition:background .16s ease;flex:none}.w-switch .w-switch-knob{position:absolute;top:1.5px;left:1.5px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform .16s ease}.w-switch[data-on] .w-switch-track{background:var(--wa-primary)}.w-switch[data-on] .w-switch-knob{transform:translate(16px)}.w-switch-label{font:400 13px/1 var(--wa-font-sans);color:var(--wa-text)}.w-search{display:flex;align-items:center;gap:8px;height:32px;width:240px;max-width:100%;padding:0 11px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface)}.w-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:14px}.w-search svg{width:15px;height:15px;color:var(--wa-text-faint);flex:none}.w-search input{border:0;background:none;outline:none;flex:1;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);min-width:0}.w-search input::placeholder{color:var(--wa-text-faint)}.w-combo{display:flex;align-items:center;gap:8px;height:34px;padding:0 10px 0 12px;width:100%;border-radius:var(--wa-radius);border:.5px solid var(--wa-border-strong);background:var(--wa-surface);cursor:pointer;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);transition:border-color .14s ease}.w-combo:hover{border-color:var(--wa-text-muted)}.w-combo[data-open]{border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft)}.w-combo .w-combo-val{flex:1;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-combo .w-combo-val[data-ph]{color:var(--wa-text-faint)}.w-combo svg{width:15px;height:15px;color:var(--wa-text-muted);flex:none}.w-combo-menu{width:100%;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;padding:4px;overflow:hidden}.w-combo-opt{display:flex;align-items:center;justify-content:flex-start;gap:9px;height:30px;padding:0 8px;border-radius:5px;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);cursor:pointer;width:100%;border:0;background:none;text-align:left;white-space:nowrap}.w-combo-opt>svg{width:15px;height:15px;flex:none;color:var(--wa-text-muted)}.w-combo-opt:hover{background:var(--wa-surface-subtle)}.w-combo-opt .w-combo-check{margin-left:auto;color:var(--wa-primary);display:grid;place-items:center}.w-combo-opt .w-combo-check svg{width:14px;height:14px}.w-combo-opt[data-disabled]{opacity:.5;cursor:not-allowed}.w-combo-grp{font:400 10px/1 var(--wa-font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--wa-text-faint);padding:9px 9px 5px}.w-phone{display:flex;align-items:stretch;gap:0;width:100%}.w-phone .w-phone-cc{display:flex;align-items:center;gap:7px;height:34px;padding:0 10px;border:.5px solid var(--wa-border-strong);border-right:0;border-radius:var(--wa-radius) 0 0 var(--wa-radius);background:var(--wa-surface-subtle);cursor:pointer;font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);white-space:nowrap}.w-phone .w-phone-cc svg{width:13px;height:13px;color:var(--wa-text-muted)}.w-phone input{flex:1;height:34px;padding:0 12px;border:.5px solid var(--wa-border-strong);border-radius:0 var(--wa-radius) var(--wa-radius) 0;background:var(--wa-surface);font:400 13px/1 var(--wa-font-sans);color:var(--wa-text);outline:none;min-width:0}.w-phone input:focus{border-color:var(--wa-primary);box-shadow:0 0 0 3px var(--wa-primary-soft);position:relative}.w-flag{width:18px;height:13px;border-radius:2px;display:inline-block;flex:none;box-shadow:inset 0 0 0 .5px #00000026}.w-country-pop{position:absolute;top:calc(100% + 6px);left:0;z-index:50;width:260px;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;overflow:hidden}.w-country-search{display:flex;align-items:center;gap:8px;padding:9px 11px;border-bottom:.5px solid var(--wa-border)}.w-country-search svg{width:14px;height:14px;color:var(--wa-text-faint);flex:none}.w-country-search input{border:0;background:none;outline:none;flex:1;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);min-width:0}.w-country-search input::placeholder{color:var(--wa-text-faint)}.w-country-list{max-height:220px;overflow-y:auto;padding:5px}.w-country-opt{display:flex;align-items:center;gap:9px;height:32px;padding:0 9px;border-radius:5px;cursor:pointer;font:400 12.5px/1 var(--wa-font-sans);color:var(--wa-text);width:100%;border:0;background:none;text-align:left}.w-country-opt:hover{background:var(--wa-surface-subtle)}.w-country-opt .dial{margin-left:auto;color:var(--wa-text-muted);font:400 12px/1 var(--wa-font-mono);flex:none}.w-method-stack{display:flex;flex-direction:column;gap:10px}.w-method{display:flex;align-items:center;gap:13px;width:100%;padding:13px 14px;border:.5px solid var(--wa-border-strong);border-radius:var(--wa-radius);background:var(--wa-surface);cursor:pointer;text-align:left;transition:background .14s ease,border-color .14s ease}.w-method .w-method-ic{width:34px;height:34px;border-radius:var(--wa-radius);display:grid;place-items:center;background:var(--wa-surface-subtle);color:var(--wa-text-secondary);flex:none}.w-method .w-method-ic svg{width:17px;height:17px}.w-method .w-method-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}.w-method .w-method-title{font:400 13.5px/1 var(--wa-font-sans);color:var(--wa-text)}.w-method .w-method-desc{font:400 12px/1.4 var(--wa-font-sans);color:var(--wa-text-muted)}.w-method .w-method-go{color:var(--wa-text-faint);flex:none}.w-method .w-method-go svg{width:16px;height:16px}.w-method[data-disabled]{opacity:.5;cursor:not-allowed}.w-overlay{position:relative;width:100%;height:100%;background:color-mix(in srgb,#000 38%,transparent);display:grid;place-items:center;border-radius:inherit}.w-dialog{background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);box-shadow:0 1px 2px #1414160d,0 12px 32px -10px #14141629;width:100%;max-width:480px;overflow:hidden;display:flex;flex-direction:column}.w-dialog--panel{display:block;width:880px;max-width:100%;height:min(560px,calc(100dvh - 40px));overflow-y:auto}.w-dialog--panel .w-card{background:transparent;border-radius:0;box-shadow:none}@media(max-width:640px){.w-dialog--panel{height:calc(100dvh - 16px)}}.w-dialog--create{background:transparent;border:0;box-shadow:none;width:440px;max-width:100%;align-items:center;scrollbar-gutter:stable both-edges}.w-create-card{width:440px;max-width:100%}.w-create-body{padding:34px 32px 28px}.w-create-head{margin-bottom:24px}.w-create-steps{margin-bottom:22px}.w-text-center{text-align:center}.w-linkbtn{background:none;border:0;padding:0;cursor:pointer}.w-modal{position:fixed;top:0;right:0;bottom:0;left:0;background:#08080c80;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);display:flex;justify-content:center;align-items:center;padding:20px;z-index:99999}@media(max-width:640px){.w-modal{padding:8px}}.w-dialog-head{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:.5px solid var(--wa-border)}.w-dialog-title{margin:0;font:400 15px/1.2 var(--wa-font-sans);letter-spacing:-.01em;color:var(--wa-text)}.w-dialog-body{padding:20px;display:flex;flex-direction:column;gap:14px}.w-dialog-foot{display:flex;gap:8px;justify-content:flex-end;padding:14px 20px;border-top:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-vtabs{display:flex;flex-direction:column;gap:2px}.w-vtab{display:flex;align-items:center;gap:10px;height:34px;padding:0 11px;border-radius:var(--wa-radius);font:400 13px/1 var(--wa-font-sans);color:var(--wa-text-muted);background:none;border:0;cursor:pointer;text-align:left;width:100%}.w-vtab svg{width:15px;height:15px}.w-vtab:hover,.w-vtab[data-on]{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-vtab[data-on] svg{color:var(--wa-primary)}@keyframes w-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.w-skel{border-radius:6px;background:linear-gradient(90deg,var(--wa-surface-subtle) 25%,var(--wa-border) 37%,var(--wa-surface-subtle) 63%);background-size:200% 100%;animation:w-shimmer 1.4s ease infinite}.w-auth-skel{display:flex;flex-direction:column;gap:22px}.w-auth-skel-head{display:flex;flex-direction:column;align-items:center;gap:12px;margin-bottom:2px}.w-auth-skel-fields{display:flex;flex-direction:column;gap:15px}.w-auth-skel-field{display:flex;flex-direction:column;gap:7px}.w-skel-avatar{width:44px;height:44px;border-radius:50%}.w-skel-line{height:10px}.w-skel-title{height:16px;width:56%}.w-skel-sub{height:11px;width:78%}.w-skel-label{height:9px;width:34%}.w-skel-input{height:38px;border-radius:var(--wa-radius)}.w-skel-btn{height:38px;border-radius:var(--wa-radius);margin-top:3px}.w-table{width:100%;border-collapse:separate;border-spacing:0;background:var(--wa-surface);border:.5px solid var(--wa-border);border-radius:var(--wa-radius-lg);overflow:hidden}.w-table thead{background:var(--wa-surface-subtle)}.w-table th{text-align:left;padding:9px 16px;font:400 11px/1 var(--wa-font-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--wa-text-faint);white-space:nowrap;border-bottom:.5px solid var(--wa-border)}.w-table th:last-child{text-align:right}.w-table td{padding:11px 16px;font:400 13px/1.35 var(--wa-font-sans);color:var(--wa-text-secondary);vertical-align:middle;white-space:nowrap}.w-table tbody tr{transition:background .12s ease}.w-table tbody tr:not(:last-child) td{border-bottom:.5px solid var(--wa-border)}.w-table tbody tr:hover td{background:var(--wa-surface-subtle)}.w-table tbody tr:last-child td:last-child{overflow:visible}.w-td--flex>div{display:flex;align-items:center;gap:10px}.w-td--actions{text-align:right;width:auto;white-space:nowrap;position:relative;overflow:visible}.w-td--actions>*{width:fit-content;margin-left:auto}.w-td--actions>[data-dropdown-trigger]{display:inline-flex;width:fit-content;margin-left:auto}.w-actions{display:flex;gap:6px;justify-content:flex-end;align-items:center}.w-kebab{width:28px;height:28px;border-radius:6px;border:0;background:none;cursor:pointer;color:var(--wa-text-muted);display:grid;place-items:center}.w-kebab:hover{background:var(--wa-surface-subtle);color:var(--wa-text)}.w-kebab svg{width:16px;height:16px}.w-token{display:flex;align-items:center;gap:8px;height:36px;padding:0 6px 0 12px;border-radius:var(--wa-radius);border:.5px solid var(--wa-border);background:var(--wa-surface-subtle)}.w-token code{flex:1;font:400 12px/1 var(--wa-font-mono);color:var(--wa-text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.w-page-head{display:flex;align-items:center;flex-wrap:wrap;gap:12px;padding:18px 22px}.w-tabsbar{flex:none;padding:0 22px;border-bottom:.5px solid var(--wa-border);overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.w-tabsbar::-webkit-scrollbar{display:none}.w-tabbody{flex:1;min-height:0;padding:20px 22px;overflow-y:auto;overflow-x:auto}.w-tabpane{min-width:300px}.w-card-head{display:flex;align-items:flex-start;justify-content:space-between;flex-wrap:wrap;gap:16px;padding:16px 20px}.w-card-body{padding:16px 20px}.w-card-foot{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:12px;padding:14px 20px;border-top:.5px solid var(--wa-border)}.w-sechead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px}.w-iconbox{width:22px;height:22px;flex:none;display:inline-flex;align-items:center;justify-content:center;overflow:hidden}.w-iconbox svg,.w-iconbox img{width:22px;height:22px;display:block}.w-vrow{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 0}.w-vrow:not(:last-child){border-bottom:.5px solid var(--wa-border)}.w-row-act-top{align-self:flex-start;margin-top:20px}.w-rowitem{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 20px}.w-rowitem:not(:last-child){border-bottom:.5px solid var(--wa-border)}.w-aside-copy{max-width:220px;text-align:center}.w-split{display:flex;min-height:400px;border-radius:var(--wa-radius-lg);overflow:hidden;border:.5px solid var(--wa-border);background:var(--wa-surface)}.w-split-aside{width:35%;min-width:200px;flex:none;background:var(--wa-surface-subtle);border-right:.5px solid var(--wa-border);padding:28px;display:flex;flex-direction:column;gap:14px}.w-split-main{flex:1;min-width:0;padding:28px;display:flex;flex-direction:column;gap:16px}@media(max-width:600px){.w-split{flex-direction:column}.w-split-aside{width:100%;border-right:0;border-bottom:.5px solid var(--wa-border)}}.w-listrow{display:flex;align-items:center;gap:12px;width:100%;padding:12px 0;text-align:left;border:0;border-bottom:.5px solid var(--wa-border);background:transparent;cursor:pointer;transition:background .12s ease}.w-listrow:last-child{border-bottom:0}.w-listrow:hover{background:var(--wa-surface-subtle)}.w-listrow:disabled{opacity:.6;cursor:not-allowed}.w-tile{border:.5px solid var(--wa-border);border-radius:var(--wa-radius);padding:12px;background:var(--wa-surface-subtle)}.w-input--area{min-height:80px;padding-top:9px;padding-bottom:9px;resize:vertical;line-height:1.5}.w-input--mono{font-family:var(--wa-font-mono)}.w-pop--wide{width:372px;max-width:calc(100vw - 24px);overflow:visible}.w-pop .w-input:not(.w-input--area),.w-pop .w-combo{height:32px}.w-feature-badge{width:52px;height:52px;border-radius:999px;display:grid;place-items:center;color:var(--wa-primary-foreground);background:linear-gradient(135deg,var(--wa-primary),var(--wa-primary-tint, #9277ff));box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-primary) 55%,transparent);margin-bottom:18px}.w-narrow{max-width:420px;margin:0 auto}.w-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:14px}.w-grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.w-grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}@media(max-width:600px){.w-grid-2,.w-grid-3,.w-grid-4{grid-template-columns:1fr}}.w-toast--fixed{position:fixed;bottom:20px;right:20px;z-index:1000}.w-toast--contained{position:absolute;bottom:16px;left:50%;transform:translate(-50%);z-index:20;width:max-content;max-width:calc(100% - 32px)}.w-notif-badge{position:absolute;top:4px;right:4px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--wa-error);color:#fff;font:500 9px/1 var(--wa-font-sans);display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--wa-surface)}.w-notif-badge[data-dot]{top:6px;right:6px;min-width:8px;height:8px;padding:0}.w-notif-row{cursor:pointer;padding:12px 18px;border-bottom:.5px solid var(--wa-border);transition:background .12s ease}.w-notif-row:hover,.w-notif-row[data-unread]{background:var(--wa-surface-subtle)}.w-notif-row:hover .w-notif-actions button{color:var(--wa-text-secondary)}.w-notif-row .w-notif-actions button{color:var(--wa-text-faint);transition:color .12s ease}.w-notif-row .w-notif-actions button:hover{color:var(--wa-text);background:var(--wa-surface-subtle)}.w-notif-row .w-notif-actions button[data-on]{color:var(--wa-warning)}.w-notif-dot{width:8px;height:8px;border-radius:50%;background:var(--wa-primary);flex:none}.w-notif-pop{position:fixed;width:450px;max-width:calc(100vw - 24px);z-index:99999}.w-notif-panel{width:450px;max-width:100%;height:100%;background:var(--wa-surface);overflow:hidden}.w-notif-panel--fill{width:100%}.w-notif-head{position:relative;padding:14px 18px;border-bottom:.5px solid var(--wa-border)}.w-notif-body{overflow-x:hidden;overflow-y:auto;background:var(--wa-surface)}.w-notif-menu{position:absolute;top:calc(100% + 4px);right:12px;width:200px;z-index:100000}.w-notif-menu .w-menu-check{margin-left:auto;color:var(--wa-primary)}.w-notif-filter-dot{position:absolute;top:5px;right:5px;width:6px;height:6px;border-radius:50%;background:var(--wa-primary)}.w-banner--success{background:var(--wa-success-soft)}.w-banner--success svg{color:var(--wa-success)}@keyframes w-pop{0%{transform:scale(.5);opacity:0}60%{transform:scale(1.06)}to{transform:scale(1);opacity:1}}@keyframes w-ring{0%{transform:scale(.85);opacity:.45}to{transform:scale(1.9);opacity:0}}@keyframes w-draw{to{stroke-dashoffset:0}}@keyframes w-indeterminate{0%{transform:translate(-100%)}to{transform:translate(330%)}}.w-success{position:relative;display:grid;place-items:center;width:56px;height:56px}.w-success .ring{position:absolute;top:2px;right:2px;bottom:2px;left:2px;border-radius:999px;border:1.5px solid var(--wa-success);opacity:0}.w-success .disc{width:52px;height:52px;border-radius:999px;background:var(--wa-success);color:#fff;display:grid;place-items:center;box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-success) 55%,transparent)}.w-success .disc svg{width:26px;height:26px}.w-success--error .ring{border-color:var(--wa-error)}.w-success--error .disc{background:var(--wa-error);box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-error) 55%,transparent)}.w-success--info .ring{border-color:var(--wa-info)}.w-success--info .disc{background:var(--wa-info);box-shadow:0 4px 14px -3px color-mix(in srgb,var(--wa-info) 55%,transparent)}.w-progress{position:relative;width:70%;height:3px;border-radius:999px;background:var(--wa-border);overflow:hidden}.w-progress:after{content:"";position:absolute;top:0;left:0;width:30%;height:100%;border-radius:999px;background:var(--wa-primary)}@media(prefers-reduced-motion:no-preference){.w-success .ring{animation:w-ring 1.7s ease-out infinite}.w-success .disc{animation:w-pop .42s cubic-bezier(.2,.9,.3,1.2)}.w-success .disc svg path{stroke-dasharray:26;stroke-dashoffset:26;animation:w-draw .4s .22s ease forwards}.w-progress:after{animation:w-indeterminate 1.15s ease-in-out infinite}}.w-sso-conn{padding-bottom:24px}.w-sso-conn:not(:last-child){margin-bottom:24px;border-bottom:.5px solid var(--wa-border)}.w-sso-detail{display:grid;grid-template-columns:auto 1fr;gap:4px 32px}.w-sso-scim{padding-top:16px;border-top:.5px solid var(--wa-border)}.w-sso-template{padding:12px;background:var(--wa-primary-soft);border-radius:var(--wa-radius);border:.5px solid var(--wa-primary)}.w-sso-check{padding:8px 12px;background:var(--wa-surface);border-radius:var(--wa-radius);border:.5px solid var(--wa-border)}.w-sso-check-mark{min-width:12px}.w-sso-tile{display:flex;flex-direction:column;align-items:center;gap:8px;padding:14px 10px;border:.5px solid var(--wa-border);border-radius:var(--wa-radius);background:var(--wa-surface);cursor:pointer;transition:border-color .14s ease,background .14s ease}.w-sso-tile:hover{border-color:var(--wa-border-strong);background:var(--wa-surface-subtle)}.w-sso-logo{object-fit:contain;background:var(--wa-surface);padding:4px}.w-sso-logo--ph{background:var(--wa-surface)}.w-token-chip{background:var(--wa-surface-subtle);padding:2px 6px;border-radius:4px;color:var(--wa-text)}.w-disclosure{cursor:pointer;font:400 12.5px/1 var(--wa-font-sans)}.w-disclosure-caret{font-size:9px}.w-break-all{word-break:break-all}.w-col-full{grid-column:1 / -1}.dark .w-card{box-shadow:0 0 0 .5px var(--wa-border),0 2px 4px #0006,0 28px 60px -20px #000000b3}.dark .w-menu,.dark .w-pop,.dark .w-toast,.dark .w-dialog,.dark .w-combo-menu,.dark .w-country-pop{box-shadow:0 1px 2px #00000080,0 18px 44px -14px #000000b3}.dark .w-btn--secondary,.dark .w-social{box-shadow:inset 0 1px #ffffff0d,0 1px 1.5px #1414160a}.w-flex{display:flex}.w-inline{display:inline-flex}.w-items-center{align-items:center}.w-items-start{align-items:flex-start}.w-items-end{align-items:flex-end}.w-justify-start{justify-content:flex-start}.w-justify-center{justify-content:center}.w-justify-end{justify-content:flex-end}.w-justify-between{justify-content:space-between}',l4=r4`
100
100
  ${i4}
101
101
  ${o4}
102
- `,c4={display:"contents"};function d4(e){const a={};if(!e)return a;const s=(r,i)=>{if(i)for(const l in i){const m=i[l];typeof m=="string"&&m.trim()!==""&&(a[`--wa-ov-${r}-${l}`]=m)}};return s("light",e.light),s("dark",e.dark),a}function ts(){var s,r;const e=o.useContext(fr),a=(r=(s=e==null?void 0:e.deployment)==null?void 0:s.ui_settings)==null?void 0:r.theme_tokens;return o.useMemo(()=>d4(a),[a])}const Mi=o.createContext(!1),u4=o.memo(function(){return t.jsx(l4,{})});function $e({children:e,className:a,style:s,...r}){const i=o.useContext(Mi),l=ts(),[m,c]=o.useState(!1);if(o.useEffect(()=>c(!0),[]),!m)return null;const d=t.jsx("div",{...r,className:a?`wacht-root ${a}`:"wacht-root",style:{...c4,...l,...s},children:e});return i?d:t.jsxs(Mi.Provider,{value:!0,children:[t.jsx(u4,{}),d]})}function ya({length:e=6,onComplete:a,onResend:s,error:r,isSubmitting:i=!1}){const[l,m]=o.useState(new Array(e).fill("")),[c,d]=o.useState(60),[p,u]=o.useState(!1),f=o.useRef([]),h=o.useCallback(()=>{const j=setInterval(()=>{d(v=>v<=1?(u(!0),clearInterval(j),0):v-1)},1e3);return j},[]);o.useEffect(()=>{const j=h();return()=>clearInterval(j)},[h]);const g=async()=>{var j;!p||i||!s||(await s(),u(!1),d(60),m(new Array(e).fill("")),(j=f.current[0])==null||j.focus(),h())},x=(j,v)=>{var C;if(i)return;const k=j.value,N=[...l];N[v]=k.replace(/[^0-9]/g,""),m(N);const _=N.join("");_.length===e&&a(_),k&&v<e-1&&((C=f.current[v+1])==null||C.focus())},w=(j,v)=>{var k;i||j.key==="Backspace"&&!l[v]&&v>0&&((k=f.current[v-1])==null||k.focus())},b=(j,v)=>{var C,y;if(i)return;j.preventDefault();const k=j.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!k.length)return;const N=[...l];for(let E=0;E<k.length&&v+E<e;E++)N[v+E]=k[E];if(v===0&&k.length===e)for(let E=0;E<e;E++)N[E]=k[E];m(N);const _=N.join("");if(_.length===e)a(_),(C=f.current[e-1])==null||C.focus();else{const E=N.findIndex((A,H)=>H>=v&&!A);E!==-1&&((y=f.current[E])==null||y.focus())}};return t.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{className:"w-otp","data-error":r?"":void 0,children:l.map((j,v)=>t.jsx("input",{className:"w-otp-cell",type:"text",inputMode:"numeric",maxLength:1,value:j,"data-filled":j?"":void 0,onChange:k=>x(k.target,v),onKeyDown:k=>w(k,v),onPaste:k=>b(k,v),ref:k=>{f.current[v]=k},disabled:i,autoFocus:v===0},v))}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[r&&t.jsx("span",{className:"w-input-err",children:r}),s&&(p?t.jsx("button",{type:"button",className:"w-link",style:{background:"none",border:0,cursor:"pointer",fontSize:12.5},onClick:g,disabled:i,children:"Didn't receive a code? Resend"}):t.jsxs("span",{className:"w-secsub",children:["Resend code in ",c,"s"]}))]})]})}const Cc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...e,children:[t.jsx("title",{id:"githubIconTitle",children:"GitHub"}),t.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),Nc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),t.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),t.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),t.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),Sc=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...e,children:t.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),m4=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Ec=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:t.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),Ac=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),p4=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Mc=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),t.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),h4={google_oauth:{label:"Continue with Google",icon:t.jsx(Nc,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(Cc,{})},x_oauth:{label:"Continue with X",icon:t.jsx(Sc,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(m4,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(Ec,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(Ac,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(p4,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(Mc,{})}},Nr=({connections:e,callback:a})=>{const s=e.map(r=>({connection:r,config:h4[r.provider]})).filter(r=>r.config);if(!s.length)return null;if(s.length>3){const r=Math.min(s.length,4);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gap:8},children:s.map(({connection:i,config:l})=>t.jsx("button",{type:"button",className:"w-social",style:{justifyContent:"center",padding:0},onClick:()=>a(i),title:l.label,"aria-label":l.label,children:l.icon},i.provider))})}return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:s.map(({connection:r,config:i})=>t.jsxs("button",{type:"button",className:"w-social",onClick:()=>a(r),children:[i.icon,t.jsx("span",{className:"w-social-label",children:i.label})]},r.provider))})},Et=({to:e,replace:a,children:s,...r})=>{const{navigate:i}=kt(),l=o.useCallback(m=>{m.preventDefault(),i(e,{replace:a})},[e,a,i]);return t.jsx("a",{href:e||void 0,onClick:l,...r,children:s})},qt=o.forwardRef(({onFocus:e,readOnly:a,...s},r)=>{const[i,l]=o.useState(!1);return t.jsx("input",{ref:r,...s,readOnly:a||!i,onFocus:m=>{i||l(!0),e==null||e(m)}})});qt.displayName="NoPrefillInput";const Gs=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],ys=({value:e,onChange:a,error:s,countryCode:r,setCountryCode:i})=>{const[l,m]=o.useState(!1),[c,d]=o.useState(Gs.find(x=>x.code===r)||Gs[0]),p=o.useRef(null),[u,f]=o.useState(""),h=o.useRef(null);o.useEffect(()=>{function x(w){p.current&&!p.current.contains(w.target)&&m(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const g=Gs.filter(x=>x.name.toLowerCase().includes(u.toLowerCase())||x.dialCode.includes(u));return o.useEffect(()=>{i(c.dialCode)},[c,i]),t.jsxs("div",{className:"w-phone",children:[t.jsxs("div",{style:{position:"relative"},ref:p,children:[t.jsxs("button",{type:"button",className:"w-phone-cc",style:{height:"100%"},onClick:()=>m(x=>!x),children:[t.jsx("span",{children:c.flag}),t.jsx("span",{children:c.dialCode}),t.jsx(Ut,{weight:"bold"})]}),l&&t.jsxs("div",{className:"w-country-pop",children:[t.jsxs("div",{className:"w-country-search",children:[t.jsx(Ml,{}),t.jsx("input",{type:"text",placeholder:"Search country…",value:u,onChange:x=>f(x.target.value),onClick:x=>x.stopPropagation()})]}),t.jsx("div",{className:"w-country-list",children:g.map(x=>t.jsxs("button",{type:"button",className:"w-country-opt",onClick:w=>{var b;w.stopPropagation(),w.preventDefault(),d(x),m(!1),(b=h.current)==null||b.focus()},children:[t.jsx("span",{children:x.flag}),t.jsx("span",{children:x.name}),t.jsx("span",{className:"dial",children:x.dialCode})]},x.code))})]})]}),t.jsx("input",{type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:h,value:e,onChange:a,placeholder:"Phone number","aria-invalid":!!s,pattern:"^\\d{7,15}$"})]})};function Sr({placement:e="center"}){var m;const{deployment:a}=Ce(),[s,r]=o.useState(!1),i=(m=a==null?void 0:a.ui_settings)==null?void 0:m.logo_image_url;if(!i||s)return null;const l=e==="left"?"flex-start":e==="right"?"flex-end":"center";return t.jsx("div",{style:{display:"flex",justifyContent:l,width:"100%"},children:t.jsx("img",{src:i,alt:"Logo",onError:()=>r(!0),style:{maxWidth:40,maxHeight:40,width:"auto",height:"auto",objectFit:"contain"}})})}function tt({children:e,footer:a}){return t.jsxs("div",{className:"w-card w-auth-card",children:[t.jsx("div",{className:"w-create-body",children:e}),a&&t.jsx("div",{className:"w-create-foot",children:a})]})}function rt({title:e,sub:a,children:s}){return t.jsxs("div",{className:"w-auth-head",children:[t.jsx(Sr,{}),t.jsxs("div",{className:"w-auth-head-text",children:[t.jsx("h1",{className:"w-auth-title",children:e}),a&&t.jsx("p",{className:"w-auth-sub",children:a})]}),s]})}function vt({size:e=16,onAccent:a}){return t.jsx("span",{className:a?"w-spin w-spin--on-accent":"w-spin",style:{width:e,height:e}})}function js(){return t.jsx($e,{children:t.jsx("div",{className:"w-card w-auth-card",children:t.jsx("div",{className:"w-create-body",children:t.jsxs("div",{className:"w-auth-skel","aria-hidden":"true",children:[t.jsxs("div",{className:"w-auth-skel-head",children:[t.jsx("span",{className:"w-skel w-skel-avatar"}),t.jsx("span",{className:"w-skel w-skel-title"}),t.jsx("span",{className:"w-skel w-skel-sub"})]}),t.jsxs("div",{className:"w-auth-skel-fields",children:[t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsx("span",{className:"w-skel w-skel-btn"})]})]})})})})}function f4(e){const a=e.indexOf(":");return a>=0?e.slice(0,a):e}function w4(e){const a=e.trim();if(!a)return null;try{return new URL(a.includes("://")?a:`https://${a}`).hostname.toLowerCase()||null}catch{return null}}function g4(e){try{return new URL(e)}catch{if(typeof window>"u")return null;try{return new URL(e,window.location.origin)}catch{return null}}}function x4(e,a){return!e||!a?!1:e===a?!0:e.endsWith(`.${a}`)}function v4(e,a){if(!a)return!1;const s=g4(a);if(!s||s.protocol!=="https:"&&s.protocol!=="http:")return!1;if((e==null?void 0:e.mode)==="staging")return!0;if(s.protocol!=="https:"||!(e!=null&&e.frontend_host))return!1;const r=w4(f4(e.frontend_host));return r?x4(s.hostname.toLowerCase(),r):!1}function gt(e,a){return a&&v4(e,a)?a:null}const b4="https://cdn.wacht.services/captcha/wacht-challenge.min.js",Ri="wacht-challenge-script";function y4(e){const a=e.trim().replace(/\/$/,"");return a?/^https?:\/\//i.test(a)?a:`https://${a}`:""}function j4(){return document.getElementById(Ri)?Promise.resolve():new Promise((e,a)=>{const s=document.createElement("script");s.id=Ri,s.src=b4,s.async=!0,s.onload=()=>e(),s.onerror=()=>a(new Error("Failed to load challenge script")),document.head.appendChild(s)})}function Rc({apiHost:e,onSolve:a,onError:s}){const r=o.useRef(null),[i,l]=o.useState(null),m=o.useRef(a),c=o.useRef(s),d=o.useRef(!1);return m.current=a,c.current=s,o.useEffect(()=>{if(d.current)return;d.current=!0;const p=y4(e);if(!p)return;let u=!1;return(async()=>{var f;try{if(await j4(),u||!window.Cap)return;window.CAP_SILENT=!0,window.CAP_DISABLE_WIDGET_REF=!0;const h=new window.Cap({apiEndpoint:`${p}/captcha/`});r.current=h;const g=await h.solve();if(u)return;m.current(g.token)}catch(h){if(u)return;const g=h instanceof Error?h.message:"Challenge failed";l(g),(f=c.current)==null||f.call(c,"challenge_failed")}})(),()=>{var f;u=!0,(f=r.current)==null||f.reset(),r.current=null}},[e]),i?t.jsx("div",{style:{fontSize:12,color:"var(--wa-error)",marginBottom:12},children:i}):null}function _4(){var fe,ne,ae,re,Le,K,at,ze,We,Re,ce,B,q,X,oe,Ee;const{loading:e,signUp:a,signupAttempt:s,discardSignupAttempt:r}=xo(),{signIn:i}=ls("oauth"),{deployment:l}=Ce(),{navigate:m}=kt(),{session:c,refetch:d,loading:p}=ot(),[u,f]=o.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[h,g]=o.useState({}),[x,w]=o.useState(!1),[b,j]=o.useState(void 0),[v,k]=o.useState(null),[N,_]=o.useState(null),[C,y]=o.useState(!1),[E,A]=o.useState(""),H=!!E,M=((fe=l==null?void 0:l.restrictions)==null?void 0:fe.sign_up_mode)==="restricted",T=((ne=l==null?void 0:l.restrictions)==null?void 0:ne.sign_up_mode)==="waitlist",P=((re=(ae=l==null?void 0:l.auth_settings)==null?void 0:ae.multi_session_support)==null?void 0:re.enabled)??!1;o.useEffect(()=>{var z;if(!p&&(c!=null&&c.active_signin)&&!P&&!C){y(!0);let D=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));D||(D=((z=l==null?void 0:l.ui_settings)==null?void 0:z.after_signin_redirect_url)||null),!D&&(l!=null&&l.frontend_host)&&(D=`https://${l.frontend_host}`),D&&m(D)}},[c,p,P,l,m,C]),o.useEffect(()=>{var we;if(!l)return;const D=new URLSearchParams(window.location.search).get("invite_token");if(T&&!D){y(!0);const ge=((we=l.ui_settings)==null?void 0:we.waitlist_page_url)||`https://${l.frontend_host}/waitlist`;m(ge);return}D&&!v&&a&&(_(D),a.validateDeploymentInvitation(D).then(ge=>{k(ge),ge.valid&&f(xe=>({...xe,first_name:ge.first_name||xe.first_name,last_name:ge.last_name||xe.last_name,email:ge.email||xe.email}))}).catch(()=>{g(ge=>({...ge,submit:"Failed to validate invitation."}))}))},[l,T,m,v,a]);const[S,$]=o.useState(!1),[Z,R]=o.useState(""),L=z=>{let{name:D,value:we}=z.target;D==="phone_number"?we=we.replace(/[^0-9-]/g,""):D==="email"&&(we=we.toLowerCase()),f(ge=>({...ge,[D]:we})),g(ge=>({...ge,[D]:""}))},O=()=>{f({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),g({}),$(!1),R(""),r()},F=async z=>{if(z.preventDefault(),e||x)return;const D={};H||(D.submit="Challenge verification is still loading. Please try again.");const we=/^[a-zA-Z]{3,30}$/,ge=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,xe=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,lt=/^\d{7,15}$/,Qe=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(V!=null&&V.first_name.enabled&&(V!=null&&V.first_name.required&&!u.first_name?D.first_name="First name is required":u.first_name&&!we.test(u.first_name)&&(D.first_name="Invalid name")),V!=null&&V.last_name.enabled&&(V!=null&&V.last_name.required&&!u.last_name?D.last_name="Last name is required":u.last_name&&!we.test(u.last_name)&&(D.last_name="Invalid last name")),V!=null&&V.username.enabled&&(V!=null&&V.username.required&&!u.username?D.username="Username is required":u.username&&!ge.test(u.username)&&(D.username="Username must be 3-20 characters")),V!=null&&V.email_address.enabled&&(V!=null&&V.email_address.required&&!u.email?D.email="Email address is required":u.email&&!xe.test(u.email)&&(D.email="Invalid email address")),V!=null&&V.phone_number.enabled&&(V!=null&&V.phone_number.required&&!u.phone_number?D.phone_number="Phone number is required":u.phone_number&&!lt.test(u.phone_number)&&(D.phone_number="Phone number must contain 7-15 digits")),V!=null&&V.password.enabled&&(u.password?Qe.test(u.password)||(D.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):D.password="Password is required"),g(D),!(Object.keys(D).length>0)){w(!0);try{const Q={...u};u.phone_number&&b&&(Q.phone_country_code=b),N&&(Q.invite_token=N),E&&(Q.challenge_token=E),await a.create(Q)}catch(Q){g({submit:Q.message})}finally{w(!1)}}},W=async z=>{if(!(e||x||!H)){w(!0);try{const D=new URLSearchParams(window.location.search),we=gt(l,D.get("redirect_uri"))||void 0,{data:ge}=await i.create({provider:z.provider,redirectUri:we,challenge_token:E});ge&&typeof ge=="object"&&"oauth_url"in ge&&(window.location.href=ge.oauth_url)}catch(D){g({submit:D.message})}finally{w(!1)}}},U=(l==null?void 0:l.social_connections.filter(z=>z.enabled))||[],V=l==null?void 0:l.auth_settings,G=!!((Le=V==null?void 0:V.first_name)!=null&&Le.enabled&&((K=V==null?void 0:V.last_name)!=null&&K.enabled)),Y=async z=>{var we;if(z.preventDefault(),e||x)return;w(!0);const D={};if(!Z){D.otp="OTP code is required",g(D),w(!1);return}g(D);try{const ge=await a.completeVerification(Z);"data"in ge&&((we=ge.data)!=null&&we.active_signin)&&await d()}catch{g(ge=>({...ge,submit:"Verification failed. Please try again."}))}finally{w(!1)}};if(o.useEffect(()=>{var z;if(s){if(s.completed){let D=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(D||(D=((z=l==null?void 0:l.ui_settings)==null?void 0:z.after_signup_redirect_url)||null),!D&&(l!=null&&l.frontend_host)&&(D=`https://${l.frontend_host}`),D){let we;try{we=new URL(D)}catch{we=new URL(D,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&we.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(we.toString())}return}if(!S){switch(s.current_step){case"verify_email":a.prepareVerification({strategy:"email_otp",challenge_token:E});break;case"verify_phone":a.prepareVerification({strategy:"phone_otp",challenge_token:E});break}$(!0)}}},[s,a,S,l,c,m]),p||C)return t.jsx(js,{});const de=((at=l==null?void 0:l.ui_settings)==null?void 0:at.app_name)||"App";if(M)return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx(Et,{className:"w-link",to:(ze=l==null?void 0:l.ui_settings)!=null&&ze.sign_in_page_url?`${l.ui_settings.sign_in_page_url}?help=true`:"#",children:"Get help"})]}),children:[t.jsx(rt,{title:"Sign-up restricted",sub:"This app isn't open for public sign-up right now."}),t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"New account registration is currently restricted. Please check back later or contact your administrator for an invitation."})})]})});if(S){const z=(s==null?void 0:s.current_step)==="verify_phone";return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((We=l==null?void 0:l.ui_settings)==null?void 0:We.support_page_url)||"#",children:"Get help"})]}),children:[t.jsx(rt,{title:z?"Check your phone":"Enter the code",sub:z?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",children:t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:O,children:[t.jsx($l,{weight:"bold"}),z?`+${u.phone_number}`:u.email]})}),t.jsxs("form",{onSubmit:Y,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ya,{onComplete:async D=>{R(D)},onResend:async()=>{const D=z?"phone_otp":"email_otp";await a.prepareVerification({strategy:D,challenge_token:E})},error:h.otp,isSubmitting:x}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!Z,children:x&&Z?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${de}`})]})]})})}return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Already have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((Re=l==null?void 0:l.ui_settings)==null?void 0:Re.sign_in_page_url)??""}${window.location.search}`,children:"Sign in"})]}),children:[t.jsx(rt,{title:"Create your account",sub:v!=null&&v.valid?"You've been invited — complete your registration below.":"Get started in a few seconds."}),U.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Nr,{connections:U,callback:W}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})})]}),t.jsxs("form",{onSubmit:F,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[(((ce=V==null?void 0:V.first_name)==null?void 0:ce.enabled)||((B=V==null?void 0:V.last_name)==null?void 0:B.enabled))&&t.jsxs("div",{className:G?"w-grid-2":"",children:[((q=V==null?void 0:V.first_name)==null?void 0:q.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["First name",((X=V==null?void 0:V.first_name)==null?void 0:X.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"first_name",name:"first_name",autoComplete:"given-name",required:!0,minLength:3,maxLength:30,value:u.first_name,onChange:L,placeholder:"Jane","aria-invalid":!!h.first_name,pattern:"^[a-zA-Z]{3,30}$"}),h.first_name&&t.jsx("span",{className:"w-input-err",children:h.first_name})]}),((oe=V==null?void 0:V.last_name)==null?void 0:oe.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Last name",((Ee=V==null?void 0:V.last_name)==null?void 0:Ee.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"last_name",name:"last_name",autoComplete:"family-name",required:!0,minLength:3,maxLength:30,value:u.last_name,onChange:L,placeholder:"Doe","aria-invalid":!!h.last_name,pattern:"^[a-zA-Z]{3,30}$"}),h.last_name&&t.jsx("span",{className:"w-input-err",children:h.last_name})]})]}),(V==null?void 0:V.username.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Username",V.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",autoComplete:"username",minLength:3,maxLength:20,value:u.username,onChange:L,placeholder:"yourname","aria-invalid":!!h.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),h.username&&t.jsx("span",{className:"w-input-err",children:h.username})]}),(V==null?void 0:V.email_address.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Email address",V.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",maxLength:320,value:u.email,onChange:L,placeholder:"you@company.com","aria-invalid":!!h.email,required:!0,readOnly:(v==null?void 0:v.valid)&&!!(v!=null&&v.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),h.email&&t.jsx("span",{className:"w-input-err",children:h.email})]}),(V==null?void 0:V.phone_number.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Phone number",V.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(ys,{value:u.phone_number,onChange:L,error:h.phone_number,countryCode:b,setCountryCode:j}),h.phone_number&&t.jsx("span",{className:"w-input-err",children:h.phone_number})]}),(V==null?void 0:V.password.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Password",V.password.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"new-password",value:u.password,onChange:L,placeholder:"Create a password","aria-invalid":!!h.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"}),h.password&&t.jsx("span",{className:"w-input-err",children:h.password})]}),h.submit&&t.jsx("span",{className:"w-input-err",children:h.submit}),t.jsx(Rc,{apiHost:(l==null?void 0:l.backend_host)??"",onSolve:z=>A(z),onError:()=>A("")}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!H,children:x?t.jsx(vt,{size:15,onAccent:!0}):"Continue"}),(()=>{var we,ge;const z=(we=l==null?void 0:l.ui_settings)==null?void 0:we.tos_page_url,D=(ge=l==null?void 0:l.ui_settings)==null?void 0:ge.privacy_policy_url;return!z&&!D?null:t.jsxs("p",{className:"w-fineprint",children:["By continuing you agree to our"," ",z&&t.jsx(Et,{className:"w-link w-link--muted",to:z,children:"Terms of Service"}),z&&D&&" and ",D&&t.jsx(Et,{className:"w-link w-link--muted",to:D,children:"Privacy Policy"}),"."]})})()]})]})})}function Lc({icon:e,label:a,description:s,onClick:r,disabled:i,type:l="button"}){return t.jsxs("button",{type:l,className:"w-method",onClick:r,disabled:i,"data-disabled":i?"":void 0,children:[t.jsx("span",{className:"w-method-ic",children:e}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:a}),s&&t.jsx("span",{className:"w-method-desc",children:s})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Qt,{})})]})}const Pc=o.createContext(void 0);function $c(){const e=o.useContext(Pc);if(!e)throw new Error("useSignIn must be used within a SignInProvider");return e}function k4({children:e}){var j;const{deployment:a}=Ce(),[s,r]=o.useState((a==null?void 0:a.auth_settings.first_factor)||"email_password"),i=o.useRef(!!(a!=null&&a.auth_settings.first_factor)),[l,m]=o.useState(""),[c,d]=o.useState(!1),[p,u]=o.useState(!1),[f,h]=o.useState(!1),[g,x]=o.useState("identifier"),w=(a==null?void 0:a.social_connections.filter(v=>v.enabled))||[],b=a==null?void 0:a.auth_settings;return o.useEffect(()=>{var k;const v=(k=a==null?void 0:a.auth_settings)==null?void 0:k.first_factor;!i.current&&v&&(r(v),i.current=!0)},[(j=a==null?void 0:a.auth_settings)==null?void 0:j.first_factor]),t.jsx(Pc.Provider,{value:{email:l,showOtherOptions:c,showForgotPassword:p,otpSent:f,setFirstFactor:r,setEmail:m,setShowOtherOptions:d,setShowForgotPassword:u,setOtpSent:h,enabledSocialsProviders:w,authSettings:b,firstFactor:s,signInStep:g,setSignInStep:x},children:e})}const C4=[{key:"email_magic_link",icon:t.jsx(Tu,{}),label:"Magic link",description:"We'll email you a one-click sign-in link"},{key:"email_password",icon:t.jsx(Fu,{}),label:"Email and password",description:"Sign in with your email and password"},{key:"email_otp",icon:t.jsx(_l,{}),label:"Email one-time code",description:"We'll send a verification code to your email"},{key:"phone_otp",icon:t.jsx(Pu,{}),label:"Phone number",description:"We'll send a verification code via SMS"},{key:"username_password",icon:t.jsx(hs,{}),label:"Username and password",description:"Sign in with your username and password"}];function Oc(){const{deployment:e}=Ce(),{signIn:a}=ls("oauth"),{setFirstFactor:s,firstFactor:r,setShowOtherOptions:i,setSignInStep:l}=$c(),[m,c]=o.useState(!1),d=e==null?void 0:e.auth_settings,p=(e==null?void 0:e.social_connections.filter(x=>x.enabled))||[],u=async x=>{if(!m){c(!0);try{const{data:w}=await a.create({provider:x.provider});w&&typeof w=="object"&&"oauth_url"in w&&(window.location.href=w.oauth_url)}catch{}finally{c(!1)}}},f=C4.filter(x=>{if(x.key===r)return!1;const w=d==null?void 0:d.auth_factors_enabled;return w?w[x.key]:!1}),h=p.length>0,g=f.length>0;return t.jsxs(t.Fragment,{children:[h&&t.jsx(Nr,{connections:p,callback:u}),h&&g&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"or"})}),g&&t.jsx("div",{className:"w-method-stack",children:f.map(x=>t.jsx(Lc,{icon:x.icon,label:x.label,description:x.description,onClick:()=>{s(x.key),l("identifier"),i(!1)}},x.key))})]})}function N4({onBack:e}){var H;const{deployment:a}=Ce(),{navigate:s}=kt(),[r,i]=o.useState("start"),[l,m]=o.useState(""),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(""),[g,x]=o.useState(""),{forgotPassword:w,verifyOtp:b,resetPassword:j}=Po(),[v,k]=o.useState(!1),[N,_]=o.useState(null),C=async M=>{if(M.preventDefault(),!!l){k(!0),_(null);try{await w(l),i("otp")}catch(T){_(T)}finally{k(!1)}}},y=async M=>{if(M.preventDefault(),c.length===6){k(!0),_(null);try{const T=await b(l,c);T.data&&(u(T.data.token),i("reset"))}catch(T){_(T)}finally{k(!1)}}},E=async M=>{var T,P;if(M.preventDefault(),f===g&&!(f.length<8)){k(!0),_(null);try{const S=await j(p,f);if(S.data){const $=S.data,Z=$.signin_attempts&&$.signin_attempts.length>0?$.signin_attempts[$.signin_attempts.length-1]:null;if(Z&&!Z.completed){const R=(T=a==null?void 0:a.ui_settings)==null?void 0:T.sign_in_page_url;if(R){const L=new URL(R,window.location.origin);L.searchParams.set("signin_attempt_id",Z.id),s(L.toString())}else e()}else{const R=((P=a==null?void 0:a.ui_settings)==null?void 0:P.after_signin_redirect_url)||"/";s(R)}}}catch(S){_(S)}finally{k(!1)}}},A=t.jsx("span",{className:"w-auth-foot",children:t.jsx("span",{className:"w-link",style:{cursor:"pointer"},onClick:e,children:"Back to sign in"})});return t.jsxs($e,{children:[r==="start"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Forgot your password?",sub:"Reset it, or sign in another way."}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>i("email"),disabled:v,children:"Reset your password"}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsx(Oc,{}),t.jsxs("p",{className:"w-secsub",style:{textAlign:"center",marginTop:16},children:["Unable to reset password?"," ",t.jsx("a",{className:"w-link",href:((H=a==null?void 0:a.ui_settings)==null?void 0:H.support_page_url)||"#",children:"Get help"})]})]}),r==="email"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Forgot password",sub:"Enter your email and we'll send you a code to reset your password."}),t.jsxs("form",{onSubmit:C,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx("input",{className:"w-input",type:"email",id:"email",value:l,onChange:M=>m(M.target.value),placeholder:"you@company.com",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Send code"})]})]}),r==="otp"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Enter verification code",sub:`We sent a 6-digit code to ${l}.`}),t.jsxs("form",{onSubmit:y,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ya,{onComplete:M=>d(M),isSubmitting:v,error:N==null?void 0:N.message,onResend:async()=>{await w(l)}}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v||c.length!==6,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Verify"})]})]}),r==="reset"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Reset password",sub:"Create a new password for your account."}),t.jsxs("form",{onSubmit:E,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"New password"}),t.jsx("input",{className:"w-input",type:"password",id:"password",value:f,onChange:M=>h(M.target.value),placeholder:"Enter new password",required:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Confirm new password"}),t.jsx("input",{className:"w-input",type:"password",id:"confirmPassword",value:g,onChange:M=>x(M.target.value),placeholder:"Confirm new password",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Reset password"})]})]})]})}function S4({onBack:e}){var r;const{deployment:a}=Ce(),s=(r=a==null?void 0:a.ui_settings)==null?void 0:r.app_name;return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to sign in"})}),children:[t.jsx(rt,{title:"All sign-in methods",sub:`Choose another way to sign in to ${s||"your account"}`}),t.jsx(Oc,{})]})})}function Zc({methods:e,onSelectMethod:a,onBack:s}){return t.jsx($e,{children:t.jsxs(tt,{footer:s?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:s,children:"Back to login"})}):void 0,children:[t.jsx(rt,{title:"Two-factor authentication",sub:"Choose how you'd like to verify your identity"}),t.jsx("div",{className:"w-method-stack",children:e.map(r=>t.jsx(Lc,{icon:r.icon,label:r.name,description:r.phoneNumber?`${r.description} ${r.phoneNumber}`:r.description,onClick:()=>a(r.id),disabled:!r.available},r.id))})]})})}function Hc({onVerify:e,onBack:a,loading:s}){const[r,i]=o.useState(""),[l,m]=o.useState(""),c=p=>{if(p.preventDefault(),r.length!==4){m("Please enter the last 4 digits of your phone number");return}e(r)},d=p=>{const u=p.target.value.replace(/\D/g,"").slice(0,4);i(u),m("")};return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Choose a different method"})}),children:[t.jsx(rt,{title:"Verify phone",sub:"Enter the last 4 digits of your phone number."}),t.jsxs("form",{onSubmit:c,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"lastDigits",children:"Last 4 digits"}),t.jsx("input",{className:`w-input${l?" w-input--invalid":""}`,type:"text",id:"lastDigits",name:"lastDigits",value:r,onChange:d,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!l,autoFocus:!0}),l&&t.jsx("span",{className:"w-input-err",children:l})]}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:s||r.length!==4,children:s?t.jsx(vt,{onAccent:!0}):"Send code"})]})]})})}const E4=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),A4=()=>t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),t.jsx("path",{d:"M12 18h.01"})]}),M4=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})});function Fc({onBack:e,attempt:a,completeVerification:s,prepareVerification:r}){const{deployment:i}=Ce(),[l,m]=o.useState(""),[c,d]=o.useState({}),[p,u]=o.useState(!1),[f,h]=o.useState(null),[g,x]=o.useState(!0),[w,b]=o.useState(!1),[j,v]=o.useState(""),[k,N]=o.useState(!1),{navigate:_}=kt(),C=(a==null?void 0:a.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(E4,{}),available:C.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(A4,{}),available:C.includes("phone_otp"),phoneNumber:j},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(M4,{}),available:C.includes("backup_code")}].filter(P=>P.available),E=async P=>{h(P),x(!1),P==="phone_otp"&&b(!0)},A=async P=>{var S,$;if(a){u(!0);try{const Z=await r({strategy:"phone_otp",lastDigits:P});Z&&"data"in Z&&((S=Z.data)!=null&&S.otp_sent)?(($=Z.data)!=null&&$.masked_phone&&v(Z.data.masked_phone),b(!1)):d({phone:"Phone number verification failed"})}catch(Z){d({phone:Z.message})}finally{u(!1)}}},H=async(P,S)=>{if(P.preventDefault(),p)return;const $=S||l,Z={};if($?f==="authenticator"&&$.length!==6?Z.code="Authentication code must be 6 digits":f==="phone_otp"&&$.length!==6&&(Z.code="SMS code must be 6 digits"):Z.code="Verification code is required",d(Z),!(Object.keys(Z).length>0)){u(!0);try{await s($)}catch(R){d({submit:R.message})}finally{u(!1)}}},M=P=>{let S=P.target.value;f!=="backup_code"&&(S=S.replace(/\D/g,"").slice(0,6)),m(S),d($=>({...$,code:""}))};if(o.useEffect(()=>{var P;if(a.completed){N(!0);let S=gt(i,new URLSearchParams(window.location.search).get("redirect_uri"));if(S||(S=((P=i==null?void 0:i.ui_settings)==null?void 0:P.after_signin_redirect_url)||null),!S&&(i!=null&&i.frontend_host)&&(S=`https://${i.frontend_host}`),S){let $;try{$=new URL(S)}catch{$=new URL(S,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&$.searchParams.set("__dev_session__",xt(i.backend_host)||""),_($.toString())}return}},[a,i]),k)return t.jsx(js,{});if(g)return y.length===0?t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(rt,{title:"Set up two-factor authentication",sub:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."}),e&&t.jsx("div",{style:{textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to login"})})]})}):t.jsx(Zc,{methods:y,onSelectMethod:E,onBack:e});if(w&&f==="phone_otp")return t.jsx(Hc,{onVerify:A,onBack:()=>{b(!1),x(!0),h(null)},loading:p});const T=f==="authenticator"?"Enter the 6-digit code from your authenticator app":f==="phone_otp"?`Enter the 6-digit code sent to your phone ${j}`:"Enter one of your backup codes";return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(rt,{title:"Two-factor authentication",sub:T}),t.jsxs("form",{onSubmit:H,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[f==="backup_code"?t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"code",children:"Backup code"}),t.jsx("input",{className:`w-input${c.code?" w-input--invalid":""}`,type:"text",id:"code",name:"code",value:l,onChange:M,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!c.code,autoFocus:!0}),c.code&&t.jsx("span",{className:"w-input-err",children:c.code})]}):t.jsx(ya,{onComplete:async P=>{if(m(P),f!=="backup_code"){const S=new Event("submit",{bubbles:!0,cancelable:!0});await H(S,P)}},onResend:f==="phone_otp"?async()=>{try{await r({strategy:"phone_otp",lastDigits:j.slice(-4)})}catch(P){d({submit:P.message})}}:void 0,error:c.code,isSubmitting:p}),c.submit&&t.jsx("span",{className:"w-input-err",children:c.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:p||!l,children:p?t.jsx(vt,{onAccent:!0}):"Verify"})]}),t.jsxs("div",{style:{marginTop:18,textAlign:"center",display:"flex",flexDirection:"column",gap:8},children:[t.jsx("button",{type:"button",className:"w-link",onClick:()=>{x(!0),h(null),m(""),d({})},children:"Try another method"}),e&&t.jsx("button",{type:"button",className:"w-link w-link--muted",onClick:e,children:"Back to login"})]})]})})}function Tc({attempt:e,onBack:a,completeProfile:s,completeVerification:r,prepareVerification:i}){var O,F,W,U,V,G,Y,de,fe;const{deployment:l}=Ce(),{navigate:m}=kt(),[c,d]=o.useState({}),[p,u]=o.useState({}),[f,h]=o.useState("US"),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(null),[k,N]=o.useState(!1),_=j,C=w,y=()=>{var ae;N(!0);let ne=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(ne||(ne=((ae=l==null?void 0:l.ui_settings)==null?void 0:ae.after_signin_redirect_url)||null),!ne&&(l!=null&&l.frontend_host)&&(ne=`https://${l.frontend_host}`),ne){let re;try{re=new URL(ne)}catch{re=new URL(ne,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&re.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(re.toString())}},E=async ne=>{b(!0),v(null);try{await s(ne)&&y()}catch(ae){const re=ae;throw v(re),re}finally{b(!1)}},A=async ne=>{b(!0),v(null);try{return await r(ne)&&y(),!0}catch(ae){return v(ae),!1}finally{b(!1)}};if(k||!e)return t.jsx(js,{});const H=e.missing_fields||[],M=l==null?void 0:l.auth_settings,T=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||g,P=ne=>{const{name:ae,value:re}=ne.target;d(Le=>({...Le,[ae]:re})),p[ae]&&u(Le=>({...Le,[ae]:""}))},S=()=>{const ne={};return H.forEach(ae=>{var K,at,ze,We,Re;const re=c[ae];let Le=!1;switch(ae){case"first_name":Le=((K=M==null?void 0:M.first_name)==null?void 0:K.enabled)||!1;break;case"last_name":Le=((at=M==null?void 0:M.last_name)==null?void 0:at.enabled)||!1;break;case"username":Le=((ze=M==null?void 0:M.username)==null?void 0:ze.enabled)||!1;break;case"phone_number":Le=((We=M==null?void 0:M.phone_number)==null?void 0:We.enabled)||!1;break;case"email_address":Le=((Re=M==null?void 0:M.email_address)==null?void 0:Re.enabled)||!1;break;default:Le=!0}if(Le&&(!re||re.trim()==="")){const ce=ae.replace("_"," ").replace(/\b\w/g,B=>B.toUpperCase());ne[ae]=`${ce} is required`}}),c.username&&H.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(c.username)||(ne.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),c.phone_number&&H.includes("phone_number")&&(/^\d{7,15}$/.test(c.phone_number)||(ne.phone_number="Phone number must contain 7-15 digits")),c.email&&H.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(c.email)||(ne.email_address="Please enter a valid email address")),u(ne),Object.keys(ne).length===0},$=async ne=>{if(ne.preventDefault(),!S())return;const ae={...c};c.phone_number&&f&&(ae.phone_country_code=f),await E(ae)},Z=ne=>{const ae=ne.target.value;d(re=>({...re,phone_number:ae})),p.phone_number&&u(re=>({...re,phone_number:""}))},R=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(l==null?void 0:l.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]});if(T){const ne=e.current_step==="verify_phone_otp"?"Verify your phone number":"Verify your email",ae=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",re=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx($e,{children:t.jsxs(tt,{footer:R,children:[t.jsx(rt,{title:ne,sub:ae}),t.jsxs("form",{onSubmit:Le=>Le.preventDefault(),noValidate:!0,style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsx(ya,{onComplete:A,onResend:async()=>{await i({strategy:re})},error:_==null?void 0:_.message,isSubmitting:C}),_&&t.jsx("span",{className:"w-input-err",children:_.message})]}),t.jsx("div",{style:{marginTop:16,textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:()=>x(!1),children:"Back to profile completion"})})]})})}const L=!!((O=M==null?void 0:M.first_name)!=null&&O.enabled&&((F=M==null?void 0:M.last_name)!=null&&F.enabled)&&H.includes("first_name")&&H.includes("last_name"));return t.jsx($e,{children:t.jsxs(tt,{footer:a?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Back to login"})}):R,children:[t.jsx(rt,{title:"Complete your profile",sub:"Please provide the following information to continue"}),t.jsxs("form",{onSubmit:$,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(H.includes("first_name")||H.includes("last_name"))&&(((W=M==null?void 0:M.first_name)==null?void 0:W.enabled)||((U=M==null?void 0:M.last_name)==null?void 0:U.enabled))&&t.jsxs("div",{className:L?"w-grid-2":"",children:[H.includes("first_name")&&((V=M==null?void 0:M.first_name)==null?void 0:V.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",M.first_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.first_name?" w-input--invalid":""}`,type:"text",id:"first_name",name:"first_name",value:c.first_name||"",onChange:P,placeholder:"Enter your first name",disabled:C,autoComplete:"given-name"}),p.first_name&&t.jsx("span",{className:"w-input-err",children:p.first_name})]}),H.includes("last_name")&&((G=M==null?void 0:M.last_name)==null?void 0:G.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",M.last_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.last_name?" w-input--invalid":""}`,type:"text",id:"last_name",name:"last_name",value:c.last_name||"",onChange:P,placeholder:"Enter your last name",disabled:C,autoComplete:"family-name"}),p.last_name&&t.jsx("span",{className:"w-input-err",children:p.last_name})]})]}),H.includes("username")&&((Y=M==null?void 0:M.username)==null?void 0:Y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"username",children:["Username",M.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.username?" w-input--invalid":""}`,type:"text",id:"username",name:"username",value:c.username||"",onChange:P,placeholder:"Choose a username",disabled:C,autoComplete:"username"}),p.username&&t.jsx("span",{className:"w-input-err",children:p.username})]}),H.includes("phone_number")&&((de=M==null?void 0:M.phone_number)==null?void 0:de.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"phone_number",children:["Phone number",M.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(ys,{value:c.phone_number||"",onChange:Z,error:p.phone_number,countryCode:f,setCountryCode:h}),p.phone_number&&t.jsx("span",{className:"w-input-err",children:p.phone_number})]}),H.includes("email_address")&&((fe=M==null?void 0:M.email_address)==null?void 0:fe.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",M.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.email_address?" w-input--invalid":""}`,type:"email",id:"email",name:"email",value:c.email||"",onChange:P,placeholder:"Enter your email address",disabled:C,autoComplete:"email"}),p.email_address&&t.jsx("span",{className:"w-input-err",children:p.email_address})]}),_&&t.jsx("span",{className:"w-input-err",children:_.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:C,children:C?t.jsx(vt,{onAccent:!0}):"Continue"})]})]})})}function Ic({onComplete:e,onSkip:a}){var u;const[s,r]=o.useState(!1),[i,l]=o.useState(null),{registerPasskey:m}=ba(),{deployment:c}=Ce(),d=async()=>{r(!0),l(null);try{await m(),e==null||e()}catch(f){l(f instanceof Error?f.message:"Failed to register passkey")}finally{r(!1)}},p=((u=c==null?void 0:c.ui_settings)==null?void 0:u.app_name)||"this app";return t.jsxs("div",{className:"w-flex w-flex-col w-items-center w-text-center",children:[t.jsx("div",{className:"w-feature-badge",children:t.jsx(ar,{size:26})}),t.jsx("h1",{className:"w-title-lg",children:"Add a passkey"}),t.jsxs("p",{className:"w-sub",style:{marginTop:6,maxWidth:320},children:["Sign in faster and more securely with a passkey. Use your fingerprint, face, or screen lock to access ",p,"."]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,width:"100%",marginTop:24},children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:d,disabled:s,children:s?t.jsxs(t.Fragment,{children:[t.jsx(vt,{size:15,onAccent:!0}),"Registering…"]}):t.jsxs(t.Fragment,{children:[t.jsx(ar,{}),"Add passkey"]})}),t.jsx("button",{type:"button",className:"w-social",onClick:a,children:"Maybe later"})]}),i&&t.jsx("p",{className:"w-input-err",style:{marginTop:14},children:i})]})}function R4(){return t.jsx(k4,{children:t.jsx(L4,{})})}function L4(){var yt,na,ra,ia,oa,ie,ve,Ae,J,be,Je,De,jt,_t,Ke,wt,Bt,la,ca,da,Ur,Wr,Br;const{deployment:e}=Ce(),{navigate:a}=kt(),{session:s,loading:r,refetch:i,exchangeTicket:l,switchSignIn:m}=ot(),c=((na=(yt=e==null?void 0:e.auth_settings)==null?void 0:yt.multi_session_support)==null?void 0:na.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:u,showForgotPassword:f,setShowForgotPassword:h,showOtherOptions:g,setShowOtherOptions:x,enabledSocialsProviders:w,firstFactor:b,setFirstFactor:j,signInStep:v,setSignInStep:k}=$c(),{loading:N,signIn:_,signinAttempt:C,discardSignInAttempt:y,setSignInAttempt:E}=ls("generic"),{signIn:A}=ls("oauth"),{signIn:H}=ls("passkey"),[M,T]=o.useState({email:"",username:"",password:"",phone:""}),[P,S]=o.useState({}),[$,Z]=o.useState(!1),[R,L]=o.useState(""),[O,F]=o.useState("US"),[W,U]=o.useState(!1),[V,G]=o.useState(null),[Y,de]=o.useState(!1),[fe,ne]=o.useState(!1),[ae,re]=o.useState(!1),[Le,K]=o.useState(60),[at,ze]=o.useState(!1),[We,Re]=o.useState(null),[ce,B]=o.useState(""),q=!!ce,X=[...(s==null?void 0:s.signins)||[]].sort((ee,te)=>{var ue,Ze;return ee.id===((ue=s==null?void 0:s.active_signin)==null?void 0:ue.id)?-1:te.id===((Ze=s==null?void 0:s.active_signin)==null?void 0:Ze.id)?1:0});o.useEffect(()=>{const ee=new URLSearchParams(window.location.search),te=ee.get("error"),ue=ee.get("error_description");if(te==="access_denied"&&ue){G(ue),ee.delete("error"),ee.delete("error_description");const Ze=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Ze)}},[]),o.useEffect(()=>{if(b!=="email_magic_link"||!p)return;K(60),ze(!1);const ee=setInterval(()=>{K(te=>te<=1?(ze(!0),clearInterval(ee),0):te-1)},1e3);return()=>clearInterval(ee)},[b,p]),o.useEffect(()=>{var ee,te,ue,Ze;if(!r&&(s!=null&&s.active_signin)&&!c&&!W&&!Y){let Ne=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));Ne||(Ne=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!Ne&&(e!=null&&e.frontend_host)&&(Ne=`https://${e.frontend_host}`);const dt=(te=e==null?void 0:e.auth_settings)==null?void 0:te.passkey;(dt==null?void 0:dt.enabled)&&(dt==null?void 0:dt.prompt_registration_on_auth)&&!((Ze=(ue=s.active_signin)==null?void 0:ue.user)!=null&&Ze.has_passkeys)?(Re(Ne),de(!0)):Ne&&(U(!0),a(Ne))}},[s,r,c,e,a,W]);const oe=ee=>{let{name:te,value:ue}=ee.target;te==="phone"?ue=ue.replace(/[^0-9]/g,""):te==="email"&&(d(ue),ue=ue.toLowerCase()),T(Ze=>({...Ze,[te]:ue})),S(Ze=>({...Ze,[te]:""}))},Ee=()=>{T({email:"",username:"",password:"",phone:""}),S({}),F("US"),k("identifier")},z=async ee=>{if(!ee){S({email:"Email address is required"});return}if(!q){S({submit:"Challenge verification is still loading. Please try again."});return}Z(!0),S({});try{const te=await _.identify(ee,ce);if(te.strategy==="sso"&&te.connection_id){const ue=new URLSearchParams(window.location.search),Ze=gt(e,ue.get("redirect_uri"))||void 0,Ne=await _.initEnterpriseSso(te.connection_id,Ze,ce);if(Ne&&Ne.sso_url){U(!0),window.location.href=Ne.sso_url;return}}else if(te.strategy==="social"&&te.provider){const ue=w.find(Ze=>Ze.provider===te.provider);if(ue){const Ze=new URLSearchParams(window.location.search),Ne=gt(e,Ze.get("redirect_uri"))||void 0,{data:dt}=await A.create({provider:ue.provider,redirectUri:Ne,challenge_token:ce});if(dt&&typeof dt=="object"&&"oauth_url"in dt){U(!0),window.location.href=dt.oauth_url;return}}else k("password")}else k("password")}catch(te){S({submit:te.message})}finally{W||Z(!1)}},D=async ee=>{if(ee.preventDefault(),N||$)return;y();const te={};if(v==="identifier"&&b==="email_password"){if(!M.email){S({email:"Email address is required"});return}await z(M.email);return}if(v==="identifier"&&b==="username_password"){if(!M.username){S({username:"Username is required"});return}S({}),k("password");return}if(b==="email_password"?(M.email||(te.email="Email address is required"),M.password||(te.password="Password is required")):b==="username_password"?(M.username||(te.username="Username is required"),M.password||(te.password="Password is required")):b==="email_otp"||b==="email_magic_link"?M.email||(te.email="Email address is required"):b==="phone_otp"&&(M.phone?/^\d{7,15}$/.test(M.phone)||(te.phone="Phone number must contain 7-15 digits"):te.phone="Phone number is required"),S(te),Object.keys(te).length>0)return;let ue="";switch(b){case"email_password":ue="plain_email";break;case"username_password":ue="plain_username";break;case"email_otp":ue="email_otp";break;case"email_magic_link":ue="magic_link";break;case"phone_otp":ue="phone_otp";break}const Ze=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";if(!q){S({submit:"Challenge verification is still loading. Please try again."});return}Z(!0);try{const Ne={...M,strategy:ue};b==="phone_otp"&&O&&(Ne.phone_country_code=O),ce&&(Ne.challenge_token=ce),await _.create(Ne),Ze||Z(!1)}catch(Ne){S({submit:Ne.message}),Z(!1)}},we=async ee=>{if(ee.preventDefault(),N||$)return;const te={};if(!R){te.otp="OTP code is required",S(te);return}Z(!0),S({});try{await _.completeVerification(R),u(!1),L("")}catch(ue){S({otp:ue.message||"Verification failed"})}finally{Z(!1)}},ge=async ee=>{if(!(N||$||!q)){Z(!0);try{const te=new URLSearchParams(window.location.search),ue=gt(e,te.get("redirect_uri"))||void 0,{data:Ze}=await A.create({provider:ee.provider,redirectUri:ue,challenge_token:ce});Ze&&typeof Ze=="object"&&"oauth_url"in Ze&&(window.location.href=Ze.oauth_url)}catch(te){S({submit:te.message})}finally{Z(!1)}}},xe=async()=>{var ee;if(!(N||$||!q)){Z(!0),S({});try{const te=await H.create({challenge_token:ce});if("data"in te&&te.data){await i();let ue=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));ue||(ue=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!ue&&(e!=null&&e.frontend_host)&&(ue=`https://${e.frontend_host}`),U(!0),ue&&a(ue)}}catch(te){S({submit:te.message||"Passkey sign-in failed"})}finally{Z(!1)}}},lt=()=>{var ue;let ee=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(ee||(ee=((ue=e==null?void 0:e.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!ee&&(e!=null&&e.frontend_host)&&(ee=`https://${e.frontend_host}`),!ee)return null;let te;try{te=new URL(ee)}catch{te=new URL(ee,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&te.searchParams.set("__dev_session__",xt(e.backend_host)||""),te.toString()},Qe=async ee=>{if(!(N||$)){S({}),Z(!0);try{await m(ee);const te=lt();te&&(U(!0),a(te))}catch(te){S({submit:te.message||"Failed to continue with selected account"})}finally{Z(!1)}}},Q=(ee,te)=>`${ee||""} ${te||""}`.trim().split(" ").filter(Boolean).map(ue=>ue[0]).join("").toUpperCase().slice(0,2)||"?",le=o.useRef(!1);if(o.useEffect(()=>{if(r)return;const ee=new URLSearchParams(window.location.search),te=ee.get("ticket");if(te&&!le.current&&!N){le.current=!0,ee.delete("ticket");const Ze=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Ze),(async()=>{var dt;try{Z(!0),await l(te),U(!0);let It=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(It||(It=((dt=e==null?void 0:e.ui_settings)==null?void 0:dt.after_signin_redirect_url)||null),!It&&(e!=null&&e.frontend_host)&&(It=`https://${e.frontend_host}`),It){let Ns;try{Ns=new URL(It)}catch{Ns=new URL(It,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Ns.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(Ns.toString())}return}catch(It){S({submit:It.message||"Failed to exchange ticket"}),le.current=!1}finally{Z(!1)}})();return}const ue=ee.get("signin_attempt_id");if(ue&&(s!=null&&s.signin_attempts)&&!C){const Ze=s.signin_attempts.find(Ne=>Ne.id===ue);if(Ze){E(Ze),ee.delete("signin_attempt_id");const Ne=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Ne)}}},[s,r,C,E,N]),o.useEffect(()=>{var Ze;if(!C)return;if(C.completed){U(!0);let Ne=new URLSearchParams(window.location.search).get("redirect_uri");if(Ne||(Ne=((Ze=e==null?void 0:e.ui_settings)==null?void 0:Ze.after_signin_redirect_url)||null),!Ne&&(e!=null&&e.frontend_host)&&(Ne=`https://${e.frontend_host}`),Ne){let dt;try{dt=new URL(Ne)}catch{dt=new URL(Ne,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&dt.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(dt.toString())}return}if(!_||p)return;const te={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[C.current_step];if(!te)return;(async()=>{try{await _.prepareVerification({strategy:te,challenge_token:ce}),Z(!1),u(!0)}catch{S({submit:"Failed to send verification. Please try again."}),Z(!1)}})()},[C,_,p,u,a,e]),g)return t.jsx(S4,{onBack:()=>x(!1)});if(f)return t.jsx(N4,{onBack:()=>h(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return t.jsx(Fc,{attempt:C,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),Ee(),u(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return t.jsx(Tc,{attempt:C,completeProfile:_.completeProfile,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),Ee(),u(!1)}});if(Y){const ee=()=>{de(!1),We&&(U(!0),a(We))},te=()=>{de(!1),We&&(U(!0),a(We))};return t.jsx($e,{children:t.jsx(tt,{children:t.jsx(Ic,{onComplete:ee,onSkip:te})})})}if(r||W)return t.jsx(js,{});const me=((ra=e==null?void 0:e.ui_settings)==null?void 0:ra.app_name)||"App",Pe=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&p,qe=b==="email_magic_link",pt=c&&!Pe&&X.length>0&&!ae,aa=()=>{u(!1),y(),Ee()};let Tt;if(Pe){const ee=b==="phone_otp"?"Check your phone":qe?"Check your inbox":"Enter the code",te=qe?"We sent a magic link to your email — click it to sign in instantly.":b==="phone_otp"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",ue=(b==="email_otp"||qe)&&M.email?M.email:b==="phone_otp"&&M.phone?`+${M.phone}`:null;Tt=t.jsx(rt,{title:ee,sub:te,children:ue&&t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:aa,children:[t.jsx($l,{weight:"bold"}),ue]})})}else Tt=t.jsx(rt,{title:"Sign in to your account",sub:`Please enter your details to continue to ${me}.`});let sa;Pe?sa=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((ia=e==null?void 0:e.ui_settings)==null?void 0:ia.support_page_url)||"#",children:"Get help"})]}):sa=t.jsxs("span",{className:"w-auth-foot",children:["Don't have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((oa=e==null?void 0:e.ui_settings)==null?void 0:oa.sign_up_page_url)??""}${window.location.search}`,children:"Sign up"})]});let Wt;if(Pe&&qe)Wt=t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,padding:"12px 0 4px"},children:at?t.jsx("button",{type:"button",className:"w-link w-linkbtn",onClick:async()=>{ze(!1),K(60);try{await _.prepareVerification({strategy:"magic_link",challenge_token:ce})}catch{}},children:"Resend magic link"}):t.jsxs("span",{className:"w-secsub",children:["Resend in ",Le,"s"]})});else if(Pe)Wt=t.jsxs("form",{onSubmit:we,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ya,{onComplete:async ee=>{if(L(ee),ee&&ee.length===6){Z(!0),S({});try{await _.completeVerification(ee),u(!1)}catch(te){S({otp:te.message||"Verification failed"})}finally{Z(!1)}}},onResend:async()=>{const ee=b==="email_otp"?"email_otp":"phone_otp";await _.prepareVerification({strategy:ee,challenge_token:ce})},error:P.otp,isSubmitting:$}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N||!R,children:$&&R?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${me}`})]});else{const ee=(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((ve=(ie=e==null?void 0:e.auth_settings)==null?void 0:ie.email_address)==null?void 0:ve.enabled),te=b==="username_password"&&((J=(Ae=e==null?void 0:e.auth_settings)==null?void 0:Ae.username)==null?void 0:J.enabled),ue=b==="phone_otp"&&((Je=(be=e==null?void 0:e.auth_settings)==null?void 0:be.phone_number)==null?void 0:Je.enabled),Ze=v==="password"&&(b==="email_password"||b==="username_password")&&((jt=(De=e==null?void 0:e.auth_settings)==null?void 0:De.password)==null?void 0:jt.enabled);Wt=t.jsxs(t.Fragment,{children:[w.length>0&&t.jsx(Nr,{connections:w,callback:ge}),((Ke=(_t=e==null?void 0:e.auth_settings)==null?void 0:_t.passkey)==null?void 0:Ke.enabled)&&t.jsxs("button",{type:"button",className:"w-social",style:{marginTop:w.length>0?10:0},onClick:xe,disabled:$,children:[t.jsx(ar,{}),t.jsx("span",{children:"Sign in with a passkey"})]}),(w.length>0||((Bt=(wt=e==null?void 0:e.auth_settings)==null?void 0:wt.passkey)==null?void 0:Bt.enabled))&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsxs("form",{onSubmit:D,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[ee&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Email address"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&b==="email_password"&&M.email?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:M.email}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>k("identifier"),children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",value:M.email,onChange:oe,placeholder:"you@company.com","aria-invalid":!!P.email}),P.email&&t.jsx("span",{className:"w-input-err",children:P.email})]}),te&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Username"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&M.username?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:M.username}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>{k("identifier"),T(Ne=>({...Ne,password:""}))},children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",value:M.username,onChange:oe,placeholder:"yourname","aria-invalid":!!P.username,autoComplete:"username"}),P.username&&t.jsx("span",{className:"w-input-err",children:P.username})]}),ue&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(ys,{value:M.phone,onChange:oe,error:P.phone,countryCode:O,setCountryCode:F}),P.phone&&t.jsx("span",{className:"w-input-err",children:P.phone})]}),Ze&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{className:"w-label",children:"Password"}),t.jsx("span",{className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer"},onClick:()=>h(!0),children:"Forgot?"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"current-password",value:M.password,onChange:oe,placeholder:"••••••••","aria-invalid":!!P.password}),P.password&&t.jsx("span",{className:"w-input-err",children:P.password})]}),P.submit&&t.jsx("span",{className:"w-input-err",children:P.submit}),t.jsx(Rc,{apiHost:(e==null?void 0:e.backend_host)??"",onSolve:Ne=>B(Ne),onError:()=>B("")}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N||!q,children:$?t.jsx(vt,{size:15,onAccent:!0}):t.jsxs(t.Fragment,{children:[v==="identifier"?"Continue":"Sign in",t.jsx(Qt,{weight:"bold"})]})}),v==="password"&&((ca=(la=e==null?void 0:e.auth_settings)==null?void 0:la.auth_factors_enabled)==null?void 0:ca.email_otp)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-or",style:{margin:"5px 0"},children:t.jsx("span",{children:"OR"})}),t.jsxs("button",{type:"button",className:"w-method",disabled:$,onClick:async()=>{Z(!0),S({});try{await _.create({email:M.email,strategy:"email_otp",challenge_token:ce}),j("email_otp")}catch(Ne){S({submit:Ne.message}),Z(!1)}},children:[t.jsx("span",{className:"w-method-ic",children:t.jsx(_l,{})}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:"Sign in with a code"}),t.jsx("span",{className:"w-method-desc",children:"We'll send a 6-digit code to your email"})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Qt,{})})]})]})]})]})}return t.jsx($e,{children:t.jsxs(tt,{footer:sa,children:[Tt,V&&t.jsxs("div",{className:"w-banner w-banner--error",style:{marginBottom:18},children:[t.jsx(Fa,{weight:"fill"}),t.jsxs("span",{className:"w-banner-txt",children:[t.jsx("strong",{children:"Access denied."})," ",V," ",t.jsx("span",{className:"w-link",onClick:()=>G(null),children:"Try again"})]})]}),pt&&(fe?t.jsxs("div",{className:"w-acct-list",children:[t.jsx("div",{className:"w-secsub w-acct-list-head",children:"Choose an account"}),t.jsxs("div",{className:"w-acct-list-body",children:[X.map(ee=>{var te,ue,Ze,Ne;return t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>Qe(ee.id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:ee.user.has_profile_picture?t.jsx("img",{src:ee.user.profile_picture_url,alt:((te=ee.user.primary_email_address)==null?void 0:te.email)||"account"}):Q(ee.user.first_name,ee.user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsx("span",{className:"w-acct-name",children:ee.user.first_name&&ee.user.last_name?`${ee.user.first_name} ${ee.user.last_name}`:ee.user.first_name||((Ze=(ue=ee.user.primary_email_address)==null?void 0:ue.email)==null?void 0:Ze.split("@")[0])||"Account"}),t.jsx("span",{className:"w-secsub",children:(Ne=ee.user.primary_email_address)==null?void 0:Ne.email})]}),t.jsx(Qt,{className:"w-acct-go"})]},ee.id)}),t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>{ne(!1),re(!0),Ee()},children:[t.jsx("span",{className:"w-avatar",style:{background:"var(--wa-surface-subtle)",color:"var(--wa-text-muted)"},children:t.jsx(Wu,{size:16})}),t.jsx("span",{className:"w-acct-text w-acct-name",children:"Use a different account"}),t.jsx(Qt,{className:"w-acct-go"})]})]})]}):t.jsxs("button",{type:"button",className:"w-acct","data-active":!0,style:{marginBottom:18},onClick:()=>Qe(X[0].id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:X[0].user.has_profile_picture?t.jsx("img",{src:X[0].user.profile_picture_url,alt:((da=X[0].user.primary_email_address)==null?void 0:da.email)||"account"}):Q(X[0].user.first_name,X[0].user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsxs("span",{className:"w-acct-name",children:["Welcome back,"," ",X[0].user.first_name||((Wr=(Ur=X[0].user.primary_email_address)==null?void 0:Ur.email)==null?void 0:Wr.split("@")[0])||"back"]}),t.jsx("span",{className:"w-secsub",children:(Br=X[0].user.primary_email_address)==null?void 0:Br.email})]}),t.jsx("span",{className:"w-link w-link--muted w-link--sm",style:{flex:"none"},onClick:ee=>{ee.stopPropagation(),X.length>1?ne(!0):(re(!0),Ee())},children:"Not you?"})]})),Wt]})})}function P4(){var b,j,v,k,N,_,C,y,E,A,H,M;const{deployment:e}=Ce(),{loading:a,joinWaitlist:s}=Mo(),[r,i]=o.useState({first_name:"",last_name:"",email:""}),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(null),f=()=>{if(p)return p.message},h=e==null?void 0:e.auth_settings,g=!!((b=h==null?void 0:h.first_name)!=null&&b.enabled&&((j=h==null?void 0:h.last_name)!=null&&j.enabled)),x=T=>{const{name:P,value:S}=T.target;i($=>({...$,[P]:S}))},w=async T=>{if(T.preventDefault(),!!h){d(!0),u(null);try{(await s(r)).data&&m(!0)}catch(P){u(P)}finally{d(!1)}}};return l?t.jsx($e,{children:t.jsx(tt,{children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,textAlign:"center"},children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{weight:"bold"})})]}),t.jsx("h1",{className:"w-auth-title",children:"You're on the waitlist"}),t.jsxs("p",{className:"w-auth-sub",children:["Thanks for your interest! We'll notify you at"," ",r.email," when we're ready for you to join."]})]})})}):t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx("a",{href:"/contact",className:"w-link",children:"Get help"})]}),children:[t.jsx(rt,{title:"Join the waitlist",sub:"Be the first to know when we launch!"}),t.jsxs("form",{onSubmit:w,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(((v=h==null?void 0:h.first_name)==null?void 0:v.enabled)||((k=h==null?void 0:h.last_name)==null?void 0:k.enabled))&&t.jsxs("div",{className:g?"w-grid-2":"",children:[((N=h==null?void 0:h.first_name)==null?void 0:N.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",((_=h==null?void 0:h.first_name)==null?void 0:_.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"first_name",name:"first_name",required:(C=h==null?void 0:h.first_name)==null?void 0:C.required,minLength:2,maxLength:50,value:r.first_name,onChange:x,placeholder:"First name"})]}),((y=h==null?void 0:h.last_name)==null?void 0:y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",((E=h==null?void 0:h.last_name)==null?void 0:E.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"last_name",name:"last_name",required:(A=h==null?void 0:h.last_name)==null?void 0:A.required,minLength:2,maxLength:50,value:r.last_name,onChange:x,placeholder:"Last name"})]})]}),t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",((H=h==null?void 0:h.email_address)==null?void 0:H.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"email",id:"email",name:"email",required:(M=h==null?void 0:h.email_address)==null?void 0:M.required,value:r.email,onChange:x,placeholder:"Enter your email address"})]}),f()&&t.jsx("span",{className:"w-input-err",children:f()}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:c||a,children:c||a?t.jsx(vt,{onAccent:!0}):"Join waitlist"})]})]})})}function On({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx($e,{children:t.jsxs(tt,{footer:l,children:[t.jsx(rt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function $4(){const{deployment:e}=Ce(),{navigate:a}=kt(),{error:s,session:r,processed:i,signinAttempt:l,redirectUri:m,loading:c}=Ro(),[d,p]=o.useState(!1),[u,f]=o.useState(null),h=()=>{window.location.reload()},g=()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||"/sign-in";a(b)},x=()=>{p(!1),u&&a(u)},w=()=>{p(!1),u&&a(u)};if(o.useEffect(()=>{var b,j,v,k,N;if(!(!i||c||d)){if(l&&!l.completed){const _=(b=e==null?void 0:e.ui_settings)==null?void 0:b.sign_in_page_url;if(_){const C=new URL(_,window.location.origin);C.searchParams.set("signin_attempt_id",l.id),m&&C.searchParams.set("redirect_uri",m),a(C.toString())}return}if(l!=null&&l.completed){const C=gt(e,m)||((j=e==null?void 0:e.ui_settings)==null?void 0:j.after_signin_redirect_url)||(e==null?void 0:e.frontend_host)||"/";let y;try{y=new URL(C)}catch{y=new URL(C,window.location.origin)}if(y){(e==null?void 0:e.mode)==="staging"&&y.searchParams.set("__dev_session__",xt(e.backend_host)||"");const E=(v=e==null?void 0:e.auth_settings)==null?void 0:v.passkey;(E==null?void 0:E.enabled)&&(E==null?void 0:E.prompt_registration_on_auth)&&!((N=(k=r==null?void 0:r.active_signin)==null?void 0:k.user)!=null&&N.has_passkeys)?(f(y.toString()),p(!0)):a(y.toString())}}}},[r,i,c,m,e,l,a]),o.useEffect(()=>{s&&s.message.includes("No OAuth callback data found")&&setTimeout(()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||(e==null?void 0:e.frontend_host);b&&a(b)},2e3)},[s,e,a]),d)return t.jsx($e,{children:t.jsx(tt,{children:t.jsx(Ic,{onComplete:x,onSkip:w})})});if(r&&i&&!s)return t.jsx(On,{title:"Success",sub:"Authentication completed successfully",icon:t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{weight:"bold"})})]}),message:"You'll be redirected to your destination shortly."});if(s){const b=s.message.includes("No OAuth callback data found");return t.jsx(On,{title:"Something went wrong",sub:"We couldn't complete your sign in",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(La,{weight:"bold"})})]}),message:s.message||"An unexpected error occurred during authentication.",action:b?void 0:t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:h,children:"Try again"}),footer:b?void 0:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:g,children:"Return to sign in"})]})})}return t.jsx(On,{title:"Completing sign in",sub:"Please wait while we authenticate you",icon:t.jsx(vt,{size:32}),message:"Verifying your credentials… this will only take a moment."})}function O4({onSuccess:e,onError:a}={}){const[s,r]=o.useState("loading"),[i,l]=o.useState(""),{token:m,attempt:c,redirectUri:d}=Q1(),{verifyMagicLink:p}=Lo(),{navigate:u}=kt(),{deployment:f}=Ce(),h=o.useRef(!1);o.useEffect(()=>{(async()=>{if(!h.current){if(!m||!c){r("error"),l("The magic link appears to be malformed. Please try signing in again."),a==null||a("Invalid magic link parameters");return}h.current=!0,r("loading"),l("Please wait while we verify your magic link.");try{await p({token:m,attempt:c,redirectUri:d}),r("success"),l("You will be redirected to your account shortly."),e==null||e(),setTimeout(()=>{var b;let w=gt(f,d);if(w||(w=(b=f==null?void 0:f.ui_settings)==null?void 0:b.after_signin_redirect_url),!w&&(f!=null&&f.frontend_host)&&(w=`https://${f.frontend_host}`),w){const j=new URL(w);(f==null?void 0:f.mode)==="staging"&&j.searchParams.set("__dev_session__",xt(f.backend_host)||""),u(j.toString())}},2e3)}catch(w){r("error"),l("The magic link may have expired or already been used. Please try signing in again."),a==null||a(w.message)}}})()},[m,c]);const g=()=>{var x;(x=f==null?void 0:f.ui_settings)!=null&&x.sign_in_page_url&&u(f.ui_settings.sign_in_page_url)};return t.jsx($e,{children:t.jsxs(tt,{children:[t.jsx(rt,{title:"Magic link",sub:"Verifying your magic link"}),t.jsxs("div",{className:"w-auth-status",children:[s==="loading"&&t.jsx(vt,{size:32}),s==="success"&&t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{weight:"bold"})})]}),s==="error"&&t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(La,{weight:"bold"})})]}),t.jsx("p",{className:"w-auth-sub",children:i}),s==="error"&&t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:g,children:"Try again"})]})]})})}function Z4(e){var r,i;return e?((r=e.signin_attempts)==null?void 0:r.find(l=>l.requires_completion&&!l.completed))?!0:!!((i=e.signup_attempts)==null?void 0:i.find(l=>{var m,c;return((m=l.missing_fields)==null?void 0:m.length)>0||((c=l.remaining_steps)==null?void 0:c.length)>0&&!l.completed})):!1}function H4(e){const a=e?`/profile-completion?redirect_uri=${encodeURIComponent(e)}`:"/profile-completion";window.location.href=a}function ns({kind:e}){const a=e==="success"?"w-success":e==="error"?"w-success w-success--error":"w-success w-success--info",s=e==="success"?Ye:e==="error"?La:Hu;return t.jsxs("div",{className:a,children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(s,{weight:"bold"})})]})}function _a({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx($e,{children:t.jsxs(tt,{footer:l,children:[t.jsx(rt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function F4({token:e,onSuccess:a,onError:s}){var b;const{acceptInvitation:r,invitationData:i,loading:l,error:m}=Vo(),{navigate:c}=kt(),{deployment:d}=Ce(),p=o.useRef(!1),u=()=>{var v;const j=new URLSearchParams(window.location.search);return{token:e||j.get("invite_token")||j.get("token"),redirectUri:gt(d,j.get("redirect_uri"))||((v=d==null?void 0:d.ui_settings)==null?void 0:v.after_signin_redirect_url)||"/"}};o.useEffect(()=>{if(p.current)return;const{token:j}=u();j&&(p.current=!0,r(j))},[r]),o.useEffect(()=>{var j;i&&(i.organization&&!i.requires_signin&&a&&a(i.organization.id,(j=i.workspace)==null?void 0:j.id),i.error_code&&s&&s(i.message||"Failed to accept invitation"))},[i,a,s]);const f=()=>{const{redirectUri:j}=u();c(j)},h=()=>{var E,A;const{token:j}=u(),v=((E=d==null?void 0:d.ui_settings)==null?void 0:E.sign_in_page_url)||"/sign-in",k=((A=d==null?void 0:d.ui_settings)==null?void 0:A.sign_up_page_url)||"/sign-up",N=new URLSearchParams;j&&N.set("invite_token",j),i!=null&&i.invited_email&&N.set("invited_email",i.invited_email);const C=`${window.location.pathname}?token=${j}`;N.set("redirect_uri",C),i!=null&&i.message&&N.set("message",i.message);const y=(i==null?void 0:i.error_code)==="INVITATION_REQUIRES_SIGNUP";c(`${y?k:v}?${N.toString()}`)},g=()=>{const{token:j}=u();j&&(p.current=!1,r(j))},x=(j,v)=>t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:v,children:j}),{token:w}=u();if(!w&&!l)return t.jsx(_a,{title:"Invalid invitation",sub:"No invitation token found",icon:t.jsx(ns,{kind:"error"}),message:"The invitation link appears to be invalid or incomplete.",action:x("Go to home",()=>c("/"))});if(l)return t.jsx(_a,{title:"Processing invitation",sub:"Please wait while we verify your invitation",icon:t.jsx(vt,{size:32}),message:"Verifying invitation… this will only take a moment."});if(i!=null&&i.organization&&!i.requires_signin)return t.jsx(_a,{title:"Invitation accepted",sub:"You've successfully joined the organization",icon:t.jsx(ns,{kind:"success"}),message:t.jsxs(t.Fragment,{children:["Welcome to"," ",t.jsx("strong",{children:i.organization.name}),i.workspace?`. You've been added to the ${i.workspace.name} workspace.`:"."]}),action:x("Continue to application",f)});if(i!=null&&i.already_member)return t.jsx(_a,{title:"Already a member",sub:"You're already part of this organization",icon:t.jsx(ns,{kind:"info"}),message:`You're already a member of ${((b=i.organization)==null?void 0:b.name)||"this organization"}. No action needed.`,action:x("Continue to application",f)});if(i!=null&&i.requires_signin){const j=i.error_code==="INVITATION_REQUIRES_SIGNUP";return t.jsx(_a,{title:j?"Sign up required":"Sign in required",sub:"To accept this invitation",icon:t.jsx(ns,{kind:"info"}),message:t.jsxs(t.Fragment,{children:["This invitation is for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email}),"."," ",j?"Create an account with this email address to accept it.":i.error_code==="INVITATION_EMAIL_MISMATCH"?"You're signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."]}),action:x(j?"Sign up to accept":"Sign in to accept",h)})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?t.jsx(_a,{title:"Invitation expired",sub:"This invitation is no longer valid",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Lu,{weight:"bold"})})]}),message:t.jsxs(t.Fragment,{children:["Invitation for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email})," ","has expired. Invitations are valid for 10 days — please request a new one from your organization administrator."]})}):m||i!=null&&i.error_code?t.jsx(_a,{title:"Invitation error",sub:"Unable to process invitation",icon:t.jsx(ns,{kind:"error"}),message:(i==null?void 0:i.message)||m||"Failed to accept invitation",action:x("Try again",g),footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:h,children:"Sign in manually"})]})}):null}const Vc=o.createContext(void 0),zc=()=>{const e=o.useContext(Vc);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},T4=({isOpen:e,onClose:a,children:s})=>{const[r,i]=o.useState(!1),l=ts();return o.useEffect(()=>{i(!0);const m=c=>{c.key==="Escape"&&e&&(a==null||a())};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[e,a]),!e||!r?null:en.createPortal(t.jsx("div",{className:"wacht-root",style:l,children:t.jsx(Vc.Provider,{value:{isOpen:e,onClose:a},children:s})}),document.body)},I4=({children:e})=>{const{onClose:a}=zc(),s=o.useRef(null),r=i=>{s.current&&!s.current.contains(i.target)&&(a==null||a())};return t.jsx("div",{className:"w-modal",onClick:r,children:t.jsx("div",{ref:s,style:{maxWidth:"100%",minWidth:0},children:e})})},V4=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog${s?` ${s}`:""}`,style:{maxHeight:"90vh",overflowY:"auto",...a},children:e}),z4=({children:e,showCloseButton:a=!0})=>{const{onClose:s}=zc();return t.jsxs("div",{className:"w-dialog-head",children:[typeof e=="string"?t.jsx("h2",{className:"w-dialog-title",children:e}):e,a&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:s,children:t.jsx(La,{size:18})})]})},D4=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog-body${s?` ${s}`:""}`,style:a,children:e}),U4=({children:e})=>t.jsx("div",{className:"w-dialog-foot",children:e}),Ue=Object.assign(T4,{Overlay:I4,Content:V4,Header:z4,Body:D4,Footer:U4}),W4=({isOpen:e,onClose:a,title:s,children:r,showCloseButton:i=!0})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{children:[s&&t.jsx(Ue.Header,{showCloseButton:i,children:s}),t.jsx(Ue.Body,{children:r})]})})}),B4=({trigger:e,renderDialog:a})=>{const[s,r]=o.useState(!1),i=()=>r(!0),l=()=>r(!1);return t.jsxs(t.Fragment,{children:[e({onClick:i}),a({isOpen:s,onClose:l})]})},Dc=o.createContext(void 0),Uc=()=>{const e=o.useContext(Dc);if(!e)throw new Error("useDropdownContext must be used within a DropdownProvider");return e},_s=({children:e,open:a,openChange:s,style:r})=>{const i=o.useRef(null),[l,m]=o.useState(!1);return o.useEffect(()=>{const c=d=>{i.current&&!i.current.contains(d.target)&&m(!1)};return l&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[l,s]),o.useEffect(()=>{s==null||s(l)},[l]),o.useEffect(()=>{m(!!a)},[a]),t.jsx(Dc.Provider,{value:{open:l,openChange:c=>m(c)},children:t.jsx("div",{style:{width:"fit-content",...r},ref:i,children:e})})},ks=({children:e,style:a,className:s})=>{const{open:r}=Uc(),[i,l]=o.useState({top:0,left:0}),[m,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{r&&d.current?(c(!1),requestAnimationFrame(()=>{var f,h;const p=(f=d.current)==null?void 0:f.parentElement;if(!p)return;const u=p.querySelector("[data-dropdown-trigger]")||p.firstElementChild;if(u&&u!==d.current){const g=u.getBoundingClientRect(),x=(h=d.current)==null?void 0:h.getBoundingClientRect(),w=window.innerWidth,b=window.innerHeight;let j=g.bottom+4,v=g.right-((x==null?void 0:x.width)||200);v<8&&(v=g.left),v+((x==null?void 0:x.width)||200)>w-8&&(v=w-((x==null?void 0:x.width)||200)-8),x&&j+x.height>b-8&&(j=g.top-(x.height+4)),l({top:j,left:v}),c(!0)}})):c(!1)},[r]),r?t.jsx("div",{className:s?`w-menu ${s}`:"w-menu",ref:d,style:{position:"fixed",zIndex:1e3,width:"max-content",minWidth:140,maxWidth:240,...a,top:`${i.top}px`,left:`${i.left}px`,visibility:m?"visible":"hidden",opacity:m?1:0,transition:m?"opacity 0.15s ease-in-out":"none"},children:e}):null},Cs=({children:e})=>{const{openChange:a,open:s}=Uc(),r=o.useCallback(()=>{a(!s)},[s,a]);return t.jsx("div",{style:{position:"relative",display:"inline-flex"},onClick:r,"data-dropdown-trigger":!0,children:e})},ea=o.forwardRef(({$destructive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:`w-menu-item${e?" w-menu-item--danger":""}${a?` ${a}`:""}`,...s}));ea.displayName="DropdownItem";const Wc=()=>t.jsx("div",{style:{height:"0.5px",background:"var(--wa-border)",width:"100%",margin:"4px 0"}}),Bc=o.forwardRef(({className:e,style:a,...s},r)=>t.jsx("form",{ref:r,className:e,style:{display:"flex",flexDirection:"column",gap:16,...a},...s}));Bc.displayName="Form";const Ge=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:`w-field${e?` ${e}`:""}`,...a}));Ge.displayName="FormGroup";const Ve=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:`w-label${e?` ${e}`:""}`,...a}));Ve.displayName="Label";const ye=o.forwardRef(({as:e="input",className:a,...s},r)=>{const i=`w-input${a?` ${a}`:""}`;return e==="textarea"?t.jsx("textarea",{className:i,...s}):t.jsx("input",{ref:r,className:i,...s})});ye.displayName="Input";const _e=({size:e,className:a})=>t.jsx("div",{className:a,style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:e?`${e}px`:"100%"},children:t.jsx("span",{className:"w-spin",style:{width:e??40,height:e??40}})}),Za=({checked:e,onChange:a})=>t.jsxs("label",{className:"w-switch","data-on":e?"":void 0,children:[t.jsx("input",{type:"checkbox",checked:e,onChange:s=>a(s.target.checked),style:{position:"absolute",opacity:0,width:0,height:0}}),t.jsx("span",{className:"w-switch-track",children:t.jsx("span",{className:"w-switch-knob"})})]}),Kt=(e=!1)=>{const[a,s]=o.useState(e),r=o.useCallback(()=>{s(!0)},[]),i=o.useCallback(()=>{s(!1)},[]),l=o.useCallback(()=>{s(m=>!m)},[]);return{isOpen:a,open:r,close:i,toggle:l}},Gc=({onChange:e,placeholder:a,value:s})=>t.jsxs("div",{className:"w-search",children:[t.jsx(Ml,{}),t.jsx("input",{type:"text",placeholder:a,value:s,onChange:r=>e(r.target.value)})]}),se=o.forwardRef(({$primary:e,$outline:a,$destructive:s,$fullWidth:r,$size:i,className:l,style:m,...c},d)=>{const f=`w-btn ${s?"w-btn--danger-solid":a?"w-btn--secondary":"w-btn--primary"}${i==="sm"?" w-btn--sm":i==="lg"?" w-btn--lg":""}${l?` ${l}`:""}`;return t.jsx("button",{ref:d,className:f,style:r?{width:"100%",...m}:m,...c})});se.displayName="Button";const qc=e=>({position:"absolute",top:"calc(100% + 6px)",left:0,width:"100%",maxHeight:260,overflowY:"auto",zIndex:1e3,opacity:e?1:0,transform:e?"scale(1)":"scale(0.97)",transformOrigin:"top",pointerEvents:e?"auto":"none",transition:"opacity 0.15s ease, transform 0.15s ease"}),Kc={width:"100%",height:32,padding:"0 9px",border:"none",borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,fontFamily:"var(--wa-font-sans)",fontSize:13,outline:"none",background:"transparent",color:"var(--wa-text)",marginBottom:4},Qs=({children:e})=>t.jsx("div",{style:{padding:"10px 9px",color:"var(--wa-text-faint)",fontFamily:"var(--wa-font-sans)",fontSize:12.5,textAlign:"center"},children:e}),un=({options:e,value:a,onChange:s,placeholder:r="Select an option",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).find(y=>y.value===a),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(s(y),h(!1),x(""))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k?void 0:"",children:k?k.label:r}),f?t.jsx(al,{size:16}):t.jsx(Ut,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:qc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Kc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Qs,{children:"No options available"}):y.options.map(A=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":A.disabled?"":void 0,onClick:()=>_(A.value,A.disabled),role:"option","aria-selected":A.value===a,children:[A.label,A.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},A.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":y.value===a,children:[y.label,y.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a||""})]})},Yc=({options:e,value:a,onChange:s,placeholder:r="Select options",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).filter(y=>a.includes(y.value)),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(a.includes(y)?s(a.filter(A=>A!==y)):s([...a,y]))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k.length>0?void 0:"",children:k.length>0?k.map(y=>y.label).join(", "):r}),f?t.jsx(al,{size:16}):t.jsx(Ut,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:qc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Kc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Qs,{children:"No options available"}):y.options.map(A=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":A.disabled?"":void 0,onClick:()=>_(A.value,A.disabled),role:"option","aria-selected":a.includes(A.value),children:[A.label,a.includes(A.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},A.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":a.includes(y.value),children:[y.label,a.includes(y.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a.join(",")})]})},Os=e=>e.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)||"?",Li=e=>e.trim().replace(/[<>"'&]/g,""),G4=e=>e.length>=2&&e.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(e),q4=e=>/.+@.+\..+/.test(e),Pi=(e,a)=>e.length?e.find(s=>s.name===a)||e[0]:null,K4=({roles:e,value:a,onChange:s,fullWidth:r})=>{const[i,l]=o.useState(!1),m=o.useRef(null);return o.useEffect(()=>{if(!i)return;const c=d=>{m.current&&!m.current.contains(d.target)&&l(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]),t.jsxs("div",{ref:m,className:`w-relative${r?" w-full":" w-none"}`,children:[t.jsxs("button",{type:"button",className:`w-combo${r?" w-full":" w-rolepick-btn"}`,"data-open":i?"":void 0,onClick:()=>l(c=>!c),disabled:!e.length,children:[t.jsx("span",{className:"w-combo-val",children:(a==null?void 0:a.name)||"Role"}),t.jsx(Ut,{size:14})]}),i&&t.jsx("div",{className:"w-combo-menu w-combo-menu--pop",children:e.map(c=>t.jsxs("button",{type:"button",className:"w-combo-opt",onClick:()=>{s(c),l(!1)},children:[c.name,c.id===(a==null?void 0:a.id)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:13})})]},c.id))})]})},Qc=({mode:e,organizationId:a,onSuccess:s,onCancel:r,onCreateOrganization:i})=>{var ce;const l=e==="org",m=l?"organization":"workspace",c=l?"Organization":"Workspace",{createOrganization:d,getOrganizationRoles:p,inviteOrganizationMember:u}=zt(),{createWorkspace:f,getWorkspaceRoles:h,createWorkspaceInvitation:g}=va(),{organizationMemberships:x}=xa(),{refetch:w}=ot(),[b,j]=o.useState(0),[v,k]=o.useState(""),[N,_]=o.useState(""),[C,y]=o.useState(),[E,A]=o.useState(null),[H,M]=o.useState(!1),[T,P]=o.useState(null),[S,$]=o.useState(a),[Z,R]=o.useState(!1),L=o.useRef(null),O=o.useRef(null),[F,W]=o.useState(null),[U,V]=o.useState([]),[G,Y]=o.useState([]),[de,fe]=o.useState(""),[ne,ae]=o.useState(null),re=(ce=x==null?void 0:x.find(B=>B.organization.id===S))==null?void 0:ce.organization;o.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]),o.useEffect(()=>{if(!Z)return;const B=q=>{L.current&&!L.current.contains(q.target)&&R(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[Z]);const Le=B=>{var X;const q=(X=B.target.files)==null?void 0:X[0];if(q){if(q.size>2*1024*1024){P("Image must be under 2 MB.");return}if(!q.type.startsWith("image/")){P("Please choose a valid image file.");return}E&&URL.revokeObjectURL(E),P(null),y(q),A(URL.createObjectURL(q))}},K=async()=>{var X;const B=Li(v),q=Li(N);if(!G4(B)){P(`Enter a valid ${m} name (2–100 characters).`);return}if(!l&&!S){P("Select an organization first.");return}M(!0),P(null);try{if(l){const oe=await d({name:B,description:q,image:C}),Ee=((X=oe==null?void 0:oe.data)==null?void 0:X.organization)??(oe==null?void 0:oe.organization)??oe;W(Ee);const z=await p(Ee).catch(()=>[]);V(z),ae(Pi(z,"Member"))}else{const oe=await f(S,B,C,q),Ee=(oe==null?void 0:oe.workspace)??oe,z={...Ee,organization:{id:S}};W(z);const D=await h(Ee).catch(()=>[]);V(D),ae(Pi(D,"Editor"))}await w(),j(1)}catch(oe){P((oe==null?void 0:oe.message)||`Failed to create ${m}.`)}finally{M(!1)}},at=()=>{const B=de.trim();!q4(B)||G.some(q=>q.email===B)||ne&&(Y(q=>[...q,{email:B,roleId:ne.id,roleName:ne.name}]),fe(""))},ze=B=>{(B.key==="Enter"||B.key===",")&&(B.preventDefault(),at())},We=async()=>{if(!G.length){j(2);return}M(!0),P(null);try{for(const B of G)l?await u(F,{email:B.email,organizationRole:{id:B.roleId}}):await g(F,B.email,B.roleId);j(2)}catch(B){P((B==null?void 0:B.message)||"Some invitations could not be sent.")}finally{M(!1)}},Re=()=>{j(0),k(""),_(""),y(void 0),E&&URL.revokeObjectURL(E),A(null),W(null),V([]),Y([]),fe(""),P(null)};return t.jsxs("div",{className:"w-card w-create-card",children:[t.jsxs("div",{className:"w-create-body",children:[t.jsxs("div",{className:"w-flex-col w-items-center w-gap-3 w-create-head",children:[b===0?t.jsxs("span",{className:"w-ibadge-wrap",children:[t.jsxs("button",{type:"button",className:"w-ibadge w-avatar-edit","data-busy":H?"":void 0,onClick:()=>{var B;return(B=O.current)==null?void 0:B.click()},title:`Upload ${m} logo`,"aria-label":`Upload ${m} logo`,children:[E?t.jsx("img",{src:E,alt:`${c} logo`}):l?t.jsx(ps,{}):t.jsx(pi,{}),t.jsx("span",{className:"w-avatar-veil",children:t.jsx(sn,{})})]}),t.jsx("input",{ref:O,type:"file",className:"w-none",hidden:!0,accept:"image/png, image/jpeg, image/gif, image/svg+xml",onChange:Le,disabled:H}),E&&t.jsx("button",{type:"button",className:"w-ibadge-x",title:"Remove logo","aria-label":"Remove logo",onClick:()=>{E&&URL.revokeObjectURL(E),A(null),y(void 0)},children:t.jsx(La,{})})]}):t.jsx("span",{className:`w-ibadge${b===2?" w-ibadge--done":""}`,children:b===2?t.jsx(Ye,{}):l?t.jsx(ps,{}):t.jsx(pi,{})}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-text-center",children:[t.jsx("h1",{className:"w-title-lg",children:b===0?`Create ${l?"an":"a"} ${m}`:b===1?"Invite your team":`${c} created`}),t.jsx("p",{className:"w-sub",children:b===0?`Set up a new ${m}${l?" to collaborate with your team.":" inside your organization."}`:b===1?"Add people now, or skip and do it later.":`${v} is ready to go.`})]})]}),b<2&&t.jsxs("div",{className:"w-steps w-create-steps",children:[t.jsx("i",{"data-on":""}),t.jsx("i",{"data-on":b>=1?"":void 0})]}),T&&t.jsx("div",{className:"w-banner w-banner--error w-mb-4",children:T}),b===0&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[!l&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Organization"}),t.jsxs("div",{className:"w-relative",ref:L,children:[t.jsxs("button",{type:"button",className:"w-combo w-full","data-open":Z?"":void 0,onClick:()=>R(B=>!B),disabled:H,children:[t.jsxs("span",{className:"w-combo-val w-inline w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:re!=null&&re.image_url?t.jsx("img",{src:re.image_url,alt:re.name}):Os((re==null?void 0:re.name)||"O").charAt(0)}),t.jsx("span",{children:(re==null?void 0:re.name)||"Select organization"})]}),t.jsx(Ut,{size:14})]}),Z&&t.jsxs("div",{className:"w-combo-menu w-combo-menu--pop",children:[x==null?void 0:x.map(B=>{var X;const q=!!((X=B.eligibility_restriction)!=null&&X.type)&&B.eligibility_restriction.type!=="none";return t.jsxs("button",{type:"button",className:"w-combo-opt",disabled:q,"data-disabled":q?"":void 0,onClick:()=>{q||($(B.organization.id),R(!1))},children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:B.organization.image_url?t.jsx("img",{src:B.organization.image_url,alt:B.organization.name}):Os(B.organization.name).charAt(0)}),t.jsx("span",{children:B.organization.name})]},B.organization.id)}),i&&t.jsxs("button",{type:"button",className:"w-combo-opt w-text-primary",onClick:()=>{R(!1),i()},children:[t.jsx(St,{size:13}),"Create new organization"]})]})]})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:[c," name"]}),t.jsx(ye,{autoFocus:!0,value:v,onChange:B=>k(B.target.value),placeholder:l?"Acme Inc":"Product",disabled:H})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Description"," ",t.jsx("span",{className:"w-secsub",children:"· optional"})]}),t.jsx(ye,{as:"textarea",className:"w-input--area",value:N,onChange:B=>_(B.target.value),placeholder:l?"What does your team do?":"What's this workspace for?",disabled:H})]}),t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:K,disabled:H||!v.trim(),children:H?t.jsx(_e,{size:15}):t.jsxs(t.Fragment,{children:["Continue",t.jsx(Qt,{size:15})]})}),r&&t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-btn--block",onClick:r,disabled:H,children:"Cancel"})]})]}),b===1&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Invite by email"}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(ye,{autoFocus:!0,className:"w-grow",value:de,onChange:B=>fe(B.target.value),onKeyDown:ze,placeholder:"teammate@acme.com"}),t.jsx(K4,{roles:U,value:ne,onChange:ae})]}),t.jsx("span",{className:"w-secsub",children:"Press Enter to add each person."})]}),G.length>0&&t.jsx("div",{className:"w-list",children:G.map(B=>t.jsxs("div",{className:"w-row",style:{gridTemplateColumns:"1fr auto",padding:"10px 0"},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:Os(B.email)}),t.jsx("span",{className:"w-truncate w-text-secondary",children:B.email})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-pill",children:B.roleName}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",title:"Remove",onClick:()=>Y(q=>q.filter(X=>X.email!==B.email)),children:t.jsx(La,{size:13})})]})]},B.email))}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-none",onClick:()=>j(2),disabled:H,children:"Skip"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-grow",onClick:We,disabled:H,children:H?t.jsx(_e,{size:15}):G.length?`Invite ${G.length} & finish`:"Finish"})]})]}),b===2&&t.jsxs("div",{className:"w-flex-col w-items-center w-gap-4",children:[t.jsxs("div",{className:"w-create-summary",children:[t.jsx("span",{className:"w-avatar w-avatar--md",children:E?t.jsx("img",{src:E,alt:v}):Os(v)}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:v}),t.jsx("span",{className:"w-secsub",children:G.length?`${G.length} invite${G.length>1?"s":""} sent`:"No invites yet"})]})]}),t.jsxs("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>s==null?void 0:s(F),children:["Go to ",m,t.jsx(Qt,{size:15})]}),t.jsxs("button",{type:"button",className:"w-link w-link--muted w-linkbtn w-inline w-gap-1",onClick:Re,children:[t.jsx(Wo,{size:12})," Create another"]})]})]}),b===0&&t.jsx("div",{className:"w-create-foot",children:t.jsx("span",{className:"w-secsub",children:l?"Organizations group your team, billing and settings.":"Workspaces live inside an organization."})})]})},mn=({onSuccess:e,onCancel:a})=>t.jsx($e,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Qc,{mode:"org",onSuccess:e,onCancel:a})})}),Jc=({isOpen:e,onClose:a,onCreated:s})=>{const r=()=>{s==null||s(),a==null||a()};return t.jsx($e,{children:t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsx(Ue.Content,{className:"w-dialog--create",children:t.jsx(mn,{onSuccess:r,onCancel:a})})})})})},Er=o.createContext({screen:null,setScreen:()=>{},toast:(e,a)=>{}}),Ct=()=>{const e=o.useContext(Er);if(!e)throw new Error("useScreenContext must be used within a ScreenContextProvider");return e},Qa=({title:e,description:a,onConfirm:s,onCancel:r,style:i})=>{const l=o.useRef(null);return o.useEffect(()=>{const m=c=>{l.current&&!l.current.contains(c.target)&&r()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[r]),t.jsxs("div",{ref:l,className:"w-pop",style:{position:"fixed",zIndex:1e3,right:44,...i},children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("h3",{className:"w-pop-title",children:e}),a&&t.jsx("p",{className:"w-pop-sub",children:a})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:r,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:s,children:"Confirm"})]})]})},$i=[{id:"okta",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"saml",description:"SAML",docUrl:"https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_saml.htm",placeholders:{entityId:"http://www.okta.com/{yourOktaDomain}",ssoUrl:"https://{yourOktaDomain}.okta.com/app/{appId}/sso/saml"},attributeMapping:{first_name:"firstName",last_name:"lastName",email:"email"}},{id:"okta-oidc",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"oidc",description:"OIDC",docUrl:"https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/",placeholders:{issuerUrl:"https://{yourOktaDomain}.okta.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"azure",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso",placeholders:{entityId:"https://sts.windows.net/{tenantId}/",ssoUrl:"https://login.microsoftonline.com/{tenantId}/saml2"},attributeMapping:{first_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",last_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",email:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"}},{id:"azure-oidc",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"oidc",description:"OIDC",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc",placeholders:{issuerUrl:"https://login.microsoftonline.com/{tenantId}/v2.0",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"google",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"saml",description:"SAML",docUrl:"https://support.google.com/a/answer/6087519",placeholders:{entityId:"https://accounts.google.com/o/saml2?idpid={idpId}",ssoUrl:"https://accounts.google.com/o/saml2/idp?idpid={idpId}"},attributeMapping:{first_name:"FirstName",last_name:"LastName",email:"email"}},{id:"google-oidc",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"oidc",description:"OIDC",docUrl:"https://developers.google.com/identity/openid-connect/openid-connect",placeholders:{issuerUrl:"https://accounts.google.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"auth0",name:"Auth0",logo:"https://cdn.auth0.com/styleguide/latest/lib/logos/img/badge.png",protocol:"oidc",description:"OIDC",docUrl:"https://auth0.com/docs/authenticate/protocols/openid-connect-protocol",placeholders:{issuerUrl:"https://{yourDomain}.auth0.com/",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"onelogin",name:"OneLogin",logo:"",protocol:"saml",description:"SAML",docUrl:"https://onelogin.service-now.com/support?id=kb_article&sys_id=912bb23adbdc1cd0ca1c400e0b96197d",placeholders:{entityId:"https://app.onelogin.com/saml/metadata/{appId}",ssoUrl:"https://{subdomain}.onelogin.com/trust/saml2/http-post/sso/{appId}"}},{id:"ping",name:"PingOne",logo:"",protocol:"saml",description:"SAML",docUrl:"https://docs.pingidentity.com/pingone/latest/connector/configure-saml.html",placeholders:{entityId:"https://auth.pingone.com/{envId}",ssoUrl:"https://auth.pingone.com/{envId}/saml20/idp/sso"}},{id:"jumpcloud",name:"JumpCloud",logo:"",protocol:"saml",description:"SAML",docUrl:"https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-saml",placeholders:{entityId:"https://sso.jumpcloud.com/saml2/{appId}",ssoUrl:"https://sso.jumpcloud.com/saml2/{appId}"}},{id:"duo",name:"Duo",logo:"",protocol:"saml",description:"SAML",docUrl:"https://duo.com/docs/sso",placeholders:{entityId:"https://sso.duosecurity.com/saml2/sp/{appId}",ssoUrl:"https://sso.duosecurity.com/saml2/idp/{appId}/sso"}},{id:"keycloak",name:"Keycloak",logo:"https://www.keycloak.org/resources/images/icon.svg",protocol:"oidc",description:"OIDC",docUrl:"https://www.keycloak.org/docs/latest/securing_apps/",placeholders:{issuerUrl:"https://{host}/realms/{realm}",scopes:"openid profile email"}},{id:"adfs",name:"ADFS",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Microsoft_logo.svg/100px-Microsoft_logo.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-relying-party-trust",placeholders:{entityId:"http://{adfsServer}/adfs/services/trust",ssoUrl:"https://{adfsServer}/adfs/ls/"}},{id:"custom-saml",name:"Custom",logo:"",protocol:"saml",description:"SAML",docUrl:"",placeholders:{}},{id:"custom-oidc",name:"Custom",logo:"",protocol:"oidc",description:"OIDC",docUrl:"",placeholders:{}}],Y4=({template:e})=>{const[a,s]=o.useState(!1);return!e.logo||a?t.jsx("span",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo--ph",children:t.jsx(Xt,{size:18,className:"w-text-muted"})}):t.jsx("img",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo",src:e.logo,alt:e.name,onError:()=>s(!0)})},Q4=({organization:e})=>{const{getEnterpriseConnections:a,createEnterpriseConnection:s,deleteEnterpriseConnection:r,testEnterpriseConnection:i,generateSCIMToken:l,getSCIMToken:m,revokeSCIMToken:c}=zt(),{toast:d}=Ct(),[p,u]=o.useState(!1),[f,h]=o.useState(null),{data:g=[],isLoading:x,mutate:w}=Se(e!=null&&e.id?`wacht-org-sso:${e.id}`:null,async()=>await(a==null?void 0:a(e))||[],{refreshInterval:3e4,revalidateOnFocus:!1}),b=async j=>{try{await(r==null?void 0:r(e,j)),w(),d("SSO connection deleted","info")}catch(v){d(v.message||"Failed to delete connection","error")}h(null)};return x?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):p?t.jsx(X4,{organization:e,onClose:()=>u(!1),onCreate:async j=>{try{await(s==null?void 0:s(e,j)),w(),u(!1),d("SSO connection created","info")}catch(v){d(v.message||"Failed to create connection","error")}}}):t.jsx(t.Fragment,{children:g.length===0?t.jsxs("div",{className:"w-empty w-empty--fill",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(Xt,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"Enterprise SSO"}),t.jsx("p",{children:"Let members sign in with your identity provider."})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{onClick:()=>u(!0),children:[t.jsx(St,{size:16})," Configure SSO"]})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-sechead",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-title",children:"Enterprise SSO"}),t.jsx("p",{className:"w-sub",children:"Configure SAML or OIDC SSO for your organization"})]})}),g.map(j=>t.jsx(J4,{connection:j,onDelete:v=>h(v),connectionToDelete:f,onConfirmDelete:b,onCancelDelete:()=>h(null),testConnection:v=>i(e,v),generateSCIMToken:v=>l(e,v),getSCIMToken:v=>m(e,v),revokeSCIMToken:v=>c(e,v),toast:d},j.id))]})})},J4=({connection:e,onDelete:a,connectionToDelete:s,onConfirmDelete:r,onCancelDelete:i,testConnection:l,generateSCIMToken:m,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var H,M,T,P,S;const[u,f]=o.useState(null),[h,g]=o.useState(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),[v,k]=o.useState(!1),[N,_]=o.useState(null);o.useEffect(()=>{c&&e.id&&c(e.id).then(f).catch(()=>{})},[e.id,c]);const C=async()=>{if(l){k(!0),_(null);try{const $=await l(e.id);_($)}catch($){_({success:!1,checks:{},errors:{general:$.message||"Test failed"}})}finally{k(!1)}}},y=async()=>{if(m){g(!0);try{const $=await m(e.id);w($.token),f({exists:!0,token:$}),p("SCIM token generated. Copy it now - it won't be shown again!","info")}catch($){p($.message||"Failed to generate token","error")}finally{g(!1)}}},E=async()=>{if(d){g(!0);try{await d(e.id),f({exists:!1,scim_base_url:u==null?void 0:u.scim_base_url}),w(null),p("SCIM token revoked","info")}catch($){p($.message||"Failed to revoke token","error")}finally{g(!1)}}},A=($,Z)=>{navigator.clipboard.writeText($),j(Z),setTimeout(()=>j(null),2e3)};return t.jsxs("div",{className:"w-flex-col w-gap-4 w-sso-conn",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-start",children:[t.jsxs("h3",{className:"w-sec w-inline w-gap-2",children:[t.jsx(Xt,{size:16}),e.protocol==="oidc"?"OIDC SSO":"SAML SSO",t.jsx("span",{className:"w-pill w-pill--current",children:e.protocol.toUpperCase()})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(se,{$size:"sm",onClick:C,disabled:v,children:v?t.jsx(_e,{size:14}):"Test"}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>a(e.id),className:"w-text-error",children:"Remove"}),s===e.id&&t.jsx(Qa,{title:"Delete this SSO connection?",onConfirm:()=>r(e.id),onCancel:i})]})]})]}),N&&t.jsx("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"}`,children:t.jsxs("span",{className:`w-banner-txt w-flex-col w-gap-1 ${N.success?"w-text-success":"w-text-error"}`,children:[t.jsx("span",{children:N.success?"✓ Connection is valid":"✗ Connection failed"}),N.errors&&Object.entries(N.errors).map(([$,Z])=>t.jsxs("div",{children:[$.replace(/_/g," "),": ",Z]},$))]})}),t.jsxs("div",{className:"w-sso-detail",children:[e.protocol==="saml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Entity ID"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_entity_id}),t.jsx("span",{className:"w-secsub",children:"SSO URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_sso_url})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Issuer URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.oidc_issuer_url}),t.jsx("span",{className:"w-secsub",children:"Client ID"}),t.jsx("span",{className:"w-sec",children:e.oidc_client_id}),t.jsx("span",{className:"w-secsub",children:"Scopes"}),t.jsx("span",{className:"w-sec",children:e.oidc_scopes||"openid profile email"})]}),t.jsx("span",{className:"w-secsub",children:"Created"}),t.jsx("span",{className:"w-sec",children:new Date(e.created_at).toLocaleDateString()})]}),t.jsxs("div",{className:"w-flex-col w-gap-3 w-sso-scim",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center",children:[t.jsxs("div",{className:"w-sec w-inline w-gap-2",children:[t.jsx(Xt,{size:14}),"SCIM Provisioning"]}),t.jsx("div",{className:"w-flex w-wrap w-gap-2",children:!(u!=null&&u.exists)||!((H=u==null?void 0:u.token)!=null&&H.enabled)?t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Rotate"}),t.jsx(se,{$size:"sm",$outline:!0,onClick:E,disabled:h,className:"w-text-error",children:"Revoke"})]})})]}),(((M=u==null?void 0:u.token)==null?void 0:M.scim_base_url)||x)&&t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Base URL:"}),t.jsx("code",{children:((T=u==null?void 0:u.token)==null?void 0:T.scim_base_url)||"Loading..."}),((P=u==null?void 0:u.token)==null?void 0:P.scim_base_url)&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>A(u.token.scim_base_url,"scim-url"),children:b==="scim-url"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]}),x&&t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Token:"}),t.jsx("code",{children:x}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>A(x,"scim-token"),children:b==="scim-token"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]}),t.jsx("div",{className:"w-mono-faint w-text-warning",children:"⚠️ Copy this token now. It won't be shown again."})]}),(u==null?void 0:u.exists)&&((S=u==null?void 0:u.token)==null?void 0:S.enabled)&&!x&&t.jsxs("div",{className:"w-secsub",children:["Token:"," ",t.jsxs("code",{className:"w-mono-sm w-token-chip",children:[u.token.token_prefix,"..."]}),u.token.last_used_at&&t.jsxs("span",{children:[" ","· Last used:"," ",new Date(u.token.last_used_at).toLocaleDateString()]})]})]})]})},X4=({onCreate:e,organization:a})=>{const{getOrganizationDomains:s,testEnterpriseConnectionConfig:r}=zt(),{deployment:i}=Ce(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(null),[u,f]=o.useState("saml"),[h,g]=o.useState(null),[x,w]=o.useState(!1),[b,j]=o.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[v,k]=o.useState(!1),[N,_]=o.useState(null),{data:C=[],isLoading:y}=Se("wacht-org-verified-domains-for-sso-screen",async()=>(await(s==null?void 0:s(a))||[]).filter(R=>R.verified),{revalidateOnFocus:!1}),E=Z=>{p(Z),f(Z.protocol),Z.protocol==="saml"?j(R=>{var L,O,F;return{...R,idp_entity_id:Z.placeholders.entityId||"",idp_sso_url:Z.placeholders.ssoUrl||"",attr_first_name:((L=Z.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((O=Z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((F=Z.attributeMapping)==null?void 0:F.email)||""}}):j(R=>{var L,O,F;return{...R,oidc_issuer_url:Z.placeholders.issuerUrl||"",oidc_scopes:Z.placeholders.scopes||"openid profile email",attr_first_name:((L=Z.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((O=Z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((F=Z.attributeMapping)==null?void 0:F.email)||""}})},A=i!=null&&i.backend_host?`${i.backend_host.startsWith("https://")?"":"https://"}${i.backend_host}/auth/sso/oidc/callback`:"",H=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/metadata`:"",M=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/callback`:"",T=(Z,R)=>{navigator.clipboard.writeText(Z),g(R),setTimeout(()=>g(null),2e3)},P=async Z=>{Z.preventDefault();const R=L=>L.includes("{")||L.includes("}");if(u==="saml"){if(!b.idp_entity_id||R(b.idp_entity_id)){l("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||R(b.idp_sso_url)){l("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){l("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||R(b.oidc_issuer_url)){l("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||R(b.oidc_client_id)){l("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){l("Please enter the Client Secret","error");return}}c(!0);try{const L={};b.attr_first_name&&(L.first_name=b.attr_first_name),b.attr_last_name&&(L.last_name=b.attr_last_name),b.attr_email&&(L.email=b.attr_email);const O=Object.keys(L).length>0;u==="saml"?await e({protocol:"saml",domain_id:b.domain_id||void 0,idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate,jit_enabled:b.jit_enabled,...O&&{attribute_mapping:L}}):await e({protocol:"oidc",domain_id:b.domain_id||void 0,oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret,oidc_scopes:b.oidc_scopes,jit_enabled:b.jit_enabled,...O&&{attribute_mapping:L}})}finally{c(!1)}},S=async()=>{k(!0),_(null);const Z=O=>O.includes("{")||O.includes("}"),R={},L={};if(u==="saml"?(b.idp_entity_id?Z(b.idp_entity_id)?(L.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):L.entity_id_valid=!0:(L.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?Z(b.idp_sso_url)?(L.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):L.sso_url_valid=!0:(L.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?L.certificate_provided=!0:(L.certificate_provided=!1,R.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?Z(b.oidc_issuer_url)?(L.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):L.issuer_url_valid=!0:(L.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?Z(b.oidc_client_id)?(L.client_id_valid=!1,R.client_id_valid="Client ID contains placeholder values - please replace with actual values"):L.client_id_valid=!0:(L.client_id_valid=!1,R.client_id_valid="Client ID is required")),Object.keys(R).length>0){_({success:!1,checks:L,errors:R}),k(!1);return}try{const O=u==="saml"?{protocol:"saml",idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate}:{protocol:"oidc",oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret},F=await(r==null?void 0:r(a,O));F&&_(F)}catch(O){_({success:!1,checks:{},errors:{general:"Test failed: "+O.message}})}finally{k(!1)}},$=Z=>t.jsx(Y4,{template:Z});return t.jsxs("form",{onSubmit:P,autoComplete:"off",className:"w-flex-col w-gap-4",children:[d?t.jsxs("div",{className:"w-flex w-items-center w-gap-4 w-sso-template",children:[$(d),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:d.name}),t.jsx("div",{className:"w-eyebrow",children:d.protocol})]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:()=>p(null),children:"Change"})]}):t.jsxs("div",{className:"w-flex-col w-gap-5",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"SAML Providers"}),t.jsx("div",{className:"w-grid-4",children:$i.filter(Z=>Z.protocol==="saml").map(Z=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(Z),children:[$(Z),t.jsx("span",{className:"w-secsub",children:Z.name})]},Z.id))})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"OIDC Providers"}),t.jsx("div",{className:"w-grid-4",children:$i.filter(Z=>Z.protocol==="oidc").map(Z=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(Z),children:[$(Z),t.jsx("span",{className:"w-secsub",children:Z.name})]},Z.id))})]})]}),d&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-sec",children:"Service Provider Details"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"ACS URL:"}),t.jsx("code",{children:M}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(M,"acs"),children:h==="acs"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]}),t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Metadata:"}),t.jsx("code",{children:H}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(H,"metadata"),children:h==="metadata"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]})]}):t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Callback:"}),t.jsx("code",{children:A}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(A,"callback"),children:h==="callback"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]})})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:d?`${d.name} Configuration`:"Configuration"}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[d&&d.docUrl&&t.jsxs("a",{href:d.docUrl,target:"_blank",rel:"noopener noreferrer",className:"w-link w-link--sm w-text-primary w-inline w-gap-1",children:[t.jsx(Nu,{size:12})," Docs"]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:S,disabled:v||!d,children:v?t.jsx(_e,{size:16}):"Test Connection"}),t.jsx(se,{$size:"sm",type:"submit",disabled:m||C.length===0||!d,children:m?t.jsx(_e,{size:16}):"Create Connection"})]})]}),N&&(()=>{const Z={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return t.jsxs("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"} w-flex-col w-gap-3`,children:[t.jsx("div",{className:`w-sec ${N.success?"w-text-success":"w-text-error"}`,children:N.success?"✓ All checks passed":"✗ Some checks failed"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:Object.entries(N.checks).map(([R,L])=>{var O;return t.jsxs("div",{className:"w-flex w-items-start w-gap-2 w-sso-check",children:[t.jsx("span",{className:`w-sso-check-mark ${L?"w-text-success":"w-text-error"}`,children:L?"✓":"✗"}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:Z[R]||R.replace(/_/g," ").replace(/\b\w/g,F=>F.toUpperCase())}),((O=N.errors)==null?void 0:O[R])&&t.jsx("div",{className:"w-secsub w-text-error",children:N.errors[R]})]})]},R)})})]})})(),t.jsxs("div",{className:"w-grid-2",children:[!d&&t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Protocol *"}),t.jsxs("select",{className:"w-input",value:u,onChange:Z=>f(Z.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(Ge,{className:"w-col-full",children:[t.jsx(Ve,{children:"Domain *"}),y?t.jsx("div",{className:"w-secsub",children:"Loading domains..."}):C.length===0?t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"No verified domains found. Please add and verify a domain first."})}):t.jsxs("select",{className:"w-input",value:b.domain_id,onChange:Z=>j({...b,domain_id:Z.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),C.map(Z=>t.jsx("option",{value:Z.id,children:Z.fqdn},Z.id))]})]}),u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(Ge,{children:[t.jsx(Ve,{children:"IdP Entity ID *"}),t.jsx(ye,{type:"text",value:b.idp_entity_id,onChange:Z=>j({...b,idp_entity_id:Z.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"IdP SSO URL *"}),t.jsx(ye,{type:"url",value:b.idp_sso_url,onChange:Z=>j({...b,idp_sso_url:Z.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(Ge,{className:"w-col-full",children:[t.jsx(Ve,{children:"X.509 Certificate *"}),t.jsx(ye,{as:"textarea",value:b.idp_certificate,onChange:Z=>j({...b,idp_certificate:Z.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0,className:"w-input--area w-input--mono"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Issuer URL *"}),t.jsx(ye,{type:"url",value:b.oidc_issuer_url,onChange:Z=>j({...b,oidc_issuer_url:Z.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Client ID *"}),t.jsx(ye,{type:"text",value:b.oidc_client_id,onChange:Z=>j({...b,oidc_client_id:Z.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Client Secret *"}),t.jsx(ye,{type:"password",value:b.oidc_client_secret,onChange:Z=>j({...b,oidc_client_secret:Z.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Scopes"}),t.jsx(ye,{type:"text",value:b.oidc_scopes,onChange:Z=>j({...b,oidc_scopes:Z.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(Ge,{className:"w-col-full",children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:"Enable JIT Provisioning"}),t.jsx("div",{className:"w-secsub",children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),t.jsx(Za,{checked:b.jit_enabled,onChange:()=>j({...b,jit_enabled:!b.jit_enabled})})]})}),t.jsxs("div",{className:"w-col-full w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-inline w-gap-2 w-text-primary w-disclosure",onClick:()=>w(!x),children:[t.jsx("span",{className:"w-disclosure-caret",children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-secsub",children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),t.jsxs("div",{className:"w-grid-3",children:[t.jsxs(Ge,{children:[t.jsx(Ve,{children:"First Name Attribute"}),t.jsx(ye,{type:"text",value:b.attr_first_name,onChange:Z=>j({...b,attr_first_name:Z.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Last Name Attribute"}),t.jsx(ye,{type:"text",value:b.attr_last_name,onChange:Z=>j({...b,attr_last_name:Z.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Email Attribute"}),t.jsx(ye,{type:"text",value:b.attr_email,onChange:Z=>j({...b,attr_email:Z.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ht=(...e)=>e.filter(Boolean).join(" "),Oi=({className:e,...a})=>t.jsx("div",{className:ht("w-contents",e),...a}),Zn=({className:e,...a})=>t.jsx("div",{className:ht("w-card","w-flex-col","w-full","w-minh-full",e),...a}),em=({className:e,...a})=>t.jsx("div",{className:ht("w-tabsbar",e),...a}),tm=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),za=({className:e,$isActive:a,...s})=>t.jsx("button",{className:ht("w-tab",a&&"w-tab--active",e),...s}),Da=({className:e,...a})=>t.jsx("span",{className:ht("w-inline","w-gap-2",e),...a}),am=({className:e,children:a,...s})=>t.jsx("div",{className:ht("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Ar=({className:e,...a})=>t.jsx("div",{className:ht("w-sechead",e),...a}),Zi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Hi=({className:e,...a})=>t.jsx("div",{className:ht("w-grow",e),...a}),Fi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-3","w-none",e),...a}),pn=({className:e,...a})=>t.jsx("div",{className:ht("w-full",e),...a}),sm=({className:e,...a})=>t.jsx("div",{className:ht("w-page-head",e),...a}),nm=({className:e,...a})=>t.jsx("div",{className:ht("w-grow","w-flex-col","w-gap-1",e),...a}),rm=({className:e,...a})=>t.jsx("div",{className:ht("w-sec","w-truncate",e),...a}),im=({className:e,...a})=>t.jsx("div",{className:ht("w-secsub","w-truncate",e),...a}),om={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},fa=({className:e,$variant:a="neutral",children:s,...r})=>t.jsxs("span",{className:ht("w-pill",om[a],e),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),Ti=({className:e,$first:a,...s})=>t.jsx("div",{className:ht("w-sec",e),...s}),lm=({organization:e})=>{var M,T,P,S,$,Z;const{switchOrganization:a,refetch:s}=ot(),{workspaces:r}=va(),{deployment:i}=Ce(),{deleteOrganization:l,updateOrganization:m}=zt(),{toast:c}=Ct(),[d,p]=o.useState((e==null?void 0:e.name)||""),[u,f]=o.useState((e==null?void 0:e.description)||""),[h,g]=o.useState(!1),[x,w]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,j]=o.useState(""),[v,k]=o.useState(!1),[N,_]=o.useState(!1),C=o.useRef({name:d,description:u,security:x,isSaving:h});o.useEffect(()=>{C.current={name:d,description:u,security:x,isSaving:h}},[d,u,x,h]);const y=o.useCallback(async()=>{if(!e)return;const R=C.current;try{g(!0),await m(e,{name:R.name,description:R.description,whitelisted_ips:R.security.allowed_ips.split(`
102
+ `,c4={display:"contents"};function d4(e){const a={};if(!e)return a;const s=(r,i)=>{if(i)for(const l in i){const m=i[l];typeof m=="string"&&m.trim()!==""&&(a[`--wa-ov-${r}-${l}`]=m)}};return s("light",e.light),s("dark",e.dark),a}function ts(){var s,r;const e=o.useContext(fr),a=(r=(s=e==null?void 0:e.deployment)==null?void 0:s.ui_settings)==null?void 0:r.theme_tokens;return o.useMemo(()=>d4(a),[a])}const Mi=o.createContext(!1),u4=o.memo(function(){return t.jsx(l4,{})});function $e({children:e,className:a,style:s,...r}){const i=o.useContext(Mi),l=ts(),[m,c]=o.useState(!1);if(o.useEffect(()=>c(!0),[]),!m)return null;const d=t.jsx("div",{...r,className:a?`wacht-root ${a}`:"wacht-root",style:{...c4,...l,...s},children:e});return i?d:t.jsxs(Mi.Provider,{value:!0,children:[t.jsx(u4,{}),d]})}function ya({length:e=6,onComplete:a,onResend:s,error:r,isSubmitting:i=!1}){const[l,m]=o.useState(new Array(e).fill("")),[c,d]=o.useState(60),[p,u]=o.useState(!1),f=o.useRef([]),h=o.useCallback(()=>{const j=setInterval(()=>{d(v=>v<=1?(u(!0),clearInterval(j),0):v-1)},1e3);return j},[]);o.useEffect(()=>{const j=h();return()=>clearInterval(j)},[h]);const g=async()=>{var j;!p||i||!s||(await s(),u(!1),d(60),m(new Array(e).fill("")),(j=f.current[0])==null||j.focus(),h())},x=(j,v)=>{var C;if(i)return;const k=j.value,N=[...l];N[v]=k.replace(/[^0-9]/g,""),m(N);const _=N.join("");_.length===e&&a(_),k&&v<e-1&&((C=f.current[v+1])==null||C.focus())},w=(j,v)=>{var k;i||j.key==="Backspace"&&!l[v]&&v>0&&((k=f.current[v-1])==null||k.focus())},b=(j,v)=>{var C,y;if(i)return;j.preventDefault();const k=j.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!k.length)return;const N=[...l];for(let E=0;E<k.length&&v+E<e;E++)N[v+E]=k[E];if(v===0&&k.length===e)for(let E=0;E<e;E++)N[E]=k[E];m(N);const _=N.join("");if(_.length===e)a(_),(C=f.current[e-1])==null||C.focus();else{const E=N.findIndex((A,H)=>H>=v&&!A);E!==-1&&((y=f.current[E])==null||y.focus())}};return t.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{className:"w-otp","data-error":r?"":void 0,children:l.map((j,v)=>t.jsx("input",{className:"w-otp-cell",type:"text",inputMode:"numeric",maxLength:1,value:j,"data-filled":j?"":void 0,onChange:k=>x(k.target,v),onKeyDown:k=>w(k,v),onPaste:k=>b(k,v),ref:k=>{f.current[v]=k},disabled:i,autoFocus:v===0},v))}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[r&&t.jsx("span",{className:"w-input-err",children:r}),s&&(p?t.jsx("button",{type:"button",className:"w-link",style:{background:"none",border:0,cursor:"pointer",fontSize:12.5},onClick:g,disabled:i,children:"Didn't receive a code? Resend"}):t.jsxs("span",{className:"w-secsub",children:["Resend code in ",c,"s"]}))]})]})}const Cc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...e,children:[t.jsx("title",{id:"githubIconTitle",children:"GitHub"}),t.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),Nc=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),t.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),t.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),t.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),Sc=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...e,children:t.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),m4=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Ec=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:t.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),Ac=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),t.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),t.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),p4=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Mc=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),t.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),h4={google_oauth:{label:"Continue with Google",icon:t.jsx(Nc,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(Cc,{})},x_oauth:{label:"Continue with X",icon:t.jsx(Sc,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(m4,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(Ec,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(Ac,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(p4,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(Mc,{})}},Nr=({connections:e,callback:a})=>{const s=e.map(r=>({connection:r,config:h4[r.provider]})).filter(r=>r.config);if(!s.length)return null;if(s.length>3){const r=Math.min(s.length,4);return t.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gap:8},children:s.map(({connection:i,config:l})=>t.jsx("button",{type:"button",className:"w-social",style:{justifyContent:"center",padding:0},onClick:()=>a(i),title:l.label,"aria-label":l.label,children:l.icon},i.provider))})}return t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:s.map(({connection:r,config:i})=>t.jsxs("button",{type:"button",className:"w-social",onClick:()=>a(r),children:[i.icon,t.jsx("span",{className:"w-social-label",children:i.label})]},r.provider))})},Et=({to:e,replace:a,children:s,...r})=>{const{navigate:i}=kt(),l=o.useCallback(m=>{m.preventDefault(),i(e,{replace:a})},[e,a,i]);return t.jsx("a",{href:e||void 0,onClick:l,...r,children:s})},qt=o.forwardRef(({onFocus:e,readOnly:a,...s},r)=>{const[i,l]=o.useState(!1);return t.jsx("input",{ref:r,...s,readOnly:a||!i,onFocus:m=>{i||l(!0),e==null||e(m)}})});qt.displayName="NoPrefillInput";const Gs=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],ys=({value:e,onChange:a,error:s,countryCode:r,setCountryCode:i})=>{const[l,m]=o.useState(!1),[c,d]=o.useState(Gs.find(x=>x.code===r)||Gs[0]),p=o.useRef(null),[u,f]=o.useState(""),h=o.useRef(null);o.useEffect(()=>{function x(w){p.current&&!p.current.contains(w.target)&&m(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const g=Gs.filter(x=>x.name.toLowerCase().includes(u.toLowerCase())||x.dialCode.includes(u));return o.useEffect(()=>{i(c.dialCode)},[c,i]),t.jsxs("div",{className:"w-phone",children:[t.jsxs("div",{style:{position:"relative"},ref:p,children:[t.jsxs("button",{type:"button",className:"w-phone-cc",style:{height:"100%"},onClick:()=>m(x=>!x),children:[t.jsx("span",{children:c.flag}),t.jsx("span",{children:c.dialCode}),t.jsx(Ut,{weight:"bold"})]}),l&&t.jsxs("div",{className:"w-country-pop",children:[t.jsxs("div",{className:"w-country-search",children:[t.jsx(Ml,{}),t.jsx("input",{type:"text",placeholder:"Search country…",value:u,onChange:x=>f(x.target.value),onClick:x=>x.stopPropagation()})]}),t.jsx("div",{className:"w-country-list",children:g.map(x=>t.jsxs("button",{type:"button",className:"w-country-opt",onClick:w=>{var b;w.stopPropagation(),w.preventDefault(),d(x),m(!1),(b=h.current)==null||b.focus()},children:[t.jsx("span",{children:x.flag}),t.jsx("span",{children:x.name}),t.jsx("span",{className:"dial",children:x.dialCode})]},x.code))})]})]}),t.jsx("input",{type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:h,value:e,onChange:a,placeholder:"Phone number","aria-invalid":!!s,pattern:"^\\d{7,15}$"})]})};function Sr({placement:e="center"}){var m;const{deployment:a}=Ce(),[s,r]=o.useState(!1),i=(m=a==null?void 0:a.ui_settings)==null?void 0:m.logo_image_url;if(!i||s)return null;const l=e==="left"?"flex-start":e==="right"?"flex-end":"center";return t.jsx("div",{style:{display:"flex",justifyContent:l,width:"100%"},children:t.jsx("img",{src:i,alt:"Logo",onError:()=>r(!0),style:{maxWidth:40,maxHeight:40,width:"auto",height:"auto",objectFit:"contain"}})})}function tt({children:e,footer:a}){return t.jsxs("div",{className:"w-card w-auth-card",children:[t.jsx("div",{className:"w-create-body",children:e}),a&&t.jsx("div",{className:"w-create-foot",children:a})]})}function rt({title:e,sub:a,children:s}){return t.jsxs("div",{className:"w-auth-head",children:[t.jsx(Sr,{}),t.jsxs("div",{className:"w-auth-head-text",children:[t.jsx("h1",{className:"w-auth-title",children:e}),a&&t.jsx("p",{className:"w-auth-sub",children:a})]}),s]})}function vt({size:e=16,onAccent:a}){return t.jsx("span",{className:a?"w-spin w-spin--on-accent":"w-spin",style:{width:e,height:e}})}function js(){return t.jsx($e,{children:t.jsx("div",{className:"w-card w-auth-card",children:t.jsx("div",{className:"w-create-body",children:t.jsxs("div",{className:"w-auth-skel","aria-hidden":"true",children:[t.jsxs("div",{className:"w-auth-skel-head",children:[t.jsx("span",{className:"w-skel w-skel-avatar"}),t.jsx("span",{className:"w-skel w-skel-title"}),t.jsx("span",{className:"w-skel w-skel-sub"})]}),t.jsxs("div",{className:"w-auth-skel-fields",children:[t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsxs("div",{className:"w-auth-skel-field",children:[t.jsx("span",{className:"w-skel w-skel-label"}),t.jsx("span",{className:"w-skel w-skel-input"})]}),t.jsx("span",{className:"w-skel w-skel-btn"})]})]})})})})}function f4(e){const a=e.indexOf(":");return a>=0?e.slice(0,a):e}function w4(e){const a=e.trim();if(!a)return null;try{return new URL(a.includes("://")?a:`https://${a}`).hostname.toLowerCase()||null}catch{return null}}function g4(e){try{return new URL(e)}catch{if(typeof window>"u")return null;try{return new URL(e,window.location.origin)}catch{return null}}}function x4(e,a){return!e||!a?!1:e===a?!0:e.endsWith(`.${a}`)}function v4(e,a){if(!a)return!1;const s=g4(a);if(!s||s.protocol!=="https:"&&s.protocol!=="http:")return!1;if((e==null?void 0:e.mode)==="staging")return!0;if(s.protocol!=="https:"||!(e!=null&&e.frontend_host))return!1;const r=w4(f4(e.frontend_host));return r?x4(s.hostname.toLowerCase(),r):!1}function gt(e,a){return a&&v4(e,a)?a:null}const b4="https://cdn.wacht.services/captcha/wacht-challenge.min.js",y4="https://cdn.wacht.services/captcha/cap_wasm_bg.wasm",Ri="wacht-challenge-script";function j4(e){const a=e.trim().replace(/\/$/,"");return a?/^https?:\/\//i.test(a)?a:`https://${a}`:""}function _4(){return document.getElementById(Ri)?Promise.resolve():new Promise((e,a)=>{const s=document.createElement("script");s.id=Ri,s.src=b4,s.async=!0,s.onload=()=>e(),s.onerror=()=>a(new Error("Failed to load challenge script")),document.head.appendChild(s)})}function Rc({apiHost:e,onSolve:a,onError:s}){const r=o.useRef(null),[i,l]=o.useState(null),m=o.useRef(a),c=o.useRef(s),d=o.useRef(!1);return m.current=a,c.current=s,o.useEffect(()=>{if(d.current)return;d.current=!0;const p=j4(e);if(!p)return;let u=!1;return(async()=>{var f;try{if(await _4(),u||!window.Cap)return;window.CAP_SILENT=!0,window.CAP_DISABLE_WIDGET_REF=!0,window.CAP_CUSTOM_WASM_URL=y4;const h=new window.Cap({apiEndpoint:`${p}/captcha/`});r.current=h;const g=await h.solve();if(u)return;m.current(g.token)}catch(h){if(u)return;const g=h instanceof Error?h.message:"Challenge failed";l(g),(f=c.current)==null||f.call(c,"challenge_failed")}})(),()=>{var f;u=!0,(f=r.current)==null||f.reset(),r.current=null}},[e]),i?t.jsx("div",{style:{fontSize:12,color:"var(--wa-error)",marginBottom:12},children:i}):null}function k4(){var fe,ne,ae,re,Le,K,at,ze,We,Re,ce,B,q,X,oe,Ee;const{loading:e,signUp:a,signupAttempt:s,discardSignupAttempt:r}=xo(),{signIn:i}=ls("oauth"),{deployment:l}=Ce(),{navigate:m}=kt(),{session:c,refetch:d,loading:p}=ot(),[u,f]=o.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[h,g]=o.useState({}),[x,w]=o.useState(!1),[b,j]=o.useState(void 0),[v,k]=o.useState(null),[N,_]=o.useState(null),[C,y]=o.useState(!1),[E,A]=o.useState(""),H=!!E,M=((fe=l==null?void 0:l.restrictions)==null?void 0:fe.sign_up_mode)==="restricted",T=((ne=l==null?void 0:l.restrictions)==null?void 0:ne.sign_up_mode)==="waitlist",P=((re=(ae=l==null?void 0:l.auth_settings)==null?void 0:ae.multi_session_support)==null?void 0:re.enabled)??!1;o.useEffect(()=>{var z;if(!p&&(c!=null&&c.active_signin)&&!P&&!C){y(!0);let D=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));D||(D=((z=l==null?void 0:l.ui_settings)==null?void 0:z.after_signin_redirect_url)||null),!D&&(l!=null&&l.frontend_host)&&(D=`https://${l.frontend_host}`),D&&m(D)}},[c,p,P,l,m,C]),o.useEffect(()=>{var we;if(!l)return;const D=new URLSearchParams(window.location.search).get("invite_token");if(T&&!D){y(!0);const ge=((we=l.ui_settings)==null?void 0:we.waitlist_page_url)||`https://${l.frontend_host}/waitlist`;m(ge);return}D&&!v&&a&&(_(D),a.validateDeploymentInvitation(D).then(ge=>{k(ge),ge.valid&&f(xe=>({...xe,first_name:ge.first_name||xe.first_name,last_name:ge.last_name||xe.last_name,email:ge.email||xe.email}))}).catch(()=>{g(ge=>({...ge,submit:"Failed to validate invitation."}))}))},[l,T,m,v,a]);const[S,$]=o.useState(!1),[Z,R]=o.useState(""),L=z=>{let{name:D,value:we}=z.target;D==="phone_number"?we=we.replace(/[^0-9-]/g,""):D==="email"&&(we=we.toLowerCase()),f(ge=>({...ge,[D]:we})),g(ge=>({...ge,[D]:""}))},O=()=>{f({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),g({}),$(!1),R(""),r()},F=async z=>{if(z.preventDefault(),e||x)return;const D={};H||(D.submit="Challenge verification is still loading. Please try again.");const we=/^[a-zA-Z]{3,30}$/,ge=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,xe=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,lt=/^\d{7,15}$/,Qe=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(V!=null&&V.first_name.enabled&&(V!=null&&V.first_name.required&&!u.first_name?D.first_name="First name is required":u.first_name&&!we.test(u.first_name)&&(D.first_name="Invalid name")),V!=null&&V.last_name.enabled&&(V!=null&&V.last_name.required&&!u.last_name?D.last_name="Last name is required":u.last_name&&!we.test(u.last_name)&&(D.last_name="Invalid last name")),V!=null&&V.username.enabled&&(V!=null&&V.username.required&&!u.username?D.username="Username is required":u.username&&!ge.test(u.username)&&(D.username="Username must be 3-20 characters")),V!=null&&V.email_address.enabled&&(V!=null&&V.email_address.required&&!u.email?D.email="Email address is required":u.email&&!xe.test(u.email)&&(D.email="Invalid email address")),V!=null&&V.phone_number.enabled&&(V!=null&&V.phone_number.required&&!u.phone_number?D.phone_number="Phone number is required":u.phone_number&&!lt.test(u.phone_number)&&(D.phone_number="Phone number must contain 7-15 digits")),V!=null&&V.password.enabled&&(u.password?Qe.test(u.password)||(D.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):D.password="Password is required"),g(D),!(Object.keys(D).length>0)){w(!0);try{const Q={...u};u.phone_number&&b&&(Q.phone_country_code=b),N&&(Q.invite_token=N),E&&(Q.challenge_token=E),await a.create(Q)}catch(Q){g({submit:Q.message})}finally{w(!1)}}},W=async z=>{if(!(e||x||!H)){w(!0);try{const D=new URLSearchParams(window.location.search),we=gt(l,D.get("redirect_uri"))||void 0,{data:ge}=await i.create({provider:z.provider,redirectUri:we,challenge_token:E});ge&&typeof ge=="object"&&"oauth_url"in ge&&(window.location.href=ge.oauth_url)}catch(D){g({submit:D.message})}finally{w(!1)}}},U=(l==null?void 0:l.social_connections.filter(z=>z.enabled))||[],V=l==null?void 0:l.auth_settings,G=!!((Le=V==null?void 0:V.first_name)!=null&&Le.enabled&&((K=V==null?void 0:V.last_name)!=null&&K.enabled)),Y=async z=>{var we;if(z.preventDefault(),e||x)return;w(!0);const D={};if(!Z){D.otp="OTP code is required",g(D),w(!1);return}g(D);try{const ge=await a.completeVerification(Z);"data"in ge&&((we=ge.data)!=null&&we.active_signin)&&await d()}catch{g(ge=>({...ge,submit:"Verification failed. Please try again."}))}finally{w(!1)}};if(o.useEffect(()=>{var z;if(s){if(s.completed){let D=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(D||(D=((z=l==null?void 0:l.ui_settings)==null?void 0:z.after_signup_redirect_url)||null),!D&&(l!=null&&l.frontend_host)&&(D=`https://${l.frontend_host}`),D){let we;try{we=new URL(D)}catch{we=new URL(D,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&we.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(we.toString())}return}if(!S){switch(s.current_step){case"verify_email":a.prepareVerification({strategy:"email_otp",challenge_token:E});break;case"verify_phone":a.prepareVerification({strategy:"phone_otp",challenge_token:E});break}$(!0)}}},[s,a,S,l,c,m]),p||C)return t.jsx(js,{});const de=((at=l==null?void 0:l.ui_settings)==null?void 0:at.app_name)||"App";if(M)return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx(Et,{className:"w-link",to:(ze=l==null?void 0:l.ui_settings)!=null&&ze.sign_in_page_url?`${l.ui_settings.sign_in_page_url}?help=true`:"#",children:"Get help"})]}),children:[t.jsx(rt,{title:"Sign-up restricted",sub:"This app isn't open for public sign-up right now."}),t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"New account registration is currently restricted. Please check back later or contact your administrator for an invitation."})})]})});if(S){const z=(s==null?void 0:s.current_step)==="verify_phone";return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((We=l==null?void 0:l.ui_settings)==null?void 0:We.support_page_url)||"#",children:"Get help"})]}),children:[t.jsx(rt,{title:z?"Check your phone":"Enter the code",sub:z?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",children:t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:O,children:[t.jsx($l,{weight:"bold"}),z?`+${u.phone_number}`:u.email]})}),t.jsxs("form",{onSubmit:Y,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ya,{onComplete:async D=>{R(D)},onResend:async()=>{const D=z?"phone_otp":"email_otp";await a.prepareVerification({strategy:D,challenge_token:E})},error:h.otp,isSubmitting:x}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!Z,children:x&&Z?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${de}`})]})]})})}return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Already have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((Re=l==null?void 0:l.ui_settings)==null?void 0:Re.sign_in_page_url)??""}${window.location.search}`,children:"Sign in"})]}),children:[t.jsx(rt,{title:"Create your account",sub:v!=null&&v.valid?"You've been invited — complete your registration below.":"Get started in a few seconds."}),U.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Nr,{connections:U,callback:W}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})})]}),t.jsxs("form",{onSubmit:F,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[(((ce=V==null?void 0:V.first_name)==null?void 0:ce.enabled)||((B=V==null?void 0:V.last_name)==null?void 0:B.enabled))&&t.jsxs("div",{className:G?"w-grid-2":"",children:[((q=V==null?void 0:V.first_name)==null?void 0:q.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["First name",((X=V==null?void 0:V.first_name)==null?void 0:X.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"first_name",name:"first_name",autoComplete:"given-name",required:!0,minLength:3,maxLength:30,value:u.first_name,onChange:L,placeholder:"Jane","aria-invalid":!!h.first_name,pattern:"^[a-zA-Z]{3,30}$"}),h.first_name&&t.jsx("span",{className:"w-input-err",children:h.first_name})]}),((oe=V==null?void 0:V.last_name)==null?void 0:oe.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Last name",((Ee=V==null?void 0:V.last_name)==null?void 0:Ee.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"last_name",name:"last_name",autoComplete:"family-name",required:!0,minLength:3,maxLength:30,value:u.last_name,onChange:L,placeholder:"Doe","aria-invalid":!!h.last_name,pattern:"^[a-zA-Z]{3,30}$"}),h.last_name&&t.jsx("span",{className:"w-input-err",children:h.last_name})]})]}),(V==null?void 0:V.username.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Username",V.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",autoComplete:"username",minLength:3,maxLength:20,value:u.username,onChange:L,placeholder:"yourname","aria-invalid":!!h.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),h.username&&t.jsx("span",{className:"w-input-err",children:h.username})]}),(V==null?void 0:V.email_address.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Email address",V.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",maxLength:320,value:u.email,onChange:L,placeholder:"you@company.com","aria-invalid":!!h.email,required:!0,readOnly:(v==null?void 0:v.valid)&&!!(v!=null&&v.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),h.email&&t.jsx("span",{className:"w-input-err",children:h.email})]}),(V==null?void 0:V.phone_number.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Phone number",V.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(ys,{value:u.phone_number,onChange:L,error:h.phone_number,countryCode:b,setCountryCode:j}),h.phone_number&&t.jsx("span",{className:"w-input-err",children:h.phone_number})]}),(V==null?void 0:V.password.enabled)&&t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Password",V.password.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"new-password",value:u.password,onChange:L,placeholder:"Create a password","aria-invalid":!!h.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"}),h.password&&t.jsx("span",{className:"w-input-err",children:h.password})]}),h.submit&&t.jsx("span",{className:"w-input-err",children:h.submit}),t.jsx(Rc,{apiHost:(l==null?void 0:l.backend_host)??"",onSolve:z=>A(z),onError:()=>A("")}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:x||e||!H,children:x?t.jsx(vt,{size:15,onAccent:!0}):"Continue"}),(()=>{var we,ge;const z=(we=l==null?void 0:l.ui_settings)==null?void 0:we.tos_page_url,D=(ge=l==null?void 0:l.ui_settings)==null?void 0:ge.privacy_policy_url;return!z&&!D?null:t.jsxs("p",{className:"w-fineprint",children:["By continuing you agree to our"," ",z&&t.jsx(Et,{className:"w-link w-link--muted",to:z,children:"Terms of Service"}),z&&D&&" and ",D&&t.jsx(Et,{className:"w-link w-link--muted",to:D,children:"Privacy Policy"}),"."]})})()]})]})})}function Lc({icon:e,label:a,description:s,onClick:r,disabled:i,type:l="button"}){return t.jsxs("button",{type:l,className:"w-method",onClick:r,disabled:i,"data-disabled":i?"":void 0,children:[t.jsx("span",{className:"w-method-ic",children:e}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:a}),s&&t.jsx("span",{className:"w-method-desc",children:s})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Qt,{})})]})}const Pc=o.createContext(void 0);function $c(){const e=o.useContext(Pc);if(!e)throw new Error("useSignIn must be used within a SignInProvider");return e}function C4({children:e}){var j;const{deployment:a}=Ce(),[s,r]=o.useState((a==null?void 0:a.auth_settings.first_factor)||"email_password"),i=o.useRef(!!(a!=null&&a.auth_settings.first_factor)),[l,m]=o.useState(""),[c,d]=o.useState(!1),[p,u]=o.useState(!1),[f,h]=o.useState(!1),[g,x]=o.useState("identifier"),w=(a==null?void 0:a.social_connections.filter(v=>v.enabled))||[],b=a==null?void 0:a.auth_settings;return o.useEffect(()=>{var k;const v=(k=a==null?void 0:a.auth_settings)==null?void 0:k.first_factor;!i.current&&v&&(r(v),i.current=!0)},[(j=a==null?void 0:a.auth_settings)==null?void 0:j.first_factor]),t.jsx(Pc.Provider,{value:{email:l,showOtherOptions:c,showForgotPassword:p,otpSent:f,setFirstFactor:r,setEmail:m,setShowOtherOptions:d,setShowForgotPassword:u,setOtpSent:h,enabledSocialsProviders:w,authSettings:b,firstFactor:s,signInStep:g,setSignInStep:x},children:e})}const N4=[{key:"email_magic_link",icon:t.jsx(Tu,{}),label:"Magic link",description:"We'll email you a one-click sign-in link"},{key:"email_password",icon:t.jsx(Fu,{}),label:"Email and password",description:"Sign in with your email and password"},{key:"email_otp",icon:t.jsx(_l,{}),label:"Email one-time code",description:"We'll send a verification code to your email"},{key:"phone_otp",icon:t.jsx(Pu,{}),label:"Phone number",description:"We'll send a verification code via SMS"},{key:"username_password",icon:t.jsx(hs,{}),label:"Username and password",description:"Sign in with your username and password"}];function Oc(){const{deployment:e}=Ce(),{signIn:a}=ls("oauth"),{setFirstFactor:s,firstFactor:r,setShowOtherOptions:i,setSignInStep:l}=$c(),[m,c]=o.useState(!1),d=e==null?void 0:e.auth_settings,p=(e==null?void 0:e.social_connections.filter(x=>x.enabled))||[],u=async x=>{if(!m){c(!0);try{const{data:w}=await a.create({provider:x.provider});w&&typeof w=="object"&&"oauth_url"in w&&(window.location.href=w.oauth_url)}catch{}finally{c(!1)}}},f=N4.filter(x=>{if(x.key===r)return!1;const w=d==null?void 0:d.auth_factors_enabled;return w?w[x.key]:!1}),h=p.length>0,g=f.length>0;return t.jsxs(t.Fragment,{children:[h&&t.jsx(Nr,{connections:p,callback:u}),h&&g&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"or"})}),g&&t.jsx("div",{className:"w-method-stack",children:f.map(x=>t.jsx(Lc,{icon:x.icon,label:x.label,description:x.description,onClick:()=>{s(x.key),l("identifier"),i(!1)}},x.key))})]})}function S4({onBack:e}){var H;const{deployment:a}=Ce(),{navigate:s}=kt(),[r,i]=o.useState("start"),[l,m]=o.useState(""),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(""),[g,x]=o.useState(""),{forgotPassword:w,verifyOtp:b,resetPassword:j}=Po(),[v,k]=o.useState(!1),[N,_]=o.useState(null),C=async M=>{if(M.preventDefault(),!!l){k(!0),_(null);try{await w(l),i("otp")}catch(T){_(T)}finally{k(!1)}}},y=async M=>{if(M.preventDefault(),c.length===6){k(!0),_(null);try{const T=await b(l,c);T.data&&(u(T.data.token),i("reset"))}catch(T){_(T)}finally{k(!1)}}},E=async M=>{var T,P;if(M.preventDefault(),f===g&&!(f.length<8)){k(!0),_(null);try{const S=await j(p,f);if(S.data){const $=S.data,Z=$.signin_attempts&&$.signin_attempts.length>0?$.signin_attempts[$.signin_attempts.length-1]:null;if(Z&&!Z.completed){const R=(T=a==null?void 0:a.ui_settings)==null?void 0:T.sign_in_page_url;if(R){const L=new URL(R,window.location.origin);L.searchParams.set("signin_attempt_id",Z.id),s(L.toString())}else e()}else{const R=((P=a==null?void 0:a.ui_settings)==null?void 0:P.after_signin_redirect_url)||"/";s(R)}}}catch(S){_(S)}finally{k(!1)}}},A=t.jsx("span",{className:"w-auth-foot",children:t.jsx("span",{className:"w-link",style:{cursor:"pointer"},onClick:e,children:"Back to sign in"})});return t.jsxs($e,{children:[r==="start"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Forgot your password?",sub:"Reset it, or sign in another way."}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>i("email"),disabled:v,children:"Reset your password"}),t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsx(Oc,{}),t.jsxs("p",{className:"w-secsub",style:{textAlign:"center",marginTop:16},children:["Unable to reset password?"," ",t.jsx("a",{className:"w-link",href:((H=a==null?void 0:a.ui_settings)==null?void 0:H.support_page_url)||"#",children:"Get help"})]})]}),r==="email"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Forgot password",sub:"Enter your email and we'll send you a code to reset your password."}),t.jsxs("form",{onSubmit:C,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx("input",{className:"w-input",type:"email",id:"email",value:l,onChange:M=>m(M.target.value),placeholder:"you@company.com",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Send code"})]})]}),r==="otp"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Enter verification code",sub:`We sent a 6-digit code to ${l}.`}),t.jsxs("form",{onSubmit:y,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ya,{onComplete:M=>d(M),isSubmitting:v,error:N==null?void 0:N.message,onResend:async()=>{await w(l)}}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v||c.length!==6,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Verify"})]})]}),r==="reset"&&t.jsxs(tt,{footer:A,children:[t.jsx(rt,{title:"Reset password",sub:"Create a new password for your account."}),t.jsxs("form",{onSubmit:E,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"New password"}),t.jsx("input",{className:"w-input",type:"password",id:"password",value:f,onChange:M=>h(M.target.value),placeholder:"Enter new password",required:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Confirm new password"}),t.jsx("input",{className:"w-input",type:"password",id:"confirmPassword",value:g,onChange:M=>x(M.target.value),placeholder:"Confirm new password",required:!0})]}),N&&t.jsx("span",{className:"w-input-err",children:N.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:v,children:v?t.jsx(vt,{size:15,onAccent:!0}):"Reset password"})]})]})]})}function E4({onBack:e}){var r;const{deployment:a}=Ce(),s=(r=a==null?void 0:a.ui_settings)==null?void 0:r.app_name;return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to sign in"})}),children:[t.jsx(rt,{title:"All sign-in methods",sub:`Choose another way to sign in to ${s||"your account"}`}),t.jsx(Oc,{})]})})}function Zc({methods:e,onSelectMethod:a,onBack:s}){return t.jsx($e,{children:t.jsxs(tt,{footer:s?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:s,children:"Back to login"})}):void 0,children:[t.jsx(rt,{title:"Two-factor authentication",sub:"Choose how you'd like to verify your identity"}),t.jsx("div",{className:"w-method-stack",children:e.map(r=>t.jsx(Lc,{icon:r.icon,label:r.name,description:r.phoneNumber?`${r.description} ${r.phoneNumber}`:r.description,onClick:()=>a(r.id),disabled:!r.available},r.id))})]})})}function Hc({onVerify:e,onBack:a,loading:s}){const[r,i]=o.useState(""),[l,m]=o.useState(""),c=p=>{if(p.preventDefault(),r.length!==4){m("Please enter the last 4 digits of your phone number");return}e(r)},d=p=>{const u=p.target.value.replace(/\D/g,"").slice(0,4);i(u),m("")};return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Choose a different method"})}),children:[t.jsx(rt,{title:"Verify phone",sub:"Enter the last 4 digits of your phone number."}),t.jsxs("form",{onSubmit:c,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"lastDigits",children:"Last 4 digits"}),t.jsx("input",{className:`w-input${l?" w-input--invalid":""}`,type:"text",id:"lastDigits",name:"lastDigits",value:r,onChange:d,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!l,autoFocus:!0}),l&&t.jsx("span",{className:"w-input-err",children:l})]}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:s||r.length!==4,children:s?t.jsx(vt,{onAccent:!0}):"Send code"})]})]})})}const A4=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),M4=()=>t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),t.jsx("path",{d:"M12 18h.01"})]}),R4=()=>t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})});function Fc({onBack:e,attempt:a,completeVerification:s,prepareVerification:r}){const{deployment:i}=Ce(),[l,m]=o.useState(""),[c,d]=o.useState({}),[p,u]=o.useState(!1),[f,h]=o.useState(null),[g,x]=o.useState(!0),[w,b]=o.useState(!1),[j,v]=o.useState(""),[k,N]=o.useState(!1),{navigate:_}=kt(),C=(a==null?void 0:a.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(A4,{}),available:C.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(M4,{}),available:C.includes("phone_otp"),phoneNumber:j},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(R4,{}),available:C.includes("backup_code")}].filter(P=>P.available),E=async P=>{h(P),x(!1),P==="phone_otp"&&b(!0)},A=async P=>{var S,$;if(a){u(!0);try{const Z=await r({strategy:"phone_otp",lastDigits:P});Z&&"data"in Z&&((S=Z.data)!=null&&S.otp_sent)?(($=Z.data)!=null&&$.masked_phone&&v(Z.data.masked_phone),b(!1)):d({phone:"Phone number verification failed"})}catch(Z){d({phone:Z.message})}finally{u(!1)}}},H=async(P,S)=>{if(P.preventDefault(),p)return;const $=S||l,Z={};if($?f==="authenticator"&&$.length!==6?Z.code="Authentication code must be 6 digits":f==="phone_otp"&&$.length!==6&&(Z.code="SMS code must be 6 digits"):Z.code="Verification code is required",d(Z),!(Object.keys(Z).length>0)){u(!0);try{await s($)}catch(R){d({submit:R.message})}finally{u(!1)}}},M=P=>{let S=P.target.value;f!=="backup_code"&&(S=S.replace(/\D/g,"").slice(0,6)),m(S),d($=>({...$,code:""}))};if(o.useEffect(()=>{var P;if(a.completed){N(!0);let S=gt(i,new URLSearchParams(window.location.search).get("redirect_uri"));if(S||(S=((P=i==null?void 0:i.ui_settings)==null?void 0:P.after_signin_redirect_url)||null),!S&&(i!=null&&i.frontend_host)&&(S=`https://${i.frontend_host}`),S){let $;try{$=new URL(S)}catch{$=new URL(S,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&$.searchParams.set("__dev_session__",xt(i.backend_host)||""),_($.toString())}return}},[a,i]),k)return t.jsx(js,{});if(g)return y.length===0?t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(rt,{title:"Set up two-factor authentication",sub:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."}),e&&t.jsx("div",{style:{textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:e,children:"Back to login"})})]})}):t.jsx(Zc,{methods:y,onSelectMethod:E,onBack:e});if(w&&f==="phone_otp")return t.jsx(Hc,{onVerify:A,onBack:()=>{b(!1),x(!0),h(null)},loading:p});const T=f==="authenticator"?"Enter the 6-digit code from your authenticator app":f==="phone_otp"?`Enter the 6-digit code sent to your phone ${j}`:"Enter one of your backup codes";return t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]}),children:[t.jsx(rt,{title:"Two-factor authentication",sub:T}),t.jsxs("form",{onSubmit:H,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[f==="backup_code"?t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",htmlFor:"code",children:"Backup code"}),t.jsx("input",{className:`w-input${c.code?" w-input--invalid":""}`,type:"text",id:"code",name:"code",value:l,onChange:M,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!c.code,autoFocus:!0}),c.code&&t.jsx("span",{className:"w-input-err",children:c.code})]}):t.jsx(ya,{onComplete:async P=>{if(m(P),f!=="backup_code"){const S=new Event("submit",{bubbles:!0,cancelable:!0});await H(S,P)}},onResend:f==="phone_otp"?async()=>{try{await r({strategy:"phone_otp",lastDigits:j.slice(-4)})}catch(P){d({submit:P.message})}}:void 0,error:c.code,isSubmitting:p}),c.submit&&t.jsx("span",{className:"w-input-err",children:c.submit}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:p||!l,children:p?t.jsx(vt,{onAccent:!0}):"Verify"})]}),t.jsxs("div",{style:{marginTop:18,textAlign:"center",display:"flex",flexDirection:"column",gap:8},children:[t.jsx("button",{type:"button",className:"w-link",onClick:()=>{x(!0),h(null),m(""),d({})},children:"Try another method"}),e&&t.jsx("button",{type:"button",className:"w-link w-link--muted",onClick:e,children:"Back to login"})]})]})})}function Tc({attempt:e,onBack:a,completeProfile:s,completeVerification:r,prepareVerification:i}){var O,F,W,U,V,G,Y,de,fe;const{deployment:l}=Ce(),{navigate:m}=kt(),[c,d]=o.useState({}),[p,u]=o.useState({}),[f,h]=o.useState("US"),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(null),[k,N]=o.useState(!1),_=j,C=w,y=()=>{var ae;N(!0);let ne=gt(l,new URLSearchParams(window.location.search).get("redirect_uri"));if(ne||(ne=((ae=l==null?void 0:l.ui_settings)==null?void 0:ae.after_signin_redirect_url)||null),!ne&&(l!=null&&l.frontend_host)&&(ne=`https://${l.frontend_host}`),ne){let re;try{re=new URL(ne)}catch{re=new URL(ne,window.location.origin)}(l==null?void 0:l.mode)==="staging"&&re.searchParams.set("__dev_session__",xt(l.backend_host)||""),m(re.toString())}},E=async ne=>{b(!0),v(null);try{await s(ne)&&y()}catch(ae){const re=ae;throw v(re),re}finally{b(!1)}},A=async ne=>{b(!0),v(null);try{return await r(ne)&&y(),!0}catch(ae){return v(ae),!1}finally{b(!1)}};if(k||!e)return t.jsx(js,{});const H=e.missing_fields||[],M=l==null?void 0:l.auth_settings,T=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||g,P=ne=>{const{name:ae,value:re}=ne.target;d(Le=>({...Le,[ae]:re})),p[ae]&&u(Le=>({...Le,[ae]:""}))},S=()=>{const ne={};return H.forEach(ae=>{var K,at,ze,We,Re;const re=c[ae];let Le=!1;switch(ae){case"first_name":Le=((K=M==null?void 0:M.first_name)==null?void 0:K.enabled)||!1;break;case"last_name":Le=((at=M==null?void 0:M.last_name)==null?void 0:at.enabled)||!1;break;case"username":Le=((ze=M==null?void 0:M.username)==null?void 0:ze.enabled)||!1;break;case"phone_number":Le=((We=M==null?void 0:M.phone_number)==null?void 0:We.enabled)||!1;break;case"email_address":Le=((Re=M==null?void 0:M.email_address)==null?void 0:Re.enabled)||!1;break;default:Le=!0}if(Le&&(!re||re.trim()==="")){const ce=ae.replace("_"," ").replace(/\b\w/g,B=>B.toUpperCase());ne[ae]=`${ce} is required`}}),c.username&&H.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(c.username)||(ne.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),c.phone_number&&H.includes("phone_number")&&(/^\d{7,15}$/.test(c.phone_number)||(ne.phone_number="Phone number must contain 7-15 digits")),c.email&&H.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(c.email)||(ne.email_address="Please enter a valid email address")),u(ne),Object.keys(ne).length===0},$=async ne=>{if(ne.preventDefault(),!S())return;const ae={...c};c.phone_number&&f&&(ae.phone_country_code=f),await E(ae)},Z=ne=>{const ae=ne.target.value;d(re=>({...re,phone_number:ae})),p.phone_number&&u(re=>({...re,phone_number:""}))},R=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{to:(l==null?void 0:l.ui_settings.support_page_url)||"#",className:"w-link",children:"Get help"})]});if(T){const ne=e.current_step==="verify_phone_otp"?"Verify your phone number":"Verify your email",ae=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",re=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx($e,{children:t.jsxs(tt,{footer:R,children:[t.jsx(rt,{title:ne,sub:ae}),t.jsxs("form",{onSubmit:Le=>Le.preventDefault(),noValidate:!0,style:{display:"flex",flexDirection:"column",gap:14},children:[t.jsx(ya,{onComplete:A,onResend:async()=>{await i({strategy:re})},error:_==null?void 0:_.message,isSubmitting:C}),_&&t.jsx("span",{className:"w-input-err",children:_.message})]}),t.jsx("div",{style:{marginTop:16,textAlign:"center"},children:t.jsx("button",{type:"button",className:"w-link",onClick:()=>x(!1),children:"Back to profile completion"})})]})})}const L=!!((O=M==null?void 0:M.first_name)!=null&&O.enabled&&((F=M==null?void 0:M.last_name)!=null&&F.enabled)&&H.includes("first_name")&&H.includes("last_name"));return t.jsx($e,{children:t.jsxs(tt,{footer:a?t.jsx("span",{className:"w-auth-foot",children:t.jsx("button",{type:"button",className:"w-link",onClick:a,children:"Back to login"})}):R,children:[t.jsx(rt,{title:"Complete your profile",sub:"Please provide the following information to continue"}),t.jsxs("form",{onSubmit:$,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(H.includes("first_name")||H.includes("last_name"))&&(((W=M==null?void 0:M.first_name)==null?void 0:W.enabled)||((U=M==null?void 0:M.last_name)==null?void 0:U.enabled))&&t.jsxs("div",{className:L?"w-grid-2":"",children:[H.includes("first_name")&&((V=M==null?void 0:M.first_name)==null?void 0:V.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",M.first_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.first_name?" w-input--invalid":""}`,type:"text",id:"first_name",name:"first_name",value:c.first_name||"",onChange:P,placeholder:"Enter your first name",disabled:C,autoComplete:"given-name"}),p.first_name&&t.jsx("span",{className:"w-input-err",children:p.first_name})]}),H.includes("last_name")&&((G=M==null?void 0:M.last_name)==null?void 0:G.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",M.last_name.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.last_name?" w-input--invalid":""}`,type:"text",id:"last_name",name:"last_name",value:c.last_name||"",onChange:P,placeholder:"Enter your last name",disabled:C,autoComplete:"family-name"}),p.last_name&&t.jsx("span",{className:"w-input-err",children:p.last_name})]})]}),H.includes("username")&&((Y=M==null?void 0:M.username)==null?void 0:Y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"username",children:["Username",M.username.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.username?" w-input--invalid":""}`,type:"text",id:"username",name:"username",value:c.username||"",onChange:P,placeholder:"Choose a username",disabled:C,autoComplete:"username"}),p.username&&t.jsx("span",{className:"w-input-err",children:p.username})]}),H.includes("phone_number")&&((de=M==null?void 0:M.phone_number)==null?void 0:de.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"phone_number",children:["Phone number",M.phone_number.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx(ys,{value:c.phone_number||"",onChange:Z,error:p.phone_number,countryCode:f,setCountryCode:h}),p.phone_number&&t.jsx("span",{className:"w-input-err",children:p.phone_number})]}),H.includes("email_address")&&((fe=M==null?void 0:M.email_address)==null?void 0:fe.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",M.email_address.required&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:`w-input${p.email_address?" w-input--invalid":""}`,type:"email",id:"email",name:"email",value:c.email||"",onChange:P,placeholder:"Enter your email address",disabled:C,autoComplete:"email"}),p.email_address&&t.jsx("span",{className:"w-input-err",children:p.email_address})]}),_&&t.jsx("span",{className:"w-input-err",children:_.message}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:C,children:C?t.jsx(vt,{onAccent:!0}):"Continue"})]})]})})}function Ic({onComplete:e,onSkip:a}){var u;const[s,r]=o.useState(!1),[i,l]=o.useState(null),{registerPasskey:m}=ba(),{deployment:c}=Ce(),d=async()=>{r(!0),l(null);try{await m(),e==null||e()}catch(f){l(f instanceof Error?f.message:"Failed to register passkey")}finally{r(!1)}},p=((u=c==null?void 0:c.ui_settings)==null?void 0:u.app_name)||"this app";return t.jsxs("div",{className:"w-flex w-flex-col w-items-center w-text-center",children:[t.jsx("div",{className:"w-feature-badge",children:t.jsx(ar,{size:26})}),t.jsx("h1",{className:"w-title-lg",children:"Add a passkey"}),t.jsxs("p",{className:"w-sub",style:{marginTop:6,maxWidth:320},children:["Sign in faster and more securely with a passkey. Use your fingerprint, face, or screen lock to access ",p,"."]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,width:"100%",marginTop:24},children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:d,disabled:s,children:s?t.jsxs(t.Fragment,{children:[t.jsx(vt,{size:15,onAccent:!0}),"Registering…"]}):t.jsxs(t.Fragment,{children:[t.jsx(ar,{}),"Add passkey"]})}),t.jsx("button",{type:"button",className:"w-social",onClick:a,children:"Maybe later"})]}),i&&t.jsx("p",{className:"w-input-err",style:{marginTop:14},children:i})]})}function L4(){return t.jsx(C4,{children:t.jsx(P4,{})})}function P4(){var yt,na,ra,ia,oa,ie,ve,Ae,J,be,Je,De,jt,_t,Ke,wt,Bt,la,ca,da,Ur,Wr,Br;const{deployment:e}=Ce(),{navigate:a}=kt(),{session:s,loading:r,refetch:i,exchangeTicket:l,switchSignIn:m}=ot(),c=((na=(yt=e==null?void 0:e.auth_settings)==null?void 0:yt.multi_session_support)==null?void 0:na.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:u,showForgotPassword:f,setShowForgotPassword:h,showOtherOptions:g,setShowOtherOptions:x,enabledSocialsProviders:w,firstFactor:b,setFirstFactor:j,signInStep:v,setSignInStep:k}=$c(),{loading:N,signIn:_,signinAttempt:C,discardSignInAttempt:y,setSignInAttempt:E}=ls("generic"),{signIn:A}=ls("oauth"),{signIn:H}=ls("passkey"),[M,T]=o.useState({email:"",username:"",password:"",phone:""}),[P,S]=o.useState({}),[$,Z]=o.useState(!1),[R,L]=o.useState(""),[O,F]=o.useState("US"),[W,U]=o.useState(!1),[V,G]=o.useState(null),[Y,de]=o.useState(!1),[fe,ne]=o.useState(!1),[ae,re]=o.useState(!1),[Le,K]=o.useState(60),[at,ze]=o.useState(!1),[We,Re]=o.useState(null),[ce,B]=o.useState(""),q=!!ce,X=[...(s==null?void 0:s.signins)||[]].sort((ee,te)=>{var ue,Ze;return ee.id===((ue=s==null?void 0:s.active_signin)==null?void 0:ue.id)?-1:te.id===((Ze=s==null?void 0:s.active_signin)==null?void 0:Ze.id)?1:0});o.useEffect(()=>{const ee=new URLSearchParams(window.location.search),te=ee.get("error"),ue=ee.get("error_description");if(te==="access_denied"&&ue){G(ue),ee.delete("error"),ee.delete("error_description");const Ze=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Ze)}},[]),o.useEffect(()=>{if(b!=="email_magic_link"||!p)return;K(60),ze(!1);const ee=setInterval(()=>{K(te=>te<=1?(ze(!0),clearInterval(ee),0):te-1)},1e3);return()=>clearInterval(ee)},[b,p]),o.useEffect(()=>{var ee,te,ue,Ze;if(!r&&(s!=null&&s.active_signin)&&!c&&!W&&!Y){let Ne=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));Ne||(Ne=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!Ne&&(e!=null&&e.frontend_host)&&(Ne=`https://${e.frontend_host}`);const dt=(te=e==null?void 0:e.auth_settings)==null?void 0:te.passkey;(dt==null?void 0:dt.enabled)&&(dt==null?void 0:dt.prompt_registration_on_auth)&&!((Ze=(ue=s.active_signin)==null?void 0:ue.user)!=null&&Ze.has_passkeys)?(Re(Ne),de(!0)):Ne&&(U(!0),a(Ne))}},[s,r,c,e,a,W]);const oe=ee=>{let{name:te,value:ue}=ee.target;te==="phone"?ue=ue.replace(/[^0-9]/g,""):te==="email"&&(d(ue),ue=ue.toLowerCase()),T(Ze=>({...Ze,[te]:ue})),S(Ze=>({...Ze,[te]:""}))},Ee=()=>{T({email:"",username:"",password:"",phone:""}),S({}),F("US"),k("identifier")},z=async ee=>{if(!ee){S({email:"Email address is required"});return}if(!q){S({submit:"Challenge verification is still loading. Please try again."});return}Z(!0),S({});try{const te=await _.identify(ee,ce);if(te.strategy==="sso"&&te.connection_id){const ue=new URLSearchParams(window.location.search),Ze=gt(e,ue.get("redirect_uri"))||void 0,Ne=await _.initEnterpriseSso(te.connection_id,Ze,ce);if(Ne&&Ne.sso_url){U(!0),window.location.href=Ne.sso_url;return}}else if(te.strategy==="social"&&te.provider){const ue=w.find(Ze=>Ze.provider===te.provider);if(ue){const Ze=new URLSearchParams(window.location.search),Ne=gt(e,Ze.get("redirect_uri"))||void 0,{data:dt}=await A.create({provider:ue.provider,redirectUri:Ne,challenge_token:ce});if(dt&&typeof dt=="object"&&"oauth_url"in dt){U(!0),window.location.href=dt.oauth_url;return}}else k("password")}else k("password")}catch(te){S({submit:te.message})}finally{W||Z(!1)}},D=async ee=>{if(ee.preventDefault(),N||$)return;y();const te={};if(v==="identifier"&&b==="email_password"){if(!M.email){S({email:"Email address is required"});return}await z(M.email);return}if(v==="identifier"&&b==="username_password"){if(!M.username){S({username:"Username is required"});return}S({}),k("password");return}if(b==="email_password"?(M.email||(te.email="Email address is required"),M.password||(te.password="Password is required")):b==="username_password"?(M.username||(te.username="Username is required"),M.password||(te.password="Password is required")):b==="email_otp"||b==="email_magic_link"?M.email||(te.email="Email address is required"):b==="phone_otp"&&(M.phone?/^\d{7,15}$/.test(M.phone)||(te.phone="Phone number must contain 7-15 digits"):te.phone="Phone number is required"),S(te),Object.keys(te).length>0)return;let ue="";switch(b){case"email_password":ue="plain_email";break;case"username_password":ue="plain_username";break;case"email_otp":ue="email_otp";break;case"email_magic_link":ue="magic_link";break;case"phone_otp":ue="phone_otp";break}const Ze=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";if(!q){S({submit:"Challenge verification is still loading. Please try again."});return}Z(!0);try{const Ne={...M,strategy:ue};b==="phone_otp"&&O&&(Ne.phone_country_code=O),ce&&(Ne.challenge_token=ce),await _.create(Ne),Ze||Z(!1)}catch(Ne){S({submit:Ne.message}),Z(!1)}},we=async ee=>{if(ee.preventDefault(),N||$)return;const te={};if(!R){te.otp="OTP code is required",S(te);return}Z(!0),S({});try{await _.completeVerification(R),u(!1),L("")}catch(ue){S({otp:ue.message||"Verification failed"})}finally{Z(!1)}},ge=async ee=>{if(!(N||$||!q)){Z(!0);try{const te=new URLSearchParams(window.location.search),ue=gt(e,te.get("redirect_uri"))||void 0,{data:Ze}=await A.create({provider:ee.provider,redirectUri:ue,challenge_token:ce});Ze&&typeof Ze=="object"&&"oauth_url"in Ze&&(window.location.href=Ze.oauth_url)}catch(te){S({submit:te.message})}finally{Z(!1)}}},xe=async()=>{var ee;if(!(N||$||!q)){Z(!0),S({});try{const te=await H.create({challenge_token:ce});if("data"in te&&te.data){await i();let ue=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));ue||(ue=((ee=e==null?void 0:e.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!ue&&(e!=null&&e.frontend_host)&&(ue=`https://${e.frontend_host}`),U(!0),ue&&a(ue)}}catch(te){S({submit:te.message||"Passkey sign-in failed"})}finally{Z(!1)}}},lt=()=>{var ue;let ee=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(ee||(ee=((ue=e==null?void 0:e.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!ee&&(e!=null&&e.frontend_host)&&(ee=`https://${e.frontend_host}`),!ee)return null;let te;try{te=new URL(ee)}catch{te=new URL(ee,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&te.searchParams.set("__dev_session__",xt(e.backend_host)||""),te.toString()},Qe=async ee=>{if(!(N||$)){S({}),Z(!0);try{await m(ee);const te=lt();te&&(U(!0),a(te))}catch(te){S({submit:te.message||"Failed to continue with selected account"})}finally{Z(!1)}}},Q=(ee,te)=>`${ee||""} ${te||""}`.trim().split(" ").filter(Boolean).map(ue=>ue[0]).join("").toUpperCase().slice(0,2)||"?",le=o.useRef(!1);if(o.useEffect(()=>{if(r)return;const ee=new URLSearchParams(window.location.search),te=ee.get("ticket");if(te&&!le.current&&!N){le.current=!0,ee.delete("ticket");const Ze=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Ze),(async()=>{var dt;try{Z(!0),await l(te),U(!0);let It=gt(e,new URLSearchParams(window.location.search).get("redirect_uri"));if(It||(It=((dt=e==null?void 0:e.ui_settings)==null?void 0:dt.after_signin_redirect_url)||null),!It&&(e!=null&&e.frontend_host)&&(It=`https://${e.frontend_host}`),It){let Ns;try{Ns=new URL(It)}catch{Ns=new URL(It,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Ns.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(Ns.toString())}return}catch(It){S({submit:It.message||"Failed to exchange ticket"}),le.current=!1}finally{Z(!1)}})();return}const ue=ee.get("signin_attempt_id");if(ue&&(s!=null&&s.signin_attempts)&&!C){const Ze=s.signin_attempts.find(Ne=>Ne.id===ue);if(Ze){E(Ze),ee.delete("signin_attempt_id");const Ne=ee.toString()?`${window.location.pathname}?${ee.toString()}`:window.location.pathname;window.history.replaceState({},"",Ne)}}},[s,r,C,E,N]),o.useEffect(()=>{var Ze;if(!C)return;if(C.completed){U(!0);let Ne=new URLSearchParams(window.location.search).get("redirect_uri");if(Ne||(Ne=((Ze=e==null?void 0:e.ui_settings)==null?void 0:Ze.after_signin_redirect_url)||null),!Ne&&(e!=null&&e.frontend_host)&&(Ne=`https://${e.frontend_host}`),Ne){let dt;try{dt=new URL(Ne)}catch{dt=new URL(Ne,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&dt.searchParams.set("__dev_session__",xt(e.backend_host)||""),a(dt.toString())}return}if(!_||p)return;const te={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[C.current_step];if(!te)return;(async()=>{try{await _.prepareVerification({strategy:te,challenge_token:ce}),Z(!1),u(!0)}catch{S({submit:"Failed to send verification. Please try again."}),Z(!1)}})()},[C,_,p,u,a,e]),g)return t.jsx(E4,{onBack:()=>x(!1)});if(f)return t.jsx(S4,{onBack:()=>h(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return t.jsx(Fc,{attempt:C,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),Ee(),u(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return t.jsx(Tc,{attempt:C,completeProfile:_.completeProfile,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),Ee(),u(!1)}});if(Y){const ee=()=>{de(!1),We&&(U(!0),a(We))},te=()=>{de(!1),We&&(U(!0),a(We))};return t.jsx($e,{children:t.jsx(tt,{children:t.jsx(Ic,{onComplete:ee,onSkip:te})})})}if(r||W)return t.jsx(js,{});const me=((ra=e==null?void 0:e.ui_settings)==null?void 0:ra.app_name)||"App",Pe=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&p,qe=b==="email_magic_link",pt=c&&!Pe&&X.length>0&&!ae,aa=()=>{u(!1),y(),Ee()};let Tt;if(Pe){const ee=b==="phone_otp"?"Check your phone":qe?"Check your inbox":"Enter the code",te=qe?"We sent a magic link to your email — click it to sign in instantly.":b==="phone_otp"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email.",ue=(b==="email_otp"||qe)&&M.email?M.email:b==="phone_otp"&&M.phone?`+${M.phone}`:null;Tt=t.jsx(rt,{title:ee,sub:te,children:ue&&t.jsxs("button",{type:"button",className:"w-addr-badge",onClick:aa,children:[t.jsx($l,{weight:"bold"}),ue]})})}else Tt=t.jsx(rt,{title:"Sign in to your account",sub:`Please enter your details to continue to ${me}.`});let sa;Pe?sa=t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx(Et,{className:"w-link",to:((ia=e==null?void 0:e.ui_settings)==null?void 0:ia.support_page_url)||"#",children:"Get help"})]}):sa=t.jsxs("span",{className:"w-auth-foot",children:["Don't have an account?"," ",t.jsx(Et,{className:"w-link",to:`${((oa=e==null?void 0:e.ui_settings)==null?void 0:oa.sign_up_page_url)??""}${window.location.search}`,children:"Sign up"})]});let Wt;if(Pe&&qe)Wt=t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,padding:"12px 0 4px"},children:at?t.jsx("button",{type:"button",className:"w-link w-linkbtn",onClick:async()=>{ze(!1),K(60);try{await _.prepareVerification({strategy:"magic_link",challenge_token:ce})}catch{}},children:"Resend magic link"}):t.jsxs("span",{className:"w-secsub",children:["Resend in ",Le,"s"]})});else if(Pe)Wt=t.jsxs("form",{onSubmit:we,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:20,alignItems:"center"},children:[t.jsx(ya,{onComplete:async ee=>{if(L(ee),ee&&ee.length===6){Z(!0),S({});try{await _.completeVerification(ee),u(!1)}catch(te){S({otp:te.message||"Verification failed"})}finally{Z(!1)}}},onResend:async()=>{const ee=b==="email_otp"?"email_otp":"phone_otp";await _.prepareVerification({strategy:ee,challenge_token:ce})},error:P.otp,isSubmitting:$}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N||!R,children:$&&R?t.jsx(vt,{size:15,onAccent:!0}):`Continue to ${me}`})]});else{const ee=(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((ve=(ie=e==null?void 0:e.auth_settings)==null?void 0:ie.email_address)==null?void 0:ve.enabled),te=b==="username_password"&&((J=(Ae=e==null?void 0:e.auth_settings)==null?void 0:Ae.username)==null?void 0:J.enabled),ue=b==="phone_otp"&&((Je=(be=e==null?void 0:e.auth_settings)==null?void 0:be.phone_number)==null?void 0:Je.enabled),Ze=v==="password"&&(b==="email_password"||b==="username_password")&&((jt=(De=e==null?void 0:e.auth_settings)==null?void 0:De.password)==null?void 0:jt.enabled);Wt=t.jsxs(t.Fragment,{children:[w.length>0&&t.jsx(Nr,{connections:w,callback:ge}),((Ke=(_t=e==null?void 0:e.auth_settings)==null?void 0:_t.passkey)==null?void 0:Ke.enabled)&&t.jsxs("button",{type:"button",className:"w-social",style:{marginTop:w.length>0?10:0},onClick:xe,disabled:$,children:[t.jsx(ar,{}),t.jsx("span",{children:"Sign in with a passkey"})]}),(w.length>0||((Bt=(wt=e==null?void 0:e.auth_settings)==null?void 0:wt.passkey)==null?void 0:Bt.enabled))&&t.jsx("div",{className:"w-or",children:t.jsx("span",{children:"OR"})}),t.jsxs("form",{onSubmit:D,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:13},children:[ee&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Email address"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&b==="email_password"&&M.email?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:M.email}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>k("identifier"),children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"email",id:"email",name:"email",autoComplete:"email",value:M.email,onChange:oe,placeholder:"you@company.com","aria-invalid":!!P.email}),P.email&&t.jsx("span",{className:"w-input-err",children:P.email})]}),te&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{className:"w-label",children:"Username"}),v==="identifier"&&t.jsx("span",{className:"w-link w-link--muted w-link--sm",onClick:()=>x(!0),children:"Other methods"})]}),v==="password"&&M.username?t.jsxs("div",{className:"w-locked",children:[t.jsx("span",{className:"w-locked-ic",children:t.jsx(hi,{})}),t.jsx("span",{className:"w-locked-val",children:M.username}),t.jsx("button",{type:"button",className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer",background:"none",border:0},onClick:()=>{k("identifier"),T(Ne=>({...Ne,password:""}))},children:"Edit"})]}):t.jsx(qt,{className:"w-input",type:"text",id:"username",name:"username",value:M.username,onChange:oe,placeholder:"yourname","aria-invalid":!!P.username,autoComplete:"username"}),P.username&&t.jsx("span",{className:"w-input-err",children:P.username})]}),ue&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(ys,{value:M.phone,onChange:oe,error:P.phone,countryCode:O,setCountryCode:F}),P.phone&&t.jsx("span",{className:"w-input-err",children:P.phone})]}),Ze&&t.jsxs("label",{className:"w-field",children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{className:"w-label",children:"Password"}),t.jsx("span",{className:"w-link w-link--muted",style:{fontSize:12,cursor:"pointer"},onClick:()=>h(!0),children:"Forgot?"})]}),t.jsx(qt,{className:"w-input",type:"password",id:"password",name:"password",autoComplete:"current-password",value:M.password,onChange:oe,placeholder:"••••••••","aria-invalid":!!P.password}),P.password&&t.jsx("span",{className:"w-input-err",children:P.password})]}),P.submit&&t.jsx("span",{className:"w-input-err",children:P.submit}),t.jsx(Rc,{apiHost:(e==null?void 0:e.backend_host)??"",onSolve:Ne=>B(Ne),onError:()=>B("")}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:$||N||!q,children:$?t.jsx(vt,{size:15,onAccent:!0}):t.jsxs(t.Fragment,{children:[v==="identifier"?"Continue":"Sign in",t.jsx(Qt,{weight:"bold"})]})}),v==="password"&&((ca=(la=e==null?void 0:e.auth_settings)==null?void 0:la.auth_factors_enabled)==null?void 0:ca.email_otp)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-or",style:{margin:"5px 0"},children:t.jsx("span",{children:"OR"})}),t.jsxs("button",{type:"button",className:"w-method",disabled:$,onClick:async()=>{Z(!0),S({});try{await _.create({email:M.email,strategy:"email_otp",challenge_token:ce}),j("email_otp")}catch(Ne){S({submit:Ne.message}),Z(!1)}},children:[t.jsx("span",{className:"w-method-ic",children:t.jsx(_l,{})}),t.jsxs("span",{className:"w-method-body",children:[t.jsx("span",{className:"w-method-title",children:"Sign in with a code"}),t.jsx("span",{className:"w-method-desc",children:"We'll send a 6-digit code to your email"})]}),t.jsx("span",{className:"w-method-go",children:t.jsx(Qt,{})})]})]})]})]})}return t.jsx($e,{children:t.jsxs(tt,{footer:sa,children:[Tt,V&&t.jsxs("div",{className:"w-banner w-banner--error",style:{marginBottom:18},children:[t.jsx(Fa,{weight:"fill"}),t.jsxs("span",{className:"w-banner-txt",children:[t.jsx("strong",{children:"Access denied."})," ",V," ",t.jsx("span",{className:"w-link",onClick:()=>G(null),children:"Try again"})]})]}),pt&&(fe?t.jsxs("div",{className:"w-acct-list",children:[t.jsx("div",{className:"w-secsub w-acct-list-head",children:"Choose an account"}),t.jsxs("div",{className:"w-acct-list-body",children:[X.map(ee=>{var te,ue,Ze,Ne;return t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>Qe(ee.id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:ee.user.has_profile_picture?t.jsx("img",{src:ee.user.profile_picture_url,alt:((te=ee.user.primary_email_address)==null?void 0:te.email)||"account"}):Q(ee.user.first_name,ee.user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsx("span",{className:"w-acct-name",children:ee.user.first_name&&ee.user.last_name?`${ee.user.first_name} ${ee.user.last_name}`:ee.user.first_name||((Ze=(ue=ee.user.primary_email_address)==null?void 0:ue.email)==null?void 0:Ze.split("@")[0])||"Account"}),t.jsx("span",{className:"w-secsub",children:(Ne=ee.user.primary_email_address)==null?void 0:Ne.email})]}),t.jsx(Qt,{className:"w-acct-go"})]},ee.id)}),t.jsxs("button",{type:"button",className:"w-acct",onClick:()=>{ne(!1),re(!0),Ee()},children:[t.jsx("span",{className:"w-avatar",style:{background:"var(--wa-surface-subtle)",color:"var(--wa-text-muted)"},children:t.jsx(Wu,{size:16})}),t.jsx("span",{className:"w-acct-text w-acct-name",children:"Use a different account"}),t.jsx(Qt,{className:"w-acct-go"})]})]})]}):t.jsxs("button",{type:"button",className:"w-acct","data-active":!0,style:{marginBottom:18},onClick:()=>Qe(X[0].id),disabled:$||N,children:[t.jsx("span",{className:"w-avatar",children:X[0].user.has_profile_picture?t.jsx("img",{src:X[0].user.profile_picture_url,alt:((da=X[0].user.primary_email_address)==null?void 0:da.email)||"account"}):Q(X[0].user.first_name,X[0].user.last_name)}),t.jsxs("span",{className:"w-acct-text",children:[t.jsxs("span",{className:"w-acct-name",children:["Welcome back,"," ",X[0].user.first_name||((Wr=(Ur=X[0].user.primary_email_address)==null?void 0:Ur.email)==null?void 0:Wr.split("@")[0])||"back"]}),t.jsx("span",{className:"w-secsub",children:(Br=X[0].user.primary_email_address)==null?void 0:Br.email})]}),t.jsx("span",{className:"w-link w-link--muted w-link--sm",style:{flex:"none"},onClick:ee=>{ee.stopPropagation(),X.length>1?ne(!0):(re(!0),Ee())},children:"Not you?"})]})),Wt]})})}function $4(){var b,j,v,k,N,_,C,y,E,A,H,M;const{deployment:e}=Ce(),{loading:a,joinWaitlist:s}=Mo(),[r,i]=o.useState({first_name:"",last_name:"",email:""}),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(null),f=()=>{if(p)return p.message},h=e==null?void 0:e.auth_settings,g=!!((b=h==null?void 0:h.first_name)!=null&&b.enabled&&((j=h==null?void 0:h.last_name)!=null&&j.enabled)),x=T=>{const{name:P,value:S}=T.target;i($=>({...$,[P]:S}))},w=async T=>{if(T.preventDefault(),!!h){d(!0),u(null);try{(await s(r)).data&&m(!0)}catch(P){u(P)}finally{d(!1)}}};return l?t.jsx($e,{children:t.jsx(tt,{children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16,textAlign:"center"},children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{weight:"bold"})})]}),t.jsx("h1",{className:"w-auth-title",children:"You're on the waitlist"}),t.jsxs("p",{className:"w-auth-sub",children:["Thanks for your interest! We'll notify you at"," ",r.email," when we're ready for you to join."]})]})})}):t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-auth-foot",children:["Need assistance?"," ",t.jsx("a",{href:"/contact",className:"w-link",children:"Get help"})]}),children:[t.jsx(rt,{title:"Join the waitlist",sub:"Be the first to know when we launch!"}),t.jsxs("form",{onSubmit:w,noValidate:!0,style:{display:"flex",flexDirection:"column",gap:16},children:[(((v=h==null?void 0:h.first_name)==null?void 0:v.enabled)||((k=h==null?void 0:h.last_name)==null?void 0:k.enabled))&&t.jsxs("div",{className:g?"w-grid-2":"",children:[((N=h==null?void 0:h.first_name)==null?void 0:N.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"first_name",children:["First name",((_=h==null?void 0:h.first_name)==null?void 0:_.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"first_name",name:"first_name",required:(C=h==null?void 0:h.first_name)==null?void 0:C.required,minLength:2,maxLength:50,value:r.first_name,onChange:x,placeholder:"First name"})]}),((y=h==null?void 0:h.last_name)==null?void 0:y.enabled)&&t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"last_name",children:["Last name",((E=h==null?void 0:h.last_name)==null?void 0:E.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"text",id:"last_name",name:"last_name",required:(A=h==null?void 0:h.last_name)==null?void 0:A.required,minLength:2,maxLength:50,value:r.last_name,onChange:x,placeholder:"Last name"})]})]}),t.jsxs("div",{className:"w-field",children:[t.jsxs("label",{className:"w-label",htmlFor:"email",children:["Email address",((H=h==null?void 0:h.email_address)==null?void 0:H.required)&&t.jsx("span",{className:"w-req",children:"*"})]}),t.jsx("input",{className:"w-input",type:"email",id:"email",name:"email",required:(M=h==null?void 0:h.email_address)==null?void 0:M.required,value:r.email,onChange:x,placeholder:"Enter your email address"})]}),f()&&t.jsx("span",{className:"w-input-err",children:f()}),t.jsx("button",{type:"submit",className:"w-btn w-btn--primary w-btn--block",disabled:c||a,children:c||a?t.jsx(vt,{onAccent:!0}):"Join waitlist"})]})]})})}function On({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx($e,{children:t.jsxs(tt,{footer:l,children:[t.jsx(rt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function O4(){const{deployment:e}=Ce(),{navigate:a}=kt(),{error:s,session:r,processed:i,signinAttempt:l,redirectUri:m,loading:c}=Ro(),[d,p]=o.useState(!1),[u,f]=o.useState(null),h=()=>{window.location.reload()},g=()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||"/sign-in";a(b)},x=()=>{p(!1),u&&a(u)},w=()=>{p(!1),u&&a(u)};if(o.useEffect(()=>{var b,j,v,k,N;if(!(!i||c||d)){if(l&&!l.completed){const _=(b=e==null?void 0:e.ui_settings)==null?void 0:b.sign_in_page_url;if(_){const C=new URL(_,window.location.origin);C.searchParams.set("signin_attempt_id",l.id),m&&C.searchParams.set("redirect_uri",m),a(C.toString())}return}if(l!=null&&l.completed){const C=gt(e,m)||((j=e==null?void 0:e.ui_settings)==null?void 0:j.after_signin_redirect_url)||(e==null?void 0:e.frontend_host)||"/";let y;try{y=new URL(C)}catch{y=new URL(C,window.location.origin)}if(y){(e==null?void 0:e.mode)==="staging"&&y.searchParams.set("__dev_session__",xt(e.backend_host)||"");const E=(v=e==null?void 0:e.auth_settings)==null?void 0:v.passkey;(E==null?void 0:E.enabled)&&(E==null?void 0:E.prompt_registration_on_auth)&&!((N=(k=r==null?void 0:r.active_signin)==null?void 0:k.user)!=null&&N.has_passkeys)?(f(y.toString()),p(!0)):a(y.toString())}}}},[r,i,c,m,e,l,a]),o.useEffect(()=>{s&&s.message.includes("No OAuth callback data found")&&setTimeout(()=>{var j;const b=((j=e==null?void 0:e.ui_settings)==null?void 0:j.sign_in_page_url)||(e==null?void 0:e.frontend_host);b&&a(b)},2e3)},[s,e,a]),d)return t.jsx($e,{children:t.jsx(tt,{children:t.jsx(Ic,{onComplete:x,onSkip:w})})});if(r&&i&&!s)return t.jsx(On,{title:"Success",sub:"Authentication completed successfully",icon:t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{weight:"bold"})})]}),message:"You'll be redirected to your destination shortly."});if(s){const b=s.message.includes("No OAuth callback data found");return t.jsx(On,{title:"Something went wrong",sub:"We couldn't complete your sign in",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(La,{weight:"bold"})})]}),message:s.message||"An unexpected error occurred during authentication.",action:b?void 0:t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:h,children:"Try again"}),footer:b?void 0:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:g,children:"Return to sign in"})]})})}return t.jsx(On,{title:"Completing sign in",sub:"Please wait while we authenticate you",icon:t.jsx(vt,{size:32}),message:"Verifying your credentials… this will only take a moment."})}function Z4({onSuccess:e,onError:a}={}){const[s,r]=o.useState("loading"),[i,l]=o.useState(""),{token:m,attempt:c,redirectUri:d}=Q1(),{verifyMagicLink:p}=Lo(),{navigate:u}=kt(),{deployment:f}=Ce(),h=o.useRef(!1);o.useEffect(()=>{(async()=>{if(!h.current){if(!m||!c){r("error"),l("The magic link appears to be malformed. Please try signing in again."),a==null||a("Invalid magic link parameters");return}h.current=!0,r("loading"),l("Please wait while we verify your magic link.");try{await p({token:m,attempt:c,redirectUri:d}),r("success"),l("You will be redirected to your account shortly."),e==null||e(),setTimeout(()=>{var b;let w=gt(f,d);if(w||(w=(b=f==null?void 0:f.ui_settings)==null?void 0:b.after_signin_redirect_url),!w&&(f!=null&&f.frontend_host)&&(w=`https://${f.frontend_host}`),w){const j=new URL(w);(f==null?void 0:f.mode)==="staging"&&j.searchParams.set("__dev_session__",xt(f.backend_host)||""),u(j.toString())}},2e3)}catch(w){r("error"),l("The magic link may have expired or already been used. Please try signing in again."),a==null||a(w.message)}}})()},[m,c]);const g=()=>{var x;(x=f==null?void 0:f.ui_settings)!=null&&x.sign_in_page_url&&u(f.ui_settings.sign_in_page_url)};return t.jsx($e,{children:t.jsxs(tt,{children:[t.jsx(rt,{title:"Magic link",sub:"Verifying your magic link"}),t.jsxs("div",{className:"w-auth-status",children:[s==="loading"&&t.jsx(vt,{size:32}),s==="success"&&t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{weight:"bold"})})]}),s==="error"&&t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(La,{weight:"bold"})})]}),t.jsx("p",{className:"w-auth-sub",children:i}),s==="error"&&t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:g,children:"Try again"})]})]})})}function H4(e){var r,i;return e?((r=e.signin_attempts)==null?void 0:r.find(l=>l.requires_completion&&!l.completed))?!0:!!((i=e.signup_attempts)==null?void 0:i.find(l=>{var m,c;return((m=l.missing_fields)==null?void 0:m.length)>0||((c=l.remaining_steps)==null?void 0:c.length)>0&&!l.completed})):!1}function F4(e){const a=e?`/profile-completion?redirect_uri=${encodeURIComponent(e)}`:"/profile-completion";window.location.href=a}function ns({kind:e}){const a=e==="success"?"w-success":e==="error"?"w-success w-success--error":"w-success w-success--info",s=e==="success"?Ye:e==="error"?La:Hu;return t.jsxs("div",{className:a,children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(s,{weight:"bold"})})]})}function _a({title:e,sub:a,icon:s,message:r,action:i,footer:l}){return t.jsx($e,{children:t.jsxs(tt,{footer:l,children:[t.jsx(rt,{title:e,sub:a}),t.jsxs("div",{className:"w-auth-status",children:[s,t.jsx("p",{className:"w-auth-sub",children:r}),i]})]})})}function T4({token:e,onSuccess:a,onError:s}){var b;const{acceptInvitation:r,invitationData:i,loading:l,error:m}=Vo(),{navigate:c}=kt(),{deployment:d}=Ce(),p=o.useRef(!1),u=()=>{var v;const j=new URLSearchParams(window.location.search);return{token:e||j.get("invite_token")||j.get("token"),redirectUri:gt(d,j.get("redirect_uri"))||((v=d==null?void 0:d.ui_settings)==null?void 0:v.after_signin_redirect_url)||"/"}};o.useEffect(()=>{if(p.current)return;const{token:j}=u();j&&(p.current=!0,r(j))},[r]),o.useEffect(()=>{var j;i&&(i.organization&&!i.requires_signin&&a&&a(i.organization.id,(j=i.workspace)==null?void 0:j.id),i.error_code&&s&&s(i.message||"Failed to accept invitation"))},[i,a,s]);const f=()=>{const{redirectUri:j}=u();c(j)},h=()=>{var E,A;const{token:j}=u(),v=((E=d==null?void 0:d.ui_settings)==null?void 0:E.sign_in_page_url)||"/sign-in",k=((A=d==null?void 0:d.ui_settings)==null?void 0:A.sign_up_page_url)||"/sign-up",N=new URLSearchParams;j&&N.set("invite_token",j),i!=null&&i.invited_email&&N.set("invited_email",i.invited_email);const C=`${window.location.pathname}?token=${j}`;N.set("redirect_uri",C),i!=null&&i.message&&N.set("message",i.message);const y=(i==null?void 0:i.error_code)==="INVITATION_REQUIRES_SIGNUP";c(`${y?k:v}?${N.toString()}`)},g=()=>{const{token:j}=u();j&&(p.current=!1,r(j))},x=(j,v)=>t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:v,children:j}),{token:w}=u();if(!w&&!l)return t.jsx(_a,{title:"Invalid invitation",sub:"No invitation token found",icon:t.jsx(ns,{kind:"error"}),message:"The invitation link appears to be invalid or incomplete.",action:x("Go to home",()=>c("/"))});if(l)return t.jsx(_a,{title:"Processing invitation",sub:"Please wait while we verify your invitation",icon:t.jsx(vt,{size:32}),message:"Verifying invitation… this will only take a moment."});if(i!=null&&i.organization&&!i.requires_signin)return t.jsx(_a,{title:"Invitation accepted",sub:"You've successfully joined the organization",icon:t.jsx(ns,{kind:"success"}),message:t.jsxs(t.Fragment,{children:["Welcome to"," ",t.jsx("strong",{children:i.organization.name}),i.workspace?`. You've been added to the ${i.workspace.name} workspace.`:"."]}),action:x("Continue to application",f)});if(i!=null&&i.already_member)return t.jsx(_a,{title:"Already a member",sub:"You're already part of this organization",icon:t.jsx(ns,{kind:"info"}),message:`You're already a member of ${((b=i.organization)==null?void 0:b.name)||"this organization"}. No action needed.`,action:x("Continue to application",f)});if(i!=null&&i.requires_signin){const j=i.error_code==="INVITATION_REQUIRES_SIGNUP";return t.jsx(_a,{title:j?"Sign up required":"Sign in required",sub:"To accept this invitation",icon:t.jsx(ns,{kind:"info"}),message:t.jsxs(t.Fragment,{children:["This invitation is for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email}),"."," ",j?"Create an account with this email address to accept it.":i.error_code==="INVITATION_EMAIL_MISMATCH"?"You're signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."]}),action:x(j?"Sign up to accept":"Sign in to accept",h)})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?t.jsx(_a,{title:"Invitation expired",sub:"This invitation is no longer valid",icon:t.jsxs("div",{className:"w-success w-success--error",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Lu,{weight:"bold"})})]}),message:t.jsxs(t.Fragment,{children:["Invitation for"," ",t.jsx("strong",{className:"w-text-primary",children:i.invited_email})," ","has expired. Invitations are valid for 10 days — please request a new one from your organization administrator."]})}):m||i!=null&&i.error_code?t.jsx(_a,{title:"Invitation error",sub:"Unable to process invitation",icon:t.jsx(ns,{kind:"error"}),message:(i==null?void 0:i.message)||m||"Failed to accept invitation",action:x("Try again",g),footer:t.jsxs("span",{className:"w-auth-foot",children:["Having trouble?"," ",t.jsx("button",{type:"button",className:"w-link",onClick:h,children:"Sign in manually"})]})}):null}const Vc=o.createContext(void 0),zc=()=>{const e=o.useContext(Vc);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},I4=({isOpen:e,onClose:a,children:s})=>{const[r,i]=o.useState(!1),l=ts();return o.useEffect(()=>{i(!0);const m=c=>{c.key==="Escape"&&e&&(a==null||a())};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[e,a]),!e||!r?null:en.createPortal(t.jsx("div",{className:"wacht-root",style:l,children:t.jsx(Vc.Provider,{value:{isOpen:e,onClose:a},children:s})}),document.body)},V4=({children:e})=>{const{onClose:a}=zc(),s=o.useRef(null),r=i=>{s.current&&!s.current.contains(i.target)&&(a==null||a())};return t.jsx("div",{className:"w-modal",onClick:r,children:t.jsx("div",{ref:s,style:{maxWidth:"100%",minWidth:0},children:e})})},z4=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog${s?` ${s}`:""}`,style:{maxHeight:"90vh",overflowY:"auto",...a},children:e}),D4=({children:e,showCloseButton:a=!0})=>{const{onClose:s}=zc();return t.jsxs("div",{className:"w-dialog-head",children:[typeof e=="string"?t.jsx("h2",{className:"w-dialog-title",children:e}):e,a&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:s,children:t.jsx(La,{size:18})})]})},U4=({children:e,style:a,className:s})=>t.jsx("div",{className:`w-dialog-body${s?` ${s}`:""}`,style:a,children:e}),W4=({children:e})=>t.jsx("div",{className:"w-dialog-foot",children:e}),Ue=Object.assign(I4,{Overlay:V4,Content:z4,Header:D4,Body:U4,Footer:W4}),B4=({isOpen:e,onClose:a,title:s,children:r,showCloseButton:i=!0})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{children:[s&&t.jsx(Ue.Header,{showCloseButton:i,children:s}),t.jsx(Ue.Body,{children:r})]})})}),G4=({trigger:e,renderDialog:a})=>{const[s,r]=o.useState(!1),i=()=>r(!0),l=()=>r(!1);return t.jsxs(t.Fragment,{children:[e({onClick:i}),a({isOpen:s,onClose:l})]})},Dc=o.createContext(void 0),Uc=()=>{const e=o.useContext(Dc);if(!e)throw new Error("useDropdownContext must be used within a DropdownProvider");return e},_s=({children:e,open:a,openChange:s,style:r})=>{const i=o.useRef(null),[l,m]=o.useState(!1);return o.useEffect(()=>{const c=d=>{i.current&&!i.current.contains(d.target)&&m(!1)};return l&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[l,s]),o.useEffect(()=>{s==null||s(l)},[l]),o.useEffect(()=>{m(!!a)},[a]),t.jsx(Dc.Provider,{value:{open:l,openChange:c=>m(c)},children:t.jsx("div",{style:{width:"fit-content",...r},ref:i,children:e})})},ks=({children:e,style:a,className:s})=>{const{open:r}=Uc(),[i,l]=o.useState({top:0,left:0}),[m,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{r&&d.current?(c(!1),requestAnimationFrame(()=>{var f,h;const p=(f=d.current)==null?void 0:f.parentElement;if(!p)return;const u=p.querySelector("[data-dropdown-trigger]")||p.firstElementChild;if(u&&u!==d.current){const g=u.getBoundingClientRect(),x=(h=d.current)==null?void 0:h.getBoundingClientRect(),w=window.innerWidth,b=window.innerHeight;let j=g.bottom+4,v=g.right-((x==null?void 0:x.width)||200);v<8&&(v=g.left),v+((x==null?void 0:x.width)||200)>w-8&&(v=w-((x==null?void 0:x.width)||200)-8),x&&j+x.height>b-8&&(j=g.top-(x.height+4)),l({top:j,left:v}),c(!0)}})):c(!1)},[r]),r?t.jsx("div",{className:s?`w-menu ${s}`:"w-menu",ref:d,style:{position:"fixed",zIndex:1e3,width:"max-content",minWidth:140,maxWidth:240,...a,top:`${i.top}px`,left:`${i.left}px`,visibility:m?"visible":"hidden",opacity:m?1:0,transition:m?"opacity 0.15s ease-in-out":"none"},children:e}):null},Cs=({children:e})=>{const{openChange:a,open:s}=Uc(),r=o.useCallback(()=>{a(!s)},[s,a]);return t.jsx("div",{style:{position:"relative",display:"inline-flex"},onClick:r,"data-dropdown-trigger":!0,children:e})},ea=o.forwardRef(({$destructive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:`w-menu-item${e?" w-menu-item--danger":""}${a?` ${a}`:""}`,...s}));ea.displayName="DropdownItem";const Wc=()=>t.jsx("div",{style:{height:"0.5px",background:"var(--wa-border)",width:"100%",margin:"4px 0"}}),Bc=o.forwardRef(({className:e,style:a,...s},r)=>t.jsx("form",{ref:r,className:e,style:{display:"flex",flexDirection:"column",gap:16,...a},...s}));Bc.displayName="Form";const Ge=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:`w-field${e?` ${e}`:""}`,...a}));Ge.displayName="FormGroup";const Ve=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:`w-label${e?` ${e}`:""}`,...a}));Ve.displayName="Label";const ye=o.forwardRef(({as:e="input",className:a,...s},r)=>{const i=`w-input${a?` ${a}`:""}`;return e==="textarea"?t.jsx("textarea",{className:i,...s}):t.jsx("input",{ref:r,className:i,...s})});ye.displayName="Input";const _e=({size:e,className:a})=>t.jsx("div",{className:a,style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:e?`${e}px`:"100%"},children:t.jsx("span",{className:"w-spin",style:{width:e??40,height:e??40}})}),Za=({checked:e,onChange:a})=>t.jsxs("label",{className:"w-switch","data-on":e?"":void 0,children:[t.jsx("input",{type:"checkbox",checked:e,onChange:s=>a(s.target.checked),style:{position:"absolute",opacity:0,width:0,height:0}}),t.jsx("span",{className:"w-switch-track",children:t.jsx("span",{className:"w-switch-knob"})})]}),Kt=(e=!1)=>{const[a,s]=o.useState(e),r=o.useCallback(()=>{s(!0)},[]),i=o.useCallback(()=>{s(!1)},[]),l=o.useCallback(()=>{s(m=>!m)},[]);return{isOpen:a,open:r,close:i,toggle:l}},Gc=({onChange:e,placeholder:a,value:s})=>t.jsxs("div",{className:"w-search",children:[t.jsx(Ml,{}),t.jsx("input",{type:"text",placeholder:a,value:s,onChange:r=>e(r.target.value)})]}),se=o.forwardRef(({$primary:e,$outline:a,$destructive:s,$fullWidth:r,$size:i,className:l,style:m,...c},d)=>{const f=`w-btn ${s?"w-btn--danger-solid":a?"w-btn--secondary":"w-btn--primary"}${i==="sm"?" w-btn--sm":i==="lg"?" w-btn--lg":""}${l?` ${l}`:""}`;return t.jsx("button",{ref:d,className:f,style:r?{width:"100%",...m}:m,...c})});se.displayName="Button";const qc=e=>({position:"absolute",top:"calc(100% + 6px)",left:0,width:"100%",maxHeight:260,overflowY:"auto",zIndex:1e3,opacity:e?1:0,transform:e?"scale(1)":"scale(0.97)",transformOrigin:"top",pointerEvents:e?"auto":"none",transition:"opacity 0.15s ease, transform 0.15s ease"}),Kc={width:"100%",height:32,padding:"0 9px",border:"none",borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,fontFamily:"var(--wa-font-sans)",fontSize:13,outline:"none",background:"transparent",color:"var(--wa-text)",marginBottom:4},Qs=({children:e})=>t.jsx("div",{style:{padding:"10px 9px",color:"var(--wa-text-faint)",fontFamily:"var(--wa-font-sans)",fontSize:12.5,textAlign:"center"},children:e}),un=({options:e,value:a,onChange:s,placeholder:r="Select an option",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).find(y=>y.value===a),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(s(y),h(!1),x(""))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k?void 0:"",children:k?k.label:r}),f?t.jsx(al,{size:16}):t.jsx(Ut,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:qc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Kc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Qs,{children:"No options available"}):y.options.map(A=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":A.disabled?"":void 0,onClick:()=>_(A.value,A.disabled),role:"option","aria-selected":A.value===a,children:[A.label,A.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},A.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":y.value===a,children:[y.label,y.value===a&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a||""})]})},Yc=({options:e,value:a,onChange:s,placeholder:r="Select options",disabled:i=!1,searchable:l=!1,width:m,name:c,id:d,groupsEnabled:p=!1,className:u})=>{const[f,h]=o.useState(!1),[g,x]=o.useState(""),w=o.useRef(null),b=o.useRef(null),j=p&&"options"in e[0],k=(j?e.flatMap(y=>y.options):e).filter(y=>a.includes(y.value)),N=g?j?e.map(y=>({...y,options:y.options.filter(E=>E.label.toLowerCase().includes(g.toLowerCase()))})).filter(y=>y.options.length>0):e.filter(y=>y.label.toLowerCase().includes(g.toLowerCase())):e,_=(y,E=!1)=>{E||(a.includes(y)?s(a.filter(A=>A!==y)):s([...a,y]))},C=()=>{i||h(!f)};return o.useEffect(()=>{f&&l&&b.current&&setTimeout(()=>{var y;(y=b.current)==null||y.focus()},10)},[f,l]),o.useEffect(()=>{const y=E=>{w.current&&!w.current.contains(E.target)&&(h(!1),x(""))};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[]),t.jsxs("div",{ref:w,style:{position:"relative",width:m||"100%"},className:u,children:[t.jsxs("button",{type:"button",className:"w-combo","data-open":f?"":void 0,onClick:C,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[t.jsx("span",{className:"w-combo-val","data-ph":k.length>0?void 0:"",children:k.length>0?k.map(y=>y.label).join(", "):r}),f?t.jsx(al,{size:16}):t.jsx(Ut,{size:16})]}),t.jsxs("div",{className:"w-combo-menu",style:qc(f),role:"listbox",children:[l&&t.jsx("input",{ref:b,type:"text",style:Kc,placeholder:"Search...",value:g,onChange:y=>x(y.target.value),onClick:y=>y.stopPropagation()}),j?N.map((y,E)=>t.jsxs(o.Fragment,{children:[t.jsx("div",{className:"w-combo-grp",children:y.label}),y.options.length===0?t.jsx(Qs,{children:"No options available"}):y.options.map(A=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":A.disabled?"":void 0,onClick:()=>_(A.value,A.disabled),role:"option","aria-selected":a.includes(A.value),children:[A.label,a.includes(A.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},A.value))]},`group-${E}`)):t.jsx(t.Fragment,{children:N.length===0?t.jsx(Qs,{children:"No options available"}):N.map(y=>t.jsxs("button",{type:"button",className:"w-combo-opt","data-disabled":y.disabled?"":void 0,onClick:()=>_(y.value,y.disabled),role:"option","aria-selected":a.includes(y.value),children:[y.label,a.includes(y.value)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:16})})]},y.value))})]}),c&&t.jsx("input",{type:"hidden",name:c,value:a.join(",")})]})},Os=e=>e.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)||"?",Li=e=>e.trim().replace(/[<>"'&]/g,""),q4=e=>e.length>=2&&e.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(e),K4=e=>/.+@.+\..+/.test(e),Pi=(e,a)=>e.length?e.find(s=>s.name===a)||e[0]:null,Y4=({roles:e,value:a,onChange:s,fullWidth:r})=>{const[i,l]=o.useState(!1),m=o.useRef(null);return o.useEffect(()=>{if(!i)return;const c=d=>{m.current&&!m.current.contains(d.target)&&l(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]),t.jsxs("div",{ref:m,className:`w-relative${r?" w-full":" w-none"}`,children:[t.jsxs("button",{type:"button",className:`w-combo${r?" w-full":" w-rolepick-btn"}`,"data-open":i?"":void 0,onClick:()=>l(c=>!c),disabled:!e.length,children:[t.jsx("span",{className:"w-combo-val",children:(a==null?void 0:a.name)||"Role"}),t.jsx(Ut,{size:14})]}),i&&t.jsx("div",{className:"w-combo-menu w-combo-menu--pop",children:e.map(c=>t.jsxs("button",{type:"button",className:"w-combo-opt",onClick:()=>{s(c),l(!1)},children:[c.name,c.id===(a==null?void 0:a.id)&&t.jsx("span",{className:"w-combo-check",children:t.jsx(Ye,{size:13})})]},c.id))})]})},Qc=({mode:e,organizationId:a,onSuccess:s,onCancel:r,onCreateOrganization:i})=>{var ce;const l=e==="org",m=l?"organization":"workspace",c=l?"Organization":"Workspace",{createOrganization:d,getOrganizationRoles:p,inviteOrganizationMember:u}=zt(),{createWorkspace:f,getWorkspaceRoles:h,createWorkspaceInvitation:g}=va(),{organizationMemberships:x}=xa(),{refetch:w}=ot(),[b,j]=o.useState(0),[v,k]=o.useState(""),[N,_]=o.useState(""),[C,y]=o.useState(),[E,A]=o.useState(null),[H,M]=o.useState(!1),[T,P]=o.useState(null),[S,$]=o.useState(a),[Z,R]=o.useState(!1),L=o.useRef(null),O=o.useRef(null),[F,W]=o.useState(null),[U,V]=o.useState([]),[G,Y]=o.useState([]),[de,fe]=o.useState(""),[ne,ae]=o.useState(null),re=(ce=x==null?void 0:x.find(B=>B.organization.id===S))==null?void 0:ce.organization;o.useEffect(()=>()=>{E&&URL.revokeObjectURL(E)},[E]),o.useEffect(()=>{if(!Z)return;const B=q=>{L.current&&!L.current.contains(q.target)&&R(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[Z]);const Le=B=>{var X;const q=(X=B.target.files)==null?void 0:X[0];if(q){if(q.size>2*1024*1024){P("Image must be under 2 MB.");return}if(!q.type.startsWith("image/")){P("Please choose a valid image file.");return}E&&URL.revokeObjectURL(E),P(null),y(q),A(URL.createObjectURL(q))}},K=async()=>{var X;const B=Li(v),q=Li(N);if(!q4(B)){P(`Enter a valid ${m} name (2–100 characters).`);return}if(!l&&!S){P("Select an organization first.");return}M(!0),P(null);try{if(l){const oe=await d({name:B,description:q,image:C}),Ee=((X=oe==null?void 0:oe.data)==null?void 0:X.organization)??(oe==null?void 0:oe.organization)??oe;W(Ee);const z=await p(Ee).catch(()=>[]);V(z),ae(Pi(z,"Member"))}else{const oe=await f(S,B,C,q),Ee=(oe==null?void 0:oe.workspace)??oe,z={...Ee,organization:{id:S}};W(z);const D=await h(Ee).catch(()=>[]);V(D),ae(Pi(D,"Editor"))}await w(),j(1)}catch(oe){P((oe==null?void 0:oe.message)||`Failed to create ${m}.`)}finally{M(!1)}},at=()=>{const B=de.trim();!K4(B)||G.some(q=>q.email===B)||ne&&(Y(q=>[...q,{email:B,roleId:ne.id,roleName:ne.name}]),fe(""))},ze=B=>{(B.key==="Enter"||B.key===",")&&(B.preventDefault(),at())},We=async()=>{if(!G.length){j(2);return}M(!0),P(null);try{for(const B of G)l?await u(F,{email:B.email,organizationRole:{id:B.roleId}}):await g(F,B.email,B.roleId);j(2)}catch(B){P((B==null?void 0:B.message)||"Some invitations could not be sent.")}finally{M(!1)}},Re=()=>{j(0),k(""),_(""),y(void 0),E&&URL.revokeObjectURL(E),A(null),W(null),V([]),Y([]),fe(""),P(null)};return t.jsxs("div",{className:"w-card w-create-card",children:[t.jsxs("div",{className:"w-create-body",children:[t.jsxs("div",{className:"w-flex-col w-items-center w-gap-3 w-create-head",children:[b===0?t.jsxs("span",{className:"w-ibadge-wrap",children:[t.jsxs("button",{type:"button",className:"w-ibadge w-avatar-edit","data-busy":H?"":void 0,onClick:()=>{var B;return(B=O.current)==null?void 0:B.click()},title:`Upload ${m} logo`,"aria-label":`Upload ${m} logo`,children:[E?t.jsx("img",{src:E,alt:`${c} logo`}):l?t.jsx(ps,{}):t.jsx(pi,{}),t.jsx("span",{className:"w-avatar-veil",children:t.jsx(sn,{})})]}),t.jsx("input",{ref:O,type:"file",className:"w-none",hidden:!0,accept:"image/png, image/jpeg, image/gif, image/svg+xml",onChange:Le,disabled:H}),E&&t.jsx("button",{type:"button",className:"w-ibadge-x",title:"Remove logo","aria-label":"Remove logo",onClick:()=>{E&&URL.revokeObjectURL(E),A(null),y(void 0)},children:t.jsx(La,{})})]}):t.jsx("span",{className:`w-ibadge${b===2?" w-ibadge--done":""}`,children:b===2?t.jsx(Ye,{}):l?t.jsx(ps,{}):t.jsx(pi,{})}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-text-center",children:[t.jsx("h1",{className:"w-title-lg",children:b===0?`Create ${l?"an":"a"} ${m}`:b===1?"Invite your team":`${c} created`}),t.jsx("p",{className:"w-sub",children:b===0?`Set up a new ${m}${l?" to collaborate with your team.":" inside your organization."}`:b===1?"Add people now, or skip and do it later.":`${v} is ready to go.`})]})]}),b<2&&t.jsxs("div",{className:"w-steps w-create-steps",children:[t.jsx("i",{"data-on":""}),t.jsx("i",{"data-on":b>=1?"":void 0})]}),T&&t.jsx("div",{className:"w-banner w-banner--error w-mb-4",children:T}),b===0&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[!l&&t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Organization"}),t.jsxs("div",{className:"w-relative",ref:L,children:[t.jsxs("button",{type:"button",className:"w-combo w-full","data-open":Z?"":void 0,onClick:()=>R(B=>!B),disabled:H,children:[t.jsxs("span",{className:"w-combo-val w-inline w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:re!=null&&re.image_url?t.jsx("img",{src:re.image_url,alt:re.name}):Os((re==null?void 0:re.name)||"O").charAt(0)}),t.jsx("span",{children:(re==null?void 0:re.name)||"Select organization"})]}),t.jsx(Ut,{size:14})]}),Z&&t.jsxs("div",{className:"w-combo-menu w-combo-menu--pop",children:[x==null?void 0:x.map(B=>{var X;const q=!!((X=B.eligibility_restriction)!=null&&X.type)&&B.eligibility_restriction.type!=="none";return t.jsxs("button",{type:"button",className:"w-combo-opt",disabled:q,"data-disabled":q?"":void 0,onClick:()=>{q||($(B.organization.id),R(!1))},children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:B.organization.image_url?t.jsx("img",{src:B.organization.image_url,alt:B.organization.name}):Os(B.organization.name).charAt(0)}),t.jsx("span",{children:B.organization.name})]},B.organization.id)}),i&&t.jsxs("button",{type:"button",className:"w-combo-opt w-text-primary",onClick:()=>{R(!1),i()},children:[t.jsx(St,{size:13}),"Create new organization"]})]})]})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:[c," name"]}),t.jsx(ye,{autoFocus:!0,value:v,onChange:B=>k(B.target.value),placeholder:l?"Acme Inc":"Product",disabled:H})]}),t.jsxs("label",{className:"w-field",children:[t.jsxs("span",{className:"w-label",children:["Description"," ",t.jsx("span",{className:"w-secsub",children:"· optional"})]}),t.jsx(ye,{as:"textarea",className:"w-input--area",value:N,onChange:B=>_(B.target.value),placeholder:l?"What does your team do?":"What's this workspace for?",disabled:H})]}),t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:K,disabled:H||!v.trim(),children:H?t.jsx(_e,{size:15}):t.jsxs(t.Fragment,{children:["Continue",t.jsx(Qt,{size:15})]})}),r&&t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-btn--block",onClick:r,disabled:H,children:"Cancel"})]})]}),b===1&&t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Invite by email"}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(ye,{autoFocus:!0,className:"w-grow",value:de,onChange:B=>fe(B.target.value),onKeyDown:ze,placeholder:"teammate@acme.com"}),t.jsx(Y4,{roles:U,value:ne,onChange:ae})]}),t.jsx("span",{className:"w-secsub",children:"Press Enter to add each person."})]}),G.length>0&&t.jsx("div",{className:"w-list",children:G.map(B=>t.jsxs("div",{className:"w-row",style:{gridTemplateColumns:"1fr auto",padding:"10px 0"},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:Os(B.email)}),t.jsx("span",{className:"w-truncate w-text-secondary",children:B.email})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-pill",children:B.roleName}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",title:"Remove",onClick:()=>Y(q=>q.filter(X=>X.email!==B.email)),children:t.jsx(La,{size:13})})]})]},B.email))}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--secondary w-none",onClick:()=>j(2),disabled:H,children:"Skip"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-grow",onClick:We,disabled:H,children:H?t.jsx(_e,{size:15}):G.length?`Invite ${G.length} & finish`:"Finish"})]})]}),b===2&&t.jsxs("div",{className:"w-flex-col w-items-center w-gap-4",children:[t.jsxs("div",{className:"w-create-summary",children:[t.jsx("span",{className:"w-avatar w-avatar--md",children:E?t.jsx("img",{src:E,alt:v}):Os(v)}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:v}),t.jsx("span",{className:"w-secsub",children:G.length?`${G.length} invite${G.length>1?"s":""} sent`:"No invites yet"})]})]}),t.jsxs("button",{type:"button",className:"w-btn w-btn--primary w-btn--block",onClick:()=>s==null?void 0:s(F),children:["Go to ",m,t.jsx(Qt,{size:15})]}),t.jsxs("button",{type:"button",className:"w-link w-link--muted w-linkbtn w-inline w-gap-1",onClick:Re,children:[t.jsx(Wo,{size:12})," Create another"]})]})]}),b===0&&t.jsx("div",{className:"w-create-foot",children:t.jsx("span",{className:"w-secsub",children:l?"Organizations group your team, billing and settings.":"Workspaces live inside an organization."})})]})},mn=({onSuccess:e,onCancel:a})=>t.jsx($e,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Qc,{mode:"org",onSuccess:e,onCancel:a})})}),Jc=({isOpen:e,onClose:a,onCreated:s})=>{const r=()=>{s==null||s(),a==null||a()};return t.jsx($e,{children:t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsx(Ue.Content,{className:"w-dialog--create",children:t.jsx(mn,{onSuccess:r,onCancel:a})})})})})},Er=o.createContext({screen:null,setScreen:()=>{},toast:(e,a)=>{}}),Ct=()=>{const e=o.useContext(Er);if(!e)throw new Error("useScreenContext must be used within a ScreenContextProvider");return e},Qa=({title:e,description:a,onConfirm:s,onCancel:r,style:i})=>{const l=o.useRef(null);return o.useEffect(()=>{const m=c=>{l.current&&!l.current.contains(c.target)&&r()};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[r]),t.jsxs("div",{ref:l,className:"w-pop",style:{position:"fixed",zIndex:1e3,right:44,...i},children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("h3",{className:"w-pop-title",children:e}),a&&t.jsx("p",{className:"w-pop-sub",children:a})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:r,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:s,children:"Confirm"})]})]})},$i=[{id:"okta",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"saml",description:"SAML",docUrl:"https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_saml.htm",placeholders:{entityId:"http://www.okta.com/{yourOktaDomain}",ssoUrl:"https://{yourOktaDomain}.okta.com/app/{appId}/sso/saml"},attributeMapping:{first_name:"firstName",last_name:"lastName",email:"email"}},{id:"okta-oidc",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"oidc",description:"OIDC",docUrl:"https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/",placeholders:{issuerUrl:"https://{yourOktaDomain}.okta.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"azure",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso",placeholders:{entityId:"https://sts.windows.net/{tenantId}/",ssoUrl:"https://login.microsoftonline.com/{tenantId}/saml2"},attributeMapping:{first_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",last_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",email:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"}},{id:"azure-oidc",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"oidc",description:"OIDC",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc",placeholders:{issuerUrl:"https://login.microsoftonline.com/{tenantId}/v2.0",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"google",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"saml",description:"SAML",docUrl:"https://support.google.com/a/answer/6087519",placeholders:{entityId:"https://accounts.google.com/o/saml2?idpid={idpId}",ssoUrl:"https://accounts.google.com/o/saml2/idp?idpid={idpId}"},attributeMapping:{first_name:"FirstName",last_name:"LastName",email:"email"}},{id:"google-oidc",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"oidc",description:"OIDC",docUrl:"https://developers.google.com/identity/openid-connect/openid-connect",placeholders:{issuerUrl:"https://accounts.google.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"auth0",name:"Auth0",logo:"https://cdn.auth0.com/styleguide/latest/lib/logos/img/badge.png",protocol:"oidc",description:"OIDC",docUrl:"https://auth0.com/docs/authenticate/protocols/openid-connect-protocol",placeholders:{issuerUrl:"https://{yourDomain}.auth0.com/",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"onelogin",name:"OneLogin",logo:"",protocol:"saml",description:"SAML",docUrl:"https://onelogin.service-now.com/support?id=kb_article&sys_id=912bb23adbdc1cd0ca1c400e0b96197d",placeholders:{entityId:"https://app.onelogin.com/saml/metadata/{appId}",ssoUrl:"https://{subdomain}.onelogin.com/trust/saml2/http-post/sso/{appId}"}},{id:"ping",name:"PingOne",logo:"",protocol:"saml",description:"SAML",docUrl:"https://docs.pingidentity.com/pingone/latest/connector/configure-saml.html",placeholders:{entityId:"https://auth.pingone.com/{envId}",ssoUrl:"https://auth.pingone.com/{envId}/saml20/idp/sso"}},{id:"jumpcloud",name:"JumpCloud",logo:"",protocol:"saml",description:"SAML",docUrl:"https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-saml",placeholders:{entityId:"https://sso.jumpcloud.com/saml2/{appId}",ssoUrl:"https://sso.jumpcloud.com/saml2/{appId}"}},{id:"duo",name:"Duo",logo:"",protocol:"saml",description:"SAML",docUrl:"https://duo.com/docs/sso",placeholders:{entityId:"https://sso.duosecurity.com/saml2/sp/{appId}",ssoUrl:"https://sso.duosecurity.com/saml2/idp/{appId}/sso"}},{id:"keycloak",name:"Keycloak",logo:"https://www.keycloak.org/resources/images/icon.svg",protocol:"oidc",description:"OIDC",docUrl:"https://www.keycloak.org/docs/latest/securing_apps/",placeholders:{issuerUrl:"https://{host}/realms/{realm}",scopes:"openid profile email"}},{id:"adfs",name:"ADFS",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Microsoft_logo.svg/100px-Microsoft_logo.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-relying-party-trust",placeholders:{entityId:"http://{adfsServer}/adfs/services/trust",ssoUrl:"https://{adfsServer}/adfs/ls/"}},{id:"custom-saml",name:"Custom",logo:"",protocol:"saml",description:"SAML",docUrl:"",placeholders:{}},{id:"custom-oidc",name:"Custom",logo:"",protocol:"oidc",description:"OIDC",docUrl:"",placeholders:{}}],Q4=({template:e})=>{const[a,s]=o.useState(!1);return!e.logo||a?t.jsx("span",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo--ph",children:t.jsx(Xt,{size:18,className:"w-text-muted"})}):t.jsx("img",{className:"w-avatar w-avatar--square w-avatar--md w-sso-logo",src:e.logo,alt:e.name,onError:()=>s(!0)})},J4=({organization:e})=>{const{getEnterpriseConnections:a,createEnterpriseConnection:s,deleteEnterpriseConnection:r,testEnterpriseConnection:i,generateSCIMToken:l,getSCIMToken:m,revokeSCIMToken:c}=zt(),{toast:d}=Ct(),[p,u]=o.useState(!1),[f,h]=o.useState(null),{data:g=[],isLoading:x,mutate:w}=Se(e!=null&&e.id?`wacht-org-sso:${e.id}`:null,async()=>await(a==null?void 0:a(e))||[],{refreshInterval:3e4,revalidateOnFocus:!1}),b=async j=>{try{await(r==null?void 0:r(e,j)),w(),d("SSO connection deleted","info")}catch(v){d(v.message||"Failed to delete connection","error")}h(null)};return x?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):p?t.jsx(em,{organization:e,onClose:()=>u(!1),onCreate:async j=>{try{await(s==null?void 0:s(e,j)),w(),u(!1),d("SSO connection created","info")}catch(v){d(v.message||"Failed to create connection","error")}}}):t.jsx(t.Fragment,{children:g.length===0?t.jsxs("div",{className:"w-empty w-empty--fill",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(Xt,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"Enterprise SSO"}),t.jsx("p",{children:"Let members sign in with your identity provider."})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{onClick:()=>u(!0),children:[t.jsx(St,{size:16})," Configure SSO"]})})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-sechead",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-title",children:"Enterprise SSO"}),t.jsx("p",{className:"w-sub",children:"Configure SAML or OIDC SSO for your organization"})]})}),g.map(j=>t.jsx(X4,{connection:j,onDelete:v=>h(v),connectionToDelete:f,onConfirmDelete:b,onCancelDelete:()=>h(null),testConnection:v=>i(e,v),generateSCIMToken:v=>l(e,v),getSCIMToken:v=>m(e,v),revokeSCIMToken:v=>c(e,v),toast:d},j.id))]})})},X4=({connection:e,onDelete:a,connectionToDelete:s,onConfirmDelete:r,onCancelDelete:i,testConnection:l,generateSCIMToken:m,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var H,M,T,P,S;const[u,f]=o.useState(null),[h,g]=o.useState(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),[v,k]=o.useState(!1),[N,_]=o.useState(null);o.useEffect(()=>{c&&e.id&&c(e.id).then(f).catch(()=>{})},[e.id,c]);const C=async()=>{if(l){k(!0),_(null);try{const $=await l(e.id);_($)}catch($){_({success:!1,checks:{},errors:{general:$.message||"Test failed"}})}finally{k(!1)}}},y=async()=>{if(m){g(!0);try{const $=await m(e.id);w($.token),f({exists:!0,token:$}),p("SCIM token generated. Copy it now - it won't be shown again!","info")}catch($){p($.message||"Failed to generate token","error")}finally{g(!1)}}},E=async()=>{if(d){g(!0);try{await d(e.id),f({exists:!1,scim_base_url:u==null?void 0:u.scim_base_url}),w(null),p("SCIM token revoked","info")}catch($){p($.message||"Failed to revoke token","error")}finally{g(!1)}}},A=($,Z)=>{navigator.clipboard.writeText($),j(Z),setTimeout(()=>j(null),2e3)};return t.jsxs("div",{className:"w-flex-col w-gap-4 w-sso-conn",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-start",children:[t.jsxs("h3",{className:"w-sec w-inline w-gap-2",children:[t.jsx(Xt,{size:16}),e.protocol==="oidc"?"OIDC SSO":"SAML SSO",t.jsx("span",{className:"w-pill w-pill--current",children:e.protocol.toUpperCase()})]}),t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(se,{$size:"sm",onClick:C,disabled:v,children:v?t.jsx(_e,{size:14}):"Test"}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>a(e.id),className:"w-text-error",children:"Remove"}),s===e.id&&t.jsx(Qa,{title:"Delete this SSO connection?",onConfirm:()=>r(e.id),onCancel:i})]})]})]}),N&&t.jsx("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"}`,children:t.jsxs("span",{className:`w-banner-txt w-flex-col w-gap-1 ${N.success?"w-text-success":"w-text-error"}`,children:[t.jsx("span",{children:N.success?"✓ Connection is valid":"✗ Connection failed"}),N.errors&&Object.entries(N.errors).map(([$,Z])=>t.jsxs("div",{children:[$.replace(/_/g," "),": ",Z]},$))]})}),t.jsxs("div",{className:"w-sso-detail",children:[e.protocol==="saml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Entity ID"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_entity_id}),t.jsx("span",{className:"w-secsub",children:"SSO URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.idp_sso_url})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"w-secsub",children:"Issuer URL"}),t.jsx("span",{className:"w-sec w-break-all",children:e.oidc_issuer_url}),t.jsx("span",{className:"w-secsub",children:"Client ID"}),t.jsx("span",{className:"w-sec",children:e.oidc_client_id}),t.jsx("span",{className:"w-secsub",children:"Scopes"}),t.jsx("span",{className:"w-sec",children:e.oidc_scopes||"openid profile email"})]}),t.jsx("span",{className:"w-secsub",children:"Created"}),t.jsx("span",{className:"w-sec",children:new Date(e.created_at).toLocaleDateString()})]}),t.jsxs("div",{className:"w-flex-col w-gap-3 w-sso-scim",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center",children:[t.jsxs("div",{className:"w-sec w-inline w-gap-2",children:[t.jsx(Xt,{size:14}),"SCIM Provisioning"]}),t.jsx("div",{className:"w-flex w-wrap w-gap-2",children:!(u!=null&&u.exists)||!((H=u==null?void 0:u.token)!=null&&H.enabled)?t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(se,{$size:"sm",onClick:y,disabled:h,children:h?t.jsx(_e,{size:14}):"Rotate"}),t.jsx(se,{$size:"sm",$outline:!0,onClick:E,disabled:h,className:"w-text-error",children:"Revoke"})]})})]}),(((M=u==null?void 0:u.token)==null?void 0:M.scim_base_url)||x)&&t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Base URL:"}),t.jsx("code",{children:((T=u==null?void 0:u.token)==null?void 0:T.scim_base_url)||"Loading..."}),((P=u==null?void 0:u.token)==null?void 0:P.scim_base_url)&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>A(u.token.scim_base_url,"scim-url"),children:b==="scim-url"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]}),x&&t.jsxs("div",{className:"w-flex-col w-gap-2",children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Token:"}),t.jsx("code",{children:x}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:()=>A(x,"scim-token"),children:b==="scim-token"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]}),t.jsx("div",{className:"w-mono-faint w-text-warning",children:"⚠️ Copy this token now. It won't be shown again."})]}),(u==null?void 0:u.exists)&&((S=u==null?void 0:u.token)==null?void 0:S.enabled)&&!x&&t.jsxs("div",{className:"w-secsub",children:["Token:"," ",t.jsxs("code",{className:"w-mono-sm w-token-chip",children:[u.token.token_prefix,"..."]}),u.token.last_used_at&&t.jsxs("span",{children:[" ","· Last used:"," ",new Date(u.token.last_used_at).toLocaleDateString()]})]})]})]})},em=({onCreate:e,organization:a})=>{const{getOrganizationDomains:s,testEnterpriseConnectionConfig:r}=zt(),{deployment:i}=Ce(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(null),[u,f]=o.useState("saml"),[h,g]=o.useState(null),[x,w]=o.useState(!1),[b,j]=o.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[v,k]=o.useState(!1),[N,_]=o.useState(null),{data:C=[],isLoading:y}=Se("wacht-org-verified-domains-for-sso-screen",async()=>(await(s==null?void 0:s(a))||[]).filter(R=>R.verified),{revalidateOnFocus:!1}),E=Z=>{p(Z),f(Z.protocol),Z.protocol==="saml"?j(R=>{var L,O,F;return{...R,idp_entity_id:Z.placeholders.entityId||"",idp_sso_url:Z.placeholders.ssoUrl||"",attr_first_name:((L=Z.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((O=Z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((F=Z.attributeMapping)==null?void 0:F.email)||""}}):j(R=>{var L,O,F;return{...R,oidc_issuer_url:Z.placeholders.issuerUrl||"",oidc_scopes:Z.placeholders.scopes||"openid profile email",attr_first_name:((L=Z.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((O=Z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((F=Z.attributeMapping)==null?void 0:F.email)||""}})},A=i!=null&&i.backend_host?`${i.backend_host.startsWith("https://")?"":"https://"}${i.backend_host}/auth/sso/oidc/callback`:"",H=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/metadata`:"",M=i!=null&&i.backend_host?`https://${i.backend_host}/auth/sso/callback`:"",T=(Z,R)=>{navigator.clipboard.writeText(Z),g(R),setTimeout(()=>g(null),2e3)},P=async Z=>{Z.preventDefault();const R=L=>L.includes("{")||L.includes("}");if(u==="saml"){if(!b.idp_entity_id||R(b.idp_entity_id)){l("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||R(b.idp_sso_url)){l("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){l("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||R(b.oidc_issuer_url)){l("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||R(b.oidc_client_id)){l("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){l("Please enter the Client Secret","error");return}}c(!0);try{const L={};b.attr_first_name&&(L.first_name=b.attr_first_name),b.attr_last_name&&(L.last_name=b.attr_last_name),b.attr_email&&(L.email=b.attr_email);const O=Object.keys(L).length>0;u==="saml"?await e({protocol:"saml",domain_id:b.domain_id||void 0,idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate,jit_enabled:b.jit_enabled,...O&&{attribute_mapping:L}}):await e({protocol:"oidc",domain_id:b.domain_id||void 0,oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret,oidc_scopes:b.oidc_scopes,jit_enabled:b.jit_enabled,...O&&{attribute_mapping:L}})}finally{c(!1)}},S=async()=>{k(!0),_(null);const Z=O=>O.includes("{")||O.includes("}"),R={},L={};if(u==="saml"?(b.idp_entity_id?Z(b.idp_entity_id)?(L.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):L.entity_id_valid=!0:(L.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?Z(b.idp_sso_url)?(L.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):L.sso_url_valid=!0:(L.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?L.certificate_provided=!0:(L.certificate_provided=!1,R.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?Z(b.oidc_issuer_url)?(L.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):L.issuer_url_valid=!0:(L.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?Z(b.oidc_client_id)?(L.client_id_valid=!1,R.client_id_valid="Client ID contains placeholder values - please replace with actual values"):L.client_id_valid=!0:(L.client_id_valid=!1,R.client_id_valid="Client ID is required")),Object.keys(R).length>0){_({success:!1,checks:L,errors:R}),k(!1);return}try{const O=u==="saml"?{protocol:"saml",idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate}:{protocol:"oidc",oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret},F=await(r==null?void 0:r(a,O));F&&_(F)}catch(O){_({success:!1,checks:{},errors:{general:"Test failed: "+O.message}})}finally{k(!1)}},$=Z=>t.jsx(Q4,{template:Z});return t.jsxs("form",{onSubmit:P,autoComplete:"off",className:"w-flex-col w-gap-4",children:[d?t.jsxs("div",{className:"w-flex w-items-center w-gap-4 w-sso-template",children:[$(d),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:d.name}),t.jsx("div",{className:"w-eyebrow",children:d.protocol})]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:()=>p(null),children:"Change"})]}):t.jsxs("div",{className:"w-flex-col w-gap-5",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"SAML Providers"}),t.jsx("div",{className:"w-grid-4",children:$i.filter(Z=>Z.protocol==="saml").map(Z=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(Z),children:[$(Z),t.jsx("span",{className:"w-secsub",children:Z.name})]},Z.id))})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:"OIDC Providers"}),t.jsx("div",{className:"w-grid-4",children:$i.filter(Z=>Z.protocol==="oidc").map(Z=>t.jsxs("button",{type:"button",className:"w-sso-tile",onClick:()=>E(Z),children:[$(Z),t.jsx("span",{className:"w-secsub",children:Z.name})]},Z.id))})]})]}),d&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-sec",children:"Service Provider Details"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"ACS URL:"}),t.jsx("code",{children:M}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(M,"acs"),children:h==="acs"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]}),t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Metadata:"}),t.jsx("code",{children:H}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(H,"metadata"),children:h==="metadata"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]})]}):t.jsxs("div",{className:"w-token",children:[t.jsx("span",{className:"w-secsub w-none",children:"Callback:"}),t.jsx("code",{children:A}),t.jsx("button",{type:"button",className:"w-btn w-btn--icon",onClick:()=>T(A,"callback"),children:h==="callback"?t.jsx(Ye,{size:12}):t.jsx(Ga,{size:12})})]})})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs("div",{className:"w-flex w-justify-between w-items-center w-gap-3",children:[t.jsx("div",{className:"w-eyebrow",children:d?`${d.name} Configuration`:"Configuration"}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[d&&d.docUrl&&t.jsxs("a",{href:d.docUrl,target:"_blank",rel:"noopener noreferrer",className:"w-link w-link--sm w-text-primary w-inline w-gap-1",children:[t.jsx(Nu,{size:12})," Docs"]}),t.jsx(se,{type:"button",$size:"sm",$outline:!0,onClick:S,disabled:v||!d,children:v?t.jsx(_e,{size:16}):"Test Connection"}),t.jsx(se,{$size:"sm",type:"submit",disabled:m||C.length===0||!d,children:m?t.jsx(_e,{size:16}):"Create Connection"})]})]}),N&&(()=>{const Z={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return t.jsxs("div",{className:`w-banner ${N.success?"w-banner--success":"w-banner--error"} w-flex-col w-gap-3`,children:[t.jsx("div",{className:`w-sec ${N.success?"w-text-success":"w-text-error"}`,children:N.success?"✓ All checks passed":"✗ Some checks failed"}),t.jsx("div",{className:"w-flex-col w-gap-2 w-full",children:Object.entries(N.checks).map(([R,L])=>{var O;return t.jsxs("div",{className:"w-flex w-items-start w-gap-2 w-sso-check",children:[t.jsx("span",{className:`w-sso-check-mark ${L?"w-text-success":"w-text-error"}`,children:L?"✓":"✗"}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:Z[R]||R.replace(/_/g," ").replace(/\b\w/g,F=>F.toUpperCase())}),((O=N.errors)==null?void 0:O[R])&&t.jsx("div",{className:"w-secsub w-text-error",children:N.errors[R]})]})]},R)})})]})})(),t.jsxs("div",{className:"w-grid-2",children:[!d&&t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Protocol *"}),t.jsxs("select",{className:"w-input",value:u,onChange:Z=>f(Z.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(Ge,{className:"w-col-full",children:[t.jsx(Ve,{children:"Domain *"}),y?t.jsx("div",{className:"w-secsub",children:"Loading domains..."}):C.length===0?t.jsx("div",{className:"w-banner w-banner--warn",children:t.jsx("span",{className:"w-banner-txt",children:"No verified domains found. Please add and verify a domain first."})}):t.jsxs("select",{className:"w-input",value:b.domain_id,onChange:Z=>j({...b,domain_id:Z.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),C.map(Z=>t.jsx("option",{value:Z.id,children:Z.fqdn},Z.id))]})]}),u==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(Ge,{children:[t.jsx(Ve,{children:"IdP Entity ID *"}),t.jsx(ye,{type:"text",value:b.idp_entity_id,onChange:Z=>j({...b,idp_entity_id:Z.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"IdP SSO URL *"}),t.jsx(ye,{type:"url",value:b.idp_sso_url,onChange:Z=>j({...b,idp_sso_url:Z.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(Ge,{className:"w-col-full",children:[t.jsx(Ve,{children:"X.509 Certificate *"}),t.jsx(ye,{as:"textarea",value:b.idp_certificate,onChange:Z=>j({...b,idp_certificate:Z.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0,className:"w-input--area w-input--mono"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Issuer URL *"}),t.jsx(ye,{type:"url",value:b.oidc_issuer_url,onChange:Z=>j({...b,oidc_issuer_url:Z.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Client ID *"}),t.jsx(ye,{type:"text",value:b.oidc_client_id,onChange:Z=>j({...b,oidc_client_id:Z.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Client Secret *"}),t.jsx(ye,{type:"password",value:b.oidc_client_secret,onChange:Z=>j({...b,oidc_client_secret:Z.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Scopes"}),t.jsx(ye,{type:"text",value:b.oidc_scopes,onChange:Z=>j({...b,oidc_scopes:Z.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(Ge,{className:"w-col-full",children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:"Enable JIT Provisioning"}),t.jsx("div",{className:"w-secsub",children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),t.jsx(Za,{checked:b.jit_enabled,onChange:()=>j({...b,jit_enabled:!b.jit_enabled})})]})}),t.jsxs("div",{className:"w-col-full w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-inline w-gap-2 w-text-primary w-disclosure",onClick:()=>w(!x),children:[t.jsx("span",{className:"w-disclosure-caret",children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&t.jsxs("div",{className:"w-tile w-flex-col w-gap-3",children:[t.jsx("div",{className:"w-secsub",children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),t.jsxs("div",{className:"w-grid-3",children:[t.jsxs(Ge,{children:[t.jsx(Ve,{children:"First Name Attribute"}),t.jsx(ye,{type:"text",value:b.attr_first_name,onChange:Z=>j({...b,attr_first_name:Z.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Last Name Attribute"}),t.jsx(ye,{type:"text",value:b.attr_last_name,onChange:Z=>j({...b,attr_last_name:Z.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Email Attribute"}),t.jsx(ye,{type:"text",value:b.attr_email,onChange:Z=>j({...b,attr_email:Z.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ht=(...e)=>e.filter(Boolean).join(" "),Oi=({className:e,...a})=>t.jsx("div",{className:ht("w-contents",e),...a}),Zn=({className:e,...a})=>t.jsx("div",{className:ht("w-card","w-flex-col","w-full","w-minh-full",e),...a}),tm=({className:e,...a})=>t.jsx("div",{className:ht("w-tabsbar",e),...a}),am=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),za=({className:e,$isActive:a,...s})=>t.jsx("button",{className:ht("w-tab",a&&"w-tab--active",e),...s}),Da=({className:e,...a})=>t.jsx("span",{className:ht("w-inline","w-gap-2",e),...a}),sm=({className:e,children:a,...s})=>t.jsx("div",{className:ht("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Ar=({className:e,...a})=>t.jsx("div",{className:ht("w-sechead",e),...a}),Zi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Hi=({className:e,...a})=>t.jsx("div",{className:ht("w-grow",e),...a}),Fi=({className:e,...a})=>t.jsx("div",{className:ht("w-flex","w-items-center","w-gap-3","w-none",e),...a}),pn=({className:e,...a})=>t.jsx("div",{className:ht("w-full",e),...a}),nm=({className:e,...a})=>t.jsx("div",{className:ht("w-page-head",e),...a}),rm=({className:e,...a})=>t.jsx("div",{className:ht("w-grow","w-flex-col","w-gap-1",e),...a}),im=({className:e,...a})=>t.jsx("div",{className:ht("w-sec","w-truncate",e),...a}),om=({className:e,...a})=>t.jsx("div",{className:ht("w-secsub","w-truncate",e),...a}),lm={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},fa=({className:e,$variant:a="neutral",children:s,...r})=>t.jsxs("span",{className:ht("w-pill",lm[a],e),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),Ti=({className:e,$first:a,...s})=>t.jsx("div",{className:ht("w-sec",e),...s}),cm=({organization:e})=>{var M,T,P,S,$,Z;const{switchOrganization:a,refetch:s}=ot(),{workspaces:r}=va(),{deployment:i}=Ce(),{deleteOrganization:l,updateOrganization:m}=zt(),{toast:c}=Ct(),[d,p]=o.useState((e==null?void 0:e.name)||""),[u,f]=o.useState((e==null?void 0:e.description)||""),[h,g]=o.useState(!1),[x,w]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,j]=o.useState(""),[v,k]=o.useState(!1),[N,_]=o.useState(!1),C=o.useRef({name:d,description:u,security:x,isSaving:h});o.useEffect(()=>{C.current={name:d,description:u,security:x,isSaving:h}},[d,u,x,h]);const y=o.useCallback(async()=>{if(!e)return;const R=C.current;try{g(!0),await m(e,{name:R.name,description:R.description,whitelisted_ips:R.security.allowed_ips.split(`
103
103
  `).filter(L=>L.trim()),enable_ip_restriction:R.security.ip_restrictions,enforce_mfa:R.security.mfa_required,auto_assigned_workspace_id:R.security.default_workspace_id||"0"}),c("Changes saved","info")}catch(L){c(L.message||"Failed to save changes","error")}finally{g(!1)}},[e,m,c]),E=o.useCallback(()=>{C.current.isSaving||y()},[y]);o.useEffect(()=>{var R;e&&(p(e.name||""),f(e.description||""),w({allowed_ips:((R=e.whitelisted_ips)==null?void 0:R.join(`
104
104
  `))||"",ip_restrictions:e.enable_ip_restriction||!1,mfa_required:e.enforce_mfa||!1,default_workspace_id:e.auto_assigned_workspace_id||""}))},[e]);const A=o.useMemo(()=>r.filter(R=>R.organization.id===(e==null?void 0:e.id)),[r,e==null?void 0:e.id]),H=async()=>{if(!(!e||b!==e.name))try{k(!0),await a(""),await l(e),await s(),c("Organization deleted","info")}catch{c("Failed to delete organization","error")}finally{k(!1),j("")}};return e?t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"name",children:"Organization name"}),t.jsx(ye,{id:"name",value:d,onChange:R=>p(R.target.value),onBlur:E,placeholder:"Organization name",required:!0})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"description",children:"Description"}),t.jsx(ye,{id:"description",as:"textarea",value:u,onChange:R=>f(R.target.value),onBlur:E,placeholder:"Optional description",className:"w-input--area"})]}),((M=i==null?void 0:i.b2b_settings)==null?void 0:M.workspaces_enabled)&&A.length>0&&t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"default_workspace",children:"Default workspace"}),t.jsx(un,{options:A.map(R=>({value:R.id,label:R.name})),value:x.default_workspace_id,onChange:R=>{w(L=>({...L,default_workspace_id:R})),setTimeout(E,0)},placeholder:"Select default workspace"})]})]}),(((T=i==null?void 0:i.b2b_settings)==null?void 0:T.enforce_mfa_per_org_enabled)||((P=i==null?void 0:i.b2b_settings)==null?void 0:P.ip_allowlist_per_org_enabled))&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Ti,{children:"Security"}),((S=i==null?void 0:i.b2b_settings)==null?void 0:S.enforce_mfa_per_org_enabled)&&t.jsxs(Zi,{children:[t.jsxs(Hi,{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Multi-factor authentication"}),t.jsx("p",{className:"w-secsub",children:"Require all members to set up MFA for added security."})]}),t.jsx(Fi,{children:t.jsx(Za,{checked:x.mfa_required,onChange:()=>{const R=!x.mfa_required;w(L=>({...L,mfa_required:R})),setTimeout(E,0)}})})]}),(($=i==null?void 0:i.b2b_settings)==null?void 0:$.ip_allowlist_per_org_enabled)&&t.jsxs(t.Fragment,{children:[t.jsxs(Zi,{children:[t.jsxs(Hi,{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"IP restrictions"}),t.jsx("p",{className:"w-secsub",children:"Only allow access from specific IP addresses."})]}),t.jsx(Fi,{children:t.jsx(Za,{checked:x.ip_restrictions,onChange:()=>{const R=!x.ip_restrictions;w(L=>({...L,ip_restrictions:R})),setTimeout(E,0)}})})]}),x.ip_restrictions&&t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(ye,{id:"allowed_ips",as:"textarea",value:x.allowed_ips,onChange:R=>w(L=>({...L,allowed_ips:R.target.value})),onBlur:E,placeholder:`192.168.1.1
105
- 10.0.0.0/24`,className:"w-input--area w-input--mono"})]})]})]}),((Z=i==null?void 0:i.b2b_settings)==null?void 0:Z.allow_org_deletion)&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Ti,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start w-gap-3",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-full",children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete organization"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this organization, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{_(!N),j("")},children:N?"Cancel":"Delete organization"})]}),N&&t.jsxs("div",{className:"w-flex-col w-gap-3 w-full",children:[t.jsxs(Ge,{children:[t.jsxs(Ve,{htmlFor:"confirm_org_name",children:["Type"," ",t.jsx("strong",{children:e.name})," ","to confirm"]}),t.jsx(ye,{id:"confirm_org_name",type:"text",value:b,onChange:R=>j(R.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:H,disabled:b!==e.name||v,children:v?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})]}):t.jsx(_e,{})},Mr=(e,a)=>a?`${e} ${a}`:e,Ot=o.forwardRef(({className:e,...a},s)=>t.jsx("table",{ref:s,className:Mr("w-table",e),...a}));Ot.displayName="Table";const Zt=o.forwardRef((e,a)=>t.jsx("thead",{ref:a,...e}));Zt.displayName="TableHead";const Ht=o.forwardRef((e,a)=>t.jsx("tbody",{ref:a,...e}));Ht.displayName="TableBody";const it=o.forwardRef((e,a)=>t.jsx("tr",{ref:a,...e}));it.displayName="TableRow";const Fe=o.forwardRef((e,a)=>t.jsx("th",{ref:a,...e}));Fe.displayName="TableHeader";const Xe=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:e,...a}));Xe.displayName="TableCell";const cm=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Mr("w-td--flex",e),...a}));cm.displayName="TableCellFlex";const Ft=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Mr("w-td--actions",e),...a}));Ft.displayName="ActionsCell";const Nt=({title:e,description:a,icon:s,action:r})=>t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:s??t.jsx(Uu,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:e}),t.jsx("p",{children:a})]}),r&&t.jsx("div",{className:"w-empty-action",children:r})]}),bt=({triggerRef:e,isOpen:a,minWidth:s=300,defaultMaxHeight:r=400,offset:i=8,contentRef:l})=>{const[m,c]=o.useState();return o.useEffect(()=>{if(!a||!e.current){c(void 0);return}const d=()=>{var N;if(!e.current)return;const u=e.current.getBoundingClientRect(),f=window.innerWidth,h=window.innerHeight,g=((N=l==null?void 0:l.current)==null?void 0:N.offsetWidth)||s,x=h-u.bottom,w=u.top,b={};x>=w?(b.top=u.bottom+i,b.maxHeight=Math.min(r,x-i*2)):(b.bottom=h-u.top+i,b.maxHeight=Math.min(r,w-i*2));const j=f-u.left,v=u.right,k=j>=v?u.left:u.right-g;b.left=Math.max(i,Math.min(f-g-i,k)),c(b)},p=requestAnimationFrame(d);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{cancelAnimationFrame(p),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[a,s,r,i,l]),m},Ii=({onClose:e,domain:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,f]=o.useState(!1),{addDomain:h,verifyDomain:g}=ga(),{toast:x}=Ct(),w=bt({contentRef:r,triggerRef:s??{current:null},isOpen:u,minWidth:360,defaultMaxHeight:420}),b=_=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(_),j=_=>_.trim().toLowerCase().replace(/^https?:\/\//,""),v=async()=>{const _=j(m);if(!_){x("Please enter a domain name","error");return}if(!b(_)){x("Please enter a valid domain (e.g., example.com)","error");return}if(_.length>253){x("Domain name is too long","error");return}p(!0);try{const C=await h({fqdn:_});x("Domain added","info"),l(C.data)}catch(C){x(C.message||"Failed to add domain. Please try again.","error")}finally{p(!1)}},k=async()=>{if(!(!i||d)){p(!0);try{await g(i),e==null||e(),x("Domain verified","info")}catch(_){x(_.message||"Failed to verify domain. Check DNS records and try again.","error")}finally{p(!1)}}};if(o.useEffect(()=>{f(!0);const _=y=>{r.current&&!r.current.contains(y.target)&&(e==null||e())},C=y=>{y.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]),o.useEffect(()=>{a&&l(a)},[a]),!u)return null;const N={position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"};return i?t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"verify-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"verify-domain-title",children:"Verify domain"}),t.jsx("p",{className:"w-pop-sub",children:"Add this DNS record, then verify."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Type"}),t.jsx(ye,{value:i==null?void 0:i.verification_dns_record_type,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(ye,{value:i==null?void 0:i.verification_dns_record_name,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Value"}),t.jsx(ye,{value:i==null?void 0:i.verification_dns_record_data,disabled:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:d,children:d?t.jsx(_e,{size:12}):"Verify"})]})]}):t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"add-domain-title",children:"Add domain"}),t.jsx("p",{className:"w-pop-sub",children:"Verified members auto-join this org."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Domain"}),t.jsx(ye,{type:"text",placeholder:"example.com",value:m,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&m&&v()},autoFocus:!0,"aria-label":"Domain name"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!m||d,children:d?t.jsx(_e,{size:12}):"Continue"})]})]})},dm=({organization:e})=>{const{getOrganizationDomains:a,removeOrganizationDomain:s}=zt(),[r,i]=o.useState(null),[l,m]=o.useState(!1),[c,d]=o.useState(null),[p,u]=o.useState(new Set),f=o.useRef(null),h=o.useRef({}),{data:g=[],isLoading:x,mutate:w}=Se(e!=null&&e.id?`wacht-org-domains:${e.id}`:null,async()=>(await(a==null?void 0:a(e))||[]).map(k=>({...k,verified:k.verified!==void 0?k.verified:!1}))),b=(v,k)=>{u(N=>{const _=new Set(N);return k?_.add(v):_.delete(v),_})},j=async v=>{b(v.id,!0);try{await s(e,v),w()}finally{b(v.id,!1),i(null)}};return x?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Ar,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Domains"}),t.jsx("div",{className:"w-secsub",children:"Users with verified domain emails auto-join this organization."})]}),t.jsx(se,{ref:f,onClick:()=>m(!0),$size:"sm",children:"Add domain"}),l&&t.jsx(Ii,{onClose:()=>{m(!1),w()},triggerRef:f})]}),g!=null&&g.length?t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Domain"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{children:"Added"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:g.map(v=>{const k=p.has(v.id);return t.jsxs(it,{children:[t.jsx(Xe,{children:v.fqdn}),t.jsx(Xe,{children:v.verified?t.jsx(fa,{$variant:"success",children:"Verified"}):t.jsx(fa,{$variant:"warning",children:"Pending"})}),t.jsx(Xe,{children:new Date(v.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:N=>{N&&(h.current[v.id]=N)},$size:"sm",$outline:!0,disabled:k,onClick:()=>d(v.id),children:v.verified?"View DNS":"Verify"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:k,onClick:()=>i(v.id),children:k?t.jsx(_e,{size:12}):"Remove"})]})})]},v.id)})})]})}):t.jsx(Nt,{title:"No domains added",description:"Users with verified domain emails automatically join this organization."}),r&&t.jsx(Qa,{title:"Remove domain?",description:"Active users aren't affected, but new users with this domain won't auto-join.",onConfirm:()=>{const v=g.find(k=>k.id===r);v&&j(v)},onCancel:()=>i(null)}),c&&t.jsx(Ii,{domain:g.find(v=>v.id===c),onClose:()=>d(null),triggerRef:{current:h.current[c]}})]})},Xc=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{inviteMember:g}=ga(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:360}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}u(!0);try{await g({email:k,organizationRole:c}),a==null||a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{u(!1)}}};return o.useEffect(()=>{h(!0);const k=_=>{i.current&&!i.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email"}),t.jsx(ye,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&l&&c&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Role"}),t.jsx(un,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},um=({organization:e})=>{const{getOrganizationMembers:a,getOrganizationRoles:s,addRoleToOrganizationMember:r,removeRoleFromOrganizationMember:i,removeOrganizationMember:l}=zt(),{session:m}=ot(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(!1),[w,b]=o.useState(new Set),j=o.useRef(null),[v,k]=o.useState(d);o.useEffect(()=>{const S=setTimeout(()=>{k(d),f(1)},500);return()=>clearTimeout(S)},[d]);const{data:N,mutate:_}=Se(e?`wacht-api-organizations:${e.id}:members:${u}:${h}:${v}`:null,()=>a==null?void 0:a(e,{page:u,limit:h,search:v}),{keepPreviousData:!0}),C=(N==null?void 0:N.data)||[],y=(N==null?void 0:N.meta)||{total:0,limit:10},E=Math.ceil(y.total/(y.limit||10)),{data:A=[]}=Se(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),H=A,M=(S,$)=>{b(Z=>{const R=new Set(Z);return $?R.add(S):R.delete(S),R})},T=async(S,$,Z)=>{M(S.id,!0);try{Z?(await i(e,S,$),c("Role removed","info")):(await r(e,S,$),c("Role added","info")),_()}catch(R){c(R.message||"Failed to update role","error")}finally{M(S.id,!1)}},P=async S=>{M(S.id,!0);try{await l(e,S),_(),c("Member removed","info")}catch($){c($.message||"Failed to remove member","error")}finally{M(S.id,!1)}};return N?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Gc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[y.total>0&&t.jsxs("div",{className:"w-secsub",children:[y.total," member",y.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>x(!0),$size:"sm",children:"Invite"})]})]}),g&&t.jsx(Xc,{onClose:()=>x(!1),onSuccess:()=>{_(),x(!1)},roles:H,triggerRef:j}),C.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Invite someone or connect a corporate domain to auto-join."}):t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Member"}),t.jsx(Fe,{children:"Joined"}),t.jsx(Fe,{children:"Roles"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:C.map(S=>{var R,L;const $=((R=S.user)==null?void 0:R.id)===((L=m==null?void 0:m.active_signin)==null?void 0:L.user_id),Z=w.has(S.id);return t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsx(mm,{member:S,isCurrentUser:$})}),t.jsx(Xe,{children:new Date(S.created_at).toLocaleDateString()}),t.jsx(Xe,{children:t.jsx(pm,{member:S,roles:H,onToggle:T,disabled:Z})}),t.jsx(Ft,{children:t.jsx("div",{className:"w-actions",children:t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:Z||$,onClick:()=>P(S),title:$?"You cannot remove yourself":"Remove member",children:Z?t.jsx(_e,{size:12}):"Remove"})})})]},S.id)})})]})}),E>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4 w-mt-6",children:[t.jsx(se,{onClick:()=>f(S=>Math.max(1,S-1)),disabled:u===1,$size:"sm",$outline:!0,children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",E]}),t.jsx(se,{onClick:()=>f(S=>Math.min(E,S+1)),disabled:u===E,$size:"sm",$outline:!0,children:"Next"})]})]}):t.jsx(_e,{})},mm=({member:e,isCurrentUser:a})=>{var l,m;const s=e.user,r=(c="",d="")=>`${c[0]||""}${d[0]||""}`.toUpperCase()||"?",i=s?`${s.first_name||""} ${s.last_name||""}`.trim()||((l=s.primary_email_address)==null?void 0:l.email):"Unknown";return t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx("div",{className:"w-avatar w-avatar--md",children:s!=null&&s.profile_picture_url?t.jsx("img",{src:s.profile_picture_url,alt:i}):r(s==null?void 0:s.first_name,s==null?void 0:s.last_name)}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:i}),a&&t.jsx(fa,{$variant:"neutral",children:"You"})]}),t.jsx("span",{className:"w-secsub",children:(m=s==null?void 0:s.primary_email_address)==null?void 0:m.email})]})]})},pm=({member:e,roles:a,onToggle:s,disabled:r})=>{var c;const i=e.roles||[],l=d=>i.some(p=>p.id===d),m=i.length===0?"No role":i.length===1?(c=i[0])==null?void 0:c.name:`${i.length} roles`;return t.jsxs(_s,{children:[t.jsx(Cs,{children:t.jsxs(se,{$size:"sm",$outline:!0,disabled:r,className:"w-justify-between w-rolepick-btn",children:[m,t.jsx(Ut,{size:12})]})}),t.jsx(ks,{children:a.length===0?t.jsx("div",{className:"w-secsub w-menu-head",children:"No roles configured"}):a.map(d=>{const p=l(d.id);return t.jsx(ea,{onClick:()=>s(e,d,p),children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-3 w-full",children:[t.jsx("span",{children:d.name}),p&&t.jsx(Ye,{size:13,className:"w-text-primary"})]})},d.id)})})]})},hm=e=>{const a=e.expires_at;return a?new Date(a).getTime()<Date.now():!1},fm=({organization:e})=>{const{getOrganizationInvitations:a,getOrganizationRoles:s,discardOrganizationInvitation:r,resendOrganizationInvitation:i}=zt(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(new Set),u=o.useRef(null),{data:f=[],isLoading:h,mutate:g}=Se(e?`wacht-api-organizations:${e.id}:invitations`:null,()=>(a==null?void 0:a(e))||[]),{data:x=[],isLoading:w}=Se(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),b=x,j=(N,_)=>{p(C=>{const y=new Set(C);return _?y.add(N):y.delete(N),y})},v=async N=>{j(N.id,!0);try{await r(e,N),g(),l("Invitation cancelled","info")}catch(_){l(_.message||"Failed to cancel invitation","error")}finally{j(N.id,!1)}},k=async N=>{j(N.id,!0);try{await i(e,N),l("Invitation resent","info")}catch(_){l(_.message||"Failed to resend invitation","error")}finally{j(N.id,!1)}};return h||w?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Ar,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this organization."})]}),t.jsx(se,{ref:u,onClick:()=>c(!0),$size:"sm",children:"Invite"})]}),m&&t.jsx(Xc,{onClose:()=>c(!1),onSuccess:()=>{g(),c(!1)},roles:b,triggerRef:u}),f.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to collaborate."}):t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Email"}),t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{children:"Invited"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:f.map(N=>{var y;const _=hm(N),C=d.has(N.id);return t.jsxs(it,{children:[t.jsx(Xe,{children:N.email}),t.jsx(Xe,{children:((y=N.initial_organization_role)==null?void 0:y.name)||"No role"}),t.jsx(Xe,{children:_?t.jsx(fa,{$variant:"danger",children:"Expired"}):t.jsx(fa,{$variant:"warning",children:"Pending"})}),t.jsx(Xe,{children:new Date(N.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{$size:"sm",$outline:!0,disabled:C,onClick:()=>k(N),children:"Resend"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:C,onClick:()=>v(N),children:C?t.jsx(_e,{size:12}):"Cancel"})]})})]},N.id)})})]})})]})},Vi=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var _;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=Ce(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=Array.isArray((_=g==null?void 0:g.b2b_settings)==null?void 0:_.organization_permissions)?g.b2b_settings.organization_permissions.map(C=>({value:C,label:C})):[];o.useEffect(()=>{h(!0);const C=A=>{i.current&&!i.current.contains(A.target)&&(e==null||e())},y=A=>{A.key==="Escape"&&(e==null||e())},E=setTimeout(()=>{document.addEventListener("mousedown",C),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(E),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",y)}},[e]);const v=C=>C.trim().replace(/[<>"'&]/g,""),k=C=>C.length>=2&&C.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(C),N=async()=>{const C=v(l);if(!C){x("Please enter a role name","error");return}if(!k(C)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const y={id:s==null?void 0:s.id,name:C,permissions:c};a==null||a(y)}catch(y){x(y.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:C=>C.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(ye,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:C=>m(C.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(Yc,{options:j,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null};function Rr(e){return typeof e=="object"&&e!==null}function e0(e,a){const s=e[a];return typeof s=="string"?s.length>0&&s!=="0":typeof s=="number"?Number.isFinite(s)&&s>0:!1}function wm(e,a){const s=e[a];return typeof s=="boolean"?s:null}function t0(e){if(!Rr(e))return!1;const a=wm(e,"is_deployment_level");return a!==null?a:!1}function gm(e){return!Rr(e)||t0(e)?!1:e0(e,"organization_id")}function ur(e){return!Rr(e)||t0(e)?!1:e0(e,"workspace_id")}const xm=({organization:e})=>{var _;const{getOrganizationRoles:a,removeOrganizationRoles:s}=zt(),{deployment:r}=Ce(),[i,l]=o.useState({isOpen:!1}),[m,c]=o.useState(null),[d,p]=o.useState(null),[u,f]=o.useState(new Set),h=o.useRef(null),g=o.useRef(new Map),{data:x=[],isLoading:w,mutate:b}=Se(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(a==null?void 0:a(e))||[]),j=(C,y)=>{f(E=>{const A=new Set(E);return y?A.add(C):A.delete(C),A})},v=async C=>{try{await new Promise(y=>setTimeout(y,500)),c({text:`Role ${C.id?"updated":"created"} successfully`,type:"success"}),l({isOpen:!1}),b()}catch(y){const E=y instanceof Error?y.message:"Failed to save role";c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},k=async C=>{j(C.id,!0);try{await s(e,C),b()}finally{j(C.id,!1),p(null)}};if(w&&x.length===0)return t.jsx(_e,{});const N=C=>{const y=gm(C),E=u.has(C.id),A=C.permissions.length;return t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("span",{className:"w-inline w-gap-2 w-sec",children:[C.name,!y&&t.jsx(fa,{$variant:"neutral",children:"Default"})]})}),t.jsx(Xe,{children:A===0?t.jsx(fa,{$variant:"neutral",children:"No permissions"}):t.jsxs("div",{className:"w-inline w-items-center w-gap-2",children:[t.jsxs(fa,{$variant:"primary",children:[A," ",A===1?"permission":"permissions"]}),t.jsx("span",{className:"w-truncate w-text-secondary w-maxw-sm",children:C.permissions.join(", ")})]})}),t.jsx(Ft,{children:y?t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:H=>{H&&g.current.set(C.id,H)},$size:"sm",$outline:!0,disabled:E,onClick:()=>l({isOpen:!0,role:C,triggerElement:g.current.get(C.id)??null}),children:"Edit"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:E,onClick:()=>p(C.id),children:E?t.jsx(_e,{size:12}):"Delete"})]}):t.jsx("span",{className:"w-secsub",children:"Read-only"})})]},C.id)};return t.jsxs(t.Fragment,{children:[m&&t.jsxs("div",{className:`w-banner ${m.type==="success"?"w-banner--success":"w-banner--error"} w-mb-4`,children:[m.type==="success"?t.jsx(Ye,{size:16}):t.jsx(Fa,{size:16}),t.jsx("span",{className:"w-banner-txt",children:m.text})]}),t.jsxs(Ar,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for members."})]}),((_=r==null?void 0:r.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&t.jsx(se,{ref:h,onClick:()=>l({isOpen:!0,triggerElement:h.current}),$size:"sm",children:"Add role"})]}),i.isOpen&&!i.role&&t.jsx(Vi,{onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||h.current}}),x.length===0?t.jsx(Nt,{title:"No roles yet",description:"Define custom roles to manage granular permissions."}):t.jsx(t.Fragment,{children:t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Permissions"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:x.map(N)})]})})}),d&&t.jsx(Qa,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const C=x.find(y=>y.id===d);C&&k(C)},onCancel:()=>p(null)}),i.isOpen&&i.role&&t.jsx(Vi,{role:i.role,onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||null}})]})},vm=()=>{const{activeOrganization:e,loading:a}=ga(),[s,r]=o.useState(null);return o.useEffect(()=>{e?r(e):!a&&!e&&s&&r(null)},[e,a,s]),{activeOrganization:s||e,loading:a}},a0=()=>{var w,b,j;const{loading:e,activeOrganization:a}=vm(),{updateOrganization:s}=ga(),{deployment:r}=Ce(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};return e&&!a?t.jsx($e,{children:t.jsx(Zn,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})}):a?t.jsx($e,{children:t.jsx(Oi,{children:t.jsx(Er.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(Zn,{className:"w-relative",children:[t.jsxs(sm,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,title:"Change logo","aria-label":"Change organization logo",children:[a.image_url?t.jsx("img",{src:a.image_url,alt:a.name}):((w=a.name)==null?void 0:w.slice(0,2).toUpperCase())||"O",t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(sn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(nm,{children:[t.jsx(rm,{children:a.name}),t.jsx(im,{children:a.member_count!=null?`${a.member_count} members`:"Organization settings"})]})]}),t.jsx(em,{children:t.jsxs(tm,{children:[t.jsx(za,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Da,{children:[t.jsx(Ea,{size:16})," General"]})}),t.jsx(za,{$isActive:i==="domains",onClick:()=>l("domains"),children:t.jsxs(Da,{children:[t.jsx(Zu,{size:16})," Domains"]})}),t.jsx(za,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Da,{children:[t.jsx(cs,{size:16})," Members"]})}),t.jsx(za,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Da,{children:[t.jsx(hl,{size:16})," Invitations"]})}),((b=r==null?void 0:r.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&t.jsx(za,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Da,{children:[t.jsx(Xt,{size:16})," Roles"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.enterprise_sso_enabled)&&t.jsx(za,{$isActive:i==="sso",onClick:()=>l("sso"),children:t.jsxs(Da,{children:[t.jsx(Xt,{size:16})," SSO"]})})]})}),t.jsxs(am,{children:[i==="general"&&t.jsx(lm,{organization:a}),i==="domains"&&t.jsx(dm,{organization:a}),i==="members"&&t.jsx(um,{organization:a}),i==="invitations"&&t.jsx(fm,{organization:a}),i==="roles"&&t.jsx(xm,{organization:a}),i==="sso"&&t.jsx(Q4,{organization:a})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Fa,{size:12}):t.jsx(Ye,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})}):t.jsx($e,{children:t.jsx(Oi,{children:t.jsx(Zn,{className:"w-items-center w-justify-center",children:t.jsxs("div",{className:"w-empty",children:[t.jsx("span",{className:"w-empty-ic",children:t.jsx(ps,{size:20})}),t.jsx("h4",{children:"No Organization Selected"}),t.jsx(d0,{})]})})})})},s0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{className:"w-dialog--panel",children:[r&&t.jsx(Ue.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(a0,{}),l&&t.jsx(Ue.Footer,{children:l})]})})}),Lr=({organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})=>t.jsx($e,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Qc,{mode:"ws",organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})})}),Pr=({isOpen:e,onClose:a,onCreated:s,organizationId:r})=>{const[i,l]=o.useState(!1),[m,c]=o.useState(r),d=()=>{s==null||s(),a==null||a()},p=()=>{l(!0)},u=f=>{var g,x,w;const h=((x=(g=f==null?void 0:f.data)==null?void 0:g.organization)==null?void 0:x.id)??((w=f==null?void 0:f.organization)==null?void 0:w.id)??(f==null?void 0:f.id);h&&c(h),l(!1)};return t.jsx($e,{children:t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsx(Ue.Content,{className:"w-dialog--create",children:i?t.jsx(mn,{onSuccess:u,onCancel:()=>l(!1)}):t.jsx(Lr,{organizationId:m||r,onSuccess:d,onCancel:a,onCreateOrganization:p})})})})})},ft=(...e)=>e.filter(Boolean).join(" "),bm=({className:e,...a})=>t.jsx("div",{className:ft("w-contents",e),...a}),zi=({className:e,...a})=>t.jsx("div",{className:ft("w-card","w-flex-col","w-full","w-minh-full",e),...a}),ym=({className:e,...a})=>t.jsx("div",{className:ft("w-tabsbar",e),...a}),jm=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),Zs=({$isActive:e,className:a,...s})=>t.jsx("button",{className:ft("w-tab",e&&"w-tab--active",a),...s}),Hs=({className:e,...a})=>t.jsx("span",{className:ft("w-inline","w-gap-2",e),...a}),_m=({className:e,children:a,...s})=>t.jsx("div",{className:ft("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Js=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:ft("w-kebab",e),...a}));Js.displayName="IconButton";const n0=({className:e,...a})=>t.jsx("div",{className:ft("w-sechead",e),...a}),Di=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Ui=({className:e,...a})=>t.jsx("div",{className:ft("w-grow",e),...a}),Wi=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-3","w-none",e),...a}),$r=({className:e,...a})=>t.jsx("div",{className:ft("w-full",e),...a}),km=({className:e,...a})=>t.jsx("div",{className:ft("w-page-head",e),...a}),Cm=({className:e,...a})=>t.jsx("div",{className:ft("w-grow","w-flex-col","w-gap-1",e),...a}),Nm=({className:e,...a})=>t.jsx("div",{className:ft("w-sec","w-truncate",e),...a}),Sm=({className:e,...a})=>t.jsx("div",{className:ft("w-secsub","w-truncate",e),...a}),Bi=({$first:e,className:a,...s})=>t.jsx("div",{className:ft("w-sec",a),...s}),Em=()=>{var E,A;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Dt(),{deleteWorkspace:r}=va(),{deployment:i}=Ce(),{toast:l}=Ct(),[m,c]=o.useState((e==null?void 0:e.name)||""),[d,p]=o.useState((e==null?void 0:e.description)||""),[u,f]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[h,g]=o.useState(!1),[x,w]=o.useState(""),[b,j]=o.useState(!1),[v,k]=o.useState(!1);o.useEffect(()=>{var H;e&&(c(e.name||""),p(e.description||""),f({mfa_required:e.enforce_2fa||!1,ip_restrictions:e.enable_ip_restriction||!1,allowed_ips:((H=e.whitelisted_ips)==null?void 0:H.join(`
105
+ 10.0.0.0/24`,className:"w-input--area w-input--mono"})]})]})]}),((Z=i==null?void 0:i.b2b_settings)==null?void 0:Z.allow_org_deletion)&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Ti,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start w-gap-3",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-full",children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete organization"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this organization, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{_(!N),j("")},children:N?"Cancel":"Delete organization"})]}),N&&t.jsxs("div",{className:"w-flex-col w-gap-3 w-full",children:[t.jsxs(Ge,{children:[t.jsxs(Ve,{htmlFor:"confirm_org_name",children:["Type"," ",t.jsx("strong",{children:e.name})," ","to confirm"]}),t.jsx(ye,{id:"confirm_org_name",type:"text",value:b,onChange:R=>j(R.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:H,disabled:b!==e.name||v,children:v?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})]}):t.jsx(_e,{})},Mr=(e,a)=>a?`${e} ${a}`:e,Ot=o.forwardRef(({className:e,...a},s)=>t.jsx("table",{ref:s,className:Mr("w-table",e),...a}));Ot.displayName="Table";const Zt=o.forwardRef((e,a)=>t.jsx("thead",{ref:a,...e}));Zt.displayName="TableHead";const Ht=o.forwardRef((e,a)=>t.jsx("tbody",{ref:a,...e}));Ht.displayName="TableBody";const it=o.forwardRef((e,a)=>t.jsx("tr",{ref:a,...e}));it.displayName="TableRow";const Fe=o.forwardRef((e,a)=>t.jsx("th",{ref:a,...e}));Fe.displayName="TableHeader";const Xe=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:e,...a}));Xe.displayName="TableCell";const dm=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Mr("w-td--flex",e),...a}));dm.displayName="TableCellFlex";const Ft=o.forwardRef(({className:e,...a},s)=>t.jsx("td",{ref:s,className:Mr("w-td--actions",e),...a}));Ft.displayName="ActionsCell";const Nt=({title:e,description:a,icon:s,action:r})=>t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:s??t.jsx(Uu,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:e}),t.jsx("p",{children:a})]}),r&&t.jsx("div",{className:"w-empty-action",children:r})]}),bt=({triggerRef:e,isOpen:a,minWidth:s=300,defaultMaxHeight:r=400,offset:i=8,contentRef:l})=>{const[m,c]=o.useState();return o.useEffect(()=>{if(!a||!e.current){c(void 0);return}const d=()=>{var N;if(!e.current)return;const u=e.current.getBoundingClientRect(),f=window.innerWidth,h=window.innerHeight,g=((N=l==null?void 0:l.current)==null?void 0:N.offsetWidth)||s,x=h-u.bottom,w=u.top,b={};x>=w?(b.top=u.bottom+i,b.maxHeight=Math.min(r,x-i*2)):(b.bottom=h-u.top+i,b.maxHeight=Math.min(r,w-i*2));const j=f-u.left,v=u.right,k=j>=v?u.left:u.right-g;b.left=Math.max(i,Math.min(f-g-i,k)),c(b)},p=requestAnimationFrame(d);return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),()=>{cancelAnimationFrame(p),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0)}},[a,s,r,i,l]),m},Ii=({onClose:e,domain:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,f]=o.useState(!1),{addDomain:h,verifyDomain:g}=ga(),{toast:x}=Ct(),w=bt({contentRef:r,triggerRef:s??{current:null},isOpen:u,minWidth:360,defaultMaxHeight:420}),b=_=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(_),j=_=>_.trim().toLowerCase().replace(/^https?:\/\//,""),v=async()=>{const _=j(m);if(!_){x("Please enter a domain name","error");return}if(!b(_)){x("Please enter a valid domain (e.g., example.com)","error");return}if(_.length>253){x("Domain name is too long","error");return}p(!0);try{const C=await h({fqdn:_});x("Domain added","info"),l(C.data)}catch(C){x(C.message||"Failed to add domain. Please try again.","error")}finally{p(!1)}},k=async()=>{if(!(!i||d)){p(!0);try{await g(i),e==null||e(),x("Domain verified","info")}catch(_){x(_.message||"Failed to verify domain. Check DNS records and try again.","error")}finally{p(!1)}}};if(o.useEffect(()=>{f(!0);const _=y=>{r.current&&!r.current.contains(y.target)&&(e==null||e())},C=y=>{y.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]),o.useEffect(()=>{a&&l(a)},[a]),!u)return null;const N={position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"};return i?t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"verify-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"verify-domain-title",children:"Verify domain"}),t.jsx("p",{className:"w-pop-sub",children:"Add this DNS record, then verify."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Type"}),t.jsx(ye,{value:i==null?void 0:i.verification_dns_record_type,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(ye,{value:i==null?void 0:i.verification_dns_record_name,disabled:!0})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Value"}),t.jsx(ye,{value:i==null?void 0:i.verification_dns_record_data,disabled:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:d,children:d?t.jsx(_e,{size:12}):"Verify"})]})]}):t.jsxs("div",{ref:r,className:"w-pop w-pop--wide",style:N,onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"add-domain-title",children:"Add domain"}),t.jsx("p",{className:"w-pop-sub",children:"Verified members auto-join this org."}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Domain"}),t.jsx(ye,{type:"text",placeholder:"example.com",value:m,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&m&&v()},autoFocus:!0,"aria-label":"Domain name"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!m||d,children:d?t.jsx(_e,{size:12}):"Continue"})]})]})},um=({organization:e})=>{const{getOrganizationDomains:a,removeOrganizationDomain:s}=zt(),[r,i]=o.useState(null),[l,m]=o.useState(!1),[c,d]=o.useState(null),[p,u]=o.useState(new Set),f=o.useRef(null),h=o.useRef({}),{data:g=[],isLoading:x,mutate:w}=Se(e!=null&&e.id?`wacht-org-domains:${e.id}`:null,async()=>(await(a==null?void 0:a(e))||[]).map(k=>({...k,verified:k.verified!==void 0?k.verified:!1}))),b=(v,k)=>{u(N=>{const _=new Set(N);return k?_.add(v):_.delete(v),_})},j=async v=>{b(v.id,!0);try{await s(e,v),w()}finally{b(v.id,!1),i(null)}};return x?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Ar,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Domains"}),t.jsx("div",{className:"w-secsub",children:"Users with verified domain emails auto-join this organization."})]}),t.jsx(se,{ref:f,onClick:()=>m(!0),$size:"sm",children:"Add domain"}),l&&t.jsx(Ii,{onClose:()=>{m(!1),w()},triggerRef:f})]}),g!=null&&g.length?t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Domain"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{children:"Added"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:g.map(v=>{const k=p.has(v.id);return t.jsxs(it,{children:[t.jsx(Xe,{children:v.fqdn}),t.jsx(Xe,{children:v.verified?t.jsx(fa,{$variant:"success",children:"Verified"}):t.jsx(fa,{$variant:"warning",children:"Pending"})}),t.jsx(Xe,{children:new Date(v.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:N=>{N&&(h.current[v.id]=N)},$size:"sm",$outline:!0,disabled:k,onClick:()=>d(v.id),children:v.verified?"View DNS":"Verify"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:k,onClick:()=>i(v.id),children:k?t.jsx(_e,{size:12}):"Remove"})]})})]},v.id)})})]})}):t.jsx(Nt,{title:"No domains added",description:"Users with verified domain emails automatically join this organization."}),r&&t.jsx(Qa,{title:"Remove domain?",description:"Active users aren't affected, but new users with this domain won't auto-join.",onConfirm:()=>{const v=g.find(k=>k.id===r);v&&j(v)},onCancel:()=>i(null)}),c&&t.jsx(Ii,{domain:g.find(v=>v.id===c),onClose:()=>d(null),triggerRef:{current:h.current[c]}})]})},Xc=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{inviteMember:g}=ga(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:360}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}u(!0);try{await g({email:k,organizationRole:c}),a==null||a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{u(!1)}}};return o.useEffect(()=>{h(!0);const k=_=>{i.current&&!i.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email"}),t.jsx(ye,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),onKeyDown:k=>{k.key==="Enter"&&l&&c&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Role"}),t.jsx(un,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},mm=({organization:e})=>{const{getOrganizationMembers:a,getOrganizationRoles:s,addRoleToOrganizationMember:r,removeRoleFromOrganizationMember:i,removeOrganizationMember:l}=zt(),{session:m}=ot(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(!1),[w,b]=o.useState(new Set),j=o.useRef(null),[v,k]=o.useState(d);o.useEffect(()=>{const S=setTimeout(()=>{k(d),f(1)},500);return()=>clearTimeout(S)},[d]);const{data:N,mutate:_}=Se(e?`wacht-api-organizations:${e.id}:members:${u}:${h}:${v}`:null,()=>a==null?void 0:a(e,{page:u,limit:h,search:v}),{keepPreviousData:!0}),C=(N==null?void 0:N.data)||[],y=(N==null?void 0:N.meta)||{total:0,limit:10},E=Math.ceil(y.total/(y.limit||10)),{data:A=[]}=Se(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),H=A,M=(S,$)=>{b(Z=>{const R=new Set(Z);return $?R.add(S):R.delete(S),R})},T=async(S,$,Z)=>{M(S.id,!0);try{Z?(await i(e,S,$),c("Role removed","info")):(await r(e,S,$),c("Role added","info")),_()}catch(R){c(R.message||"Failed to update role","error")}finally{M(S.id,!1)}},P=async S=>{M(S.id,!0);try{await l(e,S),_(),c("Member removed","info")}catch($){c($.message||"Failed to remove member","error")}finally{M(S.id,!1)}};return N?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Gc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[y.total>0&&t.jsxs("div",{className:"w-secsub",children:[y.total," member",y.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>x(!0),$size:"sm",children:"Invite"})]})]}),g&&t.jsx(Xc,{onClose:()=>x(!1),onSuccess:()=>{_(),x(!1)},roles:H,triggerRef:j}),C.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Invite someone or connect a corporate domain to auto-join."}):t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Member"}),t.jsx(Fe,{children:"Joined"}),t.jsx(Fe,{children:"Roles"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:C.map(S=>{var R,L;const $=((R=S.user)==null?void 0:R.id)===((L=m==null?void 0:m.active_signin)==null?void 0:L.user_id),Z=w.has(S.id);return t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsx(pm,{member:S,isCurrentUser:$})}),t.jsx(Xe,{children:new Date(S.created_at).toLocaleDateString()}),t.jsx(Xe,{children:t.jsx(hm,{member:S,roles:H,onToggle:T,disabled:Z})}),t.jsx(Ft,{children:t.jsx("div",{className:"w-actions",children:t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:Z||$,onClick:()=>P(S),title:$?"You cannot remove yourself":"Remove member",children:Z?t.jsx(_e,{size:12}):"Remove"})})})]},S.id)})})]})}),E>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4 w-mt-6",children:[t.jsx(se,{onClick:()=>f(S=>Math.max(1,S-1)),disabled:u===1,$size:"sm",$outline:!0,children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",E]}),t.jsx(se,{onClick:()=>f(S=>Math.min(E,S+1)),disabled:u===E,$size:"sm",$outline:!0,children:"Next"})]})]}):t.jsx(_e,{})},pm=({member:e,isCurrentUser:a})=>{var l,m;const s=e.user,r=(c="",d="")=>`${c[0]||""}${d[0]||""}`.toUpperCase()||"?",i=s?`${s.first_name||""} ${s.last_name||""}`.trim()||((l=s.primary_email_address)==null?void 0:l.email):"Unknown";return t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx("div",{className:"w-avatar w-avatar--md",children:s!=null&&s.profile_picture_url?t.jsx("img",{src:s.profile_picture_url,alt:i}):r(s==null?void 0:s.first_name,s==null?void 0:s.last_name)}),t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:i}),a&&t.jsx(fa,{$variant:"neutral",children:"You"})]}),t.jsx("span",{className:"w-secsub",children:(m=s==null?void 0:s.primary_email_address)==null?void 0:m.email})]})]})},hm=({member:e,roles:a,onToggle:s,disabled:r})=>{var c;const i=e.roles||[],l=d=>i.some(p=>p.id===d),m=i.length===0?"No role":i.length===1?(c=i[0])==null?void 0:c.name:`${i.length} roles`;return t.jsxs(_s,{children:[t.jsx(Cs,{children:t.jsxs(se,{$size:"sm",$outline:!0,disabled:r,className:"w-justify-between w-rolepick-btn",children:[m,t.jsx(Ut,{size:12})]})}),t.jsx(ks,{children:a.length===0?t.jsx("div",{className:"w-secsub w-menu-head",children:"No roles configured"}):a.map(d=>{const p=l(d.id);return t.jsx(ea,{onClick:()=>s(e,d,p),children:t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-3 w-full",children:[t.jsx("span",{children:d.name}),p&&t.jsx(Ye,{size:13,className:"w-text-primary"})]})},d.id)})})]})},fm=e=>{const a=e.expires_at;return a?new Date(a).getTime()<Date.now():!1},wm=({organization:e})=>{const{getOrganizationInvitations:a,getOrganizationRoles:s,discardOrganizationInvitation:r,resendOrganizationInvitation:i}=zt(),{toast:l}=Ct(),[m,c]=o.useState(!1),[d,p]=o.useState(new Set),u=o.useRef(null),{data:f=[],isLoading:h,mutate:g}=Se(e?`wacht-api-organizations:${e.id}:invitations`:null,()=>(a==null?void 0:a(e))||[]),{data:x=[],isLoading:w}=Se(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(s==null?void 0:s(e))||[]),b=x,j=(N,_)=>{p(C=>{const y=new Set(C);return _?y.add(N):y.delete(N),y})},v=async N=>{j(N.id,!0);try{await r(e,N),g(),l("Invitation cancelled","info")}catch(_){l(_.message||"Failed to cancel invitation","error")}finally{j(N.id,!1)}},k=async N=>{j(N.id,!0);try{await i(e,N),l("Invitation resent","info")}catch(_){l(_.message||"Failed to resend invitation","error")}finally{j(N.id,!1)}};return h||w?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(Ar,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this organization."})]}),t.jsx(se,{ref:u,onClick:()=>c(!0),$size:"sm",children:"Invite"})]}),m&&t.jsx(Xc,{onClose:()=>c(!1),onSuccess:()=>{g(),c(!1)},roles:b,triggerRef:u}),f.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to collaborate."}):t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Email"}),t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{children:"Invited"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:f.map(N=>{var y;const _=fm(N),C=d.has(N.id);return t.jsxs(it,{children:[t.jsx(Xe,{children:N.email}),t.jsx(Xe,{children:((y=N.initial_organization_role)==null?void 0:y.name)||"No role"}),t.jsx(Xe,{children:_?t.jsx(fa,{$variant:"danger",children:"Expired"}):t.jsx(fa,{$variant:"warning",children:"Pending"})}),t.jsx(Xe,{children:new Date(N.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{$size:"sm",$outline:!0,disabled:C,onClick:()=>k(N),children:"Resend"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:C,onClick:()=>v(N),children:C?t.jsx(_e,{size:12}):"Cancel"})]})})]},N.id)})})]})})]})},Vi=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var _;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=Ce(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=Array.isArray((_=g==null?void 0:g.b2b_settings)==null?void 0:_.organization_permissions)?g.b2b_settings.organization_permissions.map(C=>({value:C,label:C})):[];o.useEffect(()=>{h(!0);const C=A=>{i.current&&!i.current.contains(A.target)&&(e==null||e())},y=A=>{A.key==="Escape"&&(e==null||e())},E=setTimeout(()=>{document.addEventListener("mousedown",C),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(E),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",y)}},[e]);const v=C=>C.trim().replace(/[<>"'&]/g,""),k=C=>C.length>=2&&C.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(C),N=async()=>{const C=v(l);if(!C){x("Please enter a role name","error");return}if(!k(C)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const y={id:s==null?void 0:s.id,name:C,permissions:c};a==null||a(y)}catch(y){x(y.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:C=>C.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(ye,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:C=>m(C.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(Yc,{options:j,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null};function Rr(e){return typeof e=="object"&&e!==null}function e0(e,a){const s=e[a];return typeof s=="string"?s.length>0&&s!=="0":typeof s=="number"?Number.isFinite(s)&&s>0:!1}function gm(e,a){const s=e[a];return typeof s=="boolean"?s:null}function t0(e){if(!Rr(e))return!1;const a=gm(e,"is_deployment_level");return a!==null?a:!1}function xm(e){return!Rr(e)||t0(e)?!1:e0(e,"organization_id")}function ur(e){return!Rr(e)||t0(e)?!1:e0(e,"workspace_id")}const vm=({organization:e})=>{var _;const{getOrganizationRoles:a,removeOrganizationRoles:s}=zt(),{deployment:r}=Ce(),[i,l]=o.useState({isOpen:!1}),[m,c]=o.useState(null),[d,p]=o.useState(null),[u,f]=o.useState(new Set),h=o.useRef(null),g=o.useRef(new Map),{data:x=[],isLoading:w,mutate:b}=Se(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(a==null?void 0:a(e))||[]),j=(C,y)=>{f(E=>{const A=new Set(E);return y?A.add(C):A.delete(C),A})},v=async C=>{try{await new Promise(y=>setTimeout(y,500)),c({text:`Role ${C.id?"updated":"created"} successfully`,type:"success"}),l({isOpen:!1}),b()}catch(y){const E=y instanceof Error?y.message:"Failed to save role";c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},k=async C=>{j(C.id,!0);try{await s(e,C),b()}finally{j(C.id,!1),p(null)}};if(w&&x.length===0)return t.jsx(_e,{});const N=C=>{const y=xm(C),E=u.has(C.id),A=C.permissions.length;return t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("span",{className:"w-inline w-gap-2 w-sec",children:[C.name,!y&&t.jsx(fa,{$variant:"neutral",children:"Default"})]})}),t.jsx(Xe,{children:A===0?t.jsx(fa,{$variant:"neutral",children:"No permissions"}):t.jsxs("div",{className:"w-inline w-items-center w-gap-2",children:[t.jsxs(fa,{$variant:"primary",children:[A," ",A===1?"permission":"permissions"]}),t.jsx("span",{className:"w-truncate w-text-secondary w-maxw-sm",children:C.permissions.join(", ")})]})}),t.jsx(Ft,{children:y?t.jsxs("div",{className:"w-actions",children:[t.jsx(se,{ref:H=>{H&&g.current.set(C.id,H)},$size:"sm",$outline:!0,disabled:E,onClick:()=>l({isOpen:!0,role:C,triggerElement:g.current.get(C.id)??null}),children:"Edit"}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,disabled:E,onClick:()=>p(C.id),children:E?t.jsx(_e,{size:12}):"Delete"})]}):t.jsx("span",{className:"w-secsub",children:"Read-only"})})]},C.id)};return t.jsxs(t.Fragment,{children:[m&&t.jsxs("div",{className:`w-banner ${m.type==="success"?"w-banner--success":"w-banner--error"} w-mb-4`,children:[m.type==="success"?t.jsx(Ye,{size:16}):t.jsx(Fa,{size:16}),t.jsx("span",{className:"w-banner-txt",children:m.text})]}),t.jsxs(Ar,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for members."})]}),((_=r==null?void 0:r.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&t.jsx(se,{ref:h,onClick:()=>l({isOpen:!0,triggerElement:h.current}),$size:"sm",children:"Add role"})]}),i.isOpen&&!i.role&&t.jsx(Vi,{onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||h.current}}),x.length===0?t.jsx(Nt,{title:"No roles yet",description:"Define custom roles to manage granular permissions."}):t.jsx(t.Fragment,{children:t.jsx(pn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Permissions"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:x.map(N)})]})})}),d&&t.jsx(Qa,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const C=x.find(y=>y.id===d);C&&k(C)},onCancel:()=>p(null)}),i.isOpen&&i.role&&t.jsx(Vi,{role:i.role,onClose:()=>l({isOpen:!1}),onSuccess:v,triggerRef:{current:i.triggerElement||null}})]})},bm=()=>{const{activeOrganization:e,loading:a}=ga(),[s,r]=o.useState(null);return o.useEffect(()=>{e?r(e):!a&&!e&&s&&r(null)},[e,a,s]),{activeOrganization:s||e,loading:a}},a0=()=>{var w,b,j;const{loading:e,activeOrganization:a}=bm(),{updateOrganization:s}=ga(),{deployment:r}=Ce(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};return e&&!a?t.jsx($e,{children:t.jsx(Zn,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})}):a?t.jsx($e,{children:t.jsx(Oi,{children:t.jsx(Er.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(Zn,{className:"w-relative",children:[t.jsxs(nm,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,title:"Change logo","aria-label":"Change organization logo",children:[a.image_url?t.jsx("img",{src:a.image_url,alt:a.name}):((w=a.name)==null?void 0:w.slice(0,2).toUpperCase())||"O",t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(sn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(rm,{children:[t.jsx(im,{children:a.name}),t.jsx(om,{children:a.member_count!=null?`${a.member_count} members`:"Organization settings"})]})]}),t.jsx(tm,{children:t.jsxs(am,{children:[t.jsx(za,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Da,{children:[t.jsx(Ea,{size:16})," General"]})}),t.jsx(za,{$isActive:i==="domains",onClick:()=>l("domains"),children:t.jsxs(Da,{children:[t.jsx(Zu,{size:16})," Domains"]})}),t.jsx(za,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Da,{children:[t.jsx(cs,{size:16})," Members"]})}),t.jsx(za,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Da,{children:[t.jsx(hl,{size:16})," Invitations"]})}),((b=r==null?void 0:r.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&t.jsx(za,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Da,{children:[t.jsx(Xt,{size:16})," Roles"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.enterprise_sso_enabled)&&t.jsx(za,{$isActive:i==="sso",onClick:()=>l("sso"),children:t.jsxs(Da,{children:[t.jsx(Xt,{size:16})," SSO"]})})]})}),t.jsxs(sm,{children:[i==="general"&&t.jsx(cm,{organization:a}),i==="domains"&&t.jsx(um,{organization:a}),i==="members"&&t.jsx(mm,{organization:a}),i==="invitations"&&t.jsx(wm,{organization:a}),i==="roles"&&t.jsx(vm,{organization:a}),i==="sso"&&t.jsx(J4,{organization:a})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Fa,{size:12}):t.jsx(Ye,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})}):t.jsx($e,{children:t.jsx(Oi,{children:t.jsx(Zn,{className:"w-items-center w-justify-center",children:t.jsxs("div",{className:"w-empty",children:[t.jsx("span",{className:"w-empty-ic",children:t.jsx(ps,{size:20})}),t.jsx("h4",{children:"No Organization Selected"}),t.jsx(d0,{})]})})})})},s0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{className:"w-dialog--panel",children:[r&&t.jsx(Ue.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(a0,{}),l&&t.jsx(Ue.Footer,{children:l})]})})}),Lr=({organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})=>t.jsx($e,{children:t.jsx("div",{className:"w-flex w-justify-center w-full",children:t.jsx(Qc,{mode:"ws",organizationId:e,onSuccess:a,onCancel:s,onCreateOrganization:r})})}),Pr=({isOpen:e,onClose:a,onCreated:s,organizationId:r})=>{const[i,l]=o.useState(!1),[m,c]=o.useState(r),d=()=>{s==null||s(),a==null||a()},p=()=>{l(!0)},u=f=>{var g,x,w;const h=((x=(g=f==null?void 0:f.data)==null?void 0:g.organization)==null?void 0:x.id)??((w=f==null?void 0:f.organization)==null?void 0:w.id)??(f==null?void 0:f.id);h&&c(h),l(!1)};return t.jsx($e,{children:t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsx(Ue.Content,{className:"w-dialog--create",children:i?t.jsx(mn,{onSuccess:u,onCancel:()=>l(!1)}):t.jsx(Lr,{organizationId:m||r,onSuccess:d,onCancel:a,onCreateOrganization:p})})})})})},ft=(...e)=>e.filter(Boolean).join(" "),ym=({className:e,...a})=>t.jsx("div",{className:ft("w-contents",e),...a}),zi=({className:e,...a})=>t.jsx("div",{className:ft("w-card","w-flex-col","w-full","w-minh-full",e),...a}),jm=({className:e,...a})=>t.jsx("div",{className:ft("w-tabsbar",e),...a}),_m=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}),Zs=({$isActive:e,className:a,...s})=>t.jsx("button",{className:ft("w-tab",e&&"w-tab--active",a),...s}),Hs=({className:e,...a})=>t.jsx("span",{className:ft("w-inline","w-gap-2",e),...a}),km=({className:e,children:a,...s})=>t.jsx("div",{className:ft("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}),Js=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:ft("w-kebab",e),...a}));Js.displayName="IconButton";const n0=({className:e,...a})=>t.jsx("div",{className:ft("w-sechead",e),...a}),Di=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-justify-between","w-gap-4",e),...a}),Ui=({className:e,...a})=>t.jsx("div",{className:ft("w-grow",e),...a}),Wi=({className:e,...a})=>t.jsx("div",{className:ft("w-flex","w-items-center","w-gap-3","w-none",e),...a}),$r=({className:e,...a})=>t.jsx("div",{className:ft("w-full",e),...a}),Cm=({className:e,...a})=>t.jsx("div",{className:ft("w-page-head",e),...a}),Nm=({className:e,...a})=>t.jsx("div",{className:ft("w-grow","w-flex-col","w-gap-1",e),...a}),Sm=({className:e,...a})=>t.jsx("div",{className:ft("w-sec","w-truncate",e),...a}),Em=({className:e,...a})=>t.jsx("div",{className:ft("w-secsub","w-truncate",e),...a}),Bi=({$first:e,className:a,...s})=>t.jsx("div",{className:ft("w-sec",a),...s}),Am=()=>{var E,A;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Dt(),{deleteWorkspace:r}=va(),{deployment:i}=Ce(),{toast:l}=Ct(),[m,c]=o.useState((e==null?void 0:e.name)||""),[d,p]=o.useState((e==null?void 0:e.description)||""),[u,f]=o.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[h,g]=o.useState(!1),[x,w]=o.useState(""),[b,j]=o.useState(!1),[v,k]=o.useState(!1);o.useEffect(()=>{var H;e&&(c(e.name||""),p(e.description||""),f({mfa_required:e.enforce_2fa||!1,ip_restrictions:e.enable_ip_restriction||!1,allowed_ips:((H=e.whitelisted_ips)==null?void 0:H.join(`
106
106
  `))||""}))},[e]);const N=async()=>{if(!(!e||h))try{g(!0),await s({name:m,description:d,enforce_2fa:u.mfa_required,enable_ip_restriction:u.ip_restrictions,whitelisted_ips:u.allowed_ips.split(`
107
107
  `).filter(H=>H.trim())}),l("Changes saved","info")}catch(H){l(H.message||"Failed to save changes","error")}finally{g(!1)}},_=async()=>{if(!(!e||x!==e.name))try{j(!0),await r(e),l("Workspace deleted","info")}catch{l("Failed to delete workspace","error")}finally{j(!1),w("")}};if(a&&!e)return t.jsx(_e,{});if(!e)return null;const C=(E=i==null?void 0:i.b2b_settings)==null?void 0:E.enforce_mfa_per_workspace_enabled,y=(A=i==null?void 0:i.b2b_settings)==null?void 0:A.ip_allowlist_per_workspace_enabled;return t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"name",children:"Workspace name"}),t.jsx(ye,{id:"name",value:m,onChange:H=>c(H.target.value),onBlur:N,placeholder:"Workspace name",required:!0})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"description",children:"Description"}),t.jsx(ye,{id:"description",as:"textarea",value:d,onChange:H=>p(H.target.value),onBlur:N,placeholder:"Optional description",className:"w-input--area"})]})]}),(C||y)&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Bi,{children:"Security"}),C&&t.jsxs(Di,{children:[t.jsxs(Ui,{children:[t.jsx("div",{className:"w-sec",children:"Multi-factor authentication"}),t.jsx("p",{className:"w-secsub",children:"Require all workspace members to set up MFA."})]}),t.jsx(Wi,{children:t.jsx(Za,{checked:u.mfa_required,onChange:()=>{f(H=>({...H,mfa_required:!H.mfa_required})),setTimeout(N,0)}})})]}),y&&t.jsxs(t.Fragment,{children:[t.jsxs(Di,{children:[t.jsxs(Ui,{children:[t.jsx("div",{className:"w-sec",children:"IP restrictions"}),t.jsx("p",{className:"w-secsub",children:"Only allow access from specific IP addresses."})]}),t.jsx(Wi,{children:t.jsx(Za,{checked:u.ip_restrictions,onChange:()=>{f(H=>({...H,ip_restrictions:!H.ip_restrictions})),setTimeout(N,0)}})})]}),u.ip_restrictions&&t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(ye,{id:"allowed_ips",as:"textarea",value:u.allowed_ips,onChange:H=>f(M=>({...M,allowed_ips:H.target.value})),onBlur:N,placeholder:`192.168.1.1
108
- 10.0.0.0/24`,className:"w-input--area w-mono-sm"})]})]})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Bi,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger",children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Delete workspace"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this workspace, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{k(!v),w("")},children:v?"Cancel":"Delete workspace"})]}),v&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(Ge,{children:[t.jsxs(Ve,{htmlFor:"confirm_workspace_name",children:["Type ",t.jsx("strong",{children:e.name})," to confirm"]}),t.jsx(ye,{id:"confirm_workspace_name",type:"text",value:x,onChange:H=>w(H.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:_,disabled:x!==e.name||b,children:b?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})},Am=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{toast:g}=Ct(),{inviteMember:x}=Dt(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name}));o.useEffect(()=>{h(!0);const k=C=>{i.current&&!i.current.contains(C.target)&&(e==null||e())},N=C=>{C.key==="Escape"&&(e==null||e())},_=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",N)},100);return()=>{clearTimeout(_),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]);const j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){g("Please enter a valid email address","error");return}if(k.length>320){g("Email address is too long","error");return}u(!0);try{await x({email:k,workspaceRoleId:c.id}),a==null||a()}catch(N){const _=N.message||"Failed to send invitation. Please try again.";g(_,"error")}finally{u(!1)}}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,maxHeight:w!=null&&w.maxHeight?`${w.maxHeight}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-workspace-member-title",children:"Invite member"}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Email Address"}),t.jsx(ye,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Role"}),t.jsx(un,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:14}):"Send invite"})]})]}):null},Mm=()=>{const{activeWorkspace:e,getMembers:a,getRoles:s,removeMember:r,addMemberRole:i,removeMemberRole:l}=Dt(),{session:m}=ot(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(""),[w,b]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>{const M=setTimeout(()=>{x(d),f(1)},500);return()=>clearTimeout(M)},[d]);const{data:v,mutate:k}=Se(e?`wacht-api-workspaces:${e.id}:members:${u}:${h}:${g}`:null,()=>a==null?void 0:a({page:u,limit:h,search:g}),{keepPreviousData:!0}),N=(v==null?void 0:v.data)||[],_=(v==null?void 0:v.meta)||{total:0,limit:10},C=Math.ceil(_.total/(_.limit||10)),{data:y=[]}=Se(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),E=y,A=async(M,T,P)=>{try{P?(await l(M,T),c("Role removed","info")):(await i(M,T),c("Role added","info")),k()}catch{c("Failed to update role","error")}},H=async M=>{try{await r(M),c("Member removed","info"),k()}catch{c("Failed to remove member","error")}};return v?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Gc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[_.total>0&&t.jsxs("div",{className:"w-text-muted w-secsub",children:[_.total," member",_.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>b(!0),$size:"sm",children:"Invite"})]})]}),w&&t.jsx(Am,{onClose:()=>b(!1),onSuccess:()=>{k(),b(!1)},roles:E,triggerRef:j}),N.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):t.jsx(t.Fragment,{children:t.jsx($r,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Member"}),t.jsx(Fe,{children:"Joined"}),t.jsx(Fe,{children:"Role"})]})}),t.jsx(Ht,{children:N.map(M=>t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsx(Rm,{member:M,session:m})}),t.jsx(Xe,{children:new Date(M.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsx(Lm,{member:M,roles:E,onToggle:(T,P)=>A(M.id,T,P),onRemove:()=>H(M.id)})})]},M.id))})]})})}),C>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4",children:[t.jsx(se,{onClick:()=>f(M=>Math.max(1,M-1)),disabled:u===1,$size:"sm",children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",C]}),t.jsx(se,{onClick:()=>f(M=>Math.min(C,M+1)),disabled:u===C,$size:"sm",children:"Next"})]})]}):t.jsx(_e,{})},Rm=({member:e,session:a,subtitle:s})=>{var m,c,d;const r=e.public_user_data||e.user,i=(r==null?void 0:r.id)===((m=a==null?void 0:a.active_signin)==null?void 0:m.user_id),l=(p="",u="")=>`${p[0]||""}${u[0]||""} `.toUpperCase();return t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx("div",{className:"w-avatar",children:r!=null&&r.profile_picture_url?t.jsx("img",{src:r.profile_picture_url,alt:"Avatar"}):l(r==null?void 0:r.first_name,r==null?void 0:r.last_name)||"?"}),t.jsxs("div",{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:r?`${r.first_name||""} ${r.last_name||""} `.trim()||((c=r.primary_email_address)==null?void 0:c.email):"Unknown"}),i&&t.jsx("span",{className:"w-pill",children:"You"})]}),t.jsxs("div",{className:"w-flex w-wrap w-gap-2 w-secsub",children:[t.jsx("span",{children:(d=r==null?void 0:r.primary_email_address)==null?void 0:d.email}),s&&t.jsxs("span",{className:"w-text-muted",children:["• ",s]})]})]})]})},Lm=({member:e,roles:a,onToggle:s,onRemove:r})=>{var m;const i=e.roles||[],l=c=>i.some(d=>d.id===c);return t.jsxs(_s,{children:[t.jsx(Cs,{children:t.jsxs(se,{$outline:!0,$size:"sm",className:"w-justify-between w-rolepick-btn",children:[i.length>0?(m=i==null?void 0:i[0])==null?void 0:m.name:"No role"," ",t.jsx(Ut,{size:14})]})}),t.jsxs(ks,{children:[a.map(c=>{const d=l(c.id);return t.jsx(ea,{onClick:()=>s(c.id,d),children:t.jsxs("div",{className:"w-flex w-justify-between w-full w-gap-3",children:[t.jsx("span",{children:c.name}),d&&t.jsx(Ye,{size:14,className:"w-text-success"})]})},c.id)}),t.jsx(Wc,{}),t.jsx(ea,{$destructive:!0,onClick:r,children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(xr,{size:14})," Remove Member"]})})]})]})},Pm=({onClose:e,onSuccess:a,roles:s,createInvitation:r,triggerRef:i})=>{const l=o.useRef(null),[m,c]=o.useState(""),[d,p]=o.useState(s[0]||null),[u,f]=o.useState(!1),[h,g]=o.useState(!1),{toast:x}=Ct(),w=bt({contentRef:l,triggerRef:i,isOpen:h,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=m.trim().toLowerCase();if(!(!k||!d)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}f(!0);try{await r({email:k,role_id:d.id}),a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{f(!1)}}};return o.useEffect(()=>{g(!0);const k=_=>{l.current&&!l.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),h?t.jsxs("div",{ref:l,className:"w-pop w-pop--wide w-pop-body",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Email"}),t.jsx(ye,{type:"email",placeholder:"colleague@company.com",value:m,onChange:k=>c(k.target.value),onKeyDown:k=>{k.key==="Enter"&&m&&d&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Role"}),t.jsx(un,{options:b,value:d==null?void 0:d.id,onChange:k=>p(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(se,{$size:"sm",$outline:!0,$fullWidth:!0,onClick:e,children:"Cancel"}),t.jsx(se,{$size:"sm",$fullWidth:!0,onClick:v,disabled:!m||!d||u,children:u?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},$m=()=>{const{activeWorkspace:e,loading:a,getRoles:s,getInvitations:r,inviteMember:i,discardInvitation:l,resendInvitation:m}=Dt(),{toast:c}=Ct(),[d,p]=o.useState(!0),[u,f]=o.useState(!0),[h,g]=o.useState([]),[x,w]=o.useState([]),[b,j]=o.useState(!1),v=o.useRef(null),k=async()=>{if(e){p(!0),f(!0);try{const[C,y]=await Promise.all([s(),r()]);w(C),g(y)}catch{}finally{p(!1),f(!1)}}};o.useEffect(()=>{k()},[e==null?void 0:e.id]);const N=async C=>{try{await l(C),k(),c("Invitation cancelled","info")}catch{c("Failed to cancel invitation","error")}},_=async C=>{try{await m(C),k(),c("Invitation resent","info")}catch{c("Failed to resend invitation","error")}};return a||d||u?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(n0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this workspace."})]}),t.jsx(se,{ref:v,onClick:()=>j(!0),$size:"sm",children:"Invite"})]}),b&&t.jsx(Pm,{onClose:()=>j(!1),onSuccess:()=>{k(),j(!1),c("Invitation sent","info")},roles:x,createInvitation:C=>i({email:C.email,workspaceRoleId:C.role_id}),triggerRef:v}),h.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to your workspace."}):t.jsx(t.Fragment,{children:t.jsx($r,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Email"}),t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Invited"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:h.map(C=>{var y,E;return t.jsxs(it,{children:[t.jsx(Xe,{children:C.email}),t.jsx(Xe,{children:((y=C.initial_workspace_role)==null?void 0:y.name)||((E=C.initial_organization_role)==null?void 0:E.name)||"No role"}),t.jsx(Xe,{children:new Date(C.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsx(Om,{onResend:()=>_(C.id),onCancel:()=>N(C.id)})})]},C.id)})})]})})})]})},Om=({onResend:e,onCancel:a})=>t.jsxs(_s,{children:[t.jsx(Cs,{children:t.jsx(Js,{children:"•••"})}),t.jsxs(ks,{children:[t.jsxs(ea,{onClick:e,children:[t.jsx(Ll,{size:16})," Resend"]}),t.jsxs(ea,{$destructive:!0,onClick:a,children:[t.jsx(xr,{size:16})," Cancel"]})]})]}),Gi=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var C,y;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=Ce(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=((C=g==null?void 0:g.b2b_settings)==null?void 0:C.workspace_permissions)||((y=g==null?void 0:g.b2b_settings)==null?void 0:y.organization_permissions)||[],v=Array.isArray(j)?j.map(E=>({value:E,label:E})):[];o.useEffect(()=>{h(!0);const E=M=>{i.current&&!i.current.contains(M.target)&&(e==null||e())},A=M=>{M.key==="Escape"&&(e==null||e())},H=setTimeout(()=>{document.addEventListener("mousedown",E),document.addEventListener("keydown",A)},100);return()=>{clearTimeout(H),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",A)}},[e]);const k=E=>E.trim().replace(/[<>"'&]/g,""),N=E=>E.length>=2&&E.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(E),_=async()=>{const E=k(l);if(!E){x("Please enter a role name","error");return}if(!N(E)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const A={id:s==null?void 0:s.id,name:E,permissions:c};a==null||a(A)}catch(A){x(A.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(ye,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:E=>m(E.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(Yc,{options:v,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null},Zm=()=>{var N;const{activeWorkspace:e,loading:a,getRoles:s,createRole:r,deleteRole:i}=Dt(),{deployment:l}=Ce(),{toast:m}=Ct(),[c,d]=o.useState({isOpen:!1}),[p,u]=o.useState(null),[f,h]=o.useState(null),g=o.useRef(null),x=o.useRef(new Map),{data:w=[],isLoading:b,mutate:j}=Se(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),v=async _=>{try{await r(_.name,_.permissions||[]),m("Role saved successfully","info"),d({isOpen:!1}),j()}catch{m("Failed to save role","error")}},k=async _=>{try{await i(_),m("Role deleted","info"),u(null),j()}catch{m("Failed to delete role","error")}};return a||b?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(n0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for this workspace."})]}),((N=l==null?void 0:l.b2b_settings)==null?void 0:N.custom_workspace_role_enabled)&&t.jsx(se,{ref:g,onClick:()=>d({isOpen:!0,triggerElement:g.current}),$size:"sm",children:"Add role"})]}),c.isOpen&&!c.role&&t.jsx(Gi,{triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v}),w.length===0?t.jsx(Nt,{title:"No roles yet",description:"Create workspace-specific roles to manage access."}):t.jsx(t.Fragment,{children:t.jsx($r,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Permissions"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:w.map(_=>{var C;return t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2 w-wrap",children:[t.jsx("span",{className:"w-sec",children:_.name}),!ur(_)&&t.jsx("span",{className:"w-pill",children:"Default"})]})}),t.jsx(Xe,{children:t.jsxs("span",{className:"w-text-secondary",children:[(C=_.permissions)==null?void 0:C.join(", "),!ur(_)&&" • Cannot be edited or deleted"]})}),t.jsx(Ft,{children:t.jsx(Hm,{role:_,onEdit:y=>d({isOpen:!0,role:_,triggerElement:y}),onDelete:()=>u(_.id),open:f===_.id,onOpenChange:y=>h(y?_.id:null),dropdownButtonRefs:x})})]},_.id)})})]})})}),p&&t.jsx(Qa,{title:"Delete role?",description:"Are you sure? This will remove the role from all workspace members.",onConfirm:()=>{const _=w.find(C=>C.id===p);_&&k(_)},onCancel:()=>u(null)}),c.isOpen&&c.role&&t.jsx(Gi,{role:c.role,triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v})]})},Hm=({role:e,onEdit:a,onDelete:s,open:r,onOpenChange:i,dropdownButtonRefs:l})=>ur(e)?t.jsxs(_s,{open:r,openChange:i,children:[t.jsx(Cs,{children:t.jsx(Js,{ref:c=>{c&&l.current.set(e.id,c)},children:"•••"})}),t.jsxs(ks,{children:[t.jsx(ea,{onClick:()=>a(l.current.get(e.id)??null),children:"Edit Role"}),t.jsxs(ea,{$destructive:!0,onClick:s,children:[t.jsx(xr,{size:16})," Remove Role"]})]})]}):t.jsx(Js,{disabled:!0,title:"Deployment roles cannot be edited","aria-label":"Deployment roles cannot be edited",children:"•••"}),Fm=e=>(e||"").slice(0,2).toUpperCase()||"W",r0=()=>{var b,j;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Dt(),{deployment:r}=Ce(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(a&&!e)return t.jsx($e,{children:t.jsx(zi,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})});if(!e)return null;const w=(b=e.organization)==null?void 0:b.name;return t.jsx($e,{children:t.jsx(bm,{children:t.jsx(Er.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(zi,{className:"w-relative",children:[t.jsxs(km,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit",onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,"data-busy":u?"":void 0,title:"Change logo","aria-label":"Change workspace logo",children:[e.image_url?t.jsx("img",{src:e.image_url,alt:e.name}):Fm(e.name),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(sn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",className:"w-none",hidden:!0,onChange:x}),t.jsxs(Cm,{children:[t.jsx(Nm,{children:e.name}),t.jsx(Sm,{children:w?`${w} · Workspace settings`:"Workspace settings"})]})]}),t.jsx(ym,{children:t.jsxs(jm,{children:[t.jsx(Zs,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Hs,{children:[t.jsx(Ea,{size:14})," General"]})}),t.jsx(Zs,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Hs,{children:[t.jsx(cs,{size:14})," Members"]})}),t.jsx(Zs,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Hs,{children:[t.jsx(Ll,{size:14})," Invitations"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.custom_workspace_role_enabled)&&t.jsx(Zs,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Hs,{children:[t.jsx(Xt,{size:14})," Roles"]})})]})}),t.jsxs(_m,{children:[i==="general"&&t.jsx(Em,{}),i==="members"&&t.jsx(Mm,{}),i==="invitations"&&t.jsx($m,{}),i==="roles"&&t.jsx(Zm,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Fa,{size:14}):t.jsx(Ye,{size:14})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},Or=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{className:"w-dialog--panel",children:[r&&t.jsx(Ue.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(r0,{}),l&&t.jsx(Ue.Footer,{children:l})]})})}),i0=["organization:admin"],o0=["organization:admin","organization:manage"],l0=["workspace:admin"],c0=["workspace:admin","workspace:manage"];function Zr(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Hr(e){return Zr(e,o0)}function Tm(e){return Zr(e,i0)}function Fr(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Tr(e){return Fr(e,c0)}function Im(e){return Fr(e,l0)}const d0=({showPersonal:e=!0})=>{var Re,ce,B;const[a,s]=o.useState(!1),[r,i]=o.useState(!1),[l,m]=o.useState(new Set),c=o.useRef(null),d=o.useRef(null),p=bt({triggerRef:c,isOpen:a,minWidth:300}),u=Kt(!1),f=Kt(!1),h=Kt(!1),g=Kt(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),v=ts(),{organizationMemberships:k,loading:N,refetch:_}=xa(),{activeOrganization:C,activeMembership:y,leave:E}=ga(),{activeWorkspace:A,activeMembership:H,leave:M}=Dt(),{workspaces:T,loading:P}=va(),{session:S,switchOrganization:$,switchWorkspace:Z}=ot(),{deployment:R}=Ce(),L=R==null?void 0:R.b2b_settings.organizations_enabled,O=L&&(R==null?void 0:R.b2b_settings.workspaces_enabled),F=R==null?void 0:R.b2b_settings.allow_users_to_create_orgs,W=!y,U=o.useMemo(()=>{var X,oe;return W?{name:"Personal account",image_url:(oe=(X=S==null?void 0:S.active_signin)==null?void 0:X.user)==null?void 0:oe.profile_picture_url,isPersonal:!0}:{name:O&&A?`${C==null?void 0:C.name} / ${A.name}`:(C==null?void 0:C.name)||"",image_url:C==null?void 0:C.image_url,isPersonal:!1}},[W,C,A,S,O]);if(o.useEffect(()=>{C&&O&&m(q=>{if(q.has(C.id))return q;const X=new Set(q);return X.add(C.id),X})},[C,O]),o.useEffect(()=>{if(!a)return;let q=null;const X=setTimeout(()=>{const oe=Ee=>{var D,we;const z=Ee.target;(D=c.current)!=null&&D.contains(z)||(we=d.current)!=null&&we.contains(z)||(s(!1),j(null))};document.addEventListener("mousedown",oe),q=()=>document.removeEventListener("mousedown",oe)},50);return()=>{clearTimeout(X),q==null||q()}},[a]),o.useEffect(()=>{if(!b)return;const q=setTimeout(()=>j(null),5e3);return()=>clearTimeout(q)},[b]),!L)return null;const V=q=>q.split(" ").map(X=>X[0]).join("").toUpperCase().slice(0,2),G=q=>{i(!0),$(q).finally(()=>i(!1))},Y=q=>{i(!0),Z(q).finally(()=>i(!1))},de=q=>{m(X=>{const oe=new Set(X);return oe.has(q)?oe.delete(q):oe.add(q),oe})},fe=()=>{f.open(),s(!1)},ne=()=>{g.open(),s(!1)},ae=async()=>{if(E){j(null);try{await E(),await _(),s(!1)}catch(q){j(q instanceof Error?q.message:"Failed to leave organization")}}},re=async()=>{if(M){j(null);try{await M(),s(!1)}catch(q){j(q instanceof Error?q.message:"Failed to leave workspace")}}},Le=!!((Re=y==null?void 0:y.eligibility_restriction)!=null&&Re.type)&&y.eligibility_restriction.type!=="none",K=!!C&&!Le&&Hr(y),at=!!O&&!!A&&!Le&&Tr(H);return!!!S||N||O&&P?t.jsx($e,{children:t.jsx("div",{className:"w-full w-relative",children:t.jsxs("div",{className:"w-combo",children:[t.jsx("span",{className:"w-skel",style:{width:20,height:20}}),t.jsx("span",{className:"w-skel w-grow",style:{height:12}})]})})}):t.jsx($e,{children:t.jsxs("div",{className:"w-full w-relative",children:[t.jsxs("button",{ref:c,className:"w-orgtrigger","data-open":a?"":void 0,onClick:()=>{s(!a),a||j(null)},disabled:r,children:[t.jsx("span",{className:`w-avatar w-avatar--sm${U.isPersonal,""}`,children:U.image_url?t.jsx("img",{src:U.image_url,alt:U.name}):U.isPersonal?t.jsx(hs,{size:11}):V(U.name)}),t.jsx("span",{className:"w-grow w-truncate",children:U.name}),t.jsx(Au,{size:13})]}),typeof window<"u"&&en.createPortal(t.jsxs("div",{ref:d,className:"wacht-root w-menu w-flex-col",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 16px)",maxHeight:p!=null&&p.maxHeight?`${p.maxHeight}px`:420,padding:0,zIndex:99999,top:(p==null?void 0:p.top)!==void 0?`${p.top}px`:void 0,bottom:(p==null?void 0:p.bottom)!==void 0?`${p.bottom}px`:void 0,left:(p==null?void 0:p.left)!==void 0?`${p.left}px`:void 0,right:(p==null?void 0:p.right)!==void 0?`${p.right}px`:void 0,visibility:p&&a?"visible":"hidden",opacity:a&&p?1:0,transform:a?"translateY(0)":"translateY(-4px)",pointerEvents:a?"auto":"none",transition:`opacity 0.15s ease, transform 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,...v},children:[b&&t.jsxs("div",{className:"w-banner w-banner--error w-switch-banner",children:[t.jsx(Ma,{size:13}),t.jsx("span",{className:"w-banner-txt w-text-error",children:b})]}),t.jsx("div",{className:"w-grow w-switch-body",children:N||P?t.jsx(t.Fragment,{children:[1,2,3].map(q=>t.jsxs("div",{className:"w-flex w-items-center w-gap-3",style:{padding:"0 8px",height:34},children:[t.jsx("span",{className:"w-skel",style:{width:22,height:22}}),t.jsx("span",{className:"w-skel",style:{width:q===2?"60%":"80%",height:11}})]},q))}):t.jsxs(t.Fragment,{children:[e&&t.jsxs("button",{className:"w-menu-item",onClick:()=>{W||G()},disabled:r||W,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:(B=(ce=S==null?void 0:S.active_signin)==null?void 0:ce.user)!=null&&B.profile_picture_url?t.jsx("img",{src:S.active_signin.user.profile_picture_url,alt:"Personal"}):t.jsx(hs,{size:12})}),t.jsx("span",{className:"w-grow w-truncate",children:"Personal account"}),W&&t.jsx(Ye,{size:13,className:"w-text-primary w-none"})]}),((k==null?void 0:k.length)??0)>0&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsx("div",{className:"w-menu-label",children:"Organizations"})]}),k==null?void 0:k.map(q=>{var we,ge;const X=q.organization,oe=X.id===(C==null?void 0:C.id),Ee=l.has(X.id),z=O?(T==null?void 0:T.filter(xe=>xe.organization.id===X.id))||[]:[],D=!!((we=q.eligibility_restriction)!=null&&we.type)&&q.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{D||(O?de(X.id):oe||G(X.id))},disabled:r,style:D?{opacity:.55,cursor:"not-allowed"}:void 0,title:(ge=q.eligibility_restriction)==null?void 0:ge.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:X.image_url?t.jsx("img",{src:X.image_url,alt:X.name}):V(X.name)}),t.jsx("span",{className:"w-grow w-truncate",children:X.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[D&&t.jsx(Ma,{size:12,className:"w-text-error"}),oe&&K&&t.jsx("span",{className:"w-rowact",role:"button",title:"Organization settings","aria-label":"Organization settings",onClick:xe=>{xe.stopPropagation(),fe()},children:t.jsx(Ea,{size:13})}),oe&&!D&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave organization","aria-label":"Leave organization",onClick:xe=>{xe.stopPropagation(),ae()},children:t.jsx(Aa,{size:13})}),oe&&!O&&t.jsx(Ye,{size:13,className:"w-text-primary"}),O&&t.jsx(Ut,{size:11,className:"w-text-muted",style:{transition:"transform 0.2s ease",transform:Ee?"rotate(0deg)":"rotate(-90deg)"}})]})]}),O&&Ee&&!D&&t.jsxs("div",{className:"w-switch-nest",children:[z.map(xe=>{var Q,le;const lt=oe&&(A==null?void 0:A.id)===xe.id,Qe=((Q=xe.eligibility_restriction)==null?void 0:Q.type)&&xe.eligibility_restriction.type!=="none";return t.jsxs("button",{className:"w-menu-item",onClick:()=>{!lt&&!Qe&&Y(xe.id)},disabled:r,style:Qe?{opacity:.55,cursor:"not-allowed"}:void 0,title:(le=xe.eligibility_restriction)==null?void 0:le.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:xe.image_url?t.jsx("img",{src:xe.image_url,alt:xe.name}):V(xe.name).charAt(0)}),t.jsx("span",{className:"w-grow w-truncate",children:xe.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[Qe&&t.jsx(Ma,{size:12,className:"w-text-error"}),lt&&at&&t.jsx("span",{className:"w-rowact",role:"button",title:"Workspace settings","aria-label":"Workspace settings",onClick:me=>{me.stopPropagation(),ne()},children:t.jsx(Ea,{size:13})}),lt&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave workspace","aria-label":"Leave workspace",onClick:me=>{me.stopPropagation(),re()},children:t.jsx(Aa,{size:13})}),lt&&t.jsx(Ye,{size:12,className:"w-text-primary"})]})]},xe.id)}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>{w(X.id),h.open()},disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New workspace"})]})]})]},X.id)}),F&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>u.open(),disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New organization"})]})]})]})})]}),document.body),L&&F&&t.jsx(Jc,{isOpen:u.isOpen,onClose:u.close,onCreated:_}),t.jsx(s0,{isOpen:f.isOpen,onClose:f.close}),O&&t.jsxs(t.Fragment,{children:[t.jsx(Or,{isOpen:g.isOpen,onClose:g.close}),t.jsx(Pr,{isOpen:h.isOpen,onClose:()=>{h.close(),w(null)},organizationId:x||void 0})]})]})})},u0=o.createContext(void 0),ta=()=>{const e=o.useContext(u0);if(!e)throw new Error("useScreenContext must be used within a ScreenProvider");return e},he=(...e)=>e.filter(Boolean).join(" "),m0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-contents",e),...a}));m0.displayName="TypographyProvider";const mr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card","w-flex-col","w-full","w-minh-full",e),...a}));mr.displayName="Container";const p0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-tabsbar",e),...a}));p0.displayName="TabsContainer";const h0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}));h0.displayName="TabsList";const ka=o.forwardRef(({$isActive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:he("w-tab",e&&"w-tab--active",a),...s}));ka.displayName="Tab";const Ca=o.forwardRef(({className:e,...a},s)=>t.jsx("span",{ref:s,className:he("w-inline","w-gap-1",e),...a}));Ca.displayName="TabIcon";const f0=o.forwardRef(({className:e,children:a,...s},r)=>t.jsx("div",{ref:r,className:he("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}));f0.displayName="TabContent";const Vm=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:he("w-btn","w-btn--icon",e),...a}));Vm.displayName="IconButton";const w0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-justify-between","w-wrap","w-gap-3",e),...a}));w0.displayName="HeaderCTAContainer";const zm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-start","w-gap-6",e),...a}));zm.displayName="ProfileSectionLayout";const Dm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-none",e),...a}));Dm.displayName="ProfileImageContainer";const g0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-vrow",e),...a}));g0.displayName="SecurityItemRow";const x0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-grow",e),...a}));x0.displayName="SecurityItemContent";const v0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-2","w-none",e),...a}));v0.displayName="SecurityItemActions";const Ir=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-sechead",e),...a}));Ir.displayName="ResponsiveHeaderContainer";const hn=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-full",e),...a}));hn.displayName="DesktopTableContainer";const b0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-gap-3",e),...a}));b0.displayName="FormRow";const Um=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-vrow",e),...a}));Um.displayName="ConnectionItemRow";const Wm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-2","w-grow",e),...a}));Wm.displayName="ConnectionLeft";const Bm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-justify-end","w-gap-1","w-none",e),...a}));Bm.displayName="ConnectionRight";const Vr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-iconbox",e),...a}));Vr.displayName="IconWrapper";const Gm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-wrap","w-gap-2",e),...a}));Gm.displayName="ButtonActions";const y0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-page-head",e),...a}));y0.displayName="PageHeader";const qm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-avatar",e),...a}));qm.displayName="PageHeaderAvatar";const j0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-1","w-grow",e),...a}));j0.displayName="PageHeaderInfo";const _0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-sec","w-truncate",e),...a}));_0.displayName="PageHeaderName";const k0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-secsub","w-truncate",e),...a}));k0.displayName="PageHeaderSub";const Km=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-1","w-none",e),...a}));Km.displayName="PageHeaderActions";const Ym=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-4",e),...a}));Ym.displayName="PageContent";const Qm=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:he("w-card",e),...a}));Qm.displayName="Card";const Jm=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:he("w-card","w-danger",e),...a}));Jm.displayName="DangerCard";const Xm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card-head",e),...a}));Xm.displayName="CardHeader";const e6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-1","w-grow",e),...a}));e6.displayName="CardTitleBlock";const t6=o.forwardRef(({className:e,...a},s)=>t.jsx("h3",{ref:s,className:he("w-sec",e),...a}));t6.displayName="CardTitle";const a6=o.forwardRef(({className:e,...a},s)=>t.jsx("p",{ref:s,className:he("w-secsub",e),...a}));a6.displayName="CardSubtitle";const s6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));s6.displayName="CardActions";const n6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-hr",e),...a}));n6.displayName="CardDivider";const r6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card-body",e),...a}));r6.displayName="CardBody";const i6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card-foot",e),...a}));i6.displayName="CardFooter";const o6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-list",e),...a}));o6.displayName="RowList";const l6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-rowitem",e),...a}));l6.displayName="RowItem";const c6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-1","w-grow",e),...a}));c6.displayName="RowInfo";const d6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-sec",e),...a}));d6.displayName="RowTitle";const u6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-secsub",e),...a}));u6.displayName="RowSub";const m6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));m6.displayName="RowActions";const p6={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},qa=({$variant:e="neutral",className:a,children:s,...r})=>t.jsxs("span",{className:he("w-pill",p6[e],a),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),h6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-list",e),...a}));h6.displayName="Table";const f6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:he("w-listhead","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));f6.displayName="TableHead";const w6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:e,...a}));w6.displayName="Th";const g6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:he("w-row","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));g6.displayName="Tr";const x6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-truncate","w-text-secondary",e),...a}));x6.displayName="Td";const v6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-grid-2",e),...a}));v6.displayName="FieldGrid";const b6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-field",e),...a}));b6.displayName="Field";const y6=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:he("w-label",e),...a}));y6.displayName="FieldLabel";const j6=()=>{var T,P;const{deployment:e}=Ce(),{refetch:a}=ot(),{user:s,updateProfile:r,deleteAccount:i}=ba(),{toast:l}=ta(),[m,c]=o.useState(""),[d,p]=o.useState(""),[u,f]=o.useState(""),[h,g]=o.useState(!1),[x,w]=o.useState(!1),[b,j]=o.useState(!1),[v,k]=o.useState("");o.useEffect(()=>{s&&!h&&(c(s.first_name||""),p(s.last_name||""),f(s.username||""),g(!0))},[s,h]);const N=o.useCallback(async()=>{if(s)try{const S={};m!==s.first_name&&(S.first_name=m),d!==s.last_name&&(S.last_name=d),u!==s.username&&(S.username=u),Object.keys(S).length>0&&await r(S)}catch(S){l(S.message||"Failed to save profile changes","error")}},[s,r,m,d,u,l]),_=S=>{c(S.target.value)},C=S=>{p(S.target.value)},y=S=>{f(S.target.value)},E=()=>{N()},A=()=>{N()},H=()=>{N()};if(!s)return t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})});const M=async()=>{if(!(!s||v!=="delete this account")){j(!0);try{await i(""),l("Account deleted successfully","info"),await a()}catch(S){l(S.message||"Failed to delete account","error")}finally{j(!1),k(""),w(!1)}}};return t.jsxs("div",{className:"w-flex-col w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx("p",{className:"w-secsub",children:"Basic information about your profile"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs(b0,{children:[t.jsxs(Ge,{className:"w-grow",children:[t.jsx(Ve,{htmlFor:"firstName",children:"First Name"}),t.jsx(ye,{id:"firstName",type:"text",value:m,onChange:_,onBlur:E,placeholder:"Enter your first name",required:!0})]}),t.jsxs(Ge,{className:"w-grow",children:[t.jsx(Ve,{htmlFor:"lastName",children:"Last Name"}),t.jsx(ye,{id:"lastName",type:"text",value:d,onChange:C,onBlur:A,placeholder:"Enter your last name",required:!0})]})]}),((P=(T=e==null?void 0:e.auth_settings)==null?void 0:T.username)==null?void 0:P.enabled)&&t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"username",children:"Username"}),t.jsx(ye,{id:"username",type:"text",value:u,onChange:y,onBlur:H,placeholder:"Enter your username",required:!0})]})]})]}),t.jsx("div",{className:"w-hr"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-sec",children:"Danger Zone"}),t.jsx("p",{className:"w-secsub",children:"Irreversible and destructive actions"})]}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-full",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete Account"}),t.jsx("div",{className:"w-secsub",children:"Once you delete your account, there is no going back. Please be certain."})]}),t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>{x?(w(!1),k("")):w(!0)},children:x?"Cancel":"Delete"})]}),x&&t.jsxs("div",{className:"w-full w-flex-col w-gap-3",children:[t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),t.jsx(ye,{id:"confirm_username",type:"text",value:v,onChange:S=>k(S.target.value),placeholder:"delete this account"})]}),t.jsx(se,{$destructive:!0,$fullWidth:!0,onClick:M,disabled:v!=="delete this account"||b,children:b?t.jsx(_e,{size:12}):"Delete Forever"})]})]})]})]})},qi=({onClose:e,onAddEmail:a,onAttemptVerification:s,onPrepareVerification:r,existingEmail:i,triggerRef:l})=>{const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=ta(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const _=y=>{m.current&&!m.current.contains(y.target)&&e()},C=y=>{y.key==="Escape"&&e()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]);const[f,h]=o.useState(i?"otp":"email"),[g,x]=o.useState(i||""),[w,b]=o.useState(""),[j,v]=o.useState(!1),k=async()=>{if(!(!g||j)){v(!0);try{await a(g),h("otp")}catch(_){p(_.message||"Failed to add email. Please try again.","error")}finally{v(!1)}}},N=async()=>{v(!0);try{await s(w),e()}catch(_){p(_.message||"Failed to verify email. Check the code and try again.","error")}finally{v(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:f==="email"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add email address"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx(ye,{id:"email-input",type:"email",placeholder:"you@company.com",value:g,onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&k()},autoFocus:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:!g||j,children:j?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!i&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("email"),children:[t.jsx(nn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify your email"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:g})]})]}),t.jsx(ya,{onComplete:async _=>b(_),onResend:r,isSubmitting:j})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:w.length<6||j,children:j?"Verifying…":"Verify"})]})]})}):null},_6=()=>{var A,H,M,T;const{deployment:e}=Ce(),{toast:a}=ta(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createEmailAddress:g,deleteEmailAddress:x,prepareEmailVerification:w,attemptEmailVerification:b,makeEmailPrimary:j}=ba();if(!((H=(A=e==null?void 0:e.auth_settings)==null?void 0:A.email_address)!=null&&H.enabled))return null;const v=(P,S)=>{p($=>{const Z=new Set($);return S?Z.add(P):Z.delete(P),Z})},k=async P=>{v(P,!0);try{await j(P),await h.refetch(),a("Primary email updated","info")}catch(S){a(S.message||"Failed to update primary email","error")}finally{v(P,!1)}},N=async P=>{if(P===(h==null?void 0:h.primary_email_address_id)){a("Cannot delete primary email. Set another email as primary first.","error");return}v(P,!0);try{await x(P),await h.refetch(),a("Email removed","info")}catch(S){a(S.message||"Failed to delete email address. Please try again.","error")}finally{v(P,!1)}},_=async P=>{v(P,!0);try{await w(P),await h.refetch(),c(P)}catch(S){a(S.message||"Failed to send verification","error")}finally{v(P,!1)}},C=(h==null?void 0:h.user_email_addresses)||[],y=P=>P.id===(h==null?void 0:h.primary_email_address_id)?t.jsx(qa,{$variant:"success",children:"Primary"}):P.verified?t.jsx(qa,{$variant:"neutral",children:"Backup"}):t.jsx(qa,{$variant:"warning",children:"Pending verification"}),E=P=>{const S=P.id===(h==null?void 0:h.primary_email_address_id),$=d.has(P.id);return S?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[P.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:$,onClick:()=>k(P.id),children:"Make primary"}),!P.verified&&t.jsx(se,{ref:Z=>{Z&&(f.current[P.id]=Z)},$size:"sm",$outline:!0,disabled:$,onClick:()=>_(P.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:$,onClick:()=>N(P.id),children:$?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(Ir,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Email addresses"}),t.jsx("div",{className:"w-secsub",children:"Sign in and receive notifications at these addresses."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add email"}),i&&t.jsx(qi,{triggerRef:u,onClose:()=>l(!1),onAddEmail:async P=>{const S=await g(P);r(S.data.id),await w(S.data.id),h.refetch()},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async P=>{await b(s,P),h.refetch(),l(!1),r(""),a("Email added and verified","info")}})]})]}),C.length?t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Email address"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:C.map(P=>t.jsxs(it,{children:[t.jsx(Xe,{children:P.email}),t.jsx(Xe,{children:y(P)}),t.jsx(Ft,{children:E(P)})]},P.id))})]})})}):t.jsx(Nt,{title:"No email addresses",description:"Add an email address to get started."}),m&&t.jsx(qi,{existingEmail:(T=(M=h==null?void 0:h.user_email_addresses)==null?void 0:M.find(P=>P.id===m))==null?void 0:T.email,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async P=>{await b(m,P),h.refetch(),c(null),a("Email verified","info")}})]})},Ki=({onClose:e,onAddPhone:a,onAttemptVerification:s,existingPhone:r,onPrepareVerification:i,triggerRef:l})=>{var y;const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=ta(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const E=H=>{m.current&&!m.current.contains(H.target)&&e()},A=H=>{H.key==="Escape"&&e()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",A)}},[e]);const[f,h]=o.useState(r?"otp":"phone"),[g,x]=o.useState((r==null?void 0:r.replace(/^\+\d+/,""))||""),[w,b]=o.useState((y=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:y.pop()),[j,v]=o.useState(""),[k,N]=o.useState(!1),_=async()=>{if(!(!g||k)){N(!0);try{await a(g,w||""),h("otp")}catch(E){p(E.message||"Failed to add phone number. Please try again.","error")}finally{N(!1)}}},C=async()=>{N(!0);try{await s(j),e()}catch(E){p(E.message||"Failed to verify phone. Check the code and try again.","error")}finally{N(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:f==="phone"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add phone number"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(ys,{value:g,onChange:E=>x(E.target.value),error:"",countryCode:w,setCountryCode:b})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!g||k,children:k?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!r&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("phone"),children:[t.jsx(nn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify phone number"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:r||g})]})]}),t.jsx(ya,{onComplete:E=>v(E),onResend:async()=>i(),isSubmitting:k})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:C,disabled:j.length!==6||k,children:k?"Verifying…":"Verify"})]})]})}):null},k6=()=>{var H,M,T,P;const{deployment:e}=Ce(),{toast:a}=ta(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createPhoneNumber:g,deletePhoneNumber:x,preparePhoneVerification:w,attemptPhoneVerification:b,makePhonePrimary:j}=ba();if(!((M=(H=e==null?void 0:e.auth_settings)==null?void 0:H.phone_number)!=null&&M.enabled))return null;const v=(S,$)=>{p(Z=>{const R=new Set(Z);return $?R.add(S):R.delete(S),R})},k=S=>{const $=Gs.find(Z=>Z.dialCode===S);return($==null?void 0:$.flag)||"🌍"},N=async S=>{v(S,!0);try{await j(S),await h.refetch(),a("Primary phone updated","info")}catch($){a($.message||"Failed to update primary phone","error")}finally{v(S,!1)}},_=async S=>{if(S===(h==null?void 0:h.primary_phone_number_id)){a("Cannot delete primary phone. Set another phone as primary first.","error");return}v(S,!0);try{await x(S),await h.refetch(),a("Phone removed","info")}catch($){a($.message||"Failed to delete phone. Please try again.","error")}finally{v(S,!1)}},C=async S=>{v(S,!0);try{await w(S),await h.refetch(),c(S)}catch($){a($.message||"Failed to send verification","error")}finally{v(S,!1)}},y=(h==null?void 0:h.user_phone_numbers)||[],E=S=>S.id===(h==null?void 0:h.primary_phone_number_id)?t.jsx(qa,{$variant:"success",children:"Primary"}):S.verified?t.jsx(qa,{$variant:"neutral",children:"Backup"}):t.jsx(qa,{$variant:"warning",children:"Pending verification"}),A=S=>{const $=S.id===(h==null?void 0:h.primary_phone_number_id),Z=d.has(S.id);return $?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[S.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:Z,onClick:()=>N(S.id),children:"Make primary"}),!S.verified&&t.jsx(se,{ref:R=>{R&&(f.current[S.id]=R)},$size:"sm",$outline:!0,disabled:Z,onClick:()=>C(S.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:Z,onClick:()=>_(S.id),children:Z?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(Ir,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Phone numbers"}),t.jsx("div",{className:"w-secsub",children:"Used for sign-in and two-factor authentication."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add phone"}),i&&t.jsx(Ki,{triggerRef:u,onClose:()=>l(!1),onAddPhone:async(S,$)=>{const Z=await g(S,$);r(Z.data.id),await w(Z.data.id)},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async S=>{await b(s,S),h.refetch(),l(!1),r(""),a("Phone added and verified","info")}}),m&&t.jsx(Ki,{existingPhone:(P=(T=h==null?void 0:h.user_phone_numbers)==null?void 0:T.find(S=>S.id===m))==null?void 0:P.phone_number,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async S=>{await b(m,S),h.refetch(),c(null),a("Phone verified","info")}})]})]}),y.length?t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Phone number"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:y.map(S=>t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("span",{className:"w-inline w-gap-2",children:[t.jsx("span",{children:k(S.country_code)}),t.jsx("span",{className:"w-text-secondary",children:S.country_code}),t.jsx("span",{children:S.phone_number})]})}),t.jsx(Xe,{children:E(S)}),t.jsx(Ft,{children:A(S)})]},S.id))})]})})}):t.jsx(Nt,{title:"No phone numbers",description:"Add a phone number to get started."})]})},C6=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),t.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),t.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),t.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),N6={google_oauth:{icon:t.jsx(Nc,{}),label:"Google"},microsoft_oauth:{icon:t.jsx(C6,{}),label:"Microsoft"},github_oauth:{icon:t.jsx(Cc,{}),label:"GitHub"},gitlab_oauth:{icon:t.jsx(Ac,{}),label:"GitLab"},linkedin_oauth:{icon:t.jsx(Ec,{}),label:"LinkedIn"},discord_oauth:{icon:t.jsx(Mc,{}),label:"Discord"},x_oauth:{icon:t.jsx(Sc,{}),label:"X"}},S6=()=>{const{user:e,disconnectSocialConnection:a,connectSocialAccount:s}=ba(),{deployment:r}=Ce(),i=(r==null?void 0:r.social_connections.filter(c=>c.enabled))||[],l=c=>{s({provider:c,redirectUri:window.location.href})},m=async c=>{await a(c.toString()),e.refetch()};return i.length===0?t.jsx(Nt,{title:"No providers available",description:"Social sign-in providers have not been configured for this app."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-gap-3",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Connected accounts"}),t.jsx("div",{className:"w-secsub",children:"Sign in faster by linking third-party accounts."})]})}),t.jsx("div",{className:"w-list",children:i.map(c=>{var f;const d=N6[c.provider];if(!d)return null;const p=((f=e==null?void 0:e.social_connections)==null?void 0:f.filter(h=>h.provider===c.provider))||[],u=p.length>0;return t.jsxs("div",{className:"w-vrow",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx(Vr,{children:d.icon}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-grow",children:[t.jsx("div",{className:"w-sec",children:d.label}),u?t.jsx("div",{className:"w-flex w-wrap w-gap-1",children:p.map(h=>t.jsxs("span",{className:"w-chip",children:[t.jsx("span",{className:"w-truncate",children:h.email_address}),t.jsx("span",{className:"w-chip-x",role:"button",onClick:()=>m(h.id),title:"Remove connection","aria-label":"Remove connection",children:t.jsx(La,{size:10,weight:"bold"})})]},h.id))}):t.jsx("span",{className:"w-secsub",children:"Not linked"})]})]}),t.jsx("div",{className:`w-flex w-justify-end w-none${u?" w-row-act-top":""}`,children:t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>l(c.provider),children:u?"Link another":"Link"})})]},c.provider)})})]})};var E6=Object.defineProperty,Xs=Object.getOwnPropertySymbols,C0=Object.prototype.hasOwnProperty,N0=Object.prototype.propertyIsEnumerable,Yi=(e,a,s)=>a in e?E6(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s,pr=(e,a)=>{for(var s in a||(a={}))C0.call(a,s)&&Yi(e,s,a[s]);if(Xs)for(var s of Xs(a))N0.call(a,s)&&Yi(e,s,a[s]);return e},hr=(e,a)=>{var s={};for(var r in e)C0.call(e,r)&&a.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&Xs)for(var r of Xs(e))a.indexOf(r)<0&&N0.call(e,r)&&(s[r]=e[r]);return s};/**
108
+ 10.0.0.0/24`,className:"w-input--area w-mono-sm"})]})]})]}),t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsx(Bi,{children:"Danger zone"}),t.jsxs("div",{className:"w-danger",children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Delete workspace"}),t.jsx("div",{className:"w-secsub",children:"Once you delete this workspace, there is no going back."})]}),t.jsx(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{k(!v),w("")},children:v?"Cancel":"Delete workspace"})]}),v&&t.jsxs("div",{className:"w-flex-col w-gap-3",children:[t.jsxs(Ge,{children:[t.jsxs(Ve,{htmlFor:"confirm_workspace_name",children:["Type ",t.jsx("strong",{children:e.name})," to confirm"]}),t.jsx(ye,{id:"confirm_workspace_name",type:"text",value:x,onChange:H=>w(H.target.value),placeholder:e.name})]}),t.jsx(se,{$size:"sm",$destructive:!0,onClick:_,disabled:x!==e.name||b,children:b?t.jsx(_e,{size:12}):"Delete forever"})]})]})]})},Mm=({onClose:e,onSuccess:a,roles:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState(""),[c,d]=o.useState(null),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{toast:g}=Ct(),{inviteMember:x}=Dt(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name}));o.useEffect(()=>{h(!0);const k=C=>{i.current&&!i.current.contains(C.target)&&(e==null||e())},N=C=>{C.key==="Escape"&&(e==null||e())},_=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",N)},100);return()=>{clearTimeout(_),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]);const j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=l.trim().toLowerCase();if(!(!k||!c)){if(!j(k)){g("Please enter a valid email address","error");return}if(k.length>320){g("Email address is too long","error");return}u(!0);try{await x({email:k,workspaceRoleId:c.id}),a==null||a()}catch(N){const _=N.message||"Failed to send invitation. Please try again.";g(_,"error")}finally{u(!1)}}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,maxHeight:w!=null&&w.maxHeight?`${w.maxHeight}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"invite-workspace-member-title",children:"Invite member"}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Email Address"}),t.jsx(ye,{type:"email",placeholder:"colleague@company.com",value:l,onChange:k=>m(k.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{children:"Role"}),t.jsx(un,{options:b,value:c==null?void 0:c.id,onChange:k=>d(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:v,disabled:!l||!c||p,children:p?t.jsx(_e,{size:14}):"Send invite"})]})]}):null},Rm=()=>{const{activeWorkspace:e,getMembers:a,getRoles:s,removeMember:r,addMemberRole:i,removeMemberRole:l}=Dt(),{session:m}=ot(),{toast:c}=Ct(),[d,p]=o.useState(""),[u,f]=o.useState(1),[h]=o.useState(10),[g,x]=o.useState(""),[w,b]=o.useState(!1),j=o.useRef(null);o.useEffect(()=>{const M=setTimeout(()=>{x(d),f(1)},500);return()=>clearTimeout(M)},[d]);const{data:v,mutate:k}=Se(e?`wacht-api-workspaces:${e.id}:members:${u}:${h}:${g}`:null,()=>a==null?void 0:a({page:u,limit:h,search:g}),{keepPreviousData:!0}),N=(v==null?void 0:v.data)||[],_=(v==null?void 0:v.meta)||{total:0,limit:10},C=Math.ceil(_.total/(_.limit||10)),{data:y=[]}=Se(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),E=y,A=async(M,T,P)=>{try{P?(await l(M,T),c("Role removed","info")):(await i(M,T),c("Role added","info")),k()}catch{c("Failed to update role","error")}},H=async M=>{try{await r(M),c("Member removed","info"),k()}catch{c("Failed to remove member","error")}};return v?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-toolbar",children:[t.jsx(Gc,{value:d,onChange:p,placeholder:"Search members..."}),t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[_.total>0&&t.jsxs("div",{className:"w-text-muted w-secsub",children:[_.total," member",_.total!==1?"s":""]}),t.jsx(se,{ref:j,onClick:()=>b(!0),$size:"sm",children:"Invite"})]})]}),w&&t.jsx(Mm,{onClose:()=>b(!1),onSuccess:()=>{k(),b(!1)},roles:E,triggerRef:j}),N.length===0?t.jsx(Nt,{title:d?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):t.jsx(t.Fragment,{children:t.jsx($r,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Member"}),t.jsx(Fe,{children:"Joined"}),t.jsx(Fe,{children:"Role"})]})}),t.jsx(Ht,{children:N.map(M=>t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsx(Lm,{member:M,session:m})}),t.jsx(Xe,{children:new Date(M.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsx(Pm,{member:M,roles:E,onToggle:(T,P)=>A(M.id,T,P),onRemove:()=>H(M.id)})})]},M.id))})]})})}),C>1&&t.jsxs("div",{className:"w-flex w-items-center w-justify-center w-gap-4",children:[t.jsx(se,{onClick:()=>f(M=>Math.max(1,M-1)),disabled:u===1,$size:"sm",children:"Previous"}),t.jsxs("span",{className:"w-secsub",children:[u," / ",C]}),t.jsx(se,{onClick:()=>f(M=>Math.min(C,M+1)),disabled:u===C,$size:"sm",children:"Next"})]})]}):t.jsx(_e,{})},Lm=({member:e,session:a,subtitle:s})=>{var m,c,d;const r=e.public_user_data||e.user,i=(r==null?void 0:r.id)===((m=a==null?void 0:a.active_signin)==null?void 0:m.user_id),l=(p="",u="")=>`${p[0]||""}${u[0]||""} `.toUpperCase();return t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx("div",{className:"w-avatar",children:r!=null&&r.profile_picture_url?t.jsx("img",{src:r.profile_picture_url,alt:"Avatar"}):l(r==null?void 0:r.first_name,r==null?void 0:r.last_name)||"?"}),t.jsxs("div",{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx("span",{className:"w-sec",children:r?`${r.first_name||""} ${r.last_name||""} `.trim()||((c=r.primary_email_address)==null?void 0:c.email):"Unknown"}),i&&t.jsx("span",{className:"w-pill",children:"You"})]}),t.jsxs("div",{className:"w-flex w-wrap w-gap-2 w-secsub",children:[t.jsx("span",{children:(d=r==null?void 0:r.primary_email_address)==null?void 0:d.email}),s&&t.jsxs("span",{className:"w-text-muted",children:["• ",s]})]})]})]})},Pm=({member:e,roles:a,onToggle:s,onRemove:r})=>{var m;const i=e.roles||[],l=c=>i.some(d=>d.id===c);return t.jsxs(_s,{children:[t.jsx(Cs,{children:t.jsxs(se,{$outline:!0,$size:"sm",className:"w-justify-between w-rolepick-btn",children:[i.length>0?(m=i==null?void 0:i[0])==null?void 0:m.name:"No role"," ",t.jsx(Ut,{size:14})]})}),t.jsxs(ks,{children:[a.map(c=>{const d=l(c.id);return t.jsx(ea,{onClick:()=>s(c.id,d),children:t.jsxs("div",{className:"w-flex w-justify-between w-full w-gap-3",children:[t.jsx("span",{children:c.name}),d&&t.jsx(Ye,{size:14,className:"w-text-success"})]})},c.id)}),t.jsx(Wc,{}),t.jsx(ea,{$destructive:!0,onClick:r,children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsx(xr,{size:14})," Remove Member"]})})]})]})},$m=({onClose:e,onSuccess:a,roles:s,createInvitation:r,triggerRef:i})=>{const l=o.useRef(null),[m,c]=o.useState(""),[d,p]=o.useState(s[0]||null),[u,f]=o.useState(!1),[h,g]=o.useState(!1),{toast:x}=Ct(),w=bt({contentRef:l,triggerRef:i,isOpen:h,minWidth:360,defaultMaxHeight:320}),b=s.map(k=>({value:k.id,label:k.name})),j=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),v=async()=>{const k=m.trim().toLowerCase();if(!(!k||!d)){if(!j(k)){x("Please enter a valid email address","error");return}if(k.length>320){x("Email address is too long","error");return}f(!0);try{await r({email:k,role_id:d.id}),a()}catch(N){x(N.message||"Failed to send invitation. Please try again.","error")}finally{f(!1)}}};return o.useEffect(()=>{g(!0);const k=_=>{l.current&&!l.current.contains(_.target)&&(e==null||e())},N=_=>{_.key==="Escape"&&(e==null||e())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",N)}},[e]),h?t.jsxs("div",{ref:l,className:"w-pop w-pop--wide w-pop-body",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[t.jsx("div",{className:"w-pop-title",id:"invite-member-title",children:"Invite member"}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Email"}),t.jsx(ye,{type:"email",placeholder:"colleague@company.com",value:m,onChange:k=>c(k.target.value),onKeyDown:k=>{k.key==="Enter"&&m&&d&&v()},autoFocus:!0,"aria-label":"Email address for invitation"})]}),t.jsxs("div",{className:"w-field",children:[t.jsx("label",{className:"w-label",children:"Role"}),t.jsx(un,{options:b,value:d==null?void 0:d.id,onChange:k=>p(s.find(N=>N.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(se,{$size:"sm",$outline:!0,$fullWidth:!0,onClick:e,children:"Cancel"}),t.jsx(se,{$size:"sm",$fullWidth:!0,onClick:v,disabled:!m||!d||u,children:u?t.jsx(_e,{size:12}):"Send invite"})]})]}):null},Om=()=>{const{activeWorkspace:e,loading:a,getRoles:s,getInvitations:r,inviteMember:i,discardInvitation:l,resendInvitation:m}=Dt(),{toast:c}=Ct(),[d,p]=o.useState(!0),[u,f]=o.useState(!0),[h,g]=o.useState([]),[x,w]=o.useState([]),[b,j]=o.useState(!1),v=o.useRef(null),k=async()=>{if(e){p(!0),f(!0);try{const[C,y]=await Promise.all([s(),r()]);w(C),g(y)}catch{}finally{p(!1),f(!1)}}};o.useEffect(()=>{k()},[e==null?void 0:e.id]);const N=async C=>{try{await l(C),k(),c("Invitation cancelled","info")}catch{c("Failed to cancel invitation","error")}},_=async C=>{try{await m(C),k(),c("Invitation resent","info")}catch{c("Failed to resend invitation","error")}};return a||d||u?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(n0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Invitations"}),t.jsx("div",{className:"w-secsub",children:"Pending invites to join this workspace."})]}),t.jsx(se,{ref:v,onClick:()=>j(!0),$size:"sm",children:"Invite"})]}),b&&t.jsx($m,{onClose:()=>j(!1),onSuccess:()=>{k(),j(!1),c("Invitation sent","info")},roles:x,createInvitation:C=>i({email:C.email,workspaceRoleId:C.role_id}),triggerRef:v}),h.length===0?t.jsx(Nt,{title:"No pending invitations",description:"Invite members to your workspace."}):t.jsx(t.Fragment,{children:t.jsx($r,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Email"}),t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Invited"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:h.map(C=>{var y,E;return t.jsxs(it,{children:[t.jsx(Xe,{children:C.email}),t.jsx(Xe,{children:((y=C.initial_workspace_role)==null?void 0:y.name)||((E=C.initial_organization_role)==null?void 0:E.name)||"No role"}),t.jsx(Xe,{children:new Date(C.created_at).toLocaleDateString()}),t.jsx(Ft,{children:t.jsx(Zm,{onResend:()=>_(C.id),onCancel:()=>N(C.id)})})]},C.id)})})]})})})]})},Zm=({onResend:e,onCancel:a})=>t.jsxs(_s,{children:[t.jsx(Cs,{children:t.jsx(Js,{children:"•••"})}),t.jsxs(ks,{children:[t.jsxs(ea,{onClick:e,children:[t.jsx(Ll,{size:16})," Resend"]}),t.jsxs(ea,{$destructive:!0,onClick:a,children:[t.jsx(xr,{size:16})," Cancel"]})]})]}),Gi=({onClose:e,onSuccess:a,role:s,triggerRef:r})=>{var C,y;const i=o.useRef(null),[l,m]=o.useState((s==null?void 0:s.name)||""),[c,d]=o.useState((s==null?void 0:s.permissions)||[]),[p,u]=o.useState(!1),[f,h]=o.useState(!1),{deployment:g}=Ce(),{toast:x}=Ct(),w=bt({contentRef:i,triggerRef:r??{current:null},isOpen:f,minWidth:400,defaultMaxHeight:500}),b=!!s,j=((C=g==null?void 0:g.b2b_settings)==null?void 0:C.workspace_permissions)||((y=g==null?void 0:g.b2b_settings)==null?void 0:y.organization_permissions)||[],v=Array.isArray(j)?j.map(E=>({value:E,label:E})):[];o.useEffect(()=>{h(!0);const E=M=>{i.current&&!i.current.contains(M.target)&&(e==null||e())},A=M=>{M.key==="Escape"&&(e==null||e())},H=setTimeout(()=>{document.addEventListener("mousedown",E),document.addEventListener("keydown",A)},100);return()=>{clearTimeout(H),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",A)}},[e]);const k=E=>E.trim().replace(/[<>"'&]/g,""),N=E=>E.length>=2&&E.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(E),_=async()=>{const E=k(l);if(!E){x("Please enter a role name","error");return}if(!N(E)){x("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(c.length===0){x("Please select at least one permission","error");return}u(!0);try{const A={id:s==null?void 0:s.id,name:E,permissions:c};a==null||a(A)}catch(A){x(A.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{u(!1)}};return f?t.jsxs("div",{ref:i,className:"w-pop w-pop--wide",style:{position:"fixed",zIndex:1001,top:(w==null?void 0:w.top)!==void 0?`${w.top}px`:void 0,bottom:(w==null?void 0:w.bottom)!==void 0?`${w.bottom}px`:void 0,left:(w==null?void 0:w.left)!==void 0?`${w.left}px`:void 0,right:(w==null?void 0:w.right)!==void 0?`${w.right}px`:void 0,visibility:w?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Name"}),t.jsx(ye,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:l,onChange:E=>m(E.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Permissions"}),t.jsx(Yc,{options:v,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!l||p,children:p?t.jsx(_e,{size:12}):b?"Update":"Create"})]})]}):null},Hm=()=>{var N;const{activeWorkspace:e,loading:a,getRoles:s,createRole:r,deleteRole:i}=Dt(),{deployment:l}=Ce(),{toast:m}=Ct(),[c,d]=o.useState({isOpen:!1}),[p,u]=o.useState(null),[f,h]=o.useState(null),g=o.useRef(null),x=o.useRef(new Map),{data:w=[],isLoading:b,mutate:j}=Se(e?`wacht-api-workspaces:${e.id}:roles`:null,()=>s()||[]),v=async _=>{try{await r(_.name,_.permissions||[]),m("Role saved successfully","info"),d({isOpen:!1}),j()}catch{m("Failed to save role","error")}},k=async _=>{try{await i(_),m("Role deleted","info"),u(null),j()}catch{m("Failed to delete role","error")}};return a||b?t.jsx(_e,{}):t.jsxs(t.Fragment,{children:[t.jsxs(n0,{children:[t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec",children:"Roles"}),t.jsx("div",{className:"w-secsub",children:"Define granular permissions for this workspace."})]}),((N=l==null?void 0:l.b2b_settings)==null?void 0:N.custom_workspace_role_enabled)&&t.jsx(se,{ref:g,onClick:()=>d({isOpen:!0,triggerElement:g.current}),$size:"sm",children:"Add role"})]}),c.isOpen&&!c.role&&t.jsx(Gi,{triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v}),w.length===0?t.jsx(Nt,{title:"No roles yet",description:"Create workspace-specific roles to manage access."}):t.jsx(t.Fragment,{children:t.jsx($r,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Role"}),t.jsx(Fe,{children:"Permissions"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:w.map(_=>{var C;return t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-2 w-wrap",children:[t.jsx("span",{className:"w-sec",children:_.name}),!ur(_)&&t.jsx("span",{className:"w-pill",children:"Default"})]})}),t.jsx(Xe,{children:t.jsxs("span",{className:"w-text-secondary",children:[(C=_.permissions)==null?void 0:C.join(", "),!ur(_)&&" • Cannot be edited or deleted"]})}),t.jsx(Ft,{children:t.jsx(Fm,{role:_,onEdit:y=>d({isOpen:!0,role:_,triggerElement:y}),onDelete:()=>u(_.id),open:f===_.id,onOpenChange:y=>h(y?_.id:null),dropdownButtonRefs:x})})]},_.id)})})]})})}),p&&t.jsx(Qa,{title:"Delete role?",description:"Are you sure? This will remove the role from all workspace members.",onConfirm:()=>{const _=w.find(C=>C.id===p);_&&k(_)},onCancel:()=>u(null)}),c.isOpen&&c.role&&t.jsx(Gi,{role:c.role,triggerRef:{current:c.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:v})]})},Fm=({role:e,onEdit:a,onDelete:s,open:r,onOpenChange:i,dropdownButtonRefs:l})=>ur(e)?t.jsxs(_s,{open:r,openChange:i,children:[t.jsx(Cs,{children:t.jsx(Js,{ref:c=>{c&&l.current.set(e.id,c)},children:"•••"})}),t.jsxs(ks,{children:[t.jsx(ea,{onClick:()=>a(l.current.get(e.id)??null),children:"Edit Role"}),t.jsxs(ea,{$destructive:!0,onClick:s,children:[t.jsx(xr,{size:16})," Remove Role"]})]})]}):t.jsx(Js,{disabled:!0,title:"Deployment roles cannot be edited","aria-label":"Deployment roles cannot be edited",children:"•••"}),Tm=e=>(e||"").slice(0,2).toUpperCase()||"W",r0=()=>{var b,j;const{activeWorkspace:e,loading:a,updateWorkspace:s}=Dt(),{deployment:r}=Ce(),[i,l]=o.useState("general"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((v,k="info")=>{c(v),p(k),setTimeout(()=>c(null),3e3)},[]),x=async v=>{var N;const k=(N=v.target.files)==null?void 0:N[0];if(k){if(k.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!k.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s({image:k}),g("Logo updated","info")}catch(_){g((_==null?void 0:_.message)||"Failed to update logo","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(a&&!e)return t.jsx($e,{children:t.jsx(zi,{className:"w-items-center w-justify-center",children:t.jsx(_e,{})})});if(!e)return null;const w=(b=e.organization)==null?void 0:b.name;return t.jsx($e,{children:t.jsx(ym,{children:t.jsx(Er.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(zi,{className:"w-relative",children:[t.jsxs(Cm,{children:[t.jsxs("button",{type:"button",className:"w-avatar w-avatar--lg w-avatar-edit",onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},disabled:u,"data-busy":u?"":void 0,title:"Change logo","aria-label":"Change workspace logo",children:[e.image_url?t.jsx("img",{src:e.image_url,alt:e.name}):Tm(e.name),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(sn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",className:"w-none",hidden:!0,onChange:x}),t.jsxs(Nm,{children:[t.jsx(Sm,{children:e.name}),t.jsx(Em,{children:w?`${w} · Workspace settings`:"Workspace settings"})]})]}),t.jsx(jm,{children:t.jsxs(_m,{children:[t.jsx(Zs,{$isActive:i==="general",onClick:()=>l("general"),children:t.jsxs(Hs,{children:[t.jsx(Ea,{size:14})," General"]})}),t.jsx(Zs,{$isActive:i==="members",onClick:()=>l("members"),children:t.jsxs(Hs,{children:[t.jsx(cs,{size:14})," Members"]})}),t.jsx(Zs,{$isActive:i==="invitations",onClick:()=>l("invitations"),children:t.jsxs(Hs,{children:[t.jsx(Ll,{size:14})," Invitations"]})}),((j=r==null?void 0:r.b2b_settings)==null?void 0:j.custom_workspace_role_enabled)&&t.jsx(Zs,{$isActive:i==="roles",onClick:()=>l("roles"),children:t.jsxs(Hs,{children:[t.jsx(Xt,{size:14})," Roles"]})})]})}),t.jsxs(km,{children:[i==="general"&&t.jsx(Am,{}),i==="members"&&t.jsx(Rm,{}),i==="invitations"&&t.jsx(Om,{}),i==="roles"&&t.jsx(Hm,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Fa,{size:14}):t.jsx(Ye,{size:14})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},Or=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{className:"w-dialog--panel",children:[r&&t.jsx(Ue.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(r0,{}),l&&t.jsx(Ue.Footer,{children:l})]})})}),i0=["organization:admin"],o0=["organization:admin","organization:manage"],l0=["workspace:admin"],c0=["workspace:admin","workspace:manage"];function Zr(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Hr(e){return Zr(e,o0)}function Im(e){return Zr(e,i0)}function Fr(e,a){return e!=null&&e.roles?e.roles.some(s=>{var r;return(r=s.permissions)==null?void 0:r.some(i=>a.includes(i))}):!1}function Tr(e){return Fr(e,c0)}function Vm(e){return Fr(e,l0)}const d0=({showPersonal:e=!0})=>{var Re,ce,B;const[a,s]=o.useState(!1),[r,i]=o.useState(!1),[l,m]=o.useState(new Set),c=o.useRef(null),d=o.useRef(null),p=bt({triggerRef:c,isOpen:a,minWidth:300}),u=Kt(!1),f=Kt(!1),h=Kt(!1),g=Kt(!1),[x,w]=o.useState(null),[b,j]=o.useState(null),v=ts(),{organizationMemberships:k,loading:N,refetch:_}=xa(),{activeOrganization:C,activeMembership:y,leave:E}=ga(),{activeWorkspace:A,activeMembership:H,leave:M}=Dt(),{workspaces:T,loading:P}=va(),{session:S,switchOrganization:$,switchWorkspace:Z}=ot(),{deployment:R}=Ce(),L=R==null?void 0:R.b2b_settings.organizations_enabled,O=L&&(R==null?void 0:R.b2b_settings.workspaces_enabled),F=R==null?void 0:R.b2b_settings.allow_users_to_create_orgs,W=!y,U=o.useMemo(()=>{var X,oe;return W?{name:"Personal account",image_url:(oe=(X=S==null?void 0:S.active_signin)==null?void 0:X.user)==null?void 0:oe.profile_picture_url,isPersonal:!0}:{name:O&&A?`${C==null?void 0:C.name} / ${A.name}`:(C==null?void 0:C.name)||"",image_url:C==null?void 0:C.image_url,isPersonal:!1}},[W,C,A,S,O]);if(o.useEffect(()=>{C&&O&&m(q=>{if(q.has(C.id))return q;const X=new Set(q);return X.add(C.id),X})},[C,O]),o.useEffect(()=>{if(!a)return;let q=null;const X=setTimeout(()=>{const oe=Ee=>{var D,we;const z=Ee.target;(D=c.current)!=null&&D.contains(z)||(we=d.current)!=null&&we.contains(z)||(s(!1),j(null))};document.addEventListener("mousedown",oe),q=()=>document.removeEventListener("mousedown",oe)},50);return()=>{clearTimeout(X),q==null||q()}},[a]),o.useEffect(()=>{if(!b)return;const q=setTimeout(()=>j(null),5e3);return()=>clearTimeout(q)},[b]),!L)return null;const V=q=>q.split(" ").map(X=>X[0]).join("").toUpperCase().slice(0,2),G=q=>{i(!0),$(q).finally(()=>i(!1))},Y=q=>{i(!0),Z(q).finally(()=>i(!1))},de=q=>{m(X=>{const oe=new Set(X);return oe.has(q)?oe.delete(q):oe.add(q),oe})},fe=()=>{f.open(),s(!1)},ne=()=>{g.open(),s(!1)},ae=async()=>{if(E){j(null);try{await E(),await _(),s(!1)}catch(q){j(q instanceof Error?q.message:"Failed to leave organization")}}},re=async()=>{if(M){j(null);try{await M(),s(!1)}catch(q){j(q instanceof Error?q.message:"Failed to leave workspace")}}},Le=!!((Re=y==null?void 0:y.eligibility_restriction)!=null&&Re.type)&&y.eligibility_restriction.type!=="none",K=!!C&&!Le&&Hr(y),at=!!O&&!!A&&!Le&&Tr(H);return!!!S||N||O&&P?t.jsx($e,{children:t.jsx("div",{className:"w-full w-relative",children:t.jsxs("div",{className:"w-combo",children:[t.jsx("span",{className:"w-skel",style:{width:20,height:20}}),t.jsx("span",{className:"w-skel w-grow",style:{height:12}})]})})}):t.jsx($e,{children:t.jsxs("div",{className:"w-full w-relative",children:[t.jsxs("button",{ref:c,className:"w-orgtrigger","data-open":a?"":void 0,onClick:()=>{s(!a),a||j(null)},disabled:r,children:[t.jsx("span",{className:`w-avatar w-avatar--sm${U.isPersonal,""}`,children:U.image_url?t.jsx("img",{src:U.image_url,alt:U.name}):U.isPersonal?t.jsx(hs,{size:11}):V(U.name)}),t.jsx("span",{className:"w-grow w-truncate",children:U.name}),t.jsx(Au,{size:13})]}),typeof window<"u"&&en.createPortal(t.jsxs("div",{ref:d,className:"wacht-root w-menu w-flex-col",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 16px)",maxHeight:p!=null&&p.maxHeight?`${p.maxHeight}px`:420,padding:0,zIndex:99999,top:(p==null?void 0:p.top)!==void 0?`${p.top}px`:void 0,bottom:(p==null?void 0:p.bottom)!==void 0?`${p.bottom}px`:void 0,left:(p==null?void 0:p.left)!==void 0?`${p.left}px`:void 0,right:(p==null?void 0:p.right)!==void 0?`${p.right}px`:void 0,visibility:p&&a?"visible":"hidden",opacity:a&&p?1:0,transform:a?"translateY(0)":"translateY(-4px)",pointerEvents:a?"auto":"none",transition:`opacity 0.15s ease, transform 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,...v},children:[b&&t.jsxs("div",{className:"w-banner w-banner--error w-switch-banner",children:[t.jsx(Ma,{size:13}),t.jsx("span",{className:"w-banner-txt w-text-error",children:b})]}),t.jsx("div",{className:"w-grow w-switch-body",children:N||P?t.jsx(t.Fragment,{children:[1,2,3].map(q=>t.jsxs("div",{className:"w-flex w-items-center w-gap-3",style:{padding:"0 8px",height:34},children:[t.jsx("span",{className:"w-skel",style:{width:22,height:22}}),t.jsx("span",{className:"w-skel",style:{width:q===2?"60%":"80%",height:11}})]},q))}):t.jsxs(t.Fragment,{children:[e&&t.jsxs("button",{className:"w-menu-item",onClick:()=>{W||G()},disabled:r||W,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:(B=(ce=S==null?void 0:S.active_signin)==null?void 0:ce.user)!=null&&B.profile_picture_url?t.jsx("img",{src:S.active_signin.user.profile_picture_url,alt:"Personal"}):t.jsx(hs,{size:12})}),t.jsx("span",{className:"w-grow w-truncate",children:"Personal account"}),W&&t.jsx(Ye,{size:13,className:"w-text-primary w-none"})]}),((k==null?void 0:k.length)??0)>0&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsx("div",{className:"w-menu-label",children:"Organizations"})]}),k==null?void 0:k.map(q=>{var we,ge;const X=q.organization,oe=X.id===(C==null?void 0:C.id),Ee=l.has(X.id),z=O?(T==null?void 0:T.filter(xe=>xe.organization.id===X.id))||[]:[],D=!!((we=q.eligibility_restriction)!=null&&we.type)&&q.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{D||(O?de(X.id):oe||G(X.id))},disabled:r,style:D?{opacity:.55,cursor:"not-allowed"}:void 0,title:(ge=q.eligibility_restriction)==null?void 0:ge.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:X.image_url?t.jsx("img",{src:X.image_url,alt:X.name}):V(X.name)}),t.jsx("span",{className:"w-grow w-truncate",children:X.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[D&&t.jsx(Ma,{size:12,className:"w-text-error"}),oe&&K&&t.jsx("span",{className:"w-rowact",role:"button",title:"Organization settings","aria-label":"Organization settings",onClick:xe=>{xe.stopPropagation(),fe()},children:t.jsx(Ea,{size:13})}),oe&&!D&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave organization","aria-label":"Leave organization",onClick:xe=>{xe.stopPropagation(),ae()},children:t.jsx(Aa,{size:13})}),oe&&!O&&t.jsx(Ye,{size:13,className:"w-text-primary"}),O&&t.jsx(Ut,{size:11,className:"w-text-muted",style:{transition:"transform 0.2s ease",transform:Ee?"rotate(0deg)":"rotate(-90deg)"}})]})]}),O&&Ee&&!D&&t.jsxs("div",{className:"w-switch-nest",children:[z.map(xe=>{var Q,le;const lt=oe&&(A==null?void 0:A.id)===xe.id,Qe=((Q=xe.eligibility_restriction)==null?void 0:Q.type)&&xe.eligibility_restriction.type!=="none";return t.jsxs("button",{className:"w-menu-item",onClick:()=>{!lt&&!Qe&&Y(xe.id)},disabled:r,style:Qe?{opacity:.55,cursor:"not-allowed"}:void 0,title:(le=xe.eligibility_restriction)==null?void 0:le.message,children:[t.jsx("span",{className:"w-avatar w-avatar--sm",children:xe.image_url?t.jsx("img",{src:xe.image_url,alt:xe.name}):V(xe.name).charAt(0)}),t.jsx("span",{className:"w-grow w-truncate",children:xe.name}),t.jsxs("span",{className:"w-inline w-gap-1 w-none",children:[Qe&&t.jsx(Ma,{size:12,className:"w-text-error"}),lt&&at&&t.jsx("span",{className:"w-rowact",role:"button",title:"Workspace settings","aria-label":"Workspace settings",onClick:me=>{me.stopPropagation(),ne()},children:t.jsx(Ea,{size:13})}),lt&&t.jsx("span",{className:"w-rowact",role:"button",title:"Leave workspace","aria-label":"Leave workspace",onClick:me=>{me.stopPropagation(),re()},children:t.jsx(Aa,{size:13})}),lt&&t.jsx(Ye,{size:12,className:"w-text-primary"})]})]},xe.id)}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>{w(X.id),h.open()},disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New workspace"})]})]})]},X.id)}),F&&t.jsxs(t.Fragment,{children:[t.jsx("hr",{className:"w-hr"}),t.jsxs("button",{className:"w-menu-item w-menu-item--muted",onClick:()=>u.open(),disabled:r,children:[t.jsx(St,{size:13}),t.jsx("span",{className:"w-grow w-truncate",children:"New organization"})]})]})]})})]}),document.body),L&&F&&t.jsx(Jc,{isOpen:u.isOpen,onClose:u.close,onCreated:_}),t.jsx(s0,{isOpen:f.isOpen,onClose:f.close}),O&&t.jsxs(t.Fragment,{children:[t.jsx(Or,{isOpen:g.isOpen,onClose:g.close}),t.jsx(Pr,{isOpen:h.isOpen,onClose:()=>{h.close(),w(null)},organizationId:x||void 0})]})]})})},u0=o.createContext(void 0),ta=()=>{const e=o.useContext(u0);if(!e)throw new Error("useScreenContext must be used within a ScreenProvider");return e},he=(...e)=>e.filter(Boolean).join(" "),m0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-contents",e),...a}));m0.displayName="TypographyProvider";const mr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card","w-flex-col","w-full","w-minh-full",e),...a}));mr.displayName="Container";const p0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-tabsbar",e),...a}));p0.displayName="TabsContainer";const h0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-1","w-tabs",e),...a}));h0.displayName="TabsList";const ka=o.forwardRef(({$isActive:e,className:a,...s},r)=>t.jsx("button",{ref:r,className:he("w-tab",e&&"w-tab--active",a),...s}));ka.displayName="Tab";const Ca=o.forwardRef(({className:e,...a},s)=>t.jsx("span",{ref:s,className:he("w-inline","w-gap-1",e),...a}));Ca.displayName="TabIcon";const f0=o.forwardRef(({className:e,children:a,...s},r)=>t.jsx("div",{ref:r,className:he("w-tabbody",e),...s,children:t.jsx("div",{className:"w-tabpane",children:a})}));f0.displayName="TabContent";const zm=o.forwardRef(({className:e,...a},s)=>t.jsx("button",{ref:s,className:he("w-btn","w-btn--icon",e),...a}));zm.displayName="IconButton";const w0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-justify-between","w-wrap","w-gap-3",e),...a}));w0.displayName="HeaderCTAContainer";const Dm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-start","w-gap-6",e),...a}));Dm.displayName="ProfileSectionLayout";const Um=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-none",e),...a}));Um.displayName="ProfileImageContainer";const g0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-vrow",e),...a}));g0.displayName="SecurityItemRow";const x0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-grow",e),...a}));x0.displayName="SecurityItemContent";const v0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-2","w-none",e),...a}));v0.displayName="SecurityItemActions";const Ir=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-sechead",e),...a}));Ir.displayName="ResponsiveHeaderContainer";const hn=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-full",e),...a}));hn.displayName="DesktopTableContainer";const b0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-gap-3",e),...a}));b0.displayName="FormRow";const Wm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-vrow",e),...a}));Wm.displayName="ConnectionItemRow";const Bm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-2","w-grow",e),...a}));Bm.displayName="ConnectionLeft";const Gm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-justify-end","w-gap-1","w-none",e),...a}));Gm.displayName="ConnectionRight";const Vr=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-iconbox",e),...a}));Vr.displayName="IconWrapper";const qm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-wrap","w-gap-2",e),...a}));qm.displayName="ButtonActions";const y0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-page-head",e),...a}));y0.displayName="PageHeader";const Km=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-avatar",e),...a}));Km.displayName="PageHeaderAvatar";const j0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-1","w-grow",e),...a}));j0.displayName="PageHeaderInfo";const _0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-sec","w-truncate",e),...a}));_0.displayName="PageHeaderName";const k0=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-secsub","w-truncate",e),...a}));k0.displayName="PageHeaderSub";const Ym=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-gap-1","w-none",e),...a}));Ym.displayName="PageHeaderActions";const Qm=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-4",e),...a}));Qm.displayName="PageContent";const Jm=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:he("w-card",e),...a}));Jm.displayName="Card";const Xm=o.forwardRef(({className:e,...a},s)=>t.jsx("section",{ref:s,className:he("w-card","w-danger",e),...a}));Xm.displayName="DangerCard";const e6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card-head",e),...a}));e6.displayName="CardHeader";const t6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-1","w-grow",e),...a}));t6.displayName="CardTitleBlock";const a6=o.forwardRef(({className:e,...a},s)=>t.jsx("h3",{ref:s,className:he("w-sec",e),...a}));a6.displayName="CardTitle";const s6=o.forwardRef(({className:e,...a},s)=>t.jsx("p",{ref:s,className:he("w-secsub",e),...a}));s6.displayName="CardSubtitle";const n6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));n6.displayName="CardActions";const r6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-hr",e),...a}));r6.displayName="CardDivider";const i6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card-body",e),...a}));i6.displayName="CardBody";const o6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-card-foot",e),...a}));o6.displayName="CardFooter";const l6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-list",e),...a}));l6.displayName="RowList";const c6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-rowitem",e),...a}));c6.displayName="RowItem";const d6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex-col","w-gap-1","w-grow",e),...a}));d6.displayName="RowInfo";const u6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-sec",e),...a}));u6.displayName="RowTitle";const m6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-secsub",e),...a}));m6.displayName="RowSub";const p6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-flex","w-items-center","w-wrap","w-gap-2","w-none",e),...a}));p6.displayName="RowActions";const h6={primary:"w-pill--current",success:"w-pill--success",warning:"w-pill--pending",danger:"w-pill--error",neutral:""},qa=({$variant:e="neutral",className:a,children:s,...r})=>t.jsxs("span",{className:he("w-pill",h6[e],a),...r,children:[t.jsx("span",{className:"w-dot"}),s]}),f6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-list",e),...a}));f6.displayName="Table";const w6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:he("w-listhead","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));w6.displayName="TableHead";const g6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:e,...a}));g6.displayName="Th";const x6=o.forwardRef(({$cols:e,className:a,style:s,...r},i)=>t.jsx("div",{ref:i,className:he("w-row","w-gap-4",a),style:{gridTemplateColumns:e||"1fr 1fr auto",...s},...r}));x6.displayName="Tr";const v6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-truncate","w-text-secondary",e),...a}));v6.displayName="Td";const b6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-grid-2",e),...a}));b6.displayName="FieldGrid";const y6=o.forwardRef(({className:e,...a},s)=>t.jsx("div",{ref:s,className:he("w-field",e),...a}));y6.displayName="Field";const j6=o.forwardRef(({className:e,...a},s)=>t.jsx("label",{ref:s,className:he("w-label",e),...a}));j6.displayName="FieldLabel";const _6=()=>{var T,P;const{deployment:e}=Ce(),{refetch:a}=ot(),{user:s,updateProfile:r,deleteAccount:i}=ba(),{toast:l}=ta(),[m,c]=o.useState(""),[d,p]=o.useState(""),[u,f]=o.useState(""),[h,g]=o.useState(!1),[x,w]=o.useState(!1),[b,j]=o.useState(!1),[v,k]=o.useState("");o.useEffect(()=>{s&&!h&&(c(s.first_name||""),p(s.last_name||""),f(s.username||""),g(!0))},[s,h]);const N=o.useCallback(async()=>{if(s)try{const S={};m!==s.first_name&&(S.first_name=m),d!==s.last_name&&(S.last_name=d),u!==s.username&&(S.username=u),Object.keys(S).length>0&&await r(S)}catch(S){l(S.message||"Failed to save profile changes","error")}},[s,r,m,d,u,l]),_=S=>{c(S.target.value)},C=S=>{p(S.target.value)},y=S=>{f(S.target.value)},E=()=>{N()},A=()=>{N()},H=()=>{N()};if(!s)return t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})});const M=async()=>{if(!(!s||v!=="delete this account")){j(!0);try{await i(""),l("Account deleted successfully","info"),await a()}catch(S){l(S.message||"Failed to delete account","error")}finally{j(!1),k(""),w(!1)}}};return t.jsxs("div",{className:"w-flex-col w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx("p",{className:"w-secsub",children:"Basic information about your profile"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs(b0,{children:[t.jsxs(Ge,{className:"w-grow",children:[t.jsx(Ve,{htmlFor:"firstName",children:"First Name"}),t.jsx(ye,{id:"firstName",type:"text",value:m,onChange:_,onBlur:E,placeholder:"Enter your first name",required:!0})]}),t.jsxs(Ge,{className:"w-grow",children:[t.jsx(Ve,{htmlFor:"lastName",children:"Last Name"}),t.jsx(ye,{id:"lastName",type:"text",value:d,onChange:C,onBlur:A,placeholder:"Enter your last name",required:!0})]})]}),((P=(T=e==null?void 0:e.auth_settings)==null?void 0:T.username)==null?void 0:P.enabled)&&t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"username",children:"Username"}),t.jsx(ye,{id:"username",type:"text",value:u,onChange:y,onBlur:H,placeholder:"Enter your username",required:!0})]})]})]}),t.jsx("div",{className:"w-hr"}),t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("h3",{className:"w-sec",children:"Danger Zone"}),t.jsx("p",{className:"w-secsub",children:"Irreversible and destructive actions"})]}),t.jsxs("div",{className:"w-danger w-flex-col w-items-start",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-4 w-full",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Delete Account"}),t.jsx("div",{className:"w-secsub",children:"Once you delete your account, there is no going back. Please be certain."})]}),t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>{x?(w(!1),k("")):w(!0)},children:x?"Cancel":"Delete"})]}),x&&t.jsxs("div",{className:"w-full w-flex-col w-gap-3",children:[t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),t.jsx(ye,{id:"confirm_username",type:"text",value:v,onChange:S=>k(S.target.value),placeholder:"delete this account"})]}),t.jsx(se,{$destructive:!0,$fullWidth:!0,onClick:M,disabled:v!=="delete this account"||b,children:b?t.jsx(_e,{size:12}):"Delete Forever"})]})]})]})]})},qi=({onClose:e,onAddEmail:a,onAttemptVerification:s,onPrepareVerification:r,existingEmail:i,triggerRef:l})=>{const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=ta(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const _=y=>{m.current&&!m.current.contains(y.target)&&e()},C=y=>{y.key==="Escape"&&e()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[e]);const[f,h]=o.useState(i?"otp":"email"),[g,x]=o.useState(i||""),[w,b]=o.useState(""),[j,v]=o.useState(!1),k=async()=>{if(!(!g||j)){v(!0);try{await a(g),h("otp")}catch(_){p(_.message||"Failed to add email. Please try again.","error")}finally{v(!1)}}},N=async()=>{v(!0);try{await s(w),e()}catch(_){p(_.message||"Failed to verify email. Check the code and try again.","error")}finally{v(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:f==="email"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add email address"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Email address"}),t.jsx(ye,{id:"email-input",type:"email",placeholder:"you@company.com",value:g,onChange:_=>x(_.target.value),onKeyDown:_=>{_.key==="Enter"&&k()},autoFocus:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:k,disabled:!g||j,children:j?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!i&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("email"),children:[t.jsx(nn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify your email"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:g})]})]}),t.jsx(ya,{onComplete:async _=>b(_),onResend:r,isSubmitting:j})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:N,disabled:w.length<6||j,children:j?"Verifying…":"Verify"})]})]})}):null},k6=()=>{var A,H,M,T;const{deployment:e}=Ce(),{toast:a}=ta(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createEmailAddress:g,deleteEmailAddress:x,prepareEmailVerification:w,attemptEmailVerification:b,makeEmailPrimary:j}=ba();if(!((H=(A=e==null?void 0:e.auth_settings)==null?void 0:A.email_address)!=null&&H.enabled))return null;const v=(P,S)=>{p($=>{const Z=new Set($);return S?Z.add(P):Z.delete(P),Z})},k=async P=>{v(P,!0);try{await j(P),await h.refetch(),a("Primary email updated","info")}catch(S){a(S.message||"Failed to update primary email","error")}finally{v(P,!1)}},N=async P=>{if(P===(h==null?void 0:h.primary_email_address_id)){a("Cannot delete primary email. Set another email as primary first.","error");return}v(P,!0);try{await x(P),await h.refetch(),a("Email removed","info")}catch(S){a(S.message||"Failed to delete email address. Please try again.","error")}finally{v(P,!1)}},_=async P=>{v(P,!0);try{await w(P),await h.refetch(),c(P)}catch(S){a(S.message||"Failed to send verification","error")}finally{v(P,!1)}},C=(h==null?void 0:h.user_email_addresses)||[],y=P=>P.id===(h==null?void 0:h.primary_email_address_id)?t.jsx(qa,{$variant:"success",children:"Primary"}):P.verified?t.jsx(qa,{$variant:"neutral",children:"Backup"}):t.jsx(qa,{$variant:"warning",children:"Pending verification"}),E=P=>{const S=P.id===(h==null?void 0:h.primary_email_address_id),$=d.has(P.id);return S?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[P.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:$,onClick:()=>k(P.id),children:"Make primary"}),!P.verified&&t.jsx(se,{ref:Z=>{Z&&(f.current[P.id]=Z)},$size:"sm",$outline:!0,disabled:$,onClick:()=>_(P.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:$,onClick:()=>N(P.id),children:$?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(Ir,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Email addresses"}),t.jsx("div",{className:"w-secsub",children:"Sign in and receive notifications at these addresses."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add email"}),i&&t.jsx(qi,{triggerRef:u,onClose:()=>l(!1),onAddEmail:async P=>{const S=await g(P);r(S.data.id),await w(S.data.id),h.refetch()},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async P=>{await b(s,P),h.refetch(),l(!1),r(""),a("Email added and verified","info")}})]})]}),C.length?t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Email address"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:C.map(P=>t.jsxs(it,{children:[t.jsx(Xe,{children:P.email}),t.jsx(Xe,{children:y(P)}),t.jsx(Ft,{children:E(P)})]},P.id))})]})})}):t.jsx(Nt,{title:"No email addresses",description:"Add an email address to get started."}),m&&t.jsx(qi,{existingEmail:(T=(M=h==null?void 0:h.user_email_addresses)==null?void 0:M.find(P=>P.id===m))==null?void 0:T.email,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async P=>{await b(m,P),h.refetch(),c(null),a("Email verified","info")}})]})},Ki=({onClose:e,onAddPhone:a,onAttemptVerification:s,existingPhone:r,onPrepareVerification:i,triggerRef:l})=>{var y;const m=o.useRef(null),[c,d]=o.useState(!1),{toast:p}=ta(),u=bt({contentRef:m,triggerRef:l??{current:null},isOpen:c,minWidth:340,defaultMaxHeight:360});o.useEffect(()=>{d(!0);const E=H=>{m.current&&!m.current.contains(H.target)&&e()},A=H=>{H.key==="Escape"&&e()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",A)}},[e]);const[f,h]=o.useState(r?"otp":"phone"),[g,x]=o.useState((r==null?void 0:r.replace(/^\+\d+/,""))||""),[w,b]=o.useState((y=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:y.pop()),[j,v]=o.useState(""),[k,N]=o.useState(!1),_=async()=>{if(!(!g||k)){N(!0);try{await a(g,w||""),h("otp")}catch(E){p(E.message||"Failed to add phone number. Please try again.","error")}finally{N(!1)}}},C=async()=>{N(!0);try{await s(j),e()}catch(E){p(E.message||"Failed to verify phone. Check the code and try again.","error")}finally{N(!1)}};return c?t.jsx("div",{ref:m,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(u==null?void 0:u.top)!==void 0?`${u.top}px`:void 0,bottom:(u==null?void 0:u.bottom)!==void 0?`${u.bottom}px`:void 0,left:(u==null?void 0:u.left)!==void 0?`${u.left}px`:void 0,right:(u==null?void 0:u.right)!==void 0?`${u.right}px`:void 0,visibility:u?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:f==="phone"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add phone number"}),t.jsxs("label",{className:"w-field",children:[t.jsx("span",{className:"w-label",children:"Phone number"}),t.jsx(ys,{value:g,onChange:E=>x(E.target.value),error:"",countryCode:w,setCountryCode:b})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:_,disabled:!g||k,children:k?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[!r&&t.jsxs("button",{type:"button",className:"w-link w-link--muted w-inline w-gap-1",style:{alignSelf:"flex-start",background:"none",border:0,cursor:"pointer"},onClick:()=>h("phone"),children:[t.jsx(nn,{size:11})," Back"]}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify phone number"}),t.jsxs("p",{className:"w-pop-sub",children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:r||g})]})]}),t.jsx(ya,{onComplete:E=>v(E),onResend:async()=>i(),isSubmitting:k})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{type:"button",className:"w-btn w-btn--ghost w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{type:"button",className:"w-btn w-btn--primary w-btn--sm",onClick:C,disabled:j.length!==6||k,children:k?"Verifying…":"Verify"})]})]})}):null},C6=()=>{var H,M,T,P;const{deployment:e}=Ce(),{toast:a}=ta(),[s,r]=o.useState(""),[i,l]=o.useState(!1),[m,c]=o.useState(null),[d,p]=o.useState(new Set),u=o.useRef(null),f=o.useRef({}),{user:h,createPhoneNumber:g,deletePhoneNumber:x,preparePhoneVerification:w,attemptPhoneVerification:b,makePhonePrimary:j}=ba();if(!((M=(H=e==null?void 0:e.auth_settings)==null?void 0:H.phone_number)!=null&&M.enabled))return null;const v=(S,$)=>{p(Z=>{const R=new Set(Z);return $?R.add(S):R.delete(S),R})},k=S=>{const $=Gs.find(Z=>Z.dialCode===S);return($==null?void 0:$.flag)||"🌍"},N=async S=>{v(S,!0);try{await j(S),await h.refetch(),a("Primary phone updated","info")}catch($){a($.message||"Failed to update primary phone","error")}finally{v(S,!1)}},_=async S=>{if(S===(h==null?void 0:h.primary_phone_number_id)){a("Cannot delete primary phone. Set another phone as primary first.","error");return}v(S,!0);try{await x(S),await h.refetch(),a("Phone removed","info")}catch($){a($.message||"Failed to delete phone. Please try again.","error")}finally{v(S,!1)}},C=async S=>{v(S,!0);try{await w(S),await h.refetch(),c(S)}catch($){a($.message||"Failed to send verification","error")}finally{v(S,!1)}},y=(h==null?void 0:h.user_phone_numbers)||[],E=S=>S.id===(h==null?void 0:h.primary_phone_number_id)?t.jsx(qa,{$variant:"success",children:"Primary"}):S.verified?t.jsx(qa,{$variant:"neutral",children:"Backup"}):t.jsx(qa,{$variant:"warning",children:"Pending verification"}),A=S=>{const $=S.id===(h==null?void 0:h.primary_phone_number_id),Z=d.has(S.id);return $?t.jsx("span",{className:"w-secsub",children:"Cannot remove"}):t.jsxs("div",{className:"w-actions",children:[S.verified&&t.jsx(se,{$size:"sm",$outline:!0,disabled:Z,onClick:()=>N(S.id),children:"Make primary"}),!S.verified&&t.jsx(se,{ref:R=>{R&&(f.current[S.id]=R)},$size:"sm",$outline:!0,disabled:Z,onClick:()=>C(S.id),children:"Resend"}),t.jsx(se,{$size:"sm",$destructive:!0,disabled:Z,onClick:()=>_(S.id),children:Z?t.jsx(_e,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(Ir,{children:[t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Phone numbers"}),t.jsx("div",{className:"w-secsub",children:"Used for sign-in and two-factor authentication."})]}),t.jsxs("div",{className:"w-none w-relative",children:[t.jsx(se,{ref:u,$size:"sm",onClick:()=>l(!0),children:"Add phone"}),i&&t.jsx(Ki,{triggerRef:u,onClose:()=>l(!1),onAddPhone:async(S,$)=>{const Z=await g(S,$);r(Z.data.id),await w(Z.data.id)},onPrepareVerification:async()=>{await w(s),h.refetch()},onAttemptVerification:async S=>{await b(s,S),h.refetch(),l(!1),r(""),a("Phone added and verified","info")}}),m&&t.jsx(Ki,{existingPhone:(P=(T=h==null?void 0:h.user_phone_numbers)==null?void 0:T.find(S=>S.id===m))==null?void 0:P.phone_number,triggerRef:{current:f.current[m]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await w(m),h.refetch()},onAttemptVerification:async S=>{await b(m,S),h.refetch(),c(null),a("Phone verified","info")}})]})]}),y.length?t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Phone number"}),t.jsx(Fe,{children:"Status"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:y.map(S=>t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("span",{className:"w-inline w-gap-2",children:[t.jsx("span",{children:k(S.country_code)}),t.jsx("span",{className:"w-text-secondary",children:S.country_code}),t.jsx("span",{children:S.phone_number})]})}),t.jsx(Xe,{children:E(S)}),t.jsx(Ft,{children:A(S)})]},S.id))})]})})}):t.jsx(Nt,{title:"No phone numbers",description:"Add a phone number to get started."})]})},N6=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),t.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),t.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),t.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),S6={google_oauth:{icon:t.jsx(Nc,{}),label:"Google"},microsoft_oauth:{icon:t.jsx(N6,{}),label:"Microsoft"},github_oauth:{icon:t.jsx(Cc,{}),label:"GitHub"},gitlab_oauth:{icon:t.jsx(Ac,{}),label:"GitLab"},linkedin_oauth:{icon:t.jsx(Ec,{}),label:"LinkedIn"},discord_oauth:{icon:t.jsx(Mc,{}),label:"Discord"},x_oauth:{icon:t.jsx(Sc,{}),label:"X"}},E6=()=>{const{user:e,disconnectSocialConnection:a,connectSocialAccount:s}=ba(),{deployment:r}=Ce(),i=(r==null?void 0:r.social_connections.filter(c=>c.enabled))||[],l=c=>{s({provider:c,redirectUri:window.location.href})},m=async c=>{await a(c.toString()),e.refetch()};return i.length===0?t.jsx(Nt,{title:"No providers available",description:"Social sign-in providers have not been configured for this app."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-flex w-items-center w-gap-3",children:t.jsxs("div",{className:"w-grow w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Connected accounts"}),t.jsx("div",{className:"w-secsub",children:"Sign in faster by linking third-party accounts."})]})}),t.jsx("div",{className:"w-list",children:i.map(c=>{var f;const d=S6[c.provider];if(!d)return null;const p=((f=e==null?void 0:e.social_connections)==null?void 0:f.filter(h=>h.provider===c.provider))||[],u=p.length>0;return t.jsxs("div",{className:"w-vrow",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3 w-grow",children:[t.jsx(Vr,{children:d.icon}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-grow",children:[t.jsx("div",{className:"w-sec",children:d.label}),u?t.jsx("div",{className:"w-flex w-wrap w-gap-1",children:p.map(h=>t.jsxs("span",{className:"w-chip",children:[t.jsx("span",{className:"w-truncate",children:h.email_address}),t.jsx("span",{className:"w-chip-x",role:"button",onClick:()=>m(h.id),title:"Remove connection","aria-label":"Remove connection",children:t.jsx(La,{size:10,weight:"bold"})})]},h.id))}):t.jsx("span",{className:"w-secsub",children:"Not linked"})]})]}),t.jsx("div",{className:`w-flex w-justify-end w-none${u?" w-row-act-top":""}`,children:t.jsx(se,{$size:"sm",$outline:!0,onClick:()=>l(c.provider),children:u?"Link another":"Link"})})]},c.provider)})})]})};var A6=Object.defineProperty,Xs=Object.getOwnPropertySymbols,C0=Object.prototype.hasOwnProperty,N0=Object.prototype.propertyIsEnumerable,Yi=(e,a,s)=>a in e?A6(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s,pr=(e,a)=>{for(var s in a||(a={}))C0.call(a,s)&&Yi(e,s,a[s]);if(Xs)for(var s of Xs(a))N0.call(a,s)&&Yi(e,s,a[s]);return e},hr=(e,a)=>{var s={};for(var r in e)C0.call(e,r)&&a.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&Xs)for(var r of Xs(e))a.indexOf(r)<0&&N0.call(e,r)&&(s[r]=e[r]);return s};/**
109
109
  * @license QR Code generator library (TypeScript)
110
110
  * Copyright (c) Project Nayuki.
111
111
  * SPDX-License-Identifier: MIT
@@ -113,7 +113,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
113
113
  * @license qrcode.react
114
114
  * Copyright (c) Paul O'Shannessy
115
115
  * SPDX-License-Identifier: ISC
116
- */var A6={L:Wa.QrCode.Ecc.LOW,M:Wa.QrCode.Ecc.MEDIUM,Q:Wa.QrCode.Ecc.QUARTILE,H:Wa.QrCode.Ecc.HIGH},S0=128,E0="L",A0="#FFFFFF",M0="#000000",R0=!1,L0=1,M6=4,R6=0,L6=.1;function P0(e,a=0){const s=[];return e.forEach(function(r,i){let l=null;r.forEach(function(m,c){if(!m&&l!==null){s.push(`M${l+a} ${i+a}h${c-l}v1H${l+a}z`),l=null;return}if(c===r.length-1){if(!m)return;l===null?s.push(`M${c+a},${i+a} h1v1H${c+a}z`):s.push(`M${l+a},${i+a} h${c+1-l}v1H${l+a}z`);return}m&&l===null&&(l=c)})}),s.join("")}function $0(e,a){return e.slice().map((s,r)=>r<a.y||r>=a.y+a.h?s:s.map((i,l)=>l<a.x||l>=a.x+a.w?i:!1))}function P6(e,a,s,r){if(r==null)return null;const i=e.length+s*2,l=Math.floor(a*L6),m=i/a,c=(r.width||l)*m,d=(r.height||l)*m,p=r.x==null?e.length/2-c/2:r.x*m,u=r.y==null?e.length/2-d/2:r.y*m,f=r.opacity==null?1:r.opacity;let h=null;if(r.excavate){let x=Math.floor(p),w=Math.floor(u),b=Math.ceil(c+p-x),j=Math.ceil(d+u-w);h={x,y:w,w:b,h:j}}const g=r.crossOrigin;return{x:p,y:u,h:d,w:c,excavation:h,opacity:f,crossOrigin:g}}function $6(e,a){return a!=null?Math.max(Math.floor(a),0):e?M6:R6}function O0({value:e,level:a,minVersion:s,includeMargin:r,marginSize:i,imageSettings:l,size:m,boostLevel:c}){let d=o.useMemo(()=>{const x=(Array.isArray(e)?e:[e]).reduce((w,b)=>(w.push(...Wa.QrSegment.makeSegments(b)),w),[]);return Wa.QrCode.encodeSegments(x,A6[a],s,void 0,void 0,c)},[e,a,s,c]);const{cells:p,margin:u,numCells:f,calculatedImageSettings:h}=o.useMemo(()=>{let g=d.getModules();const x=$6(r,i),w=g.length+x*2,b=P6(g,m,x,l);return{cells:g,margin:x,numCells:w,calculatedImageSettings:b}},[d,m,l,r,i]);return{qrcode:d,margin:u,cells:p,numCells:f,calculatedImageSettings:h}}var O6=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Z6=o.forwardRef(function(a,s){const r=a,{value:i,size:l=S0,level:m=E0,bgColor:c=A0,fgColor:d=M0,includeMargin:p=R0,minVersion:u=L0,boostLevel:f,marginSize:h,imageSettings:g}=r,w=hr(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=w,j=hr(w,["style"]),v=g==null?void 0:g.src,k=o.useRef(null),N=o.useRef(null),_=o.useCallback(S=>{k.current=S,typeof s=="function"?s(S):s&&(s.current=S)},[s]),[C,y]=o.useState(!1),{margin:E,cells:A,numCells:H,calculatedImageSettings:M}=O0({value:i,level:m,minVersion:u,boostLevel:f,includeMargin:p,marginSize:h,imageSettings:g,size:l});o.useEffect(()=>{if(k.current!=null){const S=k.current,$=S.getContext("2d");if(!$)return;let Z=A;const R=N.current,L=M!=null&&R!==null&&R.complete&&R.naturalHeight!==0&&R.naturalWidth!==0;L&&M.excavation!=null&&(Z=$0(A,M.excavation));const O=window.devicePixelRatio||1;S.height=S.width=l*O;const F=l/H*O;$.scale(F,F),$.fillStyle=c,$.fillRect(0,0,H,H),$.fillStyle=d,O6?$.fill(new Path2D(P0(Z,E))):A.forEach(function(W,U){W.forEach(function(V,G){V&&$.fillRect(G+E,U+E,1,1)})}),M&&($.globalAlpha=M.opacity),L&&$.drawImage(R,M.x+E,M.y+E,M.w,M.h)}}),o.useEffect(()=>{y(!1)},[v]);const T=pr({height:l,width:l},b);let P=null;return v!=null&&(P=o.createElement("img",{src:v,key:v,style:{display:"none"},onLoad:()=>{y(!0)},ref:N,crossOrigin:M==null?void 0:M.crossOrigin})),o.createElement(o.Fragment,null,o.createElement("canvas",pr({style:T,height:l,width:l,ref:_,role:"img"},j)),P)});Z6.displayName="QRCodeCanvas";var zr=o.forwardRef(function(a,s){const r=a,{value:i,size:l=S0,level:m=E0,bgColor:c=A0,fgColor:d=M0,includeMargin:p=R0,minVersion:u=L0,boostLevel:f,title:h,marginSize:g,imageSettings:x}=r,w=hr(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:j,numCells:v,calculatedImageSettings:k}=O0({value:i,level:m,minVersion:u,boostLevel:f,includeMargin:p,marginSize:g,imageSettings:x,size:l});let N=j,_=null;x!=null&&k!=null&&(k.excavation!=null&&(N=$0(j,k.excavation)),_=o.createElement("image",{href:x.src,height:k.h,width:k.w,x:k.x+b,y:k.y+b,preserveAspectRatio:"none",opacity:k.opacity,crossOrigin:k.crossOrigin}));const C=P0(N,b);return o.createElement("svg",pr({height:l,width:l,viewBox:`0 0 ${v} ${v}`,ref:s,role:"img"},w),!!h&&o.createElement("title",null,h),o.createElement("path",{fill:c,d:`M0,0 h${v}v${v}H0z`,shapeRendering:"crispEdges"}),o.createElement("path",{fill:d,d:C,shapeRendering:"crispEdges"}),_)});zr.displayName="QRCodeSVG";const Qi=({onClose:e,onChangePassword:a,triggerRef:s,isSetup:r=!1})=>{const i=o.useRef(null),[l,m]=o.useState(!1),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(""),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(!1),[k,N]=o.useState(!1),[_,C]=o.useState({}),y=bt({contentRef:i,triggerRef:s??{current:null},isOpen:l,minWidth:380,defaultMaxHeight:420});o.useEffect(()=>{m(!0);const A=M=>{i.current&&!i.current.contains(M.target)&&e()},H=M=>{M.key==="Escape"&&e()};return document.addEventListener("mousedown",A),document.addEventListener("keydown",H),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",H)}},[e]);const E=async()=>{if(k)return;const A={};if(!r&&!c&&(A.currentPassword="Current password is required"),p?p.length<8&&(A.newPassword="Password must be at least 8 characters"):A.newPassword="New password is required",p!==f&&(A.confirmPassword="Passwords do not match"),Object.keys(A).length>0){C(A);return}N(!0);try{await a(r?"":c,p),e()}catch(H){C({form:H.message||"Failed to update password"})}finally{N(!1)}};return l?t.jsxs("div",{ref:i,className:"w-pop",style:{position:"fixed",zIndex:1001,width:380,maxWidth:"calc(100vw - 24px)",top:(y==null?void 0:y.top)!==void 0?`${y.top}px`:void 0,bottom:(y==null?void 0:y.bottom)!==void 0?`${y.bottom}px`:void 0,left:(y==null?void 0:y.left)!==void 0?`${y.left}px`:void 0,right:(y==null?void 0:y.right)!==void 0?`${y.right}px`:void 0,maxHeight:y!=null&&y.maxHeight?`${y.maxHeight}px`:void 0,visibility:y?"visible":"hidden"},onClick:A=>A.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:r?"Set Password":"Change Password"}),t.jsx("p",{className:"w-pop-sub",children:r?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."})]}),!r&&t.jsxs("div",{className:"w-field",children:[t.jsx(Ve,{children:"Current Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(ye,{type:g?"text":"password",placeholder:"Enter your current password",value:c,onChange:A=>d(A.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>x(!g),"aria-label":g?"Hide current password":"Show current password",children:g?t.jsx(Sn,{size:16}):t.jsx(Nn,{size:16})})]}),_.currentPassword&&t.jsx("span",{className:"w-input-err",children:_.currentPassword})]}),t.jsxs("div",{className:"w-field",children:[t.jsx(Ve,{children:r?"Password":"New Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(ye,{type:w?"text":"password",placeholder:r?"Enter your password":"Enter your new password",value:p,onChange:A=>u(A.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>b(!w),"aria-label":w?"Hide new password":"Show new password",children:w?t.jsx(Sn,{size:16}):t.jsx(Nn,{size:16})})]}),_.newPassword&&t.jsx("span",{className:"w-input-err",children:_.newPassword})]}),t.jsxs("div",{className:"w-field",children:[t.jsx(Ve,{children:"Confirm New Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(ye,{type:j?"text":"password",placeholder:"Confirm your new password",value:f,onChange:A=>h(A.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>v(!j),"aria-label":j?"Hide confirm password":"Show confirm password",children:j?t.jsx(Sn,{size:16}):t.jsx(Nn,{size:16})})]}),_.confirmPassword&&t.jsx("span",{className:"w-input-err",children:_.confirmPassword})]}),_.form&&t.jsx("span",{className:"w-input-err",children:_.form})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:E,disabled:k,children:k?r?"Setting...":"Updating...":r?"Set Password":"Update Password"})]})]}):null},H6=({onClose:e,onRemovePassword:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(!1),[m,c]=o.useState(""),[d,p]=o.useState(!1),{toast:u}=ta(),f=bt({contentRef:r,triggerRef:s??{current:null},isOpen:i,minWidth:400,defaultMaxHeight:360});o.useEffect(()=>{l(!0);const g=w=>{r.current&&!r.current.contains(w.target)&&e()},x=w=>{w.key==="Escape"&&e()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[e]);const h=async()=>{if(!(!m||d)){p(!0);try{await a(m),e()}catch(g){const x=g.message||"Failed to remove password. Please try again.";u(x,"error")}finally{p(!1)}}};return i?t.jsxs("div",{ref:r,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(f==null?void 0:f.top)!==void 0?`${f.top}px`:void 0,bottom:(f==null?void 0:f.bottom)!==void 0?`${f.bottom}px`:void 0,left:(f==null?void 0:f.left)!==void 0?`${f.left}px`:void 0,right:(f==null?void 0:f.right)!==void 0?`${f.right}px`:void 0,maxHeight:f!=null&&f.maxHeight?`${f.maxHeight}px`:void 0,visibility:f?"visible":"hidden"},onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Remove Password"}),t.jsxs("div",{className:"w-banner w-banner--warn",children:[t.jsx(Fa,{size:16}),t.jsx("span",{className:"w-banner-txt",children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"current-password",children:"Confirm your current password"}),t.jsx(ye,{id:"current-password",type:"password",placeholder:"Enter current password",value:m,onChange:g=>c(g.target.value),autoFocus:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:h,disabled:!m||d,children:d?"Removing...":"Remove Password"})]})]}):null},F6=({onClose:e,onSetupTOTP:a,onVerifyTOTP:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState("qr"),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(["",""]),[g,x]=o.useState(!1),[w,b]=o.useState(!1),{toast:j}=ta(),v=bt({contentRef:i,triggerRef:r??{current:null},isOpen:w,minWidth:380,defaultMaxHeight:460});o.useEffect(()=>{b(!0);const N=C=>{i.current&&!i.current.contains(C.target)&&e()},_=C=>{C.key==="Escape"&&e()};return document.addEventListener("mousedown",N),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",_)}},[e]),o.useEffect(()=>{(async()=>{x(!0);try{const _=await a();d(_.otp_url||""),u(_.totp_secret||"")}catch(_){const C=_.message||"Failed to setup two-factor authentication. Please try again.";j(C,"error")}finally{x(!1)}})()},[]);const k=async()=>{if(!f.some(N=>N.length!==6)){x(!0);try{await s(f),e()}catch(N){const _=N.message||"Failed to verify codes. Please check your authenticator app and try again.";j(_,"error")}finally{x(!1)}}};return w?t.jsx("div",{ref:i,className:"w-pop",style:{position:"fixed",zIndex:1001,width:340,maxWidth:"calc(100vw - 24px)",top:(v==null?void 0:v.top)!==void 0?`${v.top}px`:void 0,bottom:(v==null?void 0:v.bottom)!==void 0?`${v.bottom}px`:void 0,left:(v==null?void 0:v.left)!==void 0?`${v.left}px`:void 0,right:(v==null?void 0:v.right)!==void 0?`${v.right}px`:void 0,maxHeight:v!=null&&v.maxHeight?`${v.maxHeight}px`:void 0,visibility:v?"visible":"hidden"},onClick:N=>N.stopPropagation(),children:l==="qr"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Setup Two-Factor Authentication"}),t.jsx("p",{className:"w-pop-sub",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"})]}),t.jsx("div",{className:"w-flex w-justify-center",children:g?t.jsx("div",{className:"w-qr w-text-muted",children:"Loading..."}):c?t.jsx("div",{className:"w-qr",style:{background:"#fff",padding:8},children:t.jsx(zr,{value:c,size:130,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):t.jsx("div",{className:"w-qr w-text-error",children:"QR Code Not Available"})}),p&&t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-secsub",children:"Or enter manually:"}),t.jsx("div",{className:"w-token",children:t.jsx("code",{style:{wordBreak:"break-all"},children:p})})]})]}),t.jsx("div",{className:"w-pop-foot",children:t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:()=>m("verify"),disabled:g||!c,children:"I've Scanned the Code"})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify Your Authenticator"}),t.jsx("p",{className:"w-pop-sub",children:"Enter two consecutive codes from your authenticator app"})]}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(ye,{id:"totp-code-1",type:"text",placeholder:"000000",value:f[0],onChange:N=>{const _=N.target.value.replace(/[^0-9]/g,"").substring(0,6);h([_,f[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"var(--wa-font-mono)"},"aria-label":"First verification code from authenticator app"}),t.jsx(ye,{id:"totp-code-2",type:"text",placeholder:"000000",value:f[1],onChange:N=>{const _=N.target.value.replace(/[^0-9]/g,"").substring(0,6);h([f[0],_])},maxLength:6,style:{textAlign:"center",fontFamily:"var(--wa-font-mono)"},"aria-label":"Second verification code from authenticator app"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:()=>m("qr"),children:"Back"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:k,disabled:g||f.some(N=>N.length!==6),children:g?"Verifying...":"Verify"})]})]})}):null},T6=({codes:e,onClose:a,onCopy:s,onDownload:r,triggerRef:i})=>{const l=o.useRef(null),[m,c]=o.useState(!1),d=bt({contentRef:l,triggerRef:i??{current:null},isOpen:m,minWidth:380,defaultMaxHeight:360});return o.useEffect(()=>{c(!0);const p=f=>{l.current&&!l.current.contains(f.target)&&a()},u=f=>{f.key==="Escape"&&a()};return document.addEventListener("mousedown",p),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",u)}},[a]),m?t.jsx("div",{ref:l,className:"w-pop",style:{position:"fixed",zIndex:1001,width:380,maxWidth:"calc(100vw - 24px)",top:(d==null?void 0:d.top)!==void 0?`${d.top}px`:void 0,bottom:(d==null?void 0:d.bottom)!==void 0?`${d.bottom}px`:void 0,left:(d==null?void 0:d.left)!==void 0?`${d.left}px`:void 0,right:(d==null?void 0:d.right)!==void 0?`${d.right}px`:void 0,maxHeight:d!=null&&d.maxHeight?`${d.maxHeight}px`:void 0,visibility:d?"visible":"hidden"},onClick:p=>p.stopPropagation(),children:t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2",children:[t.jsx("div",{className:"w-pop-title",children:"Backup Codes"}),t.jsxs("div",{className:"w-flex w-gap-2 w-none",children:[t.jsxs(se,{$outline:!0,$size:"sm",onClick:s,children:[t.jsx(Ga,{size:14}),"Copy"]}),t.jsxs(se,{$outline:!0,$size:"sm",onClick:r,children:[t.jsx(ml,{size:14}),"DownloadSimple"]})]})]}),t.jsx("p",{className:"w-pop-sub",children:"Save these backup codes in a secure location. Each code can only be used once."}),t.jsx("div",{className:"w-codes",children:e.map((p,u)=>t.jsx("span",{role:"button",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(p)},title:"Click to copy",children:p},u))}),t.jsxs("div",{className:"w-banner w-banner--warn",children:[t.jsx("span",{style:{fontSize:13.5},children:"⚠️"}),t.jsx("span",{className:"w-banner-txt",children:"Keep these codes safe! They won't be shown again."})]})]})}):null},I6=({onClose:e,onAddPasskey:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(!1),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,f]=o.useState(""),h=bt({contentRef:r,triggerRef:s??{current:null},isOpen:i,minWidth:320,defaultMaxHeight:260});o.useEffect(()=>{l(!0);const x=b=>{r.current&&!r.current.contains(b.target)&&e()},w=b=>{b.key==="Escape"&&e()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",w)}},[e]);const g=async()=>{if(!d){p(!0),f("");try{await a(m.trim()),e()}catch(x){f(x.message||"Failed to register passkey"),p(!1)}}};return i?t.jsxs("div",{ref:r,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(h==null?void 0:h.top)!==void 0?`${h.top}px`:void 0,bottom:(h==null?void 0:h.bottom)!==void 0?`${h.bottom}px`:void 0,left:(h==null?void 0:h.left)!==void 0?`${h.left}px`:void 0,right:(h==null?void 0:h.right)!==void 0?`${h.right}px`:void 0,maxHeight:h!=null&&h.maxHeight?`${h.maxHeight}px`:void 0,visibility:h?"visible":"hidden"},onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add Passkey"}),t.jsx(ye,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:m,onChange:x=>c(x.target.value),autoFocus:!0}),u&&t.jsx("span",{className:"w-input-err",children:u})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:g,disabled:d,children:d?"Registering...":"Continue"})]})]}):null},V6=({children:e})=>t.jsx("div",{className:"w-eyebrow",children:e}),z6=()=>{var na,ra,ia,oa,ie,ve,Ae;const{deployment:e}=Ce(),{user:a,updatePassword:s,removePassword:r,setupAuthenticator:i,verifyAuthenticator:l,deleteAuthenticator:m,generateBackupCodes:c,regenerateBackupCodes:d,updateProfile:p,getPasskeys:u,registerPasskey:f,deletePasskey:h}=ba(),{toast:g}=ta(),[x,w]=o.useState((a==null?void 0:a.second_factor_policy)||"none"),[b,j]=o.useState(!1),v=async J=>{try{await p({second_factor_policy:J}),w(J),g("2FA requirement updated successfully","info")}catch(be){g(be.message||"Failed to update 2FA requirement","error")}},[k,N]=o.useState(!1),[_,C]=o.useState(!1),[y,E]=o.useState(!1),[A,H]=o.useState(!1),M=o.useRef(null),T=o.useRef(null),P=o.useRef(null),S=o.useRef(null),[$,Z]=o.useState([]),[R,L]=o.useState(!1),[O,F]=o.useState(!1),[W,U]=o.useState(!1),[V,G]=o.useState(!1),[Y,de]=o.useState(null),fe=o.useRef(null),[ne,ae]=o.useState("table"),[re,Le]=o.useState(""),[K,at]=o.useState(""),[ze,We]=o.useState(""),[Re,ce]=o.useState(["",""]),[B,q]=o.useState([]),[X,oe]=o.useState(!1),[Ee,z]=o.useState(!1),[D]=o.useState(!1),[we,ge]=o.useState(!1),xe=(na=e==null?void 0:e.auth_settings)==null?void 0:na.auth_factors_enabled,lt=(ia=(ra=e==null?void 0:e.auth_settings)==null?void 0:ra.password)==null?void 0:ia.enabled;if(!(xe!=null&&xe.authenticator)&&!(xe!=null&&xe.backup_code)&&!lt)return null;const Qe=async(J,be)=>{await s(J,be),await a.refetch(),g("Password updated successfully","info")},Q=async J=>{await r(J),await a.refetch(),g("Password removed successfully","info")},le=()=>{var _t,Ke,wt,Bt,la,ca;if(!a)return!1;const J=(_t=a.user_email_addresses)==null?void 0:_t.some(da=>da.verified),be=(Ke=a.user_phone_numbers)==null?void 0:Ke.some(da=>da.verified),Je=a.social_connections&&a.social_connections.length>0,De=e==null?void 0:e.auth_settings;return(De==null?void 0:De.first_factor)==="email_otp"&&J||((wt=De==null?void 0:De.magic_link)==null?void 0:wt.enabled)&&J||((Bt=De==null?void 0:De.passkey)==null?void 0:Bt.enabled)||((la=De==null?void 0:De.auth_factors_enabled)==null?void 0:la.phone_otp)&&be||Je&&((ca=e==null?void 0:e.social_connections)==null?void 0:ca.some(da=>da.enabled))},me=async()=>{if(Re.some(J=>J.length!==6)){g("Please enter both 6-digit verification codes","error");return}try{if(z(!0),await l(ze,Re),await a.refetch(),xe!=null&&xe.backup_code){const J=await c();q(J),await a.refetch(),ae("backup")}else ae("success")}catch(J){g(J.message||"Invalid verification codes","error")}finally{z(!1)}},Te=()=>{ae("table"),Le(""),at(""),We(""),ce(["",""]),q([]),g("Two-factor authentication setup completed successfully!","info")},Pe=async()=>{var J;if((J=a==null?void 0:a.user_authenticator)!=null&&J.id)try{ge(!0),await m(a.user_authenticator.id),await a.refetch(),j(!1),g("Two-factor authentication removed successfully","info")}catch(be){g(be.message||"Failed to remove authenticator","error")}finally{ge(!1)}},qe=async()=>{if(!X)try{oe(!0);const J=await d();q(J),await a.refetch(),H(!0),g("New backup codes generated","info")}catch(J){g(J.message||"Failed to generate backup codes","error")}finally{oe(!1)}},pt=()=>{const J=B.join(`
116
+ */var M6={L:Wa.QrCode.Ecc.LOW,M:Wa.QrCode.Ecc.MEDIUM,Q:Wa.QrCode.Ecc.QUARTILE,H:Wa.QrCode.Ecc.HIGH},S0=128,E0="L",A0="#FFFFFF",M0="#000000",R0=!1,L0=1,R6=4,L6=0,P6=.1;function P0(e,a=0){const s=[];return e.forEach(function(r,i){let l=null;r.forEach(function(m,c){if(!m&&l!==null){s.push(`M${l+a} ${i+a}h${c-l}v1H${l+a}z`),l=null;return}if(c===r.length-1){if(!m)return;l===null?s.push(`M${c+a},${i+a} h1v1H${c+a}z`):s.push(`M${l+a},${i+a} h${c+1-l}v1H${l+a}z`);return}m&&l===null&&(l=c)})}),s.join("")}function $0(e,a){return e.slice().map((s,r)=>r<a.y||r>=a.y+a.h?s:s.map((i,l)=>l<a.x||l>=a.x+a.w?i:!1))}function $6(e,a,s,r){if(r==null)return null;const i=e.length+s*2,l=Math.floor(a*P6),m=i/a,c=(r.width||l)*m,d=(r.height||l)*m,p=r.x==null?e.length/2-c/2:r.x*m,u=r.y==null?e.length/2-d/2:r.y*m,f=r.opacity==null?1:r.opacity;let h=null;if(r.excavate){let x=Math.floor(p),w=Math.floor(u),b=Math.ceil(c+p-x),j=Math.ceil(d+u-w);h={x,y:w,w:b,h:j}}const g=r.crossOrigin;return{x:p,y:u,h:d,w:c,excavation:h,opacity:f,crossOrigin:g}}function O6(e,a){return a!=null?Math.max(Math.floor(a),0):e?R6:L6}function O0({value:e,level:a,minVersion:s,includeMargin:r,marginSize:i,imageSettings:l,size:m,boostLevel:c}){let d=o.useMemo(()=>{const x=(Array.isArray(e)?e:[e]).reduce((w,b)=>(w.push(...Wa.QrSegment.makeSegments(b)),w),[]);return Wa.QrCode.encodeSegments(x,M6[a],s,void 0,void 0,c)},[e,a,s,c]);const{cells:p,margin:u,numCells:f,calculatedImageSettings:h}=o.useMemo(()=>{let g=d.getModules();const x=O6(r,i),w=g.length+x*2,b=$6(g,m,x,l);return{cells:g,margin:x,numCells:w,calculatedImageSettings:b}},[d,m,l,r,i]);return{qrcode:d,margin:u,cells:p,numCells:f,calculatedImageSettings:h}}var Z6=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),H6=o.forwardRef(function(a,s){const r=a,{value:i,size:l=S0,level:m=E0,bgColor:c=A0,fgColor:d=M0,includeMargin:p=R0,minVersion:u=L0,boostLevel:f,marginSize:h,imageSettings:g}=r,w=hr(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=w,j=hr(w,["style"]),v=g==null?void 0:g.src,k=o.useRef(null),N=o.useRef(null),_=o.useCallback(S=>{k.current=S,typeof s=="function"?s(S):s&&(s.current=S)},[s]),[C,y]=o.useState(!1),{margin:E,cells:A,numCells:H,calculatedImageSettings:M}=O0({value:i,level:m,minVersion:u,boostLevel:f,includeMargin:p,marginSize:h,imageSettings:g,size:l});o.useEffect(()=>{if(k.current!=null){const S=k.current,$=S.getContext("2d");if(!$)return;let Z=A;const R=N.current,L=M!=null&&R!==null&&R.complete&&R.naturalHeight!==0&&R.naturalWidth!==0;L&&M.excavation!=null&&(Z=$0(A,M.excavation));const O=window.devicePixelRatio||1;S.height=S.width=l*O;const F=l/H*O;$.scale(F,F),$.fillStyle=c,$.fillRect(0,0,H,H),$.fillStyle=d,Z6?$.fill(new Path2D(P0(Z,E))):A.forEach(function(W,U){W.forEach(function(V,G){V&&$.fillRect(G+E,U+E,1,1)})}),M&&($.globalAlpha=M.opacity),L&&$.drawImage(R,M.x+E,M.y+E,M.w,M.h)}}),o.useEffect(()=>{y(!1)},[v]);const T=pr({height:l,width:l},b);let P=null;return v!=null&&(P=o.createElement("img",{src:v,key:v,style:{display:"none"},onLoad:()=>{y(!0)},ref:N,crossOrigin:M==null?void 0:M.crossOrigin})),o.createElement(o.Fragment,null,o.createElement("canvas",pr({style:T,height:l,width:l,ref:_,role:"img"},j)),P)});H6.displayName="QRCodeCanvas";var zr=o.forwardRef(function(a,s){const r=a,{value:i,size:l=S0,level:m=E0,bgColor:c=A0,fgColor:d=M0,includeMargin:p=R0,minVersion:u=L0,boostLevel:f,title:h,marginSize:g,imageSettings:x}=r,w=hr(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:j,numCells:v,calculatedImageSettings:k}=O0({value:i,level:m,minVersion:u,boostLevel:f,includeMargin:p,marginSize:g,imageSettings:x,size:l});let N=j,_=null;x!=null&&k!=null&&(k.excavation!=null&&(N=$0(j,k.excavation)),_=o.createElement("image",{href:x.src,height:k.h,width:k.w,x:k.x+b,y:k.y+b,preserveAspectRatio:"none",opacity:k.opacity,crossOrigin:k.crossOrigin}));const C=P0(N,b);return o.createElement("svg",pr({height:l,width:l,viewBox:`0 0 ${v} ${v}`,ref:s,role:"img"},w),!!h&&o.createElement("title",null,h),o.createElement("path",{fill:c,d:`M0,0 h${v}v${v}H0z`,shapeRendering:"crispEdges"}),o.createElement("path",{fill:d,d:C,shapeRendering:"crispEdges"}),_)});zr.displayName="QRCodeSVG";const Qi=({onClose:e,onChangePassword:a,triggerRef:s,isSetup:r=!1})=>{const i=o.useRef(null),[l,m]=o.useState(!1),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(""),[g,x]=o.useState(!1),[w,b]=o.useState(!1),[j,v]=o.useState(!1),[k,N]=o.useState(!1),[_,C]=o.useState({}),y=bt({contentRef:i,triggerRef:s??{current:null},isOpen:l,minWidth:380,defaultMaxHeight:420});o.useEffect(()=>{m(!0);const A=M=>{i.current&&!i.current.contains(M.target)&&e()},H=M=>{M.key==="Escape"&&e()};return document.addEventListener("mousedown",A),document.addEventListener("keydown",H),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",H)}},[e]);const E=async()=>{if(k)return;const A={};if(!r&&!c&&(A.currentPassword="Current password is required"),p?p.length<8&&(A.newPassword="Password must be at least 8 characters"):A.newPassword="New password is required",p!==f&&(A.confirmPassword="Passwords do not match"),Object.keys(A).length>0){C(A);return}N(!0);try{await a(r?"":c,p),e()}catch(H){C({form:H.message||"Failed to update password"})}finally{N(!1)}};return l?t.jsxs("div",{ref:i,className:"w-pop",style:{position:"fixed",zIndex:1001,width:380,maxWidth:"calc(100vw - 24px)",top:(y==null?void 0:y.top)!==void 0?`${y.top}px`:void 0,bottom:(y==null?void 0:y.bottom)!==void 0?`${y.bottom}px`:void 0,left:(y==null?void 0:y.left)!==void 0?`${y.left}px`:void 0,right:(y==null?void 0:y.right)!==void 0?`${y.right}px`:void 0,maxHeight:y!=null&&y.maxHeight?`${y.maxHeight}px`:void 0,visibility:y?"visible":"hidden"},onClick:A=>A.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:r?"Set Password":"Change Password"}),t.jsx("p",{className:"w-pop-sub",children:r?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."})]}),!r&&t.jsxs("div",{className:"w-field",children:[t.jsx(Ve,{children:"Current Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(ye,{type:g?"text":"password",placeholder:"Enter your current password",value:c,onChange:A=>d(A.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>x(!g),"aria-label":g?"Hide current password":"Show current password",children:g?t.jsx(Sn,{size:16}):t.jsx(Nn,{size:16})})]}),_.currentPassword&&t.jsx("span",{className:"w-input-err",children:_.currentPassword})]}),t.jsxs("div",{className:"w-field",children:[t.jsx(Ve,{children:r?"Password":"New Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(ye,{type:w?"text":"password",placeholder:r?"Enter your password":"Enter your new password",value:p,onChange:A=>u(A.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>b(!w),"aria-label":w?"Hide new password":"Show new password",children:w?t.jsx(Sn,{size:16}):t.jsx(Nn,{size:16})})]}),_.newPassword&&t.jsx("span",{className:"w-input-err",children:_.newPassword})]}),t.jsxs("div",{className:"w-field",children:[t.jsx(Ve,{children:"Confirm New Password"}),t.jsxs("div",{className:"w-input-wrap",children:[t.jsx(ye,{type:j?"text":"password",placeholder:"Confirm your new password",value:f,onChange:A=>h(A.target.value),style:{paddingRight:40}}),t.jsx("button",{type:"button",className:"w-input-eye",onClick:()=>v(!j),"aria-label":j?"Hide confirm password":"Show confirm password",children:j?t.jsx(Sn,{size:16}):t.jsx(Nn,{size:16})})]}),_.confirmPassword&&t.jsx("span",{className:"w-input-err",children:_.confirmPassword})]}),_.form&&t.jsx("span",{className:"w-input-err",children:_.form})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:E,disabled:k,children:k?r?"Setting...":"Updating...":r?"Set Password":"Update Password"})]})]}):null},F6=({onClose:e,onRemovePassword:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(!1),[m,c]=o.useState(""),[d,p]=o.useState(!1),{toast:u}=ta(),f=bt({contentRef:r,triggerRef:s??{current:null},isOpen:i,minWidth:400,defaultMaxHeight:360});o.useEffect(()=>{l(!0);const g=w=>{r.current&&!r.current.contains(w.target)&&e()},x=w=>{w.key==="Escape"&&e()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[e]);const h=async()=>{if(!(!m||d)){p(!0);try{await a(m),e()}catch(g){const x=g.message||"Failed to remove password. Please try again.";u(x,"error")}finally{p(!1)}}};return i?t.jsxs("div",{ref:r,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(f==null?void 0:f.top)!==void 0?`${f.top}px`:void 0,bottom:(f==null?void 0:f.bottom)!==void 0?`${f.bottom}px`:void 0,left:(f==null?void 0:f.left)!==void 0?`${f.left}px`:void 0,right:(f==null?void 0:f.right)!==void 0?`${f.right}px`:void 0,maxHeight:f!=null&&f.maxHeight?`${f.maxHeight}px`:void 0,visibility:f?"visible":"hidden"},onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Remove Password"}),t.jsxs("div",{className:"w-banner w-banner--warn",children:[t.jsx(Fa,{size:16}),t.jsx("span",{className:"w-banner-txt",children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})]}),t.jsxs(Ge,{children:[t.jsx(Ve,{htmlFor:"current-password",children:"Confirm your current password"}),t.jsx(ye,{id:"current-password",type:"password",placeholder:"Enter current password",value:m,onChange:g=>c(g.target.value),autoFocus:!0})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--danger-solid w-btn--sm",onClick:h,disabled:!m||d,children:d?"Removing...":"Remove Password"})]})]}):null},T6=({onClose:e,onSetupTOTP:a,onVerifyTOTP:s,triggerRef:r})=>{const i=o.useRef(null),[l,m]=o.useState("qr"),[c,d]=o.useState(""),[p,u]=o.useState(""),[f,h]=o.useState(["",""]),[g,x]=o.useState(!1),[w,b]=o.useState(!1),{toast:j}=ta(),v=bt({contentRef:i,triggerRef:r??{current:null},isOpen:w,minWidth:380,defaultMaxHeight:460});o.useEffect(()=>{b(!0);const N=C=>{i.current&&!i.current.contains(C.target)&&e()},_=C=>{C.key==="Escape"&&e()};return document.addEventListener("mousedown",N),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",_)}},[e]),o.useEffect(()=>{(async()=>{x(!0);try{const _=await a();d(_.otp_url||""),u(_.totp_secret||"")}catch(_){const C=_.message||"Failed to setup two-factor authentication. Please try again.";j(C,"error")}finally{x(!1)}})()},[]);const k=async()=>{if(!f.some(N=>N.length!==6)){x(!0);try{await s(f),e()}catch(N){const _=N.message||"Failed to verify codes. Please check your authenticator app and try again.";j(_,"error")}finally{x(!1)}}};return w?t.jsx("div",{ref:i,className:"w-pop",style:{position:"fixed",zIndex:1001,width:340,maxWidth:"calc(100vw - 24px)",top:(v==null?void 0:v.top)!==void 0?`${v.top}px`:void 0,bottom:(v==null?void 0:v.bottom)!==void 0?`${v.bottom}px`:void 0,left:(v==null?void 0:v.left)!==void 0?`${v.left}px`:void 0,right:(v==null?void 0:v.right)!==void 0?`${v.right}px`:void 0,maxHeight:v!=null&&v.maxHeight?`${v.maxHeight}px`:void 0,visibility:v?"visible":"hidden"},onClick:N=>N.stopPropagation(),children:l==="qr"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Setup Two-Factor Authentication"}),t.jsx("p",{className:"w-pop-sub",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"})]}),t.jsx("div",{className:"w-flex w-justify-center",children:g?t.jsx("div",{className:"w-qr w-text-muted",children:"Loading..."}):c?t.jsx("div",{className:"w-qr",style:{background:"#fff",padding:8},children:t.jsx(zr,{value:c,size:130,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):t.jsx("div",{className:"w-qr w-text-error",children:"QR Code Not Available"})}),p&&t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-secsub",children:"Or enter manually:"}),t.jsx("div",{className:"w-token",children:t.jsx("code",{style:{wordBreak:"break-all"},children:p})})]})]}),t.jsx("div",{className:"w-pop-foot",children:t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:()=>m("verify"),disabled:g||!c,children:"I've Scanned the Code"})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-pop-title",children:"Verify Your Authenticator"}),t.jsx("p",{className:"w-pop-sub",children:"Enter two consecutive codes from your authenticator app"})]}),t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsx(ye,{id:"totp-code-1",type:"text",placeholder:"000000",value:f[0],onChange:N=>{const _=N.target.value.replace(/[^0-9]/g,"").substring(0,6);h([_,f[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"var(--wa-font-mono)"},"aria-label":"First verification code from authenticator app"}),t.jsx(ye,{id:"totp-code-2",type:"text",placeholder:"000000",value:f[1],onChange:N=>{const _=N.target.value.replace(/[^0-9]/g,"").substring(0,6);h([f[0],_])},maxLength:6,style:{textAlign:"center",fontFamily:"var(--wa-font-mono)"},"aria-label":"Second verification code from authenticator app"})]})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:()=>m("qr"),children:"Back"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:k,disabled:g||f.some(N=>N.length!==6),children:g?"Verifying...":"Verify"})]})]})}):null},I6=({codes:e,onClose:a,onCopy:s,onDownload:r,triggerRef:i})=>{const l=o.useRef(null),[m,c]=o.useState(!1),d=bt({contentRef:l,triggerRef:i??{current:null},isOpen:m,minWidth:380,defaultMaxHeight:360});return o.useEffect(()=>{c(!0);const p=f=>{l.current&&!l.current.contains(f.target)&&a()},u=f=>{f.key==="Escape"&&a()};return document.addEventListener("mousedown",p),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",u)}},[a]),m?t.jsx("div",{ref:l,className:"w-pop",style:{position:"fixed",zIndex:1001,width:380,maxWidth:"calc(100vw - 24px)",top:(d==null?void 0:d.top)!==void 0?`${d.top}px`:void 0,bottom:(d==null?void 0:d.bottom)!==void 0?`${d.bottom}px`:void 0,left:(d==null?void 0:d.left)!==void 0?`${d.left}px`:void 0,right:(d==null?void 0:d.right)!==void 0?`${d.right}px`:void 0,maxHeight:d!=null&&d.maxHeight?`${d.maxHeight}px`:void 0,visibility:d?"visible":"hidden"},onClick:p=>p.stopPropagation(),children:t.jsxs("div",{className:"w-pop-body",children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2",children:[t.jsx("div",{className:"w-pop-title",children:"Backup Codes"}),t.jsxs("div",{className:"w-flex w-gap-2 w-none",children:[t.jsxs(se,{$outline:!0,$size:"sm",onClick:s,children:[t.jsx(Ga,{size:14}),"Copy"]}),t.jsxs(se,{$outline:!0,$size:"sm",onClick:r,children:[t.jsx(ml,{size:14}),"DownloadSimple"]})]})]}),t.jsx("p",{className:"w-pop-sub",children:"Save these backup codes in a secure location. Each code can only be used once."}),t.jsx("div",{className:"w-codes",children:e.map((p,u)=>t.jsx("span",{role:"button",style:{cursor:"pointer"},onClick:()=>{navigator.clipboard.writeText(p)},title:"Click to copy",children:p},u))}),t.jsxs("div",{className:"w-banner w-banner--warn",children:[t.jsx("span",{style:{fontSize:13.5},children:"⚠️"}),t.jsx("span",{className:"w-banner-txt",children:"Keep these codes safe! They won't be shown again."})]})]})}):null},V6=({onClose:e,onAddPasskey:a,triggerRef:s})=>{const r=o.useRef(null),[i,l]=o.useState(!1),[m,c]=o.useState(""),[d,p]=o.useState(!1),[u,f]=o.useState(""),h=bt({contentRef:r,triggerRef:s??{current:null},isOpen:i,minWidth:320,defaultMaxHeight:260});o.useEffect(()=>{l(!0);const x=b=>{r.current&&!r.current.contains(b.target)&&e()},w=b=>{b.key==="Escape"&&e()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",w)}},[e]);const g=async()=>{if(!d){p(!0),f("");try{await a(m.trim()),e()}catch(x){f(x.message||"Failed to register passkey"),p(!1)}}};return i?t.jsxs("div",{ref:r,className:"w-pop",style:{position:"fixed",zIndex:1001,maxWidth:"calc(100vw - 24px)",top:(h==null?void 0:h.top)!==void 0?`${h.top}px`:void 0,bottom:(h==null?void 0:h.bottom)!==void 0?`${h.bottom}px`:void 0,left:(h==null?void 0:h.left)!==void 0?`${h.left}px`:void 0,right:(h==null?void 0:h.right)!==void 0?`${h.right}px`:void 0,maxHeight:h!=null&&h.maxHeight?`${h.maxHeight}px`:void 0,visibility:h?"visible":"hidden"},onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"w-pop-body",children:[t.jsx("div",{className:"w-pop-title",children:"Add Passkey"}),t.jsx(ye,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:m,onChange:x=>c(x.target.value),autoFocus:!0}),u&&t.jsx("span",{className:"w-input-err",children:u})]}),t.jsxs("div",{className:"w-pop-foot",children:[t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:e,children:"Cancel"}),t.jsx("button",{className:"w-btn w-btn--primary w-btn--sm",style:{width:"auto"},onClick:g,disabled:d,children:d?"Registering...":"Continue"})]})]}):null},z6=({children:e})=>t.jsx("div",{className:"w-eyebrow",children:e}),D6=()=>{var na,ra,ia,oa,ie,ve,Ae;const{deployment:e}=Ce(),{user:a,updatePassword:s,removePassword:r,setupAuthenticator:i,verifyAuthenticator:l,deleteAuthenticator:m,generateBackupCodes:c,regenerateBackupCodes:d,updateProfile:p,getPasskeys:u,registerPasskey:f,deletePasskey:h}=ba(),{toast:g}=ta(),[x,w]=o.useState((a==null?void 0:a.second_factor_policy)||"none"),[b,j]=o.useState(!1),v=async J=>{try{await p({second_factor_policy:J}),w(J),g("2FA requirement updated successfully","info")}catch(be){g(be.message||"Failed to update 2FA requirement","error")}},[k,N]=o.useState(!1),[_,C]=o.useState(!1),[y,E]=o.useState(!1),[A,H]=o.useState(!1),M=o.useRef(null),T=o.useRef(null),P=o.useRef(null),S=o.useRef(null),[$,Z]=o.useState([]),[R,L]=o.useState(!1),[O,F]=o.useState(!1),[W,U]=o.useState(!1),[V,G]=o.useState(!1),[Y,de]=o.useState(null),fe=o.useRef(null),[ne,ae]=o.useState("table"),[re,Le]=o.useState(""),[K,at]=o.useState(""),[ze,We]=o.useState(""),[Re,ce]=o.useState(["",""]),[B,q]=o.useState([]),[X,oe]=o.useState(!1),[Ee,z]=o.useState(!1),[D]=o.useState(!1),[we,ge]=o.useState(!1),xe=(na=e==null?void 0:e.auth_settings)==null?void 0:na.auth_factors_enabled,lt=(ia=(ra=e==null?void 0:e.auth_settings)==null?void 0:ra.password)==null?void 0:ia.enabled;if(!(xe!=null&&xe.authenticator)&&!(xe!=null&&xe.backup_code)&&!lt)return null;const Qe=async(J,be)=>{await s(J,be),await a.refetch(),g("Password updated successfully","info")},Q=async J=>{await r(J),await a.refetch(),g("Password removed successfully","info")},le=()=>{var _t,Ke,wt,Bt,la,ca;if(!a)return!1;const J=(_t=a.user_email_addresses)==null?void 0:_t.some(da=>da.verified),be=(Ke=a.user_phone_numbers)==null?void 0:Ke.some(da=>da.verified),Je=a.social_connections&&a.social_connections.length>0,De=e==null?void 0:e.auth_settings;return(De==null?void 0:De.first_factor)==="email_otp"&&J||((wt=De==null?void 0:De.magic_link)==null?void 0:wt.enabled)&&J||((Bt=De==null?void 0:De.passkey)==null?void 0:Bt.enabled)||((la=De==null?void 0:De.auth_factors_enabled)==null?void 0:la.phone_otp)&&be||Je&&((ca=e==null?void 0:e.social_connections)==null?void 0:ca.some(da=>da.enabled))},me=async()=>{if(Re.some(J=>J.length!==6)){g("Please enter both 6-digit verification codes","error");return}try{if(z(!0),await l(ze,Re),await a.refetch(),xe!=null&&xe.backup_code){const J=await c();q(J),await a.refetch(),ae("backup")}else ae("success")}catch(J){g(J.message||"Invalid verification codes","error")}finally{z(!1)}},Te=()=>{ae("table"),Le(""),at(""),We(""),ce(["",""]),q([]),g("Two-factor authentication setup completed successfully!","info")},Pe=async()=>{var J;if((J=a==null?void 0:a.user_authenticator)!=null&&J.id)try{ge(!0),await m(a.user_authenticator.id),await a.refetch(),j(!1),g("Two-factor authentication removed successfully","info")}catch(be){g(be.message||"Failed to remove authenticator","error")}finally{ge(!1)}},qe=async()=>{if(!X)try{oe(!0);const J=await d();q(J),await a.refetch(),H(!0),g("New backup codes generated","info")}catch(J){g(J.message||"Failed to generate backup codes","error")}finally{oe(!1)}},pt=()=>{const J=B.join(`
117
117
  `);navigator.clipboard.writeText(J).then(()=>{g("Backup codes copied to clipboard","info")}).catch(()=>{g("Failed to copy backup codes","error")})},aa=()=>{const J=B.join(`
118
- `),be=new Blob([J],{type:"text/plain"}),Je=URL.createObjectURL(be),De=document.createElement("a");De.href=Je,De.download="wacht-backup-codes.txt",De.click(),URL.revokeObjectURL(Je),g("Backup codes downloaded","info")},Tt=async()=>{var J,be;if((be=(J=e==null?void 0:e.auth_settings)==null?void 0:J.passkey)!=null&&be.enabled)try{L(!0);const Je=await u();Z(Je.data||[])}catch{g("Failed to load passkeys","error")}finally{L(!1)}},sa=async J=>{try{F(!0),await f(J||void 0),await Tt(),g("Passkey registered successfully!","info")}catch(be){throw g(be.message||"Failed to register passkey","error"),be}finally{F(!1)}},Wt=async J=>{try{await h(J),await Tt(),g("Passkey removed","info")}catch(be){g(be.message||"Failed to remove passkey","error")}};o.useEffect(()=>{Tt()},[(ie=(oa=e==null?void 0:e.auth_settings)==null?void 0:oa.passkey)==null?void 0:ie.enabled]);const yt=[];return lt&&yt.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:a!=null&&a.has_password?"Enabled":"Disabled",actions:a!=null&&a.has_password?["change"]:["setup"],group:"sign-in"}),(Ae=(ve=e==null?void 0:e.auth_settings)==null?void 0:ve.passkey)!=null&&Ae.enabled&&yt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:$.length>0?`${$.length} registered`:"",actions:$.length>0?["manage","add"]:["add"],group:"sign-in"}),xe!=null&&xe.authenticator&&yt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:a!=null&&a.user_authenticator?"Enabled":"Disabled",actions:a!=null&&a.user_authenticator?["remove"]:["setup"],group:"sign-in"}),a!=null&&a.user_authenticator&&yt.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:a!=null&&a.backup_codes_generated?"Generated":"Not Generated",actions:["generate"],group:"recovery"}),a!=null&&a.user_authenticator&&yt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:x==="enforced"?"Enforced":"Optional",actions:["toggle"],group:"recovery"}),ne!=="table"?t.jsxs(t.Fragment,{children:[t.jsxs(w0,{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(Xt,{size:16}),t.jsxs("span",{className:"w-sec",children:[ne==="qr"&&"Setup Two-Factor Authentication",ne==="verify"&&"Verify Your Authenticator",ne==="backup"&&"Save Your Backup Codes",ne==="success"&&"Setup Complete!"]})]}),t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("table"),children:"← Back"})]}),t.jsxs("div",{className:"w-narrow w-flex-col w-items-center w-gap-5",style:{textAlign:"center"},children:[ne==="qr"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),t.jsx("div",{className:"w-flex w-justify-center",children:D?t.jsxs("div",{className:"w-qr w-flex-col w-items-center w-gap-3",children:[t.jsx("span",{className:"w-spin"}),t.jsx("div",{className:"w-secsub",children:"Loading QR Code..."})]}):re?t.jsx("div",{className:"w-tile w-flex w-items-center w-justify-center",children:t.jsx(zr,{value:re,size:200,level:"M",marginSize:0})}):t.jsx("div",{className:"w-qr w-text-error",children:"QR Code Not Available"})}),t.jsxs("div",{className:"w-flex-col w-gap-2 w-full",children:[t.jsx("p",{className:"w-secsub",children:"Or enter this code manually:"}),t.jsx("div",{className:"w-token",children:t.jsx("code",{children:K||"Loading..."})})]}),t.jsx(se,{$fullWidth:!0,onClick:()=>ae("verify"),disabled:!re||!K,children:"I've Scanned the Code"})]}),ne==="verify"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Enter two consecutive codes from your authenticator app to verify setup"}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(ye,{type:"text",placeholder:"000000",value:Re[0],onChange:J=>{const be=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([be,Re[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}}),t.jsx(ye,{type:"text",placeholder:"000000",value:Re[1],onChange:J=>{const be=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([Re[0],be])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}})]}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("qr"),children:"Back"}),t.jsx(se,{$size:"sm",onClick:me,disabled:Ee||Re.some(J=>J.length!==6),children:Ee?"Verifying...":"Verify & Continue"})]})]}),ne==="backup"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-banner w-banner--warn",style:{textAlign:"left"},children:[t.jsx(Fa,{size:16}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Important!"}),t.jsx("div",{className:"w-banner-txt",children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),t.jsx("div",{className:"w-codes w-full",children:B.map((J,be)=>t.jsx("span",{onClick:()=>navigator.clipboard.writeText(J),style:{cursor:"pointer"},children:J},be))}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:pt,children:"Copy All"}),t.jsxs(se,{$outline:!0,$size:"sm",onClick:aa,children:[t.jsx(ml,{size:16}),"DownloadSimple"]})]}),t.jsx(se,{$fullWidth:!0,onClick:Te,children:"Complete Setup"})]}),ne==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{size:26})})]}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-items-center",children:[t.jsx("h3",{className:"w-title",children:"All Set!"}),t.jsx("p",{className:"w-secsub",children:"Your account is now protected with two-factor authentication."})]}),t.jsx(se,{$fullWidth:!0,onClick:Te,children:"Continue to Security"})]})]})]}):t.jsx(t.Fragment,{children:yt.length?t.jsx("div",{children:yt.map((J,be)=>{const Je=be>0?yt[be-1].group:null,De=J.group!==Je,jt=yt[be+1],_t=jt&&jt.group===J.group;return t.jsxs("div",{children:[De&&t.jsx(V6,{$first:be===0,children:J.group==="sign-in"?"Sign-in methods":"Recovery"}),t.jsxs(g0,{children:[t.jsxs(x0,{children:[t.jsx("div",{className:"w-flex w-items-center w-wrap w-gap-2 w-sec",children:t.jsx("span",{children:J.name})}),t.jsx("div",{className:"w-secsub",children:J.description})]}),t.jsx(v0,{children:t.jsxs("div",{className:"w-relative",children:[J.id==="password"&&t.jsx(t.Fragment,{children:a!=null&&a.has_password?t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Change"}),_&&t.jsx(Qi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Qe})]}),le()&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",ref:P,onClick:()=>E(!0),children:"Remove"}),y&&t.jsx(H6,{triggerRef:P,onClose:()=>E(!1),onRemovePassword:Q})]})]}):t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Setup"}),_&&t.jsx(Qi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Qe,isSetup:!0})]})}),J.id==="authenticator"&&!(a!=null&&a.user_authenticator)&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:M,onClick:()=>N(!0),disabled:D,children:D?"Setting up...":"Setup"}),k&&t.jsx(F6,{triggerRef:M,onClose:()=>N(!1),onSetupTOTP:async()=>{const Ke=await i();return We(Ke.id),Ke},onVerifyTOTP:async Ke=>{await l(ze,Ke),await a.refetch(),g("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(a==null?void 0:a.user_authenticator)&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>j(!0),disabled:we,children:we?"Removing...":"Remove"}),b&&t.jsx(Qa,{title:"Remove MFA and reset policy to default?",onConfirm:Pe,onCancel:()=>j(!1)})]}),J.id==="backup_codes"&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:S,onClick:qe,disabled:X,children:X?"Generating...":a!=null&&a.backup_codes_generated?"Regenerate":"Generate"}),A&&t.jsx(T6,{triggerRef:S,codes:B,onClose:()=>H(!1),onCopy:pt,onDownload:aa})]})}),J.id==="second_factor_policy"&&t.jsx(Za,{checked:x==="enforced",onChange:Ke=>{v(Ke?"enforced":"none")}}),J.id==="passkey"&&t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsxs(se,{$outline:!0,$size:"sm",onClick:()=>U(!W),children:[W?"Hide":"Manage"," ","(",$.length,")",t.jsx(Ut,{size:14,style:{transform:W?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:fe,onClick:()=>G(!0),disabled:O,children:O?"Adding...":"Add"}),V&&t.jsx(I6,{triggerRef:fe,onClose:()=>G(!1),onAddPasskey:sa})]})]})]})})]}),J.id==="passkey"&&W&&t.jsx("div",{className:"w-flex-col w-gap-2",children:R?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):$.length===0?t.jsx("div",{className:"w-empty",children:t.jsx("p",{children:"No passkeys registered yet"})}):t.jsx("div",{className:"w-flex-col w-gap-2",children:$.map(Ke=>t.jsxs("div",{className:"w-locked w-flex w-items-center w-justify-between",style:{height:"auto",padding:"10px 12px"},children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:Ke.name||"Unnamed Passkey"}),t.jsxs("span",{className:"w-secsub",children:[Ke.device_type==="platform"?"This device":"Security key",Ke.last_used_at&&` • Last used ${new Date(Ke.last_used_at).toLocaleDateString()}`]})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>de(Ke.id),children:"Remove"}),Y===Ke.id&&t.jsx(Qa,{title:`Remove "${Ke.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Wt(Ke.id),de(null)},onCancel:()=>de(null)})]})]},Ke.id))})}),_t&&t.jsx("div",{className:"w-hr"})]},J.id)})}):t.jsx(Nt,{title:"No security features available",description:"Contact your administrator to enable security features."})})},D6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#d93025"}),t.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),t.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#fcc934"}),t.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),t.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),t.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),t.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),t.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),t.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),t.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),t.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),t.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),U6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[t.jsx("stop",{offset:.1,stopColor:"#ffe226"}),t.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),t.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[t.jsx("stop",{offset:.3,stopColor:"#960e18"}),t.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),t.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),t.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),t.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),t.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[t.jsx("stop",{offset:.13,stopColor:"#fff44f"}),t.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),t.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[t.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),t.jsx("stop",{offset:.67,stopColor:"#9059ff"}),t.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),t.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[t.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),t.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),t.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[t.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),t.jsx("stop",{offset:.28,stopColor:"#ff980e"}),t.jsx("stop",{offset:.47,stopColor:"#ff3750"}),t.jsx("stop",{offset:.78,stopColor:"#eb0878"}),t.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),t.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[t.jsx("stop",{offset:.11,stopColor:"#fff44f"}),t.jsx("stop",{offset:.46,stopColor:"#ff980e"}),t.jsx("stop",{offset:.72,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[t.jsx("stop",{offset:0,stopColor:"#fff44f"}),t.jsx("stop",{offset:.3,stopColor:"#ff980e"}),t.jsx("stop",{offset:.57,stopColor:"#ff3647"}),t.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[t.jsx("stop",{offset:.14,stopColor:"#fff44f"}),t.jsx("stop",{offset:.48,stopColor:"#ff980e"}),t.jsx("stop",{offset:.66,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[t.jsx("stop",{offset:.09,stopColor:"#fff44f"}),t.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),t.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[t.jsx("stop",{offset:.05,stopColor:"#fff44f"}),t.jsx("stop",{offset:.37,stopColor:"#ff980e"}),t.jsx("stop",{offset:.53,stopColor:"#ff3647"}),t.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),t.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[t.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),t.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),t.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),t.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),t.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),t.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),t.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),t.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),t.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),t.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),W6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"b",children:[t.jsx("stop",{offset:0,stopColor:"#06c2e7"}),t.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),t.jsx("stop",{offset:.5,stopColor:"#12aef1"}),t.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),t.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),t.jsxs("linearGradient",{id:"a",children:[t.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),t.jsx("stop",{offset:1,stopColor:"#fff"})]}),t.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),t.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:.958})}),t.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:3.564})}),t.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),t.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),t.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),t.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),t.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),B6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.7,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.8,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#35c1f1"}),t.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),t.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),t.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),t.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),t.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#66eb6e"}),t.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),t.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#0c59a4"}),t.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),t.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1b9de2"}),t.jsx("stop",{offset:.2,stopColor:"#1595df"}),t.jsx("stop",{offset:.7,stopColor:"#0680d7"}),t.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),G6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Opera",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),t.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),t.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),t.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),q6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Brave",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),t.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),t.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),t.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),t.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),t.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),K6=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"w-text-secondary",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),t.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),t.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),t.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),Y6=({browser:e})=>{const a=(e==null?void 0:e.toLowerCase())||"",s={width:20,height:20};return a.includes("chrome")?t.jsx(D6,{...s}):a.includes("firefox")?t.jsx(U6,{...s}):a.includes("safari")?t.jsx(W6,{...s}):a.includes("edge")?t.jsx(B6,{...s}):a.includes("opera")?t.jsx(G6,{...s}):a.includes("brave")?t.jsx(q6,{...s}):t.jsx(K6,{})},Q6=()=>{const{signins:e,removeSignin:a,refetch:s,loading:r}=Eo(),{refetch:i}=ot(),{toast:l}=ta(),m=e,c=async p=>{try{await a(p),await Promise.all([s(),i()]),l("Session ended successfully","info")}catch(u){l(u.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const u=new Date(p);if(isNaN(u.getTime()))return"Unknown";const h=Math.floor((new Date().getTime()-u.getTime())/(1e3*60));return h<1?"Just now":h<60?`${h}m ago`:h<1440?`${Math.floor(h/60)}h ago`:u.toLocaleDateString()};return r?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):t.jsx("div",{children:m&&m.length>0?t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Browser & Device"}),t.jsx(Fe,{children:"Location"}),t.jsx(Fe,{children:"Last Active"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:m.map(p=>t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(Vr,{children:t.jsx(Y6,{browser:p.browser||"Unknown"})}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&t.jsx("div",{className:"w-text-muted",children:p.device})]})]})}),t.jsx(Xe,{children:t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&t.jsx("div",{className:"w-text-muted",children:p.ip_address})]})}),t.jsx(Xe,{children:d(p.last_active_at)}),t.jsx(Ft,{children:t.jsxs(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>c(p.id),children:[t.jsx(Aa,{size:12}),"Sign out"]})})]},p.id))})]})})}):t.jsx(Nt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})},J6=(e,a)=>`${(e==null?void 0:e[0])||""}${(a==null?void 0:a[0])||""}`.toUpperCase()||"U",Z0=()=>{var N,_,C,y,E,A,H,M;const{loading:e,user:a,updateProfilePicture:s}=ba(),{deployment:r}=Ce(),[i,l]=o.useState("profile"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((T,P="info")=>{c(T),p(P),setTimeout(()=>c(null),3e3)},[c]),x=async T=>{var S;const P=(S=T.target.files)==null?void 0:S[0];if(P){if(P.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!P.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s(P),await(a==null?void 0:a.refetch()),g("Profile picture updated","info")}catch($){g(($==null?void 0:$.message)||"Failed to update profile picture","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(e)return t.jsx($e,{children:t.jsx(mr,{className:"w-flex w-items-center w-justify-center",children:t.jsx(_e,{})})});const w=r==null?void 0:r.auth_settings,b=(N=w==null?void 0:w.email_address)==null?void 0:N.enabled,j=(_=w==null?void 0:w.phone_number)==null?void 0:_.enabled,v=((C=r==null?void 0:r.social_connections)==null?void 0:C.some(T=>T.enabled))||!1,k=((y=w==null?void 0:w.password)==null?void 0:y.enabled)||((E=w==null?void 0:w.auth_factors_enabled)==null?void 0:E.authenticator)||((A=w==null?void 0:w.auth_factors_enabled)==null?void 0:A.phone_otp)||((H=w==null?void 0:w.auth_factors_enabled)==null?void 0:H.backup_code);return t.jsx($e,{children:t.jsx(m0,{children:t.jsx(u0.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(mr,{className:"w-relative",children:[a&&t.jsxs(y0,{className:"mac-page-header",children:[t.jsxs("button",{type:"button",className:"w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var T;return(T=h.current)==null?void 0:T.click()},disabled:u,title:"Change profile picture","aria-label":"Change profile picture",children:[t.jsx("span",{className:"w-avatar w-avatar--lg",children:a.profile_picture_url?t.jsx("img",{src:a.profile_picture_url,alt:""}):J6(a.first_name,a.last_name)}),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(sn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(j0,{children:[t.jsx(_0,{children:`${a.first_name||""} ${a.last_name||""}`.trim()||a.username||"Account"}),((M=a.primary_email_address)==null?void 0:M.email)&&t.jsx(k0,{children:a.primary_email_address.email})]})]}),t.jsx(p0,{children:t.jsxs(h0,{children:[t.jsx(ka,{$isActive:i==="profile",onClick:()=>l("profile"),children:t.jsxs(Ca,{children:[t.jsx(hs,{size:16}),"Profile"]})}),b&&t.jsx(ka,{$isActive:i==="email",onClick:()=>l("email"),children:t.jsxs(Ca,{children:[t.jsx(hl,{size:16}),"Email"]})}),j&&t.jsx(ka,{$isActive:i==="phone",onClick:()=>l("phone"),children:t.jsxs(Ca,{children:[t.jsx(Vu,{size:16}),"Phone"]})}),v&&t.jsx(ka,{$isActive:i==="social",onClick:()=>l("social"),children:t.jsxs(Ca,{children:[t.jsx(Iu,{size:16}),"Connections"]})}),k&&t.jsx(ka,{$isActive:i==="security",onClick:()=>l("security"),children:t.jsxs(Ca,{children:[t.jsx(Xt,{size:16}),"Security"]})}),t.jsx(ka,{$isActive:i==="sessions",onClick:()=>l("sessions"),children:t.jsxs(Ca,{children:[t.jsx(zu,{size:16}),"Sessions"]})})]})}),t.jsxs(f0,{children:[i==="profile"&&t.jsx(j6,{}),i==="email"&&b&&t.jsx(_6,{}),i==="phone"&&j&&t.jsx(k6,{}),i==="social"&&v&&t.jsx(S6,{}),i==="security"&&k&&t.jsx(z6,{}),i==="sessions"&&t.jsx(Q6,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,style:{minWidth:0},children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Fa,{size:12}):t.jsx(Ye,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},H0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{className:"w-dialog--panel",children:[r&&t.jsx(Ue.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(Z0,{}),l&&t.jsx(Ue.Footer,{children:l})]})})}),Oe=(...e)=>e.filter(Boolean).join(" "),X6=e=>t.jsx("div",{...e,className:Oe("w-relative",e.className)}),F0=o.forwardRef((e,a)=>t.jsx("button",{...e,ref:a,className:Oe("w-acct",e.className),style:{width:"auto",margin:0,padding:4,gap:8,...e.style}}));F0.displayName="AccountButton";const ep=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","w-avatar--md",a.className),style:{width:28,height:28,fontSize:11,...a.style},children:e}),tp=e=>t.jsx("div",{...e,className:Oe("w-sec","w-text-secondary",e.className)}),T0=o.forwardRef(({$position:e,$isOpen:a,$maxHeight:s,children:r,...i},l)=>t.jsx("div",{...i,ref:l,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:s?`${s}px`:"calc(100vh - 48px)",overflowY:"auto",zIndex:99999,top:(e==null?void 0:e.top)!==void 0?`${e.top}px`:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?`${e.bottom}px`:void 0,left:(e==null?void 0:e.left)!==void 0?`${e.left}px`:void 0,right:(e==null?void 0:e.right)!==void 0?`${e.right}px`:void 0,visibility:e&&a?"visible":"hidden",opacity:a&&e?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,padding:0},children:r}));T0.displayName="DropdownContainer";const I0=o.forwardRef(({$top:e,$left:a,$isOpen:s,$maxHeight:r,children:i,...l},m)=>t.jsx("div",{...l,ref:m,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:`${r}px`,overflowY:"auto",zIndex:99999,display:"flex",flexDirection:"column",top:`${e}px`,left:`${a}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${s?"0s":"0.15s"}`,padding:0},children:i}));I0.displayName="SidePanel";const Ji=e=>t.jsx("hr",{...e,className:Oe("w-hr",e.className)}),ap=e=>t.jsx("div",{...e,style:{padding:"16px 14px 8px",...e.style}}),sp=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-gap-3",e.className)}),np=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","w-avatar--lg",a.className),children:e}),rp=e=>t.jsx("div",{...e,className:Oe("w-flex-col","w-grow",e.className),style:{gap:2,...e.style}}),ip=e=>t.jsx("div",{...e,className:Oe("w-sec","w-truncate",e.className)}),op=e=>t.jsx("div",{...e,className:Oe("w-secsub","w-truncate",e.className)}),lp=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{border:"0.5px solid var(--wa-border)",background:e?"var(--wa-surface-subtle)":void 0,...a.style}}),cp=({children:e,...a})=>t.jsx("div",{...a,className:"w-avatar w-avatar--sm",children:e}),dp=e=>t.jsx("div",{...e,className:Oe("w-sec","w-grow","w-truncate",e.className)}),up=e=>t.jsx("div",{...e,className:Oe("w-secsub","w-none",e.className)}),mp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),pp=e=>t.jsx("button",{...e,className:Oe("w-menu-item",e.className)}),hp=e=>t.jsx("span",{...e,className:Oe("w-grow",e.className)}),fp=e=>t.jsx("span",{...e,className:Oe("w-menu-trail",e.className)}),wp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),gp=e=>t.jsx("div",{...e,className:Oe("w-menu-label",e.className)}),Hn=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{cursor:e?"default":"pointer",...a.style}}),Fn=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-flex","w-items-center","w-justify-center","w-none",a.className),style:{width:14,height:14,color:"var(--wa-primary)",...a.style},children:e}),xp=e=>t.jsx("div",{...e,className:"w-none",style:{width:14,...e.style}}),Tn=e=>t.jsx("div",{...e,className:Oe("w-sec","w-grow","w-truncate",e.className)}),Xi=e=>t.jsx("div",{...e,className:Oe("w-secsub","w-none",e.className)}),vp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),bp=e=>t.jsx("button",{...e,className:Oe("w-menu-item","w-menu-item--danger",e.className)}),yp=e=>t.jsx("button",{...e,className:Oe("w-menu-item",e.className),style:{borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,flex:"none",...e.style}}),jp=e=>t.jsx("div",{...e,style:{flex:"1 1 auto",overflowY:"auto",padding:5,...e.style}}),eo=({$active:e,...a})=>t.jsx("button",{...a,className:Oe("w-menu-item","sp-row",e&&"sp-row--active",a.className),style:{height:32,...a.style}}),to=({$active:e,...a})=>t.jsx("button",{...a,className:Oe("w-menu-item","sp-row","sp-ws-row",e&&"sp-row--active",a.className),style:{height:32,paddingLeft:30,position:"relative",...a.style},children:a.children}),ao=({$personal:e,children:a,...s})=>t.jsx("div",{...s,className:Oe("w-avatar","w-avatar--sm",!e&&"",s.className),children:a}),so=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","","w-avatar--sm",a.className),children:e}),no=e=>t.jsx("span",{...e,className:Oe("w-sec","w-grow","w-truncate",e.className)}),ro=e=>t.jsx("span",{...e,className:Oe("w-secsub","w-grow","w-truncate",e.className)}),In=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-none",e.className),style:{gap:4,...e.style}}),_p=({$open:e,...a})=>t.jsx(Ut,{...a,className:"w-text-muted",style:{flexShrink:0,transition:"transform 0.2s ease",transform:e?"rotate(0deg)":"rotate(-90deg)"}}),Vn=e=>t.jsx(Ye,{...e,className:"w-text-primary",style:{flexShrink:0}}),kp=e=>t.jsx("div",{...e,className:Oe("w-flex-col","w-gap-3","w-none",e.className),style:{padding:"12px 12px 16px",borderBottom:"0.5px solid var(--wa-border)",...e.style}}),Cp=e=>t.jsx("button",{...e,className:Oe("w-btn","w-btn--icon",e.className),style:{width:24,height:24,...e.style}}),io=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-gap-3",e.className),style:{padding:"4px 4px 0",minWidth:0,...e.style}}),oo=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","","w-avatar--md",a.className),children:e}),lo=e=>t.jsx("div",{...e,className:Oe("w-flex-col","w-grow",e.className),style:{gap:1,minWidth:0,...e.style}}),co=e=>t.jsx("div",{...e,className:Oe("w-sec","w-truncate",e.className)}),uo=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-none",e.className),style:{gap:2,...e.style}}),Fs=({$destructive:e,...a})=>t.jsx("button",{...a,className:Oe("w-btn","w-btn--icon",e&&"w-btn--danger",a.className),style:{width:24,height:24,...a.style}}),mo=e=>t.jsx("div",{...e,className:"w-none",style:{borderTop:"0.5px solid var(--wa-border)",padding:5,...e.style}}),po=e=>t.jsx("button",{...e,className:Oe("w-menu-item",e.className),style:{height:32,color:"var(--wa-text-muted)",...e.style}}),ho=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-justify-center","w-none",e.className),style:{width:20,height:20,...e.style}}),Dr=({showName:e=!0,onCreateOrg:a,showOrgSwitcher:s=!0,narrowBreakpoint:r=640})=>{var Pe,qe,pt,aa,Tt,sa,Wt,yt,na,ra,ia,oa;const i=ts(),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(typeof window<"u"&&window.innerWidth<r),[f,h]=o.useState(!1),[g,x]=o.useState("org"),[w,b]=o.useState(null),[j,v]=o.useState({top:0,left:0,maxHeight:400}),[k,N]=o.useState(new Set),[_,C]=o.useState(null),y=o.useRef(null),E=o.useRef(null),A=o.useRef(null),H=bt({triggerRef:y,isOpen:l,minWidth:300}),M=Kt(!1),T=Kt(!1),P=Kt(!1),S=Kt(!1),$=Kt(!1),{session:Z,signOut:R,switchSignIn:L,switchOrganization:O,switchWorkspace:F,refetch:W}=ot(),{navigateToSignIn:U}=kt(),{deployment:V}=Ce(),{activeOrganization:G,activeMembership:Y,leave:de}=ga(),{organizationMemberships:fe}=xa(),{workspaces:ne}=va(),{activeWorkspace:ae,activeMembership:re,leave:Le}=Dt(),K=(Pe=Z==null?void 0:Z.active_signin)==null?void 0:Pe.user,at=((pt=(qe=V==null?void 0:V.auth_settings)==null?void 0:qe.multi_session_support)==null?void 0:pt.enabled)??!1,ze=((aa=V==null?void 0:V.b2b_settings)==null?void 0:aa.allow_users_to_create_orgs)??!1,We=((Tt=V==null?void 0:V.b2b_settings)==null?void 0:Tt.organizations_enabled)??!1,Re=We&&(((sa=V==null?void 0:V.b2b_settings)==null?void 0:sa.workspaces_enabled)??!1),ce=s&&We,B=!G,q=o.useMemo(()=>{var ve;const ie={};for(const Ae of ne||[]){const J=(ve=Ae.organization)==null?void 0:ve.id;J&&(ie[J]||(ie[J]=[]),ie[J].push(Ae))}return ie},[ne]),X=fe||[],oe=o.useCallback(()=>{if(!E.current)return;const ie=E.current.getBoundingClientRect(),ve=300,Ae=8,J=window.innerWidth<r;if(u(J),J){v({top:ie.top,left:ie.left,maxHeight:ie.height});return}const be=Math.min(Math.max(ie.height,520),window.innerHeight-ie.top-16),Je=ie.right+Ae+ve<=window.innerWidth-8;v({top:ie.top,left:Je?ie.right+Ae:ie.left-Ae-ve,maxHeight:be})},[r]),Ee=o.useCallback(()=>{oe(),d(!0)},[oe]),z=o.useCallback(ie=>{N(ve=>{const Ae=new Set(ve);return Ae.has(ie)?Ae.delete(ie):Ae.add(ie),Ae})},[]);o.useEffect(()=>{G&&Re&&N(ie=>{if(ie.has(G.id))return ie;const ve=new Set(ie);return ve.add(G.id),ve})},[G,Re]),o.useEffect(()=>{x(Re&&ae?"ws":"org")},[Re,ae==null?void 0:ae.id]),o.useEffect(()=>{const ie=()=>{u(window.innerWidth<r),c&&oe()};return window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[r,c,oe]),o.useEffect(()=>{l||(d(!1),h(!1))},[l]),o.useEffect(()=>{if(!l)return;const ie=setTimeout(()=>{const ve=Ae=>{var be,Je,De;const J=Ae.target;(be=y.current)!=null&&be.contains(J)||(Je=E.current)!=null&&Je.contains(J)||(De=A.current)!=null&&De.contains(J)||m(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},50);return()=>clearTimeout(ie)},[l]);const D=ie=>ie.split(" ").filter(Boolean).map(ve=>ve[0]).join("").toUpperCase().slice(0,2),we=(ie,ve,Ae,J,be)=>t.jsx(be,{children:ie?t.jsx("img",{src:ve,alt:Ae}):D(`${Ae||""} ${J||""}`)}),ge=async ie=>{try{await R(ie),await W(),m(!1)}catch{}},xe=async ie=>{try{await L(ie),await W(),m(!1)}catch{}},lt=async ie=>{if(!f){h(!0);try{await O(ie),await W(),d(!1)}catch{}finally{h(!1)}}},Qe=async ie=>{if(!f){h(!0);try{await F(ie),await W(),d(!1)}catch{}finally{h(!1)}}},Q=()=>{M.open(),m(!1)},le=[...(Z==null?void 0:Z.signins)||[]].sort((ie,ve)=>{const Ae=ie.user.id===(K==null?void 0:K.id),J=ve.user.id===(K==null?void 0:K.id);return Ae===J?0:Ae?-1:1}),me=((Wt=le.find(ie=>ie.user.id===(K==null?void 0:K.id)))==null?void 0:Wt.id)||"",Te=((na=(yt=Y==null?void 0:Y.roles)==null?void 0:yt[0])==null?void 0:na.name)??null;return t.jsx($e,{children:t.jsxs(X6,{children:[t.jsxs(F0,{ref:y,onClick:()=>m(!l),children:[we(K==null?void 0:K.has_profile_picture,K==null?void 0:K.profile_picture_url,K==null?void 0:K.first_name,K==null?void 0:K.last_name,ep),e&&t.jsx(tp,{children:`${(K==null?void 0:K.first_name)||""} ${(K==null?void 0:K.last_name)||""}`.trim()})]}),typeof window<"u"&&en.createPortal(t.jsxs("div",{className:"wacht-root",style:i,children:[t.jsxs(T0,{ref:E,$position:H,$isOpen:l&&!(p&&c),$maxHeight:H==null?void 0:H.maxHeight,children:[t.jsx(ap,{children:t.jsxs(sp,{children:[we(K==null?void 0:K.has_profile_picture,K==null?void 0:K.profile_picture_url,K==null?void 0:K.first_name,K==null?void 0:K.last_name,np),t.jsxs(rp,{children:[t.jsx(ip,{children:`${(K==null?void 0:K.first_name)||""} ${(K==null?void 0:K.last_name)||""}`.trim()}),t.jsx(op,{children:(ra=K==null?void 0:K.primary_email_address)==null?void 0:ra.email})]})]})}),t.jsxs(mp,{children:[ce&&t.jsxs(lp,{$active:c,onClick:Ee,style:{marginBottom:8},children:[t.jsx(cp,{children:G?G.image_url?t.jsx("img",{src:G.image_url,alt:G.name}):(ia=G.name)==null?void 0:ia.charAt(0).toUpperCase():K!=null&&K.has_profile_picture?t.jsx("img",{src:K.profile_picture_url,alt:K.first_name}):D(`${(K==null?void 0:K.first_name)||""} ${(K==null?void 0:K.last_name)||""}`)}),t.jsx(dp,{children:(G==null?void 0:G.name)??"Personal account"}),Te&&t.jsx(up,{children:Te})]}),t.jsxs(pp,{onClick:Q,children:[t.jsx(Ea,{}),t.jsx(hp,{children:"Manage account"}),t.jsx(fp,{children:"⌘,"})]})]}),t.jsx(Ji,{}),t.jsxs(wp,{children:[t.jsx(gp,{children:"Accounts"}),at?le.map(({user:ie,id:ve})=>{var J;const Ae=ie.id===(K==null?void 0:K.id);return t.jsxs(Hn,{$active:Ae,onClick:Ae?void 0:()=>xe(ve),children:[Ae?t.jsx(Fn,{children:t.jsx(Ye,{})}):t.jsx(xp,{}),t.jsx(Tn,{children:(J=ie.primary_email_address)==null?void 0:J.email}),Ae&&t.jsx(Xi,{children:"Current"})]},ie.id)}):K&&t.jsxs(Hn,{$active:!0,children:[t.jsx(Fn,{children:t.jsx(Ye,{})}),t.jsx(Tn,{children:(oa=K.primary_email_address)==null?void 0:oa.email}),t.jsx(Xi,{children:"Current"})]}),at&&t.jsxs(Hn,{onClick:()=>{U(),m(!1)},children:[t.jsx(Fn,{style:{color:"var(--wa-text-muted)"},children:t.jsx(St,{})}),t.jsx(Tn,{style:{color:"var(--wa-text-muted)"},children:"Add account"})]})]}),t.jsx(Ji,{}),t.jsx(vp,{children:t.jsxs(bp,{onClick:()=>ge(me),children:[t.jsx(Aa,{}),"Sign out"]})})]}),t.jsxs(I0,{ref:A,$top:j.top,$left:j.left,$isOpen:l&&c,$maxHeight:j.maxHeight,children:[p&&t.jsxs(yp,{onClick:()=>d(!1),children:[t.jsx(nn,{size:13}),"Back"]}),(()=>{var _t;if(B)return null;const ie=Re&&!!ae,ve=!!((_t=Y==null?void 0:Y.eligibility_restriction)!=null&&_t.type)&&Y.eligibility_restriction.type!=="none",Ae=!!G&&!ve&&Hr(Y),J=ie&&!ve&&Tr(re),be=ie?g:"org",Je=async()=>{if(de){b("org");try{await de(),await W(),d(!1)}catch{}finally{b(null)}}},De=async()=>{if(Le){b("ws");try{await Le(),d(!1)}catch{}finally{b(null)}}},jt=()=>{if(!ie)return null;const Ke=be==="org"?"ws":"org",wt=Ke==="ws"?"Switch to workspace context":"Switch to organization context";return t.jsx(Cp,{type:"button",onClick:()=>x(Ke),title:wt,"aria-label":wt,children:t.jsx(Su,{size:12})})};return t.jsxs(kp,{children:[be==="org"&&G&&t.jsxs(io,{children:[jt(),t.jsx(oo,{children:G.image_url?t.jsx("img",{src:G.image_url,alt:G.name}):D(G.name)}),t.jsx(lo,{children:t.jsx(co,{children:G.name})}),t.jsxs(uo,{children:[Ae&&t.jsx(Fs,{onClick:()=>{P.open(),m(!1)},title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Ea,{size:14})}),t.jsx(Fs,{$destructive:!0,onClick:Je,disabled:w==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(Aa,{size:14})})]})]}),be==="ws"&&ie&&t.jsxs(io,{children:[jt(),t.jsx(oo,{children:ae.image_url?t.jsx("img",{src:ae.image_url,alt:ae.name}):D(ae.name)}),t.jsx(lo,{children:t.jsx(co,{children:ae.name})}),t.jsxs(uo,{children:[J&&t.jsx(Fs,{onClick:()=>{$.open(),m(!1)},title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Ea,{size:14})}),t.jsx(Fs,{$destructive:!0,onClick:De,disabled:w==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(Aa,{size:14})})]})]})]})})(),t.jsxs(jp,{children:[t.jsxs(eo,{$active:B,onClick:()=>{B||lt(void 0)},disabled:f,style:B?{cursor:"default"}:void 0,children:[t.jsx(ao,{$personal:!0,children:K!=null&&K.has_profile_picture?t.jsx("img",{src:K.profile_picture_url,alt:K.first_name}):t.jsx(hs,{size:12})}),t.jsx(no,{children:"Personal account"}),B&&t.jsx(In,{children:t.jsx("span",{className:"sp-check",style:{display:"inline-flex"},children:t.jsx(Vn,{size:13})})})]}),X.map(ie=>{var De,jt;const ve=ie.organization,Ae=ve.id===(G==null?void 0:G.id),J=k.has(ve.id),be=Re?q[ve.id]||[]:[],Je=!!((De=ie.eligibility_restriction)!=null&&De.type)&&ie.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs(eo,{$active:Ae,onClick:()=>{Je||(Re?z(ve.id):Ae||lt(ve.id))},disabled:f,style:Je?{opacity:.55,cursor:"not-allowed"}:Ae&&!Re?{cursor:"default"}:void 0,title:(jt=ie.eligibility_restriction)==null?void 0:jt.message,children:[t.jsx(ao,{children:ve.image_url?t.jsx("img",{src:ve.image_url,alt:ve.name}):D(ve.name)}),t.jsx(no,{children:ve.name}),t.jsxs(In,{children:[Je&&t.jsx(Ma,{size:12,color:"var(--wa-error)"}),Ae&&!Re&&t.jsx(Vn,{size:13}),Re&&t.jsx(_p,{size:11,$open:J})]})]}),Re&&J&&t.jsxs(t.Fragment,{children:[be.map(_t=>{var la,ca;const Ke=Ae&&(ae==null?void 0:ae.id)===_t.id,wt=_t,Bt=((la=wt.eligibility_restriction)==null?void 0:la.type)&&wt.eligibility_restriction.type!=="none";return t.jsxs(to,{$active:Ke,onClick:()=>{!Ke&&!Bt&&Qe(_t.id)},disabled:f,style:Bt||Je?{opacity:.55,cursor:"not-allowed"}:Ke?{cursor:"default"}:void 0,title:(ca=wt.eligibility_restriction)==null?void 0:ca.message,children:[t.jsx(so,{children:wt.image_url?t.jsx("img",{src:wt.image_url,alt:wt.name}):D(wt.name).charAt(0)}),t.jsx(ro,{children:wt.name}),t.jsxs(In,{children:[Bt&&t.jsx(Ma,{size:12,color:"var(--wa-error)"}),Ke&&t.jsx(Vn,{size:12})]})]},_t.id)}),!Je&&t.jsxs(to,{onClick:()=>{C(ve.id),S.open()},disabled:f,children:[t.jsx(so,{style:{background:"transparent",border:"1px dashed var(--wa-border-strong)"},children:t.jsx(St,{size:10})}),t.jsx(ro,{children:"New workspace"})]})]})]},ve.id)})]}),(()=>{var Je,De,jt;const ie=((fe==null?void 0:fe.length)??0)>0,ve=()=>ze&&t.jsx(mo,{children:t.jsxs(po,{onClick:()=>{a?(a(),m(!1)):T.open()},disabled:f,children:[t.jsx(ho,{children:t.jsx(St,{size:12})}),"New organization"]})});if(!Re||!ie)return ve();const Ae=!!((Je=Y==null?void 0:Y.eligibility_restriction)!=null&&Je.type)&&Y.eligibility_restriction.type!=="none",J=((jt=(De=fe==null?void 0:fe[0])==null?void 0:De.organization)==null?void 0:jt.id)??null,be=G&&!Ae?G.id:J;return t.jsx(mo,{children:t.jsxs(po,{onClick:()=>{C(be),S.open()},disabled:f,children:[t.jsx(ho,{children:t.jsx(St,{size:12})}),"New workspace"]})})})()]})]}),document.body),t.jsx(H0,{isOpen:M.isOpen,onClose:M.close}),ce&&t.jsxs(t.Fragment,{children:[t.jsx(Jc,{isOpen:T.isOpen,onClose:T.close}),t.jsx(s0,{isOpen:P.isOpen,onClose:P.close}),Re&&t.jsxs(t.Fragment,{children:[t.jsx(Pr,{isOpen:S.isOpen,onClose:()=>{S.close(),C(null)},organizationId:_||void 0}),t.jsx(Or,{isOpen:$.isOpen,onClose:$.close})]})]})]})})};function V0({notification:e,onAction:a}){const[s,r]=o.useState(!1),i=c=>{c.target.closest("button")||(r(!s),e.is_read||a({type:"read",id:e.id}))},l=c=>{a({type:"custom",payload:c.payload})},m=c=>{const d=new Date(c),u=new Date().getTime()-d.getTime();if(u<6e4)return"Just now";const f=Math.floor(u/6e4);if(f<60)return`${f}m`;const h=Math.floor(f/60);if(h<24)return`${h}h`;const g=Math.floor(h/24);return g<7?`${g}d`:d.toLocaleDateString(void 0,{month:"short",day:"numeric"})};return t.jsxs("div",{className:"w-flex w-gap-3 w-notif-row",onClick:i,"data-unread":e.is_read?void 0:"",children:[t.jsxs("div",{className:"w-grow w-flex-col w-justify-center",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:2},children:[!e.is_read&&t.jsx("span",{className:"w-notif-dot"}),t.jsx("h4",{className:"w-sec w-truncate",style:{margin:0},children:e.title})]}),t.jsx("p",{className:`w-secsub${s?"":" w-truncate"}`,style:{margin:0,wordWrap:s?"break-word":void 0},children:e.body}),e.ctas&&e.ctas.length>0&&t.jsx("div",{className:"w-flex w-wrap w-gap-2",style:{marginTop:10},children:e.ctas.map((c,d)=>t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:()=>l(c),children:c.label},d))})]}),t.jsxs("div",{className:"w-flex-col w-items-end w-gap-2 w-none",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-1 w-notif-actions",children:[e.is_read&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"unread",id:e.id})},title:"Mark as unread",children:t.jsx(Ru,{size:14})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"star",id:e.id})},title:e.is_starred?"Unstar":"Star","data-on":e.is_starred?"":void 0,children:t.jsx(Du,{size:14,fill:e.is_starred?"currentColor":"none"})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"archive",id:e.id})},title:e.is_archived?"Unarchive":"Archive",children:e.is_archived?t.jsx(Wo,{size:14}):t.jsx(Do,{size:14})})]}),t.jsx("span",{className:"w-secsub",style:{whiteSpace:"nowrap"},children:m(e.created_at)})]})]})}const z0=o.forwardRef(({scope:e="all",onAction:a,fullWidth:s,maxHeight:r,className:i},l)=>{const[m,c]=o.useState("inbox"),[d,p]=o.useState(!1),[u,f]=o.useState(!1),h=o.useRef(null),g={scope:e,limit:20,is_archived:m==="archive",is_starred:m==="starred",is_read:d?!1:void 0},{notifications:x,loading:w,error:b,hasMore:j,loadMore:v,markAsRead:k,markAsUnread:N,markAllAsRead:_,archiveAllRead:C,archiveNotification:y,starNotification:E}=Oo(g);o.useEffect(()=>{if(!u)return;const T=P=>{h.current&&!h.current.contains(P.target)&&f(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[u]);const A=async T=>{switch(T.type){case"read":await k(T.id);break;case"unread":await N(T.id);break;case"archive":await y(T.id);break;case"star":await E(T.id);break;case"custom":a==null||a(T.payload);break}},H=()=>{_(),f(!1)},M=()=>{C(),f(!1)};return t.jsxs("div",{ref:l,className:`w-flex-col w-relative w-notif-panel${s?" w-notif-panel--fill":""}${i?` ${i}`:""}`,style:{maxHeight:r||"100%"},children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-none w-notif-head",children:[t.jsxs("div",{className:"w-tabs w-grow",children:[t.jsx("button",{className:`w-tab${m==="inbox"?" w-tab--active":""}`,onClick:()=>c("inbox"),children:"Inbox"}),t.jsx("button",{className:`w-tab${m==="archive"?" w-tab--active":""}`,onClick:()=>c("archive"),children:"Archive"}),t.jsx("button",{className:`w-tab${m==="starred"?" w-tab--active":""}`,onClick:()=>c("starred"),children:"Starred"})]}),t.jsxs("button",{className:"w-btn w-btn--icon w-none w-relative",onClick:()=>f(!u),title:"Options",children:[t.jsx($u,{size:16}),d&&t.jsx("span",{className:"w-notif-filter-dot"})]}),u&&t.jsxs("div",{ref:h,className:"w-menu w-notif-menu",children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{p(!d),f(!1)},children:[t.jsx(Ou,{})," Unread only",d&&t.jsx(Ye,{className:"w-menu-check"})]}),m==="inbox"&&t.jsxs("button",{className:"w-menu-item",onClick:H,children:[t.jsx(Mu,{})," Mark all as read"]}),t.jsxs("button",{className:"w-menu-item",onClick:M,children:[t.jsx(Do,{})," Archive all read"]})]})]}),t.jsx("div",{className:"w-grow w-notif-body",children:w?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):b?t.jsx(Nt,{icon:t.jsx(mi,{size:20,className:"w-text-error"}),title:"Failed to load notifications",description:b.message||"An unexpected error occurred."}):x.length===0?t.jsx(Nt,{icon:t.jsx(mi,{size:20}),title:"No notifications",description:"You're all caught up!"}):t.jsxs(t.Fragment,{children:[x.map(T=>t.jsx(V0,{notification:T,onAction:A},T.id)),j&&t.jsx("div",{className:"w-flex w-justify-center",style:{padding:12},children:t.jsx("button",{className:"w-btn w-btn--ghost w-btn--sm",onClick:v,children:"Load more"})})]})})]})}),D0=o.forwardRef(({position:e,scope:a,onAction:s,className:r},i)=>t.jsx("div",{ref:i,className:`w-card w-flex-col w-notif-pop${r?` ${r}`:""}`,style:{top:(e==null?void 0:e.top)!==void 0?e.top:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?e.bottom:void 0,left:(e==null?void 0:e.left)!==void 0?e.left:void 0,right:(e==null?void 0:e.right)!==void 0?e.right:void 0,maxHeight:e!=null&&e.maxHeight?e.maxHeight:"90vh"},children:t.jsx(z0,{scope:a,onAction:s,fullWidth:!0,maxHeight:e!=null&&e.maxHeight?`${e.maxHeight}px`:"100%"})}));function U0({className:e,showBadge:a=!0,scope:s="all",onAction:r}){const[i,l]=o.useState(!1),m=ts(),c=o.useRef(null),d=o.useRef(null),p=o.useRef(null),{count:u,refetch:f}=Zo({scope:s}),h=async x=>{await f(),r==null||r(x.payload)},g=bt({triggerRef:p,isOpen:i,minWidth:Math.min(450,typeof window<"u"?window.innerWidth-32:300),defaultMaxHeight:550});return o.useEffect(()=>{if(!i)return;const x=setTimeout(()=>{const w=b=>{var v,k;const j=b.target;(v=c.current)!=null&&v.contains(j)||(k=d.current)!=null&&k.contains(j)||l(!1)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},50);return()=>{clearTimeout(x)}},[i]),t.jsx($e,{children:t.jsxs("div",{ref:c,className:`w-inline w-relative${e?` ${e}`:""}`,children:[t.jsxs("button",{ref:p,className:"w-btn w-btn--icon w-notif-bell",onClick:()=>l(!i),"aria-label":u>0?`${u} unread notifications`:"Notifications",children:[t.jsx(Eu,{strokeWidth:1}),a&&u>0&&t.jsx("span",{className:"w-notif-badge","data-dot":u<=9?"":void 0,children:u>9?"9+":""})]}),typeof window<"u"&&i&&en.createPortal(t.jsx("div",{className:"wacht-root",style:m,children:t.jsx(D0,{ref:d,position:g,scope:s,onAction:h,onClose:()=>l(!1)})}),document.body)]})})}const Np=({showName:e=!0,showNotifications:a=!0})=>t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[a&&t.jsx(U0,{}),t.jsx(Dr,{showName:e})]}),Sp=({children:e})=>{var r;const{session:a,loading:s}=ot();return s||!((r=a.signins)!=null&&r.length)||!a.active_signin?null:t.jsx(t.Fragment,{children:e})},Ep=({children:e})=>{var r;const{loading:a,session:s}=ot();return a||(r=s.signins)!=null&&r.length&&s.active_signin?null:t.jsx(t.Fragment,{children:e})},Ap=({onAccountSelect:e,showAddAccount:a=!0})=>{var _,C,y,E;const{session:s,loading:r,switchSignIn:i,signOut:l}=ot(),{deployment:m}=Ce(),{navigateToSignIn:c,navigate:d}=kt(),[p,u]=o.useState(null),[f,h]=o.useState(null),g=s==null?void 0:s.active_signin,x=(s==null?void 0:s.signins)||[],w=((C=(_=m==null?void 0:m.auth_settings)==null?void 0:_.multi_session_support)==null?void 0:C.enabled)??!1,b=(y=m==null?void 0:m.ui_settings)==null?void 0:y.app_name;o.useEffect(()=>{r||x.length||c()},[r,x,c]);const j=A=>A.split(" ").map(H=>H[0]).join("").toUpperCase().slice(0,2),v=async A=>{var H;h(A);try{if(await i(A),e)e(A),h(null);else{let M=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));if(M||(M=(H=m.ui_settings)==null?void 0:H.after_signin_redirect_url),M){let T;try{T=new URL(M)}catch{T=new URL(M,window.location.origin)}(m==null?void 0:m.mode)==="staging"&&T.searchParams.set("__dev_session__",xt(m.backend_host)??""),d(T.toString())}else h(null)}}catch{h(null)}},k=async(A,H)=>{A.stopPropagation(),u(H);try{await l(H)}catch{}finally{u(null)}},N=()=>{var H;let A=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));A||(A=(H=m.ui_settings)==null?void 0:H.after_signin_redirect_url),c(A)};return r?t.jsx(js,{}):x.length?t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-sub",style:{fontSize:12.5},children:["Don't have an account?"," ",t.jsx(Et,{to:`${(E=m.ui_settings)==null?void 0:E.sign_up_page_url}${window.location.search}`,className:"w-link",children:"Sign up"})]}),children:[t.jsx(rt,{title:"Choose an account",sub:`Select an account to continue${b?` to ${b}`:""}`}),t.jsx("div",{className:"w-flex-col",children:x.map(({user:A,id:H})=>{var R,L;if(!A)return null;const M=H===(g==null?void 0:g.id),T=f===H,P=p===H,S=`${A.first_name||""} ${A.last_name||""}`.trim(),$=S||((R=A.primary_email_address)==null?void 0:R.email)||A.username||"User",Z=((L=A.primary_email_address)==null?void 0:L.email)||A.username;return t.jsxs("button",{className:"w-acct","data-active":M?"":void 0,"data-busy":T?"":void 0,onClick:()=>v(H),children:[t.jsx("div",{className:"w-avatar",children:T?t.jsx(vt,{onAccent:!0}):A.has_profile_picture?t.jsx("img",{src:A.profile_picture_url,alt:S}):j($)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:$}),Z&&Z!==$&&t.jsx("div",{className:"w-secsub w-truncate",children:Z})]}),M&&t.jsxs("span",{className:"w-pill w-pill--current",children:[t.jsx(Ye,{size:11,weight:"bold"}),"current"]}),t.jsx("span",{className:"w-kebab w-acct-out",role:"button","aria-disabled":P,title:"Sign out",onClick:O=>k(O,H),children:P?t.jsx(vt,{}):t.jsx(Aa,{size:15})})]},H)})}),a&&w&&t.jsx("div",{className:"w-acct-foot",children:t.jsxs("button",{className:"w-acct-add",onClick:N,children:[t.jsx(St,{size:15}),"Add another account"]})})]})}):null},Mp=()=>{const{navigateToSignIn:e}=kt();return o.useEffect(()=>{e()},[e]),null},Rp=()=>{const{navigateToSignUp:e}=kt();return o.useEffect(()=>{e()},[e]),null},Lp=()=>{var M,T;const{organizationMemberships:e,refetch:a,loading:s}=xa(),{workspaces:r}=va(),{switchOrganization:i,switchWorkspace:l}=ot(),{deployment:m}=Ce(),[c,d]=o.useState(null),[p,u]=o.useState("orgList"),[f,h]=o.useState(null),g=((m==null?void 0:m.b2b_settings.organizations_enabled)??!1)&&((m==null?void 0:m.b2b_settings.workspaces_enabled)??!1),x=(m==null?void 0:m.b2b_settings.allow_users_to_create_orgs)??!1,w=o.useRef(!1);o.useEffect(()=>{if(!(w.current||!e)){if(w.current=!0,e.length===0){u("createOrg");return}if(!g){u("orgList");return}if(!r||r.length===0){const P=e.find(S=>{var $,Z;return!(($=S.eligibility_restriction)!=null&&$.type)||((Z=S.eligibility_restriction)==null?void 0:Z.type)==="none"});if(P){h(P.organization.id),u("createWorkspace");return}}u("orgList")}},[e,r,g]);const b=P=>P.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=async P=>{if(g){h(P.id),u("workspaceList");return}d(P.id);try{await i(P.id)}finally{d(null)}},v=async P=>{d(P.id);try{await l(P.id)}finally{d(null)}},k=async P=>{var $;await a();const S=(($=P==null?void 0:P.data)==null?void 0:$.organization)||(P==null?void 0:P.organization)||P;if(!g){u("orgList");return}S!=null&&S.id?(h(S.id),u("createWorkspace")):u("orgList")},N=async P=>{var $;const S=(P==null?void 0:P.id)??(($=P==null?void 0:P.workspace)==null?void 0:$.id);if(S){d(S);try{await l(S)}finally{d(null)}}},_=async()=>{h(null),u("orgList")},C=(M=e==null?void 0:e.find(P=>P.organization.id===f))==null?void 0:M.organization,y=f?r==null?void 0:r.filter(P=>P.organization.id===f):[];if(s)return null;if(p==="createOrg")return t.jsx(Ue.Body,{style:{padding:0},children:t.jsx(mn,{onSuccess:k,onCancel:()=>u("orgList")})});if(p==="createWorkspace"&&f)return t.jsx(Ue.Body,{style:{padding:0},children:t.jsx(Lr,{organizationId:f,onSuccess:N,onCancel:()=>u("workspaceList"),onCreateOrganization:()=>u("createOrg")})});const E=p==="workspaceList",A=E?"Select a workspace":"Select an organization",H=E?`Choose a workspace in ${(C==null?void 0:C.name)||""}`:`to continue to ${((T=m==null?void 0:m.ui_settings)==null?void 0:T.app_name)||"App"}`;return t.jsxs("div",{className:"w-split",children:[t.jsxs("div",{className:"w-split-aside w-flex-col w-justify-between w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx(Sr,{placement:"left"}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-title",children:A}),t.jsx("p",{className:"w-sub",children:H})]})]}),t.jsx(Dr,{showName:!0})]}),t.jsxs("div",{className:"w-split-main",children:[t.jsxs("div",{className:"w-grow w-flex-col",style:{overflow:"hidden",marginBottom:24},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:8},children:[E&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:_,"aria-label":"Go back",title:"Go back",children:t.jsx(nn,{})}),t.jsx("h2",{className:"w-sec",children:E?"Workspaces":"Your organizations"})]}),t.jsx("div",{className:"w-grow w-flex-col",style:{overflowY:"auto"},children:E?t.jsx(t.Fragment,{children:y&&y.length>0?y.map(P=>{var $,Z,R;const S=(($=P.eligibility_restriction)==null?void 0:$.type)!=="none"&&((Z=P.eligibility_restriction)==null?void 0:Z.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!S&&v(P),disabled:c===P.id||S,title:S?(R=P.eligibility_restriction)==null?void 0:R.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:P.image_url?t.jsx("img",{src:P.image_url,alt:P.name}):b(P.name).charAt(0)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:P.name}),t.jsxs("div",{className:"w-secsub w-inline w-gap-1",children:[t.jsx(cs,{}),"Workspace"]})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[S&&t.jsx(Ma,{size:16,className:"w-text-error"}),t.jsx(Qt,{})]})]},P.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(cs,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No workspaces yet"}),t.jsxs("p",{children:["Create your first workspace for"," ",(C==null?void 0:C.name)||"this organization"]})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createWorkspace"),children:[t.jsx(St,{}),"Create workspace"]})})]})}):e&&e.length>0?e.map(P=>{var U,V,G,Y,de;const S=P.organization,$=r==null?void 0:r.filter(fe=>fe.organization.id===S.id),Z=($==null?void 0:$.length)||0,R=S.member_count,L=((V=(U=P.roles)==null?void 0:U[0])==null?void 0:V.name)||"No role",O=P.roles.length-1,F=O>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${O}`:L.charAt(0).toUpperCase()+L.slice(1),W=((G=P.eligibility_restriction)==null?void 0:G.type)!=="none"&&((Y=P.eligibility_restriction)==null?void 0:Y.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!W&&j(S),disabled:c===S.id||W,title:W?(de=P.eligibility_restriction)==null?void 0:de.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:S.image_url?t.jsx("img",{src:S.image_url,alt:S.name}):b(S.name)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:S.name}),t.jsx("div",{className:"w-secsub w-inline w-gap-1",children:g?t.jsxs(t.Fragment,{children:[t.jsx(cs,{}),Z," ","workspace",Z!==1?"s":""]}):t.jsxs(t.Fragment,{children:[t.jsx(ps,{}),F," •"," ",R," member",R!==1?"s":""]})})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[W&&t.jsx(Ma,{size:16,className:"w-text-error"}),t.jsx(Qt,{})]})]},S.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(ps,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No organizations yet"}),t.jsx("p",{children:x?"Create your first organization to get started":"You don't have access to any organizations yet"})]}),x&&t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createOrg"),children:[t.jsx(St,{}),"Create organization"]})})]})})]}),E&&f&&t.jsxs(se,{$outline:!0,onClick:()=>u("createWorkspace"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create workspace"]}),!E&&e&&e.length>0&&x&&t.jsxs(se,{$outline:!0,onClick:()=>u("createOrg"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create new organization"]})]})]})},Pp=({children:e})=>{var f,h,g,x;const{activeOrganization:a}=ga(),{activeWorkspace:s}=Dt(),{deployment:r}=Ce(),{loading:i,orgMembership:l,workspaceMembership:m}=Ao(),c=((r==null?void 0:r.b2b_settings.organizations_enabled)??!1)&&((r==null?void 0:r.b2b_settings.workspaces_enabled)??!1),d=((f=l==null?void 0:l.eligibility_restriction)==null?void 0:f.type)!=="none"&&((h=l==null?void 0:l.eligibility_restriction)==null?void 0:h.type)!==void 0,p=((g=m==null?void 0:m.eligibility_restriction)==null?void 0:g.type)!=="none"&&((x=m==null?void 0:m.eligibility_restriction)==null?void 0:x.type)!==void 0;return i?null:(d||p||!a?!1:c?s?(m==null?void 0:m.workspace.id)===s.id&&m.organization_id===a.id:!1:!0)?t.jsx(t.Fragment,{children:e}):t.jsx($e,{children:t.jsx(Ue,{isOpen:!0,children:t.jsx(Ue.Overlay,{children:t.jsx(Ue.Content,{className:"w-flex w-justify-center",style:{padding:0,width:900,maxWidth:"90vw"},children:t.jsx(Lp,{})})})})})},$p=e=>{const a=e.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(i=>a.startsWith(i))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(i=>a.startsWith(i))},Op=e=>{const a=e.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(r=>a.startsWith(r))};exports.AcceptInvite=F4;exports.AuthFormImage=Sr;exports.CreateOrganizationForm=mn;exports.CreateWorkspaceDialog=Pr;exports.CreateWorkspaceForm=Lr;exports.DefaultStylesProvider=$e;exports.DeploymentInitialized=C2;exports.DeploymentInitializing=N2;exports.DeploymentProvider=Q0;exports.Dialog=Ue;exports.DialogTrigger=B4;exports.Dropdown=_s;exports.DropdownDivider=Wc;exports.DropdownItem=ea;exports.DropdownItems=ks;exports.DropdownTrigger=Cs;exports.Form=Bc;exports.FormGroup=Ge;exports.Input=ye;exports.Label=Ve;exports.MagicLinkVerification=O4;exports.ManageAccount=Z0;exports.ManageAccountDialog=H0;exports.ManageOrganization=a0;exports.ManageWorkspace=r0;exports.ManageWorkspaceDialog=Or;exports.NavigateToSignIn=Mp;exports.NavigateToSignUp=Rp;exports.NavigationLink=Et;exports.NotificationBell=U0;exports.NotificationItem=V0;exports.NotificationPanel=z0;exports.NotificationPopover=D0;exports.OAuthProvider=wo;exports.ORG_ADMIN_PERMISSIONS=i0;exports.ORG_MANAGEMENT_PERMISSIONS=o0;exports.OTPInput=ya;exports.OrganizationSwitcher=d0;exports.PhoneNumberInput=ys;exports.PhoneVerification=Hc;exports.ProfileCompletion=Tc;exports.RequireActiveTenancy=Pp;exports.SignInForm=R4;exports.SignUpForm=_4;exports.SignedIn=Sp;exports.SignedInAccounts=Ap;exports.SignedOut=Ep;exports.SimpleDialog=W4;exports.SocialCallback=$4;exports.Spinner=_e;exports.Switch=Za;exports.TwoFactorMethodSelector=Zc;exports.TwoFactorVerification=Fc;exports.UserButton=Dr;exports.UserControls=Np;exports.WORKSPACE_ADMIN_PERMISSIONS=l0;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=c0;exports.WaitlistForm=P4;exports.canManageOrganization=Hr;exports.canManageWorkspace=Tr;exports.clearTokenCache=Pt;exports.hasIncompleteProfile=Z4;exports.hasOrgPermission=Zr;exports.hasWorkspacePermission=Fr;exports.isExternalUrl=$p;exports.isOrgAdmin=Tm;exports.isSafeUrl=Op;exports.isWorkspaceAdmin=Im;exports.redirectToProfileCompletion=H4;exports.useActiveOrganization=ga;exports.useActiveTenancy=Ao;exports.useActiveWorkspace=Dt;exports.useActorMcpServers=qd;exports.useActorProjectSearch=Zd;exports.useActorProjects=Od;exports.useActorThreadSearch=Td;exports.useAgentSession=Ad;exports.useAgentThread=Id;exports.useAgentThreadAssignments=zd;exports.useAgentThreadConversation=Ed;exports.useAgentThreadFilesystem=Vd;exports.useAgentThreadTaskGraphs=Bd;exports.useApiAuthAppSession=b2;exports.useApiAuthAuditAnalytics=_2;exports.useApiAuthAuditLogs=j2;exports.useApiAuthAuditTimeseries=k2;exports.useApiAuthKeys=y2;exports.useClient=je;exports.useCreateWebhookEndpoint=f2;exports.useDeployment=Ce;exports.useExternalAgentConnections=Kd;exports.useForgotPassword=Po;exports.useInvitation=Vo;exports.useMagicLinkVerification=Lo;exports.useNavigation=kt;exports.useNotificationStream=$o;exports.useNotificationUnreadCount=Zo;exports.useNotifications=Oo;exports.useOrganizationList=zt;exports.useOrganizationMemberships=xa;exports.useProjectTaskBoardItem=Wd;exports.useProjectTaskBoardItemComments=Gd;exports.useProjectTasks=Ud;exports.useProjectThreadFeed=Fd;exports.useProjectThreads=Hd;exports.useSession=ot;exports.useSignIn=go;exports.useSignUp=xo;exports.useSocialCallback=Ro;exports.useThemeOverrideVars=ts;exports.useUser=ba;exports.useUserSignins=Eo;exports.useWaitlist=Mo;exports.useWebhookAnalytics=x2;exports.useWebhookAppSession=m2;exports.useWebhookDeliveries=g2;exports.useWebhookEndpoints=h2;exports.useWebhookEvents=w2;exports.useWebhookStats=p2;exports.useWebhookTimeseries=v2;exports.useWorkspaceList=va;exports.useWorkspaceMemberships=tn;Object.keys(Gr).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Gr[e]})});
118
+ `),be=new Blob([J],{type:"text/plain"}),Je=URL.createObjectURL(be),De=document.createElement("a");De.href=Je,De.download="wacht-backup-codes.txt",De.click(),URL.revokeObjectURL(Je),g("Backup codes downloaded","info")},Tt=async()=>{var J,be;if((be=(J=e==null?void 0:e.auth_settings)==null?void 0:J.passkey)!=null&&be.enabled)try{L(!0);const Je=await u();Z(Je.data||[])}catch{g("Failed to load passkeys","error")}finally{L(!1)}},sa=async J=>{try{F(!0),await f(J||void 0),await Tt(),g("Passkey registered successfully!","info")}catch(be){throw g(be.message||"Failed to register passkey","error"),be}finally{F(!1)}},Wt=async J=>{try{await h(J),await Tt(),g("Passkey removed","info")}catch(be){g(be.message||"Failed to remove passkey","error")}};o.useEffect(()=>{Tt()},[(ie=(oa=e==null?void 0:e.auth_settings)==null?void 0:oa.passkey)==null?void 0:ie.enabled]);const yt=[];return lt&&yt.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:a!=null&&a.has_password?"Enabled":"Disabled",actions:a!=null&&a.has_password?["change"]:["setup"],group:"sign-in"}),(Ae=(ve=e==null?void 0:e.auth_settings)==null?void 0:ve.passkey)!=null&&Ae.enabled&&yt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:$.length>0?`${$.length} registered`:"",actions:$.length>0?["manage","add"]:["add"],group:"sign-in"}),xe!=null&&xe.authenticator&&yt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:a!=null&&a.user_authenticator?"Enabled":"Disabled",actions:a!=null&&a.user_authenticator?["remove"]:["setup"],group:"sign-in"}),a!=null&&a.user_authenticator&&yt.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:a!=null&&a.backup_codes_generated?"Generated":"Not Generated",actions:["generate"],group:"recovery"}),a!=null&&a.user_authenticator&&yt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:x==="enforced"?"Enforced":"Optional",actions:["toggle"],group:"recovery"}),ne!=="table"?t.jsxs(t.Fragment,{children:[t.jsxs(w0,{children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(Xt,{size:16}),t.jsxs("span",{className:"w-sec",children:[ne==="qr"&&"Setup Two-Factor Authentication",ne==="verify"&&"Verify Your Authenticator",ne==="backup"&&"Save Your Backup Codes",ne==="success"&&"Setup Complete!"]})]}),t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("table"),children:"← Back"})]}),t.jsxs("div",{className:"w-narrow w-flex-col w-items-center w-gap-5",style:{textAlign:"center"},children:[ne==="qr"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),t.jsx("div",{className:"w-flex w-justify-center",children:D?t.jsxs("div",{className:"w-qr w-flex-col w-items-center w-gap-3",children:[t.jsx("span",{className:"w-spin"}),t.jsx("div",{className:"w-secsub",children:"Loading QR Code..."})]}):re?t.jsx("div",{className:"w-tile w-flex w-items-center w-justify-center",children:t.jsx(zr,{value:re,size:200,level:"M",marginSize:0})}):t.jsx("div",{className:"w-qr w-text-error",children:"QR Code Not Available"})}),t.jsxs("div",{className:"w-flex-col w-gap-2 w-full",children:[t.jsx("p",{className:"w-secsub",children:"Or enter this code manually:"}),t.jsx("div",{className:"w-token",children:t.jsx("code",{children:K||"Loading..."})})]}),t.jsx(se,{$fullWidth:!0,onClick:()=>ae("verify"),disabled:!re||!K,children:"I've Scanned the Code"})]}),ne==="verify"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"w-secsub",children:"Enter two consecutive codes from your authenticator app to verify setup"}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(ye,{type:"text",placeholder:"000000",value:Re[0],onChange:J=>{const be=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([be,Re[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}}),t.jsx(ye,{type:"text",placeholder:"000000",value:Re[1],onChange:J=>{const be=J.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([Re[0],be])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"}})]}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:()=>ae("qr"),children:"Back"}),t.jsx(se,{$size:"sm",onClick:me,disabled:Ee||Re.some(J=>J.length!==6),children:Ee?"Verifying...":"Verify & Continue"})]})]}),ne==="backup"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-banner w-banner--warn",style:{textAlign:"left"},children:[t.jsx(Fa,{size:16}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-sec",children:"Important!"}),t.jsx("div",{className:"w-banner-txt",children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),t.jsx("div",{className:"w-codes w-full",children:B.map((J,be)=>t.jsx("span",{onClick:()=>navigator.clipboard.writeText(J),style:{cursor:"pointer"},children:J},be))}),t.jsxs("div",{className:"w-flex w-justify-center w-gap-3",children:[t.jsx(se,{$outline:!0,$size:"sm",onClick:pt,children:"Copy All"}),t.jsxs(se,{$outline:!0,$size:"sm",onClick:aa,children:[t.jsx(ml,{size:16}),"DownloadSimple"]})]}),t.jsx(se,{$fullWidth:!0,onClick:Te,children:"Complete Setup"})]}),ne==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"w-success",children:[t.jsx("span",{className:"ring"}),t.jsx("span",{className:"disc",children:t.jsx(Ye,{size:26})})]}),t.jsxs("div",{className:"w-flex-col w-gap-1 w-items-center",children:[t.jsx("h3",{className:"w-title",children:"All Set!"}),t.jsx("p",{className:"w-secsub",children:"Your account is now protected with two-factor authentication."})]}),t.jsx(se,{$fullWidth:!0,onClick:Te,children:"Continue to Security"})]})]})]}):t.jsx(t.Fragment,{children:yt.length?t.jsx("div",{children:yt.map((J,be)=>{const Je=be>0?yt[be-1].group:null,De=J.group!==Je,jt=yt[be+1],_t=jt&&jt.group===J.group;return t.jsxs("div",{children:[De&&t.jsx(z6,{$first:be===0,children:J.group==="sign-in"?"Sign-in methods":"Recovery"}),t.jsxs(g0,{children:[t.jsxs(x0,{children:[t.jsx("div",{className:"w-flex w-items-center w-wrap w-gap-2 w-sec",children:t.jsx("span",{children:J.name})}),t.jsx("div",{className:"w-secsub",children:J.description})]}),t.jsx(v0,{children:t.jsxs("div",{className:"w-relative",children:[J.id==="password"&&t.jsx(t.Fragment,{children:a!=null&&a.has_password?t.jsxs("div",{className:"w-flex w-gap-2",children:[t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Change"}),_&&t.jsx(Qi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Qe})]}),le()&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",ref:P,onClick:()=>E(!0),children:"Remove"}),y&&t.jsx(F6,{triggerRef:P,onClose:()=>E(!1),onRemovePassword:Q})]})]}):t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:T,onClick:()=>C(!0),children:"Setup"}),_&&t.jsx(Qi,{triggerRef:T,onClose:()=>C(!1),onChangePassword:Qe,isSetup:!0})]})}),J.id==="authenticator"&&!(a!=null&&a.user_authenticator)&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:M,onClick:()=>N(!0),disabled:D,children:D?"Setting up...":"Setup"}),k&&t.jsx(T6,{triggerRef:M,onClose:()=>N(!1),onSetupTOTP:async()=>{const Ke=await i();return We(Ke.id),Ke},onVerifyTOTP:async Ke=>{await l(ze,Ke),await a.refetch(),g("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(a==null?void 0:a.user_authenticator)&&t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>j(!0),disabled:we,children:we?"Removing...":"Remove"}),b&&t.jsx(Qa,{title:"Remove MFA and reset policy to default?",onConfirm:Pe,onCancel:()=>j(!1)})]}),J.id==="backup_codes"&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:S,onClick:qe,disabled:X,children:X?"Generating...":a!=null&&a.backup_codes_generated?"Regenerate":"Generate"}),A&&t.jsx(I6,{triggerRef:S,codes:B,onClose:()=>H(!1),onCopy:pt,onDownload:aa})]})}),J.id==="second_factor_policy"&&t.jsx(Za,{checked:x==="enforced",onChange:Ke=>{v(Ke?"enforced":"none")}}),J.id==="passkey"&&t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[t.jsxs(se,{$outline:!0,$size:"sm",onClick:()=>U(!W),children:[W?"Hide":"Manage"," ","(",$.length,")",t.jsx(Ut,{size:14,style:{transform:W?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$size:"sm",ref:fe,onClick:()=>G(!0),disabled:O,children:O?"Adding...":"Add"}),V&&t.jsx(V6,{triggerRef:fe,onClose:()=>G(!1),onAddPasskey:sa})]})]})]})})]}),J.id==="passkey"&&W&&t.jsx("div",{className:"w-flex-col w-gap-2",children:R?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):$.length===0?t.jsx("div",{className:"w-empty",children:t.jsx("p",{children:"No passkeys registered yet"})}):t.jsx("div",{className:"w-flex-col w-gap-2",children:$.map(Ke=>t.jsxs("div",{className:"w-locked w-flex w-items-center w-justify-between",style:{height:"auto",padding:"10px 12px"},children:[t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("span",{className:"w-sec",children:Ke.name||"Unnamed Passkey"}),t.jsxs("span",{className:"w-secsub",children:[Ke.device_type==="platform"?"This device":"Security key",Ke.last_used_at&&` • Last used ${new Date(Ke.last_used_at).toLocaleDateString()}`]})]}),t.jsxs("div",{className:"w-relative",children:[t.jsx(se,{$destructive:!0,$size:"sm",onClick:()=>de(Ke.id),children:"Remove"}),Y===Ke.id&&t.jsx(Qa,{title:`Remove "${Ke.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Wt(Ke.id),de(null)},onCancel:()=>de(null)})]})]},Ke.id))})}),_t&&t.jsx("div",{className:"w-hr"})]},J.id)})}):t.jsx(Nt,{title:"No security features available",description:"Contact your administrator to enable security features."})})},U6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#d93025"}),t.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),t.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#fcc934"}),t.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),t.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),t.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),t.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),t.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),t.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),t.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),t.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),t.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),W6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[t.jsx("stop",{offset:.1,stopColor:"#ffe226"}),t.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),t.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[t.jsx("stop",{offset:.3,stopColor:"#960e18"}),t.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),t.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),t.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),t.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),t.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[t.jsx("stop",{offset:.13,stopColor:"#fff44f"}),t.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),t.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[t.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),t.jsx("stop",{offset:.67,stopColor:"#9059ff"}),t.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),t.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[t.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),t.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),t.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[t.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),t.jsx("stop",{offset:.28,stopColor:"#ff980e"}),t.jsx("stop",{offset:.47,stopColor:"#ff3750"}),t.jsx("stop",{offset:.78,stopColor:"#eb0878"}),t.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),t.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[t.jsx("stop",{offset:.11,stopColor:"#fff44f"}),t.jsx("stop",{offset:.46,stopColor:"#ff980e"}),t.jsx("stop",{offset:.72,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[t.jsx("stop",{offset:0,stopColor:"#fff44f"}),t.jsx("stop",{offset:.3,stopColor:"#ff980e"}),t.jsx("stop",{offset:.57,stopColor:"#ff3647"}),t.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[t.jsx("stop",{offset:.14,stopColor:"#fff44f"}),t.jsx("stop",{offset:.48,stopColor:"#ff980e"}),t.jsx("stop",{offset:.66,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[t.jsx("stop",{offset:.09,stopColor:"#fff44f"}),t.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),t.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[t.jsx("stop",{offset:.05,stopColor:"#fff44f"}),t.jsx("stop",{offset:.37,stopColor:"#ff980e"}),t.jsx("stop",{offset:.53,stopColor:"#ff3647"}),t.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),t.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[t.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),t.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),t.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),t.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),t.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),t.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),t.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),t.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),t.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),t.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),B6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"b",children:[t.jsx("stop",{offset:0,stopColor:"#06c2e7"}),t.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),t.jsx("stop",{offset:.5,stopColor:"#12aef1"}),t.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),t.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),t.jsxs("linearGradient",{id:"a",children:[t.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),t.jsx("stop",{offset:1,stopColor:"#fff"})]}),t.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),t.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:.958})}),t.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:3.564})}),t.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),t.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),t.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),t.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),t.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),G6=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.7,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.8,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#35c1f1"}),t.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),t.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),t.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),t.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),t.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#66eb6e"}),t.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),t.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#0c59a4"}),t.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),t.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1b9de2"}),t.jsx("stop",{offset:.2,stopColor:"#1595df"}),t.jsx("stop",{offset:.7,stopColor:"#0680d7"}),t.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),q6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Opera",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),t.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),t.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),t.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),K6=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Brave",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),t.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),t.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),t.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),t.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),t.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),Y6=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",className:"w-text-secondary",children:[t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),t.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),t.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),t.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),Q6=({browser:e})=>{const a=(e==null?void 0:e.toLowerCase())||"",s={width:20,height:20};return a.includes("chrome")?t.jsx(U6,{...s}):a.includes("firefox")?t.jsx(W6,{...s}):a.includes("safari")?t.jsx(B6,{...s}):a.includes("edge")?t.jsx(G6,{...s}):a.includes("opera")?t.jsx(q6,{...s}):a.includes("brave")?t.jsx(K6,{...s}):t.jsx(Y6,{})},J6=()=>{const{signins:e,removeSignin:a,refetch:s,loading:r}=Eo(),{refetch:i}=ot(),{toast:l}=ta(),m=e,c=async p=>{try{await a(p),await Promise.all([s(),i()]),l("Session ended successfully","info")}catch(u){l(u.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const u=new Date(p);if(isNaN(u.getTime()))return"Unknown";const h=Math.floor((new Date().getTime()-u.getTime())/(1e3*60));return h<1?"Just now":h<60?`${h}m ago`:h<1440?`${Math.floor(h/60)}h ago`:u.toLocaleDateString()};return r?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):t.jsx("div",{children:m&&m.length>0?t.jsx(t.Fragment,{children:t.jsx(hn,{children:t.jsxs(Ot,{children:[t.jsx(Zt,{children:t.jsxs(it,{children:[t.jsx(Fe,{children:"Browser & Device"}),t.jsx(Fe,{children:"Location"}),t.jsx(Fe,{children:"Last Active"}),t.jsx(Fe,{})]})}),t.jsx(Ht,{children:m.map(p=>t.jsxs(it,{children:[t.jsx(Xe,{children:t.jsxs("div",{className:"w-flex w-items-center w-gap-3",children:[t.jsx(Vr,{children:t.jsx(Q6,{browser:p.browser||"Unknown"})}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&t.jsx("div",{className:"w-text-muted",children:p.device})]})]})}),t.jsx(Xe,{children:t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&t.jsx("div",{className:"w-text-muted",children:p.ip_address})]})}),t.jsx(Xe,{children:d(p.last_active_at)}),t.jsx(Ft,{children:t.jsxs(se,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>c(p.id),children:[t.jsx(Aa,{size:12}),"Sign out"]})})]},p.id))})]})})}):t.jsx(Nt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})},X6=(e,a)=>`${(e==null?void 0:e[0])||""}${(a==null?void 0:a[0])||""}`.toUpperCase()||"U",Z0=()=>{var N,_,C,y,E,A,H,M;const{loading:e,user:a,updateProfilePicture:s}=ba(),{deployment:r}=Ce(),[i,l]=o.useState("profile"),[m,c]=o.useState(null),[d,p]=o.useState("info"),[u,f]=o.useState(!1),h=o.useRef(null),g=o.useCallback((T,P="info")=>{c(T),p(P),setTimeout(()=>c(null),3e3)},[c]),x=async T=>{var S;const P=(S=T.target.files)==null?void 0:S[0];if(P){if(P.size>2*1024*1024){g("File size cannot exceed 2MB","error");return}if(!P.type.startsWith("image/")){g("Please select a valid image file","error");return}try{f(!0),await s(P),await(a==null?void 0:a.refetch()),g("Profile picture updated","info")}catch($){g(($==null?void 0:$.message)||"Failed to update profile picture","error")}finally{f(!1),h.current&&(h.current.value="")}}};if(e)return t.jsx($e,{children:t.jsx(mr,{className:"w-flex w-items-center w-justify-center",children:t.jsx(_e,{})})});const w=r==null?void 0:r.auth_settings,b=(N=w==null?void 0:w.email_address)==null?void 0:N.enabled,j=(_=w==null?void 0:w.phone_number)==null?void 0:_.enabled,v=((C=r==null?void 0:r.social_connections)==null?void 0:C.some(T=>T.enabled))||!1,k=((y=w==null?void 0:w.password)==null?void 0:y.enabled)||((E=w==null?void 0:w.auth_factors_enabled)==null?void 0:E.authenticator)||((A=w==null?void 0:w.auth_factors_enabled)==null?void 0:A.phone_otp)||((H=w==null?void 0:w.auth_factors_enabled)==null?void 0:H.backup_code);return t.jsx($e,{children:t.jsx(m0,{children:t.jsx(u0.Provider,{value:{screen:null,setScreen:()=>{},toast:g},children:t.jsxs(mr,{className:"w-relative",children:[a&&t.jsxs(y0,{className:"mac-page-header",children:[t.jsxs("button",{type:"button",className:"w-avatar-edit","data-busy":u?"":void 0,onClick:()=>{var T;return(T=h.current)==null?void 0:T.click()},disabled:u,title:"Change profile picture","aria-label":"Change profile picture",children:[t.jsx("span",{className:"w-avatar w-avatar--lg",children:a.profile_picture_url?t.jsx("img",{src:a.profile_picture_url,alt:""}):X6(a.first_name,a.last_name)}),t.jsx("span",{className:"w-avatar-veil",children:u?t.jsx(_e,{size:14}):t.jsx(sn,{size:16})})]}),t.jsx("input",{ref:h,type:"file",accept:"image/*",style:{display:"none"},onChange:x}),t.jsxs(j0,{children:[t.jsx(_0,{children:`${a.first_name||""} ${a.last_name||""}`.trim()||a.username||"Account"}),((M=a.primary_email_address)==null?void 0:M.email)&&t.jsx(k0,{children:a.primary_email_address.email})]})]}),t.jsx(p0,{children:t.jsxs(h0,{children:[t.jsx(ka,{$isActive:i==="profile",onClick:()=>l("profile"),children:t.jsxs(Ca,{children:[t.jsx(hs,{size:16}),"Profile"]})}),b&&t.jsx(ka,{$isActive:i==="email",onClick:()=>l("email"),children:t.jsxs(Ca,{children:[t.jsx(hl,{size:16}),"Email"]})}),j&&t.jsx(ka,{$isActive:i==="phone",onClick:()=>l("phone"),children:t.jsxs(Ca,{children:[t.jsx(Vu,{size:16}),"Phone"]})}),v&&t.jsx(ka,{$isActive:i==="social",onClick:()=>l("social"),children:t.jsxs(Ca,{children:[t.jsx(Iu,{size:16}),"Connections"]})}),k&&t.jsx(ka,{$isActive:i==="security",onClick:()=>l("security"),children:t.jsxs(Ca,{children:[t.jsx(Xt,{size:16}),"Security"]})}),t.jsx(ka,{$isActive:i==="sessions",onClick:()=>l("sessions"),children:t.jsxs(Ca,{children:[t.jsx(zu,{size:16}),"Sessions"]})})]})}),t.jsxs(f0,{children:[i==="profile"&&t.jsx(_6,{}),i==="email"&&b&&t.jsx(k6,{}),i==="phone"&&j&&t.jsx(C6,{}),i==="social"&&v&&t.jsx(E6,{}),i==="security"&&k&&t.jsx(D6,{}),i==="sessions"&&t.jsx(J6,{})]}),m&&t.jsxs("div",{className:`w-toast w-toast--contained ${d==="error"?"w-toast--error":"w-toast--success"}`,style:{minWidth:0},children:[t.jsx("span",{className:"w-toast-ic",children:d==="error"?t.jsx(Fa,{size:12}):t.jsx(Ye,{size:12})}),t.jsx("span",{className:"w-toast-msg",children:m})]})]})})})})},H0=({isOpen:e,onClose:a,title:s,showHeader:r,headerContent:i,footerContent:l,customContent:m,children:c,showCloseButton:d})=>t.jsx(Ue,{isOpen:e,onClose:a,children:t.jsx(Ue.Overlay,{children:t.jsxs(Ue.Content,{className:"w-dialog--panel",children:[r&&t.jsx(Ue.Header,{showCloseButton:d,children:i||s}),m||c||t.jsx(Z0,{}),l&&t.jsx(Ue.Footer,{children:l})]})})}),Oe=(...e)=>e.filter(Boolean).join(" "),ep=e=>t.jsx("div",{...e,className:Oe("w-relative",e.className)}),F0=o.forwardRef((e,a)=>t.jsx("button",{...e,ref:a,className:Oe("w-acct",e.className),style:{width:"auto",margin:0,padding:4,gap:8,...e.style}}));F0.displayName="AccountButton";const tp=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","w-avatar--md",a.className),style:{width:28,height:28,fontSize:11,...a.style},children:e}),ap=e=>t.jsx("div",{...e,className:Oe("w-sec","w-text-secondary",e.className)}),T0=o.forwardRef(({$position:e,$isOpen:a,$maxHeight:s,children:r,...i},l)=>t.jsx("div",{...i,ref:l,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:s?`${s}px`:"calc(100vh - 48px)",overflowY:"auto",zIndex:99999,top:(e==null?void 0:e.top)!==void 0?`${e.top}px`:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?`${e.bottom}px`:void 0,left:(e==null?void 0:e.left)!==void 0?`${e.left}px`:void 0,right:(e==null?void 0:e.right)!==void 0?`${e.right}px`:void 0,visibility:e&&a?"visible":"hidden",opacity:a&&e?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${a?"0s":"0.15s"}`,padding:0},children:r}));T0.displayName="DropdownContainer";const I0=o.forwardRef(({$top:e,$left:a,$isOpen:s,$maxHeight:r,children:i,...l},m)=>t.jsx("div",{...l,ref:m,className:"w-menu",style:{position:"fixed",width:300,maxWidth:"calc(100vw - 24px)",maxHeight:`${r}px`,overflowY:"auto",zIndex:99999,display:"flex",flexDirection:"column",top:`${e}px`,left:`${a}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:`opacity 0.15s ease, visibility 0s linear ${s?"0s":"0.15s"}`,padding:0},children:i}));I0.displayName="SidePanel";const Ji=e=>t.jsx("hr",{...e,className:Oe("w-hr",e.className)}),sp=e=>t.jsx("div",{...e,style:{padding:"16px 14px 8px",...e.style}}),np=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-gap-3",e.className)}),rp=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","w-avatar--lg",a.className),children:e}),ip=e=>t.jsx("div",{...e,className:Oe("w-flex-col","w-grow",e.className),style:{gap:2,...e.style}}),op=e=>t.jsx("div",{...e,className:Oe("w-sec","w-truncate",e.className)}),lp=e=>t.jsx("div",{...e,className:Oe("w-secsub","w-truncate",e.className)}),cp=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{border:"0.5px solid var(--wa-border)",background:e?"var(--wa-surface-subtle)":void 0,...a.style}}),dp=({children:e,...a})=>t.jsx("div",{...a,className:"w-avatar w-avatar--sm",children:e}),up=e=>t.jsx("div",{...e,className:Oe("w-sec","w-grow","w-truncate",e.className)}),mp=e=>t.jsx("div",{...e,className:Oe("w-secsub","w-none",e.className)}),pp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),hp=e=>t.jsx("button",{...e,className:Oe("w-menu-item",e.className)}),fp=e=>t.jsx("span",{...e,className:Oe("w-grow",e.className)}),wp=e=>t.jsx("span",{...e,className:Oe("w-menu-trail",e.className)}),gp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),xp=e=>t.jsx("div",{...e,className:Oe("w-menu-label",e.className)}),Hn=({$active:e,...a})=>t.jsx("button",{...a,className:"w-menu-item",style:{cursor:e?"default":"pointer",...a.style}}),Fn=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-flex","w-items-center","w-justify-center","w-none",a.className),style:{width:14,height:14,color:"var(--wa-primary)",...a.style},children:e}),vp=e=>t.jsx("div",{...e,className:"w-none",style:{width:14,...e.style}}),Tn=e=>t.jsx("div",{...e,className:Oe("w-sec","w-grow","w-truncate",e.className)}),Xi=e=>t.jsx("div",{...e,className:Oe("w-secsub","w-none",e.className)}),bp=e=>t.jsx("div",{...e,style:{padding:"5px",...e.style}}),yp=e=>t.jsx("button",{...e,className:Oe("w-menu-item","w-menu-item--danger",e.className)}),jp=e=>t.jsx("button",{...e,className:Oe("w-menu-item",e.className),style:{borderBottom:"0.5px solid var(--wa-border)",borderRadius:0,flex:"none",...e.style}}),_p=e=>t.jsx("div",{...e,style:{flex:"1 1 auto",overflowY:"auto",padding:5,...e.style}}),eo=({$active:e,...a})=>t.jsx("button",{...a,className:Oe("w-menu-item","sp-row",e&&"sp-row--active",a.className),style:{height:32,...a.style}}),to=({$active:e,...a})=>t.jsx("button",{...a,className:Oe("w-menu-item","sp-row","sp-ws-row",e&&"sp-row--active",a.className),style:{height:32,paddingLeft:30,position:"relative",...a.style},children:a.children}),ao=({$personal:e,children:a,...s})=>t.jsx("div",{...s,className:Oe("w-avatar","w-avatar--sm",!e&&"",s.className),children:a}),so=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","","w-avatar--sm",a.className),children:e}),no=e=>t.jsx("span",{...e,className:Oe("w-sec","w-grow","w-truncate",e.className)}),ro=e=>t.jsx("span",{...e,className:Oe("w-secsub","w-grow","w-truncate",e.className)}),In=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-none",e.className),style:{gap:4,...e.style}}),kp=({$open:e,...a})=>t.jsx(Ut,{...a,className:"w-text-muted",style:{flexShrink:0,transition:"transform 0.2s ease",transform:e?"rotate(0deg)":"rotate(-90deg)"}}),Vn=e=>t.jsx(Ye,{...e,className:"w-text-primary",style:{flexShrink:0}}),Cp=e=>t.jsx("div",{...e,className:Oe("w-flex-col","w-gap-3","w-none",e.className),style:{padding:"12px 12px 16px",borderBottom:"0.5px solid var(--wa-border)",...e.style}}),Np=e=>t.jsx("button",{...e,className:Oe("w-btn","w-btn--icon",e.className),style:{width:24,height:24,...e.style}}),io=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-gap-3",e.className),style:{padding:"4px 4px 0",minWidth:0,...e.style}}),oo=({children:e,...a})=>t.jsx("div",{...a,className:Oe("w-avatar","","w-avatar--md",a.className),children:e}),lo=e=>t.jsx("div",{...e,className:Oe("w-flex-col","w-grow",e.className),style:{gap:1,minWidth:0,...e.style}}),co=e=>t.jsx("div",{...e,className:Oe("w-sec","w-truncate",e.className)}),uo=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-none",e.className),style:{gap:2,...e.style}}),Fs=({$destructive:e,...a})=>t.jsx("button",{...a,className:Oe("w-btn","w-btn--icon",e&&"w-btn--danger",a.className),style:{width:24,height:24,...a.style}}),mo=e=>t.jsx("div",{...e,className:"w-none",style:{borderTop:"0.5px solid var(--wa-border)",padding:5,...e.style}}),po=e=>t.jsx("button",{...e,className:Oe("w-menu-item",e.className),style:{height:32,color:"var(--wa-text-muted)",...e.style}}),ho=e=>t.jsx("div",{...e,className:Oe("w-flex","w-items-center","w-justify-center","w-none",e.className),style:{width:20,height:20,...e.style}}),Dr=({showName:e=!0,onCreateOrg:a,showOrgSwitcher:s=!0,narrowBreakpoint:r=640})=>{var Pe,qe,pt,aa,Tt,sa,Wt,yt,na,ra,ia,oa;const i=ts(),[l,m]=o.useState(!1),[c,d]=o.useState(!1),[p,u]=o.useState(typeof window<"u"&&window.innerWidth<r),[f,h]=o.useState(!1),[g,x]=o.useState("org"),[w,b]=o.useState(null),[j,v]=o.useState({top:0,left:0,maxHeight:400}),[k,N]=o.useState(new Set),[_,C]=o.useState(null),y=o.useRef(null),E=o.useRef(null),A=o.useRef(null),H=bt({triggerRef:y,isOpen:l,minWidth:300}),M=Kt(!1),T=Kt(!1),P=Kt(!1),S=Kt(!1),$=Kt(!1),{session:Z,signOut:R,switchSignIn:L,switchOrganization:O,switchWorkspace:F,refetch:W}=ot(),{navigateToSignIn:U}=kt(),{deployment:V}=Ce(),{activeOrganization:G,activeMembership:Y,leave:de}=ga(),{organizationMemberships:fe}=xa(),{workspaces:ne}=va(),{activeWorkspace:ae,activeMembership:re,leave:Le}=Dt(),K=(Pe=Z==null?void 0:Z.active_signin)==null?void 0:Pe.user,at=((pt=(qe=V==null?void 0:V.auth_settings)==null?void 0:qe.multi_session_support)==null?void 0:pt.enabled)??!1,ze=((aa=V==null?void 0:V.b2b_settings)==null?void 0:aa.allow_users_to_create_orgs)??!1,We=((Tt=V==null?void 0:V.b2b_settings)==null?void 0:Tt.organizations_enabled)??!1,Re=We&&(((sa=V==null?void 0:V.b2b_settings)==null?void 0:sa.workspaces_enabled)??!1),ce=s&&We,B=!G,q=o.useMemo(()=>{var ve;const ie={};for(const Ae of ne||[]){const J=(ve=Ae.organization)==null?void 0:ve.id;J&&(ie[J]||(ie[J]=[]),ie[J].push(Ae))}return ie},[ne]),X=fe||[],oe=o.useCallback(()=>{if(!E.current)return;const ie=E.current.getBoundingClientRect(),ve=300,Ae=8,J=window.innerWidth<r;if(u(J),J){v({top:ie.top,left:ie.left,maxHeight:ie.height});return}const be=Math.min(Math.max(ie.height,520),window.innerHeight-ie.top-16),Je=ie.right+Ae+ve<=window.innerWidth-8;v({top:ie.top,left:Je?ie.right+Ae:ie.left-Ae-ve,maxHeight:be})},[r]),Ee=o.useCallback(()=>{oe(),d(!0)},[oe]),z=o.useCallback(ie=>{N(ve=>{const Ae=new Set(ve);return Ae.has(ie)?Ae.delete(ie):Ae.add(ie),Ae})},[]);o.useEffect(()=>{G&&Re&&N(ie=>{if(ie.has(G.id))return ie;const ve=new Set(ie);return ve.add(G.id),ve})},[G,Re]),o.useEffect(()=>{x(Re&&ae?"ws":"org")},[Re,ae==null?void 0:ae.id]),o.useEffect(()=>{const ie=()=>{u(window.innerWidth<r),c&&oe()};return window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[r,c,oe]),o.useEffect(()=>{l||(d(!1),h(!1))},[l]),o.useEffect(()=>{if(!l)return;const ie=setTimeout(()=>{const ve=Ae=>{var be,Je,De;const J=Ae.target;(be=y.current)!=null&&be.contains(J)||(Je=E.current)!=null&&Je.contains(J)||(De=A.current)!=null&&De.contains(J)||m(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},50);return()=>clearTimeout(ie)},[l]);const D=ie=>ie.split(" ").filter(Boolean).map(ve=>ve[0]).join("").toUpperCase().slice(0,2),we=(ie,ve,Ae,J,be)=>t.jsx(be,{children:ie?t.jsx("img",{src:ve,alt:Ae}):D(`${Ae||""} ${J||""}`)}),ge=async ie=>{try{await R(ie),await W(),m(!1)}catch{}},xe=async ie=>{try{await L(ie),await W(),m(!1)}catch{}},lt=async ie=>{if(!f){h(!0);try{await O(ie),await W(),d(!1)}catch{}finally{h(!1)}}},Qe=async ie=>{if(!f){h(!0);try{await F(ie),await W(),d(!1)}catch{}finally{h(!1)}}},Q=()=>{M.open(),m(!1)},le=[...(Z==null?void 0:Z.signins)||[]].sort((ie,ve)=>{const Ae=ie.user.id===(K==null?void 0:K.id),J=ve.user.id===(K==null?void 0:K.id);return Ae===J?0:Ae?-1:1}),me=((Wt=le.find(ie=>ie.user.id===(K==null?void 0:K.id)))==null?void 0:Wt.id)||"",Te=((na=(yt=Y==null?void 0:Y.roles)==null?void 0:yt[0])==null?void 0:na.name)??null;return t.jsx($e,{children:t.jsxs(ep,{children:[t.jsxs(F0,{ref:y,onClick:()=>m(!l),children:[we(K==null?void 0:K.has_profile_picture,K==null?void 0:K.profile_picture_url,K==null?void 0:K.first_name,K==null?void 0:K.last_name,tp),e&&t.jsx(ap,{children:`${(K==null?void 0:K.first_name)||""} ${(K==null?void 0:K.last_name)||""}`.trim()})]}),typeof window<"u"&&en.createPortal(t.jsxs("div",{className:"wacht-root",style:i,children:[t.jsxs(T0,{ref:E,$position:H,$isOpen:l&&!(p&&c),$maxHeight:H==null?void 0:H.maxHeight,children:[t.jsx(sp,{children:t.jsxs(np,{children:[we(K==null?void 0:K.has_profile_picture,K==null?void 0:K.profile_picture_url,K==null?void 0:K.first_name,K==null?void 0:K.last_name,rp),t.jsxs(ip,{children:[t.jsx(op,{children:`${(K==null?void 0:K.first_name)||""} ${(K==null?void 0:K.last_name)||""}`.trim()}),t.jsx(lp,{children:(ra=K==null?void 0:K.primary_email_address)==null?void 0:ra.email})]})]})}),t.jsxs(pp,{children:[ce&&t.jsxs(cp,{$active:c,onClick:Ee,style:{marginBottom:8},children:[t.jsx(dp,{children:G?G.image_url?t.jsx("img",{src:G.image_url,alt:G.name}):(ia=G.name)==null?void 0:ia.charAt(0).toUpperCase():K!=null&&K.has_profile_picture?t.jsx("img",{src:K.profile_picture_url,alt:K.first_name}):D(`${(K==null?void 0:K.first_name)||""} ${(K==null?void 0:K.last_name)||""}`)}),t.jsx(up,{children:(G==null?void 0:G.name)??"Personal account"}),Te&&t.jsx(mp,{children:Te})]}),t.jsxs(hp,{onClick:Q,children:[t.jsx(Ea,{}),t.jsx(fp,{children:"Manage account"}),t.jsx(wp,{children:"⌘,"})]})]}),t.jsx(Ji,{}),t.jsxs(gp,{children:[t.jsx(xp,{children:"Accounts"}),at?le.map(({user:ie,id:ve})=>{var J;const Ae=ie.id===(K==null?void 0:K.id);return t.jsxs(Hn,{$active:Ae,onClick:Ae?void 0:()=>xe(ve),children:[Ae?t.jsx(Fn,{children:t.jsx(Ye,{})}):t.jsx(vp,{}),t.jsx(Tn,{children:(J=ie.primary_email_address)==null?void 0:J.email}),Ae&&t.jsx(Xi,{children:"Current"})]},ie.id)}):K&&t.jsxs(Hn,{$active:!0,children:[t.jsx(Fn,{children:t.jsx(Ye,{})}),t.jsx(Tn,{children:(oa=K.primary_email_address)==null?void 0:oa.email}),t.jsx(Xi,{children:"Current"})]}),at&&t.jsxs(Hn,{onClick:()=>{U(),m(!1)},children:[t.jsx(Fn,{style:{color:"var(--wa-text-muted)"},children:t.jsx(St,{})}),t.jsx(Tn,{style:{color:"var(--wa-text-muted)"},children:"Add account"})]})]}),t.jsx(Ji,{}),t.jsx(bp,{children:t.jsxs(yp,{onClick:()=>ge(me),children:[t.jsx(Aa,{}),"Sign out"]})})]}),t.jsxs(I0,{ref:A,$top:j.top,$left:j.left,$isOpen:l&&c,$maxHeight:j.maxHeight,children:[p&&t.jsxs(jp,{onClick:()=>d(!1),children:[t.jsx(nn,{size:13}),"Back"]}),(()=>{var _t;if(B)return null;const ie=Re&&!!ae,ve=!!((_t=Y==null?void 0:Y.eligibility_restriction)!=null&&_t.type)&&Y.eligibility_restriction.type!=="none",Ae=!!G&&!ve&&Hr(Y),J=ie&&!ve&&Tr(re),be=ie?g:"org",Je=async()=>{if(de){b("org");try{await de(),await W(),d(!1)}catch{}finally{b(null)}}},De=async()=>{if(Le){b("ws");try{await Le(),d(!1)}catch{}finally{b(null)}}},jt=()=>{if(!ie)return null;const Ke=be==="org"?"ws":"org",wt=Ke==="ws"?"Switch to workspace context":"Switch to organization context";return t.jsx(Np,{type:"button",onClick:()=>x(Ke),title:wt,"aria-label":wt,children:t.jsx(Su,{size:12})})};return t.jsxs(Cp,{children:[be==="org"&&G&&t.jsxs(io,{children:[jt(),t.jsx(oo,{children:G.image_url?t.jsx("img",{src:G.image_url,alt:G.name}):D(G.name)}),t.jsx(lo,{children:t.jsx(co,{children:G.name})}),t.jsxs(uo,{children:[Ae&&t.jsx(Fs,{onClick:()=>{P.open(),m(!1)},title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Ea,{size:14})}),t.jsx(Fs,{$destructive:!0,onClick:Je,disabled:w==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(Aa,{size:14})})]})]}),be==="ws"&&ie&&t.jsxs(io,{children:[jt(),t.jsx(oo,{children:ae.image_url?t.jsx("img",{src:ae.image_url,alt:ae.name}):D(ae.name)}),t.jsx(lo,{children:t.jsx(co,{children:ae.name})}),t.jsxs(uo,{children:[J&&t.jsx(Fs,{onClick:()=>{$.open(),m(!1)},title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Ea,{size:14})}),t.jsx(Fs,{$destructive:!0,onClick:De,disabled:w==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(Aa,{size:14})})]})]})]})})(),t.jsxs(_p,{children:[t.jsxs(eo,{$active:B,onClick:()=>{B||lt(void 0)},disabled:f,style:B?{cursor:"default"}:void 0,children:[t.jsx(ao,{$personal:!0,children:K!=null&&K.has_profile_picture?t.jsx("img",{src:K.profile_picture_url,alt:K.first_name}):t.jsx(hs,{size:12})}),t.jsx(no,{children:"Personal account"}),B&&t.jsx(In,{children:t.jsx("span",{className:"sp-check",style:{display:"inline-flex"},children:t.jsx(Vn,{size:13})})})]}),X.map(ie=>{var De,jt;const ve=ie.organization,Ae=ve.id===(G==null?void 0:G.id),J=k.has(ve.id),be=Re?q[ve.id]||[]:[],Je=!!((De=ie.eligibility_restriction)!=null&&De.type)&&ie.eligibility_restriction.type!=="none";return t.jsxs(o.Fragment,{children:[t.jsxs(eo,{$active:Ae,onClick:()=>{Je||(Re?z(ve.id):Ae||lt(ve.id))},disabled:f,style:Je?{opacity:.55,cursor:"not-allowed"}:Ae&&!Re?{cursor:"default"}:void 0,title:(jt=ie.eligibility_restriction)==null?void 0:jt.message,children:[t.jsx(ao,{children:ve.image_url?t.jsx("img",{src:ve.image_url,alt:ve.name}):D(ve.name)}),t.jsx(no,{children:ve.name}),t.jsxs(In,{children:[Je&&t.jsx(Ma,{size:12,color:"var(--wa-error)"}),Ae&&!Re&&t.jsx(Vn,{size:13}),Re&&t.jsx(kp,{size:11,$open:J})]})]}),Re&&J&&t.jsxs(t.Fragment,{children:[be.map(_t=>{var la,ca;const Ke=Ae&&(ae==null?void 0:ae.id)===_t.id,wt=_t,Bt=((la=wt.eligibility_restriction)==null?void 0:la.type)&&wt.eligibility_restriction.type!=="none";return t.jsxs(to,{$active:Ke,onClick:()=>{!Ke&&!Bt&&Qe(_t.id)},disabled:f,style:Bt||Je?{opacity:.55,cursor:"not-allowed"}:Ke?{cursor:"default"}:void 0,title:(ca=wt.eligibility_restriction)==null?void 0:ca.message,children:[t.jsx(so,{children:wt.image_url?t.jsx("img",{src:wt.image_url,alt:wt.name}):D(wt.name).charAt(0)}),t.jsx(ro,{children:wt.name}),t.jsxs(In,{children:[Bt&&t.jsx(Ma,{size:12,color:"var(--wa-error)"}),Ke&&t.jsx(Vn,{size:12})]})]},_t.id)}),!Je&&t.jsxs(to,{onClick:()=>{C(ve.id),S.open()},disabled:f,children:[t.jsx(so,{style:{background:"transparent",border:"1px dashed var(--wa-border-strong)"},children:t.jsx(St,{size:10})}),t.jsx(ro,{children:"New workspace"})]})]})]},ve.id)})]}),(()=>{var Je,De,jt;const ie=((fe==null?void 0:fe.length)??0)>0,ve=()=>ze&&t.jsx(mo,{children:t.jsxs(po,{onClick:()=>{a?(a(),m(!1)):T.open()},disabled:f,children:[t.jsx(ho,{children:t.jsx(St,{size:12})}),"New organization"]})});if(!Re||!ie)return ve();const Ae=!!((Je=Y==null?void 0:Y.eligibility_restriction)!=null&&Je.type)&&Y.eligibility_restriction.type!=="none",J=((jt=(De=fe==null?void 0:fe[0])==null?void 0:De.organization)==null?void 0:jt.id)??null,be=G&&!Ae?G.id:J;return t.jsx(mo,{children:t.jsxs(po,{onClick:()=>{C(be),S.open()},disabled:f,children:[t.jsx(ho,{children:t.jsx(St,{size:12})}),"New workspace"]})})})()]})]}),document.body),t.jsx(H0,{isOpen:M.isOpen,onClose:M.close}),ce&&t.jsxs(t.Fragment,{children:[t.jsx(Jc,{isOpen:T.isOpen,onClose:T.close}),t.jsx(s0,{isOpen:P.isOpen,onClose:P.close}),Re&&t.jsxs(t.Fragment,{children:[t.jsx(Pr,{isOpen:S.isOpen,onClose:()=>{S.close(),C(null)},organizationId:_||void 0}),t.jsx(Or,{isOpen:$.isOpen,onClose:$.close})]})]})]})})};function V0({notification:e,onAction:a}){const[s,r]=o.useState(!1),i=c=>{c.target.closest("button")||(r(!s),e.is_read||a({type:"read",id:e.id}))},l=c=>{a({type:"custom",payload:c.payload})},m=c=>{const d=new Date(c),u=new Date().getTime()-d.getTime();if(u<6e4)return"Just now";const f=Math.floor(u/6e4);if(f<60)return`${f}m`;const h=Math.floor(f/60);if(h<24)return`${h}h`;const g=Math.floor(h/24);return g<7?`${g}d`:d.toLocaleDateString(void 0,{month:"short",day:"numeric"})};return t.jsxs("div",{className:"w-flex w-gap-3 w-notif-row",onClick:i,"data-unread":e.is_read?void 0:"",children:[t.jsxs("div",{className:"w-grow w-flex-col w-justify-center",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:2},children:[!e.is_read&&t.jsx("span",{className:"w-notif-dot"}),t.jsx("h4",{className:"w-sec w-truncate",style:{margin:0},children:e.title})]}),t.jsx("p",{className:`w-secsub${s?"":" w-truncate"}`,style:{margin:0,wordWrap:s?"break-word":void 0},children:e.body}),e.ctas&&e.ctas.length>0&&t.jsx("div",{className:"w-flex w-wrap w-gap-2",style:{marginTop:10},children:e.ctas.map((c,d)=>t.jsx("button",{className:"w-btn w-btn--secondary w-btn--sm",onClick:()=>l(c),children:c.label},d))})]}),t.jsxs("div",{className:"w-flex-col w-items-end w-gap-2 w-none",children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-1 w-notif-actions",children:[e.is_read&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"unread",id:e.id})},title:"Mark as unread",children:t.jsx(Ru,{size:14})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"star",id:e.id})},title:e.is_starred?"Unstar":"Star","data-on":e.is_starred?"":void 0,children:t.jsx(Du,{size:14,fill:e.is_starred?"currentColor":"none"})}),t.jsx("button",{className:"w-btn w-btn--icon",onClick:c=>{c.stopPropagation(),a({type:"archive",id:e.id})},title:e.is_archived?"Unarchive":"Archive",children:e.is_archived?t.jsx(Wo,{size:14}):t.jsx(Do,{size:14})})]}),t.jsx("span",{className:"w-secsub",style:{whiteSpace:"nowrap"},children:m(e.created_at)})]})]})}const z0=o.forwardRef(({scope:e="all",onAction:a,fullWidth:s,maxHeight:r,className:i},l)=>{const[m,c]=o.useState("inbox"),[d,p]=o.useState(!1),[u,f]=o.useState(!1),h=o.useRef(null),g={scope:e,limit:20,is_archived:m==="archive",is_starred:m==="starred",is_read:d?!1:void 0},{notifications:x,loading:w,error:b,hasMore:j,loadMore:v,markAsRead:k,markAsUnread:N,markAllAsRead:_,archiveAllRead:C,archiveNotification:y,starNotification:E}=Oo(g);o.useEffect(()=>{if(!u)return;const T=P=>{h.current&&!h.current.contains(P.target)&&f(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[u]);const A=async T=>{switch(T.type){case"read":await k(T.id);break;case"unread":await N(T.id);break;case"archive":await y(T.id);break;case"star":await E(T.id);break;case"custom":a==null||a(T.payload);break}},H=()=>{_(),f(!1)},M=()=>{C(),f(!1)};return t.jsxs("div",{ref:l,className:`w-flex-col w-relative w-notif-panel${s?" w-notif-panel--fill":""}${i?` ${i}`:""}`,style:{maxHeight:r||"100%"},children:[t.jsxs("div",{className:"w-flex w-items-center w-justify-between w-gap-2 w-none w-notif-head",children:[t.jsxs("div",{className:"w-tabs w-grow",children:[t.jsx("button",{className:`w-tab${m==="inbox"?" w-tab--active":""}`,onClick:()=>c("inbox"),children:"Inbox"}),t.jsx("button",{className:`w-tab${m==="archive"?" w-tab--active":""}`,onClick:()=>c("archive"),children:"Archive"}),t.jsx("button",{className:`w-tab${m==="starred"?" w-tab--active":""}`,onClick:()=>c("starred"),children:"Starred"})]}),t.jsxs("button",{className:"w-btn w-btn--icon w-none w-relative",onClick:()=>f(!u),title:"Options",children:[t.jsx($u,{size:16}),d&&t.jsx("span",{className:"w-notif-filter-dot"})]}),u&&t.jsxs("div",{ref:h,className:"w-menu w-notif-menu",children:[t.jsxs("button",{className:"w-menu-item",onClick:()=>{p(!d),f(!1)},children:[t.jsx(Ou,{})," Unread only",d&&t.jsx(Ye,{className:"w-menu-check"})]}),m==="inbox"&&t.jsxs("button",{className:"w-menu-item",onClick:H,children:[t.jsx(Mu,{})," Mark all as read"]}),t.jsxs("button",{className:"w-menu-item",onClick:M,children:[t.jsx(Do,{})," Archive all read"]})]})]}),t.jsx("div",{className:"w-grow w-notif-body",children:w?t.jsx("div",{className:"w-loading",children:t.jsx(_e,{})}):b?t.jsx(Nt,{icon:t.jsx(mi,{size:20,className:"w-text-error"}),title:"Failed to load notifications",description:b.message||"An unexpected error occurred."}):x.length===0?t.jsx(Nt,{icon:t.jsx(mi,{size:20}),title:"No notifications",description:"You're all caught up!"}):t.jsxs(t.Fragment,{children:[x.map(T=>t.jsx(V0,{notification:T,onAction:A},T.id)),j&&t.jsx("div",{className:"w-flex w-justify-center",style:{padding:12},children:t.jsx("button",{className:"w-btn w-btn--ghost w-btn--sm",onClick:v,children:"Load more"})})]})})]})}),D0=o.forwardRef(({position:e,scope:a,onAction:s,className:r},i)=>t.jsx("div",{ref:i,className:`w-card w-flex-col w-notif-pop${r?` ${r}`:""}`,style:{top:(e==null?void 0:e.top)!==void 0?e.top:void 0,bottom:(e==null?void 0:e.bottom)!==void 0?e.bottom:void 0,left:(e==null?void 0:e.left)!==void 0?e.left:void 0,right:(e==null?void 0:e.right)!==void 0?e.right:void 0,maxHeight:e!=null&&e.maxHeight?e.maxHeight:"90vh"},children:t.jsx(z0,{scope:a,onAction:s,fullWidth:!0,maxHeight:e!=null&&e.maxHeight?`${e.maxHeight}px`:"100%"})}));function U0({className:e,showBadge:a=!0,scope:s="all",onAction:r}){const[i,l]=o.useState(!1),m=ts(),c=o.useRef(null),d=o.useRef(null),p=o.useRef(null),{count:u,refetch:f}=Zo({scope:s}),h=async x=>{await f(),r==null||r(x.payload)},g=bt({triggerRef:p,isOpen:i,minWidth:Math.min(450,typeof window<"u"?window.innerWidth-32:300),defaultMaxHeight:550});return o.useEffect(()=>{if(!i)return;const x=setTimeout(()=>{const w=b=>{var v,k;const j=b.target;(v=c.current)!=null&&v.contains(j)||(k=d.current)!=null&&k.contains(j)||l(!1)};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},50);return()=>{clearTimeout(x)}},[i]),t.jsx($e,{children:t.jsxs("div",{ref:c,className:`w-inline w-relative${e?` ${e}`:""}`,children:[t.jsxs("button",{ref:p,className:"w-btn w-btn--icon w-notif-bell",onClick:()=>l(!i),"aria-label":u>0?`${u} unread notifications`:"Notifications",children:[t.jsx(Eu,{strokeWidth:1}),a&&u>0&&t.jsx("span",{className:"w-notif-badge","data-dot":u<=9?"":void 0,children:u>9?"9+":""})]}),typeof window<"u"&&i&&en.createPortal(t.jsx("div",{className:"wacht-root",style:m,children:t.jsx(D0,{ref:d,position:g,scope:s,onAction:h,onClose:()=>l(!1)})}),document.body)]})})}const Sp=({showName:e=!0,showNotifications:a=!0})=>t.jsxs("div",{className:"w-flex w-items-center w-gap-2",children:[a&&t.jsx(U0,{}),t.jsx(Dr,{showName:e})]}),Ep=({children:e})=>{var r;const{session:a,loading:s}=ot();return s||!((r=a.signins)!=null&&r.length)||!a.active_signin?null:t.jsx(t.Fragment,{children:e})},Ap=({children:e})=>{var r;const{loading:a,session:s}=ot();return a||(r=s.signins)!=null&&r.length&&s.active_signin?null:t.jsx(t.Fragment,{children:e})},Mp=({onAccountSelect:e,showAddAccount:a=!0})=>{var _,C,y,E;const{session:s,loading:r,switchSignIn:i,signOut:l}=ot(),{deployment:m}=Ce(),{navigateToSignIn:c,navigate:d}=kt(),[p,u]=o.useState(null),[f,h]=o.useState(null),g=s==null?void 0:s.active_signin,x=(s==null?void 0:s.signins)||[],w=((C=(_=m==null?void 0:m.auth_settings)==null?void 0:_.multi_session_support)==null?void 0:C.enabled)??!1,b=(y=m==null?void 0:m.ui_settings)==null?void 0:y.app_name;o.useEffect(()=>{r||x.length||c()},[r,x,c]);const j=A=>A.split(" ").map(H=>H[0]).join("").toUpperCase().slice(0,2),v=async A=>{var H;h(A);try{if(await i(A),e)e(A),h(null);else{let M=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));if(M||(M=(H=m.ui_settings)==null?void 0:H.after_signin_redirect_url),M){let T;try{T=new URL(M)}catch{T=new URL(M,window.location.origin)}(m==null?void 0:m.mode)==="staging"&&T.searchParams.set("__dev_session__",xt(m.backend_host)??""),d(T.toString())}else h(null)}}catch{h(null)}},k=async(A,H)=>{A.stopPropagation(),u(H);try{await l(H)}catch{}finally{u(null)}},N=()=>{var H;let A=gt(m,new URLSearchParams(window.location.search).get("redirect_uri"));A||(A=(H=m.ui_settings)==null?void 0:H.after_signin_redirect_url),c(A)};return r?t.jsx(js,{}):x.length?t.jsx($e,{children:t.jsxs(tt,{footer:t.jsxs("span",{className:"w-sub",style:{fontSize:12.5},children:["Don't have an account?"," ",t.jsx(Et,{to:`${(E=m.ui_settings)==null?void 0:E.sign_up_page_url}${window.location.search}`,className:"w-link",children:"Sign up"})]}),children:[t.jsx(rt,{title:"Choose an account",sub:`Select an account to continue${b?` to ${b}`:""}`}),t.jsx("div",{className:"w-flex-col",children:x.map(({user:A,id:H})=>{var R,L;if(!A)return null;const M=H===(g==null?void 0:g.id),T=f===H,P=p===H,S=`${A.first_name||""} ${A.last_name||""}`.trim(),$=S||((R=A.primary_email_address)==null?void 0:R.email)||A.username||"User",Z=((L=A.primary_email_address)==null?void 0:L.email)||A.username;return t.jsxs("button",{className:"w-acct","data-active":M?"":void 0,"data-busy":T?"":void 0,onClick:()=>v(H),children:[t.jsx("div",{className:"w-avatar",children:T?t.jsx(vt,{onAccent:!0}):A.has_profile_picture?t.jsx("img",{src:A.profile_picture_url,alt:S}):j($)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:$}),Z&&Z!==$&&t.jsx("div",{className:"w-secsub w-truncate",children:Z})]}),M&&t.jsxs("span",{className:"w-pill w-pill--current",children:[t.jsx(Ye,{size:11,weight:"bold"}),"current"]}),t.jsx("span",{className:"w-kebab w-acct-out",role:"button","aria-disabled":P,title:"Sign out",onClick:O=>k(O,H),children:P?t.jsx(vt,{}):t.jsx(Aa,{size:15})})]},H)})}),a&&w&&t.jsx("div",{className:"w-acct-foot",children:t.jsxs("button",{className:"w-acct-add",onClick:N,children:[t.jsx(St,{size:15}),"Add another account"]})})]})}):null},Rp=()=>{const{navigateToSignIn:e}=kt();return o.useEffect(()=>{e()},[e]),null},Lp=()=>{const{navigateToSignUp:e}=kt();return o.useEffect(()=>{e()},[e]),null},Pp=()=>{var M,T;const{organizationMemberships:e,refetch:a,loading:s}=xa(),{workspaces:r}=va(),{switchOrganization:i,switchWorkspace:l}=ot(),{deployment:m}=Ce(),[c,d]=o.useState(null),[p,u]=o.useState("orgList"),[f,h]=o.useState(null),g=((m==null?void 0:m.b2b_settings.organizations_enabled)??!1)&&((m==null?void 0:m.b2b_settings.workspaces_enabled)??!1),x=(m==null?void 0:m.b2b_settings.allow_users_to_create_orgs)??!1,w=o.useRef(!1);o.useEffect(()=>{if(!(w.current||!e)){if(w.current=!0,e.length===0){u("createOrg");return}if(!g){u("orgList");return}if(!r||r.length===0){const P=e.find(S=>{var $,Z;return!(($=S.eligibility_restriction)!=null&&$.type)||((Z=S.eligibility_restriction)==null?void 0:Z.type)==="none"});if(P){h(P.organization.id),u("createWorkspace");return}}u("orgList")}},[e,r,g]);const b=P=>P.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=async P=>{if(g){h(P.id),u("workspaceList");return}d(P.id);try{await i(P.id)}finally{d(null)}},v=async P=>{d(P.id);try{await l(P.id)}finally{d(null)}},k=async P=>{var $;await a();const S=(($=P==null?void 0:P.data)==null?void 0:$.organization)||(P==null?void 0:P.organization)||P;if(!g){u("orgList");return}S!=null&&S.id?(h(S.id),u("createWorkspace")):u("orgList")},N=async P=>{var $;const S=(P==null?void 0:P.id)??(($=P==null?void 0:P.workspace)==null?void 0:$.id);if(S){d(S);try{await l(S)}finally{d(null)}}},_=async()=>{h(null),u("orgList")},C=(M=e==null?void 0:e.find(P=>P.organization.id===f))==null?void 0:M.organization,y=f?r==null?void 0:r.filter(P=>P.organization.id===f):[];if(s)return null;if(p==="createOrg")return t.jsx(Ue.Body,{style:{padding:0},children:t.jsx(mn,{onSuccess:k,onCancel:()=>u("orgList")})});if(p==="createWorkspace"&&f)return t.jsx(Ue.Body,{style:{padding:0},children:t.jsx(Lr,{organizationId:f,onSuccess:N,onCancel:()=>u("workspaceList"),onCreateOrganization:()=>u("createOrg")})});const E=p==="workspaceList",A=E?"Select a workspace":"Select an organization",H=E?`Choose a workspace in ${(C==null?void 0:C.name)||""}`:`to continue to ${((T=m==null?void 0:m.ui_settings)==null?void 0:T.app_name)||"App"}`;return t.jsxs("div",{className:"w-split",children:[t.jsxs("div",{className:"w-split-aside w-flex-col w-justify-between w-gap-6",children:[t.jsxs("div",{className:"w-flex-col w-gap-4",children:[t.jsx(Sr,{placement:"left"}),t.jsxs("div",{className:"w-flex-col w-gap-1",children:[t.jsx("div",{className:"w-title",children:A}),t.jsx("p",{className:"w-sub",children:H})]})]}),t.jsx(Dr,{showName:!0})]}),t.jsxs("div",{className:"w-split-main",children:[t.jsxs("div",{className:"w-grow w-flex-col",style:{overflow:"hidden",marginBottom:24},children:[t.jsxs("div",{className:"w-flex w-items-center w-gap-2",style:{marginBottom:8},children:[E&&t.jsx("button",{className:"w-btn w-btn--icon",onClick:_,"aria-label":"Go back",title:"Go back",children:t.jsx(nn,{})}),t.jsx("h2",{className:"w-sec",children:E?"Workspaces":"Your organizations"})]}),t.jsx("div",{className:"w-grow w-flex-col",style:{overflowY:"auto"},children:E?t.jsx(t.Fragment,{children:y&&y.length>0?y.map(P=>{var $,Z,R;const S=(($=P.eligibility_restriction)==null?void 0:$.type)!=="none"&&((Z=P.eligibility_restriction)==null?void 0:Z.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!S&&v(P),disabled:c===P.id||S,title:S?(R=P.eligibility_restriction)==null?void 0:R.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:P.image_url?t.jsx("img",{src:P.image_url,alt:P.name}):b(P.name).charAt(0)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:P.name}),t.jsxs("div",{className:"w-secsub w-inline w-gap-1",children:[t.jsx(cs,{}),"Workspace"]})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[S&&t.jsx(Ma,{size:16,className:"w-text-error"}),t.jsx(Qt,{})]})]},P.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(cs,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No workspaces yet"}),t.jsxs("p",{children:["Create your first workspace for"," ",(C==null?void 0:C.name)||"this organization"]})]}),t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createWorkspace"),children:[t.jsx(St,{}),"Create workspace"]})})]})}):e&&e.length>0?e.map(P=>{var U,V,G,Y,de;const S=P.organization,$=r==null?void 0:r.filter(fe=>fe.organization.id===S.id),Z=($==null?void 0:$.length)||0,R=S.member_count,L=((V=(U=P.roles)==null?void 0:U[0])==null?void 0:V.name)||"No role",O=P.roles.length-1,F=O>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${O}`:L.charAt(0).toUpperCase()+L.slice(1),W=((G=P.eligibility_restriction)==null?void 0:G.type)!=="none"&&((Y=P.eligibility_restriction)==null?void 0:Y.type)!==void 0;return t.jsxs("button",{className:"w-listrow",onClick:()=>!W&&j(S),disabled:c===S.id||W,title:W?(de=P.eligibility_restriction)==null?void 0:de.message:void 0,children:[t.jsx("div",{className:"w-avatar w-avatar--lg",children:S.image_url?t.jsx("img",{src:S.image_url,alt:S.name}):b(S.name)}),t.jsxs("div",{className:"w-grow",children:[t.jsx("div",{className:"w-sec w-truncate",children:S.name}),t.jsx("div",{className:"w-secsub w-inline w-gap-1",children:g?t.jsxs(t.Fragment,{children:[t.jsx(cs,{}),Z," ","workspace",Z!==1?"s":""]}):t.jsxs(t.Fragment,{children:[t.jsx(ps,{}),F," •"," ",R," member",R!==1?"s":""]})})]}),t.jsxs("div",{className:"w-inline w-gap-1 w-text-secondary",children:[W&&t.jsx(Ma,{size:16,className:"w-text-error"}),t.jsx(Qt,{})]})]},S.id)}):t.jsxs("div",{className:"w-empty",children:[t.jsx("div",{className:"w-empty-ic",children:t.jsx(ps,{size:20})}),t.jsxs("div",{className:"w-empty-text",children:[t.jsx("h4",{children:"No organizations yet"}),t.jsx("p",{children:x?"Create your first organization to get started":"You don't have access to any organizations yet"})]}),x&&t.jsx("div",{className:"w-empty-action",children:t.jsxs(se,{$size:"sm",onClick:()=>u("createOrg"),children:[t.jsx(St,{}),"Create organization"]})})]})})]}),E&&f&&t.jsxs(se,{$outline:!0,onClick:()=>u("createWorkspace"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create workspace"]}),!E&&e&&e.length>0&&x&&t.jsxs(se,{$outline:!0,onClick:()=>u("createOrg"),disabled:c!==null,children:[t.jsx(St,{size:12}),"Create new organization"]})]})]})},$p=({children:e})=>{var f,h,g,x;const{activeOrganization:a}=ga(),{activeWorkspace:s}=Dt(),{deployment:r}=Ce(),{loading:i,orgMembership:l,workspaceMembership:m}=Ao(),c=((r==null?void 0:r.b2b_settings.organizations_enabled)??!1)&&((r==null?void 0:r.b2b_settings.workspaces_enabled)??!1),d=((f=l==null?void 0:l.eligibility_restriction)==null?void 0:f.type)!=="none"&&((h=l==null?void 0:l.eligibility_restriction)==null?void 0:h.type)!==void 0,p=((g=m==null?void 0:m.eligibility_restriction)==null?void 0:g.type)!=="none"&&((x=m==null?void 0:m.eligibility_restriction)==null?void 0:x.type)!==void 0;return i?null:(d||p||!a?!1:c?s?(m==null?void 0:m.workspace.id)===s.id&&m.organization_id===a.id:!1:!0)?t.jsx(t.Fragment,{children:e}):t.jsx($e,{children:t.jsx(Ue,{isOpen:!0,children:t.jsx(Ue.Overlay,{children:t.jsx(Ue.Content,{className:"w-flex w-justify-center",style:{padding:0,width:900,maxWidth:"90vw"},children:t.jsx(Pp,{})})})})})},Op=e=>{const a=e.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(i=>a.startsWith(i))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(i=>a.startsWith(i))},Zp=e=>{const a=e.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(r=>a.startsWith(r))};exports.AcceptInvite=T4;exports.AuthFormImage=Sr;exports.CreateOrganizationForm=mn;exports.CreateWorkspaceDialog=Pr;exports.CreateWorkspaceForm=Lr;exports.DefaultStylesProvider=$e;exports.DeploymentInitialized=C2;exports.DeploymentInitializing=N2;exports.DeploymentProvider=Q0;exports.Dialog=Ue;exports.DialogTrigger=G4;exports.Dropdown=_s;exports.DropdownDivider=Wc;exports.DropdownItem=ea;exports.DropdownItems=ks;exports.DropdownTrigger=Cs;exports.Form=Bc;exports.FormGroup=Ge;exports.Input=ye;exports.Label=Ve;exports.MagicLinkVerification=Z4;exports.ManageAccount=Z0;exports.ManageAccountDialog=H0;exports.ManageOrganization=a0;exports.ManageWorkspace=r0;exports.ManageWorkspaceDialog=Or;exports.NavigateToSignIn=Rp;exports.NavigateToSignUp=Lp;exports.NavigationLink=Et;exports.NotificationBell=U0;exports.NotificationItem=V0;exports.NotificationPanel=z0;exports.NotificationPopover=D0;exports.OAuthProvider=wo;exports.ORG_ADMIN_PERMISSIONS=i0;exports.ORG_MANAGEMENT_PERMISSIONS=o0;exports.OTPInput=ya;exports.OrganizationSwitcher=d0;exports.PhoneNumberInput=ys;exports.PhoneVerification=Hc;exports.ProfileCompletion=Tc;exports.RequireActiveTenancy=$p;exports.SignInForm=L4;exports.SignUpForm=k4;exports.SignedIn=Ep;exports.SignedInAccounts=Mp;exports.SignedOut=Ap;exports.SimpleDialog=B4;exports.SocialCallback=O4;exports.Spinner=_e;exports.Switch=Za;exports.TwoFactorMethodSelector=Zc;exports.TwoFactorVerification=Fc;exports.UserButton=Dr;exports.UserControls=Sp;exports.WORKSPACE_ADMIN_PERMISSIONS=l0;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=c0;exports.WaitlistForm=$4;exports.canManageOrganization=Hr;exports.canManageWorkspace=Tr;exports.clearTokenCache=Pt;exports.hasIncompleteProfile=H4;exports.hasOrgPermission=Zr;exports.hasWorkspacePermission=Fr;exports.isExternalUrl=Op;exports.isOrgAdmin=Im;exports.isSafeUrl=Zp;exports.isWorkspaceAdmin=Vm;exports.redirectToProfileCompletion=F4;exports.useActiveOrganization=ga;exports.useActiveTenancy=Ao;exports.useActiveWorkspace=Dt;exports.useActorMcpServers=qd;exports.useActorProjectSearch=Zd;exports.useActorProjects=Od;exports.useActorThreadSearch=Td;exports.useAgentSession=Ad;exports.useAgentThread=Id;exports.useAgentThreadAssignments=zd;exports.useAgentThreadConversation=Ed;exports.useAgentThreadFilesystem=Vd;exports.useAgentThreadTaskGraphs=Bd;exports.useApiAuthAppSession=b2;exports.useApiAuthAuditAnalytics=_2;exports.useApiAuthAuditLogs=j2;exports.useApiAuthAuditTimeseries=k2;exports.useApiAuthKeys=y2;exports.useClient=je;exports.useCreateWebhookEndpoint=f2;exports.useDeployment=Ce;exports.useExternalAgentConnections=Kd;exports.useForgotPassword=Po;exports.useInvitation=Vo;exports.useMagicLinkVerification=Lo;exports.useNavigation=kt;exports.useNotificationStream=$o;exports.useNotificationUnreadCount=Zo;exports.useNotifications=Oo;exports.useOrganizationList=zt;exports.useOrganizationMemberships=xa;exports.useProjectTaskBoardItem=Wd;exports.useProjectTaskBoardItemComments=Gd;exports.useProjectTasks=Ud;exports.useProjectThreadFeed=Fd;exports.useProjectThreads=Hd;exports.useSession=ot;exports.useSignIn=go;exports.useSignUp=xo;exports.useSocialCallback=Ro;exports.useThemeOverrideVars=ts;exports.useUser=ba;exports.useUserSignins=Eo;exports.useWaitlist=Mo;exports.useWebhookAnalytics=x2;exports.useWebhookAppSession=m2;exports.useWebhookDeliveries=g2;exports.useWebhookEndpoints=h2;exports.useWebhookEvents=w2;exports.useWebhookStats=p2;exports.useWebhookTimeseries=v2;exports.useWorkspaceList=va;exports.useWorkspaceMemberships=tn;Object.keys(Gr).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>Gr[e]})});
119
119
  //# sourceMappingURL=index.cjs.js.map