botnote 0.2.10 → 0.2.11

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.
@@ -478,8 +478,8 @@ Error generating stack: `+v.message+`
478
478
  `))}function u(x,k,b,w){const S=b.enter("tableCell"),Q=b.enter("phrasing"),$=b.containerPhrasing(x,{...w,before:s,after:s});return Q(),S(),$}function h(x,k){return q8(x,{align:k,alignDelimiters:r,padding:t,stringLength:i})}function f(x,k,b){const w=x.children;let S=-1;const Q=[],$=k.enter("table");for(;++S<w.length;)Q[S]=p(w[S],k,b);return $(),Q}function p(x,k,b){const w=x.children;let S=-1;const Q=[],$=k.enter("tableRow");for(;++S<w.length;)Q[S]=u(w[S],x,k,b);return $(),Q}function g(x,k,b){let w=dE.inlineCode(x,k,b);return b.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function MV(){return{exit:{taskListCheckValueChecked:IP,taskListCheckValueUnchecked:IP,paragraph:RV}}}function AV(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:NV}}}function IP(n){const e=this.stack[this.stack.length-2];e.type,e.checked=n.type==="taskListCheckValueChecked"}function RV(n){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const t=this.stack[this.stack.length-1];t.type;const r=t.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,l;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){l=o;break}}l===t&&(r.value=r.value.slice(1),r.value.length===0?t.children.shift():t.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,t.position.start=Object.assign({},r.position.start)))}}this.exit(n)}function NV(n,e,t,r){const i=n.children[0],s=typeof n.checked=="boolean"&&i&&i.type==="paragraph",l="["+(n.checked?"x":" ")+"] ",o=t.createTracker(r);s&&o.move(l);let u=dE.listItem(n,e,t,{...r,...o.current()});return s&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),u;function h(f){return f+l}}function LV(){return[p8(),N8(),I8(),PV(),MV()]}function _V(n){return{extensions:[m8(),L8(n),z8(),EV(n),AV()]}}const DV={tokenize:WV,partial:!0},pE={tokenize:qV,partial:!0},mE={tokenize:VV,partial:!0},gE={tokenize:FV,partial:!0},IV={tokenize:YV,partial:!0},OE={name:"wwwAutolink",tokenize:XV,previous:yE},xE={name:"protocolAutolink",tokenize:BV,previous:kE},Ji={name:"emailAutolink",tokenize:ZV,previous:vE},Si={};function zV(){return{text:Si}}let Ol=48;for(;Ol<123;)Si[Ol]=Ji,Ol++,Ol===58?Ol=65:Ol===91&&(Ol=97);Si[43]=Ji;Si[45]=Ji;Si[46]=Ji;Si[95]=Ji;Si[72]=[Ji,xE];Si[104]=[Ji,xE];Si[87]=[Ji,OE];Si[119]=[Ji,OE];function ZV(n,e,t){const r=this;let i,s;return l;function l(p){return!fy(p)||!vE.call(r,r.previous)||Y0(r.events)?t(p):(n.enter("literalAutolink"),n.enter("literalAutolinkEmail"),o(p))}function o(p){return fy(p)?(n.consume(p),o):p===64?(n.consume(p),u):t(p)}function u(p){return p===46?n.check(IV,f,h)(p):p===45||p===95||mn(p)?(s=!0,n.consume(p),u):f(p)}function h(p){return n.consume(p),i=!0,u}function f(p){return s&&i&&Qn(r.previous)?(n.exit("literalAutolinkEmail"),n.exit("literalAutolink"),e(p)):t(p)}}function XV(n,e,t){const r=this;return i;function i(l){return l!==87&&l!==119||!yE.call(r,r.previous)||Y0(r.events)?t(l):(n.enter("literalAutolink"),n.enter("literalAutolinkWww"),n.check(DV,n.attempt(pE,n.attempt(mE,s),t),t)(l))}function s(l){return n.exit("literalAutolinkWww"),n.exit("literalAutolink"),e(l)}}function BV(n,e,t){const r=this;let i="",s=!1;return l;function l(p){return(p===72||p===104)&&kE.call(r,r.previous)&&!Y0(r.events)?(n.enter("literalAutolink"),n.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),n.consume(p),o):t(p)}function o(p){if(Qn(p)&&i.length<5)return i+=String.fromCodePoint(p),n.consume(p),o;if(p===58){const g=i.toLowerCase();if(g==="http"||g==="https")return n.consume(p),u}return t(p)}function u(p){return p===47?(n.consume(p),s?h:(s=!0,u)):t(p)}function h(p){return p===null||Id(p)||ft(p)||ql(p)||dp(p)?t(p):n.attempt(pE,n.attempt(mE,f),t)(p)}function f(p){return n.exit("literalAutolinkHttp"),n.exit("literalAutolink"),e(p)}}function WV(n,e,t){let r=0;return i;function i(l){return(l===87||l===119)&&r<3?(r++,n.consume(l),i):l===46&&r===3?(n.consume(l),s):t(l)}function s(l){return l===null?t(l):e(l)}}function qV(n,e,t){let r,i,s;return l;function l(h){return h===46||h===95?n.check(gE,u,o)(h):h===null||ft(h)||ql(h)||h!==45&&dp(h)?u(h):(s=!0,n.consume(h),l)}function o(h){return h===95?r=!0:(i=r,r=void 0),n.consume(h),l}function u(h){return i||r||!s?t(h):e(h)}}function VV(n,e){let t=0,r=0;return i;function i(l){return l===40?(t++,n.consume(l),i):l===41&&r<t?s(l):l===33||l===34||l===38||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===60||l===63||l===93||l===95||l===126?n.check(gE,e,s)(l):l===null||ft(l)||ql(l)?e(l):(n.consume(l),i)}function s(l){return l===41&&r++,n.consume(l),i}}function FV(n,e,t){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(n.consume(o),r):o===38?(n.consume(o),s):o===93?(n.consume(o),i):o===60||o===null||ft(o)||ql(o)?e(o):t(o)}function i(o){return o===null||o===40||o===91||ft(o)||ql(o)?e(o):r(o)}function s(o){return Qn(o)?l(o):t(o)}function l(o){return o===59?(n.consume(o),r):Qn(o)?(n.consume(o),l):t(o)}}function YV(n,e,t){return r;function r(s){return n.consume(s),i}function i(s){return mn(s)?t(s):e(s)}}function yE(n){return n===null||n===40||n===42||n===95||n===91||n===93||n===126||ft(n)}function kE(n){return!Qn(n)}function vE(n){return!(n===47||fy(n))}function fy(n){return n===43||n===45||n===46||n===95||mn(n)}function Y0(n){let e=n.length,t=!1;for(;e--;){const r=n[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){t=!0;break}if(r._gfmAutolinkLiteralWalkedInto){t=!1;break}}return n.length>0&&!t&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}const UV={tokenize:rF,partial:!0};function GV(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:eF,continuation:{tokenize:tF},exit:nF}},text:{91:{name:"gfmFootnoteCall",tokenize:JV},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:HV,resolveTo:KV}}}}function HV(n,e,t){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let l;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){l=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return o;function o(u){if(!l||!l._balanced)return t(u);const h=Wr(r.sliceSerialize({start:l.end,end:r.now()}));return h.codePointAt(0)!==94||!s.includes(h.slice(1))?t(u):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(u),n.exit("gfmFootnoteCallLabelMarker"),e(u))}}function KV(n,e){let t=n.length;for(;t--;)if(n[t][1].type==="labelImage"&&n[t][0]==="enter"){n[t][1];break}n[t+1][1].type="data",n[t+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},n[t+3][1].start),end:Object.assign({},n[n.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},n[t+3][1].end),end:Object.assign({},n[t+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},n[n.length-1][1].start)},l={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[n[t+1],n[t+2],["enter",r,e],n[t+3],n[t+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",l,e],["exit",l,e],["exit",s,e],n[n.length-2],n[n.length-1],["exit",r,e]];return n.splice(t,n.length-t+1,...o),n}function JV(n,e,t){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,l;return o;function o(p){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(p),n.exit("gfmFootnoteCallLabelMarker"),u}function u(p){return p!==94?t(p):(n.enter("gfmFootnoteCallMarker"),n.consume(p),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",h)}function h(p){if(s>999||p===93&&!l||p===null||p===91||ft(p))return t(p);if(p===93){n.exit("chunkString");const g=n.exit("gfmFootnoteCallString");return i.includes(Wr(r.sliceSerialize(g)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(p),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),e):t(p)}return ft(p)||(l=!0),s++,n.consume(p),p===92?f:h}function f(p){return p===91||p===92||p===93?(n.consume(p),s++,h):h(p)}}function eF(n,e,t){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,l=0,o;return u;function u(k){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(k){return k===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",f):t(k)}function f(k){if(l>999||k===93&&!o||k===null||k===91||ft(k))return t(k);if(k===93){n.exit("chunkString");const b=n.exit("gfmFootnoteDefinitionLabelString");return s=Wr(r.sliceSerialize(b)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(k),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),g}return ft(k)||(o=!0),l++,n.consume(k),k===92?p:f}function p(k){return k===91||k===92||k===93?(n.consume(k),l++,f):f(k)}function g(k){return k===58?(n.enter("definitionMarker"),n.consume(k),n.exit("definitionMarker"),i.includes(s)||i.push(s),He(n,x,"gfmFootnoteDefinitionWhitespace")):t(k)}function x(k){return e(k)}}function tF(n,e,t){return n.check(Fc,e,n.attempt(UV,e,t))}function nF(n){n.exit("gfmFootnoteDefinition")}function rF(n,e,t){const r=this;return He(n,i,"gfmFootnoteDefinitionIndent",5);function i(s){const l=r.events[r.events.length-1];return l&&l[1].type==="gfmFootnoteDefinitionIndent"&&l[2].sliceSerialize(l[1],!0).length===4?e(s):t(s)}}function iF(n){let t=(n||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return t==null&&(t=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(l,o){let u=-1;for(;++u<l.length;)if(l[u][0]==="enter"&&l[u][1].type==="strikethroughSequenceTemporary"&&l[u][1]._close){let h=u;for(;h--;)if(l[h][0]==="exit"&&l[h][1].type==="strikethroughSequenceTemporary"&&l[h][1]._open&&l[u][1].end.offset-l[u][1].start.offset===l[h][1].end.offset-l[h][1].start.offset){l[u][1].type="strikethroughSequence",l[h][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},l[h][1].start),end:Object.assign({},l[u][1].end)},p={type:"strikethroughText",start:Object.assign({},l[h][1].end),end:Object.assign({},l[u][1].start)},g=[["enter",f,o],["enter",l[h][1],o],["exit",l[h][1],o],["enter",p,o]],x=o.parser.constructs.insideSpan.null;x&&fr(g,g.length,0,pp(x,l.slice(h+1,u),o)),fr(g,g.length,0,[["exit",p,o],["enter",l[u][1],o],["exit",l[u][1],o],["exit",f,o]]),fr(l,h-1,u-h+3,g),u=h+g.length-2;break}}for(u=-1;++u<l.length;)l[u][1].type==="strikethroughSequenceTemporary"&&(l[u][1].type="data");return l}function s(l,o,u){const h=this.previous,f=this.events;let p=0;return g;function g(k){return h===126&&f[f.length-1][1].type!=="characterEscape"?u(k):(l.enter("strikethroughSequenceTemporary"),x(k))}function x(k){const b=ga(h);if(k===126)return p>1?u(k):(l.consume(k),p++,x);if(p<2&&!t)return u(k);const w=l.exit("strikethroughSequenceTemporary"),S=ga(k);return w._open=!S||S===2&&!!b,w._close=!b||b===2&&!!S,o(k)}}}class sF{constructor(){this.map=[]}add(e,t,r){lF(this,e,t,r)}consume(e){if(this.map.sort(function(s,l){return s[0]-l[0]}),this.map.length===0)return;let t=this.map.length;const r=[];for(;t>0;)t-=1,r.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function lF(n,e,t,r){let i=0;if(!(t===0&&r.length===0)){for(;i<n.map.length;){if(n.map[i][0]===e){n.map[i][1]+=t,n.map[i][2].push(...r);return}i+=1}n.map.push([e,t,r])}}function oF(n,e){let t=!1;const r=[];for(;e<n.length;){const i=n[e];if(t){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(n[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(n[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(t=!0);e+=1}return r}function aF(){return{flow:{null:{name:"table",tokenize:uF,resolveAll:cF}}}}function uF(n,e,t){const r=this;let i=0,s=0,l;return o;function o(N){let U=r.events.length-1;for(;U>-1;){const J=r.events[U][1].type;if(J==="lineEnding"||J==="linePrefix")U--;else break}const V=U>-1?r.events[U][1].type:null,se=V==="tableHead"||V==="tableRow"?T:u;return se===T&&r.parser.lazy[r.now().line]?t(N):se(N)}function u(N){return n.enter("tableHead"),n.enter("tableRow"),h(N)}function h(N){return N===124||(l=!0,s+=1),f(N)}function f(N){return N===null?t(N):Ee(N)?s>1?(s=0,r.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(N),n.exit("lineEnding"),x):t(N):Ve(N)?He(n,f,"whitespace")(N):(s+=1,l&&(l=!1,i+=1),N===124?(n.enter("tableCellDivider"),n.consume(N),n.exit("tableCellDivider"),l=!0,f):(n.enter("data"),p(N)))}function p(N){return N===null||N===124||ft(N)?(n.exit("data"),f(N)):(n.consume(N),N===92?g:p)}function g(N){return N===92||N===124?(n.consume(N),p):p(N)}function x(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?t(N):(n.enter("tableDelimiterRow"),l=!1,Ve(N)?He(n,k,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):k(N))}function k(N){return N===45||N===58?w(N):N===124?(l=!0,n.enter("tableCellDivider"),n.consume(N),n.exit("tableCellDivider"),b):I(N)}function b(N){return Ve(N)?He(n,w,"whitespace")(N):w(N)}function w(N){return N===58?(s+=1,l=!0,n.enter("tableDelimiterMarker"),n.consume(N),n.exit("tableDelimiterMarker"),S):N===45?(s+=1,S(N)):N===null||Ee(N)?R(N):I(N)}function S(N){return N===45?(n.enter("tableDelimiterFiller"),Q(N)):I(N)}function Q(N){return N===45?(n.consume(N),Q):N===58?(l=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(N),n.exit("tableDelimiterMarker"),$):(n.exit("tableDelimiterFiller"),$(N))}function $(N){return Ve(N)?He(n,R,"whitespace")(N):R(N)}function R(N){return N===124?k(N):N===null||Ee(N)?!l||i!==s?I(N):(n.exit("tableDelimiterRow"),n.exit("tableHead"),e(N)):I(N)}function I(N){return t(N)}function T(N){return n.enter("tableRow"),X(N)}function X(N){return N===124?(n.enter("tableCellDivider"),n.consume(N),n.exit("tableCellDivider"),X):N===null||Ee(N)?(n.exit("tableRow"),e(N)):Ve(N)?He(n,X,"whitespace")(N):(n.enter("data"),Z(N))}function Z(N){return N===null||N===124||ft(N)?(n.exit("data"),X(N)):(n.consume(N),N===92?K:Z)}function K(N){return N===92||N===124?(n.consume(N),Z):Z(N)}}function cF(n,e){let t=-1,r=!0,i=0,s=[0,0,0,0],l=[0,0,0,0],o=!1,u=0,h,f,p;const g=new sF;for(;++t<n.length;){const x=n[t],k=x[1];x[0]==="enter"?k.type==="tableHead"?(o=!1,u!==0&&(zP(g,e,u,h,f),f=void 0,u=0),h={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},g.add(t,0,[["enter",h,e]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(r=!0,p=void 0,s=[0,0,0,0],l=[0,t+1,0,0],o&&(o=!1,f={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},g.add(t,0,[["enter",f,e]])),i=k.type==="tableDelimiterRow"?2:f?3:1):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(r=!1,l[2]===0&&(s[1]!==0&&(l[0]=l[1],p=Lf(g,e,s,i,void 0,p),s=[0,0,0,0]),l[2]=t)):k.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(l[0]=l[1],p=Lf(g,e,s,i,void 0,p)),s=l,l=[s[1],t,0,0])):k.type==="tableHead"?(o=!0,u=t):k.type==="tableRow"||k.type==="tableDelimiterRow"?(u=t,s[1]!==0?(l[0]=l[1],p=Lf(g,e,s,i,t,p)):l[1]!==0&&(p=Lf(g,e,l,i,t,p)),i=0):i&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(l[3]=t)}for(u!==0&&zP(g,e,u,h,f),g.consume(e.events),t=-1;++t<e.events.length;){const x=e.events[t];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=oF(e.events,t))}return n}function Lf(n,e,t,r,i,s){const l=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";t[0]!==0&&(s.end=Object.assign({},Mo(e.events,t[0])),n.add(t[0],0,[["exit",s,e]]));const u=Mo(e.events,t[1]);if(s={type:l,start:Object.assign({},u),end:Object.assign({},u)},n.add(t[1],0,[["enter",s,e]]),t[2]!==0){const h=Mo(e.events,t[2]),f=Mo(e.events,t[3]),p={type:o,start:Object.assign({},h),end:Object.assign({},f)};if(n.add(t[2],0,[["enter",p,e]]),r!==2){const g=e.events[t[2]],x=e.events[t[3]];if(g[1].end=Object.assign({},x[1].end),g[1].type="chunkText",g[1].contentType="text",t[3]>t[2]+1){const k=t[2]+1,b=t[3]-t[2]-1;n.add(k,b,[])}}n.add(t[3]+1,0,[["exit",p,e]])}return i!==void 0&&(s.end=Object.assign({},Mo(e.events,i)),n.add(i,0,[["exit",s,e]]),s=void 0),s}function zP(n,e,t,r,i){const s=[],l=Mo(e.events,t);i&&(i.end=Object.assign({},l),s.push(["exit",i,e])),r.end=Object.assign({},l),s.push(["exit",r,e]),n.add(t+1,0,s)}function Mo(n,e){const t=n[e],r=t[0]==="enter"?"start":"end";return t[1][r]}const hF={name:"tasklistCheck",tokenize:dF};function fF(){return{text:{91:hF}}}function dF(n,e,t){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?t(u):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(u),n.exit("taskListCheckMarker"),s)}function s(u){return ft(u)?(n.enter("taskListCheckValueUnchecked"),n.consume(u),n.exit("taskListCheckValueUnchecked"),l):u===88||u===120?(n.enter("taskListCheckValueChecked"),n.consume(u),n.exit("taskListCheckValueChecked"),l):t(u)}function l(u){return u===93?(n.enter("taskListCheckMarker"),n.consume(u),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),o):t(u)}function o(u){return Ee(u)?e(u):Ve(u)?n.check({tokenize:pF},e,t)(u):t(u)}}function pF(n,e,t){return He(n,r,"whitespace");function r(i){return i===null?t(i):e(i)}}function mF(n){return Ej([zV(),GV(),iF(n),aF(),fF()])}const gF={};function bE(n){const e=this,t=n||gF,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),l=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(mF(t)),s.push(LV()),l.push(_V(t))}const ZP=600;function OF(n,e){const t=n===""?[]:n.split(`
479
479
  `),r=e===""?[]:e.split(`
480
480
  `);if(t.length>ZP||r.length>ZP)return[...t.map(f=>({type:"del",text:f})),...r.map(f=>({type:"add",text:f}))];const i=t.length,s=r.length,l=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let f=i-1;f>=0;f--)for(let p=s-1;p>=0;p--)l[f][p]=t[f]===r[p]?l[f+1][p+1]+1:Math.max(l[f+1][p],l[f][p+1]);const o=[];let u=0,h=0;for(;u<i&&h<s;)t[u]===r[h]?(o.push({type:"same",text:t[u]}),u++,h++):l[u+1][h]>=l[u][h+1]?(o.push({type:"del",text:t[u]}),u++):(o.push({type:"add",text:r[h]}),h++);for(;u<i;)o.push({type:"del",text:t[u++]});for(;h<s;)o.push({type:"add",text:r[h++]});return o}function xF(n,e=2){const t=new Array(n.length).fill(!1);n.forEach((s,l)=>{if(s.type!=="same")for(let o=Math.max(0,l-e);o<=Math.min(n.length-1,l+e);o++)t[o]=!0});const r=[];let i=0;return n.forEach((s,l)=>{t[l]?(i>0&&r.push({type:"skip",count:i}),i=0,r.push(s)):i++}),i>0&&r.push({type:"skip",count:i}),r}const yF="",wE="/login",kF=new Set(["/v1/auth/login","/v1/auth/logout","/v1/auth/whoami","/health"]);function vF(n){if(typeof window>"u"||window.location.pathname===wE)return!1;for(const e of kF)if(n.startsWith(e))return!1;return!0}async function Ze(n,e){const t=new Headers(e==null?void 0:e.headers);(e==null?void 0:e.body)!==void 0&&(e==null?void 0:e.body)!==null&&!t.has("content-type")&&t.set("content-type","application/json");const r=await fetch(`${yF}${n}`,{...e,credentials:"include",headers:t});if(r.status===401&&vF(n)){const i=window.location.pathname+window.location.search;throw window.location.href=`${wE}?next=${encodeURIComponent(i)}`,new Error("unauthenticated")}if(!r.ok){let i="";try{i=await r.text()}catch{}throw new Error(`${(e==null?void 0:e.method)??"GET"} ${n} -> ${r.status} ${i}`)}if(r.status!==204)return await r.json()}const We={health:()=>Ze("/health"),listProjects:(n={})=>{const e=new URLSearchParams;n.includeArchived&&e.set("includeArchived","true");const t=e.size?`?${e.toString()}`:"";return Ze(`/v1/projects${t}`)},getProject:n=>Ze(`/v1/projects/${n}`),getProjectByKey:n=>Ze(`/v1/projects/by-key/${encodeURIComponent(n)}`),createProject:n=>Ze("/v1/projects",{method:"POST",body:JSON.stringify(n)}),updateProject:(n,e)=>Ze(`/v1/projects/${n}`,{method:"PATCH",body:JSON.stringify(e)}),openingBrief:(n,e=10)=>Ze(`/v1/projects/${n}/opening-brief`,{method:"POST",body:JSON.stringify({recentLimit:e})}),getEntity:n=>Ze(`/v1/entities/${n}`),entityRevisions:n=>Ze(`/v1/entities/${n}/revisions`),getEntityByKey:(n,e)=>Ze(`/v1/projects/by-key/${encodeURIComponent(n)}/entities/by-seq/${e}`),createTask:n=>Ze("/v1/tasks",{method:"POST",body:JSON.stringify(n)}),createNote:n=>Ze("/v1/notes",{method:"POST",body:JSON.stringify(n)}),writeEntity:n=>{if(n.kind==="task"){const{kind:r,...i}=n;return Ze("/v1/tasks",{method:"POST",body:JSON.stringify(i)})}const{kind:e,...t}=n;return Ze("/v1/notes",{method:"POST",body:JSON.stringify(t)})},updateEntity:(n,e)=>Ze(`/v1/entities/${n}`,{method:"PATCH",body:JSON.stringify(e)}),deleteEntity:n=>Ze(`/v1/entities/${n}`,{method:"DELETE"}),purgeEntity:n=>Ze(`/v1/entities/${n}?purge=true`,{method:"DELETE"}),restoreEntity:n=>Ze(`/v1/entities/${n}/restore`,{method:"POST"}),listTrash:(n=100)=>Ze(`/v1/trash?limit=${n}`),relatedEntities:n=>Ze(`/v1/entities/${n}/related`),recent:(n={})=>Ze("/v1/recent",{method:"POST",body:JSON.stringify(n)}),search:n=>Ze("/v1/search",{method:"POST",body:JSON.stringify(n)}),listFeedback:(n={})=>{const e=new URLSearchParams;n.category&&e.set("category",n.category),n.status&&e.set("status",n.status),n.limit&&e.set("limit",String(n.limit));const t=e.size?`?${e.toString()}`:"";return Ze(`/v1/feedback${t}`)},getEmbeddingSettings:()=>Ze("/v1/settings/embedding"),updateEmbeddingSettings:n=>Ze("/v1/settings/embedding",{method:"PATCH",body:JSON.stringify(n)}),backfillEmbeddings:n=>Ze("/v1/settings/embedding/backfill",{method:"POST",body:JSON.stringify(n==null?{}:{limit:n})}),getWorkspaceSettings:()=>Ze("/v1/settings/workspace"),updateWorkspaceSettings:n=>Ze("/v1/settings/workspace",{method:"PATCH",body:JSON.stringify(n)}),tasksRange:n=>Ze("/v1/tasks/range",{method:"POST",body:JSON.stringify(n)}),configureRecurrence:(n,e)=>Ze(`/v1/tasks/${n}/recurrence`,{method:"POST",body:JSON.stringify(e)}),getRecurrence:n=>Ze(`/v1/tasks/${n}/recurrence`),skipOccurrence:(n,e)=>Ze(`/v1/tasks/${n}/skip-occurrence`,{method:"POST",body:JSON.stringify(e?{reason:e,actorKind:"human"}:{actorKind:"human"})}),stopRecurrence:(n,e)=>Ze(`/v1/recurrences/${n}/stop`,{method:"POST",body:JSON.stringify(e?{reason:e}:{})}),splitRecurrence:(n,e)=>Ze(`/v1/recurrences/${n}/split`,{method:"POST",body:JSON.stringify(e)}),listTokens:()=>Ze("/v1/tokens"),createToken:n=>Ze("/v1/tokens",{method:"POST",body:JSON.stringify({name:n})}),revokeToken:n=>Ze(`/v1/tokens/${n}`,{method:"DELETE"}),login:n=>Ze("/v1/auth/login",{method:"POST",body:JSON.stringify({password:n})}),logout:()=>Ze("/v1/auth/logout",{method:"POST"}),whoami:()=>Ze("/v1/auth/whoami")},Uc=3e4;function bF(){return on({queryKey:["health"],queryFn:We.health,staleTime:5*6e4})}function Vn(n={}){const e=!!n.includeArchived;return on({queryKey:["projects",e],queryFn:()=>We.listProjects({includeArchived:e})})}function wF(n){return on({queryKey:["project",n],queryFn:()=>We.getProject(n),enabled:!!n})}function SE(n){return on({queryKey:["project","by-key",n],queryFn:()=>We.getProjectByKey(n),enabled:!!n})}function XP(n){return on({queryKey:["entity",n],queryFn:()=>We.getEntity(n),enabled:!!n})}function SF(n,e={}){return on({queryKey:["revisions",n],queryFn:()=>We.entityRevisions(n),enabled:!!n&&(e.enabled??!0)})}function PF(n){return on({queryKey:["related",n],queryFn:()=>We.relatedEntities(n),enabled:!!n})}function CF(n,e={}){return on({queryKey:["recent",n],queryFn:()=>We.recent(n),refetchInterval:e.poll===!1?!1:Uc})}function U0(n,e,t={}){return on({queryKey:["entity-list",n,e],queryFn:()=>We.recent({projectId:n??null,kinds:e??null,limit:100}),enabled:!!n,refetchInterval:t.poll===!1?!1:Uc})}function PE(n){return on({queryKey:["search",n],queryFn:()=>We.search(n),enabled:!!(n&&n.query.length>0)})}function QF(n={},e={}){return on({queryKey:["feedback",n],queryFn:()=>We.listFeedback(n),refetchInterval:e.poll===!1?!1:Uc})}function CE(n=100){return on({queryKey:["trash",n],queryFn:()=>We.listTrash(n)})}const $F=[["trash"],["tasks-range"],["recent"],["entity-list"],["feedback"]];function TF(){const n=It();return On({mutationFn:e=>We.restoreEntity(e),onSuccess:()=>{for(const e of $F)n.invalidateQueries({queryKey:e})}})}function jF(){const n=It();return On({mutationFn:e=>We.purgeEntity(e),onSuccess:()=>{n.invalidateQueries({queryKey:["trash"]})}})}function EF(){return on({queryKey:["settings","embedding"],queryFn:We.getEmbeddingSettings,refetchInterval:Uc})}function MF(){const n=It();return On({mutationFn:e=>We.updateEmbeddingSettings(e),onSuccess:e=>{n.setQueryData(["settings","embedding"],e),n.invalidateQueries({queryKey:["health"]})}})}function AF(){const n=It();return On({mutationFn:e=>We.backfillEmbeddings(e),onSuccess:e=>{n.setQueryData(["settings","embedding"],e.settings)}})}function RF(){return on({queryKey:["settings","workspace"],queryFn:We.getWorkspaceSettings})}function NF(){const n=It();return On({mutationFn:e=>We.updateWorkspaceSettings(e),onSuccess:e=>{n.setQueryData(["settings","workspace"],e)}})}function Ul(n,e={}){return on({queryKey:["tasks-range",n],queryFn:()=>We.tasksRange(n),refetchInterval:e.poll===!1?!1:Uc})}function LF(n){return on({queryKey:["recurrence",n],queryFn:()=>We.getRecurrence(n),enabled:!!n,retry:!1})}function QE(){const n=It();return On({mutationFn:({taskId:e,input:t})=>We.configureRecurrence(e,t),onSuccess:e=>{n.invalidateQueries({queryKey:["entity",e.currentOccurrenceId??void 0]}),n.invalidateQueries({queryKey:["recurrence"]}),n.invalidateQueries({queryKey:["tasks-range"]}),n.invalidateQueries({queryKey:["recent"]}),n.invalidateQueries({queryKey:["entity-list"]})}})}function _F(){const n=It();return On({mutationFn:({taskId:e,reason:t})=>We.skipOccurrence(e,t),onSuccess:e=>{n.invalidateQueries({queryKey:["entity",e.skipped.id]}),e.next&&n.invalidateQueries({queryKey:["entity",e.next.id]}),n.invalidateQueries({queryKey:["recurrence"]}),n.invalidateQueries({queryKey:["tasks-range"]}),n.invalidateQueries({queryKey:["recent"]}),n.invalidateQueries({queryKey:["entity-list"]})}})}function DF(){const n=It();return On({mutationFn:({ruleId:e,reason:t})=>We.stopRecurrence(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:["recurrence"]}),n.invalidateQueries({queryKey:["tasks-range"]}),n.invalidateQueries({queryKey:["recent"]}),n.invalidateQueries({queryKey:["entity-list"]})}})}function IF(){const n=It();return On({mutationFn:({ruleId:e,input:t})=>We.splitRecurrence(e,t),onSuccess:e=>{n.invalidateQueries({queryKey:["entity",e.currentOccurrenceId??void 0]}),n.invalidateQueries({queryKey:["recurrence"]}),n.invalidateQueries({queryKey:["tasks-range"]}),n.invalidateQueries({queryKey:["recent"]}),n.invalidateQueries({queryKey:["entity-list"]})}})}function zF(){const n=It();return On({mutationFn:e=>We.createProject(e),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]})}})}function ZF(){const n=It();return On({mutationFn:({id:e,fields:t})=>We.updateProject(e,t),onSuccess:e=>{n.invalidateQueries({queryKey:["projects"]}),n.setQueryData(["project",e.id],e),n.invalidateQueries({queryKey:["project","by-key",e.key]}),n.invalidateQueries({queryKey:["opening-brief",e.id]})}})}function $E(){const n=It();return On({mutationFn:e=>We.writeEntity(e),onSuccess:e=>{n.invalidateQueries({queryKey:["entity-list",e.projectId??void 0]}),n.invalidateQueries({queryKey:["opening-brief",e.projectId??void 0]}),n.invalidateQueries({queryKey:["recent"]}),n.invalidateQueries({queryKey:["tasks-range"]}),e.parentId&&n.invalidateQueries({queryKey:["related",e.parentId]})}})}function Js(){const n=It();return On({mutationFn:({id:e,fields:t})=>We.updateEntity(e,t),onSuccess:e=>{n.invalidateQueries({queryKey:["entity",e.id]}),n.invalidateQueries({queryKey:["entity-list",e.projectId??void 0]}),n.invalidateQueries({queryKey:["opening-brief",e.projectId??void 0]}),n.invalidateQueries({queryKey:["tasks-range"]}),n.invalidateQueries({queryKey:["related"]}),n.invalidateQueries({queryKey:["revisions",e.id]}),e.kind==="feedback"&&n.invalidateQueries({queryKey:["feedback"]})}})}function XF(){const n=It();return On({mutationFn:({id:e,agentsMd:t})=>We.updateProject(e,{agentsMd:t}),onSuccess:e=>{n.invalidateQueries({queryKey:["project","by-key",e.key]}),n.invalidateQueries({queryKey:["opening-brief",e.id]}),n.invalidateQueries({queryKey:["projects"]})}})}function BF(){return on({queryKey:["tokens"],queryFn:We.listTokens})}function WF(){const n=It();return On({mutationFn:e=>We.createToken(e),onSuccess:()=>{n.invalidateQueries({queryKey:["tokens"]})}})}function qF(){const n=It();return On({mutationFn:e=>We.revokeToken(e),onSuccess:(e,t)=>{n.setQueryData(["tokens"],r=>(r==null?void 0:r.filter(i=>i.id!==t))??r),n.invalidateQueries({queryKey:["tokens"],refetchType:"active"})}})}const VF=["task","note","comment","feedback"],FF=["bug","feature","friction","idea"],YF=["task","note"],TE=["planned","active","watching","paused","archived"],jE=["urgent","high","medium","low","none"];function Pi(){const[n,e]=Rc(),t=n.get("d"),r=M.useCallback(s=>{e(l=>{const o=new URLSearchParams(l);return o.set("d",s),o})},[e]),i=M.useCallback(()=>{e(s=>{const l=new URLSearchParams(s);return l.delete("d"),l})},[e]);return{openId:t,open:r,close:i}}function ln(n){var t;if(n.title&&n.title.trim())return n.title;const e=((t=n.body.split(`
481
- `).find(r=>r.trim()))==null?void 0:t.trim())??"";return e?e.length>60?`${e.slice(0,60)}…`:e:"Untitled"}function jr(n){return!n.title||!n.title.trim()}const EE=M.createContext(null),UF=6e3;function GF({children:n}){const[e,t]=M.useState([]),r=M.useRef(1),i=M.useRef(new Map),s=M.useCallback(u=>{const h=i.current.get(u);h&&(clearTimeout(h),i.current.delete(u)),t(f=>f.filter(p=>p.id!==u))},[]),l=M.useCallback(({duration:u=UF,...h})=>{const f=r.current++;t(p=>[...p,{...h,id:f}]),i.current.set(f,setTimeout(()=>{var p;i.current.delete(f),t(g=>g.filter(x=>x.id!==f)),(p=h.onExpire)==null||p.call(h)},u))},[]),o=M.useMemo(()=>({toasts:e,show:l,dismiss:s}),[e,l,s]);return m.jsxs(EE.Provider,{value:o,children:[n,m.jsx(HF,{})]})}function ME(){const n=M.useContext(EE);if(!n)throw new Error("useToasts must be used inside ToastsProvider");return n}function HF(){const{toasts:n,dismiss:e}=ME();return n.length===0?null:m.jsx("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-[60] flex flex-col items-center gap-2",children:n.map(t=>m.jsxs("div",{className:"flex items-center gap-3 pl-3 pr-2 py-2 rounded-md bg-ink text-white text-xs shadow-modal",role:"status",children:[m.jsx("span",{className:"max-w-[60vw] truncate",children:t.message}),t.action&&m.jsx("button",{className:"shrink-0 px-2 py-0.5 rounded font-medium text-white/90 hover:text-white hover:bg-white/10",onClick:()=>{t.action.onClick(),e(t.id)},children:t.action.label}),m.jsx("button",{className:"shrink-0 px-1.5 text-white/50 hover:text-white",onClick:()=>{var r;(r=t.onExpire)==null||r.call(t),e(t.id)},"aria-label":"Dismiss",children:"×"})]},t.id))})}const BP=[["tasks-range"],["recent"],["entity-list"],["feedback"],["trash"]];function KF(n,e){if(Array.isArray(n))return n.filter(t=>t.id!==e);if(n&&typeof n=="object"&&"scheduled"in n){const t=n;return{...t,scheduled:t.scheduled.filter(r=>r.id!==e),overdue:t.overdue.filter(r=>r.id!==e),backlog:t.backlog.filter(r=>r.id!==e)}}return n}function AE(){const n=It(),{show:e}=ME(),t=M.useCallback(()=>{for(const r of BP)n.invalidateQueries({queryKey:r})},[n]);return M.useCallback(r=>{const i=[];for(const s of BP)for(const[l,o]of n.getQueriesData({queryKey:s}))o!==void 0&&(i.push([l,o]),n.setQueryData(l,KF(o,r.id)));We.deleteEntity(r.id).catch(()=>{for(const[s,l]of i)n.setQueryData(s,l)}),e({message:`Moved “${ln(r)}” to trash`,action:{label:"Undo",onClick:()=>{We.restoreEntity(r.id).then(t).catch(t)}},onExpire:t})},[n,e,t])}const RE=["hourly","daily","weekly","monthly","yearly"],dy=["MO","TU","WE","TH","FR","SA","SU"];function JF(n){if(!n)return;const e=n.match(/^(\d{4})(\d{2})(\d{2})/);if(e)return`${e[1]}-${e[2]}-${e[3]}`;const t=new Date(n);return Number.isNaN(t.getTime())?void 0:t.toISOString().slice(0,10)}function NE(n){var o;const e=new Map(n.replace(/^RRULE:/i,"").split(";").map(u=>u.split("=")).filter(u=>u.length===2).map(([u,h])=>[u.toUpperCase(),h])),t=(o=e.get("FREQ"))==null?void 0:o.toLowerCase(),r=RE.includes(t)?t:void 0,i=Number(e.get("INTERVAL")??1),s=Number(e.get("COUNT")),l=(e.get("BYDAY")??"").split(",").filter(u=>dy.includes(u));return{preset:r,interval:Number.isFinite(i)&&i>0?i:1,byWeekday:l,count:Number.isFinite(s)&&s>0?s:void 0,until:JF(e.get("UNTIL"))}}const eY=["title","body","tags","priority"];function tY(n,e,t){return!e||!eY.some(i=>i in n)?n:{...n,recurrenceScope:t}}const nY={task:{glyph:"☑",color:"text-blue-600 bg-blue-50 border-blue-100"},note:{glyph:"✎",color:"text-slate-700 bg-slate-50 border-slate-200"},comment:{glyph:"💬",color:"text-amber-700 bg-amber-50 border-amber-100"},feedback:{glyph:"📣",color:"text-purple-700 bg-purple-50 border-purple-100"}};function xp({kind:n,compact:e=!1}){const t=nY[n];return m.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 h-5 text-xxs rounded border ${t.color}`,title:n,children:[m.jsx("span",{children:t.glyph}),!e&&m.jsx("span",{className:"uppercase tracking-wider",children:n})]})}const LE=[{name:"circle",Icon:ty},{name:"square",Icon:X6},{name:"triangle",Icon:V6},{name:"hexagon",Icon:b6},{name:"folder",Icon:y6},{name:"briefcase",Icon:o6},{name:"rocket",Icon:L6},{name:"sparkles",Icon:z6},{name:"target",Icon:W6},{name:"layers",Icon:P6},{name:"code",Icon:h6},{name:"book",Icon:i6},{name:"flame",Icon:O6},{name:"zap",Icon:gj},{name:"star",Icon:B6},{name:"heart",Icon:v6},{name:"box",Icon:s6},{name:"lightbulb",Icon:Q6},{name:"pencil",Icon:hj},{name:"hash",Icon:k6}],rY=new Map(LE.map(n=>[n.name,n.Icon]));function iY(n){return n?rY.get(n)??ty:ty}const sY=[{name:"gray",value:"#6f6f76"},{name:"red",value:"#ef4444"},{name:"orange",value:"#f59e0b"},{name:"yellow",value:"#eab308"},{name:"green",value:"#10b981"},{name:"teal",value:"#14b8a6"},{name:"cyan",value:"#06b6d4"},{name:"blue",value:"#3b82f6"},{name:"indigo",value:"#5e6ad2"},{name:"purple",value:"#8b5cf6"},{name:"pink",value:"#ec4899"}],_E="#5e6ad2",DE="circle";function lY(n){return n==="circle"||n==="square"||n==="triangle"}function el({color:n,icon:e,size:t=12,className:r=""}){const i=iY(e),s=lY(e);return m.jsx(i,{size:t,className:`shrink-0 ${r}`,color:n,fill:s?n:"none",strokeWidth:s?1.2:1.8})}function py({status:n,size:e=14}){const t="currentColor";return n==="done"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusDone shrink-0",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6",fill:"currentColor"}),m.jsx("path",{d:"M4 7.4L6.2 9.5L10 5.5",stroke:"white",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):n==="in_progress"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusInProgress shrink-0",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:t,strokeWidth:"1.4",fill:"none"}),m.jsx("path",{d:"M7 1 a6 6 0 0 1 0 12 z",fill:"currentColor"})]}):n==="rejected"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusRejected shrink-0",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:t,strokeWidth:"1.4",fill:"none"}),m.jsx("path",{d:"M4 4l6 6M10 4l-6 6",stroke:t,strokeWidth:"1.4",strokeLinecap:"round"})]}):m.jsx("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusOpen shrink-0",children:m.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:t,strokeWidth:"1.4",fill:"none"})})}function Oa({priority:n,size:e=14}){return n==="urgent"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioUrgent shrink-0",children:[m.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"2",fill:"currentColor"}),m.jsx("path",{d:"M7 4v3.5M7 9.5h.01",stroke:"white",strokeWidth:"1.6",strokeLinecap:"round"})]}):n==="high"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioHigh shrink-0",children:[m.jsx("rect",{x:"2",y:"8",width:"2.5",height:"4",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"5.75",y:"5",width:"2.5",height:"7",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"9.5",y:"2",width:"2.5",height:"10",rx:"0.5",fill:"currentColor"})]}):n==="medium"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioMedium shrink-0",children:[m.jsx("rect",{x:"2",y:"8",width:"2.5",height:"4",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"5.75",y:"5",width:"2.5",height:"7",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"9.5",y:"2",width:"2.5",height:"10",rx:"0.5",opacity:"0.3",fill:"currentColor"})]}):n==="low"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioLow shrink-0",children:[m.jsx("rect",{x:"2",y:"8",width:"2.5",height:"4",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"5.75",y:"5",width:"2.5",height:"7",rx:"0.5",opacity:"0.3",fill:"currentColor"}),m.jsx("rect",{x:"9.5",y:"2",width:"2.5",height:"10",rx:"0.5",opacity:"0.3",fill:"currentColor"})]}):m.jsx("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-faint shrink-0",children:m.jsx("line",{x1:"3",y1:"7",x2:"11",y2:"7",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeDasharray:"1.5 1.5"})})}function Gc({size:n=12,className:e=""}){return m.jsxs("svg",{width:n,height:n,viewBox:"0 0 14 14",fill:"none",className:`shrink-0 ${e}`,"aria-hidden":"true",children:[m.jsx("path",{d:"M2.5 7a4.5 4.5 0 0 1 7.7-3.2L11.5 5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"M11.5 2v3h-3",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"M11.5 7a4.5 4.5 0 0 1-7.7 3.2L2.5 9",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"M2.5 12V9h3",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]})}const xa={urgent:"Urgent",high:"High",medium:"Medium",low:"Low",none:"No priority"},Bd={open:"Todo",in_progress:"In progress",done:"Done",rejected:"Cancelled"},IE=["open","in_progress","done","rejected"];function G0({trigger:n,children:e,align:t="start"}){const[r,i]=M.useState(!1),[s,l]=M.useState(null),o=M.useRef(null),u=M.useRef(null),h=M.useCallback(()=>{const f=o.current,p=u.current;if(!f||!p)return;const g=8,x=4,k=f.getBoundingClientRect(),b=p.offsetWidth,w=p.offsetHeight,S=window.innerWidth-b-g,Q=k.bottom+x,$=k.top-w-x,R=Q+w<=window.innerHeight-g,I=$>=g,T=t==="end"?k.right-b:k.left,X=R||!I?Q:$,Z=window.innerHeight-w-g;l({top:Math.min(Math.max(g,X),Math.max(g,Z)),left:Math.min(Math.max(g,T),Math.max(g,S))})},[t]);return M.useEffect(()=>{if(!r)return;const f=g=>{var k,b;const x=g.target;!((k=o.current)!=null&&k.contains(x))&&!((b=u.current)!=null&&b.contains(x))&&i(!1)},p=g=>{g.key==="Escape"&&i(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",p),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",p)}},[r]),M.useLayoutEffect(()=>{if(!r){l(null);return}h();const f=window.requestAnimationFrame(h);return window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.cancelAnimationFrame(f),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[r,h]),m.jsxs(m.Fragment,{children:[m.jsx("span",{ref:o,onClick:f=>{f.stopPropagation(),i(p=>!p)},children:n}),r&&FR.createPortal(m.jsx("div",{ref:u,className:"popover",style:{position:"fixed",top:(s==null?void 0:s.top)??-9999,left:(s==null?void 0:s.left)??-9999,visibility:s?"visible":"hidden"},onClick:f=>f.stopPropagation(),children:e(()=>i(!1))}),document.body)]})}function yp({task:n,size:e=14,className:t="",align:r="start",onStatusChange:i}){const s=Js();return m.jsx(G0,{align:r,trigger:m.jsx("button",{type:"button",draggable:!1,className:`inline-flex shrink-0 items-center justify-center rounded p-0.5 -m-0.5 hover:bg-line/40 disabled:opacity-60 ${t}`,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>l.stopPropagation(),onKeyUp:l=>l.stopPropagation(),onDragStart:l=>{l.preventDefault(),l.stopPropagation()},disabled:s.isPending,title:`Change status (${Bd[n.status]??n.status})`,"aria-label":"Change status","aria-haspopup":"menu",children:m.jsx(py,{status:n.status,size:e})}),children:l=>m.jsx(m.Fragment,{children:IE.map(o=>m.jsxs("button",{className:"popover-item",role:"menuitemradio","aria-checked":n.status===o,onClick:u=>{if(u.stopPropagation(),l(),n.status===o)return;const h=n.status;i==null||i(o),s.mutate({id:n.id,fields:{status:o}},{onError:()=>i==null?void 0:i(h)})},children:[m.jsx(py,{status:o,size:12}),m.jsx("span",{children:Bd[o]??o}),n.status===o&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]},o))})})}const oY=600,zE={hourly:"Hourly",daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly"},aY={hourly:"hour",daily:"day",weekly:"week",monthly:"month",yearly:"year"};function uY(){const{openId:n,close:e}=Pi();return M.useEffect(()=>{if(!n)return;const t=r=>{if(r.key!=="Escape")return;const i=r.target;if(i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.closest(".cm-editor"))){i.blur();return}e()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n,e]),n?m.jsxs("div",{className:"fixed inset-0 z-30 flex",children:[m.jsx("div",{className:"flex-1 bg-ink/10 backdrop-blur-[1px] cursor-pointer",onClick:e}),m.jsx("aside",{className:"w-[min(680px,92vw)] bg-surface border-l border-line shadow-modal flex flex-col",children:m.jsx(cY,{id:n,onClose:e})})]}):null}function SO(n){if(!n)return"";const e=new Date(n),t=r=>String(r).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`}function cY({id:n,onClose:e}){var Ut,Ar,Ci;const{data:t,isLoading:r}=XP(n),{data:i}=Vn(),{data:s}=PF(n),{data:l}=XP((t==null?void 0:t.parentId)??void 0),{data:o}=LF((t==null?void 0:t.kind)==="task"?n:void 0),u=Js(),h=AE(),f=QE(),p=_F(),g=DF(),x=IF(),{open:k}=zt(),{open:b}=Pi(),[w,S]=M.useState(""),[Q,$]=M.useState(""),[R,I]=M.useState(""),[T,X]=M.useState("open"),[Z,K]=M.useState(""),[N,U]=M.useState(""),[V,se]=M.useState("none"),[J,G]=M.useState(!1),[Oe,de]=M.useState("idle"),[ee,le]=M.useState("future"),C=M.useRef(null),D=M.useRef(!1);M.useEffect(()=>{t&&C.current!==t.id&&(S(t.title??""),$(t.body),I(t.tags.join(", ")),X(t.status),K(t.dueAt?t.dueAt.slice(0,10):""),U(SO(t.completedAt)),D.current=!1,se(t.priority),G(!1),de("idle"),C.current=t.id)},[t==null?void 0:t.id,t]),M.useEffect(()=>{!t||D.current||U(SO(t.completedAt))},[t,t==null?void 0:t.completedAt]);const F=M.useMemo(()=>{if(!J||!t||C.current!==t.id)return null;const it=t.kind==="note",Gt=w.trim(),vn=Gt||(it?null:Gt),tl=R.split(",").map(H=>H.trim()).filter(Boolean),Un={};vn!==(t.title??"")&&!(vn===null&&t.title===null)&&vn!==t.title&&(Un.title=vn===""?null:vn),Q!==t.body&&(Un.body=Q),JSON.stringify(tl)!==JSON.stringify(t.tags)&&(Un.tags=tl),T!==t.status&&(Un.status=T),V!==t.priority&&(Un.priority=V);const Jl=t.dueAt?t.dueAt.slice(0,10):"";if(Z!==Jl&&(Un.dueAt=Z?new Date(Z).toISOString():null),t.kind==="task"&&T==="done"&&D.current){const H=SO(t.completedAt);N!==H&&(Un.completedAt=N?new Date(N).toISOString():null)}return Un},[J,t,w,Q,R,T,V,Z,N]),E=t!=null&&((Ar=(Ut=t.metadata)==null?void 0:Ut.recurrence)==null?void 0:Ar.role)==="occurrence";function ce(it){return tY(it,E,ee)}if(M.useEffect(()=>{if(!J||!t||!F||Object.keys(F).length===0)return;de("idle");const it=setTimeout(async()=>{de("saving");try{await u.mutateAsync({id:t.id,fields:ce(F)}),de("saved")}catch{de("error")}},oY);return()=>clearTimeout(it)},[J,F]),r||!t)return m.jsxs("div",{className:"p-6 text-sm text-muted flex items-center justify-between",children:[m.jsx("span",{children:"Loading…"}),m.jsx("button",{onClick:e,className:"text-faint hover:text-ink",children:m.jsx(Sc,{size:14})})]});const ye=t,me=i==null?void 0:i.find(it=>it.id===ye.projectId),Ie=me?`/p/${me.key}`:"",Re=ye.kind==="note",_e=F?Object.keys(F).length>0:!1;function at(){S(ye.title??""),$(ye.body),I(ye.tags.join(", ")),X(ye.status),K(ye.dueAt?ye.dueAt.slice(0,10):""),se(ye.priority),de("idle"),le("future"),G(!0)}async function Fn(){if(!_e||!F){G(!1);return}de("saving");try{await u.mutateAsync({id:ye.id,fields:ce(F)}),de("saved"),G(!1)}catch{de("error")}}async function es(){h(t),e()}async function Gr(){if(!o||!confirm("Skip this recurring occurrence?"))return;const it=await p.mutateAsync({taskId:ye.id});it.next&&b(it.next.id)}async function Yn(){!o||!confirm("Stop this recurrence series?")||await g.mutateAsync({ruleId:o.rule.id})}async function Zt(it,Gt){if(!Gt)throw new Error("First due date is required");const vn=ye.dueAt?ye.dueAt.slice(0,10):"";Gt!==vn&&await u.mutateAsync({id:ye.id,fields:{dueAt:new Date(`${Gt}T12:00:00Z`).toISOString()}}),await f.mutateAsync({taskId:ye.id,input:it})}async function kn(it){if(!o)return;const{dtstart:Gt,...vn}=it;await x.mutateAsync({ruleId:o.rule.id,input:vn})}return m.jsxs(m.Fragment,{children:[m.jsxs("header",{className:"h-12 px-3 border-b border-line flex items-center gap-2 shrink-0",children:[m.jsx("button",{onClick:e,className:"p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",title:"Close (Esc)",children:m.jsx(Sc,{size:16})}),m.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted min-w-0",children:[me&&m.jsxs(m.Fragment,{children:[m.jsxs(ba,{to:Ie,className:"flex items-center gap-1 hover:opacity-80",children:[m.jsx(el,{color:me.color,icon:me.icon,size:12}),m.jsx("span",{className:"font-mono tabular-nums",style:{color:me.color},children:me.key})]}),m.jsx(ja,{size:11,className:"text-faint shrink-0"})]}),m.jsx(xp,{kind:t.kind,compact:!0}),t.sequenceId&&me&&m.jsxs("span",{className:"font-mono text-faint tabular-nums",children:[me.key,"-",t.sequenceId]})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[J&&m.jsx(gY,{state:Oe,dirty:_e}),Re&&m.jsx("button",{className:`p-1 -m-1 rounded hover:bg-sidebar ${t.pinned?"text-accent":"text-faint hover:text-ink"}`,onClick:()=>u.mutate({id:t.id,fields:{pinned:!t.pinned}}),title:t.pinned?"Unpin from opening brief":"Pin to opening brief",children:m.jsx(j0,{size:13,fill:t.pinned?"currentColor":"none"})}),J?m.jsx("button",{className:"p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",onClick:Fn,title:"Finish editing",children:m.jsx(Ki,{size:13})}):m.jsx("button",{className:"p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",onClick:at,title:"Edit",children:m.jsx(hj,{size:13})}),m.jsx("button",{className:"p-1 -m-1 text-faint hover:text-danger rounded hover:bg-danger/10",onClick:es,title:"Delete",children:m.jsx(wc,{size:13})})]})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"px-6 py-5 space-y-4",children:[J?m.jsx("input",{className:`w-full text-lg font-semibold bg-transparent border-none outline-none focus:outline-none px-0 py-1 ${w?"":"placeholder:text-muted/60 placeholder:italic"}`,value:w,placeholder:Re?"Untitled":"Title",onChange:it=>S(it.target.value),autoFocus:!0}):m.jsx("h2",{className:`text-lg font-semibold py-1 ${jr(t)?"italic text-muted":"text-ink"}`,children:ln(t)}),m.jsx(mY,{isEditing:J,isTask:t.kind==="task",status:T,setStatus:X,dueDate:Z,setDueDate:K,priority:V,setPriority:se,tagsStr:R,setTagsStr:I,completedAt:t.completedAt,completedAtStr:N,setCompletedAtStr:it=>{D.current=!0,U(it)},createdAt:t.createdAt,actorKind:((Ci=t.actor)==null?void 0:Ci.label)??t.actorKind,task:ye.kind==="task"?{...ye,status:T}:void 0,onStatusChange:X,recurrence:o,recurrenceBusy:u.isPending||f.isPending||p.isPending||g.isPending||x.isPending,onSaveRecurrence:Zt,onSkipOccurrence:Gr,onStopRecurrence:Yn,onSplitRecurrence:kn,isRecurringOccurrence:E,occurrenceScope:ee,setOccurrenceScope:le}),Re&&l&&m.jsxs("button",{className:"w-full text-left flex items-center gap-2 text-xs px-3 py-2 rounded border border-line bg-sidebar/50 hover:border-accent hover:bg-accentSoft/40 transition-colors",onClick:()=>b(l.id),title:"Open linked task",children:[m.jsx($6,{size:12,className:"text-faint"}),m.jsx("span",{className:"text-faint",children:"Linked to task:"}),l.sequenceId&&me&&m.jsxs("span",{className:"font-mono text-faint tabular-nums",children:[me.key,"-",l.sequenceId]}),m.jsx("span",{className:"text-ink truncate",children:ln(l)})]}),m.jsx("div",{className:"border border-line rounded-md overflow-hidden bg-surface",children:J?m.jsx(T0,{value:Q,onChange:it=>$(it),extensions:[fT()],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1},theme:"light",minHeight:"220px",placeholder:"Write in Markdown…"}):Q?m.jsx("div",{className:"min-h-[120px] p-3",children:m.jsx(qP,{body:Q})}):m.jsx("div",{className:"min-h-[120px] p-3 text-xs text-faint",children:"No description."})}),J&&Q&&m.jsxs("details",{className:"text-xxs text-muted",children:[m.jsx("summary",{className:"cursor-pointer hover:text-ink",children:"Preview rendered Markdown"}),m.jsx("div",{className:"mt-2 p-3 border border-line rounded bg-sidebar/30",children:m.jsx(qP,{body:Q})})]}),t.kind==="task"&&m.jsx(OY,{related:s??[],onOpen:b,onAdd:()=>{me&&k({kind:"quick-create",projectId:me.id,initialKind:"note",parentId:t.id})},project:me}),t.kind!=="comment"&&m.jsx(hY,{entity:t})]})})]})}function hY({entity:n}){const[e,t]=M.useState(!1),r=SF(n.id,{enabled:e}),i=r.data??[];return m.jsxs("div",{children:[m.jsxs("button",{className:"flex items-center gap-1.5 text-xxs uppercase tracking-wider text-muted font-semibold hover:text-ink",onClick:()=>t(s=>!s),children:[m.jsx(ja,{size:12,className:`transition-transform ${e?"rotate-90":""}`}),"History",e&&r.data&&m.jsxs("span",{className:"text-faint normal-case tracking-normal",children:[i.length," edit",i.length===1?"":"s"]})]}),e&&m.jsx("div",{className:"mt-1.5",children:r.isLoading?m.jsx("div",{className:"text-xs text-faint p-3 text-center",children:"Loading…"}):i.length===0?m.jsx("div",{className:"text-xs text-faint border border-dashed border-line rounded p-3 text-center",children:"Never edited since it was written."}):m.jsx("div",{className:"border border-line rounded-md divide-y divide-lineSoft overflow-hidden",children:i.map((s,l)=>{const o=l===0?n:i[l-1];return m.jsx(fY,{before:s,after:o},s.id)})})})]})}function fY({before:n,after:e}){var l;const t=[];(n.title??"")!==(e.title??"")&&t.push(["title",n.title??"(untitled)",e.title??"(untitled)"]),n.status!==e.status&&t.push(["status",n.status,e.status]),n.priority!==e.priority&&t.push(["priority",n.priority,e.priority]),n.tags.join("\0")!==e.tags.join("\0")&&t.push(["tags",n.tags.join(", ")||"—",e.tags.join(", ")||"—"]);const r=n.body!==e.body,i=M.useMemo(()=>r?xF(OF(n.body,e.body)):[],[r,n.body,e.body]),s=((l=n.actor)==null?void 0:l.label)??n.actorKind;return m.jsxs("div",{className:"px-3 py-2 text-xs",children:[m.jsxs("div",{className:"flex items-baseline gap-2 text-xxs text-muted",children:[m.jsxs("span",{className:"font-mono tabular-nums text-faint",children:["#",n.revision]}),m.jsx("span",{children:new Date(n.createdAt).toLocaleString()}),m.jsxs("span",{children:["· by ",m.jsx("span",{className:"text-ink",children:s})]})]}),t.length>0&&m.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(([o,u,h])=>m.jsxs("li",{className:"text-xxs",children:[m.jsxs("span",{className:"text-muted",children:[o,":"]})," ",m.jsx("span",{className:"line-through text-danger/80",children:u})," ",m.jsx("span",{className:"text-faint",children:"→"})," ",m.jsx("span",{className:"text-ink",children:h})]},o))}),r&&m.jsx("pre",{className:"mt-1.5 font-mono text-xxs leading-relaxed whitespace-pre-wrap break-words bg-sidebar/40 rounded p-2 overflow-x-auto",children:i.map((o,u)=>o.type==="skip"?m.jsxs("div",{className:"text-faint italic",children:["… ",o.count," unchanged line",o.count===1?"":"s"]},u):m.jsxs("div",{className:o.type==="add"?"bg-success/10 text-ink":o.type==="del"?"bg-danger/10 text-muted line-through":"text-muted",children:[m.jsx("span",{className:"select-none text-faint mr-1",children:o.type==="add"?"+":o.type==="del"?"−":" "}),o.text||" "]},u))}),!r&&t.length===0&&m.jsx("div",{className:"mt-1 text-xxs text-faint",children:"No visible difference."})]})}function dY(n){const e=n.rule,t=NE(e.rrule),r=t.preset??"daily",i=t.interval??1,s=i>1?`Every ${i} ${aY[r]}s`:zE[r],l=t.byWeekday.length?` · ${t.byWeekday.join(", ")}`:"",o=e.anchor==="completion"?"after completion":"scheduled",u=e.enabled?"":" · stopped",h=e.nextOccurrenceAt?` · next ${new Date(e.nextOccurrenceAt).toLocaleDateString()}`:"";return`${s}${l} · ${o}${h}${u}`}function WP(n){const e=n?NE(n.rule.rrule):void 0;return{preset:n?(e==null?void 0:e.preset)??"weekly":"none",interval:(e==null?void 0:e.interval)??1,anchor:(n==null?void 0:n.rule.anchor)??"scheduled",byWeekday:(e==null?void 0:e.byWeekday)??[],count:e!=null&&e.count?String(e.count):"",until:(e==null?void 0:e.until)??""}}function pY({isEditing:n,task:e,dueDate:t,recurrence:r,onSave:i,onSkip:s,onStop:l,onSplit:o,busy:u}){const[h,f]=M.useState(()=>WP(r)),[p,g]=M.useState(null);if(M.useEffect(()=>{f(WP(r)),g(null)},[n,e==null?void 0:e.id,e==null?void 0:e.dueAt,r==null?void 0:r.rule.id,r==null?void 0:r.rule.rrule,r==null?void 0:r.rule.anchor]),!e)return null;const x=["done","rejected"].includes(e.status),k=!!(r!=null&&r.rule.enabled)&&(r==null?void 0:r.rule.currentOccurrenceId)===e.id,b=!!(r!=null&&r.rule.enabled),w=h.preset!=="none",S=!!i&&t.length>0&&w&&h.interval>=1,Q=!!o&&!!(r!=null&&r.rule.enabled)&&w&&h.interval>=1;function $(Z){f(K=>({...K,...Z})),g(null)}function R(Z){const K=new Set(h.byWeekday);K.has(Z)?K.delete(Z):K.add(Z),$({byWeekday:dy.filter(N=>K.has(N))})}function I(){const Z={preset:h.preset,interval:h.interval,anchor:h.anchor,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,allDay:!0};return h.preset==="weekly"&&h.byWeekday.length>0&&(Z.byWeekday=h.byWeekday),h.count&&(Z.count=Number(h.count)),h.until&&(Z.until=new Date(`${h.until}T23:59:59Z`).toISOString()),Z}async function T(){if(h.preset==="none"){g(null);return}if(!t){g("Set due date first");return}if(h.count&&h.until){g("Use count or until");return}try{await(i==null?void 0:i(I(),t)),g(null)}catch(Z){g(Z instanceof Error?Z.message:"Could not save repeat")}}async function X(){if(h.preset!=="none"){if(h.count&&h.until){g("Use count or until");return}try{await(o==null?void 0:o(I())),g(null)}catch(Z){g(Z instanceof Error?Z.message:"Could not split series")}}}return!n||x?m.jsxs("span",{className:"min-w-0 flex items-center gap-2",children:[m.jsx("span",{className:r?"text-muted truncate":"text-faint",children:r?dY(r):"None"}),k&&s&&m.jsx("button",{className:"text-faint hover:text-ink disabled:opacity-40 shrink-0",onClick:s,disabled:u,title:"Skip occurrence",children:"Skip"})]}):m.jsxs("span",{className:"min-w-0 flex flex-col gap-1",children:[m.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsxs("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:h.preset,onChange:Z=>$({preset:Z.target.value}),title:"Repeat",children:[m.jsx("option",{value:"none",children:"None"}),RE.map(Z=>m.jsx("option",{value:Z,children:zE[Z]},Z))]}),w&&m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"number",min:1,max:999,className:"w-14 bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 focus:outline-none focus:ring-1 focus:ring-accent",value:h.interval,onChange:Z=>$({interval:Math.max(1,Number(Z.target.value)||1)}),title:"Interval"}),m.jsxs("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:h.anchor,onChange:Z=>$({anchor:Z.target.value}),title:"Anchor",children:[m.jsx("option",{value:"scheduled",children:"Scheduled"}),m.jsx("option",{value:"completion",children:"Completion"})]}),m.jsx("button",{className:"text-accent hover:underline disabled:opacity-40",onClick:T,disabled:u||!S,children:"Save"}),Q&&m.jsx("button",{className:"text-faint hover:text-ink disabled:opacity-40",onClick:X,disabled:u,title:"Keep past occurrences on the old cadence; apply this cadence going forward",children:"Split"})]}),b&&l&&m.jsx("button",{className:"text-faint hover:text-danger disabled:opacity-40",onClick:l,disabled:u,title:"Stop series",children:"Stop"})]}),w&&h.preset==="weekly"&&m.jsx("span",{className:"flex flex-wrap gap-1",children:dy.map(Z=>m.jsx("button",{type:"button",className:`px-1.5 py-0.5 rounded border text-[10px] ${h.byWeekday.includes(Z)?"border-accent bg-accentSoft text-accent":"border-line bg-surface text-muted hover:text-ink"}`,onClick:()=>R(Z),children:Z},Z))}),w&&m.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsx("input",{type:"number",min:1,max:1e4,className:"w-20 bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 focus:outline-none focus:ring-1 focus:ring-accent",value:h.count,onChange:Z=>$({count:Z.target.value,until:Z.target.value?"":h.until}),placeholder:"Count",title:"Count"}),m.jsx("input",{type:"date",className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:h.until,onChange:Z=>$({until:Z.target.value,count:Z.target.value?"":h.count}),title:"Until"}),!t&&m.jsx("span",{className:"text-faint text-xxs",children:"Set due date first"}),p&&m.jsx("span",{className:"text-danger text-xxs truncate",children:p})]})]})}function mY({isEditing:n,isTask:e,status:t,setStatus:r,dueDate:i,setDueDate:s,priority:l,setPriority:o,tagsStr:u,setTagsStr:h,completedAt:f,completedAtStr:p,setCompletedAtStr:g,createdAt:x,actorKind:k,task:b,onStatusChange:w,recurrence:S,recurrenceBusy:Q,onSaveRecurrence:$,onSkipOccurrence:R,onStopRecurrence:I,onSplitRecurrence:T,isRecurringOccurrence:X,occurrenceScope:Z,setOccurrenceScope:K}){return m.jsxs("div",{className:"grid grid-cols-[80px_1fr] gap-x-3 gap-y-1.5 items-center text-xs",children:[e&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Status"}),m.jsxs("span",{className:"flex items-center gap-1.5",children:[n||!b?m.jsx(py,{status:t,size:12}):m.jsx(yp,{task:b,size:12,onStatusChange:w}),n?m.jsx("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:t,onChange:N=>r(N.target.value),children:IE.map(N=>m.jsx("option",{value:N,children:Bd[N]??N},N))}):m.jsx("span",{className:"text-ink",children:Bd[t]??t})]}),m.jsx("span",{className:"text-faint",children:"Due"}),m.jsx("span",{className:"flex items-center gap-1.5",children:n?m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"date",className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:i,onChange:N=>s(N.target.value)}),!i&&m.jsx("span",{className:"text-faint text-xxs",children:"inbox"}),i&&m.jsx("button",{className:"text-faint hover:text-danger text-xxs",onClick:()=>s(""),title:"Clear",children:"✕"})]}):m.jsx("span",{className:i?"text-ink":"text-faint text-xxs",children:i||"inbox"})}),(S||n&&b&&!["done","rejected"].includes(t))&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Repeat"}),m.jsx(pY,{isEditing:n,task:b,dueDate:i,recurrence:S,busy:!!Q,onSave:$,onSkip:R,onStop:I,onSplit:T})]}),n&&X&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Apply to"}),m.jsx("span",{className:"flex items-center gap-1.5",children:m.jsxs("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:Z??"future",onChange:N=>K==null?void 0:K(N.target.value),title:"Recurrence edit scope",children:[m.jsx("option",{value:"future",children:"This and future"}),m.jsx("option",{value:"this",children:"This occurrence only"})]})})]}),m.jsx("span",{className:"text-faint",children:"Priority"}),m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx(Oa,{priority:l,size:12}),n?m.jsx("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:l,onChange:N=>o(N.target.value),children:jE.map(N=>m.jsx("option",{value:N,children:xa[N]},N))}):m.jsx("span",{className:"text-ink",children:xa[l]})]}),t==="done"&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Completed"}),n?m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx("input",{type:"datetime-local",className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:p,onChange:N=>g(N.target.value)}),!p&&m.jsx("span",{className:"text-faint text-xxs",children:"auto"}),p&&m.jsx("button",{className:"text-faint hover:text-danger text-xxs",onClick:()=>g(""),title:"Clear",children:"✕"})]}):m.jsx("span",{className:"text-muted",children:f?new Date(f).toLocaleString():"Not recorded"})]})]}),m.jsx("span",{className:"text-faint",children:"Tags"}),n?m.jsx("input",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-none focus:ring-1 focus:ring-accent",value:u,onChange:N=>h(N.target.value),placeholder:"comma, separated"}):m.jsx("span",{className:u?"text-muted":"text-faint",children:u||"none"}),m.jsx("span",{className:"text-faint",children:"Created"}),m.jsxs("span",{className:"text-muted",children:[new Date(x).toLocaleString()," · by ",m.jsx("span",{className:"text-ink",children:k})]})]})}function gY({state:n,dirty:e}){return n==="saving"?m.jsxs("span",{className:"flex items-center gap-1 text-xxs text-muted",children:[m.jsx(uj,{size:11,className:"animate-spin"}),"Saving…"]}):n==="saved"&&!e?m.jsxs("span",{className:"flex items-center gap-1 text-xxs text-faint",children:[m.jsx(c6,{size:11}),"Saved"]}):n==="error"?m.jsx("span",{className:"text-xxs text-danger",children:"Save failed"}):e?m.jsxs("span",{className:"flex items-center gap-1 text-xxs text-faint",children:[m.jsx(u6,{size:11}),"Unsaved"]}):null}function OY({related:n,onOpen:e,onAdd:t,project:r}){const i=n.filter(s=>s.kind==="note");return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[m.jsxs("h3",{className:"text-xxs uppercase tracking-wider text-muted font-semibold",children:["Related notes ",m.jsx("span",{className:"text-faint",children:i.length})]}),m.jsx("button",{onClick:t,className:"text-xs text-accent hover:underline",children:"+ Add note"})]}),i.length===0?m.jsx("div",{className:"text-xs text-faint border border-dashed border-line rounded p-3 text-center",children:"No linked notes yet."}):m.jsx("div",{className:"border border-line rounded-md divide-y divide-lineSoft overflow-hidden",children:i.map(s=>m.jsxs("button",{className:"w-full text-left px-3 py-2 hover:bg-sidebar flex items-start gap-2",onClick:()=>e(s.id),children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(s)?"italic text-muted":"text-ink"}`,children:ln(s)}),!jr(s)&&s.body&&m.jsx("div",{className:"text-xxs text-muted truncate mt-0.5",children:s.body.replace(/\n/g," ").slice(0,140)})]}),s.pinned&&m.jsx(j0,{size:11,className:"text-accent shrink-0 mt-1",fill:"currentColor"})]},s.id))}),!r&&m.jsx("div",{className:"text-xxs text-faint mt-1",children:"No project context — link picker unavailable."})]})}function qP({body:n}){return m.jsx("div",{className:"text-sm leading-relaxed text-ink space-y-2 [&_h1]:text-lg [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-1.5 [&_h2]:text-base [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1 [&_h3]:font-semibold [&_h3]:mt-2 [&_p]:my-1 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-0.5 [&_code]:bg-sidebar [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-xs [&_pre]:bg-sidebar [&_pre]:p-2 [&_pre]:rounded [&_pre]:overflow-x-auto [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_a]:text-accent [&_a]:underline [&_blockquote]:border-l-2 [&_blockquote]:border-line [&_blockquote]:pl-3 [&_blockquote]:text-muted [&_table]:border-collapse [&_th]:border [&_th]:border-line [&_th]:px-2 [&_th]:py-1 [&_td]:border [&_td]:border-line [&_td]:px-2 [&_td]:py-1",children:m.jsx(Kj,{remarkPlugins:[bE],children:n})})}function my(n,e){const[t,r]=M.useState(()=>{if(typeof window>"u")return e;try{const s=window.localStorage.getItem(n);return s===null?e:JSON.parse(s)}catch{return e}});M.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(n,JSON.stringify(t))}catch{}},[n,t]);const i=M.useCallback(s=>r(s),[]);return[t,i]}const Vl={planned:"Planned",active:"Active",watching:"Watching",paused:"Paused",archived:"Archived"},ZE={planned:"Committed, not started",active:"Currently being built",watching:"Built, in maintenance",paused:"Intentionally on hold",archived:"Hidden from active work"},gy=["planned","active","watching","paused","archived"],PO={key:"Key (A→Z)",name:"Name (A→Z)",recent:"Recently active"},VP={archived:!0};function xY(n,e){const t=[...n];return e==="key"?t.sort((r,i)=>r.key.localeCompare(i.key)):e==="name"?t.sort((r,i)=>r.name.localeCompare(i.name)):t.sort((r,i)=>+new Date(i.updatedAt)-+new Date(r.updatedAt))}function FP(){const{open:n}=zt(),{key:e}=Gd(),[t,r]=my("botnote.projectSort","key"),[i,s]=my("botnote.sidebar.projectGroups.collapsed",VP),{data:l,isLoading:o}=Vn({includeArchived:!0}),{data:u}=CE(200),h=(u==null?void 0:u.length)??0,f=M.useMemo(()=>{const k=l??[];return new Map(gy.map(b=>[b,xY(k.filter(w=>w.status===b),t)]))},[l,t]),p=(l==null?void 0:l.length)??0,g=k=>i[k]??VP[k]??!1,x=k=>{const b=g(k);s({...i,[k]:!b})};return m.jsxs("aside",{className:"w-52 shrink-0 border-r border-line bg-sidebar flex flex-col scrollbar-thin overflow-y-auto text-sm",children:[m.jsxs("nav",{className:"px-1.5 pt-2 space-y-px",children:[m.jsx(Qo,{to:"/",end:!0,icon:m.jsx(a6,{size:12,className:"opacity-70"}),label:"Tasks",shortcut:"g d"}),m.jsx(Qo,{to:"/today",icon:m.jsx(pj,{size:12,className:"opacity-70"}),label:"Today",shortcut:"g t"}),m.jsx(Qo,{to:"/inbox",icon:m.jsx(_d,{size:12,className:"opacity-70"}),label:"Inbox",shortcut:"g i"}),m.jsx(Qo,{to:"/dashboard",icon:m.jsx(C6,{size:12,className:"opacity-70"}),label:"Workspace",shortcut:"g w"})]}),m.jsxs("div",{className:"mt-3 px-3 py-1.5 flex items-center justify-between",children:[m.jsx("div",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:"Projects"}),m.jsxs("div",{className:"flex items-center gap-0.5",children:[m.jsx(G0,{trigger:m.jsx("button",{className:"text-muted hover:text-ink p-0.5 rounded hover:bg-sidebarHover flex items-center gap-0.5",title:`Sort: ${PO[t]}`,children:m.jsx(ey,{size:11})}),align:"end",children:k=>m.jsx(m.Fragment,{children:Object.keys(PO).map(b=>m.jsxs("button",{className:"popover-item",onClick:()=>{r(b),k()},children:[m.jsx("span",{children:PO[b]}),t===b&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]},b))})}),m.jsx("button",{className:"text-muted hover:text-ink p-0.5 rounded hover:bg-sidebarHover",title:"New project (n)",onClick:()=>n({kind:"new-project"}),children:m.jsx(qc,{size:11})})]})]}),m.jsxs("nav",{className:"px-1.5 space-y-px flex-1",children:[o&&m.jsx("div",{className:"px-2 py-1 text-xs text-faint",children:"Loading…"}),!o&&p===0&&m.jsxs("button",{className:"w-full text-left px-2 py-1 text-xs text-muted hover:bg-sidebarHover rounded",onClick:()=>n({kind:"new-project"}),children:["No projects yet. ",m.jsx("span",{className:"text-accent",children:"Create →"})]}),gy.map(k=>{const b=f.get(k)??[];if(o||b.length===0)return null;const w=g(k);return m.jsxs("div",{className:"pt-2 first:pt-0",children:[m.jsxs("button",{type:"button",className:"w-full px-1.5 pb-1 flex items-center gap-1 text-xxs uppercase tracking-wider text-muted font-medium hover:text-ink",onClick:()=>x(k),title:`${w?"Expand":"Collapse"} ${Vl[k]}`,children:[w?m.jsx(ja,{size:10}):m.jsx(ey,{size:10}),m.jsx("span",{children:Vl[k]}),m.jsx("span",{className:"ml-auto text-faint tabular-nums",children:b.length})]}),!w&&b.map(S=>m.jsx(yY,{project:S,activeKey:e},S.id))]},k)})]}),m.jsxs("div",{className:"border-t border-line/60 px-1.5 py-1.5 space-y-px",children:[m.jsx(Qo,{to:"/trash",icon:m.jsx(wc,{size:12,className:"opacity-70"}),label:"Trash",badge:h>0?h:void 0}),m.jsx(Qo,{to:"/settings",icon:m.jsx(aj,{size:12,className:"opacity-70"}),label:"Settings"})]})]})}function yY({project:n,activeKey:e}){return m.jsxs(VC,{to:`/p/${n.key}`,title:n.status==="archived"?`${n.name} (archived)`:n.name,className:({isActive:t})=>`flex items-center gap-2 px-2 py-1 text-xs rounded ${t||e===n.key?"bg-accentSoft text-accentText":"text-ink2 hover:bg-sidebarHover"} ${n.status==="archived"?"opacity-60":""}`,children:[m.jsx(el,{color:n.color,icon:n.icon,size:11}),m.jsx("span",{className:"font-mono text-xxs tabular-nums opacity-90 shrink-0",style:{color:n.color},children:n.key}),m.jsx("span",{className:"truncate text-muted",children:n.name})]})}function Qo({to:n,end:e,icon:t,label:r,shortcut:i,badge:s}){return m.jsxs(VC,{to:n,end:e,className:({isActive:l})=>`group flex items-center gap-2 px-2 py-1 rounded text-xs ${l?"bg-accentSoft text-accentText":"text-ink2 hover:bg-sidebarHover"}`,title:i?`${r} (${i})`:r,children:[t,m.jsx("span",{children:r}),s!=null&&m.jsx("span",{className:"ml-auto text-xxs text-faint tabular-nums",children:s}),i&&m.jsx("kbd",{className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity",children:i})]})}function kY({onMenuClick:n}){const{open:e}=zt(),t=Gs(),r=typeof navigator<"u"&&navigator.platform.includes("Mac")?"⌘":"Ctrl";async function i(){try{await We.logout()}catch{}t("/login",{replace:!0})}return m.jsxs("header",{className:"h-11 flex items-center justify-between px-3 border-b border-line bg-surface",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("button",{className:"btn btn-ghost !h-7 !w-7 !p-0 md:hidden",onClick:n,title:"Menu","aria-label":"Toggle sidebar",children:m.jsx(E6,{size:14})}),m.jsxs(ba,{to:"/",className:"flex items-center gap-1.5 text-ink hover:opacity-90",children:[m.jsx("img",{src:"/favicon.svg",alt:"","aria-hidden":"true",className:"w-[18px] h-[18px]"}),m.jsx("span",{className:"text-xs font-semibold tracking-tight",children:"botnote"})]})]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsxs("button",{className:"btn !pl-2 !pr-1.5 gap-2 md:min-w-[220px] !justify-between text-muted",onClick:()=>e({kind:"search"}),title:"Search (⌘K)",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Dd,{size:12}),m.jsx("span",{className:"text-xs hidden sm:inline",children:"Search…"})]}),m.jsxs("kbd",{className:"hidden md:inline-block",children:[r,"K"]})]}),m.jsxs("button",{className:"btn btn-primary",onClick:()=>e({kind:"quick-create"}),title:"Quick create (c)",children:[m.jsx(qc,{size:12}),m.jsx("span",{className:"text-xs hidden sm:inline",children:"New"}),m.jsx("kbd",{className:"!bg-white/15 !border-white/25 !text-white hidden md:inline-block",children:"c"})]}),m.jsx("button",{className:"btn !px-1.5 !py-1 text-muted hover:!text-red-500",onClick:i,title:"Log out","aria-label":"Log out",children:m.jsx(cj,{size:12})})]})]})}function vY(){n5();const[n,e]=M.useState(!1),t=Us();return M.useEffect(()=>{e(!1)},[t.pathname,t.search]),m.jsxs("div",{className:"h-full w-full flex flex-col",children:[m.jsx(kY,{onMenuClick:()=>e(r=>!r)}),m.jsxs("div",{className:"flex-1 min-h-0 flex",children:[m.jsx("div",{className:"hidden md:flex shrink-0",children:m.jsx(FP,{})}),m.jsx("main",{className:"flex-1 min-w-0 min-h-0 overflow-hidden bg-bg",children:m.jsx(DN,{})})]}),n&&m.jsxs("div",{className:"fixed inset-0 z-40 md:hidden",children:[m.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:()=>e(!1)}),m.jsx("div",{className:"absolute inset-y-0 left-0 flex shadow-modal",children:m.jsx(FP,{})})]}),m.jsx(uY,{})]})}function XE({icon:n,color:e,onIconChange:t,onColorChange:r}){return m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-xxs text-muted uppercase tracking-wider mb-1",children:"Color"}),m.jsx("div",{className:"flex flex-wrap gap-1.5",children:sY.map(i=>m.jsx("button",{type:"button",onClick:()=>r(i.value),className:"relative w-6 h-6 rounded-full border border-line/80 hover:scale-110 transition-transform",style:{backgroundColor:i.value},title:i.name,children:e===i.value&&m.jsx(Ki,{size:12,className:"absolute inset-0 m-auto text-white",strokeWidth:3})},i.value))})]}),m.jsxs("div",{children:[m.jsx("div",{className:"text-xxs text-muted uppercase tracking-wider mb-1",children:"Icon"}),m.jsx("div",{className:"flex flex-wrap gap-1",children:LE.map(i=>m.jsx("button",{type:"button",onClick:()=>t(i.name),className:`w-7 h-7 rounded flex items-center justify-center border transition-colors ${n===i.name?"border-accent bg-accentSoft":"border-line bg-surface hover:bg-sidebar"}`,title:i.name,children:m.jsx(el,{color:e,icon:i.name,size:14})},i.name))})]})]})}function Qc({title:n,children:e,width:t="max-w-2xl"}){const{close:r}=zt();return M.useEffect(()=>{const i=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=i}},[]),m.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-20 px-4 bg-ink/20",onClick:r,children:m.jsxs("div",{className:`w-full ${t} bg-surface border border-line rounded-lg shadow-2xl overflow-hidden`,onClick:i=>i.stopPropagation(),children:[m.jsxs("div",{className:"h-9 px-3 flex items-center justify-between border-b border-line",children:[m.jsx("div",{className:"text-xs font-semibold text-ink",children:n}),m.jsx("button",{onClick:r,className:"text-muted hover:text-ink p-0.5 rounded hover:bg-line/60",title:"Close (Esc)",children:m.jsx(Sc,{size:14})})]}),e]})})}function bY({projectId:n}){const{data:e}=wF(n),t=ZF(),{close:r}=zt(),[i,s]=M.useState(""),[l,o]=M.useState("active"),[u,h]=M.useState(_E),[f,p]=M.useState(DE);if(M.useEffect(()=>{e&&(s(e.name),o(e.status),h(e.color),p(e.icon))},[e==null?void 0:e.id,e==null?void 0:e.name,e==null?void 0:e.status,e==null?void 0:e.color,e==null?void 0:e.icon]),!e)return m.jsx(Qc,{title:"Project settings",width:"max-w-md",children:m.jsx("div",{className:"p-4 text-sm text-muted",children:"Loading…"})});const g=e,x=i!==g.name||l!==g.status||u!==g.color||f!==g.icon,k=i.trim().length>0;return m.jsx(Qc,{title:`Settings · ${g.key}`,width:"max-w-md",children:m.jsxs("form",{onSubmit:async b=>{b.preventDefault(),!(!x||!k)&&(await t.mutateAsync({id:g.id,fields:{name:i.trim(),status:l,color:u,icon:f}}),r())},className:"p-3 space-y-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Name"}),m.jsx("input",{autoFocus:!0,className:"input",value:i,onChange:b=>s(b.target.value)})]}),m.jsx(XE,{icon:f,color:u,onIconChange:p,onColorChange:h}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Status"}),m.jsx("select",{className:"input",value:l,onChange:b=>o(b.target.value),children:TE.map(b=>m.jsxs("option",{value:b,children:[Vl[b]," · ",ZE[b]]},b))})]}),m.jsx("div",{className:"flex justify-end items-center pt-1",children:m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{type:"button",className:"btn",onClick:r,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!x||!k||t.isPending,children:t.isPending?"Saving…":"Save"})]})}),t.error&&m.jsx("div",{className:"text-xs text-danger",children:t.error.message})]})})}function wY(){const[n,e]=M.useState(""),[t,r]=M.useState(""),[i,s]=M.useState("active"),[l,o]=M.useState(""),[u,h]=M.useState(_E),[f,p]=M.useState(DE),g=zF(),{close:x}=zt(),k=Gs(),b=/^[A-Z][A-Z0-9_]{0,19}$/.test(n)&&t.trim().length>0;return m.jsx(Qc,{title:"New project",width:"max-w-md",children:m.jsxs("form",{onSubmit:async w=>{if(w.preventDefault(),!b)return;const S=await g.mutateAsync({key:n.trim(),name:t.trim(),status:i,color:u,icon:f,agentsMd:l.trim()});x(),k(`/p/${S.key}`)},className:"p-3 space-y-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Key (uppercase, e.g. BOT)"}),m.jsx("input",{autoFocus:!0,className:"input font-mono uppercase",value:n,onChange:w=>e(w.target.value.toUpperCase()),placeholder:"BOT",maxLength:20})]}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Name"}),m.jsx("input",{className:"input",value:t,onChange:w=>r(w.target.value),placeholder:"botnote"})]}),m.jsx(XE,{icon:f,color:u,onIconChange:p,onColorChange:h}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Status"}),m.jsx("select",{className:"input",value:i,onChange:w=>s(w.target.value),children:TE.map(w=>m.jsxs("option",{value:w,children:[Vl[w]," · ",ZE[w]]},w))})]}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"AGENTS.md (optional)"}),m.jsx("textarea",{className:"input !h-24 py-1.5 font-mono text-xs leading-snug resize-y",value:l,onChange:w=>o(w.target.value),placeholder:`## Critical
482
- - ALWAYS run pnpm typecheck before commit.`})]}),m.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[m.jsx("button",{type:"button",className:"btn",onClick:x,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!b||g.isPending,children:g.isPending?"Creating…":"Create project"})]}),g.error&&m.jsx("div",{className:"text-xs text-danger",children:g.error.message})]})})}function SY({initialProjectId:n,initialKind:e,initialParentId:t}){const{data:r}=Vn(),[i,s]=M.useState(e??"task"),[l,o]=M.useState(n??""),[u,h]=M.useState(""),[f,p]=M.useState(""),[g,x]=M.useState(""),[k,b]=M.useState(""),[w,S]=M.useState("none"),[Q,$]=M.useState("none"),[R,I]=M.useState(1),[T,X]=M.useState("scheduled"),[Z,K]=M.useState(!1),[N,U]=M.useState(t??""),V=$E(),se=QE(),{close:J}=zt(),{open:G}=Pi(),Oe=r==null?void 0:r.find(C=>C.id===l),de=i==="note",{data:ee}=U0(de&&l?l:void 0,["task"]),le=l.length>0&&(de?u.trim().length>0||f.trim().length>0:u.trim().length>0&&(Q==="none"||k.length>0));return m.jsx(Qc,{title:"Quick create",width:"max-w-xl",children:m.jsxs("form",{onSubmit:async C=>{if(C.preventDefault(),!le)return;const D=u.trim(),F=g.split(",").map(ce=>ce.trim()).filter(Boolean),E=i==="task"?await V.mutateAsync({kind:"task",projectId:l,title:D,body:f.trim(),tags:F,actorKind:"human",dueAt:k?new Date(k).toISOString():null,priority:w}):await V.mutateAsync({kind:"note",projectId:l,title:D||null,body:f.trim(),tags:F,actorKind:"human",pinned:Z,parentId:N||null});i==="task"&&Q!=="none"&&await se.mutateAsync({taskId:E.id,input:{preset:Q,interval:R,anchor:T,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,allDay:!0}}),J(),G(E.id)},className:"p-3 space-y-3",children:[m.jsxs("div",{className:"flex gap-2",children:[m.jsx("div",{className:"seg w-32",children:YF.map(C=>m.jsx("button",{type:"button","data-active":i===C,onClick:()=>s(C),className:"flex-1 justify-center capitalize",children:C},C))}),m.jsxs("select",{className:"input flex-1",value:l,onChange:C=>o(C.target.value),children:[m.jsx("option",{value:"",children:"— pick a project —"}),r==null?void 0:r.map(C=>m.jsxs("option",{value:C.id,children:[C.key," · ",C.name]},C.id))]})]}),m.jsx("input",{autoFocus:!0,className:"input",placeholder:de?"Title (optional)":"Title",value:u,onChange:C=>h(C.target.value)}),m.jsx("textarea",{className:"input !h-32 py-1.5 font-mono text-xs leading-snug resize-y",placeholder:"Body (Markdown, optional)",value:f,onChange:C=>p(C.target.value)}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("input",{className:"input flex-1",placeholder:"Tags (comma-separated, optional)",value:g,onChange:C=>x(C.target.value)}),i==="task"&&m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"date",className:"input w-36",value:k,onChange:C=>b(C.target.value),title:"Due date"}),m.jsx("select",{className:"input w-36",value:w,onChange:C=>S(C.target.value),title:"Priority",children:jE.map(C=>m.jsx("option",{value:C,children:xa[C]},C))})]})]}),i==="task"&&m.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_84px_132px] gap-2",children:[m.jsxs("select",{className:"input",value:Q,onChange:C=>$(C.target.value),title:"Repeat",children:[m.jsx("option",{value:"none",children:"Repeat: none"}),m.jsx("option",{value:"hourly",children:"Hourly"}),m.jsx("option",{value:"daily",children:"Daily"}),m.jsx("option",{value:"weekly",children:"Weekly"}),m.jsx("option",{value:"monthly",children:"Monthly"}),m.jsx("option",{value:"yearly",children:"Yearly"})]}),m.jsx("input",{type:"number",min:1,max:999,className:"input",value:R,disabled:Q==="none",onChange:C=>I(Math.max(1,Number(C.target.value)||1)),title:"Repeat interval"}),m.jsxs("select",{className:"input",value:T,disabled:Q==="none",onChange:C=>X(C.target.value),title:"Repeat anchor",children:[m.jsx("option",{value:"scheduled",children:"Scheduled"}),m.jsx("option",{value:"completion",children:"Completion"})]})]}),i==="task"&&w!=="none"&&m.jsxs("div",{className:"flex items-center gap-1.5 text-xxs text-muted",children:[m.jsx(Oa,{priority:w,size:11}),m.jsxs("span",{children:[xa[w]," priority"]})]}),de&&m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted cursor-pointer",children:[m.jsx("input",{type:"checkbox",checked:Z,onChange:C=>K(C.target.checked)}),m.jsx("span",{children:"📌 Pin to project — auto-include in agent opening brief"})]}),ee&&ee.length>0&&m.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[m.jsx("span",{className:"shrink-0",children:"Link to task:"}),m.jsxs("select",{className:"input flex-1 !h-7 text-xs",value:N,onChange:C=>U(C.target.value),children:[m.jsx("option",{value:"",children:"— none —"}),ee.map(C=>m.jsxs("option",{value:C.id,children:[Oe!=null&&Oe.key&&C.sequenceId?`${Oe.key}-${C.sequenceId} · `:"",ln(C)]},C.id))]})]})]}),m.jsxs("div",{className:"flex justify-between items-center pt-1",children:[m.jsxs("div",{className:"text-xxs text-muted",children:[m.jsx("kbd",{children:"⌘"}),"+",m.jsx("kbd",{children:"Enter"})," to submit · ",m.jsx("kbd",{children:"Esc"})," to close"]}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{type:"button",className:"btn",onClick:J,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!le||V.isPending,children:V.isPending?"Creating…":`Create ${i}`})]})]}),V.error&&m.jsx("div",{className:"text-xs text-danger",children:V.error.message})]})})}const PY={task:"task",note:"note",comment:"comment",feedback:"feedback"};function CY(){const[n,e]=M.useState(""),[t,r]=M.useState(""),{close:i}=zt(),{open:s}=Pi(),{data:l}=Vn();M.useEffect(()=>{const f=setTimeout(()=>r(n.trim()),200);return()=>clearTimeout(f)},[n]);const{data:o,isFetching:u}=PE(t?{query:t,limit:20}:null),h=M.useMemo(()=>{const f=new Map;return l==null||l.forEach(p=>f.set(p.id,p.key)),f},[l]);return m.jsxs(Qc,{title:"Search",children:[m.jsx("div",{className:"p-3 pb-1",children:m.jsxs("div",{className:"flex items-center gap-2 px-2 h-9 border border-line rounded bg-surface focus-within:border-accent focus-within:ring-1 focus-within:ring-accentSoft",children:[m.jsx(Dd,{size:14,className:"text-muted"}),m.jsx("input",{autoFocus:!0,placeholder:"Hybrid search (BM25 + vector + time decay)",className:"flex-1 bg-transparent border-none outline-none text-sm",value:n,onChange:f=>e(f.target.value)}),u&&m.jsx("span",{className:"text-xxs text-muted",children:"searching…"})]})}),m.jsxs("div",{className:"max-h-[60vh] overflow-y-auto scrollbar-thin",children:[t&&!u&&(!o||o.hits.length===0)&&m.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted",children:"No matches."}),o==null?void 0:o.hits.map(f=>{const p=f.entity.projectId?h.get(f.entity.projectId):null;return m.jsxs("button",{onClick:()=>{i(),s(f.entity.id)},className:"w-full px-3 py-2 row-hover text-left flex items-start gap-3 border-t border-line/60",children:[m.jsx("span",{className:"chip mt-0.5",children:PY[f.entity.kind]}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"text-sm text-ink truncate",children:ln(f.entity)}),m.jsx("div",{className:"text-xs text-muted truncate mt-0.5",children:f.entity.body.replace(/\n/g," ").slice(0,140)||"—"}),m.jsxs("div",{className:"text-xxs text-faint mt-0.5 flex gap-2",children:[p&&m.jsxs("span",{children:["· ",p]}),m.jsxs("span",{children:["· score ",f.score.toFixed(3)]}),f.components.bm25&&m.jsx("span",{children:"· bm25"}),f.components.cosine&&m.jsx("span",{children:"· vec"})]})]}),m.jsx(r6,{size:13,className:"text-faint mt-1"})]},f.entity.id)}),o&&m.jsxs("div",{className:"px-3 py-2 text-xxs text-muted border-t border-line/60",children:[o.hits.length," result(s) · embedding ",o.embeddingUsed?"ON":"OFF (BM25-only)"]})]})]})}function QY(){const{active:n}=zt();if(!n)return null;switch(n.kind){case"search":return m.jsx(CY,{});case"quick-create":return m.jsx(SY,{initialProjectId:n.projectId,initialKind:n.initialKind,initialParentId:n.parentId});case"new-project":return m.jsx(wY,{});case"edit-project":return m.jsx(bY,{projectId:n.projectId})}}const $Y=`## Critical
481
+ `).find(r=>r.trim()))==null?void 0:t.trim())??"";return e?e.length>60?`${e.slice(0,60)}…`:e:"Untitled"}function jr(n){return!n.title||!n.title.trim()}const EE=M.createContext(null),UF=6e3;function GF({children:n}){const[e,t]=M.useState([]),r=M.useRef(1),i=M.useRef(new Map),s=M.useCallback(u=>{const h=i.current.get(u);h&&(clearTimeout(h),i.current.delete(u)),t(f=>f.filter(p=>p.id!==u))},[]),l=M.useCallback(({duration:u=UF,...h})=>{const f=r.current++;t(p=>[...p,{...h,id:f}]),i.current.set(f,setTimeout(()=>{var p;i.current.delete(f),t(g=>g.filter(x=>x.id!==f)),(p=h.onExpire)==null||p.call(h)},u))},[]),o=M.useMemo(()=>({toasts:e,show:l,dismiss:s}),[e,l,s]);return m.jsxs(EE.Provider,{value:o,children:[n,m.jsx(HF,{})]})}function ME(){const n=M.useContext(EE);if(!n)throw new Error("useToasts must be used inside ToastsProvider");return n}function HF(){const{toasts:n,dismiss:e}=ME();return n.length===0?null:m.jsx("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-60 flex flex-col items-center gap-2",children:n.map(t=>m.jsxs("div",{className:"flex items-center gap-3 pl-3 pr-2 py-2 rounded-md bg-ink text-white text-xs shadow-modal",role:"status",children:[m.jsx("span",{className:"max-w-[60vw] truncate",children:t.message}),t.action&&m.jsx("button",{className:"shrink-0 px-2 py-0.5 rounded font-medium text-white/90 hover:text-white hover:bg-white/10",onClick:()=>{t.action.onClick(),e(t.id)},children:t.action.label}),m.jsx("button",{className:"shrink-0 px-1.5 text-white/50 hover:text-white",onClick:()=>{var r;(r=t.onExpire)==null||r.call(t),e(t.id)},"aria-label":"Dismiss",children:"×"})]},t.id))})}const BP=[["tasks-range"],["recent"],["entity-list"],["feedback"],["trash"]];function KF(n,e){if(Array.isArray(n))return n.filter(t=>t.id!==e);if(n&&typeof n=="object"&&"scheduled"in n){const t=n;return{...t,scheduled:t.scheduled.filter(r=>r.id!==e),overdue:t.overdue.filter(r=>r.id!==e),backlog:t.backlog.filter(r=>r.id!==e)}}return n}function AE(){const n=It(),{show:e}=ME(),t=M.useCallback(()=>{for(const r of BP)n.invalidateQueries({queryKey:r})},[n]);return M.useCallback(r=>{const i=[];for(const s of BP)for(const[l,o]of n.getQueriesData({queryKey:s}))o!==void 0&&(i.push([l,o]),n.setQueryData(l,KF(o,r.id)));We.deleteEntity(r.id).catch(()=>{for(const[s,l]of i)n.setQueryData(s,l)}),e({message:`Moved “${ln(r)}” to trash`,action:{label:"Undo",onClick:()=>{We.restoreEntity(r.id).then(t).catch(t)}},onExpire:t})},[n,e,t])}const RE=["hourly","daily","weekly","monthly","yearly"],dy=["MO","TU","WE","TH","FR","SA","SU"];function JF(n){if(!n)return;const e=n.match(/^(\d{4})(\d{2})(\d{2})/);if(e)return`${e[1]}-${e[2]}-${e[3]}`;const t=new Date(n);return Number.isNaN(t.getTime())?void 0:t.toISOString().slice(0,10)}function NE(n){var o;const e=new Map(n.replace(/^RRULE:/i,"").split(";").map(u=>u.split("=")).filter(u=>u.length===2).map(([u,h])=>[u.toUpperCase(),h])),t=(o=e.get("FREQ"))==null?void 0:o.toLowerCase(),r=RE.includes(t)?t:void 0,i=Number(e.get("INTERVAL")??1),s=Number(e.get("COUNT")),l=(e.get("BYDAY")??"").split(",").filter(u=>dy.includes(u));return{preset:r,interval:Number.isFinite(i)&&i>0?i:1,byWeekday:l,count:Number.isFinite(s)&&s>0?s:void 0,until:JF(e.get("UNTIL"))}}const eY=["title","body","tags","priority"];function tY(n,e,t){return!e||!eY.some(i=>i in n)?n:{...n,recurrenceScope:t}}const nY={task:{glyph:"☑",color:"text-blue-600 bg-blue-50 border-blue-100"},note:{glyph:"✎",color:"text-slate-700 bg-slate-50 border-slate-200"},comment:{glyph:"💬",color:"text-amber-700 bg-amber-50 border-amber-100"},feedback:{glyph:"📣",color:"text-purple-700 bg-purple-50 border-purple-100"}};function xp({kind:n,compact:e=!1}){const t=nY[n];return m.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 h-5 text-xxs rounded border ${t.color}`,title:n,children:[m.jsx("span",{children:t.glyph}),!e&&m.jsx("span",{className:"uppercase tracking-wider",children:n})]})}const LE=[{name:"circle",Icon:ty},{name:"square",Icon:X6},{name:"triangle",Icon:V6},{name:"hexagon",Icon:b6},{name:"folder",Icon:y6},{name:"briefcase",Icon:o6},{name:"rocket",Icon:L6},{name:"sparkles",Icon:z6},{name:"target",Icon:W6},{name:"layers",Icon:P6},{name:"code",Icon:h6},{name:"book",Icon:i6},{name:"flame",Icon:O6},{name:"zap",Icon:gj},{name:"star",Icon:B6},{name:"heart",Icon:v6},{name:"box",Icon:s6},{name:"lightbulb",Icon:Q6},{name:"pencil",Icon:hj},{name:"hash",Icon:k6}],rY=new Map(LE.map(n=>[n.name,n.Icon]));function iY(n){return n?rY.get(n)??ty:ty}const sY=[{name:"gray",value:"#6f6f76"},{name:"red",value:"#ef4444"},{name:"orange",value:"#f59e0b"},{name:"yellow",value:"#eab308"},{name:"green",value:"#10b981"},{name:"teal",value:"#14b8a6"},{name:"cyan",value:"#06b6d4"},{name:"blue",value:"#3b82f6"},{name:"indigo",value:"#5e6ad2"},{name:"purple",value:"#8b5cf6"},{name:"pink",value:"#ec4899"}],_E="#5e6ad2",DE="circle";function lY(n){return n==="circle"||n==="square"||n==="triangle"}function el({color:n,icon:e,size:t=12,className:r=""}){const i=iY(e),s=lY(e);return m.jsx(i,{size:t,className:`shrink-0 ${r}`,color:n,fill:s?n:"none",strokeWidth:s?1.2:1.8})}function py({status:n,size:e=14}){const t="currentColor";return n==="done"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusDone shrink-0",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6",fill:"currentColor"}),m.jsx("path",{d:"M4 7.4L6.2 9.5L10 5.5",stroke:"white",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):n==="in_progress"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusInProgress shrink-0",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:t,strokeWidth:"1.4",fill:"none"}),m.jsx("path",{d:"M7 1 a6 6 0 0 1 0 12 z",fill:"currentColor"})]}):n==="rejected"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusRejected shrink-0",children:[m.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:t,strokeWidth:"1.4",fill:"none"}),m.jsx("path",{d:"M4 4l6 6M10 4l-6 6",stroke:t,strokeWidth:"1.4",strokeLinecap:"round"})]}):m.jsx("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-statusOpen shrink-0",children:m.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:t,strokeWidth:"1.4",fill:"none"})})}function Oa({priority:n,size:e=14}){return n==="urgent"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioUrgent shrink-0",children:[m.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"2",fill:"currentColor"}),m.jsx("path",{d:"M7 4v3.5M7 9.5h.01",stroke:"white",strokeWidth:"1.6",strokeLinecap:"round"})]}):n==="high"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioHigh shrink-0",children:[m.jsx("rect",{x:"2",y:"8",width:"2.5",height:"4",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"5.75",y:"5",width:"2.5",height:"7",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"9.5",y:"2",width:"2.5",height:"10",rx:"0.5",fill:"currentColor"})]}):n==="medium"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioMedium shrink-0",children:[m.jsx("rect",{x:"2",y:"8",width:"2.5",height:"4",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"5.75",y:"5",width:"2.5",height:"7",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"9.5",y:"2",width:"2.5",height:"10",rx:"0.5",opacity:"0.3",fill:"currentColor"})]}):n==="low"?m.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-prioLow shrink-0",children:[m.jsx("rect",{x:"2",y:"8",width:"2.5",height:"4",rx:"0.5",fill:"currentColor"}),m.jsx("rect",{x:"5.75",y:"5",width:"2.5",height:"7",rx:"0.5",opacity:"0.3",fill:"currentColor"}),m.jsx("rect",{x:"9.5",y:"2",width:"2.5",height:"10",rx:"0.5",opacity:"0.3",fill:"currentColor"})]}):m.jsx("svg",{width:e,height:e,viewBox:"0 0 14 14",className:"text-faint shrink-0",children:m.jsx("line",{x1:"3",y1:"7",x2:"11",y2:"7",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeDasharray:"1.5 1.5"})})}function Gc({size:n=12,className:e=""}){return m.jsxs("svg",{width:n,height:n,viewBox:"0 0 14 14",fill:"none",className:`shrink-0 ${e}`,"aria-hidden":"true",children:[m.jsx("path",{d:"M2.5 7a4.5 4.5 0 0 1 7.7-3.2L11.5 5",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"M11.5 2v3h-3",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"M11.5 7a4.5 4.5 0 0 1-7.7 3.2L2.5 9",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),m.jsx("path",{d:"M2.5 12V9h3",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]})}const xa={urgent:"Urgent",high:"High",medium:"Medium",low:"Low",none:"No priority"},Bd={open:"Todo",in_progress:"In progress",done:"Done",rejected:"Cancelled"},IE=["open","in_progress","done","rejected"];function G0({trigger:n,children:e,align:t="start"}){const[r,i]=M.useState(!1),[s,l]=M.useState(null),o=M.useRef(null),u=M.useRef(null),h=M.useCallback(()=>{const f=o.current,p=u.current;if(!f||!p)return;const g=8,x=4,k=f.getBoundingClientRect(),b=p.offsetWidth,w=p.offsetHeight,S=window.innerWidth-b-g,Q=k.bottom+x,$=k.top-w-x,R=Q+w<=window.innerHeight-g,I=$>=g,T=t==="end"?k.right-b:k.left,X=R||!I?Q:$,Z=window.innerHeight-w-g;l({top:Math.min(Math.max(g,X),Math.max(g,Z)),left:Math.min(Math.max(g,T),Math.max(g,S))})},[t]);return M.useEffect(()=>{if(!r)return;const f=g=>{var k,b;const x=g.target;!((k=o.current)!=null&&k.contains(x))&&!((b=u.current)!=null&&b.contains(x))&&i(!1)},p=g=>{g.key==="Escape"&&i(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",p),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",p)}},[r]),M.useLayoutEffect(()=>{if(!r){l(null);return}h();const f=window.requestAnimationFrame(h);return window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),()=>{window.cancelAnimationFrame(f),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[r,h]),m.jsxs(m.Fragment,{children:[m.jsx("span",{ref:o,onClick:f=>{f.stopPropagation(),i(p=>!p)},children:n}),r&&FR.createPortal(m.jsx("div",{ref:u,className:"popover",style:{position:"fixed",top:(s==null?void 0:s.top)??-9999,left:(s==null?void 0:s.left)??-9999,visibility:s?"visible":"hidden"},onClick:f=>f.stopPropagation(),children:e(()=>i(!1))}),document.body)]})}function yp({task:n,size:e=14,className:t="",align:r="start",onStatusChange:i}){const s=Js();return m.jsx(G0,{align:r,trigger:m.jsx("button",{type:"button",draggable:!1,className:`inline-flex shrink-0 items-center justify-center rounded p-0.5 -m-0.5 hover:bg-line/40 disabled:opacity-60 ${t}`,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),onKeyDown:l=>l.stopPropagation(),onKeyUp:l=>l.stopPropagation(),onDragStart:l=>{l.preventDefault(),l.stopPropagation()},disabled:s.isPending,title:`Change status (${Bd[n.status]??n.status})`,"aria-label":"Change status","aria-haspopup":"menu",children:m.jsx(py,{status:n.status,size:e})}),children:l=>m.jsx(m.Fragment,{children:IE.map(o=>m.jsxs("button",{className:"popover-item",role:"menuitemradio","aria-checked":n.status===o,onClick:u=>{if(u.stopPropagation(),l(),n.status===o)return;const h=n.status;i==null||i(o),s.mutate({id:n.id,fields:{status:o}},{onError:()=>i==null?void 0:i(h)})},children:[m.jsx(py,{status:o,size:12}),m.jsx("span",{children:Bd[o]??o}),n.status===o&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]},o))})})}const oY=600,zE={hourly:"Hourly",daily:"Daily",weekly:"Weekly",monthly:"Monthly",yearly:"Yearly"},aY={hourly:"hour",daily:"day",weekly:"week",monthly:"month",yearly:"year"};function uY(){const{openId:n,close:e}=Pi();return M.useEffect(()=>{if(!n)return;const t=r=>{if(r.key!=="Escape")return;const i=r.target;if(i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.closest(".cm-editor"))){i.blur();return}e()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n,e]),n?m.jsxs("div",{className:"fixed inset-0 z-30 flex",children:[m.jsx("div",{className:"flex-1 bg-ink/10 backdrop-blur-[1px] cursor-pointer",onClick:e}),m.jsx("aside",{className:"w-[min(680px,92vw)] bg-surface border-l border-line shadow-modal flex flex-col",children:m.jsx(cY,{id:n,onClose:e})})]}):null}function SO(n){if(!n)return"";const e=new Date(n),t=r=>String(r).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`}function cY({id:n,onClose:e}){var Ut,Ar,Ci;const{data:t,isLoading:r}=XP(n),{data:i}=Vn(),{data:s}=PF(n),{data:l}=XP((t==null?void 0:t.parentId)??void 0),{data:o}=LF((t==null?void 0:t.kind)==="task"?n:void 0),u=Js(),h=AE(),f=QE(),p=_F(),g=DF(),x=IF(),{open:k}=zt(),{open:b}=Pi(),[w,S]=M.useState(""),[Q,$]=M.useState(""),[R,I]=M.useState(""),[T,X]=M.useState("open"),[Z,K]=M.useState(""),[N,U]=M.useState(""),[V,se]=M.useState("none"),[J,G]=M.useState(!1),[Oe,de]=M.useState("idle"),[ee,le]=M.useState("future"),C=M.useRef(null),D=M.useRef(!1);M.useEffect(()=>{t&&C.current!==t.id&&(S(t.title??""),$(t.body),I(t.tags.join(", ")),X(t.status),K(t.dueAt?t.dueAt.slice(0,10):""),U(SO(t.completedAt)),D.current=!1,se(t.priority),G(!1),de("idle"),C.current=t.id)},[t==null?void 0:t.id,t]),M.useEffect(()=>{!t||D.current||U(SO(t.completedAt))},[t,t==null?void 0:t.completedAt]);const F=M.useMemo(()=>{if(!J||!t||C.current!==t.id)return null;const it=t.kind==="note",Gt=w.trim(),vn=Gt||(it?null:Gt),tl=R.split(",").map(H=>H.trim()).filter(Boolean),Un={};vn!==(t.title??"")&&!(vn===null&&t.title===null)&&vn!==t.title&&(Un.title=vn===""?null:vn),Q!==t.body&&(Un.body=Q),JSON.stringify(tl)!==JSON.stringify(t.tags)&&(Un.tags=tl),T!==t.status&&(Un.status=T),V!==t.priority&&(Un.priority=V);const Jl=t.dueAt?t.dueAt.slice(0,10):"";if(Z!==Jl&&(Un.dueAt=Z?new Date(Z).toISOString():null),t.kind==="task"&&T==="done"&&D.current){const H=SO(t.completedAt);N!==H&&(Un.completedAt=N?new Date(N).toISOString():null)}return Un},[J,t,w,Q,R,T,V,Z,N]),E=t!=null&&((Ar=(Ut=t.metadata)==null?void 0:Ut.recurrence)==null?void 0:Ar.role)==="occurrence";function ce(it){return tY(it,E,ee)}if(M.useEffect(()=>{if(!J||!t||!F||Object.keys(F).length===0)return;de("idle");const it=setTimeout(async()=>{de("saving");try{await u.mutateAsync({id:t.id,fields:ce(F)}),de("saved")}catch{de("error")}},oY);return()=>clearTimeout(it)},[J,F]),r||!t)return m.jsxs("div",{className:"p-6 text-sm text-muted flex items-center justify-between",children:[m.jsx("span",{children:"Loading…"}),m.jsx("button",{onClick:e,className:"text-faint hover:text-ink",children:m.jsx(Sc,{size:14})})]});const ye=t,me=i==null?void 0:i.find(it=>it.id===ye.projectId),Ie=me?`/p/${me.key}`:"",Re=ye.kind==="note",_e=F?Object.keys(F).length>0:!1;function at(){S(ye.title??""),$(ye.body),I(ye.tags.join(", ")),X(ye.status),K(ye.dueAt?ye.dueAt.slice(0,10):""),se(ye.priority),de("idle"),le("future"),G(!0)}async function Fn(){if(!_e||!F){G(!1);return}de("saving");try{await u.mutateAsync({id:ye.id,fields:ce(F)}),de("saved"),G(!1)}catch{de("error")}}async function es(){h(t),e()}async function Gr(){if(!o||!confirm("Skip this recurring occurrence?"))return;const it=await p.mutateAsync({taskId:ye.id});it.next&&b(it.next.id)}async function Yn(){!o||!confirm("Stop this recurrence series?")||await g.mutateAsync({ruleId:o.rule.id})}async function Zt(it,Gt){if(!Gt)throw new Error("First due date is required");const vn=ye.dueAt?ye.dueAt.slice(0,10):"";Gt!==vn&&await u.mutateAsync({id:ye.id,fields:{dueAt:new Date(`${Gt}T12:00:00Z`).toISOString()}}),await f.mutateAsync({taskId:ye.id,input:it})}async function kn(it){if(!o)return;const{dtstart:Gt,...vn}=it;await x.mutateAsync({ruleId:o.rule.id,input:vn})}return m.jsxs(m.Fragment,{children:[m.jsxs("header",{className:"h-12 px-3 border-b border-line flex items-center gap-2 shrink-0",children:[m.jsx("button",{onClick:e,className:"p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",title:"Close (Esc)",children:m.jsx(Sc,{size:16})}),m.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted min-w-0",children:[me&&m.jsxs(m.Fragment,{children:[m.jsxs(ba,{to:Ie,className:"flex items-center gap-1 hover:opacity-80",children:[m.jsx(el,{color:me.color,icon:me.icon,size:12}),m.jsx("span",{className:"font-mono tabular-nums",style:{color:me.color},children:me.key})]}),m.jsx(ja,{size:11,className:"text-faint shrink-0"})]}),m.jsx(xp,{kind:t.kind,compact:!0}),t.sequenceId&&me&&m.jsxs("span",{className:"font-mono text-faint tabular-nums",children:[me.key,"-",t.sequenceId]})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[J&&m.jsx(gY,{state:Oe,dirty:_e}),Re&&m.jsx("button",{className:`p-1 -m-1 rounded hover:bg-sidebar ${t.pinned?"text-accent":"text-faint hover:text-ink"}`,onClick:()=>u.mutate({id:t.id,fields:{pinned:!t.pinned}}),title:t.pinned?"Unpin from opening brief":"Pin to opening brief",children:m.jsx(j0,{size:13,fill:t.pinned?"currentColor":"none"})}),J?m.jsx("button",{className:"p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",onClick:Fn,title:"Finish editing",children:m.jsx(Ki,{size:13})}):m.jsx("button",{className:"p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",onClick:at,title:"Edit",children:m.jsx(hj,{size:13})}),m.jsx("button",{className:"p-1 -m-1 text-faint hover:text-danger rounded hover:bg-danger/10",onClick:es,title:"Delete",children:m.jsx(wc,{size:13})})]})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"px-6 py-5 space-y-4",children:[J?m.jsx("input",{className:`w-full text-lg font-semibold bg-transparent border-none outline-hidden focus:outline-hidden px-0 py-1 ${w?"":"placeholder:text-muted/60 placeholder:italic"}`,value:w,placeholder:Re?"Untitled":"Title",onChange:it=>S(it.target.value),autoFocus:!0}):m.jsx("h2",{className:`text-lg font-semibold py-1 ${jr(t)?"italic text-muted":"text-ink"}`,children:ln(t)}),m.jsx(mY,{isEditing:J,isTask:t.kind==="task",status:T,setStatus:X,dueDate:Z,setDueDate:K,priority:V,setPriority:se,tagsStr:R,setTagsStr:I,completedAt:t.completedAt,completedAtStr:N,setCompletedAtStr:it=>{D.current=!0,U(it)},createdAt:t.createdAt,actorKind:((Ci=t.actor)==null?void 0:Ci.label)??t.actorKind,task:ye.kind==="task"?{...ye,status:T}:void 0,onStatusChange:X,recurrence:o,recurrenceBusy:u.isPending||f.isPending||p.isPending||g.isPending||x.isPending,onSaveRecurrence:Zt,onSkipOccurrence:Gr,onStopRecurrence:Yn,onSplitRecurrence:kn,isRecurringOccurrence:E,occurrenceScope:ee,setOccurrenceScope:le}),Re&&l&&m.jsxs("button",{className:"w-full text-left flex items-center gap-2 text-xs px-3 py-2 rounded border border-line bg-sidebar/50 hover:border-accent hover:bg-accentSoft/40 transition-colors",onClick:()=>b(l.id),title:"Open linked task",children:[m.jsx($6,{size:12,className:"text-faint"}),m.jsx("span",{className:"text-faint",children:"Linked to task:"}),l.sequenceId&&me&&m.jsxs("span",{className:"font-mono text-faint tabular-nums",children:[me.key,"-",l.sequenceId]}),m.jsx("span",{className:"text-ink truncate",children:ln(l)})]}),m.jsx("div",{className:"border border-line rounded-md overflow-hidden bg-surface",children:J?m.jsx(T0,{value:Q,onChange:it=>$(it),extensions:[fT()],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1},theme:"light",minHeight:"220px",placeholder:"Write in Markdown…"}):Q?m.jsx("div",{className:"min-h-[120px] p-3",children:m.jsx(qP,{body:Q})}):m.jsx("div",{className:"min-h-[120px] p-3 text-xs text-faint",children:"No description."})}),J&&Q&&m.jsxs("details",{className:"text-xxs text-muted",children:[m.jsx("summary",{className:"cursor-pointer hover:text-ink",children:"Preview rendered Markdown"}),m.jsx("div",{className:"mt-2 p-3 border border-line rounded bg-sidebar/30",children:m.jsx(qP,{body:Q})})]}),t.kind==="task"&&m.jsx(OY,{related:s??[],onOpen:b,onAdd:()=>{me&&k({kind:"quick-create",projectId:me.id,initialKind:"note",parentId:t.id})},project:me}),t.kind!=="comment"&&m.jsx(hY,{entity:t})]})})]})}function hY({entity:n}){const[e,t]=M.useState(!1),r=SF(n.id,{enabled:e}),i=r.data??[];return m.jsxs("div",{children:[m.jsxs("button",{className:"flex items-center gap-1.5 text-xxs uppercase tracking-wider text-muted font-semibold hover:text-ink",onClick:()=>t(s=>!s),children:[m.jsx(ja,{size:12,className:`transition-transform ${e?"rotate-90":""}`}),"History",e&&r.data&&m.jsxs("span",{className:"text-faint normal-case tracking-normal",children:[i.length," edit",i.length===1?"":"s"]})]}),e&&m.jsx("div",{className:"mt-1.5",children:r.isLoading?m.jsx("div",{className:"text-xs text-faint p-3 text-center",children:"Loading…"}):i.length===0?m.jsx("div",{className:"text-xs text-faint border border-dashed border-line rounded p-3 text-center",children:"Never edited since it was written."}):m.jsx("div",{className:"border border-line rounded-md divide-y divide-lineSoft overflow-hidden",children:i.map((s,l)=>{const o=l===0?n:i[l-1];return m.jsx(fY,{before:s,after:o},s.id)})})})]})}function fY({before:n,after:e}){var l;const t=[];(n.title??"")!==(e.title??"")&&t.push(["title",n.title??"(untitled)",e.title??"(untitled)"]),n.status!==e.status&&t.push(["status",n.status,e.status]),n.priority!==e.priority&&t.push(["priority",n.priority,e.priority]),n.tags.join("\0")!==e.tags.join("\0")&&t.push(["tags",n.tags.join(", ")||"—",e.tags.join(", ")||"—"]);const r=n.body!==e.body,i=M.useMemo(()=>r?xF(OF(n.body,e.body)):[],[r,n.body,e.body]),s=((l=n.actor)==null?void 0:l.label)??n.actorKind;return m.jsxs("div",{className:"px-3 py-2 text-xs",children:[m.jsxs("div",{className:"flex items-baseline gap-2 text-xxs text-muted",children:[m.jsxs("span",{className:"font-mono tabular-nums text-faint",children:["#",n.revision]}),m.jsx("span",{children:new Date(n.createdAt).toLocaleString()}),m.jsxs("span",{children:["· by ",m.jsx("span",{className:"text-ink",children:s})]})]}),t.length>0&&m.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(([o,u,h])=>m.jsxs("li",{className:"text-xxs",children:[m.jsxs("span",{className:"text-muted",children:[o,":"]})," ",m.jsx("span",{className:"line-through text-danger/80",children:u})," ",m.jsx("span",{className:"text-faint",children:"→"})," ",m.jsx("span",{className:"text-ink",children:h})]},o))}),r&&m.jsx("pre",{className:"mt-1.5 font-mono text-xxs leading-relaxed whitespace-pre-wrap wrap-break-word bg-sidebar/40 rounded p-2 overflow-x-auto",children:i.map((o,u)=>o.type==="skip"?m.jsxs("div",{className:"text-faint italic",children:["… ",o.count," unchanged line",o.count===1?"":"s"]},u):m.jsxs("div",{className:o.type==="add"?"bg-success/10 text-ink":o.type==="del"?"bg-danger/10 text-muted line-through":"text-muted",children:[m.jsx("span",{className:"select-none text-faint mr-1",children:o.type==="add"?"+":o.type==="del"?"−":" "}),o.text||" "]},u))}),!r&&t.length===0&&m.jsx("div",{className:"mt-1 text-xxs text-faint",children:"No visible difference."})]})}function dY(n){const e=n.rule,t=NE(e.rrule),r=t.preset??"daily",i=t.interval??1,s=i>1?`Every ${i} ${aY[r]}s`:zE[r],l=t.byWeekday.length?` · ${t.byWeekday.join(", ")}`:"",o=e.anchor==="completion"?"after completion":"scheduled",u=e.enabled?"":" · stopped",h=e.nextOccurrenceAt?` · next ${new Date(e.nextOccurrenceAt).toLocaleDateString()}`:"";return`${s}${l} · ${o}${h}${u}`}function WP(n){const e=n?NE(n.rule.rrule):void 0;return{preset:n?(e==null?void 0:e.preset)??"weekly":"none",interval:(e==null?void 0:e.interval)??1,anchor:(n==null?void 0:n.rule.anchor)??"scheduled",byWeekday:(e==null?void 0:e.byWeekday)??[],count:e!=null&&e.count?String(e.count):"",until:(e==null?void 0:e.until)??""}}function pY({isEditing:n,task:e,dueDate:t,recurrence:r,onSave:i,onSkip:s,onStop:l,onSplit:o,busy:u}){const[h,f]=M.useState(()=>WP(r)),[p,g]=M.useState(null);if(M.useEffect(()=>{f(WP(r)),g(null)},[n,e==null?void 0:e.id,e==null?void 0:e.dueAt,r==null?void 0:r.rule.id,r==null?void 0:r.rule.rrule,r==null?void 0:r.rule.anchor]),!e)return null;const x=["done","rejected"].includes(e.status),k=!!(r!=null&&r.rule.enabled)&&(r==null?void 0:r.rule.currentOccurrenceId)===e.id,b=!!(r!=null&&r.rule.enabled),w=h.preset!=="none",S=!!i&&t.length>0&&w&&h.interval>=1,Q=!!o&&!!(r!=null&&r.rule.enabled)&&w&&h.interval>=1;function $(Z){f(K=>({...K,...Z})),g(null)}function R(Z){const K=new Set(h.byWeekday);K.has(Z)?K.delete(Z):K.add(Z),$({byWeekday:dy.filter(N=>K.has(N))})}function I(){const Z={preset:h.preset,interval:h.interval,anchor:h.anchor,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,allDay:!0};return h.preset==="weekly"&&h.byWeekday.length>0&&(Z.byWeekday=h.byWeekday),h.count&&(Z.count=Number(h.count)),h.until&&(Z.until=new Date(`${h.until}T23:59:59Z`).toISOString()),Z}async function T(){if(h.preset==="none"){g(null);return}if(!t){g("Set due date first");return}if(h.count&&h.until){g("Use count or until");return}try{await(i==null?void 0:i(I(),t)),g(null)}catch(Z){g(Z instanceof Error?Z.message:"Could not save repeat")}}async function X(){if(h.preset!=="none"){if(h.count&&h.until){g("Use count or until");return}try{await(o==null?void 0:o(I())),g(null)}catch(Z){g(Z instanceof Error?Z.message:"Could not split series")}}}return!n||x?m.jsxs("span",{className:"min-w-0 flex items-center gap-2",children:[m.jsx("span",{className:r?"text-muted truncate":"text-faint",children:r?dY(r):"None"}),k&&s&&m.jsx("button",{className:"text-faint hover:text-ink disabled:opacity-40 shrink-0",onClick:s,disabled:u,title:"Skip occurrence",children:"Skip"})]}):m.jsxs("span",{className:"min-w-0 flex flex-col gap-1",children:[m.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsxs("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:h.preset,onChange:Z=>$({preset:Z.target.value}),title:"Repeat",children:[m.jsx("option",{value:"none",children:"None"}),RE.map(Z=>m.jsx("option",{value:Z,children:zE[Z]},Z))]}),w&&m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"number",min:1,max:999,className:"w-14 bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:h.interval,onChange:Z=>$({interval:Math.max(1,Number(Z.target.value)||1)}),title:"Interval"}),m.jsxs("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:h.anchor,onChange:Z=>$({anchor:Z.target.value}),title:"Anchor",children:[m.jsx("option",{value:"scheduled",children:"Scheduled"}),m.jsx("option",{value:"completion",children:"Completion"})]}),m.jsx("button",{className:"text-accent hover:underline disabled:opacity-40",onClick:T,disabled:u||!S,children:"Save"}),Q&&m.jsx("button",{className:"text-faint hover:text-ink disabled:opacity-40",onClick:X,disabled:u,title:"Keep past occurrences on the old cadence; apply this cadence going forward",children:"Split"})]}),b&&l&&m.jsx("button",{className:"text-faint hover:text-danger disabled:opacity-40",onClick:l,disabled:u,title:"Stop series",children:"Stop"})]}),w&&h.preset==="weekly"&&m.jsx("span",{className:"flex flex-wrap gap-1",children:dy.map(Z=>m.jsx("button",{type:"button",className:`px-1.5 py-0.5 rounded border text-[10px] ${h.byWeekday.includes(Z)?"border-accent bg-accentSoft text-accent":"border-line bg-surface text-muted hover:text-ink"}`,onClick:()=>R(Z),children:Z},Z))}),w&&m.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[m.jsx("input",{type:"number",min:1,max:1e4,className:"w-20 bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:h.count,onChange:Z=>$({count:Z.target.value,until:Z.target.value?"":h.until}),placeholder:"Count",title:"Count"}),m.jsx("input",{type:"date",className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:h.until,onChange:Z=>$({until:Z.target.value,count:Z.target.value?"":h.count}),title:"Until"}),!t&&m.jsx("span",{className:"text-faint text-xxs",children:"Set due date first"}),p&&m.jsx("span",{className:"text-danger text-xxs truncate",children:p})]})]})}function mY({isEditing:n,isTask:e,status:t,setStatus:r,dueDate:i,setDueDate:s,priority:l,setPriority:o,tagsStr:u,setTagsStr:h,completedAt:f,completedAtStr:p,setCompletedAtStr:g,createdAt:x,actorKind:k,task:b,onStatusChange:w,recurrence:S,recurrenceBusy:Q,onSaveRecurrence:$,onSkipOccurrence:R,onStopRecurrence:I,onSplitRecurrence:T,isRecurringOccurrence:X,occurrenceScope:Z,setOccurrenceScope:K}){return m.jsxs("div",{className:"grid grid-cols-[80px_1fr] gap-x-3 gap-y-1.5 items-center text-xs",children:[e&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Status"}),m.jsxs("span",{className:"flex items-center gap-1.5",children:[n||!b?m.jsx(py,{status:t,size:12}):m.jsx(yp,{task:b,size:12,onStatusChange:w}),n?m.jsx("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:t,onChange:N=>r(N.target.value),children:IE.map(N=>m.jsx("option",{value:N,children:Bd[N]??N},N))}):m.jsx("span",{className:"text-ink",children:Bd[t]??t})]}),m.jsx("span",{className:"text-faint",children:"Due"}),m.jsx("span",{className:"flex items-center gap-1.5",children:n?m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"date",className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:i,onChange:N=>s(N.target.value)}),!i&&m.jsx("span",{className:"text-faint text-xxs",children:"inbox"}),i&&m.jsx("button",{className:"text-faint hover:text-danger text-xxs",onClick:()=>s(""),title:"Clear",children:"✕"})]}):m.jsx("span",{className:i?"text-ink":"text-faint text-xxs",children:i||"inbox"})}),(S||n&&b&&!["done","rejected"].includes(t))&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Repeat"}),m.jsx(pY,{isEditing:n,task:b,dueDate:i,recurrence:S,busy:!!Q,onSave:$,onSkip:R,onStop:I,onSplit:T})]}),n&&X&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Apply to"}),m.jsx("span",{className:"flex items-center gap-1.5",children:m.jsxs("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:Z??"future",onChange:N=>K==null?void 0:K(N.target.value),title:"Recurrence edit scope",children:[m.jsx("option",{value:"future",children:"This and future"}),m.jsx("option",{value:"this",children:"This occurrence only"})]})})]}),m.jsx("span",{className:"text-faint",children:"Priority"}),m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx(Oa,{priority:l,size:12}),n?m.jsx("select",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:l,onChange:N=>o(N.target.value),children:jE.map(N=>m.jsx("option",{value:N,children:xa[N]},N))}):m.jsx("span",{className:"text-ink",children:xa[l]})]}),t==="done"&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-faint",children:"Completed"}),n?m.jsxs("span",{className:"flex items-center gap-1.5",children:[m.jsx("input",{type:"datetime-local",className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:p,onChange:N=>g(N.target.value)}),!p&&m.jsx("span",{className:"text-faint text-xxs",children:"auto"}),p&&m.jsx("button",{className:"text-faint hover:text-danger text-xxs",onClick:()=>g(""),title:"Clear",children:"✕"})]}):m.jsx("span",{className:"text-muted",children:f?new Date(f).toLocaleString():"Not recorded"})]})]}),m.jsx("span",{className:"text-faint",children:"Tags"}),n?m.jsx("input",{className:"bg-transparent border-none text-xs text-ink hover:bg-sidebar rounded px-1 -mx-1 focus:outline-hidden focus:ring-1 focus:ring-accent",value:u,onChange:N=>h(N.target.value),placeholder:"comma, separated"}):m.jsx("span",{className:u?"text-muted":"text-faint",children:u||"none"}),m.jsx("span",{className:"text-faint",children:"Created"}),m.jsxs("span",{className:"text-muted",children:[new Date(x).toLocaleString()," · by ",m.jsx("span",{className:"text-ink",children:k})]})]})}function gY({state:n,dirty:e}){return n==="saving"?m.jsxs("span",{className:"flex items-center gap-1 text-xxs text-muted",children:[m.jsx(uj,{size:11,className:"animate-spin"}),"Saving…"]}):n==="saved"&&!e?m.jsxs("span",{className:"flex items-center gap-1 text-xxs text-faint",children:[m.jsx(c6,{size:11}),"Saved"]}):n==="error"?m.jsx("span",{className:"text-xxs text-danger",children:"Save failed"}):e?m.jsxs("span",{className:"flex items-center gap-1 text-xxs text-faint",children:[m.jsx(u6,{size:11}),"Unsaved"]}):null}function OY({related:n,onOpen:e,onAdd:t,project:r}){const i=n.filter(s=>s.kind==="note");return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[m.jsxs("h3",{className:"text-xxs uppercase tracking-wider text-muted font-semibold",children:["Related notes ",m.jsx("span",{className:"text-faint",children:i.length})]}),m.jsx("button",{onClick:t,className:"text-xs text-accent hover:underline",children:"+ Add note"})]}),i.length===0?m.jsx("div",{className:"text-xs text-faint border border-dashed border-line rounded p-3 text-center",children:"No linked notes yet."}):m.jsx("div",{className:"border border-line rounded-md divide-y divide-lineSoft overflow-hidden",children:i.map(s=>m.jsxs("button",{className:"w-full text-left px-3 py-2 hover:bg-sidebar flex items-start gap-2",onClick:()=>e(s.id),children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(s)?"italic text-muted":"text-ink"}`,children:ln(s)}),!jr(s)&&s.body&&m.jsx("div",{className:"text-xxs text-muted truncate mt-0.5",children:s.body.replace(/\n/g," ").slice(0,140)})]}),s.pinned&&m.jsx(j0,{size:11,className:"text-accent shrink-0 mt-1",fill:"currentColor"})]},s.id))}),!r&&m.jsx("div",{className:"text-xxs text-faint mt-1",children:"No project context — link picker unavailable."})]})}function qP({body:n}){return m.jsx("div",{className:"text-sm leading-relaxed text-ink space-y-2 [&_h1]:text-lg [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-1.5 [&_h2]:text-base [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1 [&_h3]:font-semibold [&_h3]:mt-2 [&_p]:my-1 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-0.5 [&_code]:bg-sidebar [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-xs [&_pre]:bg-sidebar [&_pre]:p-2 [&_pre]:rounded [&_pre]:overflow-x-auto [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_a]:text-accent [&_a]:underline [&_blockquote]:border-l-2 [&_blockquote]:border-line [&_blockquote]:pl-3 [&_blockquote]:text-muted [&_table]:border-collapse [&_th]:border [&_th]:border-line [&_th]:px-2 [&_th]:py-1 [&_td]:border [&_td]:border-line [&_td]:px-2 [&_td]:py-1",children:m.jsx(Kj,{remarkPlugins:[bE],children:n})})}function my(n,e){const[t,r]=M.useState(()=>{if(typeof window>"u")return e;try{const s=window.localStorage.getItem(n);return s===null?e:JSON.parse(s)}catch{return e}});M.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(n,JSON.stringify(t))}catch{}},[n,t]);const i=M.useCallback(s=>r(s),[]);return[t,i]}const Vl={planned:"Planned",active:"Active",watching:"Watching",paused:"Paused",archived:"Archived"},ZE={planned:"Committed, not started",active:"Currently being built",watching:"Built, in maintenance",paused:"Intentionally on hold",archived:"Hidden from active work"},gy=["planned","active","watching","paused","archived"],PO={key:"Key (A→Z)",name:"Name (A→Z)",recent:"Recently active"},VP={archived:!0};function xY(n,e){const t=[...n];return e==="key"?t.sort((r,i)=>r.key.localeCompare(i.key)):e==="name"?t.sort((r,i)=>r.name.localeCompare(i.name)):t.sort((r,i)=>+new Date(i.updatedAt)-+new Date(r.updatedAt))}function FP(){const{open:n}=zt(),{key:e}=Gd(),[t,r]=my("botnote.projectSort","key"),[i,s]=my("botnote.sidebar.projectGroups.collapsed",VP),{data:l,isLoading:o}=Vn({includeArchived:!0}),{data:u}=CE(200),h=(u==null?void 0:u.length)??0,f=M.useMemo(()=>{const k=l??[];return new Map(gy.map(b=>[b,xY(k.filter(w=>w.status===b),t)]))},[l,t]),p=(l==null?void 0:l.length)??0,g=k=>i[k]??VP[k]??!1,x=k=>{const b=g(k);s({...i,[k]:!b})};return m.jsxs("aside",{className:"w-52 shrink-0 border-r border-line bg-sidebar flex flex-col scrollbar-thin overflow-y-auto text-sm",children:[m.jsxs("nav",{className:"px-1.5 pt-2 space-y-px",children:[m.jsx(Qo,{to:"/",end:!0,icon:m.jsx(a6,{size:12,className:"opacity-70"}),label:"Tasks",shortcut:"g d"}),m.jsx(Qo,{to:"/today",icon:m.jsx(pj,{size:12,className:"opacity-70"}),label:"Today",shortcut:"g t"}),m.jsx(Qo,{to:"/inbox",icon:m.jsx(_d,{size:12,className:"opacity-70"}),label:"Inbox",shortcut:"g i"}),m.jsx(Qo,{to:"/dashboard",icon:m.jsx(C6,{size:12,className:"opacity-70"}),label:"Workspace",shortcut:"g w"})]}),m.jsxs("div",{className:"mt-3 px-3 py-1.5 flex items-center justify-between",children:[m.jsx("div",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:"Projects"}),m.jsxs("div",{className:"flex items-center gap-0.5",children:[m.jsx(G0,{trigger:m.jsx("button",{className:"text-muted hover:text-ink p-0.5 rounded hover:bg-sidebarHover flex items-center gap-0.5",title:`Sort: ${PO[t]}`,children:m.jsx(ey,{size:11})}),align:"end",children:k=>m.jsx(m.Fragment,{children:Object.keys(PO).map(b=>m.jsxs("button",{className:"popover-item",onClick:()=>{r(b),k()},children:[m.jsx("span",{children:PO[b]}),t===b&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]},b))})}),m.jsx("button",{className:"text-muted hover:text-ink p-0.5 rounded hover:bg-sidebarHover",title:"New project (n)",onClick:()=>n({kind:"new-project"}),children:m.jsx(qc,{size:11})})]})]}),m.jsxs("nav",{className:"px-1.5 space-y-px flex-1",children:[o&&m.jsx("div",{className:"px-2 py-1 text-xs text-faint",children:"Loading…"}),!o&&p===0&&m.jsxs("button",{className:"w-full text-left px-2 py-1 text-xs text-muted hover:bg-sidebarHover rounded",onClick:()=>n({kind:"new-project"}),children:["No projects yet. ",m.jsx("span",{className:"text-accent",children:"Create →"})]}),gy.map(k=>{const b=f.get(k)??[];if(o||b.length===0)return null;const w=g(k);return m.jsxs("div",{className:"pt-2 first:pt-0",children:[m.jsxs("button",{type:"button",className:"w-full px-1.5 pb-1 flex items-center gap-1 text-xxs uppercase tracking-wider text-muted font-medium hover:text-ink",onClick:()=>x(k),title:`${w?"Expand":"Collapse"} ${Vl[k]}`,children:[w?m.jsx(ja,{size:10}):m.jsx(ey,{size:10}),m.jsx("span",{children:Vl[k]}),m.jsx("span",{className:"ml-auto text-faint tabular-nums",children:b.length})]}),!w&&b.map(S=>m.jsx(yY,{project:S,activeKey:e},S.id))]},k)})]}),m.jsxs("div",{className:"border-t border-line/60 px-1.5 py-1.5 space-y-px",children:[m.jsx(Qo,{to:"/trash",icon:m.jsx(wc,{size:12,className:"opacity-70"}),label:"Trash",badge:h>0?h:void 0}),m.jsx(Qo,{to:"/settings",icon:m.jsx(aj,{size:12,className:"opacity-70"}),label:"Settings"})]})]})}function yY({project:n,activeKey:e}){return m.jsxs(VC,{to:`/p/${n.key}`,title:n.status==="archived"?`${n.name} (archived)`:n.name,className:({isActive:t})=>`flex items-center gap-2 px-2 py-1 text-xs rounded ${t||e===n.key?"bg-accentSoft text-accentText":"text-ink2 hover:bg-sidebarHover"} ${n.status==="archived"?"opacity-60":""}`,children:[m.jsx(el,{color:n.color,icon:n.icon,size:11}),m.jsx("span",{className:"font-mono text-xxs tabular-nums opacity-90 shrink-0",style:{color:n.color},children:n.key}),m.jsx("span",{className:"truncate text-muted",children:n.name})]})}function Qo({to:n,end:e,icon:t,label:r,shortcut:i,badge:s}){return m.jsxs(VC,{to:n,end:e,className:({isActive:l})=>`group flex items-center gap-2 px-2 py-1 rounded text-xs ${l?"bg-accentSoft text-accentText":"text-ink2 hover:bg-sidebarHover"}`,title:i?`${r} (${i})`:r,children:[t,m.jsx("span",{children:r}),s!=null&&m.jsx("span",{className:"ml-auto text-xxs text-faint tabular-nums",children:s}),i&&m.jsx("kbd",{className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity",children:i})]})}function kY({onMenuClick:n}){const{open:e}=zt(),t=Gs(),r=typeof navigator<"u"&&navigator.platform.includes("Mac")?"⌘":"Ctrl";async function i(){try{await We.logout()}catch{}t("/login",{replace:!0})}return m.jsxs("header",{className:"h-11 flex items-center justify-between px-3 border-b border-line bg-surface",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("button",{className:"btn btn-ghost h-7! w-7! p-0! md:hidden",onClick:n,title:"Menu","aria-label":"Toggle sidebar",children:m.jsx(E6,{size:14})}),m.jsxs(ba,{to:"/",className:"flex items-center gap-1.5 text-ink hover:opacity-90",children:[m.jsx("img",{src:"/favicon.svg",alt:"","aria-hidden":"true",className:"w-[18px] h-[18px]"}),m.jsx("span",{className:"text-xs font-semibold tracking-tight",children:"botnote"})]})]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsxs("button",{className:"btn pl-2! pr-1.5! gap-2 md:min-w-[220px] justify-between! text-muted",onClick:()=>e({kind:"search"}),title:"Search (⌘K)",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Dd,{size:12}),m.jsx("span",{className:"text-xs hidden sm:inline",children:"Search…"})]}),m.jsxs("kbd",{className:"hidden md:inline-block",children:[r,"K"]})]}),m.jsxs("button",{className:"btn btn-primary",onClick:()=>e({kind:"quick-create"}),title:"Quick create (c)",children:[m.jsx(qc,{size:12}),m.jsx("span",{className:"text-xs hidden sm:inline",children:"New"}),m.jsx("kbd",{className:"bg-white/15! border-white/25! text-white! hidden md:inline-block",children:"c"})]}),m.jsx("button",{className:"btn px-1.5! py-1! text-muted hover:text-red-500!",onClick:i,title:"Log out","aria-label":"Log out",children:m.jsx(cj,{size:12})})]})]})}function vY(){n5();const[n,e]=M.useState(!1),t=Us();return M.useEffect(()=>{e(!1)},[t.pathname,t.search]),m.jsxs("div",{className:"h-full w-full flex flex-col",children:[m.jsx(kY,{onMenuClick:()=>e(r=>!r)}),m.jsxs("div",{className:"flex-1 min-h-0 flex",children:[m.jsx("div",{className:"hidden md:flex shrink-0",children:m.jsx(FP,{})}),m.jsx("main",{className:"flex-1 min-w-0 min-h-0 overflow-hidden bg-bg",children:m.jsx(DN,{})})]}),n&&m.jsxs("div",{className:"fixed inset-0 z-40 md:hidden",children:[m.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:()=>e(!1)}),m.jsx("div",{className:"absolute inset-y-0 left-0 flex shadow-modal",children:m.jsx(FP,{})})]}),m.jsx(uY,{})]})}function XE({icon:n,color:e,onIconChange:t,onColorChange:r}){return m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-xxs text-muted uppercase tracking-wider mb-1",children:"Color"}),m.jsx("div",{className:"flex flex-wrap gap-1.5",children:sY.map(i=>m.jsx("button",{type:"button",onClick:()=>r(i.value),className:"relative w-6 h-6 rounded-full border border-line/80 hover:scale-110 transition-transform",style:{backgroundColor:i.value},title:i.name,children:e===i.value&&m.jsx(Ki,{size:12,className:"absolute inset-0 m-auto text-white",strokeWidth:3})},i.value))})]}),m.jsxs("div",{children:[m.jsx("div",{className:"text-xxs text-muted uppercase tracking-wider mb-1",children:"Icon"}),m.jsx("div",{className:"flex flex-wrap gap-1",children:LE.map(i=>m.jsx("button",{type:"button",onClick:()=>t(i.name),className:`w-7 h-7 rounded flex items-center justify-center border transition-colors ${n===i.name?"border-accent bg-accentSoft":"border-line bg-surface hover:bg-sidebar"}`,title:i.name,children:m.jsx(el,{color:e,icon:i.name,size:14})},i.name))})]})]})}function Qc({title:n,children:e,width:t="max-w-2xl"}){const{close:r}=zt();return M.useEffect(()=>{const i=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=i}},[]),m.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-20 px-4 bg-ink/20",onClick:r,children:m.jsxs("div",{className:`w-full ${t} bg-surface border border-line rounded-lg shadow-2xl overflow-hidden`,onClick:i=>i.stopPropagation(),children:[m.jsxs("div",{className:"h-9 px-3 flex items-center justify-between border-b border-line",children:[m.jsx("div",{className:"text-xs font-semibold text-ink",children:n}),m.jsx("button",{onClick:r,className:"text-muted hover:text-ink p-0.5 rounded hover:bg-line/60",title:"Close (Esc)",children:m.jsx(Sc,{size:14})})]}),e]})})}function bY({projectId:n}){const{data:e}=wF(n),t=ZF(),{close:r}=zt(),[i,s]=M.useState(""),[l,o]=M.useState("active"),[u,h]=M.useState(_E),[f,p]=M.useState(DE);if(M.useEffect(()=>{e&&(s(e.name),o(e.status),h(e.color),p(e.icon))},[e==null?void 0:e.id,e==null?void 0:e.name,e==null?void 0:e.status,e==null?void 0:e.color,e==null?void 0:e.icon]),!e)return m.jsx(Qc,{title:"Project settings",width:"max-w-md",children:m.jsx("div",{className:"p-4 text-sm text-muted",children:"Loading…"})});const g=e,x=i!==g.name||l!==g.status||u!==g.color||f!==g.icon,k=i.trim().length>0;return m.jsx(Qc,{title:`Settings · ${g.key}`,width:"max-w-md",children:m.jsxs("form",{onSubmit:async b=>{b.preventDefault(),!(!x||!k)&&(await t.mutateAsync({id:g.id,fields:{name:i.trim(),status:l,color:u,icon:f}}),r())},className:"p-3 space-y-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Name"}),m.jsx("input",{autoFocus:!0,className:"input",value:i,onChange:b=>s(b.target.value)})]}),m.jsx(XE,{icon:f,color:u,onIconChange:p,onColorChange:h}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Status"}),m.jsx("select",{className:"input",value:l,onChange:b=>o(b.target.value),children:TE.map(b=>m.jsxs("option",{value:b,children:[Vl[b]," · ",ZE[b]]},b))})]}),m.jsx("div",{className:"flex justify-end items-center pt-1",children:m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{type:"button",className:"btn",onClick:r,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!x||!k||t.isPending,children:t.isPending?"Saving…":"Save"})]})}),t.error&&m.jsx("div",{className:"text-xs text-danger",children:t.error.message})]})})}function wY(){const[n,e]=M.useState(""),[t,r]=M.useState(""),[i,s]=M.useState("active"),[l,o]=M.useState(""),[u,h]=M.useState(_E),[f,p]=M.useState(DE),g=zF(),{close:x}=zt(),k=Gs(),b=/^[A-Z][A-Z0-9_]{0,19}$/.test(n)&&t.trim().length>0;return m.jsx(Qc,{title:"New project",width:"max-w-md",children:m.jsxs("form",{onSubmit:async w=>{if(w.preventDefault(),!b)return;const S=await g.mutateAsync({key:n.trim(),name:t.trim(),status:i,color:u,icon:f,agentsMd:l.trim()});x(),k(`/p/${S.key}`)},className:"p-3 space-y-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Key (uppercase, e.g. BOT)"}),m.jsx("input",{autoFocus:!0,className:"input font-mono uppercase",value:n,onChange:w=>e(w.target.value.toUpperCase()),placeholder:"BOT",maxLength:20})]}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Name"}),m.jsx("input",{className:"input",value:t,onChange:w=>r(w.target.value),placeholder:"botnote"})]}),m.jsx(XE,{icon:f,color:u,onIconChange:p,onColorChange:h}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"Status"}),m.jsx("select",{className:"input",value:i,onChange:w=>s(w.target.value),children:TE.map(w=>m.jsxs("option",{value:w,children:[Vl[w]," · ",ZE[w]]},w))})]}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xxs text-muted uppercase tracking-wider mb-1",children:"AGENTS.md (optional)"}),m.jsx("textarea",{className:"input h-24! py-1.5 font-mono text-xs leading-snug resize-y",value:l,onChange:w=>o(w.target.value),placeholder:`## Critical
482
+ - ALWAYS run pnpm typecheck before commit.`})]}),m.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[m.jsx("button",{type:"button",className:"btn",onClick:x,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!b||g.isPending,children:g.isPending?"Creating…":"Create project"})]}),g.error&&m.jsx("div",{className:"text-xs text-danger",children:g.error.message})]})})}function SY({initialProjectId:n,initialKind:e,initialParentId:t}){const{data:r}=Vn(),[i,s]=M.useState(e??"task"),[l,o]=M.useState(n??""),[u,h]=M.useState(""),[f,p]=M.useState(""),[g,x]=M.useState(""),[k,b]=M.useState(""),[w,S]=M.useState("none"),[Q,$]=M.useState("none"),[R,I]=M.useState(1),[T,X]=M.useState("scheduled"),[Z,K]=M.useState(!1),[N,U]=M.useState(t??""),V=$E(),se=QE(),{close:J}=zt(),{open:G}=Pi(),Oe=r==null?void 0:r.find(C=>C.id===l),de=i==="note",{data:ee}=U0(de&&l?l:void 0,["task"]),le=l.length>0&&(de?u.trim().length>0||f.trim().length>0:u.trim().length>0&&(Q==="none"||k.length>0));return m.jsx(Qc,{title:"Quick create",width:"max-w-xl",children:m.jsxs("form",{onSubmit:async C=>{if(C.preventDefault(),!le)return;const D=u.trim(),F=g.split(",").map(ce=>ce.trim()).filter(Boolean),E=i==="task"?await V.mutateAsync({kind:"task",projectId:l,title:D,body:f.trim(),tags:F,actorKind:"human",dueAt:k?new Date(k).toISOString():null,priority:w}):await V.mutateAsync({kind:"note",projectId:l,title:D||null,body:f.trim(),tags:F,actorKind:"human",pinned:Z,parentId:N||null});i==="task"&&Q!=="none"&&await se.mutateAsync({taskId:E.id,input:{preset:Q,interval:R,anchor:T,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,allDay:!0}}),J(),G(E.id)},className:"p-3 space-y-3",children:[m.jsxs("div",{className:"flex gap-2",children:[m.jsx("div",{className:"seg w-32",children:YF.map(C=>m.jsx("button",{type:"button","data-active":i===C,onClick:()=>s(C),className:"flex-1 justify-center capitalize",children:C},C))}),m.jsxs("select",{className:"input flex-1",value:l,onChange:C=>o(C.target.value),children:[m.jsx("option",{value:"",children:"— pick a project —"}),r==null?void 0:r.map(C=>m.jsxs("option",{value:C.id,children:[C.key," · ",C.name]},C.id))]})]}),m.jsx("input",{autoFocus:!0,className:"input",placeholder:de?"Title (optional)":"Title",value:u,onChange:C=>h(C.target.value)}),m.jsx("textarea",{className:"input h-32! py-1.5 font-mono text-xs leading-snug resize-y",placeholder:"Body (Markdown, optional)",value:f,onChange:C=>p(C.target.value)}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("input",{className:"input flex-1",placeholder:"Tags (comma-separated, optional)",value:g,onChange:C=>x(C.target.value)}),i==="task"&&m.jsxs(m.Fragment,{children:[m.jsx("input",{type:"date",className:"input w-36",value:k,onChange:C=>b(C.target.value),title:"Due date"}),m.jsx("select",{className:"input w-36",value:w,onChange:C=>S(C.target.value),title:"Priority",children:jE.map(C=>m.jsx("option",{value:C,children:xa[C]},C))})]})]}),i==="task"&&m.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_84px_132px] gap-2",children:[m.jsxs("select",{className:"input",value:Q,onChange:C=>$(C.target.value),title:"Repeat",children:[m.jsx("option",{value:"none",children:"Repeat: none"}),m.jsx("option",{value:"hourly",children:"Hourly"}),m.jsx("option",{value:"daily",children:"Daily"}),m.jsx("option",{value:"weekly",children:"Weekly"}),m.jsx("option",{value:"monthly",children:"Monthly"}),m.jsx("option",{value:"yearly",children:"Yearly"})]}),m.jsx("input",{type:"number",min:1,max:999,className:"input",value:R,disabled:Q==="none",onChange:C=>I(Math.max(1,Number(C.target.value)||1)),title:"Repeat interval"}),m.jsxs("select",{className:"input",value:T,disabled:Q==="none",onChange:C=>X(C.target.value),title:"Repeat anchor",children:[m.jsx("option",{value:"scheduled",children:"Scheduled"}),m.jsx("option",{value:"completion",children:"Completion"})]})]}),i==="task"&&w!=="none"&&m.jsxs("div",{className:"flex items-center gap-1.5 text-xxs text-muted",children:[m.jsx(Oa,{priority:w,size:11}),m.jsxs("span",{children:[xa[w]," priority"]})]}),de&&m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted cursor-pointer",children:[m.jsx("input",{type:"checkbox",checked:Z,onChange:C=>K(C.target.checked)}),m.jsx("span",{children:"📌 Pin to project — auto-include in agent opening brief"})]}),ee&&ee.length>0&&m.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[m.jsx("span",{className:"shrink-0",children:"Link to task:"}),m.jsxs("select",{className:"input flex-1 h-7! text-xs",value:N,onChange:C=>U(C.target.value),children:[m.jsx("option",{value:"",children:"— none —"}),ee.map(C=>m.jsxs("option",{value:C.id,children:[Oe!=null&&Oe.key&&C.sequenceId?`${Oe.key}-${C.sequenceId} · `:"",ln(C)]},C.id))]})]})]}),m.jsxs("div",{className:"flex justify-between items-center pt-1",children:[m.jsxs("div",{className:"text-xxs text-muted",children:[m.jsx("kbd",{children:"⌘"}),"+",m.jsx("kbd",{children:"Enter"})," to submit · ",m.jsx("kbd",{children:"Esc"})," to close"]}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("button",{type:"button",className:"btn",onClick:J,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-primary",disabled:!le||V.isPending,children:V.isPending?"Creating…":`Create ${i}`})]})]}),V.error&&m.jsx("div",{className:"text-xs text-danger",children:V.error.message})]})})}const PY={task:"task",note:"note",comment:"comment",feedback:"feedback"};function CY(){const[n,e]=M.useState(""),[t,r]=M.useState(""),{close:i}=zt(),{open:s}=Pi(),{data:l}=Vn();M.useEffect(()=>{const f=setTimeout(()=>r(n.trim()),200);return()=>clearTimeout(f)},[n]);const{data:o,isFetching:u}=PE(t?{query:t,limit:20}:null),h=M.useMemo(()=>{const f=new Map;return l==null||l.forEach(p=>f.set(p.id,p.key)),f},[l]);return m.jsxs(Qc,{title:"Search",children:[m.jsx("div",{className:"p-3 pb-1",children:m.jsxs("div",{className:"flex items-center gap-2 px-2 h-9 border border-line rounded bg-surface focus-within:border-accent focus-within:ring-1 focus-within:ring-accentSoft",children:[m.jsx(Dd,{size:14,className:"text-muted"}),m.jsx("input",{autoFocus:!0,placeholder:"Hybrid search (BM25 + vector + time decay)",className:"flex-1 bg-transparent border-none outline-hidden text-sm",value:n,onChange:f=>e(f.target.value)}),u&&m.jsx("span",{className:"text-xxs text-muted",children:"searching…"})]})}),m.jsxs("div",{className:"max-h-[60vh] overflow-y-auto scrollbar-thin",children:[t&&!u&&(!o||o.hits.length===0)&&m.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted",children:"No matches."}),o==null?void 0:o.hits.map(f=>{const p=f.entity.projectId?h.get(f.entity.projectId):null;return m.jsxs("button",{onClick:()=>{i(),s(f.entity.id)},className:"w-full px-3 py-2 row-hover text-left flex items-start gap-3 border-t border-line/60",children:[m.jsx("span",{className:"chip mt-0.5",children:PY[f.entity.kind]}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"text-sm text-ink truncate",children:ln(f.entity)}),m.jsx("div",{className:"text-xs text-muted truncate mt-0.5",children:f.entity.body.replace(/\n/g," ").slice(0,140)||"—"}),m.jsxs("div",{className:"text-xxs text-faint mt-0.5 flex gap-2",children:[p&&m.jsxs("span",{children:["· ",p]}),m.jsxs("span",{children:["· score ",f.score.toFixed(3)]}),f.components.bm25&&m.jsx("span",{children:"· bm25"}),f.components.cosine&&m.jsx("span",{children:"· vec"})]})]}),m.jsx(r6,{size:13,className:"text-faint mt-1"})]},f.entity.id)}),o&&m.jsxs("div",{className:"px-3 py-2 text-xxs text-muted border-t border-line/60",children:[o.hits.length," result(s) · embedding ",o.embeddingUsed?"ON":"OFF (BM25-only)"]})]})]})}function QY(){const{active:n}=zt();if(!n)return null;switch(n.kind){case"search":return m.jsx(CY,{});case"quick-create":return m.jsx(SY,{initialProjectId:n.projectId,initialKind:n.initialKind,initialParentId:n.parentId});case"new-project":return m.jsx(wY,{});case"edit-project":return m.jsx(bY,{projectId:n.projectId})}}const $Y=`## Critical
483
483
  - NEVER commit credentials.
484
484
  - ALWAYS run tests before commit.
485
485
 
@@ -488,7 +488,7 @@ Error generating stack: `+v.message+`
488
488
 
489
489
  ## Conventions
490
490
  - (idempotent writes, naming, etc.)
491
- `;function TY(){const{key:n}=Gd(),{data:e}=SE(n),t=XF(),[r,i]=M.useState(""),[s,l]=M.useState("edit");if(M.useEffect(()=>{e&&i(e.agentsMd)},[e==null?void 0:e.id]),!e)return m.jsx("div",{className:"p-6 text-sm text-muted",children:"Loading…"});const o=r!==e.agentsMd;return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("div",{className:"px-6 pt-4 pb-2 flex items-center justify-between border-b border-line bg-surface",children:[m.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[m.jsxs(ba,{to:`/p/${e.key}`,className:"text-muted hover:text-ink flex items-center gap-1.5",children:[m.jsx(oj,{size:14}),m.jsx(el,{color:e.color,icon:e.icon,size:12}),m.jsx("span",{className:"font-mono text-xs",style:{color:e.color},children:e.key})]}),m.jsx("span",{className:"text-muted",children:"/"}),m.jsxs("div",{className:"flex items-center gap-1.5 text-ink",children:[m.jsx(dj,{size:14}),m.jsx("span",{className:"font-semibold",children:"AGENTS.md"})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"flex border border-line rounded overflow-hidden",children:[m.jsx("button",{className:`px-2 py-1 text-xs flex items-center gap-1 ${s==="edit"?"bg-accent text-white":"bg-surface text-muted hover:bg-sidebar"}`,onClick:()=>l("edit"),children:"Edit"}),m.jsxs("button",{className:`px-2 py-1 text-xs flex items-center gap-1 border-l border-line ${s==="preview"?"bg-accent text-white":"bg-surface text-muted hover:bg-sidebar"}`,onClick:()=>l("preview"),children:[m.jsx(p6,{size:11})," Preview"]})]}),m.jsxs("button",{className:"btn btn-primary",disabled:!o||t.isPending,onClick:async()=>{await t.mutateAsync({id:e.id,agentsMd:r})},children:[m.jsx(D6,{size:12})," ",t.isPending?"Saving…":o?"Save":"Saved"]})]})]}),m.jsx("div",{className:"px-6 pt-2 text-xxs text-muted",children:"This text is auto-injected into every agent's opening brief for this project. Keep it short (< 200 lines) and imperative."}),m.jsx("div",{className:"flex-1 min-h-0 px-6 pb-6 pt-3",children:s==="edit"?m.jsx("div",{className:"h-full border border-line rounded bg-surface overflow-hidden",children:m.jsx(T0,{value:r,onChange:u=>i(u),extensions:[fT()],placeholder:$Y,height:"100%",minHeight:"100%",theme:"light",basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLine:!0}})}):m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin border border-line rounded bg-surface p-6",children:m.jsx("div",{className:"prose-sm max-w-2xl text-sm leading-relaxed text-ink space-y-2 [&_h1]:text-lg [&_h1]:font-semibold [&_h2]:text-base [&_h2]:font-semibold [&_ul]:list-disc [&_ul]:pl-5 [&_code]:bg-sidebar [&_code]:px-1 [&_code]:rounded",children:r?m.jsx(Kj,{remarkPlugins:[bE],children:r}):m.jsx("div",{className:"text-sm text-faint italic",children:"(empty)"})})})})]})}const BE=6048e5,jY=864e5,_f=43200,YP=1440,UP=Symbol.for("constructDateFrom");function dr(n,e){return typeof n=="function"?n(e):n&&typeof n=="object"&&UP in n?n[UP](e):n instanceof Date?new n.constructor(e):new Date(e)}function Qt(n,e){return dr(e||n,n)}function kp(n,e,t){const r=Qt(n,t==null?void 0:t.in);return isNaN(e)?dr(n,NaN):(e&&r.setDate(r.getDate()+e),r)}function EY(n,e,t){const r=Qt(n,t==null?void 0:t.in);if(isNaN(e))return dr(n,NaN);if(!e)return r;const i=r.getDate(),s=dr(n,r.getTime());s.setMonth(r.getMonth()+e+1,0);const l=s.getDate();return i>=l?s:(r.setFullYear(s.getFullYear(),s.getMonth(),i),r)}let MY={};function Aa(){return MY}function ki(n,e){var o,u,h,f;const t=Aa(),r=(e==null?void 0:e.weekStartsOn)??((u=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:u.weekStartsOn)??t.weekStartsOn??((f=(h=t.locale)==null?void 0:h.options)==null?void 0:f.weekStartsOn)??0,i=Qt(n,e==null?void 0:e.in),s=i.getDay(),l=(s<r?7:0)+s-r;return i.setDate(i.getDate()-l),i.setHours(0,0,0,0),i}function Wd(n,e){return ki(n,{...e,weekStartsOn:1})}function WE(n,e){const t=Qt(n,e==null?void 0:e.in),r=t.getFullYear(),i=dr(t,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=Wd(i),l=dr(t,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const o=Wd(l);return t.getTime()>=s.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function qd(n){const e=Qt(n),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+n-+t}function Gl(n,...e){const t=dr.bind(null,n||e.find(r=>typeof r=="object"));return e.map(t)}function Fl(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setHours(0,0,0,0),t}function AY(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e),s=Fl(r),l=Fl(i),o=+s-qd(s),u=+l-qd(l);return Math.round((o-u)/jY)}function RY(n,e){const t=WE(n,e),r=dr(n,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),Wd(r)}function NY(n,e,t){return kp(n,e*7,t)}function Jf(n,e){const t=+Qt(n)-+Qt(e);return t<0?-1:t>0?1:t}function qE(n){return dr(n,Date.now())}function LY(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e);return+Fl(r)==+Fl(i)}function _Y(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function DY(n){return!(!_Y(n)&&typeof n!="number"||isNaN(+Qt(n)))}function IY(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e),s=r.getFullYear()-i.getFullYear(),l=r.getMonth()-i.getMonth();return s*12+l}function zY(n){return e=>{const r=(n?Math[n]:Math.trunc)(e);return r===0?0:r}}function ZY(n,e){return+Qt(n)-+Qt(e)}function H0(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setHours(23,59,59,999),t}function VE(n,e){const t=Qt(n,e==null?void 0:e.in),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function XY(n,e){const t=Qt(n,e==null?void 0:e.in);return+H0(t,e)==+VE(t,e)}function BY(n,e,t){const[r,i,s]=Gl(t==null?void 0:t.in,n,n,e),l=Jf(i,s),o=Math.abs(IY(i,s));if(o<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-l*o);let u=Jf(i,s)===-l;XY(r)&&o===1&&Jf(r,s)===1&&(u=!1);const h=l*(o-+u);return h===0?0:h}function WY(n,e,t){const r=ZY(n,e)/1e3;return zY(t==null?void 0:t.roundingMethod)(r)}function qY(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setDate(1),t.setHours(0,0,0,0),t}function VY(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}function Oy(n,e){var o,u,h,f;const t=Aa(),r=(e==null?void 0:e.weekStartsOn)??((u=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:u.weekStartsOn)??t.weekStartsOn??((f=(h=t.locale)==null?void 0:h.options)==null?void 0:f.weekStartsOn)??0,i=Qt(n,e==null?void 0:e.in),s=i.getDay(),l=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+l),i.setHours(23,59,59,999),i}const FY={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},YY=(n,e,t)=>{let r;const i=FY[n];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+r:r+" ago":r};function CO(n){return(e={})=>{const t=e.width?String(e.width):n.defaultWidth;return n.formats[t]||n.formats[n.defaultWidth]}}const UY={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},GY={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},HY={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},KY={date:CO({formats:UY,defaultWidth:"full"}),time:CO({formats:GY,defaultWidth:"full"}),dateTime:CO({formats:HY,defaultWidth:"full"})},JY={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},eU=(n,e,t,r)=>JY[n];function ju(n){return(e,t)=>{const r=t!=null&&t.context?String(t.context):"standalone";let i;if(r==="formatting"&&n.formattingValues){const l=n.defaultFormattingWidth||n.defaultWidth,o=t!=null&&t.width?String(t.width):l;i=n.formattingValues[o]||n.formattingValues[l]}else{const l=n.defaultWidth,o=t!=null&&t.width?String(t.width):n.defaultWidth;i=n.values[o]||n.values[l]}const s=n.argumentCallback?n.argumentCallback(e):e;return i[s]}}const tU={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},nU={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},rU={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},iU={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},sU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},lU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},oU=(n,e)=>{const t=Number(n),r=t%100;if(r>20||r<10)switch(r%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},aU={ordinalNumber:oU,era:ju({values:tU,defaultWidth:"wide"}),quarter:ju({values:nU,defaultWidth:"wide",argumentCallback:n=>n-1}),month:ju({values:rU,defaultWidth:"wide"}),day:ju({values:iU,defaultWidth:"wide"}),dayPeriod:ju({values:sU,defaultWidth:"wide",formattingValues:lU,defaultFormattingWidth:"wide"})};function Eu(n){return(e,t={})=>{const r=t.width,i=r&&n.matchPatterns[r]||n.matchPatterns[n.defaultMatchWidth],s=e.match(i);if(!s)return null;const l=s[0],o=r&&n.parsePatterns[r]||n.parsePatterns[n.defaultParseWidth],u=Array.isArray(o)?cU(o,p=>p.test(l)):uU(o,p=>p.test(l));let h;h=n.valueCallback?n.valueCallback(u):u,h=t.valueCallback?t.valueCallback(h):h;const f=e.slice(l.length);return{value:h,rest:f}}}function uU(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&e(n[t]))return t}function cU(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return t}function hU(n){return(e,t={})=>{const r=e.match(n.matchPattern);if(!r)return null;const i=r[0],s=e.match(n.parsePattern);if(!s)return null;let l=n.valueCallback?n.valueCallback(s[0]):s[0];l=t.valueCallback?t.valueCallback(l):l;const o=e.slice(i.length);return{value:l,rest:o}}}const fU=/^(\d+)(th|st|nd|rd)?/i,dU=/\d+/i,pU={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},mU={any:[/^b/i,/^(a|c)/i]},gU={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},OU={any:[/1/i,/2/i,/3/i,/4/i]},xU={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},yU={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},kU={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},vU={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},bU={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},wU={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},SU={ordinalNumber:hU({matchPattern:fU,parsePattern:dU,valueCallback:n=>parseInt(n,10)}),era:Eu({matchPatterns:pU,defaultMatchWidth:"wide",parsePatterns:mU,defaultParseWidth:"any"}),quarter:Eu({matchPatterns:gU,defaultMatchWidth:"wide",parsePatterns:OU,defaultParseWidth:"any",valueCallback:n=>n+1}),month:Eu({matchPatterns:xU,defaultMatchWidth:"wide",parsePatterns:yU,defaultParseWidth:"any"}),day:Eu({matchPatterns:kU,defaultMatchWidth:"wide",parsePatterns:vU,defaultParseWidth:"any"}),dayPeriod:Eu({matchPatterns:bU,defaultMatchWidth:"any",parsePatterns:wU,defaultParseWidth:"any"})},FE={code:"en-US",formatDistance:YY,formatLong:KY,formatRelative:eU,localize:aU,match:SU,options:{weekStartsOn:0,firstWeekContainsDate:1}};function PU(n,e){const t=Qt(n,e==null?void 0:e.in);return AY(t,VY(t))+1}function CU(n,e){const t=Qt(n,e==null?void 0:e.in),r=+Wd(t)-+RY(t);return Math.round(r/BE)+1}function YE(n,e){var f,p,g,x;const t=Qt(n,e==null?void 0:e.in),r=t.getFullYear(),i=Aa(),s=(e==null?void 0:e.firstWeekContainsDate)??((p=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??i.firstWeekContainsDate??((x=(g=i.locale)==null?void 0:g.options)==null?void 0:x.firstWeekContainsDate)??1,l=dr((e==null?void 0:e.in)||n,0);l.setFullYear(r+1,0,s),l.setHours(0,0,0,0);const o=ki(l,e),u=dr((e==null?void 0:e.in)||n,0);u.setFullYear(r,0,s),u.setHours(0,0,0,0);const h=ki(u,e);return+t>=+o?r+1:+t>=+h?r:r-1}function QU(n,e){var o,u,h,f;const t=Aa(),r=(e==null?void 0:e.firstWeekContainsDate)??((u=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:u.firstWeekContainsDate)??t.firstWeekContainsDate??((f=(h=t.locale)==null?void 0:h.options)==null?void 0:f.firstWeekContainsDate)??1,i=YE(n,e),s=dr((e==null?void 0:e.in)||n,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),ki(s,e)}function $U(n,e){const t=Qt(n,e==null?void 0:e.in),r=+ki(t,e)-+QU(t,e);return Math.round(r/BE)+1}function lt(n,e){const t=n<0?"-":"",r=Math.abs(n).toString().padStart(e,"0");return t+r}const ws={y(n,e){const t=n.getFullYear(),r=t>0?t:1-t;return lt(e==="yy"?r%100:r,e.length)},M(n,e){const t=n.getMonth();return e==="M"?String(t+1):lt(t+1,2)},d(n,e){return lt(n.getDate(),e.length)},a(n,e){const t=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(n,e){return lt(n.getHours()%12||12,e.length)},H(n,e){return lt(n.getHours(),e.length)},m(n,e){return lt(n.getMinutes(),e.length)},s(n,e){return lt(n.getSeconds(),e.length)},S(n,e){const t=e.length,r=n.getMilliseconds(),i=Math.trunc(r*Math.pow(10,t-3));return lt(i,e.length)}},$o={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},GP={G:function(n,e,t){const r=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(r,{width:"abbreviated"});case"GGGGG":return t.era(r,{width:"narrow"});case"GGGG":default:return t.era(r,{width:"wide"})}},y:function(n,e,t){if(e==="yo"){const r=n.getFullYear(),i=r>0?r:1-r;return t.ordinalNumber(i,{unit:"year"})}return ws.y(n,e)},Y:function(n,e,t,r){const i=YE(n,r),s=i>0?i:1-i;if(e==="YY"){const l=s%100;return lt(l,2)}return e==="Yo"?t.ordinalNumber(s,{unit:"year"}):lt(s,e.length)},R:function(n,e){const t=WE(n);return lt(t,e.length)},u:function(n,e){const t=n.getFullYear();return lt(t,e.length)},Q:function(n,e,t){const r=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return lt(r,2);case"Qo":return t.ordinalNumber(r,{unit:"quarter"});case"QQQ":return t.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(r,{width:"wide",context:"formatting"})}},q:function(n,e,t){const r=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return lt(r,2);case"qo":return t.ordinalNumber(r,{unit:"quarter"});case"qqq":return t.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(r,{width:"wide",context:"standalone"})}},M:function(n,e,t){const r=n.getMonth();switch(e){case"M":case"MM":return ws.M(n,e);case"Mo":return t.ordinalNumber(r+1,{unit:"month"});case"MMM":return t.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(r,{width:"wide",context:"formatting"})}},L:function(n,e,t){const r=n.getMonth();switch(e){case"L":return String(r+1);case"LL":return lt(r+1,2);case"Lo":return t.ordinalNumber(r+1,{unit:"month"});case"LLL":return t.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(r,{width:"wide",context:"standalone"})}},w:function(n,e,t,r){const i=$U(n,r);return e==="wo"?t.ordinalNumber(i,{unit:"week"}):lt(i,e.length)},I:function(n,e,t){const r=CU(n);return e==="Io"?t.ordinalNumber(r,{unit:"week"}):lt(r,e.length)},d:function(n,e,t){return e==="do"?t.ordinalNumber(n.getDate(),{unit:"date"}):ws.d(n,e)},D:function(n,e,t){const r=PU(n);return e==="Do"?t.ordinalNumber(r,{unit:"dayOfYear"}):lt(r,e.length)},E:function(n,e,t){const r=n.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(r,{width:"short",context:"formatting"});case"EEEE":default:return t.day(r,{width:"wide",context:"formatting"})}},e:function(n,e,t,r){const i=n.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return lt(s,2);case"eo":return t.ordinalNumber(s,{unit:"day"});case"eee":return t.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(i,{width:"short",context:"formatting"});case"eeee":default:return t.day(i,{width:"wide",context:"formatting"})}},c:function(n,e,t,r){const i=n.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return lt(s,e.length);case"co":return t.ordinalNumber(s,{unit:"day"});case"ccc":return t.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(i,{width:"narrow",context:"standalone"});case"cccccc":return t.day(i,{width:"short",context:"standalone"});case"cccc":default:return t.day(i,{width:"wide",context:"standalone"})}},i:function(n,e,t){const r=n.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return lt(i,e.length);case"io":return t.ordinalNumber(i,{unit:"day"});case"iii":return t.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(r,{width:"short",context:"formatting"});case"iiii":default:return t.day(r,{width:"wide",context:"formatting"})}},a:function(n,e,t){const i=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(n,e,t){const r=n.getHours();let i;switch(r===12?i=$o.noon:r===0?i=$o.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(n,e,t){const r=n.getHours();let i;switch(r>=17?i=$o.evening:r>=12?i=$o.afternoon:r>=4?i=$o.morning:i=$o.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(n,e,t){if(e==="ho"){let r=n.getHours()%12;return r===0&&(r=12),t.ordinalNumber(r,{unit:"hour"})}return ws.h(n,e)},H:function(n,e,t){return e==="Ho"?t.ordinalNumber(n.getHours(),{unit:"hour"}):ws.H(n,e)},K:function(n,e,t){const r=n.getHours()%12;return e==="Ko"?t.ordinalNumber(r,{unit:"hour"}):lt(r,e.length)},k:function(n,e,t){let r=n.getHours();return r===0&&(r=24),e==="ko"?t.ordinalNumber(r,{unit:"hour"}):lt(r,e.length)},m:function(n,e,t){return e==="mo"?t.ordinalNumber(n.getMinutes(),{unit:"minute"}):ws.m(n,e)},s:function(n,e,t){return e==="so"?t.ordinalNumber(n.getSeconds(),{unit:"second"}):ws.s(n,e)},S:function(n,e){return ws.S(n,e)},X:function(n,e,t){const r=n.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return KP(r);case"XXXX":case"XX":return yl(r);case"XXXXX":case"XXX":default:return yl(r,":")}},x:function(n,e,t){const r=n.getTimezoneOffset();switch(e){case"x":return KP(r);case"xxxx":case"xx":return yl(r);case"xxxxx":case"xxx":default:return yl(r,":")}},O:function(n,e,t){const r=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+HP(r,":");case"OOOO":default:return"GMT"+yl(r,":")}},z:function(n,e,t){const r=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+HP(r,":");case"zzzz":default:return"GMT"+yl(r,":")}},t:function(n,e,t){const r=Math.trunc(+n/1e3);return lt(r,e.length)},T:function(n,e,t){return lt(+n,e.length)}};function HP(n,e=""){const t=n>0?"-":"+",r=Math.abs(n),i=Math.trunc(r/60),s=r%60;return s===0?t+String(i):t+String(i)+e+lt(s,2)}function KP(n,e){return n%60===0?(n>0?"-":"+")+lt(Math.abs(n)/60,2):yl(n,e)}function yl(n,e=""){const t=n>0?"-":"+",r=Math.abs(n),i=lt(Math.trunc(r/60),2),s=lt(r%60,2);return t+i+e+s}const JP=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},UE=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},TU=(n,e)=>{const t=n.match(/(P+)(p+)?/)||[],r=t[1],i=t[2];if(!i)return JP(n,e);let s;switch(r){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;case"PPPP":default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",JP(r,e)).replace("{{time}}",UE(i,e))},jU={p:UE,P:TU},EU=/^D+$/,MU=/^Y+$/,AU=["D","DD","YY","YYYY"];function RU(n){return EU.test(n)}function NU(n){return MU.test(n)}function LU(n,e,t){const r=_U(n,e,t);if(console.warn(r),AU.includes(n))throw new RangeError(r)}function _U(n,e,t){const r=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${r} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const DU=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,IU=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,zU=/^'([^]*?)'?$/,ZU=/''/g,XU=/[a-zA-Z]/;function Vt(n,e,t){var f,p,g,x;const r=Aa(),i=r.locale??FE,s=r.firstWeekContainsDate??((p=(f=r.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,l=r.weekStartsOn??((x=(g=r.locale)==null?void 0:g.options)==null?void 0:x.weekStartsOn)??0,o=Qt(n,t==null?void 0:t.in);if(!DY(o))throw new RangeError("Invalid time value");let u=e.match(IU).map(k=>{const b=k[0];if(b==="p"||b==="P"){const w=jU[b];return w(k,i.formatLong)}return k}).join("").match(DU).map(k=>{if(k==="''")return{isToken:!1,value:"'"};const b=k[0];if(b==="'")return{isToken:!1,value:BU(k)};if(GP[b])return{isToken:!0,value:k};if(b.match(XU))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:k}});i.localize.preprocessor&&(u=i.localize.preprocessor(o,u));const h={firstWeekContainsDate:s,weekStartsOn:l,locale:i};return u.map(k=>{if(!k.isToken)return k.value;const b=k.value;(NU(b)||RU(b))&&LU(b,e,String(n));const w=GP[b[0]];return w(o,b,i.localize,h)}).join("")}function BU(n){const e=n.match(zU);return e?e[1].replace(ZU,"'"):n}function WU(n,e,t){const r=Aa(),i=(t==null?void 0:t.locale)??r.locale??FE,s=2520,l=Jf(n,e);if(isNaN(l))throw new RangeError("Invalid time value");const o=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:l}),[u,h]=Gl(t==null?void 0:t.in,...l>0?[e,n]:[n,e]),f=WY(h,u),p=(qd(h)-qd(u))/1e3,g=Math.round((f-p)/60);let x;if(g<2)return t!=null&&t.includeSeconds?f<5?i.formatDistance("lessThanXSeconds",5,o):f<10?i.formatDistance("lessThanXSeconds",10,o):f<20?i.formatDistance("lessThanXSeconds",20,o):f<40?i.formatDistance("halfAMinute",0,o):f<60?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",1,o):g===0?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",g,o);if(g<45)return i.formatDistance("xMinutes",g,o);if(g<90)return i.formatDistance("aboutXHours",1,o);if(g<YP){const k=Math.round(g/60);return i.formatDistance("aboutXHours",k,o)}else{if(g<s)return i.formatDistance("xDays",1,o);if(g<_f){const k=Math.round(g/YP);return i.formatDistance("xDays",k,o)}else if(g<_f*2)return x=Math.round(g/_f),i.formatDistance("aboutXMonths",x,o)}if(x=BY(h,u),x<12){const k=Math.round(g/_f);return i.formatDistance("xMonths",k,o)}else{const k=x%12,b=Math.trunc(x/12);return k<3?i.formatDistance("aboutXYears",b,o):k<9?i.formatDistance("overXYears",b,o):i.formatDistance("almostXYears",b+1,o)}}function xy(n,e){return WU(n,qE(n),e)}function qU(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e);return+ki(r,t)==+ki(i,t)}function VU(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function vp(n,e){return LY(dr(n,n),qE(n))}function K0(n,e){if(n==="day")return{from:Fl(e),to:H0(e)};if(n==="week")return{from:ki(e,{weekStartsOn:1}),to:Oy(e,{weekStartsOn:1})};const t=qY(e),r=VE(e);return{from:ki(t,{weekStartsOn:1}),to:Oy(r,{weekStartsOn:1})}}function QO(n,e,t){return t===0?new Date:n==="day"?kp(e,t):n==="week"?NY(e,t):EY(e,t)}function FU(n,e){if(n==="day")return Vt(e,"EEEE · MMMM d, yyyy");if(n==="week"){const t=ki(e,{weekStartsOn:1}),r=Oy(e,{weekStartsOn:1});return t.getMonth()===r.getMonth()?`${Vt(t,"MMMM d")} – ${Vt(r,"d, yyyy")}`:`${Vt(t,"MMM d")} – ${Vt(r,"MMM d, yyyy")}`}return Vt(e,"MMMM yyyy")}function YU(n){if(n.status==="in_progress")return new Date;if(n.status==="done"){if(n.completedAt)return new Date(n.completedAt);if(n.updatedAt)return new Date(n.updatedAt)}return n.dueAt?new Date(n.dueAt):null}function Ra(n,e=new Date){return!n.dueAt||n.status==="done"||n.status==="in_progress"||n.status==="rejected"?!1:new Date(n.dueAt).getTime()<Fl(e).getTime()}function J0(n){var t;const e=n.metadata;return((t=e==null?void 0:e.recurrence)==null?void 0:t.role)==="occurrence"}function GE(n){const e=new Map;for(const t of n){const r=YU(t);if(!r)continue;const i=Vt(r,"yyyy-MM-dd");e.has(i)||e.set(i,[]),e.get(i).push(t)}return e}function HE(n){const e=new Map;for(const t of n){const r=Vt(new Date(t.dueAt),"yyyy-MM-dd");e.has(r)||e.set(r,[]),e.get(r).push(t)}return e}function Vd(n){return Vt(n,"yyyy-MM-dd")}function KE(n,e){const t=[];let r=Fl(n);const i=H0(e);for(;r<=i;)t.push(r),r=kp(r,1);return t}function Hl(n){const e=new Map;return n==null||n.forEach(t=>e.set(t.id,t)),e}const eC={in_progress:0,open:1,done:2};function bp(n,e){const t=eC[n.status]??3,r=eC[e.status]??3;return t-r}const tC={archived:!0};function UU(){const{data:n}=Vn({includeArchived:!0}),{data:e}=CF({limit:20}),{data:t}=Ul({includeBacklog:!0,includeDone:!1}),r=Pi(),i=new Map;if(t){const f=new Date,p=[...t.scheduled,...t.overdue,...t.backlog];for(const g of p){if(!g.projectId||g.status==="rejected")continue;const x=i.get(g.projectId)??{open:0,overdue:0};x.open+=1,Ra(g,f)&&(x.overdue+=1),i.set(g.projectId,x)}}const[s,l]=my("botnote.workspace.projectGroups.collapsed",tC),o=gy.map(f=>({status:f,projects:(n??[]).filter(p=>p.status===f)})).filter(f=>f.projects.length>0),u=f=>s[f]??tC[f]??!1,h=f=>{const p=u(f);l({...s,[f]:!p})};return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-8 space-y-8",children:[m.jsxs("header",{children:[m.jsx("h1",{className:"text-xl font-semibold text-ink",children:"Workspace"}),m.jsx("p",{className:"text-sm text-muted mt-1",children:"Projects, tasks, notes, and memory — written by you or by your agents."})]}),m.jsxs("section",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-3 text-muted",children:[m.jsx(x6,{size:14}),m.jsxs("h2",{className:"text-xs uppercase tracking-wider font-medium",children:["Projects (",(n==null?void 0:n.length)??0,")"]})]}),n&&n.length===0?m.jsxs("div",{className:"border border-dashed border-line rounded-lg p-6 text-center text-sm text-muted",children:["No projects yet. Press ",m.jsx("kbd",{children:"n"})," to create one."]}):o.map(f=>m.jsx(KU,{status:f.status,projects:f.projects,counts:i,collapsed:u(f.status),onToggle:()=>h(f.status)},f.status))]}),m.jsx(HU,{}),m.jsxs("section",{children:[m.jsxs("div",{className:"flex items-center gap-2 mb-3 text-muted",children:[m.jsx(n6,{size:14}),m.jsx("h2",{className:"text-xs uppercase tracking-wider font-medium",children:"Recent activity"})]}),e&&e.length===0?m.jsx("div",{className:"text-sm text-muted",children:"Nothing yet."}):m.jsx("div",{className:"bg-surface border border-line rounded-md divide-y divide-line/60",children:e==null?void 0:e.map(f=>{const p=n==null?void 0:n.find(g=>g.id===f.projectId);return m.jsxs("button",{type:"button",onClick:()=>r.open(f.id),className:"w-full text-left flex items-center gap-3 px-3 py-2 row-hover",children:[m.jsx(xp,{kind:f.kind}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(f)?"text-muted italic":"text-ink"}`,children:ln(f)}),m.jsxs("div",{className:"text-xxs text-muted mt-0.5",children:[p?p.key:"—"," · ",JE(f.createdAt)," ·"," ",m.jsx("span",{className:"opacity-70",children:f.actorKind})]})]})]},f.id)})})]})]})})}const nC={bug:"text-red-700 bg-red-50 border-red-100",feature:"text-blue-700 bg-blue-50 border-blue-100",friction:"text-amber-700 bg-amber-50 border-amber-100",idea:"text-purple-700 bg-purple-50 border-purple-100"},GU=[{value:"open",label:"Open"},{value:"in_progress",label:"In progress"},{value:"done",label:"Done"},{value:"rejected",label:"Rejected"}];function HU(){const[n,e]=M.useState(null),[t,r]=M.useState("open"),{data:i}=QF({category:n,status:t,limit:50}),s=Js(),l=Pi();return m.jsxs("section",{children:[m.jsxs("div",{className:"flex items-center gap-2 mb-3 text-muted",children:[m.jsx(j6,{size:14}),m.jsx("h2",{className:"text-xs uppercase tracking-wider font-medium",children:"Product feedback"})]}),m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-2",children:[m.jsx("div",{className:"seg",children:GU.map(o=>m.jsx("button",{onClick:()=>r(o.value),"data-active":t===o.value,children:o.label},o.value))}),m.jsx("div",{className:"w-px h-4 bg-line mx-1"}),m.jsx("button",{className:`h-6 px-2.5 text-xxs rounded-full border transition-colors ${n?"bg-surface text-muted border-line hover:text-ink":"bg-accentSoft text-accentText border-accent/30"}`,onClick:()=>e(null),children:"All"}),FF.map(o=>m.jsx("button",{className:`h-6 px-2.5 text-xxs rounded-full border capitalize transition-colors ${n===o?nC[o]:"bg-surface text-muted border-line hover:text-ink"}`,onClick:()=>e(n===o?null:o),children:o},o))]}),i&&i.length===0?m.jsxs("div",{className:"border border-dashed border-line rounded-md p-4 text-center text-xs text-muted",children:["No ",t.replace("_"," ")," feedback",n?` in “${n}”`:"","."]}):m.jsx("div",{className:"bg-surface border border-line rounded-md divide-y divide-line/60",children:i==null?void 0:i.map(o=>{const u=o.metadata.category??"idea",h=o.metadata.tool,f=o.status==="open"||o.status==="in_progress";return m.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 row-hover cursor-pointer group",onClick:()=>l.open(o.id),children:[m.jsx("span",{className:`inline-flex items-center px-1.5 h-5 mt-0.5 text-xxs rounded border capitalize shrink-0 ${nC[u]}`,children:u}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(o)?"text-muted italic":"text-ink"}`,children:ln(o)}),m.jsxs("div",{className:"text-xxs text-muted mt-0.5",children:[h&&m.jsxs("span",{className:"font-mono",children:[h," · "]}),o.actorKind," · ",JE(o.createdAt)]})]}),f&&m.jsxs("div",{className:"flex items-center gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:p=>p.stopPropagation(),children:[m.jsxs("button",{className:"btn btn-ghost !h-6 !px-2 text-xxs gap-1",title:"Mark done",onClick:()=>s.mutate({id:o.id,fields:{status:"done"}}),children:[m.jsx(Ki,{size:11})," Done"]}),m.jsxs("button",{className:"btn btn-ghost !h-6 !px-2 text-xxs gap-1 hover:!text-red-600",title:"Reject",onClick:()=>s.mutate({id:o.id,fields:{status:"rejected"}}),children:[m.jsx(Sc,{size:11})," Reject"]})]})]},o.id)})})]})}function KU({status:n,projects:e,counts:t,collapsed:r,onToggle:i}){return m.jsxs("div",{children:[m.jsxs("button",{type:"button",className:"flex items-center gap-1.5 mb-2 text-muted hover:text-ink",onClick:i,title:`${r?"Expand":"Collapse"} ${Vl[n]}`,children:[r?m.jsx(ja,{size:12}):m.jsx(ey,{size:12}),m.jsxs("span",{className:"text-xxs uppercase tracking-wider font-medium",children:[Vl[n]," (",e.length,")"]})]}),!r&&m.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:e.map(s=>m.jsx(JU,{project:s,counts:t.get(s.id)},s.id))})]})}function JU({project:n,counts:e}){return m.jsxs(ba,{to:`/p/${n.key}`,className:`border border-line rounded-md p-3 bg-surface hover:border-accent/50 transition-colors block ${n.status==="archived"?"opacity-70":""}`,children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[m.jsx(el,{color:n.color,icon:n.icon,size:12}),m.jsx("span",{className:"font-mono text-xs shrink-0",style:{color:n.color},children:n.key})]}),m.jsxs("span",{className:"text-xxs text-faint shrink-0",children:["Updated ",new Date(n.updatedAt).toLocaleDateString()]})]}),m.jsx("div",{className:"text-sm font-medium text-ink mt-1 truncate",children:n.name}),m.jsxs("div",{className:"text-xxs text-muted mt-1 flex items-center gap-2",children:[m.jsxs("span",{children:[(e==null?void 0:e.open)??0," open"]}),e&&e.overdue>0&&m.jsxs("span",{className:"text-danger font-medium",children:[e.overdue," overdue"]}),n.agentsMd&&m.jsx("span",{className:"text-faint",children:"· AGENTS.md"})]})]})}function JE(n){const e=Date.now()-new Date(n).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:e<7*864e5?`${Math.floor(e/864e5)}d ago`:new Date(n).toLocaleDateString()}function eG(){const{key:n,id:e}=Gd();return!n||!e?m.jsx(cb,{to:"/",replace:!0}):m.jsx(cb,{to:`/p/${n}?d=${e}`,replace:!0})}function e1({tag:n,className:e=""}){return m.jsx("span",{className:`chip shrink min-w-0 max-w-[8rem] ${e}`,title:n,children:m.jsx("span",{className:"truncate min-w-0",children:n})})}const tG=["urgent","high","medium","low","none"];function wp({task:n,project:e,showProject:t=!0,compact:r=!1}){const i=Pi(),s=Js(),l=AE(),o=e&&n.sequenceId?`${e.key}-${n.sequenceId}`:null,u=Ra(n),h=J0(n),f=n.status==="done"?n.completedAt??n.updatedAt:n.dueAt,p=n.status==="done"?"Completed":"Due";return m.jsxs("div",{className:`task-row group ${r?"!h-7 text-xs":""}`,onClick:()=>i.open(n.id),children:[m.jsx(yp,{task:n}),o&&!r&&m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums shrink-0",children:o}),m.jsx("span",{className:`flex-1 min-w-0 truncate ${n.status==="done"?"text-muted line-through":n.status==="rejected"?"text-muted":jr(n)?"text-muted italic":"text-ink"}`,children:ln(n)}),!r&&n.tags.slice(0,2).map(g=>m.jsx(e1,{tag:g,className:"hidden md:inline-flex"},g)),t&&e&&r&&m.jsx("span",{className:"font-mono text-xxs text-faint shrink-0",children:e.key}),n.blockedBy&&n.blockedBy.length>0&&n.status!=="done"&&m.jsx("span",{className:"shrink-0 px-1 rounded text-xxs font-medium uppercase tracking-wide bg-warn/15 text-warn",title:`Blocked by ${n.blockedBy.map(g=>`${g.ref} ${g.title}`).join(", ")}`,children:"blocked"}),h&&m.jsx("span",{className:"shrink-0 text-faint",title:"Recurring task",children:m.jsx(Gc,{size:12})}),f&&m.jsx("span",{className:`text-xxs tabular-nums shrink-0 ${u?"text-danger font-medium":"text-muted"}`,title:`${p} ${new Date(f).toLocaleString()}`,children:Vt(new Date(f),"MMM d")}),m.jsx(G0,{trigger:m.jsx("button",{className:"shrink-0 p-0.5 -m-0.5 rounded hover:bg-line/40",onClick:g=>g.stopPropagation(),title:xa[n.priority],children:m.jsx(Oa,{priority:n.priority})}),align:"end",children:g=>m.jsx(m.Fragment,{children:tG.map(x=>m.jsxs("button",{className:"popover-item",onClick:k=>{k.stopPropagation(),s.mutate({id:n.id,fields:{priority:x}}),g()},children:[m.jsx(Oa,{priority:x,size:12}),m.jsx("span",{children:xa[x]}),n.priority===x&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]},x))})}),m.jsx("button",{className:"shrink-0 p-1 -m-1 rounded text-faint opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger transition-opacity",onClick:g=>{g.stopPropagation(),l(n)},title:"Delete",children:m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:m.jsx("path",{d:"M3 4h8M5.5 4V2.5h3V4M4.5 4l.5 8h4l.5-8M6 6.5v3.5M8 6.5v3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})}const rC={urgent:0,high:1,medium:2,low:3,none:4};function nG(){const{data:n,isLoading:e}=Ul({includeBacklog:!0,includeDone:!1}),{data:t}=Vn(),r=M.useMemo(()=>Hl(t),[t]),{open:i}=zt(),s=M.useMemo(()=>rG((n==null?void 0:n.backlog)??[],r),[n,r]),l=s.reduce((o,u)=>o+u.tasks.length,0);return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6 space-y-4",children:[m.jsxs("header",{className:"flex items-baseline gap-3",children:[m.jsx(_d,{size:18,className:"text-accent"}),m.jsx("h1",{className:"text-lg font-semibold",children:"Inbox"}),m.jsx("span",{className:"text-xs text-muted",children:"Tasks without due date"})]}),m.jsx("p",{className:"text-xs text-muted",children:"Tasks land here until they get a due date."}),e?m.jsx("div",{className:"text-sm text-muted",children:"Loading…"}):l===0?m.jsxs("div",{className:"border border-dashed border-line rounded-md p-8 text-center",children:[m.jsx("div",{className:"text-sm text-muted",children:"Inbox empty."}),t&&t.length>0&&m.jsx("button",{className:"mt-2 text-xs text-accent hover:underline",onClick:()=>i({kind:"quick-create"}),children:"+ capture something"})]}):m.jsx("div",{className:"space-y-3",children:s.map(({projectId:o,project:u,tasks:h})=>m.jsxs("section",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsxs("div",{className:"px-3 py-1.5 border-b border-lineSoft bg-sidebar/40 flex items-center gap-1.5 text-xxs",children:[u?m.jsxs(m.Fragment,{children:[m.jsx(el,{color:u.color,icon:u.icon,size:10}),m.jsx("span",{className:"font-mono tabular-nums",style:{color:u.color},children:u.key}),m.jsx("span",{className:"text-muted truncate",children:u.name})]}):m.jsx("span",{className:"text-faint",children:"no project"}),m.jsx("span",{className:"text-faint ml-auto tabular-nums",children:h.length})]}),h.map(f=>m.jsx(wp,{task:f,project:f.projectId?r.get(f.projectId):void 0},f.id))]},o??"_none"))})]})})}function rG(n,e){const t=new Map;for(const r of n){const i=r.projectId??null;t.has(i)||t.set(i,[]),t.get(i).push(r)}return Array.from(t.entries()).map(([r,i])=>({projectId:r,project:r?e.get(r):void 0,tasks:i.slice().sort(iG)})).sort((r,i)=>!r.project&&!i.project?0:r.project?i.project?r.project.key.localeCompare(i.project.key):-1:1)}function iG(n,e){const t=(rC[n.priority]??5)-(rC[e.priority]??5);return t!==0?t:new Date(e.createdAt).getTime()-new Date(n.createdAt).getTime()}function sG(){const[n,e]=M.useState(""),[t,r]=M.useState(null),[i,s]=M.useState(!1),l=Gs(),[o]=Rc(),u=o.get("next")||"/";async function h(f){if(f.preventDefault(),!(!n||i)){s(!0),r(null);try{await We.login(n),l(u,{replace:!0})}catch(p){const g=p instanceof Error?p.message:String(p);g.includes("401")||g.includes("invalid_password")?r("密码不对"):g.includes("rate_limited")||g.includes("429")?r("登录尝试过频,稍候再试"):r("登录失败 — 服务可能离线"),s(!1)}}}return m.jsx("div",{className:"min-h-screen w-full flex items-center justify-center bg-bg px-4",children:m.jsxs("form",{onSubmit:h,className:"w-full max-w-sm bg-surface border border-line rounded-lg shadow-sm p-6 space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"w-8 h-8 rounded-md bg-accent flex items-center justify-center text-white text-sm font-bold",children:"b"}),m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-semibold text-ink leading-tight",children:"botnote"}),m.jsx("div",{className:"text-xxs text-muted",children:"Sign in to continue"})]})]}),m.jsxs("label",{className:"block space-y-1.5",children:[m.jsx("span",{className:"text-xs font-medium text-ink2",children:"Password"}),m.jsx("input",{type:"password",autoFocus:!0,autoComplete:"current-password",value:n,onChange:f=>e(f.target.value),className:"w-full px-3 py-2 text-sm rounded-md border border-line bg-bg focus:outline-none focus:ring-2 focus:ring-accent/40 focus:border-accent",disabled:i})]}),t&&m.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded px-2.5 py-1.5",children:t}),m.jsxs("button",{type:"submit",disabled:!n||i,className:"w-full btn btn-primary justify-center gap-2 py-2",children:[i?m.jsx(uj,{size:14,className:"animate-spin"}):m.jsx(T6,{size:14}),m.jsx("span",{children:i?"Signing in…":"Sign in"})]}),m.jsx("p",{className:"text-xxs text-muted text-center pt-1",children:"Session cookie expires in 30 days. CLI / MCP unaffected."})]})})}const $O=[{status:"open",label:"Todo",intent:"text-statusOpen"},{status:"in_progress",label:"In Progress",intent:"text-statusInProgress"},{status:"done",label:"Done",intent:"text-statusDone"},{status:"rejected",label:"Cancelled",intent:"text-statusRejected"}];function lG({tasks:n,project:e}){var l;const t=Js(),{open:r}=zt(),i={};for(const o of $O)i[o.status]=[];for(const o of n){const u=((l=$O.find(h=>h.status===o.status))==null?void 0:l.status)??"open";i[u].push(o)}i.done.sort((o,u)=>+new Date(u.completedAt??u.updatedAt)-+new Date(o.completedAt??o.updatedAt));function s(o,u){t.mutate({id:u,fields:{status:o}})}return m.jsx("div",{className:"h-full overflow-x-auto overflow-y-hidden",children:m.jsx("div",{className:"h-full flex gap-3 p-3 min-w-max",children:$O.map(o=>m.jsx(oG,{label:o.label,intent:o.intent,tasks:i[o.status]??[],project:e,onDropTask:u=>s(o.status,u),onAdd:()=>r({kind:"quick-create",projectId:e.id}),initialLimit:o.status==="done"?8:void 0},o.status))})})}function oG({label:n,intent:e,tasks:t,project:r,onDropTask:i,onAdd:s,initialLimit:l}){const[o,u]=M.useState(!1),[h,f]=M.useState(!1),p=l!=null&&!h?t.slice(0,l):t,g=t.length-p.length;return m.jsxs("div",{className:`w-72 shrink-0 flex flex-col rounded-md border ${o?"border-accent bg-accentSoft/30":"border-line bg-sidebar/40"} transition-colors`,onDragOver:x=>{x.preventDefault(),o||u(!0)},onDragLeave:()=>u(!1),onDrop:x=>{x.preventDefault(),u(!1);const k=x.dataTransfer.getData("text/task-id");k&&i(k)},children:[m.jsxs("div",{className:"px-3 h-9 flex items-center justify-between border-b border-line",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:`text-xs font-semibold ${e}`,children:n}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:t.length})]}),m.jsx("button",{className:"text-faint hover:text-accent text-xs",onClick:s,title:"Add task",children:"+"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin p-2 space-y-1.5",children:t.length===0?m.jsx("div",{className:"text-xxs text-faint text-center py-4",children:"No tasks"}):m.jsxs(m.Fragment,{children:[p.map(x=>m.jsx(aG,{task:x,project:r},x.id)),g>0&&m.jsxs("button",{className:"w-full text-xxs text-muted hover:text-ink py-1.5",onClick:()=>f(!0),children:["Show all ",t.length]}),h&&l!=null&&t.length>l&&m.jsxs("button",{className:"w-full text-xxs text-muted hover:text-ink py-1.5",onClick:()=>f(!1),children:["Show latest ",l]})]})})]})}function aG({task:n,project:e}){const t=Pi(),r=Ra(n),i=n.sequenceId?`${e.key}-${n.sequenceId}`:null,s=n.status==="done"?n.completedAt??n.updatedAt:n.dueAt,l=n.status==="done"?"Completed":"Due";return m.jsxs("div",{draggable:!0,onDragStart:o=>{o.dataTransfer.setData("text/task-id",n.id),o.dataTransfer.effectAllowed="move"},onClick:()=>t.open(n.id),className:"group bg-surface border border-line rounded p-2 cursor-grab active:cursor-grabbing hover:border-accent transition-colors",children:[m.jsxs("div",{className:"flex items-start gap-1.5",children:[m.jsx(yp,{task:n,size:13,className:"mt-0.5"}),m.jsx("span",{className:`flex-1 min-w-0 text-sm leading-snug ${n.status==="done"||n.status==="rejected"?"text-muted":jr(n)?"italic text-muted":"text-ink"}`,children:ln(n)}),J0(n)&&m.jsx(Gc,{size:11,className:"text-faint mt-0.5"}),m.jsx(Oa,{priority:n.priority,size:11})]}),m.jsxs("div",{className:"mt-1.5 flex items-center gap-2 overflow-hidden text-xxs text-muted",children:[i&&m.jsx("span",{className:"font-mono tabular-nums shrink-0 whitespace-nowrap",children:i}),s&&m.jsx("span",{className:`tabular-nums shrink-0 whitespace-nowrap ${r?"text-danger font-medium":""}`,title:`${l} ${new Date(s).toLocaleString()}`,children:Vt(new Date(s),"MMM d")}),n.tags.slice(0,2).map(o=>m.jsx(e1,{tag:o,className:"!h-4 !text-[10px]"},o))]})]})}function uG({project:n}){const[e,t]=Rc(),r=Js(),{open:i}=zt(),{data:s}=U0(n.id,["note"]),[l,o]=M.useState("all");function u(f){e.set("d",f),t(e,{replace:!0})}const h=(s??[]).filter(f=>l==="pinned"?f.pinned:!0);return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("div",{className:"px-3 h-9 flex items-center justify-between border-b border-line bg-surface",children:[m.jsx("div",{className:"flex items-center gap-2",children:m.jsxs("div",{className:"seg",children:[m.jsxs("button",{"data-active":l==="all",onClick:()=>o("all"),children:["All ",m.jsx("span",{className:"text-faint ml-1",children:(s==null?void 0:s.length)??0})]}),m.jsxs("button",{"data-active":l==="pinned",onClick:()=>o("pinned"),children:["Pinned ",m.jsx("span",{className:"text-faint ml-1",children:(s==null?void 0:s.filter(f=>f.pinned).length)??0})]})]})}),m.jsx("button",{className:"btn btn-primary",onClick:()=>i({kind:"quick-create",projectId:n.id}),children:"+ Note"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin bg-surface",children:h.length===0?m.jsxs("div",{className:"p-8 text-center text-xs text-muted",children:[l==="pinned"?"No pinned notes yet.":"No notes yet.",m.jsx("div",{className:"text-faint mt-1",children:l==="pinned"?"Pin notes to surface them in opening brief for agents.":"Press c to create one."})]}):h.map(f=>m.jsx("div",{className:"px-4 py-2.5 border-b border-lineSoft row-hover cursor-pointer group",onClick:()=>u(f.id),children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("button",{className:`shrink-0 mt-0.5 p-0.5 -m-0.5 rounded hover:bg-line/40 ${f.pinned?"text-accent":"text-faint hover:text-ink"}`,onClick:p=>{p.stopPropagation(),r.mutate({id:f.id,fields:{pinned:!f.pinned}})},title:f.pinned?"Unpin":"Pin to opening brief",children:f.pinned?m.jsx(j0,{size:12,fill:"currentColor"}):m.jsx(A6,{size:12,className:"opacity-0 group-hover:opacity-100 transition-opacity"})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(f)?"text-muted italic":"text-ink"}`,children:ln(f)}),!jr(f)&&f.body&&m.jsx("div",{className:"text-xs text-muted truncate mt-0.5",children:f.body.replace(/\n/g," ").slice(0,200)}),m.jsxs("div",{className:"text-xxs text-faint mt-1 flex items-center gap-2",children:[m.jsx("span",{children:xy(new Date(f.updatedAt),{addSuffix:!0})}),m.jsx("span",{children:"·"}),m.jsx("span",{children:f.actorKind}),f.tags.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"·"}),f.tags.slice(0,3).map(p=>m.jsx(e1,{tag:p,className:"!h-4 !text-[10px]"},p))]})]})]})]})},f.id))})]})}function cG(){const{key:n}=Gd(),[e,t]=Rc(),r=e.get("tab")||"tasks",{data:i}=SE(n),{data:s}=U0(i==null?void 0:i.id,["task"],{poll:!0}),{open:l}=zt(),o=M.useMemo(()=>{const h=s??[];return{todo:h.filter(f=>f.status==="open").length,in_progress:h.filter(f=>f.status==="in_progress").length,done:h.filter(f=>f.status==="done").length,tasks:h.length}},[s]);if(!i)return m.jsx("div",{className:"p-6 text-sm text-muted",children:"Loading project…"});const u=h=>{h==="tasks"?e.delete("tab"):e.set("tab",h),t(e,{replace:!0})};return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("div",{className:"h-11 px-4 border-b border-line bg-surface flex items-center justify-between shrink-0",children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[m.jsx(el,{color:i.color,icon:i.icon,size:14}),m.jsx("span",{className:"font-mono text-xs tabular-nums",style:{color:i.color},children:i.key}),m.jsx("span",{className:"text-sm font-semibold text-ink truncate",children:i.name}),m.jsx("span",{className:"chip",children:Vl[i.status]}),m.jsx("button",{className:"ml-1 p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",onClick:()=>l({kind:"edit-project",projectId:i.id}),title:"Project settings",children:m.jsx(I6,{size:11})})]}),m.jsx("div",{className:"flex items-center gap-1",children:m.jsxs("div",{className:"seg",children:[m.jsxs("button",{"data-active":r==="tasks",onClick:()=>u("tasks"),children:[m.jsx(Z6,{size:11,className:"inline mr-1"}),"Tasks ",m.jsx("span",{className:"text-faint ml-1",children:o.tasks})]}),m.jsxs("button",{"data-active":r==="notes",onClick:()=>u("notes"),children:[m.jsx(m6,{size:11,className:"inline mr-1"}),"Notes"]}),m.jsxs(ba,{to:`/p/${i.key}/agents-md`,className:"px-2 h-7 text-xs hover:text-ink hover:bg-sidebar transition-colors text-muted flex items-center",children:[m.jsx(dj,{size:11,className:"inline mr-1"}),"AGENTS.md"]})]})})]}),m.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[r==="tasks"&&m.jsx(lG,{tasks:s??[],project:i}),r==="notes"&&m.jsx(uG,{project:i})]})]})}const TO=90;function hG({body:n,query:e}){const t=n.replace(/\s+/g," ").trim(),r=e.split(/\s+/).map(p=>p.trim()).filter(p=>p.length>0),i=t.toLowerCase();let s=-1,l=0;for(const p of r){const g=i.indexOf(p.toLowerCase());g>=0&&(s===-1||g<s)&&(s=g,l=p.length)}let o=0,u=Math.min(t.length,TO*2);s>=0&&(o=Math.max(0,s-TO),u=Math.min(t.length,s+l+TO));const h=t.slice(o,u),f=[];if(r.length===0)f.push(h);else{const p=new RegExp(`(${r.map(g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`,"gi");h.split(p).forEach((g,x)=>{x%2===1?f.push(m.jsx("mark",{className:"bg-amber-100 text-inherit rounded-[2px] px-px",children:g},x)):g&&f.push(g)})}return m.jsxs("div",{className:"text-xs text-muted mt-1 break-words",children:[o>0&&"… ",f,u<t.length&&" …"]})}function fG(){const[n,e]=Rc(),t=n.get("q")??"",[r,i]=M.useState(t);M.useEffect(()=>i(t),[t]);const[s,l]=M.useState(null),{data:o}=PE(t?{query:t,kind:s,limit:50}:null),{data:u}=Vn(),h=M.useMemo(()=>Hl(u),[u]),f=Pi();function p(){const g=r.trim();e(g?{q:g}:{})}return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[m.jsxs("div",{className:"relative",children:[m.jsx(Dd,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),m.jsx("input",{type:"search",value:r,onChange:g=>i(g.target.value),onKeyDown:g=>{g.key==="Enter"&&p()},placeholder:"Search tasks, notes, comments…",autoFocus:!0,className:"w-full h-9 pl-9 pr-3 text-sm bg-surface border border-line rounded focus:outline-none focus:ring-2 focus:ring-accent/30 focus:border-accent"})]}),m.jsxs("div",{className:"mt-3 flex items-center gap-1.5",children:[m.jsx(iC,{label:"All",active:s===null,onClick:()=>l(null)}),VF.map(g=>m.jsx(iC,{label:g,active:s===g,onClick:()=>l(s===g?null:g)},g)),t&&m.jsxs("span",{className:"ml-auto text-xxs text-muted tabular-nums",children:[(o==null?void 0:o.hits.length)??0," results"]})]}),t?o&&o.hits.length===0?m.jsxs("div",{className:"mt-16 text-center text-muted",children:[m.jsxs("div",{className:"text-sm",children:["No results for “",t,"”"]}),m.jsxs("div",{className:"text-xs text-faint mt-1",children:["Try fewer or different keywords",s?", or clear the kind filter":"","."]})]}):m.jsx("div",{className:"mt-3 bg-surface border border-line rounded divide-y divide-line/60",children:o==null?void 0:o.hits.map(g=>{const x=g.entity.projectId?h.get(g.entity.projectId):void 0,k=x&&g.entity.sequenceId!=null?`${x.key}-${g.entity.sequenceId}`:null;return m.jsxs("button",{type:"button",onClick:()=>f.open(g.entity.id),className:"w-full text-left p-3 flex items-start gap-3 row-hover",children:[m.jsx(xp,{kind:g.entity.kind,compact:!0}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[k&&m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums shrink-0",children:k}),m.jsx("span",{className:`text-sm truncate ${jr(g.entity)?"italic text-muted":"text-ink"}`,children:ln(g.entity)})]}),m.jsx(hG,{body:g.entity.body,query:t}),m.jsxs("div",{className:"text-xxs text-faint mt-1 flex items-center gap-2",children:[x&&m.jsx("span",{children:x.name}),m.jsx("span",{children:Vt(new Date(g.entity.updatedAt),"MMM d, yyyy")})]})]})]},g.entity.id)})}):m.jsxs("div",{className:"mt-16 text-center text-muted",children:[m.jsx(Dd,{size:24,className:"mx-auto mb-3 text-faint"}),m.jsx("div",{className:"text-sm",children:"Search your workspace"}),m.jsx("div",{className:"text-xs text-faint mt-1",children:"Tasks, notes, comments and feedback — by keyword or meaning."})]})]})})}function iC({label:n,active:e,onClick:t}){return m.jsx("button",{type:"button",onClick:t,className:`h-6 px-2.5 text-xxs rounded-full border capitalize transition-colors ${e?"bg-accentSoft text-accentText border-accent/30":"bg-surface text-muted border-line hover:text-ink"}`,children:n})}const Sr=typeof window<"u"?window.location.origin:"http://127.0.0.1:4280",jO=1e5,dG=[{id:"account",label:"Account",icon:F6},{id:"tokens",label:"API tokens",icon:S6},{id:"cli",label:"CLI",icon:mj},{id:"plugin",label:"Plugin",icon:fj},{id:"embedding",label:"Embeddings",icon:l6},{id:"mcp",label:"MCP",icon:R6},{id:"about",label:"About",icon:w6}];function pG(){const[n,e]=M.useState("account");return m.jsxs("div",{className:"h-full flex bg-bg overflow-hidden",children:[m.jsxs("nav",{className:"w-52 shrink-0 border-r border-line bg-sidebar/60 overflow-y-auto scrollbar-thin",children:[m.jsxs("div",{className:"px-4 pt-4 pb-2 flex items-center gap-2",children:[m.jsx(aj,{size:14,className:"text-accent"}),m.jsx("span",{className:"text-sm font-semibold",children:"Settings"})]}),m.jsx("ul",{className:"px-2 pb-4 space-y-0.5",children:dG.map(t=>m.jsx("li",{children:m.jsxs("button",{onClick:()=>e(t.id),className:`w-full text-left px-2.5 py-1.5 text-sm rounded-md flex items-center gap-2.5 transition-colors ${n===t.id?"bg-accentSoft/70 text-accentText font-medium":"text-muted hover:bg-sidebarHover hover:text-ink"}`,children:[m.jsx(t.icon,{size:13,className:n===t.id?"text-accent":"text-faint"}),t.label]})},t.id))})]}),m.jsx("main",{className:"flex-1 min-w-0 overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"mx-auto max-w-3xl px-8 py-8 space-y-6",children:[n==="account"&&m.jsx(gG,{}),n==="tokens"&&m.jsx(QG,{}),n==="cli"&&m.jsx(xG,{}),n==="plugin"&&m.jsx(kG,{}),n==="embedding"&&m.jsx(vG,{}),n==="mcp"&&m.jsx(wG,{}),n==="about"&&m.jsx(SG,{})]})})]})}function Kl({title:n,blurb:e}){return m.jsxs("header",{className:"pb-4 border-b border-lineSoft space-y-1.5",children:[m.jsx("h1",{className:"text-lg font-semibold text-ink",children:n}),e&&m.jsx("p",{className:"text-xs text-muted leading-relaxed max-w-xl",children:e})]})}function mG({title:n,blurb:e}){return m.jsxs("div",{className:"pt-2",children:[m.jsx("h2",{className:"text-sm font-semibold text-ink",children:n}),e&&m.jsx("p",{className:"text-xs text-muted leading-relaxed mt-0.5",children:e})]})}function gG(){const n=Gs(),[e,t]=M.useState(!1);async function r(){if(!e){t(!0);try{await We.logout()}catch{}n("/login",{replace:!0})}}return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"Account",blurb:"Browser session uses a master-password login. Agents (CLI / MCP) authenticate with bearer tokens, generated under API tokens."}),m.jsx(OG,{}),m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-3 flex items-center justify-between",children:[m.jsx("div",{className:"text-xs text-muted",children:"Sign out of this browser. Other devices and any active bearer tokens are unaffected."}),m.jsxs("button",{onClick:r,disabled:e,className:"btn !text-red-500 !border-red-500/30 hover:!bg-red-500/10 gap-1.5",children:[m.jsx(cj,{size:12})," Log out"]})]})]})}function OG(){const{data:n}=RF(),e=NF(),[t,r]=M.useState(""),[i,s]=M.useState(null),l=(()=>{var u;try{return((u=Intl.supportedValuesOf)==null?void 0:u.call(Intl,"timeZone"))??[]}catch{return[]}})();M.useEffect(()=>{n&&r(n.timezone)},[n]);async function o(u){u.preventDefault(),s(null),await e.mutateAsync({timezone:t}),s("Workspace timezone saved.")}return m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-4 space-y-3",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-semibold text-ink",children:"Workspace timezone"}),m.jsx("p",{className:"text-xs text-muted mt-0.5 leading-relaxed",children:"Used to compute all-day recurring task occurrence dates on the correct local calendar day."})]}),m.jsxs("form",{onSubmit:o,className:"flex items-end gap-3",children:[m.jsxs("label",{className:"flex-1 space-y-1",children:[m.jsx("span",{className:"block text-xxs uppercase tracking-wider text-muted",children:"Timezone"}),l.length>0?m.jsx("select",{className:"input",value:t,onChange:u=>{r(u.target.value),s(null)},children:l.map(u=>m.jsx("option",{value:u,children:u},u))}):m.jsx("input",{className:"input font-mono",value:t,onChange:u=>{r(u.target.value),s(null)},placeholder:"UTC"})]}),m.jsxs("button",{type:"submit",className:"btn btn-primary",disabled:e.isPending||!t,children:[m.jsx(Ki,{size:11})," ",e.isPending?"Saving...":"Save"]})]}),i&&m.jsx("div",{className:"text-xs text-accentText bg-accentSoft/50 border border-accent/20 rounded-md px-3 py-2",children:i}),e.error&&m.jsx("div",{className:"text-xs text-danger",children:e.error instanceof Error?e.error.message:String(e.error)})]})}function xG(){const n=[{note:"Global install on any machine with node + npm:",code:"npm i -g botnote"},{note:m.jsxs(m.Fragment,{children:["One-time login. The default URL is the daemon on the same machine,"," ",m.jsx("code",{className:"text-ink",children:"http://127.0.0.1:4280"})," (no token needed, loopback is trusted). From another machine enter ",m.jsx("code",{className:"text-ink",children:Sr})," and paste a bearer token from Settings → API tokens."]}),code:"botnote login"}],e=[{code:"botnote today",desc:"today + overdue"},{code:"botnote tasks --status open",desc:"list open tasks"},{code:'botnote task "Ship the CLI" --project BOT --priority high --due 2026-06-10',desc:"create a task"},{code:'botnote note "Random capture" --project BOT --pin',desc:"capture a pinned note"},{code:'botnote search "deployment"',desc:"hybrid search"},{code:"botnote projects",desc:"list project keys"}],t=[{note:m.jsxs(m.Fragment,{children:["Per-shell override — skips"," ",m.jsx("code",{className:"text-ink",children:"~/.config/botnote/config.json"}),":"]}),code:"BOTNOTE_URL=http://127.0.0.1:4280 botnote today"},{note:m.jsxs(m.Fragment,{children:["Config file, preferred for the daemon host —"," ",m.jsx("code",{className:"text-ink",children:"~/.config/botnote/config.json"}),":"]}),code:'{ "baseUrl": "http://127.0.0.1:4280" }'}];return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"CLI",blurb:"The botnote npm package ships a binary that talks to this daemon over HTTP. Same tool for quick capture, today review, and ad-hoc search from any terminal."}),m.jsx($c,{title:"Install + login",steps:n}),m.jsx(tM,{title:"Daily commands",items:e}),m.jsx($c,{title:"Override the URL",steps:t})]})}const yG=`{
491
+ `;function TY(){const{key:n}=Gd(),{data:e}=SE(n),t=XF(),[r,i]=M.useState(""),[s,l]=M.useState("edit");if(M.useEffect(()=>{e&&i(e.agentsMd)},[e==null?void 0:e.id]),!e)return m.jsx("div",{className:"p-6 text-sm text-muted",children:"Loading…"});const o=r!==e.agentsMd;return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("div",{className:"px-6 pt-4 pb-2 flex items-center justify-between border-b border-line bg-surface",children:[m.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[m.jsxs(ba,{to:`/p/${e.key}`,className:"text-muted hover:text-ink flex items-center gap-1.5",children:[m.jsx(oj,{size:14}),m.jsx(el,{color:e.color,icon:e.icon,size:12}),m.jsx("span",{className:"font-mono text-xs",style:{color:e.color},children:e.key})]}),m.jsx("span",{className:"text-muted",children:"/"}),m.jsxs("div",{className:"flex items-center gap-1.5 text-ink",children:[m.jsx(dj,{size:14}),m.jsx("span",{className:"font-semibold",children:"AGENTS.md"})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("div",{className:"flex border border-line rounded overflow-hidden",children:[m.jsx("button",{className:`px-2 py-1 text-xs flex items-center gap-1 ${s==="edit"?"bg-accent text-white":"bg-surface text-muted hover:bg-sidebar"}`,onClick:()=>l("edit"),children:"Edit"}),m.jsxs("button",{className:`px-2 py-1 text-xs flex items-center gap-1 border-l border-line ${s==="preview"?"bg-accent text-white":"bg-surface text-muted hover:bg-sidebar"}`,onClick:()=>l("preview"),children:[m.jsx(p6,{size:11})," Preview"]})]}),m.jsxs("button",{className:"btn btn-primary",disabled:!o||t.isPending,onClick:async()=>{await t.mutateAsync({id:e.id,agentsMd:r})},children:[m.jsx(D6,{size:12})," ",t.isPending?"Saving…":o?"Save":"Saved"]})]})]}),m.jsx("div",{className:"px-6 pt-2 text-xxs text-muted",children:"This text is auto-injected into every agent's opening brief for this project. Keep it short (< 200 lines) and imperative."}),m.jsx("div",{className:"flex-1 min-h-0 px-6 pb-6 pt-3",children:s==="edit"?m.jsx("div",{className:"h-full border border-line rounded bg-surface overflow-hidden",children:m.jsx(T0,{value:r,onChange:u=>i(u),extensions:[fT()],placeholder:$Y,height:"100%",minHeight:"100%",theme:"light",basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLine:!0}})}):m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin border border-line rounded bg-surface p-6",children:m.jsx("div",{className:"prose-sm max-w-2xl text-sm leading-relaxed text-ink space-y-2 [&_h1]:text-lg [&_h1]:font-semibold [&_h2]:text-base [&_h2]:font-semibold [&_ul]:list-disc [&_ul]:pl-5 [&_code]:bg-sidebar [&_code]:px-1 [&_code]:rounded",children:r?m.jsx(Kj,{remarkPlugins:[bE],children:r}):m.jsx("div",{className:"text-sm text-faint italic",children:"(empty)"})})})})]})}const BE=6048e5,jY=864e5,_f=43200,YP=1440,UP=Symbol.for("constructDateFrom");function dr(n,e){return typeof n=="function"?n(e):n&&typeof n=="object"&&UP in n?n[UP](e):n instanceof Date?new n.constructor(e):new Date(e)}function Qt(n,e){return dr(e||n,n)}function kp(n,e,t){const r=Qt(n,t==null?void 0:t.in);return isNaN(e)?dr(n,NaN):(e&&r.setDate(r.getDate()+e),r)}function EY(n,e,t){const r=Qt(n,t==null?void 0:t.in);if(isNaN(e))return dr(n,NaN);if(!e)return r;const i=r.getDate(),s=dr(n,r.getTime());s.setMonth(r.getMonth()+e+1,0);const l=s.getDate();return i>=l?s:(r.setFullYear(s.getFullYear(),s.getMonth(),i),r)}let MY={};function Aa(){return MY}function ki(n,e){var o,u,h,f;const t=Aa(),r=(e==null?void 0:e.weekStartsOn)??((u=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:u.weekStartsOn)??t.weekStartsOn??((f=(h=t.locale)==null?void 0:h.options)==null?void 0:f.weekStartsOn)??0,i=Qt(n,e==null?void 0:e.in),s=i.getDay(),l=(s<r?7:0)+s-r;return i.setDate(i.getDate()-l),i.setHours(0,0,0,0),i}function Wd(n,e){return ki(n,{...e,weekStartsOn:1})}function WE(n,e){const t=Qt(n,e==null?void 0:e.in),r=t.getFullYear(),i=dr(t,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=Wd(i),l=dr(t,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const o=Wd(l);return t.getTime()>=s.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function qd(n){const e=Qt(n),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+n-+t}function Gl(n,...e){const t=dr.bind(null,n||e.find(r=>typeof r=="object"));return e.map(t)}function Fl(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setHours(0,0,0,0),t}function AY(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e),s=Fl(r),l=Fl(i),o=+s-qd(s),u=+l-qd(l);return Math.round((o-u)/jY)}function RY(n,e){const t=WE(n,e),r=dr(n,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),Wd(r)}function NY(n,e,t){return kp(n,e*7,t)}function Jf(n,e){const t=+Qt(n)-+Qt(e);return t<0?-1:t>0?1:t}function qE(n){return dr(n,Date.now())}function LY(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e);return+Fl(r)==+Fl(i)}function _Y(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function DY(n){return!(!_Y(n)&&typeof n!="number"||isNaN(+Qt(n)))}function IY(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e),s=r.getFullYear()-i.getFullYear(),l=r.getMonth()-i.getMonth();return s*12+l}function zY(n){return e=>{const r=(n?Math[n]:Math.trunc)(e);return r===0?0:r}}function ZY(n,e){return+Qt(n)-+Qt(e)}function H0(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setHours(23,59,59,999),t}function VE(n,e){const t=Qt(n,e==null?void 0:e.in),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function XY(n,e){const t=Qt(n,e==null?void 0:e.in);return+H0(t,e)==+VE(t,e)}function BY(n,e,t){const[r,i,s]=Gl(t==null?void 0:t.in,n,n,e),l=Jf(i,s),o=Math.abs(IY(i,s));if(o<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-l*o);let u=Jf(i,s)===-l;XY(r)&&o===1&&Jf(r,s)===1&&(u=!1);const h=l*(o-+u);return h===0?0:h}function WY(n,e,t){const r=ZY(n,e)/1e3;return zY(t==null?void 0:t.roundingMethod)(r)}function qY(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setDate(1),t.setHours(0,0,0,0),t}function VY(n,e){const t=Qt(n,e==null?void 0:e.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}function Oy(n,e){var o,u,h,f;const t=Aa(),r=(e==null?void 0:e.weekStartsOn)??((u=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:u.weekStartsOn)??t.weekStartsOn??((f=(h=t.locale)==null?void 0:h.options)==null?void 0:f.weekStartsOn)??0,i=Qt(n,e==null?void 0:e.in),s=i.getDay(),l=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+l),i.setHours(23,59,59,999),i}const FY={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},YY=(n,e,t)=>{let r;const i=FY[n];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+r:r+" ago":r};function CO(n){return(e={})=>{const t=e.width?String(e.width):n.defaultWidth;return n.formats[t]||n.formats[n.defaultWidth]}}const UY={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},GY={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},HY={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},KY={date:CO({formats:UY,defaultWidth:"full"}),time:CO({formats:GY,defaultWidth:"full"}),dateTime:CO({formats:HY,defaultWidth:"full"})},JY={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},eU=(n,e,t,r)=>JY[n];function ju(n){return(e,t)=>{const r=t!=null&&t.context?String(t.context):"standalone";let i;if(r==="formatting"&&n.formattingValues){const l=n.defaultFormattingWidth||n.defaultWidth,o=t!=null&&t.width?String(t.width):l;i=n.formattingValues[o]||n.formattingValues[l]}else{const l=n.defaultWidth,o=t!=null&&t.width?String(t.width):n.defaultWidth;i=n.values[o]||n.values[l]}const s=n.argumentCallback?n.argumentCallback(e):e;return i[s]}}const tU={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},nU={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},rU={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},iU={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},sU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},lU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},oU=(n,e)=>{const t=Number(n),r=t%100;if(r>20||r<10)switch(r%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},aU={ordinalNumber:oU,era:ju({values:tU,defaultWidth:"wide"}),quarter:ju({values:nU,defaultWidth:"wide",argumentCallback:n=>n-1}),month:ju({values:rU,defaultWidth:"wide"}),day:ju({values:iU,defaultWidth:"wide"}),dayPeriod:ju({values:sU,defaultWidth:"wide",formattingValues:lU,defaultFormattingWidth:"wide"})};function Eu(n){return(e,t={})=>{const r=t.width,i=r&&n.matchPatterns[r]||n.matchPatterns[n.defaultMatchWidth],s=e.match(i);if(!s)return null;const l=s[0],o=r&&n.parsePatterns[r]||n.parsePatterns[n.defaultParseWidth],u=Array.isArray(o)?cU(o,p=>p.test(l)):uU(o,p=>p.test(l));let h;h=n.valueCallback?n.valueCallback(u):u,h=t.valueCallback?t.valueCallback(h):h;const f=e.slice(l.length);return{value:h,rest:f}}}function uU(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&e(n[t]))return t}function cU(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return t}function hU(n){return(e,t={})=>{const r=e.match(n.matchPattern);if(!r)return null;const i=r[0],s=e.match(n.parsePattern);if(!s)return null;let l=n.valueCallback?n.valueCallback(s[0]):s[0];l=t.valueCallback?t.valueCallback(l):l;const o=e.slice(i.length);return{value:l,rest:o}}}const fU=/^(\d+)(th|st|nd|rd)?/i,dU=/\d+/i,pU={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},mU={any:[/^b/i,/^(a|c)/i]},gU={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},OU={any:[/1/i,/2/i,/3/i,/4/i]},xU={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},yU={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},kU={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},vU={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},bU={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},wU={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},SU={ordinalNumber:hU({matchPattern:fU,parsePattern:dU,valueCallback:n=>parseInt(n,10)}),era:Eu({matchPatterns:pU,defaultMatchWidth:"wide",parsePatterns:mU,defaultParseWidth:"any"}),quarter:Eu({matchPatterns:gU,defaultMatchWidth:"wide",parsePatterns:OU,defaultParseWidth:"any",valueCallback:n=>n+1}),month:Eu({matchPatterns:xU,defaultMatchWidth:"wide",parsePatterns:yU,defaultParseWidth:"any"}),day:Eu({matchPatterns:kU,defaultMatchWidth:"wide",parsePatterns:vU,defaultParseWidth:"any"}),dayPeriod:Eu({matchPatterns:bU,defaultMatchWidth:"any",parsePatterns:wU,defaultParseWidth:"any"})},FE={code:"en-US",formatDistance:YY,formatLong:KY,formatRelative:eU,localize:aU,match:SU,options:{weekStartsOn:0,firstWeekContainsDate:1}};function PU(n,e){const t=Qt(n,e==null?void 0:e.in);return AY(t,VY(t))+1}function CU(n,e){const t=Qt(n,e==null?void 0:e.in),r=+Wd(t)-+RY(t);return Math.round(r/BE)+1}function YE(n,e){var f,p,g,x;const t=Qt(n,e==null?void 0:e.in),r=t.getFullYear(),i=Aa(),s=(e==null?void 0:e.firstWeekContainsDate)??((p=(f=e==null?void 0:e.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??i.firstWeekContainsDate??((x=(g=i.locale)==null?void 0:g.options)==null?void 0:x.firstWeekContainsDate)??1,l=dr((e==null?void 0:e.in)||n,0);l.setFullYear(r+1,0,s),l.setHours(0,0,0,0);const o=ki(l,e),u=dr((e==null?void 0:e.in)||n,0);u.setFullYear(r,0,s),u.setHours(0,0,0,0);const h=ki(u,e);return+t>=+o?r+1:+t>=+h?r:r-1}function QU(n,e){var o,u,h,f;const t=Aa(),r=(e==null?void 0:e.firstWeekContainsDate)??((u=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:u.firstWeekContainsDate)??t.firstWeekContainsDate??((f=(h=t.locale)==null?void 0:h.options)==null?void 0:f.firstWeekContainsDate)??1,i=YE(n,e),s=dr((e==null?void 0:e.in)||n,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),ki(s,e)}function $U(n,e){const t=Qt(n,e==null?void 0:e.in),r=+ki(t,e)-+QU(t,e);return Math.round(r/BE)+1}function lt(n,e){const t=n<0?"-":"",r=Math.abs(n).toString().padStart(e,"0");return t+r}const ws={y(n,e){const t=n.getFullYear(),r=t>0?t:1-t;return lt(e==="yy"?r%100:r,e.length)},M(n,e){const t=n.getMonth();return e==="M"?String(t+1):lt(t+1,2)},d(n,e){return lt(n.getDate(),e.length)},a(n,e){const t=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(n,e){return lt(n.getHours()%12||12,e.length)},H(n,e){return lt(n.getHours(),e.length)},m(n,e){return lt(n.getMinutes(),e.length)},s(n,e){return lt(n.getSeconds(),e.length)},S(n,e){const t=e.length,r=n.getMilliseconds(),i=Math.trunc(r*Math.pow(10,t-3));return lt(i,e.length)}},$o={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},GP={G:function(n,e,t){const r=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(r,{width:"abbreviated"});case"GGGGG":return t.era(r,{width:"narrow"});case"GGGG":default:return t.era(r,{width:"wide"})}},y:function(n,e,t){if(e==="yo"){const r=n.getFullYear(),i=r>0?r:1-r;return t.ordinalNumber(i,{unit:"year"})}return ws.y(n,e)},Y:function(n,e,t,r){const i=YE(n,r),s=i>0?i:1-i;if(e==="YY"){const l=s%100;return lt(l,2)}return e==="Yo"?t.ordinalNumber(s,{unit:"year"}):lt(s,e.length)},R:function(n,e){const t=WE(n);return lt(t,e.length)},u:function(n,e){const t=n.getFullYear();return lt(t,e.length)},Q:function(n,e,t){const r=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return lt(r,2);case"Qo":return t.ordinalNumber(r,{unit:"quarter"});case"QQQ":return t.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(r,{width:"wide",context:"formatting"})}},q:function(n,e,t){const r=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return lt(r,2);case"qo":return t.ordinalNumber(r,{unit:"quarter"});case"qqq":return t.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(r,{width:"wide",context:"standalone"})}},M:function(n,e,t){const r=n.getMonth();switch(e){case"M":case"MM":return ws.M(n,e);case"Mo":return t.ordinalNumber(r+1,{unit:"month"});case"MMM":return t.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(r,{width:"wide",context:"formatting"})}},L:function(n,e,t){const r=n.getMonth();switch(e){case"L":return String(r+1);case"LL":return lt(r+1,2);case"Lo":return t.ordinalNumber(r+1,{unit:"month"});case"LLL":return t.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(r,{width:"wide",context:"standalone"})}},w:function(n,e,t,r){const i=$U(n,r);return e==="wo"?t.ordinalNumber(i,{unit:"week"}):lt(i,e.length)},I:function(n,e,t){const r=CU(n);return e==="Io"?t.ordinalNumber(r,{unit:"week"}):lt(r,e.length)},d:function(n,e,t){return e==="do"?t.ordinalNumber(n.getDate(),{unit:"date"}):ws.d(n,e)},D:function(n,e,t){const r=PU(n);return e==="Do"?t.ordinalNumber(r,{unit:"dayOfYear"}):lt(r,e.length)},E:function(n,e,t){const r=n.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(r,{width:"short",context:"formatting"});case"EEEE":default:return t.day(r,{width:"wide",context:"formatting"})}},e:function(n,e,t,r){const i=n.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return lt(s,2);case"eo":return t.ordinalNumber(s,{unit:"day"});case"eee":return t.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(i,{width:"short",context:"formatting"});case"eeee":default:return t.day(i,{width:"wide",context:"formatting"})}},c:function(n,e,t,r){const i=n.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return lt(s,e.length);case"co":return t.ordinalNumber(s,{unit:"day"});case"ccc":return t.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(i,{width:"narrow",context:"standalone"});case"cccccc":return t.day(i,{width:"short",context:"standalone"});case"cccc":default:return t.day(i,{width:"wide",context:"standalone"})}},i:function(n,e,t){const r=n.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return lt(i,e.length);case"io":return t.ordinalNumber(i,{unit:"day"});case"iii":return t.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(r,{width:"short",context:"formatting"});case"iiii":default:return t.day(r,{width:"wide",context:"formatting"})}},a:function(n,e,t){const i=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(n,e,t){const r=n.getHours();let i;switch(r===12?i=$o.noon:r===0?i=$o.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(n,e,t){const r=n.getHours();let i;switch(r>=17?i=$o.evening:r>=12?i=$o.afternoon:r>=4?i=$o.morning:i=$o.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(n,e,t){if(e==="ho"){let r=n.getHours()%12;return r===0&&(r=12),t.ordinalNumber(r,{unit:"hour"})}return ws.h(n,e)},H:function(n,e,t){return e==="Ho"?t.ordinalNumber(n.getHours(),{unit:"hour"}):ws.H(n,e)},K:function(n,e,t){const r=n.getHours()%12;return e==="Ko"?t.ordinalNumber(r,{unit:"hour"}):lt(r,e.length)},k:function(n,e,t){let r=n.getHours();return r===0&&(r=24),e==="ko"?t.ordinalNumber(r,{unit:"hour"}):lt(r,e.length)},m:function(n,e,t){return e==="mo"?t.ordinalNumber(n.getMinutes(),{unit:"minute"}):ws.m(n,e)},s:function(n,e,t){return e==="so"?t.ordinalNumber(n.getSeconds(),{unit:"second"}):ws.s(n,e)},S:function(n,e){return ws.S(n,e)},X:function(n,e,t){const r=n.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return KP(r);case"XXXX":case"XX":return yl(r);case"XXXXX":case"XXX":default:return yl(r,":")}},x:function(n,e,t){const r=n.getTimezoneOffset();switch(e){case"x":return KP(r);case"xxxx":case"xx":return yl(r);case"xxxxx":case"xxx":default:return yl(r,":")}},O:function(n,e,t){const r=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+HP(r,":");case"OOOO":default:return"GMT"+yl(r,":")}},z:function(n,e,t){const r=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+HP(r,":");case"zzzz":default:return"GMT"+yl(r,":")}},t:function(n,e,t){const r=Math.trunc(+n/1e3);return lt(r,e.length)},T:function(n,e,t){return lt(+n,e.length)}};function HP(n,e=""){const t=n>0?"-":"+",r=Math.abs(n),i=Math.trunc(r/60),s=r%60;return s===0?t+String(i):t+String(i)+e+lt(s,2)}function KP(n,e){return n%60===0?(n>0?"-":"+")+lt(Math.abs(n)/60,2):yl(n,e)}function yl(n,e=""){const t=n>0?"-":"+",r=Math.abs(n),i=lt(Math.trunc(r/60),2),s=lt(r%60,2);return t+i+e+s}const JP=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},UE=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},TU=(n,e)=>{const t=n.match(/(P+)(p+)?/)||[],r=t[1],i=t[2];if(!i)return JP(n,e);let s;switch(r){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;case"PPPP":default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",JP(r,e)).replace("{{time}}",UE(i,e))},jU={p:UE,P:TU},EU=/^D+$/,MU=/^Y+$/,AU=["D","DD","YY","YYYY"];function RU(n){return EU.test(n)}function NU(n){return MU.test(n)}function LU(n,e,t){const r=_U(n,e,t);if(console.warn(r),AU.includes(n))throw new RangeError(r)}function _U(n,e,t){const r=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${r} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const DU=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,IU=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,zU=/^'([^]*?)'?$/,ZU=/''/g,XU=/[a-zA-Z]/;function Vt(n,e,t){var f,p,g,x;const r=Aa(),i=r.locale??FE,s=r.firstWeekContainsDate??((p=(f=r.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,l=r.weekStartsOn??((x=(g=r.locale)==null?void 0:g.options)==null?void 0:x.weekStartsOn)??0,o=Qt(n,t==null?void 0:t.in);if(!DY(o))throw new RangeError("Invalid time value");let u=e.match(IU).map(k=>{const b=k[0];if(b==="p"||b==="P"){const w=jU[b];return w(k,i.formatLong)}return k}).join("").match(DU).map(k=>{if(k==="''")return{isToken:!1,value:"'"};const b=k[0];if(b==="'")return{isToken:!1,value:BU(k)};if(GP[b])return{isToken:!0,value:k};if(b.match(XU))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:k}});i.localize.preprocessor&&(u=i.localize.preprocessor(o,u));const h={firstWeekContainsDate:s,weekStartsOn:l,locale:i};return u.map(k=>{if(!k.isToken)return k.value;const b=k.value;(NU(b)||RU(b))&&LU(b,e,String(n));const w=GP[b[0]];return w(o,b,i.localize,h)}).join("")}function BU(n){const e=n.match(zU);return e?e[1].replace(ZU,"'"):n}function WU(n,e,t){const r=Aa(),i=(t==null?void 0:t.locale)??r.locale??FE,s=2520,l=Jf(n,e);if(isNaN(l))throw new RangeError("Invalid time value");const o=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:l}),[u,h]=Gl(t==null?void 0:t.in,...l>0?[e,n]:[n,e]),f=WY(h,u),p=(qd(h)-qd(u))/1e3,g=Math.round((f-p)/60);let x;if(g<2)return t!=null&&t.includeSeconds?f<5?i.formatDistance("lessThanXSeconds",5,o):f<10?i.formatDistance("lessThanXSeconds",10,o):f<20?i.formatDistance("lessThanXSeconds",20,o):f<40?i.formatDistance("halfAMinute",0,o):f<60?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",1,o):g===0?i.formatDistance("lessThanXMinutes",1,o):i.formatDistance("xMinutes",g,o);if(g<45)return i.formatDistance("xMinutes",g,o);if(g<90)return i.formatDistance("aboutXHours",1,o);if(g<YP){const k=Math.round(g/60);return i.formatDistance("aboutXHours",k,o)}else{if(g<s)return i.formatDistance("xDays",1,o);if(g<_f){const k=Math.round(g/YP);return i.formatDistance("xDays",k,o)}else if(g<_f*2)return x=Math.round(g/_f),i.formatDistance("aboutXMonths",x,o)}if(x=BY(h,u),x<12){const k=Math.round(g/_f);return i.formatDistance("xMonths",k,o)}else{const k=x%12,b=Math.trunc(x/12);return k<3?i.formatDistance("aboutXYears",b,o):k<9?i.formatDistance("overXYears",b,o):i.formatDistance("almostXYears",b+1,o)}}function xy(n,e){return WU(n,qE(n),e)}function qU(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e);return+ki(r,t)==+ki(i,t)}function VU(n,e,t){const[r,i]=Gl(t==null?void 0:t.in,n,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function vp(n,e){return LY(dr(n,n),qE(n))}function K0(n,e){if(n==="day")return{from:Fl(e),to:H0(e)};if(n==="week")return{from:ki(e,{weekStartsOn:1}),to:Oy(e,{weekStartsOn:1})};const t=qY(e),r=VE(e);return{from:ki(t,{weekStartsOn:1}),to:Oy(r,{weekStartsOn:1})}}function QO(n,e,t){return t===0?new Date:n==="day"?kp(e,t):n==="week"?NY(e,t):EY(e,t)}function FU(n,e){if(n==="day")return Vt(e,"EEEE · MMMM d, yyyy");if(n==="week"){const t=ki(e,{weekStartsOn:1}),r=Oy(e,{weekStartsOn:1});return t.getMonth()===r.getMonth()?`${Vt(t,"MMMM d")} – ${Vt(r,"d, yyyy")}`:`${Vt(t,"MMM d")} – ${Vt(r,"MMM d, yyyy")}`}return Vt(e,"MMMM yyyy")}function YU(n){if(n.status==="in_progress")return new Date;if(n.status==="done"){if(n.completedAt)return new Date(n.completedAt);if(n.updatedAt)return new Date(n.updatedAt)}return n.dueAt?new Date(n.dueAt):null}function Ra(n,e=new Date){return!n.dueAt||n.status==="done"||n.status==="in_progress"||n.status==="rejected"?!1:new Date(n.dueAt).getTime()<Fl(e).getTime()}function J0(n){var t;const e=n.metadata;return((t=e==null?void 0:e.recurrence)==null?void 0:t.role)==="occurrence"}function GE(n){const e=new Map;for(const t of n){const r=YU(t);if(!r)continue;const i=Vt(r,"yyyy-MM-dd");e.has(i)||e.set(i,[]),e.get(i).push(t)}return e}function HE(n){const e=new Map;for(const t of n){const r=Vt(new Date(t.dueAt),"yyyy-MM-dd");e.has(r)||e.set(r,[]),e.get(r).push(t)}return e}function Vd(n){return Vt(n,"yyyy-MM-dd")}function KE(n,e){const t=[];let r=Fl(n);const i=H0(e);for(;r<=i;)t.push(r),r=kp(r,1);return t}function Hl(n){const e=new Map;return n==null||n.forEach(t=>e.set(t.id,t)),e}const eC={in_progress:0,open:1,done:2};function bp(n,e){const t=eC[n.status]??3,r=eC[e.status]??3;return t-r}const tC={archived:!0};function UU(){const{data:n}=Vn({includeArchived:!0}),{data:e}=CF({limit:20}),{data:t}=Ul({includeBacklog:!0,includeDone:!1}),r=Pi(),i=new Map;if(t){const f=new Date,p=[...t.scheduled,...t.overdue,...t.backlog];for(const g of p){if(!g.projectId||g.status==="rejected")continue;const x=i.get(g.projectId)??{open:0,overdue:0};x.open+=1,Ra(g,f)&&(x.overdue+=1),i.set(g.projectId,x)}}const[s,l]=my("botnote.workspace.projectGroups.collapsed",tC),o=gy.map(f=>({status:f,projects:(n??[]).filter(p=>p.status===f)})).filter(f=>f.projects.length>0),u=f=>s[f]??tC[f]??!1,h=f=>{const p=u(f);l({...s,[f]:!p})};return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-8 space-y-8",children:[m.jsxs("header",{children:[m.jsx("h1",{className:"text-xl font-semibold text-ink",children:"Workspace"}),m.jsx("p",{className:"text-sm text-muted mt-1",children:"Projects, tasks, notes, and memory — written by you or by your agents."})]}),m.jsxs("section",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-3 text-muted",children:[m.jsx(x6,{size:14}),m.jsxs("h2",{className:"text-xs uppercase tracking-wider font-medium",children:["Projects (",(n==null?void 0:n.length)??0,")"]})]}),n&&n.length===0?m.jsxs("div",{className:"border border-dashed border-line rounded-lg p-6 text-center text-sm text-muted",children:["No projects yet. Press ",m.jsx("kbd",{children:"n"})," to create one."]}):o.map(f=>m.jsx(KU,{status:f.status,projects:f.projects,counts:i,collapsed:u(f.status),onToggle:()=>h(f.status)},f.status))]}),m.jsx(HU,{}),m.jsxs("section",{children:[m.jsxs("div",{className:"flex items-center gap-2 mb-3 text-muted",children:[m.jsx(n6,{size:14}),m.jsx("h2",{className:"text-xs uppercase tracking-wider font-medium",children:"Recent activity"})]}),e&&e.length===0?m.jsx("div",{className:"text-sm text-muted",children:"Nothing yet."}):m.jsx("div",{className:"bg-surface border border-line rounded-md divide-y divide-line/60",children:e==null?void 0:e.map(f=>{const p=n==null?void 0:n.find(g=>g.id===f.projectId);return m.jsxs("button",{type:"button",onClick:()=>r.open(f.id),className:"w-full text-left flex items-center gap-3 px-3 py-2 row-hover",children:[m.jsx(xp,{kind:f.kind}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(f)?"text-muted italic":"text-ink"}`,children:ln(f)}),m.jsxs("div",{className:"text-xxs text-muted mt-0.5",children:[p?p.key:"—"," · ",JE(f.createdAt)," ·"," ",m.jsx("span",{className:"opacity-70",children:f.actorKind})]})]})]},f.id)})})]})]})})}const nC={bug:"text-red-700 bg-red-50 border-red-100",feature:"text-blue-700 bg-blue-50 border-blue-100",friction:"text-amber-700 bg-amber-50 border-amber-100",idea:"text-purple-700 bg-purple-50 border-purple-100"},GU=[{value:"open",label:"Open"},{value:"in_progress",label:"In progress"},{value:"done",label:"Done"},{value:"rejected",label:"Rejected"}];function HU(){const[n,e]=M.useState(null),[t,r]=M.useState("open"),{data:i}=QF({category:n,status:t,limit:50}),s=Js(),l=Pi();return m.jsxs("section",{children:[m.jsxs("div",{className:"flex items-center gap-2 mb-3 text-muted",children:[m.jsx(j6,{size:14}),m.jsx("h2",{className:"text-xs uppercase tracking-wider font-medium",children:"Product feedback"})]}),m.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-2",children:[m.jsx("div",{className:"seg",children:GU.map(o=>m.jsx("button",{onClick:()=>r(o.value),"data-active":t===o.value,children:o.label},o.value))}),m.jsx("div",{className:"w-px h-4 bg-line mx-1"}),m.jsx("button",{className:`h-6 px-2.5 text-xxs rounded-full border transition-colors ${n?"bg-surface text-muted border-line hover:text-ink":"bg-accentSoft text-accentText border-accent/30"}`,onClick:()=>e(null),children:"All"}),FF.map(o=>m.jsx("button",{className:`h-6 px-2.5 text-xxs rounded-full border capitalize transition-colors ${n===o?nC[o]:"bg-surface text-muted border-line hover:text-ink"}`,onClick:()=>e(n===o?null:o),children:o},o))]}),i&&i.length===0?m.jsxs("div",{className:"border border-dashed border-line rounded-md p-4 text-center text-xs text-muted",children:["No ",t.replace("_"," ")," feedback",n?` in “${n}”`:"","."]}):m.jsx("div",{className:"bg-surface border border-line rounded-md divide-y divide-line/60",children:i==null?void 0:i.map(o=>{const u=o.metadata.category??"idea",h=o.metadata.tool,f=o.status==="open"||o.status==="in_progress";return m.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 row-hover cursor-pointer group",onClick:()=>l.open(o.id),children:[m.jsx("span",{className:`inline-flex items-center px-1.5 h-5 mt-0.5 text-xxs rounded border capitalize shrink-0 ${nC[u]}`,children:u}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(o)?"text-muted italic":"text-ink"}`,children:ln(o)}),m.jsxs("div",{className:"text-xxs text-muted mt-0.5",children:[h&&m.jsxs("span",{className:"font-mono",children:[h," · "]}),o.actorKind," · ",JE(o.createdAt)]})]}),f&&m.jsxs("div",{className:"flex items-center gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:p=>p.stopPropagation(),children:[m.jsxs("button",{className:"btn btn-ghost h-6! px-2! text-xxs gap-1",title:"Mark done",onClick:()=>s.mutate({id:o.id,fields:{status:"done"}}),children:[m.jsx(Ki,{size:11})," Done"]}),m.jsxs("button",{className:"btn btn-ghost h-6! px-2! text-xxs gap-1 hover:text-red-600!",title:"Reject",onClick:()=>s.mutate({id:o.id,fields:{status:"rejected"}}),children:[m.jsx(Sc,{size:11})," Reject"]})]})]},o.id)})})]})}function KU({status:n,projects:e,counts:t,collapsed:r,onToggle:i}){return m.jsxs("div",{children:[m.jsxs("button",{type:"button",className:"flex items-center gap-1.5 mb-2 text-muted hover:text-ink",onClick:i,title:`${r?"Expand":"Collapse"} ${Vl[n]}`,children:[r?m.jsx(ja,{size:12}):m.jsx(ey,{size:12}),m.jsxs("span",{className:"text-xxs uppercase tracking-wider font-medium",children:[Vl[n]," (",e.length,")"]})]}),!r&&m.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:e.map(s=>m.jsx(JU,{project:s,counts:t.get(s.id)},s.id))})]})}function JU({project:n,counts:e}){return m.jsxs(ba,{to:`/p/${n.key}`,className:`border border-line rounded-md p-3 bg-surface hover:border-accent/50 transition-colors block ${n.status==="archived"?"opacity-70":""}`,children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[m.jsx(el,{color:n.color,icon:n.icon,size:12}),m.jsx("span",{className:"font-mono text-xs shrink-0",style:{color:n.color},children:n.key})]}),m.jsxs("span",{className:"text-xxs text-faint shrink-0",children:["Updated ",new Date(n.updatedAt).toLocaleDateString()]})]}),m.jsx("div",{className:"text-sm font-medium text-ink mt-1 truncate",children:n.name}),m.jsxs("div",{className:"text-xxs text-muted mt-1 flex items-center gap-2",children:[m.jsxs("span",{children:[(e==null?void 0:e.open)??0," open"]}),e&&e.overdue>0&&m.jsxs("span",{className:"text-danger font-medium",children:[e.overdue," overdue"]}),n.agentsMd&&m.jsx("span",{className:"text-faint",children:"· AGENTS.md"})]})]})}function JE(n){const e=Date.now()-new Date(n).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:e<7*864e5?`${Math.floor(e/864e5)}d ago`:new Date(n).toLocaleDateString()}function eG(){const{key:n,id:e}=Gd();return!n||!e?m.jsx(cb,{to:"/",replace:!0}):m.jsx(cb,{to:`/p/${n}?d=${e}`,replace:!0})}function e1({tag:n,className:e=""}){return m.jsx("span",{className:`chip shrink min-w-0 max-w-32 ${e}`,title:n,children:m.jsx("span",{className:"truncate min-w-0",children:n})})}const tG=["urgent","high","medium","low","none"];function wp({task:n,project:e,showProject:t=!0,compact:r=!1}){const i=Pi(),s=Js(),l=AE(),o=e&&n.sequenceId?`${e.key}-${n.sequenceId}`:null,u=Ra(n),h=J0(n),f=n.status==="done"?n.completedAt??n.updatedAt:n.dueAt,p=n.status==="done"?"Completed":"Due";return m.jsxs("div",{className:`task-row group ${r?"h-7! text-xs":""}`,onClick:()=>i.open(n.id),children:[m.jsx(yp,{task:n}),o&&!r&&m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums shrink-0",children:o}),m.jsx("span",{className:`flex-1 min-w-0 truncate ${n.status==="done"?"text-muted line-through":n.status==="rejected"?"text-muted":jr(n)?"text-muted italic":"text-ink"}`,children:ln(n)}),!r&&n.tags.slice(0,2).map(g=>m.jsx(e1,{tag:g,className:"hidden md:inline-flex"},g)),t&&e&&r&&m.jsx("span",{className:"font-mono text-xxs text-faint shrink-0",children:e.key}),n.blockedBy&&n.blockedBy.length>0&&n.status!=="done"&&m.jsx("span",{className:"shrink-0 px-1 rounded text-xxs font-medium uppercase tracking-wide bg-warn/15 text-warn",title:`Blocked by ${n.blockedBy.map(g=>`${g.ref} ${g.title}`).join(", ")}`,children:"blocked"}),h&&m.jsx("span",{className:"shrink-0 text-faint",title:"Recurring task",children:m.jsx(Gc,{size:12})}),f&&m.jsx("span",{className:`text-xxs tabular-nums shrink-0 ${u?"text-danger font-medium":"text-muted"}`,title:`${p} ${new Date(f).toLocaleString()}`,children:Vt(new Date(f),"MMM d")}),m.jsx(G0,{trigger:m.jsx("button",{className:"shrink-0 p-0.5 -m-0.5 rounded hover:bg-line/40",onClick:g=>g.stopPropagation(),title:xa[n.priority],children:m.jsx(Oa,{priority:n.priority})}),align:"end",children:g=>m.jsx(m.Fragment,{children:tG.map(x=>m.jsxs("button",{className:"popover-item",onClick:k=>{k.stopPropagation(),s.mutate({id:n.id,fields:{priority:x}}),g()},children:[m.jsx(Oa,{priority:x,size:12}),m.jsx("span",{children:xa[x]}),n.priority===x&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]},x))})}),m.jsx("button",{className:"shrink-0 p-1 -m-1 rounded text-faint opacity-0 group-hover:opacity-100 hover:bg-danger/10 hover:text-danger transition-opacity",onClick:g=>{g.stopPropagation(),l(n)},title:"Delete",children:m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",children:m.jsx("path",{d:"M3 4h8M5.5 4V2.5h3V4M4.5 4l.5 8h4l.5-8M6 6.5v3.5M8 6.5v3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})}const rC={urgent:0,high:1,medium:2,low:3,none:4};function nG(){const{data:n,isLoading:e}=Ul({includeBacklog:!0,includeDone:!1}),{data:t}=Vn(),r=M.useMemo(()=>Hl(t),[t]),{open:i}=zt(),s=M.useMemo(()=>rG((n==null?void 0:n.backlog)??[],r),[n,r]),l=s.reduce((o,u)=>o+u.tasks.length,0);return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6 space-y-4",children:[m.jsxs("header",{className:"flex items-baseline gap-3",children:[m.jsx(_d,{size:18,className:"text-accent"}),m.jsx("h1",{className:"text-lg font-semibold",children:"Inbox"}),m.jsx("span",{className:"text-xs text-muted",children:"Tasks without due date"})]}),m.jsx("p",{className:"text-xs text-muted",children:"Tasks land here until they get a due date."}),e?m.jsx("div",{className:"text-sm text-muted",children:"Loading…"}):l===0?m.jsxs("div",{className:"border border-dashed border-line rounded-md p-8 text-center",children:[m.jsx("div",{className:"text-sm text-muted",children:"Inbox empty."}),t&&t.length>0&&m.jsx("button",{className:"mt-2 text-xs text-accent hover:underline",onClick:()=>i({kind:"quick-create"}),children:"+ capture something"})]}):m.jsx("div",{className:"space-y-3",children:s.map(({projectId:o,project:u,tasks:h})=>m.jsxs("section",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsxs("div",{className:"px-3 py-1.5 border-b border-lineSoft bg-sidebar/40 flex items-center gap-1.5 text-xxs",children:[u?m.jsxs(m.Fragment,{children:[m.jsx(el,{color:u.color,icon:u.icon,size:10}),m.jsx("span",{className:"font-mono tabular-nums",style:{color:u.color},children:u.key}),m.jsx("span",{className:"text-muted truncate",children:u.name})]}):m.jsx("span",{className:"text-faint",children:"no project"}),m.jsx("span",{className:"text-faint ml-auto tabular-nums",children:h.length})]}),h.map(f=>m.jsx(wp,{task:f,project:f.projectId?r.get(f.projectId):void 0},f.id))]},o??"_none"))})]})})}function rG(n,e){const t=new Map;for(const r of n){const i=r.projectId??null;t.has(i)||t.set(i,[]),t.get(i).push(r)}return Array.from(t.entries()).map(([r,i])=>({projectId:r,project:r?e.get(r):void 0,tasks:i.slice().sort(iG)})).sort((r,i)=>!r.project&&!i.project?0:r.project?i.project?r.project.key.localeCompare(i.project.key):-1:1)}function iG(n,e){const t=(rC[n.priority]??5)-(rC[e.priority]??5);return t!==0?t:new Date(e.createdAt).getTime()-new Date(n.createdAt).getTime()}function sG(){const[n,e]=M.useState(""),[t,r]=M.useState(null),[i,s]=M.useState(!1),l=Gs(),[o]=Rc(),u=o.get("next")||"/";async function h(f){if(f.preventDefault(),!(!n||i)){s(!0),r(null);try{await We.login(n),l(u,{replace:!0})}catch(p){const g=p instanceof Error?p.message:String(p);g.includes("401")||g.includes("invalid_password")?r("密码不对"):g.includes("rate_limited")||g.includes("429")?r("登录尝试过频,稍候再试"):r("登录失败 — 服务可能离线"),s(!1)}}}return m.jsx("div",{className:"min-h-screen w-full flex items-center justify-center bg-bg px-4",children:m.jsxs("form",{onSubmit:h,className:"w-full max-w-sm bg-surface border border-line rounded-lg shadow-xs p-6 space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"w-8 h-8 rounded-md bg-accent flex items-center justify-center text-white text-sm font-bold",children:"b"}),m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-semibold text-ink leading-tight",children:"botnote"}),m.jsx("div",{className:"text-xxs text-muted",children:"Sign in to continue"})]})]}),m.jsxs("label",{className:"block space-y-1.5",children:[m.jsx("span",{className:"text-xs font-medium text-ink2",children:"Password"}),m.jsx("input",{type:"password",autoFocus:!0,autoComplete:"current-password",value:n,onChange:f=>e(f.target.value),className:"w-full px-3 py-2 text-sm rounded-md border border-line bg-bg focus:outline-hidden focus:ring-2 focus:ring-accent/40 focus:border-accent",disabled:i})]}),t&&m.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded px-2.5 py-1.5",children:t}),m.jsxs("button",{type:"submit",disabled:!n||i,className:"w-full btn btn-primary justify-center gap-2 py-2",children:[i?m.jsx(uj,{size:14,className:"animate-spin"}):m.jsx(T6,{size:14}),m.jsx("span",{children:i?"Signing in…":"Sign in"})]}),m.jsx("p",{className:"text-xxs text-muted text-center pt-1",children:"Session cookie expires in 30 days. CLI / MCP unaffected."})]})})}const $O=[{status:"open",label:"Todo",intent:"text-statusOpen"},{status:"in_progress",label:"In Progress",intent:"text-statusInProgress"},{status:"done",label:"Done",intent:"text-statusDone"},{status:"rejected",label:"Cancelled",intent:"text-statusRejected"}];function lG({tasks:n,project:e}){var l;const t=Js(),{open:r}=zt(),i={};for(const o of $O)i[o.status]=[];for(const o of n){const u=((l=$O.find(h=>h.status===o.status))==null?void 0:l.status)??"open";i[u].push(o)}i.done.sort((o,u)=>+new Date(u.completedAt??u.updatedAt)-+new Date(o.completedAt??o.updatedAt));function s(o,u){t.mutate({id:u,fields:{status:o}})}return m.jsx("div",{className:"h-full overflow-x-auto overflow-y-hidden",children:m.jsx("div",{className:"h-full flex gap-3 p-3 min-w-max",children:$O.map(o=>m.jsx(oG,{label:o.label,intent:o.intent,tasks:i[o.status]??[],project:e,onDropTask:u=>s(o.status,u),onAdd:()=>r({kind:"quick-create",projectId:e.id}),initialLimit:o.status==="done"?8:void 0},o.status))})})}function oG({label:n,intent:e,tasks:t,project:r,onDropTask:i,onAdd:s,initialLimit:l}){const[o,u]=M.useState(!1),[h,f]=M.useState(!1),p=l!=null&&!h?t.slice(0,l):t,g=t.length-p.length;return m.jsxs("div",{className:`w-72 shrink-0 flex flex-col rounded-md border ${o?"border-accent bg-accentSoft/30":"border-line bg-sidebar/40"} transition-colors`,onDragOver:x=>{x.preventDefault(),o||u(!0)},onDragLeave:()=>u(!1),onDrop:x=>{x.preventDefault(),u(!1);const k=x.dataTransfer.getData("text/task-id");k&&i(k)},children:[m.jsxs("div",{className:"px-3 h-9 flex items-center justify-between border-b border-line",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:`text-xs font-semibold ${e}`,children:n}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:t.length})]}),m.jsx("button",{className:"text-faint hover:text-accent text-xs",onClick:s,title:"Add task",children:"+"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin p-2 space-y-1.5",children:t.length===0?m.jsx("div",{className:"text-xxs text-faint text-center py-4",children:"No tasks"}):m.jsxs(m.Fragment,{children:[p.map(x=>m.jsx(aG,{task:x,project:r},x.id)),g>0&&m.jsxs("button",{className:"w-full text-xxs text-muted hover:text-ink py-1.5",onClick:()=>f(!0),children:["Show all ",t.length]}),h&&l!=null&&t.length>l&&m.jsxs("button",{className:"w-full text-xxs text-muted hover:text-ink py-1.5",onClick:()=>f(!1),children:["Show latest ",l]})]})})]})}function aG({task:n,project:e}){const t=Pi(),r=Ra(n),i=n.sequenceId?`${e.key}-${n.sequenceId}`:null,s=n.status==="done"?n.completedAt??n.updatedAt:n.dueAt,l=n.status==="done"?"Completed":"Due";return m.jsxs("div",{draggable:!0,onDragStart:o=>{o.dataTransfer.setData("text/task-id",n.id),o.dataTransfer.effectAllowed="move"},onClick:()=>t.open(n.id),className:"group bg-surface border border-line rounded p-2 cursor-grab active:cursor-grabbing hover:border-accent transition-colors",children:[m.jsxs("div",{className:"flex items-start gap-1.5",children:[m.jsx(yp,{task:n,size:13,className:"mt-0.5"}),m.jsx("span",{className:`flex-1 min-w-0 text-sm leading-snug ${n.status==="done"||n.status==="rejected"?"text-muted":jr(n)?"italic text-muted":"text-ink"}`,children:ln(n)}),J0(n)&&m.jsx(Gc,{size:11,className:"text-faint mt-0.5"}),m.jsx(Oa,{priority:n.priority,size:11})]}),m.jsxs("div",{className:"mt-1.5 flex items-center gap-2 overflow-hidden text-xxs text-muted",children:[i&&m.jsx("span",{className:"font-mono tabular-nums shrink-0 whitespace-nowrap",children:i}),s&&m.jsx("span",{className:`tabular-nums shrink-0 whitespace-nowrap ${r?"text-danger font-medium":""}`,title:`${l} ${new Date(s).toLocaleString()}`,children:Vt(new Date(s),"MMM d")}),n.tags.slice(0,2).map(o=>m.jsx(e1,{tag:o,className:"h-4! text-[10px]!"},o))]})]})}function uG({project:n}){const[e,t]=Rc(),r=Js(),{open:i}=zt(),{data:s}=U0(n.id,["note"]),[l,o]=M.useState("all");function u(f){e.set("d",f),t(e,{replace:!0})}const h=(s??[]).filter(f=>l==="pinned"?f.pinned:!0);return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("div",{className:"px-3 h-9 flex items-center justify-between border-b border-line bg-surface",children:[m.jsx("div",{className:"flex items-center gap-2",children:m.jsxs("div",{className:"seg",children:[m.jsxs("button",{"data-active":l==="all",onClick:()=>o("all"),children:["All ",m.jsx("span",{className:"text-faint ml-1",children:(s==null?void 0:s.length)??0})]}),m.jsxs("button",{"data-active":l==="pinned",onClick:()=>o("pinned"),children:["Pinned ",m.jsx("span",{className:"text-faint ml-1",children:(s==null?void 0:s.filter(f=>f.pinned).length)??0})]})]})}),m.jsx("button",{className:"btn btn-primary",onClick:()=>i({kind:"quick-create",projectId:n.id}),children:"+ Note"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin bg-surface",children:h.length===0?m.jsxs("div",{className:"p-8 text-center text-xs text-muted",children:[l==="pinned"?"No pinned notes yet.":"No notes yet.",m.jsx("div",{className:"text-faint mt-1",children:l==="pinned"?"Pin notes to surface them in opening brief for agents.":"Press c to create one."})]}):h.map(f=>m.jsx("div",{className:"px-4 py-2.5 border-b border-lineSoft row-hover cursor-pointer group",onClick:()=>u(f.id),children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx("button",{className:`shrink-0 mt-0.5 p-0.5 -m-0.5 rounded hover:bg-line/40 ${f.pinned?"text-accent":"text-faint hover:text-ink"}`,onClick:p=>{p.stopPropagation(),r.mutate({id:f.id,fields:{pinned:!f.pinned}})},title:f.pinned?"Unpin":"Pin to opening brief",children:f.pinned?m.jsx(j0,{size:12,fill:"currentColor"}):m.jsx(A6,{size:12,className:"opacity-0 group-hover:opacity-100 transition-opacity"})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(f)?"text-muted italic":"text-ink"}`,children:ln(f)}),!jr(f)&&f.body&&m.jsx("div",{className:"text-xs text-muted truncate mt-0.5",children:f.body.replace(/\n/g," ").slice(0,200)}),m.jsxs("div",{className:"text-xxs text-faint mt-1 flex items-center gap-2",children:[m.jsx("span",{children:xy(new Date(f.updatedAt),{addSuffix:!0})}),m.jsx("span",{children:"·"}),m.jsx("span",{children:f.actorKind}),f.tags.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"·"}),f.tags.slice(0,3).map(p=>m.jsx(e1,{tag:p,className:"h-4! text-[10px]!"},p))]})]})]})]})},f.id))})]})}function cG(){const{key:n}=Gd(),[e,t]=Rc(),r=e.get("tab")||"tasks",{data:i}=SE(n),{data:s}=U0(i==null?void 0:i.id,["task"],{poll:!0}),{open:l}=zt(),o=M.useMemo(()=>{const h=s??[];return{todo:h.filter(f=>f.status==="open").length,in_progress:h.filter(f=>f.status==="in_progress").length,done:h.filter(f=>f.status==="done").length,tasks:h.length}},[s]);if(!i)return m.jsx("div",{className:"p-6 text-sm text-muted",children:"Loading project…"});const u=h=>{h==="tasks"?e.delete("tab"):e.set("tab",h),t(e,{replace:!0})};return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsxs("div",{className:"h-11 px-4 border-b border-line bg-surface flex items-center justify-between shrink-0",children:[m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[m.jsx(el,{color:i.color,icon:i.icon,size:14}),m.jsx("span",{className:"font-mono text-xs tabular-nums",style:{color:i.color},children:i.key}),m.jsx("span",{className:"text-sm font-semibold text-ink truncate",children:i.name}),m.jsx("span",{className:"chip",children:Vl[i.status]}),m.jsx("button",{className:"ml-1 p-1 -m-1 text-faint hover:text-ink rounded hover:bg-sidebar",onClick:()=>l({kind:"edit-project",projectId:i.id}),title:"Project settings",children:m.jsx(I6,{size:11})})]}),m.jsx("div",{className:"flex items-center gap-1",children:m.jsxs("div",{className:"seg",children:[m.jsxs("button",{"data-active":r==="tasks",onClick:()=>u("tasks"),children:[m.jsx(Z6,{size:11,className:"inline mr-1"}),"Tasks ",m.jsx("span",{className:"text-faint ml-1",children:o.tasks})]}),m.jsxs("button",{"data-active":r==="notes",onClick:()=>u("notes"),children:[m.jsx(m6,{size:11,className:"inline mr-1"}),"Notes"]}),m.jsxs(ba,{to:`/p/${i.key}/agents-md`,className:"px-2 h-7 text-xs hover:text-ink hover:bg-sidebar transition-colors text-muted flex items-center",children:[m.jsx(dj,{size:11,className:"inline mr-1"}),"AGENTS.md"]})]})})]}),m.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden",children:[r==="tasks"&&m.jsx(lG,{tasks:s??[],project:i}),r==="notes"&&m.jsx(uG,{project:i})]})]})}const TO=90;function hG({body:n,query:e}){const t=n.replace(/\s+/g," ").trim(),r=e.split(/\s+/).map(p=>p.trim()).filter(p=>p.length>0),i=t.toLowerCase();let s=-1,l=0;for(const p of r){const g=i.indexOf(p.toLowerCase());g>=0&&(s===-1||g<s)&&(s=g,l=p.length)}let o=0,u=Math.min(t.length,TO*2);s>=0&&(o=Math.max(0,s-TO),u=Math.min(t.length,s+l+TO));const h=t.slice(o,u),f=[];if(r.length===0)f.push(h);else{const p=new RegExp(`(${r.map(g=>g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`,"gi");h.split(p).forEach((g,x)=>{x%2===1?f.push(m.jsx("mark",{className:"bg-amber-100 text-inherit rounded-[2px] px-px",children:g},x)):g&&f.push(g)})}return m.jsxs("div",{className:"text-xs text-muted mt-1 wrap-break-word",children:[o>0&&"… ",f,u<t.length&&" …"]})}function fG(){const[n,e]=Rc(),t=n.get("q")??"",[r,i]=M.useState(t);M.useEffect(()=>i(t),[t]);const[s,l]=M.useState(null),{data:o}=PE(t?{query:t,kind:s,limit:50}:null),{data:u}=Vn(),h=M.useMemo(()=>Hl(u),[u]),f=Pi();function p(){const g=r.trim();e(g?{q:g}:{})}return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[m.jsxs("div",{className:"relative",children:[m.jsx(Dd,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),m.jsx("input",{type:"search",value:r,onChange:g=>i(g.target.value),onKeyDown:g=>{g.key==="Enter"&&p()},placeholder:"Search tasks, notes, comments…",autoFocus:!0,className:"w-full h-9 pl-9 pr-3 text-sm bg-surface border border-line rounded focus:outline-hidden focus:ring-2 focus:ring-accent/30 focus:border-accent"})]}),m.jsxs("div",{className:"mt-3 flex items-center gap-1.5",children:[m.jsx(iC,{label:"All",active:s===null,onClick:()=>l(null)}),VF.map(g=>m.jsx(iC,{label:g,active:s===g,onClick:()=>l(s===g?null:g)},g)),t&&m.jsxs("span",{className:"ml-auto text-xxs text-muted tabular-nums",children:[(o==null?void 0:o.hits.length)??0," results"]})]}),t?o&&o.hits.length===0?m.jsxs("div",{className:"mt-16 text-center text-muted",children:[m.jsxs("div",{className:"text-sm",children:["No results for “",t,"”"]}),m.jsxs("div",{className:"text-xs text-faint mt-1",children:["Try fewer or different keywords",s?", or clear the kind filter":"","."]})]}):m.jsx("div",{className:"mt-3 bg-surface border border-line rounded divide-y divide-line/60",children:o==null?void 0:o.hits.map(g=>{const x=g.entity.projectId?h.get(g.entity.projectId):void 0,k=x&&g.entity.sequenceId!=null?`${x.key}-${g.entity.sequenceId}`:null;return m.jsxs("button",{type:"button",onClick:()=>f.open(g.entity.id),className:"w-full text-left p-3 flex items-start gap-3 row-hover",children:[m.jsx(xp,{kind:g.entity.kind,compact:!0}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[k&&m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums shrink-0",children:k}),m.jsx("span",{className:`text-sm truncate ${jr(g.entity)?"italic text-muted":"text-ink"}`,children:ln(g.entity)})]}),m.jsx(hG,{body:g.entity.body,query:t}),m.jsxs("div",{className:"text-xxs text-faint mt-1 flex items-center gap-2",children:[x&&m.jsx("span",{children:x.name}),m.jsx("span",{children:Vt(new Date(g.entity.updatedAt),"MMM d, yyyy")})]})]})]},g.entity.id)})}):m.jsxs("div",{className:"mt-16 text-center text-muted",children:[m.jsx(Dd,{size:24,className:"mx-auto mb-3 text-faint"}),m.jsx("div",{className:"text-sm",children:"Search your workspace"}),m.jsx("div",{className:"text-xs text-faint mt-1",children:"Tasks, notes, comments and feedback — by keyword or meaning."})]})]})})}function iC({label:n,active:e,onClick:t}){return m.jsx("button",{type:"button",onClick:t,className:`h-6 px-2.5 text-xxs rounded-full border capitalize transition-colors ${e?"bg-accentSoft text-accentText border-accent/30":"bg-surface text-muted border-line hover:text-ink"}`,children:n})}const Sr=typeof window<"u"?window.location.origin:"http://127.0.0.1:4280",jO=1e5,dG=[{id:"account",label:"Account",icon:F6},{id:"tokens",label:"API tokens",icon:S6},{id:"cli",label:"CLI",icon:mj},{id:"plugin",label:"Plugin",icon:fj},{id:"embedding",label:"Embeddings",icon:l6},{id:"mcp",label:"MCP",icon:R6},{id:"about",label:"About",icon:w6}];function pG(){const[n,e]=M.useState("account");return m.jsxs("div",{className:"h-full flex bg-bg overflow-hidden",children:[m.jsxs("nav",{className:"w-52 shrink-0 border-r border-line bg-sidebar/60 overflow-y-auto scrollbar-thin",children:[m.jsxs("div",{className:"px-4 pt-4 pb-2 flex items-center gap-2",children:[m.jsx(aj,{size:14,className:"text-accent"}),m.jsx("span",{className:"text-sm font-semibold",children:"Settings"})]}),m.jsx("ul",{className:"px-2 pb-4 space-y-0.5",children:dG.map(t=>m.jsx("li",{children:m.jsxs("button",{onClick:()=>e(t.id),className:`w-full text-left px-2.5 py-1.5 text-sm rounded-md flex items-center gap-2.5 transition-colors ${n===t.id?"bg-accentSoft/70 text-accentText font-medium":"text-muted hover:bg-sidebarHover hover:text-ink"}`,children:[m.jsx(t.icon,{size:13,className:n===t.id?"text-accent":"text-faint"}),t.label]})},t.id))})]}),m.jsx("main",{className:"flex-1 min-w-0 overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"mx-auto max-w-3xl px-8 py-8 space-y-6",children:[n==="account"&&m.jsx(gG,{}),n==="tokens"&&m.jsx(QG,{}),n==="cli"&&m.jsx(xG,{}),n==="plugin"&&m.jsx(kG,{}),n==="embedding"&&m.jsx(vG,{}),n==="mcp"&&m.jsx(wG,{}),n==="about"&&m.jsx(SG,{})]})})]})}function Kl({title:n,blurb:e}){return m.jsxs("header",{className:"pb-4 border-b border-lineSoft space-y-1.5",children:[m.jsx("h1",{className:"text-lg font-semibold text-ink",children:n}),e&&m.jsx("p",{className:"text-xs text-muted leading-relaxed max-w-xl",children:e})]})}function mG({title:n,blurb:e}){return m.jsxs("div",{className:"pt-2",children:[m.jsx("h2",{className:"text-sm font-semibold text-ink",children:n}),e&&m.jsx("p",{className:"text-xs text-muted leading-relaxed mt-0.5",children:e})]})}function gG(){const n=Gs(),[e,t]=M.useState(!1);async function r(){if(!e){t(!0);try{await We.logout()}catch{}n("/login",{replace:!0})}}return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"Account",blurb:"Browser session uses a master-password login. Agents (CLI / MCP) authenticate with bearer tokens, generated under API tokens."}),m.jsx(OG,{}),m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-3 flex items-center justify-between",children:[m.jsx("div",{className:"text-xs text-muted",children:"Sign out of this browser. Other devices and any active bearer tokens are unaffected."}),m.jsxs("button",{onClick:r,disabled:e,className:"btn text-red-500! border-red-500/30! hover:bg-red-500/10! gap-1.5",children:[m.jsx(cj,{size:12})," Log out"]})]})]})}function OG(){const{data:n}=RF(),e=NF(),[t,r]=M.useState(""),[i,s]=M.useState(null),l=(()=>{var u;try{return((u=Intl.supportedValuesOf)==null?void 0:u.call(Intl,"timeZone"))??[]}catch{return[]}})();M.useEffect(()=>{n&&r(n.timezone)},[n]);async function o(u){u.preventDefault(),s(null),await e.mutateAsync({timezone:t}),s("Workspace timezone saved.")}return m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-4 space-y-3",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-semibold text-ink",children:"Workspace timezone"}),m.jsx("p",{className:"text-xs text-muted mt-0.5 leading-relaxed",children:"Used to compute all-day recurring task occurrence dates on the correct local calendar day."})]}),m.jsxs("form",{onSubmit:o,className:"flex items-end gap-3",children:[m.jsxs("label",{className:"flex-1 space-y-1",children:[m.jsx("span",{className:"block text-xxs uppercase tracking-wider text-muted",children:"Timezone"}),l.length>0?m.jsx("select",{className:"input",value:t,onChange:u=>{r(u.target.value),s(null)},children:l.map(u=>m.jsx("option",{value:u,children:u},u))}):m.jsx("input",{className:"input font-mono",value:t,onChange:u=>{r(u.target.value),s(null)},placeholder:"UTC"})]}),m.jsxs("button",{type:"submit",className:"btn btn-primary",disabled:e.isPending||!t,children:[m.jsx(Ki,{size:11})," ",e.isPending?"Saving...":"Save"]})]}),i&&m.jsx("div",{className:"text-xs text-accentText bg-accentSoft/50 border border-accent/20 rounded-md px-3 py-2",children:i}),e.error&&m.jsx("div",{className:"text-xs text-danger",children:e.error instanceof Error?e.error.message:String(e.error)})]})}function xG(){const n=[{note:"Global install on any machine with node + npm:",code:"npm i -g botnote"},{note:m.jsxs(m.Fragment,{children:["One-time login. The default URL is the daemon on the same machine,"," ",m.jsx("code",{className:"text-ink",children:"http://127.0.0.1:4280"})," (no token needed, loopback is trusted). From another machine enter ",m.jsx("code",{className:"text-ink",children:Sr})," and paste a bearer token from Settings → API tokens."]}),code:"botnote login"}],e=[{code:"botnote today",desc:"today + overdue"},{code:"botnote tasks --status open",desc:"list open tasks"},{code:'botnote task "Ship the CLI" --project BOT --priority high --due 2026-06-10',desc:"create a task"},{code:'botnote note "Random capture" --project BOT --pin',desc:"capture a pinned note"},{code:'botnote search "deployment"',desc:"hybrid search"},{code:"botnote projects",desc:"list project keys"}],t=[{note:m.jsxs(m.Fragment,{children:["Per-shell override — skips"," ",m.jsx("code",{className:"text-ink",children:"~/.config/botnote/config.json"}),":"]}),code:"BOTNOTE_URL=http://127.0.0.1:4280 botnote today"},{note:m.jsxs(m.Fragment,{children:["Config file, preferred for the daemon host —"," ",m.jsx("code",{className:"text-ink",children:"~/.config/botnote/config.json"}),":"]}),code:'{ "baseUrl": "http://127.0.0.1:4280" }'}];return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"CLI",blurb:"The botnote npm package ships a binary that talks to this daemon over HTTP. Same tool for quick capture, today review, and ad-hoc search from any terminal."}),m.jsx($c,{title:"Install + login",steps:n}),m.jsx(tM,{title:"Daily commands",items:e}),m.jsx($c,{title:"Override the URL",steps:t})]})}const yG=`{
492
492
  "name": "botnote-plugins",
493
493
  "interface": { "displayName": "botnote Plugins" },
494
494
  "plugins": [
@@ -546,5 +546,5 @@ BOTNOTE_TOKEN = "bn_..."`,t=[{note:m.jsxs(m.Fragment,{children:["Add to ",m.jsx(
546
546
  -d '{ "body": "Quick capture", "pinned": false }'`},{note:"Hybrid search:",code:`curl -X POST '${Sr}/v1/search' \\
547
547
  -H 'authorization: Bearer bn_...' \\
548
548
  -H 'content-type: application/json' \\
549
- -d '{ "query": "deployment", "limit": 10 }'`}];return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"MCP (raw integration)",blurb:"Skip the Claude Code plugin and wire the MCP server in by hand — for Codex, custom agents, or any MCP-aware client. The botnote binary doubles as the MCP stdio server."}),m.jsx(CG,{title:"Claude Code (~/.claude.json or project-local .mcp.json)",code:n}),m.jsx($c,{title:"Codex (~/.codex/config.toml)",steps:t}),m.jsx($c,{title:"REST · curl",steps:r}),m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-3 text-xs text-muted leading-relaxed",children:["Raw MCP configuration requires the ",m.jsx("code",{className:"text-ink",children:"botnote"})," binary in",m.jsx("code",{className:"text-ink",children:" PATH"})," ","(",m.jsx("code",{className:"text-ink",children:"npm i -g botnote"}),"). The Claude Code and Codex plugins do not require a global CLI install; they run the matching npm package version automatically. The MCP server has no DB connection of its own; it speaks HTTP to whichever"," ",m.jsx("code",{className:"text-ink",children:"BOTNOTE_URL"})," you set."]})]})}function SG(){const{data:n,isLoading:e}=bF(),t=n!=null&&n.version?`v${n.version}`:e?"loading...":"unknown";return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"About",blurb:"Build + runtime info for this daemon."}),m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-3 text-xs text-muted space-y-2",children:[m.jsxs("div",{children:[m.jsxs("span",{className:"text-ink",children:["botnote ",t]})," — Postgres 16 + pgvector + Fastify 5 + MCP SDK"]}),m.jsxs("div",{children:["REST: ",m.jsx("code",{className:"text-ink",children:Sr})," · docs:"," ",m.jsx("a",{className:"text-accent hover:underline",href:"/docs",target:"_blank",rel:"noreferrer",children:"/docs"})]}),m.jsxs("div",{className:"pt-1 border-t border-lineSoft",children:["Auth is enforced when ",m.jsx("code",{className:"text-ink",children:"BOTNOTE_REQUIRE_AUTH=1"})," (or a"," ",m.jsx("code",{children:"BOTNOTE_PASSWORD"})," is set) on the daemon. Every request then needs a bearer token or a browser session cookie, except direct connections from the daemon host itself (",m.jsx("code",{children:"BOTNOTE_TRUST_LOCALHOST=0"})," closes that too). Forwarded headers are honoured only from proxies listed in ",m.jsx("code",{children:"BOTNOTE_TRUST_PROXY"})," (default: loopback)."]})]})]})}function $c({title:n,steps:e}){return m.jsxs("div",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsx("div",{className:"px-3 py-1.5 border-b border-lineSoft bg-sidebar/40",children:m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:n})}),m.jsx("div",{className:"px-3 py-3 space-y-3",children:e.map((t,r)=>m.jsxs("div",{className:"space-y-1.5",children:[t.note&&m.jsx("p",{className:"text-xs text-muted leading-relaxed",children:t.note}),t.code&&m.jsx(eM,{code:t.code})]},r))})]})}function eM({code:n}){const[e,t]=M.useState(!1);function r(){navigator.clipboard.writeText(n).then(()=>{t(!0),setTimeout(()=>t(!1),1400)})}return m.jsxs("div",{className:"relative border border-lineSoft rounded-md bg-sidebar/30",children:[m.jsx("pre",{className:"px-3 py-2 pr-9 text-xs font-mono leading-relaxed overflow-x-auto whitespace-pre text-ink2",children:n}),m.jsx("button",{onClick:r,className:"absolute top-1.5 right-1.5 p-1 rounded text-faint hover:text-ink hover:bg-sidebarHover transition-colors",title:"Copy command",children:e?m.jsx(Ki,{size:12,className:"text-success"}):m.jsx(bc,{size:12})})]})}function tM({title:n,items:e}){return m.jsxs("div",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsx("div",{className:"px-3 py-1.5 border-b border-lineSoft bg-sidebar/40",children:m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:n})}),m.jsx("ul",{className:"divide-y divide-lineSoft",children:e.map(t=>m.jsx(PG,{code:t.code,desc:t.desc},t.code))})]})}function PG({code:n,desc:e}){const[t,r]=M.useState(!1);function i(){navigator.clipboard.writeText(n).then(()=>{r(!0),setTimeout(()=>r(!1),1400)})}return m.jsxs("li",{className:"group flex items-center gap-3 px-3 py-1.5",children:[m.jsx("code",{className:"font-mono text-xs text-ink whitespace-nowrap overflow-x-auto scrollbar-thin",children:n}),m.jsx("span",{className:"flex-1 text-xs text-muted text-right truncate",children:e}),m.jsx("button",{onClick:i,className:`p-1 rounded transition-colors ${t?"text-success":"text-faint hover:text-ink opacity-0 group-hover:opacity-100 focus:opacity-100"}`,title:"Copy command",children:t?m.jsx(Ki,{size:12}):m.jsx(bc,{size:12})})]})}function CG({title:n,code:e}){const[t,r]=M.useState(!1);function i(){navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1400)})}return m.jsxs("div",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsxs("div",{className:"px-3 py-1.5 border-b border-lineSoft flex items-center justify-between bg-sidebar/40",children:[m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:n}),m.jsxs("button",{onClick:i,className:"text-xxs text-muted hover:text-ink flex items-center gap-1",children:[t?m.jsx(Ki,{size:11}):m.jsx(bc,{size:11}),t?"Copied":"Copy"]})]}),m.jsx("pre",{className:"px-3 py-2 text-xs font-mono leading-relaxed overflow-x-auto whitespace-pre bg-sidebar/20 text-ink2",children:e})]})}function QG(){const{data:n,isLoading:e}=BF(),t=WF(),r=qF(),[i,s]=M.useState(""),[l,o]=M.useState(null),[u,h]=M.useState(null),[f,p]=M.useState(null),[g,x]=M.useState(null);function k(S){navigator.clipboard.writeText(S.plaintext).then(()=>{x(S.id),setTimeout(()=>x(Q=>Q===S.id?null:Q),1400)})}async function b(S){if(S.preventDefault(),!i.trim())return;const Q=await t.mutateAsync(i.trim());o(Q),s("")}async function w(S,Q){if(!u&&confirm(`Revoke token "${Q}"? Any client using it stops working.`)){h(S),p(null);try{await r.mutateAsync(S),(l==null?void 0:l.id)===S&&o(null)}catch($){const R=$ instanceof Error?$.message:String($);p(`Could not revoke "${Q}": ${R}`)}finally{h($=>$===S?null:$)}}}return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"API tokens",blurb:"Bearer tokens for the CLI, MCP server, and direct REST calls. New tokens keep their full value available for copying here; older tokens created before this change only have a prefix and must be regenerated if the full value was lost."}),l&&m.jsxs("div",{className:"border border-warn rounded-md bg-warn/10 p-3 space-y-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-warn",children:[m.jsx(q6,{size:13}),"Copy this token now, or later from the token list."]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("code",{className:"flex-1 text-xs font-mono bg-surface border border-line rounded px-2 py-1 overflow-x-auto whitespace-nowrap",children:l.plaintext}),m.jsxs("button",{className:"btn",onClick:()=>navigator.clipboard.writeText(l.plaintext),children:[m.jsx(bc,{size:11})," Copy"]}),m.jsx("button",{className:"btn",onClick:()=>o(null),children:"Done"})]})]}),f&&m.jsx("div",{className:"border border-danger/30 rounded-md bg-danger/10 px-3 py-2 text-xs text-danger",children:f}),m.jsxs("form",{onSubmit:b,className:"flex gap-2",children:[m.jsx("input",{className:"input flex-1",placeholder:"Who will use it? e.g. Claude Code @ MacBook",value:i,onChange:S=>s(S.target.value)}),m.jsxs("button",{type:"submit",className:"btn btn-primary",disabled:!i.trim()||t.isPending,children:[m.jsx(qc,{size:11})," ",t.isPending?"Generating…":"Generate"]})]}),m.jsx("p",{className:"text-[11px] text-faint -mt-1",children:"The name is shown as the author of everything written with this token, so name it after the agent and machine."}),m.jsxs("div",{className:"border border-line rounded-md bg-surface divide-y divide-lineSoft overflow-hidden",children:[e&&m.jsx("div",{className:"p-3 text-xs text-muted",children:"Loading…"}),!e&&(!n||n.length===0)&&m.jsx("div",{className:"p-4 text-xs text-faint text-center",children:"No tokens yet."}),n==null?void 0:n.map(S=>{const Q=g===S.id;return m.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"text-sm text-ink truncate",children:S.name}),m.jsxs("div",{className:"text-xxs text-muted flex items-center gap-3 mt-0.5",children:[m.jsxs("code",{className:"font-mono text-faint",children:[S.prefix,"…"]}),m.jsxs("span",{children:["created ",xy(new Date(S.createdAt),{addSuffix:!0})]}),m.jsx("span",{children:S.lastUsedAt?`used ${xy(new Date(S.lastUsedAt),{addSuffix:!0})}`:"never used"})]})]}),S.plaintext?m.jsxs("button",{type:"button",onClick:()=>k({id:S.id,plaintext:S.plaintext}),className:`btn gap-1.5 ${Q?"!border-emerald-500/30 !text-emerald-600":""}`,title:"Copy full token",children:[Q?m.jsx(Ki,{size:11}):m.jsx(bc,{size:11}),Q?"Copied":"Copy token"]}):m.jsx("span",{className:"text-xxs text-faint border border-line rounded px-2 py-1",title:"Full token is unavailable for tokens created before recoverable storage was enabled.",children:"Unavailable"}),m.jsx("button",{type:"button",className:"text-faint hover:text-danger p-1 -m-1",disabled:u!==null,onClick:()=>w(S.id,S.name),title:u===S.id?"Revoking":"Revoke",children:u===S.id?m.jsx("span",{className:"text-xxs text-muted",children:"Revoking…"}):m.jsx(wc,{size:12})})]},S.id)})]})]})}function $G({anchor:n,projectIds:e}){const t=K0("day",n),{data:r}=Ul({from:t.from.toISOString(),to:t.to.toISOString(),projectIds:e??null,includeBacklog:!1,includeDone:!0}),{data:i}=Vn(),s=M.useMemo(()=>Hl(i),[i]),{open:l}=zt(),o=((r==null?void 0:r.overdue)??[]).filter(f=>Ra(f,n)),u=((r==null?void 0:r.scheduled)??[]).slice().sort(bp),h=vp(n);return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-4xl mx-auto py-4",children:[h&&o.length>0&&m.jsx(lC,{title:"Overdue",count:o.length,accent:"text-danger",tasks:o,projectMap:s}),m.jsx(lC,{title:h?"Today":Vt(n,"EEEE"),count:u.length,accent:"text-ink",tasks:u,projectMap:s,emptyAction:m.jsx("button",{className:"text-accent text-xs hover:underline",onClick:()=>l({kind:"quick-create"}),children:"+ add a task for this day"})})]})})}function lC({title:n,count:e,accent:t,tasks:r,projectMap:i,emptyAction:s}){return m.jsxs("section",{className:"mb-6",children:[m.jsxs("div",{className:"px-4 py-1.5 flex items-baseline gap-2 sticky top-0 bg-bg z-10",children:[m.jsx("h2",{className:`text-xs font-semibold ${t}`,children:n}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:e})]}),r.length===0?m.jsx("div",{className:"px-4 py-2 text-xs text-muted",children:s??"Nothing here."}):m.jsx("div",{className:"bg-surface border-y border-lineSoft",children:r.map(l=>m.jsx(wp,{task:l,project:l.projectId?i.get(l.projectId):void 0},l.id))})]})}function TG({projectIds:n,collapsed:e,onToggle:t}){const{data:r}=Ul({projectIds:n??null,includeBacklog:!0,includeDone:!1}),{data:i}=Vn(),s=M.useMemo(()=>Hl(i),[i]),l=((r==null?void 0:r.backlog)??[]).filter(u=>u.status!=="rejected"),o=M.useMemo(()=>{const u=new Map;for(const f of l){const p=f.projectId??null,g=u.get(p);g?g.push(f):u.set(p,[f])}const h=[];for(const[f,p]of u)h.push({project:f?s.get(f):void 0,tasks:p});return h.sort((f,p)=>f.project?p.project?f.project.key.localeCompare(p.project.key):-1:1),h},[l,s]);return e?m.jsxs("button",{className:"shrink-0 w-8 border-l border-line bg-sidebar/50 hover:bg-sidebar flex flex-col items-center pt-2 gap-2 group",onClick:t,title:"Expand Inbox",children:[m.jsx(_d,{size:14,className:"text-muted group-hover:text-ink"}),l.length>0&&m.jsx("div",{className:"text-xxs text-muted bg-surface border border-line rounded-full w-5 h-5 flex items-center justify-center",children:l.length})]}):m.jsxs("aside",{className:"shrink-0 w-72 border-l border-line bg-surface flex flex-col",children:[m.jsxs("div",{className:"px-3 h-9 flex items-center justify-between border-b border-lineSoft",children:[m.jsxs("div",{className:"flex items-center gap-2 text-muted",children:[m.jsx(_d,{size:12}),m.jsx("h2",{className:"text-xs font-medium text-ink2",children:"Inbox"}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:l.length})]}),m.jsx("button",{onClick:t,className:"btn-ghost btn !h-6 !w-6 !p-0",title:"Collapse",children:"→"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:l.length===0?m.jsxs("div",{className:"text-xs text-muted text-center py-8 px-4",children:["No tasks without due date.",m.jsx("div",{className:"text-faint mt-1",children:"Tasks without due date appear here."})]}):o.map(({project:u,tasks:h})=>m.jsxs("div",{children:[m.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-1.5 px-3 py-1 bg-surface border-b border-lineSoft",children:[m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums",children:(u==null?void 0:u.key)??"—"}),m.jsx("span",{className:"text-xxs text-muted truncate",children:(u==null?void 0:u.name)??"No project"}),m.jsx("span",{className:"ml-auto text-xxs text-faint tabular-nums",children:h.length})]}),h.map(f=>m.jsx(wp,{task:f,project:u,showProject:!1,compact:!0},f.id))]},(u==null?void 0:u.id)??"none"))})]})}function jG({virtual:n,project:e}){const t=n.title&&n.title.trim()?n.title:"Untitled";return m.jsxs("div",{"aria-label":`Upcoming — will be created automatically: ${t}`,className:"pointer-events-none w-full text-left flex items-center gap-1.5 pl-1 pr-1.5 py-1 rounded text-xs opacity-40 border border-dashed border-current",children:[m.jsx("span",{className:"w-[2px] self-stretch rounded-sm shrink-0",style:{backgroundColor:(e==null?void 0:e.color)??"#a8a8af"}}),m.jsx("span",{className:"truncate flex-1 min-w-0 text-ink2 italic",children:t}),m.jsx(Gc,{size:11,className:"text-faint"})]})}function nM({virtuals:n,projectMap:e}){if(n.length===0)return null;if(n.length===1){const r=n[0];return m.jsx(jG,{virtual:r,project:r.projectId?e.get(r.projectId):void 0})}const t=n.map(r=>r.title&&r.title.trim()?r.title:"Untitled").join(`
550
- `);return m.jsxs("div",{title:t,"aria-label":`${n.length} upcoming recurring tasks: ${t}`,className:"w-full flex items-center gap-1.5 pl-1 pr-1.5 py-1 rounded text-xs opacity-40 border border-dashed border-current",children:[m.jsx(Gc,{size:11,className:"text-faint shrink-0"}),m.jsxs("span",{className:"truncate flex-1 min-w-0 text-ink2 italic",children:["+",n.length," recurring"]})]})}function rM({task:n,project:e}){const t=Pi(),r=Ra(n);return m.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:i=>{i.dataTransfer.setData("text/task-id",n.id),i.dataTransfer.effectAllowed="move",i.stopPropagation()},onClick:()=>t.open(n.id),onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),t.open(n.id))},className:`group w-full text-left flex items-center gap-1.5 pl-1 pr-1.5 py-1 rounded text-xs hover:bg-sidebarHover transition-colors cursor-grab active:cursor-grabbing ${r?"bg-danger/5":""}`,title:e?`${e.key} · ${ln(n)}`:ln(n),children:[m.jsx("span",{className:"w-[2px] self-stretch rounded-sm shrink-0",style:{backgroundColor:(e==null?void 0:e.color)??"#a8a8af"}}),m.jsx(yp,{task:n,size:11}),m.jsx("span",{className:`truncate flex-1 min-w-0 ${n.status==="done"?"line-through text-muted":n.status==="rejected"?"text-muted":jr(n)?"italic text-muted":"text-ink2"}`,children:ln(n)}),J0(n)&&m.jsx(Gc,{size:11,className:"text-faint"}),n.priority!=="none"&&m.jsx(Oa,{priority:n.priority,size:11})]})}const EG=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function MG({anchor:n,projectIds:e}){const t=K0("month",n),r=KE(t.from,t.to),{data:i}=Ul({from:t.from.toISOString(),to:t.to.toISOString(),projectIds:e??null,includeBacklog:!1,includeDone:!0,includeVirtualRecurrences:!0}),{data:s}=Vn(),l=M.useMemo(()=>Hl(s),[s]),o=M.useMemo(()=>GE((i==null?void 0:i.scheduled)??[]),[i]),u=M.useMemo(()=>HE((i==null?void 0:i.virtualOccurrences)??[]),[i]);return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsx("div",{className:"grid grid-cols-7 border-b border-lineSoft bg-sidebar/50",children:EG.map(h=>m.jsx("div",{className:"px-2 py-1 text-xxs uppercase tracking-wider text-muted text-center",children:h},h))}),m.jsx("div",{className:"flex-1 grid grid-cols-7 grid-rows-6 bg-line/30 gap-px overflow-y-auto scrollbar-thin",children:r.map(h=>{const f=o.get(Vd(h))??[],p=u.get(Vd(h))??[],g=!VU(h,n),x=vp(h);return m.jsx(AG,{day:h,tasks:f,virtuals:p,projectMap:l,outOfMonth:g,today:x},h.toISOString())})})]})}function AG({day:n,tasks:e,virtuals:t,projectMap:r,outOfMonth:i,today:s}){const{open:l}=zt(),o=Js(),[u,h]=M.useState(!1),f=e.slice().sort(bp),p=f.filter(b=>b.status==="done").length,g=f.length,x=g>0&&p===g;function k(b){b.preventDefault(),h(!1);const w=b.dataTransfer.getData("text/task-id");if(!w)return;const S=new Date(n);S.setHours(12,0,0,0),o.mutate({id:w,fields:{dueAt:S.toISOString()}})}return m.jsxs("div",{className:`group bg-surface p-1 min-h-[112px] flex flex-col transition-colors ${i?"opacity-50":""} ${u?"ring-2 ring-accent ring-inset bg-accentSoft/40":s?"ring-1 ring-accent ring-inset bg-accentSoft/30":""}`,onDragOver:b=>{b.preventDefault(),u||h(!0)},onDragLeave:()=>h(!1),onDrop:k,children:[m.jsxs("div",{className:"flex items-center justify-between mb-1 px-1",children:[m.jsxs("div",{className:"flex items-baseline gap-1.5 min-w-0",children:[m.jsx("span",{className:`text-xs tabular-nums ${s?"font-semibold text-accent":"text-muted"}`,children:Vt(n,"d")}),g>0&&m.jsxs("span",{className:`text-xxs tabular-nums ${x?"text-statusDone font-medium":"text-faint"}`,title:`${p} done · ${g} total`,children:[p,"/",g]})]}),m.jsx("button",{className:"text-xs text-faint hover:text-accent opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>l({kind:"quick-create"}),title:"Add task",children:"+"})]}),m.jsxs("div",{className:"flex-1 space-y-0.5 min-h-0 overflow-hidden",children:[f.slice(0,4).map(b=>m.jsx(rM,{task:b,project:b.projectId?r.get(b.projectId):void 0},b.id)),f.length>4&&m.jsxs("div",{className:"text-xxs text-muted pl-1",children:["+",f.length-4]}),m.jsx(nM,{virtuals:t,projectMap:r})]})]})}function RG({view:n,setView:e,anchor:t,setAnchor:r,projectIds:i,setProjectIds:s}){var h;const{data:l}=Vn(),{open:o}=zt(),u=i?i.length===1?((h=l==null?void 0:l.find(f=>f.id===i[0]))==null?void 0:h.key)??"1 project":`${i.length} projects`:"All projects";return m.jsx("div",{className:"border-b border-line bg-surface",children:m.jsxs("div",{className:"flex items-center justify-between h-11 px-3",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("h1",{className:"text-xs font-semibold text-ink hidden sm:block",children:"Tasks"}),m.jsx("div",{className:"seg hidden md:flex",children:["day","week","month"].map(f=>m.jsx("button",{onClick:()=>e(f),"data-active":n===f,className:"capitalize",children:f},f))}),m.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[m.jsx("button",{onClick:()=>r(QO(n,t,-1)),className:"btn btn-ghost !h-6 !w-6 !p-0",title:"Previous",children:m.jsx(oj,{size:12})}),m.jsx("button",{onClick:()=>r(QO(n,t,0)),className:"btn !h-6 px-2 text-xxs",title:"Today",children:"Today"}),m.jsx("button",{onClick:()=>r(QO(n,t,1)),className:"btn btn-ghost !h-6 !w-6 !p-0",title:"Next",children:m.jsx(ja,{size:12})}),m.jsx("div",{className:"ml-2 text-xs font-medium text-ink2 tabular-nums",children:FU(n,t)})]})]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(NG,{projects:l??[],projectIds:i,setProjectIds:s,label:u}),m.jsxs("button",{className:"btn btn-primary",onClick:()=>o({kind:"quick-create"}),title:"New task (c)",children:[m.jsx(qc,{size:11}),m.jsx("span",{className:"text-xs hidden sm:inline",children:"Task"}),m.jsx("kbd",{className:"!bg-white/15 !border-white/25 !text-white hidden md:inline-block",children:"c"})]})]})]})})}function NG({projects:n,projectIds:e,setProjectIds:t,label:r}){return m.jsxs("details",{className:"relative",children:[m.jsxs("summary",{className:"btn list-none cursor-pointer",children:[m.jsx(g6,{size:11}),m.jsx("span",{className:"text-xs",children:r})]}),m.jsxs("div",{className:"popover top-9 right-0 w-56 px-1 py-1.5",children:[m.jsxs("button",{className:`popover-item ${e?"":"bg-accentSoft text-accentText"}`,onClick:()=>t(null),children:[m.jsx("span",{children:"All projects"}),!e&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]}),m.jsx("div",{className:"divider my-1"}),n.map(i=>{const s=(e==null?void 0:e.includes(i.id))??!1;return m.jsxs("label",{className:"popover-item gap-2 cursor-pointer",children:[m.jsx("input",{type:"checkbox",className:"cursor-pointer",checked:s,onChange:()=>{if(!e)t([i.id]);else if(s){const l=e.filter(o=>o!==i.id);t(l.length?l:null)}else t([...e,i.id])}}),m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums",children:i.key}),m.jsx("span",{className:"text-ink2 truncate",children:i.name})]},i.id)})]})]})}function LG({anchor:n,projectIds:e}){const t=K0("week",n),r=KE(t.from,t.to),i=kp(r[r.length-1],1),s=[...r,i],l=new Date(i);l.setHours(23,59,59,999);const{data:o}=Ul({from:t.from.toISOString(),to:l.toISOString(),projectIds:e??null,includeBacklog:!1,includeDone:!0,includeVirtualRecurrences:!0}),{data:u}=Vn(),h=M.useMemo(()=>Hl(u),[u]),f=M.useMemo(()=>GE((o==null?void 0:o.scheduled)??[]),[o]),p=M.useMemo(()=>HE((o==null?void 0:o.virtualOccurrences)??[]),[o]),g=s.slice(0,4),x=s.slice(4);return m.jsxs("div",{className:"h-full flex flex-col bg-bg",children:[m.jsx(oC,{days:g,byDay:f,virtualsByDay:p,projectMap:h,anchor:n}),m.jsx(oC,{days:x,byDay:f,virtualsByDay:p,projectMap:h,anchor:n})]})}function oC({days:n,byDay:e,virtualsByDay:t,projectMap:r,anchor:i}){return m.jsx("div",{className:"flex-1 min-h-0 flex border-b border-line last:border-b-0",children:n.map(s=>{const l=e.get(Vd(s))??[],o=t.get(Vd(s))??[],u=!qU(s,i,{weekStartsOn:1});return m.jsx(_G,{day:s,tasks:l,virtuals:o,projectMap:r,outOfWeek:u},s.toISOString())})})}function _G({day:n,tasks:e,virtuals:t,projectMap:r,outOfWeek:i}){const s=vp(n),{open:l}=zt(),o=Js(),u=e.slice().sort(bp),h=u.filter(x=>x.status==="done").length,f=u.length,p=f>0&&h===f;function g(x){x.preventDefault();const k=x.dataTransfer.getData("text/task-id");if(!k)return;const b=new Date(n);b.setHours(12,0,0,0),o.mutate({id:k,fields:{dueAt:b.toISOString()}})}return m.jsxs("div",{className:`flex-1 min-w-0 border-r border-lineSoft last:border-r-0 flex flex-col group/col ${s?"bg-accentSoft/30":i?"bg-sidebar/40":"bg-surface"}`,onDragOver:x=>x.preventDefault(),onDrop:g,children:[m.jsxs("div",{className:"px-3 py-1.5 flex items-baseline justify-between border-b border-lineSoft",children:[m.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted",children:Vt(n,"EEE")}),m.jsx("span",{className:`text-sm tabular-nums font-semibold ${s?"text-accent":i?"text-muted":"text-ink2"}`,children:Vt(n,"d")}),f>0&&m.jsxs("span",{className:`text-xxs tabular-nums ${p?"text-statusDone font-medium":"text-faint"}`,title:`${h} done · ${f} total`,children:[h,"/",f]}),i&&m.jsx("span",{className:"text-xxs text-faint italic",children:"next"})]}),m.jsx("button",{className:"text-faint hover:text-accent text-xs opacity-0 group-hover/col:opacity-100",title:"Add task",onClick:()=>l({kind:"quick-create"}),children:"+"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin p-1.5 space-y-1",children:u.length===0&&t.length===0?m.jsx("div",{className:"text-xxs text-faint px-1 py-0.5",children:"—"}):m.jsxs(m.Fragment,{children:[u.map(x=>m.jsx(rM,{task:x,project:x.projectId?r.get(x.projectId):void 0},x.id)),m.jsx(nM,{virtuals:t,projectMap:r})]})})]})}const aC="(max-width: 767px)";function DG(){const[n,e]=M.useState(()=>typeof window<"u"&&window.matchMedia(aC).matches);return M.useEffect(()=>{const t=window.matchMedia(aC),r=()=>e(t.matches);return t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),n}function IG(){const n=DG(),[e,t]=M.useState("week"),[r,i]=M.useState(()=>new Date),[s,l]=M.useState(null),[o,u]=M.useState(n),h=n?"day":e;return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsx(RG,{view:h,setView:t,anchor:r,setAnchor:i,projectIds:s,setProjectIds:l}),m.jsxs("div",{className:"flex-1 min-h-0 flex",children:[m.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden bg-bg",children:[h==="day"&&m.jsx($G,{anchor:r,projectIds:s}),h==="week"&&m.jsx(LG,{anchor:r,projectIds:s}),h==="month"&&m.jsx(MG,{anchor:r,projectIds:s})]}),m.jsx(TG,{projectIds:s,collapsed:o,onToggle:()=>u(f=>!f)})]})]})}function zG(){const n=new Date,{data:e}=Vn(),t=M.useMemo(()=>Hl(e),[e]),r=M.useMemo(()=>{const h=new Date(n);h.setHours(0,0,0,0);const f=new Date(n);return f.setHours(23,59,59,999),{from:h.toISOString(),to:f.toISOString()}},[]),{data:i,isLoading:s}=Ul({from:r.from,to:r.to,includeBacklog:!1,includeDone:!0}),{open:l}=zt(),o=((i==null?void 0:i.overdue)??[]).filter(h=>Ra(h,n)),u=((i==null?void 0:i.scheduled)??[]).slice().sort(bp);return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6 space-y-6",children:[m.jsxs("header",{className:"flex items-baseline gap-3",children:[m.jsx(pj,{size:18,className:"text-accent"}),m.jsx("h1",{className:"text-lg font-semibold",children:"Today"}),m.jsx("span",{className:"text-xs text-muted",children:Vt(n,"EEEE, MMM d")})]}),s&&m.jsx("div",{className:"text-sm text-muted",children:"Loading…"}),!s&&m.jsxs(m.Fragment,{children:[m.jsx(uC,{title:"Overdue",count:o.length,accent:"text-danger",tasks:o,projectMap:t}),m.jsx(uC,{title:vp(n)?"Today":Vt(n,"EEEE"),count:u.length,accent:"text-ink",tasks:u,projectMap:t,emptyAction:m.jsx("button",{className:"text-accent text-xs hover:underline",onClick:()=>l({kind:"quick-create"}),children:"+ add a task"})}),m.jsx(ZG,{})]})]})})}function ZG(){const[n,e]=M.useState(""),t=$E();function r(){const i=n.trim();if(!i||t.isPending)return;const s=new Date;s.setHours(12,0,0,0),t.mutate({kind:"task",title:i,dueAt:s.toISOString()},{onSuccess:()=>e("")})}return m.jsxs("div",{className:"flex items-center gap-2 border border-dashed border-line rounded-md px-3 py-1.5 focus-within:border-accent transition-colors",children:[m.jsx(qc,{size:12,className:"text-faint shrink-0"}),m.jsx("input",{value:n,onChange:i=>e(i.target.value),onKeyDown:i=>{i.key==="Enter"&&r()},placeholder:"Add a task for today…",className:"flex-1 bg-transparent text-xs outline-none placeholder:text-faint",disabled:t.isPending}),t.isPending&&m.jsx("span",{className:"text-xxs text-faint",children:"Adding…"})]})}function uC({title:n,count:e,accent:t,tasks:r,projectMap:i,emptyAction:s}){if(r.length===0&&!s)return null;const l=new Map;for(const o of r){const u=o.projectId??null;l.has(u)||l.set(u,[]),l.get(u).push(o)}return m.jsxs("section",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("h2",{className:`text-xs font-semibold ${t}`,children:n}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:e})]}),r.length===0?m.jsx("div",{className:"text-xs text-muted py-1",children:s??"Nothing here."}):m.jsx("div",{className:"border border-line rounded-md overflow-hidden bg-surface",children:Array.from(l.entries()).map(([o,u])=>{const h=o?i.get(o):void 0;return m.jsxs("div",{children:[m.jsxs("div",{className:"px-3 py-1 border-b border-lineSoft bg-sidebar/40 flex items-center gap-1.5 text-xxs",children:[h?m.jsxs(m.Fragment,{children:[m.jsx(el,{color:h.color,icon:h.icon,size:10}),m.jsx("span",{className:"font-mono tabular-nums",style:{color:h.color},children:h.key}),m.jsx("span",{className:"text-muted truncate",children:h.name})]}):m.jsx("span",{className:"text-faint",children:"no project"}),m.jsx("span",{className:"text-faint ml-auto tabular-nums",children:u.length})]}),u.map(f=>m.jsx(wp,{task:f,project:h},f.id))]},o??"_none")})})]})}function XG(){const{data:n}=CE(200),{data:e}=Vn({includeArchived:!0}),t=TF(),r=jF(),i=()=>{if(!(!n||n.length===0)&&window.confirm(`Permanently delete all ${n.length} item(s) in the trash? This cannot be undone.`))for(const s of n)r.mutate(s.id)};return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-8 space-y-5",children:[m.jsxs("header",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{children:[m.jsxs("h1",{className:"text-xl font-semibold text-ink flex items-center gap-2",children:[m.jsx(wc,{size:18,className:"text-muted"})," Trash"]}),m.jsx("p",{className:"text-sm text-muted mt-1",children:"Deleted items land here and are purged automatically after 30 days."})]}),n&&n.length>0&&m.jsxs("button",{className:"btn btn-ghost !h-7 !px-2.5 text-xs gap-1 shrink-0 hover:!text-red-600",onClick:i,children:[m.jsx(Sc,{size:12})," Empty trash"]})]}),n&&n.length===0?m.jsx("div",{className:"border border-dashed border-line rounded-lg p-8 text-center text-sm text-muted",children:"Trash is empty."}):m.jsx("div",{className:"bg-surface border border-line rounded-md divide-y divide-line/60",children:n==null?void 0:n.map(s=>{const l=e==null?void 0:e.find(o=>o.id===s.projectId);return m.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 row-hover group",children:[m.jsx(xp,{kind:s.kind}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(s)?"text-muted italic":"text-ink"}`,children:ln(s)}),m.jsxs("div",{className:"text-xxs text-muted mt-0.5",children:[l?l.key:"—"," · deleted"," ",s.deletedAt?BG(s.deletedAt):"—"," ·"," ",m.jsx("span",{className:"opacity-70",children:s.actorKind})]})]}),m.jsxs("div",{className:"flex items-center gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[m.jsxs("button",{className:"btn btn-ghost !h-6 !px-2 text-xxs gap-1",title:"Restore",onClick:()=>t.mutate(s.id),children:[m.jsx(_6,{size:11})," Restore"]}),m.jsxs("button",{className:"btn btn-ghost !h-6 !px-2 text-xxs gap-1 hover:!text-red-600",title:"Delete forever",onClick:()=>{window.confirm(`Permanently delete "${ln(s)}"? This cannot be undone.`)&&r.mutate(s.id)},children:[m.jsx(wc,{size:11})," Delete forever"]})]})]},s.id)})})]})})}function BG(n){const e=Date.now()-new Date(n).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:e<7*864e5?`${Math.floor(e/864e5)}d ago`:new Date(n).toLocaleDateString()}function WG(){return m.jsx(GF,{children:m.jsxs(t5,{children:[m.jsxs(zN,{children:[m.jsx(ir,{path:"/login",element:m.jsx(sG,{})}),m.jsxs(ir,{element:m.jsx(vY,{}),children:[m.jsx(ir,{path:"/",element:m.jsx(IG,{})}),m.jsx(ir,{path:"/today",element:m.jsx(zG,{})}),m.jsx(ir,{path:"/inbox",element:m.jsx(nG,{})}),m.jsx(ir,{path:"/dashboard",element:m.jsx(UU,{})}),m.jsx(ir,{path:"/trash",element:m.jsx(XG,{})}),m.jsx(ir,{path:"/settings",element:m.jsx(pG,{})}),m.jsx(ir,{path:"/p/:key",element:m.jsx(cG,{})}),m.jsx(ir,{path:"/p/:key/e/:id",element:m.jsx(eG,{})}),m.jsx(ir,{path:"/p/:key/agents-md",element:m.jsx(TY,{})}),m.jsx(ir,{path:"/search",element:m.jsx(fG,{})})]})]}),m.jsx(QY,{})]})})}const qG=new QR({defaultOptions:{queries:{staleTime:1e4,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!0}}});VR.createRoot(document.getElementById("root")).render(m.jsx(EC.StrictMode,{children:m.jsx(TR,{client:qG,children:m.jsx(UN,{children:m.jsx(WG,{})})})}));
549
+ -d '{ "query": "deployment", "limit": 10 }'`}];return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"MCP (raw integration)",blurb:"Skip the Claude Code plugin and wire the MCP server in by hand — for Codex, custom agents, or any MCP-aware client. The botnote binary doubles as the MCP stdio server."}),m.jsx(CG,{title:"Claude Code (~/.claude.json or project-local .mcp.json)",code:n}),m.jsx($c,{title:"Codex (~/.codex/config.toml)",steps:t}),m.jsx($c,{title:"REST · curl",steps:r}),m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-3 text-xs text-muted leading-relaxed",children:["Raw MCP configuration requires the ",m.jsx("code",{className:"text-ink",children:"botnote"})," binary in",m.jsx("code",{className:"text-ink",children:" PATH"})," ","(",m.jsx("code",{className:"text-ink",children:"npm i -g botnote"}),"). The Claude Code and Codex plugins do not require a global CLI install; they run the matching npm package version automatically. The MCP server has no DB connection of its own; it speaks HTTP to whichever"," ",m.jsx("code",{className:"text-ink",children:"BOTNOTE_URL"})," you set."]})]})}function SG(){const{data:n,isLoading:e}=bF(),t=n!=null&&n.version?`v${n.version}`:e?"loading...":"unknown";return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"About",blurb:"Build + runtime info for this daemon."}),m.jsxs("div",{className:"border border-line rounded-md bg-surface px-4 py-3 text-xs text-muted space-y-2",children:[m.jsxs("div",{children:[m.jsxs("span",{className:"text-ink",children:["botnote ",t]})," — Postgres 16 + pgvector + Fastify 5 + MCP SDK"]}),m.jsxs("div",{children:["REST: ",m.jsx("code",{className:"text-ink",children:Sr})," · docs:"," ",m.jsx("a",{className:"text-accent hover:underline",href:"/docs",target:"_blank",rel:"noreferrer",children:"/docs"})]}),m.jsxs("div",{className:"pt-1 border-t border-lineSoft",children:["Auth is enforced when ",m.jsx("code",{className:"text-ink",children:"BOTNOTE_REQUIRE_AUTH=1"})," (or a"," ",m.jsx("code",{children:"BOTNOTE_PASSWORD"})," is set) on the daemon. Every request then needs a bearer token or a browser session cookie, except direct connections from the daemon host itself (",m.jsx("code",{children:"BOTNOTE_TRUST_LOCALHOST=0"})," closes that too). Forwarded headers are honoured only from proxies listed in ",m.jsx("code",{children:"BOTNOTE_TRUST_PROXY"})," (default: loopback)."]})]})]})}function $c({title:n,steps:e}){return m.jsxs("div",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsx("div",{className:"px-3 py-1.5 border-b border-lineSoft bg-sidebar/40",children:m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:n})}),m.jsx("div",{className:"px-3 py-3 space-y-3",children:e.map((t,r)=>m.jsxs("div",{className:"space-y-1.5",children:[t.note&&m.jsx("p",{className:"text-xs text-muted leading-relaxed",children:t.note}),t.code&&m.jsx(eM,{code:t.code})]},r))})]})}function eM({code:n}){const[e,t]=M.useState(!1);function r(){navigator.clipboard.writeText(n).then(()=>{t(!0),setTimeout(()=>t(!1),1400)})}return m.jsxs("div",{className:"relative border border-lineSoft rounded-md bg-sidebar/30",children:[m.jsx("pre",{className:"px-3 py-2 pr-9 text-xs font-mono leading-relaxed overflow-x-auto whitespace-pre text-ink2",children:n}),m.jsx("button",{onClick:r,className:"absolute top-1.5 right-1.5 p-1 rounded text-faint hover:text-ink hover:bg-sidebarHover transition-colors",title:"Copy command",children:e?m.jsx(Ki,{size:12,className:"text-success"}):m.jsx(bc,{size:12})})]})}function tM({title:n,items:e}){return m.jsxs("div",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsx("div",{className:"px-3 py-1.5 border-b border-lineSoft bg-sidebar/40",children:m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:n})}),m.jsx("ul",{className:"divide-y divide-lineSoft",children:e.map(t=>m.jsx(PG,{code:t.code,desc:t.desc},t.code))})]})}function PG({code:n,desc:e}){const[t,r]=M.useState(!1);function i(){navigator.clipboard.writeText(n).then(()=>{r(!0),setTimeout(()=>r(!1),1400)})}return m.jsxs("li",{className:"group flex items-center gap-3 px-3 py-1.5",children:[m.jsx("code",{className:"font-mono text-xs text-ink whitespace-nowrap overflow-x-auto scrollbar-thin",children:n}),m.jsx("span",{className:"flex-1 text-xs text-muted text-right truncate",children:e}),m.jsx("button",{onClick:i,className:`p-1 rounded transition-colors ${t?"text-success":"text-faint hover:text-ink opacity-0 group-hover:opacity-100 focus:opacity-100"}`,title:"Copy command",children:t?m.jsx(Ki,{size:12}):m.jsx(bc,{size:12})})]})}function CG({title:n,code:e}){const[t,r]=M.useState(!1);function i(){navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1400)})}return m.jsxs("div",{className:"border border-line rounded-md bg-surface overflow-hidden",children:[m.jsxs("div",{className:"px-3 py-1.5 border-b border-lineSoft flex items-center justify-between bg-sidebar/40",children:[m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted font-medium",children:n}),m.jsxs("button",{onClick:i,className:"text-xxs text-muted hover:text-ink flex items-center gap-1",children:[t?m.jsx(Ki,{size:11}):m.jsx(bc,{size:11}),t?"Copied":"Copy"]})]}),m.jsx("pre",{className:"px-3 py-2 text-xs font-mono leading-relaxed overflow-x-auto whitespace-pre bg-sidebar/20 text-ink2",children:e})]})}function QG(){const{data:n,isLoading:e}=BF(),t=WF(),r=qF(),[i,s]=M.useState(""),[l,o]=M.useState(null),[u,h]=M.useState(null),[f,p]=M.useState(null),[g,x]=M.useState(null);function k(S){navigator.clipboard.writeText(S.plaintext).then(()=>{x(S.id),setTimeout(()=>x(Q=>Q===S.id?null:Q),1400)})}async function b(S){if(S.preventDefault(),!i.trim())return;const Q=await t.mutateAsync(i.trim());o(Q),s("")}async function w(S,Q){if(!u&&confirm(`Revoke token "${Q}"? Any client using it stops working.`)){h(S),p(null);try{await r.mutateAsync(S),(l==null?void 0:l.id)===S&&o(null)}catch($){const R=$ instanceof Error?$.message:String($);p(`Could not revoke "${Q}": ${R}`)}finally{h($=>$===S?null:$)}}}return m.jsxs(m.Fragment,{children:[m.jsx(Kl,{title:"API tokens",blurb:"Bearer tokens for the CLI, MCP server, and direct REST calls. New tokens keep their full value available for copying here; older tokens created before this change only have a prefix and must be regenerated if the full value was lost."}),l&&m.jsxs("div",{className:"border border-warn rounded-md bg-warn/10 p-3 space-y-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-warn",children:[m.jsx(q6,{size:13}),"Copy this token now, or later from the token list."]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("code",{className:"flex-1 text-xs font-mono bg-surface border border-line rounded px-2 py-1 overflow-x-auto whitespace-nowrap",children:l.plaintext}),m.jsxs("button",{className:"btn",onClick:()=>navigator.clipboard.writeText(l.plaintext),children:[m.jsx(bc,{size:11})," Copy"]}),m.jsx("button",{className:"btn",onClick:()=>o(null),children:"Done"})]})]}),f&&m.jsx("div",{className:"border border-danger/30 rounded-md bg-danger/10 px-3 py-2 text-xs text-danger",children:f}),m.jsxs("form",{onSubmit:b,className:"flex gap-2",children:[m.jsx("input",{className:"input flex-1",placeholder:"Who will use it? e.g. Claude Code @ MacBook",value:i,onChange:S=>s(S.target.value)}),m.jsxs("button",{type:"submit",className:"btn btn-primary",disabled:!i.trim()||t.isPending,children:[m.jsx(qc,{size:11})," ",t.isPending?"Generating…":"Generate"]})]}),m.jsx("p",{className:"text-[11px] text-faint -mt-1",children:"The name is shown as the author of everything written with this token, so name it after the agent and machine."}),m.jsxs("div",{className:"border border-line rounded-md bg-surface divide-y divide-lineSoft overflow-hidden",children:[e&&m.jsx("div",{className:"p-3 text-xs text-muted",children:"Loading…"}),!e&&(!n||n.length===0)&&m.jsx("div",{className:"p-4 text-xs text-faint text-center",children:"No tokens yet."}),n==null?void 0:n.map(S=>{const Q=g===S.id;return m.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"text-sm text-ink truncate",children:S.name}),m.jsxs("div",{className:"text-xxs text-muted flex items-center gap-3 mt-0.5",children:[m.jsxs("code",{className:"font-mono text-faint",children:[S.prefix,"…"]}),m.jsxs("span",{children:["created ",xy(new Date(S.createdAt),{addSuffix:!0})]}),m.jsx("span",{children:S.lastUsedAt?`used ${xy(new Date(S.lastUsedAt),{addSuffix:!0})}`:"never used"})]})]}),S.plaintext?m.jsxs("button",{type:"button",onClick:()=>k({id:S.id,plaintext:S.plaintext}),className:`btn gap-1.5 ${Q?"border-emerald-500/30! text-emerald-600!":""}`,title:"Copy full token",children:[Q?m.jsx(Ki,{size:11}):m.jsx(bc,{size:11}),Q?"Copied":"Copy token"]}):m.jsx("span",{className:"text-xxs text-faint border border-line rounded px-2 py-1",title:"Full token is unavailable for tokens created before recoverable storage was enabled.",children:"Unavailable"}),m.jsx("button",{type:"button",className:"text-faint hover:text-danger p-1 -m-1",disabled:u!==null,onClick:()=>w(S.id,S.name),title:u===S.id?"Revoking":"Revoke",children:u===S.id?m.jsx("span",{className:"text-xxs text-muted",children:"Revoking…"}):m.jsx(wc,{size:12})})]},S.id)})]})]})}function $G({anchor:n,projectIds:e}){const t=K0("day",n),{data:r}=Ul({from:t.from.toISOString(),to:t.to.toISOString(),projectIds:e??null,includeBacklog:!1,includeDone:!0}),{data:i}=Vn(),s=M.useMemo(()=>Hl(i),[i]),{open:l}=zt(),o=((r==null?void 0:r.overdue)??[]).filter(f=>Ra(f,n)),u=((r==null?void 0:r.scheduled)??[]).slice().sort(bp),h=vp(n);return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-4xl mx-auto py-4",children:[h&&o.length>0&&m.jsx(lC,{title:"Overdue",count:o.length,accent:"text-danger",tasks:o,projectMap:s}),m.jsx(lC,{title:h?"Today":Vt(n,"EEEE"),count:u.length,accent:"text-ink",tasks:u,projectMap:s,emptyAction:m.jsx("button",{className:"text-accent text-xs hover:underline",onClick:()=>l({kind:"quick-create"}),children:"+ add a task for this day"})})]})})}function lC({title:n,count:e,accent:t,tasks:r,projectMap:i,emptyAction:s}){return m.jsxs("section",{className:"mb-6",children:[m.jsxs("div",{className:"px-4 py-1.5 flex items-baseline gap-2 sticky top-0 bg-bg z-10",children:[m.jsx("h2",{className:`text-xs font-semibold ${t}`,children:n}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:e})]}),r.length===0?m.jsx("div",{className:"px-4 py-2 text-xs text-muted",children:s??"Nothing here."}):m.jsx("div",{className:"bg-surface border-y border-lineSoft",children:r.map(l=>m.jsx(wp,{task:l,project:l.projectId?i.get(l.projectId):void 0},l.id))})]})}function TG({projectIds:n,collapsed:e,onToggle:t}){const{data:r}=Ul({projectIds:n??null,includeBacklog:!0,includeDone:!1}),{data:i}=Vn(),s=M.useMemo(()=>Hl(i),[i]),l=((r==null?void 0:r.backlog)??[]).filter(u=>u.status!=="rejected"),o=M.useMemo(()=>{const u=new Map;for(const f of l){const p=f.projectId??null,g=u.get(p);g?g.push(f):u.set(p,[f])}const h=[];for(const[f,p]of u)h.push({project:f?s.get(f):void 0,tasks:p});return h.sort((f,p)=>f.project?p.project?f.project.key.localeCompare(p.project.key):-1:1),h},[l,s]);return e?m.jsxs("button",{className:"shrink-0 w-8 border-l border-line bg-sidebar/50 hover:bg-sidebar flex flex-col items-center pt-2 gap-2 group",onClick:t,title:"Expand Inbox",children:[m.jsx(_d,{size:14,className:"text-muted group-hover:text-ink"}),l.length>0&&m.jsx("div",{className:"text-xxs text-muted bg-surface border border-line rounded-full w-5 h-5 flex items-center justify-center",children:l.length})]}):m.jsxs("aside",{className:"shrink-0 w-72 border-l border-line bg-surface flex flex-col",children:[m.jsxs("div",{className:"px-3 h-9 flex items-center justify-between border-b border-lineSoft",children:[m.jsxs("div",{className:"flex items-center gap-2 text-muted",children:[m.jsx(_d,{size:12}),m.jsx("h2",{className:"text-xs font-medium text-ink2",children:"Inbox"}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:l.length})]}),m.jsx("button",{onClick:t,className:"btn-ghost btn h-6! w-6! p-0!",title:"Collapse",children:"→"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin",children:l.length===0?m.jsxs("div",{className:"text-xs text-muted text-center py-8 px-4",children:["No tasks without due date.",m.jsx("div",{className:"text-faint mt-1",children:"Tasks without due date appear here."})]}):o.map(({project:u,tasks:h})=>m.jsxs("div",{children:[m.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-1.5 px-3 py-1 bg-surface border-b border-lineSoft",children:[m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums",children:(u==null?void 0:u.key)??"—"}),m.jsx("span",{className:"text-xxs text-muted truncate",children:(u==null?void 0:u.name)??"No project"}),m.jsx("span",{className:"ml-auto text-xxs text-faint tabular-nums",children:h.length})]}),h.map(f=>m.jsx(wp,{task:f,project:u,showProject:!1,compact:!0},f.id))]},(u==null?void 0:u.id)??"none"))})]})}function jG({virtual:n,project:e}){const t=n.title&&n.title.trim()?n.title:"Untitled";return m.jsxs("div",{"aria-label":`Upcoming — will be created automatically: ${t}`,className:"pointer-events-none w-full text-left flex items-center gap-1.5 pl-1 pr-1.5 py-1 rounded text-xs opacity-40 border border-dashed border-current",children:[m.jsx("span",{className:"w-[2px] self-stretch rounded-sm shrink-0",style:{backgroundColor:(e==null?void 0:e.color)??"#a8a8af"}}),m.jsx("span",{className:"truncate flex-1 min-w-0 text-ink2 italic",children:t}),m.jsx(Gc,{size:11,className:"text-faint"})]})}function nM({virtuals:n,projectMap:e}){if(n.length===0)return null;if(n.length===1){const r=n[0];return m.jsx(jG,{virtual:r,project:r.projectId?e.get(r.projectId):void 0})}const t=n.map(r=>r.title&&r.title.trim()?r.title:"Untitled").join(`
550
+ `);return m.jsxs("div",{title:t,"aria-label":`${n.length} upcoming recurring tasks: ${t}`,className:"w-full flex items-center gap-1.5 pl-1 pr-1.5 py-1 rounded text-xs opacity-40 border border-dashed border-current",children:[m.jsx(Gc,{size:11,className:"text-faint shrink-0"}),m.jsxs("span",{className:"truncate flex-1 min-w-0 text-ink2 italic",children:["+",n.length," recurring"]})]})}function rM({task:n,project:e}){const t=Pi(),r=Ra(n);return m.jsxs("div",{role:"button",tabIndex:0,draggable:!0,onDragStart:i=>{i.dataTransfer.setData("text/task-id",n.id),i.dataTransfer.effectAllowed="move",i.stopPropagation()},onClick:()=>t.open(n.id),onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),t.open(n.id))},className:`group w-full text-left flex items-center gap-1.5 pl-1 pr-1.5 py-1 rounded text-xs hover:bg-sidebarHover transition-colors cursor-grab active:cursor-grabbing ${r?"bg-danger/5":""}`,title:e?`${e.key} · ${ln(n)}`:ln(n),children:[m.jsx("span",{className:"w-[2px] self-stretch rounded-sm shrink-0",style:{backgroundColor:(e==null?void 0:e.color)??"#a8a8af"}}),m.jsx(yp,{task:n,size:11}),m.jsx("span",{className:`truncate flex-1 min-w-0 ${n.status==="done"?"line-through text-muted":n.status==="rejected"?"text-muted":jr(n)?"italic text-muted":"text-ink2"}`,children:ln(n)}),J0(n)&&m.jsx(Gc,{size:11,className:"text-faint"}),n.priority!=="none"&&m.jsx(Oa,{priority:n.priority,size:11})]})}const EG=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function MG({anchor:n,projectIds:e}){const t=K0("month",n),r=KE(t.from,t.to),{data:i}=Ul({from:t.from.toISOString(),to:t.to.toISOString(),projectIds:e??null,includeBacklog:!1,includeDone:!0,includeVirtualRecurrences:!0}),{data:s}=Vn(),l=M.useMemo(()=>Hl(s),[s]),o=M.useMemo(()=>GE((i==null?void 0:i.scheduled)??[]),[i]),u=M.useMemo(()=>HE((i==null?void 0:i.virtualOccurrences)??[]),[i]);return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsx("div",{className:"grid grid-cols-7 border-b border-lineSoft bg-sidebar/50",children:EG.map(h=>m.jsx("div",{className:"px-2 py-1 text-xxs uppercase tracking-wider text-muted text-center",children:h},h))}),m.jsx("div",{className:"flex-1 grid grid-cols-7 grid-rows-6 bg-line/30 gap-px overflow-y-auto scrollbar-thin",children:r.map(h=>{const f=o.get(Vd(h))??[],p=u.get(Vd(h))??[],g=!VU(h,n),x=vp(h);return m.jsx(AG,{day:h,tasks:f,virtuals:p,projectMap:l,outOfMonth:g,today:x},h.toISOString())})})]})}function AG({day:n,tasks:e,virtuals:t,projectMap:r,outOfMonth:i,today:s}){const{open:l}=zt(),o=Js(),[u,h]=M.useState(!1),f=e.slice().sort(bp),p=f.filter(b=>b.status==="done").length,g=f.length,x=g>0&&p===g;function k(b){b.preventDefault(),h(!1);const w=b.dataTransfer.getData("text/task-id");if(!w)return;const S=new Date(n);S.setHours(12,0,0,0),o.mutate({id:w,fields:{dueAt:S.toISOString()}})}return m.jsxs("div",{className:`group bg-surface p-1 min-h-[112px] flex flex-col transition-colors ${i?"opacity-50":""} ${u?"ring-2 ring-accent ring-inset bg-accentSoft/40":s?"ring-1 ring-accent ring-inset bg-accentSoft/30":""}`,onDragOver:b=>{b.preventDefault(),u||h(!0)},onDragLeave:()=>h(!1),onDrop:k,children:[m.jsxs("div",{className:"flex items-center justify-between mb-1 px-1",children:[m.jsxs("div",{className:"flex items-baseline gap-1.5 min-w-0",children:[m.jsx("span",{className:`text-xs tabular-nums ${s?"font-semibold text-accent":"text-muted"}`,children:Vt(n,"d")}),g>0&&m.jsxs("span",{className:`text-xxs tabular-nums ${x?"text-statusDone font-medium":"text-faint"}`,title:`${p} done · ${g} total`,children:[p,"/",g]})]}),m.jsx("button",{className:"text-xs text-faint hover:text-accent opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>l({kind:"quick-create"}),title:"Add task",children:"+"})]}),m.jsxs("div",{className:"flex-1 space-y-0.5 min-h-0 overflow-hidden",children:[f.slice(0,4).map(b=>m.jsx(rM,{task:b,project:b.projectId?r.get(b.projectId):void 0},b.id)),f.length>4&&m.jsxs("div",{className:"text-xxs text-muted pl-1",children:["+",f.length-4]}),m.jsx(nM,{virtuals:t,projectMap:r})]})]})}function RG({view:n,setView:e,anchor:t,setAnchor:r,projectIds:i,setProjectIds:s}){var h;const{data:l}=Vn(),{open:o}=zt(),u=i?i.length===1?((h=l==null?void 0:l.find(f=>f.id===i[0]))==null?void 0:h.key)??"1 project":`${i.length} projects`:"All projects";return m.jsx("div",{className:"border-b border-line bg-surface",children:m.jsxs("div",{className:"flex items-center justify-between h-11 px-3",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("h1",{className:"text-xs font-semibold text-ink hidden sm:block",children:"Tasks"}),m.jsx("div",{className:"seg hidden md:flex",children:["day","week","month"].map(f=>m.jsx("button",{onClick:()=>e(f),"data-active":n===f,className:"capitalize",children:f},f))}),m.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[m.jsx("button",{onClick:()=>r(QO(n,t,-1)),className:"btn btn-ghost h-6! w-6! p-0!",title:"Previous",children:m.jsx(oj,{size:12})}),m.jsx("button",{onClick:()=>r(QO(n,t,0)),className:"btn h-6! px-2 text-xxs",title:"Today",children:"Today"}),m.jsx("button",{onClick:()=>r(QO(n,t,1)),className:"btn btn-ghost h-6! w-6! p-0!",title:"Next",children:m.jsx(ja,{size:12})}),m.jsx("div",{className:"ml-2 text-xs font-medium text-ink2 tabular-nums",children:FU(n,t)})]})]}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(NG,{projects:l??[],projectIds:i,setProjectIds:s,label:u}),m.jsxs("button",{className:"btn btn-primary",onClick:()=>o({kind:"quick-create"}),title:"New task (c)",children:[m.jsx(qc,{size:11}),m.jsx("span",{className:"text-xs hidden sm:inline",children:"Task"}),m.jsx("kbd",{className:"bg-white/15! border-white/25! text-white! hidden md:inline-block",children:"c"})]})]})]})})}function NG({projects:n,projectIds:e,setProjectIds:t,label:r}){return m.jsxs("details",{className:"relative",children:[m.jsxs("summary",{className:"btn list-none cursor-pointer",children:[m.jsx(g6,{size:11}),m.jsx("span",{className:"text-xs",children:r})]}),m.jsxs("div",{className:"popover top-9 right-0 w-56 px-1 py-1.5",children:[m.jsxs("button",{className:`popover-item ${e?"":"bg-accentSoft text-accentText"}`,onClick:()=>t(null),children:[m.jsx("span",{children:"All projects"}),!e&&m.jsx("span",{className:"ml-auto text-faint",children:"✓"})]}),m.jsx("div",{className:"divider my-1"}),n.map(i=>{const s=(e==null?void 0:e.includes(i.id))??!1;return m.jsxs("label",{className:"popover-item gap-2 cursor-pointer",children:[m.jsx("input",{type:"checkbox",className:"cursor-pointer",checked:s,onChange:()=>{if(!e)t([i.id]);else if(s){const l=e.filter(o=>o!==i.id);t(l.length?l:null)}else t([...e,i.id])}}),m.jsx("span",{className:"font-mono text-xxs text-faint tabular-nums",children:i.key}),m.jsx("span",{className:"text-ink2 truncate",children:i.name})]},i.id)})]})]})}function LG({anchor:n,projectIds:e}){const t=K0("week",n),r=KE(t.from,t.to),i=kp(r[r.length-1],1),s=[...r,i],l=new Date(i);l.setHours(23,59,59,999);const{data:o}=Ul({from:t.from.toISOString(),to:l.toISOString(),projectIds:e??null,includeBacklog:!1,includeDone:!0,includeVirtualRecurrences:!0}),{data:u}=Vn(),h=M.useMemo(()=>Hl(u),[u]),f=M.useMemo(()=>GE((o==null?void 0:o.scheduled)??[]),[o]),p=M.useMemo(()=>HE((o==null?void 0:o.virtualOccurrences)??[]),[o]),g=s.slice(0,4),x=s.slice(4);return m.jsxs("div",{className:"h-full flex flex-col bg-bg",children:[m.jsx(oC,{days:g,byDay:f,virtualsByDay:p,projectMap:h,anchor:n}),m.jsx(oC,{days:x,byDay:f,virtualsByDay:p,projectMap:h,anchor:n})]})}function oC({days:n,byDay:e,virtualsByDay:t,projectMap:r,anchor:i}){return m.jsx("div",{className:"flex-1 min-h-0 flex border-b border-line last:border-b-0",children:n.map(s=>{const l=e.get(Vd(s))??[],o=t.get(Vd(s))??[],u=!qU(s,i,{weekStartsOn:1});return m.jsx(_G,{day:s,tasks:l,virtuals:o,projectMap:r,outOfWeek:u},s.toISOString())})})}function _G({day:n,tasks:e,virtuals:t,projectMap:r,outOfWeek:i}){const s=vp(n),{open:l}=zt(),o=Js(),u=e.slice().sort(bp),h=u.filter(x=>x.status==="done").length,f=u.length,p=f>0&&h===f;function g(x){x.preventDefault();const k=x.dataTransfer.getData("text/task-id");if(!k)return;const b=new Date(n);b.setHours(12,0,0,0),o.mutate({id:k,fields:{dueAt:b.toISOString()}})}return m.jsxs("div",{className:`flex-1 min-w-0 border-r border-lineSoft last:border-r-0 flex flex-col group/col ${s?"bg-accentSoft/30":i?"bg-sidebar/40":"bg-surface"}`,onDragOver:x=>x.preventDefault(),onDrop:g,children:[m.jsxs("div",{className:"px-3 py-1.5 flex items-baseline justify-between border-b border-lineSoft",children:[m.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[m.jsx("span",{className:"text-xxs uppercase tracking-wider text-muted",children:Vt(n,"EEE")}),m.jsx("span",{className:`text-sm tabular-nums font-semibold ${s?"text-accent":i?"text-muted":"text-ink2"}`,children:Vt(n,"d")}),f>0&&m.jsxs("span",{className:`text-xxs tabular-nums ${p?"text-statusDone font-medium":"text-faint"}`,title:`${h} done · ${f} total`,children:[h,"/",f]}),i&&m.jsx("span",{className:"text-xxs text-faint italic",children:"next"})]}),m.jsx("button",{className:"text-faint hover:text-accent text-xs opacity-0 group-hover/col:opacity-100",title:"Add task",onClick:()=>l({kind:"quick-create"}),children:"+"})]}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin p-1.5 space-y-1",children:u.length===0&&t.length===0?m.jsx("div",{className:"text-xxs text-faint px-1 py-0.5",children:"—"}):m.jsxs(m.Fragment,{children:[u.map(x=>m.jsx(rM,{task:x,project:x.projectId?r.get(x.projectId):void 0},x.id)),m.jsx(nM,{virtuals:t,projectMap:r})]})})]})}const aC="(max-width: 767px)";function DG(){const[n,e]=M.useState(()=>typeof window<"u"&&window.matchMedia(aC).matches);return M.useEffect(()=>{const t=window.matchMedia(aC),r=()=>e(t.matches);return t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),n}function IG(){const n=DG(),[e,t]=M.useState("week"),[r,i]=M.useState(()=>new Date),[s,l]=M.useState(null),[o,u]=M.useState(n),h=n?"day":e;return m.jsxs("div",{className:"h-full flex flex-col",children:[m.jsx(RG,{view:h,setView:t,anchor:r,setAnchor:i,projectIds:s,setProjectIds:l}),m.jsxs("div",{className:"flex-1 min-h-0 flex",children:[m.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden bg-bg",children:[h==="day"&&m.jsx($G,{anchor:r,projectIds:s}),h==="week"&&m.jsx(LG,{anchor:r,projectIds:s}),h==="month"&&m.jsx(MG,{anchor:r,projectIds:s})]}),m.jsx(TG,{projectIds:s,collapsed:o,onToggle:()=>u(f=>!f)})]})]})}function zG(){const n=new Date,{data:e}=Vn(),t=M.useMemo(()=>Hl(e),[e]),r=M.useMemo(()=>{const h=new Date(n);h.setHours(0,0,0,0);const f=new Date(n);return f.setHours(23,59,59,999),{from:h.toISOString(),to:f.toISOString()}},[]),{data:i,isLoading:s}=Ul({from:r.from,to:r.to,includeBacklog:!1,includeDone:!0}),{open:l}=zt(),o=((i==null?void 0:i.overdue)??[]).filter(h=>Ra(h,n)),u=((i==null?void 0:i.scheduled)??[]).slice().sort(bp);return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6 space-y-6",children:[m.jsxs("header",{className:"flex items-baseline gap-3",children:[m.jsx(pj,{size:18,className:"text-accent"}),m.jsx("h1",{className:"text-lg font-semibold",children:"Today"}),m.jsx("span",{className:"text-xs text-muted",children:Vt(n,"EEEE, MMM d")})]}),s&&m.jsx("div",{className:"text-sm text-muted",children:"Loading…"}),!s&&m.jsxs(m.Fragment,{children:[m.jsx(uC,{title:"Overdue",count:o.length,accent:"text-danger",tasks:o,projectMap:t}),m.jsx(uC,{title:vp(n)?"Today":Vt(n,"EEEE"),count:u.length,accent:"text-ink",tasks:u,projectMap:t,emptyAction:m.jsx("button",{className:"text-accent text-xs hover:underline",onClick:()=>l({kind:"quick-create"}),children:"+ add a task"})}),m.jsx(ZG,{})]})]})})}function ZG(){const[n,e]=M.useState(""),t=$E();function r(){const i=n.trim();if(!i||t.isPending)return;const s=new Date;s.setHours(12,0,0,0),t.mutate({kind:"task",title:i,dueAt:s.toISOString()},{onSuccess:()=>e("")})}return m.jsxs("div",{className:"flex items-center gap-2 border border-dashed border-line rounded-md px-3 py-1.5 focus-within:border-accent transition-colors",children:[m.jsx(qc,{size:12,className:"text-faint shrink-0"}),m.jsx("input",{value:n,onChange:i=>e(i.target.value),onKeyDown:i=>{i.key==="Enter"&&r()},placeholder:"Add a task for today…",className:"flex-1 bg-transparent text-xs outline-hidden placeholder:text-faint",disabled:t.isPending}),t.isPending&&m.jsx("span",{className:"text-xxs text-faint",children:"Adding…"})]})}function uC({title:n,count:e,accent:t,tasks:r,projectMap:i,emptyAction:s}){if(r.length===0&&!s)return null;const l=new Map;for(const o of r){const u=o.projectId??null;l.has(u)||l.set(u,[]),l.get(u).push(o)}return m.jsxs("section",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("h2",{className:`text-xs font-semibold ${t}`,children:n}),m.jsx("span",{className:"text-xxs text-faint tabular-nums",children:e})]}),r.length===0?m.jsx("div",{className:"text-xs text-muted py-1",children:s??"Nothing here."}):m.jsx("div",{className:"border border-line rounded-md overflow-hidden bg-surface",children:Array.from(l.entries()).map(([o,u])=>{const h=o?i.get(o):void 0;return m.jsxs("div",{children:[m.jsxs("div",{className:"px-3 py-1 border-b border-lineSoft bg-sidebar/40 flex items-center gap-1.5 text-xxs",children:[h?m.jsxs(m.Fragment,{children:[m.jsx(el,{color:h.color,icon:h.icon,size:10}),m.jsx("span",{className:"font-mono tabular-nums",style:{color:h.color},children:h.key}),m.jsx("span",{className:"text-muted truncate",children:h.name})]}):m.jsx("span",{className:"text-faint",children:"no project"}),m.jsx("span",{className:"text-faint ml-auto tabular-nums",children:u.length})]}),u.map(f=>m.jsx(wp,{task:f,project:h},f.id))]},o??"_none")})})]})}function XG(){const{data:n}=CE(200),{data:e}=Vn({includeArchived:!0}),t=TF(),r=jF(),i=()=>{if(!(!n||n.length===0)&&window.confirm(`Permanently delete all ${n.length} item(s) in the trash? This cannot be undone.`))for(const s of n)r.mutate(s.id)};return m.jsx("div",{className:"h-full overflow-y-auto scrollbar-thin",children:m.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-8 space-y-5",children:[m.jsxs("header",{className:"flex items-start justify-between gap-4",children:[m.jsxs("div",{children:[m.jsxs("h1",{className:"text-xl font-semibold text-ink flex items-center gap-2",children:[m.jsx(wc,{size:18,className:"text-muted"})," Trash"]}),m.jsx("p",{className:"text-sm text-muted mt-1",children:"Deleted items land here and are purged automatically after 30 days."})]}),n&&n.length>0&&m.jsxs("button",{className:"btn btn-ghost h-7! px-2.5! text-xs gap-1 shrink-0 hover:text-red-600!",onClick:i,children:[m.jsx(Sc,{size:12})," Empty trash"]})]}),n&&n.length===0?m.jsx("div",{className:"border border-dashed border-line rounded-lg p-8 text-center text-sm text-muted",children:"Trash is empty."}):m.jsx("div",{className:"bg-surface border border-line rounded-md divide-y divide-line/60",children:n==null?void 0:n.map(s=>{const l=e==null?void 0:e.find(o=>o.id===s.projectId);return m.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 row-hover group",children:[m.jsx(xp,{kind:s.kind}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:`text-sm truncate ${jr(s)?"text-muted italic":"text-ink"}`,children:ln(s)}),m.jsxs("div",{className:"text-xxs text-muted mt-0.5",children:[l?l.key:"—"," · deleted"," ",s.deletedAt?BG(s.deletedAt):"—"," ·"," ",m.jsx("span",{className:"opacity-70",children:s.actorKind})]})]}),m.jsxs("div",{className:"flex items-center gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[m.jsxs("button",{className:"btn btn-ghost h-6! px-2! text-xxs gap-1",title:"Restore",onClick:()=>t.mutate(s.id),children:[m.jsx(_6,{size:11})," Restore"]}),m.jsxs("button",{className:"btn btn-ghost h-6! px-2! text-xxs gap-1 hover:text-red-600!",title:"Delete forever",onClick:()=>{window.confirm(`Permanently delete "${ln(s)}"? This cannot be undone.`)&&r.mutate(s.id)},children:[m.jsx(wc,{size:11})," Delete forever"]})]})]},s.id)})})]})})}function BG(n){const e=Date.now()-new Date(n).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:e<7*864e5?`${Math.floor(e/864e5)}d ago`:new Date(n).toLocaleDateString()}function WG(){return m.jsx(GF,{children:m.jsxs(t5,{children:[m.jsxs(zN,{children:[m.jsx(ir,{path:"/login",element:m.jsx(sG,{})}),m.jsxs(ir,{element:m.jsx(vY,{}),children:[m.jsx(ir,{path:"/",element:m.jsx(IG,{})}),m.jsx(ir,{path:"/today",element:m.jsx(zG,{})}),m.jsx(ir,{path:"/inbox",element:m.jsx(nG,{})}),m.jsx(ir,{path:"/dashboard",element:m.jsx(UU,{})}),m.jsx(ir,{path:"/trash",element:m.jsx(XG,{})}),m.jsx(ir,{path:"/settings",element:m.jsx(pG,{})}),m.jsx(ir,{path:"/p/:key",element:m.jsx(cG,{})}),m.jsx(ir,{path:"/p/:key/e/:id",element:m.jsx(eG,{})}),m.jsx(ir,{path:"/p/:key/agents-md",element:m.jsx(TY,{})}),m.jsx(ir,{path:"/search",element:m.jsx(fG,{})})]})]}),m.jsx(QY,{})]})})}const qG=new QR({defaultOptions:{queries:{staleTime:1e4,gcTime:5*6e4,retry:1,refetchOnWindowFocus:!0}}});VR.createRoot(document.getElementById("root")).render(m.jsx(EC.StrictMode,{children:m.jsx(TR,{client:qG,children:m.jsx(UN,{children:m.jsx(WG,{})})})}));