@openparachute/app 0.22.11 → 0.22.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +141 -75
- package/dist/.parachute/info +1 -1
- package/dist/assets/{Account-Cl5c8tEo.js → Account-CRPq4eky.js} +1 -1
- package/dist/assets/Activity-BLLN2kgu.js +1 -0
- package/dist/assets/{AddVault-DoCaI37K.js → AddVault-BR5gZWT3.js} +1 -1
- package/dist/assets/{AddVaultChooser-Xvu3Uphy.js → AddVaultChooser-Bq8pAkVc.js} +1 -1
- package/dist/assets/{AddVaultCreate-Di9wcscn.js → AddVaultCreate-m_9BeV_Q.js} +1 -1
- package/dist/assets/Calendar-65Irth8Y.js +1 -0
- package/dist/assets/{CheckEmail-ntqd1kZe.js → CheckEmail-encZZOxl.js} +1 -1
- package/dist/assets/{ConnectAI-CUJNLwHZ.js → ConnectAI-B7gqvDkQ.js} +1 -1
- package/dist/assets/DayView-DsQr2XvT.js +1 -0
- package/dist/assets/{Export-BFGWcvOW.js → Export-BRO5DUzT.js} +1 -1
- package/dist/assets/{Import-2WIsPfSi.js → Import-_1c63gXI.js} +1 -1
- package/dist/assets/NoteEditor-C1s0DRwJ.js +1 -0
- package/dist/assets/NoteNew-D2gDWKnW.js +8 -0
- package/dist/assets/{NoteRenderer-DG6I-BOG.js → NoteRenderer-BwgvmHZD.js} +1 -1
- package/dist/assets/{NoteView-Dy3cUyrT.js → NoteView-BtXvo-Ke.js} +3 -3
- package/dist/assets/{OAuthCallback-W5STO-7I.js → OAuthCallback-Dne6nN7G.js} +1 -1
- package/dist/assets/{PinArchiveButtons-8xFKv2oH.js → PinArchiveButtons-BaeSYCvb.js} +1 -1
- package/dist/assets/{Settings-ClPAPWCJ.js → Settings-C5Q_6IiY.js} +1 -1
- package/dist/assets/{TagPage-pYbWcmlY.js → TagPage-Bz58IORf.js} +1 -1
- package/dist/assets/{TagSchemaEditor-ve19B-tr.js → TagSchemaEditor-YXqxcc95.js} +1 -1
- package/dist/assets/{Tags-DGl9Zubj.js → Tags-DIhbbif6.js} +1 -1
- package/dist/assets/{VaultGraph-BrDsta1c.js → VaultGraph-OyvE7-1G.js} +3 -3
- package/dist/assets/{Vaults-DWoDm-Th.js → Vaults-DZTvLJL0.js} +1 -1
- package/dist/assets/{ViewNew-D3N3bUyp.js → ViewNew-CEWGH98c.js} +1 -1
- package/dist/assets/ViewSurface-BVVt4eto.js +1 -0
- package/dist/assets/Welcome-DcaF7cVO.js +1 -0
- package/dist/assets/{WizardShell-eATuMAXz.js → WizardShell-BpDtpsOX.js} +1 -1
- package/dist/assets/{attachment-upload-D6wfJsr6.js → attachment-upload-BqMcsBiB.js} +1 -1
- package/dist/assets/{history-BHtc79G3.js → history-v1ErfO2u.js} +1 -1
- package/dist/assets/index-BBWRhmyM.css +1 -0
- package/dist/assets/index-C2wr_d3O.js +66 -0
- package/dist/assets/{provenance-BFQb2w9-.js → provenance-C8B5Q0ir.js} +1 -1
- package/dist/assets/{react-force-graph-2d-BZd7whjL.js → react-force-graph-2d-BtLtJaOD.js} +1 -1
- package/dist/assets/{transcribe-default-Cjxt7F_e.js → transcribe-default-BCVfDb3s.js} +1 -1
- package/dist/assets/{useAttachmentUploader-Be6yFw7I.js → useAttachmentUploader-BmtZQjNW.js} +2 -2
- package/dist/index.html +2 -2
- package/dist/sw.js +1 -1
- package/meta.json +1 -1
- package/package.json +3 -2
- package/dist/assets/Activity-BcJHDfuw.js +0 -1
- package/dist/assets/Calendar-DBe5DpLx.js +0 -1
- package/dist/assets/DayView-jTXjnokv.js +0 -1
- package/dist/assets/NoteEditor-DT4kYH2h.js +0 -1
- package/dist/assets/NoteNew-B7fbwu7C.js +0 -8
- package/dist/assets/ViewSurface-CB97Dtg8.js +0 -1
- package/dist/assets/Welcome-C6zOVULl.js +0 -1
- package/dist/assets/index-BKfqr8sS.js +0 -66
- package/dist/assets/index-DBJfPBlG.css +0 -1
package/dist/index.html
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
} catch (e) {}
|
|
23
23
|
})();
|
|
24
24
|
</script>
|
|
25
|
-
<script type="module" crossorigin src="/assets/index-
|
|
26
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
25
|
+
<script type="module" crossorigin src="/assets/index-C2wr_d3O.js"></script>
|
|
26
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BBWRhmyM.css">
|
|
27
27
|
<link rel="manifest" href="/manifest.webmanifest"></head>
|
|
28
28
|
<body>
|
|
29
29
|
<div id="root"></div>
|
package/dist/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let s,e={};const l=(l,i)=>(l=new URL(l+".js",i).href,e[l]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()}).then(()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s}));self.define=(i,n)=>{const r=s||("document"in self?document.currentScript.src:"")||location.href;if(e[r])return;let a={};const u=s=>l(s,r),o={module:{uri:r},exports:a,require:u};e[r]=Promise.all(i.map(s=>o[s]||u(s))).then(s=>(n(...s),a))}}define(["./workbox-9c191d2f"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"pwa-64x64.png",revision:"6f10cd3ce8dd36cf6af65fd22310235f"},{url:"pwa-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-192x192.png",revision:"536b2ea22e7195eefa8806a1d7d993da"},{url:"maskable-icon-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"manifest.webmanifest",revision:"5171a09ae3e50605a6503e2bebd6866b"},{url:"index.html",revision:"
|
|
1
|
+
if(!self.define){let s,e={};const l=(l,i)=>(l=new URL(l+".js",i).href,e[l]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()}).then(()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s}));self.define=(i,n)=>{const r=s||("document"in self?document.currentScript.src:"")||location.href;if(e[r])return;let a={};const u=s=>l(s,r),o={module:{uri:r},exports:a,require:u};e[r]=Promise.all(i.map(s=>o[s]||u(s))).then(s=>(n(...s),a))}}define(["./workbox-9c191d2f"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"pwa-64x64.png",revision:"6f10cd3ce8dd36cf6af65fd22310235f"},{url:"pwa-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-192x192.png",revision:"536b2ea22e7195eefa8806a1d7d993da"},{url:"maskable-icon-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"manifest.webmanifest",revision:"5171a09ae3e50605a6503e2bebd6866b"},{url:"index.html",revision:"90f7177d5e00fcbcef8d31541c639c74"},{url:"icon.svg",revision:"53c7d88dbec013463a85d68375229bcb"},{url:"favicon.ico",revision:"8b16a7348bc587d1c91324487d988e81"},{url:"apple-touch-icon-180x180.png",revision:"010679b40baa6da053a041cfc7fc7657"},{url:"assets/workbox-window.prod.es5-BBnX5xw4.js",revision:null},{url:"assets/useAttachmentUploader-BmtZQjNW.js",revision:null},{url:"assets/url-QSQwrjSV.js",revision:null},{url:"assets/types-BaJkUfo6.js",revision:null},{url:"assets/transcribe-default-BCVfDb3s.js",revision:null},{url:"assets/react-force-graph-2d-BtLtJaOD.js",revision:null},{url:"assets/provenance-C8B5Q0ir.js",revision:null},{url:"assets/index-C2wr_d3O.js",revision:null},{url:"assets/index-BBWRhmyM.css",revision:null},{url:"assets/history-v1ErfO2u.js",revision:null},{url:"assets/fraunces-vietnamese-opsz-normal-Czevyj-6.woff2",revision:null},{url:"assets/fraunces-vietnamese-opsz-italic-DxWqP7Ku.woff2",revision:null},{url:"assets/fraunces-latin-opsz-normal-DihXLNYH.woff2",revision:null},{url:"assets/fraunces-latin-opsz-italic-lSdLDfvT.woff2",revision:null},{url:"assets/fraunces-latin-ext-opsz-normal-CJcjJNj7.woff2",revision:null},{url:"assets/fraunces-latin-ext-opsz-italic-CGbN9UgK.woff2",revision:null},{url:"assets/figtree-latin-wght-normal-D_ZTVpCC.woff2",revision:null},{url:"assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2",revision:null},{url:"assets/editor-mode-D9fveTEx.js",revision:null},{url:"assets/attachment-upload-BqMcsBiB.js",revision:null},{url:"assets/WizardShell-BpDtpsOX.js",revision:null},{url:"assets/Welcome-DcaF7cVO.js",revision:null},{url:"assets/ViewSurface-BVVt4eto.js",revision:null},{url:"assets/ViewNew-CEWGH98c.js",revision:null},{url:"assets/Vaults-DZTvLJL0.js",revision:null},{url:"assets/VaultGraph-OyvE7-1G.js",revision:null},{url:"assets/Tags-DIhbbif6.js",revision:null},{url:"assets/TagSchemaEditor-YXqxcc95.js",revision:null},{url:"assets/TagPage-Bz58IORf.js",revision:null},{url:"assets/Settings-C5Q_6IiY.js",revision:null},{url:"assets/PinArchiveButtons-BaeSYCvb.js",revision:null},{url:"assets/OAuthCallback-Dne6nN7G.js",revision:null},{url:"assets/NoteView-BtXvo-Ke.js",revision:null},{url:"assets/NoteRenderer-BwgvmHZD.js",revision:null},{url:"assets/NoteNew-D2gDWKnW.js",revision:null},{url:"assets/NoteEditor-C1s0DRwJ.js",revision:null},{url:"assets/Import-_1c63gXI.js",revision:null},{url:"assets/Export-BRO5DUzT.js",revision:null},{url:"assets/DayView-DsQr2XvT.js",revision:null},{url:"assets/ConnectAI-B7gqvDkQ.js",revision:null},{url:"assets/CheckEmail-encZZOxl.js",revision:null},{url:"assets/Calendar-65Irth8Y.js",revision:null},{url:"assets/AddVaultCreate-m_9BeV_Q.js",revision:null},{url:"assets/AddVaultChooser-Bq8pAkVc.js",revision:null},{url:"assets/AddVault-BR5gZWT3.js",revision:null},{url:"assets/Activity-BLLN2kgu.js",revision:null},{url:"assets/Account-CRPq4eky.js",revision:null},{url:"apple-touch-icon-180x180.png",revision:"010679b40baa6da053a041cfc7fc7657"},{url:"favicon.ico",revision:"8b16a7348bc587d1c91324487d988e81"},{url:"icon.svg",revision:"53c7d88dbec013463a85d68375229bcb"},{url:"maskable-icon-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-192x192.png",revision:"536b2ea22e7195eefa8806a1d7d993da"},{url:"pwa-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-64x64.png",revision:"6f10cd3ce8dd36cf6af65fd22310235f"},{url:"manifest.webmanifest",revision:"5171a09ae3e50605a6503e2bebd6866b"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api\//,/^\/oauth\/(?!callback)/,/^\/\.well-known\//,/^\/signup/,/^\/login/,/^\/logout/,/^\/auth\//,/^\/console/,/^\/admin/,/^\/account\//,/^\/billing/,/^\/unsubscribe/,/^\/health/,/^\/vault\//,/^\/u\//]}))});
|
package/meta.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "parachute",
|
|
4
4
|
"displayName": "Parachute",
|
|
5
5
|
"tagline": "The Parachute app — your parachute's front door.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.22.13",
|
|
7
7
|
"path": "/surface/parachute",
|
|
8
8
|
"iconUrl": "icon.svg",
|
|
9
9
|
"scopes_required": ["vault:*:read", "vault:*:write"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openparachute/app",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Parachute — the super-surface. A single-page app for interfacing with your Parachute: name a vault, capture and browse notes, connect your AI, and manage the cloud + hub via their APIs. Seeded from notes-ui; the calm centered arrival + warm home lead the experience.",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
"files": ["dist", "meta.json", "README.md", "LICENSE", "CHANGELOG.md"],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "vite",
|
|
22
|
-
"build": "tsc -b && vite build",
|
|
22
|
+
"build": "bun run sync-meta-version && tsc -b && vite build",
|
|
23
23
|
"preview": "vite preview",
|
|
24
24
|
"test": "vitest run",
|
|
25
25
|
"test:watch": "vitest",
|
|
26
26
|
"test:smoke": "bun scripts/verify-dist.ts",
|
|
27
|
+
"sync-meta-version": "bun scripts/sync-meta-version.ts",
|
|
27
28
|
"bigvault": "bun scripts/bigvault/bigvault.ts",
|
|
28
29
|
"lint": "biome check .",
|
|
29
30
|
"lint:fix": "biome check --write .",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as x,t as f,r as l,j as e,N as g,v as y,E as j,L as u,w as N,x as b,V as v}from"./index-BKfqr8sS.js";const h=1440*60*1e3,w=5e3;function E(a,n=30,s=new Date){const r=s.getTime()-n*h,i=[];for(const t of a){const c=t.path??t.id,d=Date.parse(t.createdAt);if(Number.isFinite(d)&&d>=r&&i.push({id:`${t.id}:created`,noteId:t.id,noteName:c,kind:"created",at:t.createdAt,preview:t.preview,tags:t.tags}),t.updatedAt){const o=Date.parse(t.updatedAt);Number.isFinite(o)&&o>=r&&Number.isFinite(d)&&o-d>w&&i.push({id:`${t.id}:updated`,noteId:t.id,noteName:c,kind:"updated",at:t.updatedAt,preview:t.preview,tags:t.tags})}}return i.sort((t,c)=>Date.parse(c.at)-Date.parse(t.at)),i}const k=["today","yesterday","thisWeek","older"],D={today:"Today",yesterday:"Yesterday",thisWeek:"This week",older:"Older"};function A(a,n=new Date){const s=Date.parse(a);if(!Number.isFinite(s))return null;const r=m(n),i=m(new Date(s)),t=Math.round((r.getTime()-i.getTime())/h);return t<0||t===0?"today":t===1?"yesterday":t<7?"thisWeek":"older"}function m(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())}function S(a,n=new Date){const s={today:[],yesterday:[],thisWeek:[],older:[]};for(const r of a){const i=A(r.at,n);i&&s[i].push(r)}return s}const p=50;function R(){const a=x(o=>o.getActiveVault()),n=f(),[s,r]=l.useState(p),i=l.useMemo(()=>n.data?E(n.data):[],[n.data]),t=l.useMemo(()=>i.slice(0,s),[i,s]),c=l.useMemo(()=>S(t),[t]),d=i.length-t.length;return a?e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("p",{className:"eyebrow mb-1",children:"Activity"}),e.jsx("h1",{className:"page-title",children:"Recent changes"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Last 30 days, newest first. Deletions aren't tracked yet."})]}),n.isPending?e.jsx(F,{}):n.isError?e.jsx(L,{error:n.error}):i.length===0?e.jsx(C,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-8",children:k.map(o=>c[o].length>0?e.jsx(T,{title:D[o],events:c[o]},o):null)}),d>0?e.jsx("div",{className:"mt-8 flex justify-center",children:e.jsxs("button",{type:"button",onClick:()=>r(o=>o+p),className:"btn btn-secondary btn-touch",children:["Load more (",d," remaining)"]})}):null]})]}):e.jsx(g,{to:"/",replace:!0})}function T({title:a,events:n}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"eyebrow mb-3",children:[a," (",n.length,")"]}),e.jsx("ol",{className:"card shadow-soft divide-y divide-border rounded-xl",children:n.map(s=>e.jsx("li",{children:e.jsxs(u,{to:`/n/${encodeURIComponent(s.noteId)}`,className:"focus-ring block px-5 py-4 transition-colors hover:bg-bg-soft",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(B,{kind:s.kind}),e.jsx("span",{className:"truncate font-mono text-sm text-fg",children:s.noteName})]}),e.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:b(s.at)})]}),s.preview?e.jsx("p",{className:"mt-1 truncate text-sm text-fg-muted",children:s.preview}):null,s.tags&&s.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.tags.map(r=>e.jsxs("span",{className:"chip chip-tag max-w-full break-all",children:["#",r]},r))}):null]})},s.id))})]})}function B({kind:a}){return a==="created"?e.jsx("span",{className:"chip chip-tag shrink-0",children:"Created"}):e.jsx("span",{className:"chip shrink-0",children:"Edited"})}function C(){return e.jsx(N,{title:"No activity in the last 30 days.",action:e.jsx(u,{to:"/new",className:"btn btn-primary",children:"New note"})})}function F(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3,4].map(a=>e.jsx(y,{className:"h-16 rounded-xl"},a))})}function L({error:a}){const n=a instanceof v;return e.jsx(j,{title:n?"Session expired":"Could not load activity",message:a.message,action:n?e.jsx(u,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}export{R as Activity};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as k,y as E,M as y,O as f,t as A,Q as K,r as j,R as S,T,j as e,N as P,U as N,W as l,X as V,L as c,V as C}from"./index-BKfqr8sS.js";const R=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],x=5;function W(){const a=k(t=>t.getActiveVault()),[o]=E(),i=o.get("month"),r=y(i)??y(f()),s=A(),h=K(),v=j.useMemo(()=>S(r.year,r.month),[r.year,r.month]),$=j.useMemo(()=>{const t=new Map;if(!s.data)return t;for(const n of s.data){const d=T(n.createdAt);d&&t.set(d,(t.get(d)??0)+1)}return t},[s.data]);if(!a)return e.jsx(P,{to:"/",replace:!0});const u=N(r.year,r.month,-1),p=N(r.year,r.month,1),g=`${u.year}-${l(u.month)}`,b=`${p.year}-${l(p.month)}`,M=f(),w=`${r.year}-${l(r.month)}`===M;return e.jsxs("div",{className:"mx-auto max-w-4xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Calendar"}),e.jsx("h1",{className:"font-serif text-3xl tracking-tight",children:V(r.year,r.month)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(c,{to:`/calendar?month=${g}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Previous month",children:["← ",g]}),w?null:e.jsx(c,{to:"/calendar",className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"This month"}),e.jsxs(c,{to:`/calendar?month=${b}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Next month",children:[b," →"]}),e.jsx(c,{to:`/today?date=${h}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Today"})]})]}),s.isError?e.jsx(F,{error:s.error}):e.jsxs("div",{className:"rounded-md border border-border bg-card","aria-busy":s.isPending,children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-border text-xs uppercase tracking-wider text-fg-dim",children:R.map(t=>e.jsx("div",{className:"px-2 py-2 text-center",children:t},t))}),e.jsx("div",{className:"grid grid-cols-7",children:v.map(t=>{const n=`${t.getFullYear()}-${l(t.getMonth()+1)}-${l(t.getDate())}`,d=t.getMonth()+1===r.month,m=$.get(n)??0,D=n===h;return e.jsxs(c,{to:`/today?date=${n}`,className:`flex min-h-20 flex-col border-b border-r border-border p-1.5 text-xs hover:bg-bg/60 focus:bg-bg/60 focus:outline-none ${d?"":"opacity-40"}`,"aria-label":`${n} — ${m} notes`,children:[e.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full tabular-nums ${D?"bg-accent text-(--color-on-accent)":"text-fg"}`,children:t.getDate()}),m>0?e.jsx(_,{count:m}):e.jsx("span",{className:"sr-only",children:"no notes"})]},n)})})]}),e.jsx("p",{className:"mt-3 text-xs text-fg-dim",children:"Each dot is a note created on that day. Click any day to open /today."})]})}function _({count:a}){const o=Math.min(a,x),i=a>x?a-x:0;return e.jsxs("span",{className:"flex flex-wrap items-center gap-0.5",children:[Array.from({length:o}).map((r,s)=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent","aria-hidden":"true"},s)),i>0?e.jsxs("span",{className:"ml-0.5 text-[10px] text-fg-dim",children:["+",i]}):null]})}function F({error:a}){const o=a instanceof C;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:o?"Session expired":"Could not load notes"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:a.message}),o?e.jsx(c,{to:"/add",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{W as Calendar};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as g,y as w,j as e,N as p,Q as k,Z as E,t as S,r as A,T as y,L as c,_ as b,$ as D,a0 as R,v as T,E as V,w as $,a1 as L,a2 as B,a3 as C,a4 as K,V as P}from"./index-BKfqr8sS.js";import{u as O}from"./history-BHtc79G3.js";function Z(){const s=g(t=>t.getActiveVault()),[a]=w(),n=a.get("date");return s?n===null?e.jsx(p,{to:"/",replace:!0}):e.jsx(F,{dateParam:n}):e.jsx(p,{to:"/",replace:!0})}function F({dateParam:s}){const a=O("/"),n=k(),t=s||n,r=E(t),o=S(),i=A.useMemo(()=>{const m=[],x=[];if(!o.data||!r)return{created:m,edited:x};for(const l of o.data){const j=y(l.createdAt),v=y(l.updatedAt??l.createdAt);j===t&&m.push(l),v===t&&j!==t&&x.push(l)}return{created:m,edited:x}},[o.data,r,t]);if(!r)return e.jsxs("div",{className:"page-prose",children:[e.jsxs("p",{className:"text-sm text-danger",children:["Invalid date in URL: ",t]}),e.jsx(c,{to:"/",className:"text-sm text-accent hover:underline",children:"Back to today"})]});const d=t===n,u=b(t,-1),h=b(t,1),f=t.slice(0,7);return e.jsxs("div",{className:"page-prose",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx("button",{type:"button",onClick:a,className:"hover:text-accent",children:"← Back"})}),e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:d?"Today":"On"}),e.jsx("h1",{className:"page-title",children:D(t)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(c,{to:`/today?date=${u}`,className:"btn btn-secondary btn-sm","aria-label":"Previous day",children:["← ",u]}),d?null:e.jsx(c,{to:"/",className:"btn btn-secondary btn-sm",children:"Today"}),e.jsxs(c,{to:`/today?date=${h}`,className:"btn btn-secondary btn-sm","aria-label":"Next day",children:[h," →"]}),e.jsx(c,{to:`/calendar?month=${f}`,className:"btn btn-secondary btn-sm",children:"Calendar"}),e.jsx(c,{to:"/new",className:"btn btn-primary btn-sm",children:"+ New note"})]})]}),o.isPending?e.jsx(I,{}):o.isError&&!o.data?e.jsx(M,{error:o.error}):i.created.length===0&&i.edited.length===0?e.jsx(H,{isToday:d,targetKey:t}):e.jsxs("div",{className:"space-y-8",children:[o.isError?e.jsx(R,{}):null,i.created.length>0?e.jsx(N,{title:d?"Created today":`Created on ${t}`,notes:i.created}):null,i.edited.length>0?e.jsx(N,{title:d?"Edited today":`Edited on ${t}`,notes:i.edited}):null]})]})}function N({title:s,notes:a}){const n=g(r=>r.getActiveVault()),{roles:t}=L((n==null?void 0:n.id)??null);return e.jsxs("section",{children:[e.jsxs(B,{children:[s," (",a.length,")"]}),e.jsx(C,{children:a.map(r=>e.jsx(K,{note:r,pinnedTag:t.pinned,archivedTag:t.archived},r.id))})]})}function H({isToday:s,targetKey:a}){return e.jsx($,{title:s?"Nothing yet today — start capturing.":`Nothing on ${a}.`,action:s?e.jsx(c,{to:"/new",className:"btn btn-primary",children:"New note"}):void 0})}function I(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3].map(s=>e.jsx(T,{className:"h-14 rounded-xl"},s))})}function M({error:s}){const a=s instanceof P;return e.jsx(V,{title:a?"Session expired":"Could not load notes",message:s.message,action:a?e.jsx(c,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}export{Z as DayView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,j as e,a6 as H,ad as oe,V as I,a7 as le,ae as ce,a as K,af as de,N as ue,L as $,E as me,w as fe,b as he,ag as q,ah as xe,ai as pe,aj as ge,ak as be,a8 as ve,al as T,am as je,an as Ne,x as F,ao as we}from"./index-BKfqr8sS.js";import{A as ye}from"./attachment-upload-D6wfJsr6.js";import{u as Se,C as ke,A as Ce,a as Ee}from"./useAttachmentUploader-Be6yFw7I.js";import{P as Re,D as Ae}from"./PinArchiveButtons-8xFKv2oH.js";import{b as De,N as Te}from"./NoteRenderer-DG6I-BOG.js";import{r as Pe}from"./editor-mode-D9fveTEx.js";const Ie=250;function $e({noteId:t,attachment:a}){const[r,l]=n.useState(!1),x=Le(a);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>l(!0),"aria-label":`Remove attachment ${x}`,className:"shrink-0 rounded border border-transparent px-1.5 py-0.5 text-fg-dim hover:border-red-500/40 hover:text-red-400",children:"✕"}),r?e.jsx(Fe,{noteId:t,attachment:a,label:x,onClose:()=>l(!1)}):null]})}function Fe({noteId:t,attachment:a,label:r,onClose:l}){const x=H(o=>o.push),i=oe(),[u,m]=n.useState(!1),[f,N]=n.useState(null),d=n.useRef(null);n.useEffect(()=>{const o=setTimeout(()=>m(!0),Ie);return()=>clearTimeout(o)},[]),n.useEffect(()=>{var o;(o=d.current)==null||o.focus()},[]),n.useEffect(()=>{const o=k=>{k.key==="Escape"&&l()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]);const g=n.useCallback(()=>{!u||i.isPending||(N(null),i.mutate({noteId:t,attachmentId:a.id},{onSuccess:()=>{x(`Removed ${r}`,"success"),l()},onError:o=>{if(o instanceof I){N("Session expired. Reconnect to remove attachments.");return}if(o instanceof le){x(`Already removed ${r}`,"info"),l();return}N(o instanceof Error?o.message:"Remove failed")}}))},[u,a.id,r,i,t,l,x]);return e.jsx("dialog",{open:!0,"aria-labelledby":"confirm-remove-attachment-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:o=>{o.target===o.currentTarget&&l()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"confirm-remove-attachment-title",className:"mb-2 font-serif text-lg text-red-400",children:"Remove attachment?"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[e.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:r})," ","will be detached from this note. If no other note references the file, it will also be deleted from storage. Markdown referencing it will show a broken link until you update it."]}),f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{ref:d,type:"button",onClick:l,className:"min-h-11 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:g,disabled:!u||i.isPending,className:"btn btn-danger-solid btn-touch",children:i.isPending?"Removing…":"Remove"})]})]})})}function Le(t){if(t.filename)return t.filename;if(t.path){const a=t.path.split("/").pop();return a||t.path}return t.id}function Ge(){const{id:t}=ce(),a=K(l=>l.getActiveVault()),r=de(t);return a?e.jsxs("div",{className:"page",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx($,{to:t?`/n/${encodeURIComponent(t)}`:"/",className:"focus-ring hover:text-accent",children:"← Back to note"})}),r.isPending?e.jsx(Ve,{}):r.isError?e.jsx(_e,{error:r.error}):r.data?e.jsx(Be,{note:r.data}):e.jsx(Oe,{id:t??""})]}):e.jsx(ue,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function Be({note:t}){const a=he(),r=H(s=>s.push),l=q(s=>s.on),x=q(s=>s.setOn),i=n.useRef(K.getState().activeVaultId).current,u=n.useRef(Pe()).current,m=n.useMemo(()=>De(t),[t]),[f,N]=n.useState(()=>S(t)),[d,g]=n.useState(()=>S(t)),[o,k]=n.useState(()=>{if(!i)return null;const s=xe(i,t.id);return!s||pe(s.body,S(t))?null:s}),[Z,L]=n.useState(""),[B,C]=n.useState(null),[M,E]=n.useState(null),[U,V]=n.useState(!1),w=n.useRef(null);n.useEffect(()=>()=>{w.current!==null&&window.clearTimeout(w.current)},[]);const[R,G]=n.useState("edit"),j=ge(t.id),A=n.useRef(t),P=n.useRef(null),O=n.useRef(null),v=Se({noteId:t.id,onInsert:s=>{P.current?P.current.insertAtCursor(s):g(c=>({...c,content:`${c.content}${s}`}))},onLinked:()=>{r("Attachment added","success")},onError:s=>r(s,"error")});n.useEffect(()=>{A.current=t},[t]);const h=d.content!==f.content||d.path!==f.path||!We(d.tags,f.tags);be(i,t.id,d,h);const y=v.uploads.some(s=>s.status==="uploading"||s.status==="linking"),D=n.useCallback(({navigateToView:s})=>{if(!h||j.isPending||y)return;const c={};d.content!==f.content&&(c.content=d.content),d.path!==f.path&&(c.path=d.path);const b=ze(f.tags,d.tags);(b.add.length||b.remove.length)&&(c.tags=b);const z=A.current.updatedAt??A.current.createdAt;z&&(c.if_updated_at=z),E(null),C(null),j.mutate(c,{onSuccess:p=>{N(S(p)),g(S(p)),A.current=p,i&&T(i,t.id),s?a(`/n/${encodeURIComponent(p.id)}`,{replace:!0}):p.id!==t.id&&a(`/n/${encodeURIComponent(p.id)}/edit`,{replace:!0}),s||(V(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>V(!1),1500))},onError:p=>{p instanceof ve?C(p):p instanceof I?E("Session expired. Reconnect to save."):E(p instanceof Error?p.message:"Save failed")}})},[f,d,h,j,a,t.id,y,i]),Q=n.useCallback(()=>{o&&g(o.body),k(null)},[o]),X=n.useCallback(()=>{i&&T(i,t.id),k(null)},[i,t.id]),ee=n.useCallback(()=>D({navigateToView:!0}),[D]),te=n.useCallback(()=>D({navigateToView:!1}),[D]),se=n.useCallback(()=>{h&&confirm("Discard all edits and revert to last saved version?")&&(g(f),C(null),E(null))},[f,h]),_=n.useCallback(()=>{h&&!confirm("Discard unsaved changes?")||(i&&T(i,t.id),a(`/n/${encodeURIComponent(t.id)}`))},[h,a,t.id,i]);n.useEffect(()=>{if(!h)return;const s=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[h]);const ne=d.path!==f.path,ae=s=>{const c=we(s);c&&(d.tags.includes(c)||(g(b=>({...b,tags:[...b.tags,c]})),L("")))},re=s=>{g(c=>({...c,tags:c.tags.filter(b=>b!==s)}))},ie=d.content,W=l?"h-[85dvh]":"h-[60dvh]";return e.jsxs("article",{children:[l?e.jsx("div",{className:"glass-panel enter-fade fixed top-4 left-4 z-30 rounded-full border border-border px-3 py-1.5 text-xs shadow-lift",style:{marginTop:"env(safe-area-inset-top)"},children:e.jsx(Y,{isDirty:h,justSaved:U,updatedAt:t.updatedAt})}):e.jsxs("header",{className:"card mb-6 p-5 shadow-soft md:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"eyebrow",children:"Editing"}),e.jsx(Y,{isDirty:h,justSaved:U,updatedAt:t.updatedAt})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Re,{note:t}),e.jsx(Ae,{note:t}),e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(je,{width:16,height:16}),"Focus"]}),e.jsx("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":"true"}),e.jsx("button",{type:"button",onClick:se,disabled:!h||j.isPending,className:"btn btn-secondary btn-touch",children:"Revert"}),e.jsx("button",{type:"button",onClick:_,className:"btn btn-secondary btn-touch",children:"Cancel"}),e.jsx("button",{type:"button",onClick:ee,disabled:!h||j.isPending||y,className:"btn btn-primary btn-touch",title:y?"Waiting for upload…":"Save (⌘S)","aria-label":y?"Save — waiting for upload…":"Save",children:j.isPending?"Saving…":"Save"})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Ne,{tags:d.tags,input:Z,onInputChange:L,onAdd:ae,onRemove:re})}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-fg-dim",children:[e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-xs",children:"Path"}),e.jsx("input",{type:"text",value:d.path,onChange:s=>g(c=>({...c,path:s.target.value})),className:"focus-ring w-full min-w-0 truncate rounded border-0 bg-transparent font-mono text-xs text-fg-dim outline-none transition-colors hover:text-fg-muted focus:text-fg placeholder:text-fg-dim","aria-label":"Note path",placeholder:"(no path)",title:d.path||void 0})]}),ne?e.jsx("p",{className:"mt-1 text-xs text-accent",children:"Renaming moves the note — its id may change."}):null]}),o?e.jsxs("div",{role:"status","data-testid":"draft-offer",className:"mb-4 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-accent/30 bg-accent/5 px-3 py-2 text-sm",children:[e.jsxs("span",{className:"text-fg-muted",children:["You have an unsaved draft from ",F(o.savedAt),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:Q,className:"focus-ring font-medium text-accent hover:underline",children:"Restore"}),e.jsx("button",{type:"button",onClick:X,className:"focus-ring text-fg-dim hover:text-danger",children:"Discard"})]})]}):null,B?e.jsx(Ue,{conflict:B,onReload:()=>{i&&T(i,t.id),window.location.reload()},onDismiss:()=>C(null)}):null,M?e.jsx("div",{className:"mb-4 rounded-xl border border-danger-border bg-danger-soft p-3 text-sm text-danger",children:M}):null,u?null:e.jsx("div",{role:"tablist","aria-label":"Editor view",className:"mb-3 inline-flex rounded-lg border border-border bg-card p-0.5 text-sm lg:hidden",children:["edit","preview"].map(s=>e.jsx("button",{type:"button",role:"tab","aria-selected":R===s,onClick:()=>G(s),className:`rounded-sm px-3 py-1.5 capitalize ${R===s?"bg-accent text-on-accent":"text-fg-muted hover:text-accent"}`,children:s},s))}),e.jsxs("div",{className:`grid ${l?"min-h-[85dvh]":"min-h-[60dvh]"} gap-4 ${u?"":"lg:grid-cols-2"}`,children:[e.jsx(ye,{onDropFiles:v.start,className:`card min-h-0 ${W} min-w-0 ${u||R==="edit"?"":"hidden lg:block"}`,hint:J,children:e.jsx(ke,{ref:P,value:d.content,onChange:s=>g(c=>({...c,content:s})),onSave:te,onCancel:_,onPasteFile:s=>(v.start(s),!0),onRequestAttachment:()=>{var s;return(s=O.current)==null?void 0:s.open()},livePreview:u})}),u?null:e.jsx("div",{className:`card min-h-0 ${W} min-w-0 overflow-auto p-4 ${R==="preview"?"":"hidden lg:block"}`,children:e.jsx(Te,{note:{path:d.path,content:ie},resolve:m})})]}),e.jsx(Me,{noteId:t.id,pickerRef:O,attachments:t.attachments??[],uploads:v.uploads,onPickFiles:v.start,onCancel:v.cancel,onDismiss:v.dismiss})]})}const J=e.jsxs(e.Fragment,{children:["Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"text-accent hover:underline",children:"PDF + mp4 coming"})]});function Me({noteId:t,pickerRef:a,attachments:r,uploads:l,onPickFiles:x,onCancel:i,onDismiss:u}){return e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-xl",children:"Attachments"}),e.jsx(Ce,{ref:a,onPickFiles:x})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Max 100 MB each. ",J,"."]}),e.jsx(Ee,{uploads:l,onCancel:i,onDismiss:u}),r.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:r.map(m=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-lg border border-border bg-card/50 px-3 py-1.5 font-mono text-xs",children:[e.jsx("span",{className:"truncate",title:m.path??m.id,children:m.filename??m.path??m.id}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.mimeType?e.jsx("span",{className:"text-fg-dim",children:m.mimeType}):null,e.jsx($e,{noteId:t,attachment:m})]})]},m.id))}):null]})}function Ue({conflict:t,onReload:a,onDismiss:r}){return e.jsxs("div",{className:"mb-4 rounded-xl border border-warning bg-warning-soft p-4",children:[e.jsx("p",{className:"mb-1 font-medium text-warning",children:"This note was edited elsewhere."}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Your save was rejected to avoid overwriting the other edit.",t.currentUpdatedAt?` Latest update ${F(t.currentUpdatedAt)}.`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:a,className:"btn btn-primary btn-touch",children:"Reload latest (discard my edits)"}),e.jsx("button",{type:"button",onClick:r,className:"btn btn-secondary btn-touch",children:"Keep editing"})]})]})}function Ve(){return e.jsxs("div",{className:"grid min-h-[60dvh] gap-4 lg:grid-cols-2","aria-busy":"true",children:[e.jsx("div",{className:"card animate-pulse"}),e.jsx("div",{className:"card animate-pulse"})]})}function Oe({id:t}){return e.jsx(fe,{title:e.jsx("span",{className:"font-serif text-xl text-fg",children:"Note not found"}),description:e.jsxs(e.Fragment,{children:["No note with id ",e.jsx("span",{className:"font-mono",children:t})," in this vault."]}),action:e.jsx($,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function Y({isDirty:t,justSaved:a,updatedAt:r}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-accent","aria-label":"unsaved changes",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent"}),"unsaved"]}):a?e.jsx("span",{className:"text-xs text-accent","aria-label":"saved",children:"Saved ✓"}):e.jsxs("span",{className:"text-xs text-fg-dim",children:["saved ",F(r)]})}function _e({error:t}){const a=t instanceof I;return e.jsx(me,{title:a?"Session expired":"Could not load note",message:t.message,action:a?e.jsx($,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function We(t,a){if(t.length!==a.length)return!1;const r=new Set(t);for(const l of a)if(!r.has(l))return!1;return!0}function ze(t,a){const r=new Set(t),l=new Set(a),x=a.filter(u=>!r.has(u)),i=t.filter(u=>!l.has(u));return{add:x,remove:i}}export{Ge as NoteEditor};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{ap as _e,r as o,aq as Me,ar as $e,as as he,a as Le,b as Ue,a6 as qe,at as Fe,au as Ve,av as Oe,aw as Ge,a1 as Be,a5 as He,ax as We,ah as Ye,ay as ze,y as Ke,ak as Qe,j as e,N as Ze,az as Je,aA as ge,V as Xe,al as G,aB as et,aC as tt,aD as J,aE as st,aF as nt,aG as at,aH as I,L as rt,an as ot,x as it,aI as ct,ao as lt}from"./index-BKfqr8sS.js";import{v as dt,A as ut}from"./attachment-upload-D6wfJsr6.js";import{u as mt,C as pt,A as ft,a as ht}from"./useAttachmentUploader-Be6yFw7I.js";import{b as gt,N as xt}from"./NoteRenderer-DG6I-BOG.js";import{l as xe,u as bt,a as vt,b as yt}from"./transcribe-default-Cjxt7F_e.js";import{r as jt}from"./editor-mode-D9fveTEx.js";import"./types-BaJkUfo6.js";const kt=30*6e4,wt=20*1024*1024,Rt=1e4;function Nt(t){const c=t.segmentMs??kt,l=t.setTimer??((x,T)=>setTimeout(x,T)),b=t.clearTimer??(x=>clearTimeout(x)),w=t.makeRecorder??(x=>_e({...x,releaseStreamOnStop:!1})),g=[];let n=null,d=null,f="idle",u=0,h=0,y=!1;const m=()=>{for(const x of t.stream.getTracks())x.stop()},r=()=>{d!==null&&(b(d),d=null)},p=()=>{d=l(()=>{d=null,R()},c)},i=()=>{h+=1;const x=h;n=w({stream:t.stream,mimeType:t.mimeType,releaseStreamOnStop:!1,now:t.now,MediaRecorderCtor:t.MediaRecorderCtor,dataIntervalMs:Rt,onData:T=>{x===h&&T>=wt&&R()}}),n.start(),u+=1,p()},R=()=>{var x;f!=="recording"||!n||y||(y=!0,r(),g.push(n.stop()),i(),(x=t.onRoll)==null||x.call(t,u),y=!1)};return{get state(){return f},get activePart(){return u},start(){if(f!=="idle")throw new Error(`Cannot start from ${f}`);f="recording",i()},async stop(){if(f!=="recording"||!n)throw new Error(`Cannot stop from ${f}`);f="stopped",r(),g.push(n.stop()),n=null;const x=await Promise.all(g);return m(),x},cancel(){r(),n&&n.cancel(),n=null,f="stopped",m()}}}function Tt(){const[t,c]=o.useState({kind:"idle"}),[l,b]=o.useState(0),[w,g]=o.useState(0),n=o.useRef(null),d=o.useRef(null);o.useEffect(()=>{if(t.kind!=="recording")return;const m=setInterval(()=>b(Date.now()-t.startedAt),250);return()=>clearInterval(m)},[t]),o.useEffect(()=>()=>{d.current&&URL.revokeObjectURL(d.current),n.current&&n.current.state==="recording"&&n.current.cancel()},[]);const f=o.useCallback(async()=>{if(!(t.kind==="recording"||t.kind==="requesting")){c({kind:"requesting"});try{const m=Me();if(!m){c({kind:"denied",message:"This browser can't record audio in a format we can save."});return}const r=await $e(),p=Nt({stream:r,mimeType:m,onRoll:i=>g(i)});n.current=p,p.start(),b(0),g(p.activePart),c({kind:"recording",startedAt:Date.now()})}catch(m){const r=m,p=r.kind==="permission-denied"?"Microphone access was denied. Update your browser's site settings to record.":r.kind==="no-device"?"No microphone was found on this device.":r instanceof Error?r.message:"Microphone is not available in this browser.";c({kind:"denied",message:p})}}},[t]),u=o.useCallback(async()=>{var r;const m=n.current;if(!(!m||t.kind!=="recording"))try{const p=await m.stop();n.current=null,g(0);const i=((r=p[0])==null?void 0:r.mimeType)??"",R=p.reduce((B,U)=>B+U.durationMs,0),x=p[0],T=x?URL.createObjectURL(new Blob([x.data],{type:x.mimeType})):"";d.current&&URL.revokeObjectURL(d.current),d.current=T||null,c({kind:"have-audio",segments:p,mimeType:i,url:T,durationMs:R})}catch(p){console.warn(p instanceof Error?`Recording failed: ${p.message}`:"Recording failed."),g(0),c({kind:"idle"})}},[t]),h=o.useCallback(()=>{d.current&&(URL.revokeObjectURL(d.current),d.current=null),c({kind:"idle"}),b(0),g(0)},[]),y=o.useCallback(()=>{h()},[h]);return{phase:t,elapsedMs:l,parts:w,startRecording:f,stopRecording:u,discardAudio:h,reset:y}}function St(t){const{segments:c,mimeType:l,recordedAt:b,willTranscribe:w}=t,g=c.length>1,n=t.typedText.trim(),d=c.map((y,m)=>({filename:g?he(l,b,m+1):he(l,b),transcribe:w,...w&&g?{segment_index:m}:{}})),f=w?g?c.map((y,m)=>`_Transcript pending (part ${m+1})._`).join(`
|
|
2
|
-
|
|
3
|
-
`):"_Transcript pending._":"",u=d.map(y=>`![[${y.filename}]]`).join(`
|
|
4
|
-
|
|
5
|
-
`),h=[];return n&&h.push(n),f&&h.push(f),h.push(u),{body:`${h.join(`
|
|
6
|
-
|
|
7
|
-
`)}
|
|
8
|
-
`,segments:d}}const be={content:"",path:"",tags:[]};function Ut(){const t=Le(s=>s.getActiveVault()),c=Ue(),l=qe(s=>s.push),b=Fe(),w=Ve(),g=Oe(),{db:n,blobStore:d,engine:f}=Ge(),{roles:u}=Be((t==null?void 0:t.id)??null),h=He(),y=o.useRef(We()),m=o.useRef(jt()).current,r=o.useRef((t==null?void 0:t.id)??null).current,p=o.useRef(null),[i,R]=o.useState(()=>{if(r){const s=Ye(r,I);if(s)return p.current=s.savedAt,s.body}return{...be,path:y.current}}),[x,T]=o.useState(()=>p.current),[B,U]=o.useState(""),[ee,C]=o.useState(null),[q,ye]=o.useState([]),[je,te]=o.useState(!1),H=o.useRef(null),se=o.useRef(null),v=Tt(),D=ze(),N=D.capability,ke=v.phase.kind==="requesting"||v.phase.kind==="recording"||v.phase.kind==="have-audio",we=(N==null?void 0:N.enabled)===!1&&!ke,W=typeof(N==null?void 0:N.minutes_remaining)=="number"?N.minutes_remaining:void 0,Y=W!==void 0&&W<=0,[z,ne]=o.useState(()=>r?xe(r):!0),Re=(N==null?void 0:N.enabled)!==!1,ae=o.useRef(v.phase.kind);o.useEffect(()=>{const s=ae.current,a=v.phase.kind;ae.current=a,a==="idle"&&s!=="idle"&&r&&ne(xe(r))},[v.phase.kind,r]);const[Ne]=Ke(),re=Ne.has("voice"),oe=o.useRef(!1);o.useEffect(()=>{var s;!re||oe.current||D.settled&&((s=D.capability)==null?void 0:s.enabled)!==!1&&(oe.current=!0,v.startRecording())},[re,D.settled,D.capability,v.startRecording]);const A=mt({noteId:null,onInsert:s=>{H.current?H.current.insertAtCursor(s):R(a=>({...a,content:`${a.content}${s}`}))},onStaged:s=>ye(a=>[...a,s]),onError:s=>l(s,"error")}),_=o.useRef(p.current!==null),F=o.useRef(null);o.useEffect(()=>{_.current||(R(s=>{const a=F.current?s.tags.filter(P=>P!==F.current):s.tags,j=a.includes(u.captureText)?a:[...a,u.captureText];return j===s.tags?s:{...s,tags:j}}),F.current=u.captureText)},[u.captureText]);const ie=!_.current&&(i.tags.length===0||i.tags.length===1&&i.tags[0]===u.captureText),Te=i.content.trim().length>0||!ie||i.path.trim().length>0&&i.path!==y.current;if(Qe(r,I,i,Te),!t)return e.jsx(Ze,{to:"/",replace:!0});const M=v.phase.kind==="have-audio",K=i.content.trim().length>0,V=i.content.length>0||i.path!==y.current||!ie||M,$=i.path.trim().length>0&&(K||M),E=b.isPending||je,ce=o.useCallback(()=>{if(!$||E)return;const s=Je({content:i.content,path:i.path,tags:i.tags});h&&ge(t.id,h),C(null),b.mutate(s,{onSuccess:async a=>{for(const j of q)try{await w.mutateAsync({noteId:a.id,path:j.path,mimeType:j.mimeType})}catch(P){const Q=P instanceof Error?P.message:"Link failed";l(`Failed to attach ${j.filename}: ${Q}`,"error")}r&&G(r,I),l(`Created ${a.path??a.id}`,"success"),c(`/n/${encodeURIComponent(a.id)}`,{replace:!0})},onError:a=>{a instanceof Xe?C("Session expired. Reconnect to save."):C(a instanceof Error?`${a.message} — if the path is taken, try a different one.`:"Create failed")}})},[t,r,h,i,$,w,b,c,E,l,q]),le=o.useCallback(async()=>{if(!$||E||v.phase.kind!=="have-audio")return;if(!n||!d){l("Sync queue not ready — try again in a moment.","error");return}C(null);const s=v.phase,a=s.segments,j=s.mimeType,P=i.path.trim(),Q=i.tags,Pe=et(i.content),me=Array.from(new Set([u.captureVoice,...Q,...Pe].filter(k=>k.length>0)));K&&me.push(u.captureText);const pe=Array.from(new Set(me)),Ie=new Date,L=tt(),De=!Y&&z,O=St({segments:a,mimeType:j,typedText:i.content,recordedAt:Ie,willTranscribe:De});for(let k=0;k<a.length;k++){const S=dt(new File([a[k].data],O.segments[k].filename,{type:j}));if(S){l(S,"error"),C(S);return}}te(!0),h&&ge(t.id,h);const fe={content:O.body,path:P,metadata:{source:"voice"},...pe.length?{tags:pe}:{}};try{await J(n,{kind:"create-note",localId:L,payload:fe},{vaultId:t.id});for(let k=0;k<O.segments.length;k++){const S=O.segments[k],Z=st();await d.put(Z,a[k].data,j,t.id),await J(n,{kind:"upload-attachment",blobId:Z,filename:S.filename,mimeType:j},{vaultId:t.id}),await J(n,{kind:"link-attachment",noteId:L,pathRef:nt(Z),mimeType:j,transcribe:S.transcribe,...S.segment_index!==void 0?{segment_index:S.segment_index}:{}},{vaultId:t.id})}f==null||f.runOnce(),g.setQueryData(["note",t.id,L],at(fe,L)),r&&G(r,I),l("Captured — syncing audio.","success"),v.discardAudio(),c(`/n/${encodeURIComponent(L)}`,{replace:!0})}catch(k){l(k instanceof Error?`Capture failed: ${k.message}`:"Capture failed.","error"),C(k instanceof Error?k.message:"Capture failed")}finally{te(!1)}},[t,r,d,h,n,i,f,K,$,c,Y,E,l,g,u.captureText,u.captureVoice,z,v]),de=o.useCallback(()=>{M?le():ce()},[M,ce,le]),ue=o.useCallback(()=>{V&&!confirm("Discard this draft?")||(r&&G(r,I),v.discardAudio(),c("/"))},[r,V,c,v]),Se=o.useCallback(()=>{r&&G(r,I),_.current=!1,F.current=u.captureText,R({...be,path:y.current,tags:[u.captureText]}),v.discardAudio(),T(null)},[r,v,u.captureText]);o.useEffect(()=>{if(!V)return;const s=a=>{a.preventDefault(),a.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[V]);const Ce=s=>{const a=lt(s);!a||i.tags.includes(a)||(_.current=!0,R(j=>({...j,tags:[...j.tags,a]})),U(""))},Ae=s=>{_.current=!0,R(a=>({...a,tags:a.tags.filter(j=>j!==s)}))},Ee=gt({id:"__new__",createdAt:new Date().toISOString()});return e.jsxs("div",{className:"page",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx(rt,{to:"/notes",className:"hover:text-accent",children:"← All notes"})}),e.jsxs("article",{children:[e.jsxs("header",{className:"composer mb-6 p-5 md:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{className:"eyebrow",children:"New note"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:ue,className:"btn btn-secondary btn-touch",children:"Cancel"}),e.jsx("button",{type:"button",onClick:de,disabled:!$||E,className:"btn btn-primary btn-touch",title:"Create (⌘S)",children:E?"Creating…":"Create"})]})]}),e.jsx("input",{type:"text",value:i.path,onChange:s=>R(a=>({...a,path:s.target.value})),className:i.path===y.current?"mt-4 w-full border-0 bg-transparent font-sans text-sm text-fg-dim outline-none placeholder:text-fg-dim":"mt-4 w-full border-0 bg-transparent font-serif text-2xl text-fg outline-none placeholder:text-fg-dim md:text-3xl","aria-label":"Note path",placeholder:"Name your note — or just start writing"}),e.jsx("div",{className:"mt-4",children:e.jsx(ot,{tags:i.tags,input:B,onInputChange:U,onAdd:Ce,onRemove:Ae})})]}),x?e.jsxs("div",{role:"status","data-testid":"draft-restored",className:"mb-4 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-accent/30 bg-accent/5 px-3 py-2 text-sm",children:[e.jsxs("span",{className:"text-fg-muted",children:["Unsaved draft restored from ",it(x),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:Se,className:"text-fg-dim hover:text-danger",children:"Discard draft"}),e.jsx("button",{type:"button",onClick:()=>T(null),"aria-label":"Dismiss draft-restored notice",className:"text-fg-dim hover:text-accent",children:"✕"})]})]}):null,ee?e.jsx("div",{role:"alert",className:"mb-4 rounded-xl border border-danger-border bg-danger-soft p-3 text-sm text-danger",children:ee}):null,we?e.jsx(ct,{capability:N}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{voice:v,minutesRemaining:W,outOfMinutes:Y,transcribe:z,onTranscribeChange:ne,showTranscribeToggle:Re}),e.jsx(Ct,{vaultId:t.id,captureEngaged:M})]}),e.jsxs("div",{className:`grid min-h-[60dvh] gap-4 ${m?"":"lg:grid-cols-2"}`,children:[e.jsx(ut,{onDropFiles:A.start,className:"card min-h-0 h-[60dvh] min-w-0",hint:"Images, audio, webm video",children:e.jsx(pt,{ref:H,value:i.content,onChange:s=>R(a=>({...a,content:s})),onSave:de,onCancel:ue,placeholder:"Start writing…",onPasteFile:s=>(A.start(s),!0),onRequestAttachment:()=>{var s;return(s=se.current)==null?void 0:s.open()},livePreview:m})}),m?null:e.jsx("div",{className:"card min-w-0 overflow-auto p-4 lg:h-[60dvh] lg:min-h-0",children:i.content.trim()?e.jsx(xt,{note:{path:i.path,content:i.content},resolve:Ee}):e.jsx("p",{className:"text-sm text-fg-dim",children:"Preview appears here as you type."})})]}),e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-xl",children:"Attachments"}),e.jsx(ft,{ref:se,onPickFiles:A.start})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Attachments link to the note when you save. Max 100 MB each. Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"text-accent hover:underline",children:"PDF + mp4 coming"}),"."]}),e.jsx(ht,{uploads:A.uploads,onCancel:A.cancel,onDismiss:A.dismiss}),q.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:q.map(s=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-lg border border-border bg-card/50 px-3 py-1.5 font-mono text-xs text-fg-muted",children:[e.jsx("span",{className:"truncate",children:s.filename}),e.jsx("span",{className:"shrink-0 text-fg-dim",children:"staged"})]},s.path))}):null]})]})]})}function Ct({vaultId:t,captureEngaged:c}){const l=bt(),b=vt(),{made:w,markMade:g}=yt(t),[n,d]=o.useState(null);if(!(c&&!w&&l.supported&&l.value==="keep"))return null;const u=h=>{d(null),b.mutate(h,{onSuccess:()=>g(),onError:()=>d("Couldn't save that choice — this recording is kept (the vault default). We'll ask again next time; you can also set it in Settings.")})};return e.jsxs("div",{"data-testid":"retention-choice",className:"mb-4 flex flex-col gap-2 rounded-xl border border-border bg-card/60 p-3",children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"First voice note here — should this vault keep your audio files after transcribing?"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>u("keep"),disabled:b.isPending,className:"btn btn-secondary btn-touch",children:"Keep my recordings"}),e.jsx("button",{type:"button",onClick:()=>u("until_transcribed"),disabled:b.isPending,className:"btn btn-secondary btn-touch",children:"Just keep the words"}),e.jsx("span",{className:"text-xs text-fg-dim",children:"(audio deleted after transcribing)"})]}),e.jsx("p",{className:"text-xs text-fg-dim",children:"Either way your capture saves now. Change this anytime in Settings."}),n?e.jsx("p",{className:"text-xs text-danger","data-testid":"retention-choice-error",children:n}):null]})}const At=30;function ve({checked:t,disabled:c,onChange:l}){return e.jsxs("div",{className:"flex basis-full items-center gap-3",children:[e.jsx("span",{className:"text-xs text-fg-dim",children:"Transcribe this recording"}),e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Transcribe this recording","data-testid":"transcribe-toggle",disabled:c,onClick:()=>l(!t),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors disabled:opacity-40 ${t?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${t?"translate-x-5":"translate-x-0.5"}`})})]})}function Et({voice:t,minutesRemaining:c,outOfMinutes:l,transcribe:b,onTranscribeChange:w,showTranscribeToggle:g}){const{phase:n,elapsedMs:d,parts:f,startRecording:u,stopRecording:h,discardAudio:y}=t,m=n.kind==="recording",r=n.kind==="requesting",p=!l&&b,i=typeof c=="number"&&c<=At;return n.kind==="have-audio"?e.jsxs("div",{className:"mb-4 flex flex-col gap-2 rounded-xl border border-accent/30 bg-accent/5 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-sm text-fg-muted",children:["🎙 Recorded ",X(n.durationMs),n.segments.length>1?` · ${n.segments.length} parts`:""]}),e.jsx("button",{type:"button",onClick:y,className:"text-xs text-fg-dim hover:text-danger",children:"Discard"})]}),e.jsx("audio",{controls:!0,src:n.url,className:"w-full",children:e.jsx("track",{kind:"captions"})}),g?e.jsx(ve,{checked:p,disabled:l,onChange:w}):null,e.jsx("p",{className:"text-xs text-fg-dim",children:l?"Saved as audio-only — you're out of transcription minutes this month.":p?"Transcript will be appended once your vault processes it. Save to commit.":"Saved as audio-only — transcription is off for this recording."})]}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-border bg-card/60 p-3",children:[e.jsx("div",{className:"text-xs text-fg-dim",children:m?f>1?`Recording — tap Stop to finish. (part ${f})`:"Recording — tap Stop to finish.":r?"Requesting microphone…":l?"You're out of transcription minutes this month — this saves as audio-only.":p?"Add a voice memo to this note. Audio gets transcribed and appended.":"Add a voice memo to this note. Saved as audio-only — transcription is off for this recording."}),m?e.jsxs("button",{type:"button",onClick:()=>void h(),"aria-label":`Recording — ${X(d)} — stop`,"aria-pressed":"true",className:"flex min-h-11 items-center gap-2 rounded-full border border-danger-border bg-danger-soft px-4 py-2 text-sm font-medium text-danger",children:[e.jsx("span",{"aria-hidden":"true",className:"animate-pulse",children:"🎙"}),e.jsxs("span",{children:["Stop ",X(d)]})]}):e.jsxs("button",{type:"button",onClick:()=>void u(),"aria-label":"Record voice memo",disabled:r,className:"flex min-h-11 items-center gap-2 rounded-full border border-accent/30 bg-accent/10 px-4 py-2 text-sm font-medium text-accent hover:bg-accent/15 disabled:opacity-40",children:[e.jsx("span",{"aria-hidden":"true",children:"🎙"}),e.jsx("span",{children:r?"Requesting…":"Record"})]}),g?e.jsx(ve,{checked:p,disabled:l,onChange:w}):null,i&&!l?e.jsxs("p",{className:"basis-full text-xs text-fg-dim","data-testid":"voice-minutes-left",children:["About ",Math.round(c)," min of transcription left this month."]}):null,n.kind==="denied"?e.jsx("p",{className:"basis-full rounded-xl border border-danger-border bg-danger-soft px-3 py-2 text-xs text-danger",children:n.message}):null]})}function X(t){const c=Math.floor(t/1e3),l=Math.floor(c/60),b=c%60;return`${String(l).padStart(2,"0")}:${String(b).padStart(2,"0")}`}export{Ut as NoteNew};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as n,bH as Xe,r as g,bI as V,bJ as C,L as R,a$ as Ke,x as Ze,av as et,aj as Se,a6 as Ce,Q as B,bt as O,bK as $e,bL as Te,bM as tt,bN as Ee,R as nt,w as F,X as st,U as xe,$ as X,bO as De,bP as at,bQ as rt,bR as it,bS as lt,bT as ot,bU as Pe,a as Me,a1 as ct,y as dt,bV as ut,bW as mt,bX as pe,ae as xt,bY as pt,N as ht,E as Le,bZ as ft,b_ as _e,b$ as bt,c0 as Y,v as k,c1 as gt,c2 as yt,c3 as jt,at as vt,c4 as Nt,c5 as wt,a3 as he,a4 as fe,c6 as kt,bG as St}from"./index-BKfqr8sS.js";import{T as Ct}from"./TagSchemaEditor-ve19B-tr.js";const $t="—",Ae=/^https?:\/\//i;function Be(e){return typeof e=="string"&&Ae.test(e)}const be=24;function Tt(e){try{const t=new URL(e);let s=`${t.pathname}${t.search}${t.hash}`;return s==="/"&&(s=""),s.length>be&&(s=`${s.slice(0,be-1)}…`),{host:t.host,rest:s}}catch{return{host:e.replace(Ae,""),rest:""}}}function Et({value:e,schema:t}){if(e==null||e==="")return $t;if(typeof e=="boolean")return e?n.jsx("span",{className:"text-grass",children:"✓"}):n.jsx("span",{className:"text-fg-dim",children:"✕"});if((t==null?void 0:t.type)==="date"&&typeof e=="string")return Xe(e);if(Be(e)){const{host:s,rest:a}=Tt(e);return n.jsxs("span",{className:"min-w-0 truncate text-accent underline underline-offset-2",title:e,children:[s,a?n.jsx("span",{className:"opacity-70",children:a}):null]})}return typeof e=="number"?n.jsx("span",{className:"tabular-nums",children:String(e)}):String(e)}function I(e,t){if(t&&t.length>0||e!=null&&e.enum&&e.enum.length>0)return"enum";switch(e==null?void 0:e.type){case"date":return"date";case"boolean":return"boolean";case"number":return"number";default:return"string"}}const Dt="focus-ring inline-flex max-w-[9rem] items-center rounded px-1 py-0.5 text-[0.6875rem] hover:text-accent disabled:opacity-50";function Pt(e){if(typeof e!="string")return"";const t=e.match(/^\d{4}-\d{2}-\d{2}/);return t?t[0]:""}function Z({field:e,schema:t,value:s,onCommit:a,disabled:r=!1,options:i,includeClear:l=!1,trigger:o}){const u=I(t,i),[c,p]=g.useState(!1),x=s==null||s==="",d=(o==null?void 0:o.label)??n.jsx(Et,{value:s,schema:t}),h=(o==null?void 0:o.ariaLabel)??`Edit ${e}`,j=(o==null?void 0:o.className)??`${Dt} ${x&&!(o!=null&&o.label)?"text-fg-dim":"text-fg"}`;if(u==="boolean"){const v=(o==null?void 0:o.ariaLabel)??`Edit ${e} (${s===!0?"checked":"unchecked"})`;return n.jsx("button",{type:"button",disabled:r,"aria-label":v,onClick:()=>a(s!==!0),className:j,children:d})}const y=u==="enum"?i??((t==null?void 0:t.enum)??[]).map(v=>({value:v,label:v})):[],f=l&&!x,b=v=>{p(!1),a(v)};return n.jsxs("div",{className:"relative",children:[n.jsx("button",{type:"button",disabled:r,"aria-haspopup":u==="enum"?"menu":"dialog","aria-expanded":c,"aria-label":h,title:o!=null&&o.label?void 0:`Edit ${e}`,onClick:()=>p(v=>!v),className:j,children:d}),c?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"fixed inset-0 z-10 cursor-default",onClick:()=>p(!1)}),u==="enum"?n.jsxs("div",{role:"menu","aria-label":h,className:"card absolute right-0 z-20 mt-1 flex min-w-[10rem] flex-col gap-0.5 p-1 shadow-lg",children:[y.map(v=>n.jsxs("button",{type:"button",role:"menuitem",onClick:()=>b(v.value),className:`focus-ring flex items-center gap-1.5 rounded px-2 py-1.5 text-left text-sm hover:bg-bg-soft ${v.muted?"text-fg-dim":"text-fg"}`,children:[v.value===null||v.value===void 0||v.value===""?null:n.jsx("span",{"aria-hidden":"true",className:`tint-dot tint-${V(String(v.value))}`}),v.label]},v.value===null?"__clear__":String(v.value))),f?n.jsx("button",{type:"button",role:"menuitem",onClick:()=>b(null),className:"focus-ring rounded px-2 py-1.5 text-left text-sm text-fg-dim hover:bg-bg-soft",children:"Clear"}):null]}):n.jsx(Mt,{kind:u,value:s,ariaLabel:h,onCommit:b,onCancel:()=>p(!1)})]}):null]})}function Mt({kind:e,value:t,ariaLabel:s,onCommit:a,onCancel:r}){const i=e==="date"?Pt(t):t==null?"":String(t),[l,o]=g.useState(i),u=()=>{const c=l.trim();if(c==="")return a(null);if(e==="number"){const p=Number(c);return Number.isFinite(p)?a(p):r()}a(c)};return n.jsxs("div",{role:"dialog","aria-label":s,className:"card absolute right-0 z-20 mt-1 flex min-w-[10rem] items-center gap-1 p-1 shadow-lg",children:[n.jsx("input",{autoFocus:!0,type:e==="date"?"date":e==="number"?"number":"text",value:l,"aria-label":s,onChange:c=>o(c.target.value),onKeyDown:c=>{c.key==="Enter"?(c.preventDefault(),u()):c.key==="Escape"&&(c.preventDefault(),r())},className:"w-full rounded border border-border bg-bg/40 px-1.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"}),n.jsx("button",{type:"button",onClick:u,"aria-label":"Save",className:"focus-ring rounded px-1.5 py-1 text-xs text-accent hover:bg-bg-soft",children:"✓"}),Be(t)?n.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer","aria-label":"Open link",title:"Open link",className:"focus-ring rounded px-1.5 py-1 text-xs text-accent hover:bg-bg-soft",children:"↗"}):null]})}function Lt(e){for(const t of e.attachments??[]){const s=typeof t.url=="string"?t.url:null;if(typeof t.mimeType=="string"&&t.mimeType.startsWith("image/")&&s&&/^https?:\/\//i.test(s))return s}return null}function q({note:e,pinnedTag:t,archivedTag:s,variant:a="compact",overlay:r,footer:i,drag:l}){const o=C(e),u=e.updatedAt??e.createdAt,c=(e.tags??[]).includes(t),p=(e.tags??[]).includes(s),x=a==="gallery"?Lt(e):null,[d,h]=g.useState(!1),j=x&&!d,y=(l==null?void 0:l.canDrag)??!1,f=n.jsxs(R,{to:`/n/${encodeURIComponent(e.id)}`,draggable:y?!1:void 0,"data-note-id":e.id,className:`focus-ring card group flex flex-col overflow-hidden rounded-xl shadow-sm transition hover:border-accent hover:shadow-md ${p?"opacity-60 italic":""}`,children:[a==="gallery"?n.jsx("div",{className:"aspect-[3/2] w-full overflow-hidden bg-bg-soft",children:j?n.jsx("img",{src:x,alt:"",loading:"lazy",onError:()=>h(!0),className:"h-full w-full object-cover"}):n.jsx("div",{"aria-hidden":"true",className:"flex h-full w-full items-end p-3 text-fg-dim",children:n.jsx("span",{className:"line-clamp-3 text-sm text-fg-muted",children:e.preview??""})})}):null,n.jsxs("div",{className:"flex flex-1 flex-col gap-1 p-3",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[c?n.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,n.jsx("span",{className:o.kind==="timestamp"?"min-w-0 truncate text-sm title-timestamp":"min-w-0 truncate text-sm font-medium text-fg",children:o.text})]}),n.jsx(Ke,{note:e})]}),e.preview&&!(a==="gallery"&&!j)?n.jsx("p",{className:"line-clamp-2 text-xs text-fg-muted",children:e.preview}):null,n.jsx("span",{className:"mt-auto pt-1 text-[0.6875rem] tabular-nums text-fg-dim",children:Ze(u)})]})]});return!r&&!i&&!y?f:n.jsxs("div",{className:y?"relative flex flex-col cursor-grab":"relative flex flex-col",...(l==null?void 0:l.sourceProps)??{},children:[f,r?n.jsx("div",{className:"absolute right-2 top-2",children:r}):null,i?n.jsx("div",{className:"mt-1",children:i}):null]})}function _t(e,t,s){const a={...e.metadata??{}};return s===null?delete a[t]:a[t]=s,{...e,metadata:a}}function At(e,t,s,a){return e&&e.map(r=>r.id===t?_t(r,s,a):r)}function Bt(e,t){const s=et(),a=Se(e);return{move:g.useCallback(async(i,l,o)=>{const u=s.getQueryData(t);s.setQueryData(t,c=>At(c,e,i,l));try{const c=await a.mutateAsync({metadata:{[i]:l},...o?{if_updated_at:o}:{force:!0}}),p=c==null?void 0:c.updatedAt;p&&s.setQueryData(t,x=>x==null?void 0:x.map(d=>d.id===e?{...d,updatedAt:p}:d))}catch(c){throw s.setQueryData(t,u),c}},[s,t,e,a]),isPending:a.isPending}}const Ft=1800,Q="field-write-flash",Vt=700;function Rt(e){return e===null?null:typeof e=="boolean"?e?"Yes":"No":String(e)}function Ot(e){if(typeof document>"u")return;const t=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&");for(const s of document.querySelectorAll(`[data-note-id="${t}"]`))s.classList.remove(Q),s.offsetWidth,s.classList.add(Q),window.setTimeout(()=>s.classList.remove(Q),Vt)}function z(e,t){const s=Ce(c=>c.push),{move:a,isPending:r}=Bt(e.id,t),i=e.id,l=e.updatedAt,o=C(e).text;return{write:g.useCallback(async(c,p,x)=>{try{await a(c,p,l)}catch(h){const j=(x==null?void 0:x.errorPrefix)??`Couldn't update ${c} on "${o}"`;s(`${j}: ${h instanceof Error?h.message:"unknown error"}`,"error");return}const d=(x==null?void 0:x.valueLabel)??Rt(p);s(d===null?`✓ ${c} cleared`:`✓ ${c} → ${d}`,"success",{durationMs:Ft}),Ot(i)},[a,l,o,i,s]),isPending:r}}function Fe(e){if(e==null)return null;const t=typeof e;return t==="string"||t==="number"||t==="boolean"?e:null}function P({note:e,fields:t,viewResultsKey:s,omit:a}){const{write:r,isPending:i}=z(e,s),l=a&&a.length>0?t.filter(o=>!a.includes(o.name)):t;return l.length===0?null:n.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pt-0.5",children:l.map(o=>{var p;const u=Fe((p=e.metadata)==null?void 0:p[o.name]),c=I(o.schema)==="enum"&&u!==null&&u!==""?V(String(u)):null;return n.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border py-0.5 pl-2 pr-1 text-[0.6875rem] leading-none ${c?`chip-tinted tint-${c}`:"border-border bg-bg-soft/60"}`,children:[c?n.jsx("span",{"aria-hidden":"true",className:"tint-dot"}):null,n.jsx("span",{className:"text-fg-dim",children:o.name}),n.jsx(Z,{field:o.name,schema:o.schema,value:u,disabled:i,includeClear:!0,onCommit:x=>void r(o.name,x)})]},o.name)})})}function It(e,t){var a;const s=(a=e.metadata)==null?void 0:a[t];if(s==null)return null;if(typeof s=="string"){const r=s.trim();return r===""?null:r}return typeof s=="number"||typeof s=="boolean"?String(s):null}const qt={status:["active","incubating","dormant","paused","archived","done","shipped","dropped"],priority:["high","medium","low"]};function zt(e,t){var a;const s=(a=t==null?void 0:t[e])==null?void 0:a.enum;return s&&s.length>0?s:qt[e]??[]}function Gt(e,t,s=[]){var p;const a=new Map,r=new Map,i=[];for(const x of e){const d=It(x,t);if(d===null){i.push(x);continue}const h=a.get(d);h?h.push(x):(a.set(d,[x]),r.set(d,(p=x.metadata)==null?void 0:p[t]))}const l=s.filter(x=>a.has(x)),o=new Set(l),u=[...a.keys()].filter(x=>!o.has(x)).sort((x,d)=>x.localeCompare(d)),c=[...l,...u].map(x=>({key:x,label:x,notes:a.get(x)??[],uncategorized:!1,value:r.get(x)}));return i.length>0&&c.push({key:"",label:`No ${t}`,notes:i,uncategorized:!0,value:null}),c}function Ut(e){if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const s=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(s){const r=new Date(Number(s[1]),Number(s[2])-1,Number(s[3]));return Number.isNaN(r.getTime())?null:r}const a=new Date(t);return Number.isNaN(a.getTime())?null:a}function Yt(e,t){var i;const s=new Map,a=[],r=new Map;for(const l of e){const o=Ut((i=l.metadata)==null?void 0:i[t]);if(!o){a.push(l);continue}r.set(l.id,o);const u=B(o),c=s.get(u);c?c.push(l):s.set(u,[l])}return{byDay:s,undated:a,dates:r}}function Qt(e){const t=new Map,s=[],a=new Map;for(const r of e){const i=r.createdAt?new Date(r.createdAt):null;if(!i||Number.isNaN(i.getTime())){s.push(r);continue}a.set(r.id,i);const l=B(i),o=t.get(l);o?o.push(r):t.set(l,[r])}return{byDay:t,undated:s,dates:a}}function ge(e,t=new Date){let s=null;for(const r of e)(!s||r.getTime()>s.getTime())&&(s=r);const a=s??t;return{year:a.getFullYear(),month:a.getMonth()+1}}function Ht({notes:e,laneBy:t,subjectTag:s,roles:a,viewResultsKey:r,fields:i=[]}){const l=O(s??null),o=g.useMemo(()=>{var y,f,b,v;const c=Gt(e,t,zt(t,(y=l.data)==null?void 0:y.fields)),p=((v=(b=(f=l.data)==null?void 0:f.fields)==null?void 0:b[t])==null?void 0:v.enum)??[];if(p.length===0)return c;const x=new Map(c.filter(m=>!m.uncategorized).map(m=>[m.key,m])),d=p.map(m=>x.get(m)??{key:m,label:m,notes:[],uncategorized:!1,value:m}),h=new Set(p),j=c.filter(m=>m.uncategorized||!h.has(m.key));return[...d,...j]},[e,t,l.data]),u=$e();return n.jsx("div",{className:"overflow-x-auto pb-2",children:n.jsx("div",{className:"flex items-start gap-4",children:o.map(c=>n.jsx(Wt,{lane:c,dropRegistry:u,children:c.notes.map(p=>n.jsx(Xt,{note:p,laneBy:t,lanes:o,currentLane:c,roles:a,viewResultsKey:r,fields:i,dropRegistry:u},p.id))},c.uncategorized?"__uncategorized__":c.key))})})}function Wt({lane:e,dropRegistry:t,children:s}){const a=g.useCallback(l=>t.dispatch(l,e),[t,e]),{isOver:r,targetProps:i}=Te(a);return n.jsxs("section",{"aria-label":e.label,className:`flex w-72 shrink-0 flex-col gap-2 rounded-2xl border border-border-light bg-bg-soft p-2 ${r?"outline-2 outline-offset-2 outline-accent/50":""}`,...i,children:[n.jsxs("header",{className:"flex items-baseline justify-between gap-2 px-1.5 pt-1",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.uncategorized?null:n.jsx("span",{"aria-hidden":"true",className:`tint-dot tint-${V(e.key)}`}),n.jsx("span",{className:`min-w-0 truncate text-sm font-semibold ${e.uncategorized?"text-fg-dim":"text-fg"}`,children:e.label})]}),n.jsx("span",{className:"shrink-0 rounded-full bg-bg px-2 text-xs tabular-nums text-fg-dim",children:e.notes.length})]}),n.jsx("div",{className:"flex flex-col gap-2",children:e.notes.length===0?n.jsx("p",{className:"py-4 text-center text-xs italic text-fg-dim",children:tt()?"Drop here":"No notes"}):s})]})}function ye(e,t){return e.uncategorized||t.uncategorized?e.uncategorized&&t.uncategorized:e.key===t.key}const Jt="focus-ring rounded-full border border-border bg-bg-soft/90 px-2 py-0.5 text-[0.6875rem] font-medium text-fg-dim backdrop-blur transition-colors hover:text-accent disabled:opacity-50";function Xt({note:e,laneBy:t,lanes:s,currentLane:a,roles:r,viewResultsKey:i,fields:l,dropRegistry:o}){const{write:u,isPending:c}=z(e,i),p=g.useMemo(()=>s.filter(f=>!ye(f,a)),[s,a]),x=g.useMemo(()=>p.map(f=>({value:f.value,label:f.label,muted:f.uncategorized})),[p]),d=g.useCallback(async(f,b)=>{await u(t,f,{valueLabel:b,errorPrefix:`Couldn't move "${C(e).text}"`})},[u,t,e]),h=async f=>{const b=x.find(v=>v.value===f);await d(f,b==null?void 0:b.label)},j=Ee(e.id),y=g.useCallback(f=>{c||ye(f,a)||d(f.value,f.label)},[c,a,d]);return g.useEffect(()=>o.register(e.id,y),[o,e.id,y]),n.jsx(q,{note:e,pinnedTag:r.pinned,archivedTag:r.archived,drag:j,overlay:p.length>0?n.jsx(Z,{field:t,value:a.value,options:x,disabled:c,onCommit:f=>void h(f),trigger:{label:"Move",ariaLabel:`Move to another ${t}`,className:Jt}}):null,footer:l.length>0?n.jsx(P,{note:e,fields:l,viewResultsKey:i,omit:p.length>0?[t]:void 0}):null})}const Kt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],H=2;function Zt({notes:e,dateField:t,roles:s,viewResultsKey:a,fields:r=[]}){const i=g.useMemo(()=>t===null?Qt(e):Yt(e,t),[e,t]),[l,o]=g.useState(()=>ge(i.dates.values())),[u,c]=g.useState(null),p=g.useMemo(()=>nt(l.year,l.month),[l]),x=B(),d=$e();if(i.byDay.size===0)return n.jsxs("div",{className:"space-y-4",children:[n.jsx(F,{title:"Nothing on the calendar yet",description:t===null?void 0:`Give a note a ${t} date below and it lands on the grid.`}),t===null?null:n.jsx(je,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]});const h=y=>{c(null),o(y)},j=u?i.byDay.get(u)??[]:[];return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("header",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[n.jsx("h2",{className:"font-serif text-2xl tracking-tight text-fg",children:st(l.year,l.month)}),n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx("button",{type:"button",onClick:()=>h(xe(l.year,l.month,-1)),className:"chip","aria-label":"Previous month",children:"← Prev"}),n.jsx("button",{type:"button",onClick:()=>h(ge(i.dates.values())),className:"chip",children:"Latest"}),n.jsx("button",{type:"button",onClick:()=>h(xe(l.year,l.month,1)),className:"chip","aria-label":"Next month",children:"Next →"})]})]}),n.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-card",children:[n.jsx("div",{className:"grid grid-cols-7 border-b border-border bg-bg-soft text-2xs uppercase tracking-wider text-fg-dim",children:Kt.map(y=>n.jsx("div",{className:"px-2 py-2 text-center",children:y},y))}),n.jsx("div",{className:"grid grid-cols-7",children:p.map(y=>{const f=B(y),b=y.getMonth()+1===l.month,v=i.byDay.get(f)??[],m=f===x,N=f===u;return n.jsx(en,{dayKey:f,dayNumber:y.getDate(),inMonth:b,isToday:m,isSelected:N,notes:v,onSelect:()=>c(f),dateField:t,viewResultsKey:a,dropRegistry:d},f)})})]}),u&&j.length>0?n.jsxs("section",{"aria-label":`Notes on ${X(u)}`,className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsx("p",{className:"eyebrow",children:X(u)}),n.jsx("button",{type:"button",onClick:()=>c(null),className:"text-xs text-fg-dim hover:text-accent focus-ring rounded",children:"Clear"})]}),n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,16rem),1fr))] gap-2",children:j.map(y=>n.jsx(q,{note:y,pinnedTag:s.pinned,archivedTag:s.archived,footer:r.length>0?n.jsx(P,{note:y,fields:r,viewResultsKey:a}):null},y.id))})]}):null,t===null?n.jsx("p",{className:"text-xs text-fg-dim",children:"Showing by created date — set a date field to schedule."}):n.jsx(je,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]})}function en({dayKey:e,dayNumber:t,inMonth:s,isToday:a,isSelected:r,notes:i,onSelect:l,dateField:o,viewResultsKey:u,dropRegistry:c}){const p=i.length>0,x=o!==null,d=g.useCallback(m=>c.dispatch(m,e),[c,e]),{isOver:h,targetProps:j}=Te(d),y=x&&s?j:{},f=n.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full font-serif tabular-nums ${a?"bg-accent text-(--color-on-accent)":"text-fg"}`,children:t}),b=n.jsxs("span",{className:"flex flex-col gap-0.5",children:[i.slice(0,H).map(m=>o===null?n.jsx(tn,{note:m},m.id):n.jsx(nn,{note:m,dayKey:e,dateField:o,viewResultsKey:u,dropRegistry:c},m.id)),i.length>H?n.jsxs("span",{className:"text-[10px] text-fg-dim",children:["+",i.length-H," more"]}):null]}),v=`flex min-h-24 flex-col border-b border-r border-border p-1.5 text-left text-xs ${s?"":"opacity-40"} ${r?"bg-accent/5":""} ${x&&s&&h?"bg-accent/5 outline-2 -outline-offset-2 outline-accent/60":""}`;return p?n.jsxs("button",{type:"button",onClick:l,"aria-label":`${X(e)} — ${i.length} notes`,className:`${v} hover:bg-bg/60 focus:bg-bg/60 focus:outline-none`,"data-day":e,...y,children:[f,b]}):n.jsxs("div",{className:v,"data-day":e,...y,children:[f,n.jsx("span",{className:"sr-only",children:"no notes"})]})}const K="truncate rounded-md border border-border bg-card px-1.5 py-0.5 text-[10px] leading-tight text-fg shadow-sm";function tn({note:e}){return n.jsx("span",{"data-note-id":e.id,className:K,children:C(e).text})}function nn({note:e,dayKey:t,dateField:s,viewResultsKey:a,dropRegistry:r}){const{write:i,isPending:l}=z(e,a),o=Ee(e.id),u=g.useCallback(c=>{l||c===t||i(s,c,{errorPrefix:`Couldn't move "${C(e).text}"`})},[l,t,s,i,e]);return g.useEffect(()=>r.register(e.id,u),[r,e.id,u]),n.jsx("span",{"data-note-id":e.id,className:o.canDrag?`${K} cursor-grab`:K,...o.sourceProps,children:C(e).text})}function je({notes:e,dateField:t,roles:s,viewResultsKey:a,fields:r}){if(e.length===0)return null;const i=r.find(o=>o.name===t)??{name:t,schema:{type:"date"}},l=/date/i.test(t)?t:`${t} date`;return n.jsxs("section",{"aria-label":`Not on the calendar — no ${l}`,className:"space-y-2",children:[n.jsx("p",{className:"eyebrow",children:"Not on the calendar yet"}),n.jsxs("p",{className:"text-xs text-fg-dim",children:[e.length," ",e.length===1?"note has":"notes have"," no ",l," — set one to place ",e.length===1?"it":"them","."]}),n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,16rem),1fr))] gap-2",children:e.map(o=>n.jsx(q,{note:o,pinnedTag:s.pinned,archivedTag:s.archived,footer:n.jsx(P,{note:o,fields:[i],viewResultsKey:a})},o.id))})]})}const sn="border-[color-mix(in_srgb,var(--color-accent)_40%,var(--color-border))]";function Ve({label:e,value:t,icon:s,ariaLabel:a,haspopup:r="menu",open:i,dirty:l=!1,onClick:o}){return n.jsxs("button",{type:"button","aria-haspopup":r,"aria-expanded":i,"aria-label":a,onClick:o,className:`focus-ring inline-flex min-h-8 items-center gap-1.5 rounded-full border bg-card px-3 py-1 transition-colors duration-(--dur-quick) ease-out hover:border-accent/50 ${l?sn:"border-border"}`,children:[s?n.jsx("span",{"aria-hidden":"true",className:"flex-none text-fg-muted",children:s}):null,e?n.jsx("span",{className:"text-2xs uppercase tracking-[0.08em] text-fg-dim",children:e}):null,n.jsx("span",{className:"text-xs font-medium text-fg",children:t}),n.jsx("span",{"aria-hidden":"true",className:"text-2xs text-fg-dim",children:"▾"})]})}function ee({label:e,value:t,icon:s,ariaLabel:a,menuLabel:r,options:i,sections:l,current:o,onSelect:u,note:c,actions:p,busy:x=!1,dirty:d=!1}){const[h,j]=g.useState(!1);g.useEffect(()=>{if(!h)return;const m=N=>{N.key==="Escape"&&j(!1)};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[h]);const y=m=>{j(!1),u(m)},f=m=>{j(!1),m.onSelect()},b=m=>{const N=m.value===o;return n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":N,onClick:()=>y(m.value),className:`focus-ring flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm hover:bg-bg-soft ${N?"text-fg":"text-fg-muted"}`,children:[m.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:m.glyph}):null,n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:m.hint?"shrink-0":"min-w-0 shrink truncate",children:m.label??m.value}),m.hint?n.jsx("span",{"aria-hidden":"true",className:"min-w-0 shrink truncate text-2xs text-fg-dim",children:m.hint}):null]}),N?n.jsx("span",{"aria-hidden":"true",className:"text-accent",children:"✓"}):null]},m.value)},v=l?l.reduce((m,N)=>m+N.options.length,0):(i==null?void 0:i.length)??0;return n.jsxs("div",{className:"relative",children:[n.jsx(Ve,{label:e,value:t,icon:s,ariaLabel:a,open:h,dirty:d,onClick:()=>j(m=>!m)}),h?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,onClick:()=>j(!1),className:"enter-fade fixed inset-0 z-30 cursor-default bg-black/40 sm:bg-transparent"}),n.jsxs("div",{role:"menu","aria-label":r,className:"card enter-rise fixed inset-x-0 bottom-0 z-40 max-h-[70dvh] overflow-y-auto rounded-b-none p-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))] shadow-lift sm:absolute sm:top-full sm:right-auto sm:bottom-auto sm:mt-1 sm:max-h-80 sm:w-56 sm:rounded-b-[var(--radius-2xl)] sm:pb-1.5",children:[n.jsx("p",{"aria-hidden":"true",className:"eyebrow px-2 pt-1.5 pb-1",children:r}),l?l.map((m,N)=>n.jsxs("div",{className:N>0?"mt-1 border-t border-border-light pt-1":void 0,children:[m.heading?n.jsx("p",{"aria-hidden":"true",className:"px-2 pt-1 pb-0.5 text-2xs uppercase tracking-[0.08em] text-fg-dim",children:m.heading}):null,m.options.map(b)]},m.heading??N)):i==null?void 0:i.map(b),c?n.jsx("p",{className:"px-2 pt-1.5 pb-1 text-xs text-fg-dim",children:c}):null,p&&p.length>0?n.jsx("div",{className:v>0?"mt-1 border-t border-border-light pt-1":void 0,children:p.map(m=>n.jsxs("button",{type:"button",role:"menuitem",disabled:x,onClick:()=>f(m),className:"focus-ring flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm text-fg-muted hover:bg-bg-soft disabled:opacity-50",children:[m.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:m.glyph}):null,n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-fg",children:m.label}),m.hint?n.jsx("span",{className:"block truncate text-2xs text-fg-dim",children:m.hint}):null]})]},m.key))}):null]})]}):null]})}function ve(e){switch(I(e)){case"enum":case"boolean":return"●";case"date":return"📅";case"number":return"#";default:return"Aa"}}function an({fields:e,schemaFields:t,onChange:s,dirty:a=!1}){const[r,i]=g.useState(!1);g.useEffect(()=>{if(!r)return;const d=h=>{h.key==="Escape"&&i(!1)};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const l=e.map(d=>d.name),o=Object.keys(t).filter(d=>!l.includes(d));if(l.length===0&&o.length===0)return null;const u=l.length===1,c=d=>{u||s(l.filter(h=>h!==d))},p=d=>s([...l,d]),x=(d,h)=>{const j=[...l],[y]=j.splice(d,1);j.splice(d+h,0,y),s(j)};return n.jsxs("div",{className:"relative",children:[n.jsx(Ve,{label:"Fields",value:String(l.length),haspopup:"dialog",open:r,dirty:a,onClick:()=>i(d=>!d)}),r?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,onClick:()=>i(!1),className:"enter-fade fixed inset-0 z-30 cursor-default bg-black/40 sm:bg-transparent"}),n.jsxs("div",{role:"dialog","aria-label":"Fields",className:"card enter-rise fixed inset-x-0 bottom-0 z-40 max-h-[70dvh] overflow-y-auto rounded-b-none p-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))] shadow-lift sm:absolute sm:top-full sm:right-auto sm:bottom-auto sm:mt-1 sm:max-h-80 sm:w-60 sm:rounded-b-[var(--radius-2xl)] sm:pb-1.5",children:[n.jsx("p",{className:"eyebrow px-2 pt-1.5 pb-1",children:"Fields"}),n.jsxs("ul",{className:"flex flex-col gap-0.5",children:[e.map((d,h)=>n.jsxs("li",{className:"flex items-center gap-1 rounded-lg px-2 py-1 hover:bg-bg-soft",children:[n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm text-fg",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:u,onChange:()=>c(d.name)}),n.jsx("span",{"aria-hidden":"true",className:"w-4 flex-none text-center text-2xs text-fg-dim",children:ve(d.schema)}),n.jsx("span",{className:"truncate",children:d.name})]}),n.jsx("button",{type:"button","aria-label":`Move ${d.name} up`,disabled:h===0,onClick:()=>x(h,-1),className:"focus-ring rounded px-1.5 py-0.5 text-sm text-fg-muted hover:bg-bg-soft hover:text-fg disabled:opacity-30",children:"↑"}),n.jsx("button",{type:"button","aria-label":`Move ${d.name} down`,disabled:h===l.length-1,onClick:()=>x(h,1),className:"focus-ring rounded px-1.5 py-0.5 text-sm text-fg-muted hover:bg-bg-soft hover:text-fg disabled:opacity-30",children:"↓"})]},d.name)),o.map(d=>n.jsx("li",{className:"flex items-center gap-1 rounded-lg px-2 py-1 hover:bg-bg-soft",children:n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:!1,onChange:()=>p(d)}),n.jsx("span",{"aria-hidden":"true",className:"w-4 flex-none text-center text-2xs text-fg-dim",children:ve(t[d])}),n.jsx("span",{className:"truncate",children:d})]})},d))]}),u?n.jsx("p",{className:"px-2 pt-1.5 pb-1 text-xs text-fg-dim",children:"Views show at least one field."}):null]})]}):null]})}function rn({notes:e,roles:t,viewResultsKey:s,fields:a=[]}){return n.jsx("div",{"aria-label":"Gallery",className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,13rem),1fr))] gap-4",children:e.map(r=>n.jsx(q,{note:r,variant:"gallery",pinnedTag:t.pinned,archivedTag:t.archived,footer:a.length>0?n.jsx(P,{note:r,fields:a,viewResultsKey:s}):null},r.id))})}const W={list:"List",board:"Board",calendar:"Calendar",gallery:"Gallery",table:"Table"};function Ne({kind:e}){switch(e){case"board":return n.jsx(ot,{width:14,height:14});case"calendar":return n.jsx(lt,{width:14,height:14});case"gallery":return n.jsx(it,{width:14,height:14});case"table":return n.jsx(rt,{width:14,height:14});default:return n.jsx(at,{width:14,height:14})}}function ln({kind:e,onSwitch:t,dirty:s=!1}){return n.jsx(ee,{ariaLabel:`Lens: ${W[e]}`,menuLabel:"Lens",icon:n.jsx(Ne,{kind:e}),value:W[e],options:De.map(a=>({value:a,label:W[a],glyph:n.jsx(Ne,{kind:a})})),current:e,onSelect:t,dirty:s})}function on(e,t,s){const a=e.filter(s).map(r=>r.name);return t&&!a.includes(t)&&a.unshift(t),a}const cn="This view isn't scoped to one tag, so there's no schema to add a field to — add a single tag to the query, or open a tag's view.";function Re(e,t,s){return[{key:"__add_field__",label:e,hint:t,onSelect:s}]}const we="Date fields plot on the Calendar lens (By date) — not offered here.";function J(e,t){return{value:e,hint:t,glyph:n.jsx("span",{className:`tint-dot tint-${V(e)}`})}}function dn(e){const t=[],s=[],a=[];for(const r of e){const i=I(r.schema);i==="date"?a.push(r):i==="enum"?t.push(r):s.push(r)}return{valueBearing:t,other:s,dateFields:a}}function un(e){return(e.enum??[]).join(" · ")}function mn(e,t,s,a,r){if(e)return t>0?we:void 0;if(!s)return cn;if(r)return`#${s} has no fields yet — add one to give this board its columns:`;if(!a)return we}function xn({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const{valueBearing:o,other:u,dateFields:c}=dn(t),p=new Set([...o,...u].map(f=>f.name)),x=e!==void 0&&!p.has(e)?e:void 0,d=[];x!==void 0&&d.push({options:[J(x)]}),o.length>0&&d.push({heading:"Fields with values",options:o.map(f=>J(f.name,un(f.schema)))}),u.length>0&&d.push({heading:"Other fields · one column per value",options:u.map(f=>J(f.name))});const h=d.length>0,j=t.length===0,y=j&&!!r&&i&&!!l;return n.jsx(ee,{label:"Group by",menuLabel:"Group by",value:e??"—",sections:d,current:e,onSelect:s,note:mn(h,c.length,r,j,y),actions:y?Re("Add a field to group by…","You name it; give it values to get columns.",l):void 0,dirty:a})}function pn({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const o=on(t,e,c=>c.schema.type==="date"),u=o.length===0&&!!r&&i&&!!l;return n.jsx(ee,{label:"By date",menuLabel:"By date",value:e??"created",options:o.map(c=>({value:c})),current:e,onSelect:s,note:o.length===0&&u?`Showing by created date. #${r} has no date field — add one to plot and drag by it:`:e===void 0?"Showing by created date":void 0,actions:u?Re("Add a date field…","You name it; it holds a date on each note.",l):void 0,dirty:a})}function hn({notes:e,roles:t,viewResultsKey:s,fields:a=[]}){return n.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card shadow-sm",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[36rem] border-collapse text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-border text-left",children:[n.jsx("th",{scope:"col",className:"sticky left-0 z-[1] bg-bg-soft px-3 py-2 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-dim",children:"Note"}),a.map(r=>n.jsx("th",{scope:"col",className:`whitespace-nowrap bg-bg-soft px-3 py-2 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-dim ${r.schema.type==="number"?"text-right":""}`,children:r.name},r.name))]})}),n.jsx("tbody",{children:e.map(r=>n.jsx(fn,{note:r,fields:a,roles:t,viewResultsKey:s},r.id))})]})})})}function fn({note:e,fields:t,roles:s,viewResultsKey:a}){const{write:r,isPending:i}=z(e,a),l=C(e),o=(e.tags??[]).includes(s.pinned),u=(e.tags??[]).includes(s.archived);return n.jsxs("tr",{"data-note-id":e.id,className:`group border-b border-border-light last:border-b-0 hover:bg-bg-soft/60 ${u?"opacity-60 italic":""}`,children:[n.jsx("th",{scope:"row",className:"group-hover:after:opacity-100 sticky left-0 z-[1] bg-card px-3 py-1.5 text-left font-normal after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:bg-bg-soft/60 after:opacity-0",children:n.jsxs(R,{to:`/n/${encodeURIComponent(e.id)}`,className:"focus-ring inline-flex max-w-[16rem] items-baseline gap-1.5 hover:text-accent",children:[o?n.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,n.jsx("span",{className:l.kind==="timestamp"?"min-w-0 truncate title-timestamp":"min-w-0 truncate font-medium text-fg",children:l.text})]})}),t.map(c=>{var p;return n.jsx("td",{className:`px-3 py-1 align-middle ${c.schema.type==="number"?"text-right":""}`,children:n.jsx(Z,{field:c.name,schema:c.schema,value:Fe((p=e.metadata)==null?void 0:p[c.name]),disabled:i,includeClear:!0,onCommit:x=>void r(c.name,x)})},c.name)})]})}function Oe(e){return e.kind!==void 0||e.groupBy!==void 0||e.dateField!==void 0||e.fields!==void 0}function bn(e){const t=new URLSearchParams;return e.kind&&t.set("kind",e.kind),e.groupBy&&t.set("group",e.groupBy),e.dateField&&t.set("date",e.dateField),e.fields&&e.fields.length>0&&t.set("fields",e.fields.join(",")),t}function gn(e){const t={},s=e.get("kind");s&&De.includes(s)&&(t.kind=s);const a=e.get("group");a&&(t.groupBy=a);const r=e.get("date");r&&(t.dateField=r);const i=e.get("fields");if(i){const l=i.split(",").map(o=>o.trim()).filter(Boolean);l.length>0&&(t.fields=l)}return t}function te(e,t){return Oe(t)?{...e,kind:t.kind??e.kind,groupBy:t.groupBy??e.groupBy,dateField:t.dateField??e.dateField,fields:t.fields??e.fields}:e}function yn(e,t){return e===void 0||t===void 0?e===t:e.length===t.length&&e.every((s,a)=>s===t[a])}function ke(e,t){const s={};return t.kind!==void 0&&t.kind!==e.kind&&(s.kind=t.kind),t.groupBy!==void 0&&t.groupBy!==e.groupBy&&(s.groupBy=t.groupBy),t.dateField!==void 0&&t.dateField!==e.dateField&&(s.dateField=t.dateField),t.fields!==void 0&&!yn(t.fields,e.fields)&&(s.fields=t.fields),s}function jn(e){var t;return(t=e.find(s=>{var a;return(((a=s.schema.enum)==null?void 0:a.length)??0)>0}))==null?void 0:t.name}function vn(e){var t;return(t=e.find(s=>s.schema.type==="date"))==null?void 0:t.name}function Nn(e,t,s,a){const r={...t,kind:s};if(s==="board"){if(!(t.groupBy??e.groupBy)){const i=jn(a);i&&(r.groupBy=i)}}else e.groupBy===void 0&&(r.groupBy=void 0);if(s==="calendar"){if(!(t.dateField??e.dateField)){const i=vn(a);i&&(r.dateField=i)}}else e.dateField===void 0&&(r.dateField=void 0);return r}function wn(e,t,s){const r={kind:te(e,t).kind};return s!==null&&(r.query=JSON.stringify(s)),t.groupBy!==void 0&&(r.group_by=t.groupBy),t.dateField!==void 0&&(r.date_field=t.dateField),t.fields!==void 0&&(r.fields=JSON.stringify(t.fields)),r}function kn(e,t){const s={kind:e.kind};return t!==null&&(s.query=JSON.stringify(t)),e.groupBy!==void 0&&(s.group_by=e.groupBy),e.dateField!==void 0&&(s.date_field=e.dateField),e.fields!==void 0&&(s.fields=JSON.stringify(e.fields)),s}const Sn={type:"string"};function M(e){const t=Pe(e);return t.length===1?t[0]:null}function Cn(e,t){return e.fields&&e.fields.length>0?e.fields.map(a=>({name:a,schema:(t==null?void 0:t[a])??Sn})):M(e.query)&&t?Object.entries(t).map(([a,r])=>({name:a,schema:r})):[]}function $n(e){const t=e?M(e.query):null,s=O(t);return g.useMemo(()=>e?Cn(e,Ie(s.data)):[],[e,s.data])}function Ie(e){return(e==null?void 0:e.fields)??null}function Tn(e){const t=e?M(e.query):null,s=O(t);return g.useMemo(()=>Ie(s.data)??{},[s.data])}function En(e){const t=e?M(e.query):null,s=O(t);return t?s.isSuccess:!0}function Dn(e,t,s=[]){if(s.includes(t))return{pinned:[],rest:e};const a=[],r=[];for(const i of e)(i.tags??[]).includes(t)?a.push(i):r.push(i);return{pinned:a,rest:r}}function qe(){return n.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:n.jsx(R,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})})}function Wn(){const{id:e}=xt(),t=Me(a=>a.getActiveVault()),s=pt(e);return t?s.data?n.jsx(Mn,{note:s.data}):n.jsxs("div",{className:"page",children:[n.jsx(qe,{}),s.isPending?n.jsx(Pn,{}):s.isError?n.jsx(Le,{title:"Couldn't load this view",message:s.error instanceof Error?s.error.message:void 0,retry:()=>s.refetch()}):n.jsx(F,{title:"View not found",description:"It may have been deleted or moved."})]}):n.jsx(ht,{to:"/",replace:!0})}function Pn(){return n.jsxs("div",{className:"space-y-4","aria-busy":"true",children:[n.jsx(k,{height:32,width:"40%"}),n.jsx(k,{height:20,width:"60%"}),n.jsxs("div",{className:"space-y-2 pt-4",children:[n.jsx(k,{height:56}),n.jsx(k,{height:56}),n.jsx(k,{height:56})]})]})}function Mn({note:e}){const t=g.useMemo(()=>Nt(e),[e]);return n.jsx(Ln,{def:t,backingNote:e,nav:n.jsx(qe,{})})}function Ln({def:e,backingNote:t,pageSize:s,total:a,nav:r}){var de;const i=Me(w=>w.getActiveVault()),{roles:l}=ct((i==null?void 0:i.id)??null),o=typeof s=="number"&&s>0,[u,c]=g.useState(0),[p,x]=dt(),d=g.useMemo(()=>ut(p),[p]),h=g.useMemo(()=>ke(e,gn(p)),[e,p]),j=(w,E)=>{const $=bn(w);for(const[_,A]of wt(E))$.append(_,A);x($,{replace:!0})},y=w=>j(h,w),f=w=>{j(ke(e,w),d)},b=g.useMemo(()=>te(e,h),[e,h]),v=g.useMemo(()=>JSON.stringify({q:b.query,r:d}),[b.query,d]);g.useEffect(()=>{c(0)},[v]);const m=g.useMemo(()=>!o||!b.query?b:{...b,query:{...b.query,offset:u,limit:s+1}},[o,b,u,s]),N=mt(m,d,{live:!o}),S=g.useMemo(()=>o&&N.data?N.data.slice(0,s):N.data,[o,N.data,s]),ne=(S==null?void 0:S.length)??0,se=o?(((de=N.data)==null?void 0:de.length)??0)>s:!1,ze=pe(d),Ge=o&&!se?u+ne:void 0,Ue=ze?void 0:a,T=$n(b),Ye=Tn(b),ae=[...b.problems,...N.problems],re=g.useMemo(()=>S?Dn(S,l.pinned,Pe(b.query)):{pinned:[],rest:[]},[S,l.pinned,b.query]),Qe=t!==null,ie=(Oe(h)||pe(d))&&Qe,[He,le]=g.useState(!1),oe=()=>x(new URLSearchParams,{replace:!0}),L=g.useMemo(()=>M(b.query),[b.query]),ce=En(b),[G,U]=g.useState(null),We=w=>{var A,ue;const E=G;if(!E)return;const $=Object.entries(w),_=E==="date"?(A=$.find(([,D])=>D.type==="date"))==null?void 0:A[0]:(ue=$.find(([,D])=>{var me;return(((me=D.enum)==null?void 0:me.length)??0)>0})??$.find(([,D])=>D.type!=="date"))==null?void 0:ue[0];_&&f({...h,[E==="group"?"groupBy":"dateField"]:_})},Je=b.kind==="board"||b.kind==="table";return n.jsxs("div",{className:Je?"page page-wide":"page",children:[r,n.jsxs("article",{className:ie?"pb-20":void 0,children:[n.jsx(An,{def:b,backingNote:t,count:Ue}),n.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-x-2 gap-y-2 py-1",children:[n.jsx(ln,{kind:b.kind,onSwitch:w=>f(Nn(e,h,w,T)),dirty:e.kind!==b.kind}),b.kind==="board"?n.jsx(xn,{value:b.groupBy,fields:T,onChange:w=>f({...h,groupBy:w}),dirty:e.groupBy!==b.groupBy,createTag:L,schemaReady:ce,onAddField:()=>U("group")}):null,b.kind==="calendar"?n.jsx(pn,{value:b.dateField,fields:T,onChange:w=>f({...h,dateField:w}),dirty:e.dateField!==b.dateField,createTag:L,schemaReady:ce,onAddField:()=>U("date")}):null,n.jsx(an,{fields:T,schemaFields:Ye,onChange:w=>f({...h,fields:w}),dirty:e.fields!==b.fields})]}),n.jsx(On,{def:e,refinements:d,onChange:y}),ae.length>0?n.jsx(Fn,{problems:ae}):null,n.jsx("div",{className:"mt-6",children:n.jsx(Vn,{def:b,data:S,isPending:N.isPending,isError:N.isError,error:N.error,retry:N.refetch,viewResultsKey:N.queryKey,fields:T,pinned:re.pinned,rest:re.rest,roles:l})}),o?n.jsx(Bn,{offset:u,shown:ne,total:Ge,hasPrev:u>0,hasNext:se,onPrev:()=>c(w=>Math.max(0,w-s)),onNext:()=>c(w=>w+s)}):null,ie?n.jsx(_n,{onSave:()=>le(!0),onRevert:oe}):null,He&&t?n.jsx(Un,{note:t,def:e,draft:h,refinements:d,roles:l,onClose:()=>le(!1),onSaved:oe}):null,G&&L?n.jsx(Ct,{tagName:L,intent:G,onSaved:We,onClose:()=>U(null)}):null]})]})}function _n({onSave:e,onRevert:t}){const s=gt(a=>a.setShown);return g.useEffect(()=>(s(!0),()=>s(!1)),[s]),n.jsx("div",{"aria-label":"View modified",className:"glass-panel fixed inset-x-0 bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-20 border-t border-border md:bottom-0 md:pb-[env(safe-area-inset-bottom)]",children:n.jsxs("div",{className:"mx-auto flex w-full max-w-(--w-page) items-center justify-between gap-3 px-5 py-2.5 md:px-10",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n.jsx("span",{"aria-hidden":"true",className:"view-modified-pulse h-2 w-2 shrink-0 rounded-full bg-accent"}),n.jsxs("p",{className:"min-w-0 text-sm text-fg-muted",children:[n.jsx("span",{className:"font-medium text-fg",children:"View modified"})," — you're exploring. Save to keep this layout."]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:t,className:"btn btn-secondary btn-touch",children:"Revert"}),n.jsx("button",{type:"button",onClick:e,className:"btn btn-primary btn-touch",children:"Save"})]})]})})}function An({def:e,backingNote:t,count:s}){return n.jsxs("header",{className:"mb-4 flex flex-wrap items-center justify-between gap-3 border-b border-border pb-5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n.jsx(ft,{kind:e.kind,hueTag:_e(e.query)}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("h1",{className:"page-title truncate",children:e.title}),typeof s=="number"?n.jsx("p",{className:"text-sm text-fg-dim",children:s===1?"1 note":`${s.toLocaleString()} notes`}):null]})]}),t?n.jsx(R,{to:`/n/${encodeURIComponent(t.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit view note"}):null]})}function Bn({offset:e,shown:t,total:s,hasPrev:a,hasNext:r,onPrev:i,onNext:l}){const o=t>0?e+1:0,u=e+t;return!a&&!r?null:n.jsxs("div",{className:"mt-6 flex items-center justify-between text-fg-dim text-sm",children:[n.jsx("span",{children:t>0?typeof s=="number"?`Showing ${o}–${u} of ${s.toLocaleString()}`:`Showing ${o}–${u}`:""}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{type:"button",disabled:!a,onClick:i,className:"btn btn-secondary btn-touch",children:"Previous"}),n.jsx("button",{type:"button",disabled:!r,onClick:l,className:"btn btn-secondary btn-touch",children:"Next"})]})]})}function Fn({problems:e}){return n.jsx("output",{"aria-live":"polite",className:"mt-4 block rounded-lg border border-[--color-warning] bg-[--color-warning-soft] p-3 text-sm text-fg",children:n.jsx("ul",{className:"list-disc space-y-1 pl-5",children:e.map((t,s)=>n.jsx("li",{children:t.message},`${t.code}-${s}`))})})}function Vn({def:e,data:t,isPending:s,isError:a,error:r,retry:i,viewResultsKey:l,fields:o,pinned:u,rest:c,roles:p}){if(e.query===null)return n.jsx(F,{title:"Nothing is being shown",description:"Fix the view's query to see results."});if(s)return n.jsxs("div",{className:"space-y-2","aria-busy":"true",children:[n.jsx(k,{height:56}),n.jsx(k,{height:56}),n.jsx(k,{height:56})]});if(a)return n.jsx(Le,{title:"Couldn't run this view",message:r instanceof Error?r.message:void 0,retry:i});if(!t||u.length===0&&c.length===0)return n.jsx(F,{title:"No notes match this view yet."});const x=[...u,...c];switch(e.kind){case"board":if(e.groupBy)return n.jsx(Ht,{notes:x,laneBy:e.groupBy,subjectTag:_e(e.query),roles:p,viewResultsKey:l,fields:o});break;case"gallery":return n.jsx(rn,{notes:x,roles:p,viewResultsKey:l,fields:o});case"table":return n.jsx(hn,{notes:x,roles:p,viewResultsKey:l,fields:o});case"calendar":return n.jsx(Zt,{notes:x,dateField:e.dateField||null,roles:p,viewResultsKey:l,fields:o})}return n.jsx(Rn,{pinned:u,rest:c,roles:p,viewResultsKey:l,fields:o})}function Rn({pinned:e,rest:t,roles:s,viewResultsKey:a,fields:r}){const i=l=>r.length>0?n.jsx(P,{note:l,fields:r,viewResultsKey:a}):null;return n.jsxs("div",{className:"space-y-6",children:[e.length>0?n.jsxs("section",{"aria-label":"Pinned",children:[n.jsx("p",{className:"eyebrow mb-2",children:"Pinned"}),n.jsx(he,{"aria-label":"Pinned notes",children:e.map(l=>n.jsx(fe,{note:l,pinnedTag:s.pinned,archivedTag:s.archived,footer:i(l)},l.id))})]}):null,t.length>0?n.jsx("section",{"aria-label":"Results",children:n.jsx(he,{"aria-label":"View results",children:t.map(l=>n.jsx(fe,{note:l,pinnedTag:s.pinned,archivedTag:s.archived,footer:i(l)},l.id))})}):null]})}function On({def:e,refinements:t,onChange:s}){const a=g.useMemo(()=>bt(e.query),[e.query]),r=i=>{const l=t.removeExcludes.includes(i);s({...t,removeExcludes:l?t.removeExcludes.filter(o=>o!==i):[...t.removeExcludes,i]})};return n.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2",children:[a.map(i=>n.jsx(In,{chip:i,toggled:i.kind==="exclude"&&!!i.value&&t.removeExcludes.includes(i.value),onToggle:i.kind==="exclude"&&i.value?()=>r(i.value):void 0},`${i.kind}-${i.value??i.label}`)),t.addTags.map(i=>n.jsx(Y,{label:`+#${i}`,onRemove:()=>s({...t,addTags:t.addTags.filter(l=>l!==i)})},`add-${i}`)),t.search?n.jsx(Y,{label:`"${t.search}"`,onRemove:()=>s({...t,search:void 0})}):null,t.sort?n.jsx(Y,{label:`sorted by ${t.sort==="desc"?"newest":"oldest"}`,onRemove:()=>s({...t,sort:void 0})}):null,n.jsx(qn,{onAdd:i=>s({...t,addTags:[...t.addTags,i]})}),n.jsx(zn,{value:t.search??"",onChange:i=>s({...t,search:i||void 0})}),n.jsx(Gn,{value:t.sort,onChange:i=>s({...t,sort:i})})]})}function In({chip:e,toggled:t,onToggle:s}){return s?n.jsx("button",{type:"button",onClick:s,"aria-pressed":!t,title:t?"Excluded again — tap to peek":"Tap to peek at these too",className:`chip ${t?"opacity-50 line-through":""}`,children:e.label}):n.jsx("span",{className:"chip",children:e.label})}function qn({onAdd:e}){const[t,s]=g.useState(""),a=()=>{const r=t.trim().replace(/^#/,"");r&&(e(r),s(""))};return n.jsx("input",{type:"text",value:t,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),a())},placeholder:"+ tag","aria-label":"Add a tag filter",className:"w-24 rounded-full border border-border bg-bg/40 px-2.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"})}function zn({value:e,onChange:t}){return n.jsx("input",{type:"search",value:e,onChange:s=>t(s.target.value),placeholder:"Search…","aria-label":"Search within this view",className:"w-32 rounded-full border border-border bg-bg/40 px-2.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"})}function Gn({value:e,onChange:t}){return n.jsx("button",{type:"button",onClick:()=>t(e==="desc"?"asc":e==="asc"?void 0:"desc"),className:"chip","aria-label":"Cycle sort order",children:e==="desc"?"Newest first":e==="asc"?"Oldest first":"Sort"})}function Un({note:e,def:t,draft:s,refinements:a,roles:r,onClose:i,onSaved:l}){const o=Ce(m=>m.push),u=yt(),c=jt(e,u),[p,x]=g.useState(c),[d,h]=g.useState(`${t.title} (copy)`),[j,y]=g.useState(!1),f=Se(e.id),b=vt(),v=async()=>{y(!0);try{const m=kt(t.query,a);p==="update"?(await f.mutateAsync({metadata:wn(t,s,m),...e.updatedAt?{if_updated_at:e.updatedAt}:{force:!0}}),o(`Updated "${t.title}".`,"success")):(await b.mutateAsync({content:"",path:St(d),tags:[r.view],metadata:kn(te(t,s),m)}),o(`Saved "${d}".`,"success")),l(),i()}catch(m){o(`Could not save: ${m.message}`,"error")}finally{y(!1)}};return n.jsx("div",{className:"dialog-overlay",role:"dialog","aria-labelledby":"save-view-title",onMouseDown:m=>{m.target===m.currentTarget&&i()},children:n.jsxs("div",{className:"dialog-panel max-w-md",children:[n.jsx("h2",{id:"save-view-title",className:"mb-3 font-serif text-xl text-fg",children:"Save this view"}),n.jsxs("div",{className:"mb-4 space-y-2",children:[n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"radio",name:"save-mode",checked:p==="update",onChange:()=>x("update")}),"Update this view"]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"radio",name:"save-mode",checked:p==="fork",onChange:()=>x("fork")}),"Save as new view"]})]}),p==="fork"?n.jsxs("label",{className:"mb-4 block text-sm",children:[n.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),n.jsx("input",{type:"text",value:d,onChange:m=>h(m.target.value),className:"w-full rounded-lg border border-border bg-bg/40 px-2.5 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"})]}):null,n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary btn-touch",children:"Cancel"}),n.jsx("button",{type:"button",onClick:()=>void v(),disabled:j||p==="fork"&&!d.trim(),className:"btn btn-primary btn-touch",children:j?"Saving…":"Save"})]})]})})}export{Ln as ViewCanvas,Wn as ViewSurface};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as w,y,r as i,g as N,l as v,bA as S,o as j,k,j as e,N as b,P as h,L as C}from"./index-BKfqr8sS.js";import{W as p}from"./WizardShell-eATuMAXz.js";import{f as z}from"./provenance-BFQb2w9-.js";import"./history-BHtc79G3.js";function K(){const r=w(),[a]=y(),[t,n]=i.useState({kind:"checking"}),[l,f]=i.useState(0),d=i.useRef(null),m=i.useRef(null),x=a.get("new")==="1";if(i.useEffect(()=>{if(x)return;const s=`${l}|${a.toString()}`;if(d.current===s)return;d.current=s,n(c=>c.kind==="checking"?c:{kind:"checking"});const o=a.get("pick")==="1";(async()=>{let c;try{c=await N()}catch{n({kind:"redirect"});return}if(!c.signed_in){n({kind:"redirect"});return}try{const{vaults:u}=await v();if(o&&u.length>0){n({kind:"picker",email:c.email,vaults:u});return}const g=S(u);g.kind==="first-vault"?n({kind:"first-vault"}):g.kind==="welcome-back"?n({kind:"welcome-back",email:c.email,vault:g.vault}):n({kind:"picker",email:c.email,vaults:g.vaults})}catch(u){n({kind:"net-error",message:u instanceof Error?u.message:"Unknown error"})}})()},[l,a,x]),i.useEffect(()=>{if(t.kind!=="welcome-back"||t.error||m.current===t.vault.name)return;m.current=t.vault.name;const s=t.vault.name;(async()=>{try{await j(s),k(s),r("/",{replace:!0})}catch(o){m.current=null,n(c=>c.kind==="welcome-back"&&c.vault.name===s?{...c,error:o instanceof Error?o.message:"Couldn't open your vault."}:c)}})()},[t,r]),x)return e.jsx(b,{to:"/add-vault/create",replace:!0});switch(t.kind){case"checking":return e.jsx(E,{});case"redirect":return e.jsx(b,{to:a.get("link")==="expired"?"/?link=expired":"/",replace:!0});case"first-vault":return e.jsx(b,{to:"/add-vault/create?first=1",replace:!0});case"net-error":return e.jsx(O,{message:t.message,onRetry:()=>{n({kind:"checking"}),f(s=>s+1)}});case"welcome-back":return e.jsx(V,{email:t.email,vaultName:t.vault.name,error:t.error,onRetry:()=>n(s=>s.kind==="welcome-back"?{...s,error:void 0}:s)});case"picker":return e.jsx(W,{email:t.email,vaults:t.vaults,onOpenVault:async s=>{await j(s.name),k(s.name),r("/")},onCreateNew:()=>{r("/add-vault/create")}});default:return null}}function E(){return e.jsxs(p,{escape:{kind:"none"},children:[e.jsx(h,{size:72,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-2",style:{fontSize:"clamp(1.8rem, 4vw, 2.3rem)"},children:["Signing you ",e.jsx("span",{className:"accent-word",children:"in…"})]}),e.jsx("output",{"aria-live":"polite",className:"font-round text-sm text-fg-muted",children:"Checking your vaults…"})]})}function O({message:r,onRetry:a}){return e.jsxs(p,{escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:56,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Almost there"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.8rem, 4vw, 2.2rem)"},children:["You're signed in — we just couldn't fetch your ",e.jsx("span",{className:"accent-word",children:"vaults."})]}),e.jsx("p",{className:"mx-auto mb-6 max-w-sm text-fg-muted",children:r}),e.jsx("button",{type:"button",onClick:a,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again"})]})}function V({email:r,vaultName:a,error:t,onRetry:n}){return t?e.jsxs(p,{escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Couldn't open ",e.jsxs("span",{className:"accent-word",children:[a,"."]})]}),e.jsx("p",{className:"mx-auto mb-6 max-w-sm text-fg-muted",children:t}),e.jsx("button",{type:"button",onClick:n,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again"})]}):e.jsxs(p,{escape:{kind:"none"},children:[e.jsx(h,{size:76,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"Welcome back"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.8rem, 4vw, 2.1rem)"},children:["Opening ",e.jsxs("span",{className:"accent-word",children:[a,"…"]})]}),e.jsxs("output",{"aria-live":"polite",className:"mx-auto max-w-sm text-fg-muted",children:["Signed in as ",r??"you"," — opening ",a,"…"]})]})}function R({vault:r,busy:a,onOpen:t}){const n=z(r.usage),l=r.url?r.url.replace(/^https?:\/\//,""):"";return e.jsxs("li",{className:"card flex items-center gap-4 rounded-2xl p-4 shadow-soft",children:[e.jsx("span",{"aria-hidden":"true",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-grass-soft text-base",children:"🌱"}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:r.name}),e.jsx("span",{className:"chip",children:"☁ Cloud"})]}),l?e.jsx("p",{className:"mt-0.5 truncate note-id",children:l}):null,n?e.jsx("p",{className:"mt-0.5 font-round text-xs text-fg-muted",children:n}):null]}),e.jsx("button",{type:"button",onClick:t,disabled:a,className:"btn btn-primary btn-touch shrink-0 rounded-full",children:a?"Opening…":"Open →"})]})}function W({email:r,vaults:a,onOpenVault:t,onCreateNew:n}){const[l,f]=i.useState(null),[d,m]=i.useState(null);async function x(s){if(!l){f(s.name),m(null);try{await t(s)}catch(o){f(null),m(o instanceof Error?o.message:"Couldn't open that vault.")}}}return e.jsxs(p,{wide:!0,escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:56,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Which vault"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.8rem, 4vw, 2.4rem)"},children:["Which vault ",e.jsx("span",{className:"accent-word",children:"today?"})]}),e.jsxs("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:["Signed in as ",r??"you"," · ",a.length," vault",a.length===1?"":"s"," on Cloud"]}),e.jsx("ul",{className:"mx-auto flex max-w-md flex-col gap-3",children:a.map(s=>e.jsx(R,{vault:s,busy:l===s.name,onOpen:()=>x(s)},s.name))}),d?e.jsx("p",{className:"mx-auto mt-6 max-w-sm rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:d}):null,e.jsxs("p",{className:"mt-8 font-round text-sm text-fg-muted",children:[e.jsx("button",{type:"button",onClick:n,className:"font-semibold text-accent hover:underline",children:"+ Create a new vault"})," ","·"," ",e.jsx(C,{to:"/add",className:"font-semibold hover:underline",style:{color:"var(--color-sky)"},children:"Connect a self-hosted vault"})]})]})}export{K as Welcome};
|