@wizeworks/lens-ui 0.3.0-alpha.3 → 0.3.0-alpha.4

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.html CHANGED
@@ -6,9 +6,9 @@
6
6
  <meta name="color-scheme" content="light dark" />
7
7
  <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
8
8
  <title>WizeLens</title>
9
- <script type="module" crossorigin src="./assets/index-3137G7NE.js"></script>
10
- <link rel="modulepreload" crossorigin href="./assets/routes-BtwjPLlN.js">
11
- <link rel="stylesheet" crossorigin href="./assets/index-BFidY98I.css">
9
+ <script type="module" crossorigin src="./assets/index-OzB99FXf.js"></script>
10
+ <link rel="modulepreload" crossorigin href="./assets/account-CBQ8udHj.js">
11
+ <link rel="stylesheet" crossorigin href="./assets/index-DcxtAwLW.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
@@ -0,0 +1 @@
1
+ {"build":"mvghioax"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wizeworks/lens-ui",
3
- "version": "0.3.0-alpha.3",
3
+ "version": "0.3.0-alpha.4",
4
4
  "description": "WizeLens dashboard UI. Static build served by the WizeLens add-ons.",
5
5
  "license": "MIT",
6
6
  "author": "WizeWorks LLC",
@@ -27,6 +27,7 @@
27
27
  "./package.json": "./package.json"
28
28
  },
29
29
  "devDependencies": {
30
+ "@better-auth/oauth-provider": "1.7.10",
30
31
  "@better-auth/passkey": "1.7.10",
31
32
  "@better-auth/sso": "1.7.10",
32
33
  "@fontsource-variable/inter": "^5.3.0",
@@ -40,7 +41,7 @@
40
41
  "typescript": "^7.0.2",
41
42
  "uqr": "^0.1.3",
42
43
  "vite": "^8.3.4",
43
- "@wizeworks/lens-core": "0.3.0-alpha.3"
44
+ "@wizeworks/lens-core": "0.3.0-alpha.4"
44
45
  },
