@promptowl/contextnest-community 1.25.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/API.md +68 -8
  2. package/CONFIGURATION.md +572 -116
  3. package/README.md +3 -2
  4. package/dist/{chunk-32SZCH36.js → chunk-2QOJE7A5.js} +4 -4
  5. package/dist/{chunk-2KHM5C7V.js → chunk-DGPTJXIV.js} +13 -15
  6. package/dist/chunk-I5EDEZBQ.js +523 -0
  7. package/dist/{chunk-TI7HMP64.js → chunk-IEAWRHMV.js} +2 -2
  8. package/dist/{chunk-DTLMBF4W.js → chunk-M6PGYMBD.js} +15 -8
  9. package/dist/{chunk-F66VCBLA.js → chunk-PICUHQEM.js} +51 -2
  10. package/dist/{chunk-KPGNZLZL.js → chunk-RPGFHESR.js} +1 -1
  11. package/dist/{chunk-7FROMOZM.js → chunk-SWA5M5XX.js} +68 -544
  12. package/dist/{chunk-JDAOA5KP.js → chunk-TRSGPS27.js} +39 -14
  13. package/dist/{engine-TER6FDBP.js → engine-QNMFDIBV.js} +3 -2
  14. package/dist/{external-edit-service-CAGENHDJ.js → external-edit-service-4MEGPT4D.js} +4 -3
  15. package/dist/{grants-service-2OTFS7EH.js → grants-service-24GLUBY4.js} +2 -2
  16. package/dist/index.js +911 -263
  17. package/dist/invited-user-AM6A3WGO.js +12 -0
  18. package/dist/{migrations.postgres-23VJJJJX.js → migrations.postgres-HGSQ7IA5.js} +4 -0
  19. package/dist/{review-service-4G2XUFS6.js → review-service-2EWN7WWO.js} +7 -6
  20. package/dist/{stewardship-service-S22V2JKG.js → stewardship-service-TDZUC2Q6.js} +4 -3
  21. package/dist/{version-service-X4FAG2OZ.js → version-service-C3JTZLJH.js} +4 -3
  22. package/dist/web3/assets/ActivityTracePage-DzwWIjjx.js +1 -0
  23. package/dist/web3/assets/{AgentDocsPage-Dkhgb1hk.js → AgentDocsPage-ixP2UdAE.js} +1 -1
  24. package/dist/web3/assets/CollaboratorManager-C9VAXZ0h.js +1 -0
  25. package/dist/web3/assets/CollaboratorsTab-tq4ZTexH.js +1 -0
  26. package/dist/web3/assets/DocumentEditor-C2CP2fiE.js +36 -0
  27. package/dist/web3/assets/DocumentsTab-Mh7KxUoB.js +6 -0
  28. package/dist/web3/assets/ExternalEditsTab-B_CWKXZ_.js +1 -0
  29. package/dist/web3/assets/{MarkdownEditor-Dfk5uIE5.js → MarkdownEditor-CKh4WSn-.js} +136 -131
  30. package/dist/web3/assets/MarkdownEditor-ndtIx5x0.css +1 -0
  31. package/dist/web3/assets/NestPageHeader-Cizo8nUi.js +1 -0
  32. package/dist/web3/assets/NestView-EW-sraEb.js +73 -0
  33. package/dist/web3/assets/OverviewTab-CjidsMX_.js +6 -0
  34. package/dist/web3/assets/PersonCombobox-BKI7dff4.js +1 -0
  35. package/dist/web3/assets/{ReviewActions-BXDTDPp1.js → ReviewActions-CS8JXgXF.js} +2 -2
  36. package/dist/web3/assets/ReviewTab-CwVrXzw5.js +1 -0
  37. package/dist/web3/assets/StewardsTab-C-iP6gnh.js +1 -0
  38. package/dist/web3/assets/SubmitForReviewModal-Biq3m79i.js +1 -0
  39. package/dist/web3/assets/{alert-dialog-4SiLKlz8.js → alert-dialog-BvF3NFr7.js} +2 -2
  40. package/dist/web3/assets/{arrow-left-BAgIocLn.js → arrow-left-CWIsv-sG.js} +1 -1
  41. package/dist/web3/assets/backlinks-Cqcn7n1J.js +19 -0
  42. package/dist/web3/assets/boxes-ClbgQqG2.js +6 -0
  43. package/dist/web3/assets/{chevron-left-XR4ReJ9Z.js → chevron-left-CK_ZPFm9.js} +1 -1
  44. package/dist/web3/assets/{circle-check-CSkZUEFK.js → circle-check-Bw_aTXiH.js} +1 -1
  45. package/dist/web3/assets/{circle-x-in2o3aHU.js → circle-x-DkIG68H7.js} +1 -1
  46. package/dist/web3/assets/{code-xml-pPQgdctI.js → code-xml-BlR7EN6l.js} +1 -1
  47. package/dist/web3/assets/{corner-down-right-CuxZWscX.js → corner-down-right-DSVxK3tf.js} +1 -1
  48. package/dist/web3/assets/count-skeleton-DToLM74B.js +1 -0
  49. package/dist/web3/assets/{earth-CXOcThqn.js → earth-BXhVPvCR.js} +1 -1
  50. package/dist/web3/assets/{file-exclamation-point-CSphs1VD.js → file-exclamation-point-BevGZgtj.js} +1 -1
  51. package/dist/web3/assets/{folder-input-BAwK9tFL.js → folder-input-m8UBV4fA.js} +1 -1
  52. package/dist/web3/assets/{index-A0_ymcqL.js → index-BOVYgMvj.js} +1 -1
  53. package/dist/web3/assets/index-DVnaYqj9.css +1 -0
  54. package/dist/web3/assets/index-WYDmEOfO.js +404 -0
  55. package/dist/web3/assets/page-B6pkc9cd.js +2 -0
  56. package/dist/web3/assets/page-BJrFCKXB.js +1 -0
  57. package/dist/web3/assets/page-Bgy9Ng9p.js +1 -0
  58. package/dist/web3/assets/page-C2zoxumw.js +1 -0
  59. package/dist/web3/assets/page-CJWO06dN.js +1 -0
  60. package/dist/web3/assets/page-CptuAPJc.js +6 -0
  61. package/dist/web3/assets/page-DPY01SOj.js +1 -0
  62. package/dist/web3/assets/page-Dea2SblF.js +9 -0
  63. package/dist/web3/assets/page-Deq6IKiN.js +6 -0
  64. package/dist/web3/assets/page-Dfjg8p7Z.js +1 -0
  65. package/dist/web3/assets/{page-xzYqkBUP.js → page-Dh57L0RG.js} +5 -5
  66. package/dist/web3/assets/page-Dwbp4Seu.js +6 -0
  67. package/dist/web3/assets/{page-CUjuSs5Q.js → page-DzKwP5Ds.js} +3 -3
  68. package/dist/web3/assets/page-YxjrE5b5.js +45 -0
  69. package/dist/web3/assets/{page-title-BkqlUA0j.js → page-title-DVq4qvMR.js} +1 -1
  70. package/dist/web3/assets/{play-B8xE9j5f.js → play-CXhS6Pgq.js} +1 -1
  71. package/dist/web3/assets/{send-CvAgOUPG.js → send-DdfwnIrj.js} +1 -1
  72. package/dist/web3/assets/{settings-EY4A_DYv.js → settings-DKX0Q4gO.js} +1 -1
  73. package/dist/web3/assets/{share-2-vGmZUl90.js → share-2-CxmXRt58.js} +1 -1
  74. package/dist/web3/assets/{tag-Br_y1f00.js → tag-DeYC_mRv.js} +1 -1
  75. package/dist/web3/assets/{trash-2-B4hRXo-p.js → trash-2-B0HyPTnI.js} +1 -1
  76. package/dist/web3/assets/{user-plus-4CTYEkd3.js → user-plus-Ckm_Isyc.js} +1 -1
  77. package/dist/web3/assets/{x-qxt1WrUi.js → x-mNtADYHc.js} +1 -1
  78. package/dist/web3/assets/{zap-BcsKR0ef.js → zap-D2ifcnYb.js} +1 -1
  79. package/dist/web3/index.html +2 -2
  80. package/package.json +3 -2
  81. package/dist/client-D44ZHDTJ.js +0 -11
  82. package/dist/keys-CTOGAG3W.js +0 -20
  83. package/dist/web3/assets/ActivityTracePage-D2iIbEph.js +0 -1
  84. package/dist/web3/assets/CollaboratorManager-Bo81D--Q.js +0 -1
  85. package/dist/web3/assets/CollaboratorsTab-DRCitQuX.js +0 -1
  86. package/dist/web3/assets/DocumentEditor-DV2WHYbj.js +0 -36
  87. package/dist/web3/assets/DocumentsTab-BUxBCN8o.js +0 -6
  88. package/dist/web3/assets/ExternalEditsTab-kIBimZyE.js +0 -1
  89. package/dist/web3/assets/MarkdownEditor-CsVusP2d.css +0 -1
  90. package/dist/web3/assets/NestPageHeader-yOK-OIYZ.js +0 -1
  91. package/dist/web3/assets/NestView-DwIagxwJ.js +0 -68
  92. package/dist/web3/assets/OverviewTab-DFOFMVyE.js +0 -1
  93. package/dist/web3/assets/PersonCombobox-D350WlrJ.js +0 -1
  94. package/dist/web3/assets/ReasonDialog-CN3ECAnQ.js +0 -1
  95. package/dist/web3/assets/ReviewTab-CZewAYiz.js +0 -1
  96. package/dist/web3/assets/StewardsTab-AagNWcWS.js +0 -1
  97. package/dist/web3/assets/SubmitForReviewModal-BOZJxwRN.js +0 -1
  98. package/dist/web3/assets/backlinks-Cb8Uf8mw.js +0 -24
  99. package/dist/web3/assets/card-UDyMRcps.js +0 -1
  100. package/dist/web3/assets/count-skeleton-DBWCDhRy.js +0 -1
  101. package/dist/web3/assets/dates-BCxbm4_q.js +0 -1
  102. package/dist/web3/assets/index-B5hLclEq.js +0 -389
  103. package/dist/web3/assets/index-DrUAtoQM.css +0 -1
  104. package/dist/web3/assets/page-BHD4beun.js +0 -1
  105. package/dist/web3/assets/page-BSYUXYmO.js +0 -11
  106. package/dist/web3/assets/page-BYc2DIux.js +0 -45
  107. package/dist/web3/assets/page-BfibLg8e.js +0 -1
  108. package/dist/web3/assets/page-CGe8MtUu.js +0 -9
  109. package/dist/web3/assets/page-CIgPJmG6.js +0 -2
  110. package/dist/web3/assets/page-Ck31nx9b.js +0 -1
  111. package/dist/web3/assets/page-Cpdj_11Y.js +0 -1
  112. package/dist/web3/assets/page-D0sN3GO6.js +0 -1
  113. package/dist/web3/assets/page-DEpH91X2.js +0 -1
  114. package/dist/web3/assets/page-l8-B7CGt.js +0 -1
  115. package/dist/web3/assets/page-mnSHmk6A.js +0 -6
  116. package/dist/web3/assets/refresh-cw-CsCtmWwX.js +0 -6
  117. package/dist/web3/assets/scroll-area-CbcH6yrZ.js +0 -1
  118. package/dist/web3/assets/scroll-area-dRWncRqa.css +0 -1
  119. package/dist/web3/assets/select-DrL0mpRN.js +0 -6
  120. package/dist/web3/assets/triangle-alert-CsYGyfGZ.js +0 -6
