ocean-brain 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/dist/mcp.js +0 -0
  3. package/package.json +52 -52
  4. package/server/client/dist/assets/{Calendar-PQrJMeAt.js → Calendar-Bz7jheg6.js} +1 -1
  5. package/server/client/dist/assets/{Callout-1yeMHtJI.js → Callout-DlFLkTCG.js} +1 -1
  6. package/server/client/dist/assets/{Graph-D3-g5kyk.js → Graph-BdxtJvog.js} +1 -1
  7. package/server/client/dist/assets/{Image-DK0lnaK2.js → Image-DxWhlIDG.js} +1 -1
  8. package/server/client/dist/assets/{Image.es-z4AxF0hY.js → Image.es-BFodqKS5.js} +1 -1
  9. package/server/client/dist/assets/{Note-Y-3xdN3G.js → Note-BgMxsWZT.js} +1 -1
  10. package/server/client/dist/assets/{Plus.es-1spJ71ck.js → Plus.es-Yq7J1Ur4.js} +1 -1
  11. package/server/client/dist/assets/{Reminders-lu5O5_pP.js → Reminders-CUsR56ff.js} +1 -1
  12. package/server/client/dist/assets/{Search-dJsgzOd8.js → Search-DncrGgOZ.js} +1 -1
  13. package/server/client/dist/assets/{SurfaceCard-SgDqYFde.js → SurfaceCard-CfL1jD-O.js} +1 -1
  14. package/server/client/dist/assets/{Tag-DQjTUB7D.js → Tag-CKDLs2Y6.js} +1 -1
  15. package/server/client/dist/assets/{TagNotes-IS-hagJ3.js → TagNotes-ByX_Qias.js} +1 -1
  16. package/server/client/dist/assets/{Trash.es-Dfedzvhe.js → Trash.es-BPrF6TPV.js} +1 -1
  17. package/server/client/dist/assets/ViewNotes-r1kxKZ8O.js +1 -0
  18. package/server/client/dist/assets/ViewSectionTableRenderer-DQ4UeCnm.js +102 -0
  19. package/server/client/dist/assets/Views-FzFBtNT2.js +1 -0
  20. package/server/client/dist/assets/{image.api-BDkzo1i_.js → image.api-Bcg3TFCG.js} +1 -1
  21. package/server/client/dist/assets/{index-_nFnTWJM.js → index-BFfQKAUY.js} +4 -4
  22. package/server/client/dist/assets/{index-Biw4vuiN.css → index-C5BGzDgt.css} +1 -1
  23. package/server/client/dist/assets/{index-D_sDKVkI.js → index-DiMt3Dz4.js} +1 -1
  24. package/server/client/dist/assets/{manage-image-CiN4wnYb.js → manage-image-DzDlncCM.js} +1 -1
  25. package/server/client/dist/assets/{manage-image-detail-BR74WiYE.js → manage-image-detail-Bqw8NURO.js} +1 -1
  26. package/server/client/dist/assets/{mcp-DpfvOVHH.js → mcp-BqasqTWC.js} +1 -1
  27. package/server/client/dist/assets/{note-core-DMZcZ4yV.js → note-core-Z6kqulGB.js} +53 -53
  28. package/server/client/dist/assets/{note-vendor-uuJO2MTD.js → note-vendor-i1M2FSI2.js} +1 -1
  29. package/server/client/dist/assets/{placeholder-DCu7R7K3.js → placeholder-Ro00byT7.js} +1 -1
  30. package/server/client/dist/assets/{properties-puf7t5Dt.js → properties-Tid6-ghT.js} +1 -1
  31. package/server/client/dist/assets/{trash-DycpAEwI.js → trash-bHK02-Up.js} +1 -1
  32. package/server/client/dist/assets/{useReminderMutate-OnHcClBg.js → useReminderMutate-BWymIujb.js} +1 -1
  33. package/server/client/dist/index.html +4 -4
  34. package/server/dist/modules/blocknote.js +1 -1
  35. package/server/dist/modules/blocknote.js.map +1 -1
  36. package/server/client/dist/assets/ViewNotes-aJcQSFJ4.js +0 -1
  37. package/server/client/dist/assets/ViewSectionTableRenderer-CTTTH1yb.js +0 -102
  38. package/server/client/dist/assets/Views-4kyV8szd.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as t}from"./note-vendor-i1M2FSI2.js";import{P as m,J as C,a0 as K,i as r,j as D,V as I,k as M,av as O,a6 as S,q as u,ac as V,a1 as Q,aM as A,T as L,m as W}from"./index-BFfQKAUY.js";import{a as _}from"./graph-vendor-CUxe67Lr.js";import{B,f as J,i as U,V as z,a as x,d as G,u as H,e as X}from"./ViewSectionTableRenderer-DQ4UeCnm.js";import"./note-core-Z6kqulGB.js";const y=D(I);function Y(){const n=y.useNavigate(),l=M(),P=W(),{page:c,sectionId:o}=y.useSearch(),{onDelete:T,onPinned:q,deleteWarningDialog:F}=O(),[w,h]=_.useState(!1),i=25,{data:s}=S({queryKey:u.views.section(o),async queryFn(){const e=await B(o);if(e.type==="error")throw e;if(!e.viewSection)throw new Error("View section not found.");return e.viewSection}}),{data:a}=S({queryKey:u.views.sectionNotes(o,{limit:i,offset:(c-1)*i}),async queryFn(){const e=await J(o,{limit:i,offset:(c-1)*i});if(e.type==="error")throw e;return e.viewSectionNotes}}),p=s.title,d=s.tagNames,R=s.mode,g=s.propertyFilters,k=d.length>0,v=g.length>0,j=d.length>1?` · ${U(R)}`:"",E=k?v?`Property and tag filters${j}`:`Tag filters${j}`:v?"Property filters":"All notes",N=t.jsx(V,{fallback:null,children:a.totalCount&&i<a.totalCount&&t.jsx(Q,{page:c,last:Math.ceil(a.totalCount/i),onChange:e=>{n({search:f=>({...f,page:e})})}})}),$=async e=>{if(w)return;const f=s.sortBy===e?s.sortOrder==="asc"?"desc":"asc":e==="title"?"asc":"desc";h(!0);const b=await H(s.id,X(s,{sortBy:e,sortOrder:f}));if(b.type==="error"){P(b.errors[0]?.message??"Failed to update table sort."),h(!1);return}await l.invalidateQueries({queryKey:u.views.all(),exact:!1}),h(!1)};return t.jsxs(m,{title:p,heading:a.totalCount>0?`${p} (${a.totalCount})`:p,description:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(L,{as:"span",variant:"meta",tone:"tertiary",children:E}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[d.map(e=>t.jsx(x,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:e},e)),g.map(e=>t.jsx(x,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:G(e)},`${e.key}-${e.operator}-${e.value??""}`)),d.length===0&&g.length===0&&t.jsx(x,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:"All notes"})]})]}),children:[t.jsx(V,{fallback:t.jsx(C,{title:"No notes match this saved view",description:"Adjust this view's filters or keep writing until matching notes appear."}),children:a.notes.length>0&&s.displayType==="table"?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(z,{section:s,notes:a.notes,isPending:!1,isError:!1,onRetry:()=>{l.invalidateQueries({queryKey:u.views.sectionNotes(o,{limit:i,offset:(c-1)*i})})},onSortChange:$,isSortPending:w}),N]}):a.notes.length>0?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx("div",{className:"grid-auto-cards grid gap-5",children:a.notes.map(e=>t.jsx(A,{...e,onPinned:()=>q(e.id,e.pinned),onDelete:()=>T(e.id)},e.id))}),N]}):null}),F]})}function ie(){const{sectionId:n,page:l}=y.useSearch();return n?t.jsx(K,{fallback:t.jsx(m,{title:"View Notes",heading:t.jsx(r,{width:180,height:24,className:"rounded-full"}),description:t.jsx(r,{width:220,height:16,className:"rounded-full"}),children:t.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[t.jsx(r,{height:"112px"}),t.jsx(r,{height:"112px"}),t.jsx(r,{height:"112px"})]})}),errorTitle:"Failed to load view notes",errorDescription:"Retry loading notes for this saved view section",resetKeys:[l,n],children:t.jsx(Y,{})}):t.jsx(m,{title:"View Notes",description:"Saved view note lists require a section id.",children:t.jsx(C,{title:"No section selected",description:"Return to Views and open a section from there."})})}export{ie as default};
