@lunora/studio 1.0.0-alpha.392 → 1.0.0-alpha.393
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/architecture-panel.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_shared/diagram-export-panel-CleSOm6J.mjs +2 -0
- package/dist/packem_shared/{schema-diagram-Dbs7-jSJ.mjs → schema-diagram-BpIBRUm6.mjs} +1 -1
- package/dist/standalone/{chunk-7UPL6MQR.js → chunk-26RNXTU3.js} +1 -1
- package/dist/standalone/{chunk-KULAZ4W3.js → chunk-2Q4WVEPB.js} +1 -1
- package/dist/standalone/{chunk-7WGZSDRS.js → chunk-2ZNMZPPZ.js} +1 -1
- package/dist/standalone/{chunk-AZ6QNL6G.js → chunk-3BDGZAZD.js} +1 -1
- package/dist/standalone/{chunk-XHDCFSC6.js → chunk-3GBBYV7C.js} +1 -1
- package/dist/standalone/{chunk-PUTERXSU.js → chunk-4OWWWAMB.js} +1 -1
- package/dist/standalone/{chunk-MVWMRJD5.js → chunk-4WFEKKAZ.js} +1 -1
- package/dist/standalone/{chunk-AJFMXVR4.js → chunk-4Z2GLDF7.js} +1 -1
- package/dist/standalone/{chunk-5FFKYQHT.js → chunk-5BTQ4VV2.js} +1 -1
- package/dist/standalone/{chunk-ACCTEC6Y.js → chunk-5FHGTA7V.js} +1 -1
- package/dist/standalone/chunk-5J2UX2CO.js +1 -0
- package/dist/standalone/{chunk-ZIY53FID.js → chunk-5XQM44J7.js} +1 -1
- package/dist/standalone/{chunk-JPL3WAVW.js → chunk-5YEMXXQZ.js} +1 -1
- package/dist/standalone/chunk-6KIDLGYM.js +1 -0
- package/dist/standalone/{chunk-XKK5ABPC.js → chunk-7URG6FZD.js} +1 -1
- package/dist/standalone/{chunk-2XAJCKRP.js → chunk-7XZENNML.js} +1 -1
- package/dist/standalone/{chunk-BFEX6HDU.js → chunk-A33FOU2H.js} +1 -1
- package/dist/standalone/{chunk-S64V5MAT.js → chunk-A7L3PZEL.js} +1 -1
- package/dist/standalone/{chunk-22C2K5PS.js → chunk-ADOZBBJC.js} +1 -1
- package/dist/standalone/{chunk-COMBKDVY.js → chunk-AFUJCRWR.js} +1 -1
- package/dist/standalone/{chunk-EFEAOMEB.js → chunk-AWMHWVF7.js} +1 -1
- package/dist/standalone/chunk-B5YCFPYG.js +1 -0
- package/dist/standalone/{chunk-6YDEXJRE.js → chunk-BADHCM45.js} +1 -1
- package/dist/standalone/{chunk-PRVBT5AJ.js → chunk-BCT3KY76.js} +1 -1
- package/dist/standalone/{chunk-6WTQL4W2.js → chunk-BFV46XUH.js} +1 -1
- package/dist/standalone/chunk-BMGMBZAW.js +1 -0
- package/dist/standalone/{chunk-BKKE4QKE.js → chunk-BTHVLHPT.js} +1 -1
- package/dist/standalone/{chunk-RTD3B67U.js → chunk-BUYKTV27.js} +1 -1
- package/dist/standalone/{chunk-W7CLOQOU.js → chunk-BZP4FOID.js} +1 -1
- package/dist/standalone/{chunk-EXHVWM27.js → chunk-C4PC3TVC.js} +1 -1
- package/dist/standalone/chunk-C57KLL4U.js +1 -0
- package/dist/standalone/{chunk-MPGM6L64.js → chunk-CBFVQCWS.js} +1 -1
- package/dist/standalone/{chunk-B34JDEEO.js → chunk-D4CP2AUO.js} +1 -1
- package/dist/standalone/chunk-DMQVY5L7.js +1 -0
- package/dist/standalone/{chunk-XYWMQVZ2.js → chunk-DRSX6KR3.js} +1 -1
- package/dist/standalone/{chunk-RUCMNPTD.js → chunk-DUICFFES.js} +1 -1
- package/dist/standalone/{chunk-E3IVOZVW.js → chunk-E32WBVTB.js} +1 -1
- package/dist/standalone/{chunk-QIROOZNJ.js → chunk-EBGXOUAO.js} +1 -1
- package/dist/standalone/{chunk-QHI77TGI.js → chunk-ECXQQPVU.js} +1 -1
- package/dist/standalone/{chunk-725JLR43.js → chunk-EEDAK4NS.js} +1 -1
- package/dist/standalone/{chunk-6HZDJA4T.js → chunk-EH53XOVI.js} +1 -1
- package/dist/standalone/chunk-EOHXBC4U.js +1 -0
- package/dist/standalone/chunk-EOTHFTZG.js +1 -0
- package/dist/standalone/{chunk-QHVUXMRV.js → chunk-EUNTXABP.js} +1 -1
- package/dist/standalone/{chunk-TFH347JK.js → chunk-EYFAYJYD.js} +1 -1
- package/dist/standalone/{chunk-N7FOBAV3.js → chunk-F4NZZ3LK.js} +1 -1
- package/dist/standalone/chunk-FRKRT73U.js +1 -0
- package/dist/standalone/chunk-FSY7UKMG.js +1 -0
- package/dist/standalone/chunk-G4H5DPO6.js +33 -0
- package/dist/standalone/chunk-GATWEWRW.js +1 -0
- package/dist/standalone/{chunk-INDH6PRB.js → chunk-HCLUIJMW.js} +1 -1
- package/dist/standalone/{chunk-H2HGJURT.js → chunk-HE2XT2P7.js} +1 -1
- package/dist/standalone/{chunk-IFU5WQHZ.js → chunk-HLN47VMG.js} +1 -1
- package/dist/standalone/{chunk-3RCYH6UA.js → chunk-HPCOC223.js} +1 -1
- package/dist/standalone/chunk-HPQLTLIE.js +1 -0
- package/dist/standalone/chunk-HQJXQWJM.js +1 -0
- package/dist/standalone/{chunk-2CMHGYZ4.js → chunk-IC2PEYF7.js} +1 -1
- package/dist/standalone/chunk-J2SIGUHW.js +8 -0
- package/dist/standalone/chunk-JCJCUWVN.js +1 -0
- package/dist/standalone/chunk-JEJV6SVN.js +1 -0
- package/dist/standalone/chunk-JSVT5VBU.js +1 -0
- package/dist/standalone/chunk-JXW6H6LE.js +1 -0
- package/dist/standalone/{chunk-TJ76NZTD.js → chunk-K3HWPNON.js} +1 -1
- package/dist/standalone/{chunk-EYBS3Q7O.js → chunk-KEHWNM7Q.js} +1 -1
- package/dist/standalone/chunk-KJHVB5KM.js +1 -0
- package/dist/standalone/{chunk-NRWR25MB.js → chunk-KQ6YQP3Z.js} +1 -1
- package/dist/standalone/{chunk-NP6H72XD.js → chunk-LUHBGCMO.js} +1 -1
- package/dist/standalone/{chunk-UEONVTOV.js → chunk-M6WDFEUZ.js} +1 -1
- package/dist/standalone/{chunk-JKTAHFTK.js → chunk-MEYZIZGX.js} +1 -1
- package/dist/standalone/{chunk-RN32N6ZO.js → chunk-MLX6ME3Q.js} +1 -1
- package/dist/standalone/{chunk-QMZKJK53.js → chunk-N3MKRANL.js} +1 -1
- package/dist/standalone/{chunk-H6VTIXVB.js → chunk-N7TSSCGF.js} +1 -1
- package/dist/standalone/{chunk-RIHWRGFS.js → chunk-NFIFRB3W.js} +2 -2
- package/dist/standalone/{chunk-EZ5PVGPY.js → chunk-OEPNNICC.js} +1 -1
- package/dist/standalone/chunk-PLCYDHU3.js +7 -0
- package/dist/standalone/{chunk-7ELEYWJC.js → chunk-PT4GNZU7.js} +1 -1
- package/dist/standalone/chunk-PVQDT47U.js +1 -0
- package/dist/standalone/{chunk-7Z243YUE.js → chunk-PWHUPKZB.js} +1 -1
- package/dist/standalone/{chunk-YYJGL32M.js → chunk-QJ3M3IQW.js} +1 -1
- package/dist/standalone/{chunk-5D73GSOC.js → chunk-QRXJTY2S.js} +1 -1
- package/dist/standalone/chunk-R76ATTPC.js +1 -0
- package/dist/standalone/{chunk-DW5KLXPI.js → chunk-RIRXDYLA.js} +1 -1
- package/dist/standalone/{chunk-TJV64AXT.js → chunk-RRIRWVQY.js} +1 -1
- package/dist/standalone/{chunk-34USSEJN.js → chunk-S3HFNWDK.js} +1 -1
- package/dist/standalone/{chunk-PLDE5R5Y.js → chunk-S3WL3QZ2.js} +1 -1
- package/dist/standalone/{chunk-LMCBMC2V.js → chunk-SOESES7K.js} +1 -1
- package/dist/standalone/chunk-SQO3WGXH.js +3 -0
- package/dist/standalone/chunk-T6YZEXZO.js +1 -0
- package/dist/standalone/{chunk-HYAGF6A5.js → chunk-TAZRDWQE.js} +1 -1
- package/dist/standalone/{chunk-LEF32Q5K.js → chunk-TDF4VVIF.js} +1 -1
- package/dist/standalone/{chunk-TVJFKXX4.js → chunk-TIFTYP3Z.js} +1 -1
- package/dist/standalone/{chunk-TVDBLCXQ.js → chunk-TNQHMR76.js} +1 -1
- package/dist/standalone/{chunk-ANHHDGNL.js → chunk-U4ZQVQZA.js} +1 -1
- package/dist/standalone/{chunk-OOPMRFI2.js → chunk-UB6S6VYI.js} +1 -1
- package/dist/standalone/chunk-UG6ZNYWH.js +167 -0
- package/dist/standalone/{chunk-MA2KXG2L.js → chunk-UHFZV34O.js} +1 -1
- package/dist/standalone/{chunk-O46IV64X.js → chunk-V5ZKAZR6.js} +1 -1
- package/dist/standalone/chunk-VEG327ST.js +63 -0
- package/dist/standalone/{chunk-UDKKUJHY.js → chunk-VLQU4G6O.js} +1 -1
- package/dist/standalone/{chunk-4YZAJTU5.js → chunk-VND72OIC.js} +1 -1
- package/dist/standalone/{chunk-NPHGFVNE.js → chunk-VUMS4VIV.js} +1 -1
- package/dist/standalone/{chunk-N4P6WYRV.js → chunk-VUWHTKLJ.js} +1 -1
- package/dist/standalone/{chunk-ZHDO7DYM.js → chunk-WARWYT4K.js} +1 -1
- package/dist/standalone/{chunk-KMBE7RTC.js → chunk-WVAWKCNQ.js} +1 -1
- package/dist/standalone/{chunk-ZPQBVYNN.js → chunk-WY23EROJ.js} +1 -1
- package/dist/standalone/{chunk-D7UOJY4N.js → chunk-XWLURY4U.js} +1 -1
- package/dist/standalone/{chunk-3HVF5LKQ.js → chunk-Y4KOJPOW.js} +1 -1
- package/dist/standalone/chunk-YC3TUO5H.js +1 -0
- package/dist/standalone/{chunk-HWG2R642.js → chunk-YQEIOEEC.js} +1 -1
- package/dist/standalone/{chunk-O56AZXG6.js → chunk-YQI2YAD7.js} +1 -1
- package/dist/standalone/{chunk-FNBNPTCM.js → chunk-YREHZBTG.js} +1 -1
- package/dist/standalone/chunk-YWGOETFP.js +1 -0
- package/dist/standalone/{chunk-K2I3AGZR.js → chunk-ZARTCW6W.js} +1 -1
- package/dist/standalone/chunk-ZBMHFOK2.js +1 -0
- package/dist/standalone/{chunk-PYG3TDLZ.js → chunk-ZG6VEBVA.js} +1 -1
- package/dist/standalone/{chunk-EMNOVYZC.js → chunk-ZSXJJYWN.js} +1 -1
- package/dist/standalone/chunk-ZUFBUWT4.js +1 -0
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +2 -2
- package/package.json +11 -11
- package/dist/packem_shared/diagram-export-panel-miFPsocM.mjs +0 -2
- package/dist/standalone/chunk-3YBXNEUY.js +0 -1
- package/dist/standalone/chunk-4SY2N2RS.js +0 -1
- package/dist/standalone/chunk-6IDVWVML.js +0 -1
- package/dist/standalone/chunk-7ML357XR.js +0 -1
- package/dist/standalone/chunk-ATYVKUH7.js +0 -1
- package/dist/standalone/chunk-CDIV23I2.js +0 -33
- package/dist/standalone/chunk-D63EYK5I.js +0 -8
- package/dist/standalone/chunk-DYPC464U.js +0 -1
- package/dist/standalone/chunk-FT5WEK3S.js +0 -59
- package/dist/standalone/chunk-GVPVWT3Q.js +0 -1
- package/dist/standalone/chunk-I37WFNA6.js +0 -1
- package/dist/standalone/chunk-IQ5CIBXJ.js +0 -1
- package/dist/standalone/chunk-KBPMT33Z.js +0 -1
- package/dist/standalone/chunk-L27FKJTG.js +0 -1
- package/dist/standalone/chunk-LFWS6VBU.js +0 -1
- package/dist/standalone/chunk-MHZNDDGI.js +0 -1
- package/dist/standalone/chunk-O5QATFN3.js +0 -159
- package/dist/standalone/chunk-OZID3UYF.js +0 -1
- package/dist/standalone/chunk-PDBW6GTJ.js +0 -1
- package/dist/standalone/chunk-QF743FSL.js +0 -1
- package/dist/standalone/chunk-R3RIZDUS.js +0 -1
- package/dist/standalone/chunk-RZJAZ5ED.js +0 -1
- package/dist/standalone/chunk-SCTYLLJT.js +0 -1
- package/dist/standalone/chunk-UNUSBFIC.js +0 -1
- package/dist/standalone/chunk-UW34S35F.js +0 -1
- package/dist/standalone/chunk-Y6OVSHPH.js +0 -1
- package/dist/standalone/chunk-YESGXFAR.js +0 -7
- package/dist/standalone/chunk-YNCZVYCO.js +0 -1
- package/dist/standalone/chunk-Z6PYAG36.js +0 -3
- package/dist/standalone/chunk-Z7ZRXPPE.js +0 -1
- /package/dist/standalone/{chunk-OWRWDDJT.js → chunk-HXFXD5EP.js} +0 -0
- /package/dist/standalone/{chunk-UQ3WOVL2.js → chunk-HXWW3XML.js} +0 -0
- /package/dist/standalone/{chunk-T7UKRA6J.js → chunk-QBBNGQJA.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as qe}from"./chunk-XWLURY4U.js";import{a as Je}from"./chunk-S3WL3QZ2.js";import{a as Ge}from"./chunk-HCLUIJMW.js";import{a as Ze}from"./chunk-PVQDT47U.js";import"./chunk-OEPNNICC.js";import{a as He}from"./chunk-3GBBYV7C.js";import{a as W}from"./chunk-KEHWNM7Q.js";import"./chunk-6KIDLGYM.js";import{a as Xe}from"./chunk-DRHZZ7IN.js";import{a as We}from"./chunk-BUYKTV27.js";import"./chunk-EUNTXABP.js";import"./chunk-2NUCBQFU.js";import{j as q}from"./chunk-SQO3WGXH.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import{a as K}from"./chunk-ECXQQPVU.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as Me}from"./chunk-V5ZKAZR6.js";import{b as X}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as Pe,b as Re,c as Be,d as Q,e as _,f as U}from"./chunk-WVAWKCNQ.js";import{b as je}from"./chunk-LUHBGCMO.js";import{a as ie,e as ne}from"./chunk-VUMS4VIV.js";import{n as le}from"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as J,j as Ee,r as ee,s as te,u as Qe,w as ae}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as it}from"./chunk-A6TVTNKO.js";import{a as lt,b as nt}from"./chunk-ADABTCDI.js";import{a as r,d as Te}from"./chunk-5PEAXTYQ.js";var w=Te(lt(),1);var Z=Te(it(),1);var t=Te(nt(),1);var st=r(()=>{let h=(0,Z.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"lt"),rt=r((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","it"),et=500,dt=r((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),ot=r(h=>{let e=(0,Z.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:d}=h,a=J(),[u,i]=(0,w.useState)(null),s;e[0]!==n||e[1]!==d?(s=dt(d,n),e[0]=n,e[1]=d,e[2]=s):s=e[2];let c=s,f;e[3]!==c?(f=r(()=>{let L="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||L===void 0||te(L.writeText(c).then(()=>(i(c),!0)))},"p"),e[3]=c,e[4]=f):f=e[4];let N=f,b;e[5]!==a?(b=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=b):b=e[6];let F;e[7]!==b?(F=(0,t.jsx)("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];let C=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let m;e[11]!==l?(m=r(L=>{l(L.target.value)},"u"),e[11]=l,e[12]=m):m=e[12];let p;e[13]!==d||e[14]!==C||e[15]!==v||e[16]!==m?(p=(0,t.jsx)(q,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:m,value:d}),e[13]=d,e[14]=C,e[15]=v,e[16]=m,e[17]=p):p=e[17];let x=c??"",y;e[18]!==x?(y=(0,t.jsx)(q,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==u||e[21]!==c||e[22]!==a?(k=a(u!==null&&u===c?"Copied":"Copy"),e[20]=u,e[21]=c,e[22]=a,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=(0,t.jsx)(K,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=(0,t.jsxs)("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==p?(S=(0,t.jsx)(ie,{children:(0,t.jsxs)(ne,{className:"flex flex-col gap-2 p-4",children:[F,p,o]})}),e[30]=o,e[31]=F,e[32]=p,e[33]=S):S=e[33],S},"rt"),ct=r(()=>{let h=le(),e=J(),[n,l]=(0,w.useState)(""),[d,a]=(0,w.useState)(null),[u,i]=(0,w.useState)(null),[s,c]=(0,w.useState)(()=>`${Qe(h.url)}/sign-up`),f=je(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),N=f.data?.rows??null,b=f.data?.total??0,F=r(()=>{let v=n.trim();v!==""&&(a(null),te((async()=>{try{let m=await h.createAuthSignUpInvitation({email:v}),p=typeof m.token=="string"?m.token:void 0;i(p===void 0?null:{email:v,token:p}),l(""),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})()))},"F"),C=r(v=>{a(null),te((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})())},"C");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(q,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:r(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(K,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),u!==null&&(0,t.jsx)(ot,{issued:u,onSignUpPageChange:c,signUpPage:s},u.token),(d??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:d??f.error}),N!==null&&N.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),N!==null&&N.length>0&&(0,t.jsx)(ie,{children:(0,t.jsx)(ne,{className:"p-0",children:(0,t.jsxs)(Pe,{children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:e("Email")}),(0,t.jsx)(_,{children:e("Status")}),(0,t.jsx)(_,{children:e("Expires")}),(0,t.jsx)(_,{children:e("Invited by")}),(0,t.jsx)(_,{})]})}),(0,t.jsx)(Be,{children:N.map(v=>{let m=rt(v,Date.now()),p=v.email??"";return(0,t.jsxs)(Q,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(U,{children:p}),(0,t.jsxs)(U,{"data-testid":`sign-up-invitation-status-${p}`,children:[m==="spent"&&e("Accepted"),m==="expired"&&e("Expired"),m==="pending"&&e("Pending")]}),(0,t.jsx)(U,{children:typeof v.expiresAt=="number"?ae(v.expiresAt):"\u2014"}),(0,t.jsx)(U,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(U,{className:"text-right",children:(0,t.jsx)(K,{onClick:r(()=>{C(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"ot"),ut={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},mt=r((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"ct"),ht=r((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ut"),pt=r(h=>{let e=(0,Z.c)(105),{onClose:n,onCreated:l}=h,d=le(),a=J(),{config:u}=qe(),{busy:i,error:s,run:c}=Je(),[f,N]=(0,w.useState)(""),[b,F]=(0,w.useState)(""),[C,v]=(0,w.useState)(""),[m,p]=(0,w.useState)(""),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let[y,k]=(0,w.useState)(x),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=r(A=>{N(A.target.value)},"g"),e[1]=g):g=e[1];let o=g,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r(A=>{F(A.target.value)},"S"),e[2]=S):S=e[2];let L=S,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=r(A=>{v(A.target.value)},"z"),e[3]=E):E=e[3];let H=E,j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r(A=>{p(A.target.value)},"M"),e[4]=j):j=e[4];let Y=j,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=r((A,M)=>{k(se=>({...se,[A]:M}))},"D"),e[5]=B):B=e[5];let O=B,T;e[6]!==y?(T=r(A=>y[A.name]??(A.type==="boolean"?!1:""),"O"),e[6]=y,e[7]=T):T=e[7];let z=T,$;if(e[8]!==u.userFields||e[9]!==z){let A;e[11]!==z?(A=r(M=>!M.required||mt(M,z(M)),"A"),e[11]=z,e[12]=A):A=e[12],$=u.userFields.every(A),e[8]=u.userFields,e[9]=z,e[10]=$}else $=e[10];let I=$,P;e[13]!==i||e[14]!==f||e[15]!==b||e[16]!==I?(P=!i&&f.trim()!==""&&b.trim()!==""&&I,e[13]=i,e[14]=f,e[15]=b,e[16]=I,e[17]=P):P=e[17];let V=P,G;e[18]!==u.userFields||e[19]!==z?(G=r(()=>{let A={};for(let M of u.userFields){let se=ht(M,z(M));se!==void 0&&(A[M.name]=se.value)}return Object.keys(A).length===0?void 0:A},"Q"),e[18]=u.userFields,e[19]=z,e[20]=G):G=e[20];let R=G,D;e[21]!==R||e[22]!==d||e[23]!==f||e[24]!==b||e[25]!==n||e[26]!==l||e[27]!==C||e[28]!==m||e[29]!==c?(D=r(()=>{c(async()=>{await d.createAuthUser({data:R(),email:f.trim(),name:b.trim(),password:C===""?void 0:C,role:m.trim()===""?void 0:m.trim()}),l(),n()})},"L"),e[21]=R,e[22]=d,e[23]=f,e[24]=b,e[25]=n,e[26]=l,e[27]=C,e[28]=m,e[29]=c,e[30]=D):D=e[30];let Oe=D,re;e[31]!==a?(re=a("Create user"),e[31]=a,e[32]=re):re=e[32];let de;e[33]!==a?(de=a("Create user"),e[33]=a,e[34]=de):de=e[34];let oe;e[35]!==de?(oe=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:de}),e[35]=de,e[36]=oe):oe=e[36];let ce;e[37]!==a?(ce=a("email"),e[37]=a,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=(0,t.jsx)(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==f?(me=(0,t.jsx)(q,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:f}),e[41]=f,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let pe;e[46]!==a?(pe=a("name"),e[46]=a,e[47]=pe):pe=e[47];let fe;e[48]!==pe?(fe=(0,t.jsx)(W,{htmlFor:"uc-name",children:pe}),e[48]=pe,e[49]=fe):fe=e[49];let ve;e[50]!==b?(ve=(0,t.jsx)(q,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==fe||e[53]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[52]=fe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==a?(ye=a("Password (optional)"),e[55]=a,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=(0,t.jsx)(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=(0,t.jsx)(q,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==a?(ke=a("Role (optional)"),e[64]=a,e[65]=ke):ke=e[65];let we;e[66]!==ke?(we=(0,t.jsx)(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=we):we=e[67];let Ce;e[68]!==m?(Ce=(0,t.jsx)(q,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:m}),e[68]=m,e[69]=Ce):Ce=e[69];let Ie;e[70]!==we||e[71]!==Ce?(Ie=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[we,Ce]}),e[70]=we,e[71]=Ce,e[72]=Ie):Ie=e[72];let Ae;e[73]!==u.userFields||e[74]!==z||e[75]!==a?(Ae=u.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),u.userFields.map(A=>{let M=`uc-field-${A.name}`,se=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Le=z(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:M,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":M,id:M,onCheckedChange:r(at=>{O(A.name,at)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,se]})]},A.name)}let Ve=z(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(W,{htmlFor:M,children:[A.name,se]}),(0,t.jsx)(q,{"data-testid":M,id:M,onChange:r(Le=>{O(A.name,Le.target.value)},"onChange"),type:ut[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=u.userFields,e[74]=z,e[75]=a,e[76]=Ae):Ae=e[76];let Se;e[77]!==s?(Se=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:s}),e[77]=s,e[78]=Se):Se=e[78];let Fe;e[79]!==a?(Fe=a("Cancel"),e[79]=a,e[80]=Fe):Fe=e[80];let Ue;e[81]!==n||e[82]!==Fe?(Ue=(0,t.jsx)(K,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=n,e[82]=Fe,e[83]=Ue):Ue=e[83];let De=!V,ze;e[84]!==i||e[85]!==a?(ze=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ze):ze=e[86];let Ke;e[87]!==Oe||e[88]!==De||e[89]!==ze?(Ke=(0,t.jsx)(K,{"data-testid":"uc-submit",disabled:De,onClick:Oe,size:"sm",type:"button",children:ze}),e[87]=Oe,e[88]=De,e[89]=ze,e[90]=Ke):Ke=e[90];let _e;e[91]!==Ue||e[92]!==Ke?(_e=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Ke]}),e[91]=Ue,e[92]=Ke,e[93]=_e):_e=e[93];let $e;return e[94]!==n||e[95]!==re||e[96]!==oe||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ie||e[101]!==Ae||e[102]!==Se||e[103]!==_e?($e=(0,t.jsxs)(He,{label:re,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[oe,he,ge,Ne,Ie,Ae,Se,_e]}),e[94]=n,e[95]=re,e[96]=oe,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ie,e[101]=Ae,e[102]=Se,e[103]=_e,e[104]=$e):$e=e[104],$e},"mt"),Ye=r(h=>{let e=(0,Z.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"Me"),tt=r(h=>{let e=(0,Z.c)(15),{children:n,columns:l,testId:d}=h,a=J(),u;e[0]!==l?(u=l.map(yt),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==a?(i=a("Actions"),e[2]=a,e[3]=i):i=e[3];let s;e[4]!==i?(s=(0,t.jsx)(_,{"aria-label":i}),e[4]=i,e[5]=s):s=e[5];let c;e[6]!==u||e[7]!==s?(c=(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[u,s]})}),e[6]=u,e[7]=s,e[8]=c):c=e[8];let f;e[9]!==n?(f=(0,t.jsx)(Be,{children:n}),e[9]=n,e[10]=f):f=e[10];let N;return e[11]!==c||e[12]!==f||e[13]!==d?(N=(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":d,children:[c,f]})})}),e[11]=c,e[12]=f,e[13]=d,e[14]=N):N=e[14],N},"qe"),ft=r(h=>{let e=(0,Z.c)(29),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{let o=await u.listAuthSessions({limit:50,userId:d});c(o.rows)}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l?(C=r(o=>{l(()=>u.revokeAuthSession({sessionId:o}))},"C"),e[7]=u,e[8]=l,e[9]=C):C=e[9];let v=C,m;e[10]!==i?(m=i("Sessions"),e[10]=i,e[11]=m):m=e[11];let p;e[12]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[12]=m,e[13]=p):p=e[13];let x;e[14]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=x):x=e[15];let y;e[16]!==s||e[17]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=s,e[17]=i,e[18]=y):y=e[18];let k;e[19]!==n||e[20]!==v||e[21]!==s||e[22]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("expires")}),(0,t.jsx)(_,{children:i("ip")}),(0,t.jsx)(_,{children:i("user agent")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>(0,t.jsxs)(Q,{"data-testid":`ud-session-${o.id}`,children:[(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.expiresAt)}),(0,t.jsx)(U,{children:o.ipAddress??""}),(0,t.jsx)(U,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-${o.id}`,disabled:n,onClick:r(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},o.id))})]})})}),e[19]=n,e[20]=v,e[21]=s,e[22]=i,e[23]=k):k=e[23];let g;return e[24]!==p||e[25]!==x||e[26]!==y||e[27]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,y,k]}),e[24]=p,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},"ht"),vt=r(h=>{let e=(0,Z.c)(30),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{c(await u.listAuthAccounts({userId:d}))}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l||e[9]!==d?(C=r(o=>{l(()=>u.unlinkAuthAccount({accountId:o,userId:d}))},"C"),e[7]=u,e[8]=l,e[9]=d,e[10]=C):C=e[10];let v=C,m;e[11]!==i?(m=i("Linked accounts"),e[11]=i,e[12]=m):m=e[12];let p;e[13]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[13]=m,e[14]=p):p=e[14];let x;e[15]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=x):x=e[16];let y;e[17]!==s||e[18]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=s,e[18]=i,e[19]=y):y=e[19];let k;e[20]!==s||e[21]!==n||e[22]!==v||e[23]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("provider")}),(0,t.jsx)(_,{children:i("created")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>{let S=ee(o.id);return(0,t.jsxs)(Q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(U,{children:ee(o.providerId)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:r(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=s,e[21]=n,e[22]=v,e[23]=i,e[24]=k):k=e[24];let g;return e[25]!==p||e[26]!==x||e[27]!==y||e[28]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,y,k]}),e[25]=p,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},"ft"),gt=r(h=>{let e=(0,Z.c)(71),{busy:n,capabilities:l,runAction:d,userId:a,version:u}=h,i=le(),s=J(),[c,f]=(0,w.useState)(null),[N,b]=(0,w.useState)(null),[F,C]=(0,w.useState)(null),[v,m]=(0,w.useState)(0),p;e[0]!==l.apiKey||e[1]!==i||e[2]!==a?(p=r(()=>{if(!l.apiKey)return;let R={live:!0};return te((async()=>{try{let D=await i.listAuthApiKeys({userId:a});R.live&&(b({rows:D,userId:a}),C(null))}catch{R.live&&C(a)}})()),()=>{R.live=!1}},"f"),e[0]=l.apiKey,e[1]=i,e[2]=a,e[3]=p):p=e[3];let x;e[4]!==v||e[5]!==l.apiKey||e[6]!==i||e[7]!==a||e[8]!==u?(x=[v,l.apiKey,i,a,u],e[4]=v,e[5]=l.apiKey,e[6]=i,e[7]=a,e[8]=u,e[9]=x):x=e[9],(0,w.useEffect)(p,x);let y=N?.userId===a?N.rows:null,k=F===a,g;e[10]!==l.passkey||e[11]!==i||e[12]!==a?(g=r(()=>{l.passkey&&te((async()=>{try{f(await i.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"g"),e[10]=l.passkey,e[11]=i,e[12]=a,e[13]=g):g=e[13];let o;e[14]!==l.passkey||e[15]!==i||e[16]!==a||e[17]!==u?(o=[l.passkey,i,a,u],e[14]=l.passkey,e[15]=i,e[16]=a,e[17]=u,e[18]=o):o=e[18],(0,w.useEffect)(g,o);let S;e[19]!==i||e[20]!==d||e[21]!==a?(S=r(()=>{d(()=>i.disableAuthTwoFactor({userId:a}))},"S"),e[19]=i,e[20]=d,e[21]=a,e[22]=S):S=e[22];let L=S,E;e[23]!==i||e[24]!==d?(E=r(R=>{d(()=>i.deleteAuthPasskey({passkeyId:R}))},"z"),e[23]=i,e[24]=d,e[25]=E):E=e[25];let H=E,j;e[26]!==i||e[27]!==d?(j=r(R=>{d(()=>i.deleteAuthApiKey({apiKeyId:R}))},"M"),e[26]=i,e[27]=d,e[28]=j):j=e[28];let Y=j,B;e[29]!==s?(B=s("Security"),e[29]=s,e[30]=B):B=e[30];let O;e[31]!==B?(O=(0,t.jsx)(Ye,{children:B}),e[31]=B,e[32]=O):O=e[32];let T;e[33]!==n||e[34]!==l.twoFactor||e[35]!==L||e[36]!==s?(T=l.twoFactor&&(0,t.jsx)(K,{"data-testid":"ud-disable-2fa",disabled:n,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Disable two-factor")}),e[33]=n,e[34]=l.twoFactor,e[35]=L,e[36]=s,e[37]=T):T=e[37];let z;e[38]!==l.passkey||e[39]!==c||e[40]!==s?(z=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No passkeys.")}),e[38]=l.passkey,e[39]=c,e[40]=s,e[41]=z):z=e[41];let $;e[42]!==n||e[43]!==l.passkey||e[44]!==H||e[45]!==c||e[46]!==s?($=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("created")],testId:"ud-passkeys-table",children:c.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-passkey-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-delete-passkey-${D}`,disabled:n,onClick:r(()=>{H(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Delete")})})]},D)})}),e[42]=n,e[43]=l.passkey,e[44]=H,e[45]=c,e[46]=s,e[47]=$):$=e[47];let I;e[48]!==k||e[49]!==n||e[50]!==l.apiKey||e[51]!==s?(I=l.apiKey&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("Could not load API keys.")}),(0,t.jsx)(K,{"data-testid":"ud-api-keys-retry",disabled:n,onClick:r(()=>{m(bt)},"onClick"),size:"xs",type:"button",variant:"outline",children:s("Retry")})]}),e[48]=k,e[49]=n,e[50]=l.apiKey,e[51]=s,e[52]=I):I=e[52];let P;e[53]!==l.apiKey||e[54]!==y||e[55]!==s?(P=l.apiKey&&y!==null&&y.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No API keys.")}),e[53]=l.apiKey,e[54]=y,e[55]=s,e[56]=P):P=e[56];let V;e[57]!==n||e[58]!==l.apiKey||e[59]!==y||e[60]!==Y||e[61]!==s?(V=l.apiKey&&y!==null&&y.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("Key"),s("created"),s("Expires")],testId:"ud-api-keys-table",children:y.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-api-key-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"font-mono text-muted-foreground",children:ee(R.start)||"\u2014"}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.expiresAt,s("Never"))}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-api-key-${D}`,disabled:n,onClick:r(()=>{Y(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},D)})}),e[57]=n,e[58]=l.apiKey,e[59]=y,e[60]=Y,e[61]=s,e[62]=V):V=e[62];let G;return e[63]!==T||e[64]!==z||e[65]!==$||e[66]!==I||e[67]!==P||e[68]!==V||e[69]!==O?(G=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[O,T,z,$,I,P,V]}),e[63]=T,e[64]=z,e[65]=$,e[66]=I,e[67]=P,e[68]=V,e[69]=O,e[70]=G):G=e[70],G},"pt");function yt(h){return(0,t.jsx)(_,{children:h},h)}r(yt,"vt");function bt(h){return h+1}r(bt,"gt");var xt=/(?:at|expires)$/iu,Nt=/^[1-9]\d*$/u,kt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),wt=r(h=>{let e=(0,Z.c)(51),{busy:n,onBan:l}=h,d=J(),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(""),[c,f]=(0,w.useState)(!1),N;e[0]!==i?(N=Nt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=N):N=e[1];let b=N,F=c||b!==void 0,C;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==b?(C=r(()=>{l({expiresInSeconds:c||b===void 0?void 0:b*86400,reason:a.trim()===""?void 0:a.trim()})},"C"),e[2]=l,e[3]=c,e[4]=a,e[5]=b,e[6]=C):C=e[6];let v=C,m;e[7]!==d?(m=d("Ban reason (optional)"),e[7]=d,e[8]=m):m=e[8];let p;e[9]!==m?(p=(0,t.jsx)(W,{htmlFor:"ud-ban-reason",children:m}),e[9]=m,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r(P=>{u(P.target.value)},"x"),e[11]=x):x=e[11];let y;e[12]!==a?(y=(0,t.jsx)(q,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:a}),e[12]=a,e[13]=y):y=e[13];let k;e[14]!==p||e[15]!==y?(k=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[p,y]}),e[14]=p,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==d?(g=d("Days"),e[17]=d,e[18]=g):g=e[18];let o;e[19]!==g?(o=(0,t.jsx)(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==i||e[22]!==b?(S=i.trim()!==""&&b===void 0,e[21]=i,e[22]=b,e[23]=S):S=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r(P=>{s(P.target.value)},"_"),e[24]=L):L=e[24];let E;e[25]!==i||e[26]!==c||e[27]!==S?(E=(0,t.jsx)(q,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:L,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=E):E=e[28];let H;e[29]!==E||e[30]!==o?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[o,E]}),e[29]=E,e[30]=o,e[31]=H):H=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r(P=>{f(P.target.checked)},"M"),e[32]=j):j=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:j,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==d?(B=d("Permanent"),e[35]=d,e[36]=B):B=e[36];let O;e[37]!==Y||e[38]!==B?(O=(0,t.jsxs)(W,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=O):O=e[39];let T=n||!F,z;e[40]!==d?(z=d("Ban user"),e[40]=d,e[41]=z):z=e[41];let $;e[42]!==v||e[43]!==T||e[44]!==z?($=(0,t.jsx)(K,{"data-testid":"ud-ban",disabled:T,onClick:v,size:"sm",type:"button",variant:"destructive",children:z}),e[42]=v,e[43]=T,e[44]=z,e[45]=$):$=e[45];let I;return e[46]!==H||e[47]!==O||e[48]!==$||e[49]!==k?(I=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[k,H,O,$]}),e[46]=H,e[47]=O,e[48]=$,e[49]=k,e[50]=I):I=e[50],I},"Nt"),Ct=r((h,e)=>typeof e=="number"&&xt.test(h)?ae(e):ee(e),"kt"),It=r(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let d=le(),a=J(),u=l.banned===!0,[i,s]=(0,w.useState)(null),[c,f]=(0,w.useState)(!1),[N,b]=(0,w.useState)(0),[F,C]=(0,w.useState)(typeof l.role=="string"?l.role:""),[v,m]=(0,w.useState)(""),[p,x]=(0,w.useState)(null),[y,k]=(0,w.useState)(!1),g=r((I,P)=>{te((async()=>{f(!0),s(null);try{let V=await I();P?.refresh!==!1&&(b(G=>G+1),e()),P?.onResult?.(V)}catch(V){s(Ee(V))}f(!1)})())},"g"),o=r(I=>{C(I.target.value)},"o"),S=r(I=>{m(I.target.value)},"S"),L=r(()=>{let I=F.trim();I!==""&&g(async()=>{await d.setAuthUserRole({role:I,userId:l.id})})},"_"),E=r(I=>{g(async()=>{await d.banAuthUser({...I,userId:l.id})})},"z"),H=r(()=>{g(async()=>{await d.unbanAuthUser({userId:l.id})})},"q"),j=r(()=>{g(async()=>{await d.setAuthUserPassword({newPassword:v,userId:l.id}),m("")})},"M"),Y=r(()=>{g(()=>d.impersonateAuthUser({userId:l.id}),{onResult:r(I=>{x(I.token)},"onResult"),refresh:!1})},"H"),B=r(()=>{g(async()=>{await d.revokeAuthUserSessions({userId:l.id})})},"D"),O=r(()=>{g(async()=>{await d.removeAuthUser({userId:l.id}),n()})},"B"),T=r(()=>{k(!0)},"O"),z=r(()=>{k(!1)},"U"),$=Object.entries(l).filter(([I])=>!kt.has(I));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(X,{variant:"secondary",children:l.role}),u?(0,t.jsx)(X,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(X,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(X,{variant:"secondary",children:a("verified")}):(0,t.jsx)(X,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(K,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(ie,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(ne,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(W,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(q,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),(0,t.jsx)(K,{"data-testid":"ud-set-role",disabled:c||F.trim()==="",onClick:L,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),u?(0,t.jsx)(K,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(wt,{busy:c,onBan:E}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(W,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(q,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(K,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:j,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(K,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(K,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{"data-testid":"ud-delete-confirm",disabled:c,onClick:O,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(K,{"data-testid":"ud-delete-cancel",onClick:z,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(K,{"data-testid":"ud-delete",disabled:c,onClick:T,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),p!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(W,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(q,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:p})]})]})]}),(0,t.jsx)(ft,{busy:c,runAction:g,userId:l.id,version:N}),h.accounts&&(0,t.jsx)(vt,{busy:c,runAction:g,userId:l.id,version:N}),(h.twoFactor||h.passkey||h.apiKey)&&(0,t.jsx)(gt,{busy:c,capabilities:h,runAction:g,userId:l.id,version:N}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:$.map(([I,P])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:I}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Ct(I,P)})]},I))})]})]})},"Ct"),At=50,Ht=r(({pageSize:h=At}={})=>{let e=le(),n=J(),[l,d]=(0,w.useState)(""),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(0),c=Xe(l),[f,N]=(0,w.useState)(null),[b,F]=(0,w.useState)(!1),{capabilities:C}=st(),v=c.trim(),m=a.trim(),p=je(["lunora-auth-users",v,m,h,i],()=>e.listAuthUsers({filterField:m===""?void 0:"role",filterValue:m===""?void 0:m,limit:h,offset:i,search:v===""?void 0:v}).then(o=>({...o,offset:i})),{keepPreviousData:!0}),x=p.data?.rows??null,y=p.error,k=r(()=>{p.refetch()},"k");We(()=>p.poll(),!0);let g=f===null?null:x?.find(o=>o.id===f)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(q,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:r(o=>{d(o.target.value),s(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(q,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(o=>{u(o.target.value),s(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(K,{"data-testid":"us-new",onClick:r(()=>{F(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&(0,t.jsx)(Me,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),x!==null&&x.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"us-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:n("id")}),(0,t.jsx)(_,{children:n("email")}),(0,t.jsx)(_,{children:n("name")}),(0,t.jsx)(_,{children:n("role")}),(0,t.jsx)(_,{children:n("status")}),(0,t.jsx)(_,{children:n("verified")}),(0,t.jsx)(_,{children:n("created")}),(0,t.jsx)(_,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Be,{children:x.map(o=>(0,t.jsxs)(Q,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(U,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(U,{children:o.email??""}),(0,t.jsx)(U,{children:o.name??""}),(0,t.jsx)(U,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(X,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(U,{children:o.banned===!0?(0,t.jsx)(X,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(X,{variant:"success",children:n("Active")})}),(0,t.jsx)(U,{children:o.emailVerified===!0?(0,t.jsx)(X,{variant:"success",children:n("yes")}):(0,t.jsx)(X,{variant:"outline",children:n("no")})}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`us-manage-${o.id}`,onClick:r(()=>{N(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},o.id))})]})})}),x!==null&&(0,t.jsx)(Ge,{count:x.length,offset:p.data?.offset??0,onOffsetChange:s,pageSize:h,prefix:"us",total:p.data?.total}),g!==null&&(0,t.jsx)(It,{capabilities:C,onChanged:k,onClose:r(()=>{N(null)},"onClose"),user:g}),b&&(0,t.jsx)(pt,{onClose:r(()=>{F(!1)},"onClose"),onCreated:k}),C.inviteOnly&&(0,t.jsx)(ct,{})]})},"Ht");export{Ht as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b}from"./chunk-
|
|
1
|
+
import{a as b}from"./chunk-WY23EROJ.js";import{x as v}from"./chunk-G4H5DPO6.js";import{a as x}from"./chunk-A6TVTNKO.js";import{b as g}from"./chunk-ADABTCDI.js";import{a as c,d as l}from"./chunk-5PEAXTYQ.js";var u=l(x(),1);var s=l(g(),1);var p=b("flex items-start gap-2 rounded-md border px-3 py-2 text-sm [&>svg]:mt-0.5 [&>svg]:size-4 [&>svg]:shrink-0",{defaultVariants:{variant:"default"},variants:{variant:{default:"border-border bg-muted/40 text-foreground",destructive:"border-destructive/40 bg-destructive/5 text-destructive",warning:"border-amber-500/40 bg-amber-500/5 text-amber-700 dark:text-amber-400"}}}),j=c(f=>{let t=(0,u.c)(10),{children:d,className:i,icon:m,testId:o,variant:n}=f,e;t[0]!==i||t[1]!==n?(e=v(p({variant:n}),i),t[0]=i,t[1]=n,t[2]=e):e=t[2];let r;t[3]!==d?(r=(0,s.jsx)("div",{className:"min-w-0 flex-1",children:d}),t[3]=d,t[4]=r):r=t[4];let a;return t[5]!==m||t[6]!==e||t[7]!==r||t[8]!==o?(a=(0,s.jsxs)("div",{className:e,"data-testid":o,role:"alert",children:[m,r]}),t[5]=m,t[6]=e,t[7]=r,t[8]=o,t[9]=a):a=t[9],a},"N");export{j as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as L,d as W,e as $,f as q,h as D,i as F,j as H,k as A,l as S,m as I,n as J,o as M,p as P}from"./chunk-
|
|
1
|
+
import{c as L,d as W,e as $,f as q,h as D,i as F,j as H,k as A,l as S,m as I,n as J,o as M,p as P}from"./chunk-VEG327ST.js";import{a as O}from"./chunk-WARWYT4K.js";import{a as X,b as z,c as B,d as K,e as E,f as G}from"./chunk-WVAWKCNQ.js";import{B as C,r as j}from"./chunk-G4H5DPO6.js";import{a as U}from"./chunk-A6TVTNKO.js";import{b as V}from"./chunk-ADABTCDI.js";import{a as f,d as T}from"./chunk-5PEAXTYQ.js";var N=T(U(),1);var t=T(V(),1);var _=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},Q=f(r=>{let a=r.columns.find(e=>r.rows.length>0&&r.rows.every(n=>typeof n[e]=="number"))??null;return{label:r.columns.find(e=>e!==a)??null,value:a}},"D"),Y=f(r=>{let a=(0,N.c)(3),{data:e,kind:n}=r,l;return a[0]!==e||a[1]!==n?(l=(0,t.jsx)(H,{className:"h-full w-full",config:R,children:n==="area"?(0,t.jsxs)(F,{data:e,children:[(0,t.jsx)(L,{vertical:!1}),(0,t.jsx)(q,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(S,{content:(0,t.jsx)(A,{})}),(0,t.jsx)($,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,t.jsxs)(D,{data:e,children:[(0,t.jsx)(L,{vertical:!1}),(0,t.jsx)(q,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(S,{content:(0,t.jsx)(A,{})}),(0,t.jsx)(W,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=e,a[1]=n,a[2]=l):l=a[2],l},"J"),na=f(r=>{let a=(0,N.c)(21),{axes:e,kind:n,result:l}=r,u=C(),o;a[0]!==l?(o=Q(l),a[0]=l,a[1]=o):o=a[1];let d=o,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let s=m,c=e!==void 0&&s.has(e.x)?e.x:d.label,p;a[4]!==e?.y||a[5]!==s?(p=e?.y.find(i=>s.has(i)),a[4]=e?.y,a[5]=s,a[6]=p):p=a[6];let x=p,y=x??d.value,b;a[7]!==c||a[8]!==l.rows||a[9]!==y?(b=y===null?[]:l.rows.slice(0,_).map((i,w)=>({label:c===null?`#${(w+1).toString()}`:j(i[c]),value:Number(i[y])||0})),a[7]=c,a[8]=l.rows,a[9]=y,a[10]=b):b=a[10];let k=b;if(y===null){let i;a[11]!==u?(i=u("No numeric column to chart."),a[11]=u,a[12]=i):i=a[12];let w;return a[13]!==i?(w=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:i}),a[13]=i,a[14]=w):w=a[14],w}let h=n??(e!==void 0&&x!==void 0?e.kind:"bar"),v;a[15]!==k||a[16]!==h?(v=h==="bar"?(0,t.jsxs)(I,{className:"h-full w-full",config:R,data:k,children:[(0,t.jsx)(M,{dataKey:"label"}),(0,t.jsx)(J,{dataKey:"value"}),(0,t.jsx)(P,{})]}):(0,t.jsx)(Y,{data:k,kind:h}),a[15]=k,a[16]=h,a[17]=v):v=a[17];let g;return a[18]!==h||a[19]!==v?(g=(0,t.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":h,"data-testid":"sql-chart",children:v}),a[18]=h,a[19]=v,a[20]=g):g=a[20],g},"oe"),oa=f(r=>{let a=(0,N.c)(19),{result:e}=r,n=C();if(e.columns.length===0){let s;a[0]!==e.rowCount||a[1]!==n?(s=n("{count} rows",{count:e.rowCount}),a[0]=e.rowCount,a[1]=n,a[2]=s):s=a[2];let c;return a[3]!==s?(c=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:s}),a[3]=s,a[4]=c):c=a[4],c}let l;a[5]!==e.columns?(l=e.columns.map(Z),a[5]=e.columns,a[6]=l):l=a[6];let u;a[7]!==l?(u=(0,t.jsx)(z,{className:"sticky top-0 z-10 bg-muted",children:(0,t.jsx)(K,{children:l})}),a[7]=l,a[8]=u):u=a[8];let o;if(a[9]!==e.columns||a[10]!==e.rows){let s;a[12]!==e.columns?(s=f((c,p)=>(0,t.jsx)(K,{"data-testid":"sql-row",children:e.columns.map(x=>(0,t.jsx)(G,{className:"max-w-md truncate font-mono text-xs",children:(0,t.jsx)(O,{value:c[x]})},x))},p),"s"),a[12]=e.columns,a[13]=s):s=a[13],o=e.rows.map(s),a[9]=e.columns,a[10]=e.rows,a[11]=o}else o=a[11];let d;a[14]!==o?(d=(0,t.jsx)(B,{children:o}),a[14]=o,a[15]=d):d=a[15];let m;return a[16]!==u||a[17]!==d?(m=(0,t.jsxs)(X,{"data-testid":"sql-rows",children:[u,d]}),a[16]=u,a[17]=d,a[18]=m):m=a[18],m},"ne");function Z(r){return(0,t.jsx)(E,{children:r},r)}f(Z,"P");export{na as a,oa as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-ADABTCDI.js";import{a as r,d}from"./chunk-5PEAXTYQ.js";var e=d(f(),1);function m({controlled:t,default:i,name:u,state:p="value"}){let{current:n}=e.useRef(t!==void 0),[l,s]=e.useState(()=>i),a=n&&t!==void 0?t:l,c=e.useCallback(o=>{n||s(o)},[]);return[a,c]}r(m,"useControlled");export{m as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as $}from"./chunk-
|
|
1
|
+
import{a as $}from"./chunk-BUYKTV27.js";import{a as L}from"./chunk-2KTN53PK.js";import{a as F}from"./chunk-YC3TUO5H.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-SQO3WGXH.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import"./chunk-JEJV6SVN.js";import{a as D}from"./chunk-V5ZKAZR6.js";import{b as y}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as O}from"./chunk-4OWWWAMB.js";import"./chunk-5XQM44J7.js";import{a as P,b as W,c as q,d as C,e as h,f as p}from"./chunk-WVAWKCNQ.js";import"./chunk-VND72OIC.js";import"./chunk-VLQU4G6O.js";import"./chunk-EOFWXI3T.js";import{a as T}from"./chunk-LYVYUTQY.js";import{c as M}from"./chunk-LUHBGCMO.js";import{a as _,e as B}from"./chunk-VUMS4VIV.js";import"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as E,p as A}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as H}from"./chunk-A6TVTNKO.js";import{b as U}from"./chunk-ADABTCDI.js";import{a as S,d as j}from"./chunk-5PEAXTYQ.js";var R=j(H(),1);var t=j(U(),1);var J=80,Z=S(c=>{if(c===void 0)return"";let e=JSON.stringify(c,A);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=S(c=>{let e=[];for(let i of c){let n=i.id.toString();if(i.subscriptions.length===0){e.push({admin:i.admin,connectionId:i.id,key:`c${n}`,subscription:null});continue}i.subscriptions.forEach((s,o)=>{e.push({admin:i.admin,connectionId:i.id,key:`c${n}-s${o.toString()}`,subscription:s})})}return e},"J"),K=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=S(c=>{let e=(0,R.c)(24),{initialShardKey:i}=c,n=E(),{queryShardKey:s,setShardKey:o,shardKey:m}=L(i),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==s?(b={keepPreviousData:!0,shardKey:s},e[1]=s,e[2]=b):b=e[2];let{data:r,error:a,errorSource:u,poll:G}=M(T.listSubscriptions,f,b);$(G,!0);let x;if(e[3]!==a||e[4]!==u||e[5]!==s||e[6]!==r||e[7]!==o||e[8]!==m||e[9]!==n){let k=r===void 0?[]:z(r.connections),d;e[11]!==o||e[12]!==m?(d=(0,t.jsx)(F,{onChange:o,testId:"subs-shard-input",value:m}),e[11]=o,e[12]=m,e[13]=d):d=e[13];let l;e[14]!==r||e[15]!==n?(l=r!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(y,{variant:"secondary",children:n("{count} connections",{count:r.totalConnections})}),(0,t.jsx)(y,{variant:"secondary",children:n("{count} subscriptions",{count:r.totalSubscriptions})})]}),e[14]=r,e[15]=n,e[16]=l):l=e[16];let v;e[17]!==d||e[18]!==l?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[d,l]}),e[17]=d,e[18]=l,e[19]=v):v=e[19];let g;e[20]!==a||e[21]!==u||e[22]!==s?(g=a!==null&&(0,t.jsx)(O,{error:u,shardKey:s,testId:"subs-error"}),e[20]=a,e[21]=u,e[22]=s,e[23]=g):g=e[23],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[v,g,a===null&&r!==void 0&&k.length===0&&(0,t.jsx)(D,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),a===null&&k.length>0&&(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsx)(B,{className:"px-0",children:(0,t.jsxs)(P,{"data-testid":"subs-table",children:[(0,t.jsx)(W,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(q,{children:k.map(N=>{let{subscription:I}=N,w=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",N.connectionId,N.admin&&(0,t.jsx)(y,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??K}),(0,t.jsx)(p,{children:I?.table??K}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:w||void 0,children:w||K})]},N.key)})})]})})})]}),e[3]=a,e[4]=u,e[5]=s,e[6]=r,e[7]=o,e[8]=m,e[9]=n,e[10]=x}else x=e[10];return x},"ae");export{ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as i}from"./chunk-
|
|
1
|
+
import{x as i}from"./chunk-G4H5DPO6.js";import{a as d}from"./chunk-A6TVTNKO.js";import{b as p}from"./chunk-ADABTCDI.js";import{a as l,d as m}from"./chunk-5PEAXTYQ.js";var n=m(d(),1);var c=m(p(),1);function f(r){let t=(0,n.c)(8),e,s;t[0]!==r?({className:e,...s}=r,t[0]=r,t[1]=e,t[2]=s):(e=t[1],s=t[2]);let a;t[3]!==e?(a=i("animate-pulse rounded-md bg-muted",e),t[3]=e,t[4]=a):a=t[4];let o;return t[5]!==s||t[6]!==a?(o=(0,c.jsx)("div",{"data-slot":"skeleton",className:a,...s}),t[5]=s,t[6]=a,t[7]=o):o=t[7],o}l(f,"p");export{f as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-UEONVTOV.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-NP6H72XD.js";import{a as le,e as oe}from"./chunk-NPHGFVNE.js";import{n as Ae}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(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:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(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:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(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:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
|
|
1
|
+
import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-M6WDFEUZ.js";import"./chunk-4KPATTV6.js";import{j as we}from"./chunk-SQO3WGXH.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-ECXQQPVU.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{b as _e}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as je}from"./chunk-4OWWWAMB.js";import"./chunk-5XQM44J7.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-WVAWKCNQ.js";import"./chunk-VND72OIC.js";import"./chunk-VLQU4G6O.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-LUHBGCMO.js";import{a as le,e as oe}from"./chunk-VUMS4VIV.js";import{n as Ae}from"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(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:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(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:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(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:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ce,b as Re}from"./chunk-JPL3WAVW.js";import"./chunk-FT5WEK3S.js";import"./chunk-ZHDO7DYM.js";import{a as ye}from"./chunk-MPGM6L64.js";import"./chunk-Y2YLTUMD.js";import"./chunk-R3RIZDUS.js";import{e as ke,g as we}from"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import"./chunk-4AG356VE.js";import{a as X}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as pe}from"./chunk-O46IV64X.js";import"./chunk-L27FKJTG.js";import{a as le}from"./chunk-ZIY53FID.js";import"./chunk-KMBE7RTC.js";import{a as be}from"./chunk-LYVYUTQY.js";import"./chunk-NP6H72XD.js";import{a as ae,b as fe,c as xe,e as ne}from"./chunk-NPHGFVNE.js";import{n as ve}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as te,h as he,i as ue,j as ge,r as me,s as oe}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as Ke}from"./chunk-A6TVTNKO.js";import{a as Se,b as Me}from"./chunk-ADABTCDI.js";import{a as g,d as ie}from"./chunk-5PEAXTYQ.js";var Y=ie(Ke(),1),G=ie(Se(),1);var a=ie(Me(),1);var Le=he(be.runSql),qe=g((f,e)=>{let t=(0,Y.c)(11),n=ve(),[l,d]=(0,G.useState)(void 0),[s,i]=(0,G.useState)(void 0),[h,x]=(0,G.useState)(!0),m;t[0]!==n||t[1]!==e||t[2]!==f?(m=g(async u=>{x(!0);try{let C=await n.query(Le,{sql:f},ue(e));u.cancelled||(d(C),i(void 0))}catch(C){let k=C;u.cancelled||(d(void 0),i(ge(k)))}u.cancelled||x(!1)},"h"),t[0]=n,t[1]=e,t[2]=f,t[3]=m):m=t[3];let r=m,o,v;t[4]!==r?(o=g(()=>{let u={cancelled:!1};return oe(r(u)),()=>{u.cancelled=!0}},"l"),v=[r],t[4]=r,t[5]=o,t[6]=v):(o=t[5],v=t[6]),(0,G.useEffect)(o,v);let S;return t[7]!==s||t[8]!==h||t[9]!==l?(S={error:s,loading:h,result:l},t[7]=s,t[8]=h,t[9]=l,t[10]=S):S=t[10],S},"Le"),Ee=g(f=>{f.preventDefault()},"Me"),ce=g(f=>f.kind??"chart","le"),Ne=g(f=>{let e=(0,Y.c)(80),{actions:t,children:n,draggedRef:l,first:d,last:s,onEdit:i,onMove:h,onRemove:x,onReorder:m,widget:r}=f,o=te(),v;e[0]!==h||e[1]!==r.id?(v=g(()=>{h(r.id,-1)},"g"),e[0]=h,e[1]=r.id,e[2]=v):v=e[2];let S=v,u;e[3]!==h||e[4]!==r.id?(u=g(()=>{h(r.id,1)},"f"),e[3]=h,e[4]=r.id,e[5]=u):u=e[5];let C=u,k;e[6]!==i||e[7]!==r.id?(k=g(()=>{i(r.id)},"x"),e[6]=i,e[7]=r.id,e[8]=k):k=e[8];let E=k,O;e[9]!==x||e[10]!==r.id?(O=g(()=>{x(r.id)},"O"),e[9]=x,e[10]=r.id,e[11]=O):O=e[11];let j=O,T;e[12]!==l||e[13]!==r.id?(T=g(()=>{l.current=r.id},"z"),e[12]=l,e[13]=r.id,e[14]=T):T=e[14];let w=T,K;e[15]!==l||e[16]!==m||e[17]!==r.id?(K=g(()=>{let de=l.current;l.current=null,de!==null&&de!==r.id&&m(de,r.id)},"R"),e[15]=l,e[16]=m,e[17]=r.id,e[18]=K):K=e[18];let _=K,N=`dashboards-widget-${r.id}`,y;e[19]!==r.title?(y=(0,a.jsx)(xe,{className:"min-w-0 cursor-grab truncate",title:r.title,children:r.title}),e[19]=r.title,e[20]=y):y=e[20];let R;e[21]!==o?(R=o("Move widget up"),e[21]=o,e[22]=R):R=e[22];let F=`dashboards-move-up-${r.id}`,H;e[23]!==o?(H=o("Move widget up"),e[23]=o,e[24]=H):H=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=(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:"m6 15 6-6 6 6"})}),e[25]=D):D=e[25];let W;e[26]!==d||e[27]!==S||e[28]!==F||e[29]!==H||e[30]!==R?(W=(0,a.jsx)(X,{"aria-label":R,"data-testid":F,disabled:d,onClick:S,size:"icon-xs",title:H,type:"button",variant:"ghost",children:D}),e[26]=d,e[27]=S,e[28]=F,e[29]=H,e[30]=R,e[31]=W):W=e[31];let M;e[32]!==o?(M=o("Move widget down"),e[32]=o,e[33]=M):M=e[33];let $=`dashboards-move-down-${r.id}`,L;e[34]!==o?(L=o("Move widget down"),e[34]=o,e[35]=L):L=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=(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:"m6 9 6 6 6-6"})}),e[36]=z):z=e[36];let q;e[37]!==s||e[38]!==C||e[39]!==M||e[40]!==$||e[41]!==L?(q=(0,a.jsx)(X,{"aria-label":M,"data-testid":$,disabled:s,onClick:C,size:"icon-xs",title:L,type:"button",variant:"ghost",children:z}),e[37]=s,e[38]=C,e[39]=M,e[40]=$,e[41]=L,e[42]=q):q=e[42];let B;e[43]!==o?(B=o("Edit widget"),e[43]=o,e[44]=B):B=e[44];let I=`dashboards-widget-edit-${r.id}`,A;e[45]!==o?(A=o("Edit widget"),e[45]=o,e[46]=A):A=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=(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:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let b;e[48]!==E||e[49]!==B||e[50]!==I||e[51]!==A?(b=(0,a.jsx)(X,{"aria-label":B,"data-testid":I,onClick:E,size:"icon-xs",title:A,type:"button",variant:"ghost",children:p}),e[48]=E,e[49]=B,e[50]=I,e[51]=A,e[52]=b):b=e[52];let c;e[53]!==o?(c=o("Remove widget"),e[53]=o,e[54]=c):c=e[54];let J=`dashboards-widget-remove-${r.id}`,V;e[55]!==o?(V=o("Remove widget"),e[55]=o,e[56]=V):V=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=(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 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=U):U=e[57];let Q;e[58]!==j||e[59]!==c||e[60]!==J||e[61]!==V?(Q=(0,a.jsx)(X,{"aria-label":c,"data-testid":J,onClick:j,size:"icon-xs",title:V,type:"button",variant:"ghost",children:U}),e[58]=j,e[59]=c,e[60]=J,e[61]=V,e[62]=Q):Q=e[62];let Z;e[63]!==t||e[64]!==W||e[65]!==q||e[66]!==b||e[67]!==Q?(Z=(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[t,W,q,b,Q]}),e[63]=t,e[64]=W,e[65]=q,e[66]=b,e[67]=Q,e[68]=Z):Z=e[68];let P;e[69]!==Z||e[70]!==y?(P=(0,a.jsxs)(fe,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[y,Z]}),e[69]=Z,e[70]=y,e[71]=P):P=e[71];let ee;e[72]!==n?(ee=(0,a.jsx)(ne,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let re;return e[74]!==w||e[75]!==_||e[76]!==P||e[77]!==ee||e[78]!==N?(re=(0,a.jsxs)(ae,{"data-testid":N,draggable:!0,onDragOver:Ee,onDragStart:w,onDrop:_,children:[P,ee]}),e[74]=w,e[75]=_,e[76]=P,e[77]=ee,e[78]=N,e[79]=re):re=e[79],re},"ce"),je=g(f=>{let e=(0,Y.c)(10),{result:t}=f,n=te(),l=t.columns[0],d=l===void 0?void 0:t.rows[0]?.[l],s;e[0]!==d||e[1]!==n?(s=d===void 0?n("\u2014"):me(d),e[0]=d,e[1]=n,e[2]=s):s=e[2];let i;e[3]!==s?(i=(0,a.jsx)("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:s}),e[3]=s,e[4]=i):i=e[4];let h;e[5]!==l?(h=l!==void 0&&(0,a.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=h):h=e[6];let x;return e[7]!==i||e[8]!==h?(x=(0,a.jsxs)("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[i,h]}),e[7]=i,e[8]=h,e[9]=x):x=e[9],x},"Ee"),ze=g(f=>{let e=(0,Y.c)(12),{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x}=f,m=x.text??"",r;e[0]!==m?(r=(0,a.jsx)("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:m}),e[0]=m,e[1]=r):r=e[1];let o;return e[2]!==t||e[3]!==n||e[4]!==l||e[5]!==d||e[6]!==s||e[7]!==i||e[8]!==h||e[9]!==r||e[10]!==x?(o=(0,a.jsx)(Ne,{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x,children:r}),e[2]=t,e[3]=n,e[4]=l,e[5]=d,e[6]=s,e[7]=i,e[8]=h,e[9]=r,e[10]=x,e[11]=o):o=e[11],o},"qe"),Ae=g(f=>{let e=(0,Y.c)(52),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o=te(),{error:v,loading:S,result:u}=qe(r.sql,r.shardKey??""),C;e[0]!==r?(C=ce(r),e[0]=r,e[1]=C):C=e[1];let k=C,E;e[2]!==m||e[3]!==u||e[4]!==r.id?(E=g(()=>{u!==void 0&&m?.(r.id,u)},"E"),e[2]=m,e[3]=u,e[4]=r.id,e[5]=E):E=e[5];let O=E,j;e[6]!==l||e[7]!==k||e[8]!==m||e[9]!==O||e[10]!==u||e[11]!==o||e[12]!==r.id?(j=k==="chart"&&m!==void 0&&u!==void 0?(0,a.jsx)(X,{"aria-label":o("Suggest chart"),"data-testid":`dashboards-widget-suggest-${r.id}`,disabled:l,onClick:O,size:"icon-xs",title:o(l?"Suggesting\u2026":"Suggest chart"),type:"button",variant:"ghost",children:(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:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=l,e[7]=k,e[8]=m,e[9]=O,e[10]=u,e[11]=o,e[12]=r.id,e[13]=j):j=e[13];let T=j,w;e[14]!==v||e[15]!==r.id?(w=v!==void 0&&(0,a.jsx)(le,{className:"font-mono text-xs",testId:`dashboards-widget-error-${r.id}`,variant:"destructive",children:v}),e[14]=v,e[15]=r.id,e[16]=w):w=e[16];let K;e[17]!==v||e[18]!==S||e[19]!==u||e[20]!==o||e[21]!==r.id?(K=v===void 0&&S&&u===void 0&&(0,a.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${r.id}`,children:o("Running\u2026")}),e[17]=v,e[18]=S,e[19]=u,e[20]=o,e[21]=r.id,e[22]=K):K=e[22];let _;e[23]!==v||e[24]!==k||e[25]!==u||e[26]!==r.chartAxes||e[27]!==r.chartKind?(_=v===void 0&&u!==void 0&&k==="chart"&&(0,a.jsx)(Ce,{axes:r.chartAxes,kind:r.chartKind,result:u}),e[23]=v,e[24]=k,e[25]=u,e[26]=r.chartAxes,e[27]=r.chartKind,e[28]=_):_=e[28];let N;e[29]!==v||e[30]!==k||e[31]!==u?(N=v===void 0&&u!==void 0&&k==="kpi"&&(0,a.jsx)(je,{result:u}),e[29]=v,e[30]=k,e[31]=u,e[32]=N):N=e[32];let y;e[33]!==v||e[34]!==k||e[35]!==u?(y=v===void 0&&u!==void 0&&k==="table"&&(0,a.jsx)("div",{className:"max-h-72 overflow-auto",children:(0,a.jsx)(Re,{result:u})}),e[33]=v,e[34]=k,e[35]=u,e[36]=y):y=e[36];let R;return e[37]!==t||e[38]!==n||e[39]!==d||e[40]!==s||e[41]!==i||e[42]!==h||e[43]!==x||e[44]!==T||e[45]!==w||e[46]!==K||e[47]!==_||e[48]!==N||e[49]!==y||e[50]!==r?(R=(0,a.jsxs)(Ne,{actions:T,draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r,children:[w,K,_,N,y]}),e[37]=t,e[38]=n,e[39]=d,e[40]=s,e[41]=i,e[42]=h,e[43]=x,e[44]=T,e[45]=w,e[46]=K,e[47]=_,e[48]=N,e[49]=y,e[50]=r,e[51]=R):R=e[51],R},"Ae"),_e=g(f=>{let e=(0,Y.c)(11),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o;return e[0]!==t||e[1]!==n||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==x||e[8]!==m||e[9]!==r?(o=ce(r)==="text"?(0,a.jsx)(ze,{draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r}):(0,a.jsx)(Ae,{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}),e[0]=t,e[1]=n,e[2]=l,e[3]=d,e[4]=s,e[5]=i,e[6]=h,e[7]=x,e[8]=m,e[9]=r,e[10]=o):o=e[10],o},"Te"),We=["bar","line","area"],$e=["chart","kpi","table","text"],Be="lunora-studio-dashboards",se={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},Ie=g((f,e)=>t=>t.map(n=>n.id===f?{...n,chartAxes:e,chartKind:e.kind}:n),"De"),Te=g((f,e)=>t=>{let n=t.find(s=>s.id===f),l=t.filter(s=>s.id!==f),d=l.findIndex(s=>s.id===e);return n===void 0||d===-1?t:[...l.slice(0,d),n,...l.slice(d)]},"je"),De=g((f,e)=>e(f==="line"?"Line":f==="area"?"Area":"Bar"),"ze"),Oe=g((f,e)=>e(f==="kpi"?"Single value":f==="table"?"Table":f==="text"?"Text":"Chart"),"Be"),Fe=g(f=>{let e=(0,Y.c)(82),{draft:t,editing:n,onCancel:l,onChange:d,onSubmit:s}=f,i=te(),h;e[0]!==t||e[1]!==d?(h=g(c=>{d({...t,title:c.target.value})},"c"),e[0]=t,e[1]=d,e[2]=h):h=e[2];let x=h,m;e[3]!==t||e[4]!==d?(m=g(c=>{d({...t,sql:c.target.value})},"h"),e[3]=t,e[4]=d,e[5]=m):m=e[5];let r=m,o;e[6]!==t||e[7]!==d?(o=g(c=>{d({...t,text:c.target.value})},"l"),e[6]=t,e[7]=d,e[8]=o):o=e[8];let v=o,S;e[9]!==t||e[10]!==d?(S=g(c=>{d({...t,shardKey:c.target.value})},"N"),e[9]=t,e[10]=d,e[11]=S):S=e[11];let u=S,C;e[12]!==t||e[13]!==d?(C=g(c=>{d({...t,chartKind:c.target.value})},"y"),e[12]=t,e[13]=d,e[14]=C):C=e[14];let k=C,E;e[15]!==t||e[16]!==d?(E=g(c=>{d({...t,kind:c.target.value})},"E"),e[15]=t,e[16]=d,e[17]=E):E=e[17];let O=E,j;e[18]!==s?(j=g(()=>{s()},"q"),e[18]=s,e[19]=j):j=e[19];let T=j,w=t.kind==="text",K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==w?(K=t.title.trim()!==""&&(w?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=w,e[24]=K):K=e[24];let _=K,N;e[25]!==i?(N=i("Widget title"),e[25]=i,e[26]=N):N=e[26];let y;e[27]!==i?(y=i("Widget title"),e[27]=i,e[28]=y):y=e[28];let R;e[29]!==t.title||e[30]!==x||e[31]!==y||e[32]!==N?(R=(0,a.jsx)("input",{"aria-label":N,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:x,placeholder:y,type:"text",value:t.title}),e[29]=t.title,e[30]=x,e[31]=y,e[32]=N,e[33]=R):R=e[33];let F;e[34]!==i?(F=i("Widget type"),e[34]=i,e[35]=F):F=e[35];let H=t.kind,D;e[36]!==i?(D=$e.map(c=>(0,a.jsx)("option",{value:c,children:Oe(c,i)},c)),e[36]=i,e[37]=D):D=e[37];let W;e[38]!==t.kind||e[39]!==O||e[40]!==F||e[41]!==D?(W=(0,a.jsx)("select",{"aria-label":F,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:H,children:D}),e[38]=t.kind,e[39]=O,e[40]=F,e[41]=D,e[42]=W):W=e[42];let M;e[43]!==t.sql||e[44]!==t.text||e[45]!==w||e[46]!==r||e[47]!==v||e[48]!==i?(M=w?(0,a.jsx)("textarea",{"aria-label":i("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:v,placeholder:i("Notes for whoever reads this dashboard."),value:t.text}):(0,a.jsx)("textarea",{"aria-label":i("SQL query"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:r,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=w,e[46]=r,e[47]=v,e[48]=i,e[49]=M):M=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==k||e[53]!==i?($=t.kind==="chart"&&(0,a.jsx)("select",{"aria-label":i("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:k,value:t.chartKind,children:We.map(c=>(0,a.jsx)("option",{value:c,children:De(c,i)},c))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=k,e[53]=i,e[54]=$):$=e[54];let L;e[55]!==t.shardKey||e[56]!==w||e[57]!==u||e[58]!==i?(L=!w&&(0,a.jsx)("input",{"aria-label":i("Shard key (optional)"),className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:u,placeholder:i("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=w,e[57]=u,e[58]=i,e[59]=L):L=e[59];let z;e[60]!==i?(z=i("Cancel"),e[60]=i,e[61]=z):z=e[61];let q;e[62]!==l||e[63]!==z?(q=(0,a.jsx)(X,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:z}),e[62]=l,e[63]=z,e[64]=q):q=e[64];let B=!_,I;e[65]!==n||e[66]!==i?(I=i(n?"Save widget":"Add widget"),e[65]=n,e[66]=i,e[67]=I):I=e[67];let A;e[68]!==T||e[69]!==B||e[70]!==I?(A=(0,a.jsx)(X,{"data-testid":"dashboards-form-save",disabled:B,onClick:T,size:"sm",type:"button",children:I}),e[68]=T,e[69]=B,e[70]=I,e[71]=A):A=e[71];let p;e[72]!==q||e[73]!==A?(p=(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=p):p=e[74];let b;return e[75]!==R||e[76]!==W||e[77]!==M||e[78]!==$||e[79]!==L||e[80]!==p?(b=(0,a.jsx)(ae,{"data-testid":"dashboards-form",children:(0,a.jsxs)(ne,{className:"flex flex-col gap-3 py-4",children:[R,W,M,$,L,p]})}),e[75]=R,e[76]=W,e[77]=M,e[78]=$,e[79]=L,e[80]=p,e[81]=b):b=e[81],b},"Fe"),tt=g(f=>{let e=(0,Y.c)(53),{initialShardKey:t}=f,n=te(),[l,d]=ke(Be),[s,i]=(0,G.useState)(se),[h,x]=(0,G.useState)(null),[m,r]=(0,G.useState)(!1),o=ye(t??""),[v,S]=(0,G.useState)(null),u=(0,G.useRef)(null),C;e[0]!==t?(C=g(()=>{x(null),i({...se,shardKey:t??""}),r(!0)},"y"),e[0]=t,e[1]=C):C=e[1];let k=C,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=g(()=>{r(!1),x(null),i(se)},"E"),e[2]=E):E=e[2];let O=E,j;e[3]!==l?(j=g(p=>{let b=l.find(c=>c.id===p);b!==void 0&&(x(p),i({chartKind:b.chartKind??"bar",kind:ce(b),shardKey:b.shardKey??"",sql:b.sql,text:b.text??"",title:b.title}),r(!0))},"q"),e[3]=l,e[4]=j):j=e[4];let T=j,w;e[5]!==o||e[6]!==d?(w=g((p,b)=>{S(p),oe((async()=>{let c=await o.inferChart({columns:b.columns,rowCount:b.rowCount});c!==void 0&&d(Ie(p,c))})().finally(()=>{S(c=>c===p?null:c)}))},"C"),e[5]=o,e[6]=d,e[7]=w):w=e[7];let K=w,_;e[8]!==d?(_=g(p=>{d(b=>b.filter(c=>c.id!==p))},"W"),e[8]=d,e[9]=_):_=e[9];let N=_,y;e[10]!==d?(y=g((p,b)=>{d(Te(p,b))},"k"),e[10]=d,e[11]=y):y=e[11];let R=y,F;e[12]!==d?(F=g((p,b)=>{d(c=>{let J=c.findIndex(P=>P.id===p),V=J+b;if(J===-1||V<0||V>=c.length)return c;let U=[...c],Q=U[J],Z=U[V];return Q===void 0||Z===void 0?c:(U[J]=Z,U[V]=Q,U)})},"_"),e[12]=d,e[13]=F):F=e[13];let H=F,D;e[14]!==s||e[15]!==h||e[16]!==d?(D=g(()=>{let p=s.title.trim(),b=s.sql.trim(),c=s.text.trim(),{chartKind:J,kind:V}=s;if(p===""||(V==="text"?c==="":b===""))return;let U={chartKind:J,kind:V,shardKey:s.shardKey.trim(),sql:b,text:c,title:p};d(h===null?Q=>[...Q,{...U,id:we("w")}]:Q=>Q.map(Z=>Z.id===h?{...Z,...U}:Z)),O()},"B"),e[14]=s,e[15]=h,e[16]=d,e[17]=D):D=e[17];let W=D,M;e[18]!==n?(M=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=M):M=e[19];let $;e[20]!==M?($=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:M}),e[20]=M,e[21]=$):$=e[21];let L;e[22]!==m||e[23]!==k||e[24]!==n?(L=!m&&(0,a.jsx)(X,{"data-testid":"dashboards-add",onClick:k,size:"sm",type:"button",children:n("Add widget")}),e[22]=m,e[23]=k,e[24]=n,e[25]=L):L=e[25];let z;e[26]!==$||e[27]!==L?(z=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[$,L]}),e[26]=$,e[27]=L,e[28]=z):z=e[28];let q;e[29]!==o||e[30]!==n?(q=o.reason("chart")!==void 0&&(0,a.jsx)(le,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=o,e[30]=n,e[31]=q):q=e[31];let B;e[32]!==s||e[33]!==h||e[34]!==m||e[35]!==W?(B=m&&(0,a.jsx)(Fe,{draft:s,editing:h!==null,onCancel:O,onChange:i,onSubmit:W}),e[32]=s,e[33]=h,e[34]=m,e[35]=W,e[36]=B):B=e[36];let I;e[37]!==o.unavailable||e[38]!==m||e[39]!==v||e[40]!==T||e[41]!==H||e[42]!==N||e[43]!==R||e[44]!==K||e[45]!==n||e[46]!==l?(I=l.length===0&&!m?(0,a.jsx)(pe,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map((p,b)=>(0,a.jsx)(_e,{draggedRef:u,first:b===0,inferring:v===p.id,last:b===l.length-1,onEdit:T,onMove:H,onRemove:N,onReorder:R,onSuggest:o.unavailable?void 0:K,widget:p},p.id))}),e[37]=o.unavailable,e[38]=m,e[39]=v,e[40]=T,e[41]=H,e[42]=N,e[43]=R,e[44]=K,e[45]=n,e[46]=l,e[47]=I):I=e[47];let A;return e[48]!==z||e[49]!==q||e[50]!==B||e[51]!==I?(A=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[z,q,B,I]}),e[48]=z,e[49]=q,e[50]=B,e[51]=I,e[52]=A):A=e[52],A},"it");export{tt as default};
|
|
1
|
+
import{a as Ce,b as Re}from"./chunk-5YEMXXQZ.js";import"./chunk-VEG327ST.js";import"./chunk-WARWYT4K.js";import{a as ye}from"./chunk-CBFVQCWS.js";import"./chunk-Y2YLTUMD.js";import"./chunk-B5YCFPYG.js";import{e as ke,g as we}from"./chunk-4KPATTV6.js";import"./chunk-F4NZZ3LK.js";import"./chunk-4AG356VE.js";import{a as X}from"./chunk-ECXQQPVU.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import{a as pe}from"./chunk-V5ZKAZR6.js";import"./chunk-DMQVY5L7.js";import{a as le}from"./chunk-5XQM44J7.js";import"./chunk-WVAWKCNQ.js";import{a as be}from"./chunk-LYVYUTQY.js";import"./chunk-LUHBGCMO.js";import{a as ae,b as fe,c as xe,e as ne}from"./chunk-VUMS4VIV.js";import{n as ve}from"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as te,h as he,i as ue,j as ge,r as me,s as oe}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as Ke}from"./chunk-A6TVTNKO.js";import{a as Se,b as Me}from"./chunk-ADABTCDI.js";import{a as g,d as ie}from"./chunk-5PEAXTYQ.js";var Y=ie(Ke(),1),G=ie(Se(),1);var a=ie(Me(),1);var Le=he(be.runSql),qe=g((f,e)=>{let t=(0,Y.c)(11),n=ve(),[l,d]=(0,G.useState)(void 0),[s,i]=(0,G.useState)(void 0),[h,x]=(0,G.useState)(!0),m;t[0]!==n||t[1]!==e||t[2]!==f?(m=g(async u=>{x(!0);try{let C=await n.query(Le,{sql:f},ue(e));u.cancelled||(d(C),i(void 0))}catch(C){let k=C;u.cancelled||(d(void 0),i(ge(k)))}u.cancelled||x(!1)},"h"),t[0]=n,t[1]=e,t[2]=f,t[3]=m):m=t[3];let r=m,o,v;t[4]!==r?(o=g(()=>{let u={cancelled:!1};return oe(r(u)),()=>{u.cancelled=!0}},"l"),v=[r],t[4]=r,t[5]=o,t[6]=v):(o=t[5],v=t[6]),(0,G.useEffect)(o,v);let S;return t[7]!==s||t[8]!==h||t[9]!==l?(S={error:s,loading:h,result:l},t[7]=s,t[8]=h,t[9]=l,t[10]=S):S=t[10],S},"Le"),Ee=g(f=>{f.preventDefault()},"Me"),ce=g(f=>f.kind??"chart","le"),Ne=g(f=>{let e=(0,Y.c)(80),{actions:t,children:n,draggedRef:l,first:d,last:s,onEdit:i,onMove:h,onRemove:x,onReorder:m,widget:r}=f,o=te(),v;e[0]!==h||e[1]!==r.id?(v=g(()=>{h(r.id,-1)},"g"),e[0]=h,e[1]=r.id,e[2]=v):v=e[2];let S=v,u;e[3]!==h||e[4]!==r.id?(u=g(()=>{h(r.id,1)},"f"),e[3]=h,e[4]=r.id,e[5]=u):u=e[5];let C=u,k;e[6]!==i||e[7]!==r.id?(k=g(()=>{i(r.id)},"x"),e[6]=i,e[7]=r.id,e[8]=k):k=e[8];let E=k,O;e[9]!==x||e[10]!==r.id?(O=g(()=>{x(r.id)},"O"),e[9]=x,e[10]=r.id,e[11]=O):O=e[11];let j=O,T;e[12]!==l||e[13]!==r.id?(T=g(()=>{l.current=r.id},"z"),e[12]=l,e[13]=r.id,e[14]=T):T=e[14];let w=T,K;e[15]!==l||e[16]!==m||e[17]!==r.id?(K=g(()=>{let de=l.current;l.current=null,de!==null&&de!==r.id&&m(de,r.id)},"R"),e[15]=l,e[16]=m,e[17]=r.id,e[18]=K):K=e[18];let _=K,N=`dashboards-widget-${r.id}`,y;e[19]!==r.title?(y=(0,a.jsx)(xe,{className:"min-w-0 cursor-grab truncate",title:r.title,children:r.title}),e[19]=r.title,e[20]=y):y=e[20];let R;e[21]!==o?(R=o("Move widget up"),e[21]=o,e[22]=R):R=e[22];let F=`dashboards-move-up-${r.id}`,H;e[23]!==o?(H=o("Move widget up"),e[23]=o,e[24]=H):H=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=(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:"m6 15 6-6 6 6"})}),e[25]=D):D=e[25];let W;e[26]!==d||e[27]!==S||e[28]!==F||e[29]!==H||e[30]!==R?(W=(0,a.jsx)(X,{"aria-label":R,"data-testid":F,disabled:d,onClick:S,size:"icon-xs",title:H,type:"button",variant:"ghost",children:D}),e[26]=d,e[27]=S,e[28]=F,e[29]=H,e[30]=R,e[31]=W):W=e[31];let M;e[32]!==o?(M=o("Move widget down"),e[32]=o,e[33]=M):M=e[33];let $=`dashboards-move-down-${r.id}`,L;e[34]!==o?(L=o("Move widget down"),e[34]=o,e[35]=L):L=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=(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:"m6 9 6 6 6-6"})}),e[36]=z):z=e[36];let q;e[37]!==s||e[38]!==C||e[39]!==M||e[40]!==$||e[41]!==L?(q=(0,a.jsx)(X,{"aria-label":M,"data-testid":$,disabled:s,onClick:C,size:"icon-xs",title:L,type:"button",variant:"ghost",children:z}),e[37]=s,e[38]=C,e[39]=M,e[40]=$,e[41]=L,e[42]=q):q=e[42];let B;e[43]!==o?(B=o("Edit widget"),e[43]=o,e[44]=B):B=e[44];let I=`dashboards-widget-edit-${r.id}`,A;e[45]!==o?(A=o("Edit widget"),e[45]=o,e[46]=A):A=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=(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:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let b;e[48]!==E||e[49]!==B||e[50]!==I||e[51]!==A?(b=(0,a.jsx)(X,{"aria-label":B,"data-testid":I,onClick:E,size:"icon-xs",title:A,type:"button",variant:"ghost",children:p}),e[48]=E,e[49]=B,e[50]=I,e[51]=A,e[52]=b):b=e[52];let c;e[53]!==o?(c=o("Remove widget"),e[53]=o,e[54]=c):c=e[54];let J=`dashboards-widget-remove-${r.id}`,V;e[55]!==o?(V=o("Remove widget"),e[55]=o,e[56]=V):V=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=(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 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=U):U=e[57];let Q;e[58]!==j||e[59]!==c||e[60]!==J||e[61]!==V?(Q=(0,a.jsx)(X,{"aria-label":c,"data-testid":J,onClick:j,size:"icon-xs",title:V,type:"button",variant:"ghost",children:U}),e[58]=j,e[59]=c,e[60]=J,e[61]=V,e[62]=Q):Q=e[62];let Z;e[63]!==t||e[64]!==W||e[65]!==q||e[66]!==b||e[67]!==Q?(Z=(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[t,W,q,b,Q]}),e[63]=t,e[64]=W,e[65]=q,e[66]=b,e[67]=Q,e[68]=Z):Z=e[68];let P;e[69]!==Z||e[70]!==y?(P=(0,a.jsxs)(fe,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[y,Z]}),e[69]=Z,e[70]=y,e[71]=P):P=e[71];let ee;e[72]!==n?(ee=(0,a.jsx)(ne,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let re;return e[74]!==w||e[75]!==_||e[76]!==P||e[77]!==ee||e[78]!==N?(re=(0,a.jsxs)(ae,{"data-testid":N,draggable:!0,onDragOver:Ee,onDragStart:w,onDrop:_,children:[P,ee]}),e[74]=w,e[75]=_,e[76]=P,e[77]=ee,e[78]=N,e[79]=re):re=e[79],re},"ce"),je=g(f=>{let e=(0,Y.c)(10),{result:t}=f,n=te(),l=t.columns[0],d=l===void 0?void 0:t.rows[0]?.[l],s;e[0]!==d||e[1]!==n?(s=d===void 0?n("\u2014"):me(d),e[0]=d,e[1]=n,e[2]=s):s=e[2];let i;e[3]!==s?(i=(0,a.jsx)("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:s}),e[3]=s,e[4]=i):i=e[4];let h;e[5]!==l?(h=l!==void 0&&(0,a.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=h):h=e[6];let x;return e[7]!==i||e[8]!==h?(x=(0,a.jsxs)("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[i,h]}),e[7]=i,e[8]=h,e[9]=x):x=e[9],x},"Ee"),ze=g(f=>{let e=(0,Y.c)(12),{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x}=f,m=x.text??"",r;e[0]!==m?(r=(0,a.jsx)("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:m}),e[0]=m,e[1]=r):r=e[1];let o;return e[2]!==t||e[3]!==n||e[4]!==l||e[5]!==d||e[6]!==s||e[7]!==i||e[8]!==h||e[9]!==r||e[10]!==x?(o=(0,a.jsx)(Ne,{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x,children:r}),e[2]=t,e[3]=n,e[4]=l,e[5]=d,e[6]=s,e[7]=i,e[8]=h,e[9]=r,e[10]=x,e[11]=o):o=e[11],o},"qe"),Ae=g(f=>{let e=(0,Y.c)(52),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o=te(),{error:v,loading:S,result:u}=qe(r.sql,r.shardKey??""),C;e[0]!==r?(C=ce(r),e[0]=r,e[1]=C):C=e[1];let k=C,E;e[2]!==m||e[3]!==u||e[4]!==r.id?(E=g(()=>{u!==void 0&&m?.(r.id,u)},"E"),e[2]=m,e[3]=u,e[4]=r.id,e[5]=E):E=e[5];let O=E,j;e[6]!==l||e[7]!==k||e[8]!==m||e[9]!==O||e[10]!==u||e[11]!==o||e[12]!==r.id?(j=k==="chart"&&m!==void 0&&u!==void 0?(0,a.jsx)(X,{"aria-label":o("Suggest chart"),"data-testid":`dashboards-widget-suggest-${r.id}`,disabled:l,onClick:O,size:"icon-xs",title:o(l?"Suggesting\u2026":"Suggest chart"),type:"button",variant:"ghost",children:(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:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=l,e[7]=k,e[8]=m,e[9]=O,e[10]=u,e[11]=o,e[12]=r.id,e[13]=j):j=e[13];let T=j,w;e[14]!==v||e[15]!==r.id?(w=v!==void 0&&(0,a.jsx)(le,{className:"font-mono text-xs",testId:`dashboards-widget-error-${r.id}`,variant:"destructive",children:v}),e[14]=v,e[15]=r.id,e[16]=w):w=e[16];let K;e[17]!==v||e[18]!==S||e[19]!==u||e[20]!==o||e[21]!==r.id?(K=v===void 0&&S&&u===void 0&&(0,a.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${r.id}`,children:o("Running\u2026")}),e[17]=v,e[18]=S,e[19]=u,e[20]=o,e[21]=r.id,e[22]=K):K=e[22];let _;e[23]!==v||e[24]!==k||e[25]!==u||e[26]!==r.chartAxes||e[27]!==r.chartKind?(_=v===void 0&&u!==void 0&&k==="chart"&&(0,a.jsx)(Ce,{axes:r.chartAxes,kind:r.chartKind,result:u}),e[23]=v,e[24]=k,e[25]=u,e[26]=r.chartAxes,e[27]=r.chartKind,e[28]=_):_=e[28];let N;e[29]!==v||e[30]!==k||e[31]!==u?(N=v===void 0&&u!==void 0&&k==="kpi"&&(0,a.jsx)(je,{result:u}),e[29]=v,e[30]=k,e[31]=u,e[32]=N):N=e[32];let y;e[33]!==v||e[34]!==k||e[35]!==u?(y=v===void 0&&u!==void 0&&k==="table"&&(0,a.jsx)("div",{className:"max-h-72 overflow-auto",children:(0,a.jsx)(Re,{result:u})}),e[33]=v,e[34]=k,e[35]=u,e[36]=y):y=e[36];let R;return e[37]!==t||e[38]!==n||e[39]!==d||e[40]!==s||e[41]!==i||e[42]!==h||e[43]!==x||e[44]!==T||e[45]!==w||e[46]!==K||e[47]!==_||e[48]!==N||e[49]!==y||e[50]!==r?(R=(0,a.jsxs)(Ne,{actions:T,draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r,children:[w,K,_,N,y]}),e[37]=t,e[38]=n,e[39]=d,e[40]=s,e[41]=i,e[42]=h,e[43]=x,e[44]=T,e[45]=w,e[46]=K,e[47]=_,e[48]=N,e[49]=y,e[50]=r,e[51]=R):R=e[51],R},"Ae"),_e=g(f=>{let e=(0,Y.c)(11),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o;return e[0]!==t||e[1]!==n||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==x||e[8]!==m||e[9]!==r?(o=ce(r)==="text"?(0,a.jsx)(ze,{draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r}):(0,a.jsx)(Ae,{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}),e[0]=t,e[1]=n,e[2]=l,e[3]=d,e[4]=s,e[5]=i,e[6]=h,e[7]=x,e[8]=m,e[9]=r,e[10]=o):o=e[10],o},"Te"),We=["bar","line","area"],$e=["chart","kpi","table","text"],Be="lunora-studio-dashboards",se={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},Ie=g((f,e)=>t=>t.map(n=>n.id===f?{...n,chartAxes:e,chartKind:e.kind}:n),"De"),Te=g((f,e)=>t=>{let n=t.find(s=>s.id===f),l=t.filter(s=>s.id!==f),d=l.findIndex(s=>s.id===e);return n===void 0||d===-1?t:[...l.slice(0,d),n,...l.slice(d)]},"je"),De=g((f,e)=>e(f==="line"?"Line":f==="area"?"Area":"Bar"),"ze"),Oe=g((f,e)=>e(f==="kpi"?"Single value":f==="table"?"Table":f==="text"?"Text":"Chart"),"Be"),Fe=g(f=>{let e=(0,Y.c)(82),{draft:t,editing:n,onCancel:l,onChange:d,onSubmit:s}=f,i=te(),h;e[0]!==t||e[1]!==d?(h=g(c=>{d({...t,title:c.target.value})},"c"),e[0]=t,e[1]=d,e[2]=h):h=e[2];let x=h,m;e[3]!==t||e[4]!==d?(m=g(c=>{d({...t,sql:c.target.value})},"h"),e[3]=t,e[4]=d,e[5]=m):m=e[5];let r=m,o;e[6]!==t||e[7]!==d?(o=g(c=>{d({...t,text:c.target.value})},"l"),e[6]=t,e[7]=d,e[8]=o):o=e[8];let v=o,S;e[9]!==t||e[10]!==d?(S=g(c=>{d({...t,shardKey:c.target.value})},"N"),e[9]=t,e[10]=d,e[11]=S):S=e[11];let u=S,C;e[12]!==t||e[13]!==d?(C=g(c=>{d({...t,chartKind:c.target.value})},"y"),e[12]=t,e[13]=d,e[14]=C):C=e[14];let k=C,E;e[15]!==t||e[16]!==d?(E=g(c=>{d({...t,kind:c.target.value})},"E"),e[15]=t,e[16]=d,e[17]=E):E=e[17];let O=E,j;e[18]!==s?(j=g(()=>{s()},"q"),e[18]=s,e[19]=j):j=e[19];let T=j,w=t.kind==="text",K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==w?(K=t.title.trim()!==""&&(w?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=w,e[24]=K):K=e[24];let _=K,N;e[25]!==i?(N=i("Widget title"),e[25]=i,e[26]=N):N=e[26];let y;e[27]!==i?(y=i("Widget title"),e[27]=i,e[28]=y):y=e[28];let R;e[29]!==t.title||e[30]!==x||e[31]!==y||e[32]!==N?(R=(0,a.jsx)("input",{"aria-label":N,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:x,placeholder:y,type:"text",value:t.title}),e[29]=t.title,e[30]=x,e[31]=y,e[32]=N,e[33]=R):R=e[33];let F;e[34]!==i?(F=i("Widget type"),e[34]=i,e[35]=F):F=e[35];let H=t.kind,D;e[36]!==i?(D=$e.map(c=>(0,a.jsx)("option",{value:c,children:Oe(c,i)},c)),e[36]=i,e[37]=D):D=e[37];let W;e[38]!==t.kind||e[39]!==O||e[40]!==F||e[41]!==D?(W=(0,a.jsx)("select",{"aria-label":F,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:H,children:D}),e[38]=t.kind,e[39]=O,e[40]=F,e[41]=D,e[42]=W):W=e[42];let M;e[43]!==t.sql||e[44]!==t.text||e[45]!==w||e[46]!==r||e[47]!==v||e[48]!==i?(M=w?(0,a.jsx)("textarea",{"aria-label":i("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:v,placeholder:i("Notes for whoever reads this dashboard."),value:t.text}):(0,a.jsx)("textarea",{"aria-label":i("SQL query"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:r,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=w,e[46]=r,e[47]=v,e[48]=i,e[49]=M):M=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==k||e[53]!==i?($=t.kind==="chart"&&(0,a.jsx)("select",{"aria-label":i("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:k,value:t.chartKind,children:We.map(c=>(0,a.jsx)("option",{value:c,children:De(c,i)},c))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=k,e[53]=i,e[54]=$):$=e[54];let L;e[55]!==t.shardKey||e[56]!==w||e[57]!==u||e[58]!==i?(L=!w&&(0,a.jsx)("input",{"aria-label":i("Shard key (optional)"),className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:u,placeholder:i("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=w,e[57]=u,e[58]=i,e[59]=L):L=e[59];let z;e[60]!==i?(z=i("Cancel"),e[60]=i,e[61]=z):z=e[61];let q;e[62]!==l||e[63]!==z?(q=(0,a.jsx)(X,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:z}),e[62]=l,e[63]=z,e[64]=q):q=e[64];let B=!_,I;e[65]!==n||e[66]!==i?(I=i(n?"Save widget":"Add widget"),e[65]=n,e[66]=i,e[67]=I):I=e[67];let A;e[68]!==T||e[69]!==B||e[70]!==I?(A=(0,a.jsx)(X,{"data-testid":"dashboards-form-save",disabled:B,onClick:T,size:"sm",type:"button",children:I}),e[68]=T,e[69]=B,e[70]=I,e[71]=A):A=e[71];let p;e[72]!==q||e[73]!==A?(p=(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=p):p=e[74];let b;return e[75]!==R||e[76]!==W||e[77]!==M||e[78]!==$||e[79]!==L||e[80]!==p?(b=(0,a.jsx)(ae,{"data-testid":"dashboards-form",children:(0,a.jsxs)(ne,{className:"flex flex-col gap-3 py-4",children:[R,W,M,$,L,p]})}),e[75]=R,e[76]=W,e[77]=M,e[78]=$,e[79]=L,e[80]=p,e[81]=b):b=e[81],b},"Fe"),tt=g(f=>{let e=(0,Y.c)(53),{initialShardKey:t}=f,n=te(),[l,d]=ke(Be),[s,i]=(0,G.useState)(se),[h,x]=(0,G.useState)(null),[m,r]=(0,G.useState)(!1),o=ye(t??""),[v,S]=(0,G.useState)(null),u=(0,G.useRef)(null),C;e[0]!==t?(C=g(()=>{x(null),i({...se,shardKey:t??""}),r(!0)},"y"),e[0]=t,e[1]=C):C=e[1];let k=C,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=g(()=>{r(!1),x(null),i(se)},"E"),e[2]=E):E=e[2];let O=E,j;e[3]!==l?(j=g(p=>{let b=l.find(c=>c.id===p);b!==void 0&&(x(p),i({chartKind:b.chartKind??"bar",kind:ce(b),shardKey:b.shardKey??"",sql:b.sql,text:b.text??"",title:b.title}),r(!0))},"q"),e[3]=l,e[4]=j):j=e[4];let T=j,w;e[5]!==o||e[6]!==d?(w=g((p,b)=>{S(p),oe((async()=>{let c=await o.inferChart({columns:b.columns,rowCount:b.rowCount});c!==void 0&&d(Ie(p,c))})().finally(()=>{S(c=>c===p?null:c)}))},"C"),e[5]=o,e[6]=d,e[7]=w):w=e[7];let K=w,_;e[8]!==d?(_=g(p=>{d(b=>b.filter(c=>c.id!==p))},"W"),e[8]=d,e[9]=_):_=e[9];let N=_,y;e[10]!==d?(y=g((p,b)=>{d(Te(p,b))},"k"),e[10]=d,e[11]=y):y=e[11];let R=y,F;e[12]!==d?(F=g((p,b)=>{d(c=>{let J=c.findIndex(P=>P.id===p),V=J+b;if(J===-1||V<0||V>=c.length)return c;let U=[...c],Q=U[J],Z=U[V];return Q===void 0||Z===void 0?c:(U[J]=Z,U[V]=Q,U)})},"_"),e[12]=d,e[13]=F):F=e[13];let H=F,D;e[14]!==s||e[15]!==h||e[16]!==d?(D=g(()=>{let p=s.title.trim(),b=s.sql.trim(),c=s.text.trim(),{chartKind:J,kind:V}=s;if(p===""||(V==="text"?c==="":b===""))return;let U={chartKind:J,kind:V,shardKey:s.shardKey.trim(),sql:b,text:c,title:p};d(h===null?Q=>[...Q,{...U,id:we("w")}]:Q=>Q.map(Z=>Z.id===h?{...Z,...U}:Z)),O()},"B"),e[14]=s,e[15]=h,e[16]=d,e[17]=D):D=e[17];let W=D,M;e[18]!==n?(M=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=M):M=e[19];let $;e[20]!==M?($=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:M}),e[20]=M,e[21]=$):$=e[21];let L;e[22]!==m||e[23]!==k||e[24]!==n?(L=!m&&(0,a.jsx)(X,{"data-testid":"dashboards-add",onClick:k,size:"sm",type:"button",children:n("Add widget")}),e[22]=m,e[23]=k,e[24]=n,e[25]=L):L=e[25];let z;e[26]!==$||e[27]!==L?(z=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[$,L]}),e[26]=$,e[27]=L,e[28]=z):z=e[28];let q;e[29]!==o||e[30]!==n?(q=o.reason("chart")!==void 0&&(0,a.jsx)(le,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=o,e[30]=n,e[31]=q):q=e[31];let B;e[32]!==s||e[33]!==h||e[34]!==m||e[35]!==W?(B=m&&(0,a.jsx)(Fe,{draft:s,editing:h!==null,onCancel:O,onChange:i,onSubmit:W}),e[32]=s,e[33]=h,e[34]=m,e[35]=W,e[36]=B):B=e[36];let I;e[37]!==o.unavailable||e[38]!==m||e[39]!==v||e[40]!==T||e[41]!==H||e[42]!==N||e[43]!==R||e[44]!==K||e[45]!==n||e[46]!==l?(I=l.length===0&&!m?(0,a.jsx)(pe,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map((p,b)=>(0,a.jsx)(_e,{draggedRef:u,first:b===0,inferring:v===p.id,last:b===l.length-1,onEdit:T,onMove:H,onRemove:N,onReorder:R,onSuggest:o.unavailable?void 0:K,widget:p},p.id))}),e[37]=o.unavailable,e[38]=m,e[39]=v,e[40]=T,e[41]=H,e[42]=N,e[43]=R,e[44]=K,e[45]=n,e[46]=l,e[47]=I):I=e[47];let A;return e[48]!==z||e[49]!==q||e[50]!==B||e[51]!==I?(A=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[z,q,B,I]}),e[48]=z,e[49]=q,e[50]=B,e[51]=I,e[52]=A):A=e[52],A},"it");export{tt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-BCT3KY76.js";import{a as L}from"./chunk-V5ZKAZR6.js";import{b as S}from"./chunk-UB6S6VYI.js";import"./chunk-DMQVY5L7.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-WVAWKCNQ.js";import"./chunk-EOFWXI3T.js";import{a as C}from"./chunk-LYVYUTQY.js";import{c as w}from"./chunk-LUHBGCMO.js";import{a as I,e as $}from"./chunk-VUMS4VIV.js";import"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as b}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as _}from"./chunk-A6TVTNKO.js";import{b as j}from"./chunk-ADABTCDI.js";import{a as f,d as y}from"./chunk-5PEAXTYQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=b(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=w(C.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(L,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(I,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(S,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as X}from"./chunk-CVSIFPI5.js";import{a as Q}from"./chunk-
|
|
1
|
+
import{a as X}from"./chunk-CVSIFPI5.js";import{a as Q}from"./chunk-CBFVQCWS.js";import{d as O}from"./chunk-UG6ZNYWH.js";import{j as J}from"./chunk-SQO3WGXH.js";import"./chunk-R76ATTPC.js";import"./chunk-4AG356VE.js";import{a as R}from"./chunk-ECXQQPVU.js";import"./chunk-EOHXBC4U.js";import"./chunk-JEJV6SVN.js";import"./chunk-DMQVY5L7.js";import"./chunk-LYVYUTQY.js";import"./chunk-LUHBGCMO.js";import"./chunk-PLCYDHU3.js";import"./chunk-WY23EROJ.js";import{B as H,s as Y,v as G}from"./chunk-G4H5DPO6.js";import"./chunk-JSVT5VBU.js";import{a as st}from"./chunk-A6TVTNKO.js";import{a as et,b as at}from"./chunk-ADABTCDI.js";import{a as u,d as V}from"./chunk-5PEAXTYQ.js";var B=V(st(),1);var d=V(at(),1);var z=V(et(),1);var nt=u(h=>{let t=(0,B.c)(28),{draft:e,onDraftChange:r,onSend:n,pending:a}=h,l=H(),s;t[0]!==l?(s=l("Ask about your data"),t[0]=l,t[1]=s):s=t[1];let o;t[2]!==r?(o=u(v=>{r(v.target.value)},"o"),t[2]=r,t[3]=o):o=t[3];let i;t[4]!==n?(i=u(v=>{v.key==="Enter"&&(v.preventDefault(),n())},"r"),t[4]=n,t[5]=i):i=t[5];let c;t[6]!==l?(c=l("Ask about your data"),t[6]=l,t[7]=c):c=t[7];let p;t[8]!==e||t[9]!==a||t[10]!==s||t[11]!==o||t[12]!==i||t[13]!==c?(p=(0,d.jsx)(J,{"aria-label":s,"data-testid":"assistant-input",disabled:a,onChange:o,onKeyDown:i,placeholder:c,value:e}),t[8]=e,t[9]=a,t[10]=s,t[11]=o,t[12]=i,t[13]=c,t[14]=p):p=t[14];let x;t[15]!==e||t[16]!==a?(x=a||e.trim()==="",t[15]=e,t[16]=a,t[17]=x):x=t[17];let m;t[18]!==a||t[19]!==l?(m=l(a?"Thinking\u2026":"Send"),t[18]=a,t[19]=l,t[20]=m):m=t[20];let f;t[21]!==n||t[22]!==x||t[23]!==m?(f=(0,d.jsx)(R,{"data-testid":"assistant-send",disabled:x,onClick:n,size:"xs",type:"button",children:m}),t[21]=n,t[22]=x,t[23]=m,t[24]=f):f=t[24];let g;return t[25]!==p||t[26]!==f?(g=(0,d.jsxs)("div",{className:"flex items-center gap-2 border-t border-border px-3 py-2",children:[p,f]}),t[25]=p,t[26]=f,t[27]=g):g=t[27],g},"nt"),lt=u(h=>{let t=(0,B.c)(17),{onClose:e}=h,r=H(),n;t[0]!==r?(n=r("Assistant"),t[0]=r,t[1]=n):n=t[1];let a;t[2]!==n?(a=(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:n}),t[2]=n,t[3]=a):a=t[3];let l;t[4]!==r?(l=r("Answers are suggestions \u2014 nothing runs until you insert and run it."),t[4]=r,t[5]=l):l=t[5];let s;t[6]!==l?(s=(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l}),t[6]=l,t[7]=s):s=t[7];let o;t[8]!==r?(o=r("Close assistant"),t[8]=r,t[9]=o):o=t[9];let i;t[10]!==e||t[11]!==o?(i=(0,d.jsx)(R,{"aria-label":o,className:"ms-auto","data-testid":"assistant-close",onClick:e,size:"xs",type:"button",variant:"ghost",children:"\xD7"}),t[10]=e,t[11]=o,t[12]=i):i=t[12];let c;return t[13]!==a||t[14]!==s||t[15]!==i?(c=(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-1.5",children:[a,s,i]}),t[13]=a,t[14]=s,t[15]=i,t[16]=c):c=t[16],c},"lt"),ot={img:u(()=>null,"img")},Z=u(h=>{let t=(0,B.c)(2),{text:e}=h,r;return t[0]!==e?(r=(0,d.jsx)("div",{className:"prose-sm max-w-none text-xs","data-testid":"assistant-turn-body",children:(0,d.jsx)(O,{components:ot,children:e})}),t[0]=e,t[1]=r):r=t[1],r},"U"),_=u(h=>{let t=(0,B.c)(6),{children:e,label:r,testId:n}=h,a;t[0]!==r?(a=(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r}),t[0]=r,t[1]=a):a=t[1];let l;return t[2]!==e||t[3]!==a||t[4]!==n?(l=(0,d.jsxs)("li",{className:"flex flex-col gap-1 border-b border-border px-3 py-2 last:border-b-0","data-testid":n,children:[a,e]}),t[2]=e,t[3]=a,t[4]=n,t[5]=l):l=t[5],l},"W"),rt=u(h=>{let t=(0,B.c)(7),{text:e}=h,r=H(),n;t[0]!==r?(n=r("Assistant"),t[0]=r,t[1]=n):n=t[1];let a;t[2]!==e?(a=(0,d.jsx)(Z,{text:e}),t[2]=e,t[3]=a):a=t[3];let l;return t[4]!==n||t[5]!==a?(l=(0,d.jsx)(_,{label:n,testId:"assistant-turn-live",children:a}),t[4]=n,t[5]=a,t[6]=l):l=t[6],l},"ot"),it=u(h=>{let t=(0,B.c)(20),{activeId:e,onDelete:r,onNew:n,onSelect:a,sessions:l}=h,s=H(),o;if(t[0]!==e||t[1]!==r||t[2]!==a||t[3]!==l||t[4]!==s){let x;t[6]!==e||t[7]!==r||t[8]!==a||t[9]!==l.length||t[10]!==s?(x=u(m=>(0,d.jsxs)("span",{className:"flex shrink-0 items-center",children:[(0,d.jsx)(R,{"data-testid":"assistant-session",onClick:u(()=>{a(m.id)},"onClick"),size:"xs",type:"button",variant:m.id===e?"secondary":"ghost",children:m.name}),l.length>1&&(0,d.jsx)(R,{"aria-label":s("Close chat"),"data-testid":"assistant-session-close",onClick:u(()=>{r(m.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:"\xD7"})]},m.id),"p"),t[6]=e,t[7]=r,t[8]=a,t[9]=l.length,t[10]=s,t[11]=x):x=t[11],o=l.map(x),t[0]=e,t[1]=r,t[2]=a,t[3]=l,t[4]=s,t[5]=o}else o=t[5];let i;t[12]!==s?(i=s("New chat"),t[12]=s,t[13]=i):i=t[13];let c;t[14]!==n||t[15]!==i?(c=(0,d.jsx)(R,{"aria-label":i,className:"shrink-0","data-testid":"assistant-session-new",onClick:n,size:"xs",type:"button",variant:"ghost",children:"+"}),t[14]=n,t[15]=i,t[16]=c):c=t[16];let p;return t[17]!==o||t[18]!==c?(p=(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b border-border px-2 py-1","data-testid":"assistant-sessions",children:[o,c]}),t[17]=o,t[18]=c,t[19]=p):p=t[19],p},"at"),dt=u(h=>{let t=(0,B.c)(9),{reason:e,truncated:r}=h,n=H(),a;t[0]!==n||t[1]!==r?(a=r&&(0,d.jsx)("p",{className:"px-3 py-1 text-[11px] text-muted-foreground","data-testid":"assistant-truncated",children:n("Older turns were dropped to fit the context budget.")}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let l;t[3]!==e||t[4]!==n?(l=e!==void 0&&(0,d.jsx)("p",{className:"px-3 py-1 text-[11px] text-destructive","data-testid":"assistant-error",children:X(e,n)}),t[3]=e,t[4]=n,t[5]=l):l=t[5];let s;return t[6]!==a||t[7]!==l?(s=(0,d.jsxs)(d.Fragment,{children:[a,l]}),t[6]=a,t[7]=l,t[8]=s):s=t[8],s},"rt"),ct=u(h=>{let t=(0,B.c)(12),{onPick:e,suggestions:r}=h,n=H(),a;t[0]!==n?(a=n("Try asking"),t[0]=n,t[1]=a):a=t[1];let l;t[2]!==a?(l=(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground",children:a}),t[2]=a,t[3]=l):l=t[3];let s;if(t[4]!==e||t[5]!==r){let i;t[7]!==e?(i=u(c=>(0,d.jsx)("button",{className:"self-start rounded-md border border-border px-2 py-1 text-start text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"assistant-suggestion",onClick:u(()=>{e(c)},"onClick"),type:"button",children:c},c),"r"),t[7]=e,t[8]=i):i=t[8],s=r.map(i),t[4]=e,t[5]=r,t[6]=s}else s=t[6];let o;return t[9]!==l||t[10]!==s?(o=(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-3 py-2","data-testid":"assistant-suggestions",children:[l,s]}),t[9]=l,t[10]=s,t[11]=o):o=t[11],o},"dt"),L="```",ut=u(h=>{if(h.startsWith(L))return h.slice(L.length).trim().toLowerCase()==="sql"?"sql":"foreign"},"ct"),pt=u(h=>{let t=[],e=h.split(`
|
|
2
2
|
`),r,n=!1;for(let a of e){let l=a.trim();if(n){n=l!==L;continue}if(r===void 0){let s=ut(l);s==="sql"?r=[]:s==="foreign"&&(n=!0);continue}if(l===L){let s=r.join(`
|
|
3
3
|
`).trim();s!==""&&t.push(s),r=void 0;continue}r.push(a)}return t},"ft"),mt=u(h=>{let t=(0,B.c)(29),{approval:e,onDecide:r}=h,n=H(),a;t[0]!==n?(a=n("The assistant wants to read rows before answering. Nothing runs until you allow it."),t[0]=n,t[1]=a):a=t[1];let l;t[2]!==a?(l=(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground",children:a}),t[2]=a,t[3]=l):l=t[3];let s;t[4]!==e.sql?(s=(0,d.jsx)("pre",{className:"overflow-x-auto rounded bg-background p-1.5 font-mono text-[11px]","data-testid":"assistant-approval-sql",children:e.sql}),t[4]=e.sql,t[5]=s):s=t[5];let o;t[6]!==e||t[7]!==r?(o=u(()=>{r(!0,e)},"o"),t[6]=e,t[7]=r,t[8]=o):o=t[8];let i;t[9]!==n?(i=n("Allow"),t[9]=n,t[10]=i):i=t[10];let c;t[11]!==o||t[12]!==i?(c=(0,d.jsx)(R,{"data-testid":"assistant-approval-allow",onClick:o,size:"xs",type:"button",children:i}),t[11]=o,t[12]=i,t[13]=c):c=t[13];let p;t[14]!==e||t[15]!==r?(p=u(()=>{r(!1,e)},"f"),t[14]=e,t[15]=r,t[16]=p):p=t[16];let x;t[17]!==n?(x=n("Deny"),t[17]=n,t[18]=x):x=t[18];let m;t[19]!==p||t[20]!==x?(m=(0,d.jsx)(R,{"data-testid":"assistant-approval-deny",onClick:p,size:"xs",type:"button",variant:"secondary",children:x}),t[19]=p,t[20]=x,t[21]=m):m=t[21];let f;t[22]!==c||t[23]!==m?(f=(0,d.jsxs)("div",{className:"flex gap-2",children:[c,m]}),t[22]=c,t[23]=m,t[24]=f):f=t[24];let g;return t[25]!==f||t[26]!==l||t[27]!==s?(g=(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-muted/40 p-2","data-testid":"assistant-approval",children:[l,s,f]}),t[25]=f,t[26]=l,t[27]=s,t[28]=g):g=t[28],g},"ut"),xt=u(h=>{let t=(0,B.c)(15),{level:e,turn:r}=h,n=H(),a;t[0]!==r.toolCalls?(a=r.toolCalls??[],t[0]=r.toolCalls,t[1]=a):a=t[1];let l=a;if(l.length===0&&r.partial!==!0)return null;let s;if(t[2]!==l||t[3]!==e||t[4]!==n){let c;t[6]!==e||t[7]!==n?(c=u((p,x)=>(0,d.jsxs)("li",{children:[(0,d.jsx)("span",{className:"font-mono",children:p.name??n("(no such tool)")}),p.sql===void 0?null:(0,d.jsx)("span",{className:"ms-1 font-mono opacity-80",children:p.sql}),p.refused===void 0?null:(0,d.jsx)("span",{className:"ms-1 text-destructive",children:n("refused")}),p.needs===void 0?null:(0,d.jsx)("span",{className:"block text-muted-foreground","data-testid":"assistant-tool-needs",children:n("Needs the {needs} data-sharing level; this deployment is set to {level}. Change LUNORA_AI_OPT_IN in wrangler.jsonc.",{level:e??n("a lower level"),needs:p.needs})})]},`${String(x)}:${p.name??"?"}`),"d"),t[6]=e,t[7]=n,t[8]=c):c=t[8],s=l.map(c),t[2]=l,t[3]=e,t[4]=n,t[5]=s}else s=t[5];let o;t[9]!==n||t[10]!==r.partial?(o=r.partial===!0&&(0,d.jsx)("li",{"data-testid":"assistant-turn-partial",children:n("Stopped early \u2014 this answer is incomplete.")}),t[9]=n,t[10]=r.partial,t[11]=o):o=t[11];let i;return t[12]!==s||t[13]!==o?(i=(0,d.jsxs)("ul",{className:"flex flex-col gap-0.5 border-s border-border ps-2 text-[11px] text-muted-foreground","data-testid":"assistant-tool-calls",children:[s,o]}),t[12]=s,t[13]=o,t[14]=i):i=t[14],i},"pt"),ht=u(h=>{let t=(0,B.c)(60),{index:e,level:r,onBranch:n,onDecide:a,onInsert:l,onTruncate:s,turn:o}=h,i=H(),c,p,x,m,f;if(t[0]!==l||t[1]!==i||t[2]!==o.role||t[3]!==o.text){let $=o.role==="assistant"&&l!==void 0?pt(o.text):[];c=_,t[9]!==i||t[10]!==o.role?(p=o.role==="user"?i("You"):i("Assistant"),t[9]=i,t[10]=o.role,t[11]=p):p=t[11],x=`assistant-turn-${o.role}`,t[12]!==o.role||t[13]!==o.text?(m=o.role==="assistant"?(0,d.jsx)(Z,{text:o.text}):(0,d.jsx)("p",{className:"text-xs whitespace-pre-wrap","data-testid":"assistant-turn-body",children:o.text}),t[12]=o.role,t[13]=o.text,t[14]=m):m=t[14];let F;t[15]!==l||t[16]!==i?(F=u((T,j)=>(0,d.jsx)(R,{className:"self-start","data-testid":"assistant-insert",onClick:u(()=>{l?.(T)},"onClick"),size:"xs",type:"button",variant:"secondary",children:i("Insert into editor")},`${String(j)}:${T.slice(0,32)}`),"R"),t[15]=l,t[16]=i,t[17]=F):F=t[17],f=$.map(F),t[0]=l,t[1]=i,t[2]=o.role,t[3]=o.text,t[4]=c,t[5]=p,t[6]=x,t[7]=m,t[8]=f}else c=t[4],p=t[5],x=t[6],m=t[7],f=t[8];let g;t[18]!==a||t[19]!==o.pendingApproval?(g=o.pendingApproval!==void 0&&a!==void 0&&(0,d.jsx)(mt,{approval:o.pendingApproval,onDecide:a}),t[18]=a,t[19]=o.pendingApproval,t[20]=g):g=t[20];let v;t[21]!==r||t[22]!==o?(v=o.role==="assistant"&&(0,d.jsx)(xt,{level:r,turn:o}),t[21]=r,t[22]=o,t[23]=v):v=t[23];let S;t[24]!==o.text?(S=u(()=>{G(o.text)},"q"),t[24]=o.text,t[25]=S):S=t[25];let q;t[26]!==i?(q=i("Copy"),t[26]=i,t[27]=q):q=t[27];let k;t[28]!==S||t[29]!==q?(k=(0,d.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"assistant-copy",onClick:S,type:"button",children:q}),t[28]=S,t[29]=q,t[30]=k):k=t[30];let y;t[31]!==e||t[32]!==n?(y=u(()=>{n(e)},"y"),t[31]=e,t[32]=n,t[33]=y):y=t[33];let b;t[34]!==i?(b=i("Branch from here"),t[34]=i,t[35]=b):b=t[35];let w;t[36]!==y||t[37]!==b?(w=(0,d.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"assistant-branch",onClick:y,type:"button",children:b}),t[36]=y,t[37]=b,t[38]=w):w=t[38];let N;t[39]!==e||t[40]!==s?(N=u(()=>{s(e)},"k"),t[39]=e,t[40]=s,t[41]=N):N=t[41];let I;t[42]!==i?(I=i("Delete from here"),t[42]=i,t[43]=I):I=t[43];let A;t[44]!==N||t[45]!==I?(A=(0,d.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"assistant-truncate",onClick:N,type:"button",children:I}),t[44]=N,t[45]=I,t[46]=A):A=t[46];let C;t[47]!==w||t[48]!==A||t[49]!==k?(C=(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[k,w,A]}),t[47]=w,t[48]=A,t[49]=k,t[50]=C):C=t[50];let P;return t[51]!==c||t[52]!==p||t[53]!==C||t[54]!==x||t[55]!==m||t[56]!==f||t[57]!==g||t[58]!==v?(P=(0,d.jsxs)(c,{label:p,testId:x,children:[m,f,g,v,C]}),t[51]=c,t[52]=p,t[53]=C,t[54]=x,t[55]=m,t[56]=f,t[57]=g,t[58]=v,t[59]=P):P=t[59],P},"ht"),ft=u(({assistant:h,ops:t,session:e})=>{let[r,n]=(0,z.useState)(""),[a,l]=(0,z.useState)(e?.id);e?.id!==a&&(l(e?.id),n(""));let[s,o]=(0,z.useState)(void 0),[i,c]=(0,z.useState)(void 0),[p,x]=(0,z.useState)(void 0),[m,f]=(0,z.useState)(void 0),g=(0,z.useRef)(void 0);(0,z.useEffect)(()=>()=>{g.current?.abort()},[]);let v=t.pending("chat"),S=t.reason("chat"),{setTurns:q,takeAsk:k,unavailable:y}=h,b=e?.id,w=S==="ai-disabled"||S==="no-ai-binding"||p===b?S:void 0,N=u(T=>{b!==void 0&&h.branchFrom(b,T)},"k"),I=u(T=>{b!==void 0&&h.truncateFrom(b,T)},"A"),A=u((T,j,K)=>{if(T===""||v||g.current!==void 0||e===void 0)return;let E=new AbortController;g.current=E;let W={role:"user",text:T},tt=[...j,W];q(e.id,tt),o({sessionId:e.id,text:""}),x(e.id),Y(t.chat(T,j.map(D=>({role:D.role,text:D.text})),e.schema,K,D=>{o(M=>M?.sessionId===e.id?{sessionId:e.id,text:D.type==="delta"?`${M.text}${D.text}`:""}:M)},E.signal).then(D=>{if(D!==void 0&&!E.signal.aborted){c(D.truncated?e.id:void 0);let M={partial:D.partial,...D.pendingApproval===void 0?{}:{pendingApproval:D.pendingApproval},role:"assistant",text:D.reply,toolCalls:D.toolCalls};q(e.id,U=>U.at(-1)===W?[...U,M]:U)}return D}).finally(()=>{g.current=void 0,o(void 0)}))},"I"),C=u(T=>{let j=(T??r).trim();j===""||v||g.current!==void 0||e===void 0||(n(""),A(j,e.turns))},"C"),P=u((T,j)=>{if(e===void 0||v||g.current!==void 0)return;let K=e.turns.slice(0,-1),E=K.at(-1);E?.role==="user"&&A(E.text,K.slice(0,-1),{allow:T,sql:j.sql,ticket:j.ticket})},"F"),$=h.draft;$!==void 0&&$.id!==m&&(f($.id),n($.text));let F=h.pendingAsk;return(0,z.useEffect)(()=>{F===void 0||F.sessionId!==b||v||y||(k(F.id),queueMicrotask(()=>{C(F.text)}))},[F,b,k,v,y]),{branchHere:N,decide:P,draft:r,live:s,pending:v,reason:w,send:C,setDraft:n,truncatedFor:i,truncateHere:I}},"mt"),Zt=u(h=>{let t=(0,B.c)(39),{assistant:e}=h,r=H(),n;t[0]!==e.activeId?(n=u(C=>C.id===e.activeId,"l"),t[0]=e.activeId,t[1]=n):n=t[1];let a=e.sessions.find(n),l=Q(a?.shardKey??""),s=ft({assistant:e,ops:l,session:a});if(l.unavailable||a===void 0)return null;let{turns:o}=a,i;t[2]!==r?(i=r("Assistant"),t[2]=r,t[3]=i):i=t[3];let c="flex h-full w-96 min-w-0 shrink-0 flex-col border-s border-border bg-card",p="assistant-panel",x;t[4]!==e.close?(x=(0,d.jsx)(lt,{onClose:e.close}),t[4]=e.close,t[5]=x):x=t[5];let m;t[6]!==e||t[7]!==r?(m=u(()=>{e.newChat({title:r("New chat")})},"u"),t[6]=e,t[7]=r,t[8]=m):m=t[8];let f;t[9]!==e.activeId||t[10]!==e.deleteChat||t[11]!==e.selectChat||t[12]!==e.sessions||t[13]!==m?(f=(0,d.jsx)(it,{activeId:e.activeId,onDelete:e.deleteChat,onNew:m,onSelect:e.selectChat,sessions:e.sessions}),t[9]=e.activeId,t[10]=e.deleteChat,t[11]=e.selectChat,t[12]=e.sessions,t[13]=m,t[14]=f):f=t[14];let g=o.length===0&&a.suggestions.length>0&&(0,d.jsx)(ct,{onPick:u(C=>{s.send(C)},"onPick"),suggestions:a.suggestions}),v="min-h-0 flex-1 overflow-y-auto",S="assistant-turns",q=o.map((C,P)=>(0,d.jsx)(ht,{index:P,level:l.level,onBranch:s.branchHere,onDecide:P===o.length-1?s.decide:void 0,onInsert:e.hasEditor?e.requestInsert:void 0,onTruncate:s.truncateHere,turn:C},`${String(P)}:${C.role}`)),k;t[15]!==s.live||t[16]!==a.id?(k=s.live?.sessionId===a.id&&s.live.text!==""&&(0,d.jsx)(rt,{text:s.live.text}),t[15]=s.live,t[16]=a.id,t[17]=k):k=t[17];let y;t[18]!==q||t[19]!==k?(y=(0,d.jsxs)("ul",{className:v,"data-testid":S,children:[q,k]}),t[18]=q,t[19]=k,t[20]=y):y=t[20];let b=s.truncatedFor===a.id,w;t[21]!==s.reason||t[22]!==b?(w=(0,d.jsx)(dt,{reason:s.reason,truncated:b}),t[21]=s.reason,t[22]=b,t[23]=w):w=t[23];let N;t[24]!==s?(N=u(()=>{s.send()},"k"),t[24]=s,t[25]=N):N=t[25];let I;t[26]!==s.draft||t[27]!==s.pending||t[28]!==s.setDraft||t[29]!==N?(I=(0,d.jsx)(nt,{draft:s.draft,onDraftChange:s.setDraft,onSend:N,pending:s.pending}),t[26]=s.draft,t[27]=s.pending,t[28]=s.setDraft,t[29]=N,t[30]=I):I=t[30];let A;return t[31]!==y||t[32]!==w||t[33]!==I||t[34]!==i||t[35]!==x||t[36]!==f||t[37]!==g?(A=(0,d.jsxs)("section",{"aria-label":i,className:c,"data-testid":p,children:[x,f,g,y,w,I]}),t[31]=y,t[32]=w,t[33]=I,t[34]=i,t[35]=x,t[36]=f,t[37]=g,t[38]=A):A=t[38],A},"It");export{Zt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y,b as D}from"./chunk-JNWK5MJC.js";import{a as _,b as z,c as j,d as E,e as B,f as H,g as L,h as V,i as O,j as T,k as Z,l as q}from"./chunk-D63EYK5I.js";import{i as I}from"./chunk-Z6PYAG36.js";import{a as k}from"./chunk-QHI77TGI.js";import{b as w}from"./chunk-OOPMRFI2.js";import{B as $,s as P,x as N}from"./chunk-CDIV23I2.js";import{a as se}from"./chunk-A6TVTNKO.js";import{a as le,b as de}from"./chunk-ADABTCDI.js";import{a as u,d as S}from"./chunk-5PEAXTYQ.js";var v=S(se(),1);var b=S(le(),1);var s=S(de(),1);function ie(a){let e=(0,v.c)(10),t,n,r;e[0]!==a?({className:t,selected:r,...n}=a,e[0]=a,e[1]=t,e[2]=n,e[3]=r):(t=e[1],n=e[2],r=e[3]);let l=r===!0?"":void 0,o;e[4]!==t?(o=N("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==o?(d=(0,s.jsx)("div",{"data-slot":"base-node","data-selected":l,className:o,...n}),e[6]=n,e[7]=l,e[8]=o,e[9]=d):d=e[9],d}u(ie,"ie");function ce(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-header",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(ce,"ce");function me(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-content",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(me,"de");var ue=3,fe=u((a,e,t)=>{let n=e?a:a.slice(0,ue),r=n.map(o=>JSON.stringify(o)).join(" | "),l=a.length-n.length;return l>0?`${r} ${t("+{count} more",{count:l})}`:r},"fe"),J=u((a,e,t)=>{let n=a.enumValues??[],r=n.length===0?a.type:fe(n,e,t),l=a.ref===void 0?r:`${r} \u2192 ${a.ref}`;return a.optional===!0?`${l}?`:l},"H"),pe=u(a=>{let e=(0,v.c)(23),{data:t,selected:n}=a,r=$(),l;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(l=t.loadError===!0?(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"\u2014"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=l):l=e[3];let o=l,d=`sd-node-${t.label}`,c;e[4]!==t.label?(c=(0,s.jsx)("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=c):c=e[5];let m;e[6]!==t.tier?(m=(0,s.jsx)("span",{className:"ms-auto",children:(0,s.jsx)(D,{tier:t.tier})}),e[6]=t.tier,e[7]=m):m=e[7];let i;e[8]!==c||e[9]!==m?(i=(0,s.jsxs)(ce,{children:[c,m]}),e[8]=c,e[9]=m,e[10]=i):i=e[10];let f;e[11]!==t.columns||e[12]!==t.label||e[13]!==o||e[14]!==r?(f=t.columns.length===0?o:t.columns.map(h=>(0,s.jsxs)("div",{className:N("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",h.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${h.name}`,children:[(0,s.jsx)(E,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Left,type:"target"}),(0,s.jsx)("span",{className:"truncate font-mono",title:h.name,children:h.name}),h.pk===!0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),h.ref!==void 0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),(0,s.jsx)("span",{className:"ms-auto truncate text-muted-foreground",title:J(h,!0,r),children:J(h,!1,r)}),(0,s.jsx)(E,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Right,type:"source"})]},h.name)),e[11]=t.columns,e[12]=t.label,e[13]=o,e[14]=r,e[15]=f):f=e[15];let p;e[16]!==f?(p=(0,s.jsx)(me,{children:f}),e[16]=f,e[17]=p):p=e[17];let x;return e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==p?(x=(0,s.jsxs)(ie,{className:"w-64 overflow-hidden","data-testid":d,selected:n,children:[i,p]}),e[18]=n,e[19]=d,e[20]=i,e[21]=p,e[22]=x):x=e[22],x},"ue"),G=256,Q=112,W=36,M=24,he=480,be=1.4,ge=u(a=>{let e=Math.max(1,Math.round(Math.sqrt(be*a/(G+Q))));return Math.max(he,a/e)},"ge"),xe=38,Ne=28,A=u(a=>xe+Math.max(1,a)*Ne,"B"),ye=u((a,e)=>{let t=new Map;for(let o of a)t.set(o,[]);for(let o of e)o.to!==o.from&&t.has(o.from)&&t.has(o.to)&&t.get(o.from)?.push(o.to);let n=new Map,r=new Set,l=u(o=>{let d=n.get(o);if(d!==void 0)return d;if(r.has(o))return 0;r.add(o);let c=0;for(let m of t.get(o)??[])c=Math.max(c,l(m)+1);return r.delete(o),n.set(o,c),c},"r");for(let o of a)l(o);return n},"Ne"),ve=u((a,e,t)=>{let n=ye(a,e),r=new Map;for(let m of a){let i=n.get(m)??0,f=r.get(i);f===void 0?r.set(i,[m]):f.push(m)}let l=a.reduce((m,i)=>m+A(t.get(i)??0)+W,0),o=ge(l),d=[],c=0;for(let m of[...r.keys()].toSorted((i,f)=>i-f)){let i=0,f=M;for(let p of r.get(m)??[]){let x=A(t.get(p)??0);f>M&&f+x>o&&(i+=1,f=M),d.push({name:p,x:M+(c+i)*(G+Q),y:f}),f+=x+W}c+=i+1}return d},"ye"),we={databaseSchema:pe},U={backgroundColor:y.shard.color},X={backgroundColor:y.global.color},$e={global:!0,shard:!0},Me={},Ce=u(a=>{let e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},"_e"),Y=u(a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),"K"),Se=u((a,e,t)=>{let n=a.map(d=>d.name),r=new Map(a.map(d=>[d.name,d.columns.length])),l=ve(n,Y(a),r),o=new Map(a.map(d=>[d.name,d]));return l.flatMap(({name:d,x:c,y:m})=>{let i=o.get(d);return i===void 0?[]:[{className:t[d],data:{columns:i.columns,label:d,loadError:e,tier:i.tier},id:d,position:{x:c,y:m},type:"databaseSchema"}]})},"we"),ke=u(a=>{let e=new Map(a.map(t=>[t.name,t.columns]));return Y(a).flatMap(t=>{let n=e.get(t.to)??[],r=e.get(t.from)??[],l=Ce(n);return!n.some(o=>o.name===l)||!r.some(o=>o.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:l,target:t.from,targetHandle:t.column}]})},"Me"),_e=u(()=>{let a=(0,v.c)(15),e=$(),t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),a[0]=t):t=a[0];let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]}),a[1]=n):n=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let l;a[3]!==e?(l=e("Primary key"),a[3]=e,a[4]=l):l=a[4];let o;a[5]!==l?(o=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[r,l]}),a[5]=l,a[6]=o):o=a[6];let d;a[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=d):d=a[7];let c;a[8]!==e?(c=e("Foreign key"),a[8]=e,a[9]=c):c=a[9];let m;a[10]!==c?(m=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[d,c]}),a[10]=c,a[11]=m):m=a[11];let i;return a[12]!==o||a[13]!==m?(i=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,n,o,m]}),a[12]=o,a[13]=m,a[14]=i):i=a[14],i},"Ce"),ze=12,Ee=u(a=>{let e=(0,v.c)(9),{containerRef:t,seedKey:n}=a,r=V(),{fitView:l}=j(),o;e[0]!==t||e[1]!==l||e[2]!==r?(o=u(()=>{if(!r)return;let c=u(()=>{P(l({duration:0,maxZoom:1.6,padding:.14}))},"d");c();let m=t.current;if(m===null)return;let i=new ResizeObserver(()=>{c()});return i.observe(m),()=>{i.disconnect()}},"a"),e[0]=t,e[1]=l,e[2]=r,e[3]=o):o=e[3];let d;return e[4]!==t||e[5]!==l||e[6]!==r||e[7]!==n?(d=[t,l,r,n],e[4]=t,e[5]=l,e[6]=r,e[7]=n,e[8]=d):d=e[8],(0,b.useEffect)(o,d),null},"Te"),Ve=u(({columnsError:a,fill:e=!1,nodeClasses:t,tables:n,testIdPrefix:r})=>{let l=$(),[o,d]=(0,b.useState)($e),[c,m]=(0,b.useState)(""),i=(0,b.useMemo)(()=>{let g=c.trim().toLowerCase();return n.filter(K=>o[K.tier]&&K.name.toLowerCase().includes(g))},[n,o,c]),f=(0,b.useMemo)(()=>Se(i,a??!1,t??Me),[i,a,t]),p=(0,b.useMemo)(()=>ke(i),[i]),x=i.map(g=>g.name).join(","),[h,R,ee]=H(f),[te,F,ae]=L(p),C=(0,b.useRef)(null);(0,b.useEffect)(()=>{R(f)},[f,R]),(0,b.useEffect)(()=>{F(p)},[p,F]);let re=u(g=>{m(g.target.value)},"V"),oe=u(()=>{d(g=>({...g,shard:!g.shard}))},"W"),ne=u(()=>{d(g=>({...g,global:!g.global}))},"Y");return n.length===0?(0,s.jsx)("section",{className:"flex flex-col gap-2","data-testid":`${r}-section`,children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":`${r}-empty`,children:l("No tables to graph.")})}):(0,s.jsx)("section",{className:N("flex flex-col",e&&"min-h-0 flex-1"),"data-testid":`${r}-section`,children:(0,s.jsx)("div",{className:N("w-full overflow-hidden border border-border bg-muted/20",e?"min-h-0 flex-1":"h-[560px]"),"data-testid":`${r}-canvas`,ref:C,children:(0,s.jsxs)(B,{edges:te,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:h,nodesConnectable:!1,nodeTypes:we,onEdgesChange:ae,onNodesChange:ee,children:[(0,s.jsx)(O,{}),(0,s.jsx)(z,{position:"top-left",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[(0,s.jsx)(I,{"aria-label":l("Find table\u2026"),className:"h-7 w-44 text-xs","data-testid":`${r}-find`,onChange:re,placeholder:l("Find table\u2026"),value:c}),(0,s.jsxs)("div",{"aria-label":l("Storage tiers"),className:"flex items-center gap-1.5",role:"group",children:[(0,s.jsxs)(k,{"aria-pressed":o.shard,className:"gap-1.5","data-testid":`${r}-tier-shard`,onClick:oe,size:"xs",type:"button",variant:o.shard?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),(0,s.jsxs)(k,{"aria-pressed":o.global,className:"gap-1.5","data-testid":`${r}-tier-global`,onClick:ne,size:"xs",type:"button",variant:o.global?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]})]})]})}),(0,s.jsx)(z,{position:"bottom-center",children:(0,s.jsx)(_e,{})}),(0,s.jsx)(T,{showInteractive:!1}),i.length>ze&&(0,s.jsx)(Z,{className:"!border !border-border !bg-card",maskColor:"var(--color-muted)",nodeColor:"var(--color-muted-foreground)",nodeStrokeWidth:0,pannable:!0,zoomable:!0}),(0,s.jsx)(q,{containerRef:C,filenameBase:`${r}-schema-diagram`,testIdPrefix:r}),(0,s.jsx)(Ee,{containerRef:C,seedKey:x})]})})})},"Ke");export{Ve as a};
|
|
1
|
+
import{a as y,b as D}from"./chunk-JNWK5MJC.js";import{a as _,b as z,c as j,d as E,e as B,f as H,g as L,h as V,i as O,j as T,k as Z,l as q}from"./chunk-J2SIGUHW.js";import{j as I}from"./chunk-SQO3WGXH.js";import{a as k}from"./chunk-ECXQQPVU.js";import{b as w}from"./chunk-UB6S6VYI.js";import{B as $,s as P,x as N}from"./chunk-G4H5DPO6.js";import{a as se}from"./chunk-A6TVTNKO.js";import{a as le,b as de}from"./chunk-ADABTCDI.js";import{a as u,d as S}from"./chunk-5PEAXTYQ.js";var v=S(se(),1);var b=S(le(),1);var s=S(de(),1);function ie(a){let e=(0,v.c)(10),t,n,r;e[0]!==a?({className:t,selected:r,...n}=a,e[0]=a,e[1]=t,e[2]=n,e[3]=r):(t=e[1],n=e[2],r=e[3]);let l=r===!0?"":void 0,o;e[4]!==t?(o=N("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==o?(d=(0,s.jsx)("div",{"data-slot":"base-node","data-selected":l,className:o,...n}),e[6]=n,e[7]=l,e[8]=o,e[9]=d):d=e[9],d}u(ie,"ie");function ce(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-header",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(ce,"ce");function me(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-content",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(me,"de");var ue=3,fe=u((a,e,t)=>{let n=e?a:a.slice(0,ue),r=n.map(o=>JSON.stringify(o)).join(" | "),l=a.length-n.length;return l>0?`${r} ${t("+{count} more",{count:l})}`:r},"fe"),J=u((a,e,t)=>{let n=a.enumValues??[],r=n.length===0?a.type:fe(n,e,t),l=a.ref===void 0?r:`${r} \u2192 ${a.ref}`;return a.optional===!0?`${l}?`:l},"H"),pe=u(a=>{let e=(0,v.c)(23),{data:t,selected:n}=a,r=$(),l;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(l=t.loadError===!0?(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"\u2014"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=l):l=e[3];let o=l,d=`sd-node-${t.label}`,c;e[4]!==t.label?(c=(0,s.jsx)("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=c):c=e[5];let m;e[6]!==t.tier?(m=(0,s.jsx)("span",{className:"ms-auto",children:(0,s.jsx)(D,{tier:t.tier})}),e[6]=t.tier,e[7]=m):m=e[7];let i;e[8]!==c||e[9]!==m?(i=(0,s.jsxs)(ce,{children:[c,m]}),e[8]=c,e[9]=m,e[10]=i):i=e[10];let f;e[11]!==t.columns||e[12]!==t.label||e[13]!==o||e[14]!==r?(f=t.columns.length===0?o:t.columns.map(h=>(0,s.jsxs)("div",{className:N("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",h.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${h.name}`,children:[(0,s.jsx)(E,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Left,type:"target"}),(0,s.jsx)("span",{className:"truncate font-mono",title:h.name,children:h.name}),h.pk===!0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),h.ref!==void 0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),(0,s.jsx)("span",{className:"ms-auto truncate text-muted-foreground",title:J(h,!0,r),children:J(h,!1,r)}),(0,s.jsx)(E,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Right,type:"source"})]},h.name)),e[11]=t.columns,e[12]=t.label,e[13]=o,e[14]=r,e[15]=f):f=e[15];let p;e[16]!==f?(p=(0,s.jsx)(me,{children:f}),e[16]=f,e[17]=p):p=e[17];let x;return e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==p?(x=(0,s.jsxs)(ie,{className:"w-64 overflow-hidden","data-testid":d,selected:n,children:[i,p]}),e[18]=n,e[19]=d,e[20]=i,e[21]=p,e[22]=x):x=e[22],x},"ue"),G=256,Q=112,W=36,M=24,he=480,be=1.4,ge=u(a=>{let e=Math.max(1,Math.round(Math.sqrt(be*a/(G+Q))));return Math.max(he,a/e)},"ge"),xe=38,Ne=28,A=u(a=>xe+Math.max(1,a)*Ne,"B"),ye=u((a,e)=>{let t=new Map;for(let o of a)t.set(o,[]);for(let o of e)o.to!==o.from&&t.has(o.from)&&t.has(o.to)&&t.get(o.from)?.push(o.to);let n=new Map,r=new Set,l=u(o=>{let d=n.get(o);if(d!==void 0)return d;if(r.has(o))return 0;r.add(o);let c=0;for(let m of t.get(o)??[])c=Math.max(c,l(m)+1);return r.delete(o),n.set(o,c),c},"r");for(let o of a)l(o);return n},"Ne"),ve=u((a,e,t)=>{let n=ye(a,e),r=new Map;for(let m of a){let i=n.get(m)??0,f=r.get(i);f===void 0?r.set(i,[m]):f.push(m)}let l=a.reduce((m,i)=>m+A(t.get(i)??0)+W,0),o=ge(l),d=[],c=0;for(let m of[...r.keys()].toSorted((i,f)=>i-f)){let i=0,f=M;for(let p of r.get(m)??[]){let x=A(t.get(p)??0);f>M&&f+x>o&&(i+=1,f=M),d.push({name:p,x:M+(c+i)*(G+Q),y:f}),f+=x+W}c+=i+1}return d},"ye"),we={databaseSchema:pe},U={backgroundColor:y.shard.color},X={backgroundColor:y.global.color},$e={global:!0,shard:!0},Me={},Ce=u(a=>{let e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},"_e"),Y=u(a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),"K"),Se=u((a,e,t)=>{let n=a.map(d=>d.name),r=new Map(a.map(d=>[d.name,d.columns.length])),l=ve(n,Y(a),r),o=new Map(a.map(d=>[d.name,d]));return l.flatMap(({name:d,x:c,y:m})=>{let i=o.get(d);return i===void 0?[]:[{className:t[d],data:{columns:i.columns,label:d,loadError:e,tier:i.tier},id:d,position:{x:c,y:m},type:"databaseSchema"}]})},"we"),ke=u(a=>{let e=new Map(a.map(t=>[t.name,t.columns]));return Y(a).flatMap(t=>{let n=e.get(t.to)??[],r=e.get(t.from)??[],l=Ce(n);return!n.some(o=>o.name===l)||!r.some(o=>o.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:l,target:t.from,targetHandle:t.column}]})},"Me"),_e=u(()=>{let a=(0,v.c)(15),e=$(),t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),a[0]=t):t=a[0];let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]}),a[1]=n):n=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let l;a[3]!==e?(l=e("Primary key"),a[3]=e,a[4]=l):l=a[4];let o;a[5]!==l?(o=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[r,l]}),a[5]=l,a[6]=o):o=a[6];let d;a[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=d):d=a[7];let c;a[8]!==e?(c=e("Foreign key"),a[8]=e,a[9]=c):c=a[9];let m;a[10]!==c?(m=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[d,c]}),a[10]=c,a[11]=m):m=a[11];let i;return a[12]!==o||a[13]!==m?(i=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,n,o,m]}),a[12]=o,a[13]=m,a[14]=i):i=a[14],i},"Ce"),ze=12,Ee=u(a=>{let e=(0,v.c)(9),{containerRef:t,seedKey:n}=a,r=V(),{fitView:l}=j(),o;e[0]!==t||e[1]!==l||e[2]!==r?(o=u(()=>{if(!r)return;let c=u(()=>{P(l({duration:0,maxZoom:1.6,padding:"14%"}))},"d");c();let m=t.current;if(m===null)return;let i=new ResizeObserver(()=>{c()});return i.observe(m),()=>{i.disconnect()}},"a"),e[0]=t,e[1]=l,e[2]=r,e[3]=o):o=e[3];let d;return e[4]!==t||e[5]!==l||e[6]!==r||e[7]!==n?(d=[t,l,r,n],e[4]=t,e[5]=l,e[6]=r,e[7]=n,e[8]=d):d=e[8],(0,b.useEffect)(o,d),null},"Te"),Ve=u(({columnsError:a,fill:e=!1,nodeClasses:t,tables:n,testIdPrefix:r})=>{let l=$(),[o,d]=(0,b.useState)($e),[c,m]=(0,b.useState)(""),i=(0,b.useMemo)(()=>{let g=c.trim().toLowerCase();return n.filter(K=>o[K.tier]&&K.name.toLowerCase().includes(g))},[n,o,c]),f=(0,b.useMemo)(()=>Se(i,a??!1,t??Me),[i,a,t]),p=(0,b.useMemo)(()=>ke(i),[i]),x=i.map(g=>g.name).join(","),[h,R,ee]=H(f),[te,F,ae]=L(p),C=(0,b.useRef)(null);(0,b.useEffect)(()=>{R(f)},[f,R]),(0,b.useEffect)(()=>{F(p)},[p,F]);let re=u(g=>{m(g.target.value)},"V"),oe=u(()=>{d(g=>({...g,shard:!g.shard}))},"W"),ne=u(()=>{d(g=>({...g,global:!g.global}))},"Y");return n.length===0?(0,s.jsx)("section",{className:"flex flex-col gap-2","data-testid":`${r}-section`,children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":`${r}-empty`,children:l("No tables to graph.")})}):(0,s.jsx)("section",{className:N("flex flex-col",e&&"min-h-0 flex-1"),"data-testid":`${r}-section`,children:(0,s.jsx)("div",{className:N("w-full overflow-hidden border border-border bg-muted/20",e?"min-h-0 flex-1":"h-[560px]"),"data-testid":`${r}-canvas`,ref:C,children:(0,s.jsxs)(B,{edges:te,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:h,nodesConnectable:!1,nodeTypes:we,onEdgesChange:ae,onNodesChange:ee,children:[(0,s.jsx)(O,{}),(0,s.jsx)(z,{position:"top-left",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[(0,s.jsx)(I,{"aria-label":l("Find table\u2026"),className:"h-7 w-44 text-xs","data-testid":`${r}-find`,onChange:re,placeholder:l("Find table\u2026"),value:c}),(0,s.jsxs)("div",{"aria-label":l("Storage tiers"),className:"flex items-center gap-1.5",role:"group",children:[(0,s.jsxs)(k,{"aria-pressed":o.shard,className:"gap-1.5","data-testid":`${r}-tier-shard`,onClick:oe,size:"xs",type:"button",variant:o.shard?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),(0,s.jsxs)(k,{"aria-pressed":o.global,className:"gap-1.5","data-testid":`${r}-tier-global`,onClick:ne,size:"xs",type:"button",variant:o.global?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]})]})]})}),(0,s.jsx)(z,{position:"bottom-center",children:(0,s.jsx)(_e,{})}),(0,s.jsx)(T,{showInteractive:!1}),i.length>ze&&(0,s.jsx)(Z,{className:"!border !border-border !bg-card",maskColor:"var(--color-muted)",nodeColor:"var(--color-muted-foreground)",nodeStrokeWidth:0,pannable:!0,zoomable:!0}),(0,s.jsx)(q,{containerRef:C,filenameBase:`${r}-schema-diagram`,testIdPrefix:r}),(0,s.jsx)(Ee,{containerRef:C,seedKey:x})]})})})},"Ke");export{Ve as a};
|