@lunora/studio 1.0.0-alpha.223 → 1.0.0-alpha.225
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/FileBrowser.mjs +4 -4
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/vector-browser.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/DataBrowser-B5Sl4vMa.mjs +4 -0
- package/dist/packem_shared/DataFilters-CYZFt2EK.mjs +1 -0
- package/dist/packem_shared/{GlobalDataBrowser-CR138dEZ.mjs → GlobalDataBrowser-BzhSVDvF.mjs} +1 -1
- package/dist/packem_shared/table-list-sidebar-CYRSPLIv.mjs +1 -0
- package/dist/standalone/{chunk-DPJRFJGG.js → chunk-43HEY5SJ.js} +1 -1
- package/dist/standalone/{chunk-FZXPE3EA.js → chunk-46EQO6E7.js} +1 -1
- package/dist/standalone/chunk-4QWQLDFZ.js +1 -0
- package/dist/standalone/{chunk-C5JRZI3P.js → chunk-5ITJRE7T.js} +1 -1
- package/dist/standalone/{chunk-C7JZ7GM3.js → chunk-6JJLA4DT.js} +1 -1
- package/dist/standalone/{chunk-QZRXRMVF.js → chunk-6SG5Y2X3.js} +1 -1
- package/dist/standalone/{chunk-ANAVNSAK.js → chunk-7FZPPR6U.js} +1 -1
- package/dist/standalone/{chunk-PJZYLISI.js → chunk-7JR5NBZT.js} +1 -1
- package/dist/standalone/chunk-AHIYIRQJ.js +1 -0
- package/dist/standalone/{chunk-6UFH4FWY.js → chunk-B5757NYK.js} +1 -1
- package/dist/standalone/{chunk-BWLFO2IE.js → chunk-CCHE3AP7.js} +1 -1
- package/dist/standalone/{chunk-YTMEMOHR.js → chunk-CEWWYWDH.js} +1 -1
- package/dist/standalone/{chunk-U775EN4P.js → chunk-CFZF73E5.js} +1 -1
- package/dist/standalone/{chunk-D73MZIDA.js → chunk-CGBR52EF.js} +1 -1
- package/dist/standalone/{chunk-NGBD2OUY.js → chunk-CGWLZBB7.js} +1 -1
- package/dist/standalone/chunk-E34I2O2H.js +1 -0
- package/dist/standalone/{chunk-NNOKBVJ7.js → chunk-EN3YBGYA.js} +1 -1
- package/dist/standalone/{chunk-NX7UAIZ2.js → chunk-FFHEYNCC.js} +1 -1
- package/dist/standalone/{chunk-IVSO7SEU.js → chunk-FJ33XGJ2.js} +1 -1
- package/dist/standalone/{chunk-ZY35EIK4.js → chunk-FYTLD6ZB.js} +1 -1
- package/dist/standalone/{chunk-4ZHQUGP5.js → chunk-FZ5ZSUA2.js} +1 -1
- package/dist/standalone/{chunk-BOASUV37.js → chunk-GC7R2JNV.js} +1 -1
- package/dist/standalone/{chunk-DHJHD5RD.js → chunk-HSWCIY4E.js} +1 -1
- package/dist/standalone/{chunk-SQKUZR6R.js → chunk-IDGVZH7L.js} +1 -1
- package/dist/standalone/{chunk-ZXEE2Z4S.js → chunk-IOZMKJXM.js} +1 -1
- package/dist/standalone/{chunk-PQPPJGH4.js → chunk-J7PUQPIK.js} +1 -1
- package/dist/standalone/{chunk-MU57Q7EJ.js → chunk-JBFHGYJ7.js} +1 -1
- package/dist/standalone/{chunk-MK64Z2KK.js → chunk-LGHZBMSX.js} +1 -1
- package/dist/standalone/{chunk-NO3SWCXH.js → chunk-LWS3QK2Z.js} +1 -1
- package/dist/standalone/{chunk-VWJ4BY6M.js → chunk-MTPPT5DN.js} +1 -1
- package/dist/standalone/chunk-N3N44LM3.js +1 -0
- package/dist/standalone/{chunk-NSTYZZ5L.js → chunk-NAABU3WM.js} +1 -1
- package/dist/standalone/{chunk-4DLM7KCA.js → chunk-NMS7725B.js} +1 -1
- package/dist/standalone/{chunk-EBNLDFWL.js → chunk-OGFGCB3X.js} +1 -1
- package/dist/standalone/{chunk-2UECQGYG.js → chunk-OQQ3KQUW.js} +1 -1
- package/dist/standalone/{chunk-KRYLPBID.js → chunk-OYO24LYQ.js} +1 -1
- package/dist/standalone/chunk-PG7XHMUR.js +9 -0
- package/dist/standalone/{chunk-FRX3HV4O.js → chunk-PGX7ADT3.js} +1 -1
- package/dist/standalone/{chunk-6LYYH4KG.js → chunk-RBESZ4U6.js} +1 -1
- package/dist/standalone/{chunk-YGZGLWD5.js → chunk-RHCY7FOG.js} +1 -1
- package/dist/standalone/chunk-RWYC2UZQ.js +4 -0
- package/dist/standalone/{chunk-QYCKDIIK.js → chunk-SEQJ26SP.js} +1 -1
- package/dist/standalone/{chunk-LD7EXQJA.js → chunk-SX43GWLQ.js} +1 -1
- package/dist/standalone/{chunk-4IX7Z3XP.js → chunk-T7TBRE7I.js} +1 -1
- package/dist/standalone/{chunk-BF5GZZ2N.js → chunk-UKEPEJQE.js} +1 -1
- package/dist/standalone/{chunk-BNFLBJXF.js → chunk-VCJJ6V4Q.js} +1 -1
- package/dist/standalone/{chunk-SRVHSFKC.js → chunk-VELEXXBI.js} +1 -1
- package/dist/standalone/{chunk-YHYYGVE2.js → chunk-WH5TVSUG.js} +1 -1
- package/dist/standalone/{chunk-HZ23X7G4.js → chunk-WSZOB3GK.js} +1 -1
- package/dist/standalone/{chunk-5JAOC6KI.js → chunk-X4WJS7OY.js} +1 -1
- package/dist/standalone/{chunk-CFIBDQF7.js → chunk-XBSC4FT4.js} +1 -1
- package/dist/standalone/chunk-XEW4IUTU.js +5 -0
- package/dist/standalone/{chunk-2PLDVCEP.js → chunk-XUH4K2HN.js} +1 -1
- package/dist/standalone/{chunk-OCZPVECA.js → chunk-YQ7E3R3D.js} +1 -1
- package/dist/standalone/{chunk-TS5SE5EM.js → chunk-YU2KFHL7.js} +1 -1
- package/dist/standalone/{chunk-EIREQDTV.js → chunk-ZVJOW25X.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/DataBrowser-DWSaSSRj.mjs +0 -4
- package/dist/packem_shared/DataFilters-Cocu-WWE.mjs +0 -1
- package/dist/packem_shared/table-list-sidebar-DxvakjpR.mjs +0 -1
- package/dist/standalone/chunk-2H7LJELF.js +0 -1
- package/dist/standalone/chunk-4RLMVWJL.js +0 -1
- package/dist/standalone/chunk-5CEDU7OP.js +0 -1
- package/dist/standalone/chunk-6ZPT7CTC.js +0 -5
- package/dist/standalone/chunk-BJEJVHCO.js +0 -9
- package/dist/standalone/chunk-EUBMVV62.js +0 -1
- package/dist/standalone/chunk-WLA5B3GY.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as X}from"@lunora/react";import{useState as m,useEffect as re}from"react";import{B as E}from"../packem_shared/button-q0UYSmrn.mjs";import{C as P,a as j}from"../packem_shared/card--2hKx4L2.mjs";import{E as H}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as se}from"../packem_shared/input-CXhxesPC.mjs";import{T as U,a as z,b as x,c as i,d as J,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{T as ae}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ne}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as M}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as W,b as A,j as Z,d as V,c as ee}from"../packem_shared/internal-Df43vQI0.mjs";import{jsxs as n,jsx as e}from"react/jsx-runtime";const oe=["queued","running","paused","waiting","complete","errored","terminated"],le=["pause","resume","terminate"],ie="WORKFLOWS_NOT_CONFIGURED",de=o=>typeof o=="object"&&o!==null&&o.code===ie,ce=o=>{const s=o.error??o.output;if(s===void 0)return"—";try{return JSON.stringify(s,Z)}catch{return"(unserializable)"}},me=({loadDetail:o,loadInstances:s,readOnly:N,runAction:R,workflowName:w})=>{const O=X(),a=Y(),[h,g]=m(null),[k,I]=m(null),[v,_]=m(""),[b,f]=m(null),[$,S]=m(!1),[F,D]=m(null),p=o??(r=>O.getWorkflowInstance(r)),C=N?void 0:R??(s===void 0?r=>O.setWorkflowInstanceStatus(r):void 0),L=async()=>{f(null),S(!1);const r=v===""?void 0:v;try{if(s===void 0){const l=await O.listWorkflowInstances({name:w,status:r});if(l.configured===!1){g(null),S(!0);return}g(l.instances);return}g(await s({name:w,status:r}))}catch(l){g(null),de(l)?S(!0):f(A(l))}};re(()=>{I(null),W(L())},[w,v]);const K=async r=>{f(null);try{I(await p({id:r,name:w}))}catch(l){f(A(l))}},q=async(r,l)=>{if(C!==void 0){D(r),f(null);try{await C({action:l,id:r,name:w}),await L()}catch(G){f(A(G))}D(null)}};return n("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[n("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:a("Instance history")}),n("select",{"aria-label":a("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:r=>{_(r.target.value)},value:v,children:[e("option",{value:"",children:a("All statuses")}),oe.map(r=>e("option",{value:r,children:r},r))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),$&&e(H,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!$&&h!==null&&h.length===0&&e(H,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),h!==null&&h.length>0&&e(P,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:n(U,{"data-testid":"workflow-instances-table",children:[e(z,{children:n(x,{children:[e(i,{children:a("Instance id")}),e(i,{children:a("Status")}),e(i,{children:a("Created")}),e(i,{children:a("Ended")}),e(i,{"aria-label":a("Actions")})]})}),e(J,{children:h.map(r=>n(x,{"data-testid":`workflow-instance-${r.id}`,children:[e(d,{className:"font-mono text-xs",children:r.id}),e(d,{className:"font-mono text-xs",children:r.status}),e(d,{className:"text-muted-foreground tabular-nums",children:r.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:r.endedOn??"—"}),e(d,{className:"text-right",children:n("div",{className:"flex justify-end gap-1.5",children:[e(E,{"data-testid":`workflow-instance-steps-${r.id}`,onClick:()=>{W(K(r.id))},size:"sm",type:"button",variant:"outline",children:a("Steps")}),C!==void 0&&le.map(l=>e(E,{"data-testid":`workflow-instance-${l}-${r.id}`,disabled:F===r.id,onClick:()=>{W(q(r.id,l))},size:"sm",type:"button",variant:"ghost",children:a(l)},l))]})})]},r.id))})]})})}),k!==null&&e(P,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:n(j,{className:"flex flex-col gap-2 px-4 py-3",children:[n("div",{className:"flex items-center justify-between",children:[n("span",{className:"font-mono text-xs",children:[a("Steps")," · ",k.id]}),e(E,{"data-testid":"workflow-instance-detail-close",onClick:()=>{I(null)},size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),k.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):n(U,{"data-testid":"workflow-instance-steps",children:[e(z,{children:n(x,{children:[e(i,{children:a("Step")}),e(i,{children:a("Type")}),e(i,{children:a("Attempts")}),e(i,{children:a("Started")}),e(i,{children:a("Output")})]})}),e(J,{children:k.steps.map((r,l)=>n(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:r.name}),e(d,{className:"text-xs text-muted-foreground",children:r.type??"—"}),e(d,{className:"tabular-nums",children:r.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:r.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:ce(r)})]},`${r.name}:${String(l)}`))})]})]})})]})},ue=ee(M.createWorkflowInstance),fe=ee(M.getWorkflowInstanceStatus),he=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output,Z)}catch{return"(unserializable)"}},pe=(o,s)=>o.some(N=>N.exportName===s)?s:o[0]?.exportName??"",Ee=()=>{const o=X(),s=Y(),{data:N,error:R}=ne(M.listWorkflows,{}),[w,O]=m(""),[a,h]=m(""),[g,k]=m(""),[I,v]=m(!1),[_,b]=m(null),[f,$]=m([]),[S,F]=m(null),D=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],T=pe(p,w),B=p.find(t=>t.exportName===T),C=t=>{$(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},L=async()=>{const t=T;if(t==="")return;let u;const c=g.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(s("Params must be valid JSON"));return}v(!0),b(null);try{const y=a.trim(),Q=await o.query(ue,{exportName:t,id:y===""?void 0:y,params:u},V(""));C({exportName:t,id:Q.id,status:Q.status}),h("")}catch(y){b(A(y))}v(!1)},K=()=>{W(L())},q=async(t,u)=>{F(u);try{const c=await o.query(fe,{exportName:t,id:u},V(""));C({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(A(c))}F(null)},r=t=>{O(t.target.value)},l=t=>{h(t.target.value)},G=t=>{k(t.target.value)},te=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&W(q(u,c))};return n("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),e("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),D&&p.length===0?e(H,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")}):e(P,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:n(U,{"data-testid":"workflows-table",children:[e(z,{children:n(x,{children:[e(i,{children:s("Export")}),e(i,{children:s("Name")}),e(i,{children:s("Class")}),e(i,{children:s("Binding")})]})}),e(J,{children:p.map(t=>n(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&&n("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:s("Start instance")}),_!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),n("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":s("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:r,value:T,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(se,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:l,placeholder:s("Instance id (optional)"),value:a}),e(E,{"data-testid":"workflows-start-button",disabled:I||T==="",onClick:K,children:s(I?"Starting…":"Start instance")})]}),e(ae,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:G,placeholder:s("Params (JSON, optional)"),value:g})]}),f.length>0&&n("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:s("Instances")}),e(P,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:n(U,{"data-testid":"workflows-instances-table",children:[e(z,{children:n(x,{children:[e(i,{children:s("Workflow")}),e(i,{children:s("Instance id")}),e(i,{children:s("Status")}),e(i,{children:s("Output")}),e(i,{})]})}),e(J,{children:f.map(t=>n(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:he(t)}),e(d,{children:e(E,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:te,size:"xs",variant:"outline",children:S===t.id?s("Refreshing…"):s("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),B!==void 0&&e(me,{workflowName:B.name})]})};export{Ee as default};
|
|
1
|
+
import{useLunora as Z}from"@lunora/react";import{useState as c,useRef as G,useEffect as se}from"react";import{B as T}from"../packem_shared/button-q0UYSmrn.mjs";import{C as L,a as j}from"../packem_shared/card--2hKx4L2.mjs";import{E as H}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ae}from"../packem_shared/input-CXhxesPC.mjs";import{T as q,a as U,b as N,c as i,d as z,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{T as ne}from"../packem_shared/textarea--40GKAyz.mjs";import{u as oe}from"../packem_shared/use-admin-query-tlBof8Yg.mjs";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as M}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as E,b as W,j as te,d as Y,c as re}from"../packem_shared/internal-Df43vQI0.mjs";import{jsxs as o,jsx as t}from"react/jsx-runtime";const le=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=l=>typeof l=="object"&&l!==null&&l.code===de,ue=l=>{const r=l.error??l.output;if(r===void 0)return"—";try{return JSON.stringify(r,te)}catch{return"(unserializable)"}},me=({loadDetail:l,loadInstances:r,readOnly:w,runAction:A,workflowName:g})=>{const C=Z(),a=ee(),[x,v]=c(null),[k,I]=c(null),[b,R]=c(""),[y,h]=c(null),[_,S]=c(!1),[$,F]=c(null),m=G(0),f=G(0),p=G(0),D=l??(e=>C.getWorkflowInstance(e)),O=w?void 0:A??(r===void 0?e=>C.setWorkflowInstanceStatus(e):void 0),P=async()=>{f.current+=1;const e=f.current;h(null),S(!1);const s=b===""?void 0:b;try{if(r===void 0){const u=await C.listWorkflowInstances({name:g,status:s});if(e!==f.current)return;if(u.configured===!1){v(null),S(!0);return}v(u.instances);return}const n=await r({name:g,status:s});e===f.current&&v(n)}catch(n){if(e!==f.current)return;v(null),ce(n)?S(!0):h(W(n))}};se(()=>{m.current+=1,p.current+=1,I(null),E(P())},[g,b]);const J=async e=>{p.current+=1;const s=p.current;h(null);try{const n=await D({id:e,name:g});s===p.current&&I(n)}catch(n){s===p.current&&h(W(n))}},B=()=>{p.current+=1,I(null)},K=async(e,s)=>{if(O===void 0)return;const n=m.current;F(e),h(null);try{await O({action:s,id:e,name:g}),n===m.current&&await P()}catch(u){h(W(u))}F(null)};return o("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[o("div",{className:"flex items-center justify-between gap-2",children:[t("h3",{className:"text-sm font-medium",children:a("Instance history")}),o("select",{"aria-label":a("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:e=>{R(e.target.value)},value:b,children:[t("option",{value:"",children:a("All statuses")}),le.map(e=>t("option",{value:e,children:e},e))]})]}),y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:y}),_&&t(H,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!_&&x!==null&&x.length===0&&t(H,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),x!==null&&x.length>0&&t(L,{className:"overflow-hidden py-0",children:t(j,{className:"px-0",children:o(q,{"data-testid":"workflow-instances-table",children:[t(U,{children:o(N,{children:[t(i,{children:a("Instance id")}),t(i,{children:a("Status")}),t(i,{children:a("Created")}),t(i,{children:a("Ended")}),t(i,{"aria-label":a("Actions")})]})}),t(z,{children:x.map(e=>o(N,{"data-testid":`workflow-instance-${e.id}`,children:[t(d,{className:"font-mono text-xs",children:e.id}),t(d,{className:"font-mono text-xs",children:e.status}),t(d,{className:"text-muted-foreground tabular-nums",children:e.createdOn??"—"}),t(d,{className:"text-muted-foreground tabular-nums",children:e.endedOn??"—"}),t(d,{className:"text-right",children:o("div",{className:"flex justify-end gap-1.5",children:[t(T,{"data-testid":`workflow-instance-steps-${e.id}`,onClick:()=>{E(J(e.id))},size:"sm",type:"button",variant:"outline",children:a("Steps")}),O!==void 0&&ie.map(s=>t(T,{"data-testid":`workflow-instance-${s}-${e.id}`,disabled:$===e.id,onClick:()=>{E(K(e.id,s))},size:"sm",type:"button",variant:"ghost",children:a(s)},s))]})})]},e.id))})]})})}),k!==null&&t(L,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:o(j,{className:"flex flex-col gap-2 px-4 py-3",children:[o("div",{className:"flex items-center justify-between",children:[o("span",{className:"font-mono text-xs",children:[a("Steps")," · ",k.id]}),t(T,{"data-testid":"workflow-instance-detail-close",onClick:B,size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),k.steps.length===0?t("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):o(q,{"data-testid":"workflow-instance-steps",children:[t(U,{children:o(N,{children:[t(i,{children:a("Step")}),t(i,{children:a("Type")}),t(i,{children:a("Attempts")}),t(i,{children:a("Started")}),t(i,{children:a("Output")})]})}),t(z,{children:k.steps.map((e,s)=>o(N,{"data-testid":`workflow-step-${String(s)}`,children:[t(d,{className:"font-mono text-xs",children:e.name}),t(d,{className:"text-xs text-muted-foreground",children:e.type??"—"}),t(d,{className:"tabular-nums",children:e.attempts??"—"}),t(d,{className:"text-muted-foreground tabular-nums",children:e.start??"—"}),t(d,{className:"font-mono text-xs text-muted-foreground",children:ue(e)})]},`${e.name}:${String(s)}`))})]})]})})]})},fe=re(M.createWorkflowInstance),he=re(M.getWorkflowInstanceStatus),pe=l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"—";try{return JSON.stringify(l.output,te)}catch{return"(unserializable)"}},xe=(l,r)=>l.some(w=>w.exportName===r)?r:l[0]?.exportName??"",We=()=>{const l=Z(),r=ee(),{data:w,error:A}=oe(M.listWorkflows,{}),[g,C]=c(""),[a,x]=c(""),[v,k]=c(""),[I,b]=c(!1),[R,y]=c(null),[h,_]=c([]),[S,$]=c(null),F=w!==void 0,m=Array.isArray(w?.workflows)?[...w.workflows].toSorted((e,s)=>e.exportName.localeCompare(s.exportName)):[],f=xe(m,g),p=m.find(e=>e.exportName===f),D=e=>{_(s=>{const n=s.filter(u=>!(u.exportName===e.exportName&&u.id===e.id));return[e,...n]})},Q=async()=>{const e=f;if(e==="")return;let s;const n=v.trim();if(n!=="")try{s=JSON.parse(n)}catch{y(r("Params must be valid JSON"));return}b(!0),y(null);try{const u=a.trim(),X=await l.query(fe,{exportName:e,id:u===""?void 0:u,params:s},Y(""));D({exportName:e,id:X.id,status:X.status}),x("")}catch(u){y(W(u))}b(!1)},V=()=>{E(Q())},O=async(e,s)=>{$(s);try{const n=await l.query(he,{exportName:e,id:s},Y(""));D({error:n.error,exportName:e,id:n.id,output:n.output,status:n.status})}catch(n){y(W(n))}$(null)},P=e=>{C(e.target.value)},J=e=>{x(e.target.value)},B=e=>{k(e.target.value)},K=e=>{const{export:s,id:n}=e.currentTarget.dataset;s!==void 0&&n!==void 0&&E(O(s,n))};return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[A!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:A}),t("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.")}),F&&m.length===0?t(H,{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")}):t(L,{className:"overflow-hidden py-0",children:t(j,{className:"px-0",children:o(q,{"data-testid":"workflows-table",children:[t(U,{children:o(N,{children:[t(i,{children:r("Export")}),t(i,{children:r("Name")}),t(i,{children:r("Class")}),t(i,{children:r("Binding")})]})}),t(z,{children:m.map(e=>o(N,{"data-testid":`workflows-row-${e.exportName}`,children:[t(d,{className:"font-mono text-xs",children:e.exportName}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.name}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.className}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.binding})]},e.exportName))})]})})}),m.length>0&&o("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[t("h3",{className:"text-sm font-medium",children:r("Start instance")}),R!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:R}),o("div",{className:"flex flex-wrap items-center gap-2",children:[t("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:f,children:m.map(e=>t("option",{value:e.exportName,children:e.exportName},e.exportName))}),t(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:J,placeholder:r("Instance id (optional)"),value:a}),t(T,{"data-testid":"workflows-start-button",disabled:I||f==="",onClick:V,children:r(I?"Starting…":"Start instance")})]}),t(ne,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:B,placeholder:r("Params (JSON, optional)"),value:v})]}),h.length>0&&o("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[t("h3",{className:"text-sm font-medium",children:r("Instances")}),t(L,{className:"overflow-hidden py-0",children:t(j,{className:"px-0",children:o(q,{"data-testid":"workflows-instances-table",children:[t(U,{children:o(N,{children:[t(i,{children:r("Workflow")}),t(i,{children:r("Instance id")}),t(i,{children:r("Status")}),t(i,{children:r("Output")}),t(i,{})]})}),t(z,{children:h.map(e=>o(N,{"data-testid":`workflows-instance-${e.id}`,children:[t(d,{className:"font-mono text-xs",children:e.exportName}),t(d,{className:"font-mono text-xs text-muted-foreground",children:e.id}),t(d,{className:"font-mono text-xs",children:e.status}),t(d,{className:"font-mono text-xs text-muted-foreground",children:pe(e)}),t(d,{children:t(T,{"data-export":e.exportName,"data-id":e.id,"data-testid":`workflows-instance-refresh-${e.id}`,disabled:S===e.id,onClick:K,size:"xs",variant:"outline",children:S===e.id?r("Refreshing…"):r("Refresh")})})]},`${e.exportName}:${e.id}`))})]})})})]}),p!==void 0&&t(me,{workflowName:p.name})]})};export{We as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as B}from"react/compiler-runtime";import{useLunora as mt}from"@lunora/react";import{useState as P,useEffect as Be,useMemo as Rt,useRef as We,useCallback as ut}from"react";import{ShardInput as Bn}from"./ShardInput-C6mjgAh4.mjs";import{u as Ze}from"./use-admin-query-tlBof8Yg.mjs";import{m as jn,c as Zt,d as Nt,a as zn,u as it,b as qn,T as Kn,D as Gn}from"./table-list-sidebar-CYRSPLIv.mjs";import{ADMIN_FUNCTIONS as he}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as en}from"./browser-storage-BH1MxLZs.mjs";import{f as Ne,k as Fe,j as tn,b as Vt,c as Ee,d as Te,n as Jn,h as Wn}from"./internal-Df43vQI0.mjs";import{u as Hn}from"./use-sql-assistant-pjfGp-Ol.mjs";import{d as Pt,i as nn,e as on,a as Un}from"./wire-codec-Bk4XZGE4.mjs";import{B as St}from"./button-q0UYSmrn.mjs";import{I as Qn}from"./input-CXhxesPC.mjs";import{L as Bt}from"./label-DKFzyHq6.mjs";import{M as gt}from"./modal-shell-CDztwLnv.mjs";import{useT as xe}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as d,jsxs as E,Fragment as et}from"react/jsx-runtime";import{ConfirmButton as jt}from"./ConfirmButton-DU4p72Er.mjs";import{E as Yn}from"./empty-state-D7jEML_T.mjs";import{C as $t,a as De}from"./control-button-BOZ5K-FC.mjs";import{tableFeatures as Xn,sortFn_text as Zn,sortFn_datetime as eo,sortFn_basic as to,sortFn_alphanumeric as no,rowSortingFeature as oo,rowSelectionFeature as so,columnVisibilityFeature as lo,columnSizingFeature as ro,columnResizingFeature as ao,columnOrderingFeature as io,createSortedRowModel as co,useTable as uo,flexRender as fo}from"@tanstack/react-table";import{useVirtualizer as mo}from"@tanstack/react-virtual";import{C as At}from"./checkbox-CnS9cyCz.mjs";import{c as ft}from"./utils-bhneXptQ.mjs";import{f as go}from"./virtual-rect-D_j7aLxX.mjs";import{C as kt,G as po,T as bo}from"./data-grid-DIiNmDR9.mjs";import{DataFilters as ho,toFilterClauses as Ie}from"./DataFilters-CYZFt2EK.mjs";import{G as xo,C as vo}from"./grid-features-OVIMIQan.mjs";import{G as wo}from"./grid-pagination-DgzyzfBh.mjs";import zt from"./useDebounced-DVeQ5-oW.mjs";import{r as yo,l as Co}from"./shard-history-CaO3C4KQ.mjs";const No=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,onDelete:o.onDelete,references:o.ref,table:e}))}))}),So=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},ko=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},qt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},It=s=>`${s.table}.${s.column}`,To=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=xe(),[f,m]=P(n[0]??""),[p,b]=P("");let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=de=>{m(de.target.value)},e[0]=u):u=e[0];const g=u;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=de=>{b(de.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const y=v==="";let N,C;if(e[4]!==y||e[5]!==i||e[6]!==p){if(!y)try{C=Pt(JSON.parse(p))}catch(de){N=i("Invalid JSON: {message}",{message:de.message})}e[4]=y,e[5]=i,e[6]=p,e[7]=N,e[8]=C}else N=e[7],C=e[8];let k;e[9]!==f||e[10]!==r||e[11]!==a?(k=a.has(f)&&r>1,e[9]=f,e[10]=r,e[11]=a,e[12]=k):k=e[12];const S=k,w=f!==""&&!y&&N===void 0&&!S;let T;e[13]!==w||e[14]!==f||e[15]!==o||e[16]!==t||e[17]!==C?(T=()=>{w&&(o({[f]:C}),t())},e[13]=w,e[14]=f,e[15]=o,e[16]=t,e[17]=C,e[18]=T):T=e[18];const O=T;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let $;e[23]!==_?($=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=$):$=e[24];let F;e[25]!==i||e[26]!==l||e[27]!==r?(F=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=F):F=e[28];let L;e[29]!==F?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:F}),e[29]=F,e[30]=L):L=e[30];let D;e[31]!==c||e[32]!==i?(D=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=D):D=e[33];let V;e[34]!==D?(V=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:D}),e[34]=D,e[35]=V):V=e[35];let G;e[36]!==L||e[37]!==V||e[38]!==$?(G=E("div",{className:"flex flex-col gap-0.5",children:[$,L,V]}),e[36]=L,e[37]=V,e[38]=$,e[39]=G):G=e[39];let q;e[40]!==i?(q=i("Close"),e[40]=i,e[41]=q):q=e[41];let I;e[42]!==t||e[43]!==q?(I=d(St,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:q}),e[42]=t,e[43]=q,e[44]=I):I=e[44];let J;e[45]!==G||e[46]!==I?(J=E("div",{className:"flex items-start justify-between",children:[G,I]}),e[45]=G,e[46]=I,e[47]=J):J=e[47];let K;e[48]!==i?(K=i("Column"),e[48]=i,e[49]=K):K=e[49];let H;e[50]!==K?(H=d(Bt,{htmlFor:"bulk-patch-column",children:K}),e[50]=K,e[51]=H):H=e[51];let Y;e[52]!==i?(Y=i("Column"),e[52]=i,e[53]=Y):Y=e[53];let U;e[54]!==n?(U=n.map(Eo),e[54]=n,e[55]=U):U=e[55];let Z;e[56]!==f||e[57]!==Y||e[58]!==U?(Z=d("select",{"aria-label":Y,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:f,children:U}),e[56]=f,e[57]=Y,e[58]=U,e[59]=Z):Z=e[59];let se;e[60]!==i?(se=i("Value"),e[60]=i,e[61]=se):se=e[61];let re;e[62]!==se?(re=d(Bt,{htmlFor:"bulk-patch-value",children:se}),e[62]=se,e[63]=re):re=e[63];let ge;e[64]!==p?(ge=d(Qn,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=ge):ge=e[65];let fe;e[66]!==H||e[67]!==Z||e[68]!==re||e[69]!==ge?(fe=E("div",{className:"flex items-center gap-2",children:[H,Z,re,ge]}),e[66]=H,e[67]=Z,e[68]=re,e[69]=ge,e[70]=fe):fe=e[70];let me;e[71]!==N?(me=N!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:N}),e[71]=N,e[72]=me):me=e[72];let pe;e[73]!==f||e[74]!==i||e[75]!==r||e[76]!==S?(pe=S&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:f,total:r.toString()})}),e[73]=f,e[74]=i,e[75]=r,e[76]=S,e[77]=pe):pe=e[77];let ae;e[78]!==y||e[79]!==i||e[80]!==S?(ae=y&&!S&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=y,e[79]=i,e[80]=S,e[81]=ae):ae=e[81];let Q;e[82]!==w||e[83]!==f||e[84]!==p?(Q=w&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${f} = ${p.trim()}`}),e[82]=w,e[83]=f,e[84]=p,e[85]=Q):Q=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let ie;e[88]!==t||e[89]!==be?(ie=d(St,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=ie):ie=e[90];const ye=!w;let ne;e[91]!==i||e[92]!==r?(ne=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=ne):ne=e[93];let ce;e[94]!==O||e[95]!==ye||e[96]!==ne?(ce=d(St,{"data-testid":"bulk-patch-apply",disabled:ye,onClick:O,size:"xs",children:ne}),e[94]=O,e[95]=ye,e[96]=ne,e[97]=ce):ce=e[97];let W;e[98]!==ie||e[99]!==ce?(W=E("div",{className:"flex justify-end gap-2",children:[ie,ce]}),e[98]=ie,e[99]=ce,e[100]=W):W=e[100];let j;return e[101]!==t||e[102]!==J||e[103]!==fe||e[104]!==me||e[105]!==pe||e[106]!==ae||e[107]!==Q||e[108]!==W||e[109]!==R?(j=E(gt,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,fe,me,pe,ae,Q,W]}),e[101]=t,e[102]=J,e[103]=fe,e[104]=me,e[105]=pe,e[106]=ae,e[107]=Q,e[108]=W,e[109]=R,e[110]=j):j=e[110],j};function Eo(s){return d("option",{value:s,children:s},s)}const Kt=6,ct=100,_o=s=>({paddingLeft:s*16}),Ro=s=>{const e=B(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},$o=s=>{const e=B(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},Do=s=>{const e=B(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},Po=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d($o,{table:s.table}):s.isRestrict?d(Ro,{table:s.table}):d(Do,{table:s.table}),sn=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=_o(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let f;e[11]!==i?(f=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=f):f=e[12];let m;e[13]!==o?(m=Po(o),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==f||e[24]!==m||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,f,m,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=f,e[24]=m,e[25]=p,e[26]=b):b=e[26];let u;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(sn,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],u=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=u}else u=e[29];let g;return e[32]!==b||e[33]!==u?(g=E(et,{children:[b,u]}),e[32]=b,e[33]=u,e[34]=g):g=e[34],g},Ao=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},Io=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>Ao(a)||[]).slice(0,ct),l=t.total??0;return{capNote:l>ct?`showing first ${ct.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},ln=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await Io(s,n.field,e,l),f=n?.onDelete==="restrict",m=[],p=`${s}:${e}`,b=c>=Kt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await ln(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&m.push(v)}t.delete(p)}let u=r;if(b){const g=`depth capped at ${Kt.toString()}`;u=r===void 0?g:`${r}; ${g}`}return{capNote:u,children:m,isRestrict:f,relation:n,rowCount:a,rowIds:i,table:s}},Fo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=xe(),[r,a]=P(!0),[i,f]=P(null),[m,p]=P(null);Be(()=>{let g=!1;return Ne((async()=>{try{a(!0),p(null);const x=So(t);if(!((x.get(c)??[]).length>0)){g||(f({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const y=await ln(c,o,void 0,x,new Set,0,n);g||(f(y),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&ko(i,g=>g.isRestrict).length>0,u=()=>{e(),s()};return E(gt,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),m!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(sn,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:u,type:"button",children:l("Delete")})]})]})},Oo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(m=>m.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,f=0;for(const m of s){const p=m.getSize(),b=e.has(m.id),u=a+p>c&&a<l;b||u?r.add(m.id):a<c?i+=p:f+=p,a+=p}return{ids:r,leadPx:i,tailPx:f}},Mo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},Lo=Xn({columnOrderingFeature:io,columnResizingFeature:ao,columnSizingFeature:ro,columnVisibilityFeature:lo,rowSelectionFeature:so,rowSortingFeature:oo,sortedRowModel:co(),sortFns:{alphanumeric:no,basic:to,datetime:eo,text:Zn}}),Vo=()=>{const s=B(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=P(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const y=Object.fromEntries(Object.entries(v).filter(N=>{const[C,k]=N;return!(C in h)||!Object.is(k,h[C])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(x).filter(N=>{const[C]=N;return C!==g})):{...x,[g]:y}})},s[3]=a):a=s[3];const i=a;let f;s[4]!==n?(f=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=f):f=s[5];const m=f;let p;s[6]!==n?(p=Object.values(n).reduce(jo,0),s[6]=n,s[7]=p):p=s[7];const b=p;let u;return s[8]!==b||s[9]!==n||s[10]!==m?(u={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:m},s[8]=b,s[9]=n,s[10]=m,s[11]=u):u=s[11],u},rn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Bo=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=xe();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let f;e[8]!==o||e[9]!==t||e[10]!==i?(f=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=f):f=e[11];let m;e[12]!==l?(m=l("Discard"),e[12]=l,e[13]=m):m=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==m?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:m}),e[14]=o,e[15]=c,e[16]=m,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==f||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,f,p]}),e[18]=a,e[19]=f,e[20]=p,e[21]=b):b=e[21];let u;e[22]!==n?(u=n.map(zo),e[22]=n,e[23]=u):u=e[23];let g;e[24]!==u?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:u}),e[24]=u,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function jo(s,e){return s+Object.keys(e).length}function zo(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:Fe(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:Fe(s.newValue)})]},`${s.rowId}:${s.column}`)}const Gt=400,qo=36,Ko={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Go={width:"100%"},Jo=/\n$/u,Wo={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Ho={display:"flex",width:"100%"},Jt={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},Uo="2.5rem",an={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},Ft=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),cn=(s,e)=>({...Ft(s),left:`calc(${Uo} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Tt="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",Qo=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,Dt="__back__:",Yo=s=>`${Dt}${s.table}.${s.column}`,Xo=s=>{const e=B(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Pe=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},Zo=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},es=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return Zo(s,n);const o=rn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},ts=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
|
|
2
|
+
`,`
|
|
3
|
+
`).replace(Jo,"").split(`
|
|
4
|
+
`),r=[];let a=0;for(const[i,f]of l.entries()){const m=t[s.row+i],p=m===void 0?null:Pe(m),b=f.split(" ");if(m===void 0||p===null){a+=b.length;continue}for(const[u,g]of b.entries()){const h=e[s.col+u],x=h===void 0||!o(h)?void 0:es(g,m[h],n?.[h]);h===void 0||x===void 0?a+=1:r.push({column:h,rowId:p,value:x.value})}}return{edits:r,skipped:a}},dn=(s,e)=>Pe(s)??`row-${e.toString()}`,ns=8,os=s=>{const e=B(17),{anchor:n,mask:o,state:t}=s,c=xe();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let a;if(t==="loading"){let f;e[3]!==c?(f=c("Loading…"),e[3]=c,e[4]=f):f=e[4];let m;e[5]!==f?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:f}),e[5]=f,e[6]=m):m=e[6],a=m}else if(t.row===null){let f;e[7]!==c?(f=c("No matching row."),e[7]=c,e[8]=f):f=e[8];let m;e[9]!==f?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:f}),e[9]=f,e[10]=m):m=e[10],a=m}else{let f;if(e[11]!==o||e[12]!==t.row){const m=Object.entries(Zt(t.row,o)).slice(0,ns);f=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:m.map(ps)}),e[11]=o,e[12]=t.row,e[13]=f}else f=e[13];a=f}let i;return e[14]!==a||e[15]!==r?(i=d("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:a}),e[14]=a,e[15]=r,e[16]=i):i=e[16],i},ss=s=>{const e=B(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[a,i]=P(null),[f,m]=P("idle");let p;e[0]!==o||e[1]!==c||e[2]!==r?(p=()=>{c(r,o)},e[0]=o,e[1]=c,e[2]=r,e[3]=p):p=e[3];const b=p;let u;e[4]!==o||e[5]!==l||e[6]!==f||e[7]!==r?(u=S=>{const w=S.currentTarget.getBoundingClientRect();if(i({left:w.left,top:w.bottom+4}),f!=="idle")return;m("loading"),Ne((async()=>{try{m({row:await l(r,o)})}catch{m({row:null})}})())},e[4]=o,e[5]=l,e[6]=f,e[7]=r,e[8]=u):u=e[8];const g=u;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{i(null)},e[9]=h):h=e[9];const x=h,v=`db-ref-${n}`,y=`Open ${r} ${o}`;let N;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==y?(N=E("button",{"data-testid":v,onBlur:x,onClick:b,onFocus:g,onMouseEnter:g,onMouseLeave:x,title:y,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=b,e[12]=g,e[13]=v,e[14]=y,e[15]=N):N=e[15];let C;e[16]!==a||e[17]!==t||e[18]!==f||e[19]!==r?(C=a!==null&&f!=="idle"&&d(os,{anchor:a,mask:t(r,f==="loading"||f.row===null?[]:Object.keys(f.row)),state:f}),e[16]=a,e[17]=t,e[18]=f,e[19]=r,e[20]=C):C=e[20];let k;return e[21]!==N||e[22]!==C?(k=E(et,{children:[N,C]}),e[21]=N,e[22]=C,e[23]=k):k=e[23],k},ls=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",rs="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=s=>{const e=B(8),{column:n,onExpand:o,value:t}=s;let c;e[0]!==n||e[1]!==o||e[2]!==t?(c=()=>{o(n,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=c):c=e[3];const l=c,r=`db-expand-${n}`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=d("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:d("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[4]=a):a=e[4];let i;return e[5]!==l||e[6]!==r?(i=d("button",{"aria-label":"Expand cell",className:rs,"data-testid":r,onClick:l,type:"button",children:a}),e[5]=l,e[6]=r,e[7]=i):i=e[7],i},as=s=>{const e=B(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=We(null);let a,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{r.current?.select()},i=[],e[0]=a,e[1]=i):(a=e[0],i=e[1]),Be(a,i);let f;e[2]!==t||e[3]!==c?(f=x=>{x.key==="Enter"?(x.preventDefault(),c(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=f):f=e[4];const m=f;let p;e[5]!==c?(p=x=>{c(x.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,u=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=Fe(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==m||e[12]!==u||e[13]!==g?(h=d("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":u,defaultValue:g,onBlur:b,onKeyDown:m,ref:r}),e[9]=n,e[10]=b,e[11]=m,e[12]=u,e[13]=g,e[14]=h):h=e[14],h},is=s=>{const e=B(70),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let a,i,f,m;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==c||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){m=Symbol.for("react.early_return_sentinel");e:{i=n.getValue(),a=Pe(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,$=d(kt,{value:jn(i,r,c)});let F;e[12]!==_||e[13]!==$?(F=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:$}),e[12]=_,e[13]=$,e[14]=F):F=e[14],m=F;break e}if(R!==void 0&&(typeof i=="string"||typeof i=="number")&&String(i)!==""){const _=String(i),$=`${R}:${String(i)}`;let F;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==$||e[21]!==R?(F=d(ss,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:R},$),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=$,e[21]=R,e[22]=F):F=e[22],m=F;break e}if(a===null){let _;e[23]!==i?(_=d(kt,{value:i}),e[23]=i,e[24]=_):_=e[24];let $;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==i?($=d(Wt,{column:r,onExpand:o.onExpandCell,value:i}),e[25]=r,e[26]=o.onExpandCell,e[27]=i,e[28]=$):$=e[28];let F;e[29]!==_||e[30]!==$?(F=E(et,{children:[_,$]}),e[29]=_,e[30]=$,e[31]=F):F=e[31],m=F;break e}f=o.stagedValue(a,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=a,e[9]=i,e[10]=f,e[11]=m}else a=e[8],i=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=f,b=p===void 0?i:p.value;let u;e[32]!==r||e[33]!==o?(u=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=u):u=e[34];const g=u;if(o.editingCell!==null&&o.editingCell.rowId===a&&o.editingCell.column===r){let R;e[35]!==r||e[36]!==o||e[37]!==a||e[38]!==i?(R=$=>{o.stage(a,r,rn($,i)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=a,e[38]=i,e[39]=R):R=e[39];let _;return e[40]!==r||e[41]!==b||e[42]!==o.cancelEdit||e[43]!==a||e[44]!==R?(_=d(as,{column:r,initial:b,onCancel:o.cancelEdit,onCommit:R,recordId:a}),e[40]=r,e[41]=b,e[42]=o.cancelEdit,e[43]=a,e[44]=R,e[45]=_):_=e[45],_}let x;p!==void 0?x="rounded bg-warning/15 px-1":g&&(x="cursor-text");let v;e[46]!==g||e[47]!==r||e[48]!==o||e[49]!==a?(v=g?()=>{o.startEdit(a,r)}:void 0,e[46]=g,e[47]=r,e[48]=o,e[49]=a,e[50]=v):v=e[50];const y=v,N=x,C=`db-cell-${a}-${r}`;let k;e[51]!==r||e[52]!==t||e[53]!==c?(k=Qo(t,c,r),e[51]=r,e[52]=t,e[53]=c,e[54]=k):k=e[54];let S;e[55]!==b||e[56]!==k?(S=d(kt,{highlight:k,value:b}),e[55]=b,e[56]=k,e[57]=S):S=e[57];let w;e[58]!==x||e[59]!==y||e[60]!==C||e[61]!==S?(w=d("span",{className:N,"data-testid":C,onDoubleClick:y,children:S}),e[58]=x,e[59]=y,e[60]=C,e[61]=S,e[62]=w):w=e[62];let T;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell?(T=d(Wt,{column:r,onExpand:o.onExpandCell,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=T):T=e[66];let O;return e[67]!==T||e[68]!==w?(O=E(et,{children:[w,T]}),e[67]=T,e[68]=w,e[69]=O):O=e[69],O},cs=s=>{s.preventDefault()},Ht={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},ds=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:c,table:l})=>{const r=()=>{e.current=n.column.id},a=()=>{const i=e.current,f=n.column.id;if(e.current=null,i===null||i===f)return;const m=l.atoms.columnOrder.get(),b=(m.length>0?m:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==i),u=b.indexOf(f);b.splice(u===-1?b.length:u,0,i),l.setColumnOrder(b)};return E("th",{className:ft("group/head text-start text-xs font-medium text-muted-foreground",c!==void 0&&"border-e border-border bg-muted"),"data-testid":`db-head-${n.column.id}`,draggable:!0,onDragOver:cs,onDragStart:r,onDrop:a,style:c===void 0?Ft(n.getSize()):cn(n.getSize(),c),children:[E("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[fo(n.column.columnDef.header,n.getContext()),ls(n.column.getIsSorted())]}),s!==void 0&&Ht[s]!==void 0&&d("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:Ht[s]}),o&&d("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),d("button",{"aria-label":c===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":c!==void 0,className:ft("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",c===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),d("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},us=s=>{const e=B(13),{table:n}=s,o=xe();let t;e[0]!==n?(t=f=>{n.toggleAllRowsSelected(f)},e[0]=n,e[1]=t):t=e[1];const c=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let a;e[6]!==n?(a=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=a):a=e[7];let i;return e[8]!==c||e[9]!==l||e[10]!==r||e[11]!==a?(i=d("th",{className:"bg-muted",style:an,children:d(At,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:a,onCheckedChange:c})}),e[8]=c,e[9]=l,e[10]=r,e[11]=a,e[12]=i):i=e[12],i},fs=s=>{const e=B(17),{row:n}=s,o=xe();let t;e[0]!==n.original?(t=Pe(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=u=>{n.toggleSelected(u)},e[2]=n,e[3]=l):l=e[3];const r=l;let a;e[4]!==o?(a=o("Select row"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==n?(i=n.getIsSelected(),e[6]=n,e[7]=i):i=e[7];let f;e[8]!==n.index||e[9]!==n.original?(f=dn(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=f):f=e[10];const m=`db-select-${f}`,p=c===null;let b;return e[11]!==r||e[12]!==a||e[13]!==i||e[14]!==m||e[15]!==p?(b=d("td",{className:"bg-background",style:an,children:d(At,{"aria-label":a,checked:i,"data-testid":m,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=i,e[14]=m,e[15]=p,e[16]=b):b=e[16],b},ms=s=>{const e=B(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:a,highlight:i,backRelationCounts:f,onTogglePin:m,pinnedColumns:p,refs:b,tableModel:u}=s,g=xe(),{attachScroll:h,scrollLeft:x,scrollToIndex:v,table:y,tableRows:N,tbodyStyle:C,viewportWidth:k,virtualRows:S}=u,w=We(null),[T,O]=P(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,$]=P(R);let F;e[1]!==y?(F=y.getVisibleLeafColumns(),e[1]=y,e[2]=F):F=e[2];const L=F.length;let D;e[3]!==T||e[4]!==L||e[5]!==o||e[6]!==y||e[7]!==N?(D=de=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(de.key))return;de.preventDefault();const X=T??{col:0,row:0};if(de.key==="Enter"){const ve=N[X.row],we=y.getVisibleLeafColumns()[X.col];if(ve!==void 0&&we!==void 0){const ee=Pe(ve.original);ee!==null&&o.editableColumn(we.id)&&o.startEdit(ee,we.id)}O(X);return}let{col:le,row:ue}=X;e:switch(de.key){case"ArrowDown":{ue=Math.min(ue+1,N.length-1);break e}case"ArrowRight":{le=Math.min(le+1,L-1);break e}case"ArrowUp":{ue=Math.max(ue-1,0);break e}default:le=Math.max(le-1,0)}O({col:le,row:ue})},e[3]=T,e[4]=L,e[5]=o,e[6]=y,e[7]=N,e[8]=D):D=e[8];const V=D;let G;e[9]!==T||e[10]!==n||e[11]!==o||e[12]!==y||e[13]!==N?(G=de=>{const X=o.editable?de.clipboardData.getData("text/plain"):"";if(X==="")return;de.preventDefault();const le=y.getVisibleLeafColumns().map(bs),ue=ts({anchor:T??{col:0,row:0},columnIds:le,columnMeta:n,editableColumn:o.editableColumn,rows:N.map(hs),text:X});for(const ve of ue.edits)o.stage(ve.rowId,ve.column,ve.value);$({columns:le.join("\0"),count:ue.skipped})},e[9]=T,e[10]=n,e[11]=o,e[12]=y,e[13]=N,e[14]=G):G=e[14];const q=G;let I,J;e[15]!==T||e[16]!==v?(I=()=>{T!==null&&v(T.row)},J=[T,v],e[15]=T,e[16]=v,e[17]=I,e[18]=J):(I=e[17],J=e[18]),Be(I,J);let K,H,Y,U,Z,se,re,ge,fe,me,pe,ae,Q,be,ie,ye;if(e[19]!==T||e[20]!==h||e[21]!==f||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==i||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==V||e[30]!==q||e[31]!==a||e[32]!==m||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==x||e[38]!==g||e[39]!==y||e[40]!==N||e[41]!==C||e[42]!==k||e[43]!==S){const de=y.getVisibleLeafColumns().map(xs),X=Oo(de,p,x,k),le=Mo(y.getVisibleLeafColumns().map(vs),p),ue=ee=>{const Re=N[ee.index],{original:Ce}=Re,oe=Pe(Ce),Oe=dn(Ce,ee.index),qe={...Wo,height:`${ee.size.toString()}px`,transform:`translateY(${ee.start.toString()}px)`};return E("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:qe,children:[d(fs,{row:Re}),X.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),Re.getVisibleCells().map((Se,Ke)=>{if(!X.ids.has(Se.column.id))return null;const je=le.get(Se.column.id),Ue=T!==null&&T.row===ee.index&&T.col===Ke?" ring-1 ring-ring ring-inset":"";return d("td",{className:ft("group/cell truncate font-mono text-muted-foreground",je!==void 0&&"border-e border-border bg-background",Ue),onPointerDown:()=>{O({col:Ke,row:ee.index})},style:je===void 0?Ft(Se.column.getSize()):cn(Se.column.getSize(),je),children:Se.column.id.startsWith(Dt)?d(Xo,{counts:f[Se.column.id.slice(Dt.length)],rowId:Oe}):d(is,{cell:Se,edit:o,highlight:i,mask:c,refs:b})},Se.id)}),X.tailPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),E("td",{className:"flex items-center gap-1",style:Jt,children:[d("button",{className:Tt,"data-testid":`db-inspect-${Oe}`,onClick:()=>{a(Ce)},type:"button",children:"Details"}),t&&E(et,{children:[d("button",{className:Tt,"data-testid":`db-edit-${Oe}`,disabled:oe===null,onClick:()=>{r(oe,Ce)},type:"button",children:"Edit"}),d("button",{className:Tt,"data-testid":`db-delete-${Oe}`,disabled:oe===null,onClick:()=>{l(oe)},type:"button",children:"Delete"})]})]})]},Re.id)};K=po,ae="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==y?(Q=_.count>0&&_.columns===y.getVisibleLeafColumns().map(ws).join("\0")&&d("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:g("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=g,e[63]=y,e[64]=Q):Q=e[64],Z="db-scroll",se=V,re=q,ge=h,fe="grid",me=Ko,pe=0,ye="w-full text-xs",H="db-rows",Y=Go;let ve;e[65]!==y?(ve=d(us,{table:y}),e[65]=y,e[66]=ve):ve=e[66];let we;e[67]===Symbol.for("react.memo_cache_sentinel")?(we=d("th",{"aria-label":"Row actions",style:Jt}),e[67]=we):we=e[67],U=d("thead",{className:"bg-muted/50",children:E("tr",{className:"border-b border-border",style:Ho,children:[ve,X.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.leadPx.toString()}px`}}),y.getFlatHeaders().map(ee=>X.ids.has(ee.column.id)?d(ds,{declaredType:n?.[ee.column.id]?.type,draggedRef:w,header:ee,masked:c.columns.has(ee.column.id),onTogglePin:m,pinnedOffset:le.get(ee.column.id),table:y},ee.id):null),X.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${X.tailPx.toString()}px`}}),we]})}),be=C,ie=S.map(ee=>ue(ee)),e[19]=T,e[20]=h,e[21]=f,e[22]=n,e[23]=o,e[24]=t,e[25]=i,e[26]=c,e[27]=l,e[28]=r,e[29]=V,e[30]=q,e[31]=a,e[32]=m,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=x,e[38]=g,e[39]=y,e[40]=N,e[41]=C,e[42]=k,e[43]=S,e[44]=K,e[45]=H,e[46]=Y,e[47]=U,e[48]=Z,e[49]=se,e[50]=re,e[51]=ge,e[52]=fe,e[53]=me,e[54]=pe,e[55]=ae,e[56]=Q,e[57]=be,e[58]=ie,e[59]=ye}else K=e[44],H=e[45],Y=e[46],U=e[47],Z=e[48],se=e[49],re=e[50],ge=e[51],fe=e[52],me=e[53],pe=e[54],ae=e[55],Q=e[56],be=e[57],ie=e[58],ye=e[59];let ne;e[68]!==be||e[69]!==ie?(ne=d("tbody",{style:be,children:ie}),e[68]=be,e[69]=ie,e[70]=ne):ne=e[70];let ce;e[71]!==H||e[72]!==Y||e[73]!==U||e[74]!==ne||e[75]!==ye?(ce=E("table",{className:ye,"data-testid":H,style:Y,children:[U,ne]}),e[71]=H,e[72]=Y,e[73]=U,e[74]=ne,e[75]=ye,e[76]=ce):ce=e[76];let W;e[77]!==Z||e[78]!==se||e[79]!==re||e[80]!==ge||e[81]!==fe||e[82]!==me||e[83]!==pe||e[84]!==ce?(W=d("div",{"data-testid":Z,onKeyDown:se,onPaste:re,ref:ge,role:fe,style:me,tabIndex:pe,children:ce}),e[77]=Z,e[78]=se,e[79]=re,e[80]=ge,e[81]=fe,e[82]=me,e[83]=pe,e[84]=ce,e[85]=W):W=e[85];let j;return e[86]!==K||e[87]!==ae||e[88]!==Q||e[89]!==W?(j=E(K,{layout:ae,children:[Q,W]}),e[86]=K,e[87]=ae,e[88]=Q,e[89]=W,e[90]=j):j=e[90],j},gs=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=Rt(()=>{if(t===void 0)return[];const w=t.map(T=>({accessorFn:O=>O[T],header:l?.[T]===void 0?T:`${T} →`,id:T}));for(const T of o)w.push({accessorFn:()=>{},enableSorting:!1,header:`← ${T.table}`,id:Yo(T)});return w},[o,t,l]),a=Rt(()=>c??[],[c]),[i,f]=P({}),[m,p]=P({}),b=uo({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:w=>Pe(w.original)!==null,features:Lo,getRowId:(w,T)=>Pe(w)??`row-${T.toString()}`,manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:f,onSortingChange:n,state:{columnVisibility:m,rowSelection:i,sorting:e}}),u=b.getRowModel().rows,g=We(null),h=mo({count:u.length,estimateSize:()=>qo,getScrollElement:()=>g.current,initialRect:{height:Gt,width:0},observeElementRect:(w,T)=>go(w,T,Gt),overscan:8}),x=ut(w=>{h.scrollToIndex(w)},[h]),[v,y]=P({left:0,width:0}),N=ut(w=>{if(g.current=w,w===null)return;const T=()=>{y(R=>R.left===w.scrollLeft&&R.width===w.clientWidth?R:{left:w.scrollLeft,width:w.clientWidth})};w.addEventListener("scroll",T,{passive:!0});const O=new ResizeObserver(T);return O.observe(w),()=>{w.removeEventListener("scroll",T),O.disconnect(),g.current=null}},[]),C=h.getVirtualItems(),S={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:N,scrollLeft:v.left,scrollToIndex:x,table:b,tableRows:u,tbodyStyle:S,viewportWidth:v.width,virtualRows:C}};function ps(s){const[e,n]=s;return E("div",{className:"contents",children:[d("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),d("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Fe(n),children:Fe(n)})]},e)}function bs(s){return s.id}function hs(s){return s.original}function xs(s){return{getSize:()=>s.getSize(),id:s.id}}function vs(s){return{getSize:()=>s.getSize(),id:s.id}}function ws(s){return s.id}const ys=s=>{const e=B(22),{onCommit:n}=s,o=xe(),[t,c]=P(""),l=We(null);let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},a=[],e[0]=r,e[1]=a):(r=e[0],a=e[1]),Be(r,a);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=y=>{c(y.target.value)},e[2]=i):i=e[2];const f=i;let m;e[3]!==t||e[4]!==n?(m=()=>{const y=t.trim();y!==""&&n(y)},e[3]=t,e[4]=n,e[5]=m):m=e[5];const p=m;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let u;e[8]!==o?(u=o("Query name"),e[8]=o,e[9]=u):u=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==u?(g=d("input",{"aria-label":b,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:f,placeholder:u,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=u,e[13]=g):g=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let x;e[16]!==p||e[17]!==h?(x=d("button",{className:$t,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=x):x=e[18];let v;return e[19]!==g||e[20]!==x?(v=E("span",{className:"inline-flex items-center gap-1",children:[g,x]}),e[19]=g,e[20]=x,e[21]=v):v=e[21],v},Cs=s=>{const e=B(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=xe(),[a,i]=P(!1);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{i(!0)},e[0]=f):f=e[0];const m=f;let p;e[1]!==c?(p=S=>{c(S),i(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let u;e[3]!==n||e[4]!==l?(u=S=>{const w=l[Number(S.currentTarget.dataset.index)];w!==void 0&&n(w)},e[3]=n,e[4]=l,e[5]=u):u=e[5];const g=u;let h;e[6]!==t||e[7]!==l?(h=S=>{const w=l[Number(S.currentTarget.dataset.index)];w!==void 0&&t(w.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const x=h;let v;e[9]!==r?(v=r("Copy link"),e[9]=r,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=d("button",{className:$t,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let N;e[14]!==b||e[15]!==a||e[16]!==r?(N=a?d(ys,{onCommit:b}):d("button",{className:$t,"data-testid":"db-save-query",onClick:m,type:"button",children:r("Save query")}),e[14]=b,e[15]=a,e[16]=r,e[17]=N):N=e[17];let C;e[18]!==g||e[19]!==x||e[20]!==l||e[21]!==r?(C=l.length>0&&E("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((S,w)=>E("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[d("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":w,"data-testid":`db-saved-query-${S.name}`,onClick:g,type:"button",children:S.name}),d("button",{"aria-label":r("Delete saved query {name}",{name:S.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":w,"data-testid":`db-saved-query-delete-${S.name}`,onClick:x,type:"button",children:"✕"})]},S.name))]}),e[18]=g,e[19]=x,e[20]=l,e[21]=r,e[22]=C):C=e[22];let k;return e[23]!==y||e[24]!==N||e[25]!==C?(k=E("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[y,N,C]}),e[23]=y,e[24]=N,e[25]=C,e[26]=k):k=e[26],k},He="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",un=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Ut=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?un.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",Ns=(s,e,n)=>n===void 0?Ut(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?un.test(s)?"date":"number":Ut(s,e),Ss=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},ks=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},Je="\0clear",Ts=s=>{const e=B(23),{column:n,nullable:o,onChange:t,value:c}=s,l=xe();let r;e[0]!==n||e[1]!==t?(r=v=>{t(n,v)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const a=r;let i;e[3]!==n||e[4]!==t?(i=v=>{t(n,v.target.value===Je?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=i):i=e[5];const f=i;if(!o&&c!==null){const v=c===!0,y=`db-field-${n}`;let N;return e[6]!==n||e[7]!==a||e[8]!==v||e[9]!==y?(N=d(At,{"aria-label":n,checked:v,"data-testid":y,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=v,e[9]=y,e[10]=N):N=e[10],N}const m=`db-field-${n}`,p=c===!0||c===!1?String(c):Je;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let u;e[13]!==b?(u=d("option",{value:Je,children:b}),e[13]=b,e[14]=u):u=e[14];let g,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=d("option",{value:"true",children:"true"}),h=d("option",{value:"false",children:"false"}),e[15]=g,e[16]=h):(g=e[15],h=e[16]);let x;return e[17]!==n||e[18]!==f||e[19]!==m||e[20]!==p||e[21]!==u?(x=E("select",{"aria-label":n,className:He,"data-testid":m,onChange:f,value:p,children:[u,g,h]}),e[17]=n,e[18]=f,e[19]=m,e[20]=p,e[21]=u,e[22]=x):x=e[22],x},Es=s=>{const e=B(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=xe(),a=typeof l=="string"?l:null;let i;e[0]!==c||e[1]!==a?(i=a!==null&&!c.includes(a),e[0]=c,e[1]=a,e[2]=i):i=e[2];const f=i;let m;e[3]!==n||e[4]!==t?(m=y=>{t(n,y.target.value===Je?null:y.target.value)},e[3]=n,e[4]=t,e[5]=m):m=e[5];const p=m,b=`db-field-${n}`,u=a??Je;let g;e[6]!==o||e[7]!==a||e[8]!==r?(g=(o||a===null)&&d("option",{value:Je,children:r("(none)")}),e[6]=o,e[7]=a,e[8]=r,e[9]=g):g=e[9];let h;e[10]!==a||e[11]!==f?(h=f&&d("option",{value:a,children:a}),e[10]=a,e[11]=f,e[12]=h):h=e[12];let x;e[13]!==c?(x=c.map(Is),e[13]=c,e[14]=x):x=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==u||e[19]!==g||e[20]!==h||e[21]!==x?(v=E("select",{"aria-label":n,className:He,"data-testid":b,onChange:p,value:u,children:[g,h,x]}),e[15]=n,e[16]=p,e[17]=b,e[18]=u,e[19]=g,e[20]=h,e[21]=x,e[22]=v):v=e[22],v},_s=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{const m=Number(f.target.value);f.target.value!==""&&!Number.isNaN(m)&&o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="number"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:He,"data-testid":r,onChange:l,type:"number",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Rs=s=>{const e=B(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{const m=new Date(f.target.value).getTime();Number.isNaN(m)||o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`;let a;e[3]!==t?(a=typeof t=="number"?ks(t):"",e[3]=t,e[4]=a):a=e[4];let i;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==a?(i=d("input",{"aria-label":n,className:He,"data-testid":r,onChange:l,type:"datetime-local",value:a}),e[5]=n,e[6]=l,e[7]=r,e[8]=a,e[9]=i):i=e[9],i},$s=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{o(n,f.target.value)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="string"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:He,"data-testid":r,onChange:l,type:"text",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},Ds=s=>{const e=B(20),{column:n,onChange:o,value:t}=s,c=xe();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=P(l),[i,f]=P(!1);let m;e[2]!==n||e[3]!==o?(m=y=>{const N=y.target.value;a(N);try{o(n,JSON.parse(N)),f(!1)}catch{f(!0)}},e[2]=n,e[3]=o,e[4]=m):m=e[4];const p=m,b=i&&"border-destructive";let u;e[5]!==b?(u=ft(He,"min-h-16",b),e[5]=b,e[6]=u):u=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==u||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:u,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=u,e[10]=g,e[11]=r,e[12]=h):h=e[12];let x;e[13]!==n||e[14]!==i||e[15]!==c?(x=i&&d("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:c("Invalid JSON")}),e[13]=n,e[14]=i,e[15]=c,e[16]=x):x=e[16];let v;return e[17]!==h||e[18]!==x?(v=E("div",{className:"flex flex-col gap-1",children:[h,x]}),e[17]=h,e[18]=x,e[19]=v):v=e[19],v},Ps=s=>{const e=B(56),{column:n,meta:o,onChange:t,target:c,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=Ns(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const a=r,i=`db-field-${n}`;let f;e[4]!==n?(f=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=f):f=e[5];let m;e[6]!==n||e[7]!==o?(m=o!==void 0&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==c?(p=c!==void 0&&E("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",c]}),e[9]=c,e[10]=p):p=e[10];let b;e[11]!==f||e[12]!==m||e[13]!==p?(b=E("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[f,m,p]}),e[11]=f,e[12]=m,e[13]=p,e[14]=b):b=e[14];let u;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(u=a==="boolean"&&d(Ts,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=a,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=u):u=e[20];let g;e[21]!==n||e[22]!==a||e[23]!==o||e[24]!==t||e[25]!==l?(g=a==="enum"&&o?.enumValues!==void 0&&d(Es,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=a,e[23]=o,e[24]=t,e[25]=l,e[26]=g):g=e[26];let h;e[27]!==n||e[28]!==a||e[29]!==t||e[30]!==l?(h=a==="number"&&d(_s,{column:n,onChange:t,value:l}),e[27]=n,e[28]=a,e[29]=t,e[30]=l,e[31]=h):h=e[31];let x;e[32]!==n||e[33]!==a||e[34]!==t||e[35]!==l?(x=a==="date"&&d(Rs,{column:n,onChange:t,value:l}),e[32]=n,e[33]=a,e[34]=t,e[35]=l,e[36]=x):x=e[36];let v;e[37]!==n||e[38]!==a||e[39]!==t||e[40]!==l?(v=a==="json"&&d(Ds,{column:n,onChange:t,value:l}),e[37]=n,e[38]=a,e[39]=t,e[40]=l,e[41]=v):v=e[41];let y;e[42]!==n||e[43]!==a||e[44]!==t||e[45]!==l?(y=a==="text"&&d($s,{column:n,onChange:t,value:l}),e[42]=n,e[43]=a,e[44]=t,e[45]=l,e[46]=y):y=e[46];let N;return e[47]!==x||e[48]!==v||e[49]!==y||e[50]!==i||e[51]!==b||e[52]!==u||e[53]!==g||e[54]!==h?(N=E("label",{className:"flex flex-col gap-1 text-xs",htmlFor:i,children:[b,u,g,h,x,v,y]}),e[47]=x,e[48]=v,e[49]=y,e[50]=i,e[51]=b,e[52]=u,e[53]=g,e[54]=h,e[55]=N):N=e[55],N},As=s=>{const e=B(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,a=xe();let i;e[0]!==o?(i=Ss(o),e[0]=o,e[1]=i):i=e[1];const f=i,[m,p]=P(!1),b=!m&&f!==null;let u;e[2]!==f||e[3]!==c?(u=(I,J)=>{c(JSON.stringify({...f,[I]:J},null,2))},e[2]=f,e[3]=c,e[4]=u):u=e[4];const g=u;let h;e[5]!==c?(h=I=>{c(I.target.value)},e[5]=c,e[6]=h):h=e[6];const x=h;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(!1)},e[7]=v):v=e[7];const y=v;let N;e[8]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{p(!0)},e[8]=N):N=e[8];const C=N,k=f===null;let S;e[9]!==a?(S=a("Form"),e[9]=a,e[10]=S):S=e[10];let w;e[11]!==b||e[12]!==k||e[13]!==S?(w=d("button",{"aria-pressed":b,className:De,"data-testid":"db-editor-form",disabled:k,onClick:y,type:"button",children:S}),e[11]=b,e[12]=k,e[13]=S,e[14]=w):w=e[14];const T=!b;let O;e[15]!==a?(O=a("JSON"),e[15]=a,e[16]=O):O=e[16];let R;e[17]!==O||e[18]!==T?(R=d("button",{"aria-pressed":T,className:De,"data-testid":"db-editor-json",onClick:C,type:"button",children:O}),e[17]=O,e[18]=T,e[19]=R):R=e[19];let _;e[20]!==R||e[21]!==w?(_=E("div",{className:"flex items-center gap-1.5",children:[w,R]}),e[20]=R,e[21]=w,e[22]=_):_=e[22];let $;e[23]!==n||e[24]!==o||e[25]!==f||e[26]!==g||e[27]!==x||e[28]!==r||e[29]!==b||e[30]!==a?($=b?d("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(f).map(I=>{const[J,K]=I;return d(Ps,{column:J,meta:n?.[J],onChange:g,target:r?.[J],value:K},J)})}):d("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:x,value:o}),e[23]=n,e[24]=o,e[25]=f,e[26]=g,e[27]=x,e[28]=r,e[29]=b,e[30]=a,e[31]=$):$=e[31];let F;e[32]!==a?(F=a("Save"),e[32]=a,e[33]=F):F=e[33];let L;e[34]!==l||e[35]!==F?(L=d("button",{className:De,"data-testid":"db-editor-save",onClick:l,type:"button",children:F}),e[34]=l,e[35]=F,e[36]=L):L=e[36];let D;e[37]!==a?(D=a("Cancel"),e[37]=a,e[38]=D):D=e[38];let V;e[39]!==t||e[40]!==D?(V=d("button",{className:De,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:D}),e[39]=t,e[40]=D,e[41]=V):V=e[41];let G;e[42]!==L||e[43]!==V?(G=E("div",{className:"flex items-center gap-1.5",children:[L,V]}),e[42]=L,e[43]=V,e[44]=G):G=e[44];let q;return e[45]!==_||e[46]!==$||e[47]!==G?(q=E("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,$,G]}),e[45]=_,e[46]=$,e[47]=G,e[48]=q):q=e[48],q};function Is(s){return d("option",{value:s,children:s},s)}const Fs=s=>{const e=B(71),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:a,maskOn:i,onAddRow:f,onBulkDelete:m,onBulkPatch:p,onAskAiFilter:b,onClearTable:u,onFilterChange:g,onFiltersChange:h,onGenerateRows:x,onShowJson:v,onShowTable:y,onToggleMask:N,total:C,totalKnown:k,viewMode:S}=s,w=xe(),T=S==="table";let O;e[0]!==y||e[1]!==T?(O=d("button",{"aria-pressed":T,className:De,"data-testid":"db-view-table",onClick:y,type:"button",children:"Table"}),e[0]=y,e[1]=T,e[2]=O):O=e[2];const R=S==="json";let _;e[3]!==v||e[4]!==R?(_=d("button",{"aria-pressed":R,className:De,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=R,e[5]=_):_=e[5];let $;e[6]!==a||e[7]!==w?($=a===void 0?w("Live — changes stream in automatically"):w("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=w,e[8]=$):$=e[8];const F=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let L;e[9]!==F?(L=d("span",{"aria-hidden":"true",className:F}),e[9]=F,e[10]=L):L=e[10];let D;e[11]!==a||e[12]!==w?(D=w(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=w,e[13]=D):D=e[13];let V;e[14]!==$||e[15]!==L||e[16]!==D?(V=E("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:$,children:[L,D]}),e[14]=$,e[15]=L,e[16]=D,e[17]=V):V=e[17];let G;e[18]!==l||e[19]!==i||e[20]!==N||e[21]!==w?(G=l&&d("button",{"aria-pressed":i,className:De,"data-testid":"db-mask-toggle",onClick:N,type:"button",children:w("Mask sensitive columns")}),e[18]=l,e[19]=i,e[20]=N,e[21]=w,e[22]=G):G=e[22];let q;e[23]!==o||e[24]!==f?(q=o&&d("button",{className:De,"data-testid":"db-add-row",onClick:f,type:"button",children:"Add row"}),e[23]=o,e[24]=f,e[25]=q):q=e[25];let I;e[26]!==o||e[27]!==x||e[28]!==w?(I=o&&x!==void 0&&d("button",{className:De,"data-testid":"db-generate-rows",onClick:x,type:"button",children:w("Generate rows")}),e[26]=o,e[27]=x,e[28]=w,e[29]=I):I=e[29];let J;e[30]!==o||e[31]!==r||e[32]!==m||e[33]!==w||e[34]!==C||e[35]!==k?(J=o&&C>0&&r&&d(jt,{confirmLabel:k?w("Permanently delete {total} matching rows and everything that cascades?",{total:C.toString()}):w("Permanently delete all matching rows and everything that cascades?"),onConfirm:m,testId:"db-bulk-delete",children:k?w("Delete {total} matching",{total:C.toString()}):w("Delete matching")}),e[30]=o,e[31]=r,e[32]=m,e[33]=w,e[34]=C,e[35]=k,e[36]=J):J=e[36];let K;e[37]!==o||e[38]!==r||e[39]!==p||e[40]!==w||e[41]!==C||e[42]!==k?(K=o&&k&&C>0&&r&&d("button",{className:De,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:w("Set column on {total} matching",{total:C.toString()})}),e[37]=o,e[38]=r,e[39]=p,e[40]=w,e[41]=C,e[42]=k,e[43]=K):K=e[43];let H;e[44]!==o||e[45]!==r||e[46]!==u||e[47]!==w||e[48]!==C||e[49]!==k?(H=o&&C>0&&!r&&d(jt,{confirmLabel:k?w("Permanently clear all {total} rows and everything that cascades?",{total:C.toString()}):w("Permanently clear every row and everything that cascades?"),onConfirm:u,testId:"db-clear-table",children:k?w("Clear table ({total})",{total:C.toString()}):w("Clear table")}),e[44]=o,e[45]=r,e[46]=u,e[47]=w,e[48]=C,e[49]=k,e[50]=H):H=e[50];let Y;e[51]!==G||e[52]!==q||e[53]!==I||e[54]!==J||e[55]!==K||e[56]!==H||e[57]!==O||e[58]!==_||e[59]!==V?(Y=E("div",{className:"flex flex-wrap items-center gap-1.5",children:[O,_,V,G,q,I,J,K,H]}),e[51]=G,e[52]=q,e[53]=I,e[54]=J,e[55]=K,e[56]=H,e[57]=O,e[58]=_,e[59]=V,e[60]=Y):Y=e[60];let U;e[61]!==n||e[62]!==t||e[63]!==c||e[64]!==b||e[65]!==g||e[66]!==h?(U=d(ho,{columns:n,filters:c,onAskAi:b,onFiltersChange:h,onSearchChange:g,search:t}),e[61]=n,e[62]=t,e[63]=c,e[64]=b,e[65]=g,e[66]=h,e[67]=U):U=e[67];let Z;return e[68]!==Y||e[69]!==U?(Z=E("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[Y,U]}),e[68]=Y,e[69]=U,e[70]=Z):Z=e[70],Z},Os=s=>{const e=B(110),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:a,onInspect:i,onOpenBulkPatch:f,onOpenGenerateRows:m,onRowDelete:p,onSaveQuery:b,page:u,preferences:g,queryBar:h,references:x}=s,v=g.maskColumns.size>0,y=n.unavailable?void 0:a;let N;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.hasPredicate||e[7]!==t.liveError||e[8]!==t.onFilterChange||e[9]!==t.onFiltersChange||e[10]!==t.showJson||e[11]!==t.showTable||e[12]!==t.total||e[13]!==t.totalKnown||e[14]!==t.viewMode||e[15]!==r||e[16]!==f||e[17]!==m||e[18]!==g.maskOn||e[19]!==g.onToggleMask||e[20]!==v||e[21]!==y?(N=d(Fs,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,hasPredicate:t.hasPredicate,liveError:t.liveError,maskOn:g.maskOn,onAddRow:t.addRow,onAskAiFilter:y,onBulkDelete:t.bulkDelete,onBulkPatch:f,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:m,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:g.onToggleMask,total:t.total,totalKnown:t.totalKnown,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.hasPredicate,e[7]=t.liveError,e[8]=t.onFilterChange,e[9]=t.onFiltersChange,e[10]=t.showJson,e[11]=t.showTable,e[12]=t.total,e[13]=t.totalKnown,e[14]=t.viewMode,e[15]=r,e[16]=f,e[17]=m,e[18]=g.maskOn,e[19]=g.onToggleMask,e[20]=v,e[21]=y,e[22]=N):N=e[22];let C;e[23]!==b||e[24]!==h?(C=h!==void 0&&d(Cs,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[23]=b,e[24]=h,e[25]=C):C=e[25];let k;e[26]!==o||e[27]!==t.onBulkDeleteSelected||e[28]!==t.selectedTable||e[29]!==t.table||e[30]!==t.viewMode||e[31]!==r||e[32]!==u||e[33]!==g.maskView||e[34]!==g.onToggleTranspose||e[35]!==g.transposed?(k=t.viewMode==="table"&&u.rows.length>0&&d(xo,{backRelations:o.available,columns:u.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:Nt(u.rows,g.maskView),sqlColumns:u.sqlColumns,table:t.table.table,transposed:g.transposed}),e[26]=o,e[27]=t.onBulkDeleteSelected,e[28]=t.selectedTable,e[29]=t.table,e[30]=t.viewMode,e[31]=r,e[32]=u,e[33]=g.maskView,e[34]=g.onToggleTranspose,e[35]=g.transposed,e[36]=k):k=e[36];let S;e[37]!==t.cancelEdit||e[38]!==t.editing||e[39]!==t.saveEdit||e[40]!==t.setEditorDocumentText||e[41]!==c||e[42]!==r||e[43]!==u?(S=r&&t.editing!==null&&d(As,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:u.refs}),e[37]=t.cancelEdit,e[38]=t.editing,e[39]=t.saveEdit,e[40]=t.setEditorDocumentText,e[41]=c,e[42]=r,e[43]=u,e[44]=S):S=e[44];let w;e[45]!==t.committing||e[46]!==t.discardStaged||e[47]!==t.onCommitStaged||e[48]!==t.stagedChanges||e[49]!==r?(w=r&&t.stagedChanges.length>0&&d(Bo,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[45]=t.committing,e[46]=t.discardStaged,e[47]=t.onCommitStaged,e[48]=t.stagedChanges,e[49]=r,e[50]=w):w=e[50];let T;e[51]!==t.writeError?(T=t.writeError!==null&&d("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[51]=t.writeError,e[52]=T):T=e[52];let O;e[53]!==t.writeNotice?(O=t.writeNotice!==null&&d("p",{className:"text-sm text-muted-foreground","data-testid":"db-write-notice",role:"status",children:t.writeNotice}),e[53]=t.writeNotice,e[54]=O):O=e[54];let R;e[55]!==N||e[56]!==C||e[57]!==k||e[58]!==S||e[59]!==w||e[60]!==T||e[61]!==O?(R=E("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[N,C,k,S,w,T,O]}),e[55]=N,e[56]=C,e[57]=k,e[58]=S,e[59]=w,e[60]=T,e[61]=O,e[62]=R):R=e[62];let _;e[63]!==t.viewMode||e[64]!==u?(_=t.viewMode==="table"&&u.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(Yn,{description:"Rows you insert into this table will show up here.",icon:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[63]=t.viewMode,e[64]=u,e[65]=_):_=e[65];let $;e[66]!==t.viewMode||e[67]!==u||e[68]!==g.maskView||e[69]!==g.transposed?($=t.viewMode==="table"&&u.rows.length>0&&g.transposed&&d(bo,{columns:u.columns,rows:Nt(u.rows,g.maskView)}),e[66]=t.viewMode,e[67]=u,e[68]=g.maskView,e[69]=g.transposed,e[70]=$):$=e[70];let F;e[71]!==o||e[72]!==t.filter||e[73]!==t.onRowEdit||e[74]!==t.table||e[75]!==t.viewMode||e[76]!==c||e[77]!==l||e[78]!==r||e[79]!==i||e[80]!==p||e[81]!==u||e[82]!==g.maskView||e[83]!==g.onTogglePin||e[84]!==g.pinnedColumns||e[85]!==g.transposed||e[86]!==x?(F=t.viewMode==="table"&&u.rows.length>0&&!g.transposed&&d(ms,{backRelationCounts:o.counts,columnMeta:c,edit:l,editable:r,highlight:t.filter,mask:g.maskView,onDelete:p,onEdit:t.onRowEdit,onInspect:i,onTogglePin:g.onTogglePin,pinnedColumns:g.pinnedColumns,refs:x,tableModel:t.table}),e[71]=o,e[72]=t.filter,e[73]=t.onRowEdit,e[74]=t.table,e[75]=t.viewMode,e[76]=c,e[77]=l,e[78]=r,e[79]=i,e[80]=p,e[81]=u,e[82]=g.maskView,e[83]=g.onTogglePin,e[84]=g.pinnedColumns,e[85]=g.transposed,e[86]=x,e[87]=F):F=e[87];let L;e[88]!==t.viewMode||e[89]!==u||e[90]!==g.maskView?(L=t.viewMode==="json"&&d("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(Nt(u.rows,g.maskView),tn,2)}),e[88]=t.viewMode,e[89]=u,e[90]=g.maskView,e[91]=L):L=e[91];let D;e[92]!==t.changePageSize||e[93]!==t.goNext||e[94]!==t.goPrevious||e[95]!==t.hasNext||e[96]!==t.hasPrevious||e[97]!==t.jumpToPage||e[98]!==t.pageSize||e[99]!==t.rangeEnd||e[100]!==t.rangeStart||e[101]!==t.total?(D=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(wo,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[92]=t.changePageSize,e[93]=t.goNext,e[94]=t.goPrevious,e[95]=t.hasNext,e[96]=t.hasPrevious,e[97]=t.jumpToPage,e[98]=t.pageSize,e[99]=t.rangeEnd,e[100]=t.rangeStart,e[101]=t.total,e[102]=D):D=e[102];let V;return e[103]!==R||e[104]!==_||e[105]!==$||e[106]!==F||e[107]!==L||e[108]!==D?(V=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,$,F,L,D]}),e[103]=R,e[104]=_,e[105]=$,e[106]=F,e[107]=L,e[108]=D,e[109]=V):V=e[109],V},Ms="/__lunora/seed",Et=200,Ls=50,Vs=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},Bs=s=>Array.isArray(s)&&s.every(e=>nn(e)),js=async s=>{let e;try{e=await fetch(Ms,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"})}catch(o){return{kind:"error",message:`seed request failed: ${Vt(o)}`}}let n;try{n=await e.json()??{}}catch{return{kind:"error",message:`seed request failed (${String(e.status)})`}}if(e.ok&&n.rows!==void 0){let o;try{o=Pt(n.rows)}catch(t){return{kind:"error",message:`seed response could not be decoded: ${Vt(t)}`}}return Bs(o)?{kind:"ok",rows:o}:{kind:"error",message:"seed response did not carry a list of row documents"}}return n.error==="fk-parents-empty"?{kind:"error",message:`no rows to reference in ${(Array.isArray(n.tables)?n.tables.filter(t=>typeof t=="string"):[]).join(", ")} — seed those tables first`}:{kind:"error",message:typeof n.error=="string"?n.error:`seed request failed (${String(e.status)})`}},zs="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",qs="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",Ks=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=xe(),[l,r]=P(10),[a,i]=P(!1),[f,m]=P(void 0),[p,b]=P(void 0),[u,g]=P(0),h=C=>{const k=Number(C.target.value);!Number.isNaN(k)&&k>=1&&r(Math.min(k,Et))},x=async()=>{m(void 0),b(void 0),g(0),i(!0);try{const C=await js({count:l,existingIds:e,seed:Date.now(),table:t});if(C.kind==="error"){m(C.message);return}const{rows:k}=C;if(k.length===0){m(c("No rows generated — all columns were skipped."));return}const S=await o(k);if(S.error!==void 0){m(S.error);return}b(S.inserted),g(S.conflicts)}finally{i(!1)}},v=()=>{Ne(x())},y=s.filter(C=>C.pk!==!0),N=Vs(s,e);return E(gt,{label:c("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:c("Generate dummy rows")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:c("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:c("Close")})]}),E("div",{className:"flex items-center gap-2",children:[d("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:c("Row count")}),d("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:Et,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:Et.toString()})})]}),y.length>0&&E("div",{className:"flex flex-col gap-1",children:[d("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Columns to seed")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:y.map(C=>{const k=C.ref!==void 0&&C.type==="id",S=k&&(e[C.ref??""]??[]).length===0,w=S?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",T=S?`gen-rows-fk-empty-${C.name}`:`gen-rows-fk-ok-${C.name}`,O=S?c("FK: no rows in {ref} — seed it first",{ref:C.ref??""}):c("→ {ref}",{ref:C.ref??""});return E("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:C.name}),E("span",{className:"text-muted-foreground",children:["(",C.type,")"]}),C.optional&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),k&&d("span",{className:w,"data-testid":T,children:O})]},C.name)})})]}),N.length>0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-blocked",role:"alert",children:c("Cannot generate rows: these columns reference tables with no rows: {cols}. Seed those tables first.",{cols:N.join(", ")})}),f!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:f}),p!==void 0&&f===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:u>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:u.toString(),inserted:p.toString(),total:(p+u).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:zs,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:qs,"data-testid":"gen-rows-generate",disabled:a||N.length>0,onClick:v,type:"button",children:c(a?"Inserting…":"Generate & insert")})]})]})},Gs=Ee(he.backRelationCounts),Js=(s,e,n,o)=>{const t=B(16),c=mt();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=P(l);let i;if(t[1]!==s||t[2]!==e){let x;t[4]!==s?(x=v=>s.has(It(v)),t[4]=s,t[5]=x):x=t[5],i=e.filter(x),t[1]=s,t[2]=e,t[3]=i}else i=t[3];const f=i;let m;t[6]!==n||t[7]!==f?(m=JSON.stringify([f,n]),t[6]=n,t[7]=f,t[8]=m):m=t[8];const p=m;let b;t[9]!==c||t[10]!==o||t[11]!==p?(b=async x=>{const[v,y]=JSON.parse(p);if(v.length===0||y.length===0){x.cancelled||a({});return}try{const N=await c.query(Gs,{ids:y,relations:v},Te(o));x.cancelled||a(Object.fromEntries(N.relations.map(Ws)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const u=b;let g,h;return t[13]!==u?(g=()=>{const x={cancelled:!1};return Ne(u(x)),()=>{x.cancelled=!0}},h=[u],t[13]=u,t[14]=g,t[15]=h):(g=t[14],h=t[15]),Be(g,h),r};function Ws(s){return[It(s),s.counts]}const Hs=async s=>{const{args:e,maxBatches:n,openCursor:o,query:t}=s;let c=o,l=0,r="cap-hit";for(let a=0;a<n;a+=1){const i=await t({...e,after:c});if(l+=i.count,c=i.cursor,!i.hasMore){r="completed";break}}return{cursor:r==="cap-hit"?c:void 0,outcome:r,written:l}},dt=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},fn=s=>Fe(s),Qt=s=>s.map(e=>({column:e.column,...e.value===void 0?{}:{literal:[e.value]},operator:e.operator,value:e.value===void 0?"":fn(e.value)})),Yt=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],Us=s=>[s.column,s.operator,s.value],at=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>Us(t)),o===void 0?null:[o.column,o.direction]]),Ot=200,Qs=20,Ys=Ee(he.readTablePage),Xs=Ee(he.facetColumn),_t=Ee(he.writeRow),Zs=Ee(he.deleteRows),el=Ee(he.clearTable),tl=Ee(he.patchRows),nl={},Mt=new Set(["__doc__","__id__","_creationTime","_id","id"]),ol=s=>{const e=s.__doc__;if(typeof e=="string"){const o=Un(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Mt.has(o)||(n[o]=t);return n},sl=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,on(e)]),ll=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Ie(s),limit:n,offset:e,orderBy:dt(t),search:o,skipCount:!0,table:c}),rl=({filters:s,search:e,table:n})=>({filters:Ie(s),limit:1,search:e,table:n}),al=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Pe(t);c!==null&&n.set(c,t)}const o=[];for(const[t,c]of Object.entries(e))for(const[l,r]of Object.entries(c))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},il=s=>!Mt.has(s),cl=`Stopped after ${Ot.toString()} batches — rows still match. Run it again to remove the rest.`,dl=`Stopped after ${Ot.toString()} batches — rows still match. Run it again to set the rest.`,Xt={resumable:!1,truncated:cl,verb:"deleted"},ul={resumable:!0,truncated:dl,verb:"written"},fl=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const i=mt(),[f,m]=P(l),[p,b]=P(o??""),u=a===void 0||a===""?null:a,[g,h]=P(0),[x,v]=P("table"),[y,N]=P(()=>Yt(e)),[C,k]=P(n??""),[S,w]=P(()=>Qt(s??[])),{clearFacets:T,facets:O,refetchFacets:R,toggleFacet:_}=zn(),[$,F]=P(null),[L,D]=P(null),[V,G]=P(null),q=We(null),I=Vo(),[J,K]=P(null),[H,Y]=P(!1),[U,Z]=P(a),[se,re]=P(()=>at(o,n,s,e)),[ge,fe]=P(0),[me,pe]=P(()=>at(o,n,s,e)),ae=a!==U,Q=at(o,n,s,e),ie=ae||!ae&&Q!==se&&Q!==me;if(ie){Z(a),re(Q),fe(z=>z+1),N(Yt(e)),k(n??"");const A=Qt(s??[]);w(A),b(o??""),T(),I.clear(),K(null),F(null),h(0),D(null),G(null),q.current=null}else Q!==se&&re(Q);const ye=ie?n??"":C,ne=ie?o??"":p,ce=`${a??""}:${ge.toString()}`,W=zt(ye.trim(),300,ce),j=zt(ne.trim(),400,ce),[de,X]=P(j);de!==j&&(X(j),I.clear(),K(null),F(null));const le=at(j,W,Ie(S),dt(y));le!==me&&pe(le);const ue=Ze(he.listTables,nl,{live:!0,shardKey:j}),ve=ue.data??null,we=ue.error,ee=ll({filters:S,offset:g,pageSize:f,search:W,sorting:y,table:u??""}),Re=rl({filters:S,search:W,table:u??""}),Ce=Ze(he.readTablePage,ee,{enabled:u!==null,keepPreviousData:!1,live:!0,shardKey:j}),oe=Ce.data??null,Oe=Ce.error,{liveError:qe}=Ce,Se=Ze(he.readTablePage,Re,{enabled:u!==null,live:!0,shardKey:j});Be(()=>{ue.data!==void 0&&yo(j)},[ue.data,j]);const Ke=A=>{t?.(A)},je=(A,z)=>{t?.(A,{search:z})},Ue=async(A,z)=>{try{return(await i.query(Ys,{filters:[],limit:Qs,offset:0,search:z,table:A},Te(j))).rows.find(_e=>Pe(_e)===z)??null}catch{return null}},tt=(A,z,ke,_e)=>$e=>i.query(Xs,{column:$e,filters:Ie(ke),search:_e,table:z},Te(A)),pt=A=>{_(A,u===null?null:tt(j,u,S,W))},bt=(A,z)=>{const ke={column:A,literal:[Jn(z)],operator:"eq",value:fn(z)};w(_e=>[..._e.filter($e=>$e.column!==A),ke]),h(0)},ht=it(tt),nt=it(R),ot=it(c);Be(()=>{u!==null&&nt.current(ht.current(j,u,S,W))},[j,u,S,W]),Be(()=>{u===null||ot.current===void 0||U!==a||se!==Q||ot.current({filters:Ie(S),orderBy:dt(y),search:W,shard:j})},[u,a,U,se,Q,S,y,W,j]);const Qe=A=>{u!==null&&h(Math.max(0,A))},st=(A,z)=>{K({column:z,rowId:A})},xt=()=>{K(null)},vt=async()=>{if(u!==null){D(null),Y(!0);try{for(const[A,z]of Object.entries(I.staged))await i.query(_t,{doc:z,id:A,op:"patch",table:u},Te(j)),I.drop(A,z)}catch(A){D(A.message)}K(null),Ce.refetch(),Y(!1)}},wt=()=>{I.clear(),K(null)},yt=A=>{b(A),I.clear(),K(null),F(null),h(0),q.current=null},Ct=al(oe,I.staged),lt=async(A,z,ke)=>{if(u===null)return;D(null);let _e;if(A!=="delete"){let $e;try{$e=ke===void 0||ke.trim()===""?{}:JSON.parse(ke)}catch(Ve){D(`Invalid JSON: ${Ve.message}`);return}try{const Ve=Pt($e);if(!nn(Ve)){D("The document must be a JSON object.");return}_e=Ve}catch(Ve){D(`Invalid document: ${Ve.message}`);return}}try{await i.query(_t,{doc:_e,id:z??void 0,op:A,table:u},Te(j)),F(null),Ce.refetch()}catch($e){D($e.message)}},Ye=async(A,z,ke)=>{if(u===null)return 0;D(null),G(null);const _e=sl(A,z,j),$e=q.current?.key===_e?q.current.after:void 0,Ve=ke.resumable?$e??"":void 0;let Ge=0;try{const Xe=await Hs({args:z,maxBatches:Ot,openCursor:Ve,query:async Vn=>{const Lt=await i.query(A,Vn,Te(j));return Ge+=Lt.count,Lt}});return q.current=Xe.cursor===void 0?null:{after:Xe.cursor,key:_e},Xe.outcome==="cap-hit"&&D(ke.truncated),G(`${Ge.toString()} ${Ge===1?"row":"rows"} ${ke.verb}.`),Ge}catch(Xe){return D(`${Xe.message} (at least ${Ge.toString()} rows were already ${ke.verb})`),q.current=null,Ge}finally{h(0),Ce.refetch()}},M=A=>{N(A),h(0)},te=Rt(()=>u===null?[]:r?.(u)??[],[r,u]),Ae=gs(oe,y,M,te),Me={filters:Ie(S),orderBy:dt(y),search:W,shard:p,table:u??void 0},Le=Se.data?.total,ze=Le!==void 0,rt=Le??(oe===null?0:g+oe.rows.length),mn=g>0,gn=W!==""||Ie(S).length>0,pn=oe!==null&&(ze?g+oe.rows.length<rt:oe.rows.length===f),bn=oe===null||oe.rows.length===0?0:g+1,hn=oe===null?0:g+oe.rows.length,xn=()=>{ue.refetch()},vn=()=>{v("table")},wn=()=>{v("json")},yn=()=>{Ne(Ye(Zs,{filters:Ie(S),search:W,table:u},Xt))},Cn=()=>{Ne(Ye(el,{table:u},Xt))},Nn=A=>{Ne(Ye(tl,{doc:A,filters:Ie(S),search:W,table:u},ul))},Sn=A=>{k(A.target.value),h(0)},kn=A=>{w(A),h(0)},Tn=()=>{D(null);const A={};for(const z of oe?.columns??[])Mt.has(z)||(A[z]="");F({docText:JSON.stringify(A,null,2),id:""})},En=A=>{F(z=>z===null?z:{docText:A,id:z.id})},_n=()=>{$!==null&&Ne(lt($.id===""?"insert":"patch",$.id===""?null:$.id,$.docText))},Rn=()=>{F(null),D(null)},$n=()=>{Qe(g-f)},Dn=()=>{Qe(g+f)},Pn=A=>{Qe(Math.max(0,(A-1)*f))},An=A=>{m(A),h(0)},In=(A,z)=>{D(null),F({docText:JSON.stringify(on(ol(z)),null,2),id:A})},Fn=A=>{Ne(lt("delete",A))},On=async A=>{if(!(u===null||A.length===0)){D(null);try{for(const z of A)await i.query(_t,{id:z,op:"delete",table:u},Te(j));Ce.refetch()}catch(z){D(z.message)}}},Mn=A=>{Ne(On(A))},Ln=()=>{Ne(vt())};return{addRow:Tn,bulkDelete:yn,bulkPatch:Nn,cancelCellEdit:xt,cancelEdit:Rn,changePageSize:An,clearTable:Cn,columns:oe?.columns??[],committing:H,currentView:Me,discardStaged:wt,editableColumn:il,editing:$,editingCell:J,facetFilter:bt,facets:O,filter:C,filters:S,goNext:Dn,goPrevious:$n,hasNext:pn,hasPredicate:gn,hasPrevious:mn,jumpToPage:Pn,liveError:qe,loadTables:xn,navigateToRef:je,onBulkDeleteSelected:Mn,onCommitStaged:Ln,onFilterChange:Sn,onFiltersChange:kn,onRowDelete:Fn,onRowEdit:In,page:oe,previewRef:Ue,pageError:Oe,pageSize:f,rangeEnd:hn,rangeStart:bn,queryShardKey:j,saveEdit:_n,selectedTable:u,selectTable:Ke,setEditorDocumentText:En,setShardKey:yt,shardKey:p,showJson:wn,showTable:vn,stage:I.stage,stagedChanges:Ct,stagedValue:I.stagedValue,startCellEdit:st,table:Ae,tables:ve,tablesError:we,toggleFacet:pt,total:rt,totalKnown:ze,viewMode:x,writeError:L,writeNotice:V}},ml="lunora-studio-pinned-columns",gl=s=>{const e=B(21),{columns:n,initialPins:o,selectedTable:t}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];const[l,r]=en(ml,c),a=t??"",i=l[a];let f;e[1]!==o||e[2]!==i?(f=i===void 0?new Set((o??"").split(",").filter(pl)):new Set(i),e[1]=o,e[2]=i,e[3]=f):f=e[3];const m=f;let p;e[4]!==a||e[5]!==m||e[6]!==r?(p=T=>{r(O=>{const R=O[a]??[...m],_=R.includes(T)?R.filter($=>$!==T):[...R,T];return{...O,[a]:_}})},e[4]=a,e[5]=m,e[6]=r,e[7]=p):p=e[7];const b=p,[u,g]=P(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(bl)},e[8]=h):h=e[8];const x=h;let v;e[9]!==n||e[10]!==t?(v={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=v):v=e[11];const{maskColumns:y,maskOn:N,maskView:C,maskViewFor:k,onToggleMask:S}=qn(v);let w;return e[12]!==y||e[13]!==N||e[14]!==C||e[15]!==k||e[16]!==S||e[17]!==b||e[18]!==m||e[19]!==u?(w={maskColumns:y,maskOn:N,maskView:C,maskViewFor:k,onToggleMask:S,onTogglePin:b,onToggleTranspose:x,pinnedColumns:m,transposed:u},e[12]=y,e[13]=N,e[14]=C,e[15]=k,e[16]=S,e[17]=b,e[18]=m,e[19]=u,e[20]=w):w=e[20],w};function pl(s){return s!==""}function bl(s){return!s}const hl=Ee(he.describeTable),xl=Ee(he.readTablePage),vl=Ee(he.importShard),wl=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},yl=s=>{const e=Object.values(s.inserted).reduce((a,i)=>a+i,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,c=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${c})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},Cl=s=>{const e=mt(),[n,o]=P(!1),[t,c]=P(void 0),[l,r]=P(void 0),[a,i]=P(void 0),[f,m]=P({}),[p,b]=P(!1),[u,g]=P(void 0),h=async(N,C)=>{o(!0),c(N),r(C),i(void 0),m({}),g(void 0),b(!0);try{const k=await e.query(hl,{table:N},Te(C)),{columns:S}=k;i(S);const w={},T=S.filter(O=>O.ref!==void 0&&O.type==="id"&&O.pk!==!0);for(const O of T){if(O.ref===void 0)continue;const{ref:R}=O;if(w[R]===void 0)try{const _=await e.query(xl,{filters:[],limit:Ls,offset:0,search:"",table:R},Te(C));w[R]=_.rows.flatMap($=>wl($)||[])}catch{w[R]=[]}}m(w)}catch(k){g(k.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),i(void 0),m({}),g(void 0)},columnMeta:a,error:u,fkPools:f,insertBatch:async(N,C)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const k=await e.query(vl,{rows:N.map(w=>({doc:w,table:t}))},Te(l)),S=yl(k);return S.error!==void 0||(C(),s()),S}catch(k){return{conflicts:0,error:k.message,inserted:0}}},loading:p,open:n,openDialog:(N,C)=>{Ne(h(N,C))},shardKey:l,table:t}},Nl=()=>{const s=B(6),[e,n]=P(null);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{n(null)},s[0]=o):o=s[0];const t=o,[c,l]=P(null);let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=(p,b)=>{l({column:p,value:b})},s[1]=r):r=s[1];const a=r;let i;s[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{l(null)},s[2]=i):i=s[2];const f=i;let m;return s[3]!==c||s[4]!==e?(m={closeExpandedCell:f,closeInspect:t,expandedCell:c,inspecting:e,onExpandCell:a,onInspect:n},s[3]=c,s[4]=e,s[5]=m):m=s[5],m},Sl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,kl=(s,e)=>typeof e=="number"&&Sl.test(s),Tl=s=>{const e=B(36),{column:n,masked:o,onNavigate:t,target:c,value:l}=s;let r;e[0]!==t||e[1]!==c||e[2]!==l?(r=()=>{c!==void 0&&t(c,String(l))},e[0]=t,e[1]=c,e[2]=l,e[3]=r):r=e[3];const a=r;if(l==null){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=m):m=e[4],m}if(o){const m=`rd-masked-${n}`;let p;e[5]!==l?(p=Fe(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==m||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":m,title:"Masked (preview)",children:p}),e[7]=m,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const m=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let u;return e[10]!==a||e[11]!==m||e[12]!==p||e[13]!==b?(u=E("button",{"data-testid":m,onClick:a,title:p,type:"button",children:[b," ↗"]}),e[10]=a,e[11]=m,e[12]=p,e[13]=b,e[14]=u):u=e[14],u}if(kl(n,l)){const m=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let b;e[17]!==l?(b=Wn(l),e[17]=l,e[18]=b):b=e[18];let u;return e[19]!==m||e[20]!==p||e[21]!==b?(u=d("span",{"data-testid":m,title:p,children:b}),e[19]=m,e[20]=p,e[21]=b,e[22]=u):u=e[22],u}if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)){const m=`rd-bytes-${n}`;let p;e[23]!==l?(p=Fe(l),e[23]=l,e[24]=p):p=e[24];let b;return e[25]!==m||e[26]!==p?(b=d("span",{"data-testid":m,children:p}),e[25]=m,e[26]=p,e[27]=b):b=e[27],b}if(typeof l=="object"){let m;e[28]!==l?(m=JSON.stringify(l,tn,2),e[28]=l,e[29]=m):m=e[29];let p;return e[30]!==m?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:m}),e[30]=m,e[31]=p):p=e[31],p}let i;e[32]!==l?(i=Fe(l),e[32]=l,e[33]=i):i=e[33];let f;return e[34]!==i?(f=d("span",{children:i}),e[34]=i,e[35]=f):f=e[35],f},El=s=>{const e=B(23),{columns:n,mask:o,onClose:t,onNavigate:c,refs:l,row:r}=s;let a;e[0]!==t||e[1]!==c?(a=(g,h)=>{c(g,h),t()},e[0]=t,e[1]=c,e[2]=a):a=e[2];const i=a;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=f):f=e[3];let m;e[4]!==t?(m=E("div",{className:"mb-3 flex items-center justify-between",children:[f,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=m):m=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==i||e[9]!==l||e[10]!==r){let g;e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==r?(g=h=>E("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[d("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),d("dd",{className:"m-0",children:d(Tl,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:i,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=i,e[14]=l,e[15]=r,e[16]=g):g=e[16],p=n.map(g),e[6]=n,e[7]=o,e[8]=i,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let b;e[17]!==p?(b=d("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=b):b=e[18];let u;return e[19]!==t||e[20]!==m||e[21]!==b?(u=E(gt,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[m,b]}),e[19]=t,e[20]=m,e[21]=b,e[22]=u):u=e[22],u},_l=50,Rl=s=>{const e=B(8),{active:n,onPick:o,shard:t}=s;let c;e[0]!==o||e[1]!==t?(c=()=>{o(t)},e[0]=o,e[1]=t,e[2]=c):c=e[2];const l=c,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,a=`shard-explorer-item-${t}`;let i;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==a?(i=d("button",{className:r,"data-testid":a,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},$l=({onFetchTables:s,onSelect:e})=>{const n=xe(),[o]=P(()=>Co()),[t,c]=P(!1),[l,r]=P(void 0),[a,i]=P(void 0),[f,m]=P(!1),[p,b]=P(void 0),u=We(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),i(void 0),b(void 0),m(!0),u.current+=1;const y=u.current;try{const N=await s(v);u.current===y&&i(N?.slice(0,_l))}catch(N){u.current===y&&b(N.message)}u.current===y&&m(!1)},x=v=>{Ne(h(v))};return o.length===0?null:E("div",{"data-testid":"shard-explorer",children:[E("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:g,type:"button",children:[n("Shards seen"),d("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&E("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(v=>d("li",{children:d(Rl,{active:l===v,onPick:x,shard:v})},v))}),l!==void 0&&E("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[d("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),f&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!f&&p===void 0&&a?.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!f&&p===void 0&&a!==void 0&&a.length>0&&d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:a.map(v=>E("li",{className:"flex items-center justify-between text-xs",children:[d("span",{"data-testid":`shard-explorer-table-${v.name}`,children:v.name}),d("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${v.name}`,children:v.rowCount})]},v.name))})]})]})]})},Dl="lunora-studio-back-relations",Pl=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),Al={},Il=50,Fl=[],Ol=Ee(he.listTables),Ml=Ee(he.readTablePage),Ll=s=>{const e=B(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Bn,{onChange:o,testId:"db-shard-input",value:c}),e[0]=o,e[1]=c,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=d($l,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let a;return e[6]!==t||e[7]!==l||e[8]!==r?(a=E("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=a):a=e[9],a},br=({canGenerateRows:s=!1,editable:e=!1,globalTableNames:n,initialFilters:o,initialOrderBy:t,initialPins:c,initialSearch:l,initialShardKey:r,onNavigateToGlobal:a,onSelectTable:i,onViewChange:f,pageSize:m=Il,queryBar:p,schemaSwitch:b,tableParam:u})=>{const g=Ze(he.describeTables,{},{shardKey:r??""}),h=Ze(he.listTablesIndexes,{},{shardKey:r??""}),x=g.data?.columnsByTable??Al,[v,y]=en(Dl,{}),N=ut(M=>{const te=new Set(v[M]);return qt(M,x).filter(Ae=>te.has(It(Ae)))},[v,x]),C=fl({initialFilters:o,initialOrderBy:t,initialSearch:l,initialShardKey:r,onSelectTable:i,onViewChange:f,pageSize:m,resolveBackRelations:N,tableParam:u}),{cancelCellEdit:k,columns:S,currentView:w,editableColumn:T,editingCell:O,facetFilter:R,facets:_,loadTables:$,navigateToRef:F,onFiltersChange:L,page:D,pageError:V,previewRef:G,queryShardKey:q,selectedTable:I,selectTable:J,setShardKey:K,shardKey:H,stage:Y,stagedValue:U,startCellEdit:Z,tables:se,tablesError:re,toggleFacet:ge}=C,fe=Hn(H),me=it(I),pe=M=>{const te=I;Ne((async()=>{const Me=await fe.suggestFilter(M,te??"");Me!==void 0&&me.current===te&&L(Me.map(Le=>{const ze=Le.value,rt=typeof ze=="string"||typeof ze=="number"||typeof ze=="boolean"?String(ze):"";return{column:Le.column,operator:Le.operator,value:rt}}))})())},ae=I===null?[]:qt(I,x),Q=new Set(v[I??""]),be=[];for(const M of D?.rows??[]){const te=M._id??M.id;typeof te=="string"&&te!==""&&be.push(te)}const ie=Js(Q,ae,be,q),ye=M=>{y(te=>{const Ae=I??"",Me=te[Ae]??[];return{...te,[Ae]:Me.includes(M)?Me.filter(Le=>Le!==M):[...Me,M]}})},ne=gl({columns:S,initialPins:c,selectedTable:I}),ce=Nl(),[W,j]=P(null),{closeExpandedCell:de,closeInspect:X,expandedCell:le,inspecting:ue,onExpandCell:ve}=ce,we=mt(),ee=Object.fromEntries((x[I??""]??[]).map(M=>[M.name,M])),Re=new Map;for(const M of x[I??""]??[])M.isStorage===!0&&Re.set(M.name,M.bucket);const Ce=ut(async(M,te)=>we.signedStorageUrl(M,te===void 0?{}:{bucket:te}),[we]),oe=async M=>await we.query(Ol,{},Te(M)),Oe=()=>{I!==null&&J(I)},{closeDialog:qe,columnMeta:Se,fkPools:Ke,insertBatch:je,open:Ue,openDialog:tt}=Cl(Oe),pt=()=>{I!==null&&tt(I,H)},bt=M=>je(M,qe),[ht,nt]=P(!1),ot=()=>{nt(!0)},Qe=()=>{nt(!1)},st=(M,te)=>{if(a!==void 0&&n?.has(M)===!0){a(M,te);return}F(M,te)},xt=p?.onSaveQuery,vt=M=>{xt?.(M,w)},wt={cancelEdit:k,editable:e,editableColumn:T,editingCell:O,onExpandCell:ve,stage:Y,stagedValue:U,startEdit:Z},yt=M=>{M!==null&&j(M)},Ct=()=>{C.onRowDelete(W)},lt=async(M,te,Ae)=>await we.query(Ml,{filters:[{column:te,operator:"eq",value:Ae}],limit:ct,offset:0,orderBy:[],table:M},Te(q)),Ye={columns:D?.refs,maskViewFor:ne.maskViewFor,onNavigate:st,onPreview:G};return E("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(Kn,{header:d(Ll,{onFetchShardTables:oe,onShardChange:K,schemaSwitch:b,shardKey:H}),onReload:$,onSelect:J,prefix:"db",selected:I,tables:se??Fl}),E("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[re!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:re}),D===null&&V===null&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),V!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:V}),D!==null&&d(Os,{assistant:fe,backRelations:{available:ae,counts:ie,enabled:Q,onToggle:ye},browser:C,columnMeta:ee,edit:wt,editable:e,onAskAiFilter:pe,onInspect:ce.onInspect,onOpenBulkPatch:ot,onOpenGenerateRows:s?pt:void 0,onRowDelete:yt,onSaveQuery:vt,page:D,preferences:ne,queryBar:p,references:Ye})]}),D!==null&&d(Gn,{columns:S,facets:_,mask:ne.maskView,onFacetFilter:R,onToggleFacet:ge}),ue!==null&&D!==null&&d(El,{columns:D.columns,mask:ne.maskView,onClose:X,onNavigate:st,refs:D.refs,row:Zt(ue,ne.maskView)}),W!==null&&I!==null&&d(Fo,{onClose:()=>{j(null)},onConfirm:Ct,readPage:lt,rowId:W,schema:No(x),table:I}),le!==null&&d(vo,{bucket:Re.get(le.column),column:le.column,onClose:de,resolveUrl:Re.has(le.column)?Ce:void 0,value:le.value}),ht&&I!==null&&d(To,{columns:C.columns.filter(M=>C.editableColumn(M)),onApply:C.bulkPatch,onClose:Qe,shardKey:C.queryShardKey,table:I,total:C.total,uniqueColumns:Pl(h.data?.indexesByTable[I])}),Ue&&I!==null&&Se!==void 0&&d(Ks,{columns:Se,fkPools:Ke,onClose:qe,onInsertRows:bt,table:I})]})};export{br as DataBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as V}from"react/compiler-runtime";import{useState as j}from"react";import{jsxs as A,Fragment as E,jsx as u}from"react/jsx-runtime";const K=[{label:"=",value:"eq"},{label:"≠",value:"ne"},{label:"<",value:"lt"},{label:"≤",value:"lte"},{label:">",value:"gt"},{label:"≥",value:"gte"},{label:"contains",value:"contains"}],$=t=>{const e=t.trim(),n=Number(e);return e!==""&&Number.isFinite(n)&&String(n)===e?n:t},z=t=>t.operator==="contains"?t.value==="":t.operator!=="eq"&&t.operator!=="ne"&&t.literal===void 0&&t.value.trim()==="",L=t=>t.filter(e=>e.column!==""&&!z(e)).map(e=>e.operator==="contains"?{column:e.column,operator:e.operator,value:e.value}:{column:e.column,operator:e.operator,value:e.literal===void 0?$(e.value):e.literal[0]}),P=(t,e)=>({column:t.column,operator:t.operator,value:t.value,...e}),M=t=>{const e=V(44),{columns:n,filters:l,onAskAi:h,onFiltersChange:r,onSearchChange:D,search:q}=t,[c,R]=j("");let N;e[0]!==n[0]||e[1]!==l||e[2]!==r?(N=()=>{r([...l,{column:n[0]??"",operator:"eq",value:""}])},e[0]=n[0],e[1]=l,e[2]=r,e[3]=N):N=e[3];const O=N;let T;e[4]!==l||e[5]!==r?(T=a=>{const i=Number(a.currentTarget.dataset.index);r(l.filter((o,s)=>s!==i))},e[4]=l,e[5]=r,e[6]=T):T=e[6];const g=T;let y;e[7]!==l||e[8]!==r?(y=a=>{const i=Number(a.currentTarget.dataset.index),o=a.currentTarget.value;r(l.map((s,F)=>F===i?P(s,{column:o}):s))},e[7]=l,e[8]=r,e[9]=y):y=e[9];const f=y;let S;e[10]!==l||e[11]!==r?(S=a=>{const i=Number(a.currentTarget.dataset.index),o=a.currentTarget.value;r(l.map((s,F)=>F===i?{...s,operator:o}:s))},e[10]=l,e[11]=r,e[12]=S):S=e[12];const x=S;let k;e[13]!==l||e[14]!==r?(k=a=>{const i=Number(a.currentTarget.dataset.index),o=a.currentTarget.value;r(l.map((s,F)=>F===i?P(s,{value:o}):s))},e[13]=l,e[14]=r,e[15]=k):k=e[15];const C=k;let d;e[16]!==D||e[17]!==q?(d=u("input",{"aria-label":"Search rows","data-testid":"db-filter",onChange:D,placeholder:"search table…",value:q}),e[16]=D,e[17]=q,e[18]=d):d=e[18];let m;e[19]!==O?(m=u("button",{"data-testid":"db-add-filter",onClick:O,type:"button",children:"Add filter"}),e[19]=O,e[20]=m):m=e[20];let p;e[21]!==c||e[22]!==h?(p=h!==void 0&&A(E,{children:[u("input",{"aria-label":"Describe a filter","data-testid":"db-ai-prompt",onChange:a=>{R(a.target.value)},onKeyDown:a=>{a.key==="Enter"&&c.trim()!==""&&(a.preventDefault(),h(c.trim()))},placeholder:"describe a filter…",value:c}),u("button",{"data-testid":"db-ai-filter",disabled:c.trim()==="",onClick:()=>{h(c.trim())},type:"button",children:"Suggest"})]}),e[21]=c,e[22]=h,e[23]=p):p=e[23];let b;e[24]!==d||e[25]!==m||e[26]!==p?(b=A("div",{className:"flex flex-wrap items-center gap-1.5",children:[d,m,p]}),e[24]=d,e[25]=m,e[26]=p,e[27]=b):b=e[27];let v;if(e[28]!==f||e[29]!==x||e[30]!==C||e[31]!==n||e[32]!==l||e[33]!==g){let a;e[35]!==f||e[36]!==x||e[37]!==C||e[38]!==n||e[39]!==g?(a=(i,o)=>A("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-filter-row",children:[u("select",{"aria-label":"Filter column","data-index":o,"data-testid":"db-filter-column",onChange:f,value:i.column,children:n.map(B)}),u("select",{"aria-label":"Filter operator","data-index":o,"data-testid":"db-filter-operator",onChange:x,value:i.operator,children:K.map(G)}),u("input",{"aria-label":"Filter value","data-index":o,"data-testid":"db-filter-value",onChange:C,placeholder:"value",value:i.value}),u("button",{"aria-label":"Remove filter","data-index":o,"data-testid":"db-filter-remove",onClick:g,type:"button",children:"✕"})]},o),e[35]=f,e[36]=x,e[37]=C,e[38]=n,e[39]=g,e[40]=a):a=e[40],v=l.map(a),e[28]=f,e[29]=x,e[30]=C,e[31]=n,e[32]=l,e[33]=g,e[34]=v}else v=e[34];let w;return e[41]!==v||e[42]!==b?(w=A("div",{className:"flex flex-col gap-1.5","data-testid":"db-filters",children:[b,v]}),e[41]=v,e[42]=b,e[43]=w):w=e[43],w};function B(t){return u("option",{value:t,children:t},t)}function G(t){return u("option",{value:t.value,children:t.label},t.value)}export{M as DataFilters,L as toFilterClauses};
|
package/dist/packem_shared/{GlobalDataBrowser-CR138dEZ.mjs → GlobalDataBrowser-BzhSVDvF.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as de}from"@lunora/react";import{useState as V,useRef as H,useEffect as I}from"react";import{b as J}from"./use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as me}from"./DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{m as Q,u as ue,a as fe,b as pe,T as ge,D as be}from"./table-list-sidebar-
|
|
1
|
+
import{useLunora as de}from"@lunora/react";import{useState as V,useRef as H,useEffect as I}from"react";import{b as J}from"./use-admin-query-tlBof8Yg.mjs";import{useAutoRefresh as me}from"./DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{m as Q,u as ue,a as fe,b as pe,T as ge,D as be}from"./table-list-sidebar-CYRSPLIv.mjs";import{useT as B}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{b as he}from"./cf-links-CBJ5SywP.mjs";import{k as xe,n as ke}from"./internal-Df43vQI0.mjs";import{c as W}from"react/compiler-runtime";import{c as ve,a as Ne,b as Z,e as ye,d as we,T as Te}from"./table-D0SBiDu-.mjs";import{a as Se}from"./control-button-BOZ5K-FC.mjs";import{C as q,G as Ce}from"./data-grid-DIiNmDR9.mjs";import{G as Fe}from"./grid-pagination-DgzyzfBh.mjs";import{jsx as r,jsxs as P}from"react/jsx-runtime";import{E as Pe}from"./empty-state-D7jEML_T.mjs";const Ee=(t,e)=>{const o=t._id;return typeof o=="string"||typeof o=="number"?String(o):`row-${e.toString()}`},Me=t=>t==null?"∅":t===""?"(empty)":xe(t),Ge=t=>{const e=W(45),{filters:o,hasMaskedColumns:f,mask:s,maskOn:u,onChangePageSize:i,onJumpToPage:L,onNext:d,onPrevious:T,onRemoveFilter:p,onToggleMask:O,page:c,pageSize:E,pagination:S}=t,C=B(),{hasNext:z,hasPrevious:D,rangeEnd:$,rangeStart:F,total:k}=S;let v;e[0]!==f||e[1]!==u||e[2]!==O||e[3]!==C?(v=f&&r("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2",children:r("button",{"aria-pressed":u,className:Se,"data-testid":"gdb-mask-toggle",onClick:O,type:"button",children:C("Mask sensitive columns")})}),e[0]=f,e[1]=u,e[2]=O,e[3]=C,e[4]=v):v=e[4];let g;e[5]!==o||e[6]!==s||e[7]!==p||e[8]!==C?(g=o.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:o.map((n,m)=>{const G=Me(Q(n.value,n.column,s));return P("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-muted px-1.5 py-0.5","data-testid":"gdb-filter-chip",children:[r("span",{className:"font-medium text-foreground",children:n.column}),r("span",{className:"text-muted-foreground",children:"="}),r("span",{className:"font-mono text-foreground",children:G}),r("button",{"aria-label":C("Remove filter"),className:"ml-0.5 text-muted-foreground hover:text-foreground","data-testid":"gdb-filter-remove",onClick:()=>{p(m)},type:"button",children:"✕"})]},`${n.column}:${G}`)})}),e[5]=o,e[6]=s,e[7]=p,e[8]=C,e[9]=g):g=e[9];let a;if(e[10]!==s||e[11]!==c.columns){let n;e[13]!==s?(n=m=>P(ve,{children:[m,s.columns.has(m)&&r("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`gdb-mask-chip-${m}`,title:"This column is masked by a mask() policy",children:"masked"})]},m),e[13]=s,e[14]=n):n=e[14],a=c.columns.map(n),e[10]=s,e[11]=c.columns,e[12]=a}else a=e[12];let b;e[15]!==a?(b=r(Ne,{children:r(Z,{children:a})}),e[15]=a,e[16]=b):b=e[16];let N;if(e[17]!==s||e[18]!==c.columns||e[19]!==c.rows){let n;e[21]!==s||e[22]!==c.columns?(n=(m,G)=>r(Z,{"data-testid":"gdb-row",children:c.columns.map(w=>r(ye,{className:"max-w-xs truncate font-mono text-xs",children:s.enabled&&s.columns.has(w)?r("span",{className:"text-muted-foreground italic","data-testid":`gdb-masked-${w}`,title:"Masked (preview)",children:r(q,{value:Q(m[w],w,s)})}):r(q,{value:m[w]})},w))},Ee(m,G)),e[21]=s,e[22]=c.columns,e[23]=n):n=e[23],N=c.rows.map(n),e[17]=s,e[18]=c.columns,e[19]=c.rows,e[20]=N}else N=e[20];let y;e[24]!==N?(y=r(we,{children:N}),e[24]=N,e[25]=y):y=e[25];let h;e[26]!==b||e[27]!==y?(h=r(Ce,{layout:"fill",children:r("div",{className:"min-h-0 flex-1 overflow-auto",children:P(Te,{"data-testid":"gdb-rows",children:[b,y]})})}),e[26]=b,e[27]=y,e[28]=h):h=e[28];let x;e[29]!==z||e[30]!==D||e[31]!==i||e[32]!==L||e[33]!==d||e[34]!==T||e[35]!==E||e[36]!==$||e[37]!==F||e[38]!==k?(x=r("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:r(Fe,{hasNext:z,hasPrevious:D,onJumpToPage:L,onNext:d,onPageSizeChange:i,onPrevious:T,pageSize:E,prefix:"gdb",rangeEnd:$,rangeStart:F,total:k})}),e[29]=z,e[30]=D,e[31]=i,e[32]=L,e[33]=d,e[34]=T,e[35]=E,e[36]=$,e[37]=F,e[38]=k,e[39]=x):x=e[39];let M;return e[40]!==v||e[41]!==g||e[42]!==h||e[43]!==x?(M=P("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"gdb-page",children:[v,g,h,x]}),e[40]=v,e[41]=g,e[42]=h,e[43]=x,e[44]=M):M=e[44],M},Re=()=>{const t=W(8),e=B();let o;t[0]!==e?(o=e("Tables marked .global() (D1-backed, region-replicated) will appear here."),t[0]=e,t[1]=o):o=t[1];let f;t[2]===Symbol.for("react.memo_cache_sentinel")?(f=P("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{d:"M3 12h18M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18Z"})]}),t[2]=f):f=t[2];let s;t[3]!==e?(s=e("No global tables."),t[3]=e,t[4]=s):s=t[4];let u;return t[5]!==o||t[6]!==s?(u=r("div",{className:"flex flex-1 items-center justify-center p-6",children:r(Pe,{description:o,icon:f,testId:"gdb-empty",title:s})}),t[5]=o,t[6]=s,t[7]=u):u=t[7],u},Le=50,Oe=[],K=[],Ke=({initialTable:t,onSelectTable:e,pageSize:o=Le,schemaSwitch:f}={})=>{const s=de(),u=B(),[i,L]=V(t??null),[d,T]=V(0),[p,O]=V(o),[c,E]=V([]),S=ue(c),{clearFacets:C,facets:z,refetchFacets:D,toggleFacet:$}=fe(),F=J(["lunora-global-tables"],()=>s.listGlobalTables()),k=F.data??null,v=F.error,g=J(["lunora-global-page",i??"",d,p,JSON.stringify(c)],()=>s.readGlobalTablePage({filters:c,limit:p,offset:d,table:i??""}),{enabled:i!==null,keepPreviousData:!1}),a=g.data??null,b=g.error,N=(l,R)=>j=>s.facetGlobalColumn({column:j,filters:R,table:l}),y=(l,R)=>{D(N(l,R))};me(()=>{F.refetch(),i!==null&&(g.refetch(),y(i,S.current))},!0);const h=H(void 0),x=l=>{L(l),h.current=l,E([]),S.current=[],C(),T(0),e?.(l)},M=l=>{$(l,i===null?null:N(i,S.current))},n=l=>{E(l),S.current=l,T(0),i!==null&&y(i,l)},m=(l,R)=>{n([...S.current.filter(j=>j.column!==l),{column:l,value:ke(R)}])},G=l=>{n(S.current.filter((R,j)=>j!==l))},w=H(x);I(()=>{w.current=x}),I(()=>{if(t===void 0||t===""||h.current===t)return;h.current=t;const l=t;queueMicrotask(()=>{w.current(l)})},[t]);const A=l=>{i!==null&&T(Math.max(0,l))},{maskColumns:X,maskOn:Y,maskView:_,onToggleMask:ee}=pe({columns:a?.columns??K,selectedTable:i}),U=a?.total??0,te=d>0,re=a!==null&&d+a.rows.length<U,se=a===null||a.rows.length===0?0:d+1,le=a===null?0:d+a.rows.length,ae=()=>{F.refetch()},oe=()=>{A(d-p)},ne=()=>{A(d+p)},ie=l=>{A(Math.max(0,(l-1)*p))},ce=l=>{O(l),T(0)};return P("div",{className:"flex h-full min-w-0","data-testid":"lunora-global-data-browser",children:[r(ge,{header:P("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:he,rel:"noreferrer",target:"_blank",children:u("Open in Cloudflare")})]}),onReload:ae,onSelect:x,prefix:"gdb",selected:i,tables:k??Oe}),P("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[v!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-tables-error",role:"alert",children:v}),k!==null&&k.length===0&&r(Re,{}),b!==null&&r("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-page-error",role:"alert",children:b}),k!==null&&k.length>0&&a===null&&b===null&&r("div",{className:"flex flex-1 items-center justify-center p-6",children:r("p",{className:"text-sm text-muted-foreground",children:u("Select a table to browse its rows.")})}),a!==null&&r(Ge,{filters:c,hasMaskedColumns:X.size>0,mask:_,maskOn:Y,onChangePageSize:ce,onJumpToPage:ie,onNext:ne,onPrevious:oe,onRemoveFilter:G,onToggleMask:ee,page:a,pageSize:p,pagination:{hasNext:re,hasPrevious:te,rangeEnd:le,rangeStart:se,total:U}})]}),r(be,{columns:a?.columns??K,facets:z,mask:_,onFacetFilter:m,onToggleFacet:M})]})};export{Ke as GlobalDataBrowser};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as T}from"react/compiler-runtime";import{useT as E}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{k as H,f as I,b as Q}from"./internal-Df43vQI0.mjs";import{jsx as p,jsxs as S}from"react/jsx-runtime";import{useRef as O,useEffect as Y,useState as L,useMemo as G}from"react";import{u as J}from"./use-admin-query-tlBof8Yg.mjs";import{ADMIN_FUNCTIONS as K}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{useVirtualizer as Z}from"@tanstack/react-virtual";import{c as X}from"./utils-bhneXptQ.mjs";import{f as ee}from"./virtual-rect-D_j7aLxX.mjs";function te(s){const e=T(2),t=O(s);let r;return e[0]!==s?(r=()=>{t.current=s},e[0]=s,e[1]=r):r=e[1],Y(r),t}const re=2166136261,se=16777619,V=(s,e=re)=>{let t=e;for(let r=0;r<s.length;r+=1)t^=s.charCodeAt(r),t=Math.imul(t,se);return(t>>>0).toString(16).padStart(8,"0")},ne=/([a-z\d])([A-Z])/gu,oe=/[\s_-]+/u,le=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),ae=s=>{const e=s.replaceAll(ne,"$1 $2").split(oe).map(r=>r.toLowerCase()).filter(r=>r.length>0),t=new Set(e);for(let r=0;r<e.length-1;r+=1){const n=e[r],u=e[r+1];n===void 0||u===void 0||(t.add(`${n}${u}`),t.add(`${n}_${u}`))}return[...t]},j="•••",W=(s,e)=>{try{return e==="redact"?null:e==="hash"?s==null?s:V(typeof s=="bigint"?s.toString():typeof s=="string"?s:JSON.stringify(s)):j}catch{return j}},z=(s,e)=>{const t=new Map;for(const r of s)r.table===e&&t.set(r.column,r.strategy);return t},ce=s=>{for(const e of ae(s))if(le.has(e))return!0;return!1},B=(s,e)=>{const t=e.filter(n=>!s.has(n)&&ce(n));if(t.length===0)return s;const r=new Map(s);for(const n of t)r.set(n,"redact");return r},Ce=(s,e,t)=>{if(!t.enabled)return s;const r=t.columns.get(e);return r===void 0?s:W(s,r)},ie=(s,e)=>{if(!e.enabled||e.columns.size===0)return s;const t={...s};for(const[r,n]of e.columns)r in t&&(t[r]=W(t[r],n));return t},Fe=(s,e)=>!e.enabled||e.columns.size===0?s:s.map(t=>ie(t,e)),P=s=>s==null?"∅":s===""?"(empty)":H(s),ue=s=>{const e=T(32),{column:t,onFacetFilter:r,state:n}=s,u=E();let x;e[0]!==t||e[1]!==r||e[2]!==n.result?.values?(x=c=>{const m=Number(c.currentTarget.dataset.index),k=n.result?.values[m];k!==void 0&&r(t,k.value)},e[0]=t,e[1]=r,e[2]=n.result?.values,e[3]=x):x=e[3];const g=x,o=`db-facet-${t}`;let d;e[4]!==t?(d=p("span",{className:"font-medium text-foreground",children:t}),e[4]=t,e[5]=d):d=e[5];let a;e[6]!==n.loading||e[7]!==n.result||e[8]!==u?(a=n.loading&&n.result===null&&p("span",{className:"text-muted-foreground",children:u("Loading…")}),e[6]=n.loading,e[7]=n.result,e[8]=u,e[9]=a):a=e[9];let l;e[10]!==n.error?(l=n.error!==null&&p("span",{className:"text-destructive",role:"alert",children:n.error}),e[10]=n.error,e[11]=l):l=e[11];let i;e[12]!==n.result?.values?(i=n.result?.values??[],e[12]=n.result?.values,e[13]=i):i=e[13];let f;if(e[14]!==t||e[15]!==g||e[16]!==i){let c;e[18]!==t||e[19]!==g?(c=(m,k)=>S("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":k,"data-testid":`db-facet-value-${t}`,onClick:g,type:"button",children:[p("span",{className:"truncate",children:P(m.value)}),p("span",{className:"shrink-0 tabular-nums text-foreground/70",children:m.count})]},P(m.value)),e[18]=t,e[19]=g,e[20]=c):c=e[20],f=i.map(c),e[14]=t,e[15]=g,e[16]=i,e[17]=f}else f=e[17];let b;e[21]!==t||e[22]!==n.result||e[23]!==u?(b=n.result?.truncated===!0&&p("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${t}`,children:u("Showing the {n} most common values.",{n:n.result.values.length})}),e[21]=t,e[22]=n.result,e[23]=u,e[24]=b):b=e[24];let h;return e[25]!==o||e[26]!==d||e[27]!==a||e[28]!==l||e[29]!==f||e[30]!==b?(h=S("section",{className:"flex flex-col gap-1","data-testid":o,children:[d,a,l,f,b]}),e[25]=o,e[26]=d,e[27]=a,e[28]=l,e[29]=f,e[30]=b,e[31]=h):h=e[31],h},_e=s=>{const e=T(44),{columns:t,facets:r,mask:n,onFacetFilter:u,onToggleFacet:x}=s,g=E();let o;e[0]!==x?(o=y=>{const{column:v}=y.currentTarget.dataset;v!==void 0&&x(v)},e[0]=x,e[1]=o):o=e[1];const d=o;let a;e[2]!==n?(a=y=>n.enabled&&n.columns.has(y),e[2]=n,e[3]=a):a=e[3];const l=a;let i,f,b,h,c,m,k,w;if(e[4]!==t||e[5]!==r||e[6]!==l||e[7]!==g||e[8]!==d){w=Symbol.for("react.early_return_sentinel");e:{let y;e[17]!==l?(y=N=>!l(N),e[17]=l,e[18]=y):y=e[18];const v=t.filter(y);let M;if(e[19]!==r||e[20]!==l?(M=Object.entries(r).filter(N=>{const[q]=N;return!l(q)}),e[19]=r,e[20]=l,e[21]=M):M=e[21],i=M,v.length===0){w=null;break e}m="flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs",k="db-facets",h="flex flex-col gap-1.5";let $;e[22]!==g?($=g("Facets"),e[22]=g,e[23]=$):$=e[23],e[24]!==$?(c=p("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:$}),e[24]=$,e[25]=c):c=e[25],f="flex flex-wrap gap-1";let A;e[26]!==r||e[27]!==d?(A=N=>p("button",{"aria-pressed":N in r,className:"rounded border border-border px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-column":N,"data-testid":`db-facet-toggle-${N}`,onClick:d,type:"button",children:N},N),e[26]=r,e[27]=d,e[28]=A):A=e[28],b=v.map(A)}e[4]=t,e[5]=r,e[6]=l,e[7]=g,e[8]=d,e[9]=i,e[10]=f,e[11]=b,e[12]=h,e[13]=c,e[14]=m,e[15]=k,e[16]=w}else i=e[9],f=e[10],b=e[11],h=e[12],c=e[13],m=e[14],k=e[15],w=e[16];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[29]!==f||e[30]!==b?(C=p("div",{className:f,children:b}),e[29]=f,e[30]=b,e[31]=C):C=e[31];let F;e[32]!==C||e[33]!==h||e[34]!==c?(F=S("div",{className:h,children:[c,C]}),e[32]=C,e[33]=h,e[34]=c,e[35]=F):F=e[35];let _;e[36]!==u||e[37]!==i?(_=i.map(y=>{const[v,M]=y;return p(ue,{column:v,onFacetFilter:u,state:M},v)}),e[36]=u,e[37]=i,e[38]=_):_=e[38];let R;return e[39]!==F||e[40]!==_||e[41]!==m||e[42]!==k?(R=S("aside",{className:m,"data-testid":k,children:[F,_]}),e[39]=F,e[40]=_,e[41]=m,e[42]=k,e[43]=R):R=e[43],R},Me=()=>{const[s,e]=L({}),t=te(s),r=O({}),n=async(o,d)=>{const a=(r.current[o]??0)+1;r.current[o]=a,e(l=>o in l?{...l,[o]:{error:null,loading:!0,result:l[o]?.result??null}}:l);try{const l=await d(o);if(r.current[o]!==a)return;e(i=>o in i?{...i,[o]:{error:null,loading:!1,result:l}}:i)}catch(l){if(r.current[o]!==a)return;e(i=>o in i?{...i,[o]:{error:Q(l),loading:!1,result:null}}:i)}};return{clearFacets:()=>{e({})},facets:s,facetsRef:t,refetchFacets:o=>{for(const d of Object.keys(t.current))I(n(d,o))},toggleFacet:(o,d)=>{if(o in t.current){e(a=>Object.fromEntries(Object.entries(a).filter(([l])=>l!==o)));return}e(a=>({...a,[o]:{error:null,loading:!0,result:null}})),d!==null&&I(n(o,d))}}},de=[],fe=()=>{const s=T(1);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const{data:t}=J(K.maskPolicies,e);return Array.isArray(t?.columns)?t.columns:de},$e=s=>{const e=T(16),{columns:t,selectedTable:r}=s,n=fe(),[u,x]=L(!0);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{x(me)},e[0]=g):g=e[0];const o=g;let d;if(e[1]!==t||e[2]!==n||e[3]!==r){const h=z(n,r??"");d=B(h,t),e[1]=t,e[2]=n,e[3]=r,e[4]=d}else d=e[4];const a=d;let l;e[5]!==u||e[6]!==n?(l=(h,c)=>({columns:B(z(n,h),c),enabled:u}),e[5]=u,e[6]=n,e[7]=l):l=e[7];const i=l;let f;e[8]!==a||e[9]!==u?(f={columns:a,enabled:u},e[8]=a,e[9]=u,e[10]=f):f=e[10];let b;return e[11]!==a||e[12]!==u||e[13]!==i||e[14]!==f?(b={maskColumns:a,maskOn:u,maskView:f,maskViewFor:i,onToggleMask:o},e[11]=a,e[12]=u,e[13]=i,e[14]=f,e[15]=b):b=e[15],b};function me(s){return!s}const D=34,U=600,ge=s=>{const e=T(21),{item:t,onSelect:r,prefix:n,selected:u,start:x}=s;let g;e[0]!==t.name||e[1]!==r?(g=()=>{r(t.name)},e[0]=t.name,e[1]=r,e[2]=g):g=e[2];const o=g,d=`translateY(${String(x)}px)`;let a;e[3]!==d?(a={insetInline:0,position:"absolute",top:0,transform:d},e[3]=d,e[4]=a):a=e[4];const l=a,i=u?"bg-accent font-medium text-accent-foreground":"text-foreground";let f;e[5]!==i?(f=X("flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",i),e[5]=i,e[6]=f):f=e[6];const b=`${n}-table-${t.name}`;let h;e[7]!==t.name?(h=p("span",{className:"truncate",children:t.name}),e[7]=t.name,e[8]=h):h=e[8];let c;e[9]!==t.rowCount?(c=p("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:t.rowCount}),e[9]=t.rowCount,e[10]=c):c=e[10];let m;e[11]!==o||e[12]!==u||e[13]!==f||e[14]!==b||e[15]!==h||e[16]!==c?(m=S("button",{"aria-pressed":u,className:f,"data-testid":b,onClick:o,type:"button",children:[h,c]}),e[11]=o,e[12]=u,e[13]=f,e[14]=b,e[15]=h,e[16]=c,e[17]=m):m=e[17];let k;return e[18]!==l||e[19]!==m?(k=p("li",{style:l,children:m}),e[18]=l,e[19]=m,e[20]=k):k=e[20],k},Te=({header:s,onReload:e,onSelect:t,prefix:r,reloadLabel:n,selected:u,tables:x})=>{const g=E(),[o,d]=L(""),a=O(null),l=c=>{d(c.target.value)},i=G(()=>{const c=o.trim().toLowerCase();return c===""?x:x.filter(m=>m.name.toLowerCase().includes(c))},[o,x]),b=Z({count:i.length,estimateSize:()=>D,getScrollElement:()=>a.current,initialRect:{height:U,width:240},observeElementRect:(c,m)=>ee(c,m,U),overscan:12}).getVirtualItems(),h={height:i.length*D};return S("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${r}-table-list`,children:[s,S("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[p("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:g("Tables")}),e!==void 0&&p("button",{"aria-label":n??g("Refresh"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent","data-testid":`${r}-load-tables`,onClick:e,title:n??g("Refresh"),type:"button",children:p("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:p("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),p("div",{className:"shrink-0 border-b border-border p-2",children:p("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${r}-table-search`,onChange:l,placeholder:g("search table…"),type:"search",value:o})}),S("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${r}-table-list-rows`,ref:a,children:[p("li",{"aria-hidden":"true",style:h}),b.map(c=>{const m=i[c.index];return m===void 0?null:p(ge,{item:m,onSelect:t,prefix:r,selected:u===m.name,start:c.start},m.name)})]})]})};export{_e as D,Te as T,Me as a,$e as b,ie as c,Fe as d,Ce as m,te as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Me}from"./chunk-EIISOYGA.js";import{a as ve}from"./chunk-RPQL45FL.js";import{b as ye,c as we}from"./chunk-4GTO7FL5.js";import{a as xe}from"./chunk-3FBLWUXD.js";import{a as Ne}from"./chunk-Z5O2NQAV.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as be}from"./chunk-S3CRZLGS.js";import{a as fe}from"./chunk-EJSI4PMU.js";import{b as he}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as me}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as oe}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ge}from"./chunk-EIREQDTV.js";import"./chunk-ULIQFBZU.js";import"./chunk-FZXPE3EA.js";import"./chunk-35DM4JJG.js";import{a as ce}from"./chunk-4ZEL6BYL.js";import{c as ie}from"./chunk-4ZHQUGP5.js";import"./chunk-BJEJVHCO.js";import"./chunk-FSRSK4LY.js";import"./chunk-5ICUJ4IA.js";import{a as ue}from"./chunk-FKVZRPV5.js";import{d as U,m as pe,t as de}from"./chunk-PTZD7RUZ.js";import{a as m,d as le,e as Ce,f as Le,g as Te,i as te}from"./chunk-YKXDMIHQ.js";var O=le(Le(),1),A=le(Ce(),1);var s=le(Te(),1);var Pe=.5,Ie=4,Se=m(n=>Math.min(100,Math.max(0,n)),"ce"),Ke=m((n,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=Se(n.offsetMs/e*100),a=n.durationMs/e*100,l=Math.max(Pe,Math.min(Se(a),100-t));return{leftPercent:t,widthPercent:l}},"Ce"),De=m((n,e,t=!1)=>{let a=e.trim().toLowerCase(),l=t?n.filter(r=>!r.ok):n;return a===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(a)||r.functionPath.toLowerCase().includes(a)||r.traceId.toLowerCase().includes(a)||r.spans.some(o=>o.name.toLowerCase().includes(a)||o.spanId.toLowerCase().includes(a)))},"Ee"),G=m(n=>Number.isFinite(n)?n>0&&n<1?`${n.toFixed(2)}ms`:`${String(Math.round(n))}ms`:"\u2014","q"),je=m(n=>!Number.isFinite(n)||n<=0?[]:Array.from({length:Ie},(e,t)=>{let a=(t+1)/Ie;return{label:G(n*a),percent:a*100}}),"Pe"),ke=m(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n,pe)}catch{return String(n)}},"ue"),ee=m(n=>{let e=(0,O.c)(7),{label:t,value:a}=n,l;e[0]!==t?(l=(0,s.jsx)("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==a?(r=(0,s.jsx)("dd",{className:"min-w-0 break-all",children:a}),e[2]=a,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=(0,s.jsxs)("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},"Y"),Fe=m(n=>{let e=(0,O.c)(68),{span:t}=n,a=U(),l,r,o,d,i,u;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==a){let $=Object.entries(t.attributes??{}),_;e[15]!==t.events?(_=t.events??[],e[15]=t.events,e[16]=_):_=e[16],l=_,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let y;e[17]!==a?(y=a("Span ID"),e[17]=a,e[18]=y):y=e[18];let w;e[19]!==t.spanId||e[20]!==y?(w=(0,s.jsx)(ee,{label:y,value:t.spanId}),e[19]=t.spanId,e[20]=y,e[21]=w):w=e[21];let M;e[22]!==a?(M=a("Parent span ID"),e[22]=a,e[23]=M):M=e[23];let p;e[24]!==t.parentSpanId||e[25]!==a?(p=t.parentSpanId===""?a("\u2014 (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=a,e[26]=p):p=e[26];let h;e[27]!==p||e[28]!==M?(h=(0,s.jsx)(ee,{label:M,value:p}),e[27]=p,e[28]=M,e[29]=h):h=e[29];let b;e[30]!==a?(b=a("Kind"),e[30]=a,e[31]=b):b=e[31];let C=t.kind??"internal",S;e[32]!==b||e[33]!==C?(S=(0,s.jsx)(ee,{label:b,value:C}),e[32]=b,e[33]=C,e[34]=S):S=e[34];let I;e[35]!==a?(I=a("Started at"),e[35]=a,e[36]=I):I=e[36];let g;e[37]!==t.offsetMs||e[38]!==a?(g=a("+{offset}",{offset:G(t.offsetMs)}),e[37]=t.offsetMs,e[38]=a,e[39]=g):g=e[39];let x;e[40]!==I||e[41]!==g?(x=(0,s.jsx)(ee,{label:I,value:g}),e[40]=I,e[41]=g,e[42]=x):x=e[42];let k;e[43]!==a?(k=a("Duration"),e[43]=a,e[44]=k):k=e[44];let f;e[45]!==t.durationMs?(f=G(t.durationMs),e[45]=t.durationMs,e[46]=f):f=e[46];let N;e[47]!==k||e[48]!==f?(N=(0,s.jsx)(ee,{label:k,value:f}),e[47]=k,e[48]=f,e[49]=N):N=e[49],e[50]!==h||e[51]!==S||e[52]!==x||e[53]!==N||e[54]!==w?(d=(0,s.jsxs)("dl",{className:"flex flex-col gap-1",children:[w,h,S,x,N]}),e[50]=h,e[51]=S,e[52]=x,e[53]=N,e[54]=w,e[55]=d):d=e[55],e[56]!==t.error?(i=t.error!==void 0&&(0,s.jsxs)("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[(0,s.jsx)("span",{className:"font-semibold text-destructive",children:t.error.type}),(0,s.jsx)("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=i):i=e[57],u=$.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Attributes")}),(0,s.jsx)("dl",{className:"flex flex-col gap-1",children:$.map(Ee)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=a,e[9]=l,e[10]=r,e[11]=o,e[12]=d,e[13]=i,e[14]=u}else l=e[9],r=e[10],o=e[11],d=e[12],i=e[13],u=e[14];let c;e[58]!==l||e[59]!==a?(c=l.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-events",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Events")}),(0,s.jsx)("ul",{className:"flex flex-col gap-1",children:l.map(Oe)})]}),e[58]=l,e[59]=a,e[60]=c):c=e[60];let v;return e[61]!==r||e[62]!==o||e[63]!==d||e[64]!==i||e[65]!==u||e[66]!==c?(v=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,i,u,c]}),e[61]=r,e[62]=o,e[63]=d,e[64]=i,e[65]=u,e[66]=c,e[67]=v):v=e[67],v},"Fe");function Ee(n){let[e,t]=n;return(0,s.jsx)(ee,{label:e,value:ke(t)},e)}m(Ee,"Ke");function Ae(n){let[e,t]=n;return`${e}=${ke(t)}`}m(Ae,"Re");function Oe(n){return(0,s.jsxs)("li",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:de(n.ts)}),(0,s.jsx)(oe,{variant:"secondary",children:n.name}),(0,s.jsx)("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(n.attributes??{}).map(Ae).join(" ")})]},`${n.name}:${String(n.ts)}`)}m(Oe,"Ae");var Be=14,_e="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",We=m(n=>{let e=(0,O.c)(17),{traceDurationMs:t}=n,a,l,r,o,d,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{let v=je(t);if(v.length===0){i=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=te(_e,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)("span",{}),e[8]=d):d=e[8],a="relative h-3",l=v.map(Je)}e[0]=t,e[1]=a,e[2]=l,e[3]=r,e[4]=o,e[5]=d,e[6]=i}else a=e[1],l=e[2],r=e[3],o=e[4],d=e[5],i=e[6];if(i!==Symbol.for("react.early_return_sentinel"))return i;let u;e[9]!==a||e[10]!==l?(u=(0,s.jsx)("span",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=u):u=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==d||e[15]!==u?(c=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,u]}),e[12]=r,e[13]=o,e[14]=d,e[15]=u,e[16]=c):c=e[16],c},"je"),qe=m(n=>{let e=(0,O.c)(60),{span:t,traceDurationMs:a}=n,l=U(),[r,o]=(0,A.useState)(!1),d;e[0]!==t||e[1]!==a?(d=Ke(t,a),e[0]=t,e[1]=a,e[2]=d):d=e[2];let{leftPercent:i,widthPercent:u}=d,c;e[3]!==t.attributes?(c=ve(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];let v=c,$=t.depth*Be,_;e[5]!==$?(_={paddingLeft:$},e[5]=$,e[6]=_):_=e[6];let y=_,w=`${String(i)}%`,M=`${String(u)}%`,p;e[7]!==w||e[8]!==M?(p={left:w,width:M},e[7]=w,e[8]=M,e[9]=p):p=e[9];let h=p,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=m(()=>{o(Ue)},"h"),e[10]=b):b=e[10];let C=b,S=t.depth,I=`tr-span-detail-${t.spanId}`,g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:G(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:G(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=te(_e,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=x):x=e[17];let k=`tr-span-toggle-${t.spanId}`,f;e[18]!==t.ok?(f=t.ok?null:(0,s.jsx)("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"\u25CF"}),e[18]=t.ok,e[19]=f):f=e[19];let N;e[20]!==y||e[21]!==t.name||e[22]!==f?(N=(0,s.jsxs)("span",{className:"truncate",style:y,title:t.name,children:[f,t.name]}),e[20]=y,e[21]=t.name,e[22]=f,e[23]=N):N=e[23];let B=t.ok?"bg-primary/70":"bg-destructive",L;e[24]!==B?(L=te("absolute inset-y-0 rounded-sm",B),e[24]=B,e[25]=L):L=e[25];let E;e[26]!==h||e[27]!==i||e[28]!==L||e[29]!==u?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:(0,s.jsx)("span",{className:L,"data-left":i,"data-testid":"tr-span-bar","data-width":u,style:h})}),e[26]=h,e[27]=i,e[28]=L,e[29]=u,e[30]=E):E=e[30];let W;e[31]!==t.durationMs?(W=G(t.durationMs),e[31]=t.durationMs,e[32]=W):W=e[32];let D;e[33]!==W?(D=(0,s.jsx)("span",{className:"text-right tabular-nums text-muted-foreground",children:W}),e[33]=W,e[34]=D):D=e[34];let q;e[35]!==t.error?(q=t.error===void 0?null:(0,s.jsx)("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]=q):q=e[36];let T;e[37]!==q?(T=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:q}),e[37]=q,e[38]=T):T=e[38];let z;e[39]!==v?(z=v===""?null:(0,s.jsx)("span",{"data-testid":"tr-span-attributes",title:v,children:v}),e[39]=v,e[40]=z):z=e[40];let P;e[41]!==z?(P=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:z}),e[41]=z,e[42]=P):P=e[42];let J;e[43]!==r||e[44]!==I||e[45]!==g||e[46]!==k||e[47]!==N||e[48]!==E||e[49]!==D||e[50]!==T||e[51]!==P?(J=(0,s.jsxs)("button",{"aria-controls":I,"aria-expanded":r,"aria-label":g,className:x,"data-testid":k,onClick:C,type:"button",children:[N,E,D,T,P]}),e[43]=r,e[44]=I,e[45]=g,e[46]=k,e[47]=N,e[48]=E,e[49]=D,e[50]=T,e[51]=P,e[52]=J):J=e[52];let j;e[53]!==r||e[54]!==t?(j=r&&(0,s.jsx)("div",{id:`tr-span-detail-${t.spanId}`,children:(0,s.jsx)(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=j):j=e[55];let K;return e[56]!==t.depth||e[57]!==J||e[58]!==j?(K=(0,s.jsxs)("li",{"data-depth":S,"data-testid":"tr-span-row",children:[J,j]}),e[56]=t.depth,e[57]=J,e[58]=j,e[59]=K):K=e[59],K},"Be"),ze=m(n=>{let e=(0,O.c)(15),{durationMs:t,spans:a}=n,l=U(),r;e[0]!==t?(r=(0,s.jsx)(We,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let d;if(e[4]!==t||e[5]!==a){let c;e[7]!==t?(c=m(v=>(0,s.jsx)(qe,{span:v,traceDurationMs:t},v.spanId),"c"),e[7]=t,e[8]=c):c=e[8],d=a.map(c),e[4]=t,e[5]=a,e[6]=d}else d=e[6];let i;e[9]!==o||e[10]!==d?(i=(0,s.jsx)("ul",{"aria-label":o,children:d}),e[9]=o,e[10]=d,e[11]=i):i=e[11];let u;return e[12]!==r||e[13]!==i?(u=(0,s.jsxs)(s.Fragment,{children:[r,i]}),e[12]=r,e[13]=i,e[14]=u):u=e[14],u},"Oe");function Je(n){return(0,s.jsx)("span",{className:te("absolute inset-y-0 border-l border-border/70",n.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(n.percent)}%`},children:n.label},n.percent)}m(Je,"We");function Ue(n){return!n}m(Ue,"Ue");var Ge=m(n=>Array.isArray(n?.traces)?n.traces:[],"qe"),He=m(n=>{let e=(0,O.c)(12),{entries:t}=n,a=U(),l;e[0]!==t.length||e[1]!==a?(l=a("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=a,e[2]=l):l=e[2];let r;e[3]!==l?(r=(0,s.jsx)("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(Ve),e[5]=t,e[6]=o):o=e[6];let d;e[7]!==o?(d=(0,s.jsx)("div",{role:"grid",children:o}),e[7]=o,e[8]=d):d=e[8];let i;return e[9]!==r||e[10]!==d?(i=(0,s.jsxs)("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,d]}),e[9]=r,e[10]=d,e[11]=i):i=e[11],i},"ze"),Qe=m(n=>{let e=(0,O.c)(50),{expanded:t,logs:a,onToggle:l,trace:r}=n,o=U(),d;e[0]!==l||e[1]!==r.traceId?(d=m(()=>{l(r.traceId)},"i"),e[0]=l,e[1]=r.traceId,e[2]=d):d=e[2];let i=d,u=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,v=`tr-toggle-${r.traceId}`,$=t?"\u25BE":"\u25B8",_;e[3]!==$?(_=(0,s.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=_):_=e[4];let y;e[5]!==r.rootName?(y=(0,s.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=y):y=e[6];let w;e[7]!==r.functionPath?(w=(0,s.jsx)("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 M;e[9]!==r.durationMs?(M=G(r.durationMs),e[9]=r.durationMs,e[10]=M):M=e[10];let p;e[11]!==M?(p=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:M}),e[11]=M,e[12]=p):p=e[12];let h;e[13]!==o||e[14]!==r.spans.length?(h=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=h):h=e[15];let b;e[16]!==h?(b=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:h}),e[16]=h,e[17]=b):b=e[17];let C=r.ok?"secondary":"destructive",S;e[18]!==o||e[19]!==r.ok?(S=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=S):S=e[20];let I;e[21]!==C||e[22]!==S?(I=(0,s.jsx)("span",{className:"shrink-0",children:(0,s.jsx)(oe,{variant:C,children:S})}),e[21]=C,e[22]=S,e[23]=I):I=e[23];let g;e[24]!==r.startTs?(g=de(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let x;e[26]!==g?(x=(0,s.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=x):x=e[27];let k;e[28]!==t||e[29]!==i||e[30]!==p||e[31]!==b||e[32]!==I||e[33]!==x||e[34]!==c||e[35]!==v||e[36]!==_||e[37]!==y||e[38]!==w?(k=(0,s.jsxs)("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":v,onClick:i,type:"button",children:[_,y,w,p,b,I,x]}),e[28]=t,e[29]=i,e[30]=p,e[31]=b,e[32]=I,e[33]=x,e[34]=c,e[35]=v,e[36]=_,e[37]=y,e[38]=w,e[39]=k):k=e[39];let f;e[40]!==t||e[41]!==a||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(f=t&&(0,s.jsxs)("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[(0,s.jsx)(ze,{durationMs:r.durationMs,spans:r.spans}),a.length>0&&(0,s.jsx)(He,{entries:a})]}),e[40]=t,e[41]=a,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=f):f=e[45];let N;return e[46]!==k||e[47]!==f||e[48]!==u?(N=(0,s.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":u,children:[k,f]}),e[46]=k,e[47]=f,e[48]=u,e[49]=N):N=e[49],N},"Ge"),bt=m(n=>{let e=(0,O.c)(58),{initialShardKey:t}=n,a=U(),[l]=(0,A.useState)(ye),{queryShardKey:r,setShardKey:o,shardKey:d}=be(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[i,u]=(0,A.useState)(l?.traceId??""),[c,v]=(0,A.useState)(!1),[$,_]=(0,A.useState)(Xe),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],(0,A.useEffect)(Ye,y);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];let M;e[2]!==r?(M={live:!0,shardKey:r},e[2]=r,e[3]=M):M=e[3];let{data:p,error:h,errorSource:b,isLoading:C,liveError:S}=ie(ce.getTraces,w,M),I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I={},e[4]=I):I=e[4];let g=$.size>0,x;e[5]!==r||e[6]!==g?(x={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=x):x=e[7];let{data:k}=ie(ce.getLogs,I,x),f,N;e[8]!==p||e[9]!==r?(f=m(()=>{p!==void 0&&he(r)},"p"),N=[p,r],e[8]=p,e[9]=r,e[10]=f,e[11]=N):(f=e[10],N=e[11]),(0,A.useEffect)(f,N);let B;if(e[12]!==p||e[13]!==h||e[14]!==b||e[15]!==$||e[16]!==C||e[17]!==S||e[18]!==k?.entries||e[19]!==c||e[20]!==i||e[21]!==o||e[22]!==d||e[23]!==a){let L=Ge(p),E=p?.total??L.length,W=E>L.length,D=De(L,i,c),q=Map.groupBy((k?.entries??[]).toReversed(),Ze),T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=m(F=>{u(F.target.value)},"C"),e[25]=T):T=e[25];let z=T,P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=m(F=>{_($e=>{let ne=new Set($e);return ne.has(F)?ne.delete(F):ne.add(F),ne})},"E"),e[26]=P):P=e[26];let J=P,j=h===null&&D.length===0&&!C,K;e[27]!==o||e[28]!==d?(K=(0,s.jsx)(fe,{onChange:o,testId:"tr-shard-input",value:d}),e[27]=o,e[28]=d,e[29]=K):K=e[29];let H;e[30]!==a?(H=a("Search traces"),e[30]=a,e[31]=H):H=e[31];let Q;e[32]!==a?(Q=a("search trace, span, or function"),e[32]=a,e[33]=Q):Q=e[33];let V;e[34]!==i||e[35]!==H||e[36]!==Q?(V=(0,s.jsx)(me,{"aria-label":H,className:"h-8 w-56","data-testid":"tr-search",onChange:z,placeholder:Q,value:i}),e[34]=i,e[35]=H,e[36]=Q,e[37]=V):V=e[37];let X;e[38]!==c?(X=(0,s.jsx)(xe,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:v}),e[38]=c,e[39]=X):X=e[39];let Y;e[40]!==a?(Y=a("Errors only"),e[40]=a,e[41]=Y):Y=e[41];let Z;e[42]!==X||e[43]!==Y?(Z=(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[X,Y]}),e[42]=X,e[43]=Y,e[44]=Z):Z=e[44];let R;e[45]!==S?(R=(0,s.jsx)(Ne,{message:S,prefix:"tr"}),e[45]=S,e[46]=R):R=e[46];let re;e[47]!==K||e[48]!==V||e[49]!==Z||e[50]!==R?(re=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[K,V,Z,R]}),e[47]=K,e[48]=V,e[49]=Z,e[50]=R,e[51]=re):re=e[51];let ae;e[52]!==h||e[53]!==b?(ae=h!==null&&(0,s.jsx)(ge,{error:b,testId:"tr-error"}),e[52]=h,e[53]=b,e[54]=ae):ae=e[54];let se;e[55]!==j||e[56]!==a?(se=j&&(0,s.jsx)(ue,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[55]=j,e[56]=a,e[57]=se):se=e[57],B=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[re,ae,se,h===null&&W&&(0,s.jsx)("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:L.length,total:E})}),h===null&&D.length>0&&(0,s.jsx)("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:D.map(F=>(0,s.jsx)(Qe,{expanded:$.has(F.traceId),logs:q.get(F.traceId)??[],onToggle:J,trace:F},F.traceId))})]}),e[12]=p,e[13]=h,e[14]=b,e[15]=$,e[16]=C,e[17]=S,e[18]=k?.entries,e[19]=c,e[20]=i,e[21]=o,e[22]=d,e[23]=a,e[24]=B}else B=e[24];return B},"bt");function Ve(n,e){return(0,s.jsx)("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:(0,s.jsx)(Me,{entry:n})},`${String(e)}:${String(n.timestamp)}`)}m(Ve,"He");function Xe(){return new Set}m(Xe,"Je");function Ye(){we()}m(Ye,"Qe");function Ze(n){return n.traceId}m(Ze,"Ve");export{bt as default};
|
|
1
|
+
import{b as Me}from"./chunk-EIISOYGA.js";import{a as ve}from"./chunk-RPQL45FL.js";import{b as ye,c as we}from"./chunk-4GTO7FL5.js";import{a as xe}from"./chunk-3FBLWUXD.js";import{a as Ne}from"./chunk-Z5O2NQAV.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as be}from"./chunk-S3CRZLGS.js";import{a as fe}from"./chunk-EJSI4PMU.js";import{b as he}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as me}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as oe}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ge}from"./chunk-ZVJOW25X.js";import"./chunk-ULIQFBZU.js";import"./chunk-46EQO6E7.js";import"./chunk-35DM4JJG.js";import{a as ce}from"./chunk-4ZEL6BYL.js";import{c as ie}from"./chunk-FZ5ZSUA2.js";import"./chunk-PG7XHMUR.js";import"./chunk-FSRSK4LY.js";import"./chunk-5ICUJ4IA.js";import{a as ue}from"./chunk-FKVZRPV5.js";import{d as U,m as pe,t as de}from"./chunk-PTZD7RUZ.js";import{a as m,d as le,e as Ce,f as Le,g as Te,i as te}from"./chunk-YKXDMIHQ.js";var O=le(Le(),1),A=le(Ce(),1);var s=le(Te(),1);var Pe=.5,Ie=4,Se=m(n=>Math.min(100,Math.max(0,n)),"ce"),Ke=m((n,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=Se(n.offsetMs/e*100),a=n.durationMs/e*100,l=Math.max(Pe,Math.min(Se(a),100-t));return{leftPercent:t,widthPercent:l}},"Ce"),De=m((n,e,t=!1)=>{let a=e.trim().toLowerCase(),l=t?n.filter(r=>!r.ok):n;return a===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(a)||r.functionPath.toLowerCase().includes(a)||r.traceId.toLowerCase().includes(a)||r.spans.some(o=>o.name.toLowerCase().includes(a)||o.spanId.toLowerCase().includes(a)))},"Ee"),G=m(n=>Number.isFinite(n)?n>0&&n<1?`${n.toFixed(2)}ms`:`${String(Math.round(n))}ms`:"\u2014","q"),je=m(n=>!Number.isFinite(n)||n<=0?[]:Array.from({length:Ie},(e,t)=>{let a=(t+1)/Ie;return{label:G(n*a),percent:a*100}}),"Pe"),ke=m(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n,pe)}catch{return String(n)}},"ue"),ee=m(n=>{let e=(0,O.c)(7),{label:t,value:a}=n,l;e[0]!==t?(l=(0,s.jsx)("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==a?(r=(0,s.jsx)("dd",{className:"min-w-0 break-all",children:a}),e[2]=a,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=(0,s.jsxs)("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},"Y"),Fe=m(n=>{let e=(0,O.c)(68),{span:t}=n,a=U(),l,r,o,d,i,u;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==a){let $=Object.entries(t.attributes??{}),_;e[15]!==t.events?(_=t.events??[],e[15]=t.events,e[16]=_):_=e[16],l=_,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let y;e[17]!==a?(y=a("Span ID"),e[17]=a,e[18]=y):y=e[18];let w;e[19]!==t.spanId||e[20]!==y?(w=(0,s.jsx)(ee,{label:y,value:t.spanId}),e[19]=t.spanId,e[20]=y,e[21]=w):w=e[21];let M;e[22]!==a?(M=a("Parent span ID"),e[22]=a,e[23]=M):M=e[23];let p;e[24]!==t.parentSpanId||e[25]!==a?(p=t.parentSpanId===""?a("\u2014 (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=a,e[26]=p):p=e[26];let h;e[27]!==p||e[28]!==M?(h=(0,s.jsx)(ee,{label:M,value:p}),e[27]=p,e[28]=M,e[29]=h):h=e[29];let b;e[30]!==a?(b=a("Kind"),e[30]=a,e[31]=b):b=e[31];let C=t.kind??"internal",S;e[32]!==b||e[33]!==C?(S=(0,s.jsx)(ee,{label:b,value:C}),e[32]=b,e[33]=C,e[34]=S):S=e[34];let I;e[35]!==a?(I=a("Started at"),e[35]=a,e[36]=I):I=e[36];let g;e[37]!==t.offsetMs||e[38]!==a?(g=a("+{offset}",{offset:G(t.offsetMs)}),e[37]=t.offsetMs,e[38]=a,e[39]=g):g=e[39];let x;e[40]!==I||e[41]!==g?(x=(0,s.jsx)(ee,{label:I,value:g}),e[40]=I,e[41]=g,e[42]=x):x=e[42];let k;e[43]!==a?(k=a("Duration"),e[43]=a,e[44]=k):k=e[44];let f;e[45]!==t.durationMs?(f=G(t.durationMs),e[45]=t.durationMs,e[46]=f):f=e[46];let N;e[47]!==k||e[48]!==f?(N=(0,s.jsx)(ee,{label:k,value:f}),e[47]=k,e[48]=f,e[49]=N):N=e[49],e[50]!==h||e[51]!==S||e[52]!==x||e[53]!==N||e[54]!==w?(d=(0,s.jsxs)("dl",{className:"flex flex-col gap-1",children:[w,h,S,x,N]}),e[50]=h,e[51]=S,e[52]=x,e[53]=N,e[54]=w,e[55]=d):d=e[55],e[56]!==t.error?(i=t.error!==void 0&&(0,s.jsxs)("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[(0,s.jsx)("span",{className:"font-semibold text-destructive",children:t.error.type}),(0,s.jsx)("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=i):i=e[57],u=$.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Attributes")}),(0,s.jsx)("dl",{className:"flex flex-col gap-1",children:$.map(Ee)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=a,e[9]=l,e[10]=r,e[11]=o,e[12]=d,e[13]=i,e[14]=u}else l=e[9],r=e[10],o=e[11],d=e[12],i=e[13],u=e[14];let c;e[58]!==l||e[59]!==a?(c=l.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-events",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Events")}),(0,s.jsx)("ul",{className:"flex flex-col gap-1",children:l.map(Oe)})]}),e[58]=l,e[59]=a,e[60]=c):c=e[60];let v;return e[61]!==r||e[62]!==o||e[63]!==d||e[64]!==i||e[65]!==u||e[66]!==c?(v=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,i,u,c]}),e[61]=r,e[62]=o,e[63]=d,e[64]=i,e[65]=u,e[66]=c,e[67]=v):v=e[67],v},"Fe");function Ee(n){let[e,t]=n;return(0,s.jsx)(ee,{label:e,value:ke(t)},e)}m(Ee,"Ke");function Ae(n){let[e,t]=n;return`${e}=${ke(t)}`}m(Ae,"Re");function Oe(n){return(0,s.jsxs)("li",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:de(n.ts)}),(0,s.jsx)(oe,{variant:"secondary",children:n.name}),(0,s.jsx)("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(n.attributes??{}).map(Ae).join(" ")})]},`${n.name}:${String(n.ts)}`)}m(Oe,"Ae");var Be=14,_e="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",We=m(n=>{let e=(0,O.c)(17),{traceDurationMs:t}=n,a,l,r,o,d,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{let v=je(t);if(v.length===0){i=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=te(_e,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)("span",{}),e[8]=d):d=e[8],a="relative h-3",l=v.map(Je)}e[0]=t,e[1]=a,e[2]=l,e[3]=r,e[4]=o,e[5]=d,e[6]=i}else a=e[1],l=e[2],r=e[3],o=e[4],d=e[5],i=e[6];if(i!==Symbol.for("react.early_return_sentinel"))return i;let u;e[9]!==a||e[10]!==l?(u=(0,s.jsx)("span",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=u):u=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==d||e[15]!==u?(c=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,u]}),e[12]=r,e[13]=o,e[14]=d,e[15]=u,e[16]=c):c=e[16],c},"je"),qe=m(n=>{let e=(0,O.c)(60),{span:t,traceDurationMs:a}=n,l=U(),[r,o]=(0,A.useState)(!1),d;e[0]!==t||e[1]!==a?(d=Ke(t,a),e[0]=t,e[1]=a,e[2]=d):d=e[2];let{leftPercent:i,widthPercent:u}=d,c;e[3]!==t.attributes?(c=ve(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];let v=c,$=t.depth*Be,_;e[5]!==$?(_={paddingLeft:$},e[5]=$,e[6]=_):_=e[6];let y=_,w=`${String(i)}%`,M=`${String(u)}%`,p;e[7]!==w||e[8]!==M?(p={left:w,width:M},e[7]=w,e[8]=M,e[9]=p):p=e[9];let h=p,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=m(()=>{o(Ue)},"h"),e[10]=b):b=e[10];let C=b,S=t.depth,I=`tr-span-detail-${t.spanId}`,g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:G(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:G(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=te(_e,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=x):x=e[17];let k=`tr-span-toggle-${t.spanId}`,f;e[18]!==t.ok?(f=t.ok?null:(0,s.jsx)("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"\u25CF"}),e[18]=t.ok,e[19]=f):f=e[19];let N;e[20]!==y||e[21]!==t.name||e[22]!==f?(N=(0,s.jsxs)("span",{className:"truncate",style:y,title:t.name,children:[f,t.name]}),e[20]=y,e[21]=t.name,e[22]=f,e[23]=N):N=e[23];let B=t.ok?"bg-primary/70":"bg-destructive",L;e[24]!==B?(L=te("absolute inset-y-0 rounded-sm",B),e[24]=B,e[25]=L):L=e[25];let E;e[26]!==h||e[27]!==i||e[28]!==L||e[29]!==u?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:(0,s.jsx)("span",{className:L,"data-left":i,"data-testid":"tr-span-bar","data-width":u,style:h})}),e[26]=h,e[27]=i,e[28]=L,e[29]=u,e[30]=E):E=e[30];let W;e[31]!==t.durationMs?(W=G(t.durationMs),e[31]=t.durationMs,e[32]=W):W=e[32];let D;e[33]!==W?(D=(0,s.jsx)("span",{className:"text-right tabular-nums text-muted-foreground",children:W}),e[33]=W,e[34]=D):D=e[34];let q;e[35]!==t.error?(q=t.error===void 0?null:(0,s.jsx)("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]=q):q=e[36];let T;e[37]!==q?(T=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:q}),e[37]=q,e[38]=T):T=e[38];let z;e[39]!==v?(z=v===""?null:(0,s.jsx)("span",{"data-testid":"tr-span-attributes",title:v,children:v}),e[39]=v,e[40]=z):z=e[40];let P;e[41]!==z?(P=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:z}),e[41]=z,e[42]=P):P=e[42];let J;e[43]!==r||e[44]!==I||e[45]!==g||e[46]!==k||e[47]!==N||e[48]!==E||e[49]!==D||e[50]!==T||e[51]!==P?(J=(0,s.jsxs)("button",{"aria-controls":I,"aria-expanded":r,"aria-label":g,className:x,"data-testid":k,onClick:C,type:"button",children:[N,E,D,T,P]}),e[43]=r,e[44]=I,e[45]=g,e[46]=k,e[47]=N,e[48]=E,e[49]=D,e[50]=T,e[51]=P,e[52]=J):J=e[52];let j;e[53]!==r||e[54]!==t?(j=r&&(0,s.jsx)("div",{id:`tr-span-detail-${t.spanId}`,children:(0,s.jsx)(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=j):j=e[55];let K;return e[56]!==t.depth||e[57]!==J||e[58]!==j?(K=(0,s.jsxs)("li",{"data-depth":S,"data-testid":"tr-span-row",children:[J,j]}),e[56]=t.depth,e[57]=J,e[58]=j,e[59]=K):K=e[59],K},"Be"),ze=m(n=>{let e=(0,O.c)(15),{durationMs:t,spans:a}=n,l=U(),r;e[0]!==t?(r=(0,s.jsx)(We,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let d;if(e[4]!==t||e[5]!==a){let c;e[7]!==t?(c=m(v=>(0,s.jsx)(qe,{span:v,traceDurationMs:t},v.spanId),"c"),e[7]=t,e[8]=c):c=e[8],d=a.map(c),e[4]=t,e[5]=a,e[6]=d}else d=e[6];let i;e[9]!==o||e[10]!==d?(i=(0,s.jsx)("ul",{"aria-label":o,children:d}),e[9]=o,e[10]=d,e[11]=i):i=e[11];let u;return e[12]!==r||e[13]!==i?(u=(0,s.jsxs)(s.Fragment,{children:[r,i]}),e[12]=r,e[13]=i,e[14]=u):u=e[14],u},"Oe");function Je(n){return(0,s.jsx)("span",{className:te("absolute inset-y-0 border-l border-border/70",n.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(n.percent)}%`},children:n.label},n.percent)}m(Je,"We");function Ue(n){return!n}m(Ue,"Ue");var Ge=m(n=>Array.isArray(n?.traces)?n.traces:[],"qe"),He=m(n=>{let e=(0,O.c)(12),{entries:t}=n,a=U(),l;e[0]!==t.length||e[1]!==a?(l=a("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=a,e[2]=l):l=e[2];let r;e[3]!==l?(r=(0,s.jsx)("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(Ve),e[5]=t,e[6]=o):o=e[6];let d;e[7]!==o?(d=(0,s.jsx)("div",{role:"grid",children:o}),e[7]=o,e[8]=d):d=e[8];let i;return e[9]!==r||e[10]!==d?(i=(0,s.jsxs)("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,d]}),e[9]=r,e[10]=d,e[11]=i):i=e[11],i},"ze"),Qe=m(n=>{let e=(0,O.c)(50),{expanded:t,logs:a,onToggle:l,trace:r}=n,o=U(),d;e[0]!==l||e[1]!==r.traceId?(d=m(()=>{l(r.traceId)},"i"),e[0]=l,e[1]=r.traceId,e[2]=d):d=e[2];let i=d,u=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,v=`tr-toggle-${r.traceId}`,$=t?"\u25BE":"\u25B8",_;e[3]!==$?(_=(0,s.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=_):_=e[4];let y;e[5]!==r.rootName?(y=(0,s.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=y):y=e[6];let w;e[7]!==r.functionPath?(w=(0,s.jsx)("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 M;e[9]!==r.durationMs?(M=G(r.durationMs),e[9]=r.durationMs,e[10]=M):M=e[10];let p;e[11]!==M?(p=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:M}),e[11]=M,e[12]=p):p=e[12];let h;e[13]!==o||e[14]!==r.spans.length?(h=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=h):h=e[15];let b;e[16]!==h?(b=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:h}),e[16]=h,e[17]=b):b=e[17];let C=r.ok?"secondary":"destructive",S;e[18]!==o||e[19]!==r.ok?(S=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=S):S=e[20];let I;e[21]!==C||e[22]!==S?(I=(0,s.jsx)("span",{className:"shrink-0",children:(0,s.jsx)(oe,{variant:C,children:S})}),e[21]=C,e[22]=S,e[23]=I):I=e[23];let g;e[24]!==r.startTs?(g=de(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let x;e[26]!==g?(x=(0,s.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=x):x=e[27];let k;e[28]!==t||e[29]!==i||e[30]!==p||e[31]!==b||e[32]!==I||e[33]!==x||e[34]!==c||e[35]!==v||e[36]!==_||e[37]!==y||e[38]!==w?(k=(0,s.jsxs)("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":v,onClick:i,type:"button",children:[_,y,w,p,b,I,x]}),e[28]=t,e[29]=i,e[30]=p,e[31]=b,e[32]=I,e[33]=x,e[34]=c,e[35]=v,e[36]=_,e[37]=y,e[38]=w,e[39]=k):k=e[39];let f;e[40]!==t||e[41]!==a||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(f=t&&(0,s.jsxs)("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[(0,s.jsx)(ze,{durationMs:r.durationMs,spans:r.spans}),a.length>0&&(0,s.jsx)(He,{entries:a})]}),e[40]=t,e[41]=a,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=f):f=e[45];let N;return e[46]!==k||e[47]!==f||e[48]!==u?(N=(0,s.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":u,children:[k,f]}),e[46]=k,e[47]=f,e[48]=u,e[49]=N):N=e[49],N},"Ge"),bt=m(n=>{let e=(0,O.c)(58),{initialShardKey:t}=n,a=U(),[l]=(0,A.useState)(ye),{queryShardKey:r,setShardKey:o,shardKey:d}=be(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[i,u]=(0,A.useState)(l?.traceId??""),[c,v]=(0,A.useState)(!1),[$,_]=(0,A.useState)(Xe),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],(0,A.useEffect)(Ye,y);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];let M;e[2]!==r?(M={live:!0,shardKey:r},e[2]=r,e[3]=M):M=e[3];let{data:p,error:h,errorSource:b,isLoading:C,liveError:S}=ie(ce.getTraces,w,M),I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I={},e[4]=I):I=e[4];let g=$.size>0,x;e[5]!==r||e[6]!==g?(x={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=x):x=e[7];let{data:k}=ie(ce.getLogs,I,x),f,N;e[8]!==p||e[9]!==r?(f=m(()=>{p!==void 0&&he(r)},"p"),N=[p,r],e[8]=p,e[9]=r,e[10]=f,e[11]=N):(f=e[10],N=e[11]),(0,A.useEffect)(f,N);let B;if(e[12]!==p||e[13]!==h||e[14]!==b||e[15]!==$||e[16]!==C||e[17]!==S||e[18]!==k?.entries||e[19]!==c||e[20]!==i||e[21]!==o||e[22]!==d||e[23]!==a){let L=Ge(p),E=p?.total??L.length,W=E>L.length,D=De(L,i,c),q=Map.groupBy((k?.entries??[]).toReversed(),Ze),T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=m(F=>{u(F.target.value)},"C"),e[25]=T):T=e[25];let z=T,P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=m(F=>{_($e=>{let ne=new Set($e);return ne.has(F)?ne.delete(F):ne.add(F),ne})},"E"),e[26]=P):P=e[26];let J=P,j=h===null&&D.length===0&&!C,K;e[27]!==o||e[28]!==d?(K=(0,s.jsx)(fe,{onChange:o,testId:"tr-shard-input",value:d}),e[27]=o,e[28]=d,e[29]=K):K=e[29];let H;e[30]!==a?(H=a("Search traces"),e[30]=a,e[31]=H):H=e[31];let Q;e[32]!==a?(Q=a("search trace, span, or function"),e[32]=a,e[33]=Q):Q=e[33];let V;e[34]!==i||e[35]!==H||e[36]!==Q?(V=(0,s.jsx)(me,{"aria-label":H,className:"h-8 w-56","data-testid":"tr-search",onChange:z,placeholder:Q,value:i}),e[34]=i,e[35]=H,e[36]=Q,e[37]=V):V=e[37];let X;e[38]!==c?(X=(0,s.jsx)(xe,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:v}),e[38]=c,e[39]=X):X=e[39];let Y;e[40]!==a?(Y=a("Errors only"),e[40]=a,e[41]=Y):Y=e[41];let Z;e[42]!==X||e[43]!==Y?(Z=(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[X,Y]}),e[42]=X,e[43]=Y,e[44]=Z):Z=e[44];let R;e[45]!==S?(R=(0,s.jsx)(Ne,{message:S,prefix:"tr"}),e[45]=S,e[46]=R):R=e[46];let re;e[47]!==K||e[48]!==V||e[49]!==Z||e[50]!==R?(re=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[K,V,Z,R]}),e[47]=K,e[48]=V,e[49]=Z,e[50]=R,e[51]=re):re=e[51];let ae;e[52]!==h||e[53]!==b?(ae=h!==null&&(0,s.jsx)(ge,{error:b,testId:"tr-error"}),e[52]=h,e[53]=b,e[54]=ae):ae=e[54];let se;e[55]!==j||e[56]!==a?(se=j&&(0,s.jsx)(ue,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[55]=j,e[56]=a,e[57]=se):se=e[57],B=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[re,ae,se,h===null&&W&&(0,s.jsx)("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:L.length,total:E})}),h===null&&D.length>0&&(0,s.jsx)("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:D.map(F=>(0,s.jsx)(Qe,{expanded:$.has(F.traceId),logs:q.get(F.traceId)??[],onToggle:J,trace:F},F.traceId))})]}),e[12]=p,e[13]=h,e[14]=b,e[15]=$,e[16]=C,e[17]=S,e[18]=k?.entries,e[19]=c,e[20]=i,e[21]=o,e[22]=d,e[23]=a,e[24]=B}else B=e[24];return B},"bt");function Ve(n,e){return(0,s.jsx)("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:(0,s.jsx)(Me,{entry:n})},`${String(e)}:${String(n.timestamp)}`)}m(Ve,"He");function Xe(){return new Set}m(Xe,"Je");function Ye(){we()}m(Ye,"Qe");function Ze(n){return n.traceId}m(Ze,"Ve");export{bt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-FZ5ZSUA2.js";import{a as n}from"./chunk-YKXDMIHQ.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),c=Symbol("lunora.operationSeq"),_=n(t=>{if(typeof t!="object"||t===null)return;let e=t[c];return typeof e=="number"?e:void 0},"g"),d=n((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,c,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"h"),m=n(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"p"),h=n(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"O"),w=n(t=>new Proxy(t,{get(e,u,y){let i=Reflect.get(e,u,y);if(typeof i!="function"||typeof u!="string"||!g.has(u))return typeof i=="function"?i.bind(e):i;let f=i;return async(...o)=>{let l=m(o[0]);if(l===void 0)return f.apply(e,o);let p=typeof o[1]=="object"&&o[1]!==null?o[1]:{},a=s.start(l,p,h(o[2]));try{let r=await f.apply(e,o);return s.settle(a,{result:r}),r}catch(r){throw s.settle(a,{error:r instanceof Error?r.message:String(r)}),d(r,a),r}}}}),"E");export{_ as a,w as b};
|