@fgbg/mdocs 0.8.18 → 0.8.19
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/README.md +1 -1
- package/agent-skills/changelog/SKILL.md +7 -1
- package/agent-skills/index.json +1 -1
- package/dist/web/assets/{AgentChatPanel-DHy3KgSW.js → AgentChatPanel-CLKeiDeR.js} +1 -1
- package/dist/web/assets/{AiWriteWorkbench-Ce_OaED4.js → AiWriteWorkbench-Ecp214S5.js} +1 -1
- package/dist/web/assets/DiagramEditor-BTRe45TX-DzJEhM4C.js +2 -0
- package/dist/web/assets/{DocumentEditor-B2H3rHSg.js → DocumentEditor-NPbbAape.js} +1 -1
- package/dist/web/assets/{MergeView-Cy4Pi3Je.js → MergeView-BnWbq08U.js} +1 -1
- package/dist/web/assets/{PlaygroundPage-hHfIzPO5.js → PlaygroundPage-BSGipUkC.js} +1 -1
- package/dist/web/assets/{SettingsPage-BRAPdqW9.js → SettingsPage-OklrFCx7.js} +1 -1
- package/dist/web/assets/{Toolbar-DPkTtGNL.js → Toolbar-DjPuWk5G.js} +1 -1
- package/dist/web/assets/{VisitorPickerModal-CJ0K2gj8.js → VisitorPickerModal-BUS-cOq0.js} +1 -1
- package/dist/web/assets/{copy-DCKasK29.js → copy-hWOco_4c.js} +1 -1
- package/dist/web/assets/{diagram-BJFhx-27.js → diagram-gfUK8OHx.js} +332 -332
- package/dist/web/assets/{editor-BBXgdU3Q.js → editor-ONzd_YnO.js} +1 -1
- package/dist/web/assets/{history-BQkmetJ0.js → history-AMIEbyMc.js} +1 -1
- package/dist/web/assets/{index-CA7lpALZ.js → index-C46BU1-j.js} +3 -3
- package/dist/web/assets/meta2d-C8Z4cn-d.js +110 -0
- package/dist/web/assets/meta2dEngine-BD2XbzaV-D7hJ1H1g.js +1 -0
- package/dist/web/assets/{motion-D-I76zAi.js → motion-C4pN8CfU.js} +1 -1
- package/dist/web/assets/{plus-B2rZTPWV.js → plus-CnKbiP8x.js} +1 -1
- package/dist/web/assets/react-B7vrA7AR.js +2126 -0
- package/dist/web/assets/{ui-C3xtW1w8.js → ui-DxdLi_28.js} +3 -3
- package/dist/web/index.html +3 -3
- package/package.json +2 -2
- package/dist/web/assets/react-CQByW0Rg.js +0 -2236
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as e}from"./react-vendor-BNpqFP9B.js";import{b as Z,q as $e,s as We,D as Ue,l as ie,t as _e,v as He,w as _,x as ce,y as qe,z as Ge,A as Ze,a as Je,d as je,B as be,C as ve,E as Qe,G as Xe,H as Ye,I as es,J as ss,K as ke,L as ne,N as ts,O as as,P as ns,Q as is,R as cs,f as ls,T as os,U as rs,V as ds,W as ms,X as us,i as hs,Y as ps,Z as gs,_ as fs,$ as xs,a0 as js,a1 as ys,a2 as Ns,a3 as bs,a4 as vs,r as ks,j as ws,a5 as Ss,n as Cs,o as Ds}from"./index-CA7lpALZ.js";import{V as we,a as Is,M as Ts}from"./VisitorPickerModal-CJ0K2gj8.js";import"./ui-C3xtW1w8.js";import"./motion-D-I76zAi.js";function As({draft:t,onClose:s,onSuccess:y}){const{t:u,lang:m}=Z(),[E,p]=a.useState([]),[k,N]=a.useState(t.domainId??""),[C,i]=a.useState([]),[v,g]=a.useState(""),[o,x]=a.useState(`${t.displayName||"untitled"}_recovered.md`),[h,V]=a.useState(!1),[I,z]=a.useState(null),D=a.useRef(null),M=a.useRef(!0);a.useEffect(()=>(M.current=!0,()=>{M.current=!1}),[]),a.useEffect(()=>{$e().then(f=>{M.current&&p(f)})},[]),a.useEffect(()=>{k&&(i([]),g(""),We(k).then(f=>{M.current&&i(f)}).catch(()=>{M.current&&i([])}))},[k]),a.useEffect(()=>{const f=window.setTimeout(()=>{var A;return(A=D.current)==null?void 0:A.focus()},0);return()=>window.clearTimeout(f)},[]),a.useEffect(()=>{const f=A=>{A.key==="Escape"&&s()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s]);function F(f,A){for(const w of f){if(w.type==="folder"&&w.path===A)return w.documentId;if(w.type==="folder"){const S=F(w.children,A);if(S)return S}}return null}async function L(f){f.preventDefault(),V(!0),z(null);const A=o.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\-.]/g,""),w=A.endsWith(".md")?A:A+".md",S=w.replace(/\.md$/i,"");try{const P=v?`${v}/${w}`:w,c=v?F(C,v)??void 0:void 0;await He({fileName:w,displayName:S,content:t.content,domainId:k,parentId:c}),y()}catch(P){z(_(u,P))}finally{V(!1)}}return e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:f=>{f.target===f.currentTarget&&!h&&s()},children:e.jsxs("div",{className:"mdocs-dialog card mdocs-recovery-dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:u("recoverDraft")}),e.jsx("p",{className:"muted",children:u("recoverDraftDesc",{name:t.displayName||u("unknownTitle")})}),e.jsxs("form",{onSubmit:L,className:"mdocs-dialog-form",children:[e.jsxs("label",{className:"mdocs-dialog-label",children:[u("domainLabel"),E.length>0&&e.jsx(Ue,{domains:E,value:k,onChange:N,onDomainsChange:p,ariaLabel:u("domainLabel"),localizeName:f=>ie(f,m,u)})]}),e.jsxs("label",{className:"mdocs-dialog-label mdocs-recovery-tree-label",children:[u("recoverTargetFolder"),e.jsx("div",{className:"mdocs-recovery-tree",children:e.jsx(_e,{nodes:C,activeDocumentId:null,selectedParentPath:v,onOpen:()=>{},onOpenFolder:f=>g(f),onContextMenu:()=>{},onDeselect:()=>g("")})})]}),e.jsxs("label",{className:"mdocs-dialog-label",children:[u("fileNameLabel"),e.jsx("input",{ref:D,value:o,onChange:f=>x(f.target.value),placeholder:"recovered.md",maxLength:200,disabled:h})]}),I&&e.jsx("div",{className:"mdocs-dialog-error",children:I}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>!h&&s(),disabled:h,children:u("cancel")}),e.jsx("button",{type:"submit",className:"primary",disabled:h,children:u(h?"creating":"create")})]})]})]})})}function Ps({onPublish:t,onClose:s,onCountChange:y,onRecover:u}){const{t:m}=Z(),[E,p]=a.useState([]),[k,N]=a.useState(new Set),[C,i]=a.useState(!1),[v,g]=a.useState(null),[o,x]=a.useState(null),[h,V]=a.useState(null),I=a.useRef(null),z=a.useRef(!0);a.useEffect(()=>(z.current=!0,ce().then(c=>{if(!z.current)return;const d=c.filter(j=>!j.published);p(d),y==null||y(d.length)}),()=>{z.current=!1,I.current&&(clearTimeout(I.current),I.current=null)}),[]),a.useEffect(()=>{const c=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]);const D=a.useCallback((c,d)=>{V({message:c,type:d}),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>V(null),3e3)},[]);async function M(c){await Ge(c),N(d=>new Set(d).add(c));try{await t(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),D(m("published"),"success")}catch(d){d instanceof Ze||D(m("publishFailed"),"error");const j=await Je(c);j&&p(R=>R.map(O=>O.documentId===c?j:O))}finally{N(d=>{const j=new Set(d);return j.delete(c),j})}}async function F(c){g(null),await je(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),D(m("draftDeleted"),"success")}function L(c){const d=E.find(j=>j.documentId===c);d&&x(d)}function f(c){x(null),je(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),u==null||u(E.find(d=>d.documentId===c)),D(m("published"),"success")}async function A(){i(!0);let c=0,d=0;for(const O of E)try{await t(O.documentId),c++}catch{d++}const R=(await ce()).filter(O=>!O.published);p(R),y==null||y(R.length),d===0?D(m("publishAll"),"success"):D(`${c} published, ${d} failed`,"error"),i(!1)}const w=c=>new Date(c).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),S=c=>qe(m,c,c.publishError??"UNKNOWN"),P=E;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-drawer-overlay",onClick:s}),e.jsxs("div",{className:"mdocs-drawer",role:"dialog","aria-modal":"true",children:[e.jsxs("header",{className:"mdocs-drawer-header",children:[e.jsxs("div",{className:"mdocs-drawer-header-text",children:[e.jsxs("h2",{className:"mdocs-drawer-title",children:[m("unpublishedDrafts"),P.length>0&&e.jsx("span",{className:"mdocs-drawer-count-badge",children:P.length})]}),e.jsx("span",{className:"mdocs-drawer-subtitle",children:m("draftCount",{count:String(P.length)})})]}),e.jsx("button",{type:"button",className:"mdocs-drawer-close-btn",onClick:s,"aria-label":m("close"),children:"×"})]}),e.jsx("div",{className:"mdocs-drawer-body",children:P.length===0?e.jsxs("div",{className:"mdocs-drawer-empty",children:[e.jsx("div",{className:"mdocs-drawer-empty-icon","aria-hidden":"true",children:"✓"}),e.jsx("p",{className:"mdocs-drawer-empty-text",children:m("draftsEmptyState")})]}):e.jsx("div",{className:"mdocs-drawer-items",children:P.map(c=>{const d=!!c.publishError;return e.jsxs("div",{className:d?"mdocs-drawer-item mdocs-drawer-item-failed":"mdocs-drawer-item",children:[e.jsx("div",{className:"mdocs-drawer-item-icon","aria-hidden":"true",children:"📄"}),e.jsxs("div",{className:"mdocs-drawer-item-info",children:[e.jsx("span",{className:"mdocs-drawer-item-name",children:c.displayName||m("unknownTitle")}),d?e.jsxs("span",{className:"mdocs-drawer-item-error",children:[w(c.publishErrorAt)," · ",S(c)]}):e.jsxs("span",{className:"mdocs-drawer-item-meta",children:[w(c.updatedAt)," · ",m("localSnapshot")]})]}),e.jsxs("div",{className:"mdocs-drawer-item-actions",children:[d?e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:C,onClick:()=>L(c.documentId),children:m("recoverDraft")}):e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:k.has(c.documentId)||C,onClick:()=>void M(c.documentId),children:k.has(c.documentId)?m("publishing"):m("publish")}),e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-danger",disabled:C,onClick:()=>g(c.documentId),children:m("delete")})]})]},c.documentId)})})}),e.jsxs("footer",{className:"mdocs-drawer-footer",children:[e.jsx("button",{type:"button",onClick:s,children:m("close")}),e.jsx("button",{type:"button",className:"primary",disabled:P.length===0||C,onClick:()=>void A(),children:C?m("publishing"):`${m("publishAll")} (${P.length})`})]}),h&&e.jsx("div",{className:"mdocs-drawer-toast mdocs-drawer-toast--"+h.type,role:"status",children:h.message})]}),v&&e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:c=>{c.target===c.currentTarget&&g(null)},children:e.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:m("delete")}),e.jsx("p",{className:"muted",children:m("confirmDeleteDraft")}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>g(null),children:m("cancel")}),e.jsx("button",{type:"button",className:"danger",onClick:()=>void F(v),children:m("delete")})]})]})}),o&&e.jsx(As,{draft:o,onClose:()=>x(null),onSuccess:()=>f(o.documentId)})]})}function Ms(){const{t,lang:s}=Z(),y=be(),u=a.useRef(!1),[m,E]=a.useState([]),[p,k]=a.useState(!1),[N,C]=a.useState(""),[i,v]=a.useState("restricted"),[g,o]=a.useState(!1),[x,h]=a.useState(null),[V,I]=a.useState(null),[z,D]=a.useState(""),[M,F]=a.useState(""),[L,f]=a.useState("all"),[A,w]=a.useState(null);a.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const S=a.useCallback(async()=>{k(!0),h(null);try{const r=await ve();if(!u.current)return;E(r)}catch(r){if(!u.current)return;h(_(t,r))}finally{u.current&&k(!1)}},[t]);a.useEffect(()=>{S()},[S]);async function P(r){if(r.preventDefault(),!N.trim()){h(t("domainNameRequired"));return}o(!0),h(null);try{if(await ss({domainName:N.trim(),permission:i}),!u.current)return;C(""),v("restricted"),await S()}catch(K){if(!u.current)return;h(_(t,K))}finally{u.current&&o(!1)}}async function c(r){if(z.trim()){h(null);try{if(await es(r,z.trim()),!u.current)return;I(null),w(null),await S()}catch(K){if(!u.current)return;h(_(t,K))}}}function d(r){I(r.domainId),D(r.domainName),w(null)}function j(){I(null),w(null)}async function R(r,K){h(null);try{if(await Ye(r,K),!u.current)return;w(null),await S()}catch($){if(!u.current)return;h(_(t,$))}}async function O(r){if(window.confirm(t("deleteDomainConfirmDetail",{name:r.domainName,count:String(r.docCount)}))){h(null);try{if(await Xe(r.domainId),!u.current)return;await S()}catch(K){if(!u.current)return;h(_(t,K))}}}const H=a.useCallback(r=>Qe(r,t),[t]),q=a.useCallback(r=>ie(r.domainName,s,t),[s,t]),G=a.useMemo(()=>{const r=M.trim().toLowerCase();return m.filter(K=>L!=="all"&&K.permission!==L?!1:r?ie(K.domainName,s,t).toLowerCase().includes(r)||K.domainName.toLowerCase().includes(r):!0)},[m,M,L,s,t]),b=a.useCallback((r,K)=>{const $=H(r.permission);return K?`${$} ${t("domainTypeBuiltinSuffix")}`:$},[H,t]);return{domains:m,loadingDomains:p,domainError:x,newDomainName:N,setNewDomainName:C,newDomainPermission:i,setNewDomainPermission:v,creating:g,handleCreateDomain:P,renamingId:V,setRenamingId:I,renameDraft:z,setRenameDraft:D,startRename:d,cancelRename:j,handleRename:c,changeTypeForId:A,setChangeTypeForId:w,handlePermissionChange:R,handleDelete:O,domainSearch:M,setDomainSearch:F,domainFilter:L,setDomainFilter:f,filteredDomains:G,visitorId:y,plabel:H,localizeDomain:q,domainTypeLabel:b}}function Es(){const{t}=Z(),s=Ms(),[y,u]=a.useState([]),[m,E]=a.useState(null),[p,k]=a.useState(null),N=a.useCallback(async()=>{try{const i=await ke();u(i)}catch{u([])}},[]);a.useEffect(()=>{N()},[N]);async function C(i){E(null);try{const v=await cs(i.domainId);k({domainId:i.domainId,creatorVisitorId:i.creatorVisitorId,initialIds:v.map(g=>g.visitorId),memberRows:v})}catch(v){E({kind:"err",text:_(t,v)})}}return e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:t("domainManagement")})}),e.jsx("p",{className:"mdocs-domain-mgmt-restricted-hint",children:t("domainMgmtRestrictedMemberHint")}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-create",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("createDomain")}),e.jsxs("form",{onSubmit:s.handleCreateDomain,className:"mdocs-domain-mgmt-create-form",children:[e.jsxs("label",{className:"mdocs-domain-mgmt-field",children:[e.jsx("span",{className:"mdocs-domain-mgmt-label",children:t("domainName")}),e.jsx("input",{value:s.newDomainName,onChange:i=>s.setNewDomainName(i.target.value),placeholder:t("domainName"),maxLength:100,disabled:s.creating,className:"mdocs-domain-name-input"})]}),e.jsxs("fieldset",{className:"mdocs-domain-mgmt-fieldset",children:[e.jsx("legend",{className:"mdocs-domain-mgmt-label",children:t("domainPermission")}),e.jsx("div",{className:"mdocs-domain-mgmt-type-radios",children:ne.map(i=>e.jsxs("label",{className:"mdocs-domain-mgmt-radio",children:[e.jsx("input",{type:"radio",name:"newDomainPermission",checked:s.newDomainPermission===i,onChange:()=>s.setNewDomainPermission(i),disabled:s.creating}),e.jsx("span",{children:s.plabel(i)})]},i))})]}),e.jsx("button",{type:"submit",className:"primary mdocs-domain-mgmt-submit",disabled:s.creating,children:s.creating?t("creating"):t("create")})]})]}),m&&e.jsx("div",{className:"mdocs-settings-card",style:{color:m.kind==="ok"?"var(--mdocs-success, #0a7)":"var(--mdocs-danger)"},children:e.jsx("span",{className:"mdocs-settings-item-desc",children:m.text})}),s.domainError&&e.jsx("div",{className:"mdocs-settings-card mdocs-domain-error",children:e.jsx("span",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)"},children:s.domainError})}),e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-toolbar",children:[e.jsx("input",{type:"search",value:s.domainSearch,onChange:i=>s.setDomainSearch(i.target.value),placeholder:t("domainSearchPlaceholder"),className:"mdocs-domain-mgmt-search","aria-label":t("domainSearchPlaceholder")}),e.jsx("div",{className:"mdocs-domain-mgmt-filters",role:"group","aria-label":t("domainPermission"),children:["all",...ne].map(i=>e.jsx("button",{type:"button",className:"mdocs-domain-mgmt-filter"+(s.domainFilter===i?" active":""),"aria-pressed":s.domainFilter===i,onClick:()=>s.setDomainFilter(i),children:i==="all"?t("domainFilterAll"):s.plabel(i)},i))})]}),s.loadingDomains?e.jsx("div",{className:"mdocs-settings-card",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")})}):s.domains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("noDomains")})}):s.filteredDomains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("domainNoMatch")})}):e.jsx("div",{className:"mdocs-settings-card mdocs-domain-table-wrap",children:e.jsxs("table",{className:"mdocs-domain-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:t("domainColName")}),e.jsx("th",{scope:"col",children:t("domainColType")}),e.jsx("th",{scope:"col",className:"mdocs-domain-table-num",children:t("domainColDocCount")}),e.jsx("th",{scope:"col",children:t("domainColActions")})]})}),e.jsx("tbody",{children:s.filteredDomains.map(i=>{const v=ts(i,s.visitorId),g=as(i.domainId),o=ns(i),x=o?t("domainTooltipTypeLocked",{count:String(i.docCount)}):void 0;return e.jsxs("tr",{className:g?"mdocs-domain-table-row-builtin":void 0,children:[e.jsx("td",{children:s.renamingId===i.domainId?e.jsxs("div",{className:"mdocs-domain-table-rename",children:[e.jsx("input",{value:s.renameDraft,onChange:h=>s.setRenameDraft(h.target.value),maxLength:100,autoFocus:!0,className:"mdocs-domain-name-input"}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void s.handleRename(i.domainId),children:t("save")}),e.jsx("button",{type:"button",onClick:s.cancelRename,children:t("cancel")})]}):e.jsxs("div",{className:"mdocs-domain-table-name-cell",children:[e.jsx("span",{className:"mdocs-domain-table-name",children:s.localizeDomain(i)}),g&&e.jsx("span",{className:"mdocs-domain-badge-builtin",children:t("domainBuiltIn")}),!v&&!g&&e.jsx("span",{className:"mdocs-domain-badge-shared",children:t("shared")})]})}),e.jsx("td",{children:e.jsxs("span",{className:"mdocs-domain-table-type",title:x,children:[e.jsx("span",{className:"mdocs-domain-permission-badge","data-permission":i.permission,children:s.domainTypeLabel(i,g)}),o&&!g&&e.jsx("span",{className:"mdocs-domain-type-lock","aria-hidden":"true",children:"🔒"})]})}),e.jsx("td",{className:"mdocs-domain-table-num",children:i.docCount}),e.jsxs("td",{className:"mdocs-domain-table-actions",children:[g&&e.jsx("span",{className:"mdocs-domain-not-modifiable",children:t("domainNotModifiable")}),!g&&!v&&e.jsx("span",{className:"mdocs-domain-not-creator-inline",children:t("domainNotCreator")}),!g&&v&&s.changeTypeForId===i.domainId&&e.jsxs("div",{className:"mdocs-domain-change-type-panel",children:[e.jsx("div",{className:"mdocs-domain-permission-select",children:ne.map(h=>e.jsx("button",{type:"button",className:i.permission===h?"active":"",onClick:()=>void s.handlePermissionChange(i.domainId,h),children:s.plabel(h)},h))}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>s.setChangeTypeForId(null),children:t("cancel")})]}),!g&&v&&s.renamingId!==i.domainId&&s.changeTypeForId!==i.domainId&&e.jsxs("div",{className:"mdocs-domain-action-buttons",children:[e.jsx("button",{type:"button",className:"secondary",title:o?t("domainLocked"):void 0,onClick:()=>{s.setChangeTypeForId(null),s.startRename(i)},disabled:o,children:t("rename")}),e.jsx("button",{type:"button",className:"secondary",title:o?x:void 0,onClick:()=>{s.setRenamingId(null),s.setChangeTypeForId(i.domainId)},disabled:o,children:t("domainChangeType")}),e.jsx("button",{type:"button",className:"secondary",title:o?t("domainLocked"):void 0,onClick:()=>void s.handleDelete(i),disabled:o,children:t("deleteDomain")}),i.permission==="restricted"&&!g&&e.jsx("button",{type:"button",className:"secondary",onClick:()=>void C(i),children:t("domainMembersManageButton")})]})]})]},i.domainId)})})]})})]}),e.jsx(we,{open:p!==null,title:t("domainMembersPickerTitle"),initialSelectedIds:(p==null?void 0:p.initialIds)??[],lockedIds:p?[p.creatorVisitorId]:[],seedMembers:p==null?void 0:p.memberRows,templates:y,onClose:()=>k(null),onConfirm:async i=>{p&&(await is(p.domainId,i),E({kind:"ok",text:t("domainMembersSaved",{count:String(i.length)})}))}})]})}function ye(t){return t.length<=6?t:`${t.slice(0,6)}…`}function Ls(){const{t}=Z(),s=a.useRef(!0),[y,u]=a.useState([]),[m,E]=a.useState(!0),[p,k]=a.useState(null),[N,C]=a.useState(1),[i,v]=a.useState(null),[g,o]=a.useState(""),[x,h]=a.useState([]),[V,I]=a.useState(!1),[z,D]=a.useState(null),[M,F]=a.useState(!1),L=be(),[f,A]=a.useState([]),[w,S]=a.useState("idle"),[P,c]=a.useState("");a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{S("loading"),ls().then(l=>{s.current&&(A(l),S("ok"))}).catch(()=>{s.current&&S("err")})},[]);const d=a.useMemo(()=>{const l=new Map;for(const T of f)l.set(T.visitorId,T.visitorName);return l},[f]),j=a.useCallback(async()=>{E(!0),D(null);try{const l=await ke();s.current&&u(l)}catch(l){s.current&&D(_(t,l))}finally{s.current&&E(!1)}},[t]);a.useEffect(()=>{j()},[j]);const R=a.useMemo(()=>x.map(l=>{const T=f.find(W=>W.visitorId===l);return{visitorId:l,name:T?T.visitorName:t("visitorPickerUnknownVisitor"),muted:!T}}),[x,f,t]);function O(l){h(T=>T.includes(l)?T.filter(W=>W!==l):[...T,l])}const H=N===1?g.trim().length>0:N===2?x.length>0:!0;function q(){if(!(N>=3)){if(!H){F(!0);return}F(!1),C(N+1),c("")}}function G(){N<=1||(F(!1),C(N-1))}function b(){k(null),v(null),o(""),h(L?[L]:[]),D(null),C(1),c(""),F(!1)}function r(l){k(null),v(l.id),o(l.displayName);const T=L&&!l.visitorIds.includes(L)?[...l.visitorIds,L]:[...l.visitorIds];h(T),D(null),C(1),c(""),F(!1)}async function K(){if(!(!g.trim()||x.length===0)){I(!0),D(null);try{if(i===null?await os({displayName:g.trim(),visitorIds:x}):await rs(i,{displayName:g.trim(),visitorIds:x}),!s.current)return;b(),await j()}catch(l){if(!s.current)return;D(_(t,l))}finally{s.current&&I(!1)}}}async function $(l){I(!0),D(null);try{if(await ds(l),!s.current)return;k(null),i===l&&b(),await j()}catch(T){if(!s.current)return;D(_(t,T))}finally{s.current&&I(!1)}}const Q=[{key:1,label:t("memberTemplateStepName")},{key:2,label:t("memberTemplateStepMembers")},{key:3,label:t("memberTemplateStepSave")}],ee=`${(N-1)/2*100}%`;return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:t(i!==null?"memberTemplateUpdate":"memberTemplateFormNew")}),i!==null&&e.jsx("button",{type:"button",className:"secondary",onClick:b,style:{fontSize:12},children:t("memberTemplateCancelEdit")})]}),e.jsxs("div",{className:"mdocs-wizard-progress",children:[e.jsx("div",{className:"mdocs-wizard-progress-track",children:e.jsx("div",{className:"mdocs-wizard-progress-fill",style:{width:ee}})}),e.jsx("div",{className:"mdocs-wizard-progress-steps",children:Q.map(l=>{const T=N===l.key,W=N>l.key;return e.jsxs("div",{className:"mdocs-wizard-step-indicator",children:[e.jsx("div",{className:`mdocs-wizard-step-circle${T?" current":""}${W?" done":""}`,children:W?"✓":l.key}),e.jsx("span",{className:`mdocs-wizard-step-label${T?" current":""}${W?" done":""}`,children:l.label})]},l.key)})})]}),z&&e.jsx("div",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)",marginBottom:12,marginTop:12},children:z}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-wizard-card",children:[N===1&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx("input",{className:"mdocs-wizard-name-input",value:g,onChange:l=>o(l.target.value),placeholder:t("memberTemplateNamePlaceholder"),maxLength:200,disabled:V,autoFocus:!0,"aria-invalid":M&&!g.trim()}),M&&!g.trim()&&e.jsx("p",{className:"mdocs-wizard-hint",style:{color:"var(--mdocs-danger)"},children:t("domainNameRequired")})]}),N===2&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx(Is,{visitors:f,loadState:w,searchFilter:P,onSearchChange:c,selectedIds:new Set(x),onToggle:O,selectedRows:R,myVisitorId:L}),e.jsx("p",{className:`mdocs-wizard-hint${M&&x.length===0?" danger":""}`,children:"💡 "+t("memberTemplateStep2Hint")})]}),N===3&&e.jsx("div",{className:"mdocs-wizard-step-content",children:e.jsxs("div",{className:"mdocs-wizard-preview-card",children:[e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateNameLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:g})]}),e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateIdsLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:t("memberTemplateSelectedSummary",{count:String(x.length)})})]}),x.length>0&&e.jsxs("div",{className:"mdocs-wizard-preview-tags",children:[x.slice(0,15).map(l=>e.jsx("span",{className:"mdocs-wizard-preview-tag",children:ye(l)},l)),x.length>15&&e.jsxs("span",{className:"mdocs-wizard-preview-tag mdocs-wizard-preview-tag-more",children:["+",x.length-15]})]})]})}),e.jsxs("div",{className:"mdocs-wizard-footer",children:[e.jsxs("button",{type:"button",className:"secondary",onClick:G,children:["← ",t("memberTemplateWizardBack")]}),N<3?e.jsxs("button",{type:"button",className:"primary",onClick:q,children:[t("memberTemplateWizardNext")," →"]}):e.jsx("button",{type:"button",className:"primary",onClick:()=>void K(),children:t(V?"saving":i===null?"memberTemplateCreate":"memberTemplateUpdate")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("memberTemplateSavedList")}),m?e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")}):y.length===0?e.jsxs("div",{className:"mdocs-member-template-empty",children:[e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateEmpty")}),i===null&&e.jsx("button",{type:"button",className:"primary",onClick:b,children:t("memberTemplateEmptyAction")})]}):e.jsx("ul",{className:"mdocs-member-template-list",children:y.map(l=>e.jsx("li",{className:"mdocs-member-template-row",children:p===l.id?e.jsxs("div",{className:"mdocs-member-template-confirm-row",children:[e.jsx("span",{className:"mdocs-member-template-confirm-text",children:t("memberTemplateConfirmDeleteDesc",{name:l.displayName})}),e.jsxs("div",{className:"mdocs-member-template-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",style:{color:"var(--mdocs-danger)"},onClick:()=>void $(l.id),children:t(V?"saving":"memberTemplateConfirmDeleteSubmit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(null),children:t("memberTemplateConfirmDeleteCancel")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-member-template-row-head",children:[e.jsx("strong",{children:l.displayName}),e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateCount",{count:String(l.visitorIds.length)})}),l.visitorIds.length>0&&e.jsx("div",{className:"mdocs-member-template-tags mdocs-member-template-tags-scroll",children:l.visitorIds.map(T=>e.jsx("span",{className:"mdocs-member-template-tag",children:d.get(T)??ye(T)},T))})]}),e.jsxs("div",{className:"mdocs-member-template-row-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>r(l),children:t("edit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(l.id),children:t("memberTemplateDelete")})]})]})},l.id))})]})]})]})}const Rs=[{value:"deepseek-v4-flash",label:"deepseek-v4-flash"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro"}];function Bs(){const{t}=Z(),s=a.useRef(!0),[y,u]=a.useState(""),[m,E]=a.useState(null),[p,k]=a.useState(""),[N,C]=a.useState("deepseek-v4-flash"),[i,v]=a.useState(128e3),[g,o]=a.useState(""),[x,h]=a.useState(!1),[V,I]=a.useState(null),[z,D]=a.useState(!0),[M,F]=a.useState(!1),[L,f]=a.useState(null),[A,w]=a.useState(!1),[S,P]=a.useState(!1),[c,d]=a.useState(!1),[j,R]=a.useState(null);a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const[b,r]=await Promise.all([ms(),us()]);if(!s.current)return;u(b.visitorName),r?(E(r.id),k(r.name),C(r.modelId),v(r.contextWindow||128e3),h(r.hasApiKey),I(r.apiKeyMasked),P(!1)):P(!0)}catch(b){if(!s.current)return;f(b instanceof Error?b.message:String(b)),P(!0)}finally{s.current&&D(!1)}})()},[]);function O(){R({name:p,modelId:N,contextWindow:i}),o(""),d(!1),w(!1),f(null),P(!0)}function H(){j&&(k(j.name),C(j.modelId),v(j.contextWindow)),o(""),d(!1),f(null),w(!1),P(!1),R(null)}async function q(){F(!0),f(null),w(!1);try{const b={modelId:N,name:p,contextWindow:i};g.trim()&&(b.apiKey=g.trim());const r=await ps(b);if(!s.current)return;E(r.id),k(r.name),C(r.modelId),v(r.contextWindow||128e3),h(r.hasApiKey),I(r.apiKeyMasked),o(""),d(!1),w(!0),P(!1),R(null)}catch(b){if(!s.current)return;f(b instanceof Error?b.message:String(b))}finally{s.current&&F(!1)}}const G=t("agentConfigNameDefault").replace("{{name}}",y||"…");return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsxs("h2",{className:"mdocs-settings-title mdocs-agent-config-title",children:[e.jsx("img",{src:hs,alt:"DeepSeek",className:"mdocs-agent-config-logo"}),t("agentConfig")]}),!z&&m&&!S?e.jsx("button",{type:"button",className:"secondary",onClick:O,children:t("edit")}):null]}),e.jsx("div",{className:"mdocs-settings-cards",children:e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:t("agentConfigDesc")}),z?e.jsx("p",{children:t("loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-settings-item",style:{display:"block",marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigName")}),e.jsx("input",{type:"text",value:p,onChange:b=>k(b.target.value),placeholder:G,disabled:!S,style:{width:"100%",marginTop:6}})]}),e.jsxs("div",{className:"mdocs-settings-item mdocs-agent-config-field",style:{marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigModel")}),S?e.jsx("div",{className:"mdocs-agent-config-select",children:e.jsx(Ts,{options:Rs,value:N,onChange:b=>C(b)})}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:N})]}),e.jsxs("label",{className:"mdocs-settings-item",style:{display:"block",marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigContextWindow")}),e.jsx("p",{className:"mdocs-settings-item-desc",style:{margin:"4px 0 6px"},children:t("agentConfigContextWindowDesc")}),S?e.jsx("input",{type:"number",min:1e3,max:2e6,step:1e3,value:i,onChange:b=>v(Number(b.target.value)||128e3),style:{width:"100%"}}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:i})]}),e.jsxs("div",{className:"mdocs-settings-item mdocs-agent-config-field",style:{marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigApiKey")}),S?e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:c?"text":"password",value:g,onChange:b=>o(b.target.value),placeholder:x?t("agentConfigApiKeyConfigured").replace("{{masked}}",V??"…"):t("agentConfigApiKeyPlaceholder"),autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":t(c?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>d(b=>!b),children:c?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M3 3l18 18"}),e.jsx("path",{d:"M10.6 10.6a2 2 0 002.8 2.8"}),e.jsx("path",{d:"M9.9 5.1A10.5 10.5 0 0121 12c-.6 1.1-1.4 2.1-2.4 2.9"}),e.jsx("path",{d:"M6.1 6.1C4.5 7.4 3.2 9.1 2.5 12c1.5 3.5 5 7 9.5 7 1.4 0 2.7-.3 3.9-.8"})]}):e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M2.5 12C4 8.5 7.5 5 12 5s8 3.5 9.5 7c-1.5 3.5-5 7-9.5 7s-8-3.5-9.5-7z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:x?V??"…":t("agentConfigApiKeyPlaceholder")})]}),m?e.jsxs("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:[t("agentConfigId"),": ",m]}):null,L?e.jsx("p",{style:{color:"var(--mdocs-danger, #c00)",marginBottom:12},children:L}):null,A&&!S?e.jsx("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:t("saved")}):null,S?e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void q(),disabled:M,children:t(M?"saving":"save")}),m?e.jsx("button",{type:"button",className:"secondary",onClick:H,disabled:M,children:t("cancel")}):null]}):null]})]})})]})}function Ne(t,s){const y=localStorage.getItem(t);return y===null?s:y==="true"}function $s(t){const{t:s,lang:y,setLang:u}=Z(),{onBack:m,onPublishDraft:E}=t,p=a.useRef(!0);a.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const[k,N]=a.useState(()=>Ne("mdocs.autoPublish",!1)),[C,i]=a.useState(()=>Ne("mdocs.autoEdit",!0)),[v,g]=a.useState(!1),[o,x]=a.useState("general"),[h,V]=a.useState([]),[I,z]=a.useState(!0),[D,M]=a.useState(null),[F,L]=a.useState(!1),[f,A]=a.useState(!1),[w,S]=a.useState(!1),[P,c]=a.useState(!1),[d,j]=a.useState(null),[R,O]=a.useState(!1),[H,q]=a.useState(!1),[G,b]=a.useState(!1),[r,K]=a.useState(""),[$,Q]=a.useState(!1),[ee,l]=a.useState(!1),[T,W]=a.useState(0),[Se,le]=a.useState([]),[Ce,oe]=a.useState(!1),[X,De]=a.useState(""),[Ie,Te]=a.useState([]),[Ae,re]=a.useState(!1),[Y,Pe]=a.useState(""),[Me,Ee]=a.useState([]),[Le,se]=a.useState(!1),[te,de]=a.useState(null),[ae,me]=a.useState(new Map);a.useEffect(()=>{localStorage.setItem("mdocs.autoPublish",String(k))},[k]),a.useEffect(()=>{localStorage.setItem("mdocs.autoEdit",String(C))},[C]),a.useEffect(()=>{o==="savePublish"&&ce().then(n=>{p.current&&W(n.filter(B=>!B.published).length)})},[o]),a.useEffect(()=>{o==="bookmarks"&&Re(),o==="myDocuments"&&pe()},[o]),a.useEffect(()=>{he()},[]),a.useEffect(()=>{ve().then(n=>{p.current&&Ee(n)}).catch(()=>{})},[]);const ue=new Map(Me.map(n=>[n.domainId,n.domainName]));async function he(){try{z(!0);const n=await gs();if(!p.current)return;V(n)}catch{}finally{p.current&&z(!1)}}async function Re(){try{oe(!0);const n=await fs();if(!p.current)return;le(n)}catch{}finally{p.current&&oe(!1)}}async function pe(){try{re(!0);const n=await xs();if(!p.current)return;Te(n)}catch{}finally{p.current&&re(!1)}}async function Be(n){try{await ks(n),le(B=>B.filter(J=>J.documentId!==n))}catch{}}function ze(){if(h.some(B=>!B.revoked)){A(!0);return}ge()}async function ge(){try{L(!0);const n=await Ss();M({token:n.token,name:n.name}),await he()}finally{L(!1)}}async function Fe(){try{b(!0);const n=await bs();j(n.recoveryCode)}finally{b(!1)}}async function Ke(n){n.preventDefault();const B=r.trim();if(!(B&&B.length<4))try{Q(!0),await vs(B),K(""),l(!0),setTimeout(()=>l(!1),3e3)}finally{Q(!1)}}async function Ve(n){de(n);try{const B=await ws(n),J=new Map;B.forEach(U=>{J.set(U.visitorId,U.permission)}),me(J)}catch{me(new Map)}se(!0)}async function Oe(n){if(te)try{const B=new Set(n.map(U=>U.visitorId)),J=new Set(ae.keys());for(const U of J)B.has(U)||await Cs(te,U);for(const U of n)await Ds(te,U.visitorId,U.permission);await pe()}finally{se(!1),de(null)}}const fe=Se.filter(n=>{if(!X.trim())return!0;const B=X.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(B)||(n.ownerVisitorName||"").toLowerCase().includes(B)||(n.domainId||"").toLowerCase().includes(B)}),xe=Ie.filter(n=>{if(!Y.trim())return!0;const B=Y.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(B)||(n.domainId||"").toLowerCase().includes(B)});return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"mdocs-sidebar",children:[e.jsx("header",{className:"mdocs-sidebar-header",children:e.jsxs("div",{className:"mdocs-brand",children:[e.jsx("img",{src:js,alt:s("brand"),className:"mdocs-brand-logo"}),e.jsx("span",{children:s("brand")})]})}),e.jsxs("nav",{className:"mdocs-config-tree",children:[e.jsx("div",{className:"mdocs-config-item"+(o==="general"?" active":""),onClick:()=>x("general"),children:s("general")}),e.jsx("div",{className:"mdocs-config-item"+(o==="bookmarks"?" active":""),onClick:()=>x("bookmarks"),children:s("bookmarkTitle")}),e.jsx("div",{className:"mdocs-config-item"+(o==="myDocuments"?" active":""),onClick:()=>x("myDocuments"),children:s("myDocuments")}),e.jsx("div",{className:"mdocs-config-item"+(o==="domainManagement"?" active":""),onClick:()=>x("domainManagement"),children:s("domainManagement")}),e.jsx("div",{className:"mdocs-config-item"+(o==="memberTemplates"?" active":""),onClick:()=>x("memberTemplates"),children:s("memberTemplates")}),e.jsx("div",{className:"mdocs-config-item"+(o==="agentConfig"?" active":""),onClick:()=>x("agentConfig"),children:s("agentConfig")}),e.jsx("div",{className:"mdocs-config-item"+(o==="savePublish"?" active":""),onClick:()=>x("savePublish"),children:s("saveAndPublish")})]}),e.jsx("footer",{className:"mdocs-settings-sidebar-footer",onClick:m,children:s("backToDocs")})]}),e.jsxs("main",{className:"mdocs-main",children:[ys(),o==="general"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("general")})}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsx("span",{className:"mdocs-settings-item-info",children:e.jsx("span",{className:"mdocs-settings-card-title",children:s("language")})}),e.jsxs("span",{className:"mdocs-settings-lang",children:[e.jsx("button",{type:"button",className:y==="en"?"active":"",onClick:()=>u("en"),children:"EN"}),e.jsx("span",{children:"/"}),e.jsx("button",{type:"button",className:y==="zh"?"active":"",onClick:()=>u("zh"),children:"中"})]})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoEdit")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoEditDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(C?" active":""),role:"switch","aria-checked":C,onClick:()=>i(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliToken")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("cliTokenDesc")}),!I&&h.length>0&&e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8,fontSize:"0.85em",opacity:.8},children:h.map(n=>e.jsxs("span",{style:{display:"block"},children:[n.name," — ",new Date(n.createdAt).toLocaleString()," ",n.revoked?`(${s("cliTokenRevoked")})`:`(${s("cliTokenActive")})`]},n.tokenId))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:ze,disabled:F||I,children:F?"…":h.some(n=>!n.revoked)?s("cliTokenReset"):s("cliTokenCreate")})]}),D&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--ok",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliTokenGenerated")}),e.jsx("span",{className:"mdocs-settings-secret-value",children:D.token})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(D.token),c(!1),S(!0),window.setTimeout(()=>S(!1),2e3)}catch{S(!1),c(!0),window.setTimeout(()=>c(!1),3e3)}})()},children:s(w?"cliTokenCopied":"cliTokenCopy")}),e.jsx("button",{type:"button",onClick:()=>M(null),children:s("close")})]}),w&&e.jsxs("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:["✓ ",s("cliTokenCopied")]}),P&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:s("cliTokenCopyFailed")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"当 Token 丢失时,可用恢复码找回身份。生成后请立即保存,仅显示一次。"})]}),e.jsx("button",{type:"button",className:"secondary",onClick:Fe,disabled:G,children:G?"…":"生成恢复码"})]}),d&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--warn",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 你的恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8},children:"请立即复制保存,关闭后不可再查看。"}),e.jsx("div",{className:"mdocs-settings-secret-code",children:d})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(d),q(!1),O(!0),window.setTimeout(()=>O(!1),2e3)}catch{O(!1),q(!0),window.setTimeout(()=>q(!1),3e3)}})()},children:R?"已复制":"复制恢复码"}),e.jsx("button",{type:"button",onClick:()=>j(null),children:s("close")})]}),R&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:"✓ 已复制到剪贴板"}),H&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:"复制失败,请手动选中上方内容复制"})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-item",children:e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔐 登录密码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"设置密码后,可在其他浏览器或设备用「用户名+密码」登录。"})]})}),e.jsxs("form",{onSubmit:Ke,style:{marginTop:12},children:[e.jsx("input",{type:"password",placeholder:"输入新密码(至少 4 位,留空则清除密码)",value:r,onChange:n=>K(n.target.value),minLength:0,style:{marginBottom:8}}),ee&&e.jsx("div",{style:{color:"#4caf50",marginBottom:8,fontSize:"0.875rem"},children:"✓ 密码设置成功"}),e.jsx("button",{type:"submit",className:"secondary",disabled:$,children:$?"设置中…":"保存密码"})]})]})]})]}):o==="bookmarks"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("bookmarkTitle")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:s("bookmarkSearch"),value:X,onChange:n=>De(n.target.value)}),Ce?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:fe.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(X?"bookmarkNoMatch":"bookmarkEmpty")}):e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("bookmarkColTitle")}),e.jsx("th",{children:s("bookmarkColDomain")}),e.jsx("th",{children:s("bookmarkColAuthor")}),e.jsx("th",{children:s("bookmarkColTime")}),e.jsx("th",{style:{textAlign:"right"}})]})}),e.jsx("tbody",{children:fe.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:n.isDeleted?e.jsx("span",{style:{opacity:.5,fontStyle:"italic"},children:"已删除"}):ue.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:n.ownerVisitorName||"—"}),e.jsx("td",{children:new Date(n.bookmarkedAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Be(n.documentId),children:s("bookmarkRemove")})})]},n.documentId))})]})})]})]}):o==="myDocuments"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("myDocuments")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:"搜索文章…",value:Y,onChange:n=>Pe(n.target.value)}),Ae?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:xe.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(Y?"myDocumentsNoMatch":"myDocumentsEmpty")}):e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("myDocumentsColTitle")}),e.jsx("th",{children:s("myDocumentsColDomain")}),e.jsx("th",{children:s("myDocumentsColUpdated")}),e.jsx("th",{children:s("myDocumentsColCreated")}),e.jsx("th",{colSpan:2})]})}),e.jsx("tbody",{children:xe.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:ue.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:new Date(n.updatedAt).toLocaleDateString()}),e.jsx("td",{children:new Date(n.createdAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Ve(n.documentId),children:s("docInfoInviteMember")})}),e.jsx("td",{style:{textAlign:"right",paddingLeft:0},children:e.jsx("button",{type:"button",className:"primary small",onClick:()=>t.onOpenDocument(n.documentId),children:s("bookmarkOpen")})})]},n.documentId))})]})})]})]}):o==="domainManagement"?e.jsx(Es,{}):o==="memberTemplates"?e.jsx(Ls,{}):o==="agentConfig"?e.jsx(Bs,{}):e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:s("saveAndPublish")}),e.jsx("button",{type:"button",className:"secondary",onClick:m,children:s("backToDocs")})]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoSave")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoSaveAlwaysOnDesc")})]}),e.jsx("span",{className:"mdocs-toggle active",role:"switch","aria-checked":"true","aria-disabled":"true",style:{opacity:.6,cursor:"not-allowed"},children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoPublish")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoPublishDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(k?" active":""),role:"switch","aria-checked":k,onClick:()=>N(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),T>0?e.jsxs("button",{className:"mdocs-settings-card mdocs-settings-draft-link",onClick:()=>g(!0),children:[e.jsxs("span",{className:"mdocs-settings-draft-link-text",children:["📄 ",s("viewDrafts")," (",T,")"]}),e.jsx("span",{className:"mdocs-settings-draft-arrow","aria-hidden":"true",children:"›"})]}):e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:s("noDrafts")})})]})]}),v&&e.jsx(Ps,{onPublish:E,onClose:()=>g(!1),onCountChange:W,onRecover:t.onRecoverDraft})]}),f&&e.jsx(Ns,{title:s("cliToken"),message:s("cliTokenResetConfirm"),confirmLabel:s("cliTokenReset"),cancelLabel:s("cancel"),busy:F,onConfirm:()=>{A(!1),ge()},onCancel:()=>A(!1)}),e.jsx(we,{open:Le,title:s("docInfoInviteMember"),initialSelectedIds:[...ae.keys()],initialPermissions:ae,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:s("invitePermissionRead")},{value:"edit",label:s("invitePermissionEdit")}],onClose:()=>se(!1),onConfirm:n=>{Oe(n)}})]})}export{$s as SettingsPage};
|
|
1
|
+
import{r as a,j as e}from"./react-vendor-BNpqFP9B.js";import{b as Z,q as $e,s as We,D as Ue,l as ie,t as _e,v as He,w as _,x as ce,y as qe,z as Ge,A as Ze,a as Je,d as je,B as be,C as ve,E as Qe,G as Xe,H as Ye,I as es,J as ss,K as ke,L as ne,N as ts,O as as,P as ns,Q as is,R as cs,f as ls,T as os,U as rs,V as ds,W as ms,X as us,i as hs,Y as ps,Z as gs,_ as fs,$ as xs,a0 as js,a1 as ys,a2 as Ns,a3 as bs,a4 as vs,r as ks,j as ws,a5 as Ss,n as Cs,o as Ds}from"./index-C46BU1-j.js";import{V as we,a as Is,M as Ts}from"./VisitorPickerModal-BUS-cOq0.js";import"./ui-DxdLi_28.js";import"./motion-C4pN8CfU.js";function As({draft:t,onClose:s,onSuccess:y}){const{t:u,lang:m}=Z(),[E,p]=a.useState([]),[k,N]=a.useState(t.domainId??""),[C,i]=a.useState([]),[v,g]=a.useState(""),[o,x]=a.useState(`${t.displayName||"untitled"}_recovered.md`),[h,V]=a.useState(!1),[I,z]=a.useState(null),D=a.useRef(null),M=a.useRef(!0);a.useEffect(()=>(M.current=!0,()=>{M.current=!1}),[]),a.useEffect(()=>{$e().then(f=>{M.current&&p(f)})},[]),a.useEffect(()=>{k&&(i([]),g(""),We(k).then(f=>{M.current&&i(f)}).catch(()=>{M.current&&i([])}))},[k]),a.useEffect(()=>{const f=window.setTimeout(()=>{var A;return(A=D.current)==null?void 0:A.focus()},0);return()=>window.clearTimeout(f)},[]),a.useEffect(()=>{const f=A=>{A.key==="Escape"&&s()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s]);function F(f,A){for(const w of f){if(w.type==="folder"&&w.path===A)return w.documentId;if(w.type==="folder"){const S=F(w.children,A);if(S)return S}}return null}async function L(f){f.preventDefault(),V(!0),z(null);const A=o.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\-.]/g,""),w=A.endsWith(".md")?A:A+".md",S=w.replace(/\.md$/i,"");try{const P=v?`${v}/${w}`:w,c=v?F(C,v)??void 0:void 0;await He({fileName:w,displayName:S,content:t.content,domainId:k,parentId:c}),y()}catch(P){z(_(u,P))}finally{V(!1)}}return e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:f=>{f.target===f.currentTarget&&!h&&s()},children:e.jsxs("div",{className:"mdocs-dialog card mdocs-recovery-dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:u("recoverDraft")}),e.jsx("p",{className:"muted",children:u("recoverDraftDesc",{name:t.displayName||u("unknownTitle")})}),e.jsxs("form",{onSubmit:L,className:"mdocs-dialog-form",children:[e.jsxs("label",{className:"mdocs-dialog-label",children:[u("domainLabel"),E.length>0&&e.jsx(Ue,{domains:E,value:k,onChange:N,onDomainsChange:p,ariaLabel:u("domainLabel"),localizeName:f=>ie(f,m,u)})]}),e.jsxs("label",{className:"mdocs-dialog-label mdocs-recovery-tree-label",children:[u("recoverTargetFolder"),e.jsx("div",{className:"mdocs-recovery-tree",children:e.jsx(_e,{nodes:C,activeDocumentId:null,selectedParentPath:v,onOpen:()=>{},onOpenFolder:f=>g(f),onContextMenu:()=>{},onDeselect:()=>g("")})})]}),e.jsxs("label",{className:"mdocs-dialog-label",children:[u("fileNameLabel"),e.jsx("input",{ref:D,value:o,onChange:f=>x(f.target.value),placeholder:"recovered.md",maxLength:200,disabled:h})]}),I&&e.jsx("div",{className:"mdocs-dialog-error",children:I}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>!h&&s(),disabled:h,children:u("cancel")}),e.jsx("button",{type:"submit",className:"primary",disabled:h,children:u(h?"creating":"create")})]})]})]})})}function Ps({onPublish:t,onClose:s,onCountChange:y,onRecover:u}){const{t:m}=Z(),[E,p]=a.useState([]),[k,N]=a.useState(new Set),[C,i]=a.useState(!1),[v,g]=a.useState(null),[o,x]=a.useState(null),[h,V]=a.useState(null),I=a.useRef(null),z=a.useRef(!0);a.useEffect(()=>(z.current=!0,ce().then(c=>{if(!z.current)return;const d=c.filter(j=>!j.published);p(d),y==null||y(d.length)}),()=>{z.current=!1,I.current&&(clearTimeout(I.current),I.current=null)}),[]),a.useEffect(()=>{const c=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]);const D=a.useCallback((c,d)=>{V({message:c,type:d}),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>V(null),3e3)},[]);async function M(c){await Ge(c),N(d=>new Set(d).add(c));try{await t(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),D(m("published"),"success")}catch(d){d instanceof Ze||D(m("publishFailed"),"error");const j=await Je(c);j&&p(R=>R.map(O=>O.documentId===c?j:O))}finally{N(d=>{const j=new Set(d);return j.delete(c),j})}}async function F(c){g(null),await je(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),D(m("draftDeleted"),"success")}function L(c){const d=E.find(j=>j.documentId===c);d&&x(d)}function f(c){x(null),je(c),p(d=>{const j=d.filter(R=>R.documentId!==c);return y==null||y(j.length),j}),u==null||u(E.find(d=>d.documentId===c)),D(m("published"),"success")}async function A(){i(!0);let c=0,d=0;for(const O of E)try{await t(O.documentId),c++}catch{d++}const R=(await ce()).filter(O=>!O.published);p(R),y==null||y(R.length),d===0?D(m("publishAll"),"success"):D(`${c} published, ${d} failed`,"error"),i(!1)}const w=c=>new Date(c).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),S=c=>qe(m,c,c.publishError??"UNKNOWN"),P=E;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-drawer-overlay",onClick:s}),e.jsxs("div",{className:"mdocs-drawer",role:"dialog","aria-modal":"true",children:[e.jsxs("header",{className:"mdocs-drawer-header",children:[e.jsxs("div",{className:"mdocs-drawer-header-text",children:[e.jsxs("h2",{className:"mdocs-drawer-title",children:[m("unpublishedDrafts"),P.length>0&&e.jsx("span",{className:"mdocs-drawer-count-badge",children:P.length})]}),e.jsx("span",{className:"mdocs-drawer-subtitle",children:m("draftCount",{count:String(P.length)})})]}),e.jsx("button",{type:"button",className:"mdocs-drawer-close-btn",onClick:s,"aria-label":m("close"),children:"×"})]}),e.jsx("div",{className:"mdocs-drawer-body",children:P.length===0?e.jsxs("div",{className:"mdocs-drawer-empty",children:[e.jsx("div",{className:"mdocs-drawer-empty-icon","aria-hidden":"true",children:"✓"}),e.jsx("p",{className:"mdocs-drawer-empty-text",children:m("draftsEmptyState")})]}):e.jsx("div",{className:"mdocs-drawer-items",children:P.map(c=>{const d=!!c.publishError;return e.jsxs("div",{className:d?"mdocs-drawer-item mdocs-drawer-item-failed":"mdocs-drawer-item",children:[e.jsx("div",{className:"mdocs-drawer-item-icon","aria-hidden":"true",children:"📄"}),e.jsxs("div",{className:"mdocs-drawer-item-info",children:[e.jsx("span",{className:"mdocs-drawer-item-name",children:c.displayName||m("unknownTitle")}),d?e.jsxs("span",{className:"mdocs-drawer-item-error",children:[w(c.publishErrorAt)," · ",S(c)]}):e.jsxs("span",{className:"mdocs-drawer-item-meta",children:[w(c.updatedAt)," · ",m("localSnapshot")]})]}),e.jsxs("div",{className:"mdocs-drawer-item-actions",children:[d?e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:C,onClick:()=>L(c.documentId),children:m("recoverDraft")}):e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:k.has(c.documentId)||C,onClick:()=>void M(c.documentId),children:k.has(c.documentId)?m("publishing"):m("publish")}),e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-danger",disabled:C,onClick:()=>g(c.documentId),children:m("delete")})]})]},c.documentId)})})}),e.jsxs("footer",{className:"mdocs-drawer-footer",children:[e.jsx("button",{type:"button",onClick:s,children:m("close")}),e.jsx("button",{type:"button",className:"primary",disabled:P.length===0||C,onClick:()=>void A(),children:C?m("publishing"):`${m("publishAll")} (${P.length})`})]}),h&&e.jsx("div",{className:"mdocs-drawer-toast mdocs-drawer-toast--"+h.type,role:"status",children:h.message})]}),v&&e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:c=>{c.target===c.currentTarget&&g(null)},children:e.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:m("delete")}),e.jsx("p",{className:"muted",children:m("confirmDeleteDraft")}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>g(null),children:m("cancel")}),e.jsx("button",{type:"button",className:"danger",onClick:()=>void F(v),children:m("delete")})]})]})}),o&&e.jsx(As,{draft:o,onClose:()=>x(null),onSuccess:()=>f(o.documentId)})]})}function Ms(){const{t,lang:s}=Z(),y=be(),u=a.useRef(!1),[m,E]=a.useState([]),[p,k]=a.useState(!1),[N,C]=a.useState(""),[i,v]=a.useState("restricted"),[g,o]=a.useState(!1),[x,h]=a.useState(null),[V,I]=a.useState(null),[z,D]=a.useState(""),[M,F]=a.useState(""),[L,f]=a.useState("all"),[A,w]=a.useState(null);a.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const S=a.useCallback(async()=>{k(!0),h(null);try{const r=await ve();if(!u.current)return;E(r)}catch(r){if(!u.current)return;h(_(t,r))}finally{u.current&&k(!1)}},[t]);a.useEffect(()=>{S()},[S]);async function P(r){if(r.preventDefault(),!N.trim()){h(t("domainNameRequired"));return}o(!0),h(null);try{if(await ss({domainName:N.trim(),permission:i}),!u.current)return;C(""),v("restricted"),await S()}catch(K){if(!u.current)return;h(_(t,K))}finally{u.current&&o(!1)}}async function c(r){if(z.trim()){h(null);try{if(await es(r,z.trim()),!u.current)return;I(null),w(null),await S()}catch(K){if(!u.current)return;h(_(t,K))}}}function d(r){I(r.domainId),D(r.domainName),w(null)}function j(){I(null),w(null)}async function R(r,K){h(null);try{if(await Ye(r,K),!u.current)return;w(null),await S()}catch($){if(!u.current)return;h(_(t,$))}}async function O(r){if(window.confirm(t("deleteDomainConfirmDetail",{name:r.domainName,count:String(r.docCount)}))){h(null);try{if(await Xe(r.domainId),!u.current)return;await S()}catch(K){if(!u.current)return;h(_(t,K))}}}const H=a.useCallback(r=>Qe(r,t),[t]),q=a.useCallback(r=>ie(r.domainName,s,t),[s,t]),G=a.useMemo(()=>{const r=M.trim().toLowerCase();return m.filter(K=>L!=="all"&&K.permission!==L?!1:r?ie(K.domainName,s,t).toLowerCase().includes(r)||K.domainName.toLowerCase().includes(r):!0)},[m,M,L,s,t]),b=a.useCallback((r,K)=>{const $=H(r.permission);return K?`${$} ${t("domainTypeBuiltinSuffix")}`:$},[H,t]);return{domains:m,loadingDomains:p,domainError:x,newDomainName:N,setNewDomainName:C,newDomainPermission:i,setNewDomainPermission:v,creating:g,handleCreateDomain:P,renamingId:V,setRenamingId:I,renameDraft:z,setRenameDraft:D,startRename:d,cancelRename:j,handleRename:c,changeTypeForId:A,setChangeTypeForId:w,handlePermissionChange:R,handleDelete:O,domainSearch:M,setDomainSearch:F,domainFilter:L,setDomainFilter:f,filteredDomains:G,visitorId:y,plabel:H,localizeDomain:q,domainTypeLabel:b}}function Es(){const{t}=Z(),s=Ms(),[y,u]=a.useState([]),[m,E]=a.useState(null),[p,k]=a.useState(null),N=a.useCallback(async()=>{try{const i=await ke();u(i)}catch{u([])}},[]);a.useEffect(()=>{N()},[N]);async function C(i){E(null);try{const v=await cs(i.domainId);k({domainId:i.domainId,creatorVisitorId:i.creatorVisitorId,initialIds:v.map(g=>g.visitorId),memberRows:v})}catch(v){E({kind:"err",text:_(t,v)})}}return e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:t("domainManagement")})}),e.jsx("p",{className:"mdocs-domain-mgmt-restricted-hint",children:t("domainMgmtRestrictedMemberHint")}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-create",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("createDomain")}),e.jsxs("form",{onSubmit:s.handleCreateDomain,className:"mdocs-domain-mgmt-create-form",children:[e.jsxs("label",{className:"mdocs-domain-mgmt-field",children:[e.jsx("span",{className:"mdocs-domain-mgmt-label",children:t("domainName")}),e.jsx("input",{value:s.newDomainName,onChange:i=>s.setNewDomainName(i.target.value),placeholder:t("domainName"),maxLength:100,disabled:s.creating,className:"mdocs-domain-name-input"})]}),e.jsxs("fieldset",{className:"mdocs-domain-mgmt-fieldset",children:[e.jsx("legend",{className:"mdocs-domain-mgmt-label",children:t("domainPermission")}),e.jsx("div",{className:"mdocs-domain-mgmt-type-radios",children:ne.map(i=>e.jsxs("label",{className:"mdocs-domain-mgmt-radio",children:[e.jsx("input",{type:"radio",name:"newDomainPermission",checked:s.newDomainPermission===i,onChange:()=>s.setNewDomainPermission(i),disabled:s.creating}),e.jsx("span",{children:s.plabel(i)})]},i))})]}),e.jsx("button",{type:"submit",className:"primary mdocs-domain-mgmt-submit",disabled:s.creating,children:s.creating?t("creating"):t("create")})]})]}),m&&e.jsx("div",{className:"mdocs-settings-card",style:{color:m.kind==="ok"?"var(--mdocs-success, #0a7)":"var(--mdocs-danger)"},children:e.jsx("span",{className:"mdocs-settings-item-desc",children:m.text})}),s.domainError&&e.jsx("div",{className:"mdocs-settings-card mdocs-domain-error",children:e.jsx("span",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)"},children:s.domainError})}),e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-toolbar",children:[e.jsx("input",{type:"search",value:s.domainSearch,onChange:i=>s.setDomainSearch(i.target.value),placeholder:t("domainSearchPlaceholder"),className:"mdocs-domain-mgmt-search","aria-label":t("domainSearchPlaceholder")}),e.jsx("div",{className:"mdocs-domain-mgmt-filters",role:"group","aria-label":t("domainPermission"),children:["all",...ne].map(i=>e.jsx("button",{type:"button",className:"mdocs-domain-mgmt-filter"+(s.domainFilter===i?" active":""),"aria-pressed":s.domainFilter===i,onClick:()=>s.setDomainFilter(i),children:i==="all"?t("domainFilterAll"):s.plabel(i)},i))})]}),s.loadingDomains?e.jsx("div",{className:"mdocs-settings-card",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")})}):s.domains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("noDomains")})}):s.filteredDomains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("domainNoMatch")})}):e.jsx("div",{className:"mdocs-settings-card mdocs-domain-table-wrap",children:e.jsxs("table",{className:"mdocs-domain-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:t("domainColName")}),e.jsx("th",{scope:"col",children:t("domainColType")}),e.jsx("th",{scope:"col",className:"mdocs-domain-table-num",children:t("domainColDocCount")}),e.jsx("th",{scope:"col",children:t("domainColActions")})]})}),e.jsx("tbody",{children:s.filteredDomains.map(i=>{const v=ts(i,s.visitorId),g=as(i.domainId),o=ns(i),x=o?t("domainTooltipTypeLocked",{count:String(i.docCount)}):void 0;return e.jsxs("tr",{className:g?"mdocs-domain-table-row-builtin":void 0,children:[e.jsx("td",{children:s.renamingId===i.domainId?e.jsxs("div",{className:"mdocs-domain-table-rename",children:[e.jsx("input",{value:s.renameDraft,onChange:h=>s.setRenameDraft(h.target.value),maxLength:100,autoFocus:!0,className:"mdocs-domain-name-input"}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void s.handleRename(i.domainId),children:t("save")}),e.jsx("button",{type:"button",onClick:s.cancelRename,children:t("cancel")})]}):e.jsxs("div",{className:"mdocs-domain-table-name-cell",children:[e.jsx("span",{className:"mdocs-domain-table-name",children:s.localizeDomain(i)}),g&&e.jsx("span",{className:"mdocs-domain-badge-builtin",children:t("domainBuiltIn")}),!v&&!g&&e.jsx("span",{className:"mdocs-domain-badge-shared",children:t("shared")})]})}),e.jsx("td",{children:e.jsxs("span",{className:"mdocs-domain-table-type",title:x,children:[e.jsx("span",{className:"mdocs-domain-permission-badge","data-permission":i.permission,children:s.domainTypeLabel(i,g)}),o&&!g&&e.jsx("span",{className:"mdocs-domain-type-lock","aria-hidden":"true",children:"🔒"})]})}),e.jsx("td",{className:"mdocs-domain-table-num",children:i.docCount}),e.jsxs("td",{className:"mdocs-domain-table-actions",children:[g&&e.jsx("span",{className:"mdocs-domain-not-modifiable",children:t("domainNotModifiable")}),!g&&!v&&e.jsx("span",{className:"mdocs-domain-not-creator-inline",children:t("domainNotCreator")}),!g&&v&&s.changeTypeForId===i.domainId&&e.jsxs("div",{className:"mdocs-domain-change-type-panel",children:[e.jsx("div",{className:"mdocs-domain-permission-select",children:ne.map(h=>e.jsx("button",{type:"button",className:i.permission===h?"active":"",onClick:()=>void s.handlePermissionChange(i.domainId,h),children:s.plabel(h)},h))}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>s.setChangeTypeForId(null),children:t("cancel")})]}),!g&&v&&s.renamingId!==i.domainId&&s.changeTypeForId!==i.domainId&&e.jsxs("div",{className:"mdocs-domain-action-buttons",children:[e.jsx("button",{type:"button",className:"secondary",title:o?t("domainLocked"):void 0,onClick:()=>{s.setChangeTypeForId(null),s.startRename(i)},disabled:o,children:t("rename")}),e.jsx("button",{type:"button",className:"secondary",title:o?x:void 0,onClick:()=>{s.setRenamingId(null),s.setChangeTypeForId(i.domainId)},disabled:o,children:t("domainChangeType")}),e.jsx("button",{type:"button",className:"secondary",title:o?t("domainLocked"):void 0,onClick:()=>void s.handleDelete(i),disabled:o,children:t("deleteDomain")}),i.permission==="restricted"&&!g&&e.jsx("button",{type:"button",className:"secondary",onClick:()=>void C(i),children:t("domainMembersManageButton")})]})]})]},i.domainId)})})]})})]}),e.jsx(we,{open:p!==null,title:t("domainMembersPickerTitle"),initialSelectedIds:(p==null?void 0:p.initialIds)??[],lockedIds:p?[p.creatorVisitorId]:[],seedMembers:p==null?void 0:p.memberRows,templates:y,onClose:()=>k(null),onConfirm:async i=>{p&&(await is(p.domainId,i),E({kind:"ok",text:t("domainMembersSaved",{count:String(i.length)})}))}})]})}function ye(t){return t.length<=6?t:`${t.slice(0,6)}…`}function Ls(){const{t}=Z(),s=a.useRef(!0),[y,u]=a.useState([]),[m,E]=a.useState(!0),[p,k]=a.useState(null),[N,C]=a.useState(1),[i,v]=a.useState(null),[g,o]=a.useState(""),[x,h]=a.useState([]),[V,I]=a.useState(!1),[z,D]=a.useState(null),[M,F]=a.useState(!1),L=be(),[f,A]=a.useState([]),[w,S]=a.useState("idle"),[P,c]=a.useState("");a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{S("loading"),ls().then(l=>{s.current&&(A(l),S("ok"))}).catch(()=>{s.current&&S("err")})},[]);const d=a.useMemo(()=>{const l=new Map;for(const T of f)l.set(T.visitorId,T.visitorName);return l},[f]),j=a.useCallback(async()=>{E(!0),D(null);try{const l=await ke();s.current&&u(l)}catch(l){s.current&&D(_(t,l))}finally{s.current&&E(!1)}},[t]);a.useEffect(()=>{j()},[j]);const R=a.useMemo(()=>x.map(l=>{const T=f.find(W=>W.visitorId===l);return{visitorId:l,name:T?T.visitorName:t("visitorPickerUnknownVisitor"),muted:!T}}),[x,f,t]);function O(l){h(T=>T.includes(l)?T.filter(W=>W!==l):[...T,l])}const H=N===1?g.trim().length>0:N===2?x.length>0:!0;function q(){if(!(N>=3)){if(!H){F(!0);return}F(!1),C(N+1),c("")}}function G(){N<=1||(F(!1),C(N-1))}function b(){k(null),v(null),o(""),h(L?[L]:[]),D(null),C(1),c(""),F(!1)}function r(l){k(null),v(l.id),o(l.displayName);const T=L&&!l.visitorIds.includes(L)?[...l.visitorIds,L]:[...l.visitorIds];h(T),D(null),C(1),c(""),F(!1)}async function K(){if(!(!g.trim()||x.length===0)){I(!0),D(null);try{if(i===null?await os({displayName:g.trim(),visitorIds:x}):await rs(i,{displayName:g.trim(),visitorIds:x}),!s.current)return;b(),await j()}catch(l){if(!s.current)return;D(_(t,l))}finally{s.current&&I(!1)}}}async function $(l){I(!0),D(null);try{if(await ds(l),!s.current)return;k(null),i===l&&b(),await j()}catch(T){if(!s.current)return;D(_(t,T))}finally{s.current&&I(!1)}}const Q=[{key:1,label:t("memberTemplateStepName")},{key:2,label:t("memberTemplateStepMembers")},{key:3,label:t("memberTemplateStepSave")}],ee=`${(N-1)/2*100}%`;return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:t(i!==null?"memberTemplateUpdate":"memberTemplateFormNew")}),i!==null&&e.jsx("button",{type:"button",className:"secondary",onClick:b,style:{fontSize:12},children:t("memberTemplateCancelEdit")})]}),e.jsxs("div",{className:"mdocs-wizard-progress",children:[e.jsx("div",{className:"mdocs-wizard-progress-track",children:e.jsx("div",{className:"mdocs-wizard-progress-fill",style:{width:ee}})}),e.jsx("div",{className:"mdocs-wizard-progress-steps",children:Q.map(l=>{const T=N===l.key,W=N>l.key;return e.jsxs("div",{className:"mdocs-wizard-step-indicator",children:[e.jsx("div",{className:`mdocs-wizard-step-circle${T?" current":""}${W?" done":""}`,children:W?"✓":l.key}),e.jsx("span",{className:`mdocs-wizard-step-label${T?" current":""}${W?" done":""}`,children:l.label})]},l.key)})})]}),z&&e.jsx("div",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)",marginBottom:12,marginTop:12},children:z}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-wizard-card",children:[N===1&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx("input",{className:"mdocs-wizard-name-input",value:g,onChange:l=>o(l.target.value),placeholder:t("memberTemplateNamePlaceholder"),maxLength:200,disabled:V,autoFocus:!0,"aria-invalid":M&&!g.trim()}),M&&!g.trim()&&e.jsx("p",{className:"mdocs-wizard-hint",style:{color:"var(--mdocs-danger)"},children:t("domainNameRequired")})]}),N===2&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx(Is,{visitors:f,loadState:w,searchFilter:P,onSearchChange:c,selectedIds:new Set(x),onToggle:O,selectedRows:R,myVisitorId:L}),e.jsx("p",{className:`mdocs-wizard-hint${M&&x.length===0?" danger":""}`,children:"💡 "+t("memberTemplateStep2Hint")})]}),N===3&&e.jsx("div",{className:"mdocs-wizard-step-content",children:e.jsxs("div",{className:"mdocs-wizard-preview-card",children:[e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateNameLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:g})]}),e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateIdsLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:t("memberTemplateSelectedSummary",{count:String(x.length)})})]}),x.length>0&&e.jsxs("div",{className:"mdocs-wizard-preview-tags",children:[x.slice(0,15).map(l=>e.jsx("span",{className:"mdocs-wizard-preview-tag",children:ye(l)},l)),x.length>15&&e.jsxs("span",{className:"mdocs-wizard-preview-tag mdocs-wizard-preview-tag-more",children:["+",x.length-15]})]})]})}),e.jsxs("div",{className:"mdocs-wizard-footer",children:[e.jsxs("button",{type:"button",className:"secondary",onClick:G,children:["← ",t("memberTemplateWizardBack")]}),N<3?e.jsxs("button",{type:"button",className:"primary",onClick:q,children:[t("memberTemplateWizardNext")," →"]}):e.jsx("button",{type:"button",className:"primary",onClick:()=>void K(),children:t(V?"saving":i===null?"memberTemplateCreate":"memberTemplateUpdate")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("memberTemplateSavedList")}),m?e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")}):y.length===0?e.jsxs("div",{className:"mdocs-member-template-empty",children:[e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateEmpty")}),i===null&&e.jsx("button",{type:"button",className:"primary",onClick:b,children:t("memberTemplateEmptyAction")})]}):e.jsx("ul",{className:"mdocs-member-template-list",children:y.map(l=>e.jsx("li",{className:"mdocs-member-template-row",children:p===l.id?e.jsxs("div",{className:"mdocs-member-template-confirm-row",children:[e.jsx("span",{className:"mdocs-member-template-confirm-text",children:t("memberTemplateConfirmDeleteDesc",{name:l.displayName})}),e.jsxs("div",{className:"mdocs-member-template-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",style:{color:"var(--mdocs-danger)"},onClick:()=>void $(l.id),children:t(V?"saving":"memberTemplateConfirmDeleteSubmit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(null),children:t("memberTemplateConfirmDeleteCancel")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-member-template-row-head",children:[e.jsx("strong",{children:l.displayName}),e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateCount",{count:String(l.visitorIds.length)})}),l.visitorIds.length>0&&e.jsx("div",{className:"mdocs-member-template-tags mdocs-member-template-tags-scroll",children:l.visitorIds.map(T=>e.jsx("span",{className:"mdocs-member-template-tag",children:d.get(T)??ye(T)},T))})]}),e.jsxs("div",{className:"mdocs-member-template-row-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>r(l),children:t("edit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>k(l.id),children:t("memberTemplateDelete")})]})]})},l.id))})]})]})]})}const Rs=[{value:"deepseek-v4-flash",label:"deepseek-v4-flash"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro"}];function Bs(){const{t}=Z(),s=a.useRef(!0),[y,u]=a.useState(""),[m,E]=a.useState(null),[p,k]=a.useState(""),[N,C]=a.useState("deepseek-v4-flash"),[i,v]=a.useState(128e3),[g,o]=a.useState(""),[x,h]=a.useState(!1),[V,I]=a.useState(null),[z,D]=a.useState(!0),[M,F]=a.useState(!1),[L,f]=a.useState(null),[A,w]=a.useState(!1),[S,P]=a.useState(!1),[c,d]=a.useState(!1),[j,R]=a.useState(null);a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{(async()=>{try{const[b,r]=await Promise.all([ms(),us()]);if(!s.current)return;u(b.visitorName),r?(E(r.id),k(r.name),C(r.modelId),v(r.contextWindow||128e3),h(r.hasApiKey),I(r.apiKeyMasked),P(!1)):P(!0)}catch(b){if(!s.current)return;f(b instanceof Error?b.message:String(b)),P(!0)}finally{s.current&&D(!1)}})()},[]);function O(){R({name:p,modelId:N,contextWindow:i}),o(""),d(!1),w(!1),f(null),P(!0)}function H(){j&&(k(j.name),C(j.modelId),v(j.contextWindow)),o(""),d(!1),f(null),w(!1),P(!1),R(null)}async function q(){F(!0),f(null),w(!1);try{const b={modelId:N,name:p,contextWindow:i};g.trim()&&(b.apiKey=g.trim());const r=await ps(b);if(!s.current)return;E(r.id),k(r.name),C(r.modelId),v(r.contextWindow||128e3),h(r.hasApiKey),I(r.apiKeyMasked),o(""),d(!1),w(!0),P(!1),R(null)}catch(b){if(!s.current)return;f(b instanceof Error?b.message:String(b))}finally{s.current&&F(!1)}}const G=t("agentConfigNameDefault").replace("{{name}}",y||"…");return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsxs("h2",{className:"mdocs-settings-title mdocs-agent-config-title",children:[e.jsx("img",{src:hs,alt:"DeepSeek",className:"mdocs-agent-config-logo"}),t("agentConfig")]}),!z&&m&&!S?e.jsx("button",{type:"button",className:"secondary",onClick:O,children:t("edit")}):null]}),e.jsx("div",{className:"mdocs-settings-cards",children:e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:t("agentConfigDesc")}),z?e.jsx("p",{children:t("loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-settings-item",style:{display:"block",marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigName")}),e.jsx("input",{type:"text",value:p,onChange:b=>k(b.target.value),placeholder:G,disabled:!S,style:{width:"100%",marginTop:6}})]}),e.jsxs("div",{className:"mdocs-settings-item mdocs-agent-config-field",style:{marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigModel")}),S?e.jsx("div",{className:"mdocs-agent-config-select",children:e.jsx(Ts,{options:Rs,value:N,onChange:b=>C(b)})}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:N})]}),e.jsxs("label",{className:"mdocs-settings-item",style:{display:"block",marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigContextWindow")}),e.jsx("p",{className:"mdocs-settings-item-desc",style:{margin:"4px 0 6px"},children:t("agentConfigContextWindowDesc")}),S?e.jsx("input",{type:"number",min:1e3,max:2e6,step:1e3,value:i,onChange:b=>v(Number(b.target.value)||128e3),style:{width:"100%"}}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:i})]}),e.jsxs("div",{className:"mdocs-settings-item mdocs-agent-config-field",style:{marginBottom:12},children:[e.jsx("span",{className:"mdocs-settings-card-title",children:t("agentConfigApiKey")}),S?e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:c?"text":"password",value:g,onChange:b=>o(b.target.value),placeholder:x?t("agentConfigApiKeyConfigured").replace("{{masked}}",V??"…"):t("agentConfigApiKeyPlaceholder"),autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":t(c?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>d(b=>!b),children:c?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M3 3l18 18"}),e.jsx("path",{d:"M10.6 10.6a2 2 0 002.8 2.8"}),e.jsx("path",{d:"M9.9 5.1A10.5 10.5 0 0121 12c-.6 1.1-1.4 2.1-2.4 2.9"}),e.jsx("path",{d:"M6.1 6.1C4.5 7.4 3.2 9.1 2.5 12c1.5 3.5 5 7 9.5 7 1.4 0 2.7-.3 3.9-.8"})]}):e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M2.5 12C4 8.5 7.5 5 12 5s8 3.5 9.5 7c-1.5 3.5-5 7-9.5 7s-8-3.5-9.5-7z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]}):e.jsx("p",{className:"mdocs-agent-config-readonly",children:x?V??"…":t("agentConfigApiKeyPlaceholder")})]}),m?e.jsxs("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:[t("agentConfigId"),": ",m]}):null,L?e.jsx("p",{style:{color:"var(--mdocs-danger, #c00)",marginBottom:12},children:L}):null,A&&!S?e.jsx("p",{className:"mdocs-settings-item-desc",style:{marginBottom:12},children:t("saved")}):null,S?e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void q(),disabled:M,children:t(M?"saving":"save")}),m?e.jsx("button",{type:"button",className:"secondary",onClick:H,disabled:M,children:t("cancel")}):null]}):null]})]})})]})}function Ne(t,s){const y=localStorage.getItem(t);return y===null?s:y==="true"}function $s(t){const{t:s,lang:y,setLang:u}=Z(),{onBack:m,onPublishDraft:E}=t,p=a.useRef(!0);a.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const[k,N]=a.useState(()=>Ne("mdocs.autoPublish",!1)),[C,i]=a.useState(()=>Ne("mdocs.autoEdit",!0)),[v,g]=a.useState(!1),[o,x]=a.useState("general"),[h,V]=a.useState([]),[I,z]=a.useState(!0),[D,M]=a.useState(null),[F,L]=a.useState(!1),[f,A]=a.useState(!1),[w,S]=a.useState(!1),[P,c]=a.useState(!1),[d,j]=a.useState(null),[R,O]=a.useState(!1),[H,q]=a.useState(!1),[G,b]=a.useState(!1),[r,K]=a.useState(""),[$,Q]=a.useState(!1),[ee,l]=a.useState(!1),[T,W]=a.useState(0),[Se,le]=a.useState([]),[Ce,oe]=a.useState(!1),[X,De]=a.useState(""),[Ie,Te]=a.useState([]),[Ae,re]=a.useState(!1),[Y,Pe]=a.useState(""),[Me,Ee]=a.useState([]),[Le,se]=a.useState(!1),[te,de]=a.useState(null),[ae,me]=a.useState(new Map);a.useEffect(()=>{localStorage.setItem("mdocs.autoPublish",String(k))},[k]),a.useEffect(()=>{localStorage.setItem("mdocs.autoEdit",String(C))},[C]),a.useEffect(()=>{o==="savePublish"&&ce().then(n=>{p.current&&W(n.filter(B=>!B.published).length)})},[o]),a.useEffect(()=>{o==="bookmarks"&&Re(),o==="myDocuments"&&pe()},[o]),a.useEffect(()=>{he()},[]),a.useEffect(()=>{ve().then(n=>{p.current&&Ee(n)}).catch(()=>{})},[]);const ue=new Map(Me.map(n=>[n.domainId,n.domainName]));async function he(){try{z(!0);const n=await gs();if(!p.current)return;V(n)}catch{}finally{p.current&&z(!1)}}async function Re(){try{oe(!0);const n=await fs();if(!p.current)return;le(n)}catch{}finally{p.current&&oe(!1)}}async function pe(){try{re(!0);const n=await xs();if(!p.current)return;Te(n)}catch{}finally{p.current&&re(!1)}}async function Be(n){try{await ks(n),le(B=>B.filter(J=>J.documentId!==n))}catch{}}function ze(){if(h.some(B=>!B.revoked)){A(!0);return}ge()}async function ge(){try{L(!0);const n=await Ss();M({token:n.token,name:n.name}),await he()}finally{L(!1)}}async function Fe(){try{b(!0);const n=await bs();j(n.recoveryCode)}finally{b(!1)}}async function Ke(n){n.preventDefault();const B=r.trim();if(!(B&&B.length<4))try{Q(!0),await vs(B),K(""),l(!0),setTimeout(()=>l(!1),3e3)}finally{Q(!1)}}async function Ve(n){de(n);try{const B=await ws(n),J=new Map;B.forEach(U=>{J.set(U.visitorId,U.permission)}),me(J)}catch{me(new Map)}se(!0)}async function Oe(n){if(te)try{const B=new Set(n.map(U=>U.visitorId)),J=new Set(ae.keys());for(const U of J)B.has(U)||await Cs(te,U);for(const U of n)await Ds(te,U.visitorId,U.permission);await pe()}finally{se(!1),de(null)}}const fe=Se.filter(n=>{if(!X.trim())return!0;const B=X.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(B)||(n.ownerVisitorName||"").toLowerCase().includes(B)||(n.domainId||"").toLowerCase().includes(B)}),xe=Ie.filter(n=>{if(!Y.trim())return!0;const B=Y.toLowerCase();return(n.displayName||n.relativePath||"").toLowerCase().includes(B)||(n.domainId||"").toLowerCase().includes(B)});return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"mdocs-sidebar",children:[e.jsx("header",{className:"mdocs-sidebar-header",children:e.jsxs("div",{className:"mdocs-brand",children:[e.jsx("img",{src:js,alt:s("brand"),className:"mdocs-brand-logo"}),e.jsx("span",{children:s("brand")})]})}),e.jsxs("nav",{className:"mdocs-config-tree",children:[e.jsx("div",{className:"mdocs-config-item"+(o==="general"?" active":""),onClick:()=>x("general"),children:s("general")}),e.jsx("div",{className:"mdocs-config-item"+(o==="bookmarks"?" active":""),onClick:()=>x("bookmarks"),children:s("bookmarkTitle")}),e.jsx("div",{className:"mdocs-config-item"+(o==="myDocuments"?" active":""),onClick:()=>x("myDocuments"),children:s("myDocuments")}),e.jsx("div",{className:"mdocs-config-item"+(o==="domainManagement"?" active":""),onClick:()=>x("domainManagement"),children:s("domainManagement")}),e.jsx("div",{className:"mdocs-config-item"+(o==="memberTemplates"?" active":""),onClick:()=>x("memberTemplates"),children:s("memberTemplates")}),e.jsx("div",{className:"mdocs-config-item"+(o==="agentConfig"?" active":""),onClick:()=>x("agentConfig"),children:s("agentConfig")}),e.jsx("div",{className:"mdocs-config-item"+(o==="savePublish"?" active":""),onClick:()=>x("savePublish"),children:s("saveAndPublish")})]}),e.jsx("footer",{className:"mdocs-settings-sidebar-footer",onClick:m,children:s("backToDocs")})]}),e.jsxs("main",{className:"mdocs-main",children:[ys(),o==="general"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("general")})}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsx("span",{className:"mdocs-settings-item-info",children:e.jsx("span",{className:"mdocs-settings-card-title",children:s("language")})}),e.jsxs("span",{className:"mdocs-settings-lang",children:[e.jsx("button",{type:"button",className:y==="en"?"active":"",onClick:()=>u("en"),children:"EN"}),e.jsx("span",{children:"/"}),e.jsx("button",{type:"button",className:y==="zh"?"active":"",onClick:()=>u("zh"),children:"中"})]})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoEdit")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoEditDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(C?" active":""),role:"switch","aria-checked":C,onClick:()=>i(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliToken")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("cliTokenDesc")}),!I&&h.length>0&&e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8,fontSize:"0.85em",opacity:.8},children:h.map(n=>e.jsxs("span",{style:{display:"block"},children:[n.name," — ",new Date(n.createdAt).toLocaleString()," ",n.revoked?`(${s("cliTokenRevoked")})`:`(${s("cliTokenActive")})`]},n.tokenId))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:ze,disabled:F||I,children:F?"…":h.some(n=>!n.revoked)?s("cliTokenReset"):s("cliTokenCreate")})]}),D&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--ok",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliTokenGenerated")}),e.jsx("span",{className:"mdocs-settings-secret-value",children:D.token})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(D.token),c(!1),S(!0),window.setTimeout(()=>S(!1),2e3)}catch{S(!1),c(!0),window.setTimeout(()=>c(!1),3e3)}})()},children:s(w?"cliTokenCopied":"cliTokenCopy")}),e.jsx("button",{type:"button",onClick:()=>M(null),children:s("close")})]}),w&&e.jsxs("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:["✓ ",s("cliTokenCopied")]}),P&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:s("cliTokenCopyFailed")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"当 Token 丢失时,可用恢复码找回身份。生成后请立即保存,仅显示一次。"})]}),e.jsx("button",{type:"button",className:"secondary",onClick:Fe,disabled:G,children:G?"…":"生成恢复码"})]}),d&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--warn",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 你的恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8},children:"请立即复制保存,关闭后不可再查看。"}),e.jsx("div",{className:"mdocs-settings-secret-code",children:d})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(d),q(!1),O(!0),window.setTimeout(()=>O(!1),2e3)}catch{O(!1),q(!0),window.setTimeout(()=>q(!1),3e3)}})()},children:R?"已复制":"复制恢复码"}),e.jsx("button",{type:"button",onClick:()=>j(null),children:s("close")})]}),R&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:"✓ 已复制到剪贴板"}),H&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:"复制失败,请手动选中上方内容复制"})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-item",children:e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔐 登录密码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"设置密码后,可在其他浏览器或设备用「用户名+密码」登录。"})]})}),e.jsxs("form",{onSubmit:Ke,style:{marginTop:12},children:[e.jsx("input",{type:"password",placeholder:"输入新密码(至少 4 位,留空则清除密码)",value:r,onChange:n=>K(n.target.value),minLength:0,style:{marginBottom:8}}),ee&&e.jsx("div",{style:{color:"#4caf50",marginBottom:8,fontSize:"0.875rem"},children:"✓ 密码设置成功"}),e.jsx("button",{type:"submit",className:"secondary",disabled:$,children:$?"设置中…":"保存密码"})]})]})]})]}):o==="bookmarks"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("bookmarkTitle")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:s("bookmarkSearch"),value:X,onChange:n=>De(n.target.value)}),Ce?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:fe.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(X?"bookmarkNoMatch":"bookmarkEmpty")}):e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("bookmarkColTitle")}),e.jsx("th",{children:s("bookmarkColDomain")}),e.jsx("th",{children:s("bookmarkColAuthor")}),e.jsx("th",{children:s("bookmarkColTime")}),e.jsx("th",{style:{textAlign:"right"}})]})}),e.jsx("tbody",{children:fe.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:n.isDeleted?e.jsx("span",{style:{opacity:.5,fontStyle:"italic"},children:"已删除"}):ue.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:n.ownerVisitorName||"—"}),e.jsx("td",{children:new Date(n.bookmarkedAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Be(n.documentId),children:s("bookmarkRemove")})})]},n.documentId))})]})})]})]}):o==="myDocuments"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("myDocuments")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:"搜索文章…",value:Y,onChange:n=>Pe(n.target.value)}),Ae?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:xe.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(Y?"myDocumentsNoMatch":"myDocumentsEmpty")}):e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("myDocumentsColTitle")}),e.jsx("th",{children:s("myDocumentsColDomain")}),e.jsx("th",{children:s("myDocumentsColUpdated")}),e.jsx("th",{children:s("myDocumentsColCreated")}),e.jsx("th",{colSpan:2})]})}),e.jsx("tbody",{children:xe.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(n.documentId),children:n.displayName||n.relativePath||"Untitled"}),e.jsx("td",{children:ue.get(n.domainId||"")||n.domainId||"—"}),e.jsx("td",{children:new Date(n.updatedAt).toLocaleDateString()}),e.jsx("td",{children:new Date(n.createdAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Ve(n.documentId),children:s("docInfoInviteMember")})}),e.jsx("td",{style:{textAlign:"right",paddingLeft:0},children:e.jsx("button",{type:"button",className:"primary small",onClick:()=>t.onOpenDocument(n.documentId),children:s("bookmarkOpen")})})]},n.documentId))})]})})]})]}):o==="domainManagement"?e.jsx(Es,{}):o==="memberTemplates"?e.jsx(Ls,{}):o==="agentConfig"?e.jsx(Bs,{}):e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:s("saveAndPublish")}),e.jsx("button",{type:"button",className:"secondary",onClick:m,children:s("backToDocs")})]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoSave")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoSaveAlwaysOnDesc")})]}),e.jsx("span",{className:"mdocs-toggle active",role:"switch","aria-checked":"true","aria-disabled":"true",style:{opacity:.6,cursor:"not-allowed"},children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoPublish")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoPublishDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(k?" active":""),role:"switch","aria-checked":k,onClick:()=>N(n=>!n),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),T>0?e.jsxs("button",{className:"mdocs-settings-card mdocs-settings-draft-link",onClick:()=>g(!0),children:[e.jsxs("span",{className:"mdocs-settings-draft-link-text",children:["📄 ",s("viewDrafts")," (",T,")"]}),e.jsx("span",{className:"mdocs-settings-draft-arrow","aria-hidden":"true",children:"›"})]}):e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:s("noDrafts")})})]})]}),v&&e.jsx(Ps,{onPublish:E,onClose:()=>g(!1),onCountChange:W,onRecover:t.onRecoverDraft})]}),f&&e.jsx(Ns,{title:s("cliToken"),message:s("cliTokenResetConfirm"),confirmLabel:s("cliTokenReset"),cancelLabel:s("cancel"),busy:F,onConfirm:()=>{A(!1),ge()},onCancel:()=>A(!1)}),e.jsx(we,{open:Le,title:s("docInfoInviteMember"),initialSelectedIds:[...ae.keys()],initialPermissions:ae,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:s("invitePermissionRead")},{value:"edit",label:s("invitePermissionEdit")}],onClose:()=>se(!1),onConfirm:n=>{Oe(n)}})]})}export{$s as SettingsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as o}from"./index-
|
|
1
|
+
import{c as o}from"./index-C46BU1-j.js";import{r as u,j as r}from"./react-vendor-BNpqFP9B.js";import{F as _,G as C,L as v,H as c,J as l,K as N,M as L,q as j,N as z,P as w}from"./react-B7vrA7AR.js";import{z as g,V as b}from"./editor-ONzd_YnO.js";/**
|
|
2
2
|
* @license lucide-react v0.562.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e}from"./react-vendor-BNpqFP9B.js";import{b as G,B as ee,f as se,w as z}from"./index-CA7lpALZ.js";function ie({options:v,value:a,onChange:b}){const[d,f]=r.useState(!1),y=r.useRef(null),x=r.useRef(null),p=v.find(o=>o.value===a);r.useEffect(()=>{if(!d)return;const o=u=>{var N,k;!((N=y.current)!=null&&N.contains(u.target))&&!((k=x.current)!=null&&k.contains(u.target))&&f(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[d]),r.useEffect(()=>{if(!d)return;const o=u=>{var N;u.key==="Escape"&&(f(!1),(N=y.current)==null||N.focus())};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[d]);function j(o){b(o),f(!1)}return e.jsxs("div",{className:"mdocs-mini-select",style:{position:"relative"},children:[e.jsxs("button",{ref:y,type:"button",className:"mdocs-mini-select-trigger","aria-expanded":d,"aria-haspopup":"listbox",onClick:()=>f(o=>!o),children:[e.jsx("span",{children:p==null?void 0:p.label}),e.jsx("svg",{className:"mdocs-mini-select-chevron"+(d?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M1 1l4 4 4-4"})})]}),d&&e.jsx("div",{ref:x,className:"mdocs-mini-select-menu card",role:"listbox",children:v.map(o=>e.jsx("button",{type:"button",className:"mdocs-mini-select-option"+(o.value===a?" active":""),role:"option","aria-selected":o.value===a,onClick:()=>j(o.value),children:o.label},o.value))})]})}function te(v){return v.length<=6?v:`${v.slice(0,6)}…`}function re(v){const{visitors:a,loadState:b,searchFilter:d,onSearchChange:f,selectedIds:y,onToggle:x,selectedRows:p,lockedIds:j=new Set,myVisitorId:o,showPermissionSelect:u=!1,permissionOptions:N=[],onPermissionChange:k}=v,{t:i}=G(),w=r.useMemo(()=>{const t=d.trim().toLowerCase();let g=t?a.filter(m=>m.visitorName.toLowerCase().includes(t)||m.visitorId.toLowerCase().includes(t)):a;return o&&(g=[...g].sort((m,R)=>m.visitorId===o?-1:R.visitorId===o?1:0)),g},[a,d,o]);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"search",className:"mdocs-visitor-picker-search",placeholder:i("visitorPickerSearchPlaceholder"),value:d,onChange:t=>f(t.target.value),disabled:b!=="ok"}),b==="loading"&&e.jsx("div",{className:"mdocs-visitor-picker-loading",children:i("loading")}),b==="err"&&e.jsx("div",{className:"mdocs-visitor-picker-error",children:i("visitorPickerLoadError")}),b==="ok"&&e.jsxs("div",{className:"mdocs-visitor-picker-columns",children:[e.jsxs("div",{className:"mdocs-visitor-picker-col",children:[e.jsx("h3",{className:"mdocs-visitor-picker-col-title",children:i("visitorPickerColumnAll")}),e.jsx("div",{className:"mdocs-visitor-picker-table-wrap",children:e.jsxs("table",{className:"mdocs-visitor-picker-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:i("visitorPickerColIdShort")}),e.jsx("th",{scope:"col",children:i("visitorPickerColName")}),e.jsx("th",{scope:"col",className:"mdocs-visitor-picker-check-col",children:i("visitorPickerColPick")})]})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"mdocs-visitor-picker-empty-cell",children:a.length===0?i("visitorPickerEmptyDirectory"):i("domainNoMatch")})}):w.map(t=>{const g=j.has(t.visitorId),m=y.has(t.visitorId);return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{className:"mdocs-visitor-picker-id-short",children:te(t.visitorId)})}),e.jsxs("td",{children:[t.visitorName,t.visitorId===o&&e.jsx("span",{className:"mdocs-visitor-picker-self-marker",children:i("visitorPickerSelfMarker")})]}),e.jsx("td",{className:"mdocs-visitor-picker-check-col",children:e.jsx("input",{type:"checkbox",checked:m,disabled:g,onChange:()=>x(t.visitorId),"aria-label":t.visitorName})})]},t.visitorId)})})]})})]}),e.jsxs("div",{className:"mdocs-visitor-picker-col",children:[e.jsx("h3",{className:"mdocs-visitor-picker-col-title",children:i("visitorPickerColumnSelected")}),e.jsx("div",{className:"mdocs-visitor-picker-table-wrap",children:e.jsxs("table",{className:"mdocs-visitor-picker-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:i("visitorPickerColIdFull")}),e.jsx("th",{scope:"col",children:i("visitorPickerColName")}),u&&e.jsx("th",{scope:"col",children:i("permissionLabel")}),e.jsx("th",{scope:"col",className:"mdocs-visitor-picker-check-col"})]})}),e.jsx("tbody",{children:p.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:u?4:3,className:"mdocs-visitor-picker-empty-cell",children:i("visitorPickerNoSelection")})}):p.map(t=>{const g=j.has(t.visitorId);return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{className:"mdocs-visitor-picker-id-full",children:t.visitorId})}),e.jsx("td",{className:t.muted?"mdocs-visitor-picker-name-muted":void 0,children:t.name}),u&&e.jsx("td",{children:e.jsx(ie,{options:N,value:t.permission??"read",onChange:m=>k==null?void 0:k(t.visitorId,m)})}),e.jsx("td",{className:"mdocs-visitor-picker-check-col",children:g?e.jsx("span",{className:"mdocs-visitor-picker-locked",title:i("visitorPickerLockedHint"),children:"—"}):e.jsx("button",{type:"button",className:"mdocs-visitor-picker-remove",onClick:()=>x(t.visitorId),"aria-label":i("visitorPickerRemove"),children:"×"})})]},t.visitorId)})})]})})]})]})]})}function ne(v){var U;const{open:a,title:b,initialSelectedIds:d,lockedIds:f=[],seedMembers:y,excludeTemplateId:x,templates:p,onClose:j,onConfirm:o,showPermissionSelect:u=!1,permissionOptions:N=[],initialPermissions:k}=v,{t:i}=G(),w=r.useRef(i);w.current=i;const t=r.useMemo(()=>new Set(f),[f]),g=ee(),[m,R]=r.useState([]),[E,T]=r.useState("idle"),[P,V]=r.useState(()=>new Set),[O,L]=r.useState(()=>new Map),[J,F]=r.useState(""),[C,A]=r.useState(""),[M,B]=r.useState(!1),$=r.useRef(null),[K,W]=r.useState(!1),[q,I]=r.useState(null),D=r.useMemo(()=>p.filter(s=>x==null||s.id!==x),[p,x]),H=r.useMemo(()=>new Map((y??[]).map(s=>[s.visitorId,s])),[y]);r.useEffect(()=>{a&&(V(new Set(d)),L(k?new Map(k):new Map),F(""),A(""),I(null))},[a,d,k]),r.useEffect(()=>{if(!a)return;let s=!1;return T("loading"),se().then(n=>{s||(R(n),T("ok"))}).catch(n=>{s||(T("err"),I(z(w.current,n)))}),()=>{s=!0}},[a]),r.useEffect(()=>{if(!M)return;const s=n=>{var c;(c=$.current)!=null&&c.contains(n.target)||B(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[M]);const Q=r.useMemo(()=>{const s=new Map(m.map(c=>[c.visitorId,c])),n=[];for(const c of P){const l=O.get(c),h=s.get(c);if(h){n.push({visitorId:c,name:h.visitorName,muted:!1,permission:l});continue}const S=H.get(c);if(S){S.missing?n.push({visitorId:c,name:i("visitorPickerMemberMissing"),muted:!0,permission:l}):S.disabled?n.push({visitorId:c,name:`${S.visitorName} · ${i("visitorPickerDisabledTag")}`,muted:!0,permission:l}):n.push({visitorId:c,name:S.visitorName,muted:!1,permission:l});continue}n.push({visitorId:c,name:i("visitorPickerUnknownVisitor"),muted:!0,permission:l})}return n.sort((c,l)=>c.name.localeCompare(l.name,void 0,{sensitivity:"base"})),n},[m,P,H,O,i]),X=r.useCallback(s=>{t.has(s)||V(n=>{const c=new Set(n);return c.has(s)?(c.delete(s),L(l=>{const h=new Map(l);return h.delete(s),h})):(c.add(s),L(l=>{const h=new Map(l);return h.set(s,"read"),h})),c})},[t]),Y=r.useCallback((s,n)=>{L(c=>{const l=new Map(c);return l.set(s,n),l})},[]),Z=r.useCallback(()=>{const s=Number(C);if(!Number.isInteger(s)||s<1)return;const n=p.find(l=>l.id===s);if(!n)return;const c=new Set(m.map(l=>l.visitorId));V(l=>{const h=new Set(l);for(const S of n.visitorIds)c.has(S)&&h.add(S);return h})},[C,p,m]);async function _(){I(null),W(!0);try{if(u){const s=[...P].sort().map(n=>({visitorId:n,permission:O.get(n)??"read"}));await o(s)}else{const s=[...P].sort();await o(s)}j()}catch(s){I(z(i,s))}finally{W(!1)}}return a?e.jsx("div",{className:"mdocs-visitor-picker-overlay",role:"presentation",onMouseDown:s=>s.target===s.currentTarget&&j(),children:e.jsxs("div",{className:"mdocs-visitor-picker-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-visitor-picker-title",children:[e.jsxs("header",{className:"mdocs-visitor-picker-header",children:[e.jsx("h2",{id:"mdocs-visitor-picker-title",className:"mdocs-visitor-picker-title",children:b}),e.jsx("button",{type:"button",className:"mdocs-visitor-picker-close",onClick:j,"aria-label":i("close"),children:"×"})]}),D.length>0&&e.jsx("div",{className:"mdocs-visitor-picker-toolbar",children:e.jsxs("div",{className:"mdocs-visitor-picker-template-bar",children:[e.jsxs("div",{ref:$,className:"mdocs-template-picker",children:[e.jsxs("button",{type:"button",className:"mdocs-template-picker-trigger",onClick:()=>B(s=>!s),disabled:E!=="ok","aria-haspopup":"listbox","aria-expanded":M,children:[e.jsx("span",{className:"mdocs-template-picker-text",children:C?(U=D.find(s=>String(s.id)===C))==null?void 0:U.displayName:i("visitorPickerPickTemplate")}),e.jsx("svg",{className:"mdocs-template-picker-chevron"+(M?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M1 1l4 4 4-4"})})]}),M&&e.jsx("div",{className:"mdocs-template-picker-menu card",role:"listbox",children:D.map(s=>e.jsx("button",{type:"button",className:"mdocs-template-picker-option"+(String(s.id)===C?" active":""),role:"option","aria-selected":String(s.id)===C,onClick:()=>{A(String(s.id)),B(!1)},children:s.displayName},s.id))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>{if(E!=="ok"){I(i("loading"));return}if(!C){I(i("visitorPickerPickTemplate"));return}Z()},children:i("visitorPickerApplyTemplate")})]})}),q&&e.jsx("div",{className:"mdocs-visitor-picker-error",role:"alert",children:q}),e.jsx("div",{style:{padding:"8px 18px 12px"},children:e.jsx(re,{visitors:m,loadState:E,searchFilter:J,onSearchChange:F,selectedIds:P,onToggle:X,selectedRows:Q,lockedIds:t,myVisitorId:g,showPermissionSelect:u,permissionOptions:N,onPermissionChange:Y})}),e.jsxs("footer",{className:"mdocs-visitor-picker-footer",children:[e.jsx("button",{type:"button",className:"secondary",onClick:j,children:i("cancel")}),e.jsx("button",{type:"button",className:"primary",onClick:()=>{if(E!=="ok"){I(i("loading"));return}_()},children:i(K?"saving":"visitorPickerConfirm")})]})]})}):null}export{ie as M,ne as V,re as a};
|
|
1
|
+
import{r,j as e}from"./react-vendor-BNpqFP9B.js";import{b as G,B as ee,f as se,w as z}from"./index-C46BU1-j.js";function ie({options:v,value:a,onChange:b}){const[d,f]=r.useState(!1),y=r.useRef(null),x=r.useRef(null),p=v.find(o=>o.value===a);r.useEffect(()=>{if(!d)return;const o=u=>{var N,k;!((N=y.current)!=null&&N.contains(u.target))&&!((k=x.current)!=null&&k.contains(u.target))&&f(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[d]),r.useEffect(()=>{if(!d)return;const o=u=>{var N;u.key==="Escape"&&(f(!1),(N=y.current)==null||N.focus())};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[d]);function j(o){b(o),f(!1)}return e.jsxs("div",{className:"mdocs-mini-select",style:{position:"relative"},children:[e.jsxs("button",{ref:y,type:"button",className:"mdocs-mini-select-trigger","aria-expanded":d,"aria-haspopup":"listbox",onClick:()=>f(o=>!o),children:[e.jsx("span",{children:p==null?void 0:p.label}),e.jsx("svg",{className:"mdocs-mini-select-chevron"+(d?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M1 1l4 4 4-4"})})]}),d&&e.jsx("div",{ref:x,className:"mdocs-mini-select-menu card",role:"listbox",children:v.map(o=>e.jsx("button",{type:"button",className:"mdocs-mini-select-option"+(o.value===a?" active":""),role:"option","aria-selected":o.value===a,onClick:()=>j(o.value),children:o.label},o.value))})]})}function te(v){return v.length<=6?v:`${v.slice(0,6)}…`}function re(v){const{visitors:a,loadState:b,searchFilter:d,onSearchChange:f,selectedIds:y,onToggle:x,selectedRows:p,lockedIds:j=new Set,myVisitorId:o,showPermissionSelect:u=!1,permissionOptions:N=[],onPermissionChange:k}=v,{t:i}=G(),w=r.useMemo(()=>{const t=d.trim().toLowerCase();let g=t?a.filter(m=>m.visitorName.toLowerCase().includes(t)||m.visitorId.toLowerCase().includes(t)):a;return o&&(g=[...g].sort((m,R)=>m.visitorId===o?-1:R.visitorId===o?1:0)),g},[a,d,o]);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"search",className:"mdocs-visitor-picker-search",placeholder:i("visitorPickerSearchPlaceholder"),value:d,onChange:t=>f(t.target.value),disabled:b!=="ok"}),b==="loading"&&e.jsx("div",{className:"mdocs-visitor-picker-loading",children:i("loading")}),b==="err"&&e.jsx("div",{className:"mdocs-visitor-picker-error",children:i("visitorPickerLoadError")}),b==="ok"&&e.jsxs("div",{className:"mdocs-visitor-picker-columns",children:[e.jsxs("div",{className:"mdocs-visitor-picker-col",children:[e.jsx("h3",{className:"mdocs-visitor-picker-col-title",children:i("visitorPickerColumnAll")}),e.jsx("div",{className:"mdocs-visitor-picker-table-wrap",children:e.jsxs("table",{className:"mdocs-visitor-picker-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:i("visitorPickerColIdShort")}),e.jsx("th",{scope:"col",children:i("visitorPickerColName")}),e.jsx("th",{scope:"col",className:"mdocs-visitor-picker-check-col",children:i("visitorPickerColPick")})]})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"mdocs-visitor-picker-empty-cell",children:a.length===0?i("visitorPickerEmptyDirectory"):i("domainNoMatch")})}):w.map(t=>{const g=j.has(t.visitorId),m=y.has(t.visitorId);return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{className:"mdocs-visitor-picker-id-short",children:te(t.visitorId)})}),e.jsxs("td",{children:[t.visitorName,t.visitorId===o&&e.jsx("span",{className:"mdocs-visitor-picker-self-marker",children:i("visitorPickerSelfMarker")})]}),e.jsx("td",{className:"mdocs-visitor-picker-check-col",children:e.jsx("input",{type:"checkbox",checked:m,disabled:g,onChange:()=>x(t.visitorId),"aria-label":t.visitorName})})]},t.visitorId)})})]})})]}),e.jsxs("div",{className:"mdocs-visitor-picker-col",children:[e.jsx("h3",{className:"mdocs-visitor-picker-col-title",children:i("visitorPickerColumnSelected")}),e.jsx("div",{className:"mdocs-visitor-picker-table-wrap",children:e.jsxs("table",{className:"mdocs-visitor-picker-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:i("visitorPickerColIdFull")}),e.jsx("th",{scope:"col",children:i("visitorPickerColName")}),u&&e.jsx("th",{scope:"col",children:i("permissionLabel")}),e.jsx("th",{scope:"col",className:"mdocs-visitor-picker-check-col"})]})}),e.jsx("tbody",{children:p.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:u?4:3,className:"mdocs-visitor-picker-empty-cell",children:i("visitorPickerNoSelection")})}):p.map(t=>{const g=j.has(t.visitorId);return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{className:"mdocs-visitor-picker-id-full",children:t.visitorId})}),e.jsx("td",{className:t.muted?"mdocs-visitor-picker-name-muted":void 0,children:t.name}),u&&e.jsx("td",{children:e.jsx(ie,{options:N,value:t.permission??"read",onChange:m=>k==null?void 0:k(t.visitorId,m)})}),e.jsx("td",{className:"mdocs-visitor-picker-check-col",children:g?e.jsx("span",{className:"mdocs-visitor-picker-locked",title:i("visitorPickerLockedHint"),children:"—"}):e.jsx("button",{type:"button",className:"mdocs-visitor-picker-remove",onClick:()=>x(t.visitorId),"aria-label":i("visitorPickerRemove"),children:"×"})})]},t.visitorId)})})]})})]})]})]})}function ne(v){var U;const{open:a,title:b,initialSelectedIds:d,lockedIds:f=[],seedMembers:y,excludeTemplateId:x,templates:p,onClose:j,onConfirm:o,showPermissionSelect:u=!1,permissionOptions:N=[],initialPermissions:k}=v,{t:i}=G(),w=r.useRef(i);w.current=i;const t=r.useMemo(()=>new Set(f),[f]),g=ee(),[m,R]=r.useState([]),[E,T]=r.useState("idle"),[P,V]=r.useState(()=>new Set),[O,L]=r.useState(()=>new Map),[J,F]=r.useState(""),[C,A]=r.useState(""),[M,B]=r.useState(!1),$=r.useRef(null),[K,W]=r.useState(!1),[q,I]=r.useState(null),D=r.useMemo(()=>p.filter(s=>x==null||s.id!==x),[p,x]),H=r.useMemo(()=>new Map((y??[]).map(s=>[s.visitorId,s])),[y]);r.useEffect(()=>{a&&(V(new Set(d)),L(k?new Map(k):new Map),F(""),A(""),I(null))},[a,d,k]),r.useEffect(()=>{if(!a)return;let s=!1;return T("loading"),se().then(n=>{s||(R(n),T("ok"))}).catch(n=>{s||(T("err"),I(z(w.current,n)))}),()=>{s=!0}},[a]),r.useEffect(()=>{if(!M)return;const s=n=>{var c;(c=$.current)!=null&&c.contains(n.target)||B(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[M]);const Q=r.useMemo(()=>{const s=new Map(m.map(c=>[c.visitorId,c])),n=[];for(const c of P){const l=O.get(c),h=s.get(c);if(h){n.push({visitorId:c,name:h.visitorName,muted:!1,permission:l});continue}const S=H.get(c);if(S){S.missing?n.push({visitorId:c,name:i("visitorPickerMemberMissing"),muted:!0,permission:l}):S.disabled?n.push({visitorId:c,name:`${S.visitorName} · ${i("visitorPickerDisabledTag")}`,muted:!0,permission:l}):n.push({visitorId:c,name:S.visitorName,muted:!1,permission:l});continue}n.push({visitorId:c,name:i("visitorPickerUnknownVisitor"),muted:!0,permission:l})}return n.sort((c,l)=>c.name.localeCompare(l.name,void 0,{sensitivity:"base"})),n},[m,P,H,O,i]),X=r.useCallback(s=>{t.has(s)||V(n=>{const c=new Set(n);return c.has(s)?(c.delete(s),L(l=>{const h=new Map(l);return h.delete(s),h})):(c.add(s),L(l=>{const h=new Map(l);return h.set(s,"read"),h})),c})},[t]),Y=r.useCallback((s,n)=>{L(c=>{const l=new Map(c);return l.set(s,n),l})},[]),Z=r.useCallback(()=>{const s=Number(C);if(!Number.isInteger(s)||s<1)return;const n=p.find(l=>l.id===s);if(!n)return;const c=new Set(m.map(l=>l.visitorId));V(l=>{const h=new Set(l);for(const S of n.visitorIds)c.has(S)&&h.add(S);return h})},[C,p,m]);async function _(){I(null),W(!0);try{if(u){const s=[...P].sort().map(n=>({visitorId:n,permission:O.get(n)??"read"}));await o(s)}else{const s=[...P].sort();await o(s)}j()}catch(s){I(z(i,s))}finally{W(!1)}}return a?e.jsx("div",{className:"mdocs-visitor-picker-overlay",role:"presentation",onMouseDown:s=>s.target===s.currentTarget&&j(),children:e.jsxs("div",{className:"mdocs-visitor-picker-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-visitor-picker-title",children:[e.jsxs("header",{className:"mdocs-visitor-picker-header",children:[e.jsx("h2",{id:"mdocs-visitor-picker-title",className:"mdocs-visitor-picker-title",children:b}),e.jsx("button",{type:"button",className:"mdocs-visitor-picker-close",onClick:j,"aria-label":i("close"),children:"×"})]}),D.length>0&&e.jsx("div",{className:"mdocs-visitor-picker-toolbar",children:e.jsxs("div",{className:"mdocs-visitor-picker-template-bar",children:[e.jsxs("div",{ref:$,className:"mdocs-template-picker",children:[e.jsxs("button",{type:"button",className:"mdocs-template-picker-trigger",onClick:()=>B(s=>!s),disabled:E!=="ok","aria-haspopup":"listbox","aria-expanded":M,children:[e.jsx("span",{className:"mdocs-template-picker-text",children:C?(U=D.find(s=>String(s.id)===C))==null?void 0:U.displayName:i("visitorPickerPickTemplate")}),e.jsx("svg",{className:"mdocs-template-picker-chevron"+(M?" open":""),width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M1 1l4 4 4-4"})})]}),M&&e.jsx("div",{className:"mdocs-template-picker-menu card",role:"listbox",children:D.map(s=>e.jsx("button",{type:"button",className:"mdocs-template-picker-option"+(String(s.id)===C?" active":""),role:"option","aria-selected":String(s.id)===C,onClick:()=>{A(String(s.id)),B(!1)},children:s.displayName},s.id))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>{if(E!=="ok"){I(i("loading"));return}if(!C){I(i("visitorPickerPickTemplate"));return}Z()},children:i("visitorPickerApplyTemplate")})]})}),q&&e.jsx("div",{className:"mdocs-visitor-picker-error",role:"alert",children:q}),e.jsx("div",{style:{padding:"8px 18px 12px"},children:e.jsx(re,{visitors:m,loadState:E,searchFilter:J,onSearchChange:F,selectedIds:P,onToggle:X,selectedRows:Q,lockedIds:t,myVisitorId:g,showPermissionSelect:u,permissionOptions:N,onPermissionChange:Y})}),e.jsxs("footer",{className:"mdocs-visitor-picker-footer",children:[e.jsx("button",{type:"button",className:"secondary",onClick:j,children:i("cancel")}),e.jsx("button",{type:"button",className:"primary",onClick:()=>{if(E!=="ok"){I(i("loading"));return}_()},children:i(K?"saving":"visitorPickerConfirm")})]})]})}):null}export{ie as M,ne as V,re as a};
|