ocean-brain 0.11.0 → 0.12.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 (147) hide show
  1. package/package.json +1 -1
  2. package/server/client/dist/assets/ArrowRight.es-DZTjsBaI.js +1 -0
  3. package/server/client/dist/assets/AuxiliaryPanelHeader-Bp3iRjm6.js +1 -0
  4. package/server/client/dist/assets/Calendar-BLiViCGr.js +25 -0
  5. package/server/client/dist/assets/Callout-Cye6_6BM.js +1 -0
  6. package/server/client/dist/assets/CheckCircle.es-BTloiuti.js +1 -0
  7. package/server/client/dist/assets/Copy.es-CkLUgwY-.js +1 -0
  8. package/server/client/dist/assets/File.es-c83QExqr.js +1 -0
  9. package/server/client/dist/assets/FlowArrow.es-DWiIXWQG.js +1 -0
  10. package/server/client/dist/assets/Graph-jbPLcne9.js +46 -0
  11. package/server/client/dist/assets/Image.es-vY-nTyOe.js +1 -0
  12. package/server/client/dist/assets/Note-BTQLB80Y.js +25 -0
  13. package/server/client/dist/assets/{NotePropertiesPanel-aCKXAe5F.js → NotePropertiesPanel-uO-JKy19.js} +2 -2
  14. package/server/client/dist/assets/Plus.es-CaRgmXc_.js +1 -0
  15. package/server/client/dist/assets/Reminders-BAgZEUwV.js +1 -0
  16. package/server/client/dist/assets/Search-BxozUWkC.js +31 -0
  17. package/server/client/dist/assets/SurfaceCard-BAlcul6z.js +1 -0
  18. package/server/client/dist/assets/Tag-BhCf_mil.js +1 -0
  19. package/server/client/dist/assets/TagNotes-BIzhXqwp.js +1 -0
  20. package/server/client/dist/assets/Trash.es-prxIxo9c.js +1 -0
  21. package/server/client/dist/assets/ViewChip-Cq_YzRvB.js +1 -0
  22. package/server/client/dist/assets/Views-C26uWznP.js +1 -0
  23. package/server/client/dist/assets/{abnfDiagram-VRR7QNED-CWlV5dXw.js → abnfDiagram-VRR7QNED-2cuaaDg0.js} +1 -1
  24. package/server/client/dist/assets/app-CEkicO08.css +1 -0
  25. package/server/client/dist/assets/app-DbQdHfMb.js +139 -0
  26. package/server/client/dist/assets/{arc-BV-n6RUX.js → arc-Cr-oYJoQ.js} +1 -1
  27. package/server/client/dist/assets/{architectureDiagram-ZJ3FMSHR-CekzMXdu.js → architectureDiagram-ZJ3FMSHR-HF8-bEM0.js} +1 -1
  28. package/server/client/dist/assets/{blockDiagram-677ZJIJ3-B49yHoxq.js → blockDiagram-677ZJIJ3-evR8rlpQ.js} +1 -1
  29. package/server/client/dist/assets/{c4Diagram-LMCZKHZV-0AfB9NBC.js → c4Diagram-LMCZKHZV-zCjuWUmC.js} +1 -1
  30. package/server/client/dist/assets/channel-Cq5ZBtfo.js +1 -0
  31. package/server/client/dist/assets/{chunk-2Q5K7J3B-DaPQAU1q.js → chunk-2Q5K7J3B-P0v1gRui.js} +1 -1
  32. package/server/client/dist/assets/{chunk-32BRIVSS-CfL3kZAg.js → chunk-32BRIVSS-102-EyWU.js} +1 -1
  33. package/server/client/dist/assets/{chunk-5VM5RSS4-DeOwWPE_.js → chunk-5VM5RSS4-uqI_1K1p.js} +1 -1
  34. package/server/client/dist/assets/{chunk-EX3LRPZG-C3W1oc9y.js → chunk-EX3LRPZG-k5hlNinR.js} +1 -1
  35. package/server/client/dist/assets/{chunk-JWPE2WC7-_Oqh79OY.js → chunk-JWPE2WC7-PLvgEy_B.js} +1 -1
  36. package/server/client/dist/assets/{chunk-MOJQB5TN-DDKNNzI6.js → chunk-MOJQB5TN-B-LmIwhJ.js} +1 -1
  37. package/server/client/dist/assets/{chunk-RYQCIY6F-DCHah7CC.js → chunk-RYQCIY6F-CaNSMki0.js} +1 -1
  38. package/server/client/dist/assets/{chunk-V7JOEXUC-uUOIzgxj.js → chunk-V7JOEXUC-CmSzAkUx.js} +1 -1
  39. package/server/client/dist/assets/{chunk-VR4S4FIN-DDVw2WPs.js → chunk-VR4S4FIN-IiOfWaBG.js} +1 -1
  40. package/server/client/dist/assets/{chunk-XXDRQBXY-Coo4UFm2.js → chunk-XXDRQBXY-DRXrI6SM.js} +1 -1
  41. package/server/client/dist/assets/classDiagram-OUVF2IWQ-BqUaa8a6.js +1 -0
  42. package/server/client/dist/assets/classDiagram-v2-EOCWNBFH-BqUaa8a6.js +1 -0
  43. package/server/client/dist/assets/{cose-bilkent-JH36ORCC-C3pHmHpD.js → cose-bilkent-JH36ORCC-COcEaZRS.js} +1 -1
  44. package/server/client/dist/assets/{cynefinDiagram-TSTJHNR4-DZ6iiJFo.js → cynefinDiagram-TSTJHNR4-CSHqcg9K.js} +1 -1
  45. package/server/client/dist/assets/{dagre-VKFMJZFB-DNELbhwC.js → dagre-VKFMJZFB-XAWCPOS0.js} +1 -1
  46. package/server/client/dist/assets/{diagram-FQU43EPY-CMEvZJ61.js → diagram-FQU43EPY-scBCDUnE.js} +1 -1
  47. package/server/client/dist/assets/{diagram-G47NLZAW-BYDtf6j9.js → diagram-G47NLZAW-nPKP5kd8.js} +1 -1
  48. package/server/client/dist/assets/{diagram-NH7WQ7WH-CmXfcCQA.js → diagram-NH7WQ7WH-DcWalY4j.js} +1 -1
  49. package/server/client/dist/assets/{diagram-OA4YK3LP-BflTKJxU.js → diagram-OA4YK3LP-CXTlHB5A.js} +4 -4
  50. package/server/client/dist/assets/{diagram-WEI45ONY-KW3fKqna.js → diagram-WEI45ONY-D1uvaJub.js} +1 -1
  51. package/server/client/dist/assets/{ebnfDiagram-CCIWWBDH-CbyhY5Nj.js → ebnfDiagram-CCIWWBDH-nHt3vRNt.js} +1 -1
  52. package/server/client/dist/assets/{erDiagram-Q63AITRT-CC2eZV8g.js → erDiagram-Q63AITRT-K6stUUV2.js} +1 -1
  53. package/server/client/dist/assets/{flowDiagram-23GEKE2U-unplo7Qm.js → flowDiagram-23GEKE2U-DDWtKrEp.js} +4 -4
  54. package/server/client/dist/assets/{ganttDiagram-NO4QXBWP-BcBK5HcZ.js → ganttDiagram-NO4QXBWP-Daqh7b4I.js} +1 -1
  55. package/server/client/dist/assets/{gitGraphDiagram-IHSO6WYX-DgVbbb5k.js → gitGraphDiagram-IHSO6WYX-D73CLkcG.js} +1 -1
  56. package/server/client/dist/assets/{image.api-CyQisInP.js → image.api-Bbwmcw0T.js} +1 -1
  57. package/server/client/dist/assets/index-8bsOoxxg.js +1 -0
  58. package/server/client/dist/assets/{infoDiagram-FWYZ7A6U-N_D9RdfG.js → infoDiagram-FWYZ7A6U-Bc1YI5Iu.js} +1 -1
  59. package/server/client/dist/assets/{ishikawaDiagram-FXEZZL3T-BBKrzmB2.js → ishikawaDiagram-FXEZZL3T-BJDXbmaY.js} +1 -1
  60. package/server/client/dist/assets/{journeyDiagram-5HDEW3XC-NdCxLmQB.js → journeyDiagram-5HDEW3XC-DlyJx4xT.js} +1 -1
  61. package/server/client/dist/assets/{kanban-definition-HUTT4EX6-Ck7t4-tt.js → kanban-definition-HUTT4EX6-AmTeXesc.js} +1 -1
  62. package/server/client/dist/assets/manage-image-DCBgglLx.js +1 -0
  63. package/server/client/dist/assets/manage-image-detail-CPpeRZD4.js +1 -0
  64. package/server/client/dist/assets/{mcp-CCaFd0zm.js → mcp-Y2p95Lm9.js} +1 -1
  65. package/server/client/dist/assets/mcp-admin-adapter-z9OaMVrl.js +1 -0
  66. package/server/client/dist/assets/{mermaid.core-B14ZAmWA.js → mermaid.core-B528P54n.js} +4 -4
  67. package/server/client/dist/assets/{mindmap-definition-LN4V7U3C-BTUqSdcP.js → mindmap-definition-LN4V7U3C-C_6tKVmY.js} +1 -1
  68. package/server/client/dist/assets/{note-ui-CtijppHK.js → note-ui-Cv6quEYh.js} +1 -1
  69. package/server/client/dist/assets/{pegDiagram-2B236MQR-Cjcu3mVz.js → pegDiagram-2B236MQR-CGKCNdrV.js} +1 -1
  70. package/server/client/dist/assets/{pieDiagram-ENE6RG2P-BxI_c22Z.js → pieDiagram-ENE6RG2P-C3cMh7d5.js} +1 -1
  71. package/server/client/dist/assets/{placeholder-AusSo8p9.js → placeholder-CHRQt_T8.js} +1 -1
  72. package/server/client/dist/assets/properties-CwxDtivz.js +1 -0
  73. package/server/client/dist/assets/{quadrantDiagram-ABIIQ3AL-DGm0a-yR.js → quadrantDiagram-ABIIQ3AL-CVVzGxBd.js} +1 -1
  74. package/server/client/dist/assets/{railroadDiagram-RFXS5EU6-DmCDu89O.js → railroadDiagram-RFXS5EU6-wa-4aJR9.js} +1 -1
  75. package/server/client/dist/assets/{requirementDiagram-TGXJPOKE-CBpUt7Ig.js → requirementDiagram-TGXJPOKE-DyuC9W7q.js} +1 -1
  76. package/server/client/dist/assets/route-preload.js +2 -2
  77. package/server/client/dist/assets/{sankeyDiagram-HTMAVEWB-BjGnDZlp.js → sankeyDiagram-HTMAVEWB-B70y-MQg.js} +1 -1
  78. package/server/client/dist/assets/search-DCLnUWYd.js +1 -0
  79. package/server/client/dist/assets/search-admin-adapter-BLMYNm9w.js +1 -0
  80. package/server/client/dist/assets/{sequenceDiagram-DBY2YBRQ-B7rpCfS6.js → sequenceDiagram-DBY2YBRQ-mGkh3IEy.js} +1 -1
  81. package/server/client/dist/assets/{sizeCapture-X5ZJPWSS-CUJhD0uW.js → sizeCapture-X5ZJPWSS-BhnCNP5z.js} +1 -1
  82. package/server/client/dist/assets/sortable.esm-DgSW3bAA.js +5 -0
  83. package/server/client/dist/assets/{stateDiagram-2N3HPSRC-Y9-3XqRX.js → stateDiagram-2N3HPSRC-BqSKSfKi.js} +1 -1
  84. package/server/client/dist/assets/{stateDiagram-v2-6OUMAXLB-DbHXhT02.js → stateDiagram-v2-6OUMAXLB-Wl7lGTf3.js} +1 -1
  85. package/server/client/dist/assets/{swimlanes-5IMT3BWC-Cs1NO9ng.js → swimlanes-5IMT3BWC-CZ7ckdmY.js} +2 -2
  86. package/server/client/dist/assets/swimlanesDiagram-G3AALYLV-BZL3DQ-c.js +8 -0
  87. package/server/client/dist/assets/{tag.api-DNSQpqwk.js → tag.api-bU52U0tT.js} +1 -1
  88. package/server/client/dist/assets/time-DZKkPFUi.js +361 -0
  89. package/server/client/dist/assets/{timeline-definition-FHXFAJF6-8fqD4WNL.js → timeline-definition-FHXFAJF6-C-t9-x4M.js} +3 -3
  90. package/server/client/dist/assets/trash-BNeUFJnC.js +1 -0
  91. package/server/client/dist/assets/{url-9nrbQs7Z.js → url-BvjSC8PU.js} +1 -1
  92. package/server/client/dist/assets/useNoteMutate-VJYw0Vt_.js +9 -0
  93. package/server/client/dist/assets/useReminderMutate-DaO0QssD.js +121 -0
  94. package/server/client/dist/assets/{vennDiagram-L72KCM5P-BPqKkd5a.js → vennDiagram-L72KCM5P-CP014Nl5.js} +1 -1
  95. package/server/client/dist/assets/{wardleyDiagram-EHGQE667-Cq11kU2M.js → wardleyDiagram-EHGQE667-B7Ghd-94.js} +1 -1
  96. package/server/client/dist/assets/{xychartDiagram-FW5EYKEG-DJ6UzFj-.js → xychartDiagram-FW5EYKEG-C4YGS0YJ.js} +1 -1
  97. package/server/client/dist/index.html +6 -6
  98. package/server/dist/features/note/graphql/note.query.resolver.js +27 -9
  99. package/server/dist/features/note/graphql/note.type-defs.js +2 -0
  100. package/server/dist/features/note/services/content-blocks.js +24 -21
  101. package/server/dist/features/reminder/graphql/reminder.query.resolver.js +62 -0
  102. package/server/dist/features/reminder/graphql/reminder.type-defs.js +25 -0
  103. package/server/dist/features/view/graphql/view.query.resolver.js +40 -5
  104. package/server/dist/features/view/graphql/view.type-defs.js +23 -1
  105. package/server/dist/features/view/services/workspace.js +108 -5
  106. package/server/dist/paths.js +0 -1
  107. package/server/dist/routes/client.js +1 -1
  108. package/server/prisma/schema.prisma +1 -0
  109. package/server/client/dist/assets/ArrowRight.es-BEhnlwfe.js +0 -1
  110. package/server/client/dist/assets/AuxiliaryPanelHeader-B1k7pZpn.js +0 -1
  111. package/server/client/dist/assets/Calendar-D7QJsAlg.js +0 -25
  112. package/server/client/dist/assets/Callout-BTd1BYtV.js +0 -1
  113. package/server/client/dist/assets/Copy.es-BoLjilxv.js +0 -1
  114. package/server/client/dist/assets/File.es-Ct7fscBg.js +0 -1
  115. package/server/client/dist/assets/Graph-DYUb7gQb.js +0 -46
  116. package/server/client/dist/assets/Graph-LY_IgMYy.js +0 -1
  117. package/server/client/dist/assets/Image.es-OYyN3BYt.js +0 -1
  118. package/server/client/dist/assets/Note-DsMhwrHw.js +0 -25
  119. package/server/client/dist/assets/PencilLine.es-0JpEgxFY.js +0 -1
  120. package/server/client/dist/assets/Plus.es-DRfLW_bI.js +0 -1
  121. package/server/client/dist/assets/Reminders-COr1OHvF.js +0 -1
  122. package/server/client/dist/assets/Search-Ctkx0BQk.js +0 -31
  123. package/server/client/dist/assets/SurfaceCard-t7pdfhEe.js +0 -1
  124. package/server/client/dist/assets/Tag-BjxtrIQW.js +0 -1
  125. package/server/client/dist/assets/TagNotes-DV_fdRbg.js +0 -1
  126. package/server/client/dist/assets/Trash.es-Bo1VyK9Q.js +0 -1
  127. package/server/client/dist/assets/ViewChip-DlCkL4z4.js +0 -1
  128. package/server/client/dist/assets/ViewNotes-wWWeFJyU.js +0 -1
  129. package/server/client/dist/assets/ViewSectionDialog-DhH8harC.js +0 -102
  130. package/server/client/dist/assets/Views-CWE99SnI.js +0 -1
  131. package/server/client/dist/assets/app-B9WZRrAH.css +0 -1
  132. package/server/client/dist/assets/app-BpSMjzET.js +0 -26
  133. package/server/client/dist/assets/channel-CigOulR-.js +0 -1
  134. package/server/client/dist/assets/classDiagram-OUVF2IWQ-D13ISIOW.js +0 -1
  135. package/server/client/dist/assets/classDiagram-v2-EOCWNBFH-D13ISIOW.js +0 -1
  136. package/server/client/dist/assets/index-B-E1Ilh9.js +0 -1
  137. package/server/client/dist/assets/manage-image-azmo5iVw.js +0 -1
  138. package/server/client/dist/assets/manage-image-detail-BF-uSqb_.js +0 -1
  139. package/server/client/dist/assets/mcp-admin-adapter-PMmgPupc.js +0 -1
  140. package/server/client/dist/assets/note.api-D3oJmG3q.js +0 -356
  141. package/server/client/dist/assets/properties-BrNJLkxR.js +0 -1
  142. package/server/client/dist/assets/search-D-xKTPdO.js +0 -1
  143. package/server/client/dist/assets/search-admin-adapter-CJnJmL6w.js +0 -1
  144. package/server/client/dist/assets/swimlanesDiagram-G3AALYLV-DQnrq2ZC.js +0 -8
  145. package/server/client/dist/assets/time-D5LRMumI.js +0 -9
  146. package/server/client/dist/assets/trash-D4-9sv8q.js +0 -1
  147. package/server/client/dist/assets/useReminderMutate-BrGO9M0o.js +0 -82
