ocean-brain 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/server/client/dist/assets/{Calendar-BytW4PeT.js → Calendar-DbPut8EU.js} +1 -1
  3. package/server/client/dist/assets/{Callout-9sJgGNRb.js → Callout-DfX-gIUB.js} +1 -1
  4. package/server/client/dist/assets/{Graph-o5u-NzrA.js → Graph-yHE9m5fy.js} +1 -1
  5. package/server/client/dist/assets/{Image-DxWhlIDG.js → Image-DK0lnaK2.js} +1 -1
  6. package/server/client/dist/assets/{Image.es-B0LL3pb7.js → Image.es-CtMc7BW4.js} +1 -1
  7. package/server/client/dist/assets/{Note-CYoYzZNu.js → Note-BECn-AoI.js} +2 -2
  8. package/server/client/dist/assets/{Plus.es-DpxzgRtY.js → Plus.es-BGVIIQtM.js} +1 -1
  9. package/server/client/dist/assets/{Reminders-DAepTZg1.js → Reminders-CvEJf0eQ.js} +1 -1
  10. package/server/client/dist/assets/{Search-6KH7An44.js → Search-CKZhztuV.js} +1 -1
  11. package/server/client/dist/assets/{SurfaceCard-EMs50xSF.js → SurfaceCard-Bnfo5EOl.js} +1 -1
  12. package/server/client/dist/assets/Tag-C4oAwjs0.js +1 -0
  13. package/server/client/dist/assets/{TagNotes-BTbu-f6v.js → TagNotes-Rl1ZSJP6.js} +1 -1
  14. package/server/client/dist/assets/{Trash.es-C5x35NKF.js → Trash.es-BcwUz2yM.js} +1 -1
  15. package/server/client/dist/assets/ViewNotes-B9Yc0A87.js +1 -0
  16. package/server/client/dist/assets/ViewSectionTableRenderer-C5yJBO7C.js +102 -0
  17. package/server/client/dist/assets/Views-Bqq0pUEE.js +1 -0
  18. package/server/client/dist/assets/{image.api-DRhRQ0Gf.js → image.api-CuGTgzyQ.js} +1 -1
  19. package/server/client/dist/assets/{index-DYlYUrjH.js → index-B43ulIPo.js} +40 -40
  20. package/server/client/dist/assets/{index-DswSFFMb.js → index-BQDR6hIA.js} +1 -1
  21. package/server/client/dist/assets/{index-Cd81UxEh.css → index-CDjYEIVf.css} +1 -1
  22. package/server/client/dist/assets/manage-image-Bs4Kmevx.js +1 -0
  23. package/server/client/dist/assets/{manage-image-detail-CJkfybR9.js → manage-image-detail-WARala-v.js} +1 -1
  24. package/server/client/dist/assets/{mcp-piouFDNm.js → mcp-C0Z3vKBa.js} +1 -1
  25. package/server/client/dist/assets/{note-core-Z6kqulGB.js → note-core-DMZcZ4yV.js} +53 -53
  26. package/server/client/dist/assets/{note-vendor-i1M2FSI2.js → note-vendor-uuJO2MTD.js} +1 -1
  27. package/server/client/dist/assets/{placeholder-DGz3CHej.js → placeholder-D080guzn.js} +3 -3
  28. package/server/client/dist/assets/{properties-CM4khczg.js → properties-DbnmfbT5.js} +1 -1
  29. package/server/client/dist/assets/trash-D5ZiZfTk.js +1 -0
  30. package/server/client/dist/assets/{useReminderMutate-DHjDDHKg.js → useReminderMutate-h7d_S_X2.js} +2 -2
  31. package/server/client/dist/index.html +4 -4
  32. package/server/dist/features/note/services/markdown-intent-write.js +17 -0
  33. package/server/dist/features/note/services/markdown-intent-write.js.map +1 -1
  34. package/server/dist/features/note/services/markdown-patch.js.map +1 -1
  35. package/server/dist/features/view/graphql/view.type-defs.js +22 -0
  36. package/server/dist/features/view/graphql/view.type-defs.js.map +1 -1
  37. package/server/dist/features/view/services/workspace.js +77 -16
  38. package/server/dist/features/view/services/workspace.js.map +1 -1
  39. package/server/dist/modules/blocknote.js +320 -5
  40. package/server/dist/modules/blocknote.js.map +1 -1
  41. package/server/prisma/schema.prisma +1 -0
  42. package/server/client/dist/assets/Tag-C89j8x56.js +0 -1
  43. package/server/client/dist/assets/ViewNotes-DPEuki3y.js +0 -1
  44. package/server/client/dist/assets/Views-BGkuNhVd.js +0 -1
  45. package/server/client/dist/assets/manage-image-C6sHhWnI.js +0 -1
  46. package/server/client/dist/assets/trash-C2lItz-b.js +0 -1
  47. package/server/client/dist/assets/view-dashboard-C17WsdL7.js +0 -99
