@hanfang5057/co-space 0.1.10 → 0.1.12
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/dist/package.json +1 -1
- package/dist/web/app.js +1 -1
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/web/app.js
CHANGED
|
@@ -690,7 +690,7 @@ ${a.trim()}`;else return null}return n.length?n:null}function gme(e,t,n=null){le
|
|
|
690
690
|
`}):r.type==="image"?t.push({text:r.content||r.attrGet("alt")||""}):r.type==="link_open"?t.push({marker:"link",href:r.attrGet("href")}):r.type==="link_close"&&t.push({marker:"link",close:!0});return t}function Rme(e,t,n=0){return{type:t,level:n,runs:YC(e.children)}}function Mme(e){let t=Dme.parse(String(e??""),{}),n=[];for(let r=0;r<t.length;r++){let a=t[r];if(a.type==="heading_open"||a.type==="paragraph_open"){let o=t[++r];n.push(Rme(o,a.type==="heading_open"?"heading":"paragraph",Number(a.tag.slice(1))||0))}else if(a.type==="fence"||a.type==="code_block")n.push({type:"code",text:a.content,language:a.info.trim().split(/\s+/)[0]||""});else if(a.type==="bullet_list_open"||a.type==="ordered_list_open"){let o=[],i=[{ordered:a.type==="ordered_list_open",start:Number(a.attrGet("start"))||1,index:0}],s=null;for(;r+1<t.length;){let l=t[++r];if(l.type==="bullet_list_open"||l.type==="ordered_list_open")s&&(o.push(s),s=null),i.push({ordered:l.type==="ordered_list_open",start:Number(l.attrGet("start"))||1,index:0});else if(l.type==="bullet_list_close"||l.type==="ordered_list_close"){if(i.pop(),!i.length)break}else if(l.type==="list_item_open"){let u=i[i.length-1]||{ordered:!1,start:1,index:0};s={runs:[],depth:Math.max(0,i.length-1),ordered:u.ordered,number:u.start+u.index++}}else l.type==="inline"&&s?s.runs.push(...YC(l.children)):l.type==="list_item_close"&&s&&(o.push(s),s=null)}n.push({type:"list",items:o})}else if(a.type==="blockquote_open"){let o=1,i=[];for(;++r<t.length&&o;){let s=t[r];s.type==="blockquote_open"?o++:s.type==="blockquote_close"?o--:s.type==="paragraph_open"&&t[r+1]?.type==="inline"&&i.push(YC(t[++r].children))}n.push({type:"quote",paragraphs:i})}else if(a.type==="table_open"){let o=[],i=null,s=!1,l=[];for(;++r<t.length&&t[r].type!=="table_close";){let u=t[r];if(u.type==="thead_open")s=!0;else if(u.type==="tbody_open")s=!1;else if(u.type==="tr_open")i=[];else if(u.type==="th_open"||u.type==="td_open"){let c=u.attrGet("style")?.match(/text-align:\s*(left|center|right)/)?.[1]||"left";s&&l.push(c),i&&i.push({runs:[],header:s,align:c})}else u.type==="inline"&&i?.length?i[i.length-1].runs=YC(u.children):u.type==="tr_close"&&i&&(o.push(i),i=null)}n.push({type:"table",rows:o,alignments:l})}}return n}function Nme(e=[],t=[]){let n=[],r=null;return e.map(a=>{if(a.marker==="link")return r=a.close?null:a.href,"";if(a.marker){if(a.close){let s=n.lastIndexOf(a.marker);s>=0&&n.splice(s,1)}else n.push(a.marker);return""}let o=[n.includes("strong")?"<w:b/>":"",n.includes("em")?"<w:i/>":"",n.includes("strike")?"<w:strike/>":"",a.code?'<w:rStyle w:val="InlineCode"/>':"",r?'<w:color w:val="0563C1"/><w:u w:val="single"/>':""].filter(Boolean).join(""),i=String(a.text||"").split(`
|
|
691
691
|
`).map((s,l)=>`${l?"<w:r><w:br/></w:r>":""}<w:r>${o?`<w:rPr>${o}</w:rPr>`:""}<w:t xml:space="preserve">${s$(s)}</w:t></w:r>`).join("");if(r&&/^(https?:|mailto:)/i.test(r)){let s=t.find(l=>l.target===r)?.id;return s||(s=`rId${t.length+1}`,t.push({id:s,target:r})),`<w:hyperlink r:id="${s}">${i}</w:hyperlink>`}return i}).join("")}function em(e,t="Normal",n=[],r={}){return`<w:p><w:pPr>${[`<w:pStyle w:val="${t}"/>`,r.left?`<w:ind w:left="${r.left}"/>`:"",r.hanging?`<w:ind w:left="${r.left||720}" w:hanging="${r.hanging}"/>`:"",r.align?`<w:jc w:val="${r.align}"/>`:"",r.shading?`<w:shd w:val="clear" w:color="auto" w:fill="${r.shading}"/>`:"",r.borderLeft?`<w:pBdr><w:left w:val="single" w:sz="16" w:space="8" w:color="${r.borderLeft}"/></w:pBdr>`:""].filter(Boolean).join("")}</w:pPr>${Nme(e,n)}</w:p>`}function Ome(e,t){let n=Array.from({length:t},(s,l)=>Math.max(1,...e.map(u=>Array.from(u[l]?.runs||[]).reduce((c,f)=>c+String(f.text||"").length,0)))),r=Math.min(1080,Math.floor(XC/t)),a=XC-r*t,o=n.reduce((s,l)=>s+l,0),i=n.map(s=>r+Math.floor(a*s/o));return i[i.length-1]+=XC-i.reduce((s,l)=>s+l,0),i}function Pme(e,t){let n=Math.max(1,...e.rows.map(s=>s.length)),r=Ome(e.rows,n),a=r.map(s=>`<w:gridCol w:w="${s}"/>`).join(""),o='<w:tblBorders><w:top w:val="single" w:sz="4" w:color="C8D2DC"/><w:left w:val="single" w:sz="4" w:color="C8D2DC"/><w:bottom w:val="single" w:sz="4" w:color="C8D2DC"/><w:right w:val="single" w:sz="4" w:color="C8D2DC"/><w:insideH w:val="single" w:sz="4" w:color="C8D2DC"/><w:insideV w:val="single" w:sz="4" w:color="C8D2DC"/></w:tblBorders>',i=e.rows.map((s,l)=>{let u=l===0,c=Array.from({length:n},(f,d)=>{let p=s[d]||{runs:[],header:u,align:"left"},h=`<w:tcW w:w="${r[d]}" w:type="dxa"/><w:vAlign w:val="center"/>${p.header?'<w:shd w:val="clear" w:color="auto" w:fill="EAF1F8"/>':""}`,g=p.header?[{marker:"strong"},...p.runs,{marker:"strong",close:!0}]:p.runs,x=em(g,p.header?"TableHeader":"TableCell",t,{align:p.align});return`<w:tc><w:tcPr>${h}</w:tcPr>${x}</w:tc>`}).join("");return`<w:tr>${u?"<w:trPr><w:tblHeader/></w:trPr>":""}${c}</w:tr>`}).join("");return`<w:tbl><w:tblPr><w:tblW w:w="${XC}" w:type="dxa"/><w:tblLayout w:type="fixed"/>${o}<w:tblCellMar><w:top w:w="90" w:type="dxa"/><w:left w:w="110" w:type="dxa"/><w:bottom w:w="90" w:type="dxa"/><w:right w:w="110" w:type="dxa"/></w:tblCellMar></w:tblPr><w:tblGrid>${a}</w:tblGrid>${i}</w:tbl>`}function Bme(){return`<?xml version="1.0" encoding="UTF-8"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Aptos" w:hAnsi="Aptos" w:eastAsia="Microsoft YaHei"/><w:sz w:val="22"/><w:lang w:val="en-US" w:eastAsia="zh-CN"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="140" w:line="300" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style>${[1,2,3,4,5,6].map(t=>{let n=[36,30,26,24,22,22][t-1];return`<w:style w:type="paragraph" w:styleId="Heading${t}"><w:name w:val="heading ${t}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="${t===1?300:220}" w:after="120"/></w:pPr><w:rPr><w:b/><w:color w:val="${t<3?"1F2937":"374151"}"/><w:sz w:val="${n}"/></w:rPr></w:style>`}).join("")}<w:style w:type="paragraph" w:styleId="Quote"><w:name w:val="Quote"/><w:basedOn w:val="Normal"/><w:pPr><w:ind w:left="360"/><w:spacing w:before="80" w:after="160"/></w:pPr><w:rPr><w:color w:val="5B6470"/><w:i/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Code"><w:name w:val="Code"/><w:basedOn w:val="Normal"/><w:pPr><w:ind w:left="180" w:right="180"/><w:spacing w:before="60" w:after="60"/><w:shd w:val="clear" w:color="auto" w:fill="F1F3F5"/></w:pPr><w:rPr><w:rFonts w:ascii="Menlo" w:hAnsi="Menlo" w:eastAsia="Microsoft YaHei"/><w:sz w:val="19"/><w:color w:val="24292F"/></w:rPr></w:style><w:style w:type="character" w:styleId="InlineCode"><w:name w:val="Inline Code"/><w:rPr><w:rFonts w:ascii="Menlo" w:hAnsi="Menlo"/><w:shd w:val="clear" w:color="auto" w:fill="F1F3F5"/><w:color w:val="24292F"/><w:sz w:val="19"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="ListParagraph"><w:name w:val="List Paragraph"/><w:basedOn w:val="Normal"/><w:pPr><w:spacing w:after="60"/></w:pPr></w:style><w:style w:type="paragraph" w:styleId="TableHeader"><w:name w:val="Table Header"/><w:basedOn w:val="Normal"/><w:pPr><w:spacing w:after="0" w:line="260" w:lineRule="auto"/></w:pPr><w:rPr><w:b/><w:color w:val="243447"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="TableCell"><w:name w:val="Table Cell"/><w:basedOn w:val="Normal"/><w:pPr><w:spacing w:after="0" w:line="260" w:lineRule="auto"/></w:pPr></w:style></w:styles>`}function zme(e){let t=[],n=Mme(e).map(r=>r.type==="heading"?em(r.runs,`Heading${r.level}`,t):r.type==="code"?r.text.replace(/\n$/,"").split(`
|
|
692
692
|
`).map(a=>em([{text:a}],"Code",t)).join(""):r.type==="quote"?r.paragraphs.map(a=>em(a,"Quote",t,{borderLeft:"C8D2DC"})).join(""):r.type==="list"?r.items.map(a=>{let o=720*(a.depth+1),i=a.ordered?`${a.number}. `:"\u2022 ";return em([{text:i},...a.runs],"ListParagraph",t,{left:o})}).join(""):r.type==="table"?Pme(r,t):em(r.runs,"Normal",t)).join("");return{"[Content_Types].xml":'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/></Types>',"_rels/.rels":'<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>',"word/_rels/document.xml.rels":`<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rIdStyles" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>${t.map(r=>`<Relationship Id="${r.id}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="${s$(r.target)}" TargetMode="External"/>`).join("")}</Relationships>`,"word/styles.xml":Bme(),"word/document.xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><w:body>${n}<w:sectPr><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"/></w:sectPr></w:body></w:document>`}}var Fme=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Hme(e){let t=4294967295;for(let n of e)t=Fme[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function Vme(e){let t=new TextEncoder,n=[],r=[],a=0;for(let[l,u]of Object.entries(e)){let c=t.encode(l),f=typeof u=="string"?t.encode(u):u,d=Hme(f),p=new Uint8Array(30+c.length),h=new DataView(p.buffer);h.setUint32(0,67324752,!0),h.setUint16(4,20,!0),h.setUint16(6,2048,!0),h.setUint32(14,d,!0),h.setUint32(18,f.length,!0),h.setUint32(22,f.length,!0),h.setUint16(26,c.length,!0),p.set(c,30),n.push(p,f);let g=new Uint8Array(46+c.length),x=new DataView(g.buffer);x.setUint32(0,33639248,!0),x.setUint16(4,20,!0),x.setUint16(6,20,!0),x.setUint16(8,2048,!0),x.setUint32(16,d,!0),x.setUint32(20,f.length,!0),x.setUint32(24,f.length,!0),x.setUint16(28,c.length,!0),x.setUint32(42,a,!0),g.set(c,46),r.push(g),a+=p.length+f.length}let o=r.reduce((l,u)=>l+u.length,0),i=new Uint8Array(22),s=new DataView(i.buffer);return s.setUint32(0,101010256,!0),s.setUint16(8,r.length,!0),s.setUint16(10,r.length,!0),s.setUint32(12,o,!0),s.setUint32(16,a,!0),new Blob([...n,...r,i],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})}function u$(e){return Vme(zme(e))}var ZC=gr(vo(),1),c$=new WeakMap,Ume=async()=>null;function qme(e){let t=new Set,n={user:null,loaded:!1,loading:null,subscribe(r){return t.add(r),()=>{t.delete(r)}},getSnapshot(){return n.user},load(){return n.loading!==null?n.loading:n.loaded?Promise.resolve(n.user):(n.loading=e().then(r=>{n.user=r&&r.signedIn?r:null,n.loaded=!0}).catch(()=>{n.user=null,n.loaded=!0}).finally(()=>{n.loading=null;for(let r of t)r()}),n.loading)}};return n}function jme(e){let t=c$.get(e);return t||(t=qme(e),c$.set(e,t)),t}function f$(e=Ume){let t=jme(e);return(0,ZC.useEffect)(()=>{t.loaded||t.load()},[t]),(0,ZC.useSyncExternalStore)(t.subscribe,t.getSnapshot,()=>null)}function d$(e,t,n,r,a){let o=e.right,i=e.bottom-1,s=t,l=n+Math.min(24,Math.max(12,r/2)),u=s-o;if(u<=36){let g=Math.max(0,u*.45);return{x1:o,y1:i,x2:s,y2:l,d:`M ${o} ${i} C ${o+g} ${i}, ${s-g} ${l}, ${s} ${l}`}}let c=o+14,f=i+8,d=Math.max(c,Math.min(a-8,s-18)),p=(s-d)*.5,h=`M ${o} ${i} C ${o+5} ${i}, ${o+6} ${f}, ${c} ${f} L ${d} ${f} C ${d+p} ${f}, ${s-p} ${l}, ${s} ${l}`;return{x1:o,y1:i,x2:s,y2:l,d:h}}var $me=Object.freeze(["conversation.current.read","conversation.create","conversation.open","conversation.send","conversation.references.insert","conversation.references.render","workspace.list","workspace.select","identity.current.read","navigation.document.open","navigation.deepLink.register","files.export.save","files.import.choose","clipboard.write","clipboard.read","notifications.show","application.lifecycle.observe","application.window.open","application.shortcuts.register","updates.subscribe","runtime.localService.manage","runtime.localStorage.choose"]),Gme=new Set($me);function p$(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array`);let n=new Set;for(let r of e){if(typeof r!="string"||!Gme.has(r))throw new TypeError(`Unknown ${t} entry: ${String(r)}`);n.add(r)}return n}function h$(e,t=[]){if(!e||typeof e!="object")throw new TypeError("Adapter declaration is required");if(typeof e.id!="string"||!/^[a-z][a-z0-9.-]*$/.test(e.id))throw new TypeError("Adapter id must be a lowercase identifier");if(typeof e.version!="string"||e.version.length===0)throw new TypeError("Adapter version is required");if(e.contractVersion!==1)throw new TypeError(`Unsupported adapter contract version: ${e.contractVersion}`);let n=p$(e.capabilities,"declared capability"),r=p$(t,"runtime capability");return Object.freeze({id:e.id,version:e.version,contractVersion:e.contractVersion,declared:Object.freeze([...n]),available:Object.freeze([...n].filter(a=>r.has(a)))})}function tm(e,t){return Array.isArray(e?.available)&&e.available.includes(t)}function m$(e){return`\u8BF7\u901A\u8FC7 CoSpace MCP \u8BFB\u53D6\u6587\u6863\u5F15\u7528 ${e}\uFF0C\u4EC5\u6839\u636E\u5DF2\u63A5\u53D7\u7684\u6B63\u6587\u81EA\u4E3B\u5BA1\u9605\u5E76\u63D0\u4EA4\u5177\u4F53\u4FEE\u6539\u5EFA\u8BAE\u3002\u6B64\u64CD\u4F5C\u4E0D\u662F\u6309\u8BC4\u8BBA\u4FEE\u6539\uFF1A\u4E0D\u8981\u628A\u8BC4\u8BBA\u5F53\u4F5C\u4FEE\u6539\u6307\u4EE4\uFF0C\u4E0D\u8981\u5904\u7406\u6216\u5B8C\u6210\u8BC4\u8BBA\uFF0C\u4E5F\u4E0D\u8981\u628A\u5BA1\u9605\u8303\u56F4\u6269\u5C55\u5230\u8BC4\u8BBA\u8981\u6C42\u4E4B\u5916\u3002\u4E0D\u8981\u76F4\u63A5\u8986\u76D6\u5DF2\u63A5\u53D7\u5185\u5BB9\uFF1B\u6240\u6709\u4FEE\u6539\u4EE5\u5EFA\u8BAE\u63D0\u4EA4\uFF0C\u7B49\u5F85\u6211\u5728 CoSpace \u4E2D\u63A5\u53D7\u6216\u62D2\u7EDD\u3002\u4E0D\u8981\u66FF\u6211\u53D1\u9001\u8BC4\u8BBA\u3002`}function g$(e,t){let n=[...new Set(t)];return`${e}
|
|
693
|
-
\u8BF7\u901A\u8FC7 CoSpace MCP \u6309\u8BC4\u8BBA\u63D0\u51FA\u4FEE\u6539\u5EFA\u8BAE\uFF0C\u53EA\u5904\u7406\u4EE5\u4E0B\u8BC4\u8BBA ID\uFF1A${n.join("\u3001")}\u3002\u8C03\u7528 space_document_read \u8BFB\u53D6\u6B63\u6587\u548C\u8FD9\u4E9B\u8BC4\u8BBA\u7684\u5F15\u7528\u6587\u672C\u3001\u951A\u70B9\u53CA\u6B63\u6587\uFF1B\u9010\u6761\u7406\u89E3\u8BC4\u8BBA\uFF0C\u5E76\u5BF9\u6BCF\u6761\u660E\u786E\u4E14\u53EF\u5B9A\u4F4D\u7684\u4FEE\u6539\u8981\u6C42\u63D0\u4EA4\u5BF9\u5E94\u7684\u5177\u4F53\u5EFA\u8BAE\u3002\u4E0D\u8981\u53EA\u590D\u8FF0\u6216\u5206\u7C7B\u8BC4\u8BBA\uFF0C\u4E5F\u4E0D\u8981\u5728\u8BC4\u8BBA\u8981\u6C42\u4E4B\u5916\u81EA\u4E3B\u5BA1\u9605\u6216\u589E\u52A0\u5EFA\u8BAE\u3002\u8BC4\u8BBA\u542B\u7CCA\u6216\u65E0\u6CD5\u5B89\u5168\u5B9A\u4F4D\u65F6\uFF0C\u8BF4\u660E\u539F\u56E0\u5E76\u8BE2\u95EE\uFF0C\u4E0D\u8981\u731C\u6D4B\u3002\u5B8C\u6210\u540E\u8C03\u7528 space_comment_complete\uFF0C\u4E3A\u6BCF\u6761\u5DF2\u5904\u7406\u8BC4\u8BBA\u5173\u8054\u5BF9\u5E94\u5EFA\u8BAE ID\uFF1B\u672A\u5904\u7406\u7684\u8BC4\u8BBA\u4F20\u7A7A suggestionIds\uFF0C\u4F7F\u5176\u4FDD\u6301\u5F85\u5904\u7406\u3002\u4E0D\u8981\u76F4\u63A5\u8986\u76D6\u5DF2\u63A5\u53D7\u5185\u5BB9\uFF1B\u6240\u6709\u4FEE\u6539\u4EE5\u5EFA\u8BAE\u63D0\u4EA4\uFF0C\u7B49\u5F85\u6211\u5728 CoSpace \u4E2D\u63A5\u53D7\u6216\u62D2\u7EDD\u3002\u4E0D\u8981\u66FF\u6211\u53D1\u9001\u8BC4\u8BBA\u3002`}var A=gr(Nf(),1);var lb=()=>globalThis.crypto.randomUUID();function x$({label:e,value:t,options:n,onChange:r}){let[a,o]=(0,ae.useState)(!1),i=(0,ae.useRef)(null);(0,ae.useEffect)(()=>{if(!a)return;let l=u=>{i.current?.contains(u.target)||o(!1)};return document.addEventListener("pointerdown",l),()=>document.removeEventListener("pointerdown",l)},[a]);let s=n.findIndex(l=>l.value===t);return(0,A.jsxs)("div",{className:"space-home-select",ref:i,children:[(0,A.jsxs)("button",{type:"button",className:"space-home-select-trigger","aria-label":e,"aria-haspopup":"listbox","aria-expanded":a,onClick:()=>o(l=>!l),onKeyDown:l=>{if(l.key==="Escape"){o(!1);return}if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();let u=l.key==="ArrowDown"?1:-1;r(n[(s+u+n.length)%n.length].value)}},children:[(0,A.jsx)("span",{children:n[s]?.label}),(0,A.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",children:(0,A.jsx)("path",{d:"m4 6 4 4 4-4"})})]}),a&&(0,A.jsx)("div",{className:"space-home-select-menu",role:"listbox","aria-label":e,children:n.map(l=>(0,A.jsxs)("button",{type:"button",role:"option","aria-selected":t===l.value,onClick:()=>{r(l.value),o(!1)},children:[l.label,t===l.value&&(0,A.jsx)("span",{"aria-hidden":"true",children:"\u2713"})]},l.value))})]})}function w$(e,t,n){if(!e)return!1;if(LR(e,t,t,n))return!0;let r=e.closest(".space-paper-wrap");if(!r)return!1;let a=n.length?Math.max(0,Math.min(1,t/n.length)):0;return r.scrollTo({top:Math.max(0,e.offsetTop+e.offsetHeight*a-r.clientHeight*.3),behavior:"auto"}),!0}var b$={pending:"status.pending",sending:"status.sending",sent:"status.sent",failed:"status.failed",unknown:"status.unknown",processed:"status.processed"},y$={pending:"suggestion.pendingStatus",accepted:"suggestion.acceptedStatus",rejected:"suggestion.rejectedStatus",conflicted:"suggestion.conflictedStatus"};var Wme=(e,t)=>{let n=e.updatedAt||e.createdAt;if(!n||!Number.isFinite(Date.parse(n)))return t("home.timeUnknown");let r=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n));return t(e.updatedAt?"home.updated":"home.created",{time:r})},ub=(e,t)=>J4(Z4,e,t),k$=typeof __COSPACE_BUILD_VERSION__>"u"?"development":__COSPACE_BUILD_VERSION__,Kme=k$.split("+",1)[0];function Xme({className:e=""}){return(0,A.jsx)("img",{className:e,src:Y4,alt:"","aria-hidden":"true"})}function Yme({size:e=14}){return(0,A.jsx)(ws,{size:e,strokeWidth:1.8,"aria-hidden":"true"})}function Zme({size:e=15}){return(0,A.jsx)(Hd,{size:e,strokeWidth:1.8,"aria-hidden":"true"})}function Jme({label:e,children:t,...n}){return(0,A.jsx)("button",{type:"button","aria-label":e,title:e,...n,children:t})}function Qme({exporting:e,onExport:t,onReview:n,onPreferences:r,canExport:a,t:o}){let[i,s]=(0,ae.useState)(!1),l=(0,ae.useRef)(null),u=(0,ae.useRef)(null),c=(0,ae.useId)();(0,ae.useEffect)(()=>{if(!i)return;let d=h=>{l.current?.contains(h.target)||s(!1)},p=h=>{h.key==="Escape"&&(s(!1),u.current?.focus())};return document.addEventListener("pointerdown",d),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",d),document.removeEventListener("keydown",p)}},[i]);let f=d=>{s(!1),d?.()};return(0,A.jsxs)("div",{className:"space-tools-menu",ref:l,children:[(0,A.jsx)("button",{ref:u,type:"button",className:"space-tools-menu-trigger","aria-label":o("toolbar.more"),title:o("toolbar.more"),"aria-haspopup":"true","aria-expanded":i,"aria-controls":c,onClick:()=>s(d=>!d),children:(0,A.jsx)(Fl,{size:19,"aria-hidden":"true"})}),i&&(0,A.jsxs)("div",{id:c,className:"space-tools-menu-panel",children:[n&&(0,A.jsx)("button",{type:"button",onClick:()=>f(n),children:"\u8BA9 Agent \u5BA1\u9605"}),r&&(0,A.jsx)("button",{type:"button",onClick:()=>f(r),children:o("collab.open")}),a&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"space-tools-menu-divider",role:"separator"}),(0,A.jsx)("p",{children:o("export.button")}),(0,A.jsxs)("button",{type:"button",disabled:e,onClick:()=>f(()=>t("md")),children:["Markdown ",(0,A.jsx)("span",{children:".md"})]}),(0,A.jsxs)("button",{type:"button",disabled:e,onClick:()=>f(()=>t("docx")),children:["Word ",(0,A.jsx)("span",{children:".docx"})]})]})]})]})}function nm({open:e,onClose:t,labelledBy:n,title:r,closeLabel:a,className:o="",closeOnBackdrop:i=!1,actions:s,children:l}){let u=(0,ae.useRef)(null),c=(0,ae.useRef)(t);return c.current=t,(0,ae.useEffect)(()=>{if(!e||typeof document>"u")return;let f=u.current,d=document.activeElement,p=document.body.style.overflow;document.body.style.overflow="hidden";let h=()=>[...f.querySelectorAll('button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),a[href],[tabindex]:not([tabindex="-1"])')];(f.querySelector("[autofocus]")||h()[0]||f).focus();let x=m=>{if(m.key==="Escape"){m.preventDefault(),c.current?.();return}if(m.key!=="Tab")return;let y=h();if(!y.length){m.preventDefault(),f.focus();return}let b=y[0],v=y.at(-1);m.shiftKey&&(document.activeElement===b||document.activeElement===f)?(m.preventDefault(),v.focus()):!m.shiftKey&&document.activeElement===v&&(m.preventDefault(),b.focus())};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x),document.body.style.overflow=p,d instanceof HTMLElement&&d.isConnected&&d.focus()}},[e]),!e||typeof document>"u"?null:(0,A.jsx)("div",{className:"space-dialog-backdrop",onMouseDown:f=>{i&&f.target===f.currentTarget&&t()},children:(0,A.jsxs)("section",{ref:u,className:`space-dialog ${o}`,role:"dialog","aria-modal":"true","aria-labelledby":n,tabIndex:-1,onMouseDown:f=>f.stopPropagation(),children:[(0,A.jsxs)("header",{className:"space-dialog-header",children:[(0,A.jsx)("h2",{id:n,children:r}),(0,A.jsx)("button",{type:"button",className:"space-dialog-close","aria-label":a,onClick:()=>c.current?.(),children:(0,A.jsx)(Ud,{size:17,"aria-hidden":"true"})})]}),(0,A.jsx)("div",{className:"space-dialog-content",children:l}),s&&(0,A.jsx)("footer",{className:"space-dialog-actions",children:s})]})})}function ege(e,t,n,r=ub,a=null,o=null){let i=a?.conversation||null,[s,l]=(0,ae.useState)(null),[u,c]=(0,ae.useState)([]),[f,d]=(0,ae.useState)(null),[p,h]=(0,ae.useState)(null),[g,x]=(0,ae.useState)(""),[m,y]=(0,ae.useState)(null),[b,v]=(0,ae.useState)(1),[w,k]=(0,ae.useState)(!1),[_,E]=(0,ae.useState)(""),[M,S]=(0,ae.useState)(!1),[U,N]=(0,ae.useState)(""),[q,ie]=(0,ae.useState)(null),[fe,he]=(0,ae.useState)(!1),xe=(0,ae.useRef)(null),Ce=(0,ae.useRef)(new Map),Fe=(0,ae.useRef)(new Map),D=(0,ae.useRef)(0),st=(0,ae.useRef)(null),Ke=(0,ae.useRef)(null),T=(0,ae.useRef)(!1),at=(0,ae.useRef)(r);at.current=r;let yt=(0,ae.useCallback)(($,te={})=>e($,te),[e]);(0,ae.useEffect)(()=>{v(1)},[t]);let Ut=(0,ae.useCallback)(async $=>{let te=++D.current,le=await yt("readDocument",{docId:$});if(te!==D.current)return;$===o&&(S(!0),ie(le?.version??null),he(!1));let me=le?.comments||[],P=JSON.stringify(le),G=!Ke.current||Ke.current.content!==le?.content||Ke.current.version!==le?.version;Ke.current?.signature!==P&&(l(le),c(me)),Ke.current={signature:P,content:le?.content,version:le?.version},G&&y(null),le?.title&&i$($,le.title,e)},[yt,o]);(0,ae.useEffect)(()=>{if(S(!1),ie(null),he(!1),st.current=null,!t){D.current++,Ke.current=null,l(null),c([]),d(null),h(null),y(null),x(""),E("");return}Ke.current=null,l(null),E(""),Ut(t).catch($=>E(ks($,at.current)))},[t,Ut]),(0,ae.useEffect)(()=>()=>{D.current++},[]),(0,ae.useEffect)(()=>{T.current=w},[w]),(0,ae.useEffect)(()=>{if(!t)return;let $=!1,te=()=>{$||document.visibilityState==="hidden"||T.current||Ut(t).catch(()=>{})},le=setInterval(te,2500);return document.addEventListener("visibilitychange",te),()=>{$=!0,clearInterval(le),document.removeEventListener("visibilitychange",te)}},[t,Ut]);let ln=(0,ae.useMemo)(()=>[...s?.suggestions||[]].sort(($,te)=>($.from??0)-(te.from??0)),[s]),mt=!!s&&!ln.some($=>["pending","conflicted"].includes($.status))&&!u.some($=>["pending","sending","failed","unknown"].includes($.status)),be=$=>b$[$.status]?r(b$[$.status]):$.status,Tt=$=>{h(null),d($);let te=s?.suggestions?.find(le=>le.id===$);(!te||!w$(xe.current,te.from,s?.content||""))&&E(r("suggestion.unavailable"))},Dt=$=>{h(null),d($),Ce.current.get($)?.scrollIntoView({block:"nearest",behavior:"auto"})},vt=async $=>{k(!0),E("");try{return await $()}catch(te){return E(ks(te,at.current)),null}finally{k(!1)}},I=($,te)=>vt(async()=>{await yt("decide",{docId:t,suggestionId:$,decision:te,operationId:lb()}),await Ut(t)}),R=()=>{if(!mt){E(r("edit.unavailable"));return}E(""),N(""),y(null),ie(s.version),he(!1),S(!0)},z=()=>vt(async()=>{if(q===null)throw Object.assign(new Error(r("edit.unavailable")),{code:"EDIT_REQUIRES_UNANNOTATED_DOCUMENT"});let $=st.current?.getMarkdown(),te=fe&&typeof $=="string"&&$!==s?.content;if(te)try{await yt("updateDocument",{docId:t,baseVersion:q,content:$,operationId:lb()})}catch(le){throw N(ks(le,at.current)),le}return S(!1),ie(null),he(!1),st.current=null,N(""),te&&await Ut(t),!0}),ne=()=>{N(""),E("")},j=()=>vt(async()=>{if(!m||!g.trim())throw Error(r("comment.required"));let $=await yt("createComment",{docId:t,quote:m.quote,body:g.trim(),anchor:{from:m.from,to:m.to,version:m.version}});return x(""),await Ut(t),h($.id),$}),W=tm(a?.capabilities,"clipboard.write")&&typeof a?.clipboard?.writeText=="function",Y=tm(a?.capabilities,"conversation.send"),se=tm(a?.capabilities,"conversation.create")&&i?.canCreate===!0;return{doc:s,setDoc:l,comments:u,active:f,setActive:d,activeComment:p,setActiveComment:h,draft:g,setDraft:x,selection:m,setSelection:y,zoom:b,setZoom:v,busy:w,message:_,setMessage:E,surface:xe,cardRefs:Ce,commentRefs:Fe,reload:Ut,suggestions:ln,statusText:be,chooseCard:Tt,chooseFromText:Dt,decide:I,addComment:j,deleteComment:$=>vt(async()=>{await yt("deleteComment",{docId:t,commentId:$}),h(null),await Ut(t)}),send:($=n&&Y?"current":se?"new":W?"copy":"unavailable")=>vt(async()=>{let te=u.filter(me=>["pending","failed"].includes(me.status)).map(me=>me.id);if(!te.length)throw Error(r("send.none"));if($==="copy"){if(!W)throw Object.assign(new Error(r("send.clipboardUnavailable")),{code:"CLIPBOARD_UNAVAILABLE"});if(typeof a?.clipboard?.writeText!="function")throw Object.assign(new Error(r("send.clipboardUnavailable")),{code:"CLIPBOARD_UNAVAILABLE"});let me=g$(`space:${encodeURIComponent(t)}`,te);return await a.clipboard.writeText(me),E(r("send.copied")),h(null),{copied:!0}}if($!=="current"&&$!=="new")throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});if(!Y)throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});if($==="current"&&!n)throw Object.assign(new Error(r("send.noSession")),{code:"SESSION_UNAVAILABLE"});if($==="new"&&!se)throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});let le=$==="current"?n:void 0;try{if(typeof i?.send!="function")throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});let me=await i.send({intent:"process-comments",documentId:t,commentIds:te,...le?{conversationId:le}:{createConversation:!0,...n?{excludeConversationId:n}:{}},requestId:lb()});return!le&&me?.createdConversation&&me.conversationId&&typeof i?.open=="function"&&i.open(me.conversationId),me}finally{await Ut(t),h(null)}}),canCopy:W,canSend:Y,canCreate:se,canEdit:mt,editing:M,autoFocus:s?.id===o,editSaveError:U,dismissEditSaveError:ne,editorRef:st,startEditing:R,switchToReview:z,markEditDirty:()=>he(!0)}}function tge({review:e,t=ub}){let{zoom:n,setZoom:r}=e;return(0,A.jsxs)("div",{className:"space-zoom-tools",role:"group","aria-label":t("zoom.label"),children:[(0,A.jsx)("button",{type:"button","aria-label":t("zoom.out"),title:t("zoom.out"),disabled:n<=.6,onClick:()=>r(a=>Math.max(.6,Math.round((a-.1)*10)/10)),children:"\u2212"}),(0,A.jsxs)("span",{children:[Math.round(n*100),"%"]}),(0,A.jsx)("button",{type:"button","aria-label":t("zoom.in"),title:t("zoom.in"),disabled:n>=1.5,onClick:()=>r(a=>Math.min(1.5,Math.round((a+.1)*10)/10)),children:"\uFF0B"})]})}function sb(e){return e.resolved||(!e.stale&&Number.isInteger(e.anchor?.from)&&Number.isInteger(e.anchor?.to)?{from:e.anchor.from,to:e.anchor.to}:null)}function nge({name:e,avatarUrl:t}){let[n,r]=(0,ae.useState)(!1);(0,ae.useEffect)(()=>{r(!1)},[t]);let a=Array.from(e.trim())[0]?.toLocaleUpperCase()||"?";return(0,A.jsx)("span",{className:`space-annotation-avatar${t&&!n?" is-image":""}`,"aria-hidden":"true",children:t&&!n?(0,A.jsx)("img",{src:t,alt:"",loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0)}):a})}function C$({name:e,createdAt:t,fallback:n,fallbackTime:r="",avatarUrl:a=null}){let o=e||n,i=Number.isFinite(Date.parse(t))?new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t)):"";return(0,A.jsxs)("div",{className:"space-annotation-identity",children:[(0,A.jsx)(nge,{name:o,avatarUrl:a}),(0,A.jsxs)("span",{className:"space-annotation-byline",children:[(0,A.jsx)("strong",{children:o}),(i||r)&&(0,A.jsx)("time",{dateTime:i?t:void 0,children:i||r})]})]})}function v$({comment:e,author:t,active:n,busy:r,t:a,statusText:o,confirming:i,onAskDelete:s,onConfirmDelete:l,onCancelDelete:u,onActivate:c,setRef:f,style:d,className:p="",onPointerEnter:h,onPointerLeave:g}){let x=e.status,m=r||e.status==="sending",y=e.status==="pending"?e.stale?a("comment.staleStatus"):null:`${o(e)}${e.stale?a("comment.stale"):""}`,b=t?.name||(t?.signedIn?a("comment.accountUser"):null);return(0,A.jsxs)("article",{className:`space-annotation-balloon space-comment-balloon${n?" is-active":""}${e.stale?" is-stale":""}${i?" is-confirming":""} ${p}`,"data-comment-id":e.id,ref:v=>f(e.id,v),style:d,onPointerEnter:h,onPointerLeave:g,onClick:()=>c(e.id),children:[(0,A.jsx)(C$,{name:b,avatarUrl:t?.avatarUrl,createdAt:e.createdAt,fallback:a("comment.author")}),y&&(0,A.jsx)("div",{className:"space-annotation-head",children:(0,A.jsx)("span",{className:`space-comment-status is-${x}`,children:y})}),(0,A.jsx)("p",{className:"space-comment-body",children:e.body}),e.processing?.suggestions?.length>0&&(0,A.jsx)("div",{className:"space-comment-processing-meta",children:a("comment.relatedSuggestions",{states:e.processing.suggestions.map(v=>y$[v.status]?a(y$[v.status]):v.status).join("\u3001")})}),(0,A.jsx)("button",{type:"button",className:"space-annotation-action space-comment-delete-icon",disabled:m,"aria-label":a("comment.delete"),title:a("comment.delete"),onClick:v=>{v.stopPropagation(),s(e.id)},children:(0,A.jsx)(ws,{size:18,strokeWidth:2,"aria-hidden":"true"})}),i&&(0,A.jsxs)("div",{className:"space-comment-footer is-confirming",onClick:v=>v.stopPropagation(),children:[(0,A.jsx)("span",{className:"space-comment-confirm-text",children:a("comment.deleteConfirm")}),(0,A.jsx)("button",{type:"button",className:"space-comment-delete is-danger",disabled:m,onClick:()=>l(e.id),children:a("comment.delete")}),(0,A.jsx)("button",{type:"button",className:"space-comment-delete",disabled:m,onClick:()=>u(),children:a("comment.cancel")})]})]})}function rge({item:e,active:t,busy:n,t:r,onActivate:a,onDecide:o,setRef:i,style:s,className:l="",onPointerEnter:u,onPointerLeave:c}){let f=e.status==="conflicted";return(0,A.jsxs)("article",{className:`space-annotation-balloon space-suggestion-balloon${t?" is-active":""}${f?" is-conflicted":""} ${l}`,"data-suggestion-card":e.id,ref:d=>i(e.id,d),style:s,onPointerEnter:u,onPointerLeave:c,onClick:a,children:[(0,A.jsxs)("div",{className:"space-suggestion-head",children:[(0,A.jsx)(C$,{name:e.author,createdAt:e.createdAt,fallback:r("suggestion.defaultAuthor"),fallbackTime:r("suggestion.unknownTime")}),!f&&(0,A.jsxs)("div",{className:"space-suggestion-actions",children:[(0,A.jsx)("button",{type:"button",className:"space-annotation-action is-accept",disabled:n,"aria-label":r("action.accept"),title:r("action.accept"),onClick:d=>{d.stopPropagation(),o("accept")},children:(0,A.jsx)(Eg,{size:18,strokeWidth:2,"aria-hidden":"true"})}),(0,A.jsx)("button",{type:"button",className:"space-annotation-action is-reject",disabled:n,"aria-label":r("action.reject"),title:r("action.reject"),onClick:d=>{d.stopPropagation(),o("reject")},children:(0,A.jsx)(Ud,{size:18,strokeWidth:2,"aria-hidden":"true"})})]})]}),(0,A.jsxs)("div",{className:"space-suggestion-change",children:[e.expected&&(0,A.jsxs)("p",{className:"is-deleted",children:[(0,A.jsxs)("strong",{children:[r("suggestion.deletedLabel"),"\uFF1A"]}),e.expected]}),e.replacement&&(0,A.jsxs)("p",{className:"is-inserted",children:[(0,A.jsxs)("strong",{children:[r("suggestion.insertedLabel"),"\uFF1A"]}),e.replacement]}),!e.expected&&!e.replacement&&(0,A.jsx)("p",{className:"is-unavailable",children:r("suggestion.unavailable")})]}),f&&(0,A.jsx)("div",{className:"space-suggestion-meta",children:(0,A.jsx)("span",{className:"space-suggestion-conflict",children:r("suggestion.conflicted")})})]})}function age({review:e,sessionId:t,adapter:n=null,t:r=ub,compact:a=!1}){let o=(0,ae.useId)(),i=(0,ae.useId)(),[s,l]=(0,ae.useState)(!1),[u,c]=(0,ae.useState)("copy"),f=e.comments.filter(k=>["pending","failed"].includes(k.status)),d=n?.conversation||null,p=e.canSend&&!!t,h=e.canCreate,g=e.canCopy;(0,ae.useEffect)(()=>{l(!1)},[e.doc?.id,t,g,h,f.length===0]);let x=e.busy||!f.length,m=!p&&!h&&g?r("send.copyHint"):void 0,y=null,b=null;try{y=t&&d?.getConversationLabel?.(t)}catch{}try{b=t&&d?.getWorkspaceLabel?.(t)}catch{}let v=()=>{c(p?"current":h?"new":g?"copy":"unavailable"),l(!0)},w=u==="copy"?"send.copyConfirm":u==="new"?"send.newSessionConfirm":"send.confirm";return!f.length||!p&&!h&&!g?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("button",{type:"button",className:`space-send ${a?"space-send-compact":"space-send-header"}`,disabled:x,title:m,onClick:v,children:[(0,A.jsx)(Hd,{size:14,"aria-hidden":"true"}),(0,A.jsx)("span",{children:r("send.action")})]}),(0,A.jsxs)(nm,{open:s,onClose:()=>l(!1),labelledBy:o,title:r("send.chooseTitle"),closeLabel:r("dialog.close"),className:"space-send-dialog",actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",autoFocus:!0,onClick:()=>l(!1),children:r("comment.cancel")}),(0,A.jsx)("button",{type:"button",className:"is-primary",disabled:e.busy||!f.length||u==="current"&&!p||u==="new"&&!h,onClick:()=>{l(!1),e.send(u)},children:r(w)})]}),children:[(0,A.jsx)("p",{children:r("send.chooseDescription",{count:f.length})}),(0,A.jsxs)("fieldset",{className:"space-send-options",children:[(0,A.jsx)("legend",{children:r("send.destination")}),(0,A.jsxs)("label",{className:"space-send-option",children:[(0,A.jsx)("input",{type:"radio",name:i,value:"current",checked:u==="current",disabled:!p,onChange:()=>c("current")}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:r("send.currentOption")}),(0,A.jsxs)("small",{className:"space-send-conversation",children:[p&&b&&(0,A.jsx)("span",{className:"space-send-workspace",children:b}),p?y||r("send.sessionId",{id:t}):r("send.currentUnavailable")]})]})]}),(0,A.jsxs)("label",{className:"space-send-option",children:[(0,A.jsx)("input",{type:"radio",name:i,value:"new",checked:u==="new",disabled:!h,onChange:()=>c("new")}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:r("send.newOption")}),(0,A.jsx)("small",{children:r(h?"send.newOptionHint":"send.newUnavailable")})]})]}),g&&(0,A.jsxs)("label",{className:"space-send-option",children:[(0,A.jsx)("input",{type:"radio",name:i,value:"copy",checked:u==="copy",onChange:()=>c("copy")}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:r("send.copyOption")}),(0,A.jsx)("small",{children:r("send.copyOptionHint")})]})]})]})]})]})}function oge(e){let t=e.filter(s=>s.caret),n=e.filter(s=>!s.caret&&s.kind!=="comment"),r=e.filter(s=>!s.caret&&s.kind==="comment").sort((s,l)=>s.top-l.top||s.height-l.height||s.left-l.left),a=[];for(let s of r){let l=a.at(-1);if(l&&Math.abs(l.top-s.top)<=1&&Math.abs(l.height-s.height)<=1&&s.left<=l.left+l.width){let u=Math.max(l.left+l.width,s.left+s.width);l.width=u-l.left,l.active=l.active||s.active,l.keys.push(s.key),s.active&&l.activeRects.push(s)}else a.push({...s,active:!1,keys:[s.key],activeRects:s.active?[s]:[]})}let o=a.map(s=>({key:`comment-fill:${s.keys.join("|")}`,kind:"comment",active:!1,left:s.left,top:s.top,width:s.width,height:s.height,caret:!1})),i=a.flatMap(s=>s.activeRects.map(l=>({...l,key:`${l.key}:active-outline`,active:!0,outline:!0})));return[...o,...n,...t,...i]}function ige({review:e,user:t=null,t:n=ub}){let[r,a]=(0,ae.useState)(!1),[o,i]=(0,ae.useState)(null),[s,l]=(0,ae.useState)(0),[u,c]=(0,ae.useState)(null),f=(0,ae.useRef)(null),[d,p]=(0,ae.useState)({positions:{},lines:[],highlights:[],height:0,minHeight:0}),h=(0,ae.useId)(),g=(0,ae.useId)(),x=(0,ae.useId)(),m=(0,ae.useRef)(null),y=(0,ae.useRef)(null),b=(0,ae.useRef)(null),v=(0,ae.useRef)(null),w=(0,ae.useRef)(null),[k,_]=(0,ae.useState)(null),{doc:E,comments:M,active:S,setActive:U,activeComment:N,setActiveComment:q,draft:ie,setDraft:fe,selection:he,setSelection:xe,zoom:Ce,busy:Fe,message:D,setMessage:st,surface:Ke,cardRefs:T,commentRefs:at,suggestions:yt,statusText:Ut,chooseCard:ln,chooseFromText:mt,decide:be,addComment:Tt,deleteComment:Dt,editing:vt,editorRef:I,markEditDirty:R}=e,z=(0,ae.useMemo)(()=>M.filter(V=>!["sent","processed"].includes(V.status)),[M]),ne=(0,ae.useMemo)(()=>z.filter(V=>sb(V)),[z]),j=(0,ae.useMemo)(()=>z.filter(V=>!sb(V)),[z]),W=yt.length>0||z.length>0,Y=(0,ae.useMemo)(()=>yt.map((V,Le)=>({kind:"suggestion",key:`suggestion:${V.id}`,id:V.id,item:V,index:Le})),[yt]),se=(0,ae.useMemo)(()=>ne.map(V=>({kind:"comment",key:`comment:${V.id}`,id:V.id,item:V})),[ne]),K=(0,ae.useMemo)(()=>[...Y,...se],[Y,se]);if((0,ae.useLayoutEffect)(()=>{let V=y.current;if(!V)return;let Le=()=>l(et=>et+1);Le();let Oe=typeof ResizeObserver=="function"?new ResizeObserver(Le):null;return Oe?.observe(V),Ke.current&&Oe?.observe(Ke.current),window.addEventListener("resize",Le),()=>{Oe?.disconnect(),window.removeEventListener("resize",Le)}},[E?.content]),(0,ae.useEffect)(()=>{if(!document.fonts?.ready)return;let V=!0;return document.fonts.ready.then(()=>{V&&l(Le=>Le+1)}),()=>{V=!1}},[]),(0,ae.useEffect)(()=>{let V=Ke.current;if(!V||!E||vt)return;let Le=typeof requestAnimationFrame=="function"?requestAnimationFrame:cn=>setTimeout(cn,0),Oe=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:clearTimeout,et=0,lt=()=>{if(et=0,r||document.activeElement?.tagName==="TEXTAREA")return;let cn=window.getSelection?.();if(!cn||cn.rangeCount===0){xe(Je=>Je&&null);return}let wt=cn.getRangeAt(0);if(wt.collapsed){xe(Je=>Je&&null);return}if(!V.contains(wt.commonAncestorContainer)){xe(Je=>Je&&null);return}try{let Je=SR(V,wt,E.content,E.version);Je&&xe(zt=>zt&&zt.from===Je.from&&zt.to===Je.to&&zt.quote===Je.quote?zt:Je)}catch{}},An=()=>{et||(et=Le(lt))};return document.addEventListener("selectionchange",An),()=>{document.removeEventListener("selectionchange",An),et&&Oe(et)}},[r,E,vt,xe,Ke]),(0,ae.useLayoutEffect)(()=>{if(!W){p($e=>$e.height===0&&!$e.lines.length&&!$e.highlights?.length&&!Object.keys($e.positions).length?$e:{positions:{},lines:[],highlights:[],height:0,minHeight:0});return}let V=b.current,Le=Ke.current,Oe=v.current;if(!V||!Le||!Oe)return;let et=V.getBoundingClientRect(),lt=Ce,An=Le.getBoundingClientRect(),cn=Oe.getBoundingClientRect(),wt=Ki(Le,E.content),Je=S!=null?`suggestion:${S}`:N!=null?`comment:${N}`:null,zt=new Map,Qn=[];for(let $e of K){let En=$e.kind==="suggestion"?{from:$e.item.from,to:$e.item.to}:sb($e.item);if(!En)continue;let fn=Mf(wt,En.from,En.to);if(!fn)continue;let yn=WC(fn.range,et).map(en=>Object.fromEntries(Object.entries(en).map(([Zo,al])=>[Zo,typeof al=="number"?al/lt:al])));if(!yn.length){let en=fn.startSpan.element.getBoundingClientRect();en&&(en.width||en.height)&&(yn=[{left:(en.left-et.left)/lt,top:(en.top-et.top)/lt,right:(en.right-et.left)/lt,bottom:(en.bottom-et.top)/lt,width:en.width/lt,height:en.height/lt}])}let Vn=yn[0];if(!Vn)continue;let Zi=yn[yn.length-1];zt.set($e.key,{left:Vn.left,right:Vn.right,top:Vn.top,bottom:Vn.bottom,height:Vn.height,end:Zi});let xo=$e.key===Je;En.from===En.to?Qn.push({key:`${$e.key}:caret`,kind:$e.kind,active:xo,left:Math.max(0,Vn.left-1),top:Vn.top,width:2,height:Math.max(Vn.height,18),caret:!0}):yn.forEach((en,Zo)=>{en.width>0&&en.height>0&&Qn.push({key:`${$e.key}:${Zo}`,kind:$e.kind,deleted:$e.kind==="suggestion"&&!!$e.item.expected,active:xo,left:en.left,top:en.top,width:en.width,height:en.height,caret:!1})})}let mr=oge(Qn),Bu=[...K].sort(($e,En)=>{let fn=zt.get($e.key)?.top??$e.item.from??0,yn=zt.get(En.key)?.top??En.item.from??0;return fn-yn||$e.key.localeCompare(En.key)}),Xi={},Yi=[],go=8;for(let $e of Bu){let En=$e.kind==="suggestion"?T.current.get($e.id):at.current.get($e.id);if(!En)continue;let fn=zt.get($e.key),yn=En.offsetHeight||0,Vn=$e.item.from??$e.item.anchor?.from??0,Zi=E.content.length?Le.offsetHeight*Math.max(0,Math.min(1,Vn/E.content.length)):0,xo=Math.max(fn?.top??Zi,go);if(Xi[$e.key]=xo,go=xo+yn+10,fn){let en=d$(fn.end,(cn.left-et.left)/lt,xo,yn,(An.right-et.left)/lt);Yi.push({key:$e.key,kind:$e.kind,active:$e.key===Je,...en})}}let rl=Math.max(Le.offsetHeight,go);p($e=>JSON.stringify($e.positions)===JSON.stringify(Xi)&&JSON.stringify($e.lines)===JSON.stringify(Yi)&&JSON.stringify($e.highlights||[])===JSON.stringify(mr)&&$e.height===go&&$e.minHeight===rl?$e:{positions:Xi,lines:Yi,highlights:mr,height:go,minHeight:rl})},[W,K,yt,ne,E?.content,s,S,N,o,T,at,n,Ce]),(0,ae.useEffect)(()=>{he||a(!1)},[he]),(0,ae.useEffect)(()=>{i(null)},[M]),(0,ae.useEffect)(()=>(c(null),()=>{clearTimeout(f.current),f.current=null}),[E?.id]),(0,ae.useLayoutEffect)(()=>{let V=w.current,Le=Ke.current;if(!he||r||Fe||!V||!Le)return;let Oe={contextElement:Le,getBoundingClientRect(){let cn=Mf(Ki(Le,E?.content),he.from,he.to);if(cn)return cn.range.getBoundingClientRect?.()||Le.getBoundingClientRect();let wt=Le.closest(".space-paper-wrap"),Je=wt?.getBoundingClientRect(),zt=he.anchor;if(Je&&zt){let Qn=Je.left+zt.x-wt.scrollLeft,mr=Je.top+zt.top-wt.scrollTop;return{x:Qn,y:mr,left:Qn,right:Qn,top:mr,bottom:Je.top+zt.bottom-wt.scrollTop,width:1,height:Math.max(1,zt.bottom-zt.top)}}return Le.getBoundingClientRect()}},et=!0,An=Sg(Oe,V,()=>zr(Oe,V,{placement:"top",middleware:[Pa(10),zl(),xv({padding:8})]}).then(({x:cn,y:wt})=>{et&&_({left:cn,top:wt})}).catch(()=>{}));return()=>{et=!1,An()}},[he,r,Fe,Ke,s,Ce,E?.content]),!E)return(0,A.jsx)("section",{className:"space-paper-wrap",children:(0,A.jsx)("p",{className:"space-loading",role:"status",children:e.message||n("empty.loading")})});let Z=()=>{st(""),a(!0)},$=()=>{a(!1),st("")},te=async()=>{await Tt()&&(a(!1),st(""),xe(null))},le=V=>i(V),me=async V=>{await Dt(V),i(null)},P=V=>{let Le=ne.find(Oe=>Oe.id===V);if(Le){let Oe=sb(Le);w$(Ke.current,Oe.from,E.content)}},G=V=>{U(null),q(V),at.current.get(V)?.scrollIntoView({block:"nearest",inline:"nearest",behavior:"auto"})},de=V=>{U(null),q(V),P(V)},ve=V=>{q(null),U(V),ln(V)},oe=()=>{clearTimeout(f.current),f.current=null},ce=()=>{f.current===null&&(f.current=setTimeout(()=>{f.current=null,c(null)},180))},Ee=V=>{let Le=V.target?.closest?.("[data-suggestion-id]")?.getAttribute("data-suggestion-id"),Oe=Le==null?null:Y.find(wt=>String(wt.id)===Le);if(Oe){oe(),c(wt=>wt?.key===Oe.key?wt:{key:Oe.key,left:V.clientX,top:V.clientY});return}let et=document.caretRangeFromPoint?.(V.clientX,V.clientY),lt=et?{node:et.startContainer,offset:et.startOffset}:document.caretPositionFromPoint?.(V.clientX,V.clientY);if(!lt){ce();return}let An=Zj(Ke.current,lt.node||lt.offsetNode,lt.offset,E.content);if(!Number.isInteger(An)){ce();return}let cn=K.find(wt=>{let Je=wt.kind==="suggestion"?{from:wt.item.from,to:wt.item.to}:sb(wt.item);return Je&&(Je.from===Je.to?An===Je.from:An>=Je.from&&An<=Je.to)});cn?(oe(),c(wt=>wt?.key===cn.key?wt:{key:cn.key,left:V.clientX,top:V.clientY})):ce()},tt=V=>{let Le=V.target?.closest?.("a[href]");if(!Le||!Ke.current?.contains(Le))return;let Oe=Le.getAttribute("href")?.trim();if(!Oe)return;let et;try{et=new URL(Oe,window.location.href)}catch{V.preventDefault();return}let lt=new URL(window.location.href);if(Oe.startsWith("#")&&et.origin===lt.origin&&et.pathname===lt.pathname&&et.search===lt.search)return;if(["http:","https:","mailto:","tel:"].includes(et.protocol)){Le.target="_blank",Le.rel="noopener noreferrer";return}let An=adapter.navigation?.parseDocumentLink?.(Oe);if(An){V.preventDefault(),adapter.navigation?.openDocument?.(An);return}V.preventDefault()},un=he?.anchor,Et=(un?.top||0)<60,Qt=Math.max(40,Math.min(un?.x||0,(un?.wrapWidth||120)-40));return(0,A.jsxs)("section",{className:`space-paper-wrap${vt?" is-editing":""}`,"aria-label":n("paper.aria"),ref:y,children:[(0,A.jsxs)("div",{className:`space-doc-stage${W?" has-annotations":""}`,ref:b,style:{zoom:Ce},children:[(0,A.jsx)("div",{ref:Ke,onClickCapture:tt,onPointerMove:vt?void 0:Ee,onPointerLeave:ce,className:`space-paper${E.content.replace(/^# [^\r\n]*(?:\r?\n)+/,"").trim()?"":" is-empty"}`,tabIndex:-1,children:(0,A.jsx)(t$,{markdown:E.content,editorRef:I,onChange:R,onDecorationsReady:()=>l(V=>V+1),t:n,readOnly:!vt,autoFocus:e.autoFocus,suggestions:yt},vt?"edit":`review-${E.version}`)}),(0,A.jsx)("div",{className:"space-anchor-layer","aria-hidden":"true",children:d.highlights?.map(V=>(0,A.jsx)("span",{className:`space-anchor-rect is-${V.kind}${V.deleted?" is-deleted":""}${V.active?" is-active":""}${V.caret?" is-caret":""}${V.outline?" is-outline":""}`,style:{left:V.left,top:V.top,width:V.width,height:V.height}},V.key))}),W&&(0,A.jsxs)("aside",{className:"space-comment-rail",ref:v,"aria-label":n("annotations.title"),style:{minHeight:d.minHeight||void 0},children:[(0,A.jsx)("div",{className:"space-comment-spacer",style:{height:d.height||0}}),(0,A.jsxs)("div",{className:"space-comment-balloons is-positioned",children:[Y.map(V=>(0,A.jsx)(rge,{item:V.item,index:V.index,active:S===V.item.id,busy:Fe,t:n,onActivate:()=>ve(V.item.id),onDecide:Le=>be(V.item.id,Le),onPointerEnter:oe,onPointerLeave:ce,setRef:(Le,Oe)=>{Oe?T.current.set(Le,Oe):T.current.delete(Le)},style:{top:d.positions[V.key],visibility:d.positions[V.key]===void 0?"hidden":void 0,...u?.key===V.key?{"--hover-x":`${u.left}px`,"--hover-y":`${u.top}px`}:{}},className:u?.key===V.key?"is-hover-preview":""},V.key)),ne.map(V=>(0,A.jsx)(v$,{comment:V,author:t,active:N===V.id,busy:Fe,t:n,statusText:Ut,confirming:o===V.id,onAskDelete:le,onConfirmDelete:me,onCancelDelete:()=>i(null),onActivate:de,onPointerEnter:oe,onPointerLeave:ce,setRef:(Le,Oe)=>{Oe?at.current.set(Le,Oe):at.current.delete(Le)},style:{top:d.positions[`comment:${V.id}`],visibility:d.positions[`comment:${V.id}`]===void 0?"hidden":void 0,...u?.key===`comment:${V.id}`?{"--hover-x":`${u.left}px`,"--hover-y":`${u.top}px`}:{}},className:u?.key===`comment:${V.id}`?"is-hover-preview":""},V.id))]}),j.length>0&&(0,A.jsxs)("section",{className:"space-comment-stale","aria-label":n("comment.staleGroup"),children:[(0,A.jsx)("h3",{children:n("comment.staleGroup")}),(0,A.jsx)("p",{className:"space-muted",children:n("comment.staleHint")}),j.map(V=>(0,A.jsx)(v$,{comment:V,author:t,active:N===V.id,busy:Fe,t:n,statusText:Ut,confirming:o===V.id,onAskDelete:le,onConfirmDelete:me,onCancelDelete:()=>i(null),onActivate:()=>{},setRef:(Le,Oe)=>{Oe?at.current.set(Le,Oe):at.current.delete(Le)}},V.id))]})]}),d.lines.length>0&&(0,A.jsx)("svg",{className:"space-comment-lines","aria-hidden":"true",children:d.lines.map(V=>(0,A.jsxs)("g",{className:V.active?"is-active":void 0,children:[(0,A.jsx)("path",{pathLength:"1",className:`space-connector-line ${V.kind==="suggestion"?"is-suggestion":"is-comment"}`,d:V.d}),(0,A.jsx)("circle",{className:`space-connector-dot is-origin ${V.kind==="suggestion"?"is-suggestion":"is-comment"}`,cx:V.x1,cy:V.y1,r:"2"}),(0,A.jsx)("circle",{className:`space-connector-dot is-target ${V.kind==="suggestion"?"is-suggestion":"is-comment"}`,cx:V.x2,cy:V.y2,r:"4"})]},V.key))})]}),(0,A.jsxs)("div",{className:"space-comment-layer",children:[he&&!r&&!Fe&&(0,A.jsxs)("button",{ref:w,type:"button",className:`space-comment-fab${!k&&Et?" is-below":""}${k?" is-positioned":""}`,style:k||{left:Qt,top:Et?(un?.bottom||0)+10:(un?.top||0)-10},onMouseDown:V=>V.preventDefault(),onClick:Z,"aria-haspopup":"dialog","aria-label":n("comment.bubble"),children:[(0,A.jsx)(Zme,{}),(0,A.jsx)("span",{children:n("comment.bubble")})]}),(0,A.jsx)(nm,{open:!!(he&&r),onClose:()=>{a(!1),st("")},labelledBy:g,title:n("comment.addTitle"),closeLabel:n("dialog.close"),className:"space-comment-dialog",actions:he&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",onClick:$,children:n("comment.cancel")}),(0,A.jsx)("button",{type:"button",className:"is-primary",disabled:Fe||!ie.trim(),onClick:te,children:n("comment.save")})]}),children:he&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("p",{className:"space-comment-selected",children:n("comment.selected",{quote:he.quote})}),(0,A.jsx)("label",{htmlFor:h,children:n("comment.label")}),(0,A.jsx)("textarea",{ref:m,autoFocus:!0,id:h,rows:"4",maxLength:"4000",value:ie,onChange:V=>{fe(V.target.value),D&&st("")},onKeyDown:V=>{(V.metaKey||V.ctrlKey)&&V.key==="Enter"&&(V.preventDefault(),!Fe&&ie.trim()&&te())}}),D&&(0,A.jsx)("p",{className:"space-comment-error",role:"alert",children:D})]})}),(0,A.jsxs)(nm,{open:!!e.editSaveError,onClose:e.dismissEditSaveError,labelledBy:x,title:n("edit.saveErrorTitle"),closeLabel:n("dialog.close"),className:"space-comment-dialog",actions:(0,A.jsx)("button",{type:"button",autoFocus:!0,onClick:e.dismissEditSaveError,children:n("edit.keepEditing")}),children:[(0,A.jsx)("p",{role:"alert",children:e.editSaveError}),(0,A.jsx)("p",{className:"space-muted",children:n("edit.saveErrorKeepEditing")})]}),r&&he?.rects?.map((V,Le)=>(0,A.jsx)("span",{className:"space-selection-hint",style:{left:V.left,top:V.top,width:V.width,height:V.height}},Le))]})]})}function S$({adapter:e,t=ub}){let n=e.conversation?.current?.id||null,r=e.core.request,[a,o]=(0,ae.useState)([]),[i,s]=(0,ae.useState)(null),[l,u]=(0,ae.useState)(""),[c,f]=(0,ae.useState)(!1),[d,p]=(0,ae.useState)(null),[h,g]=(0,ae.useState)(""),[x,m]=(0,ae.useState)("all"),[y,b]=(0,ae.useState)("recent"),[v,w]=(0,ae.useState)(null),[k,_]=(0,ae.useState)(!1),[E,M]=(0,ae.useState)(null),[S,U]=(0,ae.useState)(""),[N,q]=(0,ae.useState)("document"),[ie,fe]=(0,ae.useState)(""),[he,xe]=(0,ae.useState)("idle"),[Ce,Fe]=(0,ae.useState)(!1),[D,st]=(0,ae.useState)(!1),[Ke,T]=(0,ae.useState)(null),[at,yt]=(0,ae.useState)(!1),Ut=(0,ae.useId)(),ln=(0,ae.useId)(),mt=f$(e.identity?.getCurrentUser),be=ege(r,i,n,t,e,d),Tt=(0,ae.useRef)(t);Tt.current=t;let Dt=(0,ae.useCallback)((oe,ce={})=>r(oe,ce),[r]),vt=(0,ae.useRef)(null),I=(0,ae.useCallback)(async()=>{let oe=await Dt("listDocuments"),ce=JSON.stringify(oe);return ce!==vt.current&&(vt.current=ce,o(oe)),oe},[Dt]);(0,ae.useEffect)(()=>{let oe=!1;return I().catch(ce=>{oe||u(ks(ce,Tt.current))}),()=>{oe=!0}},[I]),(0,ae.useEffect)(()=>{if(i)return;let oe=!1,ce=()=>{!oe&&document.visibilityState!=="hidden"&&I().catch(()=>{})},Ee=setInterval(ce,4e3);return document.addEventListener("visibilitychange",ce),()=>{oe=!0,clearInterval(Ee),document.removeEventListener("visibilitychange",ce)}},[i,I]);let R=async()=>{f(!0),u("");try{let oe=await Dt("createDocument",{title:t("document.untitled"),operationId:lb()});await I(),p(oe.id),s(oe.id)}catch(oe){u(ks(oe,t))}finally{f(!1)}},z=async()=>{if(v){f(!0),u("");try{await Dt("deleteDocument",{docId:v.id}),await I(),w(null),i===v.id&&s(null)}catch(oe){u(ks(oe,Tt.current))}finally{f(!1)}}},ne=async oe=>{st(!0),u("");try{let ce=await Dt("readDocument",{docId:i});if(!ce||typeof ce.content!="string")throw new Error("Document unavailable");let Ee=l$(ce.title,oe),tt=oe==="md"?{name:Ee,type:"text/markdown;charset=utf-8",bytes:new TextEncoder().encode(ce.content)}:oe==="docx"?{name:Ee,type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",bytes:new Uint8Array(await u$(ce.content).arrayBuffer())}:null;if(!tt||!tm(e.capabilities,"files.export.save")||typeof e.files?.saveExport!="function")throw new Error("Export saving is unavailable");if(await e.files.saveExport(tt)!==!0)throw new Error("Export saving was not accepted")}catch{u(t("export.failed"))}finally{st(!1)}},j=async oe=>{M(null),U(""),q(oe),fe(""),xe("idle"),_(!0),Fe(!0);try{let ce=await Dt("readCollaboration",{docId:oe==="document"?i:void 0});M(ce),fe((oe==="global"?ce.global:ce.document)?.content||"")}catch(ce){U(ce?.code==="METHOD_NOT_FOUND"?t("collab.backendOutdated"):ks(ce,t))}finally{Fe(!1)}},W=(0,ae.useCallback)(async oe=>{let ce=N==="global"?E?.global:E?.document;xe("saving");try{await Dt("saveInstructions",{scope:N,docId:N==="document"?i:void 0,content:oe,baseVersion:ce?.version||0,operationId:lb()});let Ee=await Dt("readCollaboration",{docId:N==="document"?i:void 0});M(Ee),xe("saved")}catch(Ee){U(Ee?.code==="METHOD_NOT_FOUND"?t("collab.backendOutdated"):ks(Ee,t)),xe("error")}},[Dt,i,N,E,t]),Y=async()=>{await W(ie)},se=()=>{_(!1)},K=async()=>{be.editing&&!await be.switchToReview()||s(null)},Z=be.comments.filter(oe=>!["sent","processed"].includes(oe.status)),$=a.find(oe=>oe.id===i),te=Ke?Ke.docId?m$(`space:${encodeURIComponent(Ke.docId)}`):"\u8BF7\u6839\u636E\u6211\u7684\u8981\u6C42\uFF0C\u901A\u8FC7 CoSpace MCP \u521B\u5EFA\u4E00\u4EFD\u65B0\u6587\u6863\u5E76\u63D0\u4EA4\u5B8C\u6574\u521D\u7A3F\u3002":"",le=async()=>{try{await navigator.clipboard.writeText(te),yt(!0)}catch{yt(!1)}},me=a.reduce((oe,ce)=>oe+(ce.pending||0),0),P=(0,ae.useMemo)(()=>{let oe=h.trim().toLocaleLowerCase(),ce=Ee=>{let tt=Date.parse(Ee.updatedAt||Ee.createdAt||"");return Number.isFinite(tt)?tt:0};return a.filter(Ee=>(!oe||(Ee.title||Ee.id||"").toLocaleLowerCase().includes(oe))&&(x!=="pending"||Ee.pending>0)).sort((Ee,tt)=>y==="title"?(Ee.title||Ee.id||"").localeCompare(tt.title||tt.id||"",void 0,{numeric:!0}):ce(tt)-ce(Ee))},[a,h,x,y]),G=!i,de=N==="global"?E?.global:E?.document,ve=!!E&&ie!==(de?.content||"");return(0,A.jsxs)("div",{className:"space-app",children:[G?(0,A.jsxs)("main",{className:"space-home","aria-labelledby":"space-home-title",children:[(0,A.jsxs)("header",{className:"space-home-header",children:[(0,A.jsxs)("div",{className:"space-brand",children:[(0,A.jsx)(Xme,{className:"space-brand-icon"}),(0,A.jsxs)("span",{className:"space-brand-names",children:[(0,A.jsx)("strong",{children:t("brand.name")}),(0,A.jsxs)("small",{children:[t("brand.nameEnglish")," ",(0,A.jsxs)("span",{className:"space-build-version",title:t("build.versionTitle"),children:["v",Kme]})]})]})]}),(0,A.jsxs)("div",{className:"space-header-tools",children:[e.prompts&&(0,A.jsx)("button",{type:"button",className:"space-collab-trigger",onClick:()=>T({kind:"create"}),children:"\u8BA9 Agent \u8D77\u8349"}),(0,A.jsxs)("button",{type:"button",className:"space-home-new",disabled:c,onClick:R,children:[(0,A.jsx)(Vd,{size:16,"aria-hidden":"true"}),t("nav.newDocument")]})]})]}),(0,A.jsxs)("section",{className:"space-home-intro",children:[(0,A.jsxs)("div",{children:[(0,A.jsx)("p",{className:"space-home-eyebrow",children:t("home.eyebrow")}),(0,A.jsx)("h1",{id:"space-home-title",children:t("home.title")}),(0,A.jsx)("p",{className:"space-home-description",children:t("home.description")})]}),(0,A.jsxs)("div",{className:"space-home-stats","aria-label":t("nav.aria"),children:[(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:a.length}),t("home.documentCount",{count:a.length})]}),(0,A.jsx)("i",{"aria-hidden":"true"}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:me}),t("home.pendingCount",{count:me})]})]})]}),(0,A.jsxs)("section",{className:"space-home-content","aria-label":t("nav.documents"),children:[(0,A.jsxs)("div",{className:"space-home-section-title",children:[(0,A.jsx)("h2",{children:t("nav.documents")}),a.length>0&&(0,A.jsx)("span",{children:a.length})]}),a.length>0&&(0,A.jsxs)("div",{className:"space-document-tools",children:[(0,A.jsxs)("label",{className:"space-document-search",children:[(0,A.jsx)(_g,{size:16,"aria-hidden":"true"}),(0,A.jsx)("span",{className:"space-visually-hidden",children:t("home.search")}),(0,A.jsx)("input",{type:"search",value:h,onChange:oe=>g(oe.target.value),placeholder:t("home.search")})]}),(0,A.jsx)("span",{className:"space-visually-hidden",children:t("home.filter")}),(0,A.jsx)(x$,{label:t("home.filter"),value:x,onChange:m,options:[{value:"all",label:t("home.filterAll")},{value:"pending",label:t("home.filterPending")}]}),(0,A.jsx)("span",{className:"space-visually-hidden",children:t("home.sort")}),(0,A.jsx)(x$,{label:t("home.sort"),value:y,onChange:b,options:[{value:"recent",label:t("home.sortRecent")},{value:"title",label:t("home.sortTitle")}]})]}),P.length?(0,A.jsx)("div",{className:"space-home-grid",children:P.map((oe,ce)=>(0,A.jsxs)("article",{className:"space-home-card",children:[(0,A.jsxs)("button",{type:"button",className:"space-home-card-open","aria-label":t("home.openDocument",{title:oe.title||oe.id}),onClick:()=>s(oe.id),children:[(0,A.jsxs)("span",{className:`space-home-card-art is-tone-${ce%4}`,"aria-hidden":"true",children:[(0,A.jsxs)("span",{className:"space-paper-icon",children:[(0,A.jsx)("i",{}),(0,A.jsx)("i",{}),(0,A.jsx)("i",{}),(0,A.jsx)("b",{})]}),(0,A.jsx)("span",{className:"space-home-card-art-label",children:kn.name.en.toUpperCase()})]}),(0,A.jsxs)("span",{className:"space-home-card-copy",children:[(0,A.jsx)("strong",{title:oe.title||oe.id,children:oe.title||oe.id}),(0,A.jsx)("span",{className:"space-home-card-meta",children:Wme(oe,t)})]}),(0,A.jsxs)("span",{className:"space-home-card-footer",children:[oe.pending>0?(0,A.jsxs)("span",{className:"space-home-pending",children:[(0,A.jsx)("i",{"aria-hidden":"true"}),t("annotations.suggestions",{count:oe.pending})]}):(0,A.jsx)("span",{className:"space-home-clear",children:t("home.noPending")}),(0,A.jsx)("span",{className:"space-home-open-icon","aria-hidden":"true",children:"\u2197"})]})]}),(0,A.jsx)("button",{type:"button",className:"space-home-delete",disabled:c,"aria-label":t("nav.deleteDocumentLabel",{title:oe.title||oe.id}),title:t("nav.deleteDocument"),onClick:()=>w(oe),children:(0,A.jsx)(Yme,{size:15})})]},oe.id))}):a.length?(0,A.jsx)("p",{className:"space-document-no-results",role:"status",children:t("home.noResults")}):(0,A.jsxs)("div",{className:"space-home-empty",children:[(0,A.jsxs)("span",{className:"space-empty-mark","aria-hidden":"true",children:[(0,A.jsx)("span",{}),(0,A.jsx)("span",{}),(0,A.jsx)("span",{})]}),(0,A.jsx)("h2",{children:t("home.emptyTitle")}),(0,A.jsx)("p",{children:t("home.emptyDescription")}),(0,A.jsxs)("button",{type:"button",className:"space-home-new",disabled:c,onClick:R,children:[(0,A.jsx)(Vd,{size:16,"aria-hidden":"true"}),t("nav.newDocument")]})]})]}),(0,A.jsx)("div",{className:"space-message space-home-message",role:"status","aria-live":"polite",children:l})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("header",{className:"space-top space-preview-top",children:[(0,A.jsx)(Jme,{className:"space-back",label:t("home.back"),disabled:c||be.busy,onClick:K,children:(0,A.jsx)(Ag,{size:18,"aria-hidden":"true"})}),(0,A.jsxs)("div",{className:"space-preview-heading",children:[(0,A.jsxs)("span",{children:[t("home.eyebrow")," ",(0,A.jsx)("small",{className:"space-build-version",title:t("build.versionTitle"),children:k$})]}),(0,A.jsx)("h1",{title:be.doc?.title||$?.title||i,children:be.doc?.title||$?.title||i})]}),(0,A.jsxs)("div",{className:"space-header-tools",role:"group","aria-label":t("toolbar.aria"),children:[be.doc&&(0,A.jsx)(Qme,{exporting:D,onExport:ne,onReview:e.prompts?()=>T({kind:"review",docId:i}):null,onPreferences:()=>j("document"),canExport:tm(e.capabilities,"files.export.save"),t}),be.doc&&(0,A.jsxs)("div",{className:"space-toolbar-group is-view",children:[(0,A.jsxs)("div",{className:"space-mode-switch",role:"group","aria-label":t("edit.modeLabel"),children:[(0,A.jsx)("button",{type:"button","aria-pressed":!be.editing,disabled:c||be.busy,title:be.editing?t("edit.autoSaveHint"):void 0,onClick:()=>be.editing?be.switchToReview():null,children:t("edit.reviewMode")}),(0,A.jsxs)("span",{className:`space-edit-mode-option${!be.canEdit&&!be.editing?" is-unavailable":""}`,tabIndex:!be.canEdit&&!be.editing?0:void 0,"aria-describedby":!be.canEdit&&!be.editing?ln:void 0,"data-tooltip":t("edit.unavailableReason"),children:[(0,A.jsx)("button",{type:"button","aria-pressed":be.editing,disabled:c||be.busy||!be.canEdit&&!be.editing,onClick:()=>be.editing?null:be.startEditing(),children:t("edit.editMode")}),!be.canEdit&&!be.editing&&(0,A.jsx)("span",{id:ln,role:"tooltip",className:"space-edit-tooltip",children:t("edit.unavailableReason")})]})]}),(0,A.jsx)(tge,{review:be,t})]}),be.editing&&be.busy&&(0,A.jsx)("span",{className:"space-edit-status",role:"status",children:t("edit.saving")}),!be.editing&&Z.length>0&&(0,A.jsx)(age,{review:be,sessionId:n,adapter:e,t})]})]}),be.doc?(0,A.jsx)("main",{className:"space-main",children:(0,A.jsx)(ige,{review:be,user:mt,t})}):(0,A.jsx)("main",{className:"space-preview-loading","aria-live":"polite",children:be.message||t("empty.loading")})]}),!G&&(0,A.jsx)("div",{className:"space-message",role:"status","aria-live":"polite",children:be.editSaveError?"":l||(be.doc?be.message:"")}),(0,A.jsxs)(nm,{open:!!Ke,onClose:()=>{T(null),yt(!1)},labelledBy:"space-agent-prompt-title",title:"\u53D1\u9001\u7ED9 Agent \u7684\u63D0\u793A\u8BCD",closeLabel:t("dialog.close"),actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",onClick:()=>{T(null),yt(!1)},children:t("dialog.close")}),(0,A.jsx)("button",{type:"button",className:"is-primary",onClick:le,children:at?"\u5DF2\u590D\u5236":"\u590D\u5236\u63D0\u793A\u8BCD"})]}),children:[e.prompts?.mcpReady===!1&&(0,A.jsx)("p",{children:"\u8BF7\u5148\u5728 Agent \u63A5\u5165\u8BBE\u7F6E\u4E2D\u914D\u7F6E CoSpace MCP\u3002"}),(0,A.jsx)("textarea",{readOnly:!0,rows:"8",value:te})]}),(0,A.jsx)(nm,{open:!!v,onClose:()=>w(null),labelledBy:Ut,title:t("document.deleteTitle"),closeLabel:t("dialog.close"),className:"space-delete-dialog",actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",autoFocus:!0,disabled:c,onClick:()=>w(null),children:t("document.deleteCancel")}),(0,A.jsx)("button",{type:"button",className:"is-danger",disabled:c,onClick:z,children:t("document.deleteConfirm")})]}),children:(0,A.jsx)("p",{children:t("document.deleteDescription",{title:v?.title||v?.id||""})})}),(0,A.jsxs)(nm,{open:k,onClose:se,labelledBy:"space-collab-title",title:t("collab.documentTitle"),closeLabel:t("dialog.close"),closeOnBackdrop:!0,actions:(0,A.jsx)("button",{type:"button",className:"is-primary",disabled:!ve||he==="saving"||Ce||!!S,onClick:Y,children:t("collab.save")}),children:[S&&(0,A.jsx)("p",{className:"space-collab-error",role:"alert",children:S}),Ce&&!E?(0,A.jsx)("p",{role:"status",children:t("collab.loading")}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("textarea",{rows:"8",maxLength:12e3,value:ie,onChange:oe=>{U(""),xe("idle"),fe(oe.target.value)},placeholder:t("collab.placeholder")}),(0,A.jsx)("p",{className:"space-collab-save-status",role:"status",children:he==="saving"?t("collab.saving"):he==="saved"?t("collab.saved"):he==="error"?t("collab.saveError"):""})]})]})]})}var L$="/cospace-api";async function AR(e,t={},n={}){let r=window.__COSPACE_LOCAL_TOKEN__,a=await fetch(L$,{method:"POST",headers:{"content-type":"application/json",...r?{"x-cospace-token":r}:{}},body:JSON.stringify({method:e,args:t}),...n.signal?{signal:n.signal}:{}}),o=await a.json();if(!a.ok||o.error)throw Object.assign(new Error(o.error?.message||"Request failed"),o.error||{code:"REQUEST_FAILED"});return o.result}var A$=gr(Nf(),1);function lge({name:e,type:t,bytes:n}){if(typeof Blob>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;let r=URL.createObjectURL(new Blob([n],{type:t})),a=document.createElement("a");return a.href=r,a.download=e,a.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3),!0}var uge={id:"local-server",version:"0.1.10",contractVersion:1,capabilities:["files.export.save","clipboard.write","identity.current.read"]},ER=["identity.current.read"];typeof Blob<"u"&&typeof URL?.createObjectURL=="function"&&ER.push("files.export.save");typeof navigator<"u"&&typeof navigator.clipboard?.writeText=="function"&&ER.push("clipboard.write");var cge={core:{request:AR},prompts:{mcpReady:!0},files:{saveExport:lge},clipboard:{writeText:e=>navigator.clipboard.writeText(e)},identity:{getCurrentUser:()=>AR("getUser")},capabilities:h$(uge,ER)};(0,I$.createRoot)(document.getElementById("root")).render((0,A$.jsx)(S$,{adapter:cge}));
|
|
693
|
+
\u8BF7\u901A\u8FC7 CoSpace MCP \u6309\u8BC4\u8BBA\u63D0\u51FA\u4FEE\u6539\u5EFA\u8BAE\uFF0C\u53EA\u5904\u7406\u4EE5\u4E0B\u8BC4\u8BBA ID\uFF1A${n.join("\u3001")}\u3002\u8C03\u7528 space_document_read \u8BFB\u53D6\u6B63\u6587\u548C\u8FD9\u4E9B\u8BC4\u8BBA\u7684\u5F15\u7528\u6587\u672C\u3001\u951A\u70B9\u53CA\u6B63\u6587\uFF1B\u9010\u6761\u7406\u89E3\u8BC4\u8BBA\uFF0C\u5E76\u5BF9\u6BCF\u6761\u660E\u786E\u4E14\u53EF\u5B9A\u4F4D\u7684\u4FEE\u6539\u8981\u6C42\u63D0\u4EA4\u5BF9\u5E94\u7684\u5177\u4F53\u5EFA\u8BAE\u3002\u4E0D\u8981\u53EA\u590D\u8FF0\u6216\u5206\u7C7B\u8BC4\u8BBA\uFF0C\u4E5F\u4E0D\u8981\u5728\u8BC4\u8BBA\u8981\u6C42\u4E4B\u5916\u81EA\u4E3B\u5BA1\u9605\u6216\u589E\u52A0\u5EFA\u8BAE\u3002\u8BC4\u8BBA\u542B\u7CCA\u6216\u65E0\u6CD5\u5B89\u5168\u5B9A\u4F4D\u65F6\uFF0C\u8BF4\u660E\u539F\u56E0\u5E76\u8BE2\u95EE\uFF0C\u4E0D\u8981\u731C\u6D4B\u3002\u5B8C\u6210\u540E\u8C03\u7528 space_comment_complete\uFF0C\u4E3A\u6BCF\u6761\u5DF2\u5904\u7406\u8BC4\u8BBA\u5173\u8054\u5BF9\u5E94\u5EFA\u8BAE ID\uFF1B\u672A\u5904\u7406\u7684\u8BC4\u8BBA\u4F20\u7A7A suggestionIds\uFF0C\u4F7F\u5176\u4FDD\u6301\u5F85\u5904\u7406\u3002\u4E0D\u8981\u76F4\u63A5\u8986\u76D6\u5DF2\u63A5\u53D7\u5185\u5BB9\uFF1B\u6240\u6709\u4FEE\u6539\u4EE5\u5EFA\u8BAE\u63D0\u4EA4\uFF0C\u7B49\u5F85\u6211\u5728 CoSpace \u4E2D\u63A5\u53D7\u6216\u62D2\u7EDD\u3002\u4E0D\u8981\u66FF\u6211\u53D1\u9001\u8BC4\u8BBA\u3002`}var A=gr(Nf(),1);var lb=()=>globalThis.crypto.randomUUID();function x$({label:e,value:t,options:n,onChange:r}){let[a,o]=(0,ae.useState)(!1),i=(0,ae.useRef)(null);(0,ae.useEffect)(()=>{if(!a)return;let l=u=>{i.current?.contains(u.target)||o(!1)};return document.addEventListener("pointerdown",l),()=>document.removeEventListener("pointerdown",l)},[a]);let s=n.findIndex(l=>l.value===t);return(0,A.jsxs)("div",{className:"space-home-select",ref:i,children:[(0,A.jsxs)("button",{type:"button",className:"space-home-select-trigger","aria-label":e,"aria-haspopup":"listbox","aria-expanded":a,onClick:()=>o(l=>!l),onKeyDown:l=>{if(l.key==="Escape"){o(!1);return}if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();let u=l.key==="ArrowDown"?1:-1;r(n[(s+u+n.length)%n.length].value)}},children:[(0,A.jsx)("span",{children:n[s]?.label}),(0,A.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",children:(0,A.jsx)("path",{d:"m4 6 4 4 4-4"})})]}),a&&(0,A.jsx)("div",{className:"space-home-select-menu",role:"listbox","aria-label":e,children:n.map(l=>(0,A.jsxs)("button",{type:"button",role:"option","aria-selected":t===l.value,onClick:()=>{r(l.value),o(!1)},children:[l.label,t===l.value&&(0,A.jsx)("span",{"aria-hidden":"true",children:"\u2713"})]},l.value))})]})}function w$(e,t,n){if(!e)return!1;if(LR(e,t,t,n))return!0;let r=e.closest(".space-paper-wrap");if(!r)return!1;let a=n.length?Math.max(0,Math.min(1,t/n.length)):0;return r.scrollTo({top:Math.max(0,e.offsetTop+e.offsetHeight*a-r.clientHeight*.3),behavior:"auto"}),!0}var b$={pending:"status.pending",sending:"status.sending",sent:"status.sent",failed:"status.failed",unknown:"status.unknown",processed:"status.processed"},y$={pending:"suggestion.pendingStatus",accepted:"suggestion.acceptedStatus",rejected:"suggestion.rejectedStatus",conflicted:"suggestion.conflictedStatus"};var Wme=(e,t)=>{let n=e.updatedAt||e.createdAt;if(!n||!Number.isFinite(Date.parse(n)))return t("home.timeUnknown");let r=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n));return t(e.updatedAt?"home.updated":"home.created",{time:r})},ub=(e,t)=>J4(Z4,e,t),k$=typeof __COSPACE_BUILD_VERSION__>"u"?"development":__COSPACE_BUILD_VERSION__,Kme=k$.split("+",1)[0];function Xme({className:e=""}){return(0,A.jsx)("img",{className:e,src:Y4,alt:"","aria-hidden":"true"})}function Yme({size:e=14}){return(0,A.jsx)(ws,{size:e,strokeWidth:1.8,"aria-hidden":"true"})}function Zme({size:e=15}){return(0,A.jsx)(Hd,{size:e,strokeWidth:1.8,"aria-hidden":"true"})}function Jme({label:e,children:t,...n}){return(0,A.jsx)("button",{type:"button","aria-label":e,title:e,...n,children:t})}function Qme({exporting:e,onExport:t,onReview:n,onPreferences:r,canExport:a,t:o}){let[i,s]=(0,ae.useState)(!1),l=(0,ae.useRef)(null),u=(0,ae.useRef)(null),c=(0,ae.useId)();(0,ae.useEffect)(()=>{if(!i)return;let d=h=>{l.current?.contains(h.target)||s(!1)},p=h=>{h.key==="Escape"&&(s(!1),u.current?.focus())};return document.addEventListener("pointerdown",d),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",d),document.removeEventListener("keydown",p)}},[i]);let f=d=>{s(!1),d?.()};return(0,A.jsxs)("div",{className:"space-tools-menu",ref:l,children:[(0,A.jsx)("button",{ref:u,type:"button",className:"space-tools-menu-trigger","aria-label":o("toolbar.more"),title:o("toolbar.more"),"aria-haspopup":"true","aria-expanded":i,"aria-controls":c,onClick:()=>s(d=>!d),children:(0,A.jsx)(Fl,{size:19,"aria-hidden":"true"})}),i&&(0,A.jsxs)("div",{id:c,className:"space-tools-menu-panel",children:[n&&(0,A.jsx)("button",{type:"button",onClick:()=>f(n),children:"\u8BA9 Agent \u5BA1\u9605"}),r&&(0,A.jsx)("button",{type:"button",onClick:()=>f(r),children:o("collab.open")}),a&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"space-tools-menu-divider",role:"separator"}),(0,A.jsx)("p",{children:o("export.button")}),(0,A.jsxs)("button",{type:"button",disabled:e,onClick:()=>f(()=>t("md")),children:["Markdown ",(0,A.jsx)("span",{children:".md"})]}),(0,A.jsxs)("button",{type:"button",disabled:e,onClick:()=>f(()=>t("docx")),children:["Word ",(0,A.jsx)("span",{children:".docx"})]})]})]})]})}function nm({open:e,onClose:t,labelledBy:n,title:r,closeLabel:a,className:o="",closeOnBackdrop:i=!1,actions:s,children:l}){let u=(0,ae.useRef)(null),c=(0,ae.useRef)(t);return c.current=t,(0,ae.useEffect)(()=>{if(!e||typeof document>"u")return;let f=u.current,d=document.activeElement,p=document.body.style.overflow;document.body.style.overflow="hidden";let h=()=>[...f.querySelectorAll('button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),a[href],[tabindex]:not([tabindex="-1"])')];(f.querySelector("[autofocus]")||h()[0]||f).focus();let x=m=>{if(m.key==="Escape"){m.preventDefault(),c.current?.();return}if(m.key!=="Tab")return;let y=h();if(!y.length){m.preventDefault(),f.focus();return}let b=y[0],v=y.at(-1);m.shiftKey&&(document.activeElement===b||document.activeElement===f)?(m.preventDefault(),v.focus()):!m.shiftKey&&document.activeElement===v&&(m.preventDefault(),b.focus())};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x),document.body.style.overflow=p,d instanceof HTMLElement&&d.isConnected&&d.focus()}},[e]),!e||typeof document>"u"?null:(0,A.jsx)("div",{className:"space-dialog-backdrop",onMouseDown:f=>{i&&f.target===f.currentTarget&&t()},children:(0,A.jsxs)("section",{ref:u,className:`space-dialog ${o}`,role:"dialog","aria-modal":"true","aria-labelledby":n,tabIndex:-1,onMouseDown:f=>f.stopPropagation(),children:[(0,A.jsxs)("header",{className:"space-dialog-header",children:[(0,A.jsx)("h2",{id:n,children:r}),(0,A.jsx)("button",{type:"button",className:"space-dialog-close","aria-label":a,onClick:()=>c.current?.(),children:(0,A.jsx)(Ud,{size:17,"aria-hidden":"true"})})]}),(0,A.jsx)("div",{className:"space-dialog-content",children:l}),s&&(0,A.jsx)("footer",{className:"space-dialog-actions",children:s})]})})}function ege(e,t,n,r=ub,a=null,o=null){let i=a?.conversation||null,[s,l]=(0,ae.useState)(null),[u,c]=(0,ae.useState)([]),[f,d]=(0,ae.useState)(null),[p,h]=(0,ae.useState)(null),[g,x]=(0,ae.useState)(""),[m,y]=(0,ae.useState)(null),[b,v]=(0,ae.useState)(1),[w,k]=(0,ae.useState)(!1),[_,E]=(0,ae.useState)(""),[M,S]=(0,ae.useState)(!1),[U,N]=(0,ae.useState)(""),[q,ie]=(0,ae.useState)(null),[fe,he]=(0,ae.useState)(!1),xe=(0,ae.useRef)(null),Ce=(0,ae.useRef)(new Map),Fe=(0,ae.useRef)(new Map),D=(0,ae.useRef)(0),st=(0,ae.useRef)(null),Ke=(0,ae.useRef)(null),T=(0,ae.useRef)(!1),at=(0,ae.useRef)(r);at.current=r;let yt=(0,ae.useCallback)(($,te={})=>e($,te),[e]);(0,ae.useEffect)(()=>{v(1)},[t]);let Ut=(0,ae.useCallback)(async $=>{let te=++D.current,le=await yt("readDocument",{docId:$});if(te!==D.current)return;$===o&&(S(!0),ie(le?.version??null),he(!1));let me=le?.comments||[],P=JSON.stringify(le),G=!Ke.current||Ke.current.content!==le?.content||Ke.current.version!==le?.version;Ke.current?.signature!==P&&(l(le),c(me)),Ke.current={signature:P,content:le?.content,version:le?.version},G&&y(null),le?.title&&i$($,le.title,e)},[yt,o]);(0,ae.useEffect)(()=>{if(S(!1),ie(null),he(!1),st.current=null,!t){D.current++,Ke.current=null,l(null),c([]),d(null),h(null),y(null),x(""),E("");return}Ke.current=null,l(null),E(""),Ut(t).catch($=>E(ks($,at.current)))},[t,Ut]),(0,ae.useEffect)(()=>()=>{D.current++},[]),(0,ae.useEffect)(()=>{T.current=w},[w]),(0,ae.useEffect)(()=>{if(!t)return;let $=!1,te=()=>{$||document.visibilityState==="hidden"||T.current||Ut(t).catch(()=>{})},le=setInterval(te,2500);return document.addEventListener("visibilitychange",te),()=>{$=!0,clearInterval(le),document.removeEventListener("visibilitychange",te)}},[t,Ut]);let ln=(0,ae.useMemo)(()=>[...s?.suggestions||[]].sort(($,te)=>($.from??0)-(te.from??0)),[s]),mt=!!s&&!ln.some($=>["pending","conflicted"].includes($.status))&&!u.some($=>["pending","sending","failed","unknown"].includes($.status)),be=$=>b$[$.status]?r(b$[$.status]):$.status,Tt=$=>{h(null),d($);let te=s?.suggestions?.find(le=>le.id===$);(!te||!w$(xe.current,te.from,s?.content||""))&&E(r("suggestion.unavailable"))},Dt=$=>{h(null),d($),Ce.current.get($)?.scrollIntoView({block:"nearest",behavior:"auto"})},vt=async $=>{k(!0),E("");try{return await $()}catch(te){return E(ks(te,at.current)),null}finally{k(!1)}},I=($,te)=>vt(async()=>{await yt("decide",{docId:t,suggestionId:$,decision:te,operationId:lb()}),await Ut(t)}),R=()=>{if(!mt){E(r("edit.unavailable"));return}E(""),N(""),y(null),ie(s.version),he(!1),S(!0)},z=()=>vt(async()=>{if(q===null)throw Object.assign(new Error(r("edit.unavailable")),{code:"EDIT_REQUIRES_UNANNOTATED_DOCUMENT"});let $=st.current?.getMarkdown(),te=fe&&typeof $=="string"&&$!==s?.content;if(te)try{await yt("updateDocument",{docId:t,baseVersion:q,content:$,operationId:lb()})}catch(le){throw N(ks(le,at.current)),le}return S(!1),ie(null),he(!1),st.current=null,N(""),te&&await Ut(t),!0}),ne=()=>{N(""),E("")},j=()=>vt(async()=>{if(!m||!g.trim())throw Error(r("comment.required"));let $=await yt("createComment",{docId:t,quote:m.quote,body:g.trim(),anchor:{from:m.from,to:m.to,version:m.version}});return x(""),await Ut(t),h($.id),$}),W=tm(a?.capabilities,"clipboard.write")&&typeof a?.clipboard?.writeText=="function",Y=tm(a?.capabilities,"conversation.send"),se=tm(a?.capabilities,"conversation.create")&&i?.canCreate===!0;return{doc:s,setDoc:l,comments:u,active:f,setActive:d,activeComment:p,setActiveComment:h,draft:g,setDraft:x,selection:m,setSelection:y,zoom:b,setZoom:v,busy:w,message:_,setMessage:E,surface:xe,cardRefs:Ce,commentRefs:Fe,reload:Ut,suggestions:ln,statusText:be,chooseCard:Tt,chooseFromText:Dt,decide:I,addComment:j,deleteComment:$=>vt(async()=>{await yt("deleteComment",{docId:t,commentId:$}),h(null),await Ut(t)}),send:($=n&&Y?"current":se?"new":W?"copy":"unavailable")=>vt(async()=>{let te=u.filter(me=>["pending","failed"].includes(me.status)).map(me=>me.id);if(!te.length)throw Error(r("send.none"));if($==="copy"){if(!W)throw Object.assign(new Error(r("send.clipboardUnavailable")),{code:"CLIPBOARD_UNAVAILABLE"});if(typeof a?.clipboard?.writeText!="function")throw Object.assign(new Error(r("send.clipboardUnavailable")),{code:"CLIPBOARD_UNAVAILABLE"});let me=g$(`space:${encodeURIComponent(t)}`,te);return await a.clipboard.writeText(me),E(r("send.copied")),h(null),{copied:!0}}if($!=="current"&&$!=="new")throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});if(!Y)throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});if($==="current"&&!n)throw Object.assign(new Error(r("send.noSession")),{code:"SESSION_UNAVAILABLE"});if($==="new"&&!se)throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});let le=$==="current"?n:void 0;try{if(typeof i?.send!="function")throw Object.assign(new Error(r("send.createUnavailable")),{code:"SESSION_UNAVAILABLE"});let me=await i.send({intent:"process-comments",documentId:t,commentIds:te,...le?{conversationId:le}:{createConversation:!0,...n?{excludeConversationId:n}:{}},requestId:lb()});return!le&&me?.createdConversation&&me.conversationId&&typeof i?.open=="function"&&i.open(me.conversationId),me}finally{await Ut(t),h(null)}}),canCopy:W,canSend:Y,canCreate:se,canEdit:mt,editing:M,autoFocus:s?.id===o,editSaveError:U,dismissEditSaveError:ne,editorRef:st,startEditing:R,switchToReview:z,markEditDirty:()=>he(!0)}}function tge({review:e,t=ub}){let{zoom:n,setZoom:r}=e;return(0,A.jsxs)("div",{className:"space-zoom-tools",role:"group","aria-label":t("zoom.label"),children:[(0,A.jsx)("button",{type:"button","aria-label":t("zoom.out"),title:t("zoom.out"),disabled:n<=.6,onClick:()=>r(a=>Math.max(.6,Math.round((a-.1)*10)/10)),children:"\u2212"}),(0,A.jsxs)("span",{children:[Math.round(n*100),"%"]}),(0,A.jsx)("button",{type:"button","aria-label":t("zoom.in"),title:t("zoom.in"),disabled:n>=1.5,onClick:()=>r(a=>Math.min(1.5,Math.round((a+.1)*10)/10)),children:"\uFF0B"})]})}function sb(e){return e.resolved||(!e.stale&&Number.isInteger(e.anchor?.from)&&Number.isInteger(e.anchor?.to)?{from:e.anchor.from,to:e.anchor.to}:null)}function nge({name:e,avatarUrl:t}){let[n,r]=(0,ae.useState)(!1);(0,ae.useEffect)(()=>{r(!1)},[t]);let a=Array.from(e.trim())[0]?.toLocaleUpperCase()||"?";return(0,A.jsx)("span",{className:`space-annotation-avatar${t&&!n?" is-image":""}`,"aria-hidden":"true",children:t&&!n?(0,A.jsx)("img",{src:t,alt:"",loading:"lazy",referrerPolicy:"no-referrer",onError:()=>r(!0)}):a})}function C$({name:e,createdAt:t,fallback:n,fallbackTime:r="",avatarUrl:a=null}){let o=e||n,i=Number.isFinite(Date.parse(t))?new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t)):"";return(0,A.jsxs)("div",{className:"space-annotation-identity",children:[(0,A.jsx)(nge,{name:o,avatarUrl:a}),(0,A.jsxs)("span",{className:"space-annotation-byline",children:[(0,A.jsx)("strong",{children:o}),(i||r)&&(0,A.jsx)("time",{dateTime:i?t:void 0,children:i||r})]})]})}function v$({comment:e,author:t,active:n,busy:r,t:a,statusText:o,confirming:i,onAskDelete:s,onConfirmDelete:l,onCancelDelete:u,onActivate:c,setRef:f,style:d,className:p="",onPointerEnter:h,onPointerLeave:g}){let x=e.status,m=r||e.status==="sending",y=e.status==="pending"?e.stale?a("comment.staleStatus"):null:`${o(e)}${e.stale?a("comment.stale"):""}`,b=t?.name||(t?.signedIn?a("comment.accountUser"):null);return(0,A.jsxs)("article",{className:`space-annotation-balloon space-comment-balloon${n?" is-active":""}${e.stale?" is-stale":""}${i?" is-confirming":""} ${p}`,"data-comment-id":e.id,ref:v=>f(e.id,v),style:d,onPointerEnter:h,onPointerLeave:g,onClick:()=>c(e.id),children:[(0,A.jsx)(C$,{name:b,avatarUrl:t?.avatarUrl,createdAt:e.createdAt,fallback:a("comment.author")}),y&&(0,A.jsx)("div",{className:"space-annotation-head",children:(0,A.jsx)("span",{className:`space-comment-status is-${x}`,children:y})}),(0,A.jsx)("p",{className:"space-comment-body",children:e.body}),e.processing?.suggestions?.length>0&&(0,A.jsx)("div",{className:"space-comment-processing-meta",children:a("comment.relatedSuggestions",{states:e.processing.suggestions.map(v=>y$[v.status]?a(y$[v.status]):v.status).join("\u3001")})}),(0,A.jsx)("button",{type:"button",className:"space-annotation-action space-comment-delete-icon",disabled:m,"aria-label":a("comment.delete"),title:a("comment.delete"),onClick:v=>{v.stopPropagation(),s(e.id)},children:(0,A.jsx)(ws,{size:18,strokeWidth:2,"aria-hidden":"true"})}),i&&(0,A.jsxs)("div",{className:"space-comment-footer is-confirming",onClick:v=>v.stopPropagation(),children:[(0,A.jsx)("span",{className:"space-comment-confirm-text",children:a("comment.deleteConfirm")}),(0,A.jsx)("button",{type:"button",className:"space-comment-delete is-danger",disabled:m,onClick:()=>l(e.id),children:a("comment.delete")}),(0,A.jsx)("button",{type:"button",className:"space-comment-delete",disabled:m,onClick:()=>u(),children:a("comment.cancel")})]})]})}function rge({item:e,active:t,busy:n,t:r,onActivate:a,onDecide:o,setRef:i,style:s,className:l="",onPointerEnter:u,onPointerLeave:c}){let f=e.status==="conflicted";return(0,A.jsxs)("article",{className:`space-annotation-balloon space-suggestion-balloon${t?" is-active":""}${f?" is-conflicted":""} ${l}`,"data-suggestion-card":e.id,ref:d=>i(e.id,d),style:s,onPointerEnter:u,onPointerLeave:c,onClick:a,children:[(0,A.jsxs)("div",{className:"space-suggestion-head",children:[(0,A.jsx)(C$,{name:e.author,createdAt:e.createdAt,fallback:r("suggestion.defaultAuthor"),fallbackTime:r("suggestion.unknownTime")}),!f&&(0,A.jsxs)("div",{className:"space-suggestion-actions",children:[(0,A.jsx)("button",{type:"button",className:"space-annotation-action is-accept",disabled:n,"aria-label":r("action.accept"),title:r("action.accept"),onClick:d=>{d.stopPropagation(),o("accept")},children:(0,A.jsx)(Eg,{size:18,strokeWidth:2,"aria-hidden":"true"})}),(0,A.jsx)("button",{type:"button",className:"space-annotation-action is-reject",disabled:n,"aria-label":r("action.reject"),title:r("action.reject"),onClick:d=>{d.stopPropagation(),o("reject")},children:(0,A.jsx)(Ud,{size:18,strokeWidth:2,"aria-hidden":"true"})})]})]}),(0,A.jsxs)("div",{className:"space-suggestion-change",children:[e.expected&&(0,A.jsxs)("p",{className:"is-deleted",children:[(0,A.jsxs)("strong",{children:[r("suggestion.deletedLabel"),"\uFF1A"]}),e.expected]}),e.replacement&&(0,A.jsxs)("p",{className:"is-inserted",children:[(0,A.jsxs)("strong",{children:[r("suggestion.insertedLabel"),"\uFF1A"]}),e.replacement]}),!e.expected&&!e.replacement&&(0,A.jsx)("p",{className:"is-unavailable",children:r("suggestion.unavailable")})]}),f&&(0,A.jsx)("div",{className:"space-suggestion-meta",children:(0,A.jsx)("span",{className:"space-suggestion-conflict",children:r("suggestion.conflicted")})})]})}function age({review:e,sessionId:t,adapter:n=null,t:r=ub,compact:a=!1}){let o=(0,ae.useId)(),i=(0,ae.useId)(),[s,l]=(0,ae.useState)(!1),[u,c]=(0,ae.useState)("copy"),f=e.comments.filter(k=>["pending","failed"].includes(k.status)),d=n?.conversation||null,p=e.canSend&&!!t,h=e.canCreate,g=e.canCopy;(0,ae.useEffect)(()=>{l(!1)},[e.doc?.id,t,g,h,f.length===0]);let x=e.busy||!f.length,m=!p&&!h&&g?r("send.copyHint"):void 0,y=null,b=null;try{y=t&&d?.getConversationLabel?.(t)}catch{}try{b=t&&d?.getWorkspaceLabel?.(t)}catch{}let v=()=>{c(p?"current":h?"new":g?"copy":"unavailable"),l(!0)},w=u==="copy"?"send.copyConfirm":u==="new"?"send.newSessionConfirm":"send.confirm";return!f.length||!p&&!h&&!g?null:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("button",{type:"button",className:`space-send ${a?"space-send-compact":"space-send-header"}`,disabled:x,title:m,onClick:v,children:[(0,A.jsx)(Hd,{size:14,"aria-hidden":"true"}),(0,A.jsx)("span",{children:r("send.action")})]}),(0,A.jsxs)(nm,{open:s,onClose:()=>l(!1),labelledBy:o,title:r("send.chooseTitle"),closeLabel:r("dialog.close"),className:"space-send-dialog",actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",autoFocus:!0,onClick:()=>l(!1),children:r("comment.cancel")}),(0,A.jsx)("button",{type:"button",className:"is-primary",disabled:e.busy||!f.length||u==="current"&&!p||u==="new"&&!h,onClick:()=>{l(!1),e.send(u)},children:r(w)})]}),children:[(0,A.jsx)("p",{children:r("send.chooseDescription",{count:f.length})}),(0,A.jsxs)("fieldset",{className:"space-send-options",children:[(0,A.jsx)("legend",{children:r("send.destination")}),(0,A.jsxs)("label",{className:"space-send-option",children:[(0,A.jsx)("input",{type:"radio",name:i,value:"current",checked:u==="current",disabled:!p,onChange:()=>c("current")}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:r("send.currentOption")}),(0,A.jsxs)("small",{className:"space-send-conversation",children:[p&&b&&(0,A.jsx)("span",{className:"space-send-workspace",children:b}),p?y||r("send.sessionId",{id:t}):r("send.currentUnavailable")]})]})]}),(0,A.jsxs)("label",{className:"space-send-option",children:[(0,A.jsx)("input",{type:"radio",name:i,value:"new",checked:u==="new",disabled:!h,onChange:()=>c("new")}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:r("send.newOption")}),(0,A.jsx)("small",{children:r(h?"send.newOptionHint":"send.newUnavailable")})]})]}),g&&(0,A.jsxs)("label",{className:"space-send-option",children:[(0,A.jsx)("input",{type:"radio",name:i,value:"copy",checked:u==="copy",onChange:()=>c("copy")}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:r("send.copyOption")}),(0,A.jsx)("small",{children:r("send.copyOptionHint")})]})]})]})]})]})}function oge(e){let t=e.filter(s=>s.caret),n=e.filter(s=>!s.caret&&s.kind!=="comment"),r=e.filter(s=>!s.caret&&s.kind==="comment").sort((s,l)=>s.top-l.top||s.height-l.height||s.left-l.left),a=[];for(let s of r){let l=a.at(-1);if(l&&Math.abs(l.top-s.top)<=1&&Math.abs(l.height-s.height)<=1&&s.left<=l.left+l.width){let u=Math.max(l.left+l.width,s.left+s.width);l.width=u-l.left,l.active=l.active||s.active,l.keys.push(s.key),s.active&&l.activeRects.push(s)}else a.push({...s,active:!1,keys:[s.key],activeRects:s.active?[s]:[]})}let o=a.map(s=>({key:`comment-fill:${s.keys.join("|")}`,kind:"comment",active:!1,left:s.left,top:s.top,width:s.width,height:s.height,caret:!1})),i=a.flatMap(s=>s.activeRects.map(l=>({...l,key:`${l.key}:active-outline`,active:!0,outline:!0})));return[...o,...n,...t,...i]}function ige({review:e,user:t=null,t:n=ub}){let[r,a]=(0,ae.useState)(!1),[o,i]=(0,ae.useState)(null),[s,l]=(0,ae.useState)(0),[u,c]=(0,ae.useState)(null),f=(0,ae.useRef)(null),[d,p]=(0,ae.useState)({positions:{},lines:[],highlights:[],height:0,minHeight:0}),h=(0,ae.useId)(),g=(0,ae.useId)(),x=(0,ae.useId)(),m=(0,ae.useRef)(null),y=(0,ae.useRef)(null),b=(0,ae.useRef)(null),v=(0,ae.useRef)(null),w=(0,ae.useRef)(null),[k,_]=(0,ae.useState)(null),{doc:E,comments:M,active:S,setActive:U,activeComment:N,setActiveComment:q,draft:ie,setDraft:fe,selection:he,setSelection:xe,zoom:Ce,busy:Fe,message:D,setMessage:st,surface:Ke,cardRefs:T,commentRefs:at,suggestions:yt,statusText:Ut,chooseCard:ln,chooseFromText:mt,decide:be,addComment:Tt,deleteComment:Dt,editing:vt,editorRef:I,markEditDirty:R}=e,z=(0,ae.useMemo)(()=>M.filter(V=>!["sent","processed"].includes(V.status)),[M]),ne=(0,ae.useMemo)(()=>z.filter(V=>sb(V)),[z]),j=(0,ae.useMemo)(()=>z.filter(V=>!sb(V)),[z]),W=yt.length>0||z.length>0,Y=(0,ae.useMemo)(()=>yt.map((V,Le)=>({kind:"suggestion",key:`suggestion:${V.id}`,id:V.id,item:V,index:Le})),[yt]),se=(0,ae.useMemo)(()=>ne.map(V=>({kind:"comment",key:`comment:${V.id}`,id:V.id,item:V})),[ne]),K=(0,ae.useMemo)(()=>[...Y,...se],[Y,se]);if((0,ae.useLayoutEffect)(()=>{let V=y.current;if(!V)return;let Le=()=>l(et=>et+1);Le();let Oe=typeof ResizeObserver=="function"?new ResizeObserver(Le):null;return Oe?.observe(V),Ke.current&&Oe?.observe(Ke.current),window.addEventListener("resize",Le),()=>{Oe?.disconnect(),window.removeEventListener("resize",Le)}},[E?.content]),(0,ae.useEffect)(()=>{if(!document.fonts?.ready)return;let V=!0;return document.fonts.ready.then(()=>{V&&l(Le=>Le+1)}),()=>{V=!1}},[]),(0,ae.useEffect)(()=>{let V=Ke.current;if(!V||!E||vt)return;let Le=typeof requestAnimationFrame=="function"?requestAnimationFrame:cn=>setTimeout(cn,0),Oe=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:clearTimeout,et=0,lt=()=>{if(et=0,r||document.activeElement?.tagName==="TEXTAREA")return;let cn=window.getSelection?.();if(!cn||cn.rangeCount===0){xe(Je=>Je&&null);return}let wt=cn.getRangeAt(0);if(wt.collapsed){xe(Je=>Je&&null);return}if(!V.contains(wt.commonAncestorContainer)){xe(Je=>Je&&null);return}try{let Je=SR(V,wt,E.content,E.version);Je&&xe(zt=>zt&&zt.from===Je.from&&zt.to===Je.to&&zt.quote===Je.quote?zt:Je)}catch{}},An=()=>{et||(et=Le(lt))};return document.addEventListener("selectionchange",An),()=>{document.removeEventListener("selectionchange",An),et&&Oe(et)}},[r,E,vt,xe,Ke]),(0,ae.useLayoutEffect)(()=>{if(!W){p($e=>$e.height===0&&!$e.lines.length&&!$e.highlights?.length&&!Object.keys($e.positions).length?$e:{positions:{},lines:[],highlights:[],height:0,minHeight:0});return}let V=b.current,Le=Ke.current,Oe=v.current;if(!V||!Le||!Oe)return;let et=V.getBoundingClientRect(),lt=Ce,An=Le.getBoundingClientRect(),cn=Oe.getBoundingClientRect(),wt=Ki(Le,E.content),Je=S!=null?`suggestion:${S}`:N!=null?`comment:${N}`:null,zt=new Map,Qn=[];for(let $e of K){let En=$e.kind==="suggestion"?{from:$e.item.from,to:$e.item.to}:sb($e.item);if(!En)continue;let fn=Mf(wt,En.from,En.to);if(!fn)continue;let yn=WC(fn.range,et).map(en=>Object.fromEntries(Object.entries(en).map(([Zo,al])=>[Zo,typeof al=="number"?al/lt:al])));if(!yn.length){let en=fn.startSpan.element.getBoundingClientRect();en&&(en.width||en.height)&&(yn=[{left:(en.left-et.left)/lt,top:(en.top-et.top)/lt,right:(en.right-et.left)/lt,bottom:(en.bottom-et.top)/lt,width:en.width/lt,height:en.height/lt}])}let Vn=yn[0];if(!Vn)continue;let Zi=yn[yn.length-1];zt.set($e.key,{left:Vn.left,right:Vn.right,top:Vn.top,bottom:Vn.bottom,height:Vn.height,end:Zi});let xo=$e.key===Je;En.from===En.to?Qn.push({key:`${$e.key}:caret`,kind:$e.kind,active:xo,left:Math.max(0,Vn.left-1),top:Vn.top,width:2,height:Math.max(Vn.height,18),caret:!0}):yn.forEach((en,Zo)=>{en.width>0&&en.height>0&&Qn.push({key:`${$e.key}:${Zo}`,kind:$e.kind,deleted:$e.kind==="suggestion"&&!!$e.item.expected,active:xo,left:en.left,top:en.top,width:en.width,height:en.height,caret:!1})})}let mr=oge(Qn),Bu=[...K].sort(($e,En)=>{let fn=zt.get($e.key)?.top??$e.item.from??0,yn=zt.get(En.key)?.top??En.item.from??0;return fn-yn||$e.key.localeCompare(En.key)}),Xi={},Yi=[],go=8;for(let $e of Bu){let En=$e.kind==="suggestion"?T.current.get($e.id):at.current.get($e.id);if(!En)continue;let fn=zt.get($e.key),yn=En.offsetHeight||0,Vn=$e.item.from??$e.item.anchor?.from??0,Zi=E.content.length?Le.offsetHeight*Math.max(0,Math.min(1,Vn/E.content.length)):0,xo=Math.max(fn?.top??Zi,go);if(Xi[$e.key]=xo,go=xo+yn+10,fn){let en=d$(fn.end,(cn.left-et.left)/lt,xo,yn,(An.right-et.left)/lt);Yi.push({key:$e.key,kind:$e.kind,active:$e.key===Je,...en})}}let rl=Math.max(Le.offsetHeight,go);p($e=>JSON.stringify($e.positions)===JSON.stringify(Xi)&&JSON.stringify($e.lines)===JSON.stringify(Yi)&&JSON.stringify($e.highlights||[])===JSON.stringify(mr)&&$e.height===go&&$e.minHeight===rl?$e:{positions:Xi,lines:Yi,highlights:mr,height:go,minHeight:rl})},[W,K,yt,ne,E?.content,s,S,N,o,T,at,n,Ce]),(0,ae.useEffect)(()=>{he||a(!1)},[he]),(0,ae.useEffect)(()=>{i(null)},[M]),(0,ae.useEffect)(()=>(c(null),()=>{clearTimeout(f.current),f.current=null}),[E?.id]),(0,ae.useLayoutEffect)(()=>{let V=w.current,Le=Ke.current;if(!he||r||Fe||!V||!Le)return;let Oe={contextElement:Le,getBoundingClientRect(){let cn=Mf(Ki(Le,E?.content),he.from,he.to);if(cn)return cn.range.getBoundingClientRect?.()||Le.getBoundingClientRect();let wt=Le.closest(".space-paper-wrap"),Je=wt?.getBoundingClientRect(),zt=he.anchor;if(Je&&zt){let Qn=Je.left+zt.x-wt.scrollLeft,mr=Je.top+zt.top-wt.scrollTop;return{x:Qn,y:mr,left:Qn,right:Qn,top:mr,bottom:Je.top+zt.bottom-wt.scrollTop,width:1,height:Math.max(1,zt.bottom-zt.top)}}return Le.getBoundingClientRect()}},et=!0,An=Sg(Oe,V,()=>zr(Oe,V,{placement:"top",middleware:[Pa(10),zl(),xv({padding:8})]}).then(({x:cn,y:wt})=>{et&&_({left:cn,top:wt})}).catch(()=>{}));return()=>{et=!1,An()}},[he,r,Fe,Ke,s,Ce,E?.content]),!E)return(0,A.jsx)("section",{className:"space-paper-wrap",children:(0,A.jsx)("p",{className:"space-loading",role:"status",children:e.message||n("empty.loading")})});let Z=()=>{st(""),a(!0)},$=()=>{a(!1),st("")},te=async()=>{await Tt()&&(a(!1),st(""),xe(null))},le=V=>i(V),me=async V=>{await Dt(V),i(null)},P=V=>{let Le=ne.find(Oe=>Oe.id===V);if(Le){let Oe=sb(Le);w$(Ke.current,Oe.from,E.content)}},G=V=>{U(null),q(V),at.current.get(V)?.scrollIntoView({block:"nearest",inline:"nearest",behavior:"auto"})},de=V=>{U(null),q(V),P(V)},ve=V=>{q(null),U(V),ln(V)},oe=()=>{clearTimeout(f.current),f.current=null},ce=()=>{f.current===null&&(f.current=setTimeout(()=>{f.current=null,c(null)},180))},Ee=V=>{let Le=V.target?.closest?.("[data-suggestion-id]")?.getAttribute("data-suggestion-id"),Oe=Le==null?null:Y.find(wt=>String(wt.id)===Le);if(Oe){oe(),c(wt=>wt?.key===Oe.key?wt:{key:Oe.key,left:V.clientX,top:V.clientY});return}let et=document.caretRangeFromPoint?.(V.clientX,V.clientY),lt=et?{node:et.startContainer,offset:et.startOffset}:document.caretPositionFromPoint?.(V.clientX,V.clientY);if(!lt){ce();return}let An=Zj(Ke.current,lt.node||lt.offsetNode,lt.offset,E.content);if(!Number.isInteger(An)){ce();return}let cn=K.find(wt=>{let Je=wt.kind==="suggestion"?{from:wt.item.from,to:wt.item.to}:sb(wt.item);return Je&&(Je.from===Je.to?An===Je.from:An>=Je.from&&An<=Je.to)});cn?(oe(),c(wt=>wt?.key===cn.key?wt:{key:cn.key,left:V.clientX,top:V.clientY})):ce()},tt=V=>{let Le=V.target?.closest?.("a[href]");if(!Le||!Ke.current?.contains(Le))return;let Oe=Le.getAttribute("href")?.trim();if(!Oe)return;let et;try{et=new URL(Oe,window.location.href)}catch{V.preventDefault();return}let lt=new URL(window.location.href);if(Oe.startsWith("#")&&et.origin===lt.origin&&et.pathname===lt.pathname&&et.search===lt.search)return;if(["http:","https:","mailto:","tel:"].includes(et.protocol)){Le.target="_blank",Le.rel="noopener noreferrer";return}let An=adapter.navigation?.parseDocumentLink?.(Oe);if(An){V.preventDefault(),adapter.navigation?.openDocument?.(An);return}V.preventDefault()},un=he?.anchor,Et=(un?.top||0)<60,Qt=Math.max(40,Math.min(un?.x||0,(un?.wrapWidth||120)-40));return(0,A.jsxs)("section",{className:`space-paper-wrap${vt?" is-editing":""}`,"aria-label":n("paper.aria"),ref:y,children:[(0,A.jsxs)("div",{className:`space-doc-stage${W?" has-annotations":""}`,ref:b,style:{zoom:Ce},children:[(0,A.jsx)("div",{ref:Ke,onClickCapture:tt,onPointerMove:vt?void 0:Ee,onPointerLeave:ce,className:`space-paper${E.content.replace(/^# [^\r\n]*(?:\r?\n)+/,"").trim()?"":" is-empty"}`,tabIndex:-1,children:(0,A.jsx)(t$,{markdown:E.content,editorRef:I,onChange:R,onDecorationsReady:()=>l(V=>V+1),t:n,readOnly:!vt,autoFocus:e.autoFocus,suggestions:yt},vt?"edit":`review-${E.version}`)}),(0,A.jsx)("div",{className:"space-anchor-layer","aria-hidden":"true",children:d.highlights?.map(V=>(0,A.jsx)("span",{className:`space-anchor-rect is-${V.kind}${V.deleted?" is-deleted":""}${V.active?" is-active":""}${V.caret?" is-caret":""}${V.outline?" is-outline":""}`,style:{left:V.left,top:V.top,width:V.width,height:V.height}},V.key))}),W&&(0,A.jsxs)("aside",{className:"space-comment-rail",ref:v,"aria-label":n("annotations.title"),style:{minHeight:d.minHeight||void 0},children:[(0,A.jsx)("div",{className:"space-comment-spacer",style:{height:d.height||0}}),(0,A.jsxs)("div",{className:"space-comment-balloons is-positioned",children:[Y.map(V=>(0,A.jsx)(rge,{item:V.item,index:V.index,active:S===V.item.id,busy:Fe,t:n,onActivate:()=>ve(V.item.id),onDecide:Le=>be(V.item.id,Le),onPointerEnter:oe,onPointerLeave:ce,setRef:(Le,Oe)=>{Oe?T.current.set(Le,Oe):T.current.delete(Le)},style:{top:d.positions[V.key],visibility:d.positions[V.key]===void 0?"hidden":void 0,...u?.key===V.key?{"--hover-x":`${u.left}px`,"--hover-y":`${u.top}px`}:{}},className:u?.key===V.key?"is-hover-preview":""},V.key)),ne.map(V=>(0,A.jsx)(v$,{comment:V,author:t,active:N===V.id,busy:Fe,t:n,statusText:Ut,confirming:o===V.id,onAskDelete:le,onConfirmDelete:me,onCancelDelete:()=>i(null),onActivate:de,onPointerEnter:oe,onPointerLeave:ce,setRef:(Le,Oe)=>{Oe?at.current.set(Le,Oe):at.current.delete(Le)},style:{top:d.positions[`comment:${V.id}`],visibility:d.positions[`comment:${V.id}`]===void 0?"hidden":void 0,...u?.key===`comment:${V.id}`?{"--hover-x":`${u.left}px`,"--hover-y":`${u.top}px`}:{}},className:u?.key===`comment:${V.id}`?"is-hover-preview":""},V.id))]}),j.length>0&&(0,A.jsxs)("section",{className:"space-comment-stale","aria-label":n("comment.staleGroup"),children:[(0,A.jsx)("h3",{children:n("comment.staleGroup")}),(0,A.jsx)("p",{className:"space-muted",children:n("comment.staleHint")}),j.map(V=>(0,A.jsx)(v$,{comment:V,author:t,active:N===V.id,busy:Fe,t:n,statusText:Ut,confirming:o===V.id,onAskDelete:le,onConfirmDelete:me,onCancelDelete:()=>i(null),onActivate:()=>{},setRef:(Le,Oe)=>{Oe?at.current.set(Le,Oe):at.current.delete(Le)}},V.id))]})]}),d.lines.length>0&&(0,A.jsx)("svg",{className:"space-comment-lines","aria-hidden":"true",children:d.lines.map(V=>(0,A.jsxs)("g",{className:V.active?"is-active":void 0,children:[(0,A.jsx)("path",{pathLength:"1",className:`space-connector-line ${V.kind==="suggestion"?"is-suggestion":"is-comment"}`,d:V.d}),(0,A.jsx)("circle",{className:`space-connector-dot is-origin ${V.kind==="suggestion"?"is-suggestion":"is-comment"}`,cx:V.x1,cy:V.y1,r:"2"}),(0,A.jsx)("circle",{className:`space-connector-dot is-target ${V.kind==="suggestion"?"is-suggestion":"is-comment"}`,cx:V.x2,cy:V.y2,r:"4"})]},V.key))})]}),(0,A.jsxs)("div",{className:"space-comment-layer",children:[he&&!r&&!Fe&&(0,A.jsxs)("button",{ref:w,type:"button",className:`space-comment-fab${!k&&Et?" is-below":""}${k?" is-positioned":""}`,style:k||{left:Qt,top:Et?(un?.bottom||0)+10:(un?.top||0)-10},onMouseDown:V=>V.preventDefault(),onClick:Z,"aria-haspopup":"dialog","aria-label":n("comment.bubble"),children:[(0,A.jsx)(Zme,{}),(0,A.jsx)("span",{children:n("comment.bubble")})]}),(0,A.jsx)(nm,{open:!!(he&&r),onClose:()=>{a(!1),st("")},labelledBy:g,title:n("comment.addTitle"),closeLabel:n("dialog.close"),className:"space-comment-dialog",actions:he&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",onClick:$,children:n("comment.cancel")}),(0,A.jsx)("button",{type:"button",className:"is-primary",disabled:Fe||!ie.trim(),onClick:te,children:n("comment.save")})]}),children:he&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("p",{className:"space-comment-selected",children:n("comment.selected",{quote:he.quote})}),(0,A.jsx)("label",{htmlFor:h,children:n("comment.label")}),(0,A.jsx)("textarea",{ref:m,autoFocus:!0,id:h,rows:"4",maxLength:"4000",value:ie,onChange:V=>{fe(V.target.value),D&&st("")},onKeyDown:V=>{(V.metaKey||V.ctrlKey)&&V.key==="Enter"&&(V.preventDefault(),!Fe&&ie.trim()&&te())}}),D&&(0,A.jsx)("p",{className:"space-comment-error",role:"alert",children:D})]})}),(0,A.jsxs)(nm,{open:!!e.editSaveError,onClose:e.dismissEditSaveError,labelledBy:x,title:n("edit.saveErrorTitle"),closeLabel:n("dialog.close"),className:"space-comment-dialog",actions:(0,A.jsx)("button",{type:"button",autoFocus:!0,onClick:e.dismissEditSaveError,children:n("edit.keepEditing")}),children:[(0,A.jsx)("p",{role:"alert",children:e.editSaveError}),(0,A.jsx)("p",{className:"space-muted",children:n("edit.saveErrorKeepEditing")})]}),r&&he?.rects?.map((V,Le)=>(0,A.jsx)("span",{className:"space-selection-hint",style:{left:V.left,top:V.top,width:V.width,height:V.height}},Le))]})]})}function S$({adapter:e,t=ub}){let n=e.conversation?.current?.id||null,r=e.core.request,[a,o]=(0,ae.useState)([]),[i,s]=(0,ae.useState)(null),[l,u]=(0,ae.useState)(""),[c,f]=(0,ae.useState)(!1),[d,p]=(0,ae.useState)(null),[h,g]=(0,ae.useState)(""),[x,m]=(0,ae.useState)("all"),[y,b]=(0,ae.useState)("recent"),[v,w]=(0,ae.useState)(null),[k,_]=(0,ae.useState)(!1),[E,M]=(0,ae.useState)(null),[S,U]=(0,ae.useState)(""),[N,q]=(0,ae.useState)("document"),[ie,fe]=(0,ae.useState)(""),[he,xe]=(0,ae.useState)("idle"),[Ce,Fe]=(0,ae.useState)(!1),[D,st]=(0,ae.useState)(!1),[Ke,T]=(0,ae.useState)(null),[at,yt]=(0,ae.useState)(!1),Ut=(0,ae.useId)(),ln=(0,ae.useId)(),mt=f$(e.identity?.getCurrentUser),be=ege(r,i,n,t,e,d),Tt=(0,ae.useRef)(t);Tt.current=t;let Dt=(0,ae.useCallback)((oe,ce={})=>r(oe,ce),[r]),vt=(0,ae.useRef)(null),I=(0,ae.useCallback)(async()=>{let oe=await Dt("listDocuments"),ce=JSON.stringify(oe);return ce!==vt.current&&(vt.current=ce,o(oe)),oe},[Dt]);(0,ae.useEffect)(()=>{let oe=!1;return I().catch(ce=>{oe||u(ks(ce,Tt.current))}),()=>{oe=!0}},[I]),(0,ae.useEffect)(()=>{if(i)return;let oe=!1,ce=()=>{!oe&&document.visibilityState!=="hidden"&&I().catch(()=>{})},Ee=setInterval(ce,4e3);return document.addEventListener("visibilitychange",ce),()=>{oe=!0,clearInterval(Ee),document.removeEventListener("visibilitychange",ce)}},[i,I]);let R=async()=>{f(!0),u("");try{let oe=await Dt("createDocument",{title:t("document.untitled"),operationId:lb()});await I(),p(oe.id),s(oe.id)}catch(oe){u(ks(oe,t))}finally{f(!1)}},z=async()=>{if(v){f(!0),u("");try{await Dt("deleteDocument",{docId:v.id}),await I(),w(null),i===v.id&&s(null)}catch(oe){u(ks(oe,Tt.current))}finally{f(!1)}}},ne=async oe=>{st(!0),u("");try{let ce=await Dt("readDocument",{docId:i});if(!ce||typeof ce.content!="string")throw new Error("Document unavailable");let Ee=l$(ce.title,oe),tt=oe==="md"?{name:Ee,type:"text/markdown;charset=utf-8",bytes:new TextEncoder().encode(ce.content)}:oe==="docx"?{name:Ee,type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",bytes:new Uint8Array(await u$(ce.content).arrayBuffer())}:null;if(!tt||!tm(e.capabilities,"files.export.save")||typeof e.files?.saveExport!="function")throw new Error("Export saving is unavailable");if(await e.files.saveExport(tt)!==!0)throw new Error("Export saving was not accepted")}catch{u(t("export.failed"))}finally{st(!1)}},j=async oe=>{M(null),U(""),q(oe),fe(""),xe("idle"),_(!0),Fe(!0);try{let ce=await Dt("readCollaboration",{docId:oe==="document"?i:void 0});M(ce),fe((oe==="global"?ce.global:ce.document)?.content||"")}catch(ce){U(ce?.code==="METHOD_NOT_FOUND"?t("collab.backendOutdated"):ks(ce,t))}finally{Fe(!1)}},W=(0,ae.useCallback)(async oe=>{let ce=N==="global"?E?.global:E?.document;xe("saving");try{await Dt("saveInstructions",{scope:N,docId:N==="document"?i:void 0,content:oe,baseVersion:ce?.version||0,operationId:lb()});let Ee=await Dt("readCollaboration",{docId:N==="document"?i:void 0});M(Ee),xe("saved")}catch(Ee){U(Ee?.code==="METHOD_NOT_FOUND"?t("collab.backendOutdated"):ks(Ee,t)),xe("error")}},[Dt,i,N,E,t]),Y=async()=>{await W(ie)},se=()=>{_(!1)},K=async()=>{be.editing&&!await be.switchToReview()||s(null)},Z=be.comments.filter(oe=>!["sent","processed"].includes(oe.status)),$=a.find(oe=>oe.id===i),te=Ke?Ke.docId?m$(`space:${encodeURIComponent(Ke.docId)}`):"\u8BF7\u6839\u636E\u6211\u7684\u8981\u6C42\uFF0C\u901A\u8FC7 CoSpace MCP \u521B\u5EFA\u4E00\u4EFD\u65B0\u6587\u6863\u5E76\u63D0\u4EA4\u5B8C\u6574\u521D\u7A3F\u3002":"",le=async()=>{try{await navigator.clipboard.writeText(te),yt(!0)}catch{yt(!1)}},me=a.reduce((oe,ce)=>oe+(ce.pending||0),0),P=(0,ae.useMemo)(()=>{let oe=h.trim().toLocaleLowerCase(),ce=Ee=>{let tt=Date.parse(Ee.updatedAt||Ee.createdAt||"");return Number.isFinite(tt)?tt:0};return a.filter(Ee=>(!oe||(Ee.title||Ee.id||"").toLocaleLowerCase().includes(oe))&&(x!=="pending"||Ee.pending>0)).sort((Ee,tt)=>y==="title"?(Ee.title||Ee.id||"").localeCompare(tt.title||tt.id||"",void 0,{numeric:!0}):ce(tt)-ce(Ee))},[a,h,x,y]),G=!i,de=N==="global"?E?.global:E?.document,ve=!!E&&ie!==(de?.content||"");return(0,A.jsxs)("div",{className:"space-app",children:[G?(0,A.jsxs)("main",{className:"space-home","aria-labelledby":"space-home-title",children:[(0,A.jsxs)("header",{className:"space-home-header",children:[(0,A.jsxs)("div",{className:"space-brand",children:[(0,A.jsx)(Xme,{className:"space-brand-icon"}),(0,A.jsxs)("span",{className:"space-brand-names",children:[(0,A.jsx)("strong",{children:t("brand.name")}),(0,A.jsxs)("small",{children:[t("brand.nameEnglish")," ",(0,A.jsxs)("span",{className:"space-build-version",title:t("build.versionTitle"),children:["v",Kme]})]})]})]}),(0,A.jsxs)("div",{className:"space-header-tools",children:[e.prompts&&(0,A.jsx)("button",{type:"button",className:"space-collab-trigger",onClick:()=>T({kind:"create"}),children:"\u8BA9 Agent \u8D77\u8349"}),(0,A.jsxs)("button",{type:"button",className:"space-home-new",disabled:c,onClick:R,children:[(0,A.jsx)(Vd,{size:16,"aria-hidden":"true"}),t("nav.newDocument")]})]})]}),(0,A.jsxs)("section",{className:"space-home-intro",children:[(0,A.jsxs)("div",{children:[(0,A.jsx)("p",{className:"space-home-eyebrow",children:t("home.eyebrow")}),(0,A.jsx)("h1",{id:"space-home-title",children:t("home.title")}),(0,A.jsx)("p",{className:"space-home-description",children:t("home.description")})]}),(0,A.jsxs)("div",{className:"space-home-stats","aria-label":t("nav.aria"),children:[(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:a.length}),t("home.documentCount",{count:a.length})]}),(0,A.jsx)("i",{"aria-hidden":"true"}),(0,A.jsxs)("span",{children:[(0,A.jsx)("strong",{children:me}),t("home.pendingCount",{count:me})]})]})]}),(0,A.jsxs)("section",{className:"space-home-content","aria-label":t("nav.documents"),children:[(0,A.jsxs)("div",{className:"space-home-section-title",children:[(0,A.jsx)("h2",{children:t("nav.documents")}),a.length>0&&(0,A.jsx)("span",{children:a.length})]}),a.length>0&&(0,A.jsxs)("div",{className:"space-document-tools",children:[(0,A.jsxs)("label",{className:"space-document-search",children:[(0,A.jsx)(_g,{size:16,"aria-hidden":"true"}),(0,A.jsx)("span",{className:"space-visually-hidden",children:t("home.search")}),(0,A.jsx)("input",{type:"search",value:h,onChange:oe=>g(oe.target.value),placeholder:t("home.search")})]}),(0,A.jsx)("span",{className:"space-visually-hidden",children:t("home.filter")}),(0,A.jsx)(x$,{label:t("home.filter"),value:x,onChange:m,options:[{value:"all",label:t("home.filterAll")},{value:"pending",label:t("home.filterPending")}]}),(0,A.jsx)("span",{className:"space-visually-hidden",children:t("home.sort")}),(0,A.jsx)(x$,{label:t("home.sort"),value:y,onChange:b,options:[{value:"recent",label:t("home.sortRecent")},{value:"title",label:t("home.sortTitle")}]})]}),P.length?(0,A.jsx)("div",{className:"space-home-grid",children:P.map((oe,ce)=>(0,A.jsxs)("article",{className:"space-home-card",children:[(0,A.jsxs)("button",{type:"button",className:"space-home-card-open","aria-label":t("home.openDocument",{title:oe.title||oe.id}),onClick:()=>s(oe.id),children:[(0,A.jsxs)("span",{className:`space-home-card-art is-tone-${ce%4}`,"aria-hidden":"true",children:[(0,A.jsxs)("span",{className:"space-paper-icon",children:[(0,A.jsx)("i",{}),(0,A.jsx)("i",{}),(0,A.jsx)("i",{}),(0,A.jsx)("b",{})]}),(0,A.jsx)("span",{className:"space-home-card-art-label",children:kn.name.en.toUpperCase()})]}),(0,A.jsxs)("span",{className:"space-home-card-copy",children:[(0,A.jsx)("strong",{title:oe.title||oe.id,children:oe.title||oe.id}),(0,A.jsx)("span",{className:"space-home-card-meta",children:Wme(oe,t)})]}),(0,A.jsxs)("span",{className:"space-home-card-footer",children:[oe.pending>0?(0,A.jsxs)("span",{className:"space-home-pending",children:[(0,A.jsx)("i",{"aria-hidden":"true"}),t("annotations.suggestions",{count:oe.pending})]}):(0,A.jsx)("span",{className:"space-home-clear",children:t("home.noPending")}),(0,A.jsx)("span",{className:"space-home-open-icon","aria-hidden":"true",children:"\u2197"})]})]}),(0,A.jsx)("button",{type:"button",className:"space-home-delete",disabled:c,"aria-label":t("nav.deleteDocumentLabel",{title:oe.title||oe.id}),title:t("nav.deleteDocument"),onClick:()=>w(oe),children:(0,A.jsx)(Yme,{size:15})})]},oe.id))}):a.length?(0,A.jsx)("p",{className:"space-document-no-results",role:"status",children:t("home.noResults")}):(0,A.jsxs)("div",{className:"space-home-empty",children:[(0,A.jsxs)("span",{className:"space-empty-mark","aria-hidden":"true",children:[(0,A.jsx)("span",{}),(0,A.jsx)("span",{}),(0,A.jsx)("span",{})]}),(0,A.jsx)("h2",{children:t("home.emptyTitle")}),(0,A.jsx)("p",{children:t("home.emptyDescription")}),(0,A.jsxs)("button",{type:"button",className:"space-home-new",disabled:c,onClick:R,children:[(0,A.jsx)(Vd,{size:16,"aria-hidden":"true"}),t("nav.newDocument")]})]})]}),(0,A.jsx)("div",{className:"space-message space-home-message",role:"status","aria-live":"polite",children:l})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("header",{className:"space-top space-preview-top",children:[(0,A.jsx)(Jme,{className:"space-back",label:t("home.back"),disabled:c||be.busy,onClick:K,children:(0,A.jsx)(Ag,{size:18,"aria-hidden":"true"})}),(0,A.jsxs)("div",{className:"space-preview-heading",children:[(0,A.jsxs)("span",{children:[t("home.eyebrow")," ",(0,A.jsx)("small",{className:"space-build-version",title:t("build.versionTitle"),children:k$})]}),(0,A.jsx)("h1",{title:be.doc?.title||$?.title||i,children:be.doc?.title||$?.title||i})]}),(0,A.jsxs)("div",{className:"space-header-tools",role:"group","aria-label":t("toolbar.aria"),children:[be.doc&&(0,A.jsx)(Qme,{exporting:D,onExport:ne,onReview:e.prompts?()=>T({kind:"review",docId:i}):null,onPreferences:()=>j("document"),canExport:tm(e.capabilities,"files.export.save"),t}),be.doc&&(0,A.jsxs)("div",{className:"space-toolbar-group is-view",children:[(0,A.jsxs)("div",{className:"space-mode-switch",role:"group","aria-label":t("edit.modeLabel"),children:[(0,A.jsx)("button",{type:"button","aria-pressed":!be.editing,disabled:c||be.busy,title:be.editing?t("edit.autoSaveHint"):void 0,onClick:()=>be.editing?be.switchToReview():null,children:t("edit.reviewMode")}),(0,A.jsxs)("span",{className:`space-edit-mode-option${!be.canEdit&&!be.editing?" is-unavailable":""}`,tabIndex:!be.canEdit&&!be.editing?0:void 0,"aria-describedby":!be.canEdit&&!be.editing?ln:void 0,"data-tooltip":t("edit.unavailableReason"),children:[(0,A.jsx)("button",{type:"button","aria-pressed":be.editing,disabled:c||be.busy||!be.canEdit&&!be.editing,onClick:()=>be.editing?null:be.startEditing(),children:t("edit.editMode")}),!be.canEdit&&!be.editing&&(0,A.jsx)("span",{id:ln,role:"tooltip",className:"space-edit-tooltip",children:t("edit.unavailableReason")})]})]}),(0,A.jsx)(tge,{review:be,t})]}),be.editing&&be.busy&&(0,A.jsx)("span",{className:"space-edit-status",role:"status",children:t("edit.saving")}),!be.editing&&Z.length>0&&(0,A.jsx)(age,{review:be,sessionId:n,adapter:e,t})]})]}),be.doc?(0,A.jsx)("main",{className:"space-main",children:(0,A.jsx)(ige,{review:be,user:mt,t})}):(0,A.jsx)("main",{className:"space-preview-loading","aria-live":"polite",children:be.message||t("empty.loading")})]}),!G&&(0,A.jsx)("div",{className:"space-message",role:"status","aria-live":"polite",children:be.editSaveError?"":l||(be.doc?be.message:"")}),(0,A.jsxs)(nm,{open:!!Ke,onClose:()=>{T(null),yt(!1)},labelledBy:"space-agent-prompt-title",title:"\u53D1\u9001\u7ED9 Agent \u7684\u63D0\u793A\u8BCD",closeLabel:t("dialog.close"),actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",onClick:()=>{T(null),yt(!1)},children:t("dialog.close")}),(0,A.jsx)("button",{type:"button",className:"is-primary",onClick:le,children:at?"\u5DF2\u590D\u5236":"\u590D\u5236\u63D0\u793A\u8BCD"})]}),children:[e.prompts?.mcpReady===!1&&(0,A.jsx)("p",{children:"\u8BF7\u5148\u5728 Agent \u63A5\u5165\u8BBE\u7F6E\u4E2D\u914D\u7F6E CoSpace MCP\u3002"}),(0,A.jsx)("textarea",{readOnly:!0,rows:"8",value:te})]}),(0,A.jsx)(nm,{open:!!v,onClose:()=>w(null),labelledBy:Ut,title:t("document.deleteTitle"),closeLabel:t("dialog.close"),className:"space-delete-dialog",actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("button",{type:"button",autoFocus:!0,disabled:c,onClick:()=>w(null),children:t("document.deleteCancel")}),(0,A.jsx)("button",{type:"button",className:"is-danger",disabled:c,onClick:z,children:t("document.deleteConfirm")})]}),children:(0,A.jsx)("p",{children:t("document.deleteDescription",{title:v?.title||v?.id||""})})}),(0,A.jsxs)(nm,{open:k,onClose:se,labelledBy:"space-collab-title",title:t("collab.documentTitle"),closeLabel:t("dialog.close"),closeOnBackdrop:!0,actions:(0,A.jsx)("button",{type:"button",className:"is-primary",disabled:!ve||he==="saving"||Ce||!!S,onClick:Y,children:t("collab.save")}),children:[S&&(0,A.jsx)("p",{className:"space-collab-error",role:"alert",children:S}),Ce&&!E?(0,A.jsx)("p",{role:"status",children:t("collab.loading")}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("textarea",{rows:"8",maxLength:12e3,value:ie,onChange:oe=>{U(""),xe("idle"),fe(oe.target.value)},placeholder:t("collab.placeholder")}),(0,A.jsx)("p",{className:"space-collab-save-status",role:"status",children:he==="saving"?t("collab.saving"):he==="saved"?t("collab.saved"):he==="error"?t("collab.saveError"):""})]})]})]})}var L$="/cospace-api";async function AR(e,t={},n={}){let r=window.__COSPACE_LOCAL_TOKEN__,a=await fetch(L$,{method:"POST",headers:{"content-type":"application/json",...r?{"x-cospace-token":r}:{}},body:JSON.stringify({method:e,args:t}),...n.signal?{signal:n.signal}:{}}),o=await a.json();if(!a.ok||o.error)throw Object.assign(new Error(o.error?.message||"Request failed"),o.error||{code:"REQUEST_FAILED"});return o.result}var A$=gr(Nf(),1);function lge({name:e,type:t,bytes:n}){if(typeof Blob>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;let r=URL.createObjectURL(new Blob([n],{type:t})),a=document.createElement("a");return a.href=r,a.download=e,a.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3),!0}var uge={id:"local-server",version:"0.1.12",contractVersion:1,capabilities:["files.export.save","clipboard.write","identity.current.read"]},ER=["identity.current.read"];typeof Blob<"u"&&typeof URL?.createObjectURL=="function"&&ER.push("files.export.save");typeof navigator<"u"&&typeof navigator.clipboard?.writeText=="function"&&ER.push("clipboard.write");var cge={core:{request:AR},prompts:{mcpReady:!0},files:{saveExport:lge},clipboard:{writeText:e=>navigator.clipboard.writeText(e)},identity:{getCurrentUser:()=>AR("getUser")},capabilities:h$(uge,ER)};(0,I$.createRoot)(document.getElementById("root")).render((0,A$.jsx)(S$,{adapter:cge}));
|
|
694
694
|
/*! Bundled license information:
|
|
695
695
|
|
|
696
696
|
react/cjs/react.production.js:
|