@@ -1,25 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B14ZAmWA.js","assets/preload-helper-BXl3LOEh.js","assets/floating-ui.react-dom-BWTnA00G.js","assets/transform-BUB79_za.js","assets/katex-DywYRkvg.css"])))=>i.map(i=>d[i]);
2
- import{r as o,j as a}from"./floating-ui.react-dom-BWTnA00G.js";import{af as jn,A as vt,T as j,i as yt,m as Sn,q as B,M as D,B as k,c as K,G as wt,D as Ct,R as Rn,e as Re,u as Ze,ag as An,ah as En,ai as kn,L as Be,I as Tn,d as Dn,a as Mn,b as Fe,a0 as Pn,s as _n,aj as Ln,$ as Nt,ab as jt,ak as We,al as On,U as Bn,ac as Fn,ad as Hn,am as $n,Q as qe,P as Ge,an as Qe,h as In,l as ie,F as Un}from"./note.api-D3oJmG3q.js";import{M as xe,k as zn,r as Wn,f as St,m as Kn,a as He,b as Vn,d as G,s as Yn,l as Rt,o as Zn,p as At,q as Et,v as qn,w as nt,e as Gn}from"./time-D5LRMumI.js";import{m as Qn,c as Jn,C as rt}from"./Callout-BTd1BYtV.js";import{J as kt,A as Tt,N as Xn}from"./NotePropertiesPanel-aCKXAe5F.js";import{N as Ae,T as er,S as tr}from"./url-9nrbQs7Z.js";import{S as nr}from"./SurfaceCard-t7pdfhEe.js";import{u as rr,R as ar}from"./useReminderMutate-BrGO9M0o.js";import{n as sr}from"./Plus.es-DRfLW_bI.js";import{h as Je,m as or,L as Dt,Z as Mt,M as ir,K as cr,a as lr}from"./note-ui-CtijppHK.js";import{u as dr}from"./image.api-CyQisInP.js";import{L as ur,t as at,q as fr,B as he,G as pr,y as st}from"./note-core-DUTqUh5N.js";import{_ as Ke}from"./preload-helper-BXl3LOEh.js";import{s as mr}from"./Copy.es-BoLjilxv.js";import{m as hr}from"./PencilLine.es-0JpEgxFY.js";import{A as gr,p as xr}from"./AuxiliaryPanelHeader-B1k7pZpn.js";import{f as br,c as vr}from"./tag.api-DNSQpqwk.js";import{cn as ot}from"./note-runtime-zN5ddTba.js";import{s as yr}from"./File.es-Ct7fscBg.js";function wr(e,n){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const t=!!(e.condition??!0),s=e.blockerFn;return{shouldBlockFn:async()=>t&&s!==void 0?await s():t,enableBeforeUnload:t,withResolver:s===void 0}}function Cr(e,n){const{shouldBlockFn:t,enableBeforeUnload:s=!0,disabled:r=!1,withResolver:i=!1}=wr(e),l=jn(),{history:c}=l,[f,u]=o.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return o.useEffect(()=>{const p=async g=>{function x(A){const w=l.parseLocation(A),m=l.getMatchedRoutes(w.pathname);return m.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:m.routeParams,search:l.options.parseSearch(A.search)}:{routeId:m.foundRoute.id,fullPath:m.foundRoute.fullPath,pathname:w.pathname,params:m.routeParams,search:l.options.parseSearch(A.search)}}const d=x(g.currentLocation),h=x(g.nextLocation);if(d.routeId==="__notFound__"&&h.routeId!=="__notFound__")return!1;const y=await t({action:g.action,current:d,next:h});if(!i)return y;if(!y)return!1;const S=await new Promise(A=>{u({status:"blocked",current:d,next:h,action:g.action,proceed:()=>A(!1),reset:()=>A(!0)})});return u({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),S};return r?void 0:c.block({blockerFn:p,enableBeforeUnload:s})},[t,s,r,i,c,l]),f}const Nr=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M248.49,71.51l-32-32a12,12,0,0,0-17,17L211,68h-3c-52,0-64.8,30.71-75.08,55.38-8.82,21.17-15.45,37.05-42.75,40.09a44,44,0,1,0,.28,24.08c43.34-3.87,55.07-32,64.63-54.93C164.9,109,172,92,208,92h3l-11.52,11.51a12,12,0,0,0,17,17l32-32A12,12,0,0,0,248.49,71.51ZM48,196a20,20,0,1,1,20-20A20,20,0,0,1,48,196Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M80,176a32,32,0,1,1-32-32A32,32,0,0,1,80,176Z",opacity:"0.2"}),o.createElement("path",{d:"M245.66,74.34l-32-32a8,8,0,0,0-11.32,11.32L220.69,72H208c-49.33,0-61.05,28.12-71.38,52.92-9.38,22.51-16.92,40.59-49.48,42.84a40,40,0,1,0,.1,16c43.26-2.65,54.34-29.15,64.14-52.69C161.41,107,169.33,88,208,88h12.69l-18.35,18.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,245.66,74.34ZM48,200a24,24,0,1,1,24-24A24,24,0,0,1,48,200Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M245.66,85.66l-32,32a8,8,0,0,1-11.32-11.32L220.69,88H208c-38.67,0-46.59,19-56.62,43.08C141.05,155.88,129.33,184,80,184H79a32,32,0,1,1,0-16h1c38.67,0,46.59-19,56.62-43.08C147,100.12,158.67,72,208,72h12.69L202.34,53.66a8,8,0,0,1,11.32-11.32l32,32A8,8,0,0,1,245.66,85.66Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M244.24,75.76l-32-32a6,6,0,0,0-8.48,8.48L225.51,74H208c-48,0-59.44,27.46-69.54,51.69-9.43,22.64-17.66,42.33-53,44.16a38,38,0,1,0,.06,12c43.34-2.06,54.29-28.29,64-51.55C159.44,106.53,168,86,208,86h17.51l-21.75,21.76a6,6,0,1,0,8.48,8.48l32-32A6,6,0,0,0,244.24,75.76ZM48,202a26,26,0,1,1,26-26A26,26,0,0,1,48,202Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M245.66,74.34l-32-32a8,8,0,0,0-11.32,11.32L220.69,72H208c-49.33,0-61.05,28.12-71.38,52.92-9.38,22.51-16.92,40.59-49.48,42.84a40,40,0,1,0,.1,16c43.26-2.65,54.34-29.15,64.14-52.69C161.41,107,169.33,88,208,88h12.69l-18.35,18.34a8,8,0,0,0,11.32,11.32l32-32A8,8,0,0,0,245.66,74.34ZM48,200a24,24,0,1,1,24-24A24,24,0,0,1,48,200Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M242.83,77.17l-32-32a4,4,0,0,0-5.66,5.66L230.34,76H208c-46.67,0-57.84,26.81-67.69,50.46-9.46,22.69-18.4,44.16-56.55,45.48a36,36,0,1,0,0,8c43.49-1.42,54.33-27.39,63.91-50.39C157.45,106.12,166.67,84,208,84h22.34l-25.17,25.17a4,4,0,0,0,5.66,5.66l32-32A4,4,0,0,0,242.83,77.17ZM48,204a28,28,0,1,1,28-28A28,28,0,0,1,48,204Z"}))]]),jr=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M212,40a12,12,0,0,1-12,12H170.71A20,20,0,0,0,151,68.42L142.38,116H184a12,12,0,0,1,0,24H138l-9.44,51.87A44,44,0,0,1,85.29,228H56a12,12,0,0,1,0-24H85.29A20,20,0,0,0,105,187.58L113.62,140H72a12,12,0,0,1,0-24h46l9.44-51.87A44,44,0,0,1,170.71,28H200A12,12,0,0,1,212,40Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M200,40V200a16,16,0,0,1-16,16H56V56A16,16,0,0,1,72,40Z",opacity:"0.2"}),o.createElement("path",{d:"M208,40a8,8,0,0,1-8,8H170.71a24,24,0,0,0-23.62,19.71L137.59,120H184a8,8,0,0,1,0,16H134.68l-10,55.16A40,40,0,0,1,85.29,224H56a8,8,0,0,1,0-16H85.29a24,24,0,0,0,23.62-19.71l9.5-52.29H72a8,8,0,0,1,0-16h49.32l10-55.16A40,40,0,0,1,170.71,32H200A8,8,0,0,1,208,40Z"}))],["fill",o.createElement(o.Fragment,null,o.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,32ZM176,72H159.92a16,16,0,0,0-15.73,13l-6.55,35H168a8,8,0,0,1,0,16H134.64l-7.11,37.9A32,32,0,0,1,96.08,200H80a8,8,0,0,1,0-16H96.08A16,16,0,0,0,111.81,171L118.36,136H88a8,8,0,0,1,0-16h33.36l7.11-37.9A32,32,0,0,1,159.92,56H176a8,8,0,0,1,0,16Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M206,40a6,6,0,0,1-6,6H170.71a26,26,0,0,0-25.58,21.35L135.19,122H184a6,6,0,0,1,0,12H133l-10.33,56.8A38,38,0,0,1,85.29,222H56a6,6,0,0,1,0-12H85.29a26,26,0,0,0,25.58-21.35L120.81,134H72a6,6,0,0,1,0-12h51l10.33-56.8A38,38,0,0,1,170.71,34H200A6,6,0,0,1,206,40Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,40a8,8,0,0,1-8,8H170.71a24,24,0,0,0-23.62,19.71L137.59,120H184a8,8,0,0,1,0,16H134.68l-10,55.16A40,40,0,0,1,85.29,224H56a8,8,0,0,1,0-16H85.29a24,24,0,0,0,23.62-19.71l9.5-52.29H72a8,8,0,0,1,0-16h49.32l10-55.16A40,40,0,0,1,170.71,32H200A8,8,0,0,1,208,40Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M204,40a4,4,0,0,1-4,4H170.71a28,28,0,0,0-27.55,23l-10.37,57H184a4,4,0,0,1,0,8H131.34l-10.63,58.44A36,36,0,0,1,85.29,220H56a4,4,0,0,1,0-8H85.29a28,28,0,0,0,27.55-23l10.37-57H72a4,4,0,0,1,0-8h52.66l10.63-58.44A36,36,0,0,1,170.71,36H200A4,4,0,0,1,204,40Z"}))]]),Pt=o.forwardRef((e,n)=>o.createElement(vt,{ref:n,...e,weights:Nr}));Pt.displayName="FlowArrowIcon";const _t=Pt,Lt=o.forwardRef((e,n)=>o.createElement(vt,{ref:n,...e,weights:jr}));Lt.displayName="FunctionIcon";const Ot=Lt;function Sr({title:e,description:n,selected:t=!1,onClick:s,children:r}){return a.jsxs("button",{type:"button","aria-pressed":t,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${t?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:s,children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(j,{as:"div",variant:"body",weight:"semibold",tone:t?"default":"secondary",children:e}),a.jsx(j,{as:"div",variant:"meta",weight:"medium",tone:t?"secondary":"tertiary",className:"mt-1",children:n})]}),r?a.jsx("div",{className:"shrink-0",children:r}):null]})}const Rr=e=>{const{data:n}=yt({queryKey:B.notes.backReferences(e.noteId),async queryFn(){const t=await Sn(e.noteId);if(t.type==="error")throw t;return t.backReferences}});return e.render(n)},Ar=[{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 Er({isOpen:e,onClose:n,onSave:t,currentLayout:s="wide"}){const[r,i]=o.useState(s);o.useEffect(()=>{e&&i(s)},[e,s]);const l=()=>{t(r),n()};return a.jsxs(D,{isOpen:e,onClose:n,variant:"compact",children:[a.jsx(D.Header,{title:"Layout Settings",onClose:n}),a.jsx(D.Body,{children:a.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(j,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),a.jsx("div",{className:"flex flex-col gap-2",children:Ar.map(c=>a.jsx(Sr,{title:c.label,description:c.description,selected:r===c.value,onClick:()=>i(c.value)},c.value))})]})})}),a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(k,{variant:"primary",size:"sm",onClick:l,children:"Apply"})]})})]})}const ge=e=>{const n=/^\d+$/.test(e)?Number(e):Date.parse(e);return Number.isFinite(n)?n:null},je=(e,n)=>{const t=ge(e),s=ge(n);return t===null||s===null?e===n?0:null:t===s?0:t<s?-1:1},kr=2200;function Tr({status:e,savedAt:n,savedVersion:t,confirmationRevision:s}){const[r,i]=o.useState(()=>Date.now()),[l,c]=o.useState(!1);o.useEffect(()=>{if(e!=="saved")return;const d=window.setTimeout(()=>i(Date.now()),zn(ge(t),r));return()=>window.clearTimeout(d)},[r,t,e]),o.useEffect(()=>{if(s===0)return;c(!0);const d=window.setTimeout(()=>c(!1),kr);return()=>window.clearTimeout(d)},[s]);const f=e==="saved"&&l,u=e==="pending"?"Saving...":e==="saving"?"Saving now...":e==="error"?"Save failed. Try again.":e==="conflict"?"Save paused: changed elsewhere":`Saved ${Wn(ge(t),r)}`,p=K("inline-flex items-center gap-2 transition-colors",e==="saved"&&!f&&"text-fg-secondary",f&&"text-accent-success",(e==="pending"||e==="saving")&&"text-fg-default",(e==="error"||e==="conflict")&&"text-fg-error"),g=K("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(e==="pending"||e==="saving")&&"save-progress-ring-active",e==="saved"&&f&&"save-progress-ring-complete",(e==="error"||e==="conflict")&&"save-progress-ring-error"),x=e==="error"||e==="conflict"?a.jsx(Qn,{className:"h-3.5 w-3.5",weight:"fill"}):a.jsx("span",{className:g,"aria-hidden":!0,children:a.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})});return a.jsxs(j,{as:"span",variant:"label",weight:"medium",className:p,role:"status","aria-live":"polite",title:n,children:[x,u]})}function Dr({title:e,titleRef:n,isPinned:t,createdAt:s,saveStatus:r,savedAt:i,savedVersion:l,saveConfirmationRevision:c,onTitleChange:f,onCopyMarkdown:u,onDownloadDocument:p,onTogglePinned:g,onChangeLayout:x,onCloneNote:d,onRestoreVersion:h,onDelete:y,onSave:N}){return a.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:a.jsxs("div",{className:"flex flex-col gap-3.5",children:[a.jsxs("div",{className:"flex items-start justify-between gap-5",children:[a.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[a.jsx(j,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),a.jsx("input",{ref:n,"aria-label":"Note title",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:e,onChange:S=>f(S.target.value)})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(wt,{button:a.jsx(St,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:u},{name:"Download document",onClick:p},{type:"separator",key:"export-separator"},{name:t?"Unpin":"Pin",onClick:g},{name:"Change layout",onClick:x},{type:"separator"},{name:"Clone this note",onClick:d},{name:"Restore previous version",onClick:h},{type:"separator"},{name:"Delete",onClick:y}]}),a.jsx(k,{size:"sm",variant:"subtle",isLoading:r==="saving",disabled:r==="conflict",onClick:N,children:"Save"})]})]}),a.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:[t&&a.jsxs(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[a.jsx(Kn,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),t&&a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsx(Tr,{status:r,savedAt:i,savedVersion:l,confirmationRevision:c}),a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsxs(j,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",s]})]})]})})}const Mr=/[:{}[\],&*#?|<>=!%@`-]/,Pr="/assets/images/",_r=e=>e.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",Ne=e=>e?Mr.test(e)||/^\s|\s$/.test(e)?JSON.stringify(e):e:'""',Se=e=>{if(!e)return;const n=Number(e);return Number.isFinite(n)?new Date(n).toISOString():e},Xe=()=>typeof window>"u"||!window.location?.origin?"http://localhost":window.location.origin,Ee=(e,n=Xe())=>{try{const t=new URL(e,n);return t.origin===n&&t.pathname.startsWith(Pr)}catch{return!1}},Bt=(e,n=Xe())=>{const t=new URL(e,n);return`${t.pathname}${t.search}`},Ft=e=>e.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase()??"",Lr=e=>e.trim().replace(/[\\/:*?"<>|]/g,"-").split("").map(s=>s.charCodeAt(0)<32?"-":s).join("").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"image",Or=e=>{const n=e.lastIndexOf(".");return n<=0||n===e.length-1?{baseName:e,extension:""}:{baseName:e.slice(0,n),extension:e.slice(n)}},Ht=(e,n,t)=>{const r=new URL(e,Xe()).pathname.split("/").filter(Boolean),i=decodeURIComponent(r[r.length-1]??""),l=`image-${n+1}`,{baseName:c,extension:f}=Or(Lr(i||l));let u=`${c}${f}`,p=2;for(;t.has(u);)u=`${c}-${p}${f}`,p+=1;return t.add(u),`assets/${u}`},Br=(e,n)=>{let t=null;for(let s=n;s<e.length;s+=1){const r=e[s];if(t){r===t&&(t=null);continue}if(r==='"'||r==="'"){t=r;continue}if(r===">")return s}return-1},Fr=(e,n)=>{let t=n;for(;t<e.length;){const s=e.toLowerCase().indexOf("<img",t);if(s===-1)return-1;const r=e[s+4],i=s===0?-1:e.lastIndexOf("<",s-1),l=s===0?-1:e.lastIndexOf(">",s-1);if(i<=l&&(!r||/[\s/>]/.test(r)))return s;t=s+4}return-1},Hr=(e,n,t,s)=>{let r=n;for(;r<t;){for(;r<t&&/[\s/]/.test(e[r]);)r+=1;const i=r;for(;r<t&&/[^\s=/>]/.test(e[r]);)r+=1;const l=e.slice(i,r).toLowerCase();for(;r<t&&/\s/.test(e[r]);)r+=1;if(e[r]!=="=")continue;for(r+=1;r<t&&/\s/.test(e[r]);)r+=1;const c=e[r];if(c==='"'||c==="'"){const u=r+1,p=e.indexOf(c,u);if(p===-1||p>t)return;if(r=p+1,l===s)return{end:p,start:u,value:e.slice(u,p)};continue}const f=r;for(;r<t&&/[^\s>]/.test(e[r]);)r+=1;if(l===s)return{end:r,start:f,value:e.slice(f,r)}}},$t=e=>{const n=[];let t=0;for(;t<e.length;){const s=Fr(e,t);if(s===-1)break;const r=Br(e,s+4);if(r===-1)break;const i=Hr(e,s+4,r,"src");i&&n.push({end:r+1,source:i,start:s}),t=r+1}return n},It=(e,n)=>{let t=e;for(const s of[...n].sort((r,i)=>i.start-r.start))t=`${t.slice(0,s.start)}${s.value}${t.slice(s.end)}`;return t},Ut=(e,n)=>{let t=e;for(const s of[...n].sort((r,i)=>i.start-r.start))t=`${t.slice(0,s.start)}${s.value}${t.slice(s.end)}`;return t},zt=e=>{const n=[];let t=0;for(;t<e.length;){const s=e.indexOf("![",t);if(s===-1)break;let r=s+2,i=1;for(;r<e.length&&i>0&&e[r]!==`
3
- `;){if(e[r]==="\\"){r+=2;continue}e[r]==="["?i+=1:e[r]==="]"&&(i-=1),r+=1}if(i!==0||e[r]!=="("){t=s+2;continue}const l=r+1;let c=l;for(;c<e.length&&e[c]!==`
4
- `&&/\s/.test(e[c]);)c+=1;if(c>=e.length||e[c]===`
5
- `){t=s+2;continue}let f=c,u=c,p=c;if(e[c]==="<"){for(r=c+1;r<e.length&&e[r]!==">"&&e[r]!==`
6
- `;)r+=e[r]==="\\"?2:1;if(e[r]!==">"){t=s+2;continue}f=r+1,u=c+1,p=r}else{let g=0;for(r=c;r<e.length&&e[r]!==`
7
- `;){const x=e[r];if(x==="\\"){r+=2;continue}if(/\s/.test(x)&&g===0)break;if(x==="(")g+=1;else if(x===")"){if(g===0)break;g-=1}r+=1}f=r,u=c,p=f}if(p<=u){t=s+2;continue}for(r=f;r<e.length&&e[r]!==`
8
- `&&/\s/.test(e[r]);)r+=1;if(e[r]==='"'||e[r]==="'"){const g=e[r];for(r+=1;r<e.length&&e[r]!==`
9
- `;){if(e[r]==="\\"){r+=2;continue}if(e[r]===g){r+=1;break}r+=1}}for(;r<e.length&&e[r]!==`
10
- `&&/\s/.test(e[r]);)r+=1;if(e[r]!==")"){t=s+2;continue}n.push({end:r+1,source:{end:f,start:l,value:e.slice(u,p)},start:s}),t=r+1}return n},$r=(e,n)=>`${_r(e)}.${n}`,Ir=({id:e,title:n,createdAt:t,updatedAt:s})=>{const r=["---",`title: ${Ne(n)}`,`note_id: ${Ne(e)}`],i=Se(t),l=Se(s);return i&&r.push(`created_at: ${Ne(i)}`),l&&r.push(`updated_at: ${Ne(l)}`),r.push("source: ocean-brain","---"),r.join(`
11
- `)},Wt=(e,n,t=!1)=>t?`${Ir(n)}
12
-
13
- ${e}`:e,Kt=(e,n,{includeMetadata:t=!1}={})=>{const s=Wt(e,n,t),r=zt(s).filter(i=>Ee(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return Ut(s,r)},Vt=(e,n,{includeMetadata:t=!1}={})=>`${t?`<!--
14
- source: ocean-brain
15
- note_id: ${n.id}
16
- title: ${n.title}
17
- created_at: ${Se(n.createdAt)??""}
18
- updated_at: ${Se(n.updatedAt)??""}
19
- -->
20
- `:""}${e}`,Ur=(e,n,{includeMetadata:t=!1}={})=>{const s=Vt(e,n,{includeMetadata:t}),r=$t(s).filter(i=>Ee(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return It(s,r)},zr=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new kt,i=Vt(e,n,{includeMetadata:s}),l=$t(i),c=[],f=new Set,u=new Map;for(const{source:p}of l){if(!Ee(p.value))continue;const g=Bt(p.value);let x=u.get(g);if(!x){x=Ht(g,u.size,f),u.set(g,x);const d=await t(g,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${g}`);if(!Ft(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${g}`);r.file(x,new Uint8Array(await d.arrayBuffer()))}c.push({end:p.end,start:p.start,value:`./${x}`})}return r.file("note.html",It(i,c)),r.generateAsync({type:"blob"})},Wr=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new kt,i=Wt(e,n,s),l=zt(i),c=[],f=new Set,u=new Map;for(const{source:p}of l){if(!Ee(p.value))continue;const g=Bt(p.value);let x=u.get(g);if(!x){x=Ht(g,u.size,f),u.set(g,x);const d=await t(g,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${g}`);if(!Ft(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${g}`);r.file(x,new Uint8Array(await d.arrayBuffer()))}c.push({end:p.end,start:p.start,value:`./${x}`})}return r.file("note.md",Ut(i,c)),r.generateAsync({type:"blob"})},Kr=(e,n)=>{const t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download=n,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(t)},Yt={html:{extension:"html",getContent:e=>e.getHtml(),createDocumentBlob:(e,n)=>new Blob([Ur(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/html;charset=utf-8"}),createZipBlob:(e,n)=>zr(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})},markdown:{extension:"md",getContent:e=>e.getMarkdown(),createDocumentBlob:(e,n)=>new Blob([Kt(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/markdown;charset=utf-8"}),createZipBlob:(e,n)=>Wr(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})}},Zt=(e,n)=>n?"zip":Yt[e].extension,Vr=async e=>{const n=Yt[e.format],t=n.getContent(e.source);if(t===void 0)return{type:"not-ready",format:e.format};const s=Zt(e.format,e.includeAssets);return{type:"success",blob:e.includeAssets?await n.createZipBlob(t,e):n.createDocumentBlob(t,e),filename:$r(e.metadata.title,s)}},Yr=e=>e==="markdown"?"Markdown is not ready yet.":"HTML is not ready yet.",it=({checked:e,description:n,id:t,label:s,onChange:r})=>{const i=`${t}-label`;return a.jsxs("div",{className:"flex min-h-6 items-center gap-2",children:[a.jsx(Ct,{id:t,size:"sm",checked:e,onChange:l=>r(l.target.checked),"aria-labelledby":i}),a.jsx("label",{id:i,htmlFor:t,className:"min-w-0 cursor-pointer",children:a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"block",children:s})}),a.jsx(Rn,{content:a.jsx("span",{className:"block max-w-[240px] leading-4",children:n}),side:"top",children:a.jsx("button",{type:"button",className:"focus-ring-soft inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-secondary","aria-label":`${s} help`,children:a.jsx(Jn,{className:"h-3.5 w-3.5"})})})]})};function Zr({isOpen:e,metadata:n,getHtml:t,getMarkdown:s,onClose:r}){const i=Re(),[l,c]=o.useState("html"),[f,u]=o.useState(!0),[p,g]=o.useState(!1),[x,d]=o.useState(!1),h=Zt(l,f),y=async()=>{d(!0);try{const N=await Vr({format:l,includeAssets:f,includeMetadata:p,metadata:n,source:{getHtml:t,getMarkdown:s}});if(N.type==="not-ready"){i(Yr(N.format));return}Kr(N.blob,N.filename),r(),i("Downloaded note.")}catch{i("Failed to download note.")}finally{d(!1)}};return a.jsxs(D,{isOpen:e,onClose:r,variant:"compact",children:[a.jsx(D.Header,{title:"Download document",onClose:r}),a.jsx(D.Body,{children:a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsxs("div",{className:"flex flex-col gap-3",role:"radiogroup","aria-label":"Format",children:[a.jsx(j,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Format"}),a.jsxs("div",{className:"flex flex-wrap gap-4",children:[a.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[a.jsx("input",{type:"radio",name:"note-export-format",value:"html",checked:l==="html",onChange:()=>c("html"),className:"h-4 w-4 accent-cta"}),a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".html"})]}),a.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[a.jsx("input",{type:"radio",name:"note-export-format",value:"markdown",checked:l==="markdown",onChange:()=>c("markdown"),className:"h-4 w-4 accent-cta"}),a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".md"})]})]})]}),a.jsxs("div",{className:"flex flex-col gap-3",role:"group","aria-label":"Options",children:[a.jsx(j,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Options"}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(it,{id:"note-export-include-assets",label:"Include local image assets",checked:f,onChange:u,description:"Bundle uploaded Ocean Brain images with the document. Without assets, local images are omitted."}),a.jsx(it,{id:"note-export-include-metadata",label:"Include metadata",checked:p,onChange:g,description:"Add the note title, note id, timestamps, and Ocean Brain source information."})]})]})]})}),a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),a.jsx(k,{variant:"primary",size:"sm",onClick:y,disabled:x,children:x?"Downloading...":`Download .${h}`})]})})]})}const qt=e=>e==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:e==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},qr=({isDeleted:e,isConflict:n,source:t})=>{const s=qt(t);return e?`This note was moved to trash ${s.place}`:n?`Save paused: note changed ${s.place}`:`This note changed ${s.place}`},Gr=({isDeleted:e,isConflict:n,hasDraft:t,source:s})=>{const r=qt(s);return e?`${r.actor} moved this note to trash. Open trash to review or restore it.`:n&&t?`Your draft is saved locally. Reload the latest note, overwrite ${r.target}, or clone your draft into a new note.`:n?`The layout change is paused because the note changed ${r.place}. Reload the latest note or overwrite only the layout.`:`${r.actor} changed this note while it was open here. Reload the latest version before continuing.`};function Qr({isOpen:e,isDeleted:n,isConflict:t,hasDraft:s,source:r,isReloading:i,onReload:l,onOverwrite:c,onCloneDraft:f,onOpenTrash:u}){return a.jsxs(D,{isOpen:e,onClose:()=>{},variant:"inspect",children:[a.jsx(D.Header,{title:qr({isDeleted:n,isConflict:t,source:r})}),a.jsx(D.Body,{children:a.jsx(j,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:Gr({isDeleted:n,isConflict:t,hasDraft:s,source:r})})}),a.jsx(D.Footer,{children:a.jsx(xe,{children:n?a.jsx(k,{type:"button",variant:"primary",size:"sm",onClick:u,children:"Open trash"}):t?a.jsxs(a.Fragment,{children:[a.jsx(k,{type:"button",variant:"subtle",size:"sm",isLoading:i,onClick:l,children:"Reload latest"}),s&&a.jsx(k,{type:"button",variant:"ghost",size:"sm",onClick:f,children:"Clone draft"}),a.jsx(k,{type:"button",variant:"danger",size:"sm",onClick:c,children:"Overwrite"})]}):a.jsx(k,{type:"button",variant:"primary",size:"sm",isLoading:i,onClick:l,children:"Reload latest"})})})]})}function Jr({localDraftCreatedAt:e,hasSaveError:n,onRestoreDraft:t,onDiscardDraft:s,onRetrySave:r,onSaveAsNewNote:i}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(rt,{tone:"danger",className:"mb-6",children:a.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[a.jsxs("span",{children:["A draft from ",e," is saved only in this browser."]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(k,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:t,children:"Restore draft"}),a.jsx(k,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:s,children:"Discard"})]})]})}),n&&a.jsx(rt,{tone:"danger",className:"mb-6",children:a.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[a.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(k,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:r,children:"Retry save"}),a.jsx(k,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:i,children:"Save as new note"})]})]})})]})}const ct=(e,n)=>e||(n==="mobile"?"Mobile browser":n==="mcp"?"MCP":"Web browser");function Xr({isOpen:e,noteId:n,onClose:t,restoreSnapshot:s,onRestored:r}){const i=Re(),l=Ze(),[c,f]=o.useState(null),[u,p]=o.useState("diff"),g=o.useRef(null),x=He({queryKey:B.notes.snapshots(n),queryFn:async()=>{const m=await An(n);if(m.type==="error")throw m;return m.noteSnapshots},enabled:e}),d=Vn({mutationFn:s,onSuccess:async m=>{if(m){if(m.type==="error"){i(m.errors[0].message);return}await Promise.all([l.invalidateQueries({queryKey:B.notes.detail(n),exact:!0}),l.invalidateQueries({queryKey:B.notes.listAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.tagListAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.tagNameListAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.pinned(),exact:!0}),l.invalidateQueries({queryKey:B.notes.backReferencesAll(),exact:!1}),l.invalidateQueries({queryKey:B.notes.graph(),exact:!0}),l.invalidateQueries({queryKey:B.notes.snapshots(n),exact:!1}),l.invalidateQueries({queryKey:B.views.sectionNotesAll(),exact:!1}),l.invalidateQueries({queryKey:B.tags.all(),exact:!1})]),i("Previous version restored."),r?.(m.restoreNoteSnapshot),f(null),t()}}}),h=x.data?.find(m=>m.id===c)??null,y=He({queryKey:[...B.notes.snapshotDetail(c??"pending"),"diff"],queryFn:async()=>{if(!c)throw new Error("SNAPSHOT_NOT_SELECTED");const m=await En(c,"current");if(m.type==="error")throw m;if(!m.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return m.noteSnapshotDiff},enabled:!!c&&u==="diff"}),N=He({queryKey:B.notes.snapshotDetail(c??"pending"),queryFn:async()=>{if(!c)throw new Error("SNAPSHOT_NOT_SELECTED");const m=await kn(c);if(m.type==="error")throw m;if(!m.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return m.noteSnapshot},enabled:!!c&&u==="content"}),S=N.data?.contentAsMarkdown.trim()??"";o.useEffect(()=>{c&&g.current?.focus()},[c]);const A=(m,v)=>{p(v),f(m)},w=()=>{f(null),p("diff"),t()};return a.jsxs(D,{isOpen:e,onClose:w,variant:"inspect",children:[a.jsx(D.Header,{title:h?u==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:w}),a.jsx(D.Description,{className:"sr-only",children:h?u==="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."}),a.jsx(D.Body,{children:h?a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(j,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:h.title}),a.jsxs(j,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",ct(h.meta.label,h.meta.entrypoint)," ","edit - ",G(h.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(k,{variant:u==="diff"?"primary":"subtle",size:"sm",onClick:()=>p("diff"),children:"Show diff"}),a.jsx(k,{variant:u==="content"?"primary":"subtle",size:"sm",onClick:()=>p("content"),children:"View content"})]}),u==="diff"?y.isLoading?a.jsx(j,{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..."}):y.isError?a.jsx(j,{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."}):y.data?a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(j,{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."}),a.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:y.data.diff.markdown.split(`
21
- `).map((m,v)=>{const T=m.startsWith("+")&&!m.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":m.startsWith("-")&&!m.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":m.startsWith("@@")?"bg-sky-500/12 text-sky-700 dark:text-sky-200":"text-fg-secondary";return a.jsx("span",{className:`block min-w-full whitespace-pre-wrap break-words px-4 ${T}`,children:m||" "},`${v}-${m}`)})})]}):null:N.isLoading?a.jsx(j,{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..."}):N.isError?a.jsx(j,{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."}):S?a.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:S}):a.jsx(j,{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."})]}):a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx(j,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),x.isLoading&&a.jsx(j,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!x.isLoading&&x.data?.length===0&&a.jsx(j,{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."}),!x.isLoading&&x.data&&x.data.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:x.data.map(m=>a.jsx(nr,{padding:"compact",children:a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs(j,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",ct(m.meta.label,m.meta.entrypoint)," ","edit"]}),a.jsx(j,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:m.title}),a.jsx(j,{as:"p",variant:"label",tone:"tertiary",children:G(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),a.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[a.jsx(k,{variant:"subtle",size:"sm",onClick:()=>A(m.id,"diff"),children:"Compare"}),a.jsx(k,{size:"sm",isLoading:d.isPending,onClick:()=>d.mutate(m.id),children:"Restore"})]})]}),m.contentPreview&&a.jsx("div",{className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:m.contentPreview})})]})},m.id))})]})}),h&&a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{ref:g,variant:"subtle",onClick:()=>{f(null),p("diff")},children:"Back"}),a.jsx(k,{isLoading:d.isPending,onClick:()=>d.mutate(h.id),children:"Restore this version"})]})})]})}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 ea({isOpen:e,onClose:n,onSave:t,reminder:s,mode:r}){const[i,l]=o.useState(new Date),[c,f]=o.useState("medium"),[u,p]=o.useState("");o.useEffect(()=>{e&&r==="edit"&&s?(l(new Date(Number(s.reminderDate))),f(s.priority||"medium"),p(s.content||"")):e&&r==="create"&&(l(new Date),f("medium"),p(""))},[e,r,s]);const g=()=>{t(i,c,u||void 0),n()},x=d=>c===d?lt[d].active:lt[d].inactive;return a.jsxs(D,{isOpen:e,onClose:n,variant:"form",children:[a.jsx(D.Header,{title:r==="create"?"Create Reminder":"Edit Reminder",onClose:n}),a.jsx(D.Body,{children:a.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Be,{children:"Date & Time"}),a.jsx(Tn,{type:"datetime-local",size:"sm",value:G(i).format("YYYY-MM-DDTHH:mm"),onChange:d=>l(new Date(d.target.value))})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Be,{children:"Content"}),a.jsx(Dn,{size:"sm",placeholder:"Enter reminder content (optional)",value:u,onChange:d=>p(d.target.value)})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Be,{children:"Priority"}),a.jsxs(Mn,{type:"single",variant:"quiet",value:c,onValueChange:d=>d&&f(d),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[a.jsx(Fe,{value:"low",className:`flex-1 rounded-[10px] border ${x("low")}`,children:a.jsx(j,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),a.jsx(Fe,{value:"medium",className:`flex-1 rounded-[10px] border ${x("medium")}`,children:a.jsx(j,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),a.jsx(Fe,{value:"high",className:`flex-1 rounded-[10px] border ${x("high")}`,children:a.jsx(j,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),a.jsx(D.Footer,{children:a.jsxs(xe,{children:[a.jsx(k,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(k,{variant:"primary",size:"sm",onClick:g,children:r==="create"?"Create":"Save"})]})})]})}function ta({noteId:e}){const[n,t]=o.useState(!1),[s,r]=o.useState(!1),[i,l]=o.useState("create"),[c,f]=o.useState(void 0),{onCreate:u,onUpdate:p,onDelete:g}=rr(),x=()=>{l("create"),f(void 0),r(!0)},d=w=>{l("edit"),f(w),r(!0)},h=(w,m,v)=>{i==="create"?u(e,w,m,()=>{r(!1)},v):i==="edit"&&c&&p(c.id,e,{reminderDate:w,priority:m,content:v},()=>{r(!1)})},y=w=>{p(w.id,e,{completed:!w.completed})},N=w=>{const m=G(Number(w)),v=G();return m.isSame(v,"day")?`Today at ${m.format("HH:mm")}`:m.isSame(v.add(1,"day"),"day")?`Tomorrow at ${m.format("HH:mm")}`:m.format("YYYY-MM-DD HH:mm")},S=w=>{const m=G(Number(w)),v=G(),T=m.diff(v,"hour");return T<=6?"high":T<=24?"medium":"low"},A=w=>{const m=G(Number(w)),v=G(),T=m.diff(v,"hour"),H=m.diff(v,"minute")%60;return T<0||H<0?"Overdue":T===0?`${H}m remaining`:`${T}h ${H}m remaining`};return a.jsxs(a.Fragment,{children:[a.jsx(Tt,{title:"Reminders",icon:a.jsx(Yn,{className:"h-3.5 w-3.5"}),action:a.jsxs(a.Fragment,{children:[!n&&a.jsxs(k,{size:"sm",variant:"ghost",onClick:x,children:[a.jsx(sr,{className:"w-3 h-3"}),a.jsx(j,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),a.jsxs(k,{type:"button",size:"sm",variant:"ghost","aria-label":n?"Expand reminders":"Collapse reminders","aria-expanded":!n,onClick:()=>t(!n),children:[n?a.jsx(Pn,{className:"h-3.5 w-3.5"}):a.jsx(_n,{className:"h-3.5 w-3.5"}),n?"Expand":"Collapse"]})]}),children:!n&&a.jsx(ar,{noteId:e,searchParams:{offset:0,limit:9999},render:({reminders:w,totalCount:m})=>a.jsx("div",{className:"flex flex-col gap-2",children:w.length===0?a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:m===0?"No reminders yet":"All reminders complete"}):a.jsx("div",{className:"flex flex-col",children:w.map(v=>{const T=v.priority||S(v.reminderDate),H=A(v.reminderDate),M=H==="Overdue";return a.jsxs("div",{className:K("flex items-center gap-2.5 px-2 py-1.5"),children:[a.jsx(Ct,{checked:v.completed,onChange:()=>y(v),size:"sm","aria-label":`Reminder: ${v.content||N(v.reminderDate)}`}),a.jsx(j,{as:"div",variant:"body",weight:"medium",className:K("truncate flex-1 min-w-0",v.completed&&"line-through opacity-40"),children:v.content||N(v.reminderDate)}),a.jsxs("div",{className:K("shrink-0 flex items-center gap-1",v.completed&&"opacity-40"),children:[v.content&&a.jsx(j,{as:"span",variant:"meta",tone:"secondary",children:N(v.reminderDate)}),!v.completed&&a.jsx(j,{as:"span",variant:"label",weight:"medium",tone:M||T==="high"?"error":"tertiary",className:K(v.content&&'before:content-["·"] before:mr-1'),children:H})]}),a.jsx(wt,{button:a.jsx(St,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>d(v)},{name:"Delete",onClick:()=>g(v.id,e)}]})]},v.id)})})})})}),a.jsx(ea,{isOpen:s,onClose:()=>r(!1),onSave:h,reminder:c,mode:i})]})}const na=e=>[{title:"Diagram",subtext:"Create a flowchart or diagram with Mermaid syntax",onItemClick:()=>{at(e,{type:"codeBlock",props:{language:"mermaid"}})},aliases:["mermaid","diagram","flowchart","sequence"],group:"Other",icon:a.jsx(_t,{})},{title:"Math Formula",subtext:"Write a formula with KaTeX or LaTeX",onItemClick:()=>{at(e,{type:"codeBlock",props:{language:"math"}})},aliases:["math","formula","equation","katex","latex"],group:"Other",icon:a.jsx(Ot,{})}],ra=({editor:e})=>a.jsx(Je,{triggerCharacter:"/",getItems:async n=>ur([...or(e).filter(t=>t.title!=="Audio"&&t.title!=="Video"&&t.title!=="File"),...na(e),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{e.insertBlocks([{type:"tableOfContents"}],e.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:a.jsx(Rt,{})}],n)}),aa=(e,n)=>n?e.filter(t=>t.id!==n):e,sa=({currentNoteId:e,onClick:n})=>a.jsx(Je,{triggerCharacter:"[",getItems:async t=>{const s=await Ln({query:t,limit:5});return s.type==="error"?[]:aa(s.allNotes.notes,e).map(i=>({title:i.title,onItemClick:()=>n({type:"reference",props:{id:i.id,title:i.title}})}))}}),Gt=["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/avif"],oa=new Set(Gt),dt="Unsupported image type. Use PNG, JPEG, GIF, WebP, BMP, or AVIF.",ia="Failed to upload image.",ca=e=>oa.has(e);let ut,ft;const la=()=>(ut??=Ke(async()=>{const{default:e}=await import("./mermaid.core-B14ZAmWA.js").then(n=>n.bc);return{default:e}},__vite__mapDeps([0,1,2,3])).then(({default:e})=>e),ut),da=()=>(ft??=Promise.all([Ke(()=>import("./katex-x288kqHd.js"),[]),Ke(()=>Promise.resolve({}),__vite__mapDeps([4]))]).then(([{default:e}])=>e),ft),ua=e=>{const n=e?.trim().toLowerCase();return n==="mermaid"?"mermaid":n==="math"||n==="katex"||n==="latex"?"math":null},fa=e=>`ocean-brain-mermaid-${e.replace(/[^a-zA-Z0-9_-]/g,"")||"diagram"}`,pa=async(e,n,t,s="light")=>{if(e==="mermaid"){const i=await la();i.initialize({securityLevel:"strict",startOnLoad:!1,suppressErrorRendering:!0,theme:s==="dark"?"dark":"default"});const l=await i.render(fa(t),n);return{html:l.svg,bindFunctions:l.bindFunctions}}return{html:(await da()).renderToString(n,{displayMode:!0,output:"htmlAndMathml",strict:"warn",throwOnError:!0,trust:!1})}},ma={floating:"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",toolbar:"focus-ring-soft inline-flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-transparent px-2.5 text-xs font-semibold text-fg-secondary outline-none transition-colors hover:border-border-subtle hover:bg-hover-subtle hover:text-fg-default"},ha={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"},ga={idle:"Copy",copied:"Copied",failed:"Copy failed"},pt=({getText:e,resetDelayMs:n=2e3,variant:t="floating"})=>{const[s,r]=o.useState("idle"),i=o.useRef(null),l=o.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),c=o.useCallback(()=>{l(),i.current=setTimeout(()=>{r("idle"),i.current=null},n)},[l,n]);o.useEffect(()=>l,[l]);const f=g=>{g.stopPropagation()},u=g=>{g.preventDefault(),g.stopPropagation()},p=async g=>{f(g);try{await navigator.clipboard.writeText(e()),r("copied")}catch{r("failed")}c()};return a.jsx("div",{className:K(t==="floating"&&"pointer-events-none absolute right-3 top-2 z-[1]"),contentEditable:!1,onMouseDown:u,children:a.jsxs("button",{type:"button",className:K(ma[t],ha[s]),contentEditable:!1,onClick:p,children:[a.jsx(mr,{className:"h-3.5 w-3.5"}),a.jsx("span",{"aria-live":"polite",children:ga[s]})]})})},xa=({kind:e,source:n})=>{const t=o.useId(),s=o.useRef(null),r=Nt(u=>u.theme),[i,l]=o.useState(()=>typeof IntersectionObserver>"u"),[c,f]=o.useState({status:"idle"});return o.useEffect(()=>{const u=s.current;if(i||!u||typeof IntersectionObserver>"u"){l(!0);return}const p=new IntersectionObserver(([g])=>{g?.isIntersecting&&(l(!0),p.disconnect())},{rootMargin:"240px"});return p.observe(u),()=>p.disconnect()},[i]),o.useEffect(()=>{if(!i)return;let u=!1;return f({status:"loading"}),pa(e,n,t,r).then(p=>{u||f({status:"success",...p})}).catch(()=>{u||f({status:"error"})}),()=>{u=!0}},[e,t,i,n,r]),o.useEffect(()=>{c.status==="success"&&c.bindFunctions&&s.current&&c.bindFunctions(s.current)},[c]),a.jsxs("div",{ref:s,"data-rich-code-preview":!0,className:"min-h-24 w-full overflow-auto bg-surface px-4 py-5 text-fg-default sm:px-6 sm:py-6",contentEditable:!1,"aria-label":e==="mermaid"?"Mermaid diagram preview":"Math formula preview",children:[c.status==="success"&&a.jsx("div",{className:"[&_.katex-display]:m-0 [&_svg]:mx-auto [&_svg]:block [&_svg]:h-auto [&_svg]:max-h-[min(68vh,640px)] [&_svg]:max-w-full",dangerouslySetInnerHTML:{__html:c.html}}),(c.status==="idle"||c.status==="loading")&&a.jsx("div",{className:"flex min-h-8 items-center justify-center text-sm text-black/55",children:"Rendering preview…"}),c.status==="error"&&a.jsxs("div",{className:"text-left",children:[a.jsx("p",{className:"mb-3 text-sm text-red-700",children:"Preview could not be rendered. The source is preserved."}),a.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap rounded-[6px] bg-black/5 p-4 text-sm text-black",children:a.jsx("code",{children:n})})]})]})},mt="focus-ring-soft inline-flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border px-2.5 text-xs font-semibold outline-none transition-colors",Ve=e=>typeof e=="string"?e:!e||typeof e!="object"?"":"text"in e&&typeof e.text=="string"?e.text:"content"in e?Array.isArray(e.content)?e.content.map(Ve).join(""):Ve(e.content):"",ba=({block:e,contentRef:n})=>{const t=o.useRef(null),s=ua(e.props.language),r=e.content.map(Ve).join(""),[i,l]=o.useState(r),[c,f]=o.useState(r.length===0),u=s!==null&&!c,p=s==="mermaid"?"Diagram":"Math Formula",g=`${p} controls`,x=o.useCallback(h=>{t.current=h,n(h)},[n]);o.useEffect(()=>{const h=t.current;if(!h)return;const y=()=>l(h.textContent??""),N=new MutationObserver(y);return N.observe(h,{characterData:!0,childList:!0,subtree:!0}),()=>N.disconnect()},[]);const d=h=>{h.preventDefault(),h.stopPropagation()};return a.jsxs(a.Fragment,{children:[s&&a.jsxs("div",{role:"toolbar","aria-label":g,"data-rich-code-toolbar":!0,className:"flex min-h-11 w-full flex-wrap items-center justify-between gap-2 border-b border-border-subtle bg-elevated px-3 py-1.5 text-fg-secondary",contentEditable:!1,onMouseDown:d,children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1 text-xs font-semibold text-fg-secondary",children:[s==="mermaid"?a.jsx(_t,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}):a.jsx(Ot,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),a.jsx("span",{className:"truncate",children:p})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex items-center gap-0.5 rounded-[10px] border border-border-subtle bg-hover-subtle/55 p-0.5",children:[a.jsxs("button",{type:"button","aria-pressed":c,className:K(mt,c?"border-border-secondary/70 bg-elevated text-fg-default shadow-[0_8px_18px_-16px_rgba(15,18,24,0.28)]":"border-transparent text-fg-secondary hover:bg-hover-subtle hover:text-fg-default"),contentEditable:!1,onClick:h=>{h.stopPropagation(),f(!0)},children:[a.jsx(hr,{className:"h-3.5 w-3.5"}),"Edit"]}),a.jsxs("button",{type:"button","aria-pressed":u,className:K(mt,u?"border-border-secondary/70 bg-elevated text-fg-default shadow-[0_8px_18px_-16px_rgba(15,18,24,0.28)]":"border-transparent text-fg-secondary hover:bg-hover-subtle hover:text-fg-default"),contentEditable:!1,onClick:h=>{h.stopPropagation(),f(!1)},children:[a.jsx(Zn,{className:"h-3.5 w-3.5"}),"Preview"]})]}),a.jsx(pt,{variant:"toolbar",getText:()=>t.current?.textContent?.trimEnd()??""})]})]}),a.jsx("pre",{className:K(u&&"hidden",s&&"bg-[#181b20]"),children:a.jsx("code",{ref:x})}),s&&u&&a.jsx(xa,{kind:s,source:i}),!s&&a.jsx(pt,{getText:()=>t.current?.textContent?.trimEnd()??""})]})},va="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))]",ya={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function wa(e){const n=jt(),t=()=>{e.editor.blur(),n({to:Ae,params:{id:e.inlineContent.props.id}})},s=r=>{r.preventDefault(),r.stopPropagation()};return a.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:va,onMouseDown:s,onClick:r=>{s(r),t()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),t())},children:a.jsxs("span",{children:["[",e.inlineContent.props.title,"]"]})})}const Ca=Dt(ya,{render:e=>a.jsx(wa,{...e})}),Na=()=>{const e=ir(),[n,t]=o.useState([]),s={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};o.useEffect(()=>{const l=()=>{const f=e.document,u=[],p=g=>{for(const x of g){if(x.type==="heading"){const d=x,h=d.props.level||1,y=d.content?.map(N=>N.text||"").join("")||"";y.trim()&&u.push({id:x.id,level:h,text:y})}x.children&&Array.isArray(x.children)&&p(x.children)}};p(f),t(u)};l();const c=e.onChange?.(l);return()=>{c&&c()}},[e]);const r=l=>{e.setTextCursorPosition(l);const c=document.querySelector(`[data-id="${l}"]`);if(c){const f=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;c.scrollIntoView({behavior:f?"auto":"smooth",block:"center"})}},i=a.jsx(gr,{icon:a.jsx(Rt,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return n.length===0?a.jsxs("div",{className:"surface-base w-full p-4",children:[i,a.jsx(j,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):a.jsxs("div",{className:"surface-base w-full p-4",children:[a.jsx("div",{className:"mb-2",children:i}),a.jsx("nav",{className:"space-y-0.5",children:n.map(l=>{const c=l.level===1;return a.jsxs("button",{type:"button",onClick:()=>r(l.id),className:K("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",s[l.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",c?"text-fg-default":"text-fg-secondary"),children:[a.jsxs(j,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",l.level]}),a.jsx(j,{as:"span",variant:"body",weight:c?"semibold":"medium",className:"line-clamp-2 text-current",children:l.text})]},l.id)})})]})},ja=Mt({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>a.jsx(Na,{})})(),Sa="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",Ra={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function Aa(e){const n=jt(),t=()=>{e.editor.blur(),n({to:er,params:{id:e.inlineContent.props.id},search:{page:1}})},s=r=>{r.preventDefault(),r.stopPropagation()};return a.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Sa,onMouseDown:s,onClick:r=>{s(r),t()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),t())},children:a.jsx("span",{children:e.inlineContent.props.tag})})}const Ea=Dt(Ra,{render:e=>a.jsx(Aa,{...e})}),ka=e=>e,Ta=e=>e,Da=ka({tag:Ea,reference:Ca}),Ma=Ta({tableOfContents:ja}),ce=he.codeBlock,ht=Mt(ce.config,{meta:ce.implementation.meta,parse:ce.implementation.parse,parseContent:ce.implementation.parseContent,runsBefore:ce.implementation.runsBefore,render:ba})(),Pa={...ht,extensions:ce.extensions,implementation:{...ht.implementation,toExternalHTML:ce.implementation.toExternalHTML}},_a={...he.image,implementation:{...he.image.implementation,meta:{...he.image.implementation.meta,fileBlockAccept:[...Gt]}}},La=fr.create({inlineContentSpecs:{...pr,...Da},blockSpecs:{...he,image:_a,codeBlock:Pa,...Ma}}),Oa=(e,n)=>n.some(t=>t.name===`@${e}`),Ba=({onClick:e})=>a.jsx(Je,{triggerCharacter:"@",getItems:async n=>{const t=await br({query:n,limit:5});if(t.type==="error")return[];const{tags:s}=t.allTags,r=Oa(n,s),i=[{title:"Add a new tag",onItemClick:async()=>{const l=await vr({name:"@"+n});if(l.type==="error")return;const{id:c,name:f}=l.createTag;e({type:"tag",props:{id:c,tag:f}})}}];return s.length===0?i:s.map(l=>({title:l.name,onItemClick:()=>e({type:"tag",props:{id:l.id,tag:l.name}})})).concat(n&&!r?i:[])}}),Fa=/^ {0,3}(`{3,}|~{3,})/,Ha=/<[^<>\n]*>/g,Qt=/~+/g,Jt=/[\p{L}\p{M}\p{N}\p{Sc}%‰.,+\-/:°℃℉µμ·²³^]/u,Ye=new RegExp("^(?:[+-]?\\p{Sc}?|\\p{Sc}[+-]?)\\p{N}","u"),Xt=/&#(?:x[0-9a-f]+|\d+);/giu,$a=new Set(["Files","blocknote/html","vscode-editor-data"]),gt="OBTILDE",xt="",Ia=[/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,/\n{2} {0,3}-{2,48}\n{2}/,/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,/(?:\n|^)(?!\s)\w[^\n]{0,64}\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/],Ua=e=>e.split(`
22
- `).some(n=>{const t=n.trim();return t.length>2&&t.startsWith("|")&&t.endsWith("|")}),za=e=>Ia.some(n=>n.test(e))||Ua(e),Wa=e=>e.endsWith(`\r
23
- `)?{body:e.slice(0,-2),ending:`\r
24
- `}:e.endsWith(`
25
- `)||e.endsWith("\r")?{body:e.slice(0,-1),ending:e.slice(-1)}:{body:e,ending:""},en=(e,n,t)=>{let s=n;for(;e[s]===t;)s+=1;return s-n},tn=e=>{const n=e.slice(2,-1),t=n[0]?.toLowerCase()==="x",s=Number.parseInt(t?n.slice(1):n,t?16:10);return!Number.isSafeInteger(s)||s<0||s>1114111?e:String.fromCodePoint(s)},Ka=e=>{const n=e.replace(Xt,tn),t=e.toLowerCase();let s=0,r=`${gt}${s}${xt}`;for(;e.includes(r)||t.includes(encodeURIComponent(r).toLowerCase())||n.includes(r);)s+=1,r=`${gt}${s}${xt}`;return r},Va=(e,n,t)=>t-n>2?!1:nn(e,n)&&Za(e,t),bt=(e,n)=>{let t=n;for(;t>0&&Jt.test(e[t-1]??"");)t-=1;return{start:t,token:e.slice(t,n)}},Ya=(e,n)=>{let t=n;for(;t<e.length&&Jt.test(e[t]??"");)t+=1;return e.slice(n,t)},nn=(e,n)=>{const t=bt(e,n);if(Ye.test(t.token))return!0;if(!t.token)return!1;let s=t.start;for(;s>0&&(e[s-1]===" "||e[s-1]===" ");)s-=1;return s===t.start?!1:Ye.test(bt(e,s).token)},Za=(e,n)=>Ye.test(Ya(e,n)),rn=e=>{const n=[],t=new Set;for(const s of e.matchAll(Qt)){const r=s.index,i=s[0].length,l=r+i;if(i>2)continue;const c=l<e.length&&!/\s/u.test(e[l]??""),f=r>0&&!/\s/u.test(e[r-1]??"");if(Va(e,r,l)){if(f&&t.delete(i))continue;n.push({length:i,start:r});continue}f&&t.delete(i)||c&&nn(e,r)&&t.add(i)}return n},$e=(e,n)=>{let t="",s=0;const r=new Set(rn(e).map(i=>i.start));for(const i of e.matchAll(Qt)){const l=i.index,c=l+i[0].length;t+=e.slice(s,l),t+=r.has(l)?n.repeat(i[0].length):i[0],s=c}return t+e.slice(s)},qa=e=>{const n=e.slice(1,-1),t=/^[a-z][a-z0-9.+-]{1,31}:[^\s<>]*$/i.test(n)||/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(n),s=/^<\/?[a-z][\w:-]*(?:\s[^<>]*)?\/?\s*>$/i.test(e)||/^<![^<>]*>$/.test(e);return t||s},Ga=(e,n)=>{let t="",s=0;for(const r of e.matchAll(Ha)){const i=r.index;t+=$e(e.slice(s,i),n),t+=qa(r[0])?r[0]:$e(r[0],n),s=i+r[0].length}return t+$e(e.slice(s),n)},an=e=>rn(e).length>0,Qa=e=>{if(!an(e))return st(e);const n=Ka(e),t=Ga(e,n),s=encodeURIComponent(n);return st(t).split(n).join("~").split(s).join("~")},Ja=(e,n)=>{let t=0;for(let s=n-1;s>=0&&e[s]==="\\";s-=1)t+=1;return t%2===1},Xa=(e,n,t)=>{let s=n+t;for(;s<e.length;){const r=e.indexOf("`",s);if(r===-1)return null;const i=en(e,r,"`");if(i===t)return r+i;s=r+i}return null},es=(e,n)=>{let t=e.indexOf("`",n);for(;t!==-1;){const s=en(e,t,"`");if(!Ja(e,t)){const r=Xa(e,t,s);if(r!==null)return{start:t,end:r}}t=e.indexOf("`",t+s)}return null},ts=(e,n)=>{let t="",s=0;for(;s<e.length;){const r=es(e,s);if(!r){t+=n(e.slice(s));break}t+=n(e.slice(s,r.start)),t+=e.slice(r.start,r.end),s=r.end}return t},sn=(e,n)=>{let t=null;return e.split(new RegExp("(?<=\\n)")).map(s=>{const{body:r,ending:i}=Wa(s);if(t)return new RegExp(`^ {0,3}${t.marker}{${t.length},} *$`).test(r)&&(t=null),s;const l=r.match(Fa)?.[1];return l?(t={marker:l[0],length:l.length},s):`${ts(r,n)}${i}`}).join("")},ns=(e,n)=>{let t=0;for(let s=n;s<e.length;s+=1){const r=e[s];if(r==="\\"){s+=1;continue}if(r==="("){t+=1;continue}if(r===")"){if(t>0){t-=1;continue}return s}}return null},on=e=>{let n="",t=0;for(;t<e.length;){const s=e.indexOf("](",t);if(s===-1){n+=e.slice(t);break}const r=s+2,i=ns(e,r);if(i===null){n+=e.slice(t);break}n+=e.slice(t,r),n+=e.slice(r,i).split("\\&").join("&"),n+=")",t=i+1}return n},rs=(e,n)=>{const t=e[n-1];if(t!=="*"&&t!=="_")return!1;let s=n-1;for(;s>0&&e[s-1]===t;)s-=1;const r=e.slice(s,n),i=e.lastIndexOf(r,s-1);return i!==-1&&i+r.length<s},as=(e,n)=>{const t=e[n];if(t!=="*"&&t!=="_")return!1;let s=n+1;for(;s<e.length&&e[s]===t;)s+=1;const r=e.slice(n,s),i=e.indexOf(r,s);return i!==-1&&s<i},ss=(e,n,t)=>rs(e,n)||as(e,n+t),os=e=>sn(e,n=>{const t=n.replace(Xt,(s,r,i)=>ss(i,r,s.length)?tn(s):s);return on(t)}),is=e=>sn(e,on),cs=e=>{const n=e.getData("text/plain");n&&(e.setData("text/markdown",n),e.setData("text/plain",os(n)))},ls=({event:e,editor:n,defaultPasteHandler:t})=>{const s=e.clipboardData;if(!s||n.getTextCursorPosition().block.type==="codeBlock")return t();const r=Array.from(s.types);if(r.some(c=>$a.has(c)))return t();const i=r.includes("text/markdown"),l=s.getData(i?"text/markdown":"text/plain");return!l||!an(l)||!i&&r.includes("text/html")&&!za(l)?t():(n.pasteHTML(Qa(l)),!0)},ds=new Set(["tableOfContents"]),us="OCEAN_BRAIN_TAG_",fs="_TOKEN",ps=e=>`${us}${e}${fs}`,ms=e=>!Array.isArray(e)&&e?.type==="tableContent",hs=(e,n)=>Array.isArray(e)?e.map(n):ms(e)?{...e,rows:e.rows?.map(t=>({...t,cells:t.cells?.map(s=>({...s,content:s.content?.map(n)}))}))}:e,cn=(e,n)=>e.filter(t=>!ds.has(t.type)).map(t=>({...t,content:n(t.content),children:t.children?.length?cn(t.children,n):[]}));function gs(e){const n=new Map;let t=0;return{blocks:cn(e,r=>hs(r,i=>{if(i.type==="reference"){const l=String(i.props?.id||""),c=String(i.props?.title||i.props?.id||"");return{type:"text",text:l?`[[${c}]](note:${l})`:`[[${c}]]`,styles:{}}}if(i.type==="tag"){const l=i.props?.tag||"",c=ps(t);return t+=1,n.set(c,l),{type:"text",text:c,styles:{}}}return i})),placeholderToTag:n}}function xs(e,n){let t=e;for(const[s,r]of n.entries())t=t.split(s).join(`[${r}]`);return t}async function bs(e){return new Promise((n,t)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>n(s.result),s.onerror=r=>t(r)})}const vs=o.forwardRef(({content:e,currentNoteId:n,editable:t,onChange:s},r)=>{const{theme:i}=Nt(u=>u),l=Re(),c=cr({schema:La,initialContent:e&&JSON.parse(e)||void 0,pasteHandler:u=>ls(u),uploadFile:async(u,p)=>{const g=()=>{p&&c.getBlock(p)&&c.removeBlocks([p])};if(!ca(u.type))throw g(),l(dt),new Error(dt);try{return await dr({base64:await bs(u)})}catch(x){throw g(),l(ia),x}}},[l]);o.useImperativeHandle(r,()=>({getContent:()=>JSON.stringify(c.document),getMarkdown:()=>{const u=gs(c.document),p=c.blocksToMarkdownLossy(u.blocks);return is(xs(p,u.placeholderToTag))},getHtml:()=>c.blocksToHTMLLossy(c.document)}));const f=u=>{cs(u.clipboardData)};return a.jsxs(lr,{slashMenu:!1,theme:i,editor:c,editable:t,onChange:s,onCopy:f,onCut:f,children:[a.jsx(ra,{editor:c}),a.jsx(sa,{currentNoteId:n,onClick:u=>{c.insertInlineContent([u," "])}}),a.jsx(Ba,{onClick:u=>{c.insertInlineContent([u," "])}})]})}),ys=({event:e,noteId:n,editSessionId:t,loadedUpdatedAt:s,acceptedUpdatedAt:r,hasUnsavedChanges:i})=>{if(e.noteId!==n||e.type==="mcp.note.created")return{type:"ignore"};if(e.source==="web"&&e.editSessionId===t)return{type:"ignore"};if(e.type==="mcp.note.deleted")return{type:"notify",change:{type:"deleted",source:e.source},shouldPauseSave:!1};const l=je(e.updatedAt,s),c=je(e.updatedAt,r);return l!==null&&l<=0||c!==null&&c<=0?{type:"ignore"}:{type:"notify",change:{type:"updated",updatedAt:e.updatedAt,source:e.source},shouldPauseSave:i}},ws=({change:e,isConflict:n,loadedUpdatedAt:t})=>e?!(e.type==="updated"&&!n&&e.updatedAt===t):!1;function Cs({allowNextNavigationRef:e,hasExternalPendingChanges:n,saveStatus:t,flushPendingChanges:s,notify:r}){const i=o.useCallback(async()=>{if(e.current)return e.current=!1,!1;if(t==="conflict")return r("Resolve the note conflict before leaving."),!0;const l=await s();return l==="error"?(r("Save failed. Stay on this note and try again."),!0):l==="conflict"},[e,s,r,t]);Cr({disabled:t==="saved"&&!n,enableBeforeUnload:!1,shouldBlockFn:i})}const et=e=>`ocean-brain.note-draft.${e}`,Ns=e=>{if(typeof window>"u")return null;try{const n=window.localStorage.getItem(et(e));if(!n)return null;const t=JSON.parse(n);return typeof t.title!="string"||typeof t.content!="string"||typeof t.baseUpdatedAt!="string"?null:{title:t.title,content:t.content,baseUpdatedAt:t.baseUpdatedAt,createdAt:typeof t.createdAt=="number"?t.createdAt:Date.now(),...t.layout==="narrow"||t.layout==="wide"||t.layout==="full"?{layout:t.layout}:{}}}catch{return null}},Ie=(e,n)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(et(e),JSON.stringify(n))}catch{}},Ue=e=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(et(e))}catch{}},js=1e3,Ss="NOTE_UPDATE_CONFLICT";function Rs({noteId:e,initialContent:n,initialUpdatedAt:t,editSessionIdRef:s,getContent:r,beforeSave:i,hasExternalPendingChanges:l,serverVersionRef:c,executeWrite:f,onSaved:u,onConflict:p,onError:g}){const x=Ze(),d=o.useRef(null),h=o.useRef(null),y=o.useRef(!1),N=o.useRef(null),S=o.useRef(!1),A=o.useRef(t),w=c??A,m=o.useRef(0),v=o.useRef(!1),T=o.useRef(!0),H=o.useRef(u),M=o.useRef(p),V=o.useRef(g),be=o.useRef(i),X=o.useRef(l),me=o.useRef(f),[re,ee]=o.useState("saved"),[ke,le]=o.useState(null),$=o.useCallback(()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]),L=o.useCallback(E=>{T.current&&ee(E)},[]),Te=o.useCallback(E=>{w.current=E},[]),ve=o.useCallback((E,O={})=>({title:E,content:r()??n,createdAt:Date.now(),baseUpdatedAt:w.current,...O.layout?{layout:O.layout}:{}}),[r,n]),de=o.useCallback(()=>{h.current&&Ie(e,h.current)},[e]),ae=o.useCallback(E=>{v.current=!0,L("conflict"),M.current(E??w.current)},[L]),_=o.useCallback(async({ignoreConflict:E=!1,silent:O=!1}={})=>{if(y.current)return S.current=!0,N.current??"idle";const Me=h.current!==null,se=X.current?.()??!1;if(!Me&&!se)return S.current=!1,"idle";const I=m.current;S.current=!1,$(),y.current=!0,O||L("saving");const F=(async()=>{const ue=await be.current?.()??"idle";if(I!==m.current)return"idle";if(ue==="error")return y.current=!1,N.current=null,h.current?L("error"):L("saved"),"error";const P=h.current;if(!P)return y.current=!1,N.current=null,L("saved"),ue;h.current=null;const q=async()=>{if(I!==m.current)return"idle";let W;try{W=await We({id:e,title:P.title,content:P.content,...P.layout?{layout:P.layout}:{},editSessionId:s.current,...E?{force:!0}:{expectedUpdatedAt:w.current}})}catch{W={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(I!==m.current)return"idle";if(W.type==="error"){y.current=!1,N.current=null,h.current||(h.current=P),de();const U=W.errors[0];if(U.code===Ss&&!E){const oe=U.details?.extensions?.currentUpdatedAt;return v.current=!0,!O&&T.current&&(L("conflict"),M.current(oe??w.current)),"conflict"}return!O&&T.current&&(L("error"),V.current(U.message)),"error"}const we=!O&&T.current,J=B.notes.detail(e);if(await x.cancelQueries({queryKey:J,exact:!0}),I!==m.current)return"idle";y.current=!1,N.current=null,v.current=!1,w.current=W.updateNote.updatedAt,we&&H.current(W.updateNote.updatedAt),x.setQueryData(J,U=>U&&{...U,title:W.updateNote.title,content:P.content,...P.layout?{layout:P.layout}:{},updatedAt:W.updateNote.updatedAt}),At({noteId:e,updatedAt:W.updateNote.updatedAt,editSessionId:s.current});const fe=h.current;return fe?.baseUpdatedAt===P.baseUpdatedAt?(h.current={...fe,baseUpdatedAt:W.updateNote.updatedAt},de()):fe||Ue(e),h.current||Et(x),we&&(h.current?ee("pending"):ee("saved")),"saved"},z=me.current?await me.current(q):await q();return z?z==="saved"&&(h.current||S.current)?_({silent:O}):z:(h.current||(h.current=P),de(),y.current=!1,N.current=null,L("pending"),"idle")})();return N.current=F,F},[$,s,e,de,x,w,L]),te=o.useCallback((E,O={})=>{if(h.current=E,Ie(e,E),v.current){L("conflict");return}if(L("pending"),$(),O.immediate){_();return}d.current=window.setTimeout(()=>{_()},js)},[$,_,e,L]),ne=o.useCallback(E=>{if(h.current=E,Ie(e,E),le(null),E.baseUpdatedAt!==w.current){ae(w.current);return}te(E)},[e,te,ae]),ye=o.useCallback(()=>{m.current+=1,$(),h.current=null,y.current=!1,N.current=null,S.current=!1,v.current=!1,Ue(e),le(null),ee("saved")},[$,e]),De=o.useCallback(()=>{$(),N.current=null,S.current=!1,v.current=!1,L(h.current?"pending":"saved")},[$,L]),Q=o.useCallback(()=>{Ue(e),le(null)},[e]),Z=o.useCallback(()=>h.current,[]),Y=o.useCallback(E=>{$(),ae(E)},[$,ae]);return o.useEffect(()=>{be.current=i,me.current=f,X.current=l,M.current=p,V.current=g,H.current=u},[i,f,l,p,g,u]),o.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]),o.useEffect(()=>{h.current||y.current||v.current||(w.current=t,ee("saved"))},[t]),o.useEffect(()=>{m.current+=1,h.current=null,y.current=!1,N.current=null,S.current=!1,v.current=!1,w.current=t,le(Ns(e)),ee("saved")},[e]),o.useEffect(()=>{const E=O=>{!h.current&&!y.current&&!v.current&&!X.current?.()||(O.preventDefault(),O.returnValue="")};return window.addEventListener("beforeunload",E),()=>{window.removeEventListener("beforeunload",E)}},[]),o.useEffect(()=>()=>{$(),h.current&&!v.current&&_({silent:!0})},[$,_]),{saveStatus:re,localDraft:ke,serverUpdatedAtRef:w,hasUnsavedChanges:re!=="saved",buildDraft:ve,queueSave:te,flushPendingSave:_,restoreLocalDraft:ne,discardLocalDraft:Q,clearDrafts:ye,resolveConflict:De,pauseForConflict:Y,getPendingDraft:Z,setServerUpdatedAt:Te}}function As(){const e=o.useRef(Promise.resolve()),n=o.useRef(0),t=o.useRef(0),[s,r]=o.useState(!1),i=o.useCallback(u=>{t.current+=1,r(!0);const p=n.current,g=()=>p===n.current?u():void 0,x=e.current.then(g,g);e.current=x.then(()=>{},()=>{});const d=()=>{t.current-=1,t.current===0&&r(!1)};return x.then(d,d),x},[]),l=o.useCallback(()=>{n.current+=1},[]),c=o.useCallback(()=>e.current,[]),f=o.useCallback(()=>t.current>0,[]);return o.useMemo(()=>({execute:i,invalidatePending:l,drain:c,isBusy:s,hasPendingWrites:f}),[c,i,f,l,s])}const Es="NOTE_UPDATE_CONFLICT",ze=e=>{const n=ge(e);return G(n??Number(e)).format("YYYY-MM-DD HH:mm:ss")},ks=e=>e?.extensions?.currentUpdatedAt;function Ts({noteId:e,navigateToNote:n,notify:t}){const s=Ze(),r=o.useRef(null),i=o.useRef(null),[l]=o.useState(ot),c=o.useRef(l),f=o.useRef(null),u=o.useRef(null),p=o.useRef(!1),g=o.useRef(0),x=yt({queryKey:B.notes.detail(e),queryFn:async()=>{const b=await On(e);if(b.type==="error")throw b;return b.note},gcTime:0}),d=x.data,h=x.refetch,y=o.useRef(d.updatedAt),N=o.useRef(d.updatedAt),[S,A]=o.useState(d.title),[w,m]=o.useState(d.pinned),[v,T]=o.useState(d.layout||"wide"),H=o.useRef(v),[M,V]=o.useState(null),[be,X]=o.useState(null),[me,re]=o.useState(0),[ee,ke]=o.useState(()=>ze(d.updatedAt)),[le,$]=o.useState(d.updatedAt),[L,Te]=o.useState(0),[ve,de]=o.useState(!1),ae=o.useRef(!1),{execute:_,invalidatePending:te,drain:ne,isBusy:ye,hasPendingWrites:De}=As(),Q=o.useCallback(b=>{H.current=b,T(b)},[]),Z=o.useCallback((b,C={})=>{y.current=b,N.current=b,ke(ze(b)),$(b),C.confirmSave&&Te(R=>R+1)},[]),Y=o.useCallback(async({updatedAt:b,patch:C,confirmSave:R=!0})=>{const pe=B.notes.detail(e),Le=g.current;return await s.cancelQueries({queryKey:pe,exact:!0}),Le!==g.current?!1:(Z(b,{confirmSave:R}),s.setQueryData(pe,Oe=>Oe&&{...Oe,...C,updatedAt:b}),At({noteId:e,updatedAt:b,editSessionId:c.current}),Et(s),!0)},[Z,e,s]),E=o.useCallback(b=>{ae.current=b,de(b)},[]),O=o.useCallback(()=>f.current?.flushPendingSave({expectedUpdatedAt:y.current})??Promise.resolve("idle"),[]),Me=Rs({noteId:e,initialContent:d.content,initialUpdatedAt:d.updatedAt,editSessionIdRef:c,serverVersionRef:y,executeWrite:_,getContent:()=>r.current?.getContent(),beforeSave:O,hasExternalPendingChanges:()=>ae.current||De(),onSaved:b=>{u.current=null,Z(b,{confirmSave:!0})},onConflict:b=>{V({type:"updated",updatedAt:b,source:"unknown"}),t("This note changed elsewhere. Choose how to resolve the draft.")},onError:t}),{saveStatus:se,localDraft:I,serverUpdatedAtRef:F,hasUnsavedChanges:ue,buildDraft:P,queueSave:q,flushPendingSave:z,restoreLocalDraft:W,discardLocalDraft:we,clearDrafts:J,resolveConflict:fe,pauseForConflict:U,getPendingDraft:oe}=Me,Ce=ue||ve||ye,tt=o.useCallback(async b=>{const C=await z(b);return C==="error"||C==="conflict"||await ne(),C},[ne,z]),dn=o.useCallback(b=>_(async()=>{const C=await Bn({...b,expectedUpdatedAt:y.current});return C.type==="success"&&await Y({updatedAt:C.updateNoteProperties.updatedAt,patch:{properties:C.updateNoteProperties.properties}}),C}),[Y,_]);Cs({allowNextNavigationRef:p,hasExternalPendingChanges:ve||ye,saveStatus:se,flushPendingChanges:tt,notify:t}),o.useEffect(()=>{if(Ce){d.updatedAt!==F.current&&(je(d.updatedAt,F.current)??0)>0&&U(d.updatedAt);return}const b=N.current;if(!(b&&d.updatedAt!==b&&(je(d.updatedAt,b)??0)<0)&&(m(d.pinned),Q(d.layout||"wide"),A(d.title),b!==d.updatedAt)){const C=r.current?.getContent();Z(d.updatedAt),(C===void 0||C!==d.content)&&(X(null),re(R=>R+1))}},[Z,Ce,d.content,d.layout,d.pinned,d.title,d.updatedAt,U,F]),o.useEffect(()=>{M?.type!=="updated"||se==="conflict"||M.updatedAt!==d.updatedAt||(Z(d.updatedAt),V(null))},[Z,M,d.updatedAt,se]),o.useEffect(()=>qn(b=>{const C=ys({event:b,noteId:e,editSessionId:c.current,loadedUpdatedAt:d.updatedAt,acceptedUpdatedAt:F.current,hasUnsavedChanges:Ce});C.type!=="ignore"&&(C.shouldPauseSave&&C.change.type==="updated"&&U(C.change.updatedAt),V(C.change))}),[Ce,d.updatedAt,e,U,F]);const un=o.useCallback(()=>{q(P(S))},[P,q,S]),fn=o.useCallback(b=>{A(b),q(P(b))},[P,q]),pn=o.useCallback(()=>{q(P(S),{immediate:!0})},[P,q,S]),mn=o.useCallback(async b=>{if(ue){Q(b),q(P(S,{layout:b}),{immediate:!0}),t("Layout will be saved with your draft.");return}const C=await z();C==="error"||C==="conflict"||await _(async()=>{const R=await We({id:e,layout:b,editSessionId:c.current,expectedUpdatedAt:F.current});if(R.type==="error"){R.errors[0].code===Es&&(u.current=b,Q(b),U(ks(R.errors[0].details)??F.current)),t(R.errors[0].message);return}await Y({updatedAt:R.updateNote.updatedAt,patch:{layout:b}})&&(u.current=null,Q(b),t("Layout has been updated."))})},[Y,P,_,z,ue,e,t,U,q,F,S]),hn=o.useCallback(async()=>{const b=await z();if(b==="error"||b==="conflict")return;const C=!w;await _(async()=>{const R=await Fn(e,C);if(R.type==="error"){t(R.errors[0].message);return}await Y({updatedAt:R.pinNote.updatedAt,patch:{pinned:C},confirmSave:!1})&&m(C)})},[Y,_,z,w,e,t]),Pe=o.useCallback(()=>({id:e,title:S,createdAt:d.createdAt,updatedAt:F.current||d.updatedAt}),[d.createdAt,d.updatedAt,e,F,S]),gn=o.useCallback(async()=>{const b=r.current?.getMarkdown();if(b===void 0){t("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(Kt(b,Pe())),t("Copied note as Markdown.")}catch{t("Failed to copy Markdown.")}},[Pe,t]),xn=o.useCallback(async()=>{f.current?.invalidateInFlightSave(),te(),await ne(),g.current+=1;const b=await h();if(b.error||!b.data){t("Failed to reload the latest note state.");return}f.current?.discardPendingChanges(),J(),u.current=null,Z(b.data.updatedAt),A(b.data.title),Q(b.data.layout||"wide"),X(null),re(C=>C+1),V(null)},[J,Z,ne,te,t,h]),bn=o.useCallback(async()=>{if(oe()){u.current=null,V(null),await z({ignoreConflict:!0});return}const C=u.current;if(!C){V(null),await z({ignoreConflict:!0});return}await _(async()=>{const R=await We({id:e,layout:C,editSessionId:c.current,force:!0});if(R.type==="error"){t(R.errors[0].message);return}await Y({updatedAt:R.updateNote.updatedAt,patch:{layout:C}})&&(u.current=null,fe(),V(null),Q(C))})},[Y,_,z,oe,e,t,fe]),vn=o.useCallback(async()=>{const b=oe();if(!b||await O()==="error")return;const R=await Hn({title:nt(b.title||"untitled"),content:nt(b.content),layout:b.layout??v});if(R.type==="error"){t(R.errors[0].message);return}p.current=!0,u.current=null,V(null),J(),Promise.resolve(n(R.createNote.id)).finally(()=>{p.current=!1})},[J,O,oe,v,n,t]),yn=o.useCallback(()=>{I&&(A(I.title),I.layout&&Q(I.layout),X(I.content),re(b=>b+1),W(I))},[I,W]),wn=o.useCallback(()=>{},[]),Cn=o.useCallback(async b=>(f.current?.invalidateInFlightSave(),te(),await ne(),g.current+=1,_(async()=>{const C=await $n(b,F.current);if(C.type==="error")return C;const R=C.restoreNoteSnapshot;return await Y({updatedAt:R.updatedAt,patch:{title:R.title,content:R.content,layout:R.layout,pinned:R.pinned}})&&(c.current=ot(),f.current?.discardPendingChanges(),J(),u.current=null,V(null),A(R.title),Q(R.layout||"wide"),m(R.pinned),X(R.content),re(Le=>Le+1)),C})),[Y,J,ne,_,te]),_e=se==="conflict"&&M?.type==="updated",Nn=_e?oe():null;return{document:{title:S,titleRef:i,isPinned:w,layout:v,getLayout:()=>H.current,properties:d.properties,createdAt:ze(d.createdAt),onTitleChange:fn,onLayoutSave:mn,onTogglePinned:hn},editor:{ref:r,key:`${e}:${me}`,content:be??d.content,getContent:()=>r.current?.getContent()??"",getHtml:()=>r.current?.getHtml(),getMarkdown:()=>r.current?.getMarkdown(),onChange:un},save:{status:se,lastSavedAt:ee,lastSavedVersion:le,confirmationRevision:L,onManualSave:pn,flushPendingChanges:tt},recovery:{localDraftCreatedAt:I?G(I.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,onRestoreLocalDraft:yn,onDiscardLocalDraft:we,onClonePendingDraft:vn},externalChange:{value:M,isConflict:_e,hasConflictDraft:Nn!==null,isBlocking:ws({change:M,isConflict:_e,loadedUpdatedAt:d.updatedAt}),isReloading:x.isRefetching,onReload:xn,onOverwrite:bn},properties:{ref:f,expectedUpdatedAt:F.current,editSessionId:c.current,saveProperties:dn,onPendingChange:E,onSaved:wn},exportDocument:{metadata:Pe(),onCopyMarkdown:gn},snapshots:{restore:Cn}}}const ln=In(Ae),Ds={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},Ms=a.jsx(Ge,{title:"Loading note",variant:"none",children:a.jsxs("main",{className:"mx-auto max-w-[896px]",children:[a.jsx(ie,{className:"mb-8",height:123}),a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx(ie,{height:135}),a.jsx(ie,{className:"ml-12",height:320}),a.jsx(ie,{height:107}),a.jsx(ie,{height:100})]})]})});function Ps({noteId:e}){return a.jsx(qe,{fallback:a.jsx(ie,{height:107}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:n,retry:t})=>a.jsx(Qe,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:n,onRetry:t,showBackAction:!1,showHomeAction:!1}),children:a.jsx(ta,{noteId:e})})}function _s({noteId:e}){return a.jsx(qe,{fallback:a.jsx(ie,{height:100}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:n,retry:t})=>a.jsx(Qe,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:n,onRetry:t,showBackAction:!1,showHomeAction:!1}),children:a.jsx(Rr,{noteId:e,render:n=>n?.length?a.jsx(Tt,{icon:a.jsx(xr,{className:"h-3.5 w-3.5"}),title:"Back References",children:a.jsx("ul",{className:"flex flex-col",children:n.map(t=>a.jsx("li",{children:a.jsxs(Un,{to:Ae,params:{id:t.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:[a.jsx(yr,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),a.jsx(j,{as:"span",variant:"body",weight:"medium",className:"text-current",children:t.title})]})},t.id))})}):null})})}function Ls({id:e}){const n=Re(),t=ln.useNavigate(),[s,r]=o.useState(!1),[i,l]=o.useState(!1),[c,f]=o.useState(!1),u=Ts({noteId:e,notify:n,navigateToNote:M=>t({to:Ae,params:{id:M}})}),{onCreate:p,onDelete:g,deleteWarningDialog:x}=Gn(),{document:d,editor:h,save:y,recovery:N,externalChange:S,properties:A,exportDocument:w,snapshots:m}=u,v=()=>t({to:tr,search:{page:1}}),T=async()=>{const M=await y.flushPendingChanges();M==="error"||M==="conflict"||await g(e,v)},H=async()=>{const M=await y.flushPendingChanges();M==="error"||M==="conflict"||await p(d.titleRef.current?.value||"untitled",h.getContent(),d.getLayout())};return a.jsx(Ge,{title:d.title,variant:"none",children:a.jsxs("main",{className:K("mx-auto",Ds[d.layout]),children:[a.jsx(Dr,{title:d.title,titleRef:d.titleRef,isPinned:d.isPinned,createdAt:d.createdAt,saveStatus:y.status,savedAt:y.lastSavedAt,savedVersion:y.lastSavedVersion,saveConfirmationRevision:y.confirmationRevision,onTitleChange:d.onTitleChange,onCopyMarkdown:()=>{w.onCopyMarkdown()},onDownloadDocument:()=>f(!0),onTogglePinned:()=>{d.onTogglePinned()},onChangeLayout:()=>r(!0),onCloneNote:()=>{H()},onRestoreVersion:()=>l(!0),onDelete:()=>{T()},onSave:y.onManualSave}),a.jsx(Jr,{localDraftCreatedAt:N.localDraftCreatedAt,hasSaveError:y.status==="error",onRestoreDraft:N.onRestoreLocalDraft,onDiscardDraft:N.onDiscardLocalDraft,onRetrySave:y.onManualSave,onSaveAsNewNote:()=>{N.onClonePendingDraft()}}),a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx(Xn,{ref:A.ref,noteId:e,properties:d.properties,expectedUpdatedAt:A.expectedUpdatedAt,editSessionId:A.editSessionId,disabled:y.status!=="saved",saveProperties:A.saveProperties,onPendingChange:A.onPendingChange,onSaved:A.onSaved}),a.jsx(vs,{ref:h.ref,content:h.content,currentNoteId:e,onChange:h.onChange},h.key),a.jsx(Ps,{noteId:e}),a.jsx(_s,{noteId:e})]}),a.jsx(Er,{isOpen:s,onClose:()=>r(!1),onSave:d.onLayoutSave,currentLayout:d.layout}),a.jsx(Qr,{isOpen:S.isBlocking,isDeleted:S.value?.type==="deleted",isConflict:S.isConflict,hasDraft:S.hasConflictDraft,source:S.value?.source??"unknown",isReloading:S.isReloading,onReload:()=>{S.onReload()},onOverwrite:()=>{S.onOverwrite()},onCloneDraft:()=>{N.onClonePendingDraft()},onOpenTrash:()=>{v()}}),a.jsx(Zr,{isOpen:c,metadata:w.metadata,getHtml:h.getHtml,getMarkdown:h.getMarkdown,onClose:()=>f(!1)}),a.jsx(Xr,{isOpen:i,noteId:e,onClose:()=>l(!1),restoreSnapshot:m.restore}),x]})})}function to(){const{id:e}=ln.useParams();if(!e)throw new Error("Note id is required.");return a.jsx(qe,{fallback:Ms,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[e],renderError:({error:n,retry:t})=>a.jsx(Ge,{title:"Note",variant:"none",children:a.jsx(Qe,{title:"Failed to load note",description:"Retry loading the note editor.",error:n,onRetry:t})}),children:a.jsx(Ls,{id:e},e)})}export{Ls as NoteContent,to as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./floating-ui.react-dom-BWTnA00G.js";import{A as n}from"./note.api-D3oJmG3q.js";const m=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M230.15,70.54,185.46,25.86a20,20,0,0,0-28.28,0L33.86,149.17A19.86,19.86,0,0,0,28,163.31V208a20,20,0,0,0,20,20H216a12,12,0,0,0,0-24H125L230.15,98.83A20,20,0,0,0,230.15,70.54ZM136,81l11,11L76,163,65,152ZM52,204V173l15.52,15.51h0L83,204Zm52-13L93,180l71-71,11,11Zm88-88L153,64l18.34-18.34,39,39Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M221.66,90.34,192,120,136,64l29.66-29.66a8,8,0,0,1,11.31,0L221.66,79A8,8,0,0,1,221.66,90.34Z",opacity:"0.2"}),e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM79.32,188,164,103.31,180.69,120,96,204.69ZM68,176.69,51.31,160,136,75.31,152.69,92Zm-20,2.62L76.69,208H48Zm144-70.62L147.32,64l24-24L216,84.69Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM79.32,188l90.34-90.34,16.69,16.68L96,204.69Zm79-101.66h0L68,176.69,51.31,160l90.35-90.34ZM48,179.31,76.69,208H48Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M225.91,74.79,181.22,30.1a14,14,0,0,0-19.8,0L38.1,153.41a13.94,13.94,0,0,0-4.1,9.9V208a14,14,0,0,0,14,14H216a6,6,0,0,0,0-12H110.49L225.91,94.59A14,14,0,0,0,225.91,74.79ZM76.49,188,164,100.48,183.52,120,96,207.51ZM68,179.52,48.49,160,136,72.49,155.52,92ZM46,208V174.48L81.52,210H48A2,2,0,0,1,46,208ZM217.42,86.1,192,111.52,144.49,64,169.9,38.59a2,2,0,0,1,2.83,0l44.69,44.68A2,2,0,0,1,217.42,86.1Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M227.32,73.37,182.63,28.69a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H216a8,8,0,0,0,0-16H115.32l112-112A16,16,0,0,0,227.32,73.37ZM136,75.31,152.69,92,68,176.69,51.31,160ZM48,208V179.31L76.69,208Zm48-3.31L79.32,188,164,103.31,180.69,120Zm96-96L147.32,64l24-24L216,84.69Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224.49,76.2,179.8,31.51a12,12,0,0,0-17,0L39.51,154.83A12,12,0,0,0,36,163.31V208a12,12,0,0,0,12,12H216a4,4,0,0,0,0-8H105.66L224.49,93.17A12,12,0,0,0,224.49,76.2ZM73.66,188,164,97.66,186.35,120,96,210.34ZM68,182.34,45.66,160,136,69.66,158.35,92ZM44,208V169.66l21.17,21.17h0L86.34,212H48A4,4,0,0,1,44,208ZM218.83,87.51,192,114.34,141.66,64l26.83-26.83a4,4,0,0,1,5.66,0l44.68,44.69A4,4,0,0,1,218.83,87.51Z"}))]]),a=e.forwardRef((t,l)=>e.createElement(n,{ref:l,...t,weights:m}));a.displayName="PencilLineIcon";const L=a;export{L as m};
@@ -1 +0,0 @@
1
- import{r as e}from"./floating-ui.react-dom-BWTnA00G.js";import{A as l}from"./note.api-D3oJmG3q.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"./floating-ui.react-dom-BWTnA00G.js";import{D as k,T as h,F as H,G as M,Q as E,P as w,E as S,k as L,l as o,h as O}from"./note.api-D3oJmG3q.js";import{N as C,R as U}from"./url-9nrbQs7Z.js";import{u as I,R as P}from"./useReminderMutate-BrGO9M0o.js";import{f as Y,d as u}from"./time-D5LRMumI.js";const g={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function B({reminder:t,onUpdate:l,onDelete:f}){const j=y=>{const r=u(Number(y)),m=u();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=u(Number(y)),m=u(),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=g[i],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",x=t.content?.trim()||t.note?.title||"Untitled reminder",v=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=a(t.reminderDate),$=j(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","aria-label":`Reminder: ${x}`}),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:x}),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:C,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:v})})]})]}),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(M,{button:e.jsx(Y,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>f(t.id,c)}]})})]})}const R=O(U),A=[{label:"High",className:g.high},{label:"Medium",className:g.medium},{label:"Low",className:g.low}];function K(){const t=R.useNavigate(),{page:l}=R.useSearch(),{onUpdate:f,onDelete:j}=I(),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(E,{fallback:e.jsx(w,{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(P,{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(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(S,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(w,{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:f,onDelete:j},n.id))}),s&&a<s&&e.jsx(L,{page:l,last:Math.ceil(s/a),onChange:n=>{t({search:x=>({...x,page:n})})}})]})})}})})}export{K as default};
@@ -1,31 +0,0 @@
1
- import{j as e,r as g}from"./floating-ui.react-dom-BWTnA00G.js";import{a as L,m as Q,t as G}from"./time-D5LRMumI.js";import{g as q,x as V,y as X,c as J,H as Y,B as W,T as m,q as k,P as Z,E as A,Q as ee,F as C,k as te,h as re,l as w,i as se,s as ae}from"./note.api-D3oJmG3q.js";import{A as ne,p as ie}from"./AuxiliaryPanelHeader-B1k7pZpn.js";import{N as P,g as oe,h as le,T as ce}from"./url-9nrbQs7Z.js";import{f as de}from"./Graph-LY_IgMYy.js";import{V as R}from"./ViewChip-DlCkL4z4.js";import"./app-BpSMjzET.js";import{f as me}from"./search-admin-adapter-CJnJmL6w.js";import{s as he}from"./File.es-Ct7fscBg.js";import"./preload-helper-BXl3LOEh.js";const ue=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),B=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=ue(r),n=new RegExp(`(${a})`,"gi"),o=new RegExp(`^${a}$`,"i"),i=t.split(n);return e.jsx("span",{children:i.map((c,d)=>o.test(c)?e.jsx("mark",{children:c},d):e.jsx(g.Fragment,{children:c},d))})},xe={hybrid:"HYBRID",lexical:"LEXICAL",semantic:"SEMANTIC"};function pe({query:t,limit:s=25,offset:r=0,mode:a="hybrid"}){return q(`query FetchSearchNotes($query: String!, $pagination: PaginationInput!, $mode: SearchMode!) {
2
- searchNotes(query: $query, pagination: $pagination, mode: $mode) {
3
- totalCount
4
- semanticAvailable
5
- semanticUsed
6
- semanticError
7
- matches {
8
- noteId
9
- lexical
10
- semantic
11
- }
12
- notes {
13
- id
14
- title
15
- content
16
- pinned
17
- tags {
18
- id
19
- name
20
- }
21
- createdAt
22
- updatedAt
23
- }
24
- }
25
- }`,{query:t,mode:xe[a],pagination:{limit:s,offset:r}})}function fe(t,s=5){return q(`query FetchSearchRelatedNotes($noteId: ID!, $limit: Int!) {
26
- searchRelatedNotes(noteId: $noteId, limit: $limit) {
27
- id
28
- title
29
- reasons
30
- }
31
- }`,{noteId:t,limit:s})}const M=[{value:"hybrid",label:"Keyword + Meaning"},{value:"lexical",label:"Keyword only"},{value:"semantic",label:"Meaning only"}],ge=({value:t,onChange:s,className:r})=>e.jsx(V,{value:t,ariaLabel:"Search mode",variant:"ghost",size:"md",className:J("max-w-[12rem] shrink-0",r),onValueChange:a=>{M.some(n=>n.value===a)&&s(a)},children:M.map(a=>e.jsx(X,{value:a.value,children:a.label},a.value))}),be=({value:t,onChange:s,onSubmit:r,onClear:a,onCompositionChange:n,mode:o,onModeChange:i,autoFocus:c=!1,placeholder:d="Describe what you remember"})=>{const l=h=>{h.preventDefault(),r()};return e.jsx("form",{role:"search",className:"flex w-full",onSubmit:l,children:e.jsxs("div",{className:"flex min-h-14 min-w-0 flex-1 flex-wrap items-center overflow-hidden rounded-[16px] border border-border-subtle bg-elevated px-2 py-1 transition-colors focus-within:border-border-focus focus-within:shadow-[0_0_0_4px_color-mix(in_srgb,var(--accent-soft-primary)_90%,transparent)]",children:[o&&i&&e.jsxs("div",{className:"flex w-full items-center border-b border-border-subtle/70 pb-1 md:w-auto md:border-b-0 md:pb-0",children:[e.jsx(ge,{value:o,onChange:i,className:"max-w-full"}),e.jsx("span",{className:"mx-1 hidden h-6 w-px shrink-0 bg-divider md:block","aria-hidden":"true"})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 basis-full items-center md:basis-auto",children:[e.jsx("span",{className:"flex h-11 w-10 shrink-0 items-center justify-center text-fg-tertiary","aria-hidden":"true",children:e.jsx(de,{className:"h-[18px] w-[18px]",weight:"bold"})}),e.jsx("input",{type:"text",role:"searchbox","aria-label":"Search notes",autoFocus:c,autoComplete:"off",placeholder:d,value:t,onChange:h=>s(h.target.value),onCompositionStart:()=>n?.(!0),onCompositionEnd:h=>{s(h.currentTarget.value),n?.(!1)},className:"h-11 min-w-0 flex-1 bg-transparent px-1 text-base text-fg-default outline-none placeholder:text-fg-placeholder"}),t&&e.jsx("button",{type:"button","aria-label":"Clear search",className:"focus-ring-soft flex h-10 w-10 shrink-0 items-center justify-center rounded-[10px] text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",onClick:()=>{s(""),a?.()},children:e.jsx(Y,{className:"h-4 w-4",weight:"bold"})}),e.jsx(W,{type:"submit",size:"lg",disabled:!t.trim(),className:"my-1 px-4 sm:px-5",children:"Search"})]})]})})},ye=t=>t?.lexical&&t.semantic?"Keyword + Meaning":t?.semantic?"Meaning match":t?.lexical?"Keyword match":null,je=({match:t})=>{const s=ye(t);return s?e.jsx(m,{as:"span",variant:"meta",weight:"semibold",tone:"tertiary",className:"shrink-0 rounded-full bg-muted px-2 py-1",children:s}):null},Ne=()=>{const t=L({queryKey:k.search.adminStatus(),queryFn:me,staleTime:6e4,retry:1});return{status:t.data,isLoading:t.isPending,isError:t.isError,isSemanticSearchEnabled:t.data?.config.enabled===!0,isSemanticSearchAvailable:t.data?.available===!0}},I=180,T=t=>t.replace(/\s+/g," ").trim(),O=t=>T(t).toLowerCase().split(" ").filter(Boolean),ve=(t,s)=>{const r=T(t),a=T(s).toLowerCase();if(!a)return r;const n=r.toLowerCase();let o=a,i=n.indexOf(a);if(i===-1){const h=O(s).map(f=>({term:f,index:n.indexOf(f)})).filter(f=>f.index>=0).sort((f,v)=>f.index-v.index||v.term.length-f.term.length)[0];h&&(o=h.term,i=h.index)}if(i===-1)return r.length>I?`${r.slice(0,I-1).trimEnd()}…`:r;const c=Math.max(0,i-56),d=Math.min(r.length,i+o.length+84);let l=r.slice(c,d).trim();return c>0&&(l=`…${l}`),d<r.length&&(l=`${l}…`),l},Se=t=>Array.isArray(t)?t.map(s=>{if(!s||typeof s!="object")return"";const r=s.text;return typeof r=="string"?r:""}).join(""):"",we=t=>t==="heading"?"heading":t==="bulletListItem"||t==="numberedListItem"?"list":t==="checkListItem"?"checklist":t==="quote"?"quote":t==="codeBlock"?"code":"content",z=(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=T(Se(r.content));n&&s.push({kind:we(a),text:n});const o=r.children;Array.isArray(o)&&z(o,s)})},Ee=(t,s)=>{try{const r=JSON.parse(t),a=[];if(z(r,a),a.length===0)return[];const n=O(s),o=n.length>0?a.filter(c=>n.some(d=>c.text.toLowerCase().includes(d))):a;return(o.length>0?o:a).slice(0,2).map(c=>({...c,text:ve(c.text,s)}))}catch{return[]}},_=re(oe),E=10,Te=400,H=3e4,Ce=t=>t===1?"1 result":`${t} results`,ke=t=>{const s=Number(t),r=Number.isFinite(s)?s:Date.parse(t);return Number.isFinite(r)?`Updated ${G(r)}`:"Updated recently"},Ae=({searchParams:t,render:s})=>{const{data:r}=se({queryKey:k.search.results(t),async queryFn(){const a=await pe(t);if(a.type==="error")throw a;return a.searchNotes},staleTime:H});return s(r)},$=()=>e.jsx("main",{className:"mt-5 flex flex-col gap-3","aria-label":"Searching notes",children:Array.from({length:2},(t,s)=>e.jsxs("div",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(w,{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.jsx(w,{width:84,height:12,className:"rounded-full"}),e.jsx(w,{width:"100%",height:14,className:"rounded-full"}),e.jsx(w,{width:"82%",height:14,className:"rounded-full"})]})})]},s))}),Re=({note:t})=>{const s=t.tags.slice(0,2),r=t.tags.length-s.length;return e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1.5",children:[t.pinned&&e.jsxs("span",{className:"inline-flex items-center text-fg-tertiary",title:"Pinned note",children:[e.jsx(Q,{className:"h-3.5 w-3.5",weight:"fill","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Pinned note"})]}),e.jsx(m,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:ke(t.updatedAt)}),s.map(a=>e.jsx(C,{to:ce,params:{id:a.id},search:{page:1},children:e.jsx(R,{size:"compact",className:"border-border-subtle bg-transparent text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:a.name})},a.id)),r>0&&e.jsxs(R,{size:"compact",className:"border-border-subtle bg-subtle text-fg-tertiary",children:["+",r]})]})},Me=t=>t==="list"?"•":t==="checklist"?"☐":null,Ie=t=>{if(t==="quote")return"border-l-2 border-border-secondary pl-3 italic";if(t==="code")return"rounded-[10px] bg-subtle/70 px-2.5 py-2 font-mono text-sm"},_e=({blocks:t,query:s})=>e.jsx("div",{className:"rounded-[14px] border border-border-subtle/80 bg-muted/40 px-3.5 py-3",children:t.map((r,a)=>{const n=Me(r.kind);return e.jsx("div",{className:a>0?"mt-2 border-t border-border-subtle/70 pt-2":void 0,children:e.jsxs("div",{className:"flex items-start gap-2",children:[n&&e.jsx("span",{className:"mt-0.5 w-4 shrink-0 text-center text-fg-tertiary","aria-hidden":"true",children:n}),e.jsx(m,{as:"p",variant:"body",weight:r.kind==="heading"?"semibold":"regular",tone:r.kind==="heading"?"default":"secondary",className:Ie(r.kind)??"leading-[1.65]",children:e.jsx(B,{match:s,children:r.text})})]})},`${r.kind}:${a}`)})}),$e=({noteId:t})=>{const[s,r]=g.useState(!1),{data:a,isError:n,isLoading:o}=L({queryKey:k.search.related(t),queryFn:async()=>{const i=await fe(t);if(i.type==="error")throw i;return i.searchRelatedNotes},enabled:s,staleTime:H});return e.jsxs("details",{className:"group border-t border-border-subtle/70 pt-3",onToggle:i=>r(i.currentTarget.open),children:[e.jsxs("summary",{className:"focus-ring-soft flex cursor-pointer list-none items-center justify-between gap-3 rounded-[10px] border border-transparent px-2.5 py-1.5 outline-none transition-colors hover:bg-hover-subtle marker:hidden",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ne,{icon:e.jsx(ie,{className:"h-3.5 w-3.5"}),title:"Related notes",className:"text-fg-tertiary"}),a&&e.jsx(m,{as:"span",variant:"meta",weight:"medium",tone:"tertiary",children:a.length})]}),e.jsx(ae,{className:"h-4 w-4 shrink-0 text-fg-tertiary transition-transform group-open:rotate-180","aria-hidden":"true"})]}),e.jsxs("div",{className:"mt-2",children:[o&&e.jsx(m,{as:"p",variant:"meta",tone:"tertiary",className:"px-2 py-1.5",children:"Looking for related notes…"}),n&&e.jsx(m,{as:"p",variant:"meta",tone:"error",className:"px-2 py-1.5",children:"Related notes could not be loaded."}),!o&&!n&&a?.length===0&&e.jsx(m,{as:"p",variant:"meta",tone:"tertiary",className:"px-2 py-1.5",children:"No direct connections found yet."}),!o&&!n&&a&&a.length>0&&e.jsx("ul",{className:"flex flex-col",children:a.map(i=>e.jsx("li",{children:e.jsxs(C,{to:P,params:{id:i.id},className:"flex min-w-0 items-start 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(he,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-fg-tertiary","aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx(m,{as:"span",variant:"body",weight:"medium",className:"text-current line-clamp-1",children:i.title||"Untitled"}),e.jsx(m,{as:"span",variant:"meta",tone:"tertiary",className:"mt-0.5 block line-clamp-1",children:i.reasons.join(" · ")})]})]})},i.id))})]})]})},Le=({result:t,mode:s})=>s==="lexical"||t.semanticAvailable&&!t.semanticError?null:e.jsx(m,{as:"p",variant:"body",tone:"tertiary",className:"rounded-[14px] border border-border-subtle bg-muted px-3.5 py-2.5",children:s==="semantic"?"Meaning search is not ready. Configure an embedding API and build the index in Search settings.":"Meaning search is not ready, so these results use keyword search only."}),qe=({isVisible:t})=>t?e.jsxs(m,{as:"p",variant:"meta",tone:"tertiary",className:"mx-auto mt-5 max-w-[34rem] text-center",children:[e.jsx("span",{className:"font-semibold text-fg-secondary",children:"Tip:"})," Search by meaning when the exact words are fuzzy."," ",e.jsx(C,{to:le,className:"font-semibold text-fg-secondary underline decoration-border-secondary underline-offset-2 transition-colors hover:text-fg-default",children:"Enable meaning search"})]}):null;function Ve(){const t=_.useNavigate(),{page:s,query:r,mode:a}=_.useSearch(),[n,o]=g.useState(r),[i,c]=g.useState(!1),d=g.useRef(null),l=r.trim(),{isLoading:h,isError:f,isSemanticSearchEnabled:v,isSemanticSearchAvailable:j}=Ne(),p=h||j?a:"lexical",U=j?"Use exact words or describe a half-remembered note":"Search notes by exact words";g.useEffect(()=>{o(r)},[r]);const b=g.useCallback(()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),N=g.useCallback((u,x=p,y=!1)=>{const S={query:u.trim(),page:1,mode:x};if(y){t({search:S,replace:!0});return}t({search:S})},[p,t]);g.useEffect(()=>{if(b(),!(i||n.trim()===l))return d.current=setTimeout(()=>{d.current=null,N(n,p,!0)},Te),b},[p,b,n,i,l,N]);const D=()=>{i||(b(),N(n))},F=u=>{b(),N(n,u)};return e.jsx(Z,{title:"Search",description:U,variant:"default",children:e.jsxs("main",{children:[e.jsx("section",{"aria-label":"Search controls",className:"border-b border-border-subtle pb-5",children:e.jsx(be,{value:n,onChange:o,onCompositionChange:c,mode:j?p:void 0,onModeChange:j?F:void 0,placeholder:j?"Search or describe a memory":"Search notes by keyword",onSubmit:D,onClear:()=>{b(),N("")},autoFocus:!l})}),l?h?e.jsx($,{}):e.jsx(ee,{fallback:e.jsx($,{}),errorTitle:"Failed to load search results",errorDescription:`Retry loading results for "${l}".`,resetKeys:[l,s,p],children:e.jsx(Ae,{searchParams:{query:l,limit:E,offset:(s-1)*E,mode:p},render:u=>e.jsxs("div",{className:"mt-5 flex flex-col gap-3",children:[e.jsx("div",{className:"flex min-h-7 items-center justify-between gap-3",children:e.jsx(m,{as:"p",variant:"body",weight:"semibold",tone:"secondary",children:Ce(u.totalCount)})}),e.jsx(Le,{result:u,mode:p}),u.notes.length>0?e.jsx("div",{className:"grid gap-3",children:u.notes.map(x=>{const y=Ee(x.content,l),S=u.matches.find(K=>K.noteId===x.id);return e.jsxs("article",{className:"surface-base flex flex-col gap-3.5 rounded-[16px] p-4 transition-colors hover:border-border-secondary/70 hover:bg-hover-subtle/25 sm:p-5",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(m,{as:"h2",variant:"body",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx(C,{to:P,params:{id:x.id},className:"line-clamp-2 transition-colors hover:text-fg-default/85",children:e.jsx(B,{match:l,children:x.title||"Untitled"})})}),e.jsx(Re,{note:x})]}),e.jsx(je,{match:S})]}),y.length>0?e.jsx(_e,{blocks:y,query:l}):e.jsx("div",{className:"rounded-[14px] border border-dashed border-border-subtle/80 bg-muted/25 px-3.5 py-3",children:e.jsx(m,{as:"p",variant:"body",tone:"tertiary",className:"leading-[1.65]",children:"Open the note to inspect matching content."})}),e.jsx($e,{noteId:x.id})]},x.id)})}):e.jsx(A,{title:"No results found",description:p==="semantic"&&!u.semanticAvailable?"Meaning search must be configured before it can find related notes.":"Try another phrase or a different search method."}),u.totalCount>E&&e.jsx(te,{page:s,last:Math.ceil(u.totalCount/E),onChange:x=>{t({search:y=>({...y,page:x,mode:p})})}})]})})}):e.jsxs("div",{className:"py-10",children:[e.jsx(A,{title:"Start with anything you remember",description:"A name, phrase, rough date, or description all work."}),e.jsx(qe,{isVisible:!h&&!f&&!v})]})]})})}export{Ve as default};
@@ -1 +0,0 @@
1
- import{j as f}from"./floating-ui.react-dom-BWTnA00G.js";import{z as o}from"./note.api-D3oJmG3q.js";const n=o("surface-base",{variants:{tone:{default:"",elevated:"surface-elevated"},padding:{default:"p-4",compact:"px-3 py-2.5",roomy:"p-6",flush:"overflow-hidden"}},defaultVariants:{tone:"default",padding:"default"}});function i({children:a,className:e,flush:t=!1,padding:d="default",tone:s="default"}){const r=t?"flush":d;return f.jsx("div",{className:n({tone:s,padding:r,className:e}),children:a})}export{i as S};
@@ -1 +0,0 @@
1
- import{r as c,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as T,q as S,P as k,T as f,H as P,x as j,y as g,Q as E,F as R,k as q,E as C,l as x,h as I}from"./note.api-D3oJmG3q.js";import{s as A,T as O,a as L,i as F,b as Q,F as v}from"./app-BpSMjzET.js";import{T as _,b as M}from"./url-9nrbQs7Z.js";import{f as B}from"./tag.api-DNSQpqwk.js";import{f as D}from"./Graph-LY_IgMYy.js";import"./time-D5LRMumI.js";import"./preload-helper-BXl3LOEh.js";const z=s=>{const{data:d}=T({queryKey:S.tags.list(s.searchParams),async queryFn(){const t=await B({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit,sortBy:s.searchParams.sortBy,sortOrder:s.searchParams.sortOrder});if(t.type==="error")throw t;return t.allTags}});return s.render(d)},G=s=>{const[d,t]=c.useState(!1),r=c.useRef(null),n=c.useRef(!0),u=c.useRef(0),o=c.useCallback(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]);c.useEffect(()=>(n.current=!0,()=>{n.current=!1,o()}),[o]);const m=c.useCallback(p=>{u.current+=1;const i=u.current;o(),n.current&&t(!0),r.current=setTimeout(()=>{r.current=null,Promise.resolve().then(p).catch(()=>{}).finally(()=>{n.current&&u.current===i&&t(!1)})},s)},[o,s]);return[d,m]},b=I(M);function X(){const s=b.useNavigate(),{page:d,query:t,limit:r,sortBy:n,sortOrder:u}=b.useSearch(),[o,m]=c.useState(t),[,p]=G(350),i=t.trim();c.useEffect(()=>{m(t)},[t]),c.useEffect(()=>{const a=o.trim();a!==i&&p(()=>{s({search:l=>({...l,page:1,query:a})})})},[o,s,i,p]);const y=a=>{s({search:l=>({...l,...a})})},w=()=>{m(""),y({page:1,query:""})};return e.jsxs(k,{title:"Tags",description:"Find tags you added with @ across your notes",children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"surface-base flex min-w-0 items-center gap-2 rounded-[16px] px-3.5 py-2.5 lg:w-72",children:[e.jsx(D,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Search"}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsx("input",{"aria-label":"Search tags",placeholder:"Search tags",value:o,onChange:a=>m(a.target.value),className:"h-8 min-w-0 flex-1 bg-transparent text-sm font-medium text-fg-default outline-none placeholder:text-xs placeholder:font-medium placeholder:text-fg-placeholder"}),(o||i)&&e.jsx("button",{type:"button","aria-label":"Clear tag search",className:"focus-ring-soft flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",onClick:w,children:e.jsx(P,{className:"h-3.5 w-3.5",weight:"bold"})})]}),e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Items"}),e.jsx(j,{value:String(r),onValueChange:a=>{const l=Number(a);F(l)&&y({limit:l,page:1})},variant:"ghost",size:"sm",children:O.map(a=>e.jsx(g,{value:String(a),children:a===L?`Default (${a})`:a},a))})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Sort"}),e.jsxs(j,{value:n,onValueChange:a=>y({sortBy:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(g,{value:"referenceCount",children:"Usage"}),e.jsx(g,{value:"name",children:"Name"})]}),e.jsxs(j,{value:u,onValueChange:a=>y({sortOrder:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(g,{value:"desc",children:n==="name"?"Z to A":"Most used"}),e.jsx(g,{value:"asc",children:n==="name"?"A to Z":"Least used"})]})]})]})]}),e.jsx(E,{fallback:e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(x,{width:"90px",height:"36px"}),e.jsx(x,{width:"120px",height:"36px"}),e.jsx(x,{width:"80px",height:"36px"}),e.jsx(x,{width:"100px",height:"36px"}),e.jsx(x,{width:"110px",height:"36px"}),e.jsx(x,{width:"70px",height:"36px"})]}),errorTitle:"Failed to load tags",errorDescription:"Retry loading the tag catalog",resetKeys:[d,r,i,n,u],children:e.jsx(z,{searchParams:{query:i,offset:(d-1)*r,limit:r,sortBy:n,sortOrder:u},render:({tags:a,totalCount:l})=>e.jsx(v,{fallback:e.jsx(C,{title:i?"No matching tags":"No tags yet",description:i?"Try another tag name":"Add @tags inside notes and they will appear here"}),children:a.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2.5",children:a.map(h=>e.jsxs(R,{to:_,params:{id:h.id},search:{page:1},className:"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-hover-subtle px-3 py-1.5 text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover hover:text-fg-default",children:[e.jsx(f,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:h.name}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"text-current/70",children:h.referenceCount})]},h.id))}),e.jsx(v,{fallback:null,children:l&&r<l&&e.jsx(q,{page:d,last:Math.ceil(l/r),onChange:h=>{s({search:N=>({...N,page:h,query:i,limit:r,sortBy:n,sortOrder:u})})}})})]})})})})]})}export{X as default};
@@ -1 +0,0 @@
1
- import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as x,C as N,q as j,Q as y,P as c,k as P,E as T,l as o,h as v}from"./note.api-D3oJmG3q.js";import{F as h,N as k}from"./app-BpSMjzET.js";import{T as q}from"./url-9nrbQs7Z.js";import"./NotePropertiesPanel-aCKXAe5F.js";import{e as w}from"./time-D5LRMumI.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-LY_IgMYy.js";import"./AuxiliaryPanelHeader-B1k7pZpn.js";import"./Plus.es-DRfLW_bI.js";const R=s=>{const{data:r}=x({queryKey:j.notes.tagList(s.searchParams),async queryFn(){const t=await N({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit});if(t.type==="error")throw t;return t.tagNotes}});return s.render(r)},g=v(q);function A(){const s=g.useNavigate(),{id:r}=g.useParams(),{page:t}=g.useSearch(),i=25,{onDelete:m,onPinned:u,deleteWarningDialog:f}=w();return e.jsxs(y,{fallback:e.jsx(c,{title:"Tagged Notes",heading:e.jsx(o,{width:148,height:24,className:"rounded-full"}),description:e.jsx(o,{width:196,height:16,className:"rounded-full"}),variant:"default",children:e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"})]})}),errorTitle:"Failed to load tagged notes",errorDescription:"Retry loading notes for this tag",resetKeys:[r,t,i],children:[e.jsx(R,{searchParams:{query:r,offset:(t-1)*i,limit:i},render:({notes:l,totalCount:n})=>{const d=l.flatMap(a=>a.tags).find(a=>a.id===r)?.name;return e.jsx(c,{title:d??"Tagged Notes",heading:d?n>0?`${d} (${n})`:d:"Tagged Notes",description:"Browse every note linked to this tag",variant:"default",children:e.jsx(h,{fallback:e.jsx(T,{title:"No tagged notes yet",description:"Notes tagged with this label will appear here"}),children:l.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-5",children:l.map(a=>e.jsx(k,{...a,onPinned:()=>u(a.id,a.pinned),onDelete:()=>m(a.id)},a.id))}),e.jsx(h,{fallback:null,children:n&&i<n&&e.jsx(P,{page:t,last:Math.ceil(n/i),onChange:a=>{s({search:p=>({...p,page:a})})}})})]})})})}}),f]})}export{A as default};
@@ -1 +0,0 @@
1
- import{r as a}from"./floating-ui.react-dom-BWTnA00G.js";import{A as l}from"./note.api-D3oJmG3q.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 s}from"./floating-ui.react-dom-BWTnA00G.js";import{c as a}from"./note.api-D3oJmG3q.js";const m={compact:"h-[22px] px-2",regular:"h-7 px-2.5"};function c({children:e,className:n,contentClassName:r,size:t="regular",truncateContent:i=!0,...o}){return s.jsx("span",{className:a("inline-flex min-w-0 items-center overflow-hidden whitespace-nowrap rounded-full border text-xs font-medium leading-none",m[t],n),...o,children:i?s.jsx("span",{className:a("min-w-0 truncate",r),children:e}):e})}export{c as V};
@@ -1 +0,0 @@
1
- import{r as s,j as t}from"./floating-ui.react-dom-BWTnA00G.js";import{e as z,a as P}from"./time-D5LRMumI.js";import{A as G,P as j,E as K,Q as J,l as p,h as X,u as Y,i as T,q as l,o as ee,k as te,B as q,F as se,T as ae,e as re}from"./note.api-D3oJmG3q.js";import{f as ie}from"./tag.api-DNSQpqwk.js";import{f as ne,a as oe,g as le,V as ce,b as de,c as pe,u as C,d as ue}from"./ViewSectionDialog-DhH8harC.js";import{F as A,N as he}from"./app-BpSMjzET.js";import{V as me,c as ge}from"./url-9nrbQs7Z.js";import"./NotePropertiesPanel-aCKXAe5F.js";import{V as v}from"./ViewChip-DlCkL4z4.js";import{m as fe}from"./PencilLine.es-0JpEgxFY.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-LY_IgMYy.js";import"./AuxiliaryPanelHeader-B1k7pZpn.js";import"./Plus.es-DRfLW_bI.js";const ye=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M112,56V200L40,128Z",opacity:"0.2"}),s.createElement("path",{d:"M216,120H120V56a8,8,0,0,0-13.66-5.66l-72,72a8,8,0,0,0,0,11.32l72,72A8,8,0,0,0,120,200V136h96a8,8,0,0,0,0-16ZM104,180.69,51.31,128,104,75.31Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H120v64a8,8,0,0,1-13.66,5.66l-72-72a8,8,0,0,1,0-11.32l72-72A8,8,0,0,1,120,56v64h96A8,8,0,0,1,224,128Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H54.49l61.75,61.76a6,6,0,1,1-8.48,8.48l-72-72a6,6,0,0,1,0-8.48l72-72a6,6,0,0,1,8.48,8.48L54.49,122H216A6,6,0,0,1,222,128Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H49.66l65.17,65.17a4,4,0,0,1-5.66,5.66l-72-72a4,4,0,0,1,0-5.66l72-72a4,4,0,0,1,5.66,5.66L49.66,124H216A4,4,0,0,1,220,128Z"}))]]),M=s.forwardRef((n,o)=>s.createElement(G,{ref:o,...n,weights:ye}));M.displayName="ArrowLeftIcon";const xe=M,b=X(me);function we(){const n=b.useNavigate(),o=Y(),N=re(),{page:u,sectionId:d}=b.useSearch(),{onDelete:k,onPinned:L,deleteWarningDialog:R}=z(),[S,g]=s.useState(!1),[f,y]=s.useState(!1),i=25,{data:a}=T({queryKey:l.views.section(d),async queryFn(){const e=await ne(d);if(e.type==="error")throw e;if(!e.viewSection)throw new Error("View section not found.");return e.viewSection}}),{data:r}=T({queryKey:l.views.sectionNotes(d,{limit:i,offset:(u-1)*i}),async queryFn(){const e=await oe(d,{limit:i,offset:(u-1)*i});if(e.type==="error")throw e;return e.viewSectionNotes}}),{data:D,isPending:H}=P({queryKey:l.tags.list({limit:200}),enabled:f,async queryFn(){const e=await ie({limit:200});if(e.type==="error")throw e;return e.allTags}}),{data:I,isPending:O}=P({queryKey:l.notes.propertyKeys({limit:100}),enabled:f,async queryFn(){const e=await ee({limit:100});if(e.type==="error")throw e;return e.notePropertyKeys}}),x=a.title,h=a.tagNames,Q=a.mode,w=a.propertyFilters,Z=h.length>0,E=w.length>0,V=h.length>1?` · ${le(Q)}`:"",$=Z?E?`Property and tag filters${V}`:`Tag filters${V}`:E?"Property filters":"All notes",F=t.jsx(A,{fallback:null,children:r.totalCount&&i<r.totalCount&&t.jsx(te,{page:u,last:Math.ceil(r.totalCount/i),onChange:e=>{n({search:c=>({...c,page:e})})}})}),B=D?.tags??[],U=I?.keys??[],W=async e=>{if(S)return;const c=a.sortBy===e?a.sortOrder==="asc"?"desc":"asc":e==="title"?"asc":"desc";g(!0);const m=await C(a.id,ue(a,{sortBy:e,sortOrder:c}));if(m.type==="error"){N(m.errors[0]?.message??"Failed to update table sort."),g(!1);return}await o.invalidateQueries({queryKey:l.views.all(),exact:!1}),g(!1)},_=async e=>{const c=await C(a.id,e);if(c.type==="error"){N(c.errors[0]?.message??"Failed to update section.");return}await o.invalidateQueries({queryKey:l.views.all(),exact:!1}),n({search:m=>({...m,page:1})}),y(!1)};return t.jsxs(t.Fragment,{children:[t.jsxs(j,{title:x,heading:r.totalCount>0?`${x} (${r.totalCount})`:x,description:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(ae,{as:"span",variant:"meta",tone:"tertiary",children:$}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[h.map(e=>t.jsx(v,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:e},e)),w.map(e=>t.jsx(v,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:de(e)},`${e.key}-${e.operator}-${e.value??""}`)),h.length===0&&w.length===0&&t.jsx(v,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:"All notes"})]})]}),headerRight:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(q,{asChild:!0,variant:"ghost",size:"sm",children:t.jsxs(se,{to:ge,children:[t.jsx(xe,{className:"h-4 w-4"}),"Back to Views"]})}),t.jsxs(q,{type:"button",variant:"subtle",size:"sm",onClick:()=>y(!0),children:[t.jsx(fe,{className:"h-4 w-4"}),"Edit section"]})]}),children:[t.jsx(A,{fallback:t.jsx(K,{title:"No notes match this saved view",description:"Adjust this view's filters or keep writing until matching notes appear."}),children:r.notes.length>0&&a.displayType==="table"?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(ce,{section:a,notes:r.notes,isPending:!1,isError:!1,surface:"card",onRetry:()=>{o.invalidateQueries({queryKey:l.views.sectionNotes(d,{limit:i,offset:(u-1)*i})})},onSortChange:W,isSortPending:S}),F]}):r.notes.length>0?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx("div",{className:"grid-auto-cards grid gap-5",children:r.notes.map(e=>t.jsx(he,{...e,onPinned:()=>L(e.id,e.pinned),onDelete:()=>k(e.id)},e.id))}),F]}):null}),R]}),t.jsx(pe,{open:f,mode:"edit",initialSection:a,availableTags:B,availableProperties:U,isTagsLoading:H,isPropertiesLoading:O,onClose:()=>y(!1),onSubmit:_})]})}function Me(){const{sectionId:n,page:o}=b.useSearch();return n?t.jsx(J,{fallback:t.jsx(j,{title:"View Notes",heading:t.jsx(p,{width:180,height:24,className:"rounded-full"}),description:t.jsx(p,{width:220,height:16,className:"rounded-full"}),children:t.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[t.jsx(p,{height:"112px"}),t.jsx(p,{height:"112px"}),t.jsx(p,{height:"112px"})]})}),errorTitle:"Failed to load view notes",errorDescription:"Retry loading notes for this saved view section",resetKeys:[o,n],children:t.jsx(we,{})}):t.jsx(j,{title:"View Notes",description:"Saved view note lists require a section id.",children:t.jsx(K,{title:"No section selected",description:"Return to Views and open a section from there."})})}export{Me as default};
@@ -1,102 +0,0 @@
1
- import{g as v,T as d,B as V,F as ze,M as P,L as f,I as ae,a as re,b as R,D as _e,x as T,y as m,d as Me}from"./note.api-D3oJmG3q.js";import{j as t,r as g}from"./floating-ui.react-dom-BWTnA00G.js";import{t as ne,M as qe}from"./time-D5LRMumI.js";import{N as Be}from"./url-9nrbQs7Z.js";import{V as W}from"./ViewChip-DlCkL4z4.js";const Z=`
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 lt(){return v(`query FetchViewWorkspace {
23
- viewWorkspace {
24
- activeTabId
25
- tabs {
26
- id
27
- title
28
- order
29
- sections {
30
- ${Z}
31
- }
32
- }
33
- }
34
- }`)}function ot(e){return v(`query FetchViewSection($id: ID!) {
35
- viewSection(id: $id) {
36
- ${Z}
37
- }
38
- }`,{id:e})}function dt(e,{limit:a=25,offset:s=0}={}){return v(`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:a,offset:s}})}function ct(e){return v(`mutation CreateViewTab($title: String!) {
63
- createViewTab(title: $title) {
64
- id
65
- }
66
- }`,{title:e})}function ut(e,a){return v(`mutation UpdateViewTab($id: ID!, $title: String!) {
67
- updateViewTab(id: $id, title: $title) {
68
- id
69
- }
70
- }`,{id:e,title:a})}function pt(e){return v(`mutation DeleteViewTab($id: ID!) {
71
- deleteViewTab(id: $id)
72
- }`,{id:e})}function mt(e){return v(`mutation SetActiveViewTab($id: ID!) {
73
- setActiveViewTab(id: $id) {
74
- activeTabId
75
- tabs {
76
- id
77
- title
78
- order
79
- sections {
80
- ${Z}
81
- }
82
- }
83
- }
84
- }`,{id:e})}function bt(e){return v(`mutation ReorderViewTabs($tabIds: [ID!]!) {
85
- reorderViewTabs(tabIds: $tabIds) {
86
- id
87
- }
88
- }`,{tabIds:e})}function xt(e,a){return v(`mutation CreateViewSection($tabId: ID!, $input: ViewSectionInput!) {
89
- createViewSection(tabId: $tabId, input: $input) {
90
- id
91
- }
92
- }`,{tabId:e,input:a})}function ht(e,a){return v(`mutation UpdateViewSection($id: ID!, $input: ViewSectionInput!) {
93
- updateViewSection(id: $id, input: $input) {
94
- id
95
- }
96
- }`,{id:e,input:a})}function gt(e){return v(`mutation DeleteViewSection($id: ID!) {
97
- deleteViewSection(id: $id)
98
- }`,{id:e})}function vt(e,a){return v(`mutation ReorderViewSections($tabId: ID!, $sectionIds: [ID!]!) {
99
- reorderViewSections(tabId: $tabId, sectionIds: $sectionIds) {
100
- id
101
- }
102
- }`,{tabId:e,sectionIds:a})}const X=["title","tags","properties","createdAt","updatedAt"],yt={activeTabId:null,tabs:[]},Pe=e=>{const a=e.trim();return a?a.startsWith("@")?a:a.startsWith("#")?"":`@${a}`:""},ye=(e,a,s)=>{if(a===s)return e;const n=e.findIndex(x=>x.id===a),l=e.findIndex(x=>x.id===s);if(n<0||l<0)return e;const b=[...e],[j]=b.splice(n,1);return b.splice(l,0,j),b},fe=(e,a,s)=>{const n=e.findIndex(b=>b.id===a),l=n+(s==="previous"?-1:1);return n>=0&&l>=0&&l<e.length?e[l]?.id:void 0},ie=e=>{const a=e.flatMap(s=>typeof s=="string"?s.split(","):[]);return Array.from(new Set(a.map(Pe).filter(Boolean)))},ft=e=>e.tabs.length===0?null:e.activeTabId?e.tabs.find(a=>a.id===e.activeTabId)??e.tabs[0]??null:e.tabs[0]??null,jt=(e,a)=>e.tabs.some(s=>s.id===a)?{...e,activeTabId:a}:e,Re=(e,a,s)=>({...e,tabs:ye(e.tabs,a,s)}),We=(e,a,s,n)=>({...e,tabs:e.tabs.map(l=>l.id===a?{...l,sections:ye(l.sections,s,n)}:l)}),wt=(e,a,s)=>{const n=fe(e.tabs,a,s);return n?Re(e,a,n):e},Nt=(e,a,s,n)=>{const l=e.tabs.find(j=>j.id===a)?.sections??[],b=fe(l,s,n);return b?We(e,a,s,b):e},le=e=>e==="or"?"OR — any selected tag":"AND — all selected tags",Tt=e=>e==="or"?"OR":"AND",je=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"}},Ue=e=>{switch(e){case"table":return"Table";case"calendar":return"Unavailable";default:return"List"}},we=e=>{switch(e){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},U=e=>{const a=new Set(X),s=(e??[]).filter(l=>a.has(l)),n=Array.from(new Set(s));return n.length===0?[...X]:n.includes("title")?n:["title",...n]},Ne=e=>({tableColumns:U(e?.tableColumns)}),Vt=e=>{const a=je(e.operator);return e.operator==="exists"||e.operator==="notExists"?`${e.name} ${a}`:`${e.name} ${a} ${e.value??""}`.trim()},It=(e,a={})=>{const s={...e,...a};return{title:s.title,displayType:s.displayType,displayOptions:Ne(s.displayOptions),tagNames:s.tagNames,mode:s.mode,propertyFilters:s.propertyFilters.map(n=>({key:n.key,valueType:n.valueType,operator:n.operator,value:n.value})),sortBy:s.sortBy,sortOrder:s.sortOrder,limit:s.limit}},Ct=e=>({page:1,sectionId:e.id}),He=e=>e.valueType==="select"?e.option?.label??e.value:e.valueType==="boolean"?e.value==="true"?"True":"False":e.value,Ye=e=>(e.properties??[]).slice(0,3),Te={title:280,tags:190,properties:260,createdAt:132,updatedAt:132},Ge={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},Ve="flex h-[22px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",Ie="text-xs leading-5 text-fg-tertiary",Ke=e=>{const a=e.reduce((s,n)=>s+Te[n],0);return Math.max(520,a)},Qe=(e,a={})=>{if(e.tags.length===0)return a.hideEmpty?null:t.jsx("span",{className:Ie,children:"—"});const s=e.tags.slice(0,3),n=e.tags.length-s.length;return t.jsxs("div",{className:Ve,children:[s.map(l=>t.jsx(W,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:l.name},l.id)),n>0&&t.jsxs(W,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",n]})]})},Je=(e,a={})=>{const s=Ye(e);if(s.length===0)return a.hideEmpty?null:t.jsx("span",{className:Ie,children:"—"});const n=(e.properties?.length??0)-s.length;return t.jsxs("div",{className:Ve,children:[s.map(l=>t.jsxs(W,{size:"compact",truncateContent:!1,className:"max-w-[190px] shrink-0 gap-1 border-border-subtle bg-subtle text-fg-secondary",children:[t.jsx("span",{className:"min-w-0 max-w-[76px] shrink truncate text-fg-tertiary",children:l.name}),t.jsx("span",{className:"min-w-0 truncate",children:He(l)||"—"})]},l.key)),n>0&&t.jsxs(W,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",n]})]})};function St({section:e,notes:a,isPending:s,isError:n,onRetry:l,onSortChange:b,isSortPending:j,surface:x="flush"}){const I=U(e.displayOptions?.tableColumns),L=Ke(I),z=x==="card"?"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated":"overflow-x-auto bg-transparent",C=x==="card"?"overflow-hidden rounded-[16px] border border-border-subtle bg-elevated":"overflow-hidden bg-transparent",S=x==="card"?"bg-elevated":"bg-transparent",F=x==="card"?"bg-subtle/65":"bg-subtle/45",_=x==="card"?"bg-elevated":"bg-transparent",E=c=>{const u=Ge[c],O=we(c),k=u?e.sortBy===u:!1;return t.jsx("th",{"aria-sort":k?e.sortOrder==="asc"?"ascending":"descending":void 0,className:"px-3 py-2.5 text-xs font-semibold text-fg-tertiary",children:u?t.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:j,onClick:()=>b(u),children:[t.jsx("span",{children:O}),t.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:k?e.sortOrder==="asc"?"↑":"↓":"↕"})]}):O},c)},A=(c,u)=>{switch(u){case"tags":return t.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:Qe(c)},u);case"properties":return t.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:Je(c)},u);case"createdAt":return t.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:t.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:ne(Number(c.createdAt))})},u);case"updatedAt":return t.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:t.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:ne(Number(c.updatedAt))})},u);default:return t.jsx("td",{className:"px-3 py-2.5 align-middle",children:t.jsx(d,{as:"div",variant:"body",weight:"semibold",className:"line-clamp-1",children:t.jsx(ze,{to:Be,params:{id:c.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/85",children:c.title||"Untitled"})})},u)}};return s?t.jsxs("div",{className:C,children:[t.jsx("div",{className:"h-11 animate-pulse bg-subtle/50"}),t.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${S}`}),t.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${S}`}),t.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${S}`})]}):n?t.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[t.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),t.jsx("div",{className:"mt-3",children:t.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"Retry"})})]}):a.length===0?t.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[t.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):t.jsx("div",{className:z,children:t.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:L},children:[t.jsx("caption",{className:"sr-only",children:"View query results as a table"}),t.jsx("colgroup",{children:I.map(c=>t.jsx("col",{style:{width:Te[c]}},c))}),t.jsx("thead",{className:F,children:t.jsx("tr",{className:"border-b border-border-subtle",children:I.map(E)})}),t.jsx("tbody",{className:_,children:a.map(c=>t.jsx("tr",{className:"h-12 border-b border-border-subtle/70 last:border-b-0",children:I.map(u=>A(c,u))},c.id))})]})})}const Q="__choose_property__",Xe=["title","tags","properties","createdAt","updatedAt"],oe=e=>String(e?.limit??5),de=e=>e?.displayType==="table"?"table":"list",ce=e=>U(e?.displayOptions?.tableColumns??X),ue=e=>e?.mode??"and",pe=e=>e?e.tagNames.join(", "):"",me=e=>e?.title??"",be=e=>e?.sortBy??"updatedAt",xe=e=>e?.sortOrder??"desc",Ce=e=>`property-filter-${Date.now()}-${e}`,he=e=>(e?.propertyFilters??[]).map((a,s)=>({id:Ce(s),key:a.key,operator:a.operator,value:a.value??""})),ge=e=>e?e.valueType==="date"||e.valueType==="number"?["equals","notEquals","before","after","exists","notExists"]:e.valueType==="text"||e.valueType==="url"?["equals","notEquals","contains","notContains","exists","notExists"]:["equals","notEquals","exists","notExists"]:["exists","notExists"],ve=e=>e?"equals":"exists",Ze=e=>e?e.valueType==="boolean"?"true":e.valueType==="select"?e.options[0]?.value??"":"":"",J=e=>e!=="exists"&&e!=="notExists",Se=e=>e==="contains"||e==="notContains",et=(e,a)=>e.valueType==="date"?"date":e.valueType==="number"?"number":e.valueType==="url"&&!Se(a)?"url":"text",tt=(e,a)=>{if(e.valueType==="url")return Se(a)?"example.com":"https://example.com";if(e.valueType==="text")return"Value"};function At({open:e,mode:a,initialSection:s=null,availableTags:n,availableProperties:l,isTagsLoading:b=!1,isPropertiesLoading:j=!1,onClose:x,onSubmit:I}){const[L,z]=g.useState(me(s)),[C,S]=g.useState(de(s)),[F,_]=g.useState(ce(s)),[E,A]=g.useState(pe(s)),[c,u]=g.useState(ue(s)),[O,k]=g.useState(be(s)),[ee,te]=g.useState(xe(s)),[H,se]=g.useState(oe(s)),[$,M]=g.useState(he(s)),[Ae,Y]=g.useState((s?.tagNames.length??0)>0),[G,h]=g.useState(""),q=g.useMemo(()=>new Map(l.map(r=>[r.key,r])),[l]);g.useEffect(()=>{e&&(z(me(s)),S(de(s)),_(ce(s)),A(pe(s)),u(ue(s)),k(be(s)),te(xe(s)),se(oe(s)),M(he(s)),Y((s?.tagNames.length??0)>0),h(""))},[s,e]);const w=ie([E]),B=Ae||w.length>0,$e=w.length===0&&$.length===0,Fe=r=>{r!=="title"&&(_(o=>{if(o.includes(r)){const y=o.filter(i=>i!==r);return y.length>0?y:o}return U([...o,r])}),h(""))},Ee=r=>{const o=w.includes(r)?w.filter(y=>y!==r):[...w,r];A(o.join(", ")),h("")},Oe=()=>{Y(!0),h("")},ke=()=>{A(""),u("and"),Y(!1),h("")},De=()=>{if(l.length===0){h("Create a shared property before adding a filter.");return}M(r=>[...r,{id:Ce(r.length),key:"",operator:"exists",value:""}]),h("")},D=(r,o)=>{M(y=>y.map(i=>{if(i.id!==r)return i;const N={...i,...o},p=q.get(N.key);return ge(p).includes(N.operator)||(N.operator=ve(p)),"key"in o&&(N.value=Ze(p),N.operator=ve(p)),N})),h("")},Le=r=>{M(o=>o.filter(y=>y.id!==r)),h("")};return t.jsxs(P,{isOpen:e,onClose:x,variant:"form",className:"sm:max-w-[720px]",children:[t.jsx(P.Header,{title:a==="create"?"Create section":"Edit section",onClose:x}),t.jsx(P.Body,{children:t.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:r=>{r.preventDefault();const o=ie([E]);if(B&&o.length===0){h("Choose at least one tag, or remove this tag filter.");return}if($.find(p=>!p.key||!q.has(p.key))){h("Choose a property for every filter.");return}const i=$.map(p=>{const K=q.get(p.key);return{key:K?.key??p.key,valueType:K?.valueType??"text",operator:p.operator,value:J(p.operator)?p.value:null}});if(i.some(p=>J(p.operator)&&!p.value?.trim())){h("Fill every filter value, or switch it to is set / is empty.");return}I({title:L,displayType:C,displayOptions:Ne({tableColumns:F}),tagNames:o,mode:c,propertyFilters:i,sortBy:O,sortOrder:ee,limit:Number(H)})},children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{htmlFor:"view-section-title",size:"md",children:"Section name"}),t.jsx(ae,{id:"view-section-title",value:L,onChange:r=>z(r.target.value),placeholder:"Doing notes",autoFocus:!0})]}),t.jsxs("section",{className:"flex flex-col gap-3 rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(f,{size:"md",children:"Display"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same query as a compact list or a table."})]}),t.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:Ue(C)})]}),t.jsxs(re,{type:"single",value:C,onValueChange:r=>{(r==="list"||r==="table")&&S(r)},variant:"quiet",size:"sm",className:"self-start",children:[t.jsx(R,{value:"list","aria-label":"Show as list",children:"List"}),t.jsx(R,{value:"table","aria-label":"Show as table",children:"Table"})]}),C==="table"?t.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/45 p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx(f,{size:"sm",children:"Table columns"}),t.jsxs(d,{as:"span",variant:"meta",tone:"tertiary",children:[F.length," shown"]})]}),t.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:Xe.map(r=>{const o=we(r);return t.jsxs("div",{className:"flex items-center gap-2 rounded-[12px] border border-border-subtle bg-elevated px-3 py-2",children:[t.jsx(_e,{size:"sm",checked:F.includes(r),disabled:r==="title","aria-label":`Show ${o} column`,onChange:()=>Fe(r)}),t.jsx(d,{as:"span",variant:"label",tone:"secondary",children:o})]},r)})}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."})]}):null]}),t.jsxs("section",{className:"flex flex-col gap-3 rounded-[20px] border border-border-subtle bg-subtle/40 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(f,{size:"md",children:"Filters"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Use properties for structured fields, and tags for loose topics or context."})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(V,{type:"button",variant:"subtle",size:"sm",onClick:De,children:"Add property filter"}),!B&&t.jsx(V,{type:"button",variant:"subtle",size:"sm",onClick:Oe,children:"Add tag filter"})]})]}),$.length===0&&!B?t.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[t.jsx(d,{as:"p",variant:"label",tone:"default",children:$e?"All notes":"No filters"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add a property filter, a tag filter, or leave this view open to all notes."})]}):null,$.length>0?t.jsx("div",{className:"flex flex-col gap-2.5",children:$.map(r=>{const o=q.get(r.key),y=ge(o);return t.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:[t.jsxs(T,{value:r.key||Q,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:i=>{i!==Q&&D(r.id,{key:i})},children:[t.jsx(m,{value:Q,disabled:!0,children:"Choose property"}),l.map(i=>t.jsx(m,{value:i.key,children:i.name},i.key))]}),t.jsx(T,{value:r.operator,disabled:!o,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:i=>D(r.id,{operator:i}),children:y.map(i=>t.jsx(m,{value:i,children:je(i)},i))}),J(r.operator)&&o?o.valueType==="select"?t.jsx(T,{value:r.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:i=>D(r.id,{value:i}),children:o.options.map(i=>t.jsx(m,{value:i.value,children:i.label},i.value))}):o.valueType==="boolean"?t.jsxs(T,{value:r.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:i=>D(r.id,{value:i}),children:[t.jsx(m,{value:"true",children:"True"}),t.jsx(m,{value:"false",children:"False"})]}):t.jsx(ae,{type:et(o,r.operator),value:r.value,onChange:i=>D(r.id,{value:i.target.value}),placeholder:tt(o,r.operator),"aria-label":"Property filter value"}):t.jsx(d,{as:"span",variant:"label",tone:"tertiary",children:o?"No value needed":"Choose a property first"}),t.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:()=>Le(r.id),children:"Remove"})]},r.id)})}):null,B?t.jsxs("div",{className:"flex flex-col gap-3 rounded-[16px] border border-border-subtle bg-elevated p-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(d,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),t.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:ke,children:"Remove"})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),t.jsx(Me,{id:"view-section-tags",value:E,onChange:r=>{A(r.target.value),h("")},placeholder:"@OceanBrain, @todo",size:"sm"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"You can use tags only, properties only, both together, or no filters."})]}),w.length>1?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{size:"sm",children:"Tag match"}),t.jsxs(re,{type:"single",value:c,onValueChange:r=>{(r==="and"||r==="or")&&u(r)},variant:"quiet",size:"sm",className:"self-start",children:[t.jsx(R,{value:"and","aria-label":le("and"),children:"AND"}),t.jsx(R,{value:"or","aria-label":le("or"),children:"OR"})]}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"AND requires every selected tag. OR accepts any selected tag."})]}):null,t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(f,{size:"sm",children:"Existing tags"}),t.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:b?"Loading...":`${n.length} available`})]}),n.length>0?t.jsx("div",{className:"max-h-44 overflow-y-auto rounded-[16px] border border-border-subtle bg-hover-subtle/60 p-3",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(r=>{const o=w.includes(r.name);return t.jsx("button",{type:"button",className:`inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${o?"border-border-secondary bg-elevated text-fg-default":"border-border-subtle bg-transparent text-fg-secondary hover:border-border-secondary hover:bg-elevated hover:text-fg-default"}`,"aria-pressed":o,onClick:()=>Ee(r.name),children:r.name},r.id)})})}):t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,t.jsx(d,{as:"p",variant:"meta",tone:G?"default":"tertiary",className:G?"text-fg-error":void 0,children:G||(j||b?"Loading filter options...":`${l.length} properties · ${n.length} tags available`)})]}),t.jsxs("details",{className:"group rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[t.jsx("summary",{className:"cursor-pointer list-none",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx(d,{as:"span",variant:"label",tone:"default",children:"Sort and limit"}),t.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Controls how many matching notes appear on the Views page preview."})]}),t.jsxs(d,{as:"span",variant:"meta",tone:"tertiary",children:[H," notes"]})]})}),t.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{id:"view-section-sort-by-label",htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),t.jsxs(T,{id:"view-section-sort-by",value:O,"aria-labelledby":"view-section-sort-by-label",onValueChange:r=>k(r),children:[t.jsx(m,{value:"updatedAt",children:"Updated time"}),t.jsx(m,{value:"createdAt",children:"Created time"}),t.jsx(m,{value:"title",children:"Title"})]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{id:"view-section-sort-order-label",htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),t.jsxs(T,{id:"view-section-sort-order",value:ee,"aria-labelledby":"view-section-sort-order-label",onValueChange:r=>te(r),children:[t.jsx(m,{value:"desc",children:"Descending"}),t.jsx(m,{value:"asc",children:"Ascending"})]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{id:"view-section-limit-label",htmlFor:"view-section-limit",size:"sm",children:"Preview rows"}),t.jsxs(T,{id:"view-section-limit",value:H,"aria-labelledby":"view-section-limit-label",onValueChange:se,children:[t.jsx(m,{value:"3",children:"3 rows"}),t.jsx(m,{value:"5",children:"5 rows"}),t.jsx(m,{value:"8",children:"8 rows"}),t.jsx(m,{value:"10",children:"10 rows"}),t.jsx(m,{value:"12",children:"12 rows"})]})]})]})]})]})}),t.jsx(P.Footer,{children:t.jsxs(qe,{children:[t.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),t.jsx(V,{type:"submit",size:"sm",form:"view-section-form",children:a==="create"?"Create section":"Save section"})]})})]})}export{yt as E,St as V,dt as a,Vt as b,At as c,It as d,Ct as e,ot as f,le as g,Tt as h,Ue as i,lt as j,ft as k,mt as l,wt as m,We as n,Nt as o,ct as p,ut as q,Re as r,jt as s,pt as t,ht as u,xt as v,gt as w,bt as x,vt as y};