ocean-brain 0.12.0 → 0.12.1
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/README.md +1 -1
- package/package.json +4 -2
- package/server/client/dist/assets/Calendar-CBYfyLwm.js +25 -0
- package/server/client/dist/assets/{Search-BxozUWkC.js → Search-D0yR4DTH.js} +1 -1
- package/server/client/dist/assets/{Tag-BhCf_mil.js → Tag-B8UYGbt9.js} +1 -1
- package/server/client/dist/assets/{TagNotes-BIzhXqwp.js → TagNotes-CDVHz74G.js} +1 -1
- package/server/client/dist/assets/{Views-C26uWznP.js → Views-Cjdbbut-.js} +1 -1
- package/server/client/dist/assets/{app-DbQdHfMb.js → app-Clwvoiwx.js} +2 -2
- package/server/client/dist/assets/app-DGFNtdpS.css +1 -0
- package/server/client/dist/assets/{index-8bsOoxxg.js → index-PjoL3frH.js} +1 -1
- package/server/client/dist/assets/{manage-image-detail-CPpeRZD4.js → manage-image-detail-CLPXVSZf.js} +1 -1
- package/server/client/dist/assets/{placeholder-CHRQt_T8.js → placeholder-D4Lkz_or.js} +1 -1
- package/server/client/dist/assets/{search-DCLnUWYd.js → search-BlbdHNDA.js} +1 -1
- package/server/client/dist/index.html +2 -2
- package/server/dist/app.js +5 -5
- package/server/dist/features/search/sqlite-vector-index.js +71 -138
- package/server/dist/main.js +1 -35
- package/server/dist/routes/api.js +6 -1
- package/server/dist/routes/client.js +15 -4
- package/server/dist/server.js +40 -0
- package/server/client/dist/assets/Calendar-BLiViCGr.js +0 -25
- package/server/client/dist/assets/app-CEkicO08.css +0 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ For the product overview and screenshots, see the [Ocean Brain project](https://
|
|
|
16
16
|
|
|
17
17
|
## Requirements
|
|
18
18
|
|
|
19
|
-
Use Node.js 22. A global installation is not required; the examples below use `npx`.
|
|
19
|
+
Use Node.js 22.13+ or a newer LTS release. A global installation is not required; the examples below use `npx`.
|
|
20
20
|
|
|
21
21
|
## `serve`
|
|
22
22
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ocean-brain",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "^22.13.0 || >=24.0.0"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/baealex/ocean-brain"
|
|
@@ -39,7 +42,6 @@
|
|
|
39
42
|
"jsdom": "^25.0.1",
|
|
40
43
|
"lusca": "^1.7.0",
|
|
41
44
|
"prisma": "^6.19.3",
|
|
42
|
-
"sqlite3": "^6.0.1",
|
|
43
45
|
"sqlite-vec": "0.1.9",
|
|
44
46
|
"winston": "^3.19.0",
|
|
45
47
|
"zod": "^3.25.76"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{r as i,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{C as de,T as p,c as D,m as j,F as me,y as he,z as F,B as C,R as xe,a2 as pe,M as k,q as P,g as J,P as ue,h as ge}from"./time-DZKkPFUi.js";import{N as ye,C as fe}from"./url-BvjSC8PU.js";import{e as X}from"./app-Clwvoiwx.js";import{s as V,a as L}from"./useNoteMutate-VJYw0Vt_.js";import{C as be}from"./Callout-Cye6_6BM.js";import"./preload-helper-BXl3LOEh.js";import"./sortable.esm-DgSW3bAA.js";const je=new Map([["bold",i.createElement(i.Fragment,null,i.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Zm112-80a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,132Zm0,40a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,172Z"}))],["duotone",i.createElement(i.Fragment,null,i.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),i.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z"}))],["fill",i.createElement(i.Fragment,null,i.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,176H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm-8-56V44l44,44Z"}))],["light",i.createElement(i.Fragment,null,i.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Zm-34-82a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,136Zm0,32a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,168Z"}))],["regular",i.createElement(i.Fragment,null,i.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z"}))],["thin",i.createElement(i.Fragment,null,i.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Zm-36-84a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,136Zm0,32a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,168Z"}))]]),G=i.forwardRef((t,a)=>i.createElement(de,{ref:a,...t,weights:je}));G.displayName="FileTextIcon";const T=G,z="bg-surface shadow-[inset_0_0_0_1px_var(--border-subtle)]",K="bg-emphasis",U=(t,a)=>`${t} ${t===1?a:`${a}s`}`,Ne=({day:t,dateLabel:a,cellClassName:s,dayNumberClassName:c,isCurrentMonth:d,isToday:x,isSelected:m,noteCount:l,reminderCount:o,previewItems:u,overflowCount:n,onSelect:g})=>{const N=l+o,A=`${a}, ${U(l,"note")}, ${U(o,"reminder")}`;return e.jsxs("button",{type:"button",disabled:!d,"aria-label":A,"aria-pressed":d?m:void 0,"aria-current":d&&x?"date":void 0,onClick:g,className:D("focus-ring-soft relative flex min-h-16 min-w-0 flex-col p-1.5 text-left outline-none transition-colors focus-visible:z-10 sm:min-h-24 sm:p-2 lg:min-h-36 lg:p-2.5",s),children:[e.jsx(p,{as:"span",variant:"label",className:D("flex h-6 min-w-6 items-center justify-center self-end whitespace-nowrap rounded-[9px] px-1.5 sm:h-7 sm:min-w-7 lg:!text-sm",c),children:t}),d&&N>0?e.jsxs("div",{"aria-hidden":"true",className:"mt-1.5 w-full sm:mt-2",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 text-fg-tertiary sm:hidden",children:[l>0?e.jsxs("span",{className:"flex items-center justify-between leading-none",children:[e.jsx(T,{className:"shrink-0",size:10}),e.jsx("span",{className:"whitespace-nowrap text-[10px] font-semibold text-fg-secondary tabular-nums",children:l})]}):null,o>0?e.jsxs("span",{className:"flex items-center justify-between leading-none",children:[e.jsx(V,{className:"shrink-0",size:10}),e.jsx("span",{className:"whitespace-nowrap text-[10px] font-semibold text-fg-secondary tabular-nums",children:o})]}):null]}),e.jsxs("div",{className:"hidden flex-col gap-1 sm:flex 2xl:hidden",children:[l>0?e.jsxs("span",{className:D("flex min-h-7 min-w-0 items-center justify-between gap-1 rounded-[8px] px-2 py-1.5 text-fg-tertiary",z),children:[e.jsx(p,{as:"span",variant:"micro",weight:"medium",tone:"secondary",className:"truncate !text-[11px] !leading-4",children:"Notes"}),e.jsx(p,{as:"span",variant:"micro",weight:"semibold",tone:"secondary",className:"!text-[11px] !leading-4 tabular-nums",children:l})]}):null,o>0?e.jsxs("span",{className:D("flex min-h-7 min-w-0 items-center justify-between gap-1 rounded-[8px] px-2 py-1.5 text-fg-tertiary",K),children:[e.jsx(p,{as:"span",variant:"micro",weight:"medium",tone:"secondary",className:"truncate !text-[11px] !leading-4",children:"Reminders"}),e.jsx(p,{as:"span",variant:"micro",weight:"semibold",tone:"secondary",className:"!text-[11px] !leading-4 tabular-nums",children:o})]}):null]}),e.jsxs("div",{className:"hidden flex-col gap-1 2xl:flex",children:[u.map(v=>e.jsxs("span",{className:D("flex min-h-8 min-w-0 items-center gap-1.5 rounded-[8px] px-2 py-1.5",v.type==="reminder"?K:z),children:[v.type==="reminder"?e.jsx(V,{className:"shrink-0 text-fg-tertiary",size:12}):e.jsx(T,{className:"shrink-0 text-fg-tertiary",size:12}),e.jsx(p,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:D("truncate",v.isCompleted&&"line-through"),children:v.title})]},v.key)),n>0?e.jsxs(p,{as:"span",variant:"micro",weight:"medium",tone:"secondary",className:"flex min-h-4 items-center px-2 !text-[11px] !leading-4",children:["+",n," more"]}):null]})]}):null]})},H=2,ve=({year:t,month:a,day:s,isCurrentMonth:c,isSunday:d,isToday:x,isSelected:m,isPast:l,notes:o,reminders:u,onSelect:n})=>{const g=o.slice(0,H).map(w=>({key:`note-${w.id}`,type:"note",title:w.title})),N=u.slice(0,H).map(w=>({key:`reminder-${w.id}`,type:"reminder",title:w.content||w.note?.title||"No title",isCompleted:w.completed})),A=(l?[...g,...N]:[...N,...g]).slice(0,H),v=()=>c?m?"bg-elevated shadow-[inset_0_0_0_1px_var(--border-secondary)] hover:bg-surface":"bg-surface hover:bg-muted":"cursor-default bg-[var(--page-bg)] text-fg-disabled",S=()=>x?"bg-cta font-semibold text-fg-on-filled":c?d?"font-semibold text-fg-weekend":"font-semibold text-fg-secondary":"font-medium text-fg-tertiary";return e.jsx(Ne,{day:s,dateLabel:j(new Date(t,a-1,s)).format("dddd, MMMM D, YYYY"),cellClassName:v(),dayNumberClassName:S(),isCurrentMonth:c,isToday:x,isSelected:m,noteCount:o.length,reminderCount:u.length,previewItems:A,overflowCount:Math.max(0,o.length+u.length-H),onSelect:n})},we=ve,ee=({params:t,toneClassName:a="",header:s,title:c,meta:d,titleClassName:x=""})=>e.jsx(me,{to:ye,params:t,className:"focus-ring-soft group block rounded-[8px] outline-none",children:e.jsxs("div",{className:D("flex items-start gap-1.5 rounded-[8px] px-1.5 py-1 transition-colors group-hover:bg-muted",a),children:[s?e.jsx("span",{className:"mt-[2px] flex h-4 w-4 shrink-0 items-center justify-center text-fg-tertiary",children:s}):e.jsx("span",{"aria-hidden":"true",className:"mt-[6px] h-1.5 w-1.5 shrink-0 rounded-full bg-fg-placeholder"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(p,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:D("line-clamp-1",x),children:c}),d?e.jsx(p,{as:"div",variant:"micro",weight:"medium",tone:"secondary",className:"mt-0.5 !text-[11px] !leading-4",children:d}):null]})]})}),Me=({note:t,type:a})=>e.jsx(ee,{params:{id:t.id},header:e.jsx(T,{size:12}),title:t.title,meta:j(Number(a==="create"?t.createdAt:t.updatedAt)).format("HH:mm")}),De=({reminder:t})=>e.jsx(ee,{params:{id:String(t.note?.id??t.noteId)},header:e.jsx(V,{size:12}),title:t.content||t.note?.title||"No title",titleClassName:t.completed?"line-through":"",meta:j(Number(t.reminderDate)).format("HH:mm")}),Ee=(t,a)=>t.map(s=>s.type==="note"?e.jsx(Me,{note:s.item,type:a},`note-${s.item.id}`):e.jsx(De,{reminder:s.item},`reminder-${s.item.id}`)),q=(t,a)=>`${t} ${t===1?a:`${a}s`}`,Ae="mt-3 flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overscroll-y-contain pr-2 [scrollbar-color:var(--border-secondary)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-border-secondary [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar]:w-1.5",te=t=>j(new Date(t.year,t.month-1,t.day)).format("dddd, MMMM D"),Q=({day:t,type:a,isLoading:s,presentation:c="rail"})=>{const d=i.useMemo(()=>{if(!t)return[];const o=t.notes.map(n=>({type:"note",item:n})),u=t.reminders.map(n=>({type:"reminder",item:n}));return t.isPast?[...o,...u]:[...u,...o]},[t]);if(!t)return e.jsx("section",{"aria-label":"Day details",className:"flex h-full min-h-40 items-center justify-center text-center",children:e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Select a day to see its activity."})});const x=te(t),m=s?"Loading activity...":[q(t.notes.length,"note"),q(t.reminders.length,"reminder")].join(" · "),l=s?null:e.jsx("div",{className:c==="rail"?Ae:"flex flex-col gap-1",children:d.length>0?Ee(d,a):e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"py-8 text-center",children:"No activity on this day."})});return c==="modal"?e.jsxs("div",{"aria-label":`${x} activity`,children:[e.jsx(p,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mb-3",children:m}),l]}):e.jsxs("section",{"aria-label":`${x} details`,className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex shrink-0 items-start gap-2 border-b border-border-subtle/80 pb-3",children:[e.jsx(X,{"aria-hidden":"true",className:"mt-0.5 shrink-0 text-fg-tertiary",size:15}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(p,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",children:x}),e.jsx(p,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mt-0.5",children:m})]})]}),l]})},$e=["January","February","March","April","May","June","July","August","September","October","November","December"],Re=({month:t,year:a,type:s,onPrevMonth:c,onNextMonth:d,onToday:x,onTypeChange:m})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(p,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:$e[t-1]}),e.jsx(p,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:a})]}),e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"hidden sm:block",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:inline-flex sm:w-auto sm:flex-row sm:items-center sm:gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(p,{id:"calendar-note-date-label",as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Note date"}),e.jsxs(he,{value:s,"aria-labelledby":"calendar-note-date-label",onValueChange:o=>m(o),variant:"ghost",size:"sm",children:[e.jsx(F,{value:"create",children:"Created"}),e.jsx(F,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"hidden h-5 w-px bg-divider sm:block"}),e.jsxs("div",{className:"flex items-center justify-between sm:justify-start sm:gap-1.5",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:x,children:"Today"}),e.jsxs("div",{className:"flex items-center gap-1",role:"group","aria-label":"Month navigation",children:[e.jsx(C,{variant:"ghost",size:"icon-sm","aria-label":"Previous month",onClick:c,children:e.jsx(xe,{width:18,height:18})}),e.jsx(C,{variant:"ghost",size:"icon-sm","aria-label":"Next month",onClick:d,children:e.jsx(pe,{width:18,height:18})})]})]})]})})]}),ke=["SUN","MON","TUE","WED","THU","FRI","SAT"],W="(min-width: 1280px)",He=({days:t,type:a,isLoading:s,selectedDayKey:c,onSelectedDayChange:d})=>{const[x,m]=i.useState(!1),l=i.useMemo(()=>t.find(n=>n.key===c),[t,c]);i.useEffect(()=>{const n=window.matchMedia(W),g=N=>{N.matches&&m(!1)};return n.addEventListener("change",g),()=>n.removeEventListener("change",g)},[]);const o=n=>{d(n),window.matchMedia(W).matches||m(!0)},u=l?te(l):"Day details";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 xl:grid xl:grid-cols-[minmax(0,1fr)_20rem] 2xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx("section",{"aria-label":"Month overview","aria-busy":s,className:"min-w-0 xl:pr-5",children:e.jsx("div",{className:"overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.jsxs("div",{className:"min-w-[19rem]",children:[e.jsx("div",{className:"mb-2 grid grid-cols-7 gap-px",children:ke.map((n,g)=>e.jsxs(p,{as:"div",variant:"label",weight:"semibold",tracking:"wider",transform:"uppercase",className:`py-1.5 text-center ${g===0?"text-fg-weekend":"text-fg-secondary"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"sm:hidden",children:n.slice(0,1)}),e.jsx("span",{className:"hidden sm:inline",children:n})]},n))}),e.jsx("div",{className:"grid grid-cols-7 gap-px overflow-hidden rounded-[12px] border border-border-subtle/80 bg-border-subtle/70",children:t.map(n=>e.jsx(we,{year:n.year,month:n.month,day:n.day,isCurrentMonth:n.isCurrentMonth,isSunday:n.isSunday,isToday:n.isToday,isSelected:n.key===c,isPast:n.isPast,notes:n.notes,reminders:n.reminders,onSelect:()=>o(n.key)},n.key))})]})})}),e.jsx("aside",{className:"relative hidden min-h-0 border-l border-border-subtle xl:block","aria-label":"Selected day",children:e.jsx("div",{className:"absolute inset-y-0 right-0 left-5",children:e.jsx(Q,{day:l,type:a,isLoading:s})})})]}),e.jsxs(k,{isOpen:x&&!!l,onClose:()=>m(!1),variant:"inspect",className:"xl:hidden",children:[e.jsx(k.Header,{title:u,onClose:()=>m(!1)}),e.jsxs(k.Body,{children:[e.jsxs(k.Description,{className:"sr-only",children:["View notes and reminders for ",u,"."]}),e.jsx(Q,{day:l,type:a,isLoading:s,presentation:"modal"})]})]})]})},Se=`
|
|
2
|
+
query NotesInDateRange($dateRange: DateRangeInput) {
|
|
3
|
+
notesInDateRange(dateRange: $dateRange) {
|
|
4
|
+
id
|
|
5
|
+
title
|
|
6
|
+
createdAt
|
|
7
|
+
updatedAt
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`,Ce=`
|
|
11
|
+
query RemindersInDateRange($dateRange: DateRangeInput) {
|
|
12
|
+
remindersInDateRange(dateRange: $dateRange) {
|
|
13
|
+
id
|
|
14
|
+
noteId
|
|
15
|
+
reminderDate
|
|
16
|
+
completed
|
|
17
|
+
priority
|
|
18
|
+
content
|
|
19
|
+
note {
|
|
20
|
+
id
|
|
21
|
+
title
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`,Ve=async t=>{const a=await J(Se,{dateRange:t});if(a.type==="error")throw a;return a.notesInDateRange},Te=async t=>{const a=await J(Ce,{dateRange:t});if(a.type==="error")throw a;return a.remindersInDateRange},_e=({year:t,month:a})=>{const s=`${t}-${String(a).padStart(2,"0")}-01`,c=a===12?1:a+1,x=`${a===12?t+1:t}-${String(c).padStart(2,"0")}-01`,m={start:s,end:x},l=L({queryKey:P.calendar.notesInDateRange(t,a),queryFn:()=>Ve(m)}),o=L({queryKey:P.reminders.inDateRange(t,a),queryFn:()=>Te(m)});return{notes:l.data??[],reminders:o.data??[],isLoading:l.isLoading||o.isLoading,isError:l.isError||o.isError}},Ie=[],Ze=[],B=ge(fe);function qe(){const t=B.useNavigate(),{year:a,month:s,type:c}=B.useSearch(),d=`${a}-${s}`,[x,m]=i.useState(()=>({monthKey:d})),{notes:l,reminders:o,isLoading:u,isError:n}=_e({year:a,month:s}),g=i.useMemo(()=>{const h=j(),y=`${h.year()}-${h.month()+1}-${h.date()}`,f=new Map;for(const r of l){const M=c==="create"?j(Number(r.createdAt)):j(Number(r.updatedAt)),b=`${M.year()}-${M.month()+1}-${M.date()}`,E=f.get(b)||[];E.push(r),f.set(b,E)}const $=new Map;for(const r of o){const M=j(Number(r.reminderDate)),b=`${M.year()}-${M.month()+1}-${M.date()}`,E=$.get(b)||[];E.push(r),$.set(b,E)}const ne=new Date(a,s-1,1),re=new Date(a,s,0),_=ne.getDay(),I=re.getDate(),R=[],Z=s===1?12:s-1,O=s===1?a-1:a,ie=new Date(O,Z,0).getDate();for(let r=_-1;r>=0;r--)R.push({day:ie-r,isCurrentMonth:!1,year:O,month:Z});for(let r=1;r<=I;r++)R.push({day:r,isCurrentMonth:!0,year:a,month:s});const Y=(_+I)%7,le=Y===0?0:7-Y,oe=s===12?1:s+1,ce=s===12?a+1:a;for(let r=1;r<=le;r++)R.push({day:r,isCurrentMonth:!1,year:ce,month:oe});return R.map((r,M)=>{const b=`${r.year}-${r.month}-${r.day}`,E=j(`${r.year}-${String(r.month).padStart(2,"0")}-${String(r.day).padStart(2,"0")}`);return{key:b,year:r.year,month:r.month,day:r.day,isCurrentMonth:r.isCurrentMonth,isSunday:M%7===0,isToday:b===y,isPast:E.isBefore(h,"day"),notes:f.get(b)||Ie,reminders:$.get(b)||Ze}})},[a,s,l,o,c]),N=g.find(h=>h.isCurrentMonth&&h.isToday)?.key,A=x.monthKey===d?x.dayKey??N:N,v=()=>{const h=s===1?12:s-1,y=s===1?a-1:a;t({search:f=>({...f,month:h,year:y})})},S=()=>{const h=s===12?1:s+1,y=s===12?a+1:a;t({search:f=>({...f,month:h,year:y})})},w=()=>{const h=j(),y=h.month()+1,f=h.year();m({monthKey:`${f}-${y}`,dayKey:`${f}-${y}-${h.date()}`}),t({search:$=>({...$,month:y,year:f})})},ae=h=>{h&&t({search:y=>({...y,type:h})})},se=h=>{m({monthKey:d,dayKey:h})};return e.jsx(ue,{title:"Calendar",variant:"none",children:n?e.jsx(be,{children:"Failed to load calendar data. Please try again later."}):e.jsxs("div",{className:"-mr-4",children:[e.jsx("div",{className:"border-b border-border-subtle/80 pb-4",children:e.jsx(Re,{month:s,year:a,type:c,onPrevMonth:v,onNextMonth:S,onToday:w,onTypeChange:ae})}),e.jsx("div",{className:"pt-4",children:e.jsx(He,{days:g,type:c,isLoading:u,selectedDayKey:A,onSelectedDayChange:se})})]})})}export{qe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,r as g}from"./floating-ui.react-dom-BWTnA00G.js";import{a as L,m as Q}from"./useNoteMutate-VJYw0Vt_.js";import{g as q,y as G,z as V,c as X,G as J,B as Y,T as m,q as k,P as W,E as A,Q as Z,F as C,k as ee,h as te,l as w,i as re,s as se,N as ae}from"./time-DZKkPFUi.js";import{A as ne,p as ie}from"./AuxiliaryPanelHeader-Bp3iRjm6.js";import{N as P,f as oe,g as le,T as ce}from"./url-BvjSC8PU.js";import{f as de}from"./app-
|
|
1
|
+
import{j as e,r as g}from"./floating-ui.react-dom-BWTnA00G.js";import{a as L,m as Q}from"./useNoteMutate-VJYw0Vt_.js";import{g as q,y as G,z as V,c as X,G as J,B as Y,T as m,q as k,P as W,E as A,Q as Z,F as C,k as ee,h as te,l as w,i as re,s as se,N as ae}from"./time-DZKkPFUi.js";import{A as ne,p as ie}from"./AuxiliaryPanelHeader-Bp3iRjm6.js";import{N as P,f as oe,g as le,T as ce}from"./url-BvjSC8PU.js";import{f as de}from"./app-Clwvoiwx.js";import{s as me}from"./ArrowRight.es-DZTjsBaI.js";import{V as R}from"./ViewChip-Cq_YzRvB.js";import"./sortable.esm-DgSW3bAA.js";import{f as he}from"./search-admin-adapter-BLMYNm9w.js";import{s as ue}from"./File.es-c83QExqr.js";import"./preload-helper-BXl3LOEh.js";const xe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),B=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=xe(r),n=new RegExp(`(${a})`,"gi"),o=new RegExp(`^${a}$`,"i"),i=t.split(n);return e.jsx("span",{children:i.map((c,d)=>o.test(c)?e.jsx("mark",{children:c},d):e.jsx(g.Fragment,{children:c},d))})},pe={hybrid:"HYBRID",lexical:"LEXICAL",semantic:"SEMANTIC"};function fe({query:t,limit:s=25,offset:r=0,mode:a="hybrid"}){return q(`query FetchSearchNotes($query: String!, $pagination: PaginationInput!, $mode: SearchMode!) {
|
|
2
2
|
searchNotes(query: $query, pagination: $pagination, mode: $mode) {
|
|
3
3
|
totalCount
|
|
4
4
|
semanticAvailable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as T,q as S,P as k,T as f,G as P,y as j,z as g,Q as E,F as R,k as q,E as C,l as x,h as I}from"./time-DZKkPFUi.js";import{f as A,s as O,T as L,a as F,i as Q,b as _,F as v}from"./app-
|
|
1
|
+
import{r as c,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as T,q as S,P as k,T as f,G as P,y as j,z as g,Q as E,F as R,k as q,E as C,l as x,h as I}from"./time-DZKkPFUi.js";import{f as A,s as O,T as L,a as F,i as Q,b as _,F as v}from"./app-Clwvoiwx.js";import{T as M,d as z}from"./url-BvjSC8PU.js";import{f as B}from"./tag.api-bU52U0tT.js";import"./useNoteMutate-VJYw0Vt_.js";import"./preload-helper-BXl3LOEh.js";import"./sortable.esm-DgSW3bAA.js";const D=s=>{const{data:d}=T({queryKey:S.tags.list(s.searchParams),async queryFn(){const r=await B({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit,sortBy:s.searchParams.sortBy,sortOrder:s.searchParams.sortOrder});if(r.type==="error")throw r;return r.allTags}});return s.render(d)},G=s=>{const[d,r]=c.useState(!1),t=c.useRef(null),n=c.useRef(!0),u=c.useRef(0),o=c.useCallback(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]);c.useEffect(()=>(n.current=!0,()=>{n.current=!1,o()}),[o]);const m=c.useCallback(p=>{u.current+=1;const i=u.current;o(),n.current&&r(!0),t.current=setTimeout(()=>{t.current=null,Promise.resolve().then(p).catch(()=>{}).finally(()=>{n.current&&u.current===i&&r(!1)})},s)},[o,s]);return[d,m]},b=I(z);function X(){const s=b.useNavigate(),{page:d,query:r,limit:t,sortBy:n,sortOrder:u}=b.useSearch(),[o,m]=c.useState(r),[,p]=G(350),i=r.trim();c.useEffect(()=>{m(r)},[r]),c.useEffect(()=>{const a=o.trim();a!==i&&p(()=>{s({search:l=>({...l,page:1,query:a})})})},[o,s,i,p]);const y=a=>{s({search:l=>({...l,...a})})},w=()=>{m(""),y({page:1,query:""})};return e.jsxs(k,{title:"Tags",description:"Find tags you added with @ across your notes",children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"surface-base flex min-w-0 items-center gap-2 rounded-[16px] px-3.5 py-2.5 lg:w-72",children:[e.jsx(A,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Search"}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsx("input",{"aria-label":"Search tags",placeholder:"Search tags",value:o,onChange:a=>m(a.target.value),className:"h-8 min-w-0 flex-1 bg-transparent text-sm font-medium text-fg-default outline-none placeholder:text-xs placeholder:font-medium placeholder:text-fg-placeholder"}),(o||i)&&e.jsx("button",{type:"button","aria-label":"Clear tag search",className:"focus-ring-soft flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",onClick:w,children:e.jsx(P,{className:"h-3.5 w-3.5",weight:"bold"})})]}),e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Items"}),e.jsx(j,{value:String(t),onValueChange:a=>{const l=Number(a);Q(l)&&y({limit:l,page:1})},variant:"ghost",size:"sm",children:L.map(a=>e.jsx(g,{value:String(a),children:a===F?`Default (${a})`:a},a))})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Sort"}),e.jsxs(j,{value:n,onValueChange:a=>y({sortBy:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(g,{value:"referenceCount",children:"Usage"}),e.jsx(g,{value:"name",children:"Name"})]}),e.jsxs(j,{value:u,onValueChange:a=>y({sortOrder:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(g,{value:"desc",children:n==="name"?"Z to A":"Most used"}),e.jsx(g,{value:"asc",children:n==="name"?"A to Z":"Least used"})]})]})]})]}),e.jsx(E,{fallback:e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(x,{width:"90px",height:"36px"}),e.jsx(x,{width:"120px",height:"36px"}),e.jsx(x,{width:"80px",height:"36px"}),e.jsx(x,{width:"100px",height:"36px"}),e.jsx(x,{width:"110px",height:"36px"}),e.jsx(x,{width:"70px",height:"36px"})]}),errorTitle:"Failed to load tags",errorDescription:"Retry loading the tag catalog",resetKeys:[d,t,i,n,u],children:e.jsx(D,{searchParams:{query:i,offset:(d-1)*t,limit:t,sortBy:n,sortOrder:u},render:({tags:a,totalCount:l})=>e.jsx(v,{fallback:e.jsx(C,{title:i?"No matching tags":"No tags yet",description:i?"Try another tag name":"Add @tags inside notes and they will appear here"}),children:a.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2.5",children:a.map(h=>e.jsxs(R,{to:M,params:{id:h.id},search:{page:1},className:"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-hover-subtle px-3 py-1.5 text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover hover:text-fg-default",children:[e.jsx(f,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:h.name}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"text-current/70",children:h.referenceCount})]},h.id))}),e.jsx(v,{fallback:null,children:l&&t<l&&e.jsx(q,{page:d,last:Math.ceil(l/t),onChange:h=>{s({search:N=>({...N,page:h,query:i,limit:t,sortBy:n,sortOrder:u})})}})})]})})})})]})}export{X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as x,D as N,q as j,Q as y,P as c,k as P,E as T,l as o,h as v}from"./time-DZKkPFUi.js";import{F as h,N as k}from"./app-
|
|
1
|
+
import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as x,D as N,q as j,Q as y,P as c,k as P,E as T,l as o,h as v}from"./time-DZKkPFUi.js";import{F as h,N as k}from"./app-Clwvoiwx.js";import{T as q}from"./url-BvjSC8PU.js";import"./NotePropertiesPanel-uO-JKy19.js";import{d as w}from"./useNoteMutate-VJYw0Vt_.js";import"./preload-helper-BXl3LOEh.js";import"./sortable.esm-DgSW3bAA.js";import"./AuxiliaryPanelHeader-Bp3iRjm6.js";import"./Plus.es-CaRgmXc_.js";const R=s=>{const{data:r}=x({queryKey:j.notes.tagList(s.searchParams),async queryFn(){const t=await N({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit});if(t.type==="error")throw t;return t.tagNotes}});return s.render(r)},g=v(q);function A(){const s=g.useNavigate(),{id:r}=g.useParams(),{page:t}=g.useSearch(),i=25,{onDelete:m,onPinned:u,deleteWarningDialog:f}=w();return e.jsxs(y,{fallback:e.jsx(c,{title:"Tagged Notes",heading:e.jsx(o,{width:148,height:24,className:"rounded-full"}),description:e.jsx(o,{width:196,height:16,className:"rounded-full"}),variant:"default",children:e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"})]})}),errorTitle:"Failed to load tagged notes",errorDescription:"Retry loading notes for this tag",resetKeys:[r,t,i],children:[e.jsx(R,{searchParams:{query:r,offset:(t-1)*i,limit:i},render:({notes:l,totalCount:n})=>{const d=l.flatMap(a=>a.tags).find(a=>a.id===r)?.name;return e.jsx(c,{title:d??"Tagged Notes",heading:d?n>0?`${d} (${n})`:d:"Tagged Notes",description:"Browse every note linked to this tag",variant:"default",children:e.jsx(h,{fallback:e.jsx(T,{title:"No tagged notes yet",description:"Notes tagged with this label will appear here"}),children:l.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-5",children:l.map(a=>e.jsx(k,{...a,onPinned:()=>u(a.id,a.pinned),onDelete:()=>m(a.id)},a.id))}),e.jsx(h,{fallback:null,children:n&&i<n&&e.jsx(P,{page:t,last:Math.ceil(n/i),onChange:a=>{s({search:p=>({...p,page:a})})}})})]})})})}}),f]})}export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as u,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{u as ke,a as re,K as Te,P as at,D as Ce,c as Se,b as At,d as Pt,C as Ae,s as rt,M as Vt,S as nt,h as Et,e as it,v as Dt}from"./sortable.esm-DgSW3bAA.js";import{g as Ft,m as lt,h as Mt,r as zt,j as Rt,u as Ot,k as It,l as Bt,n as ze,o as $t,p as Lt,q as Kt,t as Re,v as _t,w as qt,x as Wt,y as Ut}from"./app-DbQdHfMb.js";import{j as Qt,f as Pe,m as ot,a as ue,M as dt,u as Gt}from"./useNoteMutate-VJYw0Vt_.js";import{a3 as Yt,a4 as Oe,a5 as Zt,a6 as Ht,a7 as Jt,C as Xt,u as ct,q as W,W as es,e as ut,T as d,l as ce,B as $,c as ee,F as Ve,N as fe,K as Ee,m as mt,a8 as ts,k as ss,M as J,L as U,I as ve,a as Ie,b as de,J as Be,y as H,z as B,d as as,t as rs,P as ns,E as $e,h as is}from"./time-DZKkPFUi.js";import{f as ls}from"./tag.api-bU52U0tT.js";import{S as je}from"./SurfaceCard-BAlcul6z.js";import{V as Q}from"./ViewChip-Cq_YzRvB.js";import{N as De,V as os}from"./url-BvjSC8PU.js";import{s as ds}from"./ArrowRight.es-DZTjsBaI.js";import{s as cs}from"./CheckCircle.es-BTloiuti.js";import{n as we}from"./Plus.es-CaRgmXc_.js";import"./preload-helper-BXl3LOEh.js";var us=class extends Yt{constructor(t,s){super(t,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Oe()})}getOptimisticResult(t){return t.behavior=Oe(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){const{state:a}=t,l=super.createResult(t,s),{isFetching:n,isRefetching:m,isError:x,isRefetchError:o}=l,v=a.fetchMeta?.fetchMore?.direction,j=x&&v==="forward",k=n&&v==="forward",p=x&&v==="backward",F=n&&v==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ht(s,a.data),hasPreviousPage:Zt(s,a.data),isFetchNextPageError:j,isFetchingNextPage:k,isFetchPreviousPageError:p,isFetchingPreviousPage:F,isRefetchError:o&&!j&&!p,isRefetching:m&&!k&&!F}}};function ms(t,s){return Jt(t,us)}const ps=new Map([["bold",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",u.createElement(u.Fragment,null,u.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),u.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",u.createElement(u.Fragment,null,u.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),pt=u.forwardRef((t,s)=>u.createElement(Xt,{ref:s,...t,weights:ps}));pt.displayName="CircleIcon";const hs=pt,me=6,Ne=["title","tags","properties","createdAt","updatedAt"],bs={activeTabId:null,tabs:[]},xs=t=>{const s=t.trim();return s?s.startsWith("@")?s:s.startsWith("#")?"":`@${s}`:""},ht=(t,s,a)=>{if(s===a)return t;const l=t.findIndex(o=>o.id===s),n=t.findIndex(o=>o.id===a);if(l<0||n<0)return t;const m=[...t],[x]=m.splice(l,1);return m.splice(n,0,x),m},bt=(t,s,a)=>{const l=t.findIndex(m=>m.id===s),n=l+(a==="previous"?-1:1);return l>=0&&n>=0&&n<t.length?t[n]?.id:void 0},Le=t=>{const s=t.flatMap(a=>typeof a=="string"?a.split(","):[]);return Array.from(new Set(s.map(xs).filter(Boolean)))},gs=t=>t.tabs.length===0?null:t.activeTabId?t.tabs.find(s=>s.id===t.activeTabId)??t.tabs[0]??null:t.tabs[0]??null,ys=(t,s)=>t.tabs.some(a=>a.id===s)?{...t,activeTabId:s}:t,xt=(t,s,a)=>({...t,tabs:ht(t.tabs,s,a)}),gt=(t,s,a,l)=>({...t,tabs:t.tabs.map(n=>n.id===s?{...n,sections:ht(n.sections,a,l)}:n)}),fs=(t,s,a)=>{const l=bt(t.tabs,s,a);return l?xt(t,s,l):t},vs=(t,s,a,l)=>{const n=t.tabs.find(x=>x.id===s)?.sections??[],m=bt(n,a,l);return m?gt(t,s,a,m):t},Ke=t=>t==="or"?"OR — any selected tag":"AND — all selected tags",js=t=>t==="or"?"OR":"AND",yt=t=>{switch(t){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"}},ws=t=>{switch(t){case"table":return"Table";case"board":return"Board";case"calendar":return"Unavailable";default:return"List"}},ft=t=>{switch(t){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},pe=t=>{const s=new Set(Ne),a=(t??[]).filter(n=>s.has(n)),l=Array.from(new Set(a));return l.length===0?[...Ne]:l.includes("title")?l:["title",...l]},Fe=t=>Array.from(new Set((t??[]).map(s=>s.trim()).filter(Boolean))).slice(0,me),vt=t=>({tableColumns:pe(t?.tableColumns),tablePropertyKeys:Fe(t?.tablePropertyKeys),boardGroupByPropertyKey:t?.boardGroupByPropertyKey?.trim()||null}),Ns=t=>{const s=yt(t.operator);return t.operator==="exists"||t.operator==="notExists"?`${t.name} ${s}`:`${t.name} ${s} ${t.value??""}`.trim()},ks=(t,s={})=>{const a={...t,...s};return{title:a.title,displayType:a.displayType,displayOptions:vt(a.displayOptions),tagNames:a.tagNames,mode:a.mode,propertyFilters:a.propertyFilters.map(l=>({key:l.key,valueType:l.valueType,operator:l.operator,value:l.value})),sortBy:a.sortBy,sortOrder:a.sortOrder,limit:a.limit}},jt="view-board-column:unassigned",Ts=t=>t===null?jt:`view-board-column:value:${encodeURIComponent(t)}`,Cs=t=>[...[...t].sort((s,a)=>s.order-a.order||s.label.localeCompare(a.label)).map(s=>({id:Ts(s.value),label:s.label,value:s.value,color:s.color??null})),{id:jt,label:"Unassigned",value:null,color:null}];function Ss({note:t,column:s,columns:a,isMoving:l,onMove:n}){const{attributes:m,listeners:x,setNodeRef:o,setActivatorNodeRef:v,transform:j,isDragging:k}=Pt({id:`view-board-note:${t.id}`,data:{note:t,sourceValue:s.value},disabled:l});return e.jsx("article",{ref:o,style:{transform:Ae.Translate.toString(j)},className:ee("group rounded-[14px] border border-border-subtle bg-elevated px-3 py-2.5 transition-[opacity,background-color,border-color] hover:border-border-secondary/80 hover:bg-hover-subtle/35",(k||l)&&"opacity-55",k&&"z-20 border-accent-primary/45 bg-elevated ring-2 ring-accent-primary/10"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("button",{type:"button",ref:v,"aria-label":`Drag ${t.title||"Untitled"} to another column`,...m,...x,className:"focus-ring-soft mt-0.5 hidden size-7 shrink-0 touch-none items-center justify-center rounded-[9px] text-fg-tertiary outline-none hover:bg-hover-subtle hover:text-fg-default sm:inline-flex",children:e.jsx(lt,{className:"size-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(d,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"leading-[1.4]",children:e.jsx(Ve,{to:De,params:{id:t.id},className:"line-clamp-2 transition-colors hover:text-fg-default/80",children:t.title||"Untitled"})}),e.jsxs(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:["Updated ",fe(Number(t.updatedAt))]})]}),e.jsx(Ee,{button:e.jsx(Pe,{label:`Move ${t.title||"Untitled"}`,size:"sm"}),items:a.filter(p=>p.value!==s.value).map(p=>({name:`Move to ${p.label}`,onClick:()=>n(t,s.value,p.value)}))})]})})}function As({section:t,groupProperty:s,column:a,columns:l,index:n,scrollRootRef:m,movingNoteIds:x,onMove:o,pageCount:v,onPageCountChange:j}){const k=u.useRef(null),[p,F]=u.useState(n<4),{isOver:h,setNodeRef:c}=At({id:a.id,data:{optionValue:a.value}});u.useEffect(()=>{if(p||!k.current)return;if(typeof IntersectionObserver>"u"){F(!0);return}const N=new IntersectionObserver(O=>{O.some(A=>A.isIntersecting)&&(F(!0),N.disconnect())},{root:m.current,rootMargin:"0px 320px",threshold:.01});return N.observe(k.current),()=>N.disconnect()},[m,p]);const{data:g,isPending:D,isError:E,refetch:V,fetchNextPage:S,hasNextPage:z,isFetchingNextPage:y,isFetchNextPageError:w}=ms({queryKey:W.views.sectionBoardColumnPages(t.id,s.key,a.value,t.limit),enabled:p,initialPageParam:0,async queryFn({pageParam:N}){const O=await Ft(t.id,{optionValue:a.value,limit:t.limit,offset:N});if(O.type==="error")throw O;return O.viewSectionBoardColumn},getNextPageParam(N,O){return O.reduce((L,G)=>L+G.notes.length,0)<N.totalCount?O.length*t.limit:void 0}}),T=u.useMemo(()=>Array.from(new Map((g?.pages??[]).flatMap(N=>N.notes).map(N=>[N.id,N])).values()),[g?.pages]),M=g?.pages[0]?.totalCount;u.useEffect(()=>{!p||!g||g.pages.length>=v||!z||y||w||S()},[g,S,z,w,y,v,p]),u.useEffect(()=>{if(M===void 0)return;const N=Math.max(1,Math.ceil(M/t.limit));v>N&&j(N)},[j,v,t.limit,M]);const R=N=>{k.current=N,c(N)};return e.jsxs("section",{ref:R,"aria-label":`${a.label} column`,className:ee("flex min-h-[248px] w-[17rem] shrink-0 flex-col rounded-[18px] border bg-subtle/30 transition-[border-color,background-color] sm:w-[18rem]",h?"border-accent-primary/50 bg-accent-primary/6":"border-border-subtle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border-subtle/75 px-3.5 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2.5 shrink-0 rounded-full border border-black/5",style:{backgroundColor:a.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx(d,{as:"h3",variant:"label",weight:"semibold",className:"truncate",children:a.label})]}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary","aria-label":M===void 0?"Card count loading":`${M} cards`,className:"inline-flex min-w-6 justify-center rounded-full bg-elevated px-2 py-0.5 tabular-nums",children:M??"–"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 p-2.5",children:[p?D&&!g?e.jsxs(e.Fragment,{children:[e.jsx(ce,{height:"76px",className:"rounded-[14px]"}),e.jsx(ce,{height:"76px",className:"rounded-[14px]"})]}):E?e.jsxs("div",{className:"rounded-[14px] border border-dashed border-border-subtle bg-elevated/60 p-3",children:[e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Failed to load this column."}),e.jsx($,{type:"button",variant:"ghost",size:"sm",className:"mt-2",onClick:()=>{V()},children:"Retry"})]}):T.length===0?e.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-center",children:e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Drop a note here"})}):T.map(N=>e.jsx(Ss,{note:N,column:a,columns:l,isMoving:x.has(N.id),onMove:o},N.id)):e.jsx("button",{type:"button",className:"focus-ring-soft flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-sm text-fg-tertiary outline-none hover:bg-elevated",onClick:()=>F(!0),children:"Load cards"}),z?e.jsx($,{type:"button",variant:"ghost",size:"sm",className:"mt-auto w-full",disabled:y,onClick:()=>{w||j(v+1),S()},children:y?"Loading...":w?"Retry loading cards":`Load more (${Math.max(0,(M??0)-T.length)})`}):null]})]})}function Ps({section:t,groupProperty:s,navigationState:a={},onNavigationStateChange:l=()=>{}}){const n=ct(),m=ut(),x=u.useRef(null),[o,v]=u.useState(()=>new Set),j=u.useMemo(()=>Cs(s.options),[s.options]),k=ke(re(at,{activationConstraint:{distance:6}}),re(Te)),p=u.useCallback(async(h,c,g)=>{if(c===g||o.has(h.id))return;v(V=>new Set(V).add(h.id));const D=W.views.sectionBoardAll(t.id),E=n.getQueriesData({queryKey:D});for(const[V,S]of E){if(!S||!Array.isArray(S.pages))continue;const z=V[3];if(z?.groupPropertyKey!==s.key)continue;const y=z.optionValue===c,w=z.optionValue===g,T=z.pageSize??t.limit;let M=S.pages.flatMap(N=>N.notes).filter(N=>N.id!==h.id);w&&(M=[h,...M]);const R=Math.max(0,(S.pages[0]?.totalCount??0)-(y?1:0)+(w?1:0));n.setQueryData(V,{...S,pages:S.pages.map((N,O)=>({totalCount:R,notes:M.slice(O*T,(O+1)*T)}))})}try{const V=await es({id:h.id,expectedUpdatedAt:h.updatedAt,...g===null?{deleteKeys:[s.key]}:{set:[{key:s.key,name:s.name,value:g,valueType:"select"}]}});if(V.type==="error"){for(const[S,z]of E)n.setQueryData(S,z);m(V.errors[0]?.message??"Failed to move this note.");return}await Promise.all([Qt(n),n.invalidateQueries({queryKey:W.notes.propertyKeysAll(),exact:!1})])}catch{for(const[V,S]of E)n.setQueryData(V,S);m("Failed to move this note.")}finally{v(V=>{const S=new Set(V);return S.delete(h.id),S})}},[s.key,s.name,o,n,t.id,t.limit,m]),F=({active:h,over:c})=>{const g=h.data.current?.note,D=h.data.current?.sourceValue,E=c?.data.current?.optionValue;!g||D===void 0||E===void 0||p(g,D,E)};return e.jsx(Ce,{sensors:k,collisionDetection:Se,onDragEnd:F,children:e.jsx("div",{ref:x,"data-scroll-restoration-id":`view-board-${t.id}`,className:"overflow-x-auto overscroll-x-contain px-3 py-3.5 [scrollbar-gutter:stable] sm:px-4","aria-label":`Board grouped by ${s.name}`,children:e.jsx("div",{className:"flex min-w-max items-stretch gap-3 pb-1",children:j.map((h,c)=>e.jsx(As,{section:t,groupProperty:s,column:h,columns:j,index:c,scrollRootRef:x,movingNoteIds:o,pageCount:a.columns?.[h.id]??1,onPageCountChange:g=>l(D=>({...D,columns:{...D.columns,[h.id]:g}})),onMove:(g,D,E)=>{p(g,D,E)}},h.id))})})})}const Vs="group flex min-h-[72px] items-center justify-between gap-3 px-4 py-3 transition-colors hover:bg-hover-subtle",Es=t=>t.valueType==="select"?t.option?.label??t.value:t.valueType==="boolean"?t.value==="true"?"True":"False":t.value,Ds=t=>{const s=t.tags.slice(0,2),a=t.tags.length-s.length;return s.length===0?null:e.jsxs(e.Fragment,{children:[s.map(l=>e.jsx(Q,{size:"compact",className:"max-w-[116px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:l.name},l.id)),a>0&&e.jsxs(Q,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",a]})]})},Fs=t=>{const s=t.properties??[],a=s.slice(0,2),l=s.length-a.length;return a.length===0?null:e.jsxs(e.Fragment,{children:[a.map(n=>e.jsxs(Q,{size:"compact",truncateContent:!1,className:"max-w-[220px] gap-1.5 border-border-subtle bg-subtle/55 text-fg-secondary",children:[n.valueType==="select"?e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:n.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}):null,e.jsx("span",{className:"max-w-[72px] shrink truncate text-fg-tertiary",children:n.name}),e.jsx("span",{className:"min-w-0 truncate",children:Es(n)||"—"})]},n.key)),l>0?e.jsxs(Q,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",l," properties"]}):null]})};function Ms({notes:t,isPending:s,isError:a,onRetry:l}){return s?e.jsxs("div",{className:"overflow-hidden bg-transparent",children:[e.jsx("div",{className:"h-[72px] animate-pulse bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"})]}):a?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(d,{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($,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"Retry"})})]}):t.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:"divide-y divide-border-subtle/70 bg-transparent",children:t.map(n=>e.jsxs(Ve,{to:De,params:{id:n.id},className:Vs,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.pinned?e.jsx(ot,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(d,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"line-clamp-1",children:n.title||"Untitled"})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Fs(n),Ds(n),e.jsxs(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"sm:hidden",children:["Updated ",fe(Number(n.updatedAt))]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pl-2",children:[e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"hidden sm:inline",children:fe(Number(n.updatedAt))}),e.jsx(ds,{className:"size-4 text-fg-tertiary transition-transform group-hover:translate-x-0.5"})]})]},n.id))})}const zs={title:300,tags:200,createdAt:148,updatedAt:148},Rs={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},Os="flex h-[24px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",wt="text-xs leading-5 text-fg-tertiary",Is=t=>mt(Number(t)).format("MMM D, YYYY"),Bs=t=>t==="text"||t==="url"?220:t==="date"?168:156,Nt=t=>t.kind==="property"?Bs(t.valueType):zs[t.key],$s=(t,s,a)=>{const l=new Map(a.map(o=>[o.key,o])),n=new Map(s.flatMap(o=>o.properties??[]).map(o=>[o.key,o])),m=Fe(t.displayOptions.tablePropertyKeys),x=Array.from(new Set([...t.propertyFilters.map(o=>o.key),...s.flatMap(o=>(o.properties??[]).map(v=>v.key))])).slice(0,3);return(m.length>0?m:x).flatMap(o=>{const v=l.get(o),j=n.get(o);return!v&&!j?[]:[{kind:"property",key:o,name:v?.name??j?.name??o,valueType:v?.valueType??j?.valueType??"text"}]})},Ls=(t,s,a)=>{const l=$s(t,s,a);return pe(t.displayOptions.tableColumns).reduce((n,m)=>(m==="properties"?n.push(...l):n.push({kind:"base",key:m}),n),[])},Ks=t=>t.reduce((s,a)=>s+Nt(a),0),_s=t=>{if(t.tags.length===0)return e.jsx("span",{className:wt,children:"—"});const s=t.tags.slice(0,3),a=t.tags.length-s.length;return e.jsxs("div",{className:Os,children:[s.map(l=>e.jsx(Q,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:l.name},l.id)),a>0?e.jsxs(Q,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",a]}):null]})},qs=t=>{if(!t)return e.jsx("span",{className:wt,children:"—"});if(t.valueType==="select")return e.jsx(Q,{size:"compact",className:"max-w-full border-border-subtle bg-subtle/65 text-fg-secondary",truncateContent:!1,children:e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:t.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:t.option?.label??t.value})]})});if(t.valueType==="boolean"){const s=t.value==="true",a=s?cs:hs;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-fg-secondary",children:[e.jsx(a,{className:"size-3.5 text-fg-tertiary",weight:s?"fill":"regular"}),s?"True":"False"]})}return e.jsx("span",{className:ee("block truncate text-sm text-fg-secondary",t.valueType==="number"&&"tabular-nums"),title:t.value,children:t.value||"—"})};function Ws({section:t,notes:s,isPending:a,isError:l,onRetry:n,onSortChange:m,isSortPending:x,activeSortBy:o=t.sortBy,activeSortOrder:v=t.sortOrder,availableProperties:j=[],surface:k="flush"}){const p=Ls(t,s,j),F=Ks(p),h=k==="card"?"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated":"overflow-x-auto bg-transparent",c=k==="card"?"overflow-hidden rounded-[16px] border border-border-subtle bg-elevated":"overflow-hidden bg-transparent",g=k==="card"?"bg-elevated":"bg-transparent",D=k==="card"?"bg-subtle/65":"bg-subtle/45",E=k==="card"?"bg-elevated":"bg-transparent",V=k==="card"?"var(--elevated)":"var(--surface)",S=y=>{if(y.kind==="property")return e.jsxs("th",{className:"px-3 py-2 text-left",children:[e.jsx(d,{as:"p",variant:"label",weight:"semibold",className:"truncate",title:y.name,children:y.name}),e.jsx(d,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5 capitalize",children:y.valueType})]},`property:${y.key}`);const w=Rs[y.key],T=ft(y.key),M=w?o===w:!1,R=y.key==="title";return e.jsx("th",{"aria-sort":M?v==="asc"?"ascending":"descending":void 0,className:ee("px-3 py-2.5 text-xs font-semibold text-fg-tertiary",R&&"lg:sticky lg:left-0 lg:z-20"),style:R?{background:`linear-gradient(var(--subtle), var(--subtle)), ${V}`}:void 0,children:w?e.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:x,onClick:()=>m(w),children:[e.jsx("span",{children:T}),e.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:M?v==="asc"?"↑":"↓":"↕"})]}):T},y.key)},z=(y,w)=>{if(w.kind==="property")return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:qs(y.properties?.find(T=>T.key===w.key))},`property:${w.key}`);switch(w.key){case"tags":return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:_s(y)},w.key);case"createdAt":case"updatedAt":{const T=w.key==="createdAt"?y.createdAt:y.updatedAt;return e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",title:mt(Number(T)).format("MMM D, YYYY h:mm A"),children:Is(T)})},w.key)}default:return e.jsxs("td",{className:"relative px-3 py-2.5 align-middle lg:sticky lg:left-0 lg:z-10",style:{background:V},children:[e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-hover-subtle opacity-0 transition-opacity group-hover:opacity-100"}),e.jsxs("div",{className:"relative z-10 flex min-w-0 items-center gap-2",children:[y.pinned?e.jsx(ot,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(d,{as:"div",variant:"body",weight:"semibold",className:"min-w-0 line-clamp-1",children:e.jsx(Ve,{to:De,params:{id:y.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/80",children:y.title||"Untitled"})})]})]},w.key)}};return a?e.jsxs("div",{className:c,children:[e.jsx("div",{className:"h-11 animate-pulse bg-subtle/50"}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${g}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${g}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${g}`})]}):l?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),e.jsx(d,{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($,{type:"button",variant:"ghost",size:"sm",onClick:n,children:"Retry"})})]}):s.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:h,"data-scroll-restoration-id":`view-table-${t.id}`,"aria-label":"Scrollable view table",children:e.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:F},children:[e.jsx("caption",{className:"sr-only",children:"View query results as a table"}),e.jsx("colgroup",{children:p.map(y=>e.jsx("col",{style:{width:`${Nt(y)/F*100}%`}},y.kind==="property"?`property:${y.key}`:y.key))}),e.jsx("thead",{className:D,children:e.jsx("tr",{className:"border-b border-border-subtle",children:p.map(S)})}),e.jsx("tbody",{className:E,children:s.map(y=>e.jsx("tr",{className:"group h-12 border-b border-border-subtle/70 last:border-b-0",children:p.map(w=>z(y,w))},y.id))})]})})}function Us({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(d,{as:"p",variant:"body",weight:"semibold",children:"This display type is unavailable"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Switch this section to List, Table, or Board to show the saved query here."}),e.jsx("div",{className:"mt-3",children:e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:t,children:"Change display"})})]})}function Qs({section:t,notes:s,isPending:a,isError:l,onRetry:n,onEdit:m,onSortChange:x,isSortPending:o,activeSortBy:v=t.sortBy,activeSortOrder:j=t.sortOrder,availableProperties:k=[],isPropertiesLoading:p=!1,navigationState:F={},onNavigationStateChange:h=()=>{}}){if(t.displayType==="board"){const c=k.find(g=>g.key===t.displayOptions.boardGroupByPropertyKey&&g.valueType==="select");return!c&&p?e.jsxs("div",{className:"flex gap-3 overflow-hidden px-4 py-3.5",children:[e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"})]}):!c||c.options.length===0?e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Board grouping is unavailable"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing select property with options to restore this board."}),e.jsx("div",{className:"mt-3",children:e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:m,children:"Edit board"})})]}):e.jsx(Ps,{section:t,groupProperty:c,navigationState:F,onNavigationStateChange:h})}return t.displayType==="table"?e.jsx(Ws,{section:t,notes:s,isPending:a,isError:l,onRetry:n,onSortChange:x,isSortPending:o,activeSortBy:v,activeSortOrder:j,availableProperties:k}):t.displayType==="calendar"?e.jsx(Us,{onEdit:m}):e.jsx(Ms,{notes:s,isPending:a,isError:l,onRetry:n})}function Gs({section:t,onEdit:s,onDuplicate:a,onDelete:l,onMoveUp:n,onMoveDown:m,dragHandle:x,availableProperties:o=[],isPropertiesLoading:v=!1,navigationState:j={},onNavigationStateChange:k=()=>{}}){const p=t.displayType==="board",F=j.page??1,h=(F-1)*t.limit,c=j.sort?.by??t.sortBy,g=j.sort?.order??t.sortOrder,{data:D,isPending:E,isError:V,isPlaceholderData:S,refetch:z}=ue({queryKey:W.views.sectionNotes(t.id,{limit:t.limit,offset:h,sortBy:c,sortOrder:g}),enabled:!p,placeholderData:ts,async queryFn(){const A=await Mt(t.id,{limit:t.limit,offset:h,sortBy:c,sortOrder:g});if(A.type==="error")throw A;return A.viewSectionNotes}}),y=D?.notes??[],w=D?.totalCount??0,T=Math.max(1,Math.ceil(w/t.limit)),M=js(t.mode),R=t.tagNames.length>0||t.propertyFilters.length>0,N=p?o.find(A=>A.key===t.displayOptions.boardGroupByPropertyKey):null,O=A=>{const L=c===A?g==="asc"?"desc":"asc":A==="title"?"asc":"desc";k(G=>({...G,page:1,sort:{by:A,order:L}}))};return u.useEffect(()=>{p||E||V||S||!D||F<=T||k(A=>({...A,page:T}))},[D,p,V,E,S,T,k,F]),e.jsxs(je,{flush:!0,className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border-subtle/75 px-4 py-3.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[x&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:x}),e.jsx("div",{className:"min-w-0",children:e.jsx(d,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx("span",{className:"truncate",children:t.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:ws(t.displayType)}),p&&t.displayOptions.boardGroupByPropertyKey?e.jsxs(Q,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:["Grouped by ",N?.name??t.displayOptions.boardGroupByPropertyKey]}):null,t.tagNames.map((A,L)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[L>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:M}),e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:A})]},A)),t.propertyFilters.map(A=>e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:Ns(A)},`${A.key}-${A.operator}-${A.value??""}`)),!R&&e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx(Ee,{button:e.jsx(Pe,{label:"Section actions"}),items:[...n?[{name:"Move up",onClick:n}]:[],...m?[{name:"Move down",onClick:m}]:[],...n||m?[{type:"separator"}]:[],{name:"Edit section",onClick:s},{name:"Duplicate section",onClick:a},{type:"separator"},{name:"Delete section",onClick:l}]})]}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx(Qs,{section:t,notes:y,isPending:E,isError:V,onRetry:()=>{z()},onEdit:s,onSortChange:O,isSortPending:S,activeSortBy:c,activeSortOrder:g,availableProperties:o,isPropertiesLoading:v,navigationState:j,onNavigationStateChange:k})}),e.jsxs("div",{className:"flex flex-col gap-3 border-t border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:p?`${t.limit} cards per column load`:E||S?"Loading notes...":w===0?"No matching notes":`Showing ${h+1}–${Math.min(h+y.length,w)} of ${w} notes`}),!p&&T>1?e.jsx(ss,{page:Math.min(F,T),last:T,className:"!mt-0 shrink-0 sm:justify-end",onChange:A=>k(L=>({...L,page:A}))}):null]})]})}const xe="__choose_property__",ge="__choose_board_group__",Ys=["title","tags","properties","createdAt","updatedAt"],_e=t=>String(t?.limit??5),qe=t=>t?.displayType==="table"||t?.displayType==="board"?t.displayType:"list",We=t=>pe(t?.displayOptions?.tableColumns??Ne),Ue=t=>Fe(t?.displayOptions?.tablePropertyKeys),Qe=t=>t?.displayOptions?.boardGroupByPropertyKey??"",Ge=t=>t?.mode??"and",Ye=t=>t?t.tagNames.join(", "):"",Ze=t=>t?.title??"",He=t=>t?.sortBy??"updatedAt",Je=t=>t?.sortOrder??"desc",kt=t=>`property-filter-${Date.now()}-${t}`,Xe=t=>(t?.propertyFilters??[]).map((s,a)=>({id:kt(a),key:s.key,operator:s.operator,value:s.value??""})),et=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"],tt=t=>t?"equals":"exists",Zs=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",ye=t=>t!=="exists"&&t!=="notExists",Tt=t=>t==="contains"||t==="notContains",Hs=(t,s)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!Tt(s)?"url":"text",Js=(t,s)=>{if(t.valueType==="url")return Tt(s)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function Xs({open:t,mode:s,initialSection:a=null,availableTags:l,availableProperties:n,isTagsLoading:m=!1,isPropertiesLoading:x=!1,onClose:o,onSubmit:v}){const[j,k]=u.useState(Ze(a)),[p,F]=u.useState(qe(a)),[h,c]=u.useState(We(a)),[g,D]=u.useState(Ue(a)),[E,V]=u.useState(Qe(a)),[S,z]=u.useState(Ye(a)),[y,w]=u.useState(Ge(a)),[T,M]=u.useState(He(a)),[R,N]=u.useState(Je(a)),[O,A]=u.useState(_e(a)),[L,G]=u.useState(Xe(a)),[he,te]=u.useState((a?.tagNames.length??0)>0),[ne,I]=u.useState(""),X=u.useMemo(()=>new Map(n.map(r=>[r.key,r])),[n]);u.useEffect(()=>{t&&(k(Ze(a)),F(qe(a)),c(We(a)),D(Ue(a)),V(Qe(a)),z(Ye(a)),w(Ge(a)),M(He(a)),N(Je(a)),A(_e(a)),G(Xe(a)),te((a?.tagNames.length??0)>0),I(""))},[a,t]);const Y=Le([S]),se=he||Y.length>0,be=Y.length===0&&L.length===0,ae=n.filter(r=>r.valueType==="select"&&r.options.length>0),i=r=>{r!=="title"&&(c(f=>{if(f.includes(r)){const _=f.filter(C=>C!==r);return _.length>0?_:f}return pe([...f,r])}),I(""))},b=r=>{D(f=>f.includes(r)?f.filter(_=>_!==r):f.length>=me?f:[...f,r])},P=r=>{const f=Y.includes(r)?Y.filter(_=>_!==r):[...Y,r];z(f.join(", ")),I("")},K=()=>{te(!0),I("")},ie=()=>{z(""),w("and"),te(!1),I("")},Ct=()=>{if(n.length===0){I("Create a shared property before adding a filter.");return}G(r=>[...r,{id:kt(r.length),key:"",operator:"exists",value:""}]),I("")},le=(r,f)=>{G(_=>_.map(C=>{if(C.id!==r)return C;const Z={...C,...f},oe=X.get(Z.key);return et(oe).includes(Z.operator)||(Z.operator=tt(oe)),"key"in f&&(Z.value=Zs(oe),Z.operator=tt(oe)),Z})),I("")},St=r=>{G(f=>f.filter(_=>_.id!==r)),I("")};return e.jsxs(J,{isOpen:t,onClose:o,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(J.Header,{title:s==="create"?"Create section":"Edit section",onClose:o}),e.jsx(J.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:r=>{r.preventDefault();const f=Le([S]);if(se&&f.length===0){I("Choose at least one tag, or remove this tag filter.");return}if(L.find(q=>!q.key||!X.has(q.key))){I("Choose a property for every filter.");return}const C=X.get(E);if(p==="board"&&(!C||C.valueType!=="select"||C.options.length===0)){I("Choose a select property with at least one option for the board columns.");return}if(p==="board"&&L.some(q=>q.key===E)){I("Use different properties for the board columns and the section filter.");return}const Z=L.map(q=>{const Me=X.get(q.key);return{key:Me?.key??q.key,valueType:Me?.valueType??"text",operator:q.operator,value:ye(q.operator)?q.value:null}});if(Z.some(q=>ye(q.operator)&&!q.value?.trim())){I("Fill every filter value, or switch it to is set / is empty.");return}v({title:j,displayType:p,displayOptions:vt({tableColumns:h,tablePropertyKeys:g,boardGroupByPropertyKey:E}),tagNames:f,mode:y,propertyFilters:Z,sortBy:T,sortOrder:R,limit:Number(O)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{htmlFor:"view-section-title",size:"md",children:"Section name"}),e.jsx(ve,{id:"view-section-title",value:j,onChange:r=>k(r.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(U,{size:"md",children:"Display"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same note set as a list, table, or property board."})]}),e.jsxs(Ie,{type:"single",value:p,onValueChange:r=>{(r==="list"||r==="table"||r==="board")&&(F(r),r==="board"&&!ae.some(f=>f.key===E)&&V(ae[0]?.key??""),I(""))},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(de,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(de,{value:"table","aria-label":"Show as table",children:"Table"}),e.jsx(de,{value:"board","aria-label":"Show as board",children:"Board"})]}),p==="table"?e.jsxs("div",{className:"border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(U,{size:"sm",children:"Table columns"}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:h.includes("properties")&&g.length===0?"Properties automatic":`${h.length-(h.includes("properties")?1:0)+(h.includes("properties")?g.length:0)} shown`})]}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:Ys.map(r=>{const f=ft(r);return e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx(Be,{size:"sm",checked:h.includes(r),disabled:r==="title","aria-label":`Show ${f} column`,onChange:()=>i(r)}),e.jsx(d,{as:"span",variant:"label",tone:"secondary",children:f})]},r)})}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."}),h.includes("properties")?e.jsxs("div",{className:"mt-3 border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(d,{as:"p",variant:"label",weight:"semibold",children:"Property columns"}),e.jsxs(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Select up to ",me," properties to compare."]})]}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:g.length>0?`${g.length} selected`:"Automatic"})]}),n.length>0?e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:n.map(r=>{const f=g.includes(r.key),_=g.length>=me;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1 py-2",children:[e.jsx(Be,{size:"sm",checked:f,disabled:!f&&_,"aria-label":`Show ${r.name} property column`,onChange:()=>b(r.key)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(d,{as:"p",variant:"label",tone:"secondary",truncate:!0,children:r.name}),e.jsx(d,{as:"p",variant:"micro",tone:"tertiary",children:r.valueType})]})]},r.key)})}):e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-3",children:"Shared properties will appear here after you create them."}),g.length===0&&n.length>0?e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Automatic mode shows up to three properties relevant to the current notes."}):null]}):null]}):null,p==="board"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{id:"view-section-board-group-label",htmlFor:"view-section-board-group",size:"sm",children:"Board columns"}),e.jsxs(H,{id:"view-section-board-group",value:E||ge,"aria-labelledby":"view-section-board-group-label",className:"w-full",onValueChange:r=>{r!==ge&&(V(r),I(""))},children:[e.jsx(B,{value:ge,disabled:!0,children:"Choose a select property"}),ae.map(r=>e.jsxs(B,{value:r.key,children:[r.name," · ",r.options.length," columns"]},r.key))]}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Moving a card changes this property. Notes without a value stay in Unassigned."}),ae.length===0&&!x?e.jsx(d,{as:"p",variant:"meta",className:"text-fg-error",children:"Create a shared select property with options before using a board."}):null]})}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",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(U,{size:"md",children:"Filters"}),e.jsx(d,{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($,{type:"button",variant:"subtle",size:"sm",onClick:Ct,children:"Add property filter"}),!se&&e.jsx($,{type:"button",variant:"subtle",size:"sm",onClick:K,children:"Add tag filter"})]})]}),L.length===0&&!se?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(d,{as:"p",variant:"label",tone:"default",children:be?"All notes":"No filters"}),e.jsx(d,{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,L.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:L.map(r=>{const f=X.get(r.key),_=et(f);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(H,{value:r.key||xe,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:C=>{C!==xe&&le(r.id,{key:C})},children:[e.jsx(B,{value:xe,disabled:!0,children:"Choose property"}),n.map(C=>e.jsx(B,{value:C.key,children:C.name},C.key))]}),e.jsx(H,{value:r.operator,disabled:!f,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:C=>le(r.id,{operator:C}),children:_.map(C=>e.jsx(B,{value:C,children:yt(C)},C))}),ye(r.operator)&&f?f.valueType==="select"?e.jsx(H,{value:r.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:C=>le(r.id,{value:C}),children:f.options.map(C=>e.jsx(B,{value:C.value,children:C.label},C.value))}):f.valueType==="boolean"?e.jsxs(H,{value:r.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:C=>le(r.id,{value:C}),children:[e.jsx(B,{value:"true",children:"True"}),e.jsx(B,{value:"false",children:"False"})]}):e.jsx(ve,{type:Hs(f,r.operator),value:r.value,onChange:C=>le(r.id,{value:C.target.value}),placeholder:Js(f,r.operator),"aria-label":"Property filter value"}):e.jsx(d,{as:"span",variant:"label",tone:"tertiary",children:f?"No value needed":"Choose a property first"}),e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:()=>St(r.id),children:"Remove"})]},r.id)})}):null,se?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(d,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:ie,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(as,{id:"view-section-tags",value:S,onChange:r=>{z(r.target.value),I("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(d,{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(U,{size:"sm",children:"Tag match"}),e.jsxs(Ie,{type:"single",value:y,onValueChange:r=>{(r==="and"||r==="or")&&w(r)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(de,{value:"and","aria-label":Ke("and"),children:"AND"}),e.jsx(de,{value:"or","aria-label":Ke("or"),children:"OR"})]}),e.jsx(d,{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(U,{size:"sm",children:"Existing tags"}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:m?"Loading...":`${l.length} available`})]}),l.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:l.map(r=>{const f=Y.includes(r.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 ${f?"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"}`,"aria-pressed":f,onClick:()=>P(r.name),children:r.name},r.id)})})}):e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(d,{as:"p",variant:"meta",tone:ne?"default":"tertiary",className:ne?"text-fg-error":void 0,children:ne||(x||m?"Loading filter options...":`${n.length} properties · ${l.length} tags available`)})]}),e.jsxs("details",{className:"group pb-1",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(d,{as:"span",variant:"label",tone:"default",children:"Sort and page size"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"col-start-1 row-start-2",children:p==="board"?"Controls how many cards each board column loads at a time.":"Controls how many matching notes appear on each section page."}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",className:"col-start-2 row-span-2 row-start-1 whitespace-nowrap",children:p==="board"?`${O} per column`:`${O} 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(U,{id:"view-section-sort-by-label",htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(H,{id:"view-section-sort-by",value:T,"aria-labelledby":"view-section-sort-by-label",onValueChange:r=>M(r),children:[e.jsx(B,{value:"updatedAt",children:"Updated time"}),e.jsx(B,{value:"createdAt",children:"Created time"}),e.jsx(B,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{id:"view-section-sort-order-label",htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(H,{id:"view-section-sort-order",value:R,"aria-labelledby":"view-section-sort-order-label",onValueChange:r=>N(r),children:[e.jsx(B,{value:"desc",children:"Descending"}),e.jsx(B,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{id:"view-section-limit-label",htmlFor:"view-section-limit",size:"sm",children:p==="board"?"Cards per load":"Rows per page"}),e.jsxs(H,{id:"view-section-limit",value:O,"aria-labelledby":"view-section-limit-label",onValueChange:A,children:[e.jsxs(B,{value:"3",children:["3 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"5",children:["5 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"8",children:["8 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"10",children:["10 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"12",children:["12 ",p==="board"?"cards":"rows"]})]})]})]})]})]})}),e.jsx(J.Footer,{children:e.jsxs(dt,{children:[e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),e.jsx($,{type:"submit",size:"sm",form:"view-section-form",children:s==="create"?"Create section":"Save section"})]})})]})}const ea="group flex h-10 max-w-[72vw] shrink-0 items-center rounded-[12px] border transition-[background-color,border-color,color,box-shadow] sm:max-w-[176px]",ta="focus-ring-soft inline-flex h-full min-w-0 flex-1 touch-pan-x items-center gap-1 rounded-[11px] px-3 text-[13px] font-medium outline-none transition-colors";function sa({tab:t,isActive:s,onSelect:a}){const{attributes:l,listeners:n,setNodeRef:m,setActivatorNodeRef:x,transform:o,transition:v,isDragging:j}=it({id:t.id});return e.jsx("div",{ref:m,style:{transform:Ae.Translate.toString(o),transition:v,opacity:j?.6:1},className:ee(ea,s?"border-border-secondary/80 bg-elevated text-fg-default shadow-[0_8px_18px_-18px_rgba(15,18,24,0.28)]":"border-transparent bg-transparent text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default"),children:e.jsxs("button",{type:"button",ref:x,...l,...n,role:"tab","aria-selected":s,title:`${t.title}. Drag to reorder.`,className:ee(ta,s?"text-fg-default":"text-fg-secondary group-hover:text-fg-default",j?"cursor-grabbing":"cursor-pointer"),onClick:a,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})]})})}function aa({tabs:t,activeTabId:s,onSelectTab:a,onReorderTabs:l,onCreateTab:n}){const m=ke(re(Vt,{activationConstraint:{distance:8}}),re(Te,{coordinateGetter:rt}));return e.jsx("div",{className:"-mx-1 rounded-[16px] border border-border-subtle/75 bg-subtle/50 p-1 sm:mx-0",children:e.jsx(Ce,{sensors:m,collisionDetection:Se,modifiers:[zt],autoScroll:!1,onDragEnd:x=>{l(x)},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nt,{items:t.map(x=>x.id),strategy:Et,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden",children:t.map(x=>e.jsx(sa,{tab:x,isActive:x.id===s,onSelect:()=>{a(x)}},x.id))})}),e.jsxs($,{type:"button","aria-label":"New view tab",variant:"ghost",size:"sm",className:"h-10 w-10 shrink-0 rounded-[12px] border-transparent bg-transparent px-0 text-[13px] text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default sm:w-auto sm:px-2.5",onClick:n,children:[e.jsx(we,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:"New view tab"})]})]})})})}function ra({open:t,mode:s,initialTitle:a="",onClose:l,onSubmit:n}){const[m,x]=u.useState(a);return u.useEffect(()=>{t&&x(a)},[a,t]),e.jsxs(J,{isOpen:t,onClose:l,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(J.Header,{title:s==="create"?"Create view tab":"Rename view tab",onClose:l}),e.jsx(J.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:o=>{o.preventDefault(),n(m)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(ve,{id:"view-tab-title",value:m,onChange:o=>x(o.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(J.Footer,{children:e.jsxs(dt,{children:[e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"Cancel"}),e.jsx($,{type:"submit",size:"sm",form:"view-tab-form",children:s==="create"?"Create tab":"Save tab"})]})})]})}const st=is(os),na="Save reusable note queries with tags, shared properties, and sorting.",ia="focus-ring-soft hidden 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 sm:inline-flex touch-none",la=({section:t,availableProperties:s,isPropertiesLoading:a,onEdit:l,onDuplicate:n,onDelete:m,onMoveUp:x,onMoveDown:o,navigationState:v,onNavigationStateChange:j})=>{const{attributes:k,listeners:p,setNodeRef:F,setActivatorNodeRef:h,transform:c,transition:g,isDragging:D}=it({id:t.id}),E=u.useCallback(V=>j(t.id,V),[j,t.id]);return e.jsx("div",{ref:F,style:{transform:Ae.Translate.toString(c),transition:g,opacity:D?.6:1},children:e.jsx(Gs,{section:t,availableProperties:s,isPropertiesLoading:a,onEdit:l,onDuplicate:n,onDelete:m,onMoveUp:x,onMoveDown:o,navigationState:v,onNavigationStateChange:E,dragHandle:e.jsx("button",{type:"button",ref:h,"aria-label":`Reorder section ${t.title}`,...k,...p,className:ee(ia,D?"cursor-grabbing":"cursor-grab"),children:e.jsx(lt,{className:"size-4"})})})})};function ja(){const t=Gt(),s=ut(),a=ct(),l=st.useSearch(),n=st.useNavigate(),[m,x]=u.useState(null),[o,v]=u.useState(null),{data:j,isPending:k,isError:p,refetch:F}=ue({queryKey:W.views.workspace(),async queryFn(){const i=await Rt();if(i.type==="error")throw i;return i.viewWorkspace}}),h=j??bs,c=h.tabs.find(i=>i.id===l.tab)??gs(h),g=c?h.tabs.findIndex(i=>i.id===c.id):-1,{data:D,isPending:E}=ue({queryKey:W.tags.list({limit:200}),async queryFn(){const i=await ls({limit:200});if(i.type==="error")throw i;return i.allTags}}),V=ke(re(at,{activationConstraint:{distance:8}}),re(Te,{coordinateGetter:rt})),S=D?.tags??[],{data:z,isPending:y}=ue({queryKey:W.notes.propertyKeys({limit:100}),async queryFn(){const i=await rs({limit:100});if(i.type==="error")throw i;return i.notePropertyKeys}}),w=z?.keys??[],T=i=>{a.setQueryData(W.views.workspace(),i)},M=u.useCallback((i,b)=>{n({search:P=>({...P,state:Ot(P.state,i,b)}),replace:!0,resetScroll:!1})},[n]),R=async()=>{await a.invalidateQueries({queryKey:W.views.all(),exact:!1})},N=async(i,b)=>{T(b);const P=await Wt(b.tabs.map(K=>K.id));if(P.type==="error"){T(i),s(P.errors[0].message);return}await R()},O=async({active:i,over:b})=>{if(!b||i.id===b.id)return;const P=a.getQueryData(W.views.workspace())??h,K=xt(P,String(i.id),String(b.id));await N(P,K)},A=async i=>{if(!c)return;const b=a.getQueryData(W.views.workspace())??h,P=fs(b,c.id,i);P!==b&&await N(b,P)},L=async i=>{const b=a.getQueryData(W.views.workspace())??h,P=l,K=ys(b,i.id);T(K),await n({search:{tab:i.id,state:void 0},resetScroll:!1});const ie=await ze(i.id);if(ie.type==="error"){T(b),await n({search:P,replace:!0,resetScroll:!1}),s(ie.errors[0].message);return}T(ie.setActiveViewTab)},G=async(i,b)=>{if(!c)return;T(b);const P=await Ut(c.id,b.tabs.find(K=>K.id===c.id)?.sections.map(K=>K.id)??[]);if(P.type==="error"){T(i),s(P.errors[0].message);return}await R()},he=async({active:i,over:b})=>{if(!c||!b||i.id===b.id)return;const P=a.getQueryData(W.views.workspace())??h,K=gt(P,c.id,String(i.id),String(b.id));await G(P,K)},te=async(i,b)=>{if(!c)return;const P=a.getQueryData(W.views.workspace())??h,K=vs(P,c.id,i,b);K!==P&&await G(P,K)},ne=async i=>{const b=await $t(i);if(b.type==="error"){s(b.errors[0].message);return}const P=await ze(b.createViewTab.id);P.type==="success"?T(P.setActiveViewTab):s(P.errors[0].message),await R(),await n({search:{tab:b.createViewTab.id,state:void 0},resetScroll:!1}),x(null)},I=async i=>{if(!c)return;const b=await Lt(c.id,i);if(b.type==="error"){s(b.errors[0].message);return}await R(),x(null)},X=async()=>{if(!c||!await t("Delete this view tab and all of its sections?"))return;const i=await Kt(c.id);if(i.type==="error"){s(i.errors[0].message);return}await R(),await n({search:{tab:void 0,state:void 0},replace:!0,resetScroll:!1})},Y=async i=>{if(!c)return;const b=await Re(c.id,i);if(b.type==="error"){s(b.errors[0].message);return}await R(),v(null)},se=async i=>{if(!c||!o||o.mode!=="edit")return;const b=await _t(o.section.id,i);if(b.type==="error"){s(b.errors[0].message);return}M(o.section.id,{}),await R(),v(null)},be=async i=>{const b=await Re(i.tabId,{...ks(i),title:`${i.title} copy`});if(b.type==="error"){s(b.errors[0].message);return}await R(),s("Section duplicated.")},ae=async i=>{if(!c||!await t("Delete this section from the current view tab?"))return;const b=await qt(i);if(b.type==="error"){s(b.errors[0].message);return}M(i,{}),await R()};return e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Views",description:na,children:k&&!j?e.jsx(je,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ce,{height:20,width:180,className:"rounded-full"}),e.jsx(ce,{height:16,width:260,className:"rounded-full"}),e.jsx(ce,{height:44,width:140,className:"rounded-[12px]"})]})}):p?e.jsxs(je,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(d,{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($,{type:"button",variant:"ghost",size:"sm",onClick:()=>{F()},children:"Retry"})})]}):h.tabs.length===0?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx($e,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both.",className:"h-[320px]"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs($,{type:"button",onClick:()=>x({mode:"create"}),children:[e.jsx(we,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(aa,{tabs:h.tabs,activeTabId:c?.id??null,onSelectTab:L,onReorderTabs:O,onCreateTab:()=>x({mode:"create"})}),c&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/80 px-1 pb-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(d,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",truncate:!0,children:c.title}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:c.sections.length>0?`${c.sections.length} section${c.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"inline-flex flex-wrap items-center gap-2 self-start sm:self-center",children:[e.jsxs($,{type:"button",size:"sm",onClick:()=>v({mode:"create"}),children:[e.jsx(we,{className:"h-4 w-4"}),"Add section"]}),e.jsx(Ee,{button:e.jsx(Pe,{label:"View tab actions"}),items:[...g>0?[{name:"Move tab left",onClick:()=>{A("previous")}}]:[],...g>=0&&g<h.tabs.length-1?[{name:"Move tab right",onClick:()=>{A("next")}}]:[],...h.tabs.length>1?[{type:"separator"}]:[],{name:"Rename tab",onClick:()=>x({mode:"edit",tab:c})},{type:"separator"},{name:"Delete tab",onClick:()=>{X()}}]})]})]}),c.sections.length===0?e.jsx($e,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both.",className:"h-[300px]"}):e.jsx("div",{className:"flex flex-col",children:e.jsx(Ce,{sensors:V,collisionDetection:Se,modifiers:[It],onDragEnd:he,children:e.jsx(nt,{items:c.sections.map(i=>i.id),strategy:Dt,children:e.jsx("div",{className:"flex flex-col gap-4",children:c.sections.map((i,b)=>e.jsx(la,{section:i,availableProperties:w,isPropertiesLoading:y,navigationState:Bt(l.state,i.id),onNavigationStateChange:M,onEdit:()=>v({mode:"edit",section:i}),onDuplicate:()=>{be(i)},onDelete:()=>{ae(i.id)},onMoveUp:b>0?()=>{te(i.id,"previous")}:void 0,onMoveDown:b<c.sections.length-1?()=>{te(i.id,"next")}:void 0},i.id))})})})})]})]})}),e.jsx(ra,{open:m!==null,mode:m?.mode??"create",initialTitle:m?.mode==="edit"?m.tab.title:"",onClose:()=>x(null),onSubmit:i=>{if(m?.mode==="edit"){I(i);return}ne(i)}}),e.jsx(Xs,{open:o!==null,mode:o?.mode??"create",initialSection:o?.mode==="edit"?o.section:null,availableTags:S,availableProperties:w,isTagsLoading:E,isPropertiesLoading:y,onClose:()=>v(null),onSubmit:i=>{if(o?.mode==="edit"){se(i);return}Y(i)}})]})}export{ja as default};
|
|
1
|
+
import{r as u,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{u as ke,a as re,K as Te,P as at,D as Ce,c as Se,b as At,d as Pt,C as Ae,s as rt,M as Vt,S as nt,h as Et,e as it,v as Dt}from"./sortable.esm-DgSW3bAA.js";import{g as Ft,m as lt,h as Mt,r as zt,j as Rt,u as Ot,k as It,l as Bt,n as ze,o as $t,p as Lt,q as Kt,t as Re,v as _t,w as qt,x as Wt,y as Ut}from"./app-Clwvoiwx.js";import{j as Qt,f as Pe,m as ot,a as ue,M as dt,u as Gt}from"./useNoteMutate-VJYw0Vt_.js";import{a3 as Yt,a4 as Oe,a5 as Zt,a6 as Ht,a7 as Jt,C as Xt,u as ct,q as W,W as es,e as ut,T as d,l as ce,B as $,c as ee,F as Ve,N as fe,K as Ee,m as mt,a8 as ts,k as ss,M as J,L as U,I as ve,a as Ie,b as de,J as Be,y as H,z as B,d as as,t as rs,P as ns,E as $e,h as is}from"./time-DZKkPFUi.js";import{f as ls}from"./tag.api-bU52U0tT.js";import{S as je}from"./SurfaceCard-BAlcul6z.js";import{V as Q}from"./ViewChip-Cq_YzRvB.js";import{N as De,V as os}from"./url-BvjSC8PU.js";import{s as ds}from"./ArrowRight.es-DZTjsBaI.js";import{s as cs}from"./CheckCircle.es-BTloiuti.js";import{n as we}from"./Plus.es-CaRgmXc_.js";import"./preload-helper-BXl3LOEh.js";var us=class extends Yt{constructor(t,s){super(t,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Oe()})}getOptimisticResult(t){return t.behavior=Oe(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){const{state:a}=t,l=super.createResult(t,s),{isFetching:n,isRefetching:m,isError:x,isRefetchError:o}=l,v=a.fetchMeta?.fetchMore?.direction,j=x&&v==="forward",k=n&&v==="forward",p=x&&v==="backward",F=n&&v==="backward";return{...l,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ht(s,a.data),hasPreviousPage:Zt(s,a.data),isFetchNextPageError:j,isFetchingNextPage:k,isFetchPreviousPageError:p,isFetchingPreviousPage:F,isRefetchError:o&&!j&&!p,isRefetching:m&&!k&&!F}}};function ms(t,s){return Jt(t,us)}const ps=new Map([["bold",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",u.createElement(u.Fragment,null,u.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),u.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",u.createElement(u.Fragment,null,u.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",u.createElement(u.Fragment,null,u.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),pt=u.forwardRef((t,s)=>u.createElement(Xt,{ref:s,...t,weights:ps}));pt.displayName="CircleIcon";const hs=pt,me=6,Ne=["title","tags","properties","createdAt","updatedAt"],bs={activeTabId:null,tabs:[]},xs=t=>{const s=t.trim();return s?s.startsWith("@")?s:s.startsWith("#")?"":`@${s}`:""},ht=(t,s,a)=>{if(s===a)return t;const l=t.findIndex(o=>o.id===s),n=t.findIndex(o=>o.id===a);if(l<0||n<0)return t;const m=[...t],[x]=m.splice(l,1);return m.splice(n,0,x),m},bt=(t,s,a)=>{const l=t.findIndex(m=>m.id===s),n=l+(a==="previous"?-1:1);return l>=0&&n>=0&&n<t.length?t[n]?.id:void 0},Le=t=>{const s=t.flatMap(a=>typeof a=="string"?a.split(","):[]);return Array.from(new Set(s.map(xs).filter(Boolean)))},gs=t=>t.tabs.length===0?null:t.activeTabId?t.tabs.find(s=>s.id===t.activeTabId)??t.tabs[0]??null:t.tabs[0]??null,ys=(t,s)=>t.tabs.some(a=>a.id===s)?{...t,activeTabId:s}:t,xt=(t,s,a)=>({...t,tabs:ht(t.tabs,s,a)}),gt=(t,s,a,l)=>({...t,tabs:t.tabs.map(n=>n.id===s?{...n,sections:ht(n.sections,a,l)}:n)}),fs=(t,s,a)=>{const l=bt(t.tabs,s,a);return l?xt(t,s,l):t},vs=(t,s,a,l)=>{const n=t.tabs.find(x=>x.id===s)?.sections??[],m=bt(n,a,l);return m?gt(t,s,a,m):t},Ke=t=>t==="or"?"OR — any selected tag":"AND — all selected tags",js=t=>t==="or"?"OR":"AND",yt=t=>{switch(t){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"}},ws=t=>{switch(t){case"table":return"Table";case"board":return"Board";case"calendar":return"Unavailable";default:return"List"}},ft=t=>{switch(t){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},pe=t=>{const s=new Set(Ne),a=(t??[]).filter(n=>s.has(n)),l=Array.from(new Set(a));return l.length===0?[...Ne]:l.includes("title")?l:["title",...l]},Fe=t=>Array.from(new Set((t??[]).map(s=>s.trim()).filter(Boolean))).slice(0,me),vt=t=>({tableColumns:pe(t?.tableColumns),tablePropertyKeys:Fe(t?.tablePropertyKeys),boardGroupByPropertyKey:t?.boardGroupByPropertyKey?.trim()||null}),Ns=t=>{const s=yt(t.operator);return t.operator==="exists"||t.operator==="notExists"?`${t.name} ${s}`:`${t.name} ${s} ${t.value??""}`.trim()},ks=(t,s={})=>{const a={...t,...s};return{title:a.title,displayType:a.displayType,displayOptions:vt(a.displayOptions),tagNames:a.tagNames,mode:a.mode,propertyFilters:a.propertyFilters.map(l=>({key:l.key,valueType:l.valueType,operator:l.operator,value:l.value})),sortBy:a.sortBy,sortOrder:a.sortOrder,limit:a.limit}},jt="view-board-column:unassigned",Ts=t=>t===null?jt:`view-board-column:value:${encodeURIComponent(t)}`,Cs=t=>[...[...t].sort((s,a)=>s.order-a.order||s.label.localeCompare(a.label)).map(s=>({id:Ts(s.value),label:s.label,value:s.value,color:s.color??null})),{id:jt,label:"Unassigned",value:null,color:null}];function Ss({note:t,column:s,columns:a,isMoving:l,onMove:n}){const{attributes:m,listeners:x,setNodeRef:o,setActivatorNodeRef:v,transform:j,isDragging:k}=Pt({id:`view-board-note:${t.id}`,data:{note:t,sourceValue:s.value},disabled:l});return e.jsx("article",{ref:o,style:{transform:Ae.Translate.toString(j)},className:ee("group rounded-[14px] border border-border-subtle bg-elevated px-3 py-2.5 transition-[opacity,background-color,border-color] hover:border-border-secondary/80 hover:bg-hover-subtle/35",(k||l)&&"opacity-55",k&&"z-20 border-accent-primary/45 bg-elevated ring-2 ring-accent-primary/10"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("button",{type:"button",ref:v,"aria-label":`Drag ${t.title||"Untitled"} to another column`,...m,...x,className:"focus-ring-soft mt-0.5 hidden size-7 shrink-0 touch-none items-center justify-center rounded-[9px] text-fg-tertiary outline-none hover:bg-hover-subtle hover:text-fg-default sm:inline-flex",children:e.jsx(lt,{className:"size-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(d,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"leading-[1.4]",children:e.jsx(Ve,{to:De,params:{id:t.id},className:"line-clamp-2 transition-colors hover:text-fg-default/80",children:t.title||"Untitled"})}),e.jsxs(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:["Updated ",fe(Number(t.updatedAt))]})]}),e.jsx(Ee,{button:e.jsx(Pe,{label:`Move ${t.title||"Untitled"}`,size:"sm"}),items:a.filter(p=>p.value!==s.value).map(p=>({name:`Move to ${p.label}`,onClick:()=>n(t,s.value,p.value)}))})]})})}function As({section:t,groupProperty:s,column:a,columns:l,index:n,scrollRootRef:m,movingNoteIds:x,onMove:o,pageCount:v,onPageCountChange:j}){const k=u.useRef(null),[p,F]=u.useState(n<4),{isOver:h,setNodeRef:c}=At({id:a.id,data:{optionValue:a.value}});u.useEffect(()=>{if(p||!k.current)return;if(typeof IntersectionObserver>"u"){F(!0);return}const N=new IntersectionObserver(O=>{O.some(A=>A.isIntersecting)&&(F(!0),N.disconnect())},{root:m.current,rootMargin:"0px 320px",threshold:.01});return N.observe(k.current),()=>N.disconnect()},[m,p]);const{data:g,isPending:D,isError:E,refetch:V,fetchNextPage:S,hasNextPage:z,isFetchingNextPage:y,isFetchNextPageError:w}=ms({queryKey:W.views.sectionBoardColumnPages(t.id,s.key,a.value,t.limit),enabled:p,initialPageParam:0,async queryFn({pageParam:N}){const O=await Ft(t.id,{optionValue:a.value,limit:t.limit,offset:N});if(O.type==="error")throw O;return O.viewSectionBoardColumn},getNextPageParam(N,O){return O.reduce((L,G)=>L+G.notes.length,0)<N.totalCount?O.length*t.limit:void 0}}),T=u.useMemo(()=>Array.from(new Map((g?.pages??[]).flatMap(N=>N.notes).map(N=>[N.id,N])).values()),[g?.pages]),M=g?.pages[0]?.totalCount;u.useEffect(()=>{!p||!g||g.pages.length>=v||!z||y||w||S()},[g,S,z,w,y,v,p]),u.useEffect(()=>{if(M===void 0)return;const N=Math.max(1,Math.ceil(M/t.limit));v>N&&j(N)},[j,v,t.limit,M]);const R=N=>{k.current=N,c(N)};return e.jsxs("section",{ref:R,"aria-label":`${a.label} column`,className:ee("flex min-h-[248px] w-[17rem] shrink-0 flex-col rounded-[18px] border bg-subtle/30 transition-[border-color,background-color] sm:w-[18rem]",h?"border-accent-primary/50 bg-accent-primary/6":"border-border-subtle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border-subtle/75 px-3.5 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2.5 shrink-0 rounded-full border border-black/5",style:{backgroundColor:a.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx(d,{as:"h3",variant:"label",weight:"semibold",className:"truncate",children:a.label})]}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary","aria-label":M===void 0?"Card count loading":`${M} cards`,className:"inline-flex min-w-6 justify-center rounded-full bg-elevated px-2 py-0.5 tabular-nums",children:M??"–"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 p-2.5",children:[p?D&&!g?e.jsxs(e.Fragment,{children:[e.jsx(ce,{height:"76px",className:"rounded-[14px]"}),e.jsx(ce,{height:"76px",className:"rounded-[14px]"})]}):E?e.jsxs("div",{className:"rounded-[14px] border border-dashed border-border-subtle bg-elevated/60 p-3",children:[e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Failed to load this column."}),e.jsx($,{type:"button",variant:"ghost",size:"sm",className:"mt-2",onClick:()=>{V()},children:"Retry"})]}):T.length===0?e.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-center",children:e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Drop a note here"})}):T.map(N=>e.jsx(Ss,{note:N,column:a,columns:l,isMoving:x.has(N.id),onMove:o},N.id)):e.jsx("button",{type:"button",className:"focus-ring-soft flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-sm text-fg-tertiary outline-none hover:bg-elevated",onClick:()=>F(!0),children:"Load cards"}),z?e.jsx($,{type:"button",variant:"ghost",size:"sm",className:"mt-auto w-full",disabled:y,onClick:()=>{w||j(v+1),S()},children:y?"Loading...":w?"Retry loading cards":`Load more (${Math.max(0,(M??0)-T.length)})`}):null]})]})}function Ps({section:t,groupProperty:s,navigationState:a={},onNavigationStateChange:l=()=>{}}){const n=ct(),m=ut(),x=u.useRef(null),[o,v]=u.useState(()=>new Set),j=u.useMemo(()=>Cs(s.options),[s.options]),k=ke(re(at,{activationConstraint:{distance:6}}),re(Te)),p=u.useCallback(async(h,c,g)=>{if(c===g||o.has(h.id))return;v(V=>new Set(V).add(h.id));const D=W.views.sectionBoardAll(t.id),E=n.getQueriesData({queryKey:D});for(const[V,S]of E){if(!S||!Array.isArray(S.pages))continue;const z=V[3];if(z?.groupPropertyKey!==s.key)continue;const y=z.optionValue===c,w=z.optionValue===g,T=z.pageSize??t.limit;let M=S.pages.flatMap(N=>N.notes).filter(N=>N.id!==h.id);w&&(M=[h,...M]);const R=Math.max(0,(S.pages[0]?.totalCount??0)-(y?1:0)+(w?1:0));n.setQueryData(V,{...S,pages:S.pages.map((N,O)=>({totalCount:R,notes:M.slice(O*T,(O+1)*T)}))})}try{const V=await es({id:h.id,expectedUpdatedAt:h.updatedAt,...g===null?{deleteKeys:[s.key]}:{set:[{key:s.key,name:s.name,value:g,valueType:"select"}]}});if(V.type==="error"){for(const[S,z]of E)n.setQueryData(S,z);m(V.errors[0]?.message??"Failed to move this note.");return}await Promise.all([Qt(n),n.invalidateQueries({queryKey:W.notes.propertyKeysAll(),exact:!1})])}catch{for(const[V,S]of E)n.setQueryData(V,S);m("Failed to move this note.")}finally{v(V=>{const S=new Set(V);return S.delete(h.id),S})}},[s.key,s.name,o,n,t.id,t.limit,m]),F=({active:h,over:c})=>{const g=h.data.current?.note,D=h.data.current?.sourceValue,E=c?.data.current?.optionValue;!g||D===void 0||E===void 0||p(g,D,E)};return e.jsx(Ce,{sensors:k,collisionDetection:Se,onDragEnd:F,children:e.jsx("div",{ref:x,"data-scroll-restoration-id":`view-board-${t.id}`,className:"overflow-x-auto overscroll-x-contain px-3 py-3.5 [scrollbar-gutter:stable] sm:px-4","aria-label":`Board grouped by ${s.name}`,children:e.jsx("div",{className:"flex min-w-max items-stretch gap-3 pb-1",children:j.map((h,c)=>e.jsx(As,{section:t,groupProperty:s,column:h,columns:j,index:c,scrollRootRef:x,movingNoteIds:o,pageCount:a.columns?.[h.id]??1,onPageCountChange:g=>l(D=>({...D,columns:{...D.columns,[h.id]:g}})),onMove:(g,D,E)=>{p(g,D,E)}},h.id))})})})}const Vs="group flex min-h-[72px] items-center justify-between gap-3 px-4 py-3 transition-colors hover:bg-hover-subtle",Es=t=>t.valueType==="select"?t.option?.label??t.value:t.valueType==="boolean"?t.value==="true"?"True":"False":t.value,Ds=t=>{const s=t.tags.slice(0,2),a=t.tags.length-s.length;return s.length===0?null:e.jsxs(e.Fragment,{children:[s.map(l=>e.jsx(Q,{size:"compact",className:"max-w-[116px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:l.name},l.id)),a>0&&e.jsxs(Q,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",a]})]})},Fs=t=>{const s=t.properties??[],a=s.slice(0,2),l=s.length-a.length;return a.length===0?null:e.jsxs(e.Fragment,{children:[a.map(n=>e.jsxs(Q,{size:"compact",truncateContent:!1,className:"max-w-[220px] gap-1.5 border-border-subtle bg-subtle/55 text-fg-secondary",children:[n.valueType==="select"?e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:n.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}):null,e.jsx("span",{className:"max-w-[72px] shrink truncate text-fg-tertiary",children:n.name}),e.jsx("span",{className:"min-w-0 truncate",children:Es(n)||"—"})]},n.key)),l>0?e.jsxs(Q,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",l," properties"]}):null]})};function Ms({notes:t,isPending:s,isError:a,onRetry:l}){return s?e.jsxs("div",{className:"overflow-hidden bg-transparent",children:[e.jsx("div",{className:"h-[72px] animate-pulse bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"})]}):a?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(d,{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($,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"Retry"})})]}):t.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:"divide-y divide-border-subtle/70 bg-transparent",children:t.map(n=>e.jsxs(Ve,{to:De,params:{id:n.id},className:Vs,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.pinned?e.jsx(ot,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(d,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"line-clamp-1",children:n.title||"Untitled"})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[Fs(n),Ds(n),e.jsxs(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"sm:hidden",children:["Updated ",fe(Number(n.updatedAt))]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pl-2",children:[e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"hidden sm:inline",children:fe(Number(n.updatedAt))}),e.jsx(ds,{className:"size-4 text-fg-tertiary transition-transform group-hover:translate-x-0.5"})]})]},n.id))})}const zs={title:300,tags:200,createdAt:148,updatedAt:148},Rs={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},Os="flex h-[24px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",wt="text-xs leading-5 text-fg-tertiary",Is=t=>mt(Number(t)).format("MMM D, YYYY"),Bs=t=>t==="text"||t==="url"?220:t==="date"?168:156,Nt=t=>t.kind==="property"?Bs(t.valueType):zs[t.key],$s=(t,s,a)=>{const l=new Map(a.map(o=>[o.key,o])),n=new Map(s.flatMap(o=>o.properties??[]).map(o=>[o.key,o])),m=Fe(t.displayOptions.tablePropertyKeys),x=Array.from(new Set([...t.propertyFilters.map(o=>o.key),...s.flatMap(o=>(o.properties??[]).map(v=>v.key))])).slice(0,3);return(m.length>0?m:x).flatMap(o=>{const v=l.get(o),j=n.get(o);return!v&&!j?[]:[{kind:"property",key:o,name:v?.name??j?.name??o,valueType:v?.valueType??j?.valueType??"text"}]})},Ls=(t,s,a)=>{const l=$s(t,s,a);return pe(t.displayOptions.tableColumns).reduce((n,m)=>(m==="properties"?n.push(...l):n.push({kind:"base",key:m}),n),[])},Ks=t=>t.reduce((s,a)=>s+Nt(a),0),_s=t=>{if(t.tags.length===0)return e.jsx("span",{className:wt,children:"—"});const s=t.tags.slice(0,3),a=t.tags.length-s.length;return e.jsxs("div",{className:Os,children:[s.map(l=>e.jsx(Q,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:l.name},l.id)),a>0?e.jsxs(Q,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",a]}):null]})},qs=t=>{if(!t)return e.jsx("span",{className:wt,children:"—"});if(t.valueType==="select")return e.jsx(Q,{size:"compact",className:"max-w-full border-border-subtle bg-subtle/65 text-fg-secondary",truncateContent:!1,children:e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:t.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:t.option?.label??t.value})]})});if(t.valueType==="boolean"){const s=t.value==="true",a=s?cs:hs;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-fg-secondary",children:[e.jsx(a,{className:"size-3.5 text-fg-tertiary",weight:s?"fill":"regular"}),s?"True":"False"]})}return e.jsx("span",{className:ee("block truncate text-sm text-fg-secondary",t.valueType==="number"&&"tabular-nums"),title:t.value,children:t.value||"—"})};function Ws({section:t,notes:s,isPending:a,isError:l,onRetry:n,onSortChange:m,isSortPending:x,activeSortBy:o=t.sortBy,activeSortOrder:v=t.sortOrder,availableProperties:j=[],surface:k="flush"}){const p=Ls(t,s,j),F=Ks(p),h=k==="card"?"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated":"overflow-x-auto bg-transparent",c=k==="card"?"overflow-hidden rounded-[16px] border border-border-subtle bg-elevated":"overflow-hidden bg-transparent",g=k==="card"?"bg-elevated":"bg-transparent",D=k==="card"?"bg-subtle/65":"bg-subtle/45",E=k==="card"?"bg-elevated":"bg-transparent",V=k==="card"?"var(--elevated)":"var(--surface)",S=y=>{if(y.kind==="property")return e.jsxs("th",{className:"px-3 py-2 text-left",children:[e.jsx(d,{as:"p",variant:"label",weight:"semibold",className:"truncate",title:y.name,children:y.name}),e.jsx(d,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5 capitalize",children:y.valueType})]},`property:${y.key}`);const w=Rs[y.key],T=ft(y.key),M=w?o===w:!1,R=y.key==="title";return e.jsx("th",{"aria-sort":M?v==="asc"?"ascending":"descending":void 0,className:ee("px-3 py-2.5 text-xs font-semibold text-fg-tertiary",R&&"lg:sticky lg:left-0 lg:z-20"),style:R?{background:`linear-gradient(var(--subtle), var(--subtle)), ${V}`}:void 0,children:w?e.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:x,onClick:()=>m(w),children:[e.jsx("span",{children:T}),e.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:M?v==="asc"?"↑":"↓":"↕"})]}):T},y.key)},z=(y,w)=>{if(w.kind==="property")return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:qs(y.properties?.find(T=>T.key===w.key))},`property:${w.key}`);switch(w.key){case"tags":return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:_s(y)},w.key);case"createdAt":case"updatedAt":{const T=w.key==="createdAt"?y.createdAt:y.updatedAt;return e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",title:mt(Number(T)).format("MMM D, YYYY h:mm A"),children:Is(T)})},w.key)}default:return e.jsxs("td",{className:"relative px-3 py-2.5 align-middle lg:sticky lg:left-0 lg:z-10",style:{background:V},children:[e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-hover-subtle opacity-0 transition-opacity group-hover:opacity-100"}),e.jsxs("div",{className:"relative z-10 flex min-w-0 items-center gap-2",children:[y.pinned?e.jsx(ot,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(d,{as:"div",variant:"body",weight:"semibold",className:"min-w-0 line-clamp-1",children:e.jsx(Ve,{to:De,params:{id:y.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/80",children:y.title||"Untitled"})})]})]},w.key)}};return a?e.jsxs("div",{className:c,children:[e.jsx("div",{className:"h-11 animate-pulse bg-subtle/50"}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${g}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${g}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${g}`})]}):l?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),e.jsx(d,{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($,{type:"button",variant:"ghost",size:"sm",onClick:n,children:"Retry"})})]}):s.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:h,"data-scroll-restoration-id":`view-table-${t.id}`,"aria-label":"Scrollable view table",children:e.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:F},children:[e.jsx("caption",{className:"sr-only",children:"View query results as a table"}),e.jsx("colgroup",{children:p.map(y=>e.jsx("col",{style:{width:`${Nt(y)/F*100}%`}},y.kind==="property"?`property:${y.key}`:y.key))}),e.jsx("thead",{className:D,children:e.jsx("tr",{className:"border-b border-border-subtle",children:p.map(S)})}),e.jsx("tbody",{className:E,children:s.map(y=>e.jsx("tr",{className:"group h-12 border-b border-border-subtle/70 last:border-b-0",children:p.map(w=>z(y,w))},y.id))})]})})}function Us({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(d,{as:"p",variant:"body",weight:"semibold",children:"This display type is unavailable"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Switch this section to List, Table, or Board to show the saved query here."}),e.jsx("div",{className:"mt-3",children:e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:t,children:"Change display"})})]})}function Qs({section:t,notes:s,isPending:a,isError:l,onRetry:n,onEdit:m,onSortChange:x,isSortPending:o,activeSortBy:v=t.sortBy,activeSortOrder:j=t.sortOrder,availableProperties:k=[],isPropertiesLoading:p=!1,navigationState:F={},onNavigationStateChange:h=()=>{}}){if(t.displayType==="board"){const c=k.find(g=>g.key===t.displayOptions.boardGroupByPropertyKey&&g.valueType==="select");return!c&&p?e.jsxs("div",{className:"flex gap-3 overflow-hidden px-4 py-3.5",children:[e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"})]}):!c||c.options.length===0?e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Board grouping is unavailable"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing select property with options to restore this board."}),e.jsx("div",{className:"mt-3",children:e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:m,children:"Edit board"})})]}):e.jsx(Ps,{section:t,groupProperty:c,navigationState:F,onNavigationStateChange:h})}return t.displayType==="table"?e.jsx(Ws,{section:t,notes:s,isPending:a,isError:l,onRetry:n,onSortChange:x,isSortPending:o,activeSortBy:v,activeSortOrder:j,availableProperties:k}):t.displayType==="calendar"?e.jsx(Us,{onEdit:m}):e.jsx(Ms,{notes:s,isPending:a,isError:l,onRetry:n})}function Gs({section:t,onEdit:s,onDuplicate:a,onDelete:l,onMoveUp:n,onMoveDown:m,dragHandle:x,availableProperties:o=[],isPropertiesLoading:v=!1,navigationState:j={},onNavigationStateChange:k=()=>{}}){const p=t.displayType==="board",F=j.page??1,h=(F-1)*t.limit,c=j.sort?.by??t.sortBy,g=j.sort?.order??t.sortOrder,{data:D,isPending:E,isError:V,isPlaceholderData:S,refetch:z}=ue({queryKey:W.views.sectionNotes(t.id,{limit:t.limit,offset:h,sortBy:c,sortOrder:g}),enabled:!p,placeholderData:ts,async queryFn(){const A=await Mt(t.id,{limit:t.limit,offset:h,sortBy:c,sortOrder:g});if(A.type==="error")throw A;return A.viewSectionNotes}}),y=D?.notes??[],w=D?.totalCount??0,T=Math.max(1,Math.ceil(w/t.limit)),M=js(t.mode),R=t.tagNames.length>0||t.propertyFilters.length>0,N=p?o.find(A=>A.key===t.displayOptions.boardGroupByPropertyKey):null,O=A=>{const L=c===A?g==="asc"?"desc":"asc":A==="title"?"asc":"desc";k(G=>({...G,page:1,sort:{by:A,order:L}}))};return u.useEffect(()=>{p||E||V||S||!D||F<=T||k(A=>({...A,page:T}))},[D,p,V,E,S,T,k,F]),e.jsxs(je,{flush:!0,className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border-subtle/75 px-4 py-3.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[x&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:x}),e.jsx("div",{className:"min-w-0",children:e.jsx(d,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx("span",{className:"truncate",children:t.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:ws(t.displayType)}),p&&t.displayOptions.boardGroupByPropertyKey?e.jsxs(Q,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:["Grouped by ",N?.name??t.displayOptions.boardGroupByPropertyKey]}):null,t.tagNames.map((A,L)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[L>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:M}),e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:A})]},A)),t.propertyFilters.map(A=>e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:Ns(A)},`${A.key}-${A.operator}-${A.value??""}`)),!R&&e.jsx(Q,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx(Ee,{button:e.jsx(Pe,{label:"Section actions"}),items:[...n?[{name:"Move up",onClick:n}]:[],...m?[{name:"Move down",onClick:m}]:[],...n||m?[{type:"separator"}]:[],{name:"Edit section",onClick:s},{name:"Duplicate section",onClick:a},{type:"separator"},{name:"Delete section",onClick:l}]})]}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx(Qs,{section:t,notes:y,isPending:E,isError:V,onRetry:()=>{z()},onEdit:s,onSortChange:O,isSortPending:S,activeSortBy:c,activeSortOrder:g,availableProperties:o,isPropertiesLoading:v,navigationState:j,onNavigationStateChange:k})}),e.jsxs("div",{className:"flex flex-col gap-3 border-t border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:p?`${t.limit} cards per column load`:E||S?"Loading notes...":w===0?"No matching notes":`Showing ${h+1}–${Math.min(h+y.length,w)} of ${w} notes`}),!p&&T>1?e.jsx(ss,{page:Math.min(F,T),last:T,className:"!mt-0 shrink-0 sm:justify-end",onChange:A=>k(L=>({...L,page:A}))}):null]})]})}const xe="__choose_property__",ge="__choose_board_group__",Ys=["title","tags","properties","createdAt","updatedAt"],_e=t=>String(t?.limit??5),qe=t=>t?.displayType==="table"||t?.displayType==="board"?t.displayType:"list",We=t=>pe(t?.displayOptions?.tableColumns??Ne),Ue=t=>Fe(t?.displayOptions?.tablePropertyKeys),Qe=t=>t?.displayOptions?.boardGroupByPropertyKey??"",Ge=t=>t?.mode??"and",Ye=t=>t?t.tagNames.join(", "):"",Ze=t=>t?.title??"",He=t=>t?.sortBy??"updatedAt",Je=t=>t?.sortOrder??"desc",kt=t=>`property-filter-${Date.now()}-${t}`,Xe=t=>(t?.propertyFilters??[]).map((s,a)=>({id:kt(a),key:s.key,operator:s.operator,value:s.value??""})),et=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"],tt=t=>t?"equals":"exists",Zs=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",ye=t=>t!=="exists"&&t!=="notExists",Tt=t=>t==="contains"||t==="notContains",Hs=(t,s)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!Tt(s)?"url":"text",Js=(t,s)=>{if(t.valueType==="url")return Tt(s)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function Xs({open:t,mode:s,initialSection:a=null,availableTags:l,availableProperties:n,isTagsLoading:m=!1,isPropertiesLoading:x=!1,onClose:o,onSubmit:v}){const[j,k]=u.useState(Ze(a)),[p,F]=u.useState(qe(a)),[h,c]=u.useState(We(a)),[g,D]=u.useState(Ue(a)),[E,V]=u.useState(Qe(a)),[S,z]=u.useState(Ye(a)),[y,w]=u.useState(Ge(a)),[T,M]=u.useState(He(a)),[R,N]=u.useState(Je(a)),[O,A]=u.useState(_e(a)),[L,G]=u.useState(Xe(a)),[he,te]=u.useState((a?.tagNames.length??0)>0),[ne,I]=u.useState(""),X=u.useMemo(()=>new Map(n.map(r=>[r.key,r])),[n]);u.useEffect(()=>{t&&(k(Ze(a)),F(qe(a)),c(We(a)),D(Ue(a)),V(Qe(a)),z(Ye(a)),w(Ge(a)),M(He(a)),N(Je(a)),A(_e(a)),G(Xe(a)),te((a?.tagNames.length??0)>0),I(""))},[a,t]);const Y=Le([S]),se=he||Y.length>0,be=Y.length===0&&L.length===0,ae=n.filter(r=>r.valueType==="select"&&r.options.length>0),i=r=>{r!=="title"&&(c(f=>{if(f.includes(r)){const _=f.filter(C=>C!==r);return _.length>0?_:f}return pe([...f,r])}),I(""))},b=r=>{D(f=>f.includes(r)?f.filter(_=>_!==r):f.length>=me?f:[...f,r])},P=r=>{const f=Y.includes(r)?Y.filter(_=>_!==r):[...Y,r];z(f.join(", ")),I("")},K=()=>{te(!0),I("")},ie=()=>{z(""),w("and"),te(!1),I("")},Ct=()=>{if(n.length===0){I("Create a shared property before adding a filter.");return}G(r=>[...r,{id:kt(r.length),key:"",operator:"exists",value:""}]),I("")},le=(r,f)=>{G(_=>_.map(C=>{if(C.id!==r)return C;const Z={...C,...f},oe=X.get(Z.key);return et(oe).includes(Z.operator)||(Z.operator=tt(oe)),"key"in f&&(Z.value=Zs(oe),Z.operator=tt(oe)),Z})),I("")},St=r=>{G(f=>f.filter(_=>_.id!==r)),I("")};return e.jsxs(J,{isOpen:t,onClose:o,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(J.Header,{title:s==="create"?"Create section":"Edit section",onClose:o}),e.jsx(J.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:r=>{r.preventDefault();const f=Le([S]);if(se&&f.length===0){I("Choose at least one tag, or remove this tag filter.");return}if(L.find(q=>!q.key||!X.has(q.key))){I("Choose a property for every filter.");return}const C=X.get(E);if(p==="board"&&(!C||C.valueType!=="select"||C.options.length===0)){I("Choose a select property with at least one option for the board columns.");return}if(p==="board"&&L.some(q=>q.key===E)){I("Use different properties for the board columns and the section filter.");return}const Z=L.map(q=>{const Me=X.get(q.key);return{key:Me?.key??q.key,valueType:Me?.valueType??"text",operator:q.operator,value:ye(q.operator)?q.value:null}});if(Z.some(q=>ye(q.operator)&&!q.value?.trim())){I("Fill every filter value, or switch it to is set / is empty.");return}v({title:j,displayType:p,displayOptions:vt({tableColumns:h,tablePropertyKeys:g,boardGroupByPropertyKey:E}),tagNames:f,mode:y,propertyFilters:Z,sortBy:T,sortOrder:R,limit:Number(O)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{htmlFor:"view-section-title",size:"md",children:"Section name"}),e.jsx(ve,{id:"view-section-title",value:j,onChange:r=>k(r.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(U,{size:"md",children:"Display"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same note set as a list, table, or property board."})]}),e.jsxs(Ie,{type:"single",value:p,onValueChange:r=>{(r==="list"||r==="table"||r==="board")&&(F(r),r==="board"&&!ae.some(f=>f.key===E)&&V(ae[0]?.key??""),I(""))},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(de,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(de,{value:"table","aria-label":"Show as table",children:"Table"}),e.jsx(de,{value:"board","aria-label":"Show as board",children:"Board"})]}),p==="table"?e.jsxs("div",{className:"border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(U,{size:"sm",children:"Table columns"}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:h.includes("properties")&&g.length===0?"Properties automatic":`${h.length-(h.includes("properties")?1:0)+(h.includes("properties")?g.length:0)} shown`})]}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:Ys.map(r=>{const f=ft(r);return e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx(Be,{size:"sm",checked:h.includes(r),disabled:r==="title","aria-label":`Show ${f} column`,onChange:()=>i(r)}),e.jsx(d,{as:"span",variant:"label",tone:"secondary",children:f})]},r)})}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."}),h.includes("properties")?e.jsxs("div",{className:"mt-3 border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(d,{as:"p",variant:"label",weight:"semibold",children:"Property columns"}),e.jsxs(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Select up to ",me," properties to compare."]})]}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:g.length>0?`${g.length} selected`:"Automatic"})]}),n.length>0?e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:n.map(r=>{const f=g.includes(r.key),_=g.length>=me;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1 py-2",children:[e.jsx(Be,{size:"sm",checked:f,disabled:!f&&_,"aria-label":`Show ${r.name} property column`,onChange:()=>b(r.key)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(d,{as:"p",variant:"label",tone:"secondary",truncate:!0,children:r.name}),e.jsx(d,{as:"p",variant:"micro",tone:"tertiary",children:r.valueType})]})]},r.key)})}):e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-3",children:"Shared properties will appear here after you create them."}),g.length===0&&n.length>0?e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Automatic mode shows up to three properties relevant to the current notes."}):null]}):null]}):null,p==="board"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{id:"view-section-board-group-label",htmlFor:"view-section-board-group",size:"sm",children:"Board columns"}),e.jsxs(H,{id:"view-section-board-group",value:E||ge,"aria-labelledby":"view-section-board-group-label",className:"w-full",onValueChange:r=>{r!==ge&&(V(r),I(""))},children:[e.jsx(B,{value:ge,disabled:!0,children:"Choose a select property"}),ae.map(r=>e.jsxs(B,{value:r.key,children:[r.name," · ",r.options.length," columns"]},r.key))]}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Moving a card changes this property. Notes without a value stay in Unassigned."}),ae.length===0&&!x?e.jsx(d,{as:"p",variant:"meta",className:"text-fg-error",children:"Create a shared select property with options before using a board."}):null]})}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",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(U,{size:"md",children:"Filters"}),e.jsx(d,{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($,{type:"button",variant:"subtle",size:"sm",onClick:Ct,children:"Add property filter"}),!se&&e.jsx($,{type:"button",variant:"subtle",size:"sm",onClick:K,children:"Add tag filter"})]})]}),L.length===0&&!se?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(d,{as:"p",variant:"label",tone:"default",children:be?"All notes":"No filters"}),e.jsx(d,{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,L.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:L.map(r=>{const f=X.get(r.key),_=et(f);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(H,{value:r.key||xe,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:C=>{C!==xe&&le(r.id,{key:C})},children:[e.jsx(B,{value:xe,disabled:!0,children:"Choose property"}),n.map(C=>e.jsx(B,{value:C.key,children:C.name},C.key))]}),e.jsx(H,{value:r.operator,disabled:!f,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:C=>le(r.id,{operator:C}),children:_.map(C=>e.jsx(B,{value:C,children:yt(C)},C))}),ye(r.operator)&&f?f.valueType==="select"?e.jsx(H,{value:r.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:C=>le(r.id,{value:C}),children:f.options.map(C=>e.jsx(B,{value:C.value,children:C.label},C.value))}):f.valueType==="boolean"?e.jsxs(H,{value:r.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:C=>le(r.id,{value:C}),children:[e.jsx(B,{value:"true",children:"True"}),e.jsx(B,{value:"false",children:"False"})]}):e.jsx(ve,{type:Hs(f,r.operator),value:r.value,onChange:C=>le(r.id,{value:C.target.value}),placeholder:Js(f,r.operator),"aria-label":"Property filter value"}):e.jsx(d,{as:"span",variant:"label",tone:"tertiary",children:f?"No value needed":"Choose a property first"}),e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:()=>St(r.id),children:"Remove"})]},r.id)})}):null,se?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(d,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:ie,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(as,{id:"view-section-tags",value:S,onChange:r=>{z(r.target.value),I("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(d,{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(U,{size:"sm",children:"Tag match"}),e.jsxs(Ie,{type:"single",value:y,onValueChange:r=>{(r==="and"||r==="or")&&w(r)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(de,{value:"and","aria-label":Ke("and"),children:"AND"}),e.jsx(de,{value:"or","aria-label":Ke("or"),children:"OR"})]}),e.jsx(d,{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(U,{size:"sm",children:"Existing tags"}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:m?"Loading...":`${l.length} available`})]}),l.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:l.map(r=>{const f=Y.includes(r.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 ${f?"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"}`,"aria-pressed":f,onClick:()=>P(r.name),children:r.name},r.id)})})}):e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(d,{as:"p",variant:"meta",tone:ne?"default":"tertiary",className:ne?"text-fg-error":void 0,children:ne||(x||m?"Loading filter options...":`${n.length} properties · ${l.length} tags available`)})]}),e.jsxs("details",{className:"group pb-1",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(d,{as:"span",variant:"label",tone:"default",children:"Sort and page size"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"col-start-1 row-start-2",children:p==="board"?"Controls how many cards each board column loads at a time.":"Controls how many matching notes appear on each section page."}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",className:"col-start-2 row-span-2 row-start-1 whitespace-nowrap",children:p==="board"?`${O} per column`:`${O} 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(U,{id:"view-section-sort-by-label",htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(H,{id:"view-section-sort-by",value:T,"aria-labelledby":"view-section-sort-by-label",onValueChange:r=>M(r),children:[e.jsx(B,{value:"updatedAt",children:"Updated time"}),e.jsx(B,{value:"createdAt",children:"Created time"}),e.jsx(B,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{id:"view-section-sort-order-label",htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(H,{id:"view-section-sort-order",value:R,"aria-labelledby":"view-section-sort-order-label",onValueChange:r=>N(r),children:[e.jsx(B,{value:"desc",children:"Descending"}),e.jsx(B,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{id:"view-section-limit-label",htmlFor:"view-section-limit",size:"sm",children:p==="board"?"Cards per load":"Rows per page"}),e.jsxs(H,{id:"view-section-limit",value:O,"aria-labelledby":"view-section-limit-label",onValueChange:A,children:[e.jsxs(B,{value:"3",children:["3 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"5",children:["5 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"8",children:["8 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"10",children:["10 ",p==="board"?"cards":"rows"]}),e.jsxs(B,{value:"12",children:["12 ",p==="board"?"cards":"rows"]})]})]})]})]})]})}),e.jsx(J.Footer,{children:e.jsxs(dt,{children:[e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),e.jsx($,{type:"submit",size:"sm",form:"view-section-form",children:s==="create"?"Create section":"Save section"})]})})]})}const ea="group flex h-10 max-w-[72vw] shrink-0 items-center rounded-[12px] border transition-[background-color,border-color,color,box-shadow] sm:max-w-[176px]",ta="focus-ring-soft inline-flex h-full min-w-0 flex-1 touch-pan-x items-center gap-1 rounded-[11px] px-3 text-[13px] font-medium outline-none transition-colors";function sa({tab:t,isActive:s,onSelect:a}){const{attributes:l,listeners:n,setNodeRef:m,setActivatorNodeRef:x,transform:o,transition:v,isDragging:j}=it({id:t.id});return e.jsx("div",{ref:m,style:{transform:Ae.Translate.toString(o),transition:v,opacity:j?.6:1},className:ee(ea,s?"border-border-secondary/80 bg-elevated text-fg-default shadow-[0_8px_18px_-18px_rgba(15,18,24,0.28)]":"border-transparent bg-transparent text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default"),children:e.jsxs("button",{type:"button",ref:x,...l,...n,role:"tab","aria-selected":s,title:`${t.title}. Drag to reorder.`,className:ee(ta,s?"text-fg-default":"text-fg-secondary group-hover:text-fg-default",j?"cursor-grabbing":"cursor-pointer"),onClick:a,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})]})})}function aa({tabs:t,activeTabId:s,onSelectTab:a,onReorderTabs:l,onCreateTab:n}){const m=ke(re(Vt,{activationConstraint:{distance:8}}),re(Te,{coordinateGetter:rt}));return e.jsx("div",{className:"-mx-1 rounded-[16px] border border-border-subtle/75 bg-subtle/50 p-1 sm:mx-0",children:e.jsx(Ce,{sensors:m,collisionDetection:Se,modifiers:[zt],autoScroll:!1,onDragEnd:x=>{l(x)},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(nt,{items:t.map(x=>x.id),strategy:Et,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden",children:t.map(x=>e.jsx(sa,{tab:x,isActive:x.id===s,onSelect:()=>{a(x)}},x.id))})}),e.jsxs($,{type:"button","aria-label":"New view tab",variant:"ghost",size:"sm",className:"h-10 w-10 shrink-0 rounded-[12px] border-transparent bg-transparent px-0 text-[13px] text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default sm:w-auto sm:px-2.5",onClick:n,children:[e.jsx(we,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:"New view tab"})]})]})})})}function ra({open:t,mode:s,initialTitle:a="",onClose:l,onSubmit:n}){const[m,x]=u.useState(a);return u.useEffect(()=>{t&&x(a)},[a,t]),e.jsxs(J,{isOpen:t,onClose:l,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(J.Header,{title:s==="create"?"Create view tab":"Rename view tab",onClose:l}),e.jsx(J.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:o=>{o.preventDefault(),n(m)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(U,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(ve,{id:"view-tab-title",value:m,onChange:o=>x(o.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(J.Footer,{children:e.jsxs(dt,{children:[e.jsx($,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"Cancel"}),e.jsx($,{type:"submit",size:"sm",form:"view-tab-form",children:s==="create"?"Create tab":"Save tab"})]})})]})}const st=is(os),na="Save reusable note queries with tags, shared properties, and sorting.",ia="focus-ring-soft hidden 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 sm:inline-flex touch-none",la=({section:t,availableProperties:s,isPropertiesLoading:a,onEdit:l,onDuplicate:n,onDelete:m,onMoveUp:x,onMoveDown:o,navigationState:v,onNavigationStateChange:j})=>{const{attributes:k,listeners:p,setNodeRef:F,setActivatorNodeRef:h,transform:c,transition:g,isDragging:D}=it({id:t.id}),E=u.useCallback(V=>j(t.id,V),[j,t.id]);return e.jsx("div",{ref:F,style:{transform:Ae.Translate.toString(c),transition:g,opacity:D?.6:1},children:e.jsx(Gs,{section:t,availableProperties:s,isPropertiesLoading:a,onEdit:l,onDuplicate:n,onDelete:m,onMoveUp:x,onMoveDown:o,navigationState:v,onNavigationStateChange:E,dragHandle:e.jsx("button",{type:"button",ref:h,"aria-label":`Reorder section ${t.title}`,...k,...p,className:ee(ia,D?"cursor-grabbing":"cursor-grab"),children:e.jsx(lt,{className:"size-4"})})})})};function ja(){const t=Gt(),s=ut(),a=ct(),l=st.useSearch(),n=st.useNavigate(),[m,x]=u.useState(null),[o,v]=u.useState(null),{data:j,isPending:k,isError:p,refetch:F}=ue({queryKey:W.views.workspace(),async queryFn(){const i=await Rt();if(i.type==="error")throw i;return i.viewWorkspace}}),h=j??bs,c=h.tabs.find(i=>i.id===l.tab)??gs(h),g=c?h.tabs.findIndex(i=>i.id===c.id):-1,{data:D,isPending:E}=ue({queryKey:W.tags.list({limit:200}),async queryFn(){const i=await ls({limit:200});if(i.type==="error")throw i;return i.allTags}}),V=ke(re(at,{activationConstraint:{distance:8}}),re(Te,{coordinateGetter:rt})),S=D?.tags??[],{data:z,isPending:y}=ue({queryKey:W.notes.propertyKeys({limit:100}),async queryFn(){const i=await rs({limit:100});if(i.type==="error")throw i;return i.notePropertyKeys}}),w=z?.keys??[],T=i=>{a.setQueryData(W.views.workspace(),i)},M=u.useCallback((i,b)=>{n({search:P=>({...P,state:Ot(P.state,i,b)}),replace:!0,resetScroll:!1})},[n]),R=async()=>{await a.invalidateQueries({queryKey:W.views.all(),exact:!1})},N=async(i,b)=>{T(b);const P=await Wt(b.tabs.map(K=>K.id));if(P.type==="error"){T(i),s(P.errors[0].message);return}await R()},O=async({active:i,over:b})=>{if(!b||i.id===b.id)return;const P=a.getQueryData(W.views.workspace())??h,K=xt(P,String(i.id),String(b.id));await N(P,K)},A=async i=>{if(!c)return;const b=a.getQueryData(W.views.workspace())??h,P=fs(b,c.id,i);P!==b&&await N(b,P)},L=async i=>{const b=a.getQueryData(W.views.workspace())??h,P=l,K=ys(b,i.id);T(K),await n({search:{tab:i.id,state:void 0},resetScroll:!1});const ie=await ze(i.id);if(ie.type==="error"){T(b),await n({search:P,replace:!0,resetScroll:!1}),s(ie.errors[0].message);return}T(ie.setActiveViewTab)},G=async(i,b)=>{if(!c)return;T(b);const P=await Ut(c.id,b.tabs.find(K=>K.id===c.id)?.sections.map(K=>K.id)??[]);if(P.type==="error"){T(i),s(P.errors[0].message);return}await R()},he=async({active:i,over:b})=>{if(!c||!b||i.id===b.id)return;const P=a.getQueryData(W.views.workspace())??h,K=gt(P,c.id,String(i.id),String(b.id));await G(P,K)},te=async(i,b)=>{if(!c)return;const P=a.getQueryData(W.views.workspace())??h,K=vs(P,c.id,i,b);K!==P&&await G(P,K)},ne=async i=>{const b=await $t(i);if(b.type==="error"){s(b.errors[0].message);return}const P=await ze(b.createViewTab.id);P.type==="success"?T(P.setActiveViewTab):s(P.errors[0].message),await R(),await n({search:{tab:b.createViewTab.id,state:void 0},resetScroll:!1}),x(null)},I=async i=>{if(!c)return;const b=await Lt(c.id,i);if(b.type==="error"){s(b.errors[0].message);return}await R(),x(null)},X=async()=>{if(!c||!await t("Delete this view tab and all of its sections?"))return;const i=await Kt(c.id);if(i.type==="error"){s(i.errors[0].message);return}await R(),await n({search:{tab:void 0,state:void 0},replace:!0,resetScroll:!1})},Y=async i=>{if(!c)return;const b=await Re(c.id,i);if(b.type==="error"){s(b.errors[0].message);return}await R(),v(null)},se=async i=>{if(!c||!o||o.mode!=="edit")return;const b=await _t(o.section.id,i);if(b.type==="error"){s(b.errors[0].message);return}M(o.section.id,{}),await R(),v(null)},be=async i=>{const b=await Re(i.tabId,{...ks(i),title:`${i.title} copy`});if(b.type==="error"){s(b.errors[0].message);return}await R(),s("Section duplicated.")},ae=async i=>{if(!c||!await t("Delete this section from the current view tab?"))return;const b=await qt(i);if(b.type==="error"){s(b.errors[0].message);return}M(i,{}),await R()};return e.jsxs(e.Fragment,{children:[e.jsx(ns,{title:"Views",description:na,children:k&&!j?e.jsx(je,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ce,{height:20,width:180,className:"rounded-full"}),e.jsx(ce,{height:16,width:260,className:"rounded-full"}),e.jsx(ce,{height:44,width:140,className:"rounded-[12px]"})]})}):p?e.jsxs(je,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(d,{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($,{type:"button",variant:"ghost",size:"sm",onClick:()=>{F()},children:"Retry"})})]}):h.tabs.length===0?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx($e,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both.",className:"h-[320px]"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs($,{type:"button",onClick:()=>x({mode:"create"}),children:[e.jsx(we,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(aa,{tabs:h.tabs,activeTabId:c?.id??null,onSelectTab:L,onReorderTabs:O,onCreateTab:()=>x({mode:"create"})}),c&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/80 px-1 pb-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(d,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",truncate:!0,children:c.title}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:c.sections.length>0?`${c.sections.length} section${c.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"inline-flex flex-wrap items-center gap-2 self-start sm:self-center",children:[e.jsxs($,{type:"button",size:"sm",onClick:()=>v({mode:"create"}),children:[e.jsx(we,{className:"h-4 w-4"}),"Add section"]}),e.jsx(Ee,{button:e.jsx(Pe,{label:"View tab actions"}),items:[...g>0?[{name:"Move tab left",onClick:()=>{A("previous")}}]:[],...g>=0&&g<h.tabs.length-1?[{name:"Move tab right",onClick:()=>{A("next")}}]:[],...h.tabs.length>1?[{type:"separator"}]:[],{name:"Rename tab",onClick:()=>x({mode:"edit",tab:c})},{type:"separator"},{name:"Delete tab",onClick:()=>{X()}}]})]})]}),c.sections.length===0?e.jsx($e,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both.",className:"h-[300px]"}):e.jsx("div",{className:"flex flex-col",children:e.jsx(Ce,{sensors:V,collisionDetection:Se,modifiers:[It],onDragEnd:he,children:e.jsx(nt,{items:c.sections.map(i=>i.id),strategy:Dt,children:e.jsx("div",{className:"flex flex-col gap-4",children:c.sections.map((i,b)=>e.jsx(la,{section:i,availableProperties:w,isPropertiesLoading:y,navigationState:Bt(l.state,i.id),onNavigationStateChange:M,onEdit:()=>v({mode:"edit",section:i}),onDuplicate:()=>{be(i)},onDelete:()=>{ae(i.id)},onMoveUp:b>0?()=>{te(i.id,"previous")}:void 0,onMoveDown:b<c.sections.length-1?()=>{te(i.id,"next")}:void 0},i.id))})})})})]})]})}),e.jsx(ra,{open:m!==null,mode:m?.mode??"create",initialTitle:m?.mode==="edit"?m.tab.title:"",onClose:()=>x(null),onSubmit:i=>{if(m?.mode==="edit"){I(i);return}ne(i)}}),e.jsx(Xs,{open:o!==null,mode:o?.mode??"create",initialSection:o?.mode==="edit"?o.section:null,availableTags:S,availableProperties:w,isTagsLoading:E,isPropertiesLoading:y,onClose:()=>v(null),onSubmit:i=>{if(o?.mode==="edit"){se(i);return}Y(i)}})]})}export{ja as default};
|