@promptowl/contextnest-community 1.24.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/API.md +177 -14
  2. package/CONFIGURATION.md +577 -116
  3. package/README.md +4 -3
  4. package/STEWARDSHIP.md +24 -0
  5. package/dist/{chunk-XUIWAWDO.js → chunk-2QOJE7A5.js} +4 -4
  6. package/dist/{chunk-2TPQTN4Y.js → chunk-DGPTJXIV.js} +47 -15
  7. package/dist/chunk-I5EDEZBQ.js +523 -0
  8. package/dist/{chunk-ZTT4U4NE.js → chunk-IEAWRHMV.js} +99 -12
  9. package/dist/{chunk-YVMSM7LS.js → chunk-LHWOJPFE.js} +7 -0
  10. package/dist/{chunk-5EZOPA47.js → chunk-M6PGYMBD.js} +20 -11
  11. package/dist/{chunk-F66VCBLA.js → chunk-PICUHQEM.js} +51 -2
  12. package/dist/{chunk-I3CSD6CK.js → chunk-RPGFHESR.js} +2 -2
  13. package/dist/{chunk-KIAAEHWL.js → chunk-SWA5M5XX.js} +88 -546
  14. package/dist/{chunk-LA3VTQ22.js → chunk-TRSGPS27.js} +81 -14
  15. package/dist/{engine-S3QBQ7LH.js → engine-QNMFDIBV.js} +4 -3
  16. package/dist/{external-edit-service-6FNFPOJJ.js → external-edit-service-4MEGPT4D.js} +5 -4
  17. package/dist/{grants-service-UT3EQ3R7.js → grants-service-24GLUBY4.js} +3 -3
  18. package/dist/index.js +1739 -583
  19. package/dist/invited-user-AM6A3WGO.js +12 -0
  20. package/dist/{migrations.postgres-AIQ7WSU7.js → migrations.postgres-HGSQ7IA5.js} +16 -2
  21. package/dist/{review-service-HHGOTO6P.js → review-service-2EWN7WWO.js} +8 -7
  22. package/dist/{stewardship-service-4DHNRULG.js → stewardship-service-TDZUC2Q6.js} +7 -4
  23. package/dist/{version-service-KIOQME6U.js → version-service-C3JTZLJH.js} +5 -4
  24. package/dist/web3/assets/ActivityTracePage-DzwWIjjx.js +1 -0
  25. package/dist/web3/assets/{AgentDocsPage-CIiaBqMy.js → AgentDocsPage-ixP2UdAE.js} +1 -1
  26. package/dist/web3/assets/CollaboratorManager-C9VAXZ0h.js +1 -0
  27. package/dist/web3/assets/CollaboratorsTab-tq4ZTexH.js +1 -0
  28. package/dist/web3/assets/DocumentEditor-C2CP2fiE.js +36 -0
  29. package/dist/web3/assets/DocumentsTab-Mh7KxUoB.js +6 -0
  30. package/dist/web3/assets/ExternalEditsTab-B_CWKXZ_.js +1 -0
  31. package/dist/web3/assets/MarkdownEditor-CKh4WSn-.js +653 -0
  32. package/dist/web3/assets/MarkdownEditor-ndtIx5x0.css +1 -0
  33. package/dist/web3/assets/NestPageHeader-Cizo8nUi.js +1 -0
  34. package/dist/web3/assets/NestView-EW-sraEb.js +73 -0
  35. package/dist/web3/assets/OverviewTab-CjidsMX_.js +6 -0
  36. package/dist/web3/assets/PersonCombobox-BKI7dff4.js +1 -0
  37. package/dist/web3/assets/{ReviewActions-OfOdqzCn.js → ReviewActions-CS8JXgXF.js} +2 -2
  38. package/dist/web3/assets/ReviewTab-CwVrXzw5.js +1 -0
  39. package/dist/web3/assets/StewardsTab-C-iP6gnh.js +1 -0
  40. package/dist/web3/assets/SubmitForReviewModal-Biq3m79i.js +1 -0
  41. package/dist/web3/assets/{alert-dialog-DTozKlmV.js → alert-dialog-BvF3NFr7.js} +2 -2
  42. package/dist/web3/assets/{arrow-left-BCKt4CwQ.js → arrow-left-CWIsv-sG.js} +1 -1
  43. package/dist/web3/assets/backlinks-Cqcn7n1J.js +19 -0
  44. package/dist/web3/assets/boxes-ClbgQqG2.js +6 -0
  45. package/dist/web3/assets/{chevron-left-BPwUT9DS.js → chevron-left-CK_ZPFm9.js} +1 -1
  46. package/dist/web3/assets/{circle-check-DI8IBGeo.js → circle-check-Bw_aTXiH.js} +1 -1
  47. package/dist/web3/assets/{circle-x-VKVhC88W.js → circle-x-DkIG68H7.js} +1 -1
  48. package/dist/web3/assets/client-attribution-BraarYaP.js +1 -0
  49. package/dist/web3/assets/{code-xml-CMabYZvH.js → code-xml-BlR7EN6l.js} +1 -1
  50. package/dist/web3/assets/{corner-down-right-BGxwK6wH.js → corner-down-right-DSVxK3tf.js} +1 -1
  51. package/dist/web3/assets/count-skeleton-DToLM74B.js +1 -0
  52. package/dist/web3/assets/{earth-BEp1EKTo.js → earth-BXhVPvCR.js} +1 -1
  53. package/dist/web3/assets/{file-exclamation-point-r8qZGIjP.js → file-exclamation-point-BevGZgtj.js} +1 -1
  54. package/dist/web3/assets/{folder-input-Cmtx1Jhk.js → folder-input-m8UBV4fA.js} +1 -1
  55. package/dist/web3/assets/{index-C1wTSjfP.js → index-BOVYgMvj.js} +1 -1
  56. package/dist/web3/assets/index-DVnaYqj9.css +1 -0
  57. package/dist/web3/assets/index-WYDmEOfO.js +404 -0
  58. package/dist/web3/assets/page-B6pkc9cd.js +2 -0
  59. package/dist/web3/assets/page-BJrFCKXB.js +1 -0
  60. package/dist/web3/assets/page-Bgy9Ng9p.js +1 -0
  61. package/dist/web3/assets/page-C2zoxumw.js +1 -0
  62. package/dist/web3/assets/page-CJWO06dN.js +1 -0
  63. package/dist/web3/assets/page-CptuAPJc.js +6 -0
  64. package/dist/web3/assets/page-DPY01SOj.js +1 -0
  65. package/dist/web3/assets/page-Dea2SblF.js +9 -0
  66. package/dist/web3/assets/page-Deq6IKiN.js +6 -0
  67. package/dist/web3/assets/page-Dfjg8p7Z.js +1 -0
  68. package/dist/web3/assets/{page-ByyVLDVo.js → page-Dh57L0RG.js} +5 -5
  69. package/dist/web3/assets/page-Dwbp4Seu.js +6 -0
  70. package/dist/web3/assets/{page-CHb0F5hV.js → page-DzKwP5Ds.js} +3 -3
  71. package/dist/web3/assets/page-YxjrE5b5.js +45 -0
  72. package/dist/web3/assets/{page-title-ClvvBsIo.js → page-title-DVq4qvMR.js} +1 -1
  73. package/dist/web3/assets/{play-C5YNKpAH.js → play-CXhS6Pgq.js} +1 -1
  74. package/dist/web3/assets/{send-0CHvmluT.js → send-DdfwnIrj.js} +1 -1
  75. package/dist/web3/assets/{settings-CeeF4LEb.js → settings-DKX0Q4gO.js} +1 -1
  76. package/dist/web3/assets/{share-2-CMnOlOt-.js → share-2-CxmXRt58.js} +1 -1
  77. package/dist/web3/assets/{tag-DQ_6J5Gv.js → tag-DeYC_mRv.js} +1 -1
  78. package/dist/web3/assets/{trash-2-HBi-Pslz.js → trash-2-B0HyPTnI.js} +1 -1
  79. package/dist/web3/assets/{user-plus-CvBNcpn4.js → user-plus-Ckm_Isyc.js} +1 -1
  80. package/dist/web3/assets/{x-By7piikG.js → x-mNtADYHc.js} +1 -1
  81. package/dist/web3/assets/zap-D2ifcnYb.js +16 -0
  82. package/dist/web3/index.html +2 -2
  83. package/package.json +3 -2
  84. package/dist/client-KEY4PYJH.js +0 -11
  85. package/dist/keys-CTOGAG3W.js +0 -20
  86. package/dist/web3/assets/ActivityTracePage-BOZHgJ8S.js +0 -1
  87. package/dist/web3/assets/CollaboratorManager-By91wrIr.js +0 -1
  88. package/dist/web3/assets/CollaboratorsTab-D1EE64Fs.js +0 -1
  89. package/dist/web3/assets/DocumentEditor-DrQfrW3d.js +0 -36
  90. package/dist/web3/assets/DocumentsTab-Vba-AzBv.js +0 -6
  91. package/dist/web3/assets/ExternalEditsTab-BSzAQIGM.js +0 -1
  92. package/dist/web3/assets/MarkdownEditor-74N_naNQ.css +0 -1
  93. package/dist/web3/assets/MarkdownEditor-C9zqZjC5.js +0 -643
  94. package/dist/web3/assets/NestPageHeader-CoLUV1Oz.js +0 -1
  95. package/dist/web3/assets/NestView-CTZ55tXD.js +0 -63
  96. package/dist/web3/assets/OverviewTab-Dxi-Hu-N.js +0 -1
  97. package/dist/web3/assets/PersonCombobox-CPOlNs6G.js +0 -1
  98. package/dist/web3/assets/ReasonDialog-DgLxfRWv.js +0 -1
  99. package/dist/web3/assets/ReviewTab-CyX8yxd3.js +0 -1
  100. package/dist/web3/assets/StewardsTab-DBEEfAQI.js +0 -1
  101. package/dist/web3/assets/SubmitForReviewModal-Ci2DdWs0.js +0 -1
  102. package/dist/web3/assets/backlinks-CYd4xENL.js +0 -24
  103. package/dist/web3/assets/card-XG2dP5Xf.js +0 -1
  104. package/dist/web3/assets/count-skeleton-DMbdpscX.js +0 -1
  105. package/dist/web3/assets/dates-BCxbm4_q.js +0 -1
  106. package/dist/web3/assets/index-BM-h3DwI.css +0 -1
  107. package/dist/web3/assets/index-EaX2yql0.js +0 -389
  108. package/dist/web3/assets/page-B3yvQvHy.js +0 -1
  109. package/dist/web3/assets/page-BExMvttJ.js +0 -1
  110. package/dist/web3/assets/page-BUOADv2X.js +0 -1
  111. package/dist/web3/assets/page-BYUFhYWZ.js +0 -1
  112. package/dist/web3/assets/page-Bicf02Cz.js +0 -1
  113. package/dist/web3/assets/page-BsPMDm5d.js +0 -45
  114. package/dist/web3/assets/page-CC0NJi8v.js +0 -1
  115. package/dist/web3/assets/page-CPjWQNKx.js +0 -11
  116. package/dist/web3/assets/page-CQt3ZGbf.js +0 -2
  117. package/dist/web3/assets/page-Cj1NetQ-.js +0 -1
  118. package/dist/web3/assets/page-CtaW65El.js +0 -1
  119. package/dist/web3/assets/page-DGOL9l8i.js +0 -6
  120. package/dist/web3/assets/refresh-cw-BhHzSH9m.js +0 -6
  121. package/dist/web3/assets/scroll-area-dRWncRqa.css +0 -1
  122. package/dist/web3/assets/scroll-area-hz-xtayP.js +0 -1
  123. package/dist/web3/assets/select-DBFTrUmI.js +0 -6
  124. package/dist/web3/assets/triangle-alert-CDy8-7sv.js +0 -6
  125. package/dist/web3/assets/zap-C2T8riBp.js +0 -11