45
46
  "publishConfig": {
46
47
  "access": "public"
@@ -1,2 +0,0 @@
1
- import{n as e,o as t,r as n,s as r}from"./routes-BtwjPLlN.js";import{t as i}from"./shield-check-BDyAufWR.js";import{A as a,C as o,D as s,F as c,G as l,H as u,I as d,N as f,O as p,P as m,R as h,S as g,T as _,V as ee,W as v,b as te,c as y,d as b,f as x,h as S,j as C,k as w,n as T,r as E,t as D,u as O,v as k,w as ne,x as re}from"./index-3137G7NE.js";var A={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};A.node;var j=u(A),M={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};M.node;var N=u(M),P=r(),F=d();function I(){let[e,t]=(0,P.useState)(!1),[n,r]=(0,P.useState)(null),[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(!1);return{busy:e,error:n,note:i,stale:o,run:(0,P.useCallback)(async(e,n)=>{t(!0),r(null),a(null);try{return await e(),n&&a(n),!0}catch(e){return re(e)?s(!0):r(te(e)),!1}finally{t(!1)}},[]),setNote:a}}function L(){return(0,F.jsxs)(`div`,{className:`wl-banner wl-banner-info`,role:`status`,children:[`For safety, sign in again first.`,` `,(0,F.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>void o(),children:`Sign out and sign in again`})]})}function R({a:e}){return(0,F.jsxs)(F.Fragment,{children:[e.stale&&(0,F.jsx)(L,{}),e.error&&(0,F.jsx)(`div`,{className:`wl-banner wl-banner-error`,role:`alert`,children:e.error}),e.note&&(0,F.jsx)(`p`,{className:`wl-muted wl-small`,role:`status`,children:e.note})]})}var z=e=>t=>{t.preventDefault(),e(Object.fromEntries([...new FormData(t.currentTarget)].map(([e,t])=>[e,String(t)])),t.currentTarget)};function B({account:t}){let r=I(),{dialog:i,confirm:a}=y(),o=t.blockingOrgs??[],s=z(async(i,o)=>{await a({title:`Delete your account?`,body:`Your account and every organization where you are the only member are deleted, with all their data. This cannot be undone.`,confirmLabel:`Delete my account`,danger:!0})&&r.run(async()=>{if(await k(e=>e.deleteUser({password:i.password})),o.reset(),t.mail)return r.setNote(`Check your email to confirm.`);n(e(`delete-account`,[],{done:`1`})),await g()})});return(0,F.jsxs)(c,{className:`wl-panel-danger`,children:[i,(0,F.jsx)(`p`,{className:`wl-muted`,children:`Organizations where you are the only member are deleted with your account, with all their data.`}),o.length>0?(0,F.jsx)(`ul`,{className:`wl-plain-list`,children:o.map(e=>(0,F.jsxs)(`li`,{children:[`Make someone else an owner of `,e,` first, or delete it.`]},e))}):(0,F.jsxs)(`form`,{className:`wl-form`,onSubmit:s,children:[(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{label:`Your password`,name:`password`,type:`password`,autoComplete:`current-password`,required:!0}),(0,F.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-danger`,disabled:r.busy,children:`Delete my account`})]}),(0,F.jsx)(R,{a:r})]})]})}var V=()=>v(`./api/me/notifications`),H=e=>l(`PATCH`,`./api/me/notifications`,e),U=()=>Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`;function W(e){let t=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return t.includes(e)?t:[e,...t]}var G=[[`daily`,`Daily`],[`weekly`,`Weekly`],[`monthly`,`Monthly`]],K=Array.from({length:24},(e,t)=>t),q=e=>`${e.toString().padStart(2,`0`)}:00`;function J({rows:e,disabled:t,onChange:n}){let r=[{key:`project`,header:`Project`,cell:e=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`b`,{children:e.project}),` `,(0,F.jsx)(`span`,{className:`wl-muted wl-small`,children:e.org})]})},...G.map(([e,r])=>({key:e,header:r,cell:i=>(0,F.jsx)(`input`,{type:`checkbox`,className:`wl-notify-box`,"aria-label":`${r} digest for ${i.project}`,checked:i[e],disabled:t,onChange:t=>n(i,e,t.target.checked)})}))];return(0,F.jsx)(S,{columns:r,rows:e,rowKey:e=>e.projectId,empty:(0,F.jsx)(`p`,{className:`wl-muted`,children:`No projects yet.`})})}function ie({n:e,busy:t,save:n}){let r=U();return(0,F.jsxs)(`div`,{className:`wl-form-row wl-notify-when`,children:[(0,F.jsxs)(`label`,{className:`wl-field`,children:[(0,F.jsx)(`span`,{children:`Digests arrive at`}),(0,F.jsx)(`select`,{className:`wl-select`,value:e.digestHour,disabled:t||!e.digests,onChange:e=>n({digestHour:Number(e.target.value)}),children:K.map(e=>(0,F.jsx)(`option`,{value:e,children:q(e)},e))})]}),(0,F.jsxs)(`label`,{className:`wl-field`,children:[(0,F.jsx)(`span`,{children:`Time zone`}),(0,F.jsx)(`select`,{className:`wl-select`,value:e.timeZone,disabled:t,onChange:e=>n({timeZone:e.target.value}),children:W(e.timeZone).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})]}),r!==e.timeZone&&(0,F.jsxs)(`button`,{type:`button`,className:`wl-link-btn`,disabled:t,onClick:()=>n({timeZone:r}),children:[`Use `,r]})]})}function Y(){let e=I(),[t,n]=(0,P.useState)(null),{run:r}=e;(0,P.useEffect)(()=>void r(async()=>n(await V())),[r]);let i=(0,P.useCallback)(e=>void r(async()=>n(await H(e)),`Saved.`),[r]),a=t?.projects.some(e=>e.role===`owner`||e.role===`admin`);return(0,F.jsxs)(c,{children:[(0,F.jsx)(R,{a:e}),t&&!t.mail&&(0,F.jsx)(`div`,{className:`wl-banner wl-banner-info`,children:`Mail is not set up on this cloud, so emails go to its log.`}),t&&(0,F.jsxs)(`div`,{className:`wl-form`,children:[(0,F.jsx)(`p`,{className:`wl-muted wl-small`,children:`Security notices (password, email, two-step sign-in, passkeys, new devices) always go out.`}),a&&(0,F.jsx)(O,{label:`Team changes: members, roles, keys, projects, and single sign-on`,checked:t.team,disabled:e.busy,onChange:e=>i({team:e.target.checked})}),a&&(0,F.jsx)(O,{label:`Project health: a busy project stops sending data`,checked:t.health,disabled:e.busy,onChange:e=>i({health:e.target.checked})}),(0,F.jsx)(O,{label:`Digests`,checked:t.digests,disabled:e.busy,onChange:e=>i({digests:e.target.checked})}),(0,F.jsx)(ie,{n:t,busy:e.busy,save:i}),(0,F.jsx)(J,{rows:t.projects,disabled:e.busy||!t.digests,onChange:(e,t,n)=>i({projects:[{projectId:e.projectId,[t]:n}]})})]})]})}var ae=e=>new Date(e).getTime();function oe(){let e=I(),{dialog:t,confirm:n,prompt:r}=y(),[i,o]=(0,P.useState)([]),s=(0,P.useCallback)(()=>void k(e=>e.passkey.listUserPasskeys()).then(e=>o(e),()=>void 0),[]);(0,P.useEffect)(s,[s]);let l=z((t,n)=>void e.run(()=>k(e=>e.passkey.addPasskey({name:t.name||void 0})),`Passkey added.`).then(e=>e&&(n.reset(),s()))),u=async t=>{let n=await r({title:`Rename this passkey`,confirmLabel:`Save`,input:{label:`Name`,initial:t.name??``}});n&&e.run(()=>k(e=>e.passkey.updatePasskey({id:t.id,name:n}))).then(s)},d=async t=>await n({title:`Delete "${t.name||`Passkey`}"?`,body:`You can no longer sign in with it. Your password and other passkeys still work.`,confirmLabel:`Delete passkey`,danger:!0})&&void e.run(()=>k(e=>e.passkey.deletePasskey({id:t.id}))).then(s);return(0,F.jsxs)(c,{title:`Passkeys`,children:[(0,F.jsxs)(`form`,{className:`wl-form`,onSubmit:l,children:[(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{label:`Name (optional)`,name:`name`,placeholder:`Work laptop`}),(0,F.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:e.busy,children:`Add a passkey`})]}),(0,F.jsx)(R,{a:e})]}),(0,F.jsx)(S,{columns:[{key:`name`,header:`Passkey`,cell:e=>(0,F.jsx)(`strong`,{children:e.name||`Passkey`})},{key:`kind`,header:`Kind`,cell:e=>e.deviceType===`multiDevice`?`Synced`:`This device only`},{key:`added`,header:`Added`,cell:e=>a(ae(e.createdAt))},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,F.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>void u(e),children:`Rename`}),(0,F.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void d(e),children:`Delete`})]})}],rows:i,rowKey:e=>e.id,empty:(0,F.jsx)(f,{children:`No passkeys yet. A passkey signs you in with your fingerprint, face, or device PIN.`})}),t]})}function se(){let e=I(),t=z((t,n)=>{if(t.newPassword!==t.again)return void e.run(()=>Promise.reject(Error(`The two new passwords are not the same.`)));let r={currentPassword:t.currentPassword,newPassword:t.newPassword,revokeOtherSessions:t.revoke===`on`};e.run(()=>k(e=>e.changePassword(r)),`Password changed.`).then(e=>e&&n.reset())});return(0,F.jsx)(c,{title:`Password`,children:(0,F.jsxs)(`form`,{className:`wl-form`,onSubmit:t,children:[(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{label:`Current password`,name:`currentPassword`,type:`password`,autoComplete:`current-password`,required:!0}),(0,F.jsx)(b,{label:`New password (12 characters or more)`,name:`newPassword`,type:`password`,autoComplete:`new-password`,minLength:12,required:!0}),(0,F.jsx)(b,{label:`New password again`,name:`again`,type:`password`,autoComplete:`new-password`,required:!0})]}),(0,F.jsxs)(`div`,{className:`wl-form-actions wl-form-actions-split`,children:[(0,F.jsx)(O,{label:`Sign out my other devices`,name:`revoke`,defaultChecked:!0}),(0,F.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:e.busy,children:`Change password`})]}),(0,F.jsx)(R,{a:e})]})})}function ce(e,t){return e.mail?t.emailVerified?`Check your email: we sent a link to ${t.email}. Open it to confirm the change.`:`Check your new email to confirm it.`:`The cloud cannot send email; the link is in its log.`}function le({account:e,user:t}){let[n,r]=(0,P.useState)(!1),i=I(),a=z((n,a)=>void i.run(()=>k(e=>e.changeEmail({newEmail:n.newEmail})),ce(e,t)).then(e=>e&&(a.reset(),r(!1))));return(0,F.jsxs)(`div`,{className:`wl-form`,children:[(0,F.jsxs)(`p`,{className:`wl-account-line`,children:[(0,F.jsx)(`span`,{className:`wl-muted`,children:`Email`}),` `,(0,F.jsx)(`strong`,{children:t.email}),` `,!n&&(0,F.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>r(!0),children:`Change`})]}),n&&(0,F.jsx)(`form`,{onSubmit:a,children:(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{label:`New email`,name:`newEmail`,type:`email`,autoComplete:`email`,required:!0}),(0,F.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:i.busy,children:`Send the link`}),(0,F.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:()=>r(!1),children:`Cancel`})]})}),(0,F.jsx)(R,{a:i})]})}function ue({account:e,user:t}){let n=I(),r=z(e=>void n.run(async()=>(await k(t=>t.updateUser({name:e.name.trim()})),await g()),`Saved.`));return(0,F.jsxs)(c,{children:[(0,F.jsxs)(`form`,{className:`wl-form`,onSubmit:r,children:[(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{label:`Name`,name:`name`,autoComplete:`name`,required:!0,defaultValue:t.name}),(0,F.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:n.busy,children:`Save`})]}),(0,F.jsx)(R,{a:n})]}),(0,F.jsx)(le,{account:e,user:t})]})}var X=e=>new Date(e).getTime(),de=[[/Edg\//,`Edge`],[/OPR\//,`Opera`],[/Firefox\//,`Firefox`],[/Chrome\//,`Chrome`],[/Safari\//,`Safari`]],fe=[[/iPhone|iPad/,`iOS`],[/Android/,`Android`],[/Windows/,`Windows`],[/Mac OS X|Macintosh/,`macOS`],[/CrOS/,`ChromeOS`],[/Linux/,`Linux`]];function pe(e){if(!e)return`Unknown device`;let t=de.find(([t])=>t.test(e))?.[1],n=fe.find(([t])=>t.test(e))?.[1];return t?n?`${t} on ${n}`:t:e.length>40?`${e.slice(0,40)}…`:e}function Z({sessionId:e}){let t=I(),n=I(),[r,i]=(0,P.useState)(null),{run:a}=n,o=(0,P.useCallback)(()=>void a(async()=>i(await k(e=>e.listSessions()))),[a]);(0,P.useEffect)(o,[o]);let l=e=>void t.run(()=>k(t=>t.revokeSession({token:e.token})),`Signed out.`).then(o),u=()=>void t.run(()=>k(e=>e.revokeOtherSessions()),`Signed out of all other devices.`).then(o),d=[{key:`device`,header:`Device`,cell:e=>(0,F.jsx)(`span`,{title:e.userAgent??void 0,children:pe(e.userAgent)})},{key:`ip`,header:`Address`,cell:e=>(0,F.jsx)(`span`,{className:`wl-mono wl-small`,children:e.ipAddress||`–`})},{key:`made`,header:`Signed in`,cell:e=>C(X(e.createdAt)),className:`wl-nowrap`},{key:`seen`,header:`Last active`,cell:e=>w(X(e.updatedAt)),className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:t=>t.id===e?(0,F.jsx)(s,{tone:`info`,children:`This device`}):(0,F.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>l(t),children:`Sign out`})}],f=(r??[]).some(t=>t.id!==e)&&(0,F.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:u,disabled:t.busy,children:`Sign out all other devices`});return(0,F.jsxs)(c,{title:`Signed in`,action:f,children:[(0,F.jsx)(R,{a:n}),(0,F.jsx)(R,{a:t}),r&&(0,F.jsx)(S,{columns:d,rows:r,rowKey:e=>e.id})]})}var me=e=>new URL(e).searchParams.get(`secret`)??``;function he({totpURI:e}){let[t,n]=(0,P.useState)(null);(0,P.useEffect)(()=>{let t=!0;return _(()=>import(`./dist-BJrmHKyY.js`).then(r=>t&&n(r.renderSVG(e))),[],import.meta.url),()=>void(t=!1)},[e]);let r=me(e);return(0,F.jsxs)(`div`,{className:`wl-totp`,children:[(0,F.jsx)(`div`,{className:`wl-totp-qr`,"aria-label":`QR code for your app`,role:`img`,dangerouslySetInnerHTML:t?{__html:t}:void 0}),(0,F.jsxs)(`div`,{className:`wl-totp-text`,children:[(0,F.jsx)(`p`,{children:`Scan the code with your app (for example 1Password, Google Authenticator, or Authy).`}),(0,F.jsx)(`p`,{className:`wl-muted wl-small`,children:`Cannot scan? Type this key into the app:`}),(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`code`,{className:`wl-mono`,children:r}),` `,(0,F.jsx)(p,{text:r,label:`Copy key`})]})]})]})}function Q({codes:e}){return(0,F.jsxs)(`div`,{className:`wl-share-link`,children:[(0,F.jsx)(`ul`,{className:`wl-backup-codes`,children:e.map(e=>(0,F.jsx)(`li`,{children:(0,F.jsx)(`code`,{className:`wl-mono`,children:e})},e))}),(0,F.jsx)(p,{text:e.join(`
2
- `),label:`Copy backup codes`}),(0,F.jsx)(`span`,{className:`wl-muted wl-small`,children:`Keep these somewhere safe. Each works once.`})]})}function $({a:e,label:t,title:n,danger:r=!1,onPassword:i}){let{dialog:a,prompt:o}=y(),s=async()=>{let e=await o({title:n,body:`Enter your password to go on.`,confirmLabel:t,danger:r,input:{label:`Your password`,password:!0}});e&&i(e)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{type:`button`,className:`wl-btn${r?` wl-btn-danger`:``}`,disabled:e.busy,onClick:()=>void s(),children:t}),a]})}function ge({setup:e,onDone:t}){let n=I(),r=z(e=>void n.run(async()=>(await k(t=>t.twoFactor.verifyTotp({code:e.code.replace(/\s+/g,``)})),await g())).then(e=>e&&t()));return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(he,{totpURI:e.totpURI}),(0,F.jsx)(Q,{codes:e.backupCodes}),(0,F.jsxs)(`form`,{className:`wl-form`,onSubmit:r,children:[(0,F.jsxs)(x,{children:[(0,F.jsx)(b,{label:`Enter a code from your app to finish`,name:`code`,inputMode:`numeric`,autoComplete:`one-time-code`,required:!0}),(0,F.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:n.busy,children:`Finish`})]}),(0,F.jsx)(R,{a:n})]})]})}function _e(){let e=I(),[t,n]=(0,P.useState)(null);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`wl-panel-text`,children:`Sign-in asks for a code from your phone app. Keep your backup codes somewhere safe.`}),t&&(0,F.jsx)(Q,{codes:t}),(0,F.jsxs)(`div`,{className:`wl-form-actions wl-form-actions-start`,children:[(0,F.jsx)($,{a:e,label:`New backup codes`,title:`Make new backup codes?`,onPassword:t=>void e.run(async()=>n((await k(e=>e.twoFactor.generateBackupCodes({password:t}))).backupCodes))}),(0,F.jsx)($,{a:e,label:`Turn off`,title:`Turn off two-step sign-in?`,danger:!0,onPassword:t=>void e.run(async()=>(await k(e=>e.twoFactor.disable({password:t})),await g()))})]}),(0,F.jsx)(R,{a:e})]})}function ve({user:e}){let t=I(),[n,r]=(0,P.useState)(null),i=e=>void t.run(async()=>{let t=await k(t=>t.twoFactor.enable({password:e}));`totpURI`in t&&r(t)}),a=e.twoFactorEnabled?(0,F.jsx)(s,{tone:`success`,children:`On`}):(0,F.jsx)(s,{tone:`neutral`,children:`Off`}),o=(0,F.jsxs)(`h2`,{className:`wl-panel-title-row`,children:[`Two-step sign-in `,a]});return e.twoFactorEnabled?(0,F.jsx)(c,{title:o,children:(0,F.jsx)(_e,{})}):(0,F.jsxs)(c,{title:o,children:[(0,F.jsx)(`p`,{className:`wl-panel-text`,children:`Sign-in also asks for a code from an app on your phone, so a stolen password is not enough.`}),n?(0,F.jsx)(ge,{setup:n,onDone:()=>r(null)}):(0,F.jsx)($,{a:t,label:`Turn on`,title:`Turn on two-step sign-in?`,onPassword:i}),(0,F.jsx)(R,{a:t})]})}function ye(){let e=ne(),{params:n}=t(),r=e?.user;if(!e||!r)return(0,F.jsx)(c,{children:(0,F.jsx)(f,{title:`Not signed in`})});let a=[{id:`profile`,label:`Profile`,icon:h,render:()=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(T,{title:`Profile`,description:`Your name and email, as your team sees them.`}),(0,F.jsx)(ue,{account:e,user:r})]})},{id:`security`,label:`Sign-in and security`,icon:i,render:()=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(T,{title:`Sign-in and security`,description:`Your password, a second step at sign-in, and passkeys. We email you when any of these change.`}),(0,F.jsx)(se,{}),(0,F.jsx)(ve,{user:r}),(0,F.jsx)(oe,{})]})},{id:`devices`,label:`Devices`,icon:j,render:()=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(T,{title:`Devices`,description:`Where you are signed in now. Sign out of any you do not know.`}),(0,F.jsx)(Z,{sessionId:e.sessionId})]})},{id:`emails`,label:`Emails`,icon:ee,render:()=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(T,{title:`Emails`,description:`What WizeLens emails you, and when digests arrive.`}),(0,F.jsx)(Y,{})]})},{id:`delete`,label:`Delete account`,icon:N,render:()=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(T,{title:`Delete account`}),(0,F.jsx)(B,{account:e})]})}];return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(m,{title:`Account`,subtitle:`${r.name} · ${r.email}`}),(0,F.jsx)(D,{thin:!1}),(0,F.jsx)(E,{page:`account`,sections:a,active:n[0]})]})}export{ye as AccountPage};
@@ -1 +0,0 @@
1
- import{a as e,o as t,s as n}from"./routes-BtwjPLlN.js";import{t as r}from"./auth-client-v6pGHWfs.js";import{t as i}from"./shield-check-BDyAufWR.js";import{A as a,B as o,D as s,E as c,F as l,G as u,H as d,I as f,L as p,M as m,N as h,O as g,P as _,S as v,U as ee,_ as y,a as b,b as x,c as S,d as C,f as w,g as T,h as E,i as te,j as ne,k as D,l as O,m as k,n as A,o as j,p as M,r as re,s as N,u as P,v as F,w as ie,y as ae,z as I}from"./index-3137G7NE.js";var L={name:`building-complex`,size:24,node:[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]],aliases:[`building-2`]};L.node;var oe=d(L),R={name:`file-clock`,size:24,node:[[`path`,{d:`M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85`,key:`ryk6xj`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 14v2.2l1.6 1`,key:`6m4bie`}],[`circle`,{cx:`8`,cy:`16`,r:`6`,key:`10v15b`}]]};R.node;var se=d(R),z={name:`folder-kanban`,size:24,node:[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]};z.node;var B=d(z),V={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};V.node;var H=d(V),U={"org.create":`Created the organization`,"org.update":`Changed the organization`,"member.invite":`Invited someone`,"member.join":`Joined`,"member.leave":`Left`,"member.remove":`Removed a member`,"member.role":`Changed a role`,"invite.cancel":`Cancelled an invite`,"project.create":`Added a project`,"project.clear":`Cleared a project's data`,"project.delete":`Deleted a project`,"service.forget":`Forgot offline hosts`,"key.create":`Made a key`,"key.revoke":`Revoked a key`,"share.create":`Shared a trace`,"share.revoke":`Revoked a shared link`,"sso.create":`Added an identity provider`,"sso.update":`Changed an identity provider`,"sso.delete":`Removed an identity provider`,"sso.verify":`Proved a single sign-on domain`,"mcp.call":`AI agent read data`},W=e=>U[e]??e;function G(e){return{people:new Map((e?.members??[]).map(e=>[e.userId,e.name])),keys:new Map((e?.keys??[]).map(e=>[e.id,e.name])),projects:new Map((e?.projects??[]).map(e=>[e.id,e.name]))}}function K(e,t){let[n,r=``]=e.split(`:`);return n===`user`?t.people.get(r)??`Former member`:n===`key`?t.keys.has(r)?`Key ${t.keys.get(r)}`:`Revoked key`:`WizeLens`}var q=(e,t)=>typeof e==`string`?t.projects.get(e)??`deleted project`:null;function ce(e,t){let n=[];typeof e.keyId==`string`&&t.keys.has(e.keyId)&&n.push(t.keys.get(e.keyId)),typeof e.name==`string`&&n.push(e.name),typeof e.email==`string`&&n.push(e.email),typeof e.role==`string`&&n.push(`as ${e.role}`),typeof e.kind==`string`&&n.push(`${e.kind} key`);let r=q(e.projectId,t);return r&&r!==e.name&&n.push(`project ${r}`),Array.isArray(e.projectIds)&&n.push(`for ${e.projectIds.map(e=>q(e,t)).join(`, `)}`),typeof e.providerId==`string`&&n.push(e.providerId),typeof e.retentionDays==`number`&&n.push(`keep data ${e.retentionDays} days`),typeof e.days==`number`&&n.push(`for ${e.days} days`),typeof e.removed==`number`&&n.push(`${e.removed} ${e.removed===1?`host`:`hosts`}`),typeof e.line==`string`&&n.length===0&&n.push(e.line),n.join(` · `)}var J=f();function le({projectId:t,projectName:n}){let{data:r,reload:i}=y(`./api/projects/${t}/shares`),{dialog:o,confirm:s}=S(),c=async e=>await s({title:`Revoke this link?`,body:`Anyone who has it can no longer open the trace.`,confirmLabel:`Revoke link`,danger:!0})&&void T(()=>u(`DELETE`,`./api/projects/${t}/shares/${e.id}`),i);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{title:`Shared links`,description:`Read-only links to single traces of ${n}, for people without an account. Make one with Share on a trace.`}),(0,J.jsx)(l,{flush:!0,children:(0,J.jsx)(E,{columns:[{key:`trace`,header:`Trace`,cell:t=>(0,J.jsx)(`a`,{className:`wl-mono`,href:e(t.traceId),children:m(t.traceId)})},{key:`made`,header:`Shared`,cell:e=>D(e.createdMs),className:`wl-nowrap`},{key:`ends`,header:`Works until`,cell:e=>a(e.expiresMs),className:`wl-nowrap`},{key:`views`,header:`Views`,num:!0,cell:e=>e.views},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void c(e),children:`Revoke`})}],rows:r??[],rowKey:e=>e.id,empty:(0,J.jsx)(h,{title:`No shared links`,children:`Open a trace and use Share to make one.`})})}),o]})}function ue({orgId:e,org:t}){let{data:n}=y(`./api/orgs/${e}/audit`),r=G(t);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{title:`Audit log`,description:`Every change to the organization, its members, projects, keys, and links, and every AI agent call. Newest first.`}),(0,J.jsx)(l,{flush:!0,children:(0,J.jsx)(E,{columns:[{key:`time`,header:`When`,cell:e=>(0,J.jsx)(`span`,{title:ne(e.timeMs),children:D(e.timeMs)}),className:`wl-nowrap`},{key:`who`,header:`Who`,cell:e=>K(e.actor,r),className:`wl-nowrap`},{key:`what`,header:`What`,cell:e=>(0,J.jsx)(`strong`,{children:W(e.action)}),className:`wl-nowrap`},{key:`detail`,header:`Detail`,cell:e=>(0,J.jsx)(`span`,{className:`wl-muted`,children:ce(e.detail,r)}),className:`wl-wrap`}],rows:n??[],rowKey:e=>`${e.timeMs}:${e.action}:${e.actor}`,empty:(0,J.jsx)(h,{children:`Nothing yet.`})})})]})}var Y=n();function de({org:e}){let[t,n]=(0,Y.useState)(e.name),[r,i]=(0,Y.useState)(e.retentionDays),[a,o]=(0,Y.useState)(null);return(0,J.jsx)(l,{title:`General`,children:(0,J.jsxs)(`form`,{className:`wl-form`,onSubmit:n=>{n.preventDefault(),T(()=>u(`PATCH`,`./api/orgs/${e.id}`,{name:t,retentionDays:r}),()=>void v()).then(e=>o(e??`Saved.`))},children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{label:`Name`,required:!0,maxLength:100,value:t,onChange:e=>n(e.target.value)}),(0,J.jsx)(C,{label:`Keep data for (days)`,narrow:!0,type:`number`,min:1,max:400,required:!0,value:r,onChange:e=>i(Number(e.target.value)),hint:`1 to 400. Older traces are deleted every few minutes.`}),(0,J.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Save`})]}),a&&(0,J.jsx)(`p`,{className:`wl-muted wl-small`,role:`status`,children:a})]})})}function X(){let[e,t]=(0,Y.useState)(``),[n,r]=(0,Y.useState)(null);return(0,J.jsxs)(l,{title:`Another organization`,children:[(0,J.jsx)(`p`,{className:`wl-muted wl-settings-note`,children:`For a separate company or client. You own it, and it starts with one project.`}),(0,J.jsxs)(`form`,{className:`wl-form`,onSubmit:n=>{n.preventDefault(),T(async()=>{let n=await u(`POST`,`./api/orgs`,{name:e}),r=(await v()).orgs?.find(e=>e.id===n.id)?.projects[0];r&&ee(r.id),t(``)},()=>void v()).then(r)},children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{label:`Name`,required:!0,maxLength:100,value:e,onChange:e=>t(e.target.value),placeholder:`Acme`}),(0,J.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Create organization`})]}),n&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:n})]})]})}function fe({org:e}){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(null);return(0,J.jsxs)(l,{title:`Delete this organization`,className:`wl-panel-danger`,children:[(0,J.jsxs)(`p`,{className:`wl-muted wl-settings-note`,children:[`This deletes `,e.name,` with all its projects, keys, alerts, and data. It cannot be undone.`]}),(0,J.jsxs)(`form`,{className:`wl-form`,onSubmit:t=>{t.preventDefault(),T(()=>u(`DELETE`,`./api/orgs/${e.id}`,{password:r}),()=>void v()).then(o)},children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{label:`Type ${e.name} to confirm`,required:!0,value:t,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,J.jsx)(C,{label:`Your password`,type:`password`,required:!0,value:r,onChange:e=>i(e.target.value),autoComplete:`current-password`}),(0,J.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-danger`,disabled:t!==e.name,children:`Delete organization`})]}),a&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:a})]})]})}var pe=[[`oidc`,`OpenID Connect`],[`saml`,`SAML 2.0`]],me=e=>`${r()}/sso/saml2/sp/metadata?providerId=${encodeURIComponent(e)}`;function he(e,t,n){let r={providerId:n.providerId,domain:n.domain.trim().toLowerCase(),organizationId:t};if(e===`oidc`)return{...r,issuer:n.issuer.trim(),oidcConfig:{clientId:n.clientId,clientSecret:n.clientSecret,pkce:!0}};let i={entityID:n.entityId.trim(),cert:n.cert.trim()};return{...r,issuer:me(n.providerId),samlConfig:{entryPoint:n.entryPoint.trim(),idpMetadata:i,wantAssertionsSigned:!0}}}function ge(){return(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{label:`Issuer URL`,name:`issuer`,type:`url`,required:!0,placeholder:`https://acme.okta.com`,hint:`Its origin must be in the cloud's --sso-origins.`}),(0,J.jsx)(C,{label:`Client ID`,name:`clientId`,required:!0,autoComplete:`off`}),(0,J.jsx)(C,{label:`Client secret`,name:`clientSecret`,type:`password`,required:!0,autoComplete:`off`})]})}function _e(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{label:`Identity provider sign-in URL`,name:`entryPoint`,type:`url`,required:!0,placeholder:`https://idp.acme.com/sso/saml`}),(0,J.jsx)(C,{label:`Identity provider entity ID`,name:`entityId`,required:!0,placeholder:`http://www.okta.com/exk…`})]}),(0,J.jsx)(k,{label:`Signing certificate (PEM)`,name:`cert`,required:!0,placeholder:`-----BEGIN CERTIFICATE-----`,hint:`Send the email as the NameID or as an email attribute.`})]})}function ve({orgId:e,reload:t,onClose:n}){let[r,i]=(0,Y.useState)(`oidc`),[a,o]=(0,Y.useState)(null);return(0,J.jsx)(l,{title:`Add an identity provider`,className:`wl-panel-form`,action:(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:n,children:`Close`}),children:(0,J.jsxs)(`form`,{className:`wl-form`,onSubmit:i=>{i.preventDefault();let a=i.currentTarget,s=Object.fromEntries([...new FormData(a)].map(([e,t])=>[e,String(t)]));T(async()=>{await F(t=>t.sso.register(he(r,e,s))),a.reset()},t).then(e=>(o(e),e||n()))},children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(M,{label:`Protocol`,value:r,options:pe,onChange:i,hint:r===`oidc`?`Okta, Entra ID, Google, Auth0, Keycloak.`:`Any SAML 2.0 identity provider.`}),(0,J.jsx)(C,{label:`Provider id`,name:`providerId`,required:!0,pattern:`[a-z0-9][a-z0-9\\-]{1,39}`,placeholder:`acme`,hint:`2 to 40 lowercase letters, digits, dashes.`}),(0,J.jsx)(C,{label:`Email domain`,name:`domain`,required:!0,placeholder:`acme.com`,hint:`People with emails at this domain can use it.`})]}),r===`oidc`?(0,J.jsx)(ge,{}):(0,J.jsx)(_e,{}),a&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:a}),(0,J.jsxs)(`div`,{className:`wl-form-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:n,children:`Cancel`}),(0,J.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Add provider`})]})]})})}function ye(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(0);return(0,Y.useEffect)(()=>{let t=!0;return F(e=>e.sso.providers()).then(r=>t&&n(r.providers.filter(t=>t.organizationId===e)),e=>t&&i(x(e))),()=>void(t=!1)},[e,a]),{list:t,error:r,reload:()=>o(e=>e+1)}}var Z=({label:e,value:t})=>(0,J.jsxs)(`div`,{className:`wl-share-link`,children:[(0,J.jsx)(`span`,{className:`wl-muted wl-small`,children:e}),(0,J.jsx)(`code`,{className:`wl-mono wl-small`,children:t}),` `,(0,J.jsx)(g,{text:t})]});function be({p:e}){let t=encodeURIComponent(e.providerId);return e.type===`oidc`?(0,J.jsx)(Z,{label:`Redirect (callback) URL`,value:`${r()}/sso/callback/${t}`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:`ACS (reply) URL`,value:`${r()}/sso/saml2/sp/acs/${t}`}),(0,J.jsx)(Z,{label:`Entity ID (audience)`,value:e.issuer}),(0,J.jsx)(Z,{label:`Metadata URL`,value:e.spMetadataUrl})]})}function xe({p:e,reload:t}){let[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null);return e.domainVerified?null:(0,J.jsxs)(`div`,{className:`wl-sso-proof`,children:[(0,J.jsx)(`p`,{className:`wl-muted wl-small`,children:`Prove you own the domain: add a TXT record, wait for DNS, then check.`}),n&&e.domain.split(`,`).map(t=>(0,J.jsx)(Z,{label:`TXT name for ${t.trim()}`,value:`_wizelens-sso-${e.providerId}.${t.trim()}`},t)),n&&(0,J.jsx)(Z,{label:`TXT value`,value:n}),(0,J.jsxs)(`span`,{className:`wl-row-actions`,children:[!n&&(0,J.jsx)(`button`,{type:`button`,className:`wl-btn`,onClick:()=>void F(t=>t.sso.requestDomainVerification({providerId:e.providerId})).then(e=>r(e.domainVerificationToken),e=>a(x(e))),children:`Show the DNS record`}),n&&(0,J.jsx)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,onClick:()=>void T(()=>F(t=>t.sso.verifyDomain({providerId:e.providerId})),t).then(a),children:`Check DNS now`})]}),i&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:i})]})}function Se({p:e,reload:t}){let[n,r]=(0,Y.useState)(null),{dialog:i,confirm:a}=S(),o=async()=>await a({title:`Remove ${e.providerId}?`,body:`People who sign in with it can no longer do so. Their accounts stay.`,confirmLabel:`Remove provider`,danger:!0})&&void T(()=>F(t=>t.sso.deleteProvider({providerId:e.providerId})),t).then(r);return(0,J.jsxs)(l,{children:[i,(0,J.jsxs)(`div`,{className:`wl-sso-item`,children:[(0,J.jsxs)(`div`,{className:`wl-sso-head`,children:[(0,J.jsx)(`strong`,{children:e.providerId}),` `,(0,J.jsxs)(`span`,{className:`wl-muted`,children:[e.type===`oidc`?`OpenID Connect`:`SAML`,` · `,e.domain]}),(0,J.jsx)(s,{tone:e.domainVerified?`success`:`warning`,children:e.domainVerified?`Domain proven`:`Domain not proven`}),(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void o(),children:`Remove`})]}),(0,J.jsx)(be,{p:e}),(0,J.jsx)(xe,{p:e,reload:t}),n&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:n})]})]})}function Ce({orgId:e}){let{list:t,error:n,reload:r}=ye(e),[i,a]=(0,Y.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{title:`Single sign-on`,description:`People with an email at a proven domain sign in with your identity provider (OpenID Connect or SAML). New people join as members.`,action:!i&&(0,J.jsxs)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,onClick:()=>a(!0),children:[(0,J.jsx)(I,{"aria-hidden":`true`}),` Add provider`]})}),n&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:n}),i&&(0,J.jsx)(ve,{orgId:e,reload:r,onClose:()=>a(!1)}),t&&t.length===0&&!i&&(0,J.jsx)(l,{children:(0,J.jsx)(h,{title:`No identity provider yet`,children:`Add Okta, Entra ID, Google Workspace, Auth0, Keycloak, or any SAML 2.0 provider.`})}),t?.map(e=>(0,J.jsx)(Se,{p:e,reload:r},e.providerId))]})}function we({orgId:e,mail:t,reload:n,onClose:r}){let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(`member`),[c,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null);return(0,J.jsx)(l,{title:`Invite someone`,className:`wl-panel-form`,action:(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:r,children:`Close`}),children:(0,J.jsxs)(`form`,{className:`wl-form`,onSubmit:t=>{t.preventDefault(),T(async()=>{let t=await F(t=>t.organization.inviteMember({email:i,role:o,organizationId:e}));u(O(t.id)),a(``)},n).then(f)},children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{label:`Email`,type:`email`,required:!0,value:i,onChange:e=>a(e.target.value),placeholder:`sam@company.com`,autoFocus:!0}),(0,J.jsx)(M,{label:`Role`,value:o,options:j,onChange:s,hint:te[o]}),(0,J.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Send invite`})]}),c&&(0,J.jsxs)(`div`,{className:`wl-share-link`,children:[(0,J.jsx)(`code`,{className:`wl-mono wl-small`,children:c}),` `,(0,J.jsx)(g,{text:c,label:`Copy invite link`}),(0,J.jsxs)(`span`,{className:`wl-muted wl-small`,children:[`Send this link to them. It works once, for 7 days.`,t&&` We emailed it too.`]})]}),d&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:d})]})})}function Te({orgId:e,mail:t,data:n,reload:r}){let[i,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),{dialog:u,confirm:d}=S(),f=(e,t=null)=>void T(e,r).then(e=>(o(e),c(e?null:t))),p=n=>f(()=>F(t=>t.organization.inviteMember({email:n.email,role:n.role,organizationId:e,resend:!0})),t?`We sent the invite to ${n.email} again.`:`The invite works for 7 more days.`),m=async e=>await d({title:`Cancel this invite?`,body:`The link for ${e.email} stops working.`,confirmLabel:`Cancel invite`,danger:!0})&&f(()=>F(t=>t.organization.cancelInvitation({invitationId:e.id})));return(0,J.jsxs)(l,{title:`Pending invites`,flush:!0,children:[i&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error wl-panel-banner`,children:i}),s&&(0,J.jsx)(`p`,{className:`wl-panel-note`,role:`status`,children:s}),(0,J.jsx)(E,{columns:[{key:`email`,header:`Email`,cell:e=>(0,J.jsx)(`strong`,{children:e.email})},{key:`role`,header:`Role`,cell:e=>b[e.role]},{key:`ends`,header:`Link works until`,cell:e=>a(e.expiresMs),className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,J.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,J.jsx)(g,{text:O(e.id),label:`Copy link`,asLink:!0}),(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>p(e),children:t?`Send again`:`Extend`}),(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void m(e),children:`Cancel`})]})}],rows:n.invites,rowKey:e=>e.id,empty:(0,J.jsx)(h,{children:`No open invites.`})}),u]})}var Ee=[[`ingest`,`Ingest: an app sends data`],[`read`,`Read: an AI agent or script reads data`]];function De({kind:e,secret:t}){return(0,J.jsxs)(`div`,{className:`wl-share-link`,children:[(0,J.jsx)(`code`,{className:`wl-mono wl-small`,children:t}),` `,(0,J.jsx)(g,{text:t,label:`Copy key`}),(0,J.jsxs)(`span`,{className:`wl-muted wl-small`,children:[`Copy it now: it is not shown again. `,e===`ingest`?`Set it as WIZELENS_HUB_TOKEN on the app.`:`Send it as Authorization: Bearer <key> to /_wizelens/mcp.`]})]})}function Oe({orgId:e,data:t,reload:n,onClose:r}){let[i,a]=(0,Y.useState)(`ingest`),[o,s]=(0,Y.useState)(``),[c,d]=(0,Y.useState)(t.projects[0]?[t.projects[0].id]:[]),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),g=(e,t)=>d(n=>i===`ingest`?[e]:t?[...n,e]:n.filter(t=>t!==e)),_=t=>{t.preventDefault(),u(`POST`,`./api/orgs/${e}/keys`,{kind:i,name:o,projectIds:i===`ingest`?c.slice(0,1):c}).then(e=>(p(e.token),s(``),h(null),n()),e=>h(e instanceof Error?e.message:String(e)))},v=t.projects.map(e=>[e.id,e.name]);return(0,J.jsx)(l,{title:`New key`,className:`wl-panel-form`,action:(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:r,children:f?`Done`:`Close`}),children:(0,J.jsxs)(`form`,{className:`wl-form`,onSubmit:_,children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(M,{label:`Kind`,value:i,options:Ee,onChange:e=>(a(e),d(e=>e.slice(0,1)))}),(0,J.jsx)(C,{label:`Name`,required:!0,value:o,onChange:e=>s(e.target.value),placeholder:`orders-api`,hint:`Name it after the app or agent that uses it.`}),i===`ingest`&&(0,J.jsx)(M,{label:`Project`,value:c[0]??``,options:v,onChange:e=>d([e])}),(0,J.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,disabled:c.length===0,children:`Create key`})]}),i===`read`&&(0,J.jsxs)(`fieldset`,{className:`wl-check-list`,children:[(0,J.jsx)(`legend`,{children:`Projects it may read`}),t.projects.map(e=>(0,J.jsx)(P,{label:e.name,checked:c.includes(e.id),onChange:t=>g(e.id,t.target.checked)},e.id))]}),f&&(0,J.jsx)(De,{kind:i,secret:f}),m&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:m})]})})}function Q({orgId:e,data:t,reload:n}){let r=new Map(t.projects.map(e=>[e.id,e.name])),{dialog:i,confirm:o}=S(),c=async t=>await o({title:`Revoke ${t.name}?`,body:t.kind===`ingest`?`Apps that send with this key stop being recorded at once.`:`Agents and scripts that read with this key lose access at once.`,confirmLabel:`Revoke key`,danger:!0})&&void T(()=>u(`DELETE`,`./api/orgs/${e}/keys/${t.id}`),n);return(0,J.jsxs)(l,{flush:!0,children:[(0,J.jsx)(E,{columns:[{key:`name`,header:`Key`,cell:e=>(0,J.jsxs)(`span`,{className:`wl-who`,children:[(0,J.jsx)(`strong`,{children:e.name}),(0,J.jsxs)(`small`,{className:`wl-mono`,children:[e.prefix,`…`]})]})},{key:`kind`,header:`Kind`,cell:e=>(0,J.jsx)(s,{tone:e.kind===`ingest`?`info`:`neutral`,children:e.kind===`ingest`?`Ingest`:`Read`})},{key:`projects`,header:`Projects`,cell:e=>e.projectIds.map(e=>r.get(e)??`Deleted project`).join(`, `),className:`wl-wrap`},{key:`made`,header:`Created`,cell:e=>a(e.createdMs),className:`wl-nowrap`},{key:`used`,header:`Last used`,cell:e=>e.lastUsedMs?D(e.lastUsedMs):`Never`,className:`wl-nowrap`},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void c(e),children:`Revoke`})}],rows:t.keys,rowKey:e=>e.id,empty:(0,J.jsx)(h,{title:`No keys yet`,children:`Make an ingest key for each app that sends data.`})}),i]})}function ke({orgId:e,me:t,manage:n,onlyOwner:r,run:i,confirm:a},o){let s=async()=>await a({title:`Remove ${o.name}?`,body:`${o.name} loses access to this organization and its data right away.`,confirmLabel:`Remove`,danger:!0})&&i(()=>F(t=>t.organization.removeMember({memberIdOrEmail:o.memberId,organizationId:e}))),c=async()=>await a({title:`Leave this organization?`,body:`You lose access to its data. Someone must invite you again to come back.`,confirmLabel:`Leave`,danger:!0})&&i(async()=>(await F(t=>t.organization.leave({organizationId:e})),await v()));return o.userId===t?r?null:(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void c(),children:`Leave`}):n?(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void s(),children:`Remove`}):null}function Ae(e){let t=(t,n)=>e.run(async()=>{await F(r=>r.organization.updateMemberRole({memberId:t.memberId,role:n,organizationId:e.orgId})),t.userId===e.me&&await v()});return[{key:`name`,header:`Name`,cell:t=>(0,J.jsxs)(`span`,{className:`wl-who`,children:[(0,J.jsxs)(`strong`,{children:[t.name,t.userId===e.me&&(0,J.jsx)(`span`,{className:`wl-muted`,children:` (you)`})]}),(0,J.jsx)(`small`,{children:t.email})]})},{key:`role`,header:`Role`,cell:n=>e.manage?(0,J.jsx)(c,{small:!0,label:`Role of ${n.name}`,value:n.role,options:j,onChange:e=>t(n,e)}):b[n.role]},{key:`since`,header:`Member since`,cell:e=>a(e.sinceMs),className:`wl-nowrap`},{key:`x`,header:``,cell:t=>ke(e,t),className:`wl-cell-actions`}]}function je({orgId:e,me:t,data:n,reload:r}){let[i,a]=(0,Y.useState)(null),{dialog:o,confirm:s}=S(),c=n.members.filter(e=>e.role===`owner`),u={orgId:e,me:t,manage:N(n.role),onlyOwner:c.length===1&&c[0].userId===t,run:e=>void T(e,r).then(a),confirm:s};return(0,J.jsxs)(l,{title:`Members`,flush:!0,children:[i&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error wl-panel-banner`,children:i}),(0,J.jsx)(E,{columns:Ae(u),rows:n.members,rowKey:e=>e.memberId}),o]})}function Me({orgId:e,reload:t,onClose:n}){let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(null);return(0,J.jsx)(l,{title:`New project`,className:`wl-panel-form`,action:(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:n,children:`Close`}),children:(0,J.jsxs)(`form`,{className:`wl-form`,onSubmit:i=>{i.preventDefault(),T(()=>u(`POST`,`./api/orgs/${e}/projects`,{name:r}),()=>(t(),void v())).then(e=>(o(e),e||n()))},children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(C,{label:`Name`,required:!0,maxLength:100,value:r,onChange:e=>i(e.target.value),placeholder:`Checkout`,autoFocus:!0,hint:`Usually one app or team. Make an ingest key for it next.`}),(0,J.jsx)(`button`,{type:`submit`,className:`wl-btn wl-btn-primary`,children:`Add project`})]}),a&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:a})]})})}function Ne({orgId:e,data:t,reload:n}){let[r,i]=(0,Y.useState)(null),{dialog:a,confirm:o}=S(),s=e=>void T(e,()=>(n(),void v())).then(i),c=e=>t.keys.filter(t=>t.projectIds.includes(e.id)).length,d=async t=>await o({title:`Clear the data of ${t.name}?`,body:`Every trace, log, and metric of this project is deleted. Its keys and alerts stay.`,confirmLabel:`Clear data`,danger:!0,typeToConfirm:t.name})&&s(()=>u(`POST`,`./api/orgs/${e}/projects/${t.id}/clear`)),f=async t=>await o({title:`Delete ${t.name}?`,body:`The project, its data, its keys, and its alerts are deleted. Apps that send with its keys stop being recorded.`,confirmLabel:`Delete project`,danger:!0,typeToConfirm:t.name})&&s(()=>u(`DELETE`,`./api/orgs/${e}/projects/${t.id}`));return(0,J.jsxs)(l,{flush:!0,children:[r&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error wl-panel-banner`,children:r}),(0,J.jsx)(E,{columns:[{key:`name`,header:`Project`,cell:e=>(0,J.jsx)(`strong`,{children:e.name})},{key:`id`,header:`Project id`,cell:e=>(0,J.jsxs)(`span`,{className:`wl-id`,children:[e.id.slice(0,8),`… `,(0,J.jsx)(g,{text:e.id,label:`Copy project id`})]})},{key:`keys`,header:`Keys`,num:!0,cell:e=>c(e)},{key:`x`,header:``,className:`wl-cell-actions`,cell:e=>(0,J.jsxs)(`span`,{className:`wl-row-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn`,onClick:()=>void d(e),children:`Clear data`}),(0,J.jsx)(`button`,{type:`button`,className:`wl-link-btn wl-text-error`,onClick:()=>void f(e),children:`Delete`})]})}],rows:t.projects,rowKey:e=>e.id}),a]})}function $({label:e,open:t,onOpen:n}){return t?null:(0,J.jsxs)(`button`,{type:`button`,className:`wl-btn wl-btn-primary`,onClick:n,children:[(0,J.jsx)(I,{"aria-hidden":`true`}),` `,e]})}function Pe({org:e,data:t,me:n,mail:r,reload:i}){let[a,o]=(0,Y.useState)(!1),s=N(t.role);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{title:`People`,description:`Who can see this organization's data, and what each person may change.`,action:s&&(0,J.jsx)($,{label:`Invite someone`,open:a,onOpen:()=>o(!0)})}),a&&(0,J.jsx)(we,{orgId:e.id,mail:r,reload:i,onClose:()=>o(!1)}),(0,J.jsx)(je,{orgId:e.id,me:n,data:t,reload:i}),s&&t.invites.length>0&&(0,J.jsx)(Te,{orgId:e.id,mail:r,data:t,reload:i})]})}function Fe({org:e,data:t,reload:n}){let[r,i]=(0,Y.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{title:`Projects`,description:`Each project keeps its own traces, dashboards, and alerts. A trace that crosses projects still opens whole for people who can read both.`,action:(0,J.jsx)($,{label:`New project`,open:r,onOpen:()=>i(!0)})}),r&&(0,J.jsx)(Me,{orgId:e.id,reload:n,onClose:()=>i(!1)}),(0,J.jsx)(Ne,{orgId:e.id,data:t,reload:n})]})}function Ie({org:e,data:t,reload:n}){let[r,i]=(0,Y.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{title:`API keys`,description:`Ingest keys let an app send data to one project. Read keys let an AI agent or script read the projects you pick. Only a hash is kept, so a key is shown once.`,action:(0,J.jsx)($,{label:`New key`,open:r,onOpen:()=>i(!0)})}),r&&(0,J.jsx)(Oe,{orgId:e.id,data:t,reload:n,onClose:()=>i(!1)}),(0,J.jsx)(Q,{orgId:e.id,data:t,reload:n})]})}function Le({org:e}){let t=N(e.role);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{title:`Organization`,description:`${e.name}. Your role: ${e.role}.`}),t&&(0,J.jsx)(de,{org:e},`settings:${e.id}`),(0,J.jsx)(X,{}),e.role===`owner`&&(0,J.jsx)(fe,{org:e},`delete:${e.id}`)]})}function Re(e,t){let{org:n,project:r}=t,a=N(n.role);return[!!e&&{id:`people`,label:`People`,icon:p,count:e.data.members.length,render:()=>(0,J.jsx)(Pe,{...e})},!!e&&a&&{id:`projects`,label:`Projects`,icon:B,count:e.data.projects.length,render:()=>(0,J.jsx)(Fe,{...e})},!!e&&a&&{id:`keys`,label:`API keys`,icon:H,count:e.data.keys.length,render:()=>(0,J.jsx)(Ie,{...e})},a&&{id:`sso`,label:`Single sign-on`,icon:i,render:()=>(0,J.jsx)(Ce,{orgId:n.id},n.id)},{id:`links`,label:`Shared links`,icon:o,render:()=>(0,J.jsx)(le,{projectId:r.id,projectName:r.name})},a&&{id:`audit`,label:`Audit log`,icon:se,render:()=>(0,J.jsx)(ue,{orgId:n.id,org:e?.data??null})},{id:`organization`,label:`Organization`,icon:oe,render:()=>(0,J.jsx)(Le,{org:n})}].filter(e=>!!e)}function ze(){let e=ie(),n=ae(e),{params:r}=t(),{data:i,error:a,reload:o}=y(n?`./api/orgs/${n.org.id}`:null);if(!n)return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_,{title:`Team`,subtitle:`You are not in an organization yet.`}),(0,J.jsx)(l,{children:(0,J.jsx)(h,{title:`No organization`,children:`Make one below, or ask your team for an invite link.`})}),(0,J.jsx)(X,{})]});let s=i?{org:n.org,data:i,me:e?.user?.id??``,mail:e?.mail??!1,reload:o}:null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_,{title:`Team`,subtitle:`${n.org.name}: people, projects, keys, and access.`}),a&&(0,J.jsx)(`div`,{className:`wl-banner wl-banner-error`,children:a}),(0,J.jsx)(re,{page:`team`,sections:Re(s,n),active:r[0]})]})}export{ze as TeamPage};
@@ -1,3 +0,0 @@
1
- import{l as e,n as t,r as n}from"./routes-BtwjPLlN.js";var r={organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`],project:[`read`,`create`,`update`,`delete`],key:[`read`,`create`,`revoke`],alert:[`read`,`create`,`update`,`delete`],share:[`create`,`revoke`],audit:[`read`]},i=[`owner`,`admin`,`member`,`viewer`],a={project:[`read`,`create`,`update`,`delete`],key:[`read`,`create`,`revoke`],alert:[`read`,`create`,`update`,`delete`],share:[`create`,`revoke`],audit:[`read`]},o={project:[`read`],key:[`read`],alert:[`read`],ac:[`read`]},s={member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],ac:[`create`,`read`,`update`,`delete`]},c={viewer:o,member:{...o,alert:a.alert,share:a.share},admin:{...s,...a,organization:[`update`]},owner:{...s,...a,organization:[`update`,`delete`]}};function l(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{code:e,message:t,toString:()=>e}]))}var u=l({CHALLENGE_NOT_FOUND:`Challenge not found`,YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY:`You are not allowed to register this passkey`,FAILED_TO_VERIFY_REGISTRATION:`Failed to verify registration`,PASSKEY_NOT_FOUND:`Passkey not found`,AUTHENTICATION_FAILED:`Authentication failed`,UNABLE_TO_CREATE_SESSION:`Unable to create session`,USER_NOT_FOUND:`User not found`,FAILED_TO_UPDATE_PASSKEY:`Failed to update passkey`,PREVIOUSLY_REGISTERED:`Previously registered`,REGISTRATION_CANCELLED:`Registration cancelled`,AUTH_CANCELLED:`Auth cancelled`,UNKNOWN_ERROR:`Unknown error`,SESSION_REQUIRED:`Passkey registration requires an authenticated session`,RESOLVE_USER_REQUIRED:`Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false`,RESOLVED_USER_INVALID:`Resolved user is invalid`}),d=`1.7.10`;function f(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function p(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function m(){return h.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var h={stubThis:e=>e};function g(e){let{id:t}=e;return{...e,id:p(t),transports:e.transports}}function _(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var v=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function y({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new v({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new v({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new v({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new v({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new v({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new v({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new v({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new v({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!_(t))return new v({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new v({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new v({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new v({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var b=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},x=[`cross-platform`,`platform`];function S(e){if(e&&!(x.indexOf(e)<0))return e}async function ee(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!m())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:p(t.challenge),user:{...t.user,id:p(t.user.id)},excludeCredentials:t.excludeCredentials?.map(g)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=b.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw y({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){C(`getPublicKeyAlgorithm()`,e)}let h;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(h=f(e))}catch(e){C(`getPublicKey()`,e)}let _;if(typeof c.getAuthenticatorData==`function`)try{_=f(c.getAuthenticatorData())}catch(e){C(`getAuthenticatorData()`,e)}return{id:o,rawId:f(s),response:{attestationObject:f(c.attestationObject),clientDataJSON:f(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:h,authenticatorData:_},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:S(a.authenticatorAttachment)}}function C(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function te(){if(!m())return w.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?w.stubThis(new Promise(e=>e(!1))):w.stubThis(e.isConditionalMediationAvailable())}var w={stubThis:e=>e};function ne({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new v({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new v({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!_(t))return new v({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new v({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new v({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function re(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!m())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(g));let a={...t,challenge:p(t.challenge),allowCredentials:i},o={};if(n){if(!await te())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=b.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw ne({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,h;return u.userHandle&&(h=f(u.userHandle)),{id:c,rawId:f(l),response:{authenticatorData:f(u.authenticatorData),clientDataJSON:f(u.clientDataJSON),signature:f(u.signature),userHandle:h},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:S(s.authenticatorAttachment)}}var ie=`1.7.10`,T=Symbol.for(`better-auth:broadcast-channel`),ae=()=>Math.floor(Date.now()/1e3),oe=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window<`u`)try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:ae()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function E(e=`better-auth.message`){return globalThis[T]||(globalThis[T]=new oe(e)),globalThis[T]}var D=[],O=0,se=null,k=4,ce=globalThis.nanostoresGlobal||={epoch:0},le=()=>{let e,t;for(;O<D.length;){t=O,O+=k;let n=se?.get(D[t]);if(n){if(!n.has(D[t+1]))continue;n.clear()}try{D[t](D[t+1].value,D[t+2],D[t+3])}catch(t){e=t}}if(D.length=O=0,e)throw e},A=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{se?.get(e)?.delete(n);for(let t=O;t<D.length;)D[t]===e&&D[t+1]===n?D.splice(t,k):t+=k;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){ce.epoch++;let i=!D.length&&!0;for(let i of t)D.push(i,n,e,r);i&&le()},off(){},set(e){let t=n.value;n.eq(t,e)||(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},ue=2,de=5,j=6,M=10,fe=(e,t,n,r)=>(e.events=e.events||{},e.events[n+M]||(e.events[n+M]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);~i&&(r.splice(i,1),r.length||(e.events[n+M](),delete e.events[n+M]))}),pe=(e,t)=>fe(e,t,ue,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),me=1e3,N=(e,t)=>fe(e,n=>{let r=t(n);r&&e.events[j].push(r)},de,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[j]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[j])t();e.events[j]=[]}},me)},()=>{e.listen=n,e.off=r}});function he(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function P(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!P(e[n],t[n]))return!1;return!0}if(he(e)&&he(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!P(e[r],t[r]))return!1;return!0}return!1}function ge(e,t){return pe(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var F=Symbol.for(`better-auth:focus-manager`),_e=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function ve(){return globalThis[F]||(globalThis[F]=new _e),globalThis[F]}var I=Symbol.for(`better-auth:online-manager`),ye=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function L(){return globalThis[I]||(globalThis[I]=new ye),globalThis[I]}var be={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},xe=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Se={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},Ce=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function we(e){return e instanceof Date&&!isNaN(e.getTime())}function Te(e){let t=Ce.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return we(f)?f:null}function Ee(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in Se)return Se[s];if(!xe.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(be).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t)r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);else{if(a&&typeof t==`string`){let e=Te(t);if(e)return e}return i?i(e,t):t}})}catch(t){if(n)throw t;return e}}function De(e,t={strict:!0}){return Ee(e,t)}var Oe=Symbol.for(`better-auth:auth-query`);function ke(e){let t=A(e);return Object.defineProperty(t,Oe,{value:!0}),t}var Ae=()=>typeof window>`u`;function je(e,t){return P(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var R=(e,t,n,r)=>{let i=ke({data:null,error:null,isPending:!0,isRefetching:!1,refetch:e=>o(e)});N(i,()=>ge(i,je));let a=0,o=async e=>{let o=++a;return new Promise(s=>{let c=typeof r==`function`?r({data:i.get().data,error:i.get().error,isPending:i.get().isPending}):r;n(t,{...c,query:{...c?.query,...e?.query},async onSuccess(e){if(o===a){let t=i.get(),n=t.data!=null&&e.data!=null&&P(t.data,e.data)?t.data:e.data;i.set({data:n,error:null,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}await c?.onSuccess?.(e)},async onError(e){let{request:t}=e,n=typeof t.retry==`number`?t.retry:t.retry?.attempts,r=t.retryAttempt||0;if(!(n&&r<n)){if(o===a){let t=e.error.status===401;i.set({error:e.error,data:t?null:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}await c?.onError?.(e)}},async onRequest(e){if(o===a){let e=i.get();i.set({isPending:e.data===null,data:e.data,error:null,isRefetching:!0,refetch:i.value.refetch})}await c?.onRequest?.(e)}}).catch(e=>{o===a&&i.set({error:e,data:i.get().data,isPending:!1,isRefetching:!1,refetch:i.value.refetch})}).finally(()=>{s(void 0)})})};e=Array.isArray(e)?e:[e];let s=!1,c=!1,l=!1,u=()=>{s?l=!0:(s=!0,o().finally(()=>{s=!1;let e=l&&c;l=!1,e&&u()}))};return N(i,()=>{if(Ae())return;c=!0;let t=!1,n,r=e.map(e=>e.listen(()=>{t?o():(t=!0,clearTimeout(n),u())}));return n=setTimeout(()=>{t=!0,u()},0),()=>{c=!1;for(let e of r)e();clearTimeout(n)}}),i},z=()=>Math.floor(Date.now()/1e3),Me=5;function Ne(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:r,options:i={}}=e,a=i.sessionOptions?.refetchInterval??0,o=i.sessionOptions?.refetchOnWindowFocus??!0,s=i.sessionOptions?.refetchWhenOffline??!1,c={isInitialized:!1,lastSessionRequest:0},l=()=>s||L().isOnline,u=e=>{if(l()){if(e?.event===`storage`)t();else if(e?.event===`poll`)c.lastSessionRequest=z(),t();else if(e?.event===`visibilitychange`){if(z()-c.lastSessionRequest<Me)return;c.lastSessionRequest=z(),t()}else t()}},d=e=>{E().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},f=()=>{a&&a>0&&(c.pollInterval=setInterval(()=>{n()&&u({event:`poll`})},a*1e3))},p=()=>{c.unsubscribeBroadcast=E().subscribe(()=>{u({event:`storage`})})},m=()=>{o&&(c.unsubscribeFocus=ve().subscribe(()=>{u({event:`visibilitychange`})}))},h=()=>{c.unsubscribeOnline=L().subscribe(e=>{e&&u({event:`visibilitychange`})})},g=()=>{c.unsubscribeSignal=r.listen(()=>{t()})};return{init:()=>{c.isInitialized||(c.isInitialized=!0,f(),p(),m(),h(),g(),c.cleanupBroadcastSetup=E().setup(),c.cleanupFocusSetup=ve().setup(),c.cleanupOnlineSetup=L().setup())},cleanup:()=>{c.isInitialized&&(c.pollInterval&&=(clearInterval(c.pollInterval),void 0),c.unsubscribeBroadcast&&=(c.unsubscribeBroadcast(),void 0),c.unsubscribeFocus&&=(c.unsubscribeFocus(),void 0),c.unsubscribeOnline&&=(c.unsubscribeOnline(),void 0),c.unsubscribeSignal&&=(c.unsubscribeSignal(),void 0),c.cleanupBroadcastSetup&&=(c.cleanupBroadcastSetup(),void 0),c.cleanupFocusSetup&&=(c.cleanupFocusSetup(),void 0),c.cleanupOnlineSetup&&=(c.cleanupOnlineSetup(),void 0),c.isInitialized=!1,c.lastSessionRequest=0)},triggerRefetch:u,broadcastSessionUpdate:d}}var B=Object.create(null),V=e=>({}),H=new Proxy(B,{get(e,t){return V()[t]??B[t]},has(e,t){return t in V()||t in B},set(e,t,n){let r=V(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=V(!0);return delete n[t],!0},ownKeys(){let e=V(!0);return Object.keys(e)}});H.NODE_ENV;function U(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return U(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return U(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return U(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return U(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return U(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return U(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return U(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});function Pe(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function Fe(e){let t=e.split(`
2
- at `);return t.length<=1?e:(t.splice(1,1),t.join(`
3
- at `))}function Ie(e,t){class n extends e{#e;constructor(...e){if(Pe()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Fe(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var Le={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Ie(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:Le[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var W=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},Re=47;function ze(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===Re;)t--;return t===e.length?e:e.slice(0,t)}function Be(e){try{return(ze(new URL(e).pathname)||`/`)!==`/`}catch{throw new W(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function Ve(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new W(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof W?t:new W(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function G(e,t=`/api/auth`){if(Ve(e),Be(e))return e;let n=ze(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function He(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[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])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function Ue(e,t,n,r,i){if(e)return G(e,t);if(r!==!1){let e=H.BETTER_AUTH_URL||H.NEXT_PUBLIC_BETTER_AUTH_URL||H.PUBLIC_BETTER_AUTH_URL||H.NUXT_PUBLIC_BETTER_AUTH_URL||H.NUXT_PUBLIC_AUTH_URL||(H.BASE_URL===`/`?void 0:H.BASE_URL);if(e)return G(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&He(o,`proto`)&&He(a,`host`))try{return G(`${o}://${a}`,t)}catch{}if(n){let e=We(n.url);if(!e)throw new W(`Could not get origin from request. Please provide a valid base URL.`);return G(e,t)}if(typeof window<`u`&&window.location)return G(window.location.origin,t)}function We(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var Ge=[`javascript:`,`data:`,`vbscript:`];function Ke(e){let t;try{t=new URL(e)}catch{return!0}return!Ge.includes(t.protocol)}var qe={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&Ke(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},Je=()=>typeof window>`u`,Ye=me;function Xe(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function Ze(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function Qe(e){return!e||e.session===null&&e.user===null?null:e}function $e(e,t){return P(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function et(e,t){let n=A(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>u(e),s=ke({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});ge(s,$e);let c=async(t,n)=>{let r=s.value;if(s.set({...r,isPending:r.data===null,isRefetching:!0,error:null,refetch:o}),t.aborted)return`aborted`;try{let r=await e(`/get-session`,{method:`GET`,query:n?.query,signal:t});if(t.aborted)return`aborted`;let{data:i,error:a}=Ze(r),c=`fresh`;if(i?.needsRefresh)try{let n=await e(`/get-session`,{method:`POST`,signal:t});if(t.aborted)return`aborted`;({data:i,error:a}=Ze(n))}catch{if(t.aborted)return`aborted`;c=`stale`}if(a){let e=s.value,t=a?.status===401;return s.set({data:t?null:e.data,error:a,isPending:!1,isRefetching:!1,refetch:o}),`failed`}let l=Qe(i),u=s.value,d=u.data!=null&&l!=null&&P(u.data,l)?u.data:l;return s.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:o}),c}catch(e){if(t.aborted)return`aborted`;let n=s.value;return s.set({data:n.data,error:e,isPending:!1,isRefetching:!1,refetch:o}),`failed`}},l=()=>{let e=s.value.data?.session?.expiresAt,t=e instanceof Date?e.getTime():1/0;return Math.min(Date.now()+Ye,t)},u=e=>{i=0,r?.cancel();let t=new AbortController,n={cancel:()=>t.abort(),promise:Promise.resolve().then(()=>t.signal.aborted?`aborted`:c(t.signal,e)),revision:a};r=n;let o=e=>{r===n&&(r=void 0,e===`fresh`&&n.revision===a&&(i=l()))};return n.promise.then(o,()=>o(`failed`)),n.promise.then(()=>void 0)},d=()=>r?.revision===a?r.promise.then(()=>void 0):Date.now()<i?Promise.resolve():u(),f=()=>{};return N(s,()=>{let e;Je()||(e=setTimeout(()=>{d()},0));let r=Ne({fetchSession:u,shouldPollSession:()=>s.value.data!=null,sessionSignal:n,options:t});return r.init(),f=r.broadcastSessionUpdate,()=>{e&&clearTimeout(e),r.cleanup()}}),{session:s,$sessionSignal:n,broadcastSessionUpdate:e=>f(e)}}function K(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function q(e,t,n=`.`,r){if(!K(t))return q(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:K(a)&&K(i[t])?q(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function tt(e){return(...t)=>t.reduce((t,n)=>q(t,n,``,e),{})}var nt=tt(),rt=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},it=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let t=await i.init?.call(i,e.toString(),n);n=t.options||n,e=t.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},at=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},ot=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function st(e){if(typeof e==`number`)return new at({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new at(e);case`exponential`:return new ot(e);default:throw Error(`Invalid retry strategy`)}}var ct=[`get`,`post`,`put`,`patch`,`delete`];function J(e){if(!e.startsWith(`@`))return{method:void 0,path:e};let t=e.indexOf(`/`),n=e.slice(1,t===-1?void 0:t);return ct.includes(n)?{method:n,path:t===-1?e:e.slice(t+1)}:{method:void 0,path:e}}var lt=e=>e===`.`||e===`..`,ut=e=>e.split(`:`).map(e=>encodeURIComponent(e)).join(`:`);function dt(e,t){let n=t.get(e);if(n===void 0)return ut(e);if(lt(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function ft(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``,{path:o}=J(e);o!==e&&(e=`/${o}`),a.endsWith(`/`)||(a+=`/`);let[s,c]=e.replace(a,``).split(`?`),l=new URLSearchParams(c);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)l.append(e,n);continue}else n=JSON.stringify(t);l.set(e,n)}let u=new Map;if(r){if(Array.isArray(r)){let e=s.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];u.set(n,String(e))}}else for(let[e,t]of Object.entries(r))u.set(`:${e}`,String(t))}s=s.split(`/`).map(e=>dt(e,u)).join(`/`),s=s.replace(/^\/+/,``);let d=l.toString();return d=d.length>0?`?${d}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${s}${d}`,a):`${a}${s}${d}`}var pt=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},mt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function ht(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return mt.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function gt(e){try{return JSON.parse(e),!0}catch{return!1}}function _t(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function vt(e){try{return JSON.parse(e)}catch{return e}}function yt(e){return typeof e==`function`}function bt(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&yt(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&yt(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function xt(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function St(e){let t=new Headers(xt(e?.headers,await pt(e)));if(!t.has(`content-type`)){let n=Ct(e?.body);n&&t.set(`content-type`,n)}return t}function Ct(e){return _t(e)?`application/json`:null}function wt(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Tt(e,t){let{body:n}=e;return n?!_t(n)||typeof n==`string`?n:wt(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function Et(e,t){if(t?.method)return t.method.toUpperCase();let{method:n}=J(e);return n?n.toUpperCase():t?.body?`POST`:`GET`}function Dt(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Ot=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function Y(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Ot(n.issues);return n.value}function X(e){"@babel/helpers - typeof";return X=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},X(e)}function kt(e,t){if(X(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(X(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function At(e){var t=kt(e,`string`);return X(t)==`symbol`?t:t+``}function jt(e,t,n){return(t=At(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Mt(Object(n),!0).forEach(function(t){jt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Q=async(e,t)=>{var n;let{hooks:r,url:i,options:a}=await it(e,t),o=bt(a),s=new AbortController,c=a.signal??s.signal,l=ft(i,a),u=await St(a),d=Tt(a,u),f=Et(i,a),p=Z(Z({},a),{},{url:l,headers:u,body:d,method:f,signal:c});for(let e of r.onRequest)if(e){let t=await e(p);typeof t==`object`&&t&&Object.assign(p,t)}(`pipeTo`in p&&typeof p.pipeTo==`function`||typeof(t==null||(n=t.body)==null?void 0:n.pipe)==`function`)&&(`duplex`in p||(p.duplex=`half`));let{clearTimeout:m}=Dt(a,s),h=await o(p.url,p);m();let g={response:h,request:p};for(let e of r.onResponse)if(e){var _;let n=await e(Z(Z({},g),{},{response:t!=null&&(_=t.hookOptions)!=null&&_.cloneResponse?h.clone():h}));n instanceof Response?h=n:typeof n==`object`&&n&&(h=n.response)}if(h.ok){if(p.method===`HEAD`)return{data:``,error:null};let e=ht(h),n={data:null,response:h,request:p};if(e===`json`||e===`text`){let e=await h.text();n.data=await(p.jsonParser??vt)(e)}else n.data=await h[e]();p?.output&&p.output&&!p.disableValidation&&(n.data=await Y(p.output,n.data));for(let e of r.onSuccess)if(e){var v;await e(Z(Z({},n),{},{response:t!=null&&(v=t.hookOptions)!=null&&v.cloneResponse?h.clone():h}))}return t?.throw?n.data:{data:n.data,error:null}}let y=t?.jsonParser??vt,b=await h.text(),x=gt(b),S=x?await y(b):null,ee={response:h,responseText:b,request:p,error:Z(Z({},S),{},{status:h.status,statusText:h.statusText})};for(let e of r.onError)if(e){var C;await e(Z(Z({},ee),{},{response:t!=null&&(C=t.hookOptions)!=null&&C.cloneResponse?h.clone():h}))}if(t?.retry){let n=st(t.retry),i=t.retryAttempt??0;if(await n.shouldAttemptRetry(i,h)){for(let e of r.onRetry)e&&await e(g);let a=n.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await Q(e,Z(Z({},t),{},{retryAttempt:i+1}))}}if(t?.throw)throw new rt(h.status,h.statusText,x?S:b);return{data:null,error:Z(Z({},S),{},{status:h.status,statusText:h.statusText})}},Nt=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){var r;let i=Z(Z({},n),e.query!==void 0&&{query:Z(Z({},e.query),n?.query)}),a=((r=e.plugins)==null||(r=r.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1))==null?void 0:r.schema)||e.schema;if(a){let r=t;a.config?.prefix&&r.startsWith(a.config.prefix)&&(r=r.replace(a.config.prefix,``),a.config.baseURL&&(t=t.replace(a.config.prefix,a.config.baseURL))),a.config?.baseURL&&r.startsWith(a.config.baseURL)&&(r=r.replace(a.config.baseURL,``)),r.startsWith(`/`)&&r.charAt(1)===`@`&&(r=r.substring(1));let o=a.schema[r];if(o){let{method:a,path:s}=J(r);a&&(t=t.slice(0,t.length-r.length)+s);let c=n?.headers;if(o.headers&&!n?.disableValidation){let e={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((t,n)=>{e[n.toLowerCase()]=t});else if(typeof n.headers==`object`)for(let[t,r]of Object.entries(n.headers))r!=null&&(e[t.toLowerCase()]=r)}let t=await Y(o.headers,e),r={};for(let[e,n]of Object.entries(t))r[e.toLowerCase()]=n;c=r}let l=o.method??a;if(i=Z(Z(Z(Z({},i),l!==void 0&&{method:l}),o.output!==void 0&&{output:o.output}),c!==void 0&&{headers:c}),!n?.disableValidation){if(o.query&&(i.query=await Y(o.query,n?.query),i.query!==null&&typeof i.query==`object`)){let t=Z({},e.query);for(let e of Object.keys(t))n?.query&&Object.prototype.hasOwnProperty.call(n.query,e)&&(t[e]=n.query[e]);i.query=Z(Z({},t),i.query)}i=Z(Z({},i),{},{body:o.input?await Y(o.input,n?.body):n?.body,params:o.params?await Y(o.params,n?.params):n?.params})}return{url:t,options:i}}}return Z({url:t},(n!==void 0||e.query!==void 0)&&{options:i})}}),Pt=e=>{async function t(t,n){let r=Z(Z(Z({},e),n),{},{headers:xt(e?.headers,n?.headers),plugins:[...e?.plugins||[],Nt(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await Q(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await Q(t,r)}return t},Ft=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},It=e=>e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`,Lt=(e,t)=>{let n=`credentials`in Request.prototype,r=Ue(e?.baseURL,e?.basePath,void 0,t)??Ft(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=Pt({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?De(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[qe],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=et(d,e),h=!1,g=e=>{h||e===null||(h=!0,Xe(p,e))},_=e?.plugins||[],v={},y={$sessionSignal:f,session:p},b={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},x=[{signal:`$sessionSignal`,matcher:It,callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of _)e.getAtoms&&Object.assign(y,e.getAtoms?.(d)),e.pathMethods&&Object.assign(b,e.pathMethods),e.atomListeners&&x.push(...e.atomListeners);let S={notify:e=>{y[e].set(!y[e].get())},listen:(e,t)=>{y[e].subscribe(t)},atoms:y};for(let t of _)t.getActions&&(v=nt(t.getActions?.(d,S,e)??{},v));return{get baseURL(){return r},pluginsActions:v,pluginsAtoms:y,pluginPathMethods:b,atomListeners:x,hydrateSession:g,$sessionSignal:f,$fetch:d,$store:S}};function Rt(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function zt(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Bt=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,Vt=/['\u2019]/g;function Ht(e){return e.replace(Vt,``).match(Bt)??[]}function Ut(e){return Ht(e).map(e=>e.toLowerCase()).join(`-`)}function Wt(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function Gt(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||Rt(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(Ut).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=Wt(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function Kt(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=Lt(e),c={};for(let[e,t]of Object.entries(r))c[`use${zt(e)}`]=t;return Gt({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}var qt=(e,{$listPasskeys:t,$store:n})=>({signIn:{passkey:async(r,i)=>{let a=await e(`/passkey/generate-authenticate-options`,{method:`GET`,throw:!1});if(!a.data)return a;let o=a.data.extensions||r?.extensions?{...a.data.extensions||{},...r?.extensions||{}}:void 0,s;try{s=await re({optionsJSON:{...a.data,extensions:o},useBrowserAutofill:r?.autoFill})}catch(e){return{data:null,error:{code:e instanceof v?e.code:`AUTH_CANCELLED`,message:u.AUTH_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}}try{let{clientExtensionResults:a,...o}=s,c=await e(`/passkey/verify-authentication`,{body:{response:o},...r?.fetchOptions,...i,method:`POST`,throw:!1});return t.set(Math.random()),n.notify(`$sessionSignal`),r?.returnWebAuthnResponse?{...c,webauthn:{response:s,clientExtensionResults:a}}:c}catch(e){return console.error(`[Better Auth] Error verifying passkey`,e),{data:null,error:{code:`AUTH_CANCELLED`,message:u.AUTH_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}}}},passkey:{addPasskey:async(r,i)=>{let a=await e(`/passkey/generate-register-options`,{method:`GET`,query:{...r?.authenticatorAttachment&&{authenticatorAttachment:r.authenticatorAttachment},...r?.name&&{name:r.name},...r?.context&&{context:r.context}},throw:!1});if(!a.data)return a;try{let o=a.data.extensions||r?.extensions?{...a.data.extensions||{},...r?.extensions||{}}:void 0,s=await ee({optionsJSON:{...a.data,extensions:o},useAutoRegister:r?.useAutoRegister}),{clientExtensionResults:c,...l}=s,u=await e(`/passkey/verify-registration`,{...r?.fetchOptions,...i,body:{response:l,name:r?.name,...r?.createSession&&{createSession:!0}},method:`POST`,throw:!1});return u.data?(t.set(Math.random()),u.data.session&&n.notify(`$sessionSignal`),r?.returnWebAuthnResponse?{...u,webauthn:{response:s,clientExtensionResults:c}}:u):u}catch(e){return e instanceof v?e.code===`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`?{data:null,error:{code:e.code,message:u.PREVIOUSLY_REGISTERED.message,status:400,statusText:`BAD_REQUEST`}}:e.code===`ERROR_CEREMONY_ABORTED`?{data:null,error:{code:e.code,message:u.REGISTRATION_CANCELLED.message,status:400,statusText:`BAD_REQUEST`}}:{data:null,error:{code:e.code,message:e.message,status:400,statusText:`BAD_REQUEST`}}:{data:null,error:{code:`UNKNOWN_ERROR`,message:e instanceof Error?e.message:u.UNKNOWN_ERROR.message,status:500,statusText:`INTERNAL_SERVER_ERROR`}}}}},$Infer:{}}),Jt=()=>{let e=A();return{id:`passkey`,version:d,$InferServerPlugin:{},getActions:(t,n)=>qt(t,{$listPasskeys:e,$store:n}),getAtoms(t){return{listPasskeys:R(e,`/passkey/list-user-passkeys`,t,{method:`GET`}),$listPasskeys:e}},pathMethods:{"/passkey/register":`POST`,"/passkey/authenticate":`POST`},atomListeners:[{matcher(e){return e===`/passkey/verify-registration`||e===`/passkey/delete-passkey`||e===`/passkey/update-passkey`||e===`/sign-out`},signal:`$listPasskeys`},{matcher:e=>e===`/passkey/verify-authentication`,signal:`$sessionSignal`}],$ERROR_CODES:u}},Yt=`1.7.10`,Xt=e=>({id:`sso-client`,version:Yt,$InferServerPlugin:{},pathMethods:{"/sso/providers":`GET`,"/sso/get-provider":`GET`}});function Zt(e){return{success:!1,error:`You are not allowed to access resource: ${e}`}}function Qt(e){return{success:!1,error:`unauthorized to access resource "${e}"`}}function $t(e){return e===`OR`?`OR`:`AND`}function en(e){return Array.isArray(e)}function tn(e){if(en(e))return{actions:e,connector:`AND`};if(!e||typeof e!=`object`)throw new W(`Invalid access control request`);let{actions:t,connector:n}=e;return en(t)?{actions:t,connector:$t(n)}:{actions:[],connector:$t(n)}}function nn(e,t){return typeof t==`string`&&e.includes(t)}function rn(e,{actions:t,connector:n}){return t.length===0?!1:n===`OR`?t.some(t=>nn(e,t)):t.every(t=>nn(e,t))}function an(e){return{authorize(t,n=`AND`){let r=!1;for(let[i,a]of Object.entries(t)){let t=e[i];if(!t){if(n===`AND`)return Zt(i);continue}let o=rn(t,tn(a));if(o&&(r=!0),o&&n===`OR`)return{success:!0};if(!o&&n===`AND`)return Qt(i)}return r?{success:!0}:{success:!1,error:`Not authorized`}},statements:e}}function on(e){return{newRole(e){return an(e)},statements:e}}var sn=l({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:`You are not allowed to create a new organization`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:`You have reached the maximum number of organizations`,ORGANIZATION_ALREADY_EXISTS:`Organization already exists`,ORGANIZATION_SLUG_ALREADY_TAKEN:`Organization slug already taken`,ORGANIZATION_NOT_FOUND:`Organization not found`,USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:`User is not a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:`You are not allowed to update this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:`You are not allowed to delete this organization`,NO_ACTIVE_ORGANIZATION:`No active organization`,USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:`User is already a member of this organization`,MEMBER_NOT_FOUND:`Member not found`,ROLE_NOT_FOUND:`Role not found`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:`You are not allowed to create a new team`,TEAM_ALREADY_EXISTS:`Team already exists`,TEAM_NOT_FOUND:`Team not found`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:`You cannot leave the organization as the only owner`,YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:`You cannot leave the organization without an owner`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:`You are not allowed to delete this member`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:`You are not allowed to invite users to this organization`,USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:`User is already invited to this organization`,INVITATION_NOT_FOUND:`Invitation not found`,YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:`You are not the recipient of the invitation`,EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:`Email verification required before accepting or rejecting invitation`,EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION:`Email verification required to view or list invitations for the session email`,YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:`You are not allowed to cancel this invitation`,INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:`Inviter is no longer a member of the organization`,YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:`You are not allowed to invite a user with this role`,FAILED_TO_RETRIEVE_INVITATION:`Failed to retrieve invitation`,YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:`You have reached the maximum number of teams`,UNABLE_TO_REMOVE_LAST_TEAM:`Unable to remove last team`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:`You are not allowed to update this member`,ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:`Organization membership limit reached`,YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to create teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:`You are not allowed to delete teams in this organization`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:`You are not allowed to update this team`,YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:`You are not allowed to delete this team`,INVITATION_LIMIT_REACHED:`Invitation limit reached`,TEAM_MEMBER_LIMIT_REACHED:`Team member limit reached`,USER_IS_NOT_A_MEMBER_OF_THE_TEAM:`User is not a member of the team`,YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:`You are not allowed to list the members of this team`,YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:`You do not have an active team`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:`You are not allowed to create a new member`,YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:`You are not allowed to remove a team member`,YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:`You are not allowed to access this organization as an owner`,YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:`You are not a member of this organization`,MISSING_AC_INSTANCE:`Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information`,YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:`You must be in an organization to create a role`,YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:`You are not allowed to create a role`,YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:`You are not allowed to update a role`,YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:`You are not allowed to delete a role`,YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:`You are not allowed to read a role`,YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:`You are not allowed to list a role`,YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:`You are not allowed to get a role`,TOO_MANY_ROLES:`This organization has too many roles`,INVALID_RESOURCE:`The provided permission includes an invalid resource`,ROLE_NAME_IS_ALREADY_TAKEN:`That role name is already taken`,CANNOT_DELETE_A_PRE_DEFINED_ROLE:`Cannot delete a pre-defined role`,ROLE_IS_ASSIGNED_TO_MEMBERS:`Cannot delete a role that is assigned to members. Please reassign the members to a different role first`,INVALID_TEAM_ID:`Team id contains a reserved character`}),$=on({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),cn=$.newRole({organization:[`update`],invitation:[`create`,`cancel`],member:[`create`,`update`,`delete`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),ln=$.newRole({organization:[`update`,`delete`],member:[`create`,`update`,`delete`],invitation:[`create`,`cancel`],team:[`create`,`update`,`delete`],ac:[`create`,`read`,`update`,`delete`]}),un=$.newRole({organization:[],member:[],invitation:[],team:[],ac:[`read`]}),dn={admin:cn,owner:ln,member:un},fn=(e,t)=>{if(!e.permissions)return!1;let n=e.role.split(`,`),r=e.options.creatorRole||`owner`,i=n.includes(r),a=e.allowCreatorAllPermissions||!1;if(i&&a)return!0;for(let r of n)if(t[r]?.authorize(e.permissions)?.success)return!0;return!1},pn=e=>fn(e,e.options.roles||dn),mn=e=>{let t=A(!1),n=A(!1),r=A(!1),i=A(!1),a={admin:cn,member:un,owner:ln,...e?.roles};return{id:`organization`,version:ie,$InferServerPlugin:{},getActions:(t,n,r)=>({$Infer:{ActiveOrganization:{},Organization:{},Invitation:{},Member:{},Team:{}},organization:{checkRolePermission:t=>pn({role:t.role,options:{ac:e?.ac,roles:a},permissions:t.permissions})}}),getAtoms:e=>{let a=R(t,`/organization/list`,e,{method:`GET`});return{$listOrg:t,$activeOrgSignal:n,$activeMemberSignal:r,$activeMemberRoleSignal:i,activeOrganization:R([n],`/organization/get-full-organization`,e,()=>({method:`GET`})),listOrganizations:a,activeMember:R([n,r],`/organization/get-active-member`,e,{method:`GET`}),activeMemberRole:R([n,i],`/organization/get-active-member-role`,e,{method:`GET`})}},pathMethods:{"/organization/get-full-organization":`GET`,"/organization/list-user-teams":`GET`},atomListeners:[{matcher(e){return e===`/organization/create`||e===`/organization/delete`||e===`/organization/update`},signal:`$listOrg`},{matcher(e){return It(e)||e.startsWith(`/organization`)},signal:`$activeOrgSignal`},{matcher(e){return e.startsWith(`/organization/set-active`)||e===`/organization/create`||e===`/organization/delete`||e===`/organization/remove-member`||e===`/organization/leave`||e===`/organization/accept-invitation`},signal:`$sessionSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberSignal`},{matcher(e){return e.includes(`/organization/update-member-role`)||e.startsWith(`/organization/set-active`)},signal:`$activeMemberRoleSignal`}],$ERROR_CODES:sn}},hn=l({OTP_NOT_ENABLED:`OTP not enabled`,OTP_NOT_CONFIGURED:`OTP is not available`,OTP_HAS_EXPIRED:`OTP has expired`,TOTP_NOT_ENABLED:`TOTP not enabled`,TOTP_ALREADY_ENABLED:`TOTP is already enabled`,TOTP_NOT_CONFIGURED:`TOTP is not available`,TWO_FACTOR_NOT_ENABLED:`Two factor isn't enabled`,BACKUP_CODES_NOT_ENABLED:`Backup codes aren't enabled`,INVALID_BACKUP_CODE:`Invalid backup code`,INVALID_CODE:`Invalid code`,TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:`Too many attempts. Please request a new code.`,ACCOUNT_TEMPORARILY_LOCKED:`Too many failed verification attempts. Your account is temporarily locked. Please try again later.`,INVALID_TWO_FACTOR_COOKIE:`Invalid two factor cookie`}),gn=e=>({id:`two-factor`,version:ie,$InferServerPlugin:{},atomListeners:[{matcher:e=>e.startsWith(`/two-factor/`),signal:`$sessionSignal`}],pathMethods:{"/two-factor/disable":`POST`,"/two-factor/enable":`POST`,"/two-factor/send-otp":`POST`,"/two-factor/generate-backup-codes":`POST`,"/two-factor/get-totp-uri":`POST`,"/two-factor/verify-totp":`POST`,"/two-factor/verify-otp":`POST`,"/two-factor/verify-backup-code":`POST`},fetchPlugins:[{id:`two-factor`,name:`two-factor`,hooks:{async onSuccess(t){if(t.data?.twoFactorRedirect){if(e?.onTwoFactorRedirect){await e.onTwoFactorRedirect({twoFactorMethods:t.data.twoFactorMethods});return}e?.twoFactorPage&&typeof window<`u`&&Ke(e.twoFactorPage)&&(window.location.href=e.twoFactorPage)}}}}],$ERROR_CODES:hn}),_n=e({authBase:()=>xn,authClient:()=>bn}),vn=on(r),yn=Object.fromEntries(i.map(e=>[e,vn.newRole(c[e])])),bn=Kt({baseURL:new URL(`api/auth`,window.location.origin+window.location.pathname).toString(),fetchOptions:{credentials:`same-origin`,headers:{"X-WizeLens-Client":`dashboard`}},plugins:[mn({ac:vn,roles:yn}),gn({onTwoFactorRedirect:()=>n(t(`two-factor`))}),Jt(),Xt({domainVerification:{enabled:!0}})]}),xn=()=>new URL(`api/auth`,window.location.origin+window.location.pathname).toString();export{_n as n,xn as t};