@lunora/studio 1.0.0-alpha.378 → 1.0.0-alpha.379

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.
Files changed (114) hide show
  1. package/LICENSE.md +201 -104
  2. package/README.md +3 -3
  3. package/dist/index.d.mts +7 -1
  4. package/dist/index.d.ts +7 -1
  5. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  6. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  7. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  8. package/dist/packem_chunks/traces-panel.mjs +1 -1
  9. package/dist/packem_shared/log-fields-CV-9O0nh.mjs +8 -0
  10. package/dist/packem_shared/{log-line-DnvvQnY5.mjs → log-line-CYJQf6P-.mjs} +1 -1
  11. package/dist/standalone/{chunk-NOJMUWHR.js → chunk-26Y4MNET.js} +1 -1
  12. package/dist/standalone/{chunk-MFVL3BKJ.js → chunk-2JV4BRZM.js} +1 -1
  13. package/dist/standalone/{chunk-YU67D2FL.js → chunk-2VGEXP5J.js} +1 -1
  14. package/dist/standalone/{chunk-2Q66YTBU.js → chunk-2X6PKSX3.js} +1 -1
  15. package/dist/standalone/chunk-323KPWNK.js +1 -0
  16. package/dist/standalone/{chunk-FBG5SSXS.js → chunk-34RW2S7B.js} +1 -1
  17. package/dist/standalone/{chunk-2RL5YVB7.js → chunk-3TPV2LT4.js} +1 -1
  18. package/dist/standalone/{chunk-APTQ5BDE.js → chunk-3VY2JXUG.js} +1 -1
  19. package/dist/standalone/{chunk-3RZB5QXH.js → chunk-4PGWRKGR.js} +1 -1
  20. package/dist/standalone/{chunk-R6B5XFEW.js → chunk-4QHOCKKK.js} +1 -1
  21. package/dist/standalone/{chunk-LDWYV63L.js → chunk-4TMXSFYX.js} +1 -1
  22. package/dist/standalone/{chunk-UA7DC3LX.js → chunk-4UMUJTD2.js} +1 -1
  23. package/dist/standalone/{chunk-A6E46F3B.js → chunk-5JP3QEKB.js} +1 -1
  24. package/dist/standalone/{chunk-FXZ6GEUP.js → chunk-5SCMOA55.js} +1 -1
  25. package/dist/standalone/{chunk-O65MHZCA.js → chunk-5UBZVLHV.js} +1 -1
  26. package/dist/standalone/{chunk-F32O6VAS.js → chunk-5YAKHHWZ.js} +1 -1
  27. package/dist/standalone/{chunk-ZBP4ZBS6.js → chunk-6BZNUPWO.js} +1 -1
  28. package/dist/standalone/{chunk-ASSIQ4W7.js → chunk-6C5FR3EZ.js} +1 -1
  29. package/dist/standalone/{chunk-27YLJQRE.js → chunk-6I7FRZA3.js} +1 -1
  30. package/dist/standalone/{chunk-F2EGC6HE.js → chunk-6M3EQLUP.js} +1 -1
  31. package/dist/standalone/{chunk-YV6YBDCS.js → chunk-6ZMVAF2O.js} +1 -1
  32. package/dist/standalone/{chunk-MSZMSG3J.js → chunk-7BNAY62O.js} +1 -1
  33. package/dist/standalone/{chunk-6DKBHMBL.js → chunk-7LXTCC2A.js} +1 -1
  34. package/dist/standalone/{chunk-BMGCCYQL.js → chunk-7M5KSH56.js} +1 -1
  35. package/dist/standalone/{chunk-4YENBZSS.js → chunk-7VZFX5O4.js} +1 -1
  36. package/dist/standalone/{chunk-CXAPSZF2.js → chunk-AB7ELB6H.js} +1 -1
  37. package/dist/standalone/{chunk-KMEDIMYZ.js → chunk-AUF7N5CE.js} +1 -1
  38. package/dist/standalone/{chunk-JAY3ZKY6.js → chunk-AUGN55ZM.js} +1 -1
  39. package/dist/standalone/{chunk-FXSY2FCG.js → chunk-B2GQMLO3.js} +1 -1
  40. package/dist/standalone/{chunk-KEICHBPK.js → chunk-BFL76ZWW.js} +1 -1
  41. package/dist/standalone/{chunk-UL5GMSAW.js → chunk-C6ZJHEQT.js} +1 -1
  42. package/dist/standalone/{chunk-FPRVR763.js → chunk-CUUNHCMD.js} +1 -1
  43. package/dist/standalone/{chunk-KFDOGDD2.js → chunk-CYL7MEO2.js} +1 -1
  44. package/dist/standalone/{chunk-D5VO54BI.js → chunk-DM63RG6O.js} +1 -1
  45. package/dist/standalone/{chunk-JLPBW5EC.js → chunk-DR4FUUVD.js} +1 -1
  46. package/dist/standalone/{chunk-IIIAOQ22.js → chunk-DXX7OLWZ.js} +1 -1
  47. package/dist/standalone/{chunk-A5HJXHD2.js → chunk-E4XUNAKO.js} +1 -1
  48. package/dist/standalone/{chunk-V4D77Q45.js → chunk-EH3PU4PH.js} +1 -1
  49. package/dist/standalone/{chunk-2SWWUGUK.js → chunk-EYF7TFVA.js} +1 -1
  50. package/dist/standalone/{chunk-3PRGO2WY.js → chunk-FGUHYMGU.js} +1 -1
  51. package/dist/standalone/{chunk-R55GP52Y.js → chunk-FLMIY73E.js} +1 -1
  52. package/dist/standalone/{chunk-FNE6FFFN.js → chunk-FZLWUX7L.js} +1 -1
  53. package/dist/standalone/{chunk-N5A7KU32.js → chunk-FZSNE2IP.js} +1 -1
  54. package/dist/standalone/{chunk-J76P372V.js → chunk-GXKHIVIJ.js} +1 -1
  55. package/dist/standalone/{chunk-DQWEVUGA.js → chunk-HROJA6UV.js} +1 -1
  56. package/dist/standalone/{chunk-VY5KDMVO.js → chunk-I63W47HC.js} +1 -1
  57. package/dist/standalone/{chunk-A5INOAIL.js → chunk-IGIBOJJG.js} +1 -1
  58. package/dist/standalone/{chunk-4XNMLHOA.js → chunk-IKI4VXGN.js} +1 -1
  59. package/dist/standalone/{chunk-UVMD7C4J.js → chunk-IXBHUFDE.js} +1 -1
  60. package/dist/standalone/{chunk-SHTZR3TU.js → chunk-IYJF4GU7.js} +1 -1
  61. package/dist/standalone/{chunk-O5NP5MVG.js → chunk-IZQESKL2.js} +1 -1
  62. package/dist/standalone/chunk-JEKJEGBJ.js +33 -0
  63. package/dist/standalone/{chunk-ZK2HQFGQ.js → chunk-JO3JBEGB.js} +1 -1
  64. package/dist/standalone/{chunk-CB22PV3X.js → chunk-JXGB4QDO.js} +1 -1
  65. package/dist/standalone/{chunk-4I23RURI.js → chunk-KCIVTT2F.js} +1 -1
  66. package/dist/standalone/{chunk-UEM26EYR.js → chunk-KLS5BVVO.js} +1 -1
  67. package/dist/standalone/{chunk-NIGA74BG.js → chunk-KMNBBIIS.js} +1 -1
  68. package/dist/standalone/{chunk-X26D3KTK.js → chunk-KN4GQKJS.js} +1 -1
  69. package/dist/standalone/{chunk-IO3TEFOW.js → chunk-KNGEOOIV.js} +1 -1
  70. package/dist/standalone/{chunk-F5DCBRCJ.js → chunk-KY5SWGWS.js} +1 -1
  71. package/dist/standalone/{chunk-AKC4XWCD.js → chunk-L62S7I64.js} +1 -1
  72. package/dist/standalone/{chunk-CX2T7TTB.js → chunk-LH2SSK4J.js} +1 -1
  73. package/dist/standalone/chunk-LJLNIVUA.js +8 -0
  74. package/dist/standalone/{chunk-SZCXVIVT.js → chunk-LMGNMZUF.js} +1 -1
  75. package/dist/standalone/{chunk-ELXPUNSN.js → chunk-LUUXWTIY.js} +1 -1
  76. package/dist/standalone/{chunk-EA3RERQQ.js → chunk-M4GISIVK.js} +1 -1
  77. package/dist/standalone/{chunk-BR2A4DYH.js → chunk-MT3SPV45.js} +1 -1
  78. package/dist/standalone/{chunk-QEQGGAZQ.js → chunk-MUQCBR27.js} +1 -1
  79. package/dist/standalone/{chunk-6EPIINAW.js → chunk-N7ZOD63M.js} +1 -1
  80. package/dist/standalone/{chunk-BOYBN3TE.js → chunk-NHBHBDXG.js} +1 -1
  81. package/dist/standalone/{chunk-5G2OOLMF.js → chunk-O3NLXHWS.js} +1 -1
  82. package/dist/standalone/{chunk-UCOKDCSX.js → chunk-O3YJ437V.js} +1 -1
  83. package/dist/standalone/{chunk-W46UJQN7.js → chunk-OFTGFFZO.js} +1 -1
  84. package/dist/standalone/{chunk-W5LH6U6X.js → chunk-OOUGEUZ4.js} +1 -1
  85. package/dist/standalone/{chunk-SAV5V3DG.js → chunk-OW7PWUF6.js} +1 -1
  86. package/dist/standalone/{chunk-TU2IB3GT.js → chunk-P3QC3BR5.js} +1 -1
  87. package/dist/standalone/{chunk-NSPPZR3Q.js → chunk-PZIS5JIG.js} +1 -1
  88. package/dist/standalone/{chunk-VONBNFUJ.js → chunk-Q2AOMTCB.js} +1 -1
  89. package/dist/standalone/{chunk-H5AOMWTU.js → chunk-QFHYWVOO.js} +1 -1
  90. package/dist/standalone/{chunk-PLONGJJL.js → chunk-QUYKKLCH.js} +1 -1
  91. package/dist/standalone/{chunk-HNNAMZHQ.js → chunk-R7MTF7SJ.js} +1 -1
  92. package/dist/standalone/{chunk-PKOFJJA2.js → chunk-S2VF3IDK.js} +1 -1
  93. package/dist/standalone/{chunk-FFQISGOB.js → chunk-S2WOKV7Y.js} +1 -1
  94. package/dist/standalone/{chunk-6IECLZ2U.js → chunk-SCHOGXPE.js} +1 -1
  95. package/dist/standalone/{chunk-ZF4WXT7S.js → chunk-SD5JCGIU.js} +1 -1
  96. package/dist/standalone/{chunk-J7M7G2BA.js → chunk-UDGBH3IC.js} +1 -1
  97. package/dist/standalone/{chunk-66PQJM66.js → chunk-W7DGN5TF.js} +1 -1
  98. package/dist/standalone/{chunk-TOBQK3ZF.js → chunk-X7YDONJY.js} +1 -1
  99. package/dist/standalone/{chunk-TRJMN2YI.js → chunk-YCQ7ZPBP.js} +1 -1
  100. package/dist/standalone/{chunk-FGEN2V4E.js → chunk-YCRGSQOQ.js} +1 -1
  101. package/dist/standalone/{chunk-7MQI2RNF.js → chunk-YECCEZZT.js} +1 -1
  102. package/dist/standalone/{chunk-77PKR3WU.js → chunk-YIXBY57R.js} +1 -1
  103. package/dist/standalone/{chunk-SBY32RYL.js → chunk-YJOQFRGE.js} +1 -1
  104. package/dist/standalone/{chunk-3OVNOP65.js → chunk-YM56MNAN.js} +1 -1
  105. package/dist/standalone/{chunk-BMS6CAKT.js → chunk-YSJ6AQXN.js} +1 -1
  106. package/dist/standalone/{chunk-YZUJTBSJ.js → chunk-Z2373QYM.js} +1 -1
  107. package/dist/standalone/{chunk-YIOJWQ3G.js → chunk-ZLGK7CDZ.js} +1 -1
  108. package/dist/standalone/{chunk-FOURRGSO.js → chunk-ZVTDYI5T.js} +1 -1
  109. package/dist/standalone/studio.js +1 -1
  110. package/package.json +2 -2
  111. package/dist/packem_shared/log-fields-PjFFEqv0.mjs +0 -8
  112. package/dist/standalone/chunk-4S7ZIMWI.js +0 -33
  113. package/dist/standalone/chunk-BEC2C3JD.js +0 -1
  114. package/dist/standalone/chunk-DKEK4ZO6.js +0 -8
