ocean-brain 0.7.5 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/index.js +3 -3
  2. package/dist/mcp.js +180 -736
  3. package/package.json +4 -1
  4. package/server/client/dist/assets/ArrowRight.es-C4zlc54Z.js +1 -0
  5. package/server/client/dist/assets/{Calendar-Bc2zJueR.js → Calendar-COrN6Hjv.js} +2 -2
  6. package/server/client/dist/assets/Callout-BK0K9E74.js +1 -0
  7. package/server/client/dist/assets/Copy.es-zm8f_XXX.js +1 -0
  8. package/server/client/dist/assets/Graph-BH1fzhue.js +1 -0
  9. package/server/client/dist/assets/{Image-DxWhlIDG.js → Image-KXuHOG4b.js} +1 -1
  10. package/server/client/dist/assets/Image.es-BKahRbIm.js +1 -0
  11. package/server/client/dist/assets/Note-C143cKKw.js +12 -0
  12. package/server/client/dist/assets/Plus.es-BqeC8T8h.js +1 -0
  13. package/server/client/dist/assets/Reminders-BYG5rz1M.js +1 -0
  14. package/server/client/dist/assets/Search-DBWsIMDP.js +1 -0
  15. package/server/client/dist/assets/{SurfaceCard-CkAVMLPs.js → SurfaceCard-CNSQfYfM.js} +1 -1
  16. package/server/client/dist/assets/Tag-5aCfSO8Y.js +1 -0
  17. package/server/client/dist/assets/TagNotes-BPZjN-6l.js +1 -0
  18. package/server/client/dist/assets/Trash.es-CRQkTnXZ.js +1 -0
  19. package/server/client/dist/assets/ViewNotes-DGLNF96x.js +1 -0
  20. package/server/client/dist/assets/ViewSectionDialog-CzskgmMF.js +102 -0
  21. package/server/client/dist/assets/Views-DR5jT23G.js +1 -0
  22. package/server/client/dist/assets/{graph-vendor-CUxe67Lr.js → graph-vendor-UTvF2NS_.js} +2 -2
  23. package/server/client/dist/assets/image.api-8dlMwzMd.js +17 -0
  24. package/server/client/dist/assets/{index-C5BGzDgt.css → index-BEUqDuAZ.css} +1 -1
  25. package/server/client/dist/assets/{index-D3BfroIT.js → index-DGIAh3ZY.js} +1 -1
  26. package/server/client/dist/assets/index-VHp17GQX.js +342 -0
  27. package/server/client/dist/assets/manage-image-RqtWKas2.js +1 -0
  28. package/server/client/dist/assets/{manage-image-detail-C8Q7K7I3.js → manage-image-detail-BTSIbLlQ.js} +1 -1
  29. package/server/client/dist/assets/mcp-EDurbggR.js +4 -0
  30. package/server/client/dist/assets/mcp-admin-adapter-DmGUo5G8.js +1 -0
  31. package/server/client/dist/assets/{note-core-Z6kqulGB.js → note-core-BklwyZHk.js} +1 -1
  32. package/server/client/dist/assets/{note-vendor-i1M2FSI2.js → note-vendor-DkYKUmLo.js} +1 -1
  33. package/server/client/dist/assets/{placeholder-Cr_nI8UI.js → placeholder-DeKgSBnC.js} +4 -4
  34. package/server/client/dist/assets/{properties-CvYWJWUM.js → properties-BjrZvOYn.js} +1 -1
  35. package/server/client/dist/assets/tag.api-Dl8DQd0m.js +21 -0
  36. package/server/client/dist/assets/trash-C5ntddLu.js +1 -0
  37. package/server/client/dist/assets/{useReminderMutate-CDmIEwsw.js → useReminderMutate-CoXXqJY2.js} +1 -1
  38. package/server/client/dist/index.html +5 -5
  39. package/server/dist/features/auth/http/login-page.js +1 -1
  40. package/server/dist/features/image/http/upload.js +34 -23
  41. package/server/dist/features/image/http/upload.js.map +1 -1
  42. package/server/dist/features/image/services/validation.js +111 -0
  43. package/server/dist/features/image/services/validation.js.map +1 -0
  44. package/server/dist/features/mcp-admin/http/handlers.js +11 -3
  45. package/server/dist/features/mcp-admin/http/handlers.js.map +1 -1
  46. package/server/dist/features/note/http/mcp.js +8 -43
  47. package/server/dist/features/note/http/mcp.js.map +1 -1
  48. package/server/dist/features/note/services/cleanup.js +2 -2
  49. package/server/dist/features/note/services/cleanup.js.map +1 -1
  50. package/server/dist/features/note/services/markdown-intent-write.js +11 -43
  51. package/server/dist/features/note/services/markdown-intent-write.js.map +1 -1
  52. package/server/dist/features/note/services/markdown-patch.js +4 -123
  53. package/server/dist/features/note/services/markdown-patch.js.map +1 -1
  54. package/server/dist/features/note/services/write.js +13 -13
  55. package/server/dist/features/note/services/write.js.map +1 -1
  56. package/server/dist/features/tag/graphql/tag.query.resolver.js +16 -1
  57. package/server/dist/features/tag/graphql/tag.query.resolver.js.map +1 -1
  58. package/server/dist/features/tag/graphql/tag.type-defs.js +2 -0
  59. package/server/dist/features/tag/graphql/tag.type-defs.js.map +1 -1
  60. package/server/dist/modules/app-version.js +105 -0
  61. package/server/dist/modules/app-version.js.map +1 -0
  62. package/server/dist/modules/mcp-auth.js +62 -1
  63. package/server/dist/modules/mcp-auth.js.map +1 -1
  64. package/server/dist/paths.js +1 -0
  65. package/server/dist/paths.js.map +1 -1
  66. package/server/dist/routes/api.js +2 -8
  67. package/server/dist/routes/api.js.map +1 -1
  68. package/server/dist/routes/client.js +51 -1
  69. package/server/dist/routes/client.js.map +1 -1
  70. package/server/client/dist/assets/Callout-B4kA_Cvr.js +0 -1
  71. package/server/client/dist/assets/Graph-uq5jfJgt.js +0 -1
  72. package/server/client/dist/assets/Image.es-BpAOJjJT.js +0 -1
  73. package/server/client/dist/assets/Note-Bo8ZYRP-.js +0 -22
  74. package/server/client/dist/assets/Plus.es-Dc_js8AC.js +0 -1
  75. package/server/client/dist/assets/Reminders-lj7Equld.js +0 -1
  76. package/server/client/dist/assets/Search-1wcRO5--.js +0 -1
  77. package/server/client/dist/assets/Tag-CeygwFfv.js +0 -1
  78. package/server/client/dist/assets/TagNotes-B8DqItxw.js +0 -1
  79. package/server/client/dist/assets/Trash.es-OuQVb_SX.js +0 -1
  80. package/server/client/dist/assets/ViewNotes-BH7PbdOD.js +0 -1
  81. package/server/client/dist/assets/ViewSectionTableRenderer-BJwhd5be.js +0 -102
  82. package/server/client/dist/assets/Views-eYFtsdFj.js +0 -1
  83. package/server/client/dist/assets/image.api-C0eYGCeH.js +0 -17
  84. package/server/client/dist/assets/index-jIfkRdY_.js +0 -361
  85. package/server/client/dist/assets/manage-image-C0YwkLIP.js +0 -1
  86. package/server/client/dist/assets/mcp-DHHhTLC8.js +0 -1
  87. package/server/client/dist/assets/trash-DA27aW7L.js +0 -1
  88. package/server/dist/features/image/services/remote-fetch.js +0 -176
  89. package/server/dist/features/image/services/remote-fetch.js.map +0 -1
