@openparachute/app 0.22.9 → 0.22.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/.parachute/info +1 -1
  2. package/dist/assets/{Account-BS79MR2p.js → Account-Cl5c8tEo.js} +1 -1
  3. package/dist/assets/{Activity-BCI-VU_G.js → Activity-BcJHDfuw.js} +1 -1
  4. package/dist/assets/{AddVault-BGmLnyvr.js → AddVault-DoCaI37K.js} +1 -1
  5. package/dist/assets/{AddVaultChooser-BOYsRq-6.js → AddVaultChooser-Xvu3Uphy.js} +1 -1
  6. package/dist/assets/{AddVaultCreate-VvY9DfX7.js → AddVaultCreate-Di9wcscn.js} +1 -1
  7. package/dist/assets/{Calendar-CStTh0s6.js → Calendar-DBe5DpLx.js} +1 -1
  8. package/dist/assets/{CheckEmail-D1qSfrIa.js → CheckEmail-ntqd1kZe.js} +1 -1
  9. package/dist/assets/{ConnectAI-_yRQ6PVE.js → ConnectAI-CUJNLwHZ.js} +1 -1
  10. package/dist/assets/{DayView-CP-3vwhX.js → DayView-jTXjnokv.js} +1 -1
  11. package/dist/assets/{Export-BN79ECKv.js → Export-BFGWcvOW.js} +1 -1
  12. package/dist/assets/{Import-CGC0ejYh.js → Import-2WIsPfSi.js} +1 -1
  13. package/dist/assets/{NoteEditor-7Ul1HK8m.js → NoteEditor-DT4kYH2h.js} +1 -1
  14. package/dist/assets/NoteNew-B7fbwu7C.js +8 -0
  15. package/dist/assets/{NoteRenderer-CyTOvjQK.js → NoteRenderer-DG6I-BOG.js} +1 -1
  16. package/dist/assets/NoteView-Dy3cUyrT.js +3 -0
  17. package/dist/assets/{OAuthCallback-DXQknDTs.js → OAuthCallback-W5STO-7I.js} +1 -1
  18. package/dist/assets/{PinArchiveButtons-CJcBoOpQ.js → PinArchiveButtons-8xFKv2oH.js} +1 -1
  19. package/dist/assets/Settings-ClPAPWCJ.js +1 -0
  20. package/dist/assets/{TagPage-CHDSvaJ4.js → TagPage-pYbWcmlY.js} +1 -1
  21. package/dist/assets/{TagSchemaEditor-Qk8dM9DF.js → TagSchemaEditor-ve19B-tr.js} +1 -1
  22. package/dist/assets/{Tags-BKTmTns9.js → Tags-DGl9Zubj.js} +1 -1
  23. package/dist/assets/{VaultGraph-CX2MzD9D.js → VaultGraph-BrDsta1c.js} +2 -2
  24. package/dist/assets/{Vaults-B9uh43KI.js → Vaults-DWoDm-Th.js} +1 -1
  25. package/dist/assets/{ViewNew-C6gk4Ujs.js → ViewNew-D3N3bUyp.js} +1 -1
  26. package/dist/assets/{ViewSurface-B-DhVasF.js → ViewSurface-CB97Dtg8.js} +1 -1
  27. package/dist/assets/{Welcome-pHYMoace.js → Welcome-C6zOVULl.js} +1 -1
  28. package/dist/assets/{WizardShell-Dbn_qWnU.js → WizardShell-eATuMAXz.js} +1 -1
  29. package/dist/assets/{attachment-upload-BfsE-IDX.js → attachment-upload-D6wfJsr6.js} +1 -1
  30. package/dist/assets/{history-BU5ztowk.js → history-BHtc79G3.js} +1 -1
  31. package/dist/assets/index-BKfqr8sS.js +66 -0
  32. package/dist/assets/{index-rEtUY3V3.css → index-DBJfPBlG.css} +1 -1
  33. package/dist/assets/{provenance-BoiAp4jO.js → provenance-BFQb2w9-.js} +1 -1
  34. package/dist/assets/{react-force-graph-2d-CAZ4sIdb.js → react-force-graph-2d-BZd7whjL.js} +1 -1
  35. package/dist/assets/{transcribe-default-3hayXb7m.js → transcribe-default-Cjxt7F_e.js} +1 -1
  36. package/dist/assets/{useAttachmentUploader-BPyx3tZN.js → useAttachmentUploader-Be6yFw7I.js} +1 -1
  37. package/dist/index.html +2 -2
  38. package/dist/sw.js +1 -1
  39. package/package.json +1 -1
  40. package/dist/assets/NoteNew-B-Lomu-W.js +0 -8
  41. package/dist/assets/NoteView-CCQoXBAK.js +0 -3
  42. package/dist/assets/Settings-BvqkQbc1.js +0 -1
  43. package/dist/assets/index-BhV_u6Bm.js +0 -66
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-CAZ4sIdb.js","assets/index-BhV_u6Bm.js","assets/index-rEtUY3V3.css"])))=>i.map(i=>d[i]);
2
- import{a as N,bt as k,r as u,bu as w,bv as S,bw as C,bx as M,j as t,N as T,L as v,b as R,by as E,V as A,aP as P}from"./index-BhV_u6Bm.js";const _=u.lazy(()=>P(()=>import("./react-force-graph-2d-CAZ4sIdb.js"),__vite__mapDeps([0,1,2]))),z=20;function $(){const e=N(c=>c.getActiveVault()),n=k(),[d,m]=u.useState(w),o=u.useMemo(()=>n.data?S(n.data):null,[n.data]),i=u.useMemo(()=>o?C(o.nodes):[],[o]),x=u.useMemo(()=>o?new Set(o.nodes.filter(c=>M(c,d)).map(c=>c.id)):new Set,[o,d]);return e?t.jsxs("div",{className:"flex h-[calc(100dvh-5rem)] flex-col",children:[t.jsx("div",{className:"border-b border-border bg-card/40 px-6 py-3",children:t.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-4",children:[t.jsx("input",{type:"search",value:d.search,onChange:c=>m(h=>({...h,search:c.target.value})),placeholder:"Search nodes…","aria-label":"Search graph nodes",className:"min-w-48 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"}),t.jsx(V,{allTags:i,selected:d.tags,onChange:c=>m(h=>({...h,tags:c}))}),o?t.jsxs("span",{className:"text-xs text-fg-dim",children:[x.size," / ",o.nodes.length," notes"]}):null]})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(F,{query:n,graph:o,matched:x})})]}):t.jsx(T,{to:"/",replace:!0})}function F({query:e,graph:n,matched:d}){return e.isPending?t.jsx(j,{message:"Loading vault…"}):e.isError?t.jsx(D,{error:e.error}):!n||n.nodes.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-10",children:t.jsxs("div",{className:"max-w-sm rounded-md border border-border bg-card p-8 text-center",children:[t.jsx("p",{className:"mb-2 font-serif text-xl",children:"No notes yet"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"This vault is empty. Start by creating the first note."}),t.jsx(v,{to:"/new",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Create a note"})]})}):t.jsx(I,{graph:n,matched:d})}function V({allTags:e,selected:n,onChange:d}){const m=e.slice(0,z);if(m.length===0)return null;const o=i=>d(n.includes(i)?n.filter(x=>x!==i):[...n,i]);return t.jsxs("fieldset",{"aria-label":"Filter by tag",className:"flex flex-wrap items-center gap-1 text-xs text-fg-dim",children:[t.jsx("legend",{className:"mr-1 inline-block",children:"Tags"}),m.map(i=>{const x=n.includes(i);return t.jsx("button",{type:"button","aria-pressed":x,onClick:()=>o(i),className:x?"max-w-full break-all rounded-full border border-accent bg-accent/10 px-2 py-0.5 text-accent":"max-w-full break-all rounded-full border border-border bg-card px-2 py-0.5 hover:text-accent",children:i},i)}),n.length>0?t.jsx("button",{type:"button",onClick:()=>d([]),className:"ml-1 text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]})}function j({message:e}){return t.jsx("div",{"aria-busy":"true",className:"flex h-full animate-pulse items-center justify-center bg-card/30 text-sm text-fg-dim",children:e})}function I({graph:e,matched:n}){const d=R(),m=u.useRef(null),o=u.useRef(null),[i,x]=u.useState({w:800,h:600});u.useEffect(()=>{const r=m.current;if(!r)return;const s=()=>{const a=r.getBoundingClientRect();x({w:Math.max(320,Math.floor(a.width)),h:Math.max(320,Math.floor(a.height))})};s();const l=new ResizeObserver(s);return l.observe(r),()=>l.disconnect()},[]);const c=()=>{var r,s;(s=(r=o.current)==null?void 0:r.zoomToFit)==null||s.call(r,400,40)},h=u.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]),f=n.size!==e.nodes.length,y=r=>!f||n.has(r)?1:.15;return t.jsxs("div",{ref:m,"data-testid":"vault-graph-canvas",className:"relative h-full w-full touch-none",children:[t.jsx(u.Suspense,{fallback:t.jsx(j,{message:"Rendering graph…"}),children:t.jsx(_,{ref:o,graphData:h,width:i.w,height:i.h,backgroundColor:"rgba(0,0,0,0)",nodeLabel:r=>L(r),nodeRelSize:5,nodeVal:r=>2+Math.min(r.degree,12),nodeColor:r=>{const s=r,l=E(s.topTag);return f&&!n.has(s.id)?G(l):l},nodePointerAreaPaint:(r,s,l)=>{const a=r;if(a.x==null||a.y==null)return;const g=2+Math.min(a.degree,12),b=Math.max(Math.sqrt(g)*5,10);l.fillStyle=s,l.beginPath(),l.arc(a.x,a.y,b,0,2*Math.PI),l.fill()},linkColor:r=>{const s=r,l=p(s.source),a=p(s.target);return f&&(!n.has(l)||!n.has(a))?"rgba(160, 160, 160, 0.08)":"rgba(160, 160, 160, 0.35)"},linkDirectionalArrowLength:2.5,linkDirectionalArrowRelPos:1,cooldownTicks:100,onEngineStop:()=>c(),nodeCanvasObjectMode:()=>"after",nodeCanvasObject:(r,s,l)=>{const a=r;if(a.x==null||a.y==null||y(a.id)<.5)return;const b=10/l;s.font=`${b}px sans-serif`,s.fillStyle="rgba(220, 220, 220, 0.8)",s.textAlign="left",s.textBaseline="middle",s.fillText(a.title,a.x+6,a.y)},onNodeClick:r=>{d(`/n/${encodeURIComponent(r.id)}`)}})}),t.jsx("button",{type:"button",onClick:c,className:"absolute right-3 bottom-3 rounded-lg border border-border bg-card/90 px-3 py-1.5 text-xs text-fg-muted shadow-sm backdrop-blur hover:text-accent",children:"Fit to screen"})]})}function L(e){const n=[e.path??e.id,`${e.degree} link${e.degree===1?"":"s"}`];return e.tags.length>0&&n.push(`tags: ${e.tags.join(", ")}`),e.summary&&n.push(e.summary),n.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-BZd7whjL.js","assets/index-BKfqr8sS.js","assets/index-DBJfPBlG.css"])))=>i.map(i=>d[i]);
2
+ import{a as N,bu as k,r as u,bv as w,bw as S,bx as C,by as M,j as t,N as T,L as v,b as R,bz as E,V as A,aP as P}from"./index-BKfqr8sS.js";const z=u.lazy(()=>P(()=>import("./react-force-graph-2d-BZd7whjL.js"),__vite__mapDeps([0,1,2]))),_=20;function $(){const e=N(c=>c.getActiveVault()),n=k(),[d,m]=u.useState(w),o=u.useMemo(()=>n.data?S(n.data):null,[n.data]),i=u.useMemo(()=>o?C(o.nodes):[],[o]),x=u.useMemo(()=>o?new Set(o.nodes.filter(c=>M(c,d)).map(c=>c.id)):new Set,[o,d]);return e?t.jsxs("div",{className:"flex h-[calc(100dvh-5rem)] flex-col",children:[t.jsx("div",{className:"border-b border-border bg-card/40 px-6 py-3",children:t.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-4",children:[t.jsx("input",{type:"search",value:d.search,onChange:c=>m(h=>({...h,search:c.target.value})),placeholder:"Search nodes…","aria-label":"Search graph nodes",className:"min-w-48 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"}),t.jsx(V,{allTags:i,selected:d.tags,onChange:c=>m(h=>({...h,tags:c}))}),o?t.jsxs("span",{className:"text-xs text-fg-dim",children:[x.size," / ",o.nodes.length," notes"]}):null]})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(F,{query:n,graph:o,matched:x})})]}):t.jsx(T,{to:"/",replace:!0})}function F({query:e,graph:n,matched:d}){return e.isPending?t.jsx(j,{message:"Loading vault…"}):e.isError?t.jsx(D,{error:e.error}):!n||n.nodes.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-10",children:t.jsxs("div",{className:"max-w-sm rounded-md border border-border bg-card p-8 text-center",children:[t.jsx("p",{className:"mb-2 font-serif text-xl",children:"No notes yet"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"This vault is empty. Start by creating the first note."}),t.jsx(v,{to:"/new",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Create a note"})]})}):t.jsx(I,{graph:n,matched:d})}function V({allTags:e,selected:n,onChange:d}){const m=e.slice(0,_);if(m.length===0)return null;const o=i=>d(n.includes(i)?n.filter(x=>x!==i):[...n,i]);return t.jsxs("fieldset",{"aria-label":"Filter by tag",className:"flex flex-wrap items-center gap-1 text-xs text-fg-dim",children:[t.jsx("legend",{className:"mr-1 inline-block",children:"Tags"}),m.map(i=>{const x=n.includes(i);return t.jsx("button",{type:"button","aria-pressed":x,onClick:()=>o(i),className:x?"max-w-full break-all rounded-full border border-accent bg-accent/10 px-2 py-0.5 text-accent":"max-w-full break-all rounded-full border border-border bg-card px-2 py-0.5 hover:text-accent",children:i},i)}),n.length>0?t.jsx("button",{type:"button",onClick:()=>d([]),className:"ml-1 text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]})}function j({message:e}){return t.jsx("div",{"aria-busy":"true",className:"flex h-full animate-pulse items-center justify-center bg-card/30 text-sm text-fg-dim",children:e})}function I({graph:e,matched:n}){const d=R(),m=u.useRef(null),o=u.useRef(null),[i,x]=u.useState({w:800,h:600});u.useEffect(()=>{const r=m.current;if(!r)return;const s=()=>{const a=r.getBoundingClientRect();x({w:Math.max(320,Math.floor(a.width)),h:Math.max(320,Math.floor(a.height))})};s();const l=new ResizeObserver(s);return l.observe(r),()=>l.disconnect()},[]);const c=()=>{var r,s;(s=(r=o.current)==null?void 0:r.zoomToFit)==null||s.call(r,400,40)},h=u.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]),f=n.size!==e.nodes.length,y=r=>!f||n.has(r)?1:.15;return t.jsxs("div",{ref:m,"data-testid":"vault-graph-canvas",className:"relative h-full w-full touch-none",children:[t.jsx(u.Suspense,{fallback:t.jsx(j,{message:"Rendering graph…"}),children:t.jsx(z,{ref:o,graphData:h,width:i.w,height:i.h,backgroundColor:"rgba(0,0,0,0)",nodeLabel:r=>L(r),nodeRelSize:5,nodeVal:r=>2+Math.min(r.degree,12),nodeColor:r=>{const s=r,l=E(s.topTag);return f&&!n.has(s.id)?G(l):l},nodePointerAreaPaint:(r,s,l)=>{const a=r;if(a.x==null||a.y==null)return;const g=2+Math.min(a.degree,12),b=Math.max(Math.sqrt(g)*5,10);l.fillStyle=s,l.beginPath(),l.arc(a.x,a.y,b,0,2*Math.PI),l.fill()},linkColor:r=>{const s=r,l=p(s.source),a=p(s.target);return f&&(!n.has(l)||!n.has(a))?"rgba(160, 160, 160, 0.08)":"rgba(160, 160, 160, 0.35)"},linkDirectionalArrowLength:2.5,linkDirectionalArrowRelPos:1,cooldownTicks:100,onEngineStop:()=>c(),nodeCanvasObjectMode:()=>"after",nodeCanvasObject:(r,s,l)=>{const a=r;if(a.x==null||a.y==null||y(a.id)<.5)return;const b=10/l;s.font=`${b}px sans-serif`,s.fillStyle="rgba(220, 220, 220, 0.8)",s.textAlign="left",s.textBaseline="middle",s.fillText(a.title,a.x+6,a.y)},onNodeClick:r=>{d(`/n/${encodeURIComponent(r.id)}`)}})}),t.jsx("button",{type:"button",onClick:c,className:"absolute right-3 bottom-3 rounded-lg border border-border bg-card/90 px-3 py-1.5 text-xs text-fg-muted shadow-sm backdrop-blur hover:text-accent",children:"Fit to screen"})]})}function L(e){const n=[e.path??e.id,`${e.degree} link${e.degree===1?"":"s"}`];return e.tags.length>0&&n.push(`tags: ${e.tags.join(", ")}`),e.summary&&n.push(e.summary),n.join(`
3
3
  `)}function G(e){return e.startsWith("hsl(")?e.replace("hsl(","hsla(").replace(")",", 0.2)"):e}function p(e){return typeof e=="string"?e:e&&typeof e=="object"&&"id"in e?String(e.id):""}function D({error:e}){const n=e instanceof A;return t.jsx("div",{className:"flex h-full items-center justify-center p-10",children:t.jsxs("div",{className:"max-w-md rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[t.jsx("p",{className:"mb-2 font-medium text-red-400",children:n?"Session expired":"Could not load vault"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:e.message}),n?t.jsx(v,{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{$ as VaultGraph};
@@ -1 +1 @@
1
- import{a,j as e,L as n,G as m}from"./index-BhV_u6Bm.js";import{v as h}from"./provenance-BoiAp4jO.js";import{a as x}from"./types-BaJkUfo6.js";function f(){const l=a(s=>s.vaults),d=a(s=>s.activeVaultId),o=a(s=>s.removeVault),c=Object.values(l).sort((s,t)=>s.name.localeCompare(t.name));return e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Vaults"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Every vault you've connected, in one place."})]}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}),c.length===0?e.jsxs("div",{className:"card rounded-xl p-8 text-center shadow-soft",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults connected yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Open one you already have, create a new one, or connect a self-hosted vault."}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}):e.jsx("ul",{className:"space-y-3",children:c.map(s=>{const t=s.id===d,r=x(s.url),i=h(s);return e.jsxs("li",{className:"card rounded-xl p-5 shadow-soft",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:s.name}),t?e.jsx("span",{className:"chip chip-tag-active",children:"active"}):null,e.jsxs("span",{className:"chip",children:[i.kind==="cloud"?"☁":"⌂"," ",i.label]}),r?e.jsx("span",{className:"chip border-warning/40 bg-warning-soft text-warning",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate note-id",children:s.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[t?null:e.jsx("button",{type:"button",onClick:()=>m(s.id,{toast:!0}),className:"focus-ring text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${s.name} from this device? Your notes stay in the vault — only this device's stored access is removed. You can add it again anytime.`)&&o(s.id)},className:"focus-ring text-danger hover:text-danger-hover",children:"Remove from this device"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded-xl border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning",children:["Vault now serves under ",e.jsx("code",{className:"font-mono",children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(n,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},s.id)})})]})}export{f as Vaults};
1
+ import{a,j as e,L as n,G as m}from"./index-BKfqr8sS.js";import{v as h}from"./provenance-BFQb2w9-.js";import{a as x}from"./types-BaJkUfo6.js";function f(){const l=a(s=>s.vaults),d=a(s=>s.activeVaultId),o=a(s=>s.removeVault),c=Object.values(l).sort((s,t)=>s.name.localeCompare(t.name));return e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Vaults"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Every vault you've connected, in one place."})]}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}),c.length===0?e.jsxs("div",{className:"card rounded-xl p-8 text-center shadow-soft",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults connected yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Open one you already have, create a new one, or connect a self-hosted vault."}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}):e.jsx("ul",{className:"space-y-3",children:c.map(s=>{const t=s.id===d,r=x(s.url),i=h(s);return e.jsxs("li",{className:"card rounded-xl p-5 shadow-soft",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:s.name}),t?e.jsx("span",{className:"chip chip-tag-active",children:"active"}):null,e.jsxs("span",{className:"chip",children:[i.kind==="cloud"?"☁":"⌂"," ",i.label]}),r?e.jsx("span",{className:"chip border-warning/40 bg-warning-soft text-warning",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate note-id",children:s.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[t?null:e.jsx("button",{type:"button",onClick:()=>m(s.id,{toast:!0}),className:"focus-ring text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${s.name} from this device? Your notes stay in the vault — only this device's stored access is removed. You can add it again anytime.`)&&o(s.id)},className:"focus-ring text-danger hover:text-danger-hover",children:"Remove from this device"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded-xl border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning",children:["Vault now serves under ",e.jsx("code",{className:"font-mono",children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(n,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},s.id)})})]})}export{f as Vaults};
@@ -1 +1 @@
1
- import{a as g,a1 as h,at as v,a6 as N,b as w,r,bF as y,a9 as j,j as e,N as b}from"./index-BhV_u6Bm.js";function k(){const a=g(t=>t.getActiveVault()),{roles:c}=h((a==null?void 0:a.id)??null),l=v(),o=N(t=>t.push),p=w(),[i,x]=r.useState("New view"),[s,u]=r.useState(!1),[d,f]=r.useState(null),m=r.useCallback(async()=>{const t=i.trim()||"New view";u(!0);try{const n=await l.mutateAsync({content:"",path:y(t),tags:[c.view],metadata:{kind:"list",query:"{}"}});f(n.id)}catch(n){n instanceof j?o("A note already exists at that path — try a different name.","error"):o(`Could not create the view: ${n.message}`,"error")}finally{u(!1)}},[i,l,c.view,o]);return a?d?e.jsx(b,{to:`/views/${encodeURIComponent(d)}`,replace:!0}):e.jsxs("div",{className:"page-prose",children:[e.jsx("h1",{className:"page-title mb-2",children:"New view"}),e.jsx("p",{className:"mb-6 text-fg-muted",children:"A view is a note that describes a query — refine and save it from the view itself once it's open."}),e.jsxs("label",{className:"mb-4 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:t=>x(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!s&&m()},autoFocus:!0,className:"w-full rounded-lg border border-border bg-bg/40 px-3 py-2 text-fg focus:border-accent focus:outline-none"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>p(-1),className:"btn btn-secondary btn-touch",disabled:s,children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void m(),disabled:s,className:"btn btn-primary btn-touch",children:s?"Creating…":"Create view"})]})]}):e.jsx(b,{to:"/",replace:!0})}export{k as ViewNew};
1
+ import{a as g,a1 as h,at as v,a6 as N,b as w,r,bG as y,a9 as j,j as e,N as b}from"./index-BKfqr8sS.js";function k(){const a=g(t=>t.getActiveVault()),{roles:c}=h((a==null?void 0:a.id)??null),l=v(),o=N(t=>t.push),p=w(),[i,x]=r.useState("New view"),[s,u]=r.useState(!1),[d,f]=r.useState(null),m=r.useCallback(async()=>{const t=i.trim()||"New view";u(!0);try{const n=await l.mutateAsync({content:"",path:y(t),tags:[c.view],metadata:{kind:"list",query:"{}"}});f(n.id)}catch(n){n instanceof j?o("A note already exists at that path — try a different name.","error"):o(`Could not create the view: ${n.message}`,"error")}finally{u(!1)}},[i,l,c.view,o]);return a?d?e.jsx(b,{to:`/views/${encodeURIComponent(d)}`,replace:!0}):e.jsxs("div",{className:"page-prose",children:[e.jsx("h1",{className:"page-title mb-2",children:"New view"}),e.jsx("p",{className:"mb-6 text-fg-muted",children:"A view is a note that describes a query — refine and save it from the view itself once it's open."}),e.jsxs("label",{className:"mb-4 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:t=>x(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!s&&m()},autoFocus:!0,className:"w-full rounded-lg border border-border bg-bg/40 px-3 py-2 text-fg focus:border-accent focus:outline-none"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>p(-1),className:"btn btn-secondary btn-touch",disabled:s,children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void m(),disabled:s,className:"btn btn-primary btn-touch",children:s?"Creating…":"Create view"})]})]}):e.jsx(b,{to:"/",replace:!0})}export{k as ViewNew};
@@ -1 +1 @@
1
- import{j as n,bG as Xe,r as g,bH as V,bI as C,L as R,a_ as Ke,x as Ze,av as et,aj as Se,a6 as Ce,Q as B,bs as O,bJ as $e,bK as Te,bL as tt,bM as Ee,R as nt,w as F,X as st,U as xe,$ as X,bN as De,bO as at,bP as rt,bQ as it,bR as lt,bS as ot,bT as Pe,a as Me,a1 as ct,y as dt,bU as ut,bV as mt,bW as pe,ae as xt,bX as pt,N as ht,E as _e,bY as ft,bZ as Le,b_ as bt,b$ as Y,v as k,c0 as gt,c1 as yt,c2 as jt,at as vt,c3 as Nt,c4 as wt,a3 as he,a4 as fe,c5 as kt,bF as St}from"./index-BhV_u6Bm.js";import{T as Ct}from"./TagSchemaEditor-Qk8dM9DF.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 _t(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"?_t(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 Lt(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?Lt(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(_e,{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(_n,{def:t,backingNote:e,nav:n.jsx(qe,{})})}function _n({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[L,A]of wt(E))$.append(L,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}),_=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),L=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];L&&f({...h,[E==="group"?"groupBy":"dateField"]:L})},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:_,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:_,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(Ln,{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&&_?n.jsx(Ct,{tagName:_,intent:G,onSaved:We,onClose:()=>U(null)}):null]})]})}function Ln({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 lg:bottom-0 lg: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:Le(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(_e,{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:Le(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{_n as ViewCanvas,Wn as ViewSurface};
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 +1 @@
1
- import{b as w,y,r as i,g as N,l as v,bz as S,o as j,k,j as e,N as b,P as h,L as C}from"./index-BhV_u6Bm.js";import{W as p}from"./WizardShell-Dbn_qWnU.js";import{f as z}from"./provenance-BoiAp4jO.js";import"./history-BU5ztowk.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};
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};
@@ -1 +1 @@
1
- import{j as e,bE as d}from"./index-BhV_u6Bm.js";import{u as x}from"./history-BU5ztowk.js";function f({children:s,wide:t=!1,escape:l,progress:n}){const a=l!==void 0&&l.kind!=="none",c=x(a?l.to:"/"),i=a?e.jsx("button",{type:"button",onClick:c,className:"focus-ring font-round text-sm text-fg-dim hover:text-accent",children:l.label??(l.kind==="back"?"← Back":"Maybe later")}):null;return e.jsxs("div",{className:"relative flex min-h-[calc(100dvh-4rem)] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 pt-6 sm:px-10",children:[e.jsx(d,{}),(l==null?void 0:l.kind)==="back"?i:null]}),n?e.jsx(m,{labels:n.labels,current:n.current}):null,e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-10 text-center",children:e.jsxs("div",{className:`mx-auto w-full ${t?"max-w-2xl":"max-w-md"}`,children:[s,(l==null?void 0:l.kind)==="maybe-later"?e.jsx("p",{className:"mt-6",children:i}):null]})})]})}function m({labels:s,current:t}){return e.jsx("ol",{"aria-label":`Step ${t+1} of ${s.length}: ${s[t]??""}`,className:"mt-5 flex items-center justify-center gap-2",children:s.map((l,n)=>e.jsx("li",{"aria-current":n===t?"step":void 0,className:n===t?"h-1.5 w-7 rounded-full bg-accent":n<t?"h-1.5 w-1.5 rounded-full bg-sage":"h-1.5 w-1.5 rounded-full bg-border",children:e.jsx("span",{className:"sr-only",children:l})},l))})}export{f as W};
1
+ import{j as e,bF as d}from"./index-BKfqr8sS.js";import{u as x}from"./history-BHtc79G3.js";function f({children:s,wide:t=!1,escape:l,progress:n}){const a=l!==void 0&&l.kind!=="none",c=x(a?l.to:"/"),i=a?e.jsx("button",{type:"button",onClick:c,className:"focus-ring font-round text-sm text-fg-dim hover:text-accent",children:l.label??(l.kind==="back"?"← Back":"Maybe later")}):null;return e.jsxs("div",{className:"relative flex min-h-[calc(100dvh-4rem)] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 pt-6 sm:px-10",children:[e.jsx(d,{}),(l==null?void 0:l.kind)==="back"?i:null]}),n?e.jsx(m,{labels:n.labels,current:n.current}):null,e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-10 text-center",children:e.jsxs("div",{className:`mx-auto w-full ${t?"max-w-2xl":"max-w-md"}`,children:[s,(l==null?void 0:l.kind)==="maybe-later"?e.jsx("p",{className:"mt-6",children:i}):null]})})]})}function m({labels:s,current:t}){return e.jsx("ol",{"aria-label":`Step ${t+1} of ${s.length}: ${s[t]??""}`,className:"mt-5 flex items-center justify-center gap-2",children:s.map((l,n)=>e.jsx("li",{"aria-current":n===t?"step":void 0,className:n===t?"h-1.5 w-7 rounded-full bg-accent":n<t?"h-1.5 w-1.5 rounded-full bg-sage":"h-1.5 w-1.5 rounded-full bg-border",children:e.jsx("span",{className:"sr-only",children:l})},l))})}export{f as W};
@@ -1,2 +1,2 @@
1
- import{r as n,j as i,aK as h,aL as v}from"./index-BhV_u6Bm.js";function E({onDropFiles:e,children:t,className:a,hint:s}){const[c,u]=n.useState(!1),o=n.useRef(0),d=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),o.current+=1,u(!0))},[]),m=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),o.current=Math.max(0,o.current-1),o.current===0&&u(!1))},[]),p=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),r.dataTransfer.dropEffect="copy")},[]),x=n.useCallback(r=>{if(!l(r.dataTransfer))return;r.preventDefault(),u(!1),o.current=0;const f=Array.from(r.dataTransfer.files);f.length>0&&e(f)},[e]);return i.jsxs("div",{className:`relative ${a??""}`,onDragEnter:d,onDragLeave:m,onDragOver:p,onDrop:x,children:[t,c?i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center rounded-md border-2 border-dashed border-accent bg-accent/10 text-sm text-accent",children:i.jsxs("div",{className:"rounded-md bg-bg/80 px-4 py-2 font-medium shadow",children:["Drop to attach",s?i.jsxs("span",{className:"ml-2 text-fg-dim",children:["— ",s]}):null]})}):null]})}function l(e){if(!e)return!1;const t=e.types;for(let a=0;a<t.length;a++)if(t[a]==="Files")return!0;return!1}function $(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}function g(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function T(e){if(e.size>h)return`${e.name} is too large (${g(e.size)}). Max: 100 MB.`;const t=$(e.name);return v.has(t)?null:`${e.name}: .${t||"?"} is not in the vault allowlist.`}function D(e,t,a={}){const s=`/api/storage/${e.path}`,c=a.newline===!1?"":`
1
+ import{r as n,j as i,aK as h,aL as v}from"./index-BKfqr8sS.js";function E({onDropFiles:e,children:t,className:a,hint:s}){const[c,u]=n.useState(!1),o=n.useRef(0),d=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),o.current+=1,u(!0))},[]),m=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),o.current=Math.max(0,o.current-1),o.current===0&&u(!1))},[]),p=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),r.dataTransfer.dropEffect="copy")},[]),x=n.useCallback(r=>{if(!l(r.dataTransfer))return;r.preventDefault(),u(!1),o.current=0;const f=Array.from(r.dataTransfer.files);f.length>0&&e(f)},[e]);return i.jsxs("div",{className:`relative ${a??""}`,onDragEnter:d,onDragLeave:m,onDragOver:p,onDrop:x,children:[t,c?i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center rounded-md border-2 border-dashed border-accent bg-accent/10 text-sm text-accent",children:i.jsxs("div",{className:"rounded-md bg-bg/80 px-4 py-2 font-medium shadow",children:["Drop to attach",s?i.jsxs("span",{className:"ml-2 text-fg-dim",children:["— ",s]}):null]})}):null]})}function l(e){if(!e)return!1;const t=e.types;for(let a=0;a<t.length;a++)if(t[a]==="Files")return!0;return!1}function $(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}function g(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function T(e){if(e.size>h)return`${e.name} is too large (${g(e.size)}). Max: 100 MB.`;const t=$(e.name);return v.has(t)?null:`${e.name}: .${t||"?"} is not in the vault allowlist.`}function D(e,t,a={}){const s=`/api/storage/${e.path}`,c=a.newline===!1?"":`
2
2
  `;return e.mimeType.startsWith("image/")?`![${t}](${s})${c}`:`[${t}](${s})${c}`}export{E as A,$ as f,D as m,T as v};
@@ -1 +1 @@
1
- import{b as a,r as i}from"./index-BhV_u6Bm.js";function n(s){const t=a();return i.useCallback(()=>{var e;(((e=window.history.state)==null?void 0:e.idx)??0)>0?t(-1):t(s)},[t,s])}export{n as u};
1
+ import{b as a,r as i}from"./index-BKfqr8sS.js";function n(s){const t=a();return i.useCallback(()=>{var e;(((e=window.history.state)==null?void 0:e.idx)??0)>0?t(-1):t(s)},[t,s])}export{n as u};