@@ -1,4 +1,4 @@
1
- import{r as Tc,g as Vy,a as x,R as Rc,N as Ve}from"./graph-vendor-CUxe67Lr.js";import{a as kC,f as VC,P as BC,b as $C,y as UC,g as GC,c as bm,D as Rd,d as ZC,M as PC,m as qC,e as YC,H as XC,N as IC,i as QC,h as FC,L as KC,A as JC,B as WC,_ as Eo,j as ht,k as kt,l as Ys,n as Wa,p as e4,o as Hl,q as Ke,r as Mc,S as ei,T as t4,s as Oc,t as Qn,I as xm,u as Pv,C as n4,v as o4,w as By,x as $y,z as Uy,E as l4,F as r4,R as ti,G as a4,J as i4,K as s4,O as c4,Q as Gy,U as u4,V as f4,W as qv,X as d4,Y as m4,Z as p4,$ as h4,a0 as g4,a1 as we,a2 as Sm}from"./note-core-Z6kqulGB.js";var Md={exports:{}},qa={};var Yv;function v4(){if(Yv)return qa;Yv=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(a,s,c){var u=null;if(c!==void 0&&(u=""+c),s.key!==void 0&&(u=""+s.key),"key"in s){c={};for(var f in s)f!=="key"&&(c[f]=s[f])}else c=s;return s=c.ref,{$$typeof:t,type:a,key:u,ref:s!==void 0?s:null,props:c}}return qa.Fragment=o,qa.jsx=r,qa.jsxs=r,qa}var Xv;function y4(){return Xv||(Xv=1,Md.exports=v4()),Md.exports}var y=y4(),Od={exports:{}},Ya={},jd={exports:{}},_d={};var Iv;function b4(){return Iv||(Iv=1,(function(t){function o(z,L){var _=z.length;z.push(L);e:for(;0<_;){var Z=_-1>>>1,I=z[Z];if(0<s(I,L))z[Z]=L,z[_]=I,_=Z;else break e}}function r(z){return z.length===0?null:z[0]}function a(z){if(z.length===0)return null;var L=z[0],_=z.pop();if(_!==L){z[0]=_;e:for(var Z=0,I=z.length,ae=I>>>1;Z<ae;){var ne=2*(Z+1)-1,re=z[ne],ve=ne+1,se=z[ve];if(0>s(re,_))ve<I&&0>s(se,re)?(z[Z]=se,z[ve]=_,Z=ve):(z[Z]=re,z[ne]=_,Z=ne);else if(ve<I&&0>s(se,_))z[Z]=se,z[ve]=_,Z=ve;else break e}}return L}function s(z,L){var _=z.sortIndex-L.sortIndex;return _!==0?_:z.id-L.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();t.unstable_now=function(){return u.now()-f}}var m=[],h=[],g=1,v=null,b=3,C=!1,E=!1,w=!1,T=!1,M=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function N(z){for(var L=r(h);L!==null;){if(L.callback===null)a(h);else if(L.startTime<=z)a(h),L.sortIndex=L.expirationTime,o(m,L);else break;L=r(h)}}function D(z){if(w=!1,N(z),!E)if(r(m)!==null)E=!0,V||(V=!0,le());else{var L=r(h);L!==null&&W(D,L.startTime-z)}}var V=!1,$=-1,X=5,F=-1;function q(){return T?!0:!(t.unstable_now()-F<X)}function te(){if(T=!1,V){var z=t.unstable_now();F=z;var L=!0;try{e:{E=!1,w&&(w=!1,O($),$=-1),C=!0;var _=b;try{t:{for(N(z),v=r(m);v!==null&&!(v.expirationTime>z&&q());){var Z=v.callback;if(typeof Z=="function"){v.callback=null,b=v.priorityLevel;var I=Z(v.expirationTime<=z);if(z=t.unstable_now(),typeof I=="function"){v.callback=I,N(z),L=!0;break t}v===r(m)&&a(m),N(z)}else a(m);v=r(m)}if(v!==null)L=!0;else{var ae=r(h);ae!==null&&W(D,ae.startTime-z),L=!1}}break e}finally{v=null,b=_,C=!1}L=void 0}}finally{L?le():V=!1}}}var le;if(typeof j=="function")le=function(){j(te)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,H=ee.port2;ee.port1.onmessage=te,le=function(){H.postMessage(null)}}else le=function(){M(te,0)};function W(z,L){$=M(function(){z(t.unstable_now())},L)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(z){switch(b){case 1:case 2:case 3:var L=3;break;default:L=b}var _=b;b=L;try{return z()}finally{b=_}},t.unstable_requestPaint=function(){T=!0},t.unstable_runWithPriority=function(z,L){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var _=b;b=z;try{return L()}finally{b=_}},t.unstable_scheduleCallback=function(z,L,_){var Z=t.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?Z+_:Z):_=Z,z){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=_+I,z={id:g++,callback:L,priorityLevel:z,startTime:_,expirationTime:I,sortIndex:-1},_>Z?(z.sortIndex=_,o(h,z),r(m)===null&&z===r(h)&&(w?(O($),$=-1):w=!0,W(D,_-Z))):(z.sortIndex=I,o(m,z),E||C||(E=!0,V||(V=!0,le()))),z},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(z){var L=b;return function(){var _=b;b=L;try{return z.apply(this,arguments)}finally{b=_}}}})(_d)),_d}var Qv;function x4(){return Qv||(Qv=1,jd.exports=b4()),jd.exports}var Nd={exports:{}},Et={};var Fv;function S4(){if(Fv)return Et;Fv=1;var t=Tc();function o(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var a={d:{f:r,r:function(){throw Error(o(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},s=Symbol.for("react.portal");function c(m,h,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:v==null?null:""+v,children:m,containerInfo:h,implementation:g}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Et.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Et.createPortal=function(m,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(o(299));return c(m,h,null,g)},Et.flushSync=function(m){var h=u.T,g=a.p;try{if(u.T=null,a.p=2,m)return m()}finally{u.T=h,a.p=g,a.d.f()}},Et.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(m,h))},Et.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Et.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,C=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?a.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:C}):g==="script"&&a.d.X(m,{crossOrigin:v,integrity:b,fetchPriority:C,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Et.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=f(h.as,h.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(m)},Et.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin);a.d.L(m,g,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Et.preloadModule=function(m,h){if(typeof m=="string")if(h){var g=f(h.as,h.crossOrigin);a.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(m)},Et.requestFormReset=function(m){a.d.r(m)},Et.unstable_batchedUpdates=function(m,h){return m(h)},Et.useFormState=function(m,h,g){return u.H.useFormState(m,h,g)},Et.useFormStatus=function(){return u.H.useHostTransitionStatus()},Et.version="19.2.4",Et}var Kv;function Zy(){if(Kv)return Nd.exports;Kv=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(o){console.error(o)}}return t(),Nd.exports=S4(),Nd.exports}var Jv;function C4(){if(Jv)return Ya;Jv=1;var t=x4(),o=Tc(),r=Zy();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function u(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function f(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function m(e){if(c(e)!==e)throw Error(a(188))}function h(e){var n=e.alternate;if(!n){if(n=c(e),n===null)throw Error(a(188));return n!==e?null:e}for(var l=e,i=n;;){var d=l.return;if(d===null)break;var p=d.alternate;if(p===null){if(i=d.return,i!==null){l=i;continue}break}if(d.child===p.child){for(p=d.child;p;){if(p===l)return m(d),e;if(p===i)return m(d),n;p=p.sibling}throw Error(a(188))}if(l.return!==i.return)l=d,i=p;else{for(var S=!1,R=d.child;R;){if(R===l){S=!0,l=d,i=p;break}if(R===i){S=!0,i=d,l=p;break}R=R.sibling}if(!S){for(R=p.child;R;){if(R===l){S=!0,l=p,i=d;break}if(R===i){S=!0,i=p,l=d;break}R=R.sibling}if(!S)throw Error(a(189))}}if(l.alternate!==i)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?e:n}function g(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=g(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),j=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),q=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function le(e){return e===null||typeof e!="object"?null:(e=te&&e[te]||e["@@iterator"],typeof e=="function"?e:null)}var ee=Symbol.for("react.client.reference");function H(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case M:return"Profiler";case T:return"StrictMode";case D:return"Suspense";case V:return"SuspenseList";case F:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case j:return e.displayName||"Context";case O:return(e._context.displayName||"Context")+".Consumer";case N:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $:return n=e.displayName||null,n!==null?n:H(e.type)||"Memo";case X:n=e._payload,e=e._init;try{return H(e(n))}catch{}}return null}var W=Array.isArray,z=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_={pending:!1,data:null,method:null,action:null},Z=[],I=-1;function ae(e){return{current:e}}function ne(e){0>I||(e.current=Z[I],Z[I]=null,I--)}function re(e,n){I++,Z[I]=e.current,e.current=n}var ve=ae(null),se=ae(null),be=ae(null),Le=ae(null);function Ee(e,n){switch(re(be,n),re(se,e),re(ve,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?mv(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=mv(n),e=pv(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ne(ve),re(ve,e)}function ye(){ne(ve),ne(se),ne(be)}function Je(e){e.memoizedState!==null&&re(Le,e);var n=ve.current,l=pv(n,e.type);n!==l&&(re(se,e),re(ve,l))}function nt(e){se.current===e&&(ne(ve),ne(se)),Le.current===e&&(ne(Le),Ua._currentValue=_)}var We,Ae;function tt(e){if(We===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);We=n&&n[1]||"",Ae=-1<l.stack.indexOf(`
1
+ import{r as Tc,g as Vy,a as x,R as Rc,N as Ve}from"./graph-vendor-CUxe67Lr.js";import{a as kC,f as VC,P as BC,b as $C,y as UC,g as GC,c as bm,D as Rd,d as ZC,M as PC,m as qC,e as YC,H as XC,N as IC,i as QC,h as FC,L as KC,A as JC,B as WC,_ as Eo,j as ht,k as kt,l as Ys,n as Wa,p as e4,o as Hl,q as Ke,r as Mc,S as ei,T as t4,s as Oc,t as Qn,I as xm,u as Pv,C as n4,v as o4,w as By,x as $y,z as Uy,E as l4,F as r4,R as ti,G as a4,J as i4,K as s4,O as c4,Q as Gy,U as u4,V as f4,W as qv,X as d4,Y as m4,Z as p4,$ as h4,a0 as g4,a1 as we,a2 as Sm}from"./note-core-DMZcZ4yV.js";var Md={exports:{}},qa={};var Yv;function v4(){if(Yv)return qa;Yv=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(a,s,c){var u=null;if(c!==void 0&&(u=""+c),s.key!==void 0&&(u=""+s.key),"key"in s){c={};for(var f in s)f!=="key"&&(c[f]=s[f])}else c=s;return s=c.ref,{$$typeof:t,type:a,key:u,ref:s!==void 0?s:null,props:c}}return qa.Fragment=o,qa.jsx=r,qa.jsxs=r,qa}var Xv;function y4(){return Xv||(Xv=1,Md.exports=v4()),Md.exports}var y=y4(),Od={exports:{}},Ya={},jd={exports:{}},_d={};var Iv;function b4(){return Iv||(Iv=1,(function(t){function o(z,L){var _=z.length;z.push(L);e:for(;0<_;){var Z=_-1>>>1,I=z[Z];if(0<s(I,L))z[Z]=L,z[_]=I,_=Z;else break e}}function r(z){return z.length===0?null:z[0]}function a(z){if(z.length===0)return null;var L=z[0],_=z.pop();if(_!==L){z[0]=_;e:for(var Z=0,I=z.length,ae=I>>>1;Z<ae;){var ne=2*(Z+1)-1,re=z[ne],ve=ne+1,se=z[ve];if(0>s(re,_))ve<I&&0>s(se,re)?(z[Z]=se,z[ve]=_,Z=ve):(z[Z]=re,z[ne]=_,Z=ne);else if(ve<I&&0>s(se,_))z[Z]=se,z[ve]=_,Z=ve;else break e}}return L}function s(z,L){var _=z.sortIndex-L.sortIndex;return _!==0?_:z.id-L.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();t.unstable_now=function(){return u.now()-f}}var m=[],h=[],g=1,v=null,b=3,C=!1,E=!1,w=!1,T=!1,M=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function N(z){for(var L=r(h);L!==null;){if(L.callback===null)a(h);else if(L.startTime<=z)a(h),L.sortIndex=L.expirationTime,o(m,L);else break;L=r(h)}}function D(z){if(w=!1,N(z),!E)if(r(m)!==null)E=!0,V||(V=!0,le());else{var L=r(h);L!==null&&W(D,L.startTime-z)}}var V=!1,$=-1,X=5,F=-1;function q(){return T?!0:!(t.unstable_now()-F<X)}function te(){if(T=!1,V){var z=t.unstable_now();F=z;var L=!0;try{e:{E=!1,w&&(w=!1,O($),$=-1),C=!0;var _=b;try{t:{for(N(z),v=r(m);v!==null&&!(v.expirationTime>z&&q());){var Z=v.callback;if(typeof Z=="function"){v.callback=null,b=v.priorityLevel;var I=Z(v.expirationTime<=z);if(z=t.unstable_now(),typeof I=="function"){v.callback=I,N(z),L=!0;break t}v===r(m)&&a(m),N(z)}else a(m);v=r(m)}if(v!==null)L=!0;else{var ae=r(h);ae!==null&&W(D,ae.startTime-z),L=!1}}break e}finally{v=null,b=_,C=!1}L=void 0}}finally{L?le():V=!1}}}var le;if(typeof j=="function")le=function(){j(te)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,H=ee.port2;ee.port1.onmessage=te,le=function(){H.postMessage(null)}}else le=function(){M(te,0)};function W(z,L){$=M(function(){z(t.unstable_now())},L)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(z){switch(b){case 1:case 2:case 3:var L=3;break;default:L=b}var _=b;b=L;try{return z()}finally{b=_}},t.unstable_requestPaint=function(){T=!0},t.unstable_runWithPriority=function(z,L){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var _=b;b=z;try{return L()}finally{b=_}},t.unstable_scheduleCallback=function(z,L,_){var Z=t.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?Z+_:Z):_=Z,z){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=_+I,z={id:g++,callback:L,priorityLevel:z,startTime:_,expirationTime:I,sortIndex:-1},_>Z?(z.sortIndex=_,o(h,z),r(m)===null&&z===r(h)&&(w?(O($),$=-1):w=!0,W(D,_-Z))):(z.sortIndex=I,o(m,z),E||C||(E=!0,V||(V=!0,le()))),z},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(z){var L=b;return function(){var _=b;b=L;try{return z.apply(this,arguments)}finally{b=_}}}})(_d)),_d}var Qv;function x4(){return Qv||(Qv=1,jd.exports=b4()),jd.exports}var Nd={exports:{}},Et={};var Fv;function S4(){if(Fv)return Et;Fv=1;var t=Tc();function o(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var a={d:{f:r,r:function(){throw Error(o(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},s=Symbol.for("react.portal");function c(m,h,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:v==null?null:""+v,children:m,containerInfo:h,implementation:g}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Et.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Et.createPortal=function(m,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(o(299));return c(m,h,null,g)},Et.flushSync=function(m){var h=u.T,g=a.p;try{if(u.T=null,a.p=2,m)return m()}finally{u.T=h,a.p=g,a.d.f()}},Et.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(m,h))},Et.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Et.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,C=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?a.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:C}):g==="script"&&a.d.X(m,{crossOrigin:v,integrity:b,fetchPriority:C,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Et.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=f(h.as,h.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(m)},Et.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin);a.d.L(m,g,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Et.preloadModule=function(m,h){if(typeof m=="string")if(h){var g=f(h.as,h.crossOrigin);a.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(m)},Et.requestFormReset=function(m){a.d.r(m)},Et.unstable_batchedUpdates=function(m,h){return m(h)},Et.useFormState=function(m,h,g){return u.H.useFormState(m,h,g)},Et.useFormStatus=function(){return u.H.useHostTransitionStatus()},Et.version="19.2.4",Et}var Kv;function Zy(){if(Kv)return Nd.exports;Kv=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(o){console.error(o)}}return t(),Nd.exports=S4(),Nd.exports}var Jv;function C4(){if(Jv)return Ya;Jv=1;var t=x4(),o=Tc(),r=Zy();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function u(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function f(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function m(e){if(c(e)!==e)throw Error(a(188))}function h(e){var n=e.alternate;if(!n){if(n=c(e),n===null)throw Error(a(188));return n!==e?null:e}for(var l=e,i=n;;){var d=l.return;if(d===null)break;var p=d.alternate;if(p===null){if(i=d.return,i!==null){l=i;continue}break}if(d.child===p.child){for(p=d.child;p;){if(p===l)return m(d),e;if(p===i)return m(d),n;p=p.sibling}throw Error(a(188))}if(l.return!==i.return)l=d,i=p;else{for(var S=!1,R=d.child;R;){if(R===l){S=!0,l=d,i=p;break}if(R===i){S=!0,i=d,l=p;break}R=R.sibling}if(!S){for(R=p.child;R;){if(R===l){S=!0,l=p,i=d;break}if(R===i){S=!0,i=p,l=d;break}R=R.sibling}if(!S)throw Error(a(189))}}if(l.alternate!==i)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?e:n}function g(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=g(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),j=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),q=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function le(e){return e===null||typeof e!="object"?null:(e=te&&e[te]||e["@@iterator"],typeof e=="function"?e:null)}var ee=Symbol.for("react.client.reference");function H(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case M:return"Profiler";case T:return"StrictMode";case D:return"Suspense";case V:return"SuspenseList";case F:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case j:return e.displayName||"Context";case O:return(e._context.displayName||"Context")+".Consumer";case N:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $:return n=e.displayName||null,n!==null?n:H(e.type)||"Memo";case X:n=e._payload,e=e._init;try{return H(e(n))}catch{}}return null}var W=Array.isArray,z=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_={pending:!1,data:null,method:null,action:null},Z=[],I=-1;function ae(e){return{current:e}}function ne(e){0>I||(e.current=Z[I],Z[I]=null,I--)}function re(e,n){I++,Z[I]=e.current,e.current=n}var ve=ae(null),se=ae(null),be=ae(null),Le=ae(null);function Ee(e,n){switch(re(be,n),re(se,e),re(ve,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?mv(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=mv(n),e=pv(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ne(ve),re(ve,e)}function ye(){ne(ve),ne(se),ne(be)}function Je(e){e.memoizedState!==null&&re(Le,e);var n=ve.current,l=pv(n,e.type);n!==l&&(re(se,e),re(ve,l))}function nt(e){se.current===e&&(ne(ve),ne(se)),Le.current===e&&(ne(Le),Ua._currentValue=_)}var We,Ae;function tt(e){if(We===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);We=n&&n[1]||"",Ae=-1<l.stack.indexOf(`
2
2
  at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
3
3
  `+We+e+Ae}var nn=!1;function An(e,n){if(!e||nn)return"";nn=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var J=function(){throw Error()};if(Object.defineProperty(J.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(J,[])}catch(Y){var P=Y}Reflect.construct(e,[],J)}else{try{J.call()}catch(Y){P=Y}e.call(J.prototype)}}else{try{throw Error()}catch(Y){P=Y}(J=e())&&typeof J.catch=="function"&&J.catch(function(){})}}catch(Y){if(Y&&P&&typeof Y.stack=="string")return[Y.stack,P.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=i.DetermineComponentFrameRoot(),S=p[0],R=p[1];if(S&&R){var A=S.split(`
4
4
  `),G=R.split(`
@@ -1,4 +1,4 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as J,h as P,w as V,q as v,b4 as W,u as ee,ah as M,P as ae,T as s,al as te,b5 as j,b6 as N,B as C,a8 as se,M as m,l as b,I as w,r as le,ac as ne,a1 as re,i as $,j as ce,aP as ie,X as oe}from"./index-DYlYUrjH.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{S as D}from"./SurfaceCard-EMs50xSF.js";import{n as de}from"./Plus.es-DpxzgRtY.js";import"./note-core-Z6kqulGB.js";const me=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),O=a.forwardRef((l,c)=>a.createElement(J,{ref:c,...l,weights:me}));O.displayName="CaretUpIcon";const he=O,k=["id","name","template","replacement","createdAt","updatedAt"],ue=new Set(k),pe=`query FetchPlaceholders(
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{p as J,h as P,k as V,q as v,b4 as W,u as ee,ah as M,P as ae,T as s,al as te,b5 as j,b6 as N,B as C,a8 as se,M as m,n as b,I as w,x as le,ac as ne,a1 as re,i as $,j as ce,aP as ie,m as oe}from"./index-B43ulIPo.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{S as D}from"./SurfaceCard-Bnfo5EOl.js";import{n as de}from"./Plus.es-BGVIIQtM.js";import"./note-core-DMZcZ4yV.js";const me=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),k=a.forwardRef((l,c)=>a.createElement(J,{ref:c,...l,weights:me}));k.displayName="CaretUpIcon";const he=k,O=["id","name","template","replacement","createdAt","updatedAt"],ue=new Set(O),pe=`query FetchPlaceholders(
2
2
  $searchFilter: SearchFilterInput,
3
3
  $pagination: PaginationInput
4
4
  ) {
@@ -10,7 +10,7 @@ import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as J,h as P,w as V,q as v
10
10
  placeholders {
11
11
  __PLACEHOLDER_FIELDS__ }
12
12
  }
13
- }`,xe=l=>{const c=l&&l.length>0?l.filter(r=>ue.has(r)):k;return Array.from(new Set(c)).map(r=>" "+r).join(`
13
+ }`,xe=l=>{const c=l&&l.length>0?l.filter(r=>ue.has(r)):O;return Array.from(new Set(c)).map(r=>" "+r).join(`
14
14
  `)+`
15
15
  `},ge=async({limit:l=25,offset:c=0,query:h="",fields:r}={})=>{const g=xe(r),i=pe.replace("__PLACEHOLDER_FIELDS__",g);return P(i,{searchFilter:{query:h},pagination:{limit:l,offset:c}})},ye=l=>P(`mutation CreatePlaceholder(
16
16
  $name: String!,
@@ -31,4 +31,4 @@ __PLACEHOLDER_FIELDS__ }
31
31
  }
32
32
  }`,l),fe=l=>P(`mutation DeletePlaceholder($id: ID!) {
33
33
  deletePlaceholder(id: $id)
34
- }`,{id:l}),I=ce(ie),Ee=()=>{const l=oe(),c=V(),h=I.useNavigate(),{page:r}=I.useSearch(),[g,i]=a.useState(!1),[y,H]=a.useState(!0),[n,u]=a.useState({name:"",template:"",replacement:""}),o=25,T=v.placeholders.list({limit:o,offset:(r-1)*o}),[E]=a.useState(W),{data:d,isLoading:p}=ee({queryKey:T,queryFn:async()=>{const t=await ge({offset:(r-1)*o,limit:o});if(t.type==="error")throw t;return t.allPlaceholders}}),F=M({mutationFn:ye,onSuccess:async()=>{l("Placeholder added successfully"),i(!1),u({name:"",template:"",replacement:""}),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),q=M({mutationFn:fe,onSuccess:async()=>{l("Placeholder deleted successfully"),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),B=E.length,x=d?.totalCount??0,Z=d?.placeholders??[],f="font-medium text-fg-tertiary",L="leading-[1.2]",A="break-all leading-[1.2]",S="leading-[1.2]",_="flex flex-col gap-px",R="space-y-px",Q="focus-ring-soft inline-flex items-center gap-2 rounded-[12px] border border-transparent px-2.5 py-1.5 text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",K="relative",U="absolute right-2 top-2",X="focus-ring-soft surface-base group flex flex-col items-center justify-center gap-0.5 px-4 py-4 text-center text-fg-secondary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",G="inline-flex h-[34px] w-[34px] items-center justify-center rounded-full border border-border-subtle bg-surface text-current transition-colors group-hover:border-border-secondary/70",z=x>0?`Placeholders (${x})`:void 0;return e.jsxs(ae,{title:"Placeholders",variant:"default",heading:p?e.jsx($,{width:244,height:24,className:"rounded-full"}):z,description:p?e.jsx($,{width:260,height:16,className:"rounded-full"}):"Create tokens that get replaced with values when you clone a note",children:[e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("section",{className:"space-y-3 border-b border-border-subtle/80 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"System placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Built-in tokens for date and time that are always available when cloning notes"})]}),e.jsxs("button",{type:"button",onClick:()=>H(!y),className:Q,children:[e.jsxs(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:[B," items"]}),y?e.jsx(he,{className:"h-4 w-4"}):e.jsx(te,{className:"h-4 w-4"})]})]}),y&&e.jsx("div",{className:"grid-auto-cards grid gap-5",children:E.map(t=>e.jsx(D,{children:e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:L,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Current value: ",t.replacement]})]})]})},t.name))})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"Custom placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Custom tokens you define once and reuse whenever you clone a note"})]}),!p&&e.jsx(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:x===1?"1 item":`${x} items`})]}),!p&&e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[Z.map(t=>e.jsxs(D,{className:K,children:[e.jsx(C,{variant:"ghost",size:"icon-sm",className:U,onClick:()=>q.mutate(t.id.toString()),children:e.jsx(se,{className:"h-4 w-4"})}),e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:`min-w-0 pr-8 ${L}`,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Replaces with: ",t.replacement]})]})]})]},t.id)),e.jsxs("button",{type:"button",onClick:()=>i(!0),className:X,children:[e.jsx("span",{className:G,children:e.jsx(de,{className:"h-4.5 w-4.5"})}),e.jsx(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:"text-current",children:"New custom"})]})]})]})]}),e.jsxs(m,{isOpen:g,onClose:()=>i(!1),variant:"form",children:[e.jsx(m.Header,{title:"Add Placeholder",onClose:()=>i(!1)}),e.jsxs(m.Body,{children:[e.jsx(m.Description,{className:"mb-4",children:"Create a token that swaps in a value when you clone a note"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"name",className:f,children:"Name"}),e.jsx(w,{id:"name",type:"text",value:n.name,onChange:t=>u({...n,name:t.target.value}),placeholder:"Description of this placeholder"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"A readable label so you can find this placeholder later"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"template",className:f,children:"Placeholder"}),e.jsx(w,{id:"template",type:"text",value:n.template,onChange:t=>u({...n,template:t.target.value}),placeholder:"note_app"}),e.jsxs(s,{as:"p",variant:"meta",tone:"secondary",children:["Use it in a note as ",j,"your_placeholder",N]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"replacement",className:f,children:"Replacement"}),e.jsx(w,{id:"replacement",type:"text",value:n.replacement,onChange:t=>u({...n,replacement:t.target.value}),placeholder:"Ocean Brain"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"This value is inserted when the placeholder is replaced during cloning"})]})]})]}),e.jsx(m.Footer,{children:e.jsxs(le,{children:[e.jsx(C,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),e.jsx(C,{variant:"primary",isLoading:F.isPending,onClick:()=>{if(!n.name||!n.template||!n.replacement){l("All fields are required");return}F.mutate({name:n.name,template:n.template,replacement:n.replacement})},children:"Add"})]})})]}),e.jsx(ne,{fallback:null,children:d?.totalCount&&o<d.totalCount&&e.jsx(re,{page:r,last:Math.ceil(d.totalCount/o),onChange:t=>{h({search:Y=>({...Y,page:t})})}})})]})};export{Ee as default};
34
+ }`,{id:l}),I=ce(ie),Ee=()=>{const l=oe(),c=V(),h=I.useNavigate(),{page:r}=I.useSearch(),[g,i]=a.useState(!1),[y,H]=a.useState(!0),[n,u]=a.useState({name:"",template:"",replacement:""}),o=25,T=v.placeholders.list({limit:o,offset:(r-1)*o}),[E]=a.useState(W),{data:d,isLoading:p}=ee({queryKey:T,queryFn:async()=>{const t=await ge({offset:(r-1)*o,limit:o});if(t.type==="error")throw t;return t.allPlaceholders}}),F=M({mutationFn:ye,onSuccess:async()=>{l("Placeholder added successfully"),i(!1),u({name:"",template:"",replacement:""}),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),q=M({mutationFn:fe,onSuccess:async()=>{l("Placeholder deleted successfully"),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),B=E.length,x=d?.totalCount??0,Z=d?.placeholders??[],f="font-medium text-fg-tertiary",L="leading-[1.2]",A="break-all leading-[1.2]",S="leading-[1.2]",_="flex flex-col gap-px",R="space-y-px",Q="focus-ring-soft inline-flex items-center gap-2 rounded-[12px] border border-transparent px-2.5 py-1.5 text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",K="relative",U="absolute right-2 top-2",G="focus-ring-soft surface-base group flex flex-col items-center justify-center gap-0.5 px-4 py-4 text-center text-fg-secondary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",X="inline-flex h-[34px] w-[34px] items-center justify-center rounded-full border border-border-subtle bg-surface text-current transition-colors group-hover:border-border-secondary/70",z=x>0?`Placeholders (${x})`:void 0;return e.jsxs(ae,{title:"Placeholders",variant:"default",heading:p?e.jsx($,{width:244,height:24,className:"rounded-full"}):z,description:p?e.jsx($,{width:260,height:16,className:"rounded-full"}):"Create tokens that get replaced with values when you clone a note",children:[e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("section",{className:"space-y-3 border-b border-border-subtle/80 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"System placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Built-in tokens for date and time that are always available when cloning notes"})]}),e.jsxs("button",{type:"button",onClick:()=>H(!y),className:Q,children:[e.jsxs(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:[B," items"]}),y?e.jsx(he,{className:"h-4 w-4"}):e.jsx(te,{className:"h-4 w-4"})]})]}),y&&e.jsx("div",{className:"grid-auto-cards grid gap-5",children:E.map(t=>e.jsx(D,{children:e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:L,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Current value: ",t.replacement]})]})]})},t.name))})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"Custom placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Custom tokens you define once and reuse whenever you clone a note"})]}),!p&&e.jsx(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:x===1?"1 item":`${x} items`})]}),!p&&e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[Z.map(t=>e.jsxs(D,{className:K,children:[e.jsx(C,{variant:"ghost",size:"icon-sm",className:U,onClick:()=>q.mutate(t.id.toString()),children:e.jsx(se,{className:"h-4 w-4"})}),e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:`min-w-0 pr-8 ${L}`,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Replaces with: ",t.replacement]})]})]})]},t.id)),e.jsxs("button",{type:"button",onClick:()=>i(!0),className:G,children:[e.jsx("span",{className:X,children:e.jsx(de,{className:"h-4.5 w-4.5"})}),e.jsx(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:"text-current",children:"New custom"})]})]})]})]}),e.jsxs(m,{isOpen:g,onClose:()=>i(!1),variant:"form",children:[e.jsx(m.Header,{title:"Add Placeholder",onClose:()=>i(!1)}),e.jsxs(m.Body,{children:[e.jsx(m.Description,{className:"mb-4",children:"Create a token that swaps in a value when you clone a note"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"name",className:f,children:"Name"}),e.jsx(w,{id:"name",type:"text",value:n.name,onChange:t=>u({...n,name:t.target.value}),placeholder:"Description of this placeholder"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"A readable label so you can find this placeholder later"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"template",className:f,children:"Placeholder"}),e.jsx(w,{id:"template",type:"text",value:n.template,onChange:t=>u({...n,template:t.target.value}),placeholder:"note_app"}),e.jsxs(s,{as:"p",variant:"meta",tone:"secondary",children:["Use it in a note as ",j,"your_placeholder",N]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"replacement",className:f,children:"Replacement"}),e.jsx(w,{id:"replacement",type:"text",value:n.replacement,onChange:t=>u({...n,replacement:t.target.value}),placeholder:"Ocean Brain"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"This value is inserted when the placeholder is replaced during cloning"})]})]})]}),e.jsx(m.Footer,{children:e.jsxs(le,{children:[e.jsx(C,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),e.jsx(C,{variant:"primary",isLoading:F.isPending,onClick:()=>{if(!n.name||!n.template||!n.replacement){l("All fields are required");return}F.mutate({name:n.name,template:n.template,replacement:n.replacement})},children:"Add"})]})})]}),e.jsx(ne,{fallback:null,children:d?.totalCount&&o<d.totalCount&&e.jsx(re,{page:r,last:Math.ceil(d.totalCount/o),onChange:t=>{h({search:Y=>({...Y,page:t})})}})})]})};export{Ee as default};
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{w as oe,u as de,F as ce,q as x,ah as M,b1 as ue,b2 as me,b3 as pe,P as he,T as s,B as o,M as d,I as v,S as xe,e as be,r as q,X as ve,j as ye,aI as ge}from"./index-DYlYUrjH.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const fe=ye(ge),W=[{value:"text",label:"Text",description:"Short status or label values."},{value:"url",label:"URL",description:"External sources, issues, docs, or references."},{value:"number",label:"Number",description:"Priority, score, or count values."},{value:"date",label:"Date",description:"Due dates and milestones."},{value:"boolean",label:"Boolean",description:"True or false flags."},{value:"select",label:"Select",description:"Choose one option from a controlled list."}],je=l=>!l.id&&!l.label.trim()&&!l.value.trim(),Ne=l=>(l.value.trim()||l.label.trim()).toLowerCase().replace(/\s+/g,"-"),Ce=l=>/^[a-z0-9][a-z0-9_-]*$/.test(l),X=l=>l.filter(r=>r.id||r.label.trim()).map((r,F)=>({...r.id?{id:r.id}:{},label:r.label.trim(),value:r.value.trim()||r.label.trim(),color:r.color??null,order:r.order??F}));function Ee(){const l=ve(),r=oe(),F=fe.useSearch(),Z=Number(F.page??1),R=50,V=Math.max(0,Z-1)*R,[O,I]=p.useState(""),[Q,A]=p.useState(""),[y,$]=p.useState("text"),[D,j]=p.useState([{label:"",value:""}]),[u,N]=p.useState(null),[i,H]=p.useState(null),[k,L]=p.useState(""),[E,g]=p.useState([{label:"",value:""}]),[ee,C]=p.useState(!1),S=()=>{I(""),A(""),$("text"),j([{label:"",value:""}])},ae=a=>{H(a),L(a.name),g(a.options.length>0?a.options.map(t=>({id:t.id,label:t.label,value:t.value,color:t.color,order:t.order})):[{label:"",value:""}])},T=()=>{H(null),L(""),g([{label:"",value:""}])},_=de({queryKey:x.notes.propertyKeys({limit:R,offset:V}),queryFn:async()=>{const a=await ce({limit:R,offset:V});if(a.type==="error")throw a;return a.notePropertyKeys}}),w=M({mutationFn:async()=>ue({key:O,name:Q||O,valueType:y,...y==="select"?{options:D.map((a,t)=>({label:a.label.trim(),value:a.value.trim()||a.label.trim(),order:t})).filter(a=>a.label)}:{}}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to create property.");return}S(),C(!1),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),l("Property created.")},onError:()=>{l("Failed to create property.")}}),h=M({mutationFn:async()=>{if(!i)throw new Error("Property to edit is missing.");return me({key:i.key,name:k||i.key,...i.valueType==="select"?{options:X(E)}:{}})},onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to update property.");return}T(),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),l("Property updated.")},onError:()=>{l("Failed to update property.")}}),f=M({mutationFn:async({propertyKey:a,confirmImpact:t})=>pe({key:a.key,confirmImpact:t}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to delete property.");return}r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),N(null),l(a.deleteNotePropertyKey.affectedNoteCount>0?`Property deleted from ${a.deleteNotePropertyKey.affectedNoteCount} note(s).`:"Property deleted.")},onError:()=>{l("Failed to delete property.")}}),P=_.data?.keys??[],se=y!=="select"||D.some(a=>a.label.trim()),z=i?.valueType==="select"?E.filter(a=>!je(a)):[],B=z.map(Ne),K=B.find((a,t)=>B.indexOf(a)!==t),U=B.find(a=>!Ce(a)),J=z.some(a=>!!a.id&&!a.label.trim()),Y=z.some(a=>!a.id&&!a.label.trim()),te=!i||i.valueType!=="select"||z.length>0&&!J&&!Y&&!K&&!U,le=!!i&&k.trim()!==i?.name,re=i?.valueType==="select"&&JSON.stringify(X(E))!==JSON.stringify(i.options.map(a=>({id:a.id,label:a.label,value:a.value,color:a.color??null,order:a.order}))),ie=le||!!re,G=J?"Existing option labels cannot be empty.":Y?"New options need a label.":K?`Option value “${K}” is duplicated.`:U?"Option values must use letters, numbers, dashes, or underscores.":"",ne=()=>{u&&f.mutate({propertyKey:u,confirmImpact:u.noteCount>0})};return e.jsxs(he,{title:"Properties",description:"Define shared note fields before using them in notes and future views.",headerRight:e.jsx(o,{type:"button",size:"md",variant:"primary",className:"w-full sm:w-auto",onClick:()=>C(!0),children:"New property"}),children:[e.jsxs("section",{className:"flex flex-col gap-3","aria-labelledby":"shared-properties-heading",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(s,{id:"shared-properties-heading",as:"h2",variant:"label",weight:"medium",className:"text-fg-tertiary",children:"Shared fields"}),!_.isLoading&&P.length>0&&e.jsxs(s,{as:"span",variant:"meta",tone:"tertiary",children:[P.length," field",P.length===1?"":"s"]})]}),_.isLoading?e.jsx(s,{as:"p",variant:"body",tone:"tertiary",className:"surface-base px-4 py-3.5",children:"Loading properties..."}):P.length===0?e.jsxs("div",{className:"surface-base border-dashed p-6 text-center",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"No shared properties yet."}),e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create one here, then attach it from the note screen."})]}):e.jsx("div",{className:"flex flex-col gap-3",children:P.map(a=>e.jsxs("article",{className:"surface-base grid gap-3 px-4 py-3.5 md:grid-cols-[minmax(0,1fr)_120px_120px_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"h3",variant:"body",weight:"semibold",className:"truncate",children:a.name}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"font-mono",children:a.key}),a.options.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.options.slice(0,6).map(t=>e.jsx("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-secondary",children:t.label},t.id)),a.options.length>6&&e.jsxs("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-tertiary",children:["+",a.options.length-6]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Type"}),e.jsx(s,{as:"span",variant:"label",tone:"secondary",className:"capitalize",children:a.valueType})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Used in"}),e.jsxs(s,{as:"span",variant:"label",tone:"tertiary",children:[a.noteCount," note",a.noteCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-self-start md:justify-self-end",children:[e.jsx(o,{type:"button",size:"sm",variant:"subtle",disabled:h.isPending||f.isPending,onClick:()=>ae(a),children:"Edit"}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",disabled:f.isPending||h.isPending,onClick:()=>N(a),children:"Delete"})]})]},a.key))})]}),e.jsxs(d,{isOpen:ee,onClose:()=>{w.isPending||(C(!1),S())},variant:"form",children:[e.jsx(d.Header,{title:"New property",onClose:()=>{C(!1),S()}}),e.jsx(d.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create a shared field that notes can use for values and future views."}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Key"}),e.jsx(v,{size:"md",placeholder:"status",value:O,onChange:a=>I(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Name"}),e.jsx(v,{size:"md",placeholder:"Status",value:Q,onChange:a=>A(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Type"}),e.jsx(xe,{value:y,onValueChange:a=>$(a),children:W.map(a=>e.jsx(be,{value:a.value,children:a.label},a.value))})]}),y==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>j(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:D.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:"value",value:a.value,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>j(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},t))})]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",children:W.find(a=>a.value===y)?.description})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:w.isPending,onClick:()=>{C(!1),S()},children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!O.trim()||!se||w.isPending,isLoading:w.isPending,onClick:()=>w.mutate(),children:"Create property"})]})})]}),e.jsxs(d,{isOpen:!!i,onClose:()=>{h.isPending||T()},variant:"form",children:[e.jsx(d.Header,{title:"Edit property",onClose:()=>{h.isPending||T()}}),e.jsx(d.Body,{children:i&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Rename the display label or add select options. Key, type, and existing option values stay fixed so notes and views remain stable."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Key"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"font-mono",children:i.key})]}),e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Type"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"capitalize",children:i.valueType})]})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Display name"}),e.jsx(v,{size:"md",placeholder:"Workflow state",value:k,onChange:a=>L(a.target.value)})]}),i.valueType==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5",children:"Existing option values are locked. Removing existing options needs an impact-aware delete flow."})]}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>g(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:a.id?"Locked value":"value",value:a.value,disabled:!!a.id,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),a.id?e.jsx(s,{as:"span",variant:"meta",tone:"tertiary",className:"flex h-8 items-center px-3",children:"Locked"}):e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>g(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},a.id??`new-${t}`))}),G&&e.jsx(s,{as:"p",variant:"micro",tone:"error",className:"mt-2",children:G})]})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:h.isPending,onClick:T,children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!k.trim()||!ie||!te||h.isPending,isLoading:h.isPending,onClick:()=>h.mutate(),children:"Save changes"})]})})]}),e.jsxs(d,{isOpen:!!u,onClose:()=>{f.isPending||N(null)},variant:"confirm",children:[e.jsx(d.Header,{title:"Delete property",onClose:()=>N(null)}),e.jsx(d.Body,{children:u&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(s,{as:"p",variant:"body",weight:"medium",children:["Delete “",u.name,"”?"]}),u.noteCount>0?e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle p-3",children:[e.jsxs(s,{as:"p",variant:"label",tone:"secondary",children:["This property is used by ",u.noteCount," note",u.noteCount===1?"":"s","."]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-1 leading-5",children:"Deleting it removes this value from those notes. Future views using this property will need configuration."})]}):e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"This property is not used by any note yet."})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:f.isPending,onClick:()=>N(null),children:"Cancel"}),e.jsx(o,{type:"button",variant:"danger",size:"sm",isLoading:f.isPending,onClick:ne,children:"Delete"})]})})]})]})}export{Ee as default};
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{k as oe,u as de,H as ce,q as x,ah as M,b1 as ue,b2 as me,b3 as pe,P as he,T as s,B as o,M as d,I as v,S as xe,e as be,x as q,m as ve,j as ye,aI as ge}from"./index-B43ulIPo.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const fe=ye(ge),W=[{value:"text",label:"Text",description:"Short status or label values."},{value:"url",label:"URL",description:"External sources, issues, docs, or references."},{value:"number",label:"Number",description:"Priority, score, or count values."},{value:"date",label:"Date",description:"Due dates and milestones."},{value:"boolean",label:"Boolean",description:"True or false flags."},{value:"select",label:"Select",description:"Choose one option from a controlled list."}],je=l=>!l.id&&!l.label.trim()&&!l.value.trim(),Ne=l=>(l.value.trim()||l.label.trim()).toLowerCase().replace(/\s+/g,"-"),Ce=l=>/^[a-z0-9][a-z0-9_-]*$/.test(l),X=l=>l.filter(r=>r.id||r.label.trim()).map((r,F)=>({...r.id?{id:r.id}:{},label:r.label.trim(),value:r.value.trim()||r.label.trim(),color:r.color??null,order:r.order??F}));function Ee(){const l=ve(),r=oe(),F=fe.useSearch(),Z=Number(F.page??1),R=50,V=Math.max(0,Z-1)*R,[k,I]=p.useState(""),[Q,A]=p.useState(""),[y,H]=p.useState("text"),[D,j]=p.useState([{label:"",value:""}]),[u,N]=p.useState(null),[i,$]=p.useState(null),[O,L]=p.useState(""),[E,g]=p.useState([{label:"",value:""}]),[ee,C]=p.useState(!1),S=()=>{I(""),A(""),H("text"),j([{label:"",value:""}])},ae=a=>{$(a),L(a.name),g(a.options.length>0?a.options.map(t=>({id:t.id,label:t.label,value:t.value,color:t.color,order:t.order})):[{label:"",value:""}])},T=()=>{$(null),L(""),g([{label:"",value:""}])},_=de({queryKey:x.notes.propertyKeys({limit:R,offset:V}),queryFn:async()=>{const a=await ce({limit:R,offset:V});if(a.type==="error")throw a;return a.notePropertyKeys}}),w=M({mutationFn:async()=>ue({key:k,name:Q||k,valueType:y,...y==="select"?{options:D.map((a,t)=>({label:a.label.trim(),value:a.value.trim()||a.label.trim(),order:t})).filter(a=>a.label)}:{}}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to create property.");return}S(),C(!1),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),l("Property created.")},onError:()=>{l("Failed to create property.")}}),h=M({mutationFn:async()=>{if(!i)throw new Error("Property to edit is missing.");return me({key:i.key,name:O||i.key,...i.valueType==="select"?{options:X(E)}:{}})},onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to update property.");return}T(),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),l("Property updated.")},onError:()=>{l("Failed to update property.")}}),f=M({mutationFn:async({propertyKey:a,confirmImpact:t})=>pe({key:a.key,confirmImpact:t}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to delete property.");return}r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),N(null),l(a.deleteNotePropertyKey.affectedNoteCount>0?`Property deleted from ${a.deleteNotePropertyKey.affectedNoteCount} note(s).`:"Property deleted.")},onError:()=>{l("Failed to delete property.")}}),P=_.data?.keys??[],se=y!=="select"||D.some(a=>a.label.trim()),z=i?.valueType==="select"?E.filter(a=>!je(a)):[],B=z.map(Ne),K=B.find((a,t)=>B.indexOf(a)!==t),U=B.find(a=>!Ce(a)),J=z.some(a=>!!a.id&&!a.label.trim()),Y=z.some(a=>!a.id&&!a.label.trim()),te=!i||i.valueType!=="select"||z.length>0&&!J&&!Y&&!K&&!U,le=!!i&&O.trim()!==i?.name,re=i?.valueType==="select"&&JSON.stringify(X(E))!==JSON.stringify(i.options.map(a=>({id:a.id,label:a.label,value:a.value,color:a.color??null,order:a.order}))),ie=le||!!re,G=J?"Existing option labels cannot be empty.":Y?"New options need a label.":K?`Option value “${K}” is duplicated.`:U?"Option values must use letters, numbers, dashes, or underscores.":"",ne=()=>{u&&f.mutate({propertyKey:u,confirmImpact:u.noteCount>0})};return e.jsxs(he,{title:"Properties",description:"Define shared note fields before using them in notes and future views.",headerRight:e.jsx(o,{type:"button",size:"md",variant:"primary",className:"w-full sm:w-auto",onClick:()=>C(!0),children:"New property"}),children:[e.jsxs("section",{className:"flex flex-col gap-3","aria-labelledby":"shared-properties-heading",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(s,{id:"shared-properties-heading",as:"h2",variant:"label",weight:"medium",className:"text-fg-tertiary",children:"Shared fields"}),!_.isLoading&&P.length>0&&e.jsxs(s,{as:"span",variant:"meta",tone:"tertiary",children:[P.length," field",P.length===1?"":"s"]})]}),_.isLoading?e.jsx(s,{as:"p",variant:"body",tone:"tertiary",className:"surface-base px-4 py-3.5",children:"Loading properties..."}):P.length===0?e.jsxs("div",{className:"surface-base border-dashed p-6 text-center",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"No shared properties yet."}),e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create one here, then attach it from the note screen."})]}):e.jsx("div",{className:"flex flex-col gap-3",children:P.map(a=>e.jsxs("article",{className:"surface-base grid gap-3 px-4 py-3.5 md:grid-cols-[minmax(0,1fr)_120px_120px_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"h3",variant:"body",weight:"semibold",className:"truncate",children:a.name}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"font-mono",children:a.key}),a.options.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.options.slice(0,6).map(t=>e.jsx("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-secondary",children:t.label},t.id)),a.options.length>6&&e.jsxs("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-tertiary",children:["+",a.options.length-6]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Type"}),e.jsx(s,{as:"span",variant:"label",tone:"secondary",className:"capitalize",children:a.valueType})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Used in"}),e.jsxs(s,{as:"span",variant:"label",tone:"tertiary",children:[a.noteCount," note",a.noteCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-self-start md:justify-self-end",children:[e.jsx(o,{type:"button",size:"sm",variant:"subtle",disabled:h.isPending||f.isPending,onClick:()=>ae(a),children:"Edit"}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",disabled:f.isPending||h.isPending,onClick:()=>N(a),children:"Delete"})]})]},a.key))})]}),e.jsxs(d,{isOpen:ee,onClose:()=>{w.isPending||(C(!1),S())},variant:"form",children:[e.jsx(d.Header,{title:"New property",onClose:()=>{C(!1),S()}}),e.jsx(d.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create a shared field that notes can use for values and future views."}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Key"}),e.jsx(v,{size:"md",placeholder:"status",value:k,onChange:a=>I(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Name"}),e.jsx(v,{size:"md",placeholder:"Status",value:Q,onChange:a=>A(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Type"}),e.jsx(xe,{value:y,onValueChange:a=>H(a),children:W.map(a=>e.jsx(be,{value:a.value,children:a.label},a.value))})]}),y==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>j(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:D.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:"value",value:a.value,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>j(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},t))})]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",children:W.find(a=>a.value===y)?.description})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:w.isPending,onClick:()=>{C(!1),S()},children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!k.trim()||!se||w.isPending,isLoading:w.isPending,onClick:()=>w.mutate(),children:"Create property"})]})})]}),e.jsxs(d,{isOpen:!!i,onClose:()=>{h.isPending||T()},variant:"form",children:[e.jsx(d.Header,{title:"Edit property",onClose:()=>{h.isPending||T()}}),e.jsx(d.Body,{children:i&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Rename the display label or add select options. Key, type, and existing option values stay fixed so notes and views remain stable."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Key"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"font-mono",children:i.key})]}),e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Type"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"capitalize",children:i.valueType})]})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Display name"}),e.jsx(v,{size:"md",placeholder:"Workflow state",value:O,onChange:a=>L(a.target.value)})]}),i.valueType==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5",children:"Existing option values are locked. Removing existing options needs an impact-aware delete flow."})]}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>g(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:a.id?"Locked value":"value",value:a.value,disabled:!!a.id,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),a.id?e.jsx(s,{as:"span",variant:"meta",tone:"tertiary",className:"flex h-8 items-center px-3",children:"Locked"}):e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>g(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},a.id??`new-${t}`))}),G&&e.jsx(s,{as:"p",variant:"micro",tone:"error",className:"mt-2",children:G})]})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:h.isPending,onClick:T,children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!O.trim()||!ie||!te||h.isPending,isLoading:h.isPending,onClick:()=>h.mutate(),children:"Save changes"})]})})]}),e.jsxs(d,{isOpen:!!u,onClose:()=>{f.isPending||N(null)},variant:"confirm",children:[e.jsx(d.Header,{title:"Delete property",onClose:()=>N(null)}),e.jsx(d.Body,{children:u&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(s,{as:"p",variant:"body",weight:"medium",children:["Delete “",u.name,"”?"]}),u.noteCount>0?e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle p-3",children:[e.jsxs(s,{as:"p",variant:"label",tone:"secondary",children:["This property is used by ",u.noteCount," note",u.noteCount===1?"":"s","."]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-1 leading-5",children:"Deleting it removes this value from those notes. Future views using this property will need configuration."})]}):e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"This property is not used by any note yet."})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:f.isPending,onClick:()=>N(null),children:"Cancel"}),e.jsx(o,{type:"button",variant:"danger",size:"sm",isLoading:f.isPending,onClick:ne,children:"Delete"})]})})]})]})}export{Ee as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{a0 as M,j as Q,aw as F,k as L,y as _,a6 as I,aT as K,q as i,ah as E,aU as B,N as O,aV as W,P as N,J as H,T as d,ax as U,B as j,a1 as V,aW as Y,i as l,m as $,d as z,ak as G,u as J,aX as X,M as y}from"./index-B43ulIPo.js";import{a as k}from"./graph-vendor-CUxe67Lr.js";import{S as C}from"./SurfaceCard-Bnfo5EOl.js";import"./note-core-DMZcZ4yV.js";const m=25,v=Q(F),S=30,R=`Deleted notes stay here for ${S} days before permanent removal`,g={title:"Permanently delete note?",description:"This note is referenced by the notes below. If you permanently delete it, those links will stay broken. Other notes will not be edited automatically.",confirmLabel:"Delete now",confirmVariant:"danger"},P=a=>z(a).format("YYYY-MM-DD HH:mm"),Z=({note:a,onClose:o})=>{const s=a?.id??"",c=a?.title||"Untitled note",r=J({queryKey:i.notes.trashDetail(s),enabled:!!a,queryFn:async()=>{const h=await X(s);if(h.type==="error")throw h;if(!h.trashedNote)throw new Error("Trashed note not found");return h.trashedNote}}),f=r.data?.contentAsMarkdown.trim()??"";return e.jsxs(y,{isOpen:!!a,onClose:o,variant:"inspect",children:[e.jsx(y.Header,{title:c,onClose:o}),e.jsx(y.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[a&&e.jsxs(d,{as:"p",variant:"meta",tone:"secondary",children:["Deleted ",P(a.deletedAt)]}),r.isLoading&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",children:"Loading deleted note content..."}),r.isError&&e.jsx(d,{as:"p",variant:"meta",tone:"error",children:"Failed to load deleted note content."}),!r.isLoading&&!r.isError&&f&&e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:f}),!r.isLoading&&!r.isError&&!f&&e.jsx(d,{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 deleted note."})]})}),e.jsx(y.Footer,{children:e.jsx(j,{variant:"ghost",size:"sm",onClick:o,children:"Close"})})]})},ee=()=>e.jsx(N,{title:"Trash",variant:"default",heading:e.jsx(l,{width:118,height:24,className:"rounded-full"}),description:e.jsx(l,{width:352,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:3},(a,o)=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx(l,{width:"40%",height:18,className:"rounded-full"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:168,height:14,className:"rounded-full"}),e.jsx(l,{width:176,height:14,className:"rounded-full"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:56,height:24,className:"rounded-full"}),e.jsx(l,{width:72,height:24,className:"rounded-full"})]})]}),e.jsx(l,{width:92,height:32,className:"rounded-[12px]"})]})},o))})}),te=()=>{const{page:a}=v.useSearch(),o=v.useNavigate(),s=L(),c=$(),r=_(),[f,h]=k.useState(null),[x,b]=k.useState(null),{data:u}=I({queryKey:i.notes.trash({limit:m,offset:(a-1)*m}),queryFn:async()=>{const t=await K({limit:m,offset:(a-1)*m});if(t.type==="error")throw t;return t.trashedNotes}}),w=E({mutationFn:B,onSuccess:async t=>{if(t.type==="error")throw t;await Promise.all([s.invalidateQueries({queryKey:i.notes.all(),exact:!1}),s.invalidateQueries({queryKey:i.tags.all(),exact:!1}),s.invalidateQueries({queryKey:i.reminders.all(),exact:!1}),s.invalidateQueries({queryKey:i.images.all(),exact:!1}),s.invalidateQueries({queryKey:i.calendar.all(),exact:!1})]),c("The note has been restored."),o({to:O,params:{id:t.restoreTrashedNote.id}})},onError:()=>{c("Failed to restore the note.")}}),p=E({mutationFn:W,onSuccess:async t=>{if(t.type==="error")throw t;await s.invalidateQueries({queryKey:i.notes.trashAll(),exact:!1}),c("The note has been permanently deleted.")},onError:()=>{c("Failed to permanently delete the note.")}}),D=()=>{if(!x)return;const{id:t}=x;b(null),p.mutate(t)},q=async t=>{const n=await G(t);if(n.type==="error"){c("Failed to check linked notes before permanently deleting this note.");return}if(s.setQueryData(i.notes.backReferences(t),n.backReferences),n.backReferences.length>0){b({id:t,backReferences:n.backReferences});return}await r("Permanently delete this note? This cannot be undone.")&&p.mutate(t)},T=u.totalCount>0?`Trash (${u.totalCount})`:void 0,A=u.notes.find(t=>t.id===f)??null;return u.notes.length===0?e.jsx(N,{title:"Trash",variant:"default",heading:T,description:R,children:e.jsx(H,{title:"Trash is empty",description:`Delete a note and you can restore it here for ${S} days before permanent removal`})}):e.jsxs(N,{title:"Trash",variant:"default",heading:T,description:R,children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid gap-3",children:u.notes.map(t=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[e.jsx(d,{as:"h2",variant:"body",weight:"medium",className:"min-w-0 flex-1 break-words leading-[1.25]",children:t.title||"Untitled note"}),t.pinned&&e.jsx("span",{title:"Pinned",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center text-fg-tertiary",children:e.jsx(U,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsxs(d,{as:"div",variant:"meta",weight:"medium",tone:"secondary",children:["Deleted ",P(t.deletedAt)]})}),t.tagNames.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.tagNames.map(n=>e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"rounded-full border border-border-subtle bg-hover-subtle px-2 py-0.5",children:n},`${t.id}-${n}`))}),t.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-3 whitespace-pre-wrap break-words",children:t.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(j,{variant:"subtle",size:"sm",onClick:()=>h(t.id),children:"View content"}),e.jsx(j,{variant:"subtle",size:"sm",isLoading:w.isPending&&w.variables===t.id,onClick:()=>w.mutate(t.id),children:"Restore"}),e.jsx(j,{variant:"soft-danger",size:"sm",isLoading:p.isPending&&p.variables===t.id,onClick:()=>q(t.id),children:"Delete now"})]})]})},t.id))}),u.totalCount>m&&e.jsx(V,{page:a,last:Math.ceil(u.totalCount/m),onChange:t=>{o({search:n=>({...n,page:t})})}})]}),e.jsx(Z,{note:A,onClose:()=>h(null)}),e.jsx(Y,{isOpen:!!x,title:g.title,description:g.description,references:x?.backReferences??[],confirmLabel:g.confirmLabel,confirmVariant:g.confirmVariant,onClose:()=>b(null),onConfirm:D})]})},oe=()=>{const{page:a}=v.useSearch();return e.jsx(M,{fallback:e.jsx(ee,{}),errorTitle:"Failed to load trash",errorDescription:"Retry loading deleted notes",resetKeys:[a],children:e.jsx(te,{})})};export{oe as default};
@@ -1,4 +1,4 @@
1
- import{j as y}from"./note-vendor-i1M2FSI2.js";import{h as u,a6 as f,q as n,w as R,X as $}from"./index-DYlYUrjH.js";import{a as l}from"./graph-vendor-CUxe67Lr.js";const g=(e={})=>({limit:e.limit??10,offset:e.offset??0}),D=async(e,t)=>u(`
1
+ import{j as y}from"./note-vendor-uuJO2MTD.js";import{h as u,a6 as f,q as n,k as R,m as $}from"./index-B43ulIPo.js";import{a as l}from"./graph-vendor-CUxe67Lr.js";const g=(e={})=>({limit:e.limit??10,offset:e.offset??0}),D=async(e,t)=>u(`
2
2
  query FetchNoteReminders($noteId: ID!, $pagination: PaginationInput) {
3
3
  noteReminders(noteId: $noteId, pagination: $pagination) {
4
4
  totalCount
@@ -79,4 +79,4 @@ import{j as y}from"./note-vendor-i1M2FSI2.js";import{h as u,a6 as f,q as n,w as
79
79
  mutation DeleteReminder($id: ID!) {
80
80
  deleteReminder(id: $id)
81
81
  }
82
- `,{id:e});function K({noteId:e,searchParams:t,render:a}){const{data:o}=f({queryKey:e?n.reminders.note(e,t):n.reminders.upcoming(t),queryFn:async()=>{if(e){const r=await D(e,t);if(r.type==="error")throw r;return r.noteReminders}const i=await A(t);if(i.type==="error")throw i;return i.upcomingReminders}});return y.jsx(y.Fragment,{children:a(o)})}function P(){const e=$(),t=R(),a=l.useCallback(async(r,m,d="medium",s,c)=>{const p=await q({noteId:r,reminderDate:m,priority:d,content:c});if(p.type==="error"){e(p.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(r),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),s&&s()},[t,e]),o=l.useCallback(async(r,m,d,s)=>{const c=await I({id:r,...d});if(c.type==="error"){e(c.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(m),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),s&&s()},[t,e]),i=l.useCallback(async(r,m,d)=>{const s=await x(r);if(s.type==="error"){e(s.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(m),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),d&&d()},[t,e]);return{onCreate:a,onUpdate:o,onDelete:i}}export{K as R,P as u};
82
+ `,{id:e});function P({noteId:e,searchParams:t,render:a}){const{data:o}=f({queryKey:e?n.reminders.note(e,t):n.reminders.upcoming(t),queryFn:async()=>{if(e){const r=await D(e,t);if(r.type==="error")throw r;return r.noteReminders}const i=await A(t);if(i.type==="error")throw i;return i.upcomingReminders}});return y.jsx(y.Fragment,{children:a(o)})}function w(){const e=$(),t=R(),a=l.useCallback(async(r,m,d="medium",s,c)=>{const p=await q({noteId:r,reminderDate:m,priority:d,content:c});if(p.type==="error"){e(p.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(r),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),s&&s()},[t,e]),o=l.useCallback(async(r,m,d,s)=>{const c=await I({id:r,...d});if(c.type==="error"){e(c.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(m),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),s&&s()},[t,e]),i=l.useCallback(async(r,m,d)=>{const s=await x(r);if(s.type==="error"){e(s.errors[0].message);return}await Promise.all([t.invalidateQueries({queryKey:n.reminders.noteAllPages(m),exact:!1}),t.invalidateQueries({queryKey:n.reminders.upcomingAllPages(),exact:!1}),t.invalidateQueries({queryKey:n.reminders.inDateRangeAll(),exact:!1})]),d&&d()},[t,e]);return{onCreate:a,onUpdate:o,onDelete:i}}export{P as R,w as u};
@@ -6,11 +6,11 @@
6
6
  <link rel="icon" type="image/png" href="/icon.png" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>Ocean Brain</title>
9
- <script type="module" crossorigin src="/assets/index-DYlYUrjH.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-B43ulIPo.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/graph-vendor-CUxe67Lr.js">
11
- <link rel="modulepreload" crossorigin href="/assets/note-core-Z6kqulGB.js">
12
- <link rel="modulepreload" crossorigin href="/assets/note-vendor-i1M2FSI2.js">
13
- <link rel="stylesheet" crossorigin href="/assets/index-Cd81UxEh.css">
11
+ <link rel="modulepreload" crossorigin href="/assets/note-core-DMZcZ4yV.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/note-vendor-uuJO2MTD.js">
13
+ <link rel="stylesheet" crossorigin href="/assets/index-CDjYEIVf.css">
14
14
  </head>
15
15
 
16
16
  <body>
@@ -2,7 +2,11 @@ import models from "../../../models.js";
2
2
  import {
3
3
  blocksToMarkdown,
4
4
  countReferenceInlinesFromContentJson,
5
+ extractLiteralAngleBracketTextTokens,
5
6
  extractTagIdsFromContentJson,
7
+ hasLiteralAngleBracketTextTokenLoss,
8
+ hasNumericTildeRangeMarkerLoss,
9
+ hasNumericTildeRangeMarkers,
6
10
  hasUnsupportedMarkdownBlocks,
7
11
  markdownToBlocksJson
8
12
  } from "../../../modules/blocknote.js";
@@ -77,6 +81,11 @@ const referenceStructureFailure = () => ({
77
81
  reason: "REFERENCE_STRUCTURE_DECREASED",
78
82
  message: "The markdown write would reduce structured note reference links."
79
83
  });
84
+ const markdownImportLossyFailure = () => ({
85
+ status: "failed",
86
+ reason: "MARKDOWN_IMPORT_LOSSY",
87
+ message: "The markdown write would lose literal text during Markdown import."
88
+ });
80
89
  const invalidPropertyInputFailure = (error) => ({
81
90
  status: "failed",
82
91
  reason: "INVALID_PROPERTY_INPUT",
@@ -124,6 +133,14 @@ const getUnsupportedSourceFailure = (deps, note) => {
124
133
  };
125
134
  const applyMarkdownPlan = async (deps, input) => {
126
135
  const content = await deps.parseMarkdownToContentJson(input.plan.afterMarkdown);
136
+ const literalAngleBracketTokens = extractLiteralAngleBracketTextTokens(input.plan.afterMarkdown);
137
+ const shouldCheckMarkdownImportLoss = literalAngleBracketTokens.length > 0 || hasNumericTildeRangeMarkers(input.plan.afterMarkdown);
138
+ if (shouldCheckMarkdownImportLoss) {
139
+ const importedMarkdown = await deps.renderMarkdown(content);
140
+ if (hasLiteralAngleBracketTextTokenLoss(input.plan.afterMarkdown, importedMarkdown) || hasNumericTildeRangeMarkerLoss(input.plan.afterMarkdown, importedMarkdown)) {
141
+ return markdownImportLossyFailure();
142
+ }
143
+ }
127
144
  const beforeReferenceCount = deps.countReferenceInlines?.(input.beforeContentJson) ?? 0;
128
145
  const afterReferenceCount = deps.countReferenceInlines?.(content) ?? 0;
129
146
  if (input.policy?.preserveReferences !== false && afterReferenceCount < beforeReferenceCount) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/note/services/markdown-intent-write.ts"],"sourcesContent":["import models, { type NoteLayout } from '~/models.js';\nimport {\n blocksToMarkdown,\n countReferenceInlinesFromContentJson,\n extractTagIdsFromContentJson,\n hasUnsupportedMarkdownBlocks,\n markdownToBlocksJson,\n} from '~/modules/blocknote.js';\nimport type {\n MarkdownAppendPlanResult,\n MarkdownChangeDryRun,\n MarkdownChangeFailure,\n MarkdownChangePlan,\n MarkdownPatchOperation,\n MarkdownPatchPlanResult,\n MarkdownPatchSelector,\n MarkdownReplacePlanResult,\n} from './markdown-patch.js';\nimport {\n buildMarkdownAppendPlan,\n buildMarkdownPatchPlan,\n buildMarkdownReplacePlan,\n calculateMarkdownSha256,\n} from './markdown-patch.js';\nimport {\n InvalidNotePropertyInputError,\n type NotePropertiesByKeyPatchInput,\n type NotePropertiesPatchInput,\n resolveNotePropertiesPatchValueTypes,\n updateNotePropertiesWithVersionGuardAndSnapshot,\n validateNotePropertiesPatchValues,\n} from './properties.js';\nimport { MCP_SNAPSHOT_META } from './snapshot.js';\nimport { type GuardedNoteWriteResult, updateNoteWithVersionGuardAndSnapshot } from './write.js';\nimport {\n isInvalidNoteVersionError,\n isMissingNoteVersionError,\n isNoteVersionConflictError,\n parseNoteVersion,\n} from './write-conflict.js';\n\ninterface MarkdownIntentNoteRecord {\n id: number;\n title: string;\n content: string;\n layout: NoteLayout;\n updatedAt: Date;\n}\n\ninterface MarkdownIntentWriteDeps {\n findNoteById: (id: number) => Promise<MarkdownIntentNoteRecord | null>;\n renderMarkdown: (contentJson: string) => Promise<string>;\n parseMarkdownToContentJson: (markdown: string) => Promise<string>;\n extractTagIds: (contentJson: string) => string[];\n countReferenceInlines?: (contentJson: string) => number;\n hasUnsupportedMarkdownBlocks?: (contentJson: string) => boolean;\n updateNote: (input: {\n id: number;\n data: {\n title?: string;\n content?: string;\n layout?: NoteLayout;\n tagIds?: number[];\n };\n expectedUpdatedAt: string;\n snapshotMeta?: string;\n force?: boolean;\n }) => Promise<GuardedNoteWriteResult | null>;\n resolvePropertyPatch?: (patch: NotePropertiesByKeyPatchInput) => Promise<NotePropertiesPatchInput>;\n validatePropertyPatch?: (patch: NotePropertiesPatchInput) => Promise<NotePropertiesPatchInput>;\n updateProperties?: (input: {\n id: number;\n patch: NotePropertiesPatchInput;\n expectedUpdatedAt: string;\n noteData?: {\n title?: string;\n layout?: NoteLayout;\n };\n snapshotMeta?: string;\n }) => Promise<{\n note: {\n id: number;\n title: string;\n layout: NoteLayout;\n updatedAt: Date;\n };\n snapshot: unknown;\n } | null>;\n}\n\nexport interface MarkdownWritePolicy {\n allowNoop?: boolean;\n maxChangedChars?: number;\n maxChangedLines?: number;\n preserveReferences?: boolean | 'warn';\n preserveTags?: boolean | 'warn';\n}\n\nexport interface PatchNoteMarkdownInput {\n id: number;\n expectedUpdatedAt?: string;\n baseMarkdownSha256?: string;\n intent: string;\n selector: MarkdownPatchSelector;\n operation: MarkdownPatchOperation;\n policy?: MarkdownWritePolicy;\n dryRun?: boolean;\n}\n\nexport interface AppendNoteMarkdownInput {\n id: number;\n expectedUpdatedAt?: string;\n baseMarkdownSha256?: string;\n intent: string;\n insertion: string;\n placement?:\n | {\n type: 'end';\n }\n | {\n type: 'after_heading';\n heading: string;\n level?: number;\n };\n separator?: '\\n\\n' | '\\n';\n policy?: MarkdownWritePolicy;\n dryRun?: boolean;\n}\n\nexport interface ReplaceNoteMarkdownInput {\n id: number;\n expectedUpdatedAt?: string;\n baseMarkdownSha256?: string;\n intent: string;\n replacement: string;\n policy?: MarkdownWritePolicy;\n dryRun?: boolean;\n}\n\nexport interface UpdateNoteMetadataInput {\n id: number;\n expectedUpdatedAt: string;\n title?: string;\n layout?: NoteLayout;\n properties?: NotePropertiesByKeyPatchInput;\n}\n\nexport interface AppliedMarkdownWriteResult {\n status: 'applied';\n note: {\n id: string;\n updatedAt: string;\n };\n change: {\n summary: string;\n changedLineCount: number;\n changedCharCount: number;\n };\n snapshot: {\n id: string;\n label: string;\n createdAt: string;\n };\n}\n\nexport interface MetadataUpdatePreview {\n status: 'dry_run';\n note: {\n id: string;\n title: string;\n updatedAt: string;\n };\n proposed: {\n title?: string;\n layout?: NoteLayout;\n properties?: NotePropertiesPatchInput;\n };\n warnings: string[];\n}\n\nexport interface AppliedMetadataUpdateResult {\n status: 'applied';\n note: {\n id: string;\n title: string;\n layout: NoteLayout;\n updatedAt: string;\n };\n snapshot: {\n id: string;\n label: string;\n createdAt: string;\n };\n}\n\nexport type MarkdownIntentWriteResult =\n | MarkdownChangeDryRun\n | AppliedMarkdownWriteResult\n | MarkdownChangeFailure\n | Extract<MarkdownPatchPlanResult, { status: 'needs_disambiguation' }>;\n\nexport type MetadataUpdateResult = MetadataUpdatePreview | AppliedMetadataUpdateResult | MarkdownChangeFailure;\n\nconst serializeNoteSnapshot = async (\n note: MarkdownIntentNoteRecord,\n renderMarkdown: (contentJson: string) => Promise<string>,\n) => {\n return {\n id: String(note.id),\n title: note.title,\n updatedAt: note.updatedAt.toISOString(),\n markdown: await renderMarkdown(note.content),\n };\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null;\n};\n\nconst serializeSnapshot = (snapshot: unknown) => {\n const meta = isRecord(snapshot) && isRecord(snapshot.meta) ? snapshot.meta : {};\n const label = typeof meta.label === 'string' ? meta.label : 'MCP';\n\n return {\n id: isRecord(snapshot) && snapshot.id !== undefined ? String(snapshot.id) : '',\n label,\n createdAt: isRecord(snapshot) && typeof snapshot.createdAt === 'string' ? snapshot.createdAt : '',\n };\n};\n\nconst toDryRun = (plan: MarkdownChangePlan): MarkdownChangeDryRun => ({\n status: 'dry_run',\n note: plan.note,\n ...(plan.match ? { match: plan.match } : {}),\n ...(plan.placement ? { placement: plan.placement } : {}),\n proposed: plan.proposed,\n warnings: plan.warnings,\n});\n\nconst toTagIds = (tagIds: string[]) => {\n return tagIds.map((tagId) => Number(tagId)).filter((tagId) => Number.isSafeInteger(tagId) && tagId > 0);\n};\n\nconst baselineMismatchFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'BASELINE_MISMATCH',\n message: 'The markdown write baseline does not match the current note.',\n});\n\nconst missingBaselineFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'MISSING_BASELINE',\n message: 'expectedUpdatedAt or baseMarkdownSha256 is required for markdown writes.',\n});\n\nconst unsupportedMarkdownStructureFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'UNSUPPORTED_MARKDOWN_STRUCTURE',\n message: 'This note contains BlockNote content that cannot be safely represented as Markdown.',\n});\n\nconst referenceStructureFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'REFERENCE_STRUCTURE_DECREASED',\n message: 'The markdown write would reduce structured note reference links.',\n});\n\nconst invalidPropertyInputFailure = (error: InvalidNotePropertyInputError): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'INVALID_PROPERTY_INPUT',\n message: error.message,\n});\n\nconst mapGuardedWriteError = (error: unknown): MarkdownChangeFailure | null => {\n if (isNoteVersionConflictError(error) || isInvalidNoteVersionError(error)) {\n return baselineMismatchFailure();\n }\n\n if (isMissingNoteVersionError(error)) {\n return missingBaselineFailure();\n }\n\n return null;\n};\n\nconst resolveMetadataPropertyPatch = async (\n deps: MarkdownIntentWriteDeps,\n patch: NotePropertiesByKeyPatchInput | undefined,\n): Promise<NotePropertiesPatchInput | MarkdownChangeFailure | undefined> => {\n if (patch === undefined) {\n return undefined;\n }\n\n if (!deps.resolvePropertyPatch || !deps.validatePropertyPatch) {\n throw new Error('Metadata property patch dependencies are not configured.');\n }\n\n try {\n const resolvedPatch = await deps.resolvePropertyPatch(patch);\n return deps.validatePropertyPatch(resolvedPatch);\n } catch (error) {\n if (error instanceof InvalidNotePropertyInputError) {\n return invalidPropertyInputFailure(error);\n }\n\n throw error;\n }\n};\n\nconst noteVersionMatches = (expectedUpdatedAt: string | undefined, currentUpdatedAt: Date) => {\n try {\n const expectedTimestamp = parseNoteVersion(expectedUpdatedAt);\n\n return expectedTimestamp !== null && expectedTimestamp === currentUpdatedAt.getTime();\n } catch {\n return false;\n }\n};\n\nconst getUnsupportedSourceFailure = (deps: MarkdownIntentWriteDeps, note: MarkdownIntentNoteRecord) => {\n if (deps.hasUnsupportedMarkdownBlocks?.(note.content)) {\n return unsupportedMarkdownStructureFailure();\n }\n\n return null;\n};\n\nconst applyMarkdownPlan = async (\n deps: MarkdownIntentWriteDeps,\n input: {\n noteId: number;\n noteUpdatedAt: string;\n beforeContentJson: string;\n plan: Extract<MarkdownPatchPlanResult, { status: 'dry_run' }>;\n expectedUpdatedAt?: string;\n policy?: MarkdownWritePolicy;\n summary: string;\n force?: boolean;\n },\n): Promise<AppliedMarkdownWriteResult | MarkdownChangeFailure> => {\n const content = await deps.parseMarkdownToContentJson(input.plan.afterMarkdown);\n const beforeReferenceCount = deps.countReferenceInlines?.(input.beforeContentJson) ?? 0;\n const afterReferenceCount = deps.countReferenceInlines?.(content) ?? 0;\n\n if (input.policy?.preserveReferences !== false && afterReferenceCount < beforeReferenceCount) {\n return referenceStructureFailure();\n }\n\n const tagIds = toTagIds(deps.extractTagIds(content));\n let updateResult: GuardedNoteWriteResult | null;\n\n try {\n updateResult = await deps.updateNote({\n id: input.noteId,\n data: {\n content,\n tagIds,\n },\n expectedUpdatedAt: input.expectedUpdatedAt ?? input.noteUpdatedAt,\n snapshotMeta: MCP_SNAPSHOT_META,\n ...(input.force ? { force: true } : {}),\n });\n } catch (error) {\n const mappedError = mapGuardedWriteError(error);\n\n if (mappedError) {\n return mappedError;\n }\n\n throw error;\n }\n\n if (!updateResult) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n return {\n status: 'applied',\n note: {\n id: String(updateResult.note.id),\n updatedAt: updateResult.note.updatedAt.toISOString(),\n },\n change: {\n summary: input.summary,\n changedLineCount: input.plan.proposed.changedLineCount,\n changedCharCount: input.plan.proposed.changedCharCount,\n },\n snapshot: serializeSnapshot(updateResult.snapshot),\n };\n};\n\nconst mapPlanResult = async (\n deps: MarkdownIntentWriteDeps,\n input: {\n noteId: number;\n noteUpdatedAt: string;\n beforeContentJson: string;\n plan: MarkdownPatchPlanResult | MarkdownAppendPlanResult | MarkdownReplacePlanResult;\n dryRun?: boolean;\n expectedUpdatedAt?: string;\n policy?: MarkdownWritePolicy;\n summary: string;\n force?: boolean;\n },\n): Promise<MarkdownIntentWriteResult> => {\n if (input.plan.status !== 'dry_run') {\n return input.plan;\n }\n\n if (input.dryRun ?? true) {\n return toDryRun(input.plan);\n }\n\n return applyMarkdownPlan(deps, {\n noteId: input.noteId,\n noteUpdatedAt: input.noteUpdatedAt,\n beforeContentJson: input.beforeContentJson,\n plan: input.plan,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.summary,\n ...(input.force ? { force: true } : {}),\n });\n};\n\nexport const createMarkdownIntentWriteService = (deps: MarkdownIntentWriteDeps) => ({\n patchNoteMarkdown: async (input: PatchNoteMarkdownInput): Promise<MarkdownIntentWriteResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n const unsupportedFailure = getUnsupportedSourceFailure(deps, note);\n\n if (unsupportedFailure) {\n return unsupportedFailure;\n }\n\n const noteSnapshot = await serializeNoteSnapshot(note, deps.renderMarkdown);\n const plan = buildMarkdownPatchPlan({\n note: noteSnapshot,\n expectedUpdatedAt: input.expectedUpdatedAt,\n baseMarkdownSha256: input.baseMarkdownSha256,\n intent: input.intent,\n selector: input.selector,\n operation: input.operation,\n policy: input.policy,\n });\n\n return mapPlanResult(deps, {\n noteId: input.id,\n noteUpdatedAt: noteSnapshot.updatedAt,\n beforeContentJson: note.content,\n plan,\n dryRun: input.dryRun,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.intent,\n });\n },\n\n appendNoteMarkdown: async (input: AppendNoteMarkdownInput): Promise<MarkdownIntentWriteResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n const unsupportedFailure = getUnsupportedSourceFailure(deps, note);\n\n if (unsupportedFailure) {\n return unsupportedFailure;\n }\n\n const noteSnapshot = await serializeNoteSnapshot(note, deps.renderMarkdown);\n const plan = buildMarkdownAppendPlan({\n note: noteSnapshot,\n expectedUpdatedAt: input.expectedUpdatedAt,\n baseMarkdownSha256: input.baseMarkdownSha256,\n intent: input.intent,\n insertion: input.insertion,\n placement: input.placement,\n separator: input.separator,\n policy: input.policy,\n });\n\n return mapPlanResult(deps, {\n noteId: input.id,\n noteUpdatedAt: noteSnapshot.updatedAt,\n beforeContentJson: note.content,\n plan,\n dryRun: input.dryRun,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.intent,\n });\n },\n\n replaceNoteMarkdown: async (input: ReplaceNoteMarkdownInput): Promise<MarkdownIntentWriteResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n const unsupportedFailure = getUnsupportedSourceFailure(deps, note);\n\n if (unsupportedFailure) {\n return unsupportedFailure;\n }\n\n const noteSnapshot = await serializeNoteSnapshot(note, deps.renderMarkdown);\n const plan = buildMarkdownReplacePlan({\n note: noteSnapshot,\n expectedUpdatedAt: input.expectedUpdatedAt,\n baseMarkdownSha256: input.baseMarkdownSha256,\n intent: input.intent,\n replacement: input.replacement,\n policy: input.policy,\n });\n\n return mapPlanResult(deps, {\n noteId: input.id,\n noteUpdatedAt: noteSnapshot.updatedAt,\n beforeContentJson: note.content,\n plan,\n dryRun: input.dryRun,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.intent,\n });\n },\n\n updateNoteMetadata: async (input: UpdateNoteMetadataInput): Promise<MetadataUpdateResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n if (!noteVersionMatches(input.expectedUpdatedAt, note.updatedAt)) {\n return {\n status: 'failed',\n reason: input.expectedUpdatedAt ? 'BASELINE_MISMATCH' : 'MISSING_BASELINE',\n message: 'The metadata update baseline does not match the current note.',\n };\n }\n\n const nextTitle = input.title?.trim();\n const resolvedPropertyPatch = await resolveMetadataPropertyPatch(deps, input.properties);\n\n if (resolvedPropertyPatch && 'status' in resolvedPropertyPatch) {\n return resolvedPropertyPatch;\n }\n\n if (input.title !== undefined && !nextTitle) {\n return {\n status: 'failed',\n reason: 'EMPTY_REPLACEMENT',\n message: 'Note title must not be empty.',\n };\n }\n\n if (\n nextTitle === note.title &&\n (input.layout === undefined || input.layout === note.layout) &&\n resolvedPropertyPatch === undefined\n ) {\n return {\n status: 'failed',\n reason: 'NOOP',\n message: 'The metadata update would not change the note.',\n };\n }\n\n return {\n status: 'dry_run',\n note: {\n id: String(note.id),\n title: note.title,\n updatedAt: note.updatedAt.toISOString(),\n },\n proposed: {\n ...(nextTitle !== undefined ? { title: nextTitle } : {}),\n ...(input.layout !== undefined ? { layout: input.layout } : {}),\n ...(resolvedPropertyPatch ? { properties: resolvedPropertyPatch } : {}),\n },\n warnings: [],\n };\n },\n\n applyNoteMetadata: async (input: UpdateNoteMetadataInput): Promise<MetadataUpdateResult> => {\n const preview = await createMarkdownIntentWriteService(deps).updateNoteMetadata(input);\n\n if (preview.status !== 'dry_run') {\n return preview;\n }\n\n if (input.properties !== undefined) {\n if (!deps.updateProperties) {\n throw new Error('Metadata property write dependency is not configured.');\n }\n\n let updateResult: Awaited<ReturnType<NonNullable<MarkdownIntentWriteDeps['updateProperties']>>>;\n\n try {\n updateResult = await deps.updateProperties({\n id: input.id,\n patch: preview.proposed.properties ?? { set: [], deleteKeys: [] },\n expectedUpdatedAt: input.expectedUpdatedAt,\n noteData: {\n ...(preview.proposed.title !== undefined ? { title: preview.proposed.title } : {}),\n ...(preview.proposed.layout !== undefined ? { layout: preview.proposed.layout } : {}),\n },\n snapshotMeta: MCP_SNAPSHOT_META,\n });\n } catch (error) {\n const mappedError = mapGuardedWriteError(error);\n\n if (mappedError) {\n return mappedError;\n }\n\n if (error instanceof InvalidNotePropertyInputError) {\n return invalidPropertyInputFailure(error);\n }\n\n throw error;\n }\n\n if (!updateResult) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n return {\n status: 'applied',\n note: {\n id: String(updateResult.note.id),\n title: updateResult.note.title,\n layout: updateResult.note.layout,\n updatedAt: updateResult.note.updatedAt.toISOString(),\n },\n snapshot: serializeSnapshot(updateResult.snapshot),\n };\n }\n\n let updateResult: GuardedNoteWriteResult | null;\n\n try {\n updateResult = await deps.updateNote({\n id: input.id,\n data: {\n ...(preview.proposed.title !== undefined ? { title: preview.proposed.title } : {}),\n ...(preview.proposed.layout !== undefined ? { layout: preview.proposed.layout } : {}),\n },\n expectedUpdatedAt: input.expectedUpdatedAt,\n snapshotMeta: MCP_SNAPSHOT_META,\n });\n } catch (error) {\n const mappedError = mapGuardedWriteError(error);\n\n if (mappedError) {\n return mappedError;\n }\n\n throw error;\n }\n\n if (!updateResult) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n return {\n status: 'applied',\n note: {\n id: String(updateResult.note.id),\n title: updateResult.note.title,\n layout: updateResult.note.layout,\n updatedAt: updateResult.note.updatedAt.toISOString(),\n },\n snapshot: serializeSnapshot(updateResult.snapshot),\n };\n },\n});\n\nexport const defaultMarkdownIntentWriteService = createMarkdownIntentWriteService({\n findNoteById: (id) =>\n models.note.findUnique({\n where: { id },\n select: {\n id: true,\n title: true,\n content: true,\n layout: true,\n updatedAt: true,\n },\n }),\n renderMarkdown: blocksToMarkdown,\n parseMarkdownToContentJson: markdownToBlocksJson,\n extractTagIds: extractTagIdsFromContentJson,\n countReferenceInlines: countReferenceInlinesFromContentJson,\n hasUnsupportedMarkdownBlocks,\n updateNote: updateNoteWithVersionGuardAndSnapshot,\n resolvePropertyPatch: resolveNotePropertiesPatchValueTypes,\n validatePropertyPatch: validateNotePropertiesPatchValues,\n updateProperties: updateNotePropertiesWithVersionGuardAndSnapshot,\n});\n\nexport const patchNoteMarkdown = async (input: PatchNoteMarkdownInput) => {\n return defaultMarkdownIntentWriteService.patchNoteMarkdown(input);\n};\n\nexport const appendNoteMarkdown = async (input: AppendNoteMarkdownInput) => {\n return defaultMarkdownIntentWriteService.appendNoteMarkdown(input);\n};\n\nexport const replaceNoteMarkdown = async (input: ReplaceNoteMarkdownInput) => {\n return defaultMarkdownIntentWriteService.replaceNoteMarkdown(input);\n};\n\nexport const updateNoteMetadata = async (input: UpdateNoteMetadataInput & { dryRun?: boolean }) => {\n if (input.dryRun ?? true) {\n return defaultMarkdownIntentWriteService.updateNoteMetadata(input);\n }\n\n return defaultMarkdownIntentWriteService.applyNoteMetadata(input);\n};\n\nexport const calculateNoteMarkdownSha256 = (markdown: string) => {\n return calculateMarkdownSha256(markdown);\n};\n"],"mappings":"AAAA,OAAO,YAAiC;AACxC;AAAA,EACI;AAAA,EACA;AAA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,KAAK,EAAE;AAAA,QAC/B,OAAO,aAAa,KAAK;AAAA,QACzB,QAAQ,aAAa,KAAK;AAAA,QAC1B,WAAW,aAAa,KAAK,UAAU,YAAY;AAAA,MACvD;AAAA,MACA,UAAU,kBAAkB,aAAa,QAAQ;AAAA,IACrD;AAAA,EACJ;AACJ;AAEO,MAAM,oCAAoC,iCAAiC;AAAA,EAC9E,cAAc,CAAC,OACX,OAAO,KAAK,WAAW;AAAA,IACnB,OAAO,EAAE,GAAG;AAAA,IACZ,QAAQ;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,WAAW;AAAA,IACf;AAAA,EACJ,CAAC;AAAA,EACL,gBAAgB;AAAA,EAChB,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB;AAAA,EACA,YAAY;AAAA,EACZ,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,kBAAkB;AACtB,CAAC;AAEM,MAAM,oBAAoB,OAAO,UAAkC;AACtE,SAAO,kCAAkC,kBAAkB,KAAK;AACpE;AAEO,MAAM,qBAAqB,OAAO,UAAmC;AACxE,SAAO,kCAAkC,mBAAmB,KAAK;AACrE;AAEO,MAAM,sBAAsB,OAAO,UAAoC;AAC1E,SAAO,kCAAkC,oBAAoB,KAAK;AACtE;AAEO,MAAM,qBAAqB,OAAO,UAA0D;AAC/F,MAAI,MAAM,UAAU,MAAM;AACtB,WAAO,kCAAkC,mBAAmB,KAAK;AAAA,EACrE;AAEA,SAAO,kCAAkC,kBAAkB,KAAK;AACpE;AAEO,MAAM,8BAA8B,CAAC,aAAqB;AAC7D,SAAO,wBAAwB,QAAQ;AAC3C;","names":["updateResult"]}