@@ -1 +0,0 @@
1
- import{O as Pe,r as l,d6 as Te,d7 as Ie,f as O,j as e,u as Ae,bs as B,B as y,L as S,T as Ee,P as De,Q as Le,R as E,U as Re,V as g,c5 as Me,C as Ue,am as Fe,aw as ze,ck as He,aP as Ge,e as We,aa as qe,D as de,x as me,y as he,z as ue,G as xe,J as z,I as P,H as pe,i as ge,c6 as Be,E as $e,d8 as _e,d9 as Ke,da as Qe,db as Ve}from"./index-EaX2yql0.js";import{P as Je}from"./page-title-ClvvBsIo.js";import{C as o,a as c,c as d,b as m,d as h}from"./card-XG2dP5Xf.js";import{E as Ye}from"./earth-BEp1EKTo.js";import{T as Xe}from"./trash-2-HBi-Pslz.js";const Ze=[{value:"open",label:"Everyone",hint:"Anyone can sign in with PromptOwl."},{value:"admin-only",label:"Admins only",hint:"Only the server admin can use PromptOwl sign-in."},{value:"disabled",label:"Off",hint:"Hide PromptOwl sign-in."}],es=[{value:"open",label:"Everyone",hint:"Anyone can sign in and create their own account."},{value:"invite-only",label:"Invite only",hint:"Invited users sign in and set a password; no self sign-up."},{value:"disabled",label:"Off",hint:"No email & password sign-in — PromptOwl only."}],$=[{id:"general",label:"General",keys:["promptowl_sign_in_gate","manual_sign_in","public_base_url","logo_url","anthropic_api_key","people_suggest_all_users"]},{id:"sso",label:"Single sign-on",keys:["oidc_enabled","oidc_issuer","oidc_client_id","oidc_client_secret","oidc_allowed_domains","oidc_auto_provision","oidc_department_tagging","sso_token_exchange_enabled","mcp_signing_secret","mcp_token_ttl_seconds","ms_token_exchange_enabled","ms_client_id","ms_tenant_id","google_token_exchange_enabled","google_client_id"]},{id:"notifications",label:"Notifications",keys:["slack_webhook_url","msteams_webhook_url","smtp_url","notify_email_from","notify_email_to"]},{id:"community-sites",label:"Community sites",keys:[]},{id:"advanced",label:"Advanced",keys:["telemetry_enabled","posthog_key","posthog_host","max_body_bytes","trace_retention_days","type_artifact_enabled","type_table_enabled","workflow_plane_enabled","promptowl_teams_enabled","subagent_runs_enabled","subagent_max_depth","subagent_max_children"]}],H=n=>({autoComplete:n==="password"?"new-password":"off","data-1p-ignore":!0,"data-lpignore":"true","data-form-type":"other"});function u({value:n,placeholder:w,onChange:t,type:p="text"}){const _=p==="password",[x,f]=l.useState(!1);return e.jsxs("div",{className:"relative flex-1",children:[e.jsx(P,{value:n,type:_&&x?"text":p,placeholder:w,onChange:k=>t(k.target.value),className:_?"flex-1 pr-9":"flex-1",...H(p)}),_&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>f(k=>!k),className:"absolute inset-y-0 right-0 flex items-center px-2.5 text-muted-foreground hover:text-foreground",title:x?"Hide":"Show","aria-label":x?"Hide value":"Show value",children:x?e.jsx(Be,{className:"h-4 w-4"}):e.jsx($e,{className:"h-4 w-4"})})]})}function ss({bytes:n,onChange:w}){const[t,p]=l.useState(String(Math.round(n/1048576)));return l.useEffect(()=>p(String(Math.round(n/(1024*1024)))),[n]),e.jsxs("div",{className:"flex items-center gap-2 max-w-xs",children:[e.jsx(P,{type:"number",value:t,onChange:_=>{p(_.target.value);const x=Number(_.target.value);Number.isFinite(x)&&x>0&&w(Math.floor(x*1024*1024))},...H("number")}),e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"MB"})]})}function K({value:n,onChange:w,min:t,max:p}){const[_,x]=l.useState(String(n));return l.useEffect(()=>x(String(n)),[n]),e.jsx(P,{type:"number",min:t,max:p,value:_,className:"max-w-[7rem]",onChange:f=>{x(f.target.value);const k=Number(f.target.value);Number.isInteger(k)&&w(k)},...H("number")})}function ts({settings:n,onUpdate:w}){var le,oe;const[t,p]=l.useState(n),[_,x]=l.useState(!1),f=Ae(),[k,D]=l.useState(null),[fe,Q]=l.useState("general"),[V,J]=l.useState(!1);l.useEffect(()=>{n&&p(n)},[n]);const[G,je]=l.useState(null),[Y,X]=l.useState(null),L=async()=>{try{await f.invalidateQueries({queryKey:ge.communitySites().queryKey});const s=await f.fetchQuery(ge.communitySites());je(s.community_sites),X(null)}catch(s){X(s.message)}};l.useEffect(()=>{L()},[]);const[j,T]=l.useState(null),[b,N]=l.useState({name:"",url:"",secret:"",is_active:!0}),[Z,ee]=l.useState(!1),[se,R]=l.useState(null),[C,M]=l.useState(null),[te,ne]=l.useState(!1),be=()=>{N({name:"",url:"",secret:"",is_active:!0}),R(null),T({mode:"add"})},ve=s=>{N({name:s.name,url:s.url,secret:"",is_active:s.is_active}),R(null),T({mode:"edit",site:s})},ye=async()=>{if(j){ee(!0),R(null);try{if(j.mode==="add")await Ke({name:b.name.trim(),url:b.url.trim(),secret:b.secret.trim(),is_active:b.is_active});else{const s={name:b.name.trim(),url:b.url.trim(),is_active:b.is_active};b.secret.trim()&&(s.secret=b.secret.trim()),await _e(j.site.id,s)}T(null),await L()}catch(s){R(s.message)}finally{ee(!1)}}},we=async s=>{try{await _e(s.id,{is_active:!s.is_active}),await L()}catch(a){O.error(a.message)}},ke=async()=>{if(C){ne(!0);try{await Qe(C.id),M(null),await L()}catch(s){O.error(s.message)}finally{ne(!1)}}},i=s=>{p(a=>a&&{...a,...s}),D(null)},I=l.useMemo(()=>{if(!t||!n)return[];const s=n;return Object.keys(t).filter(a=>{if(a==="anthropic_api_key"||a==="oidc_client_secret"||a==="mcp_signing_secret"){const r=t[a];return typeof r=="string"&&r.trim()!==""||r===null}return(t[a]??"")!==(s[a]??"")})},[t,n]),U=I.length>0,Ne=s=>s.some(a=>I.includes(a)),Ce=async()=>{var a;if(!t||!U)return;const s={};for(const r of I)s[r]=t[r];x(!0),D(null);try{await w(s)}catch(r){D((r==null?void 0:r.message)||"Failed to save settings");const v=((a=r==null?void 0:r.body)==null?void 0:a.fieldErrors)??{},A=Object.keys(v),F=W=>A.some(q=>W.keys.includes(q)),ce=A.length?$.find(F):$.find(W=>W.keys.some(q=>I.includes(q)));ce&&Q(ce.id)}finally{x(!1)}},Se=()=>{n&&p(n),D(null)},[ae,ie]=l.useState(null),Oe=async s=>{ie(s);try{await Ve(s),O.success(`Test ${s==="slack"?"Slack":"Teams"} notification sent — check the channel.`)}catch(a){O.error((a==null?void 0:a.message)||"Test notification failed.")}finally{ie(null)}},re=(s,a)=>e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs(y,{type:"button",variant:"outline",size:"sm",disabled:ae===s||!(n!=null&&n[a]),onClick:()=>Oe(s),children:[ae===s&&e.jsx(S,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Send test"]}),I.includes(a)&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Save first — the test uses the saved URL."})]});return e.jsxs("div",{children:[e.jsx(Je,{icon:B,title:"Server settings",description:"Server-wide options. Changes apply on Save and persist across restarts.",className:"mb-6",actions:n&&e.jsxs(e.Fragment,{children:[U&&e.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Unsaved changes"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:Se,disabled:!U||_,children:"Discard"}),e.jsxs(y,{size:"sm",onClick:Ce,disabled:!U||_,children:[_&&e.jsx(S,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Save changes"]})]})}),k&&e.jsxs("div",{role:"alert",className:"mb-4 rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("div",{className:"font-medium",children:"Couldn't save settings"}),e.jsx("div",{className:"mt-0.5 text-destructive/90",children:k})]}),t?e.jsxs(Ee,{value:fe,onValueChange:Q,children:[e.jsx(De,{children:$.map(s=>e.jsxs(Le,{value:s.id,className:"gap-1.5",children:[s.label,Ne(s.keys)&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary","aria-label":"unsaved changes"})]},s.id))}),e.jsxs(E,{value:"general",className:"space-y-4",children:[e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsxs(d,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-muted-foreground"}),"PromptOwl sign-in"]}),e.jsx(m,{children:"Who can sign in to this server using their PromptOwl account."})]}),e.jsx(h,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:Ze.map(s=>{const a=t.promptowl_sign_in_gate===s.value,r=s.value==="disabled"&&t.manual_sign_in==="disabled";return e.jsxs("button",{type:"button",disabled:r,onClick:()=>!a&&!r&&i({promptowl_sign_in_gate:s.value}),className:`text-left rounded-lg border p-3 transition-colors ${a?"border-primary bg-primary/5 ring-1 ring-primary":r?"opacity-50 cursor-not-allowed":"hover:bg-muted/50"}`,"aria-pressed":a,children:[e.jsx("div",{className:"text-sm font-medium",children:s.label}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.hint})]},s.value)})})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsxs(d,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-muted-foreground"}),"Manual sign-in"]}),e.jsx(m,{children:"Email & password sign-in. Independent of PromptOwl — you can't turn this fully off while PromptOwl sign-in is also off."})]}),e.jsx(h,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:es.map(s=>{const a=t.manual_sign_in===s.value,r=s.value==="disabled"&&t.promptowl_sign_in_gate==="disabled";return e.jsxs("button",{type:"button",disabled:r,onClick:()=>!a&&!r&&i({manual_sign_in:s.value}),className:`text-left rounded-lg border p-3 transition-colors ${a?"border-primary bg-primary/5 ring-1 ring-primary":r?"opacity-50 cursor-not-allowed":"hover:bg-muted/50"}`,"aria-pressed":a,children:[e.jsx("div",{className:"text-sm font-medium",children:s.label}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.hint})]},s.value)})})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Public base URL"}),e.jsx(m,{children:"This server's public address — used for share links and SSO redirects. Leave empty if unsure."})]}),e.jsx(h,{children:e.jsx(u,{value:t.public_base_url??"",placeholder:"https://nest.yourcompany.com",onChange:s=>i({public_base_url:s})})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Logo"}),e.jsx(m,{children:"URL of the logo shown in the header. Leave empty for the default."})]}),e.jsx(h,{children:e.jsx(u,{value:t.logo_url??"",placeholder:"https://example.com/logo.svg",onChange:s=>i({logo_url:s})})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Anthropic API key"}),e.jsx(m,{children:"The server-wide model key. Runners pick it up automatically (every nest, unless a nest overrides it in its Tool environment). No key, no LLM calls. Stored server-side; shown masked."})]}),e.jsxs(h,{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:t.anthropic_api_key===null?"Will be cleared when you save.":n!=null&&n.anthropic_api_key_masked?`Current: ${n.anthropic_api_key_masked}`:"Not set — runs can't execute until a key exists here or in a nest's Tool environment."}),e.jsx(u,{type:"password",value:typeof t.anthropic_api_key=="string"?t.anthropic_api_key:"",placeholder:"sk-ant-… (paste to set or replace)",onChange:s=>i({anthropic_api_key:s})}),(n==null?void 0:n.anthropic_api_key_masked)&&t.anthropic_api_key!==null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-destructive hover:underline",onClick:()=>i({anthropic_api_key:null}),children:"Clear key"}),t.anthropic_api_key===null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-muted-foreground hover:underline",onClick:()=>i({anthropic_api_key:void 0}),children:"Keep current key"})]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsxs(d,{className:"flex items-center gap-2 text-base",children:[e.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),"People directory"]}),e.jsx(m,{children:'What the "add a person" fields suggest when inviting someone to a nest, a team, or a stewardship role.'})]}),e.jsx(h,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"pr-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Suggest everyone on this server"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Off, the pickers only suggest people the inviter already shares a nest or team with. On, they suggest every registered account — right when this server is one organisation, wrong when it hosts several, because it shows them each other's email addresses. Either way anyone can still be invited by typing their address."})]}),e.jsx(g,{checked:t.people_suggest_all_users,onCheckedChange:s=>i({people_suggest_all_users:s})})]})})]})]}),e.jsxs(E,{value:"sso",className:"space-y-4",children:[e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsxs(d,{className:"flex items-center gap-2 text-base",children:[e.jsx(Me,{className:"h-4 w-4 text-muted-foreground"}),"Single sign-on (OIDC)"]}),e.jsx(m,{children:"Let teammates sign in with your identity provider — Microsoft Entra ID, Google, or any OpenID Connect issuer. Fill in the issuer and app credentials below, then turn it on."})]}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:[t.oidc_enabled?"On":"Off",!t.oidc_enabled&&!(t.oidc_issuer&&t.oidc_client_id)&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· configure the issuer and app credentials first"]})]}),e.jsx(g,{checked:t.oidc_enabled,onCheckedChange:s=>i({oidc_enabled:s})})]}),(()=>{var r,v;const s=t.oidc_client_secret===null?!1:typeof t.oidc_client_secret=="string"&&t.oidc_client_secret.trim()!==""?!0:!!(n!=null&&n.oidc_client_secret_set),a=t.oidc_enabled&&!!((r=t.oidc_issuer)!=null&&r.trim())&&!!((v=t.oidc_client_id)!=null&&v.trim())&&s;return!t.oidc_enabled||a?null:e.jsx("div",{role:"alert",className:"rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-400",children:"Enabled but not configured — the SSO sign-in button stays hidden until the issuer, client ID, and client secret are all set."})})(),(()=>{var r;const s=((r=t.oidc_issuer)==null?void 0:r.trim())??"",a=/^https:\/\/login\.microsoftonline\.com\/[^/]+\/v2\.0$/.test(s)?"entra":s==="https://accounts.google.com"?"google":null;return e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Issuer URL"}),e.jsxs("div",{className:"flex gap-2 mb-2",role:"group","aria-label":"Identity provider preset",children:[e.jsx(y,{type:"button",variant:a==="entra"?"default":"outline",size:"sm","aria-pressed":a==="entra",onClick:()=>{const v=window.prompt("Microsoft Entra tenant ID (Directory ID) — find it on your app registration's Overview page:");v&&v.trim()&&i({oidc_issuer:`https://login.microsoftonline.com/${v.trim()}/v2.0`})},children:"Microsoft Entra ID"}),e.jsx(y,{type:"button",variant:a==="google"?"default":"outline",size:"sm","aria-pressed":a==="google",onClick:()=>i({oidc_issuer:"https://accounts.google.com"}),children:"Google"}),a===null&&s!==""&&e.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Custom issuer"})]}),e.jsx(u,{value:t.oidc_issuer??"",placeholder:"https://login.microsoftonline.com/{tenant}/v2.0",onChange:v=>i({oidc_issuer:v})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"https:// only. Must serve /.well-known/openid-configuration."})]})})(),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Client ID"}),e.jsx(u,{value:t.oidc_client_id??"",placeholder:"Application (client) ID from your IdP app registration",onChange:s=>i({oidc_client_id:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Client secret"}),e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:t.oidc_client_secret===null?"Will be cleared when you save.":n!=null&&n.oidc_client_secret_set?"A client secret is set. Paste a new one to replace it.":"Not set."}),e.jsx(u,{type:"password",value:typeof t.oidc_client_secret=="string"?t.oidc_client_secret:"",placeholder:"Paste to set or replace",onChange:s=>i({oidc_client_secret:s})}),(n==null?void 0:n.oidc_client_secret_set)&&t.oidc_client_secret!==null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-destructive hover:underline",onClick:()=>i({oidc_client_secret:null}),children:"Clear secret"}),t.oidc_client_secret===null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-muted-foreground hover:underline",onClick:()=>i({oidc_client_secret:void 0}),children:"Keep current secret"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Redirect URI"}),(()=>{const a=`${(t.public_base_url||window.location.origin).replace(/\/$/,"")}/auth/oidc/callback`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 bg-muted/40 border rounded px-2 py-1.5 text-xs font-mono break-all",children:a}),e.jsxs(y,{type:"button",variant:"outline",size:"sm",onClick:async()=>{await ze(a)&&(J(!0),setTimeout(()=>J(!1),1500))},children:[V?e.jsx(Ue,{className:"h-3.5 w-3.5"}):e.jsx(Fe,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1.5",children:V?"Copied":"Copy"})]})]})})(),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Register this exact URI in your IdP's app registration (Entra: Authentication → Web redirect URIs; Google: Authorized redirect URIs)."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Allowed email domains"}),e.jsx(u,{value:t.oidc_allowed_domains??"",placeholder:"acme.com, contractors.acme.com — empty allows any",onChange:s=>i({oidc_allowed_domains:s})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Only accounts whose email domain is listed may sign in. Leave empty to allow any domain your IdP asserts."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Auto-provision new users"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create an account on first SSO sign-in. Turn off to allow only users you've already invited."})]}),e.jsx(g,{checked:t.oidc_auto_provision,onCheckedChange:s=>i({oidc_auto_provision:s})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Department auto-tagging"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tag new documents with the creator's directory department (requires the department claim from your IdP)."})]}),e.jsx(g,{checked:t.oidc_department_tagging,onCheckedChange:s=>i({oidc_department_tagging:s})})]}),t.oidc_enabled&&t.oidc_auto_provision&&!((le=t.oidc_allowed_domains)!=null&&le.trim())&&e.jsx("div",{role:"alert",className:"rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-400",children:"Anyone your issuer can authenticate will get an account on first sign-in — with a consumer or multi-tenant issuer (e.g. Google), that's any account on the internet, and it applies even when manual sign-in is invite-only. Set allowed email domains above, or turn auto-provision off."})]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{children:"Agent SSO — token exchange"}),e.jsx(m,{children:"Let an external agent, acting for a user your IdP already authenticated (Microsoft Entra / Google), exchange that IdP's ID token for a short-lived MCP bearer — no second login. Uses the domain allowlist and auto-provision settings above."})]}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.sso_token_exchange_enabled?"On":"Off"}),e.jsx(g,{checked:t.sso_token_exchange_enabled,onCheckedChange:s=>i({sso_token_exchange_enabled:s})})]}),(t.ms_token_exchange_enabled||t.google_token_exchange_enabled)&&t.oidc_auto_provision&&!((oe=t.oidc_allowed_domains)!=null&&oe.trim())&&e.jsx("div",{role:"alert",className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:"Blocked: with auto-provision on and no allowed email domains, anyone with an account at that provider could sign themselves up and mint a token. Set allowed email domains above, or turn auto-provision off."}),(()=>{var v,A,F;const s=t.mcp_signing_secret===null?!1:typeof t.mcp_signing_secret=="string"&&t.mcp_signing_secret.trim()!==""?!0:!!(n!=null&&n.mcp_signing_secret_set),a=t.ms_token_exchange_enabled&&!!((v=t.ms_client_id)!=null&&v.trim())&&!!((A=t.ms_tenant_id)!=null&&A.trim()),r=t.google_token_exchange_enabled&&!!((F=t.google_client_id)!=null&&F.trim());return!t.sso_token_exchange_enabled||s&&(a||r)?null:e.jsx("div",{role:"alert",className:"rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-400",children:"Enabled but not ready — the endpoint needs a signing secret and at least one provider turned on with its client ID filled in (plus the tenant ID for Microsoft)."})})(),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"MCP signing secret"}),e.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:t.mcp_signing_secret===null?"Will be cleared when you save.":n!=null&&n.mcp_signing_secret_set?"A signing secret is set. Paste a new one to replace it.":"Not set. Use a long random string — this signs the MCP tokens the exchange mints."}),e.jsx(u,{type:"password",value:typeof t.mcp_signing_secret=="string"?t.mcp_signing_secret:"",placeholder:"Paste to set or replace (16+ characters)",onChange:s=>i({mcp_signing_secret:s})}),(n==null?void 0:n.mcp_signing_secret_set)&&t.mcp_signing_secret!==null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-destructive hover:underline",onClick:()=>i({mcp_signing_secret:null}),children:"Clear secret"}),t.mcp_signing_secret===null&&e.jsx("button",{type:"button",className:"mt-2 text-xs text-muted-foreground hover:underline",onClick:()=>i({mcp_signing_secret:void 0}),children:"Keep current secret"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Token lifetime (seconds)"}),e.jsx(u,{type:"number",value:String(t.mcp_token_ttl_seconds??300),placeholder:"300",onChange:s=>i({mcp_token_ttl_seconds:s.trim()===""?300:Number(s)})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"30–3600. Short by design — a minted token expires quickly."})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Microsoft Entra"}),e.jsx(g,{checked:t.ms_token_exchange_enabled,onCheckedChange:s=>i({ms_token_exchange_enabled:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Client (application) ID"}),e.jsx(u,{value:t.ms_client_id??"",placeholder:"Entra app (client) ID — the token audience",onChange:s=>i({ms_client_id:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Tenant ID"}),e.jsx(u,{value:t.ms_tenant_id??"",placeholder:"Directory (tenant) ID — builds the issuer",onChange:s=>i({ms_tenant_id:s})})]})]}),e.jsxs("div",{className:"border-t pt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Google"}),e.jsx(g,{checked:t.google_token_exchange_enabled,onCheckedChange:s=>i({google_token_exchange_enabled:s})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"OAuth client ID"}),e.jsx(u,{value:t.google_client_id??"",placeholder:"Google OAuth client ID — the token audience",onChange:s=>i({google_client_id:s})})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:["Your agent calls"," ",e.jsx("code",{className:"text-[11px]",children:"POST /auth/token-exchange"})," ","with the IdP ID token and receives a short-lived MCP bearer for"," ",e.jsx("code",{className:"text-[11px]",children:"/mcp"})," and"," ",e.jsx("code",{className:"text-[11px]",children:"/index"}),". The token is verified by signature, issuer, audience (the client id above) and expiry. Security-critical — keep it off until reviewed. For a public IdP like Google, set the allowed email domains above so only your organization can exchange."]})]})]})]}),e.jsxs(E,{value:"notifications",className:"space-y-4",children:[e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Slack notifications"}),e.jsx(m,{children:"Post governance events (review requested, approved, rejected, nest shared) to a Slack channel via an incoming-webhook URL. Leave empty to turn the connector off. The URL contains a secret — treat it like a password."})]}),e.jsxs(h,{children:[e.jsx(u,{type:"password",value:t.slack_webhook_url??"",placeholder:"https://hooks.slack.com/services/…",onChange:s=>i({slack_webhook_url:s})}),re("slack","slack_webhook_url")]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Microsoft Teams notifications"}),e.jsx(m,{children:'Post the same governance events to a Microsoft Teams channel as Adaptive Cards via an incoming-webhook URL (create one in Teams with the Workflows app: "Post to a channel when a webhook request is received"). Leave empty to turn the connector off. The URL contains a secret — treat it like a password.'})]}),e.jsxs(h,{children:[e.jsx(u,{type:"password",value:t.msteams_webhook_url??"",placeholder:"https://….logic.azure.com/workflows/…",onChange:s=>i({msteams_webhook_url:s})}),re("teams","msteams_webhook_url")]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Email notifications"}),e.jsx(m,{children:"Send the same governance events over SMTP. Set the connection URL (smtp:// or smtps://, credentials inline), a From address, and one or more recipients (comma-separated). Leave the URL empty to turn the connector off."})]}),e.jsxs(h,{className:"space-y-3",children:[e.jsx(u,{type:"password",value:t.smtp_url??"",placeholder:"smtps://user:pass@smtp.example.com:465",onChange:s=>i({smtp_url:s})}),e.jsx(u,{value:t.notify_email_from??"",placeholder:"From — nest@yourcompany.com",onChange:s=>i({notify_email_from:s})}),e.jsx(u,{value:t.notify_email_to??"",placeholder:"To — team@yourcompany.com, ops@yourcompany.com",onChange:s=>i({notify_email_to:s})})]})]})]}),e.jsxs(E,{value:"advanced",className:"space-y-4",children:[e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Usage telemetry"}),e.jsx(m,{children:"Send anonymous usage counts to PromptOwl. Turn off to keep all usage data on this server."})]}),e.jsx(h,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.telemetry_enabled?"On":"Off"}),e.jsx(g,{checked:t.telemetry_enabled,onCheckedChange:s=>i({telemetry_enabled:s})})]})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Product analytics"}),e.jsx(m,{children:"Send usage events to your own PostHog project. Leave the key empty to keep analytics off. Also off whenever usage telemetry above is off."})]}),e.jsxs(h,{className:"space-y-3",children:[e.jsx(u,{value:t.posthog_key??"",placeholder:"Project API key — phc_...",onChange:s=>i({posthog_key:s})}),e.jsx(u,{value:t.posthog_host??"",placeholder:"Host — https://us.i.posthog.com",onChange:s=>i({posthog_host:s})})]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Max upload size"}),e.jsx(m,{children:"Largest request/file accepted, in megabytes. Raise this if big HTML artifacts (decks, dashboards) get rejected."})]}),e.jsx(h,{children:e.jsx(ss,{bytes:t.max_body_bytes,onChange:s=>i({max_body_bytes:s})})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Activity trace retention"}),e.jsx(m,{children:"How many days of activity-trace rows (API requests and MCP tool calls) to keep. Older rows are pruned opportunistically. Set 0 to keep activity forever."})]}),e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:t.trace_retention_days,min:0,max:3650,onChange:s=>i({trace_retention_days:s})}),e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"days"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"0–3650 — 0 disables pruning entirely."})]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Content types"}),e.jsx(m,{children:"Which node types can be created on this server. Turning one off hides it from the editor and refuses new creations — existing nodes of that type stay readable and versioned. Runnable types (agent, skill, tool) are governed by the workflow plane below."})]}),e.jsxs(h,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:["Artifacts (hosted HTML) —"," ",t.type_artifact_enabled?"On":"Off"]}),e.jsx(g,{checked:t.type_artifact_enabled,onCheckedChange:s=>i({type_artifact_enabled:s})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:["Tables (CSV fact stores) —"," ",t.type_table_enabled?"On":"Off"]}),e.jsx(g,{checked:t.type_table_enabled,onCheckedChange:s=>i({type_table_enabled:s})})]})]})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsxs(d,{className:"text-base",children:["Workflow plane ",e.jsx(He,{className:"ml-1 align-middle"})]}),e.jsx(m,{children:"Typed edges, an edge-type registry, and governed runs — the automation layer. Optional; off by default. Turning it on adds API surface and UI views but changes nothing until someone creates an edge."})]}),e.jsx(h,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.workflow_plane_enabled?"On":"Off"}),e.jsx(g,{checked:t.workflow_plane_enabled,onCheckedChange:s=>i({workflow_plane_enabled:s,...s?{}:{subagent_runs_enabled:!1}})})]})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Import teams from PromptOwl"}),e.jsx(m,{children:"Lets users who signed in with PromptOwl pull their PromptOwl teams in as local teams. Off by default. When off, the PromptOwl Teams panel is hidden and the import API is unavailable."})]}),e.jsx(h,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm",children:t.promptowl_teams_enabled?"On":"Off"}),e.jsx(g,{checked:t.promptowl_teams_enabled,onCheckedChange:s=>i({promptowl_teams_enabled:s})})]})})]}),e.jsxs(o,{children:[e.jsxs(c,{children:[e.jsx(d,{className:"text-base",children:"Sub-agent runs (recursion)"}),e.jsx(m,{children:"Lets a run spawn nested sub-agent runs (a call tree). Bounded by depth, fan-out and re-entrancy caps so the tree stays finite. This opens a recursion surface — enable it only after reviewing the caps for your deployment. Requires the workflow plane."})]}),e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm",children:[t.subagent_runs_enabled?"On":"Off",!t.workflow_plane_enabled&&e.jsxs("span",{className:"text-muted-foreground",children:[" ","· enable the workflow plane first"]})]}),e.jsx(g,{checked:t.subagent_runs_enabled,disabled:!t.workflow_plane_enabled,onCheckedChange:s=>i({subagent_runs_enabled:s})})]}),t.subagent_runs_enabled&&e.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Max depth"}),e.jsx(K,{value:t.subagent_max_depth,min:1,max:32,onChange:s=>i({subagent_max_depth:s})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"1–32 — how deep the sub-agent call tree may nest."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-1",children:"Max sub-agents per run"}),e.jsx(K,{value:t.subagent_max_children,min:1,max:128,onChange:s=>i({subagent_max_children:s})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"1–128 — fan-out a single run may spawn."})]})]})]})]})]}),e.jsx(E,{value:"community-sites",className:"space-y-4",children:e.jsxs(o,{children:[e.jsx(c,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs(d,{className:"flex items-center gap-2 text-base",children:[e.jsx(Ye,{className:"h-4 w-4 text-muted-foreground"}),"Official community sites"]}),e.jsx(m,{children:"Sites trusted for one-click SSO auto-login. A visitor arriving with a ticket signed by one of these sites' secrets is signed in automatically — the ticket's audience is also checked against this server's own base URL, so a ticket minted for a different deployment can't be replayed here."})]}),e.jsxs(y,{size:"sm",onClick:be,children:[e.jsx(Ge,{className:"h-4 w-4 mr-1.5"}),"Add site"]})]})}),e.jsxs(h,{children:[Y&&e.jsx("div",{role:"alert",className:"mb-4 rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:Y}),G?G.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-6",children:"No community sites configured yet. Add one to enable SSO auto-login from it."}):e.jsx("div",{className:"divide-y",children:G.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(We,{variant:"outline",className:s.is_active?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-muted-foreground/20 text-muted-foreground",children:s.is_active?"Enabled":"Disabled"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[s.url," · secret ",s.secret_set?"set":"not set"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(g,{checked:s.is_active,onCheckedChange:()=>we(s),"aria-label":`Enable ${s.name}`,title:"Enabled sites can sign visitors in with an SSO ticket. This is the admin switch, not a reachability check."}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>ve(s),title:"Edit this community site",children:e.jsx(qe,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>M(s),title:"Remove this community site",children:e.jsx(Xe,{className:"h-4 w-4"})})]})]},s.id))}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[e.jsx(S,{className:"h-4 w-4 animate-spin"})," Loading community sites…"]})]})]})})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-10",children:[e.jsx(S,{className:"h-4 w-4 animate-spin"})," Loading settings…"]}),e.jsx(de,{open:!!j,onOpenChange:s=>!s&&T(null),children:e.jsxs(me,{children:[e.jsxs(he,{children:[e.jsx(ue,{children:(j==null?void 0:j.mode)==="edit"?"Edit community site":"Add community site"}),e.jsx(xe,{children:"The secret is write-only — leave it blank when editing to keep the current one."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(z,{htmlFor:"site-name",children:"Name"}),e.jsx(P,{id:"site-name",value:b.name,onChange:s=>N(a=>({...a,name:s.target.value})),placeholder:"Main community site"})]}),e.jsxs("div",{children:[e.jsx(z,{htmlFor:"site-url",children:"Site URL"}),e.jsx(P,{id:"site-url",value:b.url,onChange:s=>N(a=>({...a,url:s.target.value})),placeholder:"https://community.example.com"})]}),e.jsxs("div",{children:[e.jsx(z,{htmlFor:"site-secret",children:"Secret key"}),e.jsx(P,{id:"site-secret",type:"password",value:b.secret,onChange:s=>N(a=>({...a,secret:s.target.value})),placeholder:(j==null?void 0:j.mode)==="edit"?"Leave blank to keep the current secret":"Shared secret (16+ characters)",...H("password")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{htmlFor:"site-active",children:"Auto-login enabled"}),e.jsx(g,{id:"site-active",checked:b.is_active,onCheckedChange:s=>N(a=>({...a,is_active:s}))})]}),se&&e.jsx("div",{role:"alert",className:"text-sm text-destructive",children:se})]}),e.jsxs(pe,{children:[e.jsx(y,{variant:"outline",onClick:()=>T(null),children:"Cancel"}),e.jsxs(y,{onClick:ye,disabled:Z,children:[Z&&e.jsx(S,{className:"h-4 w-4 mr-1.5 animate-spin"}),(j==null?void 0:j.mode)==="edit"?"Save changes":"Add site"]})]})]})}),e.jsx(de,{open:!!C,onOpenChange:s=>!s&&M(null),children:e.jsxs(me,{children:[e.jsxs(he,{children:[e.jsxs(ue,{children:["Remove ",C==null?void 0:C.name,"?"]}),e.jsx(xe,{children:"Visitors arriving from this site will no longer be auto-signed-in. This can't be undone from here — you'll need to re-add the site and its secret to restore it."})]}),e.jsxs(pe,{children:[e.jsx(y,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),e.jsxs(y,{variant:"destructive",onClick:ke,disabled:te,children:[te&&e.jsx(S,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Remove"]})]})]})})]})}function os(){const{isAdmin:n,refreshHealth:w}=Pe(),[t,p]=l.useState(null);l.useEffect(()=>{n&&Te().then(p).catch(()=>{})},[n]);const _=l.useCallback(async x=>{try{const f=await Ie(x);p(f.settings),await w(),O.success("Settings saved")}catch(f){throw O.error((f==null?void 0:f.message)||"Failed to save settings"),f}},[w]);return e.jsx(ts,{settings:t,onUpdate:_})}export{os as default};
@@ -1 +0,0 @@
1
- import{ch as K,O as V,r as i,u as G,bU as J,j as e,aa as W,I as X,L as R,B as h,bA as Y,bx as Z,i as ee,ax as te,f as k,a5 as se}from"./index-EaX2yql0.js";import{r as ae}from"./dates-BCxbm4_q.js";import{P as re}from"./page-title-ClvvBsIo.js";import{f as T}from"./scroll-area-hz-xtayP.js";import"./select-DBFTrUmI.js";import"./card-XG2dP5Xf.js";import{S as ie}from"./SubmitForReviewModal-Ci2DdWs0.js";import{A as ne,a as oe,b as le,c as de,d as ce,e as me,f as fe,g as ue}from"./alert-dialog-DTozKlmV.js";import{C as E}from"./circle-check-DI8IBGeo.js";import{T as M}from"./trash-2-HBi-Pslz.js";import{C as he}from"./chevron-left-BPwUT9DS.js";import"./send-0CHvmluT.js";function ke(){var A;const{openReview:F}=K(),{adminStatus:D}=V(),L=((A=D==null?void 0:D.me)==null?void 0:A.email)??null,[c,S]=i.useState([]),[a,P]=i.useState(null),[N,$]=i.useState(!0),[m,j]=i.useState(null),[C,B]=i.useState(""),[v,O]=i.useState(""),[b,Q]=i.useState("updated"),[l,x]=i.useState(new Set),[w,_]=i.useState(!1),[n,y]=i.useState(null),q=G(),u=async t=>{$(!0);try{const s=await q.fetchQuery(ee.myDrafts({offset:t,q:v||void 0,sort:b}));if(s.drafts.length===0&&t>0&&s.pagination.total>0)return void await u(0);S(s.drafts),P(s.pagination)}catch(s){console.error("[Dashboard] goToDraftsPage failed",s),S([])}finally{$(!1)}},I=async(t,s,f)=>{const r=[],d=[];for(const o of t)try{await te(o.nest_id,o.node_id,s,f),r.push(o)}catch(g){d.push(o),console.error("[Dashboard] submitForReview failed",o.node_id,g)}if(S(o=>o.filter(g=>!r.some(H=>p(H)===p(g)))),x(new Set),u((a==null?void 0:a.offset)??0),d.length){j(d);const o=r.length?`${r.length} submitted. `:"";throw new Error(`${o}Couldn't submit ${d.length}: ${d.map(g=>g.title).join(", ")}`)}r.length>1&&k.success(`${r.length} submitted for review`)},p=t=>`${t.nest_id}:${t.node_id}`;i.useEffect(()=>{const t=setTimeout(()=>O(C.trim()),250);return()=>clearTimeout(t)},[C]),i.useEffect(()=>{u(0)},[L]);const z=J.useRef(!1);i.useEffect(()=>{if(!z.current){z.current=!0;return}x(new Set),u(0)},[v,b]);const U=async t=>{if(t.length===0)return;y(null),_(!0);let s=0,f=0;const r=[];for(const d of t)try{(await se(d.nest_id,d.node_id)).deleted?f++:s++}catch(o){r.push(d.title),console.error("[Dashboard] discardDraft failed",d.node_id,o)}_(!1),x(new Set),(s||f)&&k.success([s?`${s} restored to the approved version`:"",f?`${f} deleted`:""].filter(Boolean).join(" · ")),r.length&&k.error(`Couldn't discard: ${r.join(", ")}`),u((a==null?void 0:a.offset)??0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{icon:W,title:"My Drafts",description:"Everything you started and never handed off.",className:"mb-0"}),e.jsx("div",{children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(X,{value:C,onChange:t=>B(t.target.value),placeholder:"Search drafts by title or nest…",className:"h-8 max-w-xs","aria-label":"Search your drafts","data-testid":"drafts-search"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Sort:"}),e.jsx("div",{className:"inline-flex items-center rounded-md border bg-muted/40 p-0.5",role:"group","aria-label":"Sort drafts",children:[["updated","Recently edited"],["title","Title"]].map(([t,s])=>e.jsx("button",{type:"button","aria-pressed":b===t,onClick:()=>Q(t),className:`h-6 rounded px-2 text-xs transition-colors ${b===t?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,"data-testid":`drafts-sort-${t}`,children:s},t))})]})]}),N?e.jsxs("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"}),"Loading your drafts…"]}):c.length===0?e.jsx("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 text-center text-sm text-muted-foreground",children:v?`No drafts match "${v}".`:"No unsubmitted drafts — everything you've written is in review or approved."}):e.jsxs("div",{className:"rounded-lg border divide-y overflow-hidden",children:[c.length>1&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-muted/40 px-4 py-2 text-sm",children:[e.jsx(T,{checked:l.size===0?!1:l.size===c.length?!0:"indeterminate",onCheckedChange:t=>x(t===!0?new Set(c.map(p)):new Set),"aria-label":"Select every draft on this page","data-testid":"drafts-select-all"}),e.jsx("span",{className:"text-muted-foreground",children:l.size>0?`${l.size} selected`:`Select all ${c.length} on this page`}),l.size>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs(h,{size:"sm",variant:"outline",disabled:w,onClick:()=>j(c.filter(t=>l.has(p(t)))),"data-testid":"drafts-bulk-submit",children:[e.jsx(E,{className:"h-3.5 w-3.5 mr-1"}),"Submit ",l.size," for review"]}),e.jsxs(h,{size:"sm",variant:"outline",disabled:w,onClick:()=>y(c.filter(t=>l.has(p(t)))),"data-testid":"drafts-bulk-discard",children:[w?e.jsx(R,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(M,{className:"h-3.5 w-3.5 mr-1"}),"Discard ",l.size]}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>x(new Set),children:"Clear"})]})]}),c.map(t=>{const s=`${t.nest_id}:${t.node_id}`;return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-muted/40 group",children:[c.length>1&&e.jsx(T,{checked:l.has(s),onCheckedChange:()=>x(f=>{const r=new Set(f);return r.has(s)?r.delete(s):r.add(s),r}),"aria-label":`Select ${t.title}`}),e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide shrink-0 ${t.status==="rejected"?"bg-red-100 text-red-800 dark:bg-red-950/40 dark:text-red-300":"bg-muted text-muted-foreground"}`,children:t.status==="rejected"?"Rejected":"Draft"}),e.jsxs("button",{onClick:()=>F(t.nest_id,t.nest_name,t.node_id),className:"flex flex-col min-w-0 flex-1 text-left gap-0.5",children:[e.jsx("span",{className:"font-medium truncate",children:t.title}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",title:`${t.nest_name} / ${t.node_id}`,children:[e.jsx(Y,{className:"h-3 w-3 inline mr-1 -mt-0.5"}),t.nest_name,t.folder?` / ${t.folder}`:""," · edited"," ",ae(t.updated_at)]})]}),e.jsxs(h,{size:"sm",variant:"outline",className:"shrink-0",onClick:()=>j([t]),children:[e.jsx(E,{className:"h-3.5 w-3.5 mr-1"}),"Submit for review"]}),e.jsx(h,{size:"sm",variant:"ghost",disabled:w,className:"shrink-0 text-muted-foreground hover:text-destructive",title:"Discard this draft — back to the last approved version, or delete it if there isn't one",onClick:()=>y([t]),"data-testid":"draft-discard",children:e.jsx(M,{className:"h-3.5 w-3.5"})})]},s)})]}),a&&a.total>a.limit&&e.jsxs("div",{className:"flex items-center justify-center gap-3 pt-3 text-sm text-muted-foreground",children:[e.jsxs(h,{variant:"outline",size:"sm",disabled:N||a.offset===0,onClick:()=>u(Math.max(0,a.offset-a.limit)),children:[e.jsx(he,{className:"h-3.5 w-3.5 mr-1"}),"Prev"]}),e.jsxs("span",{children:["Page ",Math.floor(a.offset/a.limit)+1," of"," ",Math.max(1,Math.ceil(a.total/a.limit))]}),e.jsxs(h,{variant:"outline",size:"sm",disabled:N||!a.has_more,onClick:()=>u(a.offset+a.limit),children:["Next",e.jsx(Z,{className:"h-3.5 w-3.5 ml-1"})]})]})]})}),m&&m.length>0&&e.jsx(ie,{isOpen:!0,onClose:()=>j(null),documentTitle:m.length===1?m[0].title:`${m.length} drafts`,currentVersion:m.length===1?m[0].version:null,onSubmit:(t,s)=>I(m,t,s)}),e.jsx(ne,{open:!!n,onOpenChange:t=>!t&&y(null),children:e.jsxs(oe,{children:[e.jsxs(le,{children:[e.jsx(de,{children:(n==null?void 0:n.length)===1?`Discard "${n[0].title}"?`:`Discard ${(n==null?void 0:n.length)??0} drafts?`}),e.jsxs(ce,{children:[(n==null?void 0:n.length)===1?"The document goes":"Each document goes"," ","back to its last approved version. A document that was never approved is deleted instead. This can't be undone."]})]}),e.jsxs(me,{children:[e.jsx(fe,{children:"Cancel"}),e.jsx(ue,{onClick:()=>void U(n??[]),"data-testid":"drafts-discard-confirm",children:"Discard"})]})]})})]})}export{ke as default};
@@ -1 +0,0 @@
1
- import{O as ue,u as me,r as o,aH as ge,aI as fe,_ as pe,i as xe,aJ as W,aK as he,aL as ye,aM as je,f as v,ap as ve,l as Ne,aN as p,au as V,aO as be,j as e,I as Y,B as q,aP as Ce,L as we,aQ as ke,aR as K,a2 as De,aS as Se,F as Oe,aT as Ae}from"./index-EaX2yql0.js";import{N as Fe}from"./NestPageHeader-CoLUV1Oz.js";import{s as Ee}from"./folder-target-CUSWqImF.js";import{R as Te}from"./refresh-cw-BhHzSH9m.js";import{X as $e}from"./x-By7piikG.js";import{G as Me,Z as Re}from"./zap-C2T8riBp.js";import"./arrow-left-BCKt4CwQ.js";const ee="cn.board.";function Le(n){try{const u=localStorage.getItem(ee+n);if(u){const m=JSON.parse(u),N=m.dimension==="status"||m.dimension==="tag"?m.dimension:"folder",k=typeof m.tagNamespace=="string"?m.tagNamespace:"",x=l=>Array.isArray(l)?l.filter(f=>typeof f=="string"):void 0,g={};for(const[l,f]of Object.entries(m.layouts??{}))f&&typeof f=="object"&&(g[l]=K(l,{columnOrder:x(f.columnOrder),hiddenColumns:x(f.hiddenColumns)}));const h={columnOrder:x(m.columnOrder),hiddenColumns:x(m.hiddenColumns)};if(h.columnOrder||h.hiddenColumns){const l=W({dimension:N,tagNamespace:k});g[l]??(g[l]=K(l,h))}return{dimension:N,tagNamespace:k,layouts:g}}}catch{}return{dimension:"folder",tagNamespace:"",layouts:{}}}function U(n,u){try{localStorage.setItem(ee+n,JSON.stringify(u))}catch{}}function Be({type:n}){const u="h-3.5 w-3.5 shrink-0";return n==="skill"?e.jsx(Re,{className:`${u} text-blue-500`}):n==="agent"?e.jsx(De,{className:`${u} text-violet-500`}):n==="table"?e.jsx(Se,{className:`${u} text-emerald-500`}):e.jsx(Oe,{className:`${u} text-muted-foreground`})}function Pe({nestId:n,nestName:u,isOwner:m,isArchived:N,onBack:k,onOpenDocument:x}){var X,Z,I;const{isAdmin:g}=ue(),h=me(),[l,f]=o.useState([]),[F,P]=o.useState(!0),[G,z]=o.useState(null),[d,H]=o.useState(()=>Le(n)),[E,T]=o.useState(null),[_,$]=o.useState(null),[se,D]=o.useState(null),[te,J]=o.useState(!1),[S,ae]=o.useState(!1);o.useEffect(()=>{let s=!1;return ge(n).then(t=>{s||ae(fe({roles:(t==null?void 0:t.roles)??[],permission:(t==null?void 0:t.permission)??null,myStewards:(t==null?void 0:t.myStewards)??[],isOwner:m,isAdmin:g,isArchived:N||pe(t==null?void 0:t.nest)}).canEditDocs)}).catch(()=>{}),()=>{s=!0}},[n,m,g,N]);const b=o.useCallback(async()=>{P(!0),z(null);try{const{nodes:s}=await h.fetchQuery(xe.nodesMeta(n));f(s.map(t=>({id:t.id,title:t.title??t.id,type:t.type??"document",tags:Array.isArray(t.tags)?t.tags:[],status:t.status??""})))}catch(s){z((s==null?void 0:s.message)||"Failed to load nodes")}finally{P(!1)}},[n,h]);o.useEffect(()=>{b()},[b]);const Q=o.useCallback(s=>{H(t=>{const i={...t,...s};return U(n,i),i})},[n]),y=o.useCallback(s=>{H(t=>{const i=W(t),a={...t,layouts:{...t.layouts,[i]:{...t.layouts[i],...s}}};return U(n,a),a})},[n]),r=o.useMemo(()=>he(d),[d]),{columns:C,byColumn:ne}=o.useMemo(()=>ye(l,r),[l,r]),re=o.useCallback(async s=>{const t=E,i=_;if(T(null),$(null),D(null),!t)return;const a=l.find(w=>w.id===t);if(!a)return;const c=je(a,s,r,i??void 0);if(c.kind==="unsupported"){c.reason!=="Already in this column."&&v(c.reason);return}J(!0);try{c.kind==="move-folder"?(await ve(n,t,c.folder),v.success("Moved")):c.kind==="retag"&&(await Ne(n,t,{tags:c.tags}),v.success("Retagged")),await b()}catch(w){v.error((w==null?void 0:w.message)||"Move failed")}finally{J(!1)}},[E,_,l,r,n,b]),O=(r.dimension==="folder"||r.dimension==="tag")&&S,[M,R]=o.useState(null),[oe,A]=o.useState(null),[L,B]=o.useState(""),j=o.useMemo(()=>C.map(s=>s.key).filter(s=>s!==p),[C]),ie=o.useCallback((s,t)=>{if(s===t)return;const i=[...j],a=i.indexOf(s),c=i.indexOf(t);a<0||c<0||(i.splice(a,1),i.splice(c,0,s),y({columnOrder:i}))},[j,y]),le=o.useCallback(s=>y({...r.explicitColumns?{columnOrder:j.filter(t=>t!==s)}:{},hiddenColumns:[...new Set([...r.hiddenColumns??[],s])]}),[j,r.explicitColumns,r.hiddenColumns,y]),de=o.useCallback(s=>{const t=r.dimension==="folder"?Ee(s):s.trim().replace(/^#/,"");if(r.dimension==="folder"&&!t){s.trim()&&v("A folder name needs at least one letter or digit.");return}if(t){if(r.dimension==="folder"&&t.split("/").length>V){v(`Folders may nest at most ${V} levels deep.`);return}y({columnOrder:[...new Set([...j,t])],hiddenColumns:(r.hiddenColumns??[]).filter(i=>i!==t)}),B("")}},[j,r.dimension,r.hiddenColumns,y]),ce=o.useMemo(()=>{if(r.dimension!=="tag")return[];const s=new Set;for(const t of l)for(const i of be(t,r))i!==p&&s.add(i);return[...s].sort()},[l,r]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Fe,{nestName:u,onBack:k,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Columns by"}),e.jsxs("select",{value:d.dimension,onChange:s=>{B(""),Q({dimension:s.target.value})},className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"folder",children:"Folder"}),e.jsx("option",{value:"status",children:"Status"}),e.jsx("option",{value:"tag",children:"Tag namespace"})]}),d.dimension==="tag"&&e.jsx(Y,{value:d.tagNamespace??"",onChange:s=>Q({tagNamespace:s.target.value}),placeholder:"all tags",className:"h-8 w-32",title:"Optional. Empty groups by every tag; a namespace like 'stage' groups by stage:<value> tags only."}),(d.dimension==="tag"||r.dimension==="folder"&&S)&&e.jsxs("form",{onSubmit:s=>{s.preventDefault(),de(L)},className:"flex items-center gap-1",children:[e.jsx(Y,{value:L,onChange:s=>B(s.target.value),placeholder:d.dimension==="tag"?"add column…":"new folder…",list:d.dimension==="tag"?"board-tag-values":void 0,className:"h-8 w-32",title:d.dimension==="tag"?"Add a tag column — pick an existing tag or type a new value":"Add a folder column — drag a card into it to file the document there (nest with parent/child)"}),d.dimension==="tag"&&e.jsx("datalist",{id:"board-tag-values",children:ce.map(s=>e.jsx("option",{value:s},s))}),e.jsx(q,{type:"submit",variant:"outline",size:"sm",disabled:!L.trim(),title:d.dimension==="tag"?"Add column":"Add folder column",children:e.jsx(Ce,{className:"h-3.5 w-3.5"})})]}),e.jsx(q,{variant:"outline",size:"sm",onClick:b,disabled:F,children:e.jsx(Te,{className:`h-3.5 w-3.5 ${F?"animate-spin":""}`})})]})}),e.jsx("ul",{className:"max-w-2xl list-disc space-y-1 pl-5 text-xs text-muted-foreground",children:d.dimension==="status"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Status is"," ",e.jsx("span",{className:"font-medium text-foreground",children:"read-only"})," ","here — move a doc through review in the document view."]}),e.jsxs("li",{children:["Switch to"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Folder"})," for a draggable board."]}),e.jsx("li",{children:"Drag a column header to reorder."})]}):d.dimension==="tag"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Grouped by"," ",e.jsx("span",{className:"font-medium text-foreground",children:(X=d.tagNamespace)!=null&&X.trim()?`${d.tagNamespace.trim().split(":")[0]}:`:"tag"}),(Z=d.tagNamespace)!=null&&Z.trim()?" — only documents carrying one show up.":" — one column per tag, so a document with several tags appears in each."]}),e.jsx("li",{children:(I=d.tagNamespace)!=null&&I.trim()?"Clear the box to group by every tag.":"Type a namespace (e.g. stage) to group by stage: values only."}),e.jsx("li",{children:S?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Drag a card"})," ","between columns to swap its tag; drag a header to reorder."]}):e.jsxs(e.Fragment,{children:["You have"," ",e.jsx("span",{className:"font-medium text-foreground",children:"read-only"})," ","access, so cards can't be retagged. Drag a header to reorder."]})}),e.jsxs("li",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"+"})," to add a column, ",e.jsx("span",{className:"font-medium text-foreground",children:"×"})," to remove one."]})]}):S?C.length<2?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["Every document is in"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Root"}),". Type a name in"," ",e.jsx("span",{className:"font-medium text-foreground",children:"new folder"})," ","above to add a column."]}),e.jsxs("li",{children:["Then ",e.jsx("span",{className:"font-medium text-foreground",children:"drag a card"})," ","into it — that files the document in the folder."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Drag a card"})," ","between columns to move it to that folder."]}),e.jsxs("li",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Drag a column header"})," ","to reorder."]}),e.jsxs("li",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"new folder"})," ","adds a column; it sticks once a card lands in it."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["You have"," ",e.jsx("span",{className:"font-medium text-foreground",children:"read-only"})," ","access to this nest, so cards can't be moved."]}),e.jsx("li",{children:"Ask the nest owner for write access to rearrange the board."})]})}),F?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground py-12 justify-center",children:[e.jsx(we,{className:"h-4 w-4 animate-spin"})," Loading board…"]}):G?e.jsx("div",{className:"text-sm text-destructive py-8",children:G}):C.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-8",children:r.dimension==="tag"?"No tag columns yet — add one above to start sorting documents into it.":"No documents to show."}):e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-4",children:C.map(s=>{const t=ne[s.key]??[],i=se===s.key;return e.jsxs("div",{onDragOver:a=>{if(M){a.preventDefault(),A(s.key);return}O&&(a.preventDefault(),D(s.key))},onDragLeave:()=>{D(a=>a===s.key?null:a),A(a=>a===s.key?null:a)},onDrop:a=>{if(a.preventDefault(),M){ie(M,s.key),R(null),A(null);return}re(s.key)},className:`flex-shrink-0 w-64 rounded-lg border bg-muted/30 flex flex-col max-h-[70vh] transition-colors ${i?"border-primary ring-1 ring-primary":"border-border"}`,children:[e.jsxs("div",{className:`flex items-center justify-between gap-1 px-3 py-2 border-b border-border sticky top-0 ${s.key!==p?"cursor-grab active:cursor-grabbing":""} ${oe===s.key?"bg-primary/10":""}`,draggable:s.key!==p,onDragStart:a=>{s.key!==p&&(R(s.key),a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",`col:${s.key}`))},onDragEnd:()=>{R(null),A(null)},title:s.title,children:[e.jsx("span",{className:`min-w-0 text-sm font-medium truncate ${ke(r.dimension)?"capitalize":""} ${s.key===p?"text-muted-foreground":""}`,children:s.label}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:t.length}),s.key!==p&&(r.dimension==="tag"||r.dimension==="folder"&&t.length===0)&&e.jsx("button",{type:"button",onClick:()=>le(s.key),className:"text-muted-foreground/50 hover:text-foreground",title:r.dimension==="folder"?"Remove this empty column":"Remove this column — its cards drop off the board; their tags aren't changed",children:e.jsx($e,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-2",children:[t.map(a=>e.jsxs("div",{draggable:O,onDragStart:c=>{T(a.id),$(s.key),c.dataTransfer.effectAllowed="move",c.dataTransfer.setData("text/plain",a.id)},onDragEnd:()=>{T(null),$(null),D(null)},onClick:()=>x(a.id),className:`group rounded-md border border-border bg-card px-2.5 py-2 text-sm cursor-pointer hover:border-primary/60 hover:shadow-sm transition ${E===a.id?"opacity-50":""} ${te?"pointer-events-none":""}`,children:[e.jsxs("div",{className:"flex items-start gap-1.5",children:[O&&e.jsx(Me,{className:"h-3.5 w-3.5 mt-0.5 text-muted-foreground/40 group-hover:text-muted-foreground shrink-0"}),e.jsx(Be,{type:a.type}),e.jsx("span",{className:"min-w-0 flex-1 leading-snug break-words",children:a.title})]}),a.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5 pl-5",children:a.tags.slice(0,4).map(c=>e.jsx("span",{className:"text-[10px] px-1 py-0.5 rounded bg-muted text-muted-foreground",children:c},c))})]},a.id)),t.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground/60 text-center py-6",children:O?"Drop here":"Empty"})]})]},s.key)})})]})}function Ie(){const n=Ae();return e.jsx(Pe,{nestId:n.nestId,nestName:n.nestName,isOwner:n.isOwner,isArchived:n.isArchived,onBack:n.leaveNest,onOpenDocument:n.openDocument})}export{Ie as default};
@@ -1 +0,0 @@
1
- import{ch as he,O as ue,r as h,u as pe,i as U,cl as F,j as t,cm as xe,cn as q,C as fe,f as x,s as ge,L as ve,B as u,bx as K,co as be,cp as je,cq as ye,bO as ke,bP as Ne,aC as _e,at as we}from"./index-EaX2yql0.js";import{f as Ce,r as Q}from"./dates-BCxbm4_q.js";import{P as Re}from"./page-title-ClvvBsIo.js";import{A as Se,a as $e,R as Ae}from"./ReviewActions-OfOdqzCn.js";import{f as V}from"./scroll-area-hz-xtayP.js";import"./select-DBFTrUmI.js";import"./card-XG2dP5Xf.js";import{R as J}from"./ReasonDialog-DgLxfRWv.js";import{C as We}from"./circle-check-DI8IBGeo.js";import{T as qe}from"./trash-2-HBi-Pslz.js";import{C as Te}from"./circle-x-VKVhC88W.js";import{C as De}from"./chevron-left-BPwUT9DS.js";const Y=8;function ze(f,j,g=Y){return j?f:f.slice(0,g)}function X(f,j){return f.filter(g=>g.id!==j)}function Je(){var I,E;const{openNest:f,openReview:j}=he(),{adminStatus:g}=ue(),G=((I=g==null?void 0:g.me)==null?void 0:I.email)??null,[n,m]=h.useState({items:[],waiting:[]}),[H,Z]=h.useState(!0),[T,D]=h.useState(!1),[l,S]=h.useState(null),[y,z]=h.useState("delete"),[d,v]=h.useState(new Set),[p,N]=h.useState(null),[$,ee]=h.useState(!1),M=pe(),w=async e=>{D(!0);try{const s=await M.fetchQuery(U.myWork({offset:e}));m(a=>({items:s.items,waiting:s.waiting,notifications:s.notifications??a.notifications,pagination:s.pagination}));const i=new Set(s.items.map(a=>`${a.nest_id}:${a.node_id}`));v(a=>new Set([...a].filter(k=>i.has(k))))}catch(s){console.error("[Dashboard] goToWorkPage failed",s)}finally{D(!1)}};h.useEffect(()=>{M.fetchQuery(U.myWork()).then(m).catch(()=>m({items:[],waiting:[],notifications:[]})).finally(()=>Z(!1))},[G]);const te=async(e,s)=>{await be(e.nest_id,e.node_id,s),R(e)},se=async(e,s)=>{await je(e.nest_id,e.node_id,s),R(e)},b=n.items.filter(e=>e.type==="review"),A=e=>`${e.nest_id}:${e.node_id}`,C=(()=>{const e=new Map;for(const i of b)d.has(A(i))&&e.set(i.nest_id,(e.get(i.nest_id)??0)+1);const s=Math.max(0,...e.values());return Math.max(0,s-F)})(),ie=async(e,s)=>{var B;const i=b.filter(o=>d.has(A(o)));if(i.length===0){x.info("Nothing selected on this page"),v(new Set),N(null);return}const a=new Map;for(const o of i)a.set(o.nest_id,[...a.get(o.nest_id)??[],o.node_id]);const k=await Promise.all([...a].map(([o,r])=>ye(o,e,r,s||void 0).then(_=>({nestId:o,..._})).catch(_=>({nestId:o,succeeded:0,failed:r.length,results:r.map(me=>({nodeId:me,ok:!1,error:(_==null?void 0:_.message)||"Request failed"}))})))),W=k.reduce((o,r)=>o+r.succeeded,0),L=k.reduce((o,r)=>o+r.failed,0),ce=new Set(k.flatMap(o=>o.results.filter(r=>!r.ok).map(r=>`${o.nestId}:${r.nodeId}`))),O=e==="approve"?"approved":"rejected";if(L===0)x.success(`${W} document${W===1?"":"s"} ${O}`);else{const o=[...new Set(k.flatMap(r=>r.results).filter(r=>!r.ok).map(r=>r.error||"Unknown reason"))];x.warning(`${W} ${O}, ${L} could not be`,{description:o.join(" "),duration:1e4})}v(ce),N(null),w(((B=n.pagination)==null?void 0:B.offset)??0)},c=e=>e.target_type==="nest_archive",ne=e=>e.type!=="deletion"?"Review":c(e)?"Archive":"Deletion",ae=async()=>{const e=l;await ke(e.nest_id,e.request_id),R(e)},oe=async e=>{const s=l;await Ne(s.nest_id,s.request_id,e),R(s)},re=async e=>{await _e(e.nest_id,e.request_id),m(s=>({...s,waiting:s.waiting.filter(i=>!(i.nest_id===e.nest_id&&i.node_id===e.node_id))}))},de=async e=>{await we(e.nest_id,e.node_id),m(s=>({...s,waiting:s.waiting.filter(i=>!(i.nest_id===e.nest_id&&i.node_id===e.node_id))}))},P=e=>{if(e.type==="deletion"&&e.target_type&&e.target_type!=="document"){f(e.nest_id,e.nest_name,!1,!1);return}j(e.nest_id,e.nest_name,e.node_id)},le=e=>{q([e.id]).catch(()=>{}),m(s=>({...s,notifications:X(s.notifications??[],e.id)})),e.node_id?j(e.nest_id,e.nest_name,e.node_id):f(e.nest_id,e.nest_name,!1,!1)},R=e=>{var s;m(i=>({...i,items:i.items.filter(a=>!(a.nest_id===e.nest_id&&a.node_id===e.node_id))})),v(i=>{const a=new Set(i);return a.delete(`${e.nest_id}:${e.node_id}`),a}),w(((s=n.pagination)==null?void 0:s.offset)??0)};return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Re,{icon:xe,title:"My Work",description:"Reviews and requests waiting on you, and what you handed off.",className:"mb-0"}),t.jsx("div",{children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{children:[(((E=n.notifications)==null?void 0:E.length)??0)>0&&t.jsxs("div",{className:"mb-3 rounded-lg border border-amber-300/50 bg-amber-500/5",children:[t.jsxs("div",{className:"px-4 py-2 flex items-center gap-2 text-sm font-medium",children:["🔔 Notifications",t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",n.notifications.length,")"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:async()=>{await q("all"),m(e=>({...e,notifications:[]}))},children:"Mark all read"})]}),t.jsx("div",{className:ge("divide-y border-t",$&&"max-h-80 overflow-y-auto"),children:ze(n.notifications,$).map(e=>t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs hover:bg-amber-500/10",children:[t.jsxs("button",{type:"button",onClick:()=>le(e),className:"flex-1 flex items-center gap-2 text-left",children:[t.jsx("span",{className:"flex-1",children:e.message}),t.jsx("span",{className:"text-muted-foreground shrink-0",children:Ce(e.created_at)})]}),t.jsx("button",{type:"button",title:"Mark as read","aria-label":"Mark as read",className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-amber-500/20 hover:text-foreground",onClick:async()=>{try{await q([e.id]),m(s=>({...s,notifications:X(s.notifications??[],e.id)}))}catch(s){x.error((s==null?void 0:s.message)||"Failed to mark as read")}},children:t.jsx(fe,{className:"h-3.5 w-3.5"})})]},e.id))}),n.notifications.length>Y&&t.jsx("div",{className:"border-t px-4 py-1.5 text-center",children:t.jsx("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:()=>ee(e=>!e),children:$?"Show less":`Show all (${n.notifications.length})`})})]}),H?t.jsxs("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(ve,{className:"h-4 w-4 animate-spin"}),"Loading your work…"]}):n.items.length===0?t.jsx("div",{className:"rounded-lg border bg-muted/20 px-4 py-6 text-center text-sm text-muted-foreground",children:"You're all caught up — nothing waiting on you."}):t.jsxs("div",{className:"rounded-lg border divide-y overflow-hidden",children:[b.length>1&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-muted/40 px-4 py-2 text-sm",children:[t.jsx(V,{checked:d.size===0?!1:d.size===b.length?!0:"indeterminate",onCheckedChange:e=>v(e===!0?new Set(b.map(A)):new Set),"aria-label":"Select every review waiting on you","data-testid":"work-select-all"}),t.jsx("span",{className:"text-muted-foreground",children:d.size>0?`${d.size} selected`:`Select all ${b.length} reviews`}),C>0&&t.jsxs("span",{className:"text-destructive",children:["Up to ",F," per nest — deselect"," ",C,"."]}),d.size>0&&t.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[t.jsxs(u,{size:"sm",disabled:C>0,onClick:()=>N("approve"),"data-testid":"work-bulk-approve",children:["Approve ",d.size]}),t.jsxs(u,{size:"sm",variant:"outline",disabled:C>0,onClick:()=>N("reject"),"data-testid":"work-bulk-reject",children:["Reject ",d.size]}),t.jsx(u,{size:"sm",variant:"ghost",onClick:()=>v(new Set),children:"Clear"})]})]}),n.items.map(e=>{const s=`${e.nest_id}:${e.node_id}`;return t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-muted/40 group",children:[b.length>1&&t.jsx(V,{checked:d.has(s),disabled:e.type!=="review",onCheckedChange:()=>v(i=>{const a=new Set(i);return a.has(s)?a.delete(s):a.add(s),a}),"aria-label":`Select ${e.title}`,className:e.type==="review"?"":"invisible"}),t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide shrink-0 ${e.type==="deletion"&&!c(e)?"bg-red-100 text-red-800 dark:bg-red-950/40 dark:text-red-300":"bg-amber-100 text-amber-800 dark:bg-amber-950/40 dark:text-amber-300"}`,children:ne(e)}),t.jsxs("button",{onClick:()=>P(e),className:"flex items-center gap-2 min-w-0 flex-1 text-left",children:[t.jsx("span",{className:"font-medium truncate",children:e.title}),t.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["in ",e.nest_name," · ",e.requested_by," · ",Q(e.requested_at),e.reason?` · "${e.reason}"`:""]})]}),t.jsx("div",{className:"flex items-center gap-2 shrink-0",children:e.type==="deletion"?t.jsxs(t.Fragment,{children:[t.jsxs(u,{variant:"outline",className:c(e)?Se:"text-destructive hover:text-destructive",onClick:()=>{z("delete"),S(e)},children:[c(e)?t.jsx(We,{className:"h-4 w-4 mr-2"}):t.jsx(qe,{className:"h-4 w-4 mr-2"}),c(e)?"Approve":"Delete"]}),t.jsxs(u,{variant:"outline",className:$e,onClick:()=>{z("decline"),S(e)},children:[t.jsx(Te,{className:"h-4 w-4 mr-2"})," Reject"]})]}):t.jsx(Ae,{documentTitle:e.title,version:1,onApprove:i=>te(e,i),onReject:i=>se(e,i)})})]},s)})]})]}),n.waiting.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Waiting on others"}),t.jsx("span",{className:"rounded-full bg-muted text-muted-foreground text-xs font-semibold px-2 py-0.5",children:n.waiting.length})]}),t.jsx("div",{className:"rounded-lg border divide-y overflow-hidden",children:n.waiting.map(e=>t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-muted/40 group text-sm",children:[t.jsxs("button",{onClick:()=>P(e),className:"flex items-center gap-3 flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"font-medium truncate",children:e.title}),t.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:["in ",e.nest_name," ·"," ",e.type==="deletion"?"requested":"submitted"," ",Q(e.requested_at)]}),t.jsx("span",{className:"flex-1"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:e.type!=="deletion"?"Pending Review":c(e)?"Archive Requested":"Deletion Requested"})]}),e.type==="deletion"&&e.request_id&&t.jsx(u,{size:"sm",variant:"ghost",className:"shrink-0 text-muted-foreground h-7 px-2",onClick:async s=>{s.stopPropagation();try{await re(e),x.success(c(e)?"Archive request withdrawn":"Deletion request withdrawn")}catch(i){x.error((i==null?void 0:i.message)||"Failed to withdraw deletion request")}},title:"Withdraw this deletion request",children:"Withdraw"}),e.type==="review"&&t.jsx(u,{size:"sm",variant:"ghost",className:"shrink-0 text-muted-foreground h-7 px-2",onClick:async s=>{s.stopPropagation();try{await de(e),x.success("Submission withdrawn — back to Draft")}catch(i){x.error((i==null?void 0:i.message)||"Failed to withdraw submission")}},title:"Withdraw this submission and return the document to Draft",children:"Withdraw"}),t.jsx(K,{className:"h-4 w-4 text-muted-foreground group-hover:translate-x-0.5 transition-transform shrink-0"})]},`${e.nest_id}:${e.node_id}`))})]}),n.pagination&&n.pagination.total>n.pagination.limit&&t.jsxs("div",{className:"flex items-center justify-center gap-3 pt-1 text-sm text-muted-foreground",children:[t.jsxs(u,{variant:"outline",size:"sm",disabled:T||n.pagination.offset===0,onClick:()=>w(Math.max(0,n.pagination.offset-n.pagination.limit)),children:[t.jsx(De,{className:"h-3.5 w-3.5 mr-1"}),"Prev"]}),t.jsxs("span",{children:["Page ",Math.floor(n.pagination.offset/n.pagination.limit)+1," of"," ",Math.max(1,Math.ceil(n.pagination.total/n.pagination.limit))]}),t.jsxs(u,{variant:"outline",size:"sm",disabled:T||!n.pagination.has_more,onClick:()=>w(n.pagination.offset+n.pagination.limit),children:["Next",t.jsx(K,{className:"h-3.5 w-3.5 ml-1"})]})]})]})}),p&&t.jsx(J,{open:!0,onOpenChange:e=>!e&&N(null),title:p==="approve"?`Approve ${d.size} document${d.size===1?"":"s"}?`:`Reject ${d.size} document${d.size===1?"":"s"}?`,description:p==="approve"?"Approving publishes each one. Anything that changed since this inbox loaded is reported back and left alone.":"Each author gets the same reason and the work goes back to them.",label:p==="reject"?"Why?":"Comment (optional)",optionalReason:p==="approve",placeholder:"Shared with every author in this batch",confirmLabel:p==="approve"?"Approve all":"Reject all",destructive:p==="reject",onConfirm:e=>ie(p,e)}),l&&t.jsx(J,{open:!0,onOpenChange:e=>!e&&S(null),title:y!=="delete"?`Reject this ${c(l)?"archive":"deletion"} request`:c(l)?`Archive "${l.title}"?`:`Delete "${l.title}"?`,description:`${l.requested_by} asked for this: "${l.reason??""}". ${y!=="delete"?c(l)?"The nest stays where it is; your note is the record, and the requester is notified.":"The document stays; your note is the record, and the requester is notified.":c(l)?"The nest goes read-only and leaves the dashboard; nothing is deleted and you can restore it.":"Deleting removes the document, its history, comments and annotations. It cannot be undone."}`,label:y==="decline"?"Why are you rejecting?":void 0,placeholder:"e.g. still referenced by onboarding",confirmLabel:y!=="delete"?"Reject":c(l)?"Archive nest":"Delete document",destructive:y==="delete"&&!c(l),onConfirm:y==="delete"?ae:oe})]})}export{Je as default};
@@ -1 +0,0 @@
1
- import{u as C,cc as L,r as y,j as e,c5 as A,I as R,B as h,L as k,aP as P,cd as S,f as x,ce as _,cf as E,cg as I,i as D}from"./index-EaX2yql0.js";import{P as T}from"./page-title-ClvvBsIo.js";import{p as q}from"./dates-BCxbm4_q.js";import{R as B}from"./refresh-cw-BhHzSH9m.js";import{T as G}from"./trash-2-HBi-Pslz.js";function N(r){if(!r)return"never";const t=q(r);return t?t.toLocaleDateString():"never"}function W(){const r=C(),{data:t,isLoading:b}=L(),c=(t==null?void 0:t.keys)??[],[p,f]=y.useState(""),[n,i]=y.useState(null),[d,v]=y.useState(null),m=p.trim(),u=c.some(s=>{var a;return((a=s.label)==null?void 0:a.trim().toLowerCase())===m.toLowerCase()}),g=m.length>0&&!u,w=()=>r.invalidateQueries({queryKey:D.apiKeys().queryKey});async function j(s,a,o){i(s);try{const{api_key:l}=await a();v({apiKey:l,kind:o}),s==="new"&&f("")}catch(l){x.error(l instanceof Error?l.message:"Something went wrong.")}finally{w(),i(null)}}async function K(s,a){if(window.confirm(`Revoke "${a}"? Anything still using this key stops working immediately.`)){i(s);try{await _(s),x.success("Key revoked")}catch(o){x.error(o instanceof Error?o.message:"Couldn't revoke.")}finally{w(),i(null)}}}return e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{icon:A,title:"API keys",description:"Each key authenticates every nest you can see, plus the server-level MCP endpoint. Make one per place you connect from — then rotating the key for one client leaves the others alone.",className:"mb-0"}),e.jsxs("form",{className:"flex flex-col gap-2 sm:flex-row",onSubmit:s=>{s.preventDefault(),g&&j("new",()=>E({label:m}),"generated")},children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(R,{value:p,onChange:s=>f(s.target.value),maxLength:60,placeholder:"What's this key for? e.g. Claude Desktop, laptop CLI","aria-label":"Key name","aria-invalid":u||void 0}),u&&e.jsx("p",{className:"mt-1 text-xs text-destructive",children:"You already have a key with this name."})]}),e.jsxs(h,{type:"submit",disabled:n==="new"||!g,className:"shrink-0",children:[n==="new"?e.jsx(k,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(P,{className:"mr-2 h-4 w-4"}),"Generate key"]})]}),b?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Loading your keys…"}):c.length===0?e.jsx("p",{className:"rounded-md border border-dashed py-6 text-center text-sm text-muted-foreground",children:"No keys yet. Generate one above to connect an AI client."}):e.jsx("ul",{className:"divide-y rounded-md border",children:c.map(s=>{const a=s.label||"Unnamed key";return e.jsxs("li",{className:"flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("code",{className:"font-mono",children:s.key_prefix})," · created ",N(s.created_at)," · last used"," ",N(s.last_used_at)]})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs(h,{variant:"outline",size:"sm",disabled:n===s.id,onClick:()=>j(s.id,()=>I({key_id:s.id}),"rotated"),children:[n===s.id?e.jsx(k,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(B,{className:"mr-1.5 h-3.5 w-3.5"}),"Rotate"]}),e.jsx(h,{variant:"ghost",size:"sm",disabled:n===s.id,onClick:()=>K(s.id,a),"aria-label":`Revoke ${a}`,children:e.jsx(G,{className:"h-3.5 w-3.5"})})]})]},s.id)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is shown once, when it's created. There's no way to read it back — if you lose one, rotate that key (its client needs the new value) or revoke it and make another."}),d&&e.jsx(S,{apiKey:d.apiKey,kind:d.kind,onClose:()=>v(null)})]})}export{W as default};