@@ -1,22 +0,0 @@
1
- import{j as e,i as qe,k as aa,U as dt,y as ut,v as ra,X as na,F as sa}from"./note-vendor-i1M2FSI2.js";import{af as oa,p as Qe,T as h,c as q,M as H,x as fe,B as S,k as je,u as ye,ag as la,q as T,ah as ia,ai as ca,aj as da,ak as ua,d as G,m as Ye,a6 as pt,al as pa,n as Me,I as $e,w as fa,o as ma,r as De,v as ft,D as mt,l as ht,g as ha,am as xa,a as ga,an as xt,ao as ya,a4 as gt,N as be,ad as va,z as ba,ap as wa,a5 as ja,aq as Ie,ar as ve,a0 as Ue,P as We,a3 as Ze,as as Na,at as Ca,au as ka,av as Aa,aw as tt,ax as Sa,i as se,L as Ke,j as Ra,ay as Ta,az as Ea,aA as at,H as Ma,aB as Da,S as rt,e as He,a8 as Ha,aC as Fa,aD as La,aE as Va,aF as Pa,aG as Oa,aH as _a,aI as nt,aJ as Ba,aK as $a}from"./index-jIfkRdY_.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{C as st,m as Ia}from"./Callout-B4kA_Cvr.js";import{S as Ua}from"./SurfaceCard-CkAVMLPs.js";import{u as Za,R as Ka}from"./useReminderMutate-CDmIEwsw.js";import{n as ze}from"./Plus.es-Dc_js8AC.js";import{u as za}from"./image.api-C0eYGCeH.js";import{A as qa,G as Qa,a3 as yt,a4 as Ya}from"./note-core-Z6kqulGB.js";function Wa(t,r){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const n=!!(t.condition??!0),i=t.blockerFn;return{shouldBlockFn:async()=>n&&i!==void 0?await i():n,enableBeforeUnload:n,withResolver:i===void 0}}function Ga(t,r){const{shouldBlockFn:n,enableBeforeUnload:i=!0,disabled:s=!1,withResolver:d=!1}=Wa(t),o=oa(),{history:p}=o,[c,g]=a.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return a.useEffect(()=>{const m=async C=>{function j(M){const u=o.parseLocation(M),y=o.getMatchedRoutes(u.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:u.pathname,pathname:u.pathname,params:y.routeParams,search:o.options.parseSearch(M.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:u.pathname,params:y.routeParams,search:o.options.parseSearch(M.search)}}const x=j(C.currentLocation),A=j(C.nextLocation);if(x.routeId==="__notFound__"&&A.routeId!=="__notFound__")return!1;const k=await n({action:C.action,current:x,next:A});if(!d)return k;if(!k)return!1;const L=await new Promise(M=>{g({status:"blocked",current:x,next:A,action:C.action,proceed:()=>M(!1),reset:()=>M(!0)})});return g({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),L};return s?void 0:p.block({blockerFn:m,enableBeforeUnload:i})},[n,i,s,d,p,o]),c}const Ja=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40V168H168V88H88V40Z",opacity:"0.2"}),a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z"}))]]),Xa=new Map([["bold",a.createElement(a.Fragment,null,a.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,12h48V212Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),a.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,8h48V216Z"}))],["fill",a.createElement(a.Fragment,null,a.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.34ZM152,88V44l44,44Z"}))],["light",a.createElement(a.Fragment,null,a.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,218Z"}))],["regular",a.createElement(a.Fragment,null,a.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,8h48V216Z"}))],["thin",a.createElement(a.Fragment,null,a.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,220Z"}))]]),er=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M87.5,151.52l64-64a12,12,0,0,1,17,17l-64,64a12,12,0,0,1-17-17Zm131-114a60.08,60.08,0,0,0-84.87,0L103.51,67.61a12,12,0,0,0,17,17l30.07-30.06a36,36,0,0,1,50.93,50.92L171.4,135.52a12,12,0,1,0,17,17l30.08-30.06A60.09,60.09,0,0,0,218.45,37.55ZM135.52,171.4l-30.07,30.08a36,36,0,0,1-50.92-50.93l30.06-30.07a12,12,0,0,0-17-17L37.55,133.58a60,60,0,0,0,84.88,84.87l30.06-30.07a12,12,0,0,0-17-17Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M209.94,113.94l-96,96a48,48,0,0,1-67.88-67.88l96-96a48,48,0,0,1,67.88,67.88Z",opacity:"0.2"}),a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM144.56,173.66l-21.45,21.45a44,44,0,0,1-62.22-62.22l21.45-21.46a8,8,0,0,1,11.32,11.31L72.2,144.2a28,28,0,0,0,39.6,39.6l21.45-21.46a8,8,0,0,1,11.31,11.32Zm-34.9-16a8,8,0,0,1-11.32-11.32l48-48a8,8,0,0,1,11.32,11.32Zm85.45-34.55-21.45,21.45a8,8,0,0,1-11.32-11.31L183.8,111.8a28,28,0,0,0-39.6-39.6L122.74,93.66a8,8,0,0,1-11.31-11.32l21.46-21.45a44,44,0,0,1,62.22,62.22Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M164.25,91.75a6,6,0,0,1,0,8.49l-64,64a6,6,0,0,1-8.49-8.48l64-64A6,6,0,0,1,164.25,91.75ZM214.2,41.8a54.07,54.07,0,0,0-76.38,0L107.75,71.85a6,6,0,0,0,8.49,8.49l30.07-30.06a42,42,0,0,1,59.41,59.41l-30.08,30.07a6,6,0,1,0,8.49,8.49l30.07-30.07A54,54,0,0,0,214.2,41.8ZM139.76,175.64l-30.07,30.08a42,42,0,0,1-59.41-59.41l30.06-30.07a6,6,0,0,0-8.49-8.49l-30,30.07a54,54,0,0,0,76.38,76.39l30.07-30.08a6,6,0,0,0-8.49-8.49Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M162.84,93.16a4,4,0,0,1,0,5.66l-64,64a4,4,0,0,1-5.66-5.66l64-64A4,4,0,0,1,162.84,93.16Zm49.95-49.95a52.07,52.07,0,0,0-73.56,0L109.17,73.27a4,4,0,0,0,5.65,5.66l30.07-30.06a44,44,0,0,1,62.24,62.24l-30.07,30.06a4,4,0,0,0,5.66,5.66l30.07-30.06A52.07,52.07,0,0,0,212.79,43.21ZM141.17,177.06l-30.06,30.07a44,44,0,0,1-62.24-62.24l30.06-30.06a4,4,0,0,0-5.66-5.66L43.21,139.23a52,52,0,0,0,73.56,73.56l30.06-30.07a4,4,0,1,0-5.66-5.66Z"}))]]),vt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:Ja}));vt.displayName="CopyIcon";const tr=vt,bt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:Xa}));bt.displayName="FileIcon";const ar=bt,wt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:er}));wt.displayName="LinkSimpleIcon";const jt=wt;function Nt({icon:t,title:r,className:n}){return e.jsxs("div",{className:q("flex items-center gap-2",n),children:[e.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:t}),e.jsx(h,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:r})]})}function Ge({title:t,icon:r,action:n,titleButtonProps:i,ariaLabel:s,className:d,children:o}){const p=o!=null&&o!==!1,c=n!=null&&n!==!1,g=e.jsx(Nt,{icon:r,title:t,className:"text-fg-tertiary"});return e.jsxs("section",{className:q("surface-base p-4",d),"aria-label":s??t,children:[e.jsxs("div",{className:q("relative",c&&"pr-44 sm:pr-48",p&&"mb-3"),children:[i?e.jsx("button",{...i,type:"button",className:q("focus-ring-soft -m-1 flex items-center gap-2 rounded-[10px] p-1 text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",i.className),children:g}):g,c&&e.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:n})]}),o]})}function ue({title:t,description:r,selected:n=!1,onClick:i,children:s}){return e.jsxs("button",{type:"button","aria-pressed":n,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${n?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:i,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:n?"default":"secondary",children:t}),e.jsx(h,{as:"div",variant:"meta",weight:"medium",tone:n?"secondary":"tertiary",className:"mt-1",children:r})]}),s?e.jsx("div",{className:"shrink-0",children:s}):null]})}const rr=[{value:"narrow",label:"Narrow",description:"Optimized for reading long-form content"},{value:"wide",label:"Wide",description:"Balanced width suitable for most content"},{value:"full",label:"Full Width",description:"Maximize screen space utilization"}];function nr({isOpen:t,onClose:r,onSave:n,currentLayout:i="wide"}){const[s,d]=a.useState(i);a.useEffect(()=>{t&&d(i)},[t,i]);const o=()=>{n(s),r()};return e.jsxs(H,{isOpen:t,onClose:r,variant:"compact",children:[e.jsx(H.Header,{title:"Layout Settings",onClose:r}),e.jsx(H.Body,{children:e.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),e.jsx("div",{className:"flex flex-col gap-2",children:rr.map(p=>e.jsx(ue,{title:p.label,description:p.description,selected:s===p.value,onClick:()=>d(p.value)},p.value))})]})})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:o,children:"Apply"})]})})]})}const Ct=t=>t==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:t==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},sr=({isDeleted:t,isConflict:r,source:n})=>{const i=Ct(n);return t?`This note was moved to trash ${i.place}`:r?`Save paused: note changed ${i.place}`:`This note changed ${i.place}`},or=({isDeleted:t,isConflict:r,hasDraft:n,source:i})=>{const s=Ct(i);return t?`${s.actor} moved this note to trash. Open trash to review or restore it.`:r&&n?`Your draft is saved locally. Reload the latest note, overwrite ${s.target}, or clone your draft into a new note.`:r?`The layout change is paused because the note changed ${s.place}. Reload the latest note or overwrite only the layout.`:`${s.actor} changed this note while it was open here. Reload the latest version before continuing.`};function lr({isOpen:t,isDeleted:r,isConflict:n,hasDraft:i,source:s,isReloading:d,onReload:o,onOverwrite:p,onCloneDraft:c,onOpenTrash:g}){return e.jsxs(H,{isOpen:t,onClose:()=>{},variant:"inspect",children:[e.jsx(H.Header,{title:sr({isDeleted:r,isConflict:n,source:s})}),e.jsx(H.Body,{children:e.jsx(h,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:or({isDeleted:r,isConflict:n,hasDraft:i,source:s})})}),e.jsx(H.Footer,{children:e.jsx(fe,{children:r?e.jsx(S,{type:"button",variant:"primary",size:"sm",onClick:g,children:"Open trash"}):n?e.jsxs(e.Fragment,{children:[e.jsx(S,{type:"button",variant:"subtle",size:"sm",isLoading:d,onClick:o,children:"Reload latest"}),i&&e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Clone draft"}),e.jsx(S,{type:"button",variant:"danger",size:"sm",onClick:p,children:"Overwrite"})]}):e.jsx(S,{type:"button",variant:"primary",size:"sm",isLoading:d,onClick:o,children:"Reload latest"})})})]})}const ot=(t,r)=>t||(r==="mobile"?"Mobile browser":r==="mcp"?"MCP":"Web browser");function ir({isOpen:t,noteId:r,onClose:n,onRestored:i}){const s=Ye(),d=je(),[o,p]=a.useState(null),[c,g]=a.useState("diff"),m=a.useRef(null),C=ye({queryKey:T.notes.snapshots(r),queryFn:async()=>{const u=await la(r);if(u.type==="error")throw u;return u.noteSnapshots},enabled:t}),j=ia({mutationFn:ca,onSuccess:async u=>{if(u.type==="error"){s(u.errors[0].message);return}await Promise.all([d.invalidateQueries({queryKey:T.notes.detail(r),exact:!0}),d.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagNameListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.pinned(),exact:!0}),d.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.graph(),exact:!0}),d.invalidateQueries({queryKey:T.notes.snapshots(r),exact:!1}),d.invalidateQueries({queryKey:T.views.sectionNotesAll(),exact:!1}),d.invalidateQueries({queryKey:T.tags.all(),exact:!1})]),s("Previous version restored."),i?.(u.restoreNoteSnapshot),p(null),n()}}),x=C.data?.find(u=>u.id===o)??null,A=ye({queryKey:[...T.notes.snapshotDetail(o??"pending"),"diff"],queryFn:async()=>{if(!o)throw new Error("SNAPSHOT_NOT_SELECTED");const u=await da(o,"current");if(u.type==="error")throw u;if(!u.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return u.noteSnapshotDiff},enabled:!!o&&c==="diff"}),k=ye({queryKey:T.notes.snapshotDetail(o??"pending"),queryFn:async()=>{if(!o)throw new Error("SNAPSHOT_NOT_SELECTED");const u=await ua(o);if(u.type==="error")throw u;if(!u.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return u.noteSnapshot},enabled:!!o&&c==="content"}),D=k.data?.contentAsMarkdown.trim()??"";a.useEffect(()=>{o&&m.current?.focus()},[o]);const L=(u,y)=>{g(y),p(u)},M=()=>{p(null),g("diff"),n()};return e.jsxs(H,{isOpen:t,onClose:M,variant:"inspect",children:[e.jsx(H.Header,{title:x?c==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:M}),e.jsx(H.Description,{className:"sr-only",children:x?c==="diff"?"Review the markdown diff between this snapshot and the current note.":"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),e.jsx(H.Body,{children:x?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:x.title}),e.jsxs(h,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",ot(x.meta.label,x.meta.entrypoint)," ","edit - ",G(x.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{variant:c==="diff"?"primary":"subtle",size:"sm",onClick:()=>g("diff"),children:"Show diff"}),e.jsx(S,{variant:c==="content"?"primary":"subtle",size:"sm",onClick:()=>g("content"),children:"View content"})]}),c==="diff"?A.isLoading?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot diff..."}):A.isError?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot diff could not be loaded."}):A.data?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"p",variant:"meta",tone:"secondary",children:"Changes from this snapshot to the current note. Red lines were in the snapshot; green lines are in the current note."}),e.jsx("pre",{className:"max-h-[60vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-0 py-3 text-xs leading-5 text-fg-secondary",children:A.data.diff.markdown.split(`
2
- `).map((u,y)=>{const v=u.startsWith("+")&&!u.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":u.startsWith("-")&&!u.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":u.startsWith("@@")?"bg-sky-500/12 text-sky-700 dark:text-sky-200":"text-fg-secondary";return e.jsx("span",{className:`block min-w-full whitespace-pre-wrap break-words px-4 ${v}`,children:u||" "},`${y}-${u}`)})})]}):null:k.isLoading?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot content..."}):k.isError?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot content could not be loaded."}):D?e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:D}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this snapshot."})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(h,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),C.isLoading&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!C.isLoading&&C.data?.length===0&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"A recovery snapshot appears before the first edit in a session. Up to 10 recent snapshots are kept for 7 days, and identical versions are skipped."}),!C.isLoading&&C.data&&C.data.length>0&&e.jsx("div",{className:"flex flex-col gap-2",children:C.data.map(u=>e.jsx(Ua,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(h,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",ot(u.meta.label,u.meta.entrypoint)," ","edit"]}),e.jsx(h,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:u.title}),e.jsx(h,{as:"p",variant:"label",tone:"tertiary",children:G(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(S,{variant:"subtle",size:"sm",onClick:()=>L(u.id,"diff"),children:"Compare"}),e.jsx(S,{size:"sm",isLoading:j.isPending,onClick:()=>j.mutate(u.id),children:"Restore"})]})]}),u.contentPreview&&e.jsx("div",{className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:u.contentPreview})})]})},u.id))})]})}),x&&e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{ref:m,variant:"subtle",onClick:()=>{p(null),g("diff")},children:"Back"}),e.jsx(S,{isLoading:j.isPending,onClick:()=>j.mutate(x.id),children:"Restore this version"})]})})]})}const cr=t=>{const{data:r}=pt({queryKey:T.notes.backReferences(t.noteId),async queryFn(){const n=await pa(t.noteId);if(n.type==="error")throw n;return n.backReferences}});return t.render(r)};let dr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",ur=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)r+=dr[n[t]&63];return r};const lt={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function pr({isOpen:t,onClose:r,onSave:n,reminder:i,mode:s}){const[d,o]=a.useState(new Date),[p,c]=a.useState("medium"),[g,m]=a.useState("");a.useEffect(()=>{t&&s==="edit"&&i?(o(new Date(Number(i.reminderDate))),c(i.priority||"medium"),m(i.content||"")):t&&s==="create"&&(o(new Date),c("medium"),m(""))},[t,s,i]);const C=()=>{n(d,p,g||void 0),r()},j=x=>p===x?lt[x].active:lt[x].inactive;return e.jsxs(H,{isOpen:t,onClose:r,variant:"form",children:[e.jsx(H.Header,{title:s==="create"?"Create Reminder":"Edit Reminder",onClose:r}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Date & Time"}),e.jsx($e,{type:"datetime-local",size:"sm",value:G(d).format("YYYY-MM-DDTHH:mm"),onChange:x=>o(new Date(x.target.value))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Content"}),e.jsx(fa,{size:"sm",placeholder:"Enter reminder content (optional)",value:g,onChange:x=>m(x.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Priority"}),e.jsxs(ma,{type:"single",variant:"quiet",value:p,onValueChange:x=>x&&c(x),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[e.jsx(De,{value:"low",className:`flex-1 rounded-[10px] border ${j("low")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),e.jsx(De,{value:"medium",className:`flex-1 rounded-[10px] border ${j("medium")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),e.jsx(De,{value:"high",className:`flex-1 rounded-[10px] border ${j("high")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:C,children:s==="create"?"Create":"Save"})]})})]})}function fr({noteId:t}){const[r,n]=a.useState(!1),[i,s]=a.useState(!1),[d,o]=a.useState("create"),[p,c]=a.useState(void 0),{onCreate:g,onUpdate:m,onDelete:C}=Za(),j=()=>{o("create"),c(void 0),s(!0)},x=u=>{o("edit"),c(u),s(!0)},A=(u,y,v)=>{d==="create"?g(t,u,y,()=>{s(!1)},v):d==="edit"&&p&&m(p.id,t,{reminderDate:u,priority:y,content:v},()=>{s(!1)})},k=u=>{m(u.id,t,{completed:!u.completed})},D=u=>{const y=G(Number(u)),v=G();return y.isSame(v,"day")?`Today at ${y.format("HH:mm")}`:y.isSame(v.add(1,"day"),"day")?`Tomorrow at ${y.format("HH:mm")}`:y.format("YYYY-MM-DD HH:mm")},L=u=>{const y=G(Number(u)),v=G(),P=y.diff(v,"hour");return P<=6?"high":P<=24?"medium":"low"},M=u=>{const y=G(Number(u)),v=G(),P=y.diff(v,"hour"),B=y.diff(v,"minute")%60;return P<0||B<0?"Overdue":P===0?`${B}m remaining`:`${P}h ${B}m remaining`};return e.jsxs(e.Fragment,{children:[e.jsx(Ge,{title:"Reminders",icon:e.jsx(ga,{className:"h-3.5 w-3.5"}),action:e.jsxs(e.Fragment,{children:[!r&&e.jsxs(S,{size:"sm",variant:"ghost",onClick:j,children:[e.jsx(ze,{className:"w-3 h-3"}),e.jsx(h,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),e.jsxs(S,{type:"button",size:"sm",variant:"ghost","aria-label":r?"Expand reminders":"Collapse reminders","aria-expanded":!r,onClick:()=>n(!r),children:[r?e.jsx(ha,{className:"h-3.5 w-3.5"}):e.jsx(xa,{className:"h-3.5 w-3.5"}),r?"Expand":"Collapse"]})]}),children:!r&&e.jsx(Ka,{noteId:t,searchParams:{offset:0,limit:9999},render:({reminders:u,totalCount:y})=>e.jsx("div",{className:"flex flex-col gap-2",children:u.length===0?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:y===0?"No reminders yet":"All reminders complete"}):e.jsx("div",{className:"flex flex-col",children:u.map(v=>{const P=v.priority||L(v.reminderDate),B=M(v.reminderDate),F=B==="Overdue";return e.jsxs("div",{className:q("flex items-center gap-2.5 px-2 py-1.5"),children:[e.jsx(ft,{checked:v.completed,onChange:()=>k(v),size:"sm"}),e.jsx(h,{as:"div",variant:"body",weight:"medium",className:q("truncate flex-1 min-w-0",v.completed&&"line-through opacity-40"),children:v.content||D(v.reminderDate)}),e.jsxs("div",{className:q("shrink-0 flex items-center gap-1",v.completed&&"opacity-40"),children:[v.content&&e.jsx(h,{as:"span",variant:"meta",tone:"secondary",children:D(v.reminderDate)}),!v.completed&&e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:F||P==="high"?"error":"tertiary",className:q(v.content&&'before:content-["·"] before:mr-1'),children:B})]}),e.jsx(mt,{button:e.jsx(ht,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>x(v)},{name:"Delete",onClick:()=>C(v.id,t)}]})]},v.id)})})})})}),e.jsx(pr,{isOpen:i,onClose:()=>s(!1),onSave:A,reminder:p,mode:d})]})}const mr=({editor:t})=>e.jsx(qe,{triggerCharacter:"/",getItems:async r=>qa([...aa(t).filter(n=>n.title!=="Audio"&&n.title!=="Video"&&n.title!=="File"),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{t.insertBlocks([{type:"tableOfContents"}],t.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:e.jsx(xt,{})}],r)}),hr=(t,r)=>r?t.filter(n=>n.id!==r):t,xr=({currentNoteId:t,onClick:r})=>e.jsx(qe,{triggerCharacter:"[",getItems:async n=>{const i=await ya({query:n,limit:5});return i.type==="error"?[]:hr(i.allNotes.notes,t).map(d=>({title:d.title,onItemClick:()=>r({type:"reference",props:{id:d.id,title:d.title}})}))}}),gr="pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",yr={idle:"",copied:"text-accent-success hover:text-accent-success focus:text-accent-success",failed:"text-fg-error hover:text-fg-error focus:text-fg-error"},vr={idle:"Copy",copied:"Copied",failed:"Copy failed"},br=({getText:t,resetDelayMs:r=2e3})=>{const[n,i]=a.useState("idle"),s=a.useRef(null),d=a.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),o=a.useCallback(()=>{d(),s.current=setTimeout(()=>{i("idle"),s.current=null},r)},[d,r]);a.useEffect(()=>d,[d]);const p=m=>{m.stopPropagation()},c=m=>{m.preventDefault(),m.stopPropagation()},g=async m=>{p(m);try{await navigator.clipboard.writeText(t()),i("copied")}catch{i("failed")}o()};return e.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:c,children:e.jsxs("button",{type:"button",className:q(gr,yr[n]),contentEditable:!1,onClick:g,children:[e.jsx(tr,{className:"h-3.5 w-3.5"}),e.jsx("span",{"aria-live":"polite",children:vr[n]})]})})},wr=({contentRef:t})=>{const r=a.useRef(null),n=a.useCallback(i=>{r.current=i,t(i)},[t]);return e.jsxs(e.Fragment,{children:[e.jsx("pre",{children:e.jsx("code",{ref:n})}),e.jsx(br,{getText:()=>r.current?.textContent?.trimEnd()??""})]})},jr="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-[color-mix(in_srgb,var(--elevated)_72%,var(--hover-subtle))] px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-elevated hover:text-fg-default dark:bg-[color-mix(in_srgb,var(--elevated)_82%,var(--hover-subtle))]",Nr={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function Cr(t){const r=gt(),n=()=>{t.editor.blur(),r({to:be,params:{id:t.inlineContent.props.id}})},i=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:jr,onMouseDown:i,onClick:s=>{i(s),n()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(i(s),n())},children:e.jsxs("span",{children:["[",t.inlineContent.props.title,"]"]})})}const kr=dt(Nr,{render:t=>e.jsx(Cr,{...t})}),Ar=()=>{const t=ra(),[r,n]=a.useState([]),i={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};a.useEffect(()=>{const o=()=>{const c=t.document,g=[],m=C=>{for(const j of C){if(j.type==="heading"){const x=j,A=x.props.level||1,k=x.content?.map(D=>D.text||"").join("")||"";k.trim()&&g.push({id:j.id,level:A,text:k})}j.children&&Array.isArray(j.children)&&m(j.children)}};m(c),n(g)};o();const p=t.onChange?.(o);return()=>{p&&p()}},[t]);const s=o=>{t.setTextCursorPosition(o);const p=document.querySelector(`[data-id="${o}"]`);p&&p.scrollIntoView({behavior:"smooth",block:"center"})},d=e.jsx(Nt,{icon:e.jsx(xt,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return r.length===0?e.jsxs("div",{className:"surface-base w-full p-4",children:[d,e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):e.jsxs("div",{className:"surface-base w-full p-4",children:[e.jsx("div",{className:"mb-2",children:d}),e.jsx("nav",{className:"space-y-0.5",children:r.map(o=>{const p=o.level===1;return e.jsxs("button",{type:"button",onClick:()=>s(o.id),className:q("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",i[o.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",p?"text-fg-default":"text-fg-secondary"),children:[e.jsxs(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",o.level]}),e.jsx(h,{as:"span",variant:"body",weight:p?"semibold":"medium",className:"line-clamp-2 text-current",children:o.text})]},o.id)})})]})},Sr=ut({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>e.jsx(Ar,{})})(),Rr="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-emphasis px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover-subtle hover:text-fg-default dark:bg-emphasis",Tr={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function Er(t){const r=gt(),n=()=>{t.editor.blur(),r({to:va,params:{id:t.inlineContent.props.id},search:{page:1}})},i=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Rr,onMouseDown:i,onClick:s=>{i(s),n()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(i(s),n())},children:e.jsx("span",{children:t.inlineContent.props.tag})})}const Mr=dt(Tr,{render:t=>e.jsx(Er,{...t})}),Dr=t=>t,Hr=t=>t,Fr=Dr({tag:Mr,reference:kr}),Lr=Hr({tableOfContents:Sr}),oe=yt.codeBlock,it=ut(oe.config,{meta:oe.implementation.meta,parse:oe.implementation.parse,parseContent:oe.implementation.parseContent,runsBefore:oe.implementation.runsBefore,render:wr})(),Vr={...it,extensions:oe.extensions,implementation:{...it.implementation,toExternalHTML:oe.implementation.toExternalHTML}},Pr=Qa.create({inlineContentSpecs:{...Ya,...Fr},blockSpecs:{...yt,codeBlock:Vr,...Lr}}),Or=(t,r)=>r.some(n=>n.name===`@${t}`),_r=({onClick:t})=>e.jsx(qe,{triggerCharacter:"@",getItems:async r=>{const n=await ba({query:r,limit:5});if(n.type==="error")return[];const{tags:i}=n.allTags,s=Or(r,i),d=[{title:"Add a new tag",onItemClick:async()=>{const o=await wa({name:"@"+r});if(o.type==="error")return;const{id:p,name:c}=o.createTag;t({type:"tag",props:{id:p,tag:c}})}}];return i.length===0?d:i.map(o=>({title:o.name,onItemClick:()=>t({type:"tag",props:{id:o.id,tag:o.name}})})).concat(r&&!s?d:[])}}),Br=new Set(["tableOfContents"]),$r="OCEAN_BRAIN_TAG_",Ir="_TOKEN",Ur=t=>`${$r}${t}${Ir}`,Zr=t=>!Array.isArray(t)&&t?.type==="tableContent",Kr=(t,r)=>Array.isArray(t)?t.map(r):Zr(t)?{...t,rows:t.rows?.map(n=>({...n,cells:n.cells?.map(i=>({...i,content:i.content?.map(r)}))}))}:t,kt=(t,r)=>t.filter(n=>!Br.has(n.type)).map(n=>({...n,content:r(n.content),children:n.children?.length?kt(n.children,r):[]}));function zr(t){const r=new Map;let n=0;return{blocks:kt(t,s=>Kr(s,d=>{if(d.type==="reference"){const o=String(d.props?.id||""),p=String(d.props?.title||d.props?.id||"");return{type:"text",text:o?`[[${p}]](note:${o})`:`[[${p}]]`,styles:{}}}if(d.type==="tag"){const o=d.props?.tag||"",p=Ur(n);return n+=1,r.set(p,o),{type:"text",text:p,styles:{}}}return d})),placeholderToTag:r}}function qr(t,r){let n=t;for(const[i,s]of r.entries())n=n.split(i).join(`[${s}]`);return n}async function Qr(t){return new Promise((r,n)=>{const i=new FileReader;i.readAsDataURL(t),i.onload=()=>r(i.result),i.onerror=s=>n(s)})}const Yr=a.forwardRef(({content:t,currentNoteId:r,editable:n,onChange:i},s)=>{const{theme:d}=ja(p=>p),o=na({schema:Pr,initialContent:t&&JSON.parse(t)||void 0,uploadFile:async p=>za({base64:await Qr(p)})},[]);return a.useImperativeHandle(s,()=>({getContent:()=>JSON.stringify(o.document),getMarkdown:()=>{const p=zr(o.document),c=o.blocksToMarkdownLossy(p.blocks);return qr(c,p.placeholderToTag)},getHtml:()=>o.blocksToHTMLLossy(o.document)})),e.jsxs(sa,{slashMenu:!1,theme:d,editor:o,editable:n,onChange:i,children:[e.jsx(mr,{editor:o}),e.jsx(xr,{currentNoteId:r,onClick:p=>{o.insertInlineContent([p," "])}}),e.jsx(_r,{onClick:p=>{o.insertInlineContent([p," "])}})]})}),Je=t=>`ocean-brain.note-draft.${t}`,Wr=t=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(Je(t));if(!r)return null;const n=JSON.parse(r);return typeof n.title!="string"||typeof n.content!="string"||typeof n.baseUpdatedAt!="string"?null:{title:n.title,content:n.content,baseUpdatedAt:n.baseUpdatedAt,createdAt:typeof n.createdAt=="number"?n.createdAt:Date.now(),...n.layout==="narrow"||n.layout==="wide"||n.layout==="full"?{layout:n.layout}:{}}}catch{return null}},Fe=(t,r)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Je(t),JSON.stringify(r))}catch{}},Le=t=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Je(t))}catch{}},Gr=1e3,Jr="NOTE_UPDATE_CONFLICT";function Xr({noteId:t,initialContent:r,initialUpdatedAt:n,editSessionIdRef:i,getContent:s,onSaved:d,onConflict:o,onError:p}){const c=je(),g=a.useRef(null),m=a.useRef(null),C=a.useRef(!1),j=a.useRef(null),x=a.useRef(!1),A=a.useRef(n),k=a.useRef(!1),D=a.useRef(!0),L=a.useRef(d),M=a.useRef(o),u=a.useRef(p),[y,v]=a.useState("saved"),[P,B]=a.useState(null),F=a.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),O=a.useCallback(R=>{D.current&&v(R)},[]),J=a.useCallback(R=>{A.current=R},[]),Y=a.useCallback((R,_={})=>({title:R,content:s()??r,createdAt:Date.now(),baseUpdatedAt:A.current,..._.layout?{layout:_.layout}:{}}),[s,r]),re=a.useCallback(()=>{m.current&&Fe(t,m.current)},[t]),W=a.useCallback(R=>{k.current=!0,O("conflict"),M.current(R??A.current)},[O]),Q=a.useCallback(async({ignoreConflict:R=!1,silent:_=!1}={})=>{if(C.current)return x.current=!0,j.current??"idle";const $=m.current;if(!$)return x.current=!1,"idle";m.current=null,x.current=!1,F(),C.current=!0,_||O("saving");const U=(async()=>{let Z;try{Z=await Ie({id:t,title:$.title,content:$.content,...$.layout?{layout:$.layout}:{},editSessionId:i.current,...R?{force:!0}:{expectedUpdatedAt:$.baseUpdatedAt}})}catch{Z={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(C.current=!1,j.current=null,Z.type==="error"){m.current||(m.current=$),re();const X=Z.errors[0];if(X.code===Jr&&!R){const N=X.details?.extensions?.currentUpdatedAt;return k.current=!0,!_&&D.current&&(O("conflict"),M.current(N??A.current)),"conflict"}return!_&&D.current&&(O("error"),u.current(X.message)),"error"}k.current=!1,A.current=Z.updateNote.updatedAt;const K=!_&&D.current,ne=T.notes.detail(t);await c.cancelQueries({queryKey:ne,exact:!0}),K&&L.current(Z.updateNote.updatedAt),c.setQueryData(ne,X=>X&&{...X,title:Z.updateNote.title,content:$.content,...$.layout?{layout:$.layout}:{},updatedAt:Z.updateNote.updatedAt}),ve({noteId:t,updatedAt:Z.updateNote.updatedAt,editSessionId:i.current});const I=m.current;return I?.baseUpdatedAt===$.baseUpdatedAt?(m.current={...I,baseUpdatedAt:Z.updateNote.updatedAt},re()):I||Le(t),K&&(m.current?v("pending"):(v("saved"),c.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.graph(),exact:!0}))),m.current||x.current?Q({silent:_}):"saved"})();return j.current=U,U},[F,i,t,re,c,O]),f=a.useCallback((R,_={})=>{if(m.current=R,Fe(t,R),k.current){O("conflict");return}if(O("pending"),F(),_.immediate){Q();return}g.current=window.setTimeout(()=>{Q()},Gr)},[F,Q,t,O]),E=a.useCallback(R=>{if(m.current=R,Fe(t,R),B(null),R.baseUpdatedAt!==A.current){W(A.current);return}f(R)},[t,f,W]),w=a.useCallback(()=>{F(),m.current=null,j.current=null,x.current=!1,k.current=!1,Le(t),B(null),v("saved")},[F,t]),V=a.useCallback(()=>{F(),j.current=null,x.current=!1,k.current=!1,O(m.current?"pending":"saved")},[F,O]),Ne=a.useCallback(()=>{Le(t),B(null)},[t]),le=a.useCallback(()=>m.current,[]),Ce=a.useCallback(R=>{F(),W(R)},[F,W]);return a.useEffect(()=>{M.current=o,u.current=p,L.current=d},[o,p,d]),a.useEffect(()=>(D.current=!0,()=>{D.current=!1}),[]),a.useEffect(()=>{m.current||C.current||k.current||(A.current=n,v("saved"))},[n]),a.useEffect(()=>{m.current=null,C.current=!1,j.current=null,x.current=!1,k.current=!1,A.current=n,B(Wr(t)),v("saved")},[t]),a.useEffect(()=>{const R=_=>{!m.current&&!C.current&&!k.current||(_.preventDefault(),_.returnValue="")};return window.addEventListener("beforeunload",R),()=>{window.removeEventListener("beforeunload",R)}},[]),a.useEffect(()=>()=>{F(),m.current&&!k.current&&Q({silent:!0})},[F,Q]),{saveStatus:y,localDraft:P,serverUpdatedAtRef:A,hasUnsavedChanges:y!=="saved",buildDraft:Y,queueSave:f,flushPendingSave:Q,restoreLocalDraft:E,discardLocalDraft:Ne,clearDrafts:w,resolveConflict:V,pauseForConflict:Ce,getPendingDraft:le,setServerUpdatedAt:J}}const en=/[:{}[\],&*#?|<>=!%@`-]/,tn=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",an=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),ge=t=>t?en.test(t)||/^\s|\s$/.test(t)?JSON.stringify(t):t:'""',we=t=>{if(!t)return;const r=Number(t);return Number.isFinite(r)?new Date(r).toISOString():t},Ve=(t,r)=>`${tn(t)}.${r}`,rn=({id:t,title:r,createdAt:n,updatedAt:i})=>{const s=["---",`title: ${ge(r)}`,`note_id: ${ge(t)}`],d=we(n),o=we(i);return d&&s.push(`created_at: ${ge(d)}`),o&&s.push(`updated_at: ${ge(o)}`),s.push("source: ocean-brain","---"),s.join(`
3
- `)},nn=(t,r,n=!1)=>n?`${rn(r)}
4
-
5
- ${t}`:t,sn=(t,r,{includeMetadata:n=!1,mode:i="fragment"}={})=>{const s=n?`<!--
6
- source: ocean-brain
7
- note_id: ${r.id}
8
- title: ${r.title}
9
- created_at: ${we(r.createdAt)??""}
10
- updated_at: ${we(r.updatedAt)??""}
11
- -->
12
- `:"";return i==="fragment"?`${s}${t}`:`<!doctype html>
13
- <html lang="ko">
14
- <head>
15
- <meta charset="utf-8" />
16
- <meta name="viewport" content="width=device-width, initial-scale=1" />
17
- <title>${an(r.title)}</title>
18
- </head>
19
- <body>
20
- ${s}${t}
21
- </body>
22
- </html>`},Pe=(t,r,n)=>{const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=r,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(s)},At=Ra(be),pe=t=>{const r=/^\d+$/.test(t)?Number(t):Date.parse(t);return Number.isFinite(r)?r:null},Oe=t=>{const r=pe(t);return G(r??Number(t)).format("YYYY-MM-DD HH:mm:ss")},on=(t,r)=>Ta(pe(t),r),_e=()=>ur(),ln="NOTE_UPDATE_CONFLICT",cn=2200,dn=t=>t?.extensions?.currentUpdatedAt,ct=(t,r)=>{const n=pe(t),i=pe(r);return n===null||i===null?t===r?0:1:n-i},un=t=>{const r=t.trim();if(!r)return null;try{const n=new URL(r);return n.protocol==="http:"||n.protocol==="https:"?n.toString():null}catch{return null}},pn={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},fn=e.jsx(We,{title:"Loading note",variant:"none",children:e.jsxs("main",{className:"mx-auto max-w-[896px]",children:[e.jsx(se,{className:"mb-8",height:123}),e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(se,{height:135}),e.jsx(se,{className:"ml-12",height:320}),e.jsx(se,{height:107}),e.jsx(se,{height:100})]})]})}),mn=t=>({id:t?.key??"",key:t?.key??"",name:t?.name??"",value:t?.value??"",valueType:t?.valueType??"text",persistedKey:t?.key}),hn=t=>{if(Array.isArray(t))return t;const r=t?.keys;return Array.isArray(r)?r:[]},Be=(t=[])=>t.map(mn),St=(t,r)=>{const n=[],i=new Set(r);for(const s of t){const d=s.key.trim();if(!d)continue;const o=s.value.trim(),p=!!s.persistedKey&&(s.valueType==="number"||s.valueType==="date"||s.valueType==="select"||s.valueType==="url");if(!o&&p){i.add(s.persistedKey);continue}!o&&s.valueType!=="text"&&s.valueType!=="boolean"||n.push({key:d,name:s.name.trim()||d,value:s.valueType==="boolean"?o||"false":o,valueType:s.valueType})}return{set:n.sort((s,d)=>s.key.localeCompare(d.key)),deleteKeys:Array.from(i).sort()}},ie=(t,r=[])=>JSON.stringify(St(t,r)),xn=({noteId:t,properties:r=[],expectedUpdatedAt:n,editSessionId:i,disabled:s,onSaved:d})=>{const o=Ye(),p=je(),[c,g]=a.useState(()=>Be(r)),[m,C]=a.useState([]),[j,x]=a.useState("idle"),A=a.useRef(c),k=a.useRef(m),D=a.useRef(n),L=a.useRef(ie(c)),M=a.useRef(null),u=a.useRef(!1),y=a.useRef(!1),v=ye({queryKey:T.notes.propertyKeys({limit:50}),queryFn:async()=>{const f=await Ma({limit:50});if(f.type==="error")throw f;return f.notePropertyKeys.keys}});a.useEffect(()=>{const f=Be(r);g(f),C([]),L.current=ie(f),x("idle")},[r]),a.useEffect(()=>{A.current=c},[c]),a.useEffect(()=>{k.current=m},[m]),a.useEffect(()=>{D.current=n},[n]);const P=hn(v.data),B=P.filter(f=>!c.some(E=>E.key===f.key)),F=P.length>0,O=a.useCallback(async()=>{const f=ie(A.current,k.current);if(s||f===L.current)return;if(u.current){y.current=!0;return}const E=St(A.current,k.current);if(!(E.set.length===0&&E.deleteKeys.length===0)){u.current=!0,y.current=!1,x("saving");try{const w=await Da({id:t,set:E.set,deleteKeys:E.deleteKeys,editSessionId:i,expectedUpdatedAt:D.current});if(w.type==="error"){x("error"),o(w.errors[0]?.message??"Failed to save properties.");return}D.current=w.updateNoteProperties.updatedAt,L.current=ie(Be(w.updateNoteProperties.properties??[])),d(w.updateNoteProperties),p.invalidateQueries({queryKey:T.notes.propertyKeysAll(),exact:!1}),x("saved")}catch{x("error"),o("Failed to save properties.")}finally{u.current=!1,y.current&&(y.current=!1,O())}}},[s,i,t,d,p,o]);a.useEffect(()=>{if(M.current&&clearTimeout(M.current),!(s||ie(c,m)===L.current))return M.current=setTimeout(()=>{O()},500),()=>{M.current&&clearTimeout(M.current)}},[m,s,c,O]);const J=f=>{g(E=>[...E,{id:f.key,key:f.key,name:f.name,value:"",valueType:f.valueType,persistedKey:void 0}]),C(E=>E.filter(w=>w!==f.key))},Y=(f,E)=>{g(w=>w.map(V=>V.id===f?{...V,...E}:V))},re=f=>{f.persistedKey&&C(E=>[...new Set([...E,f.persistedKey])]),g(E=>E.filter(w=>w.id!==f.id))},W=ie(c,m)!==L.current,Q=s||!W&&j==="idle"?null:j==="saving"?"Saving...":j==="error"?"Save failed":W?"Waiting...":"Saved";return e.jsxs(Ge,{title:"Properties",icon:e.jsx($a,{className:"h-3.5 w-3.5"}),ariaLabel:"Note properties",action:e.jsxs(e.Fragment,{children:[Q&&e.jsx(h,{as:"span",variant:"micro",tone:j==="error"?"error":"tertiary",className:"px-1",children:Q}),F&&e.jsx(S,{asChild:!0,size:"sm",variant:"ghost",children:e.jsxs(Ke,{to:nt,search:{page:1},children:[e.jsx(Ba,{className:"h-3 w-3"}),"Manage"]})})]}),children:[c.length===0?e.jsx(h,{as:"p",variant:"label",tone:"tertiary",className:"px-1 py-2",children:"No properties yet."}):e.jsx("div",{className:"divide-y divide-border-subtle",children:c.map(f=>{const E=f.valueType==="url"?un(f.value):null;return e.jsxs("div",{className:"group grid gap-2 py-2 sm:grid-cols-[minmax(0,180px)_minmax(0,1fr)_auto] sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[e.jsx(h,{as:"span",variant:"label",tone:"secondary",className:"truncate",children:f.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:f.key})]}),f.valueType==="boolean"?e.jsxs(rt,{size:"sm",variant:"ghost",value:f.value||"false",disabled:s,onValueChange:w=>Y(f.id,{value:w}),children:[e.jsx(He,{value:"false",children:"False"}),e.jsx(He,{value:"true",children:"True"})]}):f.valueType==="select"?e.jsx(rt,{size:"sm",variant:"ghost",value:f.value,placeholder:"Select option",disabled:s,onValueChange:w=>Y(f.id,{value:w}),children:(P.find(w=>w.key===f.key)?.options??[]).map(w=>e.jsx(He,{value:w.value,children:w.label},w.id))}):f.valueType==="url"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx($e,{className:"min-w-0",size:"sm",variant:"ghost",type:"url","aria-label":"Property value",placeholder:"https://example.com",value:f.value,disabled:s,onChange:w=>Y(f.id,{value:w.target.value})}),E?e.jsx(S,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${f.name}`,className:"shrink-0 text-fg-tertiary",children:e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",title:E,children:e.jsx(jt,{className:"h-4 w-4"})})}):null]}):e.jsx($e,{size:"sm",variant:"ghost",type:f.valueType==="date"?"date":f.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:f.value,disabled:s,onChange:w=>Y(f.id,{value:w.target.value})}),e.jsx(S,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${f.name}`,disabled:s,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>re(f),children:e.jsx(Ha,{className:"h-4 w-4"})})]},f.id)})}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:v.isLoading?e.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):B.length>0?e.jsxs(Fa,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{type:"button",size:"sm",variant:"ghost",disabled:s,children:[e.jsx(ze,{className:"h-4 w-4"}),"Add property"]})}),e.jsxs(Va,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[e.jsx(Pa,{children:e.jsx(h,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),e.jsx(Oa,{}),B.map(f=>e.jsxs(_a,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>J(f),children:[e.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[e.jsx(h,{as:"span",variant:"label",weight:"medium",className:"truncate",children:f.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:f.valueType})]}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:f.key})]},f.key))]})]}):F?e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):e.jsxs(Ke,{to:nt,search:{page:1},className:"focus-ring-soft inline-flex items-center gap-2 rounded-[12px] px-2.5 py-1.5 text-sm font-medium text-fg-secondary outline-none hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(ze,{className:"h-4 w-4"}),"Create property definition"]})})]})};function gn({id:t}){const r=Ye(),n=At.useNavigate(),i=je(),s=a.useRef(null),d=a.useRef(null),o=a.useRef(_e()),p=pt({queryKey:T.notes.detail(t),queryFn:async()=>{const l=await Na(t);if(l.type==="error")throw l;return l.note},gcTime:0}),c=p.data,[g,m]=a.useState(c.title),[C,j]=a.useState(()=>Oe(c.updatedAt)),[x,A]=a.useState(c.updatedAt),[k,D]=a.useState(()=>Date.now()),[L,M]=a.useState(c.pinned),[u,y]=a.useState(c.layout||"wide"),[v,P]=a.useState(!1),[B,F]=a.useState(!1),[O,J]=a.useState(!1),[Y,re]=a.useState("markdown"),[W,Q]=a.useState(!1),[f,E]=a.useState("fragment"),[w,V]=a.useState(null),[Ne,le]=a.useState(null),[Ce,R]=a.useState(0),[_,$]=a.useState(!1),U=a.useRef(c.updatedAt),Z=a.useRef(t),K=a.useRef(null),ne=a.useRef(!1),I=a.useCallback(l=>{j(Oe(l)),A(l),D(Date.now())},[]),X=Xr({noteId:t,initialContent:c.content,initialUpdatedAt:c.updatedAt,editSessionIdRef:o,getContent:()=>s.current?.getContent(),onSaved:l=>{K.current=null,U.current=l,I(l),$(!0)},onConflict:l=>{V({type:"updated",updatedAt:l,source:"unknown"}),r("This note changed elsewhere. Choose how to resolve the draft.")},onError:r}),{saveStatus:N,localDraft:ee,serverUpdatedAtRef:te,hasUnsavedChanges:ce,buildDraft:me,queueSave:he,flushPendingSave:xe,restoreLocalDraft:Rt,discardLocalDraft:Tt,clearDrafts:ke,resolveConflict:Et,pauseForConflict:de,getPendingDraft:Ae,setServerUpdatedAt:ae}=X,Mt=a.useCallback(async()=>{if(ne.current)return ne.current=!1,!1;if(N==="conflict")return r("Resolve the note conflict before leaving."),!0;const l=await xe();return l==="error"?(r("Save failed. Stay on this note and try again."),!0):l==="conflict"},[xe,N,r]);Ga({disabled:N==="saved",enableBeforeUnload:!1,shouldBlockFn:Mt}),a.useEffect(()=>{if(ce){c.updatedAt!==te.current&&ct(c.updatedAt,te.current)>0&&de(c.updatedAt);return}const l=U.current;if(!(c.updatedAt!==l&&ct(c.updatedAt,l)<0)&&(M(c.pinned),y(c.layout||"wide"),ae(c.updatedAt),m(c.title),I(c.updatedAt),l!==c.updatedAt)){const b=s.current?.getContent();U.current=c.updatedAt,(b===void 0||b!==c.content)&&(le(null),R(z=>z+1))}},[ce,c.layout,c.pinned,c.title,c.updatedAt,de,te,ae,I]),a.useEffect(()=>{Z.current!==t&&(Z.current=t,o.current=_e(),U.current=c.updatedAt,K.current=null,V(null),le(null),R(l=>l+1),$(!1))},[t,c.updatedAt]),a.useEffect(()=>{if(N!=="saved")return;const l=window.setTimeout(()=>{D(Date.now())},Ca(pe(x),k));return()=>window.clearTimeout(l)},[x,k,N]),a.useEffect(()=>{if(!_)return;const l=window.setTimeout(()=>{$(!1)},cn);return()=>window.clearTimeout(l)},[_]),a.useEffect(()=>{w?.type!=="updated"||N==="conflict"||w.updatedAt!==c.updatedAt||(U.current=c.updatedAt,ae(c.updatedAt),I(c.updatedAt),V(null))},[w,c.updatedAt,N,ae,I]),a.useEffect(()=>ka(l=>{if(l.noteId===t&&!(l.source==="web"&&l.editSessionId===o.current)){if(l.type==="mcp.note.updated"||l.type==="web.note.updated"){if(l.updatedAt===c.updatedAt||l.updatedAt===te.current)return;if(ce){de(l.updatedAt),V({type:"updated",updatedAt:l.updatedAt,source:l.source});return}V({type:"updated",updatedAt:l.updatedAt,source:l.source});return}l.type==="mcp.note.deleted"&&V({type:"deleted",source:l.source})}}),[ce,t,c.updatedAt,de,te]);const{onCreate:Dt,onDelete:Ht,onPinned:Ft,deleteWarningDialog:Lt}=Aa(),Vt=()=>{he(me(g))},Pt=l=>{m(l),he(me(l))},Xe=()=>{he(me(g),{immediate:!0})},Ot=async l=>{if(ce){y(l),he(me(g,{layout:l}),{immediate:!0}),r("Layout will be saved with your draft.");return}const b=await Ie({id:t,layout:l,editSessionId:o.current,expectedUpdatedAt:te.current});if(b.type==="error"){b.errors[0].code===ln&&(K.current=l,y(l),de(dn(b.errors[0].details)??te.current)),r(b.errors[0].message);return}K.current=null,await i.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=b.updateNote.updatedAt,ae(b.updateNote.updatedAt),i.setQueryData(T.notes.detail(t),z=>z&&{...z,layout:l,updatedAt:b.updateNote.updatedAt}),ve({noteId:t,updatedAt:b.updateNote.updatedAt,editSessionId:o.current}),I(b.updateNote.updatedAt),y(l),r("Layout has been updated.")},_t=()=>({id:t,title:g,createdAt:c.createdAt,updatedAt:te.current||c.updatedAt}),Bt=async()=>{const l=s.current?.getMarkdown();if(l===void 0){r("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(l),r("Copied note as Markdown.")}catch{r("Failed to copy Markdown.")}},$t=()=>{const l=s.current?.getMarkdown();if(l===void 0){r("Markdown is not ready yet.");return}try{Pe(l,Ve(g,"md"),"text/markdown;charset=utf-8"),r("Downloaded note as Markdown.")}catch{r("Failed to download Markdown.")}},It=()=>{const l=_t();try{if(Y==="markdown"){const b=s.current?.getMarkdown();if(b===void 0){r("Markdown is not ready yet.");return}Pe(nn(b,l,W),Ve(g,"md"),"text/markdown;charset=utf-8")}else{const b=s.current?.getHtml();if(b===void 0){r("HTML is not ready yet.");return}Pe(sn(b,l,{includeMetadata:W,mode:f}),Ve(g,"html"),"text/html;charset=utf-8")}J(!1),r("Downloaded note.")}catch{r("Failed to download note.")}},Ut=async()=>{const l=await p.refetch();if(l.error||!l.data){r("Failed to reload the latest note state.");return}ke(),K.current=null,U.current=l.data.updatedAt,ae(l.data.updatedAt),m(l.data.title),y(l.data.layout||"wide"),I(l.data.updatedAt),le(null),R(b=>b+1),V(null)},Zt=async()=>{if(Ae()){K.current=null,V(null),await xe({ignoreConflict:!0});return}const b=K.current;if(b){const z=await Ie({id:t,layout:b,editSessionId:o.current,force:!0});if(z.type==="error"){r(z.errors[0].message);return}K.current=null,await i.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=z.updateNote.updatedAt,Et(),V(null),ae(z.updateNote.updatedAt),i.setQueryData(T.notes.detail(t),Ee=>Ee&&{...Ee,layout:b,updatedAt:z.updateNote.updatedAt}),ve({noteId:t,updatedAt:z.updateNote.updatedAt,editSessionId:o.current}),I(z.updateNote.updatedAt),y(b);return}V(null),await xe({ignoreConflict:!0})},et=async()=>{const l=Ae();if(!l)return;const b=await Ea({title:at(l.title||"untitled"),content:at(l.content),layout:l.layout??u});if(b.type==="error"){r(b.errors[0].message);return}ne.current=!0,K.current=null,V(null),ke(),Promise.resolve(n({to:be,params:{id:b.createNote.id}})).finally(()=>{ne.current=!1})},Kt=()=>{ee&&(m(ee.title),ee.layout&&y(ee.layout),le(ee.content),R(l=>l+1),Rt(ee))},zt=()=>{Tt()},qt=ee?G(ee.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,Se=N==="saved"&&_,Qt=on(x,k),Yt=Oe(c.createdAt),Wt=N==="pending"?"Saving...":N==="saving"?"Saving now...":N==="error"?"Save failed. Try again.":N==="conflict"?"Save paused: changed elsewhere":`Saved ${Qt}`,Gt=q("inline-flex items-center gap-2 transition-colors",N==="saved"&&!Se&&"text-fg-secondary",Se&&"text-accent-success",(N==="pending"||N==="saving")&&"text-fg-default",(N==="error"||N==="conflict")&&"text-fg-error"),Re=q("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(N==="pending"||N==="saving")&&"save-progress-ring-active",N==="saved"&&Se&&"save-progress-ring-complete",(N==="error"||N==="conflict")&&"save-progress-ring-error"),Jt=N==="saving"?e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="pending"?e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="error"||N==="conflict"?e.jsx(Ia,{className:"h-3.5 w-3.5",weight:"fill"}):e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}),Xt=e.jsxs(h,{as:"span",variant:"label",weight:"medium",className:Gt,role:"status","aria-live":"polite",title:C,children:[Jt,Wt]}),Te=N==="conflict"&&w?.type==="updated",ea=Te?Ae():null,ta=w!==null&&!(w.type==="updated"&&!Te&&w.updatedAt===c.updatedAt);return e.jsx(We,{title:g,variant:"none",children:e.jsxs("main",{className:q("mx-auto",pn[u]),children:[e.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-5",children:[e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),e.jsx("input",{ref:d,placeholder:"Title",className:"text-heading sm:text-display w-full bg-transparent font-semibold leading-[1.25] tracking-[-0.02em] outline-none",type:"text",value:g,onChange:l=>Pt(l.target.value)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(mt,{button:e.jsx(ht,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:Bt},{name:"Download Markdown",onClick:$t},{name:"Download in another format",onClick:()=>J(!0)},{type:"separator",key:"export-separator"},{name:L?"Unpin":"Pin",onClick:()=>Ft(t,L,()=>{M(l=>!l)})},{name:"Change layout",onClick:()=>P(!0)},{type:"separator"},{name:"Clone this note",onClick:()=>Dt(d.current?.value||"untitled",s.current?.getContent()||"",u)},{name:"Restore previous version",onClick:()=>F(!0)},{type:"separator"},{name:"Delete",onClick:()=>Ht(t,()=>{n({to:tt,search:{page:1}})})}]}),e.jsx(S,{size:"sm",variant:"subtle",isLoading:N==="saving",disabled:N==="conflict",onClick:Xe,children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-t border-border-subtle/80 pt-3",children:[L&&e.jsxs(h,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[e.jsx(Sa,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),L&&e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),Xt,e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsxs(h,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",Yt]})]})]})}),ee&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["A draft from ",qt," is saved only in this browser."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Kt,children:"Restore draft"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:zt,children:"Discard"})]})]})}),N==="error"&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Xe,children:"Retry save"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:()=>{et()},children:"Save as new note"})]})]})}),e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(xn,{noteId:t,properties:c.properties,expectedUpdatedAt:te.current,editSessionId:o.current,disabled:N!=="saved",onSaved:l=>{U.current=l.updatedAt,ae(l.updatedAt),I(l.updatedAt),$(!0),i.setQueryData(T.notes.detail(t),b=>b&&{...b,updatedAt:l.updatedAt,properties:l.properties}),ve({noteId:t,updatedAt:l.updatedAt,editSessionId:o.current})}}),e.jsx(Yr,{ref:s,content:Ne??c.content,currentNoteId:t,onChange:Vt},`${t}:${Ce}`),e.jsx(Ue,{fallback:e.jsx(se,{height:107}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:l,retry:b})=>e.jsx(Ze,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:l,onRetry:b,showBackAction:!1,showHomeAction:!1}),children:e.jsx(fr,{noteId:t})}),e.jsx(Ue,{fallback:e.jsx(se,{height:100}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:l,retry:b})=>e.jsx(Ze,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:l,onRetry:b,showBackAction:!1,showHomeAction:!1}),children:e.jsx(cr,{noteId:t,render:l=>l&&l.length>0&&e.jsx(Ge,{icon:e.jsx(jt,{className:"h-3.5 w-3.5"}),title:"Back References",children:e.jsx("ul",{className:"flex flex-col",children:l.map(b=>e.jsx("li",{children:e.jsxs(Ke,{to:be,params:{id:b.id},className:"flex items-center gap-2 rounded-[10px] px-2.5 py-1.5 text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(ar,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(h,{as:"span",variant:"body",weight:"medium",className:"text-current",children:b.title})]})},b.id))})})})})]}),e.jsx(nr,{isOpen:v,onClose:()=>P(!1),onSave:Ot,currentLayout:u}),e.jsx(lr,{isOpen:ta,isDeleted:w?.type==="deleted",isConflict:Te,hasDraft:ea!==null,source:w?.source??"unknown",isReloading:p.isRefetching,onReload:Ut,onOverwrite:()=>{Zt()},onCloneDraft:()=>{et()},onOpenTrash:()=>n({to:tt,search:{page:1}})}),e.jsxs(H,{isOpen:O,onClose:()=>J(!1),variant:"compact",children:[e.jsx(H.Header,{title:"Download in another format",onClose:()=>J(!1)}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Format"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Markdown",description:"Good for GitHub, static blogs, and other note apps.",selected:Y==="markdown",onClick:()=>re("markdown")}),e.jsx(ue,{title:"HTML",description:"Good for web documents or CMS editors.",selected:Y==="html",onClick:()=>re("html")})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-[14px] border border-border-subtle bg-subtle/60 p-3",children:[e.jsx(ft,{size:"sm",checked:W,onChange:l=>Q(l.target.checked),className:"mt-0.5","aria-label":"Include metadata"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(h,{as:"span",variant:"body",weight:"semibold",children:"Include metadata"}),e.jsx(h,{as:"span",variant:"label",tone:"tertiary",children:"Add the title, note id, timestamps, and Ocean Brain source information."})]})]}),Y==="html"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"HTML style"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Content only",description:"Save only the note body HTML.",selected:f==="fragment",onClick:()=>E("fragment")}),e.jsx(ue,{title:"Full HTML document",description:"Save a complete HTML file that opens in a browser.",selected:f==="standalone",onClick:()=>E("standalone")})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>J(!1),children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:It,children:"Download"})]})})]}),e.jsx(ir,{isOpen:B,noteId:t,onClose:()=>F(!1),onRestored:l=>{o.current=_e(),ke(),K.current=null,U.current=l.updatedAt,V(null),ae(l.updatedAt),I(l.updatedAt)}}),Lt]})})}function Sn(){const{id:t}=At.useParams();if(!t)throw new Error("Note id is required.");return e.jsx(Ue,{fallback:fn,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[t],renderError:({error:r,retry:n})=>e.jsx(We,{title:"Note",variant:"none",children:e.jsx(Ze,{title:"Failed to load note",description:"Retry loading the note editor.",error:r,onRetry:n})}),children:e.jsx(gn,{id:t},t)})}export{gn as NoteContent,Sn as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./graph-vendor-CUxe67Lr.js";import{p as l}from"./index-jIfkRdY_.js";const r=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]),a=e.forwardRef((t,n)=>e.createElement(l,{ref:n,...t,weights:r}));a.displayName="PlusIcon";const c=a;export{c as n};
@@ -1 +0,0 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{v as k,T as h,L as H,N as M,D as E,l as L,d as x,a0 as S,P as v,J as O,a1 as C,i as o,j as U,a2 as I}from"./index-jIfkRdY_.js";import"./graph-vendor-CUxe67Lr.js";import{u as P,R as Y}from"./useReminderMutate-CDmIEwsw.js";import"./note-core-Z6kqulGB.js";const u={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function B({reminder:t,onUpdate:l,onDelete:g}){const f=y=>{const r=x(Number(y)),m=x();return r.isSame(m,"day")?`Today at ${r.format("HH:mm")}`:r.isSame(m.add(1,"day"),"day")?`Tomorrow at ${r.format("HH:mm")}`:r.format("YYYY-MM-DD HH:mm")},a=y=>{const r=x(Number(y)),m=x(),N=r.diff(m,"hour"),b=r.diff(m,"minute")%60;return N<0||b<0?"Overdue":N===0?`${b}m remaining`:`${N}h ${b}m remaining`},d=a(t.reminderDate)==="Overdue",i=t.priority||"low",s=i==="high"?"High":i==="medium"?"Medium":"Low",p=u[i],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",j=t.content?.trim()||t.note?.title||"Untitled reminder",R=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=a(t.reminderDate),$=f(t.reminderDate);return e.jsxs("div",{className:"surface-base flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[e.jsx(k,{checked:t.completed,onChange:()=>l(t.id,c,{completed:!t.completed}),size:"sm"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate line-through opacity-45":"truncate",children:j}),T&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate opacity-45":"mt-0.5 truncate",children:e.jsx(H,{to:M,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:R})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${p}`,"aria-label":`${s} priority`,title:`${s} priority`}),e.jsx(h,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"opacity-45":void 0,children:$}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",className:t.completed?"opacity-45":n,children:D})]}),e.jsx("div",{className:"flex items-center justify-end gap-1.5 sm:shrink-0",children:e.jsx(E,{button:e.jsx(L,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>g(t.id,c)}]})})]})}const w=U(I),A=[{label:"High",className:u.high},{label:"Medium",className:u.medium},{label:"Low",className:u.low}];function Q(){const t=w.useNavigate(),{page:l}=w.useSearch(),{onUpdate:g,onDelete:f}=P(),a=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:A.map(({label:i,className:s})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full border border-border-subtle ${s}`,"aria-hidden":"true"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:i})]},i))});return e.jsx(S,{fallback:e.jsx(v,{title:"Reminders",heading:e.jsx(o,{width:164,height:24,className:"rounded-full"}),description:e.jsx(o,{width:224,height:16,className:"rounded-full"}),headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"})]})}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the upcoming reminder list",resetKeys:[l,a],children:e.jsx(Y,{searchParams:{offset:(l-1)*a,limit:a},render:({reminders:i,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return i.length===0?e.jsx(v,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(O,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(v,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(n=>e.jsx(B,{reminder:n,onUpdate:g,onDelete:f},n.id))}),s&&a<s&&e.jsx(C,{page:l,last:Math.ceil(s/a),onChange:n=>{t({search:j=>({...j,page:n})})}})]})})}})})}export{Q as default};
@@ -1 +0,0 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{P as m,J as f,a0 as N,a9 as b,T as h,L as w,N as S,a1 as k,j as E,aa as $,i as d}from"./index-jIfkRdY_.js";import{a as R}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const L=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=L(r),n=new RegExp(`(${a})`,"gi"),c=new RegExp(`^${a}$`,"i"),l=t.split(n);return e.jsx("span",{children:l.map((i,o)=>c.test(i)?e.jsx("mark",{children:i},o):e.jsx(R.Fragment,{children:i},o))})},j=E($),v=180,x=t=>t.replace(/\s+/g," ").trim(),T=(t,s)=>{const r=x(t),a=x(s).toLowerCase();if(!a)return r;const n=r.toLowerCase().indexOf(a);if(n===-1)return r.length>v?`${r.slice(0,v-1).trimEnd()}…`:r;const c=Math.max(0,n-56),l=Math.min(r.length,n+a.length+84);let i=r.slice(c,l).trim();return c>0&&(i=`…${i}`),l<r.length&&(i=`${i}…`),i},A=t=>Array.isArray(t)?t.map(s=>{if(!s||typeof s!="object")return"";const r=s.text;return typeof r=="string"?r:""}).join(""):"",B=(t,s)=>t==="heading"?`Heading ${typeof s?.level=="number"?s.level:1}`:t==="bulletListItem"?"Bullet":t==="numberedListItem"?"Numbered":t==="checkListItem"?"Checklist":t==="quote"?"Quote":t==="codeBlock"?"Code":"Content",y=(t,s)=>{Array.isArray(t)&&t.forEach(r=>{if(!r||typeof r!="object")return;const a=typeof r.type=="string"?r.type:void 0,n=typeof r.props=="object"&&r.props?r.props:void 0,c=x(A(r.content));c&&s.push({label:B(a,n),text:c});const l=r.children;Array.isArray(l)&&y(l,s)})},C=(t,s)=>{try{const r=JSON.parse(t),a=[];if(y(r,a),a.length===0)return[];const n=x(s).toLowerCase(),c=n?a.filter(i=>i.text.toLowerCase().includes(n)):a;return(c.length>0?c:a).slice(0,2).map(i=>({...i,text:T(i.text,s)}))}catch{return[]}},P=t=>t===1?"1 result":`${t} results`,M=()=>"Open the note to inspect matching content.",z=(t,s)=>`${P(s)} for "${t}"`,I=()=>e.jsx(m,{title:"Search",variant:"default",description:e.jsx(d,{width:208,height:16,className:"rounded-full"}),children:e.jsx("main",{className:"flex flex-col gap-3",children:Array.from({length:2},(t,s)=>e.jsxs("div",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(d,{width:"34%",height:18,className:"rounded-full"}),e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{children:[e.jsx(d,{width:84,height:12,className:"rounded-full"}),e.jsx(d,{width:"100%",height:14,className:"mt-2 rounded-full"}),e.jsx(d,{width:"82%",height:14,className:"mt-1.5 rounded-full"})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-2",children:[e.jsx(d,{width:72,height:12,className:"rounded-full"}),e.jsx(d,{width:"94%",height:14,className:"mt-2 rounded-full"})]})]})})]},s))})});function F(){const t=j.useNavigate(),{page:s,query:r}=j.useSearch(),a=r.trim(),n=10;return a?e.jsx(N,{fallback:e.jsx(I,{}),errorTitle:"Failed to load search results",errorDescription:`Retry loading results for "${a}".`,resetKeys:[a,s],children:e.jsx(b,{searchParams:{query:a,limit:n,offset:(s-1)*n,fields:["content"]},render:({notes:c,totalCount:l})=>e.jsx(m,{title:"Search",description:z(a,l),variant:"default",children:e.jsxs("main",{className:"flex flex-col gap-4",children:[c.length>0?e.jsx("div",{className:"flex flex-col gap-3",children:c.map(i=>{const o=C(i.content,a);return e.jsxs("article",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(h,{as:"h2",variant:"body",weight:"semibold",tracking:"tight",children:e.jsx(w,{to:S,params:{id:i.id},className:"transition-colors hover:text-fg-default/85",children:e.jsx(g,{match:a,children:i.title||"Untitled"})})}),o.length>0?e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((u,p)=>e.jsxs("div",{className:p>0?"border-t border-border-subtle pt-2":void 0,children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"wider",transform:"uppercase",tone:"tertiary",children:u.label}),e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-1 leading-[1.65]",children:e.jsx(g,{match:a,children:u.text})})]},`${i.id}:${u.label}:${p}`))})}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"leading-[1.65]",children:M()})]},i.id)})}):e.jsx(f,{title:"No results found",description:"Try searching for a different word or phrase"}),l>n&&e.jsx(k,{page:s,last:Math.ceil(l/n),onChange:i=>{t({search:o=>({...o,page:i})})}})]})})})}):e.jsx(m,{title:"Search",description:"Search note titles and matching sections across your workspace",variant:"default",children:e.jsx("main",{children:e.jsx(f,{title:"Start searching",description:"Enter a keyword to look through note titles and matching content"})})})}export{F as default};
@@ -1 +0,0 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{a6 as g,z as p,q as m,a0 as u,ab as f,P as d,ac as h,L as j,ad as y,T as o,a1 as T,J as w,i as s,j as b,ae as v}from"./index-jIfkRdY_.js";import"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const N=r=>{const{data:i}=g({queryKey:m.tags.list(r.searchParams),async queryFn(){const a=await p({offset:r.searchParams.offset,limit:r.searchParams.limit});if(a.type==="error")throw a;return a.allTags}});return r.render(i)},E=f,c=b(v);function k(){const r=c.useNavigate(),{page:i}=c.useSearch(),a=E;return e.jsx("div",{children:e.jsx(u,{fallback:e.jsx(d,{title:"Tags",heading:e.jsx(s,{width:120,height:24,className:"rounded-full"}),description:e.jsx(s,{width:188,height:16,className:"rounded-full"}),children:e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(s,{width:"90px",height:"36px"}),e.jsx(s,{width:"120px",height:"36px"}),e.jsx(s,{width:"80px",height:"36px"}),e.jsx(s,{width:"100px",height:"36px"}),e.jsx(s,{width:"110px",height:"36px"}),e.jsx(s,{width:"70px",height:"36px"})]})}),errorTitle:"Failed to load tags",errorDescription:"Retry loading the tag catalog",resetKeys:[i,a],children:e.jsx(N,{searchParams:{offset:(i-1)*a,limit:a},render:({tags:l,totalCount:n})=>e.jsx(d,{title:"Tags",heading:n>0?`Tags (${n})`:void 0,description:"Browse the tags you added with @ across your notes",children:e.jsx(h,{fallback:e.jsx(w,{title:"No tags yet",description:"Add @tags inside notes and they will appear here"}),children:l.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2.5",children:l.map(t=>e.jsxs(j,{to:y,params:{id:t.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(o,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:t.name}),e.jsx(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"text-current/70",children:t.referenceCount})]},t.id))}),e.jsx(h,{fallback:null,children:n&&a<n&&e.jsx(T,{page:i,last:Math.ceil(n/a),onChange:t=>{r({search:x=>({...x,page:t})})}})})]})})})})})})}export{k as default};
@@ -1 +0,0 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{a6 as j,aL as p,q as y,av as N,a0 as P,P as c,ac as h,aM as T,a1 as v,J as q,i as d,j as w,ad as k}from"./index-jIfkRdY_.js";import"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const R=s=>{const{data:r}=j({queryKey:y.notes.tagList(s.searchParams),async queryFn(){const t=await p({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=w(k);function M(){const s=g.useNavigate(),{id:r}=g.useParams(),{page:t}=g.useSearch(),i=25,{onDelete:u,onPinned:m,deleteWarningDialog:x}=N();return e.jsxs(P,{fallback:e.jsx(c,{title:"Tagged Notes",heading:e.jsx(d,{width:148,height:24,className:"rounded-full"}),description:e.jsx(d,{width:196,height:16,className:"rounded-full"}),variant:"default",children:e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[e.jsx(d,{height:"112px"}),e.jsx(d,{height:"112px"}),e.jsx(d,{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:o,totalCount:n})=>{const l=o.flatMap(a=>a.tags).find(a=>a.id===r)?.name;return e.jsx(c,{title:l??"Tagged Notes",heading:l?n>0?`${l} (${n})`:l:"Tagged Notes",description:"Browse every note linked to this tag",variant:"default",children:e.jsx(h,{fallback:e.jsx(q,{title:"No tagged notes yet",description:"Notes tagged with this label will appear here"}),children:o.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-5",children:o.map(a=>e.jsx(T,{...a,onPinned:()=>m(a.id,a.pinned),onDelete:()=>u(a.id)},a.id))}),e.jsx(h,{fallback:null,children:n&&i<n&&e.jsx(v,{page:t,last:Math.ceil(n/i),onChange:a=>{s({search:f=>({...f,page:a})})}})})]})})})}}),x]})}export{M as default};
@@ -1 +0,0 @@
1
- import{a}from"./graph-vendor-CUxe67Lr.js";import{p as l}from"./index-jIfkRdY_.js";const r=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M117.18,188.74a12,12,0,0,1,0,17l-5.12,5.12A58.26,58.26,0,0,1,70.6,228h0A58.62,58.62,0,0,1,29.14,127.92L63.89,93.17a58.64,58.64,0,0,1,98.56,28.11,12,12,0,1,1-23.37,5.44,34.65,34.65,0,0,0-58.22-16.58L46.11,144.89A34.62,34.62,0,0,0,70.57,204h0a34.41,34.41,0,0,0,24.49-10.14l5.11-5.12A12,12,0,0,1,117.18,188.74ZM226.83,45.17a58.65,58.65,0,0,0-82.93,0l-5.11,5.11a12,12,0,0,0,17,17l5.12-5.12a34.63,34.63,0,1,1,49,49L175.1,145.86A34.39,34.39,0,0,1,150.61,156h0a34.63,34.63,0,0,1-33.69-26.72,12,12,0,0,0-23.38,5.44A58.64,58.64,0,0,0,150.56,180h.05a58.28,58.28,0,0,0,41.47-17.17l34.75-34.75a58.62,58.62,0,0,0,0-82.91Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M218.34,119.6,183.6,154.34a46.58,46.58,0,0,1-44.31,12.26c-.31.34-.62.67-.95,1L103.6,202.34A46.63,46.63,0,1,1,37.66,136.4L72.4,101.66A46.6,46.6,0,0,1,116.71,89.4c.31-.34.62-.67,1-1L152.4,53.66a46.63,46.63,0,0,1,65.94,65.94Z",opacity:"0.2"}),a.createElement("path",{d:"M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,7.78,8.22H152a8,8,0,0,0,8-7.78A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM115.7,192.49a43.31,43.31,0,0,1-55-66.43l25.37-25.37a43.35,43.35,0,0,1,61.25,0,42.9,42.9,0,0,1,9.95,15.43,8,8,0,1,1-15,5.6A27.33,27.33,0,0,0,97.37,112L72,137.37a27.32,27.32,0,0,0,34.68,41.91,8,8,0,1,1,9,13.21Zm79.61-62.55-25.37,25.37A43,43,0,0,1,139.32,168h0a43.35,43.35,0,0,1-40.53-28.12,8,8,0,1,1,15-5.6A27.35,27.35,0,0,0,139.28,152h0a27.14,27.14,0,0,0,19.32-8L184,118.63a27.32,27.32,0,0,0-34.68-41.91,8,8,0,1,1-9-13.21,43.32,43.32,0,0,1,55,66.43Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M238,88.18a52.42,52.42,0,0,1-15.4,35.66l-34.75,34.75A52.28,52.28,0,0,1,150.62,174h-.05A52.63,52.63,0,0,1,98,119.9a6,6,0,0,1,6-5.84h.17a6,6,0,0,1,5.83,6.16A40.62,40.62,0,0,0,150.58,162h0a40.4,40.4,0,0,0,28.73-11.9l34.75-34.74A40.63,40.63,0,0,0,156.63,57.9l-11,11a6,6,0,0,1-8.49-8.49l11-11a52.62,52.62,0,0,1,74.43,0A52.83,52.83,0,0,1,238,88.18Zm-127.62,98.9-11,11A40.36,40.36,0,0,1,70.6,210h0a40.63,40.63,0,0,1-28.7-69.36L76.62,105.9A40.63,40.63,0,0,1,146,135.77a6,6,0,0,0,5.83,6.16H152a6,6,0,0,0,6-5.84A52.63,52.63,0,0,0,68.14,97.42L33.38,132.16A52.63,52.63,0,0,0,70.56,222h0a52.26,52.26,0,0,0,37.22-15.42l11-11a6,6,0,1,0-8.49-8.48Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,16,.45A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M236,88.12a50.44,50.44,0,0,1-14.81,34.31l-34.75,34.74A50.33,50.33,0,0,1,150.62,172h-.05A50.63,50.63,0,0,1,100,120a4,4,0,0,1,4-3.89h.11a4,4,0,0,1,3.89,4.11A42.64,42.64,0,0,0,150.58,164h0a42.32,42.32,0,0,0,30.14-12.49l34.75-34.74a42.63,42.63,0,1,0-60.29-60.28l-11,11a4,4,0,0,1-5.66-5.65l11-11A50.64,50.64,0,0,1,236,88.12ZM111.78,188.49l-11,11A42.33,42.33,0,0,1,70.6,212h0a42.63,42.63,0,0,1-30.11-72.77l34.75-34.74A42.63,42.63,0,0,1,148,135.82a4,4,0,0,0,8,.23A50.64,50.64,0,0,0,69.55,98.83L34.8,133.57A50.63,50.63,0,0,0,70.56,220h0a50.33,50.33,0,0,0,35.81-14.83l11-11a4,4,0,1,0-5.65-5.66Z"}))]]),m=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,48H180V36A28,28,0,0,0,152,8H104A28,28,0,0,0,76,36V48H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V72h4a12,12,0,0,0,0-24ZM100,36a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4V48H100Zm88,168H68V72H188ZM116,104v64a12,12,0,0,1-24,0V104a12,12,0,0,1,24,0Zm48,0v64a12,12,0,0,1-24,0V104a12,12,0,0,1,24,0Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M200,56V208a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V56Z",opacity:"0.2"}),a.createElement("path",{d:"M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM112,168a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm0-120H96V40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,50H174V40a22,22,0,0,0-22-22H104A22,22,0,0,0,82,40V50H40a6,6,0,0,0,0,12H50V208a14,14,0,0,0,14,14H192a14,14,0,0,0,14-14V62h10a6,6,0,0,0,0-12ZM94,40a10,10,0,0,1,10-10h48a10,10,0,0,1,10,10V50H94ZM194,208a2,2,0,0,1-2,2H64a2,2,0,0,1-2-2V62H194ZM110,104v64a6,6,0,0,1-12,0V104a6,6,0,0,1,12,0Zm48,0v64a6,6,0,0,1-12,0V104a6,6,0,0,1,12,0Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,52H172V40a20,20,0,0,0-20-20H104A20,20,0,0,0,84,40V52H40a4,4,0,0,0,0,8H52V208a12,12,0,0,0,12,12H192a12,12,0,0,0,12-12V60h12a4,4,0,0,0,0-8ZM92,40a12,12,0,0,1,12-12h48a12,12,0,0,1,12,12V52H92ZM196,208a4,4,0,0,1-4,4H64a4,4,0,0,1-4-4V60H196ZM108,104v64a4,4,0,0,1-8,0V104a4,4,0,0,1,8,0Zm48,0v64a4,4,0,0,1-8,0V104a4,4,0,0,1,8,0Z"}))]]),n=a.forwardRef((e,t)=>a.createElement(l,{ref:t,...e,weights:r}));n.displayName="LinkIcon";const V=n,h=a.forwardRef((e,t)=>a.createElement(l,{ref:t,...e,weights:m}));h.displayName="TrashIcon";const Z=h;export{V as c,Z as n};
@@ -1 +0,0 @@
1
- import{j as t}from"./note-vendor-i1M2FSI2.js";import{P as m,J as C,a0 as K,i as r,j as D,V as I,k as M,av as O,a6 as S,q as u,ac as V,a1 as Q,aM as A,T as L,m as W}from"./index-jIfkRdY_.js";import{a as _}from"./graph-vendor-CUxe67Lr.js";import{B,f as J,i as U,V as z,a as x,d as G,u as H,e as X}from"./ViewSectionTableRenderer-BJwhd5be.js";import"./note-core-Z6kqulGB.js";const y=D(I);function Y(){const n=y.useNavigate(),l=M(),P=W(),{page:c,sectionId:o}=y.useSearch(),{onDelete:T,onPinned:q,deleteWarningDialog:F}=O(),[w,h]=_.useState(!1),i=25,{data:s}=S({queryKey:u.views.section(o),async queryFn(){const e=await B(o);if(e.type==="error")throw e;if(!e.viewSection)throw new Error("View section not found.");return e.viewSection}}),{data:a}=S({queryKey:u.views.sectionNotes(o,{limit:i,offset:(c-1)*i}),async queryFn(){const e=await J(o,{limit:i,offset:(c-1)*i});if(e.type==="error")throw e;return e.viewSectionNotes}}),p=s.title,d=s.tagNames,R=s.mode,g=s.propertyFilters,k=d.length>0,v=g.length>0,j=d.length>1?` · ${U(R)}`:"",E=k?v?`Property and tag filters${j}`:`Tag filters${j}`:v?"Property filters":"All notes",N=t.jsx(V,{fallback:null,children:a.totalCount&&i<a.totalCount&&t.jsx(Q,{page:c,last:Math.ceil(a.totalCount/i),onChange:e=>{n({search:f=>({...f,page:e})})}})}),$=async e=>{if(w)return;const f=s.sortBy===e?s.sortOrder==="asc"?"desc":"asc":e==="title"?"asc":"desc";h(!0);const b=await H(s.id,X(s,{sortBy:e,sortOrder:f}));if(b.type==="error"){P(b.errors[0]?.message??"Failed to update table sort."),h(!1);return}await l.invalidateQueries({queryKey:u.views.all(),exact:!1}),h(!1)};return t.jsxs(m,{title:p,heading:a.totalCount>0?`${p} (${a.totalCount})`:p,description:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(L,{as:"span",variant:"meta",tone:"tertiary",children:E}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[d.map(e=>t.jsx(x,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:e},e)),g.map(e=>t.jsx(x,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:G(e)},`${e.key}-${e.operator}-${e.value??""}`)),d.length===0&&g.length===0&&t.jsx(x,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:"All notes"})]})]}),children:[t.jsx(V,{fallback:t.jsx(C,{title:"No notes match this saved view",description:"Adjust this view's filters or keep writing until matching notes appear."}),children:a.notes.length>0&&s.displayType==="table"?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(z,{section:s,notes:a.notes,isPending:!1,isError:!1,onRetry:()=>{l.invalidateQueries({queryKey:u.views.sectionNotes(o,{limit:i,offset:(c-1)*i})})},onSortChange:$,isSortPending:w}),N]}):a.notes.length>0?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx("div",{className:"grid-auto-cards grid gap-5",children:a.notes.map(e=>t.jsx(A,{...e,onPinned:()=>q(e.id,e.pinned),onDelete:()=>T(e.id)},e.id))}),N]}):null}),F]})}function ie(){const{sectionId:n,page:l}=y.useSearch();return n?t.jsx(K,{fallback:t.jsx(m,{title:"View Notes",heading:t.jsx(r,{width:180,height:24,className:"rounded-full"}),description:t.jsx(r,{width:220,height:16,className:"rounded-full"}),children:t.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[t.jsx(r,{height:"112px"}),t.jsx(r,{height:"112px"}),t.jsx(r,{height:"112px"})]})}),errorTitle:"Failed to load view notes",errorDescription:"Retry loading notes for this saved view section",resetKeys:[l,n],children:t.jsx(Y,{})}):t.jsx(m,{title:"View Notes",description:"Saved view note lists require a section id.",children:t.jsx(C,{title:"No section selected",description:"Return to Views and open a section from there."})})}export{ie as default};
@@ -1,102 +0,0 @@
1
- import{h as d,c as w,a4 as D,T as c,B as E,N as f,L as O,t as y}from"./index-jIfkRdY_.js";import{j as r}from"./note-vendor-i1M2FSI2.js";import"./graph-vendor-CUxe67Lr.js";const x=`
2
- id
3
- tabId
4
- title
5
- displayType
6
- displayOptions {
7
- tableColumns
8
- }
9
- tagNames
10
- mode
11
- propertyFilters {
12
- key
13
- name
14
- valueType
15
- operator
16
- value
17
- }
18
- sortBy
19
- sortOrder
20
- limit
21
- order
22
- `;function Q(){return d(`query FetchViewWorkspace {
23
- viewWorkspace {
24
- activeTabId
25
- tabs {
26
- id
27
- title
28
- order
29
- sections {
30
- ${x}
31
- }
32
- }
33
- }
34
- }`)}function Y(e){return d(`query FetchViewSection($id: ID!) {
35
- viewSection(id: $id) {
36
- ${x}
37
- }
38
- }`,{id:e})}function G(e,{limit:t=25,offset:a=0}={}){return d(`query FetchViewSectionNotes($id: ID!, $pagination: PaginationInput) {
39
- viewSectionNotes(id: $id, pagination: $pagination) {
40
- totalCount
41
- notes {
42
- id
43
- title
44
- pinned
45
- tags {
46
- id
47
- name
48
- }
49
- createdAt
50
- updatedAt
51
- properties {
52
- key
53
- name
54
- value
55
- valueType
56
- option { id label value color order }
57
- createdAt
58
- updatedAt
59
- }
60
- }
61
- }
62
- }`,{id:e,pagination:{limit:t,offset:a}})}function J(e){return d(`mutation CreateViewTab($title: String!) {
63
- createViewTab(title: $title) {
64
- id
65
- }
66
- }`,{title:e})}function X(e,t){return d(`mutation UpdateViewTab($id: ID!, $title: String!) {
67
- updateViewTab(id: $id, title: $title) {
68
- id
69
- }
70
- }`,{id:e,title:t})}function Z(e){return d(`mutation DeleteViewTab($id: ID!) {
71
- deleteViewTab(id: $id)
72
- }`,{id:e})}function ee(e){return d(`mutation SetActiveViewTab($id: ID!) {
73
- setActiveViewTab(id: $id) {
74
- activeTabId
75
- tabs {
76
- id
77
- title
78
- order
79
- sections {
80
- ${x}
81
- }
82
- }
83
- }
84
- }`,{id:e})}function te(e){return d(`mutation ReorderViewTabs($tabIds: [ID!]!) {
85
- reorderViewTabs(tabIds: $tabIds) {
86
- id
87
- }
88
- }`,{tabIds:e})}function re(e,t){return d(`mutation CreateViewSection($tabId: ID!, $input: ViewSectionInput!) {
89
- createViewSection(tabId: $tabId, input: $input) {
90
- id
91
- }
92
- }`,{tabId:e,input:t})}function ae(e,t){return d(`mutation UpdateViewSection($id: ID!, $input: ViewSectionInput!) {
93
- updateViewSection(id: $id, input: $input) {
94
- id
95
- }
96
- }`,{id:e,input:t})}function se(e){return d(`mutation DeleteViewSection($id: ID!) {
97
- deleteViewSection(id: $id)
98
- }`,{id:e})}function ie(e,t){return d(`mutation ReorderViewSections($tabId: ID!, $sectionIds: [ID!]!) {
99
- reorderViewSections(tabId: $tabId, sectionIds: $sectionIds) {
100
- id
101
- }
102
- }`,{tabId:e,sectionIds:t})}const L={compact:"h-[22px] px-2",regular:"h-7 px-2.5"};function m({children:e,className:t,contentClassName:a,size:s="regular",truncateContent:i=!0,...l}){return r.jsx("span",{className:w("inline-flex min-w-0 items-center overflow-hidden whitespace-nowrap rounded-full border text-xs font-medium leading-none",L[s],t),...l,children:i?r.jsx("span",{className:w("min-w-0 truncate",a),children:e}):e})}const v=["title","tags","properties","createdAt","updatedAt"],ne={activeTabId:null,tabs:[]},W=e=>{const t=e.trim();return t?t.startsWith("@")?t:t.startsWith("#")?`@${t.slice(1)}`:`@${t}`:""},N=(e,t,a)=>{if(t===a)return e;const s=e.findIndex(u=>u.id===t),i=e.findIndex(u=>u.id===a);if(s<0||i<0)return e;const l=[...e],[h]=l.splice(s,1);return l.splice(i,0,h),l},oe=e=>{const t=e.flatMap(a=>typeof a=="string"?a.split(","):[]);return Array.from(new Set(t.map(W).filter(Boolean)))},de=e=>e.tabs.length===0?null:e.activeTabId?e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]??null:e.tabs[0]??null,le=(e,t)=>e.tabs.some(a=>a.id===t)?{...e,activeTabId:t}:e,ce=(e,t,a)=>({...e,tabs:N(e.tabs,t,a)}),ue=(e,t,a,s)=>({...e,tabs:e.tabs.map(i=>i.id===t?{...i,sections:N(i.sections,a,s)}:i)}),pe=e=>e==="or"?"OR — any selected tag":"AND — all selected tags",be=e=>e==="or"?"OR":"AND",k=e=>{switch(e){case"notEquals":return"is not";case"contains":return"contains";case"notContains":return"does not contain";case"before":return"before";case"after":return"after";case"exists":return"is set";case"notExists":return"is empty";default:return"is"}},me=e=>{switch(e){case"table":return"Table";case"calendar":return"Unavailable";default:return"List"}},B=e=>{switch(e){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},T=e=>{const t=new Set(v),a=(e??[]).filter(i=>t.has(i)),s=Array.from(new Set(a));return s.length===0?[...v]:s.includes("title")?s:["title",...s]},z=e=>({tableColumns:T(e?.tableColumns)}),he=e=>{const t=k(e.operator);return e.operator==="exists"||e.operator==="notExists"?`${e.name} ${t}`:`${e.name} ${t} ${e.value??""}`.trim()},xe=(e,t={})=>{const a={...e,...t};return{title:a.title,displayType:a.displayType,displayOptions:z(a.displayOptions),tagNames:a.tagNames,mode:a.mode,propertyFilters:a.propertyFilters.map(s=>({key:s.key,valueType:s.valueType,operator:s.operator,value:s.value})),sortBy:a.sortBy,sortOrder:a.sortOrder,limit:a.limit}},ge=e=>({page:1,sectionId:e.id}),_=e=>e.valueType==="select"?e.option?.label??e.value:e.valueType==="boolean"?e.value==="true"?"True":"False":e.value,F=e=>(e.properties??[]).slice(0,3),V={title:280,tags:190,properties:260,createdAt:132,updatedAt:132},P={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},j="flex h-[22px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",I="text-xs leading-5 text-fg-tertiary",R=e=>{const t=e.reduce((a,s)=>a+V[s],0);return Math.max(520,t)},q=(e,t={})=>{if(e.tags.length===0)return t.hideEmpty?null:r.jsx("span",{className:I,children:"—"});const a=e.tags.slice(0,3),s=e.tags.length-a.length;return r.jsxs("div",{className:j,children:[a.map(i=>r.jsx(m,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0&&r.jsxs(m,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]})]})},M=(e,t={})=>{const a=F(e);if(a.length===0)return t.hideEmpty?null:r.jsx("span",{className:I,children:"—"});const s=(e.properties?.length??0)-a.length;return r.jsxs("div",{className:j,children:[a.map(i=>r.jsxs(m,{size:"compact",truncateContent:!1,className:"max-w-[190px] shrink-0 gap-1 border-border-subtle bg-subtle text-fg-secondary",children:[r.jsx("span",{className:"min-w-0 max-w-[76px] shrink truncate text-fg-tertiary",children:i.name}),r.jsx("span",{className:"min-w-0 truncate",children:_(i)||"—"})]},i.key)),s>0&&r.jsxs(m,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]})]})};function we({section:e,notes:t,isPending:a,isError:s,onRetry:i,onSortChange:l,isSortPending:h}){const u=D(),p=T(e.displayOptions?.tableColumns),S=R(p),$=n=>{u({to:f,params:{id:n}})},A=n=>{const o=P[n],b=B(n),g=o?e.sortBy===o:!1;return r.jsx("th",{"aria-sort":g?e.sortOrder==="asc"?"ascending":"descending":void 0,className:"px-3 py-2.5 text-xs font-semibold text-fg-tertiary",children:o?r.jsxs("button",{type:"button",className:"focus-ring-soft -ml-1 inline-flex items-center gap-1 rounded-[8px] px-1 py-0.5 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-secondary disabled:cursor-wait disabled:opacity-60",disabled:h,onClick:()=>l(o),children:[r.jsx("span",{children:b}),r.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:g?e.sortOrder==="asc"?"↑":"↓":"↕"})]}):b},n)},C=(n,o)=>{switch(o){case"tags":return r.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:q(n)},o);case"properties":return r.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:M(n)},o);case"createdAt":return r.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:r.jsx(c,{as:"span",variant:"meta",tone:"tertiary",children:y(Number(n.createdAt))})},o);case"updatedAt":return r.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:r.jsx(c,{as:"span",variant:"meta",tone:"tertiary",children:y(Number(n.updatedAt))})},o);default:return r.jsx("td",{className:"px-3 py-2.5 align-middle",children:r.jsx(c,{as:"div",variant:"body",weight:"semibold",className:"line-clamp-1",children:r.jsx(O,{to:f,params:{id:n.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/85",onClick:b=>b.stopPropagation(),children:n.title||"Untitled"})})},o)}};return a?r.jsxs("div",{className:"overflow-hidden rounded-[16px] border border-border-subtle",children:[r.jsx("div",{className:"h-11 animate-pulse bg-hover-subtle"}),r.jsx("div",{className:"h-14 animate-pulse border-t border-border-subtle bg-elevated"}),r.jsx("div",{className:"h-14 animate-pulse border-t border-border-subtle bg-elevated"}),r.jsx("div",{className:"h-14 animate-pulse border-t border-border-subtle bg-elevated"})]}):s?r.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[r.jsx(c,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),r.jsx(c,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),r.jsx("div",{className:"mt-3",children:r.jsx(E,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Retry"})})]}):t.length===0?r.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[r.jsx(c,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),r.jsx(c,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):r.jsx("div",{className:"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated",children:r.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:S},children:[r.jsx("caption",{className:"sr-only",children:"View query results as a table"}),r.jsx("colgroup",{children:p.map(n=>r.jsx("col",{style:{width:V[n]}},n))}),r.jsx("thead",{className:"bg-subtle/80",children:r.jsx("tr",{className:"border-b border-border-subtle",children:p.map(A)})}),r.jsx("tbody",{className:"bg-elevated",children:t.map(n=>r.jsx("tr",{className:"h-12 cursor-pointer border-b border-border-subtle/70 transition-colors last:border-b-0 hover:bg-hover-subtle",onClick:()=>$(n.id),children:p.map(o=>C(n,o))},n.id))})]})})}export{se as A,Y as B,v as D,ne as E,we as V,m as a,ge as b,me as c,he as d,xe as e,G as f,be as g,k as h,pe as i,z as j,T as k,B as l,Q as m,oe as n,de as o,ee as p,te as q,ce as r,le as s,ue as t,ae as u,ie as v,J as w,X as x,Z as y,re as z};
@@ -1 +0,0 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as Ze,T as l,B as N,L as oe,N as Ye,t as Ge,k as Ee,u as ee,q as E,V as ce,D as De,l as Ae,m as Le,M as R,n as V,I as de,o as ue,r as J,v as Je,S as _,e as v,w as Xe,x as ze,y as et,z as tt,A as st,E as me,F as at,K as rt,G as nt,H as it,P as lt,i as re,J as pe,O as xe,Q as ot,R as he,U as ge,W as dt,X as ct,Y as ut,Z as Oe,_ as Re,c as te,$ as qe}from"./index-jIfkRdY_.js";import{a as i}from"./graph-vendor-CUxe67Lr.js";import{V as mt,b as pt,f as xt,g as ht,a as X,c as Ie,d as gt,u as Me,e as bt,n as be,h as ft,i as fe,j as vt,k as Pe,l as yt,D as jt,m as wt,o as Nt,E as Tt,s as St,p as Ct,r as kt,q as Vt,t as Ft,v as Et,w as Dt,x as At,y as Lt,z as zt,A as Ot}from"./ViewSectionTableRenderer-BJwhd5be.js";import{S as K}from"./SurfaceCard-CkAVMLPs.js";import{n as ne}from"./Plus.es-Dc_js8AC.js";import"./note-core-Z6kqulGB.js";const Rt=new Map([["bold",i.createElement(i.Fragment,null,i.createElement("path",{d:"M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z"}))],["duotone",i.createElement(i.Fragment,null,i.createElement("path",{d:"M216,128l-72,72V56Z",opacity:"0.2"}),i.createElement("path",{d:"M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z"}))],["fill",i.createElement(i.Fragment,null,i.createElement("path",{d:"M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z"}))],["light",i.createElement(i.Fragment,null,i.createElement("path",{d:"M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z"}))],["regular",i.createElement(i.Fragment,null,i.createElement("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"}))],["thin",i.createElement(i.Fragment,null,i.createElement("path",{d:"M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z"}))]]),_e=i.forwardRef((t,n)=>i.createElement(Ze,{ref:n,...t,weights:Rt}));_e.displayName="ArrowRightIcon";const qt=_e,It="flex items-start justify-between gap-3 rounded-[14px] border border-border-subtle/70 px-3 py-2.5 transition-colors hover:border-border-secondary hover:bg-hover-subtle";function Mt({notes:t,isPending:n,isError:r,onRetry:p}){return n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-14 animate-pulse rounded-[14px] bg-hover-subtle"}),e.jsx("div",{className:"h-14 animate-pulse rounded-[14px] bg-hover-subtle"}),e.jsx("div",{className:"h-14 animate-pulse rounded-[14px] bg-hover-subtle"})]}):r?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:p,children:"Retry"})})]}):t.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx(e.Fragment,{children:t.map(u=>e.jsxs(oe,{to:Ye,params:{id:u.id},className:It,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(l,{as:"div",variant:"body",weight:"semibold",className:"line-clamp-1",children:u.title||"Untitled"}),e.jsxs(l,{as:"div",variant:"meta",tone:"tertiary",className:"mt-1",children:["Updated ",Ge(Number(u.updatedAt))]})]}),e.jsx(qt,{className:"mt-0.5 h-4 w-4 shrink-0 text-fg-tertiary"})]},u.id))})}function Pt({onEdit:t}){return e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"This display type is unavailable"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Switch this section to List or Table to preview the saved query here."}),e.jsx("div",{className:"mt-3",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:t,children:"Change display"})})]})}function _t({section:t,notes:n,isPending:r,isError:p,onRetry:u,onEdit:x,onSortChange:b,isSortPending:g}){return t.displayType==="table"?e.jsx(mt,{section:t,notes:n,isPending:r,isError:p,onRetry:u,onSortChange:b,isSortPending:g}):t.displayType==="calendar"?e.jsx(Pt,{onEdit:x}):e.jsx(Mt,{notes:n,isPending:r,isError:p,onRetry:u})}function Wt({section:t,onEdit:n,onDelete:r,dragHandle:p}){const u=Ee(),x=Le(),[b,g]=i.useState(!1),F=pt(t),{data:T,isPending:q,isError:j,refetch:m}=ee({queryKey:E.views.sectionNotes(t.id,{limit:t.limit,offset:0}),async queryFn(){const h=await xt(t.id,{limit:t.limit,offset:0});if(h.type==="error")throw h;return h.viewSectionNotes}}),D=T?.notes??[],W=T?.totalCount??0,A=ht(t.mode),L=t.tagNames.length>0||t.propertyFilters.length>0,H=async h=>{if(b)return;const z=t.sortBy===h?t.sortOrder==="asc"?"desc":"asc":h==="title"?"asc":"desc";g(!0);const S=await Me(t.id,bt(t,{sortBy:h,sortOrder:z}));if(S.type==="error"){x(S.errors[0]?.message??"Failed to update table sort."),g(!1);return}await u.invalidateQueries({queryKey:E.views.all(),exact:!1}),g(!1)};return e.jsxs(K,{className:"flex h-full flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[p&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:p}),e.jsx("div",{className:"min-w-0",children:e.jsx(l,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx(oe,{to:ce,search:F,className:"truncate hover:text-fg-default/85",children:t.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:Ie(t.displayType)}),t.tagNames.map((h,z)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[z>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:A}),e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:h})]},h)),t.propertyFilters.map(h=>e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:gt(h)},`${h.key}-${h.operator}-${h.value??""}`)),!L&&e.jsx(X,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx("div",{className:"shrink-0",children:e.jsx(De,{button:e.jsx(Ae,{label:"Section actions"}),items:[{name:"Edit section",onClick:n},{type:"separator"},{name:"Delete section",onClick:r}]})})]}),e.jsx("div",{className:"flex flex-1 flex-col gap-2.5",children:e.jsx(_t,{section:t,notes:D,isPending:q,isError:j,onRetry:()=>{m()},onEdit:n,onSortChange:H,isSortPending:b})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle/70 pt-4",children:[e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:q?"Loading notes...":`Showing ${D.length} of ${W} notes`}),e.jsx(N,{asChild:!0,variant:"subtle",size:"sm",children:e.jsx(oe,{to:ce,search:F,children:"Open results"})})]})]})}const ie="__choose_property__",Ht=["title","tags","properties","createdAt","updatedAt"],ve=t=>String(t?.limit??5),ye=t=>t?.displayType==="table"?"table":"list",je=t=>Pe(t?.displayOptions?.tableColumns??jt),we=t=>t?.mode??"and",Ne=t=>t?t.tagNames.join(", "):"",Te=t=>t?.title??"",Se=t=>t?.sortBy??"updatedAt",Ce=t=>t?.sortOrder??"desc",We=t=>`property-filter-${Date.now()}-${t}`,ke=t=>(t?.propertyFilters??[]).map((n,r)=>({id:We(r),key:n.key,operator:n.operator,value:n.value??""})),Ve=t=>t?t.valueType==="date"||t.valueType==="number"?["equals","notEquals","before","after","exists","notExists"]:t.valueType==="text"||t.valueType==="url"?["equals","notEquals","contains","notContains","exists","notExists"]:["equals","notEquals","exists","notExists"]:["exists","notExists"],Fe=t=>t?"equals":"exists",$t=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",le=t=>t!=="exists"&&t!=="notExists",He=t=>t==="contains"||t==="notContains",Kt=(t,n)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!He(n)?"url":"text",Ut=(t,n)=>{if(t.valueType==="url")return He(n)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function Bt({open:t,mode:n,initialSection:r=null,availableTags:p,availableProperties:u,isTagsLoading:x=!1,isPropertiesLoading:b=!1,onClose:g,onSubmit:F}){const[T,q]=i.useState(Te(r)),[j,m]=i.useState(ye(r)),[D,W]=i.useState(je(r)),[A,L]=i.useState(Ne(r)),[H,h]=i.useState(we(r)),[z,S]=i.useState(Se(r)),[C,Y]=i.useState(Ce(r)),[U,G]=i.useState(ve(r)),[O,$]=i.useState(ke(r)),[se,B]=i.useState((r?.tagNames.length??0)>0),[Q,s]=i.useState(""),d=i.useMemo(()=>new Map(u.map(a=>[a.key,a])),[u]);i.useEffect(()=>{t&&(q(Te(r)),m(ye(r)),W(je(r)),L(Ne(r)),h(we(r)),S(Se(r)),Y(Ce(r)),G(ve(r)),$(ke(r)),B((r?.tagNames.length??0)>0),s(""))},[r,t]);const y=be([A]),w=se||y.length>0,I=y.length===0&&O.length===0,M=a=>{a!=="title"&&(W(c=>{if(c.includes(a)){const k=c.filter(o=>o!==a);return k.length>0?k:c}return Pe([...c,a])}),s(""))},$e=a=>{const c=y.includes(a)?y.filter(k=>k!==a):[...y,a];L(c.join(", ")),s("")},Ke=()=>{B(!0),s("")},Ue=()=>{L(""),h("and"),B(!1),s("")},Be=()=>{if(u.length===0){s("Create a shared property before adding a filter.");return}$(a=>[...a,{id:We(a.length),key:"",operator:"exists",value:""}]),s("")},Z=(a,c)=>{$(k=>k.map(o=>{if(o.id!==a)return o;const P={...o,...c},f=d.get(P.key);return Ve(f).includes(P.operator)||(P.operator=Fe(f)),"key"in c&&(P.value=$t(f),P.operator=Fe(f)),P})),s("")},Qe=a=>{$(c=>c.filter(k=>k.id!==a)),s("")};return e.jsxs(R,{isOpen:t,onClose:g,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(R.Header,{title:n==="create"?"Create view":"Edit view",onClose:g}),e.jsx(R.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:a=>{a.preventDefault();const c=be([A]);if(w&&c.length===0){s("Choose at least one tag, or remove this tag filter.");return}if(O.find(f=>!f.key||!d.has(f.key))){s("Choose a property for every filter.");return}const o=O.map(f=>{const ae=d.get(f.key);return{key:ae?.key??f.key,valueType:ae?.valueType??"text",operator:f.operator,value:le(f.operator)?f.value:null}});if(o.some(f=>le(f.operator)&&!f.value?.trim())){s("Fill every filter value, or switch it to is set / is empty.");return}F({title:T,displayType:j,displayOptions:vt({tableColumns:D}),tagNames:c,mode:H,propertyFilters:o,sortBy:z,sortOrder:C,limit:Number(U)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-title",size:"md",children:"View name"}),e.jsx(de,{id:"view-section-title",value:T,onChange:a=>q(a.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(V,{size:"md",children:"Display"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same query as a compact list or a table."})]}),e.jsx(l,{as:"span",variant:"meta",tone:"tertiary",children:Ie(j)})]}),e.jsxs(ue,{type:"single",value:j,onValueChange:a=>{(a==="list"||a==="table")&&m(a)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(J,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(J,{value:"table","aria-label":"Show as table",children:"Table"})]}),j==="table"?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/45 p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(V,{size:"sm",children:"Table columns"}),e.jsxs(l,{as:"span",variant:"meta",tone:"tertiary",children:[D.length," shown"]})]}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:Ht.map(a=>{const c=yt(a);return e.jsxs("div",{className:"flex items-center gap-2 rounded-[12px] border border-border-subtle bg-elevated px-3 py-2",children:[e.jsx(Je,{size:"sm",checked:D.includes(a),disabled:a==="title","aria-label":`Show ${c} column`,onChange:()=>M(a)}),e.jsx(l,{as:"span",variant:"label",tone:"secondary",children:c})]},a)})}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."})]}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 rounded-[20px] border border-border-subtle bg-subtle/40 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(V,{size:"md",children:"Filters"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Use properties for structured fields, and tags for loose topics or context."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{type:"button",variant:"subtle",size:"sm",onClick:Be,children:"Add property filter"}),!w&&e.jsx(N,{type:"button",variant:"subtle",size:"sm",onClick:Ke,children:"Add tag filter"})]})]}),O.length===0&&!w?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(l,{as:"p",variant:"label",tone:"default",children:I?"All notes":"No filters"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add a property filter, a tag filter, or leave this view open to all notes."})]}):null,O.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:O.map(a=>{const c=d.get(a.key),k=Ve(c);return e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-border-subtle bg-elevated p-3 md:grid-cols-[minmax(0,1fr)_minmax(10.5rem,12rem)_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs(_,{value:a.key||ie,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:o=>{o!==ie&&Z(a.id,{key:o})},children:[e.jsx(v,{value:ie,disabled:!0,children:"Choose property"}),u.map(o=>e.jsx(v,{value:o.key,children:o.name},o.key))]}),e.jsx(_,{value:a.operator,disabled:!c,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:o=>Z(a.id,{operator:o}),children:k.map(o=>e.jsx(v,{value:o,children:ft(o)},o))}),le(a.operator)&&c?c.valueType==="select"?e.jsx(_,{value:a.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:o=>Z(a.id,{value:o}),children:c.options.map(o=>e.jsx(v,{value:o.value,children:o.label},o.value))}):c.valueType==="boolean"?e.jsxs(_,{value:a.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:o=>Z(a.id,{value:o}),children:[e.jsx(v,{value:"true",children:"True"}),e.jsx(v,{value:"false",children:"False"})]}):e.jsx(de,{type:Kt(c,a.operator),value:a.value,onChange:o=>Z(a.id,{value:o.target.value}),placeholder:Ut(c,a.operator),"aria-label":"Property filter value"}):e.jsx(l,{as:"span",variant:"label",tone:"tertiary",children:c?"No value needed":"Choose a property first"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>Qe(a.id),children:"Remove"})]},a.id)})}):null,w?e.jsxs("div",{className:"flex flex-col gap-3 rounded-[16px] border border-border-subtle bg-elevated p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(l,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:Ue,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(Xe,{id:"view-section-tags",value:A,onChange:a=>{L(a.target.value),s("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"You can use tags only, properties only, both together, or no filters."})]}),y.length>1?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{size:"sm",children:"Tag match"}),e.jsxs(ue,{type:"single",value:H,onValueChange:a=>{(a==="and"||a==="or")&&h(a)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(J,{value:"and","aria-label":fe("and"),children:"AND"}),e.jsx(J,{value:"or","aria-label":fe("or"),children:"OR"})]}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"AND requires every selected tag. OR accepts any selected tag."})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(V,{size:"sm",children:"Existing tags"}),e.jsx(l,{as:"span",variant:"meta",tone:"tertiary",children:x?"Loading...":`${p.length} available`})]}),p.length>0?e.jsx("div",{className:"max-h-44 overflow-y-auto rounded-[16px] border border-border-subtle bg-hover-subtle/60 p-3",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(a=>{const c=y.includes(a.name);return e.jsx("button",{type:"button",className:`inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${c?"border-border-secondary bg-elevated text-fg-default":"border-border-subtle bg-transparent text-fg-secondary hover:border-border-secondary hover:bg-elevated hover:text-fg-default"}`,onClick:()=>$e(a.name),children:a.name},a.id)})})}):e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(l,{as:"p",variant:"meta",tone:Q?"default":"tertiary",className:Q?"text-fg-error":void 0,children:Q||(b||x?"Loading filter options...":`${u.length} properties · ${p.length} tags available`)})]}),e.jsxs("details",{className:"group rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(l,{as:"span",variant:"label",tone:"default",children:"Sort and limit"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Defaults to recently updated notes."})]}),e.jsxs(l,{as:"span",variant:"meta",tone:"tertiary",children:[U," notes"]})]})}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(_,{value:z,onValueChange:a=>S(a),children:[e.jsx(v,{value:"updatedAt",children:"Updated time"}),e.jsx(v,{value:"createdAt",children:"Created time"}),e.jsx(v,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(_,{value:C,onValueChange:a=>Y(a),children:[e.jsx(v,{value:"desc",children:"Descending"}),e.jsx(v,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-section-limit",size:"sm",children:"Max notes"}),e.jsxs(_,{value:U,onValueChange:G,children:[e.jsx(v,{value:"3",children:"3 notes"}),e.jsx(v,{value:"5",children:"5 notes"}),e.jsx(v,{value:"8",children:"8 notes"}),e.jsx(v,{value:"10",children:"10 notes"}),e.jsx(v,{value:"12",children:"12 notes"})]})]})]})]})]})}),e.jsx(R.Footer,{children:e.jsxs(ze,{children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:g,children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",form:"view-section-form",children:n==="create"?"Create view":"Save view"})]})})]})}function Qt({open:t,mode:n,initialTitle:r="",onClose:p,onSubmit:u}){const[x,b]=i.useState(r);return i.useEffect(()=>{t&&b(r)},[r,t]),e.jsxs(R,{isOpen:t,onClose:p,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(R.Header,{title:n==="create"?"Create view tab":"Rename view tab",onClose:p}),e.jsx(R.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:g=>{g.preventDefault(),u(x)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(V,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(de,{id:"view-tab-title",value:x,onChange:g=>b(g.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(R.Footer,{children:e.jsxs(ze,{children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:p,children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",form:"view-tab-form",children:n==="create"?"Create tab":"Save tab"})]})})]})}const Zt="Save reusable note queries with tags, shared properties, and sorting.",Yt="focus-ring-soft inline-flex h-8 w-8 items-center justify-center rounded-[10px] text-fg-default/70 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default touch-none",Gt="group relative -mb-px flex h-10 min-w-[92px] max-w-[118px] shrink-0 items-center gap-0.5 rounded-t-[12px] border border-b-0 px-1.5 transition-[background-color,border-color,color,box-shadow]",Jt="focus-ring-soft inline-flex min-w-0 flex-1 items-center gap-1 rounded-[9px] px-0.5 py-1.5 text-[13px] font-medium outline-none",Xt="focus-ring-soft inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[8px] text-current/55 outline-none transition-[background-color,color,opacity] hover:bg-hover-subtle hover:text-current touch-none",es="focus-ring-soft relative mb-0.5 inline-flex h-9 shrink-0 items-center gap-1 rounded-[10px] px-2.5 text-[13px] font-medium text-fg-secondary outline-none transition-colors hover:bg-hover-subtle/85 hover:text-fg-default",ts=({tab:t,isActive:n,onSelect:r})=>{const{attributes:p,listeners:u,setNodeRef:x,setActivatorNodeRef:b,transform:g,transition:F,isDragging:T}=Oe({id:t.id});return e.jsxs("div",{ref:x,style:{transform:qe.Translate.toString(g),transition:F,opacity:T?.6:1},className:te(Gt,n?"z-10 border-border-secondary/75 bg-elevated text-fg-default shadow-[0_10px_18px_-20px_rgba(15,18,24,0.24)]":"border-transparent bg-hover-subtle/45 text-fg-secondary hover:bg-hover-subtle/75 hover:text-fg-default"),children:[e.jsx("button",{type:"button",ref:b,"aria-label":`Reorder view tab ${t.title}`,...p,...u,className:te(Xt,T?"cursor-grabbing opacity-100":"cursor-grab opacity-70 group-hover:opacity-100"),children:e.jsx(Re,{className:"size-4"})}),e.jsxs("button",{type:"button",role:"tab","aria-selected":n,className:te(Jt,n?"text-fg-default":"text-fg-secondary group-hover:text-fg-default"),onClick:r,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.title}),e.jsx("span",{className:"inline-flex min-w-4 shrink-0 items-center justify-center rounded-full bg-hover-subtle/75 px-1 py-0 text-[10px] leading-4 text-current/70",children:t.sections.length})]})]})},ss=({section:t,onEdit:n,onDelete:r})=>{const{attributes:p,listeners:u,setNodeRef:x,setActivatorNodeRef:b,transform:g,transition:F,isDragging:T}=Oe({id:t.id});return e.jsx("div",{ref:x,style:{transform:qe.Translate.toString(g),transition:F,opacity:T?.6:1},children:e.jsx(Wt,{section:t,onEdit:n,onDelete:r,dragHandle:e.jsx("button",{type:"button",ref:b,"aria-label":`Reorder section ${t.title}`,...p,...u,className:te(Yt,T?"cursor-grabbing":"cursor-grab"),children:e.jsx(Re,{className:"size-4"})})})})};function cs(){const t=et(),n=Le(),r=Ee(),[p,u]=i.useState(null),[x,b]=i.useState(null),{data:g,isPending:F,isError:T,refetch:q}=ee({queryKey:E.views.workspace(),async queryFn(){const s=await wt();if(s.type==="error")throw s;return s.viewWorkspace}}),j=g??Tt,m=Nt(j),{data:D,isPending:W}=ee({queryKey:E.tags.list({limit:200}),async queryFn(){const s=await tt({limit:200});if(s.type==="error")throw s;return s.allTags}}),A=st(me(nt,{activationConstraint:{distance:8}}),me(rt,{coordinateGetter:at})),L=D?.tags??[],{data:H,isPending:h}=ee({queryKey:E.notes.propertyKeys({limit:100}),async queryFn(){const s=await it({limit:100});if(s.type==="error")throw s;return s.notePropertyKeys}}),z=H?.keys??[],S=s=>{r.setQueryData(E.views.workspace(),s)},C=async()=>{await r.invalidateQueries({queryKey:E.views.all(),exact:!1})},Y=async({active:s,over:d})=>{if(!d||s.id===d.id)return;const y=r.getQueryData(E.views.workspace())??j,w=kt(y,String(s.id),String(d.id));S(w);const I=await Vt(w.tabs.map(M=>M.id));if(I.type==="error"){S(y),n(I.errors[0].message);return}await C()},U=async({active:s,over:d})=>{if(!m||!d||s.id===d.id)return;const y=r.getQueryData(E.views.workspace())??j,w=Ft(y,m.id,String(s.id),String(d.id));S(w);const I=await Et(m.id,w.tabs.find(M=>M.id===m.id)?.sections.map(M=>M.id)??[]);if(I.type==="error"){S(y),n(I.errors[0].message);return}await C()},G=async s=>{const d=await Dt(s);if(d.type==="error"){n(d.errors[0].message);return}await C(),u(null)},O=async s=>{if(!m)return;const d=await At(m.id,s);if(d.type==="error"){n(d.errors[0].message);return}await C(),u(null)},$=async()=>{if(!m||!await t("Delete this view tab and all of its sections?"))return;const s=await Lt(m.id);if(s.type==="error"){n(s.errors[0].message);return}await C()},se=async s=>{if(!m)return;const d=await zt(m.id,s);if(d.type==="error"){n(d.errors[0].message);return}await C(),b(null)},B=async s=>{if(!m||!x||x.mode!=="edit")return;const d=await Me(x.section.id,s);if(d.type==="error"){n(d.errors[0].message);return}await C(),b(null)},Q=async s=>{if(!m||!await t("Delete this section from the current view tab?"))return;const d=await Ot(s);if(d.type==="error"){n(d.errors[0].message);return}await C()};return e.jsxs(e.Fragment,{children:[e.jsx(lt,{title:"Views",description:Zt,children:F&&!g?e.jsx(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(re,{height:20,width:180,className:"rounded-full"}),e.jsx(re,{height:16,width:260,className:"rounded-full"}),e.jsx(re,{height:44,width:140,className:"rounded-[12px]"})]})}):T?e.jsxs(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(l,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry loading your saved view tabs."}),e.jsx("div",{className:"mt-4",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{q()},children:"Retry"})})]}):j.tabs.length===0?e.jsxs(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(pe,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both."}),e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsxs(N,{type:"button",onClick:()=>u({mode:"create"}),children:[e.jsx(ne,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"border-b border-border-secondary/75",children:e.jsx(xe,{sensors:A,collisionDetection:he,modifiers:[ot],onDragEnd:Y,children:e.jsxs("div",{className:"flex items-end gap-1 overflow-x-auto overflow-y-hidden pb-px",children:[e.jsx(ge,{items:j.tabs.map(s=>s.id),strategy:dt,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 items-end gap-1",children:j.tabs.map(s=>e.jsx(ts,{tab:s,isActive:s.id===m?.id,onSelect:async()=>{const d=r.getQueryData(E.views.workspace())??j,y=St(d,s.id);S(y);const w=await Ct(s.id);if(w.type==="error"){S(d),n(w.errors[0].message);return}S(w.setActiveViewTab)}},s.id))})}),e.jsxs("button",{type:"button",className:es,onClick:()=>u({mode:"create"}),children:[e.jsx(ne,{className:"size-4"}),"Add tab"]})]})})}),m&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs(K,{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{as:"h2",variant:"heading",weight:"bold",tracking:"tight",children:m.title}),e.jsx(l,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:m.sections.length>0?`${m.sections.length} section${m.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs(N,{type:"button",size:"sm",onClick:()=>b({mode:"create"}),children:[e.jsx(ne,{className:"h-4 w-4"}),"Add section"]}),e.jsx(De,{button:e.jsx(Ae,{label:"View tab actions"}),items:[{name:"Rename",onClick:()=>u({mode:"edit",tab:m})},{type:"separator"},{name:"Delete tab",onClick:()=>{$()}}]})]})]}),m.sections.length===0?e.jsx(K,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsx(pe,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both."})}):e.jsx("div",{className:"flex flex-col",children:e.jsx(xe,{sensors:A,collisionDetection:he,modifiers:[ct],onDragEnd:U,children:e.jsx(ge,{items:m.sections.map(s=>s.id),strategy:ut,children:e.jsx("div",{className:"flex flex-col gap-4",children:m.sections.map(s=>e.jsx(ss,{section:s,onEdit:()=>b({mode:"edit",section:s}),onDelete:()=>{Q(s.id)}},s.id))})})})})]})]})}),e.jsx(Qt,{open:p!==null,mode:p?.mode??"create",initialTitle:p?.mode==="edit"?p.tab.title:"",onClose:()=>u(null),onSubmit:s=>{if(p?.mode==="edit"){O(s);return}G(s)}}),e.jsx(Bt,{open:x!==null,mode:x?.mode??"create",initialSection:x?.mode==="edit"?x.section:null,availableTags:L,availableProperties:z,isTagsLoading:W,isPropertiesLoading:h,onClose:()=>b(null),onSubmit:s=>{if(x?.mode==="edit"){B(s);return}se(s)}})]})}export{cs as default};
@@ -1,17 +0,0 @@
1
- import{aR as n,h as i}from"./index-jIfkRdY_.js";async function r({base64:a,externalSrc:e}){if(a){const{data:t}=await n.post("/api/image",{image:a});return t.url}if(e){const{data:t}=await n.post("/api/image-from-src",{src:e});return t.url}throw new Error("No file or src provided")}function u({limit:a=50,offset:e=0}={}){return i(`query FetchImages($pagination: PaginationInput) {
2
- allImages(pagination: $pagination) {
3
- totalCount
4
- images {
5
- id
6
- url
7
- referenceCount
8
- }
9
- }
10
- }`,{pagination:{limit:a,offset:e}})}function g(a){return i(`query FetchImage($id: ID!) {
11
- image(id: $id) {
12
- id
13
- url
14
- }
15
- }`,{id:a})}function m(a){return i(`mutation DeleteImage($id: ID!) {
16
- deleteImage(id: $id)
17
- }`,{id:a})}const s=r;export{g as a,m as d,u as f,s as u};