@covro/covro 0.2.0 → 0.2.1-dev.2
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.
|
@@ -36,15 +36,15 @@ Error generating stack: `+e.message+`
|
|
|
36
36
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
37
37
|
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=H_(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}G_.peek=K_;function G_(e){return e.value||``}function K_(){return`<`}q_.peek=J_;function q_(e,t,n,r){let i=I_(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function J_(){return`!`}Y_.peek=X_;function Y_(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function X_(){return`!`}Z_.peek=Q_;function Z_(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Q_(){return"`"}function $_(e,t){let n=bd(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}ev.peek=tv;function ev(e,t,n,r){let i=I_(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if($_(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function tv(e,t,n){return $_(e,n)?`<`:`[`}nv.peek=rv;function nv(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function rv(){return`[`}function iv(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function av(e){let t=iv(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function ov(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function sv(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function cv(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?ov(n):iv(n),s=e.ordered?o===`.`?`)`:`.`:av(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),sv(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function lv(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function uv(e,t,n,r){let i=lv(n),a=n.bulletCurrent||iv(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function dv(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function fv(e,t,n,r){if(!e.children.some(function(e){return T_(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function pv(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}mv.attention=hv,mv.peek=gv;function mv(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function hv(e,t){return{construct:`strong`,markers:pv(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function gv(e,t,n){return n.options.strong||`*`}function _v(e,t,n,r){let i=t?t.children:[],a=i.indexOf(e);return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function vv(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function yv(e,t,n){let r=(sv(n)+(n.options.ruleSpaces?` `:``)).repeat(vv(n));return n.options.ruleSpaces?r.slice(0,-1):r}var bv={blockquote:E_,break:A_,code:P_,definition:L_,emphasis:z_,hardBreak:A_,heading:W_,html:G_,image:q_,imageReference:Y_,inlineCode:Z_,link:ev,linkReference:nv,list:cv,listItem:uv,paragraph:dv,root:fv,strong:mv,text:_v,thematicBreak:yv};function xv(){return{enter:{table:Sv,tableData:Ev,tableHeader:Ev,tableRow:wv},exit:{codeText:Dv,table:Cv,tableData:Tv,tableHeader:Tv,tableRow:Tv}}}function Sv(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Cv(e){this.exit(e),this.data.inTable=void 0}function wv(e){this.enter({type:`tableRow`,children:[]},e)}function Tv(e){this.exit(e)}function Ev(e){this.enter({type:`tableCell`,children:[]},e)}function Dv(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Ov));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Ov(e,t){return t===`|`?t:e}function kv(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
38
38
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
39
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return S_(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=bv.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Av(){return{exit:{taskListCheckValueChecked:Mv,taskListCheckValueUnchecked:Mv,paragraph:Nv}}}function jv(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Pv}}}function Mv(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Nv(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Pv(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=bv.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Fv(){return[zg(),l_(),m_(),xv(),Av()]}function Iv(e){return{extensions:[Bg(),u_(e),h_(),kv(e),jv()]}}var Lv={tokenize:Zv,partial:!0},Rv={tokenize:Qv,partial:!0},zv={tokenize:$v,partial:!0},Bv={tokenize:ey,partial:!0},Vv={tokenize:ty,partial:!0},Hv={name:`wwwAutolink`,tokenize:Yv,previous:ny},Uv={name:`protocolAutolink`,tokenize:Xv,previous:ry},Wv={name:`emailAutolink`,tokenize:Jv,previous:iy},Gv={};function Kv(){return{text:Gv}}for(var qv=48;qv<123;)Gv[qv]=Wv,qv++,qv===58?qv=65:qv===91&&(qv=97);Gv[43]=Wv,Gv[45]=Wv,Gv[46]=Wv,Gv[95]=Wv,Gv[72]=[Wv,Uv],Gv[104]=[Wv,Uv],Gv[87]=[Wv,Hv],Gv[119]=[Wv,Hv];function Jv(e,t,n){let r=this,i,a;return o;function o(t){return!ay(t)||!iy.call(r,r.previous)||oy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return ay(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Vv,u,l)(t):t===45||t===95||Fd(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Pd(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Yv(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!ny.call(r,r.previous)||oy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Lv,e.attempt(Rv,e.attempt(zv,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Xv(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&ry.call(r,r.previous)&&!oy(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Pd(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ld(t)||Vd(t)||Wd(t)||Ud(t)?n(t):e.attempt(Rv,e.attempt(zv,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Zv(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Qv(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Bv,c,s)(t):t===null||Vd(t)||Wd(t)||t!==45&&Ud(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function $v(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Bv,t,a)(o):o===null||Vd(o)||Wd(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function ey(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Vd(o)||Wd(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Vd(e)||Wd(e)?t(e):r(e)}function a(e){return Pd(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Pd(t)?(e.consume(t),o):n(t)}}function ty(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Fd(e)?n(e):t(e)}}function ny(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Vd(e)}function ry(e){return!Pd(e)}function iy(e){return!(e===47||ay(e))}function ay(e){return e===43||e===45||e===46||e===95||Fd(e)}function oy(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var sy={tokenize:hy,partial:!0};function cy(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:fy,continuation:{tokenize:py},exit:my}},text:{91:{name:`gfmFootnoteCall`,tokenize:dy},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:ly,resolveTo:uy}}}}function ly(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Nd(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function uy(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function dy(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Vd(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Nd(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Vd(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function fy(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Vd(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Nd(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Vd(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),qd(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function py(e,t,n){return e.check(ff,t,e.attempt(sy,t,n))}function my(e){e.exit(`gfmFootnoteDefinition`)}function hy(e,t,n){let r=this;return qd(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function gy(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Ed(o,o.length,0,af(s,e.slice(r+1,n),t)),Ed(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Ed(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=rf(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=rf(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var _y=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){vy(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function vy(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function yy(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function by(){return{flow:{null:{name:`table`,tokenize:xy,resolveAll:Sy}}}}function xy(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):Z(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Hd(t)?qd(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Vd(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Hd(t)?qd(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Hd(t)?qd(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Z(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Hd(t)?qd(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Z(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Z(n)?(e.exit(`tableRow`),t(n)):Hd(n)?qd(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Vd(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Sy(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new _y;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(wy(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Cy(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Cy(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Cy(f,t,o,i,n,d)):(o[0]=o[1],d=Cy(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&wy(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=yy(t.events,n))}return e}function Cy(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Ty(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Ty(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Ty(t.events,n[2]),a=Ty(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Ty(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function wy(e,t,n,r,i){let a=[],o=Ty(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Ty(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Ey={name:`tasklistCheck`,tokenize:Oy};function Dy(){return{text:{91:Ey}}}function Oy(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Vd(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Z(r)?t(r):Hd(r)?e.check({tokenize:ky},t,n)(r):n(r)}}function ky(e,t,n){return qd(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Ay(e){return kd([Kv(),cy(),gy(e),by(),Dy()])}var jy={};function My(e){let t=this,n=e||jy,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Ay(n)),a.push(Fv()),o.push(Iv(n))}var Ny=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|ico|tiff?|heic|heif)$/i;function Py(e,t=!1){let n=Ne(e);return n&&(t||Ny.test(n))?n:void 0}function Fy(e,t){return`/api/threads/${encodeURIComponent(e)}/images?path=${encodeURIComponent(t)}`}async function Iy(e,t,n){let r=await fetch(Fy(e,t),{credentials:`same-origin`,headers:{Accept:`image/png, image/jpeg, image/gif, image/webp, application/json`},signal:n}),i=r.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase();if(!r.ok){if(i===`application/json`){let e=await r.json();if(e&&typeof e==`object`&&`error`in e){let t=e.error;if(t&&typeof t==`object`&&`code`in t&&typeof t.code==`string`&&`message`in t&&typeof t.message==`string`)throw new Le(r.status,{code:t.code,message:t.message})}}throw Error(r.status===401||r.status===403?`无法读取图片,请确认登录状态和文件访问权限。`:`图片加载失败(${r.status}),请重试。`)}if(!i||![`image/png`,`image/jpeg`,`image/gif`,`image/webp`].includes(i))throw Error(i===`text/html`?`登录可能已过期,请重新登录后预览图片。`:`服务器未返回支持的图片格式。`);return r.blob()}var Ly=(0,O.createContext)({open:()=>{}});function Ry({threadId:e,children:t}){let[n,r]=(0,O.useState)(),i=(0,O.useMemo)(()=>({threadId:e,open:r}),[e]);return(0,W.jsxs)(Ly,{value:i,children:[t,n&&(n.url||e)&&(0,W.jsx)(Gy,{threadId:e,target:n,onClose:()=>r(void 0)},n.url||n.path)]})}function zy(){return(0,O.useContext)(Ly)}function By(e,{path:t,url:n}){let[r,i]=(0,O.useState)(()=>({src:n})),[a,o]=(0,O.useState)(0);return(0,O.useEffect)(()=>{if(n){i({src:n});return}if(!e||!t)return;let r=new AbortController,a,o=setTimeout(()=>{r.abort(),i({error:`图片加载超时,请重试。`})},35e3);return i({}),Iy(e,t,r.signal).then(e=>{r.signal.aborted||(a=URL.createObjectURL(e),i({src:a}))}).catch(e=>{r.signal.aborted||i({error:En(e)})}).finally(()=>clearTimeout(o)),()=>{clearTimeout(o),r.abort(),a&&URL.revokeObjectURL(a)}},[e,t,n,a]),{...r,retry:()=>{i({}),o(e=>e+1)},fail:()=>i({error:n?`图片加载失败,可能已失效、访问受限或网络不可用。`:`图片无法解码,文件可能已损坏或格式不受浏览器支持。`})}}function Vy({error:e,path:t,retry:n,url:r}){return(0,W.jsxs)(`span`,{className:`local-image-error`,role:`alert`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`code`,{children:t}),r&&(0,W.jsx)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,children:`打开原图`}),n&&(0,W.jsx)(`button`,{type:`button`,className:`image-retry`,onClick:n,children:`重试加载图片`})]})}function Hy({source:e,alt:t,title:n,interactive:r=!0}){let{threadId:i,open:a}=zy(),o=By(i,e),{path:s,url:c}=e,l=t||(s?s.split(`/`).at(-1):void 0)||`图片`,u=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`img`,{className:`local-image-thumbnail`,src:o.src,alt:t||l,referrerPolicy:c?`no-referrer`:void 0,onError:o.fail}),(0,W.jsxs)(`span`,{className:`local-image-caption`,children:[l,r&&(0,W.jsx)(`span`,{"aria-hidden":`true`,children:` ↗`})]})]});return(0,W.jsx)(`span`,{className:`local-image`,children:o.error?(0,W.jsx)(Vy,{error:o.error,path:c??s,retry:r?o.retry:void 0,url:r?c:void 0}):o.src?r?(0,W.jsx)(ol,{asChild:!0,content:n||`点击放大图片`,children:(0,W.jsx)(`button`,{type:`button`,className:`local-image-open`,"aria-label":`预览图片:${l}`,onClick:()=>a({...e,label:l}),children:u})}):(0,W.jsx)(ol,{asChild:!0,content:n,children:(0,W.jsx)(`span`,{className:`local-image-open`,children:u})}):(0,W.jsxs)(`span`,{className:`local-image-loading`,role:`status`,children:[`正在加载图片…`,(0,W.jsx)(`code`,{children:c||s})]})})}function Uy({path:e,...t}){return(0,W.jsx)(Hy,{source:{path:e},...t})}function Wy({src:e,...t}){return e?(0,W.jsx)(Hy,{source:{url:e},...t}):(0,W.jsx)(`span`,{className:`local-image-error`,role:`alert`,children:`图片地址不可用。`})}function Gy({threadId:e,target:t,onClose:n}){let r=(0,O.useRef)(null),i=(0,O.useRef)(null),a=By(e,t),[o,s]=(0,O.useState)(1),[c,l]=(0,O.useState)({width:0,height:0}),[u,d]=(0,O.useState)({width:0,height:0});(0,O.useEffect)(()=>{let e=r.current,t=document.activeElement;return e?.showModal(),()=>{e?.close(),t instanceof HTMLElement&&t.isConnected&&t.focus()}},[]),(0,O.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(()=>d({width:e.clientWidth,height:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[]);let f=c.width&&u.width?Math.min(1,u.width/c.width,u.height/c.height):0,p=!(!a.src||a.error);return(0,W.jsxs)(`dialog`,{ref:r,className:`image-preview-dialog`,"aria-label":`图片预览`,onCancel:e=>{e.preventDefault(),n()},onKeyDown:e=>{e.ctrlKey||e.metaKey||e.altKey||!p||(e.key===`+`||e.key===`=`?(e.preventDefault(),s(e=>Math.min(4,e+.25))):e.key===`-`?(e.preventDefault(),s(e=>Math.max(.5,e-.25))):e.key===`0`&&(e.preventDefault(),s(1)))},children:[(0,W.jsxs)(`div`,{className:`image-preview-heading`,children:[(0,W.jsx)(`h2`,{children:t.label}),(0,W.jsx)(q,{autoFocus:!0,variant:`ghost`,size:`icon`,"aria-label":`关闭图片预览`,onClick:n,children:(0,W.jsx)(J,{name:`close`,size:19})})]}),(0,W.jsxs)(`div`,{className:`image-preview-toolbar`,"aria-label":`图片缩放`,children:[(0,W.jsx)(q,{variant:`secondary`,size:`sm`,"aria-label":`缩小图片`,disabled:!p||o<=.5,onClick:()=>s(e=>Math.max(.5,e-.25)),children:`−`}),(0,W.jsxs)(`output`,{"aria-label":`图片缩放比例`,children:[Math.round(o*100),`%`]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,"aria-label":`放大图片`,disabled:!p||o>=4,onClick:()=>s(e=>Math.min(4,e+.25)),children:`+`}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:!p,onClick:()=>s(1),children:`适应窗口`}),(0,W.jsx)(`span`,{className:`image-preview-shortcuts`,children:`+ / − 缩放 · Esc 关闭`})]}),(0,W.jsx)(`div`,{className:`image-preview-viewport`,ref:i,tabIndex:0,"aria-label":`图片查看区域`,children:a.error?(0,W.jsx)(Vy,{error:a.error,path:t.url??t.path,retry:a.retry,url:t.url}):a.src?(0,W.jsx)(`div`,{className:`image-preview-canvas`,children:(0,W.jsx)(`img`,{src:a.src,referrerPolicy:t.url?`no-referrer`:void 0,alt:t.label,style:f?{width:c.width*f*o,height:c.height*f*o}:{maxWidth:`100%`},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:a.fail})}):(0,W.jsx)(`span`,{className:`local-image-loading`,role:`status`,children:`正在加载图片…`})}),(0,W.jsxs)(`p`,{className:`image-preview-path`,children:[(0,W.jsx)(`span`,{children:t.url?`原图链接`:`原始路径`}),t.url?(0,W.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,children:`打开原图`}):(0,W.jsx)(`code`,{children:t.path})]})]})}function Ky({children:e}){let t=(0,O.useRef)(null),n=(0,O.useRef)(!1),r=(0,O.useRef)(void 0),[i,a]=(0,O.useState)(`idle`);(0,O.useEffect)(()=>()=>clearTimeout(r.current),[]);async function o(){if(!n.current&&t.current){n.current=!0,clearTimeout(r.current),a(`idle`);try{await navigator.clipboard.writeText(t.current.textContent??``),a(`copied`),r.current=setTimeout(()=>a(`idle`),2e3)}catch{a(`failed`)}finally{n.current=!1}}}return(0,W.jsxs)(`div`,{className:`markdown-code-block`,children:[(0,W.jsxs)(`div`,{className:`markdown-code-toolbar`,children:[(0,W.jsxs)(`span`,{className:`code-copy-feedback code-copy-${i}`,role:`status`,children:[i===`copied`&&`已复制`,i===`failed`&&`复制失败,请手动选择代码复制。`]}),(0,W.jsx)(ol,{asChild:!0,content:`复制代码块`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,className:`code-copy-button`,"aria-label":`复制代码块`,onClick:()=>void o(),children:(0,W.jsx)(J,{name:i===`copied`?`check`:`copy`,size:16})})})]}),(0,W.jsx)(`pre`,{ref:t,tabIndex:0,"aria-label":`代码块`,children:e})]})}var qy=(e,t)=>Py(e,t===`src`)||t===`href`&&Fe(e)?e:Ag(e),Jy=(0,O.createContext)(void 0),Yy=(0,O.createContext)(!1),Xy={pre:Ky,a:function({children:e,href:t,title:n}){let{threadId:r,open:i}=zy(),a=(0,O.useContext)(Jy),o=hb(),s=t?Fe(t):void 0;if(s&&o.threadId){let t=Pe(s,a);return(0,W.jsx)(Yy,{value:!0,children:(0,W.jsx)(`a`,{href:Ie(o.threadId,t),className:`local-file-link`,title:n||`预览文件:${t}`,onClick:e=>{e.preventDefault(),o.open(t)},children:e})})}let c=t?Py(t):void 0,l=c?Pe(c,a):void 0;return l&&r?(0,W.jsx)(Yy,{value:!0,children:(0,W.jsx)(ol,{asChild:!0,content:n||`预览图片:${l}`,children:(0,W.jsx)(`a`,{href:Fy(r,l),className:`local-image-link`,onClick:t=>{t.preventDefault(),i({path:l,label:typeof e==`string`?e:l.split(`/`).at(-1)||`图片`})},children:e})})}):(0,W.jsx)(Yy,{value:!0,children:(0,W.jsx)(ol,{asChild:!0,content:n,children:(0,W.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e})})})},img:function({src:e,alt:t,title:n}){let r=(0,O.useContext)(Yy),i=(0,O.useContext)(Jy),a=typeof e==`string`?Py(e,!0):void 0,o=a?Pe(a,i):void 0;return o?(0,W.jsx)(Uy,{path:o,alt:t,title:n,interactive:!r},o):(0,W.jsx)(Wy,{src:typeof e==`string`?e:``,alt:t,title:n,interactive:!r},String(e))},table:({children:e})=>(0,W.jsx)(`div`,{className:`markdown-table-scroll`,role:`region`,"aria-label":`表格`,tabIndex:0,children:(0,W.jsx)(`table`,{children:e})})};function Zy({text:e,baseFile:t}){return(0,W.jsx)(Jy,{value:t,children:(0,W.jsx)(`div`,{className:`markdown`,children:(0,W.jsx)(Eg,{skipHtml:!0,remarkPlugins:[My],components:Xy,urlTransform:qy,children:e})})})}function Qy({threadId:e,path:t,onClose:n}){let r=/\.json$/i.test(t)?`JSON`:`Markdown`,i=(0,O.useRef)(null),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(0),[d,f]=(0,O.useState)(`preview`),[p,m]=(0,O.useState)(``),h=(0,O.useRef)(!1),g=(0,O.useRef)(void 0);(0,O.useEffect)(()=>()=>clearTimeout(g.current),[]),(0,O.useEffect)(()=>{let n=new AbortController,r=setTimeout(()=>{n.abort(),c(`文件加载超时,请重试。`)},35e3);return o(void 0),c(void 0),ze.previewFile(e,t,n.signal).then(e=>{n.signal.aborted||o(e)}).catch(e=>{n.signal.aborted||c(En(e))}).finally(()=>clearTimeout(r)),()=>{clearTimeout(r),n.abort()}},[e,t,l]);async function _(){if(a&&!h.current){h.current=!0,clearTimeout(g.current),m(``);try{await navigator.clipboard.writeText(a.content),m(`已复制 ${r} 原文`),g.current=setTimeout(()=>m(``),2500)}catch{f(`source`),m(`复制失败,请在原文中手动选择复制。`)}finally{h.current=!1}}}return(0,O.useEffect)(()=>{d===`source`&&i.current?.focus({preventScroll:!0})},[d]),(0,W.jsxs)(zl,{label:`${r} 文件预览`,closeLabel:`关闭文件预览`,title:t.split(`/`).at(-1)??t,subtitle:`${r} 文件`,icon:(0,W.jsx)(me,{size:19,className:`file-preview-icon`,"aria-hidden":`true`}),onClose:n,actions:(0,W.jsxs)(q,{variant:`secondary`,size:`sm`,disabled:!a,onClick:()=>void _(),children:[p.startsWith(`已复制`)?(0,W.jsx)(ee,{size:15}):(0,W.jsx)(se,{size:15}),`复制原文`]}),children:[(0,W.jsxs)(`div`,{className:`file-preview-toolbar`,children:[(0,W.jsxs)(`div`,{role:`group`,"aria-label":`文件展示方式`,children:[(0,W.jsx)(q,{variant:`ghost`,size:`sm`,"aria-pressed":d===`preview`,onClick:()=>f(`preview`),children:`预览`}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,"aria-pressed":d===`source`,onClick:()=>f(`source`),children:`原文`})]}),(0,W.jsx)(`span`,{children:`只读`})]}),(0,W.jsx)(`p`,{className:`file-preview-feedback`,role:`status`,children:p}),(0,W.jsx)(`div`,{className:`file-preview-scroll`,tabIndex:0,"aria-label":`文件内容`,children:s?(0,W.jsxs)(`div`,{className:`file-preview-error`,role:`alert`,children:[(0,W.jsx)(me,{size:28,"aria-hidden":`true`}),(0,W.jsx)(`h3`,{children:`无法预览此文件`}),(0,W.jsx)(`p`,{children:s}),(0,W.jsx)(q,{variant:`secondary`,onClick:()=>u(e=>e+1),children:`重新加载`})]}):a?d===`preview`?r===`JSON`?(0,W.jsx)(Vl,{content:a.content}):(0,W.jsx)(Ry,{threadId:e,children:(0,W.jsx)(Zy,{text:a.content,baseFile:a.path})}):(0,W.jsx)(`pre`,{ref:i,className:`file-preview-source`,tabIndex:0,"aria-label":`${r} 原文`,children:a.content}):(0,W.jsx)(`p`,{className:`file-preview-loading`,role:`status`,children:`正在加载文件…`})},`${l}:${d}`),(0,W.jsx)(`footer`,{className:`file-preview-path`,title:a?.path??t,children:a?.path??t})]})}var $y={added:`新增`,deleted:`删除`,modified:`修改`,renamed:`重命名`};function eb(e,t=!0){let n=e.split(` `)[0];return n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1).replace(/(?:\\[0-7]{1,3})+/g,e=>new TextDecoder().decode(Uint8Array.from([...e.matchAll(/\\([0-7]{1,3})/g)].map(e=>parseInt(e[1],8))))).replace(/\\([\\"tnr])/g,(e,t)=>({t:` `,n:`
|
|
40
|
-
`,r:`\r`})[t]??t)),t?n.replace(/^[ab]\//,``):n}function
|
|
39
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return S_(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=bv.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Av(){return{exit:{taskListCheckValueChecked:Mv,taskListCheckValueUnchecked:Mv,paragraph:Nv}}}function jv(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Pv}}}function Mv(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Nv(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Pv(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=bv.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Fv(){return[zg(),l_(),m_(),xv(),Av()]}function Iv(e){return{extensions:[Bg(),u_(e),h_(),kv(e),jv()]}}var Lv={tokenize:Zv,partial:!0},Rv={tokenize:Qv,partial:!0},zv={tokenize:$v,partial:!0},Bv={tokenize:ey,partial:!0},Vv={tokenize:ty,partial:!0},Hv={name:`wwwAutolink`,tokenize:Yv,previous:ny},Uv={name:`protocolAutolink`,tokenize:Xv,previous:ry},Wv={name:`emailAutolink`,tokenize:Jv,previous:iy},Gv={};function Kv(){return{text:Gv}}for(var qv=48;qv<123;)Gv[qv]=Wv,qv++,qv===58?qv=65:qv===91&&(qv=97);Gv[43]=Wv,Gv[45]=Wv,Gv[46]=Wv,Gv[95]=Wv,Gv[72]=[Wv,Uv],Gv[104]=[Wv,Uv],Gv[87]=[Wv,Hv],Gv[119]=[Wv,Hv];function Jv(e,t,n){let r=this,i,a;return o;function o(t){return!ay(t)||!iy.call(r,r.previous)||oy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return ay(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Vv,u,l)(t):t===45||t===95||Fd(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Pd(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Yv(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!ny.call(r,r.previous)||oy(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Lv,e.attempt(Rv,e.attempt(zv,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Xv(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&ry.call(r,r.previous)&&!oy(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Pd(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Ld(t)||Vd(t)||Wd(t)||Ud(t)?n(t):e.attempt(Rv,e.attempt(zv,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Zv(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Qv(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Bv,c,s)(t):t===null||Vd(t)||Wd(t)||t!==45&&Ud(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function $v(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Bv,t,a)(o):o===null||Vd(o)||Wd(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function ey(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Vd(o)||Wd(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Vd(e)||Wd(e)?t(e):r(e)}function a(e){return Pd(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Pd(t)?(e.consume(t),o):n(t)}}function ty(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Fd(e)?n(e):t(e)}}function ny(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Vd(e)}function ry(e){return!Pd(e)}function iy(e){return!(e===47||ay(e))}function ay(e){return e===43||e===45||e===46||e===95||Fd(e)}function oy(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var sy={tokenize:hy,partial:!0};function cy(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:fy,continuation:{tokenize:py},exit:my}},text:{91:{name:`gfmFootnoteCall`,tokenize:dy},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:ly,resolveTo:uy}}}}function ly(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Nd(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function uy(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function dy(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Vd(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Nd(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Vd(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function fy(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Vd(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Nd(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Vd(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),qd(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function py(e,t,n){return e.check(ff,t,e.attempt(sy,t,n))}function my(e){e.exit(`gfmFootnoteDefinition`)}function hy(e,t,n){let r=this;return qd(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function gy(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Ed(o,o.length,0,af(s,e.slice(r+1,n),t)),Ed(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Ed(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=rf(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=rf(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var _y=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){vy(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function vy(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function yy(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function by(){return{flow:{null:{name:`table`,tokenize:xy,resolveAll:Sy}}}}function xy(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):Z(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Hd(t)?qd(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Vd(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Hd(t)?qd(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Hd(t)?qd(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Z(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Hd(t)?qd(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Z(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Z(n)?(e.exit(`tableRow`),t(n)):Hd(n)?qd(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Vd(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Sy(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new _y;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(wy(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Cy(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Cy(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Cy(f,t,o,i,n,d)):(o[0]=o[1],d=Cy(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&wy(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=yy(t.events,n))}return e}function Cy(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Ty(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Ty(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Ty(t.events,n[2]),a=Ty(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Ty(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function wy(e,t,n,r,i){let a=[],o=Ty(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Ty(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Ey={name:`tasklistCheck`,tokenize:Oy};function Dy(){return{text:{91:Ey}}}function Oy(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Vd(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Z(r)?t(r):Hd(r)?e.check({tokenize:ky},t,n)(r):n(r)}}function ky(e,t,n){return qd(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Ay(e){return kd([Kv(),cy(),gy(e),by(),Dy()])}var jy={};function My(e){let t=this,n=e||jy,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Ay(n)),a.push(Fv()),o.push(Iv(n))}var Ny=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|ico|tiff?|heic|heif)$/i;function Py(e,t=!1){let n=Ne(e);return n&&(t||Ny.test(n))?n:void 0}function Fy(e,t){return`/api/threads/${encodeURIComponent(e)}/images?path=${encodeURIComponent(t)}`}async function Iy(e,t,n){let r=await fetch(Fy(e,t),{credentials:`same-origin`,headers:{Accept:`image/png, image/jpeg, image/gif, image/webp, application/json`},signal:n}),i=r.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase();if(!r.ok){if(i===`application/json`){let e=await r.json();if(e&&typeof e==`object`&&`error`in e){let t=e.error;if(t&&typeof t==`object`&&`code`in t&&typeof t.code==`string`&&`message`in t&&typeof t.message==`string`)throw new Le(r.status,{code:t.code,message:t.message})}}throw Error(r.status===401||r.status===403?`无法读取图片,请确认登录状态和文件访问权限。`:`图片加载失败(${r.status}),请重试。`)}if(!i||![`image/png`,`image/jpeg`,`image/gif`,`image/webp`].includes(i))throw Error(i===`text/html`?`登录可能已过期,请重新登录后预览图片。`:`服务器未返回支持的图片格式。`);return r.blob()}var Ly=(0,O.createContext)({open:()=>{}});function Ry({threadId:e,children:t}){let[n,r]=(0,O.useState)(),i=(0,O.useMemo)(()=>({threadId:e,open:r}),[e]);return(0,W.jsxs)(Ly,{value:i,children:[t,n&&(n.url||e)&&(0,W.jsx)(Gy,{threadId:e,target:n,onClose:()=>r(void 0)},n.url||n.path)]})}function zy(){return(0,O.useContext)(Ly)}function By(e,{path:t,url:n}){let[r,i]=(0,O.useState)(()=>({src:n})),[a,o]=(0,O.useState)(0);return(0,O.useEffect)(()=>{if(n){i({src:n});return}if(!e||!t)return;let r=new AbortController,a,o=setTimeout(()=>{r.abort(),i({error:`图片加载超时,请重试。`})},35e3);return i({}),Iy(e,t,r.signal).then(e=>{r.signal.aborted||(a=URL.createObjectURL(e),i({src:a}))}).catch(e=>{r.signal.aborted||i({error:En(e)})}).finally(()=>clearTimeout(o)),()=>{clearTimeout(o),r.abort(),a&&URL.revokeObjectURL(a)}},[e,t,n,a]),{...r,retry:()=>{i({}),o(e=>e+1)},fail:()=>i({error:n?`图片加载失败,可能已失效、访问受限或网络不可用。`:`图片无法解码,文件可能已损坏或格式不受浏览器支持。`})}}function Vy({error:e,path:t,retry:n,url:r}){return(0,W.jsxs)(`span`,{className:`local-image-error`,role:`alert`,children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(`code`,{children:t}),r&&(0,W.jsx)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,children:`打开原图`}),n&&(0,W.jsx)(`button`,{type:`button`,className:`image-retry`,onClick:n,children:`重试加载图片`})]})}function Hy({source:e,alt:t,title:n,interactive:r=!0}){let{threadId:i,open:a}=zy(),o=By(i,e),{path:s,url:c}=e,l=t||(s?s.split(`/`).at(-1):void 0)||`图片`,u=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`img`,{className:`local-image-thumbnail`,src:o.src,alt:t||l,referrerPolicy:c?`no-referrer`:void 0,onError:o.fail}),(0,W.jsxs)(`span`,{className:`local-image-caption`,children:[l,r&&(0,W.jsx)(`span`,{"aria-hidden":`true`,children:` ↗`})]})]});return(0,W.jsx)(`span`,{className:`local-image`,children:o.error?(0,W.jsx)(Vy,{error:o.error,path:c??s,retry:r?o.retry:void 0,url:r?c:void 0}):o.src?r?(0,W.jsx)(ol,{asChild:!0,content:n||`点击放大图片`,children:(0,W.jsx)(`button`,{type:`button`,className:`local-image-open`,"aria-label":`预览图片:${l}`,onClick:()=>a({...e,label:l}),children:u})}):(0,W.jsx)(ol,{asChild:!0,content:n,children:(0,W.jsx)(`span`,{className:`local-image-open`,children:u})}):(0,W.jsxs)(`span`,{className:`local-image-loading`,role:`status`,children:[`正在加载图片…`,(0,W.jsx)(`code`,{children:c||s})]})})}function Uy({path:e,...t}){return(0,W.jsx)(Hy,{source:{path:e},...t})}function Wy({src:e,...t}){return e?(0,W.jsx)(Hy,{source:{url:e},...t}):(0,W.jsx)(`span`,{className:`local-image-error`,role:`alert`,children:`图片地址不可用。`})}function Gy({threadId:e,target:t,onClose:n}){let r=(0,O.useRef)(null),i=(0,O.useRef)(null),a=By(e,t),[o,s]=(0,O.useState)(1),[c,l]=(0,O.useState)({width:0,height:0}),[u,d]=(0,O.useState)({width:0,height:0});(0,O.useEffect)(()=>{let e=r.current,t=document.activeElement;return e?.showModal(),()=>{e?.close(),t instanceof HTMLElement&&t.isConnected&&t.focus()}},[]),(0,O.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(()=>d({width:e.clientWidth,height:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[]);let f=c.width&&u.width?Math.min(1,u.width/c.width,u.height/c.height):0,p=!(!a.src||a.error);return(0,W.jsxs)(`dialog`,{ref:r,className:`image-preview-dialog`,"aria-label":`图片预览`,onCancel:e=>{e.preventDefault(),n()},onKeyDown:e=>{e.ctrlKey||e.metaKey||e.altKey||!p||(e.key===`+`||e.key===`=`?(e.preventDefault(),s(e=>Math.min(4,e+.25))):e.key===`-`?(e.preventDefault(),s(e=>Math.max(.5,e-.25))):e.key===`0`&&(e.preventDefault(),s(1)))},children:[(0,W.jsxs)(`div`,{className:`image-preview-heading`,children:[(0,W.jsx)(`h2`,{children:t.label}),(0,W.jsx)(q,{autoFocus:!0,variant:`ghost`,size:`icon`,"aria-label":`关闭图片预览`,onClick:n,children:(0,W.jsx)(J,{name:`close`,size:19})})]}),(0,W.jsxs)(`div`,{className:`image-preview-toolbar`,"aria-label":`图片缩放`,children:[(0,W.jsx)(q,{variant:`secondary`,size:`sm`,"aria-label":`缩小图片`,disabled:!p||o<=.5,onClick:()=>s(e=>Math.max(.5,e-.25)),children:`−`}),(0,W.jsxs)(`output`,{"aria-label":`图片缩放比例`,children:[Math.round(o*100),`%`]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,"aria-label":`放大图片`,disabled:!p||o>=4,onClick:()=>s(e=>Math.min(4,e+.25)),children:`+`}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:!p,onClick:()=>s(1),children:`适应窗口`}),(0,W.jsx)(`span`,{className:`image-preview-shortcuts`,children:`+ / − 缩放 · Esc 关闭`})]}),(0,W.jsx)(`div`,{className:`image-preview-viewport`,ref:i,tabIndex:0,"aria-label":`图片查看区域`,children:a.error?(0,W.jsx)(Vy,{error:a.error,path:t.url??t.path,retry:a.retry,url:t.url}):a.src?(0,W.jsx)(`div`,{className:`image-preview-canvas`,children:(0,W.jsx)(`img`,{src:a.src,referrerPolicy:t.url?`no-referrer`:void 0,alt:t.label,style:f?{width:c.width*f*o,height:c.height*f*o}:{maxWidth:`100%`},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:a.fail})}):(0,W.jsx)(`span`,{className:`local-image-loading`,role:`status`,children:`正在加载图片…`})}),(0,W.jsxs)(`p`,{className:`image-preview-path`,children:[(0,W.jsx)(`span`,{children:t.url?`原图链接`:`原始路径`}),t.url?(0,W.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,children:`打开原图`}):(0,W.jsx)(`code`,{children:t.path})]})]})}function Ky({children:e}){let t=(0,O.useRef)(null),n=(0,O.useRef)(!1),r=(0,O.useRef)(void 0),[i,a]=(0,O.useState)(`idle`);(0,O.useEffect)(()=>()=>clearTimeout(r.current),[]);async function o(){if(!n.current&&t.current){n.current=!0,clearTimeout(r.current),a(`idle`);try{await navigator.clipboard.writeText(t.current.textContent??``),a(`copied`),r.current=setTimeout(()=>a(`idle`),2e3)}catch{a(`failed`)}finally{n.current=!1}}}return(0,W.jsxs)(`div`,{className:`markdown-code-block`,children:[(0,W.jsxs)(`div`,{className:`markdown-code-toolbar`,children:[(0,W.jsxs)(`span`,{className:`code-copy-feedback code-copy-${i}`,role:`status`,children:[i===`copied`&&`已复制`,i===`failed`&&`复制失败,请手动选择代码复制。`]}),(0,W.jsx)(ol,{asChild:!0,content:`复制代码块`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,className:`code-copy-button`,"aria-label":`复制代码块`,onClick:()=>void o(),children:(0,W.jsx)(J,{name:i===`copied`?`check`:`copy`,size:16})})})]}),(0,W.jsx)(`pre`,{ref:t,tabIndex:0,"aria-label":`代码块`,children:e})]})}var qy=(e,t)=>Py(e,t===`src`)||t===`href`&&Fe(e)?e:Ag(e),Jy=(0,O.createContext)(void 0),Yy=(0,O.createContext)(!1),Xy={pre:Ky,a:function({children:e,href:t,title:n}){let{threadId:r,open:i}=zy(),a=(0,O.useContext)(Jy),o=vb(),s=t?Fe(t):void 0;if(s&&o.threadId){let t=Pe(s,a);return(0,W.jsx)(Yy,{value:!0,children:(0,W.jsx)(`a`,{href:Ie(o.threadId,t),className:`local-file-link`,title:n||`预览文件:${t}`,onClick:e=>{e.preventDefault(),o.open(t)},children:e})})}let c=t?Py(t):void 0,l=c?Pe(c,a):void 0;return l&&r?(0,W.jsx)(Yy,{value:!0,children:(0,W.jsx)(ol,{asChild:!0,content:n||`预览图片:${l}`,children:(0,W.jsx)(`a`,{href:Fy(r,l),className:`local-image-link`,onClick:t=>{t.preventDefault(),i({path:l,label:typeof e==`string`?e:l.split(`/`).at(-1)||`图片`})},children:e})})}):(0,W.jsx)(Yy,{value:!0,children:(0,W.jsx)(ol,{asChild:!0,content:n,children:(0,W.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:e})})})},img:function({src:e,alt:t,title:n}){let r=(0,O.useContext)(Yy),i=(0,O.useContext)(Jy),a=typeof e==`string`?Py(e,!0):void 0,o=a?Pe(a,i):void 0;return o?(0,W.jsx)(Uy,{path:o,alt:t,title:n,interactive:!r},o):(0,W.jsx)(Wy,{src:typeof e==`string`?e:``,alt:t,title:n,interactive:!r},String(e))},table:({children:e})=>(0,W.jsx)(`div`,{className:`markdown-table-scroll`,role:`region`,"aria-label":`表格`,tabIndex:0,children:(0,W.jsx)(`table`,{children:e})})};function Zy({text:e,baseFile:t}){return(0,W.jsx)(Jy,{value:t,children:(0,W.jsx)(`div`,{className:`markdown`,children:(0,W.jsx)(Eg,{skipHtml:!0,remarkPlugins:[My],components:Xy,urlTransform:qy,children:e})})})}function Qy({threadId:e,path:t,onClose:n}){let r=/\.json$/i.test(t)?`JSON`:`Markdown`,i=(0,O.useRef)(null),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(0),[d,f]=(0,O.useState)(`preview`),[p,m]=(0,O.useState)(``),h=(0,O.useRef)(!1),g=(0,O.useRef)(void 0);(0,O.useEffect)(()=>()=>clearTimeout(g.current),[]),(0,O.useEffect)(()=>{let n=new AbortController,r=setTimeout(()=>{n.abort(),c(`文件加载超时,请重试。`)},35e3);return o(void 0),c(void 0),ze.previewFile(e,t,n.signal).then(e=>{n.signal.aborted||o(e)}).catch(e=>{n.signal.aborted||c(En(e))}).finally(()=>clearTimeout(r)),()=>{clearTimeout(r),n.abort()}},[e,t,l]);async function _(){if(a&&!h.current){h.current=!0,clearTimeout(g.current),m(``);try{await navigator.clipboard.writeText(a.content),m(`已复制 ${r} 原文`),g.current=setTimeout(()=>m(``),2500)}catch{f(`source`),m(`复制失败,请在原文中手动选择复制。`)}finally{h.current=!1}}}return(0,O.useEffect)(()=>{d===`source`&&i.current?.focus({preventScroll:!0})},[d]),(0,W.jsxs)(zl,{label:`${r} 文件预览`,closeLabel:`关闭文件预览`,title:t.split(`/`).at(-1)??t,subtitle:`${r} 文件`,icon:(0,W.jsx)(me,{size:19,className:`file-preview-icon`,"aria-hidden":`true`}),onClose:n,actions:(0,W.jsxs)(q,{variant:`secondary`,size:`sm`,disabled:!a,onClick:()=>void _(),children:[p.startsWith(`已复制`)?(0,W.jsx)(ee,{size:15}):(0,W.jsx)(se,{size:15}),`复制原文`]}),children:[(0,W.jsxs)(`div`,{className:`file-preview-toolbar`,children:[(0,W.jsxs)(`div`,{role:`group`,"aria-label":`文件展示方式`,children:[(0,W.jsx)(q,{variant:`ghost`,size:`sm`,"aria-pressed":d===`preview`,onClick:()=>f(`preview`),children:`预览`}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,"aria-pressed":d===`source`,onClick:()=>f(`source`),children:`原文`})]}),(0,W.jsx)(`span`,{children:`只读`})]}),(0,W.jsx)(`p`,{className:`file-preview-feedback`,role:`status`,children:p}),(0,W.jsx)(`div`,{className:`file-preview-scroll`,tabIndex:0,"aria-label":`文件内容`,children:s?(0,W.jsxs)(`div`,{className:`file-preview-error`,role:`alert`,children:[(0,W.jsx)(me,{size:28,"aria-hidden":`true`}),(0,W.jsx)(`h3`,{children:`无法预览此文件`}),(0,W.jsx)(`p`,{children:s}),(0,W.jsx)(q,{variant:`secondary`,onClick:()=>u(e=>e+1),children:`重新加载`})]}):a?d===`preview`?r===`JSON`?(0,W.jsx)(Vl,{content:a.content}):(0,W.jsx)(Ry,{threadId:e,children:(0,W.jsx)(Zy,{text:a.content,baseFile:a.path})}):(0,W.jsx)(`pre`,{ref:i,className:`file-preview-source`,tabIndex:0,"aria-label":`${r} 原文`,children:a.content}):(0,W.jsx)(`p`,{className:`file-preview-loading`,role:`status`,children:`正在加载文件…`})},`${l}:${d}`),(0,W.jsx)(`footer`,{className:`file-preview-path`,title:a?.path??t,children:a?.path??t})]})}var $y={added:`新增`,deleted:`删除`,modified:`修改`,renamed:`重命名`};function eb(e){let t=0,n=0;for(let r of e.hunks){t+=r.lines.length,n+=r.header.length;for(let e of r.lines)n+=e.text.length}if(t){if(t>300)return`此文件共 ${t} 行,超过 300 行,默认折叠。`;if(n>5e4)return`此文件超过 50,000 字符,默认折叠。`}}function tb(e,t=!0){let n=e.split(` `)[0];return n.startsWith(`"`)&&n.endsWith(`"`)&&(n=n.slice(1,-1).replace(/(?:\\[0-7]{1,3})+/g,e=>new TextDecoder().decode(Uint8Array.from([...e.matchAll(/\\([0-7]{1,3})/g)].map(e=>parseInt(e[1],8))))).replace(/\\([\\"tnr])/g,(e,t)=>({t:` `,n:`
|
|
40
|
+
`,r:`\r`})[t]??t)),t?n.replace(/^[ab]\//,``):n}function nb(e,t){let n=e.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,``).replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,``).replace(/\r\n/g,`
|
|
41
41
|
`);if(!n.trim()&&!t)return[];let r=[],i,a,o=0,s=0,c=0,l=0,u=!1,d=!1,f=()=>{i&&a&&(c!==0||l!==0)&&(i.incomplete=!0),a=void 0},p=e=>(f(),i={path:e,kind:`modified`,additions:0,deletions:0,hunks:[],metadata:[],binary:!1,incomplete:!1},r.push(i),u=!1,d=!1,i),m=n.split(`
|
|
42
|
-
`);m.at(-1)===``&&m.pop();for(let e of m)if(e.startsWith(`diff --git `)){let n=/^diff --git ("(?:\\.|[^"\\])*"|a\/.*?) ("(?:\\.|[^"\\])*"|b\/.*)$/.exec(e);p(n?eb(n[2]):t?.path??`未知文件`)}else if(a&&(c>0||l>0)&&/^[ +\-\\]/.test(e))e.startsWith(`\\`)?a.lines.push({kind:`note`,text:`文件末尾没有换行`}):e.startsWith(`+`)?(a.lines.push({kind:`added`,text:e.slice(1),newLine:s++}),l--,i.additions++):e.startsWith(`-`)?(a.lines.push({kind:`removed`,text:e.slice(1),oldLine:o++}),c--,i.deletions++):(a.lines.push({kind:`context`,text:e.slice(1),oldLine:o++,newLine:s++}),c--,l--);else if(e.startsWith(`--- `)){(!i||d)&&p(t?.path??`未知文件`),f(),u=!0;let n=eb(e.slice(4));n===`/dev/null`?i.kind=`added`:(i.oldPath=n,i.path=n)}else if(e.startsWith(`+++ `)){i??=p(t?.path??`未知文件`),d=!0;let n=eb(e.slice(4));n===`/dev/null`?i.kind=`deleted`:(i.path=n,i.oldPath&&i.oldPath!==n&&(i.kind=`renamed`))}else if(e.startsWith(`@@`)){i??=p(t?.path??`未知文件`),f();let n=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(e);if(!n){i.incomplete=!0,i.metadata.push(e);continue}o=Number(n[1]),s=Number(n[3]),c=Number(n[2]??1),l=Number(n[4]??1),a={header:e,lines:[]},i.hunks.push(a)}else e.startsWith(`\\ No newline`)&&a?a.lines.push({kind:`note`,text:`文件末尾没有换行`}):(e||i)&&(i??=p(t?.path??`未知文件`),(e.startsWith(`[输出已截断`)||e.startsWith(`[内容已截断`))&&(i.incomplete=!0),e.startsWith(`new file mode`)?i.kind=`added`:e.startsWith(`deleted file mode`)?i.kind=`deleted`:e.startsWith(`rename from `)?(i.oldPath=eb(e.slice(12),!1),i.kind=`renamed`):e.startsWith(`rename to `)&&(i.path=eb(e.slice(10),!1),i.kind=`renamed`),/^(Binary files |GIT binary patch)/.test(e)&&(i.binary=!0),!i.binary&&!e.startsWith(`index `)&&e&&i.metadata.push(e));return f(),!r.length&&t&&p(t.path),t&&r.length===1&&(!u&&!d&&(i.path=t.path),t.kind===`add`&&(i.kind=`added`),t.kind===`delete`&&(i.kind=`deleted`)),r}var nb=new Intl.Segmenter(void 0,{granularity:`grapheme`}),rb=e=>Array.from(nb.segment(e),e=>e.segment),ib=new Intl.Segmenter(void 0,{granularity:`word`}),ab=e=>Array.from(ib.segment(e.join(``)),e=>e.segment);function ob(e,t,n){if(!t)return;let r=e.at(-1);r?.changed===n?r.text+=t:e.push({text:t,changed:n})}function sb(e,t,n){let r=rb(e),i=rb(t),a=[],o=[],s=0,c=0;for(;s<r.length&&s<i.length&&r[s]===i[s];)s++;for(;c<r.length-s&&c<i.length-s&&r.at(-c-1)===i.at(-c-1);)c++;ob(a,r.slice(0,s).join(``),!1),ob(o,i.slice(0,s).join(``),!1);let l=ab(r.slice(s,r.length-c)),u=ab(i.slice(s,i.length-c)),d=(l.length+1)*(u.length+1);if(!l.length||!u.length||d>n.cells)ob(a,l.join(``),!0),ob(o,u.join(``),!0);else{n.cells-=d;let e=u.length+1,t=new Uint16Array(d);for(let n=l.length-1;n>=0;n--)for(let r=u.length-1;r>=0;r--)t[n*e+r]=l[n]===u[r]?1+t[(n+1)*e+r+1]:Math.max(t[(n+1)*e+r],t[n*e+r+1]);let r=0,i=0;for(;r<l.length||i<u.length;)r<l.length&&i<u.length&&l[r]===u[i]?(ob(a,l[r++],!1),ob(o,u[i++],!1)):r<l.length&&(i===u.length||t[(r+1)*e+i]>=t[r*e+i+1])?ob(a,l[r++],!0):ob(o,u[i++],!0)}return ob(a,r.slice(r.length-c).join(``),!1),ob(o,i.slice(i.length-c).join(``),!1),[a,o]}function cb(e){let t=e.trim().slice(0,4096),n=new Map,r=0;for(let e of t.match(/[\p{L}\p{N}_]+|[^\s\p{L}\p{N}_]/gu)??[])n.set(e,(n.get(e)??0)+1),r+=e.length;return{trimmed:t,tokens:n,size:r}}function lb(e,t){if(e.trimmed===t.trimmed)return 1;let n=0,r=0,i=0;for(let[r,i]of e.tokens)n+=Math.min(i,t.tokens.get(r)??0)*r.length;let a=e.trimmed,o=t.trimmed;for(;r<a.length&&r<o.length&&a[r]===o[r];)r++;for(;i<a.length-r&&i<o.length-r&&a.at(-i-1)===o.at(-i-1);)i++;return Math.max(2*n/Math.max(1,e.size+t.size),(r+i)/Math.max(1,a.length,o.length))}function ub(e){let t={cells:2e5},n=1e4;return e.map(e=>{let r=[...e.lines];for(let e=0;e<r.length;){if(r[e].kind===`context`){e++;continue}let i=e,a=[],o=[];for(;i<r.length&&r[i].kind!==`context`;)r[i].kind===`removed`&&a.push(i),r[i].kind===`added`&&o.push(i),i++;let s=(a.length+1)*(o.length+1);if(a.length&&o.length&&s<=n){n-=s;let e=a.map(e=>cb(r[e].text)),i=o.map(e=>cb(r[e].text)),c=o.length+1,l=new Float64Array(s),u=new Uint8Array(s);for(let t=a.length-1;t>=0;t--)for(let n=o.length-1;n>=0;n--){let r=lb(e[t],i[n])*2-.5,a=r>0?r+l[(t+1)*c+n+1]:-1,o=l[(t+1)*c+n],s=l[t*c+n+1];l[t*c+n]=Math.max(a,o,s),u[t*c+n]=a>=o&&a>=s?1:o>=s?2:3}let d=0,f=0;for(;d<a.length&&f<o.length;){let e=u[d*c+f];if(e===1){let e=a[d++],n=o[f++],i=r[e],s=r[n];if(i.text!==s.text){let[a,o]=sb(i.text,s.text,t);r[e]={...i,segments:a},r[n]={...s,segments:o}}}else e===2?d++:f++}}e=i}return{...e,lines:r}})}function db({file:e}){return(0,W.jsxs)(`span`,{className:`diff-stats`,"aria-label":`新增 ${e.additions} 行,删除 ${e.deletions} 行`,children:[(0,W.jsxs)(`span`,{children:[`+`,e.additions]}),(0,W.jsxs)(`span`,{children:[`−`,e.deletions]})]})}function fb({target:e,threadId:t,onClose:n}){let[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(0);return(0,O.useEffect)(()=>{let n=new AbortController,r=setTimeout(()=>{n.abort(),o(`读取变更超时,请重试。`)},35e3);return i(void 0),o(void 0),(e.cursor?ze.threadHistory(t,e.cursor,n.signal):ze.thread(t,n.signal)).then(t=>{if(!n.signal.aborted){if(e.source===`turn`){let n=t.turns.find(t=>t.id===e.id);if(!n)throw Error(`此轮变更已不在可读取的会话历史中。`);i({...e,text:n.diff,changes:n.diff===void 0?n.items.flatMap(e=>e.changes??[]):void 0,truncated:t.historyTruncated||n.items.some(e=>e.type===`fileChange`&&e.truncated)})}else{let n=t.turns.flatMap(e=>e.items).find(t=>t.id===e.id);if(!n)throw Error(`此工具的变更已不在可读取的会话历史中。`);i({...e,changes:n.changes??[],truncated:n.truncated})}}}).catch(e=>{n.signal.aborted||o(En(e))}).finally(()=>clearTimeout(r)),()=>{n.abort(),clearTimeout(r)}},[e,t,s]),(0,W.jsxs)(zl,{label:`代码变更预览`,title:`代码变更`,subtitle:`${e.scope} · 只读`,icon:(0,W.jsx)(fe,{size:19,className:`file-preview-icon`,"aria-hidden":`true`}),onClose:n,children:[(0,W.jsx)(`p`,{className:`diff-scope`,children:`Codex 提供的变更快照,仅包含此范围内的补丁,不代表工作区全部未提交变更。`}),a?(0,W.jsxs)(`div`,{className:`diff-empty`,role:`alert`,children:[(0,W.jsx)(`h3`,{children:`无法读取变更`}),(0,W.jsx)(`p`,{children:a}),(0,W.jsx)(q,{variant:`secondary`,onClick:()=>c(e=>e+1),children:`重新加载`})]}):r?(0,W.jsx)(pb,{target:r},s):(0,W.jsx)(`p`,{className:`file-preview-loading diff-loading`,role:`status`,children:`正在读取变更…`})]})}function pb({target:e}){let t=(0,O.useMemo)(()=>e.changes?e.changes.flatMap(e=>tb(e.diff,e)):tb(e.text??``),[e]),[n,r]=(0,O.useState)(()=>Math.max(0,t.findIndex(t=>e.selectedPath!==void 0&&(t.path===e.selectedPath||t.oldPath===e.selectedPath)))),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(0),c=(0,O.useRef)([]),l=t[n],u=(0,O.useMemo)(()=>ub(l?.hunks??[]),[l]),d=l&&!l.binary&&!l.hunks.length&&l.metadata.some(e=>!/^(old mode |new mode |new file mode |deleted file mode |similarity index |dissimilarity index |rename from |rename to )/.test(e));function f(e){r(e),s(0),c.current=[]}function p(e){s(e),c.current[e]?.scrollIntoView({block:`start`})}return(0,W.jsxs)(W.Fragment,{children:[e.truncated&&(0,W.jsx)(`p`,{className:`diff-warning`,role:`status`,children:`补丁已被截断,以下仅展示收到的部分内容。`}),t.length?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`diff-file-picker`,children:[(0,W.jsx)(`label`,{htmlFor:`diff-file-select`,children:`变更文件`}),(0,W.jsx)(`select`,{id:`diff-file-select`,value:n,onChange:e=>f(Number(e.target.value)),children:t.map((e,t)=>(0,W.jsxs)(`option`,{value:t,children:[$y[e.kind],` · `,e.path]},t))}),(0,W.jsxs)(`span`,{children:[n+1,` / `,t.length]})]}),l&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`diff-file-heading`,children:[(0,W.jsx)(`span`,{className:`diff-kind diff-kind-${l.kind}`,children:$y[l.kind]}),(0,W.jsx)(`code`,{children:l.path}),(0,W.jsx)(db,{file:l})]}),l.kind===`renamed`&&l.oldPath&&(0,W.jsxs)(`p`,{className:`diff-rename`,children:[`原路径:`,l.oldPath]}),(0,W.jsxs)(`div`,{className:`diff-controls`,children:[(0,W.jsxs)(q,{variant:`ghost`,size:`sm`,"aria-pressed":i,onClick:()=>a(!i),children:[(0,W.jsx)(Se,{size:15}),`自动换行`]}),(0,W.jsxs)(`div`,{role:`group`,"aria-label":`变更区块导航`,children:[(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`上一个变更区块`,disabled:!l.hunks.length||o===0,onClick:()=>p(o-1),children:(0,W.jsx)(re,{size:16})}),(0,W.jsxs)(`span`,{children:[l.hunks.length?`${o+1} / ${l.hunks.length}`:`0`,` 个区块`]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`下一个变更区块`,disabled:o>=l.hunks.length-1,onClick:()=>p(o+1),children:(0,W.jsx)(R,{size:16})})]})]}),l.incomplete&&(0,W.jsx)(`p`,{className:`diff-warning`,role:`status`,children:`补丁不完整或格式有误,行号与统计仅对应已收到的内容。`}),(0,W.jsx)(`div`,{className:`diff-content${i?` diff-wrap`:``}`,tabIndex:0,"aria-label":`变更内容`,children:l.binary?(0,W.jsxs)(`div`,{className:`diff-empty`,children:[(0,W.jsx)(fe,{size:28}),(0,W.jsx)(`h3`,{children:`二进制文件已变更`}),(0,W.jsx)(`p`,{children:`此文件无法逐行预览。`})]}):d?(0,W.jsxs)(`div`,{className:`diff-empty`,role:`alert`,children:[(0,W.jsx)(`h3`,{children:`无法读取变更内容`}),(0,W.jsx)(`p`,{children:`收到的内容不是可识别的 unified diff。请等待 Codex 更新补丁,或重新打开预览。`})]}):l.hunks.length?(0,W.jsxs)(`table`,{className:`diff-table`,"aria-label":`${l.path} 的行变更`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,children:`原行`}),(0,W.jsx)(`th`,{scope:`col`,children:`新行`}),(0,W.jsx)(`th`,{scope:`col`,"aria-label":`变更类型`}),(0,W.jsx)(`th`,{scope:`col`,children:`代码内容`})]})}),u.map((e,t)=>(0,W.jsxs)(`tbody`,{ref:e=>{c.current[t]=e},children:[(0,W.jsx)(`tr`,{className:`diff-hunk`,children:(0,W.jsxs)(`td`,{colSpan:4,children:[(0,W.jsxs)(`span`,{children:[`区块 `,t+1]}),` `,e.header]})}),e.lines.map((e,t)=>(0,W.jsxs)(`tr`,{className:`diff-line diff-${e.kind}`,children:[(0,W.jsx)(`td`,{className:`diff-line-number`,children:e.oldLine}),(0,W.jsx)(`td`,{className:`diff-line-number`,children:e.newLine}),(0,W.jsx)(`td`,{className:`diff-marker`,"aria-label":{added:`新增`,removed:`删除`,context:`上下文`,note:`提示`}[e.kind],children:e.kind===`added`?`+`:e.kind===`removed`?`−`:``}),(0,W.jsx)(`td`,{className:`diff-code`,children:(0,W.jsx)(`code`,{children:e.segments?e.segments.map((e,t)=>e.changed?(0,W.jsx)(`mark`,{className:`diff-inline-change`,children:e.text},t):e.text):e.text||` `})})]},t))]},t))]}):(0,W.jsxs)(`div`,{className:`diff-empty`,children:[(0,W.jsx)(`h3`,{children:`没有逐行内容变更`}),(0,W.jsx)(`p`,{children:`此补丁仅包含文件属性、路径或空文件变更,没有可展示的代码行。`})]})},n)]})]}):(0,W.jsxs)(`div`,{className:`diff-empty`,role:`status`,children:[(0,W.jsx)(fe,{size:28}),(0,W.jsx)(`h3`,{children:`暂无文件变更`}),(0,W.jsx)(`p`,{children:`此范围内尚未收到可预览的补丁。`})]}),(0,W.jsx)(`footer`,{className:`file-preview-path`,title:l?.path,children:l?.path??e.scope})]})}var mb=(0,O.createContext)({open:()=>{},openDiff:()=>{}}),hb=()=>(0,O.useContext)(mb),gb=()=>(0,O.useContext)(mb).openDiff;function _b({threadId:e,getHistoryCursor:t,children:n}){let[r,i]=(0,O.useState)();(0,O.useEffect)(()=>i(void 0),[e]);let a=(0,O.useCallback)(()=>i(void 0),[]),o=(0,O.useMemo)(()=>({threadId:e,open:t=>{e&&i({threadId:e,kind:`file`,path:t})},openDiff:n=>{e&&i({threadId:e,kind:`diff`,diff:{...n,cursor:t?.(n.id)}})}}),[e,t]);return(0,W.jsxs)(mb,{value:o,children:[n,r&&r.threadId===e&&(r.kind===`file`?(0,W.jsx)(Qy,{threadId:r.threadId,path:r.path,onClose:a},`${e}:${r.path}`):(0,W.jsx)(fb,{threadId:r.threadId,target:r.diff,onClose:a},`${e}:${r.diff.id}`))]})}var vb=`<send_user_message_question_reply>`,yb=`</send_user_message_question_reply>`;function bb(e,t){return JSON.stringify([`request_user_input_async`,e,t])}function xb(e){return`${vb}${JSON.stringify(e)}${yb}`}function Sb({itemId:e,questions:t,replies:n=[],disabled:r,onReply:i}){let a=(0,O.useId)(),[o,s]=(0,O.useState)(()=>t.map(e=>e.options?.length?0:-1)),[c,l]=(0,O.useState)([]),[u,d]=(0,O.useState)(!1),f=(0,O.useRef)(!1),[p,m]=(0,O.useState)(),h=t.map((t,r)=>n.find(t=>t.questionItemId===bb(e,r))?.answer??n.find(n=>n.questionItemId===e&&n.question===t.title)?.answer??p?.[r]),g=h.every(e=>e!==void 0),_=t.map((e,t)=>h[t]??(o[t]===-1?c[t]:e.options?.[o[t]??0])?.trim()??``),v=r||u||!!g;return(0,W.jsxs)(`section`,{className:`async-question-card`,"aria-label":`Codex 的提问`,children:[(0,W.jsxs)(`div`,{className:`async-question-heading`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`chat`,size:16}),`需要你的回答`]}),(0,W.jsx)(`small`,{children:g?`已发送回答`:u?`正在发送…`:`可稍后回答`})]}),(0,W.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),!(v||f.current||_.some(e=>!e))){f.current=!0,d(!0);try{await i(t.flatMap((t,n)=>h[n]===void 0?[{questionItemId:bb(e,n),question:t.title,answer:_[n]}]:[]))&&m(_)}finally{f.current=!1,d(!1)}}},children:[t.map((e,t)=>(0,W.jsxs)(`fieldset`,{disabled:v||h[t]!==void 0,children:[(0,W.jsx)(`legend`,{children:e.title}),h[t]===void 0?(0,W.jsxs)(W.Fragment,{children:[e.options?.map((e,n)=>(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${a}-${t}`,checked:o[t]===n,onChange:()=>s(e=>e.map((e,r)=>r===t?n:e))}),(0,W.jsx)(`span`,{children:e})]},n)),!!e.options?.length&&(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${a}-${t}`,checked:o[t]===-1,onChange:()=>s(e=>e.map((e,n)=>n===t?-1:e))}),(0,W.jsx)(`span`,{children:`自由回答`})]}),o[t]===-1&&(0,W.jsx)(`textarea`,{className:`text-input`,"aria-label":`${e.title}:自由回答`,placeholder:`输入你的回答`,rows:2,maxLength:1e4,value:c[t]??``,onChange:e=>l(n=>{let r=[...n];return r[t]=e.target.value,r})})]}):(0,W.jsx)(`p`,{className:`async-question-answer`,children:h[t]})]},t)),!g&&(0,W.jsxs)(`div`,{className:`async-question-footer`,children:[(0,W.jsx)(`span`,{children:`回答会发送到当前会话,Codex 可以继续执行。`}),(0,W.jsx)(q,{type:`submit`,disabled:v||_.some(e=>!e),children:u?`正在发送…`:`发送回答`})]})]})]})}function Cb({className:e=``,label:t,summary:n,children:r,group:i=!1}){let a=(0,O.useRef)(null),o=(0,O.useRef)(void 0),[s,c]=(0,O.useState)(!1);return(0,O.useLayoutEffect)(()=>{let e=a.current,t=e?.querySelector(`:scope > summary`);if(!i||!e||!t)return;let n=()=>{e.style.setProperty(`--activity-group-header-height`,`${t.getBoundingClientRect().height}px`)};n();let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[i]),(0,O.useEffect)(()=>()=>{o.current!==void 0&&cancelAnimationFrame(o.current)},[]),(0,W.jsxs)(`details`,{ref:a,className:`collapsible-activity${i?` collapsible-activity-group`:``} ${e}`,onToggle:e=>{e.target===e.currentTarget&&c(e.currentTarget.open)},children:[(0,W.jsxs)(`summary`,{"aria-label":`${s?`收起`:`展开`}${t}`,onClick:e=>{let t=a.current,n=t?.closest(`.conversation-scroll`);if(!t?.open||!n)return;let r=e.currentTarget,i=Number.parseFloat(getComputedStyle(r).top)||0,s=n.getBoundingClientRect().top+n.clientTop;t.getBoundingClientRect().top>=s+i||(o.current!==void 0&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{if(o.current=void 0,!t.isConnected||t.open)return;let e=n.getBoundingClientRect().top+n.clientTop;n.scrollTop+=t.getBoundingClientRect().top-e-i-8,r.focus({preventScroll:!0})}))},children:[n,(0,W.jsx)(`span`,{className:`activity-collapse-hint`,"aria-hidden":`true`,children:`收起`}),(0,W.jsx)(J,{name:`chevron`,size:14})]}),r]})}var wb={inProgress:`审核中`,approved:`已允许`,denied:`已拒绝`,timedOut:`审核超时`,aborted:`审核已中止`,unknown:`结果未确认`},Tb={low:`低`,medium:`中`,high:`高`,critical:`极高`},Eb={unknown:`未知`,low:`低`,medium:`中`,high:`高`};function Db(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString(`zh-CN`,{hour12:!1}):`未提供有效时间`}function Ob({review:e}){return(0,W.jsx)(Cb,{className:`auto-review-card auto-review-${e.status}`,label:`自动审核结果:${e.actionSummary||e.actionLabel},${wb[e.status]}`,summary:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{name:e.status===`approved`?`check`:e.status===`denied`?`close`:e.status===`inProgress`?`refresh`:`alert`,size:15}),(0,W.jsxs)(`span`,{className:`activity-description`,children:[(0,W.jsx)(`span`,{className:`activity-label`,children:`自动审核`}),(0,W.jsx)(`code`,{className:`command-summary`,children:e.actionSummary||e.actionLabel})]}),(0,W.jsx)(`span`,{className:`auto-review-status`,role:`status`,children:wb[e.status]})]}),children:(0,W.jsxs)(`div`,{className:`activity-body auto-review-body`,children:[(0,W.jsxs)(`div`,{className:`auto-review-operation`,children:[(0,W.jsx)(`span`,{children:e.actionLabel}),(0,W.jsx)(`code`,{children:e.actionSummary||`未提供被审核操作。`})]}),(0,W.jsxs)(`div`,{className:`auto-review-rationale`,children:[(0,W.jsx)(`strong`,{children:`审核原因`}),(0,W.jsx)(`p`,{children:e.rationale?.trim()?e.rationale:`未提供审核原因。`})]}),(0,W.jsxs)(`details`,{className:`auto-review-details`,children:[(0,W.jsx)(`summary`,{children:`技术详情`}),(0,W.jsxs)(`dl`,{children:[e.cwd&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`工作目录`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.cwd})})]}),e.riskLevel&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`风险评估`}),(0,W.jsx)(`dd`,{children:Tb[e.riskLevel]})]}),e.userAuthorization&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`用户授权评估`}),(0,W.jsx)(`dd`,{children:Eb[e.userAuthorization]})]}),(0,W.jsx)(`dt`,{children:`审核标识`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.reviewId})}),e.targetItemId&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`操作标识`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.targetItemId})})]}),(0,W.jsx)(`dt`,{children:`开始时间`}),(0,W.jsx)(`dd`,{children:Db(e.startedAtMs)}),e.completedAtMs!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`结束时间`}),(0,W.jsx)(`dd`,{children:Db(e.completedAtMs)})]})]})]})]})})}function kb(e){let t=[];for(let n of e){if(n.type===`userMessage`||n.type===`agentMessage`||n.type===`exitedReviewMode`||n.type===`contextCompaction`){t.push({kind:`message`,key:`message:${n.id}`,item:n});continue}let e=t.at(-1);e?.kind===`activity`?e.items.push(n):t.push({kind:`activity`,key:`activity:${n.id}`,items:[n]})}return t}function Ab(e){let t={total:e.length,reviews:0,running:0,completed:0,failed:0,denied:0,timedOut:0,interrupted:0,unknown:0};for(let n of e){let e=n.type===`autoApprovalReview`;e&&(t.reviews+=1);let r=e?n.autoReview?.status??`unknown`:n.status,i=n.details&&typeof n.details==`object`&&!Array.isArray(n.details)?n.details:void 0,a=n.type===`mcpToolCall`&&i?.error!=null||n.type===`dynamicToolCall`&&i?.success===!1||n.type===`imageGeneration`&&i?.failure!=null;n.error||r===`failed`||a?t.failed+=1:r===`denied`||r===`declined`?t.denied+=1:r===`timedOut`?t.timedOut+=1:r===`aborted`||r===`interrupted`?t.interrupted+=1:r===`inProgress`||r===`running`?t.running+=1:r===`approved`||r===`completed`?t.completed+=1:r&&(t.unknown+=1)}return t}function jb({items:e,children:t}){let n=Ab(e),r=e.at(-1),i=r?.autoReview?.actionSummary||r?.command,a=[{count:n.running,label:`执行中`,className:`activity-group-running`},{count:n.failed,label:`失败`,className:`activity-group-problem`},{count:n.denied,label:`已拒绝`,className:`activity-group-problem`},{count:n.timedOut,label:`审核超时`,className:`activity-group-attention`},{count:n.interrupted,label:`已中止`,className:`activity-group-attention`},{count:n.unknown,label:`结果未确认`,className:`activity-group-attention`},{count:n.completed,label:`已完成`,className:``}].filter(({count:e})=>e>0),o=a.map(({label:e,count:t})=>`${e} ${t}`).join(`,`);return(0,W.jsx)(Cb,{className:`activity-group`,group:!0,label:`${n.total} 项活动${o?`,${o}`:``}`,summary:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{name:n.running?`refresh`:`terminal`,size:16}),(0,W.jsxs)(`span`,{className:`activity-description`,children:[(0,W.jsxs)(`span`,{className:`activity-label`,children:[n.total,` 项活动`]}),n.reviews>0&&(0,W.jsxs)(`span`,{className:`activity-group-reviews`,children:[`含 `,n.reviews,` 次自动审核`]}),i&&(0,W.jsx)(`code`,{className:`command-summary`,children:i})]}),(0,W.jsx)(`span`,{className:`activity-group-status`,role:`status`,children:a.map(({label:e,count:t,className:n})=>(0,W.jsxs)(`span`,{className:n,children:[e,` `,t]},e))})]}),children:(0,W.jsx)(`div`,{className:`activity-group-items`,children:t})})}function Mb({item:e,offline:t=!1}){let n=e.status??`unknown`,r=n===`inProgress`,i={inProgress:`正在压缩上下文…`,completed:`上下文已压缩`,failed:`上下文压缩失败`,interrupted:`上下文压缩已中断`}[n]??`上下文压缩状态未知`,a=e.error??(r?`正在整理会话上下文,完成后将继续当前任务。`:n===`unknown`?`未收到明确的完成结果,请查看后续任务状态。`:void 0);return(0,W.jsxs)(`div`,{className:`context-compaction context-compaction-${n}`,"data-testid":`context-compaction`,"data-state":n,role:n===`failed`?`alert`:`status`,"aria-label":`上下文压缩状态`,children:[(0,W.jsx)(`span`,{className:`compaction-icon`,children:(0,W.jsx)(J,{name:n===`failed`?`alert`:n===`completed`?`check`:`compress`,size:18})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[r&&t&&`上次已知:`,i]}),a&&(0,W.jsx)(`p`,{children:a})]})]})}function Nb(e){if(e===void 0||!Number.isFinite(e)||e<0)return;if(e>0&&e<1e3)return`不足 1 秒`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60);return[...n?[`${n} 小时`]:[],...r?[`${r} 分`]:[],...t%60||t===0?[`${t%60} 秒`]:[]].join(` `)}function Pb(e,t){if(e===void 0||!Number.isFinite(e)||e<0)return;let n=new Date(e);if(!Number.isFinite(n.getTime()))return;let r=new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(n),i=e=>r.find(t=>t.type===e).value;return{dateTime:n.toISOString(),label:`${i(`year`)}-${i(`month`)}-${i(`day`)} ${i(`hour`)}:${i(`minute`)}:${i(`second`)}(${i(`timeZoneName`).replace(/^GMT$/,`GMT+00:00`).replace(`GMT`,`UTC`)})`}}function Fb(e,t){if(e===void 0||!Number.isSafeInteger(e)||e<0||t===void 0||!Number.isFinite(t)||t<=0)return;let n=e/(t/1e3);if(Number.isFinite(n))return n>0&&n<.1?`<0.1`:n.toFixed(1)}function Ib({text:e}){let t=(0,O.useRef)(!1),n=(0,O.useRef)(void 0),[r,i]=(0,O.useState)(`idle`);(0,O.useEffect)(()=>()=>clearTimeout(n.current),[]);async function a(){if(!t.current){t.current=!0,clearTimeout(n.current),i(`idle`);try{await navigator.clipboard.writeText(e),i(`copied`),n.current=setTimeout(()=>i(`idle`),2e3)}catch{i(`failed`)}finally{t.current=!1}}}return(0,W.jsxs)(`span`,{className:`reply-copy-controls`,children:[(0,W.jsx)(ol,{asChild:!0,content:`复制回答(Markdown)`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,className:`reply-copy-button`,"aria-label":`复制回答`,onClick:()=>void a(),children:(0,W.jsx)(J,{name:r===`copied`?`check`:`copy`,size:14})})}),(0,W.jsxs)(`span`,{className:`reply-copy-feedback reply-copy-${r}`,role:`status`,children:[r===`copied`&&`已复制`,r===`failed`&&`复制失败,请手动选择回答复制。`]})]})}function Lb({turn:e}){if(e.status!==`completed`)return null;let t=Nb(e.durationMs),n=Pb(e.completedAt),r=Fb(e.outputTokens,e.durationMs),i=e.items.findLast(e=>e.type===`agentMessage`&&e.text?.trim())?.text;return(0,W.jsxs)(`div`,{className:`turn-completion`,role:`group`,"aria-label":`本轮完成信息`,children:[(0,W.jsxs)(`span`,{className:`turn-completion-status`,children:[(0,W.jsx)(J,{name:`check`,size:14}),`已完成`]}),(0,W.jsxs)(`span`,{children:[` · `,t?`耗时 ${t}`:`耗时未知`]}),(0,W.jsxs)(`span`,{children:[` · `,(0,W.jsx)(nl,{children:(0,W.jsxs)(rl,{children:[(0,W.jsx)(il,{asChild:!0,children:(0,W.jsx)(`span`,{className:`turn-tps`,tabIndex:0,children:r===void 0?`TPS 未知`:`平均 ${r} TPS`})}),(0,W.jsx)(al,{children:r===void 0?`缺少完整的本轮 token 统计或有效耗时,无法计算 TPS。`:`本轮输出 ${e.outputTokens} tokens(含推理 token)÷ 整轮耗时(秒)。耗时包含工具调用、审批、等待等时间,因此该值通常低于纯模型生成时的 TPS。`})]})})]}),(0,W.jsxs)(`span`,{children:[` · `,n?(0,W.jsxs)(W.Fragment,{children:[`完成于 `,(0,W.jsx)(`time`,{dateTime:n.dateTime,children:n.label})]}):`完成时间未知`]}),i&&(0,W.jsx)(Ib,{text:i})]})}function Rb({item:e}){return(0,W.jsx)(`article`,{className:`message user-message`,"aria-label":`你的消息`,"data-prompt-id":e.id,tabIndex:-1,children:(0,W.jsxs)(`div`,{className:`message-content`,children:[e.questionReplies?.length?e.questionReplies.map((e,t)=>(0,W.jsxs)(`div`,{className:`user-question-reply`,children:[(0,W.jsx)(`blockquote`,{children:e.question}),(0,W.jsx)(`p`,{className:`user-text`,children:e.answer})]},t)):(0,W.jsx)(`p`,{className:`user-text`,children:e.text}),e.images&&(0,W.jsx)(`div`,{className:`message-images`,children:e.images.map((e,t)=>(0,W.jsx)(`img`,{src:e,alt:`已发送的图片 ${t+1}`,loading:`lazy`},t))}),(e.imageCount??0)>(e.images?.length??0)&&(0,W.jsxs)(`p`,{className:`subtle`,children:[(e.imageCount??0)-(e.images?.length??0),` 张图片未提供预览`]}),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error})]})})}function zb({thread:e,onJump:t}){let n=(0,O.useRef)(null),[r,i]=(0,O.useState)(),a=e?.turns.flatMap(e=>e.items).find(e=>e.type===`userMessage`&&e.id===r),o=(0,O.useCallback)(()=>{let e=n.current?.parentElement?.querySelector(`.conversation-scroll`);if(!e)return;let t=e.getBoundingClientRect().top+e.clientTop,r=e.querySelectorAll(`.conversation-content .user-message[data-prompt-id]`),a;for(let e=r.length-1;e>=0;e--)if(r[e].getBoundingClientRect().top<t){a=r[e].dataset.promptId;break}i(a)},[]);(0,O.useLayoutEffect)(o,[e,o]),(0,O.useEffect)(()=>{let e=n.current?.parentElement?.querySelector(`.conversation-scroll`),t=e?.querySelector(`.conversation-content`);if(!e||!t)return;let r,i=()=>{r===void 0&&(r=requestAnimationFrame(()=>{r=void 0,o()}))},a=new ResizeObserver(i);return a.observe(e),a.observe(t),e.addEventListener(`scroll`,i,{passive:!0}),()=>{a.disconnect(),e.removeEventListener(`scroll`,i),r!==void 0&&cancelAnimationFrame(r)}},[o]);let s=Math.max(a?.imageCount??0,a?.images?.length??0);return(0,W.jsx)(`div`,{className:`sticky-prompt-slot`,ref:n,children:a&&(0,W.jsx)(ol,{asChild:!0,content:`回到 Prompt 原文`,children:(0,W.jsxs)(q,{variant:`ghost`,className:`sticky-prompt`,"aria-label":`回到 Prompt 原文`,onClick:e=>{let r=n.current?.parentElement?.querySelector(`.conversation-scroll`),i=[...r?.querySelectorAll(`[data-prompt-id]`)??[]].find(e=>e.dataset.promptId===a.id);if(!r||!i)return;let o=e.currentTarget.getBoundingClientRect().height+8;t(),i.focus({preventScroll:!0}),r.scrollTop+=i.getBoundingClientRect().top-r.getBoundingClientRect().top-r.clientTop-o},children:[(0,W.jsx)(`span`,{className:`sticky-prompt-label`,children:`你的要求`}),(0,W.jsx)(`span`,{className:`sticky-prompt-text`,children:a.text?.trim()||(s?`${s} 张图片`:`用户 Prompt`)}),(0,W.jsx)(J,{name:`down`,size:14,style:{transform:`rotate(180deg)`}})]})})})}var Bb={commandExecution:`执行命令`,fileChange:`文件变更`,reasoning:`思考过程`,mcpToolCall:`调用工具`,webSearch:`搜索网页`,plan:`执行计划`,enteredReviewMode:`开始代码审查`,exitedReviewMode:`代码审查结果`},Vb={completed:`已完成`,inProgress:`执行中`,running:`执行中`,failed:`失败`,declined:`已拒绝`,interrupted:`已中断`};function Hb({item:e}){let t=gb();return(0,W.jsx)(Cb,{className:`activity${e.status===`failed`?` activity-failed`:``}`,label:`${Bb[e.type]??e.type}${e.command?`:${e.command}`:``}`,summary:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{name:e.type===`fileChange`?`code`:`terminal`,size:16}),(0,W.jsxs)(`span`,{className:`activity-description`,children:[(0,W.jsx)(`span`,{className:`activity-label`,children:Bb[e.type]??e.type}),e.command&&(0,W.jsx)(`code`,{className:`command-summary`,children:e.command})]}),(0,W.jsx)(`span`,{className:`activity-status`,children:e.status?Vb[e.status]??e.status:``})]}),children:(0,W.jsxs)(`div`,{className:`activity-body`,children:[e.cwd&&(0,W.jsx)(`p`,{className:`mono subtle`,children:e.cwd}),e.command&&(0,W.jsx)(`pre`,{className:`command`,children:(0,W.jsxs)(`code`,{children:[`$ `,e.command]})}),e.text&&(0,W.jsx)(Zy,{text:e.text}),e.output!==void 0&&(0,W.jsx)(`pre`,{className:`tool-output`,children:(0,W.jsx)(`code`,{children:e.output||`暂无输出`})}),e.truncated&&(0,W.jsxs)(`p`,{className:`truncation`,children:[(0,W.jsx)(J,{name:`alert`,size:14}),`输出超出显示上限,部分内容已截断。`]}),e.changes?.map((n,r)=>(0,W.jsxs)(q,{className:`file-change-link`,variant:`ghost`,onClick:()=>t({id:e.id,scope:`此工具的文件变更`,source:`item`,selectedPath:n.path}),children:[(0,W.jsx)(J,{name:`code`,size:15}),(0,W.jsx)(`code`,{children:n.path}),(0,W.jsx)(`span`,{children:`查看变更`}),(0,W.jsx)(J,{name:`chevron`,size:14})]},`${n.path}:${r}`)),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error}),e.details!==void 0&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:`活动详情`}),(0,W.jsx)(`pre`,{children:JSON.stringify(e.details,null,2)})]})]})})}function Ub({item:e,questionControls:t,replies:n}){return e.type===`contextCompaction`?e.status===`inProgress`?null:(0,W.jsx)(Mb,{item:e}):e.type===`userMessage`?(0,W.jsx)(Rb,{item:e}):e.type===`autoApprovalReview`&&e.autoReview?(0,W.jsx)(Ob,{review:e.autoReview}):e.type===`agentMessage`||e.type===`exitedReviewMode`?(0,W.jsx)(`article`,{className:`message assistant-message`,"aria-label":`Codex 的回复`,children:(0,W.jsxs)(`div`,{className:`message-content`,children:[e.type===`agentMessage`&&e.questions?.length?(0,W.jsx)(Sb,{itemId:e.id,questions:e.questions,replies:n,disabled:t?.disabled??!0,onReply:t?.onReply??(async()=>!1)}):(0,W.jsx)(Zy,{text:e.text??``}),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error})]})}):(0,W.jsx)(Hb,{item:e})}function Wb({turn:e,offline:t}){if(!e.reconnect)return null;let n=e.reconnect.status===`retrying`;return(0,W.jsxs)(`div`,{className:`codex-reconnect codex-reconnect-${e.reconnect.status}`,"data-testid":`codex-reconnect-status`,"data-state":e.reconnect.status,role:n?`status`:`alert`,"aria-label":`Codex 连接状态`,children:[(0,W.jsx)(J,{name:n?`refresh`:`alert`,size:18}),(0,W.jsxs)(`div`,{className:`codex-reconnect-content`,children:[(0,W.jsxs)(`strong`,{children:[t&&`上次已知:`,n?`Codex Reconnecting…`:`Codex 重新连接失败`]}),(0,W.jsx)(`p`,{children:n?`正在重新连接模型服务,Codex 会自动重试。恢复后将继续当前任务。`:kl(e.status)?`Codex 已停止重试。请检查运行 Codex 的服务器网络与模型服务;若本轮仍未结束,可点击下方“中断”,结束后重新发送要求以继续。`:`Codex 已停止重试。请检查运行 Codex 的服务器网络与模型服务,然后重新发送要求以继续。`}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`连接详情`}),(0,W.jsx)(`p`,{className:`codex-reconnect-message`,children:e.reconnect.message})]})]})]})}function Gb(e){return(0,W.jsx)(Ry,{threadId:e.thread?.id,children:(0,W.jsx)(Kb,{...e})},e.thread?.id??`empty`)}function Kb({thread:e,offline:t,history:n,projectName:r,needsProject:i=!1,canAddProject:a=!0,onAddProject:o,readingEnabled:s=!0,onReadCompleted:c,questionControls:l}){let u=gb(),d=(0,O.useRef)(null),f=(0,O.useRef)(null),p=(0,O.useRef)(!0),[m,h]=(0,O.useState)(!1),g=(0,O.useRef)(e?.id),_=(0,O.useRef)(void 0),v=(0,O.useRef)(void 0),y=(0,O.useRef)(0),b=(0,O.useRef)(!1),x=(0,O.useRef)(!1),S=e?.turns.at(-1),C=new Map;for(let t of e?.turns??[])for(let e of t.items)for(let t of e.questionReplies??[]){let e=C.get(t.questionItemId)??[];C.set(t.questionItemId,[...e,t])}let w=S&&kl(S.status)?S.items.findLast(e=>e.type===`contextCompaction`&&e.status===`inProgress`):void 0;(0,O.useLayoutEffect)(()=>{g.current!==e?.id&&(g.current=e?.id,p.current=!0,h(!1),v.current=void 0,b.current=!1,x.current=!1);let t=d.current;if(p.current)f.current?.scrollIntoView({block:`end`});else if(t&&v.current){let e=[...t.querySelectorAll(`[data-turn-id]`)].find(e=>e.dataset.turnId===v.current.id);e&&(t.scrollTop+=e.getBoundingClientRect().top-t.getBoundingClientRect().top-v.current.offset)}t&&(y.current=t.scrollTop)},[e]);let T=(0,O.useCallback)(()=>{let e=d.current;if(!e)return;b.current=x.current&&e.scrollTop<y.current,y.current=e.scrollTop;let t=[...e.querySelectorAll(`[data-turn-id]`)].find(t=>t.getBoundingClientRect().bottom>e.getBoundingClientRect().top);v.current=t?{id:t.dataset.turnId,offset:t.getBoundingClientRect().top-e.getBoundingClientRect().top}:void 0,b.current&&e.scrollTop<Math.max(600,e.clientHeight*1.5)&&!n?.error&&n?.onLoadOlder(),p.current=e.scrollHeight-e.scrollTop-e.clientHeight<100,h(!p.current)},[n]);return(0,O.useEffect)(()=>{let e=d.current;e&&b.current&&e.scrollTop<Math.max(600,e.clientHeight*1.5)&&!n?.loading&&!n?.error&&n?.onLoadOlder()},[e,n]),(0,O.useEffect)(()=>{let e=d.current;if(!e)return;let t=e=>{e.target instanceof HTMLDetailsElement&&e.target.classList.contains(`collapsible-activity`)&&T()};return e.addEventListener(`toggle`,t,!0),()=>e.removeEventListener(`toggle`,t,!0)},[T]),(0,O.useEffect)(()=>{let t=d.current,n=f.current,r=e?.id,i=S?.id;if(!s||!c||!t||!n||!r||!i||S.status!==`completed`)return;let a=()=>{if(document.visibilityState!==`visible`||!document.hasFocus()||document.querySelector(`dialog[open]`)||t.clientHeight===0)return;let e=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=Math.max(0,e.top+t.clientTop),s=Math.min(window.innerHeight,e.top+t.clientTop+t.clientHeight);if(s<=o||a.top<o||a.bottom>s)return;let l=_.current;(l?.threadId!==r||l.turnId!==i)&&(_.current={threadId:r,turnId:i},c(r,i))},o=new IntersectionObserver(a,{root:t});return o.observe(n),t.addEventListener(`scroll`,a),window.addEventListener(`focus`,a),document.addEventListener(`focusin`,a),document.addEventListener(`close`,a,!0),document.addEventListener(`visibilitychange`,a),a(),()=>{o.disconnect(),t.removeEventListener(`scroll`,a),window.removeEventListener(`focus`,a),document.removeEventListener(`focusin`,a),document.removeEventListener(`close`,a,!0),document.removeEventListener(`visibilitychange`,a)}},[e?.id,S?.id,S?.status,s,c]),(0,W.jsxs)(`div`,{className:`conversation-area`,children:[n?.cached&&(0,W.jsxs)(`div`,{className:`history-cache-notice`,role:`status`,children:[(0,W.jsx)(`span`,{children:n.syncError?`显示本机缓存 · 同步失败,部分历史可能缺失。`:`显示本机缓存 · 正在核对最新消息与任务状态…`}),n.syncError&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:n.onRetryOpen,children:`重新同步`})]}),S?.reconnect&&(0,W.jsx)(`div`,{className:`codex-reconnect-pinned`,children:(0,W.jsx)(Wb,{turn:S,offline:t})}),w&&(0,W.jsx)(`div`,{className:`context-compaction-pinned`,children:(0,W.jsx)(Mb,{item:w,offline:t})}),(0,W.jsxs)(`div`,{className:`conversation-viewport`,children:[(0,W.jsx)(zb,{thread:e,onJump:()=>{p.current=!1}}),(0,W.jsx)(`div`,{className:`conversation-scroll`,ref:d,onScroll:T,onWheel:()=>{x.current=!0},onTouchStart:()=>{x.current=!0},onPointerDown:()=>{x.current=!0},onKeyDown:e=>{[`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&(x.current=!0)},tabIndex:0,"aria-label":`会话消息`,children:(0,W.jsxs)(`div`,{className:`conversation-content`,children:[(e?.history?.olderCursor||n?.error)&&(0,W.jsxs)(`div`,{className:`history-pagination`,role:`status`,"aria-live":`polite`,"aria-busy":n?.loading,children:[(0,W.jsx)(`span`,{children:n?.error??(n?.loading?`正在加载较早的消息…`:`向上滚动,加载更早的消息`)}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:n?.loading,onClick:()=>n?.onLoadOlder(),children:n?.error?`重试加载`:`加载更早的消息`}),n?.error&&n.cached&&e?.history?.olderCursor&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:n.loading||n.cacheExhausted,onClick:n.onLoadCachedOlder,children:n.cacheExhausted?`此处尚无本机缓存`:`继续读取本机历史`})]}),e?.historyTruncated&&(0,W.jsxs)(`p`,{className:`truncation`,children:[(0,W.jsx)(J,{name:`alert`,size:14}),`当前实时快照已省略部分较早历史,以限制传输大小。`]}),n?.opening&&!e?.turns.length?(0,W.jsxs)(`div`,{className:`history-opening`,role:n.openingError?`alert`:`status`,children:[(0,W.jsx)(`p`,{children:n.openingError??`正在读取会话…`}),n.openingError?(0,W.jsx)(q,{variant:`secondary`,onClick:n.onRetryOpen,children:`重试读取`}):(0,W.jsxs)(`div`,{className:`history-skeleton`,"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{})]})]}):e?.turns.length?e.turns.map((e,n)=>(0,W.jsxs)(`section`,{className:`turn`,"data-turn-id":e.id,"aria-label":`第 ${n+1} 轮`,children:[(0,W.jsxs)(`div`,{className:`turn-heading`,children:[(0,W.jsxs)(`span`,{children:[`第 `,n+1,` 轮`]}),(0,W.jsx)(Al,{status:e.status,offline:t})]}),e.id!==S?.id&&e.reconnect?.status===`failed`&&(0,W.jsx)(Wb,{turn:e,offline:t}),kb(e.items).map(e=>e.kind===`message`?(0,W.jsx)(Ub,{item:e.item,questionControls:l,replies:[...C.get(e.item.id)??[],...(e.item.questions??[]).flatMap((t,n)=>C.get(bb(e.item.id,n))??[])]},e.key):(0,W.jsx)(jb,{items:e.items,children:e.items.map(e=>(0,W.jsx)(Ub,{item:e},e.id))},e.key)),(e.diff!==void 0||e.items.some(e=>e.changes?.length))&&(0,W.jsxs)(q,{className:`turn-diff`,variant:`ghost`,onClick:()=>u({id:e.id,scope:`第 ${n+1} 轮变更`,source:`turn`}),children:[(0,W.jsx)(J,{name:`code`,size:17}),(0,W.jsxs)(`span`,{children:[`本轮变更预览`,(0,W.jsx)(`small`,{children:`查看文件与代码行变更`})]}),(0,W.jsx)(J,{name:`chevron`,size:16})]}),e.error&&e.reconnect?.status!==`failed`&&!e.items.some(t=>t.type===`contextCompaction`&&t.error===e.error)&&(0,W.jsx)(`div`,{className:`error-banner`,children:e.error}),(0,W.jsx)(Lb,{turn:e})]},e.id)):(0,W.jsxs)(`div`,{className:`empty-state`,"data-testid":`workspace-start`,"data-thread-ready":!!e,children:[(0,W.jsx)(`div`,{className:`empty-symbol`,children:(0,W.jsx)(J,{name:`code`,size:36})}),(0,W.jsx)(`p`,{className:`eyebrow`,children:`你的开发工作空间`}),(0,W.jsx)(`h1`,{children:i?`添加项目,开始工作。`:`从一个想法,开始工作。`}),i?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{children:[`连接服务器上已有的项目目录,继续历史会话或创建新任务。`,(0,W.jsx)(`br`,{}),`项目会保存在服务器上,下次打开即可继续。`]}),(0,W.jsxs)(q,{onClick:o,disabled:!a,children:[(0,W.jsx)(J,{name:`plus`,size:16}),`添加项目`]})]}):(0,W.jsxs)(`p`,{children:[`描述你要完成的任务,也可以粘贴图片、问题或错误信息。`,(0,W.jsx)(`br`,{}),`发送后将在`,r?`「${r}」`:`当前项目`,`中开始新会话。`]}),(0,W.jsxs)(`div`,{className:`empty-features`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`terminal`,size:16}),`实时执行过程`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`code`,size:16}),`逐轮变更预览`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`check`,size:16}),`随时审批与追加`]})]})]}),(0,W.jsx)(`div`,{ref:f})]})})]}),m&&(0,W.jsxs)(q,{className:`back-to-bottom`,variant:`secondary`,size:`sm`,onClick:()=>{p.current=!0,h(!1),f.current?.scrollIntoView({behavior:`smooth`,block:`end`})},children:[(0,W.jsx)(J,{name:`down`,size:15}),`回到最新内容`]})]})}function qb({title:e,rename:t,pending:n}){let[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(!1),d=(0,O.useRef)(!1),f=(0,O.useRef)(null),p=(0,O.useRef)(null),m=(0,O.useRef)(!1),h=(0,O.useRef)(!1),g=(0,O.useRef)(-1/0),_=(0,O.useId)(),v=t.unavailableReason?.replaceAll(`/status`,`状态诊断`);(0,O.useEffect)(()=>{r&&(f.current?.focus(),f.current?.select())},[r]),(0,O.useEffect)(()=>{r&&!l&&s&&f.current?.focus()},[r,l,s]),(0,O.useEffect)(()=>{!s||l||n||r||(e===a.trim()?c(void 0):i(!0))},[s,l,n,r,e,a]),(0,O.useLayoutEffect)(()=>{!r&&m.current&&(m.current=!1,p.current?.focus())},[r]);function y(){m.current=!0,i(!1),c(void 0)}async function b(){if(d.current||v)return;let e=a.trim()?Xe(a):`请输入会话名称。`;if(e)c(e),f.current?.focus();else{d.current=!0,u(!0),c(void 0),y();try{let e=await t.run(a);e.error?c(e.message.replaceAll(`/status`,`状态诊断`)):c(void 0)}catch(e){c(En(e))}finally{d.current=!1,u(!1)}}}return(0,W.jsx)(`div`,{className:`thread-title-editor${r?` thread-title-editing`:``}`,children:r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h1`,{className:`sr-only`,children:e}),(0,W.jsxs)(`form`,{className:`thread-title-form`,"aria-label":`重命名会话`,"aria-busy":l,onSubmit:e=>{e.preventDefault(),h.current||b()},children:[(0,W.jsxs)(`div`,{className:`thread-title-fields`,children:[(0,W.jsx)(`input`,{ref:f,"aria-label":`会话名称`,"aria-describedby":`${_}-help${s?` ${_}-error`:``}`,"aria-invalid":!!s,value:a,disabled:l,onChange:e=>{o(e.target.value),c(void 0)},onCompositionStart:()=>{h.current=!0},onCompositionEnd:()=>{h.current=!1,g.current=performance.now()},onBlur:()=>{h.current=!1,g.current=-1/0},onKeyDown:e=>{h.current||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229?e.key===`Enter`&&e.preventDefault():(e.key===`Escape`&&(e.preventDefault(),d.current||y()),e.key===`Enter`&&(e.preventDefault(),performance.now()-g.current>=100&&b()))},onKeyUp:e=>{e.key===`Enter`&&(g.current=-1/0)}}),(0,W.jsx)(ol,{content:`保存会话名称`,children:(0,W.jsx)(q,{type:`submit`,size:`icon`,"aria-label":`保存会话名称`,disabled:l||!!v,children:(0,W.jsx)(J,{name:`check`,size:16})})}),(0,W.jsx)(ol,{content:`取消重命名`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`取消重命名`,disabled:l,onClick:y,children:(0,W.jsx)(J,{name:`close`,size:16})})})]}),(0,W.jsx)(`p`,{id:`${_}-help`,className:`thread-title-help`,children:l?`正在保存…`:v??`Enter 保存 · Esc 取消 · 最多 100 个字符`}),s&&(0,W.jsx)(`p`,{id:`${_}-error`,className:`thread-title-error`,role:`alert`,children:s})]})]}):(0,W.jsx)(ol,{id:`${_}-hint`,className:`thread-title-hint`,content:v??`点击标题重命名会话`,children:(0,W.jsx)(`h1`,{"aria-label":e,children:(0,W.jsxs)(`button`,{ref:p,type:`button`,className:`thread-title-trigger`,"aria-label":`重命名会话`,"aria-describedby":`${_}-hint`,"aria-disabled":!!v,onClick:()=>{v||(o(e),c(void 0),h.current=!1,g.current=-1/0,i(!0))},children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(ve,{size:13,"aria-hidden":`true`})]})})})})}var Jb=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`],Yb={text:``,images:[]};function Xb(e,t){if(e.some(e=>!Jb.includes(e.type)))return`请粘贴 PNG、JPEG、WebP 或 GIF 图片。`;if(e.some(e=>e.size===0))return`图片为空,请重新复制后粘贴。`;if(e.length+t.length>4)return`每条消息最多添加 4 张图片。`;if([...e,...t].reduce((e,t)=>e+t.size,0)>2097152)return`每条消息的图片总大小不能超过 2 MiB,请缩小图片后重试。`}function Zb(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{typeof r.result==`string`?t(r.result):n(Error(`图片读取失败,请重新粘贴。`))},r.onerror=r.onabort=()=>n(Error(`图片读取失败,请重新粘贴。`)),r.readAsDataURL(e)})}function Qb(e,t){let[n,r]=(0,O.useState)(0),i=e&&t?JSON.stringify([e,t,n]):``,[a,o]=(0,O.useState)();return(0,O.useEffect)(()=>{if(!i||!e)return;let t=!1;return ze.runtimeSettings(e).then(e=>{t||o({key:i,value:e})},()=>{t||o({key:i,error:`无法读取默认配置`})}),()=>{t=!0}},[i,e]),{value:a?.key===i?a.value:void 0,error:a?.key===i?a.error:void 0,loading:!!(i&&a?.key!==i),retry:()=>r(e=>e+1)}}var $b=Object.defineProperty,ex=(e,t)=>$b(e,`name`,{value:t,configurable:!0});function tx(e,[t,n]){return Math.min(n,Math.max(t,e))}ex(tx,`clamp`);var nx=Object.defineProperty,rx=(e,t)=>nx(e,`name`,{value:t,configurable:!0});function ix(e){let t=e+`CollectionProvider`,[n,r]=Yr(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=rx(e=>{let{scope:t,children:n}=e,r=O.useRef(null),a=O.useRef(new Map).current;return(0,W.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=ei(s),l=O.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Wr(t,a(s,n).collectionRef);return(0,W.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ei(u),p=O.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=O.useRef(null),s=Wr(t,o),c=a(u,n);return O.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,W.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return O.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return rx(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}rx(ix,`createCollection`);var ax=new WeakMap,ox=class e extends Map{static{rx(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],ax.set(this,!0)}set(e,t){return ax.get(this)&&!this.has(e)&&this.#e.push(e),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=r?this.size:this.size+1,a=lx(e),o=a>=0?Math.min(a,i-1):Math.max(i+a,0);if(r?this.#e.indexOf(t)===o:o===this.size)return this.set(t,n),this;let s=this.#e.filter(e=>e!==t);s.splice(o,0,t);let c=s.map(e=>[e,e===t?n:this.get(e)]);this.clear();for(let[e,t]of c)this.set(e,t);return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);if(r===-1)return this;let i=this.#e.indexOf(t),a=i!==-1&&i<r?r-1:r;return this.insert(a,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);if(r===-1)return this;let i=this.#e.indexOf(t),a=i!==-1&&i<=r?r:r+1;return this.insert(a,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=sx(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=sx(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return sx(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=0,a=n;for(let e of this)a=i===0&&!r?e:Reflect.apply(t,this,[a,e,i,this]),i++;return a}reduceRight(...e){let[t,n]=e,r=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=n;for(let e=this.size-1;e>=0;e--){let n=this.entryAt(e);i=e===this.size-1&&!r?n:Reflect.apply(t,this,[i,n,e,this])}return i}sort(e){if(typeof e!=`function`)throw TypeError(`OrderedDict.sort requires a compare function`);let t=[...this.entries()].sort(e);this.clear();for(let[e,n]of t)this.set(e,n);return this}toSorted(t){if(typeof t!=`function`)throw TypeError(`OrderedDict.toSorted requires a compare function`);let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e;for(let e of this.#e.slice(t,n))r.set(e,this.get(e));return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function sx(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=cx(e,t);return n===-1?void 0:e[n]}rx(sx,`at`);function cx(e,t){let n=e.length,r=lx(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}rx(cx,`toSafeIndex`);function lx(e){return e!==e||e===0?0:Math.trunc(e)}rx(lx,`toSafeInteger`);function ux(e){let t=e+`CollectionProvider`,[n,r]=Yr(t),[i,a]=n(t);i.displayName=e+`CollectionStableContextProvider`;let[o,s]=n(t);o.displayName=e+`CollectionStatefulContextProvider`;let c=rx(({state:e,...t})=>e?(0,W.jsx)(u,{...t,state:e}):(0,W.jsx)(l,{...t}),`CollectionProvider`);c.displayName=t;let l=rx(e=>{let t=_();return(0,W.jsx)(u,{...e,state:t})},`CollectionInit`);l.displayName=e+`CollectionInit`;let u=rx(e=>{let{scope:t,children:n,state:r}=e,a=O.useRef(null),[s,c]=O.useState(null),l=Wr(a,c),[u,d]=r,f=O.useRef(new ox),p=O.useCallback(()=>{let e=f.current;return px(e)||e.sort(mx),e},[]);return O.useEffect(()=>{if(!s)return;let e=hx(()=>{d(e=>{let t=e.toSorted(mx);return t.some(([t],n)=>e.keyAt(n)!==t)?t:e})});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s,d]),(0,W.jsx)(i,{scope:t,collectionElementRef:l,collectionElementRefObject:a,getCollection:p,setCollection:d,registryRef:f,children:(0,W.jsx)(o,{scope:t,collectionElement:s,collection:u,children:n})})},`CollectionProviderImpl`);u.displayName=e+`CollectionProviderImpl`;let d=e+`CollectionSlot`,f=ei(d),p=O.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Wr(t,a(d,n).collectionElementRef);return(0,W.jsx)(f,{ref:i,children:r})});p.displayName=d;let m=e+`CollectionItemSlot`,h=ei(m),g=O.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=O.useRef(null),{setCollection:s,registryRef:c}=a(m,n),l=O.useRef(i);dx(l.current,i)||(l.current=i);let u=l.current,d=Wr(t,O.useCallback(e=>{let t=c.current;e?t.set(e,{...l.current,element:e}):o.current&&t.delete(o.current)},[c]),o);yi(()=>{let e=o.current,t=c.current;e&&t.has(e)&&t.set(e,{...u,element:e})},[u,c]);let f=O.useRef(null);return O.useEffect(()=>{let e=o.current,t=f.current;((t?.element??null)!==e||e&&t?.itemData!==u)&&(f.current=e?{element:e,itemData:u}:null,s(n=>{let r=new ox(n);return t&&t.element!==e&&r.delete(t.element),e&&r.set(e,{...u,element:e}),r.sort(mx)}))}),O.useEffect(()=>()=>{let e=f.current;f.current=null,e&&s(t=>{if(!t.has(e.element))return t;let n=new ox(t);return n.delete(e.element),n})},[s]),(0,W.jsx)(h,{"data-radix-collection-item":``,ref:d,children:r})});g.displayName=m;function _(){return O.useState(new ox)}rx(_,`useInitCollection`);function v(t){let{collection:n}=s(e+`CollectionConsumer`,t);return n}rx(v,`useCollection`);function y(t){let{getCollection:n}=a(e+`CollectionConsumer`,t);return n}return rx(y,`useGetCollection`),[{Provider:c,Slot:p,ItemSlot:g},{createCollectionScope:r,useCollection:v,useGetCollection:y,useInitCollection:_}]}rx(ux,`createCollection`);function dx(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}rx(dx,`shallowEqual`);function fx(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}rx(fx,`isElementPreceding`);function px(e){let t;for(let n of e.keys()){if(t){let e=t.compareDocumentPosition(n);if(!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&e&Node.DOCUMENT_POSITION_PRECEDING)return!1}t=n}return!0}rx(px,`isInDocumentOrder`);function mx(e,t){return!e[1].element||!t[1].element?0:fx(e[1].element,t[1].element)?-1:1}rx(mx,`sortByDocumentPosition`);function hx(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}rx(hx,`getChildListObserver`);var gx=Object.defineProperty,_x=(e,t)=>gx(e,`name`,{value:t,configurable:!0}),vx={LTR:`ltr`,RTL:`rtl`},yx=O.createContext(void 0);function bx(e){let t=O.useContext(yx);return e||t||vx.LTR}_x(bx,`useDirection`);var xx=Object.defineProperty,Sx=(e,t)=>xx(e,`name`,{value:t,configurable:!0}),Cx=0,wx=null;function Tx(e){return Ex(),e.children}Sx(Tx,`FocusGuards`);function Ex(){O.useEffect(()=>{wx||={start:Dx(),end:Dx()};let{start:e,end:t}=wx;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Cx++,()=>{Cx===1&&(wx?.start.remove(),wx?.end.remove(),wx=null),Cx=Math.max(0,Cx-1)}},[])}Sx(Ex,`useFocusGuards`);function Dx(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}Sx(Dx,`createFocusGuard`);var Ox=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},kx=new WeakMap,Ax=new WeakMap,jx={},Mx=0,Nx=function(e){return e&&(e.host||Nx(e.parentNode))},Px=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Nx(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Fx=function(e,t,n,r){var i=Px(t,Array.isArray(e)?e:[e]);jx[n]||(jx[n]=new WeakMap);var a=jx[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(kx.get(e)||0)+1,l=(a.get(e)||0)+1;kx.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Ax.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Mx++,function(){o.forEach(function(e){var t=kx.get(e)-1,i=a.get(e)-1;kx.set(e,t),a.set(e,i),t||(Ax.has(e)||e.removeAttribute(r),Ax.delete(e)),i||e.removeAttribute(n)}),Mx--,Mx||(kx=new WeakMap,kx=new WeakMap,Ax=new WeakMap,jx={})}},Ix=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Ox(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Fx(r,i,n,`aria-hidden`)):function(){return null}},Lx=function(){return Lx=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Lx.apply(this,arguments)};function Rx(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function zx(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Bx=`right-scroll-bar-position`,Vx=`width-before-scroll-bar`,Hx=`with-scroll-bars-hidden`,Ux=`--removed-body-scroll-bar-size`;function Wx(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Gx(e,t){var n=(0,O.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Kx=typeof window<`u`?O.useLayoutEffect:O.useEffect,qx=new WeakMap;function Jx(e,t){var n=Gx(t||null,function(t){return e.forEach(function(e){return Wx(e,t)})});return Kx(function(){var t=qx.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Wx(e,null)}),i.forEach(function(e){r.has(e)||Wx(e,a)})}qx.set(n,e)},[e]),n}function Yx(e){return e}function Xx(e,t){t===void 0&&(t=Yx);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Zx(e){e===void 0&&(e={});var t=Xx(null);return t.options=Lx({async:!0,ssr:!1},e),t}var Qx=function(e){var t=e.sideCar,n=Rx(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return O.createElement(r,Lx({},n))};Qx.isSideCarExport=!0;function $x(e,t){return e.useMedium(t),Qx}var eS=Zx(),tS=function(){},nS=O.forwardRef(function(e,t){var n=O.useRef(null),r=O.useState({onScrollCapture:tS,onWheelCapture:tS,onTouchMoveCapture:tS}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Rx(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=Jx([n,t]),C=Lx(Lx({},b),i);return O.createElement(O.Fragment,null,u&&O.createElement(x,{sideCar:eS,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?O.cloneElement(O.Children.only(s),Lx(Lx({},C),{ref:S})):O.createElement(v,Lx({},C,{className:c,ref:S}),s))});nS.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},nS.classNames={fullWidth:Vx,zeroRight:Bx};var rS=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function iS(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=rS();return t&&e.setAttribute(`nonce`,t),e}function aS(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function oS(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var sS=function(){var e=0,t=null;return{add:function(n){e==0&&(t=iS())&&(aS(t,n),oS(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cS=function(){var e=sS();return function(t,n){O.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},lS=function(){var e=cS();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},uS={left:0,top:0,right:0,gap:0},dS=function(e){return parseInt(e||``,10)||0},fS=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[dS(n),dS(r),dS(i)]},pS=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return uS;var t=fS(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},mS=lS(),hS=`data-scroll-locked`,gS=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
43
|
-
.${
|
|
42
|
+
`);m.at(-1)===``&&m.pop();for(let e of m)if(e.startsWith(`diff --git `)){let n=/^diff --git ("(?:\\.|[^"\\])*"|a\/.*?) ("(?:\\.|[^"\\])*"|b\/.*)$/.exec(e);p(n?tb(n[2]):t?.path??`未知文件`)}else if(a&&(c>0||l>0)&&/^[ +\-\\]/.test(e))e.startsWith(`\\`)?a.lines.push({kind:`note`,text:`文件末尾没有换行`}):e.startsWith(`+`)?(a.lines.push({kind:`added`,text:e.slice(1),newLine:s++}),l--,i.additions++):e.startsWith(`-`)?(a.lines.push({kind:`removed`,text:e.slice(1),oldLine:o++}),c--,i.deletions++):(a.lines.push({kind:`context`,text:e.slice(1),oldLine:o++,newLine:s++}),c--,l--);else if(e.startsWith(`--- `)){(!i||d)&&p(t?.path??`未知文件`),f(),u=!0;let n=tb(e.slice(4));n===`/dev/null`?i.kind=`added`:(i.oldPath=n,i.path=n)}else if(e.startsWith(`+++ `)){i??=p(t?.path??`未知文件`),d=!0;let n=tb(e.slice(4));n===`/dev/null`?i.kind=`deleted`:(i.path=n,i.oldPath&&i.oldPath!==n&&(i.kind=`renamed`))}else if(e.startsWith(`@@`)){i??=p(t?.path??`未知文件`),f();let n=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(e);if(!n){i.incomplete=!0,i.metadata.push(e);continue}o=Number(n[1]),s=Number(n[3]),c=Number(n[2]??1),l=Number(n[4]??1),a={header:e,lines:[]},i.hunks.push(a)}else e.startsWith(`\\ No newline`)&&a?a.lines.push({kind:`note`,text:`文件末尾没有换行`}):(e||i)&&(i??=p(t?.path??`未知文件`),(e.startsWith(`[输出已截断`)||e.startsWith(`[内容已截断`))&&(i.incomplete=!0),e.startsWith(`new file mode`)?i.kind=`added`:e.startsWith(`deleted file mode`)?i.kind=`deleted`:e.startsWith(`rename from `)?(i.oldPath=tb(e.slice(12),!1),i.kind=`renamed`):e.startsWith(`rename to `)&&(i.path=tb(e.slice(10),!1),i.kind=`renamed`),/^(Binary files |GIT binary patch)/.test(e)&&(i.binary=!0),!i.binary&&!e.startsWith(`index `)&&e&&i.metadata.push(e));return f(),!r.length&&t&&p(t.path),t&&r.length===1&&(!u&&!d&&(i.path=t.path),t.kind===`add`&&(i.kind=`added`),t.kind===`delete`&&(i.kind=`deleted`)),r}var rb=new Intl.Segmenter(void 0,{granularity:`grapheme`}),ib=e=>Array.from(rb.segment(e),e=>e.segment),ab=new Intl.Segmenter(void 0,{granularity:`word`}),ob=e=>Array.from(ab.segment(e.join(``)),e=>e.segment);function sb(e,t,n){if(!t)return;let r=e.at(-1);r?.changed===n?r.text+=t:e.push({text:t,changed:n})}function cb(e,t,n){let r=ib(e),i=ib(t),a=[],o=[],s=0,c=0;for(;s<r.length&&s<i.length&&r[s]===i[s];)s++;for(;c<r.length-s&&c<i.length-s&&r.at(-c-1)===i.at(-c-1);)c++;sb(a,r.slice(0,s).join(``),!1),sb(o,i.slice(0,s).join(``),!1);let l=ob(r.slice(s,r.length-c)),u=ob(i.slice(s,i.length-c)),d=(l.length+1)*(u.length+1);if(!l.length||!u.length||d>n.cells)sb(a,l.join(``),!0),sb(o,u.join(``),!0);else{n.cells-=d;let e=u.length+1,t=new Uint16Array(d);for(let n=l.length-1;n>=0;n--)for(let r=u.length-1;r>=0;r--)t[n*e+r]=l[n]===u[r]?1+t[(n+1)*e+r+1]:Math.max(t[(n+1)*e+r],t[n*e+r+1]);let r=0,i=0;for(;r<l.length||i<u.length;)r<l.length&&i<u.length&&l[r]===u[i]?(sb(a,l[r++],!1),sb(o,u[i++],!1)):r<l.length&&(i===u.length||t[(r+1)*e+i]>=t[r*e+i+1])?sb(a,l[r++],!0):sb(o,u[i++],!0)}return sb(a,r.slice(r.length-c).join(``),!1),sb(o,i.slice(i.length-c).join(``),!1),[a,o]}function lb(e){let t=e.trim().slice(0,4096),n=new Map,r=0;for(let e of t.match(/[\p{L}\p{N}_]+|[^\s\p{L}\p{N}_]/gu)??[])n.set(e,(n.get(e)??0)+1),r+=e.length;return{trimmed:t,tokens:n,size:r}}function ub(e,t){if(e.trimmed===t.trimmed)return 1;let n=0,r=0,i=0;for(let[r,i]of e.tokens)n+=Math.min(i,t.tokens.get(r)??0)*r.length;let a=e.trimmed,o=t.trimmed;for(;r<a.length&&r<o.length&&a[r]===o[r];)r++;for(;i<a.length-r&&i<o.length-r&&a.at(-i-1)===o.at(-i-1);)i++;return Math.max(2*n/Math.max(1,e.size+t.size),(r+i)/Math.max(1,a.length,o.length))}function db(e){let t={cells:2e5},n=1e4;return e.map(e=>{let r=[...e.lines];for(let e=0;e<r.length;){if(r[e].kind===`context`){e++;continue}let i=e,a=[],o=[];for(;i<r.length&&r[i].kind!==`context`;)r[i].kind===`removed`&&a.push(i),r[i].kind===`added`&&o.push(i),i++;let s=(a.length+1)*(o.length+1);if(a.length&&o.length&&s<=n){n-=s;let e=a.map(e=>lb(r[e].text)),i=o.map(e=>lb(r[e].text)),c=o.length+1,l=new Float64Array(s),u=new Uint8Array(s);for(let t=a.length-1;t>=0;t--)for(let n=o.length-1;n>=0;n--){let r=ub(e[t],i[n])*2-.5,a=r>0?r+l[(t+1)*c+n+1]:-1,o=l[(t+1)*c+n],s=l[t*c+n+1];l[t*c+n]=Math.max(a,o,s),u[t*c+n]=a>=o&&a>=s?1:o>=s?2:3}let d=0,f=0;for(;d<a.length&&f<o.length;){let e=u[d*c+f];if(e===1){let e=a[d++],n=o[f++],i=r[e],s=r[n];if(i.text!==s.text){let[a,o]=cb(i.text,s.text,t);r[e]={...i,segments:a},r[n]={...s,segments:o}}}else e===2?d++:f++}}e=i}return{...e,lines:r}})}function fb({file:e}){return(0,W.jsxs)(`span`,{className:`diff-stats`,"aria-label":`新增 ${e.additions} 行,删除 ${e.deletions} 行`,children:[(0,W.jsxs)(`span`,{children:[`+`,e.additions]}),(0,W.jsxs)(`span`,{children:[`−`,e.deletions]})]})}function pb({target:e,threadId:t,onClose:n}){let[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(0);return(0,O.useEffect)(()=>{let n=new AbortController,r=setTimeout(()=>{n.abort(),o(`读取变更超时,请重试。`)},35e3);return i(void 0),o(void 0),(e.cursor?ze.threadHistory(t,e.cursor,n.signal):ze.thread(t,n.signal)).then(t=>{if(!n.signal.aborted){if(e.source===`turn`){let n=t.turns.find(t=>t.id===e.id);if(!n)throw Error(`此轮变更已不在可读取的会话历史中。`);i({...e,text:n.diff,changes:n.diff===void 0?n.items.flatMap(e=>e.changes??[]):void 0,truncated:t.historyTruncated||n.items.some(e=>e.type===`fileChange`&&e.truncated)})}else{let n=t.turns.flatMap(e=>e.items).find(t=>t.id===e.id);if(!n)throw Error(`此工具的变更已不在可读取的会话历史中。`);i({...e,changes:n.changes??[],truncated:n.truncated})}}}).catch(e=>{n.signal.aborted||o(En(e))}).finally(()=>clearTimeout(r)),()=>{n.abort(),clearTimeout(r)}},[e,t,s]),(0,W.jsxs)(zl,{label:`代码变更预览`,title:`代码变更`,subtitle:`${e.scope} · 只读`,icon:(0,W.jsx)(fe,{size:19,className:`file-preview-icon`,"aria-hidden":`true`}),onClose:n,children:[(0,W.jsx)(`p`,{className:`diff-scope`,children:`Codex 提供的变更快照,仅包含此范围内的补丁,不代表工作区全部未提交变更。`}),a?(0,W.jsxs)(`div`,{className:`diff-empty`,role:`alert`,children:[(0,W.jsx)(`h3`,{children:`无法读取变更`}),(0,W.jsx)(`p`,{children:a}),(0,W.jsx)(q,{variant:`secondary`,onClick:()=>c(e=>e+1),children:`重新加载`})]}):r?(0,W.jsx)(mb,{target:r},s):(0,W.jsx)(`p`,{className:`file-preview-loading diff-loading`,role:`status`,children:`正在读取变更…`})]})}function mb({target:e}){let t=(0,O.useMemo)(()=>e.changes?e.changes.flatMap(e=>nb(e.diff,e)):nb(e.text??``),[e]),[n,r]=(0,O.useState)(!1);return(0,W.jsxs)(W.Fragment,{children:[e.truncated&&(0,W.jsx)(`p`,{className:`diff-warning`,role:`status`,children:`补丁已被截断,以下仅展示收到的部分内容。`}),t.length?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`diff-list-toolbar`,children:[(0,W.jsxs)(`span`,{children:[`此快照共 `,t.length,` 个文件`]}),(0,W.jsxs)(q,{variant:`ghost`,size:`sm`,"aria-pressed":n,onClick:()=>r(!n),children:[(0,W.jsx)(Se,{size:15}),`自动换行`]})]}),(0,W.jsx)(`div`,{className:`diff-files`,tabIndex:0,"aria-label":`变更文件列表`,children:t.map((t,r)=>(0,W.jsx)(hb,{file:t,wrap:n,reveal:e.selectedPath!==void 0&&(t.path===e.selectedPath||t.oldPath===e.selectedPath)},r))})]}):(0,W.jsxs)(`div`,{className:`diff-empty`,role:`status`,children:[(0,W.jsx)(fe,{size:28}),(0,W.jsx)(`h3`,{children:`暂无文件变更`}),(0,W.jsx)(`p`,{children:`此范围内尚未收到可预览的补丁。`})]}),(0,W.jsx)(`footer`,{className:`file-preview-path`,children:e.scope})]})}function hb({file:e,wrap:t,reveal:n}){let r=(0,O.useMemo)(()=>eb(e),[e]),[i,a]=(0,O.useState)(()=>n||!r),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),l=(0,O.useId)();(0,O.useEffect)(()=>{n&&o.current?.scrollIntoView({block:`start`})},[n]),(0,O.useLayoutEffect)(()=>{let e=c.current,t=o.current,n=t?.closest(`.diff-files`);e!==void 0&&t&&n&&(n.scrollTop+=t.getBoundingClientRect().top-e,s.current?.focus({preventScroll:!0}),c.current=void 0)},[i]);function u(){let e=o.current,t=e?.closest(`.diff-files`);e&&t&&(c.current=Math.max(e.getBoundingClientRect().top,t.getBoundingClientRect().top)),a(!1)}return(0,W.jsxs)(`section`,{ref:o,className:`diff-file`,"aria-label":e.path,children:[(0,W.jsxs)(`div`,{className:`diff-file-heading`,children:[(0,W.jsx)(`h3`,{children:(0,W.jsx)(`code`,{children:e.path})}),(0,W.jsx)(`span`,{className:`diff-kind diff-kind-${e.kind}`,children:$y[e.kind]}),(0,W.jsx)(fb,{file:e}),(0,W.jsxs)(q,{ref:s,variant:`ghost`,size:`sm`,"aria-expanded":i,"aria-controls":l,onClick:()=>i?u():a(!0),children:[i?(0,W.jsx)(re,{size:15}):(0,W.jsx)(R,{size:15}),i?`收起变更`:`展开变更`]})]}),e.kind===`renamed`&&e.oldPath&&(0,W.jsxs)(`p`,{className:`diff-rename`,children:[`原路径:`,e.oldPath]}),e.incomplete&&(0,W.jsx)(`p`,{className:`diff-warning`,role:`status`,children:`补丁不完整或格式有误,行号与统计仅对应已收到的内容。`}),!i&&(0,W.jsxs)(`p`,{className:`diff-collapsed`,children:[r??`变更已手动收起。`,` 可通过「展开变更」查看。`]}),(0,W.jsxs)(`div`,{id:l,hidden:!i,children:[i&&(0,W.jsx)(gb,{file:e,wrap:t}),i&&r&&(0,W.jsxs)(q,{className:`diff-collapse-bottom`,variant:`ghost`,size:`sm`,onClick:u,children:[(0,W.jsx)(re,{size:15}),`收起变更`]})]})]})}function gb({file:e,wrap:t}){let[n,r]=(0,O.useState)(0),i=(0,O.useRef)([]),a=(0,O.useMemo)(()=>db(e.hunks),[e]),o=!e.binary&&!e.hunks.length&&e.metadata.some(e=>!/^(old mode |new mode |new file mode |deleted file mode |similarity index |dissimilarity index |rename from |rename to )/.test(e));function s(e){r(e);let t=i.current[e],n=t?.closest(`.diff-files`),a=t?.closest(`.diff-file`)?.querySelector(`.diff-file-heading`);t&&n&&a&&(n.scrollTop+=t.getBoundingClientRect().top-n.getBoundingClientRect().top-a.getBoundingClientRect().height-12)}return(0,W.jsxs)(W.Fragment,{children:[e.hunks.length>1&&(0,W.jsxs)(`div`,{className:`diff-controls`,role:`group`,"aria-label":`变更区块导航`,children:[(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`上一个变更区块`,disabled:n===0,onClick:()=>s(n-1),children:(0,W.jsx)(re,{size:16})}),(0,W.jsxs)(`span`,{children:[n+1,` / `,e.hunks.length,` 个区块`]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`下一个变更区块`,disabled:n>=e.hunks.length-1,onClick:()=>s(n+1),children:(0,W.jsx)(R,{size:16})})]}),(0,W.jsx)(`div`,{className:`diff-content${t?` diff-wrap`:``}`,tabIndex:0,"aria-label":`${e.path} 的变更内容`,children:e.binary?(0,W.jsxs)(`div`,{className:`diff-empty`,children:[(0,W.jsx)(fe,{size:28}),(0,W.jsx)(`h3`,{children:`二进制文件已变更`}),(0,W.jsx)(`p`,{children:`此文件无法逐行预览。`})]}):o?(0,W.jsxs)(`div`,{className:`diff-empty`,role:`alert`,children:[(0,W.jsx)(`h3`,{children:`无法读取变更内容`}),(0,W.jsx)(`p`,{children:`收到的内容不是可识别的 unified diff。请等待 Codex 更新补丁,或重新打开预览。`})]}):e.hunks.length?(0,W.jsxs)(`table`,{className:`diff-table`,"aria-label":`${e.path} 的行变更`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,children:`原行`}),(0,W.jsx)(`th`,{scope:`col`,children:`新行`}),(0,W.jsx)(`th`,{scope:`col`,"aria-label":`变更类型`}),(0,W.jsx)(`th`,{scope:`col`,children:`代码内容`})]})}),a.map((e,t)=>(0,W.jsxs)(`tbody`,{ref:e=>{i.current[t]=e},children:[(0,W.jsx)(`tr`,{className:`diff-hunk`,children:(0,W.jsxs)(`td`,{colSpan:4,children:[(0,W.jsxs)(`span`,{children:[`区块 `,t+1]}),` `,e.header]})}),e.lines.map((e,t)=>(0,W.jsxs)(`tr`,{className:`diff-line diff-${e.kind}`,children:[(0,W.jsx)(`td`,{className:`diff-line-number`,children:e.oldLine}),(0,W.jsx)(`td`,{className:`diff-line-number`,children:e.newLine}),(0,W.jsx)(`td`,{className:`diff-marker`,"aria-label":{added:`新增`,removed:`删除`,context:`上下文`,note:`提示`}[e.kind],children:e.kind===`added`?`+`:e.kind===`removed`?`−`:``}),(0,W.jsx)(`td`,{className:`diff-code`,children:(0,W.jsx)(`code`,{children:e.segments?e.segments.map((e,t)=>e.changed?(0,W.jsx)(`mark`,{className:`diff-inline-change`,children:e.text},t):e.text):e.text||` `})})]},t))]},t))]}):(0,W.jsxs)(`div`,{className:`diff-empty`,children:[(0,W.jsx)(`h3`,{children:`没有逐行内容变更`}),(0,W.jsx)(`p`,{children:`此补丁仅包含文件属性、路径或空文件变更,没有可展示的代码行。`})]})})]})}var _b=(0,O.createContext)({open:()=>{},openDiff:()=>{}}),vb=()=>(0,O.useContext)(_b),yb=()=>(0,O.useContext)(_b).openDiff;function bb({threadId:e,getHistoryCursor:t,children:n}){let[r,i]=(0,O.useState)();(0,O.useEffect)(()=>i(void 0),[e]);let a=(0,O.useCallback)(()=>i(void 0),[]),o=(0,O.useMemo)(()=>({threadId:e,open:t=>{e&&i({threadId:e,kind:`file`,path:t})},openDiff:n=>{e&&i({threadId:e,kind:`diff`,diff:{...n,cursor:t?.(n.id)}})}}),[e,t]);return(0,W.jsxs)(_b,{value:o,children:[n,r&&r.threadId===e&&(r.kind===`file`?(0,W.jsx)(Qy,{threadId:r.threadId,path:r.path,onClose:a},`${e}:${r.path}`):(0,W.jsx)(pb,{threadId:r.threadId,target:r.diff,onClose:a},`${e}:${r.diff.id}`))]})}var xb=`<send_user_message_question_reply>`,Sb=`</send_user_message_question_reply>`;function Cb(e,t){return JSON.stringify([`request_user_input_async`,e,t])}function wb(e){return`${xb}${JSON.stringify(e)}${Sb}`}function Tb({itemId:e,questions:t,replies:n=[],disabled:r,onReply:i}){let a=(0,O.useId)(),[o,s]=(0,O.useState)(()=>t.map(e=>e.options?.length?0:-1)),[c,l]=(0,O.useState)([]),[u,d]=(0,O.useState)(!1),f=(0,O.useRef)(!1),[p,m]=(0,O.useState)(),h=t.map((t,r)=>n.find(t=>t.questionItemId===Cb(e,r))?.answer??n.find(n=>n.questionItemId===e&&n.question===t.title)?.answer??p?.[r]),g=h.every(e=>e!==void 0),_=t.map((e,t)=>h[t]??(o[t]===-1?c[t]:e.options?.[o[t]??0])?.trim()??``),v=r||u||!!g;return(0,W.jsxs)(`section`,{className:`async-question-card`,"aria-label":`Codex 的提问`,children:[(0,W.jsxs)(`div`,{className:`async-question-heading`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`chat`,size:16}),`需要你的回答`]}),(0,W.jsx)(`small`,{children:g?`已发送回答`:u?`正在发送…`:`可稍后回答`})]}),(0,W.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),!(v||f.current||_.some(e=>!e))){f.current=!0,d(!0);try{await i(t.flatMap((t,n)=>h[n]===void 0?[{questionItemId:Cb(e,n),question:t.title,answer:_[n]}]:[]))&&m(_)}finally{f.current=!1,d(!1)}}},children:[t.map((e,t)=>(0,W.jsxs)(`fieldset`,{disabled:v||h[t]!==void 0,children:[(0,W.jsx)(`legend`,{children:e.title}),h[t]===void 0?(0,W.jsxs)(W.Fragment,{children:[e.options?.map((e,n)=>(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${a}-${t}`,checked:o[t]===n,onChange:()=>s(e=>e.map((e,r)=>r===t?n:e))}),(0,W.jsx)(`span`,{children:e})]},n)),!!e.options?.length&&(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${a}-${t}`,checked:o[t]===-1,onChange:()=>s(e=>e.map((e,n)=>n===t?-1:e))}),(0,W.jsx)(`span`,{children:`自由回答`})]}),o[t]===-1&&(0,W.jsx)(`textarea`,{className:`text-input`,"aria-label":`${e.title}:自由回答`,placeholder:`输入你的回答`,rows:2,maxLength:1e4,value:c[t]??``,onChange:e=>l(n=>{let r=[...n];return r[t]=e.target.value,r})})]}):(0,W.jsx)(`p`,{className:`async-question-answer`,children:h[t]})]},t)),!g&&(0,W.jsxs)(`div`,{className:`async-question-footer`,children:[(0,W.jsx)(`span`,{children:`回答会发送到当前会话,Codex 可以继续执行。`}),(0,W.jsx)(q,{type:`submit`,disabled:v||_.some(e=>!e),children:u?`正在发送…`:`发送回答`})]})]})]})}function Eb({className:e=``,label:t,summary:n,children:r,group:i=!1}){let a=(0,O.useRef)(null),o=(0,O.useRef)(void 0),[s,c]=(0,O.useState)(!1);return(0,O.useLayoutEffect)(()=>{let e=a.current,t=e?.querySelector(`:scope > summary`);if(!i||!e||!t)return;let n=()=>{e.style.setProperty(`--activity-group-header-height`,`${t.getBoundingClientRect().height}px`)};n();let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[i]),(0,O.useEffect)(()=>()=>{o.current!==void 0&&cancelAnimationFrame(o.current)},[]),(0,W.jsxs)(`details`,{ref:a,className:`collapsible-activity${i?` collapsible-activity-group`:``} ${e}`,onToggle:e=>{e.target===e.currentTarget&&c(e.currentTarget.open)},children:[(0,W.jsxs)(`summary`,{"aria-label":`${s?`收起`:`展开`}${t}`,onClick:e=>{let t=a.current,n=t?.closest(`.conversation-scroll`);if(!t?.open||!n)return;let r=e.currentTarget,i=Number.parseFloat(getComputedStyle(r).top)||0,s=n.getBoundingClientRect().top+n.clientTop;t.getBoundingClientRect().top>=s+i||(o.current!==void 0&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{if(o.current=void 0,!t.isConnected||t.open)return;let e=n.getBoundingClientRect().top+n.clientTop;n.scrollTop+=t.getBoundingClientRect().top-e-i-8,r.focus({preventScroll:!0})}))},children:[n,(0,W.jsx)(`span`,{className:`activity-collapse-hint`,"aria-hidden":`true`,children:`收起`}),(0,W.jsx)(J,{name:`chevron`,size:14})]}),r]})}var Db={inProgress:`审核中`,approved:`已允许`,denied:`已拒绝`,timedOut:`审核超时`,aborted:`审核已中止`,unknown:`结果未确认`},Ob={low:`低`,medium:`中`,high:`高`,critical:`极高`},kb={unknown:`未知`,low:`低`,medium:`中`,high:`高`};function Ab(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString(`zh-CN`,{hour12:!1}):`未提供有效时间`}function jb({review:e}){return(0,W.jsx)(Eb,{className:`auto-review-card auto-review-${e.status}`,label:`自动审核结果:${e.actionSummary||e.actionLabel},${Db[e.status]}`,summary:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{name:e.status===`approved`?`check`:e.status===`denied`?`close`:e.status===`inProgress`?`refresh`:`alert`,size:15}),(0,W.jsxs)(`span`,{className:`activity-description`,children:[(0,W.jsx)(`span`,{className:`activity-label`,children:`自动审核`}),(0,W.jsx)(`code`,{className:`command-summary`,children:e.actionSummary||e.actionLabel})]}),(0,W.jsx)(`span`,{className:`auto-review-status`,role:`status`,children:Db[e.status]})]}),children:(0,W.jsxs)(`div`,{className:`activity-body auto-review-body`,children:[(0,W.jsxs)(`div`,{className:`auto-review-operation`,children:[(0,W.jsx)(`span`,{children:e.actionLabel}),(0,W.jsx)(`code`,{children:e.actionSummary||`未提供被审核操作。`})]}),(0,W.jsxs)(`div`,{className:`auto-review-rationale`,children:[(0,W.jsx)(`strong`,{children:`审核原因`}),(0,W.jsx)(`p`,{children:e.rationale?.trim()?e.rationale:`未提供审核原因。`})]}),(0,W.jsxs)(`details`,{className:`auto-review-details`,children:[(0,W.jsx)(`summary`,{children:`技术详情`}),(0,W.jsxs)(`dl`,{children:[e.cwd&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`工作目录`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.cwd})})]}),e.riskLevel&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`风险评估`}),(0,W.jsx)(`dd`,{children:Ob[e.riskLevel]})]}),e.userAuthorization&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`用户授权评估`}),(0,W.jsx)(`dd`,{children:kb[e.userAuthorization]})]}),(0,W.jsx)(`dt`,{children:`审核标识`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.reviewId})}),e.targetItemId&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`操作标识`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{children:e.targetItemId})})]}),(0,W.jsx)(`dt`,{children:`开始时间`}),(0,W.jsx)(`dd`,{children:Ab(e.startedAtMs)}),e.completedAtMs!==void 0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`结束时间`}),(0,W.jsx)(`dd`,{children:Ab(e.completedAtMs)})]})]})]})]})})}function Mb(e){let t=[];for(let n of e){if(n.type===`userMessage`||n.type===`agentMessage`||n.type===`exitedReviewMode`||n.type===`contextCompaction`){t.push({kind:`message`,key:`message:${n.id}`,item:n});continue}let e=t.at(-1);e?.kind===`activity`?e.items.push(n):t.push({kind:`activity`,key:`activity:${n.id}`,items:[n]})}return t}function Nb(e){let t={total:e.length,reviews:0,running:0,completed:0,failed:0,denied:0,timedOut:0,interrupted:0,unknown:0};for(let n of e){let e=n.type===`autoApprovalReview`;e&&(t.reviews+=1);let r=e?n.autoReview?.status??`unknown`:n.status,i=n.details&&typeof n.details==`object`&&!Array.isArray(n.details)?n.details:void 0,a=n.type===`mcpToolCall`&&i?.error!=null||n.type===`dynamicToolCall`&&i?.success===!1||n.type===`imageGeneration`&&i?.failure!=null;n.error||r===`failed`||a?t.failed+=1:r===`denied`||r===`declined`?t.denied+=1:r===`timedOut`?t.timedOut+=1:r===`aborted`||r===`interrupted`?t.interrupted+=1:r===`inProgress`||r===`running`?t.running+=1:r===`approved`||r===`completed`?t.completed+=1:r&&(t.unknown+=1)}return t}function Pb({items:e,children:t}){let n=Nb(e),r=e.at(-1),i=r?.autoReview?.actionSummary||r?.command,a=[{count:n.running,label:`执行中`,className:`activity-group-running`},{count:n.failed,label:`失败`,className:`activity-group-problem`},{count:n.denied,label:`已拒绝`,className:`activity-group-problem`},{count:n.timedOut,label:`审核超时`,className:`activity-group-attention`},{count:n.interrupted,label:`已中止`,className:`activity-group-attention`},{count:n.unknown,label:`结果未确认`,className:`activity-group-attention`},{count:n.completed,label:`已完成`,className:``}].filter(({count:e})=>e>0),o=a.map(({label:e,count:t})=>`${e} ${t}`).join(`,`);return(0,W.jsx)(Eb,{className:`activity-group`,group:!0,label:`${n.total} 项活动${o?`,${o}`:``}`,summary:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{name:n.running?`refresh`:`terminal`,size:16}),(0,W.jsxs)(`span`,{className:`activity-description`,children:[(0,W.jsxs)(`span`,{className:`activity-label`,children:[n.total,` 项活动`]}),n.reviews>0&&(0,W.jsxs)(`span`,{className:`activity-group-reviews`,children:[`含 `,n.reviews,` 次自动审核`]}),i&&(0,W.jsx)(`code`,{className:`command-summary`,children:i})]}),(0,W.jsx)(`span`,{className:`activity-group-status`,role:`status`,children:a.map(({label:e,count:t,className:n})=>(0,W.jsxs)(`span`,{className:n,children:[e,` `,t]},e))})]}),children:(0,W.jsx)(`div`,{className:`activity-group-items`,children:t})})}function Fb({item:e,offline:t=!1}){let n=e.status??`unknown`,r=n===`inProgress`,i={inProgress:`正在压缩上下文…`,completed:`上下文已压缩`,failed:`上下文压缩失败`,interrupted:`上下文压缩已中断`}[n]??`上下文压缩状态未知`,a=e.error??(r?`正在整理会话上下文,完成后将继续当前任务。`:n===`unknown`?`未收到明确的完成结果,请查看后续任务状态。`:void 0);return(0,W.jsxs)(`div`,{className:`context-compaction context-compaction-${n}`,"data-testid":`context-compaction`,"data-state":n,role:n===`failed`?`alert`:`status`,"aria-label":`上下文压缩状态`,children:[(0,W.jsx)(`span`,{className:`compaction-icon`,children:(0,W.jsx)(J,{name:n===`failed`?`alert`:n===`completed`?`check`:`compress`,size:18})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[r&&t&&`上次已知:`,i]}),a&&(0,W.jsx)(`p`,{children:a})]})]})}function Ib(e){if(e===void 0||!Number.isFinite(e)||e<0)return;if(e>0&&e<1e3)return`不足 1 秒`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60);return[...n?[`${n} 小时`]:[],...r?[`${r} 分`]:[],...t%60||t===0?[`${t%60} 秒`]:[]].join(` `)}function Lb(e,t){if(e===void 0||!Number.isFinite(e)||e<0)return;let n=new Date(e);if(!Number.isFinite(n.getTime()))return;let r=new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`,timeZoneName:`longOffset`}).formatToParts(n),i=e=>r.find(t=>t.type===e).value;return{dateTime:n.toISOString(),label:`${i(`year`)}-${i(`month`)}-${i(`day`)} ${i(`hour`)}:${i(`minute`)}:${i(`second`)}(${i(`timeZoneName`).replace(/^GMT$/,`GMT+00:00`).replace(`GMT`,`UTC`)})`}}function Rb(e,t){if(e===void 0||!Number.isSafeInteger(e)||e<0||t===void 0||!Number.isFinite(t)||t<=0)return;let n=e/(t/1e3);if(Number.isFinite(n))return n>0&&n<.1?`<0.1`:n.toFixed(1)}function zb({text:e}){let t=(0,O.useRef)(!1),n=(0,O.useRef)(void 0),[r,i]=(0,O.useState)(`idle`);(0,O.useEffect)(()=>()=>clearTimeout(n.current),[]);async function a(){if(!t.current){t.current=!0,clearTimeout(n.current),i(`idle`);try{await navigator.clipboard.writeText(e),i(`copied`),n.current=setTimeout(()=>i(`idle`),2e3)}catch{i(`failed`)}finally{t.current=!1}}}return(0,W.jsxs)(`span`,{className:`reply-copy-controls`,children:[(0,W.jsx)(ol,{asChild:!0,content:`复制回答(Markdown)`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,className:`reply-copy-button`,"aria-label":`复制回答`,onClick:()=>void a(),children:(0,W.jsx)(J,{name:r===`copied`?`check`:`copy`,size:14})})}),(0,W.jsxs)(`span`,{className:`reply-copy-feedback reply-copy-${r}`,role:`status`,children:[r===`copied`&&`已复制`,r===`failed`&&`复制失败,请手动选择回答复制。`]})]})}function Bb({turn:e}){if(e.status!==`completed`)return null;let t=Ib(e.durationMs),n=Lb(e.completedAt),r=Rb(e.outputTokens,e.durationMs),i=e.items.findLast(e=>e.type===`agentMessage`&&e.text?.trim())?.text;return(0,W.jsxs)(`div`,{className:`turn-completion`,role:`group`,"aria-label":`本轮完成信息`,children:[(0,W.jsxs)(`span`,{className:`turn-completion-status`,children:[(0,W.jsx)(J,{name:`check`,size:14}),`已完成`]}),(0,W.jsxs)(`span`,{children:[` · `,t?`耗时 ${t}`:`耗时未知`]}),(0,W.jsxs)(`span`,{children:[` · `,(0,W.jsx)(nl,{children:(0,W.jsxs)(rl,{children:[(0,W.jsx)(il,{asChild:!0,children:(0,W.jsx)(`span`,{className:`turn-tps`,tabIndex:0,children:r===void 0?`TPS 未知`:`平均 ${r} TPS`})}),(0,W.jsx)(al,{children:r===void 0?`缺少完整的本轮 token 统计或有效耗时,无法计算 TPS。`:`本轮输出 ${e.outputTokens} tokens(含推理 token)÷ 整轮耗时(秒)。耗时包含工具调用、审批、等待等时间,因此该值通常低于纯模型生成时的 TPS。`})]})})]}),(0,W.jsxs)(`span`,{children:[` · `,n?(0,W.jsxs)(W.Fragment,{children:[`完成于 `,(0,W.jsx)(`time`,{dateTime:n.dateTime,children:n.label})]}):`完成时间未知`]}),i&&(0,W.jsx)(zb,{text:i})]})}function Vb({item:e}){return(0,W.jsx)(`article`,{className:`message user-message`,"aria-label":`你的消息`,"data-prompt-id":e.id,tabIndex:-1,children:(0,W.jsxs)(`div`,{className:`message-content`,children:[e.questionReplies?.length?e.questionReplies.map((e,t)=>(0,W.jsxs)(`div`,{className:`user-question-reply`,children:[(0,W.jsx)(`blockquote`,{children:e.question}),(0,W.jsx)(`p`,{className:`user-text`,children:e.answer})]},t)):(0,W.jsx)(`p`,{className:`user-text`,children:e.text}),e.images&&(0,W.jsx)(`div`,{className:`message-images`,children:e.images.map((e,t)=>(0,W.jsx)(`img`,{src:e,alt:`已发送的图片 ${t+1}`,loading:`lazy`},t))}),(e.imageCount??0)>(e.images?.length??0)&&(0,W.jsxs)(`p`,{className:`subtle`,children:[(e.imageCount??0)-(e.images?.length??0),` 张图片未提供预览`]}),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error})]})})}function Hb({thread:e,onJump:t}){let n=(0,O.useRef)(null),[r,i]=(0,O.useState)(),a=e?.turns.flatMap(e=>e.items).find(e=>e.type===`userMessage`&&e.id===r),o=(0,O.useCallback)(()=>{let e=n.current?.parentElement?.querySelector(`.conversation-scroll`);if(!e)return;let t=e.getBoundingClientRect().top+e.clientTop,r=e.querySelectorAll(`.conversation-content .user-message[data-prompt-id]`),a;for(let e=r.length-1;e>=0;e--)if(r[e].getBoundingClientRect().top<t){a=r[e].dataset.promptId;break}i(a)},[]);(0,O.useLayoutEffect)(o,[e,o]),(0,O.useEffect)(()=>{let e=n.current?.parentElement?.querySelector(`.conversation-scroll`),t=e?.querySelector(`.conversation-content`);if(!e||!t)return;let r,i=()=>{r===void 0&&(r=requestAnimationFrame(()=>{r=void 0,o()}))},a=new ResizeObserver(i);return a.observe(e),a.observe(t),e.addEventListener(`scroll`,i,{passive:!0}),()=>{a.disconnect(),e.removeEventListener(`scroll`,i),r!==void 0&&cancelAnimationFrame(r)}},[o]);let s=Math.max(a?.imageCount??0,a?.images?.length??0);return(0,W.jsx)(`div`,{className:`sticky-prompt-slot`,ref:n,children:a&&(0,W.jsx)(ol,{asChild:!0,content:`回到 Prompt 原文`,children:(0,W.jsxs)(q,{variant:`ghost`,className:`sticky-prompt`,"aria-label":`回到 Prompt 原文`,onClick:e=>{let r=n.current?.parentElement?.querySelector(`.conversation-scroll`),i=[...r?.querySelectorAll(`[data-prompt-id]`)??[]].find(e=>e.dataset.promptId===a.id);if(!r||!i)return;let o=e.currentTarget.getBoundingClientRect().height+8;t(),i.focus({preventScroll:!0}),r.scrollTop+=i.getBoundingClientRect().top-r.getBoundingClientRect().top-r.clientTop-o},children:[(0,W.jsx)(`span`,{className:`sticky-prompt-label`,children:`你的要求`}),(0,W.jsx)(`span`,{className:`sticky-prompt-text`,children:a.text?.trim()||(s?`${s} 张图片`:`用户 Prompt`)}),(0,W.jsx)(J,{name:`down`,size:14,style:{transform:`rotate(180deg)`}})]})})})}var Ub={commandExecution:`执行命令`,fileChange:`文件变更`,reasoning:`思考过程`,mcpToolCall:`调用工具`,webSearch:`搜索网页`,plan:`执行计划`,enteredReviewMode:`开始代码审查`,exitedReviewMode:`代码审查结果`},Wb={completed:`已完成`,inProgress:`执行中`,running:`执行中`,failed:`失败`,declined:`已拒绝`,interrupted:`已中断`};function Gb({item:e}){let t=yb();return(0,W.jsx)(Eb,{className:`activity${e.status===`failed`?` activity-failed`:``}`,label:`${Ub[e.type]??e.type}${e.command?`:${e.command}`:``}`,summary:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(J,{name:e.type===`fileChange`?`code`:`terminal`,size:16}),(0,W.jsxs)(`span`,{className:`activity-description`,children:[(0,W.jsx)(`span`,{className:`activity-label`,children:Ub[e.type]??e.type}),e.command&&(0,W.jsx)(`code`,{className:`command-summary`,children:e.command})]}),(0,W.jsx)(`span`,{className:`activity-status`,children:e.status?Wb[e.status]??e.status:``})]}),children:(0,W.jsxs)(`div`,{className:`activity-body`,children:[e.cwd&&(0,W.jsx)(`p`,{className:`mono subtle`,children:e.cwd}),e.command&&(0,W.jsx)(`pre`,{className:`command`,children:(0,W.jsxs)(`code`,{children:[`$ `,e.command]})}),e.text&&(0,W.jsx)(Zy,{text:e.text}),e.output!==void 0&&(0,W.jsx)(`pre`,{className:`tool-output`,children:(0,W.jsx)(`code`,{children:e.output||`暂无输出`})}),e.truncated&&(0,W.jsxs)(`p`,{className:`truncation`,children:[(0,W.jsx)(J,{name:`alert`,size:14}),`输出超出显示上限,部分内容已截断。`]}),e.changes?.map((n,r)=>(0,W.jsxs)(q,{className:`file-change-link`,variant:`ghost`,onClick:()=>t({id:e.id,scope:`此工具的文件变更`,source:`item`,selectedPath:n.path}),children:[(0,W.jsx)(J,{name:`code`,size:15}),(0,W.jsx)(`code`,{children:n.path}),(0,W.jsx)(`span`,{children:`查看变更`}),(0,W.jsx)(J,{name:`chevron`,size:14})]},`${n.path}:${r}`)),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error}),e.details!==void 0&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:`活动详情`}),(0,W.jsx)(`pre`,{children:JSON.stringify(e.details,null,2)})]})]})})}function Kb({item:e,questionControls:t,replies:n}){return e.type===`contextCompaction`?e.status===`inProgress`?null:(0,W.jsx)(Fb,{item:e}):e.type===`userMessage`?(0,W.jsx)(Vb,{item:e}):e.type===`autoApprovalReview`&&e.autoReview?(0,W.jsx)(jb,{review:e.autoReview}):e.type===`agentMessage`||e.type===`exitedReviewMode`?(0,W.jsx)(`article`,{className:`message assistant-message`,"aria-label":`Codex 的回复`,children:(0,W.jsxs)(`div`,{className:`message-content`,children:[e.type===`agentMessage`&&e.questions?.length?(0,W.jsx)(Tb,{itemId:e.id,questions:e.questions,replies:n,disabled:t?.disabled??!0,onReply:t?.onReply??(async()=>!1)}):(0,W.jsx)(Zy,{text:e.text??``}),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error})]})}):(0,W.jsx)(Gb,{item:e})}function qb({turn:e,offline:t}){if(!e.reconnect)return null;let n=e.reconnect.status===`retrying`;return(0,W.jsxs)(`div`,{className:`codex-reconnect codex-reconnect-${e.reconnect.status}`,"data-testid":`codex-reconnect-status`,"data-state":e.reconnect.status,role:n?`status`:`alert`,"aria-label":`Codex 连接状态`,children:[(0,W.jsx)(J,{name:n?`refresh`:`alert`,size:18}),(0,W.jsxs)(`div`,{className:`codex-reconnect-content`,children:[(0,W.jsxs)(`strong`,{children:[t&&`上次已知:`,n?`Codex Reconnecting…`:`Codex 重新连接失败`]}),(0,W.jsx)(`p`,{children:n?`正在重新连接模型服务,Codex 会自动重试。恢复后将继续当前任务。`:kl(e.status)?`Codex 已停止重试。请检查运行 Codex 的服务器网络与模型服务;若本轮仍未结束,可点击下方“中断”,结束后重新发送要求以继续。`:`Codex 已停止重试。请检查运行 Codex 的服务器网络与模型服务,然后重新发送要求以继续。`}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`连接详情`}),(0,W.jsx)(`p`,{className:`codex-reconnect-message`,children:e.reconnect.message})]})]})]})}function Jb(e){return(0,W.jsx)(Ry,{threadId:e.thread?.id,children:(0,W.jsx)(Yb,{...e})},e.thread?.id??`empty`)}function Yb({thread:e,offline:t,history:n,projectName:r,needsProject:i=!1,canAddProject:a=!0,onAddProject:o,readingEnabled:s=!0,onReadCompleted:c,questionControls:l}){let u=yb(),d=(0,O.useRef)(null),f=(0,O.useRef)(null),p=(0,O.useRef)(!0),[m,h]=(0,O.useState)(!1),g=(0,O.useRef)(e?.id),_=(0,O.useRef)(void 0),v=(0,O.useRef)(void 0),y=(0,O.useRef)(0),b=(0,O.useRef)(!1),x=(0,O.useRef)(!1),S=e?.turns.at(-1),C=new Map;for(let t of e?.turns??[])for(let e of t.items)for(let t of e.questionReplies??[]){let e=C.get(t.questionItemId)??[];C.set(t.questionItemId,[...e,t])}let w=S&&kl(S.status)?S.items.findLast(e=>e.type===`contextCompaction`&&e.status===`inProgress`):void 0;(0,O.useLayoutEffect)(()=>{g.current!==e?.id&&(g.current=e?.id,p.current=!0,h(!1),v.current=void 0,b.current=!1,x.current=!1);let t=d.current;if(p.current)f.current?.scrollIntoView({block:`end`});else if(t&&v.current){let e=[...t.querySelectorAll(`[data-turn-id]`)].find(e=>e.dataset.turnId===v.current.id);e&&(t.scrollTop+=e.getBoundingClientRect().top-t.getBoundingClientRect().top-v.current.offset)}t&&(y.current=t.scrollTop)},[e]);let T=(0,O.useCallback)(()=>{let e=d.current;if(!e)return;b.current=x.current&&e.scrollTop<y.current,y.current=e.scrollTop;let t=[...e.querySelectorAll(`[data-turn-id]`)].find(t=>t.getBoundingClientRect().bottom>e.getBoundingClientRect().top);v.current=t?{id:t.dataset.turnId,offset:t.getBoundingClientRect().top-e.getBoundingClientRect().top}:void 0,b.current&&e.scrollTop<Math.max(600,e.clientHeight*1.5)&&!n?.error&&n?.onLoadOlder(),p.current=e.scrollHeight-e.scrollTop-e.clientHeight<100,h(!p.current)},[n]);return(0,O.useEffect)(()=>{let e=d.current;e&&b.current&&e.scrollTop<Math.max(600,e.clientHeight*1.5)&&!n?.loading&&!n?.error&&n?.onLoadOlder()},[e,n]),(0,O.useEffect)(()=>{let e=d.current;if(!e)return;let t=e=>{e.target instanceof HTMLDetailsElement&&e.target.classList.contains(`collapsible-activity`)&&T()};return e.addEventListener(`toggle`,t,!0),()=>e.removeEventListener(`toggle`,t,!0)},[T]),(0,O.useEffect)(()=>{let t=d.current,n=f.current,r=e?.id,i=S?.id;if(!s||!c||!t||!n||!r||!i||S.status!==`completed`)return;let a=()=>{if(document.visibilityState!==`visible`||!document.hasFocus()||document.querySelector(`dialog[open]`)||t.clientHeight===0)return;let e=t.getBoundingClientRect(),a=n.getBoundingClientRect(),o=Math.max(0,e.top+t.clientTop),s=Math.min(window.innerHeight,e.top+t.clientTop+t.clientHeight);if(s<=o||a.top<o||a.bottom>s)return;let l=_.current;(l?.threadId!==r||l.turnId!==i)&&(_.current={threadId:r,turnId:i},c(r,i))},o=new IntersectionObserver(a,{root:t});return o.observe(n),t.addEventListener(`scroll`,a),window.addEventListener(`focus`,a),document.addEventListener(`focusin`,a),document.addEventListener(`close`,a,!0),document.addEventListener(`visibilitychange`,a),a(),()=>{o.disconnect(),t.removeEventListener(`scroll`,a),window.removeEventListener(`focus`,a),document.removeEventListener(`focusin`,a),document.removeEventListener(`close`,a,!0),document.removeEventListener(`visibilitychange`,a)}},[e?.id,S?.id,S?.status,s,c]),(0,W.jsxs)(`div`,{className:`conversation-area`,children:[n?.cached&&(0,W.jsxs)(`div`,{className:`history-cache-notice`,role:`status`,children:[(0,W.jsx)(`span`,{children:n.syncError?`显示本机缓存 · 同步失败,部分历史可能缺失。`:`显示本机缓存 · 正在核对最新消息与任务状态…`}),n.syncError&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:n.onRetryOpen,children:`重新同步`})]}),S?.reconnect&&(0,W.jsx)(`div`,{className:`codex-reconnect-pinned`,children:(0,W.jsx)(qb,{turn:S,offline:t})}),w&&(0,W.jsx)(`div`,{className:`context-compaction-pinned`,children:(0,W.jsx)(Fb,{item:w,offline:t})}),(0,W.jsxs)(`div`,{className:`conversation-viewport`,children:[(0,W.jsx)(Hb,{thread:e,onJump:()=>{p.current=!1}}),(0,W.jsx)(`div`,{className:`conversation-scroll`,ref:d,onScroll:T,onWheel:()=>{x.current=!0},onTouchStart:()=>{x.current=!0},onPointerDown:()=>{x.current=!0},onKeyDown:e=>{[`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&(x.current=!0)},tabIndex:0,"aria-label":`会话消息`,children:(0,W.jsxs)(`div`,{className:`conversation-content`,children:[(e?.history?.olderCursor||n?.error)&&(0,W.jsxs)(`div`,{className:`history-pagination`,role:`status`,"aria-live":`polite`,"aria-busy":n?.loading,children:[(0,W.jsx)(`span`,{children:n?.error??(n?.loading?`正在加载较早的消息…`:`向上滚动,加载更早的消息`)}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:n?.loading,onClick:()=>n?.onLoadOlder(),children:n?.error?`重试加载`:`加载更早的消息`}),n?.error&&n.cached&&e?.history?.olderCursor&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:n.loading||n.cacheExhausted,onClick:n.onLoadCachedOlder,children:n.cacheExhausted?`此处尚无本机缓存`:`继续读取本机历史`})]}),e?.historyTruncated&&(0,W.jsxs)(`p`,{className:`truncation`,children:[(0,W.jsx)(J,{name:`alert`,size:14}),`当前实时快照已省略部分较早历史,以限制传输大小。`]}),n?.opening&&!e?.turns.length?(0,W.jsxs)(`div`,{className:`history-opening`,role:n.openingError?`alert`:`status`,children:[(0,W.jsx)(`p`,{children:n.openingError??`正在读取会话…`}),n.openingError?(0,W.jsx)(q,{variant:`secondary`,onClick:n.onRetryOpen,children:`重试读取`}):(0,W.jsxs)(`div`,{className:`history-skeleton`,"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{})]})]}):e?.turns.length?e.turns.map((e,n)=>(0,W.jsxs)(`section`,{className:`turn`,"data-turn-id":e.id,"aria-label":`第 ${n+1} 轮`,children:[(0,W.jsxs)(`div`,{className:`turn-heading`,children:[(0,W.jsxs)(`span`,{children:[`第 `,n+1,` 轮`]}),(0,W.jsx)(Al,{status:e.status,offline:t})]}),e.id!==S?.id&&e.reconnect?.status===`failed`&&(0,W.jsx)(qb,{turn:e,offline:t}),Mb(e.items).map(e=>e.kind===`message`?(0,W.jsx)(Kb,{item:e.item,questionControls:l,replies:[...C.get(e.item.id)??[],...(e.item.questions??[]).flatMap((t,n)=>C.get(Cb(e.item.id,n))??[])]},e.key):(0,W.jsx)(Pb,{items:e.items,children:e.items.map(e=>(0,W.jsx)(Kb,{item:e},e.id))},e.key)),(e.diff!==void 0||e.items.some(e=>e.changes?.length))&&(0,W.jsxs)(q,{className:`turn-diff`,variant:`ghost`,onClick:()=>u({id:e.id,scope:`第 ${n+1} 轮变更`,source:`turn`}),children:[(0,W.jsx)(J,{name:`code`,size:17}),(0,W.jsxs)(`span`,{children:[`本轮变更预览`,(0,W.jsx)(`small`,{children:`查看文件与代码行变更`})]}),(0,W.jsx)(J,{name:`chevron`,size:16})]}),e.error&&e.reconnect?.status!==`failed`&&!e.items.some(t=>t.type===`contextCompaction`&&t.error===e.error)&&(0,W.jsx)(`div`,{className:`error-banner`,children:e.error}),(0,W.jsx)(Bb,{turn:e})]},e.id)):(0,W.jsxs)(`div`,{className:`empty-state`,"data-testid":`workspace-start`,"data-thread-ready":!!e,children:[(0,W.jsx)(`div`,{className:`empty-symbol`,children:(0,W.jsx)(J,{name:`code`,size:36})}),(0,W.jsx)(`p`,{className:`eyebrow`,children:`你的开发工作空间`}),(0,W.jsx)(`h1`,{children:i?`添加项目,开始工作。`:`从一个想法,开始工作。`}),i?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{children:[`连接服务器上已有的项目目录,继续历史会话或创建新任务。`,(0,W.jsx)(`br`,{}),`项目会保存在服务器上,下次打开即可继续。`]}),(0,W.jsxs)(q,{onClick:o,disabled:!a,children:[(0,W.jsx)(J,{name:`plus`,size:16}),`添加项目`]})]}):(0,W.jsxs)(`p`,{children:[`描述你要完成的任务,也可以粘贴图片、问题或错误信息。`,(0,W.jsx)(`br`,{}),`发送后将在`,r?`「${r}」`:`当前项目`,`中开始新会话。`]}),(0,W.jsxs)(`div`,{className:`empty-features`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`terminal`,size:16}),`实时执行过程`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`code`,size:16}),`逐轮变更预览`]}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(J,{name:`check`,size:16}),`随时审批与追加`]})]})]}),(0,W.jsx)(`div`,{ref:f})]})})]}),m&&(0,W.jsxs)(q,{className:`back-to-bottom`,variant:`secondary`,size:`sm`,onClick:()=>{p.current=!0,h(!1),f.current?.scrollIntoView({behavior:`smooth`,block:`end`})},children:[(0,W.jsx)(J,{name:`down`,size:15}),`回到最新内容`]})]})}function Xb({title:e,rename:t,pending:n}){let[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(!1),d=(0,O.useRef)(!1),f=(0,O.useRef)(null),p=(0,O.useRef)(null),m=(0,O.useRef)(!1),h=(0,O.useRef)(!1),g=(0,O.useRef)(-1/0),_=(0,O.useId)(),v=t.unavailableReason?.replaceAll(`/status`,`状态诊断`);(0,O.useEffect)(()=>{r&&(f.current?.focus(),f.current?.select())},[r]),(0,O.useEffect)(()=>{r&&!l&&s&&f.current?.focus()},[r,l,s]),(0,O.useEffect)(()=>{!s||l||n||r||(e===a.trim()?c(void 0):i(!0))},[s,l,n,r,e,a]),(0,O.useLayoutEffect)(()=>{!r&&m.current&&(m.current=!1,p.current?.focus())},[r]);function y(){m.current=!0,i(!1),c(void 0)}async function b(){if(d.current||v)return;let e=a.trim()?Xe(a):`请输入会话名称。`;if(e)c(e),f.current?.focus();else{d.current=!0,u(!0),c(void 0),y();try{let e=await t.run(a);e.error?c(e.message.replaceAll(`/status`,`状态诊断`)):c(void 0)}catch(e){c(En(e))}finally{d.current=!1,u(!1)}}}return(0,W.jsx)(`div`,{className:`thread-title-editor${r?` thread-title-editing`:``}`,children:r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h1`,{className:`sr-only`,children:e}),(0,W.jsxs)(`form`,{className:`thread-title-form`,"aria-label":`重命名会话`,"aria-busy":l,onSubmit:e=>{e.preventDefault(),h.current||b()},children:[(0,W.jsxs)(`div`,{className:`thread-title-fields`,children:[(0,W.jsx)(`input`,{ref:f,"aria-label":`会话名称`,"aria-describedby":`${_}-help${s?` ${_}-error`:``}`,"aria-invalid":!!s,value:a,disabled:l,onChange:e=>{o(e.target.value),c(void 0)},onCompositionStart:()=>{h.current=!0},onCompositionEnd:()=>{h.current=!1,g.current=performance.now()},onBlur:()=>{h.current=!1,g.current=-1/0},onKeyDown:e=>{h.current||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229?e.key===`Enter`&&e.preventDefault():(e.key===`Escape`&&(e.preventDefault(),d.current||y()),e.key===`Enter`&&(e.preventDefault(),performance.now()-g.current>=100&&b()))},onKeyUp:e=>{e.key===`Enter`&&(g.current=-1/0)}}),(0,W.jsx)(ol,{content:`保存会话名称`,children:(0,W.jsx)(q,{type:`submit`,size:`icon`,"aria-label":`保存会话名称`,disabled:l||!!v,children:(0,W.jsx)(J,{name:`check`,size:16})})}),(0,W.jsx)(ol,{content:`取消重命名`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`取消重命名`,disabled:l,onClick:y,children:(0,W.jsx)(J,{name:`close`,size:16})})})]}),(0,W.jsx)(`p`,{id:`${_}-help`,className:`thread-title-help`,children:l?`正在保存…`:v??`Enter 保存 · Esc 取消 · 最多 100 个字符`}),s&&(0,W.jsx)(`p`,{id:`${_}-error`,className:`thread-title-error`,role:`alert`,children:s})]})]}):(0,W.jsx)(ol,{id:`${_}-hint`,className:`thread-title-hint`,content:v??`点击标题重命名会话`,children:(0,W.jsx)(`h1`,{"aria-label":e,children:(0,W.jsxs)(`button`,{ref:p,type:`button`,className:`thread-title-trigger`,"aria-label":`重命名会话`,"aria-describedby":`${_}-hint`,"aria-disabled":!!v,onClick:()=>{v||(o(e),c(void 0),h.current=!1,g.current=-1/0,i(!0))},children:[(0,W.jsx)(`span`,{children:e}),(0,W.jsx)(ve,{size:13,"aria-hidden":`true`})]})})})})}var Zb=[`image/png`,`image/jpeg`,`image/webp`,`image/gif`],Qb={text:``,images:[]};function $b(e,t){if(e.some(e=>!Zb.includes(e.type)))return`请粘贴 PNG、JPEG、WebP 或 GIF 图片。`;if(e.some(e=>e.size===0))return`图片为空,请重新复制后粘贴。`;if(e.length+t.length>4)return`每条消息最多添加 4 张图片。`;if([...e,...t].reduce((e,t)=>e+t.size,0)>2097152)return`每条消息的图片总大小不能超过 2 MiB,请缩小图片后重试。`}function ex(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{typeof r.result==`string`?t(r.result):n(Error(`图片读取失败,请重新粘贴。`))},r.onerror=r.onabort=()=>n(Error(`图片读取失败,请重新粘贴。`)),r.readAsDataURL(e)})}function tx(e,t){let[n,r]=(0,O.useState)(0),i=e&&t?JSON.stringify([e,t,n]):``,[a,o]=(0,O.useState)();return(0,O.useEffect)(()=>{if(!i||!e)return;let t=!1;return ze.runtimeSettings(e).then(e=>{t||o({key:i,value:e})},()=>{t||o({key:i,error:`无法读取默认配置`})}),()=>{t=!0}},[i,e]),{value:a?.key===i?a.value:void 0,error:a?.key===i?a.error:void 0,loading:!!(i&&a?.key!==i),retry:()=>r(e=>e+1)}}var nx=Object.defineProperty,rx=(e,t)=>nx(e,`name`,{value:t,configurable:!0});function ix(e,[t,n]){return Math.min(n,Math.max(t,e))}rx(ix,`clamp`);var ax=Object.defineProperty,ox=(e,t)=>ax(e,`name`,{value:t,configurable:!0});function sx(e){let t=e+`CollectionProvider`,[n,r]=Yr(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=ox(e=>{let{scope:t,children:n}=e,r=O.useRef(null),a=O.useRef(new Map).current;return(0,W.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=ei(s),l=O.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Wr(t,a(s,n).collectionRef);return(0,W.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ei(u),p=O.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=O.useRef(null),s=Wr(t,o),c=a(u,n);return O.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,W.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return O.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return ox(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}ox(sx,`createCollection`);var cx=new WeakMap,lx=class e extends Map{static{ox(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],cx.set(this,!0)}set(e,t){return cx.get(this)&&!this.has(e)&&this.#e.push(e),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=r?this.size:this.size+1,a=fx(e),o=a>=0?Math.min(a,i-1):Math.max(i+a,0);if(r?this.#e.indexOf(t)===o:o===this.size)return this.set(t,n),this;let s=this.#e.filter(e=>e!==t);s.splice(o,0,t);let c=s.map(e=>[e,e===t?n:this.get(e)]);this.clear();for(let[e,t]of c)this.set(e,t);return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);if(r===-1)return this;let i=this.#e.indexOf(t),a=i!==-1&&i<r?r-1:r;return this.insert(a,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);if(r===-1)return this;let i=this.#e.indexOf(t),a=i!==-1&&i<=r?r:r+1;return this.insert(a,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=ux(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=ux(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return ux(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=0,a=n;for(let e of this)a=i===0&&!r?e:Reflect.apply(t,this,[a,e,i,this]),i++;return a}reduceRight(...e){let[t,n]=e,r=e.length>1;if(!r&&this.size===0)throw TypeError(`Reduce of empty OrderedDict with no initial value`);let i=n;for(let e=this.size-1;e>=0;e--){let n=this.entryAt(e);i=e===this.size-1&&!r?n:Reflect.apply(t,this,[i,n,e,this])}return i}sort(e){if(typeof e!=`function`)throw TypeError(`OrderedDict.sort requires a compare function`);let t=[...this.entries()].sort(e);this.clear();for(let[e,n]of t)this.set(e,n);return this}toSorted(t){if(typeof t!=`function`)throw TypeError(`OrderedDict.toSorted requires a compare function`);let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e;for(let e of this.#e.slice(t,n))r.set(e,this.get(e));return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function ux(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=dx(e,t);return n===-1?void 0:e[n]}ox(ux,`at`);function dx(e,t){let n=e.length,r=fx(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}ox(dx,`toSafeIndex`);function fx(e){return e!==e||e===0?0:Math.trunc(e)}ox(fx,`toSafeInteger`);function px(e){let t=e+`CollectionProvider`,[n,r]=Yr(t),[i,a]=n(t);i.displayName=e+`CollectionStableContextProvider`;let[o,s]=n(t);o.displayName=e+`CollectionStatefulContextProvider`;let c=ox(({state:e,...t})=>e?(0,W.jsx)(u,{...t,state:e}):(0,W.jsx)(l,{...t}),`CollectionProvider`);c.displayName=t;let l=ox(e=>{let t=_();return(0,W.jsx)(u,{...e,state:t})},`CollectionInit`);l.displayName=e+`CollectionInit`;let u=ox(e=>{let{scope:t,children:n,state:r}=e,a=O.useRef(null),[s,c]=O.useState(null),l=Wr(a,c),[u,d]=r,f=O.useRef(new lx),p=O.useCallback(()=>{let e=f.current;return gx(e)||e.sort(_x),e},[]);return O.useEffect(()=>{if(!s)return;let e=vx(()=>{d(e=>{let t=e.toSorted(_x);return t.some(([t],n)=>e.keyAt(n)!==t)?t:e})});return e.observe(s,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[s,d]),(0,W.jsx)(i,{scope:t,collectionElementRef:l,collectionElementRefObject:a,getCollection:p,setCollection:d,registryRef:f,children:(0,W.jsx)(o,{scope:t,collectionElement:s,collection:u,children:n})})},`CollectionProviderImpl`);u.displayName=e+`CollectionProviderImpl`;let d=e+`CollectionSlot`,f=ei(d),p=O.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Wr(t,a(d,n).collectionElementRef);return(0,W.jsx)(f,{ref:i,children:r})});p.displayName=d;let m=e+`CollectionItemSlot`,h=ei(m),g=O.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=O.useRef(null),{setCollection:s,registryRef:c}=a(m,n),l=O.useRef(i);mx(l.current,i)||(l.current=i);let u=l.current,d=Wr(t,O.useCallback(e=>{let t=c.current;e?t.set(e,{...l.current,element:e}):o.current&&t.delete(o.current)},[c]),o);yi(()=>{let e=o.current,t=c.current;e&&t.has(e)&&t.set(e,{...u,element:e})},[u,c]);let f=O.useRef(null);return O.useEffect(()=>{let e=o.current,t=f.current;((t?.element??null)!==e||e&&t?.itemData!==u)&&(f.current=e?{element:e,itemData:u}:null,s(n=>{let r=new lx(n);return t&&t.element!==e&&r.delete(t.element),e&&r.set(e,{...u,element:e}),r.sort(_x)}))}),O.useEffect(()=>()=>{let e=f.current;f.current=null,e&&s(t=>{if(!t.has(e.element))return t;let n=new lx(t);return n.delete(e.element),n})},[s]),(0,W.jsx)(h,{"data-radix-collection-item":``,ref:d,children:r})});g.displayName=m;function _(){return O.useState(new lx)}ox(_,`useInitCollection`);function v(t){let{collection:n}=s(e+`CollectionConsumer`,t);return n}ox(v,`useCollection`);function y(t){let{getCollection:n}=a(e+`CollectionConsumer`,t);return n}return ox(y,`useGetCollection`),[{Provider:c,Slot:p,ItemSlot:g},{createCollectionScope:r,useCollection:v,useGetCollection:y,useInitCollection:_}]}ox(px,`createCollection`);function mx(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}ox(mx,`shallowEqual`);function hx(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}ox(hx,`isElementPreceding`);function gx(e){let t;for(let n of e.keys()){if(t){let e=t.compareDocumentPosition(n);if(!(e&Node.DOCUMENT_POSITION_DISCONNECTED)&&e&Node.DOCUMENT_POSITION_PRECEDING)return!1}t=n}return!0}ox(gx,`isInDocumentOrder`);function _x(e,t){return!e[1].element||!t[1].element?0:hx(e[1].element,t[1].element)?-1:1}ox(_x,`sortByDocumentPosition`);function vx(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}ox(vx,`getChildListObserver`);var yx=Object.defineProperty,bx=(e,t)=>yx(e,`name`,{value:t,configurable:!0}),xx={LTR:`ltr`,RTL:`rtl`},Sx=O.createContext(void 0);function Cx(e){let t=O.useContext(Sx);return e||t||xx.LTR}bx(Cx,`useDirection`);var wx=Object.defineProperty,Tx=(e,t)=>wx(e,`name`,{value:t,configurable:!0}),Ex=0,Dx=null;function Ox(e){return kx(),e.children}Tx(Ox,`FocusGuards`);function kx(){O.useEffect(()=>{Dx||={start:Ax(),end:Ax()};let{start:e,end:t}=Dx;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Ex++,()=>{Ex===1&&(Dx?.start.remove(),Dx?.end.remove(),Dx=null),Ex=Math.max(0,Ex-1)}},[])}Tx(kx,`useFocusGuards`);function Ax(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}Tx(Ax,`createFocusGuard`);var jx=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Mx=new WeakMap,Nx=new WeakMap,Px={},Fx=0,Ix=function(e){return e&&(e.host||Ix(e.parentNode))},Lx=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Ix(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Rx=function(e,t,n,r){var i=Lx(t,Array.isArray(e)?e:[e]);Px[n]||(Px[n]=new WeakMap);var a=Px[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(Mx.get(e)||0)+1,l=(a.get(e)||0)+1;Mx.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Nx.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Fx++,function(){o.forEach(function(e){var t=Mx.get(e)-1,i=a.get(e)-1;Mx.set(e,t),a.set(e,i),t||(Nx.has(e)||e.removeAttribute(r),Nx.delete(e)),i||e.removeAttribute(n)}),Fx--,Fx||(Mx=new WeakMap,Mx=new WeakMap,Nx=new WeakMap,Px={})}},zx=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||jx(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Rx(r,i,n,`aria-hidden`)):function(){return null}},Bx=function(){return Bx=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Bx.apply(this,arguments)};function Vx(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Hx(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Ux=`right-scroll-bar-position`,Wx=`width-before-scroll-bar`,Gx=`with-scroll-bars-hidden`,Kx=`--removed-body-scroll-bar-size`;function qx(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Jx(e,t){var n=(0,O.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Yx=typeof window<`u`?O.useLayoutEffect:O.useEffect,Xx=new WeakMap;function Zx(e,t){var n=Jx(t||null,function(t){return e.forEach(function(e){return qx(e,t)})});return Yx(function(){var t=Xx.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||qx(e,null)}),i.forEach(function(e){r.has(e)||qx(e,a)})}Xx.set(n,e)},[e]),n}function Qx(e){return e}function $x(e,t){t===void 0&&(t=Qx);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function eS(e){e===void 0&&(e={});var t=$x(null);return t.options=Bx({async:!0,ssr:!1},e),t}var tS=function(e){var t=e.sideCar,n=Vx(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return O.createElement(r,Bx({},n))};tS.isSideCarExport=!0;function nS(e,t){return e.useMedium(t),tS}var rS=eS(),iS=function(){},aS=O.forwardRef(function(e,t){var n=O.useRef(null),r=O.useState({onScrollCapture:iS,onWheelCapture:iS,onTouchMoveCapture:iS}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Vx(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=Zx([n,t]),C=Bx(Bx({},b),i);return O.createElement(O.Fragment,null,u&&O.createElement(x,{sideCar:rS,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?O.cloneElement(O.Children.only(s),Bx(Bx({},C),{ref:S})):O.createElement(v,Bx({},C,{className:c,ref:S}),s))});aS.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},aS.classNames={fullWidth:Wx,zeroRight:Ux};var oS=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function sS(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=oS();return t&&e.setAttribute(`nonce`,t),e}function cS(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function lS(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var uS=function(){var e=0,t=null;return{add:function(n){e==0&&(t=sS())&&(cS(t,n),lS(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},dS=function(){var e=uS();return function(t,n){O.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},fS=function(){var e=dS();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},pS={left:0,top:0,right:0,gap:0},mS=function(e){return parseInt(e||``,10)||0},hS=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[mS(n),mS(r),mS(i)]},gS=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return pS;var t=hS(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},_S=fS(),vS=`data-scroll-locked`,yS=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
43
|
+
.${Gx} {
|
|
44
44
|
overflow: hidden ${r};
|
|
45
45
|
padding-right: ${s}px ${r};
|
|
46
46
|
}
|
|
47
|
-
body[${
|
|
47
|
+
body[${vS}] {
|
|
48
48
|
overflow: hidden ${r};
|
|
49
49
|
overscroll-behavior: contain;
|
|
50
50
|
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
@@ -57,35 +57,35 @@ Error generating stack: `+e.message+`
|
|
|
57
57
|
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.${
|
|
60
|
+
.${Ux} {
|
|
61
61
|
right: ${s}px ${r};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.${
|
|
64
|
+
.${Wx} {
|
|
65
65
|
margin-right: ${s}px ${r};
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.${
|
|
68
|
+
.${Ux} .${Ux} {
|
|
69
69
|
right: 0 ${r};
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
.${
|
|
72
|
+
.${Wx} .${Wx} {
|
|
73
73
|
margin-right: 0 ${r};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
body[${
|
|
77
|
-
${
|
|
76
|
+
body[${vS}] {
|
|
77
|
+
${Kx}: ${s}px;
|
|
78
78
|
}
|
|
79
|
-
`},
|
|
79
|
+
`},bS=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},xS=function(){O.useEffect(function(){return document.body.setAttribute(vS,(bS()+1).toString()),function(){var e=bS()-1;e<=0?document.body.removeAttribute(vS):document.body.setAttribute(vS,e.toString())}},[])},SS=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;xS();var a=O.useMemo(function(){return gS(i)},[i]);return O.createElement(_S,{styles:yS(a,!t,i,n?``:`!important`)})},CS=!1;if(typeof window<`u`)try{var wS=Object.defineProperty({},"passive",{get:function(){return CS=!0,!0}});window.addEventListener(`test`,wS,wS),window.removeEventListener(`test`,wS,wS)}catch{CS=!1}var TS=CS?{passive:!1}:!1,ES=function(e){return e.tagName===`TEXTAREA`},DS=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!ES(e)&&n[t]===`visible`)},OS=function(e){return DS(e,`overflowY`)},kS=function(e){return DS(e,`overflowX`)},AS=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),NS(e,r)){var i=PS(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},jS=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},MS=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},NS=function(e,t){return e===`v`?OS(t):kS(t)},PS=function(e,t){return e===`v`?jS(t):MS(t)},FS=function(e,t){return e===`h`&&t===`rtl`?-1:1},IS=function(e,t,n,r,i){var a=FS(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=PS(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&NS(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},LS=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},RS=function(e){return[e.deltaX,e.deltaY]},zS=function(e){return e&&`current`in e?e.current:e},BS=function(e,t){return e[0]===t[0]&&e[1]===t[1]},VS=function(e){return`
|
|
80
80
|
.block-interactivity-${e} {pointer-events: none;}
|
|
81
81
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
82
|
-
`},zS=0,BS=[];function VS(e){var t=O.useRef([]),n=O.useRef([0,0]),r=O.useRef(),i=O.useState(zS++)[0],a=O.useState(lS)[0],o=O.useRef(e);O.useEffect(function(){o.current=e},[e]),O.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=zx([e.lockRef.current],(e.shards||[]).map(IS),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=O.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=PS(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=DS(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=DS(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return NS(h,t,e,h===`h`?s:c,!0)},[]),c=O.useCallback(function(e){var n=e;if(BS.length&&BS[BS.length-1]===a){var r=`deltaY`in n?FS(n):PS(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&LS(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(IS).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=O.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:HS(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=O.useCallback(function(e){n.current=PS(e),r.current=void 0},[]),d=O.useCallback(function(t){l(t.type,FS(t),t.target,s(t,e.lockRef.current))},[]),f=O.useCallback(function(t){l(t.type,PS(t),t.target,s(t,e.lockRef.current))},[]);O.useEffect(function(){return BS.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,SS),document.addEventListener(`touchmove`,c,SS),document.addEventListener(`touchstart`,u,SS),function(){BS=BS.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,SS),document.removeEventListener(`touchmove`,c,SS),document.removeEventListener(`touchstart`,u,SS)}},[]);var p=e.removeScrollBar,m=e.inert;return O.createElement(O.Fragment,null,m?O.createElement(a,{styles:RS(i)}):null,p?O.createElement(yS,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function HS(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var US=$x(eS,VS),WS=O.forwardRef(function(e,t){return O.createElement(nS,Lx({},e,{ref:t,sideCar:US}))});WS.classNames=nS.classNames;var GS=Object.defineProperty,KS=(e,t)=>GS(e,`name`,{value:t,configurable:!0}),qS={ItemAligned:`item-aligned`,Popper:`popper`},JS={LTR:`ltr`,RTL:`rtl`},YS=[` `,`Enter`,`ArrowUp`,`ArrowDown`],XS=[` `,`Enter`],ZS=`Select`,[QS,$S,eC]=ix(ZS),[tC,nC]=Yr(ZS,[eC,js]),rC=js(),[iC,aC]=tC(ZS),[oC,sC]=tC(ZS);function cC(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=rC(t),[_,v]=O.useState(null),[y,b]=O.useState(null),[x,S]=O.useState(!1),C=bx(l),[w,T]=fc({prop:r,defaultProp:i??!1,onChange:a,caller:ZS}),[E,D]=fc({prop:o,defaultProp:s,onChange:c,caller:ZS}),k=O.useRef(null),A=O.useRef(!1),[j,M]=O.useState(null),N=KS(e=>{M({value:e,hasConsumerStoppedPropagation:A.current}),D(e)},`handleUserSelect`),P=O.useRef(E);O.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=KS(()=>D(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,D]);let F=!_||!!m||!!_.closest(`form`),[I,L]=O.useState(new Set),ee=ca(),te=Array.from(I).map(e=>e.props.value).join(`;`),R=O.useCallback(e=>{L(t=>new Set(t).add(e))},[]),ne=O.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),re={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:ee,value:E,onValueChange:D,hasConsumerStoppedPropagationRef:A,userSelection:j,onUserSelect:N,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:k,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:I,nativeSelectKey:te,isFormControl:F};return(0,W.jsx)(Ps,{...g,children:(0,W.jsx)(iC,{scope:t,...re,children:(0,W.jsx)(QS.Provider,{scope:t,children:(0,W.jsx)(oC,{scope:t,onNativeOptionAdd:R,onNativeOptionRemove:ne,children:YC(h)?h(re):n})})})})}KS(cC,`SelectProvider`);var lC=KS(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(cC,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(JC,{__scopeSelect:t}):null]})})},`Select`),uC=`SelectTrigger`,dC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=rC(n),o=aC(uC,n),s=o.disabled||r,c=Wr(t,o.onTriggerChange),l=$S(n),u=O.useRef(`touch`),[d,f,p]=ZC(e=>{let t=l().filter(e=>!e.disabled),n=QC(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onUserSelect(n.value)}),m=KS(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,W.jsx)(Is,{asChild:!0,...a,children:(0,W.jsx)(_i.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":XC(o.value)?``:void 0,...i,ref:c,onClick:Fr(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Fr(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:Fr(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(o.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),f(e.key)),!(t&&e.key===` `)&&YS.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),fC=`SelectValue`,pC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=aC(fC,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Wr(t,c.onValueNodeChange);yi(()=>{l(u)},[l,u]);let f=XC(c.value);return(0,W.jsx)(_i.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,W.jsx)(O.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),mC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(_i.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[hC,gC]=tC(`SelectPortal`,{forceMount:void 0}),_C=KS(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(hC,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)(Js,{asChild:!0,...r})})},`SelectPortal`),vC=`SelectContent`,yC=O.forwardRef(KS(function(e,t){let n=gC(vC,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=aC(vC,e.__scopeSelect),[o,s]=O.useState();return yi(()=>{s(new DocumentFragment)},[]),(0,W.jsx)(Qs,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(TC,{...i,ref:t}):(0,W.jsx)(bC,{...i,fragment:o})})},`SelectContent`)),bC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Zr.createPortal((0,W.jsx)(SC,{scope:n,children:(0,W.jsx)(QS.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),xC=10,[SC,CC]=tC(vC),wC=ei(`SelectContent.RemoveScroll`),TC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n}=e,{position:r=qS.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=aC(vC,n),[y,b]=O.useState(null),[x,S]=O.useState(null),C=Wr(t,b),[w,T]=O.useState(null),[E,D]=O.useState(null),k=$S(n),[A,j]=O.useState(!1),M=O.useRef(!1),N=O.useRef(!1),P=O.useRef(!1);O.useEffect(()=>{if(y)return Ix(y)},[y]),Ex();let F=O.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,x]),I=O.useCallback(()=>F([w,y]),[F,w,y]);O.useEffect(()=>{A&&I()},[A,I]);let{onOpenChange:L,triggerPointerDownPosRef:ee}=v;O.useEffect(()=>{if(y){let e={x:0,y:0},t=KS(t=>{e={x:Math.abs(Math.round(t.pageX)-(ee.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ee.current?.y??0))}},`handlePointerMove`),n=KS(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||L(!1),document.removeEventListener(`pointermove`,t),ee.current=null},`handlePointerUp`);return ee.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,L,ee]),O.useEffect(()=>{let e=KS(()=>L(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[L]);let[te,R]=ZC(e=>{let t=k().filter(e=>!e.disabled),n=QC(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ne=O.useCallback((e,t,n)=>{let r=!N.current;r&&(N.current=!0);let i=!M.current&&!n;v.value!==void 0&&v.value===t||i?(T(e),i&&(M.current=!0)):r&&T(e)},[v.value]),re=O.useCallback(()=>y?.focus(),[y]),ie=O.useCallback((e,t,n)=>{if(!e)return;let r=!P.current;r&&(P.current=!0);let i=!M.current&&!n;(v.value!==void 0&&v.value===t||i||r)&&D(e)},[v.value]),ae=r===qS.Popper?DC:EC,oe=ae===DC?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,W.jsx)(SC,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ne,selectedItem:w,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:I,selectedItemText:E,position:r,isPositioned:A,searchRef:te,children:(0,W.jsx)(WS,{as:wC,allowPinchZoom:!0,children:(0,W.jsx)(Ui,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Fr(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,W.jsx)(ae,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...oe,onPlaced:()=>j(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Fr(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&R(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>F(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),EC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=aC(vC,n),o=CC(vC,n),[s,c]=O.useState(null),[l,u]=O.useState(null),d=Wr(t,u),f=$S(n),p=O.useRef(!1),m=O.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=O.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==JS.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-xC,d=tx(a,[xC,Math.max(xC,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-xC,d=tx(a,[xC,Math.max(xC,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-xC*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-xC,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${xC}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);yi(()=>y(),[y]);let[b,x]=O.useState();yi(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]);let S=O.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,W.jsx)(OC,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,W.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,W.jsx)(_i.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),DC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=xC,...a}=e,o=rC(n);return(0,W.jsx)(Bs,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[OC,kC]=tC(vC,{}),AC=`SelectViewport`,jC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=CC(AC,n),o=kC(AC,n),s=Wr(t,a.onViewportChange),c=O.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(QS.Slot,{scope:n,children:(0,W.jsx)(_i.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Fr(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-xC*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[MC,NC]=tC(`SelectGroup`),PC=`SelectItem`,[FC,IC]=tC(PC),LC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=aC(PC,n),c=CC(PC,n),l=s.value===r,[u,d]=O.useState(a??``),[f,p]=O.useState(!1),m=Wr(t,Ci(e=>c.itemRefCallback?.(e,r,i))),h=ca(),g=O.useRef(`touch`);function _(e){s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),s.onUserSelect(r),s.onOpenChange(!1)}return KS(_,`handleSelect`),(0,W.jsx)(FC,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:O.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(QS.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,W.jsx)(_i.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Fr(o.onFocus,()=>p(!0)),onBlur:Fr(o.onBlur,()=>p(!1)),onClick:Fr(o.onClick,e=>{i||g.current!==`mouse`&&_(e)}),onPointerUp:Fr(o.onPointerUp,e=>{i||g.current===`mouse`&&_(e)}),onPointerDown:Fr(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Fr(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Fr(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Fr(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(XS.includes(e.key)&&_(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),RC=`SelectItemText`,zC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=aC(RC,n),s=CC(RC,n),c=IC(RC,n),l=sC(RC,n),[u,d]=O.useState(null),f=Ci(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=Wr(t,d,c.onItemTextChange,f),m=u?.textContent,h=O.useMemo(()=>(0,W.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return yi(()=>(g(h),()=>_(h)),[g,_,h]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_i.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!XC(o.value)?Zr.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),BC=`SelectItemIndicator`,VC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,...r}=e;return IC(BC,n).isSelected?(0,W.jsx)(_i.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),HC=`SelectScrollUpButton`,UC=O.forwardRef(KS(function(e,t){let n=CC(HC,e.__scopeSelect),r=kC(HC,e.__scopeSelect),[i,a]=O.useState(!1),o=Wr(t,r.onScrollButtonChange);return yi(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};KS(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(KC,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),WC=`SelectScrollDownButton`,GC=O.forwardRef(KS(function(e,t){let n=CC(WC,e.__scopeSelect),r=kC(WC,e.__scopeSelect),[i,a]=O.useState(!1),o=Wr(t,r.onScrollButtonChange);return yi(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};KS(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(KC,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),KC=O.forwardRef(KS(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=CC(`SelectScrollButton`,n),o=O.useRef(null),s=$S(n),c=O.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return O.useEffect(()=>()=>c(),[c]),yi(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,W.jsx)(_i.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Fr(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Fr(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Fr(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),qC=`SelectBubbleInput`,JC=O.forwardRef(KS(function({__scopeSelect:e,...t},n){let r=aC(qC,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u,userSelection:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=O.useRef(null),h=Wr(n,m),g=i??``,_=O.useRef(g),v=O.useRef(d),y=O.useRef(!1),b=Array.from(f).some(e=>(e.props.value??``)===``);return O.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=d!==null&&d!==v.current;v.current=d;let i=_.current!==g;_.current=g;let a=r&&i;if(r&&!i&&d.value!==g&&!d.hasConsumerStoppedPropagation&&n){y.current=!0;try{n.call(e,d.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{y.current=!1,n.call(e,g)}return}let o=a&&!d.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,g),e.dispatchEvent(t)}},[g,d]),(0,W.jsxs)(_i.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>{y.current||a(e.target.value)},...t,style:{...yc,...t.style},ref:h,defaultValue:g,children:[XC(i)&&!b?(0,W.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function YC(e){return typeof e==`function`}KS(YC,`isFunction`);function XC(e){return e===``||e===void 0}KS(XC,`shouldShowPlaceholder`);function ZC(e){let t=Ci(e),n=O.useRef(``),r=O.useRef(0),i=O.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}KS(a,`updateSearch`),a(i)},[t]),a=O.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return O.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}KS(ZC,`useTypeaheadSearch`);function QC(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=$C(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}KS(QC,`findNextItem`);function $C(e,t){return e.map((n,r)=>e[(t+r)%e.length])}KS($C,`wrapArray`);var ew=lC,tw=pC;function nw({className:e,children:t,...n}){return(0,W.jsxs)(dC,{"data-slot":`select-trigger`,className:wn(`select-trigger`,e),...n,children:[t,(0,W.jsx)(mC,{asChild:!0,children:(0,W.jsx)(R,{className:`select-chevron`,size:14})})]})}function rw({className:e,children:t,position:n=`popper`,align:r=`end`,sideOffset:i=6,collisionPadding:a=8,...o}){return(0,W.jsx)(_C,{children:(0,W.jsxs)(yC,{"data-slot":`select-content`,className:wn(`select-content`,e),position:n,align:r,sideOffset:i,collisionPadding:a,...o,children:[(0,W.jsx)(aw,{}),(0,W.jsx)(jC,{className:`select-viewport`,children:t}),(0,W.jsx)(ow,{})]})})}function iw({className:e,children:t,description:n,...r}){let i=(0,O.useId)();return(0,W.jsxs)(LC,{"data-slot":`select-item`,className:wn(`select-item`,e),"aria-describedby":n?i:void 0,...r,children:[(0,W.jsx)(zC,{children:t}),n&&(0,W.jsx)(`span`,{className:`select-item-description`,id:i,children:n}),(0,W.jsx)(`span`,{className:`select-item-indicator`,children:(0,W.jsx)(VC,{children:(0,W.jsx)(ee,{size:14})})})]})}function aw({className:e,...t}){return(0,W.jsx)(UC,{className:wn(`select-scroll-button`,e),...t,children:(0,W.jsx)(re,{size:14})})}function ow({className:e,...t}){return(0,W.jsx)(GC,{className:wn(`select-scroll-button`,e),...t,children:(0,W.jsx)(R,{size:14})})}function sw({settings:e,current:t,unknown:n,disabled:r,scope:i,onChange:a}){let[o,s]=(0,O.useState)(!1);(0,O.useEffect)(()=>s(!1),[i,r]);let c=e.permissionMode??Ue(t)??``,l=e.permissionMode?Be[e.permissionMode].label:We(t,n);return(0,W.jsxs)(ew,{value:c,disabled:r,open:o,onOpenChange:s,onValueChange:n=>{let r=n;r in Be&&!Ve(r,t?.permissionCapabilities,e.model??t?.model)&&a(Ge(e,t,r))},children:[(0,W.jsx)(ol,{content:`权限模式:${l}${e.permissionMode?`(待生效)`:``}`,suppressed:o,children:(0,W.jsxs)(nw,{className:`settings-policy`,"aria-label":`权限模式`,"data-value":c,children:[(0,W.jsx)(J,{name:`shield`,size:16}),(0,W.jsx)(`span`,{className:`permission-mode-label`,children:(0,W.jsx)(tw,{placeholder:n,children:l})}),e.permissionMode&&(0,W.jsx)(`span`,{className:`permission-pending-dot`,"aria-label":`待生效`})]})}),(0,W.jsxs)(rw,{className:`permission-mode-menu`,side:`top`,align:`start`,"aria-label":`权限模式`,children:[c===`custom`&&(0,W.jsxs)(iw,{value:`custom`,disabled:!0,children:[l,`(保留当前配置)`]}),Object.keys(Be).map(n=>{let r=Be[n],i=Ve(n,t?.permissionCapabilities,e.model??t?.model);return(0,W.jsx)(iw,{value:n,textValue:r.label,disabled:!!i,description:(0,W.jsxs)(`span`,{className:`permission-description`,children:[(0,W.jsx)(`span`,{children:r.description}),i&&(0,W.jsx)(`span`,{className:`permission-unavailable`,children:i})]}),children:(0,W.jsx)(`strong`,{children:r.label})},n)})]})]})}var cw={"read-only":`只读`,"workspace-write":`项目内写入`,"danger-full-access":`完全访问`,"external-sandbox":`外部沙箱`},lw={untrusted:`不可信操作需审批`,"on-request":`由 Codex 请求审批`,never:`不请求审批`,granular:`自定义审批规则`};function uw({current:e,source:t,settings:n,thread:r,unknown:i}){let a=n.permissionMode,o=a&&Ve(a,e?.permissionCapabilities,n.model??e?.model);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`settings-heading`,children:[(0,W.jsx)(`strong`,{children:`权限详情`}),(0,W.jsx)(`span`,{children:t})]}),(0,W.jsxs)(`p`,{className:`settings-note`,children:[`当前模式:`,We(e,i),a&&`;待生效:${Be[a].label}`]}),(0,W.jsxs)(`dl`,{className:`permission-values`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`权限范围`}),(0,W.jsx)(`dd`,{children:cw[e?.sandbox??``]??i})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`审批策略`}),(0,W.jsx)(`dd`,{children:lw[e?.approvalPolicy??``]??i})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`权限 profile`}),(0,W.jsxs)(`dd`,{children:[e?.permissionProfile?.id??`未报告`,e?.permissionProfile?.extends&&`(继承 ${e.permissionProfile.extends})`]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`可写目录`}),(0,W.jsx)(`dd`,{children:e?.sandbox===`danger-full-access`?`无 Codex 沙箱限制`:e?.sandbox===`read-only`?`写入需额外批准`:e?.writableRoots?[`项目目录`,...e.writableRoots].join(`、`):`未报告`})]}),e?.sandbox===`workspace-write`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`临时目录`}),(0,W.jsxs)(`dd`,{children:[`TMPDIR:`,e.excludeTmpdirEnvVar==null?`未报告`:e.excludeTmpdirEnvVar?`排除`:`允许`,`;/tmp:`,e.excludeSlashTmp==null?`未报告`:e.excludeSlashTmp?`排除`:`允许`]})]})]}),(0,W.jsxs)(`p`,{className:`settings-observed`,children:[`当前网络权限:`,e?.networkAccess==null?`未报告`:e.networkAccess?`允许`:`受限`,(0,W.jsxs)(`span`,{children:[`审批执行方:`,e?.approvalReviewer??`未报告`]})]}),(0,W.jsxs)(`p`,{className:`settings-note`,children:[`修改仅用于此`,r?`会话的后续操作`:`项目的新会话`,`,`,r?`下次任务开始时`:`新建会话时`,`请求应用,以 Codex 确认为准,不更改全局配置。`]}),(!e?.permissionMode||e.permissionMode===`custom`)&&(0,W.jsx)(`p`,{className:`settings-note`,children:`保留实际配置;尚未选择其他模式时不会改写权限。`}),o&&(0,W.jsxs)(`p`,{className:`settings-error`,role:`status`,children:[`待生效选择目前不可用:`,o]})]})}var dw=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`];function fw({effort:e}){let t=dw.indexOf(e),n=t<0?void 0:t/(dw.length-1),r=Math.PI*(1+(n??0));return(0,W.jsxs)(`svg`,{className:`reasoning-gauge`,"data-effort":e,"data-progress":n,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M3 15a9 9 0 0 1 18 0`,stroke:`currentColor`,strokeOpacity:`0.18`,strokeWidth:`2.5`,strokeLinecap:`round`}),n===void 0?(0,W.jsx)(`text`,{x:`12`,y:`17`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`?`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M3 15a9 9 0 0 1 18 0`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeDasharray:`${n*100} 100`}),(0,W.jsx)(`path`,{d:`M12 15L${12+Math.cos(r)*6} ${15+Math.sin(r)*6}`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`15`,r:`2`,fill:`currentColor`})]})]})}function pw({settings:e,projectName:t,children:n,models:r,thread:i,projectId:a,runtimeKey:o,disabled:s,threadLoading:c,onChange:l,onSaveModelDefaults:u,savingModelDefaults:d}){let[f,p]=(0,O.useState)(!1),[m,h]=(0,O.useState)(!1),[g,_]=(0,O.useState)(!1),v=(0,O.useId)(),y=(0,O.useId)(),b=(0,O.useId)(),x=JSON.stringify([a,i?.id]),[S,C]=(0,O.useState)(),w=S?.scope===x?S:void 0,T=d||w?.state===`saving`;(0,O.useEffect)(()=>{h(!1),_(!1)},[s,i?.id,a]),(0,O.useEffect)(()=>p(!1),[i?.id,a]);let E=Qb(i?.managed||c?void 0:a,o),D=i?i.runtimeSettings:E.value,k=D?.permissionCapabilities||i?.managed?D:{...D,model:D?.model??null,reasoningEffort:D?.reasoningEffort??null,permissionCapabilities:E.value?.permissionCapabilities},A=c||E.loading&&!i?`读取中…`:`未报告`,j=e.model??D?.model??``,M=e.reasoningEffort??D?.reasoningEffort??``,N=M===`max`?`Max`:M===`ultra`?`Ultra`:null,P=e.serviceTier===void 0?D?.serviceTier:e.serviceTier,F=P===`fast`,I=r.find(e=>e.id===j),L=I?.serviceTiers?.includes(`fast`),ee=Ke(e,D),te=Object.keys(ee).length>0,R=i?i.managed?`会话当前配置`:`会话保存配置`:`新会话默认配置`;async function ne(e){C({scope:x,settings:e,state:`saving`});try{let t=await u(e);C({scope:x,settings:e,state:t?.status===`ok`?`saved`:t?.status===`okOverridden`?`overridden`:`error`})}catch{C({scope:x,settings:e,state:`error`})}}return(0,W.jsxs)(`div`,{className:`settings-panel`,role:`group`,"aria-label":`运行设置`,children:[te&&(0,W.jsxs)(`div`,{className:`settings-pending`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[i?i.managed?`下次任务生效`:`恢复后发送或 Fork 时生效`:`新建会话时生效`,` `,`· 当前 `,D?.model??`未报告`,` / `,D?.reasoningEffort??`未报告`,ee.serviceTier!==void 0&&` · 速度待生效:${Ye(ee.serviceTier)};当前:${Ye(D?.serviceTier,A)}`,ee.permissionMode&&` · 权限待生效:${Be[ee.permissionMode].label};当前:${We(D)}`]}),(0,W.jsx)(`button`,{type:`button`,disabled:s||T,onClick:()=>{l({}),w?.state===`error`&&C(void 0)},children:i&&(ee.model!==void 0||ee.reasoningEffort!==void 0)?`撤销本会话修改`:`撤销修改`})]}),w&&(0,W.jsxs)(`p`,{className:`settings-defaults`,"data-state":w.state,role:`status`,children:[w.state===`saving`?`正在保存模型和推理强度默认值…`:w.state===`saved`?`已保存为 Codex 新会话默认值`:w.state===`overridden`?`默认值已保存,但被更高优先级配置覆盖;新会话以实际配置为准。`:`未能确认默认值已保存。当前会话的待生效选择仍保留,请查看提交核对结果。`,w.state===`error`&&(0,W.jsx)(`button`,{type:`button`,disabled:s||T,onClick:()=>void ne(w.settings),children:`重新保存默认值`})]}),!i&&E.error&&(0,W.jsxs)(`p`,{className:`settings-error`,role:`status`,children:[E.error,` `,(0,W.jsx)(`button`,{type:`button`,onClick:E.retry,children:`重试`})]}),f&&(0,W.jsx)(`div`,{className:`settings-fields`,id:v,children:(0,W.jsx)(uw,{current:k,source:R,settings:ee,thread:!!i,unknown:A})}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(`div`,{className:`composer-context`,children:[(0,W.jsx)(ol,{asChild:!0,content:t??`未选择项目`,children:(0,W.jsxs)(`span`,{className:`composer-target`,children:[(0,W.jsx)(J,{name:`folder`,size:14}),(0,W.jsx)(`span`,{children:t??`未选择项目`})]})}),(0,W.jsx)(sw,{settings:ee,current:k,unknown:A,disabled:s||!!c,scope:`${a}:${i?.id??``}:${o}`,onChange:l}),(0,W.jsx)(ol,{asChild:!0,content:`权限详情`,children:(0,W.jsx)(`button`,{className:`settings-details-toggle`,type:`button`,"aria-label":`权限详情`,"aria-expanded":f,"aria-controls":v,onClick:()=>p(!f),children:(0,W.jsx)(J,{name:`settings`,size:14})})})]}),(0,W.jsxs)(`div`,{className:`composer-send-controls`,children:[(0,W.jsxs)(ew,{value:j,disabled:s||!r.length,open:m,onOpenChange:e=>{(!T||!e)&&h(e)},onValueChange:t=>{if(T)return;let n=r.find(e=>e.id===t);n&&(l(Je(e,D,n)),ne(qe(e,D,n)))},children:[(0,W.jsx)(ol,{content:`模型:${j||A}`,suppressed:m,children:(0,W.jsx)(nw,{className:`settings-choice settings-model`,"aria-label":`模型`,"aria-disabled":T||void 0,"data-value":j,children:(0,W.jsx)(`span`,{className:`settings-model-value`,children:(0,W.jsx)(tw,{placeholder:A,children:j||A})})})}),(0,W.jsxs)(rw,{side:`top`,"aria-label":`模型`,children:[j&&!I&&(0,W.jsx)(iw,{value:j,disabled:!0,children:j}),r.map(e=>(0,W.jsx)(iw,{value:e.id,children:e.id},e.id))]})]}),(0,W.jsxs)(ew,{value:M,disabled:s||!I?.reasoningEfforts.length,open:g,onOpenChange:e=>{(!T||!e)&&_(e)},onValueChange:t=>{T||(l(Ke({...e,reasoningEffort:t},D)),ne({model:j,reasoningEffort:t}))},children:[(0,W.jsx)(ol,{id:y,suppressed:g,content:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{children:[`推理强度:`,M||A]}),ee.reasoningEffort!==void 0&&(0,W.jsxs)(`span`,{children:[`待应用 · 当前 `,D?.reasoningEffort??A]})]}),children:(0,W.jsxs)(nw,{className:`settings-choice settings-effort reasoning-tier`,"aria-label":`推理强度`,"aria-disabled":T||void 0,"aria-describedby":y,"data-value":M,"data-effort":M,children:[(0,W.jsxs)(`span`,{className:`reasoning-effort-display`,"aria-hidden":`true`,children:[(0,W.jsx)(fw,{effort:M}),N&&(0,W.jsx)(`span`,{className:`reasoning-tier-label`,children:N})]},M),(0,W.jsx)(`span`,{className:`sr-only`,children:(0,W.jsx)(tw,{placeholder:A,children:M||A})})]})}),(0,W.jsxs)(rw,{side:`top`,"aria-label":`推理强度`,children:[M&&!I?.reasoningEfforts.includes(M)&&(0,W.jsx)(iw,{value:M,disabled:!0,className:`reasoning-tier`,"data-effort":M,children:M}),I?.reasoningEfforts.map(e=>(0,W.jsx)(iw,{value:e,className:`reasoning-tier`,"data-effort":e,children:e},e))]})]}),(0,W.jsx)(ol,{id:b,content:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:Ye(P,A)}),(0,W.jsx)(`span`,{children:F?`点击关闭 Fast`:L?`点击开启 Fast · 更快响应,增加用量`:`当前模型未提供 Fast`}),ee.serviceTier!==void 0&&(0,W.jsxs)(`span`,{children:[`待应用 · 当前 `,Ye(D?.serviceTier,A)]})]}),children:(0,W.jsx)(`button`,{type:`button`,className:`settings-choice settings-speed`,"aria-label":`Fast 模式`,"aria-describedby":b,"aria-pressed":P===void 0?`mixed`:F,disabled:s||!!c||!F&&!L,"data-fast":F,"data-pending":ee.serviceTier!==void 0,onClick:()=>l(Ke({...e,serviceTier:F?null:`fast`},D)),children:(0,W.jsx)(Oe,{size:18,strokeWidth:1.7,fill:F?`currentColor`:`none`,"aria-hidden":`true`})})}),n]})]})]})}function mw({id:e,commands:t,selectedIndex:n,onSelect:r,onExecute:i}){let a=(0,O.useRef)(null);return(0,O.useEffect)(()=>{a.current?.scrollIntoView({block:`nearest`})},[n,t[n]?.name]),(0,W.jsxs)(`div`,{className:`slash-menu`,children:[(0,W.jsxs)(`div`,{className:`slash-menu-heading`,children:[`会话命令 `,(0,W.jsx)(`span`,{children:`作用于当前项目与会话`})]}),(0,W.jsx)(`div`,{id:e,role:`listbox`,"aria-label":`Slash 命令`,className:`slash-options`,children:t.map((t,o)=>(0,W.jsxs)(`button`,{id:`${e}-${t.name}`,ref:o===n?a:void 0,type:`button`,role:`option`,tabIndex:-1,"aria-selected":o===n,"aria-disabled":!!t.unavailableReason,className:`slash-option`,onPointerDown:e=>e.preventDefault(),onPointerMove:e=>{e.pointerType===`mouse`&&r(o)},onClick:()=>i(t),children:[(0,W.jsxs)(`span`,{className:`slash-option-title`,children:[(0,W.jsxs)(`strong`,{children:[`/`,t.name]}),(0,W.jsx)(`span`,{children:t.usage})]}),(0,W.jsx)(`span`,{children:t.description}),t.unavailableReason&&(0,W.jsx)(`span`,{className:`slash-unavailable`,children:t.unavailableReason})]},t.name))}),t.length===0&&(0,W.jsx)(`p`,{className:`slash-empty`,role:`status`,children:`没有匹配的命令。输入 /help 查看支持范围。`}),(0,W.jsx)(`div`,{className:`slash-menu-footer`,children:`↑ ↓ 选择 · Enter 执行 · Esc 关闭`})]})}function hw(e){let t=e.trimStart();if(!t.startsWith(`/`)||t.startsWith(`//`))return null;let n=/^\/([^\s]*)(?:\s+([\s\S]*))?$/.exec(t);return{name:n[1].toLowerCase(),arguments:(n[2]??``).trim()}}function gw(e,t){let n=hw(t);if(!n)return[];if(n.arguments)return e.filter(e=>e.name===n.name);let r=e=>e.name===n.name?0:e.name.startsWith(n.name)?1:2;return e.filter(e=>e.name.includes(n.name)||e.description.toLowerCase().includes(n.name)).sort((e,t)=>r(e)-r(t))}function _w(e,t){let n=hw(e);if(!n)return;let r=t.find(e=>e.name===n.name);if(!r)return n.name?`未知命令 /${n.name}。使用 /help 查看可用命令;发送以 / 开头的普通消息请使用 //。`:`请选择命令,或输入 /help 查看可用命令。`;if(r.name===`rename`){let e=Xe(n.arguments);if(e)return e}else if(n.arguments)return`/${r.name} 不接受参数。用法:${r.usage}`;return r.unavailableReason}var vw=[{name:`help`,description:`查看本网页支持的命令和使用方式`},{name:`new`,description:`打开当前项目的新建会话输入页`},{name:`fork`,description:`复制当前会话已保存的历史为新会话`},{name:`resume`,description:`恢复当前选中的历史会话(不是 CLI 会话选择器)`},{name:`review`,description:`审查当前项目的未提交改动(使用会话当前配置)`},{name:`rename`,description:`重命名当前会话,名称可包含空格`},{name:`stop`,description:`请求中断当前任务(网页快捷命令)`},{name:`status`,description:`打开当前连接、运行状态与提交诊断`},{name:`compact`,description:`压缩当前会话上下文,保留会话继续工作`},{name:`export`,description:`下载当前会话的已保存记录为 Markdown 文件`}];function yw(e,t){if(e===`help`||e===`status`)return;if(t.authRequired||t.connection===`authenticationRequired`)return`登录已过期,请重新登录后重试。`;if(t.connection!==`connected`)return`当前已离线,请等待连接恢复后重试。`;if(t.system?.authenticated===!1)return`Codex 尚未登录,请先完成认证。`;if(!t.system?.ready)return`Codex 尚不可用,请先查看状态诊断。`;if(e===`export`)return t.thread?t.system.capabilities.includes(`thread/read`)?void 0:`当前 Codex 未提供 thread/read 能力。`:t.selectedId?`会话正在加载,请稍后重试。`:`请先选择一个会话。`;if(e!==`stop`&&Hn(t.system))return`请先确认当前 Codex 版本的兼容性提示。`;let n={fork:`thread/fork`,resume:`thread/resume`,review:`review/start`,rename:`thread/name/set`,stop:`turn/interrupt`,compact:`thread/compact/start`};if(e!==`new`&&!t.system.capabilities.includes(n[e]))return`当前 Codex 未提供 ${n[e]} 能力。`;let r=(e,n)=>t.busy.includes(`${e}:${n}`),i=(e,n)=>t.operations.some(t=>(!n||t.kind===n)&&Fn(t,e));if(e!==`stop`){if(!t.project)return`请先选择一个项目。`;if(!t.project.available)return`当前项目目录不可用,请先检查项目配置。`}if(e===`new`)return t.busy.some(e=>e.startsWith(`saveModelDefaults:`))?`正在保存模型默认值,请完成后再操作。`:r(`create`,t.project.id)?`正在新建会话,请等待回执。`:i(t.project.id)?`新建会话的请求尚未确认,请先用 /status 核对提交。`:void 0;let a=t.thread;if(!a)return t.selectedId?`会话正在加载,请稍后重试。`:`请先选择一个会话。`;if(e===`compact`)return a.archived?`请先取消归档后再压缩上下文。`:a.managed?a.turns.length?r(`compact`,a.id)?`压缩请求正在提交,请等待回执。`:kl(a.status)||a.turns.some(e=>kl(e.status))?`请等待当前任务结束后再压缩上下文。`:a.status===`unknown`||a.execution&&!a.execution.ended||i(a.id)?`当前会话仍有待核对的执行,请先用 /status 核对提交。`:void 0:`当前会话为空,无需压缩上下文。`:`请先恢复当前会话,再压缩上下文。`;if(e===`review`)return a.archived?`会话已归档,请先取消归档。`:a.managed?r(`review`,a.id)?`正在提交代码审查,请等待回执。`:i(a.id)||a.status===`unknown`?`当前会话有尚未确认的请求,请先用 /status 核对提交。`:kl(a.status)||a.turns.some(e=>kl(e.status))?`当前会话仍在运行,请等待任务结束后开始代码审查。`:a.execution&&!a.execution.ended?`当前会话仍有执行占用,请先用 /status 核对旧任务。`:void 0:`会话尚未恢复,请先恢复后开始代码审查。`;if(e===`rename`)return a.archived?`请先取消归档并恢复会话后再重命名。`:a.managed?r(`rename`,a.id)?`正在重命名,请等待回执。`:i(a.id,`rename`)?`重命名请求尚未确认,请先用 /status 核对提交。`:r(`archive`,a.id)||i(a.id,`archive`)?`会话归档操作尚未确认,请先用 /status 核对提交。`:void 0:`请先恢复当前会话后再重命名;不能修改其他进程占用的会话。`;if(e===`fork`)return a.turns.length?r(`fork`,a.id)?`正在 Fork 会话,请等待回执。`:i(a.id,`fork`)?`Fork 请求尚未确认,请先用 /status 核对提交。`:void 0:`当前会话为空,发送首条消息后才能 Fork 已保存的历史。`;if(e===`resume`)return r(`resume`,a.id)?`正在恢复会话,请等待回执。`:i(a.id)?`当前会话有尚未确认的请求,请先用 /status 核对提交。`:a.managed&&(a.turns.some(e=>kl(e.status))||kl(a.status))?`当前会话仍在运行,请等待任务结束或使用 /stop。`:a.execution&&!a.execution.ended?`当前会话仍有执行占用,请先用 /status 核对旧任务。`:a.managed?`当前会话已恢复,无需再次恢复。`:void 0;if(!a.managed)return a.resumeError?.code===`THREAD_IN_USE`?`当前会话被其他进程占用,无法从网页中断该进程的任务。`:`当前会话尚未恢复,无法从网页中断其他进程的任务。`;if(r(`interrupt`,a.id))return`中断请求正在提交,请等待回执。`;if(i(a.id,`interrupt`))return`中断请求尚未确认,请先用 /status 核对提交。`;if(!a.turns.some(e=>kl(e.status)))return a.status===`unknown`||a.execution&&!a.execution.ended?`任务状态尚未确认,请先用 /status 核对提交。`:`当前会话没有可中断的任务。`}function bw(e,t){if(!t)return{error:!0,message:`未收到可确认的成功回执。请查看页面错误或用 /status 核对提交;输入已保留。`};if(t.status===`failed`)return{error:!0,message:t.error?.message??`操作失败,请查看状态诊断。`};if(t.status!==`acknowledged`)return{error:!0,message:`提交结果尚未确认,请先用 /status 核对提交,不要重复提交。`};if(e===`compact`)return{message:`已提交上下文压缩请求;进度和结果以会话中的任务状态为准。`};if(e===`rename`){let e=t.result;return typeof e?.name==`string`&&e.name?{message:`会话已重命名为「${e.name}」。`}:{error:!0,message:`重命名已被接受,但无法确认名称,请用 /status 核对提交。`}}if(e===`fork`){let e=t.result,n=e?.threadId??e?.thread?.id;return typeof n!=`string`||!n?{error:!0,message:`请求已被接受,但尚未获得新会话标识,请用 /status 核对提交。`}:{message:`已 Fork 为新会话。`,draftKey:n}}return{message:e===`review`?`已提交代码审查,请在当前会话查看进度和结果。`:e===`stop`?`已提交中断请求,请等待任务状态更新。`:`已恢复当前选中的会话。`}}function xw(e){let t=e();return vw.map(({name:n,description:r})=>({name:n,description:r,usage:n===`rename`?`/rename <名称>`:`/${n}(无需参数)`,unavailableReason:yw(n,t),run:async(r=``)=>{let i=e();if(n===`help`)return{message:`${vw.map(e=>`/${e.name}${e.name===`rename`?` <名称>`:``}:${e.description}`).join(`
|
|
83
|
-
`)}\n/rename 必须提供名称,其他命令无需参数。输入 // 可发送以 / 开头的普通消息。`};if(n===`status`)return i.openStatus(),{message:`已打开状态诊断;可在面板中刷新或核对提交。`};if(i.project?.id!==t.project?.id||i.selectedId!==t.selectedId)return{error:!0,message:`当前项目或会话已切换,请重新选择命令。`};let a=yw(n,i);if(a)return{error:!0,message:a};if(n===`rename`){let e=Xe(r);if(e)return{error:!0,message:e}}let o=i.thread,s=`/api/threads/${encodeURIComponent(o?.id??``)}`;try{if(n===`export`){let{partial:e}=await i.exportThread(o.id);return{message:e?`已发起 Markdown 下载;存在未完成、状态待确认或截断内容,请查看文件内说明。`:`已发起已保存历史的 Markdown 下载。图片和内部记录的省略范围已在文件中说明。`}}let e;if(n===`new`)return{draftKey:i.openDraft(),message:`已打开新会话输入页,发送首条消息时创建会话。`};if(n===`fork`)e=await i.run(`fork`,o.id,`${s}/fork`,{settings:i.settings});else if(n===`review`)e=await i.run(`review`,o.id,`${s}/review`);else if(n===`rename`)e=await i.run(`rename`,o.id,`${s}/rename`,{name:r.trim()});else if(n===`resume`)i.onResumeAttempt(),e=await i.run(`resume`,o.id,`${s}/resume`),await i.refreshThread();else if(n===`compact`)e=await i.run(`compact`,o.id,`${s}/compact`);else{let t=o.turns.findLast(e=>kl(e.status));e=await i.run(`interrupt`,o.id,`${s}/interrupt`,{expectedTurnId:t.id})}return bw(n,e)}catch(e){return{error:!0,message:En(e)}}}}))}function Sw({textareaRef:e,inputId:t}){let[n,r]=(0,O.useState)({min:93,max:230,height:93}),[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(n),s=(0,O.useRef)(null);function c(){s.current=null,a(!1),document.documentElement.classList.remove(`composer-resizing`)}function l(t){let n=e.current;if(!n)return;let i=Math.min(o.current.max,Math.max(o.current.min,t));n.style.height=`${i}px`,r(e=>({...e,height:i}))}return(0,O.useEffect)(()=>{let t=e.current,n=t?.closest(`.bottom-region`),i=n?.parentElement;if(!t||!n||!i)return;let a=0,s=()=>{let e=getComputedStyle(t),a=parseFloat(e.getPropertyValue(`--composer-min-height`)),s=parseFloat(e.getPropertyValue(`--composer-max-height`)),c=getComputedStyle(n).maxHeight,l=c.endsWith(`%`)?i.clientHeight*parseFloat(c)/100:parseFloat(c),u=i.querySelector(`.conversation-area`),d=Array.from(i.children).reduce((e,t)=>{let r=getComputedStyle(t);return t===n||r.position===`absolute`||r.position===`fixed`||r.display===`none`?e:e+(t===u?parseFloat(r.minHeight)||0:t.getBoundingClientRect().height)+(parseFloat(r.marginTop)||0)+(parseFloat(r.marginBottom)||0)},0),f=n.scrollHeight-t.getBoundingClientRect().height,p=window.visualViewport?.offsetTop??0,m=t.getBoundingClientRect().bottom-p-24,h=Math.max(a,Math.floor(Math.min(s,l-f,i.clientHeight-d-f,m)));t.style.setProperty(`--composer-available-height`,`${h}px`),t.style.height&&(t.style.height=`${Math.min(h,Math.max(a,parseFloat(t.style.height)))}px`);let g=t.getBoundingClientRect().height;o.current={min:a,max:h,height:g},r(e=>e.min===a&&e.max===h&&e.height===g?e:{min:a,max:h,height:g})};function l(){cancelAnimationFrame(a),a=requestAnimationFrame(s)}let u=new ResizeObserver(l);for(let e of[t,...i.children])u.observe(e);u.observe(i);let d=new MutationObserver(l);return d.observe(i,{childList:!0}),window.visualViewport?.addEventListener(`resize`,l),window.addEventListener(`blur`,c),s(),()=>{u.disconnect(),d.disconnect(),cancelAnimationFrame(a),window.visualViewport?.removeEventListener(`resize`,l),window.removeEventListener(`blur`,c),c()}},[e]),(0,W.jsx)(ol,{asChild:!0,suppressed:i,content:`向上拖动增高,向下拖动缩小;也可用方向键调整`,children:(0,W.jsx)(`button`,{type:`button`,className:`composer-resize-handle`,"data-resizing":i||void 0,role:`separator`,"aria-label":`调整输入框高度`,"aria-orientation":`horizontal`,"aria-controls":t,"aria-valuemin":Math.round(n.min),"aria-valuemax":Math.round(n.max),"aria-valuenow":Math.round(n.height),"aria-valuetext":`${Math.round(n.height)} 像素`,onPointerDown:t=>{t.isPrimary&&t.button===0&&e.current&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),s.current={pointerId:t.pointerId,y:t.clientY,height:e.current.getBoundingClientRect().height},document.documentElement.classList.add(`composer-resizing`),a(!0))},onPointerMove:e=>{s.current?.pointerId===e.pointerId&&(e.preventDefault(),l(s.current.height+s.current.y-e.clientY))},onPointerUp:e=>{s.current?.pointerId===e.pointerId&&(c(),e.currentTarget.releasePointerCapture(e.pointerId))},onPointerCancel:c,onLostPointerCapture:c,onKeyDown:t=>{let r=e.current?.getBoundingClientRect().height??n.height,i=t.shiftKey?40:10,a={ArrowUp:r+i,ArrowDown:r-i,Home:n.min,End:n.max}[t.key];a!==void 0&&(t.preventDefault(),l(a))},children:(0,W.jsx)(`svg`,{width:`32`,height:`32`,viewBox:`0 0 32 32`,fill:`none`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M21 3.5a7.5 7.5 0 0 1 7.5 7.5`})})})})}function Cw(e){let[t,n]=(0,O.useState)({}),r=(0,O.useRef)(t),i=(0,O.useId)(),a=(0,O.useRef)(!1);Cr(`composer`,()=>{if(a.current||Object.values(r.current).some(e=>e.images.some(e=>!e.dataUrl)))throw Error(`正在输入或读取图片,完成后会自动加载新版`);return r.current},e=>{r.current={...e,...r.current},n(r.current)});let o=(0,O.useRef)(-1/0),s=(0,O.useRef)(new Set),c=(0,O.useRef)(new Map),l=(0,O.useRef)(null),u=(0,O.useId)(),d=(0,O.useId)(),[f,p]=(0,O.useState)(!1),[m,h]=(0,O.useState)({key:``,text:``,selectedIndex:0,dismissed:!1}),[g,_]=(0,O.useState)({}),[v,y]=(0,O.useState)([]),b=e.draftKey,x=(0,O.useRef)(new WeakSet);(0,O.useEffect)(()=>{for(let t of Object.values(e.sentDrafts))x.current.has(t)||(x.current.add(t),c.current.get(t.key)?.text.replace(/^(\s*)\/\//,`$1/`)===t.text&&ee(t.key))},[e.sentDrafts]),(0,O.useEffect)(()=>{a.current=!1,o.current=-1/0,h({key:``,text:``,selectedIndex:0,dismissed:!1})},[b]);let S=t[b]??Yb,{text:C,images:w}=S,T=hw(C),E=gw(e.commands,C),D=m.key===b&&m.text===C?m:void 0,k=Math.min(D?.selectedIndex??0,Math.max(0,E.length-1)),A=!!(T&&f&&!D?.dismissed),j=A?E[k]:e.commands.find(e=>e.name===T?.name),M=v.includes(b);function N(e){h({key:b,text:C,selectedIndex:e,dismissed:!1})}function P(){h({key:b,text:C,selectedIndex:k,dismissed:!0})}async function F(t){if(s.current.has(b)||a.current)return;let n=r.current[b]??Yb,i=hw(n.text);if(!i)return;let o=t?`/${t.name}${i.arguments?` ${i.arguments}`:``}`:n.text,c=n.images.length?`Slash 命令不能附带图片。请先移除图片,或改为普通消息。`:_w(o,e.commands);if(c){_(e=>({...e,[b]:{message:c,error:!0}}));return}let l=e.commands.find(e=>e.name===hw(o)?.name);if(l){s.current.add(b),y(e=>[...e,b]),_(e=>({...e,[b]:{message:`正在执行 /${l.name}…`}})),P();try{let e=await l.run(hw(o)?.arguments);_(t=>({...t,[b]:e,[e.draftKey??b]:e})),e.error||L(b,e=>({...e,text:e.text===n.text?``:e.text}))}catch(e){_(t=>({...t,[b]:{error:!0,message:e instanceof Error?e.message:`命令执行失败,请重试。`}}))}finally{s.current.delete(b),y(e=>e.filter(e=>e!==b))}}}let I=w.some(e=>!e.dataUrl);function L(e,t){let i={...r.current,[e]:t(r.current[e]??Yb)};r.current=i,n(i)}function ee(e){let t=c.current.get(e);t&&(c.current.delete(e),L(e,e=>({text:e.text===t.text?``:e.text,images:e.images.filter(e=>!t.images.some(t=>t.id===e.id)),error:e.error===t.error?void 0:e.error})))}function te(e){if(e.defaultPrevented)return;let t=Array.from(e.clipboardData.files);if(!t.length)return;e.preventDefault();let n=Xb(t,(r.current[b]??Yb).images);if(n){L(b,e=>({...e,error:n}));return}let i=t.map(e=>({id:crypto.randomUUID(),name:e.name||`粘贴的图片`,size:e.size})),a=e.clipboardData.getData(`text/plain`),o=e.currentTarget.selectionStart,s=e.currentTarget.selectionEnd;L(b,e=>({text:a?(e.text.slice(0,o)+a+e.text.slice(s)).slice(0,1e5):e.text,images:[...e.images,...i]})),t.forEach((e,t)=>{let n=i[t].id;Zb(e).then(e=>L(b,t=>({...t,images:t.images.map(t=>t.id===n?{...t,dataUrl:e}:t)})),()=>L(b,e=>e.images.some(e=>e.id===n)?{...e,images:e.images.filter(e=>e.id!==n),error:`图片读取失败,请重新粘贴。`}:e))})}let R=!!(e.thread?.managed&&kl(e.thread.status)),ne=e.thread&&!e.thread.managed&&!e.thread.archived,re=ne?e.thread?.resumeError:void 0,ie=re?.code===`THREAD_IN_USE`,ae=!(!e.thread&&!e.projectId||e.threadLoading||ne||!C.trim()&&!w.length||I||e.disabled||e.submitting);async function oe(){if(T){await F(A?E[k]:void 0);return}if(!ae||s.current.has(b))return;let t=r.current[b]??Yb;if(!t.text.trim()&&!t.images.length||t.images.some(e=>!e.dataUrl))return;s.current.add(b),c.current.set(b,t);let n=t.text,i=t.images;try{await e.onSend(n.replace(/^(\s*)\/\//,`$1/`),R,i.length?i.map(e=>e.dataUrl):void 0)&&ee(b)}finally{s.current.delete(b)}}return(0,W.jsxs)(`div`,{className:`composer-region`,children:[e.submitting&&(0,W.jsxs)(`p`,{className:`composer-resume-status`,role:`status`,children:[(0,W.jsx)(J,{name:`refresh`,size:14}),e.thread?`正在提交消息…`:`正在创建会话并发送首条消息…`]}),ne&&e.resuming&&(0,W.jsxs)(`p`,{className:`composer-resume-status`,role:`status`,children:[(0,W.jsx)(J,{name:`refresh`,size:14}),`正在恢复会话…`]}),ne&&e.resumeAttempted&&!e.resuming&&!re&&e.canResume&&(0,W.jsx)(q,{size:`sm`,variant:`secondary`,onClick:e.onResume,children:`重试恢复`}),re&&!e.resuming&&(0,W.jsxs)(`div`,{className:`session-resume-notice`,role:`status`,children:[(0,W.jsx)(`strong`,{children:ie?`此会话正被其他进程使用`:`无法恢复会话`}),(0,W.jsx)(`p`,{children:ie?`可以 Fork 已保存的历史继续对话,或在原进程释放会话后重试。新会话使用同一项目目录。`:re.message}),ie&&(0,W.jsxs)(q,{size:`sm`,variant:`secondary`,disabled:!e.canFork,onClick:e.onFork,children:[(0,W.jsx)(J,{name:`fork`,size:14}),e.forking?`正在确认 Fork…`:`Fork 为新会话`]}),(0,W.jsx)(q,{size:`sm`,disabled:!e.canResume,onClick:e.onResume,children:`重试恢复`})]}),(0,W.jsxs)(`div`,{className:`composer-box`,children:[(0,W.jsx)(Sw,{textareaRef:l,inputId:u}),g[b]&&(0,W.jsx)(`p`,{className:`slash-feedback`,role:g[b].error?`alert`:`status`,children:g[b].message}),A&&(0,W.jsx)(mw,{id:d,commands:E,selectedIndex:k,onSelect:N,onExecute:e=>{l.current?.focus(),F(e)}}),w.length>0&&(0,W.jsx)(`ul`,{className:`composer-images`,"aria-label":`待发送的图片`,children:w.map((e,t)=>(0,W.jsxs)(`li`,{children:[e.dataUrl?(0,W.jsx)(`img`,{src:e.dataUrl,alt:`待发送的图片 ${t+1}`}):(0,W.jsx)(`span`,{role:`status`,children:`读取中…`}),(0,W.jsx)(ol,{asChild:!0,content:e.name,children:(0,W.jsx)(`span`,{className:`composer-image-name`,children:e.name})}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,"aria-label":`移除图片 ${t+1}`,onClick:()=>L(b,t=>({...t,error:void 0,images:t.images.filter(t=>t.id!==e.id)})),children:(0,W.jsx)(J,{name:`close`,size:13})})]},e.id))}),S.error&&(0,W.jsx)(`p`,{className:`composer-image-error`,role:`alert`,children:S.error}),(0,W.jsx)(`textarea`,{id:u,ref:l,"aria-label":R?`追加要求`:`任务内容`,"aria-haspopup":`listbox`,"aria-controls":A?d:void 0,"aria-autocomplete":`list`,"aria-activedescendant":A&&E[k]?`${d}-${E[k].name}`:void 0,value:C,readOnly:!!e.thread?.archived,placeholder:e.thread?.archived?`取消归档后可继续对话…`:R?`补充要求或调整方向…`:`描述任务、粘贴图片,或输入 / 查看命令…`,maxLength:1e5,onChange:e=>{L(b,t=>({...t,text:e.target.value})),h({key:b,text:e.target.value,selectedIndex:0,dismissed:!1}),_(e=>{let t={...e};return delete t[b],t})},onPaste:te,onFocus:()=>p(!0),onCompositionStart:()=>{a.current=!0},onCompositionEnd:()=>{a.current=!1,o.current=performance.now()},onBlur:()=>{p(!1),a.current=!1,o.current=-1/0},onKeyDown:e=>{if((!e.defaultPrevented||A&&e.key===`Escape`)&&!(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229||a.current)){if(performance.now()-o.current<100)e.key===`Enter`&&!e.shiftKey&&e.preventDefault();else{if(A&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),E.length&&N((k+(e.key===`ArrowDown`?1:-1)+E.length)%E.length);return}if(e.key===`Escape`){e.preventDefault(),P();return}}e.key!==`Enter`||e.shiftKey||(e.preventDefault(),!e.repeat&&oe())}}},onKeyUp:e=>{e.key===`Enter`&&(o.current=-1/0)},rows:3}),(0,W.jsxs)(pw,{settings:e.settings,projectName:e.projectName,models:e.models,onChange:e.onSettings,onSaveModelDefaults:e.onSaveModelDefaults,savingModelDefaults:e.savingModelDefaults,thread:e.thread,projectId:e.projectId,runtimeKey:e.runtimeKey,threadLoading:e.threadLoading,disabled:e.disabled||!!e.threadLoading||R||e.submitting||e.resuming||e.forking,children:[R&&(0,W.jsx)(ol,{content:`中断`,children:(0,W.jsxs)(q,{"aria-label":e.interrupting?`请求中…`:`中断`,variant:`secondary`,size:`sm`,onClick:e.onInterrupt,disabled:!e.canInterrupt||e.interrupting,children:[(0,W.jsx)(J,{name:`stop`,size:13}),(0,W.jsx)(`span`,{className:`composer-action-label`,children:e.interrupting?`请求中…`:`中断`})]})}),(0,W.jsx)(ol,{id:i,className:`composer-submit`,content:T?`Enter 执行命令 / Esc 关闭菜单`:`Enter 发送 / Shift + Enter 换行`,children:(0,W.jsxs)(q,{size:`sm`,"aria-label":T?M?`正在执行命令…`:`执行命令`:e.submitting?`正在提交…`:R?`追加要求`:`发送任务`,"aria-describedby":i,onPointerDown:e=>{T&&e.preventDefault()},onClick:()=>{oe()},disabled:T?M||!!j?.unavailableReason:!ae,children:[(0,W.jsx)(J,{name:`send`,size:14}),(0,W.jsx)(`span`,{className:`composer-action-label`,children:T?M?`正在执行…`:`执行命令`:e.submitting?`正在提交…`:R?`追加要求`:`发送任务`})]})})]})]}),(0,W.jsx)(`p`,{className:`composer-note`,children:R?`关闭页面不会停止任务。中断以 Codex 返回的实际状态为准。`:`Codex 使用服务器项目与权限执行,请核对操作和变更。`})]})}var ww={read:`读取`,write:`写入`,deny:`禁止访问`};function Tw({request:e}){let t=e.fileSystem,n=[...t?.read.map(e=>({path:e,access:`read`}))??[],...t?.write.map(e=>({path:e,access:`write`}))??[],...t?.entries??[]];return(0,W.jsxs)(`div`,{className:`permission-details`,children:[e.network!==void 0&&(0,W.jsxs)(`div`,{className:`permission-network`,children:[(0,W.jsx)(`strong`,{children:`网络访问`}),(0,W.jsx)(`span`,{children:e.network===!0?`允许访问网络`:e.network===!1?`不开放额外网络访问`:`未指定网络访问变更`})]}),n.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{children:`文件与目录`}),(0,W.jsx)(`ul`,{className:`permission-paths`,children:n.map((e,t)=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`permission-access permission-access-${e.access}`,children:ww[e.access]??e.access}),(0,W.jsx)(`code`,{children:e.path})]},`${e.access}-${e.path}-${t}`))})]}),t?.globScanMaxDepth!==void 0&&(0,W.jsxs)(`p`,{children:[`目录匹配搜索深度:`,t.globScanMaxDepth]}),e.network===void 0&&n.length===0&&(0,W.jsx)(`p`,{children:`未请求额外网络或文件访问权限。`})]})}var Ew=class extends Error{code;status;details;constructor(e,t,n=400,r){super(t),this.code=e,this.status=n,this.details=r,this.name=`AppError`}toJSON(e){return{code:this.code,message:this.message,...e?{clientOperationId:e}:{},...this.details===void 0?{}:{details:this.details}}}},Dw=e=>{throw new Ew(`VALIDATION_ERROR`,e)};function Ow(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(`${e}T00:00:00.000Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e}function kw(e,t){switch(e){case`email`:return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);case`uri`:try{return!/\s/.test(t)&&!!new URL(t).protocol}catch{return!1}case`date`:return Ow(t);case`date-time`:{let e=/^(\d{4}-\d{2}-\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/.exec(t);return!!(e&&Ow(e[1])&&Number(e[2])<=23&&Number(e[3])<=59&&Number(e[4])<=59&&(e[5]===void 0||Number(e[5])<=23)&&(e[6]===void 0||Number(e[6])<=59)&&Number.isFinite(Date.parse(t)))}default:return!0}}function Aw(e,t){let n=()=>Dw(`“${e.title}”的回答不符合字段要求`);switch(e.type){case`string`:if(typeof t!=`string`)n();else{let r=[...t].length;(e.minLength!==void 0&&r<e.minLength||e.maxLength!==void 0&&r>e.maxLength||t.length>1e4||!kw(e.format,t))&&n()}break;case`number`:case`integer`:(typeof t!=`number`||!Number.isFinite(t)||e.type===`integer`&&!Number.isSafeInteger(t)||e.minimum!==void 0&&t<e.minimum||e.maximum!==void 0&&t>e.maximum)&&n();break;case`boolean`:typeof t!=`boolean`&&n();break;case`enum`:(typeof t!=`string`||t.length>1e4||!e.options?.some(e=>e.value===t))&&n();break;case`multiEnum`:(!Array.isArray(t)||t.some(t=>typeof t!=`string`||t.length>1e4||!e.options?.some(e=>e.value===t))||t.length>500||new Set(t).size!==t.length||e.minItems!==void 0&&t.length<e.minItems||e.maxItems!==void 0&&t.length>e.maxItems)&&n()}}function jw(e){switch(e){case`pending`:return`需要你处理`;case`responding`:return`正在提交…`;case`responded`:return`已处理`;case`expired`:return`请求已失效`}}function Mw(e){return Object.fromEntries(e.filter(e=>e.default!==void 0).map(e=>[e.name,typeof e.default==`number`?String(e.default):e.default]))}function Nw(e){let t=[];return e.type===`integer`&&t.push(`填写整数`),e.minimum!==void 0&&t.push(`最小 ${e.minimum}`),e.maximum!==void 0&&t.push(`最大 ${e.maximum}`),e.minLength!==void 0&&t.push(`至少 ${e.minLength} 个字符`),e.maxLength!==void 0&&t.push(`最多 ${e.maxLength} 个字符`),e.minItems!==void 0&&t.push(`至少选择 ${e.minItems} 项`),e.maxItems!==void 0&&t.push(`最多选择 ${e.maxItems} 项`),e.format===`date-time`&&t.push(`日期与时间需包含时区,例如 2026-10-14T12:30:00+08:00`),t.join(` · `)}function Pw(e,t){let n=Object.create(null),r=Object.create(null);for(let i of e){let e=Object.hasOwn(t,i.name)?t[i.name]:void 0;if(e===void 0||(i.type===`number`||i.type===`integer`)&&e===``){i.required&&(r[i.name]=`请填写此必填项。`);continue}let a=i.type===`number`||i.type===`integer`?Number(e):e;try{Aw(i,a),n[i.name]=a}catch(e){r[i.name]=e instanceof Error?e.message:`请检查此字段的填写要求。`}}return{content:n,errors:r}}function Fw(e){if(e)try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password?t.href:void 0}catch{return}}function Iw({request:e,actionId:t,status:n,disabled:r,onResolve:i}){let a=e.fields??[],o=n===`pending`?e.approval?`允许本次`:e.mode===`url`?`我已完成`:a.length===0?`确认继续`:a.every(e=>[`boolean`,`enum`,`multiEnum`].includes(e.type))?`确认选择`:`提交回答`:jw(n),[s,c]=(0,O.useState)(()=>Mw(a)),[l,u]=(0,O.useState)(!1),{content:d,errors:f}=Pw(a,s),p=Fw(e.url),m=e.schemaError||(e.mode===`url`&&!p?`此请求没有可安全打开的 HTTP 或 HTTPS 地址,无法确认完成。`:void 0),h=(e,t)=>c(n=>({...n,[e]:t}));return(0,W.jsxs)(`form`,{className:`elicitation-form`,noValidate:!0,onSubmit:t=>{t.preventDefault(),!(r||m)&&(u(!0),!(e.mode===`form`&&Object.keys(f).length>0)&&i(e.mode===`form`&&!e.approval?{decision:`accept`,content:d}:{decision:`accept`}))},children:[(0,W.jsxs)(`p`,{className:`elicitation-source`,children:[`来源:`,(0,W.jsx)(`strong`,{children:e.serverName})]}),e.approval?.allowSession&&(0,W.jsx)(`p`,{className:`elicitation-scope subtle`,children:`本会话允许仅适用于当前请求对应的工具或连接范围,并受审批策略约束;新会话需重新确认。`}),m&&(0,W.jsx)(`p`,{className:`elicitation-error`,role:`alert`,children:m}),e.mode===`url`?(0,W.jsxs)(`div`,{className:`elicitation-url`,children:[(0,W.jsx)(`span`,{children:`访问地址`}),(0,W.jsx)(`code`,{children:e.url??`未提供地址`}),p&&(0,W.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,referrerPolicy:`no-referrer`,children:`在新标签页打开`}),(0,W.jsx)(`p`,{children:`完成页面中的操作后,点击“我已完成”继续。`})]}):!m&&(0,W.jsx)(`div`,{className:`elicitation-fields`,children:a.map((e,n)=>{let i=`elicitation-${t}-${n}`,a=Nw(e),o=l?f[e.name]:void 0,c=Object.hasOwn(s,e.name)?s[e.name]:void 0,u=[e.description&&`${i}-description`,a&&`${i}-hint`,o&&`${i}-error`].filter(Boolean).join(` `)||void 0;return(0,W.jsxs)(`div`,{className:`elicitation-field`,children:[(0,W.jsxs)(`div`,{className:`elicitation-field-heading`,children:[(0,W.jsxs)(`label`,{id:`${i}-label`,htmlFor:e.type===`multiEnum`?void 0:i,children:[e.title,(0,W.jsx)(`span`,{className:`field-necessity`,"aria-hidden":`true`,children:e.required?`必填`:`可选`})]}),!e.required&&c!==void 0&&(0,W.jsxs)(`button`,{type:`button`,className:`field-unset`,disabled:r,onClick:()=>h(e.name,void 0),children:[`不填写`,(0,W.jsx)(`span`,{className:`sr-only`,children:e.title})]})]}),e.description&&(0,W.jsx)(`p`,{id:`${i}-description`,className:`field-description`,children:e.description}),e.type===`boolean`||e.type===`enum`?(0,W.jsxs)(`select`,{id:i,className:`text-input`,value:c===void 0?``:e.type===`boolean`?c?`true`:`false`:`option:${String(c)}`,disabled:r,"aria-required":e.required,"aria-invalid":!!o,"aria-describedby":u,onChange:t=>h(e.name,t.target.value===``?void 0:e.type===`boolean`?t.target.value===`true`:t.target.value.slice(7)),children:[(0,W.jsx)(`option`,{value:``,children:`请选择`}),e.type===`boolean`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`option`,{value:`true`,children:`是`}),(0,W.jsx)(`option`,{value:`false`,children:`否`})]}):e.options?.map(e=>(0,W.jsx)(`option`,{value:`option:${e.value}`,children:e.label},e.value))]}):e.type===`multiEnum`?(0,W.jsx)(`div`,{role:`group`,"aria-labelledby":`${i}-label`,"aria-describedby":u,"aria-invalid":!!o,className:`elicitation-multi-options`,children:e.options?.map(t=>(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,disabled:r,checked:Array.isArray(c)&&c.includes(t.value),onChange:n=>{let r=Array.isArray(c)?c:[];h(e.name,n.target.checked?[...r,t.value]:r.filter(e=>e!==t.value))}}),(0,W.jsx)(`span`,{children:t.label})]},t.value))}):(0,W.jsx)(`input`,{id:i,className:`text-input`,type:e.type===`number`||e.type===`integer`?`number`:e.format===`email`?`email`:e.format===`uri`?`url`:e.format===`date`?`date`:`text`,value:typeof c==`string`?c:``,step:e.type===`integer`?1:`any`,min:e.minimum,max:e.maximum,disabled:r,"aria-required":e.required,"aria-invalid":!!o,"aria-describedby":u,placeholder:e.required?void 0:`未填写(可选)`,autoComplete:`off`,onChange:t=>h(e.name,t.target.value)}),a&&(0,W.jsx)(`p`,{id:`${i}-hint`,className:`field-hint`,children:a}),o&&(0,W.jsx)(`p`,{id:`${i}-error`,className:`elicitation-error`,role:`alert`,children:o})]},e.name)})}),l&&Object.keys(f).length>0&&!m&&(0,W.jsx)(`p`,{className:`elicitation-error`,role:`alert`,children:`请检查标出的字段后再提交。`}),(0,W.jsxs)(`div`,{className:`action-options`,children:[!m&&(0,W.jsx)(q,{type:`submit`,disabled:r,children:o}),!m&&e.approval?.allowSession&&(0,W.jsx)(q,{variant:`secondary`,disabled:r,onClick:()=>i({decision:`accept`,persist:`session`}),children:`本会话允许`}),(0,W.jsx)(q,{variant:`secondary`,disabled:r,onClick:()=>i({decision:`decline`}),children:`拒绝`}),(0,W.jsx)(q,{variant:`ghost`,disabled:r,onClick:()=>i({decision:`cancel`}),children:`取消`})]})]})}function Lw({action:e,disabled:t,onResolve:n}){let[r,i]=(0,O.useState)({}),[a,o]=(0,O.useState)({}),s=e.status===`pending`,c=e.questions??[],l=e=>r[e]===`__other__`?a[e]?.trim()??``:r[e]?.trim()??``,u=c.length>0&&c.every(e=>l(e.id)),d=c.length>0&&c.every(e=>e.options.length>0&&r[e.id]!==`__other__`);return(0,W.jsxs)(`section`,{className:`action-card${e.kind===`unsupported`?` action-card-unsupported`:``}`,"aria-label":e.title,children:[(0,W.jsxs)(`div`,{className:`action-heading`,children:[(0,W.jsx)(`span`,{className:`action-icon`,children:(0,W.jsx)(J,{name:e.kind===`questions`?`chat`:`alert`,size:17})}),(0,W.jsx)(`h3`,{children:e.title}),(0,W.jsx)(`span`,{className:`action-state`,children:e.kind===`unsupported`&&e.status===`expired`?`请求未能处理`:jw(e.status)})]}),e.reason&&(0,W.jsx)(`p`,{children:e.reason}),e.cwd&&(0,W.jsxs)(`p`,{className:`mono subtle action-cwd`,children:[(0,W.jsx)(`span`,{children:`工作目录:`}),e.cwd]}),e.command&&(0,W.jsx)(`pre`,{className:`command`,children:(0,W.jsx)(`code`,{children:e.command})}),e.kind===`permissions`&&e.permissionRequest&&(0,W.jsx)(Tw,{request:e.permissionRequest}),e.details!==void 0&&(0,W.jsxs)(`details`,{className:`raw-details`,open:e.kind===`network`||e.kind===`file`||void 0,children:[(0,W.jsx)(`summary`,{children:e.kind===`network`?`网络访问目标`:e.kind===`file`?`变更详情`:e.kind===`permissions`||e.kind===`elicitation`?`技术详情`:`请求详情`}),(0,W.jsx)(`pre`,{children:JSON.stringify(e.details,null,2)})]}),e.kind===`elicitation`&&e.elicitation?(0,W.jsx)(Iw,{request:e.elicitation,actionId:e.actionId,status:e.status,disabled:t||!s,onResolve:n}):e.kind===`questions`?(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!t&&s&&u&&n({answers:Object.fromEntries(c.map(e=>[e.id,[l(e.id)]]))})},children:[c.map(n=>(0,W.jsxs)(`fieldset`,{disabled:t||!s,children:[(0,W.jsx)(`legend`,{children:n.header}),(0,W.jsx)(`p`,{children:n.question}),n.options.map((t,a)=>(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${e.actionId}-${n.id}`,value:t.label,checked:r[n.id]===t.label,onChange:()=>i(e=>({...e,[n.id]:t.label}))}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:t.label}),(0,W.jsx)(`small`,{children:t.description})]}),(0,W.jsx)(`span`,{className:`option-number`,children:a+1})]},t.label)),n.options.length>0&&n.isOther&&(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${e.actionId}-${n.id}`,checked:r[n.id]===`__other__`,onChange:()=>i(e=>({...e,[n.id]:`__other__`}))}),(0,W.jsx)(`span`,{children:`其他回答`})]}),(n.options.length===0||r[n.id]===`__other__`)&&(0,W.jsx)(`input`,{className:`text-input`,type:n.isSecret?`password`:`text`,"aria-label":`${n.header}:自由回答`,value:n.options.length===0?r[n.id]??``:a[n.id]??``,maxLength:1e4,onChange:e=>n.options.length===0?i(t=>({...t,[n.id]:e.target.value})):o(t=>({...t,[n.id]:e.target.value})),placeholder:`输入你的回答`,autoComplete:`off`})]},n.id)),(0,W.jsx)(q,{type:`submit`,disabled:t||!s||!u,children:s?d?`确认选择`:`提交回答`:jw(e.status)})]}):(0,W.jsx)(`div`,{className:`action-options`,children:e.options.map(e=>(0,W.jsx)(q,{variant:/decline|cancel|reject|deny/i.test(e.id)?`secondary`:`default`,disabled:t||!s,onClick:()=>n({decision:e.id}),children:e.label},e.id))}),e.kind===`unsupported`&&(0,W.jsx)(`p`,{className:`inline-error`,children:`当前版本不支持此交互请求,未发送批准。请查看兼容性诊断。`})]})}var Rw={connecting:`正在连接`,connected:`实时连接正常`,disconnected:`连接已断开`,authenticationRequired:`需要重新登录`},zw={accepted:`网关已接受`,dispatching:`等待上游确认`,acknowledged:`上游已确认提交`,failed:`提交失败`,unknown:`提交结果待核对`};function Bw({connection:e}){return(0,W.jsxs)(`span`,{className:`connection-badge connection-${e}`,children:[(0,W.jsx)(`span`,{className:`status-dot`}),Rw[e]]})}function Vw({entry:e,thread:t,onReconcile:n,onDiscardMissing:r,busy:i,refreshing:a}){let[o,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(!1),u=e.operation?.execution,d=e.kind===`fork`,f=!!(t&&kl(t.status)&&u?.threadId===t.id),p=!!(!d&&t&&kl(t.status)&&e.target===t.id);return(0,W.jsxs)(`div`,{className:`operation-card`,children:[(0,W.jsxs)(`div`,{className:`operation-title`,children:[(0,W.jsx)(`strong`,{children:zw[e.status]}),(0,W.jsx)(`span`,{children:Tn(e.createdAt)})]}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`操作`}),(0,W.jsx)(`dd`,{children:e.kind}),(0,W.jsx)(`dt`,{children:`目标`}),(0,W.jsx)(`dd`,{children:e.target}),(0,W.jsx)(`dt`,{children:`操作 ID`}),(0,W.jsx)(`dd`,{children:e.clientOperationId}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`会话`}),(0,W.jsx)(`dd`,{children:u.threadId}),(0,W.jsx)(`dt`,{children:`工作区`}),(0,W.jsx)(`dd`,{children:u.workspaceKey}),(0,W.jsx)(`dt`,{children:`运行状态`}),(0,W.jsx)(`dd`,{children:u.ended?`已经结束`:`尚未确认终结`})]})]}),(e.lookupError?.message||e.error)&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:e.lookupError?.message??e.error}),An(e)&&(0,W.jsxs)(`div`,{className:`reconcile`,children:[(0,W.jsx)(`p`,{children:`请先检查会话历史、会话列表和原执行环境。清理仅移除此浏览器的待核对记录,不会停止任务或重新提交。`}),p?(0,W.jsx)(`p`,{children:`当前会话仍在执行,请等待结束或正常中断后再核对。`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`我已检查历史和原执行环境,确认无需继续核对这笔提交`]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!c||i||a,onClick:()=>r(e.clientOperationId),children:`清除此浏览器的待核对记录`})]})]}),e.kind===`confirmCompatibility`&&e.status===`unknown`&&(0,W.jsx)(`p`,{className:`subtle`,children:`兼容性确认结果待核对,请刷新状态。此记录不代表任务执行,也不会自动重新提交。`}),e.kind!==`confirmCompatibility`&&Nn(e)&&!e.lookupError?.missing&&!e.operation?.reconciliation&&(0,W.jsxs)(`div`,{className:`reconcile`,children:[(0,W.jsx)(`p`,{children:d?`请先刷新会话列表,检查是否已生成包含原历史的新会话。核对此次 Fork 不会停止原任务或改变原任务的执行状态。`:`不会自动重发任务。先检查会话历史和原执行环境,再核对这笔提交。`}),f?(0,W.jsx)(`p`,{children:`当前任务仍在执行,请使用输入区的中断按钮。`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),d?`我已检查会话列表和历史,核实此次 Fork 的结果`:`我已核实对应旧运行已经结束`]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!o||i||a,onClick:()=>n(e.clientOperationId),children:i?`正在提交核对…`:d?`核对此次 Fork`:`核对并解除旧占用`})]})]}),e.operation?.reconciliation&&(0,W.jsxs)(`p`,{className:`subtle`,children:[`已于 `,Tn(e.operation.reconciliation.at),` `,d?`人工核对 Fork 结果。原任务状态不变。`:`人工核对旧运行结束。`,`保留原始提交状态。`]})]})}function Hw({system:e,connection:t,operations:n,thread:r,selectedId:i,threadReadFailed:a,onRefresh:o,onReconcile:s,onDiscardMissing:c,busy:l,open:u,onOpenChange:d,refreshing:f}){let p=(0,O.useRef)(null);return(0,O.useEffect)(()=>{u&&p.current?.focus()},[u]),(0,W.jsxs)(`details`,{className:`diagnostics`,open:u,onToggle:e=>d(e.currentTarget.open),children:[(0,W.jsxs)(`summary`,{children:[(0,W.jsx)(J,{name:`settings`,size:16}),`状态诊断`,n.length>0&&(0,W.jsx)(`span`,{className:`count-badge`,children:n.length})]}),(0,W.jsxs)(`div`,{className:`diagnostics-panel`,id:`diagnostics-panel`,ref:p,tabIndex:-1,role:`region`,"aria-label":`状态诊断详情`,"aria-busy":f,children:[(0,W.jsxs)(`div`,{className:`diagnostics-heading`,children:[(0,W.jsx)(`h2`,{children:`运行状态`}),(0,W.jsxs)(q,{variant:`ghost`,size:`sm`,disabled:f,onClick:o,children:[(0,W.jsx)(J,{name:`refresh`,size:14}),f?`正在核对…`:`刷新状态`]})]}),(0,W.jsxs)(`section`,{className:`operation-section`,"aria-label":`当前会话信息`,children:[(0,W.jsx)(`h3`,{children:`当前会话`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Thread ID`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(Ml,{id:r?.id===i?r?.id:void 0,placeholder:i?a?`会话详情加载失败`:`正在加载会话详情…`:`会话尚未创建`})})]})]}),(0,W.jsxs)(`section`,{className:`operation-section`,children:[(0,W.jsx)(`h3`,{children:`操作与状态核对`}),(0,W.jsx)(`p`,{className:`subtle`,role:`status`,children:f?`正在核对会话历史和提交回执…`:r?.status===`unknown`?`会话状态仍待核对。请检查操作记录和原执行环境。`:n.length>0?`请查看提交记录;核对不会自动重发任务。`:`没有待核对的提交。`}),n.map(e=>(0,W.jsx)(Vw,{entry:e,thread:r,onReconcile:s,onDiscardMissing:c,busy:l.includes(`reconcile:${e.clientOperationId}`)||l.includes(`${e.kind}:${e.target}`),refreshing:f},e.clientOperationId))]}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`网页连接`}),(0,W.jsx)(`dd`,{children:Rw[t]}),(0,W.jsx)(`dt`,{children:`Codex`}),(0,W.jsx)(`dd`,{children:e?.ready?`已就绪`:e?.connection===`starting`?`启动中`:`不可用`}),(0,W.jsx)(`dt`,{children:`账户认证`}),(0,W.jsx)(`dd`,{children:e?.authenticated===!0?`可用`:e?.authenticated===!1?`需要在本机登录 Codex`:`尚未确认`}),(0,W.jsx)(`dt`,{children:`运行版本`}),(0,W.jsx)(`dd`,{children:e?.codexVersion??`未检测到`}),(0,W.jsx)(`dt`,{children:`已验证版本`}),(0,W.jsx)(`dd`,{children:e?.verifiedVersion??`读取中`}),(0,W.jsx)(`dt`,{children:`兼容性`}),(0,W.jsx)(`dd`,{children:e?.compatibility===`verified`?`版本已验证`:e?.compatibility===`unverified`?e.compatibilityConfirmation===`confirmed`?`当前版本未经验证 · 已确认继续`:`当前版本未经验证 · 待确认`:`不可用`}),(0,W.jsx)(`dt`,{children:`入口认证`}),(0,W.jsx)(`dd`,{children:e?.authMode===`cloudflare-access`?`Cloudflare Access`:`本机模式`})]}),e?.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error}),e&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:`已支持能力`}),(0,W.jsx)(`p`,{children:e.capabilities.join(` · `)||`暂无`})]})]})]})}async function Uw(e){let t=await fetch(`/api/threads/${encodeURIComponent(e)}/export`,{credentials:`same-origin`,cache:`no-store`,headers:{Accept:`text/markdown`},signal:AbortSignal.timeout(35e3)}),n=t.headers.get(`content-type`)??``;if(!t.ok||!n.includes(`text/markdown`)){if(n.includes(`application/json`)){let e=await t.json();throw new Le(t.status,e.error??{code:`EXPORT_FAILED`,message:`无法读取会话历史,未下载文件。`})}throw new Le(t.status===200?401:t.status,{code:`AUTH_REQUIRED`,message:`登录已过期或历史接口未返回 Markdown,请重新登录后重试。`})}let r=/filename="(codex-thread-[A-Za-z0-9_-]+\.md)"/.exec(t.headers.get(`content-disposition`)??``)?.[1];if(!r)throw Error(`导出响应缺少有效文件名,未下载文件。`);let i=t.headers.get(`x-export-completeness`);if(i!==`partial`&&i!==`saved-history`)throw Error(`导出响应缺少历史完整性说明,未下载文件。`);let a=await t.blob(),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=r,document.body.append(s);try{s.click()}finally{s.remove(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}return{partial:i===`partial`}}function Ww(e){let{system:t}=e,n=(0,O.useRef)(null),[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(),s=Vn(t),c=Un(t,r,a);(0,O.useEffect)(()=>{e.onOpenChange?.(c)},[c,e.onOpenChange]),(0,O.useEffect)(()=>{let e=n.current;if(e)return c&&!e.open?e.showModal():!c&&e.open&&e.close(),()=>{e.open&&e.close()}},[c]);function l(){i(s),o(void 0)}return(0,W.jsxs)(W.Fragment,{children:[t?.compatibility===`unverified`&&(0,W.jsxs)(`div`,{className:`compatibility-banner compatibility-notice`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[`当前 Codex `,t.codexVersion,` 尚未验证兼容性,部分功能可能无法正常使用。`,t.compatibilityConfirmation===`confirmed`?` 已确认继续;这不代表版本已验证。`:` 使用前需要确认。`]}),t.compatibilityConfirmation===`required`&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>o(s),children:`查看兼容性提示`})]}),(0,W.jsxs)(`dialog`,{ref:n,className:`compatibility-dialog`,"aria-labelledby":`compatibility-title`,"aria-describedby":`compatibility-description`,onCancel:e=>{e.preventDefault(),l()},children:[(0,W.jsxs)(`div`,{className:`compatibility-dialog-heading`,children:[(0,W.jsx)(J,{name:`alert`,size:22}),(0,W.jsx)(`h2`,{id:`compatibility-title`,children:`Codex 版本兼容性未经验证`})]}),(0,W.jsx)(`p`,{id:`compatibility-description`,children:`当前运行的 Codex 版本尚未验证,部分功能可能无法正常使用。确认继续后仍将保留兼容性提示。`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`运行版本`}),(0,W.jsx)(`dd`,{children:t?.codexVersion??`未检测到`}),(0,W.jsx)(`dt`,{children:`已验证版本`}),(0,W.jsx)(`dd`,{children:t?.verifiedVersion??`读取中`})]}),t?.ready?!e.canConfirm&&(0,W.jsx)(`p`,{className:`subtle`,role:`status`,children:`请等待连接和 Codex 认证恢复后再确认。`}):(0,W.jsx)(`p`,{className:`inline-error`,role:`status`,children:`Codex 当前不可用,无法确认继续。请关闭此提示后查看状态诊断。`}),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:e.error}),e.uncertain&&(0,W.jsxs)(`div`,{className:`compatibility-uncertain`,role:`status`,children:[(0,W.jsx)(`p`,{children:`确认请求的结果尚待核对。可刷新状态,或重新确认当前运行版本的使用许可;不会重发任务。`}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,onClick:e.onRefresh,children:`刷新确认状态`}),t?.ready&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!e.canConfirm||e.submitting,onClick:e.onReconfirm,children:`重新确认`})]}),(0,W.jsx)(`p`,{className:`subtle`,children:`关闭提示后仍可查看诊断或中断当前任务。确认不会自动发送任务,未发送的草稿会保留。`}),(0,W.jsxs)(`div`,{className:`compatibility-dialog-actions`,children:[(0,W.jsx)(q,{variant:`secondary`,autoFocus:!0,onClick:l,children:`暂不使用`}),t?.ready&&(0,W.jsx)(q,{disabled:!e.canConfirm||e.submitting||e.uncertain,onClick:e.onConfirm,children:e.submitting?`正在确认…`:`确认继续`})]})]})]})}function Gw(e){let t=(0,O.useRef)(null),n=(0,O.useRef)(!1),[r,i]=(0,O.useState)(``),[a,o]=(0,O.useState)(e.project?.name??``),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(),p=e.disabled||l,m=s?`移除项目`:e.project?`管理项目`:`添加服务器项目`;(0,O.useEffect)(()=>{let e=t.current;return e?.showModal(),()=>e?.close()},[]);async function h(){if(!(p||n.current)){n.current=!0,u(!0),f(void 0);try{e.project?s?await e.onRemove(e.project.id):await e.onRename(e.project.id,a.trim()):await e.onAdd({path:r.trim(),...a.trim()?{name:a.trim()}:{}}),e.onClose()}catch(e){f(En(e))}finally{n.current=!1,u(!1)}}}return(0,W.jsxs)(`dialog`,{ref:t,className:`project-dialog`,"aria-labelledby":`project-dialog-title`,"aria-describedby":`project-dialog-description`,onCancel:t=>{t.preventDefault(),l||e.onClose()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(J,{name:`folder`,size:20}),(0,W.jsx)(`h2`,{id:`project-dialog-title`,children:m})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭项目管理`,disabled:l,onClick:e.onClose,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},children:[s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{id:`project-dialog-description`,children:[`确定从工作空间移除「`,e.project?.name,`」?`]}),(0,W.jsxs)(`div`,{className:`project-removal-note`,children:[(0,W.jsx)(`p`,{children:`只移除项目列表中的记录,服务器上的文件和会话历史都会保留。`}),(0,W.jsx)(`p`,{children:`之后重新添加同一目录,即可继续访问原有会话。进行中的任务或未确认的操作需要先处理完成。`})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{id:`project-dialog-description`,children:e.project?`为项目设置便于识别的名称,或从工作空间移除项目。`:`添加运行 Codex Web UI 的服务器上已有的目录。添加后即可查看历史会话并开始工作。`}),e.project?(0,W.jsxs)(`div`,{className:`project-directory`,children:[(0,W.jsx)(`span`,{children:`服务器目录`}),(0,W.jsx)(`code`,{children:e.project.rootPath})]}):(0,W.jsxs)(`label`,{className:`project-field`,children:[(0,W.jsx)(`span`,{children:`服务器目录`}),(0,W.jsx)(`input`,{autoFocus:!0,required:!0,autoComplete:`off`,spellCheck:!1,placeholder:`/home/you/code/my-project`,value:r,onChange:e=>i(e.target.value),"aria-describedby":`project-path-help`,"aria-label":`服务器目录`,disabled:p}),(0,W.jsx)(`small`,{id:`project-path-help`,children:`填写服务器上的绝对路径,不是当前浏览器所在设备的目录。目录需要已存在,且服务有权访问。`})]}),(0,W.jsxs)(`label`,{className:`project-field`,children:[(0,W.jsx)(`span`,{children:e.project?`项目名称`:`项目名称(可选)`}),(0,W.jsx)(`input`,{autoFocus:!!e.project,required:!!e.project,maxLength:100,placeholder:`默认使用目录名称`,value:a,onChange:e=>o(e.target.value),disabled:p})]})]}),d&&(0,W.jsx)(`p`,{className:`inline-error project-dialog-error`,role:`alert`,children:d}),e.disabled&&(0,W.jsx)(`p`,{className:`subtle`,children:`登录已过期,请重新登录后管理项目。`}),(0,W.jsxs)(`div`,{className:`project-dialog-actions`,children:[e.project&&!s&&(0,W.jsx)(q,{className:`project-remove-button`,variant:`ghost`,disabled:p,onClick:()=>{f(void 0),c(!0)},children:`移除项目…`}),(0,W.jsx)(q,{variant:`secondary`,disabled:l,onClick:()=>{s?(f(void 0),c(!1)):e.onClose()},children:s?`返回`:`取消`}),(0,W.jsx)(q,{type:`submit`,variant:s?`destructive`:`default`,disabled:p||!s&&(e.project?!a.trim():!r.trim()),children:l?s?`正在移除…`:`正在保存…`:s?`确认移除`:e.project?`保存名称`:`添加项目`})]})]})]})}function Kw({notifications:e,onClose:t}){let n=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=n.current;return e?.showModal(),()=>e?.close()},[]);let{enabled:r,access:i,requesting:a,error:o}=e,s=r&&i===`granted`,c={default:`尚未授权`,granted:`已授权`,denied:`已被浏览器阻止`,unsupported:`当前浏览器不支持`,insecure:`需要安全连接`}[i],l=![`default`,`granted`].includes(i);return(0,W.jsxs)(`dialog`,{ref:n,className:`project-dialog notification-dialog`,"aria-labelledby":`notification-dialog-title`,onCancel:e=>{e.preventDefault(),t()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(I,{size:20,"aria-hidden":`true`}),(0,W.jsx)(`h2`,{id:`notification-dialog-title`,children:`工作完成通知`})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭通知设置`,onClick:t,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsx)(`p`,{children:`每轮工作结束时显示项目、会话及结果,点击通知可返回对应会话。`}),(0,W.jsxs)(`div`,{className:`notification-control`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`浏览器通知`}),(0,W.jsxs)(`span`,{role:`status`,children:[c,` · `,s?`已开启`:`未开启`]})]}),(0,W.jsx)(q,{role:`switch`,"aria-label":`浏览器通知`,"aria-checked":s,"aria-describedby":`notification-permission-help`,variant:s?`secondary`:`default`,size:`sm`,disabled:a||l,onClick:()=>void e.toggle(),children:a?`等待授权…`:s?`关闭通知`:`启用通知`})]}),(0,W.jsx)(`p`,{id:`notification-permission-help`,className:`notification-help`,children:i===`denied`?`请在浏览器的站点设置中允许通知,再回到此页面开启。`:i===`insecure`?`请使用 HTTPS 访问。localhost 或 127.0.0.1 可用于本机访问。`:i===`unsupported`?`请使用支持系统通知的桌面浏览器。页内状态与未读提示仍然可用。`:`只有点击启用后才会请求授权。此设置在当前浏览器的本站标签页间共享。`}),r&&i===`granted`&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,onClick:e.test,children:`发送测试通知`}),o&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:o}),(0,W.jsxs)(`section`,{className:`notification-background`,"aria-labelledby":`notification-background-title`,children:[(0,W.jsx)(`h3`,{id:`notification-background-title`,children:`后台通知与页面休眠`}),(0,W.jsx)(`p`,{children:`请保持页面和浏览器运行。普通后台状态可接收通知;页面被冻结或被回收期间,无法保证及时通知。恢复页面后会同步结果与未读提示。`}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`如何让本站保持活跃`}),(0,W.jsxs)(`ul`,{children:[(0,W.jsxs)(`li`,{children:[`Chrome:设置 → 性能 → 始终保持这些网站活跃,添加本站。`,(0,W.jsx)(`a`,{href:`https://support.google.com/chrome/answer/12929150?hl=zh-Hans`,target:`_blank`,rel:`noreferrer`,children:`设置说明`})]}),(0,W.jsxs)(`li`,{children:[`Edge:设置 → 系统和性能 → 性能 → 始终保持这些网站活跃(或「从不将这些网站置于睡眠状态」),添加本站。`,(0,W.jsx)(`a`,{href:`https://support.microsoft.com/edge/learn-about-performance-features-in-microsoft-edge`,target:`_blank`,rel:`noreferrer`,children:`设置说明`})]})]}),(0,W.jsx)(`p`,{children:`需要在浏览器中手动设置,具体名称可能随版本变化。`})]})]})]})}var qw=1048576,Jw=e=>`0.0009765625–${e} MiB(最小 1 KiB)`;function Yw(e,t,n,r){return{key:e,label:`${t}(MiB)`,group:`advanced`,unit:`MiB`,maxMiB:n,help:`范围 ${Jw(n)},默认 ${r} MiB。支持精确对应整数字节的小数;1 MiB = 1024 × 1024 字节。`}}var Xw=e=>(e/qw).toFixed(20).replace(/\.?0+$/,``),Zw=[{key:`host`,label:`监听地址`,group:`network`,help:`本机模式使用 127.0.0.1、localhost 或 ::1。`},{key:`port`,label:`监听端口`,group:`network`,type:`number`,help:`范围 1–65535;修改后使用新端口访问。`},{key:`publicOrigin`,label:`允许访问地址`,group:`network`,multiline:!0,help:`每行一个完整的 HTTP(S) 地址,仅包含协议、主机和端口。`},{key:`issuer`,label:`Access 团队地址`,group:`network`,help:`例如 https://your-team.cloudflareaccess.com`},{key:`audience`,label:`Access 应用 AUD`,group:`network`,help:`填写 Cloudflare Access 应用的 Audience。`},{key:`binary`,label:`Codex 可执行文件`,group:`codex`,help:`可填写 codex 或服务器上的绝对路径。`},{key:`home`,label:`CODEX_HOME(可选)`,group:`codex`,help:`留空继承服务进程环境;指定时必须填写服务器上的绝对路径。`},{key:`requestTimeoutMs`,label:`请求超时(毫秒)`,group:`codex`,type:`number`,help:`范围 100–300000,默认 30000。`},Yw(`maxLineBytes`,`Codex 单行消息上限`,256,64),Yw(`eventBytes`,`事件缓冲上限`,64,16),Yw(`wsBytes`,`WebSocket 缓冲上限`,16,4),Yw(`itemBytes`,`单项内容上限`,8,2),{key:`developmentOrigins`,label:`开发环境来源`,group:`advanced`,multiline:!0,help:`每行一个本机 HTTP(S) 来源,仅在 --dev 模式使用。`}];function Qw(e){return{host:e.host,port:String(e.port),publicOrigin:e.publicOrigin.join(`
|
|
82
|
+
`},HS=0,US=[];function WS(e){var t=O.useRef([]),n=O.useRef([0,0]),r=O.useRef(),i=O.useState(HS++)[0],a=O.useState(fS)[0],o=O.useRef(e);O.useEffect(function(){o.current=e},[e]),O.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Hx([e.lockRef.current],(e.shards||[]).map(zS),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=O.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=LS(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=AS(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=AS(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return IS(h,t,e,h===`h`?s:c,!0)},[]),c=O.useCallback(function(e){var n=e;if(US.length&&US[US.length-1]===a){var r=`deltaY`in n?RS(n):LS(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&BS(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(zS).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=O.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:GS(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=O.useCallback(function(e){n.current=LS(e),r.current=void 0},[]),d=O.useCallback(function(t){l(t.type,RS(t),t.target,s(t,e.lockRef.current))},[]),f=O.useCallback(function(t){l(t.type,LS(t),t.target,s(t,e.lockRef.current))},[]);O.useEffect(function(){return US.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,TS),document.addEventListener(`touchmove`,c,TS),document.addEventListener(`touchstart`,u,TS),function(){US=US.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,TS),document.removeEventListener(`touchmove`,c,TS),document.removeEventListener(`touchstart`,u,TS)}},[]);var p=e.removeScrollBar,m=e.inert;return O.createElement(O.Fragment,null,m?O.createElement(a,{styles:VS(i)}):null,p?O.createElement(SS,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function GS(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var KS=nS(rS,WS),qS=O.forwardRef(function(e,t){return O.createElement(aS,Bx({},e,{ref:t,sideCar:KS}))});qS.classNames=aS.classNames;var JS=Object.defineProperty,YS=(e,t)=>JS(e,`name`,{value:t,configurable:!0}),XS={ItemAligned:`item-aligned`,Popper:`popper`},ZS={LTR:`ltr`,RTL:`rtl`},QS=[` `,`Enter`,`ArrowUp`,`ArrowDown`],$S=[` `,`Enter`],eC=`Select`,[tC,nC,rC]=sx(eC),[iC,aC]=Yr(eC,[rC,js]),oC=js(),[sC,cC]=iC(eC),[lC,uC]=iC(eC);function dC(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=oC(t),[_,v]=O.useState(null),[y,b]=O.useState(null),[x,S]=O.useState(!1),C=Cx(l),[w,T]=fc({prop:r,defaultProp:i??!1,onChange:a,caller:eC}),[E,D]=fc({prop:o,defaultProp:s,onChange:c,caller:eC}),k=O.useRef(null),A=O.useRef(!1),[j,M]=O.useState(null),N=YS(e=>{M({value:e,hasConsumerStoppedPropagation:A.current}),D(e)},`handleUserSelect`),P=O.useRef(E);O.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=YS(()=>D(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,D]);let F=!_||!!m||!!_.closest(`form`),[I,L]=O.useState(new Set),ee=ca(),te=Array.from(I).map(e=>e.props.value).join(`;`),R=O.useCallback(e=>{L(t=>new Set(t).add(e))},[]),ne=O.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),re={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:ee,value:E,onValueChange:D,hasConsumerStoppedPropagationRef:A,userSelection:j,onUserSelect:N,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:k,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:I,nativeSelectKey:te,isFormControl:F};return(0,W.jsx)(Ps,{...g,children:(0,W.jsx)(sC,{scope:t,...re,children:(0,W.jsx)(tC.Provider,{scope:t,children:(0,W.jsx)(lC,{scope:t,onNativeOptionAdd:R,onNativeOptionRemove:ne,children:QC(h)?h(re):n})})})})}YS(dC,`SelectProvider`);var fC=YS(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(dC,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(ZC,{__scopeSelect:t}):null]})})},`Select`),pC=`SelectTrigger`,mC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=oC(n),o=cC(pC,n),s=o.disabled||r,c=Wr(t,o.onTriggerChange),l=nC(n),u=O.useRef(`touch`),[d,f,p]=ew(e=>{let t=l().filter(e=>!e.disabled),n=tw(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onUserSelect(n.value)}),m=YS(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,W.jsx)(Is,{asChild:!0,...a,children:(0,W.jsx)(_i.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":$C(o.value)?``:void 0,...i,ref:c,onClick:Fr(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:Fr(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:Fr(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(o.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),f(e.key)),!(t&&e.key===` `)&&QS.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),hC=`SelectValue`,gC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=cC(hC,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Wr(t,c.onValueNodeChange);yi(()=>{l(u)},[l,u]);let f=$C(c.value);return(0,W.jsx)(_i.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,W.jsx)(O.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),_C=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(_i.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[vC,yC]=iC(`SelectPortal`,{forceMount:void 0}),bC=YS(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(vC,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)(Js,{asChild:!0,...r})})},`SelectPortal`),xC=`SelectContent`,SC=O.forwardRef(YS(function(e,t){let n=yC(xC,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=cC(xC,e.__scopeSelect),[o,s]=O.useState();return yi(()=>{s(new DocumentFragment)},[]),(0,W.jsx)(Qs,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(OC,{...i,ref:t}):(0,W.jsx)(CC,{...i,fragment:o})})},`SelectContent`)),CC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Zr.createPortal((0,W.jsx)(TC,{scope:n,children:(0,W.jsx)(tC.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),wC=10,[TC,EC]=iC(xC),DC=ei(`SelectContent.RemoveScroll`),OC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n}=e,{position:r=XS.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=cC(xC,n),[y,b]=O.useState(null),[x,S]=O.useState(null),C=Wr(t,b),[w,T]=O.useState(null),[E,D]=O.useState(null),k=nC(n),[A,j]=O.useState(!1),M=O.useRef(!1),N=O.useRef(!1),P=O.useRef(!1);O.useEffect(()=>{if(y)return zx(y)},[y]),kx();let F=O.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,x]),I=O.useCallback(()=>F([w,y]),[F,w,y]);O.useEffect(()=>{A&&I()},[A,I]);let{onOpenChange:L,triggerPointerDownPosRef:ee}=v;O.useEffect(()=>{if(y){let e={x:0,y:0},t=YS(t=>{e={x:Math.abs(Math.round(t.pageX)-(ee.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ee.current?.y??0))}},`handlePointerMove`),n=YS(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||L(!1),document.removeEventListener(`pointermove`,t),ee.current=null},`handlePointerUp`);return ee.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,L,ee]),O.useEffect(()=>{let e=YS(()=>L(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[L]);let[te,R]=ew(e=>{let t=k().filter(e=>!e.disabled),n=tw(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ne=O.useCallback((e,t,n)=>{let r=!N.current;r&&(N.current=!0);let i=!M.current&&!n;v.value!==void 0&&v.value===t||i?(T(e),i&&(M.current=!0)):r&&T(e)},[v.value]),re=O.useCallback(()=>y?.focus(),[y]),ie=O.useCallback((e,t,n)=>{if(!e)return;let r=!P.current;r&&(P.current=!0);let i=!M.current&&!n;(v.value!==void 0&&v.value===t||i||r)&&D(e)},[v.value]),ae=r===XS.Popper?AC:kC,oe=ae===AC?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,W.jsx)(TC,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ne,selectedItem:w,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:I,selectedItemText:E,position:r,isPositioned:A,searchRef:te,children:(0,W.jsx)(qS,{as:DC,allowPinchZoom:!0,children:(0,W.jsx)(Ui,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:Fr(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,W.jsx)(ae,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...oe,onPlaced:()=>j(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:Fr(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&R(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>F(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),kC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=cC(xC,n),o=EC(xC,n),[s,c]=O.useState(null),[l,u]=O.useState(null),d=Wr(t,u),f=nC(n),p=O.useRef(!1),m=O.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=O.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==ZS.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-wC,d=ix(a,[wC,Math.max(wC,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-wC,d=ix(a,[wC,Math.max(wC,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-wC*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-wC,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${wC}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);yi(()=>y(),[y]);let[b,x]=O.useState();yi(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]);let S=O.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,W.jsx)(jC,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,W.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,W.jsx)(_i.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),AC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=wC,...a}=e,o=oC(n);return(0,W.jsx)(Bs,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[jC,MC]=iC(xC,{}),NC=`SelectViewport`,PC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=EC(NC,n),o=MC(NC,n),s=Wr(t,a.onViewportChange),c=O.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(tC.Slot,{scope:n,children:(0,W.jsx)(_i.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:Fr(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-wC*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[FC,IC]=iC(`SelectGroup`),LC=`SelectItem`,[RC,zC]=iC(LC),BC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=cC(LC,n),c=EC(LC,n),l=s.value===r,[u,d]=O.useState(a??``),[f,p]=O.useState(!1),m=Wr(t,Ci(e=>c.itemRefCallback?.(e,r,i))),h=ca(),g=O.useRef(`touch`);function _(e){s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),s.onUserSelect(r),s.onOpenChange(!1)}return YS(_,`handleSelect`),(0,W.jsx)(RC,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:O.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(tC.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,W.jsx)(_i.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:Fr(o.onFocus,()=>p(!0)),onBlur:Fr(o.onBlur,()=>p(!1)),onClick:Fr(o.onClick,e=>{i||g.current!==`mouse`&&_(e)}),onPointerUp:Fr(o.onPointerUp,e=>{i||g.current===`mouse`&&_(e)}),onPointerDown:Fr(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:Fr(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Fr(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Fr(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&($S.includes(e.key)&&_(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),VC=`SelectItemText`,HC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=cC(VC,n),s=EC(VC,n),c=zC(VC,n),l=uC(VC,n),[u,d]=O.useState(null),f=Ci(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=Wr(t,d,c.onItemTextChange,f),m=u?.textContent,h=O.useMemo(()=>(0,W.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return yi(()=>(g(h),()=>_(h)),[g,_,h]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_i.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$C(o.value)?Zr.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),UC=`SelectItemIndicator`,WC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,...r}=e;return zC(UC,n).isSelected?(0,W.jsx)(_i.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),GC=`SelectScrollUpButton`,KC=O.forwardRef(YS(function(e,t){let n=EC(GC,e.__scopeSelect),r=MC(GC,e.__scopeSelect),[i,a]=O.useState(!1),o=Wr(t,r.onScrollButtonChange);return yi(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};YS(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(YC,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),qC=`SelectScrollDownButton`,JC=O.forwardRef(YS(function(e,t){let n=EC(qC,e.__scopeSelect),r=MC(qC,e.__scopeSelect),[i,a]=O.useState(!1),o=Wr(t,r.onScrollButtonChange);return yi(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};YS(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(YC,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),YC=O.forwardRef(YS(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=EC(`SelectScrollButton`,n),o=O.useRef(null),s=nC(n),c=O.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return O.useEffect(()=>()=>c(),[c]),yi(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,W.jsx)(_i.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Fr(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Fr(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Fr(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),XC=`SelectBubbleInput`,ZC=O.forwardRef(YS(function({__scopeSelect:e,...t},n){let r=cC(XC,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u,userSelection:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=O.useRef(null),h=Wr(n,m),g=i??``,_=O.useRef(g),v=O.useRef(d),y=O.useRef(!1),b=Array.from(f).some(e=>(e.props.value??``)===``);return O.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=d!==null&&d!==v.current;v.current=d;let i=_.current!==g;_.current=g;let a=r&&i;if(r&&!i&&d.value!==g&&!d.hasConsumerStoppedPropagation&&n){y.current=!0;try{n.call(e,d.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{y.current=!1,n.call(e,g)}return}let o=a&&!d.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,g),e.dispatchEvent(t)}},[g,d]),(0,W.jsxs)(_i.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>{y.current||a(e.target.value)},...t,style:{...yc,...t.style},ref:h,defaultValue:g,children:[$C(i)&&!b?(0,W.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function QC(e){return typeof e==`function`}YS(QC,`isFunction`);function $C(e){return e===``||e===void 0}YS($C,`shouldShowPlaceholder`);function ew(e){let t=Ci(e),n=O.useRef(``),r=O.useRef(0),i=O.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}YS(a,`updateSearch`),a(i)},[t]),a=O.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return O.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}YS(ew,`useTypeaheadSearch`);function tw(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=nw(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}YS(tw,`findNextItem`);function nw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}YS(nw,`wrapArray`);var rw=fC,iw=gC;function aw({className:e,children:t,...n}){return(0,W.jsxs)(mC,{"data-slot":`select-trigger`,className:wn(`select-trigger`,e),...n,children:[t,(0,W.jsx)(_C,{asChild:!0,children:(0,W.jsx)(R,{className:`select-chevron`,size:14})})]})}function ow({className:e,children:t,position:n=`popper`,align:r=`end`,sideOffset:i=6,collisionPadding:a=8,...o}){return(0,W.jsx)(bC,{children:(0,W.jsxs)(SC,{"data-slot":`select-content`,className:wn(`select-content`,e),position:n,align:r,sideOffset:i,collisionPadding:a,...o,children:[(0,W.jsx)(cw,{}),(0,W.jsx)(PC,{className:`select-viewport`,children:t}),(0,W.jsx)(lw,{})]})})}function sw({className:e,children:t,description:n,...r}){let i=(0,O.useId)();return(0,W.jsxs)(BC,{"data-slot":`select-item`,className:wn(`select-item`,e),"aria-describedby":n?i:void 0,...r,children:[(0,W.jsx)(HC,{children:t}),n&&(0,W.jsx)(`span`,{className:`select-item-description`,id:i,children:n}),(0,W.jsx)(`span`,{className:`select-item-indicator`,children:(0,W.jsx)(WC,{children:(0,W.jsx)(ee,{size:14})})})]})}function cw({className:e,...t}){return(0,W.jsx)(KC,{className:wn(`select-scroll-button`,e),...t,children:(0,W.jsx)(re,{size:14})})}function lw({className:e,...t}){return(0,W.jsx)(JC,{className:wn(`select-scroll-button`,e),...t,children:(0,W.jsx)(R,{size:14})})}function uw({settings:e,current:t,unknown:n,disabled:r,scope:i,onChange:a}){let[o,s]=(0,O.useState)(!1);(0,O.useEffect)(()=>s(!1),[i,r]);let c=e.permissionMode??Ue(t)??``,l=e.permissionMode?Be[e.permissionMode].label:We(t,n);return(0,W.jsxs)(rw,{value:c,disabled:r,open:o,onOpenChange:s,onValueChange:n=>{let r=n;r in Be&&!Ve(r,t?.permissionCapabilities,e.model??t?.model)&&a(Ge(e,t,r))},children:[(0,W.jsx)(ol,{content:`权限模式:${l}${e.permissionMode?`(待生效)`:``}`,suppressed:o,children:(0,W.jsxs)(aw,{className:`settings-policy`,"aria-label":`权限模式`,"data-value":c,children:[(0,W.jsx)(J,{name:`shield`,size:16}),(0,W.jsx)(`span`,{className:`permission-mode-label`,children:(0,W.jsx)(iw,{placeholder:n,children:l})}),e.permissionMode&&(0,W.jsx)(`span`,{className:`permission-pending-dot`,"aria-label":`待生效`})]})}),(0,W.jsxs)(ow,{className:`permission-mode-menu`,side:`top`,align:`start`,"aria-label":`权限模式`,children:[c===`custom`&&(0,W.jsxs)(sw,{value:`custom`,disabled:!0,children:[l,`(保留当前配置)`]}),Object.keys(Be).map(n=>{let r=Be[n],i=Ve(n,t?.permissionCapabilities,e.model??t?.model);return(0,W.jsx)(sw,{value:n,textValue:r.label,disabled:!!i,description:(0,W.jsxs)(`span`,{className:`permission-description`,children:[(0,W.jsx)(`span`,{children:r.description}),i&&(0,W.jsx)(`span`,{className:`permission-unavailable`,children:i})]}),children:(0,W.jsx)(`strong`,{children:r.label})},n)})]})]})}var dw={"read-only":`只读`,"workspace-write":`项目内写入`,"danger-full-access":`完全访问`,"external-sandbox":`外部沙箱`},fw={untrusted:`不可信操作需审批`,"on-request":`由 Codex 请求审批`,never:`不请求审批`,granular:`自定义审批规则`};function pw({current:e,source:t,settings:n,thread:r,unknown:i}){let a=n.permissionMode,o=a&&Ve(a,e?.permissionCapabilities,n.model??e?.model);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`settings-heading`,children:[(0,W.jsx)(`strong`,{children:`权限详情`}),(0,W.jsx)(`span`,{children:t})]}),(0,W.jsxs)(`p`,{className:`settings-note`,children:[`当前模式:`,We(e,i),a&&`;待生效:${Be[a].label}`]}),(0,W.jsxs)(`dl`,{className:`permission-values`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`权限范围`}),(0,W.jsx)(`dd`,{children:dw[e?.sandbox??``]??i})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`审批策略`}),(0,W.jsx)(`dd`,{children:fw[e?.approvalPolicy??``]??i})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`权限 profile`}),(0,W.jsxs)(`dd`,{children:[e?.permissionProfile?.id??`未报告`,e?.permissionProfile?.extends&&`(继承 ${e.permissionProfile.extends})`]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`可写目录`}),(0,W.jsx)(`dd`,{children:e?.sandbox===`danger-full-access`?`无 Codex 沙箱限制`:e?.sandbox===`read-only`?`写入需额外批准`:e?.writableRoots?[`项目目录`,...e.writableRoots].join(`、`):`未报告`})]}),e?.sandbox===`workspace-write`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`临时目录`}),(0,W.jsxs)(`dd`,{children:[`TMPDIR:`,e.excludeTmpdirEnvVar==null?`未报告`:e.excludeTmpdirEnvVar?`排除`:`允许`,`;/tmp:`,e.excludeSlashTmp==null?`未报告`:e.excludeSlashTmp?`排除`:`允许`]})]})]}),(0,W.jsxs)(`p`,{className:`settings-observed`,children:[`当前网络权限:`,e?.networkAccess==null?`未报告`:e.networkAccess?`允许`:`受限`,(0,W.jsxs)(`span`,{children:[`审批执行方:`,e?.approvalReviewer??`未报告`]})]}),(0,W.jsxs)(`p`,{className:`settings-note`,children:[`修改仅用于此`,r?`会话的后续操作`:`项目的新会话`,`,`,r?`下次任务开始时`:`新建会话时`,`请求应用,以 Codex 确认为准,不更改全局配置。`]}),(!e?.permissionMode||e.permissionMode===`custom`)&&(0,W.jsx)(`p`,{className:`settings-note`,children:`保留实际配置;尚未选择其他模式时不会改写权限。`}),o&&(0,W.jsxs)(`p`,{className:`settings-error`,role:`status`,children:[`待生效选择目前不可用:`,o]})]})}var mw=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`,`ultra`];function hw({effort:e}){let t=mw.indexOf(e),n=t<0?void 0:t/(mw.length-1),r=Math.PI*(1+(n??0));return(0,W.jsxs)(`svg`,{className:`reasoning-gauge`,"data-effort":e,"data-progress":n,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{d:`M3 15a9 9 0 0 1 18 0`,stroke:`currentColor`,strokeOpacity:`0.18`,strokeWidth:`2.5`,strokeLinecap:`round`}),n===void 0?(0,W.jsx)(`text`,{x:`12`,y:`17`,textAnchor:`middle`,fontSize:`10`,fill:`currentColor`,children:`?`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{d:`M3 15a9 9 0 0 1 18 0`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeDasharray:`${n*100} 100`}),(0,W.jsx)(`path`,{d:`M12 15L${12+Math.cos(r)*6} ${15+Math.sin(r)*6}`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`}),(0,W.jsx)(`circle`,{cx:`12`,cy:`15`,r:`2`,fill:`currentColor`})]})]})}function gw({settings:e,projectName:t,children:n,models:r,thread:i,projectId:a,runtimeKey:o,disabled:s,threadLoading:c,onChange:l,onSaveModelDefaults:u,savingModelDefaults:d}){let[f,p]=(0,O.useState)(!1),[m,h]=(0,O.useState)(!1),[g,_]=(0,O.useState)(!1),v=(0,O.useId)(),y=(0,O.useId)(),b=(0,O.useId)(),x=JSON.stringify([a,i?.id]),[S,C]=(0,O.useState)(),w=S?.scope===x?S:void 0,T=d||w?.state===`saving`;(0,O.useEffect)(()=>{h(!1),_(!1)},[s,i?.id,a]),(0,O.useEffect)(()=>p(!1),[i?.id,a]);let E=tx(i?.managed||c?void 0:a,o),D=i?i.runtimeSettings:E.value,k=D?.permissionCapabilities||i?.managed?D:{...D,model:D?.model??null,reasoningEffort:D?.reasoningEffort??null,permissionCapabilities:E.value?.permissionCapabilities},A=c||E.loading&&!i?`读取中…`:`未报告`,j=e.model??D?.model??``,M=e.reasoningEffort??D?.reasoningEffort??``,N=M===`max`?`Max`:M===`ultra`?`Ultra`:null,P=e.serviceTier===void 0?D?.serviceTier:e.serviceTier,F=P===`fast`,I=r.find(e=>e.id===j),L=I?.serviceTiers?.includes(`fast`),ee=Ke(e,D),te=Object.keys(ee).length>0,R=i?i.managed?`会话当前配置`:`会话保存配置`:`新会话默认配置`;async function ne(e){C({scope:x,settings:e,state:`saving`});try{let t=await u(e);C({scope:x,settings:e,state:t?.status===`ok`?`saved`:t?.status===`okOverridden`?`overridden`:`error`})}catch{C({scope:x,settings:e,state:`error`})}}return(0,W.jsxs)(`div`,{className:`settings-panel`,role:`group`,"aria-label":`运行设置`,children:[te&&(0,W.jsxs)(`div`,{className:`settings-pending`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[i?i.managed?`下次任务生效`:`恢复后发送或 Fork 时生效`:`新建会话时生效`,` `,`· 当前 `,D?.model??`未报告`,` / `,D?.reasoningEffort??`未报告`,ee.serviceTier!==void 0&&` · 速度待生效:${Ye(ee.serviceTier)};当前:${Ye(D?.serviceTier,A)}`,ee.permissionMode&&` · 权限待生效:${Be[ee.permissionMode].label};当前:${We(D)}`]}),(0,W.jsx)(`button`,{type:`button`,disabled:s||T,onClick:()=>{l({}),w?.state===`error`&&C(void 0)},children:i&&(ee.model!==void 0||ee.reasoningEffort!==void 0)?`撤销本会话修改`:`撤销修改`})]}),w&&(0,W.jsxs)(`p`,{className:`settings-defaults`,"data-state":w.state,role:`status`,children:[w.state===`saving`?`正在保存模型和推理强度默认值…`:w.state===`saved`?`已保存为 Codex 新会话默认值`:w.state===`overridden`?`默认值已保存,但被更高优先级配置覆盖;新会话以实际配置为准。`:`未能确认默认值已保存。当前会话的待生效选择仍保留,请查看提交核对结果。`,w.state===`error`&&(0,W.jsx)(`button`,{type:`button`,disabled:s||T,onClick:()=>void ne(w.settings),children:`重新保存默认值`})]}),!i&&E.error&&(0,W.jsxs)(`p`,{className:`settings-error`,role:`status`,children:[E.error,` `,(0,W.jsx)(`button`,{type:`button`,onClick:E.retry,children:`重试`})]}),f&&(0,W.jsx)(`div`,{className:`settings-fields`,id:v,children:(0,W.jsx)(pw,{current:k,source:R,settings:ee,thread:!!i,unknown:A})}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsxs)(`div`,{className:`composer-context`,children:[(0,W.jsx)(ol,{asChild:!0,content:t??`未选择项目`,children:(0,W.jsxs)(`span`,{className:`composer-target`,children:[(0,W.jsx)(J,{name:`folder`,size:14}),(0,W.jsx)(`span`,{children:t??`未选择项目`})]})}),(0,W.jsx)(uw,{settings:ee,current:k,unknown:A,disabled:s||!!c,scope:`${a}:${i?.id??``}:${o}`,onChange:l}),(0,W.jsx)(ol,{asChild:!0,content:`权限详情`,children:(0,W.jsx)(`button`,{className:`settings-details-toggle`,type:`button`,"aria-label":`权限详情`,"aria-expanded":f,"aria-controls":v,onClick:()=>p(!f),children:(0,W.jsx)(J,{name:`settings`,size:14})})})]}),(0,W.jsxs)(`div`,{className:`composer-send-controls`,children:[(0,W.jsxs)(rw,{value:j,disabled:s||!r.length,open:m,onOpenChange:e=>{(!T||!e)&&h(e)},onValueChange:t=>{if(T)return;let n=r.find(e=>e.id===t);n&&(l(Je(e,D,n)),ne(qe(e,D,n)))},children:[(0,W.jsx)(ol,{content:`模型:${j||A}`,suppressed:m,children:(0,W.jsx)(aw,{className:`settings-choice settings-model`,"aria-label":`模型`,"aria-disabled":T||void 0,"data-value":j,children:(0,W.jsx)(`span`,{className:`settings-model-value`,children:(0,W.jsx)(iw,{placeholder:A,children:j||A})})})}),(0,W.jsxs)(ow,{side:`top`,"aria-label":`模型`,children:[j&&!I&&(0,W.jsx)(sw,{value:j,disabled:!0,children:j}),r.map(e=>(0,W.jsx)(sw,{value:e.id,children:e.id},e.id))]})]}),(0,W.jsxs)(rw,{value:M,disabled:s||!I?.reasoningEfforts.length,open:g,onOpenChange:e=>{(!T||!e)&&_(e)},onValueChange:t=>{T||(l(Ke({...e,reasoningEffort:t},D)),ne({model:j,reasoningEffort:t}))},children:[(0,W.jsx)(ol,{id:y,suppressed:g,content:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`span`,{children:[`推理强度:`,M||A]}),ee.reasoningEffort!==void 0&&(0,W.jsxs)(`span`,{children:[`待应用 · 当前 `,D?.reasoningEffort??A]})]}),children:(0,W.jsxs)(aw,{className:`settings-choice settings-effort reasoning-tier`,"aria-label":`推理强度`,"aria-disabled":T||void 0,"aria-describedby":y,"data-value":M,"data-effort":M,children:[(0,W.jsxs)(`span`,{className:`reasoning-effort-display`,"aria-hidden":`true`,children:[(0,W.jsx)(hw,{effort:M}),N&&(0,W.jsx)(`span`,{className:`reasoning-tier-label`,children:N})]},M),(0,W.jsx)(`span`,{className:`sr-only`,children:(0,W.jsx)(iw,{placeholder:A,children:M||A})})]})}),(0,W.jsxs)(ow,{side:`top`,"aria-label":`推理强度`,children:[M&&!I?.reasoningEfforts.includes(M)&&(0,W.jsx)(sw,{value:M,disabled:!0,className:`reasoning-tier`,"data-effort":M,children:M}),I?.reasoningEfforts.map(e=>(0,W.jsx)(sw,{value:e,className:`reasoning-tier`,"data-effort":e,children:e},e))]})]}),(0,W.jsx)(ol,{id:b,content:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:Ye(P,A)}),(0,W.jsx)(`span`,{children:F?`点击关闭 Fast`:L?`点击开启 Fast · 更快响应,增加用量`:`当前模型未提供 Fast`}),ee.serviceTier!==void 0&&(0,W.jsxs)(`span`,{children:[`待应用 · 当前 `,Ye(D?.serviceTier,A)]})]}),children:(0,W.jsx)(`button`,{type:`button`,className:`settings-choice settings-speed`,"aria-label":`Fast 模式`,"aria-describedby":b,"aria-pressed":P===void 0?`mixed`:F,disabled:s||!!c||!F&&!L,"data-fast":F,"data-pending":ee.serviceTier!==void 0,onClick:()=>l(Ke({...e,serviceTier:F?null:`fast`},D)),children:(0,W.jsx)(Oe,{size:18,strokeWidth:1.7,fill:F?`currentColor`:`none`,"aria-hidden":`true`})})}),n]})]})]})}function _w({id:e,commands:t,selectedIndex:n,onSelect:r,onExecute:i}){let a=(0,O.useRef)(null);return(0,O.useEffect)(()=>{a.current?.scrollIntoView({block:`nearest`})},[n,t[n]?.name]),(0,W.jsxs)(`div`,{className:`slash-menu`,children:[(0,W.jsxs)(`div`,{className:`slash-menu-heading`,children:[`会话命令 `,(0,W.jsx)(`span`,{children:`作用于当前项目与会话`})]}),(0,W.jsx)(`div`,{id:e,role:`listbox`,"aria-label":`Slash 命令`,className:`slash-options`,children:t.map((t,o)=>(0,W.jsxs)(`button`,{id:`${e}-${t.name}`,ref:o===n?a:void 0,type:`button`,role:`option`,tabIndex:-1,"aria-selected":o===n,"aria-disabled":!!t.unavailableReason,className:`slash-option`,onPointerDown:e=>e.preventDefault(),onPointerMove:e=>{e.pointerType===`mouse`&&r(o)},onClick:()=>i(t),children:[(0,W.jsxs)(`span`,{className:`slash-option-title`,children:[(0,W.jsxs)(`strong`,{children:[`/`,t.name]}),(0,W.jsx)(`span`,{children:t.usage})]}),(0,W.jsx)(`span`,{children:t.description}),t.unavailableReason&&(0,W.jsx)(`span`,{className:`slash-unavailable`,children:t.unavailableReason})]},t.name))}),t.length===0&&(0,W.jsx)(`p`,{className:`slash-empty`,role:`status`,children:`没有匹配的命令。输入 /help 查看支持范围。`}),(0,W.jsx)(`div`,{className:`slash-menu-footer`,children:`↑ ↓ 选择 · Enter 执行 · Esc 关闭`})]})}function vw(e){let t=e.trimStart();if(!t.startsWith(`/`)||t.startsWith(`//`))return null;let n=/^\/([^\s]*)(?:\s+([\s\S]*))?$/.exec(t);return{name:n[1].toLowerCase(),arguments:(n[2]??``).trim()}}function yw(e,t){let n=vw(t);if(!n)return[];if(n.arguments)return e.filter(e=>e.name===n.name);let r=e=>e.name===n.name?0:e.name.startsWith(n.name)?1:2;return e.filter(e=>e.name.includes(n.name)||e.description.toLowerCase().includes(n.name)).sort((e,t)=>r(e)-r(t))}function bw(e,t){let n=vw(e);if(!n)return;let r=t.find(e=>e.name===n.name);if(!r)return n.name?`未知命令 /${n.name}。使用 /help 查看可用命令;发送以 / 开头的普通消息请使用 //。`:`请选择命令,或输入 /help 查看可用命令。`;if(r.name===`rename`){let e=Xe(n.arguments);if(e)return e}else if(n.arguments)return`/${r.name} 不接受参数。用法:${r.usage}`;return r.unavailableReason}var xw=[{name:`help`,description:`查看本网页支持的命令和使用方式`},{name:`new`,description:`打开当前项目的新建会话输入页`},{name:`fork`,description:`复制当前会话已保存的历史为新会话`},{name:`resume`,description:`恢复当前选中的历史会话(不是 CLI 会话选择器)`},{name:`review`,description:`审查当前项目的未提交改动(使用会话当前配置)`},{name:`rename`,description:`重命名当前会话,名称可包含空格`},{name:`stop`,description:`请求中断当前任务(网页快捷命令)`},{name:`status`,description:`打开当前连接、运行状态与提交诊断`},{name:`compact`,description:`压缩当前会话上下文,保留会话继续工作`},{name:`export`,description:`下载当前会话的已保存记录为 Markdown 文件`}];function Sw(e,t){if(e===`help`||e===`status`)return;if(t.authRequired||t.connection===`authenticationRequired`)return`登录已过期,请重新登录后重试。`;if(t.connection!==`connected`)return`当前已离线,请等待连接恢复后重试。`;if(t.system?.authenticated===!1)return`Codex 尚未登录,请先完成认证。`;if(!t.system?.ready)return`Codex 尚不可用,请先查看状态诊断。`;if(e===`export`)return t.thread?t.system.capabilities.includes(`thread/read`)?void 0:`当前 Codex 未提供 thread/read 能力。`:t.selectedId?`会话正在加载,请稍后重试。`:`请先选择一个会话。`;if(e!==`stop`&&Hn(t.system))return`请先确认当前 Codex 版本的兼容性提示。`;let n={fork:`thread/fork`,resume:`thread/resume`,review:`review/start`,rename:`thread/name/set`,stop:`turn/interrupt`,compact:`thread/compact/start`};if(e!==`new`&&!t.system.capabilities.includes(n[e]))return`当前 Codex 未提供 ${n[e]} 能力。`;let r=(e,n)=>t.busy.includes(`${e}:${n}`),i=(e,n)=>t.operations.some(t=>(!n||t.kind===n)&&Fn(t,e));if(e!==`stop`){if(!t.project)return`请先选择一个项目。`;if(!t.project.available)return`当前项目目录不可用,请先检查项目配置。`}if(e===`new`)return t.busy.some(e=>e.startsWith(`saveModelDefaults:`))?`正在保存模型默认值,请完成后再操作。`:r(`create`,t.project.id)?`正在新建会话,请等待回执。`:i(t.project.id)?`新建会话的请求尚未确认,请先用 /status 核对提交。`:void 0;let a=t.thread;if(!a)return t.selectedId?`会话正在加载,请稍后重试。`:`请先选择一个会话。`;if(e===`compact`)return a.archived?`请先取消归档后再压缩上下文。`:a.managed?a.turns.length?r(`compact`,a.id)?`压缩请求正在提交,请等待回执。`:kl(a.status)||a.turns.some(e=>kl(e.status))?`请等待当前任务结束后再压缩上下文。`:a.status===`unknown`||a.execution&&!a.execution.ended||i(a.id)?`当前会话仍有待核对的执行,请先用 /status 核对提交。`:void 0:`当前会话为空,无需压缩上下文。`:`请先恢复当前会话,再压缩上下文。`;if(e===`review`)return a.archived?`会话已归档,请先取消归档。`:a.managed?r(`review`,a.id)?`正在提交代码审查,请等待回执。`:i(a.id)||a.status===`unknown`?`当前会话有尚未确认的请求,请先用 /status 核对提交。`:kl(a.status)||a.turns.some(e=>kl(e.status))?`当前会话仍在运行,请等待任务结束后开始代码审查。`:a.execution&&!a.execution.ended?`当前会话仍有执行占用,请先用 /status 核对旧任务。`:void 0:`会话尚未恢复,请先恢复后开始代码审查。`;if(e===`rename`)return a.archived?`请先取消归档并恢复会话后再重命名。`:a.managed?r(`rename`,a.id)?`正在重命名,请等待回执。`:i(a.id,`rename`)?`重命名请求尚未确认,请先用 /status 核对提交。`:r(`archive`,a.id)||i(a.id,`archive`)?`会话归档操作尚未确认,请先用 /status 核对提交。`:void 0:`请先恢复当前会话后再重命名;不能修改其他进程占用的会话。`;if(e===`fork`)return a.turns.length?r(`fork`,a.id)?`正在 Fork 会话,请等待回执。`:i(a.id,`fork`)?`Fork 请求尚未确认,请先用 /status 核对提交。`:void 0:`当前会话为空,发送首条消息后才能 Fork 已保存的历史。`;if(e===`resume`)return r(`resume`,a.id)?`正在恢复会话,请等待回执。`:i(a.id)?`当前会话有尚未确认的请求,请先用 /status 核对提交。`:a.managed&&(a.turns.some(e=>kl(e.status))||kl(a.status))?`当前会话仍在运行,请等待任务结束或使用 /stop。`:a.execution&&!a.execution.ended?`当前会话仍有执行占用,请先用 /status 核对旧任务。`:a.managed?`当前会话已恢复,无需再次恢复。`:void 0;if(!a.managed)return a.resumeError?.code===`THREAD_IN_USE`?`当前会话被其他进程占用,无法从网页中断该进程的任务。`:`当前会话尚未恢复,无法从网页中断其他进程的任务。`;if(r(`interrupt`,a.id))return`中断请求正在提交,请等待回执。`;if(i(a.id,`interrupt`))return`中断请求尚未确认,请先用 /status 核对提交。`;if(!a.turns.some(e=>kl(e.status)))return a.status===`unknown`||a.execution&&!a.execution.ended?`任务状态尚未确认,请先用 /status 核对提交。`:`当前会话没有可中断的任务。`}function Cw(e,t){if(!t)return{error:!0,message:`未收到可确认的成功回执。请查看页面错误或用 /status 核对提交;输入已保留。`};if(t.status===`failed`)return{error:!0,message:t.error?.message??`操作失败,请查看状态诊断。`};if(t.status!==`acknowledged`)return{error:!0,message:`提交结果尚未确认,请先用 /status 核对提交,不要重复提交。`};if(e===`compact`)return{message:`已提交上下文压缩请求;进度和结果以会话中的任务状态为准。`};if(e===`rename`){let e=t.result;return typeof e?.name==`string`&&e.name?{message:`会话已重命名为「${e.name}」。`}:{error:!0,message:`重命名已被接受,但无法确认名称,请用 /status 核对提交。`}}if(e===`fork`){let e=t.result,n=e?.threadId??e?.thread?.id;return typeof n!=`string`||!n?{error:!0,message:`请求已被接受,但尚未获得新会话标识,请用 /status 核对提交。`}:{message:`已 Fork 为新会话。`,draftKey:n}}return{message:e===`review`?`已提交代码审查,请在当前会话查看进度和结果。`:e===`stop`?`已提交中断请求,请等待任务状态更新。`:`已恢复当前选中的会话。`}}function ww(e){let t=e();return xw.map(({name:n,description:r})=>({name:n,description:r,usage:n===`rename`?`/rename <名称>`:`/${n}(无需参数)`,unavailableReason:Sw(n,t),run:async(r=``)=>{let i=e();if(n===`help`)return{message:`${xw.map(e=>`/${e.name}${e.name===`rename`?` <名称>`:``}:${e.description}`).join(`
|
|
83
|
+
`)}\n/rename 必须提供名称,其他命令无需参数。输入 // 可发送以 / 开头的普通消息。`};if(n===`status`)return i.openStatus(),{message:`已打开状态诊断;可在面板中刷新或核对提交。`};if(i.project?.id!==t.project?.id||i.selectedId!==t.selectedId)return{error:!0,message:`当前项目或会话已切换,请重新选择命令。`};let a=Sw(n,i);if(a)return{error:!0,message:a};if(n===`rename`){let e=Xe(r);if(e)return{error:!0,message:e}}let o=i.thread,s=`/api/threads/${encodeURIComponent(o?.id??``)}`;try{if(n===`export`){let{partial:e}=await i.exportThread(o.id);return{message:e?`已发起 Markdown 下载;存在未完成、状态待确认或截断内容,请查看文件内说明。`:`已发起已保存历史的 Markdown 下载。图片和内部记录的省略范围已在文件中说明。`}}let e;if(n===`new`)return{draftKey:i.openDraft(),message:`已打开新会话输入页,发送首条消息时创建会话。`};if(n===`fork`)e=await i.run(`fork`,o.id,`${s}/fork`,{settings:i.settings});else if(n===`review`)e=await i.run(`review`,o.id,`${s}/review`);else if(n===`rename`)e=await i.run(`rename`,o.id,`${s}/rename`,{name:r.trim()});else if(n===`resume`)i.onResumeAttempt(),e=await i.run(`resume`,o.id,`${s}/resume`),await i.refreshThread();else if(n===`compact`)e=await i.run(`compact`,o.id,`${s}/compact`);else{let t=o.turns.findLast(e=>kl(e.status));e=await i.run(`interrupt`,o.id,`${s}/interrupt`,{expectedTurnId:t.id})}return Cw(n,e)}catch(e){return{error:!0,message:En(e)}}}}))}function Tw({textareaRef:e,inputId:t}){let[n,r]=(0,O.useState)({min:93,max:230,height:93}),[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(n),s=(0,O.useRef)(null);function c(){s.current=null,a(!1),document.documentElement.classList.remove(`composer-resizing`)}function l(t){let n=e.current;if(!n)return;let i=Math.min(o.current.max,Math.max(o.current.min,t));n.style.height=`${i}px`,r(e=>({...e,height:i}))}return(0,O.useEffect)(()=>{let t=e.current,n=t?.closest(`.bottom-region`),i=n?.parentElement;if(!t||!n||!i)return;let a=0,s=()=>{let e=getComputedStyle(t),a=parseFloat(e.getPropertyValue(`--composer-min-height`)),s=parseFloat(e.getPropertyValue(`--composer-max-height`)),c=getComputedStyle(n).maxHeight,l=c.endsWith(`%`)?i.clientHeight*parseFloat(c)/100:parseFloat(c),u=i.querySelector(`.conversation-area`),d=Array.from(i.children).reduce((e,t)=>{let r=getComputedStyle(t);return t===n||r.position===`absolute`||r.position===`fixed`||r.display===`none`?e:e+(t===u?parseFloat(r.minHeight)||0:t.getBoundingClientRect().height)+(parseFloat(r.marginTop)||0)+(parseFloat(r.marginBottom)||0)},0),f=n.scrollHeight-t.getBoundingClientRect().height,p=window.visualViewport?.offsetTop??0,m=t.getBoundingClientRect().bottom-p-24,h=Math.max(a,Math.floor(Math.min(s,l-f,i.clientHeight-d-f,m)));t.style.setProperty(`--composer-available-height`,`${h}px`),t.style.height&&(t.style.height=`${Math.min(h,Math.max(a,parseFloat(t.style.height)))}px`);let g=t.getBoundingClientRect().height;o.current={min:a,max:h,height:g},r(e=>e.min===a&&e.max===h&&e.height===g?e:{min:a,max:h,height:g})};function l(){cancelAnimationFrame(a),a=requestAnimationFrame(s)}let u=new ResizeObserver(l);for(let e of[t,...i.children])u.observe(e);u.observe(i);let d=new MutationObserver(l);return d.observe(i,{childList:!0}),window.visualViewport?.addEventListener(`resize`,l),window.addEventListener(`blur`,c),s(),()=>{u.disconnect(),d.disconnect(),cancelAnimationFrame(a),window.visualViewport?.removeEventListener(`resize`,l),window.removeEventListener(`blur`,c),c()}},[e]),(0,W.jsx)(ol,{asChild:!0,suppressed:i,content:`向上拖动增高,向下拖动缩小;也可用方向键调整`,children:(0,W.jsx)(`button`,{type:`button`,className:`composer-resize-handle`,"data-resizing":i||void 0,role:`separator`,"aria-label":`调整输入框高度`,"aria-orientation":`horizontal`,"aria-controls":t,"aria-valuemin":Math.round(n.min),"aria-valuemax":Math.round(n.max),"aria-valuenow":Math.round(n.height),"aria-valuetext":`${Math.round(n.height)} 像素`,onPointerDown:t=>{t.isPrimary&&t.button===0&&e.current&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),s.current={pointerId:t.pointerId,y:t.clientY,height:e.current.getBoundingClientRect().height},document.documentElement.classList.add(`composer-resizing`),a(!0))},onPointerMove:e=>{s.current?.pointerId===e.pointerId&&(e.preventDefault(),l(s.current.height+s.current.y-e.clientY))},onPointerUp:e=>{s.current?.pointerId===e.pointerId&&(c(),e.currentTarget.releasePointerCapture(e.pointerId))},onPointerCancel:c,onLostPointerCapture:c,onKeyDown:t=>{let r=e.current?.getBoundingClientRect().height??n.height,i=t.shiftKey?40:10,a={ArrowUp:r+i,ArrowDown:r-i,Home:n.min,End:n.max}[t.key];a!==void 0&&(t.preventDefault(),l(a))},children:(0,W.jsx)(`svg`,{width:`32`,height:`32`,viewBox:`0 0 32 32`,fill:`none`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M21 3.5a7.5 7.5 0 0 1 7.5 7.5`})})})})}function Ew(e){let[t,n]=(0,O.useState)({}),r=(0,O.useRef)(t),i=(0,O.useId)(),a=(0,O.useRef)(!1);Cr(`composer`,()=>{if(a.current||Object.values(r.current).some(e=>e.images.some(e=>!e.dataUrl)))throw Error(`正在输入或读取图片,完成后会自动加载新版`);return r.current},e=>{r.current={...e,...r.current},n(r.current)});let o=(0,O.useRef)(-1/0),s=(0,O.useRef)(new Set),c=(0,O.useRef)(new Map),l=(0,O.useRef)(null),u=(0,O.useId)(),d=(0,O.useId)(),[f,p]=(0,O.useState)(!1),[m,h]=(0,O.useState)({key:``,text:``,selectedIndex:0,dismissed:!1}),[g,_]=(0,O.useState)({}),[v,y]=(0,O.useState)([]),b=e.draftKey,x=(0,O.useRef)(new WeakSet);(0,O.useEffect)(()=>{for(let t of Object.values(e.sentDrafts))x.current.has(t)||(x.current.add(t),c.current.get(t.key)?.text.replace(/^(\s*)\/\//,`$1/`)===t.text&&ee(t.key))},[e.sentDrafts]),(0,O.useEffect)(()=>{a.current=!1,o.current=-1/0,h({key:``,text:``,selectedIndex:0,dismissed:!1})},[b]);let S=t[b]??Qb,{text:C,images:w}=S,T=vw(C),E=yw(e.commands,C),D=m.key===b&&m.text===C?m:void 0,k=Math.min(D?.selectedIndex??0,Math.max(0,E.length-1)),A=!!(T&&f&&!D?.dismissed),j=A?E[k]:e.commands.find(e=>e.name===T?.name),M=v.includes(b);function N(e){h({key:b,text:C,selectedIndex:e,dismissed:!1})}function P(){h({key:b,text:C,selectedIndex:k,dismissed:!0})}async function F(t){if(s.current.has(b)||a.current)return;let n=r.current[b]??Qb,i=vw(n.text);if(!i)return;let o=t?`/${t.name}${i.arguments?` ${i.arguments}`:``}`:n.text,c=n.images.length?`Slash 命令不能附带图片。请先移除图片,或改为普通消息。`:bw(o,e.commands);if(c){_(e=>({...e,[b]:{message:c,error:!0}}));return}let l=e.commands.find(e=>e.name===vw(o)?.name);if(l){s.current.add(b),y(e=>[...e,b]),_(e=>({...e,[b]:{message:`正在执行 /${l.name}…`}})),P();try{let e=await l.run(vw(o)?.arguments);_(t=>({...t,[b]:e,[e.draftKey??b]:e})),e.error||L(b,e=>({...e,text:e.text===n.text?``:e.text}))}catch(e){_(t=>({...t,[b]:{error:!0,message:e instanceof Error?e.message:`命令执行失败,请重试。`}}))}finally{s.current.delete(b),y(e=>e.filter(e=>e!==b))}}}let I=w.some(e=>!e.dataUrl);function L(e,t){let i={...r.current,[e]:t(r.current[e]??Qb)};r.current=i,n(i)}function ee(e){let t=c.current.get(e);t&&(c.current.delete(e),L(e,e=>({text:e.text===t.text?``:e.text,images:e.images.filter(e=>!t.images.some(t=>t.id===e.id)),error:e.error===t.error?void 0:e.error})))}function te(e){if(e.defaultPrevented)return;let t=Array.from(e.clipboardData.files);if(!t.length)return;e.preventDefault();let n=$b(t,(r.current[b]??Qb).images);if(n){L(b,e=>({...e,error:n}));return}let i=t.map(e=>({id:crypto.randomUUID(),name:e.name||`粘贴的图片`,size:e.size})),a=e.clipboardData.getData(`text/plain`),o=e.currentTarget.selectionStart,s=e.currentTarget.selectionEnd;L(b,e=>({text:a?(e.text.slice(0,o)+a+e.text.slice(s)).slice(0,1e5):e.text,images:[...e.images,...i]})),t.forEach((e,t)=>{let n=i[t].id;ex(e).then(e=>L(b,t=>({...t,images:t.images.map(t=>t.id===n?{...t,dataUrl:e}:t)})),()=>L(b,e=>e.images.some(e=>e.id===n)?{...e,images:e.images.filter(e=>e.id!==n),error:`图片读取失败,请重新粘贴。`}:e))})}let R=!!(e.thread?.managed&&kl(e.thread.status)),ne=e.thread&&!e.thread.managed&&!e.thread.archived,re=ne?e.thread?.resumeError:void 0,ie=re?.code===`THREAD_IN_USE`,ae=!(!e.thread&&!e.projectId||e.threadLoading||ne||!C.trim()&&!w.length||I||e.disabled||e.submitting);async function oe(){if(T){await F(A?E[k]:void 0);return}if(!ae||s.current.has(b))return;let t=r.current[b]??Qb;if(!t.text.trim()&&!t.images.length||t.images.some(e=>!e.dataUrl))return;s.current.add(b),c.current.set(b,t);let n=t.text,i=t.images;try{await e.onSend(n.replace(/^(\s*)\/\//,`$1/`),R,i.length?i.map(e=>e.dataUrl):void 0)&&ee(b)}finally{s.current.delete(b)}}return(0,W.jsxs)(`div`,{className:`composer-region`,children:[e.submitting&&(0,W.jsxs)(`p`,{className:`composer-resume-status`,role:`status`,children:[(0,W.jsx)(J,{name:`refresh`,size:14}),e.thread?`正在提交消息…`:`正在创建会话并发送首条消息…`]}),ne&&e.resuming&&(0,W.jsxs)(`p`,{className:`composer-resume-status`,role:`status`,children:[(0,W.jsx)(J,{name:`refresh`,size:14}),`正在恢复会话…`]}),ne&&e.resumeAttempted&&!e.resuming&&!re&&e.canResume&&(0,W.jsx)(q,{size:`sm`,variant:`secondary`,onClick:e.onResume,children:`重试恢复`}),re&&!e.resuming&&(0,W.jsxs)(`div`,{className:`session-resume-notice`,role:`status`,children:[(0,W.jsx)(`strong`,{children:ie?`此会话正被其他进程使用`:`无法恢复会话`}),(0,W.jsx)(`p`,{children:ie?`可以 Fork 已保存的历史继续对话,或在原进程释放会话后重试。新会话使用同一项目目录。`:re.message}),ie&&(0,W.jsxs)(q,{size:`sm`,variant:`secondary`,disabled:!e.canFork,onClick:e.onFork,children:[(0,W.jsx)(J,{name:`fork`,size:14}),e.forking?`正在确认 Fork…`:`Fork 为新会话`]}),(0,W.jsx)(q,{size:`sm`,disabled:!e.canResume,onClick:e.onResume,children:`重试恢复`})]}),(0,W.jsxs)(`div`,{className:`composer-box`,children:[(0,W.jsx)(Tw,{textareaRef:l,inputId:u}),g[b]&&(0,W.jsx)(`p`,{className:`slash-feedback`,role:g[b].error?`alert`:`status`,children:g[b].message}),A&&(0,W.jsx)(_w,{id:d,commands:E,selectedIndex:k,onSelect:N,onExecute:e=>{l.current?.focus(),F(e)}}),w.length>0&&(0,W.jsx)(`ul`,{className:`composer-images`,"aria-label":`待发送的图片`,children:w.map((e,t)=>(0,W.jsxs)(`li`,{children:[e.dataUrl?(0,W.jsx)(`img`,{src:e.dataUrl,alt:`待发送的图片 ${t+1}`}):(0,W.jsx)(`span`,{role:`status`,children:`读取中…`}),(0,W.jsx)(ol,{asChild:!0,content:e.name,children:(0,W.jsx)(`span`,{className:`composer-image-name`,children:e.name})}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,"aria-label":`移除图片 ${t+1}`,onClick:()=>L(b,t=>({...t,error:void 0,images:t.images.filter(t=>t.id!==e.id)})),children:(0,W.jsx)(J,{name:`close`,size:13})})]},e.id))}),S.error&&(0,W.jsx)(`p`,{className:`composer-image-error`,role:`alert`,children:S.error}),(0,W.jsx)(`textarea`,{id:u,ref:l,"aria-label":R?`追加要求`:`任务内容`,"aria-haspopup":`listbox`,"aria-controls":A?d:void 0,"aria-autocomplete":`list`,"aria-activedescendant":A&&E[k]?`${d}-${E[k].name}`:void 0,value:C,readOnly:!!e.thread?.archived,placeholder:e.thread?.archived?`取消归档后可继续对话…`:R?`补充要求或调整方向…`:`描述任务、粘贴图片,或输入 / 查看命令…`,maxLength:1e5,onChange:e=>{L(b,t=>({...t,text:e.target.value})),h({key:b,text:e.target.value,selectedIndex:0,dismissed:!1}),_(e=>{let t={...e};return delete t[b],t})},onPaste:te,onFocus:()=>p(!0),onCompositionStart:()=>{a.current=!0},onCompositionEnd:()=>{a.current=!1,o.current=performance.now()},onBlur:()=>{p(!1),a.current=!1,o.current=-1/0},onKeyDown:e=>{if((!e.defaultPrevented||A&&e.key===`Escape`)&&!(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229||a.current)){if(performance.now()-o.current<100)e.key===`Enter`&&!e.shiftKey&&e.preventDefault();else{if(A&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),E.length&&N((k+(e.key===`ArrowDown`?1:-1)+E.length)%E.length);return}if(e.key===`Escape`){e.preventDefault(),P();return}}e.key!==`Enter`||e.shiftKey||(e.preventDefault(),!e.repeat&&oe())}}},onKeyUp:e=>{e.key===`Enter`&&(o.current=-1/0)},rows:3}),(0,W.jsxs)(gw,{settings:e.settings,projectName:e.projectName,models:e.models,onChange:e.onSettings,onSaveModelDefaults:e.onSaveModelDefaults,savingModelDefaults:e.savingModelDefaults,thread:e.thread,projectId:e.projectId,runtimeKey:e.runtimeKey,threadLoading:e.threadLoading,disabled:e.disabled||!!e.threadLoading||R||e.submitting||e.resuming||e.forking,children:[R&&(0,W.jsx)(ol,{content:`中断`,children:(0,W.jsxs)(q,{"aria-label":e.interrupting?`请求中…`:`中断`,variant:`secondary`,size:`sm`,onClick:e.onInterrupt,disabled:!e.canInterrupt||e.interrupting,children:[(0,W.jsx)(J,{name:`stop`,size:13}),(0,W.jsx)(`span`,{className:`composer-action-label`,children:e.interrupting?`请求中…`:`中断`})]})}),(0,W.jsx)(ol,{id:i,className:`composer-submit`,content:T?`Enter 执行命令 / Esc 关闭菜单`:`Enter 发送 / Shift + Enter 换行`,children:(0,W.jsxs)(q,{size:`sm`,"aria-label":T?M?`正在执行命令…`:`执行命令`:e.submitting?`正在提交…`:R?`追加要求`:`发送任务`,"aria-describedby":i,onPointerDown:e=>{T&&e.preventDefault()},onClick:()=>{oe()},disabled:T?M||!!j?.unavailableReason:!ae,children:[(0,W.jsx)(J,{name:`send`,size:14}),(0,W.jsx)(`span`,{className:`composer-action-label`,children:T?M?`正在执行…`:`执行命令`:e.submitting?`正在提交…`:R?`追加要求`:`发送任务`})]})})]})]}),(0,W.jsx)(`p`,{className:`composer-note`,children:R?`关闭页面不会停止任务。中断以 Codex 返回的实际状态为准。`:`Codex 使用服务器项目与权限执行,请核对操作和变更。`})]})}var Dw={read:`读取`,write:`写入`,deny:`禁止访问`};function Ow({request:e}){let t=e.fileSystem,n=[...t?.read.map(e=>({path:e,access:`read`}))??[],...t?.write.map(e=>({path:e,access:`write`}))??[],...t?.entries??[]];return(0,W.jsxs)(`div`,{className:`permission-details`,children:[e.network!==void 0&&(0,W.jsxs)(`div`,{className:`permission-network`,children:[(0,W.jsx)(`strong`,{children:`网络访问`}),(0,W.jsx)(`span`,{children:e.network===!0?`允许访问网络`:e.network===!1?`不开放额外网络访问`:`未指定网络访问变更`})]}),n.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{children:`文件与目录`}),(0,W.jsx)(`ul`,{className:`permission-paths`,children:n.map((e,t)=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`permission-access permission-access-${e.access}`,children:Dw[e.access]??e.access}),(0,W.jsx)(`code`,{children:e.path})]},`${e.access}-${e.path}-${t}`))})]}),t?.globScanMaxDepth!==void 0&&(0,W.jsxs)(`p`,{children:[`目录匹配搜索深度:`,t.globScanMaxDepth]}),e.network===void 0&&n.length===0&&(0,W.jsx)(`p`,{children:`未请求额外网络或文件访问权限。`})]})}var kw=class extends Error{code;status;details;constructor(e,t,n=400,r){super(t),this.code=e,this.status=n,this.details=r,this.name=`AppError`}toJSON(e){return{code:this.code,message:this.message,...e?{clientOperationId:e}:{},...this.details===void 0?{}:{details:this.details}}}},Aw=e=>{throw new kw(`VALIDATION_ERROR`,e)};function jw(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(`${e}T00:00:00.000Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e}function Mw(e,t){switch(e){case`email`:return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);case`uri`:try{return!/\s/.test(t)&&!!new URL(t).protocol}catch{return!1}case`date`:return jw(t);case`date-time`:{let e=/^(\d{4}-\d{2}-\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|[+-](\d{2}):(\d{2}))$/.exec(t);return!!(e&&jw(e[1])&&Number(e[2])<=23&&Number(e[3])<=59&&Number(e[4])<=59&&(e[5]===void 0||Number(e[5])<=23)&&(e[6]===void 0||Number(e[6])<=59)&&Number.isFinite(Date.parse(t)))}default:return!0}}function Nw(e,t){let n=()=>Aw(`“${e.title}”的回答不符合字段要求`);switch(e.type){case`string`:if(typeof t!=`string`)n();else{let r=[...t].length;(e.minLength!==void 0&&r<e.minLength||e.maxLength!==void 0&&r>e.maxLength||t.length>1e4||!Mw(e.format,t))&&n()}break;case`number`:case`integer`:(typeof t!=`number`||!Number.isFinite(t)||e.type===`integer`&&!Number.isSafeInteger(t)||e.minimum!==void 0&&t<e.minimum||e.maximum!==void 0&&t>e.maximum)&&n();break;case`boolean`:typeof t!=`boolean`&&n();break;case`enum`:(typeof t!=`string`||t.length>1e4||!e.options?.some(e=>e.value===t))&&n();break;case`multiEnum`:(!Array.isArray(t)||t.some(t=>typeof t!=`string`||t.length>1e4||!e.options?.some(e=>e.value===t))||t.length>500||new Set(t).size!==t.length||e.minItems!==void 0&&t.length<e.minItems||e.maxItems!==void 0&&t.length>e.maxItems)&&n()}}function Pw(e){switch(e){case`pending`:return`需要你处理`;case`responding`:return`正在提交…`;case`responded`:return`已处理`;case`expired`:return`请求已失效`}}function Fw(e){return Object.fromEntries(e.filter(e=>e.default!==void 0).map(e=>[e.name,typeof e.default==`number`?String(e.default):e.default]))}function Iw(e){let t=[];return e.type===`integer`&&t.push(`填写整数`),e.minimum!==void 0&&t.push(`最小 ${e.minimum}`),e.maximum!==void 0&&t.push(`最大 ${e.maximum}`),e.minLength!==void 0&&t.push(`至少 ${e.minLength} 个字符`),e.maxLength!==void 0&&t.push(`最多 ${e.maxLength} 个字符`),e.minItems!==void 0&&t.push(`至少选择 ${e.minItems} 项`),e.maxItems!==void 0&&t.push(`最多选择 ${e.maxItems} 项`),e.format===`date-time`&&t.push(`日期与时间需包含时区,例如 2026-10-14T12:30:00+08:00`),t.join(` · `)}function Lw(e,t){let n=Object.create(null),r=Object.create(null);for(let i of e){let e=Object.hasOwn(t,i.name)?t[i.name]:void 0;if(e===void 0||(i.type===`number`||i.type===`integer`)&&e===``){i.required&&(r[i.name]=`请填写此必填项。`);continue}let a=i.type===`number`||i.type===`integer`?Number(e):e;try{Nw(i,a),n[i.name]=a}catch(e){r[i.name]=e instanceof Error?e.message:`请检查此字段的填写要求。`}}return{content:n,errors:r}}function Rw(e){if(e)try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&!t.username&&!t.password?t.href:void 0}catch{return}}function zw({request:e,actionId:t,status:n,disabled:r,onResolve:i}){let a=e.fields??[],o=n===`pending`?e.approval?`允许本次`:e.mode===`url`?`我已完成`:a.length===0?`确认继续`:a.every(e=>[`boolean`,`enum`,`multiEnum`].includes(e.type))?`确认选择`:`提交回答`:Pw(n),[s,c]=(0,O.useState)(()=>Fw(a)),[l,u]=(0,O.useState)(!1),{content:d,errors:f}=Lw(a,s),p=Rw(e.url),m=e.schemaError||(e.mode===`url`&&!p?`此请求没有可安全打开的 HTTP 或 HTTPS 地址,无法确认完成。`:void 0),h=(e,t)=>c(n=>({...n,[e]:t}));return(0,W.jsxs)(`form`,{className:`elicitation-form`,noValidate:!0,onSubmit:t=>{t.preventDefault(),!(r||m)&&(u(!0),!(e.mode===`form`&&Object.keys(f).length>0)&&i(e.mode===`form`&&!e.approval?{decision:`accept`,content:d}:{decision:`accept`}))},children:[(0,W.jsxs)(`p`,{className:`elicitation-source`,children:[`来源:`,(0,W.jsx)(`strong`,{children:e.serverName})]}),e.approval?.allowSession&&(0,W.jsx)(`p`,{className:`elicitation-scope subtle`,children:`本会话允许仅适用于当前请求对应的工具或连接范围,并受审批策略约束;新会话需重新确认。`}),m&&(0,W.jsx)(`p`,{className:`elicitation-error`,role:`alert`,children:m}),e.mode===`url`?(0,W.jsxs)(`div`,{className:`elicitation-url`,children:[(0,W.jsx)(`span`,{children:`访问地址`}),(0,W.jsx)(`code`,{children:e.url??`未提供地址`}),p&&(0,W.jsx)(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,referrerPolicy:`no-referrer`,children:`在新标签页打开`}),(0,W.jsx)(`p`,{children:`完成页面中的操作后,点击“我已完成”继续。`})]}):!m&&(0,W.jsx)(`div`,{className:`elicitation-fields`,children:a.map((e,n)=>{let i=`elicitation-${t}-${n}`,a=Iw(e),o=l?f[e.name]:void 0,c=Object.hasOwn(s,e.name)?s[e.name]:void 0,u=[e.description&&`${i}-description`,a&&`${i}-hint`,o&&`${i}-error`].filter(Boolean).join(` `)||void 0;return(0,W.jsxs)(`div`,{className:`elicitation-field`,children:[(0,W.jsxs)(`div`,{className:`elicitation-field-heading`,children:[(0,W.jsxs)(`label`,{id:`${i}-label`,htmlFor:e.type===`multiEnum`?void 0:i,children:[e.title,(0,W.jsx)(`span`,{className:`field-necessity`,"aria-hidden":`true`,children:e.required?`必填`:`可选`})]}),!e.required&&c!==void 0&&(0,W.jsxs)(`button`,{type:`button`,className:`field-unset`,disabled:r,onClick:()=>h(e.name,void 0),children:[`不填写`,(0,W.jsx)(`span`,{className:`sr-only`,children:e.title})]})]}),e.description&&(0,W.jsx)(`p`,{id:`${i}-description`,className:`field-description`,children:e.description}),e.type===`boolean`||e.type===`enum`?(0,W.jsxs)(`select`,{id:i,className:`text-input`,value:c===void 0?``:e.type===`boolean`?c?`true`:`false`:`option:${String(c)}`,disabled:r,"aria-required":e.required,"aria-invalid":!!o,"aria-describedby":u,onChange:t=>h(e.name,t.target.value===``?void 0:e.type===`boolean`?t.target.value===`true`:t.target.value.slice(7)),children:[(0,W.jsx)(`option`,{value:``,children:`请选择`}),e.type===`boolean`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`option`,{value:`true`,children:`是`}),(0,W.jsx)(`option`,{value:`false`,children:`否`})]}):e.options?.map(e=>(0,W.jsx)(`option`,{value:`option:${e.value}`,children:e.label},e.value))]}):e.type===`multiEnum`?(0,W.jsx)(`div`,{role:`group`,"aria-labelledby":`${i}-label`,"aria-describedby":u,"aria-invalid":!!o,className:`elicitation-multi-options`,children:e.options?.map(t=>(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,disabled:r,checked:Array.isArray(c)&&c.includes(t.value),onChange:n=>{let r=Array.isArray(c)?c:[];h(e.name,n.target.checked?[...r,t.value]:r.filter(e=>e!==t.value))}}),(0,W.jsx)(`span`,{children:t.label})]},t.value))}):(0,W.jsx)(`input`,{id:i,className:`text-input`,type:e.type===`number`||e.type===`integer`?`number`:e.format===`email`?`email`:e.format===`uri`?`url`:e.format===`date`?`date`:`text`,value:typeof c==`string`?c:``,step:e.type===`integer`?1:`any`,min:e.minimum,max:e.maximum,disabled:r,"aria-required":e.required,"aria-invalid":!!o,"aria-describedby":u,placeholder:e.required?void 0:`未填写(可选)`,autoComplete:`off`,onChange:t=>h(e.name,t.target.value)}),a&&(0,W.jsx)(`p`,{id:`${i}-hint`,className:`field-hint`,children:a}),o&&(0,W.jsx)(`p`,{id:`${i}-error`,className:`elicitation-error`,role:`alert`,children:o})]},e.name)})}),l&&Object.keys(f).length>0&&!m&&(0,W.jsx)(`p`,{className:`elicitation-error`,role:`alert`,children:`请检查标出的字段后再提交。`}),(0,W.jsxs)(`div`,{className:`action-options`,children:[!m&&(0,W.jsx)(q,{type:`submit`,disabled:r,children:o}),!m&&e.approval?.allowSession&&(0,W.jsx)(q,{variant:`secondary`,disabled:r,onClick:()=>i({decision:`accept`,persist:`session`}),children:`本会话允许`}),(0,W.jsx)(q,{variant:`secondary`,disabled:r,onClick:()=>i({decision:`decline`}),children:`拒绝`}),(0,W.jsx)(q,{variant:`ghost`,disabled:r,onClick:()=>i({decision:`cancel`}),children:`取消`})]})]})}function Bw({action:e,disabled:t,onResolve:n}){let[r,i]=(0,O.useState)({}),[a,o]=(0,O.useState)({}),s=e.status===`pending`,c=e.questions??[],l=e=>r[e]===`__other__`?a[e]?.trim()??``:r[e]?.trim()??``,u=c.length>0&&c.every(e=>l(e.id)),d=c.length>0&&c.every(e=>e.options.length>0&&r[e.id]!==`__other__`);return(0,W.jsxs)(`section`,{className:`action-card${e.kind===`unsupported`?` action-card-unsupported`:``}`,"aria-label":e.title,children:[(0,W.jsxs)(`div`,{className:`action-heading`,children:[(0,W.jsx)(`span`,{className:`action-icon`,children:(0,W.jsx)(J,{name:e.kind===`questions`?`chat`:`alert`,size:17})}),(0,W.jsx)(`h3`,{children:e.title}),(0,W.jsx)(`span`,{className:`action-state`,children:e.kind===`unsupported`&&e.status===`expired`?`请求未能处理`:Pw(e.status)})]}),e.reason&&(0,W.jsx)(`p`,{children:e.reason}),e.cwd&&(0,W.jsxs)(`p`,{className:`mono subtle action-cwd`,children:[(0,W.jsx)(`span`,{children:`工作目录:`}),e.cwd]}),e.command&&(0,W.jsx)(`pre`,{className:`command`,children:(0,W.jsx)(`code`,{children:e.command})}),e.kind===`permissions`&&e.permissionRequest&&(0,W.jsx)(Ow,{request:e.permissionRequest}),e.details!==void 0&&(0,W.jsxs)(`details`,{className:`raw-details`,open:e.kind===`network`||e.kind===`file`||void 0,children:[(0,W.jsx)(`summary`,{children:e.kind===`network`?`网络访问目标`:e.kind===`file`?`变更详情`:e.kind===`permissions`||e.kind===`elicitation`?`技术详情`:`请求详情`}),(0,W.jsx)(`pre`,{children:JSON.stringify(e.details,null,2)})]}),e.kind===`elicitation`&&e.elicitation?(0,W.jsx)(zw,{request:e.elicitation,actionId:e.actionId,status:e.status,disabled:t||!s,onResolve:n}):e.kind===`questions`?(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),!t&&s&&u&&n({answers:Object.fromEntries(c.map(e=>[e.id,[l(e.id)]]))})},children:[c.map(n=>(0,W.jsxs)(`fieldset`,{disabled:t||!s,children:[(0,W.jsx)(`legend`,{children:n.header}),(0,W.jsx)(`p`,{children:n.question}),n.options.map((t,a)=>(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${e.actionId}-${n.id}`,value:t.label,checked:r[n.id]===t.label,onChange:()=>i(e=>({...e,[n.id]:t.label}))}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:t.label}),(0,W.jsx)(`small`,{children:t.description})]}),(0,W.jsx)(`span`,{className:`option-number`,children:a+1})]},t.label)),n.options.length>0&&n.isOther&&(0,W.jsxs)(`label`,{className:`question-option`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`${e.actionId}-${n.id}`,checked:r[n.id]===`__other__`,onChange:()=>i(e=>({...e,[n.id]:`__other__`}))}),(0,W.jsx)(`span`,{children:`其他回答`})]}),(n.options.length===0||r[n.id]===`__other__`)&&(0,W.jsx)(`input`,{className:`text-input`,type:n.isSecret?`password`:`text`,"aria-label":`${n.header}:自由回答`,value:n.options.length===0?r[n.id]??``:a[n.id]??``,maxLength:1e4,onChange:e=>n.options.length===0?i(t=>({...t,[n.id]:e.target.value})):o(t=>({...t,[n.id]:e.target.value})),placeholder:`输入你的回答`,autoComplete:`off`})]},n.id)),(0,W.jsx)(q,{type:`submit`,disabled:t||!s||!u,children:s?d?`确认选择`:`提交回答`:Pw(e.status)})]}):(0,W.jsx)(`div`,{className:`action-options`,children:e.options.map(e=>(0,W.jsx)(q,{variant:/decline|cancel|reject|deny/i.test(e.id)?`secondary`:`default`,disabled:t||!s,onClick:()=>n({decision:e.id}),children:e.label},e.id))}),e.kind===`unsupported`&&(0,W.jsx)(`p`,{className:`inline-error`,children:`当前版本不支持此交互请求,未发送批准。请查看兼容性诊断。`})]})}var Vw={connecting:`正在连接`,connected:`实时连接正常`,disconnected:`连接已断开`,authenticationRequired:`需要重新登录`},Hw={accepted:`网关已接受`,dispatching:`等待上游确认`,acknowledged:`上游已确认提交`,failed:`提交失败`,unknown:`提交结果待核对`};function Uw({connection:e}){return(0,W.jsxs)(`span`,{className:`connection-badge connection-${e}`,children:[(0,W.jsx)(`span`,{className:`status-dot`}),Vw[e]]})}function Ww({entry:e,thread:t,onReconcile:n,onDiscardMissing:r,busy:i,refreshing:a}){let[o,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(!1),u=e.operation?.execution,d=e.kind===`fork`,f=!!(t&&kl(t.status)&&u?.threadId===t.id),p=!!(!d&&t&&kl(t.status)&&e.target===t.id);return(0,W.jsxs)(`div`,{className:`operation-card`,children:[(0,W.jsxs)(`div`,{className:`operation-title`,children:[(0,W.jsx)(`strong`,{children:Hw[e.status]}),(0,W.jsx)(`span`,{children:Tn(e.createdAt)})]}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`操作`}),(0,W.jsx)(`dd`,{children:e.kind}),(0,W.jsx)(`dt`,{children:`目标`}),(0,W.jsx)(`dd`,{children:e.target}),(0,W.jsx)(`dt`,{children:`操作 ID`}),(0,W.jsx)(`dd`,{children:e.clientOperationId}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`dt`,{children:`会话`}),(0,W.jsx)(`dd`,{children:u.threadId}),(0,W.jsx)(`dt`,{children:`工作区`}),(0,W.jsx)(`dd`,{children:u.workspaceKey}),(0,W.jsx)(`dt`,{children:`运行状态`}),(0,W.jsx)(`dd`,{children:u.ended?`已经结束`:`尚未确认终结`})]})]}),(e.lookupError?.message||e.error)&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:e.lookupError?.message??e.error}),An(e)&&(0,W.jsxs)(`div`,{className:`reconcile`,children:[(0,W.jsx)(`p`,{children:`请先检查会话历史、会话列表和原执行环境。清理仅移除此浏览器的待核对记录,不会停止任务或重新提交。`}),p?(0,W.jsx)(`p`,{children:`当前会话仍在执行,请等待结束或正常中断后再核对。`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`我已检查历史和原执行环境,确认无需继续核对这笔提交`]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!c||i||a,onClick:()=>r(e.clientOperationId),children:`清除此浏览器的待核对记录`})]})]}),e.kind===`confirmCompatibility`&&e.status===`unknown`&&(0,W.jsx)(`p`,{className:`subtle`,children:`兼容性确认结果待核对,请刷新状态。此记录不代表任务执行,也不会自动重新提交。`}),e.kind!==`confirmCompatibility`&&Nn(e)&&!e.lookupError?.missing&&!e.operation?.reconciliation&&(0,W.jsxs)(`div`,{className:`reconcile`,children:[(0,W.jsx)(`p`,{children:d?`请先刷新会话列表,检查是否已生成包含原历史的新会话。核对此次 Fork 不会停止原任务或改变原任务的执行状态。`:`不会自动重发任务。先检查会话历史和原执行环境,再核对这笔提交。`}),f?(0,W.jsx)(`p`,{children:`当前任务仍在执行,请使用输入区的中断按钮。`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),d?`我已检查会话列表和历史,核实此次 Fork 的结果`:`我已核实对应旧运行已经结束`]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!o||i||a,onClick:()=>n(e.clientOperationId),children:i?`正在提交核对…`:d?`核对此次 Fork`:`核对并解除旧占用`})]})]}),e.operation?.reconciliation&&(0,W.jsxs)(`p`,{className:`subtle`,children:[`已于 `,Tn(e.operation.reconciliation.at),` `,d?`人工核对 Fork 结果。原任务状态不变。`:`人工核对旧运行结束。`,`保留原始提交状态。`]})]})}function Gw({system:e,connection:t,operations:n,thread:r,selectedId:i,threadReadFailed:a,onRefresh:o,onReconcile:s,onDiscardMissing:c,busy:l,open:u,onOpenChange:d,refreshing:f}){let p=(0,O.useRef)(null);return(0,O.useEffect)(()=>{u&&p.current?.focus()},[u]),(0,W.jsxs)(`details`,{className:`diagnostics`,open:u,onToggle:e=>d(e.currentTarget.open),children:[(0,W.jsxs)(`summary`,{children:[(0,W.jsx)(J,{name:`settings`,size:16}),`状态诊断`,n.length>0&&(0,W.jsx)(`span`,{className:`count-badge`,children:n.length})]}),(0,W.jsxs)(`div`,{className:`diagnostics-panel`,id:`diagnostics-panel`,ref:p,tabIndex:-1,role:`region`,"aria-label":`状态诊断详情`,"aria-busy":f,children:[(0,W.jsxs)(`div`,{className:`diagnostics-heading`,children:[(0,W.jsx)(`h2`,{children:`运行状态`}),(0,W.jsxs)(q,{variant:`ghost`,size:`sm`,disabled:f,onClick:o,children:[(0,W.jsx)(J,{name:`refresh`,size:14}),f?`正在核对…`:`刷新状态`]})]}),(0,W.jsxs)(`section`,{className:`operation-section`,"aria-label":`当前会话信息`,children:[(0,W.jsx)(`h3`,{children:`当前会话`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`Thread ID`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(Ml,{id:r?.id===i?r?.id:void 0,placeholder:i?a?`会话详情加载失败`:`正在加载会话详情…`:`会话尚未创建`})})]})]}),(0,W.jsxs)(`section`,{className:`operation-section`,children:[(0,W.jsx)(`h3`,{children:`操作与状态核对`}),(0,W.jsx)(`p`,{className:`subtle`,role:`status`,children:f?`正在核对会话历史和提交回执…`:r?.status===`unknown`?`会话状态仍待核对。请检查操作记录和原执行环境。`:n.length>0?`请查看提交记录;核对不会自动重发任务。`:`没有待核对的提交。`}),n.map(e=>(0,W.jsx)(Ww,{entry:e,thread:r,onReconcile:s,onDiscardMissing:c,busy:l.includes(`reconcile:${e.clientOperationId}`)||l.includes(`${e.kind}:${e.target}`),refreshing:f},e.clientOperationId))]}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`网页连接`}),(0,W.jsx)(`dd`,{children:Vw[t]}),(0,W.jsx)(`dt`,{children:`Codex`}),(0,W.jsx)(`dd`,{children:e?.ready?`已就绪`:e?.connection===`starting`?`启动中`:`不可用`}),(0,W.jsx)(`dt`,{children:`账户认证`}),(0,W.jsx)(`dd`,{children:e?.authenticated===!0?`可用`:e?.authenticated===!1?`需要在本机登录 Codex`:`尚未确认`}),(0,W.jsx)(`dt`,{children:`运行版本`}),(0,W.jsx)(`dd`,{children:e?.codexVersion??`未检测到`}),(0,W.jsx)(`dt`,{children:`已验证版本`}),(0,W.jsx)(`dd`,{children:e?.verifiedVersion??`读取中`}),(0,W.jsx)(`dt`,{children:`兼容性`}),(0,W.jsx)(`dd`,{children:e?.compatibility===`verified`?`版本已验证`:e?.compatibility===`unverified`?e.compatibilityConfirmation===`confirmed`?`当前版本未经验证 · 已确认继续`:`当前版本未经验证 · 待确认`:`不可用`}),(0,W.jsx)(`dt`,{children:`入口认证`}),(0,W.jsx)(`dd`,{children:e?.authMode===`cloudflare-access`?`Cloudflare Access`:`本机模式`})]}),e?.error&&(0,W.jsx)(`p`,{className:`inline-error`,children:e.error}),e&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:`已支持能力`}),(0,W.jsx)(`p`,{children:e.capabilities.join(` · `)||`暂无`})]})]})]})}async function Kw(e){let t=await fetch(`/api/threads/${encodeURIComponent(e)}/export`,{credentials:`same-origin`,cache:`no-store`,headers:{Accept:`text/markdown`},signal:AbortSignal.timeout(35e3)}),n=t.headers.get(`content-type`)??``;if(!t.ok||!n.includes(`text/markdown`)){if(n.includes(`application/json`)){let e=await t.json();throw new Le(t.status,e.error??{code:`EXPORT_FAILED`,message:`无法读取会话历史,未下载文件。`})}throw new Le(t.status===200?401:t.status,{code:`AUTH_REQUIRED`,message:`登录已过期或历史接口未返回 Markdown,请重新登录后重试。`})}let r=/filename="(codex-thread-[A-Za-z0-9_-]+\.md)"/.exec(t.headers.get(`content-disposition`)??``)?.[1];if(!r)throw Error(`导出响应缺少有效文件名,未下载文件。`);let i=t.headers.get(`x-export-completeness`);if(i!==`partial`&&i!==`saved-history`)throw Error(`导出响应缺少历史完整性说明,未下载文件。`);let a=await t.blob(),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=r,document.body.append(s);try{s.click()}finally{s.remove(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}return{partial:i===`partial`}}function qw(e){let{system:t}=e,n=(0,O.useRef)(null),[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(),s=Vn(t),c=Un(t,r,a);(0,O.useEffect)(()=>{e.onOpenChange?.(c)},[c,e.onOpenChange]),(0,O.useEffect)(()=>{let e=n.current;if(e)return c&&!e.open?e.showModal():!c&&e.open&&e.close(),()=>{e.open&&e.close()}},[c]);function l(){i(s),o(void 0)}return(0,W.jsxs)(W.Fragment,{children:[t?.compatibility===`unverified`&&(0,W.jsxs)(`div`,{className:`compatibility-banner compatibility-notice`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[`当前 Codex `,t.codexVersion,` 尚未验证兼容性,部分功能可能无法正常使用。`,t.compatibilityConfirmation===`confirmed`?` 已确认继续;这不代表版本已验证。`:` 使用前需要确认。`]}),t.compatibilityConfirmation===`required`&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>o(s),children:`查看兼容性提示`})]}),(0,W.jsxs)(`dialog`,{ref:n,className:`compatibility-dialog`,"aria-labelledby":`compatibility-title`,"aria-describedby":`compatibility-description`,onCancel:e=>{e.preventDefault(),l()},children:[(0,W.jsxs)(`div`,{className:`compatibility-dialog-heading`,children:[(0,W.jsx)(J,{name:`alert`,size:22}),(0,W.jsx)(`h2`,{id:`compatibility-title`,children:`Codex 版本兼容性未经验证`})]}),(0,W.jsx)(`p`,{id:`compatibility-description`,children:`当前运行的 Codex 版本尚未验证,部分功能可能无法正常使用。确认继续后仍将保留兼容性提示。`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsx)(`dt`,{children:`运行版本`}),(0,W.jsx)(`dd`,{children:t?.codexVersion??`未检测到`}),(0,W.jsx)(`dt`,{children:`已验证版本`}),(0,W.jsx)(`dd`,{children:t?.verifiedVersion??`读取中`})]}),t?.ready?!e.canConfirm&&(0,W.jsx)(`p`,{className:`subtle`,role:`status`,children:`请等待连接和 Codex 认证恢复后再确认。`}):(0,W.jsx)(`p`,{className:`inline-error`,role:`status`,children:`Codex 当前不可用,无法确认继续。请关闭此提示后查看状态诊断。`}),e.error&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:e.error}),e.uncertain&&(0,W.jsxs)(`div`,{className:`compatibility-uncertain`,role:`status`,children:[(0,W.jsx)(`p`,{children:`确认请求的结果尚待核对。可刷新状态,或重新确认当前运行版本的使用许可;不会重发任务。`}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,onClick:e.onRefresh,children:`刷新确认状态`}),t?.ready&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!e.canConfirm||e.submitting,onClick:e.onReconfirm,children:`重新确认`})]}),(0,W.jsx)(`p`,{className:`subtle`,children:`关闭提示后仍可查看诊断或中断当前任务。确认不会自动发送任务,未发送的草稿会保留。`}),(0,W.jsxs)(`div`,{className:`compatibility-dialog-actions`,children:[(0,W.jsx)(q,{variant:`secondary`,autoFocus:!0,onClick:l,children:`暂不使用`}),t?.ready&&(0,W.jsx)(q,{disabled:!e.canConfirm||e.submitting||e.uncertain,onClick:e.onConfirm,children:e.submitting?`正在确认…`:`确认继续`})]})]})]})}function Jw(e){let t=(0,O.useRef)(null),n=(0,O.useRef)(!1),[r,i]=(0,O.useState)(``),[a,o]=(0,O.useState)(e.project?.name??``),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(),p=e.disabled||l,m=s?`移除项目`:e.project?`管理项目`:`添加服务器项目`;(0,O.useEffect)(()=>{let e=t.current;return e?.showModal(),()=>e?.close()},[]);async function h(){if(!(p||n.current)){n.current=!0,u(!0),f(void 0);try{e.project?s?await e.onRemove(e.project.id):await e.onRename(e.project.id,a.trim()):await e.onAdd({path:r.trim(),...a.trim()?{name:a.trim()}:{}}),e.onClose()}catch(e){f(En(e))}finally{n.current=!1,u(!1)}}}return(0,W.jsxs)(`dialog`,{ref:t,className:`project-dialog`,"aria-labelledby":`project-dialog-title`,"aria-describedby":`project-dialog-description`,onCancel:t=>{t.preventDefault(),l||e.onClose()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(J,{name:`folder`,size:20}),(0,W.jsx)(`h2`,{id:`project-dialog-title`,children:m})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭项目管理`,disabled:l,onClick:e.onClose,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},children:[s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{id:`project-dialog-description`,children:[`确定从工作空间移除「`,e.project?.name,`」?`]}),(0,W.jsxs)(`div`,{className:`project-removal-note`,children:[(0,W.jsx)(`p`,{children:`只移除项目列表中的记录,服务器上的文件和会话历史都会保留。`}),(0,W.jsx)(`p`,{children:`之后重新添加同一目录,即可继续访问原有会话。进行中的任务或未确认的操作需要先处理完成。`})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{id:`project-dialog-description`,children:e.project?`为项目设置便于识别的名称,或从工作空间移除项目。`:`添加运行 Codex Web UI 的服务器上已有的目录。添加后即可查看历史会话并开始工作。`}),e.project?(0,W.jsxs)(`div`,{className:`project-directory`,children:[(0,W.jsx)(`span`,{children:`服务器目录`}),(0,W.jsx)(`code`,{children:e.project.rootPath})]}):(0,W.jsxs)(`label`,{className:`project-field`,children:[(0,W.jsx)(`span`,{children:`服务器目录`}),(0,W.jsx)(`input`,{autoFocus:!0,required:!0,autoComplete:`off`,spellCheck:!1,placeholder:`/home/you/code/my-project`,value:r,onChange:e=>i(e.target.value),"aria-describedby":`project-path-help`,"aria-label":`服务器目录`,disabled:p}),(0,W.jsx)(`small`,{id:`project-path-help`,children:`填写服务器上的绝对路径,不是当前浏览器所在设备的目录。目录需要已存在,且服务有权访问。`})]}),(0,W.jsxs)(`label`,{className:`project-field`,children:[(0,W.jsx)(`span`,{children:e.project?`项目名称`:`项目名称(可选)`}),(0,W.jsx)(`input`,{autoFocus:!!e.project,required:!!e.project,maxLength:100,placeholder:`默认使用目录名称`,value:a,onChange:e=>o(e.target.value),disabled:p})]})]}),d&&(0,W.jsx)(`p`,{className:`inline-error project-dialog-error`,role:`alert`,children:d}),e.disabled&&(0,W.jsx)(`p`,{className:`subtle`,children:`登录已过期,请重新登录后管理项目。`}),(0,W.jsxs)(`div`,{className:`project-dialog-actions`,children:[e.project&&!s&&(0,W.jsx)(q,{className:`project-remove-button`,variant:`ghost`,disabled:p,onClick:()=>{f(void 0),c(!0)},children:`移除项目…`}),(0,W.jsx)(q,{variant:`secondary`,disabled:l,onClick:()=>{s?(f(void 0),c(!1)):e.onClose()},children:s?`返回`:`取消`}),(0,W.jsx)(q,{type:`submit`,variant:s?`destructive`:`default`,disabled:p||!s&&(e.project?!a.trim():!r.trim()),children:l?s?`正在移除…`:`正在保存…`:s?`确认移除`:e.project?`保存名称`:`添加项目`})]})]})]})}function Yw({notifications:e,onClose:t}){let n=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=n.current;return e?.showModal(),()=>e?.close()},[]);let{enabled:r,access:i,requesting:a,error:o}=e,s=r&&i===`granted`,c={default:`尚未授权`,granted:`已授权`,denied:`已被浏览器阻止`,unsupported:`当前浏览器不支持`,insecure:`需要安全连接`}[i],l=![`default`,`granted`].includes(i);return(0,W.jsxs)(`dialog`,{ref:n,className:`project-dialog notification-dialog`,"aria-labelledby":`notification-dialog-title`,onCancel:e=>{e.preventDefault(),t()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(I,{size:20,"aria-hidden":`true`}),(0,W.jsx)(`h2`,{id:`notification-dialog-title`,children:`工作完成通知`})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭通知设置`,onClick:t,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsx)(`p`,{children:`每轮工作结束时显示项目、会话及结果,点击通知可返回对应会话。`}),(0,W.jsxs)(`div`,{className:`notification-control`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`浏览器通知`}),(0,W.jsxs)(`span`,{role:`status`,children:[c,` · `,s?`已开启`:`未开启`]})]}),(0,W.jsx)(q,{role:`switch`,"aria-label":`浏览器通知`,"aria-checked":s,"aria-describedby":`notification-permission-help`,variant:s?`secondary`:`default`,size:`sm`,disabled:a||l,onClick:()=>void e.toggle(),children:a?`等待授权…`:s?`关闭通知`:`启用通知`})]}),(0,W.jsx)(`p`,{id:`notification-permission-help`,className:`notification-help`,children:i===`denied`?`请在浏览器的站点设置中允许通知,再回到此页面开启。`:i===`insecure`?`请使用 HTTPS 访问。localhost 或 127.0.0.1 可用于本机访问。`:i===`unsupported`?`请使用支持系统通知的桌面浏览器。页内状态与未读提示仍然可用。`:`只有点击启用后才会请求授权。此设置在当前浏览器的本站标签页间共享。`}),r&&i===`granted`&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,onClick:e.test,children:`发送测试通知`}),o&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:o}),(0,W.jsxs)(`section`,{className:`notification-background`,"aria-labelledby":`notification-background-title`,children:[(0,W.jsx)(`h3`,{id:`notification-background-title`,children:`后台通知与页面休眠`}),(0,W.jsx)(`p`,{children:`请保持页面和浏览器运行。普通后台状态可接收通知;页面被冻结或被回收期间,无法保证及时通知。恢复页面后会同步结果与未读提示。`}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`如何让本站保持活跃`}),(0,W.jsxs)(`ul`,{children:[(0,W.jsxs)(`li`,{children:[`Chrome:设置 → 性能 → 始终保持这些网站活跃,添加本站。`,(0,W.jsx)(`a`,{href:`https://support.google.com/chrome/answer/12929150?hl=zh-Hans`,target:`_blank`,rel:`noreferrer`,children:`设置说明`})]}),(0,W.jsxs)(`li`,{children:[`Edge:设置 → 系统和性能 → 性能 → 始终保持这些网站活跃(或「从不将这些网站置于睡眠状态」),添加本站。`,(0,W.jsx)(`a`,{href:`https://support.microsoft.com/edge/learn-about-performance-features-in-microsoft-edge`,target:`_blank`,rel:`noreferrer`,children:`设置说明`})]})]}),(0,W.jsx)(`p`,{children:`需要在浏览器中手动设置,具体名称可能随版本变化。`})]})]})]})}var Xw=1048576,Zw=e=>`0.0009765625–${e} MiB(最小 1 KiB)`;function Qw(e,t,n,r){return{key:e,label:`${t}(MiB)`,group:`advanced`,unit:`MiB`,maxMiB:n,help:`范围 ${Zw(n)},默认 ${r} MiB。支持精确对应整数字节的小数;1 MiB = 1024 × 1024 字节。`}}var $w=e=>(e/Xw).toFixed(20).replace(/\.?0+$/,``),eT=[{key:`host`,label:`监听地址`,group:`network`,help:`本机模式使用 127.0.0.1、localhost 或 ::1。`},{key:`port`,label:`监听端口`,group:`network`,type:`number`,help:`范围 1–65535;修改后使用新端口访问。`},{key:`publicOrigin`,label:`允许访问地址`,group:`network`,multiline:!0,help:`每行一个完整的 HTTP(S) 地址,仅包含协议、主机和端口。`},{key:`issuer`,label:`Access 团队地址`,group:`network`,help:`例如 https://your-team.cloudflareaccess.com`},{key:`audience`,label:`Access 应用 AUD`,group:`network`,help:`填写 Cloudflare Access 应用的 Audience。`},{key:`binary`,label:`Codex 可执行文件`,group:`codex`,help:`可填写 codex 或服务器上的绝对路径。`},{key:`home`,label:`CODEX_HOME(可选)`,group:`codex`,help:`留空继承服务进程环境;指定时必须填写服务器上的绝对路径。`},{key:`requestTimeoutMs`,label:`请求超时(毫秒)`,group:`codex`,type:`number`,help:`范围 100–300000,默认 30000。`},Qw(`maxLineBytes`,`Codex 单行消息上限`,256,64),Qw(`eventBytes`,`事件缓冲上限`,64,16),Qw(`wsBytes`,`WebSocket 缓冲上限`,16,4),Qw(`itemBytes`,`单项内容上限`,8,2),{key:`developmentOrigins`,label:`开发环境来源`,group:`advanced`,multiline:!0,help:`每行一个本机 HTTP(S) 来源,仅在 --dev 模式使用。`}];function tT(e){return{host:e.host,port:String(e.port),publicOrigin:e.publicOrigin.join(`
|
|
84
84
|
`),developmentOrigins:e.developmentOrigins.join(`
|
|
85
|
-
`),mode:e.auth.mode,issuer:e.auth.mode===`cloudflare-access`?e.auth.issuer:``,audience:e.auth.mode===`cloudflare-access`?e.auth.audience:``,binary:e.codex.binary,home:e.codex.home??``,requestTimeoutMs:String(e.codex.requestTimeoutMs),maxLineBytes
|
|
86
|
-
`).map(e=>e.trim()).filter(Boolean),eT=Zw.filter(e=>`unit`in e);function tT(e,t){let n=e=>({bytes:NaN,error:`${t.label}:${e}`}),r=e.trim();if(!r)return n(`请输入 MiB 数值。`);if(!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(r)||!Number.isFinite(Number(r)))return n(`请输入有效的 MiB 数值,可使用小数。`);if(Number(r)<1/1024||Number(r)>t.maxMiB)return n(`范围为 ${Jw(t.maxMiB)}。`);let[i,a=``]=r.replace(/^\+/,``).split(`.`),o=a.replace(/0+$/,``),s=()=>n(`MiB 数值必须精确对应整数字节,请调整小数(不会自动舍入)。`);if(o.length>20)return s();let c=10n**BigInt(o.length),l=(BigInt(i||`0`)*c+BigInt(o||`0`))*BigInt(qw);return l<1024n*c||l>BigInt(t.maxMiB*qw)*c?n(`范围为 ${Jw(t.maxMiB)}。`):l%c===0n?{bytes:Number(l/c)}:s()}function nT(e){return Object.fromEntries(eT.flatMap(t=>{let{error:n}=tT(e[t.key],t);return n?[[t.key,n]]:[]}))}function rT(e,t){return`unit`in e?`${t} ${e.unit}`:t}function iT(e,t){let n=Object.fromEntries(eT.map(t=>[t.key,tT(e[t.key],t).bytes]));return{...t,host:e.host.trim(),port:Number(e.port),publicOrigin:$w(e.publicOrigin),developmentOrigins:$w(e.developmentOrigins),auth:e.mode===`local`?{mode:`local`}:{mode:e.mode,issuer:e.issuer.trim(),audience:e.audience.trim()},codex:{binary:e.binary.trim(),...e.home.trim()?{home:e.home.trim()}:{},requestTimeoutMs:Number(e.requestTimeoutMs),maxLineBytes:n.maxLineBytes},limits:{eventBytes:n.eventBytes,wsBytes:n.wsBytes,itemBytes:n.itemBytes}}}function aT(e,t){let n=Qw(e),r=Qw(t);return[...n.mode===r.mode?[]:[{label:`认证模式`,before:n.mode,after:r.mode}],...Zw.filter(e=>!([`issuer`,`audience`].includes(e.key)&&r.mode===`local`)&&n[e.key]!==r[e.key]).map(e=>({label:e.label,before:rT(e,n[e.key]),after:rT(e,r[e.key])}))]}var oT=e=>e instanceof Error?e.message:`操作失败,请重试。`;function sT({onClose:e}){let t=(0,O.useRef)(null),n=(0,O.useRef)(null),[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(),[d,f]=(0,O.useState)(!0),[p,m]=(0,O.useState)(``),[h,g]=(0,O.useState)(``),[_,v]=(0,O.useState)({}),[y,b]=(0,O.useState)(!1),[x,S]=(0,O.useState)(!1),C=!!r&&!!a&&JSON.stringify(iT(a,r.saved))!==JSON.stringify(r.saved);(0,O.useEffect)(()=>{t.current?.showModal();let e=new AbortController;return ze.gatewayConfig().then(t=>{e.signal.aborted||(i(t),o(Qw(t.saved)))}).catch(t=>{e.signal.aborted||m(oT(t))}).finally(()=>{e.signal.aborted||f(!1)}),()=>{e.abort(),t.current?.close()}},[]),(0,O.useEffect)(()=>{let e=e=>{C&&e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[C]);let w=()=>{d||(C||l?S(!0):e())};async function T(e){f(!0),m(``),g(``);try{await e()}catch(e){m(oT(e)),e instanceof Le&&e.problem.code===`CONFIG_CONFLICT`&&b(!0)}finally{f(!1)}}async function E(){await T(async()=>{let e=await ze.gatewayConfig();i(e),o(Qw(e.saved)),v({}),c(void 0),u(void 0),b(!1)})}async function D(e){let t=e.target.files?.[0];e.target.value=``,t&&await T(async()=>{if(t.size>262144)throw Error(`配置文件不能超过 256 KiB。`);let e;try{e=JSON.parse(await t.text())}catch{throw Error(`无法解析 JSON,请检查配置文件格式。`)}u(await ze.importGatewayConfig(e)),c(void 0)})}async function k(){await T(async()=>{let e=await ze.exportGatewayConfig(),t=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`codex-web-config.json`,document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3),g(`已导出配置文件中的已保存配置;未保存的编辑不包含在内。`)})}let A=r&&Qw(r.running),j=l?.config??s,M=r&&j?aT(r.saved,j):[];function N(e){if(!a||!A||[`issuer`,`audience`].includes(e.key)&&a.mode!==`cloudflare-access`)return null;let t={id:`gateway-${e.key}`,"aria-labelledby":`gateway-${e.key}-label`,"aria-describedby":`gateway-${e.key}-help${_[e.key]?` gateway-${e.key}-error`:``}`,"aria-invalid":!!_[e.key],value:a[e.key],disabled:d||!r?.writable,onChange:t=>{o({...a,[e.key]:t.target.value}),v(t=>({...t,[e.key]:void 0})),g(``)}};return(0,W.jsxs)(`label`,{className:`project-field`,htmlFor:t.id,children:[(0,W.jsx)(`span`,{id:`gateway-${e.key}-label`,children:e.label}),`multiline`in e?(0,W.jsx)(`textarea`,{...t,rows:3,spellCheck:!1}):(0,W.jsx)(`input`,{...t,type:`type`in e?e.type:`text`,inputMode:`unit`in e?`decimal`:void 0,spellCheck:!1}),(0,W.jsx)(`small`,{id:`gateway-${e.key}-help`,children:e.help}),_[e.key]&&(0,W.jsx)(`small`,{id:`gateway-${e.key}-error`,className:`gateway-error`,role:`alert`,children:_[e.key]}),a[e.key]!==A[e.key]&&(0,W.jsxs)(`small`,{className:`gateway-running`,children:[`当前运行:`,rT(e,A[e.key])||`未设置`]})]},e.key)}return(0,W.jsxs)(`dialog`,{ref:t,className:`project-dialog gateway-dialog`,"aria-labelledby":`gateway-title`,onCancel:e=>{e.preventDefault(),w()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(be,{size:20,"aria-hidden":`true`}),(0,W.jsx)(`h2`,{id:`gateway-title`,children:`服务配置`})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭服务配置`,disabled:d,onClick:w,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsx)(`p`,{className:`gateway-intro`,children:`配置运行此网页服务的电脑。保存后需手动重启服务生效。`}),p&&(0,W.jsx)(`p`,{className:`gateway-error`,role:`alert`,children:p}),!r&&(0,W.jsx)(q,{variant:`secondary`,disabled:d,onClick:()=>void E(),children:d?`正在读取配置…`:`重新读取配置`}),r&&a&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`gateway-file`,children:[(0,W.jsx)(`span`,{children:`配置文件`}),(0,W.jsx)(`code`,{children:r.path})]}),(0,W.jsxs)(`div`,{className:`gateway-status`,role:`status`,"data-pending":r.restartRequired,children:[(0,W.jsx)(`strong`,{children:r.restartRequired?`已保存,待重启生效`:`已保存配置与当前运行配置一致`}),(0,W.jsx)(`span`,{children:`保存不会重启服务或中断当前任务。`})]}),!r.writable&&(0,W.jsx)(`p`,{className:`gateway-error`,children:r.readOnlyReason}),h&&(0,W.jsx)(`p`,{className:`gateway-notice`,role:`status`,children:h}),y&&(0,W.jsxs)(`div`,{className:`gateway-conflict`,children:[(0,W.jsx)(`p`,{children:`重新读取会丢弃当前编辑,并载入文件的最新内容。`}),(0,W.jsx)(q,{variant:`secondary`,disabled:d,onClick:()=>void E(),children:`丢弃编辑并重新读取`})]}),x?(0,W.jsxs)(`section`,{className:`gateway-review`,"aria-label":`放弃编辑确认`,children:[(0,W.jsx)(`h3`,{children:`放弃未保存的更改?`}),(0,W.jsx)(`p`,{children:`配置文件尚未修改。`}),(0,W.jsxs)(`div`,{className:`project-dialog-actions`,children:[(0,W.jsx)(q,{variant:`secondary`,onClick:()=>S(!1),children:`继续编辑`}),(0,W.jsx)(q,{variant:`destructive`,onClick:e,children:`放弃更改并关闭`})]})]}):j?(0,W.jsxs)(`section`,{className:`gateway-review`,"aria-label":l?`导入配置预览`:`保存配置预览`,children:[(0,W.jsx)(`h3`,{children:l?`预览导入配置`:`确认配置更改`}),(0,W.jsx)(`p`,{children:l?`应用到表单后仍需检查并保存,才会修改配置文件。导入将替换当前表单中的可编辑配置。`:`以下更改将在服务重启后生效。请确认新的访问地址和认证配置。`}),l&&(0,W.jsxs)(`p`,{children:[`保留当前数据目录和项目初始配置。`,l.preserved.length>0?`已忽略导入文件中的 ${l.preserved.join(`、`)}。`:``]}),M.length?(0,W.jsx)(`div`,{className:`gateway-changes`,children:M.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsxs)(`span`,{children:[`已保存:`,e.before||`未设置`]}),(0,W.jsxs)(`span`,{children:[`更改为:`,e.after||`未设置`]})]},e.label))}):(0,W.jsx)(`p`,{children:`与已保存配置没有差异。`}),(0,W.jsxs)(`details`,{className:`gateway-json`,children:[(0,W.jsx)(`summary`,{children:`查看完整 JSON`}),(0,W.jsx)(`pre`,{children:JSON.stringify(j,null,2)})]}),(0,W.jsxs)(`div`,{className:`project-dialog-actions`,children:[(0,W.jsx)(q,{variant:`secondary`,disabled:d,onClick:()=>{u(void 0),c(void 0)},children:`返回编辑`}),l?(0,W.jsx)(q,{disabled:d,onClick:()=>{o(Qw(l.config)),v({}),u(void 0),g(`导入配置已应用到表单,尚未保存。`)},children:`应用到表单`}):(0,W.jsx)(q,{disabled:d||y||!M.length,onClick:()=>void T(async()=>{let e=await ze.saveGatewayConfig(r.revision,j);i(e),o(Qw(e.saved)),c(void 0),g(e.restartRequired?`配置已保存。请在方便时手动重启服务。`:`配置已保存,与当前运行配置一致。`)}),children:d?`正在保存…`:`确认保存`})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`gateway-tools`,children:[(0,W.jsxs)(q,{variant:`secondary`,size:`sm`,disabled:d||!r.writable,onClick:()=>n.current?.click(),children:[(0,W.jsx)(we,{size:15,"aria-hidden":`true`}),`导入配置`]}),(0,W.jsxs)(q,{variant:`secondary`,size:`sm`,disabled:d,onClick:()=>void k(),children:[(0,W.jsx)(le,{size:15,"aria-hidden":`true`}),`导出已保存配置`]}),(0,W.jsx)(`input`,{ref:n,type:`file`,accept:`.json,application/json`,"aria-label":`选择配置文件`,hidden:!0,onChange:e=>void D(e)})]}),(0,W.jsx)(`p`,{className:`gateway-help`,children:`导入仅更新服务设置;导出包含文件中的项目初始配置,不包含页面注册项目、会话、数据库或登录凭据。`}),(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=nT(a);v(t);let n=Zw.find(e=>t[e.key]);n?requestAnimationFrame(()=>{let e=document.getElementById(`gateway-${n.key}`);e?.closest(`details`)?.setAttribute(`open`,``),e?.focus({preventScroll:!0}),e?.closest(`label`)?.scrollIntoView({block:`center`})}):T(async()=>{c((await ze.importGatewayConfig(iT(a,r.saved))).config)})},children:[(0,W.jsxs)(`fieldset`,{disabled:d||!r.writable,children:[(0,W.jsxs)(`section`,{className:`gateway-section`,children:[(0,W.jsx)(`h3`,{children:`网络与访问`}),(0,W.jsxs)(`div`,{className:`gateway-fields`,children:[Zw.filter(e=>e.group===`network`).map(N),(0,W.jsxs)(`label`,{className:`project-field`,children:[(0,W.jsx)(`span`,{children:`认证模式`}),(0,W.jsxs)(`select`,{"aria-label":`认证模式`,value:a.mode,onChange:e=>o({...a,mode:e.target.value}),children:[(0,W.jsx)(`option`,{value:`local`,children:`本机 / Tailscale(local)`}),(0,W.jsx)(`option`,{value:`cloudflare-access`,children:`Cloudflare Access`})]}),(0,W.jsx)(`small`,{children:`本机模式仅监听回环地址;公开互联网入口使用 Cloudflare Access。`}),a.mode!==A?.mode&&(0,W.jsxs)(`small`,{className:`gateway-running`,children:[`当前运行:`,A?.mode]})]})]})]}),(0,W.jsxs)(`section`,{className:`gateway-section`,children:[(0,W.jsx)(`h3`,{children:`Codex`}),(0,W.jsx)(`div`,{className:`gateway-fields`,children:Zw.filter(e=>e.group===`codex`).map(N)})]}),(0,W.jsxs)(`section`,{className:`gateway-section`,children:[(0,W.jsx)(`h3`,{children:`数据与项目`}),(0,W.jsxs)(`div`,{className:`gateway-file`,children:[(0,W.jsx)(`span`,{children:`数据目录(只读)`}),(0,W.jsx)(`code`,{children:r.saved.dataDir}),(0,W.jsx)(`span`,{children:`当前运行目录`}),(0,W.jsx)(`code`,{children:r.running.dataDir})]}),(0,W.jsx)(`p`,{className:`gateway-help`,children:`数据目录变更需要迁移数据库,请在服务停止后处理。项目请在侧栏添加、重命名或移除;此处不覆盖已保存的项目管理结果。`})]}),(0,W.jsxs)(`details`,{className:`gateway-section`,children:[(0,W.jsx)(`summary`,{children:`高级设置`}),(0,W.jsx)(`div`,{className:`gateway-fields`,children:Zw.filter(e=>e.group===`advanced`).map(N)})]})]}),(0,W.jsxs)(`div`,{className:`gateway-save-bar`,children:[(0,W.jsx)(`span`,{children:C?`有未保存的更改`:`没有未保存的更改`}),(0,W.jsx)(q,{type:`submit`,disabled:d||!C||!r.writable||y,children:d?`正在校验…`:`检查更改`})]})]})]})]})]})}var cT=[`stable`,`beta`,`dev`],lT=e=>!!(e&&[`installing`,`waiting`,`stopping`,`verifying`].includes(e.phase)),uT={stable:`稳定版`,beta:`预览版`,dev:`开发版`},dT={installing:`正在安装候选版本`,waiting:`等待任务空闲`,stopping:`正在备份并重启`,verifying:`正在验证新版`,succeeded:`升级成功`,rolledBack:`已恢复上一版本`,failed:`升级失败`},fT={verified:`已验证`,unverified:`尚未验证`,unsupported:`明确不支持`,unknown:`无法确认`};function pT({title:e,value:t}){return(0,W.jsxs)(`section`,{className:`update-codex`,"aria-label":e,"data-state":t.status,children:[(0,W.jsx)(`h3`,{children:e}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Codex CLI`}),(0,W.jsx)(`strong`,{children:t.version??`未识别`}),(0,W.jsx)(`span`,{className:`update-codex-status`,children:fT[t.status]})]}),t.manifest&&(0,W.jsxs)(`p`,{className:`subtle`,children:[`推荐:`,t.manifest.recommended,` · 已验证:`,t.manifest.verified.join(`、`)]}),t.reason&&(0,W.jsx)(`p`,{children:t.reason})]})}function mT({updates:e,onClose:t}){let n=(0,O.useRef)(null),{status:r,busy:i,error:a,reloadError:o}=e,[s,c]=(0,O.useState)(),l=s??r?.settings.channel??`stable`,[u,d]=(0,O.useState)(!1),f=r?.available?.channel===l?r.available:void 0,p=lT(r?.run),m=f?.version===r?.version,[h,g]=(0,O.useState)(),_=JSON.stringify([l,f?.version,f?.codex]),v=h===_,y=f?.codex,b=!m&&y?.status===`unverified`,x=!m&&f&&(!y||y.status===`unknown`||y.status===`unsupported`||b&&!v);return(0,O.useEffect)(()=>{g(void 0)},[_]),(0,O.useEffect)(()=>{let e=n.current;return e?.showModal(),()=>e?.close()},[]),(0,W.jsxs)(`dialog`,{ref:n,className:`project-dialog update-dialog`,"aria-labelledby":`update-title`,onCancel:e=>{e.preventDefault(),t()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(ae,{size:20,"aria-hidden":`true`}),(0,W.jsx)(`h2`,{id:`update-title`,children:`Covro 更新`})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭更新设置`,onClick:t,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsxs)(`div`,{className:`update-version`,children:[(0,W.jsx)(`span`,{children:`当前 Covro`}),(0,W.jsx)(`strong`,{children:r?.version??`读取中…`}),r?.commit&&(0,W.jsx)(`code`,{children:r.commit.slice(0,8)})]}),r?.codex&&(0,W.jsx)(pT,{title:`当前 Codex`,value:r.codex}),(0,W.jsxs)(`label`,{className:`update-channel`,children:[`版本渠道`,(0,W.jsx)(`select`,{"aria-label":`版本渠道`,value:l,disabled:i||p,onChange:t=>{let n=t.target.value;c(n),d(!1),g(void 0),e.check(n)},children:cT.map(e=>(0,W.jsx)(`option`,{value:e,children:uT[e]},e))})]}),(0,W.jsx)(`p`,{className:`subtle`,children:l===`stable`?`经过验证的正式版本,适合日常使用。`:l===`beta`?`提前体验准备发布的功能。`:`跟随通过检查的 main 提交,适合开发者体验和验证新功能。`}),(0,W.jsxs)(`div`,{className:`update-control`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`空闲时自动升级`}),(0,W.jsx)(`p`,{className:`subtle`,children:`定期检查当前渠道,已验证的 Codex 组合在任务结束后安装并重启。`})]}),(0,W.jsx)(q,{role:`switch`,"aria-label":`空闲时自动升级`,"aria-checked":r?.settings.automatic??!1,variant:`secondary`,size:`sm`,disabled:i||p||!r?.supported,onClick:()=>r&&void e.configure({...r.settings,automatic:!r.settings.automatic}),children:r?.settings.automatic?`已开启`:`已关闭`})]}),r&&l!==r.settings.channel&&(0,W.jsxs)(`p`,{className:`subtle`,children:[`当前订阅:`,uT[r.settings.channel],`。成功更新后切换到`,uT[l],`。`]}),f&&(0,W.jsxs)(`div`,{className:`update-available`,children:[(0,W.jsx)(`span`,{children:m?`此渠道已是当前版本`:f.downgrade?`目标版本`:`可用版本`}),(0,W.jsx)(`strong`,{children:f.version}),f.commit&&(0,W.jsx)(`code`,{children:f.commit.slice(0,8)})]}),f?.codex&&(0,W.jsx)(pT,{title:`目标版本兼容性`,value:f.codex}),b&&(0,W.jsxs)(`label`,{className:`update-downgrade update-codex-consent`,children:[(0,W.jsx)(`input`,{type:`checkbox`,"aria-label":`允许尝试未验证的 Codex 组合`,checked:v,disabled:i||p,onChange:e=>g(e.target.checked?_:void 0)}),`我确认尝试 Codex `,y?.version,` 与 Covro `,f?.version,` `,`的未验证组合;此确认仅用于本次升级。`]}),f&&!m&&f.channel===r?.settings.channel&&r.settings.automatic&&y?.status!==`verified`&&(0,W.jsx)(`p`,{className:`update-notice`,role:`status`,children:y?.status===`unverified`?`自动升级已暂停。可以调整 Codex 版本后重新检查,或勾选确认后手动尝试。`:`自动升级已暂停。请先恢复 Codex 连接、调整版本或等待含有效兼容声明的发行版,再重新检查。`}),(0,W.jsxs)(`div`,{className:`update-buttons`,children:[(0,W.jsx)(q,{variant:`secondary`,disabled:i||p,onClick:()=>void e.check(l),children:i?`正在处理…`:`检查更新`}),(0,W.jsx)(q,{disabled:i||p||!f||!r?.supported||!!x||f.downgrade&&!u||m&&l===r.settings.channel,onClick:()=>void e.start(l,u,b&&v&&f?.codex.version?{version:f.codex.version,target:f.version}:void 0),children:m?`使用此渠道`:f?.downgrade?`切换并重启`:`升级并重启`})]}),f?.downgrade&&(0,W.jsxs)(`label`,{className:`update-downgrade`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),`允许降级;数据库不兼容时仍会阻止切换`]}),r?.run&&(0,W.jsxs)(`section`,{className:`update-progress`,"data-phase":r.run.phase,role:`status`,children:[(0,W.jsx)(`strong`,{children:dT[r.run.phase]}),(0,W.jsxs)(`span`,{children:[r.run.from,` → `,r.run.target]}),(0,W.jsx)(`p`,{children:r.run.message}),p&&(0,W.jsx)(`progress`,{"aria-label":`升级进度`})]}),(a||r?.checkError||o)&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:o??a??r?.checkError}),!r?.supported&&r?.unsupportedReason&&(0,W.jsx)(`p`,{className:`update-notice`,children:r.unsupportedReason}),(0,W.jsxs)(`p`,{className:`update-source`,children:[`版本来源:npm 官方 registry · `,l===`stable`?`latest`:l,(0,W.jsxs)(`a`,{href:`https://github.com/yuzheng14/codex-web-ui/releases`,target:`_blank`,rel:`noreferrer`,children:[`更新记录 `,(0,W.jsx)(de,{size:12,"aria-hidden":`true`})]})]}),(0,W.jsx)(`p`,{className:`subtle`,children:`升级保留配置、项目和会话记录。页面关闭也会继续处理,重启后自动恢复连接。`})]})}function hT(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set(e.map(e=>e.id));return[...e.map(e=>n.get(e.id)??e),...t.filter(e=>!r.has(e.id))]}var gT=class{latest;chunks=[];constructor(e){this.latest=e}update(e){this.latest=e,(!e.history||e.history.olderCursor===null)&&(this.chunks.length=0)}get cursor(){return(this.chunks.length?this.chunks.at(-1).page:this.latest).history?.olderCursor??null}append(e,t){if(t.id!==this.latest.id||t.projectId!==this.latest.projectId)throw Error(`历史分片不属于当前会话。`);if(!(this.cursor!==e||this.chunks.some(t=>t.cursor===e))){if(t.history?.olderCursor&&(t.history.olderCursor===e||this.chunks.some(e=>e.cursor===t.history.olderCursor)))throw Error(`历史分页未前进,请重试同步会话。`);this.chunks.push({cursor:e,page:t})}}replace(e,t){let n=this.chunks.findIndex(t=>t.cursor===e);if(n<0)return this.append(e,t);if(t.id!==this.latest.id||t.projectId!==this.latest.projectId)throw Error(`历史分片不属于当前会话。`);let r=this.chunks[n];this.chunks[n]={cursor:e,page:t},r.page.history?.olderCursor!==t.history?.olderCursor&&this.chunks.splice(n+1)}getHistoryCursor(e){let t=t=>t.turns.some(t=>t.id===e||t.items.some(t=>t.id===e));if(!t(this.latest))return this.chunks.find(e=>t(e.page))?.cursor}get view(){let e=[];for(let t of this.chunks.slice().reverse())e=hT(e,t.page.turns);return{...this.latest,turns:hT(e,this.latest.turns),history:{olderCursor:this.cursor}}}};function _T(e){return{...e,managed:!1,status:`unknown`,actions:[],execution:void 0,resumeError:void 0,runtimeSettings:void 0,turns:e.turns.map(e=>({...e,status:[`running`,`waitingApproval`,`waitingInput`].includes(e.status)?`unknown`:e.status,reconnect:void 0,items:e.items.map(e=>({...e,status:[`running`,`inProgress`].includes(e.status??``)?`unknown`:e.status}))}))}}var vT=new or,yT=(e,t,n,r=`latest`)=>JSON.stringify([e,t,n,r]),bT=class{scope;constructor(e){this.scope=e}async read(e,t,n){let r=await vT.read(yT(this.scope,e,t,n));if(r&&r.id===t&&r.projectId===e&&Array.isArray(r.turns))try{return _T(r)}catch{return}}write(e,t){return vT.write(yT(this.scope,e.projectId,e.id,t),_T(e))}remove(e,t){return vT.remove(([n,r,i])=>n===this.scope&&r===e&&i===t)}};function xT(e,t,n){let{projectId:r,scope:i,forbidden:a}=n,o=(0,O.useMemo)(()=>i?new bT(i):void 0,[i]),s=(0,O.useRef)(void 0),c=(0,O.useRef)(void 0),l=(0,O.useRef)(!1),u=(0,O.useRef)(new Set),d=(0,O.useRef)(!1),f=(0,O.useRef)(void 0),p=(0,O.useRef)(void 0),[m,h]=(0,O.useState)({loading:!1,cached:!1}),g=(0,O.useCallback)((e=!1)=>{h({id:s.current?.latest.id,scope:i,thread:s.current?.view,loading:e,cached:l.current||u.current.size>0,cacheExhausted:d.current,error:p.current})},[i]);(0,O.useEffect)(()=>{c.current?.abort(),c.current=void 0,s.current=void 0,l.current=!1,u.current.clear(),d.current=!1,f.current=void 0,p.current=void 0,h({id:t,scope:i,loading:!1,cached:!1});let e=!0;return t&&!a&&o?.read(r,t).then(t=>{e&&t&&!s.current&&(s.current=new gT(t),l.current=!0,g())}),t&&a&&o?.remove(r,t),()=>{e=!1,c.current?.abort()}},[t,r,o,i,a,g]),(0,O.useEffect)(()=>{e&&e.id===t&&!a&&(s.current?.latest.id===e.id?s.current.update(e):s.current=new gT(e),l.current=!1,s.current.chunks.length||u.current.clear(),g(!!c.current))},[e,t,i,a,g]),(0,O.useEffect)(()=>{if(!e||a||e.id!==t)return;let n=setTimeout(()=>{o?.write(e)},e.status===`running`?750:0);return()=>clearTimeout(n)},[e,t,o,a]);let _=(0,O.useCallback)(async()=>{let e=s.current,t=f.current??e?.cursor;if(!e||!t||c.current||a)return;let n=new AbortController;c.current=n,p.current=void 0,g(!0);try{let i=await o?.read(r,e.latest.id,t);if(n.signal.aborted||s.current!==e)return;i&&e.cursor===t&&(e.append(t,i),u.current.add(t),g(!0));let a=AbortSignal.any([n.signal,AbortSignal.timeout(35e3)]);for(;t;){let r=await ze.threadHistory(e.latest.id,t,a);if(n.signal.aborted||s.current!==e)return;e.replace(t,r),u.current.delete(t);for(let t of u.current)e.chunks.some(e=>e.cursor===t)||u.current.delete(t);f.current=void 0,d.current=!1,o?.write(r,t),t=u.current.values().next().value,g(!!t)}}catch(i){!n.signal.aborted&&s.current===e&&(f.current=t,p.current=En(i),i instanceof Le&&[401,403,404].includes(i.status)&&(o?.remove(r,e.latest.id),s.current=void 0),g())}finally{c.current===n&&(c.current=void 0)}},[g,o,r,a]),v=(0,O.useCallback)(async()=>{let e=s.current,t=e?.cursor;if(!e||!t||!o||c.current||a)return;let n=new AbortController;c.current=n,g(!0);try{let i=await o.read(r,e.latest.id,t);if(n.signal.aborted||s.current!==e)return;i?(e.append(t,i),u.current.add(t)):d.current=!0,g()}finally{c.current===n&&(c.current=void 0)}},[o,r,a,g]),y=(0,O.useCallback)(e=>s.current?.getHistoryCursor(e),[]),b=!a&&m.id===t&&m.scope===i;return{...m,cached:b&&m.cached,loading:b&&m.loading,error:b?m.error:void 0,thread:b?m.thread:void 0,loadOlder:_,loadCachedOlder:v,getHistoryCursor:y}}function ST(){let[e,t]=(0,O.useState)(),[n,r]=(0,O.useState)(),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(),c=(0,O.useRef)(!1),l=(0,O.useRef)(!0),u=(0,O.useRef)(0),d=(0,O.useCallback)(async e=>{if(l.current&&(t(e),r(void 0),e.version!==`unknown`&&e.version!==`0.2.0`&&!c.current&&(!e.run||e.run.committed||[`rolledBack`,`failed`].includes(e.run.phase)))){c.current=!0;try{await wr()}catch(e){c.current=!1,s(e instanceof Error?e.message:`草稿未能备份,暂缓重载页面`)}}},[]);(0,O.useEffect)(()=>{l.current=!0;let e=!0,t=!1,n=async()=>{if(t)return;t=!0;let n=u.current;try{let t=await Re(`/api/updates`);e&&n===u.current&&await d(t)}catch{e&&r(`连接暂时中断,正在等待服务恢复…`)}finally{t=!1}};n();let i=setInterval(()=>void n(),5e3);return()=>{l.current=!1,e=!1,clearInterval(i)}},[d]);let f=(0,O.useCallback)(async(e,t)=>{u.current++,a(!0),r(void 0);try{await d(await Re(e,t))}catch(e){r(e instanceof Error?e.message:`操作未能确认,请查看升级状态`)}finally{a(!1),u.current++}},[d]);return{status:e,error:n,busy:i,reloadError:o,check:e=>f(`/api/updates/check`,{channel:e}),configure:e=>f(`/api/updates/settings`,e),start:(e,t,n)=>f(`/api/updates/run`,{clientOperationId:crypto.randomUUID(),channel:e,allowDowngrade:t,codexConfirmation:n})}}function CT(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function wT(e,t=`|`){return e.map(e=>JT(e)).join(t)}function TT(e,t){return typeof t==`bigint`?t.toString():t}var ET=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function DT(e){return new ET(e)}function OT(e){return e==null}function kT(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function AT(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function jT(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function MT(e){return jT(e._zod.def)??e._zod.def.shape}function NT(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return AT(this,t,e),e},enumerable:!0,configurable:!0})}function PT(e,t,n){t in e?AT(e,t,n):e[t]=n}function FT(e,t,n,r){let i=MT(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?NT(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):PT(e,a,r?r(n.value,a):n.value))}}function IT(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?NT(e,n,()=>t[n]):PT(e,n,r.value))}}function LT(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function RT(e){return JSON.stringify(e)}function zT(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var BT=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function VT(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var HT=DT(()=>{if(RE.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function UT(e){if(VT(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return VT(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function WT(e){return UT(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var GT=new Set([`string`,`number`,`symbol`]);function KT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function qT(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Q(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function JT(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function YT(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var XT={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ZT={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function QT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return FT(i,e,$T(e,t)),qT(e,LT(n,{shape:i,checks:[]}))}function $T(e,t){let n=MT(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function eE(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set($T(e,t)),a={};return FT(a,e,Reflect.ownKeys(MT(e)).filter(e=>!i.has(e))),qT(e,LT(n,{shape:a,checks:[]}))}function tE(e,t){if(!UT(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=MT(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qT(e,LT(e._zod.def,{shape:nE(e,t)}))}function nE(e,t){let n={};return FT(n,e,Reflect.ownKeys(MT(e))),IT(n,t),n}function rE(e,t){if(!UT(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return qT(e,LT(e._zod.def,{shape:nE(e,t)}))}function iE(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return FT(n,e,Reflect.ownKeys(MT(e))),FT(n,t,Reflect.ownKeys(MT(t))),qT(e,LT(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function aE(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set($T(t,n)):void 0,o={};return FT(o,t,Reflect.ownKeys(MT(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),qT(t,LT(t._zod.def,{shape:o,checks:[]}))}function oE(e,t,n){let r=n?new Set($T(t,n)):void 0,i={};return FT(i,t,Reflect.ownKeys(MT(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),qT(t,LT(t._zod.def,{shape:i}))}function sE(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function cE(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function lE(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function uE(e){return typeof e==`string`?e:e?.message}function dE(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function fE(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function pE(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:uE(e.inst?._zod.def?.error?.(e))??uE(a?.(e))??uE(t?.error?.(e))??uE(n.customError?.(e))??uE(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var mE=/[\uD800-\uDBFF]/;function hE(e){let t=e.length;if(!mE.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function gE(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function _E(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function vE(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function yE(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):CE(e,n,r.value)}}function bE(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function xE(e,t,n){return bE(e,t,n,!1)}function SE(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return bE(this,n,r(this))},set(e){bE(this,n,e)}})}return t}function CE(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:bE(this,t,n.bind(this))},set(e){bE(this,t,e)}})}function wE(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var TE,EE=!1,DE={configurable:!0,get(){EE=!0}};function OE(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&TE!==e._zod?TE=void 0:(TE=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,DE);let e=EE;EE=!1;try{let r=n(this);return EE?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),EE||=e,r}catch(n){throw delete this[t],EE||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function kE(e,t,n,r){let i=wE(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var AE=`~constantCatch`;function jE(e){let t=()=>e;return t[AE]=!0,t}var ME,NE={value:void 0,enumerable:!1},PE=`captureStackTrace`in Error?Error:null;function FE(e){let t=PE;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return PE=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function $(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){NE.value=new a(r);try{Object.defineProperty(n,"_zod",NE)}finally{NE.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),yE(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?FE(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var IE=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},LE=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ME=globalThis).__zod_globalConfig??(ME.__zod_globalConfig={});var RE=globalThis.__zod_globalConfig;function zE(e){return e&&Object.assign(RE,e),RE}function BE(){let e=this._zod;return e.message??=JSON.stringify(e.def,TT,2),e.message}function VE(e){this._zod.message=e}var HE={get:BE,set:VE,enumerable:!0,configurable:!0},UE={value:void 0,enumerable:!1},WE=new WeakSet([Object.prototype,Error.prototype]),GE=(e,t)=>{e.name=`$ZodError`,UE.value=t,Object.defineProperty(e,"issues",UE),UE.value=void 0,Object.defineProperty(e,"message",HE);let n=Object.getPrototypeOf(e);WE.has(n)||(WE.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},KE=$(`$ZodError`,GE);$(`$ZodError`,GE,void 0,{Parent:Error});function qE(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function JE(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?qE(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function YE(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function XE(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ZE=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new IE;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>pE(e,o,zE())));throw BT(n,a?.callee??t),n}return s.value};return t},QE=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>pE(e,o,zE())));throw BT(n,a?.callee??t),n}return s.value};return t},$E=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new IE;return a.issues.length?eD(e,a.issues,i):{success:!0,data:a.value}};function eD(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>pE(e,n,zE()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var tD=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?eD(e,a.issues,i):{success:!0,data:a.value}},nD=Symbol.for(`zod.compile.invalid`),rD=Symbol.for(`zod.compile.fallback`),iD=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==nD)return!0;if(r.definite===!0&&n===void 0)return!1}return aD(e,t,n)});function aD(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[rD]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new IE;return a.issues.length===0}var oD=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},sD=e=>{let t=ZE(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,XE(n,a))};return n},cD=e=>{let t=ZE(e),n=(e,r,i,a)=>t(e,r,i,XE(n,a));return n},lD=e=>{let t=QE(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,XE(n,a))};return n},uD=e=>{let t=QE(e),n=async(e,r,i,a)=>await t(e,r,i,XE(n,a));return n},dD=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return $E(e)(t,n,i)},fD=e=>(t,n,r)=>$E(e)(t,n,r),pD=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return tD(e)(t,n,i)},mD=e=>async(t,n,r)=>tD(e)(t,n,r),hD=/^[cC][0-9a-z]{6,}$/,gD=/^[0-9a-z]+$/,_D=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vD=/^[0-9a-vA-V]{20}$/,yD=/^[A-Za-z0-9]{27}$/,bD=/^[a-zA-Z0-9_-]{21}$/;function xD(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var SD=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,CD=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wD=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,TD=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ED=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function DD(){return new RegExp(ED,`u`)}var OD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,kD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,AD=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,jD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,MD=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ND=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,PD=/^https?$/,FD=/^\+[1-9]\d{6,14}$/,ID=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function LD(e){return RegExp(`^${e}$`)}var RD=LD(ID);function zD(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function BD(e){return RegExp(`^${zD(e)}$`)}function VD(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${zD({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${zD({precision:e.precision})}`:n;return RegExp(`^${ID}T(?:${r})$`)}var HD=/^[\s\S]{0,}$/,UD=/^[^A-Z]*$/,WD=/^[^a-z]*$/,GD=$(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),KD=e=>{let t=e.value;return!OT(t)&&t.length!==void 0},qD=$(`$ZodCheckMaxLength`,(e,t)=>{var n;GD.init(e,t),(n=e._zod.def).when??(n.when=KD),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?hE(r):i)<=t.maximum)return;let a=gE(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),JD=$(`$ZodCheckMinLength`,(e,t)=>{var n;GD.init(e,t),(n=e._zod.def).when??(n.when=KD),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?hE(r):i)>=t.minimum)return;let a=gE(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),YD=$(`$ZodCheckLengthEquals`,(e,t)=>{var n;GD.init(e,t),(n=e._zod.def).when??(n.when=KD),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?hE(r):i;if(a===t.length)return;let o=gE(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),XD=$(`$ZodCheckStringFormat`,(e,t)=>{var n,r;GD.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ZD=$(`$ZodCheckRegex`,(e,t)=>{XD.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),QD=$(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=UD,XD.init(e,t)}),$D=$(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=WD,XD.init(e,t)}),eO=$(`$ZodCheckIncludes`,(e,t)=>{GD.init(e,t);let n=KT(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),tO=$(`$ZodCheckStartsWith`,(e,t)=>{GD.init(e,t);let n=RegExp(`^${KT(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),nO=$(`$ZodCheckEndsWith`,(e,t)=>{GD.init(e,t);let n=RegExp(`.*${KT(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),rO=$(`$ZodCheckOverwrite`,(e,t)=>{GD.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),iO=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
85
|
+
`),mode:e.auth.mode,issuer:e.auth.mode===`cloudflare-access`?e.auth.issuer:``,audience:e.auth.mode===`cloudflare-access`?e.auth.audience:``,binary:e.codex.binary,home:e.codex.home??``,requestTimeoutMs:String(e.codex.requestTimeoutMs),maxLineBytes:$w(e.codex.maxLineBytes),eventBytes:$w(e.limits.eventBytes),wsBytes:$w(e.limits.wsBytes),itemBytes:$w(e.limits.itemBytes)}}var nT=e=>e.split(`
|
|
86
|
+
`).map(e=>e.trim()).filter(Boolean),rT=eT.filter(e=>`unit`in e);function iT(e,t){let n=e=>({bytes:NaN,error:`${t.label}:${e}`}),r=e.trim();if(!r)return n(`请输入 MiB 数值。`);if(!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(r)||!Number.isFinite(Number(r)))return n(`请输入有效的 MiB 数值,可使用小数。`);if(Number(r)<1/1024||Number(r)>t.maxMiB)return n(`范围为 ${Zw(t.maxMiB)}。`);let[i,a=``]=r.replace(/^\+/,``).split(`.`),o=a.replace(/0+$/,``),s=()=>n(`MiB 数值必须精确对应整数字节,请调整小数(不会自动舍入)。`);if(o.length>20)return s();let c=10n**BigInt(o.length),l=(BigInt(i||`0`)*c+BigInt(o||`0`))*BigInt(Xw);return l<1024n*c||l>BigInt(t.maxMiB*Xw)*c?n(`范围为 ${Zw(t.maxMiB)}。`):l%c===0n?{bytes:Number(l/c)}:s()}function aT(e){return Object.fromEntries(rT.flatMap(t=>{let{error:n}=iT(e[t.key],t);return n?[[t.key,n]]:[]}))}function oT(e,t){return`unit`in e?`${t} ${e.unit}`:t}function sT(e,t){let n=Object.fromEntries(rT.map(t=>[t.key,iT(e[t.key],t).bytes]));return{...t,host:e.host.trim(),port:Number(e.port),publicOrigin:nT(e.publicOrigin),developmentOrigins:nT(e.developmentOrigins),auth:e.mode===`local`?{mode:`local`}:{mode:e.mode,issuer:e.issuer.trim(),audience:e.audience.trim()},codex:{binary:e.binary.trim(),...e.home.trim()?{home:e.home.trim()}:{},requestTimeoutMs:Number(e.requestTimeoutMs),maxLineBytes:n.maxLineBytes},limits:{eventBytes:n.eventBytes,wsBytes:n.wsBytes,itemBytes:n.itemBytes}}}function cT(e,t){let n=tT(e),r=tT(t);return[...n.mode===r.mode?[]:[{label:`认证模式`,before:n.mode,after:r.mode}],...eT.filter(e=>!([`issuer`,`audience`].includes(e.key)&&r.mode===`local`)&&n[e.key]!==r[e.key]).map(e=>({label:e.label,before:oT(e,n[e.key]),after:oT(e,r[e.key])}))]}var lT=e=>e instanceof Error?e.message:`操作失败,请重试。`;function uT({onClose:e}){let t=(0,O.useRef)(null),n=(0,O.useRef)(null),[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(),[d,f]=(0,O.useState)(!0),[p,m]=(0,O.useState)(``),[h,g]=(0,O.useState)(``),[_,v]=(0,O.useState)({}),[y,b]=(0,O.useState)(!1),[x,S]=(0,O.useState)(!1),C=!!r&&!!a&&JSON.stringify(sT(a,r.saved))!==JSON.stringify(r.saved);(0,O.useEffect)(()=>{t.current?.showModal();let e=new AbortController;return ze.gatewayConfig().then(t=>{e.signal.aborted||(i(t),o(tT(t.saved)))}).catch(t=>{e.signal.aborted||m(lT(t))}).finally(()=>{e.signal.aborted||f(!1)}),()=>{e.abort(),t.current?.close()}},[]),(0,O.useEffect)(()=>{let e=e=>{C&&e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[C]);let w=()=>{d||(C||l?S(!0):e())};async function T(e){f(!0),m(``),g(``);try{await e()}catch(e){m(lT(e)),e instanceof Le&&e.problem.code===`CONFIG_CONFLICT`&&b(!0)}finally{f(!1)}}async function E(){await T(async()=>{let e=await ze.gatewayConfig();i(e),o(tT(e.saved)),v({}),c(void 0),u(void 0),b(!1)})}async function D(e){let t=e.target.files?.[0];e.target.value=``,t&&await T(async()=>{if(t.size>262144)throw Error(`配置文件不能超过 256 KiB。`);let e;try{e=JSON.parse(await t.text())}catch{throw Error(`无法解析 JSON,请检查配置文件格式。`)}u(await ze.importGatewayConfig(e)),c(void 0)})}async function k(){await T(async()=>{let e=await ze.exportGatewayConfig(),t=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`codex-web-config.json`,document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3),g(`已导出配置文件中的已保存配置;未保存的编辑不包含在内。`)})}let A=r&&tT(r.running),j=l?.config??s,M=r&&j?cT(r.saved,j):[];function N(e){if(!a||!A||[`issuer`,`audience`].includes(e.key)&&a.mode!==`cloudflare-access`)return null;let t={id:`gateway-${e.key}`,"aria-labelledby":`gateway-${e.key}-label`,"aria-describedby":`gateway-${e.key}-help${_[e.key]?` gateway-${e.key}-error`:``}`,"aria-invalid":!!_[e.key],value:a[e.key],disabled:d||!r?.writable,onChange:t=>{o({...a,[e.key]:t.target.value}),v(t=>({...t,[e.key]:void 0})),g(``)}};return(0,W.jsxs)(`label`,{className:`project-field`,htmlFor:t.id,children:[(0,W.jsx)(`span`,{id:`gateway-${e.key}-label`,children:e.label}),`multiline`in e?(0,W.jsx)(`textarea`,{...t,rows:3,spellCheck:!1}):(0,W.jsx)(`input`,{...t,type:`type`in e?e.type:`text`,inputMode:`unit`in e?`decimal`:void 0,spellCheck:!1}),(0,W.jsx)(`small`,{id:`gateway-${e.key}-help`,children:e.help}),_[e.key]&&(0,W.jsx)(`small`,{id:`gateway-${e.key}-error`,className:`gateway-error`,role:`alert`,children:_[e.key]}),a[e.key]!==A[e.key]&&(0,W.jsxs)(`small`,{className:`gateway-running`,children:[`当前运行:`,oT(e,A[e.key])||`未设置`]})]},e.key)}return(0,W.jsxs)(`dialog`,{ref:t,className:`project-dialog gateway-dialog`,"aria-labelledby":`gateway-title`,onCancel:e=>{e.preventDefault(),w()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(be,{size:20,"aria-hidden":`true`}),(0,W.jsx)(`h2`,{id:`gateway-title`,children:`服务配置`})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭服务配置`,disabled:d,onClick:w,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsx)(`p`,{className:`gateway-intro`,children:`配置运行此网页服务的电脑。保存后需手动重启服务生效。`}),p&&(0,W.jsx)(`p`,{className:`gateway-error`,role:`alert`,children:p}),!r&&(0,W.jsx)(q,{variant:`secondary`,disabled:d,onClick:()=>void E(),children:d?`正在读取配置…`:`重新读取配置`}),r&&a&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`gateway-file`,children:[(0,W.jsx)(`span`,{children:`配置文件`}),(0,W.jsx)(`code`,{children:r.path})]}),(0,W.jsxs)(`div`,{className:`gateway-status`,role:`status`,"data-pending":r.restartRequired,children:[(0,W.jsx)(`strong`,{children:r.restartRequired?`已保存,待重启生效`:`已保存配置与当前运行配置一致`}),(0,W.jsx)(`span`,{children:`保存不会重启服务或中断当前任务。`})]}),!r.writable&&(0,W.jsx)(`p`,{className:`gateway-error`,children:r.readOnlyReason}),h&&(0,W.jsx)(`p`,{className:`gateway-notice`,role:`status`,children:h}),y&&(0,W.jsxs)(`div`,{className:`gateway-conflict`,children:[(0,W.jsx)(`p`,{children:`重新读取会丢弃当前编辑,并载入文件的最新内容。`}),(0,W.jsx)(q,{variant:`secondary`,disabled:d,onClick:()=>void E(),children:`丢弃编辑并重新读取`})]}),x?(0,W.jsxs)(`section`,{className:`gateway-review`,"aria-label":`放弃编辑确认`,children:[(0,W.jsx)(`h3`,{children:`放弃未保存的更改?`}),(0,W.jsx)(`p`,{children:`配置文件尚未修改。`}),(0,W.jsxs)(`div`,{className:`project-dialog-actions`,children:[(0,W.jsx)(q,{variant:`secondary`,onClick:()=>S(!1),children:`继续编辑`}),(0,W.jsx)(q,{variant:`destructive`,onClick:e,children:`放弃更改并关闭`})]})]}):j?(0,W.jsxs)(`section`,{className:`gateway-review`,"aria-label":l?`导入配置预览`:`保存配置预览`,children:[(0,W.jsx)(`h3`,{children:l?`预览导入配置`:`确认配置更改`}),(0,W.jsx)(`p`,{children:l?`应用到表单后仍需检查并保存,才会修改配置文件。导入将替换当前表单中的可编辑配置。`:`以下更改将在服务重启后生效。请确认新的访问地址和认证配置。`}),l&&(0,W.jsxs)(`p`,{children:[`保留当前数据目录和项目初始配置。`,l.preserved.length>0?`已忽略导入文件中的 ${l.preserved.join(`、`)}。`:``]}),M.length?(0,W.jsx)(`div`,{className:`gateway-changes`,children:M.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsxs)(`span`,{children:[`已保存:`,e.before||`未设置`]}),(0,W.jsxs)(`span`,{children:[`更改为:`,e.after||`未设置`]})]},e.label))}):(0,W.jsx)(`p`,{children:`与已保存配置没有差异。`}),(0,W.jsxs)(`details`,{className:`gateway-json`,children:[(0,W.jsx)(`summary`,{children:`查看完整 JSON`}),(0,W.jsx)(`pre`,{children:JSON.stringify(j,null,2)})]}),(0,W.jsxs)(`div`,{className:`project-dialog-actions`,children:[(0,W.jsx)(q,{variant:`secondary`,disabled:d,onClick:()=>{u(void 0),c(void 0)},children:`返回编辑`}),l?(0,W.jsx)(q,{disabled:d,onClick:()=>{o(tT(l.config)),v({}),u(void 0),g(`导入配置已应用到表单,尚未保存。`)},children:`应用到表单`}):(0,W.jsx)(q,{disabled:d||y||!M.length,onClick:()=>void T(async()=>{let e=await ze.saveGatewayConfig(r.revision,j);i(e),o(tT(e.saved)),c(void 0),g(e.restartRequired?`配置已保存。请在方便时手动重启服务。`:`配置已保存,与当前运行配置一致。`)}),children:d?`正在保存…`:`确认保存`})]})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`gateway-tools`,children:[(0,W.jsxs)(q,{variant:`secondary`,size:`sm`,disabled:d||!r.writable,onClick:()=>n.current?.click(),children:[(0,W.jsx)(we,{size:15,"aria-hidden":`true`}),`导入配置`]}),(0,W.jsxs)(q,{variant:`secondary`,size:`sm`,disabled:d,onClick:()=>void k(),children:[(0,W.jsx)(le,{size:15,"aria-hidden":`true`}),`导出已保存配置`]}),(0,W.jsx)(`input`,{ref:n,type:`file`,accept:`.json,application/json`,"aria-label":`选择配置文件`,hidden:!0,onChange:e=>void D(e)})]}),(0,W.jsx)(`p`,{className:`gateway-help`,children:`导入仅更新服务设置;导出包含文件中的项目初始配置,不包含页面注册项目、会话、数据库或登录凭据。`}),(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=aT(a);v(t);let n=eT.find(e=>t[e.key]);n?requestAnimationFrame(()=>{let e=document.getElementById(`gateway-${n.key}`);e?.closest(`details`)?.setAttribute(`open`,``),e?.focus({preventScroll:!0}),e?.closest(`label`)?.scrollIntoView({block:`center`})}):T(async()=>{c((await ze.importGatewayConfig(sT(a,r.saved))).config)})},children:[(0,W.jsxs)(`fieldset`,{disabled:d||!r.writable,children:[(0,W.jsxs)(`section`,{className:`gateway-section`,children:[(0,W.jsx)(`h3`,{children:`网络与访问`}),(0,W.jsxs)(`div`,{className:`gateway-fields`,children:[eT.filter(e=>e.group===`network`).map(N),(0,W.jsxs)(`label`,{className:`project-field`,children:[(0,W.jsx)(`span`,{children:`认证模式`}),(0,W.jsxs)(`select`,{"aria-label":`认证模式`,value:a.mode,onChange:e=>o({...a,mode:e.target.value}),children:[(0,W.jsx)(`option`,{value:`local`,children:`本机 / Tailscale(local)`}),(0,W.jsx)(`option`,{value:`cloudflare-access`,children:`Cloudflare Access`})]}),(0,W.jsx)(`small`,{children:`本机模式仅监听回环地址;公开互联网入口使用 Cloudflare Access。`}),a.mode!==A?.mode&&(0,W.jsxs)(`small`,{className:`gateway-running`,children:[`当前运行:`,A?.mode]})]})]})]}),(0,W.jsxs)(`section`,{className:`gateway-section`,children:[(0,W.jsx)(`h3`,{children:`Codex`}),(0,W.jsx)(`div`,{className:`gateway-fields`,children:eT.filter(e=>e.group===`codex`).map(N)})]}),(0,W.jsxs)(`section`,{className:`gateway-section`,children:[(0,W.jsx)(`h3`,{children:`数据与项目`}),(0,W.jsxs)(`div`,{className:`gateway-file`,children:[(0,W.jsx)(`span`,{children:`数据目录(只读)`}),(0,W.jsx)(`code`,{children:r.saved.dataDir}),(0,W.jsx)(`span`,{children:`当前运行目录`}),(0,W.jsx)(`code`,{children:r.running.dataDir})]}),(0,W.jsx)(`p`,{className:`gateway-help`,children:`数据目录变更需要迁移数据库,请在服务停止后处理。项目请在侧栏添加、重命名或移除;此处不覆盖已保存的项目管理结果。`})]}),(0,W.jsxs)(`details`,{className:`gateway-section`,children:[(0,W.jsx)(`summary`,{children:`高级设置`}),(0,W.jsx)(`div`,{className:`gateway-fields`,children:eT.filter(e=>e.group===`advanced`).map(N)})]})]}),(0,W.jsxs)(`div`,{className:`gateway-save-bar`,children:[(0,W.jsx)(`span`,{children:C?`有未保存的更改`:`没有未保存的更改`}),(0,W.jsx)(q,{type:`submit`,disabled:d||!C||!r.writable||y,children:d?`正在校验…`:`检查更改`})]})]})]})]})]})}var dT=[`stable`,`beta`,`dev`],fT=e=>!!(e&&[`installing`,`waiting`,`stopping`,`verifying`].includes(e.phase)),pT={stable:`稳定版`,beta:`预览版`,dev:`开发版`},mT={installing:`正在安装候选版本`,waiting:`等待任务空闲`,stopping:`正在备份并重启`,verifying:`正在验证新版`,succeeded:`升级成功`,rolledBack:`已恢复上一版本`,failed:`升级失败`},hT={verified:`已验证`,unverified:`尚未验证`,unsupported:`明确不支持`,unknown:`无法确认`};function gT({title:e,value:t}){return(0,W.jsxs)(`section`,{className:`update-codex`,"aria-label":e,"data-state":t.status,children:[(0,W.jsx)(`h3`,{children:e}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:`Codex CLI`}),(0,W.jsx)(`strong`,{children:t.version??`未识别`}),(0,W.jsx)(`span`,{className:`update-codex-status`,children:hT[t.status]})]}),t.manifest&&(0,W.jsxs)(`p`,{className:`subtle`,children:[`推荐:`,t.manifest.recommended,` · 已验证:`,t.manifest.verified.join(`、`)]}),t.reason&&(0,W.jsx)(`p`,{children:t.reason})]})}function _T({updates:e,onClose:t}){let n=(0,O.useRef)(null),{status:r,busy:i,error:a,reloadError:o}=e,[s,c]=(0,O.useState)(),l=s??r?.settings.channel??`stable`,[u,d]=(0,O.useState)(!1),f=r?.available?.channel===l?r.available:void 0,p=fT(r?.run),m=f?.version===r?.version,[h,g]=(0,O.useState)(),_=JSON.stringify([l,f?.version,f?.codex]),v=h===_,y=f?.codex,b=!m&&y?.status===`unverified`,x=!m&&f&&(!y||y.status===`unknown`||y.status===`unsupported`||b&&!v);return(0,O.useEffect)(()=>{g(void 0)},[_]),(0,O.useEffect)(()=>{let e=n.current;return e?.showModal(),()=>e?.close()},[]),(0,W.jsxs)(`dialog`,{ref:n,className:`project-dialog update-dialog`,"aria-labelledby":`update-title`,onCancel:e=>{e.preventDefault(),t()},children:[(0,W.jsxs)(`div`,{className:`project-dialog-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(ae,{size:20,"aria-hidden":`true`}),(0,W.jsx)(`h2`,{id:`update-title`,children:`Covro 更新`})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭更新设置`,onClick:t,children:(0,W.jsx)(J,{name:`close`,size:17})})]}),(0,W.jsxs)(`div`,{className:`update-version`,children:[(0,W.jsx)(`span`,{children:`当前 Covro`}),(0,W.jsx)(`strong`,{children:r?.version??`读取中…`}),r?.commit&&(0,W.jsx)(`code`,{children:r.commit.slice(0,8)})]}),r?.codex&&(0,W.jsx)(gT,{title:`当前 Codex`,value:r.codex}),(0,W.jsxs)(`label`,{className:`update-channel`,children:[`版本渠道`,(0,W.jsx)(`select`,{"aria-label":`版本渠道`,value:l,disabled:i||p,onChange:t=>{let n=t.target.value;c(n),d(!1),g(void 0),e.check(n)},children:dT.map(e=>(0,W.jsx)(`option`,{value:e,children:pT[e]},e))})]}),(0,W.jsx)(`p`,{className:`subtle`,children:l===`stable`?`经过验证的正式版本,适合日常使用。`:l===`beta`?`提前体验准备发布的功能。`:`跟随通过检查的 main 提交,适合开发者体验和验证新功能。`}),(0,W.jsxs)(`div`,{className:`update-control`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`空闲时自动升级`}),(0,W.jsx)(`p`,{className:`subtle`,children:`定期检查当前渠道,已验证的 Codex 组合在任务结束后安装并重启。`})]}),(0,W.jsx)(q,{role:`switch`,"aria-label":`空闲时自动升级`,"aria-checked":r?.settings.automatic??!1,variant:`secondary`,size:`sm`,disabled:i||p||!r?.supported,onClick:()=>r&&void e.configure({...r.settings,automatic:!r.settings.automatic}),children:r?.settings.automatic?`已开启`:`已关闭`})]}),r&&l!==r.settings.channel&&(0,W.jsxs)(`p`,{className:`subtle`,children:[`当前订阅:`,pT[r.settings.channel],`。成功更新后切换到`,pT[l],`。`]}),f&&(0,W.jsxs)(`div`,{className:`update-available`,children:[(0,W.jsx)(`span`,{children:m?`此渠道已是当前版本`:f.downgrade?`目标版本`:`可用版本`}),(0,W.jsx)(`strong`,{children:f.version}),f.commit&&(0,W.jsx)(`code`,{children:f.commit.slice(0,8)})]}),f?.codex&&(0,W.jsx)(gT,{title:`目标版本兼容性`,value:f.codex}),b&&(0,W.jsxs)(`label`,{className:`update-downgrade update-codex-consent`,children:[(0,W.jsx)(`input`,{type:`checkbox`,"aria-label":`允许尝试未验证的 Codex 组合`,checked:v,disabled:i||p,onChange:e=>g(e.target.checked?_:void 0)}),`我确认尝试 Codex `,y?.version,` 与 Covro `,f?.version,` `,`的未验证组合;此确认仅用于本次升级。`]}),f&&!m&&f.channel===r?.settings.channel&&r.settings.automatic&&y?.status!==`verified`&&(0,W.jsx)(`p`,{className:`update-notice`,role:`status`,children:y?.status===`unverified`?`自动升级已暂停。可以调整 Codex 版本后重新检查,或勾选确认后手动尝试。`:`自动升级已暂停。请先恢复 Codex 连接、调整版本或等待含有效兼容声明的发行版,再重新检查。`}),(0,W.jsxs)(`div`,{className:`update-buttons`,children:[(0,W.jsx)(q,{variant:`secondary`,disabled:i||p,onClick:()=>void e.check(l),children:i?`正在处理…`:`检查更新`}),(0,W.jsx)(q,{disabled:i||p||!f||!r?.supported||!!x||f.downgrade&&!u||m&&l===r.settings.channel,onClick:()=>void e.start(l,u,b&&v&&f?.codex.version?{version:f.codex.version,target:f.version}:void 0),children:m?`使用此渠道`:f?.downgrade?`切换并重启`:`升级并重启`})]}),f?.downgrade&&(0,W.jsxs)(`label`,{className:`update-downgrade`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),`允许降级;数据库不兼容时仍会阻止切换`]}),r?.run&&(0,W.jsxs)(`section`,{className:`update-progress`,"data-phase":r.run.phase,role:`status`,children:[(0,W.jsx)(`strong`,{children:mT[r.run.phase]}),(0,W.jsxs)(`span`,{children:[r.run.from,` → `,r.run.target]}),(0,W.jsx)(`p`,{children:r.run.message}),p&&(0,W.jsx)(`progress`,{"aria-label":`升级进度`})]}),(a||r?.checkError||o)&&(0,W.jsx)(`p`,{className:`inline-error`,role:`alert`,children:o??a??r?.checkError}),!r?.supported&&r?.unsupportedReason&&(0,W.jsx)(`p`,{className:`update-notice`,children:r.unsupportedReason}),(0,W.jsxs)(`p`,{className:`update-source`,children:[`版本来源:npm 官方 registry · `,l===`stable`?`latest`:l,(0,W.jsxs)(`a`,{href:`https://github.com/yuzheng14/codex-web-ui/releases`,target:`_blank`,rel:`noreferrer`,children:[`更新记录 `,(0,W.jsx)(de,{size:12,"aria-hidden":`true`})]})]}),(0,W.jsx)(`p`,{className:`subtle`,children:`升级保留配置、项目和会话记录。页面关闭也会继续处理,重启后自动恢复连接。`})]})}function vT(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Set(e.map(e=>e.id));return[...e.map(e=>n.get(e.id)??e),...t.filter(e=>!r.has(e.id))]}var yT=class{latest;chunks=[];constructor(e){this.latest=e}update(e){this.latest=e,(!e.history||e.history.olderCursor===null)&&(this.chunks.length=0)}get cursor(){return(this.chunks.length?this.chunks.at(-1).page:this.latest).history?.olderCursor??null}append(e,t){if(t.id!==this.latest.id||t.projectId!==this.latest.projectId)throw Error(`历史分片不属于当前会话。`);if(!(this.cursor!==e||this.chunks.some(t=>t.cursor===e))){if(t.history?.olderCursor&&(t.history.olderCursor===e||this.chunks.some(e=>e.cursor===t.history.olderCursor)))throw Error(`历史分页未前进,请重试同步会话。`);this.chunks.push({cursor:e,page:t})}}replace(e,t){let n=this.chunks.findIndex(t=>t.cursor===e);if(n<0)return this.append(e,t);if(t.id!==this.latest.id||t.projectId!==this.latest.projectId)throw Error(`历史分片不属于当前会话。`);let r=this.chunks[n];this.chunks[n]={cursor:e,page:t},r.page.history?.olderCursor!==t.history?.olderCursor&&this.chunks.splice(n+1)}getHistoryCursor(e){let t=t=>t.turns.some(t=>t.id===e||t.items.some(t=>t.id===e));if(!t(this.latest))return this.chunks.find(e=>t(e.page))?.cursor}get view(){let e=[];for(let t of this.chunks.slice().reverse())e=vT(e,t.page.turns);return{...this.latest,turns:vT(e,this.latest.turns),history:{olderCursor:this.cursor}}}};function bT(e){return{...e,managed:!1,status:`unknown`,actions:[],execution:void 0,resumeError:void 0,runtimeSettings:void 0,turns:e.turns.map(e=>({...e,status:[`running`,`waitingApproval`,`waitingInput`].includes(e.status)?`unknown`:e.status,reconnect:void 0,items:e.items.map(e=>({...e,status:[`running`,`inProgress`].includes(e.status??``)?`unknown`:e.status}))}))}}var xT=new or,ST=(e,t,n,r=`latest`)=>JSON.stringify([e,t,n,r]),CT=class{scope;constructor(e){this.scope=e}async read(e,t,n){let r=await xT.read(ST(this.scope,e,t,n));if(r&&r.id===t&&r.projectId===e&&Array.isArray(r.turns))try{return bT(r)}catch{return}}write(e,t){return xT.write(ST(this.scope,e.projectId,e.id,t),bT(e))}remove(e,t){return xT.remove(([n,r,i])=>n===this.scope&&r===e&&i===t)}};function wT(e,t,n){let{projectId:r,scope:i,forbidden:a}=n,o=(0,O.useMemo)(()=>i?new CT(i):void 0,[i]),s=(0,O.useRef)(void 0),c=(0,O.useRef)(void 0),l=(0,O.useRef)(!1),u=(0,O.useRef)(new Set),d=(0,O.useRef)(!1),f=(0,O.useRef)(void 0),p=(0,O.useRef)(void 0),[m,h]=(0,O.useState)({loading:!1,cached:!1}),g=(0,O.useCallback)((e=!1)=>{h({id:s.current?.latest.id,scope:i,thread:s.current?.view,loading:e,cached:l.current||u.current.size>0,cacheExhausted:d.current,error:p.current})},[i]);(0,O.useEffect)(()=>{c.current?.abort(),c.current=void 0,s.current=void 0,l.current=!1,u.current.clear(),d.current=!1,f.current=void 0,p.current=void 0,h({id:t,scope:i,loading:!1,cached:!1});let e=!0;return t&&!a&&o?.read(r,t).then(t=>{e&&t&&!s.current&&(s.current=new yT(t),l.current=!0,g())}),t&&a&&o?.remove(r,t),()=>{e=!1,c.current?.abort()}},[t,r,o,i,a,g]),(0,O.useEffect)(()=>{e&&e.id===t&&!a&&(s.current?.latest.id===e.id?s.current.update(e):s.current=new yT(e),l.current=!1,s.current.chunks.length||u.current.clear(),g(!!c.current))},[e,t,i,a,g]),(0,O.useEffect)(()=>{if(!e||a||e.id!==t)return;let n=setTimeout(()=>{o?.write(e)},e.status===`running`?750:0);return()=>clearTimeout(n)},[e,t,o,a]);let _=(0,O.useCallback)(async()=>{let e=s.current,t=f.current??e?.cursor;if(!e||!t||c.current||a)return;let n=new AbortController;c.current=n,p.current=void 0,g(!0);try{let i=await o?.read(r,e.latest.id,t);if(n.signal.aborted||s.current!==e)return;i&&e.cursor===t&&(e.append(t,i),u.current.add(t),g(!0));let a=AbortSignal.any([n.signal,AbortSignal.timeout(35e3)]);for(;t;){let r=await ze.threadHistory(e.latest.id,t,a);if(n.signal.aborted||s.current!==e)return;e.replace(t,r),u.current.delete(t);for(let t of u.current)e.chunks.some(e=>e.cursor===t)||u.current.delete(t);f.current=void 0,d.current=!1,o?.write(r,t),t=u.current.values().next().value,g(!!t)}}catch(i){!n.signal.aborted&&s.current===e&&(f.current=t,p.current=En(i),i instanceof Le&&[401,403,404].includes(i.status)&&(o?.remove(r,e.latest.id),s.current=void 0),g())}finally{c.current===n&&(c.current=void 0)}},[g,o,r,a]),v=(0,O.useCallback)(async()=>{let e=s.current,t=e?.cursor;if(!e||!t||!o||c.current||a)return;let n=new AbortController;c.current=n,g(!0);try{let i=await o.read(r,e.latest.id,t);if(n.signal.aborted||s.current!==e)return;i?(e.append(t,i),u.current.add(t)):d.current=!0,g()}finally{c.current===n&&(c.current=void 0)}},[o,r,a,g]),y=(0,O.useCallback)(e=>s.current?.getHistoryCursor(e),[]),b=!a&&m.id===t&&m.scope===i;return{...m,cached:b&&m.cached,loading:b&&m.loading,error:b?m.error:void 0,thread:b?m.thread:void 0,loadOlder:_,loadCachedOlder:v,getHistoryCursor:y}}function TT(){let[e,t]=(0,O.useState)(),[n,r]=(0,O.useState)(),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(),c=(0,O.useRef)(!1),l=(0,O.useRef)(!0),u=(0,O.useRef)(0),d=(0,O.useCallback)(async e=>{if(l.current&&(t(e),r(void 0),e.version!==`unknown`&&e.version!==`0.2.1-dev.2`&&!c.current&&(!e.run||e.run.committed||[`rolledBack`,`failed`].includes(e.run.phase)))){c.current=!0;try{await wr()}catch(e){c.current=!1,s(e instanceof Error?e.message:`草稿未能备份,暂缓重载页面`)}}},[]);(0,O.useEffect)(()=>{l.current=!0;let e=!0,t=!1,n=async()=>{if(t)return;t=!0;let n=u.current;try{let t=await Re(`/api/updates`);e&&n===u.current&&await d(t)}catch{e&&r(`连接暂时中断,正在等待服务恢复…`)}finally{t=!1}};n();let i=setInterval(()=>void n(),5e3);return()=>{l.current=!1,e=!1,clearInterval(i)}},[d]);let f=(0,O.useCallback)(async(e,t)=>{u.current++,a(!0),r(void 0);try{await d(await Re(e,t))}catch(e){r(e instanceof Error?e.message:`操作未能确认,请查看升级状态`)}finally{a(!1),u.current++}},[d]);return{status:e,error:n,busy:i,reloadError:o,check:e=>f(`/api/updates/check`,{channel:e}),configure:e=>f(`/api/updates/settings`,e),start:(e,t,n)=>f(`/api/updates/run`,{clientOperationId:crypto.randomUUID(),channel:e,allowDowngrade:t,codexConfirmation:n})}}function ET(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function DT(e,t=`|`){return e.map(e=>ZT(e)).join(t)}function OT(e,t){return typeof t==`bigint`?t.toString():t}var kT=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function AT(e){return new kT(e)}function jT(e){return e==null}function MT(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function NT(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function PT(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function FT(e){return PT(e._zod.def)??e._zod.def.shape}function IT(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return NT(this,t,e),e},enumerable:!0,configurable:!0})}function LT(e,t,n){t in e?NT(e,t,n):e[t]=n}function RT(e,t,n,r){let i=FT(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?IT(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):LT(e,a,r?r(n.value,a):n.value))}}function zT(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?IT(e,n,()=>t[n]):LT(e,n,r.value))}}function BT(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function VT(e){return JSON.stringify(e)}function HT(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var UT=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function WT(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var GT=AT(()=>{if(VE.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function KT(e){if(WT(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return WT(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function qT(e){return KT(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var JT=new Set([`string`,`number`,`symbol`]);function YT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function XT(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Q(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ZT(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function QT(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var $T={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},eE={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function tE(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return RT(i,e,nE(e,t)),XT(e,BT(n,{shape:i,checks:[]}))}function nE(e,t){let n=FT(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function rE(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(nE(e,t)),a={};return RT(a,e,Reflect.ownKeys(FT(e)).filter(e=>!i.has(e))),XT(e,BT(n,{shape:a,checks:[]}))}function iE(e,t){if(!KT(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=FT(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return XT(e,BT(e._zod.def,{shape:aE(e,t)}))}function aE(e,t){let n={};return RT(n,e,Reflect.ownKeys(FT(e))),zT(n,t),n}function oE(e,t){if(!KT(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return XT(e,BT(e._zod.def,{shape:aE(e,t)}))}function sE(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return RT(n,e,Reflect.ownKeys(FT(e))),RT(n,t,Reflect.ownKeys(FT(t))),XT(e,BT(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function cE(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(nE(t,n)):void 0,o={};return RT(o,t,Reflect.ownKeys(FT(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),XT(t,BT(t._zod.def,{shape:o,checks:[]}))}function lE(e,t,n){let r=n?new Set(nE(t,n)):void 0,i={};return RT(i,t,Reflect.ownKeys(FT(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),XT(t,BT(t._zod.def,{shape:i}))}function uE(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function dE(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function fE(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function pE(e){return typeof e==`string`?e:e?.message}function mE(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function hE(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function gE(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:pE(e.inst?._zod.def?.error?.(e))??pE(a?.(e))??pE(t?.error?.(e))??pE(n.customError?.(e))??pE(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var _E=/[\uD800-\uDBFF]/;function vE(e){let t=e.length;if(!_E.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function yE(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function bE(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function xE(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function SE(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):EE(e,n,r.value)}}function CE(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function wE(e,t,n){return CE(e,t,n,!1)}function TE(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return CE(this,n,r(this))},set(e){CE(this,n,e)}})}return t}function EE(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:CE(this,t,n.bind(this))},set(e){CE(this,t,e)}})}function DE(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var OE,kE=!1,AE={configurable:!0,get(){kE=!0}};function jE(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&OE!==e._zod?OE=void 0:(OE=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,AE);let e=kE;kE=!1;try{let r=n(this);return kE?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),kE||=e,r}catch(n){throw delete this[t],kE||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function ME(e,t,n,r){let i=DE(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var NE=`~constantCatch`;function PE(e){let t=()=>e;return t[NE]=!0,t}var FE,IE={value:void 0,enumerable:!1},LE=`captureStackTrace`in Error?Error:null;function RE(e){let t=LE;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return LE=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function $(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){IE.value=new a(r);try{Object.defineProperty(n,"_zod",IE)}finally{IE.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),SE(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?RE(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var zE=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},BE=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(FE=globalThis).__zod_globalConfig??(FE.__zod_globalConfig={});var VE=globalThis.__zod_globalConfig;function HE(e){return e&&Object.assign(VE,e),VE}function UE(){let e=this._zod;return e.message??=JSON.stringify(e.def,OT,2),e.message}function WE(e){this._zod.message=e}var GE={get:UE,set:WE,enumerable:!0,configurable:!0},KE={value:void 0,enumerable:!1},qE=new WeakSet([Object.prototype,Error.prototype]),JE=(e,t)=>{e.name=`$ZodError`,KE.value=t,Object.defineProperty(e,"issues",KE),KE.value=void 0,Object.defineProperty(e,"message",GE);let n=Object.getPrototypeOf(e);qE.has(n)||(qE.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},YE=$(`$ZodError`,JE);$(`$ZodError`,JE,void 0,{Parent:Error});function XE(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ZE(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?XE(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function QE(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function $E(e,t){return{callee:t?.callee??e,Err:t?.Err}}var eD=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new zE;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>gE(e,o,HE())));throw UT(n,a?.callee??t),n}return s.value};return t},tD=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>gE(e,o,HE())));throw UT(n,a?.callee??t),n}return s.value};return t},nD=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new zE;return a.issues.length?rD(e,a.issues,i):{success:!0,data:a.value}};function rD(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>gE(e,n,HE()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var iD=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?rD(e,a.issues,i):{success:!0,data:a.value}},aD=Symbol.for(`zod.compile.invalid`),oD=Symbol.for(`zod.compile.fallback`),sD=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==aD)return!0;if(r.definite===!0&&n===void 0)return!1}return cD(e,t,n)});function cD(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[oD]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new zE;return a.issues.length===0}var lD=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},uD=e=>{let t=eD(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,$E(n,a))};return n},dD=e=>{let t=eD(e),n=(e,r,i,a)=>t(e,r,i,$E(n,a));return n},fD=e=>{let t=tD(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,$E(n,a))};return n},pD=e=>{let t=tD(e),n=async(e,r,i,a)=>await t(e,r,i,$E(n,a));return n},mD=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return nD(e)(t,n,i)},hD=e=>(t,n,r)=>nD(e)(t,n,r),gD=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return iD(e)(t,n,i)},_D=e=>async(t,n,r)=>iD(e)(t,n,r),vD=/^[cC][0-9a-z]{6,}$/,yD=/^[0-9a-z]+$/,bD=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,xD=/^[0-9a-vA-V]{20}$/,SD=/^[A-Za-z0-9]{27}$/,CD=/^[a-zA-Z0-9_-]{21}$/;function wD(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var TD=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ED=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,DD=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,OD=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,kD=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function AD(){return new RegExp(kD,`u`)}var jD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,MD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ND=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,PD=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,FD=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ID=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,LD=/^https?$/,RD=/^\+[1-9]\d{6,14}$/,zD=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function BD(e){return RegExp(`^${e}$`)}var VD=BD(zD);function HD(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function UD(e){return RegExp(`^${HD(e)}$`)}function WD(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${HD({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${HD({precision:e.precision})}`:n;return RegExp(`^${zD}T(?:${r})$`)}var GD=/^[\s\S]{0,}$/,KD=/^[^A-Z]*$/,qD=/^[^a-z]*$/,JD=$(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),YD=e=>{let t=e.value;return!jT(t)&&t.length!==void 0},XD=$(`$ZodCheckMaxLength`,(e,t)=>{var n;JD.init(e,t),(n=e._zod.def).when??(n.when=YD),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?vE(r):i)<=t.maximum)return;let a=yE(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ZD=$(`$ZodCheckMinLength`,(e,t)=>{var n;JD.init(e,t),(n=e._zod.def).when??(n.when=YD),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?vE(r):i)>=t.minimum)return;let a=yE(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),QD=$(`$ZodCheckLengthEquals`,(e,t)=>{var n;JD.init(e,t),(n=e._zod.def).when??(n.when=YD),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?vE(r):i;if(a===t.length)return;let o=yE(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$D=$(`$ZodCheckStringFormat`,(e,t)=>{var n,r;JD.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),eO=$(`$ZodCheckRegex`,(e,t)=>{$D.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tO=$(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=KD,$D.init(e,t)}),nO=$(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=qD,$D.init(e,t)}),rO=$(`$ZodCheckIncludes`,(e,t)=>{JD.init(e,t);let n=YT(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),iO=$(`$ZodCheckStartsWith`,(e,t)=>{JD.init(e,t);let n=RegExp(`^${YT(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),aO=$(`$ZodCheckEndsWith`,(e,t)=>{JD.init(e,t);let n=RegExp(`.*${YT(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),oO=$(`$ZodCheckOverwrite`,(e,t)=>{JD.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),sO=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
87
87
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
88
|
-
`)}\n};`)(...Object.values(this.closed))}},aO={major:4,minor:6,patch:6},oO=$(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=aO;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=sE(t),a;for(let o of n){if(o._zod.def.when){if(cE(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new IE;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(fE(t.issues,n,e),i||=sE(t,n))});else{if(t.issues.length===n)continue;fE(t.issues,n,e),i||=sE(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(sE(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new IE;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new IE;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return xE(this,`~standard`,lO(this))},set"~standard"(e){bE(this,`~standard`,e)}}),sO=(e,t)=>e.issues.length?{issues:e.issues.map(e=>pE(e,t,zE()))}:{value:e.value};async function cO(e,t){let n={async:!0};return sO(await e._zod.run({value:t,issues:[]},n),n)}function lO(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return sO(r,n)}catch{}return cO(e,t)},vendor:`zod`,version:1}}var uO=$(`$ZodString`,(e,t)=>{oO.init(e,t),e._zod.pattern=t.pattern??HD,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),dO=$(`$ZodStringFormat`,(e,t)=>{XD.init(e,t),uO.init(e,t)}),fO=$(`$ZodGUID`,(e,t)=>{t.pattern??=CD,dO.init(e,t)}),pO=$(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=wD(e)}else t.pattern??=wD();dO.init(e,t)}),mO=$(`$ZodEmail`,(e,t)=>{t.pattern??=TD,dO.init(e,t)});function hO(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function gO(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?hO(e)||2:_O(e,t)}function _O(e,t){if(!t.normalize&&t.protocol?.source===PD.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var vO=/[\t\n\r]/g;function yO(e){return e.replace(vO,``)}function bO(e,t){return t.lastIndex=0,t.test(e.hostname)}function xO(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var SO=$(`$ZodURL`,(e,t)=>{dO.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=gO(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=yO(r);return}t.hostname&&!bO(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!xO(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:yO(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),CO=$(`$ZodEmoji`,(e,t)=>{t.pattern??=DD(),dO.init(e,t)}),wO=$(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?bD:xD(t.length),dO.init(e,t)}),TO=$(`$ZodCUID`,(e,t)=>{t.pattern??=hD,dO.init(e,t)}),EO=$(`$ZodCUID2`,(e,t)=>{t.pattern??=gD,dO.init(e,t)}),DO=$(`$ZodULID`,(e,t)=>{t.pattern??=_D,dO.init(e,t)}),OO=$(`$ZodXID`,(e,t)=>{t.pattern??=vD,dO.init(e,t)}),kO=$(`$ZodKSUID`,(e,t)=>{t.pattern??=yD,dO.init(e,t)}),AO=$(`$ZodISODateTime`,(e,t)=>{t.pattern??=VD(t),dO.init(e,t)}),jO=$(`$ZodISODate`,(e,t)=>{t.pattern??=RD,dO.init(e,t)}),MO=$(`$ZodISOTime`,(e,t)=>{t.pattern??=BD(t),dO.init(e,t)}),NO=$(`$ZodISODuration`,(e,t)=>{t.pattern??=SD,dO.init(e,t)}),PO=$(`$ZodIPv4`,(e,t)=>{t.pattern??=OD,dO.init(e,t)}),FO=/^[0-9a-fA-F:.]+$/;function IO(e){return FO.test(e)?hO(`http://[${e}]`):!1}var LO=$(`$ZodIPv6`,(e,t)=>{t.pattern??=kD,dO.init(e,t),e._zod.check=n=>{IO(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),RO=$(`$ZodCIDRv4`,(e,t)=>{t.pattern??=AD,dO.init(e,t)});function zO(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:IO(n)}var BO=$(`$ZodCIDRv6`,(e,t)=>{t.pattern??=jD,dO.init(e,t),e._zod.check=n=>{zO(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function VO(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var HO=/^[0-9a-zA-Z+/]*={0,2}$/,UO=$(`$ZodBase64`,(e,t)=>{t.pattern??=HO,dO.init(e,t),e._zod.check=n=>{VO(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),WO=/^[A-Za-z0-9_-]*$/;function GO(e){if(!WO.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return VO(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var KO=$(`$ZodBase64URL`,(e,t)=>{t.pattern??=WO,dO.init(e,t),e._zod.check=n=>{GO(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),qO=$(`$ZodE164`,(e,t)=>{t.pattern??=FD,dO.init(e,t)});function JO(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var YO=$(`$ZodJWT`,(e,t)=>{dO.init(e,t),e._zod.check=n=>{JO(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),XO=$(`$ZodUnknown`,(e,t)=>{oO.init(e,t),e._zod.parse=e=>e}),ZO=$(`$ZodNever`,(e,t)=>{oO.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function QO(e,t){let n=dE(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of dE(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,fE(n.issues,t,e),n}}return i(n,a)}}var $O=e=>Array.isArray(e)?e.length:-1;function ek(e,t,n){e.issues.length&&t.issues.push(...lE(n,e.issues)),t.value[n]=e.value}var tk=$(`$ZodArray`,(e,t)=>{oO.init(e,t);let n=RE.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>ek(t,r,e)));else if(ek(c,r,e),s&&c.issues.length!==0&&sE(c))break}return o.length?Promise.all(o).then(()=>r):r},QO(e,$O)});function nk(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...lE(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var rk=[];function ik(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:rk,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=YT(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ak(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(sE(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>nk(e,n,i,t,d,f))):nk(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var ok=$(`$ZodObject`,(e,t)=>{oO.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=DT(()=>ik(t));OE(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||AT(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=VT,o=t.catchall,s,c=RE.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(sE(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>nk(n,t,e,r,a,o))):nk(s,t,e,r,a,o)}return o?ak(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),sk=$(`$ZodObjectJIT`,(e,t)=>{ok.init(e,t);let n=e._zod.parse,r=DT(()=>ik(t)),i=RE.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new iO([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
88
|
+
`)}\n};`)(...Object.values(this.closed))}},cO={major:4,minor:6,patch:6},lO=$(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=cO;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=uE(t),a;for(let o of n){if(o._zod.def.when){if(dE(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new zE;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(hE(t.issues,n,e),i||=uE(t,n))});else{if(t.issues.length===n)continue;hE(t.issues,n,e),i||=uE(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(uE(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new zE;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new zE;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return wE(this,`~standard`,fO(this))},set"~standard"(e){CE(this,`~standard`,e)}}),uO=(e,t)=>e.issues.length?{issues:e.issues.map(e=>gE(e,t,HE()))}:{value:e.value};async function dO(e,t){let n={async:!0};return uO(await e._zod.run({value:t,issues:[]},n),n)}function fO(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return uO(r,n)}catch{}return dO(e,t)},vendor:`zod`,version:1}}var pO=$(`$ZodString`,(e,t)=>{lO.init(e,t),e._zod.pattern=t.pattern??GD,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),mO=$(`$ZodStringFormat`,(e,t)=>{$D.init(e,t),pO.init(e,t)}),hO=$(`$ZodGUID`,(e,t)=>{t.pattern??=ED,mO.init(e,t)}),gO=$(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=DD(e)}else t.pattern??=DD();mO.init(e,t)}),_O=$(`$ZodEmail`,(e,t)=>{t.pattern??=OD,mO.init(e,t)});function vO(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function yO(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?vO(e)||2:bO(e,t)}function bO(e,t){if(!t.normalize&&t.protocol?.source===LD.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var xO=/[\t\n\r]/g;function SO(e){return e.replace(xO,``)}function CO(e,t){return t.lastIndex=0,t.test(e.hostname)}function wO(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var TO=$(`$ZodURL`,(e,t)=>{mO.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=yO(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=SO(r);return}t.hostname&&!CO(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!wO(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:SO(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),EO=$(`$ZodEmoji`,(e,t)=>{t.pattern??=AD(),mO.init(e,t)}),DO=$(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?CD:wD(t.length),mO.init(e,t)}),OO=$(`$ZodCUID`,(e,t)=>{t.pattern??=vD,mO.init(e,t)}),kO=$(`$ZodCUID2`,(e,t)=>{t.pattern??=yD,mO.init(e,t)}),AO=$(`$ZodULID`,(e,t)=>{t.pattern??=bD,mO.init(e,t)}),jO=$(`$ZodXID`,(e,t)=>{t.pattern??=xD,mO.init(e,t)}),MO=$(`$ZodKSUID`,(e,t)=>{t.pattern??=SD,mO.init(e,t)}),NO=$(`$ZodISODateTime`,(e,t)=>{t.pattern??=WD(t),mO.init(e,t)}),PO=$(`$ZodISODate`,(e,t)=>{t.pattern??=VD,mO.init(e,t)}),FO=$(`$ZodISOTime`,(e,t)=>{t.pattern??=UD(t),mO.init(e,t)}),IO=$(`$ZodISODuration`,(e,t)=>{t.pattern??=TD,mO.init(e,t)}),LO=$(`$ZodIPv4`,(e,t)=>{t.pattern??=jD,mO.init(e,t)}),RO=/^[0-9a-fA-F:.]+$/;function zO(e){return RO.test(e)?vO(`http://[${e}]`):!1}var BO=$(`$ZodIPv6`,(e,t)=>{t.pattern??=MD,mO.init(e,t),e._zod.check=n=>{zO(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),VO=$(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ND,mO.init(e,t)});function HO(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:zO(n)}var UO=$(`$ZodCIDRv6`,(e,t)=>{t.pattern??=PD,mO.init(e,t),e._zod.check=n=>{HO(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function WO(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var GO=/^[0-9a-zA-Z+/]*={0,2}$/,KO=$(`$ZodBase64`,(e,t)=>{t.pattern??=GO,mO.init(e,t),e._zod.check=n=>{WO(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),qO=/^[A-Za-z0-9_-]*$/;function JO(e){if(!qO.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return WO(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var YO=$(`$ZodBase64URL`,(e,t)=>{t.pattern??=qO,mO.init(e,t),e._zod.check=n=>{JO(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),XO=$(`$ZodE164`,(e,t)=>{t.pattern??=RD,mO.init(e,t)});function ZO(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var QO=$(`$ZodJWT`,(e,t)=>{mO.init(e,t),e._zod.check=n=>{ZO(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),$O=$(`$ZodUnknown`,(e,t)=>{lO.init(e,t),e._zod.parse=e=>e}),ek=$(`$ZodNever`,(e,t)=>{lO.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function tk(e,t){let n=mE(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of mE(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,hE(n.issues,t,e),n}}return i(n,a)}}var nk=e=>Array.isArray(e)?e.length:-1;function rk(e,t,n){e.issues.length&&t.issues.push(...fE(n,e.issues)),t.value[n]=e.value}var ik=$(`$ZodArray`,(e,t)=>{lO.init(e,t);let n=VE.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>rk(t,r,e)));else if(rk(c,r,e),s&&c.issues.length!==0&&uE(c))break}return o.length?Promise.all(o).then(()=>r):r},tk(e,nk)});function ak(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...fE(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var ok=[];function sk(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ok,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=QT(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function ck(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(uE(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ak(e,n,i,t,d,f))):ak(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var lk=$(`$ZodObject`,(e,t)=>{lO.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=AT(()=>sk(t));jE(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||NT(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=WT,o=t.catchall,s,c=VE.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(uE(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ak(n,t,e,r,a,o))):ak(s,t,e,r,a,o)}return o?ck(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),uk=$(`$ZodObjectJIT`,(e,t)=>{lk.init(e,t);let n=e._zod.parse,r=AT(()=>sk(t)),i=VE.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new sO([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
89
89
|
let ${e}_ab = false;
|
|
90
90
|
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
91
91
|
const iss = ${e}.issues[i];
|
|
@@ -96,7 +96,7 @@ Error generating stack: `+e.message+`
|
|
|
96
96
|
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
97
97
|
payload.value = newResult;
|
|
98
98
|
return payload;
|
|
99
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:
|
|
99
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:VT(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
100
100
|
const ${n}_present = ${i};
|
|
101
101
|
if (!${n}.issues.length || ${n}_present) {
|
|
102
102
|
if (${n}.issues.length) {${c(n,r)}
|
|
@@ -135,6 +135,6 @@ Error generating stack: `+e.message+`
|
|
|
135
135
|
newResult[${r}] = ${n}.value;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=VT,c=!RE.jitless,l=c&&HT.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ak([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function ck(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!sE(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>pE(e,r,zE())))}),t)}var lk=$(`$ZodUnion`,(e,t)=>{oO.init(e,t),OE(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),OE(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),OE(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),OE(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>kT(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ck(t,r,e,i)):ck(o,r,e,i)}}),uk=$(`$ZodIntersection`,(e,t)=>{oO.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>fk(e,t,n)):fk(e,i,a)}});function dk(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(UT(e)&&UT(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=dk(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=dk(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function fk(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=dk(t.value,n.value);if(!c.valid){if(sE(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var pk=$(`$ZodEnum`,(e,t)=>{oO.init(e,t);let n=CT(t.entries),r=new Set(n);e._zod.values=r,OE(e,`pattern`,e=>{let t=CT(e.def.entries).filter(e=>GT.has(typeof e));return RegExp(t.length?`^(${t.map(e=>KT(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),mk=$(`$ZodTransform`,(e,t)=>{oO.init(e,t),e._zod.optin=`optional`,RE.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new LE(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new IE;return n.value=i,n}});function hk(e,t){return e.value=t.issues.length?void 0:t.value,e}var gk=$(`$ZodOptional`,(e,t)=>{oO.init(e,t),OE(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,OE(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),OE(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${kT(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>hk(e,t)):hk(e,r)}return t.innerType._zod.run(e,n)}}),_k=$(`$ZodExactOptional`,(e,t)=>{gk.init(e,t),OE(e,`values`,e=>e.def.innerType._zod.values),OE(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),vk=$(`$ZodNullable`,(e,t)=>{oO.init(e,t),OE(e,`optin`,e=>e.def.innerType._zod.optin),OE(e,`optout`,e=>e.def.innerType._zod.optout),OE(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${kT(t.source)}|null)$`):void 0}),OE(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),yk=$(`$ZodDefault`,(e,t)=>{oO.init(e,t),e._zod.optin=`defaulted`,OE(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>bk(e,t)):bk(r,t)}});function bk(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var xk=$(`$ZodPrefault`,(e,t)=>{oO.init(e,t),e._zod.optin=`defaulted`,OE(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Sk=$(`$ZodNonOptional`,(e,t)=>{oO.init(e,t),OE(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ck(t,e)):Ck(i,e)}});function Ck(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function wk(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>pE(e,r,zE()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Tk=$(`$ZodCatch`,(e,t)=>{oO.init(e,t),OE(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),OE(e,`optout`,e=>e.def.innerType._zod.optout),OE(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>wk(e,r,t,n)):wk(e,r,t,n)}}),Ek=$(`$ZodPipe`,(e,t)=>{oO.init(e,t),OE(e,`values`,e=>e.def.in._zod.values),OE(e,`optin`,e=>e.def.in._zod.optin),OE(e,`optout`,e=>e.def.out._zod.optout),OE(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Dk(e,t.in,n)):Dk(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Dk(e,t.out,n)):Dk(r,t.out,n)}});function Dk(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Ok=$(`$ZodReadonly`,(e,t)=>{oO.init(e,t),OE(e,`propValues`,e=>e.def.innerType._zod.propValues),OE(e,`values`,e=>e.def.innerType._zod.values),OE(e,`optin`,e=>e.def.innerType?._zod?.optin),OE(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(kk):kk(r)}});function kk(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Ak=$(`$ZodCustom`,(e,t)=>{GD.init(e,t),oO.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>jk(t,n,r,e));jk(i,n,r,e)}});function jk(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(vE(e))}}var Mk=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Nk=`~memo`,Pk=[];function Fk(e){return typeof e==`object`&&!!e}function Ik(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Lk=new WeakMap,Rk=0,zk=1,Bk=2;function Vk(e,t,n){let r=Lk.get(e);if(r!==void 0)return r?Bk:Rk;if(t.has(e))return Bk;t.add(e);let i=Rk,a=e=>{if(i!==Bk&&e?._zod){let r=Vk(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Rk;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?zk:o.value?._zod?Vk(o.value,t,n):Rk;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=jT(c);s(e?o(e,!0):zk),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Vk(r,t,!1):zk);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Hk(e,i)}function Hk(e,t){return t!==zk&&Lk.set(e,t===Bk),t}function Uk(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Wk,Gk=[],Kk={alloc(e,t,n){let r=Wk;if(!r)return n;Wk=void 0;let i={value:n,issues:null};return r.set(t.value,i),Gk.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Jk(n,e.value))throw new Mk;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Vk(e,new Set,!1);if(i===Rk)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Bk||r?n=!0:r=!0}let l=s.value;if(!Fk(l))return t(s,c);let u=c[Nk];u||(u={buckets:new WeakMap,backEdges:void 0},c[Nk]=u);let d;i===c?d=a:(d=Uk(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Ik(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Wk=d;let p=Gk.length,m=t(s,c);Wk=void 0;let h=Gk.length>p?Gk.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Ik(e.issues):Pk),e)):(h&&(h.issues=m.issues.length?Ik(m.issues):Pk),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function qk(){return Kk}function Jk(e,t){let n=e[Nk]?.backEdges;return n!==void 0&&Fk(t)&&n.has(t)}var Yk=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(_E(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${JT(e.values[0])}`:`Invalid option: expected one of ${wT(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${wT(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Xk(){return{localeError:Yk()}}var Zk,Qk=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function $k(){return new Qk}(Zk=globalThis).__zod_globalRegistry??(Zk.__zod_globalRegistry=$k());var eA=globalThis.__zod_globalRegistry;function tA(e){return e.checks&&=[...e.checks],e}function nA(e,t){return new e(tA({type:`string`,...Q(t)}))}function rA(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Q(t)})}function iA(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Q(t)})}function aA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Q(t)})}function oA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Q(t)})}function sA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Q(t)})}function cA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Q(t)})}function lA(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Q(t)})}function uA(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Q(t)})}function dA(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Q(t)})}function fA(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Q(t)})}function pA(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Q(t)})}function mA(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Q(t)})}function hA(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Q(t)})}function gA(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Q(t)})}function _A(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Q(t)})}function vA(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Q(t)})}function yA(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Q(t)})}function bA(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Q(t)})}function xA(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Q(t)})}function SA(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Q(t)})}function CA(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Q(t)})}function wA(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Q(t)})}function TA(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Q(t)})}function EA(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Q(t)})}function DA(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Q(t)})}function OA(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Q(t)})}function kA(e){return new e({type:`unknown`})}function AA(e,t){return new e({type:`never`,...Q(t)})}function jA(e,t){return new qD({check:`max_length`,...Q(t),maximum:e})}function MA(e,t){return new JD({check:`min_length`,...Q(t),minimum:e})}function NA(e,t){return new YD({check:`length_equals`,...Q(t),length:e})}function PA(e,t){return new ZD({check:`string_format`,format:`regex`,...Q(t),pattern:e})}function FA(e){return new QD({check:`string_format`,format:`lowercase`,...Q(e)})}function IA(e){return new $D({check:`string_format`,format:`uppercase`,...Q(e)})}function LA(e,t){return new eO({check:`string_format`,format:`includes`,...Q(t),includes:e})}function RA(e,t){return new tO({check:`string_format`,format:`starts_with`,...Q(t),prefix:e})}function zA(e,t){return new nO({check:`string_format`,format:`ends_with`,...Q(t),suffix:e})}function BA(e){return new rO({check:`overwrite`,tx:e})}function VA(e){return BA(t=>t.normalize(e))}function HA(){return BA(e=>e.trim())}function UA(){return BA(e=>e.toLowerCase())}function WA(){return BA(e=>e.toUpperCase())}function GA(){return BA(e=>zT(e))}function KA(e,t,n){return new e({type:`array`,element:t,...Q(n)})}function qA(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Q(n)})}function JA(e,t){let n=YA(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(vE(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(vE(r))}},e(t.value,t)),t);return n}function YA(e,t){let n=new GD({check:`custom`,...Q(t)});return n._zod.check=e,n}function XA(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&AT(e,t,n[t]);return e}function ZA(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??eA,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function QA(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function $A(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,$A(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&XA(o.schema,c),t.io===`input`&&lj(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ej(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function tj(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${ej(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+ej(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
138
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=WT,c=!VE.jitless,l=c&>.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?ck([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function dk(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!uE(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>gE(e,r,HE())))}),t)}var fk=$(`$ZodUnion`,(e,t)=>{lO.init(e,t),jE(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),jE(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),jE(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),jE(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>MT(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>dk(t,r,e,i)):dk(o,r,e,i)}}),pk=$(`$ZodIntersection`,(e,t)=>{lO.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>hk(e,t,n)):hk(e,i,a)}});function mk(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(KT(e)&&KT(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=mk(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=mk(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function hk(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=mk(t.value,n.value);if(!c.valid){if(uE(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var gk=$(`$ZodEnum`,(e,t)=>{lO.init(e,t);let n=ET(t.entries),r=new Set(n);e._zod.values=r,jE(e,`pattern`,e=>{let t=ET(e.def.entries).filter(e=>JT.has(typeof e));return RegExp(t.length?`^(${t.map(e=>YT(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),_k=$(`$ZodTransform`,(e,t)=>{lO.init(e,t),e._zod.optin=`optional`,VE.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new BE(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new zE;return n.value=i,n}});function vk(e,t){return e.value=t.issues.length?void 0:t.value,e}var yk=$(`$ZodOptional`,(e,t)=>{lO.init(e,t),jE(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,jE(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),jE(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${MT(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>vk(e,t)):vk(e,r)}return t.innerType._zod.run(e,n)}}),bk=$(`$ZodExactOptional`,(e,t)=>{yk.init(e,t),jE(e,`values`,e=>e.def.innerType._zod.values),jE(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xk=$(`$ZodNullable`,(e,t)=>{lO.init(e,t),jE(e,`optin`,e=>e.def.innerType._zod.optin),jE(e,`optout`,e=>e.def.innerType._zod.optout),jE(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${MT(t.source)}|null)$`):void 0}),jE(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Sk=$(`$ZodDefault`,(e,t)=>{lO.init(e,t),e._zod.optin=`defaulted`,jE(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ck(e,t)):Ck(r,t)}});function Ck(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var wk=$(`$ZodPrefault`,(e,t)=>{lO.init(e,t),e._zod.optin=`defaulted`,jE(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Tk=$(`$ZodNonOptional`,(e,t)=>{lO.init(e,t),jE(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ek(t,e)):Ek(i,e)}});function Ek(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Dk(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>gE(e,r,HE()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Ok=$(`$ZodCatch`,(e,t)=>{lO.init(e,t),jE(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),jE(e,`optout`,e=>e.def.innerType._zod.optout),jE(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Dk(e,r,t,n)):Dk(e,r,t,n)}}),kk=$(`$ZodPipe`,(e,t)=>{lO.init(e,t),jE(e,`values`,e=>e.def.in._zod.values),jE(e,`optin`,e=>e.def.in._zod.optin),jE(e,`optout`,e=>e.def.out._zod.optout),jE(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ak(e,t.in,n)):Ak(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ak(e,t.out,n)):Ak(r,t.out,n)}});function Ak(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var jk=$(`$ZodReadonly`,(e,t)=>{lO.init(e,t),jE(e,`propValues`,e=>e.def.innerType._zod.propValues),jE(e,`values`,e=>e.def.innerType._zod.values),jE(e,`optin`,e=>e.def.innerType?._zod?.optin),jE(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Mk):Mk(r)}});function Mk(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Nk=$(`$ZodCustom`,(e,t)=>{JD.init(e,t),lO.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Pk(t,n,r,e));Pk(i,n,r,e)}});function Pk(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(xE(e))}}var Fk=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Ik=`~memo`,Lk=[];function Rk(e){return typeof e==`object`&&!!e}function zk(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Bk=new WeakMap,Vk=0,Hk=1,Uk=2;function Wk(e,t,n){let r=Bk.get(e);if(r!==void 0)return r?Uk:Vk;if(t.has(e))return Uk;t.add(e);let i=Vk,a=e=>{if(i!==Uk&&e?._zod){let r=Wk(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Vk;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Hk:o.value?._zod?Wk(o.value,t,n):Vk;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=PT(c);s(e?o(e,!0):Hk),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Wk(r,t,!1):Hk);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Gk(e,i)}function Gk(e,t){return t!==Hk&&Bk.set(e,t===Uk),t}function Kk(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var qk,Jk=[],Yk={alloc(e,t,n){let r=qk;if(!r)return n;qk=void 0;let i={value:n,issues:null};return r.set(t.value,i),Jk.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Zk(n,e.value))throw new Fk;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Wk(e,new Set,!1);if(i===Vk)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Uk||r?n=!0:r=!0}let l=s.value;if(!Rk(l))return t(s,c);let u=c[Ik];u||(u={buckets:new WeakMap,backEdges:void 0},c[Ik]=u);let d;i===c?d=a:(d=Kk(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...zk(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;qk=d;let p=Jk.length,m=t(s,c);qk=void 0;let h=Jk.length>p?Jk.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?zk(e.issues):Lk),e)):(h&&(h.issues=m.issues.length?zk(m.issues):Lk),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Xk(){return Yk}function Zk(e,t){let n=e[Ik]?.backEdges;return n!==void 0&&Rk(t)&&n.has(t)}var Qk=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(bE(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ZT(e.values[0])}`:`Invalid option: expected one of ${DT(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${DT(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function $k(){return{localeError:Qk()}}var eA,tA=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function nA(){return new tA}(eA=globalThis).__zod_globalRegistry??(eA.__zod_globalRegistry=nA());var rA=globalThis.__zod_globalRegistry;function iA(e){return e.checks&&=[...e.checks],e}function aA(e,t){return new e(iA({type:`string`,...Q(t)}))}function oA(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Q(t)})}function sA(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Q(t)})}function cA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Q(t)})}function lA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Q(t)})}function uA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Q(t)})}function dA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Q(t)})}function fA(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Q(t)})}function pA(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Q(t)})}function mA(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Q(t)})}function hA(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Q(t)})}function gA(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Q(t)})}function _A(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Q(t)})}function vA(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Q(t)})}function yA(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Q(t)})}function bA(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Q(t)})}function xA(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Q(t)})}function SA(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Q(t)})}function CA(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Q(t)})}function wA(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Q(t)})}function TA(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Q(t)})}function EA(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Q(t)})}function DA(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Q(t)})}function OA(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Q(t)})}function kA(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Q(t)})}function AA(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Q(t)})}function jA(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Q(t)})}function MA(e){return new e({type:`unknown`})}function NA(e,t){return new e({type:`never`,...Q(t)})}function PA(e,t){return new XD({check:`max_length`,...Q(t),maximum:e})}function FA(e,t){return new ZD({check:`min_length`,...Q(t),minimum:e})}function IA(e,t){return new QD({check:`length_equals`,...Q(t),length:e})}function LA(e,t){return new eO({check:`string_format`,format:`regex`,...Q(t),pattern:e})}function RA(e){return new tO({check:`string_format`,format:`lowercase`,...Q(e)})}function zA(e){return new nO({check:`string_format`,format:`uppercase`,...Q(e)})}function BA(e,t){return new rO({check:`string_format`,format:`includes`,...Q(t),includes:e})}function VA(e,t){return new iO({check:`string_format`,format:`starts_with`,...Q(t),prefix:e})}function HA(e,t){return new aO({check:`string_format`,format:`ends_with`,...Q(t),suffix:e})}function UA(e){return new oO({check:`overwrite`,tx:e})}function WA(e){return UA(t=>t.normalize(e))}function GA(){return UA(e=>e.trim())}function KA(){return UA(e=>e.toLowerCase())}function qA(){return UA(e=>e.toUpperCase())}function JA(){return UA(e=>HT(e))}function YA(e,t,n){return new e({type:`array`,element:t,...Q(n)})}function XA(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Q(n)})}function ZA(e,t){let n=QA(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(xE(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(xE(r))}},e(t.value,t)),t);return n}function QA(e,t){let n=new JD({check:`custom`,...Q(t)});return n._zod.check=e,n}function $A(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&NT(e,t,n[t]);return e}function ej(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??rA,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function tj(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function nj(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,nj(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&$A(o.schema,c),t.io===`input`&&fj(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function rj(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ij(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${rj(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+rj(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
139
139
|
|
|
140
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function nj(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;nj(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var rj=new Set([`type`,`properties`,`required`,`additionalProperties`]),ij=[`oneOf`,`anyOf`];function aj(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function oj(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!rj.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??aj(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}AT(n,r,e.length===1?e[0]:oj(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=aj(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function sj(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of rj)if(t in e)return;let n=t.filter(e=>ij.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=oj(t);else{let e=n[0],i=ij.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>oj([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,XA(e,r))}function cj(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):XA(i,s),XA(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())nj(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])sj(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}XA(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,AT(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:dj(t,`input`,e.processors),output:dj(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function lj(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return lj(r.element,n);if(r.type===`set`)return lj(r.valueType,n);if(r.type===`lazy`)return lj(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return lj(r.innerType,n);if(r.type===`intersection`)return lj(r.left,n)||lj(r.right,n);if(r.type===`record`||r.type===`map`)return lj(r.keyType,n)||lj(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:lj(r.in,n)||lj(r.out,n);if(r.type===`object`){for(let e in r.shape)if(lj(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(lj(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(lj(e,n))return!0;return!!(r.rest&&lj(r.rest,n))}return!1}var uj=(e,t={})=>n=>{let r=ZA({...n,processors:t});return $A(e,r),tj(r,e),cj(r,e)},dj=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ZA({...i??{},target:a,io:t,processors:n});return $A(e,o),tj(o,e),cj(o,e)},fj=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},pj=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},mj=(e,t)=>{fj(e,`minimum`,t),pj(e,`maximum`,t)},hj=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},gj=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},_j=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},vj=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},yj=(e,t)=>fj(e,`minimum`,t.minimum),bj=(e,t)=>pj(e,`maximum`,t.maximum),xj=e=>(t,n)=>{vj(t,n.format);let[r,i]=e[n.format];fj(t,`minimum`,r),pj(t,`maximum`,i)},Sj={greater_than:(e,t)=>fj(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>pj(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>hj(e,t.value),number_format:xj(XT),bigint_format:xj(ZT),min_length:yj,max_length:bj,length_equals:(e,t)=>mj(e,t.length),min_size:yj,max_size:bj,size_equals:(e,t)=>mj(e,t.size),string_format:(e,t)=>{vj(e,t.format),t.pattern&&gj(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>_j(e,t.mime)};function Cj(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Sj[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&fj(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&fj(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&pj(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&pj(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&hj(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&_j(t,i.mime);for(let e of i.patterns??[])gj(t,e);return t}var wj={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Tj=new Map([[HO,MD],[WO,ND]]),Ej=e=>Tj.get(e)??e,Dj=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Cj(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=wj[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Ej);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Oj=(e,t,n,r)=>{n.not={}},kj=(e,t,n,r)=>{let i=e._zod.def,a=CT(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Aj=(e,t,n,r)=>{QA(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},jj=(e,t,n,r)=>{QA(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Mj=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Cj(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=$A(a.element,t,{...r,path:[...r.path,`items`]})};function Nj(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Nj(t.out):t.type===`catch`?Nj(t.innerType):e._zod.optin}var Pj=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&QA(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)AT(i.properties,e,$A(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Nj(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=$A(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Fj=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>$A(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ij=(e,t,n,r)=>{let i=e._zod.def,a=$A(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=$A(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Lj=(e,t,n,r)=>{let i=e._zod.def,a=$A(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Rj=(e,t,n,r)=>{let i=e._zod.def;$A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},zj=Symbol();function Bj(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(QA(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),zj):JSON.parse(o)}var Vj=(e,t,n,r)=>{let i=e._zod.def;$A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Bj(i.defaultValue,e,t,n,r);o!==zj&&(n.default=o)},Hj=(e,t,n,r)=>{let i=e._zod.def;$A(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Bj(i.defaultValue,e,t,n,r);o!==zj&&(n._prefault=o)},Uj=(e,t,n,r)=>{let i=e._zod.def;$A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{QA(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Wj=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;$A(o,t,r);let s=t.seen.get(e);s.ref=o},Gj=(e,t,n,r)=>{let i=e._zod.def;$A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Kj=(e,t,n,r)=>{let i=e._zod.def;$A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},qj=new WeakSet([Object.prototype,Error.prototype]);function Jj(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Yj=$(`ZodError`,(e,t)=>{KE.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);qj.has(n)||(qj.add(n),Jj(n,`format`,e=>t=>YE(e,t)),Jj(n,`flatten`,e=>t=>JE(e,t)),Jj(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,TT,2)}),Jj(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,TT,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Xj=ZE(Yj),Zj=QE(Yj),Qj=$E(Yj),$j=tD(Yj),eM=sD(Yj),tM=cD(Yj),nM=lD(Yj),rM=uD(Yj),iM=dD(Yj),aM=fD(Yj),oM=pD(Yj),sM=mD(Yj);function cM(){RE.localeError||zE(Xk())}function lM(){RE.memoizer||zE({memoizer:qk()})}var uM=$(`ZodType`,(e,t)=>(cM(),oO.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(LT(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return qT(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(yN(e,t))},superRefine(e,t){return this.check(bN(e,t))},overwrite(e){return this.check(BA(e))},optional(){return tN(this)},exactOptional(){return rN(this)},nullable(){return aN(this)},nullish(){return tN(aN(this))},nonoptional(e){return dN(this,e)},array(){return UM(this)},or(e){return qM([this,e])},and(e){return YM(this,e)},transform(e){return hN(this,$M(e))},default(e){return sN(this,e)},prefault(e){return lN(this,e)},catch(e){return pN(this,e)},pipe(e){return hN(this,e)},readonly(){return _N(this)},describe(e){let t=this.clone();return eA.add(t,{description:e}),t},meta(...e){if(e.length===0)return eA.get(this);let t=this.clone();return eA.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return xE(this,`~standard`,{...lO(this),jsonSchema:{input:dj(this,`input`),output:dj(this,`output`)}})},set"~standard"(e){bE(this,`~standard`,e)},parse:function e(t,n){return Xj(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Zj(this,t,n,{callee:e})},safeParse(e,t){return Qj(this,e,t)},async safeParseAsync(e,t){return $j(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){bE(this,`spa`,e)},validate(e,t){return iD(this,e,t)},validateAsync(e,t){return oD(this,e,t)},encode:function e(t,n){return eM(this,t,n,{callee:e})},decode:function e(t,n){return tM(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await nM(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await rM(this,t,n,{callee:e})},safeEncode(e,t){return iM(this,e,t)},safeDecode(e,t){return aM(this,e,t)},async safeEncodeAsync(e,t){return oM(this,e,t)},async safeDecodeAsync(e,t){return sM(this,e,t)},toJSONSchema(e){return uj(this,{})(e)},get description(){return eA.get(this)?.description},get _def(){return this._zod.def}}),dM=$(`_ZodString`,(e,t)=>{uO.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dj(e,t,n,r)},SE({format:e=>Cj(e).format??null,minLength:e=>Cj(e).minimum??null,maxLength:e=>Cj(e).maximum??null},{regex(...e){return this.check(PA(...e))},includes(...e){return this.check(LA(...e))},startsWith(...e){return this.check(RA(...e))},endsWith(...e){return this.check(zA(...e))},min(...e){return this.check(MA(...e))},max(...e){return this.check(jA(...e))},length(...e){return this.check(NA(...e))},nonempty(...e){return this.check(MA(1,...e))},lowercase(e){return this.check(FA(e))},uppercase(e){return this.check(IA(e))},trim(){return this.check(HA())},normalize(...e){return this.check(VA(...e))},toLowerCase(){return this.check(UA())},toUpperCase(){return this.check(WA())},slugify(){return this.check(GA())}})),fM=$(`ZodString`,(e,t)=>{uO.init(e,t),dM.init(e,t)},{email(e){return this.check(rA(yM,e))},url(e){return this.check(lA(SM,e))},jwt(e){return this.check(wA(LM,e))},emoji(e){return this.check(uA(CM,e))},guid(e){return this.check(iA(bM,e))},uuid(e){return this.check(aA(xM,e))},uuidv4(e){return this.check(oA(xM,e))},uuidv6(e){return this.check(sA(xM,e))},uuidv7(e){return this.check(cA(xM,e))},nanoid(e){return this.check(dA(wM,e))},cuid(e){return this.check(fA(TM,e))},cuid2(e){return this.check(pA(EM,e))},ulid(e){return this.check(mA(DM,e))},base64(e){return this.check(xA(PM,e))},base64url(e){return this.check(SA(FM,e))},xid(e){return this.check(hA(OM,e))},ksuid(e){return this.check(gA(kM,e))},ipv4(e){return this.check(_A(AM,e))},ipv6(e){return this.check(vA(jM,e))},cidrv4(e){return this.check(yA(MM,e))},cidrv6(e){return this.check(bA(NM,e))},e164(e){return this.check(CA(IM,e))},datetime(e){return this.check(TA(hM,e))},date(e){return this.check(EA(gM,e))},time(e){return this.check(DA(_M,e))},duration(e){return this.check(OA(vM,e))}});function pM(e){return nA(fM,e)}var mM=$(`ZodStringFormat`,(e,t)=>{dO.init(e,t),dM.init(e,t)}),hM=$(`ZodISODateTime`,(e,t)=>{AO.init(e,t),mM.init(e,t)}),gM=$(`ZodISODate`,(e,t)=>{jO.init(e,t),mM.init(e,t)}),_M=$(`ZodISOTime`,(e,t)=>{MO.init(e,t),mM.init(e,t)}),vM=$(`ZodISODuration`,(e,t)=>{NO.init(e,t),mM.init(e,t)}),yM=$(`ZodEmail`,(e,t)=>{mO.init(e,t),mM.init(e,t)}),bM=$(`ZodGUID`,(e,t)=>{fO.init(e,t),mM.init(e,t)}),xM=$(`ZodUUID`,(e,t)=>{pO.init(e,t),mM.init(e,t)}),SM=$(`ZodURL`,(e,t)=>{SO.init(e,t),mM.init(e,t)}),CM=$(`ZodEmoji`,(e,t)=>{CO.init(e,t),mM.init(e,t)}),wM=$(`ZodNanoID`,(e,t)=>{wO.init(e,t),mM.init(e,t)}),TM=$(`ZodCUID`,(e,t)=>{TO.init(e,t),mM.init(e,t)}),EM=$(`ZodCUID2`,(e,t)=>{EO.init(e,t),mM.init(e,t)}),DM=$(`ZodULID`,(e,t)=>{DO.init(e,t),mM.init(e,t)}),OM=$(`ZodXID`,(e,t)=>{OO.init(e,t),mM.init(e,t)}),kM=$(`ZodKSUID`,(e,t)=>{kO.init(e,t),mM.init(e,t)}),AM=$(`ZodIPv4`,(e,t)=>{PO.init(e,t),mM.init(e,t)}),jM=$(`ZodIPv6`,(e,t)=>{LO.init(e,t),mM.init(e,t)}),MM=$(`ZodCIDRv4`,(e,t)=>{RO.init(e,t),mM.init(e,t)}),NM=$(`ZodCIDRv6`,(e,t)=>{BO.init(e,t),mM.init(e,t)}),PM=$(`ZodBase64`,(e,t)=>{UO.init(e,t),mM.init(e,t)}),FM=$(`ZodBase64URL`,(e,t)=>{KO.init(e,t),mM.init(e,t)}),IM=$(`ZodE164`,(e,t)=>{qO.init(e,t),mM.init(e,t)}),LM=$(`ZodJWT`,(e,t)=>{YO.init(e,t),mM.init(e,t)}),RM=$(`ZodUnknown`,(e,t)=>{XO.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function zM(){return kA(RM)}var BM=$(`ZodNever`,(e,t)=>{ZO.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oj(e,t,n,r)});function VM(e){return AA(BM,e)}var HM=$(`ZodArray`,(e,t)=>{lM(),tk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mj(e,t,n,r),e.element=t.element},{min(e,t){return this.check(MA(e,t))},nonempty(e){return this.check(MA(1,e))},max(e,t){return this.check(jA(e,t))},length(e,t){return this.check(NA(e,t))},unwrap(){return this.element}});function UM(e,t){return KA(HM,e,t)}var WM=$(`ZodObject`,(e,t)=>{lM(),sk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pj(e,t,n,r),kE(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return ZM(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(LT(this._zod.def,{catchall:e}))},passthrough(){return this.clone(LT(this._zod.def,{catchall:zM()}))},loose(){return this.clone(LT(this._zod.def,{catchall:zM()}))},strict(){return this.clone(LT(this._zod.def,{catchall:VM()}))},strip(){return this.clone(LT(this._zod.def,{catchall:void 0}))},extend(e){return tE(this,e)},safeExtend(e){return rE(this,e)},merge(e){return iE(this,e)},pick(e){return QT(this,e)},omit(e){return eE(this,e)},partial(...e){return aE(eN,this,e[0])},exactPartial(...e){return aE(nN,this,e[0],`exactPartial`)},required(...e){return oE(uN,this,e[0])}});function GM(e,t){return new WM({type:`object`,shape:e??{},...Q(t)})}var KM=$(`ZodUnion`,(e,t)=>{lk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fj(e,t,n,r),e.options=t.options});function qM(e,t){return new KM({type:`union`,options:e,...Q(t)})}var JM=$(`ZodIntersection`,(e,t)=>{uk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ij(e,t,n,r)});function YM(e,t){return new JM({type:`intersection`,left:e,right:t})}var XM=$(`ZodEnum`,(e,t)=>{pk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kj(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new XM({...t,checks:[],...Q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new XM({...t,checks:[],...Q(r),entries:i})}});function ZM(e,t){return new XM({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Q(t)})}var QM=$(`ZodTransform`,(e,t)=>{lM(),mk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jj(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new LE(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(vE(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(vE(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function $M(e){return new QM({type:`transform`,transform:e})}var eN=$(`ZodOptional`,(e,t)=>{gk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tN(e){return new eN({type:`optional`,innerType:e})}var nN=$(`ZodExactOptional`,(e,t)=>{_k.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rN(e){return new nN({type:`optional`,innerType:e})}var iN=$(`ZodNullable`,(e,t)=>{vk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function aN(e){return new iN({type:`nullable`,innerType:e})}var oN=$(`ZodDefault`,(e,t)=>{yk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sN(e,t){return new oN({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():WT(t)}})}var cN=$(`ZodPrefault`,(e,t)=>{xk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lN(e,t){return new cN({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():WT(t)}})}var uN=$(`ZodNonOptional`,(e,t)=>{Sk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dN(e,t){return new uN({type:`nonoptional`,innerType:e,...Q(t)})}var fN=$(`ZodCatch`,(e,t)=>{Tk.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pN(e,t){return new fN({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:jE(t)})}var mN=$(`ZodPipe`,(e,t)=>{Ek.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wj(e,t,n,r),e.in=t.in,e.out=t.out});function hN(e,t){return new mN({type:`pipe`,in:e,out:t})}var gN=$(`ZodReadonly`,(e,t)=>{Ok.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _N(e){return new gN({type:`readonly`,innerType:e})}var vN=$(`ZodCustom`,(e,t)=>{Ak.init(e,t),uM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aj(e,t,n,r)});function yN(e,t={}){return qA(vN,e,t)}function bN(e,t){return JA(e,t)}GM({clientOperationId:pM().uuid(),command:pM().min(1).max(8192).refine(e=>!!e.trim()&&!e.includes(`\0`))}).strict();var xN=e=>e.status===`running`||e.status===`stopping`;function SN(e){let[t,n]=(0,O.useState)([]),[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(),p=(0,O.useRef)({revision:0}),m=(0,O.useRef)(s);m.current=s;let h=(0,O.useRef)(5e3);h.current=e||t.some(xN)||s?500:5e3;let g=(0,O.useCallback)((e,t=!1)=>{n(n=>{let r=new Map(n.map(e=>[e.id,t&&xN(e)?{...e,status:`unknown`,error:`服务已重启,无法恢复执行状态;已收到的输出已保留。`}:e]));for(let n of e){let e=r.get(n.id);(!e||t||e.revision<=n.revision)&&r.set(n.id,n)}return[...r.values()].sort((e,t)=>t.startedAt-e.startedAt).slice(0,20)})},[]),_=(0,O.useCallback)(async e=>{let t=p.current,n=await Re(`/api/shell?${new URLSearchParams({after:String(t.revision),...t.epoch?{epoch:t.epoch}:{}})}`,void 0,e??AbortSignal.timeout(5e3));if(e?.aborted)return;let r=!!(t.epoch&&t.epoch!==n.epoch);(n.commands.length||r)&&g(n.commands,r),p.current={epoch:n.epoch,revision:n.revision},i(!0);let a=m.current;if(a){if(n.commands.find(e=>e.id===a.id)){c(void 0),o(void 0);return}let t;try{t=await Re(`/api/operations/${a.id}`,void 0,e)}catch{return}if(t.status===`acknowledged`){let e=t.result?.shellCommand;e&&!n.commands.some(t=>t.id===e.id)&&g([{...e,status:`unknown`,error:`执行已提交;记录已过期或服务已重启,请检查服务端结果。`}]),c(void 0),o(void 0)}else t.status===`failed`&&(c(void 0),o(t.error?.message??`命令未能启动`))}},[g]);return(0,O.useEffect)(()=>{let e=new AbortController,t,n=async()=>{try{await _(AbortSignal.any([e.signal,AbortSignal.timeout(5e3)]))}catch{e.signal.aborted||i(!1)}e.signal.aborted||(t=setTimeout(()=>{n()},h.current))};return n(),()=>{e.abort(),clearTimeout(t)}},[_,e]),{commands:t,connected:r,error:a,pending:s,submitting:l,interrupting:d,execute:async(e,t)=>{if(s||l)return!1;let n=crypto.randomUUID();u(!0),o(void 0);try{let r=await Re(`/api/projects/${encodeURIComponent(e)}/shell`,{clientOperationId:n,command:t});if(r.status===`acknowledged`)return g([r.result.shellCommand]),!0;if(r.status===`failed`)return o(r.error?.message??`命令未能启动`),!1;c({id:n,projectId:e,command:t})}catch(r){if(r instanceof Le&&r.status>=400&&r.status<500)return o(r.message),!1;c({id:n,projectId:e,command:t}),o(`提交结果未确认,正在核对;请勿重复执行。`)}finally{u(!1)}return!1},interrupt:async e=>{f(e),o(void 0);try{let t=await Re(`/api/shell/${encodeURIComponent(e)}/interrupt`,{clientOperationId:crypto.randomUUID()});t.status!==`acknowledged`&&o(t.error?.message??`中断结果尚未确认,请刷新后核对`),await _()}catch(e){o(e instanceof Error?e.message:`中断失败,请重试`)}finally{f(void 0)}},retry:async()=>{if(s&&!l){u(!0);try{let e=await Re(`/api/projects/${encodeURIComponent(s.projectId)}/shell`,{clientOperationId:s.id,command:s.command});e.status===`acknowledged`?(c(void 0),o(void 0),p.current={revision:0}):e.status===`failed`&&(c(void 0),o(e.error?.message??`命令未能启动`))}catch(e){o(e instanceof Error?e.message:`提交仍未确认`)}finally{u(!1)}}}}}var CN={running:`执行中`,stopping:`正在中断`,completed:`已完成`,failed:`执行失败`,interrupted:`已中断`,unknown:`结果未知`};function wN({open:e,project:t,shell:n,canExecute:r,collapsed:i,onCollapse:a,onClose:o}){let[s,c]=(0,O.useState)({}),[l,u]=(0,O.useState)({}),d=(0,O.useRef)(null),f=t?.id??``,p=n.commands.filter(e=>e.projectId===f),m=p.find(e=>e.id===l[f])??p[0],h=p.find(xN),g=n.commands.filter(e=>e.projectId!==f&&xN(e)),_=s[f]??``,v=e=>c(t=>({...t,[f]:e}));return(0,O.useEffect)(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[m?.revision,m?.id,i,e]),e?(0,W.jsxs)(`section`,{className:`shell-panel${i?` shell-collapsed`:``}`,"aria-label":`Shell 面板`,children:[(0,W.jsxs)(`header`,{className:`shell-header`,children:[(0,W.jsxs)(`div`,{className:`shell-heading`,children:[(0,W.jsx)(J,{name:`terminal`,size:17}),(0,W.jsx)(`strong`,{children:`Shell`}),(0,W.jsx)(`span`,{children:t?.name??`请选择项目`}),h&&(0,W.jsx)(`span`,{className:`shell-running`,children:CN[h.status]})]}),(0,W.jsxs)(`div`,{className:`shell-actions`,children:[(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":i?`展开 Shell`:`收起 Shell`,"aria-expanded":!i,"aria-controls":`shell-body`,onClick:a,children:(0,W.jsx)(J,{name:i?`terminal`:`down`,size:15})}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭 Shell 面板`,onClick:o,children:(0,W.jsx)(J,{name:`close`,size:15})})]})]}),i?(0,W.jsxs)(`p`,{className:`shell-collapsed-note`,children:[`收起不会停止命令`,g.length?` · 另有 ${g.length} 个项目正在执行`:``]}):(0,W.jsxs)(`div`,{id:`shell-body`,className:`shell-body`,children:[(0,W.jsxs)(`div`,{className:`shell-location`,children:[(0,W.jsx)(`span`,{children:`工作目录`}),(0,W.jsx)(`code`,{children:t?.canonicalRoot??`—`})]}),(0,W.jsx)(`p`,{className:`shell-help`,children:`命令执行面板 · 使用 Codex 服务端配置的沙箱,独立于会话权限。每次从项目根目录启动,不支持交互输入。收起、关闭或切换项目均不会停止命令。`}),g.length>0&&(0,W.jsxs)(`p`,{className:`shell-background`,role:`status`,children:[`其他项目仍在执行:`,g.map(e=>e.projectName).join(`、`),`。切回对应项目可查看或中断。`]}),!n.connected&&(0,W.jsx)(`p`,{className:`shell-warning`,role:`status`,children:`Shell 连接已断开,正在重连。已收到的输出已保留,运行状态待确认;断开浏览器不会停止命令。`}),n.error&&(0,W.jsx)(`p`,{className:`shell-warning`,role:`alert`,children:n.error}),n.pending&&(0,W.jsxs)(`div`,{className:`shell-warning`,role:`status`,children:[`正在核对命令的提交结果:`,(0,W.jsx)(`code`,{children:n.pending.command}),` `,(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!n.connected||n.submitting,onClick:()=>void n.retry(),children:`核对并重试原提交`})]}),(0,W.jsxs)(`div`,{className:`shell-result`,children:[(0,W.jsxs)(`div`,{className:`shell-result-toolbar`,children:[(0,W.jsxs)(`label`,{children:[`近期命令`,(0,W.jsxs)(`select`,{"aria-label":`近期 Shell 命令`,value:m?.id??``,onChange:e=>u(t=>({...t,[f]:e.target.value})),children:[!p.length&&(0,W.jsx)(`option`,{value:``,children:`尚未执行`}),p.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[CN[e.status],` · `,e.command.slice(0,70)]},e.id))]})]}),m&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>v(m.command),children:`复用命令`})]}),m?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`shell-command-line`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,W.jsx)(`code`,{children:m.command})]}),(0,W.jsx)(`pre`,{ref:d,className:`shell-output`,"aria-label":`Shell 输出`,tabIndex:0,children:m.output.length?m.output.map((e,t)=>(0,W.jsx)(`span`,{className:e.stream===`stderr`?`shell-stderr`:void 0,children:e.text},t)):(0,W.jsx)(`span`,{className:`shell-output-empty`,children:xN(m)?`等待输出…`:`无输出`})}),(0,W.jsxs)(`div`,{className:`shell-result-status shell-status-${m.status}`,role:`status`,children:[(0,W.jsx)(`span`,{children:CN[m.status]}),m.exitCode!==void 0&&(0,W.jsxs)(`span`,{children:[`退出码 `,m.exitCode]}),m.truncated&&(0,W.jsx)(`span`,{children:`输出已截断(最多 64 KiB)`})]}),m.error&&(0,W.jsx)(`p`,{className:`shell-warning`,role:`alert`,children:m.error})]}):(0,W.jsxs)(`div`,{className:`shell-empty`,children:[(0,W.jsx)(J,{name:`terminal`,size:25}),(0,W.jsx)(`p`,{children:`在项目目录中运行命令,实时查看输出。`}),(0,W.jsx)(`span`,{children:`例如 git status、pwd 或运行项目测试`})]})]}),(0,W.jsxs)(`form`,{className:`shell-form`,onSubmit:e=>{if(e.preventDefault(),!t||!r||!n.connected||h||n.pending||!_.trim())return;let i=t.id;n.execute(i,_).then(e=>{e&&(c(e=>e[i]===_?{...e,[i]:``}:e),u(e=>({...e,[i]:``})))})},children:[(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`shell-command-input`,children:`Shell 命令`}),(0,W.jsx)(`textarea`,{id:`shell-command-input`,rows:2,maxLength:8192,value:_,onChange:e=>v(e.target.value),placeholder:`输入命令…`,disabled:!t?.available,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&e.currentTarget.form?.requestSubmit()}}),(0,W.jsxs)(`div`,{className:`shell-submit-row`,children:[(0,W.jsx)(`span`,{children:h?`命令在服务端运行,可随时中断`:`Ctrl / ⌘ + Enter 执行 · 最长 10 分钟`}),h?(0,W.jsxs)(q,{variant:`destructive`,size:`sm`,disabled:!n.connected||!!n.interrupting||h.status===`stopping`,onClick:()=>void n.interrupt(h.id),children:[(0,W.jsx)(J,{name:`stop`,size:13}),h.status===`stopping`||n.interrupting===h.id?`正在中断…`:`中断命令`]}):(0,W.jsxs)(q,{type:`submit`,size:`sm`,disabled:!r||!n.connected||!_.trim()||!!n.pending||n.submitting,children:[(0,W.jsx)(J,{name:`terminal`,size:14}),n.submitting?`正在提交…`:`执行命令`]})]})]})]})]}):null}var TN=encodeURIComponent;function EN({threadId:e,getHistoryCursor:t,children:n}){return(0,W.jsx)(`div`,{className:`app-shell`,children:(0,W.jsx)(_b,{threadId:e,getHistoryCursor:t,children:n})})}function DN(){let e=Er(),[t,n]=(0,O.useState)(!1),r=SN(t),[i,a]=(0,O.useState)(!1),o=ST(),[s,c]=(0,O.useState)(!1),{isUnreadCompletion:l,markCompletedRead:u}=jr(),[d,f]=(0,O.useState)(!1),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1);(0,O.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&f(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[_,v]=(0,O.useState)(!1),[y,b]=(0,O.useState)(!1),x=(0,O.useRef)(!1),[S,C]=(0,O.useState)(),[w,T]=(0,O.useState)(!1),[E,D]=(0,O.useState)(!1),k=(0,O.useRef)(!1),A=e.projects.find(t=>t.id===e.projectId),j=S?.kind===`manage`?e.projects.find(e=>e.id===S.id):void 0;(0,O.useEffect)(()=>{S?.kind===`manage`&&!j&&C(void 0)},[S,j]);let M=()=>{f(!1),C({kind:`add`})},{thread:N,system:F}=e,I=e.authRequired||!!(e.threadReadFailure&&e.threadReadFailure.id===e.selectedId&&[401,403,404].includes(e.threadReadFailure.status)),L=xT(N,e.selectedId,{projectId:e.projectId,scope:e.cacheScope,forbidden:I}),ee=(0,O.useRef)(void 0),te=!(!F?.ready||F.authenticated===!1||e.connection!==`connected`||e.authRequired),R=te&&!!A?.available&&!Hn(F),ne=Wn(F,e.connection,e.authRequired),re=Vn(F)??``,ie=(t,n=N?.id??``)=>e.busy.includes(`${t}:${n}`),ae=t=>e.operations.some(e=>Fn(e,t)),oe=N?.turns.findLast(e=>kl(e.status)),se=N?.actions.filter(e=>e.status===`pending`||e.status===`responding`||e.kind===`unsupported`&&e.status===`expired`)??[],ce=N?ae(N.id)&&!ie(`resume`)||N.managed&&N.status===`unknown`||N.execution&&!N.execution.ended&&N.status===`unknown`:!ie(`create`,e.projectId)&&ae(e.projectId),le=!!(N&&(!R||N.archived||ae(N.id)||ie(`resume`)||N.execution&&!N.execution.ended)),{run:ue,refreshThread:de}=e,z=(0,O.useCallback)(()=>{N&&!le&&(ee.current=`${F?.codexEpoch}:${N.id}`,ue(`resume`,N.id,`/api/threads/${TN(N.id)}/resume`).then(()=>de()))},[N,le,F?.codexEpoch,ue,de]);(0,O.useEffect)(()=>{if((!F?.ready||N?.archived)&&(ee.current=void 0),!N||N.managed||le)return;let e=`${F?.codexEpoch}:${N.id}`;ee.current!==e&&z()},[N,F?.ready,F?.codexEpoch,le,z]);let fe=!!(N&&e.operations.some(e=>e.kind===`fork`&&Fn(e,N.id))),pe=F?.capabilities.includes(`thread/fork`)??!1,me=t=>ie(`fork`,t)||e.operations.some(e=>e.kind===`fork`&&Fn(e,t)),he=t=>{if(me(t.id))return`正在确认 Fork…请等待提交回执,暂时不能再次 Fork。`;if(!pe)return`当前 Codex 版本不支持 Fork 会话。`;if(!te)return`连接恢复且 Codex 就绪后可 Fork 会话。`;if(!e.projects.find(e=>e.id===t.projectId)?.available)return`项目目录不可用,恢复后可 Fork 会话。`;if(Hn(F))return`请先确认当前 Codex 版本的兼容性。`;if(t.historyVisible===!1||t.id===N?.id&&!N.turns.length)return`发送首条消息后可 Fork 已保存的历史。`},ge=!!(N&&me(N.id)),_e=!(!N?.turns.length||he(N)),ye=async t=>{if(!he(t))return e.run(`fork`,t.id,`/api/threads/${TN(t.id)}/fork`,t.id===N?.id?{settings:e.settings}:{})},be=()=>{N&&_e&&ye(N)},xe=e.connection!==`connected`,Se=e.operations.filter(e=>e.kind===`confirmCompatibility`&&e.target===re),Ce=w||ie(`confirmCompatibility`,re)||Se.some(e=>e.status===`accepted`||e.status===`dispatching`),we=Se.some(e=>e.status===`unknown`&&!e.operation?.reconciliation);async function Te(){if(!x.current){x.current=!0,b(!0);try{await Promise.all([e.refreshSystem(),e.refreshThread()]),await e.refreshOperations(!0)}finally{x.current=!1,b(!1)}}}async function Ee(){if(ne&&!k.current){k.current=!0,T(!0);try{let t=await e.refreshSystem(),n=Kn(re,t,e.connection,e.authRequired);if(!n)return;await e.run(`confirmCompatibility`,re,`/api/system/compatibility/confirm`,n)}finally{k.current=!1,T(!1)}}}let De={project:A,selectedId:e.selectedId,thread:N,system:F,connection:e.connection,authRequired:e.authRequired,settings:e.settings,openDraft:e.openDraft,busy:e.busy,operations:e.operations,run:e.run,onResumeAttempt:()=>{ee.current=`${F?.codexEpoch}:${N?.id}`},refreshThread:e.refreshThread,openStatus:()=>v(!0),exportThread:Uw},Oe=(0,O.useRef)(De);Oe.current=De;let ke=xw(()=>Oe.current),Ae=ke.find(e=>e.name===`rename`);async function je(t,n,r){return!R||e.restoringSelection||e.savingModelDefaults?!1:N?n&&!oe?!1:(await e.run(n?`steer`:`send`,N.id,`/api/threads/${TN(N.id)}/${n?`steer`:`turns`}`,n?{text:t,images:r,expectedTurnId:oe.id}:{text:t,images:r,settings:e.settings},{kind:`send`,key:e.draftKey,text:t,images:r}))?.status===`acknowledged`:!e.selectedId&&e.sendFirstMessage(t,r)}return(0,W.jsxs)(EN,{threadId:N?.id,getHistoryCursor:L.getHistoryCursor,children:[(0,W.jsx)(Rl,{onGatewaySettings:()=>{f(!1),g(!0)},onUpdates:()=>{f(!1),c(!0)},appVersion:o.status?.version,updateAvailable:!!(o.status?.available&&o.status.available.version!==o.status.version),updating:lT(o.status?.run),onNotificationSettings:()=>{f(!1),m(!0)},notificationStatus:e.notifications.error?`请检查设置`:e.notifications.enabled&&e.notifications.access===`granted`?`已开启`:`未开启`,archiveView:e.archiveView,onArchiveView:e.setArchiveView,onArchive:(t,n)=>{e.archiveThread(t,n)},onFork:e=>{ye(e).then(e=>{e?.status===`acknowledged`&&f(!1)})},forkDisabledReason:he,forking:me,archiveDisabledReason:t=>{if(ie(`archive`,t.id))return`正在保存…`;if(ae(t.id))return`请先核对会话操作的结果`;if(!te)return`连接恢复后可操作`;if(Hn(F))return`请先确认 Codex 版本兼容性`;if(!F?.capabilities.includes(t.archived?`thread/unarchive`:`thread/archive`))return`当前 Codex 不支持此操作`;if(!e.projects.find(e=>e.id===t.projectId)?.available)return`项目目录不可用`;if(!t.archived&&(kl(t.status)||t.pendingActionCount>0))return`任务结束并处理完待办后可归档`;if(!t.archived&&t.managed&&t.status===`unknown`)return`会话状态待核对,暂时无法归档`},projects:e.projects,projectsLoaded:e.projectsLoaded,projectId:e.projectId,onProject:t=>{e.setProjectId(t),f(!1)},projectThreads:e.projectThreads,selectedId:e.selectedId,isUnreadCompletion:l,onThread:(t,n)=>{e.selectThread(t,n)},onMore:(t,n)=>{e.loadProjectThreads(t,n)},onRetry:t=>{e.loadProjectThreads(t,e.projectThreads[t]?.retryCursor)},onRefresh:()=>{e.refreshProjects().then(e.refreshProjectsThreads)},onAddProject:M,onManageProject:e=>{f(!1),C({kind:`manage`,id:e.id})},canManageProjects:!e.authRequired,onCreate:t=>{e.setProjectId(t),f(!1)},creating:t=>e.firstMessages.includes(t)||ie(`create`,t)||ae(t),canCreate:t=>te&&!e.savingModelDefaults&&!Hn(F)&&!!e.projects.find(e=>e.id===t)?.available,offline:xe,open:d,onClose:()=>f(!1)}),(0,W.jsxs)(`main`,{className:`main-panel${t&&!i?` shell-visible`:``}`,children:[(0,W.jsxs)(`header`,{className:`topbar`,children:[(0,W.jsxs)(`div`,{className:`topbar-title`,children:[(0,W.jsx)(q,{className:`mobile-only`,variant:`ghost`,size:`icon`,"aria-label":`打开项目与会话`,onClick:()=>f(!0),children:(0,W.jsx)(J,{name:`menu`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`breadcrumb`,children:[A?.name??`工作空间`,(0,W.jsx)(J,{name:`chevron`,size:12}),(0,W.jsx)(`span`,{children:e.selectedId?`会话`:`新会话`})]}),N?(0,W.jsx)(qb,{title:N.title||`新会话`,rename:Ae,pending:!!(N&&e.operations.some(e=>e.kind===`rename`&&Fn(e,N.id)))},`${N.projectId}:${N.id}`):(0,W.jsx)(`h1`,{children:e.selectedId?L.thread?.title??e.threads.find(t=>t.id===e.selectedId)?.title??`正在读取会话…`:`开始你的下一项任务`})]})]}),(0,W.jsxs)(`div`,{className:`topbar-status`,children:[(0,W.jsxs)(q,{variant:`ghost`,size:`sm`,className:`shell-entry`,"aria-label":`打开 Shell 面板`,"aria-expanded":t&&!i,onClick:()=>{n(!0),a(!1)},children:[(0,W.jsx)(J,{name:`terminal`,size:16}),(0,W.jsx)(`span`,{children:`Shell`}),r.commands.some(xN)&&(0,W.jsx)(`span`,{className:`shell-entry-count`,"aria-label":`运行中的 Shell 命令`,children:r.commands.filter(xN).length})]}),N&&(0,W.jsx)(Al,{status:N.status,offline:xe}),(0,W.jsx)(Bw,{connection:e.connection}),N?.forkedFromId&&(0,W.jsx)(ol,{id:`thread-source-hint`,content:`返回原会话`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`返回原会话`,"aria-describedby":`thread-source-hint`,onClick:()=>{e.selectThread(N.forkedFromId)},children:(0,W.jsx)(P,{size:16})})}),(0,W.jsx)(Hw,{system:F,connection:e.connection,operations:e.operations,thread:N,selectedId:e.selectedId,threadReadFailed:e.threadReadFailure?.id===e.selectedId,busy:e.busy,open:_,onOpenChange:v,refreshing:y,onDiscardMissing:e.discardMissingOperation,onRefresh:()=>{Te(),xe&&e.retryConnection()},onReconcile:t=>{e.run(`reconcile`,t,`/api/operations/${TN(t)}/reconcile`,{confirmEnded:!0}).then(e=>{if(e?.status===`acknowledged`)return Te()})}})]})]}),F?.demo&&(0,W.jsx)(`div`,{className:`demo-banner`,children:`模拟测试模式 · 当前执行结果来自显式启用的测试 app-server`}),e.authRequired?(0,W.jsxs)(`div`,{className:`error-banner persistent-banner`,role:`alert`,children:[(0,W.jsx)(J,{name:`alert`}),`登录已过期。任务不会因页面断开而被取消。`,(0,W.jsx)(`a`,{className:`button button-secondary button-small`,href:`/`,children:`重新打开登录入口`})]}):xe&&(0,W.jsxs)(`div`,{className:`connection-banner`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[`实时连接`,e.connection===`connecting`?`正在建立`:`已断开,正在重连`,`。当前显示上次已知状态。`]}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e.retryConnection,children:`立即重连`})]}),F&&!F.ready&&(0,W.jsxs)(`div`,{className:`error-banner persistent-banner`,role:`alert`,children:[`Codex 尚不可用:`,F.error??`请在私人电脑上检查 Codex 安装、认证与服务状态。`]}),(0,W.jsx)(Ww,{system:F,onOpenChange:D,canConfirm:ne,submitting:Ce,uncertain:we,error:e.error,onRefresh:()=>{e.refreshSystem(),e.refreshOperations()},onConfirm:()=>{Ee()},onReconfirm:()=>{Ee()}}),e.error&&(0,W.jsxs)(`div`,{className:`error-banner dismissible`,role:`alert`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:e.error}),e.errorDetails!==void 0&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:`错误详情`}),(0,W.jsx)(`pre`,{children:JSON.stringify(e.errorDetails,null,2)})]})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭错误提示`,onClick:e.clearError,children:(0,W.jsx)(J,{name:`close`,size:15})})]}),e.operations.filter(e=>e.mutation).map(e=>(0,W.jsxs)(`div`,{className:`archive-notice mutation-notice`,role:`status`,children:[e.kind===`rename`?(0,W.jsx)(ve,{size:16}):(0,W.jsx)(J,{name:`archive`,size:16}),(0,W.jsx)(`span`,{children:e.kind===`rename`?e.status===`unknown`?`重命名结果待确认`:`正在保存会话名称…`:e.mutation.archived?e.status===`unknown`?`归档结果待确认`:`正在归档会话…`:e.status===`unknown`?`取消归档结果待确认`:`正在取消归档…`}),e.status===`unknown`&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:y,onClick:()=>void Te(),children:y?`正在核对…`:`核对提交`})]},e.clientOperationId)),N?.archived&&(0,W.jsxs)(`div`,{className:`archive-notice`,role:`status`,children:[(0,W.jsx)(J,{name:`archive`,size:18}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`此会话已归档`}),(0,W.jsx)(`p`,{children:`历史已保留。取消归档后可继续对话。`})]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!R||ae(N.id)||ie(`archive`)||!F?.capabilities.includes(`thread/unarchive`),onClick:()=>{e.archiveThread(N.id,!1)},children:ie(`archive`)?`正在保存…`:`取消归档`})]}),(0,W.jsx)(Gb,{thread:L.thread,history:{cached:L.cached,cacheExhausted:L.cacheExhausted,onLoadCachedOlder:L.loadCachedOlder,syncError:N?L.error:e.error,loading:L.loading,error:L.error,onLoadOlder:L.loadOlder,opening:!(!e.selectedId||N),openingError:N?void 0:e.error,onRetryOpen:()=>{e.clearError(),L.error&&L.loadOlder(),e.refreshThread()}},readingEnabled:!d&&!S&&!_&&!e.authRequired&&!E,onReadCompleted:u,offline:xe,projectName:A?.name,needsProject:e.projectsLoaded&&e.projects.length===0,canAddProject:!e.authRequired,onAddProject:M,questionControls:{disabled:!R||!N?.managed||!!N.archived||!!ce||ie(`send`)||ie(`steer`)||ie(`resume`),onReply:async e=>je(xb(e),!!oe)}}),(0,W.jsxs)(`div`,{className:`bottom-region`,children:[se.length>0&&(0,W.jsx)(`div`,{className:`pending-actions`,"aria-label":`待处理请求`,children:se.map(t=>(0,W.jsx)(Lw,{action:t,disabled:!R||ie(`resolve`,t.actionId)||ae(t.actionId),onResolve:n=>{e.run(`resolve`,t.actionId,`/api/actions/${TN(t.actionId)}/resolve`,{resolution:n})}},t.actionId))}),ce&&(0,W.jsxs)(`div`,{className:`pending-notice`,role:`status`,children:[(0,W.jsx)(J,{name:`alert`,size:15}),(0,W.jsx)(`span`,{children:N?fe?`Fork 结果尚未确认。请核对提交,暂时不能再次 Fork。`:`提交结果尚未确认。请核对提交,也可以 Fork 已保存的历史为新会话。`:`新建会话的提交结果尚未确认。请先核对提交,避免重复创建。`}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:y,"aria-expanded":_,"aria-controls":`diagnostics-panel`,onClick:()=>{v(!0),Te()},children:y?`正在核对…`:`核对提交`}),N&&!fe&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!_e,onClick:be,children:`Fork 为新会话`})]}),(0,W.jsx)(Cw,{commands:ke,thread:N,threadLoading:e.restoringSelection||!(!e.selectedId||N),draftKey:e.draftKey,sentDrafts:e.sentDrafts,projectName:A?.name,projectId:A?.available?A.id:void 0,runtimeKey:F?.ready&&e.connection===`connected`?`${F.codexEpoch}:${e.runtimeDefaultsRevision}`:void 0,settings:e.settings,models:F?.models??[],onSettings:e.setSettings,onSaveModelDefaults:e.saveModelDefaults,savingModelDefaults:e.savingModelDefaults,disabled:!R||e.restoringSelection||!!ce||!!N?.archived,canInterrupt:te&&!!(N?.managed&&oe),submitting:e.firstMessages.includes(e.projectId)||ie(`send`)||ie(`steer`),interrupting:ie(`interrupt`),resuming:ie(`resume`),canResume:!le,resumeAttempted:ee.current===`${F?.codexEpoch}:${N?.id}`,canFork:_e,forking:ge,onFork:be,onResume:z,onInterrupt:()=>{N&&oe&&e.run(`interrupt`,N.id,`/api/threads/${TN(N.id)}/interrupt`,{expectedTurnId:oe.id})},onSend:je})]}),(0,W.jsx)(wN,{open:t,project:A,shell:r,canExecute:R&&!!F?.capabilities.includes(`command/exec`),collapsed:i,onCollapse:()=>a(e=>!e),onClose:()=>n(!1)})]}),S&&(S.kind===`add`||j)&&(0,W.jsx)(Gw,{project:j,disabled:e.authRequired,onAdd:e.addProject,onRename:e.renameProject,onRemove:e.removeProject,onClose:()=>C(e=>e===S?void 0:e)},S.kind===`add`?`add`:S.id),p&&(0,W.jsx)(Kw,{notifications:e.notifications,onClose:()=>m(!1)}),h&&(0,W.jsx)(sT,{onClose:()=>g(!1)}),s&&(0,W.jsx)(mT,{updates:o,onClose:()=>c(!1)})]})}(0,ke.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(O.StrictMode,{children:(0,W.jsx)(DN,{})}));
|
|
140
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function aj(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;aj(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var oj=new Set([`type`,`properties`,`required`,`additionalProperties`]),sj=[`oneOf`,`anyOf`];function cj(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function lj(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!oj.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??cj(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}NT(n,r,e.length===1?e[0]:lj(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=cj(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function uj(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of oj)if(t in e)return;let n=t.filter(e=>sj.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=lj(t);else{let e=n[0],i=sj.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>lj([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,$A(e,r))}function dj(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):$A(i,s),$A(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())aj(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])uj(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}$A(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,NT(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:mj(t,`input`,e.processors),output:mj(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function fj(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return fj(r.element,n);if(r.type===`set`)return fj(r.valueType,n);if(r.type===`lazy`)return fj(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return fj(r.innerType,n);if(r.type===`intersection`)return fj(r.left,n)||fj(r.right,n);if(r.type===`record`||r.type===`map`)return fj(r.keyType,n)||fj(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:fj(r.in,n)||fj(r.out,n);if(r.type===`object`){for(let e in r.shape)if(fj(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(fj(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(fj(e,n))return!0;return!!(r.rest&&fj(r.rest,n))}return!1}var pj=(e,t={})=>n=>{let r=ej({...n,processors:t});return nj(e,r),ij(r,e),dj(r,e)},mj=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ej({...i??{},target:a,io:t,processors:n});return nj(e,o),ij(o,e),dj(o,e)},hj=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},gj=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},_j=(e,t)=>{hj(e,`minimum`,t),gj(e,`maximum`,t)},vj=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},yj=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},bj=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},xj=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Sj=(e,t)=>hj(e,`minimum`,t.minimum),Cj=(e,t)=>gj(e,`maximum`,t.maximum),wj=e=>(t,n)=>{xj(t,n.format);let[r,i]=e[n.format];hj(t,`minimum`,r),gj(t,`maximum`,i)},Tj={greater_than:(e,t)=>hj(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>gj(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>vj(e,t.value),number_format:wj($T),bigint_format:wj(eE),min_length:Sj,max_length:Cj,length_equals:(e,t)=>_j(e,t.length),min_size:Sj,max_size:Cj,size_equals:(e,t)=>_j(e,t.size),string_format:(e,t)=>{xj(e,t.format),t.pattern&&yj(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>bj(e,t.mime)};function Ej(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Tj[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&hj(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&hj(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&gj(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&gj(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&vj(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&bj(t,i.mime);for(let e of i.patterns??[])yj(t,e);return t}var Dj={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Oj=new Map([[GO,FD],[qO,ID]]),kj=e=>Oj.get(e)??e,Aj=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Ej(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Dj[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(kj);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},jj=(e,t,n,r)=>{n.not={}},Mj=(e,t,n,r)=>{let i=e._zod.def,a=ET(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Nj=(e,t,n,r)=>{tj(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Pj=(e,t,n,r)=>{tj(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Fj=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Ej(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=nj(a.element,t,{...r,path:[...r.path,`items`]})};function Ij(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Ij(t.out):t.type===`catch`?Ij(t.innerType):e._zod.optin}var Lj=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&tj(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)NT(i.properties,e,nj(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Ij(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=nj(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Rj=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>nj(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zj=(e,t,n,r)=>{let i=e._zod.def,a=nj(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=nj(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Bj=(e,t,n,r)=>{let i=e._zod.def,a=nj(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Vj=(e,t,n,r)=>{let i=e._zod.def;nj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Hj=Symbol();function Uj(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(tj(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Hj):JSON.parse(o)}var Wj=(e,t,n,r)=>{let i=e._zod.def;nj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Uj(i.defaultValue,e,t,n,r);o!==Hj&&(n.default=o)},Gj=(e,t,n,r)=>{let i=e._zod.def;nj(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Uj(i.defaultValue,e,t,n,r);o!==Hj&&(n._prefault=o)},Kj=(e,t,n,r)=>{let i=e._zod.def;nj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{tj(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},qj=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;nj(o,t,r);let s=t.seen.get(e);s.ref=o},Jj=(e,t,n,r)=>{let i=e._zod.def;nj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Yj=(e,t,n,r)=>{let i=e._zod.def;nj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xj=new WeakSet([Object.prototype,Error.prototype]);function Zj(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Qj=$(`ZodError`,(e,t)=>{YE.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Xj.has(n)||(Xj.add(n),Zj(n,`format`,e=>t=>QE(e,t)),Zj(n,`flatten`,e=>t=>ZE(e,t)),Zj(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,OT,2)}),Zj(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,OT,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),$j=eD(Qj),eM=tD(Qj),tM=nD(Qj),nM=iD(Qj),rM=uD(Qj),iM=dD(Qj),aM=fD(Qj),oM=pD(Qj),sM=mD(Qj),cM=hD(Qj),lM=gD(Qj),uM=_D(Qj);function dM(){VE.localeError||HE($k())}function fM(){VE.memoizer||HE({memoizer:Xk()})}var pM=$(`ZodType`,(e,t)=>(dM(),lO.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(BT(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return XT(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(SN(e,t))},superRefine(e,t){return this.check(CN(e,t))},overwrite(e){return this.check(UA(e))},optional(){return iN(this)},exactOptional(){return oN(this)},nullable(){return cN(this)},nullish(){return iN(cN(this))},nonoptional(e){return mN(this,e)},array(){return KM(this)},or(e){return XM([this,e])},and(e){return QM(this,e)},transform(e){return vN(this,nN(e))},default(e){return uN(this,e)},prefault(e){return fN(this,e)},catch(e){return gN(this,e)},pipe(e){return vN(this,e)},readonly(){return bN(this)},describe(e){let t=this.clone();return rA.add(t,{description:e}),t},meta(...e){if(e.length===0)return rA.get(this);let t=this.clone();return rA.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return wE(this,`~standard`,{...fO(this),jsonSchema:{input:mj(this,`input`),output:mj(this,`output`)}})},set"~standard"(e){CE(this,`~standard`,e)},parse:function e(t,n){return $j(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await eM(this,t,n,{callee:e})},safeParse(e,t){return tM(this,e,t)},async safeParseAsync(e,t){return nM(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){CE(this,`spa`,e)},validate(e,t){return sD(this,e,t)},validateAsync(e,t){return lD(this,e,t)},encode:function e(t,n){return rM(this,t,n,{callee:e})},decode:function e(t,n){return iM(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await aM(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await oM(this,t,n,{callee:e})},safeEncode(e,t){return sM(this,e,t)},safeDecode(e,t){return cM(this,e,t)},async safeEncodeAsync(e,t){return lM(this,e,t)},async safeDecodeAsync(e,t){return uM(this,e,t)},toJSONSchema(e){return pj(this,{})(e)},get description(){return rA.get(this)?.description},get _def(){return this._zod.def}}),mM=$(`_ZodString`,(e,t)=>{pO.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aj(e,t,n,r)},TE({format:e=>Ej(e).format??null,minLength:e=>Ej(e).minimum??null,maxLength:e=>Ej(e).maximum??null},{regex(...e){return this.check(LA(...e))},includes(...e){return this.check(BA(...e))},startsWith(...e){return this.check(VA(...e))},endsWith(...e){return this.check(HA(...e))},min(...e){return this.check(FA(...e))},max(...e){return this.check(PA(...e))},length(...e){return this.check(IA(...e))},nonempty(...e){return this.check(FA(1,...e))},lowercase(e){return this.check(RA(e))},uppercase(e){return this.check(zA(e))},trim(){return this.check(GA())},normalize(...e){return this.check(WA(...e))},toLowerCase(){return this.check(KA())},toUpperCase(){return this.check(qA())},slugify(){return this.check(JA())}})),hM=$(`ZodString`,(e,t)=>{pO.init(e,t),mM.init(e,t)},{email(e){return this.check(oA(SM,e))},url(e){return this.check(fA(TM,e))},jwt(e){return this.check(DA(BM,e))},emoji(e){return this.check(pA(EM,e))},guid(e){return this.check(sA(CM,e))},uuid(e){return this.check(cA(wM,e))},uuidv4(e){return this.check(lA(wM,e))},uuidv6(e){return this.check(uA(wM,e))},uuidv7(e){return this.check(dA(wM,e))},nanoid(e){return this.check(mA(DM,e))},cuid(e){return this.check(hA(OM,e))},cuid2(e){return this.check(gA(kM,e))},ulid(e){return this.check(_A(AM,e))},base64(e){return this.check(wA(LM,e))},base64url(e){return this.check(TA(RM,e))},xid(e){return this.check(vA(jM,e))},ksuid(e){return this.check(yA(MM,e))},ipv4(e){return this.check(bA(NM,e))},ipv6(e){return this.check(xA(PM,e))},cidrv4(e){return this.check(SA(FM,e))},cidrv6(e){return this.check(CA(IM,e))},e164(e){return this.check(EA(zM,e))},datetime(e){return this.check(OA(vM,e))},date(e){return this.check(kA(yM,e))},time(e){return this.check(AA(bM,e))},duration(e){return this.check(jA(xM,e))}});function gM(e){return aA(hM,e)}var _M=$(`ZodStringFormat`,(e,t)=>{mO.init(e,t),mM.init(e,t)}),vM=$(`ZodISODateTime`,(e,t)=>{NO.init(e,t),_M.init(e,t)}),yM=$(`ZodISODate`,(e,t)=>{PO.init(e,t),_M.init(e,t)}),bM=$(`ZodISOTime`,(e,t)=>{FO.init(e,t),_M.init(e,t)}),xM=$(`ZodISODuration`,(e,t)=>{IO.init(e,t),_M.init(e,t)}),SM=$(`ZodEmail`,(e,t)=>{_O.init(e,t),_M.init(e,t)}),CM=$(`ZodGUID`,(e,t)=>{hO.init(e,t),_M.init(e,t)}),wM=$(`ZodUUID`,(e,t)=>{gO.init(e,t),_M.init(e,t)}),TM=$(`ZodURL`,(e,t)=>{TO.init(e,t),_M.init(e,t)}),EM=$(`ZodEmoji`,(e,t)=>{EO.init(e,t),_M.init(e,t)}),DM=$(`ZodNanoID`,(e,t)=>{DO.init(e,t),_M.init(e,t)}),OM=$(`ZodCUID`,(e,t)=>{OO.init(e,t),_M.init(e,t)}),kM=$(`ZodCUID2`,(e,t)=>{kO.init(e,t),_M.init(e,t)}),AM=$(`ZodULID`,(e,t)=>{AO.init(e,t),_M.init(e,t)}),jM=$(`ZodXID`,(e,t)=>{jO.init(e,t),_M.init(e,t)}),MM=$(`ZodKSUID`,(e,t)=>{MO.init(e,t),_M.init(e,t)}),NM=$(`ZodIPv4`,(e,t)=>{LO.init(e,t),_M.init(e,t)}),PM=$(`ZodIPv6`,(e,t)=>{BO.init(e,t),_M.init(e,t)}),FM=$(`ZodCIDRv4`,(e,t)=>{VO.init(e,t),_M.init(e,t)}),IM=$(`ZodCIDRv6`,(e,t)=>{UO.init(e,t),_M.init(e,t)}),LM=$(`ZodBase64`,(e,t)=>{KO.init(e,t),_M.init(e,t)}),RM=$(`ZodBase64URL`,(e,t)=>{YO.init(e,t),_M.init(e,t)}),zM=$(`ZodE164`,(e,t)=>{XO.init(e,t),_M.init(e,t)}),BM=$(`ZodJWT`,(e,t)=>{QO.init(e,t),_M.init(e,t)}),VM=$(`ZodUnknown`,(e,t)=>{$O.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function HM(){return MA(VM)}var UM=$(`ZodNever`,(e,t)=>{ek.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jj(e,t,n,r)});function WM(e){return NA(UM,e)}var GM=$(`ZodArray`,(e,t)=>{fM(),ik.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fj(e,t,n,r),e.element=t.element},{min(e,t){return this.check(FA(e,t))},nonempty(e){return this.check(FA(1,e))},max(e,t){return this.check(PA(e,t))},length(e,t){return this.check(IA(e,t))},unwrap(){return this.element}});function KM(e,t){return YA(GM,e,t)}var qM=$(`ZodObject`,(e,t)=>{fM(),uk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lj(e,t,n,r),ME(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return eN(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(BT(this._zod.def,{catchall:e}))},passthrough(){return this.clone(BT(this._zod.def,{catchall:HM()}))},loose(){return this.clone(BT(this._zod.def,{catchall:HM()}))},strict(){return this.clone(BT(this._zod.def,{catchall:WM()}))},strip(){return this.clone(BT(this._zod.def,{catchall:void 0}))},extend(e){return iE(this,e)},safeExtend(e){return oE(this,e)},merge(e){return sE(this,e)},pick(e){return tE(this,e)},omit(e){return rE(this,e)},partial(...e){return cE(rN,this,e[0])},exactPartial(...e){return cE(aN,this,e[0],`exactPartial`)},required(...e){return lE(pN,this,e[0])}});function JM(e,t){return new qM({type:`object`,shape:e??{},...Q(t)})}var YM=$(`ZodUnion`,(e,t)=>{fk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rj(e,t,n,r),e.options=t.options});function XM(e,t){return new YM({type:`union`,options:e,...Q(t)})}var ZM=$(`ZodIntersection`,(e,t)=>{pk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zj(e,t,n,r)});function QM(e,t){return new ZM({type:`intersection`,left:e,right:t})}var $M=$(`ZodEnum`,(e,t)=>{gk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mj(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new $M({...t,checks:[],...Q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new $M({...t,checks:[],...Q(r),entries:i})}});function eN(e,t){return new $M({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Q(t)})}var tN=$(`ZodTransform`,(e,t)=>{fM(),_k.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pj(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new BE(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(xE(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(xE(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function nN(e){return new tN({type:`transform`,transform:e})}var rN=$(`ZodOptional`,(e,t)=>{yk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function iN(e){return new rN({type:`optional`,innerType:e})}var aN=$(`ZodExactOptional`,(e,t)=>{bk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oN(e){return new aN({type:`optional`,innerType:e})}var sN=$(`ZodNullable`,(e,t)=>{xk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cN(e){return new sN({type:`nullable`,innerType:e})}var lN=$(`ZodDefault`,(e,t)=>{Sk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function uN(e,t){return new lN({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():qT(t)}})}var dN=$(`ZodPrefault`,(e,t)=>{wk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fN(e,t){return new dN({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():qT(t)}})}var pN=$(`ZodNonOptional`,(e,t)=>{Tk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mN(e,t){return new pN({type:`nonoptional`,innerType:e,...Q(t)})}var hN=$(`ZodCatch`,(e,t)=>{Ok.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gN(e,t){return new hN({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:PE(t)})}var _N=$(`ZodPipe`,(e,t)=>{kk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qj(e,t,n,r),e.in=t.in,e.out=t.out});function vN(e,t){return new _N({type:`pipe`,in:e,out:t})}var yN=$(`ZodReadonly`,(e,t)=>{jk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jj(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bN(e){return new yN({type:`readonly`,innerType:e})}var xN=$(`ZodCustom`,(e,t)=>{Nk.init(e,t),pM.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nj(e,t,n,r)});function SN(e,t={}){return XA(xN,e,t)}function CN(e,t){return ZA(e,t)}JM({clientOperationId:gM().uuid(),command:gM().min(1).max(8192).refine(e=>!!e.trim()&&!e.includes(`\0`))}).strict();var wN=e=>e.status===`running`||e.status===`stopping`;function TN(e){let[t,n]=(0,O.useState)([]),[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(),p=(0,O.useRef)({revision:0}),m=(0,O.useRef)(s);m.current=s;let h=(0,O.useRef)(5e3);h.current=e||t.some(wN)||s?500:5e3;let g=(0,O.useCallback)((e,t=!1)=>{n(n=>{let r=new Map(n.map(e=>[e.id,t&&wN(e)?{...e,status:`unknown`,error:`服务已重启,无法恢复执行状态;已收到的输出已保留。`}:e]));for(let n of e){let e=r.get(n.id);(!e||t||e.revision<=n.revision)&&r.set(n.id,n)}return[...r.values()].sort((e,t)=>t.startedAt-e.startedAt).slice(0,20)})},[]),_=(0,O.useCallback)(async e=>{let t=p.current,n=await Re(`/api/shell?${new URLSearchParams({after:String(t.revision),...t.epoch?{epoch:t.epoch}:{}})}`,void 0,e??AbortSignal.timeout(5e3));if(e?.aborted)return;let r=!!(t.epoch&&t.epoch!==n.epoch);(n.commands.length||r)&&g(n.commands,r),p.current={epoch:n.epoch,revision:n.revision},i(!0);let a=m.current;if(a){if(n.commands.find(e=>e.id===a.id)){c(void 0),o(void 0);return}let t;try{t=await Re(`/api/operations/${a.id}`,void 0,e)}catch{return}if(t.status===`acknowledged`){let e=t.result?.shellCommand;e&&!n.commands.some(t=>t.id===e.id)&&g([{...e,status:`unknown`,error:`执行已提交;记录已过期或服务已重启,请检查服务端结果。`}]),c(void 0),o(void 0)}else t.status===`failed`&&(c(void 0),o(t.error?.message??`命令未能启动`))}},[g]);return(0,O.useEffect)(()=>{let e=new AbortController,t,n=async()=>{try{await _(AbortSignal.any([e.signal,AbortSignal.timeout(5e3)]))}catch{e.signal.aborted||i(!1)}e.signal.aborted||(t=setTimeout(()=>{n()},h.current))};return n(),()=>{e.abort(),clearTimeout(t)}},[_,e]),{commands:t,connected:r,error:a,pending:s,submitting:l,interrupting:d,execute:async(e,t)=>{if(s||l)return!1;let n=crypto.randomUUID();u(!0),o(void 0);try{let r=await Re(`/api/projects/${encodeURIComponent(e)}/shell`,{clientOperationId:n,command:t});if(r.status===`acknowledged`)return g([r.result.shellCommand]),!0;if(r.status===`failed`)return o(r.error?.message??`命令未能启动`),!1;c({id:n,projectId:e,command:t})}catch(r){if(r instanceof Le&&r.status>=400&&r.status<500)return o(r.message),!1;c({id:n,projectId:e,command:t}),o(`提交结果未确认,正在核对;请勿重复执行。`)}finally{u(!1)}return!1},interrupt:async e=>{f(e),o(void 0);try{let t=await Re(`/api/shell/${encodeURIComponent(e)}/interrupt`,{clientOperationId:crypto.randomUUID()});t.status!==`acknowledged`&&o(t.error?.message??`中断结果尚未确认,请刷新后核对`),await _()}catch(e){o(e instanceof Error?e.message:`中断失败,请重试`)}finally{f(void 0)}},retry:async()=>{if(s&&!l){u(!0);try{let e=await Re(`/api/projects/${encodeURIComponent(s.projectId)}/shell`,{clientOperationId:s.id,command:s.command});e.status===`acknowledged`?(c(void 0),o(void 0),p.current={revision:0}):e.status===`failed`&&(c(void 0),o(e.error?.message??`命令未能启动`))}catch(e){o(e instanceof Error?e.message:`提交仍未确认`)}finally{u(!1)}}}}}var EN={running:`执行中`,stopping:`正在中断`,completed:`已完成`,failed:`执行失败`,interrupted:`已中断`,unknown:`结果未知`};function DN({open:e,project:t,shell:n,canExecute:r,collapsed:i,onCollapse:a,onClose:o}){let[s,c]=(0,O.useState)({}),[l,u]=(0,O.useState)({}),d=(0,O.useRef)(null),f=t?.id??``,p=n.commands.filter(e=>e.projectId===f),m=p.find(e=>e.id===l[f])??p[0],h=p.find(wN),g=n.commands.filter(e=>e.projectId!==f&&wN(e)),_=s[f]??``,v=e=>c(t=>({...t,[f]:e}));return(0,O.useEffect)(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[m?.revision,m?.id,i,e]),e?(0,W.jsxs)(`section`,{className:`shell-panel${i?` shell-collapsed`:``}`,"aria-label":`Shell 面板`,children:[(0,W.jsxs)(`header`,{className:`shell-header`,children:[(0,W.jsxs)(`div`,{className:`shell-heading`,children:[(0,W.jsx)(J,{name:`terminal`,size:17}),(0,W.jsx)(`strong`,{children:`Shell`}),(0,W.jsx)(`span`,{children:t?.name??`请选择项目`}),h&&(0,W.jsx)(`span`,{className:`shell-running`,children:EN[h.status]})]}),(0,W.jsxs)(`div`,{className:`shell-actions`,children:[(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":i?`展开 Shell`:`收起 Shell`,"aria-expanded":!i,"aria-controls":`shell-body`,onClick:a,children:(0,W.jsx)(J,{name:i?`terminal`:`down`,size:15})}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭 Shell 面板`,onClick:o,children:(0,W.jsx)(J,{name:`close`,size:15})})]})]}),i?(0,W.jsxs)(`p`,{className:`shell-collapsed-note`,children:[`收起不会停止命令`,g.length?` · 另有 ${g.length} 个项目正在执行`:``]}):(0,W.jsxs)(`div`,{id:`shell-body`,className:`shell-body`,children:[(0,W.jsxs)(`div`,{className:`shell-location`,children:[(0,W.jsx)(`span`,{children:`工作目录`}),(0,W.jsx)(`code`,{children:t?.canonicalRoot??`—`})]}),(0,W.jsx)(`p`,{className:`shell-help`,children:`命令执行面板 · 使用 Codex 服务端配置的沙箱,独立于会话权限。每次从项目根目录启动,不支持交互输入。收起、关闭或切换项目均不会停止命令。`}),g.length>0&&(0,W.jsxs)(`p`,{className:`shell-background`,role:`status`,children:[`其他项目仍在执行:`,g.map(e=>e.projectName).join(`、`),`。切回对应项目可查看或中断。`]}),!n.connected&&(0,W.jsx)(`p`,{className:`shell-warning`,role:`status`,children:`Shell 连接已断开,正在重连。已收到的输出已保留,运行状态待确认;断开浏览器不会停止命令。`}),n.error&&(0,W.jsx)(`p`,{className:`shell-warning`,role:`alert`,children:n.error}),n.pending&&(0,W.jsxs)(`div`,{className:`shell-warning`,role:`status`,children:[`正在核对命令的提交结果:`,(0,W.jsx)(`code`,{children:n.pending.command}),` `,(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!n.connected||n.submitting,onClick:()=>void n.retry(),children:`核对并重试原提交`})]}),(0,W.jsxs)(`div`,{className:`shell-result`,children:[(0,W.jsxs)(`div`,{className:`shell-result-toolbar`,children:[(0,W.jsxs)(`label`,{children:[`近期命令`,(0,W.jsxs)(`select`,{"aria-label":`近期 Shell 命令`,value:m?.id??``,onChange:e=>u(t=>({...t,[f]:e.target.value})),children:[!p.length&&(0,W.jsx)(`option`,{value:``,children:`尚未执行`}),p.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[EN[e.status],` · `,e.command.slice(0,70)]},e.id))]})]}),m&&(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>v(m.command),children:`复用命令`})]}),m?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`shell-command-line`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,W.jsx)(`code`,{children:m.command})]}),(0,W.jsx)(`pre`,{ref:d,className:`shell-output`,"aria-label":`Shell 输出`,tabIndex:0,children:m.output.length?m.output.map((e,t)=>(0,W.jsx)(`span`,{className:e.stream===`stderr`?`shell-stderr`:void 0,children:e.text},t)):(0,W.jsx)(`span`,{className:`shell-output-empty`,children:wN(m)?`等待输出…`:`无输出`})}),(0,W.jsxs)(`div`,{className:`shell-result-status shell-status-${m.status}`,role:`status`,children:[(0,W.jsx)(`span`,{children:EN[m.status]}),m.exitCode!==void 0&&(0,W.jsxs)(`span`,{children:[`退出码 `,m.exitCode]}),m.truncated&&(0,W.jsx)(`span`,{children:`输出已截断(最多 64 KiB)`})]}),m.error&&(0,W.jsx)(`p`,{className:`shell-warning`,role:`alert`,children:m.error})]}):(0,W.jsxs)(`div`,{className:`shell-empty`,children:[(0,W.jsx)(J,{name:`terminal`,size:25}),(0,W.jsx)(`p`,{children:`在项目目录中运行命令,实时查看输出。`}),(0,W.jsx)(`span`,{children:`例如 git status、pwd 或运行项目测试`})]})]}),(0,W.jsxs)(`form`,{className:`shell-form`,onSubmit:e=>{if(e.preventDefault(),!t||!r||!n.connected||h||n.pending||!_.trim())return;let i=t.id;n.execute(i,_).then(e=>{e&&(c(e=>e[i]===_?{...e,[i]:``}:e),u(e=>({...e,[i]:``})))})},children:[(0,W.jsx)(`label`,{className:`sr-only`,htmlFor:`shell-command-input`,children:`Shell 命令`}),(0,W.jsx)(`textarea`,{id:`shell-command-input`,rows:2,maxLength:8192,value:_,onChange:e=>v(e.target.value),placeholder:`输入命令…`,disabled:!t?.available,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&e.currentTarget.form?.requestSubmit()}}),(0,W.jsxs)(`div`,{className:`shell-submit-row`,children:[(0,W.jsx)(`span`,{children:h?`命令在服务端运行,可随时中断`:`Ctrl / ⌘ + Enter 执行 · 最长 10 分钟`}),h?(0,W.jsxs)(q,{variant:`destructive`,size:`sm`,disabled:!n.connected||!!n.interrupting||h.status===`stopping`,onClick:()=>void n.interrupt(h.id),children:[(0,W.jsx)(J,{name:`stop`,size:13}),h.status===`stopping`||n.interrupting===h.id?`正在中断…`:`中断命令`]}):(0,W.jsxs)(q,{type:`submit`,size:`sm`,disabled:!r||!n.connected||!_.trim()||!!n.pending||n.submitting,children:[(0,W.jsx)(J,{name:`terminal`,size:14}),n.submitting?`正在提交…`:`执行命令`]})]})]})]})]}):null}var ON=encodeURIComponent;function kN({threadId:e,getHistoryCursor:t,children:n}){return(0,W.jsx)(`div`,{className:`app-shell`,children:(0,W.jsx)(bb,{threadId:e,getHistoryCursor:t,children:n})})}function AN(){let e=Er(),[t,n]=(0,O.useState)(!1),r=TN(t),[i,a]=(0,O.useState)(!1),o=TT(),[s,c]=(0,O.useState)(!1),{isUnreadCompletion:l,markCompletedRead:u}=jr(),[d,f]=(0,O.useState)(!1),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1);(0,O.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&f(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[_,v]=(0,O.useState)(!1),[y,b]=(0,O.useState)(!1),x=(0,O.useRef)(!1),[S,C]=(0,O.useState)(),[w,T]=(0,O.useState)(!1),[E,D]=(0,O.useState)(!1),k=(0,O.useRef)(!1),A=e.projects.find(t=>t.id===e.projectId),j=S?.kind===`manage`?e.projects.find(e=>e.id===S.id):void 0;(0,O.useEffect)(()=>{S?.kind===`manage`&&!j&&C(void 0)},[S,j]);let M=()=>{f(!1),C({kind:`add`})},{thread:N,system:F}=e,I=e.authRequired||!!(e.threadReadFailure&&e.threadReadFailure.id===e.selectedId&&[401,403,404].includes(e.threadReadFailure.status)),L=wT(N,e.selectedId,{projectId:e.projectId,scope:e.cacheScope,forbidden:I}),ee=(0,O.useRef)(void 0),te=!(!F?.ready||F.authenticated===!1||e.connection!==`connected`||e.authRequired),R=te&&!!A?.available&&!Hn(F),ne=Wn(F,e.connection,e.authRequired),re=Vn(F)??``,ie=(t,n=N?.id??``)=>e.busy.includes(`${t}:${n}`),ae=t=>e.operations.some(e=>Fn(e,t)),oe=N?.turns.findLast(e=>kl(e.status)),se=N?.actions.filter(e=>e.status===`pending`||e.status===`responding`||e.kind===`unsupported`&&e.status===`expired`)??[],ce=N?ae(N.id)&&!ie(`resume`)||N.managed&&N.status===`unknown`||N.execution&&!N.execution.ended&&N.status===`unknown`:!ie(`create`,e.projectId)&&ae(e.projectId),le=!!(N&&(!R||N.archived||ae(N.id)||ie(`resume`)||N.execution&&!N.execution.ended)),{run:ue,refreshThread:de}=e,z=(0,O.useCallback)(()=>{N&&!le&&(ee.current=`${F?.codexEpoch}:${N.id}`,ue(`resume`,N.id,`/api/threads/${ON(N.id)}/resume`).then(()=>de()))},[N,le,F?.codexEpoch,ue,de]);(0,O.useEffect)(()=>{if((!F?.ready||N?.archived)&&(ee.current=void 0),!N||N.managed||le)return;let e=`${F?.codexEpoch}:${N.id}`;ee.current!==e&&z()},[N,F?.ready,F?.codexEpoch,le,z]);let fe=!!(N&&e.operations.some(e=>e.kind===`fork`&&Fn(e,N.id))),pe=F?.capabilities.includes(`thread/fork`)??!1,me=t=>ie(`fork`,t)||e.operations.some(e=>e.kind===`fork`&&Fn(e,t)),he=t=>{if(me(t.id))return`正在确认 Fork…请等待提交回执,暂时不能再次 Fork。`;if(!pe)return`当前 Codex 版本不支持 Fork 会话。`;if(!te)return`连接恢复且 Codex 就绪后可 Fork 会话。`;if(!e.projects.find(e=>e.id===t.projectId)?.available)return`项目目录不可用,恢复后可 Fork 会话。`;if(Hn(F))return`请先确认当前 Codex 版本的兼容性。`;if(t.historyVisible===!1||t.id===N?.id&&!N.turns.length)return`发送首条消息后可 Fork 已保存的历史。`},ge=!!(N&&me(N.id)),_e=!(!N?.turns.length||he(N)),ye=async t=>{if(!he(t))return e.run(`fork`,t.id,`/api/threads/${ON(t.id)}/fork`,t.id===N?.id?{settings:e.settings}:{})},be=()=>{N&&_e&&ye(N)},xe=e.connection!==`connected`,Se=e.operations.filter(e=>e.kind===`confirmCompatibility`&&e.target===re),Ce=w||ie(`confirmCompatibility`,re)||Se.some(e=>e.status===`accepted`||e.status===`dispatching`),we=Se.some(e=>e.status===`unknown`&&!e.operation?.reconciliation);async function Te(){if(!x.current){x.current=!0,b(!0);try{await Promise.all([e.refreshSystem(),e.refreshThread()]),await e.refreshOperations(!0)}finally{x.current=!1,b(!1)}}}async function Ee(){if(ne&&!k.current){k.current=!0,T(!0);try{let t=await e.refreshSystem(),n=Kn(re,t,e.connection,e.authRequired);if(!n)return;await e.run(`confirmCompatibility`,re,`/api/system/compatibility/confirm`,n)}finally{k.current=!1,T(!1)}}}let De={project:A,selectedId:e.selectedId,thread:N,system:F,connection:e.connection,authRequired:e.authRequired,settings:e.settings,openDraft:e.openDraft,busy:e.busy,operations:e.operations,run:e.run,onResumeAttempt:()=>{ee.current=`${F?.codexEpoch}:${N?.id}`},refreshThread:e.refreshThread,openStatus:()=>v(!0),exportThread:Kw},Oe=(0,O.useRef)(De);Oe.current=De;let ke=ww(()=>Oe.current),Ae=ke.find(e=>e.name===`rename`);async function je(t,n,r){return!R||e.restoringSelection||e.savingModelDefaults?!1:N?n&&!oe?!1:(await e.run(n?`steer`:`send`,N.id,`/api/threads/${ON(N.id)}/${n?`steer`:`turns`}`,n?{text:t,images:r,expectedTurnId:oe.id}:{text:t,images:r,settings:e.settings},{kind:`send`,key:e.draftKey,text:t,images:r}))?.status===`acknowledged`:!e.selectedId&&e.sendFirstMessage(t,r)}return(0,W.jsxs)(kN,{threadId:N?.id,getHistoryCursor:L.getHistoryCursor,children:[(0,W.jsx)(Rl,{onGatewaySettings:()=>{f(!1),g(!0)},onUpdates:()=>{f(!1),c(!0)},appVersion:o.status?.version,updateAvailable:!!(o.status?.available&&o.status.available.version!==o.status.version),updating:fT(o.status?.run),onNotificationSettings:()=>{f(!1),m(!0)},notificationStatus:e.notifications.error?`请检查设置`:e.notifications.enabled&&e.notifications.access===`granted`?`已开启`:`未开启`,archiveView:e.archiveView,onArchiveView:e.setArchiveView,onArchive:(t,n)=>{e.archiveThread(t,n)},onFork:e=>{ye(e).then(e=>{e?.status===`acknowledged`&&f(!1)})},forkDisabledReason:he,forking:me,archiveDisabledReason:t=>{if(ie(`archive`,t.id))return`正在保存…`;if(ae(t.id))return`请先核对会话操作的结果`;if(!te)return`连接恢复后可操作`;if(Hn(F))return`请先确认 Codex 版本兼容性`;if(!F?.capabilities.includes(t.archived?`thread/unarchive`:`thread/archive`))return`当前 Codex 不支持此操作`;if(!e.projects.find(e=>e.id===t.projectId)?.available)return`项目目录不可用`;if(!t.archived&&(kl(t.status)||t.pendingActionCount>0))return`任务结束并处理完待办后可归档`;if(!t.archived&&t.managed&&t.status===`unknown`)return`会话状态待核对,暂时无法归档`},projects:e.projects,projectsLoaded:e.projectsLoaded,projectId:e.projectId,onProject:t=>{e.setProjectId(t),f(!1)},projectThreads:e.projectThreads,selectedId:e.selectedId,isUnreadCompletion:l,onThread:(t,n)=>{e.selectThread(t,n)},onMore:(t,n)=>{e.loadProjectThreads(t,n)},onRetry:t=>{e.loadProjectThreads(t,e.projectThreads[t]?.retryCursor)},onRefresh:()=>{e.refreshProjects().then(e.refreshProjectsThreads)},onAddProject:M,onManageProject:e=>{f(!1),C({kind:`manage`,id:e.id})},canManageProjects:!e.authRequired,onCreate:t=>{e.setProjectId(t),f(!1)},creating:t=>e.firstMessages.includes(t)||ie(`create`,t)||ae(t),canCreate:t=>te&&!e.savingModelDefaults&&!Hn(F)&&!!e.projects.find(e=>e.id===t)?.available,offline:xe,open:d,onClose:()=>f(!1)}),(0,W.jsxs)(`main`,{className:`main-panel${t&&!i?` shell-visible`:``}`,children:[(0,W.jsxs)(`header`,{className:`topbar`,children:[(0,W.jsxs)(`div`,{className:`topbar-title`,children:[(0,W.jsx)(q,{className:`mobile-only`,variant:`ghost`,size:`icon`,"aria-label":`打开项目与会话`,onClick:()=>f(!0),children:(0,W.jsx)(J,{name:`menu`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`breadcrumb`,children:[A?.name??`工作空间`,(0,W.jsx)(J,{name:`chevron`,size:12}),(0,W.jsx)(`span`,{children:e.selectedId?`会话`:`新会话`})]}),N?(0,W.jsx)(Xb,{title:N.title||`新会话`,rename:Ae,pending:!!(N&&e.operations.some(e=>e.kind===`rename`&&Fn(e,N.id)))},`${N.projectId}:${N.id}`):(0,W.jsx)(`h1`,{children:e.selectedId?L.thread?.title??e.threads.find(t=>t.id===e.selectedId)?.title??`正在读取会话…`:`开始你的下一项任务`})]})]}),(0,W.jsxs)(`div`,{className:`topbar-status`,children:[(0,W.jsxs)(q,{variant:`ghost`,size:`sm`,className:`shell-entry`,"aria-label":`打开 Shell 面板`,"aria-expanded":t&&!i,onClick:()=>{n(!0),a(!1)},children:[(0,W.jsx)(J,{name:`terminal`,size:16}),(0,W.jsx)(`span`,{children:`Shell`}),r.commands.some(wN)&&(0,W.jsx)(`span`,{className:`shell-entry-count`,"aria-label":`运行中的 Shell 命令`,children:r.commands.filter(wN).length})]}),N&&(0,W.jsx)(Al,{status:N.status,offline:xe}),(0,W.jsx)(Uw,{connection:e.connection}),N?.forkedFromId&&(0,W.jsx)(ol,{id:`thread-source-hint`,content:`返回原会话`,children:(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`返回原会话`,"aria-describedby":`thread-source-hint`,onClick:()=>{e.selectThread(N.forkedFromId)},children:(0,W.jsx)(P,{size:16})})}),(0,W.jsx)(Gw,{system:F,connection:e.connection,operations:e.operations,thread:N,selectedId:e.selectedId,threadReadFailed:e.threadReadFailure?.id===e.selectedId,busy:e.busy,open:_,onOpenChange:v,refreshing:y,onDiscardMissing:e.discardMissingOperation,onRefresh:()=>{Te(),xe&&e.retryConnection()},onReconcile:t=>{e.run(`reconcile`,t,`/api/operations/${ON(t)}/reconcile`,{confirmEnded:!0}).then(e=>{if(e?.status===`acknowledged`)return Te()})}})]})]}),F?.demo&&(0,W.jsx)(`div`,{className:`demo-banner`,children:`模拟测试模式 · 当前执行结果来自显式启用的测试 app-server`}),e.authRequired?(0,W.jsxs)(`div`,{className:`error-banner persistent-banner`,role:`alert`,children:[(0,W.jsx)(J,{name:`alert`}),`登录已过期。任务不会因页面断开而被取消。`,(0,W.jsx)(`a`,{className:`button button-secondary button-small`,href:`/`,children:`重新打开登录入口`})]}):xe&&(0,W.jsxs)(`div`,{className:`connection-banner`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[`实时连接`,e.connection===`connecting`?`正在建立`:`已断开,正在重连`,`。当前显示上次已知状态。`]}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e.retryConnection,children:`立即重连`})]}),F&&!F.ready&&(0,W.jsxs)(`div`,{className:`error-banner persistent-banner`,role:`alert`,children:[`Codex 尚不可用:`,F.error??`请在私人电脑上检查 Codex 安装、认证与服务状态。`]}),(0,W.jsx)(qw,{system:F,onOpenChange:D,canConfirm:ne,submitting:Ce,uncertain:we,error:e.error,onRefresh:()=>{e.refreshSystem(),e.refreshOperations()},onConfirm:()=>{Ee()},onReconfirm:()=>{Ee()}}),e.error&&(0,W.jsxs)(`div`,{className:`error-banner dismissible`,role:`alert`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:e.error}),e.errorDetails!==void 0&&(0,W.jsxs)(`details`,{className:`raw-details`,children:[(0,W.jsx)(`summary`,{children:`错误详情`}),(0,W.jsx)(`pre`,{children:JSON.stringify(e.errorDetails,null,2)})]})]}),(0,W.jsx)(q,{variant:`ghost`,size:`icon`,"aria-label":`关闭错误提示`,onClick:e.clearError,children:(0,W.jsx)(J,{name:`close`,size:15})})]}),e.operations.filter(e=>e.mutation).map(e=>(0,W.jsxs)(`div`,{className:`archive-notice mutation-notice`,role:`status`,children:[e.kind===`rename`?(0,W.jsx)(ve,{size:16}):(0,W.jsx)(J,{name:`archive`,size:16}),(0,W.jsx)(`span`,{children:e.kind===`rename`?e.status===`unknown`?`重命名结果待确认`:`正在保存会话名称…`:e.mutation.archived?e.status===`unknown`?`归档结果待确认`:`正在归档会话…`:e.status===`unknown`?`取消归档结果待确认`:`正在取消归档…`}),e.status===`unknown`&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:y,onClick:()=>void Te(),children:y?`正在核对…`:`核对提交`})]},e.clientOperationId)),N?.archived&&(0,W.jsxs)(`div`,{className:`archive-notice`,role:`status`,children:[(0,W.jsx)(J,{name:`archive`,size:18}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`此会话已归档`}),(0,W.jsx)(`p`,{children:`历史已保留。取消归档后可继续对话。`})]}),(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!R||ae(N.id)||ie(`archive`)||!F?.capabilities.includes(`thread/unarchive`),onClick:()=>{e.archiveThread(N.id,!1)},children:ie(`archive`)?`正在保存…`:`取消归档`})]}),(0,W.jsx)(Jb,{thread:L.thread,history:{cached:L.cached,cacheExhausted:L.cacheExhausted,onLoadCachedOlder:L.loadCachedOlder,syncError:N?L.error:e.error,loading:L.loading,error:L.error,onLoadOlder:L.loadOlder,opening:!(!e.selectedId||N),openingError:N?void 0:e.error,onRetryOpen:()=>{e.clearError(),L.error&&L.loadOlder(),e.refreshThread()}},readingEnabled:!d&&!S&&!_&&!e.authRequired&&!E,onReadCompleted:u,offline:xe,projectName:A?.name,needsProject:e.projectsLoaded&&e.projects.length===0,canAddProject:!e.authRequired,onAddProject:M,questionControls:{disabled:!R||!N?.managed||!!N.archived||!!ce||ie(`send`)||ie(`steer`)||ie(`resume`),onReply:async e=>je(wb(e),!!oe)}}),(0,W.jsxs)(`div`,{className:`bottom-region`,children:[se.length>0&&(0,W.jsx)(`div`,{className:`pending-actions`,"aria-label":`待处理请求`,children:se.map(t=>(0,W.jsx)(Bw,{action:t,disabled:!R||ie(`resolve`,t.actionId)||ae(t.actionId),onResolve:n=>{e.run(`resolve`,t.actionId,`/api/actions/${ON(t.actionId)}/resolve`,{resolution:n})}},t.actionId))}),ce&&(0,W.jsxs)(`div`,{className:`pending-notice`,role:`status`,children:[(0,W.jsx)(J,{name:`alert`,size:15}),(0,W.jsx)(`span`,{children:N?fe?`Fork 结果尚未确认。请核对提交,暂时不能再次 Fork。`:`提交结果尚未确认。请核对提交,也可以 Fork 已保存的历史为新会话。`:`新建会话的提交结果尚未确认。请先核对提交,避免重复创建。`}),(0,W.jsx)(q,{variant:`ghost`,size:`sm`,disabled:y,"aria-expanded":_,"aria-controls":`diagnostics-panel`,onClick:()=>{v(!0),Te()},children:y?`正在核对…`:`核对提交`}),N&&!fe&&(0,W.jsx)(q,{variant:`secondary`,size:`sm`,disabled:!_e,onClick:be,children:`Fork 为新会话`})]}),(0,W.jsx)(Ew,{commands:ke,thread:N,threadLoading:e.restoringSelection||!(!e.selectedId||N),draftKey:e.draftKey,sentDrafts:e.sentDrafts,projectName:A?.name,projectId:A?.available?A.id:void 0,runtimeKey:F?.ready&&e.connection===`connected`?`${F.codexEpoch}:${e.runtimeDefaultsRevision}`:void 0,settings:e.settings,models:F?.models??[],onSettings:e.setSettings,onSaveModelDefaults:e.saveModelDefaults,savingModelDefaults:e.savingModelDefaults,disabled:!R||e.restoringSelection||!!ce||!!N?.archived,canInterrupt:te&&!!(N?.managed&&oe),submitting:e.firstMessages.includes(e.projectId)||ie(`send`)||ie(`steer`),interrupting:ie(`interrupt`),resuming:ie(`resume`),canResume:!le,resumeAttempted:ee.current===`${F?.codexEpoch}:${N?.id}`,canFork:_e,forking:ge,onFork:be,onResume:z,onInterrupt:()=>{N&&oe&&e.run(`interrupt`,N.id,`/api/threads/${ON(N.id)}/interrupt`,{expectedTurnId:oe.id})},onSend:je})]}),(0,W.jsx)(DN,{open:t,project:A,shell:r,canExecute:R&&!!F?.capabilities.includes(`command/exec`),collapsed:i,onCollapse:()=>a(e=>!e),onClose:()=>n(!1)})]}),S&&(S.kind===`add`||j)&&(0,W.jsx)(Jw,{project:j,disabled:e.authRequired,onAdd:e.addProject,onRename:e.renameProject,onRemove:e.removeProject,onClose:()=>C(e=>e===S?void 0:e)},S.kind===`add`?`add`:S.id),p&&(0,W.jsx)(Yw,{notifications:e.notifications,onClose:()=>m(!1)}),h&&(0,W.jsx)(uT,{onClose:()=>g(!1)}),s&&(0,W.jsx)(_T,{updates:o,onClose:()=>c(!1)})]})}(0,ke.createRoot)(document.getElementById(`root`)).render((0,W.jsx)(O.StrictMode,{children:(0,W.jsx)(AN,{})}));
|