ocean-brain 0.8.2 → 0.10.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.
- package/README.md +2 -0
- package/dist/mcp.js +47 -75
- package/package.json +3 -2
- package/server/client/dist/assets/{ArrowRight.es-g2YZTklZ.js → ArrowRight.es-Bm-ZXpEC.js} +1 -1
- package/server/client/dist/assets/Calendar-BsNs3NzO.js +25 -0
- package/server/client/dist/assets/{Callout-B_IPSF_5.js → Callout-CviyPHKO.js} +1 -1
- package/server/client/dist/assets/{Copy.es-CNxe4ujr.js → Copy.es-BPreRnP9.js} +1 -1
- package/server/client/dist/assets/{Graph-D9GeO71k.js → Graph-vXQQ0a-Q.js} +1 -1
- package/server/client/dist/assets/Graph-yPE3ljW0.js +46 -0
- package/server/client/dist/assets/{Image.es-DnON8cv2.js → Image.es-DnR3qc_c.js} +1 -1
- package/server/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/server/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/server/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/server/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/server/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/server/client/dist/assets/Note-CmreVzvQ.js +25 -0
- package/server/client/dist/assets/{NotePropertiesPanel-2DgXEM4B.js → NotePropertiesPanel-DXYgE8h2.js} +2 -2
- package/server/client/dist/assets/PencilLine.es-B9V6u64t.js +1 -0
- package/server/client/dist/assets/{Plus.es-CQ8wn2is.js → Plus.es-CRRp2u5J.js} +1 -1
- package/server/client/dist/assets/Reminders-BOtfNeYD.js +1 -0
- package/server/client/dist/assets/Search-C-FB3pKf.js +1 -0
- package/server/client/dist/assets/SurfaceCard-GMt5xM7v.js +1 -0
- package/server/client/dist/assets/Tag-lBxDRE77.js +1 -0
- package/server/client/dist/assets/TagNotes-Bgorp_rC.js +1 -0
- package/server/client/dist/assets/{Trash.es-0aPpA-3S.js → Trash.es-svHOb5LN.js} +1 -1
- package/server/client/dist/assets/ViewNotes-C7d10VFf.js +1 -0
- package/server/client/dist/assets/ViewSectionDialog-Bhw-ILop.js +102 -0
- package/server/client/dist/assets/Views-C7V3saUo.js +1 -0
- package/server/client/dist/assets/abnfDiagram-VRR7QNED-CWlV5dXw.js +1 -0
- package/server/client/dist/assets/app-DQBV36r_.js +50 -0
- package/server/client/dist/assets/app-ZgwR5t_I.css +1 -0
- package/server/client/dist/assets/arc-BV-n6RUX.js +1 -0
- package/server/client/dist/assets/architectureDiagram-ZJ3FMSHR-CekzMXdu.js +36 -0
- package/server/client/dist/assets/blockDiagram-677ZJIJ3-B49yHoxq.js +132 -0
- package/server/client/dist/assets/c4Diagram-LMCZKHZV-0AfB9NBC.js +10 -0
- package/server/client/dist/assets/channel-CigOulR-.js +1 -0
- package/server/client/dist/assets/chunk-2Q5K7J3B-DaPQAU1q.js +1 -0
- package/server/client/dist/assets/chunk-32BRIVSS-CfL3kZAg.js +1 -0
- package/server/client/dist/assets/chunk-5VM5RSS4-DeOwWPE_.js +15 -0
- package/server/client/dist/assets/chunk-EX3LRPZG-C3W1oc9y.js +231 -0
- package/server/client/dist/assets/chunk-JWPE2WC7-_Oqh79OY.js +1 -0
- package/server/client/dist/assets/chunk-MOJQB5TN-DDKNNzI6.js +88 -0
- package/server/client/dist/assets/chunk-RYQCIY6F-DCHah7CC.js +1 -0
- package/server/client/dist/assets/chunk-V7JOEXUC-uUOIzgxj.js +206 -0
- package/server/client/dist/assets/chunk-VR4S4FIN-DDVw2WPs.js +1 -0
- package/server/client/dist/assets/chunk-XXDRQBXY-Coo4UFm2.js +1 -0
- package/server/client/dist/assets/classDiagram-OUVF2IWQ-D13ISIOW.js +1 -0
- package/server/client/dist/assets/classDiagram-v2-EOCWNBFH-D13ISIOW.js +1 -0
- package/server/client/dist/assets/colors-Cc3OSVma.js +1 -0
- package/server/client/dist/assets/cose-bilkent-JH36ORCC-C3pHmHpD.js +1 -0
- package/server/client/dist/assets/cynefin-VYW2F7L2-DU_G4Atc.js +166 -0
- package/server/client/dist/assets/cynefinDiagram-TSTJHNR4-DZ6iiJFo.js +62 -0
- package/server/client/dist/assets/cytoscape.esm-D3_iZ_3b.js +321 -0
- package/server/client/dist/assets/dagre-VKFMJZFB-DNELbhwC.js +4 -0
- package/server/client/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/server/client/dist/assets/diagram-FQU43EPY-CMEvZJ61.js +3 -0
- package/server/client/dist/assets/diagram-G47NLZAW-BYDtf6j9.js +24 -0
- package/server/client/dist/assets/diagram-NH7WQ7WH-CmXfcCQA.js +24 -0
- package/server/client/dist/assets/diagram-OA4YK3LP-BflTKJxU.js +30 -0
- package/server/client/dist/assets/diagram-WEI45ONY-KW3fKqna.js +41 -0
- package/server/client/dist/assets/ebnfDiagram-CCIWWBDH-CbyhY5Nj.js +1 -0
- package/server/client/dist/assets/erDiagram-Q63AITRT-CC2eZV8g.js +85 -0
- package/server/client/dist/assets/{floating-ui.react-dom-wWLZ1CdM.js → floating-ui.react-dom-BWTnA00G.js} +1 -1
- package/server/client/dist/assets/flowDiagram-23GEKE2U-unplo7Qm.js +156 -0
- package/server/client/dist/assets/ganttDiagram-NO4QXBWP-BcBK5HcZ.js +292 -0
- package/server/client/dist/assets/gitGraphDiagram-IHSO6WYX-DgVbbb5k.js +106 -0
- package/server/client/dist/assets/graph-C5DFNLrC.js +1 -0
- package/server/client/dist/assets/image-delete-confirmation-D7xrODQV.js +1 -0
- package/server/client/dist/assets/image.api-QmHYjp3z.js +17 -0
- package/server/client/dist/assets/index-CaF9d-zG.js +1 -0
- package/server/client/dist/assets/infoDiagram-FWYZ7A6U-N_D9RdfG.js +2 -0
- package/server/client/dist/assets/init-Gi6I4Gst.js +1 -0
- package/server/client/dist/assets/isObject-U9U2HXiq.js +1 -0
- package/server/client/dist/assets/ishikawaDiagram-FXEZZL3T-BBKrzmB2.js +70 -0
- package/server/client/dist/assets/journeyDiagram-5HDEW3XC-NdCxLmQB.js +139 -0
- package/server/client/dist/assets/kanban-definition-HUTT4EX6-Ck7t4-tt.js +89 -0
- package/server/client/dist/assets/katex-DywYRkvg.css +1 -0
- package/server/client/dist/assets/katex-HP8lGamR.js +257 -0
- package/server/client/dist/assets/katex-x288kqHd.js +257 -0
- package/server/client/dist/assets/layout-Cz0MDlGi.js +1 -0
- package/server/client/dist/assets/linear-D6yRgDLq.js +1 -0
- package/server/client/dist/assets/manage-image-DCDF8AM9.js +1 -0
- package/server/client/dist/assets/manage-image-detail-e0ViRAj-.js +1 -0
- package/server/client/dist/assets/map-Mm1V-_Na.js +1 -0
- package/server/client/dist/assets/mcp-admin-adapter-D39G3udJ.js +1 -0
- package/server/client/dist/assets/{mcp-CT_9IV2c.js → mcp-uFZkdhCi.js} +4 -4
- package/server/client/dist/assets/mermaid.core-B14ZAmWA.js +308 -0
- package/server/client/dist/assets/min-tv6RD-6E.js +1 -0
- package/server/client/dist/assets/mindmap-definition-LN4V7U3C-BTUqSdcP.js +96 -0
- package/server/client/dist/assets/{note-core-Buwzyxi7.js → note-core-DUTqUh5N.js} +2 -2
- package/server/client/dist/assets/{note-runtime-CPDVOFEo.js → note-runtime-zN5ddTba.js} +1 -1
- package/server/client/dist/assets/{note-ui-CHI-tzj-.js → note-ui-CxK8ymUc.js} +1 -1
- package/server/client/dist/assets/{note.api-D_00ZzJC.js → note.api-BQovzEzd.js} +6 -6
- package/server/client/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/server/client/dist/assets/pegDiagram-2B236MQR-Cjcu3mVz.js +1 -0
- package/server/client/dist/assets/pieDiagram-ENE6RG2P-BxI_c22Z.js +39 -0
- package/server/client/dist/assets/{placeholder-DbdGiYGL.js → placeholder-D3b8lZGE.js} +4 -4
- package/server/client/dist/assets/properties-M-yWq1D7.js +1 -0
- package/server/client/dist/assets/quadrantDiagram-ABIIQ3AL-DGm0a-yR.js +7 -0
- package/server/client/dist/assets/railroadDiagram-RFXS5EU6-DmCDu89O.js +1 -0
- package/server/client/dist/assets/requirementDiagram-TGXJPOKE-CBpUt7Ig.js +84 -0
- package/server/client/dist/assets/route-preload.js +2 -2
- package/server/client/dist/assets/sankeyDiagram-HTMAVEWB-BjGnDZlp.js +40 -0
- package/server/client/dist/assets/search-DFnzZKLd.js +1 -0
- package/server/client/dist/assets/sequenceDiagram-DBY2YBRQ-B7rpCfS6.js +162 -0
- package/server/client/dist/assets/sizeCapture-X5ZJPWSS-CUJhD0uW.js +1 -0
- package/server/client/dist/assets/stateDiagram-2N3HPSRC-Y9-3XqRX.js +1 -0
- package/server/client/dist/assets/stateDiagram-v2-6OUMAXLB-DbHXhT02.js +1 -0
- package/server/client/dist/assets/swimlanes-5IMT3BWC-Cs1NO9ng.js +2 -0
- package/server/client/dist/assets/swimlanesDiagram-G3AALYLV-DQnrq2ZC.js +8 -0
- package/server/client/dist/assets/{tag.api-CX0SE06J.js → tag.api-DUfjr8bg.js} +3 -3
- package/server/client/dist/assets/time-CfAYZipR.js +9 -0
- package/server/client/dist/assets/timeline-definition-FHXFAJF6-8fqD4WNL.js +120 -0
- package/server/client/dist/assets/toNumber-DE3J3kMD.js +1 -0
- package/server/client/dist/assets/transform-BUB79_za.js +1 -0
- package/server/client/dist/assets/trash-CClKfP1x.js +1 -0
- package/server/client/dist/assets/url-9nrbQs7Z.js +1 -0
- package/server/client/dist/assets/{useReminderMutate-CLK1tHvT.js → useReminderMutate--omDLmBV.js} +4 -4
- package/server/client/dist/assets/vennDiagram-L72KCM5P-BPqKkd5a.js +34 -0
- package/server/client/dist/assets/wardleyDiagram-EHGQE667-Cq11kU2M.js +78 -0
- package/server/client/dist/assets/xychartDiagram-FW5EYKEG-DJ6UzFj-.js +7 -0
- package/server/client/dist/index.html +7 -7
- package/server/dist/features/image/services/delete.js +25 -1
- package/server/dist/features/note/graphql/note.mutation.resolver.js +38 -12
- package/server/dist/features/note/graphql/note.type-defs.js +1 -1
- package/server/dist/features/note/http/mcp.js +1 -60
- package/server/dist/features/note/services/authoring.js +2 -70
- package/server/dist/features/note/services/markdown-patch.js +80 -8
- package/server/dist/features/note/services/properties.js +21 -1
- package/server/dist/features/note/services/property-restore.js +26 -0
- package/server/dist/features/note/services/snapshot.js +79 -59
- package/server/dist/features/note/services/trash.js +16 -31
- package/server/dist/features/search/embedding-api-key-store.js +57 -0
- package/server/dist/features/search/embedding-client.js +179 -0
- package/server/dist/features/search/graphql/index.js +6 -0
- package/server/dist/features/search/graphql/resolver.js +20 -0
- package/server/dist/features/search/graphql/type-defs.js +30 -0
- package/server/dist/features/search/http/handlers.js +108 -0
- package/server/dist/features/search/hybrid-ranking.js +55 -0
- package/server/dist/features/search/hybrid-search.js +174 -0
- package/server/dist/features/search/note-change.js +16 -0
- package/server/dist/features/search/note-chunking.js +75 -0
- package/server/dist/features/search/search-config.js +150 -0
- package/server/dist/features/search/search-manager.js +431 -0
- package/server/dist/features/search/semantic-indexer.js +138 -0
- package/server/dist/features/search/sqlite-vector-index.js +636 -0
- package/server/dist/features/search/url-normalization.js +10 -0
- package/server/dist/features/tag/services/organization.js +3 -0
- package/server/dist/features/view/services/workspace.js +1 -1
- package/server/dist/main.js +2 -0
- package/server/dist/modules/blocknote.js +4 -5
- package/server/dist/paths.js +7 -2
- package/server/dist/routes/api.js +37 -0
- package/server/dist/routes/mcp.js +0 -5
- package/server/dist/schema/index.js +3 -0
- package/server/client/dist/assets/Calendar-BP6HTuSn.js +0 -25
- package/server/client/dist/assets/Graph-Xha3fwhp.js +0 -46
- package/server/client/dist/assets/Image-BLEjLUqd.js +0 -1
- package/server/client/dist/assets/Note-DjrCYtat.js +0 -24
- package/server/client/dist/assets/Reminders-B4l3KdlK.js +0 -1
- package/server/client/dist/assets/Search-BN5sf7bE.js +0 -1
- package/server/client/dist/assets/SurfaceCard-BZm73nyS.js +0 -1
- package/server/client/dist/assets/Tag-oSnmViVp.js +0 -1
- package/server/client/dist/assets/TagNotes-BDTCcJcL.js +0 -1
- package/server/client/dist/assets/ViewNotes-CiZtGJNE.js +0 -1
- package/server/client/dist/assets/ViewSectionDialog-Ctl_694Y.js +0 -102
- package/server/client/dist/assets/Views-D-zlatYD.js +0 -1
- package/server/client/dist/assets/app-DmqIOMWF.css +0 -1
- package/server/client/dist/assets/app-cTRcKMGc.js +0 -26
- package/server/client/dist/assets/image.api-CVuuvTBk.js +0 -17
- package/server/client/dist/assets/index-DKJChPr4.js +0 -1
- package/server/client/dist/assets/manage-image-BZjaxp-f.js +0 -1
- package/server/client/dist/assets/manage-image-detail-DPv0FQ2m.js +0 -1
- package/server/client/dist/assets/mcp-admin-adapter-xAuyZc_M.js +0 -1
- package/server/client/dist/assets/properties-D447wsWk.js +0 -1
- package/server/client/dist/assets/time-B3pt8vt4.js +0 -9
- package/server/client/dist/assets/trash-8sH7EZgc.js +0 -1
- package/server/client/dist/assets/url-BSnWpmJx.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as g,j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";function u({src:r,alt:n,loading:t="lazy",className:i}){const s=g.useRef(null);return g.useEffect(()=>{if(!s.current||t!=="lazy"||!r)return;const A=new IntersectionObserver(([c])=>{if(c.isIntersecting){const a=c.target;a.src=a.dataset.src,A.unobserve(a)}});return A.observe(s.current),()=>{A.disconnect()}},[t,r]),e.jsx(e.Fragment,{children:t!=="lazy"?e.jsx("img",{src:r,alt:n,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()}):e.jsx("img",{ref:s,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2O4evXqfwAIgQN/QHwrfwAAAABJRU5ErkJggg==",alt:n,"data-src":r,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()})})}export{u as I};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import{r as o,j as a}from"./floating-ui.react-dom-wWLZ1CdM.js";import{H as fn,R as pn,Z as N,a9 as ft,aA as hn,T as E,at as M,au as T,a5 as J,ah as pt,a4 as ht,aB as mn,a8 as Re,U as Ke,aC as mt,aD as gn,aE as xn,aF as vn,a3 as Le,aw as yn,aG as bn,aH as wn,aI as Fe,af as Cn,aJ as Nn,ag as Sn,I as gt,aq as jn,aK as ze,aL as Rn,aM as An,aN as kn,aO as En,aa as Ye,aj as qe,ab as Qe,ai as Tn,ac as ie,ad as Dn}from"./note.api-D_00ZzJC.js";import{j as xe,k as Mn,r as Pn,M as xt,m as _n,d as $e,e as On,i as Q,g as Bn,b as vt,l as yt,s as Ln,o as et,f as Fn}from"./time-B3pt8vt4.js";import{m as $n,c as Un,C as tt}from"./Callout-B_IPSF_5.js";import{J as bt,A as wt,a as Hn,N as In,p as Vn}from"./NotePropertiesPanel-2DgXEM4B.js";import{N as Ae,b as zn,e as Wn}from"./url-BSnWpmJx.js";import{S as Kn}from"./SurfaceCard-BZm73nyS.js";import{u as Yn,R as qn}from"./useReminderMutate-CLK1tHvT.js";import{n as Qn}from"./Plus.es-CQ8wn2is.js";import{h as Ge,m as Gn,L as Ct,Z as Nt,M as Zn,K as Jn,a as Xn}from"./note-ui-CHI-tzj-.js";import{u as er}from"./image.api-CVuuvTBk.js";import{L as tr,q as nr,B as me,G as rr,t as nt}from"./note-core-Buwzyxi7.js";import{s as ar}from"./Copy.es-CNxe4ujr.js";import{f as sr,c as or}from"./tag.api-CX0SE06J.js";import{cn as rt}from"./note-runtime-CPDVOFEo.js";import"./preload-helper-BXl3LOEh.js";function ir(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}=ir(e),c=fn(),{history:l}=c,[p,u]=o.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return o.useEffect(()=>{const h=async x=>{function m(A){const w=c.parseLocation(A),f=c.getMatchedRoutes(w.pathname);return f.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:f.routeParams,search:c.options.parseSearch(A.search)}:{routeId:f.foundRoute.id,fullPath:f.foundRoute.fullPath,pathname:w.pathname,params:f.routeParams,search:c.options.parseSearch(A.search)}}const d=m(x.currentLocation),v=m(x.nextLocation);if(d.routeId==="__notFound__"&&v.routeId!=="__notFound__")return!1;const b=await t({action:x.action,current:d,next:v});if(!i)return b;if(!b)return!1;const j=await new Promise(A=>{u({status:"blocked",current:d,next:v,action:x.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}),j};return r?void 0:l.block({blockerFn:h,enableBeforeUnload:s})},[t,s,r,i,l,c]),p}const lr=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),o.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z"}))]]),St=o.forwardRef((e,n)=>o.createElement(pn,{ref:n,...e,weights:lr}));St.displayName="FileIcon";const dr=St;function ur({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(N,{as:"div",variant:"body",weight:"semibold",tone:t?"default":"secondary",children:e}),a.jsx(N,{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 fr=e=>{const{data:n}=ft({queryKey:E.notes.backReferences(e.noteId),async queryFn(){const t=await hn(e.noteId);if(t.type==="error")throw t;return t.backReferences}});return e.render(n)},pr=[{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 hr({isOpen:e,onClose:n,onSave:t,currentLayout:s="wide"}){const[r,i]=o.useState(s);o.useEffect(()=>{e&&i(s)},[e,s]);const c=()=>{t(r),n()};return a.jsxs(M,{isOpen:e,onClose:n,variant:"compact",children:[a.jsx(M.Header,{title:"Layout Settings",onClose:n}),a.jsx(M.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(N,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),a.jsx("div",{className:"flex flex-col gap-2",children:pr.map(l=>a.jsx(ur,{title:l.label,description:l.description,selected:r===l.value,onClick:()=>i(l.value)},l.value))})]})})}),a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(T,{variant:"primary",size:"sm",onClick:c,children:"Apply"})]})})]})}const ge=e=>{const n=/^\d+$/.test(e)?Number(e):Date.parse(e);return Number.isFinite(n)?n:null},Se=(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},mr=2200;function gr({status:e,savedAt:n,savedVersion:t,confirmationRevision:s}){const[r,i]=o.useState(()=>Date.now()),[c,l]=o.useState(!1);o.useEffect(()=>{if(e!=="saved")return;const d=window.setTimeout(()=>i(Date.now()),Mn(ge(t),r));return()=>window.clearTimeout(d)},[r,t,e]),o.useEffect(()=>{if(s===0)return;l(!0);const d=window.setTimeout(()=>l(!1),mr);return()=>window.clearTimeout(d)},[s]);const p=e==="saved"&&c,u=e==="pending"?"Saving...":e==="saving"?"Saving now...":e==="error"?"Save failed. Try again.":e==="conflict"?"Save paused: changed elsewhere":`Saved ${Pn(ge(t),r)}`,h=J("inline-flex items-center gap-2 transition-colors",e==="saved"&&!p&&"text-fg-secondary",p&&"text-accent-success",(e==="pending"||e==="saving")&&"text-fg-default",(e==="error"||e==="conflict")&&"text-fg-error"),x=J("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"&&p&&"save-progress-ring-complete",(e==="error"||e==="conflict")&&"save-progress-ring-error"),m=e==="error"||e==="conflict"?a.jsx($n,{className:"h-3.5 w-3.5",weight:"fill"}):a.jsx("span",{className:x,"aria-hidden":!0,children:a.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})});return a.jsxs(N,{as:"span",variant:"label",weight:"medium",className:h,role:"status","aria-live":"polite",title:n,children:[m,u]})}function xr({title:e,titleRef:n,isPinned:t,createdAt:s,saveStatus:r,savedAt:i,savedVersion:c,saveConfirmationRevision:l,onTitleChange:p,onCopyMarkdown:u,onDownloadDocument:h,onTogglePinned:x,onChangeLayout:m,onCloneNote:d,onRestoreVersion:v,onDelete:b,onSave:S}){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(N,{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:j=>p(j.target.value)})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(pt,{button:a.jsx(xt,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:u},{name:"Download document",onClick:h},{type:"separator",key:"export-separator"},{name:t?"Unpin":"Pin",onClick:x},{name:"Change layout",onClick:m},{type:"separator"},{name:"Clone this note",onClick:d},{name:"Restore previous version",onClick:v},{type:"separator"},{name:"Delete",onClick:b}]}),a.jsx(T,{size:"sm",variant:"subtle",isLoading:r==="saving",disabled:r==="conflict",onClick:S,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(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[a.jsx(_n,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),t&&a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsx(gr,{status:r,savedAt:i,savedVersion:c,confirmationRevision:l}),a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsxs(N,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",s]})]})]})})}const vr=/[:{}[\],&*#?|<>=!%@`-]/,yr="/assets/images/",br=e=>e.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",Ne=e=>e?vr.test(e)||/^\s|\s$/.test(e)?JSON.stringify(e):e:'""',je=e=>{if(!e)return;const n=Number(e);return Number.isFinite(n)?new Date(n).toISOString():e},Ze=()=>typeof window>"u"||!window.location?.origin?"http://localhost":window.location.origin,ke=(e,n=Ze())=>{try{const t=new URL(e,n);return t.origin===n&&t.pathname.startsWith(yr)}catch{return!1}},jt=(e,n=Ze())=>{const t=new URL(e,n);return`${t.pathname}${t.search}`},Rt=e=>e.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase()??"",wr=e=>e.trim().replace(/[\\/:*?"<>|]/g,"-").split("").map(s=>s.charCodeAt(0)<32?"-":s).join("").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"image",Cr=e=>{const n=e.lastIndexOf(".");return n<=0||n===e.length-1?{baseName:e,extension:""}:{baseName:e.slice(0,n),extension:e.slice(n)}},At=(e,n,t)=>{const r=new URL(e,Ze()).pathname.split("/").filter(Boolean),i=decodeURIComponent(r[r.length-1]??""),c=`image-${n+1}`,{baseName:l,extension:p}=Cr(wr(i||c));let u=`${l}${p}`,h=2;for(;t.has(u);)u=`${l}-${h}${p}`,h+=1;return t.add(u),`assets/${u}`},Nr=(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},Sr=(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),c=s===0?-1:e.lastIndexOf(">",s-1);if(i<=c&&(!r||/[\s/>]/.test(r)))return s;t=s+4}return-1},jr=(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 c=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 l=e[r];if(l==='"'||l==="'"){const u=r+1,h=e.indexOf(l,u);if(h===-1||h>t)return;if(r=h+1,c===s)return{end:h,start:u,value:e.slice(u,h)};continue}const p=r;for(;r<t&&/[^\s>]/.test(e[r]);)r+=1;if(c===s)return{end:r,start:p,value:e.slice(p,r)}}},kt=e=>{const n=[];let t=0;for(;t<e.length;){const s=Sr(e,t);if(s===-1)break;const r=Nr(e,s+4);if(r===-1)break;const i=jr(e,s+4,r,"src");i&&n.push({end:r+1,source:i,start:s}),t=r+1}return n},Et=(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},Tt=(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},Dt=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]!==`
|
|
2
|
-
`;){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 c=r+1;let l=c;for(;l<e.length&&e[l]!==`
|
|
3
|
-
`&&/\s/.test(e[l]);)l+=1;if(l>=e.length||e[l]===`
|
|
4
|
-
`){t=s+2;continue}let p=l,u=l,h=l;if(e[l]==="<"){for(r=l+1;r<e.length&&e[r]!==">"&&e[r]!==`
|
|
5
|
-
`;)r+=e[r]==="\\"?2:1;if(e[r]!==">"){t=s+2;continue}p=r+1,u=l+1,h=r}else{let x=0;for(r=l;r<e.length&&e[r]!==`
|
|
6
|
-
`;){const m=e[r];if(m==="\\"){r+=2;continue}if(/\s/.test(m)&&x===0)break;if(m==="(")x+=1;else if(m===")"){if(x===0)break;x-=1}r+=1}p=r,u=l,h=p}if(h<=u){t=s+2;continue}for(r=p;r<e.length&&e[r]!==`
|
|
7
|
-
`&&/\s/.test(e[r]);)r+=1;if(e[r]==='"'||e[r]==="'"){const x=e[r];for(r+=1;r<e.length&&e[r]!==`
|
|
8
|
-
`;){if(e[r]==="\\"){r+=2;continue}if(e[r]===x){r+=1;break}r+=1}}for(;r<e.length&&e[r]!==`
|
|
9
|
-
`&&/\s/.test(e[r]);)r+=1;if(e[r]!==")"){t=s+2;continue}n.push({end:r+1,source:{end:p,start:c,value:e.slice(u,h)},start:s}),t=r+1}return n},Rr=(e,n)=>`${br(e)}.${n}`,Ar=({id:e,title:n,createdAt:t,updatedAt:s})=>{const r=["---",`title: ${Ne(n)}`,`note_id: ${Ne(e)}`],i=je(t),c=je(s);return i&&r.push(`created_at: ${Ne(i)}`),c&&r.push(`updated_at: ${Ne(c)}`),r.push("source: ocean-brain","---"),r.join(`
|
|
10
|
-
`)},Mt=(e,n,t=!1)=>t?`${Ar(n)}
|
|
11
|
-
|
|
12
|
-
${e}`:e,Pt=(e,n,{includeMetadata:t=!1}={})=>{const s=Mt(e,n,t),r=Dt(s).filter(i=>ke(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return Tt(s,r)},_t=(e,n,{includeMetadata:t=!1}={})=>`${t?`<!--
|
|
13
|
-
source: ocean-brain
|
|
14
|
-
note_id: ${n.id}
|
|
15
|
-
title: ${n.title}
|
|
16
|
-
created_at: ${je(n.createdAt)??""}
|
|
17
|
-
updated_at: ${je(n.updatedAt)??""}
|
|
18
|
-
-->
|
|
19
|
-
`:""}${e}`,kr=(e,n,{includeMetadata:t=!1}={})=>{const s=_t(e,n,{includeMetadata:t}),r=kt(s).filter(i=>ke(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return Et(s,r)},Er=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new bt,i=_t(e,n,{includeMetadata:s}),c=kt(i),l=[],p=new Set,u=new Map;for(const{source:h}of c){if(!ke(h.value))continue;const x=jt(h.value);let m=u.get(x);if(!m){m=At(x,u.size,p),u.set(x,m);const d=await t(x,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${x}`);if(!Rt(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${x}`);r.file(m,new Uint8Array(await d.arrayBuffer()))}l.push({end:h.end,start:h.start,value:`./${m}`})}return r.file("note.html",Et(i,l)),r.generateAsync({type:"blob"})},Tr=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new bt,i=Mt(e,n,s),c=Dt(i),l=[],p=new Set,u=new Map;for(const{source:h}of c){if(!ke(h.value))continue;const x=jt(h.value);let m=u.get(x);if(!m){m=At(x,u.size,p),u.set(x,m);const d=await t(x,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${x}`);if(!Rt(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${x}`);r.file(m,new Uint8Array(await d.arrayBuffer()))}l.push({end:h.end,start:h.start,value:`./${m}`})}return r.file("note.md",Tt(i,l)),r.generateAsync({type:"blob"})},Dr=(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)},Ot={html:{extension:"html",getContent:e=>e.getHtml(),createDocumentBlob:(e,n)=>new Blob([kr(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/html;charset=utf-8"}),createZipBlob:(e,n)=>Er(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})},markdown:{extension:"md",getContent:e=>e.getMarkdown(),createDocumentBlob:(e,n)=>new Blob([Pt(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/markdown;charset=utf-8"}),createZipBlob:(e,n)=>Tr(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})}},Bt=(e,n)=>n?"zip":Ot[e].extension,Mr=async e=>{const n=Ot[e.format],t=n.getContent(e.source);if(t===void 0)return{type:"not-ready",format:e.format};const s=Bt(e.format,e.includeAssets);return{type:"success",blob:e.includeAssets?await n.createZipBlob(t,e):n.createDocumentBlob(t,e),filename:Rr(e.metadata.title,s)}},Pr=e=>e==="markdown"?"Markdown is not ready yet.":"HTML is not ready yet.",at=({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(ht,{id:t,size:"sm",checked:e,onChange:c=>r(c.target.checked),"aria-labelledby":i}),a.jsx("label",{id:i,htmlFor:t,className:"min-w-0 cursor-pointer",children:a.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"block",children:s})}),a.jsx(mn,{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(Un,{className:"h-3.5 w-3.5"})})})]})};function _r({isOpen:e,metadata:n,getHtml:t,getMarkdown:s,onClose:r}){const i=Re(),[c,l]=o.useState("html"),[p,u]=o.useState(!0),[h,x]=o.useState(!1),[m,d]=o.useState(!1),v=Bt(c,p),b=async()=>{d(!0);try{const S=await Mr({format:c,includeAssets:p,includeMetadata:h,metadata:n,source:{getHtml:t,getMarkdown:s}});if(S.type==="not-ready"){i(Pr(S.format));return}Dr(S.blob,S.filename),r(),i("Downloaded note.")}catch{i("Failed to download note.")}finally{d(!1)}};return a.jsxs(M,{isOpen:e,onClose:r,variant:"compact",children:[a.jsx(M.Header,{title:"Download document",onClose:r}),a.jsx(M.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(N,{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:c==="html",onChange:()=>l("html"),className:"h-4 w-4 accent-cta"}),a.jsx(N,{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:c==="markdown",onChange:()=>l("markdown"),className:"h-4 w-4 accent-cta"}),a.jsx(N,{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(N,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Options"}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(at,{id:"note-export-include-assets",label:"Include local image assets",checked:p,onChange:u,description:"Bundle uploaded Ocean Brain images with the document. Without assets, local images are omitted."}),a.jsx(at,{id:"note-export-include-metadata",label:"Include metadata",checked:h,onChange:x,description:"Add the note title, note id, timestamps, and Ocean Brain source information."})]})]})]})}),a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),a.jsx(T,{variant:"primary",size:"sm",onClick:b,disabled:m,children:m?"Downloading...":`Download .${v}`})]})})]})}const Lt=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"},Or=({isDeleted:e,isConflict:n,source:t})=>{const s=Lt(t);return e?`This note was moved to trash ${s.place}`:n?`Save paused: note changed ${s.place}`:`This note changed ${s.place}`},Br=({isDeleted:e,isConflict:n,hasDraft:t,source:s})=>{const r=Lt(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 Lr({isOpen:e,isDeleted:n,isConflict:t,hasDraft:s,source:r,isReloading:i,onReload:c,onOverwrite:l,onCloneDraft:p,onOpenTrash:u}){return a.jsxs(M,{isOpen:e,onClose:()=>{},variant:"inspect",children:[a.jsx(M.Header,{title:Or({isDeleted:n,isConflict:t,source:r})}),a.jsx(M.Body,{children:a.jsx(N,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:Br({isDeleted:n,isConflict:t,hasDraft:s,source:r})})}),a.jsx(M.Footer,{children:a.jsx(xe,{children:n?a.jsx(T,{type:"button",variant:"primary",size:"sm",onClick:u,children:"Open trash"}):t?a.jsxs(a.Fragment,{children:[a.jsx(T,{type:"button",variant:"subtle",size:"sm",isLoading:i,onClick:c,children:"Reload latest"}),s&&a.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:p,children:"Clone draft"}),a.jsx(T,{type:"button",variant:"danger",size:"sm",onClick:l,children:"Overwrite"})]}):a.jsx(T,{type:"button",variant:"primary",size:"sm",isLoading:i,onClick:c,children:"Reload latest"})})})]})}function Fr({localDraftCreatedAt:e,hasSaveError:n,onRestoreDraft:t,onDiscardDraft:s,onRetrySave:r,onSaveAsNewNote:i}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(tt,{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(T,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:t,children:"Restore draft"}),a.jsx(T,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:s,children:"Discard"})]})]})}),n&&a.jsx(tt,{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(T,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:r,children:"Retry save"}),a.jsx(T,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:i,children:"Save as new note"})]})]})})]})}const st=(e,n)=>e||(n==="mobile"?"Mobile browser":n==="mcp"?"MCP":"Web browser");function $r({isOpen:e,noteId:n,onClose:t,restoreSnapshot:s=mt,onRestored:r}){const i=Re(),c=Ke(),[l,p]=o.useState(null),[u,h]=o.useState("diff"),x=o.useRef(null),m=$e({queryKey:E.notes.snapshots(n),queryFn:async()=>{const f=await gn(n);if(f.type==="error")throw f;return f.noteSnapshots},enabled:e}),d=On({mutationFn:s,onSuccess:async f=>{if(f){if(f.type==="error"){i(f.errors[0].message);return}await Promise.all([c.invalidateQueries({queryKey:E.notes.detail(n),exact:!0}),c.invalidateQueries({queryKey:E.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.tagNameListAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.pinned(),exact:!0}),c.invalidateQueries({queryKey:E.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.graph(),exact:!0}),c.invalidateQueries({queryKey:E.notes.snapshots(n),exact:!1}),c.invalidateQueries({queryKey:E.views.sectionNotesAll(),exact:!1}),c.invalidateQueries({queryKey:E.tags.all(),exact:!1})]),i("Previous version restored."),r?.(f.restoreNoteSnapshot),p(null),t()}}}),v=m.data?.find(f=>f.id===l)??null,b=$e({queryKey:[...E.notes.snapshotDetail(l??"pending"),"diff"],queryFn:async()=>{if(!l)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await xn(l,"current");if(f.type==="error")throw f;if(!f.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return f.noteSnapshotDiff},enabled:!!l&&u==="diff"}),S=$e({queryKey:E.notes.snapshotDetail(l??"pending"),queryFn:async()=>{if(!l)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await vn(l);if(f.type==="error")throw f;if(!f.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return f.noteSnapshot},enabled:!!l&&u==="content"}),j=S.data?.contentAsMarkdown.trim()??"";o.useEffect(()=>{l&&x.current?.focus()},[l]);const A=(f,y)=>{h(y),p(f)},w=()=>{p(null),h("diff"),t()};return a.jsxs(M,{isOpen:e,onClose:w,variant:"inspect",children:[a.jsx(M.Header,{title:v?u==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:w}),a.jsx(M.Description,{className:"sr-only",children:v?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(M.Body,{children:v?a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(N,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:v.title}),a.jsxs(N,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",st(v.meta.label,v.meta.entrypoint)," ","edit - ",Q(v.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(T,{variant:u==="diff"?"primary":"subtle",size:"sm",onClick:()=>h("diff"),children:"Show diff"}),a.jsx(T,{variant:u==="content"?"primary":"subtle",size:"sm",onClick:()=>h("content"),children:"View content"})]}),u==="diff"?b.isLoading?a.jsx(N,{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..."}):b.isError?a.jsx(N,{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."}):b.data?a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(N,{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:b.data.diff.markdown.split(`
|
|
20
|
-
`).map((f,y)=>{const D=f.startsWith("+")&&!f.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":f.startsWith("-")&&!f.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":f.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 ${D}`,children:f||" "},`${y}-${f}`)})})]}):null:S.isLoading?a.jsx(N,{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..."}):S.isError?a.jsx(N,{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."}):j?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:j}):a.jsx(N,{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(N,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),m.isLoading&&a.jsx(N,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!m.isLoading&&m.data?.length===0&&a.jsx(N,{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."}),!m.isLoading&&m.data&&m.data.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:m.data.map(f=>a.jsx(Kn,{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(N,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",st(f.meta.label,f.meta.entrypoint)," ","edit"]}),a.jsx(N,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:f.title}),a.jsx(N,{as:"p",variant:"label",tone:"tertiary",children:Q(f.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(T,{variant:"subtle",size:"sm",onClick:()=>A(f.id,"diff"),children:"Compare"}),a.jsx(T,{size:"sm",isLoading:d.isPending,onClick:()=>d.mutate(f.id),children:"Restore"})]})]}),f.contentPreview&&a.jsx("div",{className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:f.contentPreview})})]})},f.id))})]})}),v&&a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{ref:x,variant:"subtle",onClick:()=>{p(null),h("diff")},children:"Back"}),a.jsx(T,{isLoading:d.isPending,onClick:()=>d.mutate(v.id),children:"Restore this version"})]})})]})}const ot={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 Ur({isOpen:e,onClose:n,onSave:t,reminder:s,mode:r}){const[i,c]=o.useState(new Date),[l,p]=o.useState("medium"),[u,h]=o.useState("");o.useEffect(()=>{e&&r==="edit"&&s?(c(new Date(Number(s.reminderDate))),p(s.priority||"medium"),h(s.content||"")):e&&r==="create"&&(c(new Date),p("medium"),h(""))},[e,r,s]);const x=()=>{t(i,l,u||void 0),n()},m=d=>l===d?ot[d].active:ot[d].inactive;return a.jsxs(M,{isOpen:e,onClose:n,variant:"form",children:[a.jsx(M.Header,{title:r==="create"?"Create Reminder":"Edit Reminder",onClose:n}),a.jsx(M.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(Le,{children:"Date & Time"}),a.jsx(yn,{type:"datetime-local",size:"sm",value:Q(i).format("YYYY-MM-DDTHH:mm"),onChange:d=>c(new Date(d.target.value))})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Le,{children:"Content"}),a.jsx(bn,{size:"sm",placeholder:"Enter reminder content (optional)",value:u,onChange:d=>h(d.target.value)})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Le,{children:"Priority"}),a.jsxs(wn,{type:"single",variant:"quiet",value:l,onValueChange:d=>d&&p(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 ${m("low")}`,children:a.jsx(N,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),a.jsx(Fe,{value:"medium",className:`flex-1 rounded-[10px] border ${m("medium")}`,children:a.jsx(N,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),a.jsx(Fe,{value:"high",className:`flex-1 rounded-[10px] border ${m("high")}`,children:a.jsx(N,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(T,{variant:"primary",size:"sm",onClick:x,children:r==="create"?"Create":"Save"})]})})]})}function Hr({noteId:e}){const[n,t]=o.useState(!1),[s,r]=o.useState(!1),[i,c]=o.useState("create"),[l,p]=o.useState(void 0),{onCreate:u,onUpdate:h,onDelete:x}=Yn(),m=()=>{c("create"),p(void 0),r(!0)},d=w=>{c("edit"),p(w),r(!0)},v=(w,f,y)=>{i==="create"?u(e,w,f,()=>{r(!1)},y):i==="edit"&&l&&h(l.id,e,{reminderDate:w,priority:f,content:y},()=>{r(!1)})},b=w=>{h(w.id,e,{completed:!w.completed})},S=w=>{const f=Q(Number(w)),y=Q();return f.isSame(y,"day")?`Today at ${f.format("HH:mm")}`:f.isSame(y.add(1,"day"),"day")?`Tomorrow at ${f.format("HH:mm")}`:f.format("YYYY-MM-DD HH:mm")},j=w=>{const f=Q(Number(w)),y=Q(),D=f.diff(y,"hour");return D<=6?"high":D<=24?"medium":"low"},A=w=>{const f=Q(Number(w)),y=Q(),D=f.diff(y,"hour"),F=f.diff(y,"minute")%60;return D<0||F<0?"Overdue":D===0?`${F}m remaining`:`${D}h ${F}m remaining`};return a.jsxs(a.Fragment,{children:[a.jsx(wt,{title:"Reminders",icon:a.jsx(Bn,{className:"h-3.5 w-3.5"}),action:a.jsxs(a.Fragment,{children:[!n&&a.jsxs(T,{size:"sm",variant:"ghost",onClick:m,children:[a.jsx(Qn,{className:"w-3 h-3"}),a.jsx(N,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),a.jsxs(T,{type:"button",size:"sm",variant:"ghost","aria-label":n?"Expand reminders":"Collapse reminders","aria-expanded":!n,onClick:()=>t(!n),children:[n?a.jsx(Cn,{className:"h-3.5 w-3.5"}):a.jsx(Nn,{className:"h-3.5 w-3.5"}),n?"Expand":"Collapse"]})]}),children:!n&&a.jsx(qn,{noteId:e,searchParams:{offset:0,limit:9999},render:({reminders:w,totalCount:f})=>a.jsx("div",{className:"flex flex-col gap-2",children:w.length===0?a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:f===0?"No reminders yet":"All reminders complete"}):a.jsx("div",{className:"flex flex-col",children:w.map(y=>{const D=y.priority||j(y.reminderDate),F=A(y.reminderDate),P=F==="Overdue";return a.jsxs("div",{className:J("flex items-center gap-2.5 px-2 py-1.5"),children:[a.jsx(ht,{checked:y.completed,onChange:()=>b(y),size:"sm","aria-label":`Reminder: ${y.content||S(y.reminderDate)}`}),a.jsx(N,{as:"div",variant:"body",weight:"medium",className:J("truncate flex-1 min-w-0",y.completed&&"line-through opacity-40"),children:y.content||S(y.reminderDate)}),a.jsxs("div",{className:J("shrink-0 flex items-center gap-1",y.completed&&"opacity-40"),children:[y.content&&a.jsx(N,{as:"span",variant:"meta",tone:"secondary",children:S(y.reminderDate)}),!y.completed&&a.jsx(N,{as:"span",variant:"label",weight:"medium",tone:P||D==="high"?"error":"tertiary",className:J(y.content&&'before:content-["·"] before:mr-1'),children:F})]}),a.jsx(pt,{button:a.jsx(xt,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>d(y)},{name:"Delete",onClick:()=>x(y.id,e)}]})]},y.id)})})})})}),a.jsx(Ur,{isOpen:s,onClose:()=>r(!1),onSave:v,reminder:l,mode:i})]})}const Ir=({editor:e})=>a.jsx(Ge,{triggerCharacter:"/",getItems:async n=>tr([...Gn(e).filter(t=>t.title!=="Audio"&&t.title!=="Video"&&t.title!=="File"),{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(vt,{})}],n)}),Vr=(e,n)=>n?e.filter(t=>t.id!==n):e,zr=({currentNoteId:e,onClick:n})=>a.jsx(Ge,{triggerCharacter:"[",getItems:async t=>{const s=await Sn({query:t,limit:5});return s.type==="error"?[]:Vr(s.allNotes.notes,e).map(i=>({title:i.title,onItemClick:()=>n({type:"reference",props:{id:i.id,title:i.title}})}))}}),Ft=["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/avif"],Wr=new Set(Ft),it="Unsupported image type. Use PNG, JPEG, GIF, WebP, BMP, or AVIF.",Kr="Failed to upload image.",Yr=e=>Wr.has(e),qr="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",Qr={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"},Gr={idle:"Copy",copied:"Copied",failed:"Copy failed"},Zr=({getText:e,resetDelayMs:n=2e3})=>{const[t,s]=o.useState("idle"),r=o.useRef(null),i=o.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),c=o.useCallback(()=>{i(),r.current=setTimeout(()=>{s("idle"),r.current=null},n)},[i,n]);o.useEffect(()=>i,[i]);const l=h=>{h.stopPropagation()},p=h=>{h.preventDefault(),h.stopPropagation()},u=async h=>{l(h);try{await navigator.clipboard.writeText(e()),s("copied")}catch{s("failed")}c()};return a.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:p,children:a.jsxs("button",{type:"button",className:J(qr,Qr[t]),contentEditable:!1,onClick:u,children:[a.jsx(ar,{className:"h-3.5 w-3.5"}),a.jsx("span",{"aria-live":"polite",children:Gr[t]})]})})},Jr=({contentRef:e})=>{const n=o.useRef(null),t=o.useCallback(s=>{n.current=s,e(s)},[e]);return a.jsxs(a.Fragment,{children:[a.jsx("pre",{children:a.jsx("code",{ref:t})}),a.jsx(Zr,{getText:()=>n.current?.textContent?.trimEnd()??""})]})},Xr="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))]",ea={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function ta(e){const n=gt(),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:Xr,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 na=Ct(ea,{render:e=>a.jsx(ta,{...e})}),ra=()=>{const e=Zn(),[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 c=()=>{const p=e.document,u=[],h=x=>{for(const m of x){if(m.type==="heading"){const d=m,v=d.props.level||1,b=d.content?.map(S=>S.text||"").join("")||"";b.trim()&&u.push({id:m.id,level:v,text:b})}m.children&&Array.isArray(m.children)&&h(m.children)}};h(p),t(u)};c();const l=e.onChange?.(c);return()=>{l&&l()}},[e]);const r=c=>{e.setTextCursorPosition(c);const l=document.querySelector(`[data-id="${c}"]`);if(l){const p=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;l.scrollIntoView({behavior:p?"auto":"smooth",block:"center"})}},i=a.jsx(Hn,{icon:a.jsx(vt,{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(N,{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(c=>{const l=c.level===1;return a.jsxs("button",{type:"button",onClick:()=>r(c.id),className:J("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",s[c.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",l?"text-fg-default":"text-fg-secondary"),children:[a.jsxs(N,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",c.level]}),a.jsx(N,{as:"span",variant:"body",weight:l?"semibold":"medium",className:"line-clamp-2 text-current",children:c.text})]},c.id)})})]})},aa=Nt({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>a.jsx(ra,{})})(),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",oa={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function ia(e){const n=gt(),t=()=>{e.editor.blur(),n({to:zn,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 ca=Ct(oa,{render:e=>a.jsx(ia,{...e})}),la=e=>e,da=e=>e,ua=la({tag:ca,reference:na}),fa=da({tableOfContents:aa}),ce=me.codeBlock,ct=Nt(ce.config,{meta:ce.implementation.meta,parse:ce.implementation.parse,parseContent:ce.implementation.parseContent,runsBefore:ce.implementation.runsBefore,render:Jr})(),pa={...ct,extensions:ce.extensions,implementation:{...ct.implementation,toExternalHTML:ce.implementation.toExternalHTML}},ha={...me.image,implementation:{...me.image.implementation,meta:{...me.image.implementation.meta,fileBlockAccept:[...Ft]}}},ma=nr.create({inlineContentSpecs:{...rr,...ua},blockSpecs:{...me,image:ha,codeBlock:pa,...fa}}),ga=(e,n)=>n.some(t=>t.name===`@${e}`),xa=({onClick:e})=>a.jsx(Ge,{triggerCharacter:"@",getItems:async n=>{const t=await sr({query:n,limit:5});if(t.type==="error")return[];const{tags:s}=t.allTags,r=ga(n,s),i=[{title:"Add a new tag",onItemClick:async()=>{const c=await or({name:"@"+n});if(c.type==="error")return;const{id:l,name:p}=c.createTag;e({type:"tag",props:{id:l,tag:p}})}}];return s.length===0?i:s.map(c=>({title:c.name,onItemClick:()=>e({type:"tag",props:{id:c.id,tag:c.name}})})).concat(n&&!r?i:[])}}),va=/^ {0,3}(`{3,}|~{3,})/,ya=/<[^<>\n]*>/g,$t=/~+/g,Ut=/[\p{L}\p{M}\p{N}\p{Sc}%‰.,+\-/:°℃℉µμ·²³^]/u,We=new RegExp("^(?:[+-]?\\p{Sc}?|\\p{Sc}[+-]?)\\p{N}","u"),Ht=/&#(?:x[0-9a-f]+|\d+);/giu,ba=new Set(["Files","blocknote/html","vscode-editor-data"]),lt="OBTILDE",dt="",wa=[/(^|\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))/],Ca=e=>e.split(`
|
|
21
|
-
`).some(n=>{const t=n.trim();return t.length>2&&t.startsWith("|")&&t.endsWith("|")}),Na=e=>wa.some(n=>n.test(e))||Ca(e),Sa=e=>e.endsWith(`\r
|
|
22
|
-
`)?{body:e.slice(0,-2),ending:`\r
|
|
23
|
-
`}:e.endsWith(`
|
|
24
|
-
`)||e.endsWith("\r")?{body:e.slice(0,-1),ending:e.slice(-1)}:{body:e,ending:""},It=(e,n,t)=>{let s=n;for(;e[s]===t;)s+=1;return s-n},Vt=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)},ja=e=>{const n=e.replace(Ht,Vt),t=e.toLowerCase();let s=0,r=`${lt}${s}${dt}`;for(;e.includes(r)||t.includes(encodeURIComponent(r).toLowerCase())||n.includes(r);)s+=1,r=`${lt}${s}${dt}`;return r},Ra=(e,n,t)=>t-n>2?!1:zt(e,n)&&ka(e,t),ut=(e,n)=>{let t=n;for(;t>0&&Ut.test(e[t-1]??"");)t-=1;return{start:t,token:e.slice(t,n)}},Aa=(e,n)=>{let t=n;for(;t<e.length&&Ut.test(e[t]??"");)t+=1;return e.slice(n,t)},zt=(e,n)=>{const t=ut(e,n);if(We.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:We.test(ut(e,s).token)},ka=(e,n)=>We.test(Aa(e,n)),Wt=e=>{const n=[],t=new Set;for(const s of e.matchAll($t)){const r=s.index,i=s[0].length,c=r+i;if(i>2)continue;const l=c<e.length&&!/\s/u.test(e[c]??""),p=r>0&&!/\s/u.test(e[r-1]??"");if(Ra(e,r,c)){if(p&&t.delete(i))continue;n.push({length:i,start:r});continue}p&&t.delete(i)||l&&zt(e,r)&&t.add(i)}return n},Ue=(e,n)=>{let t="",s=0;const r=new Set(Wt(e).map(i=>i.start));for(const i of e.matchAll($t)){const c=i.index,l=c+i[0].length;t+=e.slice(s,c),t+=r.has(c)?n.repeat(i[0].length):i[0],s=l}return t+e.slice(s)},Ea=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},Ta=(e,n)=>{let t="",s=0;for(const r of e.matchAll(ya)){const i=r.index;t+=Ue(e.slice(s,i),n),t+=Ea(r[0])?r[0]:Ue(r[0],n),s=i+r[0].length}return t+Ue(e.slice(s),n)},Kt=e=>Wt(e).length>0,Da=e=>{if(!Kt(e))return nt(e);const n=ja(e),t=Ta(e,n),s=encodeURIComponent(n);return nt(t).split(n).join("~").split(s).join("~")},Ma=(e,n)=>{let t=0;for(let s=n-1;s>=0&&e[s]==="\\";s-=1)t+=1;return t%2===1},Pa=(e,n,t)=>{let s=n+t;for(;s<e.length;){const r=e.indexOf("`",s);if(r===-1)return null;const i=It(e,r,"`");if(i===t)return r+i;s=r+i}return null},_a=(e,n)=>{let t=e.indexOf("`",n);for(;t!==-1;){const s=It(e,t,"`");if(!Ma(e,t)){const r=Pa(e,t,s);if(r!==null)return{start:t,end:r}}t=e.indexOf("`",t+s)}return null},Oa=(e,n)=>{let t="",s=0;for(;s<e.length;){const r=_a(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},Yt=(e,n)=>{let t=null;return e.split(new RegExp("(?<=\\n)")).map(s=>{const{body:r,ending:i}=Sa(s);if(t)return new RegExp(`^ {0,3}${t.marker}{${t.length},} *$`).test(r)&&(t=null),s;const c=r.match(va)?.[1];return c?(t={marker:c[0],length:c.length},s):`${Oa(r,n)}${i}`}).join("")},Ba=(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},qt=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=Ba(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},La=(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},Fa=(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},$a=(e,n,t)=>La(e,n)||Fa(e,n+t),Ua=e=>Yt(e,n=>{const t=n.replace(Ht,(s,r,i)=>$a(i,r,s.length)?Vt(s):s);return qt(t)}),Ha=e=>Yt(e,qt),Ia=e=>{const n=e.getData("text/plain");n&&(e.setData("text/markdown",n),e.setData("text/plain",Ua(n)))},Va=({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(l=>ba.has(l)))return t();const i=r.includes("text/markdown"),c=s.getData(i?"text/markdown":"text/plain");return!c||!Kt(c)||!i&&r.includes("text/html")&&!Na(c)?t():(n.pasteHTML(Da(c)),!0)},za=new Set(["tableOfContents"]),Wa="OCEAN_BRAIN_TAG_",Ka="_TOKEN",Ya=e=>`${Wa}${e}${Ka}`,qa=e=>!Array.isArray(e)&&e?.type==="tableContent",Qa=(e,n)=>Array.isArray(e)?e.map(n):qa(e)?{...e,rows:e.rows?.map(t=>({...t,cells:t.cells?.map(s=>({...s,content:s.content?.map(n)}))}))}:e,Qt=(e,n)=>e.filter(t=>!za.has(t.type)).map(t=>({...t,content:n(t.content),children:t.children?.length?Qt(t.children,n):[]}));function Ga(e){const n=new Map;let t=0;return{blocks:Qt(e,r=>Qa(r,i=>{if(i.type==="reference"){const c=String(i.props?.id||""),l=String(i.props?.title||i.props?.id||"");return{type:"text",text:c?`[[${l}]](note:${c})`:`[[${l}]]`,styles:{}}}if(i.type==="tag"){const c=i.props?.tag||"",l=Ya(t);return t+=1,n.set(l,c),{type:"text",text:l,styles:{}}}return i})),placeholderToTag:n}}function Za(e,n){let t=e;for(const[s,r]of n.entries())t=t.split(s).join(`[${r}]`);return t}async function Ja(e){return new Promise((n,t)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>n(s.result),s.onerror=r=>t(r)})}const Xa=o.forwardRef(({content:e,currentNoteId:n,editable:t,onChange:s},r)=>{const{theme:i}=jn(u=>u),c=Re(),l=Jn({schema:ma,initialContent:e&&JSON.parse(e)||void 0,pasteHandler:u=>Va(u),uploadFile:async(u,h)=>{const x=()=>{h&&l.getBlock(h)&&l.removeBlocks([h])};if(!Yr(u.type))throw x(),c(it),new Error(it);try{return await er({base64:await Ja(u)})}catch(m){throw x(),c(Kr),m}}},[c]);o.useImperativeHandle(r,()=>({getContent:()=>JSON.stringify(l.document),getMarkdown:()=>{const u=Ga(l.document),h=l.blocksToMarkdownLossy(u.blocks);return Ha(Za(h,u.placeholderToTag))},getHtml:()=>l.blocksToHTMLLossy(l.document)}));const p=u=>{Ia(u.clipboardData)};return a.jsxs(Xn,{slashMenu:!1,theme:i,editor:l,editable:t,onChange:s,onCopy:p,onCut:p,children:[a.jsx(Ir,{editor:l}),a.jsx(zr,{currentNoteId:n,onClick:u=>{l.insertInlineContent([u," "])}}),a.jsx(xa,{onClick:u=>{l.insertInlineContent([u," "])}})]})}),es=({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 c=Se(e.updatedAt,s),l=Se(e.updatedAt,r);return c!==null&&c<=0||l!==null&&l<=0?{type:"ignore"}:{type:"notify",change:{type:"updated",updatedAt:e.updatedAt,source:e.source},shouldPauseSave:i}},ts=({change:e,isConflict:n,loadedUpdatedAt:t})=>e?!(e.type==="updated"&&!n&&e.updatedAt===t):!1;function ns({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 c=await s();return c==="error"?(r("Save failed. Stay on this note and try again."),!0):c==="conflict"},[e,s,r,t]);cr({disabled:t==="saved"&&!n,enableBeforeUnload:!1,shouldBlockFn:i})}const Je=e=>`ocean-brain.note-draft.${e}`,rs=e=>{if(typeof window>"u")return null;try{const n=window.localStorage.getItem(Je(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}},He=(e,n)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Je(e),JSON.stringify(n))}catch{}},Ie=e=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Je(e))}catch{}},as=1e3,ss="NOTE_UPDATE_CONFLICT";function os({noteId:e,initialContent:n,initialUpdatedAt:t,editSessionIdRef:s,getContent:r,beforeSave:i,hasExternalPendingChanges:c,serverVersionRef:l,executeWrite:p,onSaved:u,onConflict:h,onError:x}){const m=Ke(),d=o.useRef(null),v=o.useRef(null),b=o.useRef(!1),S=o.useRef(null),j=o.useRef(!1),A=o.useRef(t),w=l??A,f=o.useRef(0),y=o.useRef(!1),D=o.useRef(!0),F=o.useRef(u),P=o.useRef(h),W=o.useRef(x),ve=o.useRef(i),X=o.useRef(c),he=o.useRef(p),[re,ee]=o.useState("saved"),[Ee,le]=o.useState(null),$=o.useCallback(()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]),B=o.useCallback(k=>{D.current&&ee(k)},[]),Te=o.useCallback(k=>{w.current=k},[]),ye=o.useCallback((k,L={})=>({title:k,content:r()??n,createdAt:Date.now(),baseUpdatedAt:w.current,...L.layout?{layout:L.layout}:{}}),[r,n]),de=o.useCallback(()=>{v.current&&He(e,v.current)},[e]),ae=o.useCallback(k=>{y.current=!0,B("conflict"),P.current(k??w.current)},[B]),O=o.useCallback(async({ignoreConflict:k=!1,silent:L=!1}={})=>{if(b.current)return j.current=!0,S.current??"idle";const Me=v.current!==null,se=X.current?.()??!1;if(!Me&&!se)return j.current=!1,"idle";const U=f.current;j.current=!1,$(),b.current=!0,L||B("saving");const H=(async()=>{const ue=await ve.current?.()??"idle";if(U!==f.current)return"idle";if(ue==="error")return b.current=!1,S.current=null,v.current?B("error"):B("saved"),"error";const _=v.current;if(!_)return b.current=!1,S.current=null,B("saved"),ue;v.current=null;const q=async()=>{if(U!==f.current)return"idle";let z;try{z=await ze({id:e,title:_.title,content:_.content,..._.layout?{layout:_.layout}:{},editSessionId:s.current,...k?{force:!0}:{expectedUpdatedAt:w.current}})}catch{z={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(U!==f.current)return"idle";if(z.type==="error"){b.current=!1,S.current=null,v.current||(v.current=_),de();const I=z.errors[0];if(I.code===ss&&!k){const oe=I.details?.extensions?.currentUpdatedAt;return y.current=!0,!L&&D.current&&(B("conflict"),P.current(oe??w.current)),"conflict"}return!L&&D.current&&(B("error"),W.current(I.message)),"error"}const we=!L&&D.current,Z=E.notes.detail(e);if(await m.cancelQueries({queryKey:Z,exact:!0}),U!==f.current)return"idle";b.current=!1,S.current=null,y.current=!1,w.current=z.updateNote.updatedAt,we&&F.current(z.updateNote.updatedAt),m.setQueryData(Z,I=>I&&{...I,title:z.updateNote.title,content:_.content,..._.layout?{layout:_.layout}:{},updatedAt:z.updateNote.updatedAt}),yt({noteId:e,updatedAt:z.updateNote.updatedAt,editSessionId:s.current});const fe=v.current;return fe?.baseUpdatedAt===_.baseUpdatedAt?(v.current={...fe,baseUpdatedAt:z.updateNote.updatedAt},de()):fe||Ie(e),we&&(v.current?ee("pending"):(ee("saved"),m.invalidateQueries({queryKey:E.notes.listAll(),exact:!1}),m.invalidateQueries({queryKey:E.notes.tagListAll(),exact:!1}),m.invalidateQueries({queryKey:E.notes.backReferencesAll(),exact:!1}),m.invalidateQueries({queryKey:E.notes.graph(),exact:!0}))),"saved"},V=he.current?await he.current(q):await q();return V?V==="saved"&&(v.current||j.current)?O({silent:L}):V:(v.current||(v.current=_),de(),b.current=!1,S.current=null,B("pending"),"idle")})();return S.current=H,H},[$,s,e,de,m,w,B]),te=o.useCallback((k,L={})=>{if(v.current=k,He(e,k),y.current){B("conflict");return}if(B("pending"),$(),L.immediate){O();return}d.current=window.setTimeout(()=>{O()},as)},[$,O,e,B]),ne=o.useCallback(k=>{if(v.current=k,He(e,k),le(null),k.baseUpdatedAt!==w.current){ae(w.current);return}te(k)},[e,te,ae]),be=o.useCallback(()=>{f.current+=1,$(),v.current=null,b.current=!1,S.current=null,j.current=!1,y.current=!1,Ie(e),le(null),ee("saved")},[$,e]),De=o.useCallback(()=>{$(),S.current=null,j.current=!1,y.current=!1,B(v.current?"pending":"saved")},[$,B]),G=o.useCallback(()=>{Ie(e),le(null)},[e]),Y=o.useCallback(()=>v.current,[]),K=o.useCallback(k=>{$(),ae(k)},[$,ae]);return o.useEffect(()=>{ve.current=i,he.current=p,X.current=c,P.current=h,W.current=x,F.current=u},[i,p,c,h,x,u]),o.useEffect(()=>(D.current=!0,()=>{D.current=!1}),[]),o.useEffect(()=>{v.current||b.current||y.current||(w.current=t,ee("saved"))},[t]),o.useEffect(()=>{f.current+=1,v.current=null,b.current=!1,S.current=null,j.current=!1,y.current=!1,w.current=t,le(rs(e)),ee("saved")},[e]),o.useEffect(()=>{const k=L=>{!v.current&&!b.current&&!y.current&&!X.current?.()||(L.preventDefault(),L.returnValue="")};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[]),o.useEffect(()=>()=>{$(),v.current&&!y.current&&O({silent:!0})},[$,O]),{saveStatus:re,localDraft:Ee,serverUpdatedAtRef:w,hasUnsavedChanges:re!=="saved",buildDraft:ye,queueSave:te,flushPendingSave:O,restoreLocalDraft:ne,discardLocalDraft:G,clearDrafts:be,resolveConflict:De,pauseForConflict:K,getPendingDraft:Y,setServerUpdatedAt:Te}}function is(){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 h=n.current,x=()=>h===n.current?u():void 0,m=e.current.then(x,x);e.current=m.then(()=>{},()=>{});const d=()=>{t.current-=1,t.current===0&&r(!1)};return m.then(d,d),m},[]),c=o.useCallback(()=>{n.current+=1},[]),l=o.useCallback(()=>e.current,[]),p=o.useCallback(()=>t.current>0,[]);return o.useMemo(()=>({execute:i,invalidatePending:c,drain:l,isBusy:s,hasPendingWrites:p}),[l,i,p,c,s])}const cs="NOTE_UPDATE_CONFLICT",Ve=e=>{const n=ge(e);return Q(n??Number(e)).format("YYYY-MM-DD HH:mm:ss")},ls=e=>e?.extensions?.currentUpdatedAt;function ds({noteId:e,navigateToNote:n,notify:t}){const s=Ke(),r=o.useRef(null),i=o.useRef(null),[c]=o.useState(rt),l=o.useRef(c),p=o.useRef(null),u=o.useRef(null),h=o.useRef(!1),x=o.useRef(0),m=ft({queryKey:E.notes.detail(e),queryFn:async()=>{const g=await Rn(e);if(g.type==="error")throw g;return g.note},gcTime:0}),d=m.data,v=m.refetch,b=o.useRef(d.updatedAt),S=o.useRef(d.updatedAt),[j,A]=o.useState(d.title),[w,f]=o.useState(d.pinned),[y,D]=o.useState(d.layout||"wide"),F=o.useRef(y),[P,W]=o.useState(null),[ve,X]=o.useState(null),[he,re]=o.useState(0),[ee,Ee]=o.useState(()=>Ve(d.updatedAt)),[le,$]=o.useState(d.updatedAt),[B,Te]=o.useState(0),[ye,de]=o.useState(!1),ae=o.useRef(!1),{execute:O,invalidatePending:te,drain:ne,isBusy:be,hasPendingWrites:De}=is(),G=o.useCallback(g=>{F.current=g,D(g)},[]),Y=o.useCallback((g,C={})=>{b.current=g,S.current=g,Ee(Ve(g)),$(g),C.confirmSave&&Te(R=>R+1)},[]),K=o.useCallback(async({updatedAt:g,patch:C,confirmSave:R=!0})=>{const pe=E.notes.detail(e),Oe=x.current;return await s.cancelQueries({queryKey:pe,exact:!0}),Oe!==x.current?!1:(Y(g,{confirmSave:R}),s.setQueryData(pe,Be=>Be&&{...Be,...C,updatedAt:g}),yt({noteId:e,updatedAt:g,editSessionId:l.current}),!0)},[Y,e,s]),k=o.useCallback(g=>{ae.current=g,de(g)},[]),L=o.useCallback(()=>p.current?.flushPendingSave({expectedUpdatedAt:b.current})??Promise.resolve("idle"),[]),Me=os({noteId:e,initialContent:d.content,initialUpdatedAt:d.updatedAt,editSessionIdRef:l,serverVersionRef:b,executeWrite:O,getContent:()=>r.current?.getContent(),beforeSave:L,hasExternalPendingChanges:()=>ae.current||De(),onSaved:g=>{u.current=null,Y(g,{confirmSave:!0})},onConflict:g=>{W({type:"updated",updatedAt:g,source:"unknown"}),t("This note changed elsewhere. Choose how to resolve the draft.")},onError:t}),{saveStatus:se,localDraft:U,serverUpdatedAtRef:H,hasUnsavedChanges:ue,buildDraft:_,queueSave:q,flushPendingSave:V,restoreLocalDraft:z,discardLocalDraft:we,clearDrafts:Z,resolveConflict:fe,pauseForConflict:I,getPendingDraft:oe}=Me,Ce=ue||ye||be,Xe=o.useCallback(async g=>{const C=await V(g);return C==="error"||C==="conflict"||await ne(),C},[ne,V]),Zt=o.useCallback(g=>O(async()=>{const C=await An({...g,expectedUpdatedAt:b.current});return C.type==="success"&&await K({updatedAt:C.updateNoteProperties.updatedAt,patch:{properties:C.updateNoteProperties.properties}}),C}),[K,O]);ns({allowNextNavigationRef:h,hasExternalPendingChanges:ye||be,saveStatus:se,flushPendingChanges:Xe,notify:t}),o.useEffect(()=>{if(Ce){d.updatedAt!==H.current&&(Se(d.updatedAt,H.current)??0)>0&&I(d.updatedAt);return}const g=S.current;if(!(g&&d.updatedAt!==g&&(Se(d.updatedAt,g)??0)<0)&&(f(d.pinned),G(d.layout||"wide"),A(d.title),g!==d.updatedAt)){const C=r.current?.getContent();Y(d.updatedAt),(C===void 0||C!==d.content)&&(X(null),re(R=>R+1))}},[Y,Ce,d.content,d.layout,d.pinned,d.title,d.updatedAt,I,H]),o.useEffect(()=>{P?.type!=="updated"||se==="conflict"||P.updatedAt!==d.updatedAt||(Y(d.updatedAt),W(null))},[Y,P,d.updatedAt,se]),o.useEffect(()=>Ln(g=>{const C=es({event:g,noteId:e,editSessionId:l.current,loadedUpdatedAt:d.updatedAt,acceptedUpdatedAt:H.current,hasUnsavedChanges:Ce});C.type!=="ignore"&&(C.shouldPauseSave&&C.change.type==="updated"&&I(C.change.updatedAt),W(C.change))}),[Ce,d.updatedAt,e,I,H]);const Jt=o.useCallback(()=>{q(_(j))},[_,q,j]),Xt=o.useCallback(g=>{A(g),q(_(g))},[_,q]),en=o.useCallback(()=>{q(_(j),{immediate:!0})},[_,q,j]),tn=o.useCallback(async g=>{if(ue){G(g),q(_(j,{layout:g}),{immediate:!0}),t("Layout will be saved with your draft.");return}const C=await V();C==="error"||C==="conflict"||await O(async()=>{const R=await ze({id:e,layout:g,editSessionId:l.current,expectedUpdatedAt:H.current});if(R.type==="error"){R.errors[0].code===cs&&(u.current=g,G(g),I(ls(R.errors[0].details)??H.current)),t(R.errors[0].message);return}await K({updatedAt:R.updateNote.updatedAt,patch:{layout:g}})&&(u.current=null,G(g),t("Layout has been updated."))})},[K,_,O,V,ue,e,t,I,q,H,j]),nn=o.useCallback(async()=>{const g=await V();if(g==="error"||g==="conflict")return;const C=!w;await O(async()=>{const R=await kn(e,C);if(R.type==="error"){t(R.errors[0].message);return}await K({updatedAt:R.pinNote.updatedAt,patch:{pinned:C},confirmSave:!1})&&(f(C),await Promise.all([s.invalidateQueries({queryKey:E.notes.listAll(),exact:!1}),s.invalidateQueries({queryKey:E.notes.tagListAll(),exact:!1}),s.invalidateQueries({queryKey:E.notes.pinned(),exact:!0})]))})},[K,O,V,w,e,t,s]),Pe=o.useCallback(()=>({id:e,title:j,createdAt:d.createdAt,updatedAt:H.current||d.updatedAt}),[d.createdAt,d.updatedAt,e,H,j]),rn=o.useCallback(async()=>{const g=r.current?.getMarkdown();if(g===void 0){t("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(Pt(g,Pe())),t("Copied note as Markdown.")}catch{t("Failed to copy Markdown.")}},[Pe,t]),an=o.useCallback(async()=>{p.current?.invalidateInFlightSave(),te(),await ne(),x.current+=1;const g=await v();if(g.error||!g.data){t("Failed to reload the latest note state.");return}p.current?.discardPendingChanges(),Z(),u.current=null,Y(g.data.updatedAt),A(g.data.title),G(g.data.layout||"wide"),X(null),re(C=>C+1),W(null)},[Z,Y,ne,te,t,v]),sn=o.useCallback(async()=>{if(oe()){u.current=null,W(null),await V({ignoreConflict:!0});return}const C=u.current;if(!C){W(null),await V({ignoreConflict:!0});return}await O(async()=>{const R=await ze({id:e,layout:C,editSessionId:l.current,force:!0});if(R.type==="error"){t(R.errors[0].message);return}await K({updatedAt:R.updateNote.updatedAt,patch:{layout:C}})&&(u.current=null,fe(),W(null),G(C))})},[K,O,V,oe,e,t,fe]),on=o.useCallback(async()=>{const g=oe();if(!g||await L()==="error")return;const R=await En({title:et(g.title||"untitled"),content:et(g.content),layout:g.layout??y});if(R.type==="error"){t(R.errors[0].message);return}h.current=!0,u.current=null,W(null),Z(),Promise.resolve(n(R.createNote.id)).finally(()=>{h.current=!1})},[Z,L,oe,y,n,t]),cn=o.useCallback(()=>{U&&(A(U.title),U.layout&&G(U.layout),X(U.content),re(g=>g+1),z(U))},[U,z]),ln=o.useCallback(()=>{},[]),dn=o.useCallback(async g=>(p.current?.invalidateInFlightSave(),te(),await ne(),x.current+=1,O(async()=>{const C=await mt(g);if(C.type==="error")return C;const R=C.restoreNoteSnapshot;return await K({updatedAt:R.updatedAt,patch:{title:R.title,content:R.content,layout:R.layout,pinned:R.pinned}})&&(l.current=rt(),p.current?.discardPendingChanges(),Z(),u.current=null,W(null),A(R.title),G(R.layout||"wide"),f(R.pinned),X(R.content),re(Oe=>Oe+1)),C})),[K,Z,ne,O,te]),_e=se==="conflict"&&P?.type==="updated",un=_e?oe():null;return{document:{title:j,titleRef:i,isPinned:w,layout:y,getLayout:()=>F.current,properties:d.properties,createdAt:Ve(d.createdAt),onTitleChange:Xt,onLayoutSave:tn,onTogglePinned:nn},editor:{ref:r,key:`${e}:${he}`,content:ve??d.content,getContent:()=>r.current?.getContent()??"",getHtml:()=>r.current?.getHtml(),getMarkdown:()=>r.current?.getMarkdown(),onChange:Jt},save:{status:se,lastSavedAt:ee,lastSavedVersion:le,confirmationRevision:B,onManualSave:en,flushPendingChanges:Xe},recovery:{localDraftCreatedAt:U?Q(U.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,onRestoreLocalDraft:cn,onDiscardLocalDraft:we,onClonePendingDraft:on},externalChange:{value:P,isConflict:_e,hasConflictDraft:un!==null,isBlocking:ts({change:P,isConflict:_e,loadedUpdatedAt:d.updatedAt}),isReloading:m.isRefetching,onReload:an,onOverwrite:sn},properties:{ref:p,expectedUpdatedAt:H.current,editSessionId:l.current,saveProperties:Zt,onPendingChange:k,onSaved:ln},exportDocument:{metadata:Pe(),onCopyMarkdown:rn},snapshots:{restore:dn}}}const Gt=Tn(Ae),us={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},fs=a.jsx(qe,{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(Ye,{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(Hr,{noteId:e})})}function hs({noteId:e}){return a.jsx(Ye,{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(fr,{noteId:e,render:n=>n?.length?a.jsx(wt,{icon:a.jsx(Vn,{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(Dn,{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(dr,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),a.jsx(N,{as:"span",variant:"body",weight:"medium",className:"text-current",children:t.title})]})},t.id))})}):null})})}function ms({id:e}){const n=Re(),t=Gt.useNavigate(),[s,r]=o.useState(!1),[i,c]=o.useState(!1),[l,p]=o.useState(!1),u=ds({noteId:e,notify:n,navigateToNote:P=>t({to:Ae,params:{id:P}})}),{onCreate:h,onDelete:x,deleteWarningDialog:m}=Fn(),{document:d,editor:v,save:b,recovery:S,externalChange:j,properties:A,exportDocument:w,snapshots:f}=u,y=()=>t({to:Wn,search:{page:1}}),D=async()=>{const P=await b.flushPendingChanges();P==="error"||P==="conflict"||await x(e,y)},F=async()=>{const P=await b.flushPendingChanges();P==="error"||P==="conflict"||await h(d.titleRef.current?.value||"untitled",v.getContent(),d.getLayout())};return a.jsx(qe,{title:d.title,variant:"none",children:a.jsxs("main",{className:J("mx-auto",us[d.layout]),children:[a.jsx(xr,{title:d.title,titleRef:d.titleRef,isPinned:d.isPinned,createdAt:d.createdAt,saveStatus:b.status,savedAt:b.lastSavedAt,savedVersion:b.lastSavedVersion,saveConfirmationRevision:b.confirmationRevision,onTitleChange:d.onTitleChange,onCopyMarkdown:()=>{w.onCopyMarkdown()},onDownloadDocument:()=>p(!0),onTogglePinned:()=>{d.onTogglePinned()},onChangeLayout:()=>r(!0),onCloneNote:()=>{F()},onRestoreVersion:()=>c(!0),onDelete:()=>{D()},onSave:b.onManualSave}),a.jsx(Fr,{localDraftCreatedAt:S.localDraftCreatedAt,hasSaveError:b.status==="error",onRestoreDraft:S.onRestoreLocalDraft,onDiscardDraft:S.onDiscardLocalDraft,onRetrySave:b.onManualSave,onSaveAsNewNote:()=>{S.onClonePendingDraft()}}),a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx(In,{ref:A.ref,noteId:e,properties:d.properties,expectedUpdatedAt:A.expectedUpdatedAt,editSessionId:A.editSessionId,disabled:b.status!=="saved",saveProperties:A.saveProperties,onPendingChange:A.onPendingChange,onSaved:A.onSaved}),a.jsx(Xa,{ref:v.ref,content:v.content,currentNoteId:e,onChange:v.onChange},v.key),a.jsx(ps,{noteId:e}),a.jsx(hs,{noteId:e})]}),a.jsx(hr,{isOpen:s,onClose:()=>r(!1),onSave:d.onLayoutSave,currentLayout:d.layout}),a.jsx(Lr,{isOpen:j.isBlocking,isDeleted:j.value?.type==="deleted",isConflict:j.isConflict,hasDraft:j.hasConflictDraft,source:j.value?.source??"unknown",isReloading:j.isReloading,onReload:()=>{j.onReload()},onOverwrite:()=>{j.onOverwrite()},onCloneDraft:()=>{S.onClonePendingDraft()},onOpenTrash:()=>{y()}}),a.jsx(_r,{isOpen:l,metadata:w.metadata,getHtml:v.getHtml,getMarkdown:v.getMarkdown,onClose:()=>p(!1)}),a.jsx($r,{isOpen:i,noteId:e,onClose:()=>c(!1),restoreSnapshot:f.restore}),m]})})}function Ms(){const{id:e}=Gt.useParams();if(!e)throw new Error("Note id is required.");return a.jsx(Ye,{fallback:fs,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[e],renderError:({error:n,retry:t})=>a.jsx(qe,{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(ms,{id:e},e)})}export{ms as NoteContent,Ms as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";import{a4 as k,Z as h,ad as H,ah as M,aa as E,aj as w,al as S,ak as L,ac as o,ai as O}from"./note.api-D_00ZzJC.js";import{N as C,R as U}from"./url-BSnWpmJx.js";import{u as I,R as Y}from"./useReminderMutate-CLK1tHvT.js";import{M as B,i as u}from"./time-B3pt8vt4.js";const g={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function P({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")},i=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=i(t.reminderDate)==="Overdue",a=t.priority||"low",s=a==="high"?"High":a==="medium"?"Medium":"Low",p=g[a],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=i(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(B,{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 Z(){const t=R.useNavigate(),{page:l}=R.useSearch(),{onUpdate:f,onDelete:j}=I(),i=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:A.map(({label:a,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:a})]},a))});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,i],children:e.jsx(Y,{searchParams:{offset:(l-1)*i,limit:i},render:({reminders:a,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return a.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:a.map(n=>e.jsx(P,{reminder:n,onUpdate:f,onDelete:j},n.id))}),s&&i<s&&e.jsx(L,{page:l,last:Math.ceil(s/i),onChange:n=>{t({search:x=>({...x,page:n})})}})]})})}})})}export{Z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,r as N}from"./floating-ui.react-dom-wWLZ1CdM.js";import{aj as u,al as f,aa as b,Z as h,ad as w,ak as S,ai as k,ac as d}from"./note.api-D_00ZzJC.js";import{N as E,S as $}from"./url-BSnWpmJx.js";import{N as R}from"./app-cTRcKMGc.js";import"./time-B3pt8vt4.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-D9GeO71k.js";const A=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=A(r),n=new RegExp(`(${a})`,"gi"),c=new RegExp(`^${a}$`,"i"),l=t.split(n);return e.jsx("span",{children:l.map((i,o)=>c.test(i)?e.jsx("mark",{children:i},o):e.jsx(N.Fragment,{children:i},o))})},j=k($),v=180,m=t=>t.replace(/\s+/g," ").trim(),L=(t,s)=>{const r=m(t),a=m(s).toLowerCase();if(!a)return r;const n=r.toLowerCase().indexOf(a);if(n===-1)return r.length>v?`${r.slice(0,v-1).trimEnd()}…`:r;const c=Math.max(0,n-56),l=Math.min(r.length,n+a.length+84);let i=r.slice(c,l).trim();return c>0&&(i=`…${i}`),l<r.length&&(i=`${i}…`),i},T=t=>Array.isArray(t)?t.map(s=>{if(!s||typeof s!="object")return"";const r=s.text;return typeof r=="string"?r:""}).join(""):"",B=(t,s)=>t==="heading"?`Heading ${typeof s?.level=="number"?s.level:1}`:t==="bulletListItem"?"Bullet":t==="numberedListItem"?"Numbered":t==="checkListItem"?"Checklist":t==="quote"?"Quote":t==="codeBlock"?"Code":"Content",y=(t,s)=>{Array.isArray(t)&&t.forEach(r=>{if(!r||typeof r!="object")return;const a=typeof r.type=="string"?r.type:void 0,n=typeof r.props=="object"&&r.props?r.props:void 0,c=m(T(r.content));c&&s.push({label:B(a,n),text:c});const l=r.children;Array.isArray(l)&&y(l,s)})},C=(t,s)=>{try{const r=JSON.parse(t),a=[];if(y(r,a),a.length===0)return[];const n=m(s).toLowerCase(),c=n?a.filter(i=>i.text.toLowerCase().includes(n)):a;return(c.length>0?c:a).slice(0,2).map(i=>({...i,text:L(i.text,s)}))}catch{return[]}},P=t=>t===1?"1 result":`${t} results`,M=()=>"Open the note to inspect matching content.",z=(t,s)=>`${P(s)} for "${t}"`,I=()=>e.jsx(u,{title:"Search",variant:"default",description:e.jsx(d,{width:208,height:16,className:"rounded-full"}),children:e.jsx("main",{className:"flex flex-col gap-3",children:Array.from({length:2},(t,s)=>e.jsxs("div",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(d,{width:"34%",height:18,className:"rounded-full"}),e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{children:[e.jsx(d,{width:84,height:12,className:"rounded-full"}),e.jsx(d,{width:"100%",height:14,className:"mt-2 rounded-full"}),e.jsx(d,{width:"82%",height:14,className:"mt-1.5 rounded-full"})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-2",children:[e.jsx(d,{width:72,height:12,className:"rounded-full"}),e.jsx(d,{width:"94%",height:14,className:"mt-2 rounded-full"})]})]})})]},s))})});function D(){const t=j.useNavigate(),{page:s,query:r}=j.useSearch(),a=r.trim(),n=10;return a?e.jsx(b,{fallback:e.jsx(I,{}),errorTitle:"Failed to load search results",errorDescription:`Retry loading results for "${a}".`,resetKeys:[a,s],children:e.jsx(R,{searchParams:{query:a,limit:n,offset:(s-1)*n,fields:["content"]},render:({notes:c,totalCount:l})=>e.jsx(u,{title:"Search",description:z(a,l),variant:"default",children:e.jsxs("main",{className:"flex flex-col gap-4",children:[c.length>0?e.jsx("div",{className:"flex flex-col gap-3",children:c.map(i=>{const o=C(i.content,a);return e.jsxs("article",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(h,{as:"h2",variant:"body",weight:"semibold",tracking:"tight",children:e.jsx(w,{to:E,params:{id:i.id},className:"transition-colors hover:text-fg-default/85",children:e.jsx(g,{match:a,children:i.title||"Untitled"})})}),o.length>0?e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((x,p)=>e.jsxs("div",{className:p>0?"border-t border-border-subtle pt-2":void 0,children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"wider",transform:"uppercase",tone:"tertiary",children:x.label}),e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-1 leading-[1.65]",children:e.jsx(g,{match:a,children:x.text})})]},`${i.id}:${x.label}:${p}`))})}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"leading-[1.65]",children:M()})]},i.id)})}):e.jsx(f,{title:"No results found",description:"Try searching for a different word or phrase"}),l>n&&e.jsx(S,{page:s,last:Math.ceil(l/n),onChange:i=>{t({search:o=>({...o,page:i})})}})]})})})}):e.jsx(u,{title:"Search",description:"Search note titles and matching sections across your workspace",variant:"default",children:e.jsx("main",{children:e.jsx(f,{title:"Start searching",description:"Enter a keyword to look through note titles and matching content"})})})}export{D as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as f}from"./floating-ui.react-dom-wWLZ1CdM.js";import{aZ as o}from"./note.api-D_00ZzJC.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 p,j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";import{a9 as T,T as S,aj as k,Z as d,a7 as P,_ as y,a0 as x,aa as q,ad as E,ak as A,al as O,ac as o,ai as C}from"./note.api-D_00ZzJC.js";import{g as L,i as _,T as I,j as R,k as F,l as Q,F as v}from"./app-cTRcKMGc.js";import{b as B,T as D}from"./url-BSnWpmJx.js";import{f as z}from"./tag.api-CX0SE06J.js";import{f as G}from"./Graph-D9GeO71k.js";import"./time-B3pt8vt4.js";import"./preload-helper-BXl3LOEh.js";const M=s=>{const{data:h}=T({queryKey:S.tags.list(s.searchParams),async queryFn(){const t=await z({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(h)},b=C(D);function X(){const s=b.useNavigate(),{page:h,query:t,limit:l,sortBy:n,sortOrder:m}=b.useSearch(),[u,f]=p.useState(t),[,j]=L(350),i=t.trim();p.useEffect(()=>{f(t)},[t]),p.useEffect(()=>{const a=u.trim();a!==i&&j(()=>{s({search:r=>({...r,page:1,query:a})})})},[u,s,i,j]);const g=a=>{s({search:r=>({...r,...a})})},w=()=>{f(""),g({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(G,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(d,{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:u,onChange:a=>f(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"}),(u||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(_,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Items"}),e.jsx(y,{value:String(l),onValueChange:a=>{const r=Number(a);F(r)&&g({limit:r,page:1})},variant:"ghost",size:"sm",children:I.map(a=>e.jsx(x,{value:String(a),children:a===R?`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(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Sort"}),e.jsxs(y,{value:n,onValueChange:a=>g({sortBy:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(x,{value:"referenceCount",children:"Usage"}),e.jsx(x,{value:"name",children:"Name"})]}),e.jsxs(y,{value:m,onValueChange:a=>g({sortOrder:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(x,{value:"desc",children:n==="name"?"Z to A":"Most used"}),e.jsx(x,{value:"asc",children:n==="name"?"A to Z":"Least used"})]})]})]})]}),e.jsx(q,{fallback:e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(o,{width:"90px",height:"36px"}),e.jsx(o,{width:"120px",height:"36px"}),e.jsx(o,{width:"80px",height:"36px"}),e.jsx(o,{width:"100px",height:"36px"}),e.jsx(o,{width:"110px",height:"36px"}),e.jsx(o,{width:"70px",height:"36px"})]}),errorTitle:"Failed to load tags",errorDescription:"Retry loading the tag catalog",resetKeys:[h,l,i,n,m],children:e.jsx(M,{searchParams:{query:i,offset:(h-1)*l,limit:l,sortBy:n,sortOrder:m},render:({tags:a,totalCount:r})=>e.jsx(v,{fallback:e.jsx(O,{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(c=>e.jsxs(E,{to:B,params:{id:c.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(d,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:c.name}),e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"text-current/70",children:c.referenceCount})]},c.id))}),e.jsx(v,{fallback:null,children:r&&l<r&&e.jsx(A,{page:h,last:Math.ceil(r/l),onChange:c=>{s({search:N=>({...N,page:c,query:i,limit:l,sortBy:n,sortOrder:m})})}})})]})})})})]})}export{X as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";import{a9 as x,a$ as j,T as y,aa as N,aj as c,ak as T,al as P,ac as o,ai as v}from"./note.api-D_00ZzJC.js";import{F as h,n as k}from"./app-cTRcKMGc.js";import{b as w}from"./url-BSnWpmJx.js";import"./NotePropertiesPanel-2DgXEM4B.js";import{f as b}from"./time-B3pt8vt4.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-D9GeO71k.js";import"./Plus.es-CQ8wn2is.js";const q=s=>{const{data:r}=x({queryKey:y.notes.tagList(s.searchParams),async queryFn(){const t=await j({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(w);function A(){const s=g.useNavigate(),{id:r}=g.useParams(),{page:t}=g.useSearch(),i=25,{onDelete:m,onPinned:u,deleteWarningDialog:f}=b();return e.jsxs(N,{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(q,{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(P,{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(T,{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 e,j as a}from"./floating-ui.react-dom-wWLZ1CdM.js";import{f as J,d as N}from"./time-B3pt8vt4.js";import{R as P,aj as v,al as T,aa as X,ac as m,ai as Y,U as ee,a9 as S,T as o,ax as te,ak as ae,au as A,ad as se,Z as re,a8 as ne}from"./note.api-D_00ZzJC.js";import{f as ie}from"./tag.api-CX0SE06J.js";import{w as le,f as oe,x as ce,a as de,V as j,d as me,j as pe,u as F,e as ue}from"./ViewSectionDialog-Ctl_694Y.js";import{F as H,n as he}from"./app-cTRcKMGc.js";import{c as ge,V as fe}from"./url-BSnWpmJx.js";import"./NotePropertiesPanel-2DgXEM4B.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-D9GeO71k.js";import"./Plus.es-CQ8wn2is.js";const ye=new Map([["bold",e.createElement(e.Fragment,null,e.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",e.createElement(e.Fragment,null,e.createElement("path",{d:"M112,56V200L40,128Z",opacity:"0.2"}),e.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",e.createElement(e.Fragment,null,e.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",e.createElement(e.Fragment,null,e.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",e.createElement(e.Fragment,null,e.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",e.createElement(e.Fragment,null,e.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"}))]]),xe=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"}))]]),C=e.forwardRef((r,n)=>e.createElement(P,{ref:n,...r,weights:ye}));C.displayName="ArrowLeftIcon";const we=C,q=e.forwardRef((r,n)=>e.createElement(P,{ref:n,...r,weights:xe}));q.displayName="PencilLineIcon";const je=q,E=Y(ge);function ve(){const r=E.useNavigate(),n=ee(),Z=ne(),{page:p,sectionId:d}=E.useSearch(),{onDelete:R,onPinned:K,deleteWarningDialog:k}=J(),[L,g]=e.useState(!1),[f,y]=e.useState(!1),l=25,{data:s}=S({queryKey:o.views.section(d),async queryFn(){const t=await le(d);if(t.type==="error")throw t;if(!t.viewSection)throw new Error("View section not found.");return t.viewSection}}),{data:i}=S({queryKey:o.views.sectionNotes(d,{limit:l,offset:(p-1)*l}),async queryFn(){const t=await oe(d,{limit:l,offset:(p-1)*l});if(t.type==="error")throw t;return t.viewSectionNotes}}),{data:D,isPending:I}=N({queryKey:o.tags.list({limit:200}),enabled:f,async queryFn(){const t=await ie({limit:200});if(t.type==="error")throw t;return t.allTags}}),{data:$,isPending:O}=N({queryKey:o.notes.propertyKeys({limit:100}),enabled:f,async queryFn(){const t=await te({limit:100});if(t.type==="error")throw t;return t.notePropertyKeys}}),x=s.title,u=s.tagNames,Q=s.mode,w=s.propertyFilters,U=u.length>0,M=w.length>0,b=u.length>1?` · ${ce(Q)}`:"",W=U?M?`Property and tag filters${b}`:`Tag filters${b}`:M?"Property filters":"All notes",V=a.jsx(H,{fallback:null,children:i.totalCount&&l<i.totalCount&&a.jsx(ae,{page:p,last:Math.ceil(i.totalCount/l),onChange:t=>{r({search:c=>({...c,page:t})})}})}),_=D?.tags??[],z=$?.keys??[],B=async t=>{if(L)return;const c=s.sortBy===t?s.sortOrder==="asc"?"desc":"asc":t==="title"?"asc":"desc";g(!0);const h=await F(s.id,ue(s,{sortBy:t,sortOrder:c}));if(h.type==="error"){Z(h.errors[0]?.message??"Failed to update table sort."),g(!1);return}await n.invalidateQueries({queryKey:o.views.all(),exact:!1}),g(!1)},G=async t=>{const c=await F(s.id,t);if(c.type==="error"){Z(c.errors[0]?.message??"Failed to update section.");return}await n.invalidateQueries({queryKey:o.views.all(),exact:!1}),r({search:h=>({...h,page:1})}),y(!1)};return a.jsxs(a.Fragment,{children:[a.jsxs(v,{title:x,heading:i.totalCount>0?`${x} (${i.totalCount})`:x,description:a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(re,{as:"span",variant:"meta",tone:"tertiary",children:W}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[u.map(t=>a.jsx(j,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:t},t)),w.map(t=>a.jsx(j,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:me(t)},`${t.key}-${t.operator}-${t.value??""}`)),u.length===0&&w.length===0&&a.jsx(j,{className:"max-w-full border-border-subtle bg-hover-subtle text-fg-secondary",children:"All notes"})]})]}),headerRight:a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(A,{asChild:!0,variant:"ghost",size:"sm",children:a.jsxs(se,{to:fe,children:[a.jsx(we,{className:"h-4 w-4"}),"Back to Views"]})}),a.jsxs(A,{type:"button",variant:"subtle",size:"sm",onClick:()=>y(!0),children:[a.jsx(je,{className:"h-4 w-4"}),"Edit section"]})]}),children:[a.jsx(H,{fallback:a.jsx(T,{title:"No notes match this saved view",description:"Adjust this view's filters or keep writing until matching notes appear."}),children:i.notes.length>0&&s.displayType==="table"?a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx(de,{section:s,notes:i.notes,isPending:!1,isError:!1,surface:"card",onRetry:()=>{n.invalidateQueries({queryKey:o.views.sectionNotes(d,{limit:l,offset:(p-1)*l})})},onSortChange:B,isSortPending:L}),V]}):i.notes.length>0?a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx("div",{className:"grid-auto-cards grid gap-5",children:i.notes.map(t=>a.jsx(he,{...t,onPinned:()=>K(t.id,t.pinned),onDelete:()=>R(t.id)},t.id))}),V]}):null}),k]}),a.jsx(pe,{open:f,mode:"edit",initialSection:s,availableTags:_,availableProperties:z,isTagsLoading:I,isPropertiesLoading:O,onClose:()=>y(!1),onSubmit:G})]})}function Pe(){const{sectionId:r,page:n}=E.useSearch();return r?a.jsx(X,{fallback:a.jsx(v,{title:"View Notes",heading:a.jsx(m,{width:180,height:24,className:"rounded-full"}),description:a.jsx(m,{width:220,height:16,className:"rounded-full"}),children:a.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[a.jsx(m,{height:"112px"}),a.jsx(m,{height:"112px"}),a.jsx(m,{height:"112px"})]})}),errorTitle:"Failed to load view notes",errorDescription:"Retry loading notes for this saved view section",resetKeys:[n,r],children:a.jsx(ve,{})}):a.jsx(v,{title:"View Notes",description:"Saved view note lists require a section id.",children:a.jsx(T,{title:"No section selected",description:"Return to Views and open a section from there."})})}export{Pe as default};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import{a6 as g,a5 as ae,Z as d,au as T,ad as Le,at as M,a3 as f,aw as re,aH as ne,aI as R,a4 as _e,_ as N,a0 as m,aG as qe}from"./note.api-D_00ZzJC.js";import{j as e,r as h}from"./floating-ui.react-dom-wWLZ1CdM.js";import{t as ie,j as Pe}from"./time-B3pt8vt4.js";import{N as Be}from"./url-BSnWpmJx.js";const X=`
|
|
2
|
-
id
|
|
3
|
-
tabId
|
|
4
|
-
title
|
|
5
|
-
displayType
|
|
6
|
-
displayOptions {
|
|
7
|
-
tableColumns
|
|
8
|
-
}
|
|
9
|
-
tagNames
|
|
10
|
-
mode
|
|
11
|
-
propertyFilters {
|
|
12
|
-
key
|
|
13
|
-
name
|
|
14
|
-
valueType
|
|
15
|
-
operator
|
|
16
|
-
value
|
|
17
|
-
}
|
|
18
|
-
sortBy
|
|
19
|
-
sortOrder
|
|
20
|
-
limit
|
|
21
|
-
order
|
|
22
|
-
`;function nt(){return g(`query FetchViewWorkspace {
|
|
23
|
-
viewWorkspace {
|
|
24
|
-
activeTabId
|
|
25
|
-
tabs {
|
|
26
|
-
id
|
|
27
|
-
title
|
|
28
|
-
order
|
|
29
|
-
sections {
|
|
30
|
-
${X}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}`)}function it(t){return g(`query FetchViewSection($id: ID!) {
|
|
35
|
-
viewSection(id: $id) {
|
|
36
|
-
${X}
|
|
37
|
-
}
|
|
38
|
-
}`,{id:t})}function lt(t,{limit:r=25,offset:a=0}={}){return g(`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:t,pagination:{limit:r,offset:a}})}function ot(t){return g(`mutation CreateViewTab($title: String!) {
|
|
63
|
-
createViewTab(title: $title) {
|
|
64
|
-
id
|
|
65
|
-
}
|
|
66
|
-
}`,{title:t})}function dt(t,r){return g(`mutation UpdateViewTab($id: ID!, $title: String!) {
|
|
67
|
-
updateViewTab(id: $id, title: $title) {
|
|
68
|
-
id
|
|
69
|
-
}
|
|
70
|
-
}`,{id:t,title:r})}function ct(t){return g(`mutation DeleteViewTab($id: ID!) {
|
|
71
|
-
deleteViewTab(id: $id)
|
|
72
|
-
}`,{id:t})}function ut(t){return g(`mutation SetActiveViewTab($id: ID!) {
|
|
73
|
-
setActiveViewTab(id: $id) {
|
|
74
|
-
activeTabId
|
|
75
|
-
tabs {
|
|
76
|
-
id
|
|
77
|
-
title
|
|
78
|
-
order
|
|
79
|
-
sections {
|
|
80
|
-
${X}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}`,{id:t})}function pt(t){return g(`mutation ReorderViewTabs($tabIds: [ID!]!) {
|
|
85
|
-
reorderViewTabs(tabIds: $tabIds) {
|
|
86
|
-
id
|
|
87
|
-
}
|
|
88
|
-
}`,{tabIds:t})}function mt(t,r){return g(`mutation CreateViewSection($tabId: ID!, $input: ViewSectionInput!) {
|
|
89
|
-
createViewSection(tabId: $tabId, input: $input) {
|
|
90
|
-
id
|
|
91
|
-
}
|
|
92
|
-
}`,{tabId:t,input:r})}function bt(t,r){return g(`mutation UpdateViewSection($id: ID!, $input: ViewSectionInput!) {
|
|
93
|
-
updateViewSection(id: $id, input: $input) {
|
|
94
|
-
id
|
|
95
|
-
}
|
|
96
|
-
}`,{id:t,input:r})}function xt(t){return g(`mutation DeleteViewSection($id: ID!) {
|
|
97
|
-
deleteViewSection(id: $id)
|
|
98
|
-
}`,{id:t})}function ht(t,r){return g(`mutation ReorderViewSections($tabId: ID!, $sectionIds: [ID!]!) {
|
|
99
|
-
reorderViewSections(tabId: $tabId, sectionIds: $sectionIds) {
|
|
100
|
-
id
|
|
101
|
-
}
|
|
102
|
-
}`,{tabId:t,sectionIds:r})}const Me={compact:"h-[22px] px-2",regular:"h-7 px-2.5"};function W({children:t,className:r,contentClassName:a,size:n="regular",truncateContent:o=!0,...y}){return e.jsx("span",{className:ae("inline-flex min-w-0 items-center overflow-hidden whitespace-nowrap rounded-full border text-xs font-medium leading-none",Me[n],r),...y,children:o?e.jsx("span",{className:ae("min-w-0 truncate",a),children:t}):t})}const J=["title","tags","properties","createdAt","updatedAt"],gt={activeTabId:null,tabs:[]},Re=t=>{const r=t.trim();return r?r.startsWith("@")?r:r.startsWith("#")?`@${r.slice(1)}`:`@${r}`:""},fe=(t,r,a)=>{if(r===a)return t;const n=t.findIndex(b=>b.id===r),o=t.findIndex(b=>b.id===a);if(n<0||o<0)return t;const y=[...t],[$]=y.splice(n,1);return y.splice(o,0,$),y},le=t=>{const r=t.flatMap(a=>typeof a=="string"?a.split(","):[]);return Array.from(new Set(r.map(Re).filter(Boolean)))},vt=t=>t.tabs.length===0?null:t.activeTabId?t.tabs.find(r=>r.id===t.activeTabId)??t.tabs[0]??null:t.tabs[0]??null,yt=(t,r)=>t.tabs.some(a=>a.id===r)?{...t,activeTabId:r}:t,ft=(t,r,a)=>({...t,tabs:fe(t.tabs,r,a)}),jt=(t,r,a,n)=>({...t,tabs:t.tabs.map(o=>o.id===r?{...o,sections:fe(o.sections,a,n)}:o)}),oe=t=>t==="or"?"OR — any selected tag":"AND — all selected tags",wt=t=>t==="or"?"OR":"AND",je=t=>{switch(t){case"notEquals":return"is not";case"contains":return"contains";case"notContains":return"does not contain";case"before":return"before";case"after":return"after";case"exists":return"is set";case"notExists":return"is empty";default:return"is"}},We=t=>{switch(t){case"table":return"Table";case"calendar":return"Unavailable";default:return"List"}},we=t=>{switch(t){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},U=t=>{const r=new Set(J),a=(t??[]).filter(o=>r.has(o)),n=Array.from(new Set(a));return n.length===0?[...J]:n.includes("title")?n:["title",...n]},Ne=t=>({tableColumns:U(t?.tableColumns)}),Nt=t=>{const r=je(t.operator);return t.operator==="exists"||t.operator==="notExists"?`${t.name} ${r}`:`${t.name} ${r} ${t.value??""}`.trim()},Tt=(t,r={})=>{const a={...t,...r};return{title:a.title,displayType:a.displayType,displayOptions:Ne(a.displayOptions),tagNames:a.tagNames,mode:a.mode,propertyFilters:a.propertyFilters.map(n=>({key:n.key,valueType:n.valueType,operator:n.operator,value:n.value})),sortBy:a.sortBy,sortOrder:a.sortOrder,limit:a.limit}},Vt=t=>({page:1,sectionId:t.id}),Ue=t=>t.valueType==="select"?t.option?.label??t.value:t.valueType==="boolean"?t.value==="true"?"True":"False":t.value,He=t=>(t.properties??[]).slice(0,3),Te={title:280,tags:190,properties:260,createdAt:132,updatedAt:132},Ye={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",Ce="text-xs leading-5 text-fg-tertiary",Ge=t=>{const r=t.reduce((a,n)=>a+Te[n],0);return Math.max(520,r)},Ke=(t,r={})=>{if(t.tags.length===0)return r.hideEmpty?null:e.jsx("span",{className:Ce,children:"—"});const a=t.tags.slice(0,3),n=t.tags.length-a.length;return e.jsxs("div",{className:Ve,children:[a.map(o=>e.jsx(W,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:o.name},o.id)),n>0&&e.jsxs(W,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",n]})]})},Qe=(t,r={})=>{const a=He(t);if(a.length===0)return r.hideEmpty?null:e.jsx("span",{className:Ce,children:"—"});const n=(t.properties?.length??0)-a.length;return e.jsxs("div",{className:Ve,children:[a.map(o=>e.jsxs(W,{size:"compact",truncateContent:!1,className:"max-w-[190px] shrink-0 gap-1 border-border-subtle bg-subtle text-fg-secondary",children:[e.jsx("span",{className:"min-w-0 max-w-[76px] shrink truncate text-fg-tertiary",children:o.name}),e.jsx("span",{className:"min-w-0 truncate",children:Ue(o)||"—"})]},o.key)),n>0&&e.jsxs(W,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",n]})]})};function Ct({section:t,notes:r,isPending:a,isError:n,onRetry:o,onSortChange:y,isSortPending:$,surface:b="flush"}){const V=U(t.displayOptions?.tableColumns),z=Ge(V),L=b==="card"?"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated":"overflow-x-auto bg-transparent",C=b==="card"?"overflow-hidden rounded-[16px] border border-border-subtle bg-elevated":"overflow-hidden bg-transparent",I=b==="card"?"bg-elevated":"bg-transparent",F=b==="card"?"bg-subtle/65":"bg-subtle/45",_=b==="card"?"bg-elevated":"bg-transparent",E=c=>{const u=Ye[c],O=we(c),k=u?t.sortBy===u:!1;return e.jsx("th",{"aria-sort":k?t.sortOrder==="asc"?"ascending":"descending":void 0,className:"px-3 py-2.5 text-xs font-semibold text-fg-tertiary",children:u?e.jsxs("button",{type:"button",className:"focus-ring-soft -ml-1 inline-flex items-center gap-1 rounded-[8px] px-1 py-0.5 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-secondary disabled:cursor-wait disabled:opacity-60",disabled:$,onClick:()=>y(u),children:[e.jsx("span",{children:O}),e.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:k?t.sortOrder==="asc"?"↑":"↓":"↕"})]}):O},c)},S=(c,u)=>{switch(u){case"tags":return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:Ke(c)},u);case"properties":return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle",children:Qe(c)},u);case"createdAt":return e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:ie(Number(c.createdAt))})},u);case"updatedAt":return e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle",children:e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:ie(Number(c.updatedAt))})},u);default:return e.jsx("td",{className:"px-3 py-2.5 align-middle",children:e.jsx(d,{as:"div",variant:"body",weight:"semibold",className:"line-clamp-1",children:e.jsx(Le,{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 a?e.jsxs("div",{className:C,children:[e.jsx("div",{className:"h-11 animate-pulse bg-subtle/50"}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${I}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${I}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${I}`})]}):n?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:o,children:"Retry"})})]}):r.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(d,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:L,children:e.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:z},children:[e.jsx("caption",{className:"sr-only",children:"View query results as a table"}),e.jsx("colgroup",{children:V.map(c=>e.jsx("col",{style:{width:Te[c]}},c))}),e.jsx("thead",{className:F,children:e.jsx("tr",{className:"border-b border-border-subtle",children:V.map(E)})}),e.jsx("tbody",{className:_,children:r.map(c=>e.jsx("tr",{className:"h-12 border-b border-border-subtle/70 last:border-b-0",children:V.map(u=>S(c,u))},c.id))})]})})}const Q="__choose_property__",Ze=["title","tags","properties","createdAt","updatedAt"],de=t=>String(t?.limit??5),ce=t=>t?.displayType==="table"?"table":"list",ue=t=>U(t?.displayOptions?.tableColumns??J),pe=t=>t?.mode??"and",me=t=>t?t.tagNames.join(", "):"",be=t=>t?.title??"",xe=t=>t?.sortBy??"updatedAt",he=t=>t?.sortOrder??"desc",Ie=t=>`property-filter-${Date.now()}-${t}`,ge=t=>(t?.propertyFilters??[]).map((r,a)=>({id:Ie(a),key:r.key,operator:r.operator,value:r.value??""})),ve=t=>t?t.valueType==="date"||t.valueType==="number"?["equals","notEquals","before","after","exists","notExists"]:t.valueType==="text"||t.valueType==="url"?["equals","notEquals","contains","notContains","exists","notExists"]:["equals","notEquals","exists","notExists"]:["exists","notExists"],ye=t=>t?"equals":"exists",Je=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",Z=t=>t!=="exists"&&t!=="notExists",Se=t=>t==="contains"||t==="notContains",Xe=(t,r)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!Se(r)?"url":"text",et=(t,r)=>{if(t.valueType==="url")return Se(r)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function It({open:t,mode:r,initialSection:a=null,availableTags:n,availableProperties:o,isTagsLoading:y=!1,isPropertiesLoading:$=!1,onClose:b,onSubmit:V}){const[z,L]=h.useState(be(a)),[C,I]=h.useState(ce(a)),[F,_]=h.useState(ue(a)),[E,S]=h.useState(me(a)),[c,u]=h.useState(pe(a)),[O,k]=h.useState(xe(a)),[ee,te]=h.useState(he(a)),[H,se]=h.useState(de(a)),[A,q]=h.useState(ge(a)),[Ae,Y]=h.useState((a?.tagNames.length??0)>0),[G,x]=h.useState(""),P=h.useMemo(()=>new Map(o.map(s=>[s.key,s])),[o]);h.useEffect(()=>{t&&(L(be(a)),I(ce(a)),_(ue(a)),S(me(a)),u(pe(a)),k(xe(a)),te(he(a)),se(de(a)),q(ge(a)),Y((a?.tagNames.length??0)>0),x(""))},[a,t]);const j=le([E]),B=Ae||j.length>0,$e=j.length===0&&A.length===0,Fe=s=>{s!=="title"&&(_(l=>{if(l.includes(s)){const v=l.filter(i=>i!==s);return v.length>0?v:l}return U([...l,s])}),x(""))},Ee=s=>{const l=j.includes(s)?j.filter(v=>v!==s):[...j,s];S(l.join(", ")),x("")},Oe=()=>{Y(!0),x("")},ke=()=>{S(""),u("and"),Y(!1),x("")},De=()=>{if(o.length===0){x("Create a shared property before adding a filter.");return}q(s=>[...s,{id:Ie(s.length),key:"",operator:"exists",value:""}]),x("")},D=(s,l)=>{q(v=>v.map(i=>{if(i.id!==s)return i;const w={...i,...l},p=P.get(w.key);return ve(p).includes(w.operator)||(w.operator=ye(p)),"key"in l&&(w.value=Je(p),w.operator=ye(p)),w})),x("")},ze=s=>{q(l=>l.filter(v=>v.id!==s)),x("")};return e.jsxs(M,{isOpen:t,onClose:b,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(M.Header,{title:r==="create"?"Create section":"Edit section",onClose:b}),e.jsx(M.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:s=>{s.preventDefault();const l=le([E]);if(B&&l.length===0){x("Choose at least one tag, or remove this tag filter.");return}if(A.find(p=>!p.key||!P.has(p.key))){x("Choose a property for every filter.");return}const i=A.map(p=>{const K=P.get(p.key);return{key:K?.key??p.key,valueType:K?.valueType??"text",operator:p.operator,value:Z(p.operator)?p.value:null}});if(i.some(p=>Z(p.operator)&&!p.value?.trim())){x("Fill every filter value, or switch it to is set / is empty.");return}V({title:z,displayType:C,displayOptions:Ne({tableColumns:F}),tagNames:l,mode:c,propertyFilters:i,sortBy:O,sortOrder:ee,limit:Number(H)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(f,{htmlFor:"view-section-title",size:"md",children:"Section name"}),e.jsx(re,{id:"view-section-title",value:z,onChange:s=>L(s.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(f,{size:"md",children:"Display"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same query as a compact list or a table."})]}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:We(C)})]}),e.jsxs(ne,{type:"single",value:C,onValueChange:s=>{(s==="list"||s==="table")&&I(s)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(R,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(R,{value:"table","aria-label":"Show as table",children:"Table"})]}),C==="table"?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/45 p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(f,{size:"sm",children:"Table columns"}),e.jsxs(d,{as:"span",variant:"meta",tone:"tertiary",children:[F.length," shown"]})]}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:Ze.map(s=>{const l=we(s);return e.jsxs("div",{className:"flex items-center gap-2 rounded-[12px] border border-border-subtle bg-elevated px-3 py-2",children:[e.jsx(_e,{size:"sm",checked:F.includes(s),disabled:s==="title","aria-label":`Show ${l} column`,onChange:()=>Fe(s)}),e.jsx(d,{as:"span",variant:"label",tone:"secondary",children:l})]},s)})}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."})]}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 rounded-[20px] border border-border-subtle bg-subtle/40 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(f,{size:"md",children:"Filters"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Use properties for structured fields, and tags for loose topics or context."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(T,{type:"button",variant:"subtle",size:"sm",onClick:De,children:"Add property filter"}),!B&&e.jsx(T,{type:"button",variant:"subtle",size:"sm",onClick:Oe,children:"Add tag filter"})]})]}),A.length===0&&!B?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(d,{as:"p",variant:"label",tone:"default",children:$e?"All notes":"No filters"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add a property filter, a tag filter, or leave this view open to all notes."})]}):null,A.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:A.map(s=>{const l=P.get(s.key),v=ve(l);return e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-border-subtle bg-elevated p-3 md:grid-cols-[minmax(0,1fr)_minmax(10.5rem,12rem)_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs(N,{value:s.key||Q,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:i=>{i!==Q&&D(s.id,{key:i})},children:[e.jsx(m,{value:Q,disabled:!0,children:"Choose property"}),o.map(i=>e.jsx(m,{value:i.key,children:i.name},i.key))]}),e.jsx(N,{value:s.operator,disabled:!l,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:i=>D(s.id,{operator:i}),children:v.map(i=>e.jsx(m,{value:i,children:je(i)},i))}),Z(s.operator)&&l?l.valueType==="select"?e.jsx(N,{value:s.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:i=>D(s.id,{value:i}),children:l.options.map(i=>e.jsx(m,{value:i.value,children:i.label},i.value))}):l.valueType==="boolean"?e.jsxs(N,{value:s.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:i=>D(s.id,{value:i}),children:[e.jsx(m,{value:"true",children:"True"}),e.jsx(m,{value:"false",children:"False"})]}):e.jsx(re,{type:Xe(l,s.operator),value:s.value,onChange:i=>D(s.id,{value:i.target.value}),placeholder:et(l,s.operator),"aria-label":"Property filter value"}):e.jsx(d,{as:"span",variant:"label",tone:"tertiary",children:l?"No value needed":"Choose a property first"}),e.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:()=>ze(s.id),children:"Remove"})]},s.id)})}):null,B?e.jsxs("div",{className:"flex flex-col gap-3 rounded-[16px] border border-border-subtle bg-elevated p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(d,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:ke,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(f,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(qe,{id:"view-section-tags",value:E,onChange:s=>{S(s.target.value),x("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"You can use tags only, properties only, both together, or no filters."})]}),j.length>1?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(f,{size:"sm",children:"Tag match"}),e.jsxs(ne,{type:"single",value:c,onValueChange:s=>{(s==="and"||s==="or")&&u(s)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(R,{value:"and","aria-label":oe("and"),children:"AND"}),e.jsx(R,{value:"or","aria-label":oe("or"),children:"OR"})]}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"AND requires every selected tag. OR accepts any selected tag."})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(f,{size:"sm",children:"Existing tags"}),e.jsx(d,{as:"span",variant:"meta",tone:"tertiary",children:y?"Loading...":`${n.length} available`})]}),n.length>0?e.jsx("div",{className:"max-h-44 overflow-y-auto rounded-[16px] border border-border-subtle bg-hover-subtle/60 p-3",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(s=>{const l=j.includes(s.name);return e.jsx("button",{type:"button",className:`inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${l?"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":l,onClick:()=>Ee(s.name),children:s.name},s.id)})})}):e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(d,{as:"p",variant:"meta",tone:G?"default":"tertiary",className:G?"text-fg-error":void 0,children:G||($||y?"Loading filter options...":`${o.length} properties · ${n.length} tags available`)})]}),e.jsxs("details",{className:"group rounded-[18px] border border-border-subtle bg-elevated px-4 py-3",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(d,{as:"span",variant:"label",tone:"default",children:"Sort and limit"}),e.jsx(d,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Controls how many matching notes appear on the Views page preview."})]}),e.jsxs(d,{as:"span",variant:"meta",tone:"tertiary",children:[H," notes"]})]})}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(f,{id:"view-section-sort-by-label",htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(N,{id:"view-section-sort-by",value:O,"aria-labelledby":"view-section-sort-by-label",onValueChange:s=>k(s),children:[e.jsx(m,{value:"updatedAt",children:"Updated time"}),e.jsx(m,{value:"createdAt",children:"Created time"}),e.jsx(m,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(f,{id:"view-section-sort-order-label",htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(N,{id:"view-section-sort-order",value:ee,"aria-labelledby":"view-section-sort-order-label",onValueChange:s=>te(s),children:[e.jsx(m,{value:"desc",children:"Descending"}),e.jsx(m,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(f,{id:"view-section-limit-label",htmlFor:"view-section-limit",size:"sm",children:"Preview rows"}),e.jsxs(N,{id:"view-section-limit",value:H,"aria-labelledby":"view-section-limit-label",onValueChange:se,children:[e.jsx(m,{value:"3",children:"3 rows"}),e.jsx(m,{value:"5",children:"5 rows"}),e.jsx(m,{value:"8",children:"8 rows"}),e.jsx(m,{value:"10",children:"10 rows"}),e.jsx(m,{value:"12",children:"12 rows"})]})]})]})]})]})}),e.jsx(M.Footer,{children:e.jsxs(Pe,{children:[e.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),e.jsx(T,{type:"submit",size:"sm",form:"view-section-form",children:r==="create"?"Create section":"Save section"})]})})]})}export{gt as E,W as V,Ct as a,Vt as b,We as c,Nt as d,Tt as e,lt as f,wt as g,nt as h,vt as i,It as j,pt as k,ut as l,jt as m,ht as n,ot as o,dt as p,ct as q,ft as r,yt as s,mt as t,bt as u,xt as v,it as w,oe as x};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,r as C}from"./floating-ui.react-dom-wWLZ1CdM.js";import{u as Q,b as K,M as ue,D as U,r as xe,c as B,S as H,h as he,d as G,C as Y,e as be,K as fe,P as ge,f as we,v as ye,m as ve}from"./app-cTRcKMGc.js";import{t as je,d as R,M as Z,j as Ne,u as Se}from"./time-B3pt8vt4.js";import{Z as u,au as v,ad as z,U as J,T as b,ah as X,a8 as ee,a5 as L,at as D,a3 as ke,aw as Te,ax as Ce,aj as Ve,ac as P,al as $}from"./note.api-D_00ZzJC.js";import{f as De}from"./tag.api-CX0SE06J.js";import{V as S,a as Re,b as Ee,f as qe,g as We,c as Ae,d as Fe,u as te,e as se,h as Pe,i as Ke,E as ze,j as Le,r as Ie,k as Oe,s as $e,l as Me,m as _e,n as Qe,o as Ue,p as Be,q as He,t as M,v as Ge}from"./ViewSectionDialog-Ctl_694Y.js";import{S as I}from"./SurfaceCard-BZm73nyS.js";import{N as Ye,c as _}from"./url-BSnWpmJx.js";import{s as Ze}from"./ArrowRight.es-g2YZTklZ.js";import{n as O}from"./Plus.es-CQ8wn2is.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-D9GeO71k.js";const Je="group flex min-h-[64px] items-start justify-between gap-3 px-3 py-2.5 transition-colors hover:bg-hover-subtle",Xe=s=>{const a=s.tags.slice(0,2),n=s.tags.length-a.length;return a.length===0?null:e.jsxs(e.Fragment,{children:[a.map(o=>e.jsx(S,{size:"compact",className:"max-w-[116px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:o.name},o.id)),n>0&&e.jsxs(S,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",n]})]})};function et({notes:s,isPending:a,isError:n,onRetry:o}){return a?e.jsxs("div",{className:"overflow-hidden bg-transparent",children:[e.jsx("div",{className:"h-[64px] animate-pulse bg-subtle/35"}),e.jsx("div",{className:"h-[64px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"}),e.jsx("div",{className:"h-[64px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"})]}):n?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(u,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(u,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:o,children:"Retry"})})]}):s.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(u,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(u,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:"divide-y divide-border-subtle/70 bg-transparent",children:s.map(i=>e.jsxs(z,{to:Ye,params:{id:i.id},className:Je,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(u,{as:"div",variant:"body",weight:"semibold",className:"line-clamp-1",children:i.title||"Untitled"}),e.jsxs("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsxs(u,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"mr-0.5",children:["Updated ",je(Number(i.updatedAt))]}),Xe(i)]})]}),e.jsx(Ze,{className:"mt-0.5 h-4 w-4 shrink-0 text-fg-tertiary transition-transform group-hover:translate-x-0.5"})]},i.id))})}function tt({onEdit:s}){return e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(u,{as:"p",variant:"body",weight:"semibold",children:"This display type is unavailable"}),e.jsx(u,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Switch this section to List or Table to preview the saved query here."}),e.jsx("div",{className:"mt-3",children:e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:s,children:"Change display"})})]})}function st({section:s,notes:a,isPending:n,isError:o,onRetry:i,onEdit:d,onSortChange:l,isSortPending:p}){return s.displayType==="table"?e.jsx(Re,{section:s,notes:a,isPending:n,isError:o,onRetry:i,onSortChange:l,isSortPending:p}):s.displayType==="calendar"?e.jsx(tt,{onEdit:d}):e.jsx(et,{notes:a,isPending:n,isError:o,onRetry:i})}function at({section:s,onEdit:a,onDuplicate:n,onDelete:o,dragHandle:i}){const d=J(),l=ee(),[p,f]=C.useState(!1),g=Ee(s),{data:j,isPending:w,isError:c,refetch:E}=R({queryKey:b.views.sectionNotes(s.id,{limit:s.limit,offset:0}),async queryFn(){const m=await qe(s.id,{limit:s.limit,offset:0});if(m.type==="error")throw m;return m.viewSectionNotes}}),V=j?.notes??[],q=j?.totalCount??0,W=We(s.mode),A=s.tagNames.length>0||s.propertyFilters.length>0,F=async m=>{if(p)return;const h=s.sortBy===m?s.sortOrder==="asc"?"desc":"asc":m==="title"?"asc":"desc";f(!0);const x=await te(s.id,se(s,{sortBy:m,sortOrder:h}));if(x.type==="error"){l(x.errors[0]?.message??"Failed to update table sort."),f(!1);return}await d.invalidateQueries({queryKey:b.views.all(),exact:!1}),f(!1)};return e.jsxs(I,{flush:!0,className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border-subtle/75 px-4 py-3.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[i&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:i}),e.jsx("div",{className:"min-w-0",children:e.jsx(u,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx(z,{to:_,search:g,className:"truncate hover:text-fg-default/85",children:s.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(S,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:Ae(s.displayType)}),s.tagNames.map((m,h)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[h>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:W}),e.jsx(S,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:m})]},m)),s.propertyFilters.map(m=>e.jsx(S,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:Fe(m)},`${m.key}-${m.operator}-${m.value??""}`)),!A&&e.jsx(S,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx(X,{button:e.jsx(Z,{label:"Section actions"}),items:[{name:"Edit section",onClick:a},{name:"Duplicate section",onClick:n},{type:"separator"},{name:"Delete section",onClick:o}]})]}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx(st,{section:s,notes:V,isPending:w,isError:c,onRetry:()=>{E()},onEdit:a,onSortChange:F,isSortPending:p})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle/75 px-4 py-3",children:[e.jsx(u,{as:"p",variant:"meta",tone:"tertiary",children:w?"Loading notes...":`Showing ${V.length} of ${q} notes`}),e.jsx(v,{asChild:!0,variant:"subtle",size:"sm",children:e.jsx(z,{to:_,search:g,children:"Open results"})})]})]})}const rt="group flex h-10 max-w-[72vw] shrink-0 items-center rounded-[12px] border transition-[background-color,border-color,color,box-shadow] sm:max-w-[176px]",it="focus-ring-soft inline-flex h-full min-w-0 flex-1 touch-pan-x items-center gap-1 rounded-[11px] px-3 text-[13px] font-medium outline-none transition-colors";function nt({tab:s,isActive:a,onSelect:n}){const{attributes:o,listeners:i,setNodeRef:d,setActivatorNodeRef:l,transform:p,transition:f,isDragging:g}=G({id:s.id});return e.jsx("div",{ref:d,style:{transform:Y.Translate.toString(p),transition:f,opacity:g?.6:1},className:L(rt,a?"border-border-secondary/80 bg-elevated text-fg-default shadow-[0_8px_18px_-18px_rgba(15,18,24,0.28)]":"border-transparent bg-transparent text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default"),children:e.jsxs("button",{type:"button",ref:l,...o,...i,role:"tab","aria-selected":a,title:`${s.title}. Drag to reorder.`,className:L(it,a?"text-fg-default":"text-fg-secondary group-hover:text-fg-default",g?"cursor-grabbing":"cursor-pointer"),onClick:n,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:s.title}),e.jsx("span",{className:"inline-flex min-w-4 shrink-0 items-center justify-center rounded-full bg-hover-subtle/75 px-1 py-0 text-[10px] leading-4 text-current/70",children:s.sections.length})]})})}function ot({tabs:s,activeTabId:a,onSelectTab:n,onReorderTabs:o,onCreateTab:i}){const d=Q(K(ue,{activationConstraint:{distance:8}}));return e.jsx("div",{className:"-mx-1 rounded-[16px] border border-border-subtle/75 bg-subtle/50 p-1 sm:mx-0",children:e.jsx(U,{sensors:d,collisionDetection:B,modifiers:[xe],autoScroll:!1,onDragEnd:l=>{o(l)},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(H,{items:s.map(l=>l.id),strategy:he,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden",children:s.map(l=>e.jsx(nt,{tab:l,isActive:l.id===a,onSelect:()=>{n(l)}},l.id))})}),e.jsxs(v,{type:"button","aria-label":"New view tab",variant:"ghost",size:"sm",className:"h-10 w-10 shrink-0 rounded-[12px] border-transparent bg-transparent px-0 text-[13px] text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default sm:w-auto sm:px-2.5",onClick:i,children:[e.jsx(O,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:"New view tab"})]})]})})})}function lt({open:s,mode:a,initialTitle:n="",onClose:o,onSubmit:i}){const[d,l]=C.useState(n);return C.useEffect(()=>{s&&l(n)},[n,s]),e.jsxs(D,{isOpen:s,onClose:o,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(D.Header,{title:a==="create"?"Create view tab":"Rename view tab",onClose:o}),e.jsx(D.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:p=>{p.preventDefault(),i(d)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ke,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(Te,{id:"view-tab-title",value:d,onChange:p=>l(p.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(u,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(D.Footer,{children:e.jsxs(Ne,{children:[e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),e.jsx(v,{type:"submit",size:"sm",form:"view-tab-form",children:a==="create"?"Create tab":"Save tab"})]})})]})}const ct="Save reusable note queries with tags, shared properties, and sorting.",dt="focus-ring-soft hidden h-8 w-8 items-center justify-center rounded-[10px] text-fg-default/70 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default sm:inline-flex touch-none",mt=({section:s,onEdit:a,onDuplicate:n,onDelete:o})=>{const{attributes:i,listeners:d,setNodeRef:l,setActivatorNodeRef:p,transform:f,transition:g,isDragging:j}=G({id:s.id});return e.jsx("div",{ref:l,style:{transform:Y.Translate.toString(f),transition:g,opacity:j?.6:1},children:e.jsx(at,{section:s,onEdit:a,onDuplicate:n,onDelete:o,dragHandle:e.jsx("button",{type:"button",ref:p,"aria-label":`Reorder section ${s.title}`,...i,...d,className:L(dt,j?"cursor-grabbing":"cursor-grab"),children:e.jsx(ve,{className:"size-4"})})})})};function St(){const s=Se(),a=ee(),n=J(),[o,i]=C.useState(null),[d,l]=C.useState(null),{data:p,isPending:f,isError:g,refetch:j}=R({queryKey:b.views.workspace(),async queryFn(){const t=await Pe();if(t.type==="error")throw t;return t.viewWorkspace}}),w=p??ze,c=Ke(w),{data:E,isPending:V}=R({queryKey:b.tags.list({limit:200}),async queryFn(){const t=await De({limit:200});if(t.type==="error")throw t;return t.allTags}}),q=Q(K(ge,{activationConstraint:{distance:8}}),K(fe,{coordinateGetter:be})),W=E?.tags??[],{data:A,isPending:F}=R({queryKey:b.notes.propertyKeys({limit:100}),async queryFn(){const t=await Ce({limit:100});if(t.type==="error")throw t;return t.notePropertyKeys}}),m=A?.keys??[],h=t=>{n.setQueryData(b.views.workspace(),t)},x=async()=>{await n.invalidateQueries({queryKey:b.views.all(),exact:!1})},ae=async({active:t,over:r})=>{if(!r||t.id===r.id)return;const N=n.getQueryData(b.views.workspace())??w,y=Ie(N,String(t.id),String(r.id));h(y);const k=await Oe(y.tabs.map(T=>T.id));if(k.type==="error"){h(N),a(k.errors[0].message);return}await x()},re=async t=>{const r=n.getQueryData(b.views.workspace())??w,N=$e(r,t.id);h(N);const y=await Me(t.id);if(y.type==="error"){h(r),a(y.errors[0].message);return}h(y.setActiveViewTab)},ie=async({active:t,over:r})=>{if(!c||!r||t.id===r.id)return;const N=n.getQueryData(b.views.workspace())??w,y=_e(N,c.id,String(t.id),String(r.id));h(y);const k=await Qe(c.id,y.tabs.find(T=>T.id===c.id)?.sections.map(T=>T.id)??[]);if(k.type==="error"){h(N),a(k.errors[0].message);return}await x()},ne=async t=>{const r=await Ue(t);if(r.type==="error"){a(r.errors[0].message);return}await x(),i(null)},oe=async t=>{if(!c)return;const r=await Be(c.id,t);if(r.type==="error"){a(r.errors[0].message);return}await x(),i(null)},le=async()=>{if(!c||!await s("Delete this view tab and all of its sections?"))return;const t=await He(c.id);if(t.type==="error"){a(t.errors[0].message);return}await x()},ce=async t=>{if(!c)return;const r=await M(c.id,t);if(r.type==="error"){a(r.errors[0].message);return}await x(),l(null)},de=async t=>{if(!c||!d||d.mode!=="edit")return;const r=await te(d.section.id,t);if(r.type==="error"){a(r.errors[0].message);return}await x(),l(null)},me=async t=>{const r=await M(t.tabId,{...se(t),title:`${t.title} copy`});if(r.type==="error"){a(r.errors[0].message);return}await x(),a("Section duplicated.")},pe=async t=>{if(!c||!await s("Delete this section from the current view tab?"))return;const r=await Ge(t);if(r.type==="error"){a(r.errors[0].message);return}await x()};return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{title:"Views",description:ct,children:f&&!p?e.jsx(I,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(P,{height:20,width:180,className:"rounded-full"}),e.jsx(P,{height:16,width:260,className:"rounded-full"}),e.jsx(P,{height:44,width:140,className:"rounded-[12px]"})]})}):g?e.jsxs(I,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(u,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(u,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry loading your saved view tabs."}),e.jsx("div",{className:"mt-4",children:e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>{j()},children:"Retry"})})]}):w.tabs.length===0?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx($,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both.",className:"h-[320px]"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(v,{type:"button",onClick:()=>i({mode:"create"}),children:[e.jsx(O,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(ot,{tabs:w.tabs,activeTabId:c?.id??null,onSelectTab:re,onReorderTabs:ae,onCreateTab:()=>i({mode:"create"})}),c&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/80 px-1 pb-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(u,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",truncate:!0,children:c.title}),e.jsx(u,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:c.sections.length>0?`${c.sections.length} section${c.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"inline-flex flex-wrap items-center gap-2 self-start sm:self-center",children:[e.jsxs(v,{type:"button",size:"sm",onClick:()=>l({mode:"create"}),children:[e.jsx(O,{className:"h-4 w-4"}),"Add section"]}),e.jsx(X,{button:e.jsx(Z,{label:"View tab actions"}),items:[{name:"Rename tab",onClick:()=>i({mode:"edit",tab:c})},{type:"separator"},{name:"Delete tab",onClick:()=>{le()}}]})]})]}),c.sections.length===0?e.jsx($,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both.",className:"h-[300px]"}):e.jsx("div",{className:"flex flex-col",children:e.jsx(U,{sensors:q,collisionDetection:B,modifiers:[we],onDragEnd:ie,children:e.jsx(H,{items:c.sections.map(t=>t.id),strategy:ye,children:e.jsx("div",{className:"flex flex-col gap-4",children:c.sections.map(t=>e.jsx(mt,{section:t,onEdit:()=>l({mode:"edit",section:t}),onDuplicate:()=>{me(t)},onDelete:()=>{pe(t.id)}},t.id))})})})})]})]})}),e.jsx(lt,{open:o!==null,mode:o?.mode??"create",initialTitle:o?.mode==="edit"?o.tab.title:"",onClose:()=>i(null),onSubmit:t=>{if(o?.mode==="edit"){oe(t);return}ne(t)}}),e.jsx(Le,{open:d!==null,mode:d?.mode??"create",initialSection:d?.mode==="edit"?d.section:null,availableTags:W,availableProperties:m,isTagsLoading:V,isPropertiesLoading:F,onClose:()=>l(null),onSubmit:t=>{if(d?.mode==="edit"){de(t);return}ce(t)}})]})}export{St as default};
|