1
+ {"version":3,"sources":["../../../../src/features/note/services/markdown-intent-write.ts"],"sourcesContent":["import models, { type NoteLayout } from '~/models.js';\nimport {\n blocksToMarkdown,\n countReferenceInlinesFromContentJson,\n extractLiteralAngleBracketTextTokens,\n extractTagIdsFromContentJson,\n hasLiteralAngleBracketTextTokenLoss,\n hasNumericTildeRangeMarkerLoss,\n hasNumericTildeRangeMarkers,\n hasUnsupportedMarkdownBlocks,\n markdownToBlocksJson,\n} from '~/modules/blocknote.js';\nimport type {\n MarkdownAppendPlanResult,\n MarkdownChangeDryRun,\n MarkdownChangeFailure,\n MarkdownChangePlan,\n MarkdownPatchOperation,\n MarkdownPatchPlanResult,\n MarkdownPatchSelector,\n MarkdownReplacePlanResult,\n} from './markdown-patch.js';\nimport {\n buildMarkdownAppendPlan,\n buildMarkdownPatchPlan,\n buildMarkdownReplacePlan,\n calculateMarkdownSha256,\n} from './markdown-patch.js';\nimport {\n InvalidNotePropertyInputError,\n type NotePropertiesByKeyPatchInput,\n type NotePropertiesPatchInput,\n resolveNotePropertiesPatchValueTypes,\n updateNotePropertiesWithVersionGuardAndSnapshot,\n validateNotePropertiesPatchValues,\n} from './properties.js';\nimport { MCP_SNAPSHOT_META } from './snapshot.js';\nimport { type GuardedNoteWriteResult, updateNoteWithVersionGuardAndSnapshot } from './write.js';\nimport {\n isInvalidNoteVersionError,\n isMissingNoteVersionError,\n isNoteVersionConflictError,\n parseNoteVersion,\n} from './write-conflict.js';\n\ninterface MarkdownIntentNoteRecord {\n id: number;\n title: string;\n content: string;\n layout: NoteLayout;\n updatedAt: Date;\n}\n\ninterface MarkdownIntentWriteDeps {\n findNoteById: (id: number) => Promise<MarkdownIntentNoteRecord | null>;\n renderMarkdown: (contentJson: string) => Promise<string>;\n parseMarkdownToContentJson: (markdown: string) => Promise<string>;\n extractTagIds: (contentJson: string) => string[];\n countReferenceInlines?: (contentJson: string) => number;\n hasUnsupportedMarkdownBlocks?: (contentJson: string) => boolean;\n updateNote: (input: {\n id: number;\n data: {\n title?: string;\n content?: string;\n layout?: NoteLayout;\n tagIds?: number[];\n };\n expectedUpdatedAt: string;\n snapshotMeta?: string;\n force?: boolean;\n }) => Promise<GuardedNoteWriteResult | null>;\n resolvePropertyPatch?: (patch: NotePropertiesByKeyPatchInput) => Promise<NotePropertiesPatchInput>;\n validatePropertyPatch?: (patch: NotePropertiesPatchInput) => Promise<NotePropertiesPatchInput>;\n updateProperties?: (input: {\n id: number;\n patch: NotePropertiesPatchInput;\n expectedUpdatedAt: string;\n noteData?: {\n title?: string;\n layout?: NoteLayout;\n };\n snapshotMeta?: string;\n }) => Promise<{\n note: {\n id: number;\n title: string;\n layout: NoteLayout;\n updatedAt: Date;\n };\n snapshot: unknown;\n } | null>;\n}\n\nexport interface MarkdownWritePolicy {\n allowNoop?: boolean;\n maxChangedChars?: number;\n maxChangedLines?: number;\n preserveReferences?: boolean | 'warn';\n preserveTags?: boolean | 'warn';\n}\n\nexport interface PatchNoteMarkdownInput {\n id: number;\n expectedUpdatedAt?: string;\n baseMarkdownSha256?: string;\n intent: string;\n selector: MarkdownPatchSelector;\n operation: MarkdownPatchOperation;\n policy?: MarkdownWritePolicy;\n dryRun?: boolean;\n}\n\nexport interface AppendNoteMarkdownInput {\n id: number;\n expectedUpdatedAt?: string;\n baseMarkdownSha256?: string;\n intent: string;\n insertion: string;\n placement?:\n | {\n type: 'end';\n }\n | {\n type: 'after_heading';\n heading: string;\n level?: number;\n };\n separator?: '\\n\\n' | '\\n';\n policy?: MarkdownWritePolicy;\n dryRun?: boolean;\n}\n\nexport interface ReplaceNoteMarkdownInput {\n id: number;\n expectedUpdatedAt?: string;\n baseMarkdownSha256?: string;\n intent: string;\n replacement: string;\n policy?: MarkdownWritePolicy;\n dryRun?: boolean;\n}\n\nexport interface UpdateNoteMetadataInput {\n id: number;\n expectedUpdatedAt: string;\n title?: string;\n layout?: NoteLayout;\n properties?: NotePropertiesByKeyPatchInput;\n}\n\nexport interface AppliedMarkdownWriteResult {\n status: 'applied';\n note: {\n id: string;\n updatedAt: string;\n };\n change: {\n summary: string;\n changedLineCount: number;\n changedCharCount: number;\n };\n snapshot: {\n id: string;\n label: string;\n createdAt: string;\n };\n}\n\nexport interface MetadataUpdatePreview {\n status: 'dry_run';\n note: {\n id: string;\n title: string;\n updatedAt: string;\n };\n proposed: {\n title?: string;\n layout?: NoteLayout;\n properties?: NotePropertiesPatchInput;\n };\n warnings: string[];\n}\n\nexport interface AppliedMetadataUpdateResult {\n status: 'applied';\n note: {\n id: string;\n title: string;\n layout: NoteLayout;\n updatedAt: string;\n };\n snapshot: {\n id: string;\n label: string;\n createdAt: string;\n };\n}\n\nexport type MarkdownIntentWriteResult =\n | MarkdownChangeDryRun\n | AppliedMarkdownWriteResult\n | MarkdownChangeFailure\n | Extract<MarkdownPatchPlanResult, { status: 'needs_disambiguation' }>;\n\nexport type MetadataUpdateResult = MetadataUpdatePreview | AppliedMetadataUpdateResult | MarkdownChangeFailure;\n\nconst serializeNoteSnapshot = async (\n note: MarkdownIntentNoteRecord,\n renderMarkdown: (contentJson: string) => Promise<string>,\n) => {\n return {\n id: String(note.id),\n title: note.title,\n updatedAt: note.updatedAt.toISOString(),\n markdown: await renderMarkdown(note.content),\n };\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null;\n};\n\nconst serializeSnapshot = (snapshot: unknown) => {\n const meta = isRecord(snapshot) && isRecord(snapshot.meta) ? snapshot.meta : {};\n const label = typeof meta.label === 'string' ? meta.label : 'MCP';\n\n return {\n id: isRecord(snapshot) && snapshot.id !== undefined ? String(snapshot.id) : '',\n label,\n createdAt: isRecord(snapshot) && typeof snapshot.createdAt === 'string' ? snapshot.createdAt : '',\n };\n};\n\nconst toDryRun = (plan: MarkdownChangePlan): MarkdownChangeDryRun => ({\n status: 'dry_run',\n note: plan.note,\n ...(plan.match ? { match: plan.match } : {}),\n ...(plan.placement ? { placement: plan.placement } : {}),\n proposed: plan.proposed,\n warnings: plan.warnings,\n});\n\nconst toTagIds = (tagIds: string[]) => {\n return tagIds.map((tagId) => Number(tagId)).filter((tagId) => Number.isSafeInteger(tagId) && tagId > 0);\n};\n\nconst baselineMismatchFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'BASELINE_MISMATCH',\n message: 'The markdown write baseline does not match the current note.',\n});\n\nconst missingBaselineFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'MISSING_BASELINE',\n message: 'expectedUpdatedAt or baseMarkdownSha256 is required for markdown writes.',\n});\n\nconst unsupportedMarkdownStructureFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'UNSUPPORTED_MARKDOWN_STRUCTURE',\n message: 'This note contains BlockNote content that cannot be safely represented as Markdown.',\n});\n\nconst referenceStructureFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'REFERENCE_STRUCTURE_DECREASED',\n message: 'The markdown write would reduce structured note reference links.',\n});\n\nconst markdownImportLossyFailure = (): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'MARKDOWN_IMPORT_LOSSY',\n message: 'The markdown write would lose literal text during Markdown import.',\n});\n\nconst invalidPropertyInputFailure = (error: InvalidNotePropertyInputError): MarkdownChangeFailure => ({\n status: 'failed',\n reason: 'INVALID_PROPERTY_INPUT',\n message: error.message,\n});\n\nconst mapGuardedWriteError = (error: unknown): MarkdownChangeFailure | null => {\n if (isNoteVersionConflictError(error) || isInvalidNoteVersionError(error)) {\n return baselineMismatchFailure();\n }\n\n if (isMissingNoteVersionError(error)) {\n return missingBaselineFailure();\n }\n\n return null;\n};\n\nconst resolveMetadataPropertyPatch = async (\n deps: MarkdownIntentWriteDeps,\n patch: NotePropertiesByKeyPatchInput | undefined,\n): Promise<NotePropertiesPatchInput | MarkdownChangeFailure | undefined> => {\n if (patch === undefined) {\n return undefined;\n }\n\n if (!deps.resolvePropertyPatch || !deps.validatePropertyPatch) {\n throw new Error('Metadata property patch dependencies are not configured.');\n }\n\n try {\n const resolvedPatch = await deps.resolvePropertyPatch(patch);\n return deps.validatePropertyPatch(resolvedPatch);\n } catch (error) {\n if (error instanceof InvalidNotePropertyInputError) {\n return invalidPropertyInputFailure(error);\n }\n\n throw error;\n }\n};\n\nconst noteVersionMatches = (expectedUpdatedAt: string | undefined, currentUpdatedAt: Date) => {\n try {\n const expectedTimestamp = parseNoteVersion(expectedUpdatedAt);\n\n return expectedTimestamp !== null && expectedTimestamp === currentUpdatedAt.getTime();\n } catch {\n return false;\n }\n};\n\nconst getUnsupportedSourceFailure = (deps: MarkdownIntentWriteDeps, note: MarkdownIntentNoteRecord) => {\n if (deps.hasUnsupportedMarkdownBlocks?.(note.content)) {\n return unsupportedMarkdownStructureFailure();\n }\n\n return null;\n};\n\nconst applyMarkdownPlan = async (\n deps: MarkdownIntentWriteDeps,\n input: {\n noteId: number;\n noteUpdatedAt: string;\n beforeContentJson: string;\n plan: Extract<MarkdownPatchPlanResult, { status: 'dry_run' }>;\n expectedUpdatedAt?: string;\n policy?: MarkdownWritePolicy;\n summary: string;\n force?: boolean;\n },\n): Promise<AppliedMarkdownWriteResult | MarkdownChangeFailure> => {\n const content = await deps.parseMarkdownToContentJson(input.plan.afterMarkdown);\n const literalAngleBracketTokens = extractLiteralAngleBracketTextTokens(input.plan.afterMarkdown);\n const shouldCheckMarkdownImportLoss =\n literalAngleBracketTokens.length > 0 || hasNumericTildeRangeMarkers(input.plan.afterMarkdown);\n\n if (shouldCheckMarkdownImportLoss) {\n const importedMarkdown = await deps.renderMarkdown(content);\n\n if (\n hasLiteralAngleBracketTextTokenLoss(input.plan.afterMarkdown, importedMarkdown) ||\n hasNumericTildeRangeMarkerLoss(input.plan.afterMarkdown, importedMarkdown)\n ) {\n return markdownImportLossyFailure();\n }\n }\n\n const beforeReferenceCount = deps.countReferenceInlines?.(input.beforeContentJson) ?? 0;\n const afterReferenceCount = deps.countReferenceInlines?.(content) ?? 0;\n\n if (input.policy?.preserveReferences !== false && afterReferenceCount < beforeReferenceCount) {\n return referenceStructureFailure();\n }\n\n const tagIds = toTagIds(deps.extractTagIds(content));\n let updateResult: GuardedNoteWriteResult | null;\n\n try {\n updateResult = await deps.updateNote({\n id: input.noteId,\n data: {\n content,\n tagIds,\n },\n expectedUpdatedAt: input.expectedUpdatedAt ?? input.noteUpdatedAt,\n snapshotMeta: MCP_SNAPSHOT_META,\n ...(input.force ? { force: true } : {}),\n });\n } catch (error) {\n const mappedError = mapGuardedWriteError(error);\n\n if (mappedError) {\n return mappedError;\n }\n\n throw error;\n }\n\n if (!updateResult) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n return {\n status: 'applied',\n note: {\n id: String(updateResult.note.id),\n updatedAt: updateResult.note.updatedAt.toISOString(),\n },\n change: {\n summary: input.summary,\n changedLineCount: input.plan.proposed.changedLineCount,\n changedCharCount: input.plan.proposed.changedCharCount,\n },\n snapshot: serializeSnapshot(updateResult.snapshot),\n };\n};\n\nconst mapPlanResult = async (\n deps: MarkdownIntentWriteDeps,\n input: {\n noteId: number;\n noteUpdatedAt: string;\n beforeContentJson: string;\n plan: MarkdownPatchPlanResult | MarkdownAppendPlanResult | MarkdownReplacePlanResult;\n dryRun?: boolean;\n expectedUpdatedAt?: string;\n policy?: MarkdownWritePolicy;\n summary: string;\n force?: boolean;\n },\n): Promise<MarkdownIntentWriteResult> => {\n if (input.plan.status !== 'dry_run') {\n return input.plan;\n }\n\n if (input.dryRun ?? true) {\n return toDryRun(input.plan);\n }\n\n return applyMarkdownPlan(deps, {\n noteId: input.noteId,\n noteUpdatedAt: input.noteUpdatedAt,\n beforeContentJson: input.beforeContentJson,\n plan: input.plan,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.summary,\n ...(input.force ? { force: true } : {}),\n });\n};\n\nexport const createMarkdownIntentWriteService = (deps: MarkdownIntentWriteDeps) => ({\n patchNoteMarkdown: async (input: PatchNoteMarkdownInput): Promise<MarkdownIntentWriteResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n const unsupportedFailure = getUnsupportedSourceFailure(deps, note);\n\n if (unsupportedFailure) {\n return unsupportedFailure;\n }\n\n const noteSnapshot = await serializeNoteSnapshot(note, deps.renderMarkdown);\n const plan = buildMarkdownPatchPlan({\n note: noteSnapshot,\n expectedUpdatedAt: input.expectedUpdatedAt,\n baseMarkdownSha256: input.baseMarkdownSha256,\n intent: input.intent,\n selector: input.selector,\n operation: input.operation,\n policy: input.policy,\n });\n\n return mapPlanResult(deps, {\n noteId: input.id,\n noteUpdatedAt: noteSnapshot.updatedAt,\n beforeContentJson: note.content,\n plan,\n dryRun: input.dryRun,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.intent,\n });\n },\n\n appendNoteMarkdown: async (input: AppendNoteMarkdownInput): Promise<MarkdownIntentWriteResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n const unsupportedFailure = getUnsupportedSourceFailure(deps, note);\n\n if (unsupportedFailure) {\n return unsupportedFailure;\n }\n\n const noteSnapshot = await serializeNoteSnapshot(note, deps.renderMarkdown);\n const plan = buildMarkdownAppendPlan({\n note: noteSnapshot,\n expectedUpdatedAt: input.expectedUpdatedAt,\n baseMarkdownSha256: input.baseMarkdownSha256,\n intent: input.intent,\n insertion: input.insertion,\n placement: input.placement,\n separator: input.separator,\n policy: input.policy,\n });\n\n return mapPlanResult(deps, {\n noteId: input.id,\n noteUpdatedAt: noteSnapshot.updatedAt,\n beforeContentJson: note.content,\n plan,\n dryRun: input.dryRun,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.intent,\n });\n },\n\n replaceNoteMarkdown: async (input: ReplaceNoteMarkdownInput): Promise<MarkdownIntentWriteResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n const unsupportedFailure = getUnsupportedSourceFailure(deps, note);\n\n if (unsupportedFailure) {\n return unsupportedFailure;\n }\n\n const noteSnapshot = await serializeNoteSnapshot(note, deps.renderMarkdown);\n const plan = buildMarkdownReplacePlan({\n note: noteSnapshot,\n expectedUpdatedAt: input.expectedUpdatedAt,\n baseMarkdownSha256: input.baseMarkdownSha256,\n intent: input.intent,\n replacement: input.replacement,\n policy: input.policy,\n });\n\n return mapPlanResult(deps, {\n noteId: input.id,\n noteUpdatedAt: noteSnapshot.updatedAt,\n beforeContentJson: note.content,\n plan,\n dryRun: input.dryRun,\n expectedUpdatedAt: input.expectedUpdatedAt,\n policy: input.policy,\n summary: input.intent,\n });\n },\n\n updateNoteMetadata: async (input: UpdateNoteMetadataInput): Promise<MetadataUpdateResult> => {\n const note = await deps.findNoteById(input.id);\n\n if (!note) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n if (!noteVersionMatches(input.expectedUpdatedAt, note.updatedAt)) {\n return {\n status: 'failed',\n reason: input.expectedUpdatedAt ? 'BASELINE_MISMATCH' : 'MISSING_BASELINE',\n message: 'The metadata update baseline does not match the current note.',\n };\n }\n\n const nextTitle = input.title?.trim();\n const resolvedPropertyPatch = await resolveMetadataPropertyPatch(deps, input.properties);\n\n if (resolvedPropertyPatch && 'status' in resolvedPropertyPatch) {\n return resolvedPropertyPatch;\n }\n\n if (input.title !== undefined && !nextTitle) {\n return {\n status: 'failed',\n reason: 'EMPTY_REPLACEMENT',\n message: 'Note title must not be empty.',\n };\n }\n\n if (\n nextTitle === note.title &&\n (input.layout === undefined || input.layout === note.layout) &&\n resolvedPropertyPatch === undefined\n ) {\n return {\n status: 'failed',\n reason: 'NOOP',\n message: 'The metadata update would not change the note.',\n };\n }\n\n return {\n status: 'dry_run',\n note: {\n id: String(note.id),\n title: note.title,\n updatedAt: note.updatedAt.toISOString(),\n },\n proposed: {\n ...(nextTitle !== undefined ? { title: nextTitle } : {}),\n ...(input.layout !== undefined ? { layout: input.layout } : {}),\n ...(resolvedPropertyPatch ? { properties: resolvedPropertyPatch } : {}),\n },\n warnings: [],\n };\n },\n\n applyNoteMetadata: async (input: UpdateNoteMetadataInput): Promise<MetadataUpdateResult> => {\n const preview = await createMarkdownIntentWriteService(deps).updateNoteMetadata(input);\n\n if (preview.status !== 'dry_run') {\n return preview;\n }\n\n if (input.properties !== undefined) {\n if (!deps.updateProperties) {\n throw new Error('Metadata property write dependency is not configured.');\n }\n\n let updateResult: Awaited<ReturnType<NonNullable<MarkdownIntentWriteDeps['updateProperties']>>>;\n\n try {\n updateResult = await deps.updateProperties({\n id: input.id,\n patch: preview.proposed.properties ?? { set: [], deleteKeys: [] },\n expectedUpdatedAt: input.expectedUpdatedAt,\n noteData: {\n ...(preview.proposed.title !== undefined ? { title: preview.proposed.title } : {}),\n ...(preview.proposed.layout !== undefined ? { layout: preview.proposed.layout } : {}),\n },\n snapshotMeta: MCP_SNAPSHOT_META,\n });\n } catch (error) {\n const mappedError = mapGuardedWriteError(error);\n\n if (mappedError) {\n return mappedError;\n }\n\n if (error instanceof InvalidNotePropertyInputError) {\n return invalidPropertyInputFailure(error);\n }\n\n throw error;\n }\n\n if (!updateResult) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n return {\n status: 'applied',\n note: {\n id: String(updateResult.note.id),\n title: updateResult.note.title,\n layout: updateResult.note.layout,\n updatedAt: updateResult.note.updatedAt.toISOString(),\n },\n snapshot: serializeSnapshot(updateResult.snapshot),\n };\n }\n\n let updateResult: GuardedNoteWriteResult | null;\n\n try {\n updateResult = await deps.updateNote({\n id: input.id,\n data: {\n ...(preview.proposed.title !== undefined ? { title: preview.proposed.title } : {}),\n ...(preview.proposed.layout !== undefined ? { layout: preview.proposed.layout } : {}),\n },\n expectedUpdatedAt: input.expectedUpdatedAt,\n snapshotMeta: MCP_SNAPSHOT_META,\n });\n } catch (error) {\n const mappedError = mapGuardedWriteError(error);\n\n if (mappedError) {\n return mappedError;\n }\n\n throw error;\n }\n\n if (!updateResult) {\n return {\n status: 'failed',\n reason: 'TARGET_NOT_FOUND',\n message: 'The requested note was not found.',\n };\n }\n\n return {\n status: 'applied',\n note: {\n id: String(updateResult.note.id),\n title: updateResult.note.title,\n layout: updateResult.note.layout,\n updatedAt: updateResult.note.updatedAt.toISOString(),\n },\n snapshot: serializeSnapshot(updateResult.snapshot),\n };\n },\n});\n\nexport const defaultMarkdownIntentWriteService = createMarkdownIntentWriteService({\n findNoteById: (id) =>\n models.note.findUnique({\n where: { id },\n select: {\n id: true,\n title: true,\n content: true,\n layout: true,\n updatedAt: true,\n },\n }),\n renderMarkdown: blocksToMarkdown,\n parseMarkdownToContentJson: markdownToBlocksJson,\n extractTagIds: extractTagIdsFromContentJson,\n countReferenceInlines: countReferenceInlinesFromContentJson,\n hasUnsupportedMarkdownBlocks,\n updateNote: updateNoteWithVersionGuardAndSnapshot,\n resolvePropertyPatch: resolveNotePropertiesPatchValueTypes,\n validatePropertyPatch: validateNotePropertiesPatchValues,\n updateProperties: updateNotePropertiesWithVersionGuardAndSnapshot,\n});\n\nexport const patchNoteMarkdown = async (input: PatchNoteMarkdownInput) => {\n return defaultMarkdownIntentWriteService.patchNoteMarkdown(input);\n};\n\nexport const appendNoteMarkdown = async (input: AppendNoteMarkdownInput) => {\n return defaultMarkdownIntentWriteService.appendNoteMarkdown(input);\n};\n\nexport const replaceNoteMarkdown = async (input: ReplaceNoteMarkdownInput) => {\n return defaultMarkdownIntentWriteService.replaceNoteMarkdown(input);\n};\n\nexport const updateNoteMetadata = async (input: UpdateNoteMetadataInput & { dryRun?: boolean }) => {\n if (input.dryRun ?? true) {\n return defaultMarkdownIntentWriteService.updateNoteMetadata(input);\n }\n\n return defaultMarkdownIntentWriteService.applyNoteMetadata(input);\n};\n\nexport const calculateNoteMarkdownSha256 = (markdown: string) => {\n return calculateMarkdownSha256(markdown);\n};\n"],"mappings":"AAAA,OAAO,YAAiC;AACxC;AAAA,EACI;AAAA,EACA;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