@@ -1 +1 @@
1
- import{a as C}from"./chunk-SZCXVIVT.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as $}from"./chunk-X26D3KTK.js";import{b as v}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as j}from"./chunk-UA7DC3LX.js";import"./chunk-KFDOGDD2.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-3OVNOP65.js";import"./chunk-UVMD7C4J.js";import"./chunk-FXSY2FCG.js";import"./chunk-EOFWXI3T.js";import{a as g}from"./chunk-LYVYUTQY.js";import{c as h}from"./chunk-AKC4XWCD.js";import{a as K,e as S}from"./chunk-CB22PV3X.js";import"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as T,w as F}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as oe}from"./chunk-A6TVTNKO.js";import{a as ne,b as ie}from"./chunk-ADABTCDI.js";import{a as d,d as k}from"./chunk-5PEAXTYQ.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):f&&b.length===0?x=(0,e.jsx)($,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(K,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,shardKey:s,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(K,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(S,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,shardKey:s,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),Z!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),x]})},"Ee");export{Te as default};
1
+ import{a as C}from"./chunk-LMGNMZUF.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as $}from"./chunk-KN4GQKJS.js";import{b as v}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as j}from"./chunk-4UMUJTD2.js";import"./chunk-CYL7MEO2.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-YM56MNAN.js";import"./chunk-IXBHUFDE.js";import"./chunk-B2GQMLO3.js";import"./chunk-EOFWXI3T.js";import{a as g}from"./chunk-LYVYUTQY.js";import{c as h}from"./chunk-L62S7I64.js";import{a as K,e as S}from"./chunk-JXGB4QDO.js";import"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as T,w as F}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as oe}from"./chunk-A6TVTNKO.js";import{a as ne,b as ie}from"./chunk-ADABTCDI.js";import{a as d,d as k}from"./chunk-5PEAXTYQ.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):f&&b.length===0?x=(0,e.jsx)($,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(K,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,shardKey:s,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(K,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(S,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,shardKey:s,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),Z!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),x]})},"Ee");export{Te as default};
@@ -1,4 +1,4 @@
1
- import{c as Ue}from"./chunk-R6NJ4ER6.js";import{a as ke}from"./chunk-2RL5YVB7.js";import{e as _e}from"./chunk-D5VO54BI.js";import"./chunk-BOYBN3TE.js";import"./chunk-YU67D2FL.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import{a as De}from"./chunk-W5LH6U6X.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as Ee}from"./chunk-5G2OOLMF.js";import"./chunk-EDL46BPM.js";import{a as $e}from"./chunk-V4D77Q45.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as Ke}from"./chunk-A5INOAIL.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ee}from"./chunk-SZCXVIVT.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as ve}from"./chunk-X26D3KTK.js";import{b as ae}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as Le,b as Ie,c as Re,d as de,e as te,f as X}from"./chunk-3OVNOP65.js";import{a as xe}from"./chunk-LYVYUTQY.js";import{a as Fe,e as Oe}from"./chunk-CB22PV3X.js";import{n as ze}from"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as Te,h as pe,i as be,j as le,o as ye,s as Z,v as je}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as yt}from"./chunk-A6TVTNKO.js";import{a as bt,b as xt}from"./chunk-ADABTCDI.js";import{a as h,d as ge}from"./chunk-5PEAXTYQ.js";var B=ge(yt(),1),z=ge(bt(),1);var o=ge(xt(),1);var Ae=h((d,e,t)=>{let{onCopy:r,onDelete:l,onDownload:n,onToggleSelect:c}=t,i=h(()=>{r(d.key)},"c"),s=h(()=>{n(d.key)},"o"),u=h(()=>{l(d.key)},"f"),m=h(()=>{c(d.key)},"h");return{copy:i,download:s,name:d.key.slice(e.length),remove:u,toggle:m}},"Re"),We=h(d=>{let e=(0,B.c)(31),{busy:t,buttonClassName:r,copied:l,objectKey:n,onCopy:c,onDelete:i,onDownload:s,t:u}=d,m=`storage-copy-${n}`,f;e[0]!==l||e[1]!==u?(f=u(l?"Copied":"Copy URL"),e[0]=l,e[1]=u,e[2]=f):f=e[2];let g;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==m||e[7]!==f?(g=(0,o.jsx)(ee,{className:r,"data-testid":m,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=m,e[7]=f,e[8]=g):g=e[8];let w=`storage-download-${n}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==s||e[14]!==w||e[15]!==a?(k=(0,o.jsx)(ee,{className:r,"data-testid":w,disabled:t,onClick:s,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=s,e[14]=w,e[15]=a,e[16]=k):k=e[16];let S;e[17]!==u?(S=u("Delete object?"),e[17]=u,e[18]=S):S=e[18];let x=`storage-delete-${n}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let y;e[21]!==t||e[22]!==i||e[23]!==S||e[24]!==x||e[25]!==b?(y=(0,o.jsx)($e,{confirmLabel:S,disabled:t,onConfirm:i,testId:x,children:b}),e[21]=t,e[22]=i,e[23]=S,e[24]=x,e[25]=b,e[26]=y):y=e[26];let v;return e[27]!==y||e[28]!==g||e[29]!==k?(v=(0,o.jsxs)(o.Fragment,{children:[g,k,y]}),e[27]=y,e[28]=g,e[29]=k,e[30]=v):v=e[30],v},"ze"),He=h(d=>{let e=(0,B.c)(14),{objectKey:t,references:r,t:l}=d;if(r===void 0)return null;if(r.length===0){let m=`storage-orphan-${t}`,f;e[0]!==l?(f=l("Orphan"),e[0]=l,e[1]=f):f=e[1];let g;return e[2]!==m||e[3]!==f?(g=(0,o.jsx)(ae,{"data-testid":m,variant:"warning",children:f}),e[2]=m,e[3]=f,e[4]=g):g=e[4],g}let n;e[5]!==r?(n=r.map(vt).join(`
1
+ import{c as Ue}from"./chunk-R6NJ4ER6.js";import{a as ke}from"./chunk-3TPV2LT4.js";import{e as _e}from"./chunk-DM63RG6O.js";import"./chunk-NHBHBDXG.js";import"./chunk-2VGEXP5J.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import{a as De}from"./chunk-OOUGEUZ4.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as Ee}from"./chunk-O3NLXHWS.js";import"./chunk-EDL46BPM.js";import{a as $e}from"./chunk-EH3PU4PH.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as Ke}from"./chunk-IGIBOJJG.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ee}from"./chunk-LMGNMZUF.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as ve}from"./chunk-KN4GQKJS.js";import{b as ae}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as Le,b as Ie,c as Re,d as de,e as te,f as X}from"./chunk-YM56MNAN.js";import{a as xe}from"./chunk-LYVYUTQY.js";import{a as Fe,e as Oe}from"./chunk-JXGB4QDO.js";import{n as ze}from"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as Te,h as pe,i as be,j as le,o as ye,s as Z,v as je}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as yt}from"./chunk-A6TVTNKO.js";import{a as bt,b as xt}from"./chunk-ADABTCDI.js";import{a as h,d as ge}from"./chunk-5PEAXTYQ.js";var B=ge(yt(),1),z=ge(bt(),1);var o=ge(xt(),1);var Ae=h((d,e,t)=>{let{onCopy:r,onDelete:l,onDownload:n,onToggleSelect:c}=t,i=h(()=>{r(d.key)},"c"),s=h(()=>{n(d.key)},"o"),u=h(()=>{l(d.key)},"f"),m=h(()=>{c(d.key)},"h");return{copy:i,download:s,name:d.key.slice(e.length),remove:u,toggle:m}},"Re"),We=h(d=>{let e=(0,B.c)(31),{busy:t,buttonClassName:r,copied:l,objectKey:n,onCopy:c,onDelete:i,onDownload:s,t:u}=d,m=`storage-copy-${n}`,f;e[0]!==l||e[1]!==u?(f=u(l?"Copied":"Copy URL"),e[0]=l,e[1]=u,e[2]=f):f=e[2];let g;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==m||e[7]!==f?(g=(0,o.jsx)(ee,{className:r,"data-testid":m,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=m,e[7]=f,e[8]=g):g=e[8];let w=`storage-download-${n}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==s||e[14]!==w||e[15]!==a?(k=(0,o.jsx)(ee,{className:r,"data-testid":w,disabled:t,onClick:s,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=s,e[14]=w,e[15]=a,e[16]=k):k=e[16];let S;e[17]!==u?(S=u("Delete object?"),e[17]=u,e[18]=S):S=e[18];let x=`storage-delete-${n}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let y;e[21]!==t||e[22]!==i||e[23]!==S||e[24]!==x||e[25]!==b?(y=(0,o.jsx)($e,{confirmLabel:S,disabled:t,onConfirm:i,testId:x,children:b}),e[21]=t,e[22]=i,e[23]=S,e[24]=x,e[25]=b,e[26]=y):y=e[26];let v;return e[27]!==y||e[28]!==g||e[29]!==k?(v=(0,o.jsxs)(o.Fragment,{children:[g,k,y]}),e[27]=y,e[28]=g,e[29]=k,e[30]=v):v=e[30],v},"ze"),He=h(d=>{let e=(0,B.c)(14),{objectKey:t,references:r,t:l}=d;if(r===void 0)return null;if(r.length===0){let m=`storage-orphan-${t}`,f;e[0]!==l?(f=l("Orphan"),e[0]=l,e[1]=f):f=e[1];let g;return e[2]!==m||e[3]!==f?(g=(0,o.jsx)(ae,{"data-testid":m,variant:"warning",children:f}),e[2]=m,e[3]=f,e[4]=g):g=e[4],g}let n;e[5]!==r?(n=r.map(vt).join(`
2
2
  `),e[5]=r,e[6]=n):n=e[6];let c=n,i=`storage-refs-${t}`,s;e[7]!==r.length||e[8]!==l?(s=r.length===1?l("1 record"):l("{count} records",{count:r.length}),e[7]=r.length,e[8]=l,e[9]=s):s=e[9];let u;return e[10]!==c||e[11]!==i||e[12]!==s?(u=(0,o.jsx)(ae,{"data-testid":i,title:c,variant:"secondary",children:s}),e[10]=c,e[11]=i,e[12]=s,e[13]=u):u=e[13],u},"De"),Ze=h(d=>{let e=(0,B.c)(7),{objectKey:t,onToggle:r,selected:l,t:n}=d,c;e[0]!==n?(c=n("Select row"),e[0]=n,e[1]=c):c=e[1];let i=`storage-select-${t}`,s;return e[2]!==r||e[3]!==l||e[4]!==c||e[5]!==i?(s=(0,o.jsx)(ke,{"aria-label":c,checked:l,"data-testid":i,onCheckedChange:r}),e[2]=r,e[3]=l,e[4]=c,e[5]=i,e[6]=s):s=e[6],s},"je");function vt(d){return`${d.table}\xB7${d.id}`}h(vt,"kt");var kt=h(d=>{let e=(0,B.c)(10),{colSpan:t,name:r,onEnter:l}=d,n;e[0]!==r||e[1]!==l?(n=h(()=>{l(r)},"l"),e[0]=r,e[1]=l,e[2]=n):n=e[2];let c=n,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,o.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=i):i=e[3];let s;e[4]!==c||e[5]!==r?(s=(0,o.jsxs)("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:c,type:"button",children:[i,r]}),e[4]=c,e[5]=r,e[6]=s):s=e[6];let u;return e[7]!==t||e[8]!==s?(u=(0,o.jsx)(de,{children:(0,o.jsx)(X,{colSpan:t,children:s})}),e[7]=t,e[8]=s,e[9]=u):u=e[9],u},"St"),wt=h(d=>{let e=(0,B.c)(37),{busy:t,copiedKey:r,handlers:l,object:n,prefix:c,references:i,selected:s,showReferences:u,t:m}=d,f;e[0]!==l||e[1]!==n||e[2]!==c?(f=Ae(n,c,l),e[0]=l,e[1]=n,e[2]=c,e[3]=f):f=e[3];let{copy:g,download:w,name:a,remove:k,toggle:S}=f,x;e[4]!==n.key||e[5]!==s||e[6]!==m||e[7]!==S?(x=(0,o.jsx)(X,{className:"w-8",children:(0,o.jsx)(Ze,{objectKey:n.key,onToggle:S,selected:s,t:m})}),e[4]=n.key,e[5]=s,e[6]=m,e[7]=S,e[8]=x):x=e[8];let b;e[9]!==a?(b=(0,o.jsx)(X,{className:"font-mono text-xs",children:a}),e[9]=a,e[10]=b):b=e[10];let y;e[11]!==n.size?(y=ye(n.size),e[11]=n.size,e[12]=y):y=e[12];let v;e[13]!==y?(v=(0,o.jsx)(X,{className:"tabular-nums text-muted-foreground",children:y}),e[13]=y,e[14]=v):v=e[14];let j=n.httpMetadata?.contentType??"",N;e[15]!==j?(N=(0,o.jsx)(X,{children:j}),e[15]=j,e[16]=N):N=e[16];let C;e[17]!==n.key||e[18]!==i||e[19]!==u||e[20]!==m?(C=u&&(0,o.jsx)(X,{children:(0,o.jsx)(He,{objectKey:n.key,references:i,t:m})}),e[17]=n.key,e[18]=i,e[19]=u,e[20]=m,e[21]=C):C=e[21];let T=r===n.key,D;e[22]!==t||e[23]!==g||e[24]!==w||e[25]!==n.key||e[26]!==k||e[27]!==m||e[28]!==T?(D=(0,o.jsx)(X,{className:"text-right",children:(0,o.jsx)("span",{className:"inline-flex items-center gap-1",children:(0,o.jsx)(We,{busy:t,copied:T,objectKey:n.key,onCopy:g,onDelete:k,onDownload:w,t:m})})}),e[22]=t,e[23]=g,e[24]=w,e[25]=n.key,e[26]=k,e[27]=m,e[28]=T,e[29]=D):D=e[29];let F;return e[30]!==D||e[31]!==x||e[32]!==b||e[33]!==v||e[34]!==N||e[35]!==C?(F=(0,o.jsxs)(de,{"data-testid":"fb-row",children:[x,b,v,N,C,D]}),e[30]=D,e[31]=x,e[32]=b,e[33]=v,e[34]=N,e[35]=C,e[36]=F):F=e[36],F},"wt"),St=h(d=>{let e=(0,B.c)(65),{allSelected:t,busy:r,copiedKey:l,files:n,folders:c,handlers:i,onEnterFolder:s,prefix:u,references:m,selected:f,showReferences:g,someSelected:w,t:a,toggleSelectAll:k}=d,S;e[0]!==a?(S=a("Select all rows"),e[0]=a,e[1]=S):S=e[1];let x;e[2]!==t||e[3]!==w||e[4]!==S||e[5]!==k?(x=(0,o.jsx)(te,{className:"w-8",children:(0,o.jsx)(ke,{"aria-label":S,checked:t,"data-testid":"storage-select-all",indeterminate:w,onCheckedChange:k})}),e[2]=t,e[3]=w,e[4]=S,e[5]=k,e[6]=x):x=e[6];let b;e[7]!==a?(b=a("key"),e[7]=a,e[8]=b):b=e[8];let y;e[9]!==b?(y=(0,o.jsx)(te,{children:b}),e[9]=b,e[10]=y):y=e[10];let v;e[11]!==a?(v=a("size"),e[11]=a,e[12]=v):v=e[12];let j;e[13]!==v?(j=(0,o.jsx)(te,{children:v}),e[13]=v,e[14]=j):j=e[14];let N;e[15]!==a?(N=a("content-type"),e[15]=a,e[16]=N):N=e[16];let C;e[17]!==N?(C=(0,o.jsx)(te,{children:N}),e[17]=N,e[18]=C):C=e[18];let T;e[19]!==g||e[20]!==a?(T=g&&(0,o.jsx)(te,{children:a("used by")}),e[19]=g,e[20]=a,e[21]=T):T=e[21];let D;e[22]!==a?(D=a("Actions"),e[22]=a,e[23]=D):D=e[23];let F;e[24]!==D?(F=(0,o.jsx)(te,{"aria-label":D}),e[24]=D,e[25]=F):F=e[25];let $;e[26]!==F||e[27]!==x||e[28]!==y||e[29]!==j||e[30]!==C||e[31]!==T?($=(0,o.jsx)(Ie,{children:(0,o.jsxs)(de,{children:[x,y,j,C,T,F]})}),e[26]=F,e[27]=x,e[28]=y,e[29]=j,e[30]=C,e[31]=T,e[32]=$):$=e[32];let O;if(e[33]!==c||e[34]!==s||e[35]!==g){let E;e[37]!==s||e[38]!==g?(E=h(I=>(0,o.jsx)(kt,{colSpan:g?6:5,name:I,onEnter:s},I),"D"),e[37]=s,e[38]=g,e[39]=E):E=e[39],O=c.map(E),e[33]=c,e[34]=s,e[35]=g,e[36]=O}else O=e[36];let R;if(e[40]!==r||e[41]!==l||e[42]!==n||e[43]!==i||e[44]!==u||e[45]!==m||e[46]!==f||e[47]!==g||e[48]!==a){let E;e[50]!==r||e[51]!==l||e[52]!==i||e[53]!==u||e[54]!==m||e[55]!==f||e[56]!==g||e[57]!==a?(E=h(I=>(0,o.jsx)(wt,{busy:r,copiedKey:l,handlers:i,object:I,prefix:u,references:m[I.key],selected:f.has(I.key),showReferences:g,t:a},I.key),"D"),e[50]=r,e[51]=l,e[52]=i,e[53]=u,e[54]=m,e[55]=f,e[56]=g,e[57]=a,e[58]=E):E=e[58],R=n.map(E),e[40]=r,e[41]=l,e[42]=n,e[43]=i,e[44]=u,e[45]=m,e[46]=f,e[47]=g,e[48]=a,e[49]=R}else R=e[49];let L;e[59]!==O||e[60]!==R?(L=(0,o.jsxs)(Re,{children:[O,R]}),e[59]=O,e[60]=R,e[61]=L):L=e[61];let _;return e[62]!==$||e[63]!==L?(_=(0,o.jsx)(Fe,{className:"overflow-hidden py-0",children:(0,o.jsx)(Oe,{className:"px-0",children:(0,o.jsxs)(Le,{"data-testid":"fb-table",children:[$,L]})})}),e[62]=$,e[63]=L,e[64]=_):_=e[64],_},"Ct"),Nt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],Ct=3600,Me=h((d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;let t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},"we"),jt=h((d,e,t)=>{let r=t==="desc"?-1:1;return d.toSorted((l,n)=>{let c=Me(l,e),i=Me(n,e);return(typeof c=="number"&&typeof i=="number"?c-i:String(c).localeCompare(String(i)))*r})},"Et"),zt=h((d,e)=>{let t=new Set,r=[];for(let l of d){let n=l.key.slice(e.length),c=n.indexOf("/");c===-1?r.push(l):t.add(n.slice(0,c+1))}return{files:r,folders:[...t].toSorted((l,n)=>l.localeCompare(n))}},"_t"),Dt=h(d=>{let e=(0,B.c)(59),{bucket:t,buckets:r,busy:l,draftPrefix:n,expiry:c,fileInputRef:i,onBucketChange:s,onExpiryChange:u,onFileChange:m,onList:f,onPrefixChange:g,onUploadClick:w,t:a}=d,k;e[0]!==g?(k=h(A=>{g(A.target.value)},"v"),e[0]=g,e[1]=k):k=e[1];let S=k,x;e[2]!==s?(x=h(A=>{s(A.target.value)},"y"),e[2]=s,e[3]=x):x=e[3];let b=x,y;e[4]!==u?(y=h(A=>{u(Number.parseInt(A.target.value,10))},"b"),e[4]=u,e[5]=y):y=e[5];let v=y,j;e[6]!==t||e[7]!==r||e[8]!==b||e[9]!==a?(j=r.length>0&&(0,o.jsx)("select",{"aria-label":a("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:b,value:t,children:r.map($t)}),e[6]=t,e[7]=r,e[8]=b,e[9]=a,e[10]=j):j=e[10];let N;e[11]!==a?(N=a("Key prefix"),e[11]=a,e[12]=N):N=e[12];let C;e[13]!==a?(C=a("key prefix (optional)"),e[13]=a,e[14]=C):C=e[14];let T;e[15]!==n||e[16]!==S||e[17]!==N||e[18]!==C?(T=(0,o.jsx)(Ke,{"aria-label":N,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:S,placeholder:C,value:n}),e[15]=n,e[16]=S,e[17]=N,e[18]=C,e[19]=T):T=e[19];let D;e[20]!==a?(D=a("List"),e[20]=a,e[21]=D):D=e[21];let F;e[22]!==l||e[23]!==f||e[24]!==D?(F=(0,o.jsx)(ee,{"data-testid":"fb-list",disabled:l,onClick:f,size:"sm",type:"button",children:D}),e[22]=l,e[23]=f,e[24]=D,e[25]=F):F=e[25];let $;e[26]!==l||e[27]!==a?($=a(l?"Uploading\u2026":"Upload"),e[26]=l,e[27]=a,e[28]=$):$=e[28];let O;e[29]!==l||e[30]!==w||e[31]!==$?(O=(0,o.jsx)(ee,{"data-testid":"storage-upload",disabled:l,onClick:w,size:"sm",type:"button",variant:"outline",children:$}),e[29]=l,e[30]=w,e[31]=$,e[32]=O):O=e[32];let R;e[33]!==i||e[34]!==m?(R=(0,o.jsx)("input",{className:"hidden","data-testid":"storage-file-input",onChange:m,ref:i,type:"file"}),e[33]=i,e[34]=m,e[35]=R):R=e[35];let L;e[36]!==a?(L=a("Link expiry"),e[36]=a,e[37]=L):L=e[37];let _;e[38]!==a?(_=Nt.map(A=>(0,o.jsx)("option",{value:A.seconds,children:a(A.label)},A.seconds)),e[38]=a,e[39]=_):_=e[39];let E;e[40]!==c||e[41]!==v||e[42]!==_?(E=(0,o.jsx)("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:v,value:c,children:_}),e[40]=c,e[41]=v,e[42]=_,e[43]=E):E=e[43];let I;e[44]!==L||e[45]!==E?(I=(0,o.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[L,E]}),e[44]=L,e[45]=E,e[46]=I):I=e[46];let M;e[47]!==a?(M=a("Open in Cloudflare"),e[47]=a,e[48]=M):M=e[48];let P;e[49]!==M?(P=(0,o.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:Ue,rel:"noreferrer",target:"_blank",children:M}),e[49]=M,e[50]=P):P=e[50];let W;return e[51]!==O||e[52]!==R||e[53]!==I||e[54]!==P||e[55]!==j||e[56]!==T||e[57]!==F?(W=(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[j,T,F,O,R,I,P]}),e[51]=O,e[52]=R,e[53]=I,e[54]=P,e[55]=j,e[56]=T,e[57]=F,e[58]=W):W=e[58],W},"$t"),Tt=h(d=>{let e=(0,B.c)(66),{onSortKeyChange:t,onThumbSizeChange:r,showGrid:l,showList:n,sortDirection:c,sortKey:i,t:s,tagKeys:u,thumbSize:m,toggleSortDirection:f,view:g}=d,w;e[0]!==t?(w=h(q=>{t(q.target.value)},"k"),e[0]=t,e[1]=w):w=e[1];let a=w,k;e[2]!==r?(k=h(q=>{r(Number.parseInt(q.target.value,10))},"v"),e[2]=r,e[3]=k):k=e[3];let S=k,x=g==="list",b;e[4]!==s?(b=s("List"),e[4]=s,e[5]=b):b=e[5];let y;e[6]!==n||e[7]!==x||e[8]!==b?(y=(0,o.jsx)("button",{"aria-pressed":x,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:n,type:"button",children:b}),e[6]=n,e[7]=x,e[8]=b,e[9]=y):y=e[9];let v=g==="grid",j;e[10]!==s?(j=s("Grid"),e[10]=s,e[11]=j):j=e[11];let N;e[12]!==l||e[13]!==v||e[14]!==j?(N=(0,o.jsx)("button",{"aria-pressed":v,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:l,type:"button",children:j}),e[12]=l,e[13]=v,e[14]=j,e[15]=N):N=e[15];let C;e[16]!==y||e[17]!==N?(C=(0,o.jsxs)("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[y,N]}),e[16]=y,e[17]=N,e[18]=C):C=e[18];let T;e[19]!==s?(T=s("Sort"),e[19]=s,e[20]=T):T=e[20];let D;e[21]!==s?(D=s("Name"),e[21]=s,e[22]=D):D=e[22];let F;e[23]!==D?(F=(0,o.jsx)("option",{value:"name",children:D}),e[23]=D,e[24]=F):F=e[24];let $;e[25]!==s?($=s("size"),e[25]=s,e[26]=$):$=e[26];let O;e[27]!==$?(O=(0,o.jsx)("option",{value:"size",children:$}),e[27]=$,e[28]=O):O=e[28];let R;e[29]!==s?(R=s("Type"),e[29]=s,e[30]=R):R=e[30];let L;e[31]!==R?(L=(0,o.jsx)("option",{value:"type",children:R}),e[31]=R,e[32]=L):L=e[32];let _;e[33]!==s?(_=s("Modified"),e[33]=s,e[34]=_):_=e[34];let E;e[35]!==_?(E=(0,o.jsx)("option",{value:"date",children:_}),e[35]=_,e[36]=E):E=e[36];let I;e[37]!==u?(I=u.map(Kt),e[37]=u,e[38]=I):I=e[38];let M;e[39]!==a||e[40]!==i||e[41]!==F||e[42]!==O||e[43]!==L||e[44]!==E||e[45]!==I?(M=(0,o.jsxs)("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:a,value:i,children:[F,O,L,E,I]}),e[39]=a,e[40]=i,e[41]=F,e[42]=O,e[43]=L,e[44]=E,e[45]=I,e[46]=M):M=e[46];let P;e[47]!==T||e[48]!==M?(P=(0,o.jsxs)("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[T,M]}),e[47]=T,e[48]=M,e[49]=P):P=e[49];let W;e[50]!==s?(W=s("Toggle sort direction"),e[50]=s,e[51]=W):W=e[51];let A=c==="asc"?"\u2191":"\u2193",H;e[52]!==W||e[53]!==A||e[54]!==f?(H=(0,o.jsx)("button",{"aria-label":W,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:f,type:"button",children:A}),e[52]=W,e[53]=A,e[54]=f,e[55]=H):H=e[55];let V;e[56]!==S||e[57]!==s||e[58]!==m||e[59]!==g?(V=g==="grid"&&(0,o.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[s("Thumbnail size"),(0,o.jsx)("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:S,step:8,type:"range",value:m})]}),e[56]=S,e[57]=s,e[58]=m,e[59]=g,e[60]=V):V=e[60];let re;return e[61]!==P||e[62]!==H||e[63]!==V||e[64]!==C?(re=(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[C,P,H,V]}),e[61]=P,e[62]=H,e[63]=V,e[64]=C,e[65]=re):re=e[65],re},"Ft");function $t(d){return(0,o.jsx)("option",{value:d,children:d},d)}h($t,"Rt");function Kt(d){return(0,o.jsx)("option",{value:`tag:${d}`,children:d},d)}h(Kt,"zt");var Ft=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,Ot=h(d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Ft.test(d.key),"jt"),Et=h(()=>{let d=(0,B.c)(1),e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,o.jsx)("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,o.jsx)("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},"Kt"),Lt=h(d=>{let e=(0,B.c)(13),{object:t,resolveUrl:r}=d,[l,n]=(0,z.useState)(null),[c,i]=(0,z.useState)(!1),s;e[0]!==t?(s=Ot(t),e[0]=t,e[1]=s):s=e[1];let u=s,m,f;e[2]!==u||e[3]!==t.key||e[4]!==r?(m=h(()=>{if(!u)return;let k={cancelled:!1};return Z((async()=>{try{let S=await r(t.key);k.cancelled||n(S)}catch{k.cancelled||i(!0)}})()),()=>{k.cancelled=!0}},"h"),f=[u,t.key,r],e[2]=u,e[3]=t.key,e[4]=r,e[5]=m,e[6]=f):(m=e[5],f=e[6]),(0,z.useEffect)(m,f);let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=h(()=>{i(!0)},"m"),e[7]=g):g=e[7];let w=g,a;return e[8]!==c||e[9]!==u||e[10]!==t.key||e[11]!==l?(a=(0,o.jsx)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:u&&l!==null&&!c?(0,o.jsx)("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:w,src:l}):(0,o.jsx)(Et,{})}),e[8]=c,e[9]=u,e[10]=t.key,e[11]=l,e[12]=a):a=e[12],a},"Bt"),It=h(d=>{let e=(0,B.c)(42),{busy:t,copiedKey:r,handlers:l,object:n,prefix:c,references:i,resolveUrl:s,selected:u,showReferences:m,t:f}=d,g;e[0]!==l||e[1]!==n||e[2]!==c?(g=Ae(n,c,l),e[0]=l,e[1]=n,e[2]=c,e[3]=g):g=e[3];let{copy:w,download:a,name:k,remove:S,toggle:x}=g,b;e[4]!==n||e[5]!==s?(b=(0,o.jsx)(Lt,{object:n,resolveUrl:s}),e[4]=n,e[5]=s,e[6]=b):b=e[6];let y;e[7]!==n.key||e[8]!==u||e[9]!==f||e[10]!==x?(y=(0,o.jsx)("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:(0,o.jsx)(Ze,{objectKey:n.key,onToggle:x,selected:u,t:f})}),e[7]=n.key,e[8]=u,e[9]=f,e[10]=x,e[11]=y):y=e[11];let v;e[12]!==b||e[13]!==y?(v=(0,o.jsxs)("div",{className:"relative",children:[b,y]}),e[12]=b,e[13]=y,e[14]=v):v=e[14];let j;e[15]!==k?(j=(0,o.jsx)("p",{className:"truncate font-mono text-xs",title:k,children:k}),e[15]=k,e[16]=j):j=e[16];let N;e[17]!==n.size?(N=ye(n.size),e[17]=n.size,e[18]=N):N=e[18];let C;e[19]!==N?(C=(0,o.jsx)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:N}),e[19]=N,e[20]=C):C=e[20];let T;e[21]!==n.key||e[22]!==i||e[23]!==m||e[24]!==f?(T=m&&(0,o.jsx)("div",{className:"mt-1",children:(0,o.jsx)(He,{objectKey:n.key,references:i,t:f})}),e[21]=n.key,e[22]=i,e[23]=m,e[24]=f,e[25]=T):T=e[25];let D;e[26]!==j||e[27]!==C||e[28]!==T?(D=(0,o.jsxs)("div",{className:"min-w-0",children:[j,C,T]}),e[26]=j,e[27]=C,e[28]=T,e[29]=D):D=e[29];let F=r===n.key,$;e[30]!==t||e[31]!==w||e[32]!==a||e[33]!==n.key||e[34]!==S||e[35]!==f||e[36]!==F?($=(0,o.jsx)("div",{className:"flex items-center gap-1",children:(0,o.jsx)(We,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:n.key,onCopy:w,onDelete:S,onDownload:a,t:f})}),e[30]=t,e[31]=w,e[32]=a,e[33]=n.key,e[34]=S,e[35]=f,e[36]=F,e[37]=$):$=e[37];let O;return e[38]!==$||e[39]!==v||e[40]!==D?(O=(0,o.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[v,D,$]}),e[38]=$,e[39]=v,e[40]=D,e[41]=O):O=e[41],O},"Lt"),Rt=h(d=>{let e=(0,B.c)(9),{name:t,onEnter:r}=d,l;e[0]!==t||e[1]!==r?(l=h(()=>{r(t)},"n"),e[0]=t,e[1]=r,e[2]=l):l=e[2];let n=l,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,o.jsx)("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:(0,o.jsx)("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,o.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=c):c=e[3];let i;e[4]!==t?(i=(0,o.jsx)("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=i):i=e[5];let s;return e[6]!==n||e[7]!==i?(s=(0,o.jsxs)("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:n,type:"button",children:[c,i]}),e[6]=n,e[7]=i,e[8]=s):s=e[8],s},"It"),_t=h(d=>{let e=(0,B.c)(34),{busy:t,copiedKey:r,files:l,folders:n,handlers:c,onEnterFolder:i,prefix:s,references:u,resolveUrl:m,selected:f,showReferences:g,size:w,t:a}=d,k;e[0]!==w?(k=w.toString(),e[0]=w,e[1]=k):k=e[1];let S=`repeat(auto-fill, minmax(${k}px, 1fr))`,x;e[2]!==S?(x={gridTemplateColumns:S},e[2]=S,e[3]=x):x=e[3];let b=x,y;if(e[4]!==n||e[5]!==i){let N;e[7]!==i?(N=h(C=>(0,o.jsx)(Rt,{name:C,onEnter:i},C),"w"),e[7]=i,e[8]=N):N=e[8],y=n.map(N),e[4]=n,e[5]=i,e[6]=y}else y=e[6];let v;if(e[9]!==t||e[10]!==r||e[11]!==l||e[12]!==c||e[13]!==s||e[14]!==u||e[15]!==m||e[16]!==f||e[17]!==g||e[18]!==a){let N;e[20]!==t||e[21]!==r||e[22]!==c||e[23]!==s||e[24]!==u||e[25]!==m||e[26]!==f||e[27]!==g||e[28]!==a?(N=h(C=>(0,o.jsx)(It,{busy:t,copiedKey:r,handlers:c,object:C,prefix:s,references:u[C.key],resolveUrl:m,selected:f.has(C.key),showReferences:g,t:a},C.key),"w"),e[20]=t,e[21]=r,e[22]=c,e[23]=s,e[24]=u,e[25]=m,e[26]=f,e[27]=g,e[28]=a,e[29]=N):N=e[29],v=l.map(N),e[9]=t,e[10]=r,e[11]=l,e[12]=c,e[13]=s,e[14]=u,e[15]=m,e[16]=f,e[17]=g,e[18]=a,e[19]=v}else v=e[19];let j;return e[30]!==b||e[31]!==y||e[32]!==v?(j=(0,o.jsxs)("div",{className:"grid gap-4","data-testid":"fb-gallery",style:b,children:[y,v]}),e[30]=b,e[31]=y,e[32]=v,e[33]=j):j=e[33],j},"Ot"),Ut=h(d=>{let e=(0,B.c)(23),{reference:t,t:r}=d,l=`fb-dangling-${t.table}-${t.id}-${t.column}`,n=`${t.table}\xB7${t.id}`,c;e[0]!==n?(c=(0,o.jsx)(ae,{variant:"secondary",children:n}),e[0]=n,e[1]=c):c=e[1];let i;e[2]!==t.column?(i=(0,o.jsx)("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=i):i=e[3];let s;e[4]!==r?(s=r("\u2192"),e[4]=r,e[5]=s):s=e[5];let u;e[6]!==s?(u=(0,o.jsx)("span",{className:"text-muted-foreground/60",children:s}),e[6]=s,e[7]=u):u=e[7];let m;e[8]!==t.key?(m=(0,o.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=m):m=e[9];let f;e[10]!==c||e[11]!==i||e[12]!==u||e[13]!==m?(f=(0,o.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[c,i,u,m]}),e[10]=c,e[11]=i,e[12]=u,e[13]=m,e[14]=f):f=e[14];let g;e[15]!==r?(g=r("Missing object"),e[15]=r,e[16]=g):g=e[16];let w;e[17]!==g?(w=(0,o.jsx)(ae,{className:"border-destructive/40 text-destructive",variant:"outline",children:g}),e[17]=g,e[18]=w):w=e[18];let a;return e[19]!==l||e[20]!==w||e[21]!==f?(a=(0,o.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":l,children:[f,w]}),e[19]=l,e[20]=w,e[21]=f,e[22]=a):a=e[22],a},"At"),Mt=h(d=>{let e=(0,B.c)(42),{busy:t,onCheck:r,references:l,t:n,truncated:c}=d,i;e[0]!==n?(i=n("Integrity"),e[0]=n,e[1]=i):i=e[1];let s;e[2]!==i?(s=(0,o.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[2]=i,e[3]=s):s=e[3];let u;e[4]!==n?(u=n("Orphaned objects"),e[4]=n,e[5]=u):u=e[5];let m;e[6]!==u?(m=(0,o.jsx)("span",{className:"text-sm font-medium text-foreground",children:u}),e[6]=u,e[7]=m):m=e[7];let f;e[8]!==n?(f=n("Find records whose file reference points at an object the bucket no longer has."),e[8]=n,e[9]=f):f=e[9];let g;e[10]!==f?(g=(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[10]=f,e[11]=g):g=e[11];let w;e[12]!==s||e[13]!==m||e[14]!==g?(w=(0,o.jsxs)("div",{className:"flex flex-col gap-1",children:[s,m,g]}),e[12]=s,e[13]=m,e[14]=g,e[15]=w):w=e[15];let a;e[16]!==t||e[17]!==n?(a=n(t?"Checking\u2026":"Check for orphans"),e[16]=t,e[17]=n,e[18]=a):a=e[18];let k;e[19]!==t||e[20]!==r||e[21]!==a?(k=(0,o.jsx)(ee,{"data-testid":"fb-orphans-check",disabled:t,onClick:r,size:"sm",type:"button",variant:"outline",children:a}),e[19]=t,e[20]=r,e[21]=a,e[22]=k):k=e[22];let S;e[23]!==w||e[24]!==k?(S=(0,o.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[w,k]}),e[23]=w,e[24]=k,e[25]=S):S=e[25];let x;e[26]!==l||e[27]!==n||e[28]!==c?(x=c&&(0,o.jsx)("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:l===void 0||l.length===0?n("The bucket is larger than the scan's key limit, so dangling references could not be checked."):n("Showing the first {count} dangling references \u2014 the scan was truncated.",{count:l.length})}),e[26]=l,e[27]=n,e[28]=c,e[29]=x):x=e[29];let b;e[30]!==l?.length||e[31]!==n||e[32]!==c?(b=l?.length===0&&!c&&(0,o.jsx)(ve,{description:n("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:n("No dangling references.")}),e[30]=l?.length,e[31]=n,e[32]=c,e[33]=b):b=e[33];let y;e[34]!==l||e[35]!==n?(y=l!==void 0&&l.length>0&&(0,o.jsx)("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:l.map(j=>(0,o.jsx)(Ut,{reference:j,t:n},`${j.table}\xB7${j.id}\xB7${j.column}`))}),e[34]=l,e[35]=n,e[36]=y):y=e[36];let v;return e[37]!==S||e[38]!==x||e[39]!==b||e[40]!==y?(v=(0,o.jsxs)("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[S,x,b,y]}),e[37]=S,e[38]=x,e[39]=b,e[40]=y,e[41]=v):v=e[41],v},"Ut"),Bt=h(function(d,e){let t=(0,B.c)(18),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[0]=r):r=t[0];let[l,n]=(0,z.useState)(r),c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=h(x=>{n(b=>{let y=new Set(b);return y.has(x)?y.delete(x):y.add(x),y})},"a"),t[1]=c):c=t[1];let i=c,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=h(()=>{n(new Set)},"o"),t[2]=s):s=t[2];let u=s,m,f,g;if(t[3]!==d||t[4]!==e||t[5]!==l){let x;t[9]!==e?(x=h(b=>e(b),"y"),t[9]=e,t[10]=x):x=t[10],f=d.map(x),m=f.length>0&&f.every(b=>l.has(b)),g=!m&&f.some(b=>l.has(b)),t[3]=d,t[4]=e,t[5]=l,t[6]=m,t[7]=f,t[8]=g}else m=t[6],f=t[7],g=t[8];let w=g,a;t[11]!==f?(a=h(()=>{n(x=>f.every(b=>x.has(b))?new Set:new Set(f))},"i"),t[11]=f,t[12]=a):a=t[12];let k=a,S;return t[13]!==m||t[14]!==l||t[15]!==w||t[16]!==k?(S={allSelected:m,clear:u,selected:l,someSelected:w,toggle:i,toggleAll:k},t[13]=m,t[14]=l,t[15]=w,t[16]=k,t[17]=S):S=t[17],S},"Mt"),Pt=pe(xe.storageReferences),At=pe(xe.storageOrphans),Be=1e4,Wt=1e3,Ht=h(async d=>{let e=[],t,r=!0,l=!1;for(;r&&e.length<Be;){let n=await d.list({cursor:t,limit:Wt}),c=Be-e.length;for(let i of n.objects.slice(0,c))e.push(i.key);l||=n.objects.length>c,t=n.cursor,r=t!==void 0}return{liveKeys:e,truncated:l||r}},"qt"),Zt=3600,qt=h((d,e)=>{if(!("document"in globalThis))return;let t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},"Vt"),Gt=h(d=>d.key,"Zt"),Vt=h(({initialPrefix:d,pageSize:e})=>{let t=ze(),[r,l]=(0,z.useState)(d??""),[n,c]=(0,z.useState)(d??""),[i,s]=(0,z.useState)(Ct),[u,m]=(0,z.useState)("list"),[f,g]=(0,z.useState)(128),[w,a]=(0,z.useState)("name"),[k,S]=(0,z.useState)("asc"),[x,b]=(0,z.useState)(void 0),[y,v]=(0,z.useState)(void 0),[j,N]=(0,z.useState)(!1),[C,T]=(0,z.useState)(void 0),[D,F]=(0,z.useState)(void 0),[$,O]=(0,z.useState)(""),[R,L]=(0,z.useState)({}),[_,E]=(0,z.useState)(!1),[I,M]=(0,z.useState)(void 0),[P,W]=(0,z.useState)(!1),[A,H]=(0,z.useState)(!1),[V,re]=(0,z.useState)([]),[q,we]=(0,z.useState)(""),ne=(0,z.useRef)(0),Q=(0,z.useRef)(0),ce=(0,z.useRef)(0);(0,z.useEffect)(()=>{let p={cancelled:!1};return Z((async()=>{try{let K=await t.listStorageBuckets();if(!p.cancelled){re(K);let[U]=K;U!==void 0&&we(J=>J===""?U:J)}}catch{}})()),()=>{p.cancelled=!0}},[t]);let G=(0,z.useMemo)(()=>({list:h(p=>t.listStorageObjects({...p,bucket:q}),"list"),remove:h(p=>t.deleteStorageObject(p,{bucket:q}),"remove"),signedUrl:h((p,K)=>t.signedStorageUrl(p,{...K,bucket:q}),"signedUrl"),upload:h(p=>t.uploadStorageObject({...p,bucket:q}),"upload")}),[q,t]),Y=(0,z.useCallback)(async(p,K,U,J=!1)=>{ne.current+=1;let me=ne.current;v(void 0),N(!0);try{let oe=await G.list({cursor:K,limit:e,prefix:p});if(me!==ne.current)return;b(Ce=>U&&Ce!==void 0?[...Ce,...oe.objects]:oe.objects),F(oe.cursor)}catch(oe){if(me!==ne.current)return;if(U||b(void 0),v(le(oe)),J)throw oe}finally{me===ne.current&&N(!1)}},[e,G]);(0,z.useEffect)(()=>{Z(Y(d??"",void 0,!1))},[Y,d]);let qe=(x?.length??0)<=e;De(()=>Y(r,void 0,!1,!0),qe);let{files:ue,folders:Ge}=zt(x??[],r),Ve=(0,z.useMemo)(()=>{let p=new Set;for(let K of ue)for(let U of Object.keys(K.customMetadata??{}))p.add(U);return[...p].toSorted((K,U)=>K.localeCompare(U))},[ue]),ie=jt(ue,w,k),fe=(0,z.useMemo)(()=>[...new Set(ie.map(p=>p.key))].toSorted((p,K)=>p.localeCompare(K)).join(`
3
3
  `),[ie]);(0,z.useEffect)(()=>{let p=fe===""?[]:fe.split(`
4
4
  `);if(p.length===0){L({});return}let K={current:!0};return Z((async()=>{try{let U=await t.query(Pt,{keys:p},be($));K.current&&(L(U.references??{}),E(Object.keys(U.storageColumns??{}).length>0))}catch{K.current&&(L({}),E(!1))}})()),()=>{K.current=!1}},[t,fe,$]);let{allSelected:Qe,clear:se,selected:Se,someSelected:Xe,toggle:Ye,toggleAll:Je}=Bt(ie,Gt),et=h(()=>{l(n),se(),Z(Y(n,void 0,!1))},"Me"),tt=h(()=>{Z(Y(r,D,!0))},"Ge"),Ne=h(p=>{l(p),c(p),se(),Z(Y(p,void 0,!1))},"ve"),rt=h(p=>{Ne(`${r}${p}`)},"He"),nt=h(p=>G.signedUrl(p,{expiresInSeconds:Zt}),"Pe"),ot=h(()=>{m("list")},"qe"),lt=h(()=>{m("grid")},"We"),st=h(p=>{a(p)},"Ve"),at=h(()=>{S(p=>p==="asc"?"desc":"asc")},"Ze"),ct=h(p=>{g(p)},"Xe"),it=h(p=>{s(p)},"Ye"),he=h(p=>{let K=ce.current;v(void 0),N(!0),Z((async()=>{try{await p(),K===ce.current&&await Y(r,void 0,!1)}catch(U){v(le(U))}K===ce.current&&N(!1)})())},"me"),dt=h(()=>{he(async()=>{for(let p of Se)await G.remove(p);se()})},"Je"),ut=h(p=>{v(void 0),Z((async()=>{try{let K=await G.signedUrl(p,{expiresInSeconds:i});je(K)&&T(p)}catch(K){v(le(K))}})())},"Qe"),ft=h(p=>{v(void 0),Z((async()=>{try{let K=await G.signedUrl(p,{expiresInSeconds:i}),U=p.slice(p.lastIndexOf("/")+1)||p;qt(K,U)}catch(K){v(le(K))}})())},"et");(0,z.useEffect)(()=>{if(C===void 0)return;let p=globalThis.setTimeout(()=>{T(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[C]);let ht=h(p=>{he(async()=>{await G.remove(p)})},"tt"),mt=h(p=>{let K=`${r}${p.name}`;he(async()=>{let U=await p.arrayBuffer();await G.upload({body:U,contentType:p.type===""?void 0:p.type,key:K})})},"st");(0,z.useEffect)(()=>{Q.current+=1,M(void 0),H(!1)},[$]);let gt=h(()=>{Q.current+=1;let p=Q.current;v(void 0),W(!0),Z((async()=>{try{let{liveKeys:K,truncated:U}=await Ht(G);if(U)p===Q.current&&(M(void 0),H(!0));else{let J=await t.query(At,{liveKeys:K},be($));p===Q.current&&(M(J.references??[]),H(J.truncated===!0))}}catch(K){p===Q.current&&(M(void 0),H(!1),v(le(K)))}p===Q.current&&W(!1)})())},"lt"),pt=h(p=>{ne.current+=1,Q.current+=1,ce.current+=1,we(p),l(d??""),c(d??""),b(void 0),M(void 0),H(!1),se()},"nt");return{allSelected:Qe,bucket:q,buckets:V,bulkDelete:dt,busy:j,checkOrphans:gt,clearSelection:se,copiedKey:C,danglingBusy:P,danglingReferences:I,danglingTruncated:A,draftPrefix:n,enterFolder:rt,error:y,expiry:i,files:ie,folders:Ge,hasObjects:x!==void 0&&x.length>0,hasStorageColumns:_,listFirst:et,loaded:x!==void 0,loadMore:tt,navigate:Ne,nextCursor:D,onCopy:ut,onDelete:ht,onDownload:ft,onExpiryChange:it,onFile:mt,onSortKeyChange:st,onThumbSizeChange:ct,prefix:r,referenceShard:$,references:R,resolveUrl:nt,selectBucket:pt,selected:Se,setDraftPrefix:c,setReferenceShard:O,showGrid:lt,showList:ot,someSelected:Xe,sortDirection:k,sortKey:w,tagKeys:Ve,thumbSize:f,toggleSelect:Ye,toggleSelectAll:Je,toggleSortDirection:at,view:u}},"Xt"),Qt=100,Pe=h(d=>{let e=(0,B.c)(6),{label:t,onNavigate:r,target:l}=d,n;e[0]!==r||e[1]!==l?(n=h(()=>{r(l)},"l"),e[0]=r,e[1]=l,e[2]=n):n=e[2];let c=n,i;return e[3]!==c||e[4]!==t?(i=(0,o.jsx)("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:c,type:"button",children:t}),e[3]=c,e[4]=t,e[5]=i):i=e[5],i},"Ne"),Xt=h(d=>{let e=(0,B.c)(11),{onNavigate:t,prefix:r,t:l}=d,n;if(e[0]!==t||e[1]!==r||e[2]!==l){let c=r.split("/").filter(Yt),i;e[4]!==l?(i=l("Folder path"),e[4]=l,e[5]=i):i=e[5];let s;e[6]!==l?(s=l("root"),e[6]=l,e[7]=s):s=e[7];let u;e[8]!==t||e[9]!==s?(u=(0,o.jsx)(Pe,{label:s,onNavigate:t,target:""}),e[8]=t,e[9]=s,e[10]=u):u=e[10],n=(0,o.jsxs)("nav",{"aria-label":i,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[u,c.map((m,f)=>(0,o.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,o.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,o.jsx)(Pe,{label:m,onNavigate:t,target:`${c.slice(0,f+1).join("/")}/`})]},`${m}-${f.toString()}`))]}),e[0]=t,e[1]=r,e[2]=l,e[3]=n}else n=e[3];return n},"Jt"),gr=h(({initialPrefix:d,pageSize:e=Qt})=>{let t=Te(),r=Vt({initialPrefix:d,pageSize:e}),l=(0,z.useRef)(null),{onCopy:n,onDelete:c,onDownload:i,onFile:s,toggleSelect:u}=r,m={onCopy:n,onDelete:c,onDownload:i,onToggleSelect:u},f=h(()=>{l.current?.click()},"u"),g=h(a=>{let k=a.target,S=k.files?.[0];k.value="",S&&s(S)},"m"),w=r.loaded&&!r.hasObjects;return(0,o.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[(0,o.jsx)(Dt,{bucket:r.bucket,buckets:r.buckets,busy:r.busy,draftPrefix:r.draftPrefix,expiry:r.expiry,fileInputRef:l,onBucketChange:r.selectBucket,onExpiryChange:r.onExpiryChange,onFileChange:g,onList:r.listFirst,onPrefixChange:r.setDraftPrefix,onUploadClick:f,t}),r.loaded&&(0,o.jsx)(Xt,{onNavigate:r.navigate,prefix:r.prefix,t}),r.hasObjects&&(0,o.jsx)(Tt,{onSortKeyChange:r.onSortKeyChange,onThumbSizeChange:r.onThumbSizeChange,showGrid:r.showGrid,showList:r.showList,sortDirection:r.sortDirection,sortKey:r.sortKey,t,tagKeys:r.tagKeys,thumbSize:r.thumbSize,toggleSortDirection:r.toggleSortDirection,view:r.view}),r.hasStorageColumns&&(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[(0,o.jsx)("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),(0,o.jsx)(Ee,{id:"fb-reference-shard-input",onChange:r.setReferenceShard,testId:"fb-reference-shard-input",value:r.referenceShard}),(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),r.hasStorageColumns&&(0,o.jsx)(Mt,{busy:r.danglingBusy,onCheck:r.checkOrphans,references:r.danglingReferences,t,truncated:r.danglingTruncated}),r.selected.size>0&&(0,o.jsx)(_e,{count:r.selected.size,editable:!0,onClear:r.clearSelection,onDelete:r.bulkDelete}),r.error!==void 0&&(0,o.jsx)("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:r.error}),w&&(0,o.jsx)(ve,{description:t("Objects you upload to your R2 buckets will appear here."),icon:(0,o.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,o.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),(0,o.jsx)("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),r.hasObjects&&r.view==="list"&&(0,o.jsx)(St,{allSelected:r.allSelected,busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:m,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,selected:r.selected,showReferences:r.hasStorageColumns,someSelected:r.someSelected,t,toggleSelectAll:r.toggleSelectAll}),r.hasObjects&&r.view==="grid"&&(0,o.jsx)(_t,{busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:m,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,resolveUrl:r.resolveUrl,selected:r.selected,showReferences:r.hasStorageColumns,size:r.thumbSize,t}),r.nextCursor!==void 0&&(0,o.jsx)("div",{children:(0,o.jsx)(ee,{"data-testid":"fb-next",disabled:r.busy,onClick:r.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})},"xs");function Yt(d){return d!==""}h(Yt,"Qt");export{gr as FileBrowser};
@@ -1 +1 @@
1
- import{a as s}from"./chunk-SZCXVIVT.js";import{B as d}from"./chunk-4S7ZIMWI.js";import{a as h,b as k}from"./chunk-ADABTCDI.js";import{a as e,d as r}from"./chunk-5PEAXTYQ.js";var l=r(h(),1);var t=r(k(),1);var g=e(({children:m,confirmLabel:c,disabled:a=!1,onConfirm:p,testId:i})=>{let o=d(),[f,n]=(0,l.useState)(!1),u=e(()=>{n(!0)},"f"),C=e(()=>{n(!1)},"l"),b=e(()=>{n(!1),p()},"p");return f?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":`${i}-prompt`,role:"group",children:[(0,t.jsx)(s,{"data-testid":`${i}-confirm`,disabled:a,onClick:b,size:"sm",type:"button",variant:"destructive",children:c??o("Confirm")}),(0,t.jsx)(s,{"data-testid":`${i}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:o("Cancel")})]}):(0,t.jsx)(s,{"data-testid":i,disabled:a,onClick:u,size:"sm",type:"button",variant:"outline",children:m})},"k");export{g as a};
1
+ import{a as s}from"./chunk-LMGNMZUF.js";import{B as d}from"./chunk-JEKJEGBJ.js";import{a as h,b as k}from"./chunk-ADABTCDI.js";import{a as e,d as r}from"./chunk-5PEAXTYQ.js";var l=r(h(),1);var t=r(k(),1);var g=e(({children:m,confirmLabel:c,disabled:a=!1,onConfirm:p,testId:i})=>{let o=d(),[f,n]=(0,l.useState)(!1),u=e(()=>{n(!0)},"f"),C=e(()=>{n(!1)},"l"),b=e(()=>{n(!1),p()},"p");return f?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":`${i}-prompt`,role:"group",children:[(0,t.jsx)(s,{"data-testid":`${i}-confirm`,disabled:a,onClick:b,size:"sm",type:"button",variant:"destructive",children:c??o("Confirm")}),(0,t.jsx)(s,{"data-testid":`${i}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:o("Cancel")})]}):(0,t.jsx)(s,{"data-testid":i,disabled:a,onClick:u,size:"sm",type:"button",variant:"outline",children:m})},"k");export{g as a};
@@ -1 +1 @@
1
- import{a as k,b as y}from"./chunk-DKEK4ZO6.js";import{b as N}from"./chunk-TRJMN2YI.js";import{B as b,w}from"./chunk-4S7ZIMWI.js";import{a as _}from"./chunk-A6TVTNKO.js";import{a as S,b as E}from"./chunk-ADABTCDI.js";import{a as h,d as x}from"./chunk-5PEAXTYQ.js";var v=x(_(),1);var j=x(S(),1);var l=x(E(),1);var F={debug:"secondary",error:"destructive",fatal:"destructive",info:"outline",log:"outline",trace:"outline",warn:"secondary"},L=h(f=>{let e=(0,v.c)(19),{errors:t}=f,i=b(),[r,u]=(0,j.useState)(!1),s,m;if(e[0]!==t||e[1]!==r||e[2]!==i){let g=t.map(B).join(", ");s=r,m=i(r?"Hide the stack and cause of {field}":"Show the stack and cause of {field}",{field:g}),e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=m}else s=e[3],m=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=h(()=>{u(C)},"i"),e[5]=d):d=e[5];let p=r?"\u25BE":"\u25B8",a;e[6]!==i?(a=i("Error details"),e[6]=i,e[7]=a):a=e[7];let n;e[8]!==s||e[9]!==m||e[10]!==p||e[11]!==a?(n=(0,l.jsxs)("button",{"aria-expanded":s,"aria-label":m,className:"shrink-0 pl-2 text-[11px] text-destructive underline-offset-2 hover:underline","data-testid":"lg-error-toggle",onClick:d,type:"button",children:[p," ",a]}),e[8]=s,e[9]=m,e[10]=p,e[11]=a,e[12]=n):n=e[12];let o;e[13]!==t||e[14]!==r?(o=r?(0,l.jsx)("pre",{className:"order-last mt-1 basis-full overflow-x-auto whitespace-pre rounded-md bg-muted/50 p-2 font-mono text-[11px] leading-snug text-muted-foreground","data-testid":"lg-error-detail",children:k(t)}):null,e[13]=t,e[14]=r,e[15]=o):o=e[15];let c;return e[16]!==n||e[17]!==o?(c=(0,l.jsxs)(l.Fragment,{children:[n,o]}),e[16]=n,e[17]=o,e[18]=c):c=e[18],c},"_");function B(f){let[e]=f;return e}h(B,"j");function C(f){return!f}h(C,"F");var q=h(f=>{let e=(0,v.c)(24),{entry:t}=f,i;e[0]!==t.fields?(i=y(t.fields),e[0]=t.fields,e[1]=i):i=e[1];let r=i,u;e[2]!==t.timestamp?(u=w(t.timestamp),e[2]=t.timestamp,e[3]=u):u=e[3];let s;e[4]!==u?(s=(0,l.jsx)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u}),e[4]=u,e[5]=s):s=e[5];let m=F[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,l.jsx)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,l.jsx)(N,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let p=t.functionPath??"\u2014",a;e[9]!==p?(a=(0,l.jsx)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:p}),e[9]=p,e[10]=a):a=e[10];let n;e[11]!==r.text?(n=r.text===""?null:(0,l.jsx)("span",{className:"ml-2 text-muted-foreground","data-testid":"lg-fields",children:r.text}),e[11]=r.text,e[12]=n):n=e[12];let o;e[13]!==t.message||e[14]!==n?(o=(0,l.jsxs)("span",{className:"min-w-0 flex-1 truncate",role:"gridcell",children:[t.message,n]}),e[13]=t.message,e[14]=n,e[15]=o):o=e[15];let c;e[16]!==r.errors?(c=r.errors.length===0?null:(0,l.jsx)("span",{className:"contents",role:"gridcell",children:(0,l.jsx)(L,{errors:r.errors})}),e[16]=r.errors,e[17]=c):c=e[17];let g;return e[18]!==c||e[19]!==s||e[20]!==d||e[21]!==a||e[22]!==o?(g=(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center",role:"none",children:[s,d,a,o,c]}),e[18]=c,e[19]=s,e[20]=d,e[21]=a,e[22]=o,e[23]=g):g=e[23],g},"D");export{F as a,L as b,q as c};
1
+ import{a as k,b as y}from"./chunk-LJLNIVUA.js";import{b as N}from"./chunk-YCQ7ZPBP.js";import{B as b,w}from"./chunk-JEKJEGBJ.js";import{a as _}from"./chunk-A6TVTNKO.js";import{a as S,b as E}from"./chunk-ADABTCDI.js";import{a as h,d as x}from"./chunk-5PEAXTYQ.js";var v=x(_(),1);var j=x(S(),1);var l=x(E(),1);var F={debug:"secondary",error:"destructive",fatal:"destructive",info:"outline",log:"outline",trace:"outline",warn:"secondary"},L=h(f=>{let e=(0,v.c)(19),{errors:t}=f,i=b(),[r,u]=(0,j.useState)(!1),s,m;if(e[0]!==t||e[1]!==r||e[2]!==i){let g=t.map(B).join(", ");s=r,m=i(r?"Hide the stack and cause of {field}":"Show the stack and cause of {field}",{field:g}),e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=m}else s=e[3],m=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=h(()=>{u(C)},"i"),e[5]=d):d=e[5];let p=r?"\u25BE":"\u25B8",a;e[6]!==i?(a=i("Error details"),e[6]=i,e[7]=a):a=e[7];let n;e[8]!==s||e[9]!==m||e[10]!==p||e[11]!==a?(n=(0,l.jsxs)("button",{"aria-expanded":s,"aria-label":m,className:"shrink-0 pl-2 text-[11px] text-destructive underline-offset-2 hover:underline","data-testid":"lg-error-toggle",onClick:d,type:"button",children:[p," ",a]}),e[8]=s,e[9]=m,e[10]=p,e[11]=a,e[12]=n):n=e[12];let o;e[13]!==t||e[14]!==r?(o=r?(0,l.jsx)("pre",{className:"order-last mt-1 basis-full overflow-x-auto whitespace-pre rounded-md bg-muted/50 p-2 font-mono text-[11px] leading-snug text-muted-foreground","data-testid":"lg-error-detail",children:k(t)}):null,e[13]=t,e[14]=r,e[15]=o):o=e[15];let c;return e[16]!==n||e[17]!==o?(c=(0,l.jsxs)(l.Fragment,{children:[n,o]}),e[16]=n,e[17]=o,e[18]=c):c=e[18],c},"_");function B(f){let[e]=f;return e}h(B,"j");function C(f){return!f}h(C,"F");var q=h(f=>{let e=(0,v.c)(24),{entry:t}=f,i;e[0]!==t.fields?(i=y(t.fields),e[0]=t.fields,e[1]=i):i=e[1];let r=i,u;e[2]!==t.timestamp?(u=w(t.timestamp),e[2]=t.timestamp,e[3]=u):u=e[3];let s;e[4]!==u?(s=(0,l.jsx)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u}),e[4]=u,e[5]=s):s=e[5];let m=F[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,l.jsx)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,l.jsx)(N,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let p=t.functionPath??"\u2014",a;e[9]!==p?(a=(0,l.jsx)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:p}),e[9]=p,e[10]=a):a=e[10];let n;e[11]!==r.text?(n=r.text===""?null:(0,l.jsx)("span",{className:"ml-2 text-muted-foreground","data-testid":"lg-fields",children:r.text}),e[11]=r.text,e[12]=n):n=e[12];let o;e[13]!==t.message||e[14]!==n?(o=(0,l.jsxs)("span",{className:"min-w-0 flex-1 truncate",role:"gridcell",children:[t.message,n]}),e[13]=t.message,e[14]=n,e[15]=o):o=e[15];let c;e[16]!==r.errors?(c=r.errors.length===0?null:(0,l.jsx)("span",{className:"contents",role:"gridcell",children:(0,l.jsx)(L,{errors:r.errors})}),e[16]=r.errors,e[17]=c):c=e[17];let g;return e[18]!==c||e[19]!==s||e[20]!==d||e[21]!==a||e[22]!==o?(g=(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center",role:"none",children:[s,d,a,o,c]}),e[18]=c,e[19]=s,e[20]=d,e[21]=a,e[22]=o,e[23]=g):g=e[23],g},"D");export{F as a,L as b,q as c};
@@ -1 +1 @@
1
- import{a as ct}from"./chunk-FXZ6GEUP.js";import{a as lt}from"./chunk-J7M7G2BA.js";import"./chunk-JNWK5MJC.js";import{a as De}from"./chunk-FOURRGSO.js";import"./chunk-FPRVR763.js";import"./chunk-Y2YLTUMD.js";import"./chunk-YU67D2FL.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as it}from"./chunk-2KTN53PK.js";import{a as nt}from"./chunk-5G2OOLMF.js";import{b as rt}from"./chunk-EDL46BPM.js";import{a as Ye}from"./chunk-V4D77Q45.js";import"./chunk-4KPATTV6.js";import{h as Ue,i as ze}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as Ze}from"./chunk-A5INOAIL.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as Xe}from"./chunk-SZCXVIVT.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as qe}from"./chunk-X26D3KTK.js";import{b as et}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as Te}from"./chunk-UA7DC3LX.js";import"./chunk-KFDOGDD2.js";import{a as ot,b as st,c as dt,d as _e,e as q,f as T}from"./chunk-3OVNOP65.js";import"./chunk-UVMD7C4J.js";import"./chunk-FXSY2FCG.js";import"./chunk-EOFWXI3T.js";import{a as F}from"./chunk-LYVYUTQY.js";import{c as de}from"./chunk-AKC4XWCD.js";import{a as tt,e as at}from"./chunk-CB22PV3X.js";import{n as Ge}from"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as ce,h as He,i as Qe,j as Ve,s as Se,w as je,x as le}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as Be}from"./chunk-A6TVTNKO.js";import{a as Pe,b as We}from"./chunk-ADABTCDI.js";import{a as d,d as se}from"./chunk-5PEAXTYQ.js";var be=se(Be(),1),he=se(Pe(),1);var mt=se(Be(),1),O=se(Pe(),1);var m=se(We(),1);var Tt=He(F.runMigration),ut=d(t=>{let e=(0,mt.c)(98),{initialShardKey:r}=t,n=Ge(),a=ce(),{queryShardKey:o,setShardKey:i,shardKey:s}=it(r),[l,f]=(0,O.useState)(""),[h,g]=(0,O.useState)("up"),[p,b]=(0,O.useState)(!0),[v,x]=(0,O.useState)(!1),[y,u]=(0,O.useState)(null),[w,k]=(0,O.useState)(null),L;e[0]!==s?(L=s.trim(),e[0]=s,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=de(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ve,ye;e[5]!==o||e[6]!==$.data?(ve=d(()=>{$.data!==void 0&&rt(o)},"W"),ye=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ve,e[8]=ye):(ve=e[7],ye=e[8]),(0,O.useEffect)(ve,ye);let xe;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==s||e[14]!==$||e[15]!==a){let I=d(async()=>{let Ae=l.trim();if(Ae===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await n.query(Tt,{direction:h,dryRun:p,id:Ae},Qe(s));u(Le),$.refetch()}catch(Le){let qt=Le;u(null),k(Ve(qt))}x(!1)},"u");xe=d(()=>{Se(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=l,e[13]=s,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=d(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Ot=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=d(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=d(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let jt=Ne,_;e[20]!==i||e[21]!==s?(_=(0,m.jsx)(nt,{onChange:i,testId:"mg-shard-input",value:s}),e[20]=i,e[21]=s,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(lt,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(qe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("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"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(tt,{className:"overflow-hidden py-0",children:(0,m.jsx)(at,{className:"px-0",children:(0,m.jsxs)(ot,{"data-testid":"mg-table",children:[(0,m.jsx)(st,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(dt,{children:N.map(Ct)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(Ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Ot,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:jt,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==v||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(Xe,{"data-testid":"mg-run",disabled:v||!C,onClick:ke,type:"button",children:a(v?"Running\u2026":"Run")}):(0,m.jsx)(Ye,{confirmLabel:a(v?"Running\u2026":"Run migration?"),disabled:v||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=v,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ne;e[82]!==B||e[83]!==re?(ne=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==y||e[88]!==a?(oe=y!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[y.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:y.status}),y.processed,a(", changed"),y.changed]}),e[87]=y,e[88]=a,e[89]=oe):oe=e[89];let Oe;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ne||e[95]!==ie||e[96]!==oe?(Oe=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ne,ie,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=Oe):Oe=e[97],Oe},"yt");function Ct(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(et,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:je(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}d(Ct,"Je");var c=se(We(),1);var Ke=1;function Mt(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}d(Mt,"ue");var me=d(t=>typeof t=="object"&&t!==null,"O"),It=d(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","me"),Ft=d(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!It(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"he"),Rt=d((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"pe"),ht=d(t=>t.unique!==void 0,"Q"),ge=d(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Mt(a)),"M"),ft=d(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"U"),pt=d(t=>t.kind==="union"&&t.members?t.members.map(e=>ft(e)):[ft({...t,nullable:!1,optional:!1})],"W"),Lt=d((t,e)=>{if(e.kind!=="union")return!1;let r=pt(e);return pt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"ge"),S=d(t=>{switch(t.kind){case"array":return`array(${t.of?S(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?S(t.key):"?"}, ${t.of?S(t.of):"?"})`;case"union":return(t.members??[]).map(e=>S(e)).join(" | ");default:return t.kind}},"x"),fe=d((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),pe=d((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"F"),wt=d((t,e)=>{let r=JSON.stringify(t),n=JSON.stringify(e);return r===n?0:r<n?-1:1},"N"),ue=d(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(wt)}:{}}),"S"),gt=d(t=>t.kind==="union"?t.members??[]:[t],"B"),_t=d((t,e)=>{let r=[...t],n=[...e],a=new Set,o=new Set,i=d((s,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=n.findIndex((p,b)=>!a.has(b)&&s(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],n[g]]=Me(h,n[g])))}},"s");return i((s,l)=>JSON.stringify(s)===JSON.stringify(l),!1),i((s,l)=>ge(ue(s))===ge(ue(l)),!0),[r,n]},"ve"),Me=d((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=_t(gt(t),gt(e)),i=d((s,l)=>s.kind==="union"?{...s,members:l.toSorted(wt)}:l[0],"s");return[i(t,a),i(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},n={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],n[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],i=e.fields?.[a];o&&i&&r.fields&&n.fields&&([r.fields[a],n.fields[a]]=Me(o,i))}return[{...t,...r},{...e,...n}]},"R"),Dt=d((t,e,r,n,a)=>{let[o,i]=Me(r,n);if(o.kind===i.kind&&(!a||ge(o)===ge(i)))return;if(a&&Lt(o,i))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${S(o)} \u2192 ${S(i)} \u2014 every stored value stays valid`);if(o.kind!==i.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${i.kind} \u2014 add a data migration to convert existing values`);let s=Object.values(i.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&s.length>0&&s.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${S(o)} \u2192 ${S(i)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Kt=d((t,e,r,n,a)=>{let o=[];return r.unique!==n.unique&&o.push(n.unique===!0?{...fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`),field:e,uniqueOn:[e]}:pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&o.push(n.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),a&&r.refined!==n.refined&&o.push(n.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),o},"ye"),$t=d((t,e,r,n,a=!0)=>{let o=[],i=ht(r)&&ht(n),s=Dt(t,e,r,n,i);return s&&o.push(s),i&&o.push(...Kt(t,e,r,n,a)),r.optional&&!n.optional?o.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&o.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),o},"ee"),Et=d((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"xe"),Jt=d((t,e)=>e.refinementsRecorded!==!0||t.refinementsRecorded===!0,"ke"),At=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push({...Et(t,a,o),field:a}):n.push(...$t(t,a,i,o,Jt(e,r)).map(s=>({...s,field:a})))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.push({field:a,remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"$e"),Pt=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Rt(i,o)||n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`index ${a} on ${t} changed shape and is unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"changedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`index ${a} on ${t} changed shape \u2014 a query that relied on the old index may need updating`,table:t,type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&n.push({remediation:"none",severity:"safe",index:a,summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` no longer compiles`,table:t,scope:"table",type:"removedIndex"})},"we"),Bt=d((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`removed relation ${t}.${a} \u2014 the stored foreign-key values stay in place, but its \`onDelete\` action no longer runs and a \`with: { ${a} }\` read no longer compiles`,table:t,type:"removedRelation",warning:!0})},"Oe"),Ee="shardBy:_unknown_",Ce="global",Wt=d((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"Se"),Ut=d((t,e,r)=>{if(e===r)return r!==Ee?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${Ee}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Wt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode",...r===Ee?{}:{coverage:{shardMode:r,table:t}}}},"je"),bt=d(t=>t.memory!==void 0,"K"),vt=d(t=>t.after??0,"Y"),Je=d(t=>t.after===void 0?`{ field: "${t.field}" }`:`{ after: ${String(t.after)}, field: "${t.field}" }`,"_"),R=d(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),zt=d((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=d((s,l)=>({coverage:{table:t,ttl:{...l.after===void 0?{}:{after:l.after},field:l.field}},expiry:{...l.after===void 0?{}:{after:l.after},field:l.field,...e===void 0?{}:{previous:{...e.after===void 0?{}:{after:e.after},field:e.field}}},remediation:"backfill",scope:"table",severity:"breaking",summary:s,table:t,type:"changedTtlPolicy"}),"n"),a=d(s=>({remediation:"none",scope:"table",severity:"safe",summary:s,table:t,type:"changedTtlPolicy",warning:!0}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept, so they stay until something else deletes them`);if(e===void 0)return n(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; refresh or clear "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);if(e.field!==r.field)return n(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; populate "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);let o=vt(e),i=vt(r);return i<o?n(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; refresh "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r):i>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 every row stays, and expires later than it would have`):void 0},"Te"),Ht=d((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode",coverage:{memory:!0,table:t}}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&n.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering",identityRewrites:!0}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer .commitOrdered() \u2014 stored rows are untouched, but new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers`,table:t,type:"changedCommitOrdering",warning:!0}),n},"Fe"),Qt=d((t,e,r,n)=>{let a=Ut(t,e.shardMode,r.shardMode);if(a&&n.push(a),bt(e)&&bt(r)){n.push(...Ht(t,e,r));let o=zt(t,e.ttl,r.ttl);o&&n.push(o)}At(t,e,r,n),Pt(t,e,r,n),Bt(t,e,r,n)},"qe"),Vt=d((t,e)=>{let r=[],n=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Qt(a,i,o,r)}for(let a of Object.keys(n))e.tables[a]===void 0&&r.push({remediation:"none",scope:"table",severity:"safe",summary:`removed table ${a} \u2014 its rows are left in place in each shard's SQLite (nothing deletes them) but are unreachable through the schema; export the shard first if the data must be kept, or declare the table again to reach it`,table:a,type:"removedTable",warning:!0});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (export then import to move it). Revert the change, or declare a migration with covers: { jurisdiction: "${e.jurisdiction??"none"}" } once the data is moved.`,type:"changedJurisdiction",coverage:{jurisdiction:e.jurisdiction??"none"}})}return{changes:r}},"Me"),yt=d(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:S(r)})),"z"),xt=d((t,e,r)=>{let n={},a=e?.fields??{},o=r?.fields??{};for(let[i,s]of Object.entries(o)){let l=a[i];l===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=$t(t,i,l,s).length===0?"unchanged":"changed"}for(let i of Object.keys(a))o[i]===void 0&&(n[i]="removed");return n},"X"),Gt=d((t,e)=>{let{changes:r}=Vt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],o=d((i,s)=>i?"added":n.has(s)?"changed":"context","r");for(let[i,s]of Object.entries(e.tables)){let l=t?.tables[i],f=o(l===void 0,i);a.push({columns:yt(s),fieldStatus:xt(i,l,s),name:i,shardMode:s.shardMode,status:f})}for(let[i,s]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:yt(s),fieldStatus:xt(i,s,void 0),name:i,shardMode:s.shardMode,status:"removed"});return a.sort((i,s)=>i.name.localeCompare(s.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Ce"),kt=d(t=>{let e=Ft(t);return e.status==="ok"?e.snapshot:void 0},"Z"),Xt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Yt=d(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ie"),Zt=d(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:o,seq:i}=t,s=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==s?(l=le("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",s),e[0]=s,e[1]=l):l=e[1];let f=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=d(()=>{a(n)},"m"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==i?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=g):g=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let v;e[11]!==g||e[12]!==b?(v=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=v):v=e[13];let x;e[14]!==r?(x=je(r),e[14]=r,e[15]=x):x=e[15];let y;e[16]!==x?(y=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=y):y=e[17];let u;return e[18]!==y||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==v?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[v,y]})}),e[18]=y,e[19]=l,e[20]=f,e[21]=h,e[22]=v,e[23]=u):u=e[23],u},"Ee"),ea=d(t=>{let e=(0,be.c)(26),{breaking:r,count:n,first:a}=t,o=ce();if(a){let b;e[0]!==n?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=b):b=e[1];let v;e[2]!==o?(v=o("tables"),e[2]=o,e[3]=v):v=e[3];let x;e[4]!==v?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=x):x=e[5];let y;return e[6]!==b||e[7]!==x?(y=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=y):y=e[8],y}let i=r>0&&"text-destructive",s;e[9]!==i?(s=le("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=s):s=e[10];let l;e[11]!==n||e[12]!==s?(l=(0,c.jsx)("span",{className:s,children:n}),e[11]=n,e[12]=s,e[13]=l):l=e[13];let f;e[14]!==n||e[15]!==o?(f=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Ae"),Nt={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},ta=d((t,e)=>{let r=`${Nt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"De"),aa=d(t=>{let e=new Map;for(let n of t){let a=n.table??"",o=e.get(a);o===void 0?e.set(a,[n]):o.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Le"),ra=d(t=>{let e=(0,be.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"Je"),na=d(({pane:t,shardKey:e=""})=>{let r=ce(),n=ze(),a=Ue({strict:!1}).version,o=d(u=>{Se(n({search:{version:u},to:"/migrations"}))},"s"),i=de(F.schemaHistory,{},{shardKey:e}),s=i.data?.versions??[],l=a!==void 0&&s.some(u=>u.hash===a)?a:s[0]?.hash,f=s.findIndex(u=>u.hash===l),h=f===-1?void 0:s[f+1]?.hash,g=de(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=de(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=kt(g.data?.version?.snapshotJson);if(u!==void 0)return Gt(kt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),v=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Yt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Xt[w.status];return u},[b]);if(i.error!==null)return(0,c.jsx)(Te,{error:i.errorSource,testId:"sh-error"});if(s.length===0)return(0,c.jsx)(qe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let y=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ra,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:s.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(ea,{breaking:b?.breakingCount??0,count:h===void 0?v.length:y.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(ct,{fill:!0,nodeClasses:x,tables:v,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:aa(y).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=Nt[k.type],j=k.severity==="breaking",M=ta(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:le("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:le("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Pe"),ia=d(t=>le("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"_e"),_a=d(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,n=ce(),[a,o]=(0,he.useState)("diagram"),i;e[0]!==a?(i=d((g,p,b,v)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ia(a===g),"data-testid":b,onClick:d(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,v!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"s"),e[0]=a,e[1]=i):i=e[1];let s=i,l;e[2]!==n||e[3]!==s?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[s("diagram",n("Diagram"),"mg-pane-diagram"),s("changes",n("Changes"),"mg-pane-changes"),s("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=s,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ut,{initialShardKey:r})}):(0,c.jsx)(na,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"et");export{_a as default};
1
+ import{a as ct}from"./chunk-5SCMOA55.js";import{a as lt}from"./chunk-UDGBH3IC.js";import"./chunk-JNWK5MJC.js";import{a as De}from"./chunk-ZVTDYI5T.js";import"./chunk-CUUNHCMD.js";import"./chunk-Y2YLTUMD.js";import"./chunk-2VGEXP5J.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as it}from"./chunk-2KTN53PK.js";import{a as nt}from"./chunk-O3NLXHWS.js";import{b as rt}from"./chunk-EDL46BPM.js";import{a as Ye}from"./chunk-EH3PU4PH.js";import"./chunk-4KPATTV6.js";import{h as Ue,i as ze}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as Ze}from"./chunk-IGIBOJJG.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as Xe}from"./chunk-LMGNMZUF.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as qe}from"./chunk-KN4GQKJS.js";import{b as et}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as Te}from"./chunk-4UMUJTD2.js";import"./chunk-CYL7MEO2.js";import{a as ot,b as st,c as dt,d as _e,e as q,f as T}from"./chunk-YM56MNAN.js";import"./chunk-IXBHUFDE.js";import"./chunk-B2GQMLO3.js";import"./chunk-EOFWXI3T.js";import{a as F}from"./chunk-LYVYUTQY.js";import{c as de}from"./chunk-L62S7I64.js";import{a as tt,e as at}from"./chunk-JXGB4QDO.js";import{n as Ge}from"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as ce,h as He,i as Qe,j as Ve,s as Se,w as je,x as le}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as Be}from"./chunk-A6TVTNKO.js";import{a as Pe,b as We}from"./chunk-ADABTCDI.js";import{a as d,d as se}from"./chunk-5PEAXTYQ.js";var be=se(Be(),1),he=se(Pe(),1);var mt=se(Be(),1),O=se(Pe(),1);var m=se(We(),1);var Tt=He(F.runMigration),ut=d(t=>{let e=(0,mt.c)(98),{initialShardKey:r}=t,n=Ge(),a=ce(),{queryShardKey:o,setShardKey:i,shardKey:s}=it(r),[l,f]=(0,O.useState)(""),[h,g]=(0,O.useState)("up"),[p,b]=(0,O.useState)(!0),[v,x]=(0,O.useState)(!1),[y,u]=(0,O.useState)(null),[w,k]=(0,O.useState)(null),L;e[0]!==s?(L=s.trim(),e[0]=s,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=de(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,ve,ye;e[5]!==o||e[6]!==$.data?(ve=d(()=>{$.data!==void 0&&rt(o)},"W"),ye=[$.data,o],e[5]=o,e[6]=$.data,e[7]=ve,e[8]=ye):(ve=e[7],ye=e[8]),(0,O.useEffect)(ve,ye);let xe;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==s||e[14]!==$||e[15]!==a){let I=d(async()=>{let Ae=l.trim();if(Ae===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await n.query(Tt,{direction:h,dryRun:p,id:Ae},Qe(s));u(Le),$.refetch()}catch(Le){let qt=Le;u(null),k(Ve(qt))}x(!1)},"u");xe=d(()=>{Se(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=l,e[13]=s,e[14]=$,e[15]=a,e[16]=xe}else xe=e[16];let ke=xe,we;e[17]===Symbol.for("react.memo_cache_sentinel")?(we=d(I=>{f(I.target.value)},"Y"),e[17]=we):we=e[17];let Ot=we,$e;e[18]===Symbol.for("react.memo_cache_sentinel")?($e=d(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=$e):$e=e[18];let St=$e,Ne;e[19]===Symbol.for("react.memo_cache_sentinel")?(Ne=d(I=>{b(I.target.checked)},"ee"),e[19]=Ne):Ne=e[19];let jt=Ne,_;e[20]!==i||e[21]!==s?(_=(0,m.jsx)(nt,{onChange:i,testId:"mg-shard-input",value:s}),e[20]=i,e[21]=s,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(lt,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(Te,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(qe,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("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"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(tt,{className:"overflow-hidden py-0",children:(0,m.jsx)(at,{className:"px-0",children:(0,m.jsxs)(ot,{"data-testid":"mg-table",children:[(0,m.jsx)(st,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(dt,{children:N.map(Ct)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(Ze,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Ot,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:jt,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ke||e[73]!==v||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(Xe,{"data-testid":"mg-run",disabled:v||!C,onClick:ke,type:"button",children:a(v?"Running\u2026":"Run")}):(0,m.jsx)(Ye,{confirmLabel:a(v?"Running\u2026":"Run migration?"),disabled:v||!C,onConfirm:ke,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ke,e[73]=v,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ne;e[82]!==B||e[83]!==re?(ne=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==y||e[88]!==a?(oe=y!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[y.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:y.status}),y.processed,a(", changed"),y.changed]}),e[87]=y,e[88]=a,e[89]=oe):oe=e[89];let Oe;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ne||e[95]!==ie||e[96]!==oe?(Oe=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ne,ie,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=Oe):Oe=e[97],Oe},"yt");function Ct(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(et,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:je(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}d(Ct,"Je");var c=se(We(),1);var Ke=1;function Mt(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}d(Mt,"ue");var me=d(t=>typeof t=="object"&&t!==null,"O"),It=d(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","me"),Ft=d(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!It(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"he"),Rt=d((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"pe"),ht=d(t=>t.unique!==void 0,"Q"),ge=d(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Mt(a)),"M"),ft=d(t=>({form:JSON.stringify([ge(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"U"),pt=d(t=>t.kind==="union"&&t.members?t.members.map(e=>ft(e)):[ft({...t,nullable:!1,optional:!1})],"W"),Lt=d((t,e)=>{if(e.kind!=="union")return!1;let r=pt(e);return pt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"ge"),S=d(t=>{switch(t.kind){case"array":return`array(${t.of?S(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?S(t.key):"?"}, ${t.of?S(t.of):"?"})`;case"union":return(t.members??[]).map(e=>S(e)).join(" | ");default:return t.kind}},"x"),fe=d((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),pe=d((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"F"),wt=d((t,e)=>{let r=JSON.stringify(t),n=JSON.stringify(e);return r===n?0:r<n?-1:1},"N"),ue=d(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(wt)}:{}}),"S"),gt=d(t=>t.kind==="union"?t.members??[]:[t],"B"),_t=d((t,e)=>{let r=[...t],n=[...e],a=new Set,o=new Set,i=d((s,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=n.findIndex((p,b)=>!a.has(b)&&s(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],n[g]]=Me(h,n[g])))}},"s");return i((s,l)=>JSON.stringify(s)===JSON.stringify(l),!1),i((s,l)=>ge(ue(s))===ge(ue(l)),!0),[r,n]},"ve"),Me=d((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=_t(gt(t),gt(e)),i=d((s,l)=>s.kind==="union"?{...s,members:l.toSorted(wt)}:l[0],"s");return[i(t,a),i(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},n={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],n[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],i=e.fields?.[a];o&&i&&r.fields&&n.fields&&([r.fields[a],n.fields[a]]=Me(o,i))}return[{...t,...r},{...e,...n}]},"R"),Dt=d((t,e,r,n,a)=>{let[o,i]=Me(r,n);if(o.kind===i.kind&&(!a||ge(o)===ge(i)))return;if(a&&Lt(o,i))return pe(t,"widenedFieldShape",`field ${t}.${e} widened: ${S(o)} \u2192 ${S(i)} \u2014 every stored value stays valid`);if(o.kind!==i.kind)return fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${i.kind} \u2014 add a data migration to convert existing values`);let s=Object.values(i.fields??{});return a&&o.kind==="object"&&Object.keys(o.fields??{}).length===0&&s.length>0&&s.every(l=>l.optional)?pe(t,"widenedFieldShape",`field ${t}.${e} now records its optional object shape \u2014 stored values stay valid`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${S(o)} \u2192 ${S(i)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Kt=d((t,e,r,n,a)=>{let o=[];return r.unique!==n.unique&&o.push(n.unique===!0?{...fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`),field:e,uniqueOn:[e]}:pe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&o.push(n.nullable===!0?pe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),a&&r.refined!==n.refined&&o.push(n.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):pe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),o},"ye"),$t=d((t,e,r,n,a=!0)=>{let o=[],i=ht(r)&&ht(n),s=Dt(t,e,r,n,i);return s&&o.push(s),i&&o.push(...Kt(t,e,r,n,a)),r.optional&&!n.optional?o.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&o.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),o},"ee"),Et=d((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"xe"),Jt=d((t,e)=>e.refinementsRecorded!==!0||t.refinementsRecorded===!0,"ke"),At=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push({...Et(t,a,o),field:a}):n.push(...$t(t,a,i,o,Jt(e,r)).map(s=>({...s,field:a})))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.push({field:a,remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"$e"),Pt=d((t,e,r,n)=>{for(let[a,o]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Rt(i,o)||n.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`index ${a} on ${t} changed shape and is unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"changedIndex",uniqueOn:o.fields}:{remediation:"none",scope:"table",severity:"safe",summary:`index ${a} on ${t} changed shape \u2014 a query that relied on the old index may need updating`,table:t,type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&n.push({remediation:"none",severity:"safe",index:a,summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` no longer compiles`,table:t,scope:"table",type:"removedIndex"})},"we"),Bt=d((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`removed relation ${t}.${a} \u2014 the stored foreign-key values stay in place, but its \`onDelete\` action no longer runs and a \`with: { ${a} }\` read no longer compiles`,table:t,type:"removedRelation",warning:!0})},"Oe"),Ee="shardBy:_unknown_",Ce="global",Wt=d((t,e)=>t===Ce&&e.startsWith(`${Ce}:`)||e===Ce&&t.startsWith(`${Ce}:`),"Se"),Ut=d((t,e,r)=>{if(e===r)return r!==Ee?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${Ee}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Wt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode",...r===Ee?{}:{coverage:{shardMode:r,table:t}}}},"je"),bt=d(t=>t.memory!==void 0,"K"),vt=d(t=>t.after??0,"Y"),Je=d(t=>t.after===void 0?`{ field: "${t.field}" }`:`{ after: ${String(t.after)}, field: "${t.field}" }`,"_"),R=d(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),zt=d((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=d((s,l)=>({coverage:{table:t,ttl:{...l.after===void 0?{}:{after:l.after},field:l.field}},expiry:{...l.after===void 0?{}:{after:l.after},field:l.field,...e===void 0?{}:{previous:{...e.after===void 0?{}:{after:e.after},field:e.field}}},remediation:"backfill",scope:"table",severity:"breaking",summary:s,table:t,type:"changedTtlPolicy"}),"n"),a=d(s=>({remediation:"none",scope:"table",severity:"safe",summary:s,table:t,type:"changedTtlPolicy",warning:!0}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept, so they stay until something else deletes them`);if(e===void 0)return n(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; refresh or clear "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);if(e.field!==r.field)return n(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; populate "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r);let o=vt(e),i=vt(r);return i<o?n(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; refresh "${r.field}" on the rows that must survive, then declare a migration with covers: { table: "${t}", ttl: ${Je(r)} }`,r):i>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 every row stays, and expires later than it would have`):void 0},"Te"),Ht=d((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode",coverage:{memory:!0,table:t}}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&n.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering",identityRewrites:!0}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer .commitOrdered() \u2014 stored rows are untouched, but new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers`,table:t,type:"changedCommitOrdering",warning:!0}),n},"Fe"),Qt=d((t,e,r,n)=>{let a=Ut(t,e.shardMode,r.shardMode);if(a&&n.push(a),bt(e)&&bt(r)){n.push(...Ht(t,e,r));let o=zt(t,e.ttl,r.ttl);o&&n.push(o)}At(t,e,r,n),Pt(t,e,r,n),Bt(t,e,r,n)},"qe"),Vt=d((t,e)=>{let r=[],n=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Qt(a,i,o,r)}for(let a of Object.keys(n))e.tables[a]===void 0&&r.push({remediation:"none",scope:"table",severity:"safe",summary:`removed table ${a} \u2014 its rows are left in place in each shard's SQLite (nothing deletes them) but are unreachable through the schema; export the shard first if the data must be kept, or declare the table again to reach it`,table:a,type:"removedTable",warning:!0});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (export then import to move it). Revert the change, or declare a migration with covers: { jurisdiction: "${e.jurisdiction??"none"}" } once the data is moved.`,type:"changedJurisdiction",coverage:{jurisdiction:e.jurisdiction??"none"}})}return{changes:r}},"Me"),yt=d(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:S(r)})),"z"),xt=d((t,e,r)=>{let n={},a=e?.fields??{},o=r?.fields??{};for(let[i,s]of Object.entries(o)){let l=a[i];l===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=$t(t,i,l,s).length===0?"unchanged":"changed"}for(let i of Object.keys(a))o[i]===void 0&&(n[i]="removed");return n},"X"),Gt=d((t,e)=>{let{changes:r}=Vt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],o=d((i,s)=>i?"added":n.has(s)?"changed":"context","r");for(let[i,s]of Object.entries(e.tables)){let l=t?.tables[i],f=o(l===void 0,i);a.push({columns:yt(s),fieldStatus:xt(i,l,s),name:i,shardMode:s.shardMode,status:f})}for(let[i,s]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:yt(s),fieldStatus:xt(i,s,void 0),name:i,shardMode:s.shardMode,status:"removed"});return a.sort((i,s)=>i.name.localeCompare(s.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Ce"),kt=d(t=>{let e=Ft(t);return e.status==="ok"?e.snapshot:void 0},"Z"),Xt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Yt=d(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ie"),Zt=d(t=>{let e=(0,be.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:o,seq:i}=t,s=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==s?(l=le("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",s),e[0]=s,e[1]=l):l=e[1];let f=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=d(()=>{a(n)},"m"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==i?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=g):g=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let v;e[11]!==g||e[12]!==b?(v=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=v):v=e[13];let x;e[14]!==r?(x=je(r),e[14]=r,e[15]=x):x=e[15];let y;e[16]!==x?(y=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=y):y=e[17];let u;return e[18]!==y||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==v?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[v,y]})}),e[18]=y,e[19]=l,e[20]=f,e[21]=h,e[22]=v,e[23]=u):u=e[23],u},"Ee"),ea=d(t=>{let e=(0,be.c)(26),{breaking:r,count:n,first:a}=t,o=ce();if(a){let b;e[0]!==n?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=b):b=e[1];let v;e[2]!==o?(v=o("tables"),e[2]=o,e[3]=v):v=e[3];let x;e[4]!==v?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:v}),e[4]=v,e[5]=x):x=e[5];let y;return e[6]!==b||e[7]!==x?(y=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=y):y=e[8],y}let i=r>0&&"text-destructive",s;e[9]!==i?(s=le("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=s):s=e[10];let l;e[11]!==n||e[12]!==s?(l=(0,c.jsx)("span",{className:s,children:n}),e[11]=n,e[12]=s,e[13]=l):l=e[13];let f;e[14]!==n||e[15]!==o?(f=o(n===1?"change":"changes"),e[14]=n,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Ae"),Nt={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},ta=d((t,e)=>{let r=`${Nt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"De"),aa=d(t=>{let e=new Map;for(let n of t){let a=n.table??"",o=e.get(a);o===void 0?e.set(a,[n]):o.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Le"),ra=d(t=>{let e=(0,be.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"Je"),na=d(({pane:t,shardKey:e=""})=>{let r=ce(),n=ze(),a=Ue({strict:!1}).version,o=d(u=>{Se(n({search:{version:u},to:"/migrations"}))},"s"),i=de(F.schemaHistory,{},{shardKey:e}),s=i.data?.versions??[],l=a!==void 0&&s.some(u=>u.hash===a)?a:s[0]?.hash,f=s.findIndex(u=>u.hash===l),h=f===-1?void 0:s[f+1]?.hash,g=de(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=de(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=kt(g.data?.version?.snapshotJson);if(u!==void 0)return Gt(kt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),v=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Yt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Xt[w.status];return u},[b]);if(i.error!==null)return(0,c.jsx)(Te,{error:i.errorSource,testId:"sh-error"});if(s.length===0)return(0,c.jsx)(qe,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let y=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ra,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:s.map(u=>(0,c.jsx)(Zt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(ea,{breaking:b?.breakingCount??0,count:h===void 0?v.length:y.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(ct,{fill:!0,nodeClasses:x,tables:v,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:aa(y).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=Nt[k.type],j=k.severity==="breaking",M=ta(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:le("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:le("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Pe"),ia=d(t=>le("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"_e"),_a=d(t=>{let e=(0,be.c)(11),{initialShardKey:r}=t,n=ce(),[a,o]=(0,he.useState)("diagram"),i;e[0]!==a?(i=d((g,p,b,v)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ia(a===g),"data-testid":b,onClick:d(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,v!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:v})]}),"s"),e[0]=a,e[1]=i):i=e[1];let s=i,l;e[2]!==n||e[3]!==s?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[s("diagram",n("Diagram"),"mg-pane-diagram"),s("changes",n("Changes"),"mg-pane-changes"),s("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=s,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ut,{initialShardKey:r})}):(0,c.jsx)(na,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"et");export{_a as default};
@@ -1 +1 @@
1
- import{a as S}from"./chunk-X26D3KTK.js";import{a as q,b as M,c as A,d as w,e as C,f as E}from"./chunk-3OVNOP65.js";import{a as L}from"./chunk-CB22PV3X.js";import{B as g,j as v,r as N,s as j}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as I}from"./chunk-A6TVTNKO.js";import{a as H,b as R}from"./chunk-ADABTCDI.js";import{a as u,d as x}from"./chunk-5PEAXTYQ.js";var Q=x(I(),1),d=x(H(),1);var a=x(R(),1);var T={volume:"Request volume per function",latency:"Latency p50 / p95 per function",hotShards:"Hot shards"},O=Object.keys(T),P={error:null,loading:!0,rows:null},$=u(s=>Object.keys(s[0]??{}),"B"),U=u(s=>{let e=(0,Q.c)(22),{state:y,title:o}=s,l=g(),{error:t,loading:r,rows:n}=y,c;if(e[0]!==t||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==o){let b=n===null?[]:$(n),i;e[6]!==l||e[7]!==o?(i=l(o),e[6]=l,e[7]=o,e[8]=i):i=e[8];let p;e[9]!==i?(p=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[9]=i,e[10]=p):p=e[10];let m;e[11]!==r||e[12]!==l?(m=r&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:l("Loading\u2026")}),e[11]=r,e[12]=l,e[13]=m):m=e[13];let h;e[14]!==t||e[15]!==r?(h=!r&&t!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:t}),e[14]=t,e[15]=r,e[16]=h):h=e[16];let f;e[17]!==t||e[18]!==r||e[19]!==n||e[20]!==l?(f=!r&&t===null&&n!==null&&n.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:l("No data points yet.")}),e[17]=t,e[18]=r,e[19]=n,e[20]=l,e[21]=f):f=e[21],c=(0,a.jsxs)(L,{className:"gap-0 py-0","data-testid":`analytics-panel-${o}`,children:[p,m,h,f,!r&&t===null&&n!==null&&n.length>0&&(0,a.jsxs)(q,{children:[(0,a.jsx)(M,{children:(0,a.jsx)(w,{children:b.map(W)})}),(0,a.jsx)(A,{children:n.map((V,B)=>(0,a.jsx)(w,{children:b.map(k=>(0,a.jsx)(E,{className:"font-mono text-xs",children:N(V[k])},k))},B))})]})]}),e[0]=t,e[1]=r,e[2]=n,e[3]=l,e[4]=o,e[5]=c}else c=e[5];return c},"V"),G=u(({runQuery:s}={})=>{let e=g(),[y,o]=(0,d.useState)({}),l=(0,d.useCallback)(async t=>{if(s!==void 0)for(let r of O){if(t.cancelled)return;o(n=>({...n,[r]:P}));try{let{rows:n}=await s(r);t.cancelled||o(c=>({...c,[r]:{error:null,loading:!1,rows:n}}))}catch(n){t.cancelled||o(c=>({...c,[r]:{error:v(n),loading:!1,rows:null}}))}}},[s]);return(0,d.useEffect)(()=>{let t={cancelled:!1};return j(l(t)),()=>{t.cancelled=!0}},[l]),s===void 0?(0,a.jsx)(S,{description:e("Analytics usage panels read through your worker, never from the browser. Pass studio.analyticsSqlQuery, a runner that calls an admin-only action running functionUsageQuery(panel) through ctx.analyticsSql, to enable these panels."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"})}),testId:"analytics-not-configured",title:e("Analytics usage panels are not wired up.")}):(0,a.jsx)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:O.map(t=>(0,a.jsx)(U,{state:y[t]??P,title:T[t]},t))})},"X");function W(s){return(0,a.jsx)(C,{children:s},s)}u(W,"$");export{G as AnalyticsPanel};
1
+ import{a as S}from"./chunk-KN4GQKJS.js";import{a as q,b as M,c as A,d as w,e as C,f as E}from"./chunk-YM56MNAN.js";import{a as L}from"./chunk-JXGB4QDO.js";import{B as g,j as v,r as N,s as j}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as I}from"./chunk-A6TVTNKO.js";import{a as H,b as R}from"./chunk-ADABTCDI.js";import{a as u,d as x}from"./chunk-5PEAXTYQ.js";var Q=x(I(),1),d=x(H(),1);var a=x(R(),1);var T={volume:"Request volume per function",latency:"Latency p50 / p95 per function",hotShards:"Hot shards"},O=Object.keys(T),P={error:null,loading:!0,rows:null},$=u(s=>Object.keys(s[0]??{}),"B"),U=u(s=>{let e=(0,Q.c)(22),{state:y,title:o}=s,l=g(),{error:t,loading:r,rows:n}=y,c;if(e[0]!==t||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==o){let b=n===null?[]:$(n),i;e[6]!==l||e[7]!==o?(i=l(o),e[6]=l,e[7]=o,e[8]=i):i=e[8];let p;e[9]!==i?(p=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[9]=i,e[10]=p):p=e[10];let m;e[11]!==r||e[12]!==l?(m=r&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:l("Loading\u2026")}),e[11]=r,e[12]=l,e[13]=m):m=e[13];let h;e[14]!==t||e[15]!==r?(h=!r&&t!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:t}),e[14]=t,e[15]=r,e[16]=h):h=e[16];let f;e[17]!==t||e[18]!==r||e[19]!==n||e[20]!==l?(f=!r&&t===null&&n!==null&&n.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:l("No data points yet.")}),e[17]=t,e[18]=r,e[19]=n,e[20]=l,e[21]=f):f=e[21],c=(0,a.jsxs)(L,{className:"gap-0 py-0","data-testid":`analytics-panel-${o}`,children:[p,m,h,f,!r&&t===null&&n!==null&&n.length>0&&(0,a.jsxs)(q,{children:[(0,a.jsx)(M,{children:(0,a.jsx)(w,{children:b.map(W)})}),(0,a.jsx)(A,{children:n.map((V,B)=>(0,a.jsx)(w,{children:b.map(k=>(0,a.jsx)(E,{className:"font-mono text-xs",children:N(V[k])},k))},B))})]})]}),e[0]=t,e[1]=r,e[2]=n,e[3]=l,e[4]=o,e[5]=c}else c=e[5];return c},"V"),G=u(({runQuery:s}={})=>{let e=g(),[y,o]=(0,d.useState)({}),l=(0,d.useCallback)(async t=>{if(s!==void 0)for(let r of O){if(t.cancelled)return;o(n=>({...n,[r]:P}));try{let{rows:n}=await s(r);t.cancelled||o(c=>({...c,[r]:{error:null,loading:!1,rows:n}}))}catch(n){t.cancelled||o(c=>({...c,[r]:{error:v(n),loading:!1,rows:null}}))}}},[s]);return(0,d.useEffect)(()=>{let t={cancelled:!1};return j(l(t)),()=>{t.cancelled=!0}},[l]),s===void 0?(0,a.jsx)(S,{description:e("Analytics usage panels read through your worker, never from the browser. Pass studio.analyticsSqlQuery, a runner that calls an admin-only action running functionUsageQuery(panel) through ctx.analyticsSql, to enable these panels."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"})}),testId:"analytics-not-configured",title:e("Analytics usage panels are not wired up.")}):(0,a.jsx)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:O.map(t=>(0,a.jsx)(U,{state:y[t]??P,title:T[t]},t))})},"X");function W(s){return(0,a.jsx)(C,{children:s},s)}u(W,"$");export{G as AnalyticsPanel};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-JAY3ZKY6.js";import{a as ne}from"./chunk-X26D3KTK.js";import{b as Z}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as O}from"./chunk-CB22PV3X.js";import{i as se,n as X}from"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as re,w as le,x as Y}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as ce}from"./chunk-A6TVTNKO.js";import{b as me}from"./chunk-ADABTCDI.js";import{a as k,d as ae}from"./chunk-5PEAXTYQ.js";var te=ae(ce(),1);var a=ae(me(),1);var pe="/_lunora/health",he="/_lunora/health/ready",ue=k((r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,"me"),fe=k(()=>{let r=X();return async e=>{let w=e==="ready"?he:pe,t=r.getAuthToken(),y=ue(r.url,w);try{let i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),p=null;try{p=await i.json()}catch{p=null}return{body:p,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},"pe"),ge={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ye=k(r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok","fe"),ie=k(r=>{let e=(0,te.c)(13),{label:w,level:t,testId:y,value:i}=r,p=ge[t],d;e[0]!==p?(d=Y("size-1.5 shrink-0 rounded-full",p),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==d?(o=(0,a.jsx)("span",{"aria-hidden":"true",className:d}),e[2]=d,e[3]=o):o=e[3];let c;e[4]!==w||e[5]!==o?(c=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[o,w]}),e[4]=w,e[5]=o,e[6]=c):c=e[6];let h;e[7]!==y||e[8]!==i?(h=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=h):h=e[9];let C;return e[10]!==c||e[11]!==h?(C=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[c,h]})}),e[10]=c,e[11]=h,e[12]=C):C=e[12],C},"Z"),Ie=k(r=>{let e=(0,te.c)(107),{probe:w}=r,t=re(),y=X(),i=fe(),p=w??i,d;e[0]!==p?(d=k(async()=>{let[s,n]=await Promise.all([p("live"),p("ready")]);return{live:s,ready:n}},"o"),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==y?(o=y.clientIdentifier(),e[2]=y,e[3]=o):o=e[3];let c;e[4]!==o?(c=["deployment-health",o],e[4]=o,e[5]=c):c=e[5];let h;e[6]!==d||e[7]!==c?(h={queryFn:d,queryKey:c},e[6]=d,e[7]=c,e[8]=h):h=e[8];let{data:C,isPending:de}=se(h),Q=C?.live??null,oe=C?.ready??null;if(de){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(ee,{className:"h-16 w-full"}),(0,a.jsx)(ee,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}let l=Q?.body??null;if(l===null){let s=Q?.status===403,n;e[10]!==s||e[11]!==Q?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:Q?.error??t("no response")}),e[10]=s,e[11]=Q?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let f;return e[16]!==n||e[17]!==m?(f=(0,a.jsx)(ne,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=f):f=e[18],f}let J;e[19]!==l.status?(J=ye(l.status),e[19]=l.status,e[20]=J):J=e[20];let W=J,u;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],u=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],u=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],u=s}let _=oe?.ok??!1,G=_?"ok":"crit",j,H,I,x,N,v,S,V,b,P;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==W||e[32]!==G||e[33]!==_||e[34]!==u||e[35]!==t){let s=[...l.checks].toSorted(xe);H="flex flex-col gap-6",I="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(x=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=x):x=e[49];let m;e[50]!==u?(m=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:u}),e[50]=u,e[51]=m):m=e[51];let f;e[52]!==l.appName||e[53]!==l.appVersion?(f=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," \xB7 ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=f):f=e[54];let D;e[55]!==m||e[56]!==f?(D=(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"grid leading-tight",children:[m,f]})}),e[55]=m,e[56]=f,e[57]=D):D=e[57];let T;e[58]!==t?(T=t("Checked"),e[58]=t,e[59]=T):T=e[59];let $;e[60]!==T?($=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[60]=T,e[61]=$):$=e[61];let q;e[62]!==l.timestamp?(q=le(l.timestamp),e[62]=l.timestamp,e[63]=q):q=e[63];let B;e[64]!==q?(B=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:q}),e[64]=q,e[65]=B):B=e[65];let E;e[66]!==$||e[67]!==B?(E=(0,a.jsxs)("div",{className:"text-end",children:[$,B]}),e[66]=$,e[67]=B,e[68]=E):E=e[68],e[69]!==D||e[70]!==E?(N=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[D,E]})}),e[69]=D,e[70]=E,e[71]=N):N=e[71];let L;e[72]!==t?(L=t("Liveness"),e[72]=t,e[73]=L):L=e[73];let R;e[74]!==W||e[75]!==u||e[76]!==L?(R=(0,a.jsx)(ie,{label:L,level:W,testId:"dh-liveness",value:u}),e[74]=W,e[75]=u,e[76]=L,e[77]=R):R=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let A;e[80]!==_||e[81]!==t?(A=t(_?"Ready":"Not ready"),e[80]=_,e[81]=t,e[82]=A):A=e[82];let F;e[83]!==G||e[84]!==U||e[85]!==A?(F=(0,a.jsx)(ie,{label:U,level:G,testId:"dh-readiness",value:A}),e[83]=G,e[84]=U,e[85]=A,e[86]=F):F=e[86],e[87]!==R||e[88]!==F?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[R,F]}),e[87]=R,e[88]=F,e[89]=v):v=e[89],j=O,S="gap-0 py-0",V="dh-checks";let K;e[90]!==t?(K=t("Subsystem checks"),e[90]=t,e[91]=K):K=e[91],e[92]!==K?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[92]=K,e[93]=b):b=e[93],P=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(g=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Y("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&(0,a.jsx)(Z,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:g.message}),(0,a.jsx)(Z,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=W,e[32]=G,e[33]=_,e[34]=u,e[35]=t,e[36]=j,e[37]=H,e[38]=I,e[39]=x,e[40]=N,e[41]=v,e[42]=S,e[43]=V,e[44]=b,e[45]=P}else j=e[36],H=e[37],I=e[38],x=e[39],N=e[40],v=e[41],S=e[42],V=e[43],b=e[44],P=e[45];let z;e[94]!==j||e[95]!==S||e[96]!==V||e[97]!==b||e[98]!==P?(z=(0,a.jsxs)(j,{className:S,"data-testid":V,children:[b,P]}),e[94]=j,e[95]=S,e[96]=V,e[97]=b,e[98]=P,e[99]=z):z=e[99];let M;return e[100]!==H||e[101]!==I||e[102]!==x||e[103]!==N||e[104]!==v||e[105]!==z?(M=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[x,N,v,z]}),e[100]=H,e[101]=I,e[102]=x,e[103]=N,e[104]=v,e[105]=z,e[106]=M):M=e[106],M},"_e");function xe(r,e){return r.name.localeCompare(e.name)}k(xe,"he");export{Ie as DeploymentHealthPanel};
1
+ import{a as ee}from"./chunk-AUGN55ZM.js";import{a as ne}from"./chunk-KN4GQKJS.js";import{b as Z}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as O}from"./chunk-JXGB4QDO.js";import{i as se,n as X}from"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as re,w as le,x as Y}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as ce}from"./chunk-A6TVTNKO.js";import{b as me}from"./chunk-ADABTCDI.js";import{a as k,d as ae}from"./chunk-5PEAXTYQ.js";var te=ae(ce(),1);var a=ae(me(),1);var pe="/_lunora/health",he="/_lunora/health/ready",ue=k((r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,"me"),fe=k(()=>{let r=X();return async e=>{let w=e==="ready"?he:pe,t=r.getAuthToken(),y=ue(r.url,w);try{let i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),p=null;try{p=await i.json()}catch{p=null}return{body:p,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},"pe"),ge={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ye=k(r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok","fe"),ie=k(r=>{let e=(0,te.c)(13),{label:w,level:t,testId:y,value:i}=r,p=ge[t],d;e[0]!==p?(d=Y("size-1.5 shrink-0 rounded-full",p),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==d?(o=(0,a.jsx)("span",{"aria-hidden":"true",className:d}),e[2]=d,e[3]=o):o=e[3];let c;e[4]!==w||e[5]!==o?(c=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[o,w]}),e[4]=w,e[5]=o,e[6]=c):c=e[6];let h;e[7]!==y||e[8]!==i?(h=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=h):h=e[9];let C;return e[10]!==c||e[11]!==h?(C=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[c,h]})}),e[10]=c,e[11]=h,e[12]=C):C=e[12],C},"Z"),Ie=k(r=>{let e=(0,te.c)(107),{probe:w}=r,t=re(),y=X(),i=fe(),p=w??i,d;e[0]!==p?(d=k(async()=>{let[s,n]=await Promise.all([p("live"),p("ready")]);return{live:s,ready:n}},"o"),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==y?(o=y.clientIdentifier(),e[2]=y,e[3]=o):o=e[3];let c;e[4]!==o?(c=["deployment-health",o],e[4]=o,e[5]=c):c=e[5];let h;e[6]!==d||e[7]!==c?(h={queryFn:d,queryKey:c},e[6]=d,e[7]=c,e[8]=h):h=e[8];let{data:C,isPending:de}=se(h),Q=C?.live??null,oe=C?.ready??null;if(de){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(ee,{className:"h-16 w-full"}),(0,a.jsx)(ee,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}let l=Q?.body??null;if(l===null){let s=Q?.status===403,n;e[10]!==s||e[11]!==Q?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:Q?.error??t("no response")}),e[10]=s,e[11]=Q?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let f;return e[16]!==n||e[17]!==m?(f=(0,a.jsx)(ne,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=f):f=e[18],f}let J;e[19]!==l.status?(J=ye(l.status),e[19]=l.status,e[20]=J):J=e[20];let W=J,u;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],u=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],u=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],u=s}let _=oe?.ok??!1,G=_?"ok":"crit",j,H,I,x,N,v,S,V,b,P;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==W||e[32]!==G||e[33]!==_||e[34]!==u||e[35]!==t){let s=[...l.checks].toSorted(xe);H="flex flex-col gap-6",I="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(x=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=x):x=e[49];let m;e[50]!==u?(m=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:u}),e[50]=u,e[51]=m):m=e[51];let f;e[52]!==l.appName||e[53]!==l.appVersion?(f=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," \xB7 ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=f):f=e[54];let D;e[55]!==m||e[56]!==f?(D=(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"grid leading-tight",children:[m,f]})}),e[55]=m,e[56]=f,e[57]=D):D=e[57];let T;e[58]!==t?(T=t("Checked"),e[58]=t,e[59]=T):T=e[59];let $;e[60]!==T?($=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[60]=T,e[61]=$):$=e[61];let q;e[62]!==l.timestamp?(q=le(l.timestamp),e[62]=l.timestamp,e[63]=q):q=e[63];let B;e[64]!==q?(B=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:q}),e[64]=q,e[65]=B):B=e[65];let E;e[66]!==$||e[67]!==B?(E=(0,a.jsxs)("div",{className:"text-end",children:[$,B]}),e[66]=$,e[67]=B,e[68]=E):E=e[68],e[69]!==D||e[70]!==E?(N=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[D,E]})}),e[69]=D,e[70]=E,e[71]=N):N=e[71];let L;e[72]!==t?(L=t("Liveness"),e[72]=t,e[73]=L):L=e[73];let R;e[74]!==W||e[75]!==u||e[76]!==L?(R=(0,a.jsx)(ie,{label:L,level:W,testId:"dh-liveness",value:u}),e[74]=W,e[75]=u,e[76]=L,e[77]=R):R=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let A;e[80]!==_||e[81]!==t?(A=t(_?"Ready":"Not ready"),e[80]=_,e[81]=t,e[82]=A):A=e[82];let F;e[83]!==G||e[84]!==U||e[85]!==A?(F=(0,a.jsx)(ie,{label:U,level:G,testId:"dh-readiness",value:A}),e[83]=G,e[84]=U,e[85]=A,e[86]=F):F=e[86],e[87]!==R||e[88]!==F?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[R,F]}),e[87]=R,e[88]=F,e[89]=v):v=e[89],j=O,S="gap-0 py-0",V="dh-checks";let K;e[90]!==t?(K=t("Subsystem checks"),e[90]=t,e[91]=K):K=e[91],e[92]!==K?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[92]=K,e[93]=b):b=e[93],P=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(g=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Y("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&(0,a.jsx)(Z,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:g.message}),(0,a.jsx)(Z,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=W,e[32]=G,e[33]=_,e[34]=u,e[35]=t,e[36]=j,e[37]=H,e[38]=I,e[39]=x,e[40]=N,e[41]=v,e[42]=S,e[43]=V,e[44]=b,e[45]=P}else j=e[36],H=e[37],I=e[38],x=e[39],N=e[40],v=e[41],S=e[42],V=e[43],b=e[44],P=e[45];let z;e[94]!==j||e[95]!==S||e[96]!==V||e[97]!==b||e[98]!==P?(z=(0,a.jsxs)(j,{className:S,"data-testid":V,children:[b,P]}),e[94]=j,e[95]=S,e[96]=V,e[97]=b,e[98]=P,e[99]=z):z=e[99];let M;return e[100]!==H||e[101]!==I||e[102]!==x||e[103]!==N||e[104]!==v||e[105]!==z?(M=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[x,N,v,z]}),e[100]=H,e[101]=I,e[102]=x,e[103]=N,e[104]=v,e[105]=z,e[106]=M):M=e[106],M},"_e");function xe(r,e){return r.name.localeCompare(e.name)}k(xe,"he");export{Ie as DeploymentHealthPanel};
@@ -1,4 +1,4 @@
1
- import{a as Pe}from"./chunk-77PKR3WU.js";import{a as he}from"./chunk-FOURRGSO.js";import{a as le}from"./chunk-YV6YBDCS.js";import{a as V}from"./chunk-JAY3ZKY6.js";import{d as Ie,f as Oe,g as $e,k as ie}from"./chunk-2NUCBQFU.js";import{a as Ce}from"./chunk-5G2OOLMF.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-A5INOAIL.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as U}from"./chunk-SZCXVIVT.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as E}from"./chunk-X26D3KTK.js";import{b as Se}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as ke}from"./chunk-LYVYUTQY.js";import{n as F}from"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as M,b as be,g as ye,h as oe,i as se,j as ue,p as ve,s as Ne,v as ae,x as fe}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as me,b as re}from"./chunk-ADABTCDI.js";import{a as u,d as L}from"./chunk-5PEAXTYQ.js";var Qe=L(te(),1),xe=L(me(),1);var Y=L(te(),1),X=L(me(),1);var R=L(re(),1);var Xe=oe(ke.listTables),Ye=["react","client","cli"],Ze={action:"action",mutation:"mutation",query:"query"},Te=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),et=u(({file:t,fn:e,kind:a})=>`await client.${Ze[a]}(api.${t}.${e}, { /* args */ });`,"ae"),tt=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"se"),rt=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"oe"),at=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
1
+ import{a as Pe}from"./chunk-YIXBY57R.js";import{a as he}from"./chunk-ZVTDYI5T.js";import{a as le}from"./chunk-6ZMVAF2O.js";import{a as V}from"./chunk-AUGN55ZM.js";import{d as Ie,f as Oe,g as $e,k as ie}from"./chunk-2NUCBQFU.js";import{a as Ce}from"./chunk-O3NLXHWS.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-IGIBOJJG.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as U}from"./chunk-LMGNMZUF.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as E}from"./chunk-KN4GQKJS.js";import{b as Se}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as ke}from"./chunk-LYVYUTQY.js";import{n as F}from"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as M,b as be,g as ye,h as oe,i as se,j as ue,p as ve,s as Ne,v as ae,x as fe}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as me,b as re}from"./chunk-ADABTCDI.js";import{a as u,d as L}from"./chunk-5PEAXTYQ.js";var Qe=L(te(),1),xe=L(me(),1);var Y=L(te(),1),X=L(me(),1);var R=L(re(),1);var Xe=oe(ke.listTables),Ye=["react","client","cli"],Ze={action:"action",mutation:"mutation",query:"query"},Te=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),et=u(({file:t,fn:e,kind:a})=>`await client.${Ze[a]}(api.${t}.${e}, { /* args */ });`,"ae"),tt=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"se"),rt=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"oe"),at=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
2
  `),"ce"),nt=u((t,e)=>{switch(t){case"cli":return rt(e);case"client":return et(e);default:return tt(e)}},"re"),Re=u(t=>{let e=(0,Y.c)(19),{code:a,label:r,testId:n}=t,s=M(),o;e[0]!==a?(o=u(()=>{ae(a)},"c"),e[0]=a,e[1]=o):o=e[1];let i=o,c;e[2]!==r?(c=(0,R.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i||e[7]!==m||e[8]!==l?(p=(0,R.jsx)(U,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=p):p=e[9];let f;e[10]!==c||e[11]!==p?(f=(0,R.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[c,p]}),e[10]=c,e[11]=p,e[12]=f):f=e[12];let h;e[13]!==a||e[14]!==n?(h=(0,R.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=h):h=e[15];let g;return e[16]!==f||e[17]!==h?(g=(0,R.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18],g},"U"),ot=u(t=>{let e=(0,Y.c)(46),{file:a,fn:r,kind:n}=t,s=M(),[o,i]=(0,X.useState)("react"),c,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let w={file:a,fn:r,kind:n},P;e[8]!==s?(P=s("CLI"),e[8]=s,e[9]=P):P=e[9];let O;e[10]!==s?(O=s("Client"),e[10]=s,e[11]=O):O=e[11];let S;e[12]!==s?(S=s("React"),e[12]=s,e[13]=S):S=e[13];let T;e[14]!==P||e[15]!==O||e[16]!==S?(T={cli:P,client:O,react:S},e[14]=P,e[15]=O,e[16]=S,e[17]=T):T=e[17],l=T;let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=u(_=>{i(_.currentTarget.dataset.tab)},"B"),e[18]=A):A=e[18],c=A,m=nt(o,w),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=c,e[6]=m,e[7]=l}else c=e[5],m=e[6],l=e[7];let p=m,f=`api.${a}.${r}`,h;e[19]!==f?(h=(0,R.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:f}),e[19]=f,e[20]=h):h=e[20];let g;e[21]!==n||e[22]!==s?(g=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=g):g=e[23];let x;e[24]!==g?(x=(0,R.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),e[24]=g,e[25]=x):x=e[25];let v;e[26]!==h||e[27]!==x?(v=(0,R.jsxs)("div",{children:[h,x]}),e[26]=h,e[27]=x,e[28]=v):v=e[28];let N;e[29]!==s?(N=s("Snippet flavour"),e[29]=s,e[30]=N):N=e[30];let y;e[31]!==c||e[32]!==o||e[33]!==l?(y=Ye.map(w=>(0,R.jsx)(U,{"aria-selected":o===w,"data-tab":w,"data-testid":`api-tab-${w}`,onClick:c,role:"tab",size:"xs",type:"button",variant:o===w?"default":"outline",children:l[w]},w)),e[31]=c,e[32]=o,e[33]=l,e[34]=y):y=e[34];let b;e[35]!==N||e[36]!==y?(b=(0,R.jsx)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:y}),e[35]=N,e[36]=y,e[37]=b):b=e[37];let I=l[o],C=`api-snippet-${o}`,$;e[38]!==p||e[39]!==I||e[40]!==C?($=(0,R.jsx)(Re,{code:p,label:I,testId:C}),e[38]=p,e[39]=I,e[40]=C,e[41]=$):$=e[41];let k;return e[42]!==$||e[43]!==v||e[44]!==b?(k=(0,R.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[v,b,$]}),e[42]=$,e[43]=v,e[44]=b,e[45]=k):k=e[45],k},"de"),st=u(t=>{let e=(0,Y.c)(19),{name:a}=t,r=M(),n;e[0]!==a?(n=at(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,R.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,R.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let m;e[8]!==o||e[9]!==c?(m=(0,R.jsxs)("div",{children:[o,c]}),e[8]=o,e[9]=c,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let p;e[13]!==s||e[14]!==l?(p=(0,R.jsx)(Re,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=p):p=e[15];let f;return e[16]!==m||e[17]!==p?(f=(0,R.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,p]}),e[16]=m,e[17]=p,e[18]=f):f=e[18],f},"fe"),je=u(t=>{let e=(0,Y.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"m"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let c=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==c||e[5]!==m||e[6]!==s?(l=(0,R.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:c,type:"button",children:r}),e[3]=r,e[4]=c,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),it=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=Te(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"pe"),Ae=u(t=>{let e=(0,Y.c)(58),{functions:a,initialShardKey:r}=t,n=M(),s=F(),[o,i]=(0,X.useState)(null),[c,m]=(0,X.useState)(null),l,p;e[0]!==s||e[1]!==r?(l=u(()=>{let _=!1;return s.query(Xe,{},se(r??"")).then(j=>(_||i(j),j)).catch(()=>{_||i([])}),()=>{_=!0}},"o"),p=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=p):(l=e[2],p=e[3]),(0,X.useEffect)(l,p);let f,h,g,x,v,N,y,b,I,C;if(e[4]!==a||e[5]!==c||e[6]!==n||e[7]!==o){let _=a??[],j=it(_),q=(o??[]).map(lt).toSorted(dt),J;e[18]===Symbol.for("react.memo_cache_sentinel")?(J=u(K=>{m({kind:"fn",path:K})},"P"),e[18]=J):J=e[18];let W=J,Q;e[19]===Symbol.for("react.memo_cache_sentinel")?(Q=u(K=>{m({kind:"table",name:K})},"j"),e[19]=Q):Q=e[19];let Ve=Q;h=c?.kind==="fn"?_.find(K=>K.path===c.path):void 0,f=_.length>0||q.length>0,g=h===void 0?void 0:Te(h.path),I="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",C="lunora-api-docs",e[20]!==n?(x=n("API resources"),e[20]=n,e[21]=x):x=e[21],v="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==c||e[23]!==n?(ne=u(K=>(0,R.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,R.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K.file||n("(root)")}),K.items.map(ee=>(0,R.jsx)(je,{active:c?.kind==="fn"&&c.path===ee.path,label:ee.fn,onSelect:W,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},K.file),"q"),e[22]=c,e[23]=n,e[24]=ne):ne=e[24],y=j.map(ne),b=q.length>0&&(0,R.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,R.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),q.map(K=>(0,R.jsx)(je,{active:c?.kind==="table"&&c.name===K,label:K,onSelect:Ve,testId:`api-rail-table-${K}`,value:K},K))]}),e[4]=a,e[5]=c,e[6]=n,e[7]=o,e[8]=f,e[9]=h,e[10]=g,e[11]=x,e[12]=v,e[13]=N,e[14]=y,e[15]=b,e[16]=I,e[17]=C}else f=e[8],h=e[9],g=e[10],x=e[11],v=e[12],N=e[13],y=e[14],b=e[15],I=e[16],C=e[17];let $;e[25]!==f||e[26]!==n?($=!f&&(0,R.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=$):$=e[27];let k;e[28]!==$||e[29]!==x||e[30]!==v||e[31]!==N||e[32]!==y||e[33]!==b?(k=(0,R.jsxs)("nav",{"aria-label":x,className:v,"data-testid":N,children:[y,b,$]}),e[28]=$,e[29]=x,e[30]=v,e[31]=N,e[32]=y,e[33]=b,e[34]=k):k=e[34];let w;e[35]!==c||e[36]!==n?(w=c===null&&(0,R.jsx)(E,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=c,e[36]=n,e[37]=w):w=e[37];let P;e[38]!==c?.kind||e[39]!==h||e[40]!==g?(P=c?.kind==="fn"&&h!==void 0&&g!==void 0&&(0,R.jsx)(ot,{file:g.file,fn:g.fn,kind:h.kind},h.path),e[38]=c?.kind,e[39]=h,e[40]=g,e[41]=P):P=e[41];let O;e[42]!==c?.kind||e[43]!==h||e[44]!==n?(O=c?.kind==="fn"&&h===void 0&&(0,R.jsx)(E,{testId:"api-empty",title:n("API usage snippets")}),e[42]=c?.kind,e[43]=h,e[44]=n,e[45]=O):O=e[45];let S;e[46]!==c?(S=c?.kind==="table"&&(0,R.jsx)(st,{name:c.name}),e[46]=c,e[47]=S):S=e[47];let T;e[48]!==w||e[49]!==P||e[50]!==O||e[51]!==S?(T=(0,R.jsxs)("div",{className:"min-w-0",children:[w,P,O,S]}),e[48]=w,e[49]=P,e[50]=O,e[51]=S,e[52]=T):T=e[52];let A;return e[53]!==k||e[54]!==T||e[55]!==I||e[56]!==C?(A=(0,R.jsxs)("div",{className:I,"data-testid":C,children:[k,T]}),e[53]=k,e[54]=T,e[55]=I,e[56]=C,e[57]=A):A=e[57],A},"ke");function lt(t){return t.name}u(lt,"ue");function dt(t,e){return t.localeCompare(e)}u(dt,"me");var We=L(te(),1);var B=L(te(),1);var z=L(me(),1);var d=L(re(),1);var ct=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","we"),Me=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"Q"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","z"),pt=u(t=>{let e=Me(t);return e!==void 0?t.type??ct(e[0]):ce(t)},"ke"),mt=u(t=>{let e=Me(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"Oe"),ut=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"$e"),ft=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Te"),Z=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Z(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Z(r);return e}case"string":return"";default:return null}},"D"),de=u(t=>{let e=(0,B.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,d.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,d.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"K"),ht=u(t=>{let e=(0,B.c)(40),{name:a,required:r,schema:n}=t,s=M(),o;e[0]!==n?(o=ut(n),e[0]=n,e[1]=o):o=e[1];let i=o,c;e[2]!==n?(c=mt(n),e[2]=n,e[3]=c):c=e[3];let m=c,l=n["x-lunora-table"],p=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=ft(n),e[4]=n,e[5]=f):f=e[5];let h=f,g=r?"*":"?",x;e[6]!==g?(x=(0,d.jsx)("span",{className:"text-muted-foreground",children:g}),e[6]=g,e[7]=x):x=e[7];let v;e[8]!==a||e[9]!==x?(v=(0,d.jsxs)("span",{className:"font-mono text-foreground",children:[a,x]}),e[8]=a,e[9]=x,e[10]=v):v=e[10];let N;e[11]!==n?(N=pt(n),e[11]=n,e[12]=N):N=e[12];let y;e[13]!==N?(y=(0,d.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=y):y=e[14];let b;e[15]!==v||e[16]!==y?(b=(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[v,y]}),e[15]=v,e[16]=y,e[17]=b):b=e[17];let I;e[18]!==n.description?(I=n.description!==void 0&&(0,d.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=I):I=e[19];let C;e[20]!==p||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(C=p&&(0,d.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,d.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,d.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,d.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,d.jsx)(de,{label:s("relation"),value:l})]}),e[20]=p,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=C):C=e[26];let $;e[27]!==I||e[28]!==C||e[29]!==b?($=(0,d.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[b,I,C]}),e[27]=I,e[28]=C,e[29]=b,e[30]=$):$=e[30];let k=$;if(h===void 0){let S;return e[31]!==k?(S=(0,d.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:k}),e[31]=k,e[32]=S):S=e[32],S}let w;e[33]!==k?(w=(0,d.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k}),e[33]=k,e[34]=w):w=e[34];let P;e[35]!==h?(P=(0,d.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,d.jsx)(qe,{schema:h})}),e[35]=h,e[36]=P):P=e[36];let O;return e[37]!==w||e[38]!==P?(O=(0,d.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,P]}),e[37]=w,e[38]=P,e[39]=O):O=e[39],O},"Ce"),qe=u(t=>{let e=(0,B.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,d.jsx)("div",{className:"flex flex-col",children:o.map(c=>{let[m,l]=c;return(0,d.jsx)(ht,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"Z"),_e=u(t=>{let e=(0,B.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,d.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,d.jsx)(qe,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,d.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"V"),gt=["curl","javascript","lunora"],xt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},bt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"Ae"),yt=u(t=>{let e=Z(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"je"),vt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(yt(e),void 0,2),s=JSON.stringify(Z(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";