@lunora/studio 1.0.0-alpha.85 → 1.0.0-alpha.87
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.ts +18 -3
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +6 -6
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/migrations-route.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/users-panel.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js +1 -0
- package/dist/packem_shared/{ApiDocsPanel-fYS9NiLg.js → ApiDocsPanel-DLMeLZ5-.js} +1 -1
- package/dist/packem_shared/DataBrowser-CZZ_WkJ-.js +1 -0
- package/dist/packem_shared/{GlobalDataBrowser-CSttudUx.js → GlobalDataBrowser-DpkjHfDg.js} +1 -1
- package/dist/packem_shared/{HomePanel-BYsfMhKh.js → HomePanel-3baDsDBU.js} +1 -1
- package/dist/packem_shared/MigrationsPanel-dygzHUvg.js +1 -0
- package/dist/packem_shared/{Studio-Ba9x0dG_.js → Studio-forQt-PC.js} +1 -1
- package/dist/packem_shared/{StudioApp-B_PRdg4h.js → StudioApp-B1AWsBzi.js} +1 -1
- package/dist/packem_shared/{home-panel-B60-5YfI.js → home-panel-CeeqqV0z.js} +1 -1
- package/dist/packem_shared/{studio-CPuoAmjh.js → studio-BtC7WPbz.js} +1 -1
- package/dist/packem_shared/table-list-sidebar-D9Bd4qgi.js +1 -0
- package/dist/packem_shared/use-shard-key-B2JtNa5m.js +1 -0
- package/dist/packem_shared/{use-sql-assistant-BLG9unQN.js → use-sql-assistant-C6dl2_Ty.js} +1 -1
- package/dist/packem_shared/useDebounced-CU-uftxO.js +1 -0
- package/dist/standalone/chunk-2VWWXVWK.js +1 -0
- package/dist/standalone/chunk-3CWGJYBB.js +1 -0
- package/dist/standalone/{chunk-52OYJHM7.js → chunk-4JIOFDMR.js} +1 -1
- package/dist/standalone/{chunk-MN64D74P.js → chunk-4LCY5XUR.js} +1 -1
- package/dist/standalone/{chunk-JE3WK77V.js → chunk-5KRD6F67.js} +1 -1
- package/dist/standalone/{chunk-RC3H4OP3.js → chunk-5X4OZ7OD.js} +1 -1
- package/dist/standalone/{chunk-TO45V3L6.js → chunk-6MGI5IN6.js} +1 -1
- package/dist/standalone/{chunk-HJR42BJY.js → chunk-7DNDRUMZ.js} +1 -1
- package/dist/standalone/chunk-7FO57AZY.js +1 -0
- package/dist/standalone/{chunk-YNBIW2GN.js → chunk-B5S6GSUC.js} +1 -1
- package/dist/standalone/{chunk-QZ6TCNWR.js → chunk-B5UFGO4E.js} +1 -1
- package/dist/standalone/{chunk-RFBU5RZI.js → chunk-BDNDSBYM.js} +1 -1
- package/dist/standalone/{chunk-QS4IFAFJ.js → chunk-CLNB7I3O.js} +1 -1
- package/dist/standalone/{chunk-QSFKPGK4.js → chunk-D3JTCLSF.js} +1 -1
- package/dist/standalone/chunk-DABW4OOI.js +1 -0
- package/dist/standalone/{chunk-SPT3KPV7.js → chunk-EAIUBZA5.js} +1 -1
- package/dist/standalone/{chunk-FUBR2PAD.js → chunk-EJ2CHD4G.js} +1 -1
- package/dist/standalone/chunk-EVTCXQ5D.js +1 -0
- package/dist/standalone/{chunk-OLM62NLS.js → chunk-EWDLYYJM.js} +1 -1
- package/dist/standalone/{chunk-ZOX6X2DL.js → chunk-F7NVC7YK.js} +1 -1
- package/dist/standalone/chunk-FURI47Z2.js +1 -0
- package/dist/standalone/chunk-FW75RYZU.js +1 -0
- package/dist/standalone/chunk-GE5WTIWX.js +1 -0
- package/dist/standalone/{chunk-BAAU4OTI.js → chunk-GZS3ORGS.js} +1 -1
- package/dist/standalone/chunk-HYCMT2V5.js +1 -0
- package/dist/standalone/{chunk-5YADKLAQ.js → chunk-IAKPXGTQ.js} +1 -1
- package/dist/standalone/chunk-IVCIG5J7.js +4 -0
- package/dist/standalone/chunk-KJIBL5D4.js +1 -0
- package/dist/standalone/chunk-L4RW5BFD.js +1 -0
- package/dist/standalone/{chunk-PWTURL56.js → chunk-LYRAWNV7.js} +1 -1
- package/dist/standalone/chunk-MIFLRBVS.js +11 -0
- package/dist/standalone/{chunk-OOL3FV6A.js → chunk-MV4A2PAK.js} +1 -1
- package/dist/standalone/{chunk-347H2BQO.js → chunk-NBUBAW3V.js} +1 -1
- package/dist/standalone/{chunk-232MBXB2.js → chunk-NCWUTRZB.js} +1 -1
- package/dist/standalone/{chunk-D67BVBQW.js → chunk-NMLCYY4H.js} +1 -1
- package/dist/standalone/{chunk-MDHUWMFD.js → chunk-OOWHAURL.js} +1 -1
- package/dist/standalone/{chunk-UOQ24BAY.js → chunk-ORVR33FM.js} +1 -1
- package/dist/standalone/{chunk-7AG3T4DK.js → chunk-OUCGTB3Y.js} +2 -2
- package/dist/standalone/chunk-PDMZITZZ.js +1 -0
- package/dist/standalone/{chunk-VORDESEQ.js → chunk-PNAVAJAF.js} +1 -1
- package/dist/standalone/{chunk-LVJ5IHEU.js → chunk-QJTGO4JG.js} +1 -1
- package/dist/standalone/{chunk-EDOMDMVI.js → chunk-QP7IQOKF.js} +1 -1
- package/dist/standalone/chunk-QXDMHM2V.js +1 -0
- package/dist/standalone/{chunk-VKEJTZY7.js → chunk-S2CXYDNT.js} +1 -1
- package/dist/standalone/{chunk-AQKXMWNF.js → chunk-S3DWUXGY.js} +1 -1
- package/dist/standalone/{chunk-YSMJN36P.js → chunk-SJZQPIZB.js} +1 -1
- package/dist/standalone/{chunk-ETZYJL7Z.js → chunk-SMEW3ZTU.js} +1 -1
- package/dist/standalone/chunk-SNK7TOOO.js +6 -0
- package/dist/standalone/{chunk-QI25LTPH.js → chunk-T2Q7I3V2.js} +1 -1
- package/dist/standalone/{chunk-ESKVOZLC.js → chunk-T3CGXSXO.js} +1 -1
- package/dist/standalone/{chunk-YGKR536O.js → chunk-TS6346VY.js} +1 -1
- package/dist/standalone/{chunk-ENBTOX7N.js → chunk-TVGKSIIW.js} +1 -1
- package/dist/standalone/{chunk-U5IIRHZ6.js → chunk-UNVK2VZP.js} +1 -1
- package/dist/standalone/{chunk-U44CWN7H.js → chunk-UR3X4K4T.js} +1 -1
- package/dist/standalone/chunk-VDW32UET.js +1 -0
- package/dist/standalone/chunk-VQK34A2H.js +1 -0
- package/dist/standalone/{chunk-MBVSXVTV.js → chunk-WPUINKEO.js} +1 -1
- package/dist/standalone/chunk-XNGYYOLS.js +14 -0
- package/dist/standalone/{chunk-2SC3EG5Y.js → chunk-XR7RBXKA.js} +1 -1
- package/dist/standalone/{chunk-KNHWIHC7.js → chunk-XZN645UJ.js} +1 -1
- package/dist/standalone/chunk-YFJXQUPW.js +1 -0
- package/dist/standalone/chunk-YKAO3JNJ.js +1 -0
- package/dist/standalone/{chunk-AHVDZWB3.js → chunk-YRYEZHOJ.js} +1 -1
- package/dist/standalone/{chunk-TIR6CWHO.js → chunk-ZCFDQW4U.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/ADMIN_FUNCTIONS-CZESgd10.js +0 -1
- package/dist/packem_shared/DataBrowser-C4J4gVUu.js +0 -1
- package/dist/packem_shared/MigrationsPanel-2JbQ2HwG.js +0 -1
- package/dist/packem_shared/table-list-sidebar-BRv3hTLX.js +0 -1
- package/dist/packem_shared/useDebounced-Ihdiid_k.js +0 -1
- package/dist/standalone/chunk-22LOWEEC.js +0 -1
- package/dist/standalone/chunk-2EJADIPC.js +0 -1
- package/dist/standalone/chunk-4I2TBTZS.js +0 -1
- package/dist/standalone/chunk-6IEBRNDW.js +0 -1
- package/dist/standalone/chunk-D3FRQZ4X.js +0 -1
- package/dist/standalone/chunk-ERMTJYQF.js +0 -1
- package/dist/standalone/chunk-JAT5ZBQK.js +0 -1
- package/dist/standalone/chunk-JOFD43OI.js +0 -1
- package/dist/standalone/chunk-LFKCLLPT.js +0 -1
- package/dist/standalone/chunk-MLULN4R2.js +0 -1
- package/dist/standalone/chunk-MUGKOGZG.js +0 -1
- package/dist/standalone/chunk-NPKNFZUW.js +0 -6
- package/dist/standalone/chunk-OV63HVE4.js +0 -4
- package/dist/standalone/chunk-QFJRZR4U.js +0 -1
- package/dist/standalone/chunk-QNRAMF4X.js +0 -1
- package/dist/standalone/chunk-QNUWWC3N.js +0 -14
- package/dist/standalone/chunk-S67SBGB3.js +0 -1
- package/dist/standalone/chunk-SHD2IWQI.js +0 -1
- package/dist/standalone/chunk-SKFZXESP.js +0 -1
- package/dist/standalone/chunk-UBR4KB6K.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as K}from"react/compiler-runtime";import{E as M}from"../packem_shared/error-alert-t6cpEi0z.js";import{ShardInput as T}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as $}from"../packem_shared/badge-BbuuAio7.js";import{c as j,u as _}from"../packem_shared/card-CIDGUN6K.js";import{E as q}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as D,d as F,m as C,p as g,f as J,u as N}from"../packem_shared/table-DdJBrClo.js";import{N as L}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{S as P}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as t,jsxs as c}from"react/jsx-runtime";const A=80,B=a=>{if(a===void 0)return"";const e=JSON.stringify(a);return e.length>A?`${e.slice(0,A)}…`:e},G=a=>{const e=[];for(const i of a){const n=i.id.toString();if(i.subscriptions.length===0){e.push({admin:i.admin,connectionId:i.id,key:`c${n}`,subscription:null});continue}i.subscriptions.forEach((u,o)=>{e.push({admin:i.admin,connectionId:i.id,key:`c${n}-s${o.toString()}`,subscription:u})})}return e},k=t("span",{className:"text-muted-foreground",children:"—"}),oe=a=>{const e=K(22),{initialShardKey:i}=a,n=R(),{queryShardKey:u,setShardKey:o,shardKey:m}=P(i);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==u?(f={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=f):f=e[2];const{data:r,error:s,errorSource:h,refetch:E}=L(W.listSubscriptions,p,f);O(E,!0);let b;if(e[3]!==s||e[4]!==h||e[5]!==r||e[6]!==o||e[7]!==m||e[8]!==n){const S=r===void 0?[]:G(r.connections);let l;e[10]!==o||e[11]!==m?(l=t(T,{onChange:o,testId:"subs-shard-input",value:m}),e[10]=o,e[11]=m,e[12]=l):l=e[12];let d;e[13]!==r||e[14]!==n?(d=r!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t($,{variant:"secondary",children:n("{count} connections",{count:r.totalConnections})}),t($,{variant:"secondary",children:n("{count} subscriptions",{count:r.totalSubscriptions})})]}),e[13]=r,e[14]=n,e[15]=d):d=e[15];let v;e[16]!==l||e[17]!==d?(v=c("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),e[16]=l,e[17]=d,e[18]=v):v=e[18];let x;e[19]!==s||e[20]!==h?(x=s!==null&&t(M,{error:h,testId:"subs-error"}),e[19]=s,e[20]=h,e[21]=x):x=e[21],b=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[v,x,s===null&&r!==void 0&&S.length===0&&t(q,{description:n("Active WebSocket subscriptions on this shard."),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:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),s===null&&S.length>0&&t(j,{className:"overflow-hidden py-0",children:t(_,{className:"px-0",children:c(D,{"data-testid":"subs-table",children:[t(F,{children:c(C,{children:[t(g,{children:n("Connection")}),t(g,{children:n("Function path")}),t(g,{children:n("Table")}),t(g,{children:n("Arguments")})]})}),t(J,{children:S.map(y=>{const{subscription:I}=y,w=B(I?.args);return c(C,{"data-testid":"subs-row",children:[t(N,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&t($,{variant:"outline",children:n("admin")})]})}),t(N,{className:"font-mono text-xs",children:I?.functionPath??k}),t(N,{children:I?.table??k}),t(N,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:w||void 0,children:w||k})]},y.key)})})]})})})]}),e[3]=s,e[4]=h,e[5]=r,e[6]=o,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as z}from"react/compiler-runtime";import{useState as Q,useEffect as J}from"react";import{f as Y}from"../packem_shared/log-fields-CoL3hsIQ.js";import{E as Z}from"../packem_shared/error-alert-t6cpEi0z.js";import{L as ee}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as te}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as re}from"../packem_shared/badge-BbuuAio7.js";import{E as ae}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as se}from"../packem_shared/input-JHu63lTv.js";import{N as ne}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import oe from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{i as ie}from"../packem_shared/internal-BSIsQVC6.js";import{r as de}from"../packem_shared/shard-history-DMEW5VBE.js";import{p as ce,c as me}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as B}from"react/jsx-runtime";const V=o=>Math.min(100,Math.max(0,o)),he=(o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=V(o.offsetMs/e*100),a=o.durationMs/e*100,r=Math.max(.5,Math.min(V(a),100-t));return{leftPercent:t,widthPercent:r}},fe=(o,e)=>{const t=e.trim().toLowerCase();return t===""?[...o]:o.filter(a=>a.rootName.toLowerCase().includes(t)||a.functionPath.toLowerCase().includes(t)||a.traceId.toLowerCase().includes(t))},U=o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"—",pe=14,ge=o=>Array.isArray(o?.traces)?o.traces:[],xe=o=>{const e=z(50),{span:t,traceDurationMs:a}=o,r=G();let n;e[0]!==t||e[1]!==a?(n=he(t,a),e[0]=t,e[1]=a,e[2]=n):n=e[2];const{leftPercent:S,widthPercent:x}=n;let P;e[3]!==t.attributes?(P=Y(t.attributes),e[3]=t.attributes,e[4]=P):P=e[4];const M=P,L=t.depth*pe;let y;e[5]!==L?(y={paddingLeft:L},e[5]=L,e[6]=y):y=e[6];const b=y,c=`${String(S)}%`,w=`${String(x)}%`;let p;e[7]!==c||e[8]!==w?(p={left:c,width:w},e[7]=c,e[8]=w,e[9]=p):p=e[9];const l=p,f=t.depth;let i;e[10]!==t.ok||e[11]!==r?(i=t.ok?null:s("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"●"}),e[10]=t.ok,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==b||e[14]!==t.name||e[15]!==i?(v=B("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:b,title:t.name,children:[i,t.name]}),e[13]=b,e[14]=t.name,e[15]=i,e[16]=v):v=e[16];let d;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(d=r("starts {offset} in, runs {duration}",{duration:U(t.durationMs),offset:U(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=d):d=e[20];const N=t.ok?"bg-primary/70":"bg-destructive";let m;e[21]!==N?(m=ue("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=m):m=e[22];let u;e[23]!==l||e[24]!==S||e[25]!==m||e[26]!==x?(u=s("span",{className:m,"data-left":S,"data-testid":"tr-span-bar","data-width":x,style:l}),e[23]=l,e[24]=S,e[25]=m,e[26]=x,e[27]=u):u=e[27];let h;e[28]!==d||e[29]!==u?(h=s("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:u}),e[28]=d,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==t.durationMs?(g=U(t.durationMs),e[31]=t.durationMs,e[32]=g):g=e[32];let k;e[33]!==g?(k=s("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:g}),e[33]=g,e[34]=k):k=e[34];let I;e[35]!==t.error?(I=t.error===void 0?null:s("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=I):I=e[36];let $;e[37]!==I?($=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:I}),e[37]=I,e[38]=$):$=e[38];let C;e[39]!==M?(C=M===""?null:s("span",{"data-testid":"tr-span-attributes",title:M,children:M}),e[39]=M,e[40]=C):C=e[40];let T;e[41]!==C?(T=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[41]=C,e[42]=T):T=e[42];let F;return e[43]!==t.depth||e[44]!==v||e[45]!==h||e[46]!==k||e[47]!==$||e[48]!==T?(F=B("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":f,"data-testid":"tr-span-row",role:"row",children:[v,h,k,$,T]}),e[43]=t.depth,e[44]=v,e[45]=h,e[46]=k,e[47]=$,e[48]=T,e[49]=F):F=e[49],F},be=o=>{const e=z(50),{expanded:t,onToggle:a,trace:r}=o,n=G();let S;e[0]!==a||e[1]!==r.traceId?(S=()=>{a(r.traceId)},e[0]=a,e[1]=r.traceId,e[2]=S):S=e[2];const x=S,P=`tr-row-${r.traceId}`,M=`tr-waterfall-${r.traceId}`,L=`tr-toggle-${r.traceId}`,y=t?"▾":"▸";let b;e[3]!==y?(b=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:y}),e[3]=y,e[4]=b):b=e[4];let c;e[5]!==r.rootName?(c=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=c):c=e[6];let w;e[7]!==r.functionPath?(w=s("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let p;e[9]!==r.durationMs?(p=U(r.durationMs),e[9]=r.durationMs,e[10]=p):p=e[10];let l;e[11]!==p?(l=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:p}),e[11]=p,e[12]=l):l=e[12];let f;e[13]!==n||e[14]!==r.spans.length?(f=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=f):f=e[15];let i;e[16]!==f?(i=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:f}),e[16]=f,e[17]=i):i=e[17];const v=r.ok?"secondary":"destructive";let d;e[18]!==n||e[19]!==r.ok?(d=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=d):d=e[20];let N;e[21]!==v||e[22]!==d?(N=s("span",{className:"shrink-0",children:s(re,{variant:v,children:d})}),e[21]=v,e[22]=d,e[23]=N):N=e[23];let m;e[24]!==r.startTs?(m=ie(r.startTs),e[24]=r.startTs,e[25]=m):m=e[25];let u;e[26]!==m?(u=s("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:m}),e[26]=m,e[27]=u):u=e[27];let h;e[28]!==t||e[29]!==x||e[30]!==l||e[31]!==i||e[32]!==N||e[33]!==u||e[34]!==M||e[35]!==L||e[36]!==b||e[37]!==c||e[38]!==w?(h=B("button",{"aria-controls":M,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":L,onClick:x,type:"button",children:[b,c,w,l,i,N,u]}),e[28]=t,e[29]=x,e[30]=l,e[31]=i,e[32]=N,e[33]=u,e[34]=M,e[35]=L,e[36]=b,e[37]=c,e[38]=w,e[39]=h):h=e[39];let g;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(g=t&&s("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(I=>s(xe,{span:I,traceDurationMs:r.durationMs},I.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=g):g=e[45];let k;return e[46]!==h||e[47]!==g||e[48]!==P?(k=B("div",{className:"border-b border-border last:border-b-0","data-testid":P,children:[h,g]}),e[46]=h,e[47]=g,e[48]=P,e[49]=k):k=e[49],k},Be=o=>{const e=z(44),{initialShardKey:t}=o,a=G(),[r]=Q(ce),[n,S]=Q(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[x,P]=Q(r?.traceId??""),[M,L]=Q(we);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],J(Ne,y);let b;e[1]!==n?(b=n.trim(),e[1]=n,e[2]=b):b=e[2];const c=oe(b,400);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let p;e[4]!==c?(p={live:!0,shardKey:c},e[4]=c,e[5]=p):p=e[5];const{data:l,error:f,errorSource:i,isLoading:v,liveError:d}=ne(le.getTraces,w,p);let N,m;e[6]!==l||e[7]!==c?(N=()=>{l!==void 0&&de(c)},m=[l,c],e[6]=l,e[7]=c,e[8]=N,e[9]=m):(N=e[8],m=e[9]),J(N,m);let u;if(e[10]!==l||e[11]!==f||e[12]!==i||e[13]!==M||e[14]!==v||e[15]!==d||e[16]!==x||e[17]!==n||e[18]!==a){const h=ge(l),g=l?.total??h.length,k=g>h.length,I=fe(h,x);let $;e[20]===Symbol.for("react.memo_cache_sentinel")?($=_=>{P(_.target.value)},e[20]=$):$=e[20];const C=$;let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=_=>{L(X=>{const H=new Set(X);return H.has(_)?H.delete(_):H.add(_),H})},e[21]=T):T=e[21];const F=T,W=f===null&&I.length===0&&!v;let K;e[22]!==n?(K=s(te,{onChange:S,testId:"tr-shard-input",value:n}),e[22]=n,e[23]=K):K=e[23];let A;e[24]!==a?(A=a("Search traces"),e[24]=a,e[25]=A):A=e[25];let D;e[26]!==a?(D=a("search trace or function"),e[26]=a,e[27]=D):D=e[27];let j;e[28]!==x||e[29]!==A||e[30]!==D?(j=s(se,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:C,placeholder:D,value:x}),e[28]=x,e[29]=A,e[30]=D,e[31]=j):j=e[31];let E;e[32]!==d?(E=s(ee,{message:d,prefix:"tr"}),e[32]=d,e[33]=E):E=e[33];let R;e[34]!==K||e[35]!==j||e[36]!==E?(R=B("div",{className:"flex flex-wrap items-center gap-2",children:[K,j,E]}),e[34]=K,e[35]=j,e[36]=E,e[37]=R):R=e[37];let O;e[38]!==f||e[39]!==i?(O=f!==null&&s(Z,{error:i,testId:"tr-error"}),e[38]=f,e[39]=i,e[40]=O):O=e[40];let q;e[41]!==W||e[42]!==a?(q=W&&s(ae,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[41]=W,e[42]=a,e[43]=q):q=e[43],u=B("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[R,O,q,f===null&&k&&s("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:h.length,total:g})}),f===null&&I.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:I.map(_=>s(be,{expanded:M.has(_.traceId),onToggle:F,trace:_},_.traceId))})]}),e[10]=l,e[11]=f,e[12]=i,e[13]=M,e[14]=v,e[15]=d,e[16]=x,e[17]=n,e[18]=a,e[19]=u}else u=e[19];return u};function we(){return new Set}function Ne(){me()}export{Be as TracesPanel};
|
|
1
|
+
import{c as z}from"react/compiler-runtime";import{useState as W,useEffect as J}from"react";import{f as X}from"../packem_shared/log-fields-CoL3hsIQ.js";import{E as Y}from"../packem_shared/error-alert-t6cpEi0z.js";import{L as Z}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as ee}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as te}from"../packem_shared/badge-BbuuAio7.js";import{E as re}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{N as se}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{S as ne}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as le}from"../packem_shared/internal-BSIsQVC6.js";import{r as ie}from"../packem_shared/shard-history-DMEW5VBE.js";import{p as de,c as ce}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as me}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as B}from"react/jsx-runtime";const Q=o=>Math.min(100,Math.max(0,o)),ue=(o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=Q(o.offsetMs/e*100),a=o.durationMs/e*100,r=Math.max(.5,Math.min(Q(a),100-t));return{leftPercent:t,widthPercent:r}},he=(o,e)=>{const t=e.trim().toLowerCase();return t===""?[...o]:o.filter(a=>a.rootName.toLowerCase().includes(t)||a.functionPath.toLowerCase().includes(t)||a.traceId.toLowerCase().includes(t))},U=o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"—",fe=14,pe=o=>Array.isArray(o?.traces)?o.traces:[],ge=o=>{const e=z(50),{span:t,traceDurationMs:a}=o,r=G();let n;e[0]!==t||e[1]!==a?(n=ue(t,a),e[0]=t,e[1]=a,e[2]=n):n=e[2];const{leftPercent:p,widthPercent:y}=n;let g;e[3]!==t.attributes?(g=X(t.attributes),e[3]=t.attributes,e[4]=g):g=e[4];const I=g,$=t.depth*fe;let P;e[5]!==$?(P={paddingLeft:$},e[5]=$,e[6]=P):P=e[6];const x=P,b=`${String(p)}%`,w=`${String(y)}%`;let l;e[7]!==b||e[8]!==w?(l={left:b,width:w},e[7]=b,e[8]=w,e[9]=l):l=e[9];const i=l,k=t.depth;let u;e[10]!==t.ok||e[11]!==r?(u=t.ok?null:s("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"●"}),e[10]=t.ok,e[11]=r,e[12]=u):u=e[12];let h;e[13]!==x||e[14]!==t.name||e[15]!==u?(h=B("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:t.name,children:[u,t.name]}),e[13]=x,e[14]=t.name,e[15]=u,e[16]=h):h=e[16];let d;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(d=r("starts {offset} in, runs {duration}",{duration:U(t.durationMs),offset:U(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=d):d=e[20];const N=t.ok?"bg-primary/70":"bg-destructive";let c;e[21]!==N?(c=me("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let m;e[23]!==i||e[24]!==p||e[25]!==c||e[26]!==y?(m=s("span",{className:c,"data-left":p,"data-testid":"tr-span-bar","data-width":y,style:i}),e[23]=i,e[24]=p,e[25]=c,e[26]=y,e[27]=m):m=e[27];let f;e[28]!==d||e[29]!==m?(f=s("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:m}),e[28]=d,e[29]=m,e[30]=f):f=e[30];let M;e[31]!==t.durationMs?(M=U(t.durationMs),e[31]=t.durationMs,e[32]=M):M=e[32];let v;e[33]!==M?(v=s("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:M}),e[33]=M,e[34]=v):v=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:s("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let C;e[37]!==S?(C=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=C):C=e[38];let T;e[39]!==I?(T=I===""?null:s("span",{"data-testid":"tr-span-attributes",title:I,children:I}),e[39]=I,e[40]=T):T=e[40];let K;e[41]!==T?(K=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:T}),e[41]=T,e[42]=K):K=e[42];let E;return e[43]!==t.depth||e[44]!==h||e[45]!==f||e[46]!==v||e[47]!==C||e[48]!==K?(E=B("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":k,"data-testid":"tr-span-row",role:"row",children:[h,f,v,C,K]}),e[43]=t.depth,e[44]=h,e[45]=f,e[46]=v,e[47]=C,e[48]=K,e[49]=E):E=e[49],E},xe=o=>{const e=z(50),{expanded:t,onToggle:a,trace:r}=o,n=G();let p;e[0]!==a||e[1]!==r.traceId?(p=()=>{a(r.traceId)},e[0]=a,e[1]=r.traceId,e[2]=p):p=e[2];const y=p,g=`tr-row-${r.traceId}`,I=`tr-waterfall-${r.traceId}`,$=`tr-toggle-${r.traceId}`,P=t?"▾":"▸";let x;e[3]!==P?(x=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:P}),e[3]=P,e[4]=x):x=e[4];let b;e[5]!==r.rootName?(b=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=b):b=e[6];let w;e[7]!==r.functionPath?(w=s("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let l;e[9]!==r.durationMs?(l=U(r.durationMs),e[9]=r.durationMs,e[10]=l):l=e[10];let i;e[11]!==l?(i=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l}),e[11]=l,e[12]=i):i=e[12];let k;e[13]!==n||e[14]!==r.spans.length?(k=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=k):k=e[15];let u;e[16]!==k?(u=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:k}),e[16]=k,e[17]=u):u=e[17];const h=r.ok?"secondary":"destructive";let d;e[18]!==n||e[19]!==r.ok?(d=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=d):d=e[20];let N;e[21]!==h||e[22]!==d?(N=s("span",{className:"shrink-0",children:s(te,{variant:h,children:d})}),e[21]=h,e[22]=d,e[23]=N):N=e[23];let c;e[24]!==r.startTs?(c=le(r.startTs),e[24]=r.startTs,e[25]=c):c=e[25];let m;e[26]!==c?(m=s("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c}),e[26]=c,e[27]=m):m=e[27];let f;e[28]!==t||e[29]!==y||e[30]!==i||e[31]!==u||e[32]!==N||e[33]!==m||e[34]!==I||e[35]!==$||e[36]!==x||e[37]!==b||e[38]!==w?(f=B("button",{"aria-controls":I,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":$,onClick:y,type:"button",children:[x,b,w,i,u,N,m]}),e[28]=t,e[29]=y,e[30]=i,e[31]=u,e[32]=N,e[33]=m,e[34]=I,e[35]=$,e[36]=x,e[37]=b,e[38]=w,e[39]=f):f=e[39];let M;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(M=t&&s("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>s(ge,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=M):M=e[45];let v;return e[46]!==f||e[47]!==M||e[48]!==g?(v=B("div",{className:"border-b border-border last:border-b-0","data-testid":g,children:[f,M]}),e[46]=f,e[47]=M,e[48]=g,e[49]=v):v=e[49],v},je=o=>{const e=z(44),{initialShardKey:t}=o,a=G(),[r]=W(de),{queryShardKey:n,setShardKey:p,shardKey:y}=ne(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[g,I]=W(r?.traceId??""),[$,P]=W(be);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0],J(we,x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b={},e[1]=b):b=e[1];let w;e[2]!==n?(w={live:!0,shardKey:n},e[2]=n,e[3]=w):w=e[3];const{data:l,error:i,errorSource:k,isLoading:u,liveError:h}=se(oe.getTraces,b,w);let d,N;e[4]!==l||e[5]!==n?(d=()=>{l!==void 0&&ie(n)},N=[l,n],e[4]=l,e[5]=n,e[6]=d,e[7]=N):(d=e[6],N=e[7]),J(d,N);let c;if(e[8]!==l||e[9]!==i||e[10]!==k||e[11]!==$||e[12]!==u||e[13]!==h||e[14]!==g||e[15]!==p||e[16]!==y||e[17]!==a){const m=pe(l),f=l?.total??m.length,M=f>m.length,v=he(m,g);let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=L=>{I(L.target.value)},e[19]=S):S=e[19];const C=S;let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=L=>{P(V=>{const H=new Set(V);return H.has(L)?H.delete(L):H.add(L),H})},e[20]=T):T=e[20];const K=T,E=i===null&&v.length===0&&!u;let F;e[21]!==p||e[22]!==y?(F=s(ee,{onChange:p,testId:"tr-shard-input",value:y}),e[21]=p,e[22]=y,e[23]=F):F=e[23];let A;e[24]!==a?(A=a("Search traces"),e[24]=a,e[25]=A):A=e[25];let D;e[26]!==a?(D=a("search trace or function"),e[26]=a,e[27]=D):D=e[27];let _;e[28]!==g||e[29]!==A||e[30]!==D?(_=s(ae,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:C,placeholder:D,value:g}),e[28]=g,e[29]=A,e[30]=D,e[31]=_):_=e[31];let j;e[32]!==h?(j=s(Z,{message:h,prefix:"tr"}),e[32]=h,e[33]=j):j=e[33];let q;e[34]!==_||e[35]!==j||e[36]!==F?(q=B("div",{className:"flex flex-wrap items-center gap-2",children:[F,_,j]}),e[34]=_,e[35]=j,e[36]=F,e[37]=q):q=e[37];let O;e[38]!==i||e[39]!==k?(O=i!==null&&s(Y,{error:k,testId:"tr-error"}),e[38]=i,e[39]=k,e[40]=O):O=e[40];let R;e[41]!==E||e[42]!==a?(R=E&&s(re,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[41]=E,e[42]=a,e[43]=R):R=e[43],c=B("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[q,O,R,i===null&&M&&s("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:m.length,total:f})}),i===null&&v.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:v.map(L=>s(xe,{expanded:$.has(L.traceId),onToggle:K,trace:L},L.traceId))})]}),e[8]=l,e[9]=i,e[10]=k,e[11]=$,e[12]=u,e[13]=h,e[14]=g,e[15]=p,e[16]=y,e[17]=a,e[18]=c}else c=e[18];return c};function be(){return new Set}function we(){ce()}export{je as TracesPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as ge}from"@lunora/react";import{useState as $,useEffect as Ve}from"react";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as $e,u as Fe}from"../packem_shared/card-CIDGUN6K.js";import{E as Je}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{n as Ue,d as Pe,m as L,p as z,f as _e,u as U}from"../packem_shared/table-DdJBrClo.js";import{O as Ke}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{c as Ne}from"react/compiler-runtime";import{u as Oe}from"../packem_shared/use-auth-config-BObBpdsi.js";import{useAutoRefresh as We}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Ze from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as Re,b as Ee}from"../packem_shared/internal-BSIsQVC6.js";import{f as Qe}from"../packem_shared/checkbox-StT4Gob6.js";import{p as V}from"../packem_shared/label-6uP1obNF.js";import{M as Ge}from"../packem_shared/modal-shell-CUwwWC2o.js";import{u as Xe}from"../packem_shared/use-async-submit-q3ymBJkD.js";import{jsx as t,jsxs as n,Fragment as Ye}from"react/jsx-runtime";const et=()=>{const u=Ne(3),{config:e,ready:s}=Oe();let l;return u[0]!==e.capabilities||u[1]!==s?(l={capabilities:e.capabilities,ready:s},u[0]=e.capabilities,u[1]=s,u[2]=l):l=u[2],l},tt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),lt=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const s=typeof e=="string"?e.trim():"";if(s!==""){if(u.type==="number"){const l=Number(s);return Number.isNaN(l)?void 0:{value:l}}return{value:s}}},st=u=>{const e=Ne(105),{onClose:s,onCreated:l}=u,c=ge(),a=ke(),{config:o}=Oe(),{busy:r,error:i,run:m}=Xe(),[k,I]=$(""),[x,w]=$(""),[y,A]=$(""),[h,g]=$("");let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[f,d]=$(v);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=p=>{I(p.target.value)},e[1]=C):C=e[1];const b=C;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=p=>{w(p.target.value)},e[2]=F):F=e[2];const T=F;let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=p=>{A(p.target.value)},e[3]=_):_=e[3];const De=_;let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=p=>{g(p.target.value)},e[4]=O):O=e[4];const je=O;let G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=(p,P)=>{d(q=>({...q,[p]:P}))},e[5]=G):G=e[5];const Se=G;let H;e[6]!==f?(H=p=>f[p.name]??(p.type==="boolean"?!1:""),e[6]=f,e[7]=H):H=e[7];const R=H;let J;if(e[8]!==o.userFields||e[9]!==R){let p;e[11]!==R?(p=P=>!P.required||at(P,R(P)),e[11]=R,e[12]=p):p=e[12],J=o.userFields.every(p),e[8]=o.userFields,e[9]=R,e[10]=J}else J=e[10];const we=J;let K;e[13]!==r||e[14]!==k||e[15]!==x||e[16]!==we?(K=!r&&k.trim()!==""&&x.trim()!==""&&we,e[13]=r,e[14]=k,e[15]=x,e[16]=we,e[17]=K):K=e[17];const Te=K;let W;e[18]!==o.userFields||e[19]!==R?(W=()=>{const p={};for(const P of o.userFields){const q=lt(P,R(P));q!==void 0&&(p[P.name]=q.value)}return Object.keys(p).length===0?void 0:p},e[18]=o.userFields,e[19]=R,e[20]=W):W=e[20];const Ce=W;let Z;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==s||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(Z=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),s()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=s,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=Z):Z=e[30];const N=Z;let D;e[31]!==a?(D=a("Create user"),e[31]=a,e[32]=D):D=e[32];let B;e[33]!==a?(B=a("Create user"),e[33]=a,e[34]=B):B=e[34];let E;e[35]!==B?(E=t("h2",{className:"text-sm font-semibold text-foreground",children:B}),e[35]=B,e[36]=E):E=e[36];let Q;e[37]!==a?(Q=a("email"),e[37]=a,e[38]=Q):Q=e[38];let X;e[39]!==Q?(X=t(V,{htmlFor:"uc-email",children:Q}),e[39]=Q,e[40]=X):X=e[40];let Y;e[41]!==k?(Y=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:k}),e[41]=k,e[42]=Y):Y=e[42];let ee;e[43]!==X||e[44]!==Y?(ee=n("div",{className:"flex flex-col gap-1",children:[X,Y]}),e[43]=X,e[44]=Y,e[45]=ee):ee=e[45];let te;e[46]!==a?(te=a("name"),e[46]=a,e[47]=te):te=e[47];let ae;e[48]!==te?(ae=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=ae):ae=e[49];let le;e[50]!==x?(le=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:x}),e[50]=x,e[51]=le):le=e[51];let se;e[52]!==ae||e[53]!==le?(se=n("div",{className:"flex flex-col gap-1",children:[ae,le]}),e[52]=ae,e[53]=le,e[54]=se):se=e[54];let re;e[55]!==a?(re=a("Password (optional)"),e[55]=a,e[56]=re):re=e[56];let ie;e[57]!==re?(ie=t(V,{htmlFor:"uc-password",children:re}),e[57]=re,e[58]=ie):ie=e[58];let ne;e[59]!==y?(ne=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:De,type:"password",value:y}),e[59]=y,e[60]=ne):ne=e[60];let de;e[61]!==ie||e[62]!==ne?(de=n("div",{className:"flex flex-col gap-1",children:[ie,ne]}),e[61]=ie,e[62]=ne,e[63]=de):de=e[63];let oe;e[64]!==a?(oe=a("Role (optional)"),e[64]=a,e[65]=oe):oe=e[65];let ce;e[66]!==oe?(ce=t(V,{htmlFor:"uc-role",children:oe}),e[66]=oe,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:je,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=n("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==o.userFields||e[74]!==R||e[75]!==a?(he=o.userFields.length>0&&n("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:a("Plugin fields")}),o.userFields.map(p=>{const P=`uc-field-${p.name}`,q=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){const Me=R(p)===!0;return n("label",{className:"flex items-center gap-2",htmlFor:P,children:[t(Qe,{checked:Me,"data-testid":P,id:P,onCheckedChange:He=>{Se(p.name,He)}}),n("span",{className:"text-sm",children:[p.name,q]})]},p.name)}const qe=R(p);return n("div",{className:"flex flex-col gap-1",children:[n(V,{htmlFor:P,children:[p.name,q]}),t(j,{"data-testid":P,id:P,onChange:Me=>{Se(p.name,Me.target.value)},type:tt[p.type],value:typeof qe=="string"?qe:""})]},p.name)})]}),e[73]=o.userFields,e[74]=R,e[75]=a,e[76]=he):he=e[76];let pe;e[77]!==i?(pe=i!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:i}),e[77]=i,e[78]=pe):pe=e[78];let fe;e[79]!==a?(fe=a("Cancel"),e[79]=a,e[80]=fe):fe=e[80];let ve;e[81]!==s||e[82]!==fe?(ve=t(S,{"data-testid":"uc-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:fe}),e[81]=s,e[82]=fe,e[83]=ve):ve=e[83];const Be=!Te;let be;e[84]!==r||e[85]!==a?(be=a(r?"Creating…":"Create"),e[84]=r,e[85]=a,e[86]=be):be=e[86];let xe;e[87]!==N||e[88]!==Be||e[89]!==be?(xe=t(S,{"data-testid":"uc-submit",disabled:Be,onClick:N,size:"sm",type:"button",children:be}),e[87]=N,e[88]=Be,e[89]=be,e[90]=xe):xe=e[90];let ye;e[91]!==ve||e[92]!==xe?(ye=n("div",{className:"flex justify-end gap-2 pt-1",children:[ve,xe]}),e[91]=ve,e[92]=xe,e[93]=ye):ye=e[93];let ze;return e[94]!==s||e[95]!==D||e[96]!==E||e[97]!==ee||e[98]!==se||e[99]!==de||e[100]!==me||e[101]!==he||e[102]!==pe||e[103]!==ye?(ze=n(Ge,{label:D,onClose:s,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[E,ee,se,de,me,he,pe,ye]}),e[94]=s,e[95]=D,e[96]=E,e[97]=ee,e[98]=se,e[99]=de,e[100]=me,e[101]=he,e[102]=pe,e[103]=ye,e[104]=ze):ze=e[104],ze},Le=u=>{const e=Ne(2),{children:s}=u;let l;return e[0]!==s?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[0]=s,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{const b=await o.listAuthSessions({limit:50,userId:c});m(b.rows)}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l?(y=b=>{l(()=>o.revokeAuthSession({sessionId:b}))},e[7]=o,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==r?(h=r("Sessions"),e[10]=r,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Le,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=v):v=e[15];let f;e[16]!==i||e[17]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:r("No active sessions.")}),e[16]=i,e[17]=r,e[18]=f):f=e[18];let d;e[19]!==s||e[20]!==A||e[21]!==i||e[22]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-sessions-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("expires")}),t(z,{children:r("ip")}),t(z,{children:r("user agent")}),t(z,{"aria-label":r("Actions")})]})}),t(_e,{children:i.map(b=>n(L,{"data-testid":`ud-session-${b.id}`,children:[t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.expiresAt)}),t(U,{children:b.ipAddress??""}),t(U,{className:"max-w-40 truncate",children:b.userAgent??""}),t(U,{children:t(S,{"data-testid":`ud-revoke-${b.id}`,disabled:s,onClick:()=>{A(b.id)},size:"xs",type:"button",variant:"ghost",children:r("Revoke")})})]},b.id))})]})})}),e[19]=s,e[20]=A,e[21]=i,e[22]=r,e[23]=d):d=e[23];let C;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{m(await o.listAuthAccounts({userId:c}))}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l||e[9]!==c?(y=b=>{l(()=>o.unlinkAuthAccount({accountId:b,userId:c}))},e[7]=o,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==r?(h=r("Linked accounts"),e[11]=r,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Le,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=v):v=e[16];let f;e[17]!==i||e[18]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No linked accounts.")}),e[17]=i,e[18]=r,e[19]=f):f=e[19];let d;e[20]!==i||e[21]!==s||e[22]!==A||e[23]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-accounts-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(_e,{children:i.map(b=>{const F=Ae(b.id);return n(L,{"data-testid":`ud-account-${F}`,children:[t(U,{children:Ae(b.providerId)}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-unlink-${F}`,disabled:s,onClick:()=>{A(F)},size:"xs",type:"button",variant:"ghost",children:r("Unlink")})})]},F)})})]})})}),e[20]=i,e[21]=s,e[22]=A,e[23]=r,e[24]=d):d=e[24];let C;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=C):C=e[29],C},nt=u=>{const e=Ne(40),{busy:s,capabilities:l,runAction:c,userId:a,version:o}=u,r=ge(),i=ke(),[m,k]=$(null);let I;e[0]!==l.passkey||e[1]!==r||e[2]!==a?(I=()=>{l.passkey&&Re((async()=>{try{k(await r.listAuthPasskeys({userId:a}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=r,e[2]=a,e[3]=I):I=e[3];let x;e[4]!==l.passkey||e[5]!==r||e[6]!==a||e[7]!==o?(x=[l.passkey,r,a,o],e[4]=l.passkey,e[5]=r,e[6]=a,e[7]=o,e[8]=x):x=e[8],Ve(I,x);let w;e[9]!==r||e[10]!==c||e[11]!==a?(w=()=>{c(()=>r.disableAuthTwoFactor({userId:a}))},e[9]=r,e[10]=c,e[11]=a,e[12]=w):w=e[12];const y=w;let A;e[13]!==r||e[14]!==c?(A=F=>{c(()=>r.deleteAuthPasskey({passkeyId:F}))},e[13]=r,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==i?(g=i("Security"),e[16]=i,e[17]=g):g=e[17];let v;e[18]!==g?(v=t(Le,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==s||e[21]!==l.twoFactor||e[22]!==y||e[23]!==i?(f=l.twoFactor&&t(S,{"data-testid":"ud-disable-2fa",disabled:s,onClick:y,size:"sm",type:"button",variant:"outline",children:i("Disable two-factor")}),e[20]=s,e[21]=l.twoFactor,e[22]=y,e[23]=i,e[24]=f):f=e[24];let d;e[25]!==l.passkey||e[26]!==m||e[27]!==i?(d=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:i("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=i,e[28]=d):d=e[28];let C;e[29]!==s||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==i?(C=l.passkey&&m!==null&&m.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-passkeys-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(_e,{children:m.map(F=>{const T=Ae(F.id);return n(L,{"data-testid":`ud-passkey-${T}`,children:[t(U,{children:Ae(F.name)||T}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-delete-passkey-${T}`,disabled:s,onClick:()=>{h(T)},size:"xs",type:"button",variant:"ghost",children:i("Delete")})})]},T)})})]})})}),e[29]=s,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=i,e[34]=C):C=e[34];let b;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==C?(b=n("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,C]}),e[35]=v,e[36]=f,e[37]=d,e[38]=C,e[39]=b):b=e[39],b},dt=/(?:at|expires)$/iu,ot=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ct=(u,e)=>typeof e=="number"&&dt.test(u)?Ie(e):Ae(e),ut=({capabilities:u,onChanged:e,onClose:s,user:l})=>{const c=ge(),a=ke(),o=l.banned===!0,[r,i]=$(null),[m,k]=$(!1),[I,x]=$(0),[w,y]=$(typeof l.role=="string"?l.role:""),[A,h]=$(""),[g,v]=$(""),[f,d]=$(""),[C,b]=$(null),[F,T]=$(!1),_=(N,D)=>{Re((async()=>{k(!0),i(null);try{const B=await N();D?.refresh!==!1&&(x(E=>E+1),e()),D?.onResult?.(B)}catch(B){i(Ee(B))}k(!1)})())},De=N=>{y(N.target.value)},O=N=>{h(N.target.value)},je=N=>{v(N.target.value)},G=N=>{d(N.target.value)},Se=()=>{const N=w.trim();N!==""&&_(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},H=()=>{const N=Number.parseInt(g,10),D=Number.isFinite(N)&&N>0?N*86400:void 0;_(async()=>{await c.banAuthUser({expiresInSeconds:D,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},R=()=>{_(async()=>{await c.unbanAuthUser({userId:l.id})})},J=()=>{_(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{_(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{_(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{_(async()=>{await c.removeAuthUser({userId:l.id}),s()})},W=()=>{T(!0)},Ce=()=>{T(!1)},Z=Object.entries(l).filter(([N])=>!ot.has(N));return n(Ge,{label:a("User details"),onClose:s,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[n("div",{className:"flex items-start justify-between gap-2",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),n("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),o?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"outline",children:a("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:a("verified")}):t(M,{variant:"outline",children:a("unverified")})]})]}),t(S,{"data-testid":"ud-close",onClick:s,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:r}),u.admin&&n($e,{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:a("Actions")})}),n(Fe,{className:"flex flex-col gap-3 p-3",children:[n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:a("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:De,value:w})]}),t(S,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Se,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?t(S,{"data-testid":"ud-unban",disabled:m,onClick:R,size:"sm",type:"button",variant:"outline",children:a("Unban")}):n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:O,value:A})]}),n("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:a("Days")}),t(j,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:je,type:"number",value:g})]}),t(S,{"data-testid":"ud-ban",disabled:m,onClick:H,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:a("New password")}),t(j,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:f})]}),t(S,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:J,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),n("div",{className:"flex flex-wrap gap-2",children:[t(S,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),t(S,{"data-testid":"ud-revoke-all",disabled:m,onClick:K,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?n(Ye,{children:[t(S,{"data-testid":"ud-delete-confirm",disabled:m,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),t(S,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):t(S,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),C!==null&&n("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:a("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:_,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:_,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:_,userId:l.id,version:I}),n("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:a("Fields")}),t("dl",{className:"flex flex-col",children:Z.map(([N,D])=>n("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ct(N,D)})]},N))})]})]})},mt=50,_t=({pageSize:u=mt}={})=>{const e=ge(),s=ke(),[l,c]=$(""),[a,o]=$(""),r=Ze(l),[i,m]=$(null),[k,I]=$(!1),{capabilities:x}=et(),w=r.trim(),y=a.trim(),A=Ke(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,v=()=>{A.refetch()};We(()=>{A.refetch()},!0);const f=i===null?null:h?.find(d=>d.id===i)??null;return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":s("Search users"),className:"w-56","data-testid":"us-search",onChange:d=>{c(d.target.value)},placeholder:s("Search by email or name…"),value:l}),t(j,{"aria-label":s("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:d=>{o(d.target.value)},placeholder:s("Filter by role"),value:a}),t(S,{"data-testid":"us-new",onClick:()=>{I(!0)},size:"sm",type:"button",children:s("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Je,{description:s("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:s("No users.")}),h!==null&&h.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"us-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:s("id")}),t(z,{children:s("email")}),t(z,{children:s("name")}),t(z,{children:s("role")}),t(z,{children:s("status")}),t(z,{children:s("verified")}),t(z,{children:s("created")}),t(z,{"aria-label":s("Actions")})]})}),t(_e,{children:h.map(d=>n(L,{"data-testid":`us-row-${d.id}`,children:[t(U,{className:"font-mono text-xs",children:d.id}),t(U,{children:d.email??""}),t(U,{children:d.name??""}),t(U,{children:typeof d.role=="string"&&d.role!==""?t(M,{variant:"secondary",children:d.role}):""}),t(U,{children:d.banned===!0?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"success",children:s("Active")})}),t(U,{children:d.emailVerified===!0?t(M,{variant:"success",children:s("yes")}):t(M,{variant:"outline",children:s("no")})}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),t(U,{children:t(S,{"data-testid":`us-manage-${d.id}`,onClick:()=>{m(d.id)},size:"xs",type:"button",variant:"ghost",children:s("Manage")})})]},d.id))})]})})}),f!==null&&t(ut,{capabilities:x,onChanged:v,onClose:()=>{m(null)},user:f}),k&&t(st,{onClose:()=>{I(!1)},onCreated:v})]})};export{_t as UsersPanel};
|
|
1
|
+
import{useLunora as ge}from"@lunora/react";import{useState as $,useEffect as Ve}from"react";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as $e,u as Fe}from"../packem_shared/card-CIDGUN6K.js";import{E as Je}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{n as Ue,d as Pe,m as L,p as z,f as Re,u as U}from"../packem_shared/table-DdJBrClo.js";import{O as Ke}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{c as Ne}from"react/compiler-runtime";import{u as Oe}from"../packem_shared/use-auth-config-BObBpdsi.js";import{useAutoRefresh as We}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Ze from"../packem_shared/useDebounced-CU-uftxO.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as _e,b as Ee}from"../packem_shared/internal-BSIsQVC6.js";import{f as Qe}from"../packem_shared/checkbox-StT4Gob6.js";import{p as V}from"../packem_shared/label-6uP1obNF.js";import{M as Ge}from"../packem_shared/modal-shell-CUwwWC2o.js";import{u as Xe}from"../packem_shared/use-async-submit-q3ymBJkD.js";import{jsx as t,jsxs as n,Fragment as Ye}from"react/jsx-runtime";const et=()=>{const u=Ne(3),{config:e,ready:s}=Oe();let l;return u[0]!==e.capabilities||u[1]!==s?(l={capabilities:e.capabilities,ready:s},u[0]=e.capabilities,u[1]=s,u[2]=l):l=u[2],l},tt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),lt=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const s=typeof e=="string"?e.trim():"";if(s!==""){if(u.type==="number"){const l=Number(s);return Number.isNaN(l)?void 0:{value:l}}return{value:s}}},st=u=>{const e=Ne(105),{onClose:s,onCreated:l}=u,c=ge(),a=ke(),{config:o}=Oe(),{busy:r,error:i,run:m}=Xe(),[k,I]=$(""),[x,w]=$(""),[y,A]=$(""),[h,g]=$("");let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[f,d]=$(v);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=p=>{I(p.target.value)},e[1]=C):C=e[1];const b=C;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=p=>{w(p.target.value)},e[2]=F):F=e[2];const T=F;let R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=p=>{A(p.target.value)},e[3]=R):R=e[3];const De=R;let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=p=>{g(p.target.value)},e[4]=O):O=e[4];const je=O;let G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=(p,P)=>{d(q=>({...q,[p]:P}))},e[5]=G):G=e[5];const Se=G;let H;e[6]!==f?(H=p=>f[p.name]??(p.type==="boolean"?!1:""),e[6]=f,e[7]=H):H=e[7];const _=H;let J;if(e[8]!==o.userFields||e[9]!==_){let p;e[11]!==_?(p=P=>!P.required||at(P,_(P)),e[11]=_,e[12]=p):p=e[12],J=o.userFields.every(p),e[8]=o.userFields,e[9]=_,e[10]=J}else J=e[10];const we=J;let K;e[13]!==r||e[14]!==k||e[15]!==x||e[16]!==we?(K=!r&&k.trim()!==""&&x.trim()!==""&&we,e[13]=r,e[14]=k,e[15]=x,e[16]=we,e[17]=K):K=e[17];const Te=K;let W;e[18]!==o.userFields||e[19]!==_?(W=()=>{const p={};for(const P of o.userFields){const q=lt(P,_(P));q!==void 0&&(p[P.name]=q.value)}return Object.keys(p).length===0?void 0:p},e[18]=o.userFields,e[19]=_,e[20]=W):W=e[20];const Ce=W;let Z;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==s||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(Z=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),s()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=s,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=Z):Z=e[30];const N=Z;let D;e[31]!==a?(D=a("Create user"),e[31]=a,e[32]=D):D=e[32];let B;e[33]!==a?(B=a("Create user"),e[33]=a,e[34]=B):B=e[34];let E;e[35]!==B?(E=t("h2",{className:"text-sm font-semibold text-foreground",children:B}),e[35]=B,e[36]=E):E=e[36];let Q;e[37]!==a?(Q=a("email"),e[37]=a,e[38]=Q):Q=e[38];let X;e[39]!==Q?(X=t(V,{htmlFor:"uc-email",children:Q}),e[39]=Q,e[40]=X):X=e[40];let Y;e[41]!==k?(Y=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:k}),e[41]=k,e[42]=Y):Y=e[42];let ee;e[43]!==X||e[44]!==Y?(ee=n("div",{className:"flex flex-col gap-1",children:[X,Y]}),e[43]=X,e[44]=Y,e[45]=ee):ee=e[45];let te;e[46]!==a?(te=a("name"),e[46]=a,e[47]=te):te=e[47];let ae;e[48]!==te?(ae=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=ae):ae=e[49];let le;e[50]!==x?(le=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:x}),e[50]=x,e[51]=le):le=e[51];let se;e[52]!==ae||e[53]!==le?(se=n("div",{className:"flex flex-col gap-1",children:[ae,le]}),e[52]=ae,e[53]=le,e[54]=se):se=e[54];let re;e[55]!==a?(re=a("Password (optional)"),e[55]=a,e[56]=re):re=e[56];let ie;e[57]!==re?(ie=t(V,{htmlFor:"uc-password",children:re}),e[57]=re,e[58]=ie):ie=e[58];let ne;e[59]!==y?(ne=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:De,type:"password",value:y}),e[59]=y,e[60]=ne):ne=e[60];let de;e[61]!==ie||e[62]!==ne?(de=n("div",{className:"flex flex-col gap-1",children:[ie,ne]}),e[61]=ie,e[62]=ne,e[63]=de):de=e[63];let oe;e[64]!==a?(oe=a("Role (optional)"),e[64]=a,e[65]=oe):oe=e[65];let ce;e[66]!==oe?(ce=t(V,{htmlFor:"uc-role",children:oe}),e[66]=oe,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:je,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=n("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==o.userFields||e[74]!==_||e[75]!==a?(he=o.userFields.length>0&&n("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:a("Plugin fields")}),o.userFields.map(p=>{const P=`uc-field-${p.name}`,q=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){const Me=_(p)===!0;return n("label",{className:"flex items-center gap-2",htmlFor:P,children:[t(Qe,{checked:Me,"data-testid":P,id:P,onCheckedChange:He=>{Se(p.name,He)}}),n("span",{className:"text-sm",children:[p.name,q]})]},p.name)}const qe=_(p);return n("div",{className:"flex flex-col gap-1",children:[n(V,{htmlFor:P,children:[p.name,q]}),t(j,{"data-testid":P,id:P,onChange:Me=>{Se(p.name,Me.target.value)},type:tt[p.type],value:typeof qe=="string"?qe:""})]},p.name)})]}),e[73]=o.userFields,e[74]=_,e[75]=a,e[76]=he):he=e[76];let pe;e[77]!==i?(pe=i!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:i}),e[77]=i,e[78]=pe):pe=e[78];let fe;e[79]!==a?(fe=a("Cancel"),e[79]=a,e[80]=fe):fe=e[80];let ve;e[81]!==s||e[82]!==fe?(ve=t(S,{"data-testid":"uc-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:fe}),e[81]=s,e[82]=fe,e[83]=ve):ve=e[83];const Be=!Te;let be;e[84]!==r||e[85]!==a?(be=a(r?"Creating…":"Create"),e[84]=r,e[85]=a,e[86]=be):be=e[86];let xe;e[87]!==N||e[88]!==Be||e[89]!==be?(xe=t(S,{"data-testid":"uc-submit",disabled:Be,onClick:N,size:"sm",type:"button",children:be}),e[87]=N,e[88]=Be,e[89]=be,e[90]=xe):xe=e[90];let ye;e[91]!==ve||e[92]!==xe?(ye=n("div",{className:"flex justify-end gap-2 pt-1",children:[ve,xe]}),e[91]=ve,e[92]=xe,e[93]=ye):ye=e[93];let ze;return e[94]!==s||e[95]!==D||e[96]!==E||e[97]!==ee||e[98]!==se||e[99]!==de||e[100]!==me||e[101]!==he||e[102]!==pe||e[103]!==ye?(ze=n(Ge,{label:D,onClose:s,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[E,ee,se,de,me,he,pe,ye]}),e[94]=s,e[95]=D,e[96]=E,e[97]=ee,e[98]=se,e[99]=de,e[100]=me,e[101]=he,e[102]=pe,e[103]=ye,e[104]=ze):ze=e[104],ze},Le=u=>{const e=Ne(2),{children:s}=u;let l;return e[0]!==s?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[0]=s,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{_e((async()=>{I(null);try{const b=await o.listAuthSessions({limit:50,userId:c});m(b.rows)}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l?(y=b=>{l(()=>o.revokeAuthSession({sessionId:b}))},e[7]=o,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==r?(h=r("Sessions"),e[10]=r,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Le,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=v):v=e[15];let f;e[16]!==i||e[17]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:r("No active sessions.")}),e[16]=i,e[17]=r,e[18]=f):f=e[18];let d;e[19]!==s||e[20]!==A||e[21]!==i||e[22]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-sessions-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("expires")}),t(z,{children:r("ip")}),t(z,{children:r("user agent")}),t(z,{"aria-label":r("Actions")})]})}),t(Re,{children:i.map(b=>n(L,{"data-testid":`ud-session-${b.id}`,children:[t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.expiresAt)}),t(U,{children:b.ipAddress??""}),t(U,{className:"max-w-40 truncate",children:b.userAgent??""}),t(U,{children:t(S,{"data-testid":`ud-revoke-${b.id}`,disabled:s,onClick:()=>{A(b.id)},size:"xs",type:"button",variant:"ghost",children:r("Revoke")})})]},b.id))})]})})}),e[19]=s,e[20]=A,e[21]=i,e[22]=r,e[23]=d):d=e[23];let C;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{_e((async()=>{I(null);try{m(await o.listAuthAccounts({userId:c}))}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l||e[9]!==c?(y=b=>{l(()=>o.unlinkAuthAccount({accountId:b,userId:c}))},e[7]=o,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==r?(h=r("Linked accounts"),e[11]=r,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Le,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=v):v=e[16];let f;e[17]!==i||e[18]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No linked accounts.")}),e[17]=i,e[18]=r,e[19]=f):f=e[19];let d;e[20]!==i||e[21]!==s||e[22]!==A||e[23]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-accounts-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(Re,{children:i.map(b=>{const F=Ae(b.id);return n(L,{"data-testid":`ud-account-${F}`,children:[t(U,{children:Ae(b.providerId)}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-unlink-${F}`,disabled:s,onClick:()=>{A(F)},size:"xs",type:"button",variant:"ghost",children:r("Unlink")})})]},F)})})]})})}),e[20]=i,e[21]=s,e[22]=A,e[23]=r,e[24]=d):d=e[24];let C;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=C):C=e[29],C},nt=u=>{const e=Ne(40),{busy:s,capabilities:l,runAction:c,userId:a,version:o}=u,r=ge(),i=ke(),[m,k]=$(null);let I;e[0]!==l.passkey||e[1]!==r||e[2]!==a?(I=()=>{l.passkey&&_e((async()=>{try{k(await r.listAuthPasskeys({userId:a}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=r,e[2]=a,e[3]=I):I=e[3];let x;e[4]!==l.passkey||e[5]!==r||e[6]!==a||e[7]!==o?(x=[l.passkey,r,a,o],e[4]=l.passkey,e[5]=r,e[6]=a,e[7]=o,e[8]=x):x=e[8],Ve(I,x);let w;e[9]!==r||e[10]!==c||e[11]!==a?(w=()=>{c(()=>r.disableAuthTwoFactor({userId:a}))},e[9]=r,e[10]=c,e[11]=a,e[12]=w):w=e[12];const y=w;let A;e[13]!==r||e[14]!==c?(A=F=>{c(()=>r.deleteAuthPasskey({passkeyId:F}))},e[13]=r,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==i?(g=i("Security"),e[16]=i,e[17]=g):g=e[17];let v;e[18]!==g?(v=t(Le,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==s||e[21]!==l.twoFactor||e[22]!==y||e[23]!==i?(f=l.twoFactor&&t(S,{"data-testid":"ud-disable-2fa",disabled:s,onClick:y,size:"sm",type:"button",variant:"outline",children:i("Disable two-factor")}),e[20]=s,e[21]=l.twoFactor,e[22]=y,e[23]=i,e[24]=f):f=e[24];let d;e[25]!==l.passkey||e[26]!==m||e[27]!==i?(d=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:i("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=i,e[28]=d):d=e[28];let C;e[29]!==s||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==i?(C=l.passkey&&m!==null&&m.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-passkeys-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(Re,{children:m.map(F=>{const T=Ae(F.id);return n(L,{"data-testid":`ud-passkey-${T}`,children:[t(U,{children:Ae(F.name)||T}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-delete-passkey-${T}`,disabled:s,onClick:()=>{h(T)},size:"xs",type:"button",variant:"ghost",children:i("Delete")})})]},T)})})]})})}),e[29]=s,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=i,e[34]=C):C=e[34];let b;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==C?(b=n("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,C]}),e[35]=v,e[36]=f,e[37]=d,e[38]=C,e[39]=b):b=e[39],b},dt=/(?:at|expires)$/iu,ot=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ct=(u,e)=>typeof e=="number"&&dt.test(u)?Ie(e):Ae(e),ut=({capabilities:u,onChanged:e,onClose:s,user:l})=>{const c=ge(),a=ke(),o=l.banned===!0,[r,i]=$(null),[m,k]=$(!1),[I,x]=$(0),[w,y]=$(typeof l.role=="string"?l.role:""),[A,h]=$(""),[g,v]=$(""),[f,d]=$(""),[C,b]=$(null),[F,T]=$(!1),R=(N,D)=>{_e((async()=>{k(!0),i(null);try{const B=await N();D?.refresh!==!1&&(x(E=>E+1),e()),D?.onResult?.(B)}catch(B){i(Ee(B))}k(!1)})())},De=N=>{y(N.target.value)},O=N=>{h(N.target.value)},je=N=>{v(N.target.value)},G=N=>{d(N.target.value)},Se=()=>{const N=w.trim();N!==""&&R(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},H=()=>{const N=Number.parseInt(g,10),D=Number.isFinite(N)&&N>0?N*86400:void 0;R(async()=>{await c.banAuthUser({expiresInSeconds:D,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},_=()=>{R(async()=>{await c.unbanAuthUser({userId:l.id})})},J=()=>{R(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{R(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{R(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{R(async()=>{await c.removeAuthUser({userId:l.id}),s()})},W=()=>{T(!0)},Ce=()=>{T(!1)},Z=Object.entries(l).filter(([N])=>!ot.has(N));return n(Ge,{label:a("User details"),onClose:s,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[n("div",{className:"flex items-start justify-between gap-2",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),n("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),o?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"outline",children:a("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:a("verified")}):t(M,{variant:"outline",children:a("unverified")})]})]}),t(S,{"data-testid":"ud-close",onClick:s,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:r}),u.admin&&n($e,{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:a("Actions")})}),n(Fe,{className:"flex flex-col gap-3 p-3",children:[n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:a("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:De,value:w})]}),t(S,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Se,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?t(S,{"data-testid":"ud-unban",disabled:m,onClick:_,size:"sm",type:"button",variant:"outline",children:a("Unban")}):n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:O,value:A})]}),n("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:a("Days")}),t(j,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:je,type:"number",value:g})]}),t(S,{"data-testid":"ud-ban",disabled:m,onClick:H,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:a("New password")}),t(j,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:f})]}),t(S,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:J,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),n("div",{className:"flex flex-wrap gap-2",children:[t(S,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),t(S,{"data-testid":"ud-revoke-all",disabled:m,onClick:K,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?n(Ye,{children:[t(S,{"data-testid":"ud-delete-confirm",disabled:m,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),t(S,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):t(S,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),C!==null&&n("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:a("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:R,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:R,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:R,userId:l.id,version:I}),n("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:a("Fields")}),t("dl",{className:"flex flex-col",children:Z.map(([N,D])=>n("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ct(N,D)})]},N))})]})]})},mt=50,Rt=({pageSize:u=mt}={})=>{const e=ge(),s=ke(),[l,c]=$(""),[a,o]=$(""),r=Ze(l),[i,m]=$(null),[k,I]=$(!1),{capabilities:x}=et(),w=r.trim(),y=a.trim(),A=Ke(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,v=()=>{A.refetch()};We(()=>{A.refetch()},!0);const f=i===null?null:h?.find(d=>d.id===i)??null;return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":s("Search users"),className:"w-56","data-testid":"us-search",onChange:d=>{c(d.target.value)},placeholder:s("Search by email or name…"),value:l}),t(j,{"aria-label":s("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:d=>{o(d.target.value)},placeholder:s("Filter by role"),value:a}),t(S,{"data-testid":"us-new",onClick:()=>{I(!0)},size:"sm",type:"button",children:s("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Je,{description:s("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:s("No users.")}),h!==null&&h.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"us-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:s("id")}),t(z,{children:s("email")}),t(z,{children:s("name")}),t(z,{children:s("role")}),t(z,{children:s("status")}),t(z,{children:s("verified")}),t(z,{children:s("created")}),t(z,{"aria-label":s("Actions")})]})}),t(Re,{children:h.map(d=>n(L,{"data-testid":`us-row-${d.id}`,children:[t(U,{className:"font-mono text-xs",children:d.id}),t(U,{children:d.email??""}),t(U,{children:d.name??""}),t(U,{children:typeof d.role=="string"&&d.role!==""?t(M,{variant:"secondary",children:d.role}):""}),t(U,{children:d.banned===!0?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"success",children:s("Active")})}),t(U,{children:d.emailVerified===!0?t(M,{variant:"success",children:s("yes")}):t(M,{variant:"outline",children:s("no")})}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),t(U,{children:t(S,{"data-testid":`us-manage-${d.id}`,onClick:()=>{m(d.id)},size:"xs",type:"button",variant:"ghost",children:s("Manage")})})]},d.id))})]})})}),f!==null&&t(ut,{capabilities:x,onChanged:v,onClose:()=>{m(null)},user:f}),k&&t(st,{onClose:()=>{I(!1)},onCreated:v})]})};export{Rt as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as Q}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{u as W}from"../packem_shared/button-BkCrNcAs.js";import{c as J,u as L}from"../packem_shared/card-CIDGUN6K.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{n as U,d as _,m as x,p as i,f as q,u as d}from"../packem_shared/table-DdJBrClo.js";import{l as re}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as ne}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-CZESgd10.js";import{f as A,b as E,d as H,g as X}from"../packem_shared/internal-BSIsQVC6.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const se=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const r=o.error??o.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:r,readOnly:N,runAction:T,workflowName:g})=>{const I=Q(),n=V(),[h,k]=m(null),[S,$]=m(null),[v,j]=m(""),[b,f]=m(null),[F,C]=m(!1),[R,z]=m(null),p=o??(a=>I.getWorkflowInstance(a)),w=N?void 0:T??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{f(null),C(!1);const a=v===""?void 0:v;try{if(r===void 0){const l=await I.listWorkflowInstances({name:g,status:a});if(l.configured===!1){k(null),C(!0);return}k(l.instances);return}k(await r({name:g,status:a}))}catch(l){k(null),ie(l)?C(!0):f(E(l))}};te(()=>{$(null),A(O())},[g,v]);const D=async a=>{f(null);try{$(await p({id:a,name:g}))}catch(l){f(E(l))}},K=async(a,l)=>{if(w!==void 0){z(a),f(null);try{await w({action:l,id:a,name:g}),await O()}catch(P){f(E(P))}z(null)}};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[s("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:n("Instance history")}),s("select",{"aria-label":n("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:a=>{j(a.target.value)},value:v,children:[e("option",{value:"",children:n("All statuses")}),se.map(a=>e("option",{value:a,children:a},a))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),F&&e(M,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!F&&h!==null&&h.length===0&&e(M,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),h!==null&&h.length>0&&e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflow-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:n("Instance id")}),e(i,{children:n("Status")}),e(i,{children:n("Created")}),e(i,{children:n("Ended")}),e(i,{"aria-label":n("Actions")})]})}),e(q,{children:h.map(a=>s(x,{"data-testid":`workflow-instance-${a.id}`,children:[e(d,{className:"font-mono text-xs",children:a.id}),e(d,{className:"font-mono text-xs",children:a.status}),e(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(d,{className:"text-right",children:s("div",{className:"flex justify-end gap-1.5",children:[e(W,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:()=>{A(D(a.id))},size:"sm",type:"button",variant:"outline",children:n("Steps")}),w!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:R===a.id,onClick:()=>{A(K(a.id,l))},size:"sm",type:"button",variant:"ghost",children:n(l)},l))]})})]},a.id))})]})})}),S!==null&&e(J,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:s(L,{className:"flex flex-col gap-2 px-4 py-3",children:[s("div",{className:"flex items-center justify-between",children:[s("span",{className:"font-mono text-xs",children:[n("Steps")," · ",S.id]}),e(W,{"data-testid":"workflow-instance-detail-close",onClick:()=>{$(null)},size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),S.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):s(U,{"data-testid":"workflow-instance-steps",children:[e(_,{children:s(x,{children:[e(i,{children:n("Step")}),e(i,{children:n("Type")}),e(i,{children:n("Attempts")}),e(i,{children:n("Started")}),e(i,{children:n("Output")})]})}),e(q,{children:S.steps.map((a,l)=>s(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:a.name}),e(d,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(d,{className:"tabular-nums",children:a.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},me=X(B.createWorkflowInstance),ue=X(B.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,r)=>o.some(N=>N.exportName===r)?r:o[0]?.exportName??"",Oe=()=>{const o=Q(),r=V(),{data:N,error:T}=ne(B.listWorkflows,{}),[g,I]=m(""),[n,h]=m(""),[k,S]=m(""),[$,v]=m(!1),[j,b]=m(null),[f,F]=m([]),[C,R]=m(null),z=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=he(p,g),O=p.find(t=>t.exportName===w),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},K=async()=>{const t=w;if(t==="")return;let u;const c=k.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{const y=n.trim(),G=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},H(""));D({exportName:t,id:G.id,status:G.status}),h("")}catch(y){b(E(y))}v(!1)},a=()=>{A(K())},l=async(t,u)=>{R(u);try{const c=await o.query(ue,{exportName:t,id:u},H(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(E(c))}R(null)},P=t=>{I(t.target.value)},Y=t=>{h(t.target.value)},Z=t=>{S(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&A(l(u,c))};return s("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:T}),e("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),z&&p.length===0?e(M,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Export")}),e(i,{children:r("Name")}),e(i,{children:r("Class")}),e(i,{children:r("Binding")})]})}),e(q,{children:p.map(t=>s(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:r("Start instance")}),j!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),s("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:P,value:w,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Y,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||w==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(re,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:Z,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:r("Instances")}),e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Workflow")}),e(i,{children:r("Instance id")}),e(i,{children:r("Status")}),e(i,{children:r("Output")}),e(i,{})]})}),e(q,{children:f.map(t=>s(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:ee,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(ce,{workflowName:O.name})]})};export{Oe as default};
|
|
1
|
+
import{useLunora as Q}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{u as W}from"../packem_shared/button-BkCrNcAs.js";import{c as J,u as L}from"../packem_shared/card-CIDGUN6K.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{n as U,d as _,m as x,p as i,f as q,u as d}from"../packem_shared/table-DdJBrClo.js";import{l as re}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as ne}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as A,b as E,d as H,g as X}from"../packem_shared/internal-BSIsQVC6.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const se=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const r=o.error??o.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:r,readOnly:N,runAction:T,workflowName:g})=>{const I=Q(),n=V(),[h,k]=m(null),[S,$]=m(null),[v,j]=m(""),[b,f]=m(null),[F,C]=m(!1),[R,z]=m(null),p=o??(a=>I.getWorkflowInstance(a)),w=N?void 0:T??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{f(null),C(!1);const a=v===""?void 0:v;try{if(r===void 0){const l=await I.listWorkflowInstances({name:g,status:a});if(l.configured===!1){k(null),C(!0);return}k(l.instances);return}k(await r({name:g,status:a}))}catch(l){k(null),ie(l)?C(!0):f(E(l))}};te(()=>{$(null),A(O())},[g,v]);const D=async a=>{f(null);try{$(await p({id:a,name:g}))}catch(l){f(E(l))}},K=async(a,l)=>{if(w!==void 0){z(a),f(null);try{await w({action:l,id:a,name:g}),await O()}catch(P){f(E(P))}z(null)}};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[s("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:n("Instance history")}),s("select",{"aria-label":n("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:a=>{j(a.target.value)},value:v,children:[e("option",{value:"",children:n("All statuses")}),se.map(a=>e("option",{value:a,children:a},a))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),F&&e(M,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!F&&h!==null&&h.length===0&&e(M,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),h!==null&&h.length>0&&e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflow-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:n("Instance id")}),e(i,{children:n("Status")}),e(i,{children:n("Created")}),e(i,{children:n("Ended")}),e(i,{"aria-label":n("Actions")})]})}),e(q,{children:h.map(a=>s(x,{"data-testid":`workflow-instance-${a.id}`,children:[e(d,{className:"font-mono text-xs",children:a.id}),e(d,{className:"font-mono text-xs",children:a.status}),e(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(d,{className:"text-right",children:s("div",{className:"flex justify-end gap-1.5",children:[e(W,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:()=>{A(D(a.id))},size:"sm",type:"button",variant:"outline",children:n("Steps")}),w!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:R===a.id,onClick:()=>{A(K(a.id,l))},size:"sm",type:"button",variant:"ghost",children:n(l)},l))]})})]},a.id))})]})})}),S!==null&&e(J,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:s(L,{className:"flex flex-col gap-2 px-4 py-3",children:[s("div",{className:"flex items-center justify-between",children:[s("span",{className:"font-mono text-xs",children:[n("Steps")," · ",S.id]}),e(W,{"data-testid":"workflow-instance-detail-close",onClick:()=>{$(null)},size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),S.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):s(U,{"data-testid":"workflow-instance-steps",children:[e(_,{children:s(x,{children:[e(i,{children:n("Step")}),e(i,{children:n("Type")}),e(i,{children:n("Attempts")}),e(i,{children:n("Started")}),e(i,{children:n("Output")})]})}),e(q,{children:S.steps.map((a,l)=>s(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:a.name}),e(d,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(d,{className:"tabular-nums",children:a.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},me=X(B.createWorkflowInstance),ue=X(B.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,r)=>o.some(N=>N.exportName===r)?r:o[0]?.exportName??"",Oe=()=>{const o=Q(),r=V(),{data:N,error:T}=ne(B.listWorkflows,{}),[g,I]=m(""),[n,h]=m(""),[k,S]=m(""),[$,v]=m(!1),[j,b]=m(null),[f,F]=m([]),[C,R]=m(null),z=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=he(p,g),O=p.find(t=>t.exportName===w),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},K=async()=>{const t=w;if(t==="")return;let u;const c=k.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{const y=n.trim(),G=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},H(""));D({exportName:t,id:G.id,status:G.status}),h("")}catch(y){b(E(y))}v(!1)},a=()=>{A(K())},l=async(t,u)=>{R(u);try{const c=await o.query(ue,{exportName:t,id:u},H(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(E(c))}R(null)},P=t=>{I(t.target.value)},Y=t=>{h(t.target.value)},Z=t=>{S(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&A(l(u,c))};return s("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:T}),e("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),z&&p.length===0?e(M,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Export")}),e(i,{children:r("Name")}),e(i,{children:r("Class")}),e(i,{children:r("Binding")})]})}),e(q,{children:p.map(t=>s(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:r("Start instance")}),j!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),s("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:P,value:w,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Y,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||w==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(re,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:Z,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:r("Instances")}),e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Workflow")}),e(i,{children:r("Instance id")}),e(i,{children:r("Status")}),e(i,{children:r("Output")}),e(i,{})]})}),e(q,{children:f.map(t=>s(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:ee,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(ce,{workflowName:O.name})]})};export{Oe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _="__lunora_admin__:",e={aiAvailable:"__lunora_admin__:aiAvailable",aiChartConfig:"__lunora_admin__:aiChartConfig",aiGenerateSql:"__lunora_admin__:aiGenerateSql",aiTableFilter:"__lunora_admin__:aiTableFilter",assignIssue:"__lunora_admin__:assignIssue",backRelationCounts:"__lunora_admin__:backRelationCounts",clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",explainIssue:"__lunora_admin__:explainIssue",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAdvisorProcedures:"__lunora_admin__:getAdvisorProcedures",getAuditLog:"__lunora_admin__:getAuditLog",getAuthAuditLog:"__lunora_admin__:getAuthAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",lintSql:"__lunora_admin__:lintSql",listFlags:"__lunora_admin__:listFlags",listPushSubscriptions:"__lunora_admin__:listPushSubscriptions",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listTablesIndexes:"__lunora_admin__:listTablesIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetricHistory:"__lunora_admin__:getMetricHistory",getMetricSeries:"__lunora_admin__:getMetricSeries",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueryInsights:"__lunora_admin__:getQueryInsights",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",ignoreIssue:"__lunora_admin__:ignoreIssue",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",resolveIssue:"__lunora_admin__:resolveIssue",rlsPolicies:"__lunora_admin__:rlsPolicies",schemaHistory:"__lunora_admin__:schemaHistory",schemaVersion:"__lunora_admin__:schemaVersion",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",setIssueSeverity:"__lunora_admin__:setIssueSeverity",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{e as ADMIN_FUNCTIONS,_ as ADMIN_FUNCTION_PREFIX};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as E}from"react/compiler-runtime";import{useLunora as Y}from"@lunora/react";import{useState as M,useEffect as Z}from"react";import{u as Q}from"./button-BkCrNcAs.js";import{E as z}from"./empty-state-Cg7t_8qu.js";import{useT as L}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"./ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as E}from"react/compiler-runtime";import{useLunora as Y}from"@lunora/react";import{useState as M,useEffect as Z}from"react";import{u as Q}from"./button-BkCrNcAs.js";import{E as z}from"./empty-state-Cg7t_8qu.js";import{useT as L}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"./ADMIN_FUNCTIONS-4aE59aDq.js";import{c as ee,d as te,g as ae}from"./internal-BSIsQVC6.js";import{jsxs as A,jsx as m}from"react/jsx-runtime";const ne=ae(B.listTables),ie=["react","client","cli"],le=!1,oe={action:"action",mutation:"mutation",query:"query"},J=i=>{const e=i.indexOf(":");return e===-1?{file:"",fn:i}:{file:i.slice(0,e),fn:i.slice(e+1)}},U=({file:i,fn:e,kind:l})=>`await client.${oe[l]}(api.${i}.${e}, { /* args */ });`,re=i=>{const e=`api.${i.file}.${i.fn}`;switch(i.kind){case"action":return U(i);case"mutation":return`const ${i.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},se=({file:i,fn:e})=>`lunora run ${i}:${e} --args '{ }'`,de=i=>["// Read rows",`const rows = await ctx.db.query("${i}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${i}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${i}">;`,`type RowId = Id<"${i}">;`].join(`
|
|
2
2
|
`),ce=(i,e)=>{switch(i){case"cli":return se(e);case"client":return U(e);default:return re(e)}},V=i=>{const e=E(19),{code:l,label:o,testId:a}=i,n=L();let s;e[0]!==l?(s=()=>{ee(l)},e[0]=l,e[1]=s):s=e[1];const u=s;let t;e[2]!==o?(t=m("span",{className:"text-xs font-medium text-muted-foreground",children:o}),e[2]=o,e[3]=t):t=e[3];const c=`${a}-copy`;let r;e[4]!==n?(r=n("Copy"),e[4]=n,e[5]=r):r=e[5];let p;e[6]!==u||e[7]!==c||e[8]!==r?(p=m(Q,{"data-testid":c,onClick:u,size:"xs",type:"button",variant:"ghost",children:r}),e[6]=u,e[7]=c,e[8]=r,e[9]=p):p=e[9];let f;e[10]!==t||e[11]!==p?(f=A("div",{className:"flex items-center justify-between gap-2",children:[t,p]}),e[10]=t,e[11]=p,e[12]=f):f=e[12];let d;e[13]!==l||e[14]!==a?(d=m("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":a,children:l}),e[13]=l,e[14]=a,e[15]=d):d=e[15];let h;return e[16]!==f||e[17]!==d?(h=A("div",{className:"flex flex-col gap-1.5",children:[f,d]}),e[16]=f,e[17]=d,e[18]=h):h=e[18],h},pe=i=>{const e=E(50),{file:l,fn:o,kind:a}=i,n=L(),[s,u]=M("react");let t,c,r;if(e[0]!==l||e[1]!==o||e[2]!==a||e[3]!==n||e[4]!==s){const x={file:l,fn:o,kind:a};let I;e[8]!==n?(I=n("CLI"),e[8]=n,e[9]=I):I=e[9];let C;e[10]!==n?(C=n("Client"),e[10]=n,e[11]=C):C=e[11];let T;e[12]!==n?(T=n("React"),e[12]=n,e[13]=T):T=e[13];let _;e[14]!==I||e[15]!==C||e[16]!==T?(_={cli:I,client:C,react:T},e[14]=I,e[15]=C,e[16]=T,e[17]=_):_=e[17],r=_;let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=P=>{u(P.currentTarget.dataset.tab)},e[18]=D):D=e[18],t=D,c=ce(s,x),e[0]=l,e[1]=o,e[2]=a,e[3]=n,e[4]=s,e[5]=t,e[6]=c,e[7]=r}else t=e[5],c=e[6],r=e[7];const p=c,f=a==="action"&&s==="react"&&!le,d=`api.${l}.${o}`;let h;e[19]!==d?(h=m("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:d}),e[19]=d,e[20]=h):h=e[20];let b;e[21]!==a||e[22]!==n?(b=n("Call this {kind} from your app.",{kind:a}),e[21]=a,e[22]=n,e[23]=b):b=e[23];let v;e[24]!==b?(v=m("p",{className:"text-xs text-muted-foreground",children:b}),e[24]=b,e[25]=v):v=e[25];let y;e[26]!==h||e[27]!==v?(y=A("div",{children:[h,v]}),e[26]=h,e[27]=v,e[28]=y):y=e[28];let k;e[29]!==n?(k=n("Snippet flavour"),e[29]=n,e[30]=k):k=e[30];let $;e[31]!==t||e[32]!==s||e[33]!==r?($=ie.map(x=>m(Q,{"aria-selected":s===x,"data-tab":x,"data-testid":`api-tab-${x}`,onClick:t,role:"tab",size:"xs",type:"button",variant:s===x?"default":"outline",children:r[x]},x)),e[31]=t,e[32]=s,e[33]=r,e[34]=$):$=e[34];let N;e[35]!==k||e[36]!==$?(N=m("div",{"aria-label":k,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:$}),e[35]=k,e[36]=$,e[37]=N):N=e[37];const O=r[s],j=`api-snippet-${s}`;let w;e[38]!==p||e[39]!==O||e[40]!==j?(w=m(V,{code:p,label:O,testId:j}),e[38]=p,e[39]=O,e[40]=j,e[41]=w):w=e[41];let S;e[42]!==f||e[43]!==n?(S=f&&m("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:n("Actions have no React hook — call them through the client.")}),e[42]=f,e[43]=n,e[44]=S):S=e[44];let R;return e[45]!==w||e[46]!==S||e[47]!==y||e[48]!==N?(R=A("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[y,N,w,S]}),e[45]=w,e[46]=S,e[47]=y,e[48]=N,e[49]=R):R=e[49],R},fe=i=>{const e=E(19),{name:l}=i,o=L();let a;e[0]!==l?(a=de(l),e[0]=l,e[1]=a):a=e[1];const n=a;let s;e[2]!==l?(s=m("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:l}),e[2]=l,e[3]=s):s=e[3];let u;e[4]!==o?(u=o("Read and write this table through the typed data model."),e[4]=o,e[5]=u):u=e[5];let t;e[6]!==u?(t=m("p",{className:"text-xs text-muted-foreground",children:u}),e[6]=u,e[7]=t):t=e[7];let c;e[8]!==s||e[9]!==t?(c=A("div",{children:[s,t]}),e[8]=s,e[9]=t,e[10]=c):c=e[10];let r;e[11]!==o?(r=o("Data model"),e[11]=o,e[12]=r):r=e[12];let p;e[13]!==n||e[14]!==r?(p=m(V,{code:n,label:r,testId:"api-snippet-table"}),e[13]=n,e[14]=r,e[15]=p):p=e[15];let f;return e[16]!==c||e[17]!==p?(f=A("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,p]}),e[16]=c,e[17]=p,e[18]=f):f=e[18],f},G=i=>{const e=E(8),{active:l,label:o,onSelect:a,testId:n,value:s}=i;let u;e[0]!==a||e[1]!==s?(u=()=>{a(s)},e[0]=a,e[1]=s,e[2]=u):u=e[2];const t=u,c=l?"page":void 0;let r;return e[3]!==o||e[4]!==t||e[5]!==c||e[6]!==n?(r=m("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":n,onClick:t,type:"button",children:o}),e[3]=o,e[4]=t,e[5]=c,e[6]=n,e[7]=r):r=e[7],r},me=i=>{const e=new Map;for(const l of i){const{file:o,fn:a}=J(l.path),n=e.get(o)??[];n.push({fn:a,kind:l.kind,path:l.path}),e.set(o,n)}return[...e.entries()].map(([l,o])=>({file:l,items:o.toSorted((a,n)=>a.fn.localeCompare(n.fn))})).toSorted((l,o)=>l.file.localeCompare(o.file))},Se=i=>{const e=E(58),{functions:l,initialShardKey:o}=i,a=L(),n=Y(),[s,u]=M(null),[t,c]=M(null);let r,p;e[0]!==n||e[1]!==o?(r=()=>{let _=!1;return n.query(ne,{},te(o??"")).then(D=>(_||u(D),D)).catch(()=>{_||u([])}),()=>{_=!0}},p=[n,o],e[0]=n,e[1]=o,e[2]=r,e[3]=p):(r=e[2],p=e[3]),Z(r,p);let f,d,h,b,v,y,k,$,N,O;if(e[4]!==l||e[5]!==t||e[6]!==a||e[7]!==s){const _=l??[],D=me(_),P=(s??[]).map(ue).toSorted(he);let F;e[18]===Symbol.for("react.memo_cache_sentinel")?(F=g=>{c({kind:"fn",path:g})},e[18]=F):F=e[18];const W=F;let H;e[19]===Symbol.for("react.memo_cache_sentinel")?(H=g=>{c({kind:"table",name:g})},e[19]=H):H=e[19];const X=H;d=t?.kind==="fn"?_.find(g=>g.path===t.path):void 0,f=_.length>0||P.length>0,h=d===void 0?void 0:J(d.path),N="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",O="lunora-api-docs",e[20]!==a?(b=a("API resources"),e[20]=a,e[21]=b):b=e[21],v="flex flex-col gap-4 overflow-y-auto",y="api-rail";let K;e[22]!==t||e[23]!==a?(K=g=>A("div",{className:"flex flex-col gap-1",children:[m("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g.file||a("(root)")}),g.items.map(q=>m(G,{active:t?.kind==="fn"&&t.path===q.path,label:q.fn,onSelect:W,testId:`api-rail-fn-${q.path}`,value:q.path},q.path))]},g.file),e[22]=t,e[23]=a,e[24]=K):K=e[24],k=D.map(K),$=P.length>0&&A("div",{className:"flex flex-col gap-1",children:[m("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Tables")}),P.map(g=>m(G,{active:t?.kind==="table"&&t.name===g,label:g,onSelect:X,testId:`api-rail-table-${g}`,value:g},g))]}),e[4]=l,e[5]=t,e[6]=a,e[7]=s,e[8]=f,e[9]=d,e[10]=h,e[11]=b,e[12]=v,e[13]=y,e[14]=k,e[15]=$,e[16]=N,e[17]=O}else f=e[8],d=e[9],h=e[10],b=e[11],v=e[12],y=e[13],k=e[14],$=e[15],N=e[16],O=e[17];let j;e[25]!==f||e[26]!==a?(j=!f&&m("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:a("No functions or tables to document yet.")}),e[25]=f,e[26]=a,e[27]=j):j=e[27];let w;e[28]!==j||e[29]!==b||e[30]!==v||e[31]!==y||e[32]!==k||e[33]!==$?(w=A("nav",{"aria-label":b,className:v,"data-testid":y,children:[k,$,j]}),e[28]=j,e[29]=b,e[30]=v,e[31]=y,e[32]=k,e[33]=$,e[34]=w):w=e[34];let S;e[35]!==t||e[36]!==a?(S=t===null&&m(z,{description:a("Select a function or table to see how to call it from your app."),testId:"api-empty",title:a("API usage snippets")}),e[35]=t,e[36]=a,e[37]=S):S=e[37];let R;e[38]!==t?.kind||e[39]!==d||e[40]!==h?(R=t?.kind==="fn"&&d!==void 0&&h!==void 0&&m(pe,{file:h.file,fn:h.fn,kind:d.kind},d.path),e[38]=t?.kind,e[39]=d,e[40]=h,e[41]=R):R=e[41];let x;e[42]!==t?.kind||e[43]!==d||e[44]!==a?(x=t?.kind==="fn"&&d===void 0&&m(z,{testId:"api-empty",title:a("API usage snippets")}),e[42]=t?.kind,e[43]=d,e[44]=a,e[45]=x):x=e[45];let I;e[46]!==t?(I=t?.kind==="table"&&m(fe,{name:t.name}),e[46]=t,e[47]=I):I=e[47];let C;e[48]!==S||e[49]!==R||e[50]!==x||e[51]!==I?(C=A("div",{className:"min-w-0",children:[S,R,x,I]}),e[48]=S,e[49]=R,e[50]=x,e[51]=I,e[52]=C):C=e[52];let T;return e[53]!==w||e[54]!==C||e[55]!==N||e[56]!==O?(T=A("div",{className:N,"data-testid":O,children:[w,C]}),e[53]=w,e[54]=C,e[55]=N,e[56]=O,e[57]=T):T=e[57],T};function ue(i){return i.name}function he(i,e){return i.localeCompare(e)}export{le as REACT_HAS_ACTION_HOOK,se as buildCliSnippet,U as buildClientSnippet,re as buildReactSnippet,de as buildTableSnippet,Se as default,J as splitPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as j}from"react/compiler-runtime";import{useLunora as qe}from"@lunora/react";import{useState as P,useMemo as nt,useRef as ze,useCallback as ot,useEffect as _e}from"react";import{ShardInput as dn}from"./ShardInput-BVn2iCU0.js";import{N as Fe}from"./use-admin-query-QJ-ibl5u.js";import{ADMIN_FUNCTIONS as ee}from"./ADMIN_FUNCTIONS-4aE59aDq.js";import{b as kt}from"./browser-storage-xjTyMKY0.js";import{h as Re,f as se,d as ue,g as ve,i as cn}from"./internal-BSIsQVC6.js";import{k as un}from"./use-sql-assistant-C6dl2_Ty.js";import{ConfirmButton as rt}from"./ConfirmButton-CTL3f3kr.js";import{E as mn}from"./empty-state-Cg7t_8qu.js";import{useT as me}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{useReactTable as gn,getSortedRowModel as fn,getCoreRowModel as bn,flexRender as pn}from"@tanstack/react-table";import{useVirtualizer as hn}from"@tanstack/react-virtual";import{f as st}from"./checkbox-StT4Gob6.js";import{c as Be}from"./utils-bhneXptQ.js";import{l as xn}from"./virtual-rect-1o1veP7R.js";import{g as Xe,k as vn,v as yn}from"./data-grid-DcxyIXwG.js";import{jsx as m,jsxs as T,Fragment as Ve}from"react/jsx-runtime";import{DataFilters as wn,toFilterClauses as Ee}from"./DataFilters-B26ZeqBZ.js";import{r as Sn,i as Nn}from"./grid-features-jnrD0SpX.js";import{_ as Cn,u as kn,i as Ye,a as $n,$ as Tn}from"./table-list-sidebar-D9Bd4qgi.js";import{M as $t}from"./modal-shell-CUwwWC2o.js";import ft from"./useDebounced-CU-uftxO.js";import{r as En,l as _n}from"./shard-history-DMEW5VBE.js";const bt=(r,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const l of t)l.ref===r&&n.push({column:l.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},it=r=>`${r.table}.${r.column}`,Rn=/([a-z\d])([A-Z])/gu,Mn=/[\s_-]+/u,Pn=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),Dn=r=>{const e=r.replaceAll(Rn,"$1 $2").split(Mn).map(o=>o.toLowerCase()).filter(o=>o.length>0),n=new Set(e);for(let o=0;o<e.length-1;o+=1){const t=e[o],l=e[o+1];t===void 0||l===void 0||(n.add(`${t}${l}`),n.add(`${t}_${l}`))}return[...n]},pt="•••",In=r=>{let e=2166136261;for(let n=0;n<r.length;n+=1)e^=r.codePointAt(n)??0,e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")},Tt=(r,e)=>{try{return e==="redact"?null:e==="hash"?r==null?r:In(typeof r=="string"?r:JSON.stringify(r)):pt}catch{return pt}},On=(r,e)=>{const n=new Map;for(const o of r)o.table===e&&n.set(o.column,o.strategy);return n},Fn=r=>{for(const e of Dn(r))if(Pn.has(e))return!0;return!1},zn=(r,e)=>{const n=e.filter(t=>!r.has(t)&&Fn(t));if(n.length===0)return r;const o=new Map(r);for(const t of n)o.set(t,"redact");return o},jn=(r,e,n)=>{if(!n.enabled)return r;const o=n.columns.get(e);return o===void 0?r:Tt(r,o)},ht=(r,e)=>!e.enabled||e.columns.size===0?r:r.map(n=>{const o={...n};for(const[t,l]of e.columns)t in o&&(o[t]=Tt(o[t],l));return o}),An=(r,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(r.map(c=>c.id)),leadPx:0,tailPx:0};const l=n-t,i=n+o+t,a=new Set;let d=0,s=0,g=0;for(const c of r){const u=c.getSize(),b=e.has(c.id),f=d+u>l&&d<i;b||f?a.add(c.id):d<l?s+=u:g+=u,d+=u}return{ids:a,leadPx:s,tailPx:g}},Ln=(r,e)=>{const n=new Map;let o=0;for(const t of r)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},Bn=()=>{const r=j(11);let e;r[0]===Symbol.for("react.memo_cache_sentinel")?(e={},r[0]=e):e=r[0];const[n,o]=P(e);let t;r[1]===Symbol.for("react.memo_cache_sentinel")?(t=(b,f,p)=>{o(v=>({...v,[b]:{...v[b],[f]:p}}))},r[1]=t):t=r[1];const l=t;let i;r[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{o({})},r[2]=i):i=r[2];const a=i;let d;r[3]!==n?(d=(b,f)=>{const p=n[b];return p!==void 0&&f in p?{value:p[f]}:void 0},r[3]=n,r[4]=d):d=r[4];const s=d;let g;r[5]!==n?(g=Object.values(n).reduce(Jn,0),r[5]=n,r[6]=g):g=r[6];const c=g;let u;return r[7]!==c||r[8]!==n||r[9]!==s?(u={clear:a,count:c,stage:l,staged:n,stagedValue:s},r[7]=c,r[8]=n,r[9]=s,r[10]=u):u=r[10],u},Vn=(r,e)=>{if(typeof e=="number"){const n=Number(r);return r.trim()===""||Number.isNaN(n)?r:n}if(typeof e=="boolean"){if(r==="true")return!0;if(r==="false")return!1}return r},qn=r=>{const e=j(29),{changes:n,committing:o,onCommit:t,onDiscard:l}=r,i=me();let a;e[0]!==n.length||e[1]!==i?(a=i("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=i,e[2]=a):a=e[2];let d;e[3]!==a?(d=m("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:a}),e[3]=a,e[4]=d):d=e[4];let s;e[5]!==o||e[6]!==i?(s=i(o?"Committing…":"Commit"),e[5]=o,e[6]=i,e[7]=s):s=e[7];let g;e[8]!==o||e[9]!==t||e[10]!==s?(g=m("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:s}),e[8]=o,e[9]=t,e[10]=s,e[11]=g):g=e[11];let c;e[12]!==i?(c=i("Discard"),e[12]=i,e[13]=c):c=e[13];let u;e[14]!==o||e[15]!==l||e[16]!==c?(u=m("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:l,type:"button",children:c}),e[14]=o,e[15]=l,e[16]=c,e[17]=u):u=e[17];let b;e[18]!==d||e[19]!==g||e[20]!==u?(b=T("div",{className:"flex flex-wrap items-center gap-2",children:[d,g,u]}),e[18]=d,e[19]=g,e[20]=u,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(Kn),e[22]=n,e[23]=f):f=e[23];let p;e[24]!==f?(p=m("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=p):p=e[25];let v;return e[26]!==b||e[27]!==p?(v=T("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,p]}),e[26]=b,e[27]=p,e[28]=v):v=e[28],v};function Jn(r,e){return r+Object.keys(e).length}function Kn(r){return T("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[T("span",{className:"text-muted-foreground",children:[r.rowId,".",r.column]}),m("span",{className:"text-destructive line-through",children:Re(r.oldValue)}),m("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),m("span",{className:"text-foreground",children:Re(r.newValue)})]},`${r.rowId}:${r.column}`)}const xt=400,Gn=36,Hn={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Wn={width:"100%"},Qn={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Un={display:"flex",width:"100%"},vt={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},Zn="2.5rem",Et={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},dt=r=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${r.toString()}px`}),_t=(r,e)=>({...dt(r),left:`calc(${Zn} + ${e.toString()}px)`,position:"sticky",zIndex:2}),yt="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",Xn=(r,e,n)=>e.enabled&&e.columns.has(n)?void 0:r,lt="__back__:",Yn=r=>`${lt}${r.table}.${r.column}`,eo=r=>{const e=j(3),{counts:n,rowId:o}=r;if(n===void 0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=m("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=i):i=e[0],i}const t=n[o]??0;let l;return e[1]!==t?(l=m("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=l):l=e[2],l},we=r=>{for(const e of["id","__id__","_id"]){const n=r[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},Rt=(r,e)=>we(r)??`row-${e.toString()}`,to=8,no=r=>{const e=j(16),{anchor:n,state:o}=r,t=me();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 i=l;let a;if(o==="loading"){let s;e[3]!==t?(s=t("Loading…"),e[3]=t,e[4]=s):s=e[4];let g;e[5]!==s?(g=m("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:s}),e[5]=s,e[6]=g):g=e[6],a=g}else if(o.row===null){let s;e[7]!==t?(s=t("No matching row."),e[7]=t,e[8]=s):s=e[8];let g;e[9]!==s?(g=m("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:s}),e[9]=s,e[10]=g):g=e[10],a=g}else{let s;if(e[11]!==o.row){const g=Object.entries(o.row).slice(0,to);s=m("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:g.map(bo)}),e[11]=o.row,e[12]=s}else s=e[12];a=s}let d;return e[13]!==a||e[14]!==i?(d=m("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:i,children:a}),e[13]=a,e[14]=i,e[15]=d):d=e[15],d},oo=r=>{const e=j(22),{column:n,id:o,onNavigate:t,onPreview:l,target:i}=r,[a,d]=P(null),[s,g]=P("idle");let c;e[0]!==o||e[1]!==t||e[2]!==i?(c=()=>{t(i,o)},e[0]=o,e[1]=t,e[2]=i,e[3]=c):c=e[3];const u=c;let b;e[4]!==o||e[5]!==l||e[6]!==s||e[7]!==i?(b=$=>{const h=$.currentTarget.getBoundingClientRect();d({left:h.left,top:h.bottom+4}),s==="idle"&&(g("loading"),se((async()=>{try{g({row:await l(i,o)})}catch{g({row:null})}})()))},e[4]=o,e[5]=l,e[6]=s,e[7]=i,e[8]=b):b=e[8];const f=b;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{d(null)},e[9]=p):p=e[9];const v=p,x=`db-ref-${n}`,y=`Open ${i} ${o}`;let w;e[10]!==o||e[11]!==u||e[12]!==f||e[13]!==x||e[14]!==y?(w=T("button",{"data-testid":x,onBlur:v,onClick:u,onFocus:f,onMouseEnter:f,onMouseLeave:v,title:y,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=u,e[12]=f,e[13]=x,e[14]=y,e[15]=w):w=e[15];let S;e[16]!==a||e[17]!==s?(S=a!==null&&s!=="idle"&&m(no,{anchor:a,state:s}),e[16]=a,e[17]=s,e[18]=S):S=e[18];let N;return e[19]!==w||e[20]!==S?(N=T(Ve,{children:[w,S]}),e[19]=w,e[20]=S,e[21]=N):N=e[21],N},ro=r=>r==="asc"?" ▲":r==="desc"?" ▼":"",lo="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",wt=r=>{const e=j(8),{column:n,onExpand:o,value:t}=r;let l;e[0]!==n||e[1]!==o||e[2]!==t?(l=()=>{o(n,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=l):l=e[3];const i=l,a=`db-expand-${n}`;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=m("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:m("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[4]=d):d=e[4];let s;return e[5]!==i||e[6]!==a?(s=m("button",{"aria-label":"Expand cell",className:lo,"data-testid":a,onClick:i,type:"button",children:d}),e[5]=i,e[6]=a,e[7]=s):s=e[7],s},ao=r=>{const e=j(15),{column:n,initial:o,onCancel:t,onCommit:l,recordId:i}=r,a=ze(null);let d,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{a.current?.select()},s=[],e[0]=d,e[1]=s):(d=e[0],s=e[1]),_e(d,s);let g;e[2]!==t||e[3]!==l?(g=x=>{x.key==="Enter"?(x.preventDefault(),l(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=l,e[4]=g):g=e[4];const c=g;let u;e[5]!==l?(u=x=>{l(x.currentTarget.value)},e[5]=l,e[6]=u):u=e[6];const b=u,f=`db-cell-input-${i}-${n}`;let p;e[7]!==o?(p=Re(o),e[7]=o,e[8]=p):p=e[8];let v;return e[9]!==n||e[10]!==b||e[11]!==c||e[12]!==f||e[13]!==p?(v=m("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:p,onBlur:b,onKeyDown:c,ref:a}),e[9]=n,e[10]=b,e[11]=c,e[12]=f,e[13]=p,e[14]=v):v=e[14],v},so=r=>{const e=j(68),{cell:n,edit:o,highlight:t,mask:l,refs:i}=r,a=n.column.id;let d,s,g,c;if(e[0]!==n||e[1]!==a||e[2]!==o||e[3]!==l||e[4]!==i.columns||e[5]!==i.onNavigate||e[6]!==i.onPreview){c=Symbol.for("react.early_return_sentinel");e:{s=n.getValue(),d=we(n.row.original);const E=i.columns?.[a];if(l.enabled&&l.columns.has(a)){const _=`db-masked-${a}`,R=m(Xe,{value:jn(s,a,l)});let k;e[11]!==_||e[12]!==R?(k=m("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:R}),e[11]=_,e[12]=R,e[13]=k):k=e[13],c=k;break e}if(E!==void 0&&(typeof s=="string"||typeof s=="number")&&String(s)!==""){const _=String(s),R=`${E}:${String(s)}`;let k;e[14]!==a||e[15]!==i.onNavigate||e[16]!==i.onPreview||e[17]!==_||e[18]!==R||e[19]!==E?(k=m(oo,{column:a,id:_,onNavigate:i.onNavigate,onPreview:i.onPreview,target:E},R),e[14]=a,e[15]=i.onNavigate,e[16]=i.onPreview,e[17]=_,e[18]=R,e[19]=E,e[20]=k):k=e[20],c=k;break e}if(d===null){let _;e[21]!==s?(_=m(Xe,{value:s}),e[21]=s,e[22]=_):_=e[22];let R;e[23]!==a||e[24]!==o.onExpandCell||e[25]!==s?(R=m(wt,{column:a,onExpand:o.onExpandCell,value:s}),e[23]=a,e[24]=o.onExpandCell,e[25]=s,e[26]=R):R=e[26];let k;e[27]!==_||e[28]!==R?(k=T(Ve,{children:[_,R]}),e[27]=_,e[28]=R,e[29]=k):k=e[29],c=k;break e}g=o.stagedValue(d,a)}e[0]=n,e[1]=a,e[2]=o,e[3]=l,e[4]=i.columns,e[5]=i.onNavigate,e[6]=i.onPreview,e[7]=d,e[8]=s,e[9]=g,e[10]=c}else d=e[7],s=e[8],g=e[9],c=e[10];if(c!==Symbol.for("react.early_return_sentinel"))return c;const u=g,b=u===void 0?s:u.value;let f;e[30]!==a||e[31]!==o?(f=o.editable&&o.editableColumn(a),e[30]=a,e[31]=o,e[32]=f):f=e[32];const p=f;if(o.editingCell!==null&&o.editingCell.rowId===d&&o.editingCell.column===a){let E;e[33]!==a||e[34]!==o||e[35]!==d||e[36]!==s?(E=R=>{o.stage(d,a,Vn(R,s)),o.cancelEdit()},e[33]=a,e[34]=o,e[35]=d,e[36]=s,e[37]=E):E=e[37];let _;return e[38]!==a||e[39]!==b||e[40]!==o.cancelEdit||e[41]!==d||e[42]!==E?(_=m(ao,{column:a,initial:b,onCancel:o.cancelEdit,onCommit:E,recordId:d}),e[38]=a,e[39]=b,e[40]=o.cancelEdit,e[41]=d,e[42]=E,e[43]=_):_=e[43],_}let v;u!==void 0?v="rounded bg-warning/15 px-1":p&&(v="cursor-text");let x;e[44]!==p||e[45]!==a||e[46]!==o||e[47]!==d?(x=p?()=>{o.startEdit(d,a)}:void 0,e[44]=p,e[45]=a,e[46]=o,e[47]=d,e[48]=x):x=e[48];const y=x,w=v,S=`db-cell-${d}-${a}`;let N;e[49]!==a||e[50]!==t||e[51]!==l?(N=Xn(t,l,a),e[49]=a,e[50]=t,e[51]=l,e[52]=N):N=e[52];let $;e[53]!==b||e[54]!==N?($=m(Xe,{highlight:N,value:b}),e[53]=b,e[54]=N,e[55]=$):$=e[55];let h;e[56]!==v||e[57]!==y||e[58]!==S||e[59]!==$?(h=m("span",{className:w,"data-testid":S,onDoubleClick:y,children:$}),e[56]=v,e[57]=y,e[58]=S,e[59]=$,e[60]=h):h=e[60];let C;e[61]!==a||e[62]!==b||e[63]!==o.onExpandCell?(C=m(wt,{column:a,onExpand:o.onExpandCell,value:b}),e[61]=a,e[62]=b,e[63]=o.onExpandCell,e[64]=C):C=e[64];let D;return e[65]!==C||e[66]!==h?(D=T(Ve,{children:[h,C]}),e[65]=C,e[66]=h,e[67]=D):D=e[67],D},io=r=>{r.preventDefault()},co=({draggedRef:r,header:e,masked:n=!1,onTogglePin:o,pinnedOffset:t,table:l})=>{const i=()=>{r.current=e.column.id},a=()=>{const d=r.current,s=e.column.id;if(r.current=null,d===null||d===s)return;const g=l.getState().columnOrder,c=(g.length>0?g:l.getAllLeafColumns().map(b=>b.id)).filter(b=>b!==d),u=c.indexOf(s);c.splice(u===-1?c.length:u,0,d),l.setColumnOrder(c)};return T("th",{className:Be("group/head text-start text-xs font-medium text-muted-foreground",t!==void 0&&"border-e border-border bg-muted"),draggable:!0,onDragOver:io,onDragStart:i,onDrop:a,style:t===void 0?dt(e.getSize()):_t(e.getSize(),t),children:[T("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${e.column.id}`,onClick:e.column.getToggleSortingHandler(),type:"button",children:[pn(e.column.columnDef.header,e.getContext()),ro(e.column.getIsSorted())]}),n&&m("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-${e.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),m("button",{"aria-label":t===void 0?`Pin ${e.column.id}`:`Unpin ${e.column.id}`,"aria-pressed":t!==void 0,className:Be("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",t===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${e.column.id}`,onClick:()=>{o(e.column.id)},type:"button",children:"📌"}),m("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":e.column.getIsResizing(),"data-testid":`db-resize-${e.column.id}`,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler()})]})},uo=r=>{const e=j(13),{table:n}=r,o=me();let t;e[0]!==n?(t=g=>{n.toggleAllRowsSelected(g)},e[0]=n,e[1]=t):t=e[1];const l=t;let i;e[2]!==o?(i=o("Select all rows"),e[2]=o,e[3]=i):i=e[3];let a;e[4]!==n?(a=n.getIsAllRowsSelected(),e[4]=n,e[5]=a):a=e[5];let d;e[6]!==n?(d=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=d):d=e[7];let s;return e[8]!==l||e[9]!==i||e[10]!==a||e[11]!==d?(s=m("th",{className:"bg-muted",style:Et,children:m(st,{"aria-label":i,checked:a,"data-testid":"db-select-all",indeterminate:d,onCheckedChange:l})}),e[8]=l,e[9]=i,e[10]=a,e[11]=d,e[12]=s):s=e[12],s},mo=r=>{const e=j(17),{row:n}=r,o=me();let t;e[0]!==n.original?(t=we(n.original),e[0]=n.original,e[1]=t):t=e[1];const l=t;let i;e[2]!==n?(i=f=>{n.toggleSelected(f)},e[2]=n,e[3]=i):i=e[3];const a=i;let d;e[4]!==o?(d=o("Select row"),e[4]=o,e[5]=d):d=e[5];let s;e[6]!==n?(s=n.getIsSelected(),e[6]=n,e[7]=s):s=e[7];let g;e[8]!==n.index||e[9]!==n.original?(g=Rt(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=g):g=e[10];const c=`db-select-${g}`,u=l===null;let b;return e[11]!==a||e[12]!==d||e[13]!==s||e[14]!==c||e[15]!==u?(b=m("td",{className:"bg-background",style:Et,children:m(st,{"aria-label":d,checked:s,"data-testid":c,disabled:u,onCheckedChange:a})}),e[11]=a,e[12]=d,e[13]=s,e[14]=c,e[15]=u,e[16]=b):b=e[16],b},go=r=>{const e=j(70),{edit:n,editable:o,mask:t,onDelete:l,onEdit:i,onInspect:a,highlight:d,backRelationCounts:s,onTogglePin:g,pinnedColumns:c,refs:u,tableModel:b}=r,{attachScroll:f,scrollLeft:p,scrollToIndex:v,table:x,tableRows:y,tbodyStyle:w,viewportWidth:S,virtualRows:N}=b,$=ze(null),[h,C]=P(null);let D;e[0]!==x?(D=x.getVisibleLeafColumns(),e[0]=x,e[1]=D):D=e[1];const E=D.length;let _;e[2]!==h||e[3]!==E||e[4]!==n||e[5]!==x||e[6]!==y?(_=pe=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(pe.key))return;pe.preventDefault();const Q=h??{col:0,row:0};if(pe.key==="Enter"){const L=y[Q.row],Y=x.getVisibleLeafColumns()[Q.col];if(L!==void 0&&Y!==void 0){const q=we(L.original);q!==null&&n.editableColumn(Y.id)&&n.startEdit(q,Y.id)}C(Q);return}let{col:te,row:W}=Q;e:switch(pe.key){case"ArrowDown":{W=Math.min(W+1,y.length-1);break e}case"ArrowRight":{te=Math.min(te+1,E-1);break e}case"ArrowUp":{W=Math.max(W-1,0);break e}default:te=Math.max(te-1,0)}C({col:te,row:W})},e[2]=h,e[3]=E,e[4]=n,e[5]=x,e[6]=y,e[7]=_):_=e[7];const R=_;let k,F;e[8]!==h||e[9]!==v?(k=()=>{h!==null&&v(h.row)},F=[h,v],e[8]=h,e[9]=v,e[10]=k,e[11]=F):(k=e[10],F=e[11]),_e(k,F);let B,O,I,G,A,V,H,Z,ge,oe,re,fe,ie,de;if(e[12]!==h||e[13]!==f||e[14]!==s||e[15]!==n||e[16]!==o||e[17]!==d||e[18]!==t||e[19]!==l||e[20]!==i||e[21]!==R||e[22]!==a||e[23]!==g||e[24]!==c||e[25]!==u||e[26]!==p||e[27]!==x||e[28]!==y||e[29]!==w||e[30]!==S||e[31]!==N){const pe=x.getVisibleLeafColumns().map(po),Q=An(pe,c,p,S),te=Ln(x.getVisibleLeafColumns().map(ho),c),W=q=>{const Se=y[q.index],{original:Ne}=Se,Ce=we(Ne),ke=Rt(Ne,q.index),ae={...Qn,height:`${q.size.toString()}px`,transform:`translateY(${q.start.toString()}px)`};return T("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:ae,children:[m(mo,{row:Se}),Q.leadPx>0&&m("td",{"aria-hidden":"true",style:{flex:`0 0 ${Q.leadPx.toString()}px`}}),Se.getVisibleCells().map((J,Me)=>{if(!Q.ids.has(J.column.id))return null;const $e=te.get(J.column.id),Pe=h!==null&&h.row===q.index&&h.col===Me?" ring-1 ring-ring ring-inset":"";return m("td",{className:Be("group/cell truncate font-mono text-muted-foreground",$e!==void 0&&"border-e border-border bg-background",Pe),style:$e===void 0?dt(J.column.getSize()):_t(J.column.getSize(),$e),children:J.column.id.startsWith(lt)?m(eo,{counts:s[J.column.id.slice(lt.length)],rowId:ke}):m(so,{cell:J,edit:n,highlight:d,mask:t,refs:u})},J.id)}),Q.tailPx>0&&m("td",{"aria-hidden":"true",style:{flex:`0 0 ${Q.tailPx.toString()}px`}}),T("td",{className:"flex items-center gap-1",style:vt,children:[m("button",{className:yt,"data-testid":`db-inspect-${ke}`,onClick:()=>{a(Ne)},type:"button",children:"Details"}),o&&T(Ve,{children:[m("button",{className:yt,"data-testid":`db-edit-${ke}`,disabled:Ce===null,onClick:()=>{i(Ce,Ne)},type:"button",children:"Edit"}),m(rt,{confirmLabel:"Delete?",disabled:Ce===null,onConfirm:()=>{l(Ce)},testId:`db-delete-${ke}`,children:"Delete"})]})]})]},Se.id)};B=vn,ge="fill",I="db-scroll",G=R,A=f,V="grid",H=Hn,Z=0,fe="w-full text-xs",ie="db-rows",de=Wn;let L;e[46]!==x?(L=m(uo,{table:x}),e[46]=x,e[47]=L):L=e[47];let Y;e[48]===Symbol.for("react.memo_cache_sentinel")?(Y=m("th",{"aria-label":"Row actions",style:vt}),e[48]=Y):Y=e[48],O=m("thead",{className:"bg-muted/50",children:T("tr",{className:"border-b border-border",style:Un,children:[L,Q.leadPx>0&&m("th",{"aria-hidden":"true",style:{flex:`0 0 ${Q.leadPx.toString()}px`}}),x.getFlatHeaders().map(q=>Q.ids.has(q.column.id)?m(co,{draggedRef:$,header:q,masked:t.columns.has(q.column.id),onTogglePin:g,pinnedOffset:te.get(q.column.id),table:x},q.id):null),Q.tailPx>0&&m("th",{"aria-hidden":"true",style:{flex:`0 0 ${Q.tailPx.toString()}px`}}),Y]})}),oe=w,re=N.map(q=>W(q)),e[12]=h,e[13]=f,e[14]=s,e[15]=n,e[16]=o,e[17]=d,e[18]=t,e[19]=l,e[20]=i,e[21]=R,e[22]=a,e[23]=g,e[24]=c,e[25]=u,e[26]=p,e[27]=x,e[28]=y,e[29]=w,e[30]=S,e[31]=N,e[32]=B,e[33]=O,e[34]=I,e[35]=G,e[36]=A,e[37]=V,e[38]=H,e[39]=Z,e[40]=ge,e[41]=oe,e[42]=re,e[43]=fe,e[44]=ie,e[45]=de}else B=e[32],O=e[33],I=e[34],G=e[35],A=e[36],V=e[37],H=e[38],Z=e[39],ge=e[40],oe=e[41],re=e[42],fe=e[43],ie=e[44],de=e[45];let ce;e[49]!==oe||e[50]!==re?(ce=m("tbody",{style:oe,children:re}),e[49]=oe,e[50]=re,e[51]=ce):ce=e[51];let le;e[52]!==O||e[53]!==ce||e[54]!==fe||e[55]!==ie||e[56]!==de?(le=T("table",{className:fe,"data-testid":ie,style:de,children:[O,ce]}),e[52]=O,e[53]=ce,e[54]=fe,e[55]=ie,e[56]=de,e[57]=le):le=e[57];let X;e[58]!==I||e[59]!==G||e[60]!==A||e[61]!==V||e[62]!==H||e[63]!==Z||e[64]!==le?(X=m("div",{"data-testid":I,onKeyDown:G,ref:A,role:V,style:H,tabIndex:Z,children:le}),e[58]=I,e[59]=G,e[60]=A,e[61]=V,e[62]=H,e[63]=Z,e[64]=le,e[65]=X):X=e[65];let be;return e[66]!==B||e[67]!==ge||e[68]!==X?(be=m(B,{layout:ge,children:X}),e[66]=B,e[67]=ge,e[68]=X,e[69]=be):be=e[69],be},fo=(r,e,n,o=[])=>{const t=r?.columns,l=r?.rows,i=r?.refs,a=nt(()=>{if(t===void 0)return[];const h=t.map(C=>({accessorFn:D=>D[C],header:i?.[C]===void 0?C:`${C} →`,id:C}));for(const C of o)h.push({accessorFn:()=>{},enableSorting:!1,header:`← ${C.table}`,id:Yn(C)});return h},[o,t,i]),d=nt(()=>l??[],[l]),[s,g]=P({}),[c,u]=P({}),b=gn({columnResizeMode:"onChange",columns:a,data:d,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:h=>we(h.original)!==null,getCoreRowModel:bn(),getRowId:(h,C)=>we(h)??`row-${C.toString()}`,getSortedRowModel:fn(),manualSorting:!0,onColumnVisibilityChange:u,onRowSelectionChange:g,onSortingChange:n,state:{columnVisibility:c,rowSelection:s,sorting:e}}),f=b.getRowModel().rows,p=ze(null),v=hn({count:f.length,estimateSize:()=>Gn,getScrollElement:()=>p.current,initialRect:{height:xt,width:0},observeElementRect:(h,C)=>xn(h,C,xt),overscan:8}),x=ot(h=>{v.scrollToIndex(h)},[v]),[y,w]=P({left:0,width:0}),S=ot(h=>{if(p.current=h,h===null)return;const C=()=>{w(E=>E.left===h.scrollLeft&&E.width===h.clientWidth?E:{left:h.scrollLeft,width:h.clientWidth})};h.addEventListener("scroll",C,{passive:!0});const D=new ResizeObserver(C);return D.observe(h),()=>{h.removeEventListener("scroll",C),D.disconnect(),p.current=null}},[]),N=v.getVirtualItems(),$={display:"block",height:`${v.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:S,scrollLeft:y.left,scrollToIndex:x,table:b,tableRows:f,tbodyStyle:$,viewportWidth:y.width,virtualRows:N}};function bo(r){const[e,n]=r;return T("div",{className:"contents",children:[m("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),m("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Re(n),children:Re(n)})]},e)}function po(r){return{getSize:()=>r.getSize(),id:r.id}}function ho(r){return{getSize:()=>r.getSize(),id:r.id}}const at="inline-flex items-center gap-1 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",xo=r=>{const e=j(22),{onCommit:n}=r,o=me(),[t,l]=P(""),i=ze(null);let a,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{i.current?.focus()},d=[],e[0]=a,e[1]=d):(a=e[0],d=e[1]),_e(a,d);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=w=>{l(w.target.value)},e[2]=s):s=e[2];const g=s;let c;e[3]!==t||e[4]!==n?(c=()=>{const w=t.trim();w!==""&&n(w)},e[3]=t,e[4]=n,e[5]=c):c=e[5];const u=c;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 p;e[10]!==t||e[11]!==b||e[12]!==f?(p=m("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:g,placeholder:f,ref:i,value:t}),e[10]=t,e[11]=b,e[12]=f,e[13]=p):p=e[13];let v;e[14]!==o?(v=o("Save"),e[14]=o,e[15]=v):v=e[15];let x;e[16]!==u||e[17]!==v?(x=m("button",{className:at,"data-testid":"db-save-query-confirm",onClick:u,type:"button",children:v}),e[16]=u,e[17]=v,e[18]=x):x=e[18];let y;return e[19]!==p||e[20]!==x?(y=T("span",{className:"inline-flex items-center gap-1",children:[p,x]}),e[19]=p,e[20]=x,e[21]=y):y=e[21],y},vo=r=>{const e=j(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:l,saved:i}=r,a=me(),[d,s]=P(!1);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{s(!0)},e[0]=g):g=e[0];const c=g;let u;e[1]!==l?(u=h=>{l(h),s(!1)},e[1]=l,e[2]=u):u=e[2];const b=u;let f;e[3]!==n||e[4]!==i?(f=h=>{const C=i[Number(h.currentTarget.dataset.index)];C!==void 0&&n(C)},e[3]=n,e[4]=i,e[5]=f):f=e[5];const p=f;let v;e[6]!==t||e[7]!==i?(v=h=>{const C=i[Number(h.currentTarget.dataset.index)];C!==void 0&&t(C.name)},e[6]=t,e[7]=i,e[8]=v):v=e[8];const x=v;let y;e[9]!==a?(y=a("Copy link"),e[9]=a,e[10]=y):y=e[10];let w;e[11]!==o||e[12]!==y?(w=m("button",{className:at,"data-testid":"db-copy-link",onClick:o,type:"button",children:y}),e[11]=o,e[12]=y,e[13]=w):w=e[13];let S;e[14]!==b||e[15]!==d||e[16]!==a?(S=d?m(xo,{onCommit:b}):m("button",{className:at,"data-testid":"db-save-query",onClick:c,type:"button",children:a("Save query")}),e[14]=b,e[15]=d,e[16]=a,e[17]=S):S=e[17];let N;e[18]!==p||e[19]!==x||e[20]!==i||e[21]!==a?(N=i.length>0&&T("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[m("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:a("Saved")}),i.map((h,C)=>T("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[m("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":C,"data-testid":`db-saved-query-${h.name}`,onClick:p,type:"button",children:h.name}),m("button",{"aria-label":a("Delete saved query {name}",{name:h.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":C,"data-testid":`db-saved-query-delete-${h.name}`,onClick:x,type:"button",children:"✕"})]},h.name))]}),e[18]=p,e[19]=x,e[20]=i,e[21]=a,e[22]=N):N=e[22];let $;return e[23]!==w||e[24]!==S||e[25]!==N?($=T("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[w,S,N]}),e[23]=w,e[24]=S,e[25]=N,e[26]=$):$=e[26],$},je="inline-flex items-center gap-1 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 aria-pressed:bg-accent aria-pressed:text-accent-foreground disabled:pointer-events-none disabled:opacity-50",Je="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",yo=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,wo=(r,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?yo.test(r)?"date":"number":e!==null&&typeof e=="object"?"json":"text",So=r=>{try{const e=JSON.parse(r);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},No=r=>{const e=new Date(r),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())}`},Co=r=>{const e=j(8),{column:n,onChange:o,value:t}=r;let l;e[0]!==n||e[1]!==o?(l=g=>{o(n,g)},e[0]=n,e[1]=o,e[2]=l):l=e[2];const i=l,a=t===!0,d=`db-field-${n}`;let s;return e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==d?(s=m(st,{"aria-label":n,checked:a,"data-testid":d,onCheckedChange:i}),e[3]=n,e[4]=i,e[5]=a,e[6]=d,e[7]=s):s=e[7],s},ko=r=>{const e=j(8),{column:n,onChange:o,value:t}=r;let l;e[0]!==n||e[1]!==o?(l=g=>{const c=Number(g.target.value);g.target.value!==""&&!Number.isNaN(c)&&o(n,c)},e[0]=n,e[1]=o,e[2]=l):l=e[2];const i=l,a=`db-field-${n}`,d=typeof t=="number"?t:"";let s;return e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==d?(s=m("input",{"aria-label":n,className:Je,"data-testid":a,onChange:i,type:"number",value:d}),e[3]=n,e[4]=i,e[5]=a,e[6]=d,e[7]=s):s=e[7],s},$o=r=>{const e=j(10),{column:n,onChange:o,value:t}=r;let l;e[0]!==n||e[1]!==o?(l=g=>{const c=new Date(g.target.value).getTime();Number.isNaN(c)||o(n,c)},e[0]=n,e[1]=o,e[2]=l):l=e[2];const i=l,a=`db-field-${n}`;let d;e[3]!==t?(d=typeof t=="number"?No(t):"",e[3]=t,e[4]=d):d=e[4];let s;return e[5]!==n||e[6]!==i||e[7]!==a||e[8]!==d?(s=m("input",{"aria-label":n,className:Je,"data-testid":a,onChange:i,type:"datetime-local",value:d}),e[5]=n,e[6]=i,e[7]=a,e[8]=d,e[9]=s):s=e[9],s},To=r=>{const e=j(8),{column:n,onChange:o,value:t}=r;let l;e[0]!==n||e[1]!==o?(l=g=>{o(n,g.target.value)},e[0]=n,e[1]=o,e[2]=l):l=e[2];const i=l,a=`db-field-${n}`,d=typeof t=="string"?t:"";let s;return e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==d?(s=m("input",{"aria-label":n,className:Je,"data-testid":a,onChange:i,type:"text",value:d}),e[3]=n,e[4]=i,e[5]=a,e[6]=d,e[7]=s):s=e[7],s},Eo=r=>{const e=j(20),{column:n,onChange:o,value:t}=r,l=me();let i;e[0]!==t?(i=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=i):i=e[1];const[a,d]=P(i),[s,g]=P(!1);let c;e[2]!==n||e[3]!==o?(c=w=>{const S=w.target.value;d(S);try{o(n,JSON.parse(S)),g(!1)}catch{g(!0)}},e[2]=n,e[3]=o,e[4]=c):c=e[4];const u=c,b=s&&"border-destructive";let f;e[5]!==b?(f=Be(Je,"min-h-16",b),e[5]=b,e[6]=f):f=e[6];const p=`db-field-${n}`;let v;e[7]!==n||e[8]!==u||e[9]!==f||e[10]!==p||e[11]!==a?(v=m("textarea",{"aria-label":n,className:f,"data-testid":p,onChange:u,value:a}),e[7]=n,e[8]=u,e[9]=f,e[10]=p,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==n||e[14]!==s||e[15]!==l?(x=s&&m("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:l("Invalid JSON")}),e[13]=n,e[14]=s,e[15]=l,e[16]=x):x=e[16];let y;return e[17]!==v||e[18]!==x?(y=T("div",{className:"flex flex-col gap-1",children:[v,x]}),e[17]=v,e[18]=x,e[19]=y):y=e[19],y},_o=r=>{const e=j(43),{column:n,onChange:o,target:t,value:l}=r;let i;e[0]!==n||e[1]!==l?(i=wo(n,l),e[0]=n,e[1]=l,e[2]=i):i=e[2];const a=i,d=`db-field-${n}`;let s;e[3]!==n?(s=m("span",{className:"font-mono",children:n}),e[3]=n,e[4]=s):s=e[4];let g;e[5]!==t?(g=t!==void 0&&T("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",t]}),e[5]=t,e[6]=g):g=e[6];let c;e[7]!==s||e[8]!==g?(c=T("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[s,g]}),e[7]=s,e[8]=g,e[9]=c):c=e[9];let u;e[10]!==n||e[11]!==a||e[12]!==o||e[13]!==l?(u=a==="boolean"&&m(Co,{column:n,onChange:o,value:l}),e[10]=n,e[11]=a,e[12]=o,e[13]=l,e[14]=u):u=e[14];let b;e[15]!==n||e[16]!==a||e[17]!==o||e[18]!==l?(b=a==="number"&&m(ko,{column:n,onChange:o,value:l}),e[15]=n,e[16]=a,e[17]=o,e[18]=l,e[19]=b):b=e[19];let f;e[20]!==n||e[21]!==a||e[22]!==o||e[23]!==l?(f=a==="date"&&m($o,{column:n,onChange:o,value:l}),e[20]=n,e[21]=a,e[22]=o,e[23]=l,e[24]=f):f=e[24];let p;e[25]!==n||e[26]!==a||e[27]!==o||e[28]!==l?(p=a==="json"&&m(Eo,{column:n,onChange:o,value:l}),e[25]=n,e[26]=a,e[27]=o,e[28]=l,e[29]=p):p=e[29];let v;e[30]!==n||e[31]!==a||e[32]!==o||e[33]!==l?(v=a==="text"&&m(To,{column:n,onChange:o,value:l}),e[30]=n,e[31]=a,e[32]=o,e[33]=l,e[34]=v):v=e[34];let x;return e[35]!==v||e[36]!==d||e[37]!==c||e[38]!==u||e[39]!==b||e[40]!==f||e[41]!==p?(x=T("label",{className:"flex flex-col gap-1 text-xs",htmlFor:d,children:[c,u,b,f,p,v]}),e[35]=v,e[36]=d,e[37]=c,e[38]=u,e[39]=b,e[40]=f,e[41]=p,e[42]=x):x=e[42],x},Ro=r=>{const e=j(48),{documentText:n,onCancel:o,onDocumentTextChange:t,onSave:l,refs:i}=r,a=me();let d;e[0]!==n?(d=So(n),e[0]=n,e[1]=d):d=e[1];const s=d,[g,c]=P(!1),u=!g&&s!==null;let b;e[2]!==s||e[3]!==t?(b=(A,V)=>{t(JSON.stringify({...s,[A]:V},null,2))},e[2]=s,e[3]=t,e[4]=b):b=e[4];const f=b;let p;e[5]!==t?(p=A=>{t(A.target.value)},e[5]=t,e[6]=p):p=e[6];const v=p;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{c(!1)},e[7]=x):x=e[7];const y=x;let w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{c(!0)},e[8]=w):w=e[8];const S=w,N=s===null;let $;e[9]!==a?($=a("Form"),e[9]=a,e[10]=$):$=e[10];let h;e[11]!==u||e[12]!==N||e[13]!==$?(h=m("button",{"aria-pressed":u,className:je,"data-testid":"db-editor-form",disabled:N,onClick:y,type:"button",children:$}),e[11]=u,e[12]=N,e[13]=$,e[14]=h):h=e[14];const C=!u;let D;e[15]!==a?(D=a("JSON"),e[15]=a,e[16]=D):D=e[16];let E;e[17]!==D||e[18]!==C?(E=m("button",{"aria-pressed":C,className:je,"data-testid":"db-editor-json",onClick:S,type:"button",children:D}),e[17]=D,e[18]=C,e[19]=E):E=e[19];let _;e[20]!==E||e[21]!==h?(_=T("div",{className:"flex items-center gap-1.5",children:[h,E]}),e[20]=E,e[21]=h,e[22]=_):_=e[22];let R;e[23]!==n||e[24]!==s||e[25]!==f||e[26]!==v||e[27]!==i||e[28]!==u||e[29]!==a?(R=u?m("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(s).map(A=>{const[V,H]=A;return m(_o,{column:V,onChange:f,target:i?.[V],value:H},V)})}):m("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:v,value:n}),e[23]=n,e[24]=s,e[25]=f,e[26]=v,e[27]=i,e[28]=u,e[29]=a,e[30]=R):R=e[30];let k;e[31]!==a?(k=a("Save"),e[31]=a,e[32]=k):k=e[32];let F;e[33]!==l||e[34]!==k?(F=m("button",{className:je,"data-testid":"db-editor-save",onClick:l,type:"button",children:k}),e[33]=l,e[34]=k,e[35]=F):F=e[35];let B;e[36]!==a?(B=a("Cancel"),e[36]=a,e[37]=B):B=e[37];let O;e[38]!==o||e[39]!==B?(O=m("button",{className:je,"data-testid":"db-editor-cancel",onClick:o,type:"button",children:B}),e[38]=o,e[39]=B,e[40]=O):O=e[40];let I;e[41]!==F||e[42]!==O?(I=T("div",{className:"flex items-center gap-1.5",children:[F,O]}),e[41]=F,e[42]=O,e[43]=I):I=e[43];let G;return e[44]!==_||e[45]!==R||e[46]!==I?(G=T("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,R,I]}),e[44]=_,e[45]=R,e[46]=I,e[47]=G):G=e[47],G},Oe="inline-flex items-center gap-1 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 aria-pressed:bg-accent aria-pressed:text-accent-foreground",Mo=r=>{const e=j(61),{columns:n,editable:o,filter:t,filters:l,hasMaskedColumns:i,liveError:a,maskOn:d,onAddRow:s,onBulkDelete:g,onAskAiFilter:c,onClearTable:u,onFilterChange:b,onFiltersChange:f,onGenerateRows:p,onShowJson:v,onShowTable:x,onToggleMask:y,total:w,viewMode:S}=r,N=me(),$=S==="table";let h;e[0]!==x||e[1]!==$?(h=m("button",{"aria-pressed":$,className:Oe,"data-testid":"db-view-table",onClick:x,type:"button",children:"Table"}),e[0]=x,e[1]=$,e[2]=h):h=e[2];const C=S==="json";let D;e[3]!==v||e[4]!==C?(D=m("button",{"aria-pressed":C,className:Oe,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=C,e[5]=D):D=e[5];let E;e[6]!==a||e[7]!==N?(E=a===void 0?N("Live — changes stream in automatically"):N("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=N,e[8]=E):E=e[8];const _=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let R;e[9]!==_?(R=m("span",{"aria-hidden":"true",className:_}),e[9]=_,e[10]=R):R=e[10];let k;e[11]!==a||e[12]!==N?(k=N(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=N,e[13]=k):k=e[13];let F;e[14]!==E||e[15]!==R||e[16]!==k?(F=T("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:E,children:[R,k]}),e[14]=E,e[15]=R,e[16]=k,e[17]=F):F=e[17];let B;e[18]!==i||e[19]!==d||e[20]!==y||e[21]!==N?(B=i&&m("button",{"aria-pressed":d,className:Oe,"data-testid":"db-mask-toggle",onClick:y,type:"button",children:N("Mask sensitive columns")}),e[18]=i,e[19]=d,e[20]=y,e[21]=N,e[22]=B):B=e[22];let O;e[23]!==o||e[24]!==s?(O=o&&m("button",{className:Oe,"data-testid":"db-add-row",onClick:s,type:"button",children:"Add row"}),e[23]=o,e[24]=s,e[25]=O):O=e[25];let I;e[26]!==o||e[27]!==p||e[28]!==N?(I=o&&m("button",{className:Oe,"data-testid":"db-generate-rows",onClick:p,type:"button",children:N("Generate rows")}),e[26]=o,e[27]=p,e[28]=N,e[29]=I):I=e[29];let G;e[30]!==o||e[31]!==t||e[32]!==l||e[33]!==g||e[34]!==w?(G=o&&w>0&&(t!==""||l.length>0)&&m(rt,{confirmLabel:`Delete ${w.toString()} matching?`,onConfirm:g,testId:"db-bulk-delete",children:`Delete ${w.toString()} matching`}),e[30]=o,e[31]=t,e[32]=l,e[33]=g,e[34]=w,e[35]=G):G=e[35];let A;e[36]!==o||e[37]!==t||e[38]!==l||e[39]!==u||e[40]!==w?(A=o&&w>0&&t===""&&l.length===0&&m(rt,{confirmLabel:`Clear all ${w.toString()} rows?`,onConfirm:u,testId:"db-clear-table",children:`Clear table (${w.toString()})`}),e[36]=o,e[37]=t,e[38]=l,e[39]=u,e[40]=w,e[41]=A):A=e[41];let V;e[42]!==B||e[43]!==O||e[44]!==I||e[45]!==G||e[46]!==A||e[47]!==h||e[48]!==D||e[49]!==F?(V=T("div",{className:"flex flex-wrap items-center gap-1.5",children:[h,D,F,B,O,I,G,A]}),e[42]=B,e[43]=O,e[44]=I,e[45]=G,e[46]=A,e[47]=h,e[48]=D,e[49]=F,e[50]=V):V=e[50];let H;e[51]!==n||e[52]!==t||e[53]!==l||e[54]!==c||e[55]!==b||e[56]!==f?(H=m(wn,{columns:n,filters:l,onAskAi:c,onFiltersChange:f,onSearchChange:b,search:t}),e[51]=n,e[52]=t,e[53]=l,e[54]=c,e[55]=b,e[56]=f,e[57]=H):H=e[57];let Z;return e[58]!==V||e[59]!==H?(Z=T("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[V,H]}),e[58]=V,e[59]=H,e[60]=Z):Z=e[60],Z},Po=r=>{const e=j(101),{assistant:n,backRelations:o,browser:t,edit:l,editable:i,onAskAiFilter:a,onInspect:d,onOpenGenerateRows:s,onSaveQuery:g,page:c,preferences:u,queryBar:b,references:f}=r,p=u.maskColumns.size>0,v=n.unavailable?void 0:a;let x;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.liveError||e[7]!==t.onFilterChange||e[8]!==t.onFiltersChange||e[9]!==t.showJson||e[10]!==t.showTable||e[11]!==t.total||e[12]!==t.viewMode||e[13]!==i||e[14]!==s||e[15]!==u.maskOn||e[16]!==u.onToggleMask||e[17]!==p||e[18]!==v?(x=m(Mo,{columns:t.columns,editable:i,filter:t.filter,filters:t.filters,hasMaskedColumns:p,liveError:t.liveError,maskOn:u.maskOn,onAddRow:t.addRow,onAskAiFilter:v,onBulkDelete:t.bulkDelete,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:s,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:u.onToggleMask,total:t.total,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.liveError,e[7]=t.onFilterChange,e[8]=t.onFiltersChange,e[9]=t.showJson,e[10]=t.showTable,e[11]=t.total,e[12]=t.viewMode,e[13]=i,e[14]=s,e[15]=u.maskOn,e[16]=u.onToggleMask,e[17]=p,e[18]=v,e[19]=x):x=e[19];let y;e[20]!==g||e[21]!==b?(y=b!==void 0&&m(vo,{onApply:b.onApplyQuery,onCopyLink:b.onCopyLink,onDelete:b.onDeleteQuery,onSave:g,saved:b.saved}),e[20]=g,e[21]=b,e[22]=y):y=e[22];let w;e[23]!==o||e[24]!==t.onBulkDeleteSelected||e[25]!==t.selectedTable||e[26]!==t.table||e[27]!==t.viewMode||e[28]!==i||e[29]!==c||e[30]!==u.onToggleTranspose||e[31]!==u.transposed?(w=t.viewMode==="table"&&c.rows.length>0&&m(Sn,{backRelations:o.available,columns:c.columns,editable:i,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:u.onToggleTranspose,rows:c.rows,table:t.table.table,transposed:u.transposed}),e[23]=o,e[24]=t.onBulkDeleteSelected,e[25]=t.selectedTable,e[26]=t.table,e[27]=t.viewMode,e[28]=i,e[29]=c,e[30]=u.onToggleTranspose,e[31]=u.transposed,e[32]=w):w=e[32];let S;e[33]!==t.cancelEdit||e[34]!==t.editing||e[35]!==t.saveEdit||e[36]!==t.setEditorDocumentText||e[37]!==i||e[38]!==c?(S=i&&t.editing!==null&&m(Ro,{documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:c.refs}),e[33]=t.cancelEdit,e[34]=t.editing,e[35]=t.saveEdit,e[36]=t.setEditorDocumentText,e[37]=i,e[38]=c,e[39]=S):S=e[39];let N;e[40]!==t.committing||e[41]!==t.discardStaged||e[42]!==t.onCommitStaged||e[43]!==t.stagedChanges||e[44]!==i?(N=i&&t.stagedChanges.length>0&&m(qn,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[40]=t.committing,e[41]=t.discardStaged,e[42]=t.onCommitStaged,e[43]=t.stagedChanges,e[44]=i,e[45]=N):N=e[45];let $;e[46]!==t.writeError?($=t.writeError!==null&&m("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[46]=t.writeError,e[47]=$):$=e[47];let h;e[48]!==x||e[49]!==y||e[50]!==w||e[51]!==S||e[52]!==N||e[53]!==$?(h=T("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[x,y,w,S,N,$]}),e[48]=x,e[49]=y,e[50]=w,e[51]=S,e[52]=N,e[53]=$,e[54]=h):h=e[54];let C;e[55]!==t.viewMode||e[56]!==c?(C=t.viewMode==="table"&&c.rows.length===0&&m("div",{className:"flex flex-1 items-center justify-center p-6",children:m(mn,{description:"Rows you insert into this table will show up here.",icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:m("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[55]=t.viewMode,e[56]=c,e[57]=C):C=e[57];let D;e[58]!==t.viewMode||e[59]!==c||e[60]!==u.maskView||e[61]!==u.transposed?(D=t.viewMode==="table"&&c.rows.length>0&&u.transposed&&m(yn,{columns:c.columns,rows:ht(c.rows,u.maskView)}),e[58]=t.viewMode,e[59]=c,e[60]=u.maskView,e[61]=u.transposed,e[62]=D):D=e[62];let E;e[63]!==o||e[64]!==t.filter||e[65]!==t.onRowDelete||e[66]!==t.onRowEdit||e[67]!==t.table||e[68]!==t.viewMode||e[69]!==l||e[70]!==i||e[71]!==d||e[72]!==c||e[73]!==u.maskView||e[74]!==u.onTogglePin||e[75]!==u.pinnedColumns||e[76]!==u.transposed||e[77]!==f?(E=t.viewMode==="table"&&c.rows.length>0&&!u.transposed&&m(go,{backRelationCounts:o.counts,edit:l,editable:i,highlight:t.filter,mask:u.maskView,onDelete:t.onRowDelete,onEdit:t.onRowEdit,onInspect:d,onTogglePin:u.onTogglePin,pinnedColumns:u.pinnedColumns,refs:f,tableModel:t.table}),e[63]=o,e[64]=t.filter,e[65]=t.onRowDelete,e[66]=t.onRowEdit,e[67]=t.table,e[68]=t.viewMode,e[69]=l,e[70]=i,e[71]=d,e[72]=c,e[73]=u.maskView,e[74]=u.onTogglePin,e[75]=u.pinnedColumns,e[76]=u.transposed,e[77]=f,e[78]=E):E=e[78];let _;e[79]!==t.viewMode||e[80]!==c||e[81]!==u.maskView?(_=t.viewMode==="json"&&m("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(ht(c.rows,u.maskView),null,2)}),e[79]=t.viewMode,e[80]=c,e[81]=u.maskView,e[82]=_):_=e[82];let R;e[83]!==t.changePageSize||e[84]!==t.goNext||e[85]!==t.goPrevious||e[86]!==t.hasNext||e[87]!==t.hasPrevious||e[88]!==t.jumpToPage||e[89]!==t.pageSize||e[90]!==t.rangeEnd||e[91]!==t.rangeStart||e[92]!==t.total?(R=m("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:m(Cn,{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[83]=t.changePageSize,e[84]=t.goNext,e[85]=t.goPrevious,e[86]=t.hasNext,e[87]=t.hasPrevious,e[88]=t.jumpToPage,e[89]=t.pageSize,e[90]=t.rangeEnd,e[91]=t.rangeStart,e[92]=t.total,e[93]=R):R=e[93];let k;return e[94]!==C||e[95]!==D||e[96]!==E||e[97]!==_||e[98]!==R||e[99]!==h?(k=T("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[h,C,D,E,_,R]}),e[94]=C,e[95]=D,e[96]=E,e[97]=_,e[98]=R,e[99]=h,e[100]=k):k=e[100],k},Do="/__lunora/seed",et=200,Io=50,Oo=(r,e)=>{const n=[];for(const o of r)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},Fo=async r=>{const e=await fetch(Do,{body:JSON.stringify(r),headers:{"Content-Type":"application/json"},method:"POST"}),n=await e.json();return e.ok&&n.rows!==void 0?{kind:"ok",rows:n.rows}:{kind:"error",message:n.error??`seed request failed (${String(e.status)})`}},zo="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",jo="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",Ao=({columns:r,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const l=me(),[i,a]=P(10),[d,s]=P(!1),[g,c]=P(void 0),[u,b]=P(void 0),[f,p]=P(0),v=S=>{const N=Number(S.target.value);!Number.isNaN(N)&&N>=1&&a(Math.min(N,et))},x=async()=>{c(void 0),b(void 0),p(0),s(!0);try{const S=await Fo({count:i,existingIds:e,seed:Date.now(),table:t});if(S.kind==="error"){c(S.message);return}const{rows:N}=S;if(N.length===0){c(l("No rows generated — all columns were skipped."));return}const $=await o(N);if($.error!==void 0){c($.error);return}b($.inserted),p($.conflicts);const h=Oo(r,e);h.length>0&&c(l("Inserted {count} rows. Skipped FK columns: {cols}",{cols:h.join(", "),count:$.inserted.toString()}))}finally{s(!1)}},y=()=>{se(x())},w=r.filter(S=>S.pk!==!0);return T($t,{label:l("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[T("div",{className:"flex items-start justify-between",children:[T("div",{className:"flex flex-col gap-0.5",children:[m("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:l("Generate dummy rows")}),m("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:l("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),m("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:l("Close")})]}),T("div",{className:"flex items-center gap-2",children:[m("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:l("Row count")}),m("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:et,min:1,onChange:v,type:"number",value:i}),m("span",{className:"text-xs text-muted-foreground",children:l("(max {max})",{max:et.toString()})})]}),w.length>0&&T("div",{className:"flex flex-col gap-1",children:[m("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:l("Columns to seed")}),m("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:w.map(S=>{const N=S.ref!==void 0&&S.type==="id",$=N&&(e[S.ref??""]??[]).length===0,h=$?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",C=$?`gen-rows-fk-empty-${S.name}`:`gen-rows-fk-ok-${S.name}`,D=$?l("FK: no rows in {ref} — will skip",{ref:S.ref??""}):l("→ {ref}",{ref:S.ref??""});return T("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[m("span",{className:"text-foreground",children:S.name}),T("span",{className:"text-muted-foreground",children:["(",S.type,")"]}),S.optional&&m("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),N&&m("span",{className:h,"data-testid":C,children:D})]},S.name)})})]}),g!==void 0&&m("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:g}),u!==void 0&&g===void 0&&m("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:f>0?l("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:f.toString(),inserted:u.toString(),total:(u+f).toString()}):l("Inserted {count} rows successfully.",{count:u.toString()})}),T("div",{className:"flex justify-end gap-2",children:[m("button",{className:zo,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:l("Cancel")}),m("button",{className:jo,"data-testid":"gen-rows-generate",disabled:d,onClick:y,type:"button",children:l(d?"Inserting…":"Generate & insert")})]})]})},Lo=ve(ee.backRelationCounts),Bo=(r,e,n,o)=>{const t=j(16),l=qe();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={},t[0]=i):i=t[0];const[a,d]=P(i);let s;if(t[1]!==r||t[2]!==e){let x;t[4]!==r?(x=y=>r.has(it(y)),t[4]=r,t[5]=x):x=t[5],s=e.filter(x),t[1]=r,t[2]=e,t[3]=s}else s=t[3];const g=s;let c;t[6]!==n||t[7]!==g?(c=JSON.stringify([g,n]),t[6]=n,t[7]=g,t[8]=c):c=t[8];const u=c;let b;t[9]!==l||t[10]!==o||t[11]!==u?(b=async x=>{const[y,w]=JSON.parse(u);if(y.length===0||w.length===0){x.cancelled||d({});return}try{const S=await l.query(Lo,{ids:w,relations:y},ue(o));x.cancelled||d(Object.fromEntries(S.relations.map(Vo)))}catch{}},t[9]=l,t[10]=o,t[11]=u,t[12]=b):b=t[12];const f=b;let p,v;return t[13]!==f?(p=()=>{const x={cancelled:!1};return se(f(x)),()=>{x.cancelled=!0}},v=[f],t[13]=f,t[14]=p,t[15]=v):(p=t[14],v=t[15]),_e(p,v),a};function Vo(r){return[it(r),r.counts]}const Le=r=>{const e=r[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},Mt=r=>r==null?"":typeof r=="object"?JSON.stringify(r):String(r),St=r=>r.map(e=>({column:e.column,operator:e.operator,value:e.value===void 0?"":Mt(e.value)})),Nt=r=>r===void 0?[]:[{desc:r.direction==="desc",id:r.column}],qo=r=>[r.column,r.operator,r.value],Ae=(r,e,n,o)=>JSON.stringify([r??"",e??"",(n??[]).map(t=>qo(t)),o===void 0?null:[o.column,o.direction]]),Ct=200,Jo=20,Ko=ve(ee.readTablePage),Go=ve(ee.facetColumn),tt=ve(ee.writeRow),Ho=ve(ee.deleteRows),Wo=ve(ee.clearTable),Qo={},ct=new Set(["__doc__","__id__","_creationTime","_id","id"]),Uo=r=>{const e=r.__doc__;if(typeof e=="string")try{const o=JSON.parse(e);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o}catch{}const n={};for(const[o,t]of Object.entries(r))ct.has(o)||(n[o]=t);return n},Zo=({filters:r,offset:e,pageSize:n,search:o,sorting:t,table:l})=>({filters:Ee(r),limit:n,offset:e,orderBy:Le(t),search:o,skipCount:!0,table:l}),Xo=({filters:r,search:e,table:n})=>({filters:Ee(r),limit:1,search:e,table:n}),Yo=(r,e)=>{const n=new Map;for(const t of r?.rows??[]){const l=we(t);l!==null&&n.set(l,t)}const o=[];for(const[t,l]of Object.entries(e))for(const[i,a]of Object.entries(l))o.push({column:i,newValue:a,oldValue:n.get(t)?.[i],rowId:t});return o},er=r=>!ct.has(r),tr=({initialFilters:r,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:l,pageSize:i,resolveBackRelations:a,tableParam:d})=>{const s=qe(),[g,c]=P(i),[u,b]=P(o??""),f=d===void 0||d===""?null:d,[p,v]=P(0),[x,y]=P("table"),[w,S]=P(()=>Nt(e)),[N,$]=P(n??""),[h,C]=P(()=>St(r??[])),{clearFacets:D,facets:E,refetchFacets:_,toggleFacet:R}=kn(),[k,F]=P(null),[B,O]=P(null),I=Bn(),[G,A]=P(null),[V,H]=P(!1),[Z,ge]=P(d),[oe,re]=P(()=>Ae(o,n,r,e)),[fe,ie]=P(0),[de,ce]=P(()=>Ae(o,n,r,e)),le=d!==Z,X=Ae(o,n,r,e),be=le||!le&&X!==oe&&X!==de;if(be){ge(d),re(X),ie(z=>z+1),S(Nt(e)),$(n??"");const M=St(r??[]);C(M),b(o??""),D(),I.clear(),A(null),v(0)}else X!==oe&&re(X);const pe=be?n??"":N,Q=be?o??"":u,te=`${d??""}:${fe.toString()}`,W=ft(pe.trim(),300,te),L=ft(Q.trim(),400,te),Y=Ae(L,W,Ee(h),Le(w));Y!==de&&ce(Y);const q=Fe(ee.listTables,Qo,{live:!0,shardKey:L}),Se=q.data??null,Ne=q.error,Ce=Zo({filters:h,offset:p,pageSize:g,search:W,sorting:w,table:f??""}),ke=Xo({filters:h,search:W,table:f??""}),ae=Fe(ee.readTablePage,Ce,{enabled:f!==null,keepPreviousData:!1,live:!0,shardKey:L}),J=ae.data??null,Me=ae.error,{liveError:$e}=ae,Pe=Fe(ee.readTablePage,ke,{enabled:f!==null,live:!0,shardKey:L});_e(()=>{q.data!==void 0&&En(L)},[q.data,L]);const Ke=M=>{t?.(M)},Ge=(M,z)=>{t?.(M,{search:z})},He=async(M,z)=>{try{return(await s.query(Ko,{filters:[],limit:Jo,offset:0,search:z,table:M},ue(L))).rows.find(ne=>we(ne)===z)??null}catch{return null}},De=(M,z,ne,ye)=>Te=>s.query(Go,{column:Te,filters:Ee(ne),search:ye,table:z},ue(M)),We=M=>{R(M,f===null?null:De(L,f,h,W))},Qe=(M,z)=>{const ne=Mt(z);C(ye=>[...ye.filter(Te=>Te.column!==M),{column:M,operator:"eq",value:ne}]),v(0)},Ue=Ye(De),Ze=Ye(_),K=Ye(l);_e(()=>{f!==null&&Ze.current(Ue.current(L,f,h,W))},[L,f,h,W]),_e(()=>{f===null||K.current===void 0||Z!==d||oe!==X||K.current({filters:Ee(h),orderBy:Le(w),search:W,shard:L})},[f,d,Z,oe,X,h,w,W,L]);const U=M=>{f!==null&&v(Math.max(0,M))},he=(M,z)=>{A({column:z,rowId:M})},xe=()=>{A(null)},Ie=async()=>{if(f!==null){O(null),H(!0);try{for(const[M,z]of Object.entries(I.staged))await s.query(tt,{doc:z,id:M,op:"patch",table:f},ue(L));I.clear(),A(null),ae.refetch()}catch(M){O(M.message)}H(!1)}},Pt=()=>{I.clear(),A(null)},Dt=Yo(J,I.staged),ut=async(M,z,ne)=>{if(f===null)return;O(null);let ye;if(M!=="delete")try{ye=ne===void 0||ne.trim()===""?{}:JSON.parse(ne)}catch(Te){O(`Invalid JSON: ${Te.message}`);return}try{await s.query(tt,{doc:ye,id:z??void 0,op:M,table:f},ue(L)),F(null),ae.refetch()}catch(Te){O(Te.message)}},mt=async(M,z)=>{if(f!==null){O(null);try{let ne="cap-hit";for(let ye=0;ye<Ct;ye+=1)if(!(await s.query(M,z,ue(L))).hasMore){ne="completed";break}v(0),ae.refetch(),ne==="cap-hit"&&O(`Stopped after ${Ct.toString()} batches — rows still match this delete. Run it again to remove the rest.`)}catch(ne){O(ne.message)}}},It=M=>{S(M),v(0)},Ot=nt(()=>f===null?[]:a?.(f)??[],[a,f]),Ft=fo(J,w,It,Ot),zt={filters:Ee(h),orderBy:Le(w),search:W,shard:u,table:f??void 0},gt=Pe.data?.total??(J===null?0:p+J.rows.length),jt=p>0,At=J!==null&&p+J.rows.length<gt,Lt=J===null||J.rows.length===0?0:p+1,Bt=J===null?0:p+J.rows.length,Vt=()=>{q.refetch()},qt=()=>{y("table")},Jt=()=>{y("json")},Kt=()=>{se(mt(Ho,{filters:Ee(h),search:W,table:f}))},Gt=()=>{se(mt(Wo,{table:f}))},Ht=M=>{$(M.target.value),v(0)},Wt=M=>{C(M),v(0)},Qt=()=>{O(null);const M={};for(const z of J?.columns??[])ct.has(z)||(M[z]="");F({docText:JSON.stringify(M,null,2),id:""})},Ut=M=>{F(z=>z===null?z:{docText:M,id:z.id})},Zt=()=>{k!==null&&se(ut(k.id===""?"insert":"patch",k.id===""?null:k.id,k.docText))},Xt=()=>{F(null),O(null)},Yt=()=>{U(p-g)},en=()=>{U(p+g)},tn=M=>{U(Math.max(0,(M-1)*g))},nn=M=>{c(M),v(0)},on=(M,z)=>{O(null),F({docText:JSON.stringify(Uo(z),null,2),id:M})},rn=M=>{se(ut("delete",M))},ln=async M=>{if(!(f===null||M.length===0)){O(null);try{for(const z of M)await s.query(tt,{id:z,op:"delete",table:f},ue(L));ae.refetch()}catch(z){O(z.message)}}},an=M=>{se(ln(M))},sn=()=>{se(Ie())};return{addRow:Qt,bulkDelete:Kt,cancelCellEdit:xe,cancelEdit:Xt,changePageSize:nn,clearTable:Gt,columns:J?.columns??[],committing:V,currentView:zt,discardStaged:Pt,editableColumn:er,editing:k,editingCell:G,facetFilter:Qe,facets:E,filter:N,filters:h,goNext:en,goPrevious:Yt,hasNext:At,hasPrevious:jt,jumpToPage:tn,liveError:$e,loadTables:Vt,navigateToRef:Ge,onBulkDeleteSelected:an,onCommitStaged:sn,onFilterChange:Ht,onFiltersChange:Wt,onRowDelete:rn,onRowEdit:on,page:J,previewRef:He,pageError:Me,pageSize:g,rangeEnd:Bt,rangeStart:Lt,queryShardKey:L,saveEdit:Zt,selectedTable:f,selectTable:Ke,setEditorDocumentText:Ut,setShardKey:b,shardKey:u,showJson:Jt,showTable:qt,stage:I.stage,stagedChanges:Dt,stagedValue:I.stagedValue,startCellEdit:he,table:Ft,tables:Se,tablesError:Ne,toggleFacet:We,total:gt,viewMode:x,writeError:B}},nr=[],or=()=>{const r=j(1);let e;r[0]===Symbol.for("react.memo_cache_sentinel")?(e={},r[0]=e):e=r[0];const{data:n}=Fe(ee.maskPolicies,e);return Array.isArray(n?.columns)?n.columns:nr},rr="lunora-studio-pinned-columns",lr=r=>{const e=j(24),{columns:n,initialPins:o,selectedTable:t}=r;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[i,a]=kt(rr,l),d=t??"",s=i[d];let g;e[1]!==o||e[2]!==s?(g=s===void 0?new Set((o??"").split(",").filter(ar)):new Set(s),e[1]=o,e[2]=s,e[3]=g):g=e[3];const c=g;let u;e[4]!==d||e[5]!==c||e[6]!==a?(u=R=>{a(k=>{const F=k[d]??[...c],B=F.includes(R)?F.filter(O=>O!==R):[...F,R];return{...k,[d]:B}})},e[4]=d,e[5]=c,e[6]=a,e[7]=u):u=e[7];const b=u,[f,p]=P(!1);let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(sr)},e[8]=v):v=e[8];const x=v,y=or(),[w,S]=P(!0);let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{S(ir)},e[9]=N):N=e[9];const $=N;let h;if(e[10]!==n||e[11]!==y||e[12]!==t){const R=On(y,t??"");h=zn(R,n),e[10]=n,e[11]=y,e[12]=t,e[13]=h}else h=e[13];const C=h;let D;e[14]!==C||e[15]!==w?(D={columns:C,enabled:w},e[14]=C,e[15]=w,e[16]=D):D=e[16];const E=D;let _;return e[17]!==C||e[18]!==w||e[19]!==E||e[20]!==b||e[21]!==c||e[22]!==f?(_={maskColumns:C,maskOn:w,maskView:E,onToggleMask:$,onTogglePin:b,onToggleTranspose:x,pinnedColumns:c,transposed:f},e[17]=C,e[18]=w,e[19]=E,e[20]=b,e[21]=c,e[22]=f,e[23]=_):_=e[23],_};function ar(r){return r!==""}function sr(r){return!r}function ir(r){return!r}const dr=ve(ee.describeTable),cr=ve(ee.readTablePage),ur=ve(ee.importShard),mr=r=>{const e=r._id??r.id??r.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},gr=r=>{const e=Object.values(r.inserted).reduce((d,s)=>d+s,0),[n]=r.errors;if(n===void 0)return{conflicts:r.conflicts,error:void 0,inserted:e};const o=r.errors.length-1,t=e+r.conflicts+r.errors.length,l=o===1?"error":"errors",i=o>0?` (+${o.toString()} more ${l})`:"",a=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${i}`;return{conflicts:r.conflicts,error:a,inserted:e}},fr=r=>{const e=qe(),[n,o]=P(!1),[t,l]=P(void 0),[i,a]=P(void 0),[d,s]=P(void 0),[g,c]=P({}),[u,b]=P(!1),[f,p]=P(void 0),v=async(x,y)=>{o(!0),l(x),a(y),s(void 0),c({}),p(void 0),b(!0);try{const w=await e.query(dr,{table:x},ue(y)),{columns:S}=w;s(S);const N={},$=S.filter(h=>h.ref!==void 0&&h.type==="id"&&h.pk!==!0);for(const h of $){if(h.ref===void 0)continue;const{ref:C}=h;if(N[C]===void 0)try{const D=await e.query(cr,{filters:[],limit:Io,offset:0,search:"",table:C},ue(y));N[C]=D.rows.flatMap(E=>mr(E)||[])}catch{N[C]=[]}}c(N)}catch(w){p(w.message)}b(!1)};return{closeDialog:()=>{o(!1),l(void 0),a(void 0),s(void 0),c({}),p(void 0)},columnMeta:d,error:f,fkPools:g,insertBatch:async(x,y)=>{if(t===void 0||i===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const w=await e.query(ur,{rows:x.map(N=>({doc:N,table:t}))},ue(i)),S=gr(w);return S.error!==void 0||(y(),r()),S}catch(w){return{conflicts:0,error:w.message,inserted:0}}},loading:u,open:n,openDialog:(x,y)=>{se(v(x,y))},shardKey:i,table:t}},br=()=>{const r=j(6),[e,n]=P(null);let o;r[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{n(null)},r[0]=o):o=r[0];const t=o,[l,i]=P(null);let a;r[1]===Symbol.for("react.memo_cache_sentinel")?(a=(u,b)=>{i({column:u,value:b})},r[1]=a):a=r[1];const d=a;let s;r[2]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{i(null)},r[2]=s):s=r[2];const g=s;let c;return r[3]!==l||r[4]!==e?(c={closeExpandedCell:g,closeInspect:t,expandedCell:l,inspecting:e,onExpandCell:d,onInspect:n},r[3]=l,r[4]=e,r[5]=c):c=r[5],c},pr=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,hr=(r,e)=>typeof e=="number"&&pr.test(r),xr=r=>{const e=j(26),{column:n,onNavigate:o,target:t,value:l}=r;let i;e[0]!==o||e[1]!==t||e[2]!==l?(i=()=>{t!==void 0&&o(t,String(l))},e[0]=o,e[1]=t,e[2]=l,e[3]=i):i=e[3];const a=i;if(l==null){let g;return e[4]===Symbol.for("react.memo_cache_sentinel")?(g=m("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=g):g=e[4],g}if(t!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const g=`rd-ref-${n}`,c=`Open ${t} ${String(l)}`,u=String(l);let b;return e[5]!==a||e[6]!==g||e[7]!==c||e[8]!==u?(b=T("button",{"data-testid":g,onClick:a,title:c,type:"button",children:[u," ↗"]}),e[5]=a,e[6]=g,e[7]=c,e[8]=u,e[9]=b):b=e[9],b}if(hr(n,l)){const g=`rd-ts-${n}`;let c;e[10]!==l?(c=l.toString(),e[10]=l,e[11]=c):c=e[11];let u;e[12]!==l?(u=cn(l),e[12]=l,e[13]=u):u=e[13];let b;return e[14]!==g||e[15]!==c||e[16]!==u?(b=m("span",{"data-testid":g,title:c,children:u}),e[14]=g,e[15]=c,e[16]=u,e[17]=b):b=e[17],b}if(typeof l=="object"){let g;e[18]!==l?(g=JSON.stringify(l,null,2),e[18]=l,e[19]=g):g=e[19];let c;return e[20]!==g?(c=m("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:g}),e[20]=g,e[21]=c):c=e[21],c}let d;e[22]!==l?(d=Re(l),e[22]=l,e[23]=d):d=e[23];let s;return e[24]!==d?(s=m("span",{children:d}),e[24]=d,e[25]=s):s=e[25],s},vr=r=>{const e=j(21),{columns:n,onClose:o,onNavigate:t,refs:l,row:i}=r;let a;e[0]!==o||e[1]!==t?(a=(f,p)=>{t(f,p),o()},e[0]=o,e[1]=t,e[2]=a):a=e[2];const d=a;let s;e[3]===Symbol.for("react.memo_cache_sentinel")?(s=m("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=s):s=e[3];let g;e[4]!==o?(g=T("div",{className:"mb-3 flex items-center justify-between",children:[s,m("button",{"data-testid":"rd-close",onClick:o,type:"button",children:"Close"})]}),e[4]=o,e[5]=g):g=e[5];let c;if(e[6]!==n||e[7]!==d||e[8]!==l||e[9]!==i){let f;e[11]!==d||e[12]!==l||e[13]!==i?(f=p=>T("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${p}`,children:[m("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:p}),m("dd",{className:"m-0",children:m(xr,{column:p,onNavigate:d,target:l?.[p],value:i[p]})})]},p),e[11]=d,e[12]=l,e[13]=i,e[14]=f):f=e[14],c=n.map(f),e[6]=n,e[7]=d,e[8]=l,e[9]=i,e[10]=c}else c=e[10];let u;e[15]!==c?(u=m("dl",{"data-testid":"rd-fields",children:c}),e[15]=c,e[16]=u):u=e[16];let b;return e[17]!==o||e[18]!==g||e[19]!==u?(b=T($t,{label:"Row detail",onClose:o,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[g,u]}),e[17]=o,e[18]=g,e[19]=u,e[20]=b):b=e[20],b},yr=50,wr=r=>{const e=j(8),{active:n,onPick:o,shard:t}=r;let l;e[0]!==o||e[1]!==t?(l=()=>{o(t)},e[0]=o,e[1]=t,e[2]=l):l=e[2];const i=l,a=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,d=`shard-explorer-item-${t}`;let s;return e[3]!==i||e[4]!==t||e[5]!==a||e[6]!==d?(s=m("button",{className:a,"data-testid":d,onClick:i,type:"button",children:t}),e[3]=i,e[4]=t,e[5]=a,e[6]=d,e[7]=s):s=e[7],s},Sr=({onFetchTables:r,onSelect:e})=>{const n=me(),[o]=P(()=>_n()),[t,l]=P(!1),[i,a]=P(void 0),[d,s]=P(void 0),[g,c]=P(!1),[u,b]=P(void 0),f=ze(0),p=()=>{l(y=>!y)},v=async y=>{e(y),a(y),s(void 0),b(void 0),c(!0),f.current+=1;const w=f.current;try{const S=await r(y);f.current===w&&s(S?.slice(0,yr))}catch(S){f.current===w&&b(S.message)}f.current===w&&c(!1)},x=y=>{se(v(y))};return o.length===0?null:T("div",{"data-testid":"shard-explorer",children:[T("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:p,type:"button",children:[n("Shards seen"),m("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&T("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:[m("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),m("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(y=>m("li",{children:m(wr,{active:i===y,onPick:x,shard:y})},y))}),i!==void 0&&T("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[m("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:i})}),g&&m("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),u!==void 0&&m("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:u}),!g&&u===void 0&&d?.length===0&&m("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!g&&u===void 0&&d!==void 0&&d.length>0&&m("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:d.map(y=>T("li",{className:"flex items-center justify-between text-xs",children:[m("span",{"data-testid":`shard-explorer-table-${y.name}`,children:y.name}),m("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${y.name}`,children:y.rowCount})]},y.name))})]})]})]})},Nr="lunora-studio-back-relations",Cr={},kr=50,$r=[],Tr=ve(ee.listTables),Er=r=>{const e=j(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:l}=r;let i;e[0]!==o||e[1]!==l?(i=m(dn,{onChange:o,testId:"db-shard-input",value:l}),e[0]=o,e[1]=l,e[2]=i):i=e[2];let a;e[3]!==n||e[4]!==o?(a=m(Sr,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=a):a=e[5];let d;return e[6]!==t||e[7]!==i||e[8]!==a?(d=T("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,i,a]}),e[6]=t,e[7]=i,e[8]=a,e[9]=d):d=e[9],d},el=({editable:r=!1,globalTableNames:e,initialFilters:n,initialOrderBy:o,initialPins:t,initialSearch:l,initialShardKey:i,onNavigateToGlobal:a,onSelectTable:d,onViewChange:s,pageSize:g=kr,queryBar:c,schemaSwitch:u,tableParam:b})=>{const f=Fe(ee.describeTables,{},{shardKey:i??""}).data?.columnsByTable??Cr,[p,v]=kt(Nr,{}),x=ot(K=>{const U=new Set(p[K]);return bt(K,f).filter(he=>U.has(it(he)))},[p,f]),y=tr({initialFilters:n,initialOrderBy:o,initialSearch:l,initialShardKey:i,onSelectTable:d,onViewChange:s,pageSize:g,resolveBackRelations:x,tableParam:b}),{cancelCellEdit:w,columns:S,currentView:N,editableColumn:$,editingCell:h,facetFilter:C,facets:D,loadTables:E,navigateToRef:_,onFiltersChange:R,page:k,pageError:F,previewRef:B,queryShardKey:O,selectedTable:I,selectTable:G,setShardKey:A,shardKey:V,stage:H,stagedValue:Z,startCellEdit:ge,tables:oe,tablesError:re,toggleFacet:fe}=y,ie=un(V),de=K=>{se((async()=>{const U=await ie.suggestFilter(K,I??"");U!==void 0&&R(U.map(he=>{const xe=he.value,Ie=typeof xe=="string"||typeof xe=="number"||typeof xe=="boolean"?String(xe):"";return{column:he.column,operator:he.operator,value:Ie}}))})())},ce=I===null?[]:bt(I,f),le=new Set(p[I??""]),X=[];for(const K of k?.rows??[]){const U=K._id??K.id;typeof U=="string"&&U!==""&&X.push(U)}const be=Bo(le,ce,X,O),pe=K=>{v(U=>{const he=I??"",xe=U[he]??[];return{...U,[he]:xe.includes(K)?xe.filter(Ie=>Ie!==K):[...xe,K]}})},Q=lr({columns:S,initialPins:t,selectedTable:I}),te=br(),{closeExpandedCell:W,closeInspect:L,expandedCell:Y,inspecting:q,onExpandCell:Se}=te,Ne=qe(),Ce=async K=>await Ne.query(Tr,{},ue(K)),ke=()=>{I!==null&&G(I)},{closeDialog:ae,columnMeta:J,fkPools:Me,insertBatch:$e,open:Pe,openDialog:Ke}=fr(ke),Ge=()=>{I!==null&&Ke(I,V)},He=K=>$e(K,ae),De=(K,U)=>{if(a!==void 0&&e?.has(K)===!0){a(K,U);return}_(K,U)},We=c?.onSaveQuery,Qe=K=>{We?.(K,N)},Ue={cancelEdit:w,editable:r,editableColumn:$,editingCell:h,onExpandCell:Se,stage:H,stagedValue:Z,startEdit:ge},Ze={columns:k?.refs,onNavigate:De,onPreview:B};return T("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[m($n,{header:m(Er,{onFetchShardTables:Ce,onShardChange:A,schemaSwitch:u,shardKey:V}),onReload:E,onSelect:G,prefix:"db",selected:I,tables:oe??$r}),T("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[re!==null&&m("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:re}),k===null&&F===null&&m("div",{className:"flex flex-1 items-center justify-center p-6",children:m("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),F!==null&&m("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:F}),k!==null&&m(Po,{assistant:ie,backRelations:{available:ce,counts:be,enabled:le,onToggle:pe},browser:y,edit:Ue,editable:r,onAskAiFilter:de,onInspect:te.onInspect,onOpenGenerateRows:Ge,onSaveQuery:Qe,page:k,preferences:Q,queryBar:c,references:Ze})]}),k!==null&&m(Tn,{columns:S,facets:D,onFacetFilter:C,onToggleFacet:fe}),q!==null&&k!==null&&m(vr,{columns:k.columns,onClose:L,onNavigate:De,refs:k.refs,row:q}),Y!==null&&m(Nn,{column:Y.column,onClose:W,value:Y.value}),Pe&&I!==null&&J!==void 0&&m(Ao,{columns:J,fkPools:Me,onClose:ae,onInsertRows:He,table:I})]})};export{el as DataBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as oe}from"@lunora/react";import{useState as L,useRef as G,useEffect as B}from"react";import{O as I}from"./use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as ne}from"./DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{_ as ae,i as se,u as ie,a as ce,$ as de}from"./table-list-sidebar-
|
|
1
|
+
import{useLunora as oe}from"@lunora/react";import{useState as L,useRef as G,useEffect as B}from"react";import{O as I}from"./use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as ne}from"./DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{_ as ae,i as se,u as ie,a as ce,$ as de}from"./table-list-sidebar-D9Bd4qgi.js";import{useT as J}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{b as ue}from"./cf-links-Dmg86v1D.js";import{c as A}from"react/compiler-runtime";import{d as me,m as U,f as fe,n as pe,p as ge,u as he}from"./table-DdJBrClo.js";import{k as be,g as xe}from"./data-grid-DcxyIXwG.js";import{jsx as r,jsxs as $}from"react/jsx-runtime";import{E as ve}from"./empty-state-Cg7t_8qu.js";const Ne=(t,e)=>{const a=t._id;return typeof a=="string"||typeof a=="number"?String(a):`row-${e.toString()}`},q=t=>t==null?"∅":t===""?"(empty)":typeof t=="object"?JSON.stringify(t):String(t),we=t=>{const e=A(33),{filters:a,onChangePageSize:f,onJumpToPage:i,onNext:u,onPrevious:s,onRemoveFilter:F,page:o,pageSize:b,pagination:x}=t,C=J(),{hasNext:v,hasPrevious:k,rangeEnd:p,rangeStart:R,total:_}=x;let N;e[0]!==a||e[1]!==F||e[2]!==C?(N=a.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:a.map((d,y)=>$("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:d.column}),r("span",{className:"text-muted-foreground",children:"="}),r("span",{className:"font-mono text-foreground",children:q(d.value)}),r("button",{"aria-label":C("Remove filter"),className:"ml-0.5 text-muted-foreground hover:text-foreground","data-testid":"gdb-filter-remove",onClick:()=>{F(y)},type:"button",children:"✕"})]},`${d.column}:${q(d.value)}`))}),e[0]=a,e[1]=F,e[2]=C,e[3]=N):N=e[3];let w;e[4]!==o.columns?(w=o.columns.map(Se),e[4]=o.columns,e[5]=w):w=e[5];let m;e[6]!==w?(m=r(me,{children:r(U,{children:w})}),e[6]=w,e[7]=m):m=e[7];let c;if(e[8]!==o.columns||e[9]!==o.rows){let d;e[11]!==o.columns?(d=(y,E)=>r(U,{"data-testid":"gdb-row",children:o.columns.map(P=>r(he,{className:"max-w-xs truncate font-mono text-xs",children:r(xe,{value:y[P]})},P))},Ne(y,E)),e[11]=o.columns,e[12]=d):d=e[12],c=o.rows.map(d),e[8]=o.columns,e[9]=o.rows,e[10]=c}else c=e[10];let h;e[13]!==c?(h=r(fe,{children:c}),e[13]=c,e[14]=h):h=e[14];let g;e[15]!==m||e[16]!==h?(g=r(be,{layout:"fill",children:r("div",{className:"min-h-0 flex-1 overflow-auto",children:$(pe,{"data-testid":"gdb-rows",children:[m,h]})})}),e[15]=m,e[16]=h,e[17]=g):g=e[17];let n;e[18]!==v||e[19]!==k||e[20]!==f||e[21]!==i||e[22]!==u||e[23]!==s||e[24]!==b||e[25]!==p||e[26]!==R||e[27]!==_?(n=r("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:r(ae,{hasNext:v,hasPrevious:k,onJumpToPage:i,onNext:u,onPageSizeChange:f,onPrevious:s,pageSize:b,prefix:"gdb",rangeEnd:p,rangeStart:R,total:_})}),e[18]=v,e[19]=k,e[20]=f,e[21]=i,e[22]=u,e[23]=s,e[24]=b,e[25]=p,e[26]=R,e[27]=_,e[28]=n):n=e[28];let S;return e[29]!==N||e[30]!==g||e[31]!==n?(S=$("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"gdb-page",children:[N,g,n]}),e[29]=N,e[30]=g,e[31]=n,e[32]=S):S=e[32],S};function Se(t){return r(ge,{children:t},t)}const ye=()=>{const t=A(8),e=J();let a;t[0]!==e?(a=e("Tables marked .global() (D1-backed, region-replicated) will appear here."),t[0]=e,t[1]=a):a=t[1];let f;t[2]===Symbol.for("react.memo_cache_sentinel")?(f=$("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]=f):f=t[2];let i;t[3]!==e?(i=e("No global tables."),t[3]=e,t[4]=i):i=t[4];let u;return t[5]!==a||t[6]!==i?(u=r("div",{className:"flex flex-1 items-center justify-center p-6",children:r(ve,{description:a,icon:f,testId:"gdb-empty",title:i})}),t[5]=a,t[6]=i,t[7]=u):u=t[7],u},$e=50,ke=[],Pe=[],De=({initialTable:t,onSelectTable:e,pageSize:a=$e,schemaSwitch:f}={})=>{const i=oe(),u=J(),[s,F]=L(t??null),[o,b]=L(0),[x,C]=L(a),[v,k]=L([]),p=se(v),{clearFacets:R,facets:_,refetchFacets:N,toggleFacet:w}=ie(),m=I(["lunora-global-tables"],()=>i.listGlobalTables()),c=m.data??null,h=m.error,g=I(["lunora-global-page",s??"",o,x,JSON.stringify(v)],()=>i.readGlobalTablePage({filters:v,limit:x,offset:o,table:s??""}),{enabled:s!==null,keepPreviousData:!1}),n=g.data??null,S=g.error,d=(l,T)=>z=>i.facetGlobalColumn({column:z,filters:T,table:l}),y=(l,T)=>{N(d(l,T))};ne(()=>{m.refetch(),s!==null&&(g.refetch(),y(s,p.current))},!0);const E=G(void 0),P=l=>{F(l),E.current=l,k([]),p.current=[],R(),b(0),e?.(l)},W=l=>{w(l,s===null?null:d(s,p.current))},M=l=>{k(l),p.current=l,b(0),s!==null&&y(s,l)},Z=(l,T)=>{M([...p.current.filter(z=>z.column!==l),{column:l,value:T}])},H=l=>{M(p.current.filter((T,z)=>z!==l))},O=G(P);B(()=>{O.current=P}),B(()=>{if(t===void 0||t===""||E.current===t)return;E.current=t;const l=t;queueMicrotask(()=>{O.current(l)})},[t]);const j=l=>{s!==null&&b(Math.max(0,l))},D=n?.total??0,K=o>0,Q=n!==null&&o+n.rows.length<D,V=n===null||n.rows.length===0?0:o+1,X=n===null?0:o+n.rows.length,Y=()=>{m.refetch()},ee=()=>{j(o-x)},te=()=>{j(o+x)},re=l=>{j(Math.max(0,(l-1)*x))},le=l=>{C(l),b(0)};return $("div",{className:"flex h-full min-w-0","data-testid":"lunora-global-data-browser",children:[r(ce,{header:$("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[f,r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"gdb-cf-link",href:ue,rel:"noreferrer",target:"_blank",children:u("Open in Cloudflare")})]}),onReload:Y,onSelect:P,prefix:"gdb",selected:s,tables:c??ke}),$("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[h!==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:h}),c!==null&&c.length===0&&r(ye,{}),S!==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:S}),c!==null&&c.length>0&&n===null&&S===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.")})}),n!==null&&r(we,{filters:v,onChangePageSize:le,onJumpToPage:re,onNext:te,onPrevious:ee,onRemoveFilter:H,page:n,pageSize:x,pagination:{hasNext:Q,hasPrevious:K,rangeEnd:X,rangeStart:V,total:D}})]}),r(de,{columns:n?.columns??Pe,facets:_,onFacetFilter:Z,onToggleFacet:W})]})};export{De as GlobalDataBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"react/compiler-runtime";import"@tanstack/react-router";import"react";import"./badge-BbuuAio7.js";import"./card-CIDGUN6K.js";import"./empty-state-Cg7t_8qu.js";import"./use-admin-query-QJ-ibl5u.js";import"./DEFAULT_LOCALE-BZ4NojpD.js";import"./ADMIN_FUNCTIONS-
|
|
1
|
+
import"react/compiler-runtime";import"@tanstack/react-router";import"react";import"./badge-BbuuAio7.js";import"./card-CIDGUN6K.js";import"./empty-state-Cg7t_8qu.js";import"./use-admin-query-QJ-ibl5u.js";import"./DEFAULT_LOCALE-BZ4NojpD.js";import"./ADMIN_FUNCTIONS-4aE59aDq.js";import"./internal-BSIsQVC6.js";import"./utils-bhneXptQ.js";import"./DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js";import{H as b}from"./home-panel-CeeqqV0z.js";import"react/jsx-runtime";export{b as HomePanel};
|