@openparachute/app 0.22.5 → 0.22.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +148 -0
- package/dist/.parachute/info +1 -1
- package/dist/assets/{Account-BhmA30V5.js → Account-BS79MR2p.js} +1 -1
- package/dist/assets/{Activity-BgJa7Woi.js → Activity-BCI-VU_G.js} +1 -1
- package/dist/assets/{AddVault-BWa_-QjM.js → AddVault-BGmLnyvr.js} +1 -1
- package/dist/assets/{AddVaultChooser-B3ElIlza.js → AddVaultChooser-BOYsRq-6.js} +1 -1
- package/dist/assets/{AddVaultCreate-DKJfYFJ1.js → AddVaultCreate-VvY9DfX7.js} +1 -1
- package/dist/assets/{Calendar-DUwSvnCY.js → Calendar-CStTh0s6.js} +1 -1
- package/dist/assets/{CheckEmail-BQYQLTLL.js → CheckEmail-D1qSfrIa.js} +1 -1
- package/dist/assets/{ConnectAI-DCtARp-w.js → ConnectAI-_yRQ6PVE.js} +1 -1
- package/dist/assets/{DayView-nficJMEc.js → DayView-CP-3vwhX.js} +1 -1
- package/dist/assets/{Export-DNAoKjAn.js → Export-BN79ECKv.js} +1 -1
- package/dist/assets/{Import-CoFeXNMx.js → Import-CGC0ejYh.js} +1 -1
- package/dist/assets/{NoteEditor-DtrdRbqx.js → NoteEditor-7Ul1HK8m.js} +1 -1
- package/dist/assets/NoteNew-B-Lomu-W.js +8 -0
- package/dist/assets/{NoteRenderer-Dl9X9uRt.js → NoteRenderer-CyTOvjQK.js} +1 -1
- package/dist/assets/{NoteView-B2QH25fP.js → NoteView-CCQoXBAK.js} +2 -2
- package/dist/assets/{OAuthCallback-Dj26N8oJ.js → OAuthCallback-DXQknDTs.js} +1 -1
- package/dist/assets/{PinArchiveButtons-BXZFiW-i.js → PinArchiveButtons-CJcBoOpQ.js} +1 -1
- package/dist/assets/{Settings-BuXl91ig.js → Settings-BvqkQbc1.js} +1 -1
- package/dist/assets/{TagPage-q7PgbEHn.js → TagPage-CHDSvaJ4.js} +1 -1
- package/dist/assets/{TagSchemaEditor-DIHppYmj.js → TagSchemaEditor-Qk8dM9DF.js} +1 -1
- package/dist/assets/{Tags-BqJ9vWM5.js → Tags-BKTmTns9.js} +1 -1
- package/dist/assets/{VaultGraph-CaiNmEtX.js → VaultGraph-CX2MzD9D.js} +2 -2
- package/dist/assets/{Vaults-CTsUsDH8.js → Vaults-B9uh43KI.js} +1 -1
- package/dist/assets/{ViewNew-BegTqdOq.js → ViewNew-C6gk4Ujs.js} +1 -1
- package/dist/assets/ViewSurface-B-DhVasF.js +1 -0
- package/dist/assets/{Welcome-CN4Zh9jP.js → Welcome-pHYMoace.js} +1 -1
- package/dist/assets/{WizardShell-ZqrzQKxp.js → WizardShell-Dbn_qWnU.js} +1 -1
- package/dist/assets/{attachment-upload-l7qA8_xw.js → attachment-upload-BfsE-IDX.js} +1 -1
- package/dist/assets/{history-ByMClxJV.js → history-BU5ztowk.js} +1 -1
- package/dist/assets/index-BhV_u6Bm.js +66 -0
- package/dist/assets/index-rEtUY3V3.css +1 -0
- package/dist/assets/{provenance-B6WFYTWW.js → provenance-BoiAp4jO.js} +1 -1
- package/dist/assets/{react-force-graph-2d-BMU3lxLC.js → react-force-graph-2d-CAZ4sIdb.js} +1 -1
- package/dist/assets/{transcribe-default-LVAxyzpn.js → transcribe-default-3hayXb7m.js} +1 -1
- package/dist/assets/{useAttachmentUploader-C3UnTg01.js → useAttachmentUploader-BPyx3tZN.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/NoteNew-C0DMe5Q8.js +0 -8
- package/dist/assets/ViewSurface-ClCtZW0N.js +0 -1
- package/dist/assets/index-CaleIHD8.css +0 -1
- package/dist/assets/index-Dwo2xe8_.js +0 -66
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T,j as e,N as C,L as j,b6 as k,a6 as y,r as d,b7 as E,b8 as A,b9 as O,ba as R,bb as L,a1 as M,bc as P,bd as N,be as g,aw as $,bf as _,bg as I,x as D,bh as z,b as V,u as B,g as F,bi as G,bj as H,h as U,i as Y,bk as K}from"./index-Dwo2xe8_.js";import{u as q,a as Q,b as W,c as X}from"./transcribe-default-LVAxyzpn.js";import{r as Z,w as J}from"./editor-mode-D9fveTEx.js";import"./types-BaJkUfo6.js";function pe(){const t=T(a=>a.getActiveVault());return t?e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-10",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(j,{to:"/",className:"focus-ring hover:text-accent",children:"← Home"})}),e.jsx("p",{className:"eyebrow mb-1",children:t.name}),e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Everything about this vault, in one calm place."})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsx(ee,{}),e.jsx(se,{}),e.jsx(ne,{vaultId:t.id}),e.jsx(ie,{}),e.jsx(re,{}),e.jsx(de,{vaultId:t.id}),e.jsx(ue,{vaultId:t.id}),e.jsx(le,{vaultId:t.id}),e.jsx(oe,{})]})]}):e.jsx(C,{to:"/",replace:!0})}function ee(){return e.jsxs("section",{"aria-label":"Manage",children:[e.jsx("h2",{className:"eyebrow mb-3",children:"Manage"}),e.jsxs("div",{className:"card divide-y divide-border rounded-xl shadow-soft",children:[e.jsx(b,{to:"/account",title:"Account",description:"Your plan, billing, hosted vaults, and sign-in — managed in the app."}),e.jsx(te,{}),e.jsx(b,{to:"/connect",title:"Connections",description:"Connect Claude, ChatGPT, or any MCP client to this vault."}),e.jsx(b,{to:"/vaults",title:"Vaults",description:"Add a vault, switch between them, or export."})]})]})}function te(){const t=V(),a=B(r=>r.identityEpoch),[n,s]=d.useState(null),[i,u]=d.useState(!1);if(d.useEffect(()=>{let r=!0;return F().then(o=>{r&&s(o.signed_in?{identity:o.email??o.username??null,csrf:o.csrf}:null)}).catch(()=>{r&&s(null)}),()=>{r=!1}},[a]),!n)return null;const{identity:c,csrf:h}=n;async function x(){u(!0);try{await U(h)}finally{Y(),t("/",{replace:!0})}}return e.jsxs("div",{className:"flex items-center justify-between gap-4 px-5 py-4",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"block font-medium text-fg",children:["Signed in",c?` as ${c}`:""]}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:"Signing out ends your account session on this device. Vaults already connected here stay until you remove them."})]}),e.jsx("button",{type:"button",onClick:x,disabled:i,className:"btn btn-secondary btn-touch shrink-0",children:i?"Signing out…":"Sign out"})]})}function b({to:t,href:a,title:n,description:s}){const i=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium text-fg",children:n}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:s})]}),e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-dim",children:a?"↗":"→"})]}),u="focus-ring flex items-center justify-between gap-4 px-5 py-4 transition-colors hover:bg-bg-soft first:rounded-t-xl last:rounded-b-xl";return a?e.jsx("a",{href:a,className:u,children:i}):e.jsx(j,{to:t??"/",className:u,children:i})}function se(){return e.jsxs("section",{className:"card space-y-3 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Import notes"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Bring in an Obsidian vault zip or a folder of markdown files. Parsed in your browser; previewed before any note lands in the vault."})]}),e.jsx(j,{to:"/import",className:"btn btn-primary btn-touch",children:"Open importer"})]})}const ae=[{value:"keep",title:"Keep",help:"Recordings are stored with your notes; included wherever attachments are included."},{value:"until_transcribed",title:"Delete after transcribing",help:"Your words stay; the audio file is removed once the transcript lands."},{value:"never",title:"Never store",help:"Audio is removed even if transcription fails — the transcript is your only copy; failed transcriptions lose the audio."}];function ne({vaultId:t}){const a=k(),n=q(),s=Q(),{markMade:i}=W(t),{transcribeDefault:u,setTranscribeDefault:c}=X(t),h=y(r=>r.push);if((a==null?void 0:a.enabled)===!1)return null;const x=r=>{r===n.value||s.isPending||s.mutate(r,{onSuccess:()=>{i(),h("Voice recording setting saved.","success")},onError:o=>{h(o instanceof Error&&o.message?`Couldn't save: ${o.message}`:"Couldn't save the voice recording setting.","error")}})};return e.jsxs("section",{className:"card space-y-6 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Voice"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"How voice capture behaves in this vault."})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Transcribe recordings by default"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"New voice notes start with transcription on — your words are added to the note. Turn it off for a single recording right where you capture. Applies on this device."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":u,"aria-label":"Transcribe recordings by default","data-testid":"transcribe-default-toggle",onClick:()=>c(!u),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${u?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${u?"translate-x-5":"translate-x-0.5"}`})})]}),e.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Keep recordings"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"What happens to the audio file after a voice note is transcribed. Applies to this vault, from every device connected to it."})]}),n.isLoading?e.jsx("p",{className:"text-sm text-fg-dim",children:"Loading…"}):n.isError?e.jsx("p",{className:"text-sm text-fg-dim","data-testid":"retention-load-error",children:"Couldn't load this setting — check the vault connection."}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"space-y-2",disabled:!n.supported||s.isPending,children:[e.jsx("legend",{className:"sr-only",children:"Voice recording retention"}),ae.map(r=>{const o=n.value===r.value;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${o?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"audio-retention",value:r.value,checked:o,onChange:()=>x(r.value),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:r.title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:r.help})]})]},r.value)})]}),n.supported?null:e.jsx("p",{className:"text-xs text-fg-dim","data-testid":"retention-unsupported",children:"This vault doesn't support changing this yet — recordings are kept. Update the vault to choose."})]})]})]})}function ie(){const[t,a]=d.useState(()=>Z()),n=s=>{a(s),J(s)};return e.jsx("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Live preview"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Formats your writing as you type — Markdown stays underneath. Turn off for the raw editor with a side-by-side preview."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Live preview",onClick:()=>n(!t),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${t?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${t?"translate-x-5":"translate-x-0.5"}`})})]})})}function re(){const[t,a]=d.useState(()=>E()),n=s=>{a(s),G(s),H(s)};return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Text size"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Affects the editor and rendered notes on this device. Your markdown isn't changed."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"View text size"}),A.map(s=>{const i=t===s;return e.jsxs("label",{className:`flex items-center gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"text-size",value:s,checked:i,onChange:()=>n(s),className:"accent-accent"}),e.jsx("span",{className:"font-medium text-fg",children:O(s)})]},s)})]})]})}function le({vaultId:t}){const{db:a,mirror:n}=$(),s=y(m=>m.push),[i,u]=d.useState(null),[c,h]=d.useState(null),x=d.useCallback(async()=>{if(!a)return;const[m,l]=await Promise.all([_(a,t),I(a,t)]);u({bytes:m,count:l})},[a,t]);if(d.useEffect(()=>{x()},[x]),!n.enabled)return null;const r=async()=>{if(!c){h("sync");try{await n.syncNow(),await x(),s("Synced offline copy.","success")}catch{s("Couldn't sync the offline copy right now.","error")}finally{h(null)}}},o=async()=>{if(!c&&confirm("Clear this vault's offline copy from this device? Un-synced changes are kept.")){h("clear");try{await n.clearOffline(),await x(),s("Offline copy cleared.","success")}catch{s("Couldn't clear the offline copy.","error")}finally{h(null)}}};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft","aria-label":"Offline",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Offline"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"A copy of this vault is kept on this device so your notes open without a connection."})]}),e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Status"}),e.jsx("dd",{className:"text-fg",children:ce(n.state)})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Last synced"}),e.jsx("dd",{className:"text-fg-muted",children:n.lastSyncedAt?D(new Date(n.lastSyncedAt).toISOString()):"never"})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Saved on this device"}),e.jsx("dd",{className:"text-fg-muted tabular-nums","data-testid":"offline-usage",children:i?`${i.count} note${i.count===1?"":"s"} · ${w(i.bytes)} of ${w(K)}`:"—"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[e.jsx("button",{type:"button",onClick:r,disabled:c!==null,className:"btn btn-secondary btn-touch",children:c==="sync"?"Syncing…":"Sync now"}),e.jsx("button",{type:"button",onClick:o,disabled:c!==null,className:"text-sm text-danger hover:underline disabled:opacity-60",children:c==="clear"?"Clearing…":"Clear offline copy"})]})]})}function ce(t){switch(t){case"hydrating":return"Saving your vault…";case"offline":return"Offline — showing your saved vault";case"error":return"Sync error";default:return"Saved for offline"}}function w(t){return t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function oe(){const[t,a]=d.useState(!1);return d.useEffect(()=>{a(z())},[]),t?e.jsx("section",{className:"card rounded-xl p-6 text-sm shadow-soft",children:e.jsxs("p",{className:"text-fg-muted",children:[e.jsx("span",{className:"mr-2 inline-block rounded-full bg-positive-soft px-2 py-0.5 text-xs font-medium text-positive",children:"Installed"}),"Parachute is running as an installed app on this device."]})}):null}const S={auto:{title:"Auto",help:"Show the tree only when the vault has enough folders to make it worth the space."},always:{title:"Always",help:"Always show the tree, even on a tag-flat vault."},never:{title:"Never",help:"Hide the tree. The path-prefix text input still works."}};function de({vaultId:t}){const{mode:a,setMode:n}=R(t);return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Folder tree (Notes sidebar)"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Controls the collapsible folder tree on the notes list page. Auto-detect renders the tree when the vault has at least five top-level folders or twenty notes in folders."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"Path tree visibility"}),L.map(s=>{const i=a===s;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"path-tree-mode",value:s,checked:i,onChange:()=>n(s),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:S[s].title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:S[s].help})]})]},s)})]})]})}const v={pinned:{title:"Pinned",help:"Tag for notes you want at the top of views."},archived:{title:"Archived",help:"Tag for notes you've moved out of the way."},captureVoice:{title:"Voice capture",help:"Default tag for new voice memos."},captureText:{title:"Text capture",help:"Default tag for quick typed notes."},view:{title:"Saved view",help:"Tag the saved-view notes carry. Used to list them in the notes sidebar."}};function ue({vaultId:t}){const{roles:a,setRoles:n}=M(t),s=P(),i=y(l=>l.push),u=d.useId(),[c,h]=d.useState(a);d.useEffect(()=>h(a),[a]);const x=d.useMemo(()=>{const l=(s.data??[]).map(f=>f.name);return[...new Set(l)].sort((f,p)=>f.localeCompare(p))},[s.data]),r=N.some(l=>c[l].trim()!==a[l]),o=()=>{n(c),i("Tag roles saved.","success")},m=()=>{n(null),h(g),i("Tag roles reset to defaults.","success")};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Tag roles"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Point each role at whatever tag your vault already uses. Changes apply to future notes only — existing notes keep their current tags."})]}),e.jsx("datalist",{id:u,children:x.map(l=>e.jsx("option",{value:l},l))}),e.jsx("div",{className:"space-y-4",children:N.map(l=>e.jsxs("label",{className:"block text-sm",children:[e.jsxs("span",{className:"mb-1.5 flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-fg",children:v[l].title}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["default: #",g[l]]})]}),e.jsx("input",{type:"text",value:c[l],onChange:f=>h(p=>({...p,[l]:f.target.value})),list:u,placeholder:g[l],"aria-label":`${v[l].title} tag role`,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"input input-on-bg"}),e.jsx("span",{className:"mt-1.5 block text-xs text-fg-dim",children:v[l].help})]},l))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 pt-1",children:[e.jsx("button",{type:"button",onClick:o,disabled:!r,className:"btn btn-primary btn-lg",children:"Save"}),e.jsx("button",{type:"button",onClick:m,className:"btn btn-ghost",children:"Reset to defaults"})]})]})}export{pe as Settings};
|
|
1
|
+
import{a as T,j as e,N as C,L as j,b6 as k,a6 as y,r as d,b7 as E,b8 as A,b9 as O,ba as R,bb as L,a1 as M,bc as P,bd as N,be as g,aw as $,bf as _,bg as I,x as D,bh as z,b as V,u as B,g as F,bi as G,bj as H,h as U,i as Y,bk as K}from"./index-BhV_u6Bm.js";import{u as q,a as Q,b as W,c as X}from"./transcribe-default-3hayXb7m.js";import{r as Z,w as J}from"./editor-mode-D9fveTEx.js";import"./types-BaJkUfo6.js";function pe(){const t=T(a=>a.getActiveVault());return t?e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-10",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(j,{to:"/",className:"focus-ring hover:text-accent",children:"← Home"})}),e.jsx("p",{className:"eyebrow mb-1",children:t.name}),e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Everything about this vault, in one calm place."})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsx(ee,{}),e.jsx(se,{}),e.jsx(ne,{vaultId:t.id}),e.jsx(ie,{}),e.jsx(re,{}),e.jsx(de,{vaultId:t.id}),e.jsx(ue,{vaultId:t.id}),e.jsx(le,{vaultId:t.id}),e.jsx(oe,{})]})]}):e.jsx(C,{to:"/",replace:!0})}function ee(){return e.jsxs("section",{"aria-label":"Manage",children:[e.jsx("h2",{className:"eyebrow mb-3",children:"Manage"}),e.jsxs("div",{className:"card divide-y divide-border rounded-xl shadow-soft",children:[e.jsx(b,{to:"/account",title:"Account",description:"Your plan, billing, hosted vaults, and sign-in — managed in the app."}),e.jsx(te,{}),e.jsx(b,{to:"/connect",title:"Connections",description:"Connect Claude, ChatGPT, or any MCP client to this vault."}),e.jsx(b,{to:"/vaults",title:"Vaults",description:"Add a vault, switch between them, or export."})]})]})}function te(){const t=V(),a=B(r=>r.identityEpoch),[n,s]=d.useState(null),[i,u]=d.useState(!1);if(d.useEffect(()=>{let r=!0;return F().then(o=>{r&&s(o.signed_in?{identity:o.email??o.username??null,csrf:o.csrf}:null)}).catch(()=>{r&&s(null)}),()=>{r=!1}},[a]),!n)return null;const{identity:c,csrf:h}=n;async function x(){u(!0);try{await U(h)}finally{Y(),t("/",{replace:!0})}}return e.jsxs("div",{className:"flex items-center justify-between gap-4 px-5 py-4",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"block font-medium text-fg",children:["Signed in",c?` as ${c}`:""]}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:"Signing out ends your account session on this device. Vaults already connected here stay until you remove them."})]}),e.jsx("button",{type:"button",onClick:x,disabled:i,className:"btn btn-secondary btn-touch shrink-0",children:i?"Signing out…":"Sign out"})]})}function b({to:t,href:a,title:n,description:s}){const i=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium text-fg",children:n}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:s})]}),e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-dim",children:a?"↗":"→"})]}),u="focus-ring flex items-center justify-between gap-4 px-5 py-4 transition-colors hover:bg-bg-soft first:rounded-t-xl last:rounded-b-xl";return a?e.jsx("a",{href:a,className:u,children:i}):e.jsx(j,{to:t??"/",className:u,children:i})}function se(){return e.jsxs("section",{className:"card space-y-3 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Import notes"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Bring in an Obsidian vault zip or a folder of markdown files. Parsed in your browser; previewed before any note lands in the vault."})]}),e.jsx(j,{to:"/import",className:"btn btn-primary btn-touch",children:"Open importer"})]})}const ae=[{value:"keep",title:"Keep",help:"Recordings are stored with your notes; included wherever attachments are included."},{value:"until_transcribed",title:"Delete after transcribing",help:"Your words stay; the audio file is removed once the transcript lands."},{value:"never",title:"Never store",help:"Audio is removed even if transcription fails — the transcript is your only copy; failed transcriptions lose the audio."}];function ne({vaultId:t}){const a=k(),n=q(),s=Q(),{markMade:i}=W(t),{transcribeDefault:u,setTranscribeDefault:c}=X(t),h=y(r=>r.push);if((a==null?void 0:a.enabled)===!1)return null;const x=r=>{r===n.value||s.isPending||s.mutate(r,{onSuccess:()=>{i(),h("Voice recording setting saved.","success")},onError:o=>{h(o instanceof Error&&o.message?`Couldn't save: ${o.message}`:"Couldn't save the voice recording setting.","error")}})};return e.jsxs("section",{className:"card space-y-6 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Voice"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"How voice capture behaves in this vault."})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Transcribe recordings by default"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"New voice notes start with transcription on — your words are added to the note. Turn it off for a single recording right where you capture. Applies on this device."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":u,"aria-label":"Transcribe recordings by default","data-testid":"transcribe-default-toggle",onClick:()=>c(!u),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${u?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${u?"translate-x-5":"translate-x-0.5"}`})})]}),e.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Keep recordings"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"What happens to the audio file after a voice note is transcribed. Applies to this vault, from every device connected to it."})]}),n.isLoading?e.jsx("p",{className:"text-sm text-fg-dim",children:"Loading…"}):n.isError?e.jsx("p",{className:"text-sm text-fg-dim","data-testid":"retention-load-error",children:"Couldn't load this setting — check the vault connection."}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"space-y-2",disabled:!n.supported||s.isPending,children:[e.jsx("legend",{className:"sr-only",children:"Voice recording retention"}),ae.map(r=>{const o=n.value===r.value;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${o?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"audio-retention",value:r.value,checked:o,onChange:()=>x(r.value),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:r.title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:r.help})]})]},r.value)})]}),n.supported?null:e.jsx("p",{className:"text-xs text-fg-dim","data-testid":"retention-unsupported",children:"This vault doesn't support changing this yet — recordings are kept. Update the vault to choose."})]})]})]})}function ie(){const[t,a]=d.useState(()=>Z()),n=s=>{a(s),J(s)};return e.jsx("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Live preview"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Formats your writing as you type — Markdown stays underneath. Turn off for the raw editor with a side-by-side preview."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Live preview",onClick:()=>n(!t),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${t?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${t?"translate-x-5":"translate-x-0.5"}`})})]})})}function re(){const[t,a]=d.useState(()=>E()),n=s=>{a(s),G(s),H(s)};return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Text size"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Affects the editor and rendered notes on this device. Your markdown isn't changed."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"View text size"}),A.map(s=>{const i=t===s;return e.jsxs("label",{className:`flex items-center gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"text-size",value:s,checked:i,onChange:()=>n(s),className:"accent-accent"}),e.jsx("span",{className:"font-medium text-fg",children:O(s)})]},s)})]})]})}function le({vaultId:t}){const{db:a,mirror:n}=$(),s=y(m=>m.push),[i,u]=d.useState(null),[c,h]=d.useState(null),x=d.useCallback(async()=>{if(!a)return;const[m,l]=await Promise.all([_(a,t),I(a,t)]);u({bytes:m,count:l})},[a,t]);if(d.useEffect(()=>{x()},[x]),!n.enabled)return null;const r=async()=>{if(!c){h("sync");try{await n.syncNow(),await x(),s("Synced offline copy.","success")}catch{s("Couldn't sync the offline copy right now.","error")}finally{h(null)}}},o=async()=>{if(!c&&confirm("Clear this vault's offline copy from this device? Un-synced changes are kept.")){h("clear");try{await n.clearOffline(),await x(),s("Offline copy cleared.","success")}catch{s("Couldn't clear the offline copy.","error")}finally{h(null)}}};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft","aria-label":"Offline",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Offline"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"A copy of this vault is kept on this device so your notes open without a connection."})]}),e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Status"}),e.jsx("dd",{className:"text-fg",children:ce(n.state)})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Last synced"}),e.jsx("dd",{className:"text-fg-muted",children:n.lastSyncedAt?D(new Date(n.lastSyncedAt).toISOString()):"never"})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Saved on this device"}),e.jsx("dd",{className:"text-fg-muted tabular-nums","data-testid":"offline-usage",children:i?`${i.count} note${i.count===1?"":"s"} · ${w(i.bytes)} of ${w(K)}`:"—"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[e.jsx("button",{type:"button",onClick:r,disabled:c!==null,className:"btn btn-secondary btn-touch",children:c==="sync"?"Syncing…":"Sync now"}),e.jsx("button",{type:"button",onClick:o,disabled:c!==null,className:"text-sm text-danger hover:underline disabled:opacity-60",children:c==="clear"?"Clearing…":"Clear offline copy"})]})]})}function ce(t){switch(t){case"hydrating":return"Saving your vault…";case"offline":return"Offline — showing your saved vault";case"error":return"Sync error";default:return"Saved for offline"}}function w(t){return t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function oe(){const[t,a]=d.useState(!1);return d.useEffect(()=>{a(z())},[]),t?e.jsx("section",{className:"card rounded-xl p-6 text-sm shadow-soft",children:e.jsxs("p",{className:"text-fg-muted",children:[e.jsx("span",{className:"mr-2 inline-block rounded-full bg-positive-soft px-2 py-0.5 text-xs font-medium text-positive",children:"Installed"}),"Parachute is running as an installed app on this device."]})}):null}const S={auto:{title:"Auto",help:"Show the tree only when the vault has enough folders to make it worth the space."},always:{title:"Always",help:"Always show the tree, even on a tag-flat vault."},never:{title:"Never",help:"Hide the tree. The path-prefix text input still works."}};function de({vaultId:t}){const{mode:a,setMode:n}=R(t);return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Folder tree (Notes sidebar)"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Controls the collapsible folder tree on the notes list page. Auto-detect renders the tree when the vault has at least five top-level folders or twenty notes in folders."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"Path tree visibility"}),L.map(s=>{const i=a===s;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"path-tree-mode",value:s,checked:i,onChange:()=>n(s),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:S[s].title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:S[s].help})]})]},s)})]})]})}const v={pinned:{title:"Pinned",help:"Tag for notes you want at the top of views."},archived:{title:"Archived",help:"Tag for notes you've moved out of the way."},captureVoice:{title:"Voice capture",help:"Default tag for new voice memos."},captureText:{title:"Text capture",help:"Default tag for quick typed notes."},view:{title:"Saved view",help:"Tag the saved-view notes carry. Used to list them in the notes sidebar."}};function ue({vaultId:t}){const{roles:a,setRoles:n}=M(t),s=P(),i=y(l=>l.push),u=d.useId(),[c,h]=d.useState(a);d.useEffect(()=>h(a),[a]);const x=d.useMemo(()=>{const l=(s.data??[]).map(f=>f.name);return[...new Set(l)].sort((f,p)=>f.localeCompare(p))},[s.data]),r=N.some(l=>c[l].trim()!==a[l]),o=()=>{n(c),i("Tag roles saved.","success")},m=()=>{n(null),h(g),i("Tag roles reset to defaults.","success")};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Tag roles"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Point each role at whatever tag your vault already uses. Changes apply to future notes only — existing notes keep their current tags."})]}),e.jsx("datalist",{id:u,children:x.map(l=>e.jsx("option",{value:l},l))}),e.jsx("div",{className:"space-y-4",children:N.map(l=>e.jsxs("label",{className:"block text-sm",children:[e.jsxs("span",{className:"mb-1.5 flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-fg",children:v[l].title}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["default: #",g[l]]})]}),e.jsx("input",{type:"text",value:c[l],onChange:f=>h(p=>({...p,[l]:f.target.value})),list:u,placeholder:g[l],"aria-label":`${v[l].title} tag role`,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"input input-on-bg"}),e.jsx("span",{className:"mt-1.5 block text-xs text-fg-dim",children:v[l].help})]},l))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 pt-1",children:[e.jsx("button",{type:"button",onClick:o,disabled:!r,className:"btn btn-primary btn-lg",children:"Save"}),e.jsx("button",{type:"button",onClick:m,className:"btn btn-ghost",children:"Reset to defaults"})]})]})}export{pe as Settings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{br as o,ae as x,a as l,bs as h,j as e,N as c,L as j,v as r,a1 as g,r as f}from"./index-
|
|
1
|
+
import{br as o,ae as x,a as l,bs as h,j as e,N as c,L as j,v as r,a1 as g,r as f}from"./index-BhV_u6Bm.js";import{ViewCanvas as m}from"./ViewSurface-B-DhVasF.js";import"./TagSchemaEditor-Qk8dM9DF.js";function v(t,s,a){const i=s!=null&&s.fields?Object.keys(s.fields).length:0,n={tag:t};return t!==a.archived&&(n.exclude_tags=[a.archived]),n.sort="desc",n.limit=o,{noteId:`derived:tag:${t}`,title:t,kind:i>=1?"table":"list",query:n,problems:[]}}function u(){return e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx(j,{to:"/tags",className:"focus-ring hover:text-accent",children:"← Tags"})})}function y(){const{name:t}=x(),s=l(i=>i.getActiveVault()),a=h(t??null);return s?t?a.isPending?e.jsxs("div",{className:"page",children:[e.jsx(u,{}),e.jsx(T,{})]}):e.jsx(p,{name:t,tag:a.data??null}):e.jsx(c,{to:"/tags",replace:!0}):e.jsx(c,{to:"/",replace:!0})}function p({name:t,tag:s}){const a=l(d=>d.getActiveVault()),{roles:i}=g((a==null?void 0:a.id)??null),n=f.useMemo(()=>v(t,s,i),[t,s,i]);return e.jsx(m,{def:n,backingNote:null,pageSize:o,total:s==null?void 0:s.count,nav:e.jsx(u,{})})}function T(){return e.jsxs("div",{className:"space-y-4","aria-busy":"true",children:[e.jsx(r,{height:32,width:"40%"}),e.jsx(r,{height:20,width:"60%"}),e.jsxs("div",{className:"space-y-2 pt-4",children:[e.jsx(r,{height:56}),e.jsx(r,{height:56}),e.jsx(r,{height:56})]})]})}export{y as TagPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bs as V,
|
|
1
|
+
import{bs as V,c6 as _,r as u,j as e,V as K}from"./index-BhV_u6Bm.js";const q=["string","number","boolean","date"];let C=0;function g(){return C+=1,`row-${C}`}function z(s){return s?Object.entries(s).map(([n,l])=>{var i;return{rowId:g(),name:n,type:l.type||"string",values:((i=l.enum)==null?void 0:i.join(", "))??""}}):[]}function L(s){return s==="date"?{rowId:g(),name:"",type:"date"}:{rowId:g(),name:"",type:"string",values:""}}function B({tagName:s,intent:n,onSaved:l,onClose:i}){var I;const a=V(s),d=_(),[j,v]=u.useState(""),[f,x]=u.useState([]),[N,w]=u.useState(""),[k,T]=u.useState(!1),[E,p]=u.useState(null);u.useEffect(()=>{if(k||a.isPending)return;const t=a.data;let r=[];t&&(v(t.description??""),r=z(t.fields),w((t.parent_names??[]).join(", ")));const m=n==="date"?r.some(c=>c.type==="date"):r.length>0;n&&!m&&(r=[...r,L(n)]),x(r),T(!0)},[k,a.isPending,a.data,n]);const h=((I=a.data)==null?void 0:I.fields)??null,P=!M(h,S(f)),b=(t,r)=>{x(m=>m.map(c=>c.rowId===t?{...c,...r}:c))},D=()=>{x(t=>[...t,{rowId:g(),name:"",type:"string"}])},R=t=>{x(r=>r.filter(m=>m.rowId!==t))},A=async()=>{p(null);const t=f.map(o=>({...o,name:o.name.trim()}));if(t.filter(o=>o.name.length===0).length>0){p("Field names can't be blank. Remove the empty row or fill it in.");return}const m=new Set;for(const o of t){if(m.has(o.name)){p(`Duplicate field name "${o.name}". Each field needs a unique key.`);return}m.add(o.name)}const c=t.length>0?S(t):null,$=h!=null&&Object.keys(h).some(o=>!t.find(O=>O.name===o)),F=N.split(",").map(o=>o.trim()).filter(o=>o.length>0),y={description:j.trim()||null,parent_names:F.length>0?F:null};try{$?(await d.mutateAsync({name:s,payload:{...y,fields:null}}),c&&await d.mutateAsync({name:s,payload:{...y,fields:c}})):await d.mutateAsync({name:s,payload:{...y,fields:c}}),l==null||l(c??{}),i()}catch(o){if(o instanceof K){p("Session expired. Reconnect to save.");return}p(o instanceof Error?o.message:"Save failed")}};return e.jsx("dialog",{open:!0,"aria-modal":"true","aria-label":`Edit schema for #${s}`,className:"fixed inset-0 z-50 m-0 h-dvh w-screen max-h-none max-w-none overflow-y-auto bg-black/60 p-4 md:p-8",onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),i())},children:e.jsxs("div",{className:"mx-auto max-w-xl rounded-2xl border border-border bg-card p-5 text-fg shadow-lift md:p-6",children:[e.jsxs("header",{className:"mb-4 flex items-baseline justify-between gap-3",children:[e.jsxs("h2",{className:"font-serif text-lg",children:["Schema for ",e.jsxs("span",{className:"font-mono",children:["#",s]})]}),e.jsx("button",{type:"button",onClick:i,className:"text-sm text-fg-muted hover:text-accent","aria-label":"Close schema editor",children:"Close"})]}),a.isPending?e.jsx("p",{className:"text-sm text-fg-dim","aria-busy":"true",children:"Loading schema…"}):a.isError?e.jsxs("p",{role:"alert",className:"text-sm text-red-400",children:["Could not load schema: ",a.error.message]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"A meta tag gives every note carrying it a shared shape — fields it can carry, and where it sits in your tag hierarchy."}),n?e.jsx("p",{className:"mb-4 rounded-md border border-accent/30 bg-accent/5 p-3 text-sm text-fg-muted",children:n==="group"?"Name a field to organize by, then give it a set of values — each value becomes a column on your board.":"Name a date field — the calendar plots notes on the day it holds, and lets you drag them between days."}):null,e.jsxs("label",{className:"mb-4 block",children:[e.jsx("span",{className:"mb-1 block text-xs uppercase tracking-wider text-fg-dim",children:"Description"}),e.jsx("input",{type:"text",value:j,onChange:t=>v(t.target.value),placeholder:"What does this tag mean? Who uses it?","aria-label":"Tag description",className:"w-full rounded-lg border border-border bg-bg px-2.5 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"})]}),e.jsxs("fieldset",{className:"mb-4",children:[e.jsx("legend",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Fields"}),e.jsxs("p",{className:"mb-2 text-xs text-fg-dim",children:["Each field is a key and a type — e.g."," ",e.jsx("span",{className:"font-mono",children:"status — string"}),","," ",e.jsx("span",{className:"font-mono",children:"meeting_date — date"}),"."]}),f.length===0?e.jsx("p",{className:"mb-2 text-xs text-fg-dim",children:"No fields declared yet. Add one to give notes carrying this tag a structured shape."}):e.jsx("ul",{className:"mb-2 space-y-2.5","aria-label":"Schema fields",children:f.map(t=>e.jsxs("li",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:t.name,onChange:r=>b(t.rowId,{name:r.target.value}),placeholder:"field_name","aria-label":"Field name",className:"flex-1 rounded-lg border border-border bg-bg px-2 py-1 font-mono text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("select",{value:t.type,onChange:r=>b(t.rowId,{type:r.target.value}),"aria-label":`Type for ${t.name||"new field"}`,className:"rounded-lg border border-border bg-bg px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none",children:q.map(r=>e.jsx("option",{value:r,children:r},r))}),e.jsx("button",{type:"button",onClick:()=>R(t.rowId),"aria-label":`Remove field ${t.name||"new"}`,className:"text-fg-dim hover:text-red-400",children:"×"})]}),t.type==="string"?e.jsxs("div",{className:"pl-1",children:[e.jsx("input",{type:"text",value:t.values??"",onChange:r=>b(t.rowId,{values:r.target.value}),placeholder:"e.g. To do, In progress, Done","aria-label":`Values for ${t.name||"new field"}`,className:"w-full rounded-lg border border-border bg-bg px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("p",{className:"mt-1 text-2xs text-fg-dim",children:"Optional — comma-separated values become columns on a board."})]}):null]},t.rowId))}),e.jsx("button",{type:"button",onClick:D,className:"text-xs text-accent hover:text-accent-hover",children:"+ Add field"})]}),e.jsxs("label",{className:"mb-4 block",children:[e.jsx("span",{className:"mb-1 block text-xs uppercase tracking-wider text-fg-dim",children:"Parent tags"}),e.jsx("input",{type:"text",value:N,onChange:t=>w(t.target.value),placeholder:"comma-separated (e.g. project, area)","aria-label":"Parent tags",className:"w-full rounded-lg border border-border bg-bg px-2.5 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("p",{className:"mt-1 text-xs text-fg-dim",children:"Vault treats parents as a hierarchical relationship — children inherit semantics. Comma-separated; leave blank for a top-level tag."})]}),P?e.jsxs("div",{role:"alert",className:"mb-4 rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-300",children:[e.jsx("strong",{className:"block font-medium",children:"Heads up."})," Editing this tag's schema doesn't retroactively update notes already tagged with"," ",e.jsxs("span",{className:"font-mono",children:["#",s]}),". The new schema applies to notes you create or update from here on. Existing notes keep their current shape until you edit them."]}):null,E?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:E}):null,e.jsxs("footer",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:A,disabled:d.isPending,className:"rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:d.isPending?"Saving…":"Save schema"})]})]})]})})}function W(s){if(!s)return[];const n=new Set,l=[];for(const i of s.split(/[,\n]/)){const a=i.trim();a&&!n.has(a)&&(n.add(a),l.push(a))}return l}function S(s){const n={};for(const l of s){const i=l.name.trim();if(!i)continue;const a={type:l.type};if(l.type==="string"){const d=W(l.values);d.length>0&&(a.enum=d)}n[i]=a}return n}function H(s,n){const l=s??[],i=n??[];return l.length!==i.length?!1:l.every((a,d)=>a===i[d])}function M(s,n){const l=s?Object.keys(s):[],i=n?Object.keys(n):[];if(l.length!==i.length)return!1;for(const a of l)if(!n||!n[a]||s[a].type!==n[a].type||!H(s[a].enum,n[a].enum))return!1;return!0}export{B as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a6 as F,r,a9 as D,V as R,j as e,a as I,bn as V,aw as z,bo as B,bp as K,bq as U,N as q,v as W,E as Z,L as P,w as A}from"./index-Dwo2xe8_.js";import{T as _}from"./TagSchemaEditor-DIHppYmj.js";const O=t=>Object.values(t).reduce((n,g)=>n+g,0);function L({mode:t,sources:n,tagOptions:g,onClose:i,onRun:y,onRunMerge:l,pending:o,offline:c}){const m=F(a=>a.push),d=r.useId(),[p,h]=r.useState(t==="rename"?n[0]??"":""),[f,u]=r.useState(null),[x,v]=r.useState(null),[w,S]=r.useState(!1),b=r.useRef(null);r.useEffect(()=>{var a,s;(a=b.current)==null||a.focus(),(s=b.current)==null||s.select()},[]),r.useEffect(()=>{const a=s=>{s.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const j=p.trim().replace(/^#/,""),N=!o&&!c&&!w&&j.length>0&&!(t==="rename"&&j===n[0]),T=r.useCallback(async()=>{if(N){u(null),v(null);try{const a=await y(j);if("renamed"in a)m(`Renamed on ${a.renamed} note${a.renamed===1?"":"s"}.`,"success");else{const s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success")}i()}catch(a){if(a instanceof D&&t==="rename"&&l){v(a.target);return}a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Operation failed.")}}},[N,j,t,i,y,l,m]),E=r.useCallback(async()=>{if(!(!x||!l)){u(null),S(!0);try{const a=await l(x),s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success"),i()}catch(a){a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Merge failed."),S(!1)}}},[x,i,l,m]),k=t==="rename"?"Rename tag":`Merge ${n.length} tags`;return e.jsx("dialog",{open:!0,"aria-labelledby":"tag-op-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:a=>{a.target===a.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"tag-op-title",className:"mb-2 font-serif text-xl text-fg",children:k}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[t==="rename"?e.jsxs(e.Fragment,{children:["Rename ",e.jsx(C,{children:n[0]})," on every note that carries it. Notes that already have the new tag will end up with one copy."]}):e.jsxs(e.Fragment,{children:["Combine"," ",n.map((a,s)=>e.jsxs("span",{children:[e.jsx(C,{children:a}),s<n.length-1?", ":""]},a))," ","into one tag. The originals are removed."]})," ","Changes apply atomically on the vault."]}),e.jsxs("label",{className:"mb-3 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:t==="rename"?"New tag name":"Target tag"}),e.jsx("input",{ref:b,type:"text",value:p,onChange:a=>{h(a.target.value),x&&v(null)},onKeyDown:a=>{a.key==="Enter"&&N&&T()},list:d,"aria-label":t==="rename"?"New tag name":"Merge target tag",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-lg border border-border bg-bg/40 px-2.5 py-1.5 font-mono text-sm text-fg focus:border-accent focus:outline-none",autoComplete:"off"}),e.jsx("datalist",{id:d,children:g.map(a=>e.jsx("option",{value:a},a))})]}),c?e.jsx("p",{className:"mb-3 text-sm text-amber-300",children:"Offline — tag operations need a live vault connection."}):null,x?e.jsxs("div",{role:"alert",className:"mb-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm",children:[e.jsxs("p",{className:"mb-2 text-amber-300",children:["A tag named ",e.jsx(C,{children:x})," already exists."]}),e.jsxs("p",{className:"mb-3 text-fg-muted",children:["Merge ",e.jsx(C,{children:n[0]})," into ",e.jsx(C,{children:x})," instead? Notes that carry both end up with one copy."]}),e.jsx("button",{type:"button",onClick:()=>void E(),disabled:w,className:"rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:w?"Merging…":`Merge into #${x}`})]}):null,f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"min-h-11 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void T(),disabled:!N,className:"min-h-11 rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:o?t==="rename"?"Renaming…":"Merging…":t==="rename"?"Rename":"Merge"})]})]})})}function C({children:t}){return e.jsxs("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:["#",t]})}function te(){const t=I(s=>s.getActiveVault()),n=V(),{isOnline:g}=z(),{isPinned:i,togglePin:y}=B((t==null?void 0:t.id)??null),[l,o]=r.useState(""),[c,m]=r.useState("count"),[d,p]=r.useState(new Set),[h,f]=r.useState(null),[u,x]=r.useState(!1),[v,w]=r.useState(null),S=K(),b=U(),j=r.useMemo(()=>H(n.data??[],l,c),[n.data,l,c]),N=r.useMemo(()=>(n.data??[]).map(s=>s.name),[n.data]),T=s=>{p(M=>{const $=new Set(M);return $.has(s)?$.delete(s):$.add(s),$})},E=()=>p(new Set);if(!t)return e.jsx(q,{to:"/",replace:!0});const k=d.size,a=!g;return e.jsxs("div",{className:"page",children:[e.jsxs("header",{className:"mb-5 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-3 md:mb-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:t.name}),e.jsx("h1",{className:"page-title",children:"Tags"})]}),e.jsxs("button",{type:"button",onClick:()=>m(s=>s==="count"?"alpha":"count"),className:"focus-ring text-sm text-fg-muted hover:text-accent","aria-label":"Toggle tag sort",children:["Sort: ",c==="count"?"most used":"A–Z"]})]}),e.jsx("input",{type:"search",placeholder:"Filter tags…",value:l,onChange:s=>o(s.target.value),"aria-label":"Filter tags",className:"input mb-6"}),k>0?e.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-3 rounded-xl border border-accent/30 bg-accent/5 px-4 py-3 text-sm","aria-label":"Tag selection actions",children:[e.jsxs("span",{className:"text-fg-muted",children:[k," selected: ",Array.from(d).join(", ")]}),e.jsx("button",{type:"button",onClick:()=>x(!0),disabled:k<2||a,className:"btn btn-primary btn-sm",children:"Merge into…"}),e.jsx("button",{type:"button",onClick:E,className:"btn btn-ghost btn-sm",children:"Clear"})]}):null,n.isPending?e.jsx(J,{}):n.isError?e.jsx(Q,{error:n.error}):j.length===0?e.jsx(X,{filtering:l.trim().length>0,hasAny:(n.data??[]).length>0}):e.jsx("ul",{className:"card shadow-soft divide-y divide-border rounded-xl","aria-label":"Tag list",children:j.map(s=>e.jsx(G,{tag:s,selected:d.has(s.name),onToggle:()=>T(s.name),onRename:()=>f(s.name),onEditSchema:()=>w(s.name),pinned:i(s.name),onTogglePin:()=>y(s.name),offline:a},s.name))}),n.data&&n.data.length>0?e.jsxs("p",{className:"mt-6 text-xs tabular-nums text-fg-dim",children:[j.length," / ",n.data.length," tag",n.data.length===1?"":"s"]}):null,h!==null?e.jsx(L,{mode:"rename",sources:[h],tagOptions:N,onClose:()=>f(null),pending:S.isPending||b.isPending,offline:a,onRun:s=>S.mutateAsync({oldName:h,newName:s}),onRunMerge:s=>b.mutateAsync({sources:[h],target:s})}):null,u?e.jsx(L,{mode:"merge",sources:Array.from(d),tagOptions:N,onClose:()=>x(!1),pending:b.isPending,offline:a,onRun:async s=>{const M=await b.mutateAsync({sources:Array.from(d),target:s});return E(),M}}):null,v!==null?e.jsx(_,{tagName:v,onClose:()=>w(null)}):null]})}function G({tag:t,selected:n,onToggle:g,onRename:i,onEditSchema:y,pinned:l,onTogglePin:o,offline:c}){const m=t.fields?Object.keys(t.fields):[],d=t.parent_names??[],p=!!t.description||m.length>0||d.length>0;return e.jsxs("li",{className:"px-4 py-3 text-sm transition-colors hover:bg-bg-soft",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:g,"aria-label":`Select tag ${t.name}`,className:"accent-accent"}),e.jsxs(P,{to:`/tags/${encodeURIComponent(t.name)}`,className:"chip chip-tag focus-ring shrink-0 max-w-full break-all",children:[e.jsxs("span",{className:"font-mono",children:["#",t.name]}),e.jsx("span",{className:"tabular-nums opacity-70",children:t.count??0})]}),e.jsxs("div",{className:"-my-3 ml-auto flex shrink-0 items-center gap-4",children:[e.jsx("button",{type:"button",onClick:o,className:l?"focus-ring flex min-h-11 items-center text-xs font-medium text-accent hover:text-accent-hover":"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent","aria-label":l?`Unpin tag ${t.name}`:`Pin tag ${t.name}`,"aria-pressed":l,title:l?"Pinned to home strip — click to unpin":"Pin to home strip",children:l?"★ Pinned":"☆ Pin"}),e.jsx("button",{type:"button",onClick:y,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Edit schema for tag ${t.name}`,children:p?"Schema":"+ Schema"}),e.jsx("button",{type:"button",onClick:i,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Rename tag ${t.name}`,children:"Rename"})]})]}),p?e.jsxs("dl",{className:"ml-8 mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-fg-dim","aria-label":`Schema for ${t.name}`,children:[t.description?e.jsxs("div",{className:"flex w-full items-baseline gap-1.5",children:[e.jsx("dt",{className:"sr-only",children:"Description"}),e.jsx("dd",{className:"italic",children:t.description})]}):null,m.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Fields"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:m.map(h=>{var f,u;return`${h}: ${((u=(f=t.fields)==null?void 0:f[h])==null?void 0:u.type)??"?"}`}).join(", ")})]}):null,d.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Parents"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:d.join(", ")})]}):null]}):null]})}function H(t,n,g){const i=n.trim().toLowerCase(),l=[...i?t.filter(o=>o.name.toLowerCase().includes(i)):t];return g==="alpha"?l.sort((o,c)=>o.name.localeCompare(c.name)):l.sort((o,c)=>(c.count??0)-(o.count??0)||o.name.localeCompare(c.name)),l}function J(){return e.jsx("div",{className:"space-y-2","aria-busy":"true",children:[0,1,2,3,4].map(t=>e.jsx(W,{className:"h-12 rounded-xl"},t))})}function Q({error:t}){const n=t instanceof R;return e.jsx(Z,{title:n?"Session expired":"Could not load tags",message:t.message,action:n?e.jsx(P,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function X({filtering:t,hasAny:n}){return t&&n?e.jsx(A,{title:"No tags match your filter."}):e.jsx(A,{title:"No tags in this vault yet.",action:e.jsx(P,{to:"/new",className:"btn btn-primary",children:"Create a note"})})}export{te as Tags};
|
|
1
|
+
import{a6 as F,r,a9 as D,V as R,j as e,a as I,bn as V,aw as z,bo as B,bp as K,bq as U,N as q,v as W,E as Z,L as P,w as A}from"./index-BhV_u6Bm.js";import{T as _}from"./TagSchemaEditor-Qk8dM9DF.js";const O=t=>Object.values(t).reduce((n,g)=>n+g,0);function L({mode:t,sources:n,tagOptions:g,onClose:i,onRun:y,onRunMerge:l,pending:o,offline:c}){const m=F(a=>a.push),d=r.useId(),[p,h]=r.useState(t==="rename"?n[0]??"":""),[f,u]=r.useState(null),[x,v]=r.useState(null),[w,S]=r.useState(!1),b=r.useRef(null);r.useEffect(()=>{var a,s;(a=b.current)==null||a.focus(),(s=b.current)==null||s.select()},[]),r.useEffect(()=>{const a=s=>{s.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const j=p.trim().replace(/^#/,""),N=!o&&!c&&!w&&j.length>0&&!(t==="rename"&&j===n[0]),T=r.useCallback(async()=>{if(N){u(null),v(null);try{const a=await y(j);if("renamed"in a)m(`Renamed on ${a.renamed} note${a.renamed===1?"":"s"}.`,"success");else{const s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success")}i()}catch(a){if(a instanceof D&&t==="rename"&&l){v(a.target);return}a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Operation failed.")}}},[N,j,t,i,y,l,m]),E=r.useCallback(async()=>{if(!(!x||!l)){u(null),S(!0);try{const a=await l(x),s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success"),i()}catch(a){a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Merge failed."),S(!1)}}},[x,i,l,m]),k=t==="rename"?"Rename tag":`Merge ${n.length} tags`;return e.jsx("dialog",{open:!0,"aria-labelledby":"tag-op-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:a=>{a.target===a.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"tag-op-title",className:"mb-2 font-serif text-xl text-fg",children:k}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[t==="rename"?e.jsxs(e.Fragment,{children:["Rename ",e.jsx(C,{children:n[0]})," on every note that carries it. Notes that already have the new tag will end up with one copy."]}):e.jsxs(e.Fragment,{children:["Combine"," ",n.map((a,s)=>e.jsxs("span",{children:[e.jsx(C,{children:a}),s<n.length-1?", ":""]},a))," ","into one tag. The originals are removed."]})," ","Changes apply atomically on the vault."]}),e.jsxs("label",{className:"mb-3 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:t==="rename"?"New tag name":"Target tag"}),e.jsx("input",{ref:b,type:"text",value:p,onChange:a=>{h(a.target.value),x&&v(null)},onKeyDown:a=>{a.key==="Enter"&&N&&T()},list:d,"aria-label":t==="rename"?"New tag name":"Merge target tag",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-lg border border-border bg-bg/40 px-2.5 py-1.5 font-mono text-sm text-fg focus:border-accent focus:outline-none",autoComplete:"off"}),e.jsx("datalist",{id:d,children:g.map(a=>e.jsx("option",{value:a},a))})]}),c?e.jsx("p",{className:"mb-3 text-sm text-amber-300",children:"Offline — tag operations need a live vault connection."}):null,x?e.jsxs("div",{role:"alert",className:"mb-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm",children:[e.jsxs("p",{className:"mb-2 text-amber-300",children:["A tag named ",e.jsx(C,{children:x})," already exists."]}),e.jsxs("p",{className:"mb-3 text-fg-muted",children:["Merge ",e.jsx(C,{children:n[0]})," into ",e.jsx(C,{children:x})," instead? Notes that carry both end up with one copy."]}),e.jsx("button",{type:"button",onClick:()=>void E(),disabled:w,className:"rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:w?"Merging…":`Merge into #${x}`})]}):null,f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"min-h-11 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void T(),disabled:!N,className:"min-h-11 rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:o?t==="rename"?"Renaming…":"Merging…":t==="rename"?"Rename":"Merge"})]})]})})}function C({children:t}){return e.jsxs("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:["#",t]})}function te(){const t=I(s=>s.getActiveVault()),n=V(),{isOnline:g}=z(),{isPinned:i,togglePin:y}=B((t==null?void 0:t.id)??null),[l,o]=r.useState(""),[c,m]=r.useState("count"),[d,p]=r.useState(new Set),[h,f]=r.useState(null),[u,x]=r.useState(!1),[v,w]=r.useState(null),S=K(),b=U(),j=r.useMemo(()=>H(n.data??[],l,c),[n.data,l,c]),N=r.useMemo(()=>(n.data??[]).map(s=>s.name),[n.data]),T=s=>{p(M=>{const $=new Set(M);return $.has(s)?$.delete(s):$.add(s),$})},E=()=>p(new Set);if(!t)return e.jsx(q,{to:"/",replace:!0});const k=d.size,a=!g;return e.jsxs("div",{className:"page",children:[e.jsxs("header",{className:"mb-5 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-3 md:mb-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:t.name}),e.jsx("h1",{className:"page-title",children:"Tags"})]}),e.jsxs("button",{type:"button",onClick:()=>m(s=>s==="count"?"alpha":"count"),className:"focus-ring text-sm text-fg-muted hover:text-accent","aria-label":"Toggle tag sort",children:["Sort: ",c==="count"?"most used":"A–Z"]})]}),e.jsx("input",{type:"search",placeholder:"Filter tags…",value:l,onChange:s=>o(s.target.value),"aria-label":"Filter tags",className:"input mb-6"}),k>0?e.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-3 rounded-xl border border-accent/30 bg-accent/5 px-4 py-3 text-sm","aria-label":"Tag selection actions",children:[e.jsxs("span",{className:"text-fg-muted",children:[k," selected: ",Array.from(d).join(", ")]}),e.jsx("button",{type:"button",onClick:()=>x(!0),disabled:k<2||a,className:"btn btn-primary btn-sm",children:"Merge into…"}),e.jsx("button",{type:"button",onClick:E,className:"btn btn-ghost btn-sm",children:"Clear"})]}):null,n.isPending?e.jsx(J,{}):n.isError?e.jsx(Q,{error:n.error}):j.length===0?e.jsx(X,{filtering:l.trim().length>0,hasAny:(n.data??[]).length>0}):e.jsx("ul",{className:"card shadow-soft divide-y divide-border rounded-xl","aria-label":"Tag list",children:j.map(s=>e.jsx(G,{tag:s,selected:d.has(s.name),onToggle:()=>T(s.name),onRename:()=>f(s.name),onEditSchema:()=>w(s.name),pinned:i(s.name),onTogglePin:()=>y(s.name),offline:a},s.name))}),n.data&&n.data.length>0?e.jsxs("p",{className:"mt-6 text-xs tabular-nums text-fg-dim",children:[j.length," / ",n.data.length," tag",n.data.length===1?"":"s"]}):null,h!==null?e.jsx(L,{mode:"rename",sources:[h],tagOptions:N,onClose:()=>f(null),pending:S.isPending||b.isPending,offline:a,onRun:s=>S.mutateAsync({oldName:h,newName:s}),onRunMerge:s=>b.mutateAsync({sources:[h],target:s})}):null,u?e.jsx(L,{mode:"merge",sources:Array.from(d),tagOptions:N,onClose:()=>x(!1),pending:b.isPending,offline:a,onRun:async s=>{const M=await b.mutateAsync({sources:Array.from(d),target:s});return E(),M}}):null,v!==null?e.jsx(_,{tagName:v,onClose:()=>w(null)}):null]})}function G({tag:t,selected:n,onToggle:g,onRename:i,onEditSchema:y,pinned:l,onTogglePin:o,offline:c}){const m=t.fields?Object.keys(t.fields):[],d=t.parent_names??[],p=!!t.description||m.length>0||d.length>0;return e.jsxs("li",{className:"px-4 py-3 text-sm transition-colors hover:bg-bg-soft",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:g,"aria-label":`Select tag ${t.name}`,className:"accent-accent"}),e.jsxs(P,{to:`/tags/${encodeURIComponent(t.name)}`,className:"chip chip-tag focus-ring shrink-0 max-w-full break-all",children:[e.jsxs("span",{className:"font-mono",children:["#",t.name]}),e.jsx("span",{className:"tabular-nums opacity-70",children:t.count??0})]}),e.jsxs("div",{className:"-my-3 ml-auto flex shrink-0 items-center gap-4",children:[e.jsx("button",{type:"button",onClick:o,className:l?"focus-ring flex min-h-11 items-center text-xs font-medium text-accent hover:text-accent-hover":"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent","aria-label":l?`Unpin tag ${t.name}`:`Pin tag ${t.name}`,"aria-pressed":l,title:l?"Pinned to home strip — click to unpin":"Pin to home strip",children:l?"★ Pinned":"☆ Pin"}),e.jsx("button",{type:"button",onClick:y,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Edit schema for tag ${t.name}`,children:p?"Schema":"+ Schema"}),e.jsx("button",{type:"button",onClick:i,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Rename tag ${t.name}`,children:"Rename"})]})]}),p?e.jsxs("dl",{className:"ml-8 mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-fg-dim","aria-label":`Schema for ${t.name}`,children:[t.description?e.jsxs("div",{className:"flex w-full items-baseline gap-1.5",children:[e.jsx("dt",{className:"sr-only",children:"Description"}),e.jsx("dd",{className:"italic",children:t.description})]}):null,m.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Fields"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:m.map(h=>{var f,u;return`${h}: ${((u=(f=t.fields)==null?void 0:f[h])==null?void 0:u.type)??"?"}`}).join(", ")})]}):null,d.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Parents"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:d.join(", ")})]}):null]}):null]})}function H(t,n,g){const i=n.trim().toLowerCase(),l=[...i?t.filter(o=>o.name.toLowerCase().includes(i)):t];return g==="alpha"?l.sort((o,c)=>o.name.localeCompare(c.name)):l.sort((o,c)=>(c.count??0)-(o.count??0)||o.name.localeCompare(c.name)),l}function J(){return e.jsx("div",{className:"space-y-2","aria-busy":"true",children:[0,1,2,3,4].map(t=>e.jsx(W,{className:"h-12 rounded-xl"},t))})}function Q({error:t}){const n=t instanceof R;return e.jsx(Z,{title:n?"Session expired":"Could not load tags",message:t.message,action:n?e.jsx(P,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function X({filtering:t,hasAny:n}){return t&&n?e.jsx(A,{title:"No tags match your filter."}):e.jsx(A,{title:"No tags in this vault yet.",action:e.jsx(P,{to:"/new",className:"btn btn-primary",children:"Create a note"})})}export{te as Tags};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-
|
|
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-
|
|
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(`
|
|
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-
|
|
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 +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-
|
|
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};
|
|
@@ -0,0 +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 +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-
|
|
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 +1 @@
|
|
|
1
|
-
import{j as e,bE as d}from"./index-
|
|
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,2 +1,2 @@
|
|
|
1
|
-
import{r as n,j as i,aK as h,aL as v}from"./index-
|
|
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?"":`
|
|
2
2
|
`;return e.mimeType.startsWith("image/")?`${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-
|
|
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};
|