@clawos-dev/clawd 0.2.503 → 0.2.505
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-builder-plugin/mcp-server.cjs +2 -2
- package/dist/cli.cjs +12 -12
- package/dist/dispatch/mcp-server.cjs +2 -2
- package/dist/persona-defaults/persona-clawd-butler/.claude/skills/scan-persona-for-deploy/SKILL.md +58 -7
- package/dist/share-md-viewer-error.html +1 -1
- package/dist/share-md-viewer.html +1 -1
- package/dist/share-ui/assets/guest-BllOBGLj.css +32 -0
- package/dist/share-ui/assets/{guest-DzRUzO30.js → guest-Uh00t3gI.js} +2 -2
- package/dist/share-ui/guest.html +2 -2
- package/package.json +1 -1
- package/dist/share-ui/assets/guest-BDtdGETg.css +0 -32
|
@@ -92,7 +92,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
92
92
|
0 -6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
93
93
|
0 -3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
94
94
|
0 -9px 28px 8px rgba(0, 0, 0, 0.05)
|
|
95
|
-
`,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var mw=function(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};const wO={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},SO={motionBase:!0,motionUnit:!0},kO={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},ST=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=mw(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=wT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=mw(l,["theme"]);let d=u;c&&(d=ST(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function kT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Ke.useContext(yT),s=`${yO}-${t||""}`,o=n||_T,[a,l,c]=uD(o,[Yc,e],{salt:s,override:r,getComputedToken:ST,formatToken:wT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:wO,ignore:SO,preserve:kO}});return[o,c,t?l:"",a,i]}const CO=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),EO=e=>({[`.${e}`]:Object.assign(Object.assign({},CO()),{[`.${e} .${e}-icon`]:{display:"block"}})}),NO=(e,t)=>{const[n,r]=kT();return BD({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>EO(e))},TO=Object.assign({},cl),{useId:gw}=TO,IO=()=>"",PO=typeof gw>"u"?IO:gw;function RO(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},Vh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Vh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=PO();return HN(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!BL(c,d,!0)}))}var AO=["children"],CT=g.createContext({});function MO(e){var t=e.children,n=Dv(e,AO);return g.createElement(CT.Provider,{value:n},t)}var jO=function(e){WN(n,e);var t=qN(n);function n(){return fl(this,n),t.apply(this,arguments)}return pl(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function LO(e){var t=g.useReducer(function(a){return a+1},0),n=et(t,2),r=n[1],i=g.useRef(e),s=i0(function(){return i.current}),o=i0(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var fs="none",cd="appear",ud="enter",dd="leave",vw="none",Br="prepare",Sa="start",ka="active",$_="end",ET="prepared";function xw(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function DO(e,t){var n={animationend:xw("Animation","AnimationEnd"),transitionend:xw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var OO=DO(Zi(),typeof window<"u"?window:{}),NT={};if(Zi()){var BO=document.createElement("div");NT=BO.style}var hd={};function TT(e){if(hd[e])return hd[e];var t=OO[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in NT)return hd[e]=t[s],hd[e]}return""}var IT=TT("animationend"),PT=TT("transitionend"),RT=!!(IT&&PT),_w=IT||"animationend",yw=PT||"transitionend";function bw(e,t){if(!e)return null;if(Mt(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const zO=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(yw,e),i.removeEventListener(_w,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(yw,e),i.addEventListener(_w,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var AT=Zi()?g.useLayoutEffect:g.useEffect;const $O=function(){var e=g.useRef(null);function t(){jv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=jv(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var FO=[Br,Sa,ka,$_],HO=[Br,ET],MT=!1,UO=!0;function jT(e){return e===ka||e===$_}const WO=function(e,t,n){var r=s0(vw),i=et(r,2),s=i[0],o=i[1],a=$O(),l=et(a,2),c=l[0],u=l[1];function d(){o(Br,!0)}var f=t?HO:FO;return AT(function(){if(s!==vw&&s!==$_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===MT?o(m,!0):m&&c(function(w){function x(){w.isCanceled()||o(m,!0)}v===!0?x():Promise.resolve(v).then(x)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function VO(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,w=r.onEnterStart,x=r.onLeaveStart,_=r.onAppearActive,y=r.onEnterActive,S=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,T=r.onVisibleChanged,D=s0(),P=et(D,2),O=P[0],R=P[1],A=LO(fs),M=et(A,2),L=M[0],$=M[1],F=s0(null),B=et(F,2),z=B[0],E=B[1],H=L(),q=g.useRef(!1),j=g.useRef(null);function re(){return n()}var ie=g.useRef(!1);function K(){$(fs),E(null,!0)}var _e=i0(function(Xe){var nt=L();if(nt!==fs){var zt=re();if(!(Xe&&!Xe.deadline&&Xe.target!==zt)){var xn=ie.current,tn;nt===cd&&xn?tn=C==null?void 0:C(zt,Xe):nt===ud&&xn?tn=k==null?void 0:k(zt,Xe):nt===dd&&xn&&(tn=N==null?void 0:N(zt,Xe)),xn&&tn!==!1&&K()}}}),Ee=zO(_e),ue=et(Ee,1),je=ue[0],Me=function(nt){switch(nt){case cd:return Ce(Ce(Ce({},Br,f),Sa,v),ka,_);case ud:return Ce(Ce(Ce({},Br,p),Sa,w),ka,y);case dd:return Ce(Ce(Ce({},Br,m),Sa,x),ka,S);default:return{}}},Oe=g.useMemo(function(){return Me(H)},[H]),xe=WO(H,!e,function(Xe){if(Xe===Br){var nt=Oe[Br];return nt?nt(re()):MT}if(st in Oe){var zt;E(((zt=Oe[st])===null||zt===void 0?void 0:zt.call(Oe,re(),null))||null)}return st===ka&&H!==fs&&(je(re()),u>0&&(clearTimeout(j.current),j.current=setTimeout(function(){_e({deadline:!0})},u))),st===ET&&K(),UO}),tt=et(xe,2),Nt=tt[0],st=tt[1],pt=jT(st);ie.current=pt;var Dt=g.useRef(null);AT(function(){if(!(q.current&&Dt.current===t)){R(t);var Xe=q.current;q.current=!0;var nt;!Xe&&t&&a&&(nt=cd),Xe&&t&&s&&(nt=ud),(Xe&&!t&&c||!Xe&&d&&!t&&c)&&(nt=dd);var zt=Me(nt);nt&&(e||zt[Br])?($(nt),Nt()):$(fs),Dt.current=t}},[t]),g.useEffect(function(){(H===cd&&!a||H===ud&&!s||H===dd&&!c)&&$(fs)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(j.current)}},[]);var mt=g.useRef(!1);g.useEffect(function(){O&&(mt.current=!0),O!==void 0&&H===fs&&((mt.current||O)&&(T==null||T(O)),mt.current=!0)},[O,H]);var gt=z;return Oe[Br]&&st===Sa&&(gt=He({transition:"none"},gt)),[H,st,gt,O??t]}function qO(e){var t=e;Mt(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(CT),w=v.motion,x=n(i,w),_=g.useRef(),y=g.useRef();function S(){try{return _.current instanceof HTMLElement?_.current:bL(y.current)}catch{return null}}var C=VO(x,a,S,i),k=et(C,4),N=k[0],T=k[1],D=k[2],P=k[3],O=g.useRef(P);P&&(O.current=!0);var R=g.useCallback(function(B){_.current=B,CL(s,B)},[s]),A,M=He(He({},m),{},{visible:a});if(!d)A=null;else if(N===fs)P?A=d(He({},M),R):!c&&O.current&&p?A=d(He(He({},M),{},{className:p}),R):u||!c&&!p?A=d(He(He({},M),{},{style:{display:"none"}}),R):A=null;else{var L;T===Br?L="prepare":jT(T)?L="active":T===Sa&&(L="start");var $=bw(f,"".concat(N,"-").concat(L));A=d(He(He({},M),{},{className:cL(bw(f,N),Ce(Ce({},$,$&&L),f,typeof f=="string")),style:D}),R)}if(g.isValidElement(A)&&EL(A)){var F=NL(A);F||(A=g.cloneElement(A,{ref:R}))}return g.createElement(jO,{ref:y},A)});return r.displayName="CSSMotion",r}const KO=qO(RT);var o0="add",a0="keep",l0="remove",Am="removed";function GO(e){var t;return e&&Mt(e)==="object"&&"key"in e?t=e:t={key:e},He(He({},t),{},{key:String(t.key)})}function c0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(GO)}function YO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=c0(e),o=c0(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return He(He({},p),{},{status:o0})})),r=d),n.push(He(He({},f),{},{status:a0})),r+=1,u=!0;break}}u||n.push(He(He({},c),{},{status:l0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return He(He({},c),{},{status:o0})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==l0}),n.forEach(function(u){u.key===c&&(u.status=a0)})}),n}var XO=["component","children","onVisibleChanged","onAllRemoved"],QO=["status"],ZO=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function JO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:KO,n=function(r){WN(s,r);var i=qN(s);function s(){var o;fl(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),Ce(Av(o),"state",{keyEntities:[]}),Ce(Av(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:He(He({},p),{},{status:Am})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Am}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return pl(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=Dv(c,XO),m=u||g.Fragment,v={};return ZO.forEach(function(w){v[w]=p[w],delete p[w]}),delete p.keys,g.createElement(m,p,l.map(function(w,x){var _=w.status,y=Dv(w,QO),S=_===o0||_===a0;return g.createElement(t,Hh({},v,{key:y.key,visible:S,eventProps:y,onVisibleChanged:function(k){f==null||f(k,{key:y.key}),k||a.removeKey(y.key)}}),function(C,k){return d(He(He({},C),{},{index:x}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=c0(c),f=YO(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var w=v.key;return p.key===w});return!(m&&m.status===Am&&p.status===l0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}JO(RT);const ww=g.createContext(!0);function e6(e){const t=g.useContext(ww),{children:n}=e,[,r]=kT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(ww.Provider,{value:i},g.createElement(MO,{motion:i},n)):n}const t6=()=>null;var n6=function(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};const r6=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let LT;function i6(){return LT||n0}function s6(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const o6=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(LT=t),r&&s6(r)&&pO(i6(),r)},a6=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:w,parentContext:x,iconPrefixCls:_,theme:y,componentDisabled:S,segmented:C,statistic:k,spin:N,calendar:T,carousel:D,cascader:P,collapse:O,typography:R,checkbox:A,descriptions:M,divider:L,drawer:$,skeleton:F,steps:B,image:z,layout:E,list:H,mentions:q,modal:j,progress:re,result:ie,slider:K,breadcrumb:_e,menu:Ee,pagination:ue,input:je,textArea:Me,empty:Oe,badge:xe,radio:tt,rate:Nt,switch:st,transfer:pt,avatar:Dt,message:mt,tag:gt,table:Xe,card:nt,tabs:zt,timeline:xn,timePicker:tn,upload:U,notification:Q,tree:ye,colorPicker:Pe,datePicker:Be,rangePicker:_t,flex:_n,wave:$t,dropdown:dn,warning:oe,tour:be,tooltip:Ze,popover:Tt,popconfirm:Ar,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Qs,treeSelect:Il}=e,Ko=g.useCallback((yt,Pt)=>{const{prefixCls:hr}=e;if(Pt)return Pt;const Qn=hr||x.getPrefixCls("");return yt?`${Qn}-${yt}`:Qn},[x.getPrefixCls,e.prefixCls]),ki=_||x.iconPrefixCls||bT,Go=n||x.csp;NO(ki,Go);const Yo=RO(y,x.theme,{prefixCls:Ko("")}),Xo={csp:Go,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||w,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Ko,iconPrefixCls:ki,theme:Yo,segmented:C,statistic:k,spin:N,calendar:T,carousel:D,cascader:P,collapse:O,typography:R,checkbox:A,descriptions:M,divider:L,drawer:$,skeleton:F,steps:B,image:z,input:je,textArea:Me,layout:E,list:H,mentions:q,modal:j,progress:re,result:ie,slider:K,breadcrumb:_e,menu:Ee,pagination:ue,empty:Oe,badge:xe,radio:tt,rate:Nt,switch:st,transfer:pt,avatar:Dt,message:mt,tag:gt,table:Xe,card:nt,tabs:zt,timeline:xn,timePicker:tn,upload:U,notification:Q,tree:ye,colorPicker:Pe,datePicker:Be,rangePicker:_t,flex:_n,wave:$t,dropdown:dn,warning:oe,tour:be,tooltip:Ze,popover:Tt,popconfirm:Ar,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Qs,treeSelect:Il},ss=Object.assign({},x);Object.keys(Xo).forEach(yt=>{Xo[yt]!==void 0&&(ss[yt]=Xo[yt])}),r6.forEach(yt=>{const Pt=e[yt];Pt&&(ss[yt]=Pt)}),typeof r<"u"&&(ss.button=Object.assign({autoInsertSpace:r},ss.button));const Ci=HN(()=>ss,ss,(yt,Pt)=>{const hr=Object.keys(yt),Qn=Object.keys(Pt);return hr.length!==Qn.length||hr.some(ee=>yt[ee]!==Pt[ee])}),{layer:Qo}=g.useContext(np),Yp=g.useMemo(()=>({prefixCls:ki,csp:Go,layer:Qo?"antd":void 0}),[ki,Go,Qo]);let It=g.createElement(g.Fragment,null,g.createElement(t6,{dropdownMatchSelectWidth:p}),t);const Fu=g.useMemo(()=>{var yt,Pt,hr,Qn;return qD(((yt=sp.Form)===null||yt===void 0?void 0:yt.defaultValidateMessages)||{},((hr=(Pt=Ci.locale)===null||Pt===void 0?void 0:Pt.Form)===null||hr===void 0?void 0:hr.defaultValidateMessages)||{},((Qn=Ci.form)===null||Qn===void 0?void 0:Qn.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Ci,o==null?void 0:o.validateMessages]);Object.keys(Fu).length>0&&(It=g.createElement(GD.Provider,{value:Fu},It)),a&&(It=g.createElement(QD,{locale:a,_ANT_MARK__:XD},It)),It=g.createElement(HD.Provider,{value:Yp},It),l&&(It=g.createElement(gO,{size:l},It)),It=g.createElement(e6,null,It);const Xp=g.useMemo(()=>{const yt=Yo||{},{algorithm:Pt,token:hr,components:Qn,cssVar:ee}=yt,we=n6(yt,["algorithm","token","components","cssVar"]),ke=Pt&&(!Array.isArray(Pt)||Pt.length>0)?Bv(Pt):_T,Qe={};Object.entries(Qn||{}).forEach(([Hu,I4])=>{const Ei=Object.assign({},I4);"algorithm"in Ei&&(Ei.algorithm===!0?Ei.theme=ke:(Array.isArray(Ei.algorithm)||typeof Ei.algorithm=="function")&&(Ei.theme=Bv(Ei.algorithm)),delete Ei.algorithm),Qe[Hu]=Ei});const Mr=Object.assign(Object.assign({},Yc),hr);return Object.assign(Object.assign({},we),{theme:ke,token:Mr,components:Qe,override:Object.assign({override:Mr},Qe),cssVar:ee})},[Yo]);return y&&(It=g.createElement(yT.Provider,{value:Xp},It)),Ci.warning&&(It=g.createElement(KD.Provider,{value:Ci.warning},It)),S!==void 0&&(It=g.createElement(mO,{disabled:S},It)),g.createElement(op.Provider,{value:Ci},It)},gl=e=>{const t=g.useContext(op),n=g.useContext(mT);return g.createElement(a6,Object.assign({parentContext:t,legacyLocale:n},e))};gl.ConfigContext=op;gl.SizeContext=Xc;gl.config=o6;gl.useConfig=vO;Object.defineProperty(gl,"SizeContext",{get:()=>Xc});const pr=(e,t)=>new kt(e).setA(t).toRgbString(),ea=(e,t)=>new kt(e).lighten(t).toHexString(),l6=e=>{const t=Ga(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},c6=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:pr(r,.85),colorTextSecondary:pr(r,.65),colorTextTertiary:pr(r,.45),colorTextQuaternary:pr(r,.25),colorFill:pr(r,.18),colorFillSecondary:pr(r,.12),colorFillTertiary:pr(r,.08),colorFillQuaternary:pr(r,.04),colorBgSolid:pr(r,.95),colorBgSolidHover:pr(r,1),colorBgSolidActive:pr(r,.9),colorBgElevated:ea(n,12),colorBgContainer:ea(n,8),colorBgLayout:ea(n,0),colorBgSpotlight:ea(n,26),colorBgBlur:pr(r,.04),colorBorder:ea(n,26),colorBorderSecondary:ea(n,19)}},u6=(e,t)=>{const n=Object.keys(B_).map(s=>{const o=Ga(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??z_(e),i=xT(e,{generateColorPalettes:l6,generateNeutralColorPalettes:c6});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},Sw={defaultSeed:Vh.token,defaultAlgorithm:z_,darkAlgorithm:u6};function kw({children:e}){const t=P_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(gl,{theme:{algorithm:n.mode==="dark"?Sw.darkAlgorithm:Sw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ge;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ge||(Ge={}));var Cw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Cw||(Cw={}));const he=Ge.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vs=e=>{switch(typeof e){case"undefined":return he.undefined;case"string":return he.string;case"number":return Number.isNaN(e)?he.nan:he.number;case"boolean":return he.boolean;case"function":return he.function;case"bigint":return he.bigint;case"symbol":return he.symbol;case"object":return Array.isArray(e)?he.array:e===null?he.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?he.promise:typeof Map<"u"&&e instanceof Map?he.map:typeof Set<"u"&&e instanceof Set?he.set:typeof Date<"u"&&e instanceof Date?he.date:he.object;default:return he.unknown}},G=Ge.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ki extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ki))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ge.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ki.create=e=>new Ki(e);const u0=(e,t)=>{let n;switch(e.code){case G.invalid_type:e.received===he.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case G.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ge.jsonStringifyReplacer)}`;break;case G.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ge.joinValues(e.keys,", ")}`;break;case G.invalid_union:n="Invalid input";break;case G.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ge.joinValues(e.options)}`;break;case G.invalid_enum_value:n=`Invalid enum value. Expected ${Ge.joinValues(e.options)}, received '${e.received}'`;break;case G.invalid_arguments:n="Invalid function arguments";break;case G.invalid_return_type:n="Invalid function return type";break;case G.invalid_date:n="Invalid date";break;case G.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ge.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case G.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case G.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case G.custom:n="Invalid input";break;case G.invalid_intersection_types:n="Intersection results could not be merged";break;case G.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case G.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ge.assertNever(e)}return{message:n}};let d6=u0;function h6(){return d6}const f6=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function se(e,t){const n=h6(),r=f6({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===u0?void 0:u0].filter(i=>!!i)});e.common.issues.push(r)}class jn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Te;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return jn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Te;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Te=Object.freeze({status:"aborted"}),tc=e=>({status:"dirty",value:e}),Ir=e=>({status:"valid",value:e}),Ew=e=>e.status==="aborted",Nw=e=>e.status==="dirty",Ya=e=>e.status==="valid",qh=e=>typeof Promise<"u"&&e instanceof Promise;var me;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(me||(me={}));class pi{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Tw=(e,t)=>{if(Ya(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ki(e.common.issues);return this._error=n,this._error}}};function De(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class Ve{get description(){return this._def.description}_getType(t){return vs(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:vs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new jn,ctx:{common:t.parent.common,data:t.data,parsedType:vs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(qh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:vs(t)},i=this._parseSync({data:t,path:r.path,parent:r});return Tw(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:vs(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Ya(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>Ya(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:vs(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(qh(i)?i:Promise.resolve(i));return Tw(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:G.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new Eo({schema:this,typeName:Ie.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return $i.create(this,this._def)}nullable(){return No.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ui.create(this)}promise(){return Zh.create(this,this._def)}or(t){return Gh.create([this,t],this._def)}and(t){return Yh.create(this,t,this._def)}transform(t){return new Eo({...De(this._def),schema:this,typeName:Ie.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Jh({...De(this._def),innerType:this,defaultValue:n,typeName:Ie.ZodDefault})}brand(){return new zT({typeName:Ie.ZodBranded,type:this,...De(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new ef({...De(this._def),innerType:this,catchValue:n,typeName:Ie.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return H_.create(this,t)}readonly(){return tf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const p6=/^c[^\s-]{8,}$/i,m6=/^[0-9a-z]+$/,g6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,v6=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,x6=/^[a-z0-9_-]{21}$/i,_6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,y6=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,b6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,w6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Mm;const S6=/^(?:(?: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])$/,k6=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,C6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,E6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,N6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DT="((\\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])))",I6=new RegExp(`^${DT}$`);function OT(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function P6(e){return new RegExp(`^${OT(e)}$`)}function R6(e){let t=`${DT}T${OT(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function A6(e,t){return!!((t==="v4"||!t)&&S6.test(e)||(t==="v6"||!t)&&C6.test(e))}function M6(e,t){if(!_6.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function j6(e,t){return!!((t==="v4"||!t)&&k6.test(e)||(t==="v6"||!t)&&E6.test(e))}class Di extends Ve{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==he.string){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_type,expected:he.string,received:s.parsedType}),Te}const r=new jn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?se(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&se(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")b6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"email",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Mm||(Mm=new RegExp(w6,"u")),Mm.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"emoji",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")v6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"uuid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")x6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"nanoid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")p6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")m6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid2",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")g6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ulid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),se(i,{validation:"url",code:G.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"regex",code:G.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?R6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?I6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?P6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?y6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"duration",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?A6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ip",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?M6(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"jwt",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?j6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cidr",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?N6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?T6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64url",code:G.invalid_string,message:s.message}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:G.invalid_string,...me.errToObj(r)})}_addCheck(t){return new Di({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...me.errToObj(t)})}url(t){return this._addCheck({kind:"url",...me.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...me.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...me.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...me.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...me.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...me.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...me.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...me.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...me.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...me.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...me.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...me.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...me.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...me.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...me.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...me.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...me.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...me.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...me.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...me.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...me.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...me.errToObj(n)})}nonempty(t){return this.min(1,me.errToObj(t))}trim(){return new Di({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Di({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Di({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Di.create=e=>new Di({checks:[],typeName:Ie.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...De(e)});function L6(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class Xa extends Ve{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==he.number){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_type,expected:he.number,received:s.parsedType}),Te}let r;const i=new jn;for(const s of this._def.checks)s.kind==="int"?Ge.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:G.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?L6(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:G.not_finite,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Xa({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Xa({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:me.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:me.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ge.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Xa.create=e=>new Xa({checks:[],typeName:Ie.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...De(e)});class Qc extends Ve{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==he.bigint)return this._getInvalidInput(t);let r;const i=new jn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return se(n,{code:G.invalid_type,expected:he.bigint,received:n.parsedType}),Te}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Qc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Qc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Qc.create=e=>new Qc({checks:[],typeName:Ie.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...De(e)});class d0 extends Ve{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==he.boolean){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.boolean,received:r.parsedType}),Te}return Ir(t.data)}}d0.create=e=>new d0({typeName:Ie.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...De(e)});class Kh extends Ve{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==he.date){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_type,expected:he.date,received:s.parsedType}),Te}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_date}),Te}const r=new jn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Kh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:me.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:me.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Kh.create=e=>new Kh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ie.ZodDate,...De(e)});class Iw extends Ve{_parse(t){if(this._getType(t)!==he.symbol){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.symbol,received:r.parsedType}),Te}return Ir(t.data)}}Iw.create=e=>new Iw({typeName:Ie.ZodSymbol,...De(e)});class h0 extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.undefined,received:r.parsedType}),Te}return Ir(t.data)}}h0.create=e=>new h0({typeName:Ie.ZodUndefined,...De(e)});class f0 extends Ve{_parse(t){if(this._getType(t)!==he.null){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.null,received:r.parsedType}),Te}return Ir(t.data)}}f0.create=e=>new f0({typeName:Ie.ZodNull,...De(e)});class Pw extends Ve{constructor(){super(...arguments),this._any=!0}_parse(t){return Ir(t.data)}}Pw.create=e=>new Pw({typeName:Ie.ZodAny,...De(e)});class p0 extends Ve{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ir(t.data)}}p0.create=e=>new p0({typeName:Ie.ZodUnknown,...De(e)});class zs extends Ve{_parse(t){const n=this._getOrReturnCtx(t);return se(n,{code:G.invalid_type,expected:he.never,received:n.parsedType}),Te}}zs.create=e=>new zs({typeName:Ie.ZodNever,...De(e)});class Rw extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.void,received:r.parsedType}),Te}return Ir(t.data)}}Rw.create=e=>new Rw({typeName:Ie.ZodVoid,...De(e)});class ui extends Ve{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==he.array)return se(n,{code:G.invalid_type,expected:he.array,received:n.parsedType}),Te;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(se(n,{code:o?G.too_big:G.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(se(n,{code:G.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(se(n,{code:G.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new pi(n,o,n.path,a)))).then(o=>jn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new pi(n,o,n.path,a)));return jn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ui({...this._def,minLength:{value:t,message:me.toString(n)}})}max(t,n){return new ui({...this._def,maxLength:{value:t,message:me.toString(n)}})}length(t,n){return new ui({...this._def,exactLength:{value:t,message:me.toString(n)}})}nonempty(t){return this.min(1,t)}}ui.create=(e,t)=>new ui({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ie.ZodArray,...De(t)});function ca(e){if(e instanceof Ut){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=$i.create(ca(r))}return new Ut({...e._def,shape:()=>t})}else return e instanceof ui?new ui({...e._def,type:ca(e.element)}):e instanceof $i?$i.create(ca(e.unwrap())):e instanceof No?No.create(ca(e.unwrap())):e instanceof ko?ko.create(e.items.map(t=>ca(t))):e}class Ut extends Ve{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ge.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==he.object){const c=this._getOrReturnCtx(t);return se(c,{code:G.invalid_type,expected:he.object,received:c.parsedType}),Te}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof zs&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new pi(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof zs){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(se(i,{code:G.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new pi(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>jn.mergeObjectSync(r,c)):jn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return me.errToObj,new Ut({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:me.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Ut({...this._def,unknownKeys:"strip"})}passthrough(){return new Ut({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ut({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ut({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ie.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Ut({...this._def,catchall:t})}pick(t){const n={};for(const r of Ge.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Ut({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ge.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Ut({...this._def,shape:()=>n})}deepPartial(){return ca(this)}partial(t){const n={};for(const r of Ge.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Ut({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ge.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof $i;)s=s._def.innerType;n[r]=s}return new Ut({...this._def,shape:()=>n})}keyof(){return BT(Ge.objectKeys(this.shape))}}Ut.create=(e,t)=>new Ut({shape:()=>e,unknownKeys:"strip",catchall:zs.create(),typeName:Ie.ZodObject,...De(t)});Ut.strictCreate=(e,t)=>new Ut({shape:()=>e,unknownKeys:"strict",catchall:zs.create(),typeName:Ie.ZodObject,...De(t)});Ut.lazycreate=(e,t)=>new Ut({shape:e,unknownKeys:"strip",catchall:zs.create(),typeName:Ie.ZodObject,...De(t)});class Gh extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ki(a.ctx.common.issues));return se(n,{code:G.invalid_union,unionErrors:o}),Te}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ki(l));return se(n,{code:G.invalid_union,unionErrors:a}),Te}}get options(){return this._def.options}}Gh.create=(e,t)=>new Gh({options:e,typeName:Ie.ZodUnion,...De(t)});const Pi=e=>e instanceof g0?Pi(e.schema):e instanceof Eo?Pi(e.innerType()):e instanceof Qh?[e.value]:e instanceof Co?e.options:e instanceof v0?Ge.objectValues(e.enum):e instanceof Jh?Pi(e._def.innerType):e instanceof h0?[void 0]:e instanceof f0?[null]:e instanceof $i?[void 0,...Pi(e.unwrap())]:e instanceof No?[null,...Pi(e.unwrap())]:e instanceof zT||e instanceof tf?Pi(e.unwrap()):e instanceof ef?Pi(e._def.innerType):[];class F_ extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.object)return se(n,{code:G.invalid_type,expected:he.object,received:n.parsedType}),Te;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(se(n,{code:G.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=Pi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new F_({typeName:Ie.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...De(r)})}}function m0(e,t){const n=vs(e),r=vs(t);if(e===t)return{valid:!0,data:e};if(n===he.object&&r===he.object){const i=Ge.objectKeys(t),s=Ge.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=m0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===he.array&&r===he.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=m0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===he.date&&r===he.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Yh extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(Ew(s)||Ew(o))return Te;const a=m0(s.value,o.value);return a.valid?((Nw(s)||Nw(o))&&n.dirty(),{status:n.value,value:a.data}):(se(r,{code:G.invalid_intersection_types}),Te)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Yh.create=(e,t,n)=>new Yh({left:e,right:t,typeName:Ie.ZodIntersection,...De(n)});class ko extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.array)return se(r,{code:G.invalid_type,expected:he.array,received:r.parsedType}),Te;if(r.data.length<this._def.items.length)return se(r,{code:G.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Te;!this._def.rest&&r.data.length>this._def.items.length&&(se(r,{code:G.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new pi(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>jn.mergeArray(n,o)):jn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new ko({...this._def,rest:t})}}ko.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ko({items:e,typeName:Ie.ZodTuple,rest:null,...De(t)})};class Xh extends Ve{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.object)return se(r,{code:G.invalid_type,expected:he.object,received:r.parsedType}),Te;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new pi(r,a,r.path,a)),value:o._parse(new pi(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?jn.mergeObjectAsync(n,i):jn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Ve?new Xh({keyType:t,valueType:n,typeName:Ie.ZodRecord,...De(r)}):new Xh({keyType:Di.create(),valueType:t,typeName:Ie.ZodRecord,...De(n)})}}class Aw extends Ve{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.map)return se(r,{code:G.invalid_type,expected:he.map,received:r.parsedType}),Te;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new pi(r,a,r.path,[c,"key"])),value:s._parse(new pi(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Aw.create=(e,t,n)=>new Aw({valueType:t,keyType:e,typeName:Ie.ZodMap,...De(n)});class Zc extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.set)return se(r,{code:G.invalid_type,expected:he.set,received:r.parsedType}),Te;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(se(r,{code:G.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(se(r,{code:G.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Te;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new pi(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Zc({...this._def,minSize:{value:t,message:me.toString(n)}})}max(t,n){return new Zc({...this._def,maxSize:{value:t,message:me.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Zc.create=(e,t)=>new Zc({valueType:e,minSize:null,maxSize:null,typeName:Ie.ZodSet,...De(t)});class g0 extends Ve{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}g0.create=(e,t)=>new g0({getter:e,typeName:Ie.ZodLazy,...De(t)});class Qh extends Ve{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return se(n,{received:n.data,code:G.invalid_literal,expected:this._def.value}),Te}return{status:"valid",value:t.data}}get value(){return this._def.value}}Qh.create=(e,t)=>new Qh({value:e,typeName:Ie.ZodLiteral,...De(t)});function BT(e,t){return new Co({values:e,typeName:Ie.ZodEnum,...De(t)})}class Co extends Ve{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{expected:Ge.joinValues(r),received:n.parsedType,code:G.invalid_type}),Te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{received:n.data,code:G.invalid_enum_value,options:r}),Te}return Ir(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Co.create(t,{...this._def,...n})}exclude(t,n=this._def){return Co.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Co.create=BT;class v0 extends Ve{_parse(t){const n=Ge.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==he.string&&r.parsedType!==he.number){const i=Ge.objectValues(n);return se(r,{expected:Ge.joinValues(i),received:r.parsedType,code:G.invalid_type}),Te}if(this._cache||(this._cache=new Set(Ge.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ge.objectValues(n);return se(r,{received:r.data,code:G.invalid_enum_value,options:i}),Te}return Ir(t.data)}get enum(){return this._def.values}}v0.create=(e,t)=>new v0({values:e,typeName:Ie.ZodNativeEnum,...De(t)});class Zh extends Ve{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.promise&&n.common.async===!1)return se(n,{code:G.invalid_type,expected:he.promise,received:n.parsedType}),Te;const r=n.parsedType===he.promise?n.data:Promise.resolve(n.data);return Ir(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Zh.create=(e,t)=>new Zh({type:e,typeName:Ie.ZodPromise,...De(t)});class Eo extends Ve{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ie.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{se(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Te;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Te:l.status==="dirty"||n.value==="dirty"?tc(l.value):l});{if(n.value==="aborted")return Te;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Te:a.status==="dirty"||n.value==="dirty"?tc(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ya(o))return Te;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ya(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Te);Ge.assertNever(i)}}Eo.create=(e,t,n)=>new Eo({schema:e,typeName:Ie.ZodEffects,effect:t,...De(n)});Eo.createWithPreprocess=(e,t,n)=>new Eo({schema:t,effect:{type:"preprocess",transform:e},typeName:Ie.ZodEffects,...De(n)});class $i extends Ve{_parse(t){return this._getType(t)===he.undefined?Ir(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}$i.create=(e,t)=>new $i({innerType:e,typeName:Ie.ZodOptional,...De(t)});class No extends Ve{_parse(t){return this._getType(t)===he.null?Ir(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}No.create=(e,t)=>new No({innerType:e,typeName:Ie.ZodNullable,...De(t)});class Jh extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===he.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Jh.create=(e,t)=>new Jh({innerType:e,typeName:Ie.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...De(t)});class ef extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return qh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ef.create=(e,t)=>new ef({innerType:e,typeName:Ie.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...De(t)});class Mw extends Ve{_parse(t){if(this._getType(t)!==he.nan){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.nan,received:r.parsedType}),Te}return{status:"valid",value:t.data}}}Mw.create=e=>new Mw({typeName:Ie.ZodNaN,...De(e)});class zT extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class H_ extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Te:s.status==="dirty"?(n.dirty(),tc(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Te:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new H_({in:t,out:n,typeName:Ie.ZodPipeline})}}class tf extends Ve{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ya(i)&&(i.value=Object.freeze(i.value)),i);return qh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}tf.create=(e,t)=>new tf({innerType:e,typeName:Ie.ZodReadonly,...De(t)});var Ie;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ie||(Ie={}));const b=Di.create,W=Xa.create,ge=d0.create,Fi=p0.create;zs.create;const J=ui.create,I=Ut.create;Gh.create;const _i=F_.create;Yh.create;ko.create;const Pr=Xh.create,Y=Qh.create,ve=Co.create;Zh.create;$i.create;No.create;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const D6=["owner"],O6=["agent","owner","user-upload"],$T=I({id:b().min(1),relPath:b().min(1),from:ve(O6),label:b().optional(),size:W().int().nonnegative(),mime:b().min(1),addedAt:W().int().nonnegative(),lastEditedAt:W().int().nonnegative().optional(),stale:ge().optional()});I({sessionId:b().min(1),relPath:b().min(1),ttlSeconds:W().int().positive().nullable().optional(),view:ve(["raw","md-rendered"]).optional()});I({url:b().min(1),expiresAt:W().int().nonnegative().nullable()});I({sessionId:b().min(1),relPath:b().min(1),label:b().optional(),origin:Y("agent").optional()});I({entry:$T});I({sessionId:b().min(1),relPath:b().min(1)});I({removed:Y(!0)});I({sessionId:b().min(1)});I({entries:J($T)});I({attachmentId:b().min(1),url:b().min(1),relPath:b().min(1),sizeBytes:W().int().nonnegative(),mimeType:b().min(1)});const B6=_i("type",[I({type:Y("persona"),id:b().min(1)}).strict(),I({type:Y("chat"),id:b().min(1)}).strict(),I({type:Y("*")}).strict()]),z6=ve(["read","send","admin"]),U_=I({resource:B6,actions:J(z6).min(1)}).strict(),$6=I({id:b().min(1),secretHash:b().regex(/^[a-f0-9]{64}$/),displayName:b(),grants:J(U_),issuedAt:W().int().nonnegative(),expiresAt:W().int().positive().optional(),maxUses:W().int().positive().optional(),usedCount:W().int().nonnegative(),peerOwnerId:b().min(1).optional(),firstUsedByPeerAt:W().int().positive().optional(),peerDisplayName:b().optional()}).strict(),F6=$6.omit({secretHash:!0});I({type:Y("whoami:ok"),owner:I({id:b(),kind:ve(["owner","guest"]),displayName:b(),ownerId:b(),provider:b()}).strict(),capability:F6,grantedPersonas:J(I({id:b().min(1),displayName:b()}).strict())}).strict();I({selfUrl:b().min(1)});I({type:Y("contact:handshake:ok"),owner:I({id:b(),ownerId:b(),provider:b(),displayName:b()}),grants:J(U_)});const H6=I({name:b().min(1),from:b().optional(),version:b().optional(),min:b().optional()}),U6=I({name:b().min(1),env:J(b().min(1)).min(1)}),W6=I({name:b().min(1)}),W_=b().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),FT=["proxy","env"],HT=["mcp","cli"],V6=["bearer","lark-sidecar"],q6=["none","shared","personal"],UT=["oauth","fields"],V_=b().regex(/^[A-Z][A-Z0-9_]*$/,"要填的格的名字只能是大写字母、数字和下划线,且以字母开头"),K6=I({name:W_,kind:ve(FT),runner:ve(HT),protocol:ve(V6).optional(),id:b().min(1),credentialSource:ve(q6).optional(),auth:ve(UT).optional(),fields:J(V_).default([]),http:I({url:b().min(1),headers:Pr(b(),b())}).optional()}),WT={clis:J(H6),secrets:J(U6),assets:J(W6),connectors:J(K6).default([])};I(WT);const VT=I({version:Y(1),...WT}).strict(),G6=I({target:b().min(1),reason:b().min(1),file:b().min(1),quote:b().min(1)}),Y6=I({version:Y(1),manifest:VT}).strict(),X6=["hard","soft"],qT=ve(X6),Q6=ve(["scanning","done","failed"]),Z6=I({scanSessionId:b().optional(),status:Q6,evidence:J(G6).default([]),notes:J(b()).default([]),scannedAssets:J(b()).default([]),head:b().min(1).optional(),releasedHead:b().min(1).optional(),baseKind:qT.default("hard"),base:b().min(1).optional(),startedAt:W(),finishedAt:W().optional(),error:b().optional()}).strict(),J6=I({url:b().min(1),branch:b().min(1),head:b().min(1),dirty:ge(),ahead:W()}).strict(),eB=I({env:b().min(1),setAt:W().optional()}).strict(),tB=["pending","running","done","failed","waiting","skipped"],nB=ve(tB),rB=["build","smoke","deploy"],iB=ve(rB),sB=I({key:iB,status:nB,url:b().optional(),jobId:W().optional(),startedAt:W().optional(),completedAt:W().optional()}).strict(),oB=I({runId:W(),headSha:b().min(1),status:ve(["queued","running","completed"]),htmlUrl:b().min(1),jobs:J(sB)}).strict();I({personaId:b().min(1),repo:J6.optional(),file:Y6.optional(),scan:Z6.optional(),secrets:J(eB).optional(),run:oB.optional(),fileError:b().optional()}).strict();I({sha:b().min(1),actionsUrl:b().min(1)}).strict();const aB=I({personaId:b().min(1)}).strict();aB.extend({mode:qT.optional()}).strict();I({personaId:b().min(1),patch:I({manifest:VT.optional()}).strict()}).strict();I({personaId:b().min(1),name:b().min(1),values:Pr(b(),b())}).strict();I({personaId:b().min(1),jobId:W()}).strict();I({personaId:b().min(1),kind:ve(["cli","secret","asset","connector"]),item:Pr(b(),Fi()),evidence:I({reason:b().min(1),file:b().min(1),quote:b().min(1)})}).strict();I({personaId:b().min(1),notes:J(b()).default([])}).strict();I({deviceId:b().min(1),remoteAccessAllowed:ge()}).strict();I({type:Y("contact:setRemoteAccess:ok"),deviceId:b().min(1),remoteAccessAllowed:ge()}).strict();I({type:Y("contact:remote-access-updated"),deviceId:b().min(1),remoteAccessAllowed:ge()}).strict();I({personaId:b().min(1)}).strict();const lB=["connected","missing","reauth"],cB=["link","fill"],uB=I({name:W_,id:b().min(1),kind:ve(FT),runner:ve(HT),auth:ve(UT),status:ve(lB),action:ve(cB),authUrl:b().optional(),fields:J(V_)}).strict();I({connectors:J(uB)}).strict();I({personaId:b().min(1),name:W_,values:Pr(V_,b().min(1))}).strict();const dB=I({deviceId:b().min(1),ownerId:b().min(1),provider:b().min(1),displayName:b(),remoteUrl:b().min(1),connectToken:b(),grants:J(U_),addedAt:W().int().nonnegative(),pinnedAt:W().int().nullable().default(null),remoteAccessAllowed:ge().default(!1),note:b().default("")}).strict(),KT=dB;I({deviceId:b().min(1)}).strict();I({type:Y("contact:remove:ok"),deviceId:b().min(1)}).strict();I({type:Y("contact:list:ok"),contacts:J(KT)}).strict();I({type:Y("contact:added"),contact:KT}).strict();I({type:Y("contact:removed"),deviceId:b().min(1)}).strict();I({deviceId:b().min(1),pinned:ge()}).strict();I({deviceId:b().min(1),note:b()}).strict();I({type:Y("contact:setNote:ok"),deviceId:b().min(1),note:b()}).strict();I({type:Y("contact:pin:ok"),deviceId:b().min(1),pinnedAt:W().int().nullable()}).strict();I({type:Y("contact:pinned"),deviceId:b().min(1),pinnedAt:W().int().nullable()}).strict();const hB=I({deviceId:b().min(1),name:b().min(1),url:b().min(1)});I({type:Y("device:list:ok"),devices:J(hB)});I({deviceId:b().min(1),url:b().min(1).optional(),name:b().optional()});I({type:Y("device:connect:ok"),deviceId:b(),name:b(),url:b()});const GT=I({ownerId:b().min(1),provider:b().min(1),displayName:b().min(1),avatarUrl:b().optional(),unionId:b().optional()});I({type:Y("auth:login:start:ok"),authUrl:b().min(1),state:b().min(1)});I({type:Y("auth:getIdentity:ok"),identity:GT.nullable(),deviceId:b().min(1),ttcTokenExpiresAt:W().nullable().optional()});I({type:Y("auth:logout:ok")});const YT=b().nullable();I({type:Y("auth:apiKey:get:ok"),apiKey:b().nullable(),createdAt:b().nullable(),gatewayUrl:YT});I({type:Y("auth:apiKey:regenerate:ok"),apiKey:b().min(1),createdAt:b().min(1),gatewayUrl:YT});I({type:Y("auth:login:done"),identity:GT});I({type:Y("auth:login:failed"),reason:b()});const q_=_i("kind",[I({kind:Y("success"),text:b(),brief:b().optional(),filePaths:J(b()).optional()}),I({kind:Y("failure"),reason:b(),brief:b().optional()})]);I({targetPersona:b().min(1).optional(),dispatchId:b().min(1).optional(),prompt:b(),brief:b().optional(),targetDeviceId:b().min(1).optional(),model:b().min(1).optional(),tool:b().min(1).optional(),sessionLabel:b().min(1).max(60).optional(),meta:Pr(Fi()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});I({dispatchId:b().min(1),outcome:q_});const fB=["running","completed","failed"],K_=ve(fB),pB=I({dispatchId:b().min(1),sourceSessionId:b().min(1),sourcePersonaId:b().min(1).optional(),targetPersonaId:b().min(1),targetDeviceId:b().min(1).optional(),workerSessionId:b().min(1).optional(),taskText:b(),taskBrief:b().optional(),round:W().int().positive().optional(),status:K_,outcome:q_.optional(),meta:Pr(Fi()).optional(),createdAt:b().min(1),completedAt:b().min(1).optional(),deliveredAt:b().min(1).optional()});I({sourceSessionId:b().min(1).optional(),relatedSessionId:b().min(1).optional()});I({records:J(pB)});I({dispatchId:b().min(1)});I({type:Y("personaDispatch:get:ok"),status:K_,outcome:q_.optional()});const mB=/^[a-z0-9][a-z0-9-]*$/;ve(["stopped","starting","running","crashed","invalid"]);const gB=new Set(["localhost","127.0.0.1"]);function vB(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&gB.has(t.hostname))}const fd=I({id:b().regex(mB),name:b().min(1),version:b().min(1),apiVersion:Y("1"),runtime:I({startCommand:b().min(1)}).passthrough().optional(),entry:I({url:b().url().refine(vB,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:G.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:G.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),xB=_i("kind",[I({kind:Y("local"),port:W().int().min(1).max(65535)}),I({kind:Y("hosted"),url:b().url()})]);_i("state",[I({extId:b(),manifest:fd,state:Y("stopped")}),I({extId:b(),manifest:fd,state:Y("starting")}),I({extId:b(),manifest:fd,state:Y("running"),target:xB}),I({extId:b(),manifest:fd,state:Y("crashed")}),I({extId:b(),manifest:Fi().nullable(),state:Y("invalid"),invalidReason:b().min(1)})]);I({snapshotHash:b().min(1),version:b().min(1),publishedAt:W()});const _B=_i("kind",[I({kind:Y("p2p-tunnel"),ownerPrincipalId:b().min(1),extId:b().min(1)})]);_i("kind",[I({kind:Y("p2p-tunnel"),ownerPrincipalId:b().min(1),extId:b().min(1),snapshotHash:b().min(1)})]);I({extId:b().min(1),name:b().min(1),version:b().min(1),contentHash:b().min(1),publishedAt:W()});const yB=_i("kind",[I({kind:Y("clean")}),I({kind:Y("ready-new-version"),fromVersion:b().min(1),toVersion:b().min(1)}),I({kind:Y("error-same-hash"),version:b().min(1)}),I({kind:Y("error-version-not-bumped"),localVersion:b().min(1),publishedVersion:b().min(1)}),I({kind:Y("error-version-regression"),localVersion:b().min(1),publishedVersion:b().min(1)})]);I({localManifest:I({name:b().min(1),version:b().min(1),contentHash:b().min(1)}),publishState:_i("kind",[I({kind:Y("unpublished")}),I({kind:Y("published"),version:b().min(1),contentHash:b().min(1),publishedAt:W()})]),check:yB});I({extId:b().min(1),newVersion:b().min(1).nullish()});I({extId:b().min(1)});I({extId:b().min(1),snapshotHash:b().min(1)});I({channelRef:_B,snapshotHash:b().min(1),zipBase64:b().min(1)});I({id:b().min(1),peerDeviceId:b().min(1),senderDeviceId:b().min(1),text:b().min(1),createdAt:W().int().nonnegative(),readBy:Pr(b().min(1),W().int().positive()).default({}),origin:I({kind:Y("persona"),personaId:b().min(1)}).optional()}).strict();I({peerDeviceId:b().min(1).optional(),id:b().min(1),text:b().min(1),createdAt:W().int().nonnegative(),origin:I({kind:Y("persona"),personaId:b().min(1)}).optional()}).strict();I({peerDeviceId:b().min(1),sinceCreatedAt:W().int().nonnegative().optional()}).strict();I({peerDeviceId:b().min(1),upToCreatedAt:W().int().nonnegative()}).strict();I({peerDeviceId:b().min(1).optional(),text:b().min(1)});I({peerDeviceId:b().min(1).optional(),command:b().min(1),timeoutMs:W().int().positive().optional()}).strict();I({type:Y("peerExec:run:ok"),stdout:b(),stderr:b(),exitCode:W().int().nullable(),timedOut:ge(),stdoutTruncated:ge(),stderrTruncated:ge()}).strict();const XT=_i("kind",[I({kind:Y("at"),at:b().min(1)}),I({kind:Y("every"),everyMs:W().int().positive(),anchorMs:W().int().nonnegative().optional()}),I({kind:Y("cron"),expr:b().min(1),tz:b().min(1).optional()})]),yu=b().trim().min(1);I({personaId:yu,name:b().min(1),schedule:XT,prompt:b().min(1),targetPersona:b().min(1).optional(),timeoutMs:W().int().positive().optional()});I({personaId:yu,onlyMine:ge().optional()});I({personaId:yu,shiftId:b().min(1)});const bB=I({name:b().min(1).optional(),schedule:XT.optional(),prompt:b().min(1).optional(),targetPersona:b().min(1).optional(),timeoutMs:W().int().positive().optional(),enabled:ge().optional()});I({personaId:yu,shiftId:b().min(1),patch:bB});I({personaId:yu,shiftId:b().min(1),limit:W().int().positive().optional()});const QT="persona-master",G_=I({personaId:b().min(1),deviceId:b().min(1).optional()}),ZT=I({id:b().min(1),name:b().min(1),memberPersonas:J(G_),memberContactDeviceIds:J(b().min(1)),createdAt:b().min(1),updatedAt:b().min(1)}),JT=b().trim().min(1);I({name:JT,memberPersonas:J(G_).default([]),memberContactDeviceIds:J(b().min(1)).default([])});I({channelId:b().min(1),name:JT.optional(),memberPersonas:J(G_).optional(),memberContactDeviceIds:J(b().min(1)).optional()});I({channelId:b().min(1)});I({channels:J(ZT)});I({channel:ZT});I({ok:Y(!0),removedTopics:W().int().min(0)});const Kt=b().trim().min(1),Y_=["master-confirmed","owner-needed"],X_=["open","resolved"],wB=Y_[0];Y_[1];X_[0];const SB=X_[1],kB=ve(Y_),CB=ve(X_),EB=I({id:Kt.optional(),resolves:Kt.optional(),type:kB,status:CB,question:Kt,recommendation:Kt}).superRefine((e,t)=>{e.type===wB&&e.status!==SB&&t.addIssue({code:G.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),NB=["planning","running","done"],TB=ve(NB),eI=I({at:b().min(1),actor:b().min(1),action:b().min(1),target:b().optional(),reason:b().min(1),artifacts:J(Kt).optional(),decision:EB.optional()}),IB=I({rejectCount:W().int().min(0),accepted:ge().default(!1),ordinal:W().int().min(1).optional(),overrideCount:W().int().min(0).optional()}),Q_=I({id:b().min(1),channelId:b().min(1),title:b(),masterSessionId:b().min(1),goal:b(),boundaries:b(),acceptanceCriteria:J(b()),activity:J(eI),lineMeta:Pr(IB),nextLineOrdinal:W().int().min(1).optional(),state:TB,createdAt:b().min(1),updatedAt:b().min(1)}),PB=I({lineId:b().min(1),dispatchId:b().min(1),workerSessionId:b().optional(),assignee:b().min(1),focus:b(),status:K_,acceptance:J(b()),rejectCount:W().int().min(0),accepted:ge(),ordinal:W().int().min(1).nullable()});I({channelId:b().min(1)});I({topicId:b().min(1).optional(),sessionId:b().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});I({channelId:b().min(1),title:Kt.optional()});I({topicId:b().min(1),title:Kt.optional(),goal:Kt,boundaries:b(),acceptanceCriteria:J(Kt).min(1)});I({topicId:b().min(1),action:Kt,target:Kt.optional(),reason:Kt,artifacts:J(Kt).optional(),decision:eI.shape.decision});I({topicId:b().min(1),lineId:Kt,reason:Kt});I({topicId:b().min(1),lineId:Kt,reason:Kt,artifacts:J(Kt).optional(),watcherVerdict:ve(["pass","fail"]),overrideReason:Kt.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});I({topicId:b().min(1),state:ve(["done"])});I({topicId:b().min(1),title:Kt});I({topicId:b().min(1)});const RB=Q_.extend({lineCount:W().int().min(0)});I({topics:J(RB)});I({topic:Q_,lines:J(PB)});I({topicId:b().min(1),masterSessionId:b().min(1)});I({rejectCount:W().int().min(1),needsOwnerAttention:ge()});I({acceptedLines:W().int().min(1),totalLines:W().int().min(1),allAccepted:ge(),overrides:W().int().min(0),needsOwnerAttention:ge()});I({topic:Q_});I({ok:Y(!0),removedMasterSessionId:b().min(1).nullable(),removedWorkerSessionIds:J(b().min(1))});const AB=["ask","allow","deny"],tI=ve(AB),MB=I({id:b().min(1),desc:b().min(1),action:tI});I({rules:J(MB)});I({ruleId:b().min(1)});I({action:tI,desc:b(),source:b().min(1)});const jB=["created","review-requested"],nI=/^[A-Za-z0-9._-]+$/,vl=b().min(1).regex(nI),xl=b().min(1).regex(nI),bu=W().int().positive();I({role:ve(jB)});I({owner:vl,repo:xl,number:bu});I({owner:vl,repo:xl,number:bu,expectedHeadSha:b().min(1)});I({owner:vl,repo:xl,number:bu,body:b().min(1)});I({owner:vl,repo:xl,number:bu,ready:ge()});I({owner:vl,repo:xl});I({owner:vl,repo:xl,number:bu,reviewers:J(b().min(1)).min(1)});I({personaId:b().min(1)});I({personaId:b().min(1)});const LB=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],DB=ve(LB);I({personaId:b().min(1),appId:b().min(1),appSecret:b().min(1),botName:b().min(1).optional()});const OB=I({chatId:b().min(1),chatName:b().optional(),lastActiveAt:W().int().optional()}),BB=I({state:ve(["unbound","provisioning","bound","broken"]),appId:b().optional(),botName:b().optional(),brokenReason:b().optional(),qrUrl:b().optional(),errorReason:DB.optional(),groups:J(OB),needsUpgrade:ge().optional(),upgradeQrUrl:b().optional()});BB.extend({personaId:b().min(1)});I({});I({onboardingCompletedAt:W()});const rI=["claude","codex","pi"];I({});I({tools:J(I({id:ve(rI),available:ge(),version:b().optional(),path:b().optional()}))});I({});const zB=I({tool:ve(rI),cwd:b(),toolSessionId:b(),label:b().optional(),createdAt:b(),updatedAt:b(),turns:W()});I({candidates:J(zB)});I({});I({registered:ge()});const $B=I({personaId:b(),label:b(),model:b().optional(),effort:b().optional(),public:ge(),iconKey:b().optional(),tool:b().optional(),createdAt:W(),updatedAt:W(),cloud:I({gatewayUrl:b().min(1),personaId:b().min(1)}).strict().optional()}).strict(),FB=I({name:b().min(1),description:b().optional()}),HB=I({id:b().min(1)}),iI=I({writableRoots:J(b()).optional(),denyRead:J(b()).optional(),network:ge().optional()}).strict(),UB=I({permissions:I({defaultMode:b().optional(),allow:J(b()).optional(),deny:J(b()).optional()}).optional(),sandbox:I({enabled:ge().optional(),autoAllowBashIfSandboxed:ge().optional(),allowUnsandboxedCommands:ge().optional(),excludedCommands:J(b()).optional(),filesystem:I({denyRead:J(b()).optional(),allowRead:J(b()).optional(),denyWrite:J(b()).optional(),allowWrite:J(b()).optional()}).optional(),network:I({allowedDomains:J(b()).optional(),allowLocalBinding:ge().optional()}).optional()}).optional()});$B.extend({personality:b().optional(),personalityLocal:b().optional(),personalityManaged:ge().optional(),skills:J(FB).optional(),plugins:J(HB).optional(),sandboxSettings:UB.nullable().optional(),codexSandbox:iI.nullable().optional()});I({slug:b().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:b().min(1),personality:b(),model:b().optional(),effort:b().optional(),tool:b().optional(),public:ge().optional(),iconKey:b().optional()}).strict();I({personaId:b().min(1)});I({personaId:b().min(1),patch:I({label:b().min(1).optional(),model:b().optional(),effort:b().optional(),tool:b().optional(),personality:b().optional(),personalityLocal:b().optional(),public:ge().optional(),iconKey:b().nullable().optional(),codexSandbox:iI.optional()}).strict()}).strict();const sI=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","session:queue","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","contact:note-updated","org-mesh:progress","channel:changed","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed","larkBot:state"],oI=["idle","running","running-idle","stopped","error","observing"],WB=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function ap(e){return e==="dispatch-task"||e==="dispatch-result"}const VB=["builtin","global","project","plugin"],qB=["builtin","global","project","policy","plugin"],aI=ve(["owner","guest"]);I({id:b().min(1),kind:aI,displayName:b(),feishuUnionId:b().optional()}).strict();const KB=I({did:b().min(1),displayName:b(),feishuUnionId:b().optional(),principal:aI}).strict(),GB=ve(oI),YB=I({inputTokens:W().int().nonnegative(),outputTokens:W().int().nonnegative(),cacheReadTokens:W().int().nonnegative().optional(),cacheCreateTokens:W().int().nonnegative().optional()}),lI={gitBranch:b().optional(),resolvedModel:b().optional(),resolvedEffort:b().optional(),contextUsage:YB.optional(),contextWindowSize:W().int().positive().optional(),aiLabel:b().optional()},XB=I(lI),cI=I({value:b(),label:b(),description:b().optional()}),QB=I({id:b().min(1),label:b().min(1),description:b().optional(),contextWindowSize:W().int().positive(),default:ge().optional(),efforts:J(cI).optional(),defaultEffort:b().optional(),group:b().optional()}),ZB=I({id:b().min(1),label:b().min(1),description:b().optional()}),JB=I({name:b().min(1),type:ve(["string","select","toggle"]),label:b().min(1),description:b().optional(),options:J(cI).optional(),default:Fi().optional(),scope:ve(["core","tool-specific"])});I({tool:b().min(1)});const ez=I({rewind:ge(),subagents:ge(),tui:ge(),observe:ge(),fileSharing:ge(),fork:ge()});I({tool:b().min(1),toolSessionIdLabel:b().optional(),models:J(QB),permissionModes:J(ZB),configSchema:J(JB),features:ez});const tz=I({tool:b().min(1),pattern:b().min(1),createdAt:b().min(1).optional()});I({sessionId:b().min(1),cwd:b().min(1),tool:Y("claude").or(b().min(1)).default("claude"),toolSessionId:b().optional(),label:b().optional(),model:b().optional(),permissionMode:b().optional(),effort:b().optional(),...lI,aiLabelGeneratedAt:b().optional(),permissionRules:J(tz).optional(),pinnedAt:W().int().nonnegative().nullable().optional(),archivedAt:W().int().nonnegative().nullable().optional(),pinSortOrder:W().int().nullable().optional(),unreadAt:b().min(1).nullable().optional(),iconKey:b().optional(),forkedFromSessionId:b().min(1).optional(),ephemeral:ge().optional(),deployId:b().min(1).optional(),ownerPersonaId:b().min(1).optional(),projectPath:b().min(1).optional(),appBuilderProject:b().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:b().min(1).optional(),creatorPrincipalId:b().min(1).optional(),creatorDisplayName:b().min(1).optional(),creatorFeishuUnionId:b().min(1).optional(),originOwnerPrincipalId:b().min(1).optional(),originOwnerPersonaId:b().min(1).optional(),dispatchedFromSessionId:b().min(1).optional(),shiftFiredFromSessionId:b().min(1).optional(),larkChatId:b().min(1).optional(),larkChatName:b().min(1).optional(),larkChatType:ve(["p2p","group"]).optional(),createdAt:b().min(1),updatedAt:b().min(1)});const Fn={seq:W().int().nonnegative().optional(),ts:b().optional(),uuid:b().optional()},nz=ve(WB),rz=I({readCount:W().int().nonnegative().optional(),searchCount:W().int().nonnegative().optional(),bashCount:W().int().nonnegative().optional(),editFileCount:W().int().nonnegative().optional(),linesAdded:W().int().nonnegative().optional(),linesRemoved:W().int().nonnegative().optional(),otherToolCount:W().int().nonnegative().optional()}),iz=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:J(b())}),sz=I({agentId:b().optional(),agentType:b().optional(),status:b().optional(),prompt:b().optional(),filePath:b().optional(),structuredPatch:J(iz).optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional(),toolStats:rz.optional()}).optional()}),oz=I({path:b(),content:b(),mtimeMs:W().optional()}),az=I({label:b().min(1),description:b().optional()}),uI=I({question:b().min(1),multiSelect:ge(),options:J(az).min(1)}),lz=["completed","interrupted"];_i("kind",[I({...Fn,kind:Y("session_init"),toolSessionId:b().optional()}),I({...Fn,kind:Y("thinking"),text:b(),partialId:b().optional()}),I({...Fn,kind:Y("text"),text:b(),partialId:b().optional()}),I({...Fn,kind:Y("user_text"),text:b(),meta:nz.optional(),taskId:b().optional(),parentToolUseId:b().optional(),sender:KB.optional()}),I({...Fn,kind:Y("tool_call"),toolUseId:b(),tool:b(),toolKind:b().optional(),input:Fi()}),I({...Fn,kind:Y("tool_result"),toolUseId:b(),output:Fi().optional(),error:b().optional(),toolResultExtra:sz.optional(),sourceToolAssistantUUID:b().optional(),askQuestionAnswers:Pr(b(),b()).optional()}),I({...Fn,kind:Y("attachment_memories"),memories:J(oz)}),I({...Fn,kind:Y("permission_request"),requestId:b(),tool:b(),input:Fi(),toolUseId:b().optional()}),I({...Fn,kind:Y("ask_user_question"),toolUseId:b(),questions:J(uI)}),I({...Fn,kind:Y("turn_end"),durationMs:W().int().nonnegative().optional(),reason:ve(lz).optional()}),I({...Fn,kind:Y("subagent_progress"),toolUseId:b(),agentId:b(),status:ve(["started","running","completed","failed"]),description:b().optional(),lastToolName:b().optional(),prompt:b().optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional()}).optional()}),I({...Fn,kind:Y("error"),message:b()}),I({...Fn,kind:Y("meta_update"),patch:XB}),I({...Fn,kind:Y("meta-text"),text:b(),metaSource:ve(["cc","owner"]).optional()})]);I({cwd:b().min(1).optional(),tool:b().optional(),label:b().optional(),aiLabel:b().optional(),model:b().optional(),permissionMode:b().optional(),effort:b().optional(),iconKey:b().optional(),forkedFromSessionId:b().min(1).optional(),ephemeral:ge().optional(),ownerPersonaId:b().min(1).optional(),projectPath:b().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});I({path:b().min(1),name:b().min(1),createdAt:b().datetime(),pinnedAt:W().optional()});I({path:b().min(1),pinnedAt:W().nullable()});I({path:b().min(1)});I({path:b().min(1).optional(),name:b().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});I({cwd:b().min(1),tool:b().min(1),toolSessionId:b().min(1),label:b().optional(),aiLabel:b().optional(),iconKey:b().optional(),createdAt:b().datetime(),updatedAt:b().datetime(),ownerPersonaId:b().min(1).optional()});I({originOnly:ge().optional(),ownerPersonaId:b().min(1).optional(),limit:W().int().positive().optional(),offset:W().int().nonnegative().optional()});I({sessionId:b().min(1)});I({sessionId:b().min(1),patch:I({label:b().optional(),model:b().optional(),permissionMode:b().optional(),effort:b().optional(),cwd:b().optional(),iconKey:b().optional(),ephemeral:Y(!1).optional()})});I({id:b().min(1),text:b(),queuedAt:W(),senderDisplayName:b().optional()});I({sessionId:b().min(1),text:b(),queueWhileRunning:ge().optional()});I({sessionId:b().min(1),id:b().min(1).optional()});I({sessionId:b().min(1),userMessageId:b().min(1),dryRun:ge().optional()});I({canRewind:ge(),error:b().optional(),filesChanged:J(b()).optional(),insertions:W().int().nonnegative().optional(),deletions:W().int().nonnegative().optional()});I({sessionId:b().min(1),userMessageId:b().min(1)});const cz=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:J(b())}),uz=I({filePath:b().min(1),hunks:J(cz),insertions:W().int().nonnegative(),deletions:W().int().nonnegative(),status:ve(["modified","added","deleted"]).optional()});I({canRewind:ge(),error:b().optional(),files:J(uz),totalInsertions:W().int().nonnegative(),totalDeletions:W().int().nonnegative()});I({userMessageIds:J(b())});I({sessionId:b().min(1),toolSessionId:b().min(1)});I({cwd:b().min(1),toolSessionId:b().min(1),messageUuid:b().min(1),targetCwd:b().min(1).optional()});I({forkedToolSessionId:b().min(1),forkedFilePath:b().min(1)});I({sessionId:b().min(1),toolSessionId:b().min(1),jsonlPath:b().optional()});I({sessionId:b().min(1),afterSeq:W().int().min(-1)});I({sessionId:b().min(1),permissionRequestId:b().min(1),allow:ge(),permanent:ge().optional(),pattern:b().optional()});I({projectPath:b().min(1)});I({sessionId:b().min(1),limit:W().int().positive().max(5e3).optional(),offset:W().int().nonnegative().optional(),slim:ge().optional()});I({cwd:b().min(1),toolSessionId:b().min(1)});I({cwd:b().min(1),toolSessionId:b().min(1),subagentId:b().min(1)});I({cwd:b().min(1).optional(),path:b().optional(),showHidden:ge().optional()});I({cwd:b().min(1),path:b().min(1)});I({cwd:b().min(1),tool:b().optional()});I({name:b().min(1),source:ve(VB),path:b().optional(),description:b().optional(),plugin:b().optional()});const dz=I({name:b().min(1),source:ve(qB),path:b().optional(),description:b().optional(),whenToUse:b().optional(),plugin:b().optional()});I({cwd:b().min(1),tool:b().optional()});I({agents:J(dz)});I({sessionId:b().optional()});I({sessionId:b().min(1).optional()});I({sessionId:b().min(1),pinned:ge()});I({sessionId:b().min(1),archived:ge()});I({query:b().min(1),sessionIds:J(b().min(1)),limit:W().int().positive().max(50).optional()});const hz=I({sessionId:b().min(1),snippet:b()});I({type:Y("session:searchContent"),matches:J(hz)});I({type:Y("peerSession:upsert:ok")});I({sessionId:b().min(1)});I({type:Y("peerSession:remove:ok")});I({orderedIds:J(b().min(1)).min(1)});I({cwd:b().min(1)});I({isGitRoot:ge(),gitRoot:b().nullable()});I({cwd:b().min(1)});I({branch:b().nullable()});I({cwd:b().min(1)});I({branches:J(b()),head:b().nullable()});const fz=I({cwd:b().min(1),updatedAt:b().min(1)});I({dirs:J(fz)});I({type:Y("session:question"),sessionId:b().min(1),toolUseId:b().min(1),requestId:b().min(1),questions:J(uI).min(1)});I({type:Y("session:question:cleared"),sessionId:b().min(1),toolUseId:b().min(1),answers:Pr(b(),b()).optional()});I({sessionId:b().min(1),toolUseId:b().min(1),answers:Pr(b(),b())});I({ok:Y(!0)});I({sessionId:b().min(1),toolUseId:b().min(1)});I({ok:Y(!0)});const dI=I({name:b().min(1),version:b().min(1),instanceId:b().min(1),deviceLabel:b().transform(e=>e.trim().slice(0,64)).optional()});I({type:Y("auth"),token:b().min(1),scheme:Y("bearer").optional(),clientInfo:dI.optional()});I({type:Y("auth:ok"),version:b().min(1).optional(),protocolVersion:W().int().nonnegative().optional()});const pz=I({clientId:b().min(1),connectedAt:W().int().nonnegative(),self:ge(),clientInfo:dI.optional()});I({type:Y("device:connections:ok"),connections:J(pz)});I({type:Y("tunnel:ready"),url:b().min(1),subdomain:b().min(1)});I({type:Y("tunnel:exited"),code:W().int().nullable(),subdomain:b().nullable(),url:b().nullable()});I({type:Y("tunnel:unavailable"),reason:b().min(1),failedAt:b().min(1)});const mz=I({sessionId:b().min(1),status:GB,freshSpawn:ge(),pendingPermissionRequestIds:J(b().min(1)),pendingQuestionToolUseIds:J(b().min(1))});I({type:Y("info"),version:b(),protocolVersion:W(),hostname:b(),os:b(),tools:J(I({id:b(),available:ge()})),runningSessions:J(mz),tokenRole:ve(D6).optional(),isLoopback:ge().optional(),httpBaseUrl:b().optional(),httpToken:b().optional(),daemonSource:ve(["ota","packaged"]).optional(),globalCliVersion:b().nullable().optional()});const gz=6173,vz=6272,_l=/^[a-z][a-z0-9-]{0,39}$/,wu=I({name:b().regex(_l,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:W().int().min(gz).max(vz),createdAt:b().datetime(),devCommand:b().min(1),prodUrl:b().url().optional(),readyPattern:b().optional(),publishJob:I({jobId:b().min(1),stage:ve(["build","deploy","verify"]),startedAt:W().int().nonnegative()}).optional()}),xz=["install-pending","installing","starting-dev-server","running","stopped","failed"],hI=ve(xz),Z_=wu.extend({isRunning:ge(),boundSessionId:b().nullable(),stage:hI.optional(),stageReason:b().optional(),publishJob:I({jobId:b().min(1),stage:ve(["build","deploy","verify"]),startedAt:W().int().nonnegative(),status:ve(["in-flight","interrupted"])}).optional()});I({}).strict();I({projects:J(Z_)}).strict();I({sessionId:b().min(1)}).strict();I({project:Z_.nullable()}).strict();I({sessionId:b().min(1),name:b().min(1)}).strict();I({project:wu}).strict();I({name:b()}).strict();I({}).strict();I({name:b(),newPort:W().int()}).strict();I({project:wu}).strict();I({name:b().regex(_l),url:b().url()}).strict();I({project:wu}).strict();I({sessionId:b().min(1),force:ge().optional()}).strict();I({project:wu}).strict();const _z=["installing","failed"];I({sessionId:b().min(1),stage:ve(_z),reason:b().optional()}).strict();I({ok:Y(!0)}).strict();I({sessionId:b().min(1)}).strict();I({ok:Y(!0)}).strict();I({type:Y("appBuilder:project-updated"),project:Z_,stage:hI,stageReason:b().optional()}).strict();I({name:b().regex(_l)});I({jobId:b().min(1),status:ve(["started","already-publishing"])}).strict();I({name:b().regex(_l)});I({ok:Y(!0)}).strict();I({type:Y("appBuilder:publish-progress"),name:b().regex(_l),jobId:b().min(1),stage:ve(["build","deploy","verify"]),status:ve(["started","completed"])}).strict();I({type:Y("appBuilder:publish-failed"),name:b().regex(_l),jobId:b().min(1),stage:ve(["build","deploy","verify","unknown"]),errorSummary:b()}).strict();I({});I({method:b().min(1).optional()});const yz=["allowed","conditional","denied"],bz=ve(yz),wz=I({name:b().min(1),status:bz,description:b().min(1),args:J(I({name:b(),required:ge()})).nullable(),argsSchema:Pr(Fi()).optional(),reason:b().optional()});I({type:Y("meta:methods"),methods:J(wz)});const jw=1,Sz=["daemon","main","renderer"],kz=ve(Sz),Cz=["debug","info","warn","error"],Ez=ve(Cz);I({ts:W().int(),source:kz,level:Ez,msg:b(),ownerPrincipalId:b(),deviceId:b(),appVersion:b(),daemonVersion:b().optional(),os:b(),meta_json:b().optional(),sessionId:b().optional()});I({v:Y(1),visitorId:b().min(1),displayName:b(),provider:b(),iat:W(),exp:W()});const Nz=I({visitorId:b(),displayName:b(),avatarUrl:b().optional(),provider:b(),firstSeen:W(),lastSeen:W()});I({visitors:J(Nz)});const Tz=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,fI=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,Iz="clawd-dispatch-task",Pz="clawd-dispatch-result",Lw=120;function Rz(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?Iz:Pz,i=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let s=i.exec(e);s!==null;s=i.exec(e))t.push({at:s.index,block:Az(n,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Az(e,t,n){var c;const r=zz(t),i=x0(Bz(jm(n,"detail")??n)),s=(c=jm(n,"brief"))==null?void 0:c.trim(),o=s&&s.length>0?x0(s):Mz(i),a=r.round!==void 0?Number.parseInt(r.round,10):void 0,l=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&a!==void 0&&Number.isFinite(a)?{round:a}:{},...e==="result"&&(l==="success"||l==="failure")?{status:l}:{},brief:o,briefIsDerived:!(s&&s.length>0),detail:i,filePaths:Oz(jm(n,"files"))}}function Mz(e){const t=e.split(/\n\s*\n/).map(r=>r.trim()).find(r=>r.length>0);if(!t)return"";const n=t.replace(/\s+/g," ");return n.length>Lw?`${n.slice(0,Lw)}…`:n}const jz="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",Lz=new RegExp(`<\\\\(\\\\*)(/?)(${jz})\\b`,"g");function Dz(e){return x0(e)}function x0(e){return e.replace(Lz,"<$1$2$3")}function jm(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function Oz(e){return e?e.split(`
|
|
95
|
+
`,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var mw=function(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};const wO={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},SO={motionBase:!0,motionUnit:!0},kO={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},ST=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=mw(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=wT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=mw(l,["theme"]);let d=u;c&&(d=ST(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function kT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Ke.useContext(yT),s=`${yO}-${t||""}`,o=n||_T,[a,l,c]=uD(o,[Yc,e],{salt:s,override:r,getComputedToken:ST,formatToken:wT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:wO,ignore:SO,preserve:kO}});return[o,c,t?l:"",a,i]}const CO=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),EO=e=>({[`.${e}`]:Object.assign(Object.assign({},CO()),{[`.${e} .${e}-icon`]:{display:"block"}})}),NO=(e,t)=>{const[n,r]=kT();return BD({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>EO(e))},TO=Object.assign({},cl),{useId:gw}=TO,IO=()=>"",PO=typeof gw>"u"?IO:gw;function RO(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},Vh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Vh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=PO();return HN(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!BL(c,d,!0)}))}var AO=["children"],CT=g.createContext({});function MO(e){var t=e.children,n=Dv(e,AO);return g.createElement(CT.Provider,{value:n},t)}var jO=function(e){WN(n,e);var t=qN(n);function n(){return fl(this,n),t.apply(this,arguments)}return pl(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function LO(e){var t=g.useReducer(function(a){return a+1},0),n=et(t,2),r=n[1],i=g.useRef(e),s=i0(function(){return i.current}),o=i0(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var fs="none",cd="appear",ud="enter",dd="leave",vw="none",Br="prepare",Sa="start",ka="active",$_="end",ET="prepared";function xw(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function DO(e,t){var n={animationend:xw("Animation","AnimationEnd"),transitionend:xw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var OO=DO(Zi(),typeof window<"u"?window:{}),NT={};if(Zi()){var BO=document.createElement("div");NT=BO.style}var hd={};function TT(e){if(hd[e])return hd[e];var t=OO[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in NT)return hd[e]=t[s],hd[e]}return""}var IT=TT("animationend"),PT=TT("transitionend"),RT=!!(IT&&PT),_w=IT||"animationend",yw=PT||"transitionend";function bw(e,t){if(!e)return null;if(Mt(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const zO=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(yw,e),i.removeEventListener(_w,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(yw,e),i.addEventListener(_w,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var AT=Zi()?g.useLayoutEffect:g.useEffect;const $O=function(){var e=g.useRef(null);function t(){jv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=jv(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var FO=[Br,Sa,ka,$_],HO=[Br,ET],MT=!1,UO=!0;function jT(e){return e===ka||e===$_}const WO=function(e,t,n){var r=s0(vw),i=et(r,2),s=i[0],o=i[1],a=$O(),l=et(a,2),c=l[0],u=l[1];function d(){o(Br,!0)}var f=t?HO:FO;return AT(function(){if(s!==vw&&s!==$_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===MT?o(m,!0):m&&c(function(w){function x(){w.isCanceled()||o(m,!0)}v===!0?x():Promise.resolve(v).then(x)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function VO(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,w=r.onEnterStart,x=r.onLeaveStart,_=r.onAppearActive,y=r.onEnterActive,S=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,T=r.onVisibleChanged,D=s0(),P=et(D,2),O=P[0],R=P[1],A=LO(fs),M=et(A,2),L=M[0],$=M[1],F=s0(null),B=et(F,2),z=B[0],E=B[1],H=L(),q=g.useRef(!1),j=g.useRef(null);function re(){return n()}var ie=g.useRef(!1);function K(){$(fs),E(null,!0)}var _e=i0(function(Xe){var nt=L();if(nt!==fs){var zt=re();if(!(Xe&&!Xe.deadline&&Xe.target!==zt)){var xn=ie.current,tn;nt===cd&&xn?tn=C==null?void 0:C(zt,Xe):nt===ud&&xn?tn=k==null?void 0:k(zt,Xe):nt===dd&&xn&&(tn=N==null?void 0:N(zt,Xe)),xn&&tn!==!1&&K()}}}),Ee=zO(_e),ue=et(Ee,1),je=ue[0],Me=function(nt){switch(nt){case cd:return Ce(Ce(Ce({},Br,f),Sa,v),ka,_);case ud:return Ce(Ce(Ce({},Br,p),Sa,w),ka,y);case dd:return Ce(Ce(Ce({},Br,m),Sa,x),ka,S);default:return{}}},Oe=g.useMemo(function(){return Me(H)},[H]),xe=WO(H,!e,function(Xe){if(Xe===Br){var nt=Oe[Br];return nt?nt(re()):MT}if(st in Oe){var zt;E(((zt=Oe[st])===null||zt===void 0?void 0:zt.call(Oe,re(),null))||null)}return st===ka&&H!==fs&&(je(re()),u>0&&(clearTimeout(j.current),j.current=setTimeout(function(){_e({deadline:!0})},u))),st===ET&&K(),UO}),tt=et(xe,2),Nt=tt[0],st=tt[1],pt=jT(st);ie.current=pt;var Dt=g.useRef(null);AT(function(){if(!(q.current&&Dt.current===t)){R(t);var Xe=q.current;q.current=!0;var nt;!Xe&&t&&a&&(nt=cd),Xe&&t&&s&&(nt=ud),(Xe&&!t&&c||!Xe&&d&&!t&&c)&&(nt=dd);var zt=Me(nt);nt&&(e||zt[Br])?($(nt),Nt()):$(fs),Dt.current=t}},[t]),g.useEffect(function(){(H===cd&&!a||H===ud&&!s||H===dd&&!c)&&$(fs)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(j.current)}},[]);var mt=g.useRef(!1);g.useEffect(function(){O&&(mt.current=!0),O!==void 0&&H===fs&&((mt.current||O)&&(T==null||T(O)),mt.current=!0)},[O,H]);var gt=z;return Oe[Br]&&st===Sa&&(gt=He({transition:"none"},gt)),[H,st,gt,O??t]}function qO(e){var t=e;Mt(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(CT),w=v.motion,x=n(i,w),_=g.useRef(),y=g.useRef();function S(){try{return _.current instanceof HTMLElement?_.current:bL(y.current)}catch{return null}}var C=VO(x,a,S,i),k=et(C,4),N=k[0],T=k[1],D=k[2],P=k[3],O=g.useRef(P);P&&(O.current=!0);var R=g.useCallback(function(B){_.current=B,CL(s,B)},[s]),A,M=He(He({},m),{},{visible:a});if(!d)A=null;else if(N===fs)P?A=d(He({},M),R):!c&&O.current&&p?A=d(He(He({},M),{},{className:p}),R):u||!c&&!p?A=d(He(He({},M),{},{style:{display:"none"}}),R):A=null;else{var L;T===Br?L="prepare":jT(T)?L="active":T===Sa&&(L="start");var $=bw(f,"".concat(N,"-").concat(L));A=d(He(He({},M),{},{className:cL(bw(f,N),Ce(Ce({},$,$&&L),f,typeof f=="string")),style:D}),R)}if(g.isValidElement(A)&&EL(A)){var F=NL(A);F||(A=g.cloneElement(A,{ref:R}))}return g.createElement(jO,{ref:y},A)});return r.displayName="CSSMotion",r}const KO=qO(RT);var o0="add",a0="keep",l0="remove",Am="removed";function GO(e){var t;return e&&Mt(e)==="object"&&"key"in e?t=e:t={key:e},He(He({},t),{},{key:String(t.key)})}function c0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(GO)}function YO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=c0(e),o=c0(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return He(He({},p),{},{status:o0})})),r=d),n.push(He(He({},f),{},{status:a0})),r+=1,u=!0;break}}u||n.push(He(He({},c),{},{status:l0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return He(He({},c),{},{status:o0})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==l0}),n.forEach(function(u){u.key===c&&(u.status=a0)})}),n}var XO=["component","children","onVisibleChanged","onAllRemoved"],QO=["status"],ZO=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function JO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:KO,n=function(r){WN(s,r);var i=qN(s);function s(){var o;fl(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),Ce(Av(o),"state",{keyEntities:[]}),Ce(Av(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:He(He({},p),{},{status:Am})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Am}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return pl(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=Dv(c,XO),m=u||g.Fragment,v={};return ZO.forEach(function(w){v[w]=p[w],delete p[w]}),delete p.keys,g.createElement(m,p,l.map(function(w,x){var _=w.status,y=Dv(w,QO),S=_===o0||_===a0;return g.createElement(t,Hh({},v,{key:y.key,visible:S,eventProps:y,onVisibleChanged:function(k){f==null||f(k,{key:y.key}),k||a.removeKey(y.key)}}),function(C,k){return d(He(He({},C),{},{index:x}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=c0(c),f=YO(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var w=v.key;return p.key===w});return!(m&&m.status===Am&&p.status===l0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}JO(RT);const ww=g.createContext(!0);function e6(e){const t=g.useContext(ww),{children:n}=e,[,r]=kT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(ww.Provider,{value:i},g.createElement(MO,{motion:i},n)):n}const t6=()=>null;var n6=function(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};const r6=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let LT;function i6(){return LT||n0}function s6(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const o6=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(LT=t),r&&s6(r)&&pO(i6(),r)},a6=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:w,parentContext:x,iconPrefixCls:_,theme:y,componentDisabled:S,segmented:C,statistic:k,spin:N,calendar:T,carousel:D,cascader:P,collapse:O,typography:R,checkbox:A,descriptions:M,divider:L,drawer:$,skeleton:F,steps:B,image:z,layout:E,list:H,mentions:q,modal:j,progress:re,result:ie,slider:K,breadcrumb:_e,menu:Ee,pagination:ue,input:je,textArea:Me,empty:Oe,badge:xe,radio:tt,rate:Nt,switch:st,transfer:pt,avatar:Dt,message:mt,tag:gt,table:Xe,card:nt,tabs:zt,timeline:xn,timePicker:tn,upload:U,notification:Q,tree:ye,colorPicker:Pe,datePicker:Be,rangePicker:_t,flex:_n,wave:$t,dropdown:dn,warning:oe,tour:be,tooltip:Ze,popover:Tt,popconfirm:Ar,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Qs,treeSelect:Il}=e,Ko=g.useCallback((yt,Pt)=>{const{prefixCls:hr}=e;if(Pt)return Pt;const Qn=hr||x.getPrefixCls("");return yt?`${Qn}-${yt}`:Qn},[x.getPrefixCls,e.prefixCls]),ki=_||x.iconPrefixCls||bT,Go=n||x.csp;NO(ki,Go);const Yo=RO(y,x.theme,{prefixCls:Ko("")}),Xo={csp:Go,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||w,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Ko,iconPrefixCls:ki,theme:Yo,segmented:C,statistic:k,spin:N,calendar:T,carousel:D,cascader:P,collapse:O,typography:R,checkbox:A,descriptions:M,divider:L,drawer:$,skeleton:F,steps:B,image:z,input:je,textArea:Me,layout:E,list:H,mentions:q,modal:j,progress:re,result:ie,slider:K,breadcrumb:_e,menu:Ee,pagination:ue,empty:Oe,badge:xe,radio:tt,rate:Nt,switch:st,transfer:pt,avatar:Dt,message:mt,tag:gt,table:Xe,card:nt,tabs:zt,timeline:xn,timePicker:tn,upload:U,notification:Q,tree:ye,colorPicker:Pe,datePicker:Be,rangePicker:_t,flex:_n,wave:$t,dropdown:dn,warning:oe,tour:be,tooltip:Ze,popover:Tt,popconfirm:Ar,floatButton:ae,floatButtonGroup:Je,variant:hn,inputNumber:Qs,treeSelect:Il},ss=Object.assign({},x);Object.keys(Xo).forEach(yt=>{Xo[yt]!==void 0&&(ss[yt]=Xo[yt])}),r6.forEach(yt=>{const Pt=e[yt];Pt&&(ss[yt]=Pt)}),typeof r<"u"&&(ss.button=Object.assign({autoInsertSpace:r},ss.button));const Ci=HN(()=>ss,ss,(yt,Pt)=>{const hr=Object.keys(yt),Qn=Object.keys(Pt);return hr.length!==Qn.length||hr.some(ee=>yt[ee]!==Pt[ee])}),{layer:Qo}=g.useContext(np),Yp=g.useMemo(()=>({prefixCls:ki,csp:Go,layer:Qo?"antd":void 0}),[ki,Go,Qo]);let It=g.createElement(g.Fragment,null,g.createElement(t6,{dropdownMatchSelectWidth:p}),t);const Fu=g.useMemo(()=>{var yt,Pt,hr,Qn;return qD(((yt=sp.Form)===null||yt===void 0?void 0:yt.defaultValidateMessages)||{},((hr=(Pt=Ci.locale)===null||Pt===void 0?void 0:Pt.Form)===null||hr===void 0?void 0:hr.defaultValidateMessages)||{},((Qn=Ci.form)===null||Qn===void 0?void 0:Qn.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Ci,o==null?void 0:o.validateMessages]);Object.keys(Fu).length>0&&(It=g.createElement(GD.Provider,{value:Fu},It)),a&&(It=g.createElement(QD,{locale:a,_ANT_MARK__:XD},It)),It=g.createElement(HD.Provider,{value:Yp},It),l&&(It=g.createElement(gO,{size:l},It)),It=g.createElement(e6,null,It);const Xp=g.useMemo(()=>{const yt=Yo||{},{algorithm:Pt,token:hr,components:Qn,cssVar:ee}=yt,we=n6(yt,["algorithm","token","components","cssVar"]),ke=Pt&&(!Array.isArray(Pt)||Pt.length>0)?Bv(Pt):_T,Qe={};Object.entries(Qn||{}).forEach(([Hu,I4])=>{const Ei=Object.assign({},I4);"algorithm"in Ei&&(Ei.algorithm===!0?Ei.theme=ke:(Array.isArray(Ei.algorithm)||typeof Ei.algorithm=="function")&&(Ei.theme=Bv(Ei.algorithm)),delete Ei.algorithm),Qe[Hu]=Ei});const Mr=Object.assign(Object.assign({},Yc),hr);return Object.assign(Object.assign({},we),{theme:ke,token:Mr,components:Qe,override:Object.assign({override:Mr},Qe),cssVar:ee})},[Yo]);return y&&(It=g.createElement(yT.Provider,{value:Xp},It)),Ci.warning&&(It=g.createElement(KD.Provider,{value:Ci.warning},It)),S!==void 0&&(It=g.createElement(mO,{disabled:S},It)),g.createElement(op.Provider,{value:Ci},It)},gl=e=>{const t=g.useContext(op),n=g.useContext(mT);return g.createElement(a6,Object.assign({parentContext:t,legacyLocale:n},e))};gl.ConfigContext=op;gl.SizeContext=Xc;gl.config=o6;gl.useConfig=vO;Object.defineProperty(gl,"SizeContext",{get:()=>Xc});const pr=(e,t)=>new kt(e).setA(t).toRgbString(),ea=(e,t)=>new kt(e).lighten(t).toHexString(),l6=e=>{const t=Ga(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},c6=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:pr(r,.85),colorTextSecondary:pr(r,.65),colorTextTertiary:pr(r,.45),colorTextQuaternary:pr(r,.25),colorFill:pr(r,.18),colorFillSecondary:pr(r,.12),colorFillTertiary:pr(r,.08),colorFillQuaternary:pr(r,.04),colorBgSolid:pr(r,.95),colorBgSolidHover:pr(r,1),colorBgSolidActive:pr(r,.9),colorBgElevated:ea(n,12),colorBgContainer:ea(n,8),colorBgLayout:ea(n,0),colorBgSpotlight:ea(n,26),colorBgBlur:pr(r,.04),colorBorder:ea(n,26),colorBorderSecondary:ea(n,19)}},u6=(e,t)=>{const n=Object.keys(B_).map(s=>{const o=Ga(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??z_(e),i=xT(e,{generateColorPalettes:l6,generateNeutralColorPalettes:c6});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},Sw={defaultSeed:Vh.token,defaultAlgorithm:z_,darkAlgorithm:u6};function kw({children:e}){const t=P_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(gl,{theme:{algorithm:n.mode==="dark"?Sw.darkAlgorithm:Sw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ge;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ge||(Ge={}));var Cw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Cw||(Cw={}));const he=Ge.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),vs=e=>{switch(typeof e){case"undefined":return he.undefined;case"string":return he.string;case"number":return Number.isNaN(e)?he.nan:he.number;case"boolean":return he.boolean;case"function":return he.function;case"bigint":return he.bigint;case"symbol":return he.symbol;case"object":return Array.isArray(e)?he.array:e===null?he.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?he.promise:typeof Map<"u"&&e instanceof Map?he.map:typeof Set<"u"&&e instanceof Set?he.set:typeof Date<"u"&&e instanceof Date?he.date:he.object;default:return he.unknown}},G=Ge.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ki extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ki))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ge.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ki.create=e=>new Ki(e);const u0=(e,t)=>{let n;switch(e.code){case G.invalid_type:e.received===he.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case G.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ge.jsonStringifyReplacer)}`;break;case G.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ge.joinValues(e.keys,", ")}`;break;case G.invalid_union:n="Invalid input";break;case G.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ge.joinValues(e.options)}`;break;case G.invalid_enum_value:n=`Invalid enum value. Expected ${Ge.joinValues(e.options)}, received '${e.received}'`;break;case G.invalid_arguments:n="Invalid function arguments";break;case G.invalid_return_type:n="Invalid function return type";break;case G.invalid_date:n="Invalid date";break;case G.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ge.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case G.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case G.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case G.custom:n="Invalid input";break;case G.invalid_intersection_types:n="Intersection results could not be merged";break;case G.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case G.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ge.assertNever(e)}return{message:n}};let d6=u0;function h6(){return d6}const f6=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function se(e,t){const n=h6(),r=f6({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===u0?void 0:u0].filter(i=>!!i)});e.common.issues.push(r)}class jn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Te;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return jn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Te;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Te=Object.freeze({status:"aborted"}),tc=e=>({status:"dirty",value:e}),Ir=e=>({status:"valid",value:e}),Ew=e=>e.status==="aborted",Nw=e=>e.status==="dirty",Ya=e=>e.status==="valid",qh=e=>typeof Promise<"u"&&e instanceof Promise;var me;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(me||(me={}));class pi{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Tw=(e,t)=>{if(Ya(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ki(e.common.issues);return this._error=n,this._error}}};function De(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class Ve{get description(){return this._def.description}_getType(t){return vs(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:vs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new jn,ctx:{common:t.parent.common,data:t.data,parsedType:vs(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(qh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:vs(t)},i=this._parseSync({data:t,path:r.path,parent:r});return Tw(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:vs(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Ya(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>Ya(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:vs(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(qh(i)?i:Promise.resolve(i));return Tw(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:G.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new Eo({schema:this,typeName:Ie.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return $i.create(this,this._def)}nullable(){return No.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ui.create(this)}promise(){return Zh.create(this,this._def)}or(t){return Gh.create([this,t],this._def)}and(t){return Yh.create(this,t,this._def)}transform(t){return new Eo({...De(this._def),schema:this,typeName:Ie.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Jh({...De(this._def),innerType:this,defaultValue:n,typeName:Ie.ZodDefault})}brand(){return new zT({typeName:Ie.ZodBranded,type:this,...De(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new ef({...De(this._def),innerType:this,catchValue:n,typeName:Ie.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return H_.create(this,t)}readonly(){return tf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const p6=/^c[^\s-]{8,}$/i,m6=/^[0-9a-z]+$/,g6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,v6=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,x6=/^[a-z0-9_-]{21}$/i,_6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,y6=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,b6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,w6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Mm;const S6=/^(?:(?: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])$/,k6=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,C6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,E6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,N6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,DT="((\\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])))",I6=new RegExp(`^${DT}$`);function OT(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function P6(e){return new RegExp(`^${OT(e)}$`)}function R6(e){let t=`${DT}T${OT(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function A6(e,t){return!!((t==="v4"||!t)&&S6.test(e)||(t==="v6"||!t)&&C6.test(e))}function M6(e,t){if(!_6.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function j6(e,t){return!!((t==="v4"||!t)&&k6.test(e)||(t==="v6"||!t)&&E6.test(e))}class Di extends Ve{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==he.string){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_type,expected:he.string,received:s.parsedType}),Te}const r=new jn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?se(i,{code:G.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&se(i,{code:G.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")b6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"email",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Mm||(Mm=new RegExp(w6,"u")),Mm.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"emoji",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")v6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"uuid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")x6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"nanoid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")p6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")m6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cuid2",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")g6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ulid",code:G.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),se(i,{validation:"url",code:G.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"regex",code:G.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?R6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?I6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?P6(s).test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{code:G.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?y6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"duration",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?A6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"ip",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?M6(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"jwt",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?j6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"cidr",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?N6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64",code:G.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?T6.test(t.data)||(i=this._getOrReturnCtx(t,i),se(i,{validation:"base64url",code:G.invalid_string,message:s.message}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:G.invalid_string,...me.errToObj(r)})}_addCheck(t){return new Di({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...me.errToObj(t)})}url(t){return this._addCheck({kind:"url",...me.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...me.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...me.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...me.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...me.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...me.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...me.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...me.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...me.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...me.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...me.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...me.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...me.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...me.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...me.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...me.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...me.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...me.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...me.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...me.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...me.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...me.errToObj(n)})}nonempty(t){return this.min(1,me.errToObj(t))}trim(){return new Di({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Di({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Di({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Di.create=e=>new Di({checks:[],typeName:Ie.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...De(e)});function L6(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class Xa extends Ve{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==he.number){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_type,expected:he.number,received:s.parsedType}),Te}let r;const i=new jn;for(const s of this._def.checks)s.kind==="int"?Ge.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:G.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?L6(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),se(r,{code:G.not_finite,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Xa({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Xa({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:me.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:me.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ge.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Xa.create=e=>new Xa({checks:[],typeName:Ie.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...De(e)});class Qc extends Ve{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==he.bigint)return this._getInvalidInput(t);let r;const i=new jn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),se(r,{code:G.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return se(n,{code:G.invalid_type,expected:he.bigint,received:n.parsedType}),Te}gte(t,n){return this.setLimit("min",t,!0,me.toString(n))}gt(t,n){return this.setLimit("min",t,!1,me.toString(n))}lte(t,n){return this.setLimit("max",t,!0,me.toString(n))}lt(t,n){return this.setLimit("max",t,!1,me.toString(n))}setLimit(t,n,r,i){return new Qc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:me.toString(i)}]})}_addCheck(t){return new Qc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:me.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Qc.create=e=>new Qc({checks:[],typeName:Ie.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...De(e)});class d0 extends Ve{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==he.boolean){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.boolean,received:r.parsedType}),Te}return Ir(t.data)}}d0.create=e=>new d0({typeName:Ie.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...De(e)});class Kh extends Ve{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==he.date){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_type,expected:he.date,received:s.parsedType}),Te}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return se(s,{code:G.invalid_date}),Te}const r=new jn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),se(i,{code:G.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Kh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:me.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:me.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Kh.create=e=>new Kh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ie.ZodDate,...De(e)});class Iw extends Ve{_parse(t){if(this._getType(t)!==he.symbol){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.symbol,received:r.parsedType}),Te}return Ir(t.data)}}Iw.create=e=>new Iw({typeName:Ie.ZodSymbol,...De(e)});class h0 extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.undefined,received:r.parsedType}),Te}return Ir(t.data)}}h0.create=e=>new h0({typeName:Ie.ZodUndefined,...De(e)});class f0 extends Ve{_parse(t){if(this._getType(t)!==he.null){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.null,received:r.parsedType}),Te}return Ir(t.data)}}f0.create=e=>new f0({typeName:Ie.ZodNull,...De(e)});class Pw extends Ve{constructor(){super(...arguments),this._any=!0}_parse(t){return Ir(t.data)}}Pw.create=e=>new Pw({typeName:Ie.ZodAny,...De(e)});class p0 extends Ve{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Ir(t.data)}}p0.create=e=>new p0({typeName:Ie.ZodUnknown,...De(e)});class zs extends Ve{_parse(t){const n=this._getOrReturnCtx(t);return se(n,{code:G.invalid_type,expected:he.never,received:n.parsedType}),Te}}zs.create=e=>new zs({typeName:Ie.ZodNever,...De(e)});class Rw extends Ve{_parse(t){if(this._getType(t)!==he.undefined){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.void,received:r.parsedType}),Te}return Ir(t.data)}}Rw.create=e=>new Rw({typeName:Ie.ZodVoid,...De(e)});class ui extends Ve{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==he.array)return se(n,{code:G.invalid_type,expected:he.array,received:n.parsedType}),Te;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(se(n,{code:o?G.too_big:G.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(se(n,{code:G.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(se(n,{code:G.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new pi(n,o,n.path,a)))).then(o=>jn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new pi(n,o,n.path,a)));return jn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ui({...this._def,minLength:{value:t,message:me.toString(n)}})}max(t,n){return new ui({...this._def,maxLength:{value:t,message:me.toString(n)}})}length(t,n){return new ui({...this._def,exactLength:{value:t,message:me.toString(n)}})}nonempty(t){return this.min(1,t)}}ui.create=(e,t)=>new ui({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ie.ZodArray,...De(t)});function ca(e){if(e instanceof Ut){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=$i.create(ca(r))}return new Ut({...e._def,shape:()=>t})}else return e instanceof ui?new ui({...e._def,type:ca(e.element)}):e instanceof $i?$i.create(ca(e.unwrap())):e instanceof No?No.create(ca(e.unwrap())):e instanceof ko?ko.create(e.items.map(t=>ca(t))):e}class Ut extends Ve{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ge.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==he.object){const c=this._getOrReturnCtx(t);return se(c,{code:G.invalid_type,expected:he.object,received:c.parsedType}),Te}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof zs&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new pi(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof zs){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(se(i,{code:G.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new pi(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>jn.mergeObjectSync(r,c)):jn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return me.errToObj,new Ut({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:me.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Ut({...this._def,unknownKeys:"strip"})}passthrough(){return new Ut({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ut({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ut({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ie.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Ut({...this._def,catchall:t})}pick(t){const n={};for(const r of Ge.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Ut({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ge.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Ut({...this._def,shape:()=>n})}deepPartial(){return ca(this)}partial(t){const n={};for(const r of Ge.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Ut({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ge.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof $i;)s=s._def.innerType;n[r]=s}return new Ut({...this._def,shape:()=>n})}keyof(){return BT(Ge.objectKeys(this.shape))}}Ut.create=(e,t)=>new Ut({shape:()=>e,unknownKeys:"strip",catchall:zs.create(),typeName:Ie.ZodObject,...De(t)});Ut.strictCreate=(e,t)=>new Ut({shape:()=>e,unknownKeys:"strict",catchall:zs.create(),typeName:Ie.ZodObject,...De(t)});Ut.lazycreate=(e,t)=>new Ut({shape:e,unknownKeys:"strip",catchall:zs.create(),typeName:Ie.ZodObject,...De(t)});class Gh extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ki(a.ctx.common.issues));return se(n,{code:G.invalid_union,unionErrors:o}),Te}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ki(l));return se(n,{code:G.invalid_union,unionErrors:a}),Te}}get options(){return this._def.options}}Gh.create=(e,t)=>new Gh({options:e,typeName:Ie.ZodUnion,...De(t)});const Pi=e=>e instanceof g0?Pi(e.schema):e instanceof Eo?Pi(e.innerType()):e instanceof Qh?[e.value]:e instanceof Co?e.options:e instanceof v0?Ge.objectValues(e.enum):e instanceof Jh?Pi(e._def.innerType):e instanceof h0?[void 0]:e instanceof f0?[null]:e instanceof $i?[void 0,...Pi(e.unwrap())]:e instanceof No?[null,...Pi(e.unwrap())]:e instanceof zT||e instanceof tf?Pi(e.unwrap()):e instanceof ef?Pi(e._def.innerType):[];class F_ extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.object)return se(n,{code:G.invalid_type,expected:he.object,received:n.parsedType}),Te;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(se(n,{code:G.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=Pi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new F_({typeName:Ie.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...De(r)})}}function m0(e,t){const n=vs(e),r=vs(t);if(e===t)return{valid:!0,data:e};if(n===he.object&&r===he.object){const i=Ge.objectKeys(t),s=Ge.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=m0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===he.array&&r===he.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=m0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===he.date&&r===he.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Yh extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(Ew(s)||Ew(o))return Te;const a=m0(s.value,o.value);return a.valid?((Nw(s)||Nw(o))&&n.dirty(),{status:n.value,value:a.data}):(se(r,{code:G.invalid_intersection_types}),Te)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Yh.create=(e,t,n)=>new Yh({left:e,right:t,typeName:Ie.ZodIntersection,...De(n)});class ko extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.array)return se(r,{code:G.invalid_type,expected:he.array,received:r.parsedType}),Te;if(r.data.length<this._def.items.length)return se(r,{code:G.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Te;!this._def.rest&&r.data.length>this._def.items.length&&(se(r,{code:G.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new pi(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>jn.mergeArray(n,o)):jn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new ko({...this._def,rest:t})}}ko.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ko({items:e,typeName:Ie.ZodTuple,rest:null,...De(t)})};class Xh extends Ve{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.object)return se(r,{code:G.invalid_type,expected:he.object,received:r.parsedType}),Te;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new pi(r,a,r.path,a)),value:o._parse(new pi(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?jn.mergeObjectAsync(n,i):jn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Ve?new Xh({keyType:t,valueType:n,typeName:Ie.ZodRecord,...De(r)}):new Xh({keyType:Di.create(),valueType:t,typeName:Ie.ZodRecord,...De(n)})}}class Aw extends Ve{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.map)return se(r,{code:G.invalid_type,expected:he.map,received:r.parsedType}),Te;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new pi(r,a,r.path,[c,"key"])),value:s._parse(new pi(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Aw.create=(e,t,n)=>new Aw({valueType:t,keyType:e,typeName:Ie.ZodMap,...De(n)});class Zc extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==he.set)return se(r,{code:G.invalid_type,expected:he.set,received:r.parsedType}),Te;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(se(r,{code:G.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(se(r,{code:G.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Te;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new pi(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Zc({...this._def,minSize:{value:t,message:me.toString(n)}})}max(t,n){return new Zc({...this._def,maxSize:{value:t,message:me.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Zc.create=(e,t)=>new Zc({valueType:e,minSize:null,maxSize:null,typeName:Ie.ZodSet,...De(t)});class g0 extends Ve{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}g0.create=(e,t)=>new g0({getter:e,typeName:Ie.ZodLazy,...De(t)});class Qh extends Ve{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return se(n,{received:n.data,code:G.invalid_literal,expected:this._def.value}),Te}return{status:"valid",value:t.data}}get value(){return this._def.value}}Qh.create=(e,t)=>new Qh({value:e,typeName:Ie.ZodLiteral,...De(t)});function BT(e,t){return new Co({values:e,typeName:Ie.ZodEnum,...De(t)})}class Co extends Ve{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{expected:Ge.joinValues(r),received:n.parsedType,code:G.invalid_type}),Te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return se(n,{received:n.data,code:G.invalid_enum_value,options:r}),Te}return Ir(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return Co.create(t,{...this._def,...n})}exclude(t,n=this._def){return Co.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}Co.create=BT;class v0 extends Ve{_parse(t){const n=Ge.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==he.string&&r.parsedType!==he.number){const i=Ge.objectValues(n);return se(r,{expected:Ge.joinValues(i),received:r.parsedType,code:G.invalid_type}),Te}if(this._cache||(this._cache=new Set(Ge.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ge.objectValues(n);return se(r,{received:r.data,code:G.invalid_enum_value,options:i}),Te}return Ir(t.data)}get enum(){return this._def.values}}v0.create=(e,t)=>new v0({values:e,typeName:Ie.ZodNativeEnum,...De(t)});class Zh extends Ve{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==he.promise&&n.common.async===!1)return se(n,{code:G.invalid_type,expected:he.promise,received:n.parsedType}),Te;const r=n.parsedType===he.promise?n.data:Promise.resolve(n.data);return Ir(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Zh.create=(e,t)=>new Zh({type:e,typeName:Ie.ZodPromise,...De(t)});class Eo extends Ve{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ie.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{se(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Te;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Te:l.status==="dirty"||n.value==="dirty"?tc(l.value):l});{if(n.value==="aborted")return Te;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Te:a.status==="dirty"||n.value==="dirty"?tc(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ya(o))return Te;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ya(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Te);Ge.assertNever(i)}}Eo.create=(e,t,n)=>new Eo({schema:e,typeName:Ie.ZodEffects,effect:t,...De(n)});Eo.createWithPreprocess=(e,t,n)=>new Eo({schema:t,effect:{type:"preprocess",transform:e},typeName:Ie.ZodEffects,...De(n)});class $i extends Ve{_parse(t){return this._getType(t)===he.undefined?Ir(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}$i.create=(e,t)=>new $i({innerType:e,typeName:Ie.ZodOptional,...De(t)});class No extends Ve{_parse(t){return this._getType(t)===he.null?Ir(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}No.create=(e,t)=>new No({innerType:e,typeName:Ie.ZodNullable,...De(t)});class Jh extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===he.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Jh.create=(e,t)=>new Jh({innerType:e,typeName:Ie.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...De(t)});class ef extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return qh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ki(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ef.create=(e,t)=>new ef({innerType:e,typeName:Ie.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...De(t)});class Mw extends Ve{_parse(t){if(this._getType(t)!==he.nan){const r=this._getOrReturnCtx(t);return se(r,{code:G.invalid_type,expected:he.nan,received:r.parsedType}),Te}return{status:"valid",value:t.data}}}Mw.create=e=>new Mw({typeName:Ie.ZodNaN,...De(e)});class zT extends Ve{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class H_ extends Ve{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Te:s.status==="dirty"?(n.dirty(),tc(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Te:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new H_({in:t,out:n,typeName:Ie.ZodPipeline})}}class tf extends Ve{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ya(i)&&(i.value=Object.freeze(i.value)),i);return qh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}tf.create=(e,t)=>new tf({innerType:e,typeName:Ie.ZodReadonly,...De(t)});var Ie;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ie||(Ie={}));const b=Di.create,W=Xa.create,ge=d0.create,Fi=p0.create;zs.create;const J=ui.create,I=Ut.create;Gh.create;const _i=F_.create;Yh.create;ko.create;const Pr=Xh.create,Y=Qh.create,ve=Co.create;Zh.create;$i.create;No.create;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const D6=["owner"],O6=["agent","owner","user-upload"],$T=I({id:b().min(1),relPath:b().min(1),from:ve(O6),label:b().optional(),size:W().int().nonnegative(),mime:b().min(1),addedAt:W().int().nonnegative(),lastEditedAt:W().int().nonnegative().optional(),stale:ge().optional()});I({sessionId:b().min(1),relPath:b().min(1),ttlSeconds:W().int().positive().nullable().optional(),view:ve(["raw","md-rendered"]).optional()});I({url:b().min(1),expiresAt:W().int().nonnegative().nullable()});I({sessionId:b().min(1),relPath:b().min(1),label:b().optional(),origin:Y("agent").optional()});I({entry:$T});I({sessionId:b().min(1),relPath:b().min(1)});I({removed:Y(!0)});I({sessionId:b().min(1)});I({entries:J($T)});I({attachmentId:b().min(1),url:b().min(1),relPath:b().min(1),sizeBytes:W().int().nonnegative(),mimeType:b().min(1)});const B6=_i("type",[I({type:Y("persona"),id:b().min(1)}).strict(),I({type:Y("chat"),id:b().min(1)}).strict(),I({type:Y("*")}).strict()]),z6=ve(["read","send","admin"]),U_=I({resource:B6,actions:J(z6).min(1)}).strict(),$6=I({id:b().min(1),secretHash:b().regex(/^[a-f0-9]{64}$/),displayName:b(),grants:J(U_),issuedAt:W().int().nonnegative(),expiresAt:W().int().positive().optional(),maxUses:W().int().positive().optional(),usedCount:W().int().nonnegative(),peerOwnerId:b().min(1).optional(),firstUsedByPeerAt:W().int().positive().optional(),peerDisplayName:b().optional()}).strict(),F6=$6.omit({secretHash:!0});I({type:Y("whoami:ok"),owner:I({id:b(),kind:ve(["owner","guest"]),displayName:b(),ownerId:b(),provider:b()}).strict(),capability:F6,grantedPersonas:J(I({id:b().min(1),displayName:b()}).strict())}).strict();I({selfUrl:b().min(1)});I({type:Y("contact:handshake:ok"),owner:I({id:b(),ownerId:b(),provider:b(),displayName:b()}),grants:J(U_)});const H6=I({name:b().min(1),from:b().optional(),version:b().optional(),min:b().optional()}),U6=I({name:b().min(1),env:J(b().min(1)).min(1)}),W6=I({name:b().min(1)}),W_=b().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),FT=["proxy","env"],HT=["mcp","cli"],V6=["bearer","lark-sidecar"],q6=["none","shared","personal"],UT=["oauth","fields"],V_=b().regex(/^[A-Z][A-Z0-9_]*$/,"要填的变量名只能是大写字母、数字和下划线,且以字母开头"),K6=I({name:W_,kind:ve(FT),runner:ve(HT),protocol:ve(V6).optional(),id:b().min(1),credentialSource:ve(q6).optional(),auth:ve(UT).optional(),fields:J(V_).default([]),http:I({url:b().min(1),headers:Pr(b(),b())}).optional()}),WT={clis:J(H6),secrets:J(U6),assets:J(W6),connectors:J(K6).default([])};I(WT);const VT=I({version:Y(1),...WT}).strict(),G6=I({target:b().min(1),reason:b().min(1),file:b().min(1),quote:b().min(1)}),Y6=I({version:Y(1),manifest:VT}).strict(),X6=["hard","soft"],qT=ve(X6),Q6=ve(["scanning","done","failed"]),Z6=I({scanSessionId:b().optional(),status:Q6,evidence:J(G6).default([]),notes:J(b()).default([]),scannedAssets:J(b()).default([]),head:b().min(1).optional(),releasedHead:b().min(1).optional(),baseKind:qT.default("hard"),base:b().min(1).optional(),startedAt:W(),finishedAt:W().optional(),error:b().optional()}).strict(),J6=I({url:b().min(1),branch:b().min(1),head:b().min(1),dirty:ge(),ahead:W()}).strict(),eB=I({env:b().min(1),setAt:W().optional()}).strict(),tB=["pending","running","done","failed","waiting","skipped"],nB=ve(tB),rB=["build","smoke","deploy"],iB=ve(rB),sB=I({key:iB,status:nB,url:b().optional(),jobId:W().optional(),startedAt:W().optional(),completedAt:W().optional()}).strict(),oB=I({runId:W(),headSha:b().min(1),status:ve(["queued","running","completed"]),htmlUrl:b().min(1),jobs:J(sB)}).strict();I({personaId:b().min(1),repo:J6.optional(),file:Y6.optional(),scan:Z6.optional(),secrets:J(eB).optional(),run:oB.optional(),fileError:b().optional()}).strict();I({sha:b().min(1),actionsUrl:b().min(1)}).strict();const aB=I({personaId:b().min(1)}).strict();aB.extend({mode:qT.optional()}).strict();I({personaId:b().min(1),patch:I({manifest:VT.optional()}).strict()}).strict();I({personaId:b().min(1),name:b().min(1),values:Pr(b(),b())}).strict();I({personaId:b().min(1),jobId:W()}).strict();I({personaId:b().min(1),kind:ve(["cli","secret","asset","connector"]),item:Pr(b(),Fi()),evidence:I({reason:b().min(1),file:b().min(1),quote:b().min(1)})}).strict();I({personaId:b().min(1),notes:J(b()).default([])}).strict();I({deviceId:b().min(1),remoteAccessAllowed:ge()}).strict();I({type:Y("contact:setRemoteAccess:ok"),deviceId:b().min(1),remoteAccessAllowed:ge()}).strict();I({type:Y("contact:remote-access-updated"),deviceId:b().min(1),remoteAccessAllowed:ge()}).strict();I({personaId:b().min(1)}).strict();const lB=["connected","missing","reauth"],cB=["link","fill"],uB=I({name:W_,id:b().min(1),kind:ve(FT),runner:ve(HT),auth:ve(UT),status:ve(lB),action:ve(cB),authUrl:b().optional(),fields:J(V_)}).strict();I({connectors:J(uB)}).strict();I({personaId:b().min(1),name:W_,values:Pr(V_,b().min(1))}).strict();const dB=I({deviceId:b().min(1),ownerId:b().min(1),provider:b().min(1),displayName:b(),remoteUrl:b().min(1),connectToken:b(),grants:J(U_),addedAt:W().int().nonnegative(),pinnedAt:W().int().nullable().default(null),remoteAccessAllowed:ge().default(!1),note:b().default("")}).strict(),KT=dB;I({deviceId:b().min(1)}).strict();I({type:Y("contact:remove:ok"),deviceId:b().min(1)}).strict();I({type:Y("contact:list:ok"),contacts:J(KT)}).strict();I({type:Y("contact:added"),contact:KT}).strict();I({type:Y("contact:removed"),deviceId:b().min(1)}).strict();I({deviceId:b().min(1),pinned:ge()}).strict();I({deviceId:b().min(1),note:b()}).strict();I({type:Y("contact:setNote:ok"),deviceId:b().min(1),note:b()}).strict();I({type:Y("contact:pin:ok"),deviceId:b().min(1),pinnedAt:W().int().nullable()}).strict();I({type:Y("contact:pinned"),deviceId:b().min(1),pinnedAt:W().int().nullable()}).strict();const hB=I({deviceId:b().min(1),name:b().min(1),url:b().min(1)});I({type:Y("device:list:ok"),devices:J(hB)});I({deviceId:b().min(1),url:b().min(1).optional(),name:b().optional()});I({type:Y("device:connect:ok"),deviceId:b(),name:b(),url:b()});const GT=I({ownerId:b().min(1),provider:b().min(1),displayName:b().min(1),avatarUrl:b().optional(),unionId:b().optional()});I({type:Y("auth:login:start:ok"),authUrl:b().min(1),state:b().min(1)});I({type:Y("auth:getIdentity:ok"),identity:GT.nullable(),deviceId:b().min(1),ttcTokenExpiresAt:W().nullable().optional()});I({type:Y("auth:logout:ok")});const YT=b().nullable();I({type:Y("auth:apiKey:get:ok"),apiKey:b().nullable(),createdAt:b().nullable(),gatewayUrl:YT});I({type:Y("auth:apiKey:regenerate:ok"),apiKey:b().min(1),createdAt:b().min(1),gatewayUrl:YT});I({type:Y("auth:login:done"),identity:GT});I({type:Y("auth:login:failed"),reason:b()});const q_=_i("kind",[I({kind:Y("success"),text:b(),brief:b().optional(),filePaths:J(b()).optional()}),I({kind:Y("failure"),reason:b(),brief:b().optional()})]);I({targetPersona:b().min(1).optional(),dispatchId:b().min(1).optional(),prompt:b(),brief:b().optional(),targetDeviceId:b().min(1).optional(),model:b().min(1).optional(),tool:b().min(1).optional(),sessionLabel:b().min(1).max(60).optional(),meta:Pr(Fi()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});I({dispatchId:b().min(1),outcome:q_});const fB=["running","completed","failed"],K_=ve(fB),pB=I({dispatchId:b().min(1),sourceSessionId:b().min(1),sourcePersonaId:b().min(1).optional(),targetPersonaId:b().min(1),targetDeviceId:b().min(1).optional(),workerSessionId:b().min(1).optional(),taskText:b(),taskBrief:b().optional(),round:W().int().positive().optional(),status:K_,outcome:q_.optional(),meta:Pr(Fi()).optional(),createdAt:b().min(1),completedAt:b().min(1).optional(),deliveredAt:b().min(1).optional()});I({sourceSessionId:b().min(1).optional(),relatedSessionId:b().min(1).optional()});I({records:J(pB)});I({dispatchId:b().min(1)});I({type:Y("personaDispatch:get:ok"),status:K_,outcome:q_.optional()});const mB=/^[a-z0-9][a-z0-9-]*$/;ve(["stopped","starting","running","crashed","invalid"]);const gB=new Set(["localhost","127.0.0.1"]);function vB(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&gB.has(t.hostname))}const fd=I({id:b().regex(mB),name:b().min(1),version:b().min(1),apiVersion:Y("1"),runtime:I({startCommand:b().min(1)}).passthrough().optional(),entry:I({url:b().url().refine(vB,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:G.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:G.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),xB=_i("kind",[I({kind:Y("local"),port:W().int().min(1).max(65535)}),I({kind:Y("hosted"),url:b().url()})]);_i("state",[I({extId:b(),manifest:fd,state:Y("stopped")}),I({extId:b(),manifest:fd,state:Y("starting")}),I({extId:b(),manifest:fd,state:Y("running"),target:xB}),I({extId:b(),manifest:fd,state:Y("crashed")}),I({extId:b(),manifest:Fi().nullable(),state:Y("invalid"),invalidReason:b().min(1)})]);I({snapshotHash:b().min(1),version:b().min(1),publishedAt:W()});const _B=_i("kind",[I({kind:Y("p2p-tunnel"),ownerPrincipalId:b().min(1),extId:b().min(1)})]);_i("kind",[I({kind:Y("p2p-tunnel"),ownerPrincipalId:b().min(1),extId:b().min(1),snapshotHash:b().min(1)})]);I({extId:b().min(1),name:b().min(1),version:b().min(1),contentHash:b().min(1),publishedAt:W()});const yB=_i("kind",[I({kind:Y("clean")}),I({kind:Y("ready-new-version"),fromVersion:b().min(1),toVersion:b().min(1)}),I({kind:Y("error-same-hash"),version:b().min(1)}),I({kind:Y("error-version-not-bumped"),localVersion:b().min(1),publishedVersion:b().min(1)}),I({kind:Y("error-version-regression"),localVersion:b().min(1),publishedVersion:b().min(1)})]);I({localManifest:I({name:b().min(1),version:b().min(1),contentHash:b().min(1)}),publishState:_i("kind",[I({kind:Y("unpublished")}),I({kind:Y("published"),version:b().min(1),contentHash:b().min(1),publishedAt:W()})]),check:yB});I({extId:b().min(1),newVersion:b().min(1).nullish()});I({extId:b().min(1)});I({extId:b().min(1),snapshotHash:b().min(1)});I({channelRef:_B,snapshotHash:b().min(1),zipBase64:b().min(1)});I({id:b().min(1),peerDeviceId:b().min(1),senderDeviceId:b().min(1),text:b().min(1),createdAt:W().int().nonnegative(),readBy:Pr(b().min(1),W().int().positive()).default({}),origin:I({kind:Y("persona"),personaId:b().min(1)}).optional()}).strict();I({peerDeviceId:b().min(1).optional(),id:b().min(1),text:b().min(1),createdAt:W().int().nonnegative(),origin:I({kind:Y("persona"),personaId:b().min(1)}).optional()}).strict();I({peerDeviceId:b().min(1),sinceCreatedAt:W().int().nonnegative().optional()}).strict();I({peerDeviceId:b().min(1),upToCreatedAt:W().int().nonnegative()}).strict();I({peerDeviceId:b().min(1).optional(),text:b().min(1)});I({peerDeviceId:b().min(1).optional(),command:b().min(1),timeoutMs:W().int().positive().optional()}).strict();I({type:Y("peerExec:run:ok"),stdout:b(),stderr:b(),exitCode:W().int().nullable(),timedOut:ge(),stdoutTruncated:ge(),stderrTruncated:ge()}).strict();const XT=_i("kind",[I({kind:Y("at"),at:b().min(1)}),I({kind:Y("every"),everyMs:W().int().positive(),anchorMs:W().int().nonnegative().optional()}),I({kind:Y("cron"),expr:b().min(1),tz:b().min(1).optional()})]),yu=b().trim().min(1);I({personaId:yu,name:b().min(1),schedule:XT,prompt:b().min(1),targetPersona:b().min(1).optional(),timeoutMs:W().int().positive().optional()});I({personaId:yu,onlyMine:ge().optional()});I({personaId:yu,shiftId:b().min(1)});const bB=I({name:b().min(1).optional(),schedule:XT.optional(),prompt:b().min(1).optional(),targetPersona:b().min(1).optional(),timeoutMs:W().int().positive().optional(),enabled:ge().optional()});I({personaId:yu,shiftId:b().min(1),patch:bB});I({personaId:yu,shiftId:b().min(1),limit:W().int().positive().optional()});const QT="persona-master",G_=I({personaId:b().min(1),deviceId:b().min(1).optional()}),ZT=I({id:b().min(1),name:b().min(1),memberPersonas:J(G_),memberContactDeviceIds:J(b().min(1)),createdAt:b().min(1),updatedAt:b().min(1)}),JT=b().trim().min(1);I({name:JT,memberPersonas:J(G_).default([]),memberContactDeviceIds:J(b().min(1)).default([])});I({channelId:b().min(1),name:JT.optional(),memberPersonas:J(G_).optional(),memberContactDeviceIds:J(b().min(1)).optional()});I({channelId:b().min(1)});I({channels:J(ZT)});I({channel:ZT});I({ok:Y(!0),removedTopics:W().int().min(0)});const Kt=b().trim().min(1),Y_=["master-confirmed","owner-needed"],X_=["open","resolved"],wB=Y_[0];Y_[1];X_[0];const SB=X_[1],kB=ve(Y_),CB=ve(X_),EB=I({id:Kt.optional(),resolves:Kt.optional(),type:kB,status:CB,question:Kt,recommendation:Kt}).superRefine((e,t)=>{e.type===wB&&e.status!==SB&&t.addIssue({code:G.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),NB=["planning","running","done"],TB=ve(NB),eI=I({at:b().min(1),actor:b().min(1),action:b().min(1),target:b().optional(),reason:b().min(1),artifacts:J(Kt).optional(),decision:EB.optional()}),IB=I({rejectCount:W().int().min(0),accepted:ge().default(!1),ordinal:W().int().min(1).optional(),overrideCount:W().int().min(0).optional()}),Q_=I({id:b().min(1),channelId:b().min(1),title:b(),masterSessionId:b().min(1),goal:b(),boundaries:b(),acceptanceCriteria:J(b()),activity:J(eI),lineMeta:Pr(IB),nextLineOrdinal:W().int().min(1).optional(),state:TB,createdAt:b().min(1),updatedAt:b().min(1)}),PB=I({lineId:b().min(1),dispatchId:b().min(1),workerSessionId:b().optional(),assignee:b().min(1),focus:b(),status:K_,acceptance:J(b()),rejectCount:W().int().min(0),accepted:ge(),ordinal:W().int().min(1).nullable()});I({channelId:b().min(1)});I({topicId:b().min(1).optional(),sessionId:b().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});I({channelId:b().min(1),title:Kt.optional()});I({topicId:b().min(1),title:Kt.optional(),goal:Kt,boundaries:b(),acceptanceCriteria:J(Kt).min(1)});I({topicId:b().min(1),action:Kt,target:Kt.optional(),reason:Kt,artifacts:J(Kt).optional(),decision:eI.shape.decision});I({topicId:b().min(1),lineId:Kt,reason:Kt});I({topicId:b().min(1),lineId:Kt,reason:Kt,artifacts:J(Kt).optional(),watcherVerdict:ve(["pass","fail"]),overrideReason:Kt.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});I({topicId:b().min(1),state:ve(["done"])});I({topicId:b().min(1),title:Kt});I({topicId:b().min(1)});const RB=Q_.extend({lineCount:W().int().min(0)});I({topics:J(RB)});I({topic:Q_,lines:J(PB)});I({topicId:b().min(1),masterSessionId:b().min(1)});I({rejectCount:W().int().min(1),needsOwnerAttention:ge()});I({acceptedLines:W().int().min(1),totalLines:W().int().min(1),allAccepted:ge(),overrides:W().int().min(0),needsOwnerAttention:ge()});I({topic:Q_});I({ok:Y(!0),removedMasterSessionId:b().min(1).nullable(),removedWorkerSessionIds:J(b().min(1))});const AB=["ask","allow","deny"],tI=ve(AB),MB=I({id:b().min(1),desc:b().min(1),action:tI});I({rules:J(MB)});I({ruleId:b().min(1)});I({action:tI,desc:b(),source:b().min(1)});const jB=["created","review-requested"],nI=/^[A-Za-z0-9._-]+$/,vl=b().min(1).regex(nI),xl=b().min(1).regex(nI),bu=W().int().positive();I({role:ve(jB)});I({owner:vl,repo:xl,number:bu});I({owner:vl,repo:xl,number:bu,expectedHeadSha:b().min(1)});I({owner:vl,repo:xl,number:bu,body:b().min(1)});I({owner:vl,repo:xl,number:bu,ready:ge()});I({owner:vl,repo:xl});I({owner:vl,repo:xl,number:bu,reviewers:J(b().min(1)).min(1)});I({personaId:b().min(1)});I({personaId:b().min(1)});const LB=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],DB=ve(LB);I({personaId:b().min(1),appId:b().min(1),appSecret:b().min(1),botName:b().min(1).optional()});const OB=I({chatId:b().min(1),chatName:b().optional(),lastActiveAt:W().int().optional()}),BB=I({state:ve(["unbound","provisioning","bound","broken"]),appId:b().optional(),botName:b().optional(),brokenReason:b().optional(),qrUrl:b().optional(),errorReason:DB.optional(),groups:J(OB),needsUpgrade:ge().optional(),upgradeQrUrl:b().optional()});BB.extend({personaId:b().min(1)});I({});I({onboardingCompletedAt:W()});const rI=["claude","codex","pi"];I({});I({tools:J(I({id:ve(rI),available:ge(),version:b().optional(),path:b().optional()}))});I({});const zB=I({tool:ve(rI),cwd:b(),toolSessionId:b(),label:b().optional(),createdAt:b(),updatedAt:b(),turns:W()});I({candidates:J(zB)});I({});I({registered:ge()});const $B=I({personaId:b(),label:b(),model:b().optional(),effort:b().optional(),public:ge(),iconKey:b().optional(),tool:b().optional(),createdAt:W(),updatedAt:W(),cloud:I({gatewayUrl:b().min(1),personaId:b().min(1)}).strict().optional()}).strict(),FB=I({name:b().min(1),description:b().optional()}),HB=I({id:b().min(1)}),iI=I({writableRoots:J(b()).optional(),denyRead:J(b()).optional(),network:ge().optional()}).strict(),UB=I({permissions:I({defaultMode:b().optional(),allow:J(b()).optional(),deny:J(b()).optional()}).optional(),sandbox:I({enabled:ge().optional(),autoAllowBashIfSandboxed:ge().optional(),allowUnsandboxedCommands:ge().optional(),excludedCommands:J(b()).optional(),filesystem:I({denyRead:J(b()).optional(),allowRead:J(b()).optional(),denyWrite:J(b()).optional(),allowWrite:J(b()).optional()}).optional(),network:I({allowedDomains:J(b()).optional(),allowLocalBinding:ge().optional()}).optional()}).optional()});$B.extend({personality:b().optional(),personalityLocal:b().optional(),personalityManaged:ge().optional(),skills:J(FB).optional(),plugins:J(HB).optional(),sandboxSettings:UB.nullable().optional(),codexSandbox:iI.nullable().optional()});I({slug:b().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:b().min(1),personality:b(),model:b().optional(),effort:b().optional(),tool:b().optional(),public:ge().optional(),iconKey:b().optional()}).strict();I({personaId:b().min(1)});I({personaId:b().min(1),patch:I({label:b().min(1).optional(),model:b().optional(),effort:b().optional(),tool:b().optional(),personality:b().optional(),personalityLocal:b().optional(),public:ge().optional(),iconKey:b().nullable().optional(),codexSandbox:iI.optional()}).strict()}).strict();const sI=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","session:queue","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","contact:note-updated","org-mesh:progress","channel:changed","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed","larkBot:state"],oI=["idle","running","running-idle","stopped","error","observing"],WB=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function ap(e){return e==="dispatch-task"||e==="dispatch-result"}const VB=["builtin","global","project","plugin"],qB=["builtin","global","project","policy","plugin"],aI=ve(["owner","guest"]);I({id:b().min(1),kind:aI,displayName:b(),feishuUnionId:b().optional()}).strict();const KB=I({did:b().min(1),displayName:b(),feishuUnionId:b().optional(),principal:aI}).strict(),GB=ve(oI),YB=I({inputTokens:W().int().nonnegative(),outputTokens:W().int().nonnegative(),cacheReadTokens:W().int().nonnegative().optional(),cacheCreateTokens:W().int().nonnegative().optional()}),lI={gitBranch:b().optional(),resolvedModel:b().optional(),resolvedEffort:b().optional(),contextUsage:YB.optional(),contextWindowSize:W().int().positive().optional(),aiLabel:b().optional()},XB=I(lI),cI=I({value:b(),label:b(),description:b().optional()}),QB=I({id:b().min(1),label:b().min(1),description:b().optional(),contextWindowSize:W().int().positive(),default:ge().optional(),efforts:J(cI).optional(),defaultEffort:b().optional(),group:b().optional()}),ZB=I({id:b().min(1),label:b().min(1),description:b().optional()}),JB=I({name:b().min(1),type:ve(["string","select","toggle"]),label:b().min(1),description:b().optional(),options:J(cI).optional(),default:Fi().optional(),scope:ve(["core","tool-specific"])});I({tool:b().min(1)});const ez=I({rewind:ge(),subagents:ge(),tui:ge(),observe:ge(),fileSharing:ge(),fork:ge()});I({tool:b().min(1),toolSessionIdLabel:b().optional(),models:J(QB),permissionModes:J(ZB),configSchema:J(JB),features:ez});const tz=I({tool:b().min(1),pattern:b().min(1),createdAt:b().min(1).optional()});I({sessionId:b().min(1),cwd:b().min(1),tool:Y("claude").or(b().min(1)).default("claude"),toolSessionId:b().optional(),label:b().optional(),model:b().optional(),permissionMode:b().optional(),effort:b().optional(),...lI,aiLabelGeneratedAt:b().optional(),permissionRules:J(tz).optional(),pinnedAt:W().int().nonnegative().nullable().optional(),archivedAt:W().int().nonnegative().nullable().optional(),pinSortOrder:W().int().nullable().optional(),unreadAt:b().min(1).nullable().optional(),iconKey:b().optional(),forkedFromSessionId:b().min(1).optional(),ephemeral:ge().optional(),deployId:b().min(1).optional(),ownerPersonaId:b().min(1).optional(),projectPath:b().min(1).optional(),appBuilderProject:b().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:b().min(1).optional(),creatorPrincipalId:b().min(1).optional(),creatorDisplayName:b().min(1).optional(),creatorFeishuUnionId:b().min(1).optional(),originOwnerPrincipalId:b().min(1).optional(),originOwnerPersonaId:b().min(1).optional(),dispatchedFromSessionId:b().min(1).optional(),shiftFiredFromSessionId:b().min(1).optional(),larkChatId:b().min(1).optional(),larkChatName:b().min(1).optional(),larkChatType:ve(["p2p","group"]).optional(),createdAt:b().min(1),updatedAt:b().min(1)});const Fn={seq:W().int().nonnegative().optional(),ts:b().optional(),uuid:b().optional()},nz=ve(WB),rz=I({readCount:W().int().nonnegative().optional(),searchCount:W().int().nonnegative().optional(),bashCount:W().int().nonnegative().optional(),editFileCount:W().int().nonnegative().optional(),linesAdded:W().int().nonnegative().optional(),linesRemoved:W().int().nonnegative().optional(),otherToolCount:W().int().nonnegative().optional()}),iz=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:J(b())}),sz=I({agentId:b().optional(),agentType:b().optional(),status:b().optional(),prompt:b().optional(),filePath:b().optional(),structuredPatch:J(iz).optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional(),toolStats:rz.optional()}).optional()}),oz=I({path:b(),content:b(),mtimeMs:W().optional()}),az=I({label:b().min(1),description:b().optional()}),uI=I({question:b().min(1),multiSelect:ge(),options:J(az).min(1)}),lz=["completed","interrupted"];_i("kind",[I({...Fn,kind:Y("session_init"),toolSessionId:b().optional()}),I({...Fn,kind:Y("thinking"),text:b(),partialId:b().optional()}),I({...Fn,kind:Y("text"),text:b(),partialId:b().optional()}),I({...Fn,kind:Y("user_text"),text:b(),meta:nz.optional(),taskId:b().optional(),parentToolUseId:b().optional(),sender:KB.optional()}),I({...Fn,kind:Y("tool_call"),toolUseId:b(),tool:b(),toolKind:b().optional(),input:Fi()}),I({...Fn,kind:Y("tool_result"),toolUseId:b(),output:Fi().optional(),error:b().optional(),toolResultExtra:sz.optional(),sourceToolAssistantUUID:b().optional(),askQuestionAnswers:Pr(b(),b()).optional()}),I({...Fn,kind:Y("attachment_memories"),memories:J(oz)}),I({...Fn,kind:Y("permission_request"),requestId:b(),tool:b(),input:Fi(),toolUseId:b().optional()}),I({...Fn,kind:Y("ask_user_question"),toolUseId:b(),questions:J(uI)}),I({...Fn,kind:Y("turn_end"),durationMs:W().int().nonnegative().optional(),reason:ve(lz).optional()}),I({...Fn,kind:Y("subagent_progress"),toolUseId:b(),agentId:b(),status:ve(["started","running","completed","failed"]),description:b().optional(),lastToolName:b().optional(),prompt:b().optional(),stats:I({durationMs:W().int().nonnegative().optional(),tokens:W().int().nonnegative().optional(),toolUseCount:W().int().nonnegative().optional()}).optional()}),I({...Fn,kind:Y("error"),message:b()}),I({...Fn,kind:Y("meta_update"),patch:XB}),I({...Fn,kind:Y("meta-text"),text:b(),metaSource:ve(["cc","owner"]).optional()})]);I({cwd:b().min(1).optional(),tool:b().optional(),label:b().optional(),aiLabel:b().optional(),model:b().optional(),permissionMode:b().optional(),effort:b().optional(),iconKey:b().optional(),forkedFromSessionId:b().min(1).optional(),ephemeral:ge().optional(),ownerPersonaId:b().min(1).optional(),projectPath:b().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});I({path:b().min(1),name:b().min(1),createdAt:b().datetime(),pinnedAt:W().optional()});I({path:b().min(1),pinnedAt:W().nullable()});I({path:b().min(1)});I({path:b().min(1).optional(),name:b().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});I({cwd:b().min(1),tool:b().min(1),toolSessionId:b().min(1),label:b().optional(),aiLabel:b().optional(),iconKey:b().optional(),createdAt:b().datetime(),updatedAt:b().datetime(),ownerPersonaId:b().min(1).optional()});I({originOnly:ge().optional(),ownerPersonaId:b().min(1).optional(),limit:W().int().positive().optional(),offset:W().int().nonnegative().optional()});I({sessionId:b().min(1)});I({sessionId:b().min(1),patch:I({label:b().optional(),model:b().optional(),permissionMode:b().optional(),effort:b().optional(),cwd:b().optional(),iconKey:b().optional(),ephemeral:Y(!1).optional()})});I({id:b().min(1),text:b(),queuedAt:W(),senderDisplayName:b().optional()});I({sessionId:b().min(1),text:b(),queueWhileRunning:ge().optional()});I({sessionId:b().min(1),id:b().min(1).optional()});I({sessionId:b().min(1),userMessageId:b().min(1),dryRun:ge().optional()});I({canRewind:ge(),error:b().optional(),filesChanged:J(b()).optional(),insertions:W().int().nonnegative().optional(),deletions:W().int().nonnegative().optional()});I({sessionId:b().min(1),userMessageId:b().min(1)});const cz=I({oldStart:W().int().nonnegative(),oldLines:W().int().nonnegative(),newStart:W().int().nonnegative(),newLines:W().int().nonnegative(),lines:J(b())}),uz=I({filePath:b().min(1),hunks:J(cz),insertions:W().int().nonnegative(),deletions:W().int().nonnegative(),status:ve(["modified","added","deleted"]).optional()});I({canRewind:ge(),error:b().optional(),files:J(uz),totalInsertions:W().int().nonnegative(),totalDeletions:W().int().nonnegative()});I({userMessageIds:J(b())});I({sessionId:b().min(1),toolSessionId:b().min(1)});I({cwd:b().min(1),toolSessionId:b().min(1),messageUuid:b().min(1),targetCwd:b().min(1).optional()});I({forkedToolSessionId:b().min(1),forkedFilePath:b().min(1)});I({sessionId:b().min(1),toolSessionId:b().min(1),jsonlPath:b().optional()});I({sessionId:b().min(1),afterSeq:W().int().min(-1)});I({sessionId:b().min(1),permissionRequestId:b().min(1),allow:ge(),permanent:ge().optional(),pattern:b().optional()});I({projectPath:b().min(1)});I({sessionId:b().min(1),limit:W().int().positive().max(5e3).optional(),offset:W().int().nonnegative().optional(),slim:ge().optional()});I({cwd:b().min(1),toolSessionId:b().min(1)});I({cwd:b().min(1),toolSessionId:b().min(1),subagentId:b().min(1)});I({cwd:b().min(1).optional(),path:b().optional(),showHidden:ge().optional()});I({cwd:b().min(1),path:b().min(1)});I({cwd:b().min(1),tool:b().optional()});I({name:b().min(1),source:ve(VB),path:b().optional(),description:b().optional(),plugin:b().optional()});const dz=I({name:b().min(1),source:ve(qB),path:b().optional(),description:b().optional(),whenToUse:b().optional(),plugin:b().optional()});I({cwd:b().min(1),tool:b().optional()});I({agents:J(dz)});I({sessionId:b().optional()});I({sessionId:b().min(1).optional()});I({sessionId:b().min(1),pinned:ge()});I({sessionId:b().min(1),archived:ge()});I({query:b().min(1),sessionIds:J(b().min(1)),limit:W().int().positive().max(50).optional()});const hz=I({sessionId:b().min(1),snippet:b()});I({type:Y("session:searchContent"),matches:J(hz)});I({type:Y("peerSession:upsert:ok")});I({sessionId:b().min(1)});I({type:Y("peerSession:remove:ok")});I({orderedIds:J(b().min(1)).min(1)});I({cwd:b().min(1)});I({isGitRoot:ge(),gitRoot:b().nullable()});I({cwd:b().min(1)});I({branch:b().nullable()});I({cwd:b().min(1)});I({branches:J(b()),head:b().nullable()});const fz=I({cwd:b().min(1),updatedAt:b().min(1)});I({dirs:J(fz)});I({type:Y("session:question"),sessionId:b().min(1),toolUseId:b().min(1),requestId:b().min(1),questions:J(uI).min(1)});I({type:Y("session:question:cleared"),sessionId:b().min(1),toolUseId:b().min(1),answers:Pr(b(),b()).optional()});I({sessionId:b().min(1),toolUseId:b().min(1),answers:Pr(b(),b())});I({ok:Y(!0)});I({sessionId:b().min(1),toolUseId:b().min(1)});I({ok:Y(!0)});const dI=I({name:b().min(1),version:b().min(1),instanceId:b().min(1),deviceLabel:b().transform(e=>e.trim().slice(0,64)).optional()});I({type:Y("auth"),token:b().min(1),scheme:Y("bearer").optional(),clientInfo:dI.optional()});I({type:Y("auth:ok"),version:b().min(1).optional(),protocolVersion:W().int().nonnegative().optional()});const pz=I({clientId:b().min(1),connectedAt:W().int().nonnegative(),self:ge(),clientInfo:dI.optional()});I({type:Y("device:connections:ok"),connections:J(pz)});I({type:Y("tunnel:ready"),url:b().min(1),subdomain:b().min(1)});I({type:Y("tunnel:exited"),code:W().int().nullable(),subdomain:b().nullable(),url:b().nullable()});I({type:Y("tunnel:unavailable"),reason:b().min(1),failedAt:b().min(1)});const mz=I({sessionId:b().min(1),status:GB,freshSpawn:ge(),pendingPermissionRequestIds:J(b().min(1)),pendingQuestionToolUseIds:J(b().min(1))});I({type:Y("info"),version:b(),protocolVersion:W(),hostname:b(),os:b(),tools:J(I({id:b(),available:ge()})),runningSessions:J(mz),tokenRole:ve(D6).optional(),isLoopback:ge().optional(),httpBaseUrl:b().optional(),httpToken:b().optional(),daemonSource:ve(["ota","packaged"]).optional(),globalCliVersion:b().nullable().optional()});const gz=6173,vz=6272,_l=/^[a-z][a-z0-9-]{0,39}$/,wu=I({name:b().regex(_l,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:W().int().min(gz).max(vz),createdAt:b().datetime(),devCommand:b().min(1),prodUrl:b().url().optional(),readyPattern:b().optional(),publishJob:I({jobId:b().min(1),stage:ve(["build","deploy","verify"]),startedAt:W().int().nonnegative()}).optional()}),xz=["install-pending","installing","starting-dev-server","running","stopped","failed"],hI=ve(xz),Z_=wu.extend({isRunning:ge(),boundSessionId:b().nullable(),stage:hI.optional(),stageReason:b().optional(),publishJob:I({jobId:b().min(1),stage:ve(["build","deploy","verify"]),startedAt:W().int().nonnegative(),status:ve(["in-flight","interrupted"])}).optional()});I({}).strict();I({projects:J(Z_)}).strict();I({sessionId:b().min(1)}).strict();I({project:Z_.nullable()}).strict();I({sessionId:b().min(1),name:b().min(1)}).strict();I({project:wu}).strict();I({name:b()}).strict();I({}).strict();I({name:b(),newPort:W().int()}).strict();I({project:wu}).strict();I({name:b().regex(_l),url:b().url()}).strict();I({project:wu}).strict();I({sessionId:b().min(1),force:ge().optional()}).strict();I({project:wu}).strict();const _z=["installing","failed"];I({sessionId:b().min(1),stage:ve(_z),reason:b().optional()}).strict();I({ok:Y(!0)}).strict();I({sessionId:b().min(1)}).strict();I({ok:Y(!0)}).strict();I({type:Y("appBuilder:project-updated"),project:Z_,stage:hI,stageReason:b().optional()}).strict();I({name:b().regex(_l)});I({jobId:b().min(1),status:ve(["started","already-publishing"])}).strict();I({name:b().regex(_l)});I({ok:Y(!0)}).strict();I({type:Y("appBuilder:publish-progress"),name:b().regex(_l),jobId:b().min(1),stage:ve(["build","deploy","verify"]),status:ve(["started","completed"])}).strict();I({type:Y("appBuilder:publish-failed"),name:b().regex(_l),jobId:b().min(1),stage:ve(["build","deploy","verify","unknown"]),errorSummary:b()}).strict();I({});I({method:b().min(1).optional()});const yz=["allowed","conditional","denied"],bz=ve(yz),wz=I({name:b().min(1),status:bz,description:b().min(1),args:J(I({name:b(),required:ge()})).nullable(),argsSchema:Pr(Fi()).optional(),reason:b().optional()});I({type:Y("meta:methods"),methods:J(wz)});const jw=1,Sz=["daemon","main","renderer"],kz=ve(Sz),Cz=["debug","info","warn","error"],Ez=ve(Cz);I({ts:W().int(),source:kz,level:Ez,msg:b(),ownerPrincipalId:b(),deviceId:b(),appVersion:b(),daemonVersion:b().optional(),os:b(),meta_json:b().optional(),sessionId:b().optional()});I({v:Y(1),visitorId:b().min(1),displayName:b(),provider:b(),iat:W(),exp:W()});const Nz=I({visitorId:b(),displayName:b(),avatarUrl:b().optional(),provider:b(),firstSeen:W(),lastSeen:W()});I({visitors:J(Nz)});const Tz=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,fI=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,Iz="clawd-dispatch-task",Pz="clawd-dispatch-result",Lw=120;function Rz(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?Iz:Pz,i=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let s=i.exec(e);s!==null;s=i.exec(e))t.push({at:s.index,block:Az(n,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Az(e,t,n){var c;const r=zz(t),i=x0(Bz(jm(n,"detail")??n)),s=(c=jm(n,"brief"))==null?void 0:c.trim(),o=s&&s.length>0?x0(s):Mz(i),a=r.round!==void 0?Number.parseInt(r.round,10):void 0,l=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&a!==void 0&&Number.isFinite(a)?{round:a}:{},...e==="result"&&(l==="success"||l==="failure")?{status:l}:{},brief:o,briefIsDerived:!(s&&s.length>0),detail:i,filePaths:Oz(jm(n,"files"))}}function Mz(e){const t=e.split(/\n\s*\n/).map(r=>r.trim()).find(r=>r.length>0);if(!t)return"";const n=t.replace(/\s+/g," ");return n.length>Lw?`${n.slice(0,Lw)}…`:n}const jz="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",Lz=new RegExp(`<\\\\(\\\\*)(/?)(${jz})\\b`,"g");function Dz(e){return x0(e)}function x0(e){return e.replace(Lz,"<$1$2$3")}function jm(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function Oz(e){return e?e.split(`
|
|
96
96
|
`).map(t=>t.trim()).filter(t=>t.startsWith("- ")).map(t=>t.slice(2).trim()).filter(t=>t.length>0):[]}function Bz(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function zz(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=$z(r[2]??"");return t}function $z(e){return e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}const Fz="codex-cloud";function Hz(e){return e==="codex"||e===Fz}const Uz=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let Ni=null;function Wz(){if(Ni!==null)return Ni;if(typeof window>"u")return Ni=!1,!1;if(Uz.has(window.location.hostname)||window.location.protocol==="file:")return Ni=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){Ni=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{Ni=sessionStorage.getItem("debug")==="1"}catch{Ni=!1}return Ni}function Ae(e,...t){Wz()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function pd(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const Vz=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},qz=new Set(["auth:ok","pong","error"]),Dw=new Set(sI.filter(e=>!qz.has(e)));let Kz=0;const Ow=()=>`r${++Kz}`;function Gz(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??Vz;let u=null,d=!1,f=0,p=null,m=null,v=null,w=null,x=!1,_="disconnected";const y=new Map,S=new Map;let C=null;const k=(z,E)=>{var H;z==="ready"&&(C=E),(H=S.get(z))==null||H.forEach(q=>{try{q(E)}catch{}})},N=z=>{_!==z&&(_=z,k("status",z))},T=(z,E)=>{const H=S.get(z)??new Set;if(H.add(E),S.set(z,H),z==="ready"&&C!==null)try{E(C)}catch{}return()=>H.delete(E)},D=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),w&&(clearTimeout(w),w=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},O=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Ow()}))},o),P()},R=z=>{for(const[,E]of y)clearTimeout(E.timer),E.reject(new Error(z));y.clear()},A=[],M=()=>{if(A.length===0)return;const z=A.splice(0);for(const E of z)(u==null?void 0:u.readyState)===1&&!x?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},L=z=>{if(A.length===0)return;const E=A.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(z))},$=()=>{if(d)return;const z=c(f);if(z<0){L("connection closed: not reconnecting");return}k("daemon:reconnecting",{attempt:f+1,nextDelayMs:z,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,B()},z)},F=z=>{P();const E=String(z.type??"");if(E==="auth:ok"){Ae("daemon-client","auth:ok received → connected",{url:t}),w&&(clearTimeout(w),w=null),x=!1,f=0,N("connected"),k("daemon:connected",{url:t}),O(),M();return}if(E==="pong")return;if(E==="ready"){const q=Number(z.protocolVersion??-1);q!==jw&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:jw}),k("ready",z);return}const H=z.requestId;if(typeof H=="string"&&y.has(H)){const q=y.get(H);if(y.delete(H),clearTimeout(q.timer),E==="error"){const j=String(z.code??"ERR"),re=String(z.message??"unknown");q.reject(new Error(`${j}: ${re}`))}else Dw.has(E)&&k(E,z),q.resolve(z);return}Dw.has(E)&&k(E,z)},B=()=>{p&&(clearTimeout(p),p=null),Ae("daemon-client","connect →",{url:t,token:pd(n),attempt:f}),N("connecting");let z;try{z=new WebSocket(t)}catch(E){N("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=z,x=!!n,z.onopen=()=>{if(z!==u){Ae("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Ae("daemon-client","onopen → send auth frame",{token:pd(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),z.send(JSON.stringify(E)),w=setTimeout(()=>{try{z.close(4001,"auth handshake timeout")}catch{}},l)}else Ae("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,N("connected"),k("daemon:connected",{url:t}),O(),M()},z.onclose=E=>{if(z!==u){Ae("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Ae("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:x,manualStop:d}),D(),R(`connection closed: ${H}`),u=null,E.code===4401?N("revoked"):N("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){L(`connection closed: ${H}`);return}d?L(`connection closed: ${H}`):$()},z.onerror=()=>{},z.onmessage=E=>{if(z!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,B()},stop(){d=!0,p&&(clearTimeout(p),p=null),D();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,R("shutdown"),L("shutdown"),N("disconnected")},switchProfile(z){Ae("daemon-client","switchProfile →",{url:z.url,token:pd(z.authToken)},"prev:",{url:t,token:pd(n)}),t=z.url,n=z.authToken,z.selfIdentity!==void 0&&(r=z.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),D(),R("switch profile"),L("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,B()},request(z,E){return new Promise((H,q)=>{const j=Ow(),re=setTimeout(()=>{y.delete(j);const K=A.findIndex(_e=>_e.timer===re);K>=0&&A.splice(K,1),q(new Error(`request timeout: ${z}`))},s),ie=()=>{y.set(j,{resolve:K=>H(K),reject:q,timer:re}),u.send(JSON.stringify({...E,type:z,requestId:j}))};(u==null?void 0:u.readyState)===1&&!x?ie():d||u==null&&p==null?(clearTimeout(re),q(new Error("NOT_CONNECTED"))):A.push({doSend:ie,reject:q,timer:re})})},on:T,get isOpen(){return(u==null?void 0:u.readyState)===1&&!x},get url(){return t},getStatus(){return _}}}function Yz(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=t.slice(n+1),o=new URLSearchParams(i).get("token")??void 0;return{url:r,token:o??void 0}}function Xz(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function Qz(e){return e?{id:e.id,mode:e.mode,url:e.url,token:Xz(e.token),name:e.name}:null}function md(e){return e?Array.isArray(e)?e.map(Qz):{_notArray:typeof e,_value:e}:null}function Bw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const Zz="ws://127.0.0.1:18790",zw="daemon:profiles",$w="daemon:active-profile-id";function Jz(){return Math.random().toString(36).slice(2,10)}function e$(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function pI(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Ae("profile-store","persist →",md(t.profiles),"active:",t.activeId),await e.kv.set(zw,t.profiles),await e.kv.set($w,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(zw);c=Bw(d)}catch{c=null}let u=null;try{const d=await e.kv.get($w);u=Bw(d)??null}catch{u=null}if(Ae("profile-store","ensureLoaded read kv →","profiles:",md(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(e$),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,Ae("profile-store","ensureLoaded → use kv profiles",md(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:Zz}],activeId:"default"},Ae("profile-store","ensureLoaded → fallback synthesized default (NO token)",md(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var w;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const x=Yz(c);c=x.url,!u&&x.token&&(u=x.token)}const d=l.id?t.profiles.find(x=>x.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??Jz(),m={id:p,name:((w=l.name)==null?void 0:w.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(x=>x.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const Fw="clawd.client-instance-id";let t$={name:"clawd-web",version:"unknown"};function n$(){let e=null;try{e=localStorage.getItem(Fw),e||(e=crypto.randomUUID(),localStorage.setItem(Fw,e))}catch{e=e??crypto.randomUUID()}return{...t$,instanceId:e}}function Hw(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const mI=g.createContext(null);function r$({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=pI(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return Ae("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Hw(a.token)}),{client:Gz({url:a.url,authToken:a.token,clientInfo:n$()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){Ae("daemon-context","subscribe → no active profile, skip switchProfile");return}Ae("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Hw(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx(mI.Provider,{value:n,children:t}):null}function yi(){const e=g.useContext(mI);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function i$(){const e=yi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Ae("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}function s$(){const e=yi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i;s.version!==void 0&&n(s.principalKind==="guest"?"guest":"owner")}),[e]),t}const gI=g.createContext(null);function o$({cache:e,children:t}){return g.createElement(gI.Provider,{value:e},t)}function zo(){const e=g.useContext(gI);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function mi(e){const t=zo(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const vI={actionsLevel:"none",httpBaseUrl:null,httpToken:null},xI=g.createContext(vI);function lp(){return g.useContext(xI)}function a$(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:vI}function l$(){const e=mi("daemon-info");return g.useMemo(()=>a$(e),[e])}function c$({children:e}){const t=l$();return Ke.createElement(xI.Provider,{value:t},e)}function u$(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function d$(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function h$(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function f$(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of sI)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}function _I(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const p$=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:_I(e)});function m$(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>p$(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function g$(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Jc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{},queued:[]};function Lm(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function yI(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Jc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Lm(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:queue":return!r||t.sessionId!==r?e:{...e,queued:t.items};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Lm(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Lm(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Jc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const v$="session/";function x$(e){return{sid:e.slice(v$.length)}}const _$=new Set(oI);function bI(e){return _$.has(e)}function Uw(e){return bI(e)?e:"idle"}function y$(e,t){return{start(n){const{sid:r}=x$(n);let i=!1,s=-1;const o=f=>{t(n,p=>yI(p??Jc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],w=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:w}),s=w;else{const x=m.bufferStartSeq??0,_=w<p||x>p+1;o({type:_?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:w}),s=Math.max(s,w)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Uw(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;Ae("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!bI(m.status)){Ae("session-events","push session:status drop",{sid:r,status:m.status});return}Ae("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;Ae("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="session:queue"){const m=p;if(m.sessionId!==r)return;Ae("session-events","push session:queue",{sid:r,count:m.items.length}),o({type:"session:queue",sessionId:m.sessionId,items:m.items})}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Uw(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const b$=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function w$(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{b$.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function S$(){return{start(){return()=>{}}}}function k$(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function C$(e){const t=f$(e),n=h$();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,m$(t,i)),n.register(/^sessions$/,g$(t,i)),n.register(/^session\//,y$(t,i)),n.register(/^personas$/,k$(t,i)),n.register(/^persona-detail\//,S$()),n.register(/^daemon-info$/,w$(t,i));const s=d$({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class J_{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}projectList(){return this.client.request("project:list")}projectCreate(t){return this.client.request("project:create",{...t.path?{path:t.path}:{},...t.name?{name:t.name}:{}})}projectPatch(t){return this.client.request("project:patch",t)}projectReveal(t){return this.client.request("project:reveal",{path:t})}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n,r){return this.client.request("session:send",{sessionId:t,text:n,...r!=null&&r.queueWhileRunning?{queueWhileRunning:!0}:{}})}sessionDequeue(t,n){return this.client.request("session:dequeue",{sessionId:t,...n?{id:n}:{}})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}searchSessionContent(t){return this.client.request("session:searchContent",t)}archiveSession(t,n){return this.client.request("session:archive",{sessionId:t,archived:n})}markSessionRead(t){return this.client.request("session:markRead",{sessionId:t})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}larkBotBindManual(t,n,r){return this.client.request("larkBot:bindManual",{personaId:t,appId:n,appSecret:r})}larkBotUnbind(t){return this.client.request("larkBot:unbind",{personaId:t})}larkBotStatus(t){return this.client.request("larkBot:status",{personaId:t})}toolsProbe(){return this.client.request("tools:probe",{})}sessionExternalScan(){return this.client.request("session:externalScan",{})}sessionImportExternal(t){return this.client.request("session:importExternal",t)}onboardingComplete(){return this.client.request("onboarding:complete",{})}onboardingIosInterest(){return this.client.request("onboarding:iosInterest",{})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}deployStart(t,n){return this.client.request("deploy:start",{personaId:t,...n?{mode:n}:{}})}deployGet(t){return this.client.request("deploy:get",{personaId:t})}deployPatch(t,n){return this.client.request("deploy:patch",{personaId:t,patch:n})}deployPutSecret(t,n,r){return this.client.request("deploy:putSecret",{personaId:t,name:n,values:r})}deployRerunJob(t,n){return this.client.request("deploy:rerunJob",{personaId:t,jobId:n})}deployRelease(t){return this.client.request("deploy:release",{personaId:t})}cloudConnectorsList(t){return this.client.request("cloud:connectors:list",{personaId:t})}cloudConnectorFill(t,n,r){return this.client.request("cloud:connectors:fill",{personaId:t,name:n,values:r})}channelList(){return this.client.request("channel:list")}channelCreate(t){return this.client.request("channel:create",t)}channelUpdate(t){return this.client.request("channel:update",t)}channelDelete(t){return this.client.request("channel:delete",t)}topicList(t){return this.client.request("topic:list",t)}topicGet(t){return this.client.request("topic:get",t)}topicCreate(t){return this.client.request("topic:create",t)}topicClose(t){return this.client.request("topic:close",t)}topicRename(t){return this.client.request("topic:rename",t)}topicDelete(t){return this.client.request("topic:delete",t)}personaDispatchList(t){return this.client.request("personaDispatch:list",t)}githubStatus(){return this.client.request("github:status")}githubPrList(t){return this.client.request("github:prList",{role:t})}githubPrDetail(t){return this.client.request("github:prDetail",{...t})}githubPrMerge(t){return this.client.request("github:prMerge",{...t})}githubPrComment(t){return this.client.request("github:prComment",{...t})}githubPrSetReady(t){return this.client.request("github:prSetReady",{...t})}githubCollaborators(t){return this.client.request("github:collaborators",{...t})}githubPrRequestReviewers(t){return this.client.request("github:prRequestReviewers",{...t})}}function E$(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion,daemonSource:c.daemonSource,globalCliVersion:c.globalCliVersion,onboardingCompletedAt:c.onboardingCompletedAt}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0,daemonSource:u.kind==="connected"?u.daemonSource:void 0,globalCliVersion:u.kind==="connected"?u.globalCliVersion:void 0,onboardingCompletedAt:u.kind==="connected"?u.onboardingCompletedAt:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function N$(e){const t=zo(),n=mi(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function yl(){const e=yi();return g.useMemo(()=>new J_(e),[e])}function wI(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,tool:e.tool,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt,...e.cloud?{cloud:e.cloud}:{}}}function SI(){const e=zo(),t=yl(),n=mi("personas")??[],r=g.useMemo(()=>n.map(s=>wI(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:mi("personas")!==void 0,refresh:i}}function kI(e){const{raw:t}=SI(),n=zo(),r=yl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?wI(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function T$(e){const t=yl(),n=zo(),r=e?`persona-detail/${e}`:"",i=mi(r),s=g.useCallback(async()=>{const o={personality:"",personalityLocal:"",personalityManaged:!1,skills:[],plugins:[],sandboxSettings:null,codexSandbox:null};if(!e)return o;let a=null;try{a=await t.personaGet(e)}catch(c){Ae("personas","personaGet failed → empty detail",{personaId:e,err:c}),a=null}const l=a?{personality:a.personality??"",personalityLocal:a.personalityLocal??"",personalityManaged:a.personalityManaged??!1,skills:a.skills??[],plugins:a.plugins??[],sandboxSettings:a.sandboxSettings??null,codexSandbox:a.codexSandbox??null}:o;return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",personalityLocal:(i==null?void 0:i.personalityLocal)??"",personalityManaged:(i==null?void 0:i.personalityManaged)??!1,skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,codexSandbox:(i==null?void 0:i.codexSandbox)??null,loaded:i!==void 0,refresh:s}}function CI(){const e=zo(),t=yl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function I$(){const e=yl(),t=CI();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function P$(){const e=yl(),t=CI();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Ww="clawd:sidebar:tree-collapsed";function R$(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function A$(e){const t=R$(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function M$(){const e=P_(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(Ww);if(l)return;n(A$(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Ww,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const ey=g.createContext(null);function j$(){const e=g.useContext(ey);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
|
|
97
97
|
* @license lucide-react v0.577.0 - ISC
|
|
98
98
|
*
|
|
@@ -596,4 +596,4 @@ Minimum version required to store current data is: `+s+`.
|
|
|
596
596
|
|
|
597
597
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
598
598
|
|
|
599
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},goe="DialogDescriptionWarning",voe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${x4(goe).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},xoe=s4,_oe=l4,_4=c4,y4=u4,b4=h4,w4=p4,yoe=g4;const N1=xoe,boe=_oe,S4=g.forwardRef(({className:e,...t},n)=>h.jsx(_4,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));S4.displayName=_4.displayName;const qp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(boe,{children:[h.jsx(S4,{}),h.jsxs(y4,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(yoe,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Rr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));qp.displayName=y4.displayName;const Kp=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});Kp.displayName="DialogHeader";const T1=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-row justify-end gap-2",e),...t});T1.displayName="DialogFooter";const Gp=g.forwardRef(({className:e,...t},n)=>h.jsx(b4,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));Gp.displayName=b4.displayName;const k4=g.forwardRef(({className:e,...t},n)=>h.jsx(w4,{ref:n,className:ne("text-sm text-text-300",e),...t}));k4.displayName=w4.displayName;function woe({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onLoadPersonalityLocal:a,onSavePersonalityLocal:l,hasPersonalityLocal:c=!1,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,larkBot:m}){const[v,w]=g.useState(!1),[x,_]=g.useState(!1),y=v||x,S=Ke.useRef(u);g.useEffect(()=>{S.current=u}),g.useEffect(()=>{var k;(k=S.current)==null||k.call(S,y)},[y]);const C=()=>{y&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(hF,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Rr,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(P8,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(T8,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(ny,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(ry,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),m?h.jsxs(h.Fragment,{children:[h.jsx(Coe,{...m}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(h2,{onLoad:s,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:w,initialPersonality:d,readOnly:p||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?p?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||c)&&a?h.jsx(h2,{onLoad:a,...l?{onSave:l}:{},onDirtyChange:_,readOnly:p,title:p?"补充设定":"你的补充",hint:p?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的 sub-session 生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Eoe,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Noe,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Toe,{plugins:e.plugins??[]})]})]})]}):null}function d2({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:i="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[s,o]=g.useState(null);return g.useEffect(()=>{let a=!1;return zu.toDataURL(e,{width:240,margin:1}).then(l=>{a||o(l)}).catch(()=>{a||o(null)}),()=>{a=!0}},[e]),h.jsx(N1,{open:!0,onOpenChange:a=>a||n==null?void 0:n(),children:h.jsxs(qp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:a=>a.preventDefault(),onEscapeKeyDown:a=>a.preventDefault(),children:[h.jsx(Kp,{children:h.jsx(Gp,{children:r})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s?h.jsx("img",{src:s,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:i}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const Soe={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},koe=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Coe({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i,onUpgrade:s}){const[o,a]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(""),[f,p]=g.useState(""),[m,v]=g.useState(null),w=k=>{k&&(a(!0),c(null),k().catch(N=>c(N instanceof Error?N.message:String(N))).finally(()=>a(!1)))},x=()=>{v(null),w(t)},_=!o&&!!u&&!!f,y=()=>{!_||!r||w(()=>r({appId:u,appSecret:f}))},S=Pu(y),C=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(cp,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:o||e.state==="provisioning",onClick:x,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!m?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:Soe[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[koe.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:o,onClick:x,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>v(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(d2,{qrUrl:e.qrUrl,busy:o,onCancel:n?()=>w(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:u,onChange:k=>d(k.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:f,onChange:k=>p(k.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:y,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:o?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[h.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),s?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(s),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?h.jsx(d2,{qrUrl:e.upgradeQrUrl,busy:o,onCancel:n?()=>w(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,l?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:l}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Eoe({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx($d,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx($d,{label:"沙箱启用",value:jg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx($d,{label:"沙箱内自动放行 Bash",value:jg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx($d,{label:"允许非沙箱命令",value:jg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Xl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Xl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Xl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Xl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Xl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function jg(e){return e===!0?"是":e===!1?"否":"—"}function $d({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Xl({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function Noe({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function Toe({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function h2({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1,title:s,hint:o,placeholder:a,testIdPrefix:l}){const c=r!==void 0,[u,d]=g.useState(c),[f,p]=g.useState(c?r:""),[m,v]=g.useState(c?r:""),[w,x]=g.useState(null),[_,y]=g.useState(!1),[S,C]=g.useState(null),k=Ke.useRef(e),N=Ke.useRef(t),T=Ke.useRef(n);Ke.useEffect(()=>{k.current=e,N.current=t,T.current=n});const D=Ke.useCallback(()=>{d(!1),x(null),k.current().then(M=>{p(M),v(M),d(!0)}).catch(M=>{x(M instanceof Error?M.message:String(M))})},[]);Ke.useEffect(()=>{c||D()},[c,D]);const P=!i&&u&&m!==f;Ke.useEffect(()=>{i||T.current(P)},[P,i]);const O=()=>{N.current&&(y(!0),C(null),N.current(m).then(()=>{p(m),y(!1)}).catch(M=>{C(M instanceof Error?M.message:String(M)),y(!1)}))},R=()=>{v(f),C(null)},A=Pu(()=>{!P||_||O()},()=>{!P||_||R()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${l}-section`,children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:s}),w?h.jsxs("div",{"data-testid":`${l}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",w]}),h.jsx("button",{type:"button",onClick:D,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,S?h.jsxs("div",{"data-testid":`${l}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",S]}):null,h.jsx("textarea",{"data-testid":`${l}-textarea`,value:m,onChange:M=>v(M.target.value),...A,readOnly:i,disabled:!i&&(!u||_),placeholder:u?a??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?h.jsx("p",{className:"text-[10px] text-text-400",children:o}):i?null:h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),u&&P?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:R,disabled:_,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:O,disabled:_,"data-testid":`${l}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:_?"保存中…":"保存"})]}):null]})}const Ioe={state:"unbound",groups:[]};function Poe(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let c=!1;r(null);const u=async()=>{try{const p=await e.request("larkBot:status",{personaId:t});c||r(p)}catch{c||r(Ioe)}};u();const d=e.on("larkBot:state",p=>{const m=p;if(m.personaId!==t)return;const{personaId:v,...w}=m;r(w)}),f=e.on("daemon:connected",()=>{u()});return()=>{c=!0,d(),f()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async c=>{e&&await e.request("larkBot:bindManual",{personaId:t,...c})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:upgrade",{personaId:t})},[e,t]),l=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:l,upgrade:a}}function Roe(e,t="owner"){var k;const{persona:n}=kI(e),r=T$(e),i=I$(),s=P$(),{httpBaseUrl:o}=lp(),a=yi(),l=Poe(t==="guest"?null:a,e),{capabilities:c}=x1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((N,T)=>{i(e,T).catch(D=>{Ae("persona",`${N} failed`,D)})},[i,e]),f=g.useCallback(N=>d("togglePublic",{public:N}),[d]),p=g.useCallback(async N=>{await i(e,{codexSandbox:{network:N}}),await r.refresh()},[i,e,r]),m=g.useCallback(N=>d("changeTool",{tool:N}),[d]),v=g.useCallback(N=>d("changeModel",{model:N}),[d]),w=g.useCallback(N=>d("changeEffort",{effort:N}),[d]),x=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(N=>{Ae("persona","delete failed",N)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),y=g.useCallback(async N=>{await i(e,{personality:N}),await r.refresh()},[i,e,r]),S=g.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),C=g.useCallback(async N=>{await i(e,{personalityLocal:N}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:m,changeModel:v,changeEffort:w,togglePublic:f,guestNetwork:((k=r.codexSandbox)==null?void 0:k.network)??!1,toggleGuestNetwork:p,remove:x,loadPersonality:_,savePersonality:y,loadPersonalityLocal:S,savePersonalityLocal:C}}function Aoe({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=Roe(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(woe,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings,personalityManaged:u.personalityManaged},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onLoadPersonalityLocal:l.loadPersonalityLocal,hasPersonalityLocal:u.personalityLocal!=="",onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,onSavePersonalityLocal:l.savePersonalityLocal,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind,onUpgrade:l.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const Moe={resolve:()=>{}},joe=g.createContext(Moe);function Loe(){return g.useContext(joe)}function Doe(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function Ooe(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function I1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return Ooe(s.url,Doe(t.url))}async function f2(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await I1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function Boe(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const zoe={...Us,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function $oe(e){const t=e.split("/");return t[t.length-1]||e}function C4({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:$oe(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(tl,{remarkPlugins:[nl],components:zoe,children:i})}):null})]})}function Foe({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:`${a1} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:h.jsx(C4,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(B8,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Rr,{className:"h-4 w-4"})})]})})}):null}function Hoe({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const Uoe=6173,Woe=6182;function Voe({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Uoe;v<=Woe;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(N1,{open:e,onOpenChange:t,children:h.jsxs(qp,{className:"max-w-md",children:[h.jsxs(Kp,{children:[h.jsxs(Gp,{children:["改端口 · ",n]}),h.jsxs(k4,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(T1,{children:[h.jsx(hi,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(hi,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const p2=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function qoe({currentStage:e,onCancel:t}){const n=p2.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[p2.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(up,{className:"size-3.5"}):o?h.jsx(Ln,{className:"size-3.5 animate-spin"}):h.jsx(TI,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Koe={build:"构建",deploy:"部署",verify:"验证"};function Goe({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(tu,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Koe[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Yoe={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Xoe({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ji,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",Yoe[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Rr,{className:"size-3.5"})})]})}const m2={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Qoe({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var x,_;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,w=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[w?h.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${w}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(eu,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(Ty,{children:[h.jsx(Iy,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(uF,{className:"size-3.5"})})}),h.jsxs(Sp,{align:"end",children:[h.jsx(Mi,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Mi,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Xoe,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(qoe,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(Goe,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Zoe,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(g2,{label:"等 tunnel 起来…",step:"-"}):h.jsx(g2,{label:m2[m].label,step:m2[m].step})}),h.jsx(Voe,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function g2({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ln,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Zoe({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ji,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function Joe({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(N1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(qp,{className:"max-w-lg",children:[h.jsx(Kp,{children:h.jsx(Gp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(T1,{children:[h.jsx(hi,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(bl,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(dp,{className:"size-3.5"}),"复制"]})}),h.jsx(hi,{onClick:t,children:"关闭"})]})]})})}function eae(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const v2=4;function tae({children:e,onHeightChange:t}){const n=g.useRef(null),[r,i]=g.useState(0);return g.useEffect(()=>{const s=n.current;if(!s)return;const o=()=>i(s.offsetHeight>0?s.offsetHeight+v2*2:0);if(o(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(o);return a.observe(s),()=>a.disconnect()},[]),g.useEffect(()=>{t==null||t(r)},[r,t]),h.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:h.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:v2},children:e})})}const nae=250;function rae(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function iae({agents:e}){var a,l,c;const[t,n]=g.useState(!1);if(e.length===0)return null;const r=e.length===1?e[0]:null,i=r?r.description:`${e.length} 个后台任务`,s=r?rae((l=(a=r.progress)==null?void 0:a.stats)==null?void 0:l.durationMs):null,o=r?(c=r.progress)==null?void 0:c.lastToolName:null;return h.jsxs("div",{"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?h.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:h.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:nae},children:e.map(u=>h.jsx(qA,{expandable:!1,description:u.description,input:u.input,output:u.output,...u.error!==void 0?{error:u.error}:{},pending:u.pending,notifications:u.notifications,...u.toolResultExtra?{toolResultExtra:u.toolResultExtra}:{},...u.progress?{progress:u.progress}:{}},u.toolUseId))})}):null,h.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(u=>!u),className:ne("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[h.jsx(Ln,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),s?h.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:s}):null,o?h.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",o]}):null,h.jsx(NI,{className:ne("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const sae={closeTrailing:!1},oae={closeTrailing:!0};function aae(e){return e?sae:oae}function lae({session:e,api:t,onPromoteQuickAsk:n}){const r=k5(e.sessionId);return h.jsx(P1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function cae({state:e,chat:t,extras:n}){var T;const r=mi("daemon-info"),i=yi(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(D=>c(D.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(D=>f(D.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const O=P;O!=null&&O.project&&(O.project.name===a&&c(O.project),f(R=>{const A=R.findIndex(L=>L.name===O.project.name);if(A<0)return[...R,O.project];const M=R.slice();return M[A]=O.project,M}))}),[i,a]);const{host:m,scheme:v}=eae(i.url,r==null?void 0:r.tunnelUrl),[w,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const D=i.on("appBuilder:publish-progress",O=>{const R=O;!R||R.name!==a||R.status==="started"&&x(R.stage)}),P=i.on("appBuilder:publish-failed",O=>{const R=O;!R||R.name!==a||(x(void 0),y({stage:R.stage}))});return()=>{D(),P()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[S,C]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(D){C({title:"发布请求失败",message:(D==null?void 0:D.message)??String(D)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(Hoe,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Qoe,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(D=>D.port),onUpdatePort:async D=>{await s.appBuilderUpdateProjectPort(a,D),p()},publishSlot:k,publishInFlightStage:w,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(D){C({title:"取消发布失败",message:(D==null?void 0:D.message)??String(D)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(D){C({title:"重新发布失败",message:(D==null?void 0:D.message)??String(D)})}},publishFailureBanner:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Joe,{error:S,onClose:()=>C(null)})]})}function uae({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,flatProcess:l=!1,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:w,onQuickAsk:x,topSlot:_,realtimeQuestionAnswers:y,onSubmitQuestion:S,onCancelQuestion:C,liveQuestionToolUseIds:k,api:N,cwd:T,tool:D,sessionKey:P,onSend:O,awaitingUser:R,queued:A,onDequeue:M,onAbort:L,onNewSession:$,onClearSession:F,configSlot:B,chatRootRef:z,chatBodyRef:E,drawers:H,xtermSlot:q,fileSharingScope:j,onShareFile:re,onOpenInTab:ie,onPreviewMarkdown:K,onOpenFilePath:_e,dispatchOrigin:Ee}){const[ue,je]=g.useState(0),Me=g.useMemo(()=>i==="full"?Rq(E5(c)):[],[c,i]),Oe=g.useMemo(()=>new Set(Me.map(xe=>xe.toolUseId)),[Me]);return h.jsx(Bee,{children:h.jsxs("div",{ref:z,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx($te,{meta:e,...D?{tool:D}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:E,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:ue},children:h.jsx(GA,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:_,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...w?{onFork:w}:{},...x?{onQuickAsk:x}:{},realtimeQuestionAnswers:y,onSubmitQuestion:S,...C?{onCancelQuestion:C}:{},liveQuestionToolUseIds:k,...j?{fileSharingScope:j}:{},...re?{onShareFile:re}:{},...ie?{onOpenInTab:ie}:{},...K?{onPreviewMarkdown:K}:{},..._e?{onOpenFilePath:_e}:{},...Ee?{dispatchOrigin:Ee}:{},...i==="full"&&!l?{turnCollapse:aae(d)}:{},dockedAgentToolUseIds:Oe})}),q,h.jsx(tae,{onHeightChange:je,children:h.jsx(iae,{agents:Me})}),e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(Bte,{meta:e,...N?{api:N}:{},cwd:T,...D?{tool:D}:{},sessionKey:P,onSend:O,awaitingUser:R,...A?{queued:A}:{},...M?{onDequeue:M}:{},...L?{onAbort:L}:{},...$?{onNewSession:$}:{},...F?{onClearSession:F}:{},...B?{configSlot:B}:{}}),H]})})}function P1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v,hideHeader:w,flatProcess:x}=t,{capabilities:_}=x1(i.tool||"claude"),y=(_==null?void 0:_.features)??_I(i.tool),[S,C]=g.useState(null),[k,N]=g.useState(null),T=lp(),D=!!s&&T.actionsLevel==="owner"&&y.fileSharing,P=kI(i.ownerPersonaId??null).persona,O=(P==null?void 0:P.label)??null,R=!!O&&!!i.ownerPersonaId,A=Loe(),M=g.useMemo(()=>({resolve:(ee,we)=>A.resolve(ee,we,i.sessionId),...A.onOpenSession?{onOpenSession:A.onOpenSession}:{}}),[A,i.sessionId]),L=g.useCallback((ee,we)=>{C({kind:ee,text:we}),setTimeout(()=>{C(ke=>(ke==null?void 0:ke.text)===we?null:ke)},2e3)},[]),$=yi(),F=i$(),B=_5(i.sessionId,i.toolSessionId),{events:z,pendingQuestions:E,clearQuestion:H,markQuestionSubmitted:q,status:j}=B,re=e.historyLoading,ie=S5(j);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:j,procAlive:ie})},[j,ie,i.sessionId]);const K=e.lines,_e=e.pendingPermissions,Ee=_e[0]??null,ue=g.useMemo(()=>Iq(z),[z]),[je,Me]=g.useState(null),[Oe,xe]=g.useState(()=>new Set);Eq(s,i.sessionId,i.toolSessionId,y.observe);const tt=g.useRef(i.sessionId);g.useEffect(()=>{if(tt.current=i.sessionId,!y.rewind){Me(null);return}let ee=!1;return Me(null),(async()=>{try{const we=await s.sessionRewindableMessageIds(i.sessionId);if(ee)return;Me(new Set(we.userMessageIds))}catch{ee||Me(null)}})(),()=>{ee=!0}},[s,i.sessionId,y.rewind]);const Nt=g.useCallback(()=>{const ee=i.sessionId;s.sessionRewindableMessageIds(ee).then(we=>{tt.current===ee&&Me(new Set(we.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),st=g.useMemo(()=>{if(je!==null){const Qe=new Set(je);for(const Mr of Oe)Qe.delete(Mr);return Qe}const ee=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),we=new Set;let ke=null;for(const Qe of K)Qe.kind==="user-text"?ke=Qe.uuid??null:ke&&Qe.kind==="tool-call"&&ee.has(Qe.tool)&&!Oe.has(ke)&&we.add(ke);return we},[K,Oe,je]),pt=g.useRef(c);pt.current=c,Nq(i.sessionId,i.toolSessionId,()=>{nt(null),xe(new Set)});const Dt=nne({sessionStatus:j}),mt=g.useRef(null);g.useEffect(()=>{var ke;const ee=mt.current,we=(ee==null?void 0:ee.sid)===i.sessionId;we&&ee.phase===Dt||(mt.current={sid:i.sessionId,phase:Dt},Ae("session-phase",Dt,{sid:i.sessionId,phase:Dt,prev:we?ee.phase:null,desc:tne[Dt]}),we&&ee.phase==="turn-running"&&Dt!=="turn-running"&&((ke=pt.current)==null||ke.call(pt),Nt()))},[Dt,i.sessionId,Nt]);const gt=g.useCallback(async()=>{const ee=await s.sessionInterrupt(i.sessionId).catch(()=>{});return(ee==null?void 0:ee.queued)??[]},[s,i.sessionId]),[Xe,nt]=g.useState(null),zt=g.useCallback(ee=>{nt(ee)},[]),[xn,tn]=g.useState(!1),U=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),tn(!1)},[s,i.sessionId]);g.useCallback(ee=>{s.pinSession(i.sessionId,ee).catch(we=>{Ae("chat-panel","pinSession failed",{err:we==null?void 0:we.message})})},[s,i.sessionId]);const Q=m?"quickask":"full",{container:ye,onCollapse:Pe,hostExtras:Be}=Kte(),_t=g.useRef(0),_n=g.useRef(null);g.useEffect(()=>{const ee=we=>{if(we.key!=="Escape")return;if(!ie){_t.current=0;return}if(we.isComposing)return;const Qe=we.target;if(Qe&&Qe.closest("[data-cc-chat-root]")!==_n.current)return;const Mr=Date.now();Mr-_t.current<2e3?(_t.current=0,tn(!0)):(_t.current=Mr,gt())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[gt,ie]);const $t=g.useRef(null),dn=g.useRef(!0),oe=g.useRef(void 0),be=g.useRef(0),Ze=g.useRef(0),Tt=g.useRef(void 0);g.useEffect(()=>{N(null)},[i.sessionId]),g.useEffect(()=>{const ee=$t.current;if(!ee)return;const we=150,ke=Qe=>{Date.now()<Ze.current&&(Qe.preventDefault(),Ze.current=Date.now()+we)};return ee.addEventListener("wheel",ke,{passive:!1}),()=>ee.removeEventListener("wheel",ke)},[]),g.useEffect(()=>{const ee=$t.current;if(!ee)return;const we=32,ke=()=>{const Qe=ee.scrollHeight-ee.scrollTop-ee.clientHeight;dn.current=Qe<=we};return ee.addEventListener("scroll",ke,{passive:!0}),()=>ee.removeEventListener("scroll",ke)},[]),g.useLayoutEffect(()=>{var Hu;const ee=$t.current;if(!ee)return;const we=Tt.current!==i.sessionId;we&&(Tt.current=i.sessionId,dn.current=!0,oe.current=void 0,be.current=0,Ze.current=0);const ke=oe.current,Qe=(Hu=K[0])==null?void 0:Hu.seq;oe.current=Qe,!we&&ke!==void 0&&Qe!==void 0&&Qe<ke?(ee.scrollTop=ee.scrollHeight-be.current,Ze.current=Date.now()+200):dn.current&&(ee.scrollTop=ee.scrollHeight),be.current=ee.scrollHeight-ee.scrollTop},[K,Ee==null?void 0:Ee.requestId,i.sessionId]);const Ar=g.useMemo(()=>{const ee={};for(const[we,ke]of Object.entries(E))ke.submittedAnswers&&(ee[we]=ke.submittedAnswers);return ee},[E]),ae=g.useMemo(()=>new Set(Object.keys(E)),[E]),Je=g.useCallback(async(ee,we)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:ee,answers:we}),q(ee,we)}catch{}},[s,i.sessionId,q]),hn=g.useCallback(async ee=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:ee}),H(ee)}catch{}},[s,i.sessionId,H]),Qs=g.useCallback(async(ee,we)=>{var ke;if(Ee)try{await((ke=e.respondPermission)==null?void 0:ke.call(e,Ee.requestId,ee?"allow":"deny"))}catch{}},[e,Ee]),Il=g.useCallback(async()=>{const ee=i.sessionId;try{await s.sessionStop(ee)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(ee)},[e,s,i.sessionId]),Ko=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):re&&K.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(Ln,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[re,K.length,e.historyError]),ki=e.meta,Go=h.jsxs(h.Fragment,{children:[i.toolSessionId&&y.subagents?h.jsx(Gte,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,Xe&&y.rewind?h.jsx(Xte,{open:!0,onOpenChange:ee=>{ee||nt(null)},api:s,sessionId:i.sessionId,userMessageId:Xe,lines:K,procAlive:ie,onNoChanges:ee=>{xe(we=>{if(we.has(ee))return we;const ke=new Set(we);return ke.add(ee),ke})}}):null,xn?h.jsx(dae,{onConfirm:U,onCancel:()=>tn(!1)}):null]}),Yo={kind:"session",sessionId:i.sessionId},Xo=g.useCallback(async ee=>{if(s)try{await f2(s,$,i.sessionId,ee)}catch(we){const ke=we.message;Ae("chat-panel","open-in-tab failed",{err:ke}),L("err",`Open in tab 失败:${ke}`)}},[s,$,i.sessionId,L]),[ss,Ci]=g.useState(!1),[Qo,Yp]=g.useState(null),It=g.useCallback(ee=>{if(r){r(ee);return}Yp(ee),Ci(!0)},[r]),Fu=g.useCallback(ee=>{if(!s)return;const we=async()=>{try{await s.attachmentGroupAdd(i.sessionId,ee)}catch(Qe){Ae("chat-panel","file-link groupAdd skipped",{err:Qe.message})}},ke=Qe=>{const Mr=Qe.message;Ae("chat-panel","file-link open failed",{err:Mr}),L("err",`打开文件失败:${Mr}`)};if(Dp(ee)){we().then(()=>It(ee),ke);return}f2(s,$,i.sessionId,ee,60,we).catch(ke)},[s,$,i.sessionId,It,L]),Xp=g.useCallback(async ee=>{if(!s)throw new Error("daemon api not ready");const we=await I1(s,$,i.sessionId,ee,60),ke=await fetch(we);if(!ke.ok)throw new Error(`fetch ${ke.status} ${ke.statusText}`);return await ke.text()},[s,$,i.sessionId]),yt=g.useCallback(async(ee,we)=>{if(s)try{const{url:ke}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:ee,ttlSeconds:86400,...we?{view:we}:{}}),Qe=await Boe(ke);L(Qe?"ok":"err",Qe?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(ke){const Qe=ke.message;Ae("chat-panel","share-file failed",{err:Qe}),L("err",`生成分享链接失败:${Qe}`)}},[s,i.sessionId,L]),Pt=g.useCallback(()=>N(null),[]),hr=k==="files"&&D&&s?{title:"Edited Files",onBack:Pt,content:h.jsx(gse,{api:s,scope:Yo,sessionId:i.sessionId,onShareFile:yt,onOpenInTab:Xo,onPreviewMarkdown:It})}:k==="cron"?{title:`定时任务${ue.length?` (${ue.length})`:""}`,onBack:Pt,content:h.jsx("div",{className:"p-3",children:h.jsx(ene,{jobs:ue})})}:k==="persona"&&R&&s&&i.ownerPersonaId?{title:`Persona · ${O??""}`,onBack:Pt,content:h.jsx(Aoe,{personaId:i.ownerPersonaId,open:!0,onClose:Pt,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,Qn=Q==="full"?h.jsx(Vte,{session:i,meta:ki,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...R?{personaName:O}:{},...R?{onOpenPersona:()=>N("persona")}:{},...D?{onOpenFiles:()=>N("files")}:{},cronActiveCount:ue.length,onCronClick:()=>N("cron"),onForceStop:()=>tn(!0),...p?{viewerRole:p}:{},..._!=null&&_.toolSessionIdLabel?{toolSessionIdLabel:_.toolSessionIdLabel}:{},drill:hr,...Pe?{onCollapse:Pe}:{},...Be?{title:Be.title,leadingEntries:Be.leadingEntries}:{}}):null;return h.jsxs(h.Fragment,{children:[ye&&Qn?hl.createPortal(Qn,ye):null,h.jsx(uae,{headerMeta:ki,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:Q,...w?{hideHeader:w}:{},...x?{flatProcess:x}:{},...Q==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:K,pendingPermissions:_e,procAlive:ie,rewindableUserMessageIds:st,onPermissionRespond:Qs,onPermissionInterrupt:gt,onRewind:y.rewind?zt:void 0,...d&&y.fork?{onFork:d}:{},...n&&y.fork?{onQuickAsk:n}:f&&y.fork?{onQuickAsk:f}:{},topSlot:Ko,realtimeQuestionAnswers:Ar,onSubmitQuestion:Je,onCancelQuestion:hn,liveQuestionToolUseIds:ae,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:_e.length>0||Object.values(E).some(ee=>!ee.submittedAnswers),onAbort:gt,...l?{onNewSession:l}:{},onClearSession:Il,...v?{configSlot:v}:{},chatRootRef:_n,chatBodyRef:$t,drawers:Go,xtermSlot:F==="tui"&&ie&&y.tui?h.jsx(mse,{sessionId:i.sessionId,client:$},i.sessionId):null,fileSharingScope:Yo,...s?{onShareFile:yt}:{},...s?{onOpenInTab:Xo}:{},...s?{onPreviewMarkdown:It}:{},...s?{onOpenFilePath:Fu}:{},dispatchOrigin:M}),s?h.jsx(Foe,{open:ss,onOpenChange:Ci,relPath:Qo,loadMarkdown:Xp,onShare:Qo?()=>void yt(Qo,"md-rendered"):void 0}):null,S?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:S.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:S.text}):null]})}function dae({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(tu,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}const hae={codex:"on-request",claude:"bypassPermissions",pi:"never"};function fae(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??hae[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function pae(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...fae({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Ae("quick-ask","fork rollback failed",o)),s}return i}async function mae(e,t,n){return pae(e,t,n,{ephemeral:!0})}function Fd(e){return e!=null&&e.ephemeral!==!1}async function gae(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const vae=300;function xae(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function _ae(e,t){const n=P_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=xae(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},vae)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function yae(){return{quickAsk:null,mds:[],active:null}}function bae(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function wae(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Sae(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function kae(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Cae(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Eae(e,t){return{...e,active:t}}function Nae(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function E4(e){return e.quickAsk!==null||e.mds.length>0}function Tae(e){return e.split("/").pop()||e}function Iae({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!E4(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(y0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:Tae(c),title:c,icon:h.jsx(gi,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=Nae(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Np,{children:[h.jsx(Tp,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(Rr,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Ru,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(lae,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(C4,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Pae(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function Rae({state:e,extras:t}){const{api:n,session:r}=t,i=yi(),[s,o]=g.useState(yae()),[a,l]=g.useState(null),c=r.ownerPersonaId!==QT,u=g.useRef(s);u.current=s;const d=g.useRef(!1),f=g.useCallback(async T=>{const D=u.current.quickAsk;l(null);let P;try{P=await mae(n,r,T)}catch(O){Ae("quick-ask","fork failed",O),d.current||l(Pae(O));return}if(!P){d.current||l("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(d.current){n.sessionDelete(P.sessionId).catch(()=>{});return}Fd(D)&&n.sessionDelete(D.sessionId).catch(()=>{}),o(O=>bae(O,{sessionId:P.sessionId}))},[n,r]),p=g.useCallback(async T=>{const D=u.current.quickAsk,P=(D==null?void 0:D.sessionId)===T;try{await gae(n,{sessionId:T,stillEphemeral:P&&Fd(D)})&&o(R=>kae(R))}catch(O){Ae("quick-ask","promote failed",O)}},[n]),m=g.useCallback(T=>{o(D=>wae(D,T))},[]),v=g.useCallback(T=>{o(D=>Eae(D,T))},[]),w=g.useCallback(()=>{const T=u.current.quickAsk;Fd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),o(D=>Sae(D))},[n]),x=g.useCallback(T=>{o(D=>Cae(D,T))},[]);g.useEffect(()=>()=>{d.current=!0;const T=u.current.quickAsk;Fd(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const _=mi("sessions")??[],y=s.quickAsk?_.find(T=>T.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,S=g.useCallback(async T=>{const D=await I1(n,i,r.sessionId,T,60),P=await fetch(D);if(!P.ok)throw new Error(`fetch ${P.status} ${P.statusText}`);return P.text()},[n,i,r.sessionId]),C=h.jsx(P1,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:m}),{initialSize:k,setSize:N}=_ae("chat-panel-right-slot-width",480);return h.jsxs($y,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(df,{id:"chat",minSize:"400px",children:h.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[C,a?h.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[h.jsxs("span",{className:"mr-2",children:["问一下没能打开:",a]}),h.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>l(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),E4(s)?h.jsxs(h.Fragment,{children:[h.jsx(x5,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(df,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:T=>N(T.inPixels),children:h.jsx(Iae,{state:s,api:n,onSwitchTab:v,onCloseQuickAsk:w,onCloseMd:x,loadMarkdown:S,quickAskSession:y,...c?{onPromoteQuickAsk:p}:{}})})]}):null]})}function Aae({extras:e}){const t=k5(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(P1,{state:t,extras:e});return h.jsx(cae,{state:t,chat:n,extras:e})}return h.jsx(Rae,{state:t,extras:e})}function Mae(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function jae(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function Lae(e,t){var m,v,w,x;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=Mae(s,n,i),a=o.options,l=a.some(_=>_.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(_=>_.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(_=>_.value===l))==null?void 0:v.label)??null,u=((w=i.find(_=>_.name==="permissionMode"))==null?void 0:w.default)??"",d=r.some(_=>_.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((x=r.find(_=>_.id===d))==null?void 0:x.label)??null;return{modelLabel:jae(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function Dae(e){let t;return e.map(n=>{const r=n.group&&n.group!==t?n.group:null;return n.group&&(t=n.group),{...n,groupHeading:r}})}function Oae({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=Lae({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{},...m.group?{group:m.group}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(Ty,{children:[h.jsx(Iy,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:ne("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(Sp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Lg,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Lg,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Lg,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Lg({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(AW,{children:[h.jsxs(FR,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:ne("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Bn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(HR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:Dae(s).map((l,c)=>{const u=l.value===n;return h.jsxs(Ke.Fragment,{children:[l.groupHeading?h.jsxs(h.Fragment,{children:[c>0?h.jsx(Py,{}):null,h.jsx(UR,{"data-testid":`${e}-group`,children:l.groupHeading})]}):null,h.jsxs(Mi,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:ne("block text-[12px]",u?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),u?h.jsx(bl,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},l.value||"default")})})]})}function Bae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function zae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function $ae({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner",hideHeader:f}){const{capabilities:p}=x1(t.tool),[m,v]=g.useState(0),{branch:w}=Bae(e,t.cwd,m),{worktreeRoot:x}=zae(e,t.cwd,m),_=r>1,y=S=>{e.sessionUpdate(t.sessionId,S).catch(C=>{console.error("[session-config] session:update failed",t.sessionId,C)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx($y,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(df,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(Fae,{api:e,session:t,liveGitBranch:w,liveWorktreeRoot:x,onNewSession:o,onTurnEnd:()=>v(S=>S+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(Oae,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:y}):null})})})}),_&&h.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Rr,{className:"w-3.5 h-3.5"})})]})}function Fae({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u,hideHeader:d}){return h.jsx(Aae,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:f=>{a(f)}}:{},...l?{onQuickAsk:f=>{l(f)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{},...d?{hideHeader:d}:{}}})}function Hae({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(yV,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx($ae,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function Uae(){const e=yi(),t=g.useMemo(()=>new J_(e),[e]),n=E$(e),{sessions:r,refresh:i}=N$(n),{personas:s}=SI(),o=M$(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const w=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),x=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),_=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(ey.Provider,{value:o,children:h.jsx(Hae,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void w(S,C),onDeleteSession:S=>void x(S),onEditSession:(S,C)=>void _(S,C),onCloseSession:()=>v(null)})})}const x2="https://app.ttcadvisory.com";function Wae({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${x2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==x2)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const Lx="clawd-visitor:token";function Vae(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function qae(){return{async getUrl(e){const t=localStorage.getItem(Lx);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=Vae(window.location,{});return await pI(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function Kae(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function Gae(){const e=yi(),t=g.useMemo(()=>C$(e),[e]);return h.jsx(o$,{cache:t.cache,children:h.jsx(c$,{children:h.jsx(Uae,{})})})}function Yae({host:e}){const[t]=g.useState(()=>localStorage.getItem(Lx)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>Kae(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return qae().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Vb,{host:e,children:h.jsx(kw,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(r$,{host:e,children:h.jsx(Gae,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(Vb,{host:e,children:h.jsx(kw,{children:h.jsx(Wae,{onAuthed:o=>{localStorage.setItem(Lx,o),window.location.reload()}})})})}function Xae({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Qae(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function Qae(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function Zae({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Jae,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Jae({status:e}){return e==="completed"?h.jsx(up,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(Ln,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(TI,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function ele(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function tle({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(cp,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function nle(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const rle={render:({input:e})=>Ke.createElement(Zae,{items:ele(e)})},ile={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=nle(e);return Ke.createElement(tle,{description:t,prompt:n,subagentType:r})}},N4={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=ole(e),c=l?Ke.createElement(Xae,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Ke.createElement(zA,{tool:sle(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function sle(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function ole(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}El.register("claude","TodoWrite",rle);El.register("claude","Task",ile);El.register("claude","Edit",N4);El.register("claude","Write",N4);const T4=document.getElementById("root");if(!T4)throw new Error("guest-main: #root not found");const ale=aL({});Dg.createRoot(T4).render(h.jsx(Ke.StrictMode,{children:h.jsx(Yae,{host:ale})}));
|
|
599
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},goe="DialogDescriptionWarning",voe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${x4(goe).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},xoe=s4,_oe=l4,_4=c4,y4=u4,b4=h4,w4=p4,yoe=g4;const N1=xoe,boe=_oe,S4=g.forwardRef(({className:e,...t},n)=>h.jsx(_4,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));S4.displayName=_4.displayName;const qp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(boe,{children:[h.jsx(S4,{}),h.jsxs(y4,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(yoe,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Rr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));qp.displayName=y4.displayName;const Kp=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});Kp.displayName="DialogHeader";const T1=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-row justify-end gap-2",e),...t});T1.displayName="DialogFooter";const Gp=g.forwardRef(({className:e,...t},n)=>h.jsx(b4,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));Gp.displayName=b4.displayName;const k4=g.forwardRef(({className:e,...t},n)=>h.jsx(w4,{ref:n,className:ne("text-sm text-text-300",e),...t}));k4.displayName=w4.displayName;function woe({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onLoadPersonalityLocal:a,onSavePersonalityLocal:l,hasPersonalityLocal:c=!1,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,larkBot:m}){const[v,w]=g.useState(!1),[x,_]=g.useState(!1),y=v||x,S=Ke.useRef(u);g.useEffect(()=>{S.current=u}),g.useEffect(()=>{var k;(k=S.current)==null||k.call(S,y)},[y]);const C=()=>{y&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(hF,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Rr,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(P8,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(T8,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(ny,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(ry,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),m?h.jsxs(h.Fragment,{children:[h.jsx(Coe,{...m}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(h2,{onLoad:s,...o&&!e.personalityManaged?{onSave:o}:{},onDirtyChange:w,initialPersonality:d,readOnly:p||!!e.personalityManaged,title:e.personalityManaged?"内置人格":"人格 (Personality)",hint:e.personalityManaged?p?"这个 persona 自带的人格,随 clawd 版本更新。":"这个 persona 自带的人格,随 clawd 版本更新——在这里改不会保留,要加自己的规则请写下面的「你的补充」。":void 0,testIdPrefix:"persona-personality"}),(e.personalityManaged||c)&&a?h.jsx(h2,{onLoad:a,...l?{onSave:l}:{},onDirtyChange:_,readOnly:p,title:p?"补充设定":"你的补充",hint:p?"这个 persona 的补充设定,由它的主人维护。与内置人格叠加生效。":"写入 <persona-dir>/.clawd/personality.local.md,不会被更新覆盖。与内置人格叠加生效,冲突时以你写的为准;对 owner 和访客会话都生效,要区分对象请在正文里写明。只对新启动的会话生效。",placeholder:"例:回答一律先给结论,再展开。",testIdPrefix:"persona-personality-local"}):null,h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Eoe,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Noe,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Toe,{plugins:e.plugins??[]})]})]})]}):null}function d2({qrUrl:e,busy:t,onCancel:n,title:r="扫码关联飞书 Bot",hint:i="用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}){const[s,o]=g.useState(null);return g.useEffect(()=>{let a=!1;return zu.toDataURL(e,{width:240,margin:1}).then(l=>{a||o(l)}).catch(()=>{a||o(null)}),()=>{a=!0}},[e]),h.jsx(N1,{open:!0,onOpenChange:a=>a||n==null?void 0:n(),children:h.jsxs(qp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:a=>a.preventDefault(),onEscapeKeyDown:a=>a.preventDefault(),children:[h.jsx(Kp,{children:h.jsx(Gp,{children:r})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s?h.jsx("img",{src:s,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:i}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const Soe={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},koe=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Coe({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i,onUpgrade:s}){const[o,a]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(""),[f,p]=g.useState(""),[m,v]=g.useState(null),w=k=>{k&&(a(!0),c(null),k().catch(N=>c(N instanceof Error?N.message:String(N))).finally(()=>a(!1)))},x=()=>{v(null),w(t)},_=!o&&!!u&&!!f,y=()=>{!_||!r||w(()=>r({appId:u,appSecret:f}))},S=Pu(y),C=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(cp,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:o||e.state==="provisioning",onClick:x,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!m?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:Soe[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[koe.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:o,onClick:x,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>v(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(d2,{qrUrl:e.qrUrl,busy:o,onCancel:n?()=>w(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:u,onChange:k=>d(k.target.value),...S,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:f,onChange:k=>p(k.target.value),...S,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:y,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:o?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="bound"&&e.needsUpgrade?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-warning/30 bg-warning-dim px-2 py-1.5","data-testid":"lark-bot-upgrade-notice",children:[h.jsx("span",{className:"text-[11px] text-warning",children:"这个 bot 的权限配置有更新,扫码重新授权后生效。在此之前,新增能力对它不起作用。"}),s?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(s),className:"self-start rounded border border-warning/30 bg-warning/10 px-2 py-1 text-[11px] text-warning hover:bg-warning/20 disabled:opacity-50","data-testid":"lark-bot-upgrade",children:"更新授权"}):null]}):null,e.state==="bound"&&e.upgradeQrUrl?h.jsx(d2,{qrUrl:e.upgradeQrUrl,busy:o,onCancel:n?()=>w(n):void 0,title:"扫码更新授权",hint:"用手机飞书扫码,确认页会列出将要添加的权限。期间 bot 照常服务,不会中断。"}):null,e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:o,onClick:()=>w(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,l?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:l}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[C,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Eoe({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx($d,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx($d,{label:"沙箱启用",value:jg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx($d,{label:"沙箱内自动放行 Bash",value:jg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx($d,{label:"允许非沙箱命令",value:jg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Xl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Xl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Xl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Xl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Xl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function jg(e){return e===!0?"是":e===!1?"否":"—"}function $d({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Xl({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function Noe({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function Toe({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function h2({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1,title:s,hint:o,placeholder:a,testIdPrefix:l}){const c=r!==void 0,[u,d]=g.useState(c),[f,p]=g.useState(c?r:""),[m,v]=g.useState(c?r:""),[w,x]=g.useState(null),[_,y]=g.useState(!1),[S,C]=g.useState(null),k=Ke.useRef(e),N=Ke.useRef(t),T=Ke.useRef(n);Ke.useEffect(()=>{k.current=e,N.current=t,T.current=n});const D=Ke.useCallback(()=>{d(!1),x(null),k.current().then(M=>{p(M),v(M),d(!0)}).catch(M=>{x(M instanceof Error?M.message:String(M))})},[]);Ke.useEffect(()=>{c||D()},[c,D]);const P=!i&&u&&m!==f;Ke.useEffect(()=>{i||T.current(P)},[P,i]);const O=()=>{N.current&&(y(!0),C(null),N.current(m).then(()=>{p(m),y(!1)}).catch(M=>{C(M instanceof Error?M.message:String(M)),y(!1)}))},R=()=>{v(f),C(null)},A=Pu(()=>{!P||_||O()},()=>{!P||_||R()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":`${l}-section`,children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:s}),w?h.jsxs("div",{"data-testid":`${l}-load-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",w]}),h.jsx("button",{type:"button",onClick:D,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,S?h.jsxs("div",{"data-testid":`${l}-save-error`,className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",S]}):null,h.jsx("textarea",{"data-testid":`${l}-textarea`,value:m,onChange:M=>v(M.target.value),...A,readOnly:i,disabled:!i&&(!u||_),placeholder:u?a??"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),o?h.jsx("p",{className:"text-[10px] text-text-400",children:o}):i?null:h.jsx("p",{className:"text-[10px] text-text-400",children:"写入人格文件。修改只对新启动的会话生效。"}),u&&P?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:R,disabled:_,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:O,disabled:_,"data-testid":`${l}-save-btn`,className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:_?"保存中…":"保存"})]}):null]})}const Ioe={state:"unbound",groups:[]};function Poe(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let c=!1;r(null);const u=async()=>{try{const p=await e.request("larkBot:status",{personaId:t});c||r(p)}catch{c||r(Ioe)}};u();const d=e.on("larkBot:state",p=>{const m=p;if(m.personaId!==t)return;const{personaId:v,...w}=m;r(w)}),f=e.on("daemon:connected",()=>{u()});return()=>{c=!0,d(),f()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async c=>{e&&await e.request("larkBot:bindManual",{personaId:t,...c})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:upgrade",{personaId:t})},[e,t]),l=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:l,upgrade:a}}function Roe(e,t="owner"){var k;const{persona:n}=kI(e),r=T$(e),i=I$(),s=P$(),{httpBaseUrl:o}=lp(),a=yi(),l=Poe(t==="guest"?null:a,e),{capabilities:c}=x1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((N,T)=>{i(e,T).catch(D=>{Ae("persona",`${N} failed`,D)})},[i,e]),f=g.useCallback(N=>d("togglePublic",{public:N}),[d]),p=g.useCallback(async N=>{await i(e,{codexSandbox:{network:N}}),await r.refresh()},[i,e,r]),m=g.useCallback(N=>d("changeTool",{tool:N}),[d]),v=g.useCallback(N=>d("changeModel",{model:N}),[d]),w=g.useCallback(N=>d("changeEffort",{effort:N}),[d]),x=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(N=>{Ae("persona","delete failed",N)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),y=g.useCallback(async N=>{await i(e,{personality:N}),await r.refresh()},[i,e,r]),S=g.useCallback(async()=>r.loaded?r.personalityLocal:(await r.refresh()).personalityLocal,[r]),C=g.useCallback(async N=>{await i(e,{personalityLocal:N}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:m,changeModel:v,changeEffort:w,togglePublic:f,guestNetwork:((k=r.codexSandbox)==null?void 0:k.network)??!1,toggleGuestNetwork:p,remove:x,loadPersonality:_,savePersonality:y,loadPersonalityLocal:S,savePersonalityLocal:C}}function Aoe({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=Roe(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(woe,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings,personalityManaged:u.personalityManaged},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onLoadPersonalityLocal:l.loadPersonalityLocal,hasPersonalityLocal:u.personalityLocal!=="",onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,onSavePersonalityLocal:l.savePersonalityLocal,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind,onUpgrade:l.larkBot.upgrade},...o?{onShareCapability:o}:{}}})}const Moe={resolve:()=>{}},joe=g.createContext(Moe);function Loe(){return g.useContext(joe)}function Doe(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function Ooe(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function I1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return Ooe(s.url,Doe(t.url))}async function f2(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await I1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function Boe(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const zoe={...Us,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function $oe(e){const t=e.split("/");return t[t.length-1]||e}function C4({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:$oe(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(tl,{remarkPlugins:[nl],components:zoe,children:i})}):null})]})}function Foe({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:`${a1} z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl`,children:h.jsx(C4,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(B8,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Rr,{className:"h-4 w-4"})})]})})}):null}function Hoe({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const Uoe=6173,Woe=6182;function Voe({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Uoe;v<=Woe;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(N1,{open:e,onOpenChange:t,children:h.jsxs(qp,{className:"max-w-md",children:[h.jsxs(Kp,{children:[h.jsxs(Gp,{children:["改端口 · ",n]}),h.jsxs(k4,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(T1,{children:[h.jsx(hi,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(hi,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const p2=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function qoe({currentStage:e,onCancel:t}){const n=p2.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[p2.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(up,{className:"size-3.5"}):o?h.jsx(Ln,{className:"size-3.5 animate-spin"}):h.jsx(TI,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Koe={build:"构建",deploy:"部署",verify:"验证"};function Goe({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(tu,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Koe[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Yoe={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Xoe({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ji,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",Yoe[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Rr,{className:"size-3.5"})})]})}const m2={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Qoe({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var x,_;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,w=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[w?h.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${w}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(eu,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(Ty,{children:[h.jsx(Iy,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(uF,{className:"size-3.5"})})}),h.jsxs(Sp,{align:"end",children:[h.jsx(Mi,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Mi,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Xoe,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(qoe,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(Goe,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Zoe,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(g2,{label:"等 tunnel 起来…",step:"-"}):h.jsx(g2,{label:m2[m].label,step:m2[m].step})}),h.jsx(Voe,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function g2({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ln,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Zoe({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ji,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function Joe({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(N1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(qp,{className:"max-w-lg",children:[h.jsx(Kp,{children:h.jsx(Gp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(T1,{children:[h.jsx(hi,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(bl,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(dp,{className:"size-3.5"}),"复制"]})}),h.jsx(hi,{onClick:t,children:"关闭"})]})]})})}function eae(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const v2=4;function tae({children:e,onHeightChange:t}){const n=g.useRef(null),[r,i]=g.useState(0);return g.useEffect(()=>{const s=n.current;if(!s)return;const o=()=>i(s.offsetHeight>0?s.offsetHeight+v2*2:0);if(o(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(o);return a.observe(s),()=>a.disconnect()},[]),g.useEffect(()=>{t==null||t(r)},[r,t]),h.jsx("div",{"data-testid":"chat-floating-dock","data-height":r,className:"relative z-20 h-0 shrink-0",children:h.jsx("div",{ref:n,className:"absolute left-4 right-4 flex flex-col items-end gap-1",style:{bottom:v2},children:e})})}const nae=250;function rae(e){if(!e||!Number.isFinite(e))return null;const t=e/1e3;if(t<60)return`${t.toFixed(0)}s`;const n=Math.floor(t/60);return`${n}m${Math.round(t-n*60).toString().padStart(2,"0")}s`}function iae({agents:e}){var a,l,c;const[t,n]=g.useState(!1);if(e.length===0)return null;const r=e.length===1?e[0]:null,i=r?r.description:`${e.length} 个后台任务`,s=r?rae((l=(a=r.progress)==null?void 0:a.stats)==null?void 0:l.durationMs):null,o=r?(c=r.progress)==null?void 0:c.lastToolName:null;return h.jsxs("div",{"data-testid":"running-agents-chip","data-agent-count":e.length,className:"relative",children:[t?h.jsx("div",{"data-testid":"running-agents-popover",className:"absolute bottom-full right-0 z-20 mb-1 w-[min(560px,80vw)]",children:h.jsx("div",{className:"min-w-0 overflow-y-auto rounded-lg border border-bg-200/60 bg-bg-100 px-2 py-1 shadow-lg",style:{maxHeight:nae},children:e.map(u=>h.jsx(qA,{expandable:!1,description:u.description,input:u.input,output:u.output,...u.error!==void 0?{error:u.error}:{},pending:u.pending,notifications:u.notifications,...u.toolResultExtra?{toolResultExtra:u.toolResultExtra}:{},...u.progress?{progress:u.progress}:{}},u.toolUseId))})}):null,h.jsxs("button",{type:"button","data-testid":"running-agents-chip-toggle","aria-expanded":t,onClick:()=>n(u=>!u),className:ne("flex max-w-[min(560px,80vw)] min-w-0 items-center gap-2 rounded-full","border border-bg-200/60 bg-bg-100/95 px-3 py-1 text-[12px] shadow-md backdrop-blur","hover:bg-bg-200/95 transition-colors"),children:[h.jsx(Ln,{className:"w-3 h-3 shrink-0 animate-spin text-blue-400"}),h.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-text-200",children:i}),s?h.jsx("span",{className:"shrink-0 tabular-nums text-text-400",children:s}):null,o?h.jsxs("span",{className:"shrink-0 font-mono tabular-nums text-blue-400",children:["now:",o]}):null,h.jsx(NI,{className:ne("w-3.5 h-3.5 shrink-0 text-text-400 transition-transform",t&&"rotate-180")})]})]})}const sae={closeTrailing:!1},oae={closeTrailing:!0};function aae(e){return e?sae:oae}function lae({session:e,api:t,onPromoteQuickAsk:n}){const r=k5(e.sessionId);return h.jsx(P1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function cae({state:e,chat:t,extras:n}){var T;const r=mi("daemon-info"),i=yi(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(D=>c(D.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(D=>f(D.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const O=P;O!=null&&O.project&&(O.project.name===a&&c(O.project),f(R=>{const A=R.findIndex(L=>L.name===O.project.name);if(A<0)return[...R,O.project];const M=R.slice();return M[A]=O.project,M}))}),[i,a]);const{host:m,scheme:v}=eae(i.url,r==null?void 0:r.tunnelUrl),[w,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const D=i.on("appBuilder:publish-progress",O=>{const R=O;!R||R.name!==a||R.status==="started"&&x(R.stage)}),P=i.on("appBuilder:publish-failed",O=>{const R=O;!R||R.name!==a||(x(void 0),y({stage:R.stage}))});return()=>{D(),P()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[S,C]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(D){C({title:"发布请求失败",message:(D==null?void 0:D.message)??String(D)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(Hoe,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Qoe,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(D=>D.port),onUpdatePort:async D=>{await s.appBuilderUpdateProjectPort(a,D),p()},publishSlot:k,publishInFlightStage:w,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(D){C({title:"取消发布失败",message:(D==null?void 0:D.message)??String(D)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(D){C({title:"重新发布失败",message:(D==null?void 0:D.message)??String(D)})}},publishFailureBanner:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Joe,{error:S,onClose:()=>C(null)})]})}function uae({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,flatProcess:l=!1,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:w,onQuickAsk:x,topSlot:_,realtimeQuestionAnswers:y,onSubmitQuestion:S,onCancelQuestion:C,liveQuestionToolUseIds:k,api:N,cwd:T,tool:D,sessionKey:P,onSend:O,awaitingUser:R,queued:A,onDequeue:M,onAbort:L,onNewSession:$,onClearSession:F,configSlot:B,chatRootRef:z,chatBodyRef:E,drawers:H,xtermSlot:q,fileSharingScope:j,onShareFile:re,onOpenInTab:ie,onPreviewMarkdown:K,onOpenFilePath:_e,dispatchOrigin:Ee}){const[ue,je]=g.useState(0),Me=g.useMemo(()=>i==="full"?Rq(E5(c)):[],[c,i]),Oe=g.useMemo(()=>new Set(Me.map(xe=>xe.toolUseId)),[Me]);return h.jsx(Bee,{children:h.jsxs("div",{ref:z,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx($te,{meta:e,...D?{tool:D}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:E,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none",paddingBottom:ue},children:h.jsx(GA,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:_,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...w?{onFork:w}:{},...x?{onQuickAsk:x}:{},realtimeQuestionAnswers:y,onSubmitQuestion:S,...C?{onCancelQuestion:C}:{},liveQuestionToolUseIds:k,...j?{fileSharingScope:j}:{},...re?{onShareFile:re}:{},...ie?{onOpenInTab:ie}:{},...K?{onPreviewMarkdown:K}:{},..._e?{onOpenFilePath:_e}:{},...Ee?{dispatchOrigin:Ee}:{},...i==="full"&&!l?{turnCollapse:aae(d)}:{},dockedAgentToolUseIds:Oe})}),q,h.jsx(tae,{onHeightChange:je,children:h.jsx(iae,{agents:Me})}),e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(Bte,{meta:e,...N?{api:N}:{},cwd:T,...D?{tool:D}:{},sessionKey:P,onSend:O,awaitingUser:R,...A?{queued:A}:{},...M?{onDequeue:M}:{},...L?{onAbort:L}:{},...$?{onNewSession:$}:{},...F?{onClearSession:F}:{},...B?{configSlot:B}:{}}),H]})})}function P1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v,hideHeader:w,flatProcess:x}=t,{capabilities:_}=x1(i.tool||"claude"),y=(_==null?void 0:_.features)??_I(i.tool),[S,C]=g.useState(null),[k,N]=g.useState(null),T=lp(),D=!!s&&T.actionsLevel==="owner"&&y.fileSharing,P=kI(i.ownerPersonaId??null).persona,O=(P==null?void 0:P.label)??null,R=!!O&&!!i.ownerPersonaId,A=Loe(),M=g.useMemo(()=>({resolve:(ee,we)=>A.resolve(ee,we,i.sessionId),...A.onOpenSession?{onOpenSession:A.onOpenSession}:{}}),[A,i.sessionId]),L=g.useCallback((ee,we)=>{C({kind:ee,text:we}),setTimeout(()=>{C(ke=>(ke==null?void 0:ke.text)===we?null:ke)},2e3)},[]),$=yi(),F=i$(),B=_5(i.sessionId,i.toolSessionId),{events:z,pendingQuestions:E,clearQuestion:H,markQuestionSubmitted:q,status:j}=B,re=e.historyLoading,ie=S5(j);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:j,procAlive:ie})},[j,ie,i.sessionId]);const K=e.lines,_e=e.pendingPermissions,Ee=_e[0]??null,ue=g.useMemo(()=>Iq(z),[z]),[je,Me]=g.useState(null),[Oe,xe]=g.useState(()=>new Set);Eq(s,i.sessionId,i.toolSessionId,y.observe);const tt=g.useRef(i.sessionId);g.useEffect(()=>{if(tt.current=i.sessionId,!y.rewind){Me(null);return}let ee=!1;return Me(null),(async()=>{try{const we=await s.sessionRewindableMessageIds(i.sessionId);if(ee)return;Me(new Set(we.userMessageIds))}catch{ee||Me(null)}})(),()=>{ee=!0}},[s,i.sessionId,y.rewind]);const Nt=g.useCallback(()=>{const ee=i.sessionId;s.sessionRewindableMessageIds(ee).then(we=>{tt.current===ee&&Me(new Set(we.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),st=g.useMemo(()=>{if(je!==null){const Qe=new Set(je);for(const Mr of Oe)Qe.delete(Mr);return Qe}const ee=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),we=new Set;let ke=null;for(const Qe of K)Qe.kind==="user-text"?ke=Qe.uuid??null:ke&&Qe.kind==="tool-call"&&ee.has(Qe.tool)&&!Oe.has(ke)&&we.add(ke);return we},[K,Oe,je]),pt=g.useRef(c);pt.current=c,Nq(i.sessionId,i.toolSessionId,()=>{nt(null),xe(new Set)});const Dt=nne({sessionStatus:j}),mt=g.useRef(null);g.useEffect(()=>{var ke;const ee=mt.current,we=(ee==null?void 0:ee.sid)===i.sessionId;we&&ee.phase===Dt||(mt.current={sid:i.sessionId,phase:Dt},Ae("session-phase",Dt,{sid:i.sessionId,phase:Dt,prev:we?ee.phase:null,desc:tne[Dt]}),we&&ee.phase==="turn-running"&&Dt!=="turn-running"&&((ke=pt.current)==null||ke.call(pt),Nt()))},[Dt,i.sessionId,Nt]);const gt=g.useCallback(async()=>{const ee=await s.sessionInterrupt(i.sessionId).catch(()=>{});return(ee==null?void 0:ee.queued)??[]},[s,i.sessionId]),[Xe,nt]=g.useState(null),zt=g.useCallback(ee=>{nt(ee)},[]),[xn,tn]=g.useState(!1),U=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),tn(!1)},[s,i.sessionId]);g.useCallback(ee=>{s.pinSession(i.sessionId,ee).catch(we=>{Ae("chat-panel","pinSession failed",{err:we==null?void 0:we.message})})},[s,i.sessionId]);const Q=m?"quickask":"full",{container:ye,onCollapse:Pe,hostExtras:Be}=Kte(),_t=g.useRef(0),_n=g.useRef(null);g.useEffect(()=>{const ee=we=>{if(we.key!=="Escape")return;if(!ie){_t.current=0;return}if(we.isComposing)return;const Qe=we.target;if(Qe&&Qe.closest("[data-cc-chat-root]")!==_n.current)return;const Mr=Date.now();Mr-_t.current<2e3?(_t.current=0,tn(!0)):(_t.current=Mr,gt())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[gt,ie]);const $t=g.useRef(null),dn=g.useRef(!0),oe=g.useRef(void 0),be=g.useRef(0),Ze=g.useRef(0),Tt=g.useRef(void 0);g.useEffect(()=>{N(null)},[i.sessionId]),g.useEffect(()=>{const ee=$t.current;if(!ee)return;const we=150,ke=Qe=>{Date.now()<Ze.current&&(Qe.preventDefault(),Ze.current=Date.now()+we)};return ee.addEventListener("wheel",ke,{passive:!1}),()=>ee.removeEventListener("wheel",ke)},[]),g.useEffect(()=>{const ee=$t.current;if(!ee)return;const we=32,ke=()=>{const Qe=ee.scrollHeight-ee.scrollTop-ee.clientHeight;dn.current=Qe<=we};return ee.addEventListener("scroll",ke,{passive:!0}),()=>ee.removeEventListener("scroll",ke)},[]),g.useLayoutEffect(()=>{var Hu;const ee=$t.current;if(!ee)return;const we=Tt.current!==i.sessionId;we&&(Tt.current=i.sessionId,dn.current=!0,oe.current=void 0,be.current=0,Ze.current=0);const ke=oe.current,Qe=(Hu=K[0])==null?void 0:Hu.seq;oe.current=Qe,!we&&ke!==void 0&&Qe!==void 0&&Qe<ke?(ee.scrollTop=ee.scrollHeight-be.current,Ze.current=Date.now()+200):dn.current&&(ee.scrollTop=ee.scrollHeight),be.current=ee.scrollHeight-ee.scrollTop},[K,Ee==null?void 0:Ee.requestId,i.sessionId]);const Ar=g.useMemo(()=>{const ee={};for(const[we,ke]of Object.entries(E))ke.submittedAnswers&&(ee[we]=ke.submittedAnswers);return ee},[E]),ae=g.useMemo(()=>new Set(Object.keys(E)),[E]),Je=g.useCallback(async(ee,we)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:ee,answers:we}),q(ee,we)}catch{}},[s,i.sessionId,q]),hn=g.useCallback(async ee=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:ee}),H(ee)}catch{}},[s,i.sessionId,H]),Qs=g.useCallback(async(ee,we)=>{var ke;if(Ee)try{await((ke=e.respondPermission)==null?void 0:ke.call(e,Ee.requestId,ee?"allow":"deny"))}catch{}},[e,Ee]),Il=g.useCallback(async()=>{const ee=i.sessionId;try{await s.sessionStop(ee)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(ee)},[e,s,i.sessionId]),Ko=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):re&&K.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(Ln,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[re,K.length,e.historyError]),ki=e.meta,Go=h.jsxs(h.Fragment,{children:[i.toolSessionId&&y.subagents?h.jsx(Gte,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,Xe&&y.rewind?h.jsx(Xte,{open:!0,onOpenChange:ee=>{ee||nt(null)},api:s,sessionId:i.sessionId,userMessageId:Xe,lines:K,procAlive:ie,onNoChanges:ee=>{xe(we=>{if(we.has(ee))return we;const ke=new Set(we);return ke.add(ee),ke})}}):null,xn?h.jsx(dae,{onConfirm:U,onCancel:()=>tn(!1)}):null]}),Yo={kind:"session",sessionId:i.sessionId},Xo=g.useCallback(async ee=>{if(s)try{await f2(s,$,i.sessionId,ee)}catch(we){const ke=we.message;Ae("chat-panel","open-in-tab failed",{err:ke}),L("err",`Open in tab 失败:${ke}`)}},[s,$,i.sessionId,L]),[ss,Ci]=g.useState(!1),[Qo,Yp]=g.useState(null),It=g.useCallback(ee=>{if(r){r(ee);return}Yp(ee),Ci(!0)},[r]),Fu=g.useCallback(ee=>{if(!s)return;const we=async()=>{try{await s.attachmentGroupAdd(i.sessionId,ee)}catch(Qe){Ae("chat-panel","file-link groupAdd skipped",{err:Qe.message})}},ke=Qe=>{const Mr=Qe.message;Ae("chat-panel","file-link open failed",{err:Mr}),L("err",`打开文件失败:${Mr}`)};if(Dp(ee)){we().then(()=>It(ee),ke);return}f2(s,$,i.sessionId,ee,60,we).catch(ke)},[s,$,i.sessionId,It,L]),Xp=g.useCallback(async ee=>{if(!s)throw new Error("daemon api not ready");const we=await I1(s,$,i.sessionId,ee,60),ke=await fetch(we);if(!ke.ok)throw new Error(`fetch ${ke.status} ${ke.statusText}`);return await ke.text()},[s,$,i.sessionId]),yt=g.useCallback(async(ee,we)=>{if(s)try{const{url:ke}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:ee,ttlSeconds:86400,...we?{view:we}:{}}),Qe=await Boe(ke);L(Qe?"ok":"err",Qe?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(ke){const Qe=ke.message;Ae("chat-panel","share-file failed",{err:Qe}),L("err",`生成分享链接失败:${Qe}`)}},[s,i.sessionId,L]),Pt=g.useCallback(()=>N(null),[]),hr=k==="files"&&D&&s?{title:"Edited Files",onBack:Pt,content:h.jsx(gse,{api:s,scope:Yo,sessionId:i.sessionId,onShareFile:yt,onOpenInTab:Xo,onPreviewMarkdown:It})}:k==="cron"?{title:`定时任务${ue.length?` (${ue.length})`:""}`,onBack:Pt,content:h.jsx("div",{className:"p-3",children:h.jsx(ene,{jobs:ue})})}:k==="persona"&&R&&s&&i.ownerPersonaId?{title:`Persona · ${O??""}`,onBack:Pt,content:h.jsx(Aoe,{personaId:i.ownerPersonaId,open:!0,onClose:Pt,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,Qn=Q==="full"?h.jsx(Vte,{session:i,meta:ki,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...R?{personaName:O}:{},...R?{onOpenPersona:()=>N("persona")}:{},...D?{onOpenFiles:()=>N("files")}:{},cronActiveCount:ue.length,onCronClick:()=>N("cron"),onForceStop:()=>tn(!0),...p?{viewerRole:p}:{},..._!=null&&_.toolSessionIdLabel?{toolSessionIdLabel:_.toolSessionIdLabel}:{},drill:hr,...Pe?{onCollapse:Pe}:{},...Be?{title:Be.title,leadingEntries:Be.leadingEntries}:{}}):null;return h.jsxs(h.Fragment,{children:[ye&&Qn?hl.createPortal(Qn,ye):null,h.jsx(uae,{headerMeta:ki,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:Q,...w?{hideHeader:w}:{},...x?{flatProcess:x}:{},...Q==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:K,pendingPermissions:_e,procAlive:ie,rewindableUserMessageIds:st,onPermissionRespond:Qs,onPermissionInterrupt:gt,onRewind:y.rewind?zt:void 0,...d&&y.fork?{onFork:d}:{},...n&&y.fork?{onQuickAsk:n}:f&&y.fork?{onQuickAsk:f}:{},topSlot:Ko,realtimeQuestionAnswers:Ar,onSubmitQuestion:Je,onCancelQuestion:hn,liveQuestionToolUseIds:ae,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,queued:e.queued,onDequeue:e.dequeue,awaitingUser:_e.length>0||Object.values(E).some(ee=>!ee.submittedAnswers),onAbort:gt,...l?{onNewSession:l}:{},onClearSession:Il,...v?{configSlot:v}:{},chatRootRef:_n,chatBodyRef:$t,drawers:Go,xtermSlot:F==="tui"&&ie&&y.tui?h.jsx(mse,{sessionId:i.sessionId,client:$},i.sessionId):null,fileSharingScope:Yo,...s?{onShareFile:yt}:{},...s?{onOpenInTab:Xo}:{},...s?{onPreviewMarkdown:It}:{},...s?{onOpenFilePath:Fu}:{},dispatchOrigin:M}),s?h.jsx(Foe,{open:ss,onOpenChange:Ci,relPath:Qo,loadMarkdown:Xp,onShare:Qo?()=>void yt(Qo,"md-rendered"):void 0}):null,S?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:S.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:S.text}):null]})}function dae({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(tu,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}const hae={codex:"on-request",claude:"bypassPermissions",pi:"never"};function fae(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??hae[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function pae(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...fae({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Ae("quick-ask","fork rollback failed",o)),s}return i}async function mae(e,t,n){return pae(e,t,n,{ephemeral:!0})}function Fd(e){return e!=null&&e.ephemeral!==!1}async function gae(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const vae=300;function xae(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function _ae(e,t){const n=P_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=xae(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},vae)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function yae(){return{quickAsk:null,mds:[],active:null}}function bae(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function wae(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Sae(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function kae(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Cae(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Eae(e,t){return{...e,active:t}}function Nae(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function E4(e){return e.quickAsk!==null||e.mds.length>0}function Tae(e){return e.split("/").pop()||e}function Iae({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!E4(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(y0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:Tae(c),title:c,icon:h.jsx(gi,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=Nae(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Np,{children:[h.jsx(Tp,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(Rr,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Ru,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(lae,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(C4,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Pae(e){const t=e instanceof Error?e.message:String(e);return t.length>200?`${t.slice(0,200)}…`:t}function Rae({state:e,extras:t}){const{api:n,session:r}=t,i=yi(),[s,o]=g.useState(yae()),[a,l]=g.useState(null),c=r.ownerPersonaId!==QT,u=g.useRef(s);u.current=s;const d=g.useRef(!1),f=g.useCallback(async T=>{const D=u.current.quickAsk;l(null);let P;try{P=await mae(n,r,T)}catch(O){Ae("quick-ask","fork failed",O),d.current||l(Pae(O));return}if(!P){d.current||l("这条会话还没准备好(没有可派生的对话记录),稍后再试");return}if(d.current){n.sessionDelete(P.sessionId).catch(()=>{});return}Fd(D)&&n.sessionDelete(D.sessionId).catch(()=>{}),o(O=>bae(O,{sessionId:P.sessionId}))},[n,r]),p=g.useCallback(async T=>{const D=u.current.quickAsk,P=(D==null?void 0:D.sessionId)===T;try{await gae(n,{sessionId:T,stillEphemeral:P&&Fd(D)})&&o(R=>kae(R))}catch(O){Ae("quick-ask","promote failed",O)}},[n]),m=g.useCallback(T=>{o(D=>wae(D,T))},[]),v=g.useCallback(T=>{o(D=>Eae(D,T))},[]),w=g.useCallback(()=>{const T=u.current.quickAsk;Fd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),o(D=>Sae(D))},[n]),x=g.useCallback(T=>{o(D=>Cae(D,T))},[]);g.useEffect(()=>()=>{d.current=!0;const T=u.current.quickAsk;Fd(T)&&n.sessionDelete(T.sessionId).catch(()=>{})},[]);const _=mi("sessions")??[],y=s.quickAsk?_.find(T=>T.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,S=g.useCallback(async T=>{const D=await I1(n,i,r.sessionId,T,60),P=await fetch(D);if(!P.ok)throw new Error(`fetch ${P.status} ${P.statusText}`);return P.text()},[n,i,r.sessionId]),C=h.jsx(P1,{state:e,extras:t,onQuickAskInternal:f,onPreviewMdInternal:m}),{initialSize:k,setSize:N}=_ae("chat-panel-right-slot-width",480);return h.jsxs($y,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(df,{id:"chat",minSize:"400px",children:h.jsxs("div",{className:"relative flex flex-col min-w-0 min-h-0 h-full",children:[C,a?h.jsxs("div",{"data-testid":"quick-ask-error",className:"absolute bottom-24 left-1/2 z-10 -translate-x-1/2 max-w-[90%] rounded-md border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-300 shadow-lg",children:[h.jsxs("span",{className:"mr-2",children:["问一下没能打开:",a]}),h.jsx("button",{type:"button","aria-label":"关闭提示",onClick:()=>l(null),className:"text-text-400 hover:text-text-200 cursor-pointer",children:"✕"})]}):null]})}),E4(s)?h.jsxs(h.Fragment,{children:[h.jsx(x5,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(df,{id:"right-slot",defaultSize:`${k}px`,minSize:"360px",maxSize:"800px",onResize:T=>N(T.inPixels),children:h.jsx(Iae,{state:s,api:n,onSwitchTab:v,onCloseQuickAsk:w,onCloseMd:x,loadMarkdown:S,quickAskSession:y,...c?{onPromoteQuickAsk:p}:{}})})]}):null]})}function Aae({extras:e}){const t=k5(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(P1,{state:t,extras:e});return h.jsx(cae,{state:t,chat:n,extras:e})}return h.jsx(Rae,{state:t,extras:e})}function Mae(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function jae(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function Lae(e,t){var m,v,w,x;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=Mae(s,n,i),a=o.options,l=a.some(_=>_.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(_=>_.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(_=>_.value===l))==null?void 0:v.label)??null,u=((w=i.find(_=>_.name==="permissionMode"))==null?void 0:w.default)??"",d=r.some(_=>_.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((x=r.find(_=>_.id===d))==null?void 0:x.label)??null;return{modelLabel:jae(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function Dae(e){let t;return e.map(n=>{const r=n.group&&n.group!==t?n.group:null;return n.group&&(t=n.group),{...n,groupHeading:r}})}function Oae({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=Lae({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{},...m.group?{group:m.group}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(Ty,{children:[h.jsx(Iy,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:ne("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(Sp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Lg,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Lg,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Lg,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Lg({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(AW,{children:[h.jsxs(FR,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:ne("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Bn,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(HR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:Dae(s).map((l,c)=>{const u=l.value===n;return h.jsxs(Ke.Fragment,{children:[l.groupHeading?h.jsxs(h.Fragment,{children:[c>0?h.jsx(Py,{}):null,h.jsx(UR,{"data-testid":`${e}-group`,children:l.groupHeading})]}):null,h.jsxs(Mi,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:ne("block text-[12px]",u?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),u?h.jsx(bl,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]})]},l.value||"default")})})]})}function Bae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function zae(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function $ae({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner",hideHeader:f}){const{capabilities:p}=x1(t.tool),[m,v]=g.useState(0),{branch:w}=Bae(e,t.cwd,m),{worktreeRoot:x}=zae(e,t.cwd,m),_=r>1,y=S=>{e.sessionUpdate(t.sessionId,S).catch(C=>{console.error("[session-config] session:update failed",t.sessionId,C)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx($y,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(df,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(Fae,{api:e,session:t,liveGitBranch:w,liveWorktreeRoot:x,onNewSession:o,onTurnEnd:()=>v(S=>S+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(Oae,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:y}):null})})})}),_&&h.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Rr,{className:"w-3.5 h-3.5"})})]})}function Fae({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u,hideHeader:d}){return h.jsx(Aae,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:f=>{a(f)}}:{},...l?{onQuickAsk:f=>{l(f)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{},...d?{hideHeader:d}:{}}})}function Hae({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(yV,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx($ae,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function Uae(){const e=yi(),t=g.useMemo(()=>new J_(e),[e]),n=E$(e),{sessions:r,refresh:i}=N$(n),{personas:s}=SI(),o=M$(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const w=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),x=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),_=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(ey.Provider,{value:o,children:h.jsx(Hae,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void w(S,C),onDeleteSession:S=>void x(S),onEditSession:(S,C)=>void _(S,C),onCloseSession:()=>v(null)})})}const x2="https://app.ttcadvisory.com";function Wae({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${x2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==x2)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const Lx="clawd-visitor:token";function Vae(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function qae(){return{async getUrl(e){const t=localStorage.getItem(Lx);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=Vae(window.location,{});return await pI(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function Kae(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function Gae(){const e=yi(),t=g.useMemo(()=>C$(e),[e]);return h.jsx(o$,{cache:t.cache,children:h.jsx(c$,{children:h.jsx(Uae,{})})})}function Yae({host:e}){const[t]=g.useState(()=>localStorage.getItem(Lx)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>Kae(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return qae().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Vb,{host:e,children:h.jsx(kw,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(r$,{host:e,children:h.jsx(Gae,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(Vb,{host:e,children:h.jsx(kw,{children:h.jsx(Wae,{onAuthed:o=>{localStorage.setItem(Lx,o),window.location.reload()}})})})}function Xae({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Qae(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function Qae(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function Zae({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Jae,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Jae({status:e}){return e==="completed"?h.jsx(up,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(Ln,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(TI,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function ele(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function tle({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(cp,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function nle(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const rle={render:({input:e})=>Ke.createElement(Zae,{items:ele(e)})},ile={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=nle(e);return Ke.createElement(tle,{description:t,prompt:n,subagentType:r})}},N4={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=ole(e),c=l?Ke.createElement(Xae,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Ke.createElement(zA,{tool:sle(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function sle(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function ole(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}El.register("claude","TodoWrite",rle);El.register("claude","Task",ile);El.register("claude","Edit",N4);El.register("claude","Write",N4);const T4=document.getElementById("root");if(!T4)throw new Error("guest-main: #root not found");const ale=aL({});Dg.createRoot(T4).render(h.jsx(Ke.StrictMode,{children:h.jsx(Yae,{host:ale})}));
|