@lunora/studio 1.0.0-alpha.375 → 1.0.0-alpha.376
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.mjs +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/organizations-panel.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/schedule-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/sync-client-panel.mjs +1 -1
- package/dist/packem_chunks/users-panel.mjs +1 -1
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs +1 -0
- package/dist/packem_shared/{DataBrowser-BrRWqnCr.mjs → DataBrowser-BR2nrvMW.mjs} +1 -1
- package/dist/packem_shared/GlobalDataBrowser-Df5S1NxG.mjs +1 -0
- package/dist/packem_shared/{ScheduledJobs-QCTRdugp.mjs → ScheduledJobs-Du8ZGL7v.mjs} +1 -1
- package/dist/packem_shared/{Studio-pDEG4JTx.mjs → Studio-JuMI1hpi.mjs} +1 -1
- package/dist/packem_shared/{StudioApp-C4IOJPR6.mjs → StudioApp-02dw_keu.mjs} +1 -1
- package/dist/packem_shared/{studio-DE7i2--m.mjs → studio-DtxNxSjs.mjs} +1 -1
- package/dist/packem_shared/{table-list-sidebar-DUnCjFL7.mjs → table-list-sidebar-C8qPvzGk.mjs} +1 -1
- package/dist/standalone/{chunk-4EQAUONF.js → chunk-2BQNNRAP.js} +1 -1
- package/dist/standalone/{chunk-USVLFLZL.js → chunk-3BQ6FMEA.js} +2 -2
- package/dist/standalone/{chunk-HCWB4UDT.js → chunk-3D2E7WXH.js} +1 -1
- package/dist/standalone/{chunk-QMULO5AP.js → chunk-4DIRNQHR.js} +1 -1
- package/dist/standalone/{chunk-QN66FO5B.js → chunk-64LU3VU6.js} +1 -1
- package/dist/standalone/{chunk-FK2S7VR4.js → chunk-6BH5TIGF.js} +1 -1
- package/dist/standalone/{chunk-ILSJ22BK.js → chunk-7LCGAQWG.js} +1 -1
- package/dist/standalone/{chunk-GH6CI2P2.js → chunk-AFVVESAA.js} +1 -1
- package/dist/standalone/{chunk-NGGTRLCC.js → chunk-ALNEZ5D2.js} +1 -1
- package/dist/standalone/chunk-AQ62YJJ5.js +1 -0
- package/dist/standalone/{chunk-TDJQ7HQM.js → chunk-B3TXCZUI.js} +1 -1
- package/dist/standalone/{chunk-PIOHOROI.js → chunk-B4PRNI7H.js} +1 -1
- package/dist/standalone/{chunk-52ULLZJX.js → chunk-BE3FD3E6.js} +1 -1
- package/dist/standalone/{chunk-OODTH4NA.js → chunk-BYUXIOPZ.js} +1 -1
- package/dist/standalone/{chunk-PIQ4A4BZ.js → chunk-CCETXQNF.js} +1 -1
- package/dist/standalone/{chunk-LR2FBYCC.js → chunk-CHIQ3CJZ.js} +1 -1
- package/dist/standalone/{chunk-TUFOWHEF.js → chunk-CLQKKJHL.js} +1 -1
- package/dist/standalone/{chunk-RKPVI2PI.js → chunk-CURIWKKC.js} +1 -1
- package/dist/standalone/{chunk-4B54WP4R.js → chunk-CZA2P2TU.js} +1 -1
- package/dist/standalone/{chunk-N7EIHD3H.js → chunk-EVJSGZXV.js} +1 -1
- package/dist/standalone/{chunk-RHYQB4RH.js → chunk-EYJX6GXU.js} +1 -1
- package/dist/standalone/{chunk-FGZ73BFG.js → chunk-EYMLYHWK.js} +1 -1
- package/dist/standalone/{chunk-XZHTVLDG.js → chunk-F4S2YEYW.js} +1 -1
- package/dist/standalone/{chunk-2CPMCEHD.js → chunk-FEHRNTIU.js} +1 -1
- package/dist/standalone/{chunk-FT3BWJVP.js → chunk-FERYOTLW.js} +1 -1
- package/dist/standalone/{chunk-WFXS3YRM.js → chunk-G6VBT4AU.js} +1 -1
- package/dist/standalone/{chunk-KYN4A72O.js → chunk-GMT66LBU.js} +1 -1
- package/dist/standalone/{chunk-ZCOMJH2I.js → chunk-HAK2T6YN.js} +1 -1
- package/dist/standalone/{chunk-SKZNH5QQ.js → chunk-HSI24FPH.js} +1 -1
- package/dist/standalone/{chunk-6VOBO5QL.js → chunk-JIBRGVA7.js} +1 -1
- package/dist/standalone/{chunk-XITLHKKR.js → chunk-JYCGHNPF.js} +1 -1
- package/dist/standalone/{chunk-JPCVFWR5.js → chunk-K3MVWN6E.js} +1 -1
- package/dist/standalone/{chunk-R52GVSS2.js → chunk-K46QTJR6.js} +1 -1
- package/dist/standalone/{chunk-MJWIIV2C.js → chunk-LKML3CX4.js} +1 -1
- package/dist/standalone/{chunk-LCIDEYA4.js → chunk-LQCF6SZW.js} +1 -1
- package/dist/standalone/{chunk-LFKKTGEF.js → chunk-N3FNOCHB.js} +1 -1
- package/dist/standalone/{chunk-EAPNLM2Q.js → chunk-OT2YNQPU.js} +1 -1
- package/dist/standalone/{chunk-4ADB7TWC.js → chunk-PEVNCIZQ.js} +1 -1
- package/dist/standalone/chunk-PFPJA2HR.js +7 -0
- package/dist/standalone/{chunk-RUQTILJN.js → chunk-PUU56AIE.js} +1 -1
- package/dist/standalone/{chunk-JB3DZ2PJ.js → chunk-PYQUCCUO.js} +1 -1
- package/dist/standalone/{chunk-QNY5EEBN.js → chunk-QAQ3KMY6.js} +1 -1
- package/dist/standalone/{chunk-WJA2IGZC.js → chunk-QGAWQTUE.js} +1 -1
- package/dist/standalone/{chunk-DDTWGWM4.js → chunk-QURCU2N2.js} +1 -1
- package/dist/standalone/{chunk-CBACG4XF.js → chunk-QXNMGPXW.js} +1 -1
- package/dist/standalone/{chunk-HZU4WF4X.js → chunk-R3P6KKUH.js} +1 -1
- package/dist/standalone/{chunk-2U6Z7A6C.js → chunk-RTE7SDRS.js} +1 -1
- package/dist/standalone/{chunk-PGJOTPWC.js → chunk-RWMOWRJX.js} +1 -1
- package/dist/standalone/{chunk-XWVFKYZV.js → chunk-SW52HGM4.js} +1 -1
- package/dist/standalone/{chunk-CGXIERYO.js → chunk-SWFSB4QT.js} +1 -1
- package/dist/standalone/{chunk-2IOS27FL.js → chunk-SZBLYYV6.js} +1 -1
- package/dist/standalone/{chunk-DHH7WHXQ.js → chunk-UBTKEHX6.js} +1 -1
- package/dist/standalone/{chunk-6IRGBPDN.js → chunk-UVNJG3UL.js} +1 -1
- package/dist/standalone/{chunk-VDSTHVWZ.js → chunk-W2FHSEQW.js} +1 -1
- package/dist/standalone/{chunk-LA76GGAT.js → chunk-WAIESA3E.js} +1 -1
- package/dist/standalone/{chunk-MTX62MQ7.js → chunk-WB6VGH7X.js} +1 -1
- package/dist/standalone/{chunk-3BQD5ITB.js → chunk-X45MVUVK.js} +1 -1
- package/dist/standalone/{chunk-IELLWQGA.js → chunk-X72A525Z.js} +1 -1
- package/dist/standalone/{chunk-G5REMLEG.js → chunk-YTPE33AO.js} +1 -1
- package/dist/standalone/{chunk-Z6WEYWT7.js → chunk-ZCXG3567.js} +1 -1
- package/dist/standalone/{chunk-RDS72J4I.js → chunk-ZFEDRJ7R.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +4 -4
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs +0 -1
- package/dist/packem_shared/GlobalDataBrowser-DB1B-WAN.mjs +0 -1
- package/dist/standalone/chunk-ACWAMBGT.js +0 -1
- package/dist/standalone/chunk-ODLNNVP2.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as I,useEffect as Me}from"react";import{B as q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as K,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as Ye}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as B}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Re,b as Q,c as U,d as Te,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{a as qe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{c as Z}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-CG7VvAvQ.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as ee}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{w as Ke,h as Fe,f as J,l as Pe,b as Ve}from"../packem_shared/internal-hIuTpSbx.mjs";import{A as Xe}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{jsxs as u,jsx as t,Fragment as et}from"react/jsx-runtime";import{C as tt}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as st}from"../packem_shared/use-async-submit-D0r7-m2J.mjs";const nt=()=>{const h=Z(3),{config:e,ready:l}=Qe();let n;return h[0]!==e.capabilities||h[1]!==l?(n={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=n):n=h[2],n},lt=(h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending",He=500,at=(h,e)=>{if(!URL.canParse(h.trim()))return null;const l=new URL(h.trim());return l.searchParams.set("email",e.email),l.searchParams.set("invite",e.token),l.toString()},it=h=>{const e=Z(34),{issued:l,onSignUpPageChange:n,signUpPage:o}=h,s=W(),[f,a]=I(null);let c;e[0]!==l||e[1]!==o?(c=at(o,l),e[0]=l,e[1]=o,e[2]=c):c=e[2];const d=c;let y;e[3]!==d?(y=()=>{const T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||T===void 0||J(T.writeText(d).then(()=>(a(d),!0)))},e[3]=d,e[4]=y):y=e[4];const C=y;let g;e[5]!==s?(g=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=g):g=e[6];let w;e[7]!==g?(w=t("p",{className:"text-sm",children:g}),e[7]=g,e[8]=w):w=e[8];const k=d===null;let v;e[9]!==s?(v=s("Your app's sign-up page"),e[9]=s,e[10]=v):v=e[10];let r;e[11]!==n?(r=T=>{n(T.target.value)},e[11]=n,e[12]=r):r=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==r?(m=t(B,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:r,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=r,e[17]=m):m=e[17];const b=d??"";let x;e[18]!==b?(x=t(B,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==f||e[21]!==d||e[22]!==s?(N=s(f!==null&&f===d?"Copied":"Copy"),e[20]=f,e[21]=d,e[22]=s,e[23]=N):N=e[23];let p;e[24]!==C||e[25]!==N?(p=t(R,{"data-testid":"sign-up-invitation-copy",onClick:C,type:"button",children:N}),e[24]=C,e[25]=N,e[26]=p):p=e[26];let i;e[27]!==x||e[28]!==p?(i=u("div",{className:"flex gap-2",children:[x,p]}),e[27]=x,e[28]=p,e[29]=i):i=e[29];let S;return e[30]!==i||e[31]!==w||e[32]!==m?(S=t(K,{children:u(X,{className:"flex flex-col gap-2 p-4",children:[w,m,i]})}),e[30]=i,e[31]=w,e[32]=m,e[33]=S):S=e[33],S},rt=()=>{const h=ee(),e=W(),[l,n]=I(""),[o,s]=I(null),[f,a]=I(null),[c,d]=I(()=>`${Ke(h.url)}/sign-up`),y=qe(["lunora-auth-sign-up-invitations",He],()=>h.listAuthSignUpInvitations({limit:He})),C=y.data?.rows??null,g=y.data?.total??0,w=()=>{const v=l.trim();v!==""&&(s(null),J((async()=>{try{const r=await h.createAuthSignUpInvitation({email:v}),m=typeof r.token=="string"?r.token:void 0;a(m===void 0?null:{email:v,token:m}),n(""),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})()))},k=v=>{s(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})())};return u("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[u("div",{children:[t("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),t("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed — send the invitee the one-time link yourself.")})]}),u("div",{className:"flex gap-2",children:[t(B,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:v=>{n(v.target.value)},placeholder:e("ada@example.com"),type:"email",value:l}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:w,type:"button",children:e("Invite")})]}),f!==null&&t(it,{issued:f,onSignUpPageChange:d,signUpPage:c},f.token),(o??y.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),C!==null&&C.length===0&&t(Ye,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&g>C.length&&t("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&t(K,{children:t(X,{className:"p-0",children:u(Ee,{children:[t(Re,{children:u(Q,{children:[t(U,{children:e("Email")}),t(U,{children:e("Status")}),t(U,{children:e("Expires")}),t(U,{children:e("Invited by")}),t(U,{})]})}),t(Te,{children:C.map(v=>{const r=lt(v,Date.now()),m=v.email??"";return u(Q,{"data-testid":`sign-up-invitation-${m}`,children:[t(P,{children:m}),u(P,{"data-testid":`sign-up-invitation-status-${m}`,children:[r==="spent"&&e("Accepted"),r==="expired"&&e("Expired"),r==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?Fe(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{k(m)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},ot={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=(h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),ct=(h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;const l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){const n=Number(l);return Number.isNaN(n)?void 0:{value:n}}return{value:l}}},ut=h=>{const e=Z(105),{onClose:l,onCreated:n}=h,o=ee(),s=W(),{config:f}=Qe(),{busy:a,error:c,run:d}=st(),[y,C]=I(""),[g,w]=I(""),[k,v]=I(""),[r,m]=I("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[x,N]=I(b);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=A=>{C(A.target.value)},e[1]=p):p=e[1];const i=p;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{w(A.target.value)},e[2]=S):S=e[2];const T=S;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const j=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{m(A.target.value)},e[4]=M):M=e[4];const H=M;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=(A,D)=>{N(G=>({...G,[A]:D}))},e[5]=L):L=e[5];const V=L;let Y;e[6]!==x?(Y=A=>x[A.name]??(A.type==="boolean"?!1:""),e[6]=x,e[7]=Y):Y=e[7];const E=Y;let O;if(e[8]!==f.userFields||e[9]!==E){let A;e[11]!==E?(A=D=>!D.required||dt(D,E(D)),e[11]=E,e[12]=A):A=e[12],O=f.userFields.every(A),e[8]=f.userFields,e[9]=E,e[10]=O}else O=e[10];const F=O;let $;e[13]!==a||e[14]!==y||e[15]!==g||e[16]!==F?($=!a&&y.trim()!==""&&g.trim()!==""&&F,e[13]=a,e[14]=y,e[15]=g,e[16]=F,e[17]=$):$=e[17];const Ue=$;let te;e[18]!==f.userFields||e[19]!==E?(te=()=>{const A={};for(const D of f.userFields){const G=ct(D,E(D));G!==void 0&&(A[D.name]=G.value)}return Object.keys(A).length===0?void 0:A},e[18]=f.userFields,e[19]=E,e[20]=te):te=e[20];const Be=te;let De;e[21]!==Be||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==l||e[26]!==n||e[27]!==k||e[28]!==r||e[29]!==d?(De=()=>{d(async()=>{await o.createAuthUser({data:Be(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:r.trim()===""?void 0:r.trim()}),n(),l()})},e[21]=Be,e[22]=o,e[23]=y,e[24]=g,e[25]=l,e[26]=n,e[27]=k,e[28]=r,e[29]=d,e[30]=De):De=e[30];const ze=De;let se;e[31]!==s?(se=s("Create user"),e[31]=s,e[32]=se):se=e[32];let ne;e[33]!==s?(ne=s("Create user"),e[33]=s,e[34]=ne):ne=e[34];let le;e[35]!==ne?(le=t("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=le):le=e[36];let ae;e[37]!==s?(ae=s("email"),e[37]=s,e[38]=ae):ae=e[38];let ie;e[39]!==ae?(ie=t(_,{htmlFor:"uc-email",children:ae}),e[39]=ae,e[40]=ie):ie=e[40];let re;e[41]!==y?(re=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:i,type:"email",value:y}),e[41]=y,e[42]=re):re=e[42];let oe;e[43]!==ie||e[44]!==re?(oe=u("div",{className:"flex flex-col gap-1",children:[ie,re]}),e[43]=ie,e[44]=re,e[45]=oe):oe=e[45];let de;e[46]!==s?(de=s("name"),e[46]=s,e[47]=de):de=e[47];let ce;e[48]!==de?(ce=t(_,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=ce):ce=e[49];let ue;e[50]!==g?(ue=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:g}),e[50]=g,e[51]=ue):ue=e[51];let me;e[52]!==ce||e[53]!==ue?(me=u("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[52]=ce,e[53]=ue,e[54]=me):me=e[54];let he;e[55]!==s?(he=s("Password (optional)"),e[55]=s,e[56]=he):he=e[56];let fe;e[57]!==he?(fe=t(_,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=fe):fe=e[58];let pe;e[59]!==k?(pe=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:j,type:"password",value:k}),e[59]=k,e[60]=pe):pe=e[60];let ve;e[61]!==fe||e[62]!==pe?(ve=u("div",{className:"flex flex-col gap-1",children:[fe,pe]}),e[61]=fe,e[62]=pe,e[63]=ve):ve=e[63];let ge;e[64]!==s?(ge=s("Role (optional)"),e[64]=s,e[65]=ge):ge=e[65];let be;e[66]!==ge?(be=t(_,{htmlFor:"uc-role",children:ge}),e[66]=ge,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=u("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let Ne;e[73]!==f.userFields||e[74]!==E||e[75]!==s?(Ne=f.userFields.length>0&&u("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")}),f.userFields.map(A=>{const D=`uc-field-${A.name}`,G=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const Oe=E(A)===!0;return u("label",{className:"flex items-center gap-2",htmlFor:D,children:[t(tt,{checked:Oe,"data-testid":D,id:D,onCheckedChange:Ze=>{V(A.name,Ze)}}),u("span",{className:"text-sm",children:[A.name,G]})]},A.name)}const je=E(A);return u("div",{className:"flex flex-col gap-1",children:[u(_,{htmlFor:D,children:[A.name,G]}),t(B,{"data-testid":D,id:D,onChange:Oe=>{V(A.name,Oe.target.value)},type:ot[A.type],value:typeof je=="string"?je:""})]},A.name)})]}),e[73]=f.userFields,e[74]=E,e[75]=s,e[76]=Ne):Ne=e[76];let ke;e[77]!==c?(ke=c!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:c}),e[77]=c,e[78]=ke):ke=e[78];let Ce;e[79]!==s?(Ce=s("Cancel"),e[79]=s,e[80]=Ce):Ce=e[80];let we;e[81]!==l||e[82]!==Ce?(we=t(R,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=l,e[82]=Ce,e[83]=we):we=e[83];const Le=!Ue;let Ae;e[84]!==a||e[85]!==s?(Ae=s(a?"Creating…":"Create"),e[84]=a,e[85]=s,e[86]=Ae):Ae=e[86];let Se;e[87]!==ze||e[88]!==Le||e[89]!==Ae?(Se=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:ze,size:"sm",type:"button",children:Ae}),e[87]=ze,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Ie;e[91]!==we||e[92]!==Se?(Ie=u("div",{className:"flex justify-end gap-2 pt-1",children:[we,Se]}),e[91]=we,e[92]=Se,e[93]=Ie):Ie=e[93];let $e;return e[94]!==l||e[95]!==se||e[96]!==le||e[97]!==oe||e[98]!==me||e[99]!==ve||e[100]!==ye||e[101]!==Ne||e[102]!==ke||e[103]!==Ie?($e=u(We,{label:se,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[le,oe,me,ve,ye,Ne,ke,Ie]}),e[94]=l,e[95]=se,e[96]=le,e[97]=oe,e[98]=me,e[99]=ve,e[100]=ye,e[101]=Ne,e[102]=ke,e[103]=Ie,e[104]=$e):$e=e[104],$e},_e=h=>{const e=Z(2),{children:l}=h;let n;return e[0]!==l?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=n):n=e[1],n},mt=h=>{const e=Z(29),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{const i=await f.listAuthSessions({limit:50,userId:o});d(i.rows)}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n?(k=i=>{n(()=>f.revokeAuthSession({sessionId:i}))},e[7]=f,e[8]=n,e[9]=k):k=e[9];const v=k;let r;e[10]!==a?(r=a("Sessions"),e[10]=a,e[11]=r):r=e[11];let m;e[12]!==r?(m=t(_e,{children:r}),e[12]=r,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==c||e[17]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:a("No active sessions.")}),e[16]=c,e[17]=a,e[18]=x):x=e[18];let N;e[19]!==l||e[20]!==v||e[21]!==c||e[22]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-sessions-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("expires")}),t(U,{children:a("ip")}),t(U,{children:a("user agent")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>u(Q,{"data-testid":`ud-session-${i.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.expiresAt)}),t(P,{children:i.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:i.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${i.id}`,disabled:l,onClick:()=>{v(i.id)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[19]=l,e[20]=v,e[21]=c,e[22]=a,e[23]=N):N=e[23];let p;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=p):p=e[28],p},ht=h=>{const e=Z(30),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{d(await f.listAuthAccounts({userId:o}))}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n||e[9]!==o?(k=i=>{n(()=>f.unlinkAuthAccount({accountId:i,userId:o}))},e[7]=f,e[8]=n,e[9]=o,e[10]=k):k=e[10];const v=k;let r;e[11]!==a?(r=a("Linked accounts"),e[11]=a,e[12]=r):r=e[12];let m;e[13]!==r?(m=t(_e,{children:r}),e[13]=r,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==c||e[18]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No linked accounts.")}),e[17]=c,e[18]=a,e[19]=x):x=e[19];let N;e[20]!==c||e[21]!==l||e[22]!==v||e[23]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-accounts-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("provider")}),t(U,{children:a("created")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>{const S=Pe(i.id);return u(Q,{"data-testid":`ud-account-${S}`,children:[t(P,{children:Pe(i.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${S}`,disabled:l,onClick:()=>{v(S)},size:"xs",type:"button",variant:"ghost",children:a("Unlink")})})]},S)})})]})})}),e[20]=c,e[21]=l,e[22]=v,e[23]=a,e[24]=N):N=e[24];let p;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=p):p=e[29],p},ft=h=>{const e=Z(40),{busy:l,capabilities:n,runAction:o,userId:s,version:f}=h,a=ee(),c=W(),[d,y]=I(null);let C;e[0]!==n.passkey||e[1]!==a||e[2]!==s?(C=()=>{n.passkey&&J((async()=>{try{y(await a.listAuthPasskeys({userId:s}))}catch{y(null)}})())},e[0]=n.passkey,e[1]=a,e[2]=s,e[3]=C):C=e[3];let g;e[4]!==n.passkey||e[5]!==a||e[6]!==s||e[7]!==f?(g=[n.passkey,a,s,f],e[4]=n.passkey,e[5]=a,e[6]=s,e[7]=f,e[8]=g):g=e[8],Me(C,g);let w;e[9]!==a||e[10]!==o||e[11]!==s?(w=()=>{o(()=>a.disableAuthTwoFactor({userId:s}))},e[9]=a,e[10]=o,e[11]=s,e[12]=w):w=e[12];const k=w;let v;e[13]!==a||e[14]!==o?(v=S=>{o(()=>a.deleteAuthPasskey({passkeyId:S}))},e[13]=a,e[14]=o,e[15]=v):v=e[15];const r=v;let m;e[16]!==c?(m=c("Security"),e[16]=c,e[17]=m):m=e[17];let b;e[18]!==m?(b=t(_e,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==l||e[21]!==n.twoFactor||e[22]!==k||e[23]!==c?(x=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:l,onClick:k,size:"sm",type:"button",variant:"outline",children:c("Disable two-factor")}),e[20]=l,e[21]=n.twoFactor,e[22]=k,e[23]=c,e[24]=x):x=e[24];let N;e[25]!==n.passkey||e[26]!==d||e[27]!==c?(N=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:c("No passkeys.")}),e[25]=n.passkey,e[26]=d,e[27]=c,e[28]=N):N=e[28];let p;e[29]!==l||e[30]!==n.passkey||e[31]!==r||e[32]!==d||e[33]!==c?(p=n.passkey&&d!==null&&d.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-passkeys-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:c("name")}),t(U,{children:c("created")}),t(U,{"aria-label":c("Actions")})]})}),t(Te,{children:d.map(S=>{const T=Pe(S.id);return u(Q,{"data-testid":`ud-passkey-${T}`,children:[t(P,{children:Pe(S.name)||T}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(S.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${T}`,disabled:l,onClick:()=>{r(T)},size:"xs",type:"button",variant:"ghost",children:c("Delete")})})]},T)})})]})})}),e[29]=l,e[30]=n.passkey,e[31]=r,e[32]=d,e[33]=c,e[34]=p):p=e[34];let i;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==p?(i=u("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,p]}),e[35]=b,e[36]=x,e[37]=N,e[38]=p,e[39]=i):i=e[39],i},pt=/(?:at|expires)$/iu,vt=/^[1-9]\d*$/u,gt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),bt=h=>{const e=Z(51),{busy:l,onBan:n}=h,o=W(),[s,f]=I(""),[a,c]=I(""),[d,y]=I(!1);let C;e[0]!==a?(C=vt.test(a.trim())&&Number.isSafeInteger(Number(a.trim())*86400)?Number(a.trim()):void 0,e[0]=a,e[1]=C):C=e[1];const g=C,w=d||g!==void 0;let k;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==g?(k=()=>{n({expiresInSeconds:d||g===void 0?void 0:g*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=g,e[6]=k):k=e[6];const v=k;let r;e[7]!==o?(r=o("Ban reason (optional)"),e[7]=o,e[8]=r):r=e[8];let m;e[9]!==r?(m=t(_,{htmlFor:"ud-ban-reason",children:r}),e[9]=r,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=$=>{f($.target.value)},e[11]=b):b=e[11];let x;e[12]!==s?(x=t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:s}),e[12]=s,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=u("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let p;e[17]!==o?(p=o("Days"),e[17]=o,e[18]=p):p=e[18];let i;e[19]!==p?(i=t(_,{htmlFor:"ud-ban-days",children:p}),e[19]=p,e[20]=i):i=e[20];let S;e[21]!==a||e[22]!==g?(S=a.trim()!==""&&g===void 0,e[21]=a,e[22]=g,e[23]=S):S=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=$=>{c($.target.value)},e[24]=T):T=e[24];let z;e[25]!==a||e[26]!==d||e[27]!==S?(z=t(B,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:T,step:1,type:"number",value:a}),e[25]=a,e[26]=d,e[27]=S,e[28]=z):z=e[28];let j;e[29]!==z||e[30]!==i?(j=u("div",{className:"flex w-24 flex-col gap-1",children:[i,z]}),e[29]=z,e[30]=i,e[31]=j):j=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=$=>{y($.target.checked)},e[32]=M):M=e[32];let H;e[33]!==d?(H=t("input",{checked:d,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=d,e[34]=H):H=e[34];let L;e[35]!==o?(L=o("Permanent"),e[35]=o,e[36]=L):L=e[36];let V;e[37]!==H||e[38]!==L?(V=u(_,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,L]}),e[37]=H,e[38]=L,e[39]=V):V=e[39];const Y=l||!w;let E;e[40]!==o?(E=o("Ban user"),e[40]=o,e[41]=E):E=e[41];let O;e[42]!==v||e[43]!==Y||e[44]!==E?(O=t(R,{"data-testid":"ud-ban",disabled:Y,onClick:v,size:"sm",type:"button",variant:"destructive",children:E}),e[42]=v,e[43]=Y,e[44]=E,e[45]=O):O=e[45];let F;return e[46]!==j||e[47]!==V||e[48]!==O||e[49]!==N?(F=u("div",{className:"flex items-end gap-2",children:[N,j,V,O]}),e[46]=j,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},xt=(h,e)=>typeof e=="number"&&pt.test(h)?Fe(e):Pe(e),yt=({capabilities:h,onChanged:e,onClose:l,user:n})=>{const o=ee(),s=W(),f=n.banned===!0,[a,c]=I(null),[d,y]=I(!1),[C,g]=I(0),[w,k]=I(typeof n.role=="string"?n.role:""),[v,r]=I(""),[m,b]=I(null),[x,N]=I(!1),p=(F,$)=>{J((async()=>{y(!0),c(null);try{const Ue=await F();$?.refresh!==!1&&(g(te=>te+1),e()),$?.onResult?.(Ue)}catch(Ue){c(Ve(Ue))}y(!1)})())},i=F=>{k(F.target.value)},S=F=>{r(F.target.value)},T=()=>{const F=w.trim();F!==""&&p(async()=>{await o.setAuthUserRole({role:F,userId:n.id})})},z=F=>{p(async()=>{await o.banAuthUser({...F,userId:n.id})})},j=()=>{p(async()=>{await o.unbanAuthUser({userId:n.id})})},M=()=>{p(async()=>{await o.setAuthUserPassword({newPassword:v,userId:n.id}),r("")})},H=()=>{p(()=>o.impersonateAuthUser({userId:n.id}),{onResult:F=>{b(F.token)},refresh:!1})},L=()=>{p(async()=>{await o.revokeAuthUserSessions({userId:n.id})})},V=()=>{p(async()=>{await o.removeAuthUser({userId:n.id}),l()})},Y=()=>{N(!0)},E=()=>{N(!1)},O=Object.entries(n).filter(([F])=>!gt.has(F));return u(We,{label:s("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[u("div",{className:"flex items-start justify-between gap-2",children:[u("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:n.name??n.email??n.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:n.id}),u("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(q,{variant:"secondary",children:n.role}),f?t(q,{variant:"destructive",children:s("Banned")}):t(q,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(q,{variant:"secondary",children:s("verified")}):t(q,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:a}),h.admin&&u(K,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")})}),u(X,{className:"flex flex-col gap-3 p-3",children:[u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:i,value:w})]}),t(R,{"data-testid":"ud-set-role",disabled:d||w.trim()==="",onClick:T,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),f?t(R,{"data-testid":"ud-unban",disabled:d,onClick:j,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(bt,{busy:d,onBan:z}),u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),t(R,{"data-testid":"ud-set-password",disabled:d||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),u("div",{className:"flex flex-wrap gap-2",children:[t(R,{"data-testid":"ud-impersonate",disabled:d,onClick:H,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(R,{"data-testid":"ud-revoke-all",disabled:d,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),x?u(et,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:V,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:E,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:Y,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),m!==null&&u("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(_,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),t(mt,{busy:d,runAction:p,userId:n.id,version:C}),h.accounts&&t(ht,{busy:d,runAction:p,userId:n.id,version:C}),(h.twoFactor||h.passkey)&&t(ft,{busy:d,capabilities:h,runAction:p,userId:n.id,version:C}),u("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")}),t("dl",{className:"flex flex-col",children:O.map(([F,$])=>u("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),t("dd",{className:"m-0 font-mono text-xs break-words",children:xt(F,$)})]},F))})]})]})},Nt=50,jt=({pageSize:h=Nt}={})=>{const e=ee(),l=W(),[n,o]=I(""),[s,f]=I(""),[a,c]=I(0),d=Je(n),[y,C]=I(null),[g,w]=I(!1),{capabilities:k}=nt(),v=d.trim(),r=s.trim(),m=qe(["lunora-auth-users",v,r,h,a],()=>e.listAuthUsers({filterField:r===""?void 0:"role",filterValue:r===""?void 0:r,limit:h,offset:a,search:v===""?void 0:v}).then(i=>({...i,offset:a})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=()=>{m.refetch()};Ge(()=>m.poll(),!0);const p=y===null?null:b?.find(i=>i.id===y)??null;return u("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[u("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:i=>{o(i.target.value),c(0)},placeholder:l("Search by email or name…"),value:n}),t(B,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i=>{f(i.target.value),c(0)},placeholder:l("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{w(!0)},size:"sm",type:"button",children:l("New user")})]}),x!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&t(Ye,{description:l("Users who sign up to your app will appear here."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),b!==null&&b.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"us-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:l("id")}),t(U,{children:l("email")}),t(U,{children:l("name")}),t(U,{children:l("role")}),t(U,{children:l("status")}),t(U,{children:l("verified")}),t(U,{children:l("created")}),t(U,{"aria-label":l("Actions")})]})}),t(Te,{children:b.map(i=>u(Q,{"data-testid":`us-row-${i.id}`,children:[t(P,{className:"font-mono text-xs",children:i.id}),t(P,{children:i.email??""}),t(P,{children:i.name??""}),t(P,{children:typeof i.role=="string"&&i.role!==""?t(q,{variant:"secondary",children:i.role}):""}),t(P,{children:i.banned===!0?t(q,{variant:"destructive",children:l("Banned")}):t(q,{variant:"success",children:l("Active")})}),t(P,{children:i.emailVerified===!0?t(q,{variant:"success",children:l("yes")}):t(q,{variant:"outline",children:l("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${i.id}`,onClick:()=>{C(i.id)},size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},i.id))})]})})}),b!==null&&t(Xe,{count:b.length,offset:m.data?.offset??0,onOffsetChange:c,pageSize:h,prefix:"us",total:m.data?.total}),p!==null&&t(yt,{capabilities:k,onChanged:N,onClose:()=>{C(null)},user:p}),g&&t(ut,{onClose:()=>{w(!1)},onCreated:N}),k.inviteOnly&&t(rt,{})]})};export{jt as UsersPanel};
|
|
1
|
+
import{useState as I,useEffect as Me}from"react";import{B as q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as K,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as Ye}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as B}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Re,b as Q,c as U,d as Te,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{a as qe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{c as Z}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-CG7VvAvQ.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as ee}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{w as Ke,h as Fe,f as J,l as Pe,b as Ve}from"../packem_shared/internal-hIuTpSbx.mjs";import{A as Xe}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{jsxs as u,jsx as t,Fragment as et}from"react/jsx-runtime";import{C as tt}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as st}from"../packem_shared/use-async-submit-D0r7-m2J.mjs";const nt=()=>{const h=Z(3),{config:e,ready:l}=Qe();let n;return h[0]!==e.capabilities||h[1]!==l?(n={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=n):n=h[2],n},lt=(h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending",He=500,at=(h,e)=>{if(!URL.canParse(h.trim()))return null;const l=new URL(h.trim());return l.searchParams.set("email",e.email),l.searchParams.set("invite",e.token),l.toString()},it=h=>{const e=Z(34),{issued:l,onSignUpPageChange:n,signUpPage:o}=h,s=W(),[f,a]=I(null);let c;e[0]!==l||e[1]!==o?(c=at(o,l),e[0]=l,e[1]=o,e[2]=c):c=e[2];const d=c;let y;e[3]!==d?(y=()=>{const T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||T===void 0||J(T.writeText(d).then(()=>(a(d),!0)))},e[3]=d,e[4]=y):y=e[4];const C=y;let g;e[5]!==s?(g=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=g):g=e[6];let w;e[7]!==g?(w=t("p",{className:"text-sm",children:g}),e[7]=g,e[8]=w):w=e[8];const k=d===null;let v;e[9]!==s?(v=s("Your app's sign-up page"),e[9]=s,e[10]=v):v=e[10];let r;e[11]!==n?(r=T=>{n(T.target.value)},e[11]=n,e[12]=r):r=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==r?(m=t(B,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:r,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=r,e[17]=m):m=e[17];const b=d??"";let x;e[18]!==b?(x=t(B,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==f||e[21]!==d||e[22]!==s?(N=s(f!==null&&f===d?"Copied":"Copy"),e[20]=f,e[21]=d,e[22]=s,e[23]=N):N=e[23];let p;e[24]!==C||e[25]!==N?(p=t(R,{"data-testid":"sign-up-invitation-copy",onClick:C,type:"button",children:N}),e[24]=C,e[25]=N,e[26]=p):p=e[26];let i;e[27]!==x||e[28]!==p?(i=u("div",{className:"flex gap-2",children:[x,p]}),e[27]=x,e[28]=p,e[29]=i):i=e[29];let S;return e[30]!==i||e[31]!==w||e[32]!==m?(S=t(K,{children:u(X,{className:"flex flex-col gap-2 p-4",children:[w,m,i]})}),e[30]=i,e[31]=w,e[32]=m,e[33]=S):S=e[33],S},rt=()=>{const h=ee(),e=W(),[l,n]=I(""),[o,s]=I(null),[f,a]=I(null),[c,d]=I(()=>`${Ke(h.url)}/sign-up`),y=qe(["lunora-auth-sign-up-invitations",He],()=>h.listAuthSignUpInvitations({limit:He})),C=y.data?.rows??null,g=y.data?.total??0,w=()=>{const v=l.trim();v!==""&&(s(null),J((async()=>{try{const r=await h.createAuthSignUpInvitation({email:v}),m=typeof r.token=="string"?r.token:void 0;a(m===void 0?null:{email:v,token:m}),n(""),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})()))},k=v=>{s(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})())};return u("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[u("div",{children:[t("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),t("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed — send the invitee the one-time link yourself.")})]}),u("div",{className:"flex gap-2",children:[t(B,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:v=>{n(v.target.value)},placeholder:e("ada@example.com"),type:"email",value:l}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:w,type:"button",children:e("Invite")})]}),f!==null&&t(it,{issued:f,onSignUpPageChange:d,signUpPage:c},f.token),(o??y.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),C!==null&&C.length===0&&t(Ye,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&g>C.length&&t("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&t(K,{children:t(X,{className:"p-0",children:u(Ee,{children:[t(Re,{children:u(Q,{children:[t(U,{children:e("Email")}),t(U,{children:e("Status")}),t(U,{children:e("Expires")}),t(U,{children:e("Invited by")}),t(U,{})]})}),t(Te,{children:C.map(v=>{const r=lt(v,Date.now()),m=v.email??"";return u(Q,{"data-testid":`sign-up-invitation-${m}`,children:[t(P,{children:m}),u(P,{"data-testid":`sign-up-invitation-status-${m}`,children:[r==="spent"&&e("Accepted"),r==="expired"&&e("Expired"),r==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?Fe(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{k(m)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},ot={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=(h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),ct=(h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;const l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){const n=Number(l);return Number.isNaN(n)?void 0:{value:n}}return{value:l}}},ut=h=>{const e=Z(105),{onClose:l,onCreated:n}=h,o=ee(),s=W(),{config:f}=Qe(),{busy:a,error:c,run:d}=st(),[y,C]=I(""),[g,w]=I(""),[k,v]=I(""),[r,m]=I("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[x,N]=I(b);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=A=>{C(A.target.value)},e[1]=p):p=e[1];const i=p;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{w(A.target.value)},e[2]=S):S=e[2];const T=S;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const j=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{m(A.target.value)},e[4]=M):M=e[4];const H=M;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=(A,D)=>{N(G=>({...G,[A]:D}))},e[5]=L):L=e[5];const V=L;let Y;e[6]!==x?(Y=A=>x[A.name]??(A.type==="boolean"?!1:""),e[6]=x,e[7]=Y):Y=e[7];const E=Y;let O;if(e[8]!==f.userFields||e[9]!==E){let A;e[11]!==E?(A=D=>!D.required||dt(D,E(D)),e[11]=E,e[12]=A):A=e[12],O=f.userFields.every(A),e[8]=f.userFields,e[9]=E,e[10]=O}else O=e[10];const F=O;let $;e[13]!==a||e[14]!==y||e[15]!==g||e[16]!==F?($=!a&&y.trim()!==""&&g.trim()!==""&&F,e[13]=a,e[14]=y,e[15]=g,e[16]=F,e[17]=$):$=e[17];const Ue=$;let te;e[18]!==f.userFields||e[19]!==E?(te=()=>{const A={};for(const D of f.userFields){const G=ct(D,E(D));G!==void 0&&(A[D.name]=G.value)}return Object.keys(A).length===0?void 0:A},e[18]=f.userFields,e[19]=E,e[20]=te):te=e[20];const Be=te;let De;e[21]!==Be||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==l||e[26]!==n||e[27]!==k||e[28]!==r||e[29]!==d?(De=()=>{d(async()=>{await o.createAuthUser({data:Be(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:r.trim()===""?void 0:r.trim()}),n(),l()})},e[21]=Be,e[22]=o,e[23]=y,e[24]=g,e[25]=l,e[26]=n,e[27]=k,e[28]=r,e[29]=d,e[30]=De):De=e[30];const ze=De;let se;e[31]!==s?(se=s("Create user"),e[31]=s,e[32]=se):se=e[32];let ne;e[33]!==s?(ne=s("Create user"),e[33]=s,e[34]=ne):ne=e[34];let le;e[35]!==ne?(le=t("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=le):le=e[36];let ae;e[37]!==s?(ae=s("email"),e[37]=s,e[38]=ae):ae=e[38];let ie;e[39]!==ae?(ie=t(_,{htmlFor:"uc-email",children:ae}),e[39]=ae,e[40]=ie):ie=e[40];let re;e[41]!==y?(re=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:i,type:"email",value:y}),e[41]=y,e[42]=re):re=e[42];let oe;e[43]!==ie||e[44]!==re?(oe=u("div",{className:"flex flex-col gap-1",children:[ie,re]}),e[43]=ie,e[44]=re,e[45]=oe):oe=e[45];let de;e[46]!==s?(de=s("name"),e[46]=s,e[47]=de):de=e[47];let ce;e[48]!==de?(ce=t(_,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=ce):ce=e[49];let ue;e[50]!==g?(ue=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:g}),e[50]=g,e[51]=ue):ue=e[51];let me;e[52]!==ce||e[53]!==ue?(me=u("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[52]=ce,e[53]=ue,e[54]=me):me=e[54];let he;e[55]!==s?(he=s("Password (optional)"),e[55]=s,e[56]=he):he=e[56];let fe;e[57]!==he?(fe=t(_,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=fe):fe=e[58];let pe;e[59]!==k?(pe=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:j,type:"password",value:k}),e[59]=k,e[60]=pe):pe=e[60];let ve;e[61]!==fe||e[62]!==pe?(ve=u("div",{className:"flex flex-col gap-1",children:[fe,pe]}),e[61]=fe,e[62]=pe,e[63]=ve):ve=e[63];let ge;e[64]!==s?(ge=s("Role (optional)"),e[64]=s,e[65]=ge):ge=e[65];let be;e[66]!==ge?(be=t(_,{htmlFor:"uc-role",children:ge}),e[66]=ge,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=u("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let Ne;e[73]!==f.userFields||e[74]!==E||e[75]!==s?(Ne=f.userFields.length>0&&u("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")}),f.userFields.map(A=>{const D=`uc-field-${A.name}`,G=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const Oe=E(A)===!0;return u("label",{className:"flex items-center gap-2",htmlFor:D,children:[t(tt,{checked:Oe,"data-testid":D,id:D,onCheckedChange:Ze=>{V(A.name,Ze)}}),u("span",{className:"text-sm",children:[A.name,G]})]},A.name)}const je=E(A);return u("div",{className:"flex flex-col gap-1",children:[u(_,{htmlFor:D,children:[A.name,G]}),t(B,{"data-testid":D,id:D,onChange:Oe=>{V(A.name,Oe.target.value)},type:ot[A.type],value:typeof je=="string"?je:""})]},A.name)})]}),e[73]=f.userFields,e[74]=E,e[75]=s,e[76]=Ne):Ne=e[76];let ke;e[77]!==c?(ke=c!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:c}),e[77]=c,e[78]=ke):ke=e[78];let Ce;e[79]!==s?(Ce=s("Cancel"),e[79]=s,e[80]=Ce):Ce=e[80];let we;e[81]!==l||e[82]!==Ce?(we=t(R,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=l,e[82]=Ce,e[83]=we):we=e[83];const Le=!Ue;let Ae;e[84]!==a||e[85]!==s?(Ae=s(a?"Creating…":"Create"),e[84]=a,e[85]=s,e[86]=Ae):Ae=e[86];let Se;e[87]!==ze||e[88]!==Le||e[89]!==Ae?(Se=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:ze,size:"sm",type:"button",children:Ae}),e[87]=ze,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Ie;e[91]!==we||e[92]!==Se?(Ie=u("div",{className:"flex justify-end gap-2 pt-1",children:[we,Se]}),e[91]=we,e[92]=Se,e[93]=Ie):Ie=e[93];let $e;return e[94]!==l||e[95]!==se||e[96]!==le||e[97]!==oe||e[98]!==me||e[99]!==ve||e[100]!==ye||e[101]!==Ne||e[102]!==ke||e[103]!==Ie?($e=u(We,{label:se,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[le,oe,me,ve,ye,Ne,ke,Ie]}),e[94]=l,e[95]=se,e[96]=le,e[97]=oe,e[98]=me,e[99]=ve,e[100]=ye,e[101]=Ne,e[102]=ke,e[103]=Ie,e[104]=$e):$e=e[104],$e},_e=h=>{const e=Z(2),{children:l}=h;let n;return e[0]!==l?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=n):n=e[1],n},mt=h=>{const e=Z(29),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{const i=await f.listAuthSessions({limit:50,userId:o});d(i.rows)}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n?(k=i=>{n(()=>f.revokeAuthSession({sessionId:i}))},e[7]=f,e[8]=n,e[9]=k):k=e[9];const v=k;let r;e[10]!==a?(r=a("Sessions"),e[10]=a,e[11]=r):r=e[11];let m;e[12]!==r?(m=t(_e,{children:r}),e[12]=r,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==c||e[17]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:a("No active sessions.")}),e[16]=c,e[17]=a,e[18]=x):x=e[18];let N;e[19]!==l||e[20]!==v||e[21]!==c||e[22]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-sessions-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("expires")}),t(U,{children:a("ip")}),t(U,{children:a("user agent")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>u(Q,{"data-testid":`ud-session-${i.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.expiresAt)}),t(P,{children:i.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:i.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${i.id}`,disabled:l,onClick:()=>{v(i.id)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[19]=l,e[20]=v,e[21]=c,e[22]=a,e[23]=N):N=e[23];let p;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=p):p=e[28],p},ht=h=>{const e=Z(30),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{d(await f.listAuthAccounts({userId:o}))}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n||e[9]!==o?(k=i=>{n(()=>f.unlinkAuthAccount({accountId:i,userId:o}))},e[7]=f,e[8]=n,e[9]=o,e[10]=k):k=e[10];const v=k;let r;e[11]!==a?(r=a("Linked accounts"),e[11]=a,e[12]=r):r=e[12];let m;e[13]!==r?(m=t(_e,{children:r}),e[13]=r,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==c||e[18]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No linked accounts.")}),e[17]=c,e[18]=a,e[19]=x):x=e[19];let N;e[20]!==c||e[21]!==l||e[22]!==v||e[23]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-accounts-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("provider")}),t(U,{children:a("created")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>{const S=Pe(i.id);return u(Q,{"data-testid":`ud-account-${S}`,children:[t(P,{children:Pe(i.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${S}`,disabled:l,onClick:()=>{v(S)},size:"xs",type:"button",variant:"ghost",children:a("Unlink")})})]},S)})})]})})}),e[20]=c,e[21]=l,e[22]=v,e[23]=a,e[24]=N):N=e[24];let p;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=p):p=e[29],p},ft=h=>{const e=Z(40),{busy:l,capabilities:n,runAction:o,userId:s,version:f}=h,a=ee(),c=W(),[d,y]=I(null);let C;e[0]!==n.passkey||e[1]!==a||e[2]!==s?(C=()=>{n.passkey&&J((async()=>{try{y(await a.listAuthPasskeys({userId:s}))}catch{y(null)}})())},e[0]=n.passkey,e[1]=a,e[2]=s,e[3]=C):C=e[3];let g;e[4]!==n.passkey||e[5]!==a||e[6]!==s||e[7]!==f?(g=[n.passkey,a,s,f],e[4]=n.passkey,e[5]=a,e[6]=s,e[7]=f,e[8]=g):g=e[8],Me(C,g);let w;e[9]!==a||e[10]!==o||e[11]!==s?(w=()=>{o(()=>a.disableAuthTwoFactor({userId:s}))},e[9]=a,e[10]=o,e[11]=s,e[12]=w):w=e[12];const k=w;let v;e[13]!==a||e[14]!==o?(v=S=>{o(()=>a.deleteAuthPasskey({passkeyId:S}))},e[13]=a,e[14]=o,e[15]=v):v=e[15];const r=v;let m;e[16]!==c?(m=c("Security"),e[16]=c,e[17]=m):m=e[17];let b;e[18]!==m?(b=t(_e,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==l||e[21]!==n.twoFactor||e[22]!==k||e[23]!==c?(x=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:l,onClick:k,size:"sm",type:"button",variant:"outline",children:c("Disable two-factor")}),e[20]=l,e[21]=n.twoFactor,e[22]=k,e[23]=c,e[24]=x):x=e[24];let N;e[25]!==n.passkey||e[26]!==d||e[27]!==c?(N=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:c("No passkeys.")}),e[25]=n.passkey,e[26]=d,e[27]=c,e[28]=N):N=e[28];let p;e[29]!==l||e[30]!==n.passkey||e[31]!==r||e[32]!==d||e[33]!==c?(p=n.passkey&&d!==null&&d.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-passkeys-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:c("name")}),t(U,{children:c("created")}),t(U,{"aria-label":c("Actions")})]})}),t(Te,{children:d.map(S=>{const T=Pe(S.id);return u(Q,{"data-testid":`ud-passkey-${T}`,children:[t(P,{children:Pe(S.name)||T}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(S.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${T}`,disabled:l,onClick:()=>{r(T)},size:"xs",type:"button",variant:"ghost",children:c("Delete")})})]},T)})})]})})}),e[29]=l,e[30]=n.passkey,e[31]=r,e[32]=d,e[33]=c,e[34]=p):p=e[34];let i;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==p?(i=u("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,p]}),e[35]=b,e[36]=x,e[37]=N,e[38]=p,e[39]=i):i=e[39],i},pt=/(?:at|expires)$/iu,vt=/^[1-9]\d*$/u,gt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),bt=h=>{const e=Z(51),{busy:l,onBan:n}=h,o=W(),[s,f]=I(""),[a,c]=I(""),[d,y]=I(!1);let C;e[0]!==a?(C=vt.test(a.trim())&&Number.isSafeInteger(Number(a.trim())*86400)?Number(a.trim()):void 0,e[0]=a,e[1]=C):C=e[1];const g=C,w=d||g!==void 0;let k;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==g?(k=()=>{n({expiresInSeconds:d||g===void 0?void 0:g*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=g,e[6]=k):k=e[6];const v=k;let r;e[7]!==o?(r=o("Ban reason (optional)"),e[7]=o,e[8]=r):r=e[8];let m;e[9]!==r?(m=t(_,{htmlFor:"ud-ban-reason",children:r}),e[9]=r,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=$=>{f($.target.value)},e[11]=b):b=e[11];let x;e[12]!==s?(x=t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:s}),e[12]=s,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=u("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let p;e[17]!==o?(p=o("Days"),e[17]=o,e[18]=p):p=e[18];let i;e[19]!==p?(i=t(_,{htmlFor:"ud-ban-days",children:p}),e[19]=p,e[20]=i):i=e[20];let S;e[21]!==a||e[22]!==g?(S=a.trim()!==""&&g===void 0,e[21]=a,e[22]=g,e[23]=S):S=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=$=>{c($.target.value)},e[24]=T):T=e[24];let z;e[25]!==a||e[26]!==d||e[27]!==S?(z=t(B,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:T,step:1,type:"number",value:a}),e[25]=a,e[26]=d,e[27]=S,e[28]=z):z=e[28];let j;e[29]!==z||e[30]!==i?(j=u("div",{className:"flex w-24 flex-col gap-1",children:[i,z]}),e[29]=z,e[30]=i,e[31]=j):j=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=$=>{y($.target.checked)},e[32]=M):M=e[32];let H;e[33]!==d?(H=t("input",{checked:d,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=d,e[34]=H):H=e[34];let L;e[35]!==o?(L=o("Permanent"),e[35]=o,e[36]=L):L=e[36];let V;e[37]!==H||e[38]!==L?(V=u(_,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,L]}),e[37]=H,e[38]=L,e[39]=V):V=e[39];const Y=l||!w;let E;e[40]!==o?(E=o("Ban user"),e[40]=o,e[41]=E):E=e[41];let O;e[42]!==v||e[43]!==Y||e[44]!==E?(O=t(R,{"data-testid":"ud-ban",disabled:Y,onClick:v,size:"sm",type:"button",variant:"destructive",children:E}),e[42]=v,e[43]=Y,e[44]=E,e[45]=O):O=e[45];let F;return e[46]!==j||e[47]!==V||e[48]!==O||e[49]!==N?(F=u("div",{className:"flex items-end gap-2",children:[N,j,V,O]}),e[46]=j,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},xt=(h,e)=>typeof e=="number"&&pt.test(h)?Fe(e):Pe(e),yt=({capabilities:h,onChanged:e,onClose:l,user:n})=>{const o=ee(),s=W(),f=n.banned===!0,[a,c]=I(null),[d,y]=I(!1),[C,g]=I(0),[w,k]=I(typeof n.role=="string"?n.role:""),[v,r]=I(""),[m,b]=I(null),[x,N]=I(!1),p=(F,$)=>{J((async()=>{y(!0),c(null);try{const Ue=await F();$?.refresh!==!1&&(g(te=>te+1),e()),$?.onResult?.(Ue)}catch(Ue){c(Ve(Ue))}y(!1)})())},i=F=>{k(F.target.value)},S=F=>{r(F.target.value)},T=()=>{const F=w.trim();F!==""&&p(async()=>{await o.setAuthUserRole({role:F,userId:n.id})})},z=F=>{p(async()=>{await o.banAuthUser({...F,userId:n.id})})},j=()=>{p(async()=>{await o.unbanAuthUser({userId:n.id})})},M=()=>{p(async()=>{await o.setAuthUserPassword({newPassword:v,userId:n.id}),r("")})},H=()=>{p(()=>o.impersonateAuthUser({userId:n.id}),{onResult:F=>{b(F.token)},refresh:!1})},L=()=>{p(async()=>{await o.revokeAuthUserSessions({userId:n.id})})},V=()=>{p(async()=>{await o.removeAuthUser({userId:n.id}),l()})},Y=()=>{N(!0)},E=()=>{N(!1)},O=Object.entries(n).filter(([F])=>!gt.has(F));return u(We,{label:s("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[u("div",{className:"flex items-start justify-between gap-2",children:[u("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:n.name??n.email??n.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:n.id}),u("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(q,{variant:"secondary",children:n.role}),f?t(q,{variant:"destructive",children:s("Banned")}):t(q,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(q,{variant:"secondary",children:s("verified")}):t(q,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:a}),h.admin&&u(K,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")})}),u(X,{className:"flex flex-col gap-3 p-3",children:[u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:i,value:w})]}),t(R,{"data-testid":"ud-set-role",disabled:d||w.trim()==="",onClick:T,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),f?t(R,{"data-testid":"ud-unban",disabled:d,onClick:j,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(bt,{busy:d,onBan:z}),u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),t(R,{"data-testid":"ud-set-password",disabled:d||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),u("div",{className:"flex flex-wrap gap-2",children:[t(R,{"data-testid":"ud-impersonate",disabled:d,onClick:H,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(R,{"data-testid":"ud-revoke-all",disabled:d,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),x?u(et,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:V,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:E,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:Y,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),m!==null&&u("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(_,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),t(mt,{busy:d,runAction:p,userId:n.id,version:C}),h.accounts&&t(ht,{busy:d,runAction:p,userId:n.id,version:C}),(h.twoFactor||h.passkey)&&t(ft,{busy:d,capabilities:h,runAction:p,userId:n.id,version:C}),u("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")}),t("dl",{className:"flex flex-col",children:O.map(([F,$])=>u("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),t("dd",{className:"m-0 font-mono text-xs break-words",children:xt(F,$)})]},F))})]})]})},Nt=50,jt=({pageSize:h=Nt}={})=>{const e=ee(),l=W(),[n,o]=I(""),[s,f]=I(""),[a,c]=I(0),d=Je(n),[y,C]=I(null),[g,w]=I(!1),{capabilities:k}=nt(),v=d.trim(),r=s.trim(),m=qe(["lunora-auth-users",v,r,h,a],()=>e.listAuthUsers({filterField:r===""?void 0:"role",filterValue:r===""?void 0:r,limit:h,offset:a,search:v===""?void 0:v}).then(i=>({...i,offset:a})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=()=>{m.refetch()};Ge(()=>m.poll(),!0);const p=y===null?null:b?.find(i=>i.id===y)??null;return u("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[u("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:i=>{o(i.target.value),c(0)},placeholder:l("Search by email or name…"),value:n}),t(B,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i=>{f(i.target.value),c(0)},placeholder:l("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{w(!0)},size:"sm",type:"button",children:l("New user")})]}),x!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&t(Ye,{description:l("Users who sign up to your app will appear here."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),b!==null&&b.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"us-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:l("id")}),t(U,{children:l("email")}),t(U,{children:l("name")}),t(U,{children:l("role")}),t(U,{children:l("status")}),t(U,{children:l("verified")}),t(U,{children:l("created")}),t(U,{"aria-label":l("Actions")})]})}),t(Te,{children:b.map(i=>u(Q,{"data-testid":`us-row-${i.id}`,children:[t(P,{className:"font-mono text-xs",children:i.id}),t(P,{children:i.email??""}),t(P,{children:i.name??""}),t(P,{children:typeof i.role=="string"&&i.role!==""?t(q,{variant:"secondary",children:i.role}):""}),t(P,{children:i.banned===!0?t(q,{variant:"destructive",children:l("Banned")}):t(q,{variant:"success",children:l("Active")})}),t(P,{children:i.emailVerified===!0?t(q,{variant:"success",children:l("yes")}):t(q,{variant:"outline",children:l("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${i.id}`,onClick:()=>{C(i.id)},size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},i.id))})]})})}),b!==null&&t(Xe,{count:b.length,offset:m.data?.offset??0,onOffsetChange:c,pageSize:h,prefix:"us",total:m.data?.total}),p!==null&&t(yt,{capabilities:k,onChanged:N,onClose:()=>{C(null)},user:p}),g&&t(ut,{onClose:()=>{w(!1)},onCreated:N}),k.inviteOnly&&t(rt,{})]})};export{jt as UsersPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as y}from"react/compiler-runtime";import{useRef as F,useEffect as E}from"react";import{i as P}from"./internal-hIuTpSbx.mjs";import{u as T}from"./use-studio-client-DCA50tF2.mjs";const g=6e4,D=e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function",j=5e3,v=(e,s,r,c)=>{const t=y(10),o=r===void 0?j:r,m=T(),d=F(e);let i;t[0]!==e?(i=()=>{d.current=e},t[0]=e,t[1]=i):i=t[1],E(i);let n;t[2]!==s||t[3]!==o?(n=()=>{if(!s)return;let f=o,h=!1,p;const u=()=>{h||(p=setTimeout(R,f))},_=()=>{f=o,u()},M=A=>{P(A)||(f=Math.max(o,Math.min(f*2,g)),u())},R=()=>{if(globalThis.document?.hidden===!0){u();return}let a;try{a=d.current()}catch(S){M(S);return}D(a)?Promise.resolve(a).then(_).catch(M):_()};return u(),()=>{h=!0,clearTimeout(p)}},t[2]=s,t[3]=o,t[4]=n):n=t[4];let l;t[5]!==m||t[6]!==s||t[7]!==o||t[8]!==c?(l=[m,s,o,c],t[5]=m,t[6]=s,t[7]=o,t[8]=c,t[9]=l):l=t[9],E(n,l)},B=async e=>{const r=(await Promise.allSettled(e)).find(c=>c.status==="rejected");if(r!==void 0)throw r.reason};export{j as DEFAULT_AUTO_REFRESH_MS,B as settlePolls,v as useAutoRefresh};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as B}from"react/compiler-runtime";import{useState as $,useEffect as ze,useMemo as $t,useRef as Ke,useCallback as ct}from"react";import{ShardInput as Gn}from"./ShardInput-CoySruKZ.mjs";import{u as Ze}from"./use-admin-query-CaOm4JS3.mjs";import{u as Jn}from"./use-assistant-rpc-DCC6ph2u.mjs";import{u as Xe}from"./use-mirrored-ref-CVDf2z1M.mjs";import{u as ut}from"./use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as he}from"./ADMIN_FUNCTIONS-C6U-ugro.mjs";import{b as nn}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,l as Me,k as on,b as zt,c as $e,d as Re,o as Wn,h as Hn}from"./internal-hIuTpSbx.mjs";import{m as Un,b as sn,c as Nt,u as Qn,a as Yn,T as Xn,D as Zn}from"./table-list-sidebar-DUnCjFL7.mjs";import{decodeWire as Pt,isPlainObject as ln,encodeWire as rn,decodeDocument as eo}from"@lunora/wire";import{B as kt}from"./button-q0UYSmrn.mjs";import{I as to}from"./input-CXhxesPC.mjs";import{L as qt}from"./label-DKFzyHq6.mjs";import{M as ft}from"./modal-shell-CDztwLnv.mjs";import{useT as ve}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as d,jsxs as E,Fragment as et}from"react/jsx-runtime";import{ConfirmButton as Kt}from"./ConfirmButton-CIXYF6Mg.mjs";import{E as no}from"./empty-state-D7jEML_T.mjs";import{C as Dt,a as Pe}from"./control-button-BOZ5K-FC.mjs";import{tableFeatures as oo,sortFn_text as so,sortFn_datetime as lo,sortFn_basic as ro,sortFn_alphanumeric as ao,rowSortingFeature as io,rowSelectionFeature as co,columnVisibilityFeature as uo,columnSizingFeature as fo,columnResizingFeature as mo,columnOrderingFeature as go,createSortedRowModel as po,useTable as bo,flexRender as ho}from"@tanstack/react-table";import{useVirtualizer as xo}from"@tanstack/react-virtual";import{C as It}from"./checkbox-CnS9cyCz.mjs";import{c as dt}from"./utils-bhneXptQ.mjs";import{f as vo}from"./virtual-rect-D_j7aLxX.mjs";import{C as Tt,G as wo,T as yo}from"./data-grid-B5m1OosL.mjs";import{DataFilters as Co,toFilterClauses as Fe}from"./DataFilters--ocFTVT2.mjs";import{G as So,C as No}from"./grid-features-Drvfswwy.mjs";import{G as ko}from"./grid-pagination-DY2erU65.mjs";import Gt from"./useDebounced-DVeQ5-oW.mjs";import{r as To,l as Eo}from"./shard-history-CaO3C4KQ.mjs";const _o=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,onDelete:o.onDelete,references:o.ref,table:e}))}))}),Ro=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},$o=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},Jt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Ot=s=>`${s.table}.${s.column}`,Do=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=ve(),[u,m]=$(n[0]??""),[p,b]=$("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=re=>{m(re.target.value)},e[0]=f):f=e[0];const g=f;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=re=>{b(re.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const y=v==="";let S,C;if(e[4]!==y||e[5]!==i||e[6]!==p){if(!y)try{C=Pt(JSON.parse(p))}catch(re){S=i("Invalid JSON: {message}",{message:re.message})}e[4]=y,e[5]=i,e[6]=p,e[7]=S,e[8]=C}else S=e[7],C=e[8];let k;e[9]!==u||e[10]!==r||e[11]!==a?(k=a.has(u)&&r>1,e[9]=u,e[10]=r,e[11]=a,e[12]=k):k=e[12];const N=k,w=u!==""&&!y&&S===void 0&&!N;let T;e[13]!==w||e[14]!==u||e[15]!==o||e[16]!==t||e[17]!==C?(T=()=>{w&&(o({[u]:C}),t())},e[13]=w,e[14]=u,e[15]=o,e[16]=t,e[17]=C,e[18]=T):T=e[18];const F=T;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let D;e[23]!==_?(D=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=D):D=e[24];let O;e[25]!==i||e[26]!==l||e[27]!==r?(O=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=O):O=e[28];let V;e[29]!==O?(V=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:O}),e[29]=O,e[30]=V):V=e[30];let A;e[31]!==c||e[32]!==i?(A=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=A):A=e[33];let L;e[34]!==A?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:A}),e[34]=A,e[35]=L):L=e[35];let G;e[36]!==V||e[37]!==L||e[38]!==D?(G=E("div",{className:"flex flex-col gap-0.5",children:[D,V,L]}),e[36]=V,e[37]=L,e[38]=D,e[39]=G):G=e[39];let q;e[40]!==i?(q=i("Close"),e[40]=i,e[41]=q):q=e[41];let P;e[42]!==t||e[43]!==q?(P=d(kt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:q}),e[42]=t,e[43]=q,e[44]=P):P=e[44];let J;e[45]!==G||e[46]!==P?(J=E("div",{className:"flex items-start justify-between",children:[G,P]}),e[45]=G,e[46]=P,e[47]=J):J=e[47];let K;e[48]!==i?(K=i("Column"),e[48]=i,e[49]=K):K=e[49];let H;e[50]!==K?(H=d(qt,{htmlFor:"bulk-patch-column",children:K}),e[50]=K,e[51]=H):H=e[51];let Y;e[52]!==i?(Y=i("Column"),e[52]=i,e[53]=Y):Y=e[53];let U;e[54]!==n?(U=n.map(Ao),e[54]=n,e[55]=U):U=e[55];let ne;e[56]!==u||e[57]!==Y||e[58]!==U?(ne=d("select",{"aria-label":Y,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:u,children:U}),e[56]=u,e[57]=Y,e[58]=U,e[59]=ne):ne=e[59];let le;e[60]!==i?(le=i("Value"),e[60]=i,e[61]=le):le=e[61];let ae;e[62]!==le?(ae=d(qt,{htmlFor:"bulk-patch-value",children:le}),e[62]=le,e[63]=ae):ae=e[63];let ge;e[64]!==p?(ge=d(to,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=ge):ge=e[65];let fe;e[66]!==H||e[67]!==ne||e[68]!==ae||e[69]!==ge?(fe=E("div",{className:"flex items-center gap-2",children:[H,ne,ae,ge]}),e[66]=H,e[67]=ne,e[68]=ae,e[69]=ge,e[70]=fe):fe=e[70];let me;e[71]!==S?(me=S!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:S}),e[71]=S,e[72]=me):me=e[72];let pe;e[73]!==u||e[74]!==i||e[75]!==r||e[76]!==N?(pe=N&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:u,total:r.toString()})}),e[73]=u,e[74]=i,e[75]=r,e[76]=N,e[77]=pe):pe=e[77];let ie;e[78]!==y||e[79]!==i||e[80]!==N?(ie=y&&!N&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=y,e[79]=i,e[80]=N,e[81]=ie):ie=e[81];let Q;e[82]!==w||e[83]!==u||e[84]!==p?(Q=w&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${u} = ${p.trim()}`}),e[82]=w,e[83]=u,e[84]=p,e[85]=Q):Q=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let ce;e[88]!==t||e[89]!==be?(ce=d(kt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=ce):ce=e[90];const Se=!w;let oe;e[91]!==i||e[92]!==r?(oe=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=oe):oe=e[93];let se;e[94]!==F||e[95]!==Se||e[96]!==oe?(se=d(kt,{"data-testid":"bulk-patch-apply",disabled:Se,onClick:F,size:"xs",children:oe}),e[94]=F,e[95]=Se,e[96]=oe,e[97]=se):se=e[97];let W;e[98]!==ce||e[99]!==se?(W=E("div",{className:"flex justify-end gap-2",children:[ce,se]}),e[98]=ce,e[99]=se,e[100]=W):W=e[100];let j;return e[101]!==t||e[102]!==J||e[103]!==fe||e[104]!==me||e[105]!==pe||e[106]!==ie||e[107]!==Q||e[108]!==W||e[109]!==R?(j=E(ft,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,fe,me,pe,ie,Q,W]}),e[101]=t,e[102]=J,e[103]=fe,e[104]=me,e[105]=pe,e[106]=ie,e[107]=Q,e[108]=W,e[109]=R,e[110]=j):j=e[110],j};function Ao(s){return d("option",{value:s,children:s},s)}const Wt=6,at=100,Po=s=>({paddingLeft:s*16}),Io=s=>{const e=B(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},Oo=s=>{const e=B(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},Fo=s=>{const e=B(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},Mo=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(Oo,{table:s.table}):s.isRestrict?d(Io,{table:s.table}):d(Fo,{table:s.table}),an=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=Po(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let u;e[11]!==i?(u=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=u):u=e[12];let m;e[13]!==o?(m=Mo(o),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==u||e[24]!==m||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,u,m,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=u,e[24]=m,e[25]=p,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(an,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],f=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=f}else f=e[29];let g;return e[32]!==b||e[33]!==f?(g=E(et,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=g):g=e[34],g},Vo=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},Lo=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>Vo(a)||[]).slice(0,at),l=t.total??0;return{capNote:l>at?`showing first ${at.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},cn=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await Lo(s,n.field,e,l),u=n?.onDelete==="restrict",m=[],p=`${s}:${e}`,b=c>=Wt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await cn(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&m.push(v)}t.delete(p)}let f=r;if(b){const g=`depth capped at ${Wt.toString()}`;f=r===void 0?g:`${r}; ${g}`}return{capNote:f,children:m,isRestrict:u,relation:n,rowCount:a,rowIds:i,table:s}},Bo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=ve(),[r,a]=$(!0),[i,u]=$(null),[m,p]=$(null);ze(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=Ro(t);if(!((x.get(c)??[]).length>0)){g||(u({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const y=await cn(c,o,void 0,x,new Set,0,n);g||(u(y),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&$o(i,g=>g.isRestrict).length>0,f=()=>{e(),s()};return E(ft,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),m!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(an,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:f,type:"button",children:l("Delete")})]})]})},jo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(m=>m.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,u=0;for(const m of s){const p=m.getSize(),b=e.has(m.id),f=a+p>c&&a<l;b||f?r.add(m.id):a<c?i+=p:u+=p,a+=p}return{ids:r,leadPx:i,tailPx:u}},zo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},qo=oo({columnOrderingFeature:go,columnResizingFeature:mo,columnSizingFeature:fo,columnVisibilityFeature:uo,rowSelectionFeature:co,rowSortingFeature:io,sortedRowModel:po(),sortFns:{alphanumeric:ao,basic:ro,datetime:lo,text:so}}),Ko=()=>{const s=B(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const y=Object.fromEntries(Object.entries(v).filter(S=>{const[C,k]=S;return!(C in h)||!Object.is(k,h[C])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(x).filter(S=>{const[C]=S;return C!==g})):{...x,[g]:y}})},s[3]=a):a=s[3];const i=a;let u;s[4]!==n?(u=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=u):u=s[5];const m=u;let p;s[6]!==n?(p=Object.values(n).reduce(Jo,0),s[6]=n,s[7]=p):p=s[7];const b=p;let f;return s[8]!==b||s[9]!==n||s[10]!==m?(f={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:m},s[8]=b,s[9]=n,s[10]=m,s[11]=f):f=s[11],f},dn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Go=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=ve();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let u;e[8]!==o||e[9]!==t||e[10]!==i?(u=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=u):u=e[11];let m;e[12]!==l?(m=l("Discard"),e[12]=l,e[13]=m):m=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==m?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:m}),e[14]=o,e[15]=c,e[16]=m,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==u||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,u,p]}),e[18]=a,e[19]=u,e[20]=p,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(Wo),e[22]=n,e[23]=f):f=e[23];let g;e[24]!==f?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function Jo(s,e){return s+Object.keys(e).length}function Wo(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:Me(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:Me(s.newValue)})]},`${s.rowId}:${s.column}`)}const Ht=400,Ho=36,Uo={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Qo={width:"100%"},Yo=/\n$/u,Xo={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Zo={display:"flex",width:"100%"},Ut={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},es="2.5rem",un={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},Ft=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),fn=(s,e)=>({...Ft(s),left:`calc(${es} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Et="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",ts=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,At="__back__:",ns=s=>`${At}${s.table}.${s.column}`,os=s=>{const e=B(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Ie=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},ss=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},ls=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return ss(s,n);const o=dn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},rs=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
|
|
1
|
+
import{c as B}from"react/compiler-runtime";import{useState as $,useEffect as ze,useMemo as $t,useRef as Ke,useCallback as ct}from"react";import{ShardInput as Gn}from"./ShardInput-CoySruKZ.mjs";import{u as Ze}from"./use-admin-query-CaOm4JS3.mjs";import{u as Jn}from"./use-assistant-rpc-DCC6ph2u.mjs";import{u as Xe}from"./use-mirrored-ref-CVDf2z1M.mjs";import{u as ut}from"./use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as he}from"./ADMIN_FUNCTIONS-C6U-ugro.mjs";import{b as nn}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,l as Me,k as on,b as zt,c as $e,d as Re,o as Wn,h as Hn}from"./internal-hIuTpSbx.mjs";import{m as Un,b as sn,c as Nt,u as Qn,a as Yn,T as Xn,D as Zn}from"./table-list-sidebar-C8qPvzGk.mjs";import{decodeWire as Pt,isPlainObject as ln,encodeWire as rn,decodeDocument as eo}from"@lunora/wire";import{B as kt}from"./button-q0UYSmrn.mjs";import{I as to}from"./input-CXhxesPC.mjs";import{L as qt}from"./label-DKFzyHq6.mjs";import{M as ft}from"./modal-shell-CDztwLnv.mjs";import{useT as ve}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as d,jsxs as E,Fragment as et}from"react/jsx-runtime";import{ConfirmButton as Kt}from"./ConfirmButton-CIXYF6Mg.mjs";import{E as no}from"./empty-state-D7jEML_T.mjs";import{C as Dt,a as Pe}from"./control-button-BOZ5K-FC.mjs";import{tableFeatures as oo,sortFn_text as so,sortFn_datetime as lo,sortFn_basic as ro,sortFn_alphanumeric as ao,rowSortingFeature as io,rowSelectionFeature as co,columnVisibilityFeature as uo,columnSizingFeature as fo,columnResizingFeature as mo,columnOrderingFeature as go,createSortedRowModel as po,useTable as bo,flexRender as ho}from"@tanstack/react-table";import{useVirtualizer as xo}from"@tanstack/react-virtual";import{C as It}from"./checkbox-CnS9cyCz.mjs";import{c as dt}from"./utils-bhneXptQ.mjs";import{f as vo}from"./virtual-rect-D_j7aLxX.mjs";import{C as Tt,G as wo,T as yo}from"./data-grid-B5m1OosL.mjs";import{DataFilters as Co,toFilterClauses as Fe}from"./DataFilters--ocFTVT2.mjs";import{G as So,C as No}from"./grid-features-Drvfswwy.mjs";import{G as ko}from"./grid-pagination-DY2erU65.mjs";import Gt from"./useDebounced-DVeQ5-oW.mjs";import{r as To,l as Eo}from"./shard-history-CaO3C4KQ.mjs";const _o=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,onDelete:o.onDelete,references:o.ref,table:e}))}))}),Ro=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},$o=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},Jt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Ot=s=>`${s.table}.${s.column}`,Do=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=ve(),[u,m]=$(n[0]??""),[p,b]=$("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=re=>{m(re.target.value)},e[0]=f):f=e[0];const g=f;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=re=>{b(re.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const y=v==="";let S,C;if(e[4]!==y||e[5]!==i||e[6]!==p){if(!y)try{C=Pt(JSON.parse(p))}catch(re){S=i("Invalid JSON: {message}",{message:re.message})}e[4]=y,e[5]=i,e[6]=p,e[7]=S,e[8]=C}else S=e[7],C=e[8];let k;e[9]!==u||e[10]!==r||e[11]!==a?(k=a.has(u)&&r>1,e[9]=u,e[10]=r,e[11]=a,e[12]=k):k=e[12];const N=k,w=u!==""&&!y&&S===void 0&&!N;let T;e[13]!==w||e[14]!==u||e[15]!==o||e[16]!==t||e[17]!==C?(T=()=>{w&&(o({[u]:C}),t())},e[13]=w,e[14]=u,e[15]=o,e[16]=t,e[17]=C,e[18]=T):T=e[18];const F=T;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let D;e[23]!==_?(D=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=D):D=e[24];let O;e[25]!==i||e[26]!==l||e[27]!==r?(O=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=O):O=e[28];let V;e[29]!==O?(V=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:O}),e[29]=O,e[30]=V):V=e[30];let A;e[31]!==c||e[32]!==i?(A=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=A):A=e[33];let L;e[34]!==A?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:A}),e[34]=A,e[35]=L):L=e[35];let G;e[36]!==V||e[37]!==L||e[38]!==D?(G=E("div",{className:"flex flex-col gap-0.5",children:[D,V,L]}),e[36]=V,e[37]=L,e[38]=D,e[39]=G):G=e[39];let q;e[40]!==i?(q=i("Close"),e[40]=i,e[41]=q):q=e[41];let P;e[42]!==t||e[43]!==q?(P=d(kt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:q}),e[42]=t,e[43]=q,e[44]=P):P=e[44];let J;e[45]!==G||e[46]!==P?(J=E("div",{className:"flex items-start justify-between",children:[G,P]}),e[45]=G,e[46]=P,e[47]=J):J=e[47];let K;e[48]!==i?(K=i("Column"),e[48]=i,e[49]=K):K=e[49];let H;e[50]!==K?(H=d(qt,{htmlFor:"bulk-patch-column",children:K}),e[50]=K,e[51]=H):H=e[51];let Y;e[52]!==i?(Y=i("Column"),e[52]=i,e[53]=Y):Y=e[53];let U;e[54]!==n?(U=n.map(Ao),e[54]=n,e[55]=U):U=e[55];let ne;e[56]!==u||e[57]!==Y||e[58]!==U?(ne=d("select",{"aria-label":Y,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:u,children:U}),e[56]=u,e[57]=Y,e[58]=U,e[59]=ne):ne=e[59];let le;e[60]!==i?(le=i("Value"),e[60]=i,e[61]=le):le=e[61];let ae;e[62]!==le?(ae=d(qt,{htmlFor:"bulk-patch-value",children:le}),e[62]=le,e[63]=ae):ae=e[63];let ge;e[64]!==p?(ge=d(to,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=ge):ge=e[65];let fe;e[66]!==H||e[67]!==ne||e[68]!==ae||e[69]!==ge?(fe=E("div",{className:"flex items-center gap-2",children:[H,ne,ae,ge]}),e[66]=H,e[67]=ne,e[68]=ae,e[69]=ge,e[70]=fe):fe=e[70];let me;e[71]!==S?(me=S!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:S}),e[71]=S,e[72]=me):me=e[72];let pe;e[73]!==u||e[74]!==i||e[75]!==r||e[76]!==N?(pe=N&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:u,total:r.toString()})}),e[73]=u,e[74]=i,e[75]=r,e[76]=N,e[77]=pe):pe=e[77];let ie;e[78]!==y||e[79]!==i||e[80]!==N?(ie=y&&!N&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=y,e[79]=i,e[80]=N,e[81]=ie):ie=e[81];let Q;e[82]!==w||e[83]!==u||e[84]!==p?(Q=w&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${u} = ${p.trim()}`}),e[82]=w,e[83]=u,e[84]=p,e[85]=Q):Q=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let ce;e[88]!==t||e[89]!==be?(ce=d(kt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=ce):ce=e[90];const Se=!w;let oe;e[91]!==i||e[92]!==r?(oe=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=oe):oe=e[93];let se;e[94]!==F||e[95]!==Se||e[96]!==oe?(se=d(kt,{"data-testid":"bulk-patch-apply",disabled:Se,onClick:F,size:"xs",children:oe}),e[94]=F,e[95]=Se,e[96]=oe,e[97]=se):se=e[97];let W;e[98]!==ce||e[99]!==se?(W=E("div",{className:"flex justify-end gap-2",children:[ce,se]}),e[98]=ce,e[99]=se,e[100]=W):W=e[100];let j;return e[101]!==t||e[102]!==J||e[103]!==fe||e[104]!==me||e[105]!==pe||e[106]!==ie||e[107]!==Q||e[108]!==W||e[109]!==R?(j=E(ft,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,fe,me,pe,ie,Q,W]}),e[101]=t,e[102]=J,e[103]=fe,e[104]=me,e[105]=pe,e[106]=ie,e[107]=Q,e[108]=W,e[109]=R,e[110]=j):j=e[110],j};function Ao(s){return d("option",{value:s,children:s},s)}const Wt=6,at=100,Po=s=>({paddingLeft:s*16}),Io=s=>{const e=B(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},Oo=s=>{const e=B(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},Fo=s=>{const e=B(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},Mo=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(Oo,{table:s.table}):s.isRestrict?d(Io,{table:s.table}):d(Fo,{table:s.table}),an=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=Po(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let u;e[11]!==i?(u=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=u):u=e[12];let m;e[13]!==o?(m=Mo(o),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==u||e[24]!==m||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,u,m,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=u,e[24]=m,e[25]=p,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(an,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],f=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=f}else f=e[29];let g;return e[32]!==b||e[33]!==f?(g=E(et,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=g):g=e[34],g},Vo=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},Lo=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>Vo(a)||[]).slice(0,at),l=t.total??0;return{capNote:l>at?`showing first ${at.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},cn=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await Lo(s,n.field,e,l),u=n?.onDelete==="restrict",m=[],p=`${s}:${e}`,b=c>=Wt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await cn(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&m.push(v)}t.delete(p)}let f=r;if(b){const g=`depth capped at ${Wt.toString()}`;f=r===void 0?g:`${r}; ${g}`}return{capNote:f,children:m,isRestrict:u,relation:n,rowCount:a,rowIds:i,table:s}},Bo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=ve(),[r,a]=$(!0),[i,u]=$(null),[m,p]=$(null);ze(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=Ro(t);if(!((x.get(c)??[]).length>0)){g||(u({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const y=await cn(c,o,void 0,x,new Set,0,n);g||(u(y),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&$o(i,g=>g.isRestrict).length>0,f=()=>{e(),s()};return E(ft,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),m!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(an,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:f,type:"button",children:l("Delete")})]})]})},jo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(m=>m.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,u=0;for(const m of s){const p=m.getSize(),b=e.has(m.id),f=a+p>c&&a<l;b||f?r.add(m.id):a<c?i+=p:u+=p,a+=p}return{ids:r,leadPx:i,tailPx:u}},zo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},qo=oo({columnOrderingFeature:go,columnResizingFeature:mo,columnSizingFeature:fo,columnVisibilityFeature:uo,rowSelectionFeature:co,rowSortingFeature:io,sortedRowModel:po(),sortFns:{alphanumeric:ao,basic:ro,datetime:lo,text:so}}),Ko=()=>{const s=B(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const y=Object.fromEntries(Object.entries(v).filter(S=>{const[C,k]=S;return!(C in h)||!Object.is(k,h[C])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(x).filter(S=>{const[C]=S;return C!==g})):{...x,[g]:y}})},s[3]=a):a=s[3];const i=a;let u;s[4]!==n?(u=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=u):u=s[5];const m=u;let p;s[6]!==n?(p=Object.values(n).reduce(Jo,0),s[6]=n,s[7]=p):p=s[7];const b=p;let f;return s[8]!==b||s[9]!==n||s[10]!==m?(f={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:m},s[8]=b,s[9]=n,s[10]=m,s[11]=f):f=s[11],f},dn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Go=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=ve();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let u;e[8]!==o||e[9]!==t||e[10]!==i?(u=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=u):u=e[11];let m;e[12]!==l?(m=l("Discard"),e[12]=l,e[13]=m):m=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==m?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:m}),e[14]=o,e[15]=c,e[16]=m,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==u||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,u,p]}),e[18]=a,e[19]=u,e[20]=p,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(Wo),e[22]=n,e[23]=f):f=e[23];let g;e[24]!==f?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function Jo(s,e){return s+Object.keys(e).length}function Wo(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:Me(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:Me(s.newValue)})]},`${s.rowId}:${s.column}`)}const Ht=400,Ho=36,Uo={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Qo={width:"100%"},Yo=/\n$/u,Xo={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Zo={display:"flex",width:"100%"},Ut={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},es="2.5rem",un={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},Ft=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),fn=(s,e)=>({...Ft(s),left:`calc(${es} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Et="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",ts=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,At="__back__:",ns=s=>`${At}${s.table}.${s.column}`,os=s=>{const e=B(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Ie=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},ss=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},ls=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return ss(s,n);const o=dn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},rs=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
3
|
`).replace(Yo,"").split(`
|
|
4
4
|
`),r=[];let a=0;for(const[i,u]of l.entries()){const m=t[s.row+i],p=m===void 0?null:Ie(m),b=u.split(" ");if(m===void 0||p===null){a+=b.length;continue}for(const[f,g]of b.entries()){const h=e[s.col+f],x=h===void 0||!o(h)?void 0:ls(g,m[h],n?.[h]);h===void 0||x===void 0?a+=1:r.push({column:h,rowId:p,value:x.value})}}return{edits:r,skipped:a}},mn=(s,e)=>Ie(s)??`row-${e.toString()}`,as=8,is=s=>{const e=B(17),{anchor:n,mask:o,state:t}=s,c=ve();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let a;if(t==="loading"){let u;e[3]!==c?(u=c("Loading…"),e[3]=c,e[4]=u):u=e[4];let m;e[5]!==u?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:u}),e[5]=u,e[6]=m):m=e[6],a=m}else if(t.row===null){let u;e[7]!==c?(u=c("No matching row."),e[7]=c,e[8]=u):u=e[8];let m;e[9]!==u?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:u}),e[9]=u,e[10]=m):m=e[10],a=m}else{let u;if(e[11]!==o||e[12]!==t.row){const m=Object.entries(sn(t.row,o)).slice(0,as);u=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:m.map(ws)}),e[11]=o,e[12]=t.row,e[13]=u}else u=e[13];a=u}let i;return e[14]!==a||e[15]!==r?(i=d("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:a}),e[14]=a,e[15]=r,e[16]=i):i=e[16],i},cs=s=>{const e=B(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[a,i]=$(null),[u,m]=$("idle");let p;e[0]!==o||e[1]!==c||e[2]!==r?(p=()=>{c(r,o)},e[0]=o,e[1]=c,e[2]=r,e[3]=p):p=e[3];const b=p;let f;e[4]!==o||e[5]!==l||e[6]!==u||e[7]!==r?(f=N=>{const w=N.currentTarget.getBoundingClientRect();if(i({left:w.left,top:w.bottom+4}),u!=="idle")return;m("loading"),Ce((async()=>{try{m({row:await l(r,o)})}catch{m({row:null})}})())},e[4]=o,e[5]=l,e[6]=u,e[7]=r,e[8]=f):f=e[8];const g=f;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{i(null)},e[9]=h):h=e[9];const x=h,v=`db-ref-${n}`,y=`Open ${r} ${o}`;let S;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==y?(S=E("button",{"data-testid":v,onBlur:x,onClick:b,onFocus:g,onMouseEnter:g,onMouseLeave:x,title:y,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=b,e[12]=g,e[13]=v,e[14]=y,e[15]=S):S=e[15];let C;e[16]!==a||e[17]!==t||e[18]!==u||e[19]!==r?(C=a!==null&&u!=="idle"&&d(is,{anchor:a,mask:t(r,u==="loading"||u.row===null?[]:Object.keys(u.row)),state:u}),e[16]=a,e[17]=t,e[18]=u,e[19]=r,e[20]=C):C=e[20];let k;return e[21]!==S||e[22]!==C?(k=E(et,{children:[S,C]}),e[21]=S,e[22]=C,e[23]=k):k=e[23],k},ds=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",us="absolute end-1 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded text-muted-foreground outline-none group-hover/cell:flex hover:text-foreground focus-visible:flex",Qt=s=>{const e=B(9),{column:n,onExpand:o,storedValue:t,value:c}=s;let l;e[0]!==n||e[1]!==o||e[2]!==t||e[3]!==c?(l=()=>{o(n,c,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=c,e[4]=l):l=e[4];const r=l,a=`db-expand-${n}`;let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i=d("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:d("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[5]=i):i=e[5];let u;return e[6]!==r||e[7]!==a?(u=d("button",{"aria-label":"Expand cell",className:us,"data-testid":a,onClick:r,type:"button",children:i}),e[6]=r,e[7]=a,e[8]=u):u=e[8],u},fs=s=>{const e=B(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=Ke(null);let a,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{r.current?.select()},i=[],e[0]=a,e[1]=i):(a=e[0],i=e[1]),ze(a,i);let u;e[2]!==t||e[3]!==c?(u=x=>{x.key==="Enter"?(x.preventDefault(),c(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=u):u=e[4];const m=u;let p;e[5]!==c?(p=x=>{c(x.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,f=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=Me(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==m||e[12]!==f||e[13]!==g?(h=d("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":f,defaultValue:g,onBlur:b,onKeyDown:m,ref:r}),e[9]=n,e[10]=b,e[11]=m,e[12]=f,e[13]=g,e[14]=h):h=e[14],h},ms=s=>{const e=B(71),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let a,i,u,m;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==c||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){m=Symbol.for("react.early_return_sentinel");e:{i=n.getValue(),a=Ie(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,D=d(Tt,{value:Un(i,r,c)});let O;e[12]!==_||e[13]!==D?(O=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:D}),e[12]=_,e[13]=D,e[14]=O):O=e[14],m=O;break e}if(R!==void 0&&(typeof i=="string"||typeof i=="number")&&String(i)!==""){const _=String(i),D=`${R}:${String(i)}`;let O;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==D||e[21]!==R?(O=d(cs,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:R},D),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=D,e[21]=R,e[22]=O):O=e[22],m=O;break e}if(a===null){let _;e[23]!==i?(_=d(Tt,{value:i}),e[23]=i,e[24]=_):_=e[24];let D;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==i?(D=d(Qt,{column:r,onExpand:o.onExpandCell,storedValue:i,value:i}),e[25]=r,e[26]=o.onExpandCell,e[27]=i,e[28]=D):D=e[28];let O;e[29]!==_||e[30]!==D?(O=E(et,{children:[_,D]}),e[29]=_,e[30]=D,e[31]=O):O=e[31],m=O;break e}u=o.stagedValue(a,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=a,e[9]=i,e[10]=u,e[11]=m}else a=e[8],i=e[9],u=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=u,b=p===void 0?i:p.value;let f;e[32]!==r||e[33]!==o?(f=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=f):f=e[34];const g=f;if(o.editingCell!==null&&o.editingCell.rowId===a&&o.editingCell.column===r){let R;e[35]!==r||e[36]!==o||e[37]!==a||e[38]!==i?(R=D=>{o.stage(a,r,dn(D,i)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=a,e[38]=i,e[39]=R):R=e[39];let _;return e[40]!==r||e[41]!==b||e[42]!==o.cancelEdit||e[43]!==a||e[44]!==R?(_=d(fs,{column:r,initial:b,onCancel:o.cancelEdit,onCommit:R,recordId:a}),e[40]=r,e[41]=b,e[42]=o.cancelEdit,e[43]=a,e[44]=R,e[45]=_):_=e[45],_}let x;p!==void 0?x="rounded bg-warning/15 px-1":g&&(x="cursor-text");let v;e[46]!==g||e[47]!==r||e[48]!==o||e[49]!==a?(v=g?()=>{o.startEdit(a,r)}:void 0,e[46]=g,e[47]=r,e[48]=o,e[49]=a,e[50]=v):v=e[50];const y=v,S=x,C=`db-cell-${a}-${r}`;let k;e[51]!==r||e[52]!==t||e[53]!==c?(k=ts(t,c,r),e[51]=r,e[52]=t,e[53]=c,e[54]=k):k=e[54];let N;e[55]!==b||e[56]!==k?(N=d(Tt,{highlight:k,value:b}),e[55]=b,e[56]=k,e[57]=N):N=e[57];let w;e[58]!==x||e[59]!==y||e[60]!==C||e[61]!==N?(w=d("span",{className:S,"data-testid":C,onDoubleClick:y,children:N}),e[58]=x,e[59]=y,e[60]=C,e[61]=N,e[62]=w):w=e[62];let T;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell||e[66]!==i?(T=d(Qt,{column:r,onExpand:o.onExpandCell,storedValue:i,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=i,e[67]=T):T=e[67];let F;return e[68]!==T||e[69]!==w?(F=E(et,{children:[w,T]}),e[68]=T,e[69]=w,e[70]=F):F=e[70],F},gs=s=>{s.preventDefault()},Yt={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},ps=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:c,table:l})=>{const r=()=>{e.current=n.column.id},a=()=>{const i=e.current,u=n.column.id;if(e.current=null,i===null||i===u)return;const m=l.atoms.columnOrder.get(),b=(m.length>0?m:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==i),f=b.indexOf(u);b.splice(f===-1?b.length:f,0,i),l.setColumnOrder(b)};return E("th",{className:dt("group/head text-start text-xs font-medium text-muted-foreground",c!==void 0&&"border-e border-border bg-muted"),"data-testid":`db-head-${n.column.id}`,draggable:!0,onDragOver:gs,onDragStart:r,onDrop:a,style:c===void 0?Ft(n.getSize()):fn(n.getSize(),c),children:[E("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[ho(n.column.columnDef.header,n.getContext()),ds(n.column.getIsSorted())]}),s!==void 0&&Yt[s]!==void 0&&d("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:Yt[s]}),o&&d("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),d("button",{"aria-label":c===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":c!==void 0,className:dt("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",c===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),d("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},bs=s=>{const e=B(13),{table:n}=s,o=ve();let t;e[0]!==n?(t=u=>{n.toggleAllRowsSelected(u)},e[0]=n,e[1]=t):t=e[1];const c=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let a;e[6]!==n?(a=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=a):a=e[7];let i;return e[8]!==c||e[9]!==l||e[10]!==r||e[11]!==a?(i=d("th",{className:"bg-muted",style:un,children:d(It,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:a,onCheckedChange:c})}),e[8]=c,e[9]=l,e[10]=r,e[11]=a,e[12]=i):i=e[12],i},hs=s=>{const e=B(17),{row:n}=s,o=ve();let t;e[0]!==n.original?(t=Ie(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=f=>{n.toggleSelected(f)},e[2]=n,e[3]=l):l=e[3];const r=l;let a;e[4]!==o?(a=o("Select row"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==n?(i=n.getIsSelected(),e[6]=n,e[7]=i):i=e[7];let u;e[8]!==n.index||e[9]!==n.original?(u=mn(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=u):u=e[10];const m=`db-select-${u}`,p=c===null;let b;return e[11]!==r||e[12]!==a||e[13]!==i||e[14]!==m||e[15]!==p?(b=d("td",{className:"bg-background",style:un,children:d(It,{"aria-label":a,checked:i,"data-testid":m,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=i,e[14]=m,e[15]=p,e[16]=b):b=e[16],b},xs=s=>{const e=B(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:a,highlight:i,backRelationCounts:u,onTogglePin:m,pinnedColumns:p,refs:b,tableModel:f}=s,g=ve(),{attachScroll:h,scrollLeft:x,scrollToIndex:v,table:y,tableRows:S,tbodyStyle:C,viewportWidth:k,virtualRows:N}=f,w=Ke(null),[T,F]=$(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,D]=$(R);let O;e[1]!==y?(O=y.getVisibleLeafColumns(),e[1]=y,e[2]=O):O=e[2];const V=O.length;let A;e[3]!==T||e[4]!==V||e[5]!==o||e[6]!==y||e[7]!==S?(A=re=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(re.key))return;re.preventDefault();const X=T??{col:0,row:0};if(re.key==="Enter"){const xe=S[X.row],de=y.getVisibleLeafColumns()[X.col];if(xe!==void 0&&de!==void 0){const te=Ie(xe.original);te!==null&&o.editableColumn(de.id)&&o.startEdit(te,de.id)}F(X);return}let{col:ee,row:we}=X;e:switch(re.key){case"ArrowDown":{we=Math.min(we+1,S.length-1);break e}case"ArrowRight":{ee=Math.min(ee+1,V-1);break e}case"ArrowUp":{we=Math.max(we-1,0);break e}default:ee=Math.max(ee-1,0)}F({col:ee,row:we})},e[3]=T,e[4]=V,e[5]=o,e[6]=y,e[7]=S,e[8]=A):A=e[8];const L=A;let G;e[9]!==T||e[10]!==n||e[11]!==o||e[12]!==y||e[13]!==S?(G=re=>{const X=o.editable?re.clipboardData.getData("text/plain"):"";if(X==="")return;re.preventDefault();const ee=y.getVisibleLeafColumns().map(ys),we=rs({anchor:T??{col:0,row:0},columnIds:ee,columnMeta:n,editableColumn:o.editableColumn,rows:S.map(Cs),text:X});for(const xe of we.edits)o.stage(xe.rowId,xe.column,xe.value);D({columns:ee.join("\0"),count:we.skipped})},e[9]=T,e[10]=n,e[11]=o,e[12]=y,e[13]=S,e[14]=G):G=e[14];const q=G;let P,J;e[15]!==T||e[16]!==v?(P=()=>{T!==null&&v(T.row)},J=[T,v],e[15]=T,e[16]=v,e[17]=P,e[18]=J):(P=e[17],J=e[18]),ze(P,J);let K,H,Y,U,ne,le,ae,ge,fe,me,pe,ie,Q,be,ce,Se;if(e[19]!==T||e[20]!==h||e[21]!==u||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==i||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==L||e[30]!==q||e[31]!==a||e[32]!==m||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==x||e[38]!==g||e[39]!==y||e[40]!==S||e[41]!==C||e[42]!==k||e[43]!==N){const re=y.getVisibleLeafColumns().map(Ss),X=jo(re,p,x,k),ee=zo(y.getVisibleLeafColumns().map(Ns),p),we=te=>{const De=S[te.index],{original:Ve}=De,Le=Ie(Ve),Ne=mn(Ve,te.index),ue={...Xo,height:`${te.size.toString()}px`,transform:`translateY(${te.start.toString()}px)`};return E("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:ue,children:[d(hs,{row:De}),X.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),De.getVisibleCells().map((ke,Ge)=>{if(!X.ids.has(ke.column.id))return null;const qe=ee.get(ke.column.id),He=T!==null&&T.row===te.index&&T.col===Ge?" ring-1 ring-ring ring-inset":"";return d("td",{className:dt("group/cell truncate font-mono text-muted-foreground",qe!==void 0&&"border-e border-border bg-background",He),onPointerDown:()=>{F({col:Ge,row:te.index})},style:qe===void 0?Ft(ke.column.getSize()):fn(ke.column.getSize(),qe),children:ke.column.id.startsWith(At)?d(os,{counts:u[ke.column.id.slice(At.length)],rowId:Ne}):d(ms,{cell:ke,edit:o,highlight:i,mask:c,refs:b})},ke.id)}),X.tailPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),E("td",{className:"flex items-center gap-1",style:Ut,children:[d("button",{className:Et,"data-testid":`db-inspect-${Ne}`,onClick:()=>{a(Ve)},type:"button",children:"Details"}),t&&E(et,{children:[d("button",{className:Et,"data-testid":`db-edit-${Ne}`,disabled:Le===null,onClick:()=>{r(Le,Ve)},type:"button",children:"Edit"}),d("button",{className:Et,"data-testid":`db-delete-${Ne}`,disabled:Le===null,onClick:()=>{l(Le)},type:"button",children:"Delete"})]})]})]},De.id)};K=wo,ie="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==y?(Q=_.count>0&&_.columns===y.getVisibleLeafColumns().map(ks).join("\0")&&d("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:g("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=g,e[63]=y,e[64]=Q):Q=e[64],ne="db-scroll",le=L,ae=q,ge=h,fe="grid",me=Uo,pe=0,Se="w-full text-xs",H="db-rows",Y=Qo;let xe;e[65]!==y?(xe=d(bs,{table:y}),e[65]=y,e[66]=xe):xe=e[66];let de;e[67]===Symbol.for("react.memo_cache_sentinel")?(de=d("th",{"aria-label":"Row actions",style:Ut}),e[67]=de):de=e[67],U=d("thead",{className:"bg-muted/50",children:E("tr",{className:"border-b border-border",style:Zo,children:[xe,X.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),y.getFlatHeaders().map(te=>X.ids.has(te.column.id)?d(ps,{declaredType:n?.[te.column.id]?.type,draggedRef:w,header:te,masked:c.columns.has(te.column.id),onTogglePin:m,pinnedOffset:ee.get(te.column.id),table:y},te.id):null),X.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),de]})}),be=C,ce=N.map(te=>we(te)),e[19]=T,e[20]=h,e[21]=u,e[22]=n,e[23]=o,e[24]=t,e[25]=i,e[26]=c,e[27]=l,e[28]=r,e[29]=L,e[30]=q,e[31]=a,e[32]=m,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=x,e[38]=g,e[39]=y,e[40]=S,e[41]=C,e[42]=k,e[43]=N,e[44]=K,e[45]=H,e[46]=Y,e[47]=U,e[48]=ne,e[49]=le,e[50]=ae,e[51]=ge,e[52]=fe,e[53]=me,e[54]=pe,e[55]=ie,e[56]=Q,e[57]=be,e[58]=ce,e[59]=Se}else K=e[44],H=e[45],Y=e[46],U=e[47],ne=e[48],le=e[49],ae=e[50],ge=e[51],fe=e[52],me=e[53],pe=e[54],ie=e[55],Q=e[56],be=e[57],ce=e[58],Se=e[59];let oe;e[68]!==be||e[69]!==ce?(oe=d("tbody",{style:be,children:ce}),e[68]=be,e[69]=ce,e[70]=oe):oe=e[70];let se;e[71]!==H||e[72]!==Y||e[73]!==U||e[74]!==oe||e[75]!==Se?(se=E("table",{className:Se,"data-testid":H,style:Y,children:[U,oe]}),e[71]=H,e[72]=Y,e[73]=U,e[74]=oe,e[75]=Se,e[76]=se):se=e[76];let W;e[77]!==ne||e[78]!==le||e[79]!==ae||e[80]!==ge||e[81]!==fe||e[82]!==me||e[83]!==pe||e[84]!==se?(W=d("div",{"data-testid":ne,onKeyDown:le,onPaste:ae,ref:ge,role:fe,style:me,tabIndex:pe,children:se}),e[77]=ne,e[78]=le,e[79]=ae,e[80]=ge,e[81]=fe,e[82]=me,e[83]=pe,e[84]=se,e[85]=W):W=e[85];let j;return e[86]!==K||e[87]!==ie||e[88]!==Q||e[89]!==W?(j=E(K,{layout:ie,children:[Q,W]}),e[86]=K,e[87]=ie,e[88]=Q,e[89]=W,e[90]=j):j=e[90],j},vs=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=$t(()=>{if(t===void 0)return[];const w=t.map(T=>({accessorFn:F=>F[T],header:l?.[T]===void 0?T:`${T} →`,id:T}));for(const T of o)w.push({accessorFn:()=>{},enableSorting:!1,header:`← ${T.table}`,id:ns(T)});return w},[o,t,l]),a=$t(()=>c??[],[c]),[i,u]=$({}),[m,p]=$({}),b=bo({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:w=>Ie(w.original)!==null,features:qo,getRowId:(w,T)=>Ie(w)??`row-${T.toString()}`,manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:u,onSortingChange:n,state:{columnVisibility:m,rowSelection:i,sorting:e}}),f=b.getRowModel().rows,g=Ke(null),h=xo({count:f.length,estimateSize:()=>Ho,getScrollElement:()=>g.current,initialRect:{height:Ht,width:0},observeElementRect:(w,T)=>vo(w,T,Ht),overscan:8}),x=ct(w=>{h.scrollToIndex(w)},[h]),[v,y]=$({left:0,width:0}),S=ct(w=>{if(g.current=w,w===null)return;const T=()=>{y(R=>R.left===w.scrollLeft&&R.width===w.clientWidth?R:{left:w.scrollLeft,width:w.clientWidth})};w.addEventListener("scroll",T,{passive:!0});const F=new ResizeObserver(T);return F.observe(w),()=>{w.removeEventListener("scroll",T),F.disconnect(),g.current=null}},[]),C=h.getVirtualItems(),N={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:S,scrollLeft:v.left,scrollToIndex:x,table:b,tableRows:f,tbodyStyle:N,viewportWidth:v.width,virtualRows:C}};function ws(s){const[e,n]=s;return E("div",{className:"contents",children:[d("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),d("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Me(n),children:Me(n)})]},e)}function ys(s){return s.id}function Cs(s){return s.original}function Ss(s){return{getSize:()=>s.getSize(),id:s.id}}function Ns(s){return{getSize:()=>s.getSize(),id:s.id}}function ks(s){return s.id}const Ts=s=>{const e=B(22),{onCommit:n}=s,o=ve(),[t,c]=$(""),l=Ke(null);let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},a=[],e[0]=r,e[1]=a):(r=e[0],a=e[1]),ze(r,a);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=y=>{c(y.target.value)},e[2]=i):i=e[2];const u=i;let m;e[3]!==t||e[4]!==n?(m=()=>{const y=t.trim();y!==""&&n(y)},e[3]=t,e[4]=n,e[5]=m):m=e[5];const p=m;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let f;e[8]!==o?(f=o("Query name"),e[8]=o,e[9]=f):f=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==f?(g=d("input",{"aria-label":b,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:u,placeholder:f,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=f,e[13]=g):g=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let x;e[16]!==p||e[17]!==h?(x=d("button",{className:Dt,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=x):x=e[18];let v;return e[19]!==g||e[20]!==x?(v=E("span",{className:"inline-flex items-center gap-1",children:[g,x]}),e[19]=g,e[20]=x,e[21]=v):v=e[21],v},Es=s=>{const e=B(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=ve(),[a,i]=$(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{i(!0)},e[0]=u):u=e[0];const m=u;let p;e[1]!==c?(p=N=>{c(N),i(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let f;e[3]!==n||e[4]!==l?(f=N=>{const w=l[Number(N.currentTarget.dataset.index)];w!==void 0&&n(w)},e[3]=n,e[4]=l,e[5]=f):f=e[5];const g=f;let h;e[6]!==t||e[7]!==l?(h=N=>{const w=l[Number(N.currentTarget.dataset.index)];w!==void 0&&t(w.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const x=h;let v;e[9]!==r?(v=r("Copy link"),e[9]=r,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=d("button",{className:Dt,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let S;e[14]!==b||e[15]!==a||e[16]!==r?(S=a?d(Ts,{onCommit:b}):d("button",{className:Dt,"data-testid":"db-save-query",onClick:m,type:"button",children:r("Save query")}),e[14]=b,e[15]=a,e[16]=r,e[17]=S):S=e[17];let C;e[18]!==g||e[19]!==x||e[20]!==l||e[21]!==r?(C=l.length>0&&E("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((N,w)=>E("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[d("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":w,"data-testid":`db-saved-query-${N.name}`,onClick:g,type:"button",children:N.name}),d("button",{"aria-label":r("Delete saved query {name}",{name:N.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":w,"data-testid":`db-saved-query-delete-${N.name}`,onClick:x,type:"button",children:"✕"})]},N.name))]}),e[18]=g,e[19]=x,e[20]=l,e[21]=r,e[22]=C):C=e[22];let k;return e[23]!==y||e[24]!==S||e[25]!==C?(k=E("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[y,S,C]}),e[23]=y,e[24]=S,e[25]=C,e[26]=k):k=e[26],k},We="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",gn=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Xt=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?gn.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",_s=(s,e,n)=>n===void 0?Xt(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?gn.test(s)?"date":"number":Xt(s,e),Rs=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},$s=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},Je="\0clear",Ds=s=>{const e=B(23),{column:n,nullable:o,onChange:t,value:c}=s,l=ve();let r;e[0]!==n||e[1]!==t?(r=v=>{t(n,v)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const a=r;let i;e[3]!==n||e[4]!==t?(i=v=>{t(n,v.target.value===Je?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=i):i=e[5];const u=i;if(!o&&c!==null){const v=c===!0,y=`db-field-${n}`;let S;return e[6]!==n||e[7]!==a||e[8]!==v||e[9]!==y?(S=d(It,{"aria-label":n,checked:v,"data-testid":y,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=v,e[9]=y,e[10]=S):S=e[10],S}const m=`db-field-${n}`,p=c===!0||c===!1?String(c):Je;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let f;e[13]!==b?(f=d("option",{value:Je,children:b}),e[13]=b,e[14]=f):f=e[14];let g,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=d("option",{value:"true",children:"true"}),h=d("option",{value:"false",children:"false"}),e[15]=g,e[16]=h):(g=e[15],h=e[16]);let x;return e[17]!==n||e[18]!==u||e[19]!==m||e[20]!==p||e[21]!==f?(x=E("select",{"aria-label":n,className:We,"data-testid":m,onChange:u,value:p,children:[f,g,h]}),e[17]=n,e[18]=u,e[19]=m,e[20]=p,e[21]=f,e[22]=x):x=e[22],x},As=s=>{const e=B(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=ve(),a=typeof l=="string"?l:null;let i;e[0]!==c||e[1]!==a?(i=a!==null&&!c.includes(a),e[0]=c,e[1]=a,e[2]=i):i=e[2];const u=i;let m;e[3]!==n||e[4]!==t?(m=y=>{t(n,y.target.value===Je?null:y.target.value)},e[3]=n,e[4]=t,e[5]=m):m=e[5];const p=m,b=`db-field-${n}`,f=a??Je;let g;e[6]!==o||e[7]!==a||e[8]!==r?(g=(o||a===null)&&d("option",{value:Je,children:r("(none)")}),e[6]=o,e[7]=a,e[8]=r,e[9]=g):g=e[9];let h;e[10]!==a||e[11]!==u?(h=u&&d("option",{value:a,children:a}),e[10]=a,e[11]=u,e[12]=h):h=e[12];let x;e[13]!==c?(x=c.map(Ls),e[13]=c,e[14]=x):x=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==f||e[19]!==g||e[20]!==h||e[21]!==x?(v=E("select",{"aria-label":n,className:We,"data-testid":b,onChange:p,value:f,children:[g,h,x]}),e[15]=n,e[16]=p,e[17]=b,e[18]=f,e[19]=g,e[20]=h,e[21]=x,e[22]=v):v=e[22],v},Ps=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{const m=Number(u.target.value);u.target.value!==""&&!Number.isNaN(m)&&o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="number"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"number",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Is=s=>{const e=B(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{const m=new Date(u.target.value).getTime();Number.isNaN(m)||o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`;let a;e[3]!==t?(a=typeof t=="number"?$s(t):"",e[3]=t,e[4]=a):a=e[4];let i;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"datetime-local",value:a}),e[5]=n,e[6]=l,e[7]=r,e[8]=a,e[9]=i):i=e[9],i},Os=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=u=>{o(n,u.target.value)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="string"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"text",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Fs=s=>{const e=B(20),{column:n,onChange:o,value:t}=s,c=ve();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=$(l),[i,u]=$(!1);let m;e[2]!==n||e[3]!==o?(m=y=>{const S=y.target.value;a(S);try{o(n,JSON.parse(S)),u(!1)}catch{u(!0)}},e[2]=n,e[3]=o,e[4]=m):m=e[4];const p=m,b=i&&"border-destructive";let f;e[5]!==b?(f=dt(We,"min-h-16",b),e[5]=b,e[6]=f):f=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==f||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:f,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=f,e[10]=g,e[11]=r,e[12]=h):h=e[12];let x;e[13]!==n||e[14]!==i||e[15]!==c?(x=i&&d("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:c("Invalid JSON")}),e[13]=n,e[14]=i,e[15]=c,e[16]=x):x=e[16];let v;return e[17]!==h||e[18]!==x?(v=E("div",{className:"flex flex-col gap-1",children:[h,x]}),e[17]=h,e[18]=x,e[19]=v):v=e[19],v},Ms=s=>{const e=B(56),{column:n,meta:o,onChange:t,target:c,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=_s(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const a=r,i=`db-field-${n}`;let u;e[4]!==n?(u=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==o?(m=o!==void 0&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==c?(p=c!==void 0&&E("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",c]}),e[9]=c,e[10]=p):p=e[10];let b;e[11]!==u||e[12]!==m||e[13]!==p?(b=E("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[u,m,p]}),e[11]=u,e[12]=m,e[13]=p,e[14]=b):b=e[14];let f;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(f=a==="boolean"&&d(Ds,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=a,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=f):f=e[20];let g;e[21]!==n||e[22]!==a||e[23]!==o||e[24]!==t||e[25]!==l?(g=a==="enum"&&o?.enumValues!==void 0&&d(As,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=a,e[23]=o,e[24]=t,e[25]=l,e[26]=g):g=e[26];let h;e[27]!==n||e[28]!==a||e[29]!==t||e[30]!==l?(h=a==="number"&&d(Ps,{column:n,onChange:t,value:l}),e[27]=n,e[28]=a,e[29]=t,e[30]=l,e[31]=h):h=e[31];let x;e[32]!==n||e[33]!==a||e[34]!==t||e[35]!==l?(x=a==="date"&&d(Is,{column:n,onChange:t,value:l}),e[32]=n,e[33]=a,e[34]=t,e[35]=l,e[36]=x):x=e[36];let v;e[37]!==n||e[38]!==a||e[39]!==t||e[40]!==l?(v=a==="json"&&d(Fs,{column:n,onChange:t,value:l}),e[37]=n,e[38]=a,e[39]=t,e[40]=l,e[41]=v):v=e[41];let y;e[42]!==n||e[43]!==a||e[44]!==t||e[45]!==l?(y=a==="text"&&d(Os,{column:n,onChange:t,value:l}),e[42]=n,e[43]=a,e[44]=t,e[45]=l,e[46]=y):y=e[46];let S;return e[47]!==x||e[48]!==v||e[49]!==y||e[50]!==i||e[51]!==b||e[52]!==f||e[53]!==g||e[54]!==h?(S=E("label",{className:"flex flex-col gap-1 text-xs",htmlFor:i,children:[b,f,g,h,x,v,y]}),e[47]=x,e[48]=v,e[49]=y,e[50]=i,e[51]=b,e[52]=f,e[53]=g,e[54]=h,e[55]=S):S=e[55],S},Vs=s=>{const e=B(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,a=ve();let i;e[0]!==o?(i=Rs(o),e[0]=o,e[1]=i):i=e[1];const u=i,[m,p]=$(!1),b=!m&&u!==null;let f;e[2]!==u||e[3]!==c?(f=(P,J)=>{c(JSON.stringify({...u,[P]:J},null,2))},e[2]=u,e[3]=c,e[4]=f):f=e[4];const g=f;let h;e[5]!==c?(h=P=>{c(P.target.value)},e[5]=c,e[6]=h):h=e[6];const x=h;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(!1)},e[7]=v):v=e[7];const y=v;let S;e[8]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{p(!0)},e[8]=S):S=e[8];const C=S,k=u===null;let N;e[9]!==a?(N=a("Form"),e[9]=a,e[10]=N):N=e[10];let w;e[11]!==b||e[12]!==k||e[13]!==N?(w=d("button",{"aria-pressed":b,className:Pe,"data-testid":"db-editor-form",disabled:k,onClick:y,type:"button",children:N}),e[11]=b,e[12]=k,e[13]=N,e[14]=w):w=e[14];const T=!b;let F;e[15]!==a?(F=a("JSON"),e[15]=a,e[16]=F):F=e[16];let R;e[17]!==F||e[18]!==T?(R=d("button",{"aria-pressed":T,className:Pe,"data-testid":"db-editor-json",onClick:C,type:"button",children:F}),e[17]=F,e[18]=T,e[19]=R):R=e[19];let _;e[20]!==R||e[21]!==w?(_=E("div",{className:"flex items-center gap-1.5",children:[w,R]}),e[20]=R,e[21]=w,e[22]=_):_=e[22];let D;e[23]!==n||e[24]!==o||e[25]!==u||e[26]!==g||e[27]!==x||e[28]!==r||e[29]!==b||e[30]!==a?(D=b?d("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(u).map(P=>{const[J,K]=P;return d(Ms,{column:J,meta:n?.[J],onChange:g,target:r?.[J],value:K},J)})}):d("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:x,value:o}),e[23]=n,e[24]=o,e[25]=u,e[26]=g,e[27]=x,e[28]=r,e[29]=b,e[30]=a,e[31]=D):D=e[31];let O;e[32]!==a?(O=a("Save"),e[32]=a,e[33]=O):O=e[33];let V;e[34]!==l||e[35]!==O?(V=d("button",{className:Pe,"data-testid":"db-editor-save",onClick:l,type:"button",children:O}),e[34]=l,e[35]=O,e[36]=V):V=e[36];let A;e[37]!==a?(A=a("Cancel"),e[37]=a,e[38]=A):A=e[38];let L;e[39]!==t||e[40]!==A?(L=d("button",{className:Pe,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:A}),e[39]=t,e[40]=A,e[41]=L):L=e[41];let G;e[42]!==V||e[43]!==L?(G=E("div",{className:"flex items-center gap-1.5",children:[V,L]}),e[42]=V,e[43]=L,e[44]=G):G=e[44];let q;return e[45]!==_||e[46]!==D||e[47]!==G?(q=E("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,D,G]}),e[45]=_,e[46]=D,e[47]=G,e[48]=q):q=e[48],q};function Ls(s){return d("option",{value:s,children:s},s)}const Bs=s=>{const e=B(71),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:a,maskOn:i,onAddRow:u,onBulkDelete:m,onBulkPatch:p,onAskAiFilter:b,onClearTable:f,onFilterChange:g,onFiltersChange:h,onGenerateRows:x,onShowJson:v,onShowTable:y,onToggleMask:S,total:C,totalKnown:k,viewMode:N}=s,w=ve(),T=N==="table";let F;e[0]!==y||e[1]!==T?(F=d("button",{"aria-pressed":T,className:Pe,"data-testid":"db-view-table",onClick:y,type:"button",children:"Table"}),e[0]=y,e[1]=T,e[2]=F):F=e[2];const R=N==="json";let _;e[3]!==v||e[4]!==R?(_=d("button",{"aria-pressed":R,className:Pe,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=R,e[5]=_):_=e[5];let D;e[6]!==a||e[7]!==w?(D=a===void 0?w("Live — changes stream in automatically"):w("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=w,e[8]=D):D=e[8];const O=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let V;e[9]!==O?(V=d("span",{"aria-hidden":"true",className:O}),e[9]=O,e[10]=V):V=e[10];let A;e[11]!==a||e[12]!==w?(A=w(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=w,e[13]=A):A=e[13];let L;e[14]!==D||e[15]!==V||e[16]!==A?(L=E("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:D,children:[V,A]}),e[14]=D,e[15]=V,e[16]=A,e[17]=L):L=e[17];let G;e[18]!==l||e[19]!==i||e[20]!==S||e[21]!==w?(G=l&&d("button",{"aria-pressed":i,className:Pe,"data-testid":"db-mask-toggle",onClick:S,type:"button",children:w("Mask sensitive columns")}),e[18]=l,e[19]=i,e[20]=S,e[21]=w,e[22]=G):G=e[22];let q;e[23]!==o||e[24]!==u?(q=o&&d("button",{className:Pe,"data-testid":"db-add-row",onClick:u,type:"button",children:"Add row"}),e[23]=o,e[24]=u,e[25]=q):q=e[25];let P;e[26]!==o||e[27]!==x||e[28]!==w?(P=o&&x!==void 0&&d("button",{className:Pe,"data-testid":"db-generate-rows",onClick:x,type:"button",children:w("Generate rows")}),e[26]=o,e[27]=x,e[28]=w,e[29]=P):P=e[29];let J;e[30]!==o||e[31]!==r||e[32]!==m||e[33]!==w||e[34]!==C||e[35]!==k?(J=o&&C>0&&r&&d(Kt,{confirmLabel:k?w("Permanently delete {total} matching rows and everything that cascades?",{total:C.toString()}):w("Permanently delete all matching rows and everything that cascades?"),onConfirm:m,testId:"db-bulk-delete",children:k?w("Delete {total} matching",{total:C.toString()}):w("Delete matching")}),e[30]=o,e[31]=r,e[32]=m,e[33]=w,e[34]=C,e[35]=k,e[36]=J):J=e[36];let K;e[37]!==o||e[38]!==r||e[39]!==p||e[40]!==w||e[41]!==C||e[42]!==k?(K=o&&k&&C>0&&r&&d("button",{className:Pe,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:w("Set column on {total} matching",{total:C.toString()})}),e[37]=o,e[38]=r,e[39]=p,e[40]=w,e[41]=C,e[42]=k,e[43]=K):K=e[43];let H;e[44]!==o||e[45]!==r||e[46]!==f||e[47]!==w||e[48]!==C||e[49]!==k?(H=o&&C>0&&!r&&d(Kt,{confirmLabel:k?w("Permanently clear all {total} rows and everything that cascades?",{total:C.toString()}):w("Permanently clear every row and everything that cascades?"),onConfirm:f,testId:"db-clear-table",children:k?w("Clear table ({total})",{total:C.toString()}):w("Clear table")}),e[44]=o,e[45]=r,e[46]=f,e[47]=w,e[48]=C,e[49]=k,e[50]=H):H=e[50];let Y;e[51]!==G||e[52]!==q||e[53]!==P||e[54]!==J||e[55]!==K||e[56]!==H||e[57]!==F||e[58]!==_||e[59]!==L?(Y=E("div",{className:"flex flex-wrap items-center gap-1.5",children:[F,_,L,G,q,P,J,K,H]}),e[51]=G,e[52]=q,e[53]=P,e[54]=J,e[55]=K,e[56]=H,e[57]=F,e[58]=_,e[59]=L,e[60]=Y):Y=e[60];let U;e[61]!==n||e[62]!==t||e[63]!==c||e[64]!==b||e[65]!==g||e[66]!==h?(U=d(Co,{columns:n,filters:c,onAskAi:b,onFiltersChange:h,onSearchChange:g,search:t}),e[61]=n,e[62]=t,e[63]=c,e[64]=b,e[65]=g,e[66]=h,e[67]=U):U=e[67];let ne;return e[68]!==Y||e[69]!==U?(ne=E("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[Y,U]}),e[68]=Y,e[69]=U,e[70]=ne):ne=e[70],ne},js=s=>{const e=B(110),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:a,onInspect:i,onOpenBulkPatch:u,onOpenGenerateRows:m,onRowDelete:p,onSaveQuery:b,page:f,preferences:g,queryBar:h,references:x}=s,v=g.maskColumns.size>0,y=n.unavailable?void 0:a;let S;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.hasPredicate||e[7]!==t.liveError||e[8]!==t.onFilterChange||e[9]!==t.onFiltersChange||e[10]!==t.showJson||e[11]!==t.showTable||e[12]!==t.total||e[13]!==t.totalKnown||e[14]!==t.viewMode||e[15]!==r||e[16]!==u||e[17]!==m||e[18]!==g.maskOn||e[19]!==g.onToggleMask||e[20]!==v||e[21]!==y?(S=d(Bs,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,hasPredicate:t.hasPredicate,liveError:t.liveError,maskOn:g.maskOn,onAddRow:t.addRow,onAskAiFilter:y,onBulkDelete:t.bulkDelete,onBulkPatch:u,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:m,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:g.onToggleMask,total:t.total,totalKnown:t.totalKnown,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.hasPredicate,e[7]=t.liveError,e[8]=t.onFilterChange,e[9]=t.onFiltersChange,e[10]=t.showJson,e[11]=t.showTable,e[12]=t.total,e[13]=t.totalKnown,e[14]=t.viewMode,e[15]=r,e[16]=u,e[17]=m,e[18]=g.maskOn,e[19]=g.onToggleMask,e[20]=v,e[21]=y,e[22]=S):S=e[22];let C;e[23]!==b||e[24]!==h?(C=h!==void 0&&d(Es,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[23]=b,e[24]=h,e[25]=C):C=e[25];let k;e[26]!==o||e[27]!==t.onBulkDeleteSelected||e[28]!==t.selectedTable||e[29]!==t.table||e[30]!==t.viewMode||e[31]!==r||e[32]!==f||e[33]!==g.maskView||e[34]!==g.onToggleTranspose||e[35]!==g.transposed?(k=t.viewMode==="table"&&f.rows.length>0&&d(So,{backRelations:o.available,columns:f.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:Nt(f.rows,g.maskView),sqlColumns:f.sqlColumns,table:t.table.table,transposed:g.transposed}),e[26]=o,e[27]=t.onBulkDeleteSelected,e[28]=t.selectedTable,e[29]=t.table,e[30]=t.viewMode,e[31]=r,e[32]=f,e[33]=g.maskView,e[34]=g.onToggleTranspose,e[35]=g.transposed,e[36]=k):k=e[36];let N;e[37]!==t.cancelEdit||e[38]!==t.editing||e[39]!==t.saveEdit||e[40]!==t.setEditorDocumentText||e[41]!==c||e[42]!==r||e[43]!==f?(N=r&&t.editing!==null&&d(Vs,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:f.refs}),e[37]=t.cancelEdit,e[38]=t.editing,e[39]=t.saveEdit,e[40]=t.setEditorDocumentText,e[41]=c,e[42]=r,e[43]=f,e[44]=N):N=e[44];let w;e[45]!==t.committing||e[46]!==t.discardStaged||e[47]!==t.onCommitStaged||e[48]!==t.stagedChanges||e[49]!==r?(w=r&&t.stagedChanges.length>0&&d(Go,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[45]=t.committing,e[46]=t.discardStaged,e[47]=t.onCommitStaged,e[48]=t.stagedChanges,e[49]=r,e[50]=w):w=e[50];let T;e[51]!==t.writeError?(T=t.writeError!==null&&d("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[51]=t.writeError,e[52]=T):T=e[52];let F;e[53]!==t.writeNotice?(F=t.writeNotice!==null&&d("p",{className:"text-sm text-muted-foreground","data-testid":"db-write-notice",role:"status",children:t.writeNotice}),e[53]=t.writeNotice,e[54]=F):F=e[54];let R;e[55]!==S||e[56]!==C||e[57]!==k||e[58]!==N||e[59]!==w||e[60]!==T||e[61]!==F?(R=E("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[S,C,k,N,w,T,F]}),e[55]=S,e[56]=C,e[57]=k,e[58]=N,e[59]=w,e[60]=T,e[61]=F,e[62]=R):R=e[62];let _;e[63]!==t.viewMode||e[64]!==f?(_=t.viewMode==="table"&&f.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(no,{description:"Rows you insert into this table will show up here.",icon:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[63]=t.viewMode,e[64]=f,e[65]=_):_=e[65];let D;e[66]!==t.viewMode||e[67]!==f||e[68]!==g.maskView||e[69]!==g.transposed?(D=t.viewMode==="table"&&f.rows.length>0&&g.transposed&&d(yo,{columns:f.columns,rows:Nt(f.rows,g.maskView)}),e[66]=t.viewMode,e[67]=f,e[68]=g.maskView,e[69]=g.transposed,e[70]=D):D=e[70];let O;e[71]!==o||e[72]!==t.filter||e[73]!==t.onRowEdit||e[74]!==t.table||e[75]!==t.viewMode||e[76]!==c||e[77]!==l||e[78]!==r||e[79]!==i||e[80]!==p||e[81]!==f||e[82]!==g.maskView||e[83]!==g.onTogglePin||e[84]!==g.pinnedColumns||e[85]!==g.transposed||e[86]!==x?(O=t.viewMode==="table"&&f.rows.length>0&&!g.transposed&&d(xs,{backRelationCounts:o.counts,columnMeta:c,edit:l,editable:r,highlight:t.filter,mask:g.maskView,onDelete:p,onEdit:t.onRowEdit,onInspect:i,onTogglePin:g.onTogglePin,pinnedColumns:g.pinnedColumns,refs:x,tableModel:t.table}),e[71]=o,e[72]=t.filter,e[73]=t.onRowEdit,e[74]=t.table,e[75]=t.viewMode,e[76]=c,e[77]=l,e[78]=r,e[79]=i,e[80]=p,e[81]=f,e[82]=g.maskView,e[83]=g.onTogglePin,e[84]=g.pinnedColumns,e[85]=g.transposed,e[86]=x,e[87]=O):O=e[87];let V;e[88]!==t.viewMode||e[89]!==f||e[90]!==g.maskView?(V=t.viewMode==="json"&&d("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(Nt(f.rows,g.maskView),on,2)}),e[88]=t.viewMode,e[89]=f,e[90]=g.maskView,e[91]=V):V=e[91];let A;e[92]!==t.changePageSize||e[93]!==t.goNext||e[94]!==t.goPrevious||e[95]!==t.hasNext||e[96]!==t.hasPrevious||e[97]!==t.jumpToPage||e[98]!==t.pageSize||e[99]!==t.rangeEnd||e[100]!==t.rangeStart||e[101]!==t.total?(A=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(ko,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[92]=t.changePageSize,e[93]=t.goNext,e[94]=t.goPrevious,e[95]=t.hasNext,e[96]=t.hasPrevious,e[97]=t.jumpToPage,e[98]=t.pageSize,e[99]=t.rangeEnd,e[100]=t.rangeStart,e[101]=t.total,e[102]=A):A=e[102];let L;return e[103]!==R||e[104]!==_||e[105]!==D||e[106]!==O||e[107]!==V||e[108]!==A?(L=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,D,O,V,A]}),e[103]=R,e[104]=_,e[105]=D,e[106]=O,e[107]=V,e[108]=A,e[109]=L):L=e[109],L},zs="/__lunora/seed",_t=200,qs=50,Ks=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},Gs=s=>Array.isArray(s)&&s.every(e=>ln(e)),Js=async s=>{let e;try{e=await fetch(zs,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"})}catch(o){return{kind:"error",message:`seed request failed: ${zt(o)}`}}let n;try{n=await e.json()??{}}catch{return{kind:"error",message:`seed request failed (${String(e.status)})`}}if(e.ok&&n.rows!==void 0){let o;try{o=Pt(n.rows)}catch(t){return{kind:"error",message:`seed response could not be decoded: ${zt(t)}`}}return Gs(o)?{kind:"ok",rows:o}:{kind:"error",message:"seed response did not carry a list of row documents"}}return n.error==="fk-parents-empty"?{kind:"error",message:`no rows to reference in ${(Array.isArray(n.tables)?n.tables.filter(t=>typeof t=="string"):[]).join(", ")} — seed those tables first`}:n.error==="seed-refused"&&typeof n.message=="string"?{kind:"error",message:n.message}:{kind:"error",message:typeof n.error=="string"?n.error:`seed request failed (${String(e.status)})`}},Ws="rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Hs="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",Us=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=ve(),[l,r]=$(10),[a,i]=$(!1),[u,m]=$(void 0),[p,b]=$(void 0),[f,g]=$(0),h=C=>{const k=Number(C.target.value);!Number.isNaN(k)&&k>=1&&r(Math.min(k,_t))},x=async()=>{m(void 0),b(void 0),g(0),i(!0);try{const C=await Js({count:l,existingIds:e,seed:Date.now(),table:t});if(C.kind==="error"){m(C.message);return}const{rows:k}=C;if(k.length===0){m(c("No rows generated — all columns were skipped."));return}const N=await o(k);if(N.error!==void 0){m(N.error);return}b(N.inserted),g(N.conflicts)}finally{i(!1)}},v=()=>{Ce(x())},y=s.filter(C=>C.pk!==!0),S=Ks(s,e);return E(ft,{label:c("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:c("Generate dummy rows")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:c("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:c("Close")})]}),E("div",{className:"flex items-center gap-2",children:[d("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:c("Row count")}),d("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:_t,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:_t.toString()})})]}),y.length>0&&E("div",{className:"flex flex-col gap-1",children:[d("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Columns to seed")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:y.map(C=>{const k=C.ref!==void 0&&C.type==="id",N=k&&(e[C.ref??""]??[]).length===0,w=N?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",T=N?`gen-rows-fk-empty-${C.name}`:`gen-rows-fk-ok-${C.name}`,F=N?c("FK: no rows in {ref} — seed it first",{ref:C.ref??""}):c("→ {ref}",{ref:C.ref??""});return E("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:C.name}),E("span",{className:"text-muted-foreground",children:["(",C.type,")"]}),C.optional&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),k&&d("span",{className:w,"data-testid":T,children:F})]},C.name)})})]}),S.length>0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-blocked",role:"alert",children:c("Cannot generate rows: these columns reference tables with no rows: {cols}. Seed those tables first.",{cols:S.join(", ")})}),u!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:u}),p!==void 0&&u===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:f>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:f.toString(),inserted:p.toString(),total:(p+f).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:Ws,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:Hs,"data-testid":"gen-rows-generate",disabled:a||S.length>0,onClick:v,type:"button",children:c(a?"Inserting…":"Generate & insert")})]})]})},Qs=$e(he.backRelationCounts),Ys=(s,e,n,o)=>{const t=B(16),c=ut();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=$(l);let i;if(t[1]!==s||t[2]!==e){let x;t[4]!==s?(x=v=>s.has(Ot(v)),t[4]=s,t[5]=x):x=t[5],i=e.filter(x),t[1]=s,t[2]=e,t[3]=i}else i=t[3];const u=i;let m;t[6]!==n||t[7]!==u?(m=JSON.stringify([u,n]),t[6]=n,t[7]=u,t[8]=m):m=t[8];const p=m;let b;t[9]!==c||t[10]!==o||t[11]!==p?(b=async x=>{const[v,y]=JSON.parse(p);if(v.length===0||y.length===0){x.cancelled||a({});return}try{const S=await c.query(Qs,{ids:y,relations:v},Re(o));x.cancelled||a(Object.fromEntries(S.relations.map(Xs)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const f=b;let g,h;return t[13]!==f?(g=()=>{const x={cancelled:!1};return Ce(f(x)),()=>{x.cancelled=!0}},h=[f],t[13]=f,t[14]=g,t[15]=h):(g=t[14],h=t[15]),ze(g,h),r};function Xs(s){return[Ot(s),s.counts]}const Zs=async s=>{const{args:e,maxBatches:n,openCursor:o,query:t}=s;let c=o,l=0,r="cap-hit";for(let a=0;a<n;a+=1){const i=await t({...e,after:c});if(l+=i.count,c=i.cursor,!i.hasMore){r="completed";break}}return{cursor:r==="cap-hit"?c:void 0,outcome:r,written:l}},it=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},pn=s=>Me(s),Zt=s=>s.map(e=>({column:e.column,path:(e.path??[]).join("."),...e.path===void 0||e.path.length===0?{}:{pathSegments:e.path},...e.value===void 0?{}:{literal:[e.value]},operator:e.operator,value:e.value===void 0?"":pn(e.value)})),en=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],el=s=>[s.column,s.operator,s.value,s.path??[]],rt=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>el(t)),o===void 0?null:[o.column,o.direction]]),Mt=200,tl=20,nl=$e(he.readTablePage),ol=$e(he.facetColumn),Rt=$e(he.writeRow),sl=$e(he.deleteRows),ll=$e(he.clearTable),rl=$e(he.patchRows),al={},Vt=new Set(["__doc__","__id__","_creationTime","_id","id"]),il=s=>{const e=s.__doc__;if(typeof e=="string"){const o=eo(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Vt.has(o)||(n[o]=t);return n},cl=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,rn(e)]),dl=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Fe(s),limit:n,offset:e,orderBy:it(t),search:o,skipCount:!0,table:c}),ul=({filters:s,search:e,table:n})=>({filters:Fe(s),limit:1,search:e,table:n}),fl=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Ie(t);c!==null&&n.set(c,t)}const o=[];for(const[t,c]of Object.entries(e))for(const[l,r]of Object.entries(c))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},ml=s=>!Vt.has(s),gl=`Stopped after ${Mt.toString()} batches — rows still match. Run it again to remove the rest.`,pl=`Stopped after ${Mt.toString()} batches — rows still match. Run it again to set the rest.`,tn={resumable:!1,truncated:gl,verb:"deleted"},bl={resumable:!0,truncated:pl,verb:"written"},hl=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const i=ut(),[u,m]=$(l),[p,b]=$(o??""),f=a===void 0||a===""?null:a,[g,h]=$(0),[x,v]=$("table"),[y,S]=$(()=>en(e)),[C,k]=$(n??""),[N,w]=$(()=>Zt(s??[])),{clearFacets:T,facets:F,refetchFacets:R,toggleFacet:_}=Qn(),[D,O]=$(null),[V,A]=$(null),[L,G]=$(null),q=Ke(null),P=Ko(),[J,K]=$(null),[H,Y]=$(!1),[U,ne]=$(a),[le,ae]=$(()=>rt(o,n,s,e)),[ge,fe]=$(0),[me,pe]=$(()=>rt(o,n,s,e)),ie=a!==U,Q=rt(o,n,s,e),ce=ie||!ie&&Q!==le&&Q!==me;if(ce){ne(a),ae(Q),fe(z=>z+1),S(en(e)),k(n??"");const I=Zt(s??[]);w(I),b(o??""),T(),P.clear(),K(null),O(null),h(0),A(null),G(null),q.current=null}else Q!==le&&ae(Q);const Se=ce?n??"":C,oe=ce?o??"":p,se=`${a??""}:${ge.toString()}`,W=Gt(Se.trim(),300,se),j=Gt(oe.trim(),400,se),re=Xe(se),X=Ke(0),[ee,we]=$(j);ee!==j&&(we(j),P.clear(),K(null),O(null));const xe=rt(j,W,Fe(N),it(y));xe!==me&&pe(xe);const de=Ze(he.listTables,al,{live:!0,shardKey:j}),te=de.data??null,De=de.error,Ve=dl({filters:N,offset:g,pageSize:u,search:W,sorting:y,table:f??""}),Le=ul({filters:N,search:W,table:f??""}),Ne=Ze(he.readTablePage,Ve,{enabled:f!==null,keepPreviousData:!1,live:!0,shardKey:j}),ue=Ne.data??null,ke=Ne.error,{liveError:Ge}=Ne,qe=Ze(he.readTablePage,Le,{enabled:f!==null,live:!0,shardKey:j});ze(()=>{de.data!==void 0&&To(j)},[de.data,j]);const He=I=>{t?.(I)},mt=(I,z)=>{t?.(I,{search:z})},gt=async(I,z)=>{try{return(await i.query(nl,{filters:[],limit:tl,offset:0,search:z,table:I},Re(j))).rows.find(Ae=>Ie(Ae)===z)??null}catch{return null}},tt=(I,z,Te,Ae)=>ye=>i.query(ol,{column:ye,filters:Fe(Te),search:Ae,table:z},Re(I)),pt=I=>{_(I,f===null?null:tt(j,f,N,W))},nt=(I,z)=>{const Te={column:I,literal:[Wn(z)],operator:"eq",value:pn(z)},Ae=ye=>ye.column===I&&ye.operator!=="has"&&ye.pathSegments===void 0&&(ye.path??"").trim()==="";w(ye=>[...ye.filter(_e=>!Ae(_e)),Te]),h(0)},bt=Xe(tt),ht=Xe(R),Ue=Xe(c);ze(()=>{f!==null&&Ce(ht.current(bt.current(j,f,N,W)))},[j,f,N,W]),ze(()=>{f===null||Ue.current===void 0||U!==a||le!==Q||Ue.current({filters:Fe(N),orderBy:it(y),search:W,shard:j})},[f,a,U,le,Q,N,y,W,j]);const Qe=I=>{f!==null&&h(Math.max(0,I))},xt=(I,z)=>{K({column:z,rowId:I})},vt=()=>{K(null)},wt=async()=>{if(f!==null){A(null),Y(!0);try{for(const[I,z]of Object.entries(P.staged))await i.query(Rt,{doc:z,id:I,op:"patch",table:f},Re(j)),P.drop(I,z)}catch(I){A(I.message)}K(null),Ne.refetch(),Y(!1)}},yt=()=>{P.clear(),K(null)},Ct=I=>{X.current+=1,b(I),P.clear(),K(null),O(null),h(0),q.current=null},St=fl(ue,P.staged),M=async(I,z,Te)=>{if(f===null)return;A(null);let Ae;if(I!=="delete"){let ye;try{ye=Te===void 0||Te.trim()===""?{}:JSON.parse(Te)}catch(_e){A(`Invalid JSON: ${_e.message}`);return}try{const _e=Pt(ye);if(!ln(_e)){A("The document must be a JSON object.");return}Ae=_e}catch(_e){A(`Invalid document: ${_e.message}`);return}}try{await i.query(Rt,{doc:Ae,id:z??void 0,op:I,table:f},Re(j)),O(null),Ne.refetch()}catch(ye){A(ye.message)}},Z=async(I,z,Te)=>{if(f===null)return 0;const Ae=se,ye=X.current,_e=()=>re.current===Ae&&X.current===ye;A(null),G(null);const Bt=cl(I,z,j),zn=q.current?.key===Bt?q.current.after:void 0,qn=Te.resumable?zn??"":void 0;let je=0;try{const Ye=await Zs({args:z,maxBatches:Mt,openCursor:qn,query:async Kn=>{const jt=await i.query(I,Kn,Re(j));return je+=jt.count,jt}});return _e()&&(q.current=Ye.cursor===void 0?null:{after:Ye.cursor,key:Bt},Ye.outcome==="cap-hit"&&A(Te.truncated),G(`${je.toString()} ${je===1?"row":"rows"} ${Te.verb}.`)),je}catch(Ye){return _e()&&(A(`${Ye.message} (at least ${je.toString()} rows were already ${Te.verb})`),q.current=null),je}finally{_e()&&(h(0),Ne.refetch())}},Oe=I=>{S(I),h(0)},Be=$t(()=>f===null?[]:r?.(f)??[],[r,f]),Ee=vs(ue,y,Oe,Be),ot={filters:Fe(N),orderBy:it(y),search:W,shard:p,table:f??void 0},st=qe.data?.total,lt=st!==void 0,Lt=st??(ue===null?0:g+ue.rows.length),bn=g>0,hn=W!==""||Fe(N).length>0,xn=ue!==null&&(lt?g+ue.rows.length<Lt:ue.rows.length===u),vn=ue===null||ue.rows.length===0?0:g+1,wn=ue===null?0:g+ue.rows.length,yn=()=>{de.refetch()},Cn=()=>{v("table")},Sn=()=>{v("json")},Nn=()=>{Ce(Z(sl,{filters:Fe(N),search:W,table:f},tn))},kn=()=>{Ce(Z(ll,{table:f},tn))},Tn=I=>{Ce(Z(rl,{doc:I,filters:Fe(N),search:W,table:f},bl))},En=I=>{k(I.target.value),h(0)},_n=I=>{w(I),h(0)},Rn=()=>{A(null);const I={};for(const z of ue?.columns??[])Vt.has(z)||(I[z]="");O({docText:JSON.stringify(I,null,2),id:""})},$n=I=>{O(z=>z===null?z:{docText:I,id:z.id})},Dn=()=>{D!==null&&Ce(M(D.id===""?"insert":"patch",D.id===""?null:D.id,D.docText))},An=()=>{O(null),A(null)},Pn=()=>{Qe(g-u)},In=()=>{Qe(g+u)},On=I=>{Qe(Math.max(0,(I-1)*u))},Fn=I=>{m(I),h(0)},Mn=(I,z)=>{A(null),O({docText:JSON.stringify(rn(il(z)),null,2),id:I})},Vn=I=>{Ce(M("delete",I))},Ln=async I=>{if(!(f===null||I.length===0)){A(null);try{for(const z of I)await i.query(Rt,{id:z,op:"delete",table:f},Re(j));Ne.refetch()}catch(z){A(z.message)}}},Bn=I=>{Ce(Ln(I))},jn=()=>{Ce(wt())};return{addRow:Rn,bulkDelete:Nn,bulkPatch:Tn,cancelCellEdit:vt,cancelEdit:An,changePageSize:Fn,clearTable:kn,columns:ue?.columns??[],committing:H,currentView:ot,discardStaged:yt,editableColumn:ml,editing:D,editingCell:J,facetFilter:nt,facets:F,filter:C,filters:N,goNext:In,goPrevious:Pn,hasNext:xn,hasPredicate:hn,hasPrevious:bn,jumpToPage:On,liveError:Ge,loadTables:yn,navigateToRef:mt,onBulkDeleteSelected:Bn,onCommitStaged:jn,onFilterChange:En,onFiltersChange:_n,onRowDelete:Vn,onRowEdit:Mn,page:ue,previewRef:gt,pageError:ke,pageSize:u,rangeEnd:wn,rangeStart:vn,queryShardKey:j,saveEdit:Dn,selectedTable:f,selectTable:He,setEditorDocumentText:$n,setShardKey:Ct,shardKey:p,showJson:Sn,showTable:Cn,stage:P.stage,stagedChanges:St,stagedValue:P.stagedValue,startCellEdit:xt,table:Ee,tables:te,tablesError:De,toggleFacet:pt,total:Lt,totalKnown:lt,viewMode:x,writeError:V,writeNotice:L}},xl="lunora-studio-pinned-columns",vl=s=>{const e=B(21),{columns:n,initialPins:o,selectedTable:t}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];const[l,r]=nn(xl,c),a=t??"",i=l[a];let u;e[1]!==o||e[2]!==i?(u=i===void 0?new Set((o??"").split(",").filter(wl)):new Set(i),e[1]=o,e[2]=i,e[3]=u):u=e[3];const m=u;let p;e[4]!==a||e[5]!==m||e[6]!==r?(p=T=>{r(F=>{const R=F[a]??[...m],_=R.includes(T)?R.filter(D=>D!==T):[...R,T];return{...F,[a]:_}})},e[4]=a,e[5]=m,e[6]=r,e[7]=p):p=e[7];const b=p,[f,g]=$(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(yl)},e[8]=h):h=e[8];const x=h;let v;e[9]!==n||e[10]!==t?(v={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=v):v=e[11];const{maskColumns:y,maskOn:S,maskView:C,maskViewFor:k,onToggleMask:N}=Yn(v);let w;return e[12]!==y||e[13]!==S||e[14]!==C||e[15]!==k||e[16]!==N||e[17]!==b||e[18]!==m||e[19]!==f?(w={maskColumns:y,maskOn:S,maskView:C,maskViewFor:k,onToggleMask:N,onTogglePin:b,onToggleTranspose:x,pinnedColumns:m,transposed:f},e[12]=y,e[13]=S,e[14]=C,e[15]=k,e[16]=N,e[17]=b,e[18]=m,e[19]=f,e[20]=w):w=e[20],w};function wl(s){return s!==""}function yl(s){return!s}const Cl=$e(he.describeTable),Sl=$e(he.readTablePage),Nl=$e(he.importShard),kl=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},Tl=s=>{const e=Object.values(s.inserted).reduce((a,i)=>a+i,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,c=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${c})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},El=s=>{const e=ut(),[n,o]=$(!1),[t,c]=$(void 0),[l,r]=$(void 0),[a,i]=$(void 0),[u,m]=$({}),[p,b]=$(!1),[f,g]=$(void 0),h=async(S,C)=>{o(!0),c(S),r(C),i(void 0),m({}),g(void 0),b(!0);try{const k=await e.query(Cl,{table:S},Re(C)),{columns:N}=k;i(N);const w={},T=N.filter(F=>F.ref!==void 0&&F.type==="id"&&F.pk!==!0);for(const F of T){if(F.ref===void 0)continue;const{ref:R}=F;if(w[R]===void 0)try{const _=await e.query(Sl,{filters:[],limit:qs,offset:0,search:"",table:R},Re(C));w[R]=_.rows.flatMap(D=>kl(D)||[])}catch{w[R]=[]}}m(w)}catch(k){g(k.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),i(void 0),m({}),g(void 0)},columnMeta:a,error:f,fkPools:u,insertBatch:async(S,C)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const k=await e.query(Nl,{rows:S.map(w=>({doc:w,table:t}))},Re(l)),N=Tl(k);return N.error!==void 0||(C(),s()),N}catch(k){return{conflicts:0,error:k.message,inserted:0}}},loading:p,open:n,openDialog:(S,C)=>{Ce(h(S,C))},shardKey:l,table:t}},_l=s=>{const e=B(6),[n,o]=$(null);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{o(null)},e[0]=t):t=e[0];const c=t,[l,r]=$(null);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h,x)=>{r({column:g,storedValue:x,value:h})},e[1]=a):a=e[1];const i=a;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{r(null)},e[2]=u):u=e[2];const m=u,[p,b]=$(s);p!==s&&(b(s),o(null),r(null));let f;return e[3]!==l||e[4]!==n?(f={closeExpandedCell:m,closeInspect:c,expandedCell:l,inspecting:n,onExpandCell:i,onInspect:o},e[3]=l,e[4]=n,e[5]=f):f=e[5],f},Rl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,$l=(s,e)=>typeof e=="number"&&Rl.test(s),Dl=s=>{const e=B(36),{column:n,masked:o,onNavigate:t,target:c,value:l}=s;let r;e[0]!==t||e[1]!==c||e[2]!==l?(r=()=>{c!==void 0&&t(c,String(l))},e[0]=t,e[1]=c,e[2]=l,e[3]=r):r=e[3];const a=r;if(l==null){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=m):m=e[4],m}if(o){const m=`rd-masked-${n}`;let p;e[5]!==l?(p=Me(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==m||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":m,title:"Masked (preview)",children:p}),e[7]=m,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const m=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let f;return e[10]!==a||e[11]!==m||e[12]!==p||e[13]!==b?(f=E("button",{"data-testid":m,onClick:a,title:p,type:"button",children:[b," ↗"]}),e[10]=a,e[11]=m,e[12]=p,e[13]=b,e[14]=f):f=e[14],f}if($l(n,l)){const m=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let b;e[17]!==l?(b=Hn(l),e[17]=l,e[18]=b):b=e[18];let f;return e[19]!==m||e[20]!==p||e[21]!==b?(f=d("span",{"data-testid":m,title:p,children:b}),e[19]=m,e[20]=p,e[21]=b,e[22]=f):f=e[22],f}if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)){const m=`rd-bytes-${n}`;let p;e[23]!==l?(p=Me(l),e[23]=l,e[24]=p):p=e[24];let b;return e[25]!==m||e[26]!==p?(b=d("span",{"data-testid":m,children:p}),e[25]=m,e[26]=p,e[27]=b):b=e[27],b}if(typeof l=="object"){let m;e[28]!==l?(m=JSON.stringify(l,on,2),e[28]=l,e[29]=m):m=e[29];let p;return e[30]!==m?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:m}),e[30]=m,e[31]=p):p=e[31],p}let i;e[32]!==l?(i=Me(l),e[32]=l,e[33]=i):i=e[33];let u;return e[34]!==i?(u=d("span",{children:i}),e[34]=i,e[35]=u):u=e[35],u},Al=s=>{const e=B(23),{columns:n,mask:o,onClose:t,onNavigate:c,refs:l,row:r}=s;let a;e[0]!==t||e[1]!==c?(a=(g,h)=>{c(g,h),t()},e[0]=t,e[1]=c,e[2]=a):a=e[2];const i=a;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=u):u=e[3];let m;e[4]!==t?(m=E("div",{className:"mb-3 flex items-center justify-between",children:[u,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=m):m=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==i||e[9]!==l||e[10]!==r){let g;e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==r?(g=h=>E("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[d("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),d("dd",{className:"m-0",children:d(Dl,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:i,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=i,e[14]=l,e[15]=r,e[16]=g):g=e[16],p=n.map(g),e[6]=n,e[7]=o,e[8]=i,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let b;e[17]!==p?(b=d("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=b):b=e[18];let f;return e[19]!==t||e[20]!==m||e[21]!==b?(f=E(ft,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[m,b]}),e[19]=t,e[20]=m,e[21]=b,e[22]=f):f=e[22],f},Pl=50,Il=s=>{const e=B(8),{active:n,onPick:o,shard:t}=s;let c;e[0]!==o||e[1]!==t?(c=()=>{o(t)},e[0]=o,e[1]=t,e[2]=c):c=e[2];const l=c,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,a=`shard-explorer-item-${t}`;let i;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==a?(i=d("button",{className:r,"data-testid":a,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Ol=({onFetchTables:s,onSelect:e})=>{const n=ve(),[o]=$(()=>Eo()),[t,c]=$(!1),[l,r]=$(void 0),[a,i]=$(void 0),[u,m]=$(!1),[p,b]=$(void 0),f=Ke(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),i(void 0),b(void 0),m(!0),f.current+=1;const y=f.current;try{const S=await s(v);f.current===y&&i(S?.slice(0,Pl))}catch(S){f.current===y&&b(S.message)}f.current===y&&m(!1)},x=v=>{Ce(h(v))};return o.length===0?null:E("div",{"data-testid":"shard-explorer",children:[E("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:g,type:"button",children:[n("Shards seen"),d("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&E("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(v=>d("li",{children:d(Il,{active:l===v,onPick:x,shard:v})},v))}),l!==void 0&&E("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[d("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),u&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!u&&p===void 0&&a?.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!u&&p===void 0&&a!==void 0&&a.length>0&&d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:a.map(v=>E("li",{className:"flex items-center justify-between text-xs",children:[d("span",{"data-testid":`shard-explorer-table-${v.name}`,children:v.name}),d("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${v.name}`,children:v.rowCount})]},v.name))})]})]})]})},Fl="lunora-studio-back-relations",Ml=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),Vl=(s,e)=>s==null||typeof s=="string"||typeof s=="number"&&Number.isFinite(s)||typeof s=="boolean"||typeof s=="bigint"&&e==="bigint",Ll=(s,e)=>e===null&&(s==="eq"||s==="ne")?{literal:[null],value:"null"}:typeof e!="string"&&typeof e!="number"&&typeof e!="boolean"?{value:""}:typeof e=="string"&&(s==="eq"||s==="ne")?{literal:[e],value:e}:s!=="has"&&typeof e!="boolean"?{value:String(e)}:{literal:[e],value:typeof e=="string"?`"${e}"`:String(e)},Bl={},jl=50,zl=[],ql=$e(he.listTables),Kl=$e(he.readTablePage),Gl=s=>{const e=B(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Gn,{onChange:o,testId:"db-shard-input",value:c}),e[0]=o,e[1]=c,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=d(Ol,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let a;return e[6]!==t||e[7]!==l||e[8]!==r?(a=E("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=a):a=e[9],a},Nr=({canGenerateRows:s=!1,editable:e=!1,globalTableNames:n,initialFilters:o,initialOrderBy:t,initialPins:c,initialSearch:l,initialShardKey:r,onNavigateToGlobal:a,onSelectTable:i,onViewChange:u,pageSize:m=jl,queryBar:p,schemaSwitch:b,tableParam:f})=>{const g=Ze(he.describeTables,{},{shardKey:r??""}),h=Ze(he.listTablesIndexes,{},{shardKey:r??""}),x=g.data?.columnsByTable??Bl,[v,y]=nn(Fl,{}),S=ct(M=>{const Z=new Set(v[M]);return Jt(M,x).filter(Oe=>Z.has(Ot(Oe)))},[v,x]),C=hl({initialFilters:o,initialOrderBy:t,initialSearch:l,initialShardKey:r,onSelectTable:i,onViewChange:u,pageSize:m,resolveBackRelations:S,tableParam:f}),{cancelCellEdit:k,columns:N,currentView:w,editableColumn:T,editingCell:F,facetFilter:R,facets:_,loadTables:D,navigateToRef:O,onFiltersChange:V,page:A,pageError:L,previewRef:G,queryShardKey:q,selectedTable:P,selectTable:J,setShardKey:K,shardKey:H,stage:Y,stagedValue:U,startCellEdit:ne,tables:le,tablesError:ae,toggleFacet:ge}=C,fe=Jn(H),me=Xe(P),pe=M=>{const Z=P;Ce((async()=>{const Be=await fe.suggestFilter(M,Z??"");Be!==void 0&&me.current===Z&&V(Be.map(Ee=>{const{literal:ot,value:st}=Ll(Ee.operator,Ee.value),lt=Ee.path===void 0||Ee.path.length===0?{}:{path:Ee.path.join("."),pathSegments:Ee.path};return{column:Ee.column,operator:Ee.operator,...lt,...ot===void 0?{}:{literal:ot},value:st}}))})())},ie=P===null?[]:Jt(P,x),Q=new Set(v[P??""]),be=[];for(const M of A?.rows??[]){const Z=M._id??M.id;typeof Z=="string"&&Z!==""&&be.push(Z)}const ce=Ys(Q,ie,be,q),Se=M=>{y(Z=>{const Oe=P??"",Be=Z[Oe]??[];return{...Z,[Oe]:Be.includes(M)?Be.filter(Ee=>Ee!==M):[...Be,M]}})},oe=vl({columns:N,initialPins:c,selectedTable:P}),se=_l(JSON.stringify([P,q])),[W,j]=$(null),{closeExpandedCell:re,closeInspect:X,expandedCell:ee,inspecting:we,onExpandCell:xe}=se,de=ut(),te=Object.fromEntries((x[P??""]??[]).map(M=>[M.name,M])),De=new Map;for(const M of x[P??""]??[])M.isStorage===!0&&De.set(M.name,M.bucket);const Ve=ct(async(M,Z)=>de.signedStorageUrl(M,Z===void 0?{}:{bucket:Z}),[de]),Le=async M=>await de.query(ql,{},Re(M)),Ne=()=>{P!==null&&J(P)},{closeDialog:ue,columnMeta:ke,fkPools:Ge,insertBatch:qe,open:He,openDialog:mt}=El(Ne),gt=()=>{P!==null&&mt(P,H)},tt=M=>qe(M,ue),[pt,nt]=$(!1),bt=()=>{nt(!0)},ht=()=>{nt(!1)},Ue=(M,Z)=>{if(a!==void 0&&n?.has(M)===!0){a(M,Z);return}O(M,Z)},Qe=p?.onSaveQuery,xt=M=>{Qe?.(M,w)},vt={cancelEdit:k,editable:e,editableColumn:T,editingCell:F,onExpandCell:xe,stage:Y,stagedValue:U,startEdit:ne},wt=M=>{M!==null&&j(M)},yt=()=>{C.onRowDelete(W)},Ct=async(M,Z,Oe)=>await de.query(Kl,{filters:[{column:Z,operator:"eq",value:Oe}],limit:at,offset:0,orderBy:[],table:M},Re(q)),St={columns:A?.refs,maskViewFor:oe.maskViewFor,onNavigate:Ue,onPreview:G};return E("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(Xn,{header:d(Gl,{onFetchShardTables:Le,onShardChange:K,schemaSwitch:b,shardKey:H}),onReload:D,onSelect:J,prefix:"db",selected:P,tables:le??zl}),E("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[ae!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:ae}),A===null&&L===null&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),L!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:L}),A!==null&&d(js,{assistant:fe,backRelations:{available:ie,counts:ce,enabled:Q,onToggle:Se},browser:C,columnMeta:te,edit:vt,editable:e,onAskAiFilter:pe,onInspect:se.onInspect,onOpenBulkPatch:bt,onOpenGenerateRows:s?gt:void 0,onRowDelete:wt,onSaveQuery:xt,page:A,preferences:oe,queryBar:p,references:St})]}),A!==null&&d(Zn,{columns:N,facets:_,mask:oe.maskView,onFacetFilter:R,onToggleFacet:ge}),we!==null&&A!==null&&d(Al,{columns:A.columns,mask:oe.maskView,onClose:X,onNavigate:Ue,refs:A.refs,row:sn(we,oe.maskView)}),W!==null&&P!==null&&d(Bo,{onClose:()=>{j(null)},onConfirm:yt,readPage:Ct,rowId:W,schema:_o(x),table:P}),ee!==null&&d(No,{bucket:De.get(ee.column),column:ee.column,onClose:re,onFilter:Vl(ee.storedValue,te[ee.column]?.type)?()=>{R(ee.column,ee.storedValue??null),re()}:void 0,resolveUrl:De.has(ee.column)?Ve:void 0,value:ee.value}),pt&&P!==null&&d(Do,{columns:C.columns.filter(M=>C.editableColumn(M)),onApply:C.bulkPatch,onClose:ht,shardKey:C.queryShardKey,table:P,total:C.total,uniqueColumns:Ml(h.data?.indexesByTable[P])}),He&&P!==null&&ke!==void 0&&d(Us,{columns:ke,fkPools:Ge,onClose:ue,onInsertRows:tt,table:P})]})};export{Nr as DataBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as A,useRef as H,useEffect as I}from"react";import{a as Q}from"./use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as B}from"./DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as me}from"./use-mirrored-ref-CVDf2z1M.mjs";import{u as ue}from"./use-studio-client-DCA50tF2.mjs";import{useT as J}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{a as fe}from"./cf-links-BPy1pJRO.mjs";import{l as pe,o as ge,f as be}from"./internal-hIuTpSbx.mjs";import{m as Z,u as he,a as xe,T as ke,D as ve}from"./table-list-sidebar-C8qPvzGk.mjs";import{c as X}from"react/compiler-runtime";import{c as Ne,a as ye,b as q,e as we,d as Se,T as Te}from"./table-D0SBiDu-.mjs";import{a as Ce}from"./control-button-BOZ5K-FC.mjs";import{C as K,G as Fe}from"./data-grid-B5m1OosL.mjs";import{G as Pe}from"./grid-pagination-DY2erU65.mjs";import{jsx as r,jsxs as P}from"react/jsx-runtime";import{E as Ee}from"./empty-state-D7jEML_T.mjs";const Me=(t,e)=>{const i=t._id;return typeof i=="string"||typeof i=="number"?String(i):`row-${e.toString()}`},Oe=t=>t==null?"∅":t===""?"(empty)":pe(t),Ge=t=>{const e=X(45),{filters:i,hasMaskedColumns:p,mask:s,maskOn:u,onChangePageSize:a,onJumpToPage:R,onNext:d,onPrevious:S,onRemoveFilter:f,onToggleMask:L,page:n,pageSize:E,pagination:T}=t,C=J(),{hasNext:z,hasPrevious:D,rangeEnd:$,rangeStart:F,total:k}=T;let v;e[0]!==p||e[1]!==u||e[2]!==L||e[3]!==C?(v=p&&r("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2",children:r("button",{"aria-pressed":u,className:Ce,"data-testid":"gdb-mask-toggle",onClick:L,type:"button",children:C("Mask sensitive columns")})}),e[0]=p,e[1]=u,e[2]=L,e[3]=C,e[4]=v):v=e[4];let g;e[5]!==i||e[6]!==s||e[7]!==f||e[8]!==C?(g=i.length>0&&r("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2 text-xs","data-testid":"gdb-filters",children:i.map((c,m)=>{const O=Oe(Z(c.value,c.column,s));return P("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-muted px-1.5 py-0.5","data-testid":"gdb-filter-chip",children:[r("span",{className:"font-medium text-foreground",children:c.column}),r("span",{className:"text-muted-foreground",children:"="}),r("span",{className:"font-mono text-foreground",children:O}),r("button",{"aria-label":C("Remove filter"),className:"ml-0.5 text-muted-foreground hover:text-foreground","data-testid":"gdb-filter-remove",onClick:()=>{f(m)},type:"button",children:"✕"})]},`${c.column}:${O}`)})}),e[5]=i,e[6]=s,e[7]=f,e[8]=C,e[9]=g):g=e[9];let o;if(e[10]!==s||e[11]!==n.columns){let c;e[13]!==s?(c=m=>P(Ne,{children:[m,s.columns.has(m)&&r("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`gdb-mask-chip-${m}`,title:"This column is masked by a mask() policy",children:"masked"})]},m),e[13]=s,e[14]=c):c=e[14],o=n.columns.map(c),e[10]=s,e[11]=n.columns,e[12]=o}else o=e[12];let b;e[15]!==o?(b=r(ye,{children:r(q,{children:o})}),e[15]=o,e[16]=b):b=e[16];let N;if(e[17]!==s||e[18]!==n.columns||e[19]!==n.rows){let c;e[21]!==s||e[22]!==n.columns?(c=(m,O)=>r(q,{"data-testid":"gdb-row",children:n.columns.map(w=>r(we,{className:"max-w-xs truncate font-mono text-xs",children:s.enabled&&s.columns.has(w)?r("span",{className:"text-muted-foreground italic","data-testid":`gdb-masked-${w}`,title:"Masked (preview)",children:r(K,{value:Z(m[w],w,s)})}):r(K,{value:m[w]})},w))},Me(m,O)),e[21]=s,e[22]=n.columns,e[23]=c):c=e[23],N=n.rows.map(c),e[17]=s,e[18]=n.columns,e[19]=n.rows,e[20]=N}else N=e[20];let y;e[24]!==N?(y=r(Se,{children:N}),e[24]=N,e[25]=y):y=e[25];let h;e[26]!==b||e[27]!==y?(h=r(Fe,{layout:"fill",children:r("div",{className:"min-h-0 flex-1 overflow-auto",children:P(Te,{"data-testid":"gdb-rows",children:[b,y]})})}),e[26]=b,e[27]=y,e[28]=h):h=e[28];let x;e[29]!==z||e[30]!==D||e[31]!==a||e[32]!==R||e[33]!==d||e[34]!==S||e[35]!==E||e[36]!==$||e[37]!==F||e[38]!==k?(x=r("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:r(Pe,{hasNext:z,hasPrevious:D,onJumpToPage:R,onNext:d,onPageSizeChange:a,onPrevious:S,pageSize:E,prefix:"gdb",rangeEnd:$,rangeStart:F,total:k})}),e[29]=z,e[30]=D,e[31]=a,e[32]=R,e[33]=d,e[34]=S,e[35]=E,e[36]=$,e[37]=F,e[38]=k,e[39]=x):x=e[39];let M;return e[40]!==v||e[41]!==g||e[42]!==h||e[43]!==x?(M=P("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"gdb-page",children:[v,g,h,x]}),e[40]=v,e[41]=g,e[42]=h,e[43]=x,e[44]=M):M=e[44],M},Re=()=>{const t=X(8),e=J();let i;t[0]!==e?(i=e("Tables marked .global() (D1-backed, region-replicated) will appear here."),t[0]=e,t[1]=i):i=t[1];let p;t[2]===Symbol.for("react.memo_cache_sentinel")?(p=P("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M3 12h18M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18Z"})]}),t[2]=p):p=t[2];let s;t[3]!==e?(s=e("No global tables."),t[3]=e,t[4]=s):s=t[4];let u;return t[5]!==i||t[6]!==s?(u=r("div",{className:"flex flex-1 items-center justify-center p-6",children:r(Ee,{description:i,icon:p,testId:"gdb-empty",title:s})}),t[5]=i,t[6]=s,t[7]=u):u=t[7],u},Le=50,ze=[],W=[],Xe=({initialTable:t,onSelectTable:e,pageSize:i=Le,schemaSwitch:p}={})=>{const s=ue(),u=J(),[a,R]=A(t??null),[d,S]=A(0),[f,L]=A(i),[n,E]=A([]),T=me(n),{clearFacets:C,facets:z,refetchFacets:D,toggleFacet:$}=he(),F=Q(["lunora-global-tables"],()=>s.listGlobalTables()),k=F.data??null,v=F.error,g=Q(["lunora-global-page",a??"",d,f,JSON.stringify(n)],()=>s.readGlobalTablePage({filters:n,limit:f,offset:d,table:a??""}),{enabled:a!==null,keepPreviousData:!1}),o=g.data??null,b=g.error,N=(l,G)=>j=>s.facetGlobalColumn({column:j,filters:G,table:l}),y=(l,G)=>D(N(l,G));B(()=>F.poll(),!0),B(()=>g.poll(),a!==null,void 0,JSON.stringify([a,d,f,n])),B(()=>a===null?void 0:y(a,T.current),a!==null,void 0,JSON.stringify([a,n]));const h=H(void 0),x=l=>{R(l),h.current=l,E([]),T.current=[],C(),S(0),e?.(l)},M=l=>{$(l,a===null?null:N(a,T.current))},c=l=>{E(l),T.current=l,S(0),a!==null&&be(y(a,l))},m=(l,G)=>{c([...T.current.filter(j=>j.column!==l),{column:l,value:ge(G)}])},O=l=>{c(T.current.filter((G,j)=>j!==l))},w=H(x);I(()=>{w.current=x}),I(()=>{if(t===void 0||t===""||h.current===t)return;h.current=t;const l=t;queueMicrotask(()=>{w.current(l)})},[t]);const V=l=>{a!==null&&S(Math.max(0,l))},{maskColumns:Y,maskOn:ee,maskView:_,onToggleMask:te}=xe({columns:o?.columns??W,selectedTable:a}),U=o?.total??0,re=d>0,se=o!==null&&d+o.rows.length<U,le=o===null||o.rows.length===0?0:d+1,ae=o===null?0:d+o.rows.length,oe=()=>{F.refetch()},ne=()=>{V(d-f)},ie=()=>{V(d+f)},ce=l=>{V(Math.max(0,(l-1)*f))},de=l=>{L(l),S(0)};return P("div",{className:"flex h-full min-w-0","data-testid":"lunora-global-data-browser",children:[r(ke,{header:P("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[p,r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"gdb-cf-link",href:fe,rel:"noreferrer",target:"_blank",children:u("Open in Cloudflare")})]}),onReload:oe,onSelect:x,prefix:"gdb",selected:a,tables:k??ze}),P("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[v!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-tables-error",role:"alert",children:v}),k!==null&&k.length===0&&r(Re,{}),b!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-page-error",role:"alert",children:b}),k!==null&&k.length>0&&o===null&&b===null&&r("div",{className:"flex flex-1 items-center justify-center p-6",children:r("p",{className:"text-sm text-muted-foreground",children:u("Select a table to browse its rows.")})}),o!==null&&r(Ge,{filters:n,hasMaskedColumns:Y.size>0,mask:_,maskOn:ee,onChangePageSize:de,onJumpToPage:ce,onNext:ie,onPrevious:ne,onRemoveFilter:O,onToggleMask:te,page:o,pageSize:f,pagination:{hasNext:se,hasPrevious:re,rangeEnd:ae,rangeStart:le,total:U}})]}),r(ve,{columns:o?.columns??W,facets:z,mask:_,onFacetFilter:m,onToggleFacet:M})]})};export{Xe as GlobalDataBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as I}from"react/compiler-runtime";import{useState as T,useEffect as $}from"react";import{ConfirmButton as H}from"./ConfirmButton-CIXYF6Mg.mjs";import{C as M,a as P}from"./card-By2O8ULa.mjs";import{E as Q}from"./empty-state-D7jEML_T.mjs";import{T as R,a as q,b as J,c as l,d as D,e as i}from"./table-D0SBiDu-.mjs";import{a as K}from"./use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as V}from"./DEFAULT_AUTO_REFRESH_MS-
|
|
1
|
+
import{c as I}from"react/compiler-runtime";import{useState as T,useEffect as $}from"react";import{ConfirmButton as H}from"./ConfirmButton-CIXYF6Mg.mjs";import{C as M,a as P}from"./card-By2O8ULa.mjs";import{E as Q}from"./empty-state-D7jEML_T.mjs";import{T as R,a as q,b as J,c as l,d as D,e as i}from"./table-D0SBiDu-.mjs";import{a as K}from"./use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as V}from"./DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as W}from"./use-studio-client-DCA50tF2.mjs";import{useT as z}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{f as G,h as O,b as U}from"./internal-hIuTpSbx.mjs";import{jsx as t,jsxs as p}from"react/jsx-runtime";const X=s=>Number.isFinite(s)?O(s,"—"):"—",F=s=>s.toSorted((e,u)=>e.scheduledFor-u.scheduledFor),Y=(s,e,u)=>e!==void 0?e:u===void 0?f=>s.cancelScheduledJob(f):void 0,he=s=>{const e=I(16),{cancelJob:u,loadJobs:f}=s===void 0?{}:s,n=W(),o=z(),c=f===void 0;let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=["lunora-scheduled-jobs"],e[0]=b):b=e[0];const d=K(b,async()=>{const r=await(f??(()=>n.listScheduledJobs()))();return F(r)}),[j,k]=T(void 0),[A,w]=T(void 0);let v,x;e[1]!==n||e[2]!==c?(v=()=>{if(c)return n.subscribeScheduledJobs(r=>{w(void 0),k(F(r))})},x=[c,n],e[1]=n,e[2]=c,e[3]=v,e[4]=x):(v=e[3],x=e[4]),$(v,x);let y;e[5]!==d?(y=()=>d.poll(),e[5]=d,e[6]=y):y=e[6],V(y,!c);const C=Y(n,u,f),a=j??d.data,N=A??d.error,E=async r=>{if(C!==void 0){w(void 0);try{await C(r),c||d.refetch()}catch(_){w(U(_))}}},L="flex flex-col gap-3",B="lunora-scheduled-jobs";let m;e[7]!==N?(m=N!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:N}),e[7]=N,e[8]=m):m=e[8];let h;e[9]!==a?.length||e[10]!==o?(h=a?.length===0&&t(Q,{description:o("Jobs queued with runAfter / runAt will appear here."),icon:p("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:o("No scheduled jobs.")}),e[9]=a?.length,e[10]=o,e[11]=h):h=e[11];const S=a!==void 0&&a.length>0&&t(M,{className:"overflow-hidden py-0",children:t(P,{className:"px-0",children:p(R,{"data-testid":"sj-table",children:[t(q,{children:p(J,{children:[t(l,{children:o("function")}),t(l,{children:o("scheduled for")}),t(l,{children:o("pool")}),t(l,{children:o("attempts")}),t(l,{children:o("shard")}),t(l,{children:o("id")}),C!==void 0&&t(l,{"aria-label":o("Actions")})]})}),t(D,{children:a.map(r=>p(J,{"data-testid":`sj-row-${r.id}`,children:[t(i,{className:"font-mono text-xs",children:r.workflow??r.functionPath}),t(i,{className:"text-muted-foreground tabular-nums",children:X(r.scheduledFor)}),t(i,{className:"font-mono text-xs",children:r.pool??""}),t(i,{className:"tabular-nums",children:r.attempts??0}),t(i,{children:r.shardKey??""}),t(i,{className:"font-mono text-xs",children:r.id}),C!==void 0&&t(i,{className:"text-right",children:t(H,{confirmLabel:o("Cancel job?"),onConfirm:()=>{G(E(r.id))},testId:`sj-cancel-${r.id}`,children:o("Cancel")})})]},r.id))})]})})});let g;return e[12]!==S||e[13]!==m||e[14]!==h?(g=p("div",{className:L,"data-testid":B,children:[m,h,S]}),e[12]=S,e[13]=m,e[14]=h,e[15]=g):g=e[15],g};export{he as ScheduledJobs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./assistant-provider-BQG7QZAu.mjs";import{S as c}from"./studio-
|
|
1
|
+
import"./assistant-provider-BQG7QZAu.mjs";import{S as c}from"./studio-DtxNxSjs.mjs";import"./ErrorBoundary-BWNF98VF.mjs";import"./operation-console-provider-DoloEvon.mjs";import"./badge-r_5B4LHP.mjs";import"./input-CXhxesPC.mjs";import"./skeleton-DX1gfixl.mjs";import"./home-panel-DTWHlX5S.mjs";import"./DEFAULT_LOCALE-BQ3jRT74.mjs";import"./StudioI18nProvider-CGXCPnQn.mjs";import"./data-view-params-C-_G-biH.mjs";import"./internal-hIuTpSbx.mjs";import"./utils-bhneXptQ.mjs";import"./CommandPalette-BZCHLpst.mjs";export{c as Studio};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as O}from"react/compiler-runtime";import{LunoraAdminClient as G}from"@lunora/client/admin";import{LunoraProvider as H}from"@lunora/react";import{useState as B,useEffect as $}from"react";import{ErrorBoundary as z}from"./ErrorBoundary-BWNF98VF.mjs";import{u as U,B as V,T as Y,a as q,S as J}from"./studio-
|
|
1
|
+
import{c as O}from"react/compiler-runtime";import{LunoraAdminClient as G}from"@lunora/client/admin";import{LunoraProvider as H}from"@lunora/react";import{useState as B,useEffect as $}from"react";import{ErrorBoundary as z}from"./ErrorBoundary-BWNF98VF.mjs";import{u as U,B as V,T as Y,a as q,S as J}from"./studio-DtxNxSjs.mjs";import Q from"./useDebounced-DVeQ5-oW.mjs";import{useT as j,createStudioI18n as X}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{StudioI18nProvider as D}from"./StudioI18nProvider-CGXCPnQn.mjs";import{r as Z}from"./internal-hIuTpSbx.mjs";import{w as R}from"./recording-client-z4CBi0y8.mjs";import F from"./STUDIO_ROOT_CLASS-C6MccdVk.mjs";import{a as K}from"./browser-storage-BH1MxLZs.mjs";import{c as W}from"./utils-bhneXptQ.mjs";import{B as ee}from"./button-q0UYSmrn.mjs";import{I as te}from"./input-CXhxesPC.mjs";import{jsx as f,jsxs as C}from"react/jsx-runtime";const M="lunora-studio-admin-token",oe=()=>{try{return K("session")?.getItem(M)??""}catch{return""}},ne=m=>{const e=K("session");if(e!==void 0)try{m===""?e.removeItem(M):e.setItem(M,m)}catch{}},ie="/_lunora/admin/ws-token",se=1e4,le=m=>{const e=m;return typeof e?.token=="string"&&e.token.length>0&&typeof e.expiresAtMs=="number"},re=m=>{const{adminToken:e,baseUrl:a}=m,o=m.fetchImpl??fetch;let l=a;for(;l.endsWith("/");)l=l.slice(0,-1);const r=`${l}${ie}`;let t,n;const i=async()=>{const s=await o(r,{headers:{authorization:`Bearer ${e}`},method:"POST"});if(!s.ok)throw new Error(`ws-token mint failed: ${String(s.status)}`);const u=await s.json().catch(()=>{});if(!le(u))throw new Error("ws-token mint failed: malformed response body");return t=u,u.token};return{getToken:async()=>t!==void 0&&t.expiresAtMs-se>Date.now()?t.token:(n??=i().finally(()=>{n=void 0}),n),invalidate:()=>{t=void 0}}},ae=m=>{const e=O(42),{onSubmit:a}=m,o=j(),[l,r]=B("");let t;e[0]!==l?(t=l.trim(),e[0]=l,e[1]=t):t=e[1];const n=t;let i;e[2]!==a||e[3]!==n?(i=_=>{_.preventDefault(),n!==""&&a(n)},e[2]=a,e[3]=n,e[4]=i):i=e[4];const s=i;let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=f("div",{className:"h-10 w-10 text-foreground",children:f(V,{})}),e[5]=u):u=e[5];let d;e[6]!==o?(d=o("Connect to Lunora Studio"),e[6]=o,e[7]=d):d=e[7];let v;e[8]!==d?(v=f("h1",{className:"text-base font-semibold text-foreground",children:d}),e[8]=d,e[9]=v):v=e[9];let k;e[10]!==o?(k=o("Enter your admin token to access the studio."),e[10]=o,e[11]=k):k=e[11];let p;e[12]!==k?(p=f("p",{className:"text-[13px] text-muted-foreground",children:k}),e[12]=k,e[13]=p):p=e[13];let h;e[14]!==v||e[15]!==p?(h=C("div",{className:"flex flex-col items-center gap-3 text-center",children:[u,C("div",{className:"flex flex-col gap-1",children:[v,p]})]}),e[14]=v,e[15]=p,e[16]=h):h=e[16];let g;e[17]!==o?(g=o("admin token"),e[17]=o,e[18]=g):g=e[18];let c;e[19]!==g?(c=f("label",{className:"text-xs font-medium text-foreground",htmlFor:"lunora-studio-login-token",children:g}),e[19]=g,e[20]=c):c=e[20];let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b=_=>{r(_.target.value)},e[21]=b):b=e[21];let x;e[22]!==l?(x=f(te,{autoComplete:"off",autoFocus:!0,"data-testid":"lunora-studio-login-token",id:"lunora-studio-login-token",onChange:b,placeholder:"LUNORA_ADMIN_TOKEN",type:"password",value:l}),e[22]=l,e[23]=x):x=e[23];let T;e[24]!==o?(T=o("From your worker's LUNORA_ADMIN_TOKEN — your project's .dev.vars in dev, or a deployment secret in production."),e[24]=o,e[25]=T):T=e[25];let I;e[26]!==T?(I=f("p",{className:"text-[11px] text-muted-foreground",children:T}),e[26]=T,e[27]=I):I=e[27];let S;e[28]!==c||e[29]!==x||e[30]!==I?(S=C("div",{className:"flex flex-col gap-1.5",children:[c,x,I]}),e[28]=c,e[29]=x,e[30]=I,e[31]=S):S=e[31];const E=n==="";let y;e[32]!==o?(y=o("Connect"),e[32]=o,e[33]=y):y=e[33];let w;e[34]!==E||e[35]!==y?(w=f(ee,{"data-testid":"lunora-studio-login-submit",disabled:E,type:"submit",children:y}),e[34]=E,e[35]=y,e[36]=w):w=e[36];let N;return e[37]!==s||e[38]!==S||e[39]!==w||e[40]!==h?(N=C("form",{className:"flex w-full max-w-sm flex-col gap-5 rounded-xl border border-border bg-card p-7 shadow-lg","data-testid":"lunora-studio-login",onSubmit:s,children:[h,S,w]}),e[37]=s,e[38]=S,e[39]=w,e[40]=h,e[41]=N):N=e[41],N},de=m=>{const e=O(10),{i18n:a,onSubmit:o}=m,{resolvedTheme:l}=U(),r=l==="dark"&&"dark";let t;e[0]!==r?(t=W(F,r,"flex h-dvh items-center justify-center bg-sidebar p-6 text-sm text-foreground"),e[0]=r,e[1]=t):t=e[1];let n;e[2]!==o?(n=f(ae,{onSubmit:o}),e[2]=o,e[3]=n):n=e[3];let i;e[4]!==a||e[5]!==n?(i=f(D,{i18n:a,children:n}),e[4]=a,e[5]=n,e[6]=i):i=e[6];let s;return e[7]!==t||e[8]!==i?(s=f("div",{className:t,"data-testid":"lunora-studio-login-root",children:i}),e[7]=t,e[8]=i,e[9]=s):s=e[9],s},ce=m=>{const e=O(15),{basePath:a,chrome:o,studio:l}=m,r=j();let t;e[0]!==r?(t=r("Studio failed"),e[0]=r,e[1]=t):t=e[1];let n;e[2]!==r?(n=r("Studio"),e[2]=r,e[3]=n):n=e[3];let i;e[4]!==r?(i=r("Try again"),e[4]=r,e[5]=i):i=e[5];let s;e[6]!==a||e[7]!==o||e[8]!==l?(s=f(J,{...l,basePath:a,chrome:o}),e[6]=a,e[7]=o,e[8]=l,e[9]=s):s=e[9];let u;return e[10]!==t||e[11]!==n||e[12]!==i||e[13]!==s?(u=f(z,{fallbackTitle:t,label:n,retryLabel:i,children:s}),e[10]=t,e[11]=n,e[12]=i,e[13]=s,e[14]=u):u=e[14],u},fe=m=>{const e=O(20),{basePath:a,clearToken:o,client:l,i18n:r,onTokenChange:t,rulesInstalled:n,studio:i,token:s}=m,{resolvedTheme:u}=U();let d;e[0]!==o||e[1]!==t||e[2]!==n||e[3]!==s?(d={clearToken:o,onTokenChange:t,rulesInstalled:n,token:s},e[0]=o,e[1]=t,e[2]=n,e[3]=s,e[4]=d):d=e[4];const v=d,k=u==="dark"&&"dark";let p;e[5]!==k?(p=W(F,k,"flex h-dvh flex-col overflow-hidden bg-sidebar text-sm text-foreground"),e[5]=k,e[6]=p):p=e[6];let h;e[7]!==a||e[8]!==v||e[9]!==i?(h=f(q,{children:f(ce,{basePath:a,chrome:v,studio:i})}),e[7]=a,e[8]=v,e[9]=i,e[10]=h):h=e[10];let g;e[11]!==r||e[12]!==h?(g=f(D,{i18n:r,children:h}),e[11]=r,e[12]=h,e[13]=g):g=e[13];let c;e[14]!==l||e[15]!==g?(c=f(H,{client:l,children:g}),e[14]=l,e[15]=g,e[16]=c):c=e[16];let b;return e[17]!==p||e[18]!==c?(b=f("div",{className:p,"data-testid":"lunora-studio-app",children:c}),e[17]=p,e[18]=c,e[19]=b):b=e[19],b},Ee=m=>{const e=O(28);let a;e[0]!==m?(a=m===void 0?{}:m,e[0]=m,e[1]=a):a=e[1];const{adminToken:o,basePath:l,baseUrl:r,client:t,rulesInstalled:n,studio:i,locale:s}=a;let u;e[2]!==o?(u=()=>o??oe(),e[2]=o,e[3]=u):u=e[3];const[d,v]=B(u);let k,p;e[4]!==d?(k=()=>{ne(d)},p=[d],e[4]=d,e[5]=k,e[6]=p):(k=e[5],p=e[6]),$(k,p);const h=Q(d,300,d==="");let g;e:{if(t!==void 0){let A;e[7]!==t?(A=R(t),e[7]=t,e[8]=A):A=e[8],g=A;break e}let _;if(e[9]!==r||e[10]!==h){const A=Z(r),P=h===""?void 0:re({adminToken:h,baseUrl:A}),L=new G({url:A,...P===void 0?{}:{wsTicket:P.getToken}});P!==void 0&&(L.setAuthToken(h),L.onTokenExpired(P.invalidate)),_=R(L),e[9]=r,e[10]=h,e[11]=_}else _=e[11];g=_}const c=g;let b,x;e[12]!==c||e[13]!==t?(b=()=>()=>{t===void 0&&c.close()},x=[c,t],e[12]=c,e[13]=t,e[14]=b,e[15]=x):(b=e[14],x=e[15]),$(b,x);let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=_=>{v(_.target.value)},e[16]=T):T=e[16];const I=T;let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{v("")},e[17]=S):S=e[17];const E=S;let y;e[18]!==s?(y=X(s),e[18]=s,e[19]=y):y=e[19];const w=y;let N;return e[20]!==l||e[21]!==c||e[22]!==w||e[23]!==t||e[24]!==n||e[25]!==i||e[26]!==d?(N=f(Y,{children:d===""&&t===void 0?f(de,{i18n:w,onSubmit:v}):f(fe,{basePath:l,clearToken:E,client:c,i18n:w,onTokenChange:I,rulesInstalled:n,studio:i,token:d})}),e[20]=l,e[21]=c,e[22]=w,e[23]=t,e[24]=n,e[25]=i,e[26]=d,e[27]=N):N=e[27],N};export{Ee as StudioApp};
|