@powerhousedao/connect 4.0.3 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/assets/{AddDriveModal.Dvx49ymn.js → AddDriveModal.CWoBv_48.js} +2 -2
  2. package/dist/assets/{AddDriveModal.Dvx49ymn.js.map → AddDriveModal.CWoBv_48.js.map} +1 -1
  3. package/dist/assets/{CreateDocumentModal.HxsTTO3O.js → CreateDocumentModal.DL-HobBg.js} +2 -2
  4. package/dist/assets/{CreateDocumentModal.HxsTTO3O.js.map → CreateDocumentModal.DL-HobBg.js.map} +1 -1
  5. package/dist/assets/{DebugSettingsModal.FcsYdItm.js → DebugSettingsModal.DxIXmwiM.js} +2 -2
  6. package/dist/assets/{DebugSettingsModal.FcsYdItm.js.map → DebugSettingsModal.DxIXmwiM.js.map} +1 -1
  7. package/dist/assets/{SettingsModal.DNuw8Ol8.js → SettingsModal.CDMLwaCk.js} +2 -2
  8. package/dist/assets/{SettingsModal.DNuw8Ol8.js.map → SettingsModal.CDMLwaCk.js.map} +1 -1
  9. package/dist/assets/{app.4_SWVXbR.js → app.BtXNojPV.js} +4 -4
  10. package/dist/assets/{app.4_SWVXbR.js.map → app.BtXNojPV.js.map} +1 -1
  11. package/dist/assets/{atlas-import.BcpRC7pw.js → atlas-import.KxjJCNA4.js} +2 -2
  12. package/dist/assets/{atlas-import.BcpRC7pw.js.map → atlas-import.KxjJCNA4.js.map} +1 -1
  13. package/dist/assets/{connect.config.DUXg7xh4.js → connect.config.DFiOOfbL.js} +2 -2
  14. package/dist/assets/{connect.config.DUXg7xh4.js.map → connect.config.DFiOOfbL.js.map} +1 -1
  15. package/dist/assets/{content.CdBQrvpu.js → content.DgV6Mq0-.js} +2 -2
  16. package/dist/assets/{content.CdBQrvpu.js.map → content.DgV6Mq0-.js.map} +1 -1
  17. package/dist/assets/{cookie-banner.CFaAyloc.js → cookie-banner.B_XhP7he.js} +2 -2
  18. package/dist/assets/{cookie-banner.CFaAyloc.js.map → cookie-banner.B_XhP7he.js.map} +1 -1
  19. package/dist/assets/{home.Dms1SdKb.js → home.C_U1tfub.js} +2 -2
  20. package/dist/assets/{home.Dms1SdKb.js.map → home.C_U1tfub.js.map} +1 -1
  21. package/dist/assets/{index.B0EhmKCF.js → index.BAvGLKEb.js} +2 -2
  22. package/dist/assets/{index.B0EhmKCF.js.map → index.BAvGLKEb.js.map} +1 -1
  23. package/dist/assets/{index.BI78I5tG.js → index.C4pUfNnz.js} +2 -2
  24. package/dist/assets/{index.BI78I5tG.js.map → index.C4pUfNnz.js.map} +1 -1
  25. package/dist/assets/{index.DJB97pbh.js → index.C5mu1t4S.js} +2 -2
  26. package/dist/assets/{index.DJB97pbh.js.map → index.C5mu1t4S.js.map} +1 -1
  27. package/dist/assets/{index.BDEjD6s0.js → index.CrfEkaEE.js} +3 -3
  28. package/dist/assets/{index.BDEjD6s0.js.map → index.CrfEkaEE.js.map} +1 -1
  29. package/dist/assets/{index.9LsxHx9v.js → index.Dy1TXvFH.js} +2 -2
  30. package/dist/assets/{index.9LsxHx9v.js.map → index.Dy1TXvFH.js.map} +1 -1
  31. package/dist/assets/{index.BspU3wnc.js → index.vknY1pvt.js} +2 -2
  32. package/dist/assets/{index.BspU3wnc.js.map → index.vknY1pvt.js.map} +1 -1
  33. package/dist/assets/{main.CQ97ZtJ9.js → main.BKU6sAOE.js} +3 -3
  34. package/dist/assets/{main.CQ97ZtJ9.js.map → main.BKU6sAOE.js.map} +1 -1
  35. package/dist/assets/{modal.BurIaDHm.js → modal.bK1fuPa_.js} +3 -3
  36. package/dist/assets/{modal.BurIaDHm.js.map → modal.bK1fuPa_.js.map} +1 -1
  37. package/dist/assets/{modals.BgBl4OEM.js → modals.CkpMpa3F.js} +2 -2
  38. package/dist/assets/{modals.BgBl4OEM.js.map → modals.CkpMpa3F.js.map} +1 -1
  39. package/dist/assets/{registerServiceWorker.D6UhEnk-.js → registerServiceWorker.DUgNo8Ta.js} +2 -2
  40. package/dist/assets/{registerServiceWorker.D6UhEnk-.js.map → registerServiceWorker.DUgNo8Ta.js.map} +1 -1
  41. package/dist/assets/{root.OFkJ3D8n.js → root.eCpkkkef.js} +2 -2
  42. package/dist/assets/{root.OFkJ3D8n.js.map → root.eCpkkkef.js.map} +1 -1
  43. package/dist/assets/{useAcceptedCookies.CxwtiZdL.js → useAcceptedCookies.D_OU6xT7.js} +2 -2
  44. package/dist/assets/{useAcceptedCookies.CxwtiZdL.js.map → useAcceptedCookies.D_OU6xT7.js.map} +1 -1
  45. package/dist/assets/useConnectConfig.BvkNvwSB.js +2 -0
  46. package/dist/assets/{useConnectConfig.PFYS-3o2.js.map → useConnectConfig.BvkNvwSB.js.map} +1 -1
  47. package/dist/assets/{useDefaultDocumentModelEditor.CN7iHYLX.js → useDefaultDocumentModelEditor.CtjvbYvO.js} +2 -2
  48. package/dist/assets/{useDefaultDocumentModelEditor.CN7iHYLX.js.map → useDefaultDocumentModelEditor.CtjvbYvO.js.map} +1 -1
  49. package/dist/assets/{useDocumentDriveServer.DiA5ncH8.js → useDocumentDriveServer.B5iYllwN.js} +2 -2
  50. package/dist/assets/{useDocumentDriveServer.DiA5ncH8.js.map → useDocumentDriveServer.B5iYllwN.js.map} +1 -1
  51. package/dist/assets/{useFeatureFlags.Dp7X50k3.js → useFeatureFlags.CZev5A6L.js} +2 -2
  52. package/dist/assets/{useFeatureFlags.Dp7X50k3.js.map → useFeatureFlags.CZev5A6L.js.map} +1 -1
  53. package/dist/assets/{user.BQU9ztVh.js → user.C5X0s2J6.js} +4 -4
  54. package/dist/assets/{user.BQU9ztVh.js.map → user.C5X0s2J6.js.map} +1 -1
  55. package/dist/index.html +1 -1
  56. package/dist/vite-envs.sh +1 -1
  57. package/package.json +9 -9
  58. package/dist/assets/useConnectConfig.PFYS-3o2.js +0 -2
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app.4_SWVXbR.js","./index.DFyMrewv.js","./connect.config.DUXg7xh4.js","./browser.BkwNmV2Z.js","./user.BQU9ztVh.js","./useFeatureFlags.Dp7X50k3.js","./useAcceptedCookies.CxwtiZdL.js","./useConnectConfig.PFYS-3o2.js","./index.CAUjMUXb.js","./registerServiceWorker.D6UhEnk-.js","./cookie-banner.CFaAyloc.js","./i18next.CqOP20KE.js","./useTranslation.BpVv6XIW.js","./modal.BurIaDHm.js","./Trans.-pu2RC5T.js"])))=>i.map(i=>d[i]);
2
- import{createRoot as ne}from"react-dom/client";import{a as l,u as D,c as re,b as ae,d as de,P as se,_ as F}from"./index.DFyMrewv.js";import{jsxs as K,jsx as p}from"react/jsx-runtime";import{useCallback as ce,useEffect as ue,StrictMode as ie,Suspense as J,lazy as O}from"react";import{A as le}from"./app-skeleton.js";const A={},me=Symbol((A?"production":void 0)!=="production"?"RESET":""),q=e=>typeof(e==null?void 0:e.then)=="function";function be(e=()=>{try{return window.localStorage}catch(o){(A?"production":void 0)!=="production"&&typeof window<"u"&&console.warn(o);return}},t){var o;let r,n;const u={getItem:(s,c)=>{var i,m;const S=w=>{if(w=w||"",r!==w){try{n=JSON.parse(w,void 0)}catch{return c}r=w}return n},g=(m=(i=e())==null?void 0:i.getItem(s))!=null?m:null;return q(g)?g.then(S):S(g)},setItem:(s,c)=>{var i;return(i=e())==null?void 0:i.setItem(s,JSON.stringify(c,void 0))},removeItem:s=>{var c;return(c=e())==null?void 0:c.removeItem(s)}},a=s=>(c,i,m)=>s(c,S=>{let g;try{g=JSON.parse(S||"")}catch{g=m}i(g)});let d;try{d=(o=e())==null?void 0:o.subscribe}catch{}return!d&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(d=(s,c)=>{if(!(e()instanceof window.Storage))return()=>{};const i=m=>{m.storageArea===e()&&m.key===s&&c(m.newValue)};return window.addEventListener("storage",i),()=>{window.removeEventListener("storage",i)}}),d&&(u.subscribe=a(d)),u}const fe=be();function lt(e,t,o=fe,r){const n=l(t);return(A?"production":void 0)!=="production"&&(n.debugPrivate=!0),n.onMount=a=>{a(o.getItem(e,t));let d;return o.subscribe&&(d=o.subscribe(e,a,t)),d},l(a=>a(n),(a,d,s)=>{const c=typeof s=="function"?s(a(n)):s;return c===me?(d(n,t),o.removeItem(e)):q(c)?c.then(i=>(d(n,i),o.setItem(e,i))):(d(n,c),o.setItem(e,c))})}const N=new WeakMap,pe=(e,t)=>(N.has(t)?N:N.set(t,e())).get(t),Ae=e=>typeof(e==null?void 0:e.then)=="function",$={state:"loading"};function b(e){return pe(()=>{const t=new WeakMap,o=l(0);(A?"production":void 0)!=="production"&&(o.debugPrivate=!0);const r=l((n,{setSelf:u})=>{n(o);let a;try{a=n(e)}catch(i){return{state:"hasError",error:i}}if(!Ae(a))return{state:"hasData",data:a};const d=a,s=t.get(d);if(s)return s;d.then(i=>{t.set(d,{state:"hasData",data:i}),u()},i=>{t.set(d,{state:"hasError",error:i}),u()});const c=t.get(d);return c||(t.set(d,$),$)},(n,u)=>{u(o,a=>a+1)});return(A?"production":void 0)!=="production"&&(r.debugPrivate=!0),l(n=>n(r))},e)}const G=(e,t,o)=>(t.has(o)?t:t.set(o,e())).get(o),ve=new WeakMap,he=(e,t,o)=>{const r=G(()=>new WeakMap,ve,t);return G(e,r,o)},ge=e=>typeof(e==null?void 0:e.then)=="function",we=()=>{};function f(e,t=we){return he(()=>{const o=new WeakMap,r=new WeakMap,n=l(0);(A?"production":void 0)!=="production"&&(n.debugPrivate=!0);const u=l((a,{setSelf:d})=>{a(n);const s=a(u),c=a(e);if(!ge(c))return{v:c};if(c!==(s==null?void 0:s.p)&&c.then(i=>{r.set(c,i),d()},i=>{o.set(c,i),d()}),o.has(c))throw o.get(c);return r.has(c)?{p:c,v:r.get(c)}:s&&"v"in s?{p:c,f:t(s.v),v:s.v}:{p:c,f:t()}},(a,d)=>{d(n,s=>s+1)});return u.init=void 0,(A?"production":void 0)!=="production"&&(u.debugPrivate=!0),l(a=>{const d=a(u);return"f"in d?d.f:d.v},(a,d,...s)=>d(e,...s))},e,t)}function M(e,t){const o=l(0);return(A?"production":void 0)!=="production"&&(o.debugPrivate=!0),l((r,n)=>(r(o),e(r,n)),(r,n,...u)=>{if(u.length===0)n(o,a=>a+1);else if((A?"production":void 0)!=="production")throw new Error("refresh must be called without arguments")})}function mt(e){const t=l(void 0);return delete t.init,Object.defineProperty(t,"init",{get(){return e()}}),t}const h="NOT_SET";function v(){return new Promise(()=>{})}function De(e){const t=/^\/d\/[^/]+\/([^/]+)$/.exec(e);return t?t[1]:void 0}function Le(e){if(!e)return;const o=/\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(e);return o?o[0]:void 0}function Se(e){const t=De(e),o=Le(t);return o||t}function Pe(e){const t=/^\/d\/([^/]+)/.exec(e);return t?t[1]:null}function _e(e){return e.replaceAll(/\s/g,"-")}async function Me(e,t,o,r){if(typeof window>"u"||!r||!e)return;const n=window.location.pathname,u=await Ie(e,n,t);ye(u,n,o)}async function Ie(e,t,o){const r=Pe(t),n=await e.getDrives(),a=(await Promise.all(n.map(d=>e.getDrive(d)))).find(d=>d.header.slug===r||d.header.id===r);return o(a==null?void 0:a.header.id),a}function ye(e,t,o){const r=Se(t),n=e==null?void 0:e.state.global.nodes,u=n==null?void 0:n.find(a=>a.id===r||_e(a.name)===r);o(u==null?void 0:u.id)}function Re(){return D(I)}function Ee(e){return e?e.kind.toUpperCase()==="FOLDER":!1}const _=l(h);_.debugLabel="baseReactorAtom";const C=l(async e=>{const t=e(_);return t===h?v():t});C.debugLabel="reactorAtom";const Q=l(null,(e,t,o)=>{e(_)===h&&t(_,o)});Q.debugLabel="setReactorAtom";const x=b(C);x.debugLabel="loadableReactorAtom";const X=f(C);X.debugLabel="unwrappedReactorAtom";const I=M(async e=>{const t=e(x);if(t.state!=="hasData")return v();const o=t.data;if(!o)return[];const r=await o.getDrives(),n=new Array;for(const u of r){const a=await o.getDrive(u);n.push(a)}return n});I.debugLabel="drivesAtom";const Y=b(I);Y.debugLabel="loadableDrivesAtom";const Ne=f(I);Ne.debugLabel="unwrappedDrivesAtom";const k=l(h);k.debugLabel="baseSelectedDriveIdAtom";const y=l(e=>{const t=e(k),o=e(Y);return t===h||o.state!=="hasData"?v():o.data.find(n=>n.header.id===t)},(e,t,o)=>{t(k,o),t(L,void 0)});y.debugLabel="selectedDriveAtom";const T=b(y);T.debugLabel="loadableSelectedDriveAtom";const ke=f(y);ke.debugLabel="unwrappedSelectedDriveAtom";const U=l(async e=>{const t=e(T);if(t.state!=="hasData")return v();const o=t.data;return o==null?void 0:o.state.global.nodes});U.debugLabel="nodesAtom";const Z=b(U);Z.debugLabel="loadableNodesAtom";const Fe=f(U);Fe.debugLabel="unwrappedNodesAtom";const L=l(h);L.debugLabel="selectedNodeIdAtom";const ee=l(null,(e,t,o)=>{t(L,o)});ee.debugLabel="setSelectedNodeAtom";const W=l(e=>{const t=e(Z),o=e(L);if(o===h||t.state!=="hasData")return v();const r=t.data,n=r==null?void 0:r.filter(Ee);return n==null?void 0:n.find(u=>u.id===o)});W.debugLabel="selectedFolderAtom";const Oe=b(W);Oe.debugLabel="loadableSelectedFolderAtom";const Ce=f(W);Ce.debugLabel="unwrappedSelectedFolderAtom";const R=M(async e=>{var d;const t=e(x),o=e(T);if(t.state!=="hasData"||o.state!=="hasData")return v();const r=t.data,n=(d=o.data)==null?void 0:d.header.id;if(!r||!n)return[];const u=await r.getDocuments(n);return await Promise.all(u.map(s=>r.getDocument(n,s)))});R.debugLabel="documentsAtom";const te=b(R);te.debugLabel="loadableDocumentsAtom";const xe=f(R);xe.debugLabel="unwrappedDocumentsAtom";const B=l(e=>{const t=e(te),o=e(L);return o===h||t.state!=="hasData"?v():t.data.find(n=>n.header.id===o)});B.debugLabel="selectedDocumentAtom";const Te=b(B);Te.debugLabel="loadableSelectedDocumentAtom";const Ue=f(B);Ue.debugLabel="unwrappedSelectedDocumentAtom";const E=l(Promise.resolve(void 0));E.debugLabel="phPackagesAtom";const We=l(null,(e,t,o)=>{t(E,Promise.resolve(o))});We.debugLabel="setPhPackagesAtom";const V=b(E);V.debugLabel="loadablePhPackagesAtom";const Be=f(E);Be.debugLabel="unwrappedPhPackagesAtom";const z=M(async e=>{const t=e(V);if(t.state!=="hasData")return v();const o=t.data;return o==null?void 0:o.map(r=>r.documentModels).flat()});z.debugLabel="documentModelModulesAtom";const Ve=b(z);Ve.debugLabel="loadableDocumentModelModulesAtom";const ze=f(z);ze.debugLabel="unwrappedDocumentModelModulesAtom";const j=M(async e=>{const t=e(V);if(t.state!=="hasData")return v();const o=t.data;return o==null?void 0:o.map(r=>r.editors).flat()});j.debugLabel="editorModulesAtom";const je=b(j);je.debugLabel="loadableEditorModulesAtom";const Je=f(j);Je.debugLabel="unwrappedEditorModulesAtom";const $e=l(void 0);$e.debugLabel="processorManagerAtom";const Ge=l({appVersion:void 0,studioMode:!1,warnOutdatedApp:!1,routerBasename:void 0,analyticsDatabaseName:void 0,sentry:{dsn:void 0,env:void 0,tracing:void 0},content:{showSearchBar:!0,showDocumentModelSelectionSetting:!0},drives:{addDriveEnabled:!0,sections:{LOCAL:{enabled:!0,allowAdd:!0,allowDelete:!0},CLOUD:{enabled:!0,allowAdd:!0,allowDelete:!0},PUBLIC:{enabled:!0,allowAdd:!0,allowDelete:!0}}},gaTrackingId:void 0,phCliVersion:void 0});Ge.debugLabel="configAtom";function He(){return D(R)}function Ke(){const e=Re(),t=He();return ce(()=>{e(),t()},[e,t])}const P=re(["state","reactor"]);function qe(){return ae(X)}function Qe(e,t=!0){const o=qe(),r=D(Q),n=D(y),u=D(ee),a=Ke();ue(()=>{if(o)return;async function d(){const s=await e();s.on("syncStatus",(c,i,m)=>{P.verbose("syncStatus",c,i,m),a()}),s.on("strandUpdate",()=>{P.verbose("strandUpdate"),a()}),s.on("defaultRemoteDrive",()=>{P.verbose("defaultRemoteDrive"),a()}),r(s),await Me(s,n,u,t)}d().catch(P.error)},[r,e,a,t])}var Xe=()=>null;const H=de();function Ye({reactor:e}){return Qe(()=>Promise.resolve(e)),null}function Ze({reactor:e,children:t}){return K(se,{store:H,children:[p(Xe,{store:H}),e&&p(Ye,{reactor:e}),t]})}const et=O(()=>F(()=>import("./app.4_SWVXbR.js").then(e=>e.e),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url)),tt=O(()=>F(()=>import("./cookie-banner.CFaAyloc.js"),__vite__mapDeps([10,6,2,1,3,11,12,13,14]),import.meta.url).then(e=>({default:e.CookieBanner}))),ot=O(()=>F(()=>import("./modal.BurIaDHm.js"),__vite__mapDeps([13,1]),import.meta.url).then(e=>({default:e.ModalManager}))),nt=p(ie,{children:K(Ze,{children:[p(J,{fallback:p(le,{}),name:"AppLoader",children:p(et,{})}),p(J,{name:"CookieBanner",children:p(ot,{children:p(tt,{})})})]})});function rt(e){ne(e).render(nt)}const oe=document.getElementById("app");if(!oe)throw new Error("#app element not found!");rt(oe);const bt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{mt as a,H as b,lt as c,bt as i,b as l,f as u};
3
- //# sourceMappingURL=index.BDEjD6s0.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app.BtXNojPV.js","./index.DFyMrewv.js","./connect.config.DFiOOfbL.js","./browser.BkwNmV2Z.js","./user.C5X0s2J6.js","./useFeatureFlags.CZev5A6L.js","./useAcceptedCookies.D_OU6xT7.js","./useConnectConfig.BvkNvwSB.js","./index.CAUjMUXb.js","./registerServiceWorker.DUgNo8Ta.js","./cookie-banner.B_XhP7he.js","./i18next.CqOP20KE.js","./useTranslation.BpVv6XIW.js","./modal.bK1fuPa_.js","./Trans.-pu2RC5T.js"])))=>i.map(i=>d[i]);
2
+ import{createRoot as ne}from"react-dom/client";import{a as l,u as D,c as re,b as ae,d as de,P as se,_ as F}from"./index.DFyMrewv.js";import{jsxs as K,jsx as p}from"react/jsx-runtime";import{useCallback as ce,useEffect as ue,StrictMode as ie,Suspense as J,lazy as O}from"react";import{A as le}from"./app-skeleton.js";const A={},me=Symbol((A?"production":void 0)!=="production"?"RESET":""),q=e=>typeof(e==null?void 0:e.then)=="function";function be(e=()=>{try{return window.localStorage}catch(o){(A?"production":void 0)!=="production"&&typeof window<"u"&&console.warn(o);return}},t){var o;let r,n;const u={getItem:(s,c)=>{var i,m;const S=w=>{if(w=w||"",r!==w){try{n=JSON.parse(w,void 0)}catch{return c}r=w}return n},g=(m=(i=e())==null?void 0:i.getItem(s))!=null?m:null;return q(g)?g.then(S):S(g)},setItem:(s,c)=>{var i;return(i=e())==null?void 0:i.setItem(s,JSON.stringify(c,void 0))},removeItem:s=>{var c;return(c=e())==null?void 0:c.removeItem(s)}},a=s=>(c,i,m)=>s(c,S=>{let g;try{g=JSON.parse(S||"")}catch{g=m}i(g)});let d;try{d=(o=e())==null?void 0:o.subscribe}catch{}return!d&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(d=(s,c)=>{if(!(e()instanceof window.Storage))return()=>{};const i=m=>{m.storageArea===e()&&m.key===s&&c(m.newValue)};return window.addEventListener("storage",i),()=>{window.removeEventListener("storage",i)}}),d&&(u.subscribe=a(d)),u}const fe=be();function lt(e,t,o=fe,r){const n=l(t);return(A?"production":void 0)!=="production"&&(n.debugPrivate=!0),n.onMount=a=>{a(o.getItem(e,t));let d;return o.subscribe&&(d=o.subscribe(e,a,t)),d},l(a=>a(n),(a,d,s)=>{const c=typeof s=="function"?s(a(n)):s;return c===me?(d(n,t),o.removeItem(e)):q(c)?c.then(i=>(d(n,i),o.setItem(e,i))):(d(n,c),o.setItem(e,c))})}const N=new WeakMap,pe=(e,t)=>(N.has(t)?N:N.set(t,e())).get(t),Ae=e=>typeof(e==null?void 0:e.then)=="function",$={state:"loading"};function b(e){return pe(()=>{const t=new WeakMap,o=l(0);(A?"production":void 0)!=="production"&&(o.debugPrivate=!0);const r=l((n,{setSelf:u})=>{n(o);let a;try{a=n(e)}catch(i){return{state:"hasError",error:i}}if(!Ae(a))return{state:"hasData",data:a};const d=a,s=t.get(d);if(s)return s;d.then(i=>{t.set(d,{state:"hasData",data:i}),u()},i=>{t.set(d,{state:"hasError",error:i}),u()});const c=t.get(d);return c||(t.set(d,$),$)},(n,u)=>{u(o,a=>a+1)});return(A?"production":void 0)!=="production"&&(r.debugPrivate=!0),l(n=>n(r))},e)}const G=(e,t,o)=>(t.has(o)?t:t.set(o,e())).get(o),ve=new WeakMap,he=(e,t,o)=>{const r=G(()=>new WeakMap,ve,t);return G(e,r,o)},ge=e=>typeof(e==null?void 0:e.then)=="function",we=()=>{};function f(e,t=we){return he(()=>{const o=new WeakMap,r=new WeakMap,n=l(0);(A?"production":void 0)!=="production"&&(n.debugPrivate=!0);const u=l((a,{setSelf:d})=>{a(n);const s=a(u),c=a(e);if(!ge(c))return{v:c};if(c!==(s==null?void 0:s.p)&&c.then(i=>{r.set(c,i),d()},i=>{o.set(c,i),d()}),o.has(c))throw o.get(c);return r.has(c)?{p:c,v:r.get(c)}:s&&"v"in s?{p:c,f:t(s.v),v:s.v}:{p:c,f:t()}},(a,d)=>{d(n,s=>s+1)});return u.init=void 0,(A?"production":void 0)!=="production"&&(u.debugPrivate=!0),l(a=>{const d=a(u);return"f"in d?d.f:d.v},(a,d,...s)=>d(e,...s))},e,t)}function M(e,t){const o=l(0);return(A?"production":void 0)!=="production"&&(o.debugPrivate=!0),l((r,n)=>(r(o),e(r,n)),(r,n,...u)=>{if(u.length===0)n(o,a=>a+1);else if((A?"production":void 0)!=="production")throw new Error("refresh must be called without arguments")})}function mt(e){const t=l(void 0);return delete t.init,Object.defineProperty(t,"init",{get(){return e()}}),t}const h="NOT_SET";function v(){return new Promise(()=>{})}function De(e){const t=/^\/d\/[^/]+\/([^/]+)$/.exec(e);return t?t[1]:void 0}function Le(e){if(!e)return;const o=/\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(e);return o?o[0]:void 0}function Se(e){const t=De(e),o=Le(t);return o||t}function Pe(e){const t=/^\/d\/([^/]+)/.exec(e);return t?t[1]:null}function _e(e){return e.replaceAll(/\s/g,"-")}async function Me(e,t,o,r){if(typeof window>"u"||!r||!e)return;const n=window.location.pathname,u=await Ie(e,n,t);ye(u,n,o)}async function Ie(e,t,o){const r=Pe(t),n=await e.getDrives(),a=(await Promise.all(n.map(d=>e.getDrive(d)))).find(d=>d.header.slug===r||d.header.id===r);return o(a==null?void 0:a.header.id),a}function ye(e,t,o){const r=Se(t),n=e==null?void 0:e.state.global.nodes,u=n==null?void 0:n.find(a=>a.id===r||_e(a.name)===r);o(u==null?void 0:u.id)}function Re(){return D(I)}function Ee(e){return e?e.kind.toUpperCase()==="FOLDER":!1}const _=l(h);_.debugLabel="baseReactorAtom";const C=l(async e=>{const t=e(_);return t===h?v():t});C.debugLabel="reactorAtom";const Q=l(null,(e,t,o)=>{e(_)===h&&t(_,o)});Q.debugLabel="setReactorAtom";const x=b(C);x.debugLabel="loadableReactorAtom";const X=f(C);X.debugLabel="unwrappedReactorAtom";const I=M(async e=>{const t=e(x);if(t.state!=="hasData")return v();const o=t.data;if(!o)return[];const r=await o.getDrives(),n=new Array;for(const u of r){const a=await o.getDrive(u);n.push(a)}return n});I.debugLabel="drivesAtom";const Y=b(I);Y.debugLabel="loadableDrivesAtom";const Ne=f(I);Ne.debugLabel="unwrappedDrivesAtom";const k=l(h);k.debugLabel="baseSelectedDriveIdAtom";const y=l(e=>{const t=e(k),o=e(Y);return t===h||o.state!=="hasData"?v():o.data.find(n=>n.header.id===t)},(e,t,o)=>{t(k,o),t(L,void 0)});y.debugLabel="selectedDriveAtom";const T=b(y);T.debugLabel="loadableSelectedDriveAtom";const ke=f(y);ke.debugLabel="unwrappedSelectedDriveAtom";const U=l(async e=>{const t=e(T);if(t.state!=="hasData")return v();const o=t.data;return o==null?void 0:o.state.global.nodes});U.debugLabel="nodesAtom";const Z=b(U);Z.debugLabel="loadableNodesAtom";const Fe=f(U);Fe.debugLabel="unwrappedNodesAtom";const L=l(h);L.debugLabel="selectedNodeIdAtom";const ee=l(null,(e,t,o)=>{t(L,o)});ee.debugLabel="setSelectedNodeAtom";const W=l(e=>{const t=e(Z),o=e(L);if(o===h||t.state!=="hasData")return v();const r=t.data,n=r==null?void 0:r.filter(Ee);return n==null?void 0:n.find(u=>u.id===o)});W.debugLabel="selectedFolderAtom";const Oe=b(W);Oe.debugLabel="loadableSelectedFolderAtom";const Ce=f(W);Ce.debugLabel="unwrappedSelectedFolderAtom";const R=M(async e=>{var d;const t=e(x),o=e(T);if(t.state!=="hasData"||o.state!=="hasData")return v();const r=t.data,n=(d=o.data)==null?void 0:d.header.id;if(!r||!n)return[];const u=await r.getDocuments(n);return await Promise.all(u.map(s=>r.getDocument(n,s)))});R.debugLabel="documentsAtom";const te=b(R);te.debugLabel="loadableDocumentsAtom";const xe=f(R);xe.debugLabel="unwrappedDocumentsAtom";const B=l(e=>{const t=e(te),o=e(L);return o===h||t.state!=="hasData"?v():t.data.find(n=>n.header.id===o)});B.debugLabel="selectedDocumentAtom";const Te=b(B);Te.debugLabel="loadableSelectedDocumentAtom";const Ue=f(B);Ue.debugLabel="unwrappedSelectedDocumentAtom";const E=l(Promise.resolve(void 0));E.debugLabel="phPackagesAtom";const We=l(null,(e,t,o)=>{t(E,Promise.resolve(o))});We.debugLabel="setPhPackagesAtom";const V=b(E);V.debugLabel="loadablePhPackagesAtom";const Be=f(E);Be.debugLabel="unwrappedPhPackagesAtom";const z=M(async e=>{const t=e(V);if(t.state!=="hasData")return v();const o=t.data;return o==null?void 0:o.map(r=>r.documentModels).flat()});z.debugLabel="documentModelModulesAtom";const Ve=b(z);Ve.debugLabel="loadableDocumentModelModulesAtom";const ze=f(z);ze.debugLabel="unwrappedDocumentModelModulesAtom";const j=M(async e=>{const t=e(V);if(t.state!=="hasData")return v();const o=t.data;return o==null?void 0:o.map(r=>r.editors).flat()});j.debugLabel="editorModulesAtom";const je=b(j);je.debugLabel="loadableEditorModulesAtom";const Je=f(j);Je.debugLabel="unwrappedEditorModulesAtom";const $e=l(void 0);$e.debugLabel="processorManagerAtom";const Ge=l({appVersion:void 0,studioMode:!1,warnOutdatedApp:!1,routerBasename:void 0,analyticsDatabaseName:void 0,sentry:{dsn:void 0,env:void 0,tracing:void 0},content:{showSearchBar:!0,showDocumentModelSelectionSetting:!0},drives:{addDriveEnabled:!0,sections:{LOCAL:{enabled:!0,allowAdd:!0,allowDelete:!0},CLOUD:{enabled:!0,allowAdd:!0,allowDelete:!0},PUBLIC:{enabled:!0,allowAdd:!0,allowDelete:!0}}},gaTrackingId:void 0,phCliVersion:void 0});Ge.debugLabel="configAtom";function He(){return D(R)}function Ke(){const e=Re(),t=He();return ce(()=>{e(),t()},[e,t])}const P=re(["state","reactor"]);function qe(){return ae(X)}function Qe(e,t=!0){const o=qe(),r=D(Q),n=D(y),u=D(ee),a=Ke();ue(()=>{if(o)return;async function d(){const s=await e();s.on("syncStatus",(c,i,m)=>{P.verbose("syncStatus",c,i,m),a()}),s.on("strandUpdate",()=>{P.verbose("strandUpdate"),a()}),s.on("defaultRemoteDrive",()=>{P.verbose("defaultRemoteDrive"),a()}),r(s),await Me(s,n,u,t)}d().catch(P.error)},[r,e,a,t])}var Xe=()=>null;const H=de();function Ye({reactor:e}){return Qe(()=>Promise.resolve(e)),null}function Ze({reactor:e,children:t}){return K(se,{store:H,children:[p(Xe,{store:H}),e&&p(Ye,{reactor:e}),t]})}const et=O(()=>F(()=>import("./app.BtXNojPV.js").then(e=>e.e),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url)),tt=O(()=>F(()=>import("./cookie-banner.B_XhP7he.js"),__vite__mapDeps([10,6,2,1,3,11,12,13,14]),import.meta.url).then(e=>({default:e.CookieBanner}))),ot=O(()=>F(()=>import("./modal.bK1fuPa_.js"),__vite__mapDeps([13,1]),import.meta.url).then(e=>({default:e.ModalManager}))),nt=p(ie,{children:K(Ze,{children:[p(J,{fallback:p(le,{}),name:"AppLoader",children:p(et,{})}),p(J,{name:"CookieBanner",children:p(ot,{children:p(tt,{})})})]})});function rt(e){ne(e).render(nt)}const oe=document.getElementById("app");if(!oe)throw new Error("#app element not found!");rt(oe);const bt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{mt as a,H as b,lt as c,bt as i,b as l,f as u};
3
+ //# sourceMappingURL=index.CrfEkaEE.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";uUAEMA,GAAQ,QACXC,EAAkB,aAAuB,UAAY,aAAe,QAAU,EACjF,EAgVMC,EAAmBC,GAAM,OAAQA,GAAK,KAAO,OAASA,EAAE,OAAU,WAsBxE,SAASC,GAAkBC,EAAmB,IAAM,CAClD,GAAI,CACF,OAAO,OAAO,mBACPC,EAAG,EACLL,EAAkB,aAAuB,UAAY,cACpD,OAAO,OAAW,KACpB,QAAQ,KAAKK,CAAC,EAGlB,MAAO,CAEX,EAAGC,EAAS,CACV,IAAIC,EACJ,IAAIC,EACAC,EACJ,MAAMC,EAAU,CACd,QAAS,CAACC,EAAKC,IAAiB,CAC9B,IAAIC,EAAKC,EACT,MAAMC,EAASC,GAAS,CAEtB,GADAA,EAAOA,GAAQ,GACXR,IAAYQ,EAAM,CACpB,GAAI,CACFP,EAAY,KAAK,MAAMO,EAAwB,MAAwB,OAC7D,CACV,OAAOJ,CAAA,CAETJ,EAAUQ,CAAA,CAEZ,OAAOP,CAAA,EAEHQ,GAAOH,GAAMD,EAAMT,EAAA,IAAuB,KAAO,OAASS,EAAI,QAAQF,CAAG,IAAM,KAAOG,EAAK,KACjG,OAAIb,EAAgBgB,CAAG,EACdA,EAAI,KAAKF,CAAK,EAEhBA,EAAME,CAAG,GAElB,QAAS,CAACN,EAAKO,IAAa,CAC1B,IAAIL,EACJ,OAAQA,EAAMT,EAAA,IAAuB,KAAO,OAASS,EAAI,QACvDF,EACA,KAAK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AAK,UACtB,OAAO,qBAAkB,2CAAE,SAAW,CAAE,QAASpI,EAAE,cAAe,CACtE,EAEawI,GACTC,EAACC,GAAA,CACG,SAAAC,EAACb,GAAA,CACG,UAAAW,EAACG,EAAA,CAAS,SAAUH,EAACI,GAAA,EAAY,EAAI,KAAK,YACtC,SAAAJ,EAACN,GAAA,EAAI,EACT,EACAM,EAACG,GAAS,KAAK,eACX,WAACL,GAAA,CACG,SAAAE,EAACH,GAAA,EAAa,EAClB,EACJ,GACJ,EACJ,ECxBJ,SAASQ,GAAUC,EAAsB,CACrCC,GAAWD,CAAO,EAAE,OAAOP,EAAS,CACxC,CAEA,MAAMS,GAAa,SAAS,eAAe,KAAK,EAChD,GAAI,CAACA,GACD,MAAM,IAAI,MAAM,yBAAyB,EAG7CH,GAAUG,EAAU","names":["RESET","__vite_import_meta_env__","isPromiseLike$3","x","createJSONStorage","getStringStorage","e","options","_a","lastStr","lastValue","storage","key","initialValue","_a2","_b","parse","str2","str","newValue","createHandleSubscribe","subscriber2","callback","v","subscriber","storageEventCallback","defaultStorage","atomWithStorage","baseAtom","atom","setAtom","unsub","get","set","update","nextValue","resolvedValue","cache1$1","memo1","create","dep1","isPromiseLike$1","p","LOADING","loadable","anAtom","loadableCache","refreshAtom","derivedAtom","setSelf","value","error","promise","cached1","data","cached2","_get","c","getCached","m","k","cache1","memo2","dep2","cache2","isPromiseLike","defaultFallback","unwrap","fallback","promiseErrorCache","promiseResultCache","promiseAndValueAtom","prev","state","args","atomWithRefresh","read","write","atomWithLazy","makeInitial","a","NOT_SET","suspendUntilSet","extractNodeSlug","path","match","findUuid","input","extractNodeNameOrSlugOrIdFromPath","nodeSlug","nodeId","extractDriveFromPath","makeNodeSlugFromNodeName","name","setSelectedDriveAndNodeFromUrl","reactor","setSelectedDrive","setSelectedNode","shouldNavigate","drive","handleDriveFromUrl","handleNodeFromUrl","driveSlug","driveIds","id","nodeIdOrSlugOrNameFromPath","nodes","node","n","useRefreshDrives","useSetAtom","drivesAtom","isFolderNodeKind","baseReactorAtom","reactorAtom","initializeReactorAtom","loadableReactorAtom","unwrappedReactorAtom","loadableReactor","drives","driveId","loadableDrivesAtom","unwrappedDrivesAtom","baseSelectedDriveIdAtom","selectedDriveAtom","loadableDrives","selectedNodeIdAtom","loadableSelectedDriveAtom","unwrappedSelectedDriveAtom","nodesAtom","loadableSelectedDrive","loadableNodesAtom","unwrappedNodesAtom","setSelectedNodeAtom","selectedFolderAtom","loadableNodes","folderNodes","loadableSelectedFolderAtom","unwrappedSelectedFolderAtom","documentsAtom","loadableDrive","documentIds","loadableDocumentsAtom","unwrappedDocumentsAtom","selectedDocumentAtom","loadableDocuments","document","loadableSelectedDocumentAtom","unwrappedSelectedDocumentAtom","phPackagesAtom","setPhPackagesAtom","phPackages","loadablePhPackagesAtom","unwrappedPhPackagesAtom","documentModelModulesAtom","loadablePhPackages","loadableDocumentModelModulesAtom","unwrappedDocumentModelModulesAtom","editorModulesAtom","loadableEditorModulesAtom","unwrappedEditorModulesAtom","processorManagerAtom","configAtom","useRefreshDocuments","useSyncDrivesAndDocumentsWithReactor","refreshDrives","refreshDocuments","useCallback","logger","childLogger","useUnwrappedReactor","useAtomValue","useInitializeReactor","createReactor","unwrappedReactor","setReactor","refresh","useEffect","initializeReactor","event","status","DevTools","atomStore","createStore","InitReactor","AtomStoreProvider","children","_jsxs","Provider","_jsx","App","lazy","__vitePreload","CookieBanner","ModalManager","AppLoader","jsx","StrictMode","jsxs","Suspense","AppSkeleton","renderApp","element","createRoot","AppElement"],"ignoreList":[0,8],"sources":["../../../../node_modules/.pnpm/jotai@2.12.5_@types+react@18.3.23_react@18.3.1/node_modules/jotai/esm/vanilla/utils.mjs","../../../../packages/common/dist/state/utils.js","../../../../packages/common/dist/state/drives.js","../../../../packages/common/dist/state/nodes.js","../../../../packages/common/dist/state/atoms.js","../../../../packages/common/dist/state/documents.js","../../../../packages/common/dist/state/syncing.js","../../../../packages/common/dist/state/reactor.js","../../../../node_modules/.pnpm/jotai-devtools@0.12.0_@types+react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1__c8b464b01737ba84c54b4cf01b222909/node_modules/jotai-devtools/dist/index.esm.mjs","../../../../packages/common/dist/state/store.js","../../../../packages/common/dist/state/store-provider.js","../../src/components/app-loader.tsx","../../src/index.ts"],"sourcesContent":["import { atom } from 'jotai/vanilla';\n\nconst RESET = Symbol(\n (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" ? \"RESET\" : \"\"\n);\n\nfunction atomWithReset(initialValue) {\n const anAtom = atom(\n initialValue,\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(anAtom)) : update;\n set(anAtom, nextValue === RESET ? initialValue : nextValue);\n }\n );\n return anAtom;\n}\n\nfunction atomWithReducer(initialValue, reducer) {\n return atom(initialValue, function(get, set, action) {\n set(this, reducer(get(this), action));\n });\n}\n\nfunction atomFamily(initializeAtom, areEqual) {\n let shouldRemove = null;\n const atoms = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Set();\n const createAtom = (param) => {\n let item;\n if (areEqual === void 0) {\n item = atoms.get(param);\n } else {\n for (const [key, value] of atoms) {\n if (areEqual(key, param)) {\n item = value;\n break;\n }\n }\n }\n if (item !== void 0) {\n if (shouldRemove == null ? void 0 : shouldRemove(item[1], param)) {\n createAtom.remove(param);\n } else {\n return item[0];\n }\n }\n const newAtom = initializeAtom(param);\n atoms.set(param, [newAtom, Date.now()]);\n notifyListeners(\"CREATE\", param, newAtom);\n return newAtom;\n };\n const notifyListeners = (type, param, atom) => {\n for (const listener of listeners) {\n listener({ type, param, atom });\n }\n };\n createAtom.unstable_listen = (callback) => {\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n };\n createAtom.getParams = () => atoms.keys();\n createAtom.remove = (param) => {\n if (areEqual === void 0) {\n if (!atoms.has(param)) return;\n const [atom] = atoms.get(param);\n atoms.delete(param);\n notifyListeners(\"REMOVE\", param, atom);\n } else {\n for (const [key, [atom]] of atoms) {\n if (areEqual(key, param)) {\n atoms.delete(key);\n notifyListeners(\"REMOVE\", key, atom);\n break;\n }\n }\n }\n };\n createAtom.setShouldRemove = (fn) => {\n shouldRemove = fn;\n if (!shouldRemove) return;\n for (const [key, [atom, createdAt]] of atoms) {\n if (shouldRemove(createdAt, key)) {\n atoms.delete(key);\n notifyListeners(\"REMOVE\", key, atom);\n }\n }\n };\n return createAtom;\n}\n\nconst getCached$2 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$3 = /* @__PURE__ */ new WeakMap();\nconst memo3 = (create, dep1, dep2, dep3) => {\n const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$3, dep1);\n const cache3 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache2, dep2);\n return getCached$2(create, cache3, dep3);\n};\nfunction selectAtom(anAtom, selector, equalityFn = Object.is) {\n return memo3(\n () => {\n const EMPTY = Symbol();\n const selectValue = ([value, prevSlice]) => {\n if (prevSlice === EMPTY) {\n return selector(value);\n }\n const slice = selector(value, prevSlice);\n return equalityFn(prevSlice, slice) ? prevSlice : slice;\n };\n const derivedAtom = atom((get) => {\n const prev = get(derivedAtom);\n const value = get(anAtom);\n return selectValue([value, prev]);\n });\n derivedAtom.init = EMPTY;\n return derivedAtom;\n },\n anAtom,\n selector,\n equalityFn\n );\n}\n\nconst frozenAtoms = /* @__PURE__ */ new WeakSet();\nconst deepFreeze = (value) => {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n Object.freeze(value);\n const propNames = Object.getOwnPropertyNames(value);\n for (const name of propNames) {\n deepFreeze(value[name]);\n }\n return value;\n};\nfunction freezeAtom(anAtom) {\n if (frozenAtoms.has(anAtom)) {\n return anAtom;\n }\n frozenAtoms.add(anAtom);\n const origRead = anAtom.read;\n anAtom.read = function(get, options) {\n return deepFreeze(origRead.call(this, get, options));\n };\n if (\"write\" in anAtom) {\n const origWrite = anAtom.write;\n anAtom.write = function(get, set, ...args) {\n return origWrite.call(\n this,\n get,\n (...setArgs) => {\n if (setArgs[0] === anAtom) {\n setArgs[1] = deepFreeze(setArgs[1]);\n }\n return set(...setArgs);\n },\n ...args\n );\n };\n }\n return anAtom;\n}\nfunction freezeAtomCreator(createAtom) {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n console.warn(\n \"[DEPRECATED] freezeAtomCreator is deprecated, define it on users end\"\n );\n }\n return (...args) => freezeAtom(createAtom(...args));\n}\n\nconst getCached$1 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$2 = /* @__PURE__ */ new WeakMap();\nconst memo2$1 = (create, dep1, dep2) => {\n const cache2 = getCached$1(() => /* @__PURE__ */ new WeakMap(), cache1$2, dep1);\n return getCached$1(create, cache2, dep2);\n};\nconst cacheKeyForEmptyKeyExtractor = {};\nconst isWritable = (atom2) => !!atom2.write;\nconst isFunction = (x) => typeof x === \"function\";\nfunction splitAtom(arrAtom, keyExtractor) {\n return memo2$1(\n () => {\n const mappingCache = /* @__PURE__ */ new WeakMap();\n const getMapping = (arr, prev) => {\n let mapping = mappingCache.get(arr);\n if (mapping) {\n return mapping;\n }\n const prevMapping = prev && mappingCache.get(prev);\n const atomList = [];\n const keyList = [];\n arr.forEach((item, index) => {\n const key = keyExtractor ? keyExtractor(item) : index;\n keyList[index] = key;\n const cachedAtom = prevMapping && prevMapping.atomList[prevMapping.keyList.indexOf(key)];\n if (cachedAtom) {\n atomList[index] = cachedAtom;\n return;\n }\n const read = (get) => {\n const prev2 = get(mappingAtom);\n const currArr = get(arrAtom);\n const mapping2 = getMapping(currArr, prev2 == null ? void 0 : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= currArr.length) {\n const prevItem = arr[getMapping(arr).keyList.indexOf(key)];\n if (prevItem) {\n return prevItem;\n }\n throw new Error(\"splitAtom: index out of bounds for read\");\n }\n return currArr[index2];\n };\n const write = (get, set, update) => {\n const prev2 = get(mappingAtom);\n const arr2 = get(arrAtom);\n const mapping2 = getMapping(arr2, prev2 == null ? void 0 : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= arr2.length) {\n throw new Error(\"splitAtom: index out of bounds for write\");\n }\n const nextItem = isFunction(update) ? update(arr2[index2]) : update;\n if (!Object.is(arr2[index2], nextItem)) {\n set(arrAtom, [\n ...arr2.slice(0, index2),\n nextItem,\n ...arr2.slice(index2 + 1)\n ]);\n }\n };\n atomList[index] = isWritable(arrAtom) ? atom(read, write) : atom(read);\n });\n if (prevMapping && prevMapping.keyList.length === keyList.length && prevMapping.keyList.every((x, i) => x === keyList[i])) {\n mapping = prevMapping;\n } else {\n mapping = { arr, atomList, keyList };\n }\n mappingCache.set(arr, mapping);\n return mapping;\n };\n const mappingAtom = atom((get) => {\n const prev = get(mappingAtom);\n const arr = get(arrAtom);\n const mapping = getMapping(arr, prev == null ? void 0 : prev.arr);\n return mapping;\n });\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n mappingAtom.debugPrivate = true;\n }\n mappingAtom.init = void 0;\n const splittedAtom = isWritable(arrAtom) ? atom(\n (get) => get(mappingAtom).atomList,\n (get, set, action) => {\n switch (action.type) {\n case \"remove\": {\n const index = get(splittedAtom).indexOf(action.atom);\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n ...arr.slice(index + 1)\n ]);\n }\n break;\n }\n case \"insert\": {\n const index = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n action.value,\n ...arr.slice(index)\n ]);\n }\n break;\n }\n case \"move\": {\n const index1 = get(splittedAtom).indexOf(action.atom);\n const index2 = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index1 >= 0 && index2 >= 0) {\n const arr = get(arrAtom);\n if (index1 < index2) {\n set(arrAtom, [\n ...arr.slice(0, index1),\n ...arr.slice(index1 + 1, index2),\n arr[index1],\n ...arr.slice(index2)\n ]);\n } else {\n set(arrAtom, [\n ...arr.slice(0, index2),\n arr[index1],\n ...arr.slice(index2, index1),\n ...arr.slice(index1 + 1)\n ]);\n }\n }\n break;\n }\n }\n }\n ) : atom((get) => get(mappingAtom).atomList);\n return splittedAtom;\n },\n arrAtom,\n keyExtractor || cacheKeyForEmptyKeyExtractor\n );\n}\n\nfunction atomWithDefault(getDefault) {\n const EMPTY = Symbol();\n const overwrittenAtom = atom(EMPTY);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n overwrittenAtom.debugPrivate = true;\n }\n const anAtom = atom(\n (get, options) => {\n const overwritten = get(overwrittenAtom);\n if (overwritten !== EMPTY) {\n return overwritten;\n }\n return getDefault(get, options);\n },\n (get, set, update) => {\n if (update === RESET) {\n set(overwrittenAtom, EMPTY);\n } else if (typeof update === \"function\") {\n const prevValue = get(anAtom);\n set(overwrittenAtom, update(prevValue));\n } else {\n set(overwrittenAtom, update);\n }\n }\n );\n return anAtom;\n}\n\nconst isPromiseLike$3 = (x) => typeof (x == null ? void 0 : x.then) === \"function\";\nfunction withStorageValidator(validator) {\n return (unknownStorage) => {\n const storage = {\n ...unknownStorage,\n getItem: (key, initialValue) => {\n const validate = (value2) => {\n if (!validator(value2)) {\n return initialValue;\n }\n return value2;\n };\n const value = unknownStorage.getItem(key, initialValue);\n if (isPromiseLike$3(value)) {\n return value.then(validate);\n }\n return validate(value);\n }\n };\n return storage;\n };\n}\nfunction createJSONStorage(getStringStorage = () => {\n try {\n return window.localStorage;\n } catch (e) {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n if (typeof window !== \"undefined\") {\n console.warn(e);\n }\n }\n return void 0;\n }\n}, options) {\n var _a;\n let lastStr;\n let lastValue;\n const storage = {\n getItem: (key, initialValue) => {\n var _a2, _b;\n const parse = (str2) => {\n str2 = str2 || \"\";\n if (lastStr !== str2) {\n try {\n lastValue = JSON.parse(str2, options == null ? void 0 : options.reviver);\n } catch (e) {\n return initialValue;\n }\n lastStr = str2;\n }\n return lastValue;\n };\n const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;\n if (isPromiseLike$3(str)) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (key, newValue) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem(\n key,\n JSON.stringify(newValue, options == null ? void 0 : options.replacer)\n );\n },\n removeItem: (key) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key);\n }\n };\n const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => {\n let newValue;\n try {\n newValue = JSON.parse(v || \"\");\n } catch (e) {\n newValue = initialValue;\n }\n callback(newValue);\n });\n let subscriber;\n try {\n subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;\n } catch (e) {\n }\n if (!subscriber && typeof window !== \"undefined\" && typeof window.addEventListener === \"function\" && window.Storage) {\n subscriber = (key, callback) => {\n if (!(getStringStorage() instanceof window.Storage)) {\n return () => {\n };\n }\n const storageEventCallback = (e) => {\n if (e.storageArea === getStringStorage() && e.key === key) {\n callback(e.newValue);\n }\n };\n window.addEventListener(\"storage\", storageEventCallback);\n return () => {\n window.removeEventListener(\"storage\", storageEventCallback);\n };\n };\n }\n if (subscriber) {\n storage.subscribe = createHandleSubscribe(subscriber);\n }\n return storage;\n}\nconst defaultStorage = createJSONStorage();\nfunction atomWithStorage(key, initialValue, storage = defaultStorage, options) {\n const getOnInit = options == null ? void 0 : options.getOnInit;\n const baseAtom = atom(\n getOnInit ? storage.getItem(key, initialValue) : initialValue\n );\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n baseAtom.debugPrivate = true;\n }\n baseAtom.onMount = (setAtom) => {\n setAtom(storage.getItem(key, initialValue));\n let unsub;\n if (storage.subscribe) {\n unsub = storage.subscribe(key, setAtom, initialValue);\n }\n return unsub;\n };\n const anAtom = atom(\n (get) => get(baseAtom),\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(baseAtom)) : update;\n if (nextValue === RESET) {\n set(baseAtom, initialValue);\n return storage.removeItem(key);\n }\n if (isPromiseLike$3(nextValue)) {\n return nextValue.then((resolvedValue) => {\n set(baseAtom, resolvedValue);\n return storage.setItem(key, resolvedValue);\n });\n }\n set(baseAtom, nextValue);\n return storage.setItem(key, nextValue);\n }\n );\n return anAtom;\n}\n\nconst isPromiseLike$2 = (x) => typeof (x == null ? void 0 : x.then) === \"function\";\nfunction atomWithObservable(getObservable, options) {\n const returnResultData = (result) => {\n if (\"e\" in result) {\n throw result.e;\n }\n return result.d;\n };\n const observableResultAtom = atom((get) => {\n var _a;\n let observable = getObservable(get);\n const itself = (_a = observable[Symbol.observable]) == null ? void 0 : _a.call(observable);\n if (itself) {\n observable = itself;\n }\n let resolve;\n const makePending = () => new Promise((r) => {\n resolve = r;\n });\n const initialResult = options && \"initialValue\" in options ? {\n d: typeof options.initialValue === \"function\" ? options.initialValue() : options.initialValue\n } : makePending();\n let setResult;\n let lastResult;\n const listener = (result) => {\n lastResult = result;\n resolve == null ? void 0 : resolve(result);\n setResult == null ? void 0 : setResult(result);\n };\n let subscription;\n let timer;\n const isNotMounted = () => !setResult;\n const unsubscribe = () => {\n if (subscription) {\n subscription.unsubscribe();\n subscription = void 0;\n }\n };\n const start = () => {\n if (subscription) {\n clearTimeout(timer);\n subscription.unsubscribe();\n }\n subscription = observable.subscribe({\n next: (d) => listener({ d }),\n error: (e) => listener({ e }),\n complete: () => {\n }\n });\n if (isNotMounted() && (options == null ? void 0 : options.unstable_timeout)) {\n timer = setTimeout(unsubscribe, options.unstable_timeout);\n }\n };\n start();\n const resultAtom = atom(lastResult || initialResult);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n resultAtom.debugPrivate = true;\n }\n resultAtom.onMount = (update) => {\n setResult = update;\n if (lastResult) {\n update(lastResult);\n }\n if (subscription) {\n clearTimeout(timer);\n } else {\n start();\n }\n return () => {\n setResult = void 0;\n if (options == null ? void 0 : options.unstable_timeout) {\n timer = setTimeout(unsubscribe, options.unstable_timeout);\n } else {\n unsubscribe();\n }\n };\n };\n return [resultAtom, observable, makePending, start, isNotMounted];\n });\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n observableResultAtom.debugPrivate = true;\n }\n const observableAtom = atom(\n (get) => {\n const [resultAtom] = get(observableResultAtom);\n const result = get(resultAtom);\n if (isPromiseLike$2(result)) {\n return result.then(returnResultData);\n }\n return returnResultData(result);\n },\n (get, set, data) => {\n const [resultAtom, observable, makePending, start, isNotMounted] = get(observableResultAtom);\n if (\"next\" in observable) {\n if (isNotMounted()) {\n set(resultAtom, makePending());\n start();\n }\n observable.next(data);\n } else {\n throw new Error(\"observable is not subject\");\n }\n }\n );\n return observableAtom;\n}\n\nconst cache1$1 = /* @__PURE__ */ new WeakMap();\nconst memo1 = (create, dep1) => (cache1$1.has(dep1) ? cache1$1 : cache1$1.set(dep1, create())).get(dep1);\nconst isPromiseLike$1 = (p) => typeof (p == null ? void 0 : p.then) === \"function\";\nconst LOADING = { state: \"loading\" };\nfunction loadable(anAtom) {\n return memo1(() => {\n const loadableCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const derivedAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n let value;\n try {\n value = get(anAtom);\n } catch (error) {\n return { state: \"hasError\", error };\n }\n if (!isPromiseLike$1(value)) {\n return { state: \"hasData\", data: value };\n }\n const promise = value;\n const cached1 = loadableCache.get(promise);\n if (cached1) {\n return cached1;\n }\n promise.then(\n (data) => {\n loadableCache.set(promise, { state: \"hasData\", data });\n setSelf();\n },\n (error) => {\n loadableCache.set(promise, { state: \"hasError\", error });\n setSelf();\n }\n );\n const cached2 = loadableCache.get(promise);\n if (cached2) {\n return cached2;\n }\n loadableCache.set(promise, LOADING);\n return LOADING;\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n derivedAtom.debugPrivate = true;\n }\n return atom((get) => get(derivedAtom));\n }, anAtom);\n}\n\nconst getCached = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1 = /* @__PURE__ */ new WeakMap();\nconst memo2 = (create, dep1, dep2) => {\n const cache2 = getCached(() => /* @__PURE__ */ new WeakMap(), cache1, dep1);\n return getCached(create, cache2, dep2);\n};\nconst isPromiseLike = (p) => typeof (p == null ? void 0 : p.then) === \"function\";\nconst defaultFallback = () => void 0;\nfunction unwrap(anAtom, fallback = defaultFallback) {\n return memo2(\n () => {\n const promiseErrorCache = /* @__PURE__ */ new WeakMap();\n const promiseResultCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const promiseAndValueAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n const prev = get(promiseAndValueAtom);\n const promise = get(anAtom);\n if (!isPromiseLike(promise)) {\n return { v: promise };\n }\n if (promise !== (prev == null ? void 0 : prev.p)) {\n promise.then(\n (v) => {\n promiseResultCache.set(promise, v);\n setSelf();\n },\n (e) => {\n promiseErrorCache.set(promise, e);\n setSelf();\n }\n );\n }\n if (promiseErrorCache.has(promise)) {\n throw promiseErrorCache.get(promise);\n }\n if (promiseResultCache.has(promise)) {\n return {\n p: promise,\n v: promiseResultCache.get(promise)\n };\n }\n if (prev && \"v\" in prev) {\n return { p: promise, f: fallback(prev.v), v: prev.v };\n }\n return { p: promise, f: fallback() };\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n promiseAndValueAtom.init = void 0;\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n promiseAndValueAtom.debugPrivate = true;\n }\n return atom(\n (get) => {\n const state = get(promiseAndValueAtom);\n if (\"f\" in state) {\n return state.f;\n }\n return state.v;\n },\n (_get, set, ...args) => set(anAtom, ...args)\n );\n },\n anAtom,\n fallback\n );\n}\n\nfunction atomWithRefresh(read, write) {\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n return atom(\n (get, options) => {\n get(refreshAtom);\n return read(get, options);\n },\n (get, set, ...args) => {\n if (args.length === 0) {\n set(refreshAtom, (c) => c + 1);\n } else if (write) {\n return write(get, set, ...args);\n } else if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n throw new Error(\"refresh must be called without arguments\");\n }\n }\n );\n}\n\nfunction atomWithLazy(makeInitial) {\n const a = atom(void 0);\n delete a.init;\n Object.defineProperty(a, \"init\", {\n get() {\n return makeInitial();\n }\n });\n return a;\n}\n\nexport { RESET, atomFamily, atomWithDefault, atomWithLazy, atomWithObservable, atomWithReducer, atomWithRefresh, atomWithReset, atomWithStorage, createJSONStorage, freezeAtom, freezeAtomCreator, loadable, selectAtom, splitAtom, withStorageValidator as unstable_withStorageValidator, unwrap };\n","import slug from \"slug\";\n/** Sentinel value for atoms that are not set. */\nexport const NOT_SET = \"NOT_SET\";\n/* Will suspend until the atom is set elsewhere.\n * Returns a promise that will never resolve of type T.\n *\n * Makes use of Jotai's \"async forever\" pattern as described here https://jotai.org/docs/guides/async#async-forever\n */\nexport function suspendUntilSet() {\n return new Promise(() => { });\n}\n/** Makes a URL component for a drive. */\nexport function makeDriveUrlComponent(drive) {\n if (!drive)\n return \"\";\n return `/d/${slug(drive.header.slug)}`;\n}\n/** Makes a URL component for a node. */\nexport function makeNodeUrlComponent(node) {\n if (!node)\n return \"\";\n const nodeName = node.name;\n if (!nodeName)\n return slug(node.id);\n return slug(`${nodeName}-${node.id}`);\n}\n/** Extracts the node slug from a path.\n *\n * The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.\n */\nfunction extractNodeSlug(path) {\n const match = /^\\/d\\/[^/]+\\/([^/]+)$/.exec(path);\n return match ? match[1] : undefined;\n}\n/** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */\nfunction findUuid(input) {\n if (!input)\n return undefined;\n const uuidRegex = /\\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\b/;\n const match = uuidRegex.exec(input);\n return match ? match[0] : undefined;\n}\n/** Extracts the node id from a path. */\nexport function extractNodeFromPath(path) {\n const nodeSlug = extractNodeSlug(path);\n if (!nodeSlug)\n return undefined;\n const uuid = findUuid(nodeSlug);\n if (!uuid)\n return undefined;\n return uuid;\n}\n/** Extracts the node name, slug, or id from a path. */\nexport function extractNodeNameOrSlugOrIdFromPath(path) {\n const nodeSlug = extractNodeSlug(path);\n const nodeId = findUuid(nodeSlug);\n if (nodeId)\n return nodeId;\n return nodeSlug;\n}\n/** Extracts the drive slug from a path.\n * Used for extracting drive ids from drive slugs in the URL.\n * Expects the path to be in the format `/d/<drive-slug>`.\n */\nexport function extractDriveFromPath(path) {\n const match = /^\\/d\\/([^/]+)/.exec(path);\n return match ? match[1] : null;\n}\n/** Legacy function that makes a slug from a node name.\n * Used for compatibility with the old URL structure in Connect.\n */\nexport function makeNodeSlugFromNodeName(name) {\n return name.replaceAll(/\\s/g, \"-\");\n}\n/** Sets the selected drive and node from the URL.\n *\n * Both the selected drive id and selected node id begin in the NOT_SET state, so they will suspend unless set by this function or another implementation.\n *\n * If the URL is in the format `/d/<drive-slug>`, the selected drive will be set.\n * If the URL is in the format `/d/<drive-slug>/<node-slug>`, the selected drive and node will be set.\n */\nexport async function setSelectedDriveAndNodeFromUrl(reactor, setSelectedDrive, setSelectedNode, shouldNavigate) {\n if (typeof window === \"undefined\")\n return;\n if (!shouldNavigate)\n return;\n if (!reactor)\n return;\n const path = window.location.pathname;\n const drive = await handleDriveFromUrl(reactor, path, setSelectedDrive);\n handleNodeFromUrl(drive, path, setSelectedNode);\n}\nasync function handleDriveFromUrl(reactor, path, setSelectedDrive) {\n const driveSlug = extractDriveFromPath(path);\n const driveIds = await reactor.getDrives();\n const drives = await Promise.all(driveIds.map((id) => reactor.getDrive(id)));\n const drive = drives.find((d) => d.header.slug === driveSlug || d.header.id === driveSlug);\n setSelectedDrive(drive?.header.id);\n return drive;\n}\nfunction handleNodeFromUrl(drive, path, setSelectedNode) {\n const nodeIdOrSlugOrNameFromPath = extractNodeNameOrSlugOrIdFromPath(path);\n const nodes = drive?.state.global.nodes;\n const node = nodes?.find((n) => n.id === nodeIdOrSlugOrNameFromPath ||\n makeNodeSlugFromNodeName(n.name) === nodeIdOrSlugOrNameFromPath);\n setSelectedNode(node?.id);\n}\n//# sourceMappingURL=utils.js.map","import { useAtomValue, useSetAtom } from \"jotai\";\nimport { useCallback } from \"react\";\nimport { drivesAtom, loadableDrivesAtom, loadableSelectedDriveAtom, selectedDriveAtom, unwrappedDrivesAtom, unwrappedSelectedDriveAtom, } from \"./atoms.js\";\nimport { makeDriveUrlComponent } from \"./utils.js\";\n/** Returns a loadable of the drives for a reactor. */\nexport function useDrives() {\n return useAtomValue(loadableDrivesAtom);\n}\n/** Returns a resolved promise of the drives for a reactor. */\nexport function useUnwrappedDrives() {\n return useAtomValue(unwrappedDrivesAtom);\n}\n/** Refreshes the drives for a reactor. */\nexport function useRefreshDrives() {\n return useSetAtom(drivesAtom);\n}\n/** Returns a loadable of a drive for a reactor by id. */\nexport function useDriveById(id) {\n const loadableDrives = useDrives();\n if (loadableDrives.state !== \"hasData\")\n return loadableDrives;\n if (!id)\n return { state: \"hasData\", data: undefined };\n const data = loadableDrives.data;\n return {\n state: \"hasData\",\n data: data.find((d) => d.header.id === id),\n };\n}\n/** Returns a resolved promise of a drive for a reactor by id. */\nexport function useUnwrappedDriveById(id) {\n const drives = useUnwrappedDrives();\n if (!id)\n return undefined;\n return drives?.find((d) => d.header.id === id);\n}\n/** Returns a loadable of the selected drive */\nexport function useSelectedDrive() {\n return useAtomValue(loadableSelectedDriveAtom);\n}\n/** Returns a resolved promise of the selected drive */\nexport function useUnwrappedSelectedDrive() {\n return useAtomValue(unwrappedSelectedDriveAtom);\n}\n/** Returns a function that sets the selected drive with a drive id.\n *\n * If `shouldNavigate` is true, the URL will be updated to the new drive.\n * `shouldNavigate` can be overridden by passing a different value to the callback.\n */\nexport function useSetSelectedDrive(shouldNavigate = true) {\n const drives = useUnwrappedDrives();\n const setSelectedDrive = useSetAtom(selectedDriveAtom);\n return useCallback((driveId, _shouldNavigate = shouldNavigate) => {\n setSelectedDrive(driveId);\n const drive = drives?.find((d) => d.header.id === driveId);\n const newPathname = makeDriveUrlComponent(drive);\n if (typeof window !== \"undefined\" && _shouldNavigate) {\n window.history.pushState(null, \"\", newPathname);\n }\n }, [drives, setSelectedDrive]);\n}\n/** Returns a loadable of the remote URL for a drive. */\nexport function useDriveRemoteUrl(driveId) {\n const loadableDrive = useDriveById(driveId);\n const pullResponderUrl = useDrivePullResponderUrl(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: undefined };\n if (\"remoteUrl\" in drive.state.global) {\n const remoteUrl = drive.state.global.remoteUrl;\n if (typeof remoteUrl === \"string\") {\n return {\n state: \"hasData\",\n data: remoteUrl,\n };\n }\n }\n if (pullResponderUrl.state !== \"hasData\")\n return pullResponderUrl;\n return {\n state: \"hasData\",\n data: undefined,\n };\n}\n/** Returns a loadable of the pull responder trigger for a drive. */\nexport function useDrivePullResponderTrigger(driveId) {\n const loadableDrive = useDriveById(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: undefined };\n const pullResponder = drive.state.local.triggers.find((trigger) => trigger.type === \"PullResponder\");\n return {\n state: \"hasData\",\n data: pullResponder,\n };\n}\n/** Returns a loadable of the pull responder URL for a drive. */\nexport function useDrivePullResponderUrl(driveId) {\n const pullResponder = useDrivePullResponderTrigger(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (pullResponder.state !== \"hasData\")\n return pullResponder;\n const trigger = pullResponder.data;\n return {\n state: \"hasData\",\n data: trigger?.data?.url,\n };\n}\n/** Returns a loadable of whether a drive is remote. */\nexport function useDriveIsRemote(driveId) {\n const remoteUrl = useDriveRemoteUrl(driveId);\n const pullResponder = useDrivePullResponderTrigger(driveId);\n if (!driveId)\n return { state: \"hasData\", data: false };\n if (remoteUrl.state === \"loading\" || pullResponder.state === \"loading\")\n return {\n state: \"loading\",\n };\n if (remoteUrl.state === \"hasError\")\n return {\n state: \"hasError\",\n error: remoteUrl.error,\n };\n if (pullResponder.state === \"hasError\")\n return {\n state: \"hasError\",\n error: pullResponder.error,\n };\n return {\n state: \"hasData\",\n data: remoteUrl.data !== undefined || pullResponder.data !== undefined,\n };\n}\n/** Returns a loadable of the sharing type for a drive. */\nexport function useDriveSharingType(driveId) {\n const loadableDrive = useDriveById(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: undefined };\n return {\n state: \"hasData\",\n data: getDriveSharingType(drive),\n };\n}\n/** Returns a loadable of whether a drive is available offline. */\nexport function useIsDriveAvailableOffline(driveId) {\n const loadableDrive = useDriveById(driveId);\n if (!driveId)\n return { state: \"hasData\", data: false };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: false };\n return {\n state: \"hasData\",\n data: getDriveAvailableOffline(drive),\n };\n}\n/** Returns the sharing type for a drive. */\nexport function getDriveSharingType(drive) {\n if (!drive)\n return \"PUBLIC\";\n const isReadDrive = \"readContext\" in drive;\n const { sharingType: _sharingType } = !isReadDrive\n ? drive.state.local\n : { sharingType: \"PUBLIC\" };\n const __sharingType = _sharingType?.toUpperCase();\n return (__sharingType === \"PRIVATE\" ? \"LOCAL\" : __sharingType);\n}\n/** Returns whether a drive is available offline. */\nexport function getDriveAvailableOffline(drive) {\n if (!drive)\n return false;\n const isReadDrive = \"readContext\" in drive;\n const { availableOffline: _availableOffline } = !isReadDrive\n ? drive.state.local\n : { availableOffline: false };\n return _availableOffline ?? false;\n}\n//# sourceMappingURL=drives.js.map","import { useAtomValue, useSetAtom } from \"jotai\";\nimport { useCallback } from \"react\";\nimport { loadableNodesAtom, setSelectedNodeAtom, unwrappedNodesAtom, } from \"./atoms.js\";\nimport { useSelectedDrive } from \"./drives.js\";\nimport { useSelectedFolder } from \"./folders.js\";\nimport { extractDriveFromPath, makeNodeUrlComponent } from \"./utils.js\";\n/** Returns a loadable of the nodes for a reactor. */\nexport function useNodes() {\n return useAtomValue(loadableNodesAtom);\n}\n/** Returns a function that sets the selected node with a node id.\n *\n * If `shouldNavigate` is true, the URL will be updated to the new node.\n * `shouldNavigate` can be overridden by passing a different value to the callback.\n */\nexport function useSetSelectedNode(shouldNavigate = true) {\n const nodes = useUnwrappedNodes();\n const setSelectedNode = useSetAtom(setSelectedNodeAtom);\n return useCallback((nodeId, _shouldNavigate = shouldNavigate) => {\n setSelectedNode(nodeId);\n if (typeof window !== \"undefined\" && _shouldNavigate) {\n const driveSlugFromPath = extractDriveFromPath(window.location.pathname);\n const node = nodes?.find((n) => n.id === nodeId);\n if (!node) {\n window.history.pushState(null, \"\", `/d/${driveSlugFromPath}`);\n }\n else {\n const nodeSlug = makeNodeUrlComponent(node);\n window.history.pushState(null, \"\", `/d/${driveSlugFromPath}/${nodeSlug}`);\n }\n }\n }, [setSelectedNode, nodes]);\n}\n/** Returns a resolved promise of the nodes for a reactor. */\nexport function useUnwrappedNodes() {\n return useAtomValue(unwrappedNodesAtom);\n}\n/** Returns a resolved promise of a node for a reactor by id. */\nexport function useNodeById(id) {\n const unwrappedNodes = useUnwrappedNodes();\n return unwrappedNodes?.find((n) => n.id === id);\n}\n/** Returns a resolved promise of the parent folder for a node. */\nexport function useParentFolder(id) {\n const node = useNodeById(id);\n return node?.parentFolder ?? undefined;\n}\n/** Returns a loadable of the path to a node. */\nexport function useNodePath(id) {\n const loadableNodes = useNodes();\n const loadableSelectedDrive = useSelectedDrive();\n if (loadableSelectedDrive.state !== \"hasData\")\n return loadableSelectedDrive;\n if (loadableNodes.state !== \"hasData\")\n return loadableNodes;\n const nodes = loadableNodes.data;\n const selectedDrive = loadableSelectedDrive.data;\n if (!nodes || !selectedDrive)\n return { state: \"hasData\", data: undefined };\n const driveFolderNode = {\n id: selectedDrive.header.id,\n name: selectedDrive.state.global.name,\n kind: \"FOLDER\",\n parentFolder: null,\n };\n const path = [driveFolderNode];\n let current = nodes.find((n) => n.id === id);\n while (current) {\n path.unshift(current);\n if (!current.parentFolder)\n break;\n current = nodes.find((n) => n.id === current?.parentFolder);\n }\n return { state: \"hasData\", data: path.reverse() };\n}\n/** Returns a loadable of the child nodes for the selected drive or folder. */\nexport function useChildNodes() {\n const nodes = useNodes();\n const selectedFolder = useSelectedFolder();\n if (nodes.state !== \"hasData\")\n return nodes;\n if (selectedFolder.state !== \"hasData\")\n return selectedFolder;\n const selectedFolderId = selectedFolder.data?.id;\n if (!selectedFolderId)\n return {\n state: \"hasData\",\n data: sortNodesByName(nodes.data ?? []),\n };\n return {\n state: \"hasData\",\n data: sortNodesByName(nodes.data?.filter((n) => n.parentFolder === selectedFolderId) ?? []),\n };\n}\n/** Returns the kind of a node. */\nexport function useNodeKind(id) {\n const unwrappedNodes = useUnwrappedNodes();\n if (!unwrappedNodes)\n return undefined;\n const node = unwrappedNodes.find((n) => n.id === id);\n if (!node)\n return undefined;\n return node.kind.toUpperCase();\n}\n/** Sorts nodes by name. */\nexport function sortNodesByName(nodes) {\n return nodes.toSorted((a, b) => a.name.localeCompare(b.name));\n}\n/** Returns whether a node is a file. */\nexport function isFileNodeKind(node) {\n if (!node)\n return false;\n return node.kind.toUpperCase() === \"FILE\";\n}\n/** Returns whether a node is a folder. */\nexport function isFolderNodeKind(node) {\n if (!node)\n return false;\n return node.kind.toUpperCase() === \"FOLDER\";\n}\n//# sourceMappingURL=nodes.js.map","import { atom } from \"jotai\";\nimport { atomWithRefresh, loadable, unwrap } from \"jotai/utils\";\nimport { isFolderNodeKind } from \"./nodes.js\";\nimport { NOT_SET, suspendUntilSet } from \"./utils.js\";\n/* Reactor */\n/** Holds the reactor instance.\n *\n * Like all base atoms, it is not meant to be accessed or updated directly.\n * Starts off with the sentinel value NOT_SET.\n */\nconst baseReactorAtom = atom(NOT_SET);\nbaseReactorAtom.debugLabel = \"baseReactorAtom\";\n/** Returns a promise of the reactor instance if it is set, otherwise suspends until it is set. */\nexport const reactorAtom = atom(async (get) => {\n const reactor = get(baseReactorAtom);\n // Suspends until the reactor is set.\n if (reactor === NOT_SET)\n return suspendUntilSet();\n return reactor;\n});\nreactorAtom.debugLabel = \"reactorAtom\";\n/** Sets the reactor instance. Only runs if the baseReactorAtom is NOT_SET. */\nexport const initializeReactorAtom = atom(null, (get, set, reactor) => {\n const baseReactor = get(baseReactorAtom);\n // Only runs if the baseReactorAtom is NOT_SET.\n if (baseReactor === NOT_SET) {\n set(baseReactorAtom, reactor);\n }\n});\ninitializeReactorAtom.debugLabel = \"setReactorAtom\";\n/** Returns a Loadable of the reactor instance. */\nexport const loadableReactorAtom = loadable(reactorAtom);\nloadableReactorAtom.debugLabel = \"loadableReactorAtom\";\n/** Returns a resolved promise of the reactor instance. */\nexport const unwrappedReactorAtom = unwrap(reactorAtom);\nunwrappedReactorAtom.debugLabel = \"unwrappedReactorAtom\";\n/* Drives */\n/** Holds a promise of the drives for a given reactor.\n *\n * Suspends until the reactor is set.\n *\n * Does not provide a direct setter, instead it uses `atomWithRefresh` which will refetch the drives from the reactor when called.\n * See https://jotai.org/docs/utilities/resettable#atomwithrefresh for more details.\n */\nexport const drivesAtom = atomWithRefresh(async (get) => {\n const loadableReactor = get(loadableReactorAtom);\n // Suspends until the reactor is set.\n if (loadableReactor.state !== \"hasData\")\n return suspendUntilSet();\n const reactor = loadableReactor.data;\n // If the reactor is not set, returns an empty array.\n if (!reactor)\n return [];\n const driveIds = await reactor.getDrives();\n const drives = new Array();\n for (const driveId of driveIds) {\n const drive = await reactor.getDrive(driveId);\n drives.push(drive);\n }\n return drives;\n});\ndrivesAtom.debugLabel = \"drivesAtom\";\n/** Returns a Loadable of the drives for a given reactor. */\nexport const loadableDrivesAtom = loadable(drivesAtom);\nloadableDrivesAtom.debugLabel = \"loadableDrivesAtom\";\n/** Returns a resolved promise of the drives for a given reactor. */\nexport const unwrappedDrivesAtom = unwrap(drivesAtom);\nunwrappedDrivesAtom.debugLabel = \"unwrappedDrivesAtom\";\n/** Holds the selected drive id.\n *\n * Like all base atoms, it is not meant to be accessed or updated directly.\n * Starts off with the sentinel value NOT_SET.\n *\n * When this value changes, the data for the selected drive is re-fetched from the drives atom.\n */\nconst baseSelectedDriveIdAtom = atom(NOT_SET);\nbaseSelectedDriveIdAtom.debugLabel = \"baseSelectedDriveIdAtom\";\n/** Returns a promise of the selected drive.\n *\n * Provides a setter which receives a drive id and updates the baseSelectedDriveIdAtom.\n *\n * Suspends until the reactor's drives are set and the selected drive id is set.\n * If the selected drive id is set as undefined, returns a resolved promise of undefined.\n *\n * When the selected drive is set, the selected node id is also set to undefined, since by definition selecting a new drive means navigating to the root of the new drive.\n */\nexport const selectedDriveAtom = atom((get) => {\n const driveId = get(baseSelectedDriveIdAtom);\n const loadableDrives = get(loadableDrivesAtom);\n // Suspends until the reactor's drives are set and the selected drive id is set.\n if (driveId === NOT_SET || loadableDrives.state !== \"hasData\")\n return suspendUntilSet();\n const drives = loadableDrives.data;\n return drives.find((drive) => drive.header.id === driveId);\n}, (_get, set, driveId) => {\n // Updates the baseSelectedDriveIdAtom.\n set(baseSelectedDriveIdAtom, driveId);\n // Resets the selected node id.\n set(selectedNodeIdAtom, undefined);\n});\nselectedDriveAtom.debugLabel = \"selectedDriveAtom\";\n/** Returns a Loadable of the selected drive. */\nexport const loadableSelectedDriveAtom = loadable(selectedDriveAtom);\nloadableSelectedDriveAtom.debugLabel = \"loadableSelectedDriveAtom\";\n/** Returns a resolved promise of the selected drive. */\nexport const unwrappedSelectedDriveAtom = unwrap(selectedDriveAtom);\nunwrappedSelectedDriveAtom.debugLabel = \"unwrappedSelectedDriveAtom\";\n/* Nodes */\n/** Holds a promise of the nodes for the selected drive.\n *\n * Derived from selectedDrive.state.global.nodes.\n *\n * Suspends until the selected drive is set.\n *\n * If the selected drive is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, since it is derived from the selected drive.\n */\nexport const nodesAtom = atom(async (get) => {\n const loadableSelectedDrive = get(loadableSelectedDriveAtom);\n // Suspends until the selected drive is set.\n if (loadableSelectedDrive.state !== \"hasData\")\n return suspendUntilSet();\n const drive = loadableSelectedDrive.data;\n return drive?.state.global.nodes;\n});\nnodesAtom.debugLabel = \"nodesAtom\";\nexport const loadableNodesAtom = loadable(nodesAtom);\nloadableNodesAtom.debugLabel = \"loadableNodesAtom\";\nexport const unwrappedNodesAtom = unwrap(nodesAtom);\nunwrappedNodesAtom.debugLabel = \"unwrappedNodesAtom\";\n/** Holds the selected node id.\n *\n * This id comes from the drive's nodes, which can be the id for a document or for a meta item such as a folder.\n *\n * Like all base atoms, it is not meant to be accessed or updated directly.\n * Starts off with the sentinel value NOT_SET.\n *\n * When this value changes, the data for the selected node is re-fetched from the nodes atom.\n */\nexport const selectedNodeIdAtom = atom(NOT_SET);\nselectedNodeIdAtom.debugLabel = \"selectedNodeIdAtom\";\n/** Sets the selected node via a node id. */\nexport const setSelectedNodeAtom = atom(null, (_get, set, nodeId) => {\n set(selectedNodeIdAtom, nodeId);\n});\nsetSelectedNodeAtom.debugLabel = \"setSelectedNodeAtom\";\n/** Returns a promise of the selected folder.\n *\n * A \"folder\" is a meta item that contains other nodes. It is not a document itself. Folder nodes have a `kind` of `folder` or `FOLDER`.\n *\n * Suspends until the nodes are set and the selected node id is set.\n * If the selected node id is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, since it is derived from the selected node id.\n */\nexport const selectedFolderAtom = atom((get) => {\n const loadableNodes = get(loadableNodesAtom);\n const nodeId = get(selectedNodeIdAtom);\n // Suspends until the nodes are set and the selected node id is set.\n if (nodeId === NOT_SET || loadableNodes.state !== \"hasData\")\n return suspendUntilSet();\n const nodes = loadableNodes.data;\n // Filters the nodes to only include folder nodes.\n const folderNodes = nodes?.filter(isFolderNodeKind);\n // Returns the folder node with the selected node id.\n return folderNodes?.find((node) => node.id === nodeId);\n});\nselectedFolderAtom.debugLabel = \"selectedFolderAtom\";\n/** Returns a Loadable of the selected folder. */\nexport const loadableSelectedFolderAtom = loadable(selectedFolderAtom);\nloadableSelectedFolderAtom.debugLabel = \"loadableSelectedFolderAtom\";\n/** Returns a resolved promise of the selected folder. */\nexport const unwrappedSelectedFolderAtom = unwrap(selectedFolderAtom);\nunwrappedSelectedFolderAtom.debugLabel = \"unwrappedSelectedFolderAtom\";\n/* Documents */\n/** Holds a promise of the documents for the selected drive.\n *\n * Suspends until the selected drive is set.\n *\n * If the selected drive is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, instead it uses `atomWithRefresh` which will refetch the documents from the reactor when called.\n * See https://jotai.org/docs/utilities/resettable#atomwithrefresh for more details.\n */\nexport const documentsAtom = atomWithRefresh(async (get) => {\n const loadableReactor = get(loadableReactorAtom);\n const loadableDrive = get(loadableSelectedDriveAtom);\n // Suspends until the selected drive is set.\n if (loadableReactor.state !== \"hasData\" || loadableDrive.state !== \"hasData\")\n return suspendUntilSet();\n const reactor = loadableReactor.data;\n const driveId = loadableDrive.data?.header.id;\n // If the reactor or drive id is not set, returns an empty array.\n if (!reactor || !driveId)\n return [];\n const documentIds = await reactor.getDocuments(driveId);\n const documents = await Promise.all(documentIds.map((id) => reactor.getDocument(driveId, id)));\n return documents;\n});\ndocumentsAtom.debugLabel = \"documentsAtom\";\n/** Returns a Loadable of the documents for the selected drive. */\nexport const loadableDocumentsAtom = loadable(documentsAtom);\nloadableDocumentsAtom.debugLabel = \"loadableDocumentsAtom\";\n/** Returns a resolved promise of the documents for the selected drive. */\nexport const unwrappedDocumentsAtom = unwrap(documentsAtom);\nunwrappedDocumentsAtom.debugLabel = \"unwrappedDocumentsAtom\";\n/** Returns a promise of the selected document.\n *\n * A \"document\" is a PHDocument. This id is the document's id, and this id will also be found in the drive's nodes. We use the same id for finding a node in a drive and for identifying a document in the reactor.\n *\n * Suspends until the documents are set and the selected node id is set.\n * If the selected node id is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, since it is derived from the selected node id.\n */\nexport const selectedDocumentAtom = atom((get) => {\n const loadableDocuments = get(loadableDocumentsAtom);\n const nodeId = get(selectedNodeIdAtom);\n // Suspends until the documents are set and the selected node id is set.\n if (nodeId === NOT_SET || loadableDocuments.state !== \"hasData\")\n return suspendUntilSet();\n const documents = loadableDocuments.data;\n return documents.find((document) => document.header.id === nodeId);\n});\nselectedDocumentAtom.debugLabel = \"selectedDocumentAtom\";\n/** Returns a Loadable of the selected document. */\nexport const loadableSelectedDocumentAtom = loadable(selectedDocumentAtom);\nloadableSelectedDocumentAtom.debugLabel = \"loadableSelectedDocumentAtom\";\n/** Returns a resolved promise of the selected document. */\nexport const unwrappedSelectedDocumentAtom = unwrap(selectedDocumentAtom);\nunwrappedSelectedDocumentAtom.debugLabel = \"unwrappedSelectedDocumentAtom\";\n/* PH Packages */\nexport const phPackagesAtom = atom(Promise.resolve(undefined));\nphPackagesAtom.debugLabel = \"phPackagesAtom\";\nexport const setPhPackagesAtom = atom(null, (_get, set, phPackages) => {\n set(phPackagesAtom, Promise.resolve(phPackages));\n});\nsetPhPackagesAtom.debugLabel = \"setPhPackagesAtom\";\nexport const loadablePhPackagesAtom = loadable(phPackagesAtom);\nloadablePhPackagesAtom.debugLabel = \"loadablePhPackagesAtom\";\nexport const unwrappedPhPackagesAtom = unwrap(phPackagesAtom);\nunwrappedPhPackagesAtom.debugLabel = \"unwrappedPhPackagesAtom\";\n/* Document Model Modules */\nexport const documentModelModulesAtom = atomWithRefresh(async (get) => {\n const loadablePhPackages = get(loadablePhPackagesAtom);\n if (loadablePhPackages.state !== \"hasData\")\n return suspendUntilSet();\n const phPackages = loadablePhPackages.data;\n return phPackages?.map((p) => p.documentModels).flat();\n});\ndocumentModelModulesAtom.debugLabel = \"documentModelModulesAtom\";\nexport const loadableDocumentModelModulesAtom = loadable(documentModelModulesAtom);\nloadableDocumentModelModulesAtom.debugLabel =\n \"loadableDocumentModelModulesAtom\";\nexport const unwrappedDocumentModelModulesAtom = unwrap(documentModelModulesAtom);\nunwrappedDocumentModelModulesAtom.debugLabel =\n \"unwrappedDocumentModelModulesAtom\";\n/* Editors */\nexport const editorModulesAtom = atomWithRefresh(async (get) => {\n const loadablePhPackages = get(loadablePhPackagesAtom);\n if (loadablePhPackages.state !== \"hasData\")\n return suspendUntilSet();\n const phPackages = loadablePhPackages.data;\n return phPackages?.map((p) => p.editors).flat();\n});\neditorModulesAtom.debugLabel = \"editorModulesAtom\";\nexport const loadableEditorModulesAtom = loadable(editorModulesAtom);\nloadableEditorModulesAtom.debugLabel = \"loadableEditorModulesAtom\";\nexport const unwrappedEditorModulesAtom = unwrap(editorModulesAtom);\nunwrappedEditorModulesAtom.debugLabel = \"unwrappedEditorModulesAtom\";\n/* Processor Manager */\nexport const processorManagerAtom = atom(undefined);\nprocessorManagerAtom.debugLabel = \"processorManagerAtom\";\n/* Config */\nexport const configAtom = atom({\n appVersion: undefined,\n studioMode: false,\n warnOutdatedApp: false,\n routerBasename: undefined,\n analyticsDatabaseName: undefined,\n sentry: {\n dsn: undefined,\n env: undefined,\n tracing: undefined,\n },\n content: {\n showSearchBar: true,\n showDocumentModelSelectionSetting: true,\n },\n drives: {\n addDriveEnabled: true,\n sections: {\n LOCAL: {\n enabled: true,\n allowAdd: true,\n allowDelete: true,\n },\n CLOUD: {\n enabled: true,\n allowAdd: true,\n allowDelete: true,\n },\n PUBLIC: {\n enabled: true,\n allowAdd: true,\n allowDelete: true,\n },\n },\n },\n gaTrackingId: undefined,\n phCliVersion: undefined,\n});\nconfigAtom.debugLabel = \"configAtom\";\n//# sourceMappingURL=atoms.js.map","import { useAtomValue, useSetAtom } from \"jotai\";\nimport { documentsAtom, loadableDocumentsAtom, loadableSelectedDocumentAtom, unwrappedDocumentsAtom, unwrappedSelectedDocumentAtom, } from \"./atoms.js\";\n/** Returns a loadable of the documents for a reactor. */\nexport function useDocuments() {\n return useAtomValue(loadableDocumentsAtom);\n}\n/** Returns a resolved promise of the documents for a reactor. */\nexport function useUnwrappedDocuments() {\n return useAtomValue(unwrappedDocumentsAtom);\n}\n/** Refreshes the documents for a reactor. */\nexport function useRefreshDocuments() {\n return useSetAtom(documentsAtom);\n}\n/** Returns a loadable of the selected document. */\nexport function useSelectedDocument() {\n return useAtomValue(loadableSelectedDocumentAtom);\n}\n/** Returns a resolved promise of the selected document. */\nexport function useUnwrappedSelectedDocument() {\n return useAtomValue(unwrappedSelectedDocumentAtom);\n}\n/** Returns a loadable of a document for a reactor by id. */\nexport function useDocumentById(id) {\n const documents = useDocuments();\n if (documents.state !== \"hasData\")\n return documents;\n if (!id)\n return { state: \"hasData\", data: undefined };\n const document = documents.data.find((d) => d.header.id === id);\n return { state: \"hasData\", data: document };\n}\n/** Returns a resolved promise of a document for a reactor by id. */\nexport function useUnwrappedDocumentById(id) {\n const documents = useUnwrappedDocuments();\n if (!id)\n return undefined;\n return documents?.find((d) => d.header.id === id);\n}\n//# sourceMappingURL=documents.js.map","import { useCallback } from \"react\";\nimport { useRefreshDocuments } from \"./documents.js\";\nimport { useRefreshDrives } from \"./drives.js\";\n/** Returns a function that refreshes the drives and documents for a reactor. */\nexport function useSyncDrivesAndDocumentsWithReactor() {\n const refreshDrives = useRefreshDrives();\n const refreshDocuments = useRefreshDocuments();\n return useCallback(() => {\n refreshDrives();\n refreshDocuments();\n }, [refreshDrives, refreshDocuments]);\n}\n//# sourceMappingURL=syncing.js.map","import { childLogger, SynchronizationUnitNotFoundError, } from \"document-drive\";\nimport { useAtomValue, useSetAtom } from \"jotai\";\nimport { useCallback, useEffect } from \"react\";\nimport { initializeReactorAtom, loadableReactorAtom, selectedDriveAtom, setSelectedNodeAtom, unwrappedReactorAtom, } from \"./atoms.js\";\nimport { useSyncDrivesAndDocumentsWithReactor } from \"./syncing.js\";\nimport { setSelectedDriveAndNodeFromUrl } from \"./utils.js\";\nconst logger = childLogger([\"state\", \"reactor\"]);\n/** Returns a loadable of the reactor. */\nexport function useReactor() {\n return useAtomValue(loadableReactorAtom);\n}\n/** Returns the unwrapped reactor. */\nexport function useUnwrappedReactor() {\n return useAtomValue(unwrappedReactorAtom);\n}\n/** Initializes the reactor.\n *\n * Creates the reactor and sets the selected drive and node from the URL if `shouldNavigate` is true.\n * Subscribes to the reactor's events and refreshes the drives and documents when they change.\n *\n * If the reactor is already initialized, does nothing.\n */\nexport function useInitializeReactor(createReactor, shouldNavigate = true) {\n const unwrappedReactor = useUnwrappedReactor();\n const setReactor = useSetAtom(initializeReactorAtom);\n const setSelectedDrive = useSetAtom(selectedDriveAtom);\n const setSelectedNode = useSetAtom(setSelectedNodeAtom);\n const refresh = useSyncDrivesAndDocumentsWithReactor();\n useEffect(() => {\n // If the reactor is already initialized, do nothing.\n if (unwrappedReactor)\n return;\n async function initializeReactor() {\n // Create the reactor instance.\n const reactor = await createReactor();\n // Subscribe to the reactor's events.\n reactor.on(\"syncStatus\", (event, status, error) => {\n logger.verbose(\"syncStatus\", event, status, error);\n refresh();\n });\n reactor.on(\"strandUpdate\", () => {\n logger.verbose(\"strandUpdate\");\n refresh();\n });\n reactor.on(\"defaultRemoteDrive\", () => {\n logger.verbose(\"defaultRemoteDrive\");\n refresh();\n });\n // Set the reactor instance atom.\n setReactor(reactor);\n // Set the selected drive and node from the URL if `shouldNavigate` is true.\n await setSelectedDriveAndNodeFromUrl(reactor, setSelectedDrive, setSelectedNode, shouldNavigate);\n }\n initializeReactor().catch(logger.error);\n }, [setReactor, createReactor, refresh, shouldNavigate]);\n}\nexport function useGetSyncStatusSync() {\n const reactor = useUnwrappedReactor();\n const getSyncStatusSync = useCallback((syncId, sharingType) => {\n if (sharingType === \"LOCAL\")\n return;\n if (!reactor) {\n return \"INITIAL_SYNC\";\n }\n try {\n const syncStatus = reactor.getSyncStatus(syncId);\n if (syncStatus instanceof SynchronizationUnitNotFoundError)\n return \"INITIAL_SYNC\";\n return syncStatus;\n }\n catch (error) {\n logger.error(error);\n return \"ERROR\";\n }\n }, [reactor]);\n return getSyncStatusSync;\n}\n//# sourceMappingURL=reactor.js.map","import {\n InternalDevTools\n} from \"./chunk-HLGSGNDX.esm.mjs\";\nimport {\n useAtomDevtools,\n useAtomsDebugValue,\n useAtomsDevtools,\n useAtomsSnapshot,\n useGotoAtomsSnapshot\n} from \"./chunk-K3M223F4.esm.mjs\";\n\n// src/index.ts\nvar DevTools = process.env.NODE_ENV !== \"production\" ? InternalDevTools : () => null;\nexport {\n DevTools,\n useAtomDevtools,\n useAtomsDebugValue,\n useAtomsDevtools,\n useAtomsSnapshot,\n useGotoAtomsSnapshot\n};\n","import { createStore } from \"jotai\";\n/** The atom store for the app.\n *\n * All derived hooks should use this store.\n */\nexport const atomStore = createStore();\n//# sourceMappingURL=store.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Provider } from \"jotai\";\nimport { DevTools } from \"jotai-devtools\";\nimport \"jotai-devtools/styles.css\";\nimport { useInitializeReactor } from \"./reactor.js\";\nimport { atomStore } from \"./store.js\";\nfunction InitReactor({ reactor }) {\n useInitializeReactor(() => Promise.resolve(reactor));\n return null;\n}\n/** Provides the atom store to the app.\n *\n * This is the top-level provider for the atom store.\n *\n * It is used to provide the atom store to the app.\n *\n * It should only be used once in the app and must appear before any `<Suspense>` boundaries.\n *\n * Includes the Jotai DevTools for debugging.\n */\nexport function AtomStoreProvider({ reactor, children, }) {\n return (_jsxs(Provider, { store: atomStore, children: [_jsx(DevTools, { store: atomStore }), reactor && _jsx(InitReactor, { reactor: reactor }), children] }));\n}\n//# sourceMappingURL=store-provider.js.map","import { lazy, StrictMode, Suspense } from 'react';\nimport '../i18n';\n\nimport { AtomStoreProvider } from '@powerhousedao/common';\nimport { AppSkeleton } from './app-skeleton.js';\n\nconst App = lazy(() => import('./app.js'));\nconst CookieBanner = lazy(() =>\n import('./cookie-banner.js').then(m => ({ default: m.CookieBanner })),\n);\n\nconst ModalManager = lazy(() =>\n import('./modal/modal.js').then(m => ({ default: m.ModalManager })),\n);\n\nexport const AppLoader = (\n <StrictMode>\n <AtomStoreProvider>\n <Suspense fallback={<AppSkeleton />} name=\"AppLoader\">\n <App />\n </Suspense>\n <Suspense name=\"CookieBanner\">\n <ModalManager>\n <CookieBanner />\n </ModalManager>\n </Suspense>\n </AtomStoreProvider>\n </StrictMode>\n);\n","import { createRoot } from 'react-dom/client';\nimport { AppLoader } from './components/app-loader.js';\n\nfunction renderApp(element: HTMLElement) {\n createRoot(element).render(AppLoader);\n}\n\nconst AppElement = document.getElementById('app');\nif (!AppElement) {\n throw new Error('#app element not found!');\n}\n\nrenderApp(AppElement);\n"],"file":"assets/index.BDEjD6s0.js"}
1
+ {"version":3,"mappings":";uUAEMA,GAAQ,QACXC,EAAkB,aAAuB,UAAY,aAAe,QAAU,EACjF,EAgVMC,EAAmBC,GAAM,OAAQA,GAAK,KAAO,OAASA,EAAE,OAAU,WAsBxE,SAASC,GAAkBC,EAAmB,IAAM,CAClD,GAAI,CACF,OAAO,OAAO,mBACPC,EAAG,EACLL,EAAkB,aAAuB,UAAY,cACpD,OAAO,OAAW,KACpB,QAAQ,KAAKK,CAAC,EAGlB,MAAO,CAEX,EAAGC,EAAS,CACV,IAAIC,EACJ,IAAIC,EACAC,EACJ,MAAMC,EAAU,CACd,QAAS,CAACC,EAA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CAAE,QAAAzF,GAAW,CAC9B,OAAA6E,GAAqB,IAAM,QAAQ,QAAQ7E,CAAO,CAAC,EAC5C,IACX,CAWO,SAAS0F,GAAkB,CAAE,QAAA1F,EAAS,SAAA2F,GAAa,CACtD,OAAQC,EAAMC,GAAU,CAAE,MAAON,EAAW,SAAU,CAACO,EAAKR,GAAU,CAAE,MAAOC,CAAS,CAAE,EAAGvF,GAAW8F,EAAKL,GAAa,CAAE,QAASzF,CAAO,CAAE,EAAG2F,CAAQ,EAAG,CAChK,CChBA,MAAMI,GAAMC,EAAK,IAAAC,EAAA,IAAM,OAAO,mBAAU,OAAApF,KAAA,0DAAC,EACnCqF,GAAeF,EAAK,UACtB,OAAO,6BAAoB,6DAAE,SAAW,CAAE,QAASpI,EAAE,cAAe,CACxE,EAEMuI,GAAeH,EAAK,UACtB,OAAO,qBAAkB,2CAAE,SAAW,CAAE,QAASpI,EAAE,cAAe,CACtE,EAEawI,GACTC,EAACC,GAAA,CACG,SAAAC,EAACb,GAAA,CACG,UAAAW,EAACG,EAAA,CAAS,SAAUH,EAACI,GAAA,EAAY,EAAI,KAAK,YACtC,SAAAJ,EAACN,GAAA,EAAI,EACT,EACAM,EAACG,GAAS,KAAK,eACX,WAACL,GAAA,CACG,SAAAE,EAACH,GAAA,EAAa,EAClB,EACJ,GACJ,EACJ,ECxBJ,SAASQ,GAAUC,EAAsB,CACrCC,GAAWD,CAAO,EAAE,OAAOP,EAAS,CACxC,CAEA,MAAMS,GAAa,SAAS,eAAe,KAAK,EAChD,GAAI,CAACA,GACD,MAAM,IAAI,MAAM,yBAAyB,EAG7CH,GAAUG,EAAU","names":["RESET","__vite_import_meta_env__","isPromiseLike$3","x","createJSONStorage","getStringStorage","e","options","_a","lastStr","lastValue","storage","key","initialValue","_a2","_b","parse","str2","str","newValue","createHandleSubscribe","subscriber2","callback","v","subscriber","storageEventCallback","defaultStorage","atomWithStorage","baseAtom","atom","setAtom","unsub","get","set","update","nextValue","resolvedValue","cache1$1","memo1","create","dep1","isPromiseLike$1","p","LOADING","loadable","anAtom","loadableCache","refreshAtom","derivedAtom","setSelf","value","error","promise","cached1","data","cached2","_get","c","getCached","m","k","cache1","memo2","dep2","cache2","isPromiseLike","defaultFallback","unwrap","fallback","promiseErrorCache","promiseResultCache","promiseAndValueAtom","prev","state","args","atomWithRefresh","read","write","atomWithLazy","makeInitial","a","NOT_SET","suspendUntilSet","extractNodeSlug","path","match","findUuid","input","extractNodeNameOrSlugOrIdFromPath","nodeSlug","nodeId","extractDriveFromPath","makeNodeSlugFromNodeName","name","setSelectedDriveAndNodeFromUrl","reactor","setSelectedDrive","setSelectedNode","shouldNavigate","drive","handleDriveFromUrl","handleNodeFromUrl","driveSlug","driveIds","id","nodeIdOrSlugOrNameFromPath","nodes","node","n","useRefreshDrives","useSetAtom","drivesAtom","isFolderNodeKind","baseReactorAtom","reactorAtom","initializeReactorAtom","loadableReactorAtom","unwrappedReactorAtom","loadableReactor","drives","driveId","loadableDrivesAtom","unwrappedDrivesAtom","baseSelectedDriveIdAtom","selectedDriveAtom","loadableDrives","selectedNodeIdAtom","loadableSelectedDriveAtom","unwrappedSelectedDriveAtom","nodesAtom","loadableSelectedDrive","loadableNodesAtom","unwrappedNodesAtom","setSelectedNodeAtom","selectedFolderAtom","loadableNodes","folderNodes","loadableSelectedFolderAtom","unwrappedSelectedFolderAtom","documentsAtom","loadableDrive","documentIds","loadableDocumentsAtom","unwrappedDocumentsAtom","selectedDocumentAtom","loadableDocuments","document","loadableSelectedDocumentAtom","unwrappedSelectedDocumentAtom","phPackagesAtom","setPhPackagesAtom","phPackages","loadablePhPackagesAtom","unwrappedPhPackagesAtom","documentModelModulesAtom","loadablePhPackages","loadableDocumentModelModulesAtom","unwrappedDocumentModelModulesAtom","editorModulesAtom","loadableEditorModulesAtom","unwrappedEditorModulesAtom","processorManagerAtom","configAtom","useRefreshDocuments","useSyncDrivesAndDocumentsWithReactor","refreshDrives","refreshDocuments","useCallback","logger","childLogger","useUnwrappedReactor","useAtomValue","useInitializeReactor","createReactor","unwrappedReactor","setReactor","refresh","useEffect","initializeReactor","event","status","DevTools","atomStore","createStore","InitReactor","AtomStoreProvider","children","_jsxs","Provider","_jsx","App","lazy","__vitePreload","CookieBanner","ModalManager","AppLoader","jsx","StrictMode","jsxs","Suspense","AppSkeleton","renderApp","element","createRoot","AppElement"],"ignoreList":[0,8],"sources":["../../../../node_modules/.pnpm/jotai@2.12.5_@types+react@18.3.23_react@18.3.1/node_modules/jotai/esm/vanilla/utils.mjs","../../../../packages/common/dist/state/utils.js","../../../../packages/common/dist/state/drives.js","../../../../packages/common/dist/state/nodes.js","../../../../packages/common/dist/state/atoms.js","../../../../packages/common/dist/state/documents.js","../../../../packages/common/dist/state/syncing.js","../../../../packages/common/dist/state/reactor.js","../../../../node_modules/.pnpm/jotai-devtools@0.12.0_@types+react@18.3.23_react-dom@18.3.1_react@18.3.1__react@18.3.1__c8b464b01737ba84c54b4cf01b222909/node_modules/jotai-devtools/dist/index.esm.mjs","../../../../packages/common/dist/state/store.js","../../../../packages/common/dist/state/store-provider.js","../../src/components/app-loader.tsx","../../src/index.ts"],"sourcesContent":["import { atom } from 'jotai/vanilla';\n\nconst RESET = Symbol(\n (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" ? \"RESET\" : \"\"\n);\n\nfunction atomWithReset(initialValue) {\n const anAtom = atom(\n initialValue,\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(anAtom)) : update;\n set(anAtom, nextValue === RESET ? initialValue : nextValue);\n }\n );\n return anAtom;\n}\n\nfunction atomWithReducer(initialValue, reducer) {\n return atom(initialValue, function(get, set, action) {\n set(this, reducer(get(this), action));\n });\n}\n\nfunction atomFamily(initializeAtom, areEqual) {\n let shouldRemove = null;\n const atoms = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Set();\n const createAtom = (param) => {\n let item;\n if (areEqual === void 0) {\n item = atoms.get(param);\n } else {\n for (const [key, value] of atoms) {\n if (areEqual(key, param)) {\n item = value;\n break;\n }\n }\n }\n if (item !== void 0) {\n if (shouldRemove == null ? void 0 : shouldRemove(item[1], param)) {\n createAtom.remove(param);\n } else {\n return item[0];\n }\n }\n const newAtom = initializeAtom(param);\n atoms.set(param, [newAtom, Date.now()]);\n notifyListeners(\"CREATE\", param, newAtom);\n return newAtom;\n };\n const notifyListeners = (type, param, atom) => {\n for (const listener of listeners) {\n listener({ type, param, atom });\n }\n };\n createAtom.unstable_listen = (callback) => {\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n };\n createAtom.getParams = () => atoms.keys();\n createAtom.remove = (param) => {\n if (areEqual === void 0) {\n if (!atoms.has(param)) return;\n const [atom] = atoms.get(param);\n atoms.delete(param);\n notifyListeners(\"REMOVE\", param, atom);\n } else {\n for (const [key, [atom]] of atoms) {\n if (areEqual(key, param)) {\n atoms.delete(key);\n notifyListeners(\"REMOVE\", key, atom);\n break;\n }\n }\n }\n };\n createAtom.setShouldRemove = (fn) => {\n shouldRemove = fn;\n if (!shouldRemove) return;\n for (const [key, [atom, createdAt]] of atoms) {\n if (shouldRemove(createdAt, key)) {\n atoms.delete(key);\n notifyListeners(\"REMOVE\", key, atom);\n }\n }\n };\n return createAtom;\n}\n\nconst getCached$2 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$3 = /* @__PURE__ */ new WeakMap();\nconst memo3 = (create, dep1, dep2, dep3) => {\n const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$3, dep1);\n const cache3 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache2, dep2);\n return getCached$2(create, cache3, dep3);\n};\nfunction selectAtom(anAtom, selector, equalityFn = Object.is) {\n return memo3(\n () => {\n const EMPTY = Symbol();\n const selectValue = ([value, prevSlice]) => {\n if (prevSlice === EMPTY) {\n return selector(value);\n }\n const slice = selector(value, prevSlice);\n return equalityFn(prevSlice, slice) ? prevSlice : slice;\n };\n const derivedAtom = atom((get) => {\n const prev = get(derivedAtom);\n const value = get(anAtom);\n return selectValue([value, prev]);\n });\n derivedAtom.init = EMPTY;\n return derivedAtom;\n },\n anAtom,\n selector,\n equalityFn\n );\n}\n\nconst frozenAtoms = /* @__PURE__ */ new WeakSet();\nconst deepFreeze = (value) => {\n if (typeof value !== \"object\" || value === null) {\n return value;\n }\n Object.freeze(value);\n const propNames = Object.getOwnPropertyNames(value);\n for (const name of propNames) {\n deepFreeze(value[name]);\n }\n return value;\n};\nfunction freezeAtom(anAtom) {\n if (frozenAtoms.has(anAtom)) {\n return anAtom;\n }\n frozenAtoms.add(anAtom);\n const origRead = anAtom.read;\n anAtom.read = function(get, options) {\n return deepFreeze(origRead.call(this, get, options));\n };\n if (\"write\" in anAtom) {\n const origWrite = anAtom.write;\n anAtom.write = function(get, set, ...args) {\n return origWrite.call(\n this,\n get,\n (...setArgs) => {\n if (setArgs[0] === anAtom) {\n setArgs[1] = deepFreeze(setArgs[1]);\n }\n return set(...setArgs);\n },\n ...args\n );\n };\n }\n return anAtom;\n}\nfunction freezeAtomCreator(createAtom) {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n console.warn(\n \"[DEPRECATED] freezeAtomCreator is deprecated, define it on users end\"\n );\n }\n return (...args) => freezeAtom(createAtom(...args));\n}\n\nconst getCached$1 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1$2 = /* @__PURE__ */ new WeakMap();\nconst memo2$1 = (create, dep1, dep2) => {\n const cache2 = getCached$1(() => /* @__PURE__ */ new WeakMap(), cache1$2, dep1);\n return getCached$1(create, cache2, dep2);\n};\nconst cacheKeyForEmptyKeyExtractor = {};\nconst isWritable = (atom2) => !!atom2.write;\nconst isFunction = (x) => typeof x === \"function\";\nfunction splitAtom(arrAtom, keyExtractor) {\n return memo2$1(\n () => {\n const mappingCache = /* @__PURE__ */ new WeakMap();\n const getMapping = (arr, prev) => {\n let mapping = mappingCache.get(arr);\n if (mapping) {\n return mapping;\n }\n const prevMapping = prev && mappingCache.get(prev);\n const atomList = [];\n const keyList = [];\n arr.forEach((item, index) => {\n const key = keyExtractor ? keyExtractor(item) : index;\n keyList[index] = key;\n const cachedAtom = prevMapping && prevMapping.atomList[prevMapping.keyList.indexOf(key)];\n if (cachedAtom) {\n atomList[index] = cachedAtom;\n return;\n }\n const read = (get) => {\n const prev2 = get(mappingAtom);\n const currArr = get(arrAtom);\n const mapping2 = getMapping(currArr, prev2 == null ? void 0 : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= currArr.length) {\n const prevItem = arr[getMapping(arr).keyList.indexOf(key)];\n if (prevItem) {\n return prevItem;\n }\n throw new Error(\"splitAtom: index out of bounds for read\");\n }\n return currArr[index2];\n };\n const write = (get, set, update) => {\n const prev2 = get(mappingAtom);\n const arr2 = get(arrAtom);\n const mapping2 = getMapping(arr2, prev2 == null ? void 0 : prev2.arr);\n const index2 = mapping2.keyList.indexOf(key);\n if (index2 < 0 || index2 >= arr2.length) {\n throw new Error(\"splitAtom: index out of bounds for write\");\n }\n const nextItem = isFunction(update) ? update(arr2[index2]) : update;\n if (!Object.is(arr2[index2], nextItem)) {\n set(arrAtom, [\n ...arr2.slice(0, index2),\n nextItem,\n ...arr2.slice(index2 + 1)\n ]);\n }\n };\n atomList[index] = isWritable(arrAtom) ? atom(read, write) : atom(read);\n });\n if (prevMapping && prevMapping.keyList.length === keyList.length && prevMapping.keyList.every((x, i) => x === keyList[i])) {\n mapping = prevMapping;\n } else {\n mapping = { arr, atomList, keyList };\n }\n mappingCache.set(arr, mapping);\n return mapping;\n };\n const mappingAtom = atom((get) => {\n const prev = get(mappingAtom);\n const arr = get(arrAtom);\n const mapping = getMapping(arr, prev == null ? void 0 : prev.arr);\n return mapping;\n });\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n mappingAtom.debugPrivate = true;\n }\n mappingAtom.init = void 0;\n const splittedAtom = isWritable(arrAtom) ? atom(\n (get) => get(mappingAtom).atomList,\n (get, set, action) => {\n switch (action.type) {\n case \"remove\": {\n const index = get(splittedAtom).indexOf(action.atom);\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n ...arr.slice(index + 1)\n ]);\n }\n break;\n }\n case \"insert\": {\n const index = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index >= 0) {\n const arr = get(arrAtom);\n set(arrAtom, [\n ...arr.slice(0, index),\n action.value,\n ...arr.slice(index)\n ]);\n }\n break;\n }\n case \"move\": {\n const index1 = get(splittedAtom).indexOf(action.atom);\n const index2 = action.before ? get(splittedAtom).indexOf(action.before) : get(splittedAtom).length;\n if (index1 >= 0 && index2 >= 0) {\n const arr = get(arrAtom);\n if (index1 < index2) {\n set(arrAtom, [\n ...arr.slice(0, index1),\n ...arr.slice(index1 + 1, index2),\n arr[index1],\n ...arr.slice(index2)\n ]);\n } else {\n set(arrAtom, [\n ...arr.slice(0, index2),\n arr[index1],\n ...arr.slice(index2, index1),\n ...arr.slice(index1 + 1)\n ]);\n }\n }\n break;\n }\n }\n }\n ) : atom((get) => get(mappingAtom).atomList);\n return splittedAtom;\n },\n arrAtom,\n keyExtractor || cacheKeyForEmptyKeyExtractor\n );\n}\n\nfunction atomWithDefault(getDefault) {\n const EMPTY = Symbol();\n const overwrittenAtom = atom(EMPTY);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n overwrittenAtom.debugPrivate = true;\n }\n const anAtom = atom(\n (get, options) => {\n const overwritten = get(overwrittenAtom);\n if (overwritten !== EMPTY) {\n return overwritten;\n }\n return getDefault(get, options);\n },\n (get, set, update) => {\n if (update === RESET) {\n set(overwrittenAtom, EMPTY);\n } else if (typeof update === \"function\") {\n const prevValue = get(anAtom);\n set(overwrittenAtom, update(prevValue));\n } else {\n set(overwrittenAtom, update);\n }\n }\n );\n return anAtom;\n}\n\nconst isPromiseLike$3 = (x) => typeof (x == null ? void 0 : x.then) === \"function\";\nfunction withStorageValidator(validator) {\n return (unknownStorage) => {\n const storage = {\n ...unknownStorage,\n getItem: (key, initialValue) => {\n const validate = (value2) => {\n if (!validator(value2)) {\n return initialValue;\n }\n return value2;\n };\n const value = unknownStorage.getItem(key, initialValue);\n if (isPromiseLike$3(value)) {\n return value.then(validate);\n }\n return validate(value);\n }\n };\n return storage;\n };\n}\nfunction createJSONStorage(getStringStorage = () => {\n try {\n return window.localStorage;\n } catch (e) {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n if (typeof window !== \"undefined\") {\n console.warn(e);\n }\n }\n return void 0;\n }\n}, options) {\n var _a;\n let lastStr;\n let lastValue;\n const storage = {\n getItem: (key, initialValue) => {\n var _a2, _b;\n const parse = (str2) => {\n str2 = str2 || \"\";\n if (lastStr !== str2) {\n try {\n lastValue = JSON.parse(str2, options == null ? void 0 : options.reviver);\n } catch (e) {\n return initialValue;\n }\n lastStr = str2;\n }\n return lastValue;\n };\n const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;\n if (isPromiseLike$3(str)) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (key, newValue) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem(\n key,\n JSON.stringify(newValue, options == null ? void 0 : options.replacer)\n );\n },\n removeItem: (key) => {\n var _a2;\n return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key);\n }\n };\n const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => {\n let newValue;\n try {\n newValue = JSON.parse(v || \"\");\n } catch (e) {\n newValue = initialValue;\n }\n callback(newValue);\n });\n let subscriber;\n try {\n subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;\n } catch (e) {\n }\n if (!subscriber && typeof window !== \"undefined\" && typeof window.addEventListener === \"function\" && window.Storage) {\n subscriber = (key, callback) => {\n if (!(getStringStorage() instanceof window.Storage)) {\n return () => {\n };\n }\n const storageEventCallback = (e) => {\n if (e.storageArea === getStringStorage() && e.key === key) {\n callback(e.newValue);\n }\n };\n window.addEventListener(\"storage\", storageEventCallback);\n return () => {\n window.removeEventListener(\"storage\", storageEventCallback);\n };\n };\n }\n if (subscriber) {\n storage.subscribe = createHandleSubscribe(subscriber);\n }\n return storage;\n}\nconst defaultStorage = createJSONStorage();\nfunction atomWithStorage(key, initialValue, storage = defaultStorage, options) {\n const getOnInit = options == null ? void 0 : options.getOnInit;\n const baseAtom = atom(\n getOnInit ? storage.getItem(key, initialValue) : initialValue\n );\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n baseAtom.debugPrivate = true;\n }\n baseAtom.onMount = (setAtom) => {\n setAtom(storage.getItem(key, initialValue));\n let unsub;\n if (storage.subscribe) {\n unsub = storage.subscribe(key, setAtom, initialValue);\n }\n return unsub;\n };\n const anAtom = atom(\n (get) => get(baseAtom),\n (get, set, update) => {\n const nextValue = typeof update === \"function\" ? update(get(baseAtom)) : update;\n if (nextValue === RESET) {\n set(baseAtom, initialValue);\n return storage.removeItem(key);\n }\n if (isPromiseLike$3(nextValue)) {\n return nextValue.then((resolvedValue) => {\n set(baseAtom, resolvedValue);\n return storage.setItem(key, resolvedValue);\n });\n }\n set(baseAtom, nextValue);\n return storage.setItem(key, nextValue);\n }\n );\n return anAtom;\n}\n\nconst isPromiseLike$2 = (x) => typeof (x == null ? void 0 : x.then) === \"function\";\nfunction atomWithObservable(getObservable, options) {\n const returnResultData = (result) => {\n if (\"e\" in result) {\n throw result.e;\n }\n return result.d;\n };\n const observableResultAtom = atom((get) => {\n var _a;\n let observable = getObservable(get);\n const itself = (_a = observable[Symbol.observable]) == null ? void 0 : _a.call(observable);\n if (itself) {\n observable = itself;\n }\n let resolve;\n const makePending = () => new Promise((r) => {\n resolve = r;\n });\n const initialResult = options && \"initialValue\" in options ? {\n d: typeof options.initialValue === \"function\" ? options.initialValue() : options.initialValue\n } : makePending();\n let setResult;\n let lastResult;\n const listener = (result) => {\n lastResult = result;\n resolve == null ? void 0 : resolve(result);\n setResult == null ? void 0 : setResult(result);\n };\n let subscription;\n let timer;\n const isNotMounted = () => !setResult;\n const unsubscribe = () => {\n if (subscription) {\n subscription.unsubscribe();\n subscription = void 0;\n }\n };\n const start = () => {\n if (subscription) {\n clearTimeout(timer);\n subscription.unsubscribe();\n }\n subscription = observable.subscribe({\n next: (d) => listener({ d }),\n error: (e) => listener({ e }),\n complete: () => {\n }\n });\n if (isNotMounted() && (options == null ? void 0 : options.unstable_timeout)) {\n timer = setTimeout(unsubscribe, options.unstable_timeout);\n }\n };\n start();\n const resultAtom = atom(lastResult || initialResult);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n resultAtom.debugPrivate = true;\n }\n resultAtom.onMount = (update) => {\n setResult = update;\n if (lastResult) {\n update(lastResult);\n }\n if (subscription) {\n clearTimeout(timer);\n } else {\n start();\n }\n return () => {\n setResult = void 0;\n if (options == null ? void 0 : options.unstable_timeout) {\n timer = setTimeout(unsubscribe, options.unstable_timeout);\n } else {\n unsubscribe();\n }\n };\n };\n return [resultAtom, observable, makePending, start, isNotMounted];\n });\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n observableResultAtom.debugPrivate = true;\n }\n const observableAtom = atom(\n (get) => {\n const [resultAtom] = get(observableResultAtom);\n const result = get(resultAtom);\n if (isPromiseLike$2(result)) {\n return result.then(returnResultData);\n }\n return returnResultData(result);\n },\n (get, set, data) => {\n const [resultAtom, observable, makePending, start, isNotMounted] = get(observableResultAtom);\n if (\"next\" in observable) {\n if (isNotMounted()) {\n set(resultAtom, makePending());\n start();\n }\n observable.next(data);\n } else {\n throw new Error(\"observable is not subject\");\n }\n }\n );\n return observableAtom;\n}\n\nconst cache1$1 = /* @__PURE__ */ new WeakMap();\nconst memo1 = (create, dep1) => (cache1$1.has(dep1) ? cache1$1 : cache1$1.set(dep1, create())).get(dep1);\nconst isPromiseLike$1 = (p) => typeof (p == null ? void 0 : p.then) === \"function\";\nconst LOADING = { state: \"loading\" };\nfunction loadable(anAtom) {\n return memo1(() => {\n const loadableCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const derivedAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n let value;\n try {\n value = get(anAtom);\n } catch (error) {\n return { state: \"hasError\", error };\n }\n if (!isPromiseLike$1(value)) {\n return { state: \"hasData\", data: value };\n }\n const promise = value;\n const cached1 = loadableCache.get(promise);\n if (cached1) {\n return cached1;\n }\n promise.then(\n (data) => {\n loadableCache.set(promise, { state: \"hasData\", data });\n setSelf();\n },\n (error) => {\n loadableCache.set(promise, { state: \"hasError\", error });\n setSelf();\n }\n );\n const cached2 = loadableCache.get(promise);\n if (cached2) {\n return cached2;\n }\n loadableCache.set(promise, LOADING);\n return LOADING;\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n derivedAtom.debugPrivate = true;\n }\n return atom((get) => get(derivedAtom));\n }, anAtom);\n}\n\nconst getCached = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);\nconst cache1 = /* @__PURE__ */ new WeakMap();\nconst memo2 = (create, dep1, dep2) => {\n const cache2 = getCached(() => /* @__PURE__ */ new WeakMap(), cache1, dep1);\n return getCached(create, cache2, dep2);\n};\nconst isPromiseLike = (p) => typeof (p == null ? void 0 : p.then) === \"function\";\nconst defaultFallback = () => void 0;\nfunction unwrap(anAtom, fallback = defaultFallback) {\n return memo2(\n () => {\n const promiseErrorCache = /* @__PURE__ */ new WeakMap();\n const promiseResultCache = /* @__PURE__ */ new WeakMap();\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n const promiseAndValueAtom = atom(\n (get, { setSelf }) => {\n get(refreshAtom);\n const prev = get(promiseAndValueAtom);\n const promise = get(anAtom);\n if (!isPromiseLike(promise)) {\n return { v: promise };\n }\n if (promise !== (prev == null ? void 0 : prev.p)) {\n promise.then(\n (v) => {\n promiseResultCache.set(promise, v);\n setSelf();\n },\n (e) => {\n promiseErrorCache.set(promise, e);\n setSelf();\n }\n );\n }\n if (promiseErrorCache.has(promise)) {\n throw promiseErrorCache.get(promise);\n }\n if (promiseResultCache.has(promise)) {\n return {\n p: promise,\n v: promiseResultCache.get(promise)\n };\n }\n if (prev && \"v\" in prev) {\n return { p: promise, f: fallback(prev.v), v: prev.v };\n }\n return { p: promise, f: fallback() };\n },\n (_get, set) => {\n set(refreshAtom, (c) => c + 1);\n }\n );\n promiseAndValueAtom.init = void 0;\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n promiseAndValueAtom.debugPrivate = true;\n }\n return atom(\n (get) => {\n const state = get(promiseAndValueAtom);\n if (\"f\" in state) {\n return state.f;\n }\n return state.v;\n },\n (_get, set, ...args) => set(anAtom, ...args)\n );\n },\n anAtom,\n fallback\n );\n}\n\nfunction atomWithRefresh(read, write) {\n const refreshAtom = atom(0);\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n refreshAtom.debugPrivate = true;\n }\n return atom(\n (get, options) => {\n get(refreshAtom);\n return read(get, options);\n },\n (get, set, ...args) => {\n if (args.length === 0) {\n set(refreshAtom, (c) => c + 1);\n } else if (write) {\n return write(get, set, ...args);\n } else if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") {\n throw new Error(\"refresh must be called without arguments\");\n }\n }\n );\n}\n\nfunction atomWithLazy(makeInitial) {\n const a = atom(void 0);\n delete a.init;\n Object.defineProperty(a, \"init\", {\n get() {\n return makeInitial();\n }\n });\n return a;\n}\n\nexport { RESET, atomFamily, atomWithDefault, atomWithLazy, atomWithObservable, atomWithReducer, atomWithRefresh, atomWithReset, atomWithStorage, createJSONStorage, freezeAtom, freezeAtomCreator, loadable, selectAtom, splitAtom, withStorageValidator as unstable_withStorageValidator, unwrap };\n","import slug from \"slug\";\n/** Sentinel value for atoms that are not set. */\nexport const NOT_SET = \"NOT_SET\";\n/* Will suspend until the atom is set elsewhere.\n * Returns a promise that will never resolve of type T.\n *\n * Makes use of Jotai's \"async forever\" pattern as described here https://jotai.org/docs/guides/async#async-forever\n */\nexport function suspendUntilSet() {\n return new Promise(() => { });\n}\n/** Makes a URL component for a drive. */\nexport function makeDriveUrlComponent(drive) {\n if (!drive)\n return \"\";\n return `/d/${slug(drive.header.slug)}`;\n}\n/** Makes a URL component for a node. */\nexport function makeNodeUrlComponent(node) {\n if (!node)\n return \"\";\n const nodeName = node.name;\n if (!nodeName)\n return slug(node.id);\n return slug(`${nodeName}-${node.id}`);\n}\n/** Extracts the node slug from a path.\n *\n * The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.\n */\nfunction extractNodeSlug(path) {\n const match = /^\\/d\\/[^/]+\\/([^/]+)$/.exec(path);\n return match ? match[1] : undefined;\n}\n/** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */\nfunction findUuid(input) {\n if (!input)\n return undefined;\n const uuidRegex = /\\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\b/;\n const match = uuidRegex.exec(input);\n return match ? match[0] : undefined;\n}\n/** Extracts the node id from a path. */\nexport function extractNodeFromPath(path) {\n const nodeSlug = extractNodeSlug(path);\n if (!nodeSlug)\n return undefined;\n const uuid = findUuid(nodeSlug);\n if (!uuid)\n return undefined;\n return uuid;\n}\n/** Extracts the node name, slug, or id from a path. */\nexport function extractNodeNameOrSlugOrIdFromPath(path) {\n const nodeSlug = extractNodeSlug(path);\n const nodeId = findUuid(nodeSlug);\n if (nodeId)\n return nodeId;\n return nodeSlug;\n}\n/** Extracts the drive slug from a path.\n * Used for extracting drive ids from drive slugs in the URL.\n * Expects the path to be in the format `/d/<drive-slug>`.\n */\nexport function extractDriveFromPath(path) {\n const match = /^\\/d\\/([^/]+)/.exec(path);\n return match ? match[1] : null;\n}\n/** Legacy function that makes a slug from a node name.\n * Used for compatibility with the old URL structure in Connect.\n */\nexport function makeNodeSlugFromNodeName(name) {\n return name.replaceAll(/\\s/g, \"-\");\n}\n/** Sets the selected drive and node from the URL.\n *\n * Both the selected drive id and selected node id begin in the NOT_SET state, so they will suspend unless set by this function or another implementation.\n *\n * If the URL is in the format `/d/<drive-slug>`, the selected drive will be set.\n * If the URL is in the format `/d/<drive-slug>/<node-slug>`, the selected drive and node will be set.\n */\nexport async function setSelectedDriveAndNodeFromUrl(reactor, setSelectedDrive, setSelectedNode, shouldNavigate) {\n if (typeof window === \"undefined\")\n return;\n if (!shouldNavigate)\n return;\n if (!reactor)\n return;\n const path = window.location.pathname;\n const drive = await handleDriveFromUrl(reactor, path, setSelectedDrive);\n handleNodeFromUrl(drive, path, setSelectedNode);\n}\nasync function handleDriveFromUrl(reactor, path, setSelectedDrive) {\n const driveSlug = extractDriveFromPath(path);\n const driveIds = await reactor.getDrives();\n const drives = await Promise.all(driveIds.map((id) => reactor.getDrive(id)));\n const drive = drives.find((d) => d.header.slug === driveSlug || d.header.id === driveSlug);\n setSelectedDrive(drive?.header.id);\n return drive;\n}\nfunction handleNodeFromUrl(drive, path, setSelectedNode) {\n const nodeIdOrSlugOrNameFromPath = extractNodeNameOrSlugOrIdFromPath(path);\n const nodes = drive?.state.global.nodes;\n const node = nodes?.find((n) => n.id === nodeIdOrSlugOrNameFromPath ||\n makeNodeSlugFromNodeName(n.name) === nodeIdOrSlugOrNameFromPath);\n setSelectedNode(node?.id);\n}\n//# sourceMappingURL=utils.js.map","import { useAtomValue, useSetAtom } from \"jotai\";\nimport { useCallback } from \"react\";\nimport { drivesAtom, loadableDrivesAtom, loadableSelectedDriveAtom, selectedDriveAtom, unwrappedDrivesAtom, unwrappedSelectedDriveAtom, } from \"./atoms.js\";\nimport { makeDriveUrlComponent } from \"./utils.js\";\n/** Returns a loadable of the drives for a reactor. */\nexport function useDrives() {\n return useAtomValue(loadableDrivesAtom);\n}\n/** Returns a resolved promise of the drives for a reactor. */\nexport function useUnwrappedDrives() {\n return useAtomValue(unwrappedDrivesAtom);\n}\n/** Refreshes the drives for a reactor. */\nexport function useRefreshDrives() {\n return useSetAtom(drivesAtom);\n}\n/** Returns a loadable of a drive for a reactor by id. */\nexport function useDriveById(id) {\n const loadableDrives = useDrives();\n if (loadableDrives.state !== \"hasData\")\n return loadableDrives;\n if (!id)\n return { state: \"hasData\", data: undefined };\n const data = loadableDrives.data;\n return {\n state: \"hasData\",\n data: data.find((d) => d.header.id === id),\n };\n}\n/** Returns a resolved promise of a drive for a reactor by id. */\nexport function useUnwrappedDriveById(id) {\n const drives = useUnwrappedDrives();\n if (!id)\n return undefined;\n return drives?.find((d) => d.header.id === id);\n}\n/** Returns a loadable of the selected drive */\nexport function useSelectedDrive() {\n return useAtomValue(loadableSelectedDriveAtom);\n}\n/** Returns a resolved promise of the selected drive */\nexport function useUnwrappedSelectedDrive() {\n return useAtomValue(unwrappedSelectedDriveAtom);\n}\n/** Returns a function that sets the selected drive with a drive id.\n *\n * If `shouldNavigate` is true, the URL will be updated to the new drive.\n * `shouldNavigate` can be overridden by passing a different value to the callback.\n */\nexport function useSetSelectedDrive(shouldNavigate = true) {\n const drives = useUnwrappedDrives();\n const setSelectedDrive = useSetAtom(selectedDriveAtom);\n return useCallback((driveId, _shouldNavigate = shouldNavigate) => {\n setSelectedDrive(driveId);\n const drive = drives?.find((d) => d.header.id === driveId);\n const newPathname = makeDriveUrlComponent(drive);\n if (typeof window !== \"undefined\" && _shouldNavigate) {\n window.history.pushState(null, \"\", newPathname);\n }\n }, [drives, setSelectedDrive]);\n}\n/** Returns a loadable of the remote URL for a drive. */\nexport function useDriveRemoteUrl(driveId) {\n const loadableDrive = useDriveById(driveId);\n const pullResponderUrl = useDrivePullResponderUrl(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: undefined };\n if (\"remoteUrl\" in drive.state.global) {\n const remoteUrl = drive.state.global.remoteUrl;\n if (typeof remoteUrl === \"string\") {\n return {\n state: \"hasData\",\n data: remoteUrl,\n };\n }\n }\n if (pullResponderUrl.state !== \"hasData\")\n return pullResponderUrl;\n return {\n state: \"hasData\",\n data: undefined,\n };\n}\n/** Returns a loadable of the pull responder trigger for a drive. */\nexport function useDrivePullResponderTrigger(driveId) {\n const loadableDrive = useDriveById(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: undefined };\n const pullResponder = drive.state.local.triggers.find((trigger) => trigger.type === \"PullResponder\");\n return {\n state: \"hasData\",\n data: pullResponder,\n };\n}\n/** Returns a loadable of the pull responder URL for a drive. */\nexport function useDrivePullResponderUrl(driveId) {\n const pullResponder = useDrivePullResponderTrigger(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (pullResponder.state !== \"hasData\")\n return pullResponder;\n const trigger = pullResponder.data;\n return {\n state: \"hasData\",\n data: trigger?.data?.url,\n };\n}\n/** Returns a loadable of whether a drive is remote. */\nexport function useDriveIsRemote(driveId) {\n const remoteUrl = useDriveRemoteUrl(driveId);\n const pullResponder = useDrivePullResponderTrigger(driveId);\n if (!driveId)\n return { state: \"hasData\", data: false };\n if (remoteUrl.state === \"loading\" || pullResponder.state === \"loading\")\n return {\n state: \"loading\",\n };\n if (remoteUrl.state === \"hasError\")\n return {\n state: \"hasError\",\n error: remoteUrl.error,\n };\n if (pullResponder.state === \"hasError\")\n return {\n state: \"hasError\",\n error: pullResponder.error,\n };\n return {\n state: \"hasData\",\n data: remoteUrl.data !== undefined || pullResponder.data !== undefined,\n };\n}\n/** Returns a loadable of the sharing type for a drive. */\nexport function useDriveSharingType(driveId) {\n const loadableDrive = useDriveById(driveId);\n if (!driveId)\n return { state: \"hasData\", data: undefined };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: undefined };\n return {\n state: \"hasData\",\n data: getDriveSharingType(drive),\n };\n}\n/** Returns a loadable of whether a drive is available offline. */\nexport function useIsDriveAvailableOffline(driveId) {\n const loadableDrive = useDriveById(driveId);\n if (!driveId)\n return { state: \"hasData\", data: false };\n if (loadableDrive.state !== \"hasData\")\n return loadableDrive;\n const drive = loadableDrive.data;\n if (!drive)\n return { state: \"hasData\", data: false };\n return {\n state: \"hasData\",\n data: getDriveAvailableOffline(drive),\n };\n}\n/** Returns the sharing type for a drive. */\nexport function getDriveSharingType(drive) {\n if (!drive)\n return \"PUBLIC\";\n const isReadDrive = \"readContext\" in drive;\n const { sharingType: _sharingType } = !isReadDrive\n ? drive.state.local\n : { sharingType: \"PUBLIC\" };\n const __sharingType = _sharingType?.toUpperCase();\n return (__sharingType === \"PRIVATE\" ? \"LOCAL\" : __sharingType);\n}\n/** Returns whether a drive is available offline. */\nexport function getDriveAvailableOffline(drive) {\n if (!drive)\n return false;\n const isReadDrive = \"readContext\" in drive;\n const { availableOffline: _availableOffline } = !isReadDrive\n ? drive.state.local\n : { availableOffline: false };\n return _availableOffline ?? false;\n}\n//# sourceMappingURL=drives.js.map","import { useAtomValue, useSetAtom } from \"jotai\";\nimport { useCallback } from \"react\";\nimport { loadableNodesAtom, setSelectedNodeAtom, unwrappedNodesAtom, } from \"./atoms.js\";\nimport { useSelectedDrive } from \"./drives.js\";\nimport { useSelectedFolder } from \"./folders.js\";\nimport { extractDriveFromPath, makeNodeUrlComponent } from \"./utils.js\";\n/** Returns a loadable of the nodes for a reactor. */\nexport function useNodes() {\n return useAtomValue(loadableNodesAtom);\n}\n/** Returns a function that sets the selected node with a node id.\n *\n * If `shouldNavigate` is true, the URL will be updated to the new node.\n * `shouldNavigate` can be overridden by passing a different value to the callback.\n */\nexport function useSetSelectedNode(shouldNavigate = true) {\n const nodes = useUnwrappedNodes();\n const setSelectedNode = useSetAtom(setSelectedNodeAtom);\n return useCallback((nodeId, _shouldNavigate = shouldNavigate) => {\n setSelectedNode(nodeId);\n if (typeof window !== \"undefined\" && _shouldNavigate) {\n const driveSlugFromPath = extractDriveFromPath(window.location.pathname);\n const node = nodes?.find((n) => n.id === nodeId);\n if (!node) {\n window.history.pushState(null, \"\", `/d/${driveSlugFromPath}`);\n }\n else {\n const nodeSlug = makeNodeUrlComponent(node);\n window.history.pushState(null, \"\", `/d/${driveSlugFromPath}/${nodeSlug}`);\n }\n }\n }, [setSelectedNode, nodes]);\n}\n/** Returns a resolved promise of the nodes for a reactor. */\nexport function useUnwrappedNodes() {\n return useAtomValue(unwrappedNodesAtom);\n}\n/** Returns a resolved promise of a node for a reactor by id. */\nexport function useNodeById(id) {\n const unwrappedNodes = useUnwrappedNodes();\n return unwrappedNodes?.find((n) => n.id === id);\n}\n/** Returns a resolved promise of the parent folder for a node. */\nexport function useParentFolder(id) {\n const node = useNodeById(id);\n return node?.parentFolder ?? undefined;\n}\n/** Returns a loadable of the path to a node. */\nexport function useNodePath(id) {\n const loadableNodes = useNodes();\n const loadableSelectedDrive = useSelectedDrive();\n if (loadableSelectedDrive.state !== \"hasData\")\n return loadableSelectedDrive;\n if (loadableNodes.state !== \"hasData\")\n return loadableNodes;\n const nodes = loadableNodes.data;\n const selectedDrive = loadableSelectedDrive.data;\n if (!nodes || !selectedDrive)\n return { state: \"hasData\", data: undefined };\n const driveFolderNode = {\n id: selectedDrive.header.id,\n name: selectedDrive.state.global.name,\n kind: \"FOLDER\",\n parentFolder: null,\n };\n const path = [driveFolderNode];\n let current = nodes.find((n) => n.id === id);\n while (current) {\n path.unshift(current);\n if (!current.parentFolder)\n break;\n current = nodes.find((n) => n.id === current?.parentFolder);\n }\n return { state: \"hasData\", data: path.reverse() };\n}\n/** Returns a loadable of the child nodes for the selected drive or folder. */\nexport function useChildNodes() {\n const nodes = useNodes();\n const selectedFolder = useSelectedFolder();\n if (nodes.state !== \"hasData\")\n return nodes;\n if (selectedFolder.state !== \"hasData\")\n return selectedFolder;\n const selectedFolderId = selectedFolder.data?.id;\n if (!selectedFolderId)\n return {\n state: \"hasData\",\n data: sortNodesByName(nodes.data ?? []),\n };\n return {\n state: \"hasData\",\n data: sortNodesByName(nodes.data?.filter((n) => n.parentFolder === selectedFolderId) ?? []),\n };\n}\n/** Returns the kind of a node. */\nexport function useNodeKind(id) {\n const unwrappedNodes = useUnwrappedNodes();\n if (!unwrappedNodes)\n return undefined;\n const node = unwrappedNodes.find((n) => n.id === id);\n if (!node)\n return undefined;\n return node.kind.toUpperCase();\n}\n/** Sorts nodes by name. */\nexport function sortNodesByName(nodes) {\n return nodes.toSorted((a, b) => a.name.localeCompare(b.name));\n}\n/** Returns whether a node is a file. */\nexport function isFileNodeKind(node) {\n if (!node)\n return false;\n return node.kind.toUpperCase() === \"FILE\";\n}\n/** Returns whether a node is a folder. */\nexport function isFolderNodeKind(node) {\n if (!node)\n return false;\n return node.kind.toUpperCase() === \"FOLDER\";\n}\n//# sourceMappingURL=nodes.js.map","import { atom } from \"jotai\";\nimport { atomWithRefresh, loadable, unwrap } from \"jotai/utils\";\nimport { isFolderNodeKind } from \"./nodes.js\";\nimport { NOT_SET, suspendUntilSet } from \"./utils.js\";\n/* Reactor */\n/** Holds the reactor instance.\n *\n * Like all base atoms, it is not meant to be accessed or updated directly.\n * Starts off with the sentinel value NOT_SET.\n */\nconst baseReactorAtom = atom(NOT_SET);\nbaseReactorAtom.debugLabel = \"baseReactorAtom\";\n/** Returns a promise of the reactor instance if it is set, otherwise suspends until it is set. */\nexport const reactorAtom = atom(async (get) => {\n const reactor = get(baseReactorAtom);\n // Suspends until the reactor is set.\n if (reactor === NOT_SET)\n return suspendUntilSet();\n return reactor;\n});\nreactorAtom.debugLabel = \"reactorAtom\";\n/** Sets the reactor instance. Only runs if the baseReactorAtom is NOT_SET. */\nexport const initializeReactorAtom = atom(null, (get, set, reactor) => {\n const baseReactor = get(baseReactorAtom);\n // Only runs if the baseReactorAtom is NOT_SET.\n if (baseReactor === NOT_SET) {\n set(baseReactorAtom, reactor);\n }\n});\ninitializeReactorAtom.debugLabel = \"setReactorAtom\";\n/** Returns a Loadable of the reactor instance. */\nexport const loadableReactorAtom = loadable(reactorAtom);\nloadableReactorAtom.debugLabel = \"loadableReactorAtom\";\n/** Returns a resolved promise of the reactor instance. */\nexport const unwrappedReactorAtom = unwrap(reactorAtom);\nunwrappedReactorAtom.debugLabel = \"unwrappedReactorAtom\";\n/* Drives */\n/** Holds a promise of the drives for a given reactor.\n *\n * Suspends until the reactor is set.\n *\n * Does not provide a direct setter, instead it uses `atomWithRefresh` which will refetch the drives from the reactor when called.\n * See https://jotai.org/docs/utilities/resettable#atomwithrefresh for more details.\n */\nexport const drivesAtom = atomWithRefresh(async (get) => {\n const loadableReactor = get(loadableReactorAtom);\n // Suspends until the reactor is set.\n if (loadableReactor.state !== \"hasData\")\n return suspendUntilSet();\n const reactor = loadableReactor.data;\n // If the reactor is not set, returns an empty array.\n if (!reactor)\n return [];\n const driveIds = await reactor.getDrives();\n const drives = new Array();\n for (const driveId of driveIds) {\n const drive = await reactor.getDrive(driveId);\n drives.push(drive);\n }\n return drives;\n});\ndrivesAtom.debugLabel = \"drivesAtom\";\n/** Returns a Loadable of the drives for a given reactor. */\nexport const loadableDrivesAtom = loadable(drivesAtom);\nloadableDrivesAtom.debugLabel = \"loadableDrivesAtom\";\n/** Returns a resolved promise of the drives for a given reactor. */\nexport const unwrappedDrivesAtom = unwrap(drivesAtom);\nunwrappedDrivesAtom.debugLabel = \"unwrappedDrivesAtom\";\n/** Holds the selected drive id.\n *\n * Like all base atoms, it is not meant to be accessed or updated directly.\n * Starts off with the sentinel value NOT_SET.\n *\n * When this value changes, the data for the selected drive is re-fetched from the drives atom.\n */\nconst baseSelectedDriveIdAtom = atom(NOT_SET);\nbaseSelectedDriveIdAtom.debugLabel = \"baseSelectedDriveIdAtom\";\n/** Returns a promise of the selected drive.\n *\n * Provides a setter which receives a drive id and updates the baseSelectedDriveIdAtom.\n *\n * Suspends until the reactor's drives are set and the selected drive id is set.\n * If the selected drive id is set as undefined, returns a resolved promise of undefined.\n *\n * When the selected drive is set, the selected node id is also set to undefined, since by definition selecting a new drive means navigating to the root of the new drive.\n */\nexport const selectedDriveAtom = atom((get) => {\n const driveId = get(baseSelectedDriveIdAtom);\n const loadableDrives = get(loadableDrivesAtom);\n // Suspends until the reactor's drives are set and the selected drive id is set.\n if (driveId === NOT_SET || loadableDrives.state !== \"hasData\")\n return suspendUntilSet();\n const drives = loadableDrives.data;\n return drives.find((drive) => drive.header.id === driveId);\n}, (_get, set, driveId) => {\n // Updates the baseSelectedDriveIdAtom.\n set(baseSelectedDriveIdAtom, driveId);\n // Resets the selected node id.\n set(selectedNodeIdAtom, undefined);\n});\nselectedDriveAtom.debugLabel = \"selectedDriveAtom\";\n/** Returns a Loadable of the selected drive. */\nexport const loadableSelectedDriveAtom = loadable(selectedDriveAtom);\nloadableSelectedDriveAtom.debugLabel = \"loadableSelectedDriveAtom\";\n/** Returns a resolved promise of the selected drive. */\nexport const unwrappedSelectedDriveAtom = unwrap(selectedDriveAtom);\nunwrappedSelectedDriveAtom.debugLabel = \"unwrappedSelectedDriveAtom\";\n/* Nodes */\n/** Holds a promise of the nodes for the selected drive.\n *\n * Derived from selectedDrive.state.global.nodes.\n *\n * Suspends until the selected drive is set.\n *\n * If the selected drive is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, since it is derived from the selected drive.\n */\nexport const nodesAtom = atom(async (get) => {\n const loadableSelectedDrive = get(loadableSelectedDriveAtom);\n // Suspends until the selected drive is set.\n if (loadableSelectedDrive.state !== \"hasData\")\n return suspendUntilSet();\n const drive = loadableSelectedDrive.data;\n return drive?.state.global.nodes;\n});\nnodesAtom.debugLabel = \"nodesAtom\";\nexport const loadableNodesAtom = loadable(nodesAtom);\nloadableNodesAtom.debugLabel = \"loadableNodesAtom\";\nexport const unwrappedNodesAtom = unwrap(nodesAtom);\nunwrappedNodesAtom.debugLabel = \"unwrappedNodesAtom\";\n/** Holds the selected node id.\n *\n * This id comes from the drive's nodes, which can be the id for a document or for a meta item such as a folder.\n *\n * Like all base atoms, it is not meant to be accessed or updated directly.\n * Starts off with the sentinel value NOT_SET.\n *\n * When this value changes, the data for the selected node is re-fetched from the nodes atom.\n */\nexport const selectedNodeIdAtom = atom(NOT_SET);\nselectedNodeIdAtom.debugLabel = \"selectedNodeIdAtom\";\n/** Sets the selected node via a node id. */\nexport const setSelectedNodeAtom = atom(null, (_get, set, nodeId) => {\n set(selectedNodeIdAtom, nodeId);\n});\nsetSelectedNodeAtom.debugLabel = \"setSelectedNodeAtom\";\n/** Returns a promise of the selected folder.\n *\n * A \"folder\" is a meta item that contains other nodes. It is not a document itself. Folder nodes have a `kind` of `folder` or `FOLDER`.\n *\n * Suspends until the nodes are set and the selected node id is set.\n * If the selected node id is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, since it is derived from the selected node id.\n */\nexport const selectedFolderAtom = atom((get) => {\n const loadableNodes = get(loadableNodesAtom);\n const nodeId = get(selectedNodeIdAtom);\n // Suspends until the nodes are set and the selected node id is set.\n if (nodeId === NOT_SET || loadableNodes.state !== \"hasData\")\n return suspendUntilSet();\n const nodes = loadableNodes.data;\n // Filters the nodes to only include folder nodes.\n const folderNodes = nodes?.filter(isFolderNodeKind);\n // Returns the folder node with the selected node id.\n return folderNodes?.find((node) => node.id === nodeId);\n});\nselectedFolderAtom.debugLabel = \"selectedFolderAtom\";\n/** Returns a Loadable of the selected folder. */\nexport const loadableSelectedFolderAtom = loadable(selectedFolderAtom);\nloadableSelectedFolderAtom.debugLabel = \"loadableSelectedFolderAtom\";\n/** Returns a resolved promise of the selected folder. */\nexport const unwrappedSelectedFolderAtom = unwrap(selectedFolderAtom);\nunwrappedSelectedFolderAtom.debugLabel = \"unwrappedSelectedFolderAtom\";\n/* Documents */\n/** Holds a promise of the documents for the selected drive.\n *\n * Suspends until the selected drive is set.\n *\n * If the selected drive is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, instead it uses `atomWithRefresh` which will refetch the documents from the reactor when called.\n * See https://jotai.org/docs/utilities/resettable#atomwithrefresh for more details.\n */\nexport const documentsAtom = atomWithRefresh(async (get) => {\n const loadableReactor = get(loadableReactorAtom);\n const loadableDrive = get(loadableSelectedDriveAtom);\n // Suspends until the selected drive is set.\n if (loadableReactor.state !== \"hasData\" || loadableDrive.state !== \"hasData\")\n return suspendUntilSet();\n const reactor = loadableReactor.data;\n const driveId = loadableDrive.data?.header.id;\n // If the reactor or drive id is not set, returns an empty array.\n if (!reactor || !driveId)\n return [];\n const documentIds = await reactor.getDocuments(driveId);\n const documents = await Promise.all(documentIds.map((id) => reactor.getDocument(driveId, id)));\n return documents;\n});\ndocumentsAtom.debugLabel = \"documentsAtom\";\n/** Returns a Loadable of the documents for the selected drive. */\nexport const loadableDocumentsAtom = loadable(documentsAtom);\nloadableDocumentsAtom.debugLabel = \"loadableDocumentsAtom\";\n/** Returns a resolved promise of the documents for the selected drive. */\nexport const unwrappedDocumentsAtom = unwrap(documentsAtom);\nunwrappedDocumentsAtom.debugLabel = \"unwrappedDocumentsAtom\";\n/** Returns a promise of the selected document.\n *\n * A \"document\" is a PHDocument. This id is the document's id, and this id will also be found in the drive's nodes. We use the same id for finding a node in a drive and for identifying a document in the reactor.\n *\n * Suspends until the documents are set and the selected node id is set.\n * If the selected node id is set as undefined, returns a resolved promise of undefined.\n *\n * Does not provide a setter, since it is derived from the selected node id.\n */\nexport const selectedDocumentAtom = atom((get) => {\n const loadableDocuments = get(loadableDocumentsAtom);\n const nodeId = get(selectedNodeIdAtom);\n // Suspends until the documents are set and the selected node id is set.\n if (nodeId === NOT_SET || loadableDocuments.state !== \"hasData\")\n return suspendUntilSet();\n const documents = loadableDocuments.data;\n return documents.find((document) => document.header.id === nodeId);\n});\nselectedDocumentAtom.debugLabel = \"selectedDocumentAtom\";\n/** Returns a Loadable of the selected document. */\nexport const loadableSelectedDocumentAtom = loadable(selectedDocumentAtom);\nloadableSelectedDocumentAtom.debugLabel = \"loadableSelectedDocumentAtom\";\n/** Returns a resolved promise of the selected document. */\nexport const unwrappedSelectedDocumentAtom = unwrap(selectedDocumentAtom);\nunwrappedSelectedDocumentAtom.debugLabel = \"unwrappedSelectedDocumentAtom\";\n/* PH Packages */\nexport const phPackagesAtom = atom(Promise.resolve(undefined));\nphPackagesAtom.debugLabel = \"phPackagesAtom\";\nexport const setPhPackagesAtom = atom(null, (_get, set, phPackages) => {\n set(phPackagesAtom, Promise.resolve(phPackages));\n});\nsetPhPackagesAtom.debugLabel = \"setPhPackagesAtom\";\nexport const loadablePhPackagesAtom = loadable(phPackagesAtom);\nloadablePhPackagesAtom.debugLabel = \"loadablePhPackagesAtom\";\nexport const unwrappedPhPackagesAtom = unwrap(phPackagesAtom);\nunwrappedPhPackagesAtom.debugLabel = \"unwrappedPhPackagesAtom\";\n/* Document Model Modules */\nexport const documentModelModulesAtom = atomWithRefresh(async (get) => {\n const loadablePhPackages = get(loadablePhPackagesAtom);\n if (loadablePhPackages.state !== \"hasData\")\n return suspendUntilSet();\n const phPackages = loadablePhPackages.data;\n return phPackages?.map((p) => p.documentModels).flat();\n});\ndocumentModelModulesAtom.debugLabel = \"documentModelModulesAtom\";\nexport const loadableDocumentModelModulesAtom = loadable(documentModelModulesAtom);\nloadableDocumentModelModulesAtom.debugLabel =\n \"loadableDocumentModelModulesAtom\";\nexport const unwrappedDocumentModelModulesAtom = unwrap(documentModelModulesAtom);\nunwrappedDocumentModelModulesAtom.debugLabel =\n \"unwrappedDocumentModelModulesAtom\";\n/* Editors */\nexport const editorModulesAtom = atomWithRefresh(async (get) => {\n const loadablePhPackages = get(loadablePhPackagesAtom);\n if (loadablePhPackages.state !== \"hasData\")\n return suspendUntilSet();\n const phPackages = loadablePhPackages.data;\n return phPackages?.map((p) => p.editors).flat();\n});\neditorModulesAtom.debugLabel = \"editorModulesAtom\";\nexport const loadableEditorModulesAtom = loadable(editorModulesAtom);\nloadableEditorModulesAtom.debugLabel = \"loadableEditorModulesAtom\";\nexport const unwrappedEditorModulesAtom = unwrap(editorModulesAtom);\nunwrappedEditorModulesAtom.debugLabel = \"unwrappedEditorModulesAtom\";\n/* Processor Manager */\nexport const processorManagerAtom = atom(undefined);\nprocessorManagerAtom.debugLabel = \"processorManagerAtom\";\n/* Config */\nexport const configAtom = atom({\n appVersion: undefined,\n studioMode: false,\n warnOutdatedApp: false,\n routerBasename: undefined,\n analyticsDatabaseName: undefined,\n sentry: {\n dsn: undefined,\n env: undefined,\n tracing: undefined,\n },\n content: {\n showSearchBar: true,\n showDocumentModelSelectionSetting: true,\n },\n drives: {\n addDriveEnabled: true,\n sections: {\n LOCAL: {\n enabled: true,\n allowAdd: true,\n allowDelete: true,\n },\n CLOUD: {\n enabled: true,\n allowAdd: true,\n allowDelete: true,\n },\n PUBLIC: {\n enabled: true,\n allowAdd: true,\n allowDelete: true,\n },\n },\n },\n gaTrackingId: undefined,\n phCliVersion: undefined,\n});\nconfigAtom.debugLabel = \"configAtom\";\n//# sourceMappingURL=atoms.js.map","import { useAtomValue, useSetAtom } from \"jotai\";\nimport { documentsAtom, loadableDocumentsAtom, loadableSelectedDocumentAtom, unwrappedDocumentsAtom, unwrappedSelectedDocumentAtom, } from \"./atoms.js\";\n/** Returns a loadable of the documents for a reactor. */\nexport function useDocuments() {\n return useAtomValue(loadableDocumentsAtom);\n}\n/** Returns a resolved promise of the documents for a reactor. */\nexport function useUnwrappedDocuments() {\n return useAtomValue(unwrappedDocumentsAtom);\n}\n/** Refreshes the documents for a reactor. */\nexport function useRefreshDocuments() {\n return useSetAtom(documentsAtom);\n}\n/** Returns a loadable of the selected document. */\nexport function useSelectedDocument() {\n return useAtomValue(loadableSelectedDocumentAtom);\n}\n/** Returns a resolved promise of the selected document. */\nexport function useUnwrappedSelectedDocument() {\n return useAtomValue(unwrappedSelectedDocumentAtom);\n}\n/** Returns a loadable of a document for a reactor by id. */\nexport function useDocumentById(id) {\n const documents = useDocuments();\n if (documents.state !== \"hasData\")\n return documents;\n if (!id)\n return { state: \"hasData\", data: undefined };\n const document = documents.data.find((d) => d.header.id === id);\n return { state: \"hasData\", data: document };\n}\n/** Returns a resolved promise of a document for a reactor by id. */\nexport function useUnwrappedDocumentById(id) {\n const documents = useUnwrappedDocuments();\n if (!id)\n return undefined;\n return documents?.find((d) => d.header.id === id);\n}\n//# sourceMappingURL=documents.js.map","import { useCallback } from \"react\";\nimport { useRefreshDocuments } from \"./documents.js\";\nimport { useRefreshDrives } from \"./drives.js\";\n/** Returns a function that refreshes the drives and documents for a reactor. */\nexport function useSyncDrivesAndDocumentsWithReactor() {\n const refreshDrives = useRefreshDrives();\n const refreshDocuments = useRefreshDocuments();\n return useCallback(() => {\n refreshDrives();\n refreshDocuments();\n }, [refreshDrives, refreshDocuments]);\n}\n//# sourceMappingURL=syncing.js.map","import { childLogger, SynchronizationUnitNotFoundError, } from \"document-drive\";\nimport { useAtomValue, useSetAtom } from \"jotai\";\nimport { useCallback, useEffect } from \"react\";\nimport { initializeReactorAtom, loadableReactorAtom, selectedDriveAtom, setSelectedNodeAtom, unwrappedReactorAtom, } from \"./atoms.js\";\nimport { useSyncDrivesAndDocumentsWithReactor } from \"./syncing.js\";\nimport { setSelectedDriveAndNodeFromUrl } from \"./utils.js\";\nconst logger = childLogger([\"state\", \"reactor\"]);\n/** Returns a loadable of the reactor. */\nexport function useReactor() {\n return useAtomValue(loadableReactorAtom);\n}\n/** Returns the unwrapped reactor. */\nexport function useUnwrappedReactor() {\n return useAtomValue(unwrappedReactorAtom);\n}\n/** Initializes the reactor.\n *\n * Creates the reactor and sets the selected drive and node from the URL if `shouldNavigate` is true.\n * Subscribes to the reactor's events and refreshes the drives and documents when they change.\n *\n * If the reactor is already initialized, does nothing.\n */\nexport function useInitializeReactor(createReactor, shouldNavigate = true) {\n const unwrappedReactor = useUnwrappedReactor();\n const setReactor = useSetAtom(initializeReactorAtom);\n const setSelectedDrive = useSetAtom(selectedDriveAtom);\n const setSelectedNode = useSetAtom(setSelectedNodeAtom);\n const refresh = useSyncDrivesAndDocumentsWithReactor();\n useEffect(() => {\n // If the reactor is already initialized, do nothing.\n if (unwrappedReactor)\n return;\n async function initializeReactor() {\n // Create the reactor instance.\n const reactor = await createReactor();\n // Subscribe to the reactor's events.\n reactor.on(\"syncStatus\", (event, status, error) => {\n logger.verbose(\"syncStatus\", event, status, error);\n refresh();\n });\n reactor.on(\"strandUpdate\", () => {\n logger.verbose(\"strandUpdate\");\n refresh();\n });\n reactor.on(\"defaultRemoteDrive\", () => {\n logger.verbose(\"defaultRemoteDrive\");\n refresh();\n });\n // Set the reactor instance atom.\n setReactor(reactor);\n // Set the selected drive and node from the URL if `shouldNavigate` is true.\n await setSelectedDriveAndNodeFromUrl(reactor, setSelectedDrive, setSelectedNode, shouldNavigate);\n }\n initializeReactor().catch(logger.error);\n }, [setReactor, createReactor, refresh, shouldNavigate]);\n}\nexport function useGetSyncStatusSync() {\n const reactor = useUnwrappedReactor();\n const getSyncStatusSync = useCallback((syncId, sharingType) => {\n if (sharingType === \"LOCAL\")\n return;\n if (!reactor) {\n return \"INITIAL_SYNC\";\n }\n try {\n const syncStatus = reactor.getSyncStatus(syncId);\n if (syncStatus instanceof SynchronizationUnitNotFoundError)\n return \"INITIAL_SYNC\";\n return syncStatus;\n }\n catch (error) {\n logger.error(error);\n return \"ERROR\";\n }\n }, [reactor]);\n return getSyncStatusSync;\n}\n//# sourceMappingURL=reactor.js.map","import {\n InternalDevTools\n} from \"./chunk-HLGSGNDX.esm.mjs\";\nimport {\n useAtomDevtools,\n useAtomsDebugValue,\n useAtomsDevtools,\n useAtomsSnapshot,\n useGotoAtomsSnapshot\n} from \"./chunk-K3M223F4.esm.mjs\";\n\n// src/index.ts\nvar DevTools = process.env.NODE_ENV !== \"production\" ? InternalDevTools : () => null;\nexport {\n DevTools,\n useAtomDevtools,\n useAtomsDebugValue,\n useAtomsDevtools,\n useAtomsSnapshot,\n useGotoAtomsSnapshot\n};\n","import { createStore } from \"jotai\";\n/** The atom store for the app.\n *\n * All derived hooks should use this store.\n */\nexport const atomStore = createStore();\n//# sourceMappingURL=store.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Provider } from \"jotai\";\nimport { DevTools } from \"jotai-devtools\";\nimport \"jotai-devtools/styles.css\";\nimport { useInitializeReactor } from \"./reactor.js\";\nimport { atomStore } from \"./store.js\";\nfunction InitReactor({ reactor }) {\n useInitializeReactor(() => Promise.resolve(reactor));\n return null;\n}\n/** Provides the atom store to the app.\n *\n * This is the top-level provider for the atom store.\n *\n * It is used to provide the atom store to the app.\n *\n * It should only be used once in the app and must appear before any `<Suspense>` boundaries.\n *\n * Includes the Jotai DevTools for debugging.\n */\nexport function AtomStoreProvider({ reactor, children, }) {\n return (_jsxs(Provider, { store: atomStore, children: [_jsx(DevTools, { store: atomStore }), reactor && _jsx(InitReactor, { reactor: reactor }), children] }));\n}\n//# sourceMappingURL=store-provider.js.map","import { lazy, StrictMode, Suspense } from 'react';\nimport '../i18n';\n\nimport { AtomStoreProvider } from '@powerhousedao/common';\nimport { AppSkeleton } from './app-skeleton.js';\n\nconst App = lazy(() => import('./app.js'));\nconst CookieBanner = lazy(() =>\n import('./cookie-banner.js').then(m => ({ default: m.CookieBanner })),\n);\n\nconst ModalManager = lazy(() =>\n import('./modal/modal.js').then(m => ({ default: m.ModalManager })),\n);\n\nexport const AppLoader = (\n <StrictMode>\n <AtomStoreProvider>\n <Suspense fallback={<AppSkeleton />} name=\"AppLoader\">\n <App />\n </Suspense>\n <Suspense name=\"CookieBanner\">\n <ModalManager>\n <CookieBanner />\n </ModalManager>\n </Suspense>\n </AtomStoreProvider>\n </StrictMode>\n);\n","import { createRoot } from 'react-dom/client';\nimport { AppLoader } from './components/app-loader.js';\n\nfunction renderApp(element: HTMLElement) {\n createRoot(element).render(AppLoader);\n}\n\nconst AppElement = document.getElementById('app');\nif (!AppElement) {\n throw new Error('#app element not found!');\n}\n\nrenderApp(AppElement);\n"],"file":"assets/index.CrfEkaEE.js"}
@@ -1,2 +1,2 @@
1
- var m=Object.defineProperty;var y=(r,t,e)=>t in r?m(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>y(r,typeof t!="symbol"?t+"":t,e);import{A as d,D as $}from"./app.4_SWVXbR.js";import{c as S,w as v}from"./index.DFyMrewv.js";import"react/jsx-runtime";import"react";import"./connect.config.DUXg7xh4.js";import"./browser.BkwNmV2Z.js";import"./user.BQU9ztVh.js";import"./index.BDEjD6s0.js";import"react-dom/client";import"./app-skeleton.js";import"./useFeatureFlags.Dp7X50k3.js";import"./useAcceptedCookies.CxwtiZdL.js";import"./useConnectConfig.PFYS-3o2.js";import"react-dom";import"./index.CAUjMUXb.js";import"./registerServiceWorker.D6UhEnk-.js";function w(r,t){const e=[],i=h(r,t,"state.global","global");e.push(...i);const o=e.filter(l=>l.type==="add").length,a=e.filter(l=>l.type==="remove").length,s={global:e.filter(l=>l.scope==="global")};return{totalChanges:e.length,additions:o,removals:a,changesByScope:s,changes:e}}function h(r,t,e,i){const o=[];if(Array.isArray(r)&&Array.isArray(t)){let n=0;for(;n<r.length;n++){const c=r[n];if(!t[n])o.push(...h(c,typeof c=="string"?"":null,`${e}[${n}]`,i));else{const f=h(c,t[n],`${e}[${n}]`,i);o.push(...f)}}for(;n<t.length;n++){const c=t[n];if(!r[n])o.push(...h(typeof c=="string"?"":null,c,`${e}[${n}]`,i));else{const f=h(r[n],c,`${e}[${n}]`,i);o.push(...f)}}return o}if(typeof r!="object"||typeof t!="object"||r===null||t===null){if(r!==t){if(typeof r=="string"&&typeof t=="string")return A(r,t,e,i);o.push({type:"remove",path:e,oldValue:r,scope:i}),o.push({type:"add",path:e,newValue:t,scope:i})}return o}const a=r,s=t,l=Object.keys(a),p=Object.keys(s);for(const n of l)n in s||o.push({type:"remove",path:`${e}.${n}`,oldValue:a[n],scope:i});for(const n of p)if(!(n in a))o.push({type:"add",path:`${e}.${n}`,newValue:s[n],scope:i});else if(a[n]!==s[n]){const c=h(a[n],s[n],`${e}.${n}`,i);o.push(...c)}return o}function A(r,t,e,i){const o=[],a=Math.max(r.length,t.length);for(let s=0;s<a;s++)s>=r.length?o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}):s>=t.length?o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}):r[s]!==t[s]&&(o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}),o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}));return o}class V{constructor(t,e=S(["processor","diff-analytics"])){g(this,"analyticsStore");g(this,"logger");this.analyticsStore=t,this.logger=e}async onStrands(t){if(t.length!==0)for(const e of t){if(e.operations.length===0)continue;const i=e.operations[0],o=d.fromString(`ph/diff/${e.driveId}/${e.documentId}/${e.branch}/${e.scope}`);i.index===0&&await this.clearSource(o);const a=50;for(let s=0;s<e.operations.length;s+=a){const l=e.operations.slice(s,s+a),p=[];for(const n of l){const f=(await v(async()=>w(n.previousState,n.state))).changes.map(u=>this.generateInput(e.driveId,e.documentId,e.branch,e.scope,n.index,u.type,1,o,n.timestamp,u.path));for(p.push(...f);p.length>=a;){const u=p.splice(0,a);await this.analyticsStore.addSeriesValues(u)}}p.length>0&&await this.analyticsStore.addSeriesValues(p)}}}async onDisconnect(){}async clearSource(t){try{await this.analyticsStore.clearSeriesBySource(t,!0)}catch(e){this.logger.error("Failed to clear source",e)}}generateInput(t,e,i,o,a,s,l,p,n,c){const f={},u=c.split("[")[0].replaceAll(".","/");return f.changes=d.fromString(`ph/diff/changes/${s}`),f.document=d.fromString(`ph/diff/document/${e}/${i}/${o}/${a}`),f.path=d.fromString(`ph/diff/path/${u}`),f.drive=d.fromString(`ph/diff/drive/${t}/${e}`),{dimensions:f,metric:"Count",start:$.fromISO(n),source:p,value:l}}}const U=r=>t=>[{processor:new V(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{U as processorFactory};
2
- //# sourceMappingURL=index.9LsxHx9v.js.map
1
+ var m=Object.defineProperty;var y=(r,t,e)=>t in r?m(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>y(r,typeof t!="symbol"?t+"":t,e);import{A as d,D as $}from"./app.BtXNojPV.js";import{c as S,w as v}from"./index.DFyMrewv.js";import"react/jsx-runtime";import"react";import"./connect.config.DFiOOfbL.js";import"./browser.BkwNmV2Z.js";import"./user.C5X0s2J6.js";import"./index.CrfEkaEE.js";import"react-dom/client";import"./app-skeleton.js";import"./useFeatureFlags.CZev5A6L.js";import"./useAcceptedCookies.D_OU6xT7.js";import"./useConnectConfig.BvkNvwSB.js";import"react-dom";import"./index.CAUjMUXb.js";import"./registerServiceWorker.DUgNo8Ta.js";function w(r,t){const e=[],i=h(r,t,"state.global","global");e.push(...i);const o=e.filter(l=>l.type==="add").length,a=e.filter(l=>l.type==="remove").length,s={global:e.filter(l=>l.scope==="global")};return{totalChanges:e.length,additions:o,removals:a,changesByScope:s,changes:e}}function h(r,t,e,i){const o=[];if(Array.isArray(r)&&Array.isArray(t)){let n=0;for(;n<r.length;n++){const c=r[n];if(!t[n])o.push(...h(c,typeof c=="string"?"":null,`${e}[${n}]`,i));else{const f=h(c,t[n],`${e}[${n}]`,i);o.push(...f)}}for(;n<t.length;n++){const c=t[n];if(!r[n])o.push(...h(typeof c=="string"?"":null,c,`${e}[${n}]`,i));else{const f=h(r[n],c,`${e}[${n}]`,i);o.push(...f)}}return o}if(typeof r!="object"||typeof t!="object"||r===null||t===null){if(r!==t){if(typeof r=="string"&&typeof t=="string")return A(r,t,e,i);o.push({type:"remove",path:e,oldValue:r,scope:i}),o.push({type:"add",path:e,newValue:t,scope:i})}return o}const a=r,s=t,l=Object.keys(a),p=Object.keys(s);for(const n of l)n in s||o.push({type:"remove",path:`${e}.${n}`,oldValue:a[n],scope:i});for(const n of p)if(!(n in a))o.push({type:"add",path:`${e}.${n}`,newValue:s[n],scope:i});else if(a[n]!==s[n]){const c=h(a[n],s[n],`${e}.${n}`,i);o.push(...c)}return o}function A(r,t,e,i){const o=[],a=Math.max(r.length,t.length);for(let s=0;s<a;s++)s>=r.length?o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}):s>=t.length?o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}):r[s]!==t[s]&&(o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}),o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}));return o}class V{constructor(t,e=S(["processor","diff-analytics"])){g(this,"analyticsStore");g(this,"logger");this.analyticsStore=t,this.logger=e}async onStrands(t){if(t.length!==0)for(const e of t){if(e.operations.length===0)continue;const i=e.operations[0],o=d.fromString(`ph/diff/${e.driveId}/${e.documentId}/${e.branch}/${e.scope}`);i.index===0&&await this.clearSource(o);const a=50;for(let s=0;s<e.operations.length;s+=a){const l=e.operations.slice(s,s+a),p=[];for(const n of l){const f=(await v(async()=>w(n.previousState,n.state))).changes.map(u=>this.generateInput(e.driveId,e.documentId,e.branch,e.scope,n.index,u.type,1,o,n.timestamp,u.path));for(p.push(...f);p.length>=a;){const u=p.splice(0,a);await this.analyticsStore.addSeriesValues(u)}}p.length>0&&await this.analyticsStore.addSeriesValues(p)}}}async onDisconnect(){}async clearSource(t){try{await this.analyticsStore.clearSeriesBySource(t,!0)}catch(e){this.logger.error("Failed to clear source",e)}}generateInput(t,e,i,o,a,s,l,p,n,c){const f={},u=c.split("[")[0].replaceAll(".","/");return f.changes=d.fromString(`ph/diff/changes/${s}`),f.document=d.fromString(`ph/diff/document/${e}/${i}/${o}/${a}`),f.path=d.fromString(`ph/diff/path/${u}`),f.drive=d.fromString(`ph/diff/drive/${t}/${e}`),{dimensions:f,metric:"Count",start:$.fromISO(n),source:p,value:l}}}const U=r=>t=>[{processor:new V(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{U as processorFactory};
2
+ //# sourceMappingURL=index.Dy1TXvFH.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.9LsxHx9v.js","sources":["../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/lib/document-diff.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/diff-analytics/index.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/index.js"],"sourcesContent":["/**\n * Calculates the difference between two document states\n */\nexport function diffDocumentStates(doc1, doc2) {\n const changes = [];\n // Compare global state\n const globalChanges = diffStateObjects(doc1, doc2, \"state.global\", \"global\");\n changes.push(...globalChanges);\n // Count changes by type\n const additions = changes.filter((c) => c.type === \"add\").length;\n const removals = changes.filter((c) => c.type === \"remove\").length;\n // Group changes by scope\n const changesByScope = {\n global: changes.filter((c) => c.scope === \"global\"),\n };\n return {\n totalChanges: changes.length,\n additions,\n removals,\n changesByScope,\n changes,\n };\n}\n/**\n * Recursively compares two state objects and returns a list of changes\n */\nfunction diffStateObjects(obj1, obj2, path, scope) {\n const changes = [];\n // Handle arrays\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n let index = 0;\n for (; index < obj1.length; index++) {\n const element = obj1[index];\n if (!obj2[index]) {\n changes.push(...diffStateObjects(element, typeof element === \"string\" ? \"\" : null, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(element, obj2[index], `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n for (; index < obj2.length; index++) {\n const element = obj2[index];\n if (!obj1[index]) {\n changes.push(...diffStateObjects(typeof element === \"string\" ? \"\" : null, element, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(obj1[index], element, `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n return changes;\n }\n // Handle primitive values\n if (typeof obj1 !== \"object\" ||\n typeof obj2 !== \"object\" ||\n obj1 === null ||\n obj2 === null) {\n if (obj1 !== obj2) {\n // Special handling for strings to diff character by character\n if (typeof obj1 === \"string\" && typeof obj2 === \"string\") {\n return diffStateStrings(obj1, obj2, path, scope);\n }\n else {\n // For non-string primitives, treat a change as a remove + add\n changes.push({\n type: \"remove\",\n path,\n oldValue: obj1,\n scope,\n });\n changes.push({\n type: \"add\",\n path,\n newValue: obj2,\n scope,\n });\n }\n }\n return changes;\n }\n // Handle objects\n const obj1Record = obj1;\n const obj2Record = obj2;\n const obj1Keys = Object.keys(obj1Record);\n const obj2Keys = Object.keys(obj2Record);\n // First, check for removed keys\n for (const key of obj1Keys) {\n if (!(key in obj2Record)) {\n // Key was removed\n changes.push({\n type: \"remove\",\n path: `${path}.${key}`,\n oldValue: obj1Record[key],\n scope,\n });\n }\n }\n // Then, check for added keys and modified values\n for (const key of obj2Keys) {\n if (!(key in obj1Record)) {\n // Key was added\n changes.push({\n type: \"add\",\n path: `${path}.${key}`,\n newValue: obj2Record[key],\n scope,\n });\n }\n else if (obj1Record[key] !== obj2Record[key]) {\n // For object changes, recursively diff the objects\n const nestedChanges = diffStateObjects(obj1Record[key], obj2Record[key], `${path}.${key}`, scope);\n changes.push(...nestedChanges);\n }\n }\n return changes;\n}\n/**\n * Compares two strings character by character and returns a list of changes\n */\nfunction diffStateStrings(str1, str2, path, scope) {\n const changes = [];\n const maxLen = Math.max(str1.length, str2.length);\n for (let i = 0; i < maxLen; i++) {\n if (i >= str1.length) {\n // Addition of new character\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n else if (i >= str2.length) {\n // Removal of character\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n }\n else if (str1[i] !== str2[i]) {\n // Character changed\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n }\n return changes;\n}\n/**\n * Generates analytics data from a state diff summary\n */\nexport function generateStateAnalyticsData(diff) {\n return {\n totalChanges: diff.totalChanges,\n changesByType: {\n add: diff.additions,\n remove: diff.removals,\n },\n changesByScope: {\n global: diff.changesByScope.global.length,\n },\n changePaths: diff.changes.map((c) => c.path),\n };\n}\n","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { DateTime } from \"luxon\";\nimport { diffDocumentStates } from \"../../lib/document-diff.js\";\nimport { childLogger } from \"document-drive\";\nimport { runAsapAsync } from \"document-drive/utils/misc\";\nexport class DiffAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"diff-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/diff/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const diff = await runAsapAsync(async () => diffDocumentStates(operation.previousState, operation.state));\n const inputs = diff.changes.map((change) => this.generateInput(strand.driveId, strand.documentId, strand.branch, strand.scope, operation.index, change.type, 1, source, operation.timestamp, change.path));\n buffer.push(...inputs);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n // Flush any remaining inputs\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n generateInput(driveId, documentId, branch, scope, revision, type, value, source, timestamp, path) {\n const dimensions = {};\n const changePath = path.split(\"[\")[0].replaceAll(\".\", \"/\");\n dimensions.changes = AnalyticsPath.fromString(`ph/diff/changes/${type}`);\n dimensions.document = AnalyticsPath.fromString(`ph/diff/document/${documentId}/${branch}/${scope}/${revision}`);\n dimensions.path = AnalyticsPath.fromString(`ph/diff/path/${changePath}`);\n dimensions.drive = AnalyticsPath.fromString(`ph/diff/drive/${driveId}/${documentId}`);\n return {\n dimensions,\n metric: \"Count\",\n start: DateTime.fromISO(timestamp),\n source,\n value,\n };\n }\n}\n","/**\n * This is a scaffold file meant for customization.\n * Delete the file and run the code generator again to have it reset\n */\nimport { DiffAnalyticsProcessor } from \"./diff-analytics/index.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DiffAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\n"],"names":["diffDocumentStates","doc1","doc2","changes","globalChanges","diffStateObjects","additions","c","removals","changesByScope","obj1","obj2","path","scope","index","element","elementChanges","diffStateStrings","obj1Record","obj2Record","obj1Keys","obj2Keys","key","nestedChanges","str1","str2","maxLen","i","DiffAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","CHUNK_SIZE","chunk","buffer","operation","inputs","runAsapAsync","change","batch","driveId","documentId","branch","revision","type","value","timestamp","dimensions","changePath","DateTime","processorFactory","module"],"mappings":"qqBAGO,SAASA,EAAmBC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M,EACA,OAAQ,QACR,MAAOE,EAAS,QAAQH,CAAS,EACjC,OAAAhB,EACA,MAAAe,CACZ,CACA,CACA,CCjEY,MAACK,EAAoBC,GAAYX,GAClC,CACH,CACI,UAAW,IAAIlB,EAAuB6B,EAAO,cAAc,EAC3D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CAClC,CACA,CACA","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"index.Dy1TXvFH.js","sources":["../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/lib/document-diff.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/diff-analytics/index.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/index.js"],"sourcesContent":["/**\n * Calculates the difference between two document states\n */\nexport function diffDocumentStates(doc1, doc2) {\n const changes = [];\n // Compare global state\n const globalChanges = diffStateObjects(doc1, doc2, \"state.global\", \"global\");\n changes.push(...globalChanges);\n // Count changes by type\n const additions = changes.filter((c) => c.type === \"add\").length;\n const removals = changes.filter((c) => c.type === \"remove\").length;\n // Group changes by scope\n const changesByScope = {\n global: changes.filter((c) => c.scope === \"global\"),\n };\n return {\n totalChanges: changes.length,\n additions,\n removals,\n changesByScope,\n changes,\n };\n}\n/**\n * Recursively compares two state objects and returns a list of changes\n */\nfunction diffStateObjects(obj1, obj2, path, scope) {\n const changes = [];\n // Handle arrays\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n let index = 0;\n for (; index < obj1.length; index++) {\n const element = obj1[index];\n if (!obj2[index]) {\n changes.push(...diffStateObjects(element, typeof element === \"string\" ? \"\" : null, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(element, obj2[index], `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n for (; index < obj2.length; index++) {\n const element = obj2[index];\n if (!obj1[index]) {\n changes.push(...diffStateObjects(typeof element === \"string\" ? \"\" : null, element, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(obj1[index], element, `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n return changes;\n }\n // Handle primitive values\n if (typeof obj1 !== \"object\" ||\n typeof obj2 !== \"object\" ||\n obj1 === null ||\n obj2 === null) {\n if (obj1 !== obj2) {\n // Special handling for strings to diff character by character\n if (typeof obj1 === \"string\" && typeof obj2 === \"string\") {\n return diffStateStrings(obj1, obj2, path, scope);\n }\n else {\n // For non-string primitives, treat a change as a remove + add\n changes.push({\n type: \"remove\",\n path,\n oldValue: obj1,\n scope,\n });\n changes.push({\n type: \"add\",\n path,\n newValue: obj2,\n scope,\n });\n }\n }\n return changes;\n }\n // Handle objects\n const obj1Record = obj1;\n const obj2Record = obj2;\n const obj1Keys = Object.keys(obj1Record);\n const obj2Keys = Object.keys(obj2Record);\n // First, check for removed keys\n for (const key of obj1Keys) {\n if (!(key in obj2Record)) {\n // Key was removed\n changes.push({\n type: \"remove\",\n path: `${path}.${key}`,\n oldValue: obj1Record[key],\n scope,\n });\n }\n }\n // Then, check for added keys and modified values\n for (const key of obj2Keys) {\n if (!(key in obj1Record)) {\n // Key was added\n changes.push({\n type: \"add\",\n path: `${path}.${key}`,\n newValue: obj2Record[key],\n scope,\n });\n }\n else if (obj1Record[key] !== obj2Record[key]) {\n // For object changes, recursively diff the objects\n const nestedChanges = diffStateObjects(obj1Record[key], obj2Record[key], `${path}.${key}`, scope);\n changes.push(...nestedChanges);\n }\n }\n return changes;\n}\n/**\n * Compares two strings character by character and returns a list of changes\n */\nfunction diffStateStrings(str1, str2, path, scope) {\n const changes = [];\n const maxLen = Math.max(str1.length, str2.length);\n for (let i = 0; i < maxLen; i++) {\n if (i >= str1.length) {\n // Addition of new character\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n else if (i >= str2.length) {\n // Removal of character\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n }\n else if (str1[i] !== str2[i]) {\n // Character changed\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n }\n return changes;\n}\n/**\n * Generates analytics data from a state diff summary\n */\nexport function generateStateAnalyticsData(diff) {\n return {\n totalChanges: diff.totalChanges,\n changesByType: {\n add: diff.additions,\n remove: diff.removals,\n },\n changesByScope: {\n global: diff.changesByScope.global.length,\n },\n changePaths: diff.changes.map((c) => c.path),\n };\n}\n","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { DateTime } from \"luxon\";\nimport { diffDocumentStates } from \"../../lib/document-diff.js\";\nimport { childLogger } from \"document-drive\";\nimport { runAsapAsync } from \"document-drive/utils/misc\";\nexport class DiffAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"diff-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/diff/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const diff = await runAsapAsync(async () => diffDocumentStates(operation.previousState, operation.state));\n const inputs = diff.changes.map((change) => this.generateInput(strand.driveId, strand.documentId, strand.branch, strand.scope, operation.index, change.type, 1, source, operation.timestamp, change.path));\n buffer.push(...inputs);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n // Flush any remaining inputs\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n generateInput(driveId, documentId, branch, scope, revision, type, value, source, timestamp, path) {\n const dimensions = {};\n const changePath = path.split(\"[\")[0].replaceAll(\".\", \"/\");\n dimensions.changes = AnalyticsPath.fromString(`ph/diff/changes/${type}`);\n dimensions.document = AnalyticsPath.fromString(`ph/diff/document/${documentId}/${branch}/${scope}/${revision}`);\n dimensions.path = AnalyticsPath.fromString(`ph/diff/path/${changePath}`);\n dimensions.drive = AnalyticsPath.fromString(`ph/diff/drive/${driveId}/${documentId}`);\n return {\n dimensions,\n metric: \"Count\",\n start: DateTime.fromISO(timestamp),\n source,\n value,\n };\n }\n}\n","/**\n * This is a scaffold file meant for customization.\n * Delete the file and run the code generator again to have it reset\n */\nimport { DiffAnalyticsProcessor } from \"./diff-analytics/index.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DiffAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\n"],"names":["diffDocumentStates","doc1","doc2","changes","globalChanges","diffStateObjects","additions","c","removals","changesByScope","obj1","obj2","path","scope","index","element","elementChanges","diffStateStrings","obj1Record","obj2Record","obj1Keys","obj2Keys","key","nestedChanges","str1","str2","maxLen","i","DiffAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","CHUNK_SIZE","chunk","buffer","operation","inputs","runAsapAsync","change","batch","driveId","documentId","branch","revision","type","value","timestamp","dimensions","changePath","DateTime","processorFactory","module"],"mappings":"qqBAGO,SAASA,EAAmBC,EAAMC,EAAM,CAC3C,MAAMC,EAAU,CAAA,EAEVC,EAAgBC,EAAiBJ,EAAMC,EAAM,eAAgB,QAAQ,EAC3EC,EAAQ,KAAK,GAAGC,CAAa,EAE7B,MAAME,EAAYH,EAAQ,OAAQI,GAAMA,EAAE,OAAS,KAAK,EAAE,OACpDC,EAAWL,EAAQ,OAAQI,GAAMA,EAAE,OAAS,QAAQ,EAAE,OAEtDE,EAAiB,CACnB,OAAQN,EAAQ,OAAQI,GAAMA,EAAE,QAAU,QAAQ,CAC1D,EACI,MAAO,CACH,aAAcJ,EAAQ,OACtB,UAAAG,EACA,SAAAE,EACA,eAAAC,EACA,QAAAN,CACR,CACA,CAIA,SAASE,EAAiBK,EAAMC,EAAMC,EAAMC,EAAO,CAC/C,MAAMV,EAAU,CAAA,EAEhB,GAAI,MAAM,QAAQO,CAAI,GAAK,MAAM,QAAQC,CAAI,EAAG,CAC5C,IAAIG,EAAQ,EACZ,KAAOA,EAAQJ,EAAK,OAAQI,IAAS,CACjC,MAAMC,EAAUL,EAAKI,CAAK,EAC1B,GAAI,CAACH,EAAKG,CAAK,EACXX,EAAQ,KAAK,GAAGE,EAAiBU,EAAS,OAAOA,GAAY,SAAW,GAAK,KAAM,GAAGH,CAAI,IAAIE,CAAK,IAAKD,CAAK,CAAC,MAE7G,CACD,MAAMG,EAAiBX,EAAiBU,EAASJ,EAAKG,CAAK,EAAG,GAAGF,CAAI,IAAIE,CAAK,IAAKD,CAAK,EACxFV,EAAQ,KAAK,GAAGa,CAAc,CAC9C,CACA,CACQ,KAAOF,EAAQH,EAAK,OAAQG,IAAS,CACjC,MAAMC,EAAUJ,EAAKG,CAAK,EAC1B,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