@promptowl/contextnest-community 1.23.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +2195 -0
- package/CONFIGURATION.md +8 -2
- package/README.md +62 -10
- package/STEWARDSHIP.md +253 -0
- package/dist/{chunk-2YPY2HGZ.js → chunk-2KHM5C7V.js} +40 -5
- package/dist/{chunk-XYD6V2LH.js → chunk-32SZCH36.js} +28 -33
- package/dist/{chunk-QLXC6542.js → chunk-7FROMOZM.js} +69 -27
- package/dist/{chunk-MLQU4I5J.js → chunk-DTLMBF4W.js} +10 -8
- package/dist/{chunk-QWNXWRWO.js → chunk-JDAOA5KP.js} +67 -1
- package/dist/{chunk-UOMW7TT6.js → chunk-KPGNZLZL.js} +2 -2
- package/dist/{chunk-YVMSM7LS.js → chunk-LHWOJPFE.js} +7 -0
- package/dist/{chunk-5CVZMHHB.js → chunk-TI7HMP64.js} +99 -12
- package/dist/{client-LWDMNKX3.js → client-D44ZHDTJ.js} +1 -1
- package/dist/{engine-QFF2IA3G.js → engine-TER6FDBP.js} +3 -3
- package/dist/{external-edit-service-F7D3VSA2.js → external-edit-service-CAGENHDJ.js} +4 -4
- package/dist/{grants-service-TBGTCO5K.js → grants-service-2OTFS7EH.js} +3 -3
- package/dist/index.js +1120 -331
- package/dist/{migrations.postgres-APCVSYUE.js → migrations.postgres-23VJJJJX.js} +56 -5
- package/dist/{review-service-A7PNLWG5.js → review-service-4G2XUFS6.js} +7 -7
- package/dist/{stewardship-service-32UHIRQ5.js → stewardship-service-S22V2JKG.js} +6 -4
- package/dist/{version-service-RJ6CWZ3O.js → version-service-X4FAG2OZ.js} +4 -4
- package/dist/web3/assets/ActivityTracePage-D2iIbEph.js +1 -0
- package/dist/web3/assets/AgentDocsPage-Dkhgb1hk.js +1 -0
- package/dist/web3/assets/CollaboratorManager-Bo81D--Q.js +1 -0
- package/dist/web3/assets/CollaboratorsTab-DRCitQuX.js +1 -0
- package/dist/web3/assets/DocumentEditor-DV2WHYbj.js +36 -0
- package/dist/web3/assets/DocumentsTab-BUxBCN8o.js +6 -0
- package/dist/web3/assets/ExternalEditsTab-kIBimZyE.js +1 -0
- package/dist/web3/assets/MarkdownEditor-CsVusP2d.css +1 -0
- package/dist/web3/assets/MarkdownEditor-Dfk5uIE5.js +648 -0
- package/dist/web3/assets/NestPageHeader-yOK-OIYZ.js +1 -0
- package/dist/web3/assets/NestView-DwIagxwJ.js +68 -0
- package/dist/web3/assets/OverviewTab-DFOFMVyE.js +1 -0
- package/dist/web3/assets/PersonCombobox-D350WlrJ.js +1 -0
- package/dist/web3/assets/ReasonDialog-CN3ECAnQ.js +1 -0
- package/dist/web3/assets/ReviewActions-BXDTDPp1.js +6 -0
- package/dist/web3/assets/ReviewTab-CZewAYiz.js +1 -0
- package/dist/web3/assets/StewardsTab-AagNWcWS.js +1 -0
- package/dist/web3/assets/SubmitForReviewModal-BOZJxwRN.js +1 -0
- package/dist/web3/assets/alert-dialog-4SiLKlz8.js +7 -0
- package/dist/web3/assets/arrow-left-BAgIocLn.js +6 -0
- package/dist/web3/assets/backlinks-Cb8Uf8mw.js +24 -0
- package/dist/web3/assets/card-UDyMRcps.js +1 -0
- package/dist/web3/assets/chevron-left-XR4ReJ9Z.js +6 -0
- package/dist/web3/assets/circle-check-CSkZUEFK.js +6 -0
- package/dist/web3/assets/circle-x-in2o3aHU.js +6 -0
- package/dist/web3/assets/client-attribution-BraarYaP.js +1 -0
- package/dist/web3/assets/code-xml-pPQgdctI.js +6 -0
- package/dist/web3/assets/corner-down-right-CuxZWscX.js +6 -0
- package/dist/web3/assets/count-skeleton-DBWCDhRy.js +1 -0
- package/dist/web3/assets/dates-BCxbm4_q.js +1 -0
- package/dist/web3/assets/earth-CXOcThqn.js +6 -0
- package/dist/web3/assets/file-exclamation-point-CSphs1VD.js +6 -0
- package/dist/web3/assets/folder-input-BAwK9tFL.js +11 -0
- package/dist/web3/assets/folder-target-CUSWqImF.js +1 -0
- package/dist/web3/assets/index-A0_ymcqL.js +29 -0
- package/dist/web3/assets/index-B5hLclEq.js +389 -0
- package/dist/web3/assets/index-DrUAtoQM.css +1 -0
- package/dist/web3/assets/page-BHD4beun.js +1 -0
- package/dist/web3/assets/page-BSYUXYmO.js +11 -0
- package/dist/web3/assets/page-BYc2DIux.js +45 -0
- package/dist/web3/assets/page-BfibLg8e.js +1 -0
- package/dist/web3/assets/page-CGe8MtUu.js +9 -0
- package/dist/web3/assets/page-CIgPJmG6.js +2 -0
- package/dist/web3/assets/page-CUjuSs5Q.js +24 -0
- package/dist/web3/assets/page-Ck31nx9b.js +1 -0
- package/dist/web3/assets/page-Cpdj_11Y.js +1 -0
- package/dist/web3/assets/page-D0sN3GO6.js +1 -0
- package/dist/web3/assets/page-DEpH91X2.js +1 -0
- package/dist/web3/assets/page-l8-B7CGt.js +1 -0
- package/dist/web3/assets/page-mnSHmk6A.js +6 -0
- package/dist/web3/assets/page-title-BkqlUA0j.js +1 -0
- package/dist/web3/assets/page-xzYqkBUP.js +16 -0
- package/dist/web3/assets/play-B8xE9j5f.js +6 -0
- package/dist/web3/assets/refresh-cw-CsCtmWwX.js +6 -0
- package/dist/web3/assets/scroll-area-CbcH6yrZ.js +1 -0
- package/dist/web3/assets/scroll-area-dRWncRqa.css +1 -0
- package/dist/web3/assets/select-DrL0mpRN.js +6 -0
- package/dist/web3/assets/send-CvAgOUPG.js +6 -0
- package/dist/web3/assets/settings-EY4A_DYv.js +6 -0
- package/dist/web3/assets/share-2-vGmZUl90.js +6 -0
- package/dist/web3/assets/tag-Br_y1f00.js +11 -0
- package/dist/web3/assets/trash-2-B4hRXo-p.js +6 -0
- package/dist/web3/assets/triangle-alert-CsYGyfGZ.js +6 -0
- package/dist/web3/assets/user-plus-4CTYEkd3.js +6 -0
- package/dist/web3/assets/x-qxt1WrUi.js +6 -0
- package/dist/web3/assets/zap-BcsKR0ef.js +16 -0
- package/dist/web3/index.html +2 -2
- package/package.json +5 -3
- package/dist/web3/assets/index-BJ-LRNis.js +0 -1382
- package/dist/web3/assets/index-DPMEt-A_.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s,B as r}from"./index-B5hLclEq.js";import{A as l}from"./arrow-left-BAgIocLn.js";function c({nestName:e,onBack:a,title:i,badges:m,children:t}){return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(r,{variant:"ghost",size:"sm",onClick:a,className:"shrink-0 px-2",title:"Back to nests",children:s.jsx(l,{className:"h-4 w-4"})}),i??s.jsx("h1",{className:"min-w-0 truncate text-xl font-semibold",title:e,children:e}),m]}),t&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 w-full sm:ml-auto sm:w-auto sm:shrink-0 sm:justify-end",children:t})]})}export{c as N};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ExternalEditsTab-kIBimZyE.js","assets/index-B5hLclEq.js","assets/index-DrUAtoQM.css","assets/dates-BCxbm4_q.js","assets/card-UDyMRcps.js","assets/file-exclamation-point-CSphs1VD.js","assets/refresh-cw-CsCtmWwX.js","assets/circle-check-CSkZUEFK.js","assets/MarkdownEditor-Dfk5uIE5.js","assets/zap-BcsKR0ef.js","assets/triangle-alert-CsYGyfGZ.js","assets/scroll-area-CbcH6yrZ.js","assets/select-DrL0mpRN.js","assets/scroll-area-dRWncRqa.css","assets/index-A0_ymcqL.js","assets/arrow-left-BAgIocLn.js","assets/trash-2-B4hRXo-p.js","assets/x-qxt1WrUi.js","assets/MarkdownEditor-CsVusP2d.css","assets/chevron-left-XR4ReJ9Z.js","assets/alert-dialog-4SiLKlz8.js","assets/NestPageHeader-yOK-OIYZ.js","assets/count-skeleton-DBWCDhRy.js","assets/folder-input-BAwK9tFL.js","assets/PersonCombobox-D350WlrJ.js","assets/tag-Br_y1f00.js","assets/user-plus-4CTYEkd3.js","assets/ReviewActions-BXDTDPp1.js","assets/circle-x-in2o3aHU.js","assets/ReasonDialog-CN3ECAnQ.js","assets/settings-EY4A_DYv.js","assets/StewardsTab-AagNWcWS.js","assets/CollaboratorsTab-DRCitQuX.js","assets/CollaboratorManager-Bo81D--Q.js","assets/share-2-vGmZUl90.js","assets/ReviewTab-CZewAYiz.js","assets/corner-down-right-CuxZWscX.js","assets/send-CvAgOUPG.js","assets/OverviewTab-DFOFMVyE.js","assets/DocumentsTab-BUxBCN8o.js","assets/backlinks-Cb8Uf8mw.js","assets/client-attribution-BraarYaP.js","assets/SubmitForReviewModal-BOZJxwRN.js","assets/folder-target-CUSWqImF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as rt,ay as Gt,j as e,a2 as xr,F as st,D as Fe,x as Oe,y as qe,z as $e,bq as ya,G as kt,br as ta,r,B as k,C as gr,ao as vr,at as br,A as Jt,K as Na,a as Zt,J as se,bs as St,V as tt,aX as Ke,I as Sa,H as at,L as be,bt as wr,bu as jr,bv as yr,aE as ka,bw as Nr,bx as sa,by as Sr,bz as kr,aj as Cr,bA as Rr,az as _r,S as ss,i as H,u as as,aa as es,bB as Ar,O as Tr,bC as aa,f as N,_ as Dr,aI as Er,bD as Lr,aD as Pr,U as Fr,a9 as ra,ab as Or,e as Ye,ag as qr,T as $r,P as Mr,Q as Le,ah as zr,ai as Vr,ak as Wr,am as Kt,aP as Br,R as Pe,bE as Hr,E as Qr,bF as Ur,bG as na,as as Gr,bH as Me,bI as ze,ax as Kr,bJ as Yr,ac as Ir,bK as ia,bL as Xr,bM as Jr,au as Zr,av as en,bN as tn,bO as sn,bP as an,bQ as rn}from"./index-B5hLclEq.js";import{W as nn,T as on,v as ln,n as cn,h as dn,P as un,D as mn,S as oa,U as la,O as hn,w as pn,F as ca,q as fn,x as xn,M as gn,s as vn}from"./MarkdownEditor-Dfk5uIE5.js";import{Z as bn,F as wn}from"./zap-BcsKR0ef.js";import{p as jn,r as yn}from"./dates-BCxbm4_q.js";import{T as Nn}from"./triangle-alert-CsYGyfGZ.js";import{X as Ca}from"./x-qxt1WrUi.js";import{C as Sn}from"./chevron-left-XR4ReJ9Z.js";import{A as kn,a as Cn,b as Rn,c as _n,d as An,e as Tn,f as Dn,g as En}from"./alert-dialog-4SiLKlz8.js";import{N as Ln}from"./NestPageHeader-yOK-OIYZ.js";import{C as jt,D as Pn,R as Fn}from"./count-skeleton-DBWCDhRy.js";import{C as Ie,a as Xe,b as Je,c as Ze,d as et}from"./card-UDyMRcps.js";import{T as On}from"./scroll-area-CbcH6yrZ.js";import{S as da,a as ua,b as ma,c as ha,d as yt}from"./select-DrL0mpRN.js";import{P as qn}from"./PersonCombobox-D350WlrJ.js";import{T as $n,L as Mn}from"./tag-Br_y1f00.js";import{R as zn}from"./refresh-cw-CsCtmWwX.js";import{U as Vn}from"./user-plus-4CTYEkd3.js";import{R as Wn}from"./ReviewActions-BXDTDPp1.js";import{R as Yt}from"./ReasonDialog-CN3ECAnQ.js";import{F as Bn,A as Hn}from"./folder-input-BAwK9tFL.js";import{T as pa}from"./trash-2-B4hRXo-p.js";import{C as Qn}from"./circle-check-CSkZUEFK.js";import{S as fa}from"./settings-EY4A_DYv.js";/**
|
|
3
|
+
* @license lucide-react v0.577.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const Un=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Gn=rt("activity",Un);/**
|
|
8
|
+
* @license lucide-react v0.577.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const Kn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Yn=rt("clock",Kn);/**
|
|
13
|
+
* @license lucide-react v0.577.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const In=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Xn=rt("file-code-corner",In);/**
|
|
18
|
+
* @license lucide-react v0.577.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const Jn=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Zn=rt("menu",Jn);/**
|
|
23
|
+
* @license lucide-react v0.577.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const ei=[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]],ti=rt("user-pen",ei);function si(s){return s.normalize("NFKD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}const xa=100;function ai(s){const n=s.split("/").map(p=>p.trim()).filter(Boolean),i=n.map(si).filter(Boolean).join("/"),o=i!==s.trim(),u=p=>({path:i,error:p,rewritten:o});if(n.length===0)return{path:"",error:null,rewritten:!1};if(n.some(p=>p==="."||p===".."))return u(`"." and ".." don't name a folder — use a name.`);if(!i)return u("Folder paths are built from a-z and 0-9, so the name needs at least one of those.");const b=i.split("/").length;if(b>Gt){const p=b-Gt;return u(`Folders may nest at most ${Gt} levels deep — this path is ${b}. Remove ${p} level${p===1?"":"s"}.`)}return i.split("/").some(p=>p.length>xa)?u(`Each folder level must be at most ${xa} characters.`):{path:i,error:null,rewritten:o}}function ri(){let s=!1;return{arm:()=>{s=!0},consume:()=>s?(s=!1,!0):!1}}function ni({type:s,className:n="h-4 w-4"}){const i=s==="agent"?{Icon:xr,cls:"text-violet-600 dark:text-violet-400 bg-violet-500/10",label:"Agent"}:s==="skill"?{Icon:bn,cls:"text-blue-600 dark:text-blue-400 bg-blue-500/10",label:"Skill"}:s==="artifact"?{Icon:Xn,cls:"text-amber-600 dark:text-amber-400 bg-amber-500/10",label:"Artifact"}:s==="tool"?{Icon:nn,cls:"text-teal-600 dark:text-teal-400 bg-teal-500/10",label:"Tool"}:s==="table"?{Icon:on,cls:"text-cyan-600 dark:text-cyan-400 bg-cyan-500/10",label:"Table"}:s==="pdf"?{Icon:wn,cls:"text-rose-600 dark:text-rose-400 bg-rose-500/10",label:"PDF"}:{Icon:st,cls:"text-slate-500 dark:text-slate-400 bg-slate-500/10",label:"Document"};return e.jsx("span",{className:`inline-flex items-center justify-center rounded-md p-1 shrink-0 ${i.cls}`,title:i.label,children:e.jsx(i.Icon,{className:n})})}function so(s){const n=jn(s);if(!n)return"";const i=Date.now()-n.getTime();return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:i<6048e5?`${Math.floor(i/864e5)}d ago`:n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ao(s){switch(s){case"artifact":return{label:"HTML",title:"Hosted HTML artifact",cls:"bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300"};case"agent":return{label:"Agent",title:"Runnable agent node",cls:"bg-violet-100 text-violet-800 dark:bg-violet-950/40 dark:text-violet-300"};case"skill":return{label:"Skill",title:"Runnable skill node",cls:"bg-sky-100 text-sky-800 dark:bg-sky-950/40 dark:text-sky-300"};default:return null}}function ii(s,n){const i=s.split("/"),o=n.split("/");for(let u=0;u<Math.min(i.length,o.length);u++){const b=i[u].localeCompare(o[u]);if(b!==0)return b}return i.length-o.length}function oi(s){const n=s.startsWith("nodes/")?s.slice(6):s,i=n.lastIndexOf("/");return i>0?n.slice(0,i):""}const ro={draft:"Draft",pending_review:"Pending",published:"Published",rejected:"Rejected"},no={"7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days","1y":"Last year"},io={document:"Document",artifact:"Artifact",agent:"Agent",skill:"Skill",tool:"Tool",table:"Table"};function ga({label:s,text:n}){const[i,o]=r.useState(!1);return e.jsxs("div",{className:"rounded-md border bg-muted/40",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5 border-b",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:s}),e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:async()=>{await br(n)&&(o(!0),setTimeout(()=>o(!1),1500))},children:i?e.jsxs(e.Fragment,{children:[e.jsx(gr,{className:"h-3 w-3 mr-1"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(vr,{className:"h-3 w-3 mr-1"})," Copy"]})})]}),e.jsx("pre",{className:"overflow-x-auto px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap break-words",children:n})]})}function li({isOpen:s,onClose:n,nestId:i,nestName:o,openMode:u}){const b=typeof window<"u"?window.location.origin:"https://your-server",p=u?"":` -H "Authorization: Bearer $CNST_KEY" \\
|
|
28
|
+
`,S=`You are helping me build a ContextNest knowledge base — a "nest":
|
|
29
|
+
a graph of small, linked context documents that AI agents read later. You can
|
|
30
|
+
write to it over HTTP. Nest: "${o}".
|
|
31
|
+
|
|
32
|
+
STEP 1 — Interview me first. Do NOT create anything yet. Ask me:
|
|
33
|
+
• What body of knowledge should go in here? (sources, docs, transcripts, URLs, topics)
|
|
34
|
+
• Who/what will use this nest, and for what? (purpose drives how granular to go)
|
|
35
|
+
• What's authoritative vs. rough, and is there anything to leave out?
|
|
36
|
+
• How do I want it organized — by topic, project, client/entity, or timeline?
|
|
37
|
+
Ask follow-ups until you actually understand the material and my intent.
|
|
38
|
+
|
|
39
|
+
STEP 2 — Propose an organization and wait for my OK. Give me a short plan:
|
|
40
|
+
the main topic areas, a consistent tagging scheme, a node-naming convention, and
|
|
41
|
+
roughly how many nodes. Adjust based on my feedback before writing anything.
|
|
42
|
+
|
|
43
|
+
STEP 3 — Create the nodes, organized for retrieval (not prose):
|
|
44
|
+
• One idea per node; keep each tight (~100–300 words). Prefer many small linked
|
|
45
|
+
nodes over one big dump.
|
|
46
|
+
• Clear, specific titles; 3–6 consistent lower-case tags per node.
|
|
47
|
+
• Connect related nodes with [[Wiki Links]] (use the other node's title) so the
|
|
48
|
+
graph is traversable.
|
|
49
|
+
• type "document" for markdown; type "artifact" with raw HTML for self-contained
|
|
50
|
+
pages (decks, dashboards, infographics).
|
|
51
|
+
|
|
52
|
+
API — create one node per POST:
|
|
53
|
+
POST ${b}/nests/${i}/nodes
|
|
54
|
+
Content-Type: application/json${u?"":`
|
|
55
|
+
Authorization: Bearer <MY_API_KEY> # mint one via Connect; omit if the server is in open mode`}
|
|
56
|
+
Body: {
|
|
57
|
+
"title": "<short, specific title>",
|
|
58
|
+
"content": "<markdown body, with [[Wiki Links]] to related nodes>",
|
|
59
|
+
"type": "document",
|
|
60
|
+
"tags": ["<tag>", "<tag>"]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
After each create, report the node id. At the end, give me a short map of what
|
|
64
|
+
you created and how it's organized.
|
|
65
|
+
|
|
66
|
+
Begin at STEP 1 by interviewing me about what to put in this nest.`,w=`curl -X POST ${b}/nests/${i}/nodes \\
|
|
67
|
+
${p} -H "Content-Type: application/json" \\
|
|
68
|
+
-d '{"title":"My note","content":"# Hello\\n\\nSome context…","type":"document","tags":["demo"]}'`;return e.jsx(Fe,{open:s,onOpenChange:n,children:e.jsxs(Oe,{className:"sm:max-w-[640px] max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs(qe,{children:[e.jsxs($e,{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"h-4 w-4 text-primary"}),"Generate & add context to ",o]}),e.jsx(kt,{children:"Have Claude, Codex, or any agent generate context and push it straight into this nest via the API — no copy-pasting documents by hand."})]}),e.jsxs("div",{className:"space-y-4 overflow-y-auto pr-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"1. Paste this into Claude / Codex"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"It interviews you about what to ingest, proposes an organization (topics, tags, links), then creates well-structured nodes — it won't just dump one big doc."}),e.jsx(ga,{label:"Prompt for your agent",text:S})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"2. Or call the API directly"}),e.jsx(ga,{label:"curl",text:w})]}),!u&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border bg-card p-3 text-xs text-muted-foreground",children:[e.jsx(ta,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Writes need an API key (",e.jsx("code",{children:"Bearer cnst_*"}),"). Mint one in"," ",e.jsx("strong",{children:"Connect"})," — it's shown once; set it as"," ",e.jsx("code",{children:"$CNST_KEY"})," for the snippets above."]})]}),u&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-950/20 p-3 text-xs text-amber-900 dark:text-amber-200",children:[e.jsx(ta,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["Server is in ",e.jsx("strong",{children:"open"})," mode — no API key needed; anyone on the network can write. Lock it down before exposing it."]})]})]})]})})}function ci({nestId:s,nestName:n,stewardshipEnabled:i,allowSelfApprove:o,primeOnlyReview:u,primeTags:b,creatorIsReviewer:p,canManageStewardship:S,onClose:w,onChanged:g}){const[j,$]=r.useState(i),[v,m]=r.useState(o),[P,C]=r.useState(u),[R,Q]=r.useState(b.join(", ")),[U,le]=r.useState(p),[A,O]=r.useState(!1),[G,T]=r.useState(null),[J,D]=r.useState(!1),K=i&&!j,ae=j&&P,re=[...new Set(R.split(",").map(M=>M.trim().replace(/^#+/,"").toLowerCase()).filter(Boolean))],V=async()=>{const M=j!==i,W=v!==o,F=P!==u,f=re.join(",")!==b.join(","),x=U!==p;if(!M&&!W&&!F&&!f&&!x){w();return}O(!0),T(null);try{const y=await wr(s,{...M?{stewardship_enabled:j}:{},...W?{allow_self_approve:v}:{},...F?{prime_only_review:P}:{},...f?{prime_tags:re}:{},...x?{creator_is_reviewer:U}:{}});if(y.stewardship_enabled!==j||y.allow_self_approve!==v||y.prime_only_review!==P||y.creator_is_reviewer!==U){T("Server did not accept the change. You may not have permission to change these settings."),O(!1);return}g({stewardshipEnabled:y.stewardship_enabled,allowSelfApprove:y.allow_self_approve,primeOnlyReview:y.prime_only_review,primeTags:y.prime_tags,creatorIsReviewer:y.creator_is_reviewer})}catch(y){T(y.message),O(!1)}};return e.jsx(Fe,{open:!0,onOpenChange:w,children:e.jsxs(Oe,{className:"sm:max-w-[500px] flex flex-col max-h-[85vh]",children:[e.jsxs(qe,{children:[e.jsxs($e,{children:["Settings: ",n]}),e.jsx(kt,{children:"Admin controls for this nest. Changes apply to all future documents."})]}),e.jsxs("div",{className:"space-y-4 py-2 flex-1 min-h-0 overflow-y-auto pr-1",children:[G&&e.jsxs(Jt,{variant:"destructive",children:[e.jsx(Na,{className:"h-4 w-4"}),e.jsx(Zt,{children:G})]}),S&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(St,{className:"h-4 w-4"}),"Stewardship & Approval Workflow"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Require steward approval before documents become AI-ready. New documents will start as ",e.jsx("strong",{children:"drafts"}),". This also changes what “publishing” means in this nest: with stewardship on, the document editor shows",e.jsx("em",{children:" Publish (requires approval)"}),"; with it off, saving auto-publishes and an ",e.jsx("em",{children:"Auto-published"})," badge appears next to the title."]})]}),e.jsx(tt,{checked:j,onCheckedChange:$})]}),!j&&!K&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"Currently off."})," New documents are auto-approved and immediately available to AI. Versioning is still on — every edit creates a new version."]})]}),K&&e.jsxs(Jt,{variant:"destructive",className:"pt-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),e.jsxs(Zt,{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Disabling stewardship removes governance."})," ","All steward assignments and pending review requests for this nest will be deleted, and new documents become auto-approved. Collaborator access is kept — manage it from Share. Approved/rejected review history is kept."]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:J,onChange:M=>D(M.target.checked),className:"h-3.5 w-3.5"}),"I understand this will remove all stewards."]})]})]}),j&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"When enabled:"})," New documents start as drafts. Assigned stewards must approve before they're available to AI queries. Existing approved documents stay approved."]})]})]}),S&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ln,{className:"h-4 w-4"}),"Auto-publish owner & admin edits"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Default off. When enabled, edits by an owner or admin publish immediately — their changes skip the review queue instead of waiting for approval. Editors and reviewers are unaffected: they still submit drafts for review as usual. Turning this back off only changes future behavior; it doesn't unpublish anything. Audit logs still record every actor."})]}),e.jsx(tt,{checked:v,onCheckedChange:m,disabled:ae})]}),ae&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"No effect right now."})," ","“Review prime documents only” is on, so every non-prime document already self-publishes for everyone — and prime documents always need approval, including from owners and admins. Turn prime-only review off to use this bypass."]})]}),j&&!ae&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"Prime wins."})," A document flagged prime (or carrying a prime tag) always goes through review, even for an owner or admin with this on."]})]})]}),S&&j&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(cn,{className:"h-4 w-4"}),"Review prime documents only"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Default off. When enabled, day-to-day content self-publishes and only ",e.jsx("strong",{children:"prime"})," documents go through draft → pending → approved. Prime always wins: a prime document needs approval even from an owner or admin with auto-publish on, and turning this on makes the auto-publish bypass above redundant."]})]}),e.jsx(tt,{checked:P,onCheckedChange:C})]}),e.jsxs("div",{className:"space-y-1 pt-2 border-t",children:[e.jsx(se,{className:"text-xs font-medium",children:"Prime tags"}),e.jsx(Sa,{value:R,onChange:M=>Q(M.target.value),placeholder:"prime-document, messaging-architecture"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Comma-separated. Any document carrying one of these tags is prime. A single document can also be flagged directly from its editor, which overrides its tags."})]})]}),S&&j&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(se,{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ti,{className:"h-4 w-4"}),"Creators review their own documents"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Default off. When enabled, whoever creates a document becomes its ",e.jsx("strong",{children:"reviewer"})," and the first version publishes right away. Changes by anyone else go to the creator for approval; the creator’s own later edits go to the nest’s other reviewers. Applies to documents created from now on — existing documents keep their stewards."]})]}),e.jsx(tt,{checked:U,onCheckedChange:le})]}),e.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground pt-2 border-t",children:[e.jsx(Ke,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-foreground",children:"Prime wins."})," A prime document still starts as a draft — its creator is made its reviewer, but someone else has to approve the first version."]})]})]})]}),e.jsxs(at,{children:[e.jsx(k,{variant:"outline",onClick:w,disabled:A,children:"Cancel"}),e.jsx(k,{onClick:V,disabled:A||K&&!J,children:A?e.jsx(be,{className:"h-4 w-4 animate-spin"}):"Save Settings"})]})]})})}function Nt(s){let n=s.trim().replace(/^\/+/,"").replace(/\.md$/i,"");return n.startsWith("nodes/")||(n=`nodes/${n}`),n.toLowerCase()}function di(s,n){const i=s.trim();if(!i)return null;if(i.includes("/")){const u=Nt(i),b=n.find(w=>Nt(w.id)===u);if(b)return b;const p=u.split("/").pop()??"",S=n.filter(w=>Nt(w.id).endsWith(`/${p}`));return S.length===1?S[0]:null}const o=i.toLowerCase();return n.find(u=>String(u.title??"").toLowerCase()===o)??n.find(u=>Nt(u.id).endsWith(`/${o}`))??null}function Ra(s){const n=s.replace(/[-_]+/g," ").trim();return n&&n[0].toUpperCase()+n.slice(1)}function ui(s){return!s||s==="Root"?"General":Ra(s.split("/").filter(Boolean).pop()??s)}function va(s){return s.replace(/^nodes\//,"").split("/").filter(Boolean).slice(0,-1).map(Ra)}const ts=/^(overview|index|readme|welcome|home)$/i;function rs(s){return s.split("/").pop()??s}function mi(s,n){const i=rs(s.id).toLowerCase(),o=(n.split("/").filter(Boolean).pop()??"").toLowerCase();return ts.test(i)||ts.test(String(s.title??""))||!!o&&i===o}function _a(s,n){const i=n.filter(o=>mi(o,s));return[...i,...n.filter(o=>!i.includes(o))]}function hi(s){return s.flatMap(n=>_a(n.folder,n.items))}function pi(s,n){const i=s.findIndex(o=>o.id===n);return i<0?{prev:null,next:null}:{prev:s[i-1]??null,next:s[i+1]??null}}function fi(s,n){if(!n)return s;const i=s.match(/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/);if(!i)return s;const o=u=>u.replace(/[*_`]/g,"").trim().toLowerCase();return o(i[1])===o(n)?s.slice(i[0].length):s}function xi(s,n=[]){const i=new Set;for(const u of s)u.folder&&u.folder!=="Root"&&i.add(u.folder.split("/")[0]);for(const u of n)u.path&&i.add(u.path.split("/")[0]);const o=s.some(u=>!u.folder||u.folder==="Root");return i.size===1&&!o?[...i][0]:""}function gi(s,n){if(!s)return"";const i=String(s.title??"").trim()||rs(s.id);if(!n||!ts.test(i))return i;const o=n.match(/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/);return o?o[1].replace(/[*_`]/g,"").trim():i}function Aa(s){const n=s.replace(/^nodes\//,"").split("/").filter(Boolean).slice(0,-1);return n.map((i,o)=>n.slice(0,o+1).join("/"))}function vi(s){return new Set(["",...s.flatMap(n=>Aa(n.id||""))])}const ba="lg:min-h-0 lg:overflow-y-auto",It="rounded-lg border border-border bg-card p-4";function bi(s,n){const i=n.trim().toLowerCase().replace(/^#/,"");return i?s.filter(o=>String(o.title||rs(o.id)).toLowerCase().includes(i)||(o.tags??[]).some(u=>String(u).toLowerCase().replace(/^#/,"").includes(i))):null}const wi=["welcome","index","readme","home","overview"];function ji({nestId:s,nestName:n,nodes:i,tocGroups:o,knownFolders:u,readerHomeNode:b,initialDoc:p,onDocChange:S,onExpandFolder:w,loadingFolders:g,loadedFolders:j,approvedOnly:$=!1}){const v=r.useMemo(()=>{if(b){const l=i.find(c=>jr(c,b));if(l)return l}for(const l of wi){const c=i.find(E=>yr(E).includes(l));if(c)return c}return null},[i,b]),[m,P]=r.useState(()=>p??(v==null?void 0:v.id)??null),C=l=>{P(l),S==null||S(l),W(!1),V(null)};r.useEffect(()=>{!m&&v&&P(v.id)},[v,m]);const[R,Q]=r.useState({}),[U,le]=r.useState({}),[A,O]=r.useState(null),G=r.useRef(new Set),T=async l=>{if(!(R[l]!==void 0||G.current.has(l))){G.current.add(l),O(l);try{const{node:c}=await Sr(s,l,$);Q(E=>({...E,[l]:(c==null?void 0:c.content)??""})),(c==null?void 0:c.type)==="pdf"&&(c!=null&&c.pdf)&&le(E=>({...E,[l]:c.pdf}))}catch{V("This page could not be loaded.")}finally{G.current.delete(l),O(c=>c===l?null:c)}}};r.useEffect(()=>{m&&T(m)},[m,s]);const[J,D]=r.useState(()=>new Map),K=l=>J.get(l)??!(j!=null&&j.has(l)),ae=l=>{const c=K(l);D(E=>new Map(E).set(l,!c)),c&&w(l)};r.useEffect(()=>{if(!m)return;const l=Aa(m);if(l.length!==0){D(c=>{const E=new Map(c);for(const me of l)E.set(me,!1);return E});for(const c of l)j!=null&&j.has(c)||w(c)}},[m]);const[re,V]=r.useState(null),[M,W]=r.useState(!1),[F,f]=r.useState(""),x=r.useMemo(()=>bi(i,F),[i,F]),y=l=>{const c=di(l,i);c?C(c.id):V(`No page called “${l}” in this nest.`)},we=m?i.find(l=>l.id===m):null,Ce=m?R[m]:void 0,je=gi(we,Ce),ce=Ce===void 0?void 0:fi(Ce,je),fe=!!m&&ce===void 0&&A===m,nt=r.useMemo(()=>ce?dn(ce):[],[ce]),Re=r.useMemo(()=>hi(o),[o]),{prev:de,next:ie}=m?pi(Re,m):{prev:null,next:null},_e=m?va(m):[],Ct=l=>{var me;const c=document.getElementById(l);if(!c)return;const E=(me=window.matchMedia)==null?void 0:me.call(window,"(prefers-reduced-motion: reduce)").matches;c.scrollIntoView({behavior:E?"auto":"smooth",block:"start"})},it=r.useMemo(()=>xi(o,u),[o,u]),ue=r.useMemo(()=>o.map(l=>({...l,items:_a(l.folder,l.items)})),[o]),Rt=e.jsx(kr,{className:"space-y-px",groups:ue,baseFolder:it||void 0,known:u,isCollapsed:K,renderFolder:(l,{collapsed:c})=>e.jsxs("button",{type:"button",onClick:()=>ae(l.path),"aria-expanded":!c,className:"flex w-full items-center gap-1.5 py-1.5 pr-2 text-left text-[13px] font-medium text-foreground/80 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 rounded-sm",children:[c?e.jsx(sa,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(Cr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c?e.jsx(Rr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(_r,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:ui(l.path)}),(g==null?void 0:g.has(l.path))&&e.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:"loading"})]}),renderDoc:l=>{const c=m===l.id;return e.jsxs("button",{type:"button",onClick:()=>C(l.id),"aria-current":c?"page":void 0,className:"flex w-full items-center gap-1.5 rounded-md py-1 pl-2 pr-2 text-left text-[13px] leading-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 "+(c?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),title:l.title||l.id,children:[e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 opacity-70"}),e.jsx("span",{className:"truncate",children:l.title||l.id})]})}});return e.jsxs("div",{className:"mx-auto w-full max-w-[88rem] lg:grid lg:h-[calc(100vh-9.25rem-var(--reader-offset,0px))] lg:grid-cols-[16rem_minmax(0,1fr)_14rem] lg:gap-5",children:[e.jsxs("aside",{className:ba+" "+It+" mb-4 lg:mb-0",children:[e.jsxs("button",{type:"button",onClick:()=>W(l=>!l),"aria-expanded":M,className:"lg:hidden inline-flex items-center gap-2 text-sm font-medium py-2",children:[e.jsx(Zn,{className:"h-4 w-4"}),"Contents"]}),e.jsxs("div",{className:(M?"block":"hidden")+" lg:block",children:[e.jsx("h2",{className:"mb-3 border-b pb-3",children:e.jsxs("button",{type:"button",onClick:()=>v&&C(v.id),disabled:!v,"aria-current":v&&m===v.id?"page":void 0,title:n,className:"flex w-full items-center gap-2 text-left text-base font-bold tracking-tight focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 rounded-sm disabled:cursor-default "+(v&&m!==v.id?"text-foreground/80 hover:text-foreground":"text-foreground"),children:[e.jsx(ka,{className:"h-5 w-5 shrink-0 text-primary"}),e.jsx("span",{className:"truncate",children:n})]})}),e.jsxs("label",{className:"relative mb-3 block",children:[e.jsx(Nr,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"text",value:F,onChange:l=>f(l.target.value),placeholder:"Search by title or tag","aria-label":"Search pages by title or tag",className:"h-8 w-full rounded-md border border-input bg-background pl-8 pr-7 text-[13px] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"}),F&&e.jsx("button",{type:"button",onClick:()=>f(""),"aria-label":"Clear search",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground",children:e.jsx(Ca,{className:"h-3.5 w-3.5"})})]}),x?x.length===0?e.jsx("p",{className:"px-2 text-[13px] text-muted-foreground/70",children:"No pages match."}):e.jsx("ul",{className:"space-y-px",children:x.map(l=>{const c=m===l.id,E=va(l.id).join(" / ");return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>C(l.id),"aria-current":c?"page":void 0,title:l.title||l.id,className:"flex w-full items-start gap-1.5 rounded-md py-1 pl-2 pr-2 text-left text-[13px] leading-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 "+(c?"bg-accent text-foreground font-medium":"text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[e.jsx(st,{className:"mt-[3px] h-3.5 w-3.5 shrink-0 opacity-70"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate",children:l.title||l.id}),E&&e.jsx("span",{className:"block truncate text-[11px] font-normal text-muted-foreground/70",children:E})]})]})},l.id)})}):Rt]})]}),e.jsxs("article",{className:"min-w-0 "+It+" px-6 py-6 lg:min-h-0 lg:overflow-y-auto lg:px-8",children:[re&&e.jsxs("p",{role:"status",className:"mb-4 text-sm text-amber-800 dark:text-amber-300",children:[re,m&&R[m]===void 0&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:()=>{V(null),T(m)},children:"Try again"})]})]}),we&&e.jsxs("header",{className:"mb-6",children:[_e.length>0&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-2 truncate text-[13px] text-muted-foreground",title:_e.join(" / "),children:_e.map((l,c)=>e.jsxs("span",{children:[c>0&&e.jsx("span",{"aria-hidden":!0,className:"mx-1.5 text-muted-foreground/60",children:"/"}),l]},c))}),e.jsx("h1",{className:"break-words text-[2rem] leading-[1.15] font-semibold tracking-tight text-foreground",children:je}),e.jsx(yi,{node:we})]}),!m&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a page from the contents."}),fe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}),m&&ce!==void 0&&U[m]&&e.jsx(un,{nestId:s,nodeId:m,title:je,pdf:U[m],approvedOnly:$}),m&&ce!==void 0&&e.jsx(mn,{content:ce,onWikiLinkClick:y,plainLinks:!0,className:"max-w-none px-0 py-0 min-h-0 max-h-none overflow-visible prose-base prose-headings:scroll-mt-24 prose-h2:mt-10 prose-h2:text-xl prose-h3:text-base prose-p:leading-7 prose-pre:rounded-sm prose-code:before:content-none prose-code:after:content-none"}),(de||ie)&&e.jsxs("nav",{"aria-label":"Previous and next pages",className:"mt-14 grid grid-cols-2 gap-4 border-t pt-6 text-sm",children:[e.jsx("div",{className:"min-w-0",children:de&&e.jsxs("button",{type:"button",onClick:()=>C(de.id),title:de.title||de.id,className:"group flex w-full items-center gap-3 rounded-lg border px-4 py-3 text-left hover:border-primary/60 hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",children:[e.jsx(Sn,{className:"h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Previous"}),e.jsx("span",{className:"block truncate font-medium text-foreground group-hover:text-primary",children:de.title||de.id})]})]})}),e.jsx("div",{className:"min-w-0",children:ie&&e.jsxs("button",{type:"button",onClick:()=>C(ie.id),title:ie.title||ie.id,className:"group flex w-full items-center justify-end gap-3 rounded-lg border px-4 py-3 text-right hover:border-primary/60 hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[12px] text-muted-foreground",children:"Next"}),e.jsx("span",{className:"block truncate font-medium text-foreground group-hover:text-primary",children:ie.title||ie.id})]}),e.jsx(sa,{className:"h-4 w-4 shrink-0 text-muted-foreground group-hover:text-primary"})]})})]})]}),e.jsx("aside",{className:"hidden lg:block "+ba+" "+It,children:e.jsxs("nav",{"aria-label":"On this page",children:[e.jsx("p",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wide text-muted-foreground",children:"On this page"}),nt.length===0?e.jsx("p",{className:"text-[13px] text-muted-foreground/70",children:m?"No headings yet.":"Open a page to see its headings."}):e.jsx("ul",{className:"space-y-1",children:nt.map(l=>e.jsx("li",{style:{paddingLeft:(l.level-1)*12},children:e.jsx("button",{type:"button",onClick:()=>Ct(l.id),className:"block w-full truncate text-left text-[13px] leading-5 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 rounded-sm",title:l.text,children:l.text})},l.id))})]})})]})}function yi({node:s}){const n=String(s.status||"draft"),i=s.updated_at?yn(s.updated_at):null;return e.jsxs("p",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[13px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block h-1.5 w-1.5 rounded-full "+(n==="published"?"bg-emerald-500":"bg-amber-500")}),n==="published"?"Published":n.replace(/_/g," ")]}),s.version!=null&&e.jsxs("span",{children:["Version ",s.version]}),i&&e.jsxs("span",{children:["Updated ",i]})]})}const Ni=50;function Si(s,n=!0){return ss({...H.feed(s,"comments",Ni,0),enabled:n})}const Xt={nest:{label:"Entire Nest",icon:es,placeholder:""},tag:{label:"Tag",icon:$n,placeholder:"e.g., #architecture"},document:{label:"Document",icon:st,placeholder:"e.g., nodes/getting-started"}};function wa(s){return s.scope==="tag"?s.tagName||"":s.scope==="document"&&s.nodePattern||""}function ja({isOpen:s,onClose:n,nestId:i,steward:o,onSubmit:u,onSync:b}){const p=!!o,[S,w]=r.useState(""),[g,j]=r.useState("tag"),[$,v]=r.useState(""),[m,P]=r.useState("reviewer"),[C,R]=r.useState(!1),[Q,U]=r.useState(!1),[le,A]=r.useState(null),[O,G]=r.useState([]),[T,J]=r.useState(null),[D,K]=r.useState(!1),ae=as();r.useEffect(()=>{s&&(w((o==null?void 0:o.userEmail)??""),j((o==null?void 0:o.scope)??"tag"),v(o?wa(o):""),P((o==null?void 0:o.role)??"reviewer"),A(null))},[s,o]),r.useEffect(()=>{if(!s||g!=="document"&&g!=="tag")return;let f=!1;return K(!0),(g==="document"?ae.fetchQuery(H.nodes(i)).then(y=>{if(f)return;const we=Array.isArray(y==null?void 0:y.nodes)?y.nodes:[];G(we)}):ae.fetchQuery(H.tags(i)).then(y=>{f||(J(y),y.length===0&&!o&&j("nest"))})).catch(y=>console.error(`[StewardModal] ${g} fetch failed`,y)).finally(()=>{f||K(!1)}),()=>{f=!0}},[s,g,i]);const re=!p||m!==o.role||g!==o.scope||$!==wa(o),V=async()=>{if(b){U(!0),A(null);try{await b()}catch(f){A(f instanceof Error?f.message:"Failed to sync stewards.yaml")}finally{U(!1)}}},M=async()=>{if(p&&!re){n();return}if(!p&&!S.trim()){A("Please enter an email");return}if(!p&&!Ar(S.trim())){A("Enter a valid email address.");return}if(g!=="nest"&&!$.trim()){A(`Please specify the ${g} target`);return}R(!0),A(null);try{await u({email:((o==null?void 0:o.userEmail)??S).trim(),scope:g,target:g==="nest"?void 0:$.trim(),role:m}),n()}catch(f){A(f instanceof Error?f.message:p?"Failed to update steward":"Failed to assign steward"),R(!1)}},W=C||Q,F=Xt[g].icon;return e.jsx(Fe,{open:s,onOpenChange:f=>!f&&!W&&n(),children:e.jsxs(Oe,{className:"sm:max-w-[500px]",children:[e.jsxs(qe,{children:[e.jsx($e,{children:p?"Edit steward":"Assign Context Steward"}),e.jsx(kt,{children:p?e.jsxs(e.Fragment,{children:["Change the role and scope for"," ",e.jsx("strong",{className:"text-foreground",children:o.userEmail}),"."]}):"Stewards can approve or reject documents within their assigned scope, ensuring quality context is available for AI."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[le&&e.jsxs(Jt,{variant:"destructive",children:[e.jsx(Na,{className:"h-4 w-4"}),e.jsx(Zt,{children:le})]}),!p&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{htmlFor:"email",children:"Steward Email"}),e.jsx(qn,{id:"email",value:S,onChange:w,placeholder:"reviewer@acme.com",disabled:C,testId:"steward-email-input"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Scope"}),e.jsxs(da,{value:g,onValueChange:f=>{j(f),v("")},disabled:C,children:[e.jsx(ua,{children:e.jsx(ma,{})}),e.jsx(ha,{children:Object.entries(Xt).map(([f,x])=>{const y=x.icon;return e.jsx(yt,{value:f,disabled:f==="tag"&&(T==null?void 0:T.length)===0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{className:"h-4 w-4"}),x.label]})},f)})})]})]}),g!=="nest"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(se,{htmlFor:"target",children:[e.jsx(F,{className:"h-4 w-4 inline mr-2"}),g==="tag"?"Tag":Xt[g].label]}),g==="tag"?e.jsx(oa,{id:"target",testId:"steward-tag-select",value:$,onChange:v,disabled:C||D,options:(T??[]).map(f=>({value:f,label:`#${f}`})),placeholder:D?"Loading tags...":(T==null?void 0:T.length)===0?"No tags in this nest":"Select a tag",searchPlaceholder:"Search tags…",emptyText:"No tag matches that."}):e.jsx(oa,{id:"target",testId:"steward-document-select",value:$,onChange:v,disabled:C||D,options:O.map(f=>({value:f.id,label:f.title||f.id})),placeholder:D?"Loading documents...":O.length===0?"No documents in this nest":"Select a document",searchPlaceholder:"Search documents…",emptyText:"No document matches that."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g==="tag"?"Steward approves any document with this tag.":"Steward governs this specific document."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(se,{children:"Role"}),e.jsxs(da,{value:m,onValueChange:f=>P(f),disabled:C,children:[e.jsx(ua,{children:e.jsx(ma,{})}),e.jsxs(ha,{children:[e.jsx(yt,{value:"editor",children:"Editor — can edit but not approve"}),e.jsx(yt,{value:"reviewer",children:"Reviewer — can approve/reject"}),e.jsx(yt,{value:"viewer",children:"Viewer — read-only access"})]})]})]})]}),e.jsxs(at,{className:"sm:justify-between",children:[b&&!p?e.jsxs(k,{variant:"ghost",size:"sm",onClick:V,disabled:W,title:"Re-import steward rows from the nest's stewards.yaml",children:[Q?e.jsx(be,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(zn,{className:"h-4 w-4 mr-2"}),"Sync stewards.yaml"]}):e.jsx("span",{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",onClick:n,disabled:W,children:"Cancel"}),e.jsxs(k,{onClick:M,disabled:W||!p&&!S.trim(),children:[C?e.jsx(be,{className:"h-4 w-4 mr-2 animate-spin"}):p?null:e.jsx(Vn,{className:"h-4 w-4 mr-2"}),p?"Save":"Assign Steward"]})]})]})]})})}const ki=Me(()=>ze(()=>import("./ExternalEditsTab-kIBimZyE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])).then(s=>({default:s.ExternalEditsTab}))),Ci=Me(()=>ze(()=>import("./StewardsTab-AagNWcWS.js"),__vite__mapDeps([31,1,2,26,8,9,10,11,12,13,14,15,16,17,18,25,4])).then(s=>({default:s.StewardsTab}))),Ri=Me(()=>ze(()=>import("./CollaboratorsTab-DRCitQuX.js"),__vite__mapDeps([32,1,2,33,12,20,11,13,8,9,10,14,15,16,17,18,24,26,34,4])).then(s=>({default:s.CollaboratorsTab}))),_i=Me(()=>ze(()=>import("./ReviewTab-CZewAYiz.js"),__vite__mapDeps([35,1,2,12,11,13,4,3,6,7,36,27,28,10,29,37,16,8,9,14,15,17,18,19,20,21,22,23,24,25,26,30])).then(s=>({default:s.ReviewTab}))),Ai=Me(()=>ze(()=>import("./OverviewTab-DFOFMVyE.js"),__vite__mapDeps([38,1,2,4,8,9,10,11,12,13,14,15,16,17,18,3,19,20,21,22,23,24,25,6,26,27,7,28,29,30])).then(s=>({default:s.OverviewTab}))),Ti=Me(()=>ze(()=>import("./DocumentsTab-BUxBCN8o.js"),__vite__mapDeps([39,1,2,40,4,11,12,13,8,9,10,14,15,16,17,18,3,41,7,28,23,34,42,37,29,5,43,19,20,21,22,24,25,6,26,27,30])).then(s=>({default:s.DocumentsTab})));function Di({nestId:s,nestName:n,isOwner:i,isAnonOwned:o,isArchived:u,onBack:b,initialDoc:p,onReaderDocChange:S,onOpenDocument:w,onOpenTrace:g,onManageKeys:j,initialSearch:$,initialTags:v,initialFolder:m,initialTab:P,onTabChange:C}){var Ks,Ys,Is,Xs,Js,Zs,ea;const{isAdmin:R,adminStatus:Q,authMode:U,sharedDeployment:le}=Tr(),A=i||o&&U!=="open"&&R,O=((Ys=(Ks=Q==null?void 0:Q.me)==null?void 0:Ks.email)==null?void 0:Ys.toLowerCase())??"",[G,T]=r.useState(n),J=r.useRef(n);r.useEffect(()=>{T(n),J.current=n},[n,s]);const D=r.useRef(null),K=r.useRef(()=>{}),ae=r.useRef(ri()).current,[re,V]=r.useState(null);K.current=async()=>{const t=G.trim();if(t&&t!==J.current.trim())try{await aa(s,{name:t}),J.current=t,V(null)}catch(a){const d=a instanceof Error?a.message:"Failed to rename nest";V(d)}};const M=r.useCallback(()=>{D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{D.current=null,K.current()},1200)},[]),W=r.useCallback(()=>{D.current&&(window.clearTimeout(D.current),D.current=null),!ae.consume()&&K.current()},[]);r.useEffect(()=>()=>{D.current&&window.clearTimeout(D.current)},[]);const[F,f]=r.useState([]),[x,y]=r.useState(null),[we,Ce]=r.useState(!1),[je,ce]=r.useState([]),[fe,nt]=r.useState([]),[Re,de]=r.useState([]),[ie,_e]=r.useState(null),[Ct,it]=r.useState(!1),ue=Re.find(t=>(t.targetType==="nest"||t.targetType==="nest_archive")&&t.status==="pending"),Rt=!!ue,l=r.useMemo(()=>Re.filter(t=>t.status==="pending"),[Re]),[c,E]=r.useState(null),[me,Ta]=r.useState(!1),[Z,ns]=r.useState(!1),[ot,is]=r.useState(!1),[Da,os]=r.useState(!1),[Ea,ls]=r.useState(!1),[cs,ds]=r.useState([]),[q,lt]=r.useState("private"),[us,ms]=r.useState(!1),[La,_t]=r.useState(!1),[hs,ps]=r.useState(""),[xe,ct]=r.useState(!1),[he,At]=r.useState(null),[Ve,dt]=r.useState(!1),[Tt,ut]=r.useState(!1),[ye,fs]=r.useState(!1),[xs,gs]=r.useState(!1),[Pa,mt]=r.useState(null),[vs,Fa]=r.useState(!1),[Oa,qa]=r.useState(null),[Ne,$a]=r.useState(null),oe=R&&(i||o)||!R&&(i||Ne==="owner"||Ne==="admin"),Ma=R||i||Ne==="owner"||Ne==="admin",[Dt,za]=r.useState([]),[Va,We]=r.useState(!1),[Be,bs]=r.useState(null),[Et,ws]=r.useState(!0),[ne,Wa]=r.useState(!0),[ee,Ae]=r.useState(null),[js,Lt]=r.useState(!1),[ys,Pt]=r.useState(!1),[Ns,Ss]=r.useState(!1),[Ba,ht]=r.useState(!1),ks=r.useRef(null),[Cs,Rs]=r.useState(""),[_s,As]=r.useState(!1),pe=ai(Cs),Ts=async()=>{const t=pe.path;if(t&&!pe.error){As(!0);try{await Yr(s,t),Rs(""),ht(!1),N.success(`Folder "${Ir(t)}" created`),_()}catch(a){console.error("[NestView] createFolder failed",a),N.error((a==null?void 0:a.message)||"Failed to create folder")}finally{As(!1)}}},[Ha,pt]=r.useState(!1),[Qa,Ft]=r.useState(!1),[ft,Ot]=r.useState(null),[Te,Ds]=r.useState(m??null),[De,Ua]=r.useState(P??(m||v!=null&&v.length?"documents":"overview")),He=t=>{Ua(t),C==null||C(t)},[Es,xt]=r.useState(new Set),[Ls,Ps]=r.useState(new Set),Y=as(),Se=r.useRef(new Set),[Ga,qt]=r.useState(new Set),ge=r.useCallback(async(t,a={})=>{if(!(!a.refresh&&Se.current.has(t))){Ps(d=>new Set(d).add(t));try{const d=await Y.fetchQuery(H.folderNodes(s,t));Se.current.add(t),qt(h=>new Set(h).add(t)),f(h=>[...h.filter(B=>oi(B.id||"")!==t),...d.nodes])}catch(d){console.error("[NestView] listFolderNodes failed",s,t,d),N.error((d==null?void 0:d.message)||"Failed to load folder")}finally{Ps(d=>{const h=new Set(d);return h.delete(t),h})}}},[s,Y]),gt=r.useCallback(async()=>{try{const{census:t}=await Y.fetchQuery(H.census(s));y(t)}catch(t){console.error("[NestView] getNestCensus failed",s,t)}finally{Ce(!0)}},[s,Y]),Fs=r.useCallback(async()=>{Se.current.size&&await Promise.all([gt(),...[...Se.current].map(t=>ge(t,{refresh:!0}))])},[ge,gt]),Ka=t=>{Ds(t),He("documents")},Ya=t=>{xt(a=>a.has(t)?a:new Set(a).add(t)),ge(t)},Ia=t=>{const a=!Es.has(t);xt(d=>{const h=new Set(d);return a?h.add(t):h.delete(t),h}),a&&ge(t)},_=r.useCallback(async()=>{var Ge;ws(!0);const t=await Y.fetchQuery(H.nest(s)).catch(z=>(console.error("[NestView] getNest failed",s,z),null)),a=!!(t!=null&&t.grant_only);Ta(a);const d=z=>Promise.resolve(z),[,h,B,L]=await Promise.all([Fs(),a?d({requests:[],total:0}):Y.fetchQuery(H.reviewQueue(s)).catch(z=>(console.error("[NestView] getReviewQueue failed",s,z),N.error((z==null?void 0:z.message)||"Failed to load review queue"),{requests:[],total:0})),a?d({requests:[],total:0}):Y.fetchQuery(H.deletionRequests(s,"all")).catch(z=>(console.error("[NestView] getDeletionRequests failed",s,z),{requests:[],total:0})),a?d({stewardship_enabled:!1,allow_self_approve:!1,prime_only_review:!1,prime_tags:[],creator_is_reviewer:!1}):Y.fetchQuery(H.settings(s)).catch(z=>(console.error("[NestView] getNestSettings failed",s,z),{stewardship_enabled:!1,allow_self_approve:!1,prime_only_review:!1,prime_tags:[],creator_is_reviewer:!1}))]);nt(h.requests),de(B.requests),ns(L.stewardship_enabled),is(L.allow_self_approve),os(!!L.prime_only_review),ls(!!L.creator_is_reviewer),ds(L.prime_tags??[]),(Ge=t==null?void 0:t.nest)!=null&&Ge.visibility&<(t.nest.visibility),t!=null&&t.nest&&(Fa(!!t.nest.is_imported),Ot(t.nest.description??null),ct(!!t.nest.reader_mode),At(t.nest.reader_home_node??null),qa(t.nest.archived_at??null)),t!=null&&t.permission&&$a(t.permission),za((t==null?void 0:t.roles)??[]),ce((t==null?void 0:t.myStewards)??[]),ws(!1),Wa(!1)},[s,Y,Fs]);r.useEffect(()=>{_()},[_]),r.useEffect(()=>{Se.current=new Set,xt(new Set),f([]),Ce(!1),ge(Te??""),gt()},[s,Te,ge,gt]);const $t=r.useMemo(()=>((x==null?void 0:x.folders)??[]).map(t=>({path:t.path,total:t.total})),[x]),Xa=(x==null?void 0:x.recent)??[],Ja=(x==null?void 0:x.editedLast7d)??0,vt=u||Dr({archived_at:Oa}),Qe=Er({roles:Dt,permission:Ne,myStewards:je,isOwner:i,isAdmin:R,readerMode:xe,previewReader:ye,isArchived:vt}),{canManage:ve,collabCanWrite:Mt,canEditDocs:ke,isReadOnly:I,isReaderView:zt}=Qe;r.useEffect(()=>{if(!zt)return;let t=!1;return Y.fetchQuery(H.nodesMeta(s,ye)).then(({nodes:a})=>{if(t)return;const d=vi(a);Se.current=d,qt(d),f(a)}).catch(a=>N.error((a==null?void 0:a.message)||"Failed to load documents")),()=>{t=!0}},[zt,ye,s,Y]);const Za=()=>{fs(!1),Se.current=new Set,qt(new Set),xt(new Set),f([]),ge(Te??"")},Os=(t,a)=>je.some(d=>{if(d.role!==a)return!1;if(d.scope==="nest")return!0;if(d.scope==="document")return d.nodePattern===t.id;if(d.scope==="tag"){const h=(d.tagName||"").toLowerCase().replace(/^#+/,"");return(t.tags||[]).map(B=>B.toLowerCase().replace(/^#+/,"")).includes(h)}return!1}),qs=t=>!t||I?!1:R||Dt.includes("admin")?!0:i?ot:!!Os(t,"reviewer"),Ue=fe.filter(t=>{if(t.canReview!==void 0)return t.canReview;const a=F.find(h=>h.id===t.nodeId);return!(!a||!qs(a)||t.requestedBy.toLowerCase()===O&&!(i&&ot))}),er=fe.filter(t=>t.requestedBy.toLowerCase()===O),$s=((Is=ss({...H.externalEditCount(s),enabled:!me}).data)==null?void 0:Is.total)??0,Ms=Z||Qe.canReviewDocs||fe.length>0||Qe.canManage&&l.length>0,Ee=Si(s,!me&&!ne&&!Ms).data,tr=((Xs=Ee==null?void 0:Ee.counts)==null?void 0:Xs.comments)??((Ee==null?void 0:Ee.items)??[]).filter(t=>t.type==="comment").length,Vt=Ms||tr>0,zs={overview:!0,documents:!0,review:Vt&&!I,"external-edits":!I,stewards:Z&&oe,collaborators:ve||Mt};r.useEffect(()=>{!ne&&!zs[De]&&He("overview")},[ne,De,zs[De]]);const X={total:(x==null?void 0:x.total)??F.length,pending:((Js=x==null?void 0:x.statuses)==null?void 0:Js.pending_review)??0,approved:(((Zs=x==null?void 0:x.statuses)==null?void 0:Zs.approved)??0)+(((ea=x==null?void 0:x.statuses)==null?void 0:ea.published)??0),reviewQueue:fe.length,reviewable:Ue.length},Vs=(()=>{const t=new Map;for(const a of F){const d=a.id||"",h=d.startsWith("nodes/")?d.slice(6):d,B=h.lastIndexOf("/"),L=B>0?h.slice(0,B):"Root";t.has(L)||t.set(L,[]),t.get(L).push(a)}return[...t.entries()].map(([a,d])=>({folder:a,depth:a==="Root"?0:a.split("/").length,items:[...d].sort((h,B)=>String(h.title||h.id).localeCompare(String(B.title||B.id)))})).sort((a,d)=>a.folder==="Root"?-1:d.folder==="Root"?1:ii(a.folder,d.folder))})(),sr=(x==null?void 0:x.folders.length)??0,Ws=async t=>{try{await Gr(s,t.id),N.success("Deletion request withdrawn"),_()}catch(a){N.error((a==null?void 0:a.message)||"Failed to withdraw deletion request")}},ar=async t=>{if(ee)try{await en(s,ee.id,t),N.success("Approved"),Ae(null),_()}catch(a){console.error("[NestView] approveNode failed",s,ee==null?void 0:ee.id,a),N.error((a==null?void 0:a.message)||"Approve failed")}},rr=async t=>{if(ee)try{await Zr(s,ee.id,t),N.success("Rejected"),Ae(null),_()}catch(a){console.error("[NestView] rejectNode failed",s,ee==null?void 0:ee.id,a),N.error((a==null?void 0:a.message)||"Reject failed")}},nr=async t=>{try{await Kr(s,t),N.success("Submission withdrawn — back to Draft"),_()}catch(a){console.error("[NestView] cancelReview failed",s,t,a),N.error((a==null?void 0:a.message)||"Failed to withdraw submission")}},ir=async()=>{const t=ie;try{await tn(s,t),_()}catch(a){throw console.error("[NestView] removeSteward failed",s,t,a),a}},or=async t=>{const{target:a,...d}=t,h={...d};t.scope==="document"?h.nodePattern=a:t.scope==="tag"&&(h.tagName=a),await Xr(s,h),_()},lr=async t=>{if(!Be)return;const a={role:t.role,scope:t.scope};t.scope==="document"?a.nodePattern=t.target:t.scope==="tag"&&(a.tagName=t.target),await Jr(s,Be.id,a),N.success("Steward updated"),_()},cr=async()=>{await sn(s,c.request.id),N.success("Document deleted"),_()},dr=async t=>{await an(s,c.request.id,t),N.success("Request rejected"),_()},Bs=async(t,a)=>{const d=q;lt(t),ms(!0);try{const h=await rn(s,t,a);h!=null&&h.visibility&<(h.visibility)}catch(h){lt(d),N.error((h==null?void 0:h.message)||"Failed to change visibility")}finally{ms(!1)}},ur=async()=>{if(q==="org"){He("collaborators");return}if(q!=="public"){ps(ft??""),_t(!0);return}await Bs("private")},mr=async()=>{_t(!1);const t=hs.trim();if(t&&t!==(ft??"").trim())try{await aa(s,{description:t}),Ot(t)}catch(a){N.error((a==null?void 0:a.message)||"Failed to save the description — publishing anyway")}await Bs("public",!0)},Wt=xn("public",{sharedDeployment:le}),hr=async()=>{const t=!xe;ct(t),dt(!0);try{const a=await ia(s,{enabled:t});ct(!!a.reader_mode),At(a.reader_home_node??null)}catch(a){ct(!t),N.error((a==null?void 0:a.message)||"Failed to change reader mode")}finally{dt(!1)}};r.useEffect(()=>{if(!Tt||!he){mt(null);return}let t=!1;return Y.fetchQuery(H.node(s,he)).then(({node:a})=>{t||mt((a==null?void 0:a.title)||he)}).catch(()=>{t||mt(he)}),()=>{t=!0}},[Tt,he,s,Y]);const Hs=async t=>{dt(!0);try{const a=await ia(s,{home_node:t});At(a.reader_home_node??null),N.success("Saved reader home node")}catch(a){N.error((a==null?void 0:a.message)||"Failed to set reader home node")}finally{dt(!1)}},[pr,Bt]=r.useState(!1),[fr,Qs]=r.useState(!1),Ht=r.useRef(null),Us=r.useRef(null),Gs=t=>{const a=t.toLowerCase().split(".").pop()||"";return a==="html"||a==="htm"?"artifact":a==="pdf"?"pdf":a==="md"||a==="markdown"||a==="txt"?"document":null},bt=r.useCallback(async t=>{var B;const a=Array.from(t).filter(L=>Gs(L.name)),d=t.length-a.length;if(!a.length){N.error("Drop .md, .html or .pdf files to add them to this vault.");return}Qs(!0);const h=[];try{for(const L of a){const Ge=Gs(L.name),z=L.name.replace(/\.(md|markdown|txt|html|htm|pdf)$/i,""),Qt=L.webkitRelativePath;let Ut;if(Qt&&Qt.includes("/")){const te=Qt.split("/").slice(1,-1);if(te.some(wt=>wt.startsWith(".")))continue;Ut=(te[0]==="nodes"?te.slice(1):te).join("/")||void 0}try{const te=Ge==="pdf"?await Lr(s,L,{title:z,folder:Ut}):await Pr(s,{title:z,content:await L.text(),type:Ge,folder:Ut}),wt=(B=te==null?void 0:te.node)==null?void 0:B.id;wt&&h.push(wt)}catch(te){N.error(`${L.name}: ${(te==null?void 0:te.message)||"failed to import"}`)}}h.length&&(N.success(`Added ${h.length} ${h.length===1?"item":"items"}`+(d?` (skipped ${d} unsupported)`:"")),await _(),h.length===1&&w(h[0]))}finally{Qs(!1)}},[s,_,w]);return zt?e.jsxs("div",{style:ye?{"--reader-offset":"3.5rem"}:void 0,children:[ye&&e.jsxs("div",{role:"status",className:"mb-4 flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/40 dark:text-amber-200",children:[e.jsx("span",{children:"Previewing as a reader — this is what visitors see."}),e.jsx(k,{variant:"outline",size:"sm",className:"h-7",onClick:Za,children:"Exit preview"})]}),e.jsx(ji,{nestId:s,nestName:G,nodes:F,tocGroups:Vs,knownFolders:$t,readerHomeNode:he,initialDoc:p,onDocChange:S,onExpandFolder:ge,loadingFolders:Ls,loadedFolders:Ga,approvedOnly:ye},ye?"preview":"reader")]}):e.jsxs("div",{className:"relative",onDragOver:t=>{ke&&Array.from(t.dataTransfer.types).includes("Files")&&(t.preventDefault(),Bt(!0))},onDragLeave:t=>{t.currentTarget===t.target&&Bt(!1)},onDrop:t=>{var a;ke&&(t.preventDefault(),Bt(!1),(a=t.dataTransfer.files)!=null&&a.length&&bt(t.dataTransfer.files))},children:[pr&&ke&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-primary/5 backdrop-blur-[1px]",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[e.jsx(la,{className:"h-8 w-8"}),e.jsx("div",{className:"text-sm font-medium",children:"Drop to add to this vault"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:".md → document · .html → hosted artifact · .pdf → PDF document"})]})}),fr&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-40 flex items-center justify-center bg-background/60",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"})," Importing…"]})}),e.jsxs(Ln,{nestName:n,onBack:b,title:ve?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:G,onChange:t=>{T(t.target.value),V(null),M()},onBlur:W,onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),W(),t.target.blur()),t.key==="Escape"&&(ae.arm(),T(J.current),V(null),t.target.blur())},"aria-label":"Nest name",title:"Click to rename — saved automatically",className:"w-full min-w-0 truncate text-xl font-semibold bg-transparent outline-none border-b border-transparent hover:border-border focus:border-primary px-1 -ml-1 rounded-sm"}),!Et&&e.jsx("button",{type:"button",onClick:()=>{W(),Ft(!0)},className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",title:"Rename nest","aria-label":"Rename nest","data-testid":"nest-rename",children:e.jsx(qr,{className:"h-4 w-4"})})]}),re&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-red-700",title:re,children:re})]}):void 0,badges:e.jsxs(e.Fragment,{children:[ve?e.jsxs(k,{variant:"outline",size:"sm",onClick:ur,disabled:us,className:`shrink-0 h-7 gap-1.5 ${q==="public"?"border-blue-200 bg-blue-50 text-blue-700 hover:bg-blue-100":""}`,title:q==="public"?"Public — anyone with the URL can read. Click to make private.":q==="org"?`Organization — ${pn("org",{sharedDeployment:le}).toLowerCase()}. Click to manage sharing (Collaborators tab).`:"Private. Click to make public (anyone with the URL can read).",children:[us?e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}):q==="public"?e.jsx(ra,{className:"h-3.5 w-3.5"}):q==="org"?e.jsx(es,{className:"h-3.5 w-3.5"}):e.jsx(Or,{className:"h-3.5 w-3.5"}),q==="public"?"Public":q==="org"?"Organization":"Private"]}):q!=="private"&&e.jsxs(Ye,{variant:"outline",className:`shrink-0 gap-1 ${q==="public"?"border-green-200 bg-green-50 text-green-700":"border-blue-200 bg-blue-50 text-blue-700"}`,title:q==="public"?"Anyone with the URL can read this nest":"Everyone signed in to this deployment can read this nest",children:[q==="public"?e.jsx(ra,{className:"h-3 w-3"}):e.jsx(es,{className:"h-3 w-3"}),q==="public"?"Public":"Organization"]}),Ma&&!vt&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>ut(!0),className:`shrink-0 h-7 gap-1.5 ${xe?"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100":""}`,title:"Public Docs Reader Mode — the clean, read-only docs view public readers get.",children:[Ve?e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ka,{className:"h-3.5 w-3.5"}),xe?"Reader: On":"Reader: Off"]}),vs&&e.jsxs(Ye,{variant:"outline",className:"shrink-0 gap-1 border-blue-200 bg-blue-50 text-blue-700",title:"Imported from a folder — its files were copied into the workspace",children:[e.jsx(Bn,{className:"h-3 w-3"}),"Imported"]}),ue&&(()=>{const t=ue.requestedBy.toLowerCase()===O,a=ue.targetType==="nest_archive",d=a?"archived":"deleted";return e.jsxs(Ye,{variant:"outline",className:`shrink-0 gap-1 ${a?"border-amber-200 bg-amber-50 text-amber-700":"border-red-200 bg-red-50 text-red-700"} ${t?"cursor-pointer hover:opacity-80":""}`,title:t?`Click to withdraw your ${a?"archive":"deletion"} request`:`${ue.requestedBy} asked for this nest to be ${d}: "${ue.reason}". A nest owner or admin decides.`,"data-testid":"nest-deletion-flag",onClick:t?()=>Ws(ue):void 0,children:[a?e.jsx(Hn,{className:"h-3 w-3"}):e.jsx(pa,{className:"h-3 w-3"}),a?"Archive requested":"Deletion requested",t&&e.jsx(Ca,{className:"h-3 w-3 ml-0.5"})]})})()]}),children:[!vt&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>Pt(!0),children:[e.jsx(Mn,{className:"h-3.5 w-3.5 mr-1.5"}),"Connect"]}),!I&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>Ss(!0),children:[e.jsx(ya,{className:"h-3.5 w-3.5 mr-1.5"}),"Add with AI"]}),ve&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>He("collaborators"),children:[e.jsx(Fr,{className:"h-3.5 w-3.5 mr-1.5"}),"Share"]}),!I&&ke&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:Ht,type:"file",multiple:!0,accept:".md,.markdown,.txt,.html,.htm,.pdf",className:"hidden",onChange:t=>{var a;(a=t.target.files)!=null&&a.length&&bt(t.target.files),t.target.value=""}}),e.jsx("input",{ref:Us,type:"file",multiple:!0,accept:"application/pdf,.pdf",className:"hidden",onChange:t=>{var a;(a=t.target.files)!=null&&a.length&&bt(t.target.files),t.target.value=""}}),e.jsx("input",{ref:ks,type:"file",className:"hidden",webkitdirectory:"",onChange:t=>{var a;(a=t.target.files)!=null&&a.length&&bt(t.target.files),t.target.value=""}})]}),(()=>{const t=[];return!I&&oe&&t.push({label:"Nest settings",icon:fa,onSelect:()=>We(!0)}),!I&&Z&&oe&&t.push({label:"Assign Steward",icon:St,onSelect:()=>Lt(!0)}),oe&&g&&!vt&&t.push({label:"Activity trace",icon:Gn,onSelect:g}),!I&&(A||ke)&&(A||!Rt)&&t.push({label:"Delete",icon:pa,destructive:A,separatorBefore:!0,onSelect:()=>A?pt(!0):it(!0)}),e.jsx(hn,{actions:t,variant:"outline",className:"h-8 w-8"})})()]}),e.jsxs("div",{className:`grid grid-cols-1 gap-4 mb-4 ${Z?"md:grid-cols-4":"md:grid-cols-1 max-w-sm"}`,children:[e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"Total Documents"}),e.jsx(Ze,{className:"text-3xl",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.total})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(st,{className:"h-4 w-4"}),e.jsx("span",{children:ne?"Loading…":X.total===0?"No documents yet":Z?"In your context":"Auto-approved, AI-ready"})]})})]}),Z&&e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"Pending Approvals"}),e.jsx(Ze,{className:"text-3xl text-amber-600",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.pending})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Yn,{className:"h-4 w-4"}),e.jsx("span",{children:"Awaiting approval"})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"AI Ready"}),e.jsx(Ze,{className:"text-3xl text-green-600",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.approved})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Qn,{className:"h-4 w-4"}),e.jsx("span",{children:ne?"Loading…":X.total===0?"Nothing to evaluate yet":"Approved for AI"})]})})]}),e.jsxs(Ie,{children:[e.jsxs(Xe,{className:"pb-2",children:[e.jsx(Je,{children:"Your Review Queue"}),e.jsx(Ze,{className:"text-3xl text-blue-600",children:ne?e.jsx(jt,{className:"h-8 w-12"}):X.reviewable})]}),e.jsx(et,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(St,{className:"h-4 w-4"}),e.jsxs("span",{children:["Need your review",X.reviewQueue>X.reviewable&&e.jsxs("span",{className:"ml-1 text-xs",children:["(",X.reviewQueue," pending total,"," ",X.reviewQueue-X.reviewable," outside your scope)"]})]})]})})]})]})]}),e.jsxs($r,{value:De,onValueChange:He,className:"w-full min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 min-w-0",children:[e.jsxs(Mr,{className:"max-w-full justify-start overflow-x-auto",children:[e.jsx(Le,{value:"overview",children:"Overview"}),e.jsx(Le,{value:"documents",children:"Documents"}),Vt&&!I&&e.jsxs(Le,{value:"review",className:"gap-2",children:["Review Queue",Ue.length>0&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:Ue.length})]}),!I&&e.jsxs(Le,{value:"external-edits",className:"gap-2",children:["External Edits",$s>0&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-orange-100 text-orange-700",children:$s})]}),Z&&oe&&e.jsx(Le,{value:"stewards",children:"Stewards"}),(ve||Mt)&&e.jsx(Le,{value:"collaborators",children:"Collaborators"})]}),!I&&ke&&e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(k,{variant:"outline",size:"sm",className:"text-muted-foreground",onClick:()=>ht(!0),title:"Create a folder (nest with parent/child)",children:[e.jsx(ca,{className:"h-4 w-4 mr-1.5"}),"New Folder"]}),e.jsxs(zr,{modal:!1,children:[e.jsx(Vr,{asChild:!0,children:e.jsxs(k,{variant:"outline",size:"sm","data-testid":"nest-import-files",children:[e.jsx(la,{className:"h-3.5 w-3.5 mr-1.5"}),"Import"]})}),e.jsxs(Wr,{align:"end",children:[e.jsx(Kt,{onSelect:()=>{var t;return(t=Ht.current)==null?void 0:t.click()},children:"Files (.md / .html / .pdf)"}),e.jsx(Kt,{onSelect:()=>{var t;return(t=Us.current)==null?void 0:t.click()},"data-testid":"nest-upload-pdf",children:"Upload PDF (as a document)"}),e.jsx(Kt,{onSelect:()=>{var t;return(t=ks.current)==null?void 0:t.click()},children:"Whole vault (folder, keeps structure)"})]})]}),e.jsxs(k,{size:"sm",onClick:()=>w("new",{folder:De==="documents"&&Te?Te:void 0}),children:[e.jsx(Br,{className:"h-3.5 w-3.5 mr-1.5"}),"New Document"]})]})]}),e.jsx(Pe,{value:"overview",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ai,{initialLoad:ne||!we,stats:X,recentlyEdited:Xa,recentlyEditedCount:Ja,folderCount:sr,tocGroups:Vs,knownFolders:$t,isReadOnly:I,canEditDocs:ke,onOpenDocument:w,onOpenFolder:Ka})})}),e.jsx(Pe,{value:"documents",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ti,{nestId:s,initialSearch:$,initialTags:v,initialLoad:ne,loading:Et,nodes:F,census:x,knownFolders:$t,folderFilter:Te,setFolderFilter:Ds,expandedFolders:Es,loadingFolders:Ls,toggleFolderExpanded:Ia,expandFolder:Ya,caps:Qe,isAdmin:R,isOwner:i,roles:Dt,permission:Ne,currentEmail:O,myStewards:je,stewardshipEnabled:Z,allowSelfApprove:ot,primeTags:cs,visibility:q,hasRoleOnNode:Os,canReviewNode:qs,reviewQueue:fe,reviewableQueue:Ue,deletionRequests:Re,stats:X,onOpenDocument:w,onReview:Ae,onRefresh:_,onWithdrawDeletion:t=>void Ws(t),importInputRef:Ht})})}),Vt&&e.jsx(Pe,{value:"review",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(_i,{nestId:s,enabled:!me,reviewQueue:fe,reviewableQueue:Ue,myPendingSubmissions:er,pendingDeletions:l,canManage:ve,loading:Et,onRefresh:_,onOpenDocument:w,onSelectRequest:t=>{const a=F.find(d=>d.id===t.nodeId);if(a){Ae(a);return}w(t.nodeId)},onResolveDeletion:(t,a)=>E({request:t,action:a}),onWithdrawSubmission:t=>void nr(t)},s)})}),e.jsx(Pe,{value:"external-edits",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(ki,{nestId:s,enabled:!me,onOpenDocument:w,titleOf:t=>{var a;return(a=F.find(d=>d.id===t))==null?void 0:a.title}})})}),Z&&oe&&e.jsx(Pe,{value:"stewards",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ci,{nestId:s,canManage:oe&&!Qe.isReadOnly,currentUserEmail:O,onAssign:()=>Lt(!0),onRemove:_e,onEditRole:bs})})}),(ve||Mt)&&e.jsx(Pe,{value:"collaborators",className:"space-y-4",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"Loading..."}),children:e.jsx(Ri,{nestId:s,nestName:n,canManage:ve,canManageGovernance:oe,stewardshipEnabled:Z,currentUserEmail:O,callerPermission:Ne??void 0,onOpenSettings:()=>We(!0),onChanged:_})})})]}),De==="review"&&!Z&&!I&&oe&&e.jsxs(Ie,{className:"mt-4",children:[e.jsxs(Xe,{className:"pb-3",children:[e.jsxs(Ze,{className:"text-base flex items-center gap-2",children:[e.jsx(St,{className:"h-4 w-4"}),"Stewardship is off"]}),e.jsx(Je,{children:"New documents are auto-approved and immediately AI-ready."})]}),e.jsxs(et,{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Enable stewardship to require steward approval before documents become AI-ready. Versioning stays on either way."}),e.jsxs(k,{variant:"outline",size:"sm",className:"w-full",onClick:()=>We(!0),children:[e.jsx(fa,{className:"h-3.5 w-3.5 mr-2"}),"Open Settings"]})]})]}),ys&&e.jsx(Hr,{isOpen:ys,onClose:()=>Pt(!1),nestId:s,nestName:n,onManageKeys:j&&(()=>{Pt(!1),j()})}),Ns&&e.jsx(li,{isOpen:Ns,onClose:()=>Ss(!1),nestId:s,nestName:n,openMode:U==="open"}),Va&&e.jsx(ci,{nestId:s,nestName:n,stewardshipEnabled:Z,allowSelfApprove:ot,primeOnlyReview:Da,primeTags:cs,creatorIsReviewer:Ea,canManageStewardship:oe,onClose:()=>We(!1),onChanged:t=>{We(!1),ns(t.stewardshipEnabled),is(t.allowSelfApprove),os(t.primeOnlyReview),ds(t.primeTags),ls(t.creatorIsReviewer),_()}}),Ha&&e.jsx(Pn,{nestId:s,nestName:n,isImported:vs,open:!0,onOpenChange:pt,onDeleted:()=>{pt(!1),b()},onArchived:()=>{pt(!1),N.success(`"${n}" archived — find it under Archived`),b()}}),Qa&&e.jsx(Fn,{nestId:s,nestName:G,nestDescription:ft,open:!0,onOpenChange:Ft,onRenamed:(t,a)=>{a.nameChanged&&(T(t.name),J.current=t.name,V(null)),Ot(t.description),Ft(!1)}}),e.jsx(Fe,{open:Ba,onOpenChange:ht,children:e.jsxs(Oe,{className:"max-w-md",children:[e.jsx(qe,{children:e.jsx($e,{children:"New folder"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Name the folder. Nest it with a slash — e.g."," ",e.jsx("code",{className:"text-xs",children:"gtm/deals"}),". It starts empty; add documents to it whenever you like."]}),e.jsx(Sa,{autoFocus:!0,value:Cs,onChange:t=>Rs(t.target.value),onKeyDown:t=>{t.key==="Enter"&&Ts()},placeholder:"e.g. gtm/deals",className:"font-mono"}),pe.error?e.jsx("p",{className:"text-xs text-destructive","data-testid":"new-folder-error",children:pe.error}):pe.rewritten&&pe.path?e.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"new-folder-preview",children:["Will be created as"," ",e.jsx("code",{className:"font-mono",children:pe.path})]}):null,e.jsxs(at,{children:[e.jsx(k,{variant:"ghost",onClick:()=>ht(!1),children:"Cancel"}),e.jsxs(k,{onClick:()=>void Ts(),disabled:_s||!pe.path||!!pe.error,children:[_s?e.jsx(be,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ca,{className:"h-4 w-4 mr-2"}),"Create folder"]})]})]})}),e.jsx(Fe,{open:Tt,onOpenChange:ut,children:e.jsxs(Oe,{className:"sm:max-w-[520px]",children:[e.jsxs(qe,{children:[e.jsx($e,{children:"Public Docs Reader Mode"}),e.jsx(kt,{children:"A clean, read-only docs view for people who can only read this nest. Owners, editors and reviewers keep the full authoring UI, and reader mode grants no access on its own."})]}),e.jsxs("div",{className:"rounded-lg border p-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(se,{className:"text-sm font-medium",children:"Reader mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xe?"Read-only visitors get the docs reader.":"Everyone gets the standard nest view."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Ve&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),e.jsx(tt,{checked:xe,onCheckedChange:()=>void hr(),disabled:Ve,"aria-label":"Toggle Public Docs Reader Mode"})]})]}),xe&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsx(se,{className:"text-sm font-medium",children:"Home document"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Reader mode opens on this document and keeps it in the side pane. Left unset, it resolves one by convention (welcome / index / readme / home / overview)."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm",children:he?Pa??"Loading…":e.jsx("span",{className:"text-muted-foreground",children:"Resolved by convention"})}),e.jsx(k,{variant:"outline",size:"sm",onClick:()=>gs(!0),disabled:Ve,children:he?"Change":"Choose"}),he&&e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>void Hs(null),disabled:Ve,children:"Clear"})]})]}),e.jsxs(at,{children:[xe&&e.jsxs(k,{variant:"outline",className:"mr-auto gap-1.5",onClick:()=>{ut(!1),fs(!0)},children:[e.jsx(Qr,{className:"h-3.5 w-3.5"}),"Preview as reader"]}),e.jsx(k,{variant:"outline",onClick:()=>ut(!1),children:"Done"})]})]})}),xs&&e.jsx(fn,{isOpen:xs,onClose:()=>gs(!1),nestId:s,title:"Choose the reader home document",description:"Reader mode opens on this document and keeps it in the side pane. Close without picking to resolve one by convention (welcome / index / readme / home / overview).",onSelect:t=>{mt(t.title),Hs(t.id)}}),e.jsx(kn,{open:La,onOpenChange:_t,children:e.jsxs(Cn,{children:[e.jsxs(Rn,{children:[e.jsx(_n,{children:Wt.title}),e.jsx(An,{children:Wt.body})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(se,{htmlFor:"nest-public-description",className:"text-xs",children:(ft??"").trim()?"Description readers will see":"This nest has no description — readers will only see its name. Add one? (optional)"}),e.jsx(On,{id:"nest-public-description",value:hs,onChange:t=>ps(t.target.value),placeholder:"What this nest is for, and who it's meant for",rows:2,"data-testid":"nest-public-description"})]}),e.jsxs(Tn,{children:[e.jsx(Dn,{children:"Cancel"}),e.jsx(En,{onClick:()=>void mr(),children:Wt.confirm})]})]})}),js&&e.jsx(ja,{isOpen:js,onClose:()=>Lt(!1),nestId:s,onSubmit:or,onSync:async()=>{await Ur(s),await _()}}),Be&&e.jsx(ja,{isOpen:!!Be,steward:Be,nestId:s,onClose:()=>bs(null),onSubmit:lr}),ee&&e.jsx(Ei,{node:ee,nestId:s,onApprove:ar,onReject:rr,onClose:()=>Ae(null),onOpenDocument:t=>{Ae(null),w(t)}}),ie&&e.jsx(Yt,{open:!0,onOpenChange:t=>!t&&_e(null),title:"Remove this steward?",description:"They lose approval rights immediately. The user account and any documents stay intact.",confirmLabel:"Remove steward",destructive:!0,onConfirm:ir}),Ct&&e.jsx(Yt,{open:!0,onOpenChange:it,title:`Request removal of "${n}"`,description:"A nest owner or admin reviews this. Nothing is removed yet — ask for the nest to be archived (reversible, nothing deleted) or deleted outright.",label:"Why should it be removed?",placeholder:"e.g. project wound down, superseded by another nest",confirmLabel:"Request deletion",secondaryLabel:"Request archive",onSecondary:async t=>{await na(s,"nest_archive",s,t),N.success("Archive requested — a nest admin will review it"),_()},onConfirm:async t=>{await na(s,"nest",s,t),N.success("Deletion requested — a nest admin will review it"),_()}}),c&&e.jsx(Yt,{open:!0,onOpenChange:t=>!t&&E(null),title:c.action!=="delete"?"Reject this request":c.request.targetType==="nest_archive"?`Archive "${c.request.title||c.request.nodeId}"?`:`Delete "${c.request.title||c.request.nodeId}"?`,description:c.action!=="delete"?`${c.request.requestedBy} asked for this: "${c.request.reason}". The document stays; your note is the record.`:c.request.targetType==="nest_archive"?`${c.request.requestedBy} asked for this: "${c.request.reason}". The nest goes read-only and leaves the dashboard; nothing is deleted and you can restore it.`:`${c.request.requestedBy} asked for this: "${c.request.reason}". Deleting cannot be undone.`,label:c.action==="decline"?"Why are you rejecting?":void 0,placeholder:"e.g. still referenced by onboarding",confirmLabel:c.action!=="delete"?"Reject":c.request.targetType==="nest_archive"?"Archive nest":"Delete document",destructive:c.action==="delete"&&c.request.targetType!=="nest_archive",onConfirm:c.action==="delete"?cr:dr})]})}function Ei({node:s,nestId:n,onApprove:i,onReject:o,onClose:u,onOpenDocument:b}){var m;const[p,S]=r.useState(null),w=as(),{data:g,isLoading:j}=ss({...H.node(n,s.id),enabled:!s.content}),$=s.content||((m=g==null?void 0:g.node)==null?void 0:m.content)||"",v=async(P,C)=>{S(null);try{const{nodes:R}=await w.fetchQuery(H.nodes(n)),Q=vn(R,P,!1);if(Q.kind==="navigate"){b(Q.node.id);return}S(`"${P}" doesn't exist in this nest. Reviewers can't create new documents — ask an editor to add it.`)}catch(R){console.error("[NestView] wiki-link lookup failed",n,P,R),S("Couldn't look up that document — try again later.")}};return e.jsx(Fe,{open:!0,onOpenChange:u,children:e.jsxs(Oe,{className:"sm:max-w-[600px] max-h-[80vh] flex flex-col",children:[e.jsx(qe,{children:e.jsx($e,{children:s.title})}),p&&e.jsx("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:bg-amber-950 dark:text-amber-200",children:p}),e.jsx("div",{className:"flex-1 overflow-y-auto rounded-md",children:$?e.jsx(gn,{content:$,onChange:()=>{},editable:!1,nestId:n,onWikiLinkClick:v},s.id):j?e.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading content…"}):e.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"(no content)"})}),e.jsx(at,{children:e.jsx(Wn,{documentTitle:s.title,version:s.version||1,onApprove:i,onReject:o})})]})})}const oo=Object.freeze(Object.defineProperty({__proto__:null,NestView:Di,NodeTypeIcon:ni},Symbol.toStringTag,{value:"Module"}));export{Yn as C,no as D,Xn as F,ni as N,ro as S,io as T,Ni as a,so as b,ai as c,ii as d,oo as e,oi as f,ao as t,Si as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,L as C,az as d,bx as i,F,B as P,aP as c,bz as B,e as T,ac as p}from"./index-B5hLclEq.js";import{C as u,N as h,t as j,b as $}from"./NestView-DwIagxwJ.js";import{C as a,d as l,a as g,c as N,b as z}from"./card-UDyMRcps.js";import"./MarkdownEditor-Dfk5uIE5.js";import"./zap-BcsKR0ef.js";import"./triangle-alert-CsYGyfGZ.js";import"./scroll-area-CbcH6yrZ.js";import"./select-DrL0mpRN.js";import"./index-A0_ymcqL.js";import"./arrow-left-BAgIocLn.js";import"./trash-2-B4hRXo-p.js";import"./x-qxt1WrUi.js";import"./dates-BCxbm4_q.js";import"./chevron-left-XR4ReJ9Z.js";import"./alert-dialog-4SiLKlz8.js";import"./NestPageHeader-yOK-OIYZ.js";import"./count-skeleton-DBWCDhRy.js";import"./folder-input-BAwK9tFL.js";import"./PersonCombobox-D350WlrJ.js";import"./tag-Br_y1f00.js";import"./refresh-cw-CsCtmWwX.js";import"./user-plus-4CTYEkd3.js";import"./ReviewActions-BXDTDPp1.js";import"./circle-check-CSkZUEFK.js";import"./circle-x-in2o3aHU.js";import"./ReasonDialog-CN3ECAnQ.js";import"./settings-EY4A_DYv.js";function le({initialLoad:f,stats:b,recentlyEdited:o,recentlyEditedCount:y,folderCount:m,tocGroups:w,knownFolders:n,isReadOnly:v,canEditDocs:x,onOpenDocument:r,onOpenFolder:k}){return e.jsx(e.Fragment,{children:f?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(C,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2",children:[e.jsx(a,{className:"border-muted/60",children:e.jsxs(l,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"rounded-md bg-blue-500/10 text-blue-600 p-2",children:e.jsx(d,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-semibold leading-none",children:m}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Folder",m===1?"":"s"]})]})]})}),e.jsx(a,{className:"border-muted/60",children:e.jsxs(l,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"rounded-md bg-amber-500/10 text-amber-600 p-2",children:e.jsx(u,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-semibold leading-none",children:y}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Edited this week"})]})]})})]}),o.length>0&&e.jsxs(a,{children:[e.jsx(g,{className:"pb-3",children:e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(u,{className:"h-4 w-4 text-muted-foreground"}),"Recently edited"]})}),e.jsx(l,{className:"pt-0",children:e.jsx("ul",{className:"divide-y",children:o.map(t=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>r(t.id),className:"w-full flex items-center gap-3 py-2 px-1 -mx-1 rounded hover:bg-muted/50 text-left group",children:[e.jsx(h,{type:t.type}),e.jsx("span",{className:"text-sm truncate flex-1",children:t.title||t.id}),(()=>{const s=j(t.type||"document");return s?e.jsx("span",{className:`shrink-0 rounded px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide ${s.cls}`,title:s.title,children:s.label}):null})(),t.updated_at&&e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:$(t.updated_at)}),e.jsx(i,{className:"h-4 w-4 text-muted-foreground/40 group-hover:text-muted-foreground shrink-0"})]})},t.id))})})]}),e.jsxs(a,{children:[e.jsxs(g,{className:"pb-3",children:[e.jsxs(N,{className:"text-base flex items-center gap-2",children:[e.jsx(d,{className:"h-4 w-4 text-muted-foreground"}),"Contents"]}),e.jsx(z,{children:"Browse documents grouped by folder."})]}),e.jsx(l,{className:"pt-0",children:b.total===0&&n.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(F,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No documents yet."}),!v&&x&&e.jsxs(P,{className:"mt-3",size:"sm",onClick:()=>r("new"),children:[e.jsx(c,{className:"h-4 w-4 mr-2"}),"New Document"]})]}):e.jsx(B,{className:"space-y-1",groups:w,known:n,renderFolder:t=>e.jsxs("button",{type:"button",onClick:()=>k(t.path),className:"flex items-center gap-2 py-1 group/folder rounded px-1 -mx-1 hover:bg-muted/60 w-full text-left",title:`Browse ${p(t.path)} in Documents`,children:[e.jsx(d,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm font-medium group-hover/folder:underline",children:t.label}),e.jsx(T,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5",children:t.total}),e.jsx(i,{className:"h-3.5 w-3.5 text-muted-foreground/40 group-hover/folder:text-muted-foreground"}),x&&e.jsx("span",{role:"button",tabIndex:0,className:"rounded p-0.5 text-muted-foreground opacity-0 group-hover/folder:opacity-100 hover:text-primary hover:bg-primary/10",title:`New document in ${p(t.path)}`,onClick:s=>{s.stopPropagation(),r("new",{folder:t.path})},onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),r("new",{folder:t.path}))},children:e.jsx(c,{className:"h-3.5 w-3.5"})})]}),renderDoc:t=>e.jsxs("button",{onClick:()=>r(t.id),className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted/50 text-left group min-w-0 w-full",title:t.title||t.id,children:[e.jsx(h,{type:t.type,className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm truncate flex-1",children:t.title||t.id}),(()=>{const s=j(t.type||"document");return s?e.jsx("span",{className:`shrink-0 rounded px-1 py-px text-[9px] font-semibold uppercase tracking-wide ${s.cls}`,title:s.title,children:s.label}):null})(),e.jsx(i,{className:"h-3.5 w-3.5 text-muted-foreground/40 group-hover:text-muted-foreground shrink-0"})]})})})]})]})})}export{le as OverviewTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as o,S as C,i as L,j as r,I as M,s as v}from"./index-B5hLclEq.js";const N=200;function S({value:u,onChange:d,onSubmit:c,placeholder:y="name@company.com",disabled:x,exclude:h,id:D,className:E,testId:b}){const[s,l]=o.useState(!1),[a,i]=o.useState(-1),g=o.useRef(null),[j,k]=o.useState(u.trim().toLowerCase());o.useEffect(()=>{const e=setTimeout(()=>k(u.trim().toLowerCase()),N);return()=>clearTimeout(e)},[u]);const{data:f}=C({...L.peopleSuggest(j),enabled:s&&!x}),w=o.useMemo(()=>new Set((h??[]).map(e=>e.trim().toLowerCase())),[h]),n=o.useMemo(()=>((f==null?void 0:f.people)??[]).filter(e=>!w.has(e.email.trim().toLowerCase())),[f,w]);o.useEffect(()=>i(-1),[n.length]),o.useEffect(()=>{if(!s)return;const e=t=>{var m;(m=g.current)!=null&&m.contains(t.target)||l(!1)};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[s]);const p=e=>{d(e),l(!1),i(-1)};return r.jsxs("div",{ref:g,className:v("relative",E),children:[r.jsx(M,{id:D,type:"text",inputMode:"email",autoComplete:"off",placeholder:y,value:u,disabled:x,"data-testid":b,role:"combobox","aria-expanded":s,"aria-autocomplete":"list",onChange:e=>{d(e.target.value),l(!0)},onFocus:()=>l(!0),onKeyDown:e=>{if(e.key==="Escape"&&s){e.stopPropagation(),l(!1);return}if(!s||n.length===0){e.key==="Enter"&&c&&(e.preventDefault(),c());return}if(e.key==="ArrowDown")e.preventDefault(),i(t=>(t+1)%n.length);else if(e.key==="ArrowUp")e.preventDefault(),i(t=>t<=0?n.length-1:t-1);else if(e.key==="Enter"){const t=a>=0?n[a]:void 0;t?(e.preventDefault(),p(t.email)):c&&(e.preventDefault(),c())}else if(e.key==="Tab"&&a>=0){const t=n[a];t&&(e.preventDefault(),p(t.email))}}}),s&&n.length>0&&r.jsx("ul",{role:"listbox",className:"absolute z-50 mt-1 max-h-56 w-full overflow-auto rounded-md border bg-popover py-1 text-popover-foreground shadow-md",children:n.map((e,t)=>r.jsx("li",{children:r.jsxs("button",{type:"button",role:"option","aria-selected":t===a,onMouseDown:m=>{m.preventDefault(),p(e.email)},onMouseEnter:()=>i(t),className:v("flex w-full flex-col items-start px-3 py-1.5 text-left text-sm",t===a?"bg-accent text-accent-foreground":""),children:[r.jsx("span",{className:"truncate font-medium",children:e.name||e.email.split("@")[0]}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:e.email})]})},e.email))})]})}export{S as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,j as s,D as F,x as T,y as H,z as L,G as $,J as z,A as G,K as J,a as K,H as q,B as m,L as y}from"./index-B5hLclEq.js";import{T as I}from"./scroll-area-CbcH6yrZ.js";import{f as N}from"./dates-BCxbm4_q.js";function Q({open:w,onOpenChange:u,title:C,description:x,label:t,optionalReason:A,placeholder:R,confirmLabel:k,destructive:B,priorDecline:a,secondaryLabel:h,onSecondary:j,onConfirm:S}){const[r,n]=c.useState(""),[o,g]=c.useState(null),i=o!==null,[f,l]=c.useState(null),v=e=>{i||(e||(n(""),l(null)),u(e))},p=async(e,E)=>{g(e),l(null);try{await E(r.trim()),n(""),u(!1)}catch(d){l((d==null?void 0:d.message)||"Something went wrong")}finally{g(null)}},D=()=>p("confirm",S),b=i||!!t&&!A&&!r.trim();return s.jsx(F,{open:w,onOpenChange:v,children:s.jsxs(T,{className:"sm:max-w-[440px]",children:[s.jsxs(H,{children:[s.jsx(L,{children:C}),x&&s.jsx($,{children:x})]}),a&&s.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 space-y-1","data-testid":"reason-dialog-prior-decline",children:[s.jsxs("p",{className:"font-medium",children:["Rejected",a.resolvedBy?` by ${a.resolvedBy}`:"",N(a.resolvedAt)?` · ${N(a.resolvedAt)}`:""]}),a.resolutionNote&&s.jsxs("p",{children:["“",a.resolutionNote,"”"]}),a.reason&&s.jsxs("p",{className:"text-amber-800/80",children:["Asked before: “",a.reason,"”"]})]}),t&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(z,{htmlFor:"reason-dialog-input",children:t}),s.jsx(I,{id:"reason-dialog-input",autoFocus:!0,rows:3,value:r,placeholder:R,onChange:e=>n(e.target.value),"data-testid":"reason-dialog-input"})]}),f&&s.jsxs(G,{variant:"destructive",children:[s.jsx(J,{className:"h-4 w-4"}),s.jsx(K,{children:f})]}),s.jsxs(q,{children:[s.jsx(m,{variant:"outline",onClick:()=>v(!1),disabled:i,children:"Cancel"}),h&&j&&s.jsxs(m,{variant:"outline",onClick:()=>p("secondary",j),disabled:b,"data-testid":"reason-dialog-secondary",children:[o==="secondary"&&s.jsx(y,{className:"h-4 w-4 mr-2 animate-spin"}),h]}),s.jsxs(m,{onClick:D,disabled:b,variant:B?"destructive":"default","data-testid":"reason-dialog-confirm",children:[o==="confirm"&&s.jsx(y,{className:"h-4 w-4 mr-2 animate-spin"}),k]})]})]})})}export{Q as R};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as b,r as o,j as e,B as i,D as C,x as w,y as A,z as y,G as k,A as D,K as T,a as R,J as S,H as E,L}from"./index-B5hLclEq.js";import{T as _}from"./scroll-area-CbcH6yrZ.js";import{C as v}from"./circle-check-CSkZUEFK.js";import{C as j}from"./circle-x-in2o3aHU.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 F=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],P=b("message-square",F),$="border-green-200 text-green-700 hover:bg-green-50 hover:text-green-800",B="border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800";function z({documentTitle:d,version:h,onApprove:u,onReject:g,className:f}){const[s,c]=o.useState(null),[r,p]=o.useState(""),[a,m]=o.useState(!1),[x,t]=o.useState(null),N=async()=>{if(s){if(s==="reject"&&!r.trim()){t("Please provide feedback explaining why this document is being rejected.");return}m(!0),t(null);try{s==="approve"?await u(r||void 0):await g(r),l()}catch(n){t(n instanceof Error?n.message:`Failed to ${s} document`)}finally{m(!1)}}},l=()=>{a||(c(null),p(""),t(null))};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:f,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(i,{variant:"outline",className:$,onClick:()=>c("approve"),children:[e.jsx(v,{className:"h-4 w-4 mr-2"})," Approve"]}),e.jsxs(i,{variant:"outline",className:B,onClick:()=>c("reject"),children:[e.jsx(j,{className:"h-4 w-4 mr-2"})," Reject"]})]})}),e.jsx(C,{open:!!s,onOpenChange:l,children:e.jsxs(w,{className:"sm:max-w-[425px]",children:[e.jsxs(A,{children:[e.jsx(y,{children:s==="approve"?"Approve Document":"Reject Document"}),e.jsx(k,{children:s==="approve"?`Approve "${d}" (v${h}). This version will become the official AI context for this document.`:`Reject "${d}" (v${h}). The author will be notified with your feedback.`})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[x&&e.jsxs(D,{variant:"destructive",children:[e.jsx(T,{className:"h-4 w-4"}),e.jsx(R,{children:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(S,{htmlFor:"review-note",children:[e.jsx(P,{className:"h-4 w-4 inline mr-2"}),s==="approve"?"Note (optional)":"Feedback (required)"]}),e.jsx(_,{id:"review-note",placeholder:s==="approve"?"Add any notes for the author...":"Explain what changes are needed...",value:r,onChange:n=>p(n.target.value),disabled:a,className:"min-h-[100px]"}),s==="reject"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Providing clear feedback helps authors make the right changes."})]})]}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:l,disabled:a,children:"Cancel"}),e.jsxs(i,{onClick:N,disabled:a,className:s==="approve"?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:[a?e.jsx(L,{className:"h-4 w-4 mr-2 animate-spin"}):s==="approve"?e.jsx(v,{className:"h-4 w-4 mr-2"}):e.jsx(j,{className:"h-4 w-4 mr-2"}),s==="approve"?"Approve":"Reject"]})]})]})})]})}export{$ as A,P as M,z as R,B as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,L as ae,B as d,e as E,cc as X,cd as Z,bx as O,F as le,s as ce,u as de,r as z,co as q,i as me,f as P,ct as xe,a8 as he}from"./index-B5hLclEq.js";import{C as Q,u as pe,a as ue}from"./NestView-DwIagxwJ.js";import"./select-DrL0mpRN.js";import{f as re}from"./scroll-area-CbcH6yrZ.js";import{C as $,a as A,c as R,d as S,b as W}from"./card-UDyMRcps.js";import{p as ge}from"./dates-BCxbm4_q.js";import{R as ee}from"./refresh-cw-CsCtmWwX.js";import{C as fe}from"./circle-check-CSkZUEFK.js";import{C as je}from"./corner-down-right-CuxZWscX.js";import{M as ve}from"./ReviewActions-BXDTDPp1.js";import{T as te}from"./triangle-alert-CsYGyfGZ.js";import{R as ye}from"./ReasonDialog-CN3ECAnQ.js";import{S as Ne}from"./send-CvAgOUPG.js";import{T as be}from"./trash-2-B4hRXo-p.js";import"./MarkdownEditor-Dfk5uIE5.js";import"./zap-BcsKR0ef.js";import"./index-A0_ymcqL.js";import"./arrow-left-BAgIocLn.js";import"./x-qxt1WrUi.js";import"./chevron-left-XR4ReJ9Z.js";import"./alert-dialog-4SiLKlz8.js";import"./NestPageHeader-yOK-OIYZ.js";import"./count-skeleton-DBWCDhRy.js";import"./folder-input-BAwK9tFL.js";import"./PersonCombobox-D350WlrJ.js";import"./tag-Br_y1f00.js";import"./user-plus-4CTYEkd3.js";import"./settings-EY4A_DYv.js";import"./circle-x-in2o3aHU.js";const we={low:{label:"Low",className:"bg-gray-100 text-gray-600"},normal:{label:"Normal",className:"bg-blue-100 text-blue-600"},high:{label:"High",className:"bg-amber-100 text-amber-600",icon:te},urgent:{label:"Urgent",className:"bg-red-100 text-red-600",icon:te}};function se(c){const x=ge(c);if(!x)return"";const r=new Date().getTime()-x.getTime();return r<6e4?"Just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:r<6048e5?`${Math.floor(r/864e5)}d ago`:x.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ke({requests:c,loading:x=!1,error:h=null,className:r,showHeader:j=!0,onRefresh:p,onSelect:N,comments:T,onSelectComment:v,selectedNodeIds:u,onToggleSelect:F}){const g=T!==void 0,M=g?[...c.map(a=>({kind:"change",at:a.requestedAt,id:a.id,request:a})),...(T??[]).map(a=>({kind:"comment",at:a.createdAt,id:a.id,comment:a}))].sort((a,s)=>s.at.localeCompare(a.at)||s.id.localeCompare(a.id)):c.map(a=>({kind:"change",at:a.requestedAt,id:a.id,request:a}));return x?e.jsxs($,{className:r,children:[j&&e.jsx(A,{className:"pb-3",children:e.jsx(R,{className:"text-lg",children:"Review Queue"})}),e.jsx(S,{children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ae,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):h?e.jsxs($,{className:r,children:[j&&e.jsx(A,{className:"pb-3",children:e.jsx(R,{className:"text-lg",children:"Review Queue"})}),e.jsx(S,{children:e.jsxs("div",{className:"text-center py-4 text-sm text-destructive",children:[h,p&&e.jsx(d,{variant:"ghost",size:"sm",onClick:p,className:"ml-2",children:e.jsx(ee,{className:"h-4 w-4"})})]})})]}):e.jsxs($,{className:r,children:[j&&e.jsx(A,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-lg",children:g?"Activity":"Review Queue"}),e.jsx(W,{children:g?"Changes awaiting approval and new comments":"Documents awaiting your approval"})]}),p&&e.jsx(d,{variant:"ghost",size:"icon",onClick:p,className:"h-8 w-8",children:e.jsx(ee,{className:"h-4 w-4"})})]})}),e.jsx(S,{children:M.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(fe,{className:"h-10 w-10 text-green-500 mb-3"}),e.jsx("p",{className:"text-sm font-medium",children:"Nothing needs your review"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g?"No changes or comments waiting on you":"No documents awaiting your approval"})]}):e.jsx("div",{className:"space-y-2",children:M.map(a=>{var B,D;if(a.kind==="comment"){const n=a.comment;return e.jsxs("div",{"data-testid":"feed-comment-item",className:"flex items-start gap-3 p-3 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors group",onClick:()=>v==null?void 0:v(n),children:[n.isReply?e.jsx(je,{className:"h-5 w-5 text-amber-500 flex-shrink-0 mt-0.5"}):e.jsx(ve,{className:"h-5 w-5 text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:n.title||n.nodeId}),e.jsx(E,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-100 text-amber-700",children:n.isReply?"Reply":"Comment"}),!n.resolved&&e.jsx(E,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-amber-400 text-amber-700",children:"Unresolved"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"h-4 w-4",children:e.jsx(Z,{className:"text-[8px]",children:((B=n.author[0])==null?void 0:B.toUpperCase())||"?"})}),e.jsx("span",{children:n.author})]}),e.jsx("span",{children:"•"}),e.jsx(Q,{className:"h-3 w-3"}),e.jsx("span",{children:se(n.createdAt)})]}),n.snippet&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:["“",n.snippet,"”"]})]}),e.jsx(O,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity mt-1"})]},`comment-${n.id}`)}const s=a.request,b=we[s.priority],w=b.icon;return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors group",onClick:()=>N==null?void 0:N(s),"data-testid":"review-queue-row",children:[F&&s.canReview!==!1&&e.jsx(re,{checked:(u==null?void 0:u.has(s.nodeId))??!1,onCheckedChange:()=>F(s.nodeId),onClick:n=>n.stopPropagation(),"aria-label":`Select ${s.title||s.nodeId}`,"data-testid":"review-queue-select"}),e.jsx(le,{className:"h-5 w-5 text-blue-500 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:s.title||s.nodeId}),e.jsxs(E,{variant:"secondary",className:ce("text-[10px] px-1.5 py-0",b.className),children:[w&&e.jsx(w,{className:"h-3 w-3 mr-1"}),b.label]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{children:["v",s.version]}),e.jsx("span",{children:"•"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"h-4 w-4",children:e.jsx(Z,{className:"text-[8px]",children:((D=s.requestedBy[0])==null?void 0:D.toUpperCase())||"?"})}),e.jsx("span",{children:s.requestedBy})]}),e.jsx("span",{children:"•"}),e.jsx(Q,{className:"h-3 w-3"}),e.jsx("span",{children:se(s.requestedAt)})]}),s.requestNote&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:["“",s.requestNote,"”"]})]}),e.jsx(O,{className:"h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},s.id)})})})]})}function et({nestId:c,enabled:x,reviewQueue:h,reviewableQueue:r,myPendingSubmissions:j,pendingDeletions:p,canManage:N,loading:T,onRefresh:v,onOpenDocument:u,onSelectRequest:F,onResolveDeletion:g,onWithdrawSubmission:M}){var Y,G,J;const a=de(),[s,b]=z.useState("all"),w=pe(c,x),[B,D]=z.useState([]),[n,K]=z.useState(!1),U=(((Y=w.data)==null?void 0:Y.items)??[]).filter(t=>t.type==="comment"),I=(()=>{const t=new Set(U.map(o=>o.id));return[...U,...B.filter(o=>!t.has(o.id))]})(),_=((J=(G=w.data)==null?void 0:G.counts)==null?void 0:J.comments)??U.length,ne=async()=>{K(!0);try{const o=(await a.fetchQuery(me.feed(c,"comments",ue,I.length))).items.filter(l=>l.type==="comment");D(l=>{const C=new Set(l.map(y=>y.id));return[...l,...o.filter(y=>!C.has(y.id))]})}catch(t){console.error("[ReviewTab] getNestFeed load-more failed",c,t),P.error((t==null?void 0:t.message)||"Failed to load more comments")}finally{K(!1)}},[i,k]=z.useState(new Set),[m,L]=z.useState(null),ie=async(t,o)=>{const l=[...i],{succeeded:C,failed:y,results:V}=await xe(c,t,l,o||void 0),H=t==="approve"?"approved":"rejected";if(y===0)P.success(`${C} document${C===1?"":"s"} ${H}`),k(new Set);else{const oe=[...new Set(V.filter(f=>!f.ok).map(f=>f.error||"Unknown reason"))];P.warning(`${C} ${H}, ${y} could not be`,{description:oe.join(" "),duration:1e4}),k(new Set(V.filter(f=>!f.ok).map(f=>f.nodeId)))}L(null),a.invalidateQueries({queryKey:he.nest(c)}),v()};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-1.5","data-testid":"feed-filter-chips",children:[{key:"all",label:"All"},{key:"changes",label:`Changes (${r.length})`},{key:"comments",label:`Comments (${_})`}].map(t=>e.jsx("button",{type:"button",onClick:()=>b(t.key),className:`rounded-full border px-3 py-1 text-xs font-medium transition-colors ${s===t.key?"border-primary bg-primary text-primary-foreground":"border-border text-muted-foreground hover:bg-muted hover:text-foreground"}`,"data-testid":`feed-filter-${t.key}`,children:t.label},t.key))}),s!=="comments"&&j.length>0&&e.jsxs($,{children:[e.jsxs(A,{className:"pb-3",children:[e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4 text-blue-600"}),"Submitted by you — awaiting review"]}),e.jsx(W,{children:"Your edits are awaiting review by another user. You can't approve your own work due to separation of duties."})]}),e.jsx(S,{className:"space-y-2",children:j.map(t=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border px-3 py-2 text-sm hover:bg-muted/50",children:[e.jsx("button",{onClick:()=>u(t.nodeId),className:"flex-1 min-w-0 text-left truncate",children:t.title||t.nodeId}),e.jsx(E,{variant:"secondary",className:"text-[10px] shrink-0",children:"Awaiting review"}),e.jsx(d,{size:"sm",variant:"ghost",className:"shrink-0 h-7 px-2 text-muted-foreground",title:"Withdraw this submission and return the document to Draft",onClick:()=>M(t.nodeId),children:"Withdraw"})]},t.id))})]}),N&&p.length>0&&e.jsxs($,{children:[e.jsxs(A,{className:"pb-3",children:[e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4 text-destructive"}),"Deletion requests"]}),e.jsx(W,{children:"Documents flagged as stale. Delete them, or reject with a note."})]}),e.jsx(S,{className:"space-y-2",children:p.map(t=>e.jsxs("div",{"data-testid":"deletion-request-item",className:"flex items-center gap-3 rounded-md border px-3 py-2 text-sm",children:[e.jsxs("button",{className:"flex-1 min-w-0 text-left",onClick:()=>u(t.nodeId),children:[e.jsxs("span",{className:"font-medium truncate block",children:[t.title||t.nodeId,t.targetType&&t.targetType!=="document"&&e.jsx("span",{className:"ml-2 rounded bg-muted px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:t.targetType==="folder"?"Folder":t.targetType==="nest_archive"?"Archive nest":"Nest"})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.requestedBy," — “",t.reason,"”"]})]}),e.jsx(d,{variant:"ghost",size:"sm",onClick:()=>g(t,"decline"),children:"Reject"}),e.jsx(d,{variant:"ghost",size:"sm",className:t.targetType==="nest_archive"?"":"text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>g(t,"delete"),children:t.targetType==="nest_archive"?"Approve":"Delete"})]},t.id))})]}),s!=="comments"&&r.length>1&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border bg-muted/40 px-3 py-2 text-sm",children:[e.jsx(re,{checked:i.size===0?!1:i.size===r.length?!0:"indeterminate",onCheckedChange:t=>k(t===!0?new Set(r.map(o=>o.nodeId)):new Set),"aria-label":"Select every document you can review","data-testid":"review-queue-select-all"}),e.jsx("span",{className:"text-muted-foreground",children:i.size>0?`${i.size} selected`:`Select all ${r.length}`}),i.size>q&&e.jsxs("span",{className:"text-destructive",children:["Up to ",q," at a time — deselect"," ",i.size-q,"."]}),i.size>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(d,{size:"sm",disabled:i.size>q,onClick:()=>L("approve"),"data-testid":"bulk-approve",children:["Approve ",i.size]}),e.jsxs(d,{size:"sm",variant:"outline",disabled:i.size>q,onClick:()=>L("reject"),"data-testid":"bulk-reject",children:["Reject ",i.size]}),e.jsx(d,{size:"sm",variant:"ghost",onClick:()=>k(new Set),children:"Clear"})]})]}),e.jsx(ke,{requests:s==="comments"?[]:r,selectedNodeIds:i,onToggleSelect:r.length>1?t=>k(o=>{const l=new Set(o);return l.has(t)?l.delete(t):l.add(t),l}):void 0,comments:s==="changes"?void 0:I,onSelectComment:t=>u(t.nodeId,{thread:t.threadId}),loading:T,onRefresh:v,onSelect:F}),s!=="changes"&&I.length<_&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(d,{variant:"outline",size:"sm",onClick:ne,disabled:n,"data-testid":"feed-load-more",children:[n?e.jsx(ae,{className:"h-4 w-4 mr-1.5 animate-spin"}):null,"Load more comments (",_-I.length," remaining)"]})}),s!=="comments"&&h.length>0&&r.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:h.length===1?"1 pending review in this nest, but it doesn't require your action — it's either outside your steward scope or was submitted by you.":`${h.length} pending reviews in this nest, but none require your action — they're either outside your steward scope or were submitted by you.`}),m&&e.jsx(ye,{open:!0,onOpenChange:t=>!t&&L(null),title:m==="approve"?`Approve ${i.size} document${i.size===1?"":"s"}?`:`Reject ${i.size} document${i.size===1?"":"s"}?`,description:m==="approve"?"Approving publishes each one. Anything you can't review, or that changed since this queue loaded, is reported back and left alone.":"Each author gets the same reason and the work goes back to them.",label:m==="reject"?"Why?":"Comment (optional)",optionalReason:m==="approve",placeholder:"Shared with every author in this batch",confirmLabel:m==="approve"?"Approve all":"Reject all",destructive:m==="reject",onConfirm:t=>ie(m,t)})]})}export{et as ReviewTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as w,j as e,L as S,s as j,bs as f,B as m,cc as k,cd as T,e as B,ah as F,ai as I,ak as U,am as L,ag as V,aa as P,F as H,S as W,i as q}from"./index-B5hLclEq.js";import{U as b}from"./user-plus-4CTYEkd3.js";import{E as M}from"./MarkdownEditor-Dfk5uIE5.js";import{T as Q}from"./trash-2-B4hRXo-p.js";import{T as $}from"./tag-Br_y1f00.js";import{S as G,a as J,b as K,c as O,d as g}from"./select-DrL0mpRN.js";import"./scroll-area-CbcH6yrZ.js";import{C as E,a as D,c as A,d as R,b as X}from"./card-UDyMRcps.js";import"./zap-BcsKR0ef.js";import"./triangle-alert-CsYGyfGZ.js";import"./index-A0_ymcqL.js";import"./arrow-left-BAgIocLn.js";import"./x-qxt1WrUi.js";const Y={document:{label:"Document",icon:H},tag:{label:"Tag",icon:$},nest:{label:"Nest",icon:P}};function z({stewards:t,loading:n=!1,showScope:N=!1,className:l,onAddSteward:r,onRemove:c,onEditRole:i,compact:o=!1,currentUserEmail:x}){const[h,d]=w.useState(null),v=(x||"").toLowerCase(),p=async s=>{if(c){d(s);try{await c(s)}finally{d(null)}}},a=s=>{const C=Y[s.scope];let u="";return s.scope==="tag"?u=s.tagName||"":s.scope==="document"&&(u=s.nodeTitle||s.nodePattern||""),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(C.icon,{className:"h-3 w-3"}),e.jsx("span",{children:C.label}),u&&e.jsxs("span",{className:"opacity-75",children:[": ",u]})]})},y=s=>(s.userEmail[0]||"?").toUpperCase();return n?e.jsx("div",{className:j("flex items-center justify-center py-4",l),children:e.jsx(S,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:j("text-center py-4",l),children:[e.jsx(f,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No stewards assigned"}),r&&e.jsxs(m,{variant:"outline",size:"sm",onClick:r,children:[e.jsx(b,{className:"h-4 w-4 mr-2"}),"Assign Steward"]})]}):o?e.jsxs("div",{className:j("flex items-center gap-1",l),children:[e.jsx(f,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex -space-x-2",children:t.slice(0,3).map(s=>e.jsx(k,{className:"h-6 w-6 border-2 border-background",children:e.jsx(T,{className:"text-[10px]",children:y(s)})},s.id))}),t.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",t.length-3]}),r&&e.jsx(m,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:r,children:e.jsx(b,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:j("space-y-2",l),children:[t.map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg border bg-card",children:[e.jsx(k,{className:"h-8 w-8",children:e.jsx(T,{children:y(s)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s.userEmail}),N&&a(s),e.jsx("div",{className:"flex items-center gap-1 mt-1",children:e.jsx(B,{variant:"secondary",className:"text-[10px] px-1.5 py-0 capitalize",children:s.role})})]}),(i||c)&&s.userEmail.toLowerCase()!==v&&e.jsxs(F,{modal:!1,children:[e.jsx(I,{asChild:!0,children:e.jsx(m,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:h===s.id,children:h===s.id?e.jsx(S,{className:"h-4 w-4 animate-spin"}):e.jsx(M,{className:"h-4 w-4"})})}),e.jsxs(U,{align:"end",children:[i&&e.jsxs(L,{onClick:()=>i(s),children:[e.jsx(V,{className:"h-4 w-4 mr-2"}),"Edit Role"]}),c&&e.jsxs(L,{className:"text-destructive",onClick:()=>p(s.id),children:[e.jsx(Q,{className:"h-4 w-4 mr-2"}),"Remove"]})]})]})]},s.id)),r&&e.jsxs(m,{variant:"outline",className:"w-full",onClick:r,children:[e.jsx(b,{className:"h-4 w-4 mr-2"}),"Add Steward"]})]})}function xe({nestId:t,canManage:n,currentUserEmail:N,onAssign:l,onRemove:r,onEditRole:c}){var p;const i=W(q.stewards(t)),o=((p=i.data)==null?void 0:p.stewards)??[],[x,h]=w.useState("all"),[d,v]=w.useState("all");return e.jsxs(e.Fragment,{children:[e.jsxs(E,{className:"border-blue-200 bg-blue-50/40",children:[e.jsx(D,{className:"pb-2",children:e.jsxs(A,{className:"text-sm flex items-center gap-2",children:[e.jsx(f,{className:"h-4 w-4 text-blue-700"}),"How stewardship works"]})}),e.jsxs(R,{className:"text-xs text-muted-foreground space-y-2 leading-relaxed",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-foreground",children:"New documents start as drafts."})," ","They're not available to AI queries until a steward approves them."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-foreground",children:"Stewards"})," are people you name to govern content by scope. Resolution priority (first match wins):"]}),e.jsxs("ol",{className:"list-decimal list-inside ml-2 space-y-0.5",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Document"})," — this exact doc"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Tag"})," — everything with #tag"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Nest"})," — anything not matched above"]})]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-foreground",children:"Reviewers"})," can approve/reject;"," ",e.jsx("strong",{className:"text-foreground",children:"editors"})," can edit;"," ",e.jsx("strong",{className:"text-foreground",children:"viewers"})," have read access. Authors can't approve their own work."]})]})]}),e.jsxs(E,{children:[e.jsx(D,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(A,{className:"text-lg",children:"Stewards"}),e.jsx(X,{children:i.isLoading?"Loading…":o.length===0?"Nobody's governing content yet":"Who governs what"})]}),o.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["all","document","tag","nest"].map(a=>e.jsx("button",{onClick:()=>h(a),className:`text-xs px-2 py-1 rounded border ${x===a?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-border hover:bg-secondary"}`,children:a==="all"?"All":a.charAt(0).toUpperCase()+a.slice(1)},a)),e.jsx("span",{className:"w-px h-4 bg-border"}),e.jsxs(G,{value:d,onValueChange:a=>v(a),children:[e.jsx(J,{className:"w-[120px] h-7 text-xs",children:e.jsx(K,{})}),e.jsxs(O,{children:[e.jsx(g,{value:"all",children:"All"}),e.jsx(g,{value:"editor",children:"Editor"}),e.jsx(g,{value:"reviewer",children:"Reviewer"}),e.jsx(g,{value:"viewer",children:"Viewer"})]})]})]})]})}),e.jsx(R,{children:i.isLoading?e.jsx(z,{stewards:[],loading:!0,showScope:!0}):o.length===0?e.jsxs("div",{className:"text-sm space-y-3 py-2",children:[e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:"Without stewards, every draft needs the nest owner to approve. Add an editor/reviewer to delegate approvals for a tag or specific doc."}),n&&e.jsxs(m,{variant:"outline",size:"sm",className:"w-full",onClick:l,children:[e.jsx(f,{className:"h-3.5 w-3.5 mr-2"}),"Assign your first steward"]})]}):e.jsx(z,{stewards:o.filter(a=>(x==="all"||a.scope===x)&&(d==="all"||a.role===d)),showScope:!0,onAddSteward:n?l:void 0,onRemove:n?async a=>r(a):void 0,onEditRole:n?c:void 0,currentUserEmail:N})})]})]})}export{xe as StewardsTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as e,D as S,x as y,y as f,z as C,G as N,A as D,K as A,a as F,J as u,H as P,B as j,L as E}from"./index-B5hLclEq.js";import{T as L}from"./scroll-area-CbcH6yrZ.js";import{S as H,a as I,b as R,c as T,d as i}from"./select-DrL0mpRN.js";import{S as k}from"./send-CvAgOUPG.js";function G({isOpen:g,onClose:v,documentTitle:o,currentVersion:l,onSubmit:b}){const[c,d]=r.useState(""),[h,m]=r.useState("normal"),[s,p]=r.useState(!1),[x,t]=r.useState(null),w=async()=>{p(!0),t(null);try{await b(c,h),n()}catch(a){t(a instanceof Error?a.message:"Failed to submit for review")}finally{p(!1)}},n=()=>{s||(d(""),m("normal"),t(null),v())};return e.jsx(S,{open:g,onOpenChange:n,children:e.jsxs(y,{className:"sm:max-w-[425px]",children:[e.jsxs(f,{children:[e.jsx(C,{children:l==null?`Publish ${o} (requires approval)`:`Publish “${o}” (requires approval)`}),e.jsx(N,{children:l==null?e.jsxs(e.Fragment,{children:["Publishing in this nest goes through stewardship. Each selected draft moves to ",e.jsx("strong",{children:"pending review"}),"; once a steward approves one, that version becomes the AI-readable copy."]}):e.jsxs(e.Fragment,{children:["Publishing in this nest goes through stewardship. Version"," ",l," will move to ",e.jsx("strong",{children:"pending review"}),"; once a steward approves it, this version becomes the AI-readable copy."]})})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[x&&e.jsxs(D,{variant:"destructive",children:[e.jsx(A,{className:"h-4 w-4"}),e.jsx(F,{children:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"priority",children:"Priority"}),e.jsxs(H,{value:h,onValueChange:a=>m(a),disabled:s,children:[e.jsx(I,{id:"priority",children:e.jsx(R,{placeholder:"Select priority"})}),e.jsxs(T,{children:[e.jsx(i,{value:"low",children:"Low"}),e.jsx(i,{value:"normal",children:"Normal"}),e.jsx(i,{value:"high",children:"High"}),e.jsx(i,{value:"urgent",children:"Urgent"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"note",children:"Note for Reviewer (optional)"}),e.jsx(L,{id:"note",placeholder:"Add context or specific areas to review...",value:c,onChange:a=>d(a.target.value),disabled:s,className:"min-h-[100px]"})]})]}),e.jsxs(P,{children:[e.jsx(j,{variant:"outline",onClick:n,disabled:s,children:"Cancel"}),e.jsxs(j,{onClick:w,disabled:s,children:[s?e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),"Submit for approval"]})]})]})})}export{G as S};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{j as o,cM as z,cN as u,cO as G,r as s,cP as A,cQ as H,cR as V,cS as W,cT as Y,cU as k,cV as D,cW as B,cX as q,cY as Q,s as n,cZ as v}from"./index-B5hLclEq.js";var U=Symbol("radix.slottable");function X(a){const e=({children:t})=>o.jsx(o.Fragment,{children:t});return e.displayName=`${a}.Slottable`,e.__radixId=U,e}var x="AlertDialog",[Z]=q(x,[u]),i=u(),N=a=>{const{__scopeAlertDialog:e,...t}=a,r=i(e);return o.jsx(z,{...r,...t,modal:!0})};N.displayName=x;var J="AlertDialogTrigger",K=s.forwardRef((a,e)=>{const{__scopeAlertDialog:t,...r}=a,l=i(t);return o.jsx(Q,{...l,...r,ref:e})});K.displayName=J;var ee="AlertDialogPortal",y=a=>{const{__scopeAlertDialog:e,...t}=a,r=i(e);return o.jsx(G,{...r,...t})};y.displayName=ee;var ae="AlertDialogOverlay",R=s.forwardRef((a,e)=>{const{__scopeAlertDialog:t,...r}=a,l=i(t);return o.jsx(B,{...l,...r,ref:e})});R.displayName=ae;var c="AlertDialogContent",[te,oe]=Z(c),re=X("AlertDialogContent"),_=s.forwardRef((a,e)=>{const{__scopeAlertDialog:t,children:r,...l}=a,g=i(t),p=s.useRef(null),L=A(e,p),m=s.useRef(null);return o.jsx(H,{contentName:c,titleName:j,docsSlug:"alert-dialog",children:o.jsx(te,{scope:t,cancelRef:m,children:o.jsxs(V,{role:"alertdialog",...g,...l,ref:L,onOpenAutoFocus:W(l.onOpenAutoFocus,d=>{var f;d.preventDefault(),(f=m.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[o.jsx(re,{children:r}),o.jsx(le,{contentRef:p})]})})})});_.displayName=c;var j="AlertDialogTitle",b=s.forwardRef((a,e)=>{const{__scopeAlertDialog:t,...r}=a,l=i(t);return o.jsx(Y,{...l,...r,ref:e})});b.displayName=j;var E="AlertDialogDescription",S=s.forwardRef((a,e)=>{const{__scopeAlertDialog:t,...r}=a,l=i(t);return o.jsx(k,{...l,...r,ref:e})});S.displayName=E;var se="AlertDialogAction",h=s.forwardRef((a,e)=>{const{__scopeAlertDialog:t,...r}=a,l=i(t);return o.jsx(D,{...l,...r,ref:e})});h.displayName=se;var w="AlertDialogCancel",C=s.forwardRef((a,e)=>{const{__scopeAlertDialog:t,...r}=a,{cancelRef:l}=oe(w,t),g=i(t),p=A(e,l);return o.jsx(D,{...g,...r,ref:p})});C.displayName=w;var le=({contentRef:a})=>{const e=`\`${c}\` requires a description for the component to be accessible for screen reader users.
|
|
2
|
+
|
|
3
|
+
You can add a description to the \`${c}\` by passing a \`${E}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
4
|
+
|
|
5
|
+
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${c}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
6
|
+
|
|
7
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return s.useEffect(()=>{var r;document.getElementById((r=a.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(e)},[e,a]),null},ie=N,ne=y,T=R,P=_,O=h,$=C,I=b,M=S;const ve=ie,ce=ne,F=s.forwardRef(({className:a,...e},t)=>o.jsx(T,{className:n("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...e,ref:t}));F.displayName=T.displayName;const de=s.forwardRef(({className:a,...e},t)=>o.jsxs(ce,{children:[o.jsx(F,{}),o.jsx(P,{ref:t,className:n("fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem)] max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-4 sm:p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",a),...e})]}));de.displayName=P.displayName;const pe=({className:a,...e})=>o.jsx("div",{className:n("flex flex-col space-y-2 text-center sm:text-left",a),...e});pe.displayName="AlertDialogHeader";const ge=({className:a,...e})=>o.jsx("div",{className:n("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...e});ge.displayName="AlertDialogFooter";const me=s.forwardRef(({className:a,...e},t)=>o.jsx(I,{ref:t,className:n("text-lg font-semibold",a),...e}));me.displayName=I.displayName;const fe=s.forwardRef(({className:a,...e},t)=>o.jsx(M,{ref:t,className:n("text-sm text-muted-foreground",a),...e}));fe.displayName=M.displayName;const ue=s.forwardRef(({className:a,...e},t)=>o.jsx(O,{ref:t,className:n(v(),a),...e}));ue.displayName=O.displayName;const Ae=s.forwardRef(({className:a,...e},t)=>o.jsx($,{ref:t,className:n(v({variant:"outline"}),"mt-2 sm:mt-0",a),...e}));Ae.displayName=$.displayName;export{ve as A,de as a,pe as b,me as c,fe as d,ge as e,Ae as f,ue as g};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as o}from"./index-B5hLclEq.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 e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A};
|
|
@@ -0,0 +1,24 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as e}from"./index-B5hLclEq.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 o=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],t=e("chevron-left",o);export{t as C};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c}from"./index-B5hLclEq.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 e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],r=c("circle-check",e);export{r as C};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c}from"./index-B5hLclEq.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 e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],o=c("circle-x",e);export{o as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(e){const{agent:n,session_id:i,...o}=e;return[n,i,...Object.entries(o).map(([t,s])=>`${t}=${s}`)].filter(t=>t!==void 0&&t!=="").join(" · ")}export{r as f};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as e}from"./index-B5hLclEq.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 o=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],m=e("code-xml",o);export{m as C};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as o}from"./index-B5hLclEq.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 e=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],r=o("corner-down-right",e);export{r as C};
|