@lunora/studio 1.0.0-alpha.4 → 1.0.0-alpha.40
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/LICENSE.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.ts +33 -18
- package/dist/index.js +29 -29
- package/dist/mount.d.ts +1 -1
- package/dist/mount.js +3 -2
- package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
- package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +29 -41
- package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +16 -11
- package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +15 -15
- package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +10 -10
- package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +153 -208
- package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
- package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +108 -69
- package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +46 -58
- package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +45 -139
- package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
- package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +44 -51
- package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
- package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +17 -16
- package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +47 -31
- package/dist/packem_chunks/SettingsPanel.js +391 -0
- package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +158 -387
- package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +10 -68
- package/dist/packem_chunks/analytics-panel.js +261 -0
- package/dist/packem_chunks/auth-config-panel.js +365 -0
- package/dist/packem_chunks/auth-sessions-panel.js +175 -0
- package/dist/packem_chunks/containers-panel.js +247 -0
- package/dist/packem_chunks/dashboards-panel.js +780 -0
- package/dist/packem_chunks/fanout-panel.js +482 -0
- package/dist/packem_chunks/flags-panel.js +176 -0
- package/dist/packem_chunks/kv-browser.js +1896 -0
- package/dist/packem_chunks/log-drains-panel.js +273 -0
- package/dist/packem_chunks/organizations-panel.js +3178 -0
- package/dist/packem_chunks/payments-panel.js +186 -0
- package/dist/packem_chunks/permissions-panel.js +805 -0
- package/dist/packem_chunks/queues-panel.js +1075 -0
- package/dist/packem_chunks/rls-panel.js +315 -0
- package/dist/packem_chunks/schedule-panel.js +831 -0
- package/dist/packem_chunks/sparkline.js +79 -0
- package/dist/packem_chunks/storage-rules-panel.js +140 -0
- package/dist/packem_chunks/subscriptions-panel.js +238 -0
- package/dist/packem_chunks/users-panel.js +1731 -0
- package/dist/packem_chunks/vector-browser.js +281 -0
- package/dist/packem_chunks/workflows-panel.js +562 -0
- package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-BHHJi3Gb.js} +7 -0
- package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-CBma-lnp.js} +2 -2
- package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-CQM3pPN7.js} +2 -1
- package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-X2tkbyHk.js} +1 -1
- package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-D2ywrdId.js} +198 -247
- package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-BkTPLzAY.js} +37 -66
- package/dist/packem_shared/HomePanel-D1Q9LZgK.js +14 -0
- package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-Dno-hfDb.js} +2 -1
- package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-Ctw4jYtU.js} +163 -60
- package/dist/packem_shared/Studio-lJhzDAze.js +16 -0
- package/dist/packem_shared/{StudioApp-CHOZA-z-.js → StudioApp-DiMkupvZ.js} +276 -11
- package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-BX8OhG0w.js} +6 -6
- package/dist/packem_shared/alert-CdAET2K_.js +68 -0
- package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-CNLRTrWw.d.ts} +1 -1
- package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-DSwcWIRy.js} +5 -4
- package/dist/packem_shared/browser-storage-BTrX4y3B.js +215 -0
- package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
- package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-CdXztApG.js} +1 -1
- package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
- package/dist/packem_shared/error-alert-CXjqyGw9.js +114 -0
- package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-BF-KBDFz.js} +131 -163
- package/dist/packem_shared/home-panel-TFcRf9Ui.js +1889 -0
- package/dist/packem_shared/{internal-rXJEAhXS.js → internal-CYcbqMjX.js} +44 -3
- package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
- package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-DUiJcILV.js} +6 -45
- package/dist/packem_shared/scroll-area-DLhcy-ml.js +93 -0
- package/dist/packem_shared/select-UkNYCT3s.js +273 -0
- package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
- package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-BnA1kC9X.js} +1 -1
- package/dist/packem_shared/studio-Dh9UlaF_.js +4015 -0
- package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
- package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-UVIXQJdU.js} +1 -1
- package/dist/packem_shared/use-admin-query-CfHYWx5n.js +106 -0
- package/dist/packem_shared/use-async-submit-DJQiPc-_.js +91 -0
- package/dist/standalone/chunk-23C4TCRO.js +1 -0
- package/dist/standalone/chunk-2K47A3P6.js +1 -0
- package/dist/standalone/chunk-2NGUNNGW.js +1 -0
- package/dist/standalone/chunk-3CJW6NWG.js +4 -0
- package/dist/standalone/chunk-3OA7PECS.js +6 -0
- package/dist/standalone/chunk-4QHKBC77.js +1 -0
- package/dist/standalone/chunk-5OIBXYZM.js +1 -0
- package/dist/standalone/chunk-5ZAA2PVR.js +1 -0
- package/dist/standalone/chunk-676HEBIR.js +3 -0
- package/dist/standalone/chunk-6VO23MMW.js +4 -0
- package/dist/standalone/chunk-7RE5UW27.js +8 -0
- package/dist/standalone/chunk-7TJJXVSE.js +1 -0
- package/dist/standalone/chunk-7YXOPTWI.js +1 -0
- package/dist/standalone/chunk-AAVIFQ4Y.js +2 -0
- package/dist/standalone/chunk-AHILM3ZP.js +1 -0
- package/dist/standalone/chunk-AJFQ3LNM.js +1 -0
- package/dist/standalone/chunk-AJULNB46.js +4 -0
- package/dist/standalone/chunk-BGXOXASQ.js +1 -0
- package/dist/standalone/chunk-BJGBHGK3.js +1 -0
- package/dist/standalone/chunk-BKW7FFEO.js +1 -0
- package/dist/standalone/chunk-BOXSWNXZ.js +1 -0
- package/dist/standalone/chunk-BXOYVWJR.js +13 -0
- package/dist/standalone/chunk-C7WTJLC3.js +1 -0
- package/dist/standalone/chunk-CACB34RQ.js +1 -0
- package/dist/standalone/chunk-CICVBMEN.js +1 -0
- package/dist/standalone/chunk-CKSHCYGC.js +2 -0
- package/dist/standalone/chunk-CWEAJUHW.js +1 -0
- package/dist/standalone/chunk-DC72CQY4.js +76 -0
- package/dist/standalone/chunk-DECHEGIC.js +1 -0
- package/dist/standalone/chunk-DWDILV2E.js +1 -0
- package/dist/standalone/chunk-E75ANNWX.js +19 -0
- package/dist/standalone/chunk-ERJNDIXC.js +1 -0
- package/dist/standalone/chunk-FKACHRWO.js +1 -0
- package/dist/standalone/chunk-FSGCANAU.js +1 -0
- package/dist/standalone/chunk-GLUNBZRI.js +1 -0
- package/dist/standalone/chunk-GMSGZDDH.js +13 -0
- package/dist/standalone/chunk-GTM65MVX.js +1 -0
- package/dist/standalone/chunk-H6RKXQZU.js +1 -0
- package/dist/standalone/chunk-HV7G6DFP.js +5 -0
- package/dist/standalone/chunk-HZTGDL4L.js +1 -0
- package/dist/standalone/chunk-I7ZZRM7I.js +1 -0
- package/dist/standalone/chunk-IXDH4GL5.js +1 -0
- package/dist/standalone/chunk-J46WXQYL.js +1 -0
- package/dist/standalone/chunk-J6J54MBP.js +1 -0
- package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
- package/dist/standalone/chunk-JVODY4EP.js +1 -0
- package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
- package/dist/standalone/chunk-KJJ3WM6H.js +4 -0
- package/dist/standalone/chunk-KSKXW5PX.js +1 -0
- package/dist/standalone/chunk-KZ6INM5M.js +1 -0
- package/dist/standalone/chunk-L7SK4ZZD.js +1 -0
- package/dist/standalone/chunk-LAK5VSPI.js +1 -0
- package/dist/standalone/chunk-LNZIB2MD.js +1 -0
- package/dist/standalone/chunk-LYB5L53X.js +1 -0
- package/dist/standalone/chunk-MJWVMKQ4.js +6 -0
- package/dist/standalone/chunk-MT2J3H7O.js +3 -0
- package/dist/standalone/chunk-N746FOQP.js +1 -0
- package/dist/standalone/chunk-NC6MBMSI.js +1 -0
- package/dist/standalone/chunk-NN27EDQB.js +1 -0
- package/dist/standalone/chunk-NY6GDADQ.js +1 -0
- package/dist/standalone/chunk-O3NAGRTR.js +1 -0
- package/dist/standalone/chunk-OY3HD7BJ.js +4 -0
- package/dist/standalone/chunk-P5HJXCZS.js +1 -0
- package/dist/standalone/chunk-PTS5TW3J.js +1 -0
- package/dist/standalone/chunk-Q52CHOSY.js +1 -0
- package/dist/standalone/chunk-QAFAJBAW.js +1 -0
- package/dist/standalone/chunk-QBAT52GB.js +1 -0
- package/dist/standalone/chunk-QDBOPDJ7.js +1 -0
- package/dist/standalone/chunk-QHFTGJPS.js +4 -0
- package/dist/standalone/chunk-RRCPZMC2.js +22 -0
- package/dist/standalone/chunk-SEU5V7I6.js +1 -0
- package/dist/standalone/chunk-SG3ALJJU.js +1 -0
- package/dist/standalone/chunk-SSI4G2MY.js +1 -0
- package/dist/standalone/chunk-TAD43CG5.js +1 -0
- package/dist/standalone/chunk-TBMYIZIO.js +1 -0
- package/dist/standalone/chunk-TH45YG6Q.js +1 -0
- package/dist/standalone/chunk-TQ36RWOP.js +1 -0
- package/dist/standalone/chunk-UGUEC6BC.js +1 -0
- package/dist/standalone/chunk-UK64ZSUW.js +1 -0
- package/dist/standalone/chunk-UKDJ4H7I.js +1 -0
- package/dist/standalone/chunk-V6IWFYAQ.js +1 -0
- package/dist/standalone/chunk-V7SRH36W.js +1 -0
- package/dist/standalone/chunk-VLXV72QE.js +1 -0
- package/dist/standalone/chunk-VON7JUPG.js +1 -0
- package/dist/standalone/chunk-WI7GWFEG.js +1 -0
- package/dist/standalone/chunk-WPNXY7IS.js +1 -0
- package/dist/standalone/chunk-X33MSJPP.js +1 -0
- package/dist/standalone/chunk-XNJNSCLM.js +1 -0
- package/dist/standalone/chunk-XRNXOIVZ.js +1 -0
- package/dist/standalone/chunk-YAECF5LW.js +1 -0
- package/dist/standalone/chunk-YBGC4PPD.js +1 -0
- package/dist/standalone/chunk-YNZ7ARWW.js +1 -0
- package/dist/standalone/chunk-YTO65GHS.js +1 -0
- package/dist/standalone/chunk-ZE6FT5Z3.js +1 -0
- package/dist/standalone/chunk-ZHVTQ37P.js +1 -0
- package/dist/standalone/chunk-ZIGWVHCS.js +1 -0
- package/dist/standalone/chunk-ZPP2KOR4.js +1 -0
- package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
- package/dist/standalone/studio.js +104 -246
- package/dist/styles.css +2 -2
- package/package.json +15 -13
- package/dist/packem_shared/HomePanel-Cw16stjq.js +0 -1273
- package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
- package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
- package/dist/packem_shared/Studio-DFWAlcuf.js +0 -33
- package/dist/packem_shared/studio-Bj8psK1c.js +0 -10303
- package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
- package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-RRCPZMC2.js";var u={highErrorRate:.05,highWriteContention:.1,lowCacheHitRate:.5,minCacheSamples:10,minConflictCalls:5,minErrorCalls:5,slowFunctionMs:1e3},t={error:0,info:2,warning:1},f=a((i,s)=>{let e=[];if(i.maxDurationMs>=s.slowFunctionMs){let n=i.scannedTables??[];n.length>0?e.push({fn:i.path,kind:"missing-index",severity:"warning",tables:n.map(o=>o.table),value:i.maxDurationMs}):e.push({fn:i.path,kind:"slow-function",severity:"info",value:i.maxDurationMs})}i.calls>=s.minErrorCalls&&i.errors/i.calls>=s.highErrorRate&&e.push({fn:i.path,kind:"high-error-rate",message:i.lastErrorMessage??void 0,severity:"error",value:i.errors/i.calls});let r=i.conflicts??0;return r>0&&i.calls>=s.minConflictCalls&&r/i.calls>=s.highWriteContention&&e.push({fn:i.path,kind:"high-write-contention",severity:"warning",value:r/i.calls}),e},"deriveFunctionInsights"),g=a((i,s,e=u)=>{let r=[];if(i?.cache){let{evictions:n,hits:o,misses:h}=i.cache,c=o+h;if(c>=e.minCacheSamples){let l=o/c;l<e.lowCacheHitRate&&r.push({kind:"low-cache-hit-rate",severity:"warning",value:l})}n>0&&n>o&&r.push({kind:"high-evictions",severity:"warning",value:n})}for(let n of s??[])r.push(...f(n,e));return r.toSorted((n,o)=>t[n.severity]-t[o.severity])},"deriveInsights");export{g as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as we,b as Ke,c as je}from"./chunk-L7SK4ZZD.js";import{i as Ge,k as He}from"./chunk-4QHKBC77.js";import{D as Me,I as Se,K as Ve,L as De,M as Le,N as Oe,O as Te,P as Fe,Q as _e,a as $,b as Ie,c as Ne,e as F,f as Be}from"./chunk-3CJW6NWG.js";import{b as Ae}from"./chunk-UK64ZSUW.js";import{a as T,e as ce}from"./chunk-O3NAGRTR.js";import{a as ve,c as Re,d as Ee,g as de,i as Pe,j as W}from"./chunk-CKSHCYGC.js";import{a as vt}from"./chunk-3OA7PECS.js";import{a as i,d as Ct,e as k,f as O,g as yt,h as Rt,j as ye}from"./chunk-RRCPZMC2.js";var Je=k(yt(),1);var w={};Ct(w,{Indicator:()=>fe,Root:()=>ue});var u=k(O(),1);function Ue(t){if(!t)return null;for(let e of t.elements){let n=e.tagName;if(n==="BUTTON"||n==="INPUT"){let o=e;if(o.type==="submit")return o}}return null}i(Ue,"getDefaultFormSubmitter");var qe=k(O(),1);var le=(function(t){return t.checked="data-checked",t.unchecked="data-unchecked",t.indeterminate="data-indeterminate",t.disabled="data-disabled",t.readonly="data-readonly",t.required="data-required",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t})({});function z(t){return qe.useMemo(()=>({checked(e){return t.indeterminate?{}:e?{[le.checked]:""}:{[le.unchecked]:""}},...$}),[t.indeterminate])}i(z,"useStateAttributesMapping");var We=k(O(),1);function $e(t,e,n,o=!0,a){let[f,p]=We.useState(),M=F(a?`${a}-label`:void 0),b=t??e??f;return T(()=>{let g=t||e||!o?void 0:Et(n.current,M);f!==g&&p(g)}),b}i($e,"useAriaLabelledBy");function Et(t,e){let n=Pt(t);if(n)return!n.id&&e&&(n.id=e),n.id||void 0}i(Et,"getAriaLabelledBy");function Pt(t){if(!t)return;let e=t.parentElement;if(e&&e.tagName==="LABEL")return e;let n=t.id;if(n){let a=t.nextElementSibling;if(a&&a.htmlFor===n)return a}let o=t.labels;return o&&o[0]}i(Pt,"findAssociatedLabel");var J=k(O(),1);var X=J.createContext(void 0);X.displayName="CheckboxRootContext";function ze(){let t=J.useContext(X);if(t===void 0)throw new Error("Base UI: CheckboxRootContext is missing. Checkbox parts must be placed within <Checkbox.Root>.");return t}i(ze,"useCheckboxRootContext");var _=k(vt(),1);var It="data-parent",ue=u.forwardRef(i(function(e,n){let{checked:o,className:a,defaultChecked:f=!1,"aria-labelledby":p,disabled:M=!1,form:b,id:g,indeterminate:S=!1,inputRef:Z,name:K,onCheckedChange:A,parent:m=!1,readOnly:R=!1,render:pe,required:E=!1,uncheckedValue:j,value:G,nativeButton:H=!1,style:Nt,...Xe}=e,{clearErrors:Ye}=Ne(),{disabled:Qe,name:Ze,setDirty:et,setFilled:ee,setFocused:me,setTouched:tt,state:he,validationMode:rt,validityData:nt,validation:ot}=Ie(),it=Me(),{labelId:at,controlId:st,registerControlId:P,getDescriptionProps:be}=Be(),s=_e(),V=s?.parent,D=V&&s.allValues,c=Qe||it.disabled||s?.disabled||M,I=Ze??K,d=G??I,ge=F(),dt=F(),x=st;D?x=m?dt:`${V.id}-${d}`:g&&(x=g);let te={};D&&(m?te=s.parent.getParentProps():d&&(te=s.parent.getChildProps(d)));let{checked:ke=o,indeterminate:ct=S,onCheckedChange:lt,...ut}=te,N=s?.value,xe=s?.setValue,Ce=s?.defaultValue,re=u.useRef(null),U=Re(()=>Symbol("checkbox-control")),ne=u.useRef(!1),{getButtonProps:ft,buttonRef:pt}=Ae({disabled:c,native:H}),B=s?.validation??ot,[l,mt]=Le({controlled:d&&N&&!m?N.includes(d):ke,default:d&&Ce&&!m?Ce.includes(d):f,name:"Checkbox",state:"checked"}),oe=D?!!ke:l,L=D&&ct||S;T(()=>{P!==de&&(ne.current=!0,P(U.current,x))},[x,P,U]),u.useEffect(()=>{let r=U.current;return()=>{!ne.current||P===de||(ne.current=!1,P(r,void 0))}},[P,U]),Oe(re,ge,l,void 0,!s&&!c,K);let C=u.useRef(null),ht=Ee(Z,C,B.inputRef,B.registerInput),bt=$e(p,at,C,!H,x??void 0);T(()=>{C.current&&(C.current.indeterminate=L,l&&ee(!0))},[l,L,ee]),je(l,()=>{s||(Ye(I),ee(l),et(l!==nt.initialValue),B.change(l))});let gt=ve({checked:l,disabled:c,form:b,name:m?void 0:I,id:H?void 0:x??void 0,required:E,ref:ht,style:I?Ke:we,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(r){if(r.nativeEvent.defaultPrevented)return;if(R){r.preventDefault();return}let h=r.currentTarget.checked,y=Fe(Te.none,r.nativeEvent);if(A?.(h,y),!y.isCanceled&&(lt?.(h,y),!y.isCanceled&&(mt(h),d&&N&&xe&&!m&&!D))){let v=h?[...N,d]:N.filter(q=>q!==d);xe(v,y)}},onFocus(){re.current?.focus()}},G!==void 0?{value:(s?l&&G:G)||""}:Pe,be,r=>B.getValidationProps(c,r));u.useEffect(()=>{if(!V||!d)return;let r=V.disabledStatesRef.current;return r.set(d,c),()=>{r.delete(d)}},[V,c,d]);let ie=u.useMemo(()=>({...he,checked:oe,disabled:c,readOnly:R,required:E,indeterminate:L}),[he,oe,c,R,E,L]),kt=z(ie),xt=W("span",e,{state:ie,ref:[pt,re,n,s?.registerControlRef],props:[{id:H?x??void 0:ge,role:"checkbox","aria-checked":L?"mixed":oe,"aria-readonly":R||void 0,"aria-required":E||void 0,"aria-labelledby":bt,[It]:m?"":void 0,onFocus(){c||me(!0)},onBlur(){let r=C.current;r&&(tt(!0),me(!1),rt==="onBlur"&&B.commit(s?N:r.checked))},onKeyDown(r){if(r.key!=="Enter"||(r.preventBaseUIHandler(),r.defaultPrevented))return;let h=C.current?.form??null,y=r.currentTarget,v=r.nativeEvent,q=r.preventDefault,ae=v.preventDefault,se=!1;r.preventDefault=()=>{se=!0,q.call(r)},v.preventDefault=()=>{se=!0,ae.call(v)},ae.call(v),ce(y).queueMicrotask(()=>{r.preventDefault=q,v.preventDefault=ae,se||Ue(h)?.click()})},onClick(r){if(R||c)return;r.preventDefault();let h=C.current;h&&h.dispatchEvent(new(ce(h)).PointerEvent("click",{bubbles:!0,shiftKey:r.shiftKey,ctrlKey:r.ctrlKey,altKey:r.altKey,metaKey:r.metaKey}))}},Xe,ut,ft,be,r=>B.getValidationProps(c,r)],stateAttributesMapping:kt});return(0,_.jsxs)(X.Provider,{value:ie,children:[xt,!l&&!s&&I&&!m&&j!==void 0&&(0,_.jsx)("input",{type:"hidden",form:b,name:I,value:j,disabled:c}),(0,_.jsx)("input",{...gt,suppressHydrationWarning:!0})]})},"CheckboxRoot"));ue.displayName="CheckboxRoot";var Y=k(O(),1);var fe=Y.forwardRef(i(function(e,n){let{render:o,className:a,style:f,keepMounted:p=!1,...M}=e,b=ze(),g=b.checked||b.indeterminate,{mounted:S,transitionStatus:Z,setMounted:K}=De(g),A=Y.useRef(null),m={...b,transitionStatus:Z};Ve({open:g,ref:A,onComplete(){g||K(!1)}});let pe={...z(b),...Se,...$},E=p||S,j=W("span",e,{ref:[n,A],state:m,stateAttributesMapping:pe,props:M});return E?j:null},"CheckboxIndicator"));fe.displayName="CheckboxIndicator";var Q=k(Rt(),1);function Sr(t){let e=(0,Je.c)(9),n,o;e[0]!==t?({className:n,...o}=t,e[0]=t,e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]!==n?(a=ye("peer relative flex size-4 shrink-0 items-center justify-center rounded-md border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",n),e[3]=n,e[4]=a):a=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,Q.jsxDEV)(w.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:(0,Q.jsxDEV)(He,{icon:Ge,strokeWidth:2},void 0,!1)},void 0,!1),e[5]=f):f=e[5];let p;return e[6]!==o||e[7]!==a?(p=(0,Q.jsxDEV)(w.Root,{"data-slot":"checkbox",className:a,...o,children:f},void 0,!1),e[6]=o,e[7]=a,e[8]=p):p=e[8],p}i(Sr,"Checkbox");export{Sr as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as q}from"./chunk-YAECF5LW.js";import"./chunk-DWDILV2E.js";import{a as T}from"./chunk-QAFAJBAW.js";import{a as H}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as D}from"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import{R as F}from"./chunk-3CJW6NWG.js";import{c}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as p}from"./chunk-BOXSWNXZ.js";import{a as O}from"./chunk-TAD43CG5.js";import{b as B}from"./chunk-C7WTJLC3.js";import{b as P}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as j}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as $,e as g,f as N,g as w,k as y,m as R,o as C}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as o,e as M,f as oe,h as se,j as z}from"./chunk-RRCPZMC2.js";var d=M(oe(),1);var e=M(se(),1);function de({className:r,orientation:m="horizontal",...a}){return(0,e.jsxDEV)(T,{"data-slot":"separator",orientation:m,className:z("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...a},void 0,!1)}o(de,"Separator");var le=g(p.clearCapturedMail),ne=g(p.sendTestMail),ce=/https?:\/\/[^\s"'<>)]+/i,_=o(r=>r===void 0?void 0:ce.exec(r)?.[0],"firstLink"),me=o(r=>{if(r!==void 0)return _(r.html)??_(r.text)},"selectedLink"),ue=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,fe=o(r=>`${ue}${r}`,"withPreviewCsp"),v=o(r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,"recipientText"),Ie=o(({limit:r=100})=>{let m=j(),a=$(),{data:S,error:k,errorSource:U,isLoading:V,refetch:x}=B(p.getCapturedMail,{limit:r}),[E,h]=(0,d.useState)(null),[A,L]=(0,d.useState)(null),[u,W]=(0,d.useState)("html"),[b,K]=(0,d.useState)(""),l=(0,d.useMemo)(()=>S?.entries??[],[S]),I=k??E,Q=k===null?E:U,G=o(async()=>{h(null);try{await m.query(le,{},N("")),L(null),x()}catch(t){h(w(t))}},"clearInbox"),J=o(async()=>{h(null);try{await m.query(ne,{},N("")),x()}catch(t){h(w(t))}},"sendTest");H(()=>{x()},!0);let X=o(()=>{y(G())},"onClear"),Y=o(()=>{y(J())},"onSendTest"),Z=o(t=>{K(t.currentTarget.value)},"onFilterChange"),ee=o(t=>{let{id:s}=t.currentTarget.dataset;s!==void 0&&L(s)},"onSelectMessage"),te=o(t=>{let s=t.currentTarget.dataset.tab;(s==="headers"||s==="html"||s==="text")&&W(s)},"onSelectTab"),ae=o(t=>a(t==="html"?"HTML":t==="text"?"Plain text":"Headers"),"tabTitle"),f=(0,d.useMemo)(()=>{let t=b.trim().toLowerCase();return t===""?l:l.filter(s=>`${s.subject} ${v(s.to)}`.toLowerCase().includes(t))},[l,b]),i=(0,d.useMemo)(()=>{if(f.length!==0)return f.find(t=>t.id===A)??f[0]},[f,A]),n=me(i),re=o(()=>{n!==void 0&&R(n)},"onCopyLink"),ie=o(()=>{n!==void 0&&"window"in globalThis&&globalThis.window.open(n,"_blank","noopener")},"onOpenLink");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(c,{"data-testid":"mail-send-test",onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Send test")},void 0,!1),(0,e.jsxDEV)(c,{"data-testid":"mail-clear",disabled:l.length===0,onClick:X,size:"sm",type:"button",variant:"outline",children:a("Clear inbox")},void 0,!1),l.length>0&&(0,e.jsxDEV)(P,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:a("{count} messages",{count:l.length})},void 0,!1)]},void 0,!0),I!==null&&(0,e.jsxDEV)(D,{error:Q,testId:"mail-error"},void 0,!1),I===null&&!V&&l.length===0&&(0,e.jsxDEV)(O,{description:a("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,e.jsxDEV)("path",{d:"M4 5h16v14H4z"},void 0,!1),(0,e.jsxDEV)("path",{d:"m4 6 8 6 8-6"},void 0,!1)]},void 0,!0),testId:"mail-empty",title:a("No captured email.")},void 0,!1),l.length>0&&(0,e.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxDEV)(F,{"aria-label":a("Search messages"),"data-testid":"mail-search",onChange:Z,placeholder:a("Filter messages"),type:"search",value:b},void 0,!1),(0,e.jsxDEV)(q,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,e.jsxDEV)("ul",{className:"divide-y",children:f.map(t=>{let s=t.id===i?.id;return(0,e.jsxDEV)("li",{children:(0,e.jsxDEV)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${s?"bg-muted":""}`,"data-active":s,"data-id":t.id,"data-testid":"mail-list-item",onClick:ee,type:"button",children:[(0,e.jsxDEV)("span",{className:"w-full truncate font-medium",children:t.subject||a("(no subject)")},void 0,!1),(0,e.jsxDEV)("span",{className:"w-full truncate text-xs text-muted-foreground",children:v(t.to)},void 0,!1),(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground tabular-nums",children:C(t.capturedAt,"\u2014")},void 0,!1)]},void 0,!0)},t.id,!1)})},void 0,!1)},void 0,!1)]},void 0,!0),i!==void 0&&(0,e.jsxDEV)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||a("(no subject)")},void 0,!1),(0,e.jsxDEV)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,e.jsxDEV)("dt",{children:a("From")},void 0,!1),(0,e.jsxDEV)("dd",{className:"truncate font-mono",children:i.from??"\u2014"},void 0,!1),(0,e.jsxDEV)("dt",{children:a("To")},void 0,!1),(0,e.jsxDEV)("dd",{className:"truncate font-mono",children:v(i.to)},void 0,!1),i.cc!==void 0&&i.cc.length>0&&(0,e.jsxDEV)(e.Fragment,{children:[(0,e.jsxDEV)("dt",{children:a("Cc")},void 0,!1),(0,e.jsxDEV)("dd",{className:"truncate font-mono",children:v(i.cc)},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("dt",{children:a("Sent")},void 0,!1),(0,e.jsxDEV)("dd",{className:"tabular-nums",children:C(i.capturedAt,"\u2014")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,e.jsxDEV)(c,{"data-testid":"mail-copy-link",disabled:n===void 0,onClick:re,size:"sm",type:"button",variant:"outline",children:a("Copy link")},void 0,!1),(0,e.jsxDEV)(c,{"data-testid":"mail-open-link",disabled:n===void 0,onClick:ie,size:"sm",type:"button",variant:"outline",children:a("Open in new tab")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(de,{},void 0,!1),(0,e.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(t=>(0,e.jsxDEV)(c,{"aria-selected":u===t,"data-tab":t,"data-testid":`mail-tab-${t}`,onClick:te,role:"tab",size:"sm",type:"button",variant:u===t?"secondary":"ghost",children:ae(t)},t,!1))},void 0,!1),(0,e.jsxDEV)("div",{className:"min-h-[12rem]",children:[u==="html"&&(i.html===void 0?(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a("No HTML body.")},void 0,!1):(0,e.jsxDEV)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:fe(i.html),title:a("Email preview")},void 0,!1)),u==="text"&&(i.text===void 0?(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a("No text body.")},void 0,!1):(0,e.jsxDEV)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text},void 0,!1)),u==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a("No headers.")},void 0,!1):(0,e.jsxDEV)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([t,s])=>`${t}: ${s}`).join(`
|
|
2
|
+
`)},void 0,!1))]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"MailPanel");export{Ie as MailPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d,e as h,g as N,h as E,j as k}from"./chunk-RRCPZMC2.js";var y=h(N(),1);var v=h(E(),1);var I={dialog:"fixed inset-0 z-[1000] flex justify-center bg-black/20 pt-[10vh]",drawer:"fixed inset-0 z-[1000] flex justify-end bg-black/20"},T={dialog:"flex h-fit w-[min(28rem,92vw)] flex-col gap-3 rounded-lg border border-border bg-background p-4 shadow-xl",drawer:"flex h-full w-[min(34rem,100vw)] flex-col gap-4 overflow-auto border-l border-border bg-background p-4 shadow-xl"},_=d(A=>{let e=(0,y.c)(18),{className:n,children:c,label:f,onClose:l,panelTestId:b,testId:g,variant:u}=A,r;e[0]!==l?(r=d(i=>{i.target===i.currentTarget&&l()},"t1"),e[0]=l,e[1]=r):r=e[1];let m=r,a;e[2]!==l?(a=d(i=>{i.key==="Escape"&&l()},"t2"),e[2]=l,e[3]=a):a=e[3];let p=a,x=I[u],w=T[u],o;e[4]!==n||e[5]!==w?(o=k(w,n),e[4]=n,e[5]=w,e[6]=o):o=e[6];let t;e[7]!==c||e[8]!==f||e[9]!==b||e[10]!==o?(t=(0,v.jsxDEV)("div",{"aria-label":f,className:o,"data-testid":b,role:"dialog",children:c},void 0,!1),e[7]=c,e[8]=f,e[9]=b,e[10]=o,e[11]=t):t=e[11];let s;return e[12]!==m||e[13]!==p||e[14]!==x||e[15]!==t||e[16]!==g?(s=(0,v.jsxDEV)("div",{className:x,"data-testid":g,onClick:m,onKeyDown:p,role:"presentation",children:t},void 0,!1),e[12]=m,e[13]=p,e[14]=x,e[15]=t,e[16]=g,e[17]=s):s=e[17],s},"ModalShell");export{_ as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ee,b as te,d as se}from"./chunk-NN27EDQB.js";import"./chunk-DC72CQY4.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{a as X}from"./chunk-XNJNSCLM.js";import{c as I}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{a as U}from"./chunk-TAD43CG5.js";import{a as z,b as V,c as P,e as D}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as Q}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as O,e as H,f as Y,g as G,k as Z}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as k,e as j,f as ie,g as le,h as oe}from"./chunk-RRCPZMC2.js";var W=j(le(),1),T=j(ie(),1);var o=j(oe(),1);var de=H(J.runSql),ae=k(($,e)=>{let s=Q(),[f,t]=(0,T.useState)(void 0),[i,d]=(0,T.useState)(void 0),[l,c]=(0,T.useState)(!0),q=(0,T.useCallback)(async a=>{c(!0);try{let x=await s.query(de,{sql:$},Y(e));a.cancelled||(t(x),d(void 0))}catch(x){a.cancelled||(t(void 0),d(G(x)))}finally{a.cancelled||c(!1)}},[s,$,e]);return(0,T.useEffect)(()=>{let a={cancelled:!1};return Z(q(a)),()=>{a.cancelled=!0}},[q]),{error:i,loading:l,result:f}},"useRunSql"),re="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k($=>{let e=(0,W.c)(54),{onEdit:s,onRemove:f,widget:t}=$,i=O(),{error:d,loading:l,result:c}=ae(t.sql,t.shardKey??""),q;e[0]!==s||e[1]!==t.id?(q=k(()=>{s(t.id)},"t1"),e[0]=s,e[1]=t.id,e[2]=q):q=e[2];let a=q,x;e[3]!==f||e[4]!==t.id?(x=k(()=>{f(t.id)},"t2"),e[3]=f,e[4]=t.id,e[5]=x):x=e[5];let K=x,M=`dashboards-widget-${t.id}`,S;e[6]!==t.title?(S=(0,o.jsxDEV)(P,{className:"min-w-0 truncate",title:t.title,children:t.title},void 0,!1),e[6]=t.title,e[7]=S):S=e[7];let L;e[8]!==i?(L=i("Edit widget"),e[8]=i,e[9]=L):L=e[9];let R=`dashboards-widget-edit-${t.id}`,A;e[10]!==i?(A=i("Edit widget"),e[10]=i,e[11]=A):A=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"},void 0,!1)},void 0,!1),e[12]=w):w=e[12];let C;e[13]!==a||e[14]!==L||e[15]!==R||e[16]!==A?(C=(0,o.jsxDEV)(I,{"aria-label":L,"data-testid":R,onClick:a,size:"icon-xs",title:A,type:"button",variant:"ghost",children:w},void 0,!1),e[13]=a,e[14]=L,e[15]=R,e[16]=A,e[17]=C):C=e[17];let b;e[18]!==i?(b=i("Remove widget"),e[18]=i,e[19]=b):b=e[19];let E=`dashboards-widget-remove-${t.id}`,m;e[20]!==i?(m=i("Remove widget"),e[20]=i,e[21]=m):m=e[21];let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[22]=p):p=e[22];let u;e[23]!==K||e[24]!==b||e[25]!==E||e[26]!==m?(u=(0,o.jsxDEV)(I,{"aria-label":b,"data-testid":E,onClick:K,size:"icon-xs",title:m,type:"button",variant:"ghost",children:p},void 0,!1),e[23]=K,e[24]=b,e[25]=E,e[26]=m,e[27]=u):u=e[27];let h;e[28]!==u||e[29]!==C?(h=(0,o.jsxDEV)("div",{className:"flex shrink-0 items-center gap-1",children:[C,u]},void 0,!0),e[28]=u,e[29]=C,e[30]=h):h=e[30];let v;e[31]!==h||e[32]!==S?(v=(0,o.jsxDEV)(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[S,h]},void 0,!0),e[31]=h,e[32]=S,e[33]=v):v=e[33];let g;e[34]!==d||e[35]!==t.id?(g=d!==void 0&&(0,o.jsxDEV)(X,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:d},void 0,!1),e[34]=d,e[35]=t.id,e[36]=g):g=e[36];let N;e[37]!==d||e[38]!==l||e[39]!==c||e[40]!==i||e[41]!==t.id?(N=d===void 0&&l&&c===void 0&&(0,o.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:i("Running\u2026")},void 0,!1),e[37]=d,e[38]=l,e[39]=c,e[40]=i,e[41]=t.id,e[42]=N):N=e[42];let r;e[43]!==d||e[44]!==c?(r=d===void 0&&c!==void 0&&(0,o.jsxDEV)(ee,{result:c},void 0,!1),e[43]=d,e[44]=c,e[45]=r):r=e[45];let n;e[46]!==g||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(D,{className:"min-h-32 py-2",children:[g,N,r]},void 0,!0),e[46]=g,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;return e[50]!==v||e[51]!==n||e[52]!==M?(y=(0,o.jsxDEV)(z,{"data-testid":M,children:[v,n]},void 0,!0),e[50]=v,e[51]=n,e[52]=M,e[53]=y):y=e[53],y},"WidgetCard"),ce=k($=>{let e=(0,W.c)(58),{draft:s,editing:f,onCancel:t,onChange:i,onSubmit:d}=$,l=O(),c;e[0]!==s||e[1]!==i?(c=k(_=>{i({...s,title:_.target.value})},"t1"),e[0]=s,e[1]=i,e[2]=c):c=e[2];let q=c,a;e[3]!==s||e[4]!==i?(a=k(_=>{i({...s,sql:_.target.value})},"t2"),e[3]=s,e[4]=i,e[5]=a):a=e[5];let x=a,K;e[6]!==s||e[7]!==i?(K=k(_=>{i({...s,shardKey:_.target.value})},"t3"),e[6]=s,e[7]=i,e[8]=K):K=e[8];let M=K,S;e[9]!==d?(S=k(()=>{d()},"t4"),e[9]=d,e[10]=S):S=e[10];let L=S,R;e[11]!==s.sql||e[12]!==s.title?(R=s.title.trim()!==""&&s.sql.trim()!=="",e[11]=s.sql,e[12]=s.title,e[13]=R):R=e[13];let A=R,w;e[14]!==l?(w=l("Widget title"),e[14]=l,e[15]=w):w=e[15];let C;e[16]!==l?(C=l("Widget title"),e[16]=l,e[17]=C):C=e[17];let b;e[18]!==s.title||e[19]!==q||e[20]!==w||e[21]!==C?(b=(0,o.jsxDEV)("input",{"aria-label":w,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:q,placeholder:C,type:"text",value:s.title},void 0,!1),e[18]=s.title,e[19]=q,e[20]=w,e[21]=C,e[22]=b):b=e[22];let E;e[23]!==l?(E=l("SQL query"),e[23]=l,e[24]=E):E=e[24];let m;e[25]!==s.sql||e[26]!==x||e[27]!==E?(m=(0,o.jsxDEV)("textarea",{"aria-label":E,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:x,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:s.sql},void 0,!1),e[25]=s.sql,e[26]=x,e[27]=E,e[28]=m):m=e[28];let p;e[29]!==l?(p=l("Shard key (optional)"),e[29]=l,e[30]=p):p=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let h;e[33]!==s.shardKey||e[34]!==M||e[35]!==p||e[36]!==u?(h=(0,o.jsxDEV)("input",{"aria-label":p,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:M,placeholder:u,type:"text",value:s.shardKey},void 0,!1),e[33]=s.shardKey,e[34]=M,e[35]=p,e[36]=u,e[37]=h):h=e[37];let v;e[38]!==l?(v=l("Cancel"),e[38]=l,e[39]=v):v=e[39];let g;e[40]!==t||e[41]!==v?(g=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:v},void 0,!1),e[40]=t,e[41]=v,e[42]=g):g=e[42];let N=!A,r;e[43]!==f||e[44]!==l?(r=l(f?"Save widget":"Add widget"),e[43]=f,e[44]=l,e[45]=r):r=e[45];let n;e[46]!==L||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-save",disabled:N,onClick:L,size:"sm",type:"button",children:r},void 0,!1),e[46]=L,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;e[50]!==g||e[51]!==n?(y=(0,o.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[g,n]},void 0,!0),e[50]=g,e[51]=n,e[52]=y):y=e[52];let F;return e[53]!==m||e[54]!==h||e[55]!==y||e[56]!==b?(F=(0,o.jsxDEV)(z,{"data-testid":"dashboards-form",children:(0,o.jsxDEV)(D,{className:"flex flex-col gap-3 py-4",children:[b,m,h,y]},void 0,!0)},void 0,!1),e[53]=m,e[54]=h,e[55]=y,e[56]=b,e[57]=F):F=e[57],F},"WidgetForm"),Ce=k($=>{let e=(0,W.c)(39),{initialShardKey:s}=$,f=O(),[t,i]=te(re),[d,l]=(0,T.useState)(B),[c,q]=(0,T.useState)(null),[a,x]=(0,T.useState)(!1),K;e[0]!==s?(K=k(()=>{q(null),l({...B,shardKey:s??""}),x(!0)},"t1"),e[0]=s,e[1]=K):K=e[1];let M=K,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=k(()=>{x(!1),q(null),l(B)},"t2"),e[2]=S):S=e[2];let L=S,R;e[3]!==t?(R=k(r=>{let n=t.find(y=>y.id===r);n!==void 0&&(q(r),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),x(!0))},"t3"),e[3]=t,e[4]=R):R=e[4];let A=R,w;e[5]!==i?(w=k(r=>{i(n=>n.filter(y=>y.id!==r))},"t4"),e[5]=i,e[6]=w):w=e[6];let C=w,b;e[7]!==d.shardKey||e[8]!==d.sql||e[9]!==d.title||e[10]!==c||e[11]!==i?(b=k(()=>{let r=d.title.trim(),n=d.sql.trim();if(r===""||n==="")return;let y=d.shardKey.trim();i(c===null?F=>[...F,{id:se("w"),shardKey:y,sql:n,title:r}]:F=>F.map(_=>_.id===c?{..._,shardKey:y,sql:n,title:r}:_)),L()},"t5"),e[7]=d.shardKey,e[8]=d.sql,e[9]=d.title,e[10]=c,e[11]=i,e[12]=b):b=e[12];let E=b,m;e[13]!==f?(m=f("Chart widgets backed by saved read-only SQL queries."),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==m?(p=(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[15]=m,e[16]=p):p=e[16];let u;e[17]!==a||e[18]!==M||e[19]!==f?(u=!a&&(0,o.jsxDEV)(I,{"data-testid":"dashboards-add",onClick:M,size:"sm",type:"button",children:f("Add widget")},void 0,!1),e[17]=a,e[18]=M,e[19]=f,e[20]=u):u=e[20];let h;e[21]!==p||e[22]!==u?(h=(0,o.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,u]},void 0,!0),e[21]=p,e[22]=u,e[23]=h):h=e[23];let v;e[24]!==d||e[25]!==c||e[26]!==a||e[27]!==E?(v=a&&(0,o.jsxDEV)(ce,{draft:d,editing:c!==null,onCancel:L,onChange:l,onSubmit:E},void 0,!1),e[24]=d,e[25]=c,e[26]=a,e[27]=E,e[28]=v):v=e[28];let g;e[29]!==a||e[30]!==A||e[31]!==C||e[32]!==f||e[33]!==t?(g=t.length===0&&!a?(0,o.jsxDEV)(U,{description:f("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:f("No widgets yet")},void 0,!1):(0,o.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(r=>(0,o.jsxDEV)(ne,{onEdit:A,onRemove:C,widget:r},r.id,!1))},void 0,!1),e[29]=a,e[30]=A,e[31]=C,e[32]=f,e[33]=t,e[34]=g):g=e[34];let N;return e[35]!==v||e[36]!==g||e[37]!==h?(N=(0,o.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[h,v,g]},void 0,!0),e[35]=v,e[36]=g,e[37]=h,e[38]=N):N=e[38],N},"DashboardsPanel");export{Ce as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as Pe,b as re,c as ge,d as xe}from"./chunk-NN27EDQB.js";import{a as Be}from"./chunk-BGXOXASQ.js";import{a as $e}from"./chunk-MJWVMKQ4.js";import"./chunk-LNZIB2MD.js";import"./chunk-QBAT52GB.js";import"./chunk-QAFAJBAW.js";import"./chunk-AHILM3ZP.js";import"./chunk-IXDH4GL5.js";import"./chunk-KSKXW5PX.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-DC72CQY4.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-YBGC4PPD.js";import"./chunk-KEGAWN6Y.js";import{a as Re}from"./chunk-XNJNSCLM.js";import{a as Le,b as Ae,c as Oe,d as ve,e as Me,f as De}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as Ie}from"./chunk-UKDJ4H7I.js";import{b as qe}from"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as le}from"./chunk-BOXSWNXZ.js";import"./chunk-CKSHCYGC.js";import{f as he}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as G,e as ne,f as se,g as Ee,k as Q}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as r,e as be,f as It,g as Rt,h as Lt,j as oe}from"./chunk-RRCPZMC2.js";var K=be(Rt(),1);var q=be(It(),1);var n=be(Lt(),1);var At=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Ot=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ae=String.fromCodePoint(0),Mt=new RegExp(`${ae}${String.raw`(\d+)`}${ae}`,"gu"),Dt=At.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),Bt=Ot.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
|
+
${s}`})),$t=r(s=>{let e=[],o=s.replaceAll(/'(?:[^']|'')*'/gu,l=>(e.push(l),`${ae}${(e.length-1).toString()}${ae}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:l,replacement:a}of Dt)o=o.replaceAll(l,a);for(let{pattern:l,replacement:a}of Bt)o=o.replaceAll(l,a);return o=o.replaceAll(Mt,(l,a)=>e[Number(a)]??""),o},"formatSql"),ie=8,Pt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],_t=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Wt=/[\w$]/,He=r(s=>s!==void 0&&Wt.test(s),"isWordChar"),Fe=r(s=>{let e=s.length;for(;e>0&&He(s[e-1]);)e-=1;return s.slice(e)},"trailingWord"),ze=r((s,e)=>{let t=e;for(;t>0&&He(s[t-1]);)t-=1;return{end:e,start:t,text:s.slice(t,e)}},"tokenAt"),_e=r((s,e)=>{let t=s.slice(0,e).trimEnd();return t.endsWith(".")||_t.has(Fe(t).toUpperCase())},"prefersColumns"),Ht=r((s,e)=>{let t=s.slice(0,e);if(!t.endsWith("."))return;let o=Fe(t.slice(0,-1));return o===""?void 0:o},"qualifierTable"),ke=r((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"matches"),We=r((s,e,t,o)=>{let l=[];for(let a of s)if(ke(a,e)&&(l.push(o(a)),l.length>=t))break;return l},"takeMatches"),Ft=r((s,e,t)=>{let o=new Map;for(let[l,a]of Object.entries(s.columns))for(let d of a)if(ke(d,e)&&!o.has(d)&&(o.set(d,l),o.size>=t))return[...o].map(([p,c])=>({detail:c,kind:"column",label:p}));return[...o].map(([l,a])=>({detail:a,kind:"column",label:l}))},"takeColumnMatches"),zt=r((s,e,t)=>{let o=ze(s,e),l=Ht(s,o.start);if(l!==void 0){let u=t.columns[l]??t.columns[l.toLowerCase()]??[];return We(u,o.text,ie,y=>({detail:l,kind:"column",label:y}))}if(o.text===""&&!_e(s,o.start))return[];let a=We(t.tables,o.text,ie,u=>({kind:"table",label:u})),d=Ft(t,o.text,ie),p=Pt.filter(u=>o.text!==""&&ke(u,o.text)&&u.toLowerCase()!==o.text.toLowerCase()).map(u=>({kind:"keyword",label:u}));return(_e(s,o.start)?[...d,...a,...p]:[...a,...d,...p]).slice(0,ie)},"suggestionsFor"),Ut=r((s,e,t)=>{let o=ze(s,e),l=s.slice(0,o.start)+t.label+s.slice(o.end);return{caret:o.start+t.label.length,value:l}},"acceptSuggestion"),Yt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],jt=r((s,e)=>{let t=globalThis.getComputedStyle(s),o=globalThis.document.createElement("div"),{style:l}=o;l.position="absolute",l.visibility="hidden",l.whiteSpace="pre-wrap",l.overflowWrap="break-word";for(let c of Yt)l[c]=t[c];o.textContent=s.value.slice(0,Math.max(0,e));let a=globalThis.document.createElement("span");a.textContent=s.value.slice(Math.max(0,e))||".",o.append(a),globalThis.document.body.append(o);let d=a.offsetLeft-s.scrollLeft,p=a.offsetTop-s.scrollTop;return o.remove(),{left:d,top:p}},"caretOffset"),Kt=r((s,e,t)=>{let o=(0,K.c)(13),[l,a]=(0,q.useState)(null),d;o[0]!==s||o[1]!==e?(d=r((N,x)=>{let S=zt(N,x,s);if(S.length===0){a(null);return}let h=e.current,{left:w,top:C}=h===null?{left:0,top:0}:jt(h,x);a({active:0,left:w,suggestions:S,top:C})},"t0"),o[0]=s,o[1]=e,o[2]=d):d=o[2];let p=d,c;o[3]===Symbol.for("react.memo_cache_sentinel")?(c=r(()=>{a(null)},"t1"),o[3]=c):c=o[3];let u=c,y;o[4]===Symbol.for("react.memo_cache_sentinel")?(y=r(N=>{a(x=>{if(x===null)return x;let S=x.suggestions.length,h=(x.active+N+S)%S;return{...x,active:h}})},"t2"),o[4]=y):y=o[4];let g=y,v;o[5]!==t||o[6]!==l||o[7]!==e?(v=r(()=>{let N=e.current;if(l===null||N===null)return!1;let x=l.suggestions[l.active];if(x===void 0)return!1;let S=Ut(N.value,N.selectionStart,x);return t(S.value),a(null),requestAnimationFrame(()=>{let h=e.current;h!==null&&(h.focus(),h.setSelectionRange(S.caret,S.caret))}),!0},"t3"),o[5]=t,o[6]=l,o[7]=e,o[8]=v):v=o[8];let m=v,f;return o[9]!==m||o[10]!==p||o[11]!==l?(f={close:u,commit:m,move:g,refresh:p,state:l},o[9]=m,o[10]=p,o[11]=l,o[12]=f):f=o[12],f},"useSqlAutocomplete"),Gt={column:"column",keyword:"keyword",table:"table"},Vt=20,Jt=r(s=>{let e=(0,K.c)(17),{listboxId:t,onPick:o,state:l}=s,a=G(),d;e[0]!==l?(d=l===null?void 0:{left:l.left,top:l.top+Vt},e[0]=l,e[1]=d):d=e[1];let p=d;if(l===null)return null;let c;if(e[2]!==t||e[3]!==o||e[4]!==l.active||e[5]!==l.suggestions||e[6]!==a){let y;e[8]!==t||e[9]!==o||e[10]!==l.active||e[11]!==a?(y=r((g,v)=>(0,n.jsxDEV)("li",{"aria-selected":v===l.active,className:oe("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",v===l.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${v.toString()}`,onMouseDown:r(m=>{m.preventDefault(),o(v)},"onMouseDown"),role:"option",children:[(0,n.jsxDEV)("span",{className:"truncate font-mono",children:g.label},void 0,!1),g.detail!==void 0&&(0,n.jsxDEV)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:g.detail},void 0,!1),(0,n.jsxDEV)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:a(Gt[g.kind])},void 0,!1)]},`${g.kind}:${g.label}`,!0),"t32"),e[8]=t,e[9]=o,e[10]=l.active,e[11]=a,e[12]=y):y=e[12],c=l.suggestions.map(y),e[2]=t,e[3]=o,e[4]=l.active,e[5]=l.suggestions,e[6]=a,e[7]=c}else c=e[7];let u;return e[13]!==t||e[14]!==p||e[15]!==c?(u=(0,n.jsxDEV)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:p,children:c},void 0,!1),e[13]=t,e[14]=p,e[15]=c,e[16]=u):u=e[16],u},"AutocompletePopover"),Ue=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Qt=r(s=>{let e=(0,K.c)(29),{active:t,onDelete:o,onSelect:l,query:a}=s,d=G(),p;e[0]!==l||e[1]!==a.id?(p=r(()=>{l(a.id)},"t1"),e[0]=l,e[1]=a.id,e[2]=p):p=e[2];let c=p,u;e[3]!==o||e[4]!==a.id?(u=r(E=>{E.stopPropagation(),o(a.id)},"t2"),e[3]=o,e[4]=a.id,e[5]=u):u=e[5];let y=u,g=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",v;e[6]!==g?(v=oe("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[6]=g,e[7]=v):v=e[7];let m=`sql-query-${a.id}`,f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M4 6h16M4 12h10M4 18h7"},void 0,!1)},void 0,!1),e[8]=f):f=e[8];let N;e[9]!==a.name?(N=(0,n.jsxDEV)("span",{className:"truncate",children:a.name},void 0,!1),e[9]=a.name,e[10]=N):N=e[10];let x;e[11]!==t||e[12]!==c||e[13]!==v||e[14]!==m||e[15]!==N?(x=(0,n.jsxDEV)("button",{"aria-pressed":t,className:v,"data-testid":m,onClick:c,type:"button",children:[f,N]},void 0,!0),e[11]=t,e[12]=c,e[13]=v,e[14]=m,e[15]=N,e[16]=x):x=e[16];let S;e[17]!==d?(S=d("Delete query"),e[17]=d,e[18]=S):S=e[18];let h;e[19]!==d?(h=d("Delete query"),e[19]=d,e[20]=h):h=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[21]=w):w=e[21];let C;e[22]!==y||e[23]!==h||e[24]!==S?(C=(0,n.jsxDEV)("button",{"aria-label":S,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:y,title:h,type:"button",children:w},void 0,!1),e[22]=y,e[23]=h,e[24]=S,e[25]=C):C=e[25];let A;return e[26]!==C||e[27]!==x?(A=(0,n.jsxDEV)("li",{className:"group/q flex items-center",children:[x,C]},void 0,!0),e[26]=C,e[27]=x,e[28]=A):A=e[28],A},"QueryRow"),Xt=r(s=>{let e=(0,K.c)(58),{activeId:t,history:o,listRef:l,onClearHistory:a,onDelete:d,onLoadHistory:p,onLoadTemplate:c,onNew:u,onSearchChange:y,onSelect:g,queries:v,search:m}=s,f=G(),N;if(e[0]!==v||e[1]!==m){let T=m.trim().toLowerCase();N=T===""?[...v]:v.filter(R=>R.name.toLowerCase().includes(T)),e[0]=v,e[1]=m,e[2]=N}else N=e[2];let x=N,S;e[3]!==f?(S=f("Search queries\u2026"),e[3]=f,e[4]=S):S=e[4];let h;e[5]!==y||e[6]!==m||e[7]!==S?(h=(0,n.jsxDEV)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:y,placeholder:S,type:"text",value:m},void 0,!1),e[5]=y,e[6]=m,e[7]=S,e[8]=h):h=e[8];let w;e[9]!==f?(w=f("New query"),e[9]=f,e[10]=w):w=e[10];let C;e[11]!==f?(C=f("New query"),e[11]=f,e[12]=C):C=e[12];let A;e[13]===Symbol.for("react.memo_cache_sentinel")?(A=(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M12 5v14M5 12h14"},void 0,!1)},void 0,!1),e[13]=A):A=e[13];let E;e[14]!==u||e[15]!==w||e[16]!==C?(E=(0,n.jsxDEV)("button",{"aria-label":w,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:u,title:C,type:"button",children:A},void 0,!1),e[14]=u,e[15]=w,e[16]=C,e[17]=E):E=e[17];let M;e[18]!==h||e[19]!==E?(M=(0,n.jsxDEV)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[h,E]},void 0,!0),e[18]=h,e[19]=E,e[20]=M):M=e[20];let D;e[21]!==f?(D=f("Private"),e[21]=f,e[22]=D):D=e[22];let O;e[23]!==D?(O=(0,n.jsxDEV)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:D},void 0,!1),e[23]=D,e[24]=O):O=e[24];let B;e[25]!==t||e[26]!==x||e[27]!==l||e[28]!==d||e[29]!==g||e[30]!==f?(B=x.length===0?(0,n.jsxDEV)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:f("No saved queries yet \u2014 they save to this browser as you type.")},void 0,!1):(0,n.jsxDEV)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:l,children:x.map(T=>(0,n.jsxDEV)(Qt,{active:t===T.id,onDelete:d,onSelect:g,query:T},T.id,!1))},void 0,!1),e[25]=t,e[26]=x,e[27]=l,e[28]=d,e[29]=g,e[30]=f,e[31]=B):B=e[31];let P;e[32]!==O||e[33]!==B?(P=(0,n.jsxDEV)("div",{children:[O,B]},void 0,!0),e[32]=O,e[33]=B,e[34]=P):P=e[34];let _;e[35]!==f?(_=f("Reference"),e[35]=f,e[36]=_):_=e[36];let Y;e[37]!==_?(Y=(0,n.jsxDEV)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_},void 0,!1),e[37]=_,e[38]=Y):Y=e[38];let F;e[39]!==c?(F=Ue.map(T=>(0,n.jsxDEV)("li",{children:(0,n.jsxDEV)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":T.sql,onClick:c,type:"button",children:[(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"},void 0,!1)},void 0,!1),T.label]},void 0,!0)},T.label,!1)),e[39]=c,e[40]=F):F=e[40];let $;e[41]!==F?($=(0,n.jsxDEV)("ul",{className:"flex flex-col gap-px",children:F},void 0,!1),e[41]=F,e[42]=$):$=e[42];let I;e[43]!==Y||e[44]!==$?(I=(0,n.jsxDEV)("div",{children:[Y,$]},void 0,!0),e[43]=Y,e[44]=$,e[45]=I):I=e[45];let L;e[46]!==o||e[47]!==a||e[48]!==p||e[49]!==f?(L=o.length>0&&(0,n.jsxDEV)("div",{children:[(0,n.jsxDEV)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,n.jsxDEV)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f("History")},void 0,!1),(0,n.jsxDEV)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:a,type:"button",children:f("Clear history")},void 0,!1)]},void 0,!0),(0,n.jsxDEV)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:o.map(T=>(0,n.jsxDEV)("li",{children:(0,n.jsxDEV)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":T.sql,"data-testid":"sql-history-item",onClick:p,title:T.sql,type:"button",children:[(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"},void 0,!1)},void 0,!1),(0,n.jsxDEV)("span",{className:"truncate font-mono",children:T.sql},void 0,!1)]},void 0,!0)},`${T.at.toString()}:${T.sql}`,!1))},void 0,!1)]},void 0,!0),e[46]=o,e[47]=a,e[48]=p,e[49]=f,e[50]=L):L=e[50];let W;e[51]!==P||e[52]!==I||e[53]!==L?(W=(0,n.jsxDEV)("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-2",children:[P,I,L]},void 0,!0),e[51]=P,e[52]=I,e[53]=L,e[54]=W):W=e[54];let H;return e[55]!==W||e[56]!==M?(H=(0,n.jsxDEV)("aside",{className:"flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",children:[M,W]},void 0,!0),e[55]=W,e[56]=M,e[57]=H):H=e[57],H},"SqlQuerySidebar"),Zt=ne(le.listTables),eo=ne(le.readTablePage),to=r(s=>{let e=(0,K.c)(16),t=he(),o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let[l,a]=(0,q.useState)(o),d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];let[p,c]=(0,q.useState)(d),u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[2]=u):u=e[2];let y=(0,q.useRef)(u),g,v;e[3]!==t||e[4]!==s?(g=r(()=>{let h={cancelled:!1};return Q(r(async()=>{try{let C=await t.query(Zt,{},se(s));h.cancelled||(a(C.map(no)),c({}),y.current=new Set)}catch{h.cancelled||(a([]),c({}),y.current=new Set)}},"load")()),()=>{h.cancelled=!0}},"t3"),v=[t,s],e[3]=t,e[4]=s,e[5]=g,e[6]=v):(g=e[5],v=e[6]),(0,q.useEffect)(g,v);let m;e[7]!==t||e[8]!==s?(m=r(h=>{if(y.current.has(h))return;y.current.add(h),Q(r(async()=>{try{let C=await t.query(eo,{limit:1,offset:0,table:h},se(s));c(A=>({...A,[h]:C.columns}))}catch{y.current.delete(h)}},"fetchColumns")())},"t5"),e[7]=t,e[8]=s,e[9]=m):m=e[9];let f=m,N;e[10]!==p||e[11]!==l?(N={columns:p,tables:l},e[10]=p,e[11]=l,e[12]=N):N=e[12];let x=N,S;return e[13]!==f||e[14]!==x?(S={probe:f,schema:x},e[13]=f,e[14]=x,e[15]=S):S=e[15],S},"useSqlSchema"),ye=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,oo=r(s=>{let e=new Set;ye.lastIndex=0;let t=ye.exec(s);for(;t!==null;)e.add(t[1]??t[2]),t=ye.exec(s);return[...e]},"referencedTables");function no(s){return s.name}r(no,"_temp$2");var so="lunora-studio-sql-tabs",lo="lunora-studio-sql-active-tab",Se=12,X=r((s="",e="")=>({activeId:null,id:xe("tab"),name:e,sql:s}),"makeTab"),ro=r(()=>ge(lo,""),"usePersistedActive"),io=r(s=>{let[e,t]=re(so),[o,l]=ro(),a=(0,q.useRef)(null);e.length===0&&a.current===null&&(a.current=s()),(0,q.useEffect)(()=>{if(e.length===0&&a.current!==null){let c=a.current;t([c])}},[t,e.length]);let d=e.length===0&&a.current!==null?[a.current]:e;return{activeId:d.some(c=>c.id===o)?o:d[0]?.id??"",setActiveId:l,setTabs:t,tabs:d}},"usePersistedTabs"),Ye=r(s=>s.activeId===null&&s.sql.trim()!=="","isDirty"),ao=r((s,e)=>[...s,e].slice(-Se),"addTab"),co=r((s,e,t)=>{let o=s.findIndex(d=>d.id===e);if(o===-1)return{activeId:s[0]?.id??"",tabs:[...s]};let l=s.filter(d=>d.id!==e);if(l.length===0){let d=t();return{activeId:d.id,tabs:[d]}}return{activeId:l[Math.min(o,l.length-1)].id,tabs:l}},"closeTab"),uo=r((s,e)=>{let t=s.filter(o=>o.id===e);return t.length===0?{activeId:s[0]?.id??"",tabs:[...s]}:{activeId:e,tabs:t}},"closeOtherTabs"),fo=r((s,e,t)=>{let o=s.findIndex(a=>a.id===e);if(o===-1)return{activeId:t,tabs:[...s]};let l=s.slice(0,o+1);return{activeId:l.some(a=>a.id===t)?t:e,tabs:l}},"closeTabsToRight"),mo=r(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"closeAllTabs"),po=r((s,e,t)=>{if(s==="others")return e.filter(o=>o.id!==t);if(s==="right"){let o=e.findIndex(l=>l.id===t);return o===-1?[]:e.slice(o+1)}return[...e]},"tabsClosedBy"),bo=r((s,e)=>s.trim()===""?e:(s.split(`
|
|
3
|
+
`)[0]??s).slice(0,24),"derivedTabLabel"),ho=r(s=>{let e=(0,K.c)(14),{initial:t,onCancel:o,onCommit:l,placeholder:a,testId:d}=s,p=G(),c=xo,u;e[0]!==l?(u=r(N=>{l(N.currentTarget.value.trim())},"t1"),e[0]=l,e[1]=u):u=e[1];let y=u,g;e[2]!==o||e[3]!==l?(g=r(N=>{N.key==="Enter"?l(N.currentTarget.value.trim()):N.key==="Escape"&&o()},"t2"),e[2]=o,e[3]=l,e[4]=g):g=e[4];let v=g,m;e[5]!==p?(m=p("Tab title"),e[5]=p,e[6]=m):m=e[6];let f;return e[7]!==t||e[8]!==y||e[9]!==v||e[10]!==a||e[11]!==m||e[12]!==d?(f=(0,n.jsxDEV)("input",{"aria-label":m,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":d,defaultValue:t,onBlur:y,onKeyDown:v,placeholder:a,ref:c,type:"text"},void 0,!1),e[7]=t,e[8]=y,e[9]=v,e[10]=a,e[11]=m,e[12]=d,e[13]=f):f=e[13],f},"TabRenameInput"),vo=r(s=>{let e=(0,K.c)(29),{idBase:t,onDiscard:o,onKeep:l}=s,a=G(),d=`sql-tab-close-prompt-${t}`,p;e[0]!==a?(p=a("Discard?"),e[0]=a,e[1]=p):p=e[1];let c;e[2]!==p?(c=(0,n.jsxDEV)("span",{className:"text-[11px] text-muted-foreground",children:p},void 0,!1),e[2]=p,e[3]=c):c=e[3];let u;e[4]!==a?(u=a("Discard changes"),e[4]=a,e[5]=u):u=e[5];let y=`sql-tab-close-confirm-${t}`,g;e[6]!==a?(g=a("Discard changes"),e[6]=a,e[7]=g):g=e[7];let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M5 13l4 4L19 7"},void 0,!1)},void 0,!1),e[8]=v):v=e[8];let m;e[9]!==o||e[10]!==u||e[11]!==y||e[12]!==g?(m=(0,n.jsxDEV)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":y,onClick:o,title:g,type:"button",children:v},void 0,!1),e[9]=o,e[10]=u,e[11]=y,e[12]=g,e[13]=m):m=e[13];let f;e[14]!==a?(f=a("Keep editing"),e[14]=a,e[15]=f):f=e[15];let N=`sql-tab-close-cancel-${t}`,x;e[16]!==a?(x=a("Keep editing"),e[16]=a,e[17]=x):x=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1),e[18]=S):S=e[18];let h;e[19]!==l||e[20]!==N||e[21]!==x||e[22]!==f?(h=(0,n.jsxDEV)("button",{"aria-label":f,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":N,onClick:l,title:x,type:"button",children:S},void 0,!1),e[19]=l,e[20]=N,e[21]=x,e[22]=f,e[23]=h):h=e[23];let w;return e[24]!==d||e[25]!==h||e[26]!==c||e[27]!==m?(w=(0,n.jsxDEV)("span",{className:"flex shrink-0 items-center gap-1","data-testid":d,role:"group",children:[c,m,h]},void 0,!0),e[24]=d,e[25]=h,e[26]=c,e[27]=m,e[28]=w):w=e[28],w},"TabCloseConfirm"),go=r(s=>{let e=(0,K.c)(47),{active:t,canClose:o,onClose:l,onMenu:a,onRename:d,onSelect:p,tab:c}=s,u=G(),[y,g]=(0,q.useState)(!1),[v,m]=(0,q.useState)(!1),f;e[0]!==a||e[1]!==c.id?(f=r(z=>{a(c.id,z)},"t1"),e[0]=a,e[1]=c.id,e[2]=f):f=e[2];let N=f,x;e[3]!==p||e[4]!==c.id?(x=r(()=>{p(c.id)},"t2"),e[3]=p,e[4]=c.id,e[5]=x):x=e[5];let S=x,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=r(()=>{g(!0)},"t3"),e[6]=h):h=e[6];let w=h,C;e[7]!==l||e[8]!==c?(C=r(z=>{z.stopPropagation(),Ye(c)?m(!0):l(c.id)},"t4"),e[7]=l,e[8]=c,e[9]=C):C=e[9];let A=C,E;e[10]!==l||e[11]!==c.id?(E=r(z=>{z.stopPropagation(),m(!1),l(c.id)},"t5"),e[10]=l,e[11]=c.id,e[12]=E):E=e[12];let M=E,D;e[13]===Symbol.for("react.memo_cache_sentinel")?(D=r(z=>{z.stopPropagation(),m(!1)},"t6"),e[13]=D):D=e[13];let O=D,B;e[14]!==d||e[15]!==c.id?(B=r(z=>{d(c.id,z),g(!1)},"t7"),e[14]=d,e[15]=c.id,e[16]=B):B=e[16];let P=B,_;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=r(()=>{g(!1)},"t8"),e[17]=_):_=e[17];let Y=_,F;e[18]!==c.name?(F=c.name.trim(),e[18]=c.name,e[19]=F):F=e[19];let $=F,I;e[20]!==u||e[21]!==c.sql?(I=bo(c.sql,u("Untitled")),e[20]=u,e[21]=c.sql,e[22]=I):I=e[22];let L=I,W=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",H;e[23]!==W?(H=oe("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",W),e[23]=W,e[24]=H):H=e[24];let T=`sql-tab-${c.id}`,R;e[25]!==t||e[26]!==P||e[27]!==$||e[28]!==L||e[29]!==y||e[30]!==S||e[31]!==u||e[32]!==c.id?(R=y?(0,n.jsxDEV)(ho,{initial:$,onCancel:Y,onCommit:P,placeholder:L,testId:`sql-tab-rename-${c.id}`},void 0,!1):(0,n.jsxDEV)("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:S,onDoubleClick:w,title:u("Double-click to rename"),type:"button",children:$===""?L:$},void 0,!1),e[25]=t,e[26]=P,e[27]=$,e[28]=L,e[29]=y,e[30]=S,e[31]=u,e[32]=c.id,e[33]=R):R=e[33];let j;e[34]!==o||e[35]!==M||e[36]!==v||e[37]!==A||e[38]!==u||e[39]!==c.id?(j=o&&(v?(0,n.jsxDEV)(vo,{idBase:c.id,onDiscard:M,onKeep:O},void 0,!1):(0,n.jsxDEV)("button",{"aria-label":u("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:A,title:u("Close tab"),type:"button",children:(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1)},void 0,!1)),e[34]=o,e[35]=M,e[36]=v,e[37]=A,e[38]=u,e[39]=c.id,e[40]=j):j=e[40];let J;return e[41]!==N||e[42]!==H||e[43]!==T||e[44]!==R||e[45]!==j?(J=(0,n.jsxDEV)("div",{className:H,"data-testid":T,onContextMenu:N,children:[R,j]},void 0,!0),e[41]=N,e[42]=H,e[43]=T,e[44]=R,e[45]=j,e[46]=J):J=e[46],J},"TabButton");function xo(s){s?.focus(),s?.select()}r(xo,"_temp$1");var yo=ne(le.runSql),No="lunora-studio-sql-queries",So="lunora-studio-sql-history",ko="lunora-studio-sql-split-view",Co=25,wo={minWidth:"2.75rem",paddingInline:"0.5rem"},Ne={error:null,pane:"results",result:null},To=r(s=>{let e=(0,K.c)(16),{result:t}=s;if(t.columns.length===0){let c=t.rowCount===0?"0 rows":"",u;return e[0]!==c?(u=(0,n.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground",children:c},void 0,!1),e[0]=c,e[1]=u):u=e[1],u}let o;e[2]!==t.columns?(o=t.columns.map(Eo),e[2]=t.columns,e[3]=o):o=e[3];let l;e[4]!==o?(l=(0,n.jsxDEV)(Ae,{className:"sticky top-0 z-10 bg-muted",children:(0,n.jsxDEV)(ve,{children:o},void 0,!1)},void 0,!1),e[4]=o,e[5]=l):l=e[5];let a;if(e[6]!==t.columns||e[7]!==t.rows){let c;e[9]!==t.columns?(c=r((u,y)=>(0,n.jsxDEV)(ve,{"data-testid":"sql-row",children:t.columns.map(g=>(0,n.jsxDEV)(De,{className:"max-w-md truncate font-mono text-xs",children:(0,n.jsxDEV)(Be,{value:u[g]},void 0,!1)},g,!1))},y,!1),"t42"),e[9]=t.columns,e[10]=c):c=e[10],a=t.rows.map(c),e[6]=t.columns,e[7]=t.rows,e[8]=a}else a=e[8];let d;e[11]!==a?(d=(0,n.jsxDEV)(Oe,{children:a},void 0,!1),e[11]=a,e[12]=d):d=e[12];let p;return e[13]!==l||e[14]!==d?(p=(0,n.jsxDEV)(Le,{"data-testid":"sql-rows",children:[l,d]},void 0,!0),e[13]=l,e[14]=d,e[15]=p):p=e[15],p},"SqlResultTable"),Wo=r(({initialShardKey:s})=>{let e=he(),t=G(),[o,l]=re(No),[a,d]=re(So),[p,c]=(0,q.useState)(""),u=r(()=>X(Ue[0]?.sql??""),"seedTab"),{activeId:y,setActiveId:g,setTabs:v,tabs:m}=io(u),[f,N]=(0,q.useState)({}),[x,S]=(0,q.useState)(s??""),[h,w]=(0,q.useState)(!1),[C,A]=ge(ko,!1),[E,M]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),B=(0,q.useRef)(null),P=(0,q.useRef)(null),_=(0,q.useRef)(null),Y=(0,q.useId)(),{probe:F,schema:$}=to(x),I=m.find(i=>i.id===y)??m[0]??X(),L=I.sql,{activeId:W}=I,H=f[I.id]??Ne,{error:T,result:R}=H,j=H.pane,J=r(i=>{v(b=>b.map(k=>k.id===I.id?{...k,...i}:k))},"patchActiveTab"),z=r(i=>{N(b=>{let k=b[I.id]??Ne;return{...b,[I.id]:{error:i.error,pane:i.pane??k.pane,result:i.result}}})},"setActiveOutput"),Ce=r(i=>{N(b=>{let k=b[I.id]??Ne;return{...b,[I.id]:{...k,pane:i}}})},"setActivePane"),ce=r(i=>{J({sql:i}),W!==null&&l(b=>b.map(k=>k.id===W?{...k,sql:i}:k))},"setDraft"),je=Kt($,P,ce),{close:de,commit:we,move:ue,refresh:Z,state:V}=je,Ke=r(i=>{ue(i-(V?.active??0)),we()},"onPickSuggestion");(0,q.useEffect)(()=>{let i=P.current;i!==null&&i===document.activeElement&&Z(i.value,i.selectionStart)},[Z,$]);let Ge=r(i=>{d(b=>b[0]?.sql===i?b:[{at:Date.now(),sql:i},...b.filter(U=>U.sql!==i)].slice(0,Co))},"recordHistory"),fe=r(async i=>{if(L.trim()==="")return;w(!0);let b=i==="explain"?`EXPLAIN QUERY PLAN ${L}`:L;try{let k=await e.query(yo,{sql:b},se(x));z({error:null,pane:i,result:k}),qe(x),Ge(b)}catch(k){z({error:Ee(k),pane:i,result:null})}finally{w(!1)}},"run"),Ve=r(()=>{Q(fe("results"))},"onRun"),Je=r(i=>{let{selectionStart:b,value:k}=i.target;ce(k);for(let U of oo(k))F(U);Z(k,b)},"onDraftChange"),Qe=r(i=>{let b=i.currentTarget;Z(b.value,b.selectionStart)},"onEditorSelect"),Xe=r(i=>{if(V!==null){if(i.key==="ArrowDown"){i.preventDefault(),ue(1);return}if(i.key==="ArrowUp"){i.preventDefault(),ue(-1);return}if(i.key==="Escape"){i.preventDefault(),de();return}if((i.key==="Enter"||i.key==="Tab")&&!i.metaKey&&!i.ctrlKey&&we()){i.preventDefault();return}}(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),Q(fe(j)))},"onEditorKeyDown"),Ze=r(()=>{requestAnimationFrame(()=>{de()})},"onEditorBlur"),et=r(i=>{B.current!==null&&(B.current.scrollTop=i.currentTarget.scrollTop)},"onEditorScroll"),ee=r((i,b)=>{v(k=>k.map(U=>U.id===I.id?{...U,activeId:b,sql:i}:U)),z({error:null,result:null})},"loadIntoActiveTab"),tt=r(()=>{let i={id:xe("q"),name:t("Untitled query"),sql:""};l(b=>[i,...b]),ee("",i.id)},"newQuery"),ot=r(i=>{let b=o.find(k=>k.id===i);b!==void 0&&(ee(b.sql,i),_.current?.querySelector(`[data-testid="sql-query-${i}"]`)?.scrollIntoView({block:"nearest"}))},"selectQuery"),nt=r(i=>{l(b=>b.filter(k=>k.id!==i)),v(b=>b.map(k=>k.activeId===i?{...k,activeId:null}:k))},"deleteQuery"),st=r(i=>{ee(i.currentTarget.dataset.sql??"",null)},"loadTemplate"),lt=r(i=>{ee(i.currentTarget.dataset.sql??"",null)},"loadFromHistory"),rt=r(()=>{d([])},"clearHistory"),it=r(()=>{ce($t(L))},"formatDraft"),at=r(()=>{if(m.length>=Se)return;let i=X();v(b=>ao(b,i)),g(i.id)},"addEditorTab"),te=r(i=>{M(null),O(null),v(i.tabs),g(i.activeId);let b=new Set(i.tabs.map(k=>k.id));N(k=>Object.fromEntries(Object.entries(k).filter(([U])=>b.has(U))))},"commitTabs"),ct=r(i=>{te(co(m,i,X))},"closeEditorTab"),Te=r((i,b)=>{te(i==="others"?uo(m,b):i==="right"?fo(m,b,y):mo(X))},"applyBulk"),me=r(i=>{E!==null&&(po(i,m,E.id).some(b=>Ye(b))?O(i):Te(i,E.id))},"requestBulk"),dt=r((i,b)=>{b.preventDefault(),O(null),M({id:i,x:b.clientX,y:b.clientY})},"openTabMenu"),ut=r(()=>{M(null),O(null)},"closeTabMenu"),ft=r(i=>{i.preventDefault(),M(null),O(null)},"onBackdropContextMenu"),mt=r(()=>{me("others")},"onCloseOthers"),pt=r(()=>{me("right")},"onCloseToRight"),bt=r(()=>{me("all")},"onCloseAll"),ht=r(()=>{E!==null&&D!==null&&Te(D,E.id),O(null)},"confirmBulk"),vt=r(()=>{O(null)},"cancelBulk"),gt=E===null?void 0:{left:E.x,top:E.y},xt=r(i=>{de(),g(i)},"selectTab"),yt=r((i,b)=>{v(k=>k.map(U=>U.id===i?{...U,name:b}:U))},"renameTab"),Nt=r(()=>{Ce("results")},"showResults"),St=r(()=>{Q(fe("explain"))},"showExplain"),kt=r(()=>{Ce("chart")},"showChart"),Ct=r(()=>{A(!C)},"toggleSplit"),wt=L.split(`
|
|
4
|
+
`).length,Tt=r(i=>{c(i.target.value)},"onSearchChange"),pe=r(i=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${i?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"tabClass"),Et=C?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",qt=C?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return(0,n.jsxDEV)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,n.jsxDEV)(Xt,{activeId:W,history:a,listRef:_,onClearHistory:rt,onDelete:nt,onLoadHistory:lt,onLoadTemplate:st,onNew:tt,onSearchChange:Tt,onSelect:ot,queries:o,search:p},void 0,!1),(0,n.jsxDEV)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,n.jsxDEV)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[m.map(i=>(0,n.jsxDEV)(go,{active:i.id===I.id,canClose:m.length>1,onClose:ct,onMenu:dt,onRename:yt,onSelect:xt,tab:i},i.id,!1)),(0,n.jsxDEV)("button",{"aria-label":t("New tab"),className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:m.length>=Se,onClick:at,title:t("New tab"),type:"button",children:(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,n.jsxDEV)("path",{d:"M12 5v14M5 12h14"},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0),E!==null&&(0,n.jsxDEV)(n.Fragment,{children:[(0,n.jsxDEV)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:ut,onContextMenu:ft,role:"presentation"},void 0,!1),(0,n.jsxDEV)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:gt,children:D===null?(0,n.jsxDEV)(n.Fragment,{children:[(0,n.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:m.length<=1,onClick:mt,role:"menuitem",type:"button",children:t("Close other tabs")},void 0,!1),(0,n.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:m.findIndex(i=>i.id===E.id)>=m.length-1,onClick:pt,role:"menuitem",type:"button",children:t("Close tabs to the right")},void 0,!1),(0,n.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:bt,role:"menuitem",type:"button",children:t("Close all tabs")},void 0,!1)]},void 0,!0):(0,n.jsxDEV)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,n.jsxDEV)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:t("Discard unsaved tabs?")},void 0,!1),(0,n.jsxDEV)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:ht,type:"button",children:t("Discard")},void 0,!1),(0,n.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:vt,type:"button",children:t("Cancel")},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,n.jsxDEV)("div",{className:Et,children:[(0,n.jsxDEV)("div",{className:"flex min-h-0 min-w-0 flex-1",children:[(0,n.jsxDEV)("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:B,style:wo,children:Array.from({length:wt},(i,b)=>(0,n.jsxDEV)("div",{children:b+1},b,!1))},void 0,!1),(0,n.jsxDEV)("div",{className:"relative min-w-0 flex-1",children:[(0,n.jsxDEV)("textarea",{"aria-activedescendant":V===null?void 0:`${Y}-opt-${V.active.toString()}`,"aria-autocomplete":"list","aria-controls":V===null?void 0:Y,"aria-expanded":V!==null,"aria-label":t("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Ze,onChange:Je,onKeyDown:Xe,onScroll:et,onSelect:Qe,placeholder:"SELECT * FROM \u2026",ref:P,role:"combobox",spellCheck:!1,value:L},void 0,!1),(0,n.jsxDEV)(Jt,{listboxId:Y,onPick:Ke,state:V},void 0,!1)]},void 0,!0)]},void 0,!0),(0,n.jsxDEV)("div",{className:qt,children:[(0,n.jsxDEV)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[(0,n.jsxDEV)("button",{className:pe(j==="results"),"data-testid":"sql-tab-results",onClick:Nt,type:"button",children:t("Results")},void 0,!1),(0,n.jsxDEV)("button",{className:pe(j==="chart"),"data-testid":"sql-tab-chart",onClick:kt,type:"button",children:t("Chart")},void 0,!1),(0,n.jsxDEV)("button",{className:pe(j==="explain"),"data-testid":"sql-tab-explain",onClick:St,type:"button",children:t("Explain")},void 0,!1),(0,n.jsxDEV)("div",{className:"ms-auto flex items-center gap-2",children:[(0,n.jsxDEV)("button",{"aria-label":t("Split editor and results"),"aria-pressed":C,className:`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${C?"bg-accent text-foreground":"text-muted-foreground"}`,"data-testid":"sql-split-toggle",onClick:Ct,title:t("Split editor and results"),type:"button",children:(0,n.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,n.jsxDEV)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"},void 0,!1),(0,n.jsxDEV)("path",{d:"M12 4v16"},void 0,!1)]},void 0,!0)},void 0,!1),R!==null&&R.columns.length>0&&(0,n.jsxDEV)($e,{columns:R.columns,name:"query-result",rows:R.rows},void 0,!1),(0,n.jsxDEV)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:h,onClick:it,type:"button",children:t("Format")},void 0,!1),(0,n.jsxDEV)(Ie,{onChange:S,testId:"sql-shard-input",value:x},void 0,!1),(0,n.jsxDEV)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:h,onClick:Ve,type:"button",children:[t(h?"Running\u2026":"Run"),(0,n.jsxDEV)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,n.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-auto",children:[T!==null&&(0,n.jsxDEV)(Re,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:T},void 0,!1),T===null&&R===null&&(0,n.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:t("Click Run to execute your query.")},void 0,!1),T===null&&R!==null&&(0,n.jsxDEV)("div",{"data-testid":"sql-result",children:[j==="chart"?(0,n.jsxDEV)(Pe,{result:R},void 0,!1):(0,n.jsxDEV)(To,{result:R},void 0,!1),(0,n.jsxDEV)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:R.truncated?t("Showing the first {max} of {count} rows.",{count:R.rowCount,max:R.rows.length}):t("{count} rows",{count:R.rowCount})},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"SqlEditorPanel");function Eo(s){return(0,n.jsxDEV)(Me,{children:s},s,!1)}r(Eo,"_temp");export{Wo as SqlEditorPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as N,j as x}from"./chunk-E75ANNWX.js";import{a as m,e as w,g as y,h as C}from"./chunk-RRCPZMC2.js";var v=w(y(),1);var o=w(C(),1);var T=m(b=>{let e=(0,v.c)(8),{value:l}=b;if(l==null){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,o.jsxDEV)("span",{className:"text-muted-foreground/50 italic",children:"NULL"},void 0,!1),e[0]=a):a=e[0],a}let t;e[1]!==l?(t=x(l),e[1]=l,e[2]=t):t=e[2];let r;e[3]!==l?(r=x(l),e[3]=l,e[4]=r):r=e[4];let s;return e[5]!==t||e[6]!==r?(s=(0,o.jsxDEV)("span",{title:t,children:r},void 0,!1),e[5]=t,e[6]=r,e[7]=s):s=e[7],s},"CellValue"),G=m(b=>{let e=(0,v.c)(22),{columns:l,rows:t}=b,r=N(),s;e[0]!==r?(s=r("Field"),e[0]=r,e[1]=s):s=e[1];let a;e[2]!==s?(a=(0,o.jsxDEV)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=a):a=e[3];let i;if(e[4]!==t||e[5]!==r){let d;e[7]!==r?(d=m((u,h)=>(0,o.jsxDEV)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:r("Row {n}",{n:h+1})},h,!1),"t42"),e[7]=r,e[8]=d):d=e[8],i=t.map(d),e[4]=t,e[5]=r,e[6]=i}else i=e[6];let n;e[9]!==a||e[10]!==i?(n=(0,o.jsxDEV)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,o.jsxDEV)("tr",{children:[a,i]},void 0,!0)},void 0,!1),e[9]=a,e[10]=i,e[11]=n):n=e[11];let f;if(e[12]!==l||e[13]!==t){let d;e[15]!==t?(d=m(u=>(0,o.jsxDEV)("tr",{className:"hover:bg-muted/40",children:[(0,o.jsxDEV)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:u},void 0,!1),t.map((h,g)=>(0,o.jsxDEV)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,o.jsxDEV)(T,{value:h[u]},void 0,!1)},g,!1))]},u,!0),"t62"),e[15]=t,e[16]=d):d=e[16],f=l.map(d),e[12]=l,e[13]=t,e[14]=f}else f=e[14];let c;e[17]!==f?(c=(0,o.jsxDEV)("tbody",{children:f},void 0,!1),e[17]=f,e[18]=c):c=e[18];let p;return e[19]!==n||e[20]!==c?(p=(0,o.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,o.jsxDEV)("table",{className:"border-collapse text-xs",children:[n,c]},void 0,!0)},void 0,!1),e[19]=n,e[20]=c,e[21]=p):p=e[21],p},"TransposedTable"),L=m(({children:b,layout:e="card",testId:l})=>(0,o.jsxDEV)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:b},void 0,!1),"GridContainer");export{T as a,G as b,L as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-RRCPZMC2.js";function S(e,r,t){e.prototype=r.prototype=t,t.constructor=e}f(S,"default");function W(e,r){var t=Object.create(e.prototype);for(var n in r)t[n]=r[n];return t}f(W,"extend");function B(){}f(B,"Color");var C=.7,Y=1/C,R="\\s*([+-]?\\d+)\\s*",E="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",y="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Xe=/^#([0-9a-f]{3,8})$/,Se=new RegExp(`^rgb\\(${R},${R},${R}\\)$`),Ce=new RegExp(`^rgb\\(${y},${y},${y}\\)$`),Ee=new RegExp(`^rgba\\(${R},${R},${R},${E}\\)$`),Be=new RegExp(`^rgba\\(${y},${y},${y},${E}\\)$`),Ie=new RegExp(`^hsl\\(${E},${y},${y}\\)$`),_e=new RegExp(`^hsla\\(${E},${y},${y},${E}\\)$`),se={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};S(B,v,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:le,formatHex:le,formatHex8:je,formatHsl:Ye,formatRgb:ue,toString:ue});function le(){return this.rgb().formatHex()}f(le,"color_formatHex");function je(){return this.rgb().formatHex8()}f(je,"color_formatHex8");function Ye(){return ge(this).formatHsl()}f(Ye,"color_formatHsl");function ue(){return this.rgb().formatRgb()}f(ue,"color_formatRgb");function v(e){var r,t;return e=(e+"").trim().toLowerCase(),(r=Xe.exec(e))?(t=r[1].length,r=parseInt(r[1],16),t===6?xe(r):t===3?new d(r>>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):t===8?_(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):t===4?_(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=Se.exec(e))?new d(r[1],r[2],r[3],1):(r=Ce.exec(e))?new d(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=Ee.exec(e))?_(r[1],r[2],r[3],r[4]):(r=Be.exec(e))?_(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Ie.exec(e))?he(r[1],r[2]/100,r[3]/100,1):(r=_e.exec(e))?he(r[1],r[2]/100,r[3]/100,r[4]):se.hasOwnProperty(e)?xe(se[e]):e==="transparent"?new d(NaN,NaN,NaN,0):null}f(v,"color");function xe(e){return new d(e>>16&255,e>>8&255,e&255,1)}f(xe,"rgbn");function _(e,r,t,n){return n<=0&&(e=r=t=NaN),new d(e,r,t,n)}f(_,"rgba");function Le(e){return e instanceof B||(e=v(e)),e?(e=e.rgb(),new d(e.r,e.g,e.b,e.opacity)):new d}f(Le,"rgbConvert");function H(e,r,t,n){return arguments.length===1?Le(e):new d(e,r,t,n??1)}f(H,"rgb");function d(e,r,t,n){this.r=+e,this.g=+r,this.b=+t,this.opacity=+n}f(d,"Rgb");S(d,H,W(B,{brighter(e){return e=e==null?Y:Math.pow(Y,e),new d(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?C:Math.pow(C,e),new d(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new d(k(this.r),k(this.g),k(this.b),L(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ce,formatHex:ce,formatHex8:Te,formatRgb:pe,toString:pe}));function ce(){return`#${N(this.r)}${N(this.g)}${N(this.b)}`}f(ce,"rgb_formatHex");function Te(){return`#${N(this.r)}${N(this.g)}${N(this.b)}${N((isNaN(this.opacity)?1:this.opacity)*255)}`}f(Te,"rgb_formatHex8");function pe(){let e=L(this.opacity);return`${e===1?"rgb(":"rgba("}${k(this.r)}, ${k(this.g)}, ${k(this.b)}${e===1?")":`, ${e})`}`}f(pe,"rgb_formatRgb");function L(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}f(L,"clampa");function k(e){return Math.max(0,Math.min(255,Math.round(e)||0))}f(k,"clampi");function N(e){return e=k(e),(e<16?"0":"")+e.toString(16)}f(N,"hex");function he(e,r,t,n){return n<=0?e=r=t=NaN:t<=0||t>=1?e=r=NaN:r<=0&&(e=NaN),new w(e,r,t,n)}f(he,"hsla");function ge(e){if(e instanceof w)return new w(e.h,e.s,e.l,e.opacity);if(e instanceof B||(e=v(e)),!e)return new w;if(e instanceof w)return e;e=e.rgb();var r=e.r/255,t=e.g/255,n=e.b/255,i=Math.min(r,t,n),o=Math.max(r,t,n),a=NaN,s=o-i,x=(o+i)/2;return s?(r===o?a=(t-n)/s+(t<n)*6:t===o?a=(n-r)/s+2:a=(r-t)/s+4,s/=x<.5?o+i:2-o-i,a*=60):s=x>0&&x<1?0:a,new w(a,s,x,e.opacity)}f(ge,"hslConvert");function me(e,r,t,n){return arguments.length===1?ge(e):new w(e,r,t,n??1)}f(me,"hsl");function w(e,r,t,n){this.h=+e,this.s=+r,this.l=+t,this.opacity=+n}f(w,"Hsl");S(w,me,W(B,{brighter(e){return e=e==null?Y:Math.pow(Y,e),new w(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?C:Math.pow(C,e),new w(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,r=isNaN(e)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*r,i=2*t-n;return new d(Z(e>=240?e-240:e+120,i,n),Z(e,i,n),Z(e<120?e+240:e-120,i,n),this.opacity)},clamp(){return new w(de(this.h),j(this.s),j(this.l),L(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=L(this.opacity);return`${e===1?"hsl(":"hsla("}${de(this.h)}, ${j(this.s)*100}%, ${j(this.l)*100}%${e===1?")":`, ${e})`}`}}));function de(e){return e=(e||0)%360,e<0?e+360:e}f(de,"clamph");function j(e){return Math.max(0,Math.min(1,e||0))}f(j,"clampt");function Z(e,r,t){return(e<60?r+(t-r)*e/60:e<180?t:e<240?r+(t-r)*(240-e)/60:r)*255}f(Z,"hsl2rgb");function F(e,r,t,n,i){var o=e*e,a=o*e;return((1-3*e+3*o-a)*r+(4-6*o+3*a)*t+(1+3*e+3*o-3*a)*n+a*i)/6}f(F,"basis");function J(e){var r=e.length-1;return function(t){var n=t<=0?t=0:t>=1?(t=1,r-1):Math.floor(t*r),i=e[n],o=e[n+1],a=n>0?e[n-1]:2*i-o,s=n<r-1?e[n+2]:2*o-i;return F((t-n/r)*r,a,i,o,s)}}f(J,"default");function U(e){var r=e.length;return function(t){var n=Math.floor(((t%=1)<0?++t:t)*r),i=e[(n+r-1)%r],o=e[n%r],a=e[(n+1)%r],s=e[(n+2)%r];return F((t-n/r)*r,i,o,a,s)}}f(U,"default");var I=f(e=>()=>e,"default");function De(e,r){return function(t){return e+t*r}}f(De,"linear");function Oe(e,r,t){return e=Math.pow(e,t),r=Math.pow(r,t)-e,t=1/t,function(n){return Math.pow(e+n*r,t)}}f(Oe,"exponential");function be(e){return(e=+e)==1?T:function(r,t){return t-r?Oe(r,t,e):I(isNaN(r)?t:r)}}f(be,"gamma");function T(e,r){var t=r-e;return t?De(e,t):I(isNaN(e)?r:e)}f(T,"nogamma");var D=f((function e(r){var t=be(r);function n(i,o){var a=t((i=H(i)).r,(o=H(o)).r),s=t(i.g,o.g),x=t(i.b,o.b),l=T(i.opacity,o.opacity);return function(u){return i.r=a(u),i.g=s(u),i.b=x(u),i.opacity=l(u),i+""}}return f(n,"rgb"),n.gamma=e,n}),"rgbGamma")(1);function we(e){return function(r){var t=r.length,n=new Array(t),i=new Array(t),o=new Array(t),a,s;for(a=0;a<t;++a)s=H(r[a]),n[a]=s.r||0,i[a]=s.g||0,o[a]=s.b||0;return n=e(n),i=e(i),o=e(o),s.opacity=1,function(x){return s.r=n(x),s.g=i(x),s.b=o(x),s+""}}}f(we,"rgbSpline");var ze=we(J),Pe=we(U);function ee(e,r){r||(r=[]);var t=e?Math.min(r.length,e.length):0,n=r.slice(),i;return function(o){for(i=0;i<t;++i)n[i]=e[i]*(1-o)+r[i]*o;return n}}f(ee,"default");function ye(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}f(ye,"isNumberArray");function ve(e,r){var t=r?r.length:0,n=e?Math.min(t,e.length):0,i=new Array(n),o=new Array(t),a;for(a=0;a<n;++a)i[a]=M(e[a],r[a]);for(;a<t;++a)o[a]=r[a];return function(s){for(a=0;a<n;++a)o[a]=i[a](s);return o}}f(ve,"genericArray");function re(e,r){var t=new Date;return e=+e,r=+r,function(n){return t.setTime(e*(1-n)+r*n),t}}f(re,"default");function g(e,r){return e=+e,r=+r,function(t){return e*(1-t)+r*t}}f(g,"default");function te(e,r){var t={},n={},i;(e===null||typeof e!="object")&&(e={}),(r===null||typeof r!="object")&&(r={});for(i in r)i in e?t[i]=M(e[i],r[i]):n[i]=r[i];return function(o){for(i in t)n[i]=t[i](o);return n}}f(te,"default");var fe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ne=new RegExp(fe.source,"g");function Ve(e){return function(){return e}}f(Ve,"zero");function Qe(e){return function(r){return e(r)+""}}f(Qe,"one");function O(e,r){var t=fe.lastIndex=ne.lastIndex=0,n,i,o,a=-1,s=[],x=[];for(e=e+"",r=r+"";(n=fe.exec(e))&&(i=ne.exec(r));)(o=i.index)>t&&(o=r.slice(t,o),s[a]?s[a]+=o:s[++a]=o),(n=n[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,x.push({i:a,x:g(n,i)})),t=ne.lastIndex;return t<r.length&&(o=r.slice(t),s[a]?s[a]+=o:s[++a]=o),s.length<2?x[0]?Qe(x[0].x):Ve(r):(r=x.length,function(l){for(var u=0,c;u<r;++u)s[(c=x[u]).i]=c.x(l);return s.join("")})}f(O,"default");function M(e,r){var t=typeof r,n;return r==null||t==="boolean"?I(r):(t==="number"?g:t==="string"?(n=v(r))?(r=n,D):O:r instanceof v?D:r instanceof Date?re:ye(r)?ee:Array.isArray(r)?ve:typeof r.valueOf!="function"&&typeof r.toString!="function"||isNaN(r)?te:g)(e,r)}f(M,"default");var Ge=1e-12;function Me(e){return((e=Math.exp(e))+1/e)/2}f(Me,"cosh");function Ke(e){return((e=Math.exp(e))-1/e)/2}f(Ke,"sinh");function We(e){return((e=Math.exp(2*e))-1)/(e+1)}f(We,"tanh");var Ze=f((function e(r,t,n){function i(o,a){var s=o[0],x=o[1],l=o[2],u=a[0],c=a[1],p=a[2],h=u-s,b=c-x,m=h*h+b*b,$,A;if(m<Ge)A=Math.log(p/l)/r,$=f(function(X){return[s+X*h,x+X*b,l*Math.exp(r*X*A)]},"i");else{var Q=Math.sqrt(m),G=(p*p-l*l+n*m)/(2*l*t*Q),K=(p*p-l*l-n*m)/(2*p*t*Q),q=Math.log(Math.sqrt(G*G+1)-G),qe=Math.log(Math.sqrt(K*K+1)-K);A=(qe-q)/r,$=f(function(X){var ie=X*A,ae=Me(q),oe=l/(t*Q)*(ae*We(r*ie+q)-Ke(q));return[s+oe*h,x+oe*b,l*ae/Me(r*ie+q)]},"i")}return $.duration=A*1e3*r/Math.SQRT2,$}return f(i,"zoom"),i.rho=function(o){var a=Math.max(.001,+o),s=a*a,x=s*s;return e(a,s,x)},i}),"zoomRho")(Math.SQRT2,2,4);function $e(e,r){return e=+e,r=+r,function(t){return Math.round(e*(1-t)+r*t)}}f($e,"default");var Ne=180/Math.PI,z={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function P(e,r,t,n,i,o){var a,s,x;return(a=Math.sqrt(e*e+r*r))&&(e/=a,r/=a),(x=e*t+r*n)&&(t-=e*x,n-=r*x),(s=Math.sqrt(t*t+n*n))&&(t/=s,n/=s,x/=s),e*n<r*t&&(e=-e,r=-r,x=-x,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(r,e)*Ne,skewX:Math.atan(x)*Ne,scaleX:a,scaleY:s}}f(P,"default");var V;function ke(e){let r=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return r.isIdentity?z:P(r.a,r.b,r.c,r.d,r.e,r.f)}f(ke,"parseCss");function Re(e){return e==null?z:(V||(V=document.createElementNS("http://www.w3.org/2000/svg","g")),V.setAttribute("transform",e),(e=V.transform.baseVal.consolidate())?(e=e.matrix,P(e.a,e.b,e.c,e.d,e.e,e.f)):z)}f(Re,"parseSvg");function He(e,r,t,n){function i(l){return l.length?l.pop()+" ":""}f(i,"pop");function o(l,u,c,p,h,b){if(l!==c||u!==p){var m=h.push("translate(",null,r,null,t);b.push({i:m-4,x:g(l,c)},{i:m-2,x:g(u,p)})}else(c||p)&&h.push("translate("+c+r+p+t)}f(o,"translate");function a(l,u,c,p){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),p.push({i:c.push(i(c)+"rotate(",null,n)-2,x:g(l,u)})):u&&c.push(i(c)+"rotate("+u+n)}f(a,"rotate");function s(l,u,c,p){l!==u?p.push({i:c.push(i(c)+"skewX(",null,n)-2,x:g(l,u)}):u&&c.push(i(c)+"skewX("+u+n)}f(s,"skewX");function x(l,u,c,p,h,b){if(l!==c||u!==p){var m=h.push(i(h)+"scale(",null,",",null,")");b.push({i:m-4,x:g(l,c)},{i:m-2,x:g(u,p)})}else(c!==1||p!==1)&&h.push(i(h)+"scale("+c+","+p+")")}return f(x,"scale"),function(l,u){var c=[],p=[];return l=e(l),u=e(u),o(l.translateX,l.translateY,u.translateX,u.translateY,c,p),a(l.rotate,u.rotate,c,p),s(l.skewX,u.skewX,c,p),x(l.scaleX,l.scaleY,u.scaleX,u.scaleY,c,p),l=u=null,function(h){for(var b=-1,m=p.length,$;++b<m;)c[($=p[b]).i]=$.x(h);return c.join("")}}}f(He,"interpolateTransform");var Fe=He(ke,"px, ","px)","deg)"),Je=He(Re,", ",")",")");function Ae(e,r){r===void 0&&(r=e,e=M);for(var t=0,n=r.length-1,i=r[0],o=new Array(n<0?0:n);t<n;)o[t]=e(i,i=r[++t]);return function(a){var s=Math.max(0,Math.min(n-1,Math.floor(a*=n)));return o[s](a-s)}}f(Ae,"piecewise");export{v as a,D as b,g as c,O as d,M as e,$e as f,Fe as g,Je as h,Ze as i,Ae as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as de,e as j}from"./chunk-SG3ALJJU.js";import{a as ce}from"./chunk-UGUEC6BC.js";import"./chunk-DC72CQY4.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{a as ie}from"./chunk-TBMYIZIO.js";import"./chunk-HV7G6DFP.js";import{a as E}from"./chunk-BOXSWNXZ.js";import{b as ne}from"./chunk-C7WTJLC3.js";import{a as S}from"./chunk-SEU5V7I6.js";import{b as A}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as ae,g as le}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as D,e as T,f as H,g as Q,k as F,o as oe}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as h,e as k,f as ke,g as re,h as se,j as w}from"./chunk-RRCPZMC2.js";var ve=k(re(),1);var c=k(ke(),1);var ue=k(re(),1);var W=k(se(),1);var Ae={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},fe=h(()=>{let t=(0,ue.c)(16),e=D(),a=le(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}default:s=a}let l=Ae[a],d;t[8]!==l?(d=w("size-2 rounded-full",l),t[8]=l,t[9]=d):d=t[9];let u;t[10]!==d?(u=(0,W.jsxDEV)("span",{"aria-hidden":"true",className:d},void 0,!1),t[10]=d,t[11]=u):u=t[11];let i;return t[12]!==a||t[13]!==u||t[14]!==s?(i=(0,W.jsxDEV)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[u,s]},void 0,!0),t[12]=a,t[13]=u,t[14]=s,t[15]=i):i=t[15],i},"ConnectionBadge");var r=k(se(),1);var me={completed:0,failed:2,in_progress:1},Re=h(t=>{let e=0,a=0,s=0,l=0,d=[];for(let{metrics:u}of t){if(u===null){l+=1;continue}s+=1,e+=u.requests,a+=u.errors,d.push(...u.history??[])}return{errors:a,failed:l,history:d,reachable:s,requests:e}},"sumShardMetrics"),Me=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"mergeFunctionStats"),_e=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let d=me[s.status]-me[l.status];(d>0||d===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"dedupeMigrations"),Ie=T(E.getAuthMetrics),Le=T(E.getFunctionStats),Ce=T(E.getLogs),Oe=T(E.getMetrics),qe=T(E.migrationStatus),De=5,he=2e3,Fe=5,pe=.01,ge=.05,je=.1,Ue=.3,Pe=1,Ge=50,X=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","rateLevel"),Ve=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","countLevel"),Be={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"ratePercent"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"requestErrorSeries"),$e=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"migrationSummary"),ze=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"migrationTileValue"),xe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},He={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Qe=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","worstLevel"),P=h(t=>{let e=(0,ve.c)(19),{chart:a,label:s,level:l,testId:d,value:u}=t,i=xe[l],n;e[0]!==i?(n=w("size-1.5 shrink-0 rounded-full",i),e[0]=i,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsxDEV)("span",{"aria-hidden":"true",className:n},void 0,!1),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxDEV)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]},void 0,!0),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],m;e[7]!==b?(m=w("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=m):m=e[8];let f;e[9]!==m||e[10]!==d||e[11]!==u?(f=(0,r.jsxDEV)("span",{className:m,"data-testid":d,children:u},void 0,!1),e[9]=m,e[10]=d,e[11]=u,e[12]=f):f=e[12];let v;e[13]!==a||e[14]!==f?(v=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[f,a]},void 0,!0),e[13]=a,e[14]=f,e[15]=v):v=e[15];let x;return e[16]!==g||e[17]!==v?(x=(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:(0,r.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,v]},void 0,!0)},void 0,!1),e[16]=g,e[17]=v,e[18]=x):x=e[18],x},"SloCard"),We=h(async(t,e,a)=>{let s=await Promise.all(a.map(m=>{let f=H(m);return Promise.allSettled([t.query(Oe,{},f),t.query(Le,{},f),t.query(qe,{},f)])})),l=H(e),d=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[u,i,n]=await Promise.allSettled([t.query(Ce,{},l),t.query(Ie,{},l),d]),p=s.map(([m,f,v])=>({functions:f.status==="fulfilled"?f.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:v.status==="fulfilled"?v.value.migrations:[]})),g=Re(p),b=s[0]?.[0];return{auth:i.status==="fulfilled"?i.value:null,entries:u.status==="fulfilled"?u.value.entries:[],functions:Me(p.map(m=>m.functions)),logsError:u.status==="rejected"?Q(u.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?Q(b.reason):null,migrations:_e(p.map(m=>m.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"loadSloData"),ht=h(({initialShardKey:t})=>{let e=ae(),a=D(),[s,l]=(0,c.useState)([]),[d,u]=(0,c.useState)(null),[i,n]=(0,c.useState)(null),[p,g]=(0,c.useState)(null),[b,m]=(0,c.useState)([]),[f,v]=(0,c.useState)(null),[x,be]=(0,c.useState)(null),[we,Ee]=(0,c.useState)([]),[y]=(0,c.useState)(ie),R=(0,c.useRef)(!1),G=(0,c.useRef)(!0);(0,c.useEffect)(()=>(G.current=!0,()=>{G.current=!1}),[]);let M=t??"",_=(0,c.useCallback)(async()=>{if(R.current)return;R.current=!0;let o=await We(e,M,de(M,y));if(!G.current){R.current=!1;return}n(o.totals),g(o.metricsError),m(o.functions),Ee(o.migrations),l(o.entries),u(o.logsError),v(o.auth),be(o.scheduler),R.current=!1},[e,y,M]);(0,c.useEffect)(()=>{F(_())},[_]);let V=(0,c.useRef)(0),I=(0,c.useRef)(null),Se=h(()=>{let o=Date.now()-V.current;if(o>=he){V.current=Date.now(),F(_());return}I.current??=setTimeout(()=>{I.current=null,V.current=Date.now(),F(_())},he-o)},"scheduleFanOut");(0,c.useEffect)(()=>()=>{I.current!==null&&clearTimeout(I.current)},[]);let{data:J,liveError:Te}=ne(E.getMetrics,{},{live:!0,shardKey:M});(0,c.useEffect)(()=>{J!==void 0&&Se()},[J]);let B=s.filter(o=>o.level==="error"),K=B.slice(0,De),L=Ke(i?.history),Y=(0,c.useMemo)(()=>{let o=f?.history??[];return{attempts:o.map(N=>N.attempts),failures:o.map(N=>N.failures)}},[f?.history]),Z=b.filter(o=>o.calls>0).toSorted((o,N)=>N.errors/N.calls-o.errors/o.calls||N.calls-o.calls).slice(0,Fe),$=$e(we),ye=i===null||i.requests===0?0:i.errors/i.requests,z=X(ye,pe,ge),ee=f===null?"ok":X(f.failureRate,je,Ue),te=x===null?"ok":Ve(x.backlog,Pe,Ge),C=Qe([z,ee,te,$.level]),O,q;return C==="crit"?(O=a("Critical"),q=a("One or more service levels are breached.")):C==="warn"?(O=a("Degraded"),q=a("Some service levels need attention.")):(O=a("All systems healthy"),q=a("All service levels are within target.")),(0,r.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxDEV)("div",{className:"flex items-center gap-3",children:[(0,r.jsxDEV)("span",{"aria-hidden":"true",className:w("flex size-10 shrink-0 items-center justify-center rounded-full",He[C]),children:(0,r.jsxDEV)("span",{className:w("size-3 rounded-full",xe[C])},void 0,!1)},void 0,!1),(0,r.jsxDEV)("div",{className:"grid leading-tight",children:[(0,r.jsxDEV)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:O},void 0,!1),(0,r.jsxDEV)("span",{className:"text-[13px] text-muted-foreground",children:q},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsxDEV)(j,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"},void 0,!1),(0,r.jsxDEV)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(i?.requests??0).toString()},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")},void 0,!1),(0,r.jsxDEV)("div",{className:w("text-lg font-semibold tabular-nums",Ne[z]),"data-testid":"hl-error-rate",children:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)(fe,{},void 0,!1),(0,r.jsxDEV)(ce,{message:Te,prefix:"hl"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),p!==null&&(0,r.jsxDEV)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsxDEV)(P,{chart:L.errors.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"},void 0,!1):void 0,label:a("Error rate"),level:z,testId:"hl-slo-errorrate",value:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1),(0,r.jsxDEV)(P,{chart:Y.failures.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:Y.failures,testId:"hl-spark-auth"},void 0,!1):void 0,label:a("Auth failures"),level:ee,testId:"hl-slo-auth",value:f===null?"\u2014":U(f.failures,f.attempts)},void 0,!1),(0,r.jsxDEV)(P,{label:a("Scheduler backlog"),level:te,testId:"hl-slo-backlog",value:x===null?"\u2014":x.backlog.toString()},void 0,!1),(0,r.jsxDEV)(P,{label:a("Migrations"),level:$.level,testId:"hl-slo-migrations",value:ze($,a)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0","data-testid":"hl-functions",children:[(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Functions by error rate")},void 0,!1)},void 0,!1),Z.length===0?(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:a("No function activity yet.")},void 0,!1):(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:Z.map(o=>(0,r.jsxDEV)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.path},void 0,!1),(0,r.jsxDEV)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsxDEV)("span",{className:"tabular-nums text-muted-foreground",children:a("{count} calls",{count:o.calls.toString()})},void 0,!1),(0,r.jsxDEV)(A,{variant:Be[X(o.errors/o.calls,pe,ge)],children:U(o.errors,o.calls)},void 0,!1)]},void 0,!0)]},o.path,!0))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Recent errors")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-error-count",variant:B.length>0?"destructive":"outline",children:B.length},void 0,!1)]},void 0,!0),d!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:d},void 0,!1),d===null&&K.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:a("No recent errors.")},void 0,!1),K.length>0&&(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:K.map((o,N)=>(0,r.jsxDEV)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxDEV)("span",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)("time",{className:"shrink-0 text-muted-foreground",children:oe(o.timestamp)},void 0,!1),o.functionPath!==void 0&&(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.functionPath},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{className:"text-destructive",children:o.message},void 0,!1)]},`${o.timestamp.toString()}-${N.toString()}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-shard-count",variant:"outline",children:y.length},void 0,!1)]},void 0,!0),y.length>0&&(0,r.jsxDEV)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:y.map(o=>(0,r.jsxDEV)("li",{"data-testid":"hl-shard",children:(0,r.jsxDEV)(A,{variant:"secondary",children:o},void 0,!1)},o,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)},"HealthPanel");export{ht as HealthPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _={clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAuditLog:"__lunora_admin__:getAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",listFlags:"__lunora_admin__:listFlags",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",rlsPolicies:"__lunora_admin__:rlsPolicies",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{_ as a};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{a as Ae}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as we,f as Oe,g as $e,k as ae}from"./chunk-4QHKBC77.js";import{a as Ce}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as ke}from"./chunk-3CJW6NWG.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Te}from"./chunk-BOXSWNXZ.js";import{a as W}from"./chunk-TAD43CG5.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as G}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as M,e as le,f as de,g as ce,k as Ie,m as re}from"./chunk-E75ANNWX.js";import{b as Ne}from"./chunk-GMSGZDDH.js";import{a as p,e as q,f as he,g as oe,h as ne,j as ge}from"./chunk-RRCPZMC2.js";var Ue=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var B=q(ne(),1);var Ye=le(Te.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},Pe=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),Ee=p(({file:t,fn:e,kind:o})=>`await client.${Ze[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),et=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ee(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),tt=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),st=p(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
|
|
2
|
+
`),"buildTableSnippet"),ot=p((t,e)=>{switch(t){case"cli":return tt(e);case"client":return Ee(e);default:return et(e)}},"snippetForTab"),_e=p(t=>{let e=(0,ee.c)(19),{code:o,label:s,testId:n}=t,r=M(),l;e[0]!==o?(l=p(()=>{re(o)},"t1"),e[0]=o,e[1]=l):l=e[1];let i=l,d;e[2]!==s?(d=(0,B.jsxDEV)("span",{className:"text-xs font-medium text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=d):d=e[3];let c=`${n}-copy`,m;e[4]!==r?(m=r("Copy"),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==c||e[8]!==m?(a=(0,B.jsxDEV)(H,{"data-testid":c,onClick:i,size:"xs",type:"button",variant:"ghost",children:m},void 0,!1),e[6]=i,e[7]=c,e[8]=m,e[9]=a):a=e[9];let u;e[10]!==d||e[11]!==a?(u=(0,B.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[d,a]},void 0,!0),e[10]=d,e[11]=a,e[12]=u):u=e[12];let v;e[13]!==o||e[14]!==n?(v=(0,B.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:o},void 0,!1),e[13]=o,e[14]=n,e[15]=v):v=e[15];let k;return e[16]!==u||e[17]!==v?(k=(0,B.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[u,v]},void 0,!0),e[16]=u,e[17]=v,e[18]=k):k=e[18],k},"SnippetBlock"),nt=p(t=>{let e=(0,ee.c)(50),{file:o,fn:s,kind:n}=t,r=M(),[l,i]=(0,Z.useState)("react"),d,c,m;if(e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r||e[4]!==l){let T={file:o,fn:s,kind:n},I;e[8]!==r?(I=r("CLI"),e[8]=r,e[9]=I):I=e[9];let P;e[10]!==r?(P=r("Client"),e[10]=r,e[11]=P):P=e[11];let E;e[12]!==r?(E=r("React"),e[12]=r,e[13]=E):E=e[13];let j;e[14]!==I||e[15]!==P||e[16]!==E?(j={cli:I,client:P,react:E},e[14]=I,e[15]=P,e[16]=E,e[17]=j):j=e[17],m=j;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=p(L=>{i(L.currentTarget.dataset.tab)},"t62"),e[18]=R):R=e[18],d=R,c=ot(l,T),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=l,e[5]=d,e[6]=c,e[7]=m}else d=e[5],c=e[6],m=e[7];let a=c,u=n==="action"&&l==="react"&&!Xe,v=`api.${o}.${s}`,k;e[19]!==v?(k=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:v},void 0,!1),e[19]=v,e[20]=k):k=e[20];let O;e[21]!==n||e[22]!==r?(O=r("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=r,e[23]=O):O=e[23];let h;e[24]!==O?(h=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:O},void 0,!1),e[24]=O,e[25]=h):h=e[25];let g;e[26]!==k||e[27]!==h?(g=(0,B.jsxDEV)("div",{children:[k,h]},void 0,!0),e[26]=k,e[27]=h,e[28]=g):g=e[28];let x;e[29]!==r?(x=r("Snippet flavour"),e[29]=r,e[30]=x):x=e[30];let b;e[31]!==d||e[32]!==l||e[33]!==m?(b=Qe.map(T=>(0,B.jsxDEV)(H,{"aria-selected":l===T,"data-tab":T,"data-testid":`api-tab-${T}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===T?"default":"outline",children:m[T]},T,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let S;e[35]!==x||e[36]!==b?(S=(0,B.jsxDEV)("div",{"aria-label":x,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:b},void 0,!1),e[35]=x,e[36]=b,e[37]=S):S=e[37];let y=m[l],$=`api-snippet-${l}`,N;e[38]!==a||e[39]!==y||e[40]!==$?(N=(0,B.jsxDEV)(_e,{code:a,label:y,testId:$},void 0,!1),e[38]=a,e[39]=y,e[40]=$,e[41]=N):N=e[41];let w;e[42]!==u||e[43]!==r?(w=u&&(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:r("Actions have no React hook \u2014 call them through the client.")},void 0,!1),e[42]=u,e[43]=r,e[44]=w):w=e[44];let C;return e[45]!==N||e[46]!==w||e[47]!==g||e[48]!==S?(C=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,S,N,w]},void 0,!0),e[45]=N,e[46]=w,e[47]=g,e[48]=S,e[49]=C):C=e[49],C},"FunctionDoc"),rt=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=st(o),e[0]=o,e[1]=n):n=e[1];let r=n,l;e[2]!==o?(l=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:o},void 0,!1),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==s?(i=s("Read and write this table through the typed data model."),e[4]=s,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:i},void 0,!1),e[6]=i,e[7]=d):d=e[7];let c;e[8]!==l||e[9]!==d?(c=(0,B.jsxDEV)("div",{children:[l,d]},void 0,!0),e[8]=l,e[9]=d,e[10]=c):c=e[10];let m;e[11]!==s?(m=s("Data model"),e[11]=s,e[12]=m):m=e[12];let a;e[13]!==r||e[14]!==m?(a=(0,B.jsxDEV)(_e,{code:r,label:m,testId:"api-snippet-table"},void 0,!1),e[13]=r,e[14]=m,e[15]=a):a=e[15];let u;return e[16]!==c||e[17]!==a?(u=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,a]},void 0,!0),e[16]=c,e[17]=a,e[18]=u):u=e[18],u},"TableDoc"),Re=p(t=>{let e=(0,ee.c)(8),{active:o,label:s,onSelect:n,testId:r,value:l}=t,i;e[0]!==n||e[1]!==l?(i=p(()=>{n(l)},"t1"),e[0]=n,e[1]=l,e[2]=i):i=e[2];let d=i,c=o?"page":void 0,m;return e[3]!==s||e[4]!==d||e[5]!==c||e[6]!==r?(m=(0,B.jsxDEV)("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":r,onClick:d,type:"button",children:s},void 0,!1),e[3]=s,e[4]=d,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},"RailButton"),je=p(t=>{let e=(0,ee.c)(67),{functions:o,initialShardKey:s}=t,n=M(),r=G(),[l,i]=(0,Z.useState)(null),[d,c]=(0,Z.useState)(null),m,a;e[0]!==r||e[1]!==s?(m=p(()=>{let _=!1;return r.query(Ye,{},de(s??"")).then(D=>(_||i(D),D)).catch(()=>{_||i([])}),()=>{_=!0}},"t1"),a=[r,s],e[0]=r,e[1]=s,e[2]=m,e[3]=a):(m=e[2],a=e[3]),(0,Z.useEffect)(m,a);let u;e[4]!==o?(u=o??[],e[4]=o,e[5]=u):u=e[5];let v=u,k;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Pe(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}k=[..._.entries()].map(at).toSorted(lt),e[6]=v,e[7]=k}else k=e[7];let O=k,h,g,x,b,S,y,$,N,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(dt).toSorted(ct),D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=p(F=>{c({kind:"fn",path:F})},"t122"),e[23]=D):D=e[23];let V=D,U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=p(F=>{c({kind:"table",name:F})},"t132"),e[24]=U):U=e[24];let ie=U;if(g=d?.kind==="fn"?v.find(F=>F.path===d.path):void 0,h=v.length>0||_.length>0,x=g===void 0?void 0:Pe(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",S="lunora-api-docs",e[25]!==n?(y=n("API resources"),e[25]=n,e[26]=y):y=e[26],$="flex flex-col gap-4 overflow-y-auto",N="api-rail",e[27]!==O||e[28]!==d||e[29]!==n){let F;e[31]!==d||e[32]!==n?(F=p(ve=>(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:ve.file||n("(root)")},void 0,!1),ve.items.map(se=>(0,B.jsxDEV)(Re,{active:d?.kind==="fn"&&d.path===se.path,label:se.fn,onSelect:V,testId:`api-rail-fn-${se.path}`,value:se.path},se.path,!1))]},ve.file,!0),"t142"),e[31]=d,e[32]=n,e[33]=F):F=e[33],w=O.map(F),e[27]=O,e[28]=d,e[29]=n,e[30]=w}else w=e[30];C=_.length>0&&(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")},void 0,!1),_.map(F=>(0,B.jsxDEV)(Re,{active:d?.kind==="table"&&d.name===F,label:F,onSelect:ie,testId:`api-rail-table-${F}`,value:F},F,!1))]},void 0,!0),e[8]=v,e[9]=O,e[10]=d,e[11]=n,e[12]=l,e[13]=h,e[14]=g,e[15]=x,e[16]=b,e[17]=S,e[18]=y,e[19]=$,e[20]=N,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],S=e[17],y=e[18],$=e[19],N=e[20],w=e[21],C=e[22];let T;e[34]!==h||e[35]!==n?(T=!h&&(0,B.jsxDEV)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")},void 0,!1),e[34]=h,e[35]=n,e[36]=T):T=e[36];let I;e[37]!==T||e[38]!==y||e[39]!==$||e[40]!==N||e[41]!==w||e[42]!==C?(I=(0,B.jsxDEV)("nav",{"aria-label":y,className:$,"data-testid":N,children:[w,C,T]},void 0,!0),e[37]=T,e[38]=y,e[39]=$,e[40]=N,e[41]=w,e[42]=C,e[43]=I):I=e[43];let P;e[44]!==d||e[45]!==n?(P=d===null&&(0,B.jsxDEV)(W,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[44]=d,e[45]=n,e[46]=P):P=e[46];let E;e[47]!==d?.kind||e[48]!==g||e[49]!==x?(E=d?.kind==="fn"&&g!==void 0&&x!==void 0&&(0,B.jsxDEV)(nt,{file:x.file,fn:x.fn,kind:g.kind},g.path,!1),e[47]=d?.kind,e[48]=g,e[49]=x,e[50]=E):E=e[50];let j;e[51]!==d?.kind||e[52]!==g||e[53]!==n?(j=d?.kind==="fn"&&g===void 0&&(0,B.jsxDEV)(W,{testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[51]=d?.kind,e[52]=g,e[53]=n,e[54]=j):j=e[54];let R;e[55]!==d?(R=d?.kind==="table"&&(0,B.jsxDEV)(rt,{name:d.name},void 0,!1),e[55]=d,e[56]=R):R=e[56];let L;e[57]!==P||e[58]!==E||e[59]!==j||e[60]!==R?(L=(0,B.jsxDEV)("div",{className:"min-w-0",children:[P,E,j,R]},void 0,!0),e[57]=P,e[58]=E,e[59]=j,e[60]=R,e[61]=L):L=e[61];let A;return e[62]!==b||e[63]!==S||e[64]!==I||e[65]!==L?(A=(0,B.jsxDEV)("div",{className:b,"data-testid":S,children:[I,L]},void 0,!0),e[62]=b,e[63]=S,e[64]=I,e[65]=L,e[66]=A):A=e[66],A},"ApiDocsPanel");function it(t,e){return t.fn.localeCompare(e.fn)}p(it,"_temp");function at(t){let[e,o]=t;return{file:e,items:o.toSorted(it)}}p(at,"_temp2");function lt(t,e){return t.file.localeCompare(e.file)}p(lt,"_temp3");function dt(t){return t.name}p(dt,"_temp4");function ct(t,e){return t.localeCompare(e)}p(ct,"_temp5");var Ve=q(oe(),1);var J=q(oe(),1),K=q(he(),1);var f=q(ne(),1);var ue=p(function(t,e,o){let s=(0,J.c)(10),n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},s[0]=n):n=s[0];let[r,l]=(0,K.useState)(n),i,d;s[1]!==o||s[2]!==e||s[3]!==t?(i=p(()=>{if(t!==void 0)return;let m=!1;return e().then(a=>(m||l(o(a)),a)).catch(a=>{m||l({kind:"error",message:ce(a)})}),()=>{m=!0}},"t1"),d=[o,e,t],s[1]=o,s[2]=e,s[3]=t,s[4]=i,s[5]=d):(i=s[4],d=s[5]),(0,K.useEffect)(i,d);let c;return s[6]!==o||s[7]!==r||s[8]!==t?(c=t===void 0?r:o(t),s[6]=o,s[7]=r,s[8]=t,s[9]=c):c=s[9],c},"useAdminSpec"),ft=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),De=p(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"enumValues"),pe=p(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>pe(e)).join(" | "):t.type==="array"?`array<${pe(t.items)}>`:t.type??"any","typeLabel"),pt=p(t=>{let e=De(t);return e!==void 0?t.type??ft(e[0]):pe(t)},"fieldTypeLabel"),ut=p(t=>{let e=De(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),mt=p(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let o=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let s=e.length>(o?2:1);return o||s?e.join(" "):void 0},"rangeText"),vt=p(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"childObject"),te=p(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return te(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[o,s]of Object.entries(t.properties??{}))e[o]=te(s);return e}case"string":return"";default:return null}},"exampleForSchema"),fe=p(t=>{let e=(0,J.c)(7),{label:o,value:s}=t,n;e[0]!==o?(n=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:o},void 0,!1),e[0]=o,e[1]=n):n=e[1];let r;e[2]!==s?(r=(0,f.jsxDEV)("span",{className:"text-foreground",children:s},void 0,!1),e[2]=s,e[3]=r):r=e[3];let l;return e[4]!==n||e[5]!==r?(l=(0,f.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,r]},void 0,!0),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},"Badge"),ht=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=mt(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=ut(n),e[2]=n,e[3]=d):d=e[3];let c=d,m=n["x-lunora-table"],a=n.format!==void 0||i!==void 0||c!==void 0||m!==void 0,u;e[4]!==n?(u=vt(n),e[4]=n,e[5]=u):u=e[5];let v=u,k=s?"*":"?",O;e[6]!==k?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:k},void 0,!1),e[6]=k,e[7]=O):O=e[7];let h;e[8]!==o||e[9]!==O?(h=(0,f.jsxDEV)("span",{className:"font-mono text-foreground",children:[o,O]},void 0,!0),e[8]=o,e[9]=O,e[10]=h):h=e[10];let g;e[11]!==n?(g=pt(n),e[11]=n,e[12]=g):g=e[12];let x;e[13]!==g?(x=(0,f.jsxDEV)("span",{className:"font-mono text-muted-foreground",children:g},void 0,!1),e[13]=g,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=(0,f.jsxDEV)("div",{className:"flex items-baseline gap-2",children:[h,x]},void 0,!0),e[15]=h,e[16]=x,e[17]=b):b=e[17];let S;e[18]!==n.description?(S=n.description!==void 0&&(0,f.jsxDEV)("p",{className:"max-w-prose text-muted-foreground",children:n.description},void 0,!1),e[18]=n.description,e[19]=S):S=e[19];let y;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(y=a&&(0,f.jsxDEV)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,f.jsxDEV)(fe,{label:r("Format"),value:n.format},void 0,!1),i!==void 0&&(0,f.jsxDEV)(fe,{label:r("Range"),value:i},void 0,!1),c!==void 0&&(0,f.jsxDEV)(fe,{label:r("Value in"),value:c},void 0,!1),m!==void 0&&(0,f.jsxDEV)(fe,{label:r("relation"),value:m},void 0,!1)]},void 0,!0),e[20]=a,e[21]=i,e[22]=m,e[23]=n.format,e[24]=r,e[25]=c,e[26]=y):y=e[26];let $;e[27]!==S||e[28]!==y||e[29]!==b?($=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,S,y]},void 0,!0),e[27]=S,e[28]=y,e[29]=b,e[30]=$):$=e[30];let N=$;if(v===void 0){let I;return e[31]!==N?(I=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:N},void 0,!1),e[31]=N,e[32]=I):I=e[32],I}let w;e[33]!==N?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:N},void 0,!1),e[33]=N,e[34]=w):w=e[34];let C;e[35]!==v?(C=(0,f.jsxDEV)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,f.jsxDEV)(Me,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let T;return e[37]!==w||e[38]!==C?(T=(0,f.jsxDEV)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,C]},void 0,!0),e[37]=w,e[38]=C,e[39]=T):T=e[39],T},"FieldRow"),Me=p(t=>{let e=(0,J.c)(7),{schema:o}=t,s;e[0]!==o.required?(s=new Set(o.required),e[0]=o.required,e[1]=s):s=e[1];let n=s,r;e[2]!==o.properties?(r=Object.entries(o.properties??{}),e[2]=o.properties,e[3]=r):r=e[3];let l=r,i;return e[4]!==n||e[5]!==l?(i=(0,f.jsxDEV)("div",{className:"flex flex-col",children:l.map(d=>{let[c,m]=d;return(0,f.jsxDEV)(ht,{name:c,required:n.has(c),schema:m},c,!1)})},void 0,!1),e[4]=n,e[5]=l,e[6]=i):i=e[6],i},"SchemaFields"),Le=p(t=>{let e=(0,J.c)(10),{schema:o,testId:s}=t;if(o?.type!=="object"||Object.keys(o.properties??{}).length===0){let l;e[0]!==o?(l=pe(o),e[0]=o,e[1]=l):l=e[1];let i;return e[2]!==l||e[3]!==s?(i=(0,f.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":s,children:l},void 0,!1),e[2]=l,e[3]=s,e[4]=i):i=e[4],i}let n;e[5]!==o?(n=(0,f.jsxDEV)(Me,{schema:o},void 0,!1),e[5]=o,e[6]=n):n=e[6];let r;return e[7]!==n||e[8]!==s?(r=(0,f.jsxDEV)("div",{className:"text-xs","data-testid":s,children:n},void 0,!1),e[7]=n,e[8]=s,e[9]=r):r=e[9],r},"SchemaTable"),gt=["curl","javascript","lunora"],xt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},bt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),yt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),Nt=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(yt(e),void 0,2),r=JSON.stringify(te(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let l=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(s)}`];return l&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
|
|
3
|
+
`)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
|
|
4
|
+
import { api } from "./_generated/api";
|
|
5
|
+
|
|
6
|
+
const client = useLunora();
|
|
7
|
+
await client.${e.kind??"query"}(${bt(e.functionPath)}, ${r});`;default:{let i=e.method!=="GET"&&e.method!=="HEAD"?`{
|
|
8
|
+
method: ${JSON.stringify(e.method)},
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
body: JSON.stringify(${n}),
|
|
11
|
+
}`:`{ method: ${JSON.stringify(e.method)} }`;return`const response = await fetch(${JSON.stringify(s)}, ${i});
|
|
12
|
+
const data = await response.json();`}}},"sampleSource"),St=p(t=>{let e=(0,J.c)(24),{operation:o,server:s}=t,n=M(),[r,l]=(0,K.useState)("curl"),i;e[0]!==o||e[1]!==r||e[2]!==s?(i=Nt(r,o,s),e[0]=o,e[1]=r,e[2]=s,e[3]=i):i=e[3];let d=i,c;e[4]!==d?(c=p(()=>{re(d)},"t2"),e[4]=d,e[5]=c):c=e[5];let m=c,a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=p(S=>{l(S.currentTarget.dataset.sample)},"t3"),e[6]=a):a=e[6];let u=a,v;e[7]!==r?(v=gt.map(S=>(0,f.jsxDEV)("button",{"aria-selected":r===S,className:"rounded px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium aria-selected:text-foreground","data-sample":S,"data-testid":`api-sample-${S}`,onClick:u,role:"tab",type:"button",children:xt[S]},S,!1)),e[7]=r,e[8]=v):v=e[8];let k;e[9]!==v?(k=(0,f.jsxDEV)("div",{className:"flex gap-1",role:"tablist",children:v},void 0,!1),e[9]=v,e[10]=k):k=e[10];let O;e[11]!==n?(O=n("Copy"),e[11]=n,e[12]=O):O=e[12];let h;e[13]!==m||e[14]!==O?(h=(0,f.jsxDEV)(H,{"data-testid":"api-sample-copy",onClick:m,size:"xs",type:"button",variant:"ghost",children:O},void 0,!1),e[13]=m,e[14]=O,e[15]=h):h=e[15];let g;e[16]!==k||e[17]!==h?(g=(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[k,h]},void 0,!0),e[16]=k,e[17]=h,e[18]=g):g=e[18];let x;e[19]!==d?(x=(0,f.jsxDEV)("pre",{className:"overflow-auto px-3 pb-3 font-mono text-xs","data-testid":"api-sample-source",children:d},void 0,!1),e[19]=d,e[20]=x):x=e[20];let b;return e[21]!==g||e[22]!==x?(b=(0,f.jsxDEV)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card","data-testid":"api-code-samples",children:[g,x]},void 0,!0),e[21]=g,e[22]=x,e[23]=b):b=e[23],b},"CodeSamples"),kt={blue:"text-info",emerald:"text-success",neutral:"text-muted-foreground",orange:"text-warning",red:"text-destructive",violet:"text-royal-amethyst"},wt=p(t=>{switch(t.toUpperCase()){case"DELETE":return"red";case"GET":return"emerald";case"PATCH":return"orange";case"POST":return"blue";case"PUT":return"orange";default:return"neutral"}},"methodTone"),Ot=p(t=>{switch(t){case"action":return"violet";case"mutation":return"orange";case"query":return"emerald";default:return"neutral"}},"kindTone"),be=p(t=>{let e=(0,J.c)(7),{kind:o,method:s,testId:n}=t,r;e[0]!==o||e[1]!==s?(r=o??s.toUpperCase(),e[0]=o,e[1]=s,e[2]=r):r=e[2];let l=r,i=o===void 0?wt(s):Ot(o),d=`${kt[i]} font-mono text-[10px] tracking-wide uppercase`,c;return e[3]!==l||e[4]!==d||e[5]!==n?(c=(0,f.jsxDEV)(Se,{className:d,"data-testid":n,variant:"ghost",children:l},void 0,!1),e[3]=l,e[4]=d,e[5]=n,e[6]=c):c=e[6],c},"MethodBadge"),Ke=p(t=>t.startsWith("2")?"text-emerald-600 dark:text-emerald-400":t==="default"||t.startsWith("4")||t.startsWith("5")?"text-red-600 dark:text-red-400":"text-muted-foreground","statusToneClass"),Fe=p(t=>t.startsWith("2")?"bg-emerald-500":t==="default"||t.startsWith("4")||t.startsWith("5")?"bg-red-500":"bg-muted-foreground","statusDotClass"),$t=p(t=>JSON.stringify(te(t.argsSchema)??{},void 0,2),"seedArgs"),Je=(0,K.createContext)(null),qe=p(()=>{let t=(0,K.use)(Je);if(t===null)throw new Ne("INTERNAL","useOperationRun must be used within an OperationRunProvider");return t},"useOperationRun"),It=p(({children:t,operation:e})=>{let o=M(),s=G(),[n,r]=(0,K.useState)(()=>$t(e)),[l,i]=(0,K.useState)(""),[d,c]=(0,K.useState)("idle"),[m,a]=(0,K.useState)(void 0),[u,v]=(0,K.useState)(null),[k,O]=(0,K.useState)(null),h=p(async()=>{let b;try{b=n.trim()===""?{}:JSON.parse(n)}catch(y){c("error"),a(void 0),O(null),v(o("Invalid JSON args: {message}",{message:ce(y)}));return}c("running"),v(null);let S=performance.now();try{let y;if(e.functionPath===void 0){let $=e.method!=="GET"&&e.method!=="HEAD",w=await(await fetch(e.httpPath,{body:$?JSON.stringify(b):void 0,headers:$?{"content-type":"application/json"}:void 0,method:e.method})).text();try{y=JSON.parse(w)}catch{y=w}}else{let $=le(e.functionPath),N=de(l);switch(e.kind){case"action":{y=await s.action($,b,N);break}case"mutation":{y=await s.mutation($,b,N);break}default:y=await s.query($,b,N)}}a(y),O(Math.round(performance.now()-S)),c("success")}catch(y){a(void 0),O(Math.round(performance.now()-S)),v(ce(y)),c("error")}},"send");return(0,f.jsxDEV)(Je,{value:{argsText:n,durationMs:k,error:u,operation:e,response:m,send:p(()=>{Ie(h())},"onSend"),setArgsText:r,setShardKey:i,shardKey:l,status:d},children:t},void 0,!1)},"OperationRunProvider"),Tt=p(()=>{let t=(0,J.c)(48),e=M(),{argsText:o,operation:s,send:n,setArgsText:r,setShardKey:l,shardKey:i,status:d}=qe(),c;t[0]!==r?(c=p(R=>{r(R.target.value)},"t0"),t[0]=r,t[1]=c):c=t[1];let m=c,a;t[2]!==n?(a=p(R=>{R.key==="Enter"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),n())},"t1"),t[2]=n,t[3]=a):a=t[3];let u=a,v=d==="running",k;t[4]!==s.kind||t[5]!==s.method?(k=(0,f.jsxDEV)(be,{kind:s.kind,method:s.method,testId:"api-try-method"},void 0,!1),t[4]=s.kind,t[5]=s.method,t[6]=k):k=t[6];let O=s.functionPath??s.httpPath,h;t[7]!==O?(h=(0,f.jsxDEV)("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:O},void 0,!1),t[7]=O,t[8]=h):h=t[8];let g=v?"animate-pulse":void 0,x;t[9]!==g?(x=(0,f.jsxDEV)(ae,{className:g,icon:$e,strokeWidth:2},void 0,!1),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==v||t[12]!==e?(b=e(v?"Sending\u2026":"Send"),t[11]=v,t[12]=e,t[13]=b):b=t[13];let S;t[14]!==v||t[15]!==n||t[16]!==x||t[17]!==b?(S=(0,f.jsxDEV)(H,{"data-testid":"api-try-send",disabled:v,onClick:n,size:"sm",type:"button",children:[x,b]},void 0,!0),t[14]=v,t[15]=n,t[16]=x,t[17]=b,t[18]=S):S=t[18];let y;t[19]!==k||t[20]!==h||t[21]!==S?(y=(0,f.jsxDEV)("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2",children:[k,h,S]},void 0,!0),t[19]=k,t[20]=h,t[21]=S,t[22]=y):y=t[22];let $;t[23]!==e?($=e("Arguments (JSON)"),t[23]=e,t[24]=$):$=t[24];let N;t[25]!==$?(N=(0,f.jsxDEV)(xe,{htmlFor:"api-try-args",children:$},void 0,!1),t[25]=$,t[26]=N):N=t[26];let w;t[27]!==o?(w=o.split(`
|
|
13
|
+
`),t[27]=o,t[28]=w):w=t[28];let C=Math.min(12,Math.max(3,w.length)),T;t[29]!==o||t[30]!==m||t[31]!==u||t[32]!==C?(T=(0,f.jsxDEV)(Ae,{className:"font-mono text-xs","data-testid":"api-try-args",id:"api-try-args",onChange:m,onKeyDown:u,rows:C,spellCheck:!1,value:o},void 0,!1),t[29]=o,t[30]=m,t[31]=u,t[32]=C,t[33]=T):T=t[33];let I;t[34]!==N||t[35]!==T?(I=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[N,T]},void 0,!0),t[34]=N,t[35]=T,t[36]=I):I=t[36];let P;t[37]!==s.functionPath||t[38]!==l||t[39]!==i||t[40]!==e?(P=s.functionPath!==void 0&&(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,f.jsxDEV)(xe,{htmlFor:"shard-input",children:e("Shard key (optional)")},void 0,!1),(0,f.jsxDEV)(Ce,{id:"shard-input",onChange:l,testId:"shard-input",value:i},void 0,!1)]},void 0,!0),t[37]=s.functionPath,t[38]=l,t[39]=i,t[40]=e,t[41]=P):P=t[41];let E;t[42]!==I||t[43]!==P?(E=(0,f.jsxDEV)("div",{className:"flex flex-col gap-3 p-3",children:[I,P]},void 0,!0),t[42]=I,t[43]=P,t[44]=E):E=t[44];let j;return t[45]!==E||t[46]!==y?(j=(0,f.jsxDEV)("div",{className:"overflow-hidden rounded-xl border border-border bg-card","data-testid":"api-try-it",children:[y,E]},void 0,!0),t[45]=E,t[46]=y,t[47]=j):j=t[47],j},"TryIt"),Ct=p(t=>{let e=(0,J.c)(51),{operation:o}=t,s=M(),n=`api-operation-${o.operationId}`,r=o.key,l;e[0]!==o.kind||e[1]!==o.method?(l=(0,f.jsxDEV)(be,{kind:o.kind,method:o.method,testId:"api-operation-method"},void 0,!1),e[0]=o.kind,e[1]=o.method,e[2]=l):l=e[2];let i=o.functionPath??o.httpPath,d;e[3]!==i?(d=(0,f.jsxDEV)("code",{className:"truncate font-mono text-xs text-muted-foreground",children:i},void 0,!1),e[3]=i,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=(0,f.jsxDEV)("div",{className:"flex items-center gap-2",children:[l,d]},void 0,!0),e[5]=l,e[6]=d,e[7]=c):c=e[7];let m;e[8]!==o.title?(m=(0,f.jsxDEV)("h1",{className:"text-lg font-semibold text-foreground","data-testid":"api-operation-title",children:o.title},void 0,!1),e[8]=o.title,e[9]=m):m=e[9];let a;e[10]!==o.description?(a=o.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o.description},void 0,!1),e[10]=o.description,e[11]=a):a=e[11];let u;e[12]!==c||e[13]!==m||e[14]!==a?(u=(0,f.jsxDEV)("header",{className:"sticky top-0 z-10 -mx-6 -mt-6 flex flex-col gap-2 border-b border-border bg-background px-6 pt-6 pb-3",children:[c,m,a]},void 0,!0),e[12]=c,e[13]=m,e[14]=a,e[15]=u):u=e[15];let v;e[16]!==s?(v=s("Try it"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==v?(k=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v},void 0,!1),e[18]=v,e[19]=k):k=e[19];let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=(0,f.jsxDEV)(Tt,{},void 0,!1),e[20]=O):O=e[20];let h;e[21]!==k?(h=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[k,O]},void 0,!0),e[21]=k,e[22]=h):h=e[22];let g;e[23]!==s?(g=s("Request arguments"),e[23]=s,e[24]=g):g=e[24];let x;e[25]!==g?(x=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g},void 0,!1),e[25]=g,e[26]=x):x=e[26];let b;e[27]!==o.argsSchema?(b=(0,f.jsxDEV)(Le,{schema:o.argsSchema,testId:"api-operation-args"},void 0,!1),e[27]=o.argsSchema,e[28]=b):b=e[28];let S;e[29]!==x||e[30]!==b?(S=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[x,b]},void 0,!0),e[29]=x,e[30]=b,e[31]=S):S=e[31];let y;e[32]!==s?(y=s("Response body"),e[32]=s,e[33]=y):y=e[33];let $;e[34]!==y?($=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1),e[34]=y,e[35]=$):$=e[35];let N;if(e[36]!==o.responses||e[37]!==s){let T;e[39]!==s?(T=p(I=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5 rounded-xl border border-border bg-card p-3",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,f.jsxDEV)("span",{className:`inline-flex items-center gap-1.5 font-mono text-xs font-semibold ${Ke(I.status)}`,children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Fe(I.status)}`},void 0,!1),I.status]},void 0,!0),I.schema!==void 0&&(0,f.jsxDEV)("span",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s("application/json")},void 0,!1)]},void 0,!0),I.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:I.description},void 0,!1),I.schema!==void 0&&(0,f.jsxDEV)(Le,{schema:I.schema,testId:`api-response-${I.status}`},void 0,!1)]},I.status,!0),"t212"),e[39]=s,e[40]=T):T=e[40],N=o.responses.map(T),e[36]=o.responses,e[37]=s,e[38]=N}else N=e[38];let w;e[41]!==$||e[42]!==N?(w=(0,f.jsxDEV)("section",{className:"flex flex-col gap-3",children:[$,N]},void 0,!0),e[41]=$,e[42]=N,e[43]=w):w=e[43];let C;return e[44]!==o.key||e[45]!==n||e[46]!==h||e[47]!==S||e[48]!==w||e[49]!==u?(C=(0,f.jsxDEV)("div",{className:"flex flex-col gap-6 duration-200 animate-in fade-in-0 slide-in-from-bottom-1","data-testid":n,children:[u,h,S,w]},r,!0),e[44]=o.key,e[45]=n,e[46]=h,e[47]=S,e[48]=w,e[49]=u,e[50]=C):C=e[50],C},"OperationView"),At={boolean:"text-royal-amethyst",key:"text-sky-sapphire",number:"text-warning",plain:"",string:"text-success"},Pt=/"(?:[^"\\]|\\.)*"|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?/g,Rt=/^\s*:/,Et=p((t,e,o)=>o.startsWith('"')?Rt.test(t.slice(e))?"key":"string":o==="true"||o==="false"||o==="null"?"boolean":"number","classify"),_t=p(t=>{let e=[],o=0;for(let s of t.matchAll(Pt)){let{index:n}=s,r=s[0],l=n+r.length;n>o&&e.push({kind:"plain",start:o,text:t.slice(o,n)}),e.push({kind:Et(t,l,r),start:n,text:r}),o=l}return o<t.length&&e.push({kind:"plain",start:o,text:t.slice(o)}),e},"tokenize"),jt=p(t=>{let e=(0,J.c)(4),{code:o}=t,s;e[0]!==o?(s=_t(o).map(Lt),e[0]=o,e[1]=s):s=e[1];let n;return e[2]!==s?(n=(0,f.jsxDEV)(f.Fragment,{children:s},void 0,!1),e[2]=s,e[3]=n):n=e[3],n},"JsonHighlight");function Lt(t){return(0,f.jsxDEV)("span",{className:At[t.kind],children:t.text},t.start,!1)}p(Lt,"_temp$1");var Be="__live__",Bt=p(t=>t.schema===void 0?"":JSON.stringify(te(t.schema),void 0,2),"exampleBody"),Dt=p((t,e,o)=>o?t??"":e===void 0?"":JSON.stringify(e,void 0,2),"liveBody"),Mt=p(t=>{let e=(0,J.c)(18),{active:o,running:s,showError:n}=t,r=M();if(s){let a;e[0]!==r?(a=r("Sending\u2026"),e[0]=r,e[1]=a):a=e[1];let u;return e[2]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-running",children:a},void 0,!1),e[2]=a,e[3]=u):u=e[3],u}if(o===void 0||o.body===""){let a;e[4]!==o?.live||e[5]!==r?(a=o?.live===!0?r("Send a request to see the response."):r("No example for this response."),e[4]=o?.live,e[5]=r,e[6]=a):a=e[6];let u;return e[7]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-idle",children:a},void 0,!1),e[7]=a,e[8]=u):u=e[8],u}let l=n&&"text-destructive",i;e[9]!==l?(i=ge("max-h-[28rem] overflow-auto px-3 py-3 font-mono text-xs",l),e[9]=l,e[10]=i):i=e[10];let d=n?"api-response-error":"api-response-body",c;e[11]!==o.body||e[12]!==n?(c=n?o.body:(0,f.jsxDEV)(jt,{code:o.body},void 0,!1),e[11]=o.body,e[12]=n,e[13]=c):c=e[13];let m;return e[14]!==i||e[15]!==d||e[16]!==c?(m=(0,f.jsxDEV)("pre",{className:i,"data-testid":d,children:c},void 0,!1),e[14]=i,e[15]=d,e[16]=c,e[17]=m):m=e[17],m},"ResponseBody"),Kt=p(()=>{let t=(0,J.c)(67),e=M(),{durationMs:o,error:s,operation:n,response:r,status:l}=qe(),i=l==="running",d=l==="error",c=l==="success"||d,m;if(t[0]!==o||t[1]!==s||t[2]!==d||t[3]!==n.responses||t[4]!==c||t[5]!==r||t[6]!==e){e:{let L=n.responses.map(Ft);if(!c){m=L;break e}let A;t[8]!==s||t[9]!==d||t[10]!==r?(A=Dt(s,r,d),t[8]=s,t[9]=d,t[10]=r,t[11]=A):A=t[11];let _;t[12]!==e?(_=e("Live"),t[12]=e,t[13]=_):_=t[13];let D=d?"error":"200",V;t[14]!==o||t[15]!==A||t[16]!==_||t[17]!==D?(V={body:A,durationMs:o,id:Be,label:_,live:!0,status:D},t[14]=o,t[15]=A,t[16]=_,t[17]=D,t[18]=V):V=t[18],m=[V,...L]}t[0]=o,t[1]=s,t[2]=d,t[3]=n.responses,t[4]=c,t[5]=r,t[6]=e,t[7]=m}else m=t[7];let a=m,u;t[19]!==c||t[20]!==a?(u=c?Be:a.find(Jt)?.id??a[0]?.id??"",t[19]=c,t[20]=a,t[21]=u):u=t[21];let v=u,[k,O]=(0,K.useState)(null),h,g,x,b,S,y,$,N,w,C;if(t[22]!==v||t[23]!==k||t[24]!==e||t[25]!==a){h=a.find(D=>D.id===(k??v))??a[0];let L;t[36]===Symbol.for("react.memo_cache_sentinel")?(L=p(D=>{let{id:V}=D.currentTarget.dataset;V!==void 0&&O(V)},"t82"),t[36]=L):L=t[36],x=L,g=p(()=>{h!==void 0&&re(h.body)},"onCopy");let A=h?.live===!0?h.durationMs:null;b=h?.live===!0&&h.status==="error",w="flex min-h-0 flex-col rounded-xl border border-border bg-card",C="api-response-panel",$="flex items-center justify-between gap-2 border-b border-border px-3 py-2";let _;t[37]!==e?(_=e("Response"),t[37]=e,t[38]=_):_=t[38],t[39]!==_?(N=(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_},void 0,!1),t[39]=_,t[40]=N):N=t[40],S="flex items-center gap-2",y=A!==null&&(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground",children:e("{ms} ms",{ms:A})},void 0,!1),t[22]=v,t[23]=k,t[24]=e,t[25]=a,t[26]=h,t[27]=g,t[28]=x,t[29]=b,t[30]=S,t[31]=y,t[32]=$,t[33]=N,t[34]=w,t[35]=C}else h=t[26],g=t[27],x=t[28],b=t[29],S=t[30],y=t[31],$=t[32],N=t[33],w=t[34],C=t[35];let T;t[41]!==h||t[42]!==g||t[43]!==e?(T=h!==void 0&&h.body!==""&&(0,f.jsxDEV)(H,{"aria-label":e("Copy"),"data-testid":"api-response-copy",onClick:g,size:"icon-xs",type:"button",variant:"ghost",children:(0,f.jsxDEV)(ae,{icon:we,strokeWidth:2},void 0,!1)},void 0,!1),t[41]=h,t[42]=g,t[43]=e,t[44]=T):T=t[44];let I;t[45]!==S||t[46]!==y||t[47]!==T?(I=(0,f.jsxDEV)("div",{className:S,children:[y,T]},void 0,!0),t[45]=S,t[46]=y,t[47]=T,t[48]=I):I=t[48];let P;t[49]!==$||t[50]!==N||t[51]!==I?(P=(0,f.jsxDEV)("div",{className:$,children:[N,I]},void 0,!0),t[49]=$,t[50]=N,t[51]=I,t[52]=P):P=t[52];let E;t[53]!==h?.id||t[54]!==x||t[55]!==a?(E=a.length>0&&(0,f.jsxDEV)("div",{className:"flex gap-1 overflow-x-auto border-b border-border px-2 py-1.5",role:"tablist",children:a.map(L=>{let A=L.id===h?.id;return(0,f.jsxDEV)("button",{"aria-selected":A,className:ge("inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-mono text-xs transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium",A?Ke(L.status):"text-muted-foreground"),"data-id":L.id,"data-testid":L.live?"api-response-tab-live":`api-response-tab-${L.status}`,onClick:x,role:"tab",type:"button",children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Fe(L.status)}`},void 0,!1),L.label]},L.id,!0)})},void 0,!1),t[53]=h?.id,t[54]=x,t[55]=a,t[56]=E):E=t[56];let j;t[57]!==h||t[58]!==i||t[59]!==b?(j=(0,f.jsxDEV)(Mt,{active:h,running:i,showError:b},void 0,!1),t[57]=h,t[58]=i,t[59]=b,t[60]=j):j=t[60];let R;return t[61]!==P||t[62]!==E||t[63]!==j||t[64]!==w||t[65]!==C?(R=(0,f.jsxDEV)("div",{className:w,"data-testid":C,children:[P,E,j]},void 0,!0),t[61]=P,t[62]=E,t[63]=j,t[64]=w,t[65]=C,t[66]=R):R=t[66],R},"ResponsePanel");function Ft(t){return{body:Bt(t),durationMs:null,id:t.status,label:t.status,live:!1,status:t.status}}p(Ft,"_temp");function Jt(t){return t.status.startsWith("2")}p(Jt,"_temp2");var qt=p((t,e)=>{let o=e.trim().toLowerCase();return o===""?t:t.map(s=>({...s,operations:s.operations.filter(n=>`${n.summary} ${n.operationId}`.toLowerCase().includes(o))})).filter(s=>s.operations.length>0)},"filterGroups"),me=p(t=>{let e=(0,J.c)(53),{model:o}=t,s=M(),n=o.groups[0]?.operations[0]?.key??"",[r,l]=(0,K.useState)(n),[i,d]=(0,K.useState)(""),c;e[0]!==n||e[1]!==o.operationByKey||e[2]!==r?(c=o.operationByKey.get(r)??o.operationByKey.get(n),e[0]=n,e[1]=o.operationByKey,e[2]=r,e[3]=c):c=e[3];let m=c,a,u,v,k,O,h,g,x,b,S;if(e[4]!==i||e[5]!==o.groups||e[6]!==o.server||e[7]!==m?.key||e[8]!==s){a=qt(o.groups,i);let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=p(A=>{let{key:_}=A.currentTarget.dataset;_!==void 0&&l(_)},"t102"),e[19]=T):T=e[19];let I=T,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=p(A=>{d(A.target.value)},"t112"),e[20]=P):P=e[20];let E=P;u=o.server??"",b="grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[16rem_minmax(0,1fr)_22rem]",S="api-reference",e[21]!==s?(O=s("API operations"),e[21]=s,e[22]=O):O=e[22],h="flex min-h-0 flex-col overflow-y-auto border-r border-border",g="api-reference-nav";let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=(0,f.jsxDEV)(ae,{className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground",icon:Oe,strokeWidth:2},void 0,!1),e[23]=j):j=e[23];let R;e[24]!==s?(R=s("Filter operations"),e[24]=s,e[25]=R):R=e[25],e[26]!==i||e[27]!==R?(x=(0,f.jsxDEV)("div",{className:"sticky top-0 z-10 border-b border-border bg-sidebar p-2",children:(0,f.jsxDEV)("div",{className:"relative",children:[j,(0,f.jsxDEV)(ke,{className:"h-7 pl-7","data-testid":"api-filter",onChange:E,placeholder:R,value:i},void 0,!1)]},void 0,!0)},void 0,!1),e[26]=i,e[27]=R,e[28]=x):x=e[28],v="flex flex-col gap-4 p-2";let L;e[29]!==m?.key||e[30]!==s?(L=p(A=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between px-2",children:[(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A.name||s("(root)")},void 0,!1),(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:A.operations.length},void 0,!1)]},void 0,!0),A.operations.map(_=>{let D=_.key===m?.key;return(0,f.jsxDEV)("button",{"aria-current":D?"page":void 0,className:"flex items-center justify-between gap-2 rounded-md border-l-2 border-transparent px-2 py-1 text-start text-xs text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-[current=page]:border-primary aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-key":_.key,"data-testid":`api-nav-${_.operationId}`,onClick:I,type:"button",children:[(0,f.jsxDEV)("span",{className:"truncate",children:_.summary},void 0,!1),(0,f.jsxDEV)(be,{kind:_.kind,method:_.method},void 0,!1)]},_.key,!0)})]},A.name,!0),"t142"),e[29]=m?.key,e[30]=s,e[31]=L):L=e[31],k=a.map(L),e[4]=i,e[5]=o.groups,e[6]=o.server,e[7]=m?.key,e[8]=s,e[9]=a,e[10]=u,e[11]=v,e[12]=k,e[13]=O,e[14]=h,e[15]=g,e[16]=x,e[17]=b,e[18]=S}else a=e[9],u=e[10],v=e[11],k=e[12],O=e[13],h=e[14],g=e[15],x=e[16],b=e[17],S=e[18];let y;e[32]!==a.length||e[33]!==s?(y=a.length===0&&(0,f.jsxDEV)("p",{className:"px-2 py-1 text-xs text-muted-foreground","data-testid":"api-nav-empty",children:s("No operations match your filter.")},void 0,!1),e[32]=a.length,e[33]=s,e[34]=y):y=e[34];let $;e[35]!==y||e[36]!==v||e[37]!==k?($=(0,f.jsxDEV)("div",{className:v,children:[k,y]},void 0,!0),e[35]=y,e[36]=v,e[37]=k,e[38]=$):$=e[38];let N;e[39]!==$||e[40]!==O||e[41]!==h||e[42]!==g||e[43]!==x?(N=(0,f.jsxDEV)("nav",{"aria-label":O,className:h,"data-testid":g,children:[x,$]},void 0,!0),e[39]=$,e[40]=O,e[41]=h,e[42]=g,e[43]=x,e[44]=N):N=e[44];let w;e[45]!==m||e[46]!==u?(w=m===void 0?(0,f.jsxDEV)("div",{className:"lg:col-span-2"},void 0,!1):(0,f.jsxDEV)(It,{operation:m,children:[(0,f.jsxDEV)("div",{className:"min-w-0 overflow-y-auto p-6","data-testid":"api-reference-main",children:(0,f.jsxDEV)(Ct,{operation:m},void 0,!1)},void 0,!1),(0,f.jsxDEV)("aside",{className:"flex min-w-0 flex-col gap-4 overflow-y-auto border-border p-4 lg:border-l","data-testid":"api-reference-aside",children:[(0,f.jsxDEV)(St,{operation:m,server:u},void 0,!1),(0,f.jsxDEV)(Kt,{},void 0,!1)]},void 0,!0)]},m.key,!0),e[45]=m,e[46]=u,e[47]=w):w=e[47];let C;return e[48]!==N||e[49]!==w||e[50]!==b||e[51]!==S?(C=(0,f.jsxDEV)("div",{className:b,"data-testid":S,children:[N,w]},void 0,!0),e[48]=N,e[49]=w,e[50]=b,e[51]=S,e[52]=C):C=e[52],C},"ReferenceView");var Y=q(ne(),1);var Vt=["get","post","put","patch","delete","head","options","trace"],ze=p(t=>t?.content?.["application/json"]?.schema,"jsonSchemaOf"),zt=p((t,e)=>Object.entries(t.responses??{}).map(([o,s])=>{let n=s.$ref?.replace("#/components/responses/",""),r=n===void 0?s:e.components?.responses?.[n]??s;return{description:r.description,schema:ze(r),status:o}}),"buildResponses"),Ht=p((t,e,o,s,n)=>{let r=ze(s.requestBody),l=r?.properties?.functionPath?.const,i=typeof l=="string"?l:void 0,d=i===void 0?r:r?.properties?.args,c=s.operationId??`${o} ${e}`;return{argsSchema:d,description:s.description,functionPath:i,httpPath:e,key:t,kind:s["x-lunora-function-kind"],method:o.toUpperCase(),operationId:c,requestSchema:r,responses:zt(s,n),summary:s.summary??c,tags:s.tags??[],title:s.summary??c}},"flattenOperation"),Wt=p(t=>{let e=[];for(let[o,s]of Object.entries(t.paths??{})){let n=o.includes("#")?o.slice(0,o.indexOf("#")):o;for(let r of Vt){let l=s[r];l!==void 0&&e.push(Ht(o,n,r,l,t))}}return e},"collectOperations"),Gt=p(t=>{let e=t??{},o=Wt(e),s=new Map((e.tags??[]).map(i=>[i.name,i.description])),n=new Set,r=[],l=p(i=>{if(n.has(i))return;n.add(i);let d=o.filter(c=>(c.tags[0]??"")===i);d.length>0&&r.push({description:s.get(i),name:i,operations:d})},"pushGroup");for(let i of e.tags??[])l(i.name);for(let i of o)l(i.tags[0]??"");return{groups:r,operationByKey:new Map(o.map(i=>[i.key,i])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenApi"),Ut=p(t=>{let{paths:e}=t;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},"isEmptySpec"),Yt=p(t=>{let e=t;return Ut(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifySpec"),He=p(t=>{let e=(0,Ve.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenApi(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,Yt),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?Gt(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Y.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[(0,Y.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Y.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenAPI spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenAPI spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Y.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"ApiReferencePanel");var We=q(oe(),1);var Q=q(ne(),1);var Qt=p(t=>(t.params??[]).find(e=>e.name==="args")??(t.params??[])[0],"argsParameterOf"),Xt=p(t=>t["x-tags"]?.[0]?.name??(t.name.includes(":")?t.name.slice(0,t.name.indexOf(":")):""),"namespaceOf"),Zt=p(t=>{let e=Qt(t)?.schema;return{argsSchema:e,description:t.description,functionPath:t.name,httpPath:"/_lunora/rpc",key:t.name,kind:t["x-lunora-function-kind"],method:"POST",operationId:t.name,requestSchema:e,responses:[{description:t.result?.name,schema:t.result?.schema,status:"200"}],summary:t.summary??t.name,tags:[Xt(t)],title:t.summary??t.name}},"toOperation"),es=p(t=>{let e=t??{},o=(e.methods??[]).map(r=>Zt(r)),s=new Map;for(let r of o){let l=r.tags[0]??"",i=s.get(l)??[];i.push(r),s.set(l,i)}return{groups:[...s.entries()].map(([r,l])=>({name:r,operations:l.toSorted((i,d)=>i.operationId.localeCompare(d.operationId))})).toSorted((r,l)=>r.name.localeCompare(l.name)),operationByKey:new Map(o.map(r=>[r.key,r])),title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenRpc"),ts=p(t=>t.methods===void 0||t.methods.length===0,"isEmptyDocument"),ss=p(t=>{let e=t;return ts(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifyDocument"),Ge=p(t=>{let e=(0,We.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenRpc(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,ss),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?es(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Q.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"openrpc-reference-loading",children:[(0,Q.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Q.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenRPC spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen --api-spec openrpc` and wire `_generated/openrpc.json` to the worker to render the OpenRPC reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenRPC spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Q.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"OpenRpcReferencePanel");var z=q(ne(),1);var os=["reference","snippets"],ns=["openapi","openrpc"],Ws=p(t=>{let e=(0,Ue.c)(51),{functions:o,initialShardKey:s,openApiSpec:n,openRpcSpec:r}=t,l=M(),[i,d]=(0,ye.useState)("reference"),[c,m]=(0,ye.useState)("openapi"),a;e[0]!==l?(a=l("Reference"),e[0]=l,e[1]=a):a=e[1];let u;e[2]!==l?(u=l("Snippets"),e[2]=l,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==u?(v={reference:a,snippets:u},e[4]=a,e[5]=u,e[6]=v):v=e[6];let k=v,O;e[7]!==l?(O=l("OpenAPI"),e[7]=l,e[8]=O):O=e[8];let h;e[9]!==l?(h=l("OpenRPC"),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==O||e[12]!==h?(g={openapi:O,openrpc:h},e[11]=O,e[12]=h,e[13]=g):g=e[13];let x=g,b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=p(A=>{d(A.currentTarget.dataset.view)},"t7"),e[14]=b):b=e[14];let S=b,y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=p(A=>{m(A.currentTarget.dataset.format)},"t8"),e[15]=y):y=e[15];let $=y,N;e[16]!==l?(N=l("API view"),e[16]=l,e[17]=N):N=e[17];let w;e[18]!==i||e[19]!==k?(w=os.map(A=>(0,z.jsxDEV)(H,{"aria-selected":i===A,"data-testid":`api-view-${A}`,"data-view":A,onClick:S,role:"tab",size:"sm",type:"button",variant:i===A?"default":"outline",children:k[A]},A,!1)),e[18]=i,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==w||e[22]!==N?(C=(0,z.jsxDEV)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-view-toggle",role:"tablist",children:w},void 0,!1),e[21]=w,e[22]=N,e[23]=C):C=e[23];let T;e[24]!==c||e[25]!==x||e[26]!==l||e[27]!==i?(T=i==="reference"&&(0,z.jsxDEV)("div",{"aria-label":l("API spec format"),className:"flex gap-1.5","data-testid":"api-format-toggle",role:"tablist",children:ns.map(A=>(0,z.jsxDEV)(H,{"aria-selected":c===A,"data-format":A,"data-testid":`api-format-${A}`,onClick:$,role:"tab",size:"sm",type:"button",variant:c===A?"default":"outline",children:x[A]},A,!1))},void 0,!1),e[24]=c,e[25]=x,e[26]=l,e[27]=i,e[28]=T):T=e[28];let I;e[29]!==C||e[30]!==T?(I=(0,z.jsxDEV)("div",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-6 py-3",children:[C,T]},void 0,!0),e[29]=C,e[30]=T,e[31]=I):I=e[31];let P;e[32]!==o||e[33]!==s||e[34]!==i?(P=i==="snippets"&&(0,z.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:(0,z.jsxDEV)(je,{functions:o,initialShardKey:s},void 0,!1)},void 0,!1),e[32]=o,e[33]=s,e[34]=i,e[35]=P):P=e[35];let E;e[36]!==c||e[37]!==n||e[38]!==i?(E=i==="reference"&&c==="openapi"&&(0,z.jsxDEV)(He,{spec:n},void 0,!1),e[36]=c,e[37]=n,e[38]=i,e[39]=E):E=e[39];let j;e[40]!==c||e[41]!==r||e[42]!==i?(j=i==="reference"&&c==="openrpc"&&(0,z.jsxDEV)(Ge,{spec:r},void 0,!1),e[40]=c,e[41]=r,e[42]=i,e[43]=j):j=e[43];let R;e[44]!==P||e[45]!==E||e[46]!==j?(R=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[P,E,j]},void 0,!0),e[44]=P,e[45]=E,e[46]=j,e[47]=R):R=e[47];let L;return e[48]!==I||e[49]!==R?(L=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"lunora-api-tab",children:[I,R]},void 0,!0),e[48]=I,e[49]=R,e[50]=L):L=e[50],L},"ApiTab");export{Ws as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b,c as v,d as g,f as D}from"./chunk-GLUNBZRI.js";import{e as y,f as p,g as P,k as O}from"./chunk-E75ANNWX.js";import{a as n,e as Q,f as N,g as _}from"./chunk-RRCPZMC2.js";var E=Q(_(),1);var c=Q(N(),1);var C=n((e,r,o)=>["lunora-admin",e,r,o.trim()],"adminQueryKey"),h=1e3,S=25,q=new Map,k=n(e=>{let r=Date.now(),o=(q.get(e)??[]).filter(s=>r-s<h);o.push(r),q.set(e,o),o.length===S&&(console.error(`[lunora-studio] possible request loop: ${e} fired ${String(S)}\xD7 in <1s \u2014 a render/effect is re-issuing this read unbounded.`),console.trace("[lunora-studio] request-loop call site"))},"noteQueryFetch");function R(e,r,o={}){let{enabled:s=!0,keepPreviousData:a=!1,staleTime:i=0}=o,t=g({enabled:s,queryFn:n(()=>(k(JSON.stringify(e)),r()),"trackedQueryFunction"),placeholderData:a?b:void 0,queryKey:e,staleTime:i});return{data:t.data,error:t.error?P(t.error):t.error,errorSource:t.error??void 0,isLoading:t.isLoading,liveError:void 0,refetch:n(()=>{O(t.refetch())},"refetch")}}n(R,"useClientQuery");function K(e,r,o={}){let s=D(),a=v(),{enabled:i=!0,keepPreviousData:u=!1,live:t=!1,shardKey:l="",staleTime:I}=o,d=C(e,r,l),L=R(d,()=>s.query(y(e),r,p(l)),{enabled:i,keepPreviousData:u,staleTime:I??(t?Number.POSITIVE_INFINITY:0)}),[T,f]=(0,c.useState)(void 0),F=JSON.stringify(d);return(0,c.useEffect)(()=>{if(!(!i||!t))return f(void 0),s.subscribe(y(e),r,m=>{f(void 0),a.setQueryData(d,m)},{...p(l),onError:n(m=>{f(m.message)},"onError")})},[F,i,t]),{...L,liveError:i&&t?T:void 0}}n(K,"useAdminQuery");var M=n(()=>{let e=(0,E.c)(2),r=v(),o;return e[0]!==r?(o=n((s,a,i)=>{let u=a===void 0?["lunora-admin",s]:C(s,a,i??"");O(r.invalidateQueries({queryKey:u}))},"t0"),e[0]=r,e[1]=o):o=e[1],o},"useInvalidateAdmin");export{R as a,K as b,M as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as V}from"./chunk-XNJNSCLM.js";import{g as w,h as A,i as E}from"./chunk-E75ANNWX.js";import{a as b}from"./chunk-GMSGZDDH.js";import{a as x,e as N,g as D,h as H}from"./chunk-RRCPZMC2.js";var g=N(D(),1);var d=N(H(),1);var y=x(k=>{let e=(0,g.c)(26),{className:u,error:t,testId:h}=k,o,l,i,s,a,r,n;if(e[0]!==u||e[1]!==t||e[2]!==h){let v=A(t),p;e[10]!==t?(p=E(t),e[10]=t,e[11]=p):p=e[11],l=p,o=V,i=u,s=h,a="destructive";let m;e[12]!==t?(m=w(t),e[12]=t,e[13]=m):m=e[13],e[14]!==m?(r=(0,d.jsxDEV)("p",{className:"font-medium",children:m},void 0,!1),e[14]=m,e[15]=r):r=e[15],n=v===void 0?null:(0,d.jsxDEV)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:b(v)},void 0,!1),e[0]=u,e[1]=t,e[2]=h,e[3]=o,e[4]=l,e[5]=i,e[6]=s,e[7]=a,e[8]=r,e[9]=n}else o=e[3],l=e[4],i=e[5],s=e[6],a=e[7],r=e[8],n=e[9];let c;e[16]!==l?(c=l===void 0?null:(0,d.jsxDEV)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:l,rel:"noreferrer",target:"_blank",children:"View error docs"},void 0,!1),e[16]=l,e[17]=c):c=e[17];let f;return e[18]!==o||e[19]!==i||e[20]!==s||e[21]!==a||e[22]!==r||e[23]!==n||e[24]!==c?(f=(0,d.jsxDEV)(o,{className:i,testId:s,variant:a,children:[r,n,c]},void 0,!0),e[18]=o,e[19]=i,e[20]=s,e[21]=a,e[22]=r,e[23]=n,e[24]=c,e[25]=f):f=e[25],f},"ErrorAlert");export{y as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as le}from"./chunk-UGUEC6BC.js";import{a as te}from"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import{a as ae,b as se,c as oe,d as Q,e as $,f as z}from"./chunk-GTM65MVX.js";import{a as re}from"./chunk-VLXV72QE.js";import{a as C}from"./chunk-JSEXCW5Q.js";import{a as ee}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as J}from"./chunk-TAD43CG5.js";import{b as U}from"./chunk-C7WTJLC3.js";import{a as j,b as K,c as V,d as Y,e as q}from"./chunk-SEU5V7I6.js";import{b as I}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as W}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as O,e as G,f as X,g as Z,k as D}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as n,e as B,f as ve,g as he,h as xe}from"./chunk-RRCPZMC2.js";var c=B(ve(),1);var ne=B(he(),1);var e=B(xe(),1);var ie=["read","insert","update","delete"],ye=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"operationLabel"),ge=n(a=>{let t=new Set;for(let l of a?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:r}=l.metadata;typeof r=="string"&&r!==""&&t.add(r)}return t},"uncoveredTables"),be=n((a,t,l)=>{let r=new Map,s=n(o=>{let d=r.get(o);if(d!==void 0)return d;let i={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:o,uncovered:l.has(o)};return r.set(o,i),i},"ensure");for(let o of a)s(o.table).cells[o.on]={procedure:o.procedure};for(let o of t){let d=s(o.table);d.maskedColumns.includes(o.column)||d.maskedColumns.push(o.column)}for(let o of l)s(o);return[...r.values()].toSorted((o,d)=>o.table.localeCompare(d.table))},"buildRows"),Ne=n(a=>{let t=(0,ne.c)(17),l;t[0]!==a?(l=a===void 0?{}:a,t[0]=a,t[1]=l):l=t[1];let{onProbe:r}=l,s=O(),o,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={},d={live:!0},t[2]=o,t[3]=d):(o=t[2],d=t[3]);let i=U(L.rlsPolicies,o,d),x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x={},t[4]=x):x=t[4];let p=U(L.maskPolicies,x),v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v={},t[5]=v):v=t[5];let b=U(L.getAdvisories,v),N;if(t[6]!==b.data||t[7]!==p.data||t[8]!==r||t[9]!==i||t[10]!==s){let g=null;i.data!==void 0&&(g=Array.isArray(i.data.policies)?i.data.policies:[]);let _=Array.isArray(p.data?.columns)?p.data.columns:[],F=b.data??null,{error:h,errorSource:m,liveError:P}=i,A=g===null?[]:be(g,_,ge(F)),T;t[12]!==P?(T=(0,e.jsxDEV)("div",{className:"flex items-center justify-end",children:(0,e.jsxDEV)(le,{message:P,prefix:"pm"},void 0,!1)},void 0,!1),t[12]=P,t[13]=T):T=t[13];let y;t[14]!==h||t[15]!==m?(y=h!==null&&(0,e.jsxDEV)(te,{error:m,testId:"pm-error"},void 0,!1),t[14]=h,t[15]=m,t[16]=y):y=t[16],N=(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[T,y,g!==null&&A.length===0?(0,e.jsxDEV)(J,{description:s("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:s("No policy")},void 0,!1):(0,e.jsxDEV)(ae,{"data-testid":"pm-table",children:[(0,e.jsxDEV)(se,{children:(0,e.jsxDEV)(Q,{children:[(0,e.jsxDEV)($,{children:s("Table")},void 0,!1),ie.map(u=>(0,e.jsxDEV)($,{children:ye(s,u)},u,!1)),(0,e.jsxDEV)($,{children:s("Masked columns")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(oe,{children:A.map(u=>(0,e.jsxDEV)(Q,{"data-testid":`pm-row-${u.table}`,children:[(0,e.jsxDEV)(z,{className:"font-mono text-xs",children:(0,e.jsxDEV)("span",{className:"flex items-center gap-1.5",children:[u.table,u.uncovered&&(0,e.jsxDEV)(I,{"data-testid":`pm-uncovered-${u.table}`,title:s("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:s("Uncovered \u2014 reachable without a policy")},void 0,!1)]},void 0,!0)},void 0,!1),ie.map(w=>{let R=u.cells[w];return(0,e.jsxDEV)(z,{"data-testid":`pm-cell-${u.table}-${w}`,children:R.procedure===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("No policy")},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Covered by {procedure}",{procedure:R.procedure})},void 0,!1),r!==void 0&&(0,e.jsxDEV)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${u.table}-${w}`,onClick:n(()=>{r(u.table,w,R.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Probe this")},void 0,!1)]},void 0,!0)},w,!1)}),(0,e.jsxDEV)(z,{children:u.maskedColumns.length===0?(0,e.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:u.maskedColumns.map(ke)},void 0,!1)},void 0,!1)]},u.table,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),t[6]=b.data,t[7]=p.data,t[8]=r,t[9]=i,t[10]=s,t[11]=N}else N=t[11];return N},"PermissionsMatrix");function ke(a){return(0,e.jsxDEV)(I,{variant:"outline",children:a},a,!1)}n(ke,"_temp");var Ce=G(L.runAs),we=n(()=>{let a=W();return async({args:t,functionPath:l,shardKey:r="",userId:s})=>{let o=Ce;try{return{kind:"allowed",value:await a.query(o,{args:t,functionPath:l,userId:s},X(r))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"useRunAsProbe"),Se=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"formatValue"),Pe=n(({functions:a,prefill:t,runAsIdentity:l=!1}={})=>{let r=W(),s=O(),o=we(),[d,i]=(0,c.useState)(null),[x,p]=(0,c.useState)(null),v=a??d??[],[b,N]=(0,c.useState)(""),[g,_]=(0,c.useState)("{}"),[F,h]=(0,c.useState)(""),[m,P]=(0,c.useState)(""),[A,T]=(0,c.useState)(!1),[y,u]=(0,c.useState)(null),[w,R]=(0,c.useState)(null),H=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let f=!1;return r.listFunctions().then(S=>(f||i(S),S)).catch(S=>{f||p(Z(S))}),()=>{f=!0}},[r,a]),(0,c.useEffect)(()=>{if(t===void 0||H.current===t.nonce)return;H.current=t.nonce;let f=t.functionPath;queueMicrotask(()=>{N(f),u(null)})},[t]);let M=b===""?v[0]?.path??"":b,ce=n(async()=>{if(M==="")return;let f;try{f=g.trim()===""?{}:JSON.parse(g)}catch(S){R(s("Invalid JSON args: {message}",{message:S.message})),u(null);return}R(null),T(!0);try{let S=await o({args:f,functionPath:M,shardKey:F.trim(),userId:m.trim()});u(S)}finally{T(!1)}},"run"),fe=n(()=>{D(ce())},"runOnce"),ue=n(f=>{N(f.target.value)},"onSelectChange"),me=n(f=>{_(f.target.value)},"onArgsChange"),pe=n(f=>{P(f.target.value)},"onUserIdChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[x!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:x},void 0,!1),!l&&(0,e.jsxDEV)(J,{description:s("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:s("Set `runAsIdentity` to forge an identity and probe access.")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-function",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:ue,value:M,children:v.map(f=>(0,e.jsxDEV)("option",{value:f.path,children:[f.path," (",f.kind,")"]},f.path,!0))},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-args",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(re,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:me,value:g},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(ee,{onChange:h,testId:"pp-shard",value:F},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-user",children:s("Run as (userId)")},void 0,!1),(0,e.jsxDEV)(E,{"aria-label":s("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:pe,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"pp-run",disabled:!l||A||M==="",onClick:fe,type:"button",children:s(A?"Probing\u2026":"Run probe")},void 0,!1),m.trim()!==""&&(0,e.jsxDEV)(I,{"data-testid":"pp-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:w},void 0,!1),y!==null&&y.kind==="allowed"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Allowed")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Se(y.value)},void 0,!1)]},void 0,!0),y!==null&&y.kind==="denied"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsxDEV)(I,{variant:"destructive",children:s("Denied")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:y.message},void 0,!1)]},void 0,!0)]},void 0,!0)},"PermissionsPlayground"),Ae="/__lunora/policy-scaffold",Te={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ie=n(async a=>{let t=await fetch(Ae,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),l=await t.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(t.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let r=l.error;return{kind:"error",message:r===void 0?`policy scaffold failed (${String(t.status)})`:Te[r]??r}},"applyPolicyScaffold"),de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ee=n(()=>{let a=O(),[t,l]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[o,d]=(0,c.useState)(null),[i,x]=(0,c.useState)(de),p=n(h=>{let m=h.target.name,{value:P}=h.target;x(A=>({...A,[m]:P}))},"onFieldChange"),v=n(()=>{l(null),x(de)},"reset"),b=n(async h=>{s(!0),d(null);try{let m=await Ie(h);d(m),m.kind==="ok"&&v()}catch(m){d({kind:"error",message:m instanceof Error?m.message:String(m)})}finally{s(!1)}},"submit"),N=n(()=>{D(b({kind:"scaffoldPolicy",name:i.policyName.trim(),table:i.tableName.trim()}))},"onSubmitScaffold"),g=n(()=>{D(b({exportName:i.exportName.trim(),filePath:i.filePath.trim(),kind:"wireRls",policies:i.policies.trim()}))},"onSubmitWire"),_=n(()=>{d(null),l("scaffold")},"openScaffold"),F=n(()=>{d(null),l("wire")},"openWire");return(0,e.jsxDEV)(j,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxDEV)(K,{children:[(0,e.jsxDEV)(V,{children:a("Scaffold access rules")},void 0,!1),(0,e.jsxDEV)(Y,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-new",onClick:_,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")},void 0,!1),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-wire",onClick:F,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")},void 0,!1)]},void 0,!0),t==="scaffold"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-name",children:a("Policy name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:p,value:i.policyName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-table",children:a("Table name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:p,value:i.tableName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-create",disabled:r||i.policyName.trim()===""||i.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),t==="wire"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:p,value:i.filePath},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:p,value:i.exportName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:p,value:i.policies},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-apply",disabled:r||i.filePath.trim()===""||i.exportName.trim()===""||i.policies.trim()==="",onClick:g,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),o?.kind==="error"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message},void 0,!1),o?.kind==="needs-manual-edit"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")},void 0,!1),o?.kind==="ok"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsxDEV)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})},void 0,!1),o.diagnostics.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(h=>(0,e.jsxDEV)("li",{className:"font-mono text-[11px] text-destructive",children:h},h,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"PolicyScaffolder"),He=n(({functions:a,runAsIdentity:t=!1,schemaEditable:l=!1}={})=>{let r=O(),[s,o]=(0,c.useState)(void 0),d=n((i,x,p)=>{p!==""&&o(v=>({functionPath:p,nonce:(v?.nonce??0)+1}))},"onProbe");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Permissions")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(Ne,{onProbe:d},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:(0,e.jsxDEV)(j,{className:"gap-0 py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Probe")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(q,{className:"px-4 py-4",children:[(0,e.jsxDEV)("p",{className:"mb-3 text-sm text-muted-foreground",children:r("Pick a function and an identity, then run it to see the access outcome.")},void 0,!1),(0,e.jsxDEV)(Pe,{functions:a,prefill:s,runAsIdentity:t},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),l&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,e.jsxDEV)(Ee,{},void 0,!1)},void 0,!1)]},void 0,!0)},"PermissionsPanel");export{He as PermissionsPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as r,e as p,f as m}from"./chunk-RRCPZMC2.js";function d(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}r(d,"mergeObjects");var R={};function h(e,t,n,o,i){if(!n&&!o&&!i&&!e)return y(t);let c=y(e);return t&&(c=E(c,t)),n&&(c=E(c,n)),o&&(c=E(c,o)),i&&(c=E(c,i)),c}r(h,"mergeProps");function T(e){if(e.length===0)return R;if(e.length===1)return y(e[0]);let t=y(e[0]);for(let n=1;n<e.length;n+=1)t=E(t,e[n]);return t}r(T,"mergePropsN");function y(e){return b(e)?{...x(e,R)}:K(e)}r(y,"createInitialMergedProps");function E(e,t){return b(t)?x(t,e):q(e,t)}r(E,"mergeInto");function K(e){let t={...e};for(let n in t){let o=t[n];_(n,o)&&(t[n]=k(o))}return t}r(K,"copyInitialProps");function q(e,t){if(!t)return e;for(let n in t){let o=t[n];switch(n){case"style":{e[n]=d(e.style,o);break}case"className":{e[n]=v(e.className,o);break}default:_(n,o)?e[n]=Q(e[n],o):e[n]=o}}return e}r(q,"mutablyMergeInto");function _(e,t){let n=e.charCodeAt(0),o=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&o===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}r(_,"isEventHandler");function b(e){return typeof e=="function"}r(b,"isPropsGetter");function x(e,t){return b(e)?e(t):e??R}r(x,"resolvePropsGetter");function Q(e,t){return t?e?(...n)=>{let o=n[0];if(V(o)){let c=o;M(c);let s=t(...n);return c.baseUIHandlerPrevented||e?.(...n),s}let i=t(...n);return e?.(...n),i}:k(t):e}r(Q,"mergeEventHandlers");function k(e){return e&&((...t)=>{let n=t[0];return V(n)&&M(n),e(...t)})}r(k,"wrapEventHandler");function M(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(M,"makeEventPreventable");function v(e,t){return t?e?t+" "+e:t:e}r(v,"mergeClassNames");function V(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(V,"isSyntheticEvent");var f=p(m(),1);var S=p(m(),1);var j={};function N(e,t){let n=S.useRef(j);return n.current===j&&(n.current=e(t)),n}r(N,"useRefWithInit");function g(e,t,n,o){let i=N(L).current;return X(i,e,t,n,o)&&$(i,[e,t,n,o]),i.callback}r(g,"useMergedRefs");function U(e){let t=N(L).current;return ee(t,e)&&$(t,e),t.callback}r(U,"useMergedRefsN");function L(){return{callback:null,cleanup:null,refs:[]}}r(L,"createForkRef");function X(e,t,n,o,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==o||e.refs[3]!==i}r(X,"didChange");function ee(e,t){return e.refs.length!==t.length||e.refs.some((n,o)=>n!==t[o])}r(ee,"didChangeN");function $(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){let o=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){let c=t[i];if(c!=null)switch(typeof c){case"function":{let s=c(n);typeof s=="function"&&(o[i]=s);break}case"object":{c.current=n;break}default:}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){let c=t[i];if(c!=null)switch(typeof c){case"function":{let s=o[i];typeof s=="function"?s():c(null);break}case"object":{c.current=null;break}default:}}}}}}r($,"update");var Y=p(m(),1);var B=p(m(),1);var te=parseInt(B.version,10);function D(e){return te>=e}r(D,"isReactVersionAtLeast");function A(e){if(!Y.isValidElement(e))return null;let t=e,n=t.props;return(D(19)?n?.ref:t.ref)??null}r(A,"getReactElementRef");var I;I=new Set;function z(...e){{let t=e.join(" ");I.has(t)||(I.add(t),console.warn(`Base UI: ${t}`))}}r(z,"warn");function Ce(){}r(Ce,"NOOP");var Oe=Object.freeze([]),l=Object.freeze({});function W(e,t){let n={};for(let o in e){let i=e[o];if(t?.hasOwnProperty(o)){let c=t[o](i);c!=null&&Object.assign(n,c);continue}i===!0?n[`data-${o.toLowerCase()}`]="":i&&(n[`data-${o.toLowerCase()}`]=i.toString())}return n}r(W,"getStateAttributesProps");function Z(e,t){return typeof e=="function"?e(t):e}r(Z,"resolveClassName");function F(e,t){return typeof e=="function"?e(t):e}r(F,"resolveStyle");var P=p(m(),1);function Fe(e,t,n={}){let o=t.render,i=ne(t,n);if(n.enabled===!1)return null;let c=n.state??l;return se(e,o,i,c)}r(Fe,"useRenderElement");function ne(e,t={}){let{className:n,style:o,render:i}=e,{state:c=l,ref:s,props:w,stateAttributesMapping:G,enabled:a=!0}=t,C=a?Z(n,c):void 0,O=a?F(o,c):void 0,H=a?W(c,G):l,J=a&&w?re(w):void 0,u=a?d(H,J)??{}:l;return typeof document<"u"&&(a?Array.isArray(s)?u.ref=U([u.ref,A(i),...s]):u.ref=g(u.ref,A(i),s):g(null,null)),a?(C!==void 0&&(u.className=v(u.className,C)),O!==void 0&&(u.style=d(u.style,O)),u):l}r(ne,"useRenderElementProps");function re(e){return Array.isArray(e)?T(e):h(void 0,e)}r(re,"resolveRenderFunctionProps");var oe=Symbol.for("react.lazy"),ie=/^[A-Z][A-Za-z0-9$]*$/,ce=/[a-z]/;function se(e,t,n,o){if(t){if(typeof t=="function")return ue(t),t(n,o);let i=h(n,t.props);i.ref=n.ref;let c=t;if(c?.$$typeof===oe&&(c=f.Children.toArray(t)[0]),!f.isValidElement(c))throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.","A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.","https://base-ui.com/r/invalid-render-prop"].join(`
|
|
2
|
+
`));return f.cloneElement(c,i)}if(e&&typeof e=="string")return fe(e,n);throw new Error("Base UI: Render element or function are not defined.")}r(se,"evaluateRenderProp");function ue(e){let t=e.name;t.length!==0&&ie.test(t)&&ce.test(t)&&z(`The \`render\` prop received a function named \`${t}\` that starts with an uppercase letter.`,"This usually means a React component was passed directly as `render={Component}`.","Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.","If this is an intentional render callback, rename it to start with a lowercase letter.","Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.","https://base-ui.com/r/invalid-render-prop")}r(ue,"warnIfRenderPropLooksLikeComponent");function fe(e,t){return e==="button"?(0,P.createElement)("button",{type:"button",...t,key:t.key}):e==="img"?(0,P.createElement)("img",{alt:"",...t,key:t.key}):f.createElement(e,t)}r(fe,"renderTag");export{h as a,M as b,N as c,g as d,D as e,z as f,Ce as g,Oe as h,l as i,Fe as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as V}from"./chunk-VLXV72QE.js";import{a as g}from"./chunk-JSEXCW5Q.js";import{a as z}from"./chunk-UKDJ4H7I.js";import{b as q}from"./chunk-TBMYIZIO.js";import{R as j}from"./chunk-3CJW6NWG.js";import{c as p}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as P}from"./chunk-BOXSWNXZ.js";import{b as w}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as L}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,e as B,g as J,k as K,o as M}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a,e as D,f as oe,h as ne}from"./chunk-RRCPZMC2.js";var n=D(oe(),1);var t=D(ne(),1);var ie=a(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"argumentType"),de=a(r=>r===void 0||r.length===0?"()":`(${r.map(l=>`${l.name}${l.optional?"?":""}: ${ie(l)}`).join(", ")})`,"formatSignature"),le=a(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"placeholderValue"),ce=a(r=>{let l={};for(let s of r??[])s.optional||(l[s.name]=le(s.kind));return JSON.stringify(l,void 0,2)},"argumentsTemplate"),ue=B(P.runAs),fe=10,me=a(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"formatResult"),Ie=a(({functions:r,runAsIdentity:l=!1}={})=>{let s=U(),c=L(),[H,X]=(0,n.useState)(null),[k,Y]=(0,n.useState)(null),x=r??H??[],[R,I]=(0,n.useState)(""),[f,b]=(0,n.useState)("{}"),[u,A]=(0,n.useState)(""),[m,G]=(0,n.useState)(""),[N,h]=(0,n.useState)("idle"),[Q,y]=(0,n.useState)(void 0),[C,S]=(0,n.useState)(null),[T,W]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(r!==void 0)return;let e=!1;return c.listFunctions().then(i=>(e||X(i),i)).catch(i=>{e||Y(J(i))}),()=>{e=!0}},[c,r]);let F=R===""?x[0]?.path??"":R,o=x.find(e=>e.path===F),Z=a(async()=>{if(!o)return;let e;try{e=f.trim()===""?{}:JSON.parse(f)}catch(d){h("error"),y(void 0),S(s("Invalid JSON args: {message}",{message:d.message}));return}let i={__lunoraRef:o.path},v=u.trim()===""?{}:{shardKey:u.trim()},$=l?m.trim():"",E=a(d=>{W(O=>[{argsText:f,at:Date.now(),id:(O[0]?.id??0)+1,kind:o.kind,path:o.path,shardKey:u,status:d},...O].slice(0,fe))},"record");h("running"),S(null);try{let d;if($==="")switch(o.kind){case"action":{d=await c.action(i,e,v);break}case"mutation":{d=await c.mutation(i,e,v);break}default:d=await c.query(i,e,v)}else d=await c.query(ue,{args:e,functionPath:o.path,userId:$},v);q(u),y(d),h("success"),E("success")}catch(d){y(void 0),S(d.message),h("error"),E("error")}},"run"),_=a(e=>{I(e.path),b(e.argsText),A(e.shardKey)},"loadRun"),ee=a(e=>{I(e.target.value)},"onSelectChange"),te=a(e=>{b(e.target.value)},"onArgsChange"),re=a(e=>{G(e.target.value)},"onRunAsChange"),se=a(()=>{K(Z())},"runOnce"),ae=a(()=>{b(ce(o?.args))},"prefillArgs");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)(g,{htmlFor:"function-select",children:s("Function")},void 0,!1),(0,t.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:ee,value:F,children:x.map(e=>(0,t.jsxDEV)("option",{value:e.path,children:[e.path," (",e.kind,")"]},e.path,!0))},void 0,!1),o!==void 0&&(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:[(0,t.jsxDEV)("span",{className:"mr-1.5 font-medium",children:s("Signature")},void 0,!1),(0,t.jsxDEV)("code",{className:"font-mono","data-testid":"function-signature",children:de(o.args)},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxDEV)(g,{htmlFor:"args-input",children:s("Arguments")},void 0,!1),(0,t.jsxDEV)(p,{"data-testid":"prefill-button",disabled:o===void 0,onClick:ae,size:"xs",type:"button",variant:"ghost",children:s("Prefill")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(V,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:te,value:f},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(z,{onChange:A,testId:"shard-input",value:u},void 0,!1),l&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,t.jsxDEV)(g,{htmlFor:"run-as-input",children:s("Run as identity (userId)")},void 0,!1),(0,t.jsxDEV)(j,{"aria-label":s("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:re,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1),(0,t.jsxDEV)("p",{className:"text-[11px] text-muted-foreground",children:s("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(p,{"data-testid":"run-button",disabled:N==="running"||o===void 0,onClick:se,type:"button",children:s("Run")},void 0,!1),o!==void 0&&(0,t.jsxDEV)(w,{variant:"outline",children:o.kind},void 0,!1),l&&m.trim()!==""&&(0,t.jsxDEV)(w,{"data-testid":"run-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),N==="error"&&C!==null&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C},void 0,!1),N==="success"&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:me(Q)},void 0,!1),T.length>0&&(0,t.jsxDEV)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:T.map((e,i)=>(0,t.jsxDEV)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,t.jsxDEV)("span",{className:e.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${i.toString()}`,children:e.status==="success"?"\u2713":"\u2717"},void 0,!1)," ",(0,t.jsxDEV)("span",{className:"font-mono text-xs",children:[e.path," (",e.kind,")"]},void 0,!0)," ",(0,t.jsxDEV)("time",{className:"text-xs text-muted-foreground",children:M(e.at)},void 0,!1)," ",(0,t.jsxDEV)(p,{className:"ml-auto","data-testid":`fn-history-load-${i.toString()}`,onClick:a(()=>{_(e)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Load")},void 0,!1)]},e.id,!0))},void 0,!1)]},void 0,!0)},"FunctionRunner");export{Ie as FunctionRunner};
|