@tinyrack/issuary-server 0.30.0 → 0.31.0
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/entrypoints/app.d.ts +3 -0
- package/dist/entrypoints/app.d.ts.map +1 -1
- package/dist/lib/config/client.js +1 -1
- package/dist/lib/config/client.js.map +1 -1
- package/dist/repositories/user-consent.repository.d.ts.map +1 -1
- package/dist/repositories/user-consent.repository.js +8 -2
- package/dist/repositories/user-consent.repository.js.map +1 -1
- package/dist/routes/api/auth/accounts/remove.post.d.ts +5 -5
- package/dist/routes/api/consent/get.d.ts +3 -0
- package/dist/routes/api/consent/get.d.ts.map +1 -1
- package/dist/routes/api/consent/get.js +26 -4
- package/dist/routes/api/consent/get.js.map +1 -1
- package/dist/routes/api/consent/index.d.ts +3 -0
- package/dist/routes/api/consent/index.d.ts.map +1 -1
- package/dist/routes/api/consent/post.d.ts.map +1 -1
- package/dist/routes/api/consent/post.js +8 -1
- package/dist/routes/api/consent/post.js.map +1 -1
- package/dist/routes/api/index.d.ts +3 -0
- package/dist/routes/api/index.d.ts.map +1 -1
- package/dist/routes/index.d.ts +23 -20
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/oauth/index.d.ts +9 -9
- package/dist/services/container.d.ts.map +1 -1
- package/dist/services/container.js +1 -1
- package/dist/services/container.js.map +1 -1
- package/dist/services/oauth-authorize.service.d.ts +3 -1
- package/dist/services/oauth-authorize.service.d.ts.map +1 -1
- package/dist/services/oauth-authorize.service.js +33 -4
- package/dist/services/oauth-authorize.service.js.map +1 -1
- package/dist/services/terms.service.d.ts.map +1 -1
- package/dist/services/terms.service.js +3 -2
- package/dist/services/terms.service.js.map +1 -1
- package/dist/services/user-consent.service.d.ts +12 -0
- package/dist/services/user-consent.service.d.ts.map +1 -1
- package/dist/services/user-consent.service.js +19 -1
- package/dist/services/user-consent.service.js.map +1 -1
- package/frontend/client/assets/{auth-layout-B4h13HhN.js → auth-layout-BedWIZ7L.js} +1 -1
- package/frontend/client/assets/{auth-page-header-BVY4zRzF.js → auth-page-header-C6Z6Air-.js} +1 -1
- package/frontend/client/assets/i18n-Dzv9HKFm.js +1 -0
- package/frontend/client/assets/language-selector-CeLHnp1n.js +1 -0
- package/frontend/client/assets/manifest-71025d92.js +1 -0
- package/frontend/client/assets/oauth-search-DebNssaC.js +1 -0
- package/frontend/client/assets/{passkey-CWcdr7Vy.js → passkey-Bkqvhjwb.js} +1 -1
- package/frontend/client/assets/{promise-EbDcmV0j.js → promise-CepnkPDw.js} +1 -1
- package/frontend/client/assets/{root-C2SlHCkE.js → root-CM8lJbh5.js} +1 -1
- package/frontend/client/assets/route-1rid8j-3.js +1 -0
- package/frontend/client/assets/route-B4jDMFTW.js +1 -0
- package/frontend/client/assets/{route-DO38I3ML.js → route-BcXtt6V2.js} +1 -1
- package/frontend/client/assets/{route-bKG0wKRh.js → route-BwhQptmx.js} +1 -1
- package/frontend/client/assets/{route-DEVG2czp.js → route-C-DecXPL.js} +1 -1
- package/frontend/client/assets/{route-DSD60oyb.js → route-CF1S7UUy.js} +1 -1
- package/frontend/client/assets/{route-J9z_OG4L.js → route-CGTMMDiX.js} +1 -1
- package/frontend/client/assets/{route-DH6kQz8L.js → route-CKiun7AR.js} +1 -1
- package/frontend/client/assets/{route-sHm4cfOd.js → route-CMJbXiDe.js} +1 -1
- package/frontend/client/assets/route-CdPHVY9W.js +1 -0
- package/frontend/client/assets/{route-9FLiqn21.js → route-Clxc1C2d.js} +1 -1
- package/frontend/client/assets/route-DBpAiakW.js +1 -0
- package/frontend/client/assets/{route-N586tYcn.js → route-DS92RKs5.js} +1 -1
- package/frontend/client/assets/{route-CkpB3-_U.js → route-DZvCkU11.js} +1 -1
- package/frontend/client/assets/route-Dc6G2aDX.js +1 -0
- package/frontend/client/assets/{route-CrswLAAa.js → route-DkoXJmYM.js} +1 -1
- package/frontend/client/assets/{route-DQpLeFuG.js → route-DphbGk_G.js} +1 -1
- package/frontend/client/assets/{route-E-_SSP-x.js → route-DqAmRSJE.js} +1 -1
- package/frontend/client/assets/{route-BUM2hTU8.js → route-DrtpzI6u.js} +1 -1
- package/frontend/client/assets/{route-DjCJn53Y.js → route-Ezzcj26w.js} +1 -1
- package/frontend/client/assets/{route-3IIrVTOK.js → route-HA9dma-h.js} +1 -1
- package/frontend/client/assets/{route-3gQ9Nsqa.js → route-Y1_yJKhW.js} +1 -1
- package/frontend/client/assets/{shell-header-bar-Bg85QIAq.js → shell-header-bar-CjPlfRKT.js} +1 -1
- package/frontend/client/assets/{terms-DV0oDTRf.js → terms-BGJD_l_i.js} +1 -1
- package/frontend/client/assets/{use-totp-setup-D7XZ6Nos.js → use-totp-setup-Cwuds2tR.js} +1 -1
- package/frontend/server/assets/{hydration-Cvbp7-6s.js → hydration-B63_G0fd.js} +1 -1
- package/frontend/server/assets/{root-loader.server-DaTcVcNU.js → root-loader.server-DUIBlg_3.js} +3 -3
- package/frontend/server/assets/{route-runtime.server-CEa264cW.js → route-runtime.server-DiqwWb8W.js} +1 -1
- package/frontend/server/assets/{session-QqvIIQ6R.js → session-BaAt7WMI.js} +15 -33
- package/frontend/server/index.js +244 -356
- package/package.json +1 -1
- package/frontend/client/assets/authorization-context-banner-az4f8FCY.js +0 -1
- package/frontend/client/assets/i18n-CMepi_uj.js +0 -1
- package/frontend/client/assets/language-selector-Chn-k7Pw.js +0 -1
- package/frontend/client/assets/manifest-8c4a603f.js +0 -1
- package/frontend/client/assets/oauth-search-DybZ6VWp.js +0 -1
- package/frontend/client/assets/route-BFU8OK2a.js +0 -1
- package/frontend/client/assets/route-BKI6LDOW.js +0 -1
- package/frontend/client/assets/route-CusK9Y2K.js +0 -1
- package/frontend/client/assets/route-LjqDZz5f.js +0 -1
- package/frontend/client/assets/route-nHjY3_n0.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{$ as e,J as t,a as n}from"./components-DF4L3dSB.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{L as i,a}from"./api-CfCwvXbU.js";import{r as o,t as s}from"./text-CBHShrvS.js";import{t as c}from"./useMutation-BkuKGzks.js";import{Bn as l,Dn as u,Mn as d,On as f,Pn as p,Q as m,St as h,Tt as g,Wt as _,Y as v,Z as y,bt as b,jn as x,u as S,wt as C,xt as w,yn as T}from"./usePositioner-CrQOY-iw.js";import{A as E,C as D,F as O,I as k,L as A,M as j,N as M,a as N,c as P,i as F,j as I,k as ee,t as L}from"./select-C_WHBpl_.js";import{r as R}from"./NullStore-UyCsFQfz.js";import{a as z,c as B,d as V,f as te,i as ne,l as re,n as ie,o as ae,p as oe,r as H,s as se,t as ce,u as U}from"./use-admin-selection-i-WvRvvB.js";import{t as le}from"./triangle-alert-B0lTzZDi.js";import{n as W,t as G}from"./modal-BDu41alh.js";import{t as K}from"./code-Dc5QnXCh.js";import{r as ue}from"./FieldItemContext-B3N2qWH8.js";import{t as de}from"./field-Du5xBKGW.js";import{t as fe}from"./input-Dyj4-3JM.js";import{t as pe}from"./badge-Cr0iG_iG.js";import{t as me}from"./checkbox-BymOAmaw.js";import{t as he}from"./Separator-Bu_799IG.js";import{n as ge}from"./route-module-2foR49uh.js";import{t as q}from"./CompositeItem-JwkStZhq.js";import{a as _e,d as ve,l as ye,p as be,s as xe,t as Se,u as Ce}from"./admin-console-Ej5TUkij.js";import{t as J}from"./table-BpQCtRY7.js";import{t as we}from"./admin-users-notice-D3rf-k5S.js";var Y=e(t(),1),X=r(),Te=Y.forwardRef(function(e,t){let n=N().orientation===`vertical`?`horizontal`:`vertical`;return(0,X.jsx)(he,{orientation:n,...e,ref:t})}),Ee=[];function De(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:d,disabledIndices:f,modifierKeys:m=Ee}=e,[v,y]=Y.useState(0),x=r!=null,S=Y.useRef(null),O=p(S,c),N=Y.useRef([]),P=Y.useRef(!1),F=o??v,L=T((e,t=!1)=>{if((s??y)(e),t){let t=N.current[e];A(S.current,t,a,n)}}),R=T(e=>{if(e.size===0||P.current)return;P.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)L(i);else if(g(t,F,f)){let e=b(t,{disabledIndices:f});C(t,e)||L(e)}A(S.current,r,a,n)});u(()=>{if(f==null||o!=null||!P.current)return;let e=N.current;if(g(e,F,f)){let t=b(e,{disabledIndices:f});C(e,t)||L(t)}},[f,o,F,N,L]);let z=T((e,t,n)=>i?i(e,t,n,N):n),B=T(e=>{let o=e.key===`Home`||e.key===`End`;if(!M.has(e.key)||!l&&o||Oe(e,m)||!S.current)return;let s=a===`rtl`,c=s?E:I,u=s?I:E,p=n===`vertical`?ee:c,g=n===`vertical`?j:u,v=_(e.nativeEvent);if(v!=null&&k(v)&&!D(v)){let t=v.selectionStart,n=v.selectionEnd,r=v.value;if(t==null||e.shiftKey||t!==n||e.key!==g&&t<r.length||e.key!==p&&t>0)return}let y=F,T=h(N,f),O=w(N,f);r!=null&&(y=r({disabledIndices:f,elementsRef:N,event:e,highlightedIndex:F,loopFocus:t,maxIndex:O,minIndex:T,onLoop:z,orientation:n,rtl:s}));let A=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,P=n!==`vertical`&&e.key===u||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?y=T:e.key===`End`&&(y=O)),y===F&&(A||P)&&(t&&y===O&&A?(y=T,i&&(y=i(e,F,y,N))):t&&y===T&&P?(y=O,i&&(y=i(e,F,y,N))):y=b(N.current,{startingIndex:y,decrement:P,disabledIndices:f})),y!==F&&!C(N.current,y)&&(d&&e.stopPropagation(),(x||o||A||P)&&e.preventDefault(),L(y,!0),queueMicrotask(()=>{N.current[y]?.focus()}))});return{props:{ref:O,onFocus(e){let t=S.current,n=_(e.nativeEvent);t&&n!=null&&k(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:B},highlightedIndex:F,onHighlightedIndexChange:L,elementsRef:N,onMapChange:R,relayKeyboardEvent:B}}function Oe(e,t){for(let n of O)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ke(e){let{render:t,className:n,style:r,refs:i=x,props:a=x,state:o=d,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:p,loopFocus:h,onLoop:g,enableHomeAndEndKeys:_,onMapChange:v,stopEventPropagation:y=!0,rootRef:b,disabledIndices:C,modifierKeys:w,highlightItemOnHover:T=!1,tag:E=`div`,...D}=e,{props:O,highlightedIndex:k,onHighlightedIndexChange:A,elementsRef:j,onMapChange:M,relayKeyboardEvent:N}=De({grid:p,loopFocus:h,onLoop:g,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:b,stopEventPropagation:y,enableHomeAndEndKeys:_,direction:S(),disabledIndices:C,modifierKeys:w}),F=f(E,e,{state:o,ref:i,props:[O,...a,D],stateAttributesMapping:s}),I=Y.useMemo(()=>({highlightedIndex:k,onHighlightedIndexChange:A,highlightItemOnHover:T,relayKeyboardEvent:N}),[k,A,T,N]);return(0,X.jsx)(m.Provider,{value:I,children:(0,X.jsx)(P,{elementsRef:j,onMapChange:e=>{v?.(e),M(e)},children:F})})}var Ae=Y.forwardRef(function(e,t){let{disabled:n=!1,loopFocus:r,orientation:i=`horizontal`,className:a,render:o,style:s,...c}=e,[l,u]=Y.useState(()=>new Map),d=Y.useMemo(()=>{let e=[];for(let t of l.values())t.disabled&&!t.focusableWhenDisabled&&e.push(t.index);return e},[l]),f=Y.useMemo(()=>({disabled:n,orientation:i}),[n,i]),p={disabled:n,orientation:i},m={"aria-orientation":i,role:`toolbar`};return(0,X.jsx)(F.Provider,{value:f,children:(0,X.jsx)(ke,{render:o,className:a,style:s,state:p,refs:[t],props:[m,c],disabledIndices:d,loopFocus:r,onMapChange:u,orientation:i})})}),je=Y.createContext(void 0);function Me(){return Y.useContext(je)}var Ne=Y.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,style:a,...o}=e,{orientation:s,disabled:c}=N(),l=c||r,u=Y.useMemo(()=>({disabled:l}),[l]),d=f(`div`,e,{state:{disabled:l,orientation:s},ref:t,props:[{role:`group`},o]});return(0,X.jsx)(je.Provider,{value:u,children:d})}),Pe=Y.forwardRef(function(e,t){let{className:n,disabled:r=!1,focusableWhenDisabled:i=!0,render:a,nativeButton:o,style:s,...c}=e,{disabled:l,orientation:u}=N(),f=Me(),p=l||(f?.disabled??!1)||r,m=Y.useMemo(()=>({disabled:p,focusableWhenDisabled:i}),[p,i]),{getButtonProps:h,buttonRef:g}=v({disabled:p,focusableWhenDisabled:i,native:o});return(0,X.jsx)(q,{tag:`button`,render:a,className:n,style:s,metadata:m,state:{disabled:p,orientation:u,focusable:i},refs:[t,g],props:[c,a?{disabled:p}:d,h]})}),Fe={disabled:!1,focusableWhenDisabled:!0},Ie=Y.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,{orientation:o}=N();return(0,X.jsx)(q,{tag:`a`,render:r,className:n,style:i,metadata:Fe,state:{orientation:o},refs:[t],props:[a]})}),Le=Y.forwardRef(function(e,t){let{className:n,focusableWhenDisabled:r=!0,render:i,disabled:a=!1,style:o,...s}=e,{disabled:c,orientation:l}=N(),u=Me(),d=c||(u?.disabled??!1)||a,f=Y.useMemo(()=>({disabled:d,focusableWhenDisabled:r}),[d,r]),{props:p}=y({composite:!0,disabled:d,focusableWhenDisabled:r,isNativeButton:!1}),m={disabled:d,orientation:l,focusable:r},h=e=>{d&&e.preventDefault()};return(0,X.jsx)(q,{tag:`input`,render:i,className:n,style:o,metadata:f,state:m,refs:[t],props:[{onClick:h,onPointerDown:h},s,p]})}),Re=l(Pe,`tr-toolbar-button`),ze=l(Ne,`tr-toolbar-group`),Be=l(Le,`tr-toolbar-input`,{tracksFocusModality:!0}),Ve=l(Ie,`tr-toolbar-link`),He={Root:l(Ae,`tr-toolbar`),Group:ze,Button:Re,Link:Ve,Input:Be,Separator:l(Te,`tr-toolbar-separator`)};function Ue(){let{t:e}=a(),t=i(),[n,r]=(0,Y.useState)(``),[l,u]=(0,Y.useState)({page:1,pageSize:20}),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),{data:x}=o(Se(l)),S=ce(x.clients.filter(e=>e.managed_by===`database`&&!e.deleted_at).map(e=>e.id)),C=()=>t.invalidateQueries({queryKey:[`admin`]}),w=c({mutationFn:xe,onSuccess:e=>{C(),f(null),b(e.client_secret??null)}}),T=c({mutationFn:({id:e,input:t})=>be(e,t),onSuccess:()=>{C(),f(null)}}),E=c({mutationFn:ve,onSuccess:e=>{C(),b(e.client_secret)}}),D=c({mutationFn:_e,onSuccess:()=>{C(),S.clear(),m(null)}}),O=c({mutationFn:ye,onSuccess:({client:t})=>{C(),S.clear(),g(null),v({tone:`success`,message:e(`admin.clients.deletedNotice`,{name:t.name})})},onError:()=>v({tone:`error`,message:e(`admin.clients.operationFailed`)})}),k=c({mutationFn:Ce,onSuccess:({client:t})=>{C(),v({tone:`success`,message:e(`admin.clients.restoredNotice`,{name:t.name})})},onError:()=>v({tone:`error`,message:e(`admin.clients.operationFailed`)})}),A=l.page??1,j=l.pageSize??20,M=S.selection.kind===`filter`?x.pagination.total:S.selectedCount??0,N=S.selection.kind===`filter`?{kind:`filter`,filter:{query:l.query,managed_by:l.managedBy,enabled:l.lifecycleStatus===`active`||l.lifecycleStatus!==`inactive`&&void 0}}:{kind:`ids`,ids:[...S.selection.ids]},P=e=>{S.clear(),u(e)};return(0,X.jsxs)(X.Fragment,{children:[_?(0,X.jsx)(we,{notice:_,onDismiss:()=>v(null)}):null,(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(ne,{onCreate:()=>f(`create`),onQueryChange:r,onSearch:()=>P({...l,query:n.trim(),page:1}),query:n,title:e(`admin.clients.title`),total:x.pagination.total,children:[(0,X.jsx)(H,{label:e(`admin.clients.type`),onChange:e=>P({...l,type:e===`public`?`public`:e===`confidential`?`confidential`:void 0,page:1}),options:[[`all`,e(`admin.filter.allTypes`)],[`public`,e(`admin.clients.public`)],[`confidential`,e(`admin.clients.confidential`)]],value:l.type??`all`}),(0,X.jsx)(H,{label:e(`admin.table.status`),onChange:e=>P({...l,lifecycleStatus:e===`active`||e===`inactive`||e===`deleted`?e:void 0,page:1}),options:[[`all`,e(`admin.filter.allStatuses`)],[`active`,e(`admin.status.active`)],[`inactive`,e(`admin.status.inactive`)],[`deleted`,e(`admin.status.deleted`)]],value:l.lifecycleStatus??`all`})]}),(0,X.jsxs)(oe,{children:[(0,X.jsxs)(te,{label:e(`admin.clients.title`),children:[(0,X.jsx)(J.Header,{className:`sticky top-0 z-tinyrack-component-raised`,children:(0,X.jsxs)(J.Row,{children:[(0,X.jsx)(V,{header:!0,children:(0,X.jsx)(se,{checked:S.allOnPage,indeterminate:S.someOnPage,onChange:S.togglePage})}),(0,X.jsx)(U,{header:!0,children:(0,X.jsx)(B,{direction:l.direction??`asc`,label:e(`admin.clients.name`),onClick:()=>P({...l,direction:l.direction===`desc`?`asc`:`desc`,page:1})})}),(0,X.jsx)(J.Head,{children:e(`admin.clients.clientId`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.type`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.source`)}),(0,X.jsx)(J.Head,{children:e(`admin.table.status`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.redirects`)}),(0,X.jsx)(J.Head,{children:e(`admin.clients.scopes`)}),(0,X.jsx)(re,{header:!0,children:e(`admin.table.actions`)})]})}),(0,X.jsx)(J.Body,{children:x.clients.length===0?(0,X.jsx)(J.Row,{children:(0,X.jsx)(J.Cell,{className:`py-tinyrack-3xl text-center`,colSpan:9,children:e(`admin.table.empty`)})}):x.clients.map(t=>(0,X.jsxs)(J.Row,{className:S.isSelected(t.id)?`bg-tinyrack-surface-selected`:void 0,"data-selected":S.isSelected(t.id)?``:void 0,children:[(0,X.jsx)(V,{selected:S.isSelected(t.id),children:t.managed_by===`database`&&!t.deleted_at?(0,X.jsx)(ae,{checked:S.isSelected(t.id),label:e(`admin.selection.row`,{name:t.name}),onChange:e=>S.toggleOne(t.id,e)}):null}),(0,X.jsx)(U,{selected:S.isSelected(t.id),children:(0,X.jsx)(s,{as:`p`,truncate:!0,variant:`bodySm`,weight:`medium`,children:t.name})}),(0,X.jsx)(J.Cell,{children:(0,X.jsx)(K,{children:t.client_id})}),(0,X.jsx)(J.Cell,{children:e(`admin.clients.${t.type}`)}),(0,X.jsx)(J.Cell,{children:e(`admin.source.${t.managed_by}`)}),(0,X.jsx)(J.Cell,{children:(0,X.jsx)(pe,{className:`whitespace-nowrap`,variant:t.deleted_at?`danger`:t.enabled?`success`:`neutral`,children:e(t.deleted_at?`admin.status.deleted`:t.enabled?`admin.status.active`:`admin.status.inactive`)})}),(0,X.jsx)(J.Cell,{children:t.redirect_uris.length}),(0,X.jsx)(J.Cell,{children:t.scopes.join(`, `)}),(0,X.jsx)(re,{selected:S.isSelected(t.id),children:t.deleted_at?t.managed_by===`database`?(0,X.jsx)(R,{disabled:k.isPending,onClick:()=>k.mutate(t.id),type:`button`,uiSize:`sm`,children:e(`admin.actions.restore`)}):(0,X.jsx)(s,{color:`muted`,variant:`caption`,children:e(`admin.clients.restoreViaConfig`)}):(0,X.jsxs)(He.Root,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>f(t),type:`button`,uiSize:`sm`,children:e(`admin.actions.edit`)}),t.type===`confidential`?(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>E.mutate(t.id),type:`button`,uiSize:`sm`,children:e(`admin.clients.rotateSecret`)}):null,(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,onClick:()=>D.mutate({target:{kind:`ids`,ids:[t.id]},active:!t.enabled}),type:`button`,uiSize:`sm`,children:e(t.enabled?`admin.actions.deactivate`:`admin.actions.activate`)}),(0,X.jsx)(R,{appearance:`ghost`,disabled:t.managed_by===`config`,intent:`danger`,onClick:()=>g(t),type:`button`,uiSize:`sm`,children:e(`admin.actions.delete`)})]})})]},t.id))})]}),(0,X.jsx)(z,{onPageChange:e=>P({...l,page:e}),onPageSizeChange:e=>P({...l,page:1,pageSize:e}),page:A,pageSize:j,total:x.pagination.total})]})]}),M>0?(0,X.jsx)(ie,{canExpand:S.allOnPage&&x.pagination.total>x.clients.length,filterSelected:S.selection.kind===`filter`,onActivate:()=>m(!0),onClear:S.clear,onDeactivate:()=>m(!1),onExpand:S.selectFilter,pending:D.isPending,selected:M,total:x.pagination.total}):null,(0,X.jsx)(Ke,{active:p,count:M,filterSelected:S.selection.kind===`filter`,onClose:()=>m(null),onRun:()=>D.mutate({target:N,active:p??!0})}),(0,X.jsx)(We,{client:d===`create`?void 0:d??void 0,isOpen:d!==null,onClose:()=>f(null),onSubmit:e=>{if(d&&d!==`create`){let{client_id:t,type:n,...r}=e;T.mutate({id:d.id,input:r})}else w.mutate(e)},pending:w.isPending||T.isPending}),(0,X.jsxs)(G,{isOpen:h!==null,onClose:()=>g(null),title:e(`admin.clients.deleteTitle`,{name:h?.name??``}),variant:`destructive`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs rounded-tinyrack-md border border-tinyrack-danger-border bg-tinyrack-danger-surface p-tinyrack-lg text-tinyrack-danger-foreground`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,X.jsx)(le,{"aria-hidden":!0,className:`size-tinyrack-lg`}),(0,X.jsx)(s,{as:`p`,weight:`medium`,children:e(`admin.clients.deleteWarning`)})]}),(0,X.jsx)(s,{as:`p`,variant:`bodySm`,children:e(`admin.clients.deleteDescription`)})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{disabled:O.isPending,onClick:()=>g(null),type:`button`,children:e(`common.dismiss`)}),(0,X.jsx)(R,{disabled:O.isPending||!h,intent:`danger`,onClick:()=>{h&&O.mutate(h.id)},type:`button`,children:e(`admin.actions.delete`)})]})]}),(0,X.jsx)(G,{description:e(`admin.clients.secretDescription`),isOpen:y!==null,onClose:()=>b(null),title:e(`admin.clients.secretTitle`),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md pt-tinyrack-lg`,children:[(0,X.jsx)(K,{className:`break-all rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-md`,children:y}),(0,X.jsx)(s,{color:`warning`,variant:`bodySm`,children:e(`admin.clients.secretWarning`)}),(0,X.jsx)(W,{children:(0,X.jsx)(R,{onClick:()=>b(null),type:`button`,children:e(`common.dismiss`)})})]})})]})}function Z(e,t){let n=e.get(t);return typeof n==`string`?n.trim():``}function Q(e,t){return Z(e,t).split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}function We({isOpen:e,client:t,pending:n,onClose:r,onSubmit:i}){let{t:o}=a();return(0,X.jsx)(G,{description:o(t?`admin.clients.editDescription`:`admin.clients.createDescription`),isOpen:e,onClose:r,title:o(t?`admin.clients.editTitle`:`admin.clients.createTitle`),children:(0,X.jsxs)(ue,{className:`grid gap-tinyrack-md pt-tinyrack-lg sm:grid-cols-2`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),n=Z(t,`type`);i({client_id:Z(t,`client_id`),name:Z(t,`name`),type:n===`confidential`?`confidential`:`public`,redirect_uris:Q(t,`redirect_uris`),post_logout_redirect_uris:Q(t,`post_logout_redirect_uris`),web_origins:Q(t,`web_origins`),grant_types:Q(t,`grant_types`),response_types:Q(t,`response_types`),scopes:Q(t,`scopes`),skip_consent:t.get(`skip_consent`)===`on`})},children:[(0,X.jsx)($,{defaultValue:t?.client_id,disabled:!!t,label:o(`admin.clients.clientId`),name:`client_id`,required:!0}),(0,X.jsx)($,{defaultValue:t?.name,label:o(`admin.clients.name`),name:`name`,required:!0}),(0,X.jsx)(Ge,{defaultValue:t?.type??`public`,disabled:!!t,label:o(`admin.clients.type`),name:`type`,options:[[`public`,o(`admin.clients.public`)],[`confidential`,o(`admin.clients.confidential`)]]}),(0,X.jsx)($,{defaultValue:t?.scopes.join(`, `),label:o(`admin.clients.scopes`),name:`scopes`,required:!0}),(0,X.jsx)($,{defaultValue:t?.redirect_uris.join(`
|
|
2
2
|
`),label:o(`admin.clients.redirectUris`),name:`redirect_uris`,required:!0}),(0,X.jsx)($,{defaultValue:t?.post_logout_redirect_uris.join(`
|
|
3
3
|
`),label:o(`admin.clients.postLogoutUris`),name:`post_logout_redirect_uris`}),(0,X.jsx)($,{defaultValue:t?.web_origins.join(`
|
|
4
|
-
`),label:o(`admin.clients.webOrigins`),name:`web_origins`}),(0,X.jsx)($,{defaultValue:t?.grant_types.join(`, `)??`authorization_code`,label:o(`admin.clients.grantTypes`),name:`grant_types`,required:!0}),(0,X.jsx)($,{defaultValue:t?.response_types.join(`, `)??`code`,label:o(`admin.clients.responseTypes`),name:`response_types`,required:!0}),(0,X.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,X.jsx)(me.Root,{"aria-label":o(`admin.clients.skipConsent`),defaultChecked:t?.skip_consent,name:`skip_consent`,value:`on`,children:(0,X.jsx)(me.Indicator,{})}),(0,X.jsx)(s,{variant:`caption`,children:o(`admin.clients.skipConsent`)})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{disabled:n,onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,X.jsx)(R,{disabled:n,intent:`primary`,type:`submit`,children:o(`admin.actions.save`)})]})]})})}function $({label:e,name:t,defaultValue:n,disabled:r,required:i}){return(0,X.jsxs)(de.Root,{children:[(0,X.jsx)(de.Label,{children:e}),(0,X.jsx)(fe,{defaultValue:n,disabled:r,name:t,required:i,uiSize:`sm`})]})}function Ge({label:e,name:t,defaultValue:n,disabled:r,options:i}){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs text-tinyrack-xs`,children:[(0,X.jsx)(s,{as:`span`,variant:`caption`,children:e}),(0,X.jsxs)(L.Root,{defaultValue:n,disabled:r,name:t,children:[(0,X.jsx)(L.Trigger,{"aria-label":e,uiSize:`sm`,children:(0,X.jsx)(L.Value,{children:i.find(([e])=>e===n)?.[1]??n})}),(0,X.jsx)(L.Positioner,{children:(0,X.jsx)(L.Popup,{children:(0,X.jsx)(L.List,{children:i.map(([e,t])=>(0,X.jsx)(L.Item,{value:e,children:(0,X.jsx)(L.ItemText,{children:t})},e))})})})]})]})}function Ke({active:e,count:t,filterSelected:n,onClose:r,onRun:i}){let{t:o}=a();return(0,X.jsx)(G,{isOpen:e!==null,onClose:r,title:o(e?`admin.bulk.activateTitle`:`admin.bulk.deactivateTitle`),children:(0,X.jsxs)(`div`,{className:`pt-tinyrack-lg`,children:[(0,X.jsx)(s,{color:`muted`,variant:`bodySm`,children:o(`admin.bulk.confirm`,{count:t,scope:o(n?`admin.selection.filterScope`:`admin.selection.pageScope`)})}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,X.jsx)(R,{intent:e?`primary`:`danger`,onClick:i,type:`button`,children:o(`admin.bulk.run`)})]})]})})}var qe=n(function({loaderData:e}){return(0,X.jsx)(ge,{state:e.dehydratedState,children:(0,X.jsx)(Ue,{})})});export{qe as default};
|
|
4
|
+
`),label:o(`admin.clients.webOrigins`),name:`web_origins`}),(0,X.jsx)($,{defaultValue:t?.grant_types.join(`, `)??`authorization_code`,label:o(`admin.clients.grantTypes`),name:`grant_types`,required:!0}),(0,X.jsx)($,{defaultValue:t?.response_types.join(`, `)??`code`,label:o(`admin.clients.responseTypes`),name:`response_types`,required:!0}),(0,X.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,X.jsx)(me.Root,{"aria-describedby":`client-preapproval-description`,"aria-label":o(`admin.clients.skipConsent`),defaultChecked:t?.skip_consent,name:`skip_consent`,value:`on`,children:(0,X.jsx)(me.Indicator,{})}),(0,X.jsx)(s,{variant:`caption`,children:o(`admin.clients.skipConsent`)})]}),(0,X.jsx)(s,{color:`muted`,id:`client-preapproval-description`,variant:`caption`,children:o(`admin.clients.skipConsentDescription`)}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{disabled:n,onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,X.jsx)(R,{disabled:n,intent:`primary`,type:`submit`,children:o(`admin.actions.save`)})]})]})})}function $({label:e,name:t,defaultValue:n,disabled:r,required:i}){return(0,X.jsxs)(de.Root,{children:[(0,X.jsx)(de.Label,{children:e}),(0,X.jsx)(fe,{defaultValue:n,disabled:r,name:t,required:i,uiSize:`sm`})]})}function Ge({label:e,name:t,defaultValue:n,disabled:r,options:i}){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs text-tinyrack-xs`,children:[(0,X.jsx)(s,{as:`span`,variant:`caption`,children:e}),(0,X.jsxs)(L.Root,{defaultValue:n,disabled:r,name:t,children:[(0,X.jsx)(L.Trigger,{"aria-label":e,uiSize:`sm`,children:(0,X.jsx)(L.Value,{children:i.find(([e])=>e===n)?.[1]??n})}),(0,X.jsx)(L.Positioner,{children:(0,X.jsx)(L.Popup,{children:(0,X.jsx)(L.List,{children:i.map(([e,t])=>(0,X.jsx)(L.Item,{value:e,children:(0,X.jsx)(L.ItemText,{children:t})},e))})})})]})]})}function Ke({active:e,count:t,filterSelected:n,onClose:r,onRun:i}){let{t:o}=a();return(0,X.jsx)(G,{isOpen:e!==null,onClose:r,title:o(e?`admin.bulk.activateTitle`:`admin.bulk.deactivateTitle`),children:(0,X.jsxs)(`div`,{className:`pt-tinyrack-lg`,children:[(0,X.jsx)(s,{color:`muted`,variant:`bodySm`,children:o(`admin.bulk.confirm`,{count:t,scope:o(n?`admin.selection.filterScope`:`admin.selection.pageScope`)})}),(0,X.jsxs)(W,{children:[(0,X.jsx)(R,{onClick:r,type:`button`,children:o(`common.dismiss`)}),(0,X.jsx)(R,{intent:e?`primary`:`danger`,onClick:i,type:`button`,children:o(`admin.bulk.run`)})]})]})})}var qe=n(function({loaderData:e}){return(0,X.jsx)(ge,{state:e.dehydratedState,children:(0,X.jsx)(Ue,{})})});export{qe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{c as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{L as s,a as c,n as l,t as u}from"./api-CfCwvXbU.js";import{r as d}from"./text-CBHShrvS.js";import{t as f}from"./useMutation-BkuKGzks.js";import{t as p}from"./mutationOptions-Dfvzj6n2.js";import{r as m}from"./NullStore-UyCsFQfz.js";import{t as h}from"./auth-field-CDCz-y27.js";import{n as g}from"./language-selector-CeLHnp1n.js";import{t as _}from"./lock-Cr_egoXD.js";import{t as v}from"./mail-B2PK2vlI.js";import{t as y}from"./route-error-fallback-CRL2Et8O.js";import{r as b,t as x}from"./standard-schema-kM5DbC12.js";import{r as S}from"./FieldItemContext-B3N2qWH8.js";import{a as C,r as ee,s as w}from"./schemas-B87iTMww.js";import{n as T,t as E}from"./promise-CepnkPDw.js";import{o as D}from"./passkey-Bkqvhjwb.js";import{t as O}from"./document-navigation-Cnp3Alf0.js";import{n as k,r as A,t as j}from"./route-module-2foR49uh.js";import{t as M}from"./auth-layout-BedWIZ7L.js";import{t as N}from"./link-Dsq51NsW.js";import{n as P,t as F}from"./auth-footer-LG_gGuJv.js";import{i as I,r as L,t as R}from"./oauth-search-DebNssaC.js";import{t as z}from"./sanitized-rich-text-uZcpKo6H.js";var B=e(t(),1),V=p({mutationFn:async e=>{let t=await u.api.auth.login.$post({json:e});return l(t)}}),H=o();function U({search:e}){let{t,i18n:n}=c(),[i,o]=(0,B.useState)(!1);(0,B.useEffect)(()=>{o(!0)},[]);let l=r(),u=s(),p=(0,B.useCallback)((e,t)=>l(t?A(e,t):e),[l]),y=e.account_selection_state&&e.prompt?.split(` `).includes(`login`)?{...e,account_selected:1}:e,k=e.lang??n.language,{data:j}=d(g),U=j.registration.signup_notice?.[k]??j.registration.signup_notice?.[j.i18n.fallback_language],W=j.auth.password.enabled,G=j.auth.passkey.enabled,K=j.identity_providers.length+ +!!W+ +!!G>1,q=(0,B.useMemo)(()=>C({email:w().min(1,t(`validation.email.required`)).pipe(ee(t(`validation.email.invalid`))),password:w().min(1,t(`validation.password.required`))}),[t]),J=f({...V,onSuccess:async(t,n)=>{let r=t.user;if(r.email_verification_required&&!r.email_verified){p(`/verify/email`,{email:n.email,...L(e)});return}u.setQueryData(T.queryKey,{user:r}),await E();let i=[];if(j.auth.password.totp.enabled&&r.totp_registered&&i.push(`totp`),j.auth.passkey.enabled&&r.passkey_count>0&&i.push(`passkey`),r.second_factor_required&&i.length===0){if(j.available_2fa_setup_methods.length>1)return p(`/setup/2fa`,L(e));if(j.available_2fa_setup_methods.length===1)return j.available_2fa_setup_methods[0]===`totp`?p(`/setup/totp`,L(e)):p(`/setup/passkey`,{...L(e),passkey_name:`default`})}if(i.length>1)return p(`/verify/2fa`,L(e));if(i.length===1)return i[0]===`totp`?p(`/verify/totp`,L(e)):p(`/verify/passkey`,L(e));if(I(e))O(R(y));else return l(`/profile`)},onError:e=>{te(`email`,{type:`manual`,message:t(`login.error.failed`)})}}),Y=(0,B.useCallback)(async t=>{t.user&&(u.setQueryData(T.queryKey,t),await E(),I(e)?O(R(y)):l(`/profile`)),u.invalidateQueries({queryKey:T.queryKey})},[u,l,e,y]),X=(0,B.useRef)(null),Z=(0,B.useRef)(Y);(0,B.useEffect)(()=>{Z.current=Y},[Y]),(0,B.useEffect)(()=>{if(!G||!W)return;let e=new AbortController;return X.current=e,D(e=>{Z.current(e)},e.signal),()=>{e.abort()}},[G,W]);let{register:Q,setError:te,handleSubmit:ne,formState:{errors:$}}=b({defaultValues:{email:``,password:``},resolver:x(q)});return(0,H.jsxs)(M,{showBrandSubtitle:!0,children:[W&&(0,H.jsxs)(S,{className:`flex flex-col gap-tinyrack-lg`,method:`post`,onSubmit:ne(e=>{X.current?.abort(),J.mutate(e)}),children:[(0,H.jsx)(h,{autoComplete:`username webauthn`,disabled:!i,error:$.email,icon:v,label:t(`login.email.label`),placeholder:t(`login.email.placeholder`),...Q(`email`),type:`email`}),(0,H.jsx)(h,{autoComplete:`current-password`,disabled:!i,error:$.password,icon:_,label:t(`login.password.label`),labelAction:j.email.enabled?(0,H.jsx)(N,{className:`text-tinyrack-xs`,render:(0,H.jsx)(a,{to:`/password/forgot`}),children:t(`login.link.forgotPassword`)}):void 0,placeholder:t(`login.password.placeholder`),...Q(`password`),type:`password`}),(0,H.jsx)(m,{className:`w-full`,disabled:!i,intent:`primary`,loading:J.isPending,loadingLabel:t(`login.submitting`),type:`submit`,uiSize:`lg`,children:t(`login.submit`)})]}),U&&(0,H.jsx)(z,{html:U,variant:`notice`}),(j.registration.public_registration||K)&&(0,H.jsxs)(F,{children:[j.registration.public_registration&&(0,H.jsx)(P,{link:(0,H.jsx)(a,{to:A(`/register`,L(e)),children:t(`login.link.register`)}),text:t(`login.footer.noAccount`)}),K&&(0,H.jsx)(P,{link:(0,H.jsx)(a,{to:A(`/login`,L(e)),children:t(`login.password.backToMethods`)})})]})]})}var W=i(function({error:e}){return(0,H.jsx)(j,{component:y,error:e})}),G=n(function({loaderData:e}){return(0,H.jsx)(k,{state:e.dehydratedState,children:(0,H.jsx)(U,{search:e.search})})});export{W as ErrorBoundary,G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{L as s,a as c,n as l,t as u}from"./api-CfCwvXbU.js";import{r as d,t as f}from"./text-CBHShrvS.js";import{t as p}from"./useMutation-BkuKGzks.js";import{t as m}from"./mutationOptions-Dfvzj6n2.js";import{i as h,r as g}from"./NullStore-UyCsFQfz.js";import{t as _}from"./circle-check-BW_XcUlv.js";import{t as v}from"./auth-field-CDCz-y27.js";import{t as y}from"./key-round-BlUAV-K9.js";import{n as b}from"./language-selector-
|
|
1
|
+
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{L as s,a as c,n as l,t as u}from"./api-CfCwvXbU.js";import{r as d,t as f}from"./text-CBHShrvS.js";import{t as p}from"./useMutation-BkuKGzks.js";import{t as m}from"./mutationOptions-Dfvzj6n2.js";import{i as h,r as g}from"./NullStore-UyCsFQfz.js";import{t as _}from"./circle-check-BW_XcUlv.js";import{t as v}from"./auth-field-CDCz-y27.js";import{t as y}from"./key-round-BlUAV-K9.js";import{n as b}from"./language-selector-CeLHnp1n.js";import{t as x}from"./mail-B2PK2vlI.js";import{t as S}from"./auth-page-header-C6Z6Air-.js";import{t as C}from"./alert-DS8e0Gvg.js";import{t as w}from"./auth-outcome-DyY0JgWG.js";import{t as T}from"./route-error-fallback-CRL2Et8O.js";import{r as E,t as D}from"./standard-schema-kM5DbC12.js";import{r as O}from"./FieldItemContext-B3N2qWH8.js";import{a as k,s as A}from"./schemas-B87iTMww.js";import{n as j,t as M}from"./promise-CepnkPDw.js";import{t as N}from"./document-navigation-Cnp3Alf0.js";import{n as P,r as F,t as I}from"./route-module-2foR49uh.js";import{t as L}from"./auth-layout-BedWIZ7L.js";import{t as R}from"./labeled-separator-JGa2pO6H.js";import{i as z,r as B,t as V}from"./oauth-search-DebNssaC.js";var H=e(t(),1),U=m({mutationFn:async e=>{let t=await u.api.auth.email.verify.$post({json:e});return l(t)}}),W=m({mutationFn:async e=>{let t=await u.api.auth.email.resend.$post({json:e,header:{}});return l(t)}}),G=o();function K({search:e}){let{t}=c(),n=r(),i=s(),o=(e,t)=>n(t?F(e,t):e),{token:l,email:u}=e,[m,T]=(0,H.useState)(!1),[P,I]=(0,H.useState)(!1),K=a.useToastManager(),{data:q}=d(b),J=(0,H.useMemo)(()=>k({token:A().min(1,t(`validation.token.required`))}),[t]),Y=p({...U,onSuccess:async t=>{let n=t.user;if(i.setQueryData(j.queryKey,{user:n}),await M(),n.second_factor_required){let t=[];return q.auth.password.totp.enabled&&t.push(`totp`),q.auth.passkey.enabled&&t.push(`passkey`),t.length===1?t[0]===`totp`?o(`/setup/totp`,B(e)):o(`/setup/passkey`,B(e)):o(`/setup/2fa`,B(e))}z(e)?N(V(e)):T(!0)},onSettled:()=>{i.invalidateQueries({queryKey:j.queryKey})}}),X=p({...W,onSuccess:()=>{K.add({title:t(`verifyEmail.resendSuccess`),type:`success`}),I(!0),setTimeout(()=>I(!1),5e3)}}),{register:Z,setError:Q,handleSubmit:$,formState:{errors:ee}}=E({defaultValues:{token:l||``},resolver:D(J)}),te=async e=>{try{await Y.mutateAsync(e)}catch{Q(`token`,{type:`manual`,message:t(`verifyEmail.error.invalidToken`)})}},ne=async()=>{if(u)try{await X.mutateAsync({email:u})}catch{}};return m?(0,G.jsx)(L,{children:(0,G.jsx)(`div`,{"data-testid":`alert-success`,children:(0,G.jsx)(w,{description:(0,G.jsxs)(G.Fragment,{children:[t(`verifyEmail.success.subtitle`),(0,G.jsx)(`br`,{}),t(`verifyEmail.success.description`)]}),icon:_,title:t(`verifyEmail.success.title`),tone:`success`,children:(0,G.jsx)(g,{className:`w-full`,"data-testid":`email-verify-go-profile`,intent:`primary`,onClick:()=>n(`/profile`),type:`button`,uiSize:`lg`,children:t(`verifyEmail.success.goToProfile`)})})})}):(0,G.jsxs)(L,{children:[(0,G.jsx)(S,{subtitle:t(`verifyEmail.subtitle`),title:t(`verifyEmail.title`)}),u&&(0,G.jsx)(C,{icon:x,type:`info`,children:(0,G.jsxs)(`span`,{className:`flex flex-col gap-tinyrack-3xs text-left`,children:[(0,G.jsx)(f,{variant:`body`,weight:`strong`,children:t(`register.success.subtitle`)}),(0,G.jsx)(f,{color:`muted`,variant:`caption`,children:t(`register.success.description`,{email:u})})]})}),(0,G.jsxs)(O,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:$(te),children:[(0,G.jsx)(v,{error:ee.token,icon:y,label:t(`verifyEmail.token.label`),placeholder:t(`verifyEmail.token.placeholder`),...Z(`token`),type:`text`}),(0,G.jsx)(g,{className:`w-full`,intent:`primary`,loading:Y.isPending,loadingLabel:t(`verifyEmail.submitting`),type:`submit`,uiSize:`lg`,children:t(`verifyEmail.submit`)})]}),u&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-md`,children:[(0,G.jsx)(R,{}),(0,G.jsx)(g,{appearance:`ghost`,className:`w-full`,"data-testid":`email-verify-resend`,disabled:X.isPending||P,intent:`neutral`,onClick:ne,type:`button`,uiSize:`lg`,children:X.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(h,{uiSize:`sm`}),t(`verifyEmail.resending`)]}):t(`verifyEmail.resend`)})]})]})}var q=i(function({error:e}){return(0,G.jsx)(I,{component:T,error:e})}),J=n(function({loaderData:e}){return(0,G.jsx)(P,{state:e.dehydratedState,children:(0,G.jsx)(K,{search:e.search})})});export{q as ErrorBoundary,J as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./components-DF4L3dSB.js";import{c as t}from"./toast-XXVYYXim.js";import{t as n}from"./jsx-runtime-B-57GDDH.js";import{a as r}from"./api-CfCwvXbU.js";import{t as i}from"./text-CBHShrvS.js";import{r as a}from"./NullStore-UyCsFQfz.js";import{t as o}from"./circle-alert-BZCKPkRn.js";import{t as s}from"./link-button-DGt9hwk7.js";import{t as c}from"./code-Dc5QnXCh.js";import{t as l}from"./auth-outcome-DyY0JgWG.js";import{n as u}from"./route-module-2foR49uh.js";import{t as d}from"./auth-layout-
|
|
1
|
+
import{a as e}from"./components-DF4L3dSB.js";import{c as t}from"./toast-XXVYYXim.js";import{t as n}from"./jsx-runtime-B-57GDDH.js";import{a as r}from"./api-CfCwvXbU.js";import{t as i}from"./text-CBHShrvS.js";import{r as a}from"./NullStore-UyCsFQfz.js";import{t as o}from"./circle-alert-BZCKPkRn.js";import{t as s}from"./link-button-DGt9hwk7.js";import{t as c}from"./code-Dc5QnXCh.js";import{t as l}from"./auth-outcome-DyY0JgWG.js";import{n as u}from"./route-module-2foR49uh.js";import{t as d}from"./auth-layout-BedWIZ7L.js";import{n as f,t as p}from"./auth-footer-LG_gGuJv.js";var m=n();function h({search:e}){let{t:n}=r(),u=e.code||`UNKNOWN_ERROR`,h=e.message||n(`error.defaultMessage`);return(0,m.jsxs)(d,{children:[(0,m.jsxs)(l,{description:h,icon:o,title:n(`error.subtitle`),tone:`danger`,children:[(0,m.jsxs)(i,{color:`muted`,variant:`caption`,children:[n(`error.codeLabel`),` `,(0,m.jsx)(c,{"data-testid":`error-code`,children:u})]}),(0,m.jsx)(s,{className:`w-full`,intent:`primary`,render:(0,m.jsx)(t,{to:`/login`}),uiSize:`lg`,children:n(`error.goToLogin`)}),(0,m.jsx)(a,{appearance:`ghost`,className:`w-full`,intent:`neutral`,onClick:()=>window.history.back(),type:`button`,uiSize:`lg`,children:n(`error.goBack`)})]}),(0,m.jsx)(p,{children:(0,m.jsx)(f,{link:(0,m.jsx)(`a`,{href:`mailto:support@example.com`,children:n(`error.footer.contactSupport`)}),text:n(`error.footer.needHelp`)})})]})}var g=e(function({loaderData:e}){return(0,m.jsx)(u,{state:e.dehydratedState,children:(0,m.jsx)(h,{search:e.search})})});export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,t}from"./components-DF4L3dSB.js";import{t as n}from"./jsx-runtime-B-57GDDH.js";import{n as r}from"./auth-layout-BedWIZ7L.js";var i=n(),a=e(function(){return(0,i.jsx)(r,{children:(0,i.jsx)(t,{})})});export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,J as t,a as n,f as r}from"./components-DF4L3dSB.js";import{c as i}from"./toast-XXVYYXim.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,n as c,t as l}from"./api-CfCwvXbU.js";import{n as u,t as d}from"./text-CBHShrvS.js";import{t as f}from"./useMutation-BkuKGzks.js";import{t as p}from"./useQuery-BLm0XsTI.js";import{i as m,r as h}from"./NullStore-UyCsFQfz.js";import{t as g}from"./circle-alert-BZCKPkRn.js";import{t as _}from"./fingerprint-pattern-AUfgwio5.js";import{r as v}from"./language-selector-
|
|
1
|
+
import{$ as e,J as t,a as n,f as r}from"./components-DF4L3dSB.js";import{c as i}from"./toast-XXVYYXim.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,n as c,t as l}from"./api-CfCwvXbU.js";import{n as u,t as d}from"./text-CBHShrvS.js";import{t as f}from"./useMutation-BkuKGzks.js";import{t as p}from"./useQuery-BLm0XsTI.js";import{i as m,r as h}from"./NullStore-UyCsFQfz.js";import{t as g}from"./circle-alert-BZCKPkRn.js";import{t as _}from"./fingerprint-pattern-AUfgwio5.js";import{r as v}from"./language-selector-CeLHnp1n.js";import{t as y}from"./auth-page-header-C6Z6Air-.js";import{t as b}from"./link-button-DGt9hwk7.js";import{t as x}from"./alert-DS8e0Gvg.js";import{n as S,t as C}from"./promise-CepnkPDw.js";import{t as w}from"./passkey-Bkqvhjwb.js";import{t as T}from"./document-navigation-Cnp3Alf0.js";import{n as E,r as D}from"./route-module-2foR49uh.js";import{t as O}from"./auth-layout-BedWIZ7L.js";import{n as k,t as A}from"./auth-footer-LG_gGuJv.js";import{i as j,r as M,t as N}from"./oauth-search-DebNssaC.js";import{t as P}from"./passkey-error-C3DrncLi.js";var F=e(t(),1),I=u({queryKey:v.pendingSecondFactorMethods(),queryFn:async()=>{let e=await l.api.auth[`2fa`].methods.$get();return c(e)},retry:!1}),L=a();function R({search:e}){let{t}=s(),n=r(),a=o(),[c,l]=(0,F.useState)(null),u=(0,F.useRef)(!1),v=p({...I,enabled:c!==null}).data?.methods.includes(`totp`)??!1,E=e=>{switch(e){case`unsupported`:return t(`verifyPasskey.error.unsupported`);case`not_allowed`:return t(`verifyPasskey.error.notAllowed`);case`expired`:return t(`verifyPasskey.error.expired`);case`user_mismatch`:return t(`verifyPasskey.error.userMismatch`);case`verification_failed`:return t(`verifyPasskey.error.failed`)}},R=f({...w,onSuccess:async t=>{t.user&&(a.setQueryData(S.queryKey,{user:t.user}),await C(),j(e)?T(N(e)):await n(`/profile`))},onError:async e=>{let t=P(e);l({message:E(t),reason:t})}});return(0,F.useEffect)(()=>{u.current||(u.current=!0,R.mutate())},[R]),(0,L.jsxs)(O,{children:[(0,L.jsx)(y,{align:`center`,subtitle:t(`verifyPasskey.subtitle`),title:t(`verifyPasskey.title`)}),(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-lg`,children:[(0,L.jsx)(`div`,{className:`flex size-tinyrack-3xl items-center justify-center rounded-tinyrack-full bg-tinyrack-surface-muted`,children:(0,L.jsx)(_,{"aria-hidden":!0,className:`size-tinyrack-2xl text-tinyrack-text-muted`})}),R.isPending&&(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-sm`,children:[(0,L.jsx)(m,{uiSize:`md`}),(0,L.jsx)(d,{align:`center`,as:`p`,color:`muted`,variant:`bodySm`,children:t(`verifyPasskey.waiting`)})]}),c&&(0,L.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-tinyrack-md`,children:[(0,L.jsx)(x,{className:`w-full`,icon:g,type:`error`,children:c.message}),v&&(0,L.jsx)(b,{className:`w-full`,intent:`primary`,render:(0,L.jsx)(i,{to:D(`/verify/totp`,M(e))}),uiSize:`lg`,children:t(`verifyPasskey.useTotp`)}),(0,L.jsx)(h,{appearance:v?`outline`:`solid`,className:`w-full`,intent:v?`neutral`:`primary`,onClick:()=>{l(null),R.mutate()},type:`button`,uiSize:`lg`,children:t(`verifyPasskey.retry`)})]})]}),(0,L.jsx)(A,{children:(0,L.jsx)(k,{link:(0,L.jsx)(i,{to:D(`/login`,e),children:t(`verifyPasskey.backToLogin`)})})})]})}var z=n(function({loaderData:e}){return(0,L.jsx)(E,{state:e.dehydratedState,children:(0,L.jsx)(R,{search:e.search})})});export{z as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,o as t}from"./components-DF4L3dSB.js";import{c as n}from"./toast-XXVYYXim.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{a as i}from"./api-CfCwvXbU.js";import{r as a}from"./text-CBHShrvS.js";import{t as o}from"./auth-choice-row-DNB3B1Vs.js";import{t as s}from"./fingerprint-pattern-AUfgwio5.js";import{n as c}from"./language-selector-
|
|
1
|
+
import{a as e,o as t}from"./components-DF4L3dSB.js";import{c as n}from"./toast-XXVYYXim.js";import{t as r}from"./jsx-runtime-B-57GDDH.js";import{a as i}from"./api-CfCwvXbU.js";import{r as a}from"./text-CBHShrvS.js";import{t as o}from"./auth-choice-row-DNB3B1Vs.js";import{t as s}from"./fingerprint-pattern-AUfgwio5.js";import{n as c}from"./language-selector-CeLHnp1n.js";import{t as l}from"./shield-check-2DKLuF9J.js";import{t as u}from"./auth-page-header-C6Z6Air-.js";import{t as d}from"./route-error-fallback-CRL2Et8O.js";import{n as f,r as p,t as m}from"./route-module-2foR49uh.js";import{t as h}from"./auth-layout-BedWIZ7L.js";import{n as g,t as _}from"./auth-footer-LG_gGuJv.js";import{r as v}from"./oauth-search-DebNssaC.js";var y=r();function b({search:e}){let{t}=i(),r=v(e),{data:d}=a(c);return(0,y.jsxs)(h,{children:[(0,y.jsx)(u,{subtitle:t(`verify2fa.subtitle`),title:t(`verify2fa.title`)}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[d.auth.password.enabled&&d.auth.password.totp.enabled&&(0,y.jsx)(o,{description:t(`verify2fa.totp.description`),icon:l,label:t(`verify2fa.totp.title`),render:(0,y.jsx)(n,{to:p(`/verify/totp`,r)})}),d.auth.passkey.enabled&&(0,y.jsx)(o,{description:t(`verify2fa.passkey.description`),icon:s,label:t(`verify2fa.passkey.title`),render:(0,y.jsx)(n,{to:p(`/verify/passkey`,r)})})]}),(0,y.jsx)(_,{children:(0,y.jsx)(g,{link:(0,y.jsx)(n,{to:p(`/login`,r),children:t(`verify2fa.backToLogin`)})})})]})}var x=t(function({error:e}){return(0,y.jsx)(m,{component:d,error:e})}),S=e(function({loaderData:e}){return(0,y.jsx)(f,{state:e.dehydratedState,children:(0,y.jsx)(b,{search:e.search})})});export{x as ErrorBoundary,S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s}from"./api-CfCwvXbU.js";import{r as c}from"./text-CBHShrvS.js";import{t as l}from"./useMutation-BkuKGzks.js";import{r as u}from"./NullStore-UyCsFQfz.js";import{n as d}from"./language-selector-
|
|
1
|
+
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s}from"./api-CfCwvXbU.js";import{r as c}from"./text-CBHShrvS.js";import{t as l}from"./useMutation-BkuKGzks.js";import{r as u}from"./NullStore-UyCsFQfz.js";import{n as d}from"./language-selector-CeLHnp1n.js";import{t as f}from"./triangle-alert-B0lTzZDi.js";import{t as p}from"./auth-page-header-C6Z6Air-.js";import{t as m}from"./alert-DS8e0Gvg.js";import{t as h}from"./route-error-fallback-CRL2Et8O.js";import{r as g,t as _}from"./standard-schema-kM5DbC12.js";import{r as v}from"./FieldItemContext-B3N2qWH8.js";import{a as y,i as b,n as x}from"./schemas-B87iTMww.js";import{n as S,t as C}from"./promise-CepnkPDw.js";import{t as w}from"./document-navigation-Cnp3Alf0.js";import{n as T,t as E}from"./route-module-2foR49uh.js";import{t as D}from"./auth-layout-BedWIZ7L.js";import{t as O}from"./labeled-separator-JGa2pO6H.js";import{t as k}from"./sanitized-rich-text-uZcpKo6H.js";import{n as A,r as j,t as M}from"./terms-BGJD_l_i.js";var N=e(t(),1),P=a();function F(e){return(0,P.jsx)(h,{...e,onUnauthorized:()=>{w(`/login`)}})}function I({search:e}){let{t,i18n:n}=s(),i=r(),a=o(),{data:h}=c(d),T=e.lang??n.language,E=c(M(T)),F=h.registration.signup_notice?.[T]??h.registration.signup_notice?.[h.i18n.fallback_language],I=(0,N.useMemo)(()=>E.data.terms.filter(e=>e.consentMode===`explicit`),[E.data.terms]),L=(0,N.useMemo)(()=>E.data.terms.filter(e=>e.consentMode===`implicit`),[E.data.terms]),R=I.length>0,z=(0,N.useMemo)(()=>y({termsConsents:y(Object.fromEntries(I.map(e=>[e.id,e.required?b(!0,{message:t(`validation.terms.required`)}):x()])))}),[t,I]),{handleSubmit:B,control:V,setValue:H,formState:{errors:U}}=g({defaultValues:{termsConsents:Object.fromEntries(I.map(e=>[e.id,!(!e.userConsent?.agreed||e.userConsent.requiresUpdate)]))},resolver:_(z),mode:`onChange`}),W=l({...A,onSuccess:async()=>{await a.invalidateQueries({queryKey:S.queryKey}),await a.fetchQuery(S),await C(),e.redirect?w(e.redirect):i(`/profile`)}});return(0,P.jsxs)(D,{width:`wide`,children:[(0,P.jsx)(p,{title:t(`terms.title`)}),F&&(0,P.jsx)(k,{html:F,variant:`notice`}),F&&R&&(0,P.jsx)(O,{label:t(`terms.additionalOptionalConsent`)}),(0,P.jsxs)(v,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:B(t=>{let n=Object.entries(t.termsConsents).map(([e,t])=>({termsId:e,agreed:t,consentType:`explicit`})),r=L.map(e=>({termsId:e.id,agreed:!0,consentType:`implicit`}));W.mutate({consents:[...n,...r],...e.registration_token&&{registrationToken:e.registration_token}})}),children:[R&&(0,P.jsx)(j,{control:V,disabled:W.isPending,errors:U,setValue:H,terms:I}),W.isError&&(0,P.jsx)(m,{icon:f,type:`error`,children:t(`terms.error.submitFailed`)}),(0,P.jsx)(`div`,{className:`sticky bottom-0 flex gap-tinyrack-sm border-tinyrack-border border-t-tinyrack-default bg-tinyrack-surface py-tinyrack-md`,children:(0,P.jsx)(u,{className:`w-full`,intent:`primary`,loading:W.isPending,loadingLabel:t(`terms.submit`),type:`submit`,uiSize:`lg`,children:t(`terms.submit`)})})]})]})}var L=i(function({error:e}){return(0,P.jsx)(E,{component:F,error:e})}),R=n(function({loaderData:e}){return(0,P.jsx)(T,{state:e.dehydratedState,children:(0,P.jsx)(I,{search:e.search})})});export{L as ErrorBoundary,R as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./components-DF4L3dSB.js";import{t}from"./jsx-runtime-B-57GDDH.js";import{a as n}from"./api-CfCwvXbU.js";import{t as r}from"./text-CBHShrvS.js";import{B as i,t as a,z as o}from"./select-C_WHBpl_.js";import{s}from"./i18n-
|
|
1
|
+
import{a as e}from"./components-DF4L3dSB.js";import{t}from"./jsx-runtime-B-57GDDH.js";import{a as n}from"./api-CfCwvXbU.js";import{t as r}from"./text-CBHShrvS.js";import{B as i,t as a,z as o}from"./select-C_WHBpl_.js";import{s}from"./i18n-Dzv9HKFm.js";import{t as c}from"./language-selector-CeLHnp1n.js";import{n as l}from"./route-module-2foR49uh.js";var u=t();function d(){let{t:e}=n(),{colorScheme:t,setColorScheme:l}=s(),d=[[`light`,e(`common.theme.light`)],[`dark`,e(`common.theme.dark`)]];return(0,u.jsxs)(`div`,{className:`mx-auto flex w-full max-w-tinyrack-measure-xl flex-col gap-tinyrack-2xl`,children:[(0,u.jsxs)(`header`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h1`,variant:`headingMd`,weight:`heading`,children:e(`admin.settings.title`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.description`)})]}),(0,u.jsxs)(`section`,{className:`grid items-start gap-tinyrack-md sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h2`,variant:`headingSm`,children:e(`admin.settings.language`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.languageDescription`)})]}),(0,u.jsx)(c,{alwaysVisible:!0,className:`w-full sm:justify-self-end`,presentation:`field`,triggerClassName:`w-full min-w-full`,uiSize:`md`})]}),(0,u.jsxs)(`section`,{className:`grid items-start gap-tinyrack-md sm:grid-cols-2`,children:[(0,u.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-xs`,children:[(0,u.jsx)(r,{as:`h2`,variant:`headingSm`,children:e(`admin.settings.theme`)}),(0,u.jsx)(r,{as:`p`,color:`muted`,variant:`bodySm`,children:e(`admin.settings.themeDescription`)})]}),(0,u.jsxs)(a.Root,{onValueChange:e=>{(e===`light`||e===`dark`)&&l(e)},value:t,children:[(0,u.jsxs)(a.Trigger,{appearance:`solid`,"aria-label":e(`admin.settings.theme`),className:`w-full sm:justify-self-end`,uiSize:`md`,children:[(0,u.jsx)(a.Value,{children:d.find(([e])=>e===t)?.[1]}),(0,u.jsx)(a.Icon,{children:(0,u.jsx)(o,{"aria-hidden":!0})})]}),(0,u.jsx)(a.Portal,{children:(0,u.jsx)(a.Positioner,{children:(0,u.jsx)(a.Popup,{children:(0,u.jsx)(a.List,{children:d.map(([e,t])=>(0,u.jsxs)(a.Item,{value:e,children:[(0,u.jsx)(a.ItemText,{children:t}),(0,u.jsx)(a.ItemIndicator,{children:(0,u.jsx)(i,{"aria-hidden":!0})})]},e))})})})})]})]})]})}var f=e(function({loaderData:e}){return(0,u.jsx)(l,{state:e.dehydratedState,children:(0,u.jsx)(d,{})})});export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,i as c,n as l,t as u}from"./api-CfCwvXbU.js";import{n as d,r as f,t as p}from"./text-CBHShrvS.js";import{t as m}from"./useMutation-BkuKGzks.js";import{t as h}from"./useQuery-BLm0XsTI.js";import{t as g}from"./mutationOptions-Dfvzj6n2.js";import{V as _}from"./select-C_WHBpl_.js";import{a as v,i as y,r as b,t as x}from"./shell-header-bar-Bg85QIAq.js";import{i as S,r as C}from"./NullStore-UyCsFQfz.js";import{t as w}from"./card-BaQElRNE.js";import{t as T}from"./circle-alert-BZCKPkRn.js";import{a as E,i as D,n as ee,r as O,t as k}from"./use-totp-setup-D7XZ6Nos.js";import{t as A}from"./auth-field-CDCz-y27.js";import{t as j}from"./fingerprint-pattern-AUfgwio5.js";import{t as M}from"./key-round-BlUAV-K9.js";import{n as N,r as P}from"./language-selector-Chn-k7Pw.js";import{n as F,t as I}from"./provider-mark-CCOkSxh7.js";import{n as te,r as ne,t as re}from"./logout-DpMjBzc5.js";import{t as L}from"./shield-check-2DKLuF9J.js";import{t as R}from"./trash-C7RyeTUJ.js";import{t as z}from"./triangle-alert-B0lTzZDi.js";import{t as ie}from"./auth-page-header-BVY4zRzF.js";import{t as ae}from"./link-button-DGt9hwk7.js";import{t as B}from"./alert-DS8e0Gvg.js";import{n as V,t as H}from"./modal-BDu41alh.js";import{t as oe}from"./initial-avatar-ByHiX-IF.js";import{t as U}from"./route-error-fallback-CRL2Et8O.js";import{r as W,t as G}from"./standard-schema-kM5DbC12.js";import{r as K}from"./FieldItemContext-B3N2qWH8.js";import{a as q,s as J}from"./schemas-B87iTMww.js";import{n as Y,t as se}from"./promise-EbDcmV0j.js";import{n as ce,r as le}from"./totp-4989Pb-o.js";import{t as ue}from"./badge-Cr0iG_iG.js";import{a as de,i as fe,n as pe,r as me}from"./passkey-CWcdr7Vy.js";import{t as he}from"./document-navigation-Cnp3Alf0.js";import{n as ge,t as _e}from"./route-module-2foR49uh.js";var ve={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};ve.node;var ye=_(ve),be={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};be.node;var xe=_(be),Se={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Se.node;var Ce=_(Se),we={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};we.node;var Te=_(we),X=e(t(),1),Z=a();function Ee({isConfigManaged:e,isDeletionEnabled:t,onDeleteClick:n}){let{t:r}=s();return t?(0,Z.jsxs)(w.Root,{className:`border-tinyrack-danger-border bg-tinyrack-danger-surface`,variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-danger-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,Z.jsx)(z,{"aria-hidden":!0,className:`size-tinyrack-lg text-tinyrack-danger-foreground`}),(0,Z.jsx)(w.Title,{className:`text-tinyrack-danger-foreground`,children:r(`profile.dangerZone.title`)})]}),(0,Z.jsx)(w.Description,{children:r(`profile.dangerZone.description`)})]}),(0,Z.jsx)(w.Content,{className:`px-tinyrack-lg py-tinyrack-md`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(p,{as:`p`,variant:`bodySm`,weight:`medium`,children:r(`profile.deleteAccount.title`)}),(0,Z.jsx)(p,{as:`p`,color:`muted`,variant:`caption`,children:r(e?`profile.deleteAccount.configManaged`:`profile.deleteAccount.description`)})]}),(0,Z.jsxs)(C,{appearance:`outline`,"data-testid":`profile-delete-account`,disabled:e,intent:`danger`,onClick:n,type:`button`,uiSize:`sm`,children:[(0,Z.jsx)(R,{"aria-hidden":!0,className:`size-tinyrack-lg`}),r(`profile.deleteAccount.button`)]})]})})]}):null}function De({providerId:e,iconUrl:t,className:n=`size-tinyrack-xl`}){return e===`google`||e===`github`||e===`apple`?(0,Z.jsx)(I,{"aria-hidden":!0,className:n,provider:e}):t?(0,Z.jsx)(`img`,{alt:``,className:n,src:t}):(0,Z.jsx)(F,{"aria-hidden":!0,className:n})}function Q({icon:e,active:t,title:n,status:r,note:i,actions:a}){let o;return o=(0,X.isValidElement)(e)?e:(0,Z.jsx)(e,{"aria-hidden":!0,className:`size-tinyrack-lg ${t?`text-tinyrack-success-foreground`:`text-tinyrack-text-muted`}`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg p-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-tinyrack-md`,children:[(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-tinyrack-md ${t?`bg-tinyrack-success-surface`:`bg-tinyrack-surface-muted`}`,children:o}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(p,{variant:`bodySm`,weight:`medium`,children:n}),(0,Z.jsx)(p,{color:`muted`,variant:`caption`,children:r}),i]})]}),a&&(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-tinyrack-xs`,children:a})]})}function Oe({providers:e,unlinkingProvider:t,getAuthorizeUrl:n,onUnlinkRequest:r}){let{t:i}=s();return e.length===0?null:(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:i(`profile.linkedAccounts.title`)}),(0,Z.jsx)(w.Description,{children:i(`profile.linkedAccounts.description`)})]}),(0,Z.jsx)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:e.map(e=>(0,Z.jsx)(Q,{actions:e.linked?(0,Z.jsx)(C,{appearance:`ghost`,intent:`danger`,loading:t===e.id,loadingLabel:i(`profile.linkedAccounts.unlinking`),onClick:()=>r(e),type:`button`,uiSize:`sm`,children:t===e.id?void 0:i(`profile.linkedAccounts.unlink`)}):(0,Z.jsx)(ae,{appearance:`outline`,intent:`neutral`,render:(0,Z.jsx)(`a`,{href:n(e.id,`link`,`/profile`)}),uiSize:`sm`,children:i(`profile.linkedAccounts.link`)}),active:e.linked,icon:(0,Z.jsx)(De,{className:`size-tinyrack-lg`,iconUrl:e.icon_url,providerId:e.id}),status:e.linked?i(`profile.linkedAccounts.connected`):i(`profile.linkedAccounts.notConnected`),title:e.display_name},e.id))})]})}function ke({passkeyCount:e,onOpenModal:t}){let{t:n}=s(),r=e>0;return(0,Z.jsx)(Q,{actions:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:()=>t(r?`manage`:`setup`),type:`button`,uiSize:`sm`,children:n(r?`profile.passkey.manage`:`profile.passkey.add`)}),active:r,icon:j,status:r?n(`profile.passkey.status.enabled`,{count:e}):n(`profile.passkey.status.disabled`),title:n(`profile.passkey.title`)})}function Ae({hasPassword:e,hasLinkedOAuth:t,isConfigManaged:n,hasSecondFactorOnly:r,onOpenModal:i}){let{t:a}=s();return(0,Z.jsx)(Q,{actions:n?void 0:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-change`,intent:`primary`,onClick:()=>i(`change`),type:`button`,uiSize:`sm`,children:a(`profile.password.change`)}),t?(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-remove`,intent:`danger`,onClick:()=>i(`remove`),type:`button`,uiSize:`sm`,children:a(`profile.password.remove`)}):null,!t&&r&&(0,Z.jsxs)(v.Root,{children:[(0,Z.jsx)(v.Trigger,{render:(0,Z.jsx)(C,{appearance:`ghost`,disabled:!0,type:`button`,uiSize:`sm`,children:a(`profile.password.remove`)})}),(0,Z.jsx)(v.Portal,{children:(0,Z.jsx)(v.Positioner,{children:(0,Z.jsx)(v.Popup,{className:`max-w-tinyrack-measure-lg rounded-tinyrack-md border border-tinyrack-border bg-tinyrack-surface p-tinyrack-md text-tinyrack-text text-tinyrack-xs shadow-tinyrack-overlay`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-tinyrack-sm`,children:[(0,Z.jsx)(E,{"aria-hidden":!0,className:`size-tinyrack-lg shrink-0 text-tinyrack-warning-foreground`}),(0,Z.jsx)(p,{variant:`caption`,children:a(`profile.password.removeDisabledReason`)})]})})})})]})]}):(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-set`,intent:`primary`,onClick:()=>i(`set`),type:`button`,uiSize:`sm`,children:a(`profile.password.set`)}),active:e,icon:M,note:n?(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-xs`,children:[(0,Z.jsx)(te,{"aria-hidden":!0,className:`size-tinyrack-md shrink-0`}),(0,Z.jsx)(p,{as:`span`,color:`muted`,variant:`caption`,children:a(`profile.password.configManaged`)})]}):void 0,status:a(e?`profile.password.status.set`:`profile.password.status.notSet`),title:a(`profile.password.title`)})}function je({totpEnabled:e,recoveryCodesMissing:t,onOpenModal:n}){let{t:r}=s();return(0,Z.jsx)(Q,{actions:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-regenerate`,intent:`primary`,onClick:()=>n(`regenerate`),type:`button`,uiSize:`sm`,children:r(`profile.totp.regenerate`)}),(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-disable`,intent:`danger`,onClick:()=>n(`disable`),type:`button`,uiSize:`sm`,children:r(`profile.totp.disable`)})]}):(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-enable`,intent:`primary`,onClick:()=>n(`setup`),type:`button`,uiSize:`sm`,children:r(`profile.totp.enable`)}),active:e,icon:L,status:r(e?t?`profile.totp.status.recoveryCodesMissing`:`profile.totp.status.enabled`:`profile.totp.status.disabled`),title:r(`profile.totp.title`)})}var Me={error:T,warning:z,info:E};function $({variant:e,children:t}){return(0,Z.jsx)(B,{"data-testid":`alert-banner-${e}`,icon:Me[e],type:e,children:t})}function Ne({isOpen:e,onClose:t,providerName:n,isPending:r,onConfirm:i}){let{t:a}=s(),[o,c]=(0,X.useState)(null),l=()=>{r||(c(null),t())};return(0,Z.jsx)(H,{description:a(`profile.linkedAccounts.unlinkModal.description`,{provider:n}),icon:xe,isOpen:e,onClose:l,preventClose:r,title:a(`profile.linkedAccounts.unlinkModal.title`),variant:`destructive`,children:(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,children:[(0,Z.jsx)($,{variant:`warning`,children:a(`profile.linkedAccounts.unlinkModal.warning`,{provider:n})}),o&&(0,Z.jsx)($,{variant:`error`,children:o}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`unlink-oauth-cancel`,disabled:r,intent:`neutral`,onClick:l,type:`button`,uiSize:`sm`,children:a(`profile.linkedAccounts.unlinkModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`unlink-oauth-unlink`,disabled:r,intent:`danger`,loading:r,loadingLabel:a(`profile.linkedAccounts.unlinking`),onClick:async()=>{c(null);try{await i(),l()}catch{c(a(`profile.linkedAccounts.unlinkError`))}},type:`button`,uiSize:`sm`,children:a(`profile.linkedAccounts.unlink`)})]})]})})}function Pe({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(p,{className:`shrink-0`,color:`muted`,variant:`caption`,children:e}),(0,Z.jsx)(p,{truncate:!0,variant:`bodySm`,weight:`medium`,children:t})]})}function Fe({user:e}){let{t}=s();return(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:t(`profile.account.title`)}),(0,Z.jsx)(w.Description,{children:t(`profile.account.description`)})]}),(0,Z.jsxs)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:[(0,Z.jsx)(Pe,{label:t(`profile.id.label`),value:e.sub}),(0,Z.jsx)(Pe,{label:t(`profile.email.label`),value:e.email})]})]})}function Ie({children:e,headerActions:t}){return(0,Z.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-tinyrack-surface`,children:[(0,Z.jsx)(y,{}),(0,Z.jsx)(x,{actions:t,brand:!0}),(0,Z.jsx)(`main`,{className:`flex flex-1 justify-center px-tinyrack-lg py-tinyrack-xl`,children:(0,Z.jsx)(`div`,{className:`auth-enter flex w-full max-w-tinyrack-overlay-width-md flex-col gap-tinyrack-xl`,children:e})}),(0,Z.jsx)(b,{})]})}var Le=g({mutationFn:async e=>{let t=await u.api.user.password.$post({json:e});return l(t)}}),Re=g({mutationFn:async e=>{let t=await u.api.user.password.$put({json:e});return l(t)}}),ze=g({mutationFn:async e=>{let t=await u.api.user.password.$delete({json:e});return l(t)}});function Be({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),{data:i}=f(N),a=i.auth.password.policy,l=(0,X.useMemo)(()=>q({currentPassword:J().min(1,n(`validation.password.required`)),newPassword:J().min(a.min_length,n(`validation.password.min`,{count:a.min_length})).max(a.max_length,n(`validation.password.max`,{count:a.max_length})),confirmPassword:J()}).refine(e=>e.newPassword===e.confirmPassword,{message:n(`validation.confirmPassword.mismatch`),path:[`confirmPassword`]}),[a.max_length,a.min_length,n]),u=W({resolver:G(l),defaultValues:{currentPassword:``,newPassword:``,confirmPassword:``}}),d=m({...Re,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),p()}}),p=()=>{u.reset(),t()},h=u.handleSubmit(async e=>{try{await d.mutateAsync({current_password:e.currentPassword,new_password:e.newPassword})}catch(e){e instanceof c&&e.code===`INVALID_CURRENT_PASSWORD`?u.setError(`currentPassword`,{message:n(`profile.password.changeModal.invalidCurrent`)}):u.setError(`root`,{message:n(`profile.password.changeModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.changeModal.description`),icon:M,isOpen:e,onClose:p,title:n(`profile.password.changeModal.title`),children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:h,children:[(0,Z.jsx)(A,{error:u.formState.errors.currentPassword,errorTestId:`change-password-error-currentPassword`,id:`current-password`,label:n(`profile.password.changeModal.currentPassword`),placeholder:n(`profile.password.changeModal.currentPasswordPlaceholder`),...u.register(`currentPassword`),type:`password`}),(0,Z.jsx)(A,{error:u.formState.errors.newPassword,errorTestId:`change-password-error-newPassword`,id:`new-password-change`,label:n(`profile.password.changeModal.newPassword`),placeholder:n(`profile.password.changeModal.newPasswordPlaceholder`),...u.register(`newPassword`),type:`password`}),(0,Z.jsx)(A,{error:u.formState.errors.confirmPassword,errorTestId:`change-password-error-confirmPassword`,id:`confirm-password-change`,label:n(`profile.password.changeModal.confirmPassword`),placeholder:n(`profile.password.changeModal.confirmPasswordPlaceholder`),...u.register(`confirmPassword`),type:`password`}),u.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:u.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`change-password-cancel`,disabled:d.isPending,intent:`neutral`,onClick:p,type:`button`,uiSize:`sm`,children:n(`profile.password.changeModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`change-password-submit`,disabled:d.isPending,intent:`primary`,loading:d.isPending,loadingLabel:n(`profile.password.changeModal.submitting`),type:`submit`,uiSize:`sm`,children:d.isPending?void 0:n(`profile.password.changeModal.submit`)})]})]})})}var Ve=g({mutationFn:async()=>{let e=await u.api.user.$delete();return l(e)}});function He({isOpen:e,onClose:t,retentionDays:n}){let{t:i}=s(),a=r(),c=o(),l=(0,X.useMemo)(()=>q({confirmation:J().refine(e=>e.toLowerCase()===i(`profile.deleteAccount.modal.confirmPlaceholder`).toLowerCase(),{message:i(`validation.confirmText.mismatch`)})}),[i]),u=W({resolver:G(l),defaultValues:{confirmation:``}}),d=m({...Ve,onSuccess:async()=>{c.setQueryData(Y.queryKey,{user:null}),await se(),a(`/login`)}}),f=()=>{d.isPending||(u.reset(),t())},h=u.handleSubmit(async()=>{try{await d.mutateAsync()}catch{u.setError(`root`,{message:i(`profile.deleteAccount.error`)})}});return(0,Z.jsx)(H,{icon:R,isOpen:e,onClose:f,preventClose:d.isPending,title:i(`profile.deleteAccount.modal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:h,children:[(0,Z.jsxs)($,{variant:`error`,children:[(0,Z.jsx)(p,{as:`span`,variant:`bodySm`,children:i(`profile.deleteAccount.modal.description`,{days:n})}),(0,Z.jsx)(`br`,{}),(0,Z.jsx)(p,{as:`span`,className:`opacity-tinyrack-hover`,variant:`caption`,children:i(`profile.deleteAccount.modal.warning`)})]}),(0,Z.jsx)(A,{autoComplete:`off`,error:u.formState.errors.confirmation,errorTestId:`delete-account-error`,id:`delete-confirmation`,label:i(`profile.deleteAccount.modal.confirmLabel`),placeholder:i(`profile.deleteAccount.modal.confirmPlaceholder`),...u.register(`confirmation`),type:`text`}),u.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:u.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`delete-account-cancel`,disabled:d.isPending,intent:`neutral`,onClick:f,type:`button`,uiSize:`sm`,children:i(`profile.deleteAccount.modal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`delete-account-submit`,disabled:d.isPending,intent:`danger`,loading:d.isPending,loadingLabel:i(`profile.deleteAccount.modal.confirming`),type:`submit`,uiSize:`sm`,children:d.isPending?void 0:i(`profile.deleteAccount.modal.confirm`)})]})]})})}function Ue({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),i=(0,X.useMemo)(()=>q({code:J().length(6,n(`validation.totp.length`)).regex(/^\d{6}$/,n(`validation.totp.digits`))}),[n]),a=W({resolver:G(i),defaultValues:{code:``}}),l=m({...ce,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),u()}}),u=()=>{a.reset(),t()},d=a.handleSubmit(async e=>{try{await l.mutateAsync({code:e.code})}catch(e){if(e instanceof c&&e.code===`CANNOT_REMOVE_LAST_SECOND_FACTOR`){a.setError(`code`,{message:n(`profile.totp.disableModal.cannotRemoveLastSecondFactor`)});return}a.setError(`code`,{message:n(`profile.totp.disableModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.totp.disableModal.description`),icon:L,isOpen:e,onClose:u,title:n(`profile.totp.disableModal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:d,children:[(0,Z.jsx)($,{variant:`warning`,children:n(`profile.totp.disableModal.warning`)}),(0,Z.jsx)(A,{autoComplete:`one-time-code`,error:a.formState.errors.code,errorTestId:`disable-totp-error`,id:`disable-totp-code`,inputMode:`numeric`,label:n(`profile.totp.disableModal.codeLabel`),maxLength:6,pattern:`[0-9]*`,placeholder:`000000`,...a.register(`code`),type:`text`}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`disable-totp-cancel`,disabled:l.isPending,intent:`neutral`,onClick:u,type:`button`,uiSize:`sm`,children:n(`profile.totp.disableModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`disable-totp-submit`,disabled:l.isPending,intent:`danger`,loading:l.isPending,loadingLabel:n(`profile.totp.disableModal.disabling`),type:`submit`,uiSize:`sm`,children:l.isPending?void 0:n(`profile.totp.disableModal.disable`)})]})]})})}function We({isOpen:e,onClose:t,onAddNew:n}){let{t:r}=s(),i=o(),[a,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[f,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),{data:y,isLoading:b}=h({...me,enabled:e}),x=m({...pe,onSuccess:()=>{i.invalidateQueries({queryKey:P.passkeys()}),i.invalidateQueries({queryKey:Y.queryKey})},onSettled:()=>{d(null)}}),w=(0,X.useCallback)(()=>{l(null),d(null),g(null),v(null),t()},[t]),T=e=>{g(e.id),v(null)},E=()=>{g(null),v(null)},D=async e=>{d(e.id),g(null);try{await x.mutateAsync({id:e.id})}catch(e){if(e instanceof c&&e.code===`CANNOT_REMOVE_LAST_SECOND_FACTOR`){v(r(`profile.passkey.manageModal.cannotRemoveLastSecondFactor`));return}v(r(`profile.passkey.manageModal.deleteError`))}},ee=e=>new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}),O=y?.passkeys||[];return(0,Z.jsxs)(H,{icon:j,isOpen:e,onClose:w,size:`lg`,title:r(`profile.passkey.manageModal.title`),children:[(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-sm`,children:[_&&(0,Z.jsx)($,{variant:`error`,children:_}),b&&(0,Z.jsx)(`div`,{className:`flex justify-center py-tinyrack-xl`,children:(0,Z.jsx)(S,{uiSize:`md`})}),!b&&O.length===0&&(0,Z.jsx)(p,{align:`center`,className:`py-tinyrack-xl`,color:`muted`,"data-testid":`passkeys-empty`,variant:`bodySm`,children:r(`profile.passkey.manageModal.noPasskeys`)}),!b&&O.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:O.map(e=>(0,Z.jsx)(Ge,{formatDate:ee,isConfirmingDelete:f===e.id,isDeleting:u===e.id,isEditing:a?.id===e.id,onCancelDelete:E,onCancelEdit:()=>l(null),onConfirmDelete:()=>D(e),onEdit:()=>l(e),onRequestDelete:()=>T(e),passkey:e},e.id))})]}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`manage-passkeys-close`,intent:`neutral`,onClick:w,type:`button`,uiSize:`sm`,children:r(`profile.passkey.manageModal.close`)}),(0,Z.jsx)(C,{"data-testid":`manage-passkeys-add-new`,intent:`primary`,onClick:()=>{w(),n()},type:`button`,uiSize:`sm`,children:r(`profile.passkey.manageModal.addNew`)})]})]})}function Ge({passkey:e,isDeleting:t,isEditing:n,isConfirmingDelete:r,onEdit:i,onCancelEdit:a,onRequestDelete:c,onConfirmDelete:l,onCancelDelete:u,formatDate:d}){let{t:f}=s(),h=o(),g=(0,X.useMemo)(()=>q({name:J().min(1,f(`validation.passkey.name.required`)).max(100,f(`validation.passkey.name.max`))}),[f]),_=W({resolver:G(g),defaultValues:{name:e.name||``}}),v=m({...de,onSuccess:()=>{h.invalidateQueries({queryKey:P.passkeys()}),a()}}),y=_.handleSubmit(async t=>{try{await v.mutateAsync({id:e.id,name:t.name})}catch{_.setError(`name`,{message:f(`profile.passkey.manageModal.renameError`)})}});return n?(0,Z.jsxs)(K,{className:`flex flex-col gap-tinyrack-xs rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-sm`,onSubmit:y,children:[(0,Z.jsx)(A,{"data-testid":`passkey-rename-input`,error:_.formState.errors.name,errorTestId:`passkey-rename-error`,hideLabel:!0,label:f(`profile.passkey.manageModal.nameLabel`),placeholder:f(`profile.passkey.manageModal.namePlaceholder`),..._.register(`name`),type:`text`}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,disabled:v.isPending,onClick:()=>{_.reset(),a()},type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.cancelEdit`)}),(0,Z.jsx)(C,{disabled:v.isPending,intent:`primary`,type:`submit`,uiSize:`sm`,children:v.isPending?f(`profile.passkey.manageModal.saving`):f(`profile.passkey.manageModal.save`)})]})]}):r?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-tinyrack-md border border-tinyrack-danger-border bg-tinyrack-danger-surface p-tinyrack-sm text-tinyrack-danger-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,Z.jsx)(R,{className:`size-tinyrack-lg`}),(0,Z.jsx)(p,{color:`danger`,variant:`caption`,children:f(`profile.passkey.manageModal.deleteConfirmInline`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,onClick:u,type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.cancelEdit`)}),(0,Z.jsx)(C,{intent:`danger`,onClick:l,type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.delete`)})]})]}):(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-sm`,"data-testid":`passkey-item`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[e.device_type===`multiDevice`?(0,Z.jsx)(ye,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}):(0,Z.jsx)(Te,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(p,{variant:`caption`,weight:`medium`,children:e.name||f(`profile.passkey.manageModal.unnamedPasskey`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-xs`,children:[(0,Z.jsx)(p,{color:`muted`,variant:`caption`,children:f(`profile.passkey.manageModal.createdAt`,{date:d(e.created_at)})}),e.backed_up&&(0,Z.jsx)(ue,{uiSize:`md`,variant:`success`,children:f(`profile.passkey.manageModal.backedUp`)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":f(`profile.passkey.manageModal.rename`),onClick:i,type:`button`,uiSize:`sm`,children:(0,Z.jsx)(Ce,{className:`size-tinyrack-lg`})}),(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":f(`profile.passkey.manageModal.delete`),disabled:t,intent:`danger`,loading:t,onClick:c,type:`button`,uiSize:`sm`,children:t?void 0:(0,Z.jsx)(R,{className:`size-tinyrack-lg`})})]})]})}function Ke({isOpen:e,onClose:t}){let{t:n}=s(),i=r(),a=o(),{data:l}=f(N),[u,d]=(0,X.useState)(`verify`),[p,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),v=m({...le,onSuccess:async e=>{h(e),d(`recovery`),await a.invalidateQueries({queryKey:Y.queryKey})}}),y=(0,X.useCallback)(()=>{d(`verify`),h(null),_(null),v.reset()},[v]),b=(0,X.useCallback)(()=>{y(),t()},[t,y]),x=(0,X.useCallback)(async e=>{_(null);try{await v.mutateAsync({code:e})}catch(e){if(e instanceof c){if(e.code===`INVALID_TOTP_CODE`)throw e;if(e.code===`UNAUTHORIZED`){a.setQueryData(Y.queryKey,{user:null}),await se(),i(`/login`);return}if(e.code===`TOTP_NOT_ENABLED`||e.code===`VALIDATION_ERROR`){await a.invalidateQueries({queryKey:Y.queryKey}),b();return}}_(n(`profile.totp.regenerateModal.unexpectedError`))}},[b,v,i,a,n]);return l.auth.password.totp.enabled?(0,Z.jsx)(H,{description:n(u===`verify`?`profile.totp.regenerateModal.description`:`profile.totp.regenerateModal.recoveryDescription`),icon:L,isOpen:e,onClose:b,preventClose:u===`recovery`,size:`sm`,title:n(u===`verify`?`profile.totp.regenerateModal.title`:`profile.totp.regenerateModal.recoveryTitle`),children:u===`verify`?(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg`,children:[g&&(0,Z.jsx)(`div`,{className:`mb-tinyrack-md`,children:(0,Z.jsx)($,{variant:`error`,children:g})}),(0,Z.jsx)(O,{invalidMessage:n(`profile.totp.regenerateModal.error`),isPending:v.isPending,onSubmit:x,pendingText:n(`profile.totp.regenerateModal.submitting`),submitLabel:n(`profile.totp.regenerateModal.submit`)})]}):(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(D,{onConfirm:b,recoveryCodes:p?.recovery_codes??[]})})}):null}function qe({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),i=(0,X.useMemo)(()=>q({currentPassword:J().min(1,n(`validation.password.required`))}),[n]),a=W({resolver:G(i),defaultValues:{currentPassword:``}}),l=m({...ze,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),u()}}),u=()=>{a.reset(),t()},d=a.handleSubmit(async e=>{try{await l.mutateAsync({current_password:e.currentPassword})}catch(e){if(e instanceof c){if(e.code===`INVALID_CURRENT_PASSWORD`){a.setError(`currentPassword`,{message:n(`profile.password.removeModal.invalidCurrent`)});return}if(e.code===`CANNOT_REMOVE_LAST_AUTH_METHOD`){a.setError(`root`,{message:n(`profile.password.removeModal.noOAuth`)});return}if(e.code===`CANNOT_REMOVE_PASSWORD_WITH_SECOND_FACTOR_ONLY`){a.setError(`root`,{message:n(`profile.password.removeModal.noOAuthWith2FA`)});return}}a.setError(`root`,{message:n(`profile.password.removeModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.removeModal.description`),icon:M,isOpen:e,onClose:u,title:n(`profile.password.removeModal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:d,children:[(0,Z.jsx)(A,{error:a.formState.errors.currentPassword,errorTestId:`remove-password-error`,id:`current-password-remove`,label:n(`profile.password.removeModal.currentPassword`),placeholder:n(`profile.password.removeModal.currentPasswordPlaceholder`),...a.register(`currentPassword`),type:`password`}),a.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:a.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`remove-password-cancel`,disabled:l.isPending,intent:`neutral`,onClick:u,type:`button`,uiSize:`sm`,children:n(`profile.password.removeModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`remove-password-submit`,disabled:l.isPending,intent:`danger`,loading:l.isPending,loadingLabel:n(`profile.password.removeModal.submitting`),type:`submit`,uiSize:`sm`,children:l.isPending?void 0:n(`profile.password.removeModal.submit`)})]})]})})}function Je({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),{data:i}=f(N),a=i.auth.password.policy,c=(0,X.useMemo)(()=>q({password:J().min(a.min_length,n(`validation.password.min`,{count:a.min_length})).max(a.max_length,n(`validation.password.max`,{count:a.max_length})),confirmPassword:J()}).refine(e=>e.password===e.confirmPassword,{message:n(`validation.confirmPassword.mismatch`),path:[`confirmPassword`]}),[a.max_length,a.min_length,n]),l=W({resolver:G(c),defaultValues:{password:``,confirmPassword:``}}),u=m({...Le,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),d()}}),d=()=>{l.reset(),t()},p=l.handleSubmit(async e=>{try{await u.mutateAsync({password:e.password})}catch{l.setError(`root`,{message:n(`profile.password.setModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.setModal.description`),icon:M,isOpen:e,onClose:d,title:n(`profile.password.setModal.title`),children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:p,children:[(0,Z.jsx)(A,{error:l.formState.errors.password,errorTestId:`set-password-error-password`,id:`new-password`,label:n(`profile.password.setModal.newPassword`),placeholder:n(`profile.password.setModal.newPasswordPlaceholder`),...l.register(`password`),type:`password`}),(0,Z.jsx)(A,{error:l.formState.errors.confirmPassword,errorTestId:`set-password-error-confirmPassword`,id:`confirm-password`,label:n(`profile.password.setModal.confirmPassword`),placeholder:n(`profile.password.setModal.confirmPasswordPlaceholder`),...l.register(`confirmPassword`),type:`password`}),l.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:l.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`set-password-cancel`,disabled:u.isPending,intent:`neutral`,onClick:d,type:`button`,uiSize:`sm`,children:n(`profile.password.setModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`set-password-submit`,disabled:u.isPending,intent:`primary`,loading:u.isPending,loadingLabel:n(`profile.password.setModal.submitting`),type:`submit`,uiSize:`sm`,children:u.isPending?void 0:n(`profile.password.setModal.submit`)})]})]})})}function Ye({isOpen:e,onClose:t,isRequired:n=!1,canSwitchToTotp:r=!1,onSwitchToTotp:i}){let{t:a}=s(),c=o(),[l,u]=(0,X.useState)(`name`),[d,f]=(0,X.useState)(null),h=(0,X.useMemo)(()=>q({name:J().max(100,a(`validation.passkey.name.max`)).optional().transform(e=>e?.trim()||void 0)}),[a]),g=W({resolver:G(h),defaultValues:{name:``}}),_=m({...fe,onSuccess:()=>{c.invalidateQueries({queryKey:P.passkeys()}),c.invalidateQueries({queryKey:Y.queryKey}),v()},onError:e=>{u(`name`),e.name===`NotAllowedError`?f(a(`profile.passkey.setupModal.cancelled`)):f(a(`profile.passkey.setupModal.error`))}}),v=(0,X.useCallback)(()=>{g.reset(),u(`name`),f(null),t()},[g,t]),y=g.handleSubmit(async e=>{u(`register`),f(null);try{await _.mutateAsync({name:e.name})}catch{}}),b=_.isPending;return(0,Z.jsxs)(H,{description:n?a(`profile.passkey.setupModal.requiredDescription`):void 0,icon:j,isOpen:e,onClose:v,preventClose:n,size:`sm`,title:a(`profile.passkey.setupModal.title`),children:[l===`name`&&(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:y,children:[(0,Z.jsx)(p,{as:`p`,color:`muted`,variant:`caption`,children:a(`profile.passkey.setupModal.description`)}),d&&(0,Z.jsx)($,{variant:`error`,children:d}),(0,Z.jsx)(A,{error:g.formState.errors.name,errorTestId:`setup-passkey-error`,hint:a(`profile.passkey.setupModal.nameHint`),id:`passkey-name`,label:a(`profile.passkey.setupModal.nameLabel`),placeholder:a(`profile.passkey.setupModal.namePlaceholder`),...g.register(`name`),type:`text`}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`setup-passkey-cancel`,intent:`neutral`,onClick:v,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`setup-passkey-continue`,intent:`primary`,type:`submit`,uiSize:`sm`,children:a(`profile.passkey.setupModal.continue`)})]}),r&&i&&(0,Z.jsx)(p,{align:`center`,as:`p`,className:`mt-tinyrack-sm`,variant:`caption`,children:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:i,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.switchToTotp`)})})]}),l===`register`&&(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-md py-tinyrack-xl`,"data-testid":`setup-passkey-loading`,children:[(0,Z.jsx)(S,{uiSize:`md`}),(0,Z.jsx)(p,{align:`center`,as:`p`,color:`muted`,variant:`caption`,children:a(`profile.passkey.setupModal.waitingForDevice`)})]}),(0,Z.jsx)(V,{children:(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`setup-passkey-cancel`,disabled:b,intent:`neutral`,onClick:v,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.cancel`)})})]})]})}function Xe({isOpen:e,onClose:t,isRequired:n=!1,canSwitchToPasskey:r=!1,onSwitchToPasskey:i}){let{t:a}=s(),{step:o,setupData:c,recoveryCodes:l,isSetupPending:u,isVerifyPending:d,isConfirmPending:f,startSetup:m,verify:h,goToVerify:g,goToQr:_,confirmRecoveryCodes:v,reset:y}=k({autoStart:!1,onConfirmSuccess:()=>{y(),t()}}),b=(0,X.useCallback)(()=>{y(),t()},[t,y]),x=(0,X.useCallback)(()=>{!c&&!u&&m()},[c,u,m]);e&&!c&&!u&&o!==`error`&&x();let w=(0,X.useCallback)(async e=>{await h(e)},[h]),T=a(o===`recovery`?`setupTotp.recoveryCodes.title`:`profile.totp.setupModal.title`);return(0,Z.jsxs)(H,{description:n?a(`profile.totp.setupModal.requiredDescription`):void 0,icon:L,isOpen:e,onClose:b,preventClose:n||o===`recovery`,size:`sm`,title:T,children:[u&&(0,Z.jsx)(`div`,{className:`flex justify-center py-tinyrack-xl`,"data-testid":`setup-totp-loading`,children:(0,Z.jsx)(S,{uiSize:`md`})}),o===`error`&&(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,children:[(0,Z.jsx)($,{variant:`error`,children:a(`profile.totp.setupModal.setupError`)}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,intent:`neutral`,onClick:b,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.cancel`)}),(0,Z.jsx)(C,{intent:`primary`,onClick:m,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.retry`)})]})]}),c&&o===`qr`&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(ee,{additionalActions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(V,{children:(0,Z.jsx)(C,{appearance:`outline`,intent:`neutral`,onClick:b,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.cancel`)})}),r&&i&&(0,Z.jsx)(p,{align:`center`,as:`p`,className:`mt-tinyrack-sm`,variant:`caption`,children:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:i,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.switchToPasskey`)})})]}),onNext:g,setupData:c})}),c&&o===`verify`&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(O,{isPending:d,onBack:_,onSubmit:w})}),o===`recovery`&&l.length>0&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(D,{isLoading:f,onConfirm:v,recoveryCodes:l})})]})}var Ze=(e=>d({queryKey:P.oauth.accounts(),queryFn:async()=>{let t=await e.api.user[`oauth-accounts`].$get();return l(t)}}))(u),Qe=g({mutationFn:async e=>{let t=await u.api.oauth[`:provider`].$delete({param:{provider:e}});return l(t)}});function $e(e,t=`login`,n){let r=new URLSearchParams({mode:t});return n&&r.set(`return_url`,n),`/api/oauth/${encodeURIComponent(e)}/authorize?${r.toString()}`}var et={access_denied:`oauth.error.accessDenied`,temporarily_unavailable:`oauth.error.temporarilyUnavailable`,server_error:`oauth.error.serverError`};function tt(e){return(0,Z.jsx)(U,{...e,onUnauthorized:()=>{he(`/login`)}})}function nt({search:e}){let{t}=s(),n=r(),i=o(),a=e.oauth_error,c=a?t(et[a]??`oauth.error.failed`):void 0,[l,u]=(0,X.useState)(null),[d,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,E]=(0,X.useState)(!1),{data:D}=f(Y),{data:ee}=f(Ze),{data:O}=f(N),k=m({...re,onSuccess:async()=>{i.setQueryData(Y.queryKey,{user:null}),await se(),n(`/login`)},onSettled:()=>{i.invalidateQueries({queryKey:Y.queryKey})}}),A=m({...Qe,onSuccess:()=>{i.invalidateQueries({queryKey:Ze.queryKey})},onSettled:()=>{u(null)}}),j=async()=>{d&&(u(d.id),await A.mutateAsync(d.id))};if(!D.user)return null;let M=D.user,P=ee.available_providers,F=P.some(e=>e.linked),I=M.managed_by===`config`,te=O.auth.password,L=O.auth.passkey,R=te.totp.enabled,z=L.enabled,ae=O.account_deletion.enabled,V=O.account_deletion.retention,H=(()=>{let e=V.match(/^(\d+)([dmy])$/);if(!e)return 30;let t=parseInt(e[1],10);switch(e[2]){case`d`:return t;case`m`:return t*30;case`y`:return t*365;default:return 30}})(),U=!I&&R,W=!I&&z,G=P.length>0;return(0,Z.jsxs)(Ie,{headerActions:(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":t(`profile.logout`),"data-testid":`profile-logout`,disabled:k.isPending,loading:k.isPending,onClick:()=>k.mutate(),type:`button`,uiSize:`sm`,children:k.isPending?void 0:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{"aria-hidden":!0,className:`size-tinyrack-lg`}),(0,Z.jsx)(p,{as:`span`,className:`hidden sm:inline`,variant:`bodySm`,children:t(`profile.logout`)})]})}),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-lg`,children:[(0,Z.jsx)(oe,{email:M.email,size:`lg`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(ie,{title:t(`profile.title`)}),(0,Z.jsx)(p,{as:`p`,color:`muted`,"data-testid":`profile-user-email`,truncate:!0,variant:`bodySm`,children:M.email})]})]}),c&&(0,Z.jsx)(B,{icon:T,type:`error`,children:c}),M&&(0,Z.jsx)(Fe,{user:M}),(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:t(`profile.security.title`)}),(0,Z.jsx)(w.Description,{children:t(`profile.security.description`)})]}),U&&M.totp_recovery_codes_missing&&(0,Z.jsx)(`div`,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,"data-testid":`profile-totp-recovery-warning`,children:(0,Z.jsx)(B,{icon:T,type:`warning`,children:t(`profile.totp.recoveryCodesMissing`)})}),(0,Z.jsxs)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:[(0,Z.jsx)(Ae,{hasLinkedOAuth:F,hasPassword:M.has_password,hasSecondFactorOnly:M.has_password&&!F&&(M.totp_registered||M.passkey_count>0),isConfigManaged:I,onOpenModal:_}),U&&(0,Z.jsx)(je,{onOpenModal:y,recoveryCodesMissing:M.totp_recovery_codes_missing,totpEnabled:M.totp_registered}),W&&(0,Z.jsx)(ke,{onOpenModal:x,passkeyCount:M.passkey_count})]})]}),G&&(0,Z.jsx)(Oe,{getAuthorizeUrl:$e,onUnlinkRequest:e=>h({id:e.id,name:e.display_name}),providers:P,unlinkingProvider:l}),(0,Z.jsx)(Ee,{isConfigManaged:I,isDeletionEnabled:ae,onDeleteClick:()=>E(!0)}),(0,Z.jsx)(Je,{isOpen:g===`set`,onClose:()=>_(null)}),(0,Z.jsx)(Be,{isOpen:g===`change`,onClose:()=>_(null)}),(0,Z.jsx)(qe,{isOpen:g===`remove`,onClose:()=>_(null)}),(0,Z.jsx)(Xe,{isOpen:v===`setup`,onClose:()=>y(null)}),(0,Z.jsx)(Ue,{isOpen:v===`disable`,onClose:()=>y(null)}),(0,Z.jsx)(Ke,{isOpen:v===`regenerate`,onClose:()=>y(null)}),(0,Z.jsx)(Ye,{isOpen:b===`setup`,onClose:()=>x(null)}),(0,Z.jsx)(We,{isOpen:b===`manage`,onAddNew:()=>x(`setup`),onClose:()=>x(null)}),(0,Z.jsx)(Ne,{isOpen:d!==null,isPending:A.isPending,onClose:()=>h(null),onConfirm:j,providerName:d?.name??``}),(0,Z.jsx)(He,{isOpen:S,onClose:()=>E(!1),retentionDays:H})]})}var rt=i(function({error:e}){return(0,Z.jsx)(_e,{component:tt,error:e})}),it=n(function({loaderData:e}){return(0,Z.jsx)(ge,{state:e.dehydratedState,children:(0,Z.jsx)(nt,{search:e.search})})});export{rt as ErrorBoundary,it as default};
|
|
1
|
+
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as s,i as c,n as l,t as u}from"./api-CfCwvXbU.js";import{n as d,r as f,t as p}from"./text-CBHShrvS.js";import{t as m}from"./useMutation-BkuKGzks.js";import{t as h}from"./useQuery-BLm0XsTI.js";import{t as g}from"./mutationOptions-Dfvzj6n2.js";import{V as _}from"./select-C_WHBpl_.js";import{a as v,i as y,r as b,t as x}from"./shell-header-bar-CjPlfRKT.js";import{i as S,r as C}from"./NullStore-UyCsFQfz.js";import{t as w}from"./card-BaQElRNE.js";import{t as T}from"./circle-alert-BZCKPkRn.js";import{a as E,i as D,n as ee,r as O,t as k}from"./use-totp-setup-Cwuds2tR.js";import{t as A}from"./auth-field-CDCz-y27.js";import{t as j}from"./fingerprint-pattern-AUfgwio5.js";import{t as M}from"./key-round-BlUAV-K9.js";import{n as N,r as P}from"./language-selector-CeLHnp1n.js";import{n as F,t as I}from"./provider-mark-CCOkSxh7.js";import{n as te,r as ne,t as re}from"./logout-DpMjBzc5.js";import{t as L}from"./shield-check-2DKLuF9J.js";import{t as R}from"./trash-C7RyeTUJ.js";import{t as z}from"./triangle-alert-B0lTzZDi.js";import{t as ie}from"./auth-page-header-C6Z6Air-.js";import{t as ae}from"./link-button-DGt9hwk7.js";import{t as B}from"./alert-DS8e0Gvg.js";import{n as V,t as H}from"./modal-BDu41alh.js";import{t as oe}from"./initial-avatar-ByHiX-IF.js";import{t as U}from"./route-error-fallback-CRL2Et8O.js";import{r as W,t as G}from"./standard-schema-kM5DbC12.js";import{r as K}from"./FieldItemContext-B3N2qWH8.js";import{a as q,s as J}from"./schemas-B87iTMww.js";import{n as Y,t as se}from"./promise-CepnkPDw.js";import{n as ce,r as le}from"./totp-4989Pb-o.js";import{t as ue}from"./badge-Cr0iG_iG.js";import{a as de,i as fe,n as pe,r as me}from"./passkey-Bkqvhjwb.js";import{t as he}from"./document-navigation-Cnp3Alf0.js";import{n as ge,t as _e}from"./route-module-2foR49uh.js";var ve={name:`cloud`,size:24,node:[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]};ve.node;var ye=_(ve),be={name:`link-2-off`,size:24,node:[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]};be.node;var xe=_(be),Se={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Se.node;var Ce=_(Se),we={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};we.node;var Te=_(we),X=e(t(),1),Z=a();function Ee({isConfigManaged:e,isDeletionEnabled:t,onDeleteClick:n}){let{t:r}=s();return t?(0,Z.jsxs)(w.Root,{className:`border-tinyrack-danger-border bg-tinyrack-danger-surface`,variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-danger-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,Z.jsx)(z,{"aria-hidden":!0,className:`size-tinyrack-lg text-tinyrack-danger-foreground`}),(0,Z.jsx)(w.Title,{className:`text-tinyrack-danger-foreground`,children:r(`profile.dangerZone.title`)})]}),(0,Z.jsx)(w.Description,{children:r(`profile.dangerZone.description`)})]}),(0,Z.jsx)(w.Content,{className:`px-tinyrack-lg py-tinyrack-md`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(p,{as:`p`,variant:`bodySm`,weight:`medium`,children:r(`profile.deleteAccount.title`)}),(0,Z.jsx)(p,{as:`p`,color:`muted`,variant:`caption`,children:r(e?`profile.deleteAccount.configManaged`:`profile.deleteAccount.description`)})]}),(0,Z.jsxs)(C,{appearance:`outline`,"data-testid":`profile-delete-account`,disabled:e,intent:`danger`,onClick:n,type:`button`,uiSize:`sm`,children:[(0,Z.jsx)(R,{"aria-hidden":!0,className:`size-tinyrack-lg`}),r(`profile.deleteAccount.button`)]})]})})]}):null}function De({providerId:e,iconUrl:t,className:n=`size-tinyrack-xl`}){return e===`google`||e===`github`||e===`apple`?(0,Z.jsx)(I,{"aria-hidden":!0,className:n,provider:e}):t?(0,Z.jsx)(`img`,{alt:``,className:n,src:t}):(0,Z.jsx)(F,{"aria-hidden":!0,className:n})}function Q({icon:e,active:t,title:n,status:r,note:i,actions:a}){let o;return o=(0,X.isValidElement)(e)?e:(0,Z.jsx)(e,{"aria-hidden":!0,className:`size-tinyrack-lg ${t?`text-tinyrack-success-foreground`:`text-tinyrack-text-muted`}`}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg p-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-tinyrack-md`,children:[(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-tinyrack-md ${t?`bg-tinyrack-success-surface`:`bg-tinyrack-surface-muted`}`,children:o}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(p,{variant:`bodySm`,weight:`medium`,children:n}),(0,Z.jsx)(p,{color:`muted`,variant:`caption`,children:r}),i]})]}),a&&(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-tinyrack-xs`,children:a})]})}function Oe({providers:e,unlinkingProvider:t,getAuthorizeUrl:n,onUnlinkRequest:r}){let{t:i}=s();return e.length===0?null:(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:i(`profile.linkedAccounts.title`)}),(0,Z.jsx)(w.Description,{children:i(`profile.linkedAccounts.description`)})]}),(0,Z.jsx)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:e.map(e=>(0,Z.jsx)(Q,{actions:e.linked?(0,Z.jsx)(C,{appearance:`ghost`,intent:`danger`,loading:t===e.id,loadingLabel:i(`profile.linkedAccounts.unlinking`),onClick:()=>r(e),type:`button`,uiSize:`sm`,children:t===e.id?void 0:i(`profile.linkedAccounts.unlink`)}):(0,Z.jsx)(ae,{appearance:`outline`,intent:`neutral`,render:(0,Z.jsx)(`a`,{href:n(e.id,`link`,`/profile`)}),uiSize:`sm`,children:i(`profile.linkedAccounts.link`)}),active:e.linked,icon:(0,Z.jsx)(De,{className:`size-tinyrack-lg`,iconUrl:e.icon_url,providerId:e.id}),status:e.linked?i(`profile.linkedAccounts.connected`):i(`profile.linkedAccounts.notConnected`),title:e.display_name},e.id))})]})}function ke({passkeyCount:e,onOpenModal:t}){let{t:n}=s(),r=e>0;return(0,Z.jsx)(Q,{actions:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:()=>t(r?`manage`:`setup`),type:`button`,uiSize:`sm`,children:n(r?`profile.passkey.manage`:`profile.passkey.add`)}),active:r,icon:j,status:r?n(`profile.passkey.status.enabled`,{count:e}):n(`profile.passkey.status.disabled`),title:n(`profile.passkey.title`)})}function Ae({hasPassword:e,hasLinkedOAuth:t,isConfigManaged:n,hasSecondFactorOnly:r,onOpenModal:i}){let{t:a}=s();return(0,Z.jsx)(Q,{actions:n?void 0:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-change`,intent:`primary`,onClick:()=>i(`change`),type:`button`,uiSize:`sm`,children:a(`profile.password.change`)}),t?(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-remove`,intent:`danger`,onClick:()=>i(`remove`),type:`button`,uiSize:`sm`,children:a(`profile.password.remove`)}):null,!t&&r&&(0,Z.jsxs)(v.Root,{children:[(0,Z.jsx)(v.Trigger,{render:(0,Z.jsx)(C,{appearance:`ghost`,disabled:!0,type:`button`,uiSize:`sm`,children:a(`profile.password.remove`)})}),(0,Z.jsx)(v.Portal,{children:(0,Z.jsx)(v.Positioner,{children:(0,Z.jsx)(v.Popup,{className:`max-w-tinyrack-measure-lg rounded-tinyrack-md border border-tinyrack-border bg-tinyrack-surface p-tinyrack-md text-tinyrack-text text-tinyrack-xs shadow-tinyrack-overlay`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-tinyrack-sm`,children:[(0,Z.jsx)(E,{"aria-hidden":!0,className:`size-tinyrack-lg shrink-0 text-tinyrack-warning-foreground`}),(0,Z.jsx)(p,{variant:`caption`,children:a(`profile.password.removeDisabledReason`)})]})})})})]})]}):(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-password-set`,intent:`primary`,onClick:()=>i(`set`),type:`button`,uiSize:`sm`,children:a(`profile.password.set`)}),active:e,icon:M,note:n?(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-xs`,children:[(0,Z.jsx)(te,{"aria-hidden":!0,className:`size-tinyrack-md shrink-0`}),(0,Z.jsx)(p,{as:`span`,color:`muted`,variant:`caption`,children:a(`profile.password.configManaged`)})]}):void 0,status:a(e?`profile.password.status.set`:`profile.password.status.notSet`),title:a(`profile.password.title`)})}function je({totpEnabled:e,recoveryCodesMissing:t,onOpenModal:n}){let{t:r}=s();return(0,Z.jsx)(Q,{actions:e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-regenerate`,intent:`primary`,onClick:()=>n(`regenerate`),type:`button`,uiSize:`sm`,children:r(`profile.totp.regenerate`)}),(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-disable`,intent:`danger`,onClick:()=>n(`disable`),type:`button`,uiSize:`sm`,children:r(`profile.totp.disable`)})]}):(0,Z.jsx)(C,{appearance:`ghost`,"data-testid":`profile-totp-enable`,intent:`primary`,onClick:()=>n(`setup`),type:`button`,uiSize:`sm`,children:r(`profile.totp.enable`)}),active:e,icon:L,status:r(e?t?`profile.totp.status.recoveryCodesMissing`:`profile.totp.status.enabled`:`profile.totp.status.disabled`),title:r(`profile.totp.title`)})}var Me={error:T,warning:z,info:E};function $({variant:e,children:t}){return(0,Z.jsx)(B,{"data-testid":`alert-banner-${e}`,icon:Me[e],type:e,children:t})}function Ne({isOpen:e,onClose:t,providerName:n,isPending:r,onConfirm:i}){let{t:a}=s(),[o,c]=(0,X.useState)(null),l=()=>{r||(c(null),t())};return(0,Z.jsx)(H,{description:a(`profile.linkedAccounts.unlinkModal.description`,{provider:n}),icon:xe,isOpen:e,onClose:l,preventClose:r,title:a(`profile.linkedAccounts.unlinkModal.title`),variant:`destructive`,children:(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,children:[(0,Z.jsx)($,{variant:`warning`,children:a(`profile.linkedAccounts.unlinkModal.warning`,{provider:n})}),o&&(0,Z.jsx)($,{variant:`error`,children:o}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`unlink-oauth-cancel`,disabled:r,intent:`neutral`,onClick:l,type:`button`,uiSize:`sm`,children:a(`profile.linkedAccounts.unlinkModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`unlink-oauth-unlink`,disabled:r,intent:`danger`,loading:r,loadingLabel:a(`profile.linkedAccounts.unlinking`),onClick:async()=>{c(null);try{await i(),l()}catch{c(a(`profile.linkedAccounts.unlinkError`))}},type:`button`,uiSize:`sm`,children:a(`profile.linkedAccounts.unlink`)})]})]})})}function Pe({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-tinyrack-lg px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(p,{className:`shrink-0`,color:`muted`,variant:`caption`,children:e}),(0,Z.jsx)(p,{truncate:!0,variant:`bodySm`,weight:`medium`,children:t})]})}function Fe({user:e}){let{t}=s();return(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:t(`profile.account.title`)}),(0,Z.jsx)(w.Description,{children:t(`profile.account.description`)})]}),(0,Z.jsxs)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:[(0,Z.jsx)(Pe,{label:t(`profile.id.label`),value:e.sub}),(0,Z.jsx)(Pe,{label:t(`profile.email.label`),value:e.email})]})]})}function Ie({children:e,headerActions:t}){return(0,Z.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-tinyrack-surface`,children:[(0,Z.jsx)(y,{}),(0,Z.jsx)(x,{actions:t,brand:!0}),(0,Z.jsx)(`main`,{className:`flex flex-1 justify-center px-tinyrack-lg py-tinyrack-xl`,children:(0,Z.jsx)(`div`,{className:`auth-enter flex w-full max-w-tinyrack-overlay-width-md flex-col gap-tinyrack-xl`,children:e})}),(0,Z.jsx)(b,{})]})}var Le=g({mutationFn:async e=>{let t=await u.api.user.password.$post({json:e});return l(t)}}),Re=g({mutationFn:async e=>{let t=await u.api.user.password.$put({json:e});return l(t)}}),ze=g({mutationFn:async e=>{let t=await u.api.user.password.$delete({json:e});return l(t)}});function Be({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),{data:i}=f(N),a=i.auth.password.policy,l=(0,X.useMemo)(()=>q({currentPassword:J().min(1,n(`validation.password.required`)),newPassword:J().min(a.min_length,n(`validation.password.min`,{count:a.min_length})).max(a.max_length,n(`validation.password.max`,{count:a.max_length})),confirmPassword:J()}).refine(e=>e.newPassword===e.confirmPassword,{message:n(`validation.confirmPassword.mismatch`),path:[`confirmPassword`]}),[a.max_length,a.min_length,n]),u=W({resolver:G(l),defaultValues:{currentPassword:``,newPassword:``,confirmPassword:``}}),d=m({...Re,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),p()}}),p=()=>{u.reset(),t()},h=u.handleSubmit(async e=>{try{await d.mutateAsync({current_password:e.currentPassword,new_password:e.newPassword})}catch(e){e instanceof c&&e.code===`INVALID_CURRENT_PASSWORD`?u.setError(`currentPassword`,{message:n(`profile.password.changeModal.invalidCurrent`)}):u.setError(`root`,{message:n(`profile.password.changeModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.changeModal.description`),icon:M,isOpen:e,onClose:p,title:n(`profile.password.changeModal.title`),children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:h,children:[(0,Z.jsx)(A,{error:u.formState.errors.currentPassword,errorTestId:`change-password-error-currentPassword`,id:`current-password`,label:n(`profile.password.changeModal.currentPassword`),placeholder:n(`profile.password.changeModal.currentPasswordPlaceholder`),...u.register(`currentPassword`),type:`password`}),(0,Z.jsx)(A,{error:u.formState.errors.newPassword,errorTestId:`change-password-error-newPassword`,id:`new-password-change`,label:n(`profile.password.changeModal.newPassword`),placeholder:n(`profile.password.changeModal.newPasswordPlaceholder`),...u.register(`newPassword`),type:`password`}),(0,Z.jsx)(A,{error:u.formState.errors.confirmPassword,errorTestId:`change-password-error-confirmPassword`,id:`confirm-password-change`,label:n(`profile.password.changeModal.confirmPassword`),placeholder:n(`profile.password.changeModal.confirmPasswordPlaceholder`),...u.register(`confirmPassword`),type:`password`}),u.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:u.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`change-password-cancel`,disabled:d.isPending,intent:`neutral`,onClick:p,type:`button`,uiSize:`sm`,children:n(`profile.password.changeModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`change-password-submit`,disabled:d.isPending,intent:`primary`,loading:d.isPending,loadingLabel:n(`profile.password.changeModal.submitting`),type:`submit`,uiSize:`sm`,children:d.isPending?void 0:n(`profile.password.changeModal.submit`)})]})]})})}var Ve=g({mutationFn:async()=>{let e=await u.api.user.$delete();return l(e)}});function He({isOpen:e,onClose:t,retentionDays:n}){let{t:i}=s(),a=r(),c=o(),l=(0,X.useMemo)(()=>q({confirmation:J().refine(e=>e.toLowerCase()===i(`profile.deleteAccount.modal.confirmPlaceholder`).toLowerCase(),{message:i(`validation.confirmText.mismatch`)})}),[i]),u=W({resolver:G(l),defaultValues:{confirmation:``}}),d=m({...Ve,onSuccess:async()=>{c.setQueryData(Y.queryKey,{user:null}),await se(),a(`/login`)}}),f=()=>{d.isPending||(u.reset(),t())},h=u.handleSubmit(async()=>{try{await d.mutateAsync()}catch{u.setError(`root`,{message:i(`profile.deleteAccount.error`)})}});return(0,Z.jsx)(H,{icon:R,isOpen:e,onClose:f,preventClose:d.isPending,title:i(`profile.deleteAccount.modal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:h,children:[(0,Z.jsxs)($,{variant:`error`,children:[(0,Z.jsx)(p,{as:`span`,variant:`bodySm`,children:i(`profile.deleteAccount.modal.description`,{days:n})}),(0,Z.jsx)(`br`,{}),(0,Z.jsx)(p,{as:`span`,className:`opacity-tinyrack-hover`,variant:`caption`,children:i(`profile.deleteAccount.modal.warning`)})]}),(0,Z.jsx)(A,{autoComplete:`off`,error:u.formState.errors.confirmation,errorTestId:`delete-account-error`,id:`delete-confirmation`,label:i(`profile.deleteAccount.modal.confirmLabel`),placeholder:i(`profile.deleteAccount.modal.confirmPlaceholder`),...u.register(`confirmation`),type:`text`}),u.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:u.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`delete-account-cancel`,disabled:d.isPending,intent:`neutral`,onClick:f,type:`button`,uiSize:`sm`,children:i(`profile.deleteAccount.modal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`delete-account-submit`,disabled:d.isPending,intent:`danger`,loading:d.isPending,loadingLabel:i(`profile.deleteAccount.modal.confirming`),type:`submit`,uiSize:`sm`,children:d.isPending?void 0:i(`profile.deleteAccount.modal.confirm`)})]})]})})}function Ue({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),i=(0,X.useMemo)(()=>q({code:J().length(6,n(`validation.totp.length`)).regex(/^\d{6}$/,n(`validation.totp.digits`))}),[n]),a=W({resolver:G(i),defaultValues:{code:``}}),l=m({...ce,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),u()}}),u=()=>{a.reset(),t()},d=a.handleSubmit(async e=>{try{await l.mutateAsync({code:e.code})}catch(e){if(e instanceof c&&e.code===`CANNOT_REMOVE_LAST_SECOND_FACTOR`){a.setError(`code`,{message:n(`profile.totp.disableModal.cannotRemoveLastSecondFactor`)});return}a.setError(`code`,{message:n(`profile.totp.disableModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.totp.disableModal.description`),icon:L,isOpen:e,onClose:u,title:n(`profile.totp.disableModal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:d,children:[(0,Z.jsx)($,{variant:`warning`,children:n(`profile.totp.disableModal.warning`)}),(0,Z.jsx)(A,{autoComplete:`one-time-code`,error:a.formState.errors.code,errorTestId:`disable-totp-error`,id:`disable-totp-code`,inputMode:`numeric`,label:n(`profile.totp.disableModal.codeLabel`),maxLength:6,pattern:`[0-9]*`,placeholder:`000000`,...a.register(`code`),type:`text`}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`disable-totp-cancel`,disabled:l.isPending,intent:`neutral`,onClick:u,type:`button`,uiSize:`sm`,children:n(`profile.totp.disableModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`disable-totp-submit`,disabled:l.isPending,intent:`danger`,loading:l.isPending,loadingLabel:n(`profile.totp.disableModal.disabling`),type:`submit`,uiSize:`sm`,children:l.isPending?void 0:n(`profile.totp.disableModal.disable`)})]})]})})}function We({isOpen:e,onClose:t,onAddNew:n}){let{t:r}=s(),i=o(),[a,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),[f,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(null),{data:y,isLoading:b}=h({...me,enabled:e}),x=m({...pe,onSuccess:()=>{i.invalidateQueries({queryKey:P.passkeys()}),i.invalidateQueries({queryKey:Y.queryKey})},onSettled:()=>{d(null)}}),w=(0,X.useCallback)(()=>{l(null),d(null),g(null),v(null),t()},[t]),T=e=>{g(e.id),v(null)},E=()=>{g(null),v(null)},D=async e=>{d(e.id),g(null);try{await x.mutateAsync({id:e.id})}catch(e){if(e instanceof c&&e.code===`CANNOT_REMOVE_LAST_SECOND_FACTOR`){v(r(`profile.passkey.manageModal.cannotRemoveLastSecondFactor`));return}v(r(`profile.passkey.manageModal.deleteError`))}},ee=e=>new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}),O=y?.passkeys||[];return(0,Z.jsxs)(H,{icon:j,isOpen:e,onClose:w,size:`lg`,title:r(`profile.passkey.manageModal.title`),children:[(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-sm`,children:[_&&(0,Z.jsx)($,{variant:`error`,children:_}),b&&(0,Z.jsx)(`div`,{className:`flex justify-center py-tinyrack-xl`,children:(0,Z.jsx)(S,{uiSize:`md`})}),!b&&O.length===0&&(0,Z.jsx)(p,{align:`center`,className:`py-tinyrack-xl`,color:`muted`,"data-testid":`passkeys-empty`,variant:`bodySm`,children:r(`profile.passkey.manageModal.noPasskeys`)}),!b&&O.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:O.map(e=>(0,Z.jsx)(Ge,{formatDate:ee,isConfirmingDelete:f===e.id,isDeleting:u===e.id,isEditing:a?.id===e.id,onCancelDelete:E,onCancelEdit:()=>l(null),onConfirmDelete:()=>D(e),onEdit:()=>l(e),onRequestDelete:()=>T(e),passkey:e},e.id))})]}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`manage-passkeys-close`,intent:`neutral`,onClick:w,type:`button`,uiSize:`sm`,children:r(`profile.passkey.manageModal.close`)}),(0,Z.jsx)(C,{"data-testid":`manage-passkeys-add-new`,intent:`primary`,onClick:()=>{w(),n()},type:`button`,uiSize:`sm`,children:r(`profile.passkey.manageModal.addNew`)})]})]})}function Ge({passkey:e,isDeleting:t,isEditing:n,isConfirmingDelete:r,onEdit:i,onCancelEdit:a,onRequestDelete:c,onConfirmDelete:l,onCancelDelete:u,formatDate:d}){let{t:f}=s(),h=o(),g=(0,X.useMemo)(()=>q({name:J().min(1,f(`validation.passkey.name.required`)).max(100,f(`validation.passkey.name.max`))}),[f]),_=W({resolver:G(g),defaultValues:{name:e.name||``}}),v=m({...de,onSuccess:()=>{h.invalidateQueries({queryKey:P.passkeys()}),a()}}),y=_.handleSubmit(async t=>{try{await v.mutateAsync({id:e.id,name:t.name})}catch{_.setError(`name`,{message:f(`profile.passkey.manageModal.renameError`)})}});return n?(0,Z.jsxs)(K,{className:`flex flex-col gap-tinyrack-xs rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-sm`,onSubmit:y,children:[(0,Z.jsx)(A,{"data-testid":`passkey-rename-input`,error:_.formState.errors.name,errorTestId:`passkey-rename-error`,hideLabel:!0,label:f(`profile.passkey.manageModal.nameLabel`),placeholder:f(`profile.passkey.manageModal.namePlaceholder`),..._.register(`name`),type:`text`}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,disabled:v.isPending,onClick:()=>{_.reset(),a()},type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.cancelEdit`)}),(0,Z.jsx)(C,{disabled:v.isPending,intent:`primary`,type:`submit`,uiSize:`sm`,children:v.isPending?f(`profile.passkey.manageModal.saving`):f(`profile.passkey.manageModal.save`)})]})]}):r?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-tinyrack-md border border-tinyrack-danger-border bg-tinyrack-danger-surface p-tinyrack-sm text-tinyrack-danger-foreground`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[(0,Z.jsx)(R,{className:`size-tinyrack-lg`}),(0,Z.jsx)(p,{color:`danger`,variant:`caption`,children:f(`profile.passkey.manageModal.deleteConfirmInline`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,onClick:u,type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.cancelEdit`)}),(0,Z.jsx)(C,{intent:`danger`,onClick:l,type:`button`,uiSize:`sm`,children:f(`profile.passkey.manageModal.delete`)})]})]}):(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-tinyrack-md bg-tinyrack-surface-muted p-tinyrack-sm`,"data-testid":`passkey-item`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-sm`,children:[e.device_type===`multiDevice`?(0,Z.jsx)(ye,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}):(0,Z.jsx)(Te,{className:`size-tinyrack-lg text-tinyrack-primary-foreground`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(p,{variant:`caption`,weight:`medium`,children:e.name||f(`profile.passkey.manageModal.unnamedPasskey`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-xs`,children:[(0,Z.jsx)(p,{color:`muted`,variant:`caption`,children:f(`profile.passkey.manageModal.createdAt`,{date:d(e.created_at)})}),e.backed_up&&(0,Z.jsx)(ue,{uiSize:`md`,variant:`success`,children:f(`profile.passkey.manageModal.backedUp`)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-tinyrack-xs`,children:[(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":f(`profile.passkey.manageModal.rename`),onClick:i,type:`button`,uiSize:`sm`,children:(0,Z.jsx)(Ce,{className:`size-tinyrack-lg`})}),(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":f(`profile.passkey.manageModal.delete`),disabled:t,intent:`danger`,loading:t,onClick:c,type:`button`,uiSize:`sm`,children:t?void 0:(0,Z.jsx)(R,{className:`size-tinyrack-lg`})})]})]})}function Ke({isOpen:e,onClose:t}){let{t:n}=s(),i=r(),a=o(),{data:l}=f(N),[u,d]=(0,X.useState)(`verify`),[p,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),v=m({...le,onSuccess:async e=>{h(e),d(`recovery`),await a.invalidateQueries({queryKey:Y.queryKey})}}),y=(0,X.useCallback)(()=>{d(`verify`),h(null),_(null),v.reset()},[v]),b=(0,X.useCallback)(()=>{y(),t()},[t,y]),x=(0,X.useCallback)(async e=>{_(null);try{await v.mutateAsync({code:e})}catch(e){if(e instanceof c){if(e.code===`INVALID_TOTP_CODE`)throw e;if(e.code===`UNAUTHORIZED`){a.setQueryData(Y.queryKey,{user:null}),await se(),i(`/login`);return}if(e.code===`TOTP_NOT_ENABLED`||e.code===`VALIDATION_ERROR`){await a.invalidateQueries({queryKey:Y.queryKey}),b();return}}_(n(`profile.totp.regenerateModal.unexpectedError`))}},[b,v,i,a,n]);return l.auth.password.totp.enabled?(0,Z.jsx)(H,{description:n(u===`verify`?`profile.totp.regenerateModal.description`:`profile.totp.regenerateModal.recoveryDescription`),icon:L,isOpen:e,onClose:b,preventClose:u===`recovery`,size:`sm`,title:n(u===`verify`?`profile.totp.regenerateModal.title`:`profile.totp.regenerateModal.recoveryTitle`),children:u===`verify`?(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg`,children:[g&&(0,Z.jsx)(`div`,{className:`mb-tinyrack-md`,children:(0,Z.jsx)($,{variant:`error`,children:g})}),(0,Z.jsx)(O,{invalidMessage:n(`profile.totp.regenerateModal.error`),isPending:v.isPending,onSubmit:x,pendingText:n(`profile.totp.regenerateModal.submitting`),submitLabel:n(`profile.totp.regenerateModal.submit`)})]}):(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(D,{onConfirm:b,recoveryCodes:p?.recovery_codes??[]})})}):null}function qe({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),i=(0,X.useMemo)(()=>q({currentPassword:J().min(1,n(`validation.password.required`))}),[n]),a=W({resolver:G(i),defaultValues:{currentPassword:``}}),l=m({...ze,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),u()}}),u=()=>{a.reset(),t()},d=a.handleSubmit(async e=>{try{await l.mutateAsync({current_password:e.currentPassword})}catch(e){if(e instanceof c){if(e.code===`INVALID_CURRENT_PASSWORD`){a.setError(`currentPassword`,{message:n(`profile.password.removeModal.invalidCurrent`)});return}if(e.code===`CANNOT_REMOVE_LAST_AUTH_METHOD`){a.setError(`root`,{message:n(`profile.password.removeModal.noOAuth`)});return}if(e.code===`CANNOT_REMOVE_PASSWORD_WITH_SECOND_FACTOR_ONLY`){a.setError(`root`,{message:n(`profile.password.removeModal.noOAuthWith2FA`)});return}}a.setError(`root`,{message:n(`profile.password.removeModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.removeModal.description`),icon:M,isOpen:e,onClose:u,title:n(`profile.password.removeModal.title`),variant:`destructive`,children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:d,children:[(0,Z.jsx)(A,{error:a.formState.errors.currentPassword,errorTestId:`remove-password-error`,id:`current-password-remove`,label:n(`profile.password.removeModal.currentPassword`),placeholder:n(`profile.password.removeModal.currentPasswordPlaceholder`),...a.register(`currentPassword`),type:`password`}),a.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:a.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`remove-password-cancel`,disabled:l.isPending,intent:`neutral`,onClick:u,type:`button`,uiSize:`sm`,children:n(`profile.password.removeModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`remove-password-submit`,disabled:l.isPending,intent:`danger`,loading:l.isPending,loadingLabel:n(`profile.password.removeModal.submitting`),type:`submit`,uiSize:`sm`,children:l.isPending?void 0:n(`profile.password.removeModal.submit`)})]})]})})}function Je({isOpen:e,onClose:t}){let{t:n}=s(),r=o(),{data:i}=f(N),a=i.auth.password.policy,c=(0,X.useMemo)(()=>q({password:J().min(a.min_length,n(`validation.password.min`,{count:a.min_length})).max(a.max_length,n(`validation.password.max`,{count:a.max_length})),confirmPassword:J()}).refine(e=>e.password===e.confirmPassword,{message:n(`validation.confirmPassword.mismatch`),path:[`confirmPassword`]}),[a.max_length,a.min_length,n]),l=W({resolver:G(c),defaultValues:{password:``,confirmPassword:``}}),u=m({...Le,onSuccess:()=>{r.invalidateQueries({queryKey:Y.queryKey}),d()}}),d=()=>{l.reset(),t()},p=l.handleSubmit(async e=>{try{await u.mutateAsync({password:e.password})}catch{l.setError(`root`,{message:n(`profile.password.setModal.error`)})}});return(0,Z.jsx)(H,{description:n(`profile.password.setModal.description`),icon:M,isOpen:e,onClose:d,title:n(`profile.password.setModal.title`),children:(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:p,children:[(0,Z.jsx)(A,{error:l.formState.errors.password,errorTestId:`set-password-error-password`,id:`new-password`,label:n(`profile.password.setModal.newPassword`),placeholder:n(`profile.password.setModal.newPasswordPlaceholder`),...l.register(`password`),type:`password`}),(0,Z.jsx)(A,{error:l.formState.errors.confirmPassword,errorTestId:`set-password-error-confirmPassword`,id:`confirm-password`,label:n(`profile.password.setModal.confirmPassword`),placeholder:n(`profile.password.setModal.confirmPasswordPlaceholder`),...l.register(`confirmPassword`),type:`password`}),l.formState.errors.root&&(0,Z.jsx)($,{variant:`error`,children:l.formState.errors.root.message}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`set-password-cancel`,disabled:u.isPending,intent:`neutral`,onClick:d,type:`button`,uiSize:`sm`,children:n(`profile.password.setModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`set-password-submit`,disabled:u.isPending,intent:`primary`,loading:u.isPending,loadingLabel:n(`profile.password.setModal.submitting`),type:`submit`,uiSize:`sm`,children:u.isPending?void 0:n(`profile.password.setModal.submit`)})]})]})})}function Ye({isOpen:e,onClose:t,isRequired:n=!1,canSwitchToTotp:r=!1,onSwitchToTotp:i}){let{t:a}=s(),c=o(),[l,u]=(0,X.useState)(`name`),[d,f]=(0,X.useState)(null),h=(0,X.useMemo)(()=>q({name:J().max(100,a(`validation.passkey.name.max`)).optional().transform(e=>e?.trim()||void 0)}),[a]),g=W({resolver:G(h),defaultValues:{name:``}}),_=m({...fe,onSuccess:()=>{c.invalidateQueries({queryKey:P.passkeys()}),c.invalidateQueries({queryKey:Y.queryKey}),v()},onError:e=>{u(`name`),e.name===`NotAllowedError`?f(a(`profile.passkey.setupModal.cancelled`)):f(a(`profile.passkey.setupModal.error`))}}),v=(0,X.useCallback)(()=>{g.reset(),u(`name`),f(null),t()},[g,t]),y=g.handleSubmit(async e=>{u(`register`),f(null);try{await _.mutateAsync({name:e.name})}catch{}}),b=_.isPending;return(0,Z.jsxs)(H,{description:n?a(`profile.passkey.setupModal.requiredDescription`):void 0,icon:j,isOpen:e,onClose:v,preventClose:n,size:`sm`,title:a(`profile.passkey.setupModal.title`),children:[l===`name`&&(0,Z.jsxs)(K,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,onSubmit:y,children:[(0,Z.jsx)(p,{as:`p`,color:`muted`,variant:`caption`,children:a(`profile.passkey.setupModal.description`)}),d&&(0,Z.jsx)($,{variant:`error`,children:d}),(0,Z.jsx)(A,{error:g.formState.errors.name,errorTestId:`setup-passkey-error`,hint:a(`profile.passkey.setupModal.nameHint`),id:`passkey-name`,label:a(`profile.passkey.setupModal.nameLabel`),placeholder:a(`profile.passkey.setupModal.namePlaceholder`),...g.register(`name`),type:`text`}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`setup-passkey-cancel`,intent:`neutral`,onClick:v,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.cancel`)}),(0,Z.jsx)(C,{"data-testid":`setup-passkey-continue`,intent:`primary`,type:`submit`,uiSize:`sm`,children:a(`profile.passkey.setupModal.continue`)})]}),r&&i&&(0,Z.jsx)(p,{align:`center`,as:`p`,className:`mt-tinyrack-sm`,variant:`caption`,children:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:i,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.switchToTotp`)})})]}),l===`register`&&(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-md py-tinyrack-xl`,"data-testid":`setup-passkey-loading`,children:[(0,Z.jsx)(S,{uiSize:`md`}),(0,Z.jsx)(p,{align:`center`,as:`p`,color:`muted`,variant:`caption`,children:a(`profile.passkey.setupModal.waitingForDevice`)})]}),(0,Z.jsx)(V,{children:(0,Z.jsx)(C,{appearance:`outline`,"data-testid":`setup-passkey-cancel`,disabled:b,intent:`neutral`,onClick:v,type:`button`,uiSize:`sm`,children:a(`profile.passkey.setupModal.cancel`)})})]})]})}function Xe({isOpen:e,onClose:t,isRequired:n=!1,canSwitchToPasskey:r=!1,onSwitchToPasskey:i}){let{t:a}=s(),{step:o,setupData:c,recoveryCodes:l,isSetupPending:u,isVerifyPending:d,isConfirmPending:f,startSetup:m,verify:h,goToVerify:g,goToQr:_,confirmRecoveryCodes:v,reset:y}=k({autoStart:!1,onConfirmSuccess:()=>{y(),t()}}),b=(0,X.useCallback)(()=>{y(),t()},[t,y]),x=(0,X.useCallback)(()=>{!c&&!u&&m()},[c,u,m]);e&&!c&&!u&&o!==`error`&&x();let w=(0,X.useCallback)(async e=>{await h(e)},[h]),T=a(o===`recovery`?`setupTotp.recoveryCodes.title`:`profile.totp.setupModal.title`);return(0,Z.jsxs)(H,{description:n?a(`profile.totp.setupModal.requiredDescription`):void 0,icon:L,isOpen:e,onClose:b,preventClose:n||o===`recovery`,size:`sm`,title:T,children:[u&&(0,Z.jsx)(`div`,{className:`flex justify-center py-tinyrack-xl`,"data-testid":`setup-totp-loading`,children:(0,Z.jsx)(S,{uiSize:`md`})}),o===`error`&&(0,Z.jsxs)(`div`,{className:`mt-tinyrack-lg flex flex-col gap-tinyrack-md`,children:[(0,Z.jsx)($,{variant:`error`,children:a(`profile.totp.setupModal.setupError`)}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(C,{appearance:`outline`,intent:`neutral`,onClick:b,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.cancel`)}),(0,Z.jsx)(C,{intent:`primary`,onClick:m,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.retry`)})]})]}),c&&o===`qr`&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(ee,{additionalActions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(V,{children:(0,Z.jsx)(C,{appearance:`outline`,intent:`neutral`,onClick:b,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.cancel`)})}),r&&i&&(0,Z.jsx)(p,{align:`center`,as:`p`,className:`mt-tinyrack-sm`,variant:`caption`,children:(0,Z.jsx)(C,{appearance:`ghost`,intent:`primary`,onClick:i,type:`button`,uiSize:`sm`,children:a(`profile.totp.setupModal.switchToPasskey`)})})]}),onNext:g,setupData:c})}),c&&o===`verify`&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(O,{isPending:d,onBack:_,onSubmit:w})}),o===`recovery`&&l.length>0&&(0,Z.jsx)(`div`,{className:`mt-tinyrack-lg`,children:(0,Z.jsx)(D,{isLoading:f,onConfirm:v,recoveryCodes:l})})]})}var Ze=(e=>d({queryKey:P.oauth.accounts(),queryFn:async()=>{let t=await e.api.user[`oauth-accounts`].$get();return l(t)}}))(u),Qe=g({mutationFn:async e=>{let t=await u.api.oauth[`:provider`].$delete({param:{provider:e}});return l(t)}});function $e(e,t=`login`,n){let r=new URLSearchParams({mode:t});return n&&r.set(`return_url`,n),`/api/oauth/${encodeURIComponent(e)}/authorize?${r.toString()}`}var et={access_denied:`oauth.error.accessDenied`,temporarily_unavailable:`oauth.error.temporarilyUnavailable`,server_error:`oauth.error.serverError`};function tt(e){return(0,Z.jsx)(U,{...e,onUnauthorized:()=>{he(`/login`)}})}function nt({search:e}){let{t}=s(),n=r(),i=o(),a=e.oauth_error,c=a?t(et[a]??`oauth.error.failed`):void 0,[l,u]=(0,X.useState)(null),[d,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,E]=(0,X.useState)(!1),{data:D}=f(Y),{data:ee}=f(Ze),{data:O}=f(N),k=m({...re,onSuccess:async()=>{i.setQueryData(Y.queryKey,{user:null}),await se(),n(`/login`)},onSettled:()=>{i.invalidateQueries({queryKey:Y.queryKey})}}),A=m({...Qe,onSuccess:()=>{i.invalidateQueries({queryKey:Ze.queryKey})},onSettled:()=>{u(null)}}),j=async()=>{d&&(u(d.id),await A.mutateAsync(d.id))};if(!D.user)return null;let M=D.user,P=ee.available_providers,F=P.some(e=>e.linked),I=M.managed_by===`config`,te=O.auth.password,L=O.auth.passkey,R=te.totp.enabled,z=L.enabled,ae=O.account_deletion.enabled,V=O.account_deletion.retention,H=(()=>{let e=V.match(/^(\d+)([dmy])$/);if(!e)return 30;let t=parseInt(e[1],10);switch(e[2]){case`d`:return t;case`m`:return t*30;case`y`:return t*365;default:return 30}})(),U=!I&&R,W=!I&&z,G=P.length>0;return(0,Z.jsxs)(Ie,{headerActions:(0,Z.jsx)(C,{appearance:`ghost`,"aria-label":t(`profile.logout`),"data-testid":`profile-logout`,disabled:k.isPending,loading:k.isPending,onClick:()=>k.mutate(),type:`button`,uiSize:`sm`,children:k.isPending?void 0:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{"aria-hidden":!0,className:`size-tinyrack-lg`}),(0,Z.jsx)(p,{as:`span`,className:`hidden sm:inline`,variant:`bodySm`,children:t(`profile.logout`)})]})}),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-tinyrack-lg`,children:[(0,Z.jsx)(oe,{email:M.email,size:`lg`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-tinyrack-3xs`,children:[(0,Z.jsx)(ie,{title:t(`profile.title`)}),(0,Z.jsx)(p,{as:`p`,color:`muted`,"data-testid":`profile-user-email`,truncate:!0,variant:`bodySm`,children:M.email})]})]}),c&&(0,Z.jsx)(B,{icon:T,type:`error`,children:c}),M&&(0,Z.jsx)(Fe,{user:M}),(0,Z.jsxs)(w.Root,{variant:`outlined`,children:[(0,Z.jsxs)(w.Header,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,children:[(0,Z.jsx)(w.Title,{children:t(`profile.security.title`)}),(0,Z.jsx)(w.Description,{children:t(`profile.security.description`)})]}),U&&M.totp_recovery_codes_missing&&(0,Z.jsx)(`div`,{className:`border-tinyrack-border border-b-tinyrack-default px-tinyrack-lg py-tinyrack-md`,"data-testid":`profile-totp-recovery-warning`,children:(0,Z.jsx)(B,{icon:T,type:`warning`,children:t(`profile.totp.recoveryCodesMissing`)})}),(0,Z.jsxs)(w.Content,{className:`divide-y divide-tinyrack-border p-0`,children:[(0,Z.jsx)(Ae,{hasLinkedOAuth:F,hasPassword:M.has_password,hasSecondFactorOnly:M.has_password&&!F&&(M.totp_registered||M.passkey_count>0),isConfigManaged:I,onOpenModal:_}),U&&(0,Z.jsx)(je,{onOpenModal:y,recoveryCodesMissing:M.totp_recovery_codes_missing,totpEnabled:M.totp_registered}),W&&(0,Z.jsx)(ke,{onOpenModal:x,passkeyCount:M.passkey_count})]})]}),G&&(0,Z.jsx)(Oe,{getAuthorizeUrl:$e,onUnlinkRequest:e=>h({id:e.id,name:e.display_name}),providers:P,unlinkingProvider:l}),(0,Z.jsx)(Ee,{isConfigManaged:I,isDeletionEnabled:ae,onDeleteClick:()=>E(!0)}),(0,Z.jsx)(Je,{isOpen:g===`set`,onClose:()=>_(null)}),(0,Z.jsx)(Be,{isOpen:g===`change`,onClose:()=>_(null)}),(0,Z.jsx)(qe,{isOpen:g===`remove`,onClose:()=>_(null)}),(0,Z.jsx)(Xe,{isOpen:v===`setup`,onClose:()=>y(null)}),(0,Z.jsx)(Ue,{isOpen:v===`disable`,onClose:()=>y(null)}),(0,Z.jsx)(Ke,{isOpen:v===`regenerate`,onClose:()=>y(null)}),(0,Z.jsx)(Ye,{isOpen:b===`setup`,onClose:()=>x(null)}),(0,Z.jsx)(We,{isOpen:b===`manage`,onAddNew:()=>x(`setup`),onClose:()=>x(null)}),(0,Z.jsx)(Ne,{isOpen:d!==null,isPending:A.isPending,onClose:()=>h(null),onConfirm:j,providerName:d?.name??``}),(0,Z.jsx)(He,{isOpen:S,onClose:()=>E(!1),retentionDays:H})]})}var rt=i(function({error:e}){return(0,Z.jsx)(_e,{component:tt,error:e})}),it=n(function({loaderData:e}){return(0,Z.jsx)(ge,{state:e.dehydratedState,children:(0,Z.jsx)(nt,{search:e.search})})});export{rt as ErrorBoundary,it as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{c as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{L as s,a as c}from"./api-CfCwvXbU.js";import{r as l,t as u}from"./text-CBHShrvS.js";import{t as d}from"./useMutation-BkuKGzks.js";import{V as f}from"./select-C_WHBpl_.js";import{r as p}from"./NullStore-UyCsFQfz.js";import{t as m}from"./circle-alert-BZCKPkRn.js";import{t as h}from"./auth-field-CDCz-y27.js";import{t as g}from"./fingerprint-pattern-AUfgwio5.js";import{n as _}from"./language-selector-
|
|
1
|
+
import{$ as e,J as t,a as n,f as r,o as i}from"./components-DF4L3dSB.js";import{c as a}from"./toast-XXVYYXim.js";import{t as o}from"./jsx-runtime-B-57GDDH.js";import{L as s,a as c}from"./api-CfCwvXbU.js";import{r as l,t as u}from"./text-CBHShrvS.js";import{t as d}from"./useMutation-BkuKGzks.js";import{V as f}from"./select-C_WHBpl_.js";import{r as p}from"./NullStore-UyCsFQfz.js";import{t as m}from"./circle-alert-BZCKPkRn.js";import{t as h}from"./auth-field-CDCz-y27.js";import{t as g}from"./fingerprint-pattern-AUfgwio5.js";import{n as _}from"./language-selector-CeLHnp1n.js";import{t as v}from"./shield-check-2DKLuF9J.js";import{t as y}from"./auth-page-header-C6Z6Air-.js";import{t as b}from"./link-button-DGt9hwk7.js";import{t as x}from"./alert-DS8e0Gvg.js";import{t as S}from"./route-error-fallback-CRL2Et8O.js";import{r as C,t as w}from"./standard-schema-kM5DbC12.js";import{r as T}from"./FieldItemContext-B3N2qWH8.js";import{a as E,s as D}from"./schemas-B87iTMww.js";import{n as O,t as k}from"./promise-CepnkPDw.js";import{i as A}from"./passkey-Bkqvhjwb.js";import{t as j}from"./document-navigation-Cnp3Alf0.js";import{n as M,r as N,t as P}from"./route-module-2foR49uh.js";import{t as F}from"./auth-layout-BedWIZ7L.js";import{n as I,t as L}from"./auth-footer-LG_gGuJv.js";import{i as R,r as z,t as B}from"./oauth-search-DebNssaC.js";import{t as V}from"./passkey-error-C3DrncLi.js";var H={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};H.node;var U=f(H),W=e(t(),1),G=o();function K({search:e}){let{t}=c(),n=r(),i=s(),{data:o}=l(_),[f,S]=(0,W.useState)(e.passkey_name?`registering`:`form`),[M,P]=(0,W.useState)(``),H=(0,W.useRef)(!1),K=o.auth.password.enabled&&o.auth.password.two_factor.enrollment_required&&o.auth.password.totp.enabled,q=(0,W.useMemo)(()=>E({name:D().max(100,t(`validation.passkey.name.max`))}),[t]),{register:J,handleSubmit:Y,formState:{errors:X}}=C({defaultValues:{name:``},resolver:w(q)}),Z=d({...A,onSuccess:async t=>{t.second_factor_setup_completed&&t.user?(i.setQueryData(O.queryKey,{user:t.user}),await k(),R(e)?j(B(e)):n(`/profile`)):(i.invalidateQueries({queryKey:O.queryKey}),n(`/profile`))},onError:e=>{switch(S(`error`),V(e)){case`unsupported`:P(t(`setupPasskey.error.unsupported`));return;case`not_allowed`:P(t(`setupPasskey.error.notAllowed`));return;case`expired`:P(t(`setupPasskey.error.expired`));return;case`user_mismatch`:case`verification_failed`:P(t(`setupPasskey.error.failed`));return}},onSettled:()=>{i.invalidateQueries({queryKey:O.queryKey})}});return(0,W.useEffect)(()=>{e.passkey_name&&!H.current&&(H.current=!0,Z.mutate({name:e.passkey_name}))},[Z,e.passkey_name]),f===`registering`?(0,G.jsxs)(F,{children:[(0,G.jsx)(y,{subtitle:t(`setupPasskey.subtitle`),title:t(`setupPasskey.title`)}),(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-tinyrack-lg py-tinyrack-xl`,children:[(0,G.jsx)(g,{"aria-hidden":!0,className:`size-tinyrack-3xl animate-pulse text-tinyrack-primary-foreground`}),(0,G.jsx)(u,{align:`center`,as:`p`,color:`muted`,variant:`body`,children:t(`setupPasskey.waiting`)})]})]}):f===`error`?(0,G.jsxs)(F,{children:[(0,G.jsx)(y,{subtitle:t(`setupPasskey.subtitle`),title:t(`setupPasskey.title`)}),(0,G.jsx)(x,{icon:m,type:`error`,children:M}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-tinyrack-sm`,children:[K&&(0,G.jsxs)(b,{className:`w-full gap-tinyrack-sm`,intent:`primary`,render:(0,G.jsx)(a,{to:N(`/setup/totp`,z(e))}),uiSize:`lg`,children:[(0,G.jsx)(v,{"aria-hidden":!0,className:`size-tinyrack-xl`}),t(`setupPasskey.useTotp`)]}),(0,G.jsx)(p,{appearance:K?`outline`:`solid`,className:`w-full`,intent:K?`neutral`:`primary`,onClick:()=>{e.passkey_name?(S(`registering`),P(``),Z.mutate({name:e.passkey_name})):S(`form`)},type:`button`,uiSize:`lg`,children:t(`setupPasskey.retry`)})]}),(0,G.jsx)(L,{children:(0,G.jsx)(I,{link:(0,G.jsx)(a,{to:N(`/login`,z(e)),children:t(`setupPasskey.backToLogin`)})})})]}):(0,G.jsxs)(F,{children:[(0,G.jsx)(y,{subtitle:t(`setupPasskey.subtitle`),title:t(`setupPasskey.title`)}),(0,G.jsx)(x,{icon:v,type:`info`,children:t(`setupPasskey.required`)}),(0,G.jsx)(u,{align:`center`,as:`p`,color:`muted`,variant:`bodySm`,children:t(`setupPasskey.description`)}),(0,G.jsxs)(T,{className:`flex flex-col gap-tinyrack-lg`,onSubmit:Y(e=>{S(`registering`),P(``),Z.mutate({name:e.name||void 0})}),children:[(0,G.jsx)(h,{error:X.name,hint:t(`setupPasskey.name.hint`),icon:U,id:`passkey-name`,label:t(`setupPasskey.name.label`),placeholder:t(`setupPasskey.name.placeholder`),...J(`name`),type:`text`}),(0,G.jsx)(p,{className:`w-full`,intent:`primary`,loading:Z.isPending,loadingLabel:t(`setupPasskey.registering`),type:`submit`,uiSize:`lg`,children:t(`setupPasskey.continue`)})]}),(0,G.jsx)(L,{children:(0,G.jsx)(I,{link:(0,G.jsx)(a,{to:N(`/login`,z(e)),children:t(`setupPasskey.backToLogin`)})})})]})}var q=i(function({error:e}){return(0,G.jsx)(P,{component:S,error:e})}),J=n(function({loaderData:e}){return(0,G.jsx)(M,{state:e.dehydratedState,children:(0,G.jsx)(K,{search:e.search})})});export{q as ErrorBoundary,J as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,J as t,a as n,f as r}from"./components-DF4L3dSB.js";import{c as i}from"./toast-XXVYYXim.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as ee,i as s,u as c}from"./api-CfCwvXbU.js";import{t as l}from"./text-CBHShrvS.js";import{V as u}from"./select-C_WHBpl_.js";import{i as te,r as d}from"./NullStore-UyCsFQfz.js";import{t as ne}from"./circle-alert-BZCKPkRn.js";import{a as f,i as p,n as m,r as h,t as re}from"./use-totp-setup-
|
|
1
|
+
import{$ as e,J as t,a as n,f as r}from"./components-DF4L3dSB.js";import{c as i}from"./toast-XXVYYXim.js";import{t as a}from"./jsx-runtime-B-57GDDH.js";import{L as o,a as ee,i as s,u as c}from"./api-CfCwvXbU.js";import{t as l}from"./text-CBHShrvS.js";import{V as u}from"./select-C_WHBpl_.js";import{i as te,r as d}from"./NullStore-UyCsFQfz.js";import{t as ne}from"./circle-alert-BZCKPkRn.js";import{a as f,i as p,n as m,r as h,t as re}from"./use-totp-setup-Cwuds2tR.js";import{t as ie}from"./shield-check-2DKLuF9J.js";import{t as ae}from"./auth-page-header-C6Z6Air-.js";import{t as g}from"./alert-BIM0hnda.js";import{t as _}from"./alert-DS8e0Gvg.js";import{n as v,t as y}from"./promise-CepnkPDw.js";import{t as b}from"./document-navigation-Cnp3Alf0.js";import{n as x,r as S}from"./route-module-2foR49uh.js";import{t as C}from"./auth-layout-BedWIZ7L.js";import{n as w,t as T}from"./auth-footer-LG_gGuJv.js";import{i as E,r as D,t as O}from"./oauth-search-DebNssaC.js";var k={name:`circle-x`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-circle`]};k.node;var oe=u(k),A=e(t(),1),j=a();function M({className:e,role:t=`list`,...n}){return(0,j.jsx)(`ol`,{...n,className:c(`tr-steps`,e),role:t})}function N({className:e,...t}){return(0,j.jsx)(`li`,{...t,className:c(`tr-steps-item`,e)})}function P({className:e,current:t,total:n,...r}){let i=Math.max(1,n),a=Math.min(Math.max(1,t),i);return(0,j.jsx)(`div`,{...r,"aria-valuemax":i,"aria-valuemin":1,"aria-valuenow":a,className:c(`tr-steps-progress`,e),role:`progressbar`,children:Array.from({length:i},(e,t)=>String(t+1)).map(e=>(0,j.jsx)(`span`,{"aria-hidden":`true`,className:`tr-steps-progress-segment`,"data-complete":Number(e)<=a?`true`:void 0},e))})}var F={Item:N,Progress:P,Root:M};function I({steps:e,current:t,progressLabel:n}){return(0,j.jsxs)(`div`,{className:`flex w-full flex-col gap-tinyrack-xs`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline justify-between gap-tinyrack-sm`,children:[(0,j.jsx)(l,{color:`muted`,variant:`label`,children:n}),(0,j.jsx)(l,{color:`muted`,variant:`caption`,children:e[t]})]}),(0,j.jsx)(F.Progress,{"aria-label":n,current:t+1,total:e.length})]})}var L={TOTP_ALREADY_ENABLED:`TOTP_ALREADY_ENABLED`,TOTP_NOT_SETUP:`TOTP_NOT_SETUP`,INVALID_TOTP_CODE:`INVALID_TOTP_CODE`,UNAUTHORIZED:`UNAUTHORIZED`,SECOND_FACTOR_SESSION_EXPIRED:`SECOND_FACTOR_SESSION_EXPIRED`},R=5;function z({search:e}){let{t}=ee(),n=r(),a=o(),[c,l]=(0,A.useState)(`generic`),[u,x]=(0,A.useState)(R),k=(0,A.useCallback)(()=>{n(S(`/login`,D(e)))},[n,e]),M=(0,A.useCallback)(()=>{n(`/profile`)},[n]),N=(0,A.useCallback)(e=>{if(e instanceof s)switch(e.code){case L.TOTP_ALREADY_ENABLED:l(`already_enabled`);break;case L.UNAUTHORIZED:case L.SECOND_FACTOR_SESSION_EXPIRED:l(`session_expired`),x(R);break;default:l(`generic`)}else l(`generic`)},[]),P=(0,A.useCallback)(async e=>{await y()},[]),F=(0,A.useCallback)(async t=>{a.setQueryData(v.queryKey,{user:t.user}),await y(),E(e)?b(O(e)):n(`/profile`)},[n,a,e]),{step:z,setupData:B,recoveryCodes:V,isSetupPending:H,isVerifyPending:U,isConfirmPending:W,startSetup:G,verify:K,goToQr:se,goToVerify:ce,confirmRecoveryCodes:le}=re({autoStart:!0,onSetupError:N,onVerifySuccess:P,onConfirmSuccess:F,onVerifyError:e=>{if(e instanceof s)switch(e.code){case L.TOTP_ALREADY_ENABLED:M();break;case L.UNAUTHORIZED:case L.SECOND_FACTOR_SESSION_EXPIRED:l(`session_expired`),x(R);break;case L.TOTP_NOT_SETUP:G()}}});(0,A.useEffect)(()=>{if(c!==`session_expired`||z!==`error`)return;let e=setInterval(()=>{x(t=>t<=1?(clearInterval(e),k(),0):t-1)},1e3);return()=>clearInterval(e)},[c,z,k]);let ue=(0,A.useCallback)(async e=>{await K(e)},[K]),q=z===`recovery`&&V.length>0,J=z===`qr`&&B!==null,Y=z!==`loading`&&z!==`error`,X=1;q?X=2:J&&(X=0);let Z=t(`setupTotp.title`),Q=t(`setupTotp.subtitle`);q?Z=t(`setupTotp.recoveryCodes.title`):Y&&!J&&(Z=t(`setupTotp.verifyTitle`),Q=t(`setupTotp.verifySubtitle`));let de=z===`error`||J,$;return $=z===`loading`?(0,j.jsx)(`div`,{className:`flex justify-center py-tinyrack-xl`,"data-testid":`totp-setup-loading`,children:(0,j.jsx)(te,{uiSize:`lg`,variant:`primary`})}):z===`error`&&c===`session_expired`?(0,j.jsxs)(g.Root,{"data-testid":`totp-setup-session-expired`,variant:`warning`,children:[(0,j.jsx)(ne,{"aria-hidden":!0,className:`size-tinyrack-xl`}),(0,j.jsx)(g.Title,{children:t(`setupTotp.error.expired`)}),(0,j.jsx)(g.Description,{children:t(`setupTotp.redirecting`,{seconds:u})}),(0,j.jsx)(g.Actions,{children:(0,j.jsx)(d,{appearance:`ghost`,intent:`neutral`,onClick:k,type:`button`,uiSize:`sm`,children:t(`setupTotp.redirectNow`)})})]}):z===`error`&&c===`already_enabled`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(_,{icon:f,type:`info`,children:t(`setupTotp.error.alreadyEnabled`)}),(0,j.jsx)(d,{className:`w-full`,intent:`primary`,onClick:M,type:`button`,uiSize:`lg`,children:t(`setupTotp.goToProfile`)})]}):z===`error`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(_,{icon:oe,type:`error`,children:t(`setupTotp.error.setupFailed`)}),(0,j.jsx)(d,{className:`w-full`,disabled:H,intent:`primary`,loading:H,onClick:G,type:`button`,uiSize:`lg`,children:t(`setupTotp.retry`)})]}):q?(0,j.jsx)(p,{isLoading:W,onConfirm:le,recoveryCodes:V}):J&&B?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(_,{icon:ie,type:`info`,children:t(`setupTotp.required`)}),(0,j.jsx)(m,{onNext:ce,setupData:B})]}):(0,j.jsx)(h,{isPending:U,onBack:se,onSubmit:ue}),(0,j.jsxs)(C,{width:q?`wide`:`form`,children:[(0,j.jsx)(ae,{eyebrow:Y?(0,j.jsx)(I,{current:X,progressLabel:t(`setupTotp.stepProgress`,{current:X+1,total:3}),steps:[t(`setupTotp.steps.scan`),t(`setupTotp.steps.verify`),t(`setupTotp.steps.saveCodes`)]}):void 0,subtitle:Q,title:Z}),(0,j.jsx)(`div`,{className:`auth-enter flex flex-col gap-tinyrack-lg`,children:$},z),de&&(0,j.jsx)(T,{children:(0,j.jsx)(w,{link:(0,j.jsx)(i,{to:S(`/login`,D(e)),children:t(`setupTotp.backToLogin`)})})})]})}var B=n(function({loaderData:e}){return(0,j.jsx)(x,{state:e.dehydratedState,children:(0,j.jsx)(z,{search:e.search})})});export{B as default};
|