@@ -0,0 +1,102 @@
1
+ import{h as d,c as w,a4 as D,T as c,B as E,N as f,L as O,t as y}from"./index-BFfQKAUY.js";import{j as r}from"./note-vendor-i1M2FSI2.js";import"./graph-vendor-CUxe67Lr.js";const x=`
2
+ id
3
+ tabId
4
+ title
5
+ displayType
6
+ displayOptions {
7
+ tableColumns
8
+ }
9
+ tagNames
10
+ mode
11
+ propertyFilters {
12
+ key
13
+ name
14
+ valueType
15
+ operator
16
+ value
17
+ }
18
+ sortBy
19
+ sortOrder
20
+ limit
21
+ order
22
+ `;function Q(){return d(`query FetchViewWorkspace {
23
+ viewWorkspace {
24
+ activeTabId
25
+ tabs {
26
+ id
27
+ title
28
+ order
29
+ sections {
30
+ ${x}
31
+ }
32
+ }
33
+ }
34
+ }`)}function Y(e){return d(`query FetchViewSection($id: ID!) {
35
+ viewSection(id: $id) {
36
+ ${x}
37
+ }
38
+ }`,{id:e})}function G(e,{limit:t=25,offset:a=0}={}){return d(`query FetchViewSectionNotes($id: ID!, $pagination: PaginationInput) {
39
+ viewSectionNotes(id: $id, pagination: $pagination) {
40
+ totalCount
41
+ notes {
42
+ id
43
+ title
44
+ pinned
45
+ tags {
46
+ id
47
+ name
48
+ }
49
+ createdAt
50
+ updatedAt
51
+ properties {
52
+ key
53
+ name
54
+ value
55
+ valueType
56
+ option { id label value color order }
57
+ createdAt
58
+ updatedAt
59
+ }
60
+ }
61
+ }
62
+ }`,{id:e,pagination:{limit:t,offset:a}})}function J(e){return d(`mutation CreateViewTab($title: String!) {
63
+ createViewTab(title: $title) {
64
+ id
65
+ }
66
+ }`,{title:e})}function X(e,t){return d(`mutation UpdateViewTab($id: ID!, $title: String!) {
67
+ updateViewTab(id: $id, title: $title) {
68
+ id
69
+ }
70
+ }`,{id:e,title:t})}function Z(e){return d(`mutation DeleteViewTab($id: ID!) {
71
+ deleteViewTab(id: $id)
72
+ }`,{id:e})}function ee(e){return d(`mutation SetActiveViewTab($id: ID!) {
73
+ setActiveViewTab(id: $id) {
74
+ activeTabId
75
+ tabs {
76
+ id
77
+ title
78
+ order
79
+ sections {
80
+ ${x}
81
+ }
82
+ }
83
+ }
84
+ }`,{id:e})}function te(e){return d(`mutation ReorderViewTabs($tabIds: [ID!]!) {
85
+ reorderViewTabs(tabIds: $tabIds) {
86
+ id
87
+ }
88
+ }`,{tabIds:e})}function re(e,t){return d(`mutation CreateViewSection($tabId: ID!, $input: ViewSectionInput!) {
89
+ createViewSection(tabId: $tabId, input: $input) {
90
+ id
91
+ }
92
+ }`,{tabId:e,input:t})}function ae(e,t){return d(`mutation UpdateViewSection($id: ID!, $input: ViewSectionInput!) {
93
+ updateViewSection(id: $id, input: $input) {
94
+ id
95
+ }
96
+ }`,{id:e,input:t})}function se(e){return d(`mutation DeleteViewSection($id: ID!) {
97
+ deleteViewSection(id: $id)
98
+ }`,{id:e})}function ie(e,t){return d(`mutation ReorderViewSections($tabId: ID!, $sectionIds: [ID!]!) {
99
+ reorderViewSections(tabId: $tabId, sectionIds: $sectionIds) {
100
+ id
101
+ }
102
+ }`,{tabId:e,sectionIds:t})}const L={compact:"h-[22px] px-2",regular:"h-7 px-2.5"};function m({children:e,className:t,contentClassName:a,size:s="regular",truncateContent:i=!0,...l}){return r.jsx("span",{className:w("inline-flex min-w-0 items-center overflow-hidden whitespace-nowrap rounded-full border text-xs font-medium leading-none",L[s],t),...l,children:i?r.jsx("span",{className:w("min-w-0 truncate",a),children:e}):e})}const v=["title","tags","properties","createdAt","updatedAt"],ne={activeTabId:null,tabs:[]},W=e=>{const t=e.trim();return t?t.startsWith("@")?t:t.startsWith("#")?`@${t.slice(1)}`:`@${t}`:""},N=(e,t,a)=>{if(t===a)return e;const s=e.findIndex(u=>u.id===t),i=e.findIndex(u=>u.id===a);if(s<0||i<0)return e;const l=[...e],[h]=l.splice(s,1);return l.splice(i,0,h),l},oe=e=>{const t=e.flatMap(a=>typeof a=="string"?a.split(","):[]);return Array.from(new Set(t.map(W).filter(Boolean)))},de=e=>e.tabs.length===0?null:e.activeTabId?e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]??null:e.tabs[0]??null,le=(e,t)=>e.tabs.some(a=>a.id===t)?{...e,activeTabId:t}:e,ce=(e,t,a)=>({...e,tabs:N(e.tabs,t,a)}),ue=(e,t,a,s)=>({...e,tabs:e.tabs.map(i=>i.id===t?{...i,sections:N(i.sections,a,s)}:i)}),pe=e=>e==="or"?"OR — any selected tag":"AND — all selected tags",be=e=>e==="or"?"OR":"AND",k=e=>{switch(e){case"notEquals":return"is not";case"contains":return"contains";case"notContains":return"does not contain";case"before":return"before";case"after":return"after";case"exists":return"is set";case"notExists":return"is empty";default:return"is"}},me=e=>{switch(e){case"table":return"Table";case"calendar":return"Unavailable";default:return"List"}},B=e=>{switch(e){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},T=e=>{const t=new Set(v),a=(e??[]).filter(i=>t.has(i)),s=Array.from(new Set(a));return s.length===0?[...v]:s.includes("title")?s:["title",...s]},z=e=>({tableColumns:T(e?.tableColumns)}),he=e=>{const t=k(e.operator);return e.operator==="exists"||e.operator==="notExists"?`${e.name} ${t}`:`${e.name} ${t} ${e.value??""}`.trim()},xe=(e,t={})=>{const a={...e,...t};return{title:a.title,displayType:a.displayType,displayOptions:z(a.displayOptions),tagNames:a.tagNames,mode:a.mode,propertyFilters:a.propertyFilters.map(s=>({key:s.key,valueType:s.valueType,operator:s.operator,value:s.value})),sortBy:a.sortBy,sortOrder:a.sortOrder,limit:a.limit}},ge=e=>({page:1,sectionId:e.id}),_=e=>e.valueType==="select"?e.option?.label??e.value:e.valueType==="boolean"?e.value==="true"?"True":"False":e.value,F=e=>(e.properties??[]).slice(0,3),V={title:280,tags:190,properties:260,createdAt:132,updatedAt:132},P={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},j="flex h-[22px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",I="text-xs leading-5 text-fg-tertiary",R=e=>{const t=e.reduce((a,s)=>a+V[s],0);return Math.max(520,t)},q=(e,t={})=>{if(e.tags.length===0)return t.hideEmpty?null:r.jsx("span",{className:I,children:"—"});const a=e.tags.slice(0,3),s=e.tags.length-a.length;return r.jsxs("div",{className:j,children:[a.map(i=>r.jsx(m,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0&&r.jsxs(m,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]})]})},M=(e,t={})=>{const a=F(e);if(a.length===0)return t.hideEmpty?null:r.jsx("span",{className:I,children:"—"});const s=(e.properties?.length??0)-a.length;return r.jsxs("div",{className:j,children:[a.map(i=>r.jsxs(m,{size:"compact",truncateContent:!1,className:"max-w-[190px] shrink-0 gap-1 border-border-subtle bg-subtle text-fg-secondary",children:[r.jsx("span",{className:"min-w-0 max-w-[76px] shrink truncate text-fg-tertiary",children:i.name}),r.jsx("span",{className:"min-w-0 truncate",children:_(i)||"—"})]},i.key)),s>0&&r.jsxs(m,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]})]})};function we({section:e,notes:t,isPending:a,isError:s,onRetry:i,onSortChange:l,isSortPending:h}){const u=D(),p=T(e.displayOptions?.tableColumns),S=R(p),$=n=>{u({to:f,params:{id:n}})},A=n=>{const o=P[n],b=B(n),g=o?e.sortBy===o:!1;return r.jsx("th",{"aria-sort":g?e.sortOrder==="asc"?"ascending":"descending":void 0,className:"px-3 py-2.5 text-xs font-semibold text-fg-tertiary",children:o?r.jsxs("button",{type:"button",className:"focus-ring-soft -ml-1 inline-flex items-center gap-1 rounded-[8px] px-1 py-0.5 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-secondary disabled:cursor-wait disabled:opacity-60",disabled:h,onClick:()=>l(o),children:[r.jsx("span",{children:b}),r.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:g?e.sortOrder==="asc"?"↑":"↓":"↕"})]}):b},n)},C=(n,o)=>{switch(o){case"tags":return r.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:q(n)},o);case"properties":return r.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:M(n)},o);case"createdAt":return r.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:r.jsx(c,{as:"span",variant:"meta",tone:"tertiary",children:y(Number(n.createdAt))})},o);case"updatedAt":return r.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:r.jsx(c,{as:"span",variant:"meta",tone:"tertiary",children:y(Number(n.updatedAt))})},o);default:return r.jsx("td",{className:"px-3 py-2.5 align-middle",children:r.jsx(c,{as:"div",variant:"body",weight:"semibold",className:"line-clamp-1",children:r.jsx(O,{to:f,params:{id:n.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/85",onClick:b=>b.stopPropagation(),children:n.title||"Untitled"})})},o)}};return a?r.jsxs("div",{className:"overflow-hidden rounded-[16px] border border-border-subtle",children:[r.jsx("div",{className:"h-11 animate-pulse bg-hover-subtle"}),r.jsx("div",{className:"h-14 animate-pulse border-t border-border-subtle bg-elevated"}),r.jsx("div",{className:"h-14 animate-pulse border-t border-border-subtle bg-elevated"}),r.jsx("div",{className:"h-14 animate-pulse border-t border-border-subtle bg-elevated"})]}):s?r.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[r.jsx(c,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),r.jsx(c,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),r.jsx("div",{className:"mt-3",children:r.jsx(E,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Retry"})})]}):t.length===0?r.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[r.jsx(c,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),r.jsx(c,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):r.jsx("div",{className:"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated",children:r.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:S},children:[r.jsx("caption",{className:"sr-only",children:"View query results as a table"}),r.jsx("colgroup",{children:p.map(n=>r.jsx("col",{style:{width:V[n]}},n))}),r.jsx("thead",{className:"bg-subtle/80",children:r.jsx("tr",{className:"border-b border-border-subtle",children:p.map(A)})}),r.jsx("tbody",{className:"bg-elevated",children:t.map(n=>r.jsx("tr",{className:"h-12 cursor-pointer border-b border-border-subtle/70 transition-colors last:border-b-0 hover:bg-hover-subtle",onClick:()=>$(n.id),children:p.map(o=>C(n,o))},n.id))})]})})}export{se as A,Y as B,v as D,ne as E,we as V,m as a,ge as b,me as c,he as d,xe as e,G as f,be as g,k as h,pe as i,z as j,T as k,B as l,Q as m,oe as n,de as o,ee as p,te as q,ce as r,le as s,ue as t,ae as u,ie as v,J as w,X as x,Z as y,re as z};
@@ -0,0 +1 @@
1
+ import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as Ze,T as l,B as N,L as oe,N as Ye,t as Ge,k as Ee,u as ee,q as E,V as ce,D as De,l as Ae,m as Le,M as R,n as V,I as de,o as ue,r as J,v as Je,S as _,e as v,w as Xe,x as ze,y as et,z as tt,A as st,E as me,F as at,K as rt,G as nt,H as it,P as lt,i as re,J as pe,O as xe,Q as ot,R as he,U as ge,W as dt,X as ct,Y as ut,Z as Oe,_ as Re,c as te,$ as qe}from"./index-BFfQKAUY.js";import{a as i}from"./graph-vendor-CUxe67Lr.js";import{V as mt,b as pt,f as xt,g as ht,a as X,c as Ie,d as gt,u as Me,e as bt,n as be,h as ft,i as fe,j as vt,k as Pe,l as yt,D as jt,m as wt,o as Nt,E as Tt,s as St,p as Ct,r as kt,q as Vt,t as Ft,v as Et,w as Dt,x as At,y as Lt,z as zt,A as Ot}from"./ViewSectionTableRenderer-DQ4UeCnm.js";import{S as K}from"./SurfaceCard-CfL1jD-O.js";import{n as ne}from"./Plus.es-Yq7J1Ur4.js";import"./note-core-Z6kqulGB.js";const Rt=new Map([["bold",i.createElement(i.Fragment,null,i.createElement("path",{d:"M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z"}))],["duotone",i.createElement(i.Fragment,null,i.createElement("path",{d:"M216,128l-72,72V56Z",opacity:"0.2"}),i.createElement("path",{d:"M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z"}))],["fill",i.createElement(i.Fragment,null,i.createElement("path",{d:"M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z"}))],["light",i.createElement(i.Fragment,null,i.createElement("path",{d:"M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z"}))],["regular",i.createElement(i.Fragment,null,i.createElement("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"}))],["thin",i.createElement(i.Fragment,null,i.createElement("path",{d:"M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z"}))]]),_e=i.forwardRef((t,n)=>i.createElement(Ze,{ref:n,...t,weights:Rt}));_e.displayName="ArrowRightIcon";const qt=_e,It="flex items-start justify-between gap-3 rounded-[14px] border border-border-subtle/70 px-3 py-2.5 transition-colors hover:border-border-secondary hover:bg-hover-subtle";function Mt({notes:t,isPending:n,isError:r,onRetry:p}){return n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-14 animate-pulse rounded-[14px] bg-hover-subtle"}),e.jsx("div",{className:"h-14 animate-pulse rounded-[14px] bg-hover-subtle"}),e.jsx("div",{className:"h-14 animate-pulse rounded-[14px] bg-hover-subtle"})]}):r?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:p,children:"Retry"})})]}):t.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx(e.Fragment,{children:t.map(u=>e.jsxs(oe,{to:Ye,params:{id:u.id},className:It,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(l,{as:"div",variant:"body",weight:"semibold",className:"line-clamp-1",children:u.title||"Untitled"}),e.jsxs(l,{as:"div",variant:"meta",tone:"tertiary",className:"mt-1",children:["Updated ",Ge(Number(u.updatedAt))]})]}),e.jsx(qt,{className:"mt-0.5 h-4 w-4 shrink-0 text-fg-tertiary"})]},u.id))})}function Pt({onEdit:t}){return e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"This display type is unavailable"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Switch this section to List or Table to preview the saved query here."}),e.jsx("div",{className:"mt-3",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:t,children:"Change display"})})]})}function _t({section:t,notes:n,isPending:r,isError:p,onRetry:u,onEdit:x,onSortChange:b,isSortPending:g}){return t.displayType==="table"?e.jsx(mt,{section:t,notes:n,isPending:r,isError:p,onRetry:u,onSortChange:b,isSortPending:g}):t.displayType==="calendar"?e.jsx(Pt,{onEdit:x}):e.jsx(Mt,{notes:n,isPending:r,isError:p,onRetry:u})}function Wt({section:t,onEdit:n,onDelete:r,dragHandle:p}){const u=Ee(),x=Le(),[b,g]=i.useState(!1),F=pt(t),{data:T,isPending:q,isError:j,refetch:m}=ee({queryKey:E.views.sectionNotes(t.id,{limit:t.limit,offset:0}),async queryFn(){const h=await xt(t.id,{limit:t.limit,offset:0});if(h.type==="error")throw h;return h.viewSectionNotes}}),D=T?.notes??[],W=T?.totalCount??0,A=ht(t.mode),L=t.tagNames.length>0||t.propertyFilters.length>0,H=async h=>{if(b)return;const z=t.sortBy===h?t.sortOrder==="asc"?"desc":"asc":h==="title"?"asc":"desc";g(!0);const S=await Me(t.id,bt(t,{sortBy:h,sortOrder:z}));if(S.type==="error"){x(S.errors[0]?.message??"Failed to update table sort."),g(!1);return}await u.invalidateQueries({queryKey:E.views.all(),exact:!1}),g(!1)};return e.jsxs(K,{className:"flex h-full flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[p&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:p}),e.jsx("div",{className:"min-w-0",children:e.jsx(l,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx(oe,{to:ce,search:F,className:"truncate hover:text-fg-default/85",children:t.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:Ie(t.displayType)}),t.tagNames.map((h,z)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[z>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:A}),e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:h})]},h)),t.propertyFilters.map(h=>e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:gt(h)},`${h.key}-${h.operator}-${h.value??""}`)),!L&&e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx("div",{className:"shrink-0",children:e.jsx(De,{button:e.jsx(Ae,{label:"Section actions"}),items:[{name:"Edit section",onClick:n},{type:"separator"},{name:"Delete section",onClick:r}]})})]}),e.jsx("div",{className:"flex flex-1 flex-col gap-2.5",children:e.jsx(_t,{section:t,notes:D,isPending:q,isError:j,onRetry:()=>{m()},onEdit:n,onSortChange:H,isSortPending:b})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle/70 pt-4",children:[e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:q?"Loading notes...":`Showing ${D.length} of ${W} notes`}),e.jsx(N,{asChild:!0,variant:"subtle",size:"sm",children:e.jsx(oe,{to:ce,search:F,children:"Open results"})})]})]})}const ie="__choose_property__",Ht=["title","tags","properties","createdAt","updatedAt"],ve=t=>String(t?.limit??5),ye=t=>t?.displayType==="table"?"table":"list",je=t=>Pe(t?.displayOptions?.tableColumns??jt),we=t=>t?.mode??"and",Ne=t=>t?t.tagNames.join(", "):"",Te=t=>t?.title??"",Se=t=>t?.sortBy??"updatedAt",Ce=t=>t?.sortOrder??"desc",We=t=>`property-filter-${Date.now()}-${t}`,ke=t=>(t?.propertyFilters??[]).map((n,r)=>({id:We(r),key:n.key,operator:n.operator,value:n.value??""})),Ve=t=>t?t.valueType==="date"||t.valueType==="number"?["equals","notEquals","before","after","exists","notExists"]:t.valueType==="text"||t.valueType==="url"?["equals","notEquals","contains","notContains","exists","notExists"]:["equals","notEquals","exists","notExists"]:["exists","notExists"],Fe=t=>t?"equals":"exists",$t=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",le=t=>t!=="exists"&&t!=="notExists",He=t=>t==="contains"||t==="notContains",Kt=(t,n)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!He(n)?"url":"text",Ut=(t,n)=>{if(t.valueType==="url")return He(n)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function Bt({open:t,mode:n,initialSection:r=null,availableTags:p,availableProperties:u,isTagsLoading:x=!1,isPropertiesLoading:b=!1,onClose:g,onSubmit:F}){const[T,q]=i.useState(Te(r)),[j,m]=i.useState(ye(r)),[D,W]=i.useState(je(r)),[A,L]=i.useState(Ne(r)),[H,h]=i.useState(we(r)),[z,S]=i.useState(Se(r)),[C,Y]=i.useState(Ce(r)),[U,G]=i.useState(ve(r)),[O,$]=i.useState(ke(r)),[se,B]=i.useState((r?.tagNames.length??0)>0),[Q,s]=i.useState(""),d=i.useMemo(()=>new Map(u.map(a=>[a.key,a])),[u]);i.useEffect(()=>{t&&(q(Te(r)),m(ye(r)),W(je(r)),L(Ne(r)),h(we(r)),S(Se(r)),Y(Ce(r)),G(ve(r)),$(ke(r)),B((r?.tagNames.length??0)>0),s(""))},[r,t]);const y=be([A]),w=se||y.length>0,I=y.length===0&&O.length===0,M=a=>{a!=="title"&&(W(c=>{if(c.includes(a)){const k=c.filter(o=>o!==a);return k.length>0?k:c}return Pe([...c,a])}),s(""))},$e=a=>{const c=y.includes(a)?y.filter(k=>k!==a):[...y,a];L(c.join(", ")),s("")},Ke=()=>{B(!0),s("")},Ue=()=>{L(""),h("and"),B(!1),s("")},Be=()=>{if(u.length===0){s("Create a shared property before adding a filter.");return}$(a=>[...a,{id:We(a.length),key:"",operator:"exists",value:""}]),s("")},Z=(a,c)=>{$(k=>k.map(o=>{if(o.id!==a)return o;const P={...o,...c},f=d.get(P.key);return Ve(f).includes(P.operator)||(P.operator=Fe(f)),"key"in c&&(P.value=$t(f),P.operator=Fe(f)),P})),s("")},Qe=a=>{$(c=>c.filter(k=>k.id!==a)),s("")};return e.jsxs(R,{isOpen:t,onClose:g,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(R.Header,{title:n==="create"?"Create view":"Edit view",onClose:g}),e.jsx(R.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:a=>{a.preventDefault();const c=be([A]);if(w&&c.length===0){s("Choose at least one tag, or remove this tag filter.");return}if(O.find(f=>!f.key||!d.has(f.key))){s("Choose a property for every filter.");return}const o=O.map(f=>{const ae=d.get(f.key);return{key:ae?.key??f.key,valueType:ae?.valueType??"text",operator:f.operator,value:le(f.operator)?f.value:null}});if(o.some(f=>le(f.operator)&&!f.value?.trim())){s("Fill every filter value, or switch it to is set / is empty.");return}F({title:T,displayType:j,displayOptions:vt({tableColumns:D}),tagNames:c,mode:H,propertyFilters:o,sortBy:z,sortOrder:C,limit:Number(U)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-title",size:"md",children:"View name"}),e.jsx(de,{id:"view-section-title",value:T,onChange:a=>q(a.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(V,{size:"md",children:"Display"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same query as a compact list or a table."})]}),e.jsx(l,{as:"span",variant:"meta",tone:"tertiary",children:Ie(j)})]}),e.jsxs(ue,{type:"single",value:j,onValueChange:a=>{(a==="list"||a==="table")&&m(a)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(J,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(J,{value:"table","aria-label":"Show as table",children:"Table"})]}),j==="table"?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/45 p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(V,{size:"sm",children:"Table columns"}),e.jsxs(l,{as:"span",variant:"meta",tone:"tertiary",children:[D.length," shown"]})]}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:Ht.map(a=>{const c=yt(a);return e.jsxs("div",{className:"flex items-center gap-2 rounded-[12px] border border-border-subtle bg-elevated px-3 py-2",children:[e.jsx(Je,{size:"sm",checked:D.includes(a),disabled:a==="title","aria-label":`Show ${c} column`,onChange:()=>M(a)}),e.jsx(l,{as:"span",variant:"label",tone:"secondary",children:c})]},a)})}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."})]}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 rounded-[20px] border border-border-subtle bg-subtle/40 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(V,{size:"md",children:"Filters"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Use properties for structured fields, and tags for loose topics or context."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{type:"button",variant:"subtle",size:"sm",onClick:Be,children:"Add property filter"}),!w&&e.jsx(N,{type:"button",variant:"subtle",size:"sm",onClick:Ke,children:"Add tag filter"})]})]}),O.length===0&&!w?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(l,{as:"p",variant:"label",tone:"default",children:I?"All notes":"No filters"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add a property filter, a tag filter, or leave this view open to all notes."})]}):null,O.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:O.map(a=>{const c=d.get(a.key),k=Ve(c);return e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-border-subtle bg-elevated p-3 md:grid-cols-[minmax(0,1fr)_minmax(10.5rem,12rem)_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs(_,{value:a.key||ie,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:o=>{o!==ie&&Z(a.id,{key:o})},children:[e.jsx(v,{value:ie,disabled:!0,children:"Choose property"}),u.map(o=>e.jsx(v,{value:o.key,children:o.name},o.key))]}),e.jsx(_,{value:a.operator,disabled:!c,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:o=>Z(a.id,{operator:o}),children:k.map(o=>e.jsx(v,{value:o,children:ft(o)},o))}),le(a.operator)&&c?c.valueType==="select"?e.jsx(_,{value:a.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:o=>Z(a.id,{value:o}),children:c.options.map(o=>e.jsx(v,{value:o.value,children:o.label},o.value))}):c.valueType==="boolean"?e.jsxs(_,{value:a.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:o=>Z(a.id,{value:o}),children:[e.jsx(v,{value:"true",children:"True"}),e.jsx(v,{value:"false",children:"False"})]}):e.jsx(de,{type:Kt(c,a.operator),value:a.value,onChange:o=>Z(a.id,{value:o.target.value}),placeholder:Ut(c,a.operator),"aria-label":"Property filter value"}):e.jsx(l,{as:"span",variant:"label",tone:"tertiary",children:c?"No value needed":"Choose a property first"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>Qe(a.id),children:"Remove"})]},a.id)})}):null,w?e.jsxs("div",{className:"flex flex-col gap-3 rounded-[16px] border border-border-subtle bg-elevated p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(l,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:Ue,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(Xe,{id:"view-section-tags",value:A,onChange:a=>{L(a.target.value),s("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"You can use tags only, properties only, both together, or no filters."})]}),y.length>1?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{size:"sm",children:"Tag match"}),e.jsxs(ue,{type:"single",value:H,onValueChange:a=>{(a==="and"||a==="or")&&h(a)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(J,{value:"and","aria-label":fe("and"),children:"AND"}),e.jsx(J,{value:"or","aria-label":fe("or"),children:"OR"})]}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"AND requires every selected tag. OR accepts any selected tag."})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(V,{size:"sm",children:"Existing tags"}),e.jsx(l,{as:"span",variant:"meta",tone:"tertiary",children:x?"Loading...":`${p.length} available`})]}),p.length>0?e.jsx("div",{className:"max-h-44 overflow-y-auto rounded-[16px] border border-border-subtle bg-hover-subtle/60 p-3",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(a=>{const c=y.includes(a.name);return e.jsx("button",{type:"button",className:`inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${c?"border-border-secondary bg-elevated text-fg-default":"border-border-subtle bg-transparent text-fg-secondary hover:border-border-secondary hover:bg-elevated hover:text-fg-default"}`,onClick:()=>$e(a.name),children:a.name},a.id)})})}):e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(l,{as:"p",variant:"meta",tone:Q?"default":"tertiary",className:Q?"text-fg-error":void 0,children:Q||(b||x?"Loading filter options...":`${u.length} properties · ${p.length} tags available`)})]}),e.jsxs("details",{className:"group rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(l,{as:"span",variant:"label",tone:"default",children:"Sort and limit"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Defaults to recently updated notes."})]}),e.jsxs(l,{as:"span",variant:"meta",tone:"tertiary",children:[U," notes"]})]})}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(_,{value:z,onValueChange:a=>S(a),children:[e.jsx(v,{value:"updatedAt",children:"Updated time"}),e.jsx(v,{value:"createdAt",children:"Created time"}),e.jsx(v,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(_,{value:C,onValueChange:a=>Y(a),children:[e.jsx(v,{value:"desc",children:"Descending"}),e.jsx(v,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-limit",size:"sm",children:"Max notes"}),e.jsxs(_,{value:U,onValueChange:G,children:[e.jsx(v,{value:"3",children:"3 notes"}),e.jsx(v,{value:"5",children:"5 notes"}),e.jsx(v,{value:"8",children:"8 notes"}),e.jsx(v,{value:"10",children:"10 notes"}),e.jsx(v,{value:"12",children:"12 notes"})]})]})]})]})]})}),e.jsx(R.Footer,{children:e.jsxs(ze,{children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:g,children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",form:"view-section-form",children:n==="create"?"Create view":"Save view"})]})})]})}function Qt({open:t,mode:n,initialTitle:r="",onClose:p,onSubmit:u}){const[x,b]=i.useState(r);return i.useEffect(()=>{t&&b(r)},[r,t]),e.jsxs(R,{isOpen:t,onClose:p,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(R.Header,{title:n==="create"?"Create view tab":"Rename view tab",onClose:p}),e.jsx(R.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:g=>{g.preventDefault(),u(x)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(de,{id:"view-tab-title",value:x,onChange:g=>b(g.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(R.Footer,{children:e.jsxs(ze,{children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:p,children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",form:"view-tab-form",children:n==="create"?"Create tab":"Save tab"})]})})]})}const Zt="Save reusable note queries with tags, shared properties, and sorting.",Yt="focus-ring-soft inline-flex h-8 w-8 items-center justify-center rounded-[10px] text-fg-default/70 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default touch-none",Gt="group relative -mb-px flex h-10 min-w-[92px] max-w-[118px] shrink-0 items-center gap-0.5 rounded-t-[12px] border border-b-0 px-1.5 transition-[background-color,border-color,color,box-shadow]",Jt="focus-ring-soft inline-flex min-w-0 flex-1 items-center gap-1 rounded-[9px] px-0.5 py-1.5 text-[13px] font-medium outline-none",Xt="focus-ring-soft inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[8px] text-current/55 outline-none transition-[background-color,color,opacity] hover:bg-hover-subtle hover:text-current touch-none",es="focus-ring-soft relative mb-0.5 inline-flex h-9 shrink-0 items-center gap-1 rounded-[10px] px-2.5 text-[13px] font-medium text-fg-secondary outline-none transition-colors hover:bg-hover-subtle/85 hover:text-fg-default",ts=({tab:t,isActive:n,onSelect:r})=>{const{attributes:p,listeners:u,setNodeRef:x,setActivatorNodeRef:b,transform:g,transition:F,isDragging:T}=Oe({id:t.id});return e.jsxs("div",{ref:x,style:{transform:qe.Translate.toString(g),transition:F,opacity:T?.6:1},className:te(Gt,n?"z-10 border-border-secondary/75 bg-elevated text-fg-default shadow-[0_10px_18px_-20px_rgba(15,18,24,0.24)]":"border-transparent bg-hover-subtle/45 text-fg-secondary hover:bg-hover-subtle/75 hover:text-fg-default"),children:[e.jsx("button",{type:"button",ref:b,"aria-label":`Reorder view tab ${t.title}`,...p,...u,className:te(Xt,T?"cursor-grabbing opacity-100":"cursor-grab opacity-70 group-hover:opacity-100"),children:e.jsx(Re,{className:"size-4"})}),e.jsxs("button",{type:"button",role:"tab","aria-selected":n,className:te(Jt,n?"text-fg-default":"text-fg-secondary group-hover:text-fg-default"),onClick:r,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.title}),e.jsx("span",{className:"inline-flex min-w-4 shrink-0 items-center justify-center rounded-full bg-hover-subtle/75 px-1 py-0 text-[10px] leading-4 text-current/70",children:t.sections.length})]})]})},ss=({section:t,onEdit:n,onDelete:r})=>{const{attributes:p,listeners:u,setNodeRef:x,setActivatorNodeRef:b,transform:g,transition:F,isDragging:T}=Oe({id:t.id});return e.jsx("div",{ref:x,style:{transform:qe.Translate.toString(g),transition:F,opacity:T?.6:1},children:e.jsx(Wt,{section:t,onEdit:n,onDelete:r,dragHandle:e.jsx("button",{type:"button",ref:b,"aria-label":`Reorder section ${t.title}`,...p,...u,className:te(Yt,T?"cursor-grabbing":"cursor-grab"),children:e.jsx(Re,{className:"size-4"})})})})};function cs(){const t=et(),n=Le(),r=Ee(),[p,u]=i.useState(null),[x,b]=i.useState(null),{data:g,isPending:F,isError:T,refetch:q}=ee({queryKey:E.views.workspace(),async queryFn(){const s=await wt();if(s.type==="error")throw s;return s.viewWorkspace}}),j=g??Tt,m=Nt(j),{data:D,isPending:W}=ee({queryKey:E.tags.list({limit:200}),async queryFn(){const s=await tt({limit:200});if(s.type==="error")throw s;return s.allTags}}),A=st(me(nt,{activationConstraint:{distance:8}}),me(rt,{coordinateGetter:at})),L=D?.tags??[],{data:H,isPending:h}=ee({queryKey:E.notes.propertyKeys({limit:100}),async queryFn(){const s=await it({limit:100});if(s.type==="error")throw s;return s.notePropertyKeys}}),z=H?.keys??[],S=s=>{r.setQueryData(E.views.workspace(),s)},C=async()=>{await r.invalidateQueries({queryKey:E.views.all(),exact:!1})},Y=async({active:s,over:d})=>{if(!d||s.id===d.id)return;const y=r.getQueryData(E.views.workspace())??j,w=kt(y,String(s.id),String(d.id));S(w);const I=await Vt(w.tabs.map(M=>M.id));if(I.type==="error"){S(y),n(I.errors[0].message);return}await C()},U=async({active:s,over:d})=>{if(!m||!d||s.id===d.id)return;const y=r.getQueryData(E.views.workspace())??j,w=Ft(y,m.id,String(s.id),String(d.id));S(w);const I=await Et(m.id,w.tabs.find(M=>M.id===m.id)?.sections.map(M=>M.id)??[]);if(I.type==="error"){S(y),n(I.errors[0].message);return}await C()},G=async s=>{const d=await Dt(s);if(d.type==="error"){n(d.errors[0].message);return}await C(),u(null)},O=async s=>{if(!m)return;const d=await At(m.id,s);if(d.type==="error"){n(d.errors[0].message);return}await C(),u(null)},$=async()=>{if(!m||!await t("Delete this view tab and all of its sections?"))return;const s=await Lt(m.id);if(s.type==="error"){n(s.errors[0].message);return}await C()},se=async s=>{if(!m)return;const d=await zt(m.id,s);if(d.type==="error"){n(d.errors[0].message);return}await C(),b(null)},B=async s=>{if(!m||!x||x.mode!=="edit")return;const d=await Me(x.section.id,s);if(d.type==="error"){n(d.errors[0].message);return}await C(),b(null)},Q=async s=>{if(!m||!await t("Delete this section from the current view tab?"))return;const d=await Ot(s);if(d.type==="error"){n(d.errors[0].message);return}await C()};return e.jsxs(e.Fragment,{children:[e.jsx(lt,{title:"Views",description:Zt,children:F&&!g?e.jsx(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(re,{height:20,width:180,className:"rounded-full"}),e.jsx(re,{height:16,width:260,className:"rounded-full"}),e.jsx(re,{height:44,width:140,className:"rounded-[12px]"})]})}):T?e.jsxs(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry loading your saved view tabs."}),e.jsx("div",{className:"mt-4",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{q()},children:"Retry"})})]}):j.tabs.length===0?e.jsxs(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(pe,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both."}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsxs(N,{type:"button",onClick:()=>u({mode:"create"}),children:[e.jsx(ne,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"border-b border-border-secondary/75",children:e.jsx(xe,{sensors:A,collisionDetection:he,modifiers:[ot],onDragEnd:Y,children:e.jsxs("div",{className:"flex items-end gap-1 overflow-x-auto overflow-y-hidden pb-px",children:[e.jsx(ge,{items:j.tabs.map(s=>s.id),strategy:dt,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 items-end gap-1",children:j.tabs.map(s=>e.jsx(ts,{tab:s,isActive:s.id===m?.id,onSelect:async()=>{const d=r.getQueryData(E.views.workspace())??j,y=St(d,s.id);S(y);const w=await Ct(s.id);if(w.type==="error"){S(d),n(w.errors[0].message);return}S(w.setActiveViewTab)}},s.id))})}),e.jsxs("button",{type:"button",className:es,onClick:()=>u({mode:"create"}),children:[e.jsx(ne,{className:"size-4"}),"Add tab"]})]})})}),m&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs(K,{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{as:"h2",variant:"heading",weight:"bold",tracking:"tight",children:m.title}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:m.sections.length>0?`${m.sections.length} section${m.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs(N,{type:"button",size:"sm",onClick:()=>b({mode:"create"}),children:[e.jsx(ne,{className:"h-4 w-4"}),"Add section"]}),e.jsx(De,{button:e.jsx(Ae,{label:"View tab actions"}),items:[{name:"Rename",onClick:()=>u({mode:"edit",tab:m})},{type:"separator"},{name:"Delete tab",onClick:()=>{$()}}]})]})]}),m.sections.length===0?e.jsx(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsx(pe,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both."})}):e.jsx("div",{className:"flex flex-col",children:e.jsx(xe,{sensors:A,collisionDetection:he,modifiers:[ct],onDragEnd:U,children:e.jsx(ge,{items:m.sections.map(s=>s.id),strategy:ut,children:e.jsx("div",{className:"flex flex-col gap-4",children:m.sections.map(s=>e.jsx(ss,{section:s,onEdit:()=>b({mode:"edit",section:s}),onDelete:()=>{Q(s.id)}},s.id))})})})})]})]})}),e.jsx(Qt,{open:p!==null,mode:p?.mode??"create",initialTitle:p?.mode==="edit"?p.tab.title:"",onClose:()=>u(null),onSubmit:s=>{if(p?.mode==="edit"){O(s);return}G(s)}}),e.jsx(Bt,{open:x!==null,mode:x?.mode??"create",initialSection:x?.mode==="edit"?x.section:null,availableTags:L,availableProperties:z,isTagsLoading:W,isPropertiesLoading:h,onClose:()=>b(null),onSubmit:s=>{if(x?.mode==="edit"){B(s);return}se(s)}})]})}export{cs as default};
@@ -1,4 +1,4 @@
1
- import{aR as n,h as i}from"./index-_nFnTWJM.js";async function r({base64:a,externalSrc:e}){if(a){const{data:t}=await n.post("/api/image",{image:a});return t.url}if(e){const{data:t}=await n.post("/api/image-from-src",{src:e});return t.url}throw new Error("No file or src provided")}function u({limit:a=50,offset:e=0}={}){return i(`query FetchImages($pagination: PaginationInput) {
1
+ import{aR as n,h as i}from"./index-BFfQKAUY.js";async function r({base64:a,externalSrc:e}){if(a){const{data:t}=await n.post("/api/image",{image:a});return t.url}if(e){const{data:t}=await n.post("/api/image-from-src",{src:e});return t.url}throw new Error("No file or src provided")}function u({limit:a=50,offset:e=0}={}){return i(`query FetchImages($pagination: PaginationInput) {
2
2
  allImages(pagination: $pagination) {
3
3
  totalCount
4
4
  images {