@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 as k,b as j}from"./chunk-KJJ3WM6H.js";import{a as D}from"./chunk-UGUEC6BC.js";import{a as O}from"./chunk-2K47A3P6.js";import{a as V}from"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import{a as _,b as z,c as B,d as f,e as l,f as n}from"./chunk-GTM65MVX.js";import{a as M}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as L}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as H}from"./chunk-BOXSWNXZ.js";import{a as I}from"./chunk-TAD43CG5.js";import{b as A}from"./chunk-C7WTJLC3.js";import{a as y,e as E}from"./chunk-SEU5V7I6.js";import{b as T}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as C,o as R}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as i,e as w,f as ee,h as te}from"./chunk-RRCPZMC2.js";var o=w(ee(),1);var e=w(te(),1);var K=80,ae=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>K?`${t.slice(0,K)}\u2026`:t},"formatDetail"),re=41,F=480,U=5,oe=i((s,t)=>k(s,d=>{t(d.height>0?d:{height:F,width:d.width})}),"observeViewportRect"),Se=i(({initialShardKey:s})=>{let t=C(),[d,G]=(0,o.useState)(s??""),[m,W]=(0,o.useState)(""),q=O(d.trim(),400),{data:v,error:p,errorSource:J,isLoading:P,liveError:Q}=A(H.getAuditLog,{},{live:!0,shardKey:q}),u=(0,o.useMemo)(()=>v?.entries??[],[v]),c=(0,o.useMemo)(()=>{let r=m.trim().toLowerCase();return r===""?u:u.filter(a=>a.op.toLowerCase().includes(r)||(a.table??"").toLowerCase().includes(r)||(a.id??"").toLowerCase().includes(r))},[u,m]),g=(0,o.useRef)(null),x=j({count:c.length,estimateSize:i(()=>re,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:F,width:800},observeElementRect:oe,overscan:8}),h=x.getVirtualItems(),X=x.getTotalSize(),S=h[0]?.start??0,b=X-(h.at(-1)?.end??0),Z={height:S},$={height:b},Y=i(r=>{W(r.target.value)},"onSearchChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(M,{onChange:G,testId:"au-shard-input",value:d},void 0,!1),(0,e.jsxDEV)(D,{message:Q,prefix:"au"},void 0,!1),(0,e.jsxDEV)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:m},void 0,!1)]},void 0,!0),p!==null&&(0,e.jsxDEV)(V,{error:J,testId:"au-error"},void 0,!1),p===null&&!P&&c.length===0&&(0,e.jsxDEV)(I,{description:t("State-changing admin operations are recorded here."),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:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"},void 0,!1)},void 0,!1),testId:"au-empty",title:t("No audit entries.")},void 0,!1),c.length>0&&(0,e.jsxDEV)(y,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:g,children:(0,e.jsxDEV)(_,{"data-testid":"au-table",children:[(0,e.jsxDEV)(z,{children:(0,e.jsxDEV)(f,{children:[(0,e.jsxDEV)(l,{children:t("time")},void 0,!1),(0,e.jsxDEV)(l,{children:t("op")},void 0,!1),(0,e.jsxDEV)(l,{children:t("table")},void 0,!1),(0,e.jsxDEV)(l,{children:t("id")},void 0,!1),(0,e.jsxDEV)(l,{children:t("detail")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(B,{children:[S>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:Z},void 0,!1)},void 0,!1),h.map(r=>{let a=c[r.index],N=ae(a.detail);return(0,e.jsxDEV)(f,{"data-testid":"au-row",children:[(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:R(a.ts,"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:a.op},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"font-medium",children:a.table??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:a.id??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},a.seq,!0)}),b>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:$},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AuditPanel");export{Se as AuditPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _}from"./chunk-3OA7PECS.js";import{a as n,e as E,f as S}from"./chunk-RRCPZMC2.js";var u=E(_(),1),o="base-ui-disable-scrollbar",d={className:o,getElement(t){return(0,u.jsx)("style",{nonce:t,href:o,precedence:"base-ui:low",children:`.${o}{scrollbar-width:none}.${o}::-webkit-scrollbar{display:none}`})}};d.getElement.displayName="styleDisableScrollbar.getElement";var s=E(S(),1);var p=s.createContext(void 0);p.displayName="CSPContext";var N={disableStyleElements:!1};function C(){return s.useContext(p)??N}n(C,"useCSPContext");function f(t,e=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,r))}n(f,"clamp");var m=1;function h(t,e){return Math.max(0,t-e)}n(h,"getMaxScrollOffset");function O(t,e){if(e<=0)return 0;let r=f(t,0,e),c=r,l=e-r,a=c<=m,i=l<=m;return a&&i?c<=l?0:e:a?0:i?e:r}n(O,"normalizeScrollOffset");export{d as a,C as b,f as c,m as d,h as e,O as f};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{a,c as te,e as de,f as qe}from"./chunk-RRCPZMC2.js";var pe=te((he,W)=>{(function(e,r){typeof define=="function"&&define.amd?define([],r):typeof W=="object"&&W.exports?W.exports=r():e.moo=r()})(he,function(){"use strict";var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,t=typeof new RegExp().sticky=="boolean";function s(n){return n&&r.call(n)==="[object RegExp]"}a(s,"isRegExp");function i(n){return n&&typeof n=="object"&&!s(n)&&!Array.isArray(n)}a(i,"isObject");function l(n){return n.replace(/[-\/\\^$*+?.()|[\]{}]/g,function(o){return o==="-"?"\\x2d":"\\"+o})}a(l,"reEscape");function c(n){var o=new RegExp("|"+n);return o.exec("").length-1}a(c,"reGroups");function h(n){return"("+n+")"}a(h,"reCapture");function v(n){if(!n.length)return"(?!)";var o=n.map(function(u){return"(?:"+u+")"}).join("|");return"(?:"+o+")"}a(v,"reUnion");function S(n){if(typeof n=="string")return"(?:"+l(n)+")";if(s(n)){if(n.ignoreCase)throw new Error("RegExp /i flag not allowed");if(n.global)throw new Error("RegExp /g flag is implied");if(n.sticky)throw new Error("RegExp /y flag is implied");if(n.multiline)throw new Error("RegExp /m flag is implied");return n.source}else throw new Error("Not a pattern: "+n)}a(S,"regexpOrLiteral");function k(n,o){return n.length>o?n:Array(o-n.length+1).join(" ")+n}a(k,"pad");function M(n,o){for(var u=n.length,f=0;;){var g=n.lastIndexOf(`
|
|
2
|
+
`,u-1);if(g===-1||(f++,u=g,f===o)||u===0)break}var d=f<o?0:u+1;return n.substring(d).split(`
|
|
3
|
+
`)}a(M,"lastNLines");function K(n){for(var o=Object.getOwnPropertyNames(n),u=[],f=0;f<o.length;f++){var g=o[f],d=n[g],m=[].concat(d);if(g==="include"){for(var w=0;w<m.length;w++)u.push({include:m[w]});continue}var y=[];m.forEach(function(p){i(p)?(y.length&&u.push($(g,y)),u.push($(g,p)),y=[]):y.push(p)}),y.length&&u.push($(g,y))}return u}a(K,"objectToRules");function O(n){for(var o=[],u=0;u<n.length;u++){var f=n[u];if(f.include){for(var g=[].concat(f.include),d=0;d<g.length;d++)o.push({include:g[d]});continue}if(!f.type)throw new Error("Rule has no type: "+JSON.stringify(f));o.push($(f.type,f))}return o}a(O,"arrayToRules");function $(n,o){if(i(o)||(o={match:o}),o.include)throw new Error("Matching rules cannot also include states");var u={defaultType:n,lineBreaks:!!o.error||!!o.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var f in o)e.call(o,f)&&(u[f]=o[f]);if(typeof u.type=="string"&&n!==u.type)throw new Error("Type transform cannot be a string (type '"+u.type+"' for token '"+n+"')");var g=u.match;return u.match=Array.isArray(g)?g:g?[g]:[],u.match.sort(function(d,m){return s(d)&&s(m)?0:s(m)?-1:s(d)?1:m.length-d.length}),u}a($,"ruleOptions");function C(n){return Array.isArray(n)?O(n):K(n)}a(C,"toRules");var N=$("error",{lineBreaks:!0,shouldThrow:!0});function F(n,o){for(var u=null,f=Object.create(null),g=!0,d=null,m=[],w=[],y=0;y<n.length;y++)n[y].fallback&&(g=!1);for(var y=0;y<n.length;y++){var p=n[y];if(p.include)throw new Error("Inheritance is not allowed in stateless lexers");if(p.error||p.fallback){if(u)throw!p.fallback==!u.fallback?new Error("Multiple "+(p.fallback?"fallback":"error")+" rules not allowed (for token '"+p.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+p.defaultType+"')");u=p}var _=p.match.slice();if(g)for(;_.length&&typeof _[0]=="string"&&_[0].length===1;){var D=_.shift();f[D.charCodeAt(0)]=p}if(p.pop||p.push||p.next){if(!o)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+p.defaultType+"')");if(p.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+p.defaultType+"')")}if(_.length!==0){g=!1,m.push(p);for(var P=0;P<_.length;P++){var q=_[P];if(s(q)){if(d===null)d=q.unicode;else if(d!==q.unicode&&p.fallback===!1)throw new Error("If one rule is /u then all must be")}}var I=v(_.map(S)),T=new RegExp(I);if(T.test(""))throw new Error("RegExp matches empty string: "+T);var U=c(I);if(U>0)throw new Error("RegExp has capture groups: "+T+`
|
|
4
|
+
Use (?: \u2026 ) instead`);if(!p.lineBreaks&&T.test(`
|
|
5
|
+
`))throw new Error("Rule should declare lineBreaks: "+T);w.push(h(I))}}var R=u&&u.fallback,L=t&&!R?"ym":"gm",H=t||R?"":"|";d===!0&&(L+="u");var Pe=new RegExp(v(w)+H,L);return{regexp:Pe,groups:m,fast:f,error:u||N}}a(F,"compileRules");function X(n){var o=F(C(n));return new b({start:o},"start")}a(X,"compile");function fe(n,o,u){var f=n&&(n.push||n.next);if(f&&!u[f])throw new Error("Missing state '"+f+"' (in token '"+n.defaultType+"' of state '"+o+"')");if(n&&n.pop&&+n.pop!=1)throw new Error("pop must be 1 (in token '"+n.defaultType+"' of state '"+o+"')")}a(fe,"checkStateGroup");function $e(n,o){var u=n.$all?C(n.$all):[];delete n.$all;var f=Object.getOwnPropertyNames(n);o||(o=f[0]);for(var g=Object.create(null),d=0;d<f.length;d++){var m=f[d];g[m]=C(n[m]).concat(u)}for(var d=0;d<f.length;d++)for(var m=f[d],w=g[m],y=Object.create(null),p=0;p<w.length;p++){var _=w[p];if(_.include){var D=[p,1];if(_.include!==m&&!y[_.include]){y[_.include]=!0;var P=g[_.include];if(!P)throw new Error("Cannot include nonexistent state '"+_.include+"' (in state '"+m+"')");for(var q=0;q<P.length;q++){var I=P[q];w.indexOf(I)===-1&&D.push(I)}}w.splice.apply(w,D),p--}}for(var T=Object.create(null),d=0;d<f.length;d++){var m=f[d];T[m]=F(g[m],!0)}for(var d=0;d<f.length;d++){for(var U=f[d],R=T[U],L=R.groups,p=0;p<L.length;p++)fe(L[p],U,T);for(var H=Object.getOwnPropertyNames(R.fast),p=0;p<H.length;p++)fe(R.fast[H[p]],U,T)}return new b(T,o)}a($e,"compileStates");function Be(n){for(var o=typeof Map<"u",u=o?new Map:Object.create(null),f=Object.getOwnPropertyNames(n),g=0;g<f.length;g++){var d=f[g],m=n[d],w=Array.isArray(m)?m:[m];w.forEach(function(y){if(typeof y!="string")throw new Error("keyword must be string (in keyword '"+d+"')");o?u.set(y,d):u[y]=d})}return function(y){return o?u.get(y):u[y]}}a(Be,"keywordTransform");var b=a(function(n,o){this.startState=o,this.states=n,this.buffer="",this.stack=[],this.reset()},"Lexer");b.prototype.reset=function(n,o){return this.buffer=n||"",this.index=0,this.line=o?o.line:1,this.col=o?o.col:1,this.queuedToken=o?o.queuedToken:null,this.queuedText=o?o.queuedText:"",this.queuedThrow=o?o.queuedThrow:null,this.setState(o?o.state:this.startState),this.stack=o&&o.stack?o.stack.slice():[],this},b.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedText:this.queuedText,queuedThrow:this.queuedThrow}},b.prototype.setState=function(n){if(!(!n||this.state===n)){this.state=n;var o=this.states[n];this.groups=o.groups,this.error=o.error,this.re=o.regexp,this.fast=o.fast}},b.prototype.popState=function(){this.setState(this.stack.pop())},b.prototype.pushState=function(n){this.stack.push(this.state),this.setState(n)};var Ce=t?function(n,o){return n.exec(o)}:function(n,o){var u=n.exec(o);return u[0].length===0?null:u};b.prototype._getGroup=function(n){for(var o=this.groups.length,u=0;u<o;u++)if(n[u+1]!==void 0)return this.groups[u];throw new Error("Cannot find token type for matched text")};function De(){return this.value}if(a(De,"tokenToString"),b.prototype.next=function(){var n=this.index;if(this.queuedGroup){var o=this._token(this.queuedGroup,this.queuedText,n);return this.queuedGroup=null,this.queuedText="",o}var u=this.buffer;if(n!==u.length){var m=this.fast[u.charCodeAt(n)];if(m)return this._token(m,u.charAt(n),n);var f=this.re;f.lastIndex=n;var g=Ce(f,u),d=this.error;if(g==null)return this._token(d,u.slice(n,u.length),n);var m=this._getGroup(g),w=g[0];return d.fallback&&g.index!==n?(this.queuedGroup=m,this.queuedText=w,this._token(d,u.slice(n,g.index),n)):this._token(m,w,n)}},b.prototype._token=function(n,o,u){var f=0;if(n.lineBreaks){var g=/\n/g,d=1;if(o===`
|
|
6
|
+
`)f=1;else for(;g.exec(o);)f++,d=g.lastIndex}var m={type:typeof n.type=="function"&&n.type(o)||n.defaultType,value:typeof n.value=="function"?n.value(o):o,text:o,toString:De,offset:u,lineBreaks:f,line:this.line,col:this.col},w=o.length;if(this.index+=w,this.line+=f,f!==0?this.col=w-d+1:this.col+=w,n.shouldThrow){var y=new Error(this.formatError(m,"invalid syntax"));throw y}return n.pop?this.popState():n.push?this.pushState(n.push):n.next&&this.setState(n.next),m},typeof Symbol<"u"&&Symbol.iterator){var ee=a(function(n){this.lexer=n},"LexerIterator");ee.prototype.next=function(){var n=this.lexer.next();return{value:n,done:!n}},ee.prototype[Symbol.iterator]=function(){return this},b.prototype[Symbol.iterator]=function(){return new ee(this)}}return b.prototype.formatError=function(n,o){if(n==null)var u=this.buffer.slice(this.index),n={text:u,offset:this.index,lineBreaks:u.indexOf(`
|
|
7
|
+
`)===-1?0:1,line:this.line,col:this.col};var f=2,g=Math.max(n.line-f,1),d=n.line+f,m=String(d).length,w=M(this.buffer,this.line-n.line+f+1).slice(0,5),y=[];y.push(o+" at line "+n.line+" col "+n.col+":"),y.push("");for(var p=0;p<w.length;p++){var _=w[p],D=g+p;y.push(k(String(D),m)+" "+_),D===n.line&&y.push(k("",m+n.col+1)+"^")}return y.join(`
|
|
8
|
+
`)},b.prototype.clone=function(){return new b(this.states,this.state)},b.prototype.has=function(n){return!0},{compile:X,states:$e,error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:Be}})});var ge=te(A=>{"use strict";var Ne=A&&A.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(A,"__esModule",{value:!0});A.lexer=A.states=void 0;var Fe=Ne(pe());A.states={body:{doubleapos:{match:"''",value:a(()=>"'","value")},quoted:{lineBreaks:!0,match:/'[{}#](?:[^']|'')*'(?!')/u,value:a(e=>e.slice(1,-1).replace(/''/g,"'"),"value")},argument:{lineBreaks:!0,match:/\{\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*/u,push:"arg",value:a(e=>e.substring(1).trim(),"value")},octothorpe:"#",end:{match:"}",pop:1},content:{lineBreaks:!0,match:/[^][^{}#']*/u}},arg:{select:{lineBreaks:!0,match:/,\s*(?:plural|select|selectordinal)\s*,\s*/u,next:"select",value:a(e=>e.split(",")[1].trim(),"value")},"func-args":{lineBreaks:!0,match:/,\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*,/u,next:"body",value:a(e=>e.split(",")[1].trim(),"value")},"func-simple":{lineBreaks:!0,match:/,\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*/u,value:a(e=>e.substring(1).trim(),"value")},end:{match:"}",pop:1}},select:{offset:{lineBreaks:!0,match:/\s*offset\s*:\s*\d+\s*/u,value:a(e=>e.split(":")[1].trim(),"value")},case:{lineBreaks:!0,match:/\s*(?:=\d+|[^\p{Pat_Syn}\p{Pat_WS}]+)\s*\{/u,push:"body",value:a(e=>e.substring(0,e.indexOf("{")).trim(),"value")},end:{match:/\s*\}/u,pop:1}}};A.lexer=Fe.default.states(A.states)});var ve=te(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.ParseError=void 0;z.parse=Ue;var ye=ge(),j=a(e=>({offset:e.offset,line:e.line,col:e.col,text:e.text,lineBreaks:e.lineBreaks}),"getContext"),re=a(e=>e==="plural"||e==="select"||e==="selectordinal","isSelectType");function Ie(e,r){let t="",s="";for(let l of r){let c=l.ctx.text;switch(s+=c,l.type){case"content":t+=l.value;break;case"argument":case"function":case"octothorpe":t+=c;break;default:throw new x(e,`Unsupported part in strict mode function arg style: ${c}`)}}return[{type:"content",value:t.trim(),ctx:Object.assign({},r[0].ctx,{text:s})}]}a(Ie,"strictArgStyleParam");var Re=["number","date","time","spellout","ordinal","duration"],me=["zero","one","two","few","many","other"],x=class extends Error{static{a(this,"ParseError")}constructor(r,t){super(ye.lexer.formatError(r,t))}};z.ParseError=x;var ne=class{static{a(this,"Parser")}constructor(r,t){var s,i,l,c;this.lexer=ye.lexer.reset(r),this.cardinalKeys=(s=t?.cardinal)!==null&&s!==void 0?s:me,this.ordinalKeys=(i=t?.ordinal)!==null&&i!==void 0?i:me,this.strict=(l=t?.strict)!==null&&l!==void 0?l:!1,this.strictPluralKeys=(c=t?.strictPluralKeys)!==null&&c!==void 0?c:!0}parse(){return this.parseBody(!1,!0)}checkSelectKey(r,t,s){if(s[0]==="="){if(t==="select")throw new x(r,`The case ${s} is not valid with select`)}else if(t!=="select"){let i=t==="plural"?this.cardinalKeys:this.ordinalKeys;if(this.strictPluralKeys&&i.length>0&&!i.includes(s)){let l=`The ${t} case ${s} is not valid in this locale`;throw new x(r,l)}}}parseSelect({value:r},t,s,i){let l={type:i,arg:r,cases:[],ctx:s};i==="plural"||i==="selectordinal"?t=!0:this.strict&&(t=!1);for(let c of this.lexer)switch(c.type){case"offset":if(i==="select")throw new x(c,"Unexpected plural offset for select");if(l.cases.length>0)throw new x(c,"Plural offset must be set before cases");l.pluralOffset=Number(c.value),s.text+=c.text,s.lineBreaks+=c.lineBreaks;break;case"case":{this.checkSelectKey(c,i,c.value),l.cases.push({key:c.value,tokens:this.parseBody(t),ctx:j(c)});break}case"end":return l;default:throw new x(c,`Unexpected lexer token: ${c.type}`)}throw new x(null,"Unexpected message end")}parseArgToken(r,t){let s=j(r),i=this.lexer.next();if(!i)throw new x(null,"Unexpected message end");if(s.text+=i.text,s.lineBreaks+=i.lineBreaks,this.strict&&(i.type==="func-simple"||i.type==="func-args")&&!Re.includes(i.value)){let l=`Invalid strict mode function arg type: ${i.value}`;throw new x(r,l)}switch(i.type){case"end":return{type:"argument",arg:r.value,ctx:s};case"func-simple":{let l=this.lexer.next();if(!l)throw new x(null,"Unexpected message end");if(l.type!=="end")throw new x(l,`Unexpected lexer token: ${l.type}`);if(s.text+=l.text,re(i.value.toLowerCase()))throw new x(i,`Invalid type identifier: ${i.value}`);return{type:"function",arg:r.value,key:i.value,ctx:s}}case"func-args":{if(re(i.value.toLowerCase())){let c=`Invalid type identifier: ${i.value}`;throw new x(i,c)}let l=this.parseBody(this.strict?!1:t);return this.strict&&l.length>0&&(l=Ie(r,l)),{type:"function",arg:r.value,key:i.value,param:l,ctx:s}}case"select":if(re(i.value))return this.parseSelect(r,t,s,i.value);throw new x(i,`Unexpected select type ${i.value}`);default:throw new x(i,`Unexpected lexer token: ${i.type}`)}}parseBody(r,t){let s=[],i=null;for(let l of this.lexer)if(l.type==="argument")i&&(i=null),s.push(this.parseArgToken(l,r));else if(l.type==="octothorpe"&&r)i&&(i=null),s.push({type:"octothorpe",ctx:j(l)});else{if(l.type==="end"&&!t)return s;{let c=l.value;if(!r&&l.type==="quoted"&&c[0]==="#"){if(c.includes("{")){let h=`Unsupported escape pattern: ${c}`;throw new x(l,h)}c=l.text}i?(i.value+=c,i.ctx.text+=l.text,i.ctx.lineBreaks+=l.lineBreaks):(i={type:"content",value:c,ctx:j(l)},s.push(i))}}if(t)return s;throw new x(null,"Unexpected message end")}};function Ue(e,r={}){return new ne(e,r).parse()}a(Ue,"parse")});var _e=de(ve(),1);var E=class extends Error{static{a(this,"DateFormatError")}constructor(r,t,s){super(r),this.token=t,this.type=s||"error"}},we=a(e=>e<4?"short":e===4?"long":"narrow","alpha"),G=a(e=>e%2===0?"2-digit":"numeric","numeric");function Le(e,r){switch(e.char){case"y":return{year:G(e.width)};case"r":return{calendar:"gregory",year:"numeric"};default:return r(`${e.desc} is not supported; falling back to year:numeric`,E.WARNING),{year:"numeric"}}}a(Le,"yearOptions");function ze(e,r){switch(e.width){case 1:return"numeric";case 2:return"2-digit";case 3:return"short";case 4:return"long";case 5:return"narrow";default:r(`${e.desc} is not supported with width ${e.width}`);return}}a(ze,"monthStyle");function Ge(e,r){let{char:t,desc:s,width:i}=e;if(t==="d")return G(i);r(`${s} is not supported`)}a(Ge,"dayStyle");function Ke(e,r){let{char:t,desc:s,width:i}=e;if((t==="c"||t==="e")&&i<3){let l=`Numeric value is not supported for ${s}; falling back to weekday:short`;r(l,E.WARNING)}return we(i)}a(Ke,"weekdayStyle");function He(e){let r=G(e.width),t;switch(e.char){case"h":t="h12";break;case"H":t="h23";break;case"k":t="h24";break;case"K":t="h11";break}return t?{hour:r,hourCycle:t}:{hour:r}}a(He,"hourOptions");function We(e,r){let{char:t,desc:s,width:i}=e;switch(t){case"v":case"z":return i===4?"long":"short";case"V":if(i===4)return"long";r(`${s} is not supported with width ${i}`);return;case"X":r(`${s} is not supported`);return}return"short"}a(We,"timeZoneNameStyle");function je(e,r){switch(e.field){case"era":return{era:we(e.width)};case"year":return Le(e,r);case"month":return{month:ze(e,r)};case"day":return{day:Ge(e,r)};case"weekday":return{weekday:Ke(e,r)};case"period":return;case"hour":return He(e);case"min":return{minute:G(e.width)};case"sec":return{second:G(e.width)};case"tz":return{timeZoneName:We(e,r)};case"quarter":case"week":case"sec-frac":case"ms":r(`${e.desc} is not supported`)}}a(je,"compileOptions");function se(e,r,t=s=>{throw s}){let s={timeZone:r},i=[];for(let l of e){let{error:c,field:h,str:v}=l;if(c){let k=new E(c.message,l);k.stack=c.stack,t(k)}if(v){let k=`Ignoring string part: ${v}`;t(new E(k,l,E.WARNING))}h&&(i.indexOf(h)===-1?i.push(h):t(new E(`Duplicate ${h} token`,l)));let S=je(l,(k,M)=>t(new E(k,l,M)));S&&Object.assign(s,S)}return s}a(se,"getDateFormatOptions");var Ze={G:{field:"era",desc:"Era"},y:{field:"year",desc:"Year"},Y:{field:"year",desc:'Year of "Week of Year"'},u:{field:"year",desc:"Extended year"},U:{field:"year",desc:"Cyclic year name"},r:{field:"year",desc:"Related Gregorian year"},Q:{field:"quarter",desc:"Quarter"},q:{field:"quarter",desc:"Stand-alone quarter"},M:{field:"month",desc:"Month in year"},L:{field:"month",desc:"Stand-alone month in year"},w:{field:"week",desc:"Week of year"},W:{field:"week",desc:"Week of month"},d:{field:"day",desc:"Day in month"},D:{field:"day",desc:"Day of year"},F:{field:"day",desc:"Day of week in month"},g:{field:"day",desc:"Modified julian day"},E:{field:"weekday",desc:"Day of week"},e:{field:"weekday",desc:"Local day of week"},c:{field:"weekday",desc:"Stand-alone local day of week"},a:{field:"period",desc:"AM/PM marker"},b:{field:"period",desc:"AM/PM/noon/midnight marker"},B:{field:"period",desc:"Flexible day period"},h:{field:"hour",desc:"Hour in AM/PM (1~12)"},H:{field:"hour",desc:"Hour in day (0~23)"},k:{field:"hour",desc:"Hour in day (1~24)"},K:{field:"hour",desc:"Hour in AM/PM (0~11)"},j:{field:"hour",desc:"Hour in preferred cycle"},J:{field:"hour",desc:"Hour in preferred cycle without marker"},C:{field:"hour",desc:"Hour in preferred cycle with flexible marker"},m:{field:"min",desc:"Minute in hour"},s:{field:"sec",desc:"Second in minute"},S:{field:"sec-frac",desc:"Fractional second"},A:{field:"ms",desc:"Milliseconds in day"},z:{field:"tz",desc:"Time Zone: specific non-location"},Z:{field:"tz",desc:"Time Zone"},O:{field:"tz",desc:"Time Zone: localized"},v:{field:"tz",desc:"Time Zone: generic non-location"},V:{field:"tz",desc:"Time Zone: ID"},X:{field:"tz",desc:"Time Zone: ISO8601 with Z"},x:{field:"tz",desc:"Time Zone: ISO8601"}},xe=a(e=>e>="A"&&e<="Z"||e>="a"&&e<="z","isLetter");function Je(e,r){let t=e[r],s=1;for(;e[++r]===t;)++s;let i=Ze[t];if(!i){let l=`The letter ${t} is not a valid field identifier`;return{char:t,error:new Error(l),width:s}}return{char:t,field:i.field,desc:i.desc,width:s}}a(Je,"readFieldToken");function Ye(e,r){let t=e[++r],s=2;if(t==="'")return{char:"'",str:t,width:s};for(;;){let i=e[++r];if(++s,i===void 0){let l=`Unterminated quoted literal in pattern: ${t||e}`;return{char:"'",error:new Error(l),str:t,width:s}}else if(i==="'"){if(e[++r]!=="'")return{char:"'",str:t,width:s};++s}t+=i}}a(Ye,"readQuotedToken");function Qe(e,r){let t=e[r];if(!t)return null;if(xe(t))return Je(e,r);if(t==="'")return Ye(e,r);let s=t,i=1;for(;;){let l=e[++r];if(!l||xe(l)||l==="'")return{char:t,str:s,width:i};s+=l,i+=1}}a(Qe,"readToken");function Z(e){let r=[],t=0;for(;;){let s=Qe(e,t);if(!s)return r;r.push(s),t+=s.width}}a(Z,"parseDateTokens");function be(e,r){return e.filter(t=>t.type!=="content").length?e.map(t=>{if(t.type==="content")return r(t.value);if(t.type==="octothorpe")return"#";if(t.type==="argument")return[t.arg];if(t.type==="function"){let l=t?.param?.[0];if(t.key==="date"&&l){let c=Ve(l.value.trim(),h=>{throw new Error(`Unable to compile date expression: ${h.message}`)});return[t.arg,t.key,c]}return l?[t.arg,t.key,l.value.trim()]:[t.arg,t.key]}let s=t.pluralOffset,i={};return t.cases.forEach(({key:l,tokens:c})=>{let h=l[0]==="="?l.slice(1):l;i[h]=be(c,r)}),[t.arg,t.type,{offset:s,...i}]}):e.map(t=>r(t.value))}a(be,"processTokens");function Ve(e,r){if(/^::/.test(e)){let t=Z(e.substring(2));return se(t,void 0,r)}return e}a(Ve,"compileDateExpression");function Xe(e,r=t=>t){return be((0,_e.parse)(e),r)}a(Xe,"compileMessageOrThrow");function J(e,r=t=>t){try{return Xe(e,r)}catch(t){return console.error(`${t.message}
|
|
9
|
+
|
|
10
|
+
Message: ${e}`),[e]}}a(J,"compileMessage");var B=a(e=>typeof e=="string","isString"),et=a(e=>typeof e=="function","isFunction"),ke=new Map,Te="en";function le(e){return[...Array.isArray(e)?e:[e],Te]}a(le,"normalizeLocales");function ce(e,r,t){let s=le(e);t||(t="default");let i;if(typeof t=="string")switch(i={day:"numeric",month:"short",year:"numeric"},t){case"full":i.weekday="long";case"long":i.month="long";break;case"short":i.month="numeric";break}else i=t;return Y(()=>Q("date",s,t),()=>new Intl.DateTimeFormat(s,i)).format(B(r)?new Date(r):r)}a(ce,"date");function tt(e,r,t){let s;if(t||(t="default"),typeof t=="string")switch(s={second:"numeric",minute:"numeric",hour:"numeric"},t){case"full":case"long":s.timeZoneName="short";break;case"short":delete s.second}else s=t;return ce(e,r,s)}a(tt,"time");function ie(e,r,t){let s=le(e);return Y(()=>Q("number",s,t),()=>new Intl.NumberFormat(s,t)).format(r)}a(ie,"number");function Se(e,r,t,{offset:s=0,...i}){let l=le(e),c=r?Y(()=>Q("plural-ordinal",l),()=>new Intl.PluralRules(l,{type:"ordinal"})):Y(()=>Q("plural-cardinal",l),()=>new Intl.PluralRules(l,{type:"cardinal"}));return i[t]??i[c.select(t-s)]??i.other}a(Se,"plural");function Y(e,r){let t=e(),s=ke.get(t);return s||(s=r(),ke.set(t,s)),s}a(Y,"getMemoized");function Q(e,r,t){let s=r.join("-");return`${e}-${s}-${JSON.stringify(t)}`}a(Q,"cacheKey");var Ee=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,Oe=a(e=>e.replace(/\\u([a-fA-F0-9]{4})|\\x([a-fA-F0-9]{2})/g,(r,t,s)=>{if(t){let i=parseInt(t,16);return String.fromCharCode(i)}else{let i=parseInt(s,16);return String.fromCharCode(i)}}),"decodeEscapeSequences"),Ae="%__lingui_octothorpe__%",rt=a((e,r,t={})=>{let s=r||e,i=a(c=>typeof c=="object"?c:t[c],"style"),l=a((c,h)=>{let v=Object.keys(t).length?i("number"):void 0,S=ie(s,c,v);return h.replace(new RegExp(Ae,"g"),S)},"replaceOctothorpe");return{plural:a((c,h)=>{let{offset:v=0}=h,S=Se(s,!1,c,h);return l(c-v,S)},"plural"),selectordinal:a((c,h)=>{let{offset:v=0}=h,S=Se(s,!0,c,h);return l(c-v,S)},"selectordinal"),select:nt,number:a((c,h)=>ie(s,c,i(h)||{style:h}),"number"),date:a((c,h)=>ce(s,c,i(h)||h),"date"),time:a((c,h)=>tt(s,c,i(h)||h),"time")}},"getDefaultFormats"),nt=a((e,r)=>r[e]??r.other,"selectFormatter");function st(e,r,t){return(s={},i)=>{let l=rt(r,t,i),c=a((v,S=!1)=>Array.isArray(v)?v.reduce((k,M)=>{if(M==="#"&&S)return k+Ae;if(B(M))return k+M;let[K,O,$]=M,C={};O==="plural"||O==="selectordinal"||O==="select"?Object.entries($).forEach(([F,X])=>{C[F]=c(X,O==="plural"||O==="selectordinal")}):C=$;let N;if(O){let F=l[O];N=F(s[K],C)}else N=s[K];return N==null?k:k+N},""):v,"formatMessage"),h=c(e);return B(h)&&Ee.test(h)?Oe(h):B(h)?h:h?String(h):""}}a(st,"interpolate");var ae=class{static{a(this,"EventEmitter")}_events={};on(r,t){return this._events[r]??=new Set,this._events[r].add(t),()=>this.removeListener(r,t)}removeListener(r,t){let s=this._events[r];s?.delete(t),s?.size===0&&delete this._events[r]}emit(r,...t){let s=this._events[r];if(s)for(let i of[...s])i.apply(this,t)}},oe=class extends ae{static{a(this,"I18n")}_locale="";_locales;_messages={};_missing;_messageCompiler;constructor(r){super(),this.setMessagesCompiler(J),r.missing!=null&&(this._missing=r.missing),r.messages!=null&&this.load(r.messages),(typeof r.locale=="string"||r.locales)&&this.activate(r.locale??Te,r.locales)}get locale(){return this._locale}get locales(){return this._locales}get messages(){return this._messages[this._locale]??{}}setMessagesCompiler(r){return this._messageCompiler=r,this}_load(r,t){let s=this._messages[r];s?Object.assign(s,t):this._messages[r]=t}load(r,t){typeof r=="string"&&typeof t=="object"?this._load(r,t):Object.entries(r).forEach(([s,i])=>this._load(s,i)),this.emit("change")}loadAndActivate({locale:r,locales:t,messages:s}){this._locale=r,this._locales=t||void 0,this._messages[this._locale]=s,this.emit("change")}activate(r,t){this._messages[r]||console.warn(`Messages for locale "${r}" not loaded.`),this._locale=r,this._locales=t,this.emit("change")}_(r,t,s){if(!this.locale)throw new Error("Lingui: Attempted to call a translation function without setting a locale.\nMake sure to call `i18n.activate(locale)` before using Lingui functions.\nThis issue may also occur due to a race condition in your initialization logic.");let i=s?.message;r||(r=""),B(r)||(t=r.values||t,i=r.message,r=r.id);let l=this.messages[r],c=l===void 0,h=this._missing;if(h&&c)return et(h)?h(this._locale,r):h;c&&this.emit("missing",{id:r,locale:this._locale});let v=l||i||r;return B(v)&&(this._messageCompiler?v=this._messageCompiler(v):console.warn(`Uncompiled message detected! Message:
|
|
11
|
+
|
|
12
|
+
> ${v}
|
|
13
|
+
|
|
14
|
+
That means you use raw catalog or your catalog doesn't have a translation for the message and fallback was used.
|
|
15
|
+
ICU features such as interpolation and plurals will not work properly for that message.
|
|
16
|
+
|
|
17
|
+
Please compile your catalog first.
|
|
18
|
+
`)),B(v)&&Ee.test(v)?Oe(v):B(v)?v:st(v,this._locale,this._locales)(t,s?.formats)}t=this._.bind(this);date(r,t){return ce(this._locales||this._locale,r,t)}number(r,t){return ie(this._locales||this._locale,r,t)}};function ue(e={}){return new oe(e)}a(ue,"setupI18n");var qt=ue();var V=de(qe(),1);var it={},Me="en",at={en:it},ot=a((e=Me,r=at)=>{let t=ue();t.setMessagesCompiler(J);for(let[s,i]of Object.entries(r))t.load(s,i);return t.activate(r[e]===void 0?Me:e),t},"createStudioI18n"),lt=ot(),ct=(0,V.createContext)(lt),Ut=a(()=>{let e=(0,V.use)(ct);return(r,t)=>e._(r,t)},"useT");var Gt=a(e=>({__lunoraRef:e}),"adminRef"),Kt=a(e=>{let r=e.trim();return r===""?{}:{shardKey:r}},"callOptions"),Ht=a(e=>e instanceof Error?e.message:String(e),"errorMessage"),Wt=a(e=>{if(e===null||typeof e!="object"||!("hint"in e))return;let{hint:r}=e;return typeof r=="string"?r:Array.isArray(r)?r.filter(t=>typeof t=="string").join(`
|
|
19
|
+
`):void 0},"errorHint"),jt=a(e=>{if(e===null||typeof e!="object"||!("docsUrl"in e))return;let r=e.docsUrl;if(typeof r=="string")try{let{protocol:t}=new URL(r);return t==="http:"||t==="https:"?r:void 0}catch{return}},"errorDocumentationUrl"),Zt=a(e=>{if(e==null)return"";switch(typeof e){case"bigint":case"boolean":case"number":return e.toString();case"string":return e;case"symbol":return e.toString();default:return JSON.stringify(e)}},"formatCell"),ut=a((e,r)=>{e.catch(t=>{})},"fireAndForget"),Jt=a(e=>{if(e!==void 0&&e!=="")return e;let r=globalThis.location;return r?.origin!==void 0&&r.origin!==""?r.origin:"http://localhost:5173"},"resolveOrigin"),Yt=a(e=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;return r===void 0?!1:(ut(r.writeText(e)),!0)},"copyToClipboard"),Qt=a(e=>{if(e==null)return"\u2014";if(e<1024)return`${e.toString()} B`;let r=["KB","MB","GB","TB"],t=e/1024,s=0;for(;t>=1024&&s<r.length-1;)t/=1024,s+=1;return`${t.toFixed(1)} ${r[s]??"TB"}`},"formatBytes"),Vt=a((e,r="")=>{if(e==null||e==="")return r;let t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()},"formatTimestamp");export{ot as a,lt as b,ct as c,Ut as d,Gt as e,Kt as f,Ht as g,Wt as h,jt as i,Zt as j,ut as k,Jt as l,Yt as m,Qt as n,Vt as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as f}from"./chunk-X33MSJPP.js";import"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import"./chunk-GTM65MVX.js";import{a as R}from"./chunk-BOXSWNXZ.js";import{b as p}from"./chunk-C7WTJLC3.js";import"./chunk-SEU5V7I6.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as i,e as m,g as S,h as A}from"./chunk-RRCPZMC2.js";var g=m(S(),1);var k=m(A(),1);var _=i((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],"findingTitle"),E=i(e=>Array.isArray(e.findings)?e.findings:[],"toFindings"),w=i(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"findingEntity"),T=i((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],"findingDetail"),v=i(()=>{let e=(0,g.c)(8),s=h(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=p(R.getSecurityAudit,r),o;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:E(a);o=u===null?null:u.map(t=>({description:T(s,t),entity:w(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=o}else o=e[3];let l=o,n;return e[4]!==d||e[5]!==c||e[6]!==l?(n=(0,k.jsxDEV)(f,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"},void 0,!1),e[4]=d,e[5]=c,e[6]=l,e[7]=n):n=e[7],n},"SecurityAdvisorPanel");export{v as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as R}from"./chunk-UGUEC6BC.js";import{a as w,b as O,c as D,d as C,e as v,f as h}from"./chunk-GTM65MVX.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as S}from"./chunk-TAD43CG5.js";import{b as _}from"./chunk-C7WTJLC3.js";import{a as A,e as I}from"./chunk-SEU5V7I6.js";import{b as E}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as b}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as u,e as T,f as M,g as P,h as V}from"./chunk-RRCPZMC2.js";var B=T(P(),1),K=T(M(),1);var t=T(V(),1);var k="container:",F={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},H=u(e=>{let r=e.indexOf(":");if(r===-1)return{event:e.trim()};let a=e.slice(r+1).trim(),s=e.slice(0,r).trim();return a===""?{event:s}:{detail:a,event:s}},"parseContainerMessage"),W=u(e=>{let r=new Map;for(let a of e){let s=a.functionPath??"";if(!s.startsWith(k))continue;let n=s.slice(k.length);if(n==="")continue;let i=r.get(n);if(i!==void 0&&i.timestamp>=a.timestamp)continue;let{detail:x,event:o}=H(a.message);r.set(n,{detail:x,event:o,level:a.level,name:n,state:F[o]??"unknown",timestamp:a.timestamp})}return[...r.values()].toSorted((a,s)=>a.name.localeCompare(s.name))},"foldContainerInstances"),$={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},j=u(e=>{let{entries:r}=e??{};return Array.isArray(r)?r:[]},"entriesOf"),ee=u(()=>{let e=(0,B.c)(23),r=b(),a,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},s={live:!0,shardKey:""},e[0]=a,e[1]=s):(a=e[0],s=e[1]);let{data:n,error:i,liveError:x}=_(L.getLogs,a,s),o=n!==void 0,N;e[2]!==n?(N=W(j(n)),e[2]=n,e[3]=N):N=e[3];let g=N,l;e[4]!==i?(l=i!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:i},void 0,!1),e[4]=i,e[5]=l):l=e[5];let c;e[6]!==r?(c=r("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per container \u2014 ports and health checks aren't carried in that stream."),e[6]=r,e[7]=c):c=e[7];let d;e[8]!==c?(d=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:c},void 0,!1),e[8]=c,e[9]=d):d=e[9];let m;e[10]!==x?(m=(0,t.jsxDEV)(R,{message:x,prefix:"containers"},void 0,!1),e[10]=x,e[11]=m):m=e[11];let f;e[12]!==d||e[13]!==m?(f=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[d,m]},void 0,!0),e[12]=d,e[13]=m,e[14]=f):f=e[14];let p;e[15]!==o||e[16]!==g||e[17]!==r?(p=o&&g.length===0?(0,t.jsxDEV)(S,{description:r("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:r("No container activity")},void 0,!1):(0,t.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(I,{className:"px-0",children:(0,t.jsxDEV)(w,{"data-testid":"containers-table",children:[(0,t.jsxDEV)(O,{children:(0,t.jsxDEV)(C,{children:[(0,t.jsxDEV)(v,{children:r("Container")},void 0,!1),(0,t.jsxDEV)(v,{children:r("State")},void 0,!1),(0,t.jsxDEV)(v,{children:r("Last event")},void 0,!1),(0,t.jsxDEV)(v,{children:r("Detail")},void 0,!1),(0,t.jsxDEV)(v,{children:r("When")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(D,{children:g.map(G)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[15]=o,e[16]=g,e[17]=r,e[18]=p):p=e[18];let y;return e[19]!==l||e[20]!==f||e[21]!==p?(y=(0,t.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[l,f,p]},void 0,!0),e[19]=l,e[20]=f,e[21]=p,e[22]=y):y=e[22],y},"ContainersPanel");function G(e){return(0,t.jsxDEV)(C,{"data-testid":`containers-row-${e.name}`,children:[(0,t.jsxDEV)(h,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,t.jsxDEV)(h,{children:(0,t.jsxDEV)(E,{variant:$[e.state],children:e.state},void 0,!1)},void 0,!1),(0,t.jsxDEV)(h,{className:"font-mono text-xs text-muted-foreground",children:e.event},void 0,!1),(0,t.jsxDEV)(h,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"},void 0,!1),(0,t.jsxDEV)(h,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()},void 0,!1)]},e.name,!0)}u(G,"_temp");export{ee as ContainersPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as V}from"./chunk-J6J54MBP.js";import{a as L}from"./chunk-2K47A3P6.js";import{a as W}from"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import{a as O,b as Q,c as U,d as K,e as R,f as D}from"./chunk-GTM65MVX.js";import{a as j}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as H}from"./chunk-BOXSWNXZ.js";import{a as B}from"./chunk-TAD43CG5.js";import{b as _}from"./chunk-C7WTJLC3.js";import{a as E}from"./chunk-SEU5V7I6.js";import{b as w}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as A}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as C,e as F,f as J,g as X,h as Y}from"./chunk-RRCPZMC2.js";var P=F(X(),1),G=F(J(),1);var t=F(Y(),1);var q=C(r=>`${r.toString()} ms`,"formatMs"),Z=C(r=>r.totalConnections===0&&r.shapePoke.passes===0&&r.whisper.passes===0,"isFanoutIdle"),$=C(r=>{let e=(0,P.c)(8),{label:o,testId:s,value:i}=r,l;e[0]!==o?(l=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o},void 0,!1),e[0]=o,e[1]=l):l=e[1];let d;e[2]!==s||e[3]!==i?(d=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":s,children:i},void 0,!1),e[2]=s,e[3]=i,e[4]=d):d=e[4];let v;return e[5]!==l||e[6]!==d?(v=(0,t.jsxDEV)(E,{className:"gap-0 py-0",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[l,d]},void 0,!0)},void 0,!1),e[5]=l,e[6]=d,e[7]=v):v=e[7],v},"StatCard"),z=C(r=>{let e=(0,P.c)(48),{counters:o,includeTiming:s,prefix:i,t:l,title:d}=r,v=`${i}-section`,h;e[0]!==d?(h=(0,t.jsxDEV)("h3",{className:"text-sm font-medium text-foreground",children:d},void 0,!1),e[0]=d,e[1]=h):h=e[1];let k=`${i}-stats`,a;e[2]!==l?(a=l("Passes"),e[2]=l,e[3]=a):a=e[3];let n=`${i}-passes`,g;e[4]!==o.passes||e[5]!==a||e[6]!==n?(g=(0,t.jsxDEV)($,{label:a,testId:n,value:o.passes},void 0,!1),e[4]=o.passes,e[5]=a,e[6]=n,e[7]=g):g=e[7];let N;e[8]!==l?(N=l("Sockets iterated"),e[8]=l,e[9]=N):N=e[9];let I=`${i}-iterated`,c;e[10]!==o.socketsIterated||e[11]!==N||e[12]!==I?(c=(0,t.jsxDEV)($,{label:N,testId:I,value:o.socketsIterated},void 0,!1),e[10]=o.socketsIterated,e[11]=N,e[12]=I,e[13]=c):c=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${i}-delivered`,u;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(u=(0,t.jsxDEV)($,{label:f,testId:y,value:o.socketsDelivered},void 0,!1),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=u):u=e[19];let m;e[20]!==l?(m=l("Peak width"),e[20]=l,e[21]=m):m=e[21];let b=`${i}-peak`,p;e[22]!==o.peakSocketsIterated||e[23]!==m||e[24]!==b?(p=(0,t.jsxDEV)($,{label:m,testId:b,value:o.peakSocketsIterated},void 0,!1),e[22]=o.peakSocketsIterated,e[23]=m,e[24]=b,e[25]=p):p=e[25];let x;e[26]!==o.totalMs||e[27]!==s||e[28]!==i||e[29]!==l?(x=s&&(0,t.jsxDEV)($,{label:l("Total time"),testId:`${i}-total-ms`,value:q(o.totalMs)},void 0,!1),e[26]=o.totalMs,e[27]=s,e[28]=i,e[29]=l,e[30]=x):x=e[30];let S;e[31]!==o.maxMs||e[32]!==s||e[33]!==i||e[34]!==l?(S=s&&(0,t.jsxDEV)($,{label:l("Max time"),testId:`${i}-max-ms`,value:q(o.maxMs)},void 0,!1),e[31]=o.maxMs,e[32]=s,e[33]=i,e[34]=l,e[35]=S):S=e[35];let T;e[36]!==u||e[37]!==p||e[38]!==x||e[39]!==S||e[40]!==k||e[41]!==g||e[42]!==c?(T=(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":k,children:[g,c,u,p,x,S]},void 0,!0),e[36]=u,e[37]=p,e[38]=x,e[39]=S,e[40]=k,e[41]=g,e[42]=c,e[43]=T):T=e[43];let M;return e[44]!==v||e[45]!==T||e[46]!==h?(M=(0,t.jsxDEV)("section",{className:"flex flex-col gap-2","data-testid":v,children:[h,T]},void 0,!0),e[44]=v,e[45]=T,e[46]=h,e[47]=M):M=e[47],M},"PathCounters"),ue=C(r=>{let e=(0,P.c)(32),{initialShardKey:o}=r,s=A(),[i,l]=(0,G.useState)(o??""),d;e[0]!==i?(d=i.trim(),e[0]=i,e[1]=d):d=e[1];let v=L(d,400),h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h={},e[2]=h):h=e[2];let k;e[3]!==v?(k={keepPreviousData:!0,shardKey:v},e[3]=v,e[4]=k):k=e[4];let{data:a,error:n,errorSource:g,refetch:N}=_(H.getFanoutMetrics,h,k);V(N,!0);let I;e[5]!==a?(I=a!==void 0&&Z(a),e[5]=a,e[6]=I):I=e[6];let c=I,f;e[7]!==i?(f=(0,t.jsxDEV)(j,{onChange:l,testId:"fanout-shard-input",value:i},void 0,!1),e[7]=i,e[8]=f):f=e[8];let y;e[9]!==a||e[10]!==s?(y=a!==void 0&&(0,t.jsxDEV)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[a.promoted&&(0,t.jsxDEV)(w,{"data-testid":"fanout-promoted",variant:a.relayCount>=a.maxRelays?"destructive":"default",children:a.relayCount>=a.maxRelays?s("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:a.maxRelays,relayCount:a.relayCount}):s("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:a.maxRelays,relayCount:a.relayCount})},void 0,!1),(0,t.jsxDEV)(w,{variant:"secondary",children:s("{count} connections",{count:a.totalConnections})},void 0,!1),(0,t.jsxDEV)(w,{variant:"secondary",children:s("peak {count} subscribers",{count:a.peakSubscribers})},void 0,!1)]},void 0,!0),e[9]=a,e[10]=s,e[11]=y):y=e[11];let u;e[12]!==f||e[13]!==y?(u=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[f,y]},void 0,!0),e[12]=f,e[13]=y,e[14]=u):u=e[14];let m;e[15]!==n||e[16]!==g?(m=n!==null&&(0,t.jsxDEV)(W,{error:g,testId:"fanout-error"},void 0,!1),e[15]=n,e[16]=g,e[17]=m):m=e[17];let b;e[18]!==n||e[19]!==c||e[20]!==s?(b=n===null&&c&&(0,t.jsxDEV)(B,{description:s("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M4 12h4l3 7 4-14 3 7h2"},void 0,!1)},void 0,!1),testId:"fanout-empty",title:s("No fan-out activity yet.")},void 0,!1),e[18]=n,e[19]=c,e[20]=s,e[21]=b):b=e[21];let p;e[22]!==n||e[23]!==c||e[24]!==a||e[25]!==s?(p=n===null&&a!==void 0&&!c&&(0,t.jsxDEV)(t.Fragment,{children:[a.topics.length>0&&(0,t.jsxDEV)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsxDEV)("h3",{className:"text-sm font-medium text-foreground",children:s("Hot topics")},void 0,!1),(0,t.jsxDEV)(E,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(O,{"data-testid":"fanout-topics-table",children:[(0,t.jsxDEV)(Q,{children:(0,t.jsxDEV)(K,{children:[(0,t.jsxDEV)(R,{children:s("Topic")},void 0,!1),(0,t.jsxDEV)(R,{children:s("Kind")},void 0,!1),(0,t.jsxDEV)(R,{className:"text-right",children:s("Subscribers")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(U,{children:a.topics.map(ee)},void 0,!1)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("Fan-out cost since this instance woke")},void 0,!1),(0,t.jsxDEV)(z,{counters:a.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:s,title:s("Shape pokes")},void 0,!1),(0,t.jsxDEV)(z,{counters:a.whisper,includeTiming:!1,prefix:"fanout-whisper",t:s,title:s("Whisper broadcasts")},void 0,!1)]},void 0,!0)]},void 0,!0),e[22]=n,e[23]=c,e[24]=a,e[25]=s,e[26]=p):p=e[26];let x;return e[27]!==p||e[28]!==u||e[29]!==m||e[30]!==b?(x=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[u,m,b,p]},void 0,!0),e[27]=p,e[28]=u,e[29]=m,e[30]=b,e[31]=x):x=e[31],x},"FanoutPanel");function ee(r){return(0,t.jsxDEV)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsxDEV)(D,{className:"font-mono text-xs",children:r.topic},void 0,!1),(0,t.jsxDEV)(D,{children:(0,t.jsxDEV)(w,{variant:"outline",children:r.kind},void 0,!1)},void 0,!1),(0,t.jsxDEV)(D,{className:"text-right font-medium tabular-nums",children:r.subscribers},void 0,!1)]},`${r.kind}:${r.topic}`,!0)}C(ee,"_temp");export{ue as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as it}from"./chunk-3OA7PECS.js";import{b as m}from"./chunk-GMSGZDDH.js";import{a as o,e as R,f as q,g as nt,h as ar}from"./chunk-RRCPZMC2.js";var Dt=R(nt(),1);var x=class{static{o(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var cr=class extends x{static{o(this,"FocusManager")}#t;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},z=new cr;var ur={setTimeout:o((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:o(t=>clearTimeout(t),"clearTimeout"),setInterval:o((t,e)=>setInterval(t,e),"setInterval"),clearInterval:o(t=>clearInterval(t),"clearInterval")},hr=class{static{o(this,"TimeoutManager")}#t=ur;#e=!1;setTimeoutProvider(t){this.#e&&t!==this.#t&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#t,provider:t}),this.#t=t,this.#e=!1}setTimeout(t,e){return this.#e=!0,this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#e=!0,this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},L=new hr;function ot(t){setTimeout(t,0)}o(ot,"systemSetTimeoutZero");var Fe=typeof window>"u"||"Deno"in globalThis;function S(){}o(S,"noop");function ut(t,e){return typeof t=="function"?t(e):t}o(ut,"functionalUpdate");function re(t){return typeof t=="number"&&t>=0&&t!==1/0}o(re,"isValidTimeout");function ye(t,e){return Math.max(t+(e||0)-Date.now(),0)}o(ye,"timeUntilStale");function P(t,e){return typeof t=="function"?t(e):t}o(P,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}o(I,"resolveQueryBoolean");function ge(t,e){let{type:r="all",exact:s,fetchStatus:n,predicate:i,queryKey:a,stale:u}=t;if(a){if(s){if(e.queryHash!==se(a,e.options))return!1}else if(!K(e.queryKey,a))return!1}if(r!=="all"){let c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||n&&n!==e.state.fetchStatus||i&&!i(e))}o(ge,"matchQuery");function ve(t,e){let{exact:r,status:s,predicate:n,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(B(e.options.mutationKey)!==B(i))return!1}else if(!K(e.options.mutationKey,i))return!1}return!(s&&e.state.status!==s||n&&!n(e))}o(ve,"matchMutation");function se(t,e){return(e?.queryKeyHashFn||B)(t)}o(se,"hashQueryKeyByOptions");function B(t){return JSON.stringify(t,(e,r)=>Le(r)?Object.keys(r).sort().reduce((s,n)=>(s[n]=r[n],s),{}):r)}o(B,"hashKey");function K(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>K(t[r],e[r])):!1}o(K,"partialMatchKey");var dr=Object.prototype.hasOwnProperty;function pe(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=at(t)&&at(e);if(!s&&!(Le(t)&&Le(e)))return e;let i=(s?t:Object.keys(t)).length,a=s?e:Object.keys(e),u=a.length,c=s?new Array(u):{},h=0;for(let d=0;d<u;d++){let l=s?d:a[d],f=t[l],p=e[l];if(f===p){c[l]=f,(s?d<i:dr.call(t,l))&&h++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){c[l]=p;continue}let g=pe(f,p,r+1);c[l]=g,g===f&&h++}return i===u&&h===i?t:c}o(pe,"replaceEqualDeep");function be(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}o(be,"shallowEqualObjects");function at(t){return Array.isArray(t)&&t.length===Object.keys(t).length}o(at,"isPlainArray");function Le(t){if(!ct(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!ct(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}o(Le,"isPlainObject");function ct(t){return Object.prototype.toString.call(t)==="[object Object]"}o(ct,"hasObjectPrototype");function ht(t){return new Promise(e=>{L.setTimeout(e,t)})}o(ht,"sleep");function ne(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){try{return pe(t,e)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return pe(t,e)}return e}o(ne,"replaceData");function lr(t){return t}o(lr,"keepPreviousData");function dt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}o(dt,"addToEnd");function lt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}o(lt,"addToStart");var j=Symbol();function Se(t,e){return t.queryFn===j&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===j?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}o(Se,"ensureQueryFn");function we(t,e){return typeof t=="function"?t(...e):!!t}o(we,"shouldThrowError");function ft(t,e,r){let s=!1,n;return Object.defineProperty(t,"signal",{enumerable:!0,get:o(()=>(n??=e(),s||(s=!0,n.aborted?r():n.addEventListener("abort",r,{once:!0})),n),"get")}),t}o(ft,"addConsumeAwareSignal");var F=(()=>{let t=o(()=>Fe,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function ie(){let t,e,r=new Promise((n,i)=>{t=n,e=i});r.status="pending",r.catch(()=>{});function s(n){Object.assign(r,n),delete r.resolve,delete r.reject}return o(s,"finalize"),r.resolve=n=>{s({status:"fulfilled",value:n}),t(n)},r.reject=n=>{s({status:"rejected",reason:n}),e(n)},r}o(ie,"pendingThenable");var mt=ot;function fr(){let t=[],e=0,r=o(u=>{u()},"notifyFn"),s=o(u=>{u()},"batchNotifyFn"),n=mt,i=o(u=>{e?t.push(u):n(()=>{r(u)})},"schedule"),a=o(()=>{let u=t;t=[],u.length&&n(()=>{s(()=>{u.forEach(c=>{r(c)})})})},"flush");return{batch:o(u=>{let c;e++;try{c=u()}finally{e--,e||a()}return c},"batch"),batchCalls:o(u=>(...c)=>{i(()=>{u(...c)})},"batchCalls"),schedule:i,setNotifyFunction:o(u=>{r=u},"setNotifyFunction"),setBatchNotifyFunction:o(u=>{s=u},"setBatchNotifyFunction"),setScheduler:o(u=>{n=u},"setScheduler")}}o(fr,"createNotifyManager");var v=fr();var mr=class extends x{static{o(this,"OnlineManager")}#t=!0;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(!0),"onlineListener"),r=o(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#t}},W=new mr;function pr(t){return Math.min(1e3*2**t,3e4)}o(pr,"defaultRetryDelay");function Me(t){return(t??"online")==="online"?W.isOnline():!0}o(Me,"canFetch");var Ee=class extends Error{static{o(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Te(t){let e=!1,r=0,s,n=ie(),i=o(()=>n.status!=="pending","isResolved"),a=o(y=>{if(!i()){let b=new Ee(y);f(b),t.onCancel?.(b)}},"cancel"),u=o(()=>{e=!0},"cancelRetry"),c=o(()=>{e=!1},"continueRetry"),h=o(()=>z.isFocused()&&(t.networkMode==="always"||W.isOnline())&&t.canRun(),"canContinue"),d=o(()=>Me(t.networkMode)&&t.canRun(),"canStart"),l=o(y=>{i()||(s?.(),n.resolve(y))},"resolve"),f=o(y=>{i()||(s?.(),n.reject(y))},"reject"),p=o(()=>new Promise(y=>{s=o(b=>{(i()||h())&&y(b)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,i()||t.onContinue?.()}),"pause"),g=o(()=>{if(i())return;let y,b=r===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(E){y=Promise.reject(E)}Promise.resolve(y).then(l).catch(E=>{if(i())return;let A=t.retry??(F.isServer()?0:3),M=t.retryDelay??pr,Q=typeof M=="function"?M(r,E):M,H=A===!0||typeof A=="number"&&r<A||typeof A=="function"&&A(r,E);if(e||!H){f(E);return}r++,t.onFail?.(r,E),ht(Q).then(()=>h()?void 0:p()).then(()=>{e?f(E):g()})})},"run");return{promise:n,status:o(()=>n.status,"status"),cancel:a,continue:o(()=>(s?.(),n),"continue"),cancelRetry:u,continueRetry:c,canStart:d,start:o(()=>(d()?g():p().then(g),n),"start")}}o(Te,"createRetryer");var Ce=class{static{o(this,"Removable")}#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),re(this.gcTime)&&(this.#t=L.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(F.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(L.clearTimeout(this.#t),this.#t=void 0)}};function yt(t){return{onFetch:o((e,r)=>{let s=e.options,n=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],a=e.state.data?.pageParams||[],u={pages:[],pageParams:[]},c=0,h=o(async()=>{let d=!1,l=o(g=>{ft(g,()=>e.signal,()=>d=!0)},"addSignalProperty"),f=Se(e.options,e.fetchOptions),p=o(async(g,y,b)=>{if(d)return Promise.reject(e.signal.reason);if(y==null&&g.pages.length)return Promise.resolve(g);let A=o(()=>{let xe={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return l(xe),xe},"createQueryFnContext")(),M=await f(A),{maxPages:Q}=e.options,H=b?lt:dt;return{pages:H(g.pages,M,Q),pageParams:H(g.pageParams,y,Q)}},"fetchPage");if(n&&i.length){let g=n==="backward",y=g?yr:pt,b={pages:i,pageParams:a},E=y(s,b);u=await p(b,E,g)}else{let g=t??i.length;do{let y=c===0?a[0]??s.initialPageParam:pt(s,u);if(c>0&&y==null)break;u=await p(u,y),c++}while(c<g)}return u},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(h,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=h},"onFetch")}}o(yt,"infiniteQueryBehavior");function pt(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}o(pt,"getNextPageParam");function yr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}o(yr,"getPreviousPageParam");var bt=class extends Ce{static{o(this,"Query")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#s=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=vt(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(t){if(this.options={...this.#a,...t},t?._type&&(this.#t=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=vt(this.options);e.data!==void 0&&(this.setState(gt(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ne(this.state.data,t,this.options);return this.#c({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t){this.#c({type:"setState",state:t})}cancel(t){let e=this.#n?.promise;return this.#n?.cancel(t),e?e.then(S).catch(S):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>I(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>P(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!ye(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#n&&(this.#o||this.#h()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#h(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#c({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(t&&this.setOptions(t),!this.options.queryFn){let c=this.observers.find(h=>h.options.queryFn);c&&this.setOptions(c.options)}Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']");let r=new AbortController,s=o(c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:o(()=>(this.#o=!0,r.signal),"get")})},"addSignalProperty"),n=o(()=>{let c=Se(this.options,e),d=o(()=>{let l={client:this.#i,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#o=!1,this.options.persister?this.options.persister(c,d,this):c(d)},"fetchFn"),a=o(()=>{let c={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:n};return s(c),c},"createFetchContext")();(this.#t==="infinite"?yt(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Te({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o(c=>{c instanceof Ee&&c.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:o((c,h)=>{this.#c({type:"failed",failureCount:c,error:h})},"onFail"),onPause:o(()=>{this.#c({type:"pause"})},"onPause"),onContinue:o(()=>{this.#c({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:o(()=>!0,"canRun")});try{let c=await this.#n.start();if(c===void 0)throw console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#s.config.onSuccess?.(c,this),this.#s.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof Ee){if(c.silent)return this.#n.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#c({type:"error",error:c}),this.#s.config.onError?.(c,this),this.#s.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#c(t){let e=o(r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ne(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...gt(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#r=t.manual?s:void 0,s;case"error":let n=t.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),v.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function Ne(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Me(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}o(Ne,"fetchState");function gt(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}o(gt,"successState");function vt(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}o(vt,"getDefaultState");var Ue=class extends x{static{o(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#t=t,this.#o=null,this.#a=ie(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#r=void 0;#s=void 0;#i;#n;#a;#o;#h;#c;#m;#d;#l;#u;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),St(this.#e,this.options)?this.#f():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return De(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return De(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#e.removeObserver(this)}setOptions(t){let e=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#E(),this.#e.setOptions(this.options),e._defaulted&&!be(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});let s=this.hasListeners();s&&wt(this.#e,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#e!==r||I(this.options.enabled,this.#e)!==I(e.enabled,this.#e)||P(this.options.staleTime,this.#e)!==P(e.staleTime,this.#e))&&this.#y();let n=this.#g();s&&(this.#e!==r||I(this.options.enabled,this.#e)!==I(e.enabled,this.#e)||n!==this.#u)&&this.#v(n)}getOptimisticResult(t){let e=this.#t.getQueryCache().build(this.#t,t),r=this.createResult(e,t);return vr(this,r)&&(this.#s=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:o((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#t.defaultQueryOptions(t),r=this.#t.getQueryCache().build(this.#t,e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(t){this.#E();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(S)),e}#y(){this.#S();let t=P(this.options.staleTime,this.#e);if(F.isServer()||this.#s.isStale||!re(t))return;let r=ye(this.#s.dataUpdatedAt,t)+1;this.#d=L.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#u=t,!(F.isServer()||I(this.options.enabled,this.#e)===!1||!re(this.#u)||this.#u===0)&&(this.#l=L.setInterval(()=>{(this.options.refetchIntervalInBackground||z.isFocused())&&this.#f()},this.#u))}#b(){this.#y(),this.#v(this.#g())}#S(){this.#d!==void 0&&(L.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(L.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#e,s=this.options,n=this.#s,i=this.#i,a=this.#n,c=t!==r?t.state:this.#r,{state:h}=t,d={...h},l=!1,f;if(e._optimisticResults){let k=this.hasListeners(),te=!k&&St(t,e),le=k&&wt(t,r,e,s);(te||le)&&(d={...d,...Ne(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:y}=d;f=d.data;let b=!1;if(e.placeholderData!==void 0&&f===void 0&&y==="pending"){let k;n?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(k=n.data,b=!0):k=typeof e.placeholderData=="function"?e.placeholderData(this.#m?.state.data,this.#m):e.placeholderData,k!==void 0&&(y="success",f=ne(n?.data,k,e),l=!0)}if(e.select&&f!==void 0&&!b)if(n&&f===i?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ne(n?.data,f,e),this.#c=f,this.#o=null}catch(k){this.#o=k}this.#o&&(p=this.#o,f=this.#c,g=Date.now(),y="error");let E=d.fetchStatus==="fetching",A=y==="pending",M=y==="error",Q=A&&E,H=f!==void 0,D={status:y,fetchStatus:d.fetchStatus,isPending:A,isSuccess:y==="success",isError:M,isInitialLoading:Q,isLoading:Q,data:f,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:E,isRefetching:E&&!A,isLoadingError:M&&!H,isPaused:d.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:M&&H,isStale:Qe(t,e),refetch:this.refetch,promise:this.#a,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let k=D.data!==void 0,te=D.status==="error"&&!k,le=o(me=>{te?me.reject(D.error):k&&me.resolve(D.data)},"finalizeThenableIfPossible"),st=o(()=>{let me=this.#a=D.promise=ie();le(me)},"recreateThenable"),fe=this.#a;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(te||D.data!==fe.value)&&st();break;case"rejected":(!te||D.error!==fe.reason)&&st();break}}return D}updateResult(){let t=this.#s,e=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#m=this.#e),be(e,t))return;this.#s=e;let r=o(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,n=typeof s=="function"?s():s;if(n==="all"||!n&&!this.#p.size)return!0;let i=new Set(n??this.#p);return this.options.throwOnError&&i.add("error"),Object.keys(this.#s).some(a=>{let u=a;return this.#s[u]!==t[u]&&i.has(u)})},"shouldNotifyListeners");this.#T({listeners:r()})}#E(){let t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;let e=this.#e;this.#e=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#T(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function gr(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}o(gr,"shouldLoadOnMount");function St(t,e){return gr(t,e)||t.state.data!==void 0&&De(t,e,e.refetchOnMount)}o(St,"shouldFetchOnMount");function De(t,e,r){if(I(e.enabled,t)!==!1&&P(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&Qe(t,e)}return!1}o(De,"shouldFetchOn");function wt(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Qe(t,r)}o(wt,"shouldFetchOptionally");function Qe(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(P(e.staleTime,t))}o(Qe,"isStale");function vr(t,e){return!be(t.getCurrentResult(),e)}o(vr,"shouldAssignObserverCurrentProperties");var Et=class extends Ce{static{o(this,"Mutation")}#t;#e;#r;#s;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#e=[],this.state=t.state||br(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){let e=o(()=>{this.#i({type:"continue"})},"onContinue"),r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Te({fn:o(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:o((i,a)=>{this.#i({type:"failed",failureCount:i,error:a})},"onFail"),onPause:o(()=>{this.#i({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:o(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",n=!this.#s.canStart();try{if(s)e();else{this.#i({type:"pending",variables:t,isPaused:n}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let a=await this.options.onMutate?.(t,r);a!==this.state.context&&this.#i({type:"pending",context:a,variables:t,isPaused:n})}let i=await this.#s.start();return await this.#r.config.onSuccess?.(i,t,this.state.context,this,r),await this.options.onSuccess?.(i,t,this.state.context,r),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,t,this.state.context,r),this.#i({type:"success",data:i}),i}catch(i){try{await this.#r.config.onError?.(i,t,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,t,this.state.context,r)}catch(a){Promise.reject(a)}try{await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,t,this.state.context,r)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:i}),i}finally{this.#r.runNext(this)}}#i(t){let e=o(r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}},"reducer");this.state=e(this.state),v.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function br(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}o(br,"getDefaultState");var Tt=class extends x{static{o(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#r=0}#t;#e;#r;build(t,e,r){let s=new Et({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#t.add(t);let e=Ae(t);if(typeof e=="string"){let r=this.#e.get(e);r?r.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){let e=Ae(t);if(typeof e=="string"){let r=this.#e.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ae(t);if(typeof e=="string"){let s=this.#e.get(e)?.find(n=>n.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ae(t);return typeof e=="string"?this.#e.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ve(e,r))}findAll(t={}){return this.getAll().filter(e=>ve(t,e))}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return v.batch(()=>Promise.all(t.map(e=>e.continue().catch(S))))}};function Ae(t){return t.options.scope?.id}o(Ae,"scopeFor");var Ct=class extends x{static{o(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,r){let s=e.queryKey,n=e.queryHash??se(s,e),i=this.get(n);return i||(i=new bt({client:t,queryKey:s,queryHash:n,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(i)),i}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ge(e,r))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(r=>ge(t,r)):e}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){v.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){v.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var He=class{static{o(this,"QueryClient")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t={}){this.#t=t.queryCache||new Ct,this.#e=t.mutationCache||new Tt,this.#r=t.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#a=z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#o=W.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#t.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(P(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),i=this.#t.get(s.queryHash)?.state.data,a=ut(e,i);if(a!==void 0)return this.#t.build(this,s).setData(a,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#t.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){let e=this.#t;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#t;return v.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=v.batch(()=>this.#t.findAll(t).map(n=>n.cancel(r)));return Promise.all(s).then(S).catch(S)}invalidateQueries(t,e={}){return v.batch(()=>(this.#t.findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},s=v.batch(()=>this.#t.findAll(t).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(S)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(S)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#t.build(this,e);return r.isStaleByTime(P(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(S).catch(S)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(S).catch(S)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return W.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(B(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{K(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#i.set(B(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#i.values()],r={};return e.forEach(s=>{K(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=se(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===j&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}};var J=R(q(),1),At=R(it(),1);var oe=J.createContext(void 0),qe=o(t=>{let e=J.useContext(oe);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Be=o(({client:t,children:e})=>(J.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,At.jsx)(oe.Provider,{value:t,children:e})),"QueryClientProvider");var Ie=R(q(),1);var It=Ie.createContext(!1),_t=o(()=>Ie.useContext(It),"useIsRestoring"),so=It.Provider;var ae=R(q(),1),Sr=R(it(),1);function wr(){let t=!1;return{clearReset:o(()=>{t=!1},"clearReset"),reset:o(()=>{t=!0},"reset"),isReset:o(()=>t,"isReset")}}o(wr,"createValue");var Er=ae.createContext(wr()),kt=o(()=>ae.useContext(Er),"useQueryErrorResetBoundary");var Rt=R(q(),1);var Ot=o((t,e,r)=>{let s=r?.state.error&&typeof t.throwOnError=="function"?we(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},"ensurePreventErrorBoundaryRetry"),Pt=o(t=>{Rt.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),xt=o(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:n})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(n&&t.data===void 0||we(r,[t.error,s])),"getHasError");var Lt=o(t=>{if(t.suspense){let r=o(n=>n==="static"?n:Math.max(n??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...n)=>r(s(...n)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Ft=o((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Mt=o((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),je=o((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");var U=R(q(),1);function Nt(t,e,r){if(typeof t!="object"||Array.isArray(t))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let s=_t(),n=kt(),i=qe(r),a=i.defaultQueryOptions(t);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a);let u=i.getQueryCache().get(a.queryHash);a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`);let c=t.subscribed!==!1;a._optimisticResults=s?"isRestoring":c?"optimistic":void 0,Lt(a),Ot(a,n,u),Pt(n);let h=!i.getQueryCache().get(a.queryHash),[d]=U.useState(()=>new e(i,a)),l=d.getOptimisticResult(a),f=!s&&c;if(U.useSyncExternalStore(U.useCallback(p=>{let g=f?d.subscribe(v.batchCalls(p)):S;return d.updateResult(),g},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),U.useEffect(()=>{d.setOptions(a)},[a,d]),Mt(a,l))throw je(a,d,n);if(xt({result:l,errorResetBoundary:n,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw l.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,l),a.experimental_prefetchInRender&&!F.isServer()&&Ft(l,s)&&(h?je(a,d,n):u?.promise)?.catch(S).finally(()=>{d.updateResult()}),a.notifyOnChangeProps?l:d.trackResult(l)}o(Nt,"useBaseQuery");function Tr(t,e){return Nt(t,Ue,e)}o(Tr,"useQuery");var $=R(q(),1),Ke=R(ar(),1);var Ut=(0,$.createContext)(null),Cr=o(()=>new He({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"createDefaultQueryClient"),Ar=o(t=>{let e=(0,Dt.c)(9),{children:r,client:s,queryClient:n}=t,i=(0,$.use)(oe),a;e[0]!==i||e[1]!==n?(a=o(()=>n??i??Cr(),"t1"),e[0]=i,e[1]=n,e[2]=a):a=e[2];let[u]=(0,$.useState)(a),c=n??i??u;if(!c)throw new m("INTERNAL","LunoraProvider: failed to resolve a QueryClient");let h;e[3]!==r||e[4]!==s?(h=(0,Ke.jsxDEV)(Ut,{value:s,children:r},void 0,!1),e[3]=r,e[4]=s,e[5]=h):h=e[5];let d=h;if(i===c)return d;let l;return e[6]!==d||e[7]!==c?(l=(0,Ke.jsxDEV)(Be,{client:c,children:d},void 0,!1),e[6]=d,e[7]=c,e[8]=l):l=e[8],l},"LunoraProvider"),$e=o(()=>{let t=(0,$.use)(Ut);if(!t)throw new m("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"useLunora");var Qt=R(nt(),1),Ht=R(q(),1);var Ir=o(()=>{let t=(0,Qt.c)(4),e=$e(),r,s,n;return t[0]!==e?(r=o(i=>e.onConnectionStatus(()=>{i()}),"t0"),s=o(()=>e.connectionStatus(),"t1"),n=o(()=>e.connectionStatus(),"t2"),t[0]=e,t[1]=r,t[2]=s,t[3]=n):(r=t[1],s=t[2],n=t[3]),(0,Ht.useSyncExternalStore)(r,s,n)},"useConnectionStatus");var qt=o(()=>{let t=null;return{get:o(()=>t,"get"),set:o(e=>{t=e},"set")}},"createInMemoryBookmarkStorage");var Bt="_creationTime",_r=o(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"rowId"),kr=o((t,e)=>{let r=e[Bt];if(typeof r!="number")return t.length;for(let[s,n]of t.entries()){let i=n[Bt];if(typeof i=="number"&&i>r)return s}return t.length},"insertionIndex"),jt=o(t=>{if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.key=="string"&&typeof e.table=="string"&&(e.op==="insert"||e.op==="update"||e.op==="delete")},"isMutationDelta"),Kt=o((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let c of t){if(_r(c)===void 0)return;r.push(c)}let{key:s,op:n,row:i}=e;if(n==="delete"){let c=r.filter(h=>h._id!==s);return c.length===r.length?[...r]:c}if(i===void 0)return;let a=r.findIndex(c=>c._id===s);if(a===-1){let c=[...r];return c.splice(kr(r,i),0,i),c}let u=[...r];return u[a]=i,u},"applyDelta");var _e=o((t,e)=>{let r=t;for(let s of e)try{r=s.transform(r)}catch{}return r},"foldOptimistic"),ce=o((t,e)=>{if(e!==t.lastValue){t.lastValue=e;for(let r of t.callbacks)try{r(e)}catch{}}},"notifySubscription"),Ge=o((t,e)=>{let r;try{r=e(t.lastValue)}catch{return}let s={id:Symbol("optimistic"),transform:e};t.optimisticLayers.push(s),ce(t,r);let n=o(()=>{let a=t.optimisticLayers.findIndex(u=>u.id===s.id);return a===-1?!1:(t.optimisticLayers.splice(a,1),!0)},"remove"),i=o(()=>{ce(t,_e(t.serverBase,t.optimisticLayers))},"refold");return{confirm:o(a=>{if(a===void 0){n();return}s.commitCursor=a,t.serverCursor!==void 0&&t.serverCursor>=a&&n()&&i()},"confirm"),rollback:o(()=>{n()&&i()},"rollback")}},"applyOptimisticLayer"),Ve=o((t,e)=>{if(e===void 0||t.optimisticLayers.length===0)return!1;let r=t.optimisticLayers.length;return t.optimisticLayers=t.optimisticLayers.filter(s=>s.commitCursor===void 0||s.commitCursor>e),t.optimisticLayers.length!==r},"dropConfirmedLayers"),$t=o((t,e,r)=>{let s=[],n=[],i=o((u,c)=>{for(let h of t.all())if(h.fn.__lunoraRef===u&&h.shardKey===e&&h.argsKey===c)return h},"findState");return{confirms:s,rollbacks:n,store:{getAllQueries:o(u=>{let c=[];for(let h of t.all())h.fn.__lunoraRef===u.__lunoraRef&&h.shardKey===e&&c.push({args:h.args,value:h.lastValue});return c},"getAllQueries"),getQuery:o((u,c)=>i(u.__lunoraRef,r(c??{}))?.lastValue,"getQuery"),setQuery:o((u,c,h)=>{let d=i(u.__lunoraRef,r(c??{}));if(!d)return;let l=Ge(d,()=>h);l&&(s.push(l.confirm),n.push(l.rollback))},"setQuery")}}},"createLocalStore");var Rr=o((t,e)=>t<e?-1:t>e?1:0,"compareKeys"),X=o(t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) \u2014 pass it as a string");if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(i=>X(i)).join(",")}]`;let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype){let i=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${i} in a cache key (query/subscription/shape args) \u2014 only plain objects, arrays, and JSON primitives are supported`)}let r=t,s=Object.keys(r).toSorted(Rr),n=[];for(let i of s){let a=r[i];a!==void 0&&n.push(`${JSON.stringify(i)}:${X(a)}`)}return`{${n.join(",")}}`},"stableStringify"),Y=class t{static{o(this,"SubscriptionRegistry")}static key(e,r,s){return`${e}::${X(r)}::${s??""}`}byKey=new Map;byId=new Map;get(e){return this.byKey.get(e)}getById(e){return this.byId.get(e)}add(e){this.byKey.set(t.key(e.fn.__lunoraRef,e.args,e.shardKey),e),this.byId.set(e.id,e)}remove(e){this.byKey.delete(t.key(e.fn.__lunoraRef,e.args,e.shardKey)),this.byId.delete(e.id)}all(){return[...this.byKey.values()]}};var ze=o((t,e)=>t!==void 0&&e!==t,"isStaleVersion"),Gt=0,Re=o(()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();Gt+=1;let t=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?[...crypto.getRandomValues(new Uint8Array(8))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(16).slice(2,12);return`m_${Date.now().toString(36)}_${Gt.toString(36)}_${t}`},"nextId"),Z=o((t,e,r,s)=>{if(t){t({error:r,mutationId:s,operation:e});return}console.warn(`[lunora] offline-queue persistence ${e} failed`,r)},"reportPersistenceError"),ke=class{static{o(this,"OfflineQueue")}queueBeforeFirstConnect;maxItems;onPersistenceError;persistence;onEvict;onSizeChange;version;items=[];constructor(e={},r={}){this.maxItems=e.maxItems??1e3,this.queueBeforeFirstConnect=e.queueBeforeFirstConnect??!1,this.onPersistenceError=e.onPersistenceError,this.persistence=r.persistence,this.onEvict=r.onEvict,this.onSizeChange=r.onSizeChange,this.version=r.version}get size(){return this.items.length}enqueue(e){let r=e;for(r.id??=Re(),this.items.push(r),this.persistence?.append({args:r.args,functionPath:r.functionPath,id:r.id,identity:r.identity,shardKey:r.shardKey,...this.version===void 0?{}:{version:this.version}}).catch(s=>{Z(this.onPersistenceError,"append",s,r.id)});this.items.length>this.maxItems;){let s=this.items.shift();if(s){s.id&&this.persistence?.remove(s.id).catch(i=>{Z(this.onPersistenceError,"remove",i,s.id)});let n=new Error("offline queue overflow");n.code="OFFLINE_QUEUE_OVERFLOW",s.reject(n),this.onEvict?.(s,n)}}this.notifySize()}async hydrate(){if(!this.persistence)return[];let e;try{e=await this.persistence.load()}catch(s){throw Z(this.onPersistenceError,"load",s),s}let r=new Set;for(let s of e)if(!this.items.some(n=>n.id===s.id)){if(ze(this.version,s.version)){this.persistence.remove(s.id).catch(n=>{Z(this.onPersistenceError,"remove",n,s.id)});continue}this.items.push({args:s.args,functionPath:s.functionPath,id:s.id,identity:s.identity,reject:o(()=>{},"reject"),resolve:o(()=>{},"resolve"),shardKey:s.shardKey}),r.add(s.shardKey)}return this.notifySize(),[...r]}drain(e){if(!e){let n=[...this.items];return this.items.length=0,this.notifySize(),n}let r=[],s=[];for(let n of this.items)(e(n)?r:s).push(n);return this.items.length=0,this.items.push(...s),this.notifySize(),r}requeue(e){e.length!==0&&(this.items.unshift(...e),this.notifySize())}clear(){for(let e of this.items){let r=new Error("CLIENT_CLOSED");r.code="CLIENT_CLOSED",e.reject(r)}this.items.length=0,this.notifySize()}notifySize(){this.onSizeChange?.(this.items.length)}};var Or="lunora-outbox",Pr="offline-mutations",Vt="by_id",ue=o(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"promisifyRequest"),xr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new m("INTERNAL","createIndexedDbPersistence: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryPersistence()");let r=t.databaseName??Or,s=t.storeName??Pr,n,i=o(()=>n||(n=new Promise((u,c)=>{let h=e.open(r,1);h.addEventListener("upgradeneeded",()=>{let d=h.result;d.objectStoreNames.contains(s)||d.createObjectStore(s,{autoIncrement:!0}).createIndex(Vt,"id",{unique:!0})}),h.addEventListener("success",()=>{u(h.result)}),h.addEventListener("error",()=>{c(h.error??new Error("IndexedDB open failed"))})}),n),"openDatabase"),a=o(async(u,c)=>{let d=(await i()).transaction(s,u),l=await c(d.objectStore(s));return await new Promise((f,p)=>{d.addEventListener("complete",()=>{f()}),d.addEventListener("error",()=>{p(d.error??new Error("IndexedDB transaction failed"))}),d.addEventListener("abort",()=>{p(d.error??new Error("IndexedDB transaction aborted"))})}),l},"withStore");return{append:o(async u=>{await a("readwrite",c=>ue(c.add(u)))},"append"),clear:o(async()=>{await a("readwrite",u=>ue(u.clear()))},"clear"),load:o(async()=>a("readonly",u=>ue(u.getAll())),"load"),remove:o(async u=>{await a("readwrite",async c=>{let h=await ue(c.index(Vt).getKey(u));h!==void 0&&await ue(c.delete(h))})},"remove")}},"createIndexedDbPersistence"),zt=o((t,e=!0)=>{if(t!==!1){if(t)return t;if(!(!e||typeof indexedDB>"u"))return xr()}},"resolvePersistenceAdapter");var We=o((t,e,r)=>`${t}::${e}::${r??""}`,"queryCacheKey"),Lr=500;var Fr="lunora-query-cache",Mr="query-cache",Wt="by_ts",Nr=1,he=o(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"promisifyRequest"),Dr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new m("INTERNAL","createIndexedDbQueryCache: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryQueryCache()");let r=t.databaseName??Fr,s=t.storeName??Mr,n=t.maxEntries??Lr,i,a=o(()=>i||(i=new Promise((h,d)=>{let l=e.open(r,Nr);l.addEventListener("upgradeneeded",()=>{let f=l.result;f.objectStoreNames.contains(s)||f.createObjectStore(s,{keyPath:"key"}).createIndex(Wt,"ts",{unique:!1})}),l.addEventListener("success",()=>{h(l.result)}),l.addEventListener("error",()=>{d(l.error??new Error("IndexedDB open failed"))})}),i),"openDatabase"),u=o(async(h,d)=>{let f=(await a()).transaction(s,h),p=await d(f.objectStore(s));return await new Promise((g,y)=>{f.addEventListener("complete",()=>{g()}),f.addEventListener("error",()=>{y(f.error??new Error("IndexedDB transaction failed"))}),f.addEventListener("abort",()=>{y(f.error??new Error("IndexedDB transaction aborted"))})}),p},"withStore"),c=o(async h=>{let l=await he(h.count())-n;l<=0||await new Promise((f,p)=>{let g=h.index(Wt).openCursor();g.addEventListener("success",()=>{let y=g.result;if(!y||l<=0){f();return}y.delete(),l-=1,y.continue()}),g.addEventListener("error",()=>{p(g.error??new Error("IndexedDB eviction failed"))})})},"evict");return{clear:o(async()=>{await u("readwrite",h=>he(h.clear()))},"clear"),load:o(async()=>u("readonly",h=>he(h.getAll())),"load"),put:o(async(h,d)=>{await u("readwrite",async l=>{await he(l.put({...d,key:h})),await c(l)})},"put"),remove:o(async h=>{await u("readwrite",d=>he(d.delete(h)))},"remove")}},"createIndexedDbQueryCache"),Jt=o(t=>{if(t!==!1){if(t)return t;if(!(typeof indexedDB>"u"))return Dr()}},"resolveQueryCacheAdapter");var Je=o((t={},e=Math.random)=>{let r=t.initialDelayMs??250,s=t.maxDelayMs??3e4,n=t.jitter??!0,i=0;return{next(){let a=Math.min(s,r*2**i);if(i+=1,!n)return a;let u=a/2;return Math.floor(u+e()*(a-u))},reset(){i=0}}},"createReconnect");var Xt=o(t=>{let e=t.maxBuffer??1024,r=[],s=[],n=!1,i,a=!1,u=o(()=>{let l=s.shift();if(!l)return!1;if(i)return l.reject(i),!0;if(r.length>0){let f=r.shift();return l.resolve({done:!1,value:f}),!0}return n?(l.resolve({done:!0,value:void 0}),!0):(s.unshift(l),!1)},"flushOne"),c={complete(){if(!(n||i))for(n=!0;u(););},fail(l){if(!(n||i))for(i=l,r.length=0;u(););},push(l){if(!(n||i||a)){if(r.length>=e){c.fail(Object.assign(new Error(`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`),{code:"STREAM_BACKPRESSURE"}));return}r.push(l),u()}}},h=o(()=>{if(!a){a=!0,n=!0,r.length=0;try{t.onCancel()}catch{}for(;u(););}},"cancel");return{handle:c,iterable:{cancel:h,[Symbol.asyncIterator](){return{next(){if(i)return Promise.reject(i);if(r.length>0){let l=r.shift();return Promise.resolve({done:!1,value:l})}return n?Promise.resolve({done:!0,value:void 0}):new Promise((l,f)=>{s.push({reject:f,resolve:l})})},return(){return h(),Promise.resolve({done:!0,value:void 0})}}}}}},"createStream");var Xe=500,C="$lunora.wire$",Pe=64,Yt=1024,Zt="__proto__",er={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},tr={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ye=o(t=>{let e="";for(let s=0;s<t.length;s+=32768)e+=String.fromCharCode(...t.subarray(s,s+32768));return btoa(e)},"toBase64"),Ur=o(t=>{let e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s+=1)r[s]=e.codePointAt(s)??0;return r},"fromBase64"),N=o((t,e=0)=>{if(e>Pe)throw new RangeError(`wire-codec: value nesting exceeds the ${Pe}-level limit`);if(t===void 0)return[C,"undefined"];if(t===null)return null;let r=typeof t;if(r==="bigint")return[C,"bigint",t.toString()];if(r==="number"){let a=t;return Number.isNaN(a)?[C,"nan"]:a===1/0?[C,"inf"]:a===-1/0?[C,"-inf"]:a}if(r!=="object")return t;if(t instanceof Date)return[C,"date",N(t.getTime(),e+1)];if(t instanceof Error){let a=t,u={};for(let h of Object.keys(a))a[h]!==void 0&&(u[h]=N(a[h],e+1));let c=[C,"error",a.name,a.message,u];return a.cause!==void 0&&c.push(N(a.cause,e+1)),c}if(t instanceof URL)return[C,"url",t.href];if(t instanceof Map)return[C,"map",[...t.entries()].map(([a,u])=>[N(a,e+1),N(u,e+1)])];if(t instanceof Set)return[C,"set",[...t].map(a=>N(a,e+1))];if(t instanceof ArrayBuffer)return[C,"bytes",Ye(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){let a=t,u=a.constructor.name,c=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);return u==="Uint8Array"?[C,"bytes",Ye(c)]:[C,"bytes",Ye(c),u]}if(Array.isArray(t)){let a=t.map(u=>N(u,e+1));return a.length>0&&a[0]===C?[C,"arr",a]:a}let s=Object.getPrototypeOf(t);if(s!==null&&s!==Object.prototype){let a=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${a} over the Lunora wire \u2014 only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}let n=t,i={};for(let a of Object.keys(n)){let u=n[a];u!==void 0&&(i[a]=N(u,e+1))}return i},"encodeWire"),w=o((t,e=0)=>{if(e>Pe)throw new RangeError(`wire-codec: value nesting exceeds the ${Pe}-level limit`);if(t===null||typeof t!="object")return t;if(Array.isArray(t)){if(t[0]===C)switch(t[1]){case"-inf":return-1/0;case"arr":return t[2].map(i=>w(i,e+1));case"bigint":{let i=t[2];if(typeof i!="string"||i.length>Yt||!/^-?\d+$/.test(i))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${Yt} digits)`);return BigInt(i)}case"date":return new Date(w(t[2],e+1));case"map":return new Map(t[2].map(([i,a])=>[w(i,e+1),w(a,e+1)]));case"set":return new Set(t[2].map(i=>w(i,e+1)));case"url":return new URL(t[2]);case"error":{let i=t[2],a=t[3],u=(Object.hasOwn(tr,i)?tr[i]:void 0)??Error,c=new u(a);c.name!==i&&Object.defineProperty(c,"name",{configurable:!0,value:i,writable:!0});let h=w(t[4],e+1);for(let d of Object.keys(h))d===Zt?Object.defineProperty(c,d,{configurable:!0,enumerable:!0,value:h[d],writable:!0}):c[d]=h[d];return t.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:w(t[5],e+1),writable:!0}),c}case"bytes":{let i=Ur(t[2]),a=t[3]??"Uint8Array";if(a==="ArrayBuffer")return i.buffer.byteLength===i.byteLength?i.buffer:i.slice().buffer;let u=Object.hasOwn(er,a)?er[a]:void 0;return u?new u(i.slice().buffer):i}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return t.map(i=>w(i,e+1))}return t.map(n=>w(n,e+1))}let r=t,s={};for(let n of Object.keys(r)){let i=w(r[n],e+1);n===Zt?Object.defineProperty(s,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):s[n]=i}return s},"decodeWire"),V=class{static{o(this,"Listeners")}listeners=new Set;add(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(...e){let[r]=e;for(let s of this.listeners)try{s(r)}catch{}}clear(){this.listeners.clear()}},Qr="/_lunora/rpc",rr="/_lunora/rpc-batch",Hr="/_lunora/ws",Ze=o(t=>t===void 0||t===""?"":`&bucket=${encodeURIComponent(t)}`,"bucketQuery"),et=o(t=>{for(let e=t.length-1;e>=0;e-=1)t[e]?.()},"rollbackOptimistic"),qr=o((t,e)=>{for(let r of e)r.op==="delete"?t.delete(r.key):r.value!==void 0&&t.set(r.key,r.value)},"applyRowOpsToView"),Br="lunora-ping",jr=3e4,Kr=1e4,$r=250,Gr=64,Vr="/_lunora/admin/shard-traffic",zr="/_lunora/admin/scheduled",Wr="/_lunora/admin/scheduled/status",Jr="/_lunora/admin/scheduled/ws",Xr="/_lunora/admin/scheduled/cancel",Yr="/_lunora/admin/scheduled/dead",Zr="/_lunora/admin/scheduled/dead/retry",es="/_lunora/admin/scheduled/dead/cancel",ts="/_lunora/admin/workflows/instances",rs="/_lunora/admin/workflows/instance",ss="/_lunora/admin/workflows/status",Oe="/_lunora/admin/storage",ns="/_lunora/admin/storage/url",is="/_lunora/admin/storage/buckets",os="/_lunora/admin/functions",as="/_lunora/admin/cron-jobs",cs="/_lunora/admin/cron-jobs/run",us="/_lunora/admin/openapi",hs="/_lunora/admin/openrpc",ds="/_lunora/admin/global/tables",ls="/_lunora/admin/global/table",fs="/_lunora/admin/global/facet",ms="/_lunora/admin/vector/indexes",ps="/_lunora/admin/vector/query",ys="/_lunora/admin/kv/namespaces",gs="/_lunora/admin/kv/keys",tt="/_lunora/admin/kv/value",vs="/_lunora/admin/auth/users",sr="/_lunora/admin/auth/sessions",bs="/_lunora/admin/auth/users/create",Ss="/_lunora/admin/auth/users/role",ws="/_lunora/admin/auth/users/ban",Es="/_lunora/admin/auth/users/unban",Ts="/_lunora/admin/auth/users/password",Cs="/_lunora/admin/auth/users/remove",As="/_lunora/admin/auth/users/impersonate",Is="/_lunora/admin/auth/sessions/revoke",_s="/_lunora/admin/auth/sessions/revoke-all",ks="/_lunora/admin/auth/capabilities",Rs="/_lunora/admin/auth/users/update",Os="/_lunora/admin/auth/accounts",Ps="/_lunora/admin/auth/accounts/unlink",xs="/_lunora/admin/auth/passkeys",Ls="/_lunora/admin/auth/passkeys/delete",Fs="/_lunora/admin/auth/two-factor/disable",Ms="/_lunora/admin/auth/organizations",Ns="/_lunora/admin/auth/organizations/members",Ds="/_lunora/admin/auth/organizations/invitations",Us="/_lunora/admin/auth/organizations/members/remove",Qs="/_lunora/admin/auth/organizations/invitations/cancel",Hs="/_lunora/admin/auth/config",qs="/_lunora/admin/auth/organizations/create",Bs="/_lunora/admin/auth/organizations/update",js="/_lunora/admin/auth/organizations/remove",Ks="/_lunora/admin/auth/organizations/members/add",$s="/_lunora/admin/auth/organizations/members/invite",Gs="/_lunora/admin/auth/organizations/members/role",Vs="/_lunora/admin/auth/organizations/teams",zs="/_lunora/admin/auth/organizations/teams/create",Ws="/_lunora/admin/auth/organizations/teams/update",Js="/_lunora/admin/auth/organizations/teams/remove",Xs="/_lunora/admin/auth/organizations/teams/members",Ys="/_lunora/admin/auth/organizations/teams/members/add",Zs="/_lunora/admin/auth/organizations/teams/members/remove",en="/_lunora/admin/auth/organizations/roles",tn="/_lunora/admin/auth/organizations/roles/create",rn="/_lunora/admin/auth/organizations/roles/update",sn="/_lunora/admin/auth/organizations/roles/remove",nn="/api/auth",on="/get-session",nr=o(t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,"deriveWsUrl"),G=o((t,e)=>`${t.endsWith("/")?t.slice(0,-1):t}${e}`,"joinUrl"),O=o((t,e)=>{let r=new URLSearchParams;for(let[n,i]of Object.entries(e))i!==void 0&&i!==""&&r.set(n,String(i));let s=r.toString();return s===""?t:`${t}?${s}`},"withQuery"),T=o(t=>t??"","connectionKey"),an=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0,n=(typeof t.message=="string"?t.message:void 0)??s??"stream error";return Object.assign(new Error(n),r===void 0?void 0:{code:r})},"buildStreamError"),ir=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0;return{message:(typeof t.message=="string"?t.message:void 0)??s??"subscription error",...r===void 0?{}:{code:r}}},"buildSubscriptionError"),or=o((t,e)=>{for(let r of t)try{r(e)}catch{}},"fanSubscriptionError"),cn=new TextDecoder,un=o(t=>{if(typeof t=="string")return t;if(t instanceof ArrayBuffer)return cn.decode(t)},"decodeServerFrame"),_=o((t,e)=>{if(!t.socket||t.wsState!=="open")return!1;try{return t.socket.send(JSON.stringify(e)),!0}catch{return!1}},"sendOn"),de=o(t=>{let e=new Error(t.message??"request failed");return e.code=t.code,t.data!==void 0&&(e.data=w(t.data)),t.hint!==void 0&&(e.hint=t.hint),t.docsUrl!==void 0&&(e.docsUrl=t.docsUrl),e},"reconstructError"),ee=o((t,e)=>{try{return N(t)}catch(r){let s=r instanceof Error?r.message:String(r);throw new TypeError(`LunoraClient: cannot encode ${e} \u2014 ${s}`,r instanceof Error?{cause:r}:void 0)}},"encodeCallArgs"),hn=o((t,e)=>{let r=Array.from({length:e});for(let s of t){if(typeof s.id!="number"||s.id<0||s.id>=e)continue;let n=s.body;r[s.id]=n&&"error"in n&&n.error?{error:de(n.error),ok:!1}:{ok:!0,value:w(n?.result)}}return r.map(s=>s??{error:new Error("batch call returned no result"),ok:!1})},"demuxBatchResults"),dn=new Set(["SHARD_ERROR","SHARD_UNAVAILABLE"]),rt=class t{static{o(this,"LunoraClient")}static MAX_POKE_BUFFERS=256;url;wsUrl;wsToken;authBasePath;fetchImpl;WebSocketImpl;bookmark;reconnectOptions;connectTimeoutMs;heartbeatIntervalMs;offlineQueue;outbox;clientId;clientWatermarks=new Map;outboxMutationCounter=0;onPersistenceError;persistence;persistenceVersion;outboxLeaderRelease;queryCache;hydratedQueryCache=new Map;pendingCacheWrites=new Map;cacheFlushTimer;subscriptions=new Y;connections=new Map;defaultConnectionContext;connectionContexts=new Map;connectionContextHolders=new Map;authToken=null;authSubject=void 0;queuedIdentities=new Map;closed=!1;authTokenListeners=new V;statusListeners=new V;tokenExpiredListeners=new V;mutationSettledListeners=new V;pendingChangeListeners=new V;whisperHandlers=new Map;lastStatus="idle";nextSubId=0;nextStreamId=0;streams=new Map;shapeSubscriptions=new Map;pokeBuffers=new Map;nextShapeId=0;constructor(e){this.url=e.url,this.wsUrl=e.wsUrl??G(nr(e.url),Hr),this.wsToken=e.wsToken;let r=e.authBasePath??nn;this.authBasePath=r.endsWith("/")?r.slice(0,-1):r,this.fetchImpl=e.fetch??(typeof fetch=="function"?fetch.bind(globalThis):void 0),this.WebSocketImpl=e.WebSocket??(typeof WebSocket=="function"?WebSocket:void 0),this.bookmark=e.bookmarkStorage??qt(),this.reconnectOptions=e.reconnect,this.heartbeatIntervalMs=e.heartbeatIntervalMs??jr,this.connectTimeoutMs=e.connectTimeoutMs??Kr,this.defaultConnectionContext=e.connectionContext,this.persistence=zt(e.persistence,e.outbox===void 0),this.persistenceVersion=e.persistenceVersion,this.queryCache=Jt(e.queryCache),this.onPersistenceError=e.offlineQueue?.onPersistenceError,this.offlineQueue=new ke(e.offlineQueue,{onEvict:o((s,n)=>{this.emitItemSettled(s,"rejected",n)},"onEvict"),onSizeChange:o(s=>{this.pendingChangeListeners.emit(s)},"onSizeChange"),persistence:this.persistence,version:e.persistenceVersion}),this.outbox=e.outbox,this.clientId=e.clientId??`client-${Re()}`,this.persistence&&queueMicrotask(()=>{this.hydrateAsOutboxLeader()}),this.queryCache&&queueMicrotask(()=>{this.hydrateQueryCache().catch(()=>{})})}setAuthToken(e,r){let s=this.authToken!==e,n=this.identityFingerprint();this.authToken=e,r!==void 0&&(this.authSubject=r);let i=this.identityFingerprint();i!==n&&(s?this.rejectQueuedForIdentityChange():this.restampQueuedIdentity(n,i)),s&&this.authTokenListeners.emit(e)}getAuthToken(){return this.authToken}currentIdentity(){return this.identityFingerprint()}clientIdentifier(){return this.clientId}confirmedMutationWatermark(e){return this.clientWatermarks.get(e??"")??0}async callMutator(e,r,s){let n=s?.clientSeq;if(n!==void 0&&(!Number.isInteger(n)||n<=0))throw new m("INTERNAL",`callMutator: clientSeq must be a positive integer, got ${String(n)}`);let i=s?.shardKey??"",a,u=await this.rpc(e,r,s?.shardKey,{captureBookmark:!0,clientId:this.clientId,clientSeq:n,onMutationAck:o(h=>{a=h},"onMutationAck")});return a!==void 0&&a>(this.clientWatermarks.get(i)??0)&&this.clientWatermarks.set(i,a),{applied:a===void 0||a===n,result:u}}onAuthTokenChange(e){return this.authTokenListeners.add(e)}async getCurrentUser(){if(this.closed||!this.fetchImpl)return null;let e={};this.authToken&&(e.authorization=`Bearer ${this.authToken}`);try{let r=await this.fetchImpl(G(this.url,`${this.authBasePath}${on}`),{credentials:"include",headers:e,method:"GET"});return r.ok?(await r.json())?.user??null:null}catch{return null}}setWsToken(e){if(this.wsToken!==e){this.wsToken=e;for(let r of this.connections.values())if(r.socket)try{r.socket.close()}catch{}}}setConnectionContext(e,r={}){let s=T(r.shardKey);e===void 0?this.connectionContexts.delete(s):this.connectionContexts.set(s,e),this.refreshConnectionContext(s)}acquireConnectionContext(e,r={}){let s=T(r.shardKey),n={context:e},i=this.connectionContextHolders.get(s);i?i.push(n):this.connectionContextHolders.set(s,[n]),this.refreshConnectionContext(s);let a=!1;return()=>{if(a)return;a=!0;let u=this.connectionContextHolders.get(s);if(!u)return;let c=u.indexOf(n);c!==-1&&u.splice(c,1),u.length===0&&this.connectionContextHolders.delete(s),this.refreshConnectionContext(s)}}whisperSubscribe(e,r,s={}){let n=T(s.shardKey),i=this.whisperHandlers.get(n);i||(i=new Map,this.whisperHandlers.set(n,i));let a=i.get(e),u=a===void 0;if(a||(a=new Set,i.set(e,a)),a.add(r),this.ensureSocket(s.shardKey),u){let c=this.getConnection(s.shardKey);c&&_(c,{topic:e,type:"whisper_subscribe"})}return()=>{let c=this.whisperHandlers.get(n),h=c?.get(e);if(!h?.delete(r)||h.size>0)return;c?.delete(e),c?.size===0&&this.whisperHandlers.delete(n);let d=this.getConnection(s.shardKey);d&&_(d,{topic:e,type:"whisper_unsubscribe"})}}whisper(e,r,s={}){this.ensureSocket(s.shardKey);let n=this.getConnection(s.shardKey);n&&_(n,{data:ee(r??null,`whisper data for topic '${e}'`),topic:e,type:"whisper"})}onTokenExpired(e){return this.tokenExpiredListeners.add(e)}connectionStatus(){return this.computeStatus()}onConnectionStatus(e){let r=this.statusListeners.add(e);return e(this.computeStatus()),r}pendingCount(){return this.offlineQueue.size}onPendingChange(e){let r=this.pendingChangeListeners.add(e);return e(this.offlineQueue.size),r}onMutationSettled(e){return this.mutationSettledListeners.add(e)}async query(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey,{attachBookmark:!0})}async batch(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");if(!this.fetchImpl)throw new m("INTERNAL","LunoraClient: no `fetch` implementation available");if(e.length===0)return[];let r=await this.fetchImpl(G(this.url,rr),{body:JSON.stringify({calls:e.map((i,a)=>({args:ee(i.args??{},`args for batch call '${i.fn.__lunoraRef}'`),functionPath:i.fn.__lunoraRef,id:a,shardKey:i.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"}),s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let n;try{n=await r.json()}catch{throw new m("INTERNAL",`LunoraClient: batch response was not JSON (status ${r.status.toString()})`)}if(!r.ok||n.error&&!n.results)throw n.error?de(n.error):new m("INTERNAL",`LunoraClient: batch request failed (status ${r.status.toString()})`);return hn(n.results??[],e.length)}async mutation(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let n=r,i=s.mutationId??Re(),{confirms:a,rollbacks:u}=this.applyOptimisticUpdates(e.__lunoraRef,n,s.shardKey,s.optimistic);s.optimisticUpdate&&this.applyOptimisticUpdate(s.optimisticUpdate,r,s.shardKey,u,a);let c=this.getConnection(s.shardKey),h=c?.wsState??"idle",d=c?.socket!==void 0,l=c?.wasEverConnected??!1,{queueBeforeFirstConnect:f}=this.offlineQueue,p=l||f,g=this.WebSocketImpl!==void 0&&p;if(h!=="open"&&!d&&g||h==="connecting"&&p)return this.enqueueOfflineMutation(e,n,s.shardKey,i,u,a);try{let b,E=await this.rpc(e.__lunoraRef,n,s.shardKey,{captureBookmark:!0,mutationId:i,onCommitCursor:o(A=>{b=A},"onCommitCursor")});for(let A of a)A(b);return E}catch(b){throw et(u),b}}async action(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey)}async shardTraffic(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=await this.adminFetch(Vr,"POST",{table:e});return{failed:r.failed??0,ok:r.ok??0,shards:r.shards??[]}}async listScheduledJobs(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(zr,"GET")).records??[]}async schedulerStatus(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let e=await this.adminFetch(Wr,"GET");return{backlog:e.backlog??0,inFlight:e.inFlight??0,pools:e.pools??[]}}async cancelScheduledJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{cancelled:(await this.adminFetch(Xr,"POST",{id:e})).cancelled===!0}}async listDeadJobs(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(Yr,"GET")).records??[]}async retryDeadJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{retried:(await this.adminFetch(Zr,"POST",{id:e})).retried===!0}}async removeDeadJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{removed:(await this.adminFetch(es,"POST",{id:e})).removed===!0}}async listWorkflowInstances(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({name:e.name});e.status!==void 0&&r.set("status",e.status),e.page!==void 0&&r.set("page",String(e.page)),e.perPage!==void 0&&r.set("perPage",String(e.perPage));let s=await this.adminFetch(`${ts}?${r.toString()}`,"GET");return{configured:s.configured,instances:s.instances??[],page:s.page??1,perPage:s.perPage??e.perPage??0,totalCount:s.totalCount}}async getWorkflowInstance(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({id:e.id,name:e.name}),s=await this.adminFetch(`${rs}?${r.toString()}`,"GET");return{createdOn:s.createdOn,endedOn:s.endedOn,error:s.error,id:s.id??e.id,output:s.output,params:s.params,startedOn:s.startedOn,status:s.status??"unknown",steps:s.steps??[]}}async setWorkflowInstanceStatus(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{status:(await this.adminFetch(ss,"POST",{action:e.action,id:e.id,name:e.name})).status??"unknown"}}subscribeScheduledJobs(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");if(this.WebSocketImpl===void 0)return()=>{};let r=G(nr(this.url),Jr),s=Je(this.reconnectOptions),n,i,a=!1,u=o(()=>{if(a||this.WebSocketImpl===void 0)return;let c=this.wsToken===void 0?r:`${r}?token=${encodeURIComponent(this.wsToken)}`;n=new this.WebSocketImpl(c),n.addEventListener("open",()=>{s.reset()}),n.addEventListener("message",h=>{try{let d=JSON.parse(typeof h.data=="string"?h.data:"");d.type==="jobs"&&Array.isArray(d.records)&&e(d.records)}catch{}}),n.addEventListener("close",()=>{n=void 0,a||(i=setTimeout(u,s.next()))}),n.addEventListener("error",()=>{})},"connect");return u(),()=>{a=!0,i!==void 0&&clearTimeout(i),n?.close()}}async listFunctions(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(os,"GET")).functions??[]}async getCronJobs(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(as,"GET")).jobs??[]}async runCronJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=await this.adminFetch(cs,"POST",{name:e});return{name:r.name??e,ran:r.ran===!0}}async fetchOpenApi(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.adminFetch(us,"GET")}async fetchOpenRpc(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.adminFetch(hs,"GET")}async listStorageObjects(e={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams;e.prefix!==void 0&&e.prefix!==""&&r.set("prefix",e.prefix),e.cursor!==void 0&&e.cursor!==""&&r.set("cursor",e.cursor),e.limit!==void 0&&r.set("limit",String(e.limit)),e.bucket!==void 0&&e.bucket!==""&&r.set("bucket",e.bucket);let s=r.toString(),n=s===""?Oe:`${Oe}?${s}`,i=await this.adminFetch(n,"GET");return{cursor:i.cursor,objects:i.objects??[]}}async deleteStorageObject(e,r){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let s=`${Oe}?key=${encodeURIComponent(e)}${Ze(r?.bucket)}`,n=await this.adminFetch(s,"DELETE");return{deleted:n.deleted??!0,key:n.key??e}}async listStorageBuckets(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(is,"GET")).buckets??[]}async uploadStorageObject(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=`${Oe}?key=${encodeURIComponent(e.key)}${Ze(e.bucket)}`,s=await this.adminFetch(r,"PUT",e.body,e.contentType);return{etag:s.etag,key:s.key??e.key}}async signedStorageUrl(e,r){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let s=r?.expiresInSeconds,n=s===void 0?"":`&expiresIn=${encodeURIComponent(s.toString())}`,i=`${ns}?key=${encodeURIComponent(e)}${n}${Ze(r?.bucket)}`,a=await this.adminFetch(i,"GET");if(typeof a.url!="string")throw new TypeError("LunoraClient: storage URL endpoint returned no `url`");return a.url}async listGlobalTables(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.adminFetch(ds,"GET")}async readGlobalTablePage(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${ls}?${r.toString()}`,"GET")}async facetGlobalColumn(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({column:e.column,table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${fs}?${r.toString()}`,"GET")}async listVectorIndexes(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(ms,"GET")).indexes??[]}async queryVectorIndex(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(ps,"POST",e)).matches??[]}async listKvNamespaces(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(ys,"GET")).namespaces??[]}async listKvKeys(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(gs,{cursor:e.cursor,limit:e.limit,namespace:e.namespace,prefix:e.prefix});return await this.adminFetch(r,"GET")}async getKvValue(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(tt,{key:e.key,namespace:e.namespace});return await this.adminFetch(r,"GET")}async putKvValue(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");await this.adminFetch(tt,"PUT",e)}async deleteKvKey(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(tt,{key:e.key,namespace:e.namespace});await this.adminFetch(r,"DELETE")}async listAuthUsers(e={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(vs,{filterField:e.filterField,filterValue:e.filterValue,limit:e.limit,offset:e.offset,search:e.search,searchField:e.searchField,sortBy:e.sortBy,sortDirection:e.sortDirection});return await this.adminFetch(r,"GET")}async createAuthUser(e){return await this.adminFetch(bs,"POST",e)}async setAuthUserRole(e){return await this.adminFetch(Ss,"POST",e)}async banAuthUser(e){return await this.adminFetch(ws,"POST",e)}async unbanAuthUser(e){return await this.adminFetch(Es,"POST",e)}async setAuthUserPassword(e){await this.adminFetch(Ts,"POST",e)}async removeAuthUser(e){await this.adminFetch(Cs,"POST",e)}async impersonateAuthUser(e){return await this.adminFetch(As,"POST",e)}async revokeAuthSession(e){await this.adminFetch(Is,"POST",e)}async revokeAuthUserSessions(e){await this.adminFetch(_s,"POST",e)}async getAuthCapabilities(){return await this.adminFetch(ks,"GET")}async updateAuthUser(e){return await this.adminFetch(Rs,"POST",e)}async listAuthAccounts(e){return await this.adminFetch(O(Os,{userId:e.userId}),"GET")}async unlinkAuthAccount(e){await this.adminFetch(Ps,"POST",e)}async listAuthPasskeys(e){return await this.adminFetch(O(xs,{userId:e.userId}),"GET")}async deleteAuthPasskey(e){await this.adminFetch(Ls,"POST",e)}async disableAuthTwoFactor(e){await this.adminFetch(Fs,"POST",e)}async listAuthOrganizations(e={}){return await this.adminFetch(O(Ms,{limit:e.limit,offset:e.offset}),"GET")}async listAuthOrgMembers(e){let r=O(Ns,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async listAuthOrgInvitations(e){let r=O(Ds,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async removeAuthOrgMember(e){await this.adminFetch(Us,"POST",e)}async cancelAuthOrgInvitation(e){await this.adminFetch(Qs,"POST",e)}async getAuthConfig(){return await this.adminFetch(Hs,"GET")}async createAuthOrganization(e){return await this.adminFetch(qs,"POST",e)}async updateAuthOrganization(e){return await this.adminFetch(Bs,"POST",e)}async deleteAuthOrganization(e){await this.adminFetch(js,"POST",e)}async addAuthOrgMember(e){return await this.adminFetch(Ks,"POST",e)}async inviteAuthOrgMember(e){return await this.adminFetch($s,"POST",e)}async setAuthOrgMemberRole(e){return await this.adminFetch(Gs,"POST",e)}async listAuthOrgTeams(e){let r=O(Vs,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgTeam(e){return await this.adminFetch(zs,"POST",e)}async updateAuthOrgTeam(e){return await this.adminFetch(Ws,"POST",e)}async removeAuthOrgTeam(e){await this.adminFetch(Js,"POST",e)}async listAuthOrgTeamMembers(e){let r=O(Xs,{limit:e.limit,offset:e.offset,teamId:e.teamId});return await this.adminFetch(r,"GET")}async addAuthOrgTeamMember(e){return await this.adminFetch(Ys,"POST",e)}async removeAuthOrgTeamMember(e){await this.adminFetch(Zs,"POST",e)}async listAuthOrgRoles(e){let r=O(en,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgRole(e){return await this.adminFetch(tn,"POST",e)}async updateAuthOrgRole(e){return await this.adminFetch(rn,"POST",e)}async deleteAuthOrgRole(e){await this.adminFetch(sn,"POST",e)}async listAuthSessions(e={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams;e.userId!==void 0&&e.userId!==""&&r.set("userId",e.userId),e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset));let s=r.toString();return await this.adminFetch(s===""?sr:`${sr}?${s}`,"GET")}subscribe(e,r,s,n={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let i=r??{},a=Y.key(e.__lunoraRef,i,n.shardKey),u=this.subscriptions.get(a),c=s,h=n.onError;if(!u){this.nextSubId+=1;let l=`sub_${this.nextSubId.toString()}`,f=X(i),p=this.takeHydratedCache(e.__lunoraRef,f,n.shardKey);u={acked:!1,args:i,argsKey:f,callbacks:new Set,checkpointCallbacks:new Set,errorCallbacks:new Set,fn:e,id:l,lastValue:p?.value,optimisticLayers:[],serverBase:p?.value,serverCursor:p?.serverCursor,shardKey:n.shardKey,...p?.serverEpoch===void 0?{}:{serverEpoch:p.serverEpoch}},this.subscriptions.add(u)}if(u.callbacks.add(c),h&&u.errorCallbacks.add(h),n.onCheckpoint&&u.checkpointCallbacks.add(n.onCheckpoint),u.lastValue!==void 0)try{c(u.lastValue)}catch{}this.ensureSocket(n.shardKey),this.sendSubscribeIfOpen(u);let d=u;return()=>{if(d.callbacks.delete(c),h&&d.errorCallbacks.delete(h),n.onCheckpoint&&d.checkpointCallbacks.delete(n.onCheckpoint),d.callbacks.size===0){let l=this.getConnection(d.shardKey);!(l&&_(l,{id:d.id,type:"unsubscribe"}))&&l&&l.pendingUnsubscribes.push({id:d.id,type:"unsubscribe"}),this.subscriptions.remove(d)}}}subscribeShape(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");this.nextShapeId+=1;let n=`shape_${this.nextShapeId.toString()}`,i={args:e.args,callbacks:new Set([r]),errorCallbacks:s.onError?new Set([s.onError]):new Set,id:n,name:e.name,onCheckpoint:s.onCheckpoint,rows:new Map,shardKey:s.shardKey};return this.shapeSubscriptions.set(n,i),this.ensureSocket(s.shardKey),this.sendShapeSubscribeIfOpen(i),()=>{this.shapeSubscriptions.delete(n);let a=this.getConnection(i.shardKey);!(a&&_(a,{id:n,type:"shape_unsubscribe"}))&&a&&a.pendingUnsubscribes.push({id:n,type:"shape_unsubscribe"})}}stream(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");if(this.WebSocketImpl===void 0)throw new m("INTERNAL","LunoraClient: streams require a WebSocket implementation");this.nextStreamId+=1;let n=`stream_${this.nextStreamId.toString()}`,{shardKey:i}=s,a=r??{},{handle:u,iterable:c}=Xt({maxBuffer:s.maxBuffer,onCancel:o(()=>{let f=this.getConnection(i);f&&_(f,{id:n,type:"unsubscribe"}),this.streams.delete(n)},"onCancel")});this.streams.set(n,{handle:u,shardKey:i}),this.ensureSocket(i);let h=this.getConnection(i),d={id:n,query:{args:ee(a,`stream args for '${e.__lunoraRef}'`),functionPath:e.__lunoraRef,shardKey:i},type:"stream"};if(!(h?.wsState==="open"&&_(h,d))&&h){for(h.pendingStreams=h.pendingStreams??[];h.pendingStreams.length>=Gr;){let p=h.pendingStreams.shift()?.id,g=p?this.streams.get(p):void 0;g&&(g.handle.fail(Object.assign(new Error("stream-start frame evicted while socket was unreachable"),{code:"STREAM_QUEUE_OVERFLOW"})),this.streams.delete(p))}h.pendingStreams.push(d)}return c}close(){this.closed=!0,this.outboxLeaderRelease?.(),this.outboxLeaderRelease=void 0;for(let e of this.streams.values())e.handle.fail(Object.assign(new Error("LunoraClient closed"),{code:"CLIENT_CLOSED"}));this.streams.clear();for(let e of this.connections.values()){if(e.reconnectTimer!==void 0&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=void 0),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),this.stopHeartbeat(e),e.socket){try{e.socket.close()}catch{}e.socket=void 0}e.wsState="closed"}this.offlineQueue.clear(),this.queuedIdentities.clear(),this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.size>0&&this.flushQueryCacheWrites().catch(()=>{}),this.authTokenListeners.clear(),this.statusListeners.clear(),this.tokenExpiredListeners.clear(),this.mutationSettledListeners.clear(),this.pendingChangeListeners.clear(),this.whisperHandlers.clear(),this.shapeSubscriptions.clear(),this.pokeBuffers.clear()}async enqueueOfflineMutation(e,r,s,n,i,a){let u=this.identityFingerprint();if(this.outbox){this.outboxMutationCounter+=1;let c=this.outboxMutationCounter;try{await this.outbox.enqueue({args:r,clientId:this.clientId,functionPath:e.__lunoraRef,idempotencyKey:`${this.clientId}:${String(c)}`,identity:u,mutationId:c,shardKey:s})}catch(h){throw et(i),h instanceof Error?h:new Error(String(h))}for(let h of a)h(void 0);return}return new Promise((c,h)=>{let d={args:r,functionPath:e.__lunoraRef,liveAwaiter:!0,id:n,identity:u,onCommit:o(l=>{for(let f of a)f(l)},"onCommit"),reject:o(l=>{this.queuedIdentities.delete(n),et(i),h(l instanceof Error?l:new Error(String(l)))},"reject"),resolve:c,shardKey:s};this.offlineQueue.enqueue(d),d.id!==void 0&&this.queuedIdentities.set(d.id,u)})}async hydratePersistedQueue(){try{let e=await this.offlineQueue.hydrate();for(let r of e)this.ensureSocket(r)}catch{}}hydrateAsOutboxLeader(){let e=o(()=>{this.hydratePersistedQueue().catch(()=>{})},"hydrate"),r=globalThis.navigator?.locks;if(!r){e();return}r.request(`lunora:outbox-leader:${this.url}`,()=>(this.closed||e(),new Promise(s=>{if(this.closed){s();return}this.outboxLeaderRelease=s}))).catch(e)}async hydrateQueryCache(){if(this.queryCache)try{let e=await this.queryCache.load();for(let{key:r,...s}of e){if(ze(this.persistenceVersion,s.version)){this.queryCache.remove(r).catch(()=>{});continue}this.hydratedQueryCache.set(r,s)}}catch{}}takeHydratedCache(e,r,s){let n=We(e,r,s),i=this.hydratedQueryCache.get(n);if(i!==void 0)return this.hydratedQueryCache.delete(n),i.identity===this.identityFingerprint()?i:void 0}persistQueryValue(e){let r=e.serverBase;if(!this.queryCache||r===void 0)return;let s=We(e.fn.__lunoraRef,e.argsKey,e.shardKey);this.pendingCacheWrites.set(s,{identity:this.identityFingerprint(),serverCursor:e.serverCursor,ts:Date.now(),value:r,...e.serverEpoch===void 0?{}:{serverEpoch:e.serverEpoch},...this.persistenceVersion===void 0?{}:{version:this.persistenceVersion}}),this.cacheFlushTimer??=setTimeout(()=>{this.flushQueryCacheWrites().catch(()=>{})},$r)}async flushQueryCacheWrites(){this.cacheFlushTimer=void 0;let{queryCache:e}=this;if(!e){this.pendingCacheWrites.clear();return}let r=[...this.pendingCacheWrites.entries()];this.pendingCacheWrites.clear(),await Promise.allSettled(r.map(([s,n])=>e.put(s,n)))}computeStatus(){let e=[...this.connections.values()];return e.length===0?"idle":e.some(r=>r.wsState==="open")?"connected":e.some(r=>r.wsState==="connecting")?"connecting":"offline"}emitConnectionStatus(){let e=this.computeStatus();e!==this.lastStatus&&(this.lastStatus=e,this.statusListeners.emit(e))}emitItemSettled(e,r,s){this.mutationSettledListeners.emit({args:e.args,code:s===void 0?void 0:s.code,error:s,functionPath:e.functionPath,hadAwaiter:e.liveAwaiter??!1,id:e.id??"",shardKey:e.shardKey,status:r})}applyOptimisticUpdates(e,r,s,n){let i=[],a=[];if(!n)return{confirms:i,rollbacks:a};let u=Y.key(e,r,s),c=this.subscriptions.get(u);if(c){let h=Ge(c,n);h&&(i.push(h.confirm),a.push(h.rollback))}return{confirms:i,rollbacks:a}}applyOptimisticUpdate(e,r,s,n,i){let{confirms:a,rollbacks:u,store:c}=$t(this.subscriptions,s,X);try{e(c,r)}catch{for(let h=u.length-1;h>=0;h-=1)u[h]?.();return}n.push(...u),i.push(...a)}getConnection(e){return this.connections.get(T(e))}getOrCreateConnection(e){let r=T(e),s=this.connections.get(r);return s||(s={connectTimer:void 0,heartbeatTimer:void 0,pendingUnsubscribes:[],reconnect:Je(this.reconnectOptions),reconnectTimer:void 0,shardKey:e,socket:void 0,wasEverConnected:!1,wsState:"idle"},this.connections.set(r,s)),s}wsUrlFor(e){let r=[];if(e!==void 0&&r.push(`shard=${encodeURIComponent(e)}`),this.wsToken!==void 0&&r.push(`token=${encodeURIComponent(this.wsToken)}`),r.length===0)return this.wsUrl;let s=this.wsUrl.includes("?")?"&":"?";return`${this.wsUrl}${s}${r.join("&")}`}rpcRequestHeaders(e){let r={"content-type":"application/json"};if(this.authToken&&(r.authorization=`Bearer ${this.authToken}`),e.mutationId&&(r["x-lunora-mutation-id"]=e.mutationId),e.clientId!==void 0&&(r["x-lunora-client-id"]=e.clientId),e.clientSeq!==void 0&&(r["x-lunora-client-seq"]=e.clientSeq.toString()),e.attachBookmark){let s=this.bookmark.get();s&&(r["x-d1-bookmark"]=s)}return r}async rpc(e,r,s,n={}){if(!this.fetchImpl)throw new m("INTERNAL","LunoraClient: no `fetch` implementation available");let i=this.rpcRequestHeaders(n),a=await this.fetchImpl(G(this.url,Qr),{body:JSON.stringify({args:ee(r,`args for '${e}'`),functionPath:e,shardKey:s}),headers:i,method:"POST"});if(n.captureBookmark){let c=a.headers.get("x-d1-bookmark");c&&this.bookmark.set(c)}let u;try{u=await a.json()}catch{let c=a.statusText?` ${a.statusText}`:"";throw new m("INTERNAL",`LunoraClient: response was not JSON (status ${a.status.toString()}${c})`)}if("error"in u)throw de(u.error);if(!a.ok){let c=a.statusText?` ${a.statusText}`:"";throw new m("INTERNAL",`LunoraClient: request failed (status ${a.status.toString()}${c})`)}return n.onMutationAck?.(u.lastMutationId),n.onCommitCursor?.(u.commitCursor),w(u.result)}async adminFetch(e,r,s,n){if(!this.fetchImpl)throw new m("INTERNAL","LunoraClient: no `fetch` implementation available");let i={};this.authToken&&(i.authorization=`Bearer ${this.authToken}`);let a=s instanceof ArrayBuffer||s instanceof Blob,u;s===void 0?u=void 0:a?(u=s,n!==void 0&&(i["content-type"]=n)):(u=JSON.stringify(s),i["content-type"]="application/json");let c=await this.fetchImpl(G(this.url,e),{body:u,headers:i,method:r}),h;try{h=await c.json()}catch{let d=c.statusText?` ${c.statusText}`:"";throw new m("INTERNAL",`LunoraClient: response was not JSON (status ${c.status.toString()}${d})`)}if(typeof h=="object"&&h!==null&&"error"in h){let d=h.error,l=new Error(d.message??"admin request failed");throw l.code=d.code,l}if(!c.ok){let d=c.statusText?` ${c.statusText}`:"";throw new m("INTERNAL",`LunoraClient: admin request failed (status ${c.status.toString()}${d})`)}return h}effectiveConnectionContext(e){let r=this.connectionContextHolders.get(e);return r&&r.length>0?r[r.length-1]?.context:this.connectionContexts.get(e)??this.defaultConnectionContext}refreshConnectionContext(e){let r=this.connections.get(e);r?.wsState==="open"&&this.sendConnectEnvelope(r)}sendConnectEnvelope(e){let r=this.effectiveConnectionContext(T(e.shardKey));_(e,{clientId:this.clientId,id:"connect",type:"connect",...r===void 0?{}:{context:r}})}resendShapeSubscriptions(e){for(let r of this.shapeSubscriptions.values())T(r.shardKey)===T(e)&&this.sendShapeSubscribeIfOpen(r)}ensureSocket(e){if(this.closed||this.WebSocketImpl===void 0)return;let r=this.getOrCreateConnection(e);if(r.wsState==="open"||r.wsState==="connecting")return;r.wsState="connecting",this.emitConnectionStatus();let s=new this.WebSocketImpl(this.wsUrlFor(e));r.socket=s,this.connectTimeoutMs>0&&(r.connectTimer=setTimeout(()=>{if(r.connectTimer=void 0,!(r.socket!==s||r.wsState!=="connecting")){try{s.close()}catch{}this.handleDisconnect(r)}},this.connectTimeoutMs)),s.addEventListener("open",()=>{if(r.socket!==s)return;r.connectTimer!==void 0&&(clearTimeout(r.connectTimer),r.connectTimer=void 0),r.wsState="open",r.wasEverConnected=!0,r.reconnect.reset(),this.emitConnectionStatus(),this.sendConnectEnvelope(r),this.markShardPendingAck(e);for(let i of this.subscriptions.all())T(i.shardKey)===T(e)&&this.sendSubscribeIfOpen(i);if(this.resendShapeSubscriptions(e),r.pendingUnsubscribes.length>0){let i=r.pendingUnsubscribes;r.pendingUnsubscribes=[];for(let{id:a,type:u}of i)_(r,{id:a,type:u})}if(r.pendingStreams&&r.pendingStreams.length>0){let i=r.pendingStreams;r.pendingStreams=[];for(let a of i)_(r,a)}let n=this.whisperHandlers.get(T(e));if(n)for(let i of n.keys())_(r,{topic:i,type:"whisper_subscribe"});this.flushOfflineQueue(e).catch(()=>{}),this.startHeartbeat(r)}),s.addEventListener("message",n=>{this.handleServerMessage(n.data,e)}),s.addEventListener("close",n=>{r.socket===s&&(n?.code===4001&&this.notifyTokenExpired(),this.handleDisconnect(r))}),s.addEventListener("error",()=>{r.socket===s&&(r.wsState==="connecting"||r.wsState==="open")&&this.handleDisconnect(r)})}handleDisconnect(e){if(this.closed||e.wsState==="idle"||e.wsState==="closed"||(this.stopHeartbeat(e),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.socket=void 0,e.wsState="idle",this.emitConnectionStatus(),this.markShardPendingAck(e.shardKey),this.WebSocketImpl===void 0))return;let r=e.reconnect.next();e.reconnectTimer=setTimeout(()=>{e.reconnectTimer=void 0,this.ensureSocket(e.shardKey)},r)}startHeartbeat(e){this.stopHeartbeat(e),!(this.heartbeatIntervalMs<=0)&&(e.heartbeatTimer=setInterval(()=>{if(!(e.wsState!=="open"||!e.socket))try{e.socket.send(Br)}catch{}},this.heartbeatIntervalMs))}stopHeartbeat(e){e.heartbeatTimer!==void 0&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=void 0)}markShardPendingAck(e){let r=T(e);for(let s of this.subscriptions.all())T(s.shardKey)===r&&(s.acked=!1)}sendSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);if(r?.wsState!=="open"||e.acked)return;let s=e.fn.__lunoraTable??e.fn.__lunoraRef;_(r,{id:e.id,query:{args:e.args,functionPath:e.fn.__lunoraRef,table:s,...e.serverCursor===void 0?{}:{sinceSeq:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}},type:"subscribe"})}sendShapeSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);r?.wsState==="open"&&_(r,{id:e.id,shape:{name:e.name,...e.args===void 0?{}:{args:e.args}},type:"shape_subscribe",...e.serverCursor===void 0?{}:{sinceCheckpoint:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}})}handleServerMessage(e,r){let s=un(e);if(s===void 0)return;let n;try{n=JSON.parse(s)}catch{return}switch(n.type){case"ack":{let i=this.subscriptions.getById(n.id);i&&(i.acked=!0);return}case"chunk":{let{data:i,id:a}=n;this.streams.get(a)?.handle.push(w(i));return}case"complete":{this.handleCompleteMessage(n.id);return}case"data":case"delta":{this.handleDataMessage(n);return}case"error":{this.handleErrorMessage(n);break}case"pokeEnd":{this.handlePokeEnd(n);break}case"pokePart":{this.handlePokePart(n);break}case"pokeStart":{this.handlePokeStart(n);break}case"resume":{this.handleResumeMessage(n);break}case"settled":{this.handleSettledMessage(n);break}case"whisper":{this.dispatchWhisper(n,r);break}}}handleErrorMessage(e){if(e.error?.code==="TOKEN_EXPIRED"){this.notifyTokenExpired();return}let{id:s}=e,n=s===void 0?void 0:this.streams.get(s);if(n&&s!==void 0){n.handle.fail(an(e)),this.streams.delete(s);return}let i=s===void 0?void 0:this.subscriptions.getById(s);if(i){or(i.errorCallbacks,ir(e));return}let a=s===void 0?void 0:this.shapeSubscriptions.get(s);a&&or(a.errorCallbacks,ir(e))}handlePokeStart(e){if(this.pokeBuffers.size>=t.MAX_POKE_BUFFERS){let r=this.pokeBuffers.keys().next().value;r!==void 0&&this.pokeBuffers.delete(r)}this.pokeBuffers.set(e.pokeId,{baseCheckpoint:e.baseCheckpoint,epoch:e.epoch,lastMutationId:new Map,parts:new Map})}handlePokePart(e){let r=this.pokeBuffers.get(e.pokeId);if(!r)return;let s=r.parts.get(e.shapeId)??[];for(let n of e.rowsPatch)s.push(n.value===void 0?n:{...n,value:w(n.value)});r.parts.set(e.shapeId,s),e.lastMutationId!==void 0&&r.lastMutationId.set(e.shapeId,e.lastMutationId)}handlePokeEnd(e){let r=this.pokeBuffers.get(e.pokeId);if(r){this.pokeBuffers.delete(e.pokeId);for(let[s,n]of r.parts){let i=this.shapeSubscriptions.get(s);if(!i)continue;let a=r.epoch!==void 0&&i.serverEpoch!==void 0&&r.epoch!==i.serverEpoch,u=r.baseCheckpoint!==void 0&&i.serverCursor!==void 0&&i.serverCursor!==r.baseCheckpoint;if(a||u){i.rows.clear(),i.serverCursor=void 0,i.serverEpoch=void 0,this.emitShapeRows(i),this.sendShapeSubscribeIfOpen(i);continue}qr(i.rows,n),e.checkpoint!==void 0&&(i.serverCursor=e.checkpoint),e.epoch!==void 0&&(i.serverEpoch=e.epoch);let c=r.lastMutationId.get(s);c!==void 0&&(i.lastMutationId=c),this.emitShapeRows(i),i.onCheckpoint?.({checkpoint:i.serverCursor,mutationId:i.lastMutationId})}}}emitShapeRows(e){let r=[...e.rows.values()];for(let s of e.callbacks)try{s(r)}catch{}}handleDataMessage(e){let{id:r}=e,s=r?this.subscriptions.getById(r):void 0;if(!s)return;let n=this.resolveDataPayload(e,s);s.serverBase=n,e.cursor!==void 0&&(s.serverCursor=e.cursor),e.epoch!==void 0&&(s.serverEpoch=e.epoch),this.persistQueryValue(s),Ve(s,s.serverCursor),ce(s,s.optimisticLayers.length===0?n:_e(n,s.optimisticLayers))}handleResumeMessage(e){let r=this.subscriptions.getById(e.id);r&&this.ackAndAdvanceCursor(r,e.cursor,e.epoch)}handleSettledMessage(e){let r=this.subscriptions.getById(e.id);if(r){this.ackAndAdvanceCursor(r,e.cursor,e.epoch),e.lastMutationId!==void 0&&(r.lastMutationId=e.lastMutationId);for(let s of r.checkpointCallbacks)s({checkpoint:r.serverCursor,mutationId:r.lastMutationId})}}ackAndAdvanceCursor(e,r,s){e.acked=!0,(r!==void 0&&r!==e.serverCursor||s!==void 0&&s!==e.serverEpoch)&&(r!==void 0&&(e.serverCursor=r),s!==void 0&&(e.serverEpoch=s),this.persistQueryValue(e),Ve(e,e.serverCursor)&&ce(e,_e(e.serverBase,e.optimisticLayers)))}resolveDataPayload(e,r){if("data"in e&&e.data!==void 0)return w(e.data);let s=w(e.delta);if(jt(s)&&r.serverBase!==void 0){let n=Kt(r.serverBase,s);if(n!==void 0)return n}return s}dispatchWhisper(e,r){let s=this.whisperHandlers.get(T(r))?.get(e.topic);if(!s)return;let n=w(e.data);for(let i of s)try{i(n,e.from)}catch{}}notifyTokenExpired(){this.tokenExpiredListeners.emit()}handleCompleteMessage(e){let r=this.streams.get(e);if(r){r.handle.complete(),this.streams.delete(e);return}let s=this.subscriptions.getById(e);s&&this.subscriptions.remove(s)}unpersist(e){e&&this.persistence?.remove(e).catch(r=>{Z(this.onPersistenceError,"remove",r,e)})}identityFingerprint(){if(this.authSubject!==void 0)return this.authSubject===null?null:`subj:${this.authSubject}`;let e=this.authToken;if(e===null)return null;let r=2166136261,s=5381;for(let n=0;n<e.length;n+=1){let i=e.charCodeAt(n);r^=i,r=Math.imul(r,16777619),s=Math.imul(s,33)+i}return`${e.length.toString(36)}:${(r>>>0).toString(36)}:${(s>>>0).toString(36)}`}rejectQueuedForIdentityChange(){let e=this.offlineQueue.drain();for(let r of e){this.queuedIdentities.delete(r.id??""),this.unpersist(r.id);let s=new Error("offline mutation discarded: auth identity changed before replay");s.code="OFFLINE_IDENTITY_CHANGED",r.reject(s),this.emitItemSettled(r,"rejected",s)}this.clearQueryCacheForIdentityChange()}restampQueuedIdentity(e,r){for(let[s,n]of this.queuedIdentities)n===e&&this.queuedIdentities.set(s,r)}clearQueryCacheForIdentityChange(){this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.clear(),this.hydratedQueryCache.clear(),this.queryCache?.clear().catch(()=>{})}async flushOfflineQueue(e){let r=T(e),s=this.offlineQueue.drain(c=>T(c.shardKey)===r);if(s.length===0)return;let n=this.identityFingerprint(),i=[];for(let c of s)this.passesReplayIdentityGate(c,n)&&i.push(c);if(i.length===0)return;let a=this.encodableOrSettleTerminal(i);if(a.length===0)return;if(a.length===1){await this.replaySequential(a);return}let u=[];for(let c=0;c<a.length;c+=Xe){let h=a.slice(c,c+Xe),d=await this.replayBatched(h);if(u.push(...d.requeue),d.stop){u.push(...a.slice(c+Xe));break}}u.length>0&&this.offlineQueue.requeue(u)}encodableOrSettleTerminal(e){let r=[];for(let s of e)try{ee(s.args,`args for '${s.functionPath}'`),r.push(s)}catch(n){this.settleReplayTerminal(s,n instanceof Error?n:new Error(String(n)))}return r}passesReplayIdentityGate(e,r){let s=e.id===void 0?void 0:this.queuedIdentities.get(e.id),n=s===void 0?e.identity:s;if(n!==void 0&&n!==r){this.queuedIdentities.delete(e.id??""),this.unpersist(e.id);let i=new Error("offline mutation skipped: auth identity changed before replay");return i.code="OFFLINE_IDENTITY_CHANGED",e.reject(i),this.emitItemSettled(e,"rejected",i),!1}return this.queuedIdentities.delete(e.id??""),!0}settleReplaySuccess(e,r,s){this.unpersist(e.id),e.onCommit?.(s),e.resolve(r),this.emitItemSettled(e,"committed")}settleReplayTerminal(e,r){this.unpersist(e.id),e.reject(r),this.emitItemSettled(e,"rejected",r)}async replaySequential(e){for(let r=0;r<e.length;r+=1){let s=e[r];if(s)try{let n,i=await this.rpc(s.functionPath,s.args,s.shardKey,{captureBookmark:!0,mutationId:s.id,onCommitCursor:o(a=>{n=a},"onCommitCursor")});this.settleReplaySuccess(s,i,n)}catch(n){if(n.code!==void 0){this.settleReplayTerminal(s,n);continue}this.offlineQueue.requeue(e.slice(r));return}}}async replayBatched(e){if(!this.fetchImpl)return{requeue:e,stop:!0};let r;try{r=await this.fetchImpl(G(this.url,rr),{body:JSON.stringify({calls:e.map((i,a)=>({args:ee(i.args,`args for '${i.functionPath}'`),functionPath:i.functionPath,id:a,mutationId:i.id,shardKey:i.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"})}catch{return{requeue:e,stop:!0}}let s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let n;try{n=await r.json()}catch{return{requeue:e,stop:!0}}if(!n.results){if(n.error){let i=de(n.error);for(let a of e)this.settleReplayTerminal(a,i);return{requeue:[],stop:!1}}return{requeue:e,stop:!0}}return{requeue:this.settleReplayBatchSlots(e,n.results),stop:!1}}settleReplayBatchSlots(e,r){let s=new Map;for(let i of r)typeof i.id=="number"&&i.body!==void 0&&s.set(i.id,i.body);let n=[];for(let[i,a]of e.entries()){let u=s.get(i);u===void 0?n.push(a):"error"in u?dn.has(u.error.code)?n.push(a):this.settleReplayTerminal(a,de(u.error)):this.settleReplaySuccess(a,w(u.result),u.commitCursor)}return n}};export{rt as a,lr as b,qe as c,Tr as d,Ar as e,$e as f,Ir as g};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{a as t}from"./chunk-RRCPZMC2.js";var a={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`],status:400,title:"Unique constraint violation"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{status:500,title:"Auth headers missing"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"}};var l=[{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
|
|
2
|
+
`),header:"No Lunora schema found",id:"lunora-schema-missing",test:t(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
|
|
3
|
+
`),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:t(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
|
|
4
|
+
`),header:"Table name is reserved",id:"lunora-table-reserved",test:t(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
|
|
5
|
+
`),header:"Duplicate table name",id:"lunora-table-duplicate",test:t(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
|
|
6
|
+
`),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:t(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
|
|
7
|
+
`),header:"`unique` must be a literal",id:"lunora-unique-literal",test:t(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
|
|
8
|
+
`),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:t(e=>e.includes("not exported by your worker entry"),"test")},{body:a.NOT_UNIQUE.hint.join(`
|
|
9
|
+
`),header:"Unique constraint violation",id:"lunora-runtime-unique",test:t(e=>e.includes("unique constraint violation on"),"test")},{body:a.CONFLICT.hint.join(`
|
|
10
|
+
`),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:t(e=>e.includes("optimistic concurrency conflict"),"test")}],d=t(e=>(Array.isArray(e)?e.join(`
|
|
11
|
+
`):e).split(`
|
|
12
|
+
`).filter(n=>!n.startsWith("```")).join(`
|
|
13
|
+
`).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"flattenHint");var o=class extends Error{static{t(this,"LunoraError")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(n,s,i={}){let r=a[n];super(s??n,{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??r?.hint,this.title=i.title??r?.title,this.loc=i.location,this.code=n,this.status=i.status??r?.status??500,this.docsUrl=i.docsUrl??r?.docsUrl,this.data=i.data}};export{d as a,o as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i,e as n,f,g as b,h as p,j as d}from"./chunk-RRCPZMC2.js";var c=n(b(),1),m=n(f(),1);var r=n(p(),1);function h(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,r.jsxDEV)("table",{"data-slot":"table",className:a,...l},void 0,!1)},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(h,"Table");function x(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("thead",{"data-slot":"table-header",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(x,"TableHeader");function N(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("tbody",{"data-slot":"table-body",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(N,"TableBody");function v(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("tr",{"data-slot":"table-row",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(v,"TableRow");function w(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("th",{"data-slot":"table-head",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(w,"TableHead");function g(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("td",{"data-slot":"table-cell",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(g,"TableCell");export{h as a,x as b,N as c,v as d,w as e,g as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as U}from"./chunk-J6J54MBP.js";import{a as G}from"./chunk-YBGC4PPD.js";import{a as W,b as H,c as K,d as F,e as p,f as x}from"./chunk-GTM65MVX.js";import{c as te}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{a as R}from"./chunk-TAD43CG5.js";import{a as Q}from"./chunk-C7WTJLC3.js";import{a as A,e as D}from"./chunk-SEU5V7I6.js";import{b as ee}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as P}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as q,g as Y,k as V,o as j}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as f,e as M,f as oe,g as se,h as re}from"./chunk-RRCPZMC2.js";var Z=M(se(),1),z=M(oe(),1);var t=M(re(),1);var ae=M(se(),1);var X=M(oe(),1);var u=M(re(),1);var ce=f(s=>Number.isFinite(s)?j(s,"\u2014"):"\u2014","formatScheduledFor"),ie=f(s=>s.toSorted((e,c)=>e.scheduledFor-c.scheduledFor),"sortByDue"),de=f(s=>{let e=(0,ae.c)(33),c;e[0]!==s?(c=s===void 0?{}:s,e[0]=s,e[1]=c):c=e[1];let{cancelJob:n,loadJobs:m}=c,r=P(),o=q(),l=m===void 0,k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=["lunora-scheduled-jobs"],e[2]=k):k=e[2];let v;e[3]!==r||e[4]!==m?(v=f(async()=>{let d=await(m??(()=>r.listScheduledJobs()))();return ie(d)},"t3"),e[3]=r,e[4]=m,e[5]=v):v=e[5];let a=Q(k,v),[i,h]=(0,X.useState)(void 0),[S,C]=(0,X.useState)(void 0),g,T;e[6]!==r||e[7]!==l?(g=f(()=>{if(l)return r.subscribeScheduledJobs(d=>{C(void 0),h(ie(d))})},"t4"),T=[l,r],e[6]=r,e[7]=l,e[8]=g,e[9]=T):(g=e[8],T=e[9]),(0,X.useEffect)(g,T);let b;e[10]!==a?(b=f(()=>{a.refetch()},"t6"),e[10]=a,e[11]=b):b=e[11],U(b,!l);let J;e:{if(n!==void 0){J=n;break e}let d;e[12]!==r||e[13]!==m?(d=m===void 0?O=>r.cancelScheduledJob(O):void 0,e[12]=r,e[13]=m,e[14]=d):d=e[14],J=d}let y=J,w=i??a.data,$=S??a.error,I;e[15]!==y||e[16]!==a||e[17]!==l?(I=f(async d=>{if(y!==void 0){C(void 0);try{await y(d),l||a.refetch()}catch(O){C(Y(O))}}},"t8"),e[15]=y,e[16]=a,e[17]=l,e[18]=I):I=e[18];let E=I,L;e[19]!==$?(L=$!==null&&(0,u.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:$},void 0,!1),e[19]=$,e[20]=L):L=e[20];let N;e[21]!==w?.length||e[22]!==o?(N=w?.length===0&&(0,u.jsxDEV)(R,{description:o("Jobs queued with runAfter / runAt will appear here."),icon:(0,u.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,u.jsxDEV)("circle",{cx:"12",cy:"12",r:"9"},void 0,!1),(0,u.jsxDEV)("path",{d:"M12 7.5V12l4 2"},void 0,!1)]},void 0,!0),testId:"sj-empty",title:o("No scheduled jobs.")},void 0,!1),e[21]=w?.length,e[22]=o,e[23]=N):N=e[23];let B;e[24]!==E||e[25]!==y||e[26]!==w||e[27]!==o?(B=w!==void 0&&w.length>0&&(0,u.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,u.jsxDEV)(D,{className:"px-0",children:(0,u.jsxDEV)(W,{"data-testid":"sj-table",children:[(0,u.jsxDEV)(H,{children:(0,u.jsxDEV)(F,{children:[(0,u.jsxDEV)(p,{children:o("function")},void 0,!1),(0,u.jsxDEV)(p,{children:o("scheduled for")},void 0,!1),(0,u.jsxDEV)(p,{children:o("pool")},void 0,!1),(0,u.jsxDEV)(p,{children:o("attempts")},void 0,!1),(0,u.jsxDEV)(p,{children:o("shard")},void 0,!1),(0,u.jsxDEV)(p,{children:o("id")},void 0,!1),y!==void 0&&(0,u.jsxDEV)(p,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,u.jsxDEV)(K,{children:w.map(d=>(0,u.jsxDEV)(F,{"data-testid":`sj-row-${d.id}`,children:[(0,u.jsxDEV)(x,{className:"font-mono text-xs",children:d.functionPath},void 0,!1),(0,u.jsxDEV)(x,{className:"text-muted-foreground tabular-nums",children:ce(d.scheduledFor)},void 0,!1),(0,u.jsxDEV)(x,{className:"font-mono text-xs",children:d.pool??""},void 0,!1),(0,u.jsxDEV)(x,{className:"tabular-nums",children:d.attempts??0},void 0,!1),(0,u.jsxDEV)(x,{children:d.shardKey??""},void 0,!1),(0,u.jsxDEV)(x,{className:"font-mono text-xs",children:d.id},void 0,!1),y!==void 0&&(0,u.jsxDEV)(x,{className:"text-right",children:(0,u.jsxDEV)(G,{confirmLabel:o("Cancel job?"),onConfirm:f(()=>{V(E(d.id))},"onConfirm"),testId:`sj-cancel-${d.id}`,children:o("Cancel")},void 0,!1)},void 0,!1)]},d.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[24]=E,e[25]=y,e[26]=w,e[27]=o,e[28]=B):B=e[28];let _;return e[29]!==N||e[30]!==B||e[31]!==L?(_=(0,u.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduled-jobs",children:[L,N,B]},void 0,!0),e[29]=N,e[30]=B,e[31]=L,e[32]=_):_=e[32],_},"ScheduledJobs");var fe={kind:"idle"},ue=f(({loadCronJobs:s,runCronJob:e}={})=>{let c=P(),n=q(),[m,r]=(0,z.useState)({}),o=Q(["lunora-cron-jobs",s?"custom":"default"],()=>(s??(()=>c.getCronJobs()))()),{data:l,error:k}=o,v=(0,z.useMemo)(()=>e!==void 0?e:s===void 0?i=>c.runCronJob(i):void 0,[c,s,e]),a=f(async i=>{if(v!==void 0){r(h=>({...h,[i]:{kind:"running"}}));try{await v(i),r(h=>({...h,[i]:{kind:"ok"}})),o.refetch()}catch(h){r(S=>({...S,[i]:{kind:"error",message:Y(h)}}))}}},"run");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[k!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:k},void 0,!1),l?.length===0&&(0,t.jsxDEV)(R,{description:n("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsxDEV)("circle",{cx:"12",cy:"12",r:"9"},void 0,!1),(0,t.jsxDEV)("path",{d:"M12 7.5V12l4 2"},void 0,!1)]},void 0,!0),testId:"cron-empty",title:n("No cron triggers.")},void 0,!1),l!==void 0&&l.length>0&&(0,t.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(D,{className:"px-0",children:(0,t.jsxDEV)(W,{"data-testid":"cron-table",children:[(0,t.jsxDEV)(H,{children:(0,t.jsxDEV)(F,{children:[(0,t.jsxDEV)(p,{children:n("name")},void 0,!1),(0,t.jsxDEV)(p,{children:n("schedule")},void 0,!1),(0,t.jsxDEV)(p,{children:n("target")},void 0,!1),(0,t.jsxDEV)(p,{children:n("shard")},void 0,!1),v!==void 0&&(0,t.jsxDEV)(p,{"aria-label":n("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(K,{children:l.map(i=>{let h=m[i.name]??fe;return(0,t.jsxDEV)(F,{"data-testid":`cron-row-${i.name}`,children:[(0,t.jsxDEV)(x,{children:i.name},void 0,!1),(0,t.jsxDEV)(x,{className:"font-mono text-xs tabular-nums",children:i.cron},void 0,!1),(0,t.jsxDEV)(x,{children:(0,t.jsxDEV)("span",{className:"flex items-center gap-2",children:[i.workflow===void 0?(0,t.jsxDEV)(ee,{variant:"outline",children:n("function")},void 0,!1):(0,t.jsxDEV)(ee,{variant:"secondary",children:n("workflow")},void 0,!1),(0,t.jsxDEV)("span",{className:"font-mono text-xs",children:i.workflow??i.functionPath},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(x,{children:i.shardKey??""},void 0,!1),v!==void 0&&(0,t.jsxDEV)(x,{className:"text-right",children:(0,t.jsxDEV)("span",{className:"flex items-center justify-end gap-2",children:[h.kind==="ok"&&(0,t.jsxDEV)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${i.name}`,children:n("ran")},void 0,!1),h.kind==="error"&&(0,t.jsxDEV)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${i.name}`,role:"alert",children:h.message},void 0,!1),(0,t.jsxDEV)(G,{confirmLabel:n("Run now?"),disabled:h.kind==="running",onConfirm:f(()=>{V(a(i.name))},"onConfirm"),testId:`cron-run-${i.name}`,children:h.kind==="running"?n("Running\u2026"):n("Run now")},void 0,!1)]},void 0,!0)},void 0,!1)]},`${i.cron}:${i.name}`,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"CronTriggersPanel"),he=f(s=>Number.isFinite(s)?j(s,"\u2014"):"\u2014","formatScheduledFor"),ve=f(s=>{let e=(0,Z.c)(34),c;e[0]!==s?(c=s===void 0?{}:s,e[0]=s,e[1]=c):c=e[1];let{loadJobs:n,removeJob:m,retryJob:r}=c,o=P(),l=q(),k;e[2]===Symbol.for("react.memo_cache_sentinel")?(k=["lunora-dead-jobs"],e[2]=k):k=e[2];let v;e[3]!==o||e[4]!==n?(v=f(async()=>(await(n??(()=>o.listDeadJobs()))()).toSorted(me),"t3"),e[3]=o,e[4]=n,e[5]=v):v=e[5];let a=Q(k,v),i=a.data,[h,S]=(0,z.useState)(void 0),C=a.error??h,g=n===void 0,T;e[6]!==o||e[7]!==g||e[8]!==r?(T=r??(g?d=>o.retryDeadJob(d):void 0),e[6]=o,e[7]=g,e[8]=r,e[9]=T):T=e[9];let b=T,J;e[10]!==o||e[11]!==g||e[12]!==m?(J=m??(g?d=>o.removeDeadJob(d):void 0),e[10]=o,e[11]=g,e[12]=m,e[13]=J):J=e[13];let y=J,w;e[14]!==a?(w=f(()=>{a.refetch()},"t6"),e[14]=a,e[15]=w):w=e[15],U(w,!0);let $;e[16]!==a?($=f(async d=>{S(void 0);try{await d,a.refetch()}catch(O){S(Y(O))}},"t7"),e[16]=a,e[17]=$):$=e[17];let I=$,E=b!==void 0||y!==void 0,L;e[18]!==C?(L=C!==void 0&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:C},void 0,!1),e[18]=C,e[19]=L):L=e[19];let N;e[20]!==i?.length||e[21]!==l?(N=i?.length===0&&(0,t.jsxDEV)(R,{description:l("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"},void 0,!1)},void 0,!1),testId:"dlq-empty",title:l("No dead-letter jobs.")},void 0,!1),e[20]=i?.length,e[21]=l,e[22]=N):N=e[22];let B;e[23]!==I||e[24]!==E||e[25]!==i||e[26]!==y||e[27]!==b||e[28]!==l?(B=i!==void 0&&i.length>0&&(0,t.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(D,{className:"px-0",children:(0,t.jsxDEV)(W,{"data-testid":"dlq-table",children:[(0,t.jsxDEV)(H,{children:(0,t.jsxDEV)(F,{children:[(0,t.jsxDEV)(p,{children:l("function")},void 0,!1),(0,t.jsxDEV)(p,{children:l("attempts")},void 0,!1),(0,t.jsxDEV)(p,{children:l("last tried")},void 0,!1),(0,t.jsxDEV)(p,{children:l("pool")},void 0,!1),(0,t.jsxDEV)(p,{children:l("shard")},void 0,!1),(0,t.jsxDEV)(p,{children:l("id")},void 0,!1),E&&(0,t.jsxDEV)(p,{"aria-label":l("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(K,{children:i.map(d=>(0,t.jsxDEV)(F,{"data-testid":`dlq-row-${d.id}`,children:[(0,t.jsxDEV)(x,{className:"font-mono text-xs",children:d.functionPath},void 0,!1),(0,t.jsxDEV)(x,{className:"tabular-nums",children:d.attempts??0},void 0,!1),(0,t.jsxDEV)(x,{className:"text-muted-foreground tabular-nums",children:he(d.scheduledFor)},void 0,!1),(0,t.jsxDEV)(x,{className:"font-mono text-xs",children:d.pool??""},void 0,!1),(0,t.jsxDEV)(x,{children:d.shardKey??""},void 0,!1),(0,t.jsxDEV)(x,{className:"font-mono text-xs",children:d.id},void 0,!1),E&&(0,t.jsxDEV)(x,{className:"text-right",children:(0,t.jsxDEV)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsxDEV)(te,{"data-testid":`dlq-retry-${d.id}`,onClick:f(()=>{V(I(b(d.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:l("Retry")},void 0,!1),y!==void 0&&(0,t.jsxDEV)(G,{confirmLabel:l("Drop job?"),onConfirm:f(()=>{V(I(y(d.id)))},"onConfirm"),testId:`dlq-remove-${d.id}`,children:l("Drop")},void 0,!1)]},void 0,!0)},void 0,!1)]},d.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[23]=I,e[24]=E,e[25]=i,e[26]=y,e[27]=b,e[28]=l,e[29]=B):B=e[29];let _;return e[30]!==B||e[31]!==L||e[32]!==N?(_=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[L,N,B]},void 0,!0),e[30]=B,e[31]=L,e[32]=N,e[33]=_):_=e[33],_},"DeadLetterJobs");function me(s,e){return(e.attempts??0)-(s.attempts??0)}f(me,"_temp$1");var le=f(s=>{let e=(0,Z.c)(8),{label:c,testId:n,value:m}=s,r;e[0]!==c?(r=(0,t.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:c},void 0,!1),e[0]=c,e[1]=r):r=e[1];let o;e[2]!==n||e[3]!==m?(o=(0,t.jsxDEV)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":n,children:m},void 0,!1),e[2]=n,e[3]=m,e[4]=o):o=e[4];let l;return e[5]!==r||e[6]!==o?(l=(0,t.jsxDEV)(A,{className:"flex-1 py-0",children:(0,t.jsxDEV)(D,{className:"flex flex-col gap-1 p-4",children:[r,o]},void 0,!0)},void 0,!1),e[5]=r,e[6]=o,e[7]=l):l=e[7],l},"StatTile"),pe=f(s=>{let e=(0,Z.c)(25),c;e[0]!==s?(c=s===void 0?{}:s,e[0]=s,e[1]=c):c=e[1];let{loadStatus:n}=c,m=P(),r=q(),o=n===void 0,l;e[2]!==o?(l=["lunora-scheduler-status",o],e[2]=o,e[3]=l):l=e[3];let k;e[4]!==m||e[5]!==n?(k=f(async()=>{let J=await(n??(()=>m.schedulerStatus()))();return{...J,pools:J.pools.toSorted(xe)}},"t4"),e[4]=m,e[5]=n,e[6]=k):k=e[6];let v=Q(l,k),{data:a,error:i}=v,h;e[7]!==v?(h=f(()=>{v.refetch()},"t5"),e[7]=v,e[8]=h):h=e[8],U(h,!0);let S;e[9]!==i?(S=i!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:i},void 0,!1),e[9]=i,e[10]=S):S=e[10];let C;e[11]!==a||e[12]!==r?(C=a!==void 0&&(0,t.jsxDEV)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsxDEV)(le,{label:r("backlog"),testId:"pools-backlog",value:a.backlog},void 0,!1),(0,t.jsxDEV)(le,{label:r("in flight"),testId:"pools-inflight",value:a.inFlight},void 0,!1),(0,t.jsxDEV)(le,{label:r("pools"),testId:"pools-count",value:a.pools.length},void 0,!1)]},void 0,!0),e[11]=a,e[12]=r,e[13]=C):C=e[13];let g;e[14]!==a?.pools.length||e[15]!==r?(g=a?.pools.length===0&&(0,t.jsxDEV)(R,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M4 7h16M4 12h16M4 17h16"},void 0,!1)},void 0,!1),testId:"pools-empty",title:r("No workpools.")},void 0,!1),e[14]=a?.pools.length,e[15]=r,e[16]=g):g=e[16];let T;e[17]!==a||e[18]!==r?(T=a!==void 0&&a.pools.length>0&&(0,t.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(D,{className:"px-0",children:(0,t.jsxDEV)(W,{"data-testid":"pools-table",children:[(0,t.jsxDEV)(H,{children:(0,t.jsxDEV)(F,{children:[(0,t.jsxDEV)(p,{children:r("pool")},void 0,!1),(0,t.jsxDEV)(p,{children:r("queued")},void 0,!1),(0,t.jsxDEV)(p,{children:r("in flight")},void 0,!1),(0,t.jsxDEV)(p,{children:r("max concurrency")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(K,{children:a.pools.map(ge)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[17]=a,e[18]=r,e[19]=T):T=e[19];let b;return e[20]!==S||e[21]!==C||e[22]!==g||e[23]!==T?(b=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[S,C,g,T]},void 0,!0),e[20]=S,e[21]=C,e[22]=g,e[23]=T,e[24]=b):b=e[24],b},"SchedulerPoolsPanel");function xe(s,e){return e.queued-s.queued}f(xe,"_temp");function ge(s){return(0,t.jsxDEV)(F,{"data-testid":`pools-row-${s.name}`,children:[(0,t.jsxDEV)(x,{className:"font-mono text-xs",children:s.name},void 0,!1),(0,t.jsxDEV)(x,{className:"tabular-nums",children:s.queued},void 0,!1),(0,t.jsxDEV)(x,{className:"tabular-nums",children:[s.inFlight," / ",s.maxConcurrency]},void 0,!0),(0,t.jsxDEV)(x,{className:"tabular-nums",children:s.maxConcurrency},void 0,!1)]},s.name,!0)}f(ge,"_temp2");var be=["jobs","dead","pools","cron"],We=f(s=>{let e=(0,Z.c)(41),c;e[0]!==s?(c=s===void 0?{}:s,e[0]=s,e[1]=c):c=e[1];let{loadCronJobs:n,scheduledCancel:m,scheduledLoad:r}=c,o=q(),[l,k]=(0,z.useState)("jobs"),v;e[2]!==o?(v=o("Cron triggers"),e[2]=o,e[3]=v):v=e[3];let a;e[4]!==o?(a=o("Dead letter"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==o?(i=o("Scheduled jobs"),e[6]=o,e[7]=i):i=e[7];let h;e[8]!==o?(h=o("Pools"),e[8]=o,e[9]=h):h=e[9];let S;e[10]!==v||e[11]!==a||e[12]!==i||e[13]!==h?(S={cron:v,dead:a,jobs:i,pools:h},e[10]=v,e[11]=a,e[12]=i,e[13]=h,e[14]=S):S=e[14];let C=S,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=f(N=>{k(N.currentTarget.dataset.view)},"t7"),e[15]=g):g=e[15];let T=g,b;e[16]!==o?(b=o("Schedule view"),e[16]=o,e[17]=b):b=e[17];let J;e[18]!==l||e[19]!==C?(J=be.map(N=>(0,t.jsxDEV)(te,{"aria-selected":l===N,"data-testid":`schedule-view-${N}`,"data-view":N,onClick:T,role:"tab",size:"sm",type:"button",variant:l===N?"default":"outline",children:C[N]},N,!1)),e[18]=l,e[19]=C,e[20]=J):J=e[20];let y;e[21]!==b||e[22]!==J?(y=(0,t.jsxDEV)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:J},void 0,!1),e[21]=b,e[22]=J,e[23]=y):y=e[23];let w;e[24]!==m||e[25]!==r||e[26]!==l?(w=l==="jobs"&&(0,t.jsxDEV)(de,{cancelJob:m,loadJobs:r},void 0,!1),e[24]=m,e[25]=r,e[26]=l,e[27]=w):w=e[27];let $;e[28]!==l?($=l==="dead"&&(0,t.jsxDEV)(ve,{},void 0,!1),e[28]=l,e[29]=$):$=e[29];let I;e[30]!==l?(I=l==="pools"&&(0,t.jsxDEV)(pe,{},void 0,!1),e[30]=l,e[31]=I):I=e[31];let E;e[32]!==n||e[33]!==l?(E=l==="cron"&&(0,t.jsxDEV)(ue,{loadCronJobs:n},void 0,!1),e[32]=n,e[33]=l,e[34]=E):E=e[34];let L;return e[35]!==y||e[36]!==w||e[37]!==$||e[38]!==I||e[39]!==E?(L=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[y,w,$,I,E]},void 0,!0),e[35]=y,e[36]=w,e[37]=$,e[38]=I,e[39]=E,e[40]=L):L=e[40],L},"SchedulePanel");export{We as SchedulePanel};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as s,c as m,f as S}from"./chunk-RRCPZMC2.js";var O=m(o=>{"use strict";(function(){function c(){}s(c,"noop");function y(t){return""+t}s(y,"testStringCoercion");function _(t,e,r){var a=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;try{y(a);var l=!1}catch{l=!0}return l&&(console.error("The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object"),y(a)),{$$typeof:E,key:a==null?null:""+a,children:t,containerInfo:e,implementation:r}}s(_,"createPortal$1");function d(t,e){if(t==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}s(d,"getCrossOriginStringAs");function i(t){return t===null?"`null`":t===void 0?"`undefined`":t===""?"an empty string":'something with type "'+typeof t+'"'}s(i,"getValueDescriptorExpectingObjectForWarning");function u(t){return t===null?"`null`":t===void 0?"`undefined`":t===""?"an empty string":typeof t=="string"?JSON.stringify(t):typeof t=="number"?"`"+t+"`":'something with type "'+typeof t+'"'}s(u,"getValueDescriptorExpectingEnumForWarning");function p(){var t=f.H;return t===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
2
|
+
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
3
|
+
2. You might be breaking the Rules of Hooks
|
|
4
|
+
3. You might have more than one copy of React in the same app
|
|
5
|
+
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),t}s(p,"resolveDispatcher"),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var v=S(),n={d:{f:c,r:s(function(){throw Error("Invalid form element. requestFormReset must be passed a form that was rendered by React.")},"r"),D:c,C:c,L:c,m:c,X:c,S:c,M:c},p:0,findDOMNode:null},E=Symbol.for("react.portal"),f=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;typeof Map=="function"&&Map.prototype!=null&&typeof Map.prototype.forEach=="function"&&typeof Set=="function"&&Set.prototype!=null&&typeof Set.prototype.clear=="function"&&typeof Set.prototype.forEach=="function"||console.error("React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,o.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error("Target container is not a DOM element.");return _(t,e,null,r)},o.flushSync=function(t){var e=f.T,r=n.p;try{if(f.T=null,n.p=2,t)return t()}finally{f.T=e,n.p=r,n.d.f()&&console.error("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.")}},o.preconnect=function(t,e){typeof t=="string"&&t?e!=null&&typeof e!="object"?console.error("ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.",u(e)):e!=null&&typeof e.crossOrigin!="string"&&console.error("ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",i(e.crossOrigin)):console.error("ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",i(t)),typeof t=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,n.d.C(t,e))},o.prefetchDNS=function(t){if(typeof t!="string"||!t)console.error("ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",i(t));else if(1<arguments.length){var e=arguments[1];typeof e=="object"&&e.hasOwnProperty("crossOrigin")?console.error("ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",u(e)):console.error("ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",u(e))}typeof t=="string"&&n.d.D(t)},o.preinit=function(t,e){if(typeof t=="string"&&t?e==null||typeof e!="object"?console.error("ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.",u(e)):e.as!=="style"&&e.as!=="script"&&console.error('ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',u(e.as)):console.error("ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",i(t)),typeof t=="string"&&e&&typeof e.as=="string"){var r=e.as,a=d(r,e.crossOrigin),l=typeof e.integrity=="string"?e.integrity:void 0,g=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;r==="style"?n.d.S(t,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:a,integrity:l,fetchPriority:g}):r==="script"&&n.d.X(t,{crossOrigin:a,integrity:l,fetchPriority:g,nonce:typeof e.nonce=="string"?e.nonce:void 0})}},o.preinitModule=function(t,e){var r="";typeof t=="string"&&t||(r+=" The `href` argument encountered was "+i(t)+"."),e!==void 0&&typeof e!="object"?r+=" The `options` argument encountered was "+i(e)+".":e&&"as"in e&&e.as!=="script"&&(r+=" The `as` option encountered was "+u(e.as)+"."),r?console.error("ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s",r):(r=e&&typeof e.as=="string"?e.as:"script",r)==="script"||(r=u(r),console.error('ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script" but received "%s" instead. This warning was generated for `href` "%s". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)',r,t)),typeof t=="string"&&(typeof e=="object"&&e!==null?(e.as==null||e.as==="script")&&(r=d(e.as,e.crossOrigin),n.d.M(t,{crossOrigin:r,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})):e==null&&n.d.M(t))},o.preload=function(t,e){var r="";if(typeof t=="string"&&t||(r+=" The `href` argument encountered was "+i(t)+"."),e==null||typeof e!="object"?r+=" The `options` argument encountered was "+i(e)+".":typeof e.as=="string"&&e.as||(r+=" The `as` option encountered was "+i(e.as)+"."),r&&console.error('ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s',r),typeof t=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){r=e.as;var a=d(r,e.crossOrigin);n.d.L(t,r,{crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}},o.preloadModule=function(t,e){var r="";typeof t=="string"&&t||(r+=" The `href` argument encountered was "+i(t)+"."),e!==void 0&&typeof e!="object"?r+=" The `options` argument encountered was "+i(e)+".":e&&"as"in e&&typeof e.as!="string"&&(r+=" The `as` option encountered was "+i(e.as)+"."),r&&console.error('ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s',r),typeof t=="string"&&(e?(r=d(e.as,e.crossOrigin),n.d.m(t,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:r,integrity:typeof e.integrity=="string"?e.integrity:void 0})):n.d.m(t))},o.requestFormReset=function(t){n.d.r(t)},o.unstable_batchedUpdates=function(t,e){return t(e)},o.useFormState=function(t,e,r){return p().useFormState(t,e,r)},o.useFormStatus=function(){return p().useHostTransitionStatus()},o.version="19.2.7",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var b=m((R,h)=>{"use strict";h.exports=O()});export{b as a};
|