@@ -1,24 +0,0 @@
1
- import{c as de,j as e,s as le,r as m,bX as ye,L as A,e as X,B as v,E as Ve,bx as Oe,D as K,x as Y,y as J,z as Z,G as ce,H as we,u as We,i as ke,A as G,K as oe,a as U,T as qe,P as Ge,Q as Ce,R as Se,a9 as Ue,c8 as Qe,J as Q,I as ve,C as Xe,ao as Le,dR as Ke,V as Ye,dS as Je,f as Ze,dT as et,dU as tt,bA as st,F as nt,dV as at,dW as rt,dX as it}from"./index-B5hLclEq.js";import{C as Re,a as De,c as Ee,d as Ae}from"./card-UDyMRcps.js";import{S as Te,T as lt}from"./scroll-area-CbcH6yrZ.js";import{D as ot,v as ct}from"./MarkdownEditor-Dfk5uIE5.js";import{p as dt}from"./dates-BCxbm4_q.js";import{f as ht}from"./client-attribution-BraarYaP.js";import{T as Ie}from"./trash-2-B4hRXo-p.js";import{A as xt}from"./arrow-left-BAgIocLn.js";import{C as me}from"./circle-check-CSkZUEFK.js";import{C as _e}from"./circle-x-in2o3aHU.js";import{A as ut}from"./folder-input-BAwK9tFL.js";import{S as mt}from"./share-2-vGmZUl90.js";/**
2
- * @license lucide-react v0.577.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ft=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],pt=de("ban",ft);/**
7
- * @license lucide-react v0.577.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const gt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],$e=de("history",gt);/**
12
- * @license lucide-react v0.577.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const jt=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],wt=de("mail",jt);/**
17
- * @license lucide-react v0.577.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const vt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],fe=de("rotate-ccw",vt);function bt(s){const t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(s);return t?{oldStart:Number(t[1]),newStart:Number(t[2])}:null}function Nt(s){const t=s.split(/\r?\n/),n=[];let a=0,l=0,d=!1;for(const o of t){if(!d&&(o.startsWith("+++")||o.startsWith("---")||o.startsWith("diff ")||o.startsWith("index ")||o.startsWith("Index: ")||/^=+$/.test(o)))continue;const h=bt(o);if(h){a=h.oldStart,l=h.newStart,d=!0,n.push({kind:"hunk",oldNo:null,newNo:null,text:o});continue}if(o.startsWith("+"))n.push({kind:"add",oldNo:null,newNo:l++,text:o.slice(1)});else if(o.startsWith("-"))n.push({kind:"del",oldNo:a++,newNo:null,text:o.slice(1)});else{const x=o.startsWith(" ")?o.slice(1):o;n.push({kind:"ctx",oldNo:a++,newNo:l++,text:x})}}return n}const Be={add:"bg-green-100 dark:bg-green-950/50",del:"bg-red-100 dark:bg-red-950/50",ctx:"",hunk:"bg-blue-50 dark:bg-blue-950/40 text-blue-700 dark:text-blue-300"},yt={add:"+",del:"-",ctx:" ",hunk:""},Me="select-none w-10 shrink-0 px-1 text-right tabular-nums text-[10px] text-muted-foreground/70 border-r border-border/60";function Fe({patch:s,className:t}){const n=Nt(s);return e.jsx("div",{className:le("rounded-md border bg-background font-mono text-xs leading-relaxed overflow-y-auto max-h-96",t),"data-testid":"diff-viewer",children:n.map((a,l)=>a.kind==="hunk"?e.jsx("div",{className:le("px-3 whitespace-pre-wrap break-words",Be[a.kind]),children:a.text||" "},l):e.jsxs("div",{className:le("flex items-stretch",Be[a.kind]),children:[e.jsx("span",{className:Me,children:a.oldNo??""}),e.jsx("span",{className:Me,children:a.newNo??""}),e.jsx("span",{className:le("select-none w-4 shrink-0 text-center",a.kind==="add"&&"text-green-700 dark:text-green-300",a.kind==="del"&&"text-red-700 dark:text-red-300"),children:yt[a.kind]}),e.jsx("code",{className:"block flex-1 min-w-0 pr-3 whitespace-pre-wrap break-words",children:a.text||" "})]},l))})}function kt(s,t){const n=(s??"").split(`
22
- `),a=(t??"").split(`
23
- `),l=n.length,d=a.length,o=Array.from({length:l+1},()=>new Array(d+1).fill(0));for(let f=l-1;f>=0;f--)for(let c=d-1;c>=0;c--)o[f][c]=n[f]===a[c]?o[f+1][c+1]+1:Math.max(o[f+1][c],o[f][c+1]);const h=[];let x=0,u=0;for(;x<l&&u<d;)n[x]===a[u]?(h.push(" "+n[x]),x++,u++):o[x+1][u]>=o[x][u+1]?(h.push("- "+n[x]),x++):(h.push("+ "+a[u]),u++);for(;x<l;)h.push("- "+n[x++]);for(;u<d;)h.push("+ "+a[u++]);return h.join(`
24
- `)}function Ct(s,t){return s||t}const Pe={status:"Never published — no approved version exists yet.",guidance:"Saving keeps this document a draft; Submit for review to publish it."};function pe(s){const t=dt(s);return t?t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):""}function St(s){return s.length>20?`${s.slice(0,8)}…${s.slice(-7)}`:s}function Lt(s){var l;if(!s)return{};const t=s.match(/^Restored from version\s+(\d+)/i);if(t)return{restoredFrom:Number(t[1])};const n=s.match(/^External edit (approved|rejected)(?::\s*([\s\S]*))?$/i);if(n){const d=n[1].toLowerCase()==="rejected";return{action:{label:d?"External Edit Rejected":"External Edit Approved",rejected:d},note:((l=n[2])==null?void 0:l.trim())||void 0}}const a=s.match(/^(Approved|Rejected)\s+review\s+request\s+(\S+)/i);if(a){const d=a[1].toLowerCase()==="rejected";return{action:{label:d?"Review Rejected":"Review Approved",rejected:d},requestId:a[2]}}return{note:s}}function Rt({versions:s,currentVersion:t,approvedVersion:n,externalEditVerdicts:a,loading:l=!1,onRestore:d,onDiscard:o,previewAs:h="markdown",onView:x,onLoadContent:u,className:f}){var ae;const[c,w]=m.useState(null),[k,S]=m.useState(null),[b,R]=m.useState(!1),[V,D]=m.useState(!1),[T,j]=m.useState(!1),[p,N]=m.useState("changes"),[I,ee]=m.useState({}),M=ye.useRef(new Set),_=ye.useCallback(r=>{u&&(r in I||M.current.has(r)||(M.current.add(r),u(r).then(L=>ee(y=>({...y,[r]:L}))).catch(()=>ee(L=>({...L,[r]:null}))).finally(()=>M.current.delete(r))))},[u,I]),te=r=>Ct(r.content,I[r.version]),z=!!u||!!(c!=null&&c.content),se=r=>{w(r),r.diff?N("changes"):(N("content"),_(r.version))},$=r=>{N(r),c&&(r==="content"&&_(c.version),r==="vs-current"&&(_(c.version),_(t)))},he=async()=>{if(!(!k||!d)){R(!0);try{await d(k),S(null)}finally{R(!1)}}},xe=async()=>{if(o){j(!0);try{await o(),D(!1)}finally{j(!1)}}};if(l)return e.jsxs(Re,{className:f,children:[e.jsx(De,{className:"pb-3",children:e.jsxs(Ee,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx($e,{className:"h-4 w-4"}),"Version History"]})}),e.jsx(Ae,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(A,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]});const F=(a??[]).filter(r=>r.status==="rejected").reverse(),C=(ae=s.find(r=>r.version===t))==null?void 0:ae.status,O=s.find(r=>r.version===t),B=O?te(O):void 0,E=C==="pending_review",ne=!!o&&!E&&n!=null&&t!==n,W=C==="approved"||C==="published"?"bg-green-100 text-green-800 border-green-200":C==="rejected"?"bg-red-100 text-red-800 border-red-200":C==="pending_review"?"bg-amber-100 text-amber-800 border-amber-200":"bg-muted text-muted-foreground";return e.jsxs(Re,{className:f,children:[e.jsxs(De,{className:"pb-3",children:[e.jsxs(Ee,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx($e,{className:"h-4 w-4"}),"Version History",C&&e.jsx(X,{variant:"outline",className:`text-[10px] capitalize ${W}`,children:C.replace("_"," ")}),e.jsxs(X,{variant:"secondary",className:"text-[10px] ml-auto",children:["v",t]}),ne&&e.jsxs(v,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive",title:`Throw away the unreviewed edits and go back to v${n}`,onClick:()=>D(!0),"data-testid":"version-history-discard",children:[e.jsx(Ie,{className:"h-3.5 w-3.5 mr-1"}),"Discard draft"]})]}),C==="draft"&&n==null&&e.jsxs("p",{className:"text-xs text-muted-foreground pt-1",children:[Pe.status,e.jsx("br",{}),Pe.guidance]})]}),e.jsx(Ae,{children:c?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(v,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>{w(null),N("changes")},children:[e.jsx(xt,{className:"h-4 w-4 mr-1"})," Back"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[x&&c.version!==t&&e.jsxs(v,{variant:"outline",size:"sm",className:"h-7",title:"Render this version in the viewer",onClick:()=>x(c.version),children:[e.jsx(Ve,{className:"h-4 w-4 mr-1"})," View rendered"]}),c.diff&&e.jsx(v,{variant:p==="changes"?"secondary":"outline",size:"sm",className:"h-7",onClick:()=>$("changes"),children:"Changes"}),z&&e.jsx(v,{variant:p==="content"?"secondary":"outline",size:"sm",className:"h-7",onClick:()=>$("content"),children:"Full content"}),z&&c.version!==t&&e.jsx(v,{variant:p==="vs-current"?"secondary":"outline",size:"sm",className:"h-7",onClick:()=>$("vs-current"),children:"vs current"}),d&&c.version!==t&&e.jsxs(v,{size:"sm",className:"h-7",disabled:E,title:E?"Locked while awaiting steward review — resolve the review first":void 0,onClick:()=>{S(c.version),w(null)},children:[e.jsx(fe,{className:"h-4 w-4 mr-1"}),E?"Locked — review pending":"Restore"]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-semibold flex items-center gap-2",children:["Version ",c.version,c.version===n&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-green-700",children:[e.jsx(me,{className:"h-3 w-3"})," AI-active"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[pe(c.editedAt)," · ",c.editedBy,c.changeNote&&` · ${c.changeNote}`]}),c.resolutionNote&&e.jsxs("div",{className:`mt-1 text-xs break-words border-l-2 pl-2 ${c.resolutionStatus==="rejected"?"border-red-300 text-red-800":"border-green-300 text-green-800"}`,children:[c.resolutionStatus==="rejected"?"Rejected by":"Approved by"," ",c.resolvedBy,": ",c.resolutionNote]})]}),e.jsx(Te,{className:"h-[60vh] max-h-[440px] pr-2",children:(()=>{const r=te(c),L=r===void 0;return p==="changes"&&c.diff?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-xs text-muted-foreground px-1",children:["Changes in v",c.version," (from v",c.version-1,")"]}),e.jsx(Fe,{patch:c.diff,className:"max-h-none"})]}):p==="vs-current"?L||B===void 0?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground p-4",children:[e.jsx(A,{className:"h-4 w-4 animate-spin"})," Loading…"]}):r===null||B===null?e.jsx("div",{className:"text-sm text-muted-foreground p-4",children:"(no content)"}):e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-xs text-muted-foreground px-1",children:["Diff: v",c.version," → current (v",t,")"]}),e.jsx(Fe,{patch:kt(r,B),className:"max-h-none"})]}):L?z?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground p-4",children:[e.jsx(A,{className:"h-4 w-4 animate-spin"})," Loading…"]}):e.jsx("div",{className:"text-sm text-muted-foreground p-4",children:"(no content)"}):r&&h==="source"?e.jsx("pre",{className:"whitespace-pre-wrap break-words bg-muted/30 rounded px-4 py-3 text-xs font-mono leading-relaxed",children:r}):r?e.jsx(ot,{content:r,className:"min-h-0 max-h-none overflow-visible bg-muted/30 rounded px-4 py-3"}):e.jsx("div",{className:"text-sm text-muted-foreground p-4",children:"(no content)"})})()})]}):s.length===0&&F.length===0?e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"No version history"}):e.jsxs(Te,{className:"h-[60vh] max-h-[480px] pr-2",children:[!!F.length&&e.jsxs("div",{className:"mb-3 space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground px-1",children:"Rejected external edits"}),F.map(r=>e.jsxs("div",{className:"p-2 rounded border bg-muted/20 space-y-0.5",children:[e.jsxs("div",{className:"text-xs font-medium flex items-center gap-1 text-red-700",children:[e.jsx(_e,{className:"h-3 w-3"}),"External edit rejected"]}),r.note&&e.jsx("div",{className:"text-xs text-foreground/80 break-words",children:r.note}),e.jsxs("div",{className:"text-xs text-muted-foreground break-words",children:["By:"," ",e.jsx("span",{className:"font-medium text-foreground/80",children:r.actor})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:pe(r.at)})]},r.suggestion_id))]}),e.jsx("div",{className:"space-y-1",children:s.map(r=>{const L=r.version===n,y=Lt(r.changeNote);return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>se(r),className:`flex items-center justify-between p-2 rounded hover:bg-muted/50 cursor-pointer group ${L?"bg-green-50 border border-green-200":""}`,children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:["Version ",r.version,y.restoredFrom!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-blue-700",children:[e.jsx(fe,{className:"h-3 w-3"})," Restored from v",y.restoredFrom]}),L&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-green-700",children:[e.jsx(me,{className:"h-3 w-3"})," AI-active"]})]}),y.action&&e.jsxs("div",{className:`text-xs font-medium flex items-center gap-1 ${y.action.rejected?"text-red-700":"text-green-700"}`,children:[y.action.rejected?e.jsx(_e,{className:"h-3 w-3"}):e.jsx(me,{className:"h-3 w-3"}),y.action.label]}),y.note&&e.jsx("div",{className:"text-xs text-foreground/80 break-words",children:y.note}),e.jsxs("div",{className:"text-xs text-muted-foreground break-words",children:["By:"," ",e.jsx("span",{className:"font-medium text-foreground/80",children:r.editedBy})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:pe(r.editedAt)}),r.client&&e.jsxs("div",{className:"text-xs text-muted-foreground break-words",children:["Client:"," ",e.jsx("span",{className:"font-mono text-foreground/70",children:ht(r.client)})]}),r.resolvedBy&&e.jsxs("div",{className:"text-xs text-muted-foreground break-words",children:[r.resolutionStatus==="rejected"?"Rejected by":"Approved by",":"," ",e.jsx("span",{className:"font-medium text-foreground/80",children:r.resolvedBy})]}),r.resolutionNote&&e.jsxs("div",{className:`text-xs break-words border-l-2 pl-2 ${r.resolutionStatus==="rejected"?"border-red-300 text-red-800":"border-green-300 text-green-800"}`,children:[r.resolutionStatus==="rejected"?"Reason":"Reviewer note",": ",r.resolutionNote]}),y.requestId&&e.jsxs("div",{className:"text-xs text-muted-foreground font-mono",children:["Review Request: ",St(y.requestId)]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[d&&r.version!==t&&e.jsx(v,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",disabled:E,title:E?"Locked while awaiting steward review — resolve the review first":"Restore this version",onClick:re=>{re.stopPropagation(),S(r.version)},children:e.jsx(fe,{className:"h-3.5 w-3.5"})}),e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"})]})]},r.version)})})]})}),e.jsx(K,{open:!!k,onOpenChange:()=>S(null),children:e.jsxs(Y,{children:[e.jsxs(J,{children:[e.jsxs(Z,{children:["Restore Version ",k,"?"]}),e.jsxs(ce,{children:["This will create a new version with the content from version ",k,". Your current content will be saved in the version history."]})]}),e.jsxs(we,{children:[e.jsx(v,{variant:"outline",onClick:()=>S(null),disabled:b,children:"Cancel"}),e.jsx(v,{onClick:he,disabled:b,children:b?"Restoring...":"Restore"})]})]})}),e.jsx(K,{open:V,onOpenChange:()=>D(!1),children:e.jsxs(Y,{children:[e.jsxs(J,{children:[e.jsx(Z,{children:"Discard the draft?"}),e.jsxs(ce,{children:["The document goes back to version ",n," — the last approved one. Every edit made since is thrown away and can't be recovered. Unlike Restore, this adds no version to the history."]})]}),e.jsxs(we,{children:[e.jsx(v,{variant:"outline",onClick:()=>D(!1),disabled:T,children:"Cancel"}),e.jsx(v,{variant:"destructive",onClick:xe,disabled:T,children:T?"Discarding...":"Discard draft"})]})]})})]})}function Ut({open:s,onClose:t,title:n,versionData:a,onRestore:l,onDiscard:d,previewAs:o,onView:h,onLoadContent:x}){return e.jsx(K,{open:s,onOpenChange:u=>!u&&t(),children:e.jsxs(Y,{className:"sm:max-w-[860px] max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(J,{children:e.jsx(Z,{children:n})}),a?e.jsx(Rt,{className:"flex-1 min-h-0 overflow-hidden",versions:a.versions,currentVersion:a.currentVersion,approvedVersion:a.approvedVersion,externalEditVerdicts:a.externalEditVerdicts,onRestore:l,onDiscard:d,previewAs:o,onView:h,onLoadContent:x}):e.jsxs("div",{className:"flex items-center justify-center py-12 text-sm text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4 mr-2 animate-spin"}),"Loading versions…"]})]})})}function He(s){const t=(s.split("@")[0]||"").trim();if(!t)return"?";const n=t.split(/[._+-]+/).filter(Boolean);return(n.length>=2?n[0][0]+n[1][0]:t.slice(0,2)).toUpperCase()}const Dt={sm:"h-4 w-4 text-[8px]",md:"h-5 w-5 text-[9px]"},q=["bg-teal-500/15 text-teal-700 dark:text-teal-300","bg-amber-500/15 text-amber-700 dark:text-amber-300","bg-violet-500/15 text-violet-700 dark:text-violet-300","bg-rose-500/15 text-rose-700 dark:text-rose-300","bg-sky-500/15 text-sky-700 dark:text-sky-300","bg-emerald-500/15 text-emerald-700 dark:text-emerald-300","bg-orange-500/15 text-orange-700 dark:text-orange-300","bg-fuchsia-500/15 text-fuchsia-700 dark:text-fuchsia-300"];function Et(s){let t=2166136261;for(let n=0;n<s.length;n++)t^=s.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,(t>>>0)%q.length}function At(s){const t=new Set;return s.map(n=>{const a=Et(n);for(let l=0;l<q.length;l++){const d=(a+l)%q.length;if(!t.has(d))return t.add(d),q[d]}return q[a]})}function ge({label:s,title:t,tint:n,size:a}){return e.jsx("span",{title:t,className:`flex ${Dt[a]} shrink-0 items-center justify-center rounded-full border border-background font-medium leading-none ${n??"bg-muted text-muted-foreground"}`,children:s})}function Qt({author:s,collaborators:t=[],max:n=3,size:a="sm"}){if(!s&&t.length===0)return null;const l=t.slice(0,n),d=t.length-l.length,o=At(l);return e.jsxs("span",{className:"inline-flex shrink-0 items-center -space-x-1",children:[s&&e.jsx(ge,{label:He(s),title:`Created by ${s}`,tint:"bg-primary/15 text-primary",size:a}),l.map((h,x)=>e.jsx(ge,{label:He(h),title:h,tint:o[x],size:a},h)),d>0&&e.jsx(ge,{label:`+${d}`,title:t.slice(n).join(", "),size:a})]})}function Tt(s){return s===null?{blocked:!1,behindDraft:!1}:s.approved===null?{blocked:!0,behindDraft:!1}:{blocked:!1,behindDraft:s.current>s.approved}}const _t=[{value:"public",label:"Public",hint:"Anyone with the link",icon:Ue},{value:"email",label:"Email",hint:"One-time link by email",icon:wt},{value:"code",label:"Passcode",hint:"One shared code",icon:Qe},{value:"invite",label:"Invite only",hint:"Named people only",icon:ct}];function Xt({nestId:s,nodeId:t,nodeTitle:n,onClose:a}){const[l,d]=m.useState("public"),[o,h]=m.useState(!1),[x,u]=m.useState(!1),[f,c]=m.useState(!1),[w,k]=m.useState(""),[S,b]=m.useState(""),[R,V]=m.useState(""),[D,T]=m.useState(!1),[j,p]=m.useState(null),[N,I]=m.useState(null),[ee,M]=m.useState(!1),[_,te]=m.useState([]),[z,se]=m.useState(!0),[$,he]=m.useState({}),[xe,F]=m.useState(null),[C,O]=m.useState(!0),[B,E]=m.useState(null),ne=We();async function W(){se(!0);try{const i=await Ke(s);te(i.publishes.filter(g=>g.node_id===t))}catch(i){p((i==null?void 0:i.message)||"Could not load existing links")}finally{se(!1)}}m.useEffect(()=>{W(),ne.fetchQuery(ke.health()).then(i=>O(i.email_configured!==!1)).catch(()=>O(!0)),ne.fetchQuery(ke.nodeVersions(s,t)).then(i=>E({approved:i.approvedVersion??null,current:i.currentVersion})).catch(()=>E(null))},[s,t]),m.useEffect(()=>{!C&&(l==="email"||l==="invite")&&d("public")},[C,l]);async function ae(){if(p(null),l==="code"&&!w.trim()){p("A passcode link needs a passcode.");return}const i=S.split(/[\n,]/).map(g=>g.trim()).filter(Boolean);if(l==="invite"&&!i.length){p("An invite-only link needs at least one email address.");return}T(!0);try{const g=await Je(s,{node_id:t,access_mode:l,comments_enabled:o,watermark:x,no_download:f,code:l==="code"?w.trim():null,allowlist:l==="invite"?i:[],expires_at:R?new Date(`${R}T23:59:59`).toISOString():null});I(g.link),k(""),b(""),Ze.success(`"${n}" published — link ready to share`),await W()}catch(g){p((g==null?void 0:g.message)||"Could not publish this document")}finally{T(!1)}}async function r(i){try{await navigator.clipboard.writeText(i),M(!0),setTimeout(()=>M(!1),1800)}catch{p("Could not copy — select the link and copy it manually.")}}async function L(i){p(null);try{await tt(s,i),await W()}catch(g){p((g==null?void 0:g.message)||"Could not revoke this link")}}async function y(i){F(i);try{const g=await et(s,i);he(P=>({...P,[i]:g.views}))}catch(g){p((g==null?void 0:g.message)||"Could not load the view log")}finally{F(null)}}const re=i=>i.link||`${window.location.origin}/p/${i.slug}`,{blocked:ue,behindDraft:ze}=Tt(B);return e.jsx(K,{open:!0,onOpenChange:i=>!i&&a(),children:e.jsxs(Y,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(J,{children:[e.jsxs(Z,{children:["Publish “",n,"”"]}),e.jsx(ce,{children:"Host this document as a full-screen page at its own link, with the access gate you choose."})]}),j&&e.jsxs(G,{variant:"destructive",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx(U,{children:j})]}),ue&&e.jsxs(G,{variant:"destructive",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx(U,{children:"This document has never been approved, so a published link would show nothing to whoever opens it. Get it approved first — then publish."})]}),ze&&e.jsxs(G,{className:"border-amber-300 bg-amber-50 text-amber-900",children:[e.jsx(oe,{className:"h-4 w-4 text-amber-600"}),e.jsxs(U,{className:"text-amber-900",children:["Readers get the approved version (v",B.approved,"), not the current draft (v",B.current,"). Newer edits appear on the link once they are approved."]})]}),e.jsxs(qe,{defaultValue:"new",children:[e.jsxs(Ge,{className:"grid w-full grid-cols-2",children:[e.jsx(Ce,{value:"new",children:"New link"}),e.jsxs(Ce,{value:"links",children:["Links (",_.length,")"]})]}),e.jsxs(Se,{value:"new",className:"space-y-4 pt-3",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2",children:_t.map(i=>{const g=i.icon,P=l===i.value,ie=(i.value==="email"||i.value==="invite")&&!C;return e.jsxs("button",{type:"button",disabled:ie,title:ie?"This server has no email set up, so nobody could open the link.":void 0,onClick:()=>d(i.value),className:`flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors ${ie?"cursor-not-allowed opacity-50":P?"border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(g,{className:"h-4 w-4"}),i.label]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ie?"Needs email set up":i.hint})]},i.value)})}),!C&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email and invite links are unavailable: this server has no mail transport configured, so the one-time link they rely on could never be delivered."}),l==="code"&&e.jsxs("div",{children:[e.jsx(Q,{htmlFor:"publish-code",children:"Passcode"}),e.jsx(ve,{id:"publish-code",value:w,onChange:i=>k(i.target.value),placeholder:"e.g. autumn-summit",className:"mt-1"})]}),l==="invite"&&e.jsxs("div",{children:[e.jsx(Q,{htmlFor:"publish-allowlist",children:"Invite these people"}),e.jsx(lt,{id:"publish-allowlist",value:S,onChange:i=>b(i.target.value),placeholder:"one email per line",className:"mt-1 min-h-20"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Each address gets an email with the link. Only these people can open it."})]}),e.jsxs("div",{children:[e.jsx(Q,{htmlFor:"publish-expiry",children:"Expires (optional)"}),e.jsx(ve,{id:"publish-expiry",type:"date",value:R,onChange:i=>V(i.target.value),className:"mt-1"})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsx(je,{id:"publish-comments",label:"Allow comments",hint:"Readers must give an email; comments go to the steward queue, never onto the page.",checked:o,onChange:h}),e.jsx(je,{id:"publish-watermark",label:"Watermark viewer email",hint:"Only possible on the email and invite gates, which identify the reader.",checked:x,onChange:u}),e.jsx(je,{id:"publish-nodownload",label:"Discourage download and print",hint:"Blocks copy, right-click, drag and printing. Screenshots and developer tools still work — pair it with a watermark if the content matters.",checked:f,onChange:c})]}),N&&e.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground",children:"Your link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 truncate text-sm",children:N}),e.jsx(v,{size:"sm",variant:"outline",onClick:()=>r(N),children:ee?e.jsx(Xe,{className:"h-3.5 w-3.5"}):e.jsx(Le,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs(v,{onClick:ae,disabled:D||ue,title:ue?"This document has no approved version to serve.":void 0,className:"w-full",children:[D&&e.jsx(A,{className:"mr-2 h-4 w-4 animate-spin"}),"Publish"]})]}),e.jsx(Se,{value:"links",className:"space-y-3 pt-3",children:z?e.jsx("div",{className:"flex justify-center py-6",children:e.jsx(A,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):_.length?_.map(i=>{const g=!!i.revoked_at;return e.jsxs("div",{className:"rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{variant:g?"outline":"secondary",children:i.access_mode}),g&&e.jsx(X,{variant:"outline",children:"revoked"}),i.expires_at&&!g&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["until ",new Date(i.expires_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 truncate text-xs",children:re(i)}),e.jsx(v,{size:"sm",variant:"outline",onClick:()=>r(re(i)),title:"Copy link",children:e.jsx(Le,{className:"h-3.5 w-3.5"})}),e.jsx(v,{size:"sm",variant:"outline",onClick:()=>y(i.id),title:"Who viewed",children:xe===i.id?e.jsx(A,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ve,{className:"h-3.5 w-3.5"})}),!g&&e.jsx(v,{size:"sm",variant:"outline",onClick:()=>L(i.id),title:"Revoke",className:"text-destructive",children:e.jsx(pt,{className:"h-3.5 w-3.5"})})]}),$[i.id]&&e.jsx("div",{className:"mt-2 border-t pt-2",children:$[i.id].length?e.jsx("ul",{className:"space-y-1",children:$[i.id].map((P,Ne)=>e.jsxs("li",{className:"flex justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:P.email||"anonymous"}),e.jsx("span",{className:"flex-shrink-0",children:new Date(P.created_at).toLocaleString()})]},Ne))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No views yet."})})]},i.id)}):e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"This document has no links yet."})})]})]})})}function je({id:s,label:t,hint:n,checked:a,onChange:l}){return e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(Q,{htmlFor:s,className:"text-sm",children:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n})]}),e.jsx(Ye,{id:s,checked:a,onCheckedChange:l})]})}function Kt({nestId:s,targetType:t,target:n,label:a,archived:l=!1,onClose:d}){const[o,h]=m.useState([]),[x,u]=m.useState(!0),[f,c]=m.useState(""),[w,k]=m.useState(!1),[S,b]=m.useState(null),R=async()=>{try{const{grants:j}=await at(s);h(j.filter(p=>p.target_type===t&&p.target===n))}catch(j){b((j==null?void 0:j.message)||"Failed to load who this is shared with")}finally{u(!1)}};m.useEffect(()=>{R()},[s,t,n]);const V=async j=>{if(j.preventDefault(),!f.trim())return;const p=o.find(N=>(N.email??"").toLowerCase()===f.trim().toLowerCase());if(p){b(`This ${t} is already shared with ${p.email} (${p.role==="write"?"can edit":"can view"}).`);return}k(!0),b(null);try{await rt(s,{target_type:t,target:n,email:f.trim(),role:"read"}),c(""),await R()}catch(N){b((N==null?void 0:N.message)||"Failed to share")}finally{k(!1)}},D=async j=>{k(!0),b(null);try{await it(s,j.id),await R()}catch(p){b((p==null?void 0:p.message)||"Failed to unshare")}finally{k(!1)}},T=t==="folder"?st:nt;return e.jsx(K,{open:!0,onOpenChange:d,children:e.jsxs(Y,{className:"sm:max-w-[540px]",children:[e.jsxs(J,{className:"min-w-0",children:[e.jsxs(Z,{className:"flex items-center gap-2 min-w-0",children:[e.jsx(T,{className:"h-4 w-4 shrink-0"}),e.jsxs("span",{className:"truncate",children:["Share ",t==="folder"?"folder":"document",": ",a]})]}),e.jsx(ce,{children:t==="folder"?e.jsxs(e.Fragment,{children:["People you add here can ",e.jsx("strong",{children:"view every document in this folder"})," and its subfolders — nothing else in the nest, and no editing. They do not become stewards."]}):e.jsxs(e.Fragment,{children:["People you add here can ",e.jsx("strong",{children:"view this document"})," — nothing else in the nest, and no editing. They do not become stewards."]})}),e.jsx("code",{className:"mt-1 block rounded bg-muted px-2 py-1 text-[11px] text-muted-foreground break-all",children:n})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[l&&e.jsxs(G,{children:[e.jsx(ut,{className:"h-4 w-4"}),e.jsx(U,{children:"This nest is archived, so sharing is read-only. Restore the nest to change who has access."})]}),S&&e.jsxs(G,{variant:"destructive",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx(U,{children:S})]}),!l&&e.jsxs("form",{onSubmit:V,className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(ve,{type:"email",placeholder:"teammate@example.com",value:f,onChange:j=>{c(j.target.value),S&&b(null)},disabled:w,className:"flex-1 min-w-0","data-testid":"share-target-email"}),e.jsx(v,{type:"submit",disabled:w||!f.trim(),className:"shrink-0",children:w?e.jsx(A,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(mt,{className:"h-4 w-4 mr-1"}),"Share"]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If they don't have an account yet, they'll get access when they register with this email."})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2 max-h-[40vh] overflow-y-auto",children:[e.jsxs(Q,{className:"text-sm font-medium",children:["Shared with",o.length>0?` (${o.length})`:""]}),x?e.jsx(A,{className:"h-4 w-4 animate-spin text-muted-foreground"}):o.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Not shared with anyone yet. Everyone with access to the nest can already see it."}):e.jsx("div",{className:"divide-y divide-border",children:o.map(j=>e.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[e.jsx("span",{className:"flex-1 min-w-0 truncate text-sm",children:j.email??j.user_id}),e.jsx(X,{variant:"secondary",className:"text-[11px]",children:j.role==="write"?"Can edit":"Can view"}),!l&&e.jsx(v,{variant:"ghost",size:"sm",disabled:w,onClick:()=>D(j),title:"Remove access","data-testid":`unshare-${j.id}`,children:e.jsx(Ie,{className:"h-3.5 w-3.5"})})]},j.id))})]})]}),e.jsx(we,{children:e.jsx(v,{variant:"outline",onClick:d,children:"Done"})})]})})}const be=/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g;function H(s){const t=s.lastIndexOf("/");return t>=0?s.slice(t+1):s}function $t(s){const t=[];let n;const a=new RegExp(be.source,"g");for(;(n=a.exec(s??""))!==null;){const l=n[1].trim();l&&t.push(l)}return t}function Yt(s,t){const n=t.id.toLowerCase(),a=(t.title??"").toLowerCase(),l=H(t.id).toLowerCase();if(!a)return[];const d=new RegExp(be.source,"g"),o=[];for(const h of s){if(h.id.toLowerCase()===n)continue;let x;d.lastIndex=0;let u=!1;for(;(x=d.exec(h.content??""))!==null;){const f=(x[1]??"").trim().toLowerCase(),c=(x[2]??"").trim().toLowerCase();if((f===n||H(f).toLowerCase()===l||f===a)&&(f===a||c===a)){u=!0;break}}u&&o.push({id:h.id,title:h.title})}return o}function Jt(s,t){const n=new Map,a=new Map,l=new Map;for(const u of t)n.set(u.id.toLowerCase(),u),a.set(H(u.id).toLowerCase(),u),l.set((u.title??"").toLowerCase(),u);const d=new RegExp(be.source,"g"),o=[],h=new Set;let x;for(;(x=d.exec(s??""))!==null;){const u=(x[1]??"").trim(),f=(x[2]??"").trim();if(!f)continue;const c=u.toLowerCase(),w=n.get(c)||a.get(H(u).toLowerCase())||l.get(c);if(w&&f.toLowerCase()!==(w.title??"").toLowerCase()){if(h.has(w.id))continue;h.add(w.id),o.push({id:w.id,currentTitle:w.title,shownAs:f})}}return o}function Zt(s,t){const n=t.id.toLowerCase(),a=(t.title??"").toLowerCase(),l=H(t.id).toLowerCase(),d=h=>{const x=h.toLowerCase();return x===n||a!==""&&x===a||H(h).toLowerCase()===l},o=[];for(const h of s){if(h.id.toLowerCase()===n)continue;$t(h.content??"").some(d)&&o.push({id:h.id,title:h.title})}return o}export{Qt as A,Fe as D,$e as H,Xt as P,fe as R,Kt as S,Ut as V,$t as e,Zt as f,Yt as r,Jt as s,kt as u};
@@ -1 +0,0 @@
1
- import{r,j as d,s as t}from"./index-B5hLclEq.js";const o=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("rounded-lg border bg-card text-card-foreground shadow-sm",a),...e}));o.displayName="Card";const c=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const i=r.forwardRef(({className:a,...e},s)=>d.jsx("h3",{ref:s,className:t("text-2xl font-semibold leading-none tracking-tight",a),...e}));i.displayName="CardTitle";const n=r.forwardRef(({className:a,...e},s)=>d.jsx("p",{ref:s,className:t("text-sm text-muted-foreground",a),...e}));n.displayName="CardDescription";const l=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("p-6 pt-0",a),...e}));l.displayName="CardContent";const m=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex items-center p-6 pt-0",a),...e}));m.displayName="CardFooter";export{o as C,c as a,n as b,i as c,l as d};
@@ -1 +0,0 @@
1
- import{r as n,j as e,D as z,x as Y,y as H,z as P,G as M,J as S,I as _,B as w,L as F,H as q,cK as J,cL as U,ag as $,bC as K,s as V}from"./index-B5hLclEq.js";import{T as E}from"./trash-2-B4hRXo-p.js";import{A as W}from"./folder-input-BAwK9tFL.js";import{T as X}from"./scroll-area-CbcH6yrZ.js";const A=100;function Z(t){const r=t.trim();return r?r.length>A?`Nest names are capped at ${A} characters — this one is ${r.length}.`:/<\/?[a-zA-Z][^>]*>/.test(t)?"Nest names are plain text — remove the HTML tags.":/[a-z0-9]/i.test(t)?null:"The URL slug is built from a-z and 0-9, so the name needs at least one of those":"Name is required"}const L=t=>t.trim().replace(/\s+/g," ");function se({nestId:t,nestName:r,open:l,onOpenChange:d,onDeleted:m,onArchived:u,isImported:x=!1}){const[f,h]=n.useState(""),[g,p]=n.useState(!1),[j,N]=n.useState(!1),[v,i]=n.useState(null),c=g||j;n.useEffect(()=>{l&&(h(""),i(null),p(!1),N(!1))},[l]);const o=async()=>{N(!0),i(null);try{await J(t),u==null||u()}catch(s){console.error("[DeleteNestDialog] archiveNest failed",t,s),i((s==null?void 0:s.message)??"Failed to archive this nest. You may not have permission, or the server may be unreachable."),N(!1)}},b=async()=>{p(!0),i(null);try{await U(t),m()}catch(s){console.error("[DeleteNestDialog] deleteNest failed",t,s),i((s==null?void 0:s.message)??"Failed to delete this nest. You may not have permission, or the server may be unreachable."),p(!1)}};return e.jsx(z,{open:l,onOpenChange:s=>{!s&&c||d(s)},children:e.jsxs(Y,{className:"sm:max-w-[440px]",children:[e.jsxs(H,{children:[e.jsxs(P,{className:"flex items-center gap-2 text-red-700",children:[e.jsx(E,{className:"h-4 w-4"}),"Delete nest"]}),e.jsxs(M,{children:["You're about to permanently delete"," ",e.jsx("strong",{className:"text-foreground",children:r}),". This cannot be undone."]})]}),e.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-xs text-red-900 space-y-1",children:[e.jsx("p",{className:"font-medium",children:"This will remove:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[e.jsx("li",{children:"Stewardship assignments and review-queue entries"}),e.jsx("li",{children:"Collaborator access and linked API keys"}),e.jsx("li",{children:"Version history and governance metadata"}),x?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"All documents and content (the workspace copy)"}),e.jsx("li",{className:"text-foreground",children:"Your original imported folder is not affected — only the copy in this workspace is removed"})]}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"All documents and content"}),e.jsx("li",{children:"The nest folder on disk"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(S,{htmlFor:"delete-nest-confirm",className:"text-xs",children:["Type ",e.jsx("strong",{className:"font-mono",children:r})," to confirm:"]}),e.jsx(_,{id:"delete-nest-confirm",value:f,onChange:s=>h(s.target.value),placeholder:r,disabled:c,autoComplete:"off"})]}),u&&e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3 text-xs space-y-2",children:[e.jsxs("p",{className:"text-muted-foreground",children:[e.jsx("strong",{className:"text-foreground",children:"Just want it out of the way?"})," ","Archiving keeps every document, version and steward exactly as they are. The nest leaves your dashboard, stops answering agents and published links, and becomes read-only until you restore it."]}),e.jsx(w,{variant:"outline",size:"sm",onClick:o,disabled:c,"data-testid":"archive-nest",children:j?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"h-3.5 w-3.5 mr-2 animate-spin"}),"Archiving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-3.5 w-3.5 mr-2"}),"Archive instead"]})})]}),v&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-900",children:v}),e.jsxs(q,{className:"gap-2",children:[e.jsx(w,{variant:"outline",onClick:()=>d(!1),disabled:c,children:"Cancel"}),e.jsx(w,{variant:"destructive",onClick:b,disabled:c||L(f)!==L(r),children:g?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"h-3.5 w-3.5 mr-2 animate-spin"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-3.5 w-3.5 mr-2"}),"Delete nest"]})})]})]})})}function ae({nestId:t,nestName:r,nestDescription:l,open:d,onOpenChange:m,onRenamed:u}){const[x,f]=n.useState(r),[h,g]=n.useState(l??""),[p,j]=n.useState(!1),[N,v]=n.useState(!1),i=n.useRef({name:r,description:l??""}),c=n.useRef(!1),[o,b]=n.useState(!1),[s,y]=n.useState(null);n.useEffect(()=>{d&&!c.current&&(i.current={name:r,description:l??""},f(r),g(l??""),j(!1),v(!1),y(null),b(!1)),c.current=d},[d,r,l]);const k=x.trim(),D=Z(x),T=p&&k!==i.current.name.trim(),C=N&&h.trim()!==i.current.description.trim(),R=T||C,B=async()=>{if(!o){if(D){y(D);return}if(!R){m(!1);return}b(!0),y(null);try{const a={};T&&(a.name=k),C&&(a.description=h.trim()||null);const{nest:G}=await K(t,a);u(G,{nameChanged:T,descChanged:C}),m(!1)}catch(a){console.error("[RenameNestDialog] updateNest failed",t,a),y((a==null?void 0:a.message)??"Failed to rename this nest. You may not have permission, or the server may be unreachable."),b(!1)}}};return e.jsx(z,{open:d,onOpenChange:a=>{!a&&o||m(a)},children:e.jsx(Y,{className:"sm:max-w-[440px]",children:e.jsxs("form",{onSubmit:a=>{a.preventDefault(),B()},className:"space-y-4",children:[e.jsxs(H,{children:[e.jsxs(P,{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4"}),"Rename nest"]}),e.jsx(M,{children:"Renaming updates the nest's name and URL slug. Documents, sharing, and history are unaffected."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"rename-nest-name",className:"text-xs",children:"Name"}),e.jsx(_,{id:"rename-nest-name",value:x,onChange:a=>{f(a.target.value),j(!0),y(null)},placeholder:"Nest name",disabled:o,autoComplete:"off",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(S,{htmlFor:"rename-nest-description",className:"text-xs",children:["Description"," ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(X,{id:"rename-nest-description",value:h,onChange:a=>{g(a.target.value),v(!0)},placeholder:"What lives in this nest?",disabled:o,autoComplete:"off",rows:3})]}),s&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-900",children:s}),e.jsxs(q,{className:"gap-2",children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>m(!1),disabled:o,children:"Cancel"}),e.jsx(w,{type:"submit",disabled:o||!!D||!R,children:o?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"h-3.5 w-3.5 mr-2 animate-spin"}),"Saving..."]}):"Save"})]})]})})})}function te({className:t}){return e.jsx("span",{className:V("inline-block h-6 w-10 rounded bg-muted-foreground/20 animate-pulse align-middle",t),"aria-hidden":!0})}export{te as C,se as D,ae as R,Z as n};
@@ -1 +0,0 @@
1
- function s(t){if(!t)return null;const e=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d+)?$/.test(t)?`${t.replace(" ","T")}Z`:t,n=new Date(e);return isNaN(n.getTime())?null:n}function i(t){var e;return((e=s(t))==null?void 0:e.toLocaleString())??""}function u(t){var a;const e=(a=s(t))==null?void 0:a.getTime();if(e==null)return"";const n=Math.max(0,Math.floor((Date.now()-e)/1e3));if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}export{i as f,s as p,u as r};