@clawos-dev/clawd 0.2.740 → 0.2.742

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.
@@ -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 sA=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 s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const Lae={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},Fae={motionBase:!0,motionUnit:!0},Bae={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},l7=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:s}=t,i=sA(t,["override"]);let o=Object.assign(Object.assign({},r),{override:s});return o=a7(o),i&&Object.entries(i).forEach(([l,c])=>{const{theme:u}=c,d=sA(c,["theme"]);let h=d;u&&(h=l7(Object.assign(Object.assign({},o),d),{override:d},u)),o[l]=h}),o};function c7(){const{token:e,hashed:t,theme:n,override:r,cssVar:s}=q.useContext(i7),i=`${Dae}-${t||""}`,o=n||s7,[l,c,u]=joe(o,[bg,e],{salt:i,override:r,getComputedToken:l7,formatToken:a7,cssVar:s&&{prefix:s.prefix,key:s.key,unitless:Lae,ignore:Fae,preserve:Bae}});return[o,u,t?c:"",l,s]}const zae=()=>({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"}}),Hae=e=>({[`.${e}`]:Object.assign(Object.assign({},zae()),{[`.${e} .${e}-icon`]:{display:"block"}})}),Uae=(e,t)=>{const[n,r]=c7();return tae({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>Hae(e))},Wae=Object.assign({},kf),{useId:iA}=Wae,Vae=()=>"",qae=typeof iA>"u"?Vae:iA;function Kae(e,t,n){var r;const s=e||{},i=s.inherit===!1||!t?Object.assign(Object.assign({},Tb),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Tb.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=qae();return E9(()=>{var l,c;if(!e)return t;const u=Object.assign({},i.components);Object.keys(e.components||{}).forEach(f=>{u[f]=Object.assign(Object.assign({},u[f]),e.components[f])});const d=`css-var-${o.replace(/:/g,"")}`,h=((l=s.cssVar)!==null&&l!==void 0?l:i.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof i.cssVar=="object"?i.cssVar:{}),typeof s.cssVar=="object"?s.cssVar:{}),{key:typeof s.cssVar=="object"&&((c=s.cssVar)===null||c===void 0?void 0:c.key)||d});return Object.assign(Object.assign(Object.assign({},i),s),{token:Object.assign(Object.assign({},i.token),s.token),components:u,cssVar:h})},[s,i],(l,c)=>l.some((u,d)=>{const h=c[d];return!toe(u,h,!0)}))}var Gae=["children"],u7=p.createContext({});function Yae(e){var t=e.children,n=ci(e,Gae);return p.createElement(u7.Provider,{value:n},t)}var Xae=function(e){Pr(n,e);var t=R9(n);function n(){return Rn(this,n),t.apply(this,arguments)}return Mn(n,[{key:"render",value:function(){return this.props.children}}]),n}(p.Component);function Zae(e){var t=p.useReducer(function(l){return l+1},0),n=_t(t,2),r=n[1],s=p.useRef(e),i=qN(function(){return s.current}),o=qN(function(l){s.current=typeof l=="function"?l(s.current):l,r()});return[i,o]}var Ol="none",i0="appear",o0="enter",a0="leave",oA="none",go="prepare",ah="start",lh="active",A5="end",d7="prepared";function aA(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 Qae(e,t){var n={animationend:aA("Animation","AnimationEnd"),transitionend:aA("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var Jae=Qae(hl(),typeof window<"u"?window:{}),h7={};if(hl()){var ele=document.createElement("div");h7=ele.style}var l0={};function f7(e){if(l0[e])return l0[e];var t=Jae[e];if(t)for(var n=Object.keys(t),r=n.length,s=0;s<r;s+=1){var i=n[s];if(Object.prototype.hasOwnProperty.call(t,i)&&i in h7)return l0[e]=t[i],l0[e]}return""}var p7=f7("animationend"),m7=f7("transitionend"),g7=!!(p7&&m7),lA=p7||"animationend",cA=m7||"transitionend";function uA(e,t){if(!e)return null;if(Tn(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const tle=function(e){var t=p.useRef();function n(s){s&&(s.removeEventListener(cA,e),s.removeEventListener(lA,e))}function r(s){t.current&&t.current!==s&&n(t.current),s&&s!==t.current&&(s.addEventListener(cA,e),s.addEventListener(lA,e),t.current=s)}return p.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var x7=hl()?p.useLayoutEffect:p.useEffect;const nle=function(){var e=p.useRef(null);function t(){SN.cancel(e.current)}function n(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var i=SN(function(){s<=1?r({isCanceled:function(){return i!==e.current}}):n(r,s-1)});e.current=i}return p.useEffect(function(){return function(){t()}},[]),[n,t]};var rle=[go,ah,lh,A5],sle=[go,d7],v7=!1,ile=!0;function y7(e){return e===lh||e===A5}const ole=function(e,t,n){var r=KN(oA),s=_t(r,2),i=s[0],o=s[1],l=nle(),c=_t(l,2),u=c[0],d=c[1];function h(){o(go,!0)}var f=t?sle:rle;return x7(function(){if(i!==oA&&i!==A5){var m=f.indexOf(i),g=f[m+1],x=n(i);x===v7?o(g,!0):g&&u(function(b){function y(){b.isCanceled()||o(g,!0)}x===!0?y():Promise.resolve(x).then(y)})}},[e,i]),p.useEffect(function(){return function(){d()}},[]),[h,i]};function ale(e,t,n,r){var s=r.motionEnter,i=s===void 0?!0:s,o=r.motionAppear,l=o===void 0?!0:o,c=r.motionLeave,u=c===void 0?!0:c,d=r.motionDeadline,h=r.motionLeaveImmediately,f=r.onAppearPrepare,m=r.onEnterPrepare,g=r.onLeavePrepare,x=r.onAppearStart,b=r.onEnterStart,y=r.onLeaveStart,v=r.onAppearActive,w=r.onEnterActive,_=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,C=r.onLeaveEnd,j=r.onVisibleChanged,T=KN(),E=_t(T,2),R=E[0],P=E[1],A=Zae(Ol),O=_t(A,2),F=O[0],z=O[1],W=KN(null),L=_t(W,2),D=L[0],I=L[1],V=F(),H=p.useRef(!1),M=p.useRef(null);function Y(){return n()}var X=p.useRef(!1);function K(){z(Ol),I(null,!0)}var te=qN(function(Be){var Re=F();if(Re!==Ol){var ze=Y();if(!(Be&&!Be.deadline&&Be.target!==ze)){var wt=X.current,St;Re===i0&&wt?St=S==null?void 0:S(ze,Be):Re===o0&&wt?St=k==null?void 0:k(ze,Be):Re===a0&&wt&&(St=C==null?void 0:C(ze,Be)),wt&&St!==!1&&K()}}}),ce=tle(te),ee=_t(ce,1),de=ee[0],be=function(Re){switch(Re){case i0:return Ze(Ze(Ze({},go,f),ah,x),lh,v);case o0:return Ze(Ze(Ze({},go,m),ah,b),lh,w);case a0:return Ze(Ze(Ze({},go,g),ah,y),lh,_);default:return{}}},se=p.useMemo(function(){return be(V)},[V]),ae=ole(V,!e,function(Be){if(Be===go){var Re=se[go];return Re?Re(Y()):v7}if(xe in se){var ze;I(((ze=se[xe])===null||ze===void 0?void 0:ze.call(se,Y(),null))||null)}return xe===lh&&V!==Ol&&(de(Y()),d>0&&(clearTimeout(M.current),M.current=setTimeout(function(){te({deadline:!0})},d))),xe===d7&&K(),ile}),Z=_t(ae,2),fe=Z[0],xe=Z[1],Te=y7(xe);X.current=Te;var Je=p.useRef(null);x7(function(){if(!(H.current&&Je.current===t)){P(t);var Be=H.current;H.current=!0;var Re;!Be&&t&&l&&(Re=i0),Be&&t&&i&&(Re=o0),(Be&&!t&&u||!Be&&h&&!t&&u)&&(Re=a0);var ze=be(Re);Re&&(e||ze[go])?(z(Re),fe()):z(Ol),Je.current=t}},[t]),p.useEffect(function(){(V===i0&&!l||V===o0&&!i||V===a0&&!u)&&z(Ol)},[l,i,u]),p.useEffect(function(){return function(){H.current=!1,clearTimeout(M.current)}},[]);var ve=p.useRef(!1);p.useEffect(function(){R&&(ve.current=!0),R!==void 0&&V===Ol&&((ve.current||R)&&(j==null||j(R)),ve.current=!0)},[R,V]);var Ne=D;return se[go]&&xe===ah&&(Ne=Mt({transition:"none"},Ne)),[V,xe,Ne,R??t]}function lle(e){var t=e;Tn(e)==="object"&&(t=e.transitionSupport);function n(s,i){return!!(s.motionName&&t&&i!==!1)}var r=p.forwardRef(function(s,i){var o=s.visible,l=o===void 0?!0:o,c=s.removeOnLeave,u=c===void 0?!0:c,d=s.forceRender,h=s.children,f=s.motionName,m=s.leavedClassName,g=s.eventProps,x=p.useContext(u7),b=x.motion,y=n(s,b),v=p.useRef(),w=p.useRef();function _(){try{return v.current instanceof HTMLElement?v.current:Bie(w.current)}catch{return null}}var S=ale(y,l,_,s),k=_t(S,4),C=k[0],j=k[1],T=k[2],E=k[3],R=p.useRef(E);E&&(R.current=!0);var P=p.useCallback(function(L){v.current=L,Wie(i,L)},[i]),A,O=Mt(Mt({},g),{},{visible:l});if(!h)A=null;else if(C===Ol)E?A=h(Mt({},O),P):!u&&R.current&&m?A=h(Mt(Mt({},O),{},{className:m}),P):d||!u&&!m?A=h(Mt(Mt({},O),{},{style:{display:"none"}}),P):A=null;else{var F;j===go?F="prepare":y7(j)?F="active":j===ah&&(F="start");var z=uA(f,"".concat(C,"-").concat(F));A=h(Mt(Mt({},O),{},{className:Eie(uA(f,C),Ze(Ze({},z,z&&F),f,typeof f=="string")),style:T}),P)}if(p.isValidElement(A)&&Vie(A)){var W=qie(A);W||(A=p.cloneElement(A,{ref:P}))}return p.createElement(Xae,{ref:w},A)});return r.displayName="CSSMotion",r}const cle=lle(g7);var GN="add",YN="keep",XN="remove",Ck="removed";function ule(e){var t;return e&&Tn(e)==="object"&&"key"in e?t=e:t={key:e},Mt(Mt({},t),{},{key:String(t.key)})}function ZN(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(ule)}function dle(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,s=t.length,i=ZN(e),o=ZN(t);i.forEach(function(u){for(var d=!1,h=r;h<s;h+=1){var f=o[h];if(f.key===u.key){r<h&&(n=n.concat(o.slice(r,h).map(function(m){return Mt(Mt({},m),{},{status:GN})})),r=h),n.push(Mt(Mt({},f),{},{status:YN})),r+=1,d=!0;break}}d||n.push(Mt(Mt({},u),{},{status:XN}))}),r<s&&(n=n.concat(o.slice(r).map(function(u){return Mt(Mt({},u),{},{status:GN})})));var l={};n.forEach(function(u){var d=u.key;l[d]=(l[d]||0)+1});var c=Object.keys(l).filter(function(u){return l[u]>1});return c.forEach(function(u){n=n.filter(function(d){var h=d.key,f=d.status;return h!==u||f!==XN}),n.forEach(function(d){d.key===u&&(d.status=YN)})}),n}var hle=["component","children","onVisibleChanged","onAllRemoved"],fle=["status"],ple=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function mle(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:cle,n=function(r){Pr(i,r);var s=R9(i);function i(){var o;Rn(this,i);for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];return o=s.call.apply(s,[this].concat(c)),Ze(wN(o),"state",{keyEntities:[]}),Ze(wN(o),"removeKey",function(d){o.setState(function(h){var f=h.keyEntities.map(function(m){return m.key!==d?m:Mt(Mt({},m),{},{status:Ck})});return{keyEntities:f}},function(){var h=o.state.keyEntities,f=h.filter(function(m){var g=m.status;return g!==Ck}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return Mn(i,[{key:"render",value:function(){var l=this,c=this.state.keyEntities,u=this.props,d=u.component,h=u.children,f=u.onVisibleChanged;u.onAllRemoved;var m=ci(u,hle),g=d||p.Fragment,x={};return ple.forEach(function(b){x[b]=m[b],delete m[b]}),delete m.keys,p.createElement(g,m,c.map(function(b,y){var v=b.status,w=ci(b,fle),_=v===GN||v===YN;return p.createElement(t,bt({},x,{key:w.key,visible:_,eventProps:w,onVisibleChanged:function(k){f==null||f(k,{key:w.key}),k||l.removeKey(w.key)}}),function(S,k){return h(Mt(Mt({},S),{},{index:y}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(l,c){var u=l.keys,d=c.keyEntities,h=ZN(u),f=dle(d,h);return{keyEntities:f.filter(function(m){var g=d.find(function(x){var b=x.key;return m.key===b});return!(g&&g.status===Ck&&m.status===XN)})}}}]),i}(p.Component);return Ze(n,"defaultProps",{component:"div"}),n}mle(g7);const dA=p.createContext(!0);function gle(e){const t=p.useContext(dA),{children:n}=e,[,r]=c7(),{motion:s}=r,i=p.useRef(!1);return i.current||(i.current=t!==s),i.current?p.createElement(dA.Provider,{value:s},p.createElement(Yae,{motion:s},n)):n}const xle=()=>null;var vle=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 s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const yle=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let b7;function ble(){return b7||WN}function wle(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const _le=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:s}=e;t!==void 0&&(b7=t),r&&wle(r)&&Tae(ble(),r)},Sle=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:s,anchor:i,form:o,locale:l,componentSize:c,direction:u,space:d,splitter:h,virtual:f,dropdownMatchSelectWidth:m,popupMatchSelectWidth:g,popupOverflow:x,legacyLocale:b,parentContext:y,iconPrefixCls:v,theme:w,componentDisabled:_,segmented:S,statistic:k,spin:C,calendar:j,carousel:T,cascader:E,collapse:R,typography:P,checkbox:A,descriptions:O,divider:F,drawer:z,skeleton:W,steps:L,image:D,layout:I,list:V,mentions:H,modal:M,progress:Y,result:X,slider:K,breadcrumb:te,menu:ce,pagination:ee,input:de,textArea:be,empty:se,badge:ae,radio:Z,rate:fe,switch:xe,transfer:Te,avatar:Je,message:ve,tag:Ne,table:Be,card:Re,tabs:ze,timeline:wt,timePicker:St,upload:oe,notification:le,tree:me,colorPicker:Ke,datePicker:Ge,rangePicker:ut,flex:tn,wave:qe,dropdown:Zt,warning:Se,tour:Pe,tooltip:dt,popover:Pt,popconfirm:hn,floatButton:we,floatButtonGroup:ne,variant:Oe,inputNumber:it,treeSelect:nt}=e,kt=p.useCallback((Ct,Ut)=>{const{prefixCls:hr}=e;if(Ut)return Ut;const rr=hr||y.getPrefixCls("");return Ct?`${rr}-${Ct}`:rr},[y.getPrefixCls,e.prefixCls]),At=v||y.iconPrefixCls||o7,zt=n||y.csp;Uae(At,zt);const sn=Kae(w,y.theme,{prefixCls:kt("")}),$n={csp:zt,autoInsertSpaceInButton:r,alert:s,anchor:i,locale:l||b,direction:u,space:d,splitter:h,virtual:f,popupMatchSelectWidth:g??m,popupOverflow:x,getPrefixCls:kt,iconPrefixCls:At,theme:sn,segmented:S,statistic:k,spin:C,calendar:j,carousel:T,cascader:E,collapse:R,typography:P,checkbox:A,descriptions:O,divider:F,drawer:z,skeleton:W,steps:L,image:D,input:de,textArea:be,layout:I,list:V,mentions:H,modal:M,progress:Y,result:X,slider:K,breadcrumb:te,menu:ce,pagination:ee,empty:se,badge:ae,radio:Z,rate:fe,switch:xe,transfer:Te,avatar:Je,message:ve,tag:Ne,table:Be,card:Re,tabs:ze,timeline:wt,timePicker:St,upload:oe,notification:le,tree:me,colorPicker:Ke,datePicker:Ge,rangePicker:ut,flex:tn,wave:qe,dropdown:Zt,warning:Se,tour:Pe,tooltip:dt,popover:Pt,popconfirm:hn,floatButton:we,floatButtonGroup:ne,variant:Oe,inputNumber:it,treeSelect:nt},Lt=Object.assign({},y);Object.keys($n).forEach(Ct=>{$n[Ct]!==void 0&&(Lt[Ct]=$n[Ct])}),yle.forEach(Ct=>{const Ut=e[Ct];Ut&&(Lt[Ct]=Ut)}),typeof r<"u"&&(Lt.button=Object.assign({autoInsertSpace:r},Lt.button));const xn=E9(()=>Lt,Lt,(Ct,Ut)=>{const hr=Object.keys(Ct),rr=Object.keys(Ut);return hr.length!==rr.length||hr.some(fr=>Ct[fr]!==Ut[fr])}),{layer:yn}=p.useContext(Cw),Sn=p.useMemo(()=>({prefixCls:At,csp:zt,layer:yn?"antd":void 0}),[At,zt,yn]);let Qt=p.createElement(p.Fragment,null,p.createElement(xle,{dropdownMatchSelectWidth:m}),t);const _e=p.useMemo(()=>{var Ct,Ut,hr,rr;return lae(((Ct=Ew.Form)===null||Ct===void 0?void 0:Ct.defaultValidateMessages)||{},((hr=(Ut=xn.locale)===null||Ut===void 0?void 0:Ut.Form)===null||hr===void 0?void 0:hr.defaultValidateMessages)||{},((rr=xn.form)===null||rr===void 0?void 0:rr.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[xn,o==null?void 0:o.validateMessages]);Object.keys(_e).length>0&&(Qt=p.createElement(uae.Provider,{value:_e},Qt)),l&&(Qt=p.createElement(fae,{locale:l,_ANT_MARK__:hae},Qt)),Qt=p.createElement(iae.Provider,{value:Sn},Qt),c&&(Qt=p.createElement(Mae,{size:c},Qt)),Qt=p.createElement(gle,null,Qt);const vt=p.useMemo(()=>{const Ct=sn||{},{algorithm:Ut,token:hr,components:rr,cssVar:fr}=Ct,eo=vle(Ct,["algorithm","token","components","cssVar"]),wi=Ut&&(!Array.isArray(Ut)||Ut.length>0)?NN(Ut):s7,to={};Object.entries(rr||{}).forEach(([no,ro])=>{const Wt=Object.assign({},ro);"algorithm"in Wt&&(Wt.algorithm===!0?Wt.theme=wi:(Array.isArray(Wt.algorithm)||typeof Wt.algorithm=="function")&&(Wt.theme=NN(Wt.algorithm)),delete Wt.algorithm),to[no]=Wt});const ja=Object.assign(Object.assign({},bg),hr);return Object.assign(Object.assign({},eo),{theme:wi,token:ja,components:to,override:Object.assign({override:ja},to),cssVar:fr})},[sn]);return w&&(Qt=p.createElement(i7.Provider,{value:vt},Qt)),xn.warning&&(Qt=p.createElement(cae.Provider,{value:xn.warning},Qt)),_!==void 0&&(Qt=p.createElement(Rae,{disabled:_},Qt)),p.createElement(Iw.Provider,{value:xn},Qt)},Ef=e=>{const t=p.useContext(Iw),n=p.useContext(e7);return p.createElement(Sle,Object.assign({parentContext:t,legacyLocale:n},e))};Ef.ConfigContext=Iw;Ef.SizeContext=wg;Ef.config=_le;Ef.useConfig=Pae;Object.defineProperty(Ef,"SizeContext",{get:()=>wg});var w7={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Br,function(){var n=1e3,r=6e4,s=36e5,i="millisecond",o="second",l="minute",c="hour",u="day",d="week",h="month",f="quarter",m="year",g="date",x="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(O){var F=["th","st","nd","rd"],z=O%100;return"["+O+(F[(z-20)%10]||F[z]||F[0])+"]"}},w=function(O,F,z){var W=String(O);return!W||W.length>=F?O:""+Array(F+1-W.length).join(z)+O},_={s:w,z:function(O){var F=-O.utcOffset(),z=Math.abs(F),W=Math.floor(z/60),L=z%60;return(F<=0?"+":"-")+w(W,2,"0")+":"+w(L,2,"0")},m:function O(F,z){if(F.date()<z.date())return-O(z,F);var W=12*(z.year()-F.year())+(z.month()-F.month()),L=F.clone().add(W,h),D=z-L<0,I=F.clone().add(W+(D?-1:1),h);return+(-(W+(z-L)/(D?L-I:I-L))||0)},a:function(O){return O<0?Math.ceil(O)||0:Math.floor(O)},p:function(O){return{M:h,y:m,w:d,d:u,D:g,h:c,m:l,s:o,ms:i,Q:f}[O]||String(O||"").toLowerCase().replace(/s$/,"")},u:function(O){return O===void 0}},S="en",k={};k[S]=v;var C="$isDayjsObject",j=function(O){return O instanceof P||!(!O||!O[C])},T=function O(F,z,W){var L;if(!F)return S;if(typeof F=="string"){var D=F.toLowerCase();k[D]&&(L=D),z&&(k[D]=z,L=D);var I=F.split("-");if(!L&&I.length>1)return O(I[0])}else{var V=F.name;k[V]=F,L=V}return!W&&L&&(S=L),L||!W&&S},E=function(O,F){if(j(O))return O.clone();var z=typeof F=="object"?F:{};return z.date=O,z.args=arguments,new P(z)},R=_;R.l=T,R.i=j,R.w=function(O,F){return E(O,{locale:F.$L,utc:F.$u,x:F.$x,$offset:F.$offset})};var P=function(){function O(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[C]=!0}var F=O.prototype;return F.parse=function(z){this.$d=function(W){var L=W.date,D=W.utc;if(L===null)return new Date(NaN);if(R.u(L))return new Date;if(L instanceof Date)return new Date(L);if(typeof L=="string"&&!/Z$/i.test(L)){var I=L.match(b);if(I){var V=I[2]-1||0,H=(I[7]||"0").substring(0,3);return D?new Date(Date.UTC(I[1],V,I[3]||1,I[4]||0,I[5]||0,I[6]||0,H)):new Date(I[1],V,I[3]||1,I[4]||0,I[5]||0,I[6]||0,H)}}return new Date(L)}(z),this.init()},F.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},F.$utils=function(){return R},F.isValid=function(){return this.$d.toString()!==x},F.isSame=function(z,W){var L=E(z);return this.startOf(W)<=L&&L<=this.endOf(W)},F.isAfter=function(z,W){return E(z)<this.startOf(W)},F.isBefore=function(z,W){return this.endOf(W)<E(z)},F.$g=function(z,W,L){return R.u(z)?this[W]:this.set(L,z)},F.unix=function(){return Math.floor(this.valueOf()/1e3)},F.valueOf=function(){return this.$d.getTime()},F.startOf=function(z,W){var L=this,D=!!R.u(W)||W,I=R.p(z),V=function(ee,de){var be=R.w(L.$u?Date.UTC(L.$y,de,ee):new Date(L.$y,de,ee),L);return D?be:be.endOf(u)},H=function(ee,de){return R.w(L.toDate()[ee].apply(L.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(de)),L)},M=this.$W,Y=this.$M,X=this.$D,K="set"+(this.$u?"UTC":"");switch(I){case m:return D?V(1,0):V(31,11);case h:return D?V(1,Y):V(0,Y+1);case d:var te=this.$locale().weekStart||0,ce=(M<te?M+7:M)-te;return V(D?X-ce:X+(6-ce),Y);case u:case g:return H(K+"Hours",0);case c:return H(K+"Minutes",1);case l:return H(K+"Seconds",2);case o:return H(K+"Milliseconds",3);default:return this.clone()}},F.endOf=function(z){return this.startOf(z,!1)},F.$set=function(z,W){var L,D=R.p(z),I="set"+(this.$u?"UTC":""),V=(L={},L[u]=I+"Date",L[g]=I+"Date",L[h]=I+"Month",L[m]=I+"FullYear",L[c]=I+"Hours",L[l]=I+"Minutes",L[o]=I+"Seconds",L[i]=I+"Milliseconds",L)[D],H=D===u?this.$D+(W-this.$W):W;if(D===h||D===m){var M=this.clone().set(g,1);M.$d[V](H),M.init(),this.$d=M.set(g,Math.min(this.$D,M.daysInMonth())).$d}else V&&this.$d[V](H);return this.init(),this},F.set=function(z,W){return this.clone().$set(z,W)},F.get=function(z){return this[R.p(z)]()},F.add=function(z,W){var L,D=this;z=Number(z);var I=R.p(W),V=function(Y){var X=E(D);return R.w(X.date(X.date()+Math.round(Y*z)),D)};if(I===h)return this.set(h,this.$M+z);if(I===m)return this.set(m,this.$y+z);if(I===u)return V(1);if(I===d)return V(7);var H=(L={},L[l]=r,L[c]=s,L[o]=n,L)[I]||1,M=this.$d.getTime()+z*H;return R.w(M,this)},F.subtract=function(z,W){return this.add(-1*z,W)},F.format=function(z){var W=this,L=this.$locale();if(!this.isValid())return L.invalidDate||x;var D=z||"YYYY-MM-DDTHH:mm:ssZ",I=R.z(this),V=this.$H,H=this.$m,M=this.$M,Y=L.weekdays,X=L.months,K=L.meridiem,te=function(de,be,se,ae){return de&&(de[be]||de(W,D))||se[be].slice(0,ae)},ce=function(de){return R.s(V%12||12,de,"0")},ee=K||function(de,be,se){var ae=de<12?"AM":"PM";return se?ae.toLowerCase():ae};return D.replace(y,function(de,be){return be||function(se){switch(se){case"YY":return String(W.$y).slice(-2);case"YYYY":return R.s(W.$y,4,"0");case"M":return M+1;case"MM":return R.s(M+1,2,"0");case"MMM":return te(L.monthsShort,M,X,3);case"MMMM":return te(X,M);case"D":return W.$D;case"DD":return R.s(W.$D,2,"0");case"d":return String(W.$W);case"dd":return te(L.weekdaysMin,W.$W,Y,2);case"ddd":return te(L.weekdaysShort,W.$W,Y,3);case"dddd":return Y[W.$W];case"H":return String(V);case"HH":return R.s(V,2,"0");case"h":return ce(1);case"hh":return ce(2);case"a":return ee(V,H,!0);case"A":return ee(V,H,!1);case"m":return String(H);case"mm":return R.s(H,2,"0");case"s":return String(W.$s);case"ss":return R.s(W.$s,2,"0");case"SSS":return R.s(W.$ms,3,"0");case"Z":return I}return null}(de)||I.replace(":","")})},F.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},F.diff=function(z,W,L){var D,I=this,V=R.p(W),H=E(z),M=(H.utcOffset()-this.utcOffset())*r,Y=this-H,X=function(){return R.m(I,H)};switch(V){case m:D=X()/12;break;case h:D=X();break;case f:D=X()/3;break;case d:D=(Y-M)/6048e5;break;case u:D=(Y-M)/864e5;break;case c:D=Y/s;break;case l:D=Y/r;break;case o:D=Y/n;break;default:D=Y}return L?D:R.a(D)},F.daysInMonth=function(){return this.endOf(h).$D},F.$locale=function(){return k[this.$L]},F.locale=function(z,W){if(!z)return this.$L;var L=this.clone(),D=T(z,W,!0);return D&&(L.$L=D),L},F.clone=function(){return R.w(this.$d,this)},F.toDate=function(){return new Date(this.valueOf())},F.toJSON=function(){return this.isValid()?this.toISOString():null},F.toISOString=function(){return this.$d.toISOString()},F.toString=function(){return this.$d.toUTCString()},O}(),A=P.prototype;return E.prototype=A,[["$ms",i],["$s",o],["$m",l],["$H",c],["$W",u],["$M",h],["$y",m],["$D",g]].forEach(function(O){A[O[1]]=function(F){return this.$g(F,O[0],O[1])}}),E.extend=function(O,F){return O.$i||(O(F,P,E),O.$i=!0),E},E.locale=T,E.isDayjs=j,E.unix=function(O){return E(1e3*O)},E.en=k[S],E.Ls=k,E.p={},E})})(w7);var kle=w7.exports;const QN=vn(kle);var _7={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Br,function(){return function(n,r,s){var i=r.prototype,o=function(h){return h&&(h.indexOf?h:h.s)},l=function(h,f,m,g,x){var b=h.name?h:h.$locale(),y=o(b[f]),v=o(b[m]),w=y||v.map(function(S){return S.slice(0,g)});if(!x)return w;var _=b.weekStart;return w.map(function(S,k){return w[(k+(_||0))%7]})},c=function(){return s.Ls[s.locale()]},u=function(h,f){return h.formats[f]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(g,x,b){return x||b.slice(1)})}(h.formats[f.toUpperCase()])},d=function(){var h=this;return{months:function(f){return f?f.format("MMMM"):l(h,"months")},monthsShort:function(f){return f?f.format("MMM"):l(h,"monthsShort","months",3)},firstDayOfWeek:function(){return h.$locale().weekStart||0},weekdays:function(f){return f?f.format("dddd"):l(h,"weekdays")},weekdaysMin:function(f){return f?f.format("dd"):l(h,"weekdaysMin","weekdays",2)},weekdaysShort:function(f){return f?f.format("ddd"):l(h,"weekdaysShort","weekdays",3)},longDateFormat:function(f){return u(h.$locale(),f)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return d.bind(this)()},s.localeData=function(){var h=c();return{firstDayOfWeek:function(){return h.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(f){return u(h,f)},meridiem:h.meridiem,ordinal:h.ordinal}},s.months=function(){return l(c(),"months")},s.monthsShort=function(){return l(c(),"monthsShort","months",3)},s.weekdays=function(h){return l(c(),"weekdays",null,null,h)},s.weekdaysShort=function(h){return l(c(),"weekdaysShort","weekdays",3,h)},s.weekdaysMin=function(h){return l(c(),"weekdaysMin","weekdays",2,h)}}})})(_7);var Cle=_7.exports;const Nle=vn(Cle),Ci=(e,t)=>new Un(e).setA(t).toRgbString(),jd=(e,t)=>new Un(e).lighten(t).toHexString(),jle=e=>{const t=Bh(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]}},Ele=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:Ci(r,.85),colorTextSecondary:Ci(r,.65),colorTextTertiary:Ci(r,.45),colorTextQuaternary:Ci(r,.25),colorFill:Ci(r,.18),colorFillSecondary:Ci(r,.12),colorFillTertiary:Ci(r,.08),colorFillQuaternary:Ci(r,.04),colorBgSolid:Ci(r,.95),colorBgSolidHover:Ci(r,1),colorBgSolidActive:Ci(r,.9),colorBgElevated:jd(n,12),colorBgContainer:jd(n,8),colorBgLayout:jd(n,0),colorBgSpotlight:jd(n,26),colorBgBlur:Ci(r,.04),colorBorder:jd(n,26),colorBorderSecondary:jd(n,19)}},Ile=(e,t)=>{const n=Object.keys(M5).map(i=>{const o=Bh(e[i],{theme:"dark"});return Array.from({length:10},()=>1).reduce((l,c,u)=>(l[`${i}-${u+1}`]=o[u],l[`${i}${u+1}`]=o[u],l),{})}).reduce((i,o)=>(i=Object.assign(Object.assign({},i),o),i),{}),r=t??P5(e),s=r7(e,{generateColorPalettes:jle,generateNeutralColorPalettes:Ele});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),s),{colorPrimaryBg:s.colorPrimaryBorder,colorPrimaryBgHover:s.colorPrimaryBorderHover})},hA={defaultSeed:Tb.token,defaultAlgorithm:P5,darkAlgorithm:Ile};function Tle({children:e}){const t=dl(),[n,r]=p.useState(t.theme);return p.useEffect(()=>t.onThemeChange(r),[t]),a.jsx(Ef,{theme:{algorithm:n.mode==="dark"?hA.darkAlgorithm:hA.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Yt;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),o={};for(const l of i)o[l]=s[l];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},e.find=(s,i)=>{for(const o of s)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Yt||(Yt={}));var fA;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(fA||(fA={}));const Xe=Yt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Fl=e=>{switch(typeof e){case"undefined":return Xe.undefined;case"string":return Xe.string;case"number":return Number.isNaN(e)?Xe.nan:Xe.number;case"boolean":return Xe.boolean;case"function":return Xe.function;case"bigint":return Xe.bigint;case"symbol":return Xe.symbol;case"object":return Array.isArray(e)?Xe.array:e===null?Xe.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Xe.promise:typeof Map<"u"&&e instanceof Map?Xe.map:typeof Set<"u"&&e instanceof Set?Xe.set:typeof Date<"u"&&e instanceof Date?Xe.date:Xe.object;default:return Xe.unknown}},ke=Yt.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 rl 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(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let l=r,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(n(o))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}};return s(this),r}static assert(t){if(!(t instanceof rl))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Yt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(t(s))}else r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}rl.create=e=>new rl(e);const JN=(e,t)=>{let n;switch(e.code){case ke.invalid_type:e.received===Xe.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ke.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Yt.jsonStringifyReplacer)}`;break;case ke.unrecognized_keys:n=`Unrecognized key(s) in object: ${Yt.joinValues(e.keys,", ")}`;break;case ke.invalid_union:n="Invalid input";break;case ke.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Yt.joinValues(e.options)}`;break;case ke.invalid_enum_value:n=`Invalid enum value. Expected ${Yt.joinValues(e.options)}, received '${e.received}'`;break;case ke.invalid_arguments:n="Invalid function arguments";break;case ke.invalid_return_type:n="Invalid function return type";break;case ke.invalid_date:n="Invalid date";break;case ke.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}"`:Yt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ke.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 ke.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 ke.custom:n="Invalid input";break;case ke.invalid_intersection_types:n="Intersection results could not be merged";break;case ke.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ke.not_finite:n="Number must be finite";break;default:n=t.defaultError,Yt.assertNever(e)}return{message:n}};let Rle=JN;function Mle(){return Rle}const Ple=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let l="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)l=u(o,{data:t,defaultError:l}).message;return{...s,path:i,message:l}};function Le(e,t){const n=Mle(),r=Ple({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===JN?void 0:JN].filter(s=>!!s)});e.common.issues.push(r)}class ys{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 s of n){if(s.status==="aborted")return mt;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return ys.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return mt;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:t.value,value:r}}}const mt=Object.freeze({status:"aborted"}),im=e=>({status:"dirty",value:e}),Gi=e=>({status:"valid",value:e}),pA=e=>e.status==="aborted",mA=e=>e.status==="dirty",zh=e=>e.status==="valid",Rb=e=>typeof Promise<"u"&&e instanceof Promise;var rt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(rt||(rt={}));class da{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}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 gA=(e,t)=>{if(zh(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 rl(e.common.issues);return this._error=n,this._error}}};function jt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=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:s}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??r??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:s}}class Bt{get description(){return this._def.description}_getType(t){return Fl(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Fl(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ys,ctx:{common:t.parent.common,data:t.data,parsedType:Fl(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Rb(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:Fl(t)},s=this._parseSync({data:t,path:r.path,parent:r});return gA(r,s)}"~validate"(t){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Fl(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return zh(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>zh(i)?{value:i.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:Fl(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(Rb(s)?s:Promise.resolve(s));return gA(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=t(s),l=()=>i.addIssue({code:ke.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new mc({schema:this,typeName:gt.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 Xa.create(this,this._def)}nullable(){return Eu.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ia.create(this)}promise(){return $b.create(this,this._def)}or(t){return Pb.create([this,t],this._def)}and(t){return Ab.create(this,t,this._def)}transform(t){return new mc({...jt(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Lb({...jt(this._def),innerType:this,defaultValue:n,typeName:gt.ZodDefault})}brand(){return new N7({typeName:gt.ZodBranded,type:this,...jt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Fb({...jt(this._def),innerType:this,catchValue:n,typeName:gt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return D5.create(this,t)}readonly(){return Bb.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ale=/^c[^\s-]{8,}$/i,Ole=/^[0-9a-z]+$/,Dle=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$le=/^[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,Lle=/^[a-z0-9_-]{21}$/i,Fle=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ble=/^[-+]?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)?)??$/,zle=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hle="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nk;const Ule=/^(?:(?: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])$/,Wle=/^(?:(?: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])$/,Vle=/^(([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]))$/,qle=/^(([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])$/,Kle=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gle=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,S7="((\\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])))",Yle=new RegExp(`^${S7}$`);function k7(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 Xle(e){return new RegExp(`^${k7(e)}$`)}function Zle(e){let t=`${S7}T${k7(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 Qle(e,t){return!!((t==="v4"||!t)&&Ule.test(e)||(t==="v6"||!t)&&Vle.test(e))}function Jle(e,t){if(!Fle.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,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function ece(e,t){return!!((t==="v4"||!t)&&Wle.test(e)||(t==="v6"||!t)&&qle.test(e))}class Va extends Bt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Xe.string){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_type,expected:Xe.string,received:i.parsedType}),mt}const r=new ys;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(t,s),o?Le(s,{code:ke.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&Le(s,{code:ke.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")zle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"email",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Nk||(Nk=new RegExp(Hle,"u")),Nk.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"emoji",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")$le.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"uuid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Lle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"nanoid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Ale.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"cuid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Ole.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"cuid2",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Dle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"ulid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),Le(s,{validation:"url",code:ke.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"regex",code:ke.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Zle(i).test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Yle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Xle(i).test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ble.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"duration",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Qle(t.data,i.version)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"ip",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Jle(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"jwt",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?ece(t.data,i.version)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"cidr",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Kle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"base64",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Gle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"base64url",code:ke.invalid_string,message:i.message}),r.dirty()):Yt.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:ke.invalid_string,...rt.errToObj(r)})}_addCheck(t){return new Va({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...rt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...rt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...rt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...rt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...rt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...rt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...rt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...rt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...rt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...rt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...rt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...rt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...rt.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,...rt.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,...rt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...rt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...rt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...rt.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...rt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...rt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...rt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...rt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...rt.errToObj(n)})}nonempty(t){return this.min(1,rt.errToObj(t))}trim(){return new Va({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Va({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Va({...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}}Va.create=e=>new Va({checks:[],typeName:gt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...jt(e)});function tce(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}class Hh extends Bt{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)!==Xe.number){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_type,expected:Xe.number,received:i.parsedType}),mt}let r;const s=new ys;for(const i of this._def.checks)i.kind==="int"?Yt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?tce(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.not_finite,message:i.message}),s.dirty()):Yt.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,rt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,rt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,rt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,rt.toString(n))}setLimit(t,n,r,s){return new Hh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:rt.toString(s)}]})}_addCheck(t){return new Hh({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:rt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:rt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:rt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:rt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:rt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:rt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:rt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:rt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:rt.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"&&Yt.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)}}Hh.create=e=>new Hh({checks:[],typeName:gt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...jt(e)});class _g extends Bt{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)!==Xe.bigint)return this._getInvalidInput(t);let r;const s=new ys;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Yt.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Le(n,{code:ke.invalid_type,expected:Xe.bigint,received:n.parsedType}),mt}gte(t,n){return this.setLimit("min",t,!0,rt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,rt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,rt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,rt.toString(n))}setLimit(t,n,r,s){return new _g({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:rt.toString(s)}]})}_addCheck(t){return new _g({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:rt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:rt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:rt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:rt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:rt.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}}_g.create=e=>new _g({checks:[],typeName:gt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...jt(e)});class ej extends Bt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Xe.boolean){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.boolean,received:r.parsedType}),mt}return Gi(t.data)}}ej.create=e=>new ej({typeName:gt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...jt(e)});class Mb extends Bt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Xe.date){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_type,expected:Xe.date,received:i.parsedType}),mt}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_date}),mt}const r=new ys;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Yt.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Mb({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:rt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:rt.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}}Mb.create=e=>new Mb({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:gt.ZodDate,...jt(e)});class xA extends Bt{_parse(t){if(this._getType(t)!==Xe.symbol){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.symbol,received:r.parsedType}),mt}return Gi(t.data)}}xA.create=e=>new xA({typeName:gt.ZodSymbol,...jt(e)});class tj extends Bt{_parse(t){if(this._getType(t)!==Xe.undefined){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.undefined,received:r.parsedType}),mt}return Gi(t.data)}}tj.create=e=>new tj({typeName:gt.ZodUndefined,...jt(e)});class nj extends Bt{_parse(t){if(this._getType(t)!==Xe.null){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.null,received:r.parsedType}),mt}return Gi(t.data)}}nj.create=e=>new nj({typeName:gt.ZodNull,...jt(e)});class vA extends Bt{constructor(){super(...arguments),this._any=!0}_parse(t){return Gi(t.data)}}vA.create=e=>new vA({typeName:gt.ZodAny,...jt(e)});class rj extends Bt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Gi(t.data)}}rj.create=e=>new rj({typeName:gt.ZodUnknown,...jt(e)});class pc extends Bt{_parse(t){const n=this._getOrReturnCtx(t);return Le(n,{code:ke.invalid_type,expected:Xe.never,received:n.parsedType}),mt}}pc.create=e=>new pc({typeName:gt.ZodNever,...jt(e)});class yA extends Bt{_parse(t){if(this._getType(t)!==Xe.undefined){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.void,received:r.parsedType}),mt}return Gi(t.data)}}yA.create=e=>new yA({typeName:gt.ZodVoid,...jt(e)});class ia extends Bt{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==Xe.array)return Le(n,{code:ke.invalid_type,expected:Xe.array,received:n.parsedType}),mt;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(o||l)&&(Le(n,{code:o?ke.too_big:ke.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(Le(n,{code:ke.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(Le(n,{code:ke.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>s.type._parseAsync(new da(n,o,n.path,l)))).then(o=>ys.mergeArray(r,o));const i=[...n.data].map((o,l)=>s.type._parseSync(new da(n,o,n.path,l)));return ys.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new ia({...this._def,minLength:{value:t,message:rt.toString(n)}})}max(t,n){return new ia({...this._def,maxLength:{value:t,message:rt.toString(n)}})}length(t,n){return new ia({...this._def,exactLength:{value:t,message:rt.toString(n)}})}nonempty(t){return this.min(1,t)}}ia.create=(e,t)=>new ia({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...jt(t)});function Vd(e){if(e instanceof or){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Xa.create(Vd(r))}return new or({...e._def,shape:()=>t})}else return e instanceof ia?new ia({...e._def,type:Vd(e.element)}):e instanceof Xa?Xa.create(Vd(e.unwrap())):e instanceof Eu?Eu.create(Vd(e.unwrap())):e instanceof Nu?Nu.create(e.items.map(t=>Vd(t))):e}class or extends Bt{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=Yt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Xe.object){const u=this._getOrReturnCtx(t);return Le(u,{code:ke.invalid_type,expected:Xe.object,received:u.parsedType}),mt}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof pc&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||l.push(u);const c=[];for(const u of o){const d=i[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new da(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof pc){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of l)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")l.length>0&&(Le(s,{code:ke.unrecognized_keys,keys:l}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of l){const h=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new da(s,h,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const h=await d.key,f=await d.value;u.push({key:h,value:f,alwaysSet:d.alwaysSet})}return u}).then(u=>ys.mergeObjectSync(r,u)):ys.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return rt.errToObj,new or({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:rt.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new or({...this._def,unknownKeys:"strip"})}passthrough(){return new or({...this._def,unknownKeys:"passthrough"})}extend(t){return new or({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new or({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new or({...this._def,catchall:t})}pick(t){const n={};for(const r of Yt.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new or({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Yt.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new or({...this._def,shape:()=>n})}deepPartial(){return Vd(this)}partial(t){const n={};for(const r of Yt.objectKeys(this.shape)){const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}return new or({...this._def,shape:()=>n})}required(t){const n={};for(const r of Yt.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Xa;)i=i._def.innerType;n[r]=i}return new or({...this._def,shape:()=>n})}keyof(){return C7(Yt.objectKeys(this.shape))}}or.create=(e,t)=>new or({shape:()=>e,unknownKeys:"strip",catchall:pc.create(),typeName:gt.ZodObject,...jt(t)});or.strictCreate=(e,t)=>new or({shape:()=>e,unknownKeys:"strict",catchall:pc.create(),typeName:gt.ZodObject,...jt(t)});or.lazycreate=(e,t)=>new or({shape:e,unknownKeys:"strip",catchall:pc.create(),typeName:gt.ZodObject,...jt(t)});class Pb extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new rl(l.ctx.common.issues));return Le(n,{code:ke.invalid_union,unionErrors:o}),mt}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new rl(c));return Le(n,{code:ke.invalid_union,unionErrors:l}),mt}}get options(){return this._def.options}}Pb.create=(e,t)=>new Pb({options:e,typeName:gt.ZodUnion,...jt(t)});const Ba=e=>e instanceof ij?Ba(e.schema):e instanceof mc?Ba(e.innerType()):e instanceof Db?[e.value]:e instanceof ju?e.options:e instanceof oj?Yt.objectValues(e.enum):e instanceof Lb?Ba(e._def.innerType):e instanceof tj?[void 0]:e instanceof nj?[null]:e instanceof Xa?[void 0,...Ba(e.unwrap())]:e instanceof Eu?[null,...Ba(e.unwrap())]:e instanceof N7||e instanceof Bb?Ba(e.unwrap()):e instanceof Fb?Ba(e._def.innerType):[];class O5 extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Xe.object)return Le(n,{code:ke.invalid_type,expected:Xe.object,received:n.parsedType}),mt;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(Le(n,{code:ke.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),mt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const o=Ba(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of o){if(s.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);s.set(l,i)}}return new O5({typeName:gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...jt(r)})}}function sj(e,t){const n=Fl(e),r=Fl(t);if(e===t)return{valid:!0,data:e};if(n===Xe.object&&r===Xe.object){const s=Yt.objectKeys(t),i=Yt.objectKeys(e).filter(l=>s.indexOf(l)!==-1),o={...e,...t};for(const l of i){const c=sj(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(n===Xe.array&&r===Xe.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const o=e[i],l=t[i],c=sj(o,l);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===Xe.date&&r===Xe.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Ab extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,o)=>{if(pA(i)||pA(o))return mt;const l=sj(i.value,o.value);return l.valid?((mA(i)||mA(o))&&n.dirty(),{status:n.value,value:l.data}):(Le(r,{code:ke.invalid_intersection_types}),mt)};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(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ab.create=(e,t,n)=>new Ab({left:e,right:t,typeName:gt.ZodIntersection,...jt(n)});class Nu extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Xe.array)return Le(r,{code:ke.invalid_type,expected:Xe.array,received:r.parsedType}),mt;if(r.data.length<this._def.items.length)return Le(r,{code:ke.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),mt;!this._def.rest&&r.data.length>this._def.items.length&&(Le(r,{code:ke.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new da(r,o,r.path,l)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>ys.mergeArray(n,o)):ys.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new Nu({...this._def,rest:t})}}Nu.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nu({items:e,typeName:gt.ZodTuple,rest:null,...jt(t)})};class Ob extends Bt{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!==Xe.object)return Le(r,{code:ke.invalid_type,expected:Xe.object,received:r.parsedType}),mt;const s=[],i=this._def.keyType,o=this._def.valueType;for(const l in r.data)s.push({key:i._parse(new da(r,l,r.path,l)),value:o._parse(new da(r,r.data[l],r.path,l)),alwaysSet:l in r.data});return r.common.async?ys.mergeObjectAsync(n,s):ys.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Bt?new Ob({keyType:t,valueType:n,typeName:gt.ZodRecord,...jt(r)}):new Ob({keyType:Va.create(),valueType:t,typeName:gt.ZodRecord,...jt(n)})}}class bA extends Bt{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!==Xe.map)return Le(r,{code:ke.invalid_type,expected:Xe.map,received:r.parsedType}),mt;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([l,c],u)=>({key:s._parse(new da(r,l,r.path,[u,"key"])),value:i._parse(new da(r,c,r.path,[u,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of o){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}}}}bA.create=(e,t,n)=>new bA({valueType:t,keyType:e,typeName:gt.ZodMap,...jt(n)});class Sg extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Xe.set)return Le(r,{code:ke.invalid_type,expected:Xe.set,received:r.parsedType}),mt;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(Le(r,{code:ke.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(Le(r,{code:ke.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(c){const u=new Set;for(const d of c){if(d.status==="aborted")return mt;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const l=[...r.data.values()].map((c,u)=>i._parse(new da(r,c,r.path,u)));return r.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,n){return new Sg({...this._def,minSize:{value:t,message:rt.toString(n)}})}max(t,n){return new Sg({...this._def,maxSize:{value:t,message:rt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Sg.create=(e,t)=>new Sg({valueType:e,minSize:null,maxSize:null,typeName:gt.ZodSet,...jt(t)});class ij extends Bt{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})}}ij.create=(e,t)=>new ij({getter:e,typeName:gt.ZodLazy,...jt(t)});class Db extends Bt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Le(n,{received:n.data,code:ke.invalid_literal,expected:this._def.value}),mt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Db.create=(e,t)=>new Db({value:e,typeName:gt.ZodLiteral,...jt(t)});function C7(e,t){return new ju({values:e,typeName:gt.ZodEnum,...jt(t)})}class ju extends Bt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Le(n,{expected:Yt.joinValues(r),received:n.parsedType,code:ke.invalid_type}),mt}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 Le(n,{received:n.data,code:ke.invalid_enum_value,options:r}),mt}return Gi(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 ju.create(t,{...this._def,...n})}exclude(t,n=this._def){return ju.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}ju.create=C7;class oj extends Bt{_parse(t){const n=Yt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Xe.string&&r.parsedType!==Xe.number){const s=Yt.objectValues(n);return Le(r,{expected:Yt.joinValues(s),received:r.parsedType,code:ke.invalid_type}),mt}if(this._cache||(this._cache=new Set(Yt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=Yt.objectValues(n);return Le(r,{received:r.data,code:ke.invalid_enum_value,options:s}),mt}return Gi(t.data)}get enum(){return this._def.values}}oj.create=(e,t)=>new oj({values:e,typeName:gt.ZodNativeEnum,...jt(t)});class $b extends Bt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Xe.promise&&n.common.async===!1)return Le(n,{code:ke.invalid_type,expected:Xe.promise,received:n.parsedType}),mt;const r=n.parsedType===Xe.promise?n.data:Promise.resolve(n.data);return Gi(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}$b.create=(e,t)=>new $b({type:e,typeName:gt.ZodPromise,...jt(t)});class mc extends Bt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:o=>{Le(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return mt;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?mt:c.status==="dirty"||n.value==="dirty"?im(c.value):c});{if(n.value==="aborted")return mt;const l=this._def.schema._parseSync({data:o,path:r.path,parent:r});return l.status==="aborted"?mt:l.status==="dirty"||n.value==="dirty"?im(l.value):l}}if(s.type==="refinement"){const o=l=>{const c=s.refinement(l,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!zh(o))return mt;const l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>zh(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:n.value,value:l})):mt);Yt.assertNever(s)}}mc.create=(e,t,n)=>new mc({schema:e,typeName:gt.ZodEffects,effect:t,...jt(n)});mc.createWithPreprocess=(e,t,n)=>new mc({schema:t,effect:{type:"preprocess",transform:e},typeName:gt.ZodEffects,...jt(n)});class Xa extends Bt{_parse(t){return this._getType(t)===Xe.undefined?Gi(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Xa.create=(e,t)=>new Xa({innerType:e,typeName:gt.ZodOptional,...jt(t)});class Eu extends Bt{_parse(t){return this._getType(t)===Xe.null?Gi(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Eu.create=(e,t)=>new Eu({innerType:e,typeName:gt.ZodNullable,...jt(t)});class Lb extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Xe.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Lb.create=(e,t)=>new Lb({innerType:e,typeName:gt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...jt(t)});class Fb extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Rb(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new rl(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new rl(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Fb.create=(e,t)=>new Fb({innerType:e,typeName:gt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...jt(t)});class wA extends Bt{_parse(t){if(this._getType(t)!==Xe.nan){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.nan,received:r.parsedType}),mt}return{status:"valid",value:t.data}}}wA.create=e=>new wA({typeName:gt.ZodNaN,...jt(e)});class N7 extends Bt{_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 D5 extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?mt:i.status==="dirty"?(n.dirty(),im(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?mt:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new D5({in:t,out:n,typeName:gt.ZodPipeline})}}class Bb extends Bt{_parse(t){const n=this._def.innerType._parse(t),r=s=>(zh(s)&&(s.value=Object.freeze(s.value)),s);return Rb(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Bb.create=(e,t)=>new Bb({innerType:e,typeName:gt.ZodReadonly,...jt(t)});var gt;(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"})(gt||(gt={}));const N=Va.create,Q=Hh.create,Me=ej.create,Za=rj.create;pc.create;const pe=ia.create,B=or.create,nce=Pb.create,Bs=O5.create;Ab.create;Nu.create;const Yi=Ob.create,he=Db.create,Ve=ju.create;$b.create;Xa.create;Eu.create;const rce=mc.createWithPreprocess,sce=["head","index"],j7=N().regex(/^[A-Za-z0-9][A-Za-z0-9-]{0,127}$/),zb=N().regex(/^[1-9][0-9]*$/),Hb=N().regex(/^[A-Za-z0-9_.-]+$/),kg=N().min(1).max(255).refine(e=>!e.startsWith("-")&&e!=="HEAD"&&!e.startsWith("/")&&!e.endsWith("/")&&!e.endsWith(".")&&!/[\s~^:?*\[\\\x00-\x1f\x7f]/.test(e)&&!e.includes("..")&&!e.includes("@{")&&!e.includes("//")&&e.split("/").every(t=>!t.startsWith(".")&&!t.endsWith(".lock")),"Invalid Git branch"),$5=N().min(1).max(4096).refine(e=>!e.startsWith("/")&&!e.includes("\0")&&!e.split(/[\\/]/).includes("..")),Tw=B({workspaceId:j7,repoId:zb,owner:Hb,name:Hb,sourceBranch:kg,defaultBranch:kg}).strict(),ice=B({repoId:zb,owner:Hb,name:Hb,defaultBranch:N(),private:Me(),description:N().nullable()}),oce=Tw.extend({initialCommit:N(),head:N(),actualBranch:N().nullable(),branches:pe(N()).optional(),files:pe(B({path:$5,previousPath:N().optional(),comparison:Ve(sce).optional(),status:N(),added:Q().nonnegative(),removed:Q().nonnegative(),binary:Me(),untracked:Me().optional()})),totalFiles:Q().int().nonnegative().optional(),filesTruncated:Me().optional(),added:Q().nonnegative(),removed:Q().nonnegative(),dirty:Me(),conflicted:Me(),version:N(),measuredAt:Q()}),Ed=B({sessionId:j7});Bs("action",[Ed.extend({action:he("repositories"),page:Q().int().min(1).max(1e3).optional(),search:N().max(100).optional()}).strict(),Ed.extend({action:he("branches"),repoId:zb,page:Q().int().min(1).max(1e3).optional(),search:N().max(100).optional(),cursor:N().min(1).max(1024).optional()}).strict(),Ed.extend({action:he("bind"),repoId:zb,branch:kg}).strict(),Ed.extend({action:he("status")}).strict(),Ed.extend({action:he("intend"),branch:kg.optional()}).strict(),Ed.extend({action:he("diff"),filePath:$5}).strict()]);B({binding:Tw.nullable().optional(),workspace:oce.nullable().optional(),repositories:pe(ice).optional(),branches:pe(N()).optional(),hasMore:Me().optional(),nextCursor:N().min(1).max(1024).optional(),diff:B({path:$5,patch:N(),binary:Me(),truncated:Me(),notStored:Me().optional()}).optional()});B({threadId:N().min(1),conversationId:N().min(1),workspace:Tw.optional()});new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");B({id:N().min(1),name:N().min(1),baseUrl:N().min(1),apiKey:N().min(1),remark:N().optional(),createdAt:Q(),updatedAt:Q()}).strict();const ace=B({id:N().min(1),name:N().min(1),baseUrl:N().min(1),remark:N().optional(),keyMasked:N(),hasKey:Me(),createdAt:Q(),updatedAt:Q()}).strict();B({activeChannelId:N().nullable(),channels:pe(ace)}).strict();B({}).strict();B({id:N().min(1).optional(),name:N().min(1),baseUrl:N().min(1),apiKey:N().optional(),remark:N().optional()}).strict();B({id:N().min(1)}).strict();B({id:N().min(1).nullable()}).strict();B({channelId:N().min(1).optional(),updatedAt:Q().optional()}).strict().refine(e=>e.updatedAt===void 0||e.channelId!==void 0,{message:"updatedAt requires channelId"});B({channelId:N().nullable(),models:pe(B({id:N().min(1),ownedBy:N().optional()}).strict())}).strict();const lce=["owner"],cce=["agent","owner","user-upload"],E7=B({id:N().min(1),relPath:N().min(1),from:Ve(cce),label:N().optional(),size:Q().int().nonnegative(),mime:N().min(1),addedAt:Q().int().nonnegative(),lastEditedAt:Q().int().nonnegative().optional(),stale:Me().optional()});B({sessionId:N().min(1),relPath:N().min(1),ttlSeconds:Q().int().positive().nullable().optional(),view:Ve(["raw","md-rendered"]).optional()});B({url:N().min(1),expiresAt:Q().int().nonnegative().nullable()});B({sessionId:N().min(1),relPath:N().min(1),label:N().optional(),origin:he("agent").optional()});B({entry:E7});B({sessionId:N().min(1),relPath:N().min(1)});B({removed:he(!0)});B({sessionId:N().min(1)});B({entries:pe(E7)});B({attachmentId:N().min(1),url:N().min(1),relPath:N().min(1),sizeBytes:Q().int().nonnegative(),mimeType:N().min(1)});const uce=Bs("type",[B({type:he("persona"),id:N().min(1)}).strict(),B({type:he("chat"),id:N().min(1)}).strict(),B({type:he("*")}).strict()]),dce=Ve(["read","send","admin"]),L5=B({resource:uce,actions:pe(dce).min(1)}).strict(),hce=B({id:N().min(1),secretHash:N().regex(/^[a-f0-9]{64}$/),displayName:N(),grants:pe(L5),issuedAt:Q().int().nonnegative(),expiresAt:Q().int().positive().optional(),maxUses:Q().int().positive().optional(),usedCount:Q().int().nonnegative(),peerOwnerId:N().min(1).optional(),firstUsedByPeerAt:Q().int().positive().optional(),peerDisplayName:N().optional()}).strict(),fce=hce.omit({secretHash:!0});B({type:he("whoami:ok"),owner:B({id:N(),kind:Ve(["owner","guest"]),displayName:N(),ownerId:N(),provider:N()}).strict(),capability:fce,grantedPersonas:pe(B({id:N().min(1),displayName:N()}).strict())}).strict();const pce="PEER_LOGIN_EXPIRED";B({selfUrl:N().min(1)});B({type:he("contact:handshake:ok"),owner:B({id:N(),ownerId:N(),provider:N(),displayName:N()}),grants:pe(L5)});const mce=Bs("status",[B({status:he("authorized"),login:N().min(1),source:Ve(["git","file"])}).strict(),B({status:he("missing")}).strict(),B({status:he("invalid"),message:N().min(1)}).strict(),B({status:he("pending"),authUrl:N().url()}).strict()]);B({token:N().min(1)}).strict();B({returnTo:N().url().optional()}).strict();const gce=B({url:N().url(),bin:N(),sha256:N().regex(/^[0-9a-f]{64}$/),size:Q().int().positive()}),xce={label:"Debian 13"},I7=["node","npm"],vce=["claude","codex","git","lark-cli","pi","pi-mcp-bridge","pi-cliproxyapi-provider","python3","jq","rsync","psql","go","chromium","fonts-wqy-microhei","openssh-server","pnpm","whiteboard-cli","s","supabase-mcp","mcp-server-kibana","aliyun"],yce=B({name:N().min(1),from:N().optional(),version:N().optional(),min:N().optional(),library:Me().optional(),localVersion:N().optional(),artifact:gce.optional(),aptMissing:he(!0).optional(),aptVersion:N().optional()}),F5=N().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),T7=["proxy","env"],R7=["mcp","cli"],bce=["bearer","lark-sidecar"],M7=["none","shared","personal"],B5=["oauth","fields"],Rw=N().regex(/^[A-Z][A-Z0-9_]*$/,"要填的变量名只能是大写字母、数字和下划线,且以字母开头"),wce=B({name:N().min(1),env:pe(Rw).min(1)}),P7=B({name:F5,kind:Ve(T7),runner:Ve(R7),protocol:Ve(bce).optional(),id:N().min(1),credentialSource:Ve(M7).optional(),auth:Ve(B5).optional(),publisherUnionId:N().regex(/^on_[A-Za-z0-9_-]+$/).optional(),fields:pe(Rw).default([]),http:B({url:N().min(1),headers:Yi(N(),N())}).optional()}),A7=["LARKSUITE_CLI_APP_ID","LARKSUITE_CLI_APP_SECRET"];function z5(e){return e.name==="feishu"&&e.runner==="cli"&&e.kind==="env"&&e.credentialSource==="shared"}function _ce(e){return e.name==="feishu"&&e.id==="feishu"&&e.runner==="cli"&&e.kind==="proxy"&&e.protocol==="lark-sidecar"&&e.credentialSource==="shared"&&e.auth==="oauth"&&e.fields.length===0}function O7(e){if(!e.credentialSource)return[`连接器 ${e.name} 还没选用谁的账号`];const t=[];return _ce(e)?t:e.protocol==="lark-sidecar"&&e.credentialSource==="shared"?["连接器 feishu 的发布者 OAuth 配置不完整,请重新选择账号身份"]:z5(e)?A7.filter(n=>!e.fields.includes(n)).map(n=>`连接器 feishu 的 Lark App Bot 缺少 ${n==="LARKSUITE_CLI_APP_ID"?"App ID":"App Secret"}`):(e.credentialSource==="personal"&&(e.auth?e.auth==="oauth"&&e.kind==="env"?t.push(`连接器 ${e.name} 是进程型(stdio MCP / CLI),只能粘贴 API key,走不了 OAuth`):e.auth==="fields"&&e.fields.length===0&&t.push(`连接器 ${e.name} 要填的变量还没列`):t.push(`连接器 ${e.name} 还没选用户怎么关联账号`)),e.credentialSource==="shared"&&e.fields.length===0&&t.push(`连接器 ${e.name} 选了发布者的账号,但要填的变量还没列`),t)}const Sce=/^([A-Za-z0-9._/-]+)@([A-Za-z0-9._-]+)(?:\?tags=([A-Za-z0-9_,]+))?$/,kce=["main","master","HEAD","latest"];function Cce(e){const t=Sce.exec(e);return!!t&&!kce.includes(t[2])}function D7(e){var n,r;return I7.includes(e.name)||vce.includes(e.name)?[]:(n=e.from)!=null&&n.startsWith("github:")&&!e.artifact?[`${e.name} 还没钉下载资产(github: 要具体到哪个文件)——重新扫描`]:(r=e.from)!=null&&r.startsWith("go:")&&!Cce(e.from.slice(3))?[`${e.name} 还没钉版本(go: 要写成 <module>@<tag>,不收 latest / main 这类移动引用)——重新扫描`]:[]}function H5(e){return e.connectors.filter(t=>t.credentialSource==="shared"&&t.fields.length>0).map(t=>({name:t.name,env:[...t.fields]}))}function Nce(e){return[...new Set([...e.envVars.flatMap(t=>t.env),...H5(e).flatMap(t=>t.env)])]}function jce(e){const t=new Set(e.connectors.flatMap(n=>n.fields));return[...new Set(e.envVars.flatMap(n=>n.env))].filter(n=>t.has(n)).map(n=>`${n} 同时是环境变量和连接器的字段,只能留一处——重新扫描`)}const Ece=e=>{if(!e||typeof e!="object")return e;let t=e;if("clis"in t&&Array.isArray(t.clis)){const{clis:n,...r}=t;t="packages"in r?r:{...r,packages:n}}if("assets"in t&&Array.isArray(t.assets)&&t.assets.length===0){const{assets:n,...r}=t;t=r}if("secrets"in t&&Array.isArray(t.secrets)){const{secrets:n,...r}=t,s=new Set((Array.isArray(r.connectors)?r.connectors:[]).flatMap(o=>Array.isArray(o==null?void 0:o.fields)?o.fields:[])),i=n.map(o=>({...o,env:Array.isArray(o==null?void 0:o.env)?o.env.filter(l=>!s.has(l)):o==null?void 0:o.env})).filter(o=>!Array.isArray(o.env)||o.env.length>0);t={...r,envVars:[...Array.isArray(r.envVars)?r.envVars:[],...i]}}return t},Ice="Publisher test: ",$7=B({version:he(1),entry:N().max(240).regex(/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*\.mjs$/).refine(e=>!e.split("/").some(t=>[".",".."].includes(t))),timeoutSeconds:Q().int().min(1).max(600),checks:pe(N().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)).min(1).max(64).refine(e=>new Set(e).size===e.length)}).strict(),L7={test:$7.optional(),packages:pe(yce),envVars:pe(wce).default([]),connectors:pe(P7).default([])};B(L7);const U5=rce(Ece,B({version:he(1),...L7}).strict()),Tce=B({target:N().min(1),reason:N().min(1),file:N().min(1),quote:N().min(1)}),Rce=["integration","production"],Hs=Ve(Rce),gc=N().regex(/^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[a-f0-9]{64}$/),aj=N().regex(/^[a-f0-9]{40}$/),Mce=N().refine(e=>{try{const t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password&&!t.search&&!t.hash&&t.pathname==="/"&&/(^|[.-])int([.-]|$)/.test(t.hostname)}catch{return!1}},"测试验证地址必须明确指向 int HTTPS 环境"),Pce=B({version:he(1),runId:N().regex(/^[A-Za-z0-9_-]{1,128}$/),status:he("passed"),exitCode:he(0),result:B({version:he(1),runId:N().regex(/^[A-Za-z0-9_-]{1,128}$/),checks:pe(B({name:N().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),status:he("passed"),reason:N().max(1024).optional()}).strict()).min(1).max(64)}).strict(),execution:B({image:gc,imageID:N().min(1).max(512),engine:Ve(["codex","pi"]),podUid:N().min(1).max(512),jobUid:N().min(1).max(512)}).strict()}).strict(),F7=B({status:he("passed"),fingerprint:N().regex(/^[a-f0-9]{64}$/),checks:pe(N().regex(/^[a-z0-9-]+$/)),endpoint:Mce,verifiedAt:N().refine(e=>Number.isFinite(Date.parse(e))),test:Pce.optional()}).strict(),B7=B({engine:N().min(1),model:N(),effort:N(),size:N().min(1),cpu:Q().positive(),taskConcurrency:Q().int().positive(),minPods:Q().int().nonnegative().safe().optional()}).strict(),z7=B({version:he(1),environment:he("integration"),component:he("persona"),image:gc,commit:aj,baseImage:gc,pipelineCommit:aj,repository:N().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/),config:B7.optional(),verification:F7.refine(e=>e.checks.includes("persona-smoke")),test:$7.optional()}).strict().refine(e=>{if(!e.test)return e.verification.test===void 0;const t=e.verification.test;return["persona-dialogue","persona-task","persona-custom-test"].every(n=>e.verification.checks.includes(n))&&t!==void 0&&t.execution.image===e.image&&t.runId===t.result.runId&&t.result.checks.length===e.test.checks.length&&new Set(t.result.checks.map(n=>n.name)).size===e.test.checks.length&&t.result.checks.every(n=>e.test.checks.includes(n.name))},"Declared publisher acceptance requires complete candidate runtime evidence");B({version:he(1),environment:he("integration"),component:he("base"),image:gc,commit:aj,verification:F7.refine(e=>e.checks.includes("base-smoke"))}).strict();const Cg="-cloud",W5=`codex${Cg}`,Ng={standard:"default",fast:"priority"},Ace=`claude${Cg}`;function H7(e){return e==="codex"||e===W5}const U7="pi",Oce=`${U7}${Cg}`;function W7(e){return e===U7||e===Oce}function mu(e){return typeof e=="string"&&e.length>Cg.length&&e.endsWith(Cg)}const V7=Ve([Ng.standard,Ng.fast]),V5=["tiny","small","medium","large","xlarge"],Dce=Ve(V5),Ub="medium",Wb=[.5,1,2],$ce=Q().refine(e=>Wb.includes(e),"Unsupported CPU"),lj={tiny:.5,small:1,medium:2,large:2,xlarge:2},q7=B({model:N().optional(),effort:N().optional()}).strict(),Pm=B({personaId:N(),label:N(),model:N().optional(),effort:N().optional(),serviceTier:V7.optional(),public:Me(),iconKey:N().optional(),tool:N().optional(),size:N().optional(),cpu:Q().finite().optional(),taskConcurrency:Q().int().positive().optional(),minPods:Q().int().nonnegative().safe().optional(),cloudEngine:q7.optional(),createdAt:Q(),updatedAt:Q(),cloud:B({gatewayUrl:N().min(1),personaId:N().min(1),publishedByMe:Me().optional(),label:N().optional(),environment:Hs.optional(),expectedImage:gc.optional(),testReleaseId:N().optional()}).strict().optional()}).strict(),Lce=B({name:N().min(1),description:N().optional()}),Fce=B({id:N().min(1)}),K7=B({writableRoots:pe(N()).optional(),denyRead:pe(N()).optional(),network:Me().optional()}).strict(),Bce=B({permissions:B({defaultMode:N().optional(),allow:pe(N()).optional(),deny:pe(N()).optional()}).optional(),sandbox:B({enabled:Me().optional(),autoAllowBashIfSandboxed:Me().optional(),allowUnsandboxedCommands:Me().optional(),excludedCommands:pe(N()).optional(),filesystem:B({denyRead:pe(N()).optional(),allowRead:pe(N()).optional(),denyWrite:pe(N()).optional(),allowWrite:pe(N()).optional()}).optional(),network:B({allowedDomains:pe(N()).optional(),allowLocalBinding:Me().optional()}).optional()}).optional()});Pm.extend({personality:N().optional(),personalityLocal:N().optional(),personalityManaged:Me().optional(),skills:pe(Lce).optional(),plugins:pe(Fce).optional(),sandboxSettings:Bce.nullable().optional(),codexSandbox:K7.nullable().optional()});B({slug:N().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:N().min(1),personality:N(),model:N().optional(),effort:N().optional(),serviceTier:Pm.shape.serviceTier,tool:N().optional(),public:Me().optional(),iconKey:N().optional()}).strict();B({personaId:N().min(1)});B({personaId:N().min(1),patch:B({label:N().min(1).optional(),model:N().optional(),effort:N().optional(),serviceTier:Pm.shape.serviceTier,tool:N().optional(),size:Dce.optional(),cpu:$ce.optional(),taskConcurrency:Pm.shape.taskConcurrency,minPods:Pm.shape.minPods,cloudEngine:q7.optional(),personality:N().optional(),personalityLocal:N().optional(),public:Me().optional(),iconKey:N().nullable().optional(),codexSandbox:K7.optional()}).strict()}).strict();B({version:he(1),manifest:U5}).strict();const zce=["hard","soft"],G7=Ve(zce),Hce=Ve(["scanning","done","failed"]),Y7=B({id:N().min(1),manifest:U5,scanSessionId:N().optional(),status:Hce,evidence:pe(Tce).default([]),notes:pe(N()).default([]),head:N().min(1).optional(),baseKind:G7.default("hard"),base:N().min(1).optional(),startedAt:Q(),finishedAt:Q().optional(),error:N().optional()}).strict(),q5=B({id:N().min(1).optional(),environment:Hs.optional(),legacy:Me().optional(),head:N().min(1),contentHead:N().min(1),scanId:N().min(1),at:Q(),pushed:Me().optional(),runId:Q().int().positive().optional(),runAttempt:Q().int().positive().optional(),artifactId:Q().int().positive().optional(),verified:z7.optional(),config:B7.optional(),reconfigOf:N().min(1).optional(),workflowVersion:Q().int().positive().optional(),confirmation:B({fingerprint:N().regex(/^[a-f0-9]{64}$/),runId:Q().int().positive(),runAttempt:Q().int().positive(),at:Q()}).strict().optional()}).strict(),Uce=["prepared","main-pushed","dispatching","dispatched","completed","failed"],K5=B({id:N().min(1),releaseId:N().min(1),at:Q(),verified:z7.optional(),phase:Ve(Uce),expectedMain:N().optional(),runId:Q().int().positive().optional(),runAttempt:Q().int().positive().optional(),error:N().optional()}).strict(),_A=B({channelId:N().min(1),updatedAt:Q()}).strict(),G5=B({integration:_A.nullable().optional(),production:_A.nullable().optional()}).strict();B({version:he(4),engineChannels:G5.optional(),scans:pe(Y7),releases:pe(q5),promotions:pe(K5).default([])}).strict();const Wce=B({url:N().min(1),branch:N().min(1),head:N().min(1),dirty:Me(),ahead:Q()}).strict(),Ny=B({env:N().min(1),setAt:Q().optional()}).strict(),SA={baseUrl:"CLAWD_ENGINE_BASE_URL",apiKey:"CLAWD_ENGINE_API_KEY"},Vce="模型订阅只写进去一半——重填或改回平台默认";function Vb(e){if(!e)return;const t=r=>e.some(s=>s.env===r&&s.setAt!==void 0),n=[SA.baseUrl,SA.apiKey].filter(t).length;return n===2?"own":n===0?"platform":"partial"}function qce(e){const t=e.trim();let n;try{n=new URL(t)}catch{throw new Error("订阅地址要以 http:// 或 https:// 开头,形如 https://cpa.example.com")}if(n.protocol!=="http:"&&n.protocol!=="https:"||!n.hostname)throw new Error("订阅地址要以 http:// 或 https:// 开头,形如 https://cpa.example.com");const r=`${n.origin}${n.pathname}`.replace(/\/+$/,"");return r.endsWith("/v1")?r:`${r}/v1`}const Kce=["pending","running","done","failed","waiting","skipped"],Gce=Ve(Kce),yo="verify",Am=["build","smoke","deploy",yo],Yce=Ve(Am),Xce=B({key:Yce,status:Gce,url:N().optional(),jobId:Q().optional(),startedAt:Q().optional(),completedAt:Q().optional(),cliWarnings:pe(N()).optional()}).strict(),jy=B({runId:Q(),headSha:N().min(1),status:Ve(["queued","running","completed"]),htmlUrl:N().min(1),jobs:pe(Xce),environment:Hs.optional(),branch:N().optional(),event:N().optional(),runAttempt:Q().int().positive().optional(),conclusion:Ve(["success","failure"]).optional(),promotionId:N().optional()}).strict();function X7(e,t){return t&&e.head===t.head?t.contentHead:e.head}function Mw(e,t,n){return!e||!t||e.status!=="done"?!1:e.head===X7(t,n)&&!t.dirty}function Y5(e,t,n){return!e||!t||e.status!=="done"||!e.head?!1:e.head!==X7(t,n)}function kA(e,t,n){return Mw(e,t,n)||Y5(e,t,n)}function Zce(e,t){return!t||!e.head?!1:t.contentHead===e.head||t.at>=e.startedAt}const Z7=["codex","pi","claude"];function fl(e){return Z7.includes(e||"claude")}const Q7={codex:"0.163.0",pi:"1.3.0",claude:"0.3.304"},Qce="2.1.304";function Jce(e,t){if(!e||!fl(e)||!t)return null;const n=e==="claude"?Qce:Q7[e];return n===t?null:{tool:e,cloud:n,local:t}}function J7(e){const t=e.tool||"claude",n=t==="claude"?e.cloudEngine??{}:e;return{tool:t,model:n.model??"",effort:n.effort??""}}const jk=B({runId:Q(),status:jy.shape.status,conclusion:Ve(["success","failure"]).optional(),htmlUrl:N().min(1)}).strict(),eue=B({desired:Q().int().nonnegative().safe(),ready:Q().int().nonnegative().safe(),bound:Q().int().nonnegative().safe(),starting:Q().int().nonnegative().safe(),retiring:Q().int().nonnegative().safe(),observedAt:Q(),error:N().nullable()}).strict(),CA=B({online:Me().optional(),image:gc.optional(),minPods:Q().int().nonnegative().safe().optional(),reservation:eue.nullable().optional(),reservationError:N().optional()}).strict(),eH=B({personaId:N().min(1),engineChannels:G5.optional(),github:mce.optional(),publisherFeishuAuth:B({integration:B({connected:Me(),authUrl:N().optional(),error:N().optional()}).strict(),production:B({connected:Me(),authUrl:N().optional(),error:N().optional()}).strict()}).strict().optional(),repo:Wce.optional(),scans:pe(Y7).default([]),releases:pe(q5).default([]),promotions:pe(K5).optional(),targets:B({integration:CA.extend({run:jy.optional(),secrets:pe(Ny).optional(),unpublish:jk.optional()}).optional(),production:CA.extend({run:jy.optional(),secrets:pe(Ny).optional(),unpublish:jk.optional()}).optional()}).strict().optional(),secrets:pe(Ny).optional(),run:jy.optional(),online:Me().optional(),unpublish:jk.optional(),historyError:N().optional()}).strict();B({before:Q().nullable()}).strict();eH.pick({personaId:!0,github:!0,repo:!0,scans:!0,releases:!0,promotions:!0,engineChannels:!0,historyError:!0});eH.pick({scans:!0});B({environment:Hs,secrets:pe(Ny).optional(),engineChannels:G5.optional()}).strict();const tue=e=>e.includes("minPods")?3:2,jg=1,nue=["engine","model","effort","size","cpu","taskConcurrency","minPods"];function rue(e){const{tool:t,model:n,effort:r}=J7(e),s=(e.size??"").trim()||Ub,i=e.cpu??lj[s]??lj[Ub];return{engine:t,model:n.trim(),effort:r.trim(),size:s,cpu:i,taskConcurrency:e.taskConcurrency??jg,minPods:e.minPods??0}}function tH(e,t){return!e||!t?null:nue.filter(n=>n==="minPods"?(e.minPods??0)!==(t.minPods??0):e[n]!==t[n])}B({sha:N().min(1),actionsUrl:N().min(1),releaseId:N().optional()}).strict();const px=B({personaId:N().min(1)}).strict();px.extend({releaseHead:N().min(1).optional(),releaseId:N().min(1).optional(),environment:Hs.optional()}).strict();px.extend({scanBase:G7.optional()}).strict();px.extend({scanId:N().min(1)}).strict();px.extend({releaseId:N().min(1)}).strict();px.extend({environment:Hs.default("production")}).strict();B({confirmation:q5.shape.confirmation.unwrap()}).strict();B({promotion:K5}).strict();B({personaId:N().min(1),expectedImage:gc}).strict();B({personaId:N().min(1),scanId:N().min(1),patch:B({manifest:U5.optional(),connector:P7.optional()}).strict()}).strict();B({personaId:N().min(1),environment:Hs.default("production"),scanId:N().min(1),name:N().min(1),values:Yi(N(),N())}).strict();B({personaId:N().min(1),environment:Hs.default("production"),channelId:N().min(1).optional(),auth:B({baseUrl:N(),apiKey:N()}).strict().nullable().optional()}).strict().refine(e=>e.channelId!==void 0||e.auth!==void 0,{message:"Either channelId or auth must be provided"});B({personaId:N().min(1),environment:Hs.default("production"),releaseId:N().optional(),jobId:Q()}).strict();const sue="底座已更新,重试仍会用旧底座构建——请重新发布测试环境";B({personaId:N().min(1),kind:Ve(["package","env","connector"]),item:Yi(N(),Za()),evidence:B({reason:N().min(1),file:N().min(1),quote:N().min(1)})}).strict();B({personaId:N().min(1),notes:pe(N()).default([])}).strict();const nH="ottin4ttc";function Uh(e){return e.trim().replace(/^git@[^:]+:/,"").replace(/^https?:\/\/[^/]+\//,"").replace(/\.git$/,"")}B({environment:Hs.default("production")}).strict();const iue="LOGIN_EXPIRED",oue=B({deviceId:N().min(1),name:N().min(1),url:N().min(1)});B({type:he("device:list:ok"),devices:pe(oue)});B({deviceId:N().min(1),url:N().min(1).optional(),name:N().optional()});B({type:he("device:connect:ok"),deviceId:N(),name:N(),url:N()});const rH=B({ownerId:N().min(1),provider:N().min(1),displayName:N().min(1),avatarUrl:N().optional(),unionId:N().optional()});B({type:he("auth:login:start:ok"),environment:Hs.optional(),authUrl:N().min(1),state:N().min(1)});B({type:he("auth:getIdentity:ok"),identity:rH.nullable(),deviceId:N().min(1)});B({type:he("auth:logout:ok")});const sH=N().nullable();B({type:he("auth:apiKey:get:ok"),apiKey:N().nullable(),createdAt:N().nullable(),gatewayUrl:sH});B({type:he("auth:apiKey:regenerate:ok"),apiKey:N().min(1),createdAt:N().min(1),gatewayUrl:sH});B({type:he("auth:apiKey:revoke:ok"),revoked:Me()});B({type:he("auth:login:done"),environment:Hs.optional(),identity:rH});B({type:he("auth:login:failed"),environment:Hs.optional(),reason:N()});B({deviceId:N().min(1),remoteAccessAllowed:Me()}).strict();B({type:he("contact:setRemoteAccess:ok"),deviceId:N().min(1),remoteAccessAllowed:Me()}).strict();B({type:he("contact:remote-access-updated"),deviceId:N().min(1),remoteAccessAllowed:Me()}).strict();B({personaId:N().min(1)}).strict();const aue=["connected","missing","reauth"],lue=["link","fill"],cue=B({name:F5,id:N().min(1),kind:Ve(T7),runner:Ve(R7),auth:Ve(B5),status:Ve(aue),action:Ve(lue),authUrl:N().optional(),fields:pe(Rw)}).strict();B({connectors:pe(cue)}).strict();B({personaId:N().min(1),name:F5,values:Yi(Rw,N().min(1))}).strict();const uue=B({deviceId:N().min(1),ownerId:N().min(1),provider:N().min(1),displayName:N(),remoteUrl:N().min(1),connectToken:N(),grants:pe(L5),addedAt:Q().int().nonnegative(),pinnedAt:Q().int().nullable().default(null),remoteAccessAllowed:Me().default(!1),note:N().default("")}).strict(),iH=uue;B({deviceId:N().min(1)}).strict();B({type:he("contact:remove:ok"),deviceId:N().min(1)}).strict();B({type:he("contact:list:ok"),contacts:pe(iH)}).strict();B({type:he("contact:added"),contact:iH}).strict();B({type:he("contact:removed"),deviceId:N().min(1)}).strict();B({deviceId:N().min(1),pinned:Me()}).strict();B({deviceId:N().min(1),note:N()}).strict();B({type:he("contact:setNote:ok"),deviceId:N().min(1),note:N()}).strict();B({type:he("contact:pin:ok"),deviceId:N().min(1),pinnedAt:Q().int().nullable()}).strict();B({type:he("contact:pinned"),deviceId:N().min(1),pinnedAt:Q().int().nullable()}).strict();const oH=8,due=["submitted","working","input_required","completed","failed","canceled","rejected"],X5=Ve(due),hue=/^[A-Za-z0-9_.-]{1,128}$/,Ek=/^[a-z0-9-]{1,128}$/;function fue(e){if(e.startsWith("cloud:")){const s=e.slice(6);return Ek.test(s)?{kind:"cloud",personaId:s}:null}const t=e.indexOf("@");if(t<0)return Ek.test(e)?{kind:"here",personaId:e}:null;const n=e.slice(0,t),r=e.slice(t+1);return Ek.test(n)&&hue.test(r)?{kind:"device",personaId:n,deviceId:r}:null}const pue=B({target:N().refine(e=>fue(e)!==null,{message:"target must be <personaId>, <personaId>@<deviceId> or cloud:<personaId>"}),text:N().min(1),brief:N().optional(),contextId:N().min(1).optional(),taskId:N().min(1).optional(),sessionLabel:N().min(1).max(60).optional(),model:N().min(1).optional(),tool:N().min(1).optional(),meta:Yi(Za()).optional()}).refine(e=>!(e.contextId&&e.taskId),{message:"contextId (new round) and taskId (answer) are mutually exclusive"}).refine(e=>!((e.contextId||e.taskId)&&(e.model||e.tool)),{message:"a follow-up cannot change engine or model (contextId / taskId exclude model / tool); start a new line instead"});B({calls:pe(pue).min(1).max(oH),sessionId:N().min(1).optional()});const mue=6e4;B({taskIds:pe(N().min(1)).min(1).max(oH),timeoutMs:Q().int().min(0).max(mue)});B({taskId:N().min(1),text:N().trim().min(1)});B({taskId:N().min(1)});B({contextId:N().min(1).optional(),state:X5.optional(),sessionId:N().min(1).optional(),relatedSessionId:N().min(1).optional()});B({contextId:N().min(1),state:Ve(["completed","failed","input_required"]),text:N(),brief:N().optional(),filePaths:pe(N().min(1)).optional()});const Z5=B({taskId:N().min(1),contextId:N().min(1),round:Q().int().positive(),state:X5,stale:Me(),reason:N().nullable(),depth:Q().int().min(0),tenant:N(),targetPersonaId:N(),targetDeviceId:N().nullable(),initiator:B({host:N(),personaId:N(),sessionRef:N().nullable()}),executorSessionRef:N().nullable(),executorThreadId:N().nullable(),workerSessionId:N().optional(),taskText:N(),brief:N().nullable(),resultText:N().nullable(),filePaths:pe(N()),line:Yi(Za()),deliveredAt:N().nullable(),createdAt:N(),updatedAt:N(),finishedAt:N().nullable()}),gue=Bs("ok",[B({ok:he(!0),task:Z5}),B({ok:he(!1),error:B({code:N(),message:N()})})]);B({results:pe(gue)});B({tasks:pe(Z5)});B({tasks:pe(Z5),done:Me()});const xue=/^[a-z0-9][a-z0-9-]*$/;Ve(["stopped","starting","running","crashed","invalid"]);const vue=new Set(["localhost","127.0.0.1"]);function yue(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&vue.has(t.hostname))}const c0=B({id:N().regex(xue),name:N().min(1),version:N().min(1),apiVersion:he("1"),runtime:B({startCommand:N().min(1)}).passthrough().optional(),entry:B({url:N().url().refine(yue,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var s;const n=!!e.runtime,r=!!((s=e.entry)!=null&&s.url);n&&r&&t.addIssue({code:ke.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:ke.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),bue=Bs("kind",[B({kind:he("local"),port:Q().int().min(1).max(65535)}),B({kind:he("hosted"),url:N().url()})]);Bs("state",[B({extId:N(),manifest:c0,state:he("stopped")}),B({extId:N(),manifest:c0,state:he("starting")}),B({extId:N(),manifest:c0,state:he("running"),target:bue}),B({extId:N(),manifest:c0,state:he("crashed")}),B({extId:N(),manifest:Za().nullable(),state:he("invalid"),invalidReason:N().min(1)})]);B({snapshotHash:N().min(1),version:N().min(1),publishedAt:Q()});const wue=Bs("kind",[B({kind:he("p2p-tunnel"),ownerPrincipalId:N().min(1),extId:N().min(1)})]);Bs("kind",[B({kind:he("p2p-tunnel"),ownerPrincipalId:N().min(1),extId:N().min(1),snapshotHash:N().min(1)})]);B({extId:N().min(1),name:N().min(1),version:N().min(1),contentHash:N().min(1),publishedAt:Q()});const _ue=Bs("kind",[B({kind:he("clean")}),B({kind:he("ready-new-version"),fromVersion:N().min(1),toVersion:N().min(1)}),B({kind:he("error-same-hash"),version:N().min(1)}),B({kind:he("error-version-not-bumped"),localVersion:N().min(1),publishedVersion:N().min(1)}),B({kind:he("error-version-regression"),localVersion:N().min(1),publishedVersion:N().min(1)})]);function Sue(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return(t>>>0).toString(16).padStart(8,"0")}function Q5(e,t){return`${e}-${Sue(t)}`}function J5(e){if(typeof e!="string")return{ok:!1,reason:"version must be a string"};const t=e.split(".");if(t.length!==3)return{ok:!1,reason:`"${e}" — only MAJOR.MINOR.PATCH allowed`};for(const n of t)if(!/^\d+$/.test(n))return{ok:!1,reason:`"${e}" — only numeric segments allowed`};return{ok:!0}}function aH(e,t){const n=NA(e),r=NA(t);for(let s=0;s<3;s++){if(n[s]<r[s])return-1;if(n[s]>r[s])return 1}return 0}function NA(e){const t=J5(e);if(!t.ok)throw new Error(t.reason);const[n,r,s]=e.split(".").map(i=>parseInt(i,10));return[n,r,s]}B({localManifest:B({name:N().min(1),version:N().min(1),contentHash:N().min(1)}),publishState:Bs("kind",[B({kind:he("unpublished")}),B({kind:he("published"),version:N().min(1),contentHash:N().min(1),publishedAt:Q()})]),check:_ue});B({extId:N().min(1),newVersion:N().min(1).nullish()});B({extId:N().min(1)});B({extId:N().min(1),snapshotHash:N().min(1)});B({channelRef:wue,snapshotHash:N().min(1),zipBase64:N().min(1)});B({id:N().min(1),peerDeviceId:N().min(1),senderDeviceId:N().min(1),text:N().min(1),createdAt:Q().int().nonnegative(),readBy:Yi(N().min(1),Q().int().positive()).default({}),origin:B({kind:he("persona"),personaId:N().min(1)}).optional()}).strict();B({peerDeviceId:N().min(1).optional(),id:N().min(1),text:N().min(1),createdAt:Q().int().nonnegative(),origin:B({kind:he("persona"),personaId:N().min(1)}).optional()}).strict();B({peerDeviceId:N().min(1),sinceCreatedAt:Q().int().nonnegative().optional()}).strict();B({peerDeviceId:N().min(1),upToCreatedAt:Q().int().nonnegative()}).strict();B({peerDeviceId:N().min(1).optional(),text:N().min(1)});B({peerDeviceId:N().min(1).optional(),command:N().min(1),timeoutMs:Q().int().positive().optional()}).strict();B({type:he("peerExec:run:ok"),stdout:N(),stderr:N(),exitCode:Q().int().nullable(),timedOut:Me(),stdoutTruncated:Me(),stderrTruncated:Me()}).strict();const lH=Bs("kind",[B({kind:he("at"),at:N().min(1)}),B({kind:he("every"),everyMs:Q().int().positive(),anchorMs:Q().int().nonnegative().optional()}),B({kind:he("cron"),expr:N().min(1),tz:N().min(1).optional()})]),mx=N().trim().min(1);B({personaId:mx,name:N().min(1),schedule:lH,prompt:N().min(1),targetPersona:N().min(1).optional(),timeoutMs:Q().int().positive().optional()});B({personaId:mx,onlyMine:Me().optional()});B({personaId:mx,shiftId:N().min(1)});const kue=B({name:N().min(1).optional(),schedule:lH.optional(),prompt:N().min(1).optional(),targetPersona:N().min(1).optional(),timeoutMs:Q().int().positive().optional(),enabled:Me().optional()});B({personaId:mx,shiftId:N().min(1),patch:kue});B({personaId:mx,shiftId:N().min(1),limit:Q().int().positive().optional()});const Fi="persona-master",eT=B({personaId:N().min(1),deviceId:N().min(1).optional()}),cH=B({id:N().min(1),name:N().min(1),memberPersonas:pe(eT),memberContactDeviceIds:pe(N().min(1)),createdAt:N().min(1),updatedAt:N().min(1)}),uH=N().trim().min(1);B({name:uH,memberPersonas:pe(eT).default([]),memberContactDeviceIds:pe(N().min(1)).default([])});B({channelId:N().min(1),name:uH.optional(),memberPersonas:pe(eT).optional(),memberContactDeviceIds:pe(N().min(1)).optional()});B({channelId:N().min(1)});B({channels:pe(cH)});B({channel:cH});B({ok:he(!0),removedTopics:Q().int().min(0)});const dr=N().trim().min(1),tT=["master-confirmed","owner-needed"],nT=["open","resolved"],Cue=tT[0],dH=tT[1],hH=nT[0],Nue=nT[1],jue=Ve(tT),Eue=Ve(nT),Iue=B({id:dr.optional(),resolves:dr.optional(),type:jue,status:Eue,question:dr,recommendation:dr}).superRefine((e,t)=>{e.type===Cue&&e.status!==Nue&&t.addIssue({code:ke.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),Tue=["planning","running","done"],Rue=Ve(Tue),fH=B({at:N().min(1),actor:N().min(1),action:N().min(1),target:N().optional(),reason:N().min(1),artifacts:pe(dr).optional(),decision:Iue.optional()}),Mue=B({rejectCount:Q().int().min(0),accepted:Me().default(!1),ordinal:Q().int().min(1).optional(),overrideCount:Q().int().min(0).optional()}),rT=B({id:N().min(1),channelId:N().min(1),title:N(),masterSessionId:N().min(1),goal:N(),boundaries:N(),acceptanceCriteria:pe(N()),activity:pe(fH),lineMeta:Yi(Mue),nextLineOrdinal:Q().int().min(1).optional(),state:Rue,createdAt:N().min(1),updatedAt:N().min(1)}),Pue=B({lineId:N().min(1),contextId:N().min(1),taskId:N().min(1),workerSessionId:N().optional(),assignee:N().min(1),focus:N(),status:X5,acceptance:pe(N()),rejectCount:Q().int().min(0),accepted:Me(),ordinal:Q().int().min(1).nullable()});B({channelId:N().min(1)});B({topicId:N().min(1).optional(),sessionId:N().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});B({channelId:N().min(1),title:dr.optional()});B({topicId:N().min(1),title:dr.optional(),goal:dr,boundaries:N(),acceptanceCriteria:pe(dr).min(1)});B({topicId:N().min(1),action:dr,target:dr.optional(),reason:dr,artifacts:pe(dr).optional(),decision:fH.shape.decision});B({topicId:N().min(1),lineId:dr,reason:dr});B({topicId:N().min(1),lineId:dr,reason:dr,artifacts:pe(dr).optional(),watcherVerdict:Ve(["pass","fail"]),overrideReason:dr.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});B({topicId:N().min(1),state:Ve(["done"])});B({topicId:N().min(1),title:dr});B({topicId:N().min(1)});const Aue=rT.extend({lineCount:Q().int().min(0)});B({topics:pe(Aue)});B({topic:rT,lines:pe(Pue)});B({topicId:N().min(1),masterSessionId:N().min(1)});B({rejectCount:Q().int().min(1),needsOwnerAttention:Me()});B({acceptedLines:Q().int().min(1),totalLines:Q().int().min(1),allAccepted:Me(),overrides:Q().int().min(0),needsOwnerAttention:Me()});B({topic:rT});B({ok:he(!0),removedMasterSessionId:N().min(1).nullable(),removedWorkerSessionIds:pe(N().min(1))});const Oue=["ask","allow","deny"],pH=Ve(Oue),Due=B({id:N().min(1),desc:N().min(1),action:pH});B({rules:pe(Due)});B({ruleId:N().min(1)});B({action:pH,desc:N(),source:N().min(1)});const $ue=["created","review-requested"],mH=/^[A-Za-z0-9._-]+$/,If=N().min(1).regex(mH),Tf=N().min(1).regex(mH),gx=Q().int().positive();B({role:Ve($ue)});B({owner:If,repo:Tf,number:gx});B({owner:If,repo:Tf,number:gx,expectedHeadSha:N().min(1)});B({owner:If,repo:Tf,number:gx,body:N().min(1)});B({owner:If,repo:Tf,number:gx,ready:Me()});B({owner:If,repo:Tf});B({owner:If,repo:Tf,number:gx,reviewers:pe(N().min(1)).min(1)});B({page:Q().int().min(1).max(1e3).optional(),search:N().max(100).optional()});B({personaId:N().min(1)});B({personaId:N().min(1)});const Lue=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],Fue=Ve(Lue);B({personaId:N().min(1),appId:N().min(1),appSecret:N().min(1),botName:N().min(1).optional()});const Bue=B({chatId:N().min(1),chatName:N().optional(),lastActiveAt:Q().int().optional()}),zue=B({state:Ve(["unbound","provisioning","bound","broken"]),appId:N().optional(),botName:N().optional(),brokenReason:N().optional(),qrUrl:N().optional(),provisionId:N().optional(),errorReason:Fue.optional(),groups:pe(Bue),needsUpgrade:Me().optional(),upgradeQrUrl:N().optional()});zue.extend({personaId:N().min(1)});B({});B({onboardingCompletedAt:Q()});const Wh=["claude","codex","pi"];B({});B({tools:pe(B({id:Ve(Wh),available:Me(),version:N().optional(),path:N().optional()}))});B({});const Hue=B({tool:Ve(Wh),cwd:N(),toolSessionId:N(),label:N().optional(),createdAt:N(),updatedAt:N(),turns:Q()});B({candidates:pe(Hue)});B({});B({registered:Me()});const Uue=B({kind:Ve(["rpc","file"]),ref:N().min(1).max(300)});B({question:N().min(1).max(500),status:Ve(["unanswered","answered_unverified"]),answer:N().max(4e3).optional(),resolvedBy:Ve(["rpc","source"]).optional(),evidence:pe(Uue).max(20).optional(),docsChecked:pe(N().max(200)).max(20).optional(),unansweredReason:Ve(["no_source_access","user_declined","not_found"]).optional()}).superRefine((e,t)=>{var n;e.status==="answered_unverified"?(e.answer||t.addIssue({code:"custom",path:["answer"],message:"answered_unverified 需要 answer"}),e.resolvedBy||t.addIssue({code:"custom",path:["resolvedBy"],message:"answered_unverified 需要 resolvedBy"}),(n=e.evidence)!=null&&n.length||t.addIssue({code:"custom",path:["evidence"],message:"answered_unverified 需要至少一项 evidence"})):e.unansweredReason||t.addIssue({code:"custom",path:["unansweredReason"],message:"unanswered 需要 unansweredReason"})});B({id:N()});B({tool:Ve(Wh)});const jA=B({usedPercent:Q(),windowDurationMins:Q().optional(),resetsAt:Q().optional()}).strict(),Wue=Bs("kind",[B({kind:he("claude"),loggedIn:Me(),authMethod:N().optional(),apiProvider:N().optional(),apiKeySource:N().optional(),email:N().optional(),orgName:N().optional(),subscriptionType:N().optional()}).strict(),B({kind:he("codex"),login:Bs("type",[B({type:he("none")}).strict(),B({type:he("apiKey")}).strict(),B({type:he("chatgpt"),email:N(),planType:N()}).strict()]),provider:B({name:N(),baseUrl:N().optional()}).strict(),rateLimits:B({primary:jA.optional(),secondary:jA.optional()}).strict().optional()}).strict(),B({kind:he("pi"),providers:pe(B({id:N(),modelCount:Q(),credential:Ve(["api_key","oauth"]).optional(),oauthExpiresAt:Q().optional()}).strict())}).strict()]);B({tool:Ve(Wh),installed:Me(),version:N().optional(),path:N().optional(),account:Wue.optional(),error:N().optional(),modelsLoadedAt:Q().optional()}).strict();const sT="https://cpa-portal-d417.app.clawos.chat";B({apiKey:N().min(1)}).strict();B({ok:he(!0)}).strict();const gH=["cloud-persona-metrics","cloud-persona-conversations","cloud-persona-schedules"],Vue=Ve(gH);B({page:Vue}).strict();B({url:N(),expiresAt:Q().int()}).strict();const xH=["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","larkBot:state"],que="cloud_history_refresh",iT=["idle","running","running-idle","stopped","error","observing"],Kue=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","a2a-task","a2a-result","dispatch-task","dispatch-result"],Gue=["a2a-task","a2a-result","dispatch-task","dispatch-result"];function Pw(e){return Gue.includes(e??"")}function Yue(e,t){return`${t?"dispatch":"a2a"}-${e}`}const Xue=["builtin","global","project","plugin"],Zue=["builtin","global","project","policy","plugin"],vH=Ve(["owner","guest"]);B({id:N().min(1),kind:vH,displayName:N(),feishuUnionId:N().optional()}).strict();const Que=B({did:N().min(1),displayName:N(),feishuUnionId:N().optional(),principal:vH}).strict(),Jue=Ve(iT),ede=B({inputTokens:Q().int().nonnegative(),outputTokens:Q().int().nonnegative(),cacheReadTokens:Q().int().nonnegative().optional(),cacheCreateTokens:Q().int().nonnegative().optional()}),yH={gitBranch:N().optional(),resolvedModel:N().optional(),resolvedEffort:N().optional(),contextUsage:ede.optional(),contextWindowSize:Q().int().positive().optional(),aiLabel:N().optional()},tde=B(yH),bH=B({value:N(),label:N(),description:N().optional()}),nde=B({id:N().min(1),label:N().min(1),description:N().optional(),contextWindowSize:Q().int().positive().optional(),default:Me().optional(),efforts:pe(bH).optional(),defaultEffort:N().optional(),group:N().optional()}),rde=B({id:N().min(1),label:N().min(1),description:N().optional()}),sde=B({name:N().min(1),type:Ve(["string","select","toggle"]),label:N().min(1),description:N().optional(),options:pe(bH).optional(),default:Za().optional(),scope:Ve(["core","tool-specific"])});B({tool:N().min(1),refresh:Me().optional()});const ide=B({rewind:Me(),subagents:Me(),tui:Me(),observe:Me(),fileSharing:Me(),fork:Me()});B({tool:N().min(1),toolSessionIdLabel:N().optional(),models:pe(nde),permissionModes:pe(rde),configSchema:pe(sde),features:ide});const ode=B({tool:N().min(1),pattern:N().min(1),createdAt:N().min(1).optional()});B({cloudEnvironment:Hs.optional(),cloudExpectedImage:gc.optional(),testReleaseId:N().optional(),sessionId:N().min(1),cloudConversationId:N().min(1).optional(),cloudWorkspace:Tw.optional(),cloudPendingTurns:pe(B({id:N().min(1),text:N(),prepared:Me().optional()})).optional(),cloudBranchIntent:kg.optional(),cwd:N().min(1),tool:he("claude").or(N().min(1)).default("claude"),toolSessionId:N().optional(),label:N().optional(),model:N().optional(),permissionMode:N().optional(),effort:N().optional(),serviceTier:N().optional(),...yH,aiLabelGeneratedAt:N().optional(),permissionRules:pe(ode).optional(),pinnedAt:Q().int().nonnegative().nullable().optional(),archivedAt:Q().int().nonnegative().nullable().optional(),pinSortOrder:Q().int().nullable().optional(),unreadAt:N().min(1).nullable().optional(),iconKey:N().optional(),forkedFromSessionId:N().min(1).optional(),ephemeral:Me().optional(),deployId:N().min(1).optional(),ownerPersonaId:N().min(1).optional(),projectPath:N().min(1).optional(),chatId:N().min(1).optional(),creatorPrincipalId:N().min(1).optional(),creatorDisplayName:N().min(1).optional(),creatorFeishuUnionId:N().min(1).optional(),originOwnerPrincipalId:N().min(1).optional(),originOwnerPersonaId:N().min(1).optional(),dispatchedFromSessionId:N().min(1).optional(),a2aContextId:N().min(1).optional(),shiftFiredFromSessionId:N().min(1).optional(),larkChatId:N().min(1).optional(),larkChatName:N().min(1).optional(),larkChatType:Ve(["p2p","group"]).optional(),createdAt:N().min(1),updatedAt:N().min(1)});const js={turnId:N().min(1).optional(),seq:Q().int().nonnegative().optional(),ts:N().optional(),uuid:N().optional()},ade=Ve(Kue),lde=B({readCount:Q().int().nonnegative().optional(),searchCount:Q().int().nonnegative().optional(),bashCount:Q().int().nonnegative().optional(),editFileCount:Q().int().nonnegative().optional(),linesAdded:Q().int().nonnegative().optional(),linesRemoved:Q().int().nonnegative().optional(),otherToolCount:Q().int().nonnegative().optional()}),cde=B({oldStart:Q().int().nonnegative(),oldLines:Q().int().nonnegative(),newStart:Q().int().nonnegative(),newLines:Q().int().nonnegative(),lines:pe(N())}),ude=B({agentId:N().optional(),agentType:N().optional(),status:N().optional(),prompt:N().optional(),filePath:N().optional(),structuredPatch:pe(cde).optional(),stats:B({durationMs:Q().int().nonnegative().optional(),tokens:Q().int().nonnegative().optional(),toolUseCount:Q().int().nonnegative().optional(),toolStats:lde.optional()}).optional()}),dde=B({path:N(),content:N(),mtimeMs:Q().optional()}),hde=B({label:N().min(1),description:N().optional()}),wH=B({question:N().min(1),multiSelect:Me(),options:pe(hde).min(1)}),fde=["completed","interrupted"];Bs("kind",[B({...js,kind:he("session_init"),toolSessionId:N().optional()}),B({...js,kind:he("thinking"),text:N(),partialId:N().optional()}),B({...js,kind:he("text"),text:N(),partialId:N().optional()}),B({...js,kind:he("user_text"),text:N(),meta:ade.optional(),taskId:N().optional(),parentToolUseId:N().optional(),sender:Que.optional()}),B({...js,kind:he("tool_call"),toolUseId:N(),tool:N(),toolKind:N().optional(),input:Za()}),B({...js,kind:he("tool_result"),toolUseId:N(),output:Za().optional(),error:N().optional(),toolResultExtra:ude.optional(),sourceToolAssistantUUID:N().optional(),askQuestionAnswers:Yi(N(),N()).optional()}),B({...js,kind:he("attachment_memories"),memories:pe(dde)}),B({...js,kind:he("permission_request"),requestId:N(),tool:N(),input:Za(),toolUseId:N().optional()}),B({...js,kind:he("ask_user_question"),toolUseId:N(),questions:pe(wH)}),B({...js,kind:he("turn_end"),durationMs:Q().int().nonnegative().optional(),reason:Ve(fde).optional(),turnId:N().min(1).optional()}),B({...js,kind:he("subagent_progress"),toolUseId:N(),agentId:N(),status:Ve(["started","running","completed","failed"]),description:N().optional(),lastToolName:N().optional(),prompt:N().optional(),stats:B({durationMs:Q().int().nonnegative().optional(),tokens:Q().int().nonnegative().optional(),toolUseCount:Q().int().nonnegative().optional()}).optional()}),B({...js,kind:he("error"),message:N()}),B({...js,kind:he("meta_update"),patch:tde}),B({...js,kind:he("meta-text"),text:N(),metaSource:Ve(["cc","owner"]).optional()})]);B({cwd:N().min(1).optional(),tool:N().optional(),label:N().optional(),aiLabel:N().optional(),model:N().optional(),permissionMode:N().optional(),effort:N().optional(),serviceTier:V7.optional(),iconKey:N().optional(),forkedFromSessionId:N().min(1).optional(),forkAt:nce([B({messageUuid:N().min(1)}).strict(),B({turnId:N().min(1)}).strict()]).optional(),ephemeral:Me().optional(),ownerPersonaId:N().min(1).optional(),projectPath:N().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});B({path:N().min(1),name:N().min(1),createdAt:N().datetime(),pinnedAt:Q().optional()});B({path:N().min(1),pinnedAt:Q().nullable()});B({path:N().min(1)});B({path:N().min(1).optional(),name:N().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});B({cwd:N().min(1),tool:N().min(1),toolSessionId:N().min(1),label:N().optional(),aiLabel:N().optional(),iconKey:N().optional(),createdAt:N().datetime(),updatedAt:N().datetime(),ownerPersonaId:N().min(1).optional()});B({originOnly:Me().optional(),ownerPersonaId:N().min(1).optional(),limit:Q().int().positive().optional(),offset:Q().int().nonnegative().optional()});B({sessionId:N().min(1)});B({sessionId:N().min(1),patch:B({label:N().optional(),tool:N().min(1).optional(),model:N().optional(),permissionMode:N().optional(),effort:N().optional(),cwd:N().optional(),iconKey:N().optional(),ephemeral:he(!1).optional()})});B({id:N().min(1),text:N(),queuedAt:Q(),senderDisplayName:N().optional()});B({sessionId:N().min(1),text:N(),queueWhileRunning:Me().optional()});B({sessionId:N().min(1),id:N().min(1).optional()});B({sessionId:N().min(1),userMessageId:N().min(1),dryRun:Me().optional()});B({canRewind:Me(),error:N().optional(),filesChanged:pe(N()).optional(),insertions:Q().int().nonnegative().optional(),deletions:Q().int().nonnegative().optional()});B({sessionId:N().min(1),userMessageId:N().min(1)});const pde=B({oldStart:Q().int().nonnegative(),oldLines:Q().int().nonnegative(),newStart:Q().int().nonnegative(),newLines:Q().int().nonnegative(),lines:pe(N())}),mde=B({filePath:N().min(1),hunks:pe(pde),insertions:Q().int().nonnegative(),deletions:Q().int().nonnegative(),status:Ve(["modified","added","deleted"]).optional()});B({canRewind:Me(),error:N().optional(),files:pe(mde),totalInsertions:Q().int().nonnegative(),totalDeletions:Q().int().nonnegative()});B({userMessageIds:pe(N())});B({sessionId:N().min(1),toolSessionId:N().min(1)});B({cwd:N().min(1),toolSessionId:N().min(1),messageUuid:N().min(1).optional(),turnId:N().min(1).optional(),sourceSessionId:N().min(1).optional(),targetCwd:N().min(1).optional()}).refine(e=>!!(e.messageUuid||e.turnId),"messageUuid or turnId required");B({forkedToolSessionId:N().min(1),forkedFilePath:N().min(1)});B({sessionId:N().min(1),toolSessionId:N().min(1),jsonlPath:N().optional()});B({sessionId:N().min(1),afterSeq:Q().int().min(-1)});B({sessionId:N().min(1),permissionRequestId:N().min(1),allow:Me(),permanent:Me().optional(),pattern:N().optional()});B({projectPath:N().min(1)});B({sessionId:N().min(1),limit:Q().int().positive().max(5e3).optional(),offset:Q().int().nonnegative().optional(),snapshotId:N().uuid().optional(),slim:Me().optional(),view:Ve(["turns","items"]).optional(),cursor:N().min(1).max(16384).optional(),turnId:N().min(1).max(256).optional()}).superRefine((e,t)=>{e.view==="items"&&!e.turnId&&t.addIssue({code:ke.custom,path:["turnId"],message:"items requires turnId"}),e.view&&(e.offset!==void 0||e.slim!==void 0)&&t.addIssue({code:ke.custom,message:"native views do not accept offset or slim"}),!e.view&&(e.cursor!==void 0||e.turnId!==void 0)&&t.addIssue({code:ke.custom,message:"cursor and turnId require a native view"}),e.view==="turns"&&e.turnId!==void 0&&t.addIssue({code:ke.custom,path:["turnId"],message:"turns does not accept turnId"}),e.view&&e.limit!==void 0&&e.limit>100&&t.addIssue({code:ke.custom,path:["limit"],message:"native page limit is 100"})});B({cwd:N().min(1),toolSessionId:N().min(1)});B({cwd:N().min(1),toolSessionId:N().min(1),subagentId:N().min(1)});B({cwd:N().min(1).optional(),path:N().optional(),showHidden:Me().optional()});B({cwd:N().min(1),path:N().min(1)});B({cwd:N().min(1),tool:N().optional()});B({name:N().min(1),source:Ve(Xue),path:N().optional(),description:N().optional(),plugin:N().optional()});const gde=B({name:N().min(1),source:Ve(Zue),path:N().optional(),description:N().optional(),whenToUse:N().optional(),plugin:N().optional()});B({cwd:N().min(1),tool:N().optional()});B({agents:pe(gde)});B({sessionId:N().optional()});B({sessionId:N().min(1).optional()});B({sessionId:N().min(1),pinned:Me()});B({sessionId:N().min(1),archived:Me()});B({query:N().min(1),sessionIds:pe(N().min(1)),limit:Q().int().positive().max(50).optional()});const xde=B({sessionId:N().min(1),snippet:N()});B({type:he("session:searchContent"),matches:pe(xde)});B({type:he("peerSession:upsert:ok")});B({sessionId:N().min(1)});B({type:he("peerSession:remove:ok")});B({orderedIds:pe(N().min(1)).min(1)});B({cwd:N().min(1)});B({isGitRoot:Me(),gitRoot:N().nullable()});B({cwd:N().min(1)});B({branch:N().nullable()});B({cwd:N().min(1)});B({branches:pe(N()),head:N().nullable()});const vde=B({cwd:N().min(1),updatedAt:N().min(1)});B({dirs:pe(vde)});B({type:he("session:question"),sessionId:N().min(1),toolUseId:N().min(1),requestId:N().min(1),questions:pe(wH).min(1)});B({type:he("session:question:cleared"),sessionId:N().min(1),toolUseId:N().min(1),answers:Yi(N(),N()).optional()});B({sessionId:N().min(1),toolUseId:N().min(1),answers:Yi(N(),N())});B({ok:he(!0)});B({sessionId:N().min(1),toolUseId:N().min(1)});B({ok:he(!0)});const _H=B({name:N().min(1),version:N().min(1),instanceId:N().min(1),deviceLabel:N().transform(e=>e.trim().slice(0,64)).optional()});B({type:he("auth"),token:N().min(1),scheme:he("bearer").optional(),clientInfo:_H.optional()});B({type:he("auth:ok"),version:N().min(1).optional(),protocolVersion:Q().int().nonnegative().optional()});const yde=B({clientId:N().min(1),connectedAt:Q().int().nonnegative(),self:Me(),clientInfo:_H.optional()});B({type:he("device:connections:ok"),connections:pe(yde)});B({type:he("tunnel:ready"),url:N().min(1),subdomain:N().min(1)});B({type:he("tunnel:exited"),code:Q().int().nullable(),subdomain:N().nullable(),url:N().nullable()});B({type:he("tunnel:unavailable"),reason:N().min(1),failedAt:N().min(1)});const bde=B({sessionId:N().min(1),status:Jue,freshSpawn:Me(),pendingPermissionRequestIds:pe(N().min(1)),pendingQuestionToolUseIds:pe(N().min(1))});B({type:he("info"),version:N(),protocolVersion:Q(),hostname:N(),os:N(),tools:pe(B({id:N(),available:Me()})),runningSessions:pe(bde),tokenRole:Ve(lce).optional(),isLoopback:Me().optional(),httpBaseUrl:N().optional(),httpToken:N().optional(),daemonSource:Ve(["ota","packaged"]).optional(),globalCliVersion:N().nullable().optional()});B({});B({method:N().min(1).optional()});const wde=["allowed","conditional","denied"],_de=Ve(wde),Sde=B({name:N().min(1),status:_de,description:N().min(1),args:pe(B({name:N(),required:Me()})).nullable(),argsSchema:Yi(Za()).optional(),reason:N().optional()});B({type:he("meta:methods"),methods:pe(Sde)});const EA=1,kde=B({usedBytes:Q().int().nonnegative(),sizeBytes:Q().int().positive(),measuredAt:Q().int().nonnegative()}).strict();B({volume:kde.nullable()}).strict();const IA=25*1024*1024,oT={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/plain",".markdown":"text/plain",".csv":"text/plain",".log":"text/plain",".json":"application/json",".xml":"application/xml",".yaml":"application/yaml",".yml":"application/yaml",".html":"text/html",".conf":"text/plain",".cfg":"text/plain",".ini":"text/plain",".toml":"text/plain"},SH=new Set([...Object.values(oT),"application/x-yaml"]),kH=[...SH,"text/*",...Object.keys(oT)].join(",");function CH(e,t){const n=t.split(";",1)[0].trim().toLowerCase();if(n===""||n==="application/octet-stream"){const r=e.lastIndexOf("."),s=r>0?e.slice(r).toLowerCase():"";return oT[s]??null}return SH.has(n)||n.startsWith("text/")?n:null}const Cde=["daemon","main","renderer"],Nde=Ve(Cde),jde=["debug","info","warn","error"],Ede=Ve(jde);B({ts:Q().int(),source:Nde,level:Ede,msg:N(),ownerPrincipalId:N(),deviceId:N(),appVersion:N(),daemonVersion:N().optional(),os:N(),meta_json:N().optional(),sessionId:N().optional()});B({v:he(1),visitorId:N().min(1),displayName:N(),provider:N(),iat:Q(),exp:Q()});const Ide=B({visitorId:N(),displayName:N(),avatarUrl:N().optional(),provider:N(),firstSeen:Q(),lastSeen:Q()});B({visitors:pe(Ide)});B({type:he("web:open"),url:N().min(1),expiresAt:Q()});B({ticket:N().min(1)}).strict();B({token:N().min(1),expiresAt:Q()});const Tde=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,NH=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,Rde="clawd-a2a-task",Mde="clawd-a2a-result",Pde="clawd-dispatch-task",Ade="clawd-dispatch-result",Ode=["completed","failed","input_required","canceled","rejected"],TA=120,jH=[{tag:Rde,kind:"task",legacy:!1},{tag:Mde,kind:"result",legacy:!1},{tag:Pde,kind:"task",legacy:!0},{tag:Ade,kind:"result",legacy:!0}];function Dde(e){if(!e)return null;let t=null;for(const n of jH){const r=e.search(Vde(n.tag));r>=0&&(t===null||r<t.at)&&(t={at:r,kind:n.kind,legacy:n.legacy})}return t?{kind:t.kind,legacy:t.legacy}:null}function $de(e){if(!e)return[];const t=[];for(const n of jH){const r=new RegExp(`<${n.tag}\\b([^>]*)>([\\s\\S]*?)</${n.tag}>`,"gi");for(let s=r.exec(e);s!==null;s=r.exec(e))t.push({at:s.index,block:Lde(n.kind,n.legacy,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Lde(e,t,n,r){var h;const s=qde(n),i=cj(Wde(Ik(r,"detail")??r)),o=(h=Ik(r,"brief"))==null?void 0:h.trim(),l=o&&o.length>0?cj(o):Fde(i),c=s.round!==void 0?Number.parseInt(s.round,10):void 0,u=s.status,d=t?u==="success"?"completed":u==="failure"?"failed":void 0:Ode.find(f=>f===u);return{kind:e,contextId:(t?s["dispatch-id"]:s["context-id"])??"",...!t&&s["task-id"]?{taskId:s["task-id"]}:{},...s.from?{from:s.from}:{},...e==="task"&&c!==void 0&&Number.isFinite(c)?{round:c}:{},...e==="result"&&d?{status:d}:{},brief:l,briefIsDerived:!(o&&o.length>0),detail:i,filePaths:Ude(Ik(r,"files")),legacy:t}}function Fde(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>TA?`${n.slice(0,TA)}…`:n}const Bde="clawd-a2a-task|clawd-a2a-result|clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",zde=new RegExp(`<\\\\(\\\\*)(/?)(${Bde})\\b`,"g");function Hde(e){return cj(e)}function cj(e){return e.replace(zde,"<$1$2$3")}function Ik(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function Ude(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 sA=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 s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const Lae={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},Fae={motionBase:!0,motionUnit:!0},Bae={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},l7=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:s}=t,i=sA(t,["override"]);let o=Object.assign(Object.assign({},r),{override:s});return o=a7(o),i&&Object.entries(i).forEach(([l,c])=>{const{theme:u}=c,d=sA(c,["theme"]);let h=d;u&&(h=l7(Object.assign(Object.assign({},o),d),{override:d},u)),o[l]=h}),o};function c7(){const{token:e,hashed:t,theme:n,override:r,cssVar:s}=q.useContext(i7),i=`${Dae}-${t||""}`,o=n||s7,[l,c,u]=joe(o,[bg,e],{salt:i,override:r,getComputedToken:l7,formatToken:a7,cssVar:s&&{prefix:s.prefix,key:s.key,unitless:Lae,ignore:Fae,preserve:Bae}});return[o,u,t?c:"",l,s]}const zae=()=>({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"}}),Hae=e=>({[`.${e}`]:Object.assign(Object.assign({},zae()),{[`.${e} .${e}-icon`]:{display:"block"}})}),Uae=(e,t)=>{const[n,r]=c7();return tae({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>Hae(e))},Wae=Object.assign({},kf),{useId:iA}=Wae,Vae=()=>"",qae=typeof iA>"u"?Vae:iA;function Kae(e,t,n){var r;const s=e||{},i=s.inherit===!1||!t?Object.assign(Object.assign({},Tb),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Tb.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=qae();return E9(()=>{var l,c;if(!e)return t;const u=Object.assign({},i.components);Object.keys(e.components||{}).forEach(f=>{u[f]=Object.assign(Object.assign({},u[f]),e.components[f])});const d=`css-var-${o.replace(/:/g,"")}`,h=((l=s.cssVar)!==null&&l!==void 0?l:i.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof i.cssVar=="object"?i.cssVar:{}),typeof s.cssVar=="object"?s.cssVar:{}),{key:typeof s.cssVar=="object"&&((c=s.cssVar)===null||c===void 0?void 0:c.key)||d});return Object.assign(Object.assign(Object.assign({},i),s),{token:Object.assign(Object.assign({},i.token),s.token),components:u,cssVar:h})},[s,i],(l,c)=>l.some((u,d)=>{const h=c[d];return!toe(u,h,!0)}))}var Gae=["children"],u7=p.createContext({});function Yae(e){var t=e.children,n=ci(e,Gae);return p.createElement(u7.Provider,{value:n},t)}var Xae=function(e){Pr(n,e);var t=R9(n);function n(){return Rn(this,n),t.apply(this,arguments)}return Mn(n,[{key:"render",value:function(){return this.props.children}}]),n}(p.Component);function Zae(e){var t=p.useReducer(function(l){return l+1},0),n=_t(t,2),r=n[1],s=p.useRef(e),i=qN(function(){return s.current}),o=qN(function(l){s.current=typeof l=="function"?l(s.current):l,r()});return[i,o]}var Ol="none",i0="appear",o0="enter",a0="leave",oA="none",go="prepare",ah="start",lh="active",A5="end",d7="prepared";function aA(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 Qae(e,t){var n={animationend:aA("Animation","AnimationEnd"),transitionend:aA("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var Jae=Qae(hl(),typeof window<"u"?window:{}),h7={};if(hl()){var ele=document.createElement("div");h7=ele.style}var l0={};function f7(e){if(l0[e])return l0[e];var t=Jae[e];if(t)for(var n=Object.keys(t),r=n.length,s=0;s<r;s+=1){var i=n[s];if(Object.prototype.hasOwnProperty.call(t,i)&&i in h7)return l0[e]=t[i],l0[e]}return""}var p7=f7("animationend"),m7=f7("transitionend"),g7=!!(p7&&m7),lA=p7||"animationend",cA=m7||"transitionend";function uA(e,t){if(!e)return null;if(Tn(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const tle=function(e){var t=p.useRef();function n(s){s&&(s.removeEventListener(cA,e),s.removeEventListener(lA,e))}function r(s){t.current&&t.current!==s&&n(t.current),s&&s!==t.current&&(s.addEventListener(cA,e),s.addEventListener(lA,e),t.current=s)}return p.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var x7=hl()?p.useLayoutEffect:p.useEffect;const nle=function(){var e=p.useRef(null);function t(){SN.cancel(e.current)}function n(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var i=SN(function(){s<=1?r({isCanceled:function(){return i!==e.current}}):n(r,s-1)});e.current=i}return p.useEffect(function(){return function(){t()}},[]),[n,t]};var rle=[go,ah,lh,A5],sle=[go,d7],v7=!1,ile=!0;function y7(e){return e===lh||e===A5}const ole=function(e,t,n){var r=KN(oA),s=_t(r,2),i=s[0],o=s[1],l=nle(),c=_t(l,2),u=c[0],d=c[1];function h(){o(go,!0)}var f=t?sle:rle;return x7(function(){if(i!==oA&&i!==A5){var m=f.indexOf(i),g=f[m+1],x=n(i);x===v7?o(g,!0):g&&u(function(b){function y(){b.isCanceled()||o(g,!0)}x===!0?y():Promise.resolve(x).then(y)})}},[e,i]),p.useEffect(function(){return function(){d()}},[]),[h,i]};function ale(e,t,n,r){var s=r.motionEnter,i=s===void 0?!0:s,o=r.motionAppear,l=o===void 0?!0:o,c=r.motionLeave,u=c===void 0?!0:c,d=r.motionDeadline,h=r.motionLeaveImmediately,f=r.onAppearPrepare,m=r.onEnterPrepare,g=r.onLeavePrepare,x=r.onAppearStart,b=r.onEnterStart,y=r.onLeaveStart,v=r.onAppearActive,w=r.onEnterActive,_=r.onLeaveActive,S=r.onAppearEnd,k=r.onEnterEnd,C=r.onLeaveEnd,j=r.onVisibleChanged,T=KN(),E=_t(T,2),R=E[0],P=E[1],A=Zae(Ol),O=_t(A,2),F=O[0],z=O[1],W=KN(null),L=_t(W,2),D=L[0],I=L[1],V=F(),H=p.useRef(!1),M=p.useRef(null);function Y(){return n()}var X=p.useRef(!1);function K(){z(Ol),I(null,!0)}var te=qN(function(Be){var Re=F();if(Re!==Ol){var ze=Y();if(!(Be&&!Be.deadline&&Be.target!==ze)){var wt=X.current,St;Re===i0&&wt?St=S==null?void 0:S(ze,Be):Re===o0&&wt?St=k==null?void 0:k(ze,Be):Re===a0&&wt&&(St=C==null?void 0:C(ze,Be)),wt&&St!==!1&&K()}}}),ce=tle(te),ee=_t(ce,1),de=ee[0],be=function(Re){switch(Re){case i0:return Ze(Ze(Ze({},go,f),ah,x),lh,v);case o0:return Ze(Ze(Ze({},go,m),ah,b),lh,w);case a0:return Ze(Ze(Ze({},go,g),ah,y),lh,_);default:return{}}},se=p.useMemo(function(){return be(V)},[V]),ae=ole(V,!e,function(Be){if(Be===go){var Re=se[go];return Re?Re(Y()):v7}if(xe in se){var ze;I(((ze=se[xe])===null||ze===void 0?void 0:ze.call(se,Y(),null))||null)}return xe===lh&&V!==Ol&&(de(Y()),d>0&&(clearTimeout(M.current),M.current=setTimeout(function(){te({deadline:!0})},d))),xe===d7&&K(),ile}),Z=_t(ae,2),fe=Z[0],xe=Z[1],Te=y7(xe);X.current=Te;var Je=p.useRef(null);x7(function(){if(!(H.current&&Je.current===t)){P(t);var Be=H.current;H.current=!0;var Re;!Be&&t&&l&&(Re=i0),Be&&t&&i&&(Re=o0),(Be&&!t&&u||!Be&&h&&!t&&u)&&(Re=a0);var ze=be(Re);Re&&(e||ze[go])?(z(Re),fe()):z(Ol),Je.current=t}},[t]),p.useEffect(function(){(V===i0&&!l||V===o0&&!i||V===a0&&!u)&&z(Ol)},[l,i,u]),p.useEffect(function(){return function(){H.current=!1,clearTimeout(M.current)}},[]);var ve=p.useRef(!1);p.useEffect(function(){R&&(ve.current=!0),R!==void 0&&V===Ol&&((ve.current||R)&&(j==null||j(R)),ve.current=!0)},[R,V]);var Ne=D;return se[go]&&xe===ah&&(Ne=Mt({transition:"none"},Ne)),[V,xe,Ne,R??t]}function lle(e){var t=e;Tn(e)==="object"&&(t=e.transitionSupport);function n(s,i){return!!(s.motionName&&t&&i!==!1)}var r=p.forwardRef(function(s,i){var o=s.visible,l=o===void 0?!0:o,c=s.removeOnLeave,u=c===void 0?!0:c,d=s.forceRender,h=s.children,f=s.motionName,m=s.leavedClassName,g=s.eventProps,x=p.useContext(u7),b=x.motion,y=n(s,b),v=p.useRef(),w=p.useRef();function _(){try{return v.current instanceof HTMLElement?v.current:Bie(w.current)}catch{return null}}var S=ale(y,l,_,s),k=_t(S,4),C=k[0],j=k[1],T=k[2],E=k[3],R=p.useRef(E);E&&(R.current=!0);var P=p.useCallback(function(L){v.current=L,Wie(i,L)},[i]),A,O=Mt(Mt({},g),{},{visible:l});if(!h)A=null;else if(C===Ol)E?A=h(Mt({},O),P):!u&&R.current&&m?A=h(Mt(Mt({},O),{},{className:m}),P):d||!u&&!m?A=h(Mt(Mt({},O),{},{style:{display:"none"}}),P):A=null;else{var F;j===go?F="prepare":y7(j)?F="active":j===ah&&(F="start");var z=uA(f,"".concat(C,"-").concat(F));A=h(Mt(Mt({},O),{},{className:Eie(uA(f,C),Ze(Ze({},z,z&&F),f,typeof f=="string")),style:T}),P)}if(p.isValidElement(A)&&Vie(A)){var W=qie(A);W||(A=p.cloneElement(A,{ref:P}))}return p.createElement(Xae,{ref:w},A)});return r.displayName="CSSMotion",r}const cle=lle(g7);var GN="add",YN="keep",XN="remove",Ck="removed";function ule(e){var t;return e&&Tn(e)==="object"&&"key"in e?t=e:t={key:e},Mt(Mt({},t),{},{key:String(t.key)})}function ZN(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(ule)}function dle(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,s=t.length,i=ZN(e),o=ZN(t);i.forEach(function(u){for(var d=!1,h=r;h<s;h+=1){var f=o[h];if(f.key===u.key){r<h&&(n=n.concat(o.slice(r,h).map(function(m){return Mt(Mt({},m),{},{status:GN})})),r=h),n.push(Mt(Mt({},f),{},{status:YN})),r+=1,d=!0;break}}d||n.push(Mt(Mt({},u),{},{status:XN}))}),r<s&&(n=n.concat(o.slice(r).map(function(u){return Mt(Mt({},u),{},{status:GN})})));var l={};n.forEach(function(u){var d=u.key;l[d]=(l[d]||0)+1});var c=Object.keys(l).filter(function(u){return l[u]>1});return c.forEach(function(u){n=n.filter(function(d){var h=d.key,f=d.status;return h!==u||f!==XN}),n.forEach(function(d){d.key===u&&(d.status=YN)})}),n}var hle=["component","children","onVisibleChanged","onAllRemoved"],fle=["status"],ple=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function mle(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:cle,n=function(r){Pr(i,r);var s=R9(i);function i(){var o;Rn(this,i);for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];return o=s.call.apply(s,[this].concat(c)),Ze(wN(o),"state",{keyEntities:[]}),Ze(wN(o),"removeKey",function(d){o.setState(function(h){var f=h.keyEntities.map(function(m){return m.key!==d?m:Mt(Mt({},m),{},{status:Ck})});return{keyEntities:f}},function(){var h=o.state.keyEntities,f=h.filter(function(m){var g=m.status;return g!==Ck}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return Mn(i,[{key:"render",value:function(){var l=this,c=this.state.keyEntities,u=this.props,d=u.component,h=u.children,f=u.onVisibleChanged;u.onAllRemoved;var m=ci(u,hle),g=d||p.Fragment,x={};return ple.forEach(function(b){x[b]=m[b],delete m[b]}),delete m.keys,p.createElement(g,m,c.map(function(b,y){var v=b.status,w=ci(b,fle),_=v===GN||v===YN;return p.createElement(t,bt({},x,{key:w.key,visible:_,eventProps:w,onVisibleChanged:function(k){f==null||f(k,{key:w.key}),k||l.removeKey(w.key)}}),function(S,k){return h(Mt(Mt({},S),{},{index:y}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(l,c){var u=l.keys,d=c.keyEntities,h=ZN(u),f=dle(d,h);return{keyEntities:f.filter(function(m){var g=d.find(function(x){var b=x.key;return m.key===b});return!(g&&g.status===Ck&&m.status===XN)})}}}]),i}(p.Component);return Ze(n,"defaultProps",{component:"div"}),n}mle(g7);const dA=p.createContext(!0);function gle(e){const t=p.useContext(dA),{children:n}=e,[,r]=c7(),{motion:s}=r,i=p.useRef(!1);return i.current||(i.current=t!==s),i.current?p.createElement(dA.Provider,{value:s},p.createElement(Yae,{motion:s},n)):n}const xle=()=>null;var vle=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 s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n};const yle=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let b7;function ble(){return b7||WN}function wle(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const _le=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:s}=e;t!==void 0&&(b7=t),r&&wle(r)&&Tae(ble(),r)},Sle=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:s,anchor:i,form:o,locale:l,componentSize:c,direction:u,space:d,splitter:h,virtual:f,dropdownMatchSelectWidth:m,popupMatchSelectWidth:g,popupOverflow:x,legacyLocale:b,parentContext:y,iconPrefixCls:v,theme:w,componentDisabled:_,segmented:S,statistic:k,spin:C,calendar:j,carousel:T,cascader:E,collapse:R,typography:P,checkbox:A,descriptions:O,divider:F,drawer:z,skeleton:W,steps:L,image:D,layout:I,list:V,mentions:H,modal:M,progress:Y,result:X,slider:K,breadcrumb:te,menu:ce,pagination:ee,input:de,textArea:be,empty:se,badge:ae,radio:Z,rate:fe,switch:xe,transfer:Te,avatar:Je,message:ve,tag:Ne,table:Be,card:Re,tabs:ze,timeline:wt,timePicker:St,upload:oe,notification:le,tree:me,colorPicker:Ke,datePicker:Ge,rangePicker:ut,flex:tn,wave:qe,dropdown:Zt,warning:Se,tour:Pe,tooltip:dt,popover:Pt,popconfirm:hn,floatButton:we,floatButtonGroup:ne,variant:Oe,inputNumber:it,treeSelect:nt}=e,kt=p.useCallback((Ct,Ut)=>{const{prefixCls:hr}=e;if(Ut)return Ut;const rr=hr||y.getPrefixCls("");return Ct?`${rr}-${Ct}`:rr},[y.getPrefixCls,e.prefixCls]),At=v||y.iconPrefixCls||o7,zt=n||y.csp;Uae(At,zt);const sn=Kae(w,y.theme,{prefixCls:kt("")}),$n={csp:zt,autoInsertSpaceInButton:r,alert:s,anchor:i,locale:l||b,direction:u,space:d,splitter:h,virtual:f,popupMatchSelectWidth:g??m,popupOverflow:x,getPrefixCls:kt,iconPrefixCls:At,theme:sn,segmented:S,statistic:k,spin:C,calendar:j,carousel:T,cascader:E,collapse:R,typography:P,checkbox:A,descriptions:O,divider:F,drawer:z,skeleton:W,steps:L,image:D,input:de,textArea:be,layout:I,list:V,mentions:H,modal:M,progress:Y,result:X,slider:K,breadcrumb:te,menu:ce,pagination:ee,empty:se,badge:ae,radio:Z,rate:fe,switch:xe,transfer:Te,avatar:Je,message:ve,tag:Ne,table:Be,card:Re,tabs:ze,timeline:wt,timePicker:St,upload:oe,notification:le,tree:me,colorPicker:Ke,datePicker:Ge,rangePicker:ut,flex:tn,wave:qe,dropdown:Zt,warning:Se,tour:Pe,tooltip:dt,popover:Pt,popconfirm:hn,floatButton:we,floatButtonGroup:ne,variant:Oe,inputNumber:it,treeSelect:nt},Lt=Object.assign({},y);Object.keys($n).forEach(Ct=>{$n[Ct]!==void 0&&(Lt[Ct]=$n[Ct])}),yle.forEach(Ct=>{const Ut=e[Ct];Ut&&(Lt[Ct]=Ut)}),typeof r<"u"&&(Lt.button=Object.assign({autoInsertSpace:r},Lt.button));const xn=E9(()=>Lt,Lt,(Ct,Ut)=>{const hr=Object.keys(Ct),rr=Object.keys(Ut);return hr.length!==rr.length||hr.some(fr=>Ct[fr]!==Ut[fr])}),{layer:yn}=p.useContext(Cw),Sn=p.useMemo(()=>({prefixCls:At,csp:zt,layer:yn?"antd":void 0}),[At,zt,yn]);let Qt=p.createElement(p.Fragment,null,p.createElement(xle,{dropdownMatchSelectWidth:m}),t);const _e=p.useMemo(()=>{var Ct,Ut,hr,rr;return lae(((Ct=Ew.Form)===null||Ct===void 0?void 0:Ct.defaultValidateMessages)||{},((hr=(Ut=xn.locale)===null||Ut===void 0?void 0:Ut.Form)===null||hr===void 0?void 0:hr.defaultValidateMessages)||{},((rr=xn.form)===null||rr===void 0?void 0:rr.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[xn,o==null?void 0:o.validateMessages]);Object.keys(_e).length>0&&(Qt=p.createElement(uae.Provider,{value:_e},Qt)),l&&(Qt=p.createElement(fae,{locale:l,_ANT_MARK__:hae},Qt)),Qt=p.createElement(iae.Provider,{value:Sn},Qt),c&&(Qt=p.createElement(Mae,{size:c},Qt)),Qt=p.createElement(gle,null,Qt);const vt=p.useMemo(()=>{const Ct=sn||{},{algorithm:Ut,token:hr,components:rr,cssVar:fr}=Ct,eo=vle(Ct,["algorithm","token","components","cssVar"]),wi=Ut&&(!Array.isArray(Ut)||Ut.length>0)?NN(Ut):s7,to={};Object.entries(rr||{}).forEach(([no,ro])=>{const Wt=Object.assign({},ro);"algorithm"in Wt&&(Wt.algorithm===!0?Wt.theme=wi:(Array.isArray(Wt.algorithm)||typeof Wt.algorithm=="function")&&(Wt.theme=NN(Wt.algorithm)),delete Wt.algorithm),to[no]=Wt});const ja=Object.assign(Object.assign({},bg),hr);return Object.assign(Object.assign({},eo),{theme:wi,token:ja,components:to,override:Object.assign({override:ja},to),cssVar:fr})},[sn]);return w&&(Qt=p.createElement(i7.Provider,{value:vt},Qt)),xn.warning&&(Qt=p.createElement(cae.Provider,{value:xn.warning},Qt)),_!==void 0&&(Qt=p.createElement(Rae,{disabled:_},Qt)),p.createElement(Iw.Provider,{value:xn},Qt)},Ef=e=>{const t=p.useContext(Iw),n=p.useContext(e7);return p.createElement(Sle,Object.assign({parentContext:t,legacyLocale:n},e))};Ef.ConfigContext=Iw;Ef.SizeContext=wg;Ef.config=_le;Ef.useConfig=Pae;Object.defineProperty(Ef,"SizeContext",{get:()=>wg});var w7={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Br,function(){var n=1e3,r=6e4,s=36e5,i="millisecond",o="second",l="minute",c="hour",u="day",d="week",h="month",f="quarter",m="year",g="date",x="Invalid Date",b=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(O){var F=["th","st","nd","rd"],z=O%100;return"["+O+(F[(z-20)%10]||F[z]||F[0])+"]"}},w=function(O,F,z){var W=String(O);return!W||W.length>=F?O:""+Array(F+1-W.length).join(z)+O},_={s:w,z:function(O){var F=-O.utcOffset(),z=Math.abs(F),W=Math.floor(z/60),L=z%60;return(F<=0?"+":"-")+w(W,2,"0")+":"+w(L,2,"0")},m:function O(F,z){if(F.date()<z.date())return-O(z,F);var W=12*(z.year()-F.year())+(z.month()-F.month()),L=F.clone().add(W,h),D=z-L<0,I=F.clone().add(W+(D?-1:1),h);return+(-(W+(z-L)/(D?L-I:I-L))||0)},a:function(O){return O<0?Math.ceil(O)||0:Math.floor(O)},p:function(O){return{M:h,y:m,w:d,d:u,D:g,h:c,m:l,s:o,ms:i,Q:f}[O]||String(O||"").toLowerCase().replace(/s$/,"")},u:function(O){return O===void 0}},S="en",k={};k[S]=v;var C="$isDayjsObject",j=function(O){return O instanceof P||!(!O||!O[C])},T=function O(F,z,W){var L;if(!F)return S;if(typeof F=="string"){var D=F.toLowerCase();k[D]&&(L=D),z&&(k[D]=z,L=D);var I=F.split("-");if(!L&&I.length>1)return O(I[0])}else{var V=F.name;k[V]=F,L=V}return!W&&L&&(S=L),L||!W&&S},E=function(O,F){if(j(O))return O.clone();var z=typeof F=="object"?F:{};return z.date=O,z.args=arguments,new P(z)},R=_;R.l=T,R.i=j,R.w=function(O,F){return E(O,{locale:F.$L,utc:F.$u,x:F.$x,$offset:F.$offset})};var P=function(){function O(z){this.$L=T(z.locale,null,!0),this.parse(z),this.$x=this.$x||z.x||{},this[C]=!0}var F=O.prototype;return F.parse=function(z){this.$d=function(W){var L=W.date,D=W.utc;if(L===null)return new Date(NaN);if(R.u(L))return new Date;if(L instanceof Date)return new Date(L);if(typeof L=="string"&&!/Z$/i.test(L)){var I=L.match(b);if(I){var V=I[2]-1||0,H=(I[7]||"0").substring(0,3);return D?new Date(Date.UTC(I[1],V,I[3]||1,I[4]||0,I[5]||0,I[6]||0,H)):new Date(I[1],V,I[3]||1,I[4]||0,I[5]||0,I[6]||0,H)}}return new Date(L)}(z),this.init()},F.init=function(){var z=this.$d;this.$y=z.getFullYear(),this.$M=z.getMonth(),this.$D=z.getDate(),this.$W=z.getDay(),this.$H=z.getHours(),this.$m=z.getMinutes(),this.$s=z.getSeconds(),this.$ms=z.getMilliseconds()},F.$utils=function(){return R},F.isValid=function(){return this.$d.toString()!==x},F.isSame=function(z,W){var L=E(z);return this.startOf(W)<=L&&L<=this.endOf(W)},F.isAfter=function(z,W){return E(z)<this.startOf(W)},F.isBefore=function(z,W){return this.endOf(W)<E(z)},F.$g=function(z,W,L){return R.u(z)?this[W]:this.set(L,z)},F.unix=function(){return Math.floor(this.valueOf()/1e3)},F.valueOf=function(){return this.$d.getTime()},F.startOf=function(z,W){var L=this,D=!!R.u(W)||W,I=R.p(z),V=function(ee,de){var be=R.w(L.$u?Date.UTC(L.$y,de,ee):new Date(L.$y,de,ee),L);return D?be:be.endOf(u)},H=function(ee,de){return R.w(L.toDate()[ee].apply(L.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(de)),L)},M=this.$W,Y=this.$M,X=this.$D,K="set"+(this.$u?"UTC":"");switch(I){case m:return D?V(1,0):V(31,11);case h:return D?V(1,Y):V(0,Y+1);case d:var te=this.$locale().weekStart||0,ce=(M<te?M+7:M)-te;return V(D?X-ce:X+(6-ce),Y);case u:case g:return H(K+"Hours",0);case c:return H(K+"Minutes",1);case l:return H(K+"Seconds",2);case o:return H(K+"Milliseconds",3);default:return this.clone()}},F.endOf=function(z){return this.startOf(z,!1)},F.$set=function(z,W){var L,D=R.p(z),I="set"+(this.$u?"UTC":""),V=(L={},L[u]=I+"Date",L[g]=I+"Date",L[h]=I+"Month",L[m]=I+"FullYear",L[c]=I+"Hours",L[l]=I+"Minutes",L[o]=I+"Seconds",L[i]=I+"Milliseconds",L)[D],H=D===u?this.$D+(W-this.$W):W;if(D===h||D===m){var M=this.clone().set(g,1);M.$d[V](H),M.init(),this.$d=M.set(g,Math.min(this.$D,M.daysInMonth())).$d}else V&&this.$d[V](H);return this.init(),this},F.set=function(z,W){return this.clone().$set(z,W)},F.get=function(z){return this[R.p(z)]()},F.add=function(z,W){var L,D=this;z=Number(z);var I=R.p(W),V=function(Y){var X=E(D);return R.w(X.date(X.date()+Math.round(Y*z)),D)};if(I===h)return this.set(h,this.$M+z);if(I===m)return this.set(m,this.$y+z);if(I===u)return V(1);if(I===d)return V(7);var H=(L={},L[l]=r,L[c]=s,L[o]=n,L)[I]||1,M=this.$d.getTime()+z*H;return R.w(M,this)},F.subtract=function(z,W){return this.add(-1*z,W)},F.format=function(z){var W=this,L=this.$locale();if(!this.isValid())return L.invalidDate||x;var D=z||"YYYY-MM-DDTHH:mm:ssZ",I=R.z(this),V=this.$H,H=this.$m,M=this.$M,Y=L.weekdays,X=L.months,K=L.meridiem,te=function(de,be,se,ae){return de&&(de[be]||de(W,D))||se[be].slice(0,ae)},ce=function(de){return R.s(V%12||12,de,"0")},ee=K||function(de,be,se){var ae=de<12?"AM":"PM";return se?ae.toLowerCase():ae};return D.replace(y,function(de,be){return be||function(se){switch(se){case"YY":return String(W.$y).slice(-2);case"YYYY":return R.s(W.$y,4,"0");case"M":return M+1;case"MM":return R.s(M+1,2,"0");case"MMM":return te(L.monthsShort,M,X,3);case"MMMM":return te(X,M);case"D":return W.$D;case"DD":return R.s(W.$D,2,"0");case"d":return String(W.$W);case"dd":return te(L.weekdaysMin,W.$W,Y,2);case"ddd":return te(L.weekdaysShort,W.$W,Y,3);case"dddd":return Y[W.$W];case"H":return String(V);case"HH":return R.s(V,2,"0");case"h":return ce(1);case"hh":return ce(2);case"a":return ee(V,H,!0);case"A":return ee(V,H,!1);case"m":return String(H);case"mm":return R.s(H,2,"0");case"s":return String(W.$s);case"ss":return R.s(W.$s,2,"0");case"SSS":return R.s(W.$ms,3,"0");case"Z":return I}return null}(de)||I.replace(":","")})},F.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},F.diff=function(z,W,L){var D,I=this,V=R.p(W),H=E(z),M=(H.utcOffset()-this.utcOffset())*r,Y=this-H,X=function(){return R.m(I,H)};switch(V){case m:D=X()/12;break;case h:D=X();break;case f:D=X()/3;break;case d:D=(Y-M)/6048e5;break;case u:D=(Y-M)/864e5;break;case c:D=Y/s;break;case l:D=Y/r;break;case o:D=Y/n;break;default:D=Y}return L?D:R.a(D)},F.daysInMonth=function(){return this.endOf(h).$D},F.$locale=function(){return k[this.$L]},F.locale=function(z,W){if(!z)return this.$L;var L=this.clone(),D=T(z,W,!0);return D&&(L.$L=D),L},F.clone=function(){return R.w(this.$d,this)},F.toDate=function(){return new Date(this.valueOf())},F.toJSON=function(){return this.isValid()?this.toISOString():null},F.toISOString=function(){return this.$d.toISOString()},F.toString=function(){return this.$d.toUTCString()},O}(),A=P.prototype;return E.prototype=A,[["$ms",i],["$s",o],["$m",l],["$H",c],["$W",u],["$M",h],["$y",m],["$D",g]].forEach(function(O){A[O[1]]=function(F){return this.$g(F,O[0],O[1])}}),E.extend=function(O,F){return O.$i||(O(F,P,E),O.$i=!0),E},E.locale=T,E.isDayjs=j,E.unix=function(O){return E(1e3*O)},E.en=k[S],E.Ls=k,E.p={},E})})(w7);var kle=w7.exports;const QN=vn(kle);var _7={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Br,function(){return function(n,r,s){var i=r.prototype,o=function(h){return h&&(h.indexOf?h:h.s)},l=function(h,f,m,g,x){var b=h.name?h:h.$locale(),y=o(b[f]),v=o(b[m]),w=y||v.map(function(S){return S.slice(0,g)});if(!x)return w;var _=b.weekStart;return w.map(function(S,k){return w[(k+(_||0))%7]})},c=function(){return s.Ls[s.locale()]},u=function(h,f){return h.formats[f]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(g,x,b){return x||b.slice(1)})}(h.formats[f.toUpperCase()])},d=function(){var h=this;return{months:function(f){return f?f.format("MMMM"):l(h,"months")},monthsShort:function(f){return f?f.format("MMM"):l(h,"monthsShort","months",3)},firstDayOfWeek:function(){return h.$locale().weekStart||0},weekdays:function(f){return f?f.format("dddd"):l(h,"weekdays")},weekdaysMin:function(f){return f?f.format("dd"):l(h,"weekdaysMin","weekdays",2)},weekdaysShort:function(f){return f?f.format("ddd"):l(h,"weekdaysShort","weekdays",3)},longDateFormat:function(f){return u(h.$locale(),f)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return d.bind(this)()},s.localeData=function(){var h=c();return{firstDayOfWeek:function(){return h.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(f){return u(h,f)},meridiem:h.meridiem,ordinal:h.ordinal}},s.months=function(){return l(c(),"months")},s.monthsShort=function(){return l(c(),"monthsShort","months",3)},s.weekdays=function(h){return l(c(),"weekdays",null,null,h)},s.weekdaysShort=function(h){return l(c(),"weekdaysShort","weekdays",3,h)},s.weekdaysMin=function(h){return l(c(),"weekdaysMin","weekdays",2,h)}}})})(_7);var Cle=_7.exports;const Nle=vn(Cle),Ci=(e,t)=>new Un(e).setA(t).toRgbString(),jd=(e,t)=>new Un(e).lighten(t).toHexString(),jle=e=>{const t=Bh(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]}},Ele=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:Ci(r,.85),colorTextSecondary:Ci(r,.65),colorTextTertiary:Ci(r,.45),colorTextQuaternary:Ci(r,.25),colorFill:Ci(r,.18),colorFillSecondary:Ci(r,.12),colorFillTertiary:Ci(r,.08),colorFillQuaternary:Ci(r,.04),colorBgSolid:Ci(r,.95),colorBgSolidHover:Ci(r,1),colorBgSolidActive:Ci(r,.9),colorBgElevated:jd(n,12),colorBgContainer:jd(n,8),colorBgLayout:jd(n,0),colorBgSpotlight:jd(n,26),colorBgBlur:Ci(r,.04),colorBorder:jd(n,26),colorBorderSecondary:jd(n,19)}},Ile=(e,t)=>{const n=Object.keys(M5).map(i=>{const o=Bh(e[i],{theme:"dark"});return Array.from({length:10},()=>1).reduce((l,c,u)=>(l[`${i}-${u+1}`]=o[u],l[`${i}${u+1}`]=o[u],l),{})}).reduce((i,o)=>(i=Object.assign(Object.assign({},i),o),i),{}),r=t??P5(e),s=r7(e,{generateColorPalettes:jle,generateNeutralColorPalettes:Ele});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),s),{colorPrimaryBg:s.colorPrimaryBorder,colorPrimaryBgHover:s.colorPrimaryBorderHover})},hA={defaultSeed:Tb.token,defaultAlgorithm:P5,darkAlgorithm:Ile};function Tle({children:e}){const t=dl(),[n,r]=p.useState(t.theme);return p.useEffect(()=>t.onThemeChange(r),[t]),a.jsx(Ef,{theme:{algorithm:n.mode==="dark"?hA.darkAlgorithm:hA.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Yt;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},e.getValidEnumValues=s=>{const i=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),o={};for(const l of i)o[l]=s[l];return e.objectValues(o)},e.objectValues=s=>e.objectKeys(s).map(function(i){return s[i]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},e.find=(s,i)=>{for(const o of s)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=r,e.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Yt||(Yt={}));var fA;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(fA||(fA={}));const Xe=Yt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Fl=e=>{switch(typeof e){case"undefined":return Xe.undefined;case"string":return Xe.string;case"number":return Number.isNaN(e)?Xe.nan:Xe.number;case"boolean":return Xe.boolean;case"function":return Xe.function;case"bigint":return Xe.bigint;case"symbol":return Xe.symbol;case"object":return Array.isArray(e)?Xe.array:e===null?Xe.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Xe.promise:typeof Map<"u"&&e instanceof Map?Xe.map:typeof Set<"u"&&e instanceof Set?Xe.set:typeof Date<"u"&&e instanceof Date?Xe.date:Xe.object;default:return Xe.unknown}},ke=Yt.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 rl 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(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let l=r,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(n(o))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}};return s(this),r}static assert(t){if(!(t instanceof rl))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Yt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(t(s))}else r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}rl.create=e=>new rl(e);const JN=(e,t)=>{let n;switch(e.code){case ke.invalid_type:e.received===Xe.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case ke.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Yt.jsonStringifyReplacer)}`;break;case ke.unrecognized_keys:n=`Unrecognized key(s) in object: ${Yt.joinValues(e.keys,", ")}`;break;case ke.invalid_union:n="Invalid input";break;case ke.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Yt.joinValues(e.options)}`;break;case ke.invalid_enum_value:n=`Invalid enum value. Expected ${Yt.joinValues(e.options)}, received '${e.received}'`;break;case ke.invalid_arguments:n="Invalid function arguments";break;case ke.invalid_return_type:n="Invalid function return type";break;case ke.invalid_date:n="Invalid date";break;case ke.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}"`:Yt.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case ke.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 ke.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 ke.custom:n="Invalid input";break;case ke.invalid_intersection_types:n="Intersection results could not be merged";break;case ke.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case ke.not_finite:n="Number must be finite";break;default:n=t.defaultError,Yt.assertNever(e)}return{message:n}};let Rle=JN;function Mle(){return Rle}const Ple=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let l="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)l=u(o,{data:t,defaultError:l}).message;return{...s,path:i,message:l}};function Le(e,t){const n=Mle(),r=Ple({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===JN?void 0:JN].filter(s=>!!s)});e.common.issues.push(r)}class ys{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 s of n){if(s.status==="aborted")return mt;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return ys.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return mt;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:t.value,value:r}}}const mt=Object.freeze({status:"aborted"}),im=e=>({status:"dirty",value:e}),Gi=e=>({status:"valid",value:e}),pA=e=>e.status==="aborted",mA=e=>e.status==="dirty",zh=e=>e.status==="valid",Rb=e=>typeof Promise<"u"&&e instanceof Promise;var rt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(rt||(rt={}));class da{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}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 gA=(e,t)=>{if(zh(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 rl(e.common.issues);return this._error=n,this._error}}};function jt(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=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:s}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??r??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:s}}class Bt{get description(){return this._def.description}_getType(t){return Fl(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Fl(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ys,ctx:{common:t.parent.common,data:t.data,parsedType:Fl(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Rb(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:Fl(t)},s=this._parseSync({data:t,path:r.path,parent:r});return gA(r,s)}"~validate"(t){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Fl(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:n});return zh(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(i=>zh(i)?{value:i.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:Fl(t)},s=this._parse({data:t,path:r.path,parent:r}),i=await(Rb(s)?s:Promise.resolve(s));return gA(r,i)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=t(s),l=()=>i.addIssue({code:ke.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new mc({schema:this,typeName:gt.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 Xa.create(this,this._def)}nullable(){return Eu.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ia.create(this)}promise(){return $b.create(this,this._def)}or(t){return Pb.create([this,t],this._def)}and(t){return Ab.create(this,t,this._def)}transform(t){return new mc({...jt(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Lb({...jt(this._def),innerType:this,defaultValue:n,typeName:gt.ZodDefault})}brand(){return new N7({typeName:gt.ZodBranded,type:this,...jt(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Fb({...jt(this._def),innerType:this,catchValue:n,typeName:gt.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return D5.create(this,t)}readonly(){return Bb.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ale=/^c[^\s-]{8,}$/i,Ole=/^[0-9a-z]+$/,Dle=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$le=/^[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,Lle=/^[a-z0-9_-]{21}$/i,Fle=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ble=/^[-+]?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)?)??$/,zle=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hle="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nk;const Ule=/^(?:(?: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])$/,Wle=/^(?:(?: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])$/,Vle=/^(([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]))$/,qle=/^(([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])$/,Kle=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gle=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,S7="((\\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])))",Yle=new RegExp(`^${S7}$`);function k7(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 Xle(e){return new RegExp(`^${k7(e)}$`)}function Zle(e){let t=`${S7}T${k7(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 Qle(e,t){return!!((t==="v4"||!t)&&Ule.test(e)||(t==="v6"||!t)&&Vle.test(e))}function Jle(e,t){if(!Fle.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,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function ece(e,t){return!!((t==="v4"||!t)&&Wle.test(e)||(t==="v6"||!t)&&qle.test(e))}class Va extends Bt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Xe.string){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_type,expected:Xe.string,received:i.parsedType}),mt}const r=new ys;let s;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(t,s),o?Le(s,{code:ke.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&Le(s,{code:ke.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")zle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"email",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Nk||(Nk=new RegExp(Hle,"u")),Nk.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"emoji",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")$le.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"uuid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Lle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"nanoid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Ale.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"cuid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Ole.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"cuid2",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Dle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"ulid",code:ke.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),Le(s,{validation:"url",code:ke.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"regex",code:ke.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Zle(i).test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Yle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Xle(i).test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ble.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"duration",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Qle(t.data,i.version)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"ip",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Jle(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"jwt",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?ece(t.data,i.version)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"cidr",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Kle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"base64",code:ke.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Gle.test(t.data)||(s=this._getOrReturnCtx(t,s),Le(s,{validation:"base64url",code:ke.invalid_string,message:i.message}),r.dirty()):Yt.assertNever(i);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:ke.invalid_string,...rt.errToObj(r)})}_addCheck(t){return new Va({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...rt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...rt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...rt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...rt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...rt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...rt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...rt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...rt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...rt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...rt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...rt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...rt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...rt.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,...rt.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,...rt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...rt.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...rt.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...rt.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...rt.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...rt.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...rt.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...rt.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...rt.errToObj(n)})}nonempty(t){return this.min(1,rt.errToObj(t))}trim(){return new Va({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Va({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Va({...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}}Va.create=e=>new Va({checks:[],typeName:gt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...jt(e)});function tce(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),o=Number.parseInt(t.toFixed(s).replace(".",""));return i%o/10**s}class Hh extends Bt{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)!==Xe.number){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_type,expected:Xe.number,received:i.parsedType}),mt}let r;const s=new ys;for(const i of this._def.checks)i.kind==="int"?Yt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?tce(t.data,i.value)!==0&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.not_finite,message:i.message}),s.dirty()):Yt.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,rt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,rt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,rt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,rt.toString(n))}setLimit(t,n,r,s){return new Hh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:rt.toString(s)}]})}_addCheck(t){return new Hh({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:rt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:rt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:rt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:rt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:rt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:rt.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:rt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:rt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:rt.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"&&Yt.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)}}Hh.create=e=>new Hh({checks:[],typeName:gt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...jt(e)});class _g extends Bt{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)!==Xe.bigint)return this._getInvalidInput(t);let r;const s=new ys;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),Le(r,{code:ke.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Yt.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return Le(n,{code:ke.invalid_type,expected:Xe.bigint,received:n.parsedType}),mt}gte(t,n){return this.setLimit("min",t,!0,rt.toString(n))}gt(t,n){return this.setLimit("min",t,!1,rt.toString(n))}lte(t,n){return this.setLimit("max",t,!0,rt.toString(n))}lt(t,n){return this.setLimit("max",t,!1,rt.toString(n))}setLimit(t,n,r,s){return new _g({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:rt.toString(s)}]})}_addCheck(t){return new _g({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:rt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:rt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:rt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:rt.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:rt.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}}_g.create=e=>new _g({checks:[],typeName:gt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...jt(e)});class ej extends Bt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Xe.boolean){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.boolean,received:r.parsedType}),mt}return Gi(t.data)}}ej.create=e=>new ej({typeName:gt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...jt(e)});class Mb extends Bt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Xe.date){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_type,expected:Xe.date,received:i.parsedType}),mt}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return Le(i,{code:ke.invalid_date}),mt}const r=new ys;let s;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),Le(s,{code:ke.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Yt.assertNever(i);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Mb({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:rt.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:rt.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}}Mb.create=e=>new Mb({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:gt.ZodDate,...jt(e)});class xA extends Bt{_parse(t){if(this._getType(t)!==Xe.symbol){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.symbol,received:r.parsedType}),mt}return Gi(t.data)}}xA.create=e=>new xA({typeName:gt.ZodSymbol,...jt(e)});class tj extends Bt{_parse(t){if(this._getType(t)!==Xe.undefined){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.undefined,received:r.parsedType}),mt}return Gi(t.data)}}tj.create=e=>new tj({typeName:gt.ZodUndefined,...jt(e)});class nj extends Bt{_parse(t){if(this._getType(t)!==Xe.null){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.null,received:r.parsedType}),mt}return Gi(t.data)}}nj.create=e=>new nj({typeName:gt.ZodNull,...jt(e)});class vA extends Bt{constructor(){super(...arguments),this._any=!0}_parse(t){return Gi(t.data)}}vA.create=e=>new vA({typeName:gt.ZodAny,...jt(e)});class rj extends Bt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Gi(t.data)}}rj.create=e=>new rj({typeName:gt.ZodUnknown,...jt(e)});class pc extends Bt{_parse(t){const n=this._getOrReturnCtx(t);return Le(n,{code:ke.invalid_type,expected:Xe.never,received:n.parsedType}),mt}}pc.create=e=>new pc({typeName:gt.ZodNever,...jt(e)});class yA extends Bt{_parse(t){if(this._getType(t)!==Xe.undefined){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.void,received:r.parsedType}),mt}return Gi(t.data)}}yA.create=e=>new yA({typeName:gt.ZodVoid,...jt(e)});class ia extends Bt{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==Xe.array)return Le(n,{code:ke.invalid_type,expected:Xe.array,received:n.parsedType}),mt;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(o||l)&&(Le(n,{code:o?ke.too_big:ke.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(Le(n,{code:ke.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(Le(n,{code:ke.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>s.type._parseAsync(new da(n,o,n.path,l)))).then(o=>ys.mergeArray(r,o));const i=[...n.data].map((o,l)=>s.type._parseSync(new da(n,o,n.path,l)));return ys.mergeArray(r,i)}get element(){return this._def.type}min(t,n){return new ia({...this._def,minLength:{value:t,message:rt.toString(n)}})}max(t,n){return new ia({...this._def,maxLength:{value:t,message:rt.toString(n)}})}length(t,n){return new ia({...this._def,exactLength:{value:t,message:rt.toString(n)}})}nonempty(t){return this.min(1,t)}}ia.create=(e,t)=>new ia({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...jt(t)});function Vd(e){if(e instanceof or){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Xa.create(Vd(r))}return new or({...e._def,shape:()=>t})}else return e instanceof ia?new ia({...e._def,type:Vd(e.element)}):e instanceof Xa?Xa.create(Vd(e.unwrap())):e instanceof Eu?Eu.create(Vd(e.unwrap())):e instanceof Nu?Nu.create(e.items.map(t=>Vd(t))):e}class or extends Bt{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=Yt.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Xe.object){const u=this._getOrReturnCtx(t);return Le(u,{code:ke.invalid_type,expected:Xe.object,received:u.parsedType}),mt}const{status:r,ctx:s}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof pc&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||l.push(u);const c=[];for(const u of o){const d=i[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new da(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof pc){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of l)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")l.length>0&&(Le(s,{code:ke.unrecognized_keys,keys:l}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of l){const h=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new da(s,h,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const h=await d.key,f=await d.value;u.push({key:h,value:f,alwaysSet:d.alwaysSet})}return u}).then(u=>ys.mergeObjectSync(r,u)):ys.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return rt.errToObj,new or({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:rt.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new or({...this._def,unknownKeys:"strip"})}passthrough(){return new or({...this._def,unknownKeys:"passthrough"})}extend(t){return new or({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new or({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gt.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new or({...this._def,catchall:t})}pick(t){const n={};for(const r of Yt.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new or({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Yt.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new or({...this._def,shape:()=>n})}deepPartial(){return Vd(this)}partial(t){const n={};for(const r of Yt.objectKeys(this.shape)){const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}return new or({...this._def,shape:()=>n})}required(t){const n={};for(const r of Yt.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Xa;)i=i._def.innerType;n[r]=i}return new or({...this._def,shape:()=>n})}keyof(){return C7(Yt.objectKeys(this.shape))}}or.create=(e,t)=>new or({shape:()=>e,unknownKeys:"strip",catchall:pc.create(),typeName:gt.ZodObject,...jt(t)});or.strictCreate=(e,t)=>new or({shape:()=>e,unknownKeys:"strict",catchall:pc.create(),typeName:gt.ZodObject,...jt(t)});or.lazycreate=(e,t)=>new or({shape:e,unknownKeys:"strip",catchall:pc.create(),typeName:gt.ZodObject,...jt(t)});class Pb extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new rl(l.ctx.common.issues));return Le(n,{code:ke.invalid_union,unionErrors:o}),mt}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new rl(c));return Le(n,{code:ke.invalid_union,unionErrors:l}),mt}}get options(){return this._def.options}}Pb.create=(e,t)=>new Pb({options:e,typeName:gt.ZodUnion,...jt(t)});const Ba=e=>e instanceof ij?Ba(e.schema):e instanceof mc?Ba(e.innerType()):e instanceof Db?[e.value]:e instanceof ju?e.options:e instanceof oj?Yt.objectValues(e.enum):e instanceof Lb?Ba(e._def.innerType):e instanceof tj?[void 0]:e instanceof nj?[null]:e instanceof Xa?[void 0,...Ba(e.unwrap())]:e instanceof Eu?[null,...Ba(e.unwrap())]:e instanceof N7||e instanceof Bb?Ba(e.unwrap()):e instanceof Fb?Ba(e._def.innerType):[];class O5 extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Xe.object)return Le(n,{code:ke.invalid_type,expected:Xe.object,received:n.parsedType}),mt;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(Le(n,{code:ke.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),mt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const s=new Map;for(const i of n){const o=Ba(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const l of o){if(s.has(l))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(l)}`);s.set(l,i)}}return new O5({typeName:gt.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...jt(r)})}}function sj(e,t){const n=Fl(e),r=Fl(t);if(e===t)return{valid:!0,data:e};if(n===Xe.object&&r===Xe.object){const s=Yt.objectKeys(t),i=Yt.objectKeys(e).filter(l=>s.indexOf(l)!==-1),o={...e,...t};for(const l of i){const c=sj(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(n===Xe.array&&r===Xe.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let i=0;i<e.length;i++){const o=e[i],l=t[i],c=sj(o,l);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===Xe.date&&r===Xe.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Ab extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(i,o)=>{if(pA(i)||pA(o))return mt;const l=sj(i.value,o.value);return l.valid?((mA(i)||mA(o))&&n.dirty(),{status:n.value,value:l.data}):(Le(r,{code:ke.invalid_intersection_types}),mt)};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(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ab.create=(e,t,n)=>new Ab({left:e,right:t,typeName:gt.ZodIntersection,...jt(n)});class Nu extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Xe.array)return Le(r,{code:ke.invalid_type,expected:Xe.array,received:r.parsedType}),mt;if(r.data.length<this._def.items.length)return Le(r,{code:ke.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),mt;!this._def.rest&&r.data.length>this._def.items.length&&(Le(r,{code:ke.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new da(r,o,r.path,l)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>ys.mergeArray(n,o)):ys.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new Nu({...this._def,rest:t})}}Nu.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nu({items:e,typeName:gt.ZodTuple,rest:null,...jt(t)})};class Ob extends Bt{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!==Xe.object)return Le(r,{code:ke.invalid_type,expected:Xe.object,received:r.parsedType}),mt;const s=[],i=this._def.keyType,o=this._def.valueType;for(const l in r.data)s.push({key:i._parse(new da(r,l,r.path,l)),value:o._parse(new da(r,r.data[l],r.path,l)),alwaysSet:l in r.data});return r.common.async?ys.mergeObjectAsync(n,s):ys.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof Bt?new Ob({keyType:t,valueType:n,typeName:gt.ZodRecord,...jt(r)}):new Ob({keyType:Va.create(),valueType:t,typeName:gt.ZodRecord,...jt(n)})}}class bA extends Bt{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!==Xe.map)return Le(r,{code:ke.invalid_type,expected:Xe.map,received:r.parsedType}),mt;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([l,c],u)=>({key:s._parse(new da(r,l,r.path,[u,"key"])),value:i._parse(new da(r,c,r.path,[u,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of o){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return mt;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}}}}bA.create=(e,t,n)=>new bA({valueType:t,keyType:e,typeName:gt.ZodMap,...jt(n)});class Sg extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Xe.set)return Le(r,{code:ke.invalid_type,expected:Xe.set,received:r.parsedType}),mt;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(Le(r,{code:ke.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(Le(r,{code:ke.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(c){const u=new Set;for(const d of c){if(d.status==="aborted")return mt;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const l=[...r.data.values()].map((c,u)=>i._parse(new da(r,c,r.path,u)));return r.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,n){return new Sg({...this._def,minSize:{value:t,message:rt.toString(n)}})}max(t,n){return new Sg({...this._def,maxSize:{value:t,message:rt.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Sg.create=(e,t)=>new Sg({valueType:e,minSize:null,maxSize:null,typeName:gt.ZodSet,...jt(t)});class ij extends Bt{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})}}ij.create=(e,t)=>new ij({getter:e,typeName:gt.ZodLazy,...jt(t)});class Db extends Bt{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return Le(n,{received:n.data,code:ke.invalid_literal,expected:this._def.value}),mt}return{status:"valid",value:t.data}}get value(){return this._def.value}}Db.create=(e,t)=>new Db({value:e,typeName:gt.ZodLiteral,...jt(t)});function C7(e,t){return new ju({values:e,typeName:gt.ZodEnum,...jt(t)})}class ju extends Bt{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return Le(n,{expected:Yt.joinValues(r),received:n.parsedType,code:ke.invalid_type}),mt}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 Le(n,{received:n.data,code:ke.invalid_enum_value,options:r}),mt}return Gi(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 ju.create(t,{...this._def,...n})}exclude(t,n=this._def){return ju.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}ju.create=C7;class oj extends Bt{_parse(t){const n=Yt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Xe.string&&r.parsedType!==Xe.number){const s=Yt.objectValues(n);return Le(r,{expected:Yt.joinValues(s),received:r.parsedType,code:ke.invalid_type}),mt}if(this._cache||(this._cache=new Set(Yt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=Yt.objectValues(n);return Le(r,{received:r.data,code:ke.invalid_enum_value,options:s}),mt}return Gi(t.data)}get enum(){return this._def.values}}oj.create=(e,t)=>new oj({values:e,typeName:gt.ZodNativeEnum,...jt(t)});class $b extends Bt{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Xe.promise&&n.common.async===!1)return Le(n,{code:ke.invalid_type,expected:Xe.promise,received:n.parsedType}),mt;const r=n.parsedType===Xe.promise?n.data:Promise.resolve(n.data);return Gi(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}$b.create=(e,t)=>new $b({type:e,typeName:gt.ZodPromise,...jt(t)});class mc extends Bt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:o=>{Le(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return mt;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?mt:c.status==="dirty"||n.value==="dirty"?im(c.value):c});{if(n.value==="aborted")return mt;const l=this._def.schema._parseSync({data:o,path:r.path,parent:r});return l.status==="aborted"?mt:l.status==="dirty"||n.value==="dirty"?im(l.value):l}}if(s.type==="refinement"){const o=l=>{const c=s.refinement(l,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?mt:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!zh(o))return mt;const l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>zh(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:n.value,value:l})):mt);Yt.assertNever(s)}}mc.create=(e,t,n)=>new mc({schema:e,typeName:gt.ZodEffects,effect:t,...jt(n)});mc.createWithPreprocess=(e,t,n)=>new mc({schema:t,effect:{type:"preprocess",transform:e},typeName:gt.ZodEffects,...jt(n)});class Xa extends Bt{_parse(t){return this._getType(t)===Xe.undefined?Gi(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Xa.create=(e,t)=>new Xa({innerType:e,typeName:gt.ZodOptional,...jt(t)});class Eu extends Bt{_parse(t){return this._getType(t)===Xe.null?Gi(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Eu.create=(e,t)=>new Eu({innerType:e,typeName:gt.ZodNullable,...jt(t)});class Lb extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Xe.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Lb.create=(e,t)=>new Lb({innerType:e,typeName:gt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...jt(t)});class Fb extends Bt{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Rb(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new rl(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new rl(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Fb.create=(e,t)=>new Fb({innerType:e,typeName:gt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...jt(t)});class wA extends Bt{_parse(t){if(this._getType(t)!==Xe.nan){const r=this._getOrReturnCtx(t);return Le(r,{code:ke.invalid_type,expected:Xe.nan,received:r.parsedType}),mt}return{status:"valid",value:t.data}}}wA.create=e=>new wA({typeName:gt.ZodNaN,...jt(e)});class N7 extends Bt{_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 D5 extends Bt{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?mt:i.status==="dirty"?(n.dirty(),im(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?mt:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new D5({in:t,out:n,typeName:gt.ZodPipeline})}}class Bb extends Bt{_parse(t){const n=this._def.innerType._parse(t),r=s=>(zh(s)&&(s.value=Object.freeze(s.value)),s);return Rb(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Bb.create=(e,t)=>new Bb({innerType:e,typeName:gt.ZodReadonly,...jt(t)});var gt;(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"})(gt||(gt={}));const N=Va.create,Q=Hh.create,Me=ej.create,Za=rj.create;pc.create;const pe=ia.create,B=or.create,nce=Pb.create,Bs=O5.create;Ab.create;Nu.create;const Yi=Ob.create,he=Db.create,Ve=ju.create;$b.create;Xa.create;Eu.create;const rce=mc.createWithPreprocess,sce=["head","index"],j7=N().regex(/^[A-Za-z0-9][A-Za-z0-9-]{0,127}$/),zb=N().regex(/^[1-9][0-9]*$/),Hb=N().regex(/^[A-Za-z0-9_.-]+$/),kg=N().min(1).max(255).refine(e=>!e.startsWith("-")&&e!=="HEAD"&&!e.startsWith("/")&&!e.endsWith("/")&&!e.endsWith(".")&&!/[\s~^:?*\[\\\x00-\x1f\x7f]/.test(e)&&!e.includes("..")&&!e.includes("@{")&&!e.includes("//")&&e.split("/").every(t=>!t.startsWith(".")&&!t.endsWith(".lock")),"Invalid Git branch"),$5=N().min(1).max(4096).refine(e=>!e.startsWith("/")&&!e.includes("\0")&&!e.split(/[\\/]/).includes("..")),Tw=B({workspaceId:j7,repoId:zb,owner:Hb,name:Hb,sourceBranch:kg,defaultBranch:kg}).strict(),ice=B({repoId:zb,owner:Hb,name:Hb,defaultBranch:N(),private:Me(),description:N().nullable()}),oce=Tw.extend({initialCommit:N(),head:N(),actualBranch:N().nullable(),branches:pe(N()).optional(),files:pe(B({path:$5,previousPath:N().optional(),comparison:Ve(sce).optional(),status:N(),added:Q().nonnegative(),removed:Q().nonnegative(),binary:Me(),untracked:Me().optional()})),totalFiles:Q().int().nonnegative().optional(),filesTruncated:Me().optional(),added:Q().nonnegative(),removed:Q().nonnegative(),dirty:Me(),conflicted:Me(),version:N(),measuredAt:Q()}),Ed=B({sessionId:j7});Bs("action",[Ed.extend({action:he("repositories"),page:Q().int().min(1).max(1e3).optional(),search:N().max(100).optional()}).strict(),Ed.extend({action:he("branches"),repoId:zb,page:Q().int().min(1).max(1e3).optional(),search:N().max(100).optional(),cursor:N().min(1).max(1024).optional()}).strict(),Ed.extend({action:he("bind"),repoId:zb,branch:kg}).strict(),Ed.extend({action:he("status")}).strict(),Ed.extend({action:he("intend"),branch:kg.optional()}).strict(),Ed.extend({action:he("diff"),filePath:$5}).strict()]);B({binding:Tw.nullable().optional(),workspace:oce.nullable().optional(),repositories:pe(ice).optional(),branches:pe(N()).optional(),hasMore:Me().optional(),nextCursor:N().min(1).max(1024).optional(),diff:B({path:$5,patch:N(),binary:Me(),truncated:Me(),notStored:Me().optional()}).optional()});B({threadId:N().min(1),conversationId:N().min(1),workspace:Tw.optional()});new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");B({id:N().min(1),name:N().min(1),baseUrl:N().min(1),apiKey:N().min(1),remark:N().optional(),createdAt:Q(),updatedAt:Q()}).strict();const ace=B({id:N().min(1),name:N().min(1),baseUrl:N().min(1),remark:N().optional(),keyMasked:N(),hasKey:Me(),createdAt:Q(),updatedAt:Q()}).strict();B({activeChannelId:N().nullable(),channels:pe(ace)}).strict();B({}).strict();B({id:N().min(1).optional(),name:N().min(1),baseUrl:N().min(1),apiKey:N().optional(),remark:N().optional()}).strict();B({id:N().min(1)}).strict();B({id:N().min(1).nullable()}).strict();B({channelId:N().min(1).optional(),updatedAt:Q().optional()}).strict().refine(e=>e.updatedAt===void 0||e.channelId!==void 0,{message:"updatedAt requires channelId"});B({channelId:N().nullable(),models:pe(B({id:N().min(1),ownedBy:N().optional()}).strict())}).strict();const lce=["owner"],cce=["agent","owner","user-upload"],E7=B({id:N().min(1),relPath:N().min(1),from:Ve(cce),label:N().optional(),size:Q().int().nonnegative(),mime:N().min(1),addedAt:Q().int().nonnegative(),lastEditedAt:Q().int().nonnegative().optional(),stale:Me().optional()});B({sessionId:N().min(1),relPath:N().min(1),ttlSeconds:Q().int().positive().nullable().optional(),view:Ve(["raw","md-rendered"]).optional()});B({url:N().min(1),expiresAt:Q().int().nonnegative().nullable()});B({sessionId:N().min(1),relPath:N().min(1),label:N().optional(),origin:he("agent").optional()});B({entry:E7});B({sessionId:N().min(1),relPath:N().min(1)});B({removed:he(!0)});B({sessionId:N().min(1)});B({entries:pe(E7)});B({attachmentId:N().min(1),url:N().min(1),relPath:N().min(1),sizeBytes:Q().int().nonnegative(),mimeType:N().min(1)});const uce=Bs("type",[B({type:he("persona"),id:N().min(1)}).strict(),B({type:he("chat"),id:N().min(1)}).strict(),B({type:he("*")}).strict()]),dce=Ve(["read","send","admin"]),L5=B({resource:uce,actions:pe(dce).min(1)}).strict(),hce=B({id:N().min(1),secretHash:N().regex(/^[a-f0-9]{64}$/),displayName:N(),grants:pe(L5),issuedAt:Q().int().nonnegative(),expiresAt:Q().int().positive().optional(),maxUses:Q().int().positive().optional(),usedCount:Q().int().nonnegative(),peerOwnerId:N().min(1).optional(),firstUsedByPeerAt:Q().int().positive().optional(),peerDisplayName:N().optional()}).strict(),fce=hce.omit({secretHash:!0});B({type:he("whoami:ok"),owner:B({id:N(),kind:Ve(["owner","guest"]),displayName:N(),ownerId:N(),provider:N()}).strict(),capability:fce,grantedPersonas:pe(B({id:N().min(1),displayName:N()}).strict())}).strict();const pce="PEER_LOGIN_EXPIRED";B({selfUrl:N().min(1)});B({type:he("contact:handshake:ok"),owner:B({id:N(),ownerId:N(),provider:N(),displayName:N()}),grants:pe(L5)});const mce=Bs("status",[B({status:he("authorized"),login:N().min(1),source:Ve(["git","file"])}).strict(),B({status:he("missing")}).strict(),B({status:he("invalid"),message:N().min(1)}).strict(),B({status:he("pending"),authUrl:N().url()}).strict()]);B({token:N().min(1)}).strict();B({returnTo:N().url().optional()}).strict();const gce=B({url:N().url(),bin:N(),sha256:N().regex(/^[0-9a-f]{64}$/),size:Q().int().positive()}),xce={label:"Debian 13"},I7=["node","npm"],vce=["claude","codex","git","lark-cli","pi","pi-mcp-bridge","pi-cliproxyapi-provider","python3","jq","rsync","psql","go","chromium","fonts-wqy-microhei","openssh-server","pnpm","whiteboard-cli","s","supabase-mcp","mcp-server-kibana","aliyun"],yce=B({name:N().min(1),from:N().optional(),version:N().optional(),min:N().optional(),library:Me().optional(),localVersion:N().optional(),artifact:gce.optional(),aptMissing:he(!0).optional(),aptVersion:N().optional()}),F5=N().regex(/^[a-z0-9-]+$/,"连接器名只能是小写字母、数字和短横线"),T7=["proxy","env"],R7=["mcp","cli"],bce=["bearer","lark-sidecar"],M7=["none","shared","personal"],B5=["oauth","fields"],Rw=N().regex(/^[A-Z][A-Z0-9_]*$/,"要填的变量名只能是大写字母、数字和下划线,且以字母开头"),wce=B({name:N().min(1),env:pe(Rw).min(1)}),P7=B({name:F5,kind:Ve(T7),runner:Ve(R7),protocol:Ve(bce).optional(),id:N().min(1),credentialSource:Ve(M7).optional(),auth:Ve(B5).optional(),publisherUnionId:N().regex(/^on_[A-Za-z0-9_-]+$/).optional(),fields:pe(Rw).default([]),http:B({url:N().min(1),headers:Yi(N(),N())}).optional()}),A7=["LARKSUITE_CLI_APP_ID","LARKSUITE_CLI_APP_SECRET"];function z5(e){return e.name==="feishu"&&e.runner==="cli"&&e.kind==="env"&&e.credentialSource==="shared"}function _ce(e){return e.name==="feishu"&&e.id==="feishu"&&e.runner==="cli"&&e.kind==="proxy"&&e.protocol==="lark-sidecar"&&e.credentialSource==="shared"&&e.auth==="oauth"&&e.fields.length===0}function O7(e){if(!e.credentialSource)return[`连接器 ${e.name} 还没选用谁的账号`];const t=[];return _ce(e)?t:e.protocol==="lark-sidecar"&&e.credentialSource==="shared"?["连接器 feishu 的发布者 OAuth 配置不完整,请重新选择账号身份"]:z5(e)?A7.filter(n=>!e.fields.includes(n)).map(n=>`连接器 feishu 的 Lark App Bot 缺少 ${n==="LARKSUITE_CLI_APP_ID"?"App ID":"App Secret"}`):(e.credentialSource==="personal"&&(e.auth?e.auth==="oauth"&&e.kind==="env"?t.push(`连接器 ${e.name} 是进程型(stdio MCP / CLI),只能粘贴 API key,走不了 OAuth`):e.auth==="fields"&&e.fields.length===0&&t.push(`连接器 ${e.name} 要填的变量还没列`):t.push(`连接器 ${e.name} 还没选用户怎么关联账号`)),e.credentialSource==="shared"&&e.fields.length===0&&t.push(`连接器 ${e.name} 选了发布者的账号,但要填的变量还没列`),t)}const Sce=/^([A-Za-z0-9._/-]+)@([A-Za-z0-9._-]+)(?:\?tags=([A-Za-z0-9_,]+))?$/,kce=["main","master","HEAD","latest"];function Cce(e){const t=Sce.exec(e);return!!t&&!kce.includes(t[2])}function D7(e){var n,r;return I7.includes(e.name)||vce.includes(e.name)?[]:(n=e.from)!=null&&n.startsWith("github:")&&!e.artifact?[`${e.name} 还没钉下载资产(github: 要具体到哪个文件)——重新扫描`]:(r=e.from)!=null&&r.startsWith("go:")&&!Cce(e.from.slice(3))?[`${e.name} 还没钉版本(go: 要写成 <module>@<tag>,不收 latest / main 这类移动引用)——重新扫描`]:[]}function H5(e){return e.connectors.filter(t=>t.credentialSource==="shared"&&t.fields.length>0).map(t=>({name:t.name,env:[...t.fields]}))}function Nce(e){return[...new Set([...e.envVars.flatMap(t=>t.env),...H5(e).flatMap(t=>t.env)])]}function jce(e){const t=new Set(e.connectors.flatMap(n=>n.fields));return[...new Set(e.envVars.flatMap(n=>n.env))].filter(n=>t.has(n)).map(n=>`${n} 同时是环境变量和连接器的字段,只能留一处——重新扫描`)}const Ece=e=>{if(!e||typeof e!="object")return e;let t=e;if("clis"in t&&Array.isArray(t.clis)){const{clis:n,...r}=t;t="packages"in r?r:{...r,packages:n}}if("assets"in t&&Array.isArray(t.assets)&&t.assets.length===0){const{assets:n,...r}=t;t=r}if("secrets"in t&&Array.isArray(t.secrets)){const{secrets:n,...r}=t,s=new Set((Array.isArray(r.connectors)?r.connectors:[]).flatMap(o=>Array.isArray(o==null?void 0:o.fields)?o.fields:[])),i=n.map(o=>({...o,env:Array.isArray(o==null?void 0:o.env)?o.env.filter(l=>!s.has(l)):o==null?void 0:o.env})).filter(o=>!Array.isArray(o.env)||o.env.length>0);t={...r,envVars:[...Array.isArray(r.envVars)?r.envVars:[],...i]}}return t},Ice="Publisher test: ",$7=B({version:he(1),entry:N().max(240).regex(/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*\.mjs$/).refine(e=>!e.split("/").some(t=>[".",".."].includes(t))),timeoutSeconds:Q().int().min(1).max(600),checks:pe(N().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)).min(1).max(64).refine(e=>new Set(e).size===e.length)}).strict(),L7={test:$7.optional(),packages:pe(yce),envVars:pe(wce).default([]),connectors:pe(P7).default([])};B(L7);const U5=rce(Ece,B({version:he(1),...L7}).strict()),Tce=B({target:N().min(1),reason:N().min(1),file:N().min(1),quote:N().min(1)}),Rce=["integration","production"],Hs=Ve(Rce),gc=N().regex(/^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[a-f0-9]{64}$/),aj=N().regex(/^[a-f0-9]{40}$/),Mce=N().refine(e=>{try{const t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password&&!t.search&&!t.hash&&t.pathname==="/"&&/(^|[.-])int([.-]|$)/.test(t.hostname)}catch{return!1}},"测试验证地址必须明确指向 int HTTPS 环境"),Pce=B({version:he(1),runId:N().regex(/^[A-Za-z0-9_-]{1,128}$/),status:he("passed"),exitCode:he(0),result:B({version:he(1),runId:N().regex(/^[A-Za-z0-9_-]{1,128}$/),checks:pe(B({name:N().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),status:he("passed"),reason:N().max(1024).optional()}).strict()).min(1).max(64)}).strict(),execution:B({image:gc,imageID:N().min(1).max(512),engine:Ve(["codex","pi"]),podUid:N().min(1).max(512),jobUid:N().min(1).max(512)}).strict()}).strict(),F7=B({status:he("passed"),fingerprint:N().regex(/^[a-f0-9]{64}$/),checks:pe(N().regex(/^[a-z0-9-]+$/)),endpoint:Mce,verifiedAt:N().refine(e=>Number.isFinite(Date.parse(e))),test:Pce.optional()}).strict(),B7=B({engine:N().min(1),model:N(),effort:N(),size:N().min(1),cpu:Q().positive(),taskConcurrency:Q().int().positive(),minPods:Q().int().nonnegative().safe().optional()}).strict(),z7=B({version:he(1),environment:he("integration"),component:he("persona"),image:gc,commit:aj,baseImage:gc,pipelineCommit:aj,repository:N().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/),config:B7.optional(),verification:F7.refine(e=>e.checks.includes("persona-smoke")),test:$7.optional()}).strict().refine(e=>{if(!e.test)return e.verification.test===void 0;const t=e.verification.test;return["persona-dialogue","persona-task","persona-custom-test"].every(n=>e.verification.checks.includes(n))&&t!==void 0&&t.execution.image===e.image&&t.runId===t.result.runId&&t.result.checks.length===e.test.checks.length&&new Set(t.result.checks.map(n=>n.name)).size===e.test.checks.length&&t.result.checks.every(n=>e.test.checks.includes(n.name))},"Declared publisher acceptance requires complete candidate runtime evidence");B({version:he(1),environment:he("integration"),component:he("base"),image:gc,commit:aj,verification:F7.refine(e=>e.checks.includes("base-smoke"))}).strict();const Cg="-cloud",W5=`codex${Cg}`,Ng={standard:"default",fast:"priority"},Ace=`claude${Cg}`;function H7(e){return e==="codex"||e===W5}const U7="pi",Oce=`${U7}${Cg}`;function W7(e){return e===U7||e===Oce}function mu(e){return typeof e=="string"&&e.length>Cg.length&&e.endsWith(Cg)}const V7=Ve([Ng.standard,Ng.fast]),V5=["tiny","small","medium","large","xlarge"],Dce=Ve(V5),Ub="medium",Wb=[.5,1,2],$ce=Q().refine(e=>Wb.includes(e),"Unsupported CPU"),lj={tiny:.5,small:1,medium:2,large:2,xlarge:2},q7=B({model:N().optional(),effort:N().optional()}).strict(),Pm=B({personaId:N(),label:N(),model:N().optional(),effort:N().optional(),serviceTier:V7.optional(),public:Me(),iconKey:N().optional(),tool:N().optional(),size:N().optional(),cpu:Q().finite().optional(),taskConcurrency:Q().int().positive().optional(),minPods:Q().int().nonnegative().safe().optional(),cloudEngine:q7.optional(),createdAt:Q(),updatedAt:Q(),cloud:B({gatewayUrl:N().min(1),personaId:N().min(1),publishedByMe:Me().optional(),label:N().optional(),environment:Hs.optional(),expectedImage:gc.optional(),testReleaseId:N().optional()}).strict().optional()}).strict(),Lce=B({name:N().min(1),description:N().optional()}),Fce=B({id:N().min(1)}),K7=B({writableRoots:pe(N()).optional(),denyRead:pe(N()).optional(),network:Me().optional()}).strict(),Bce=B({permissions:B({defaultMode:N().optional(),allow:pe(N()).optional(),deny:pe(N()).optional()}).optional(),sandbox:B({enabled:Me().optional(),autoAllowBashIfSandboxed:Me().optional(),allowUnsandboxedCommands:Me().optional(),excludedCommands:pe(N()).optional(),filesystem:B({denyRead:pe(N()).optional(),allowRead:pe(N()).optional(),denyWrite:pe(N()).optional(),allowWrite:pe(N()).optional()}).optional(),network:B({allowedDomains:pe(N()).optional(),allowLocalBinding:Me().optional()}).optional()}).optional()});Pm.extend({personality:N().optional(),personalityLocal:N().optional(),personalityManaged:Me().optional(),skills:pe(Lce).optional(),plugins:pe(Fce).optional(),sandboxSettings:Bce.nullable().optional(),codexSandbox:K7.nullable().optional()});B({slug:N().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:N().min(1),personality:N(),model:N().optional(),effort:N().optional(),serviceTier:Pm.shape.serviceTier,tool:N().optional(),public:Me().optional(),iconKey:N().optional()}).strict();B({personaId:N().min(1)});B({personaId:N().min(1),patch:B({label:N().min(1).optional(),model:N().optional(),effort:N().optional(),serviceTier:Pm.shape.serviceTier,tool:N().optional(),size:Dce.optional(),cpu:$ce.optional(),taskConcurrency:Pm.shape.taskConcurrency,minPods:Pm.shape.minPods,cloudEngine:q7.optional(),personality:N().optional(),personalityLocal:N().optional(),public:Me().optional(),iconKey:N().nullable().optional(),codexSandbox:K7.optional()}).strict()}).strict();B({version:he(1),manifest:U5}).strict();const zce=["hard","soft"],G7=Ve(zce),Hce=Ve(["scanning","done","failed"]),Y7=B({id:N().min(1),manifest:U5,scanSessionId:N().optional(),status:Hce,evidence:pe(Tce).default([]),notes:pe(N()).default([]),head:N().min(1).optional(),baseKind:G7.default("hard"),base:N().min(1).optional(),startedAt:Q(),finishedAt:Q().optional(),error:N().optional()}).strict(),q5=B({id:N().min(1).optional(),environment:Hs.optional(),legacy:Me().optional(),head:N().min(1),contentHead:N().min(1),scanId:N().min(1),at:Q(),pushed:Me().optional(),runId:Q().int().positive().optional(),runAttempt:Q().int().positive().optional(),artifactId:Q().int().positive().optional(),verified:z7.optional(),config:B7.optional(),reconfigOf:N().min(1).optional(),workflowVersion:Q().int().positive().optional(),confirmation:B({fingerprint:N().regex(/^[a-f0-9]{64}$/),runId:Q().int().positive(),runAttempt:Q().int().positive(),at:Q()}).strict().optional()}).strict(),Uce=["prepared","main-pushed","dispatching","dispatched","completed","failed"],K5=B({id:N().min(1),releaseId:N().min(1),at:Q(),verified:z7.optional(),phase:Ve(Uce),expectedMain:N().optional(),runId:Q().int().positive().optional(),runAttempt:Q().int().positive().optional(),error:N().optional()}).strict(),_A=B({channelId:N().min(1),updatedAt:Q()}).strict(),G5=B({integration:_A.nullable().optional(),production:_A.nullable().optional()}).strict();B({version:he(4),engineChannels:G5.optional(),scans:pe(Y7),releases:pe(q5),promotions:pe(K5).default([])}).strict();const Wce=B({url:N().min(1),branch:N().min(1),head:N().min(1),dirty:Me(),ahead:Q()}).strict(),Ny=B({env:N().min(1),setAt:Q().optional()}).strict(),SA={baseUrl:"CLAWD_ENGINE_BASE_URL",apiKey:"CLAWD_ENGINE_API_KEY"},Vce="模型订阅只写进去一半——重填或改回平台默认";function Vb(e){if(!e)return;const t=r=>e.some(s=>s.env===r&&s.setAt!==void 0),n=[SA.baseUrl,SA.apiKey].filter(t).length;return n===2?"own":n===0?"platform":"partial"}function qce(e){const t=e.trim();let n;try{n=new URL(t)}catch{throw new Error("订阅地址要以 http:// 或 https:// 开头,形如 https://cpa.example.com")}if(n.protocol!=="http:"&&n.protocol!=="https:"||!n.hostname)throw new Error("订阅地址要以 http:// 或 https:// 开头,形如 https://cpa.example.com");const r=`${n.origin}${n.pathname}`.replace(/\/+$/,"");return r.endsWith("/v1")?r:`${r}/v1`}const Kce=["pending","running","done","failed","waiting","skipped"],Gce=Ve(Kce),yo="verify",Am=["build","smoke","deploy",yo],Yce=Ve(Am),Xce=B({key:Yce,status:Gce,url:N().optional(),jobId:Q().optional(),startedAt:Q().optional(),completedAt:Q().optional(),cliWarnings:pe(N()).optional()}).strict(),jy=B({runId:Q(),headSha:N().min(1),status:Ve(["queued","running","completed"]),htmlUrl:N().min(1),jobs:pe(Xce),environment:Hs.optional(),branch:N().optional(),event:N().optional(),runAttempt:Q().int().positive().optional(),conclusion:Ve(["success","failure"]).optional(),promotionId:N().optional()}).strict();function X7(e,t){return t&&e.head===t.head?t.contentHead:e.head}function Mw(e,t,n){return!e||!t||e.status!=="done"?!1:e.head===X7(t,n)&&!t.dirty}function Y5(e,t,n){return!e||!t||e.status!=="done"||!e.head?!1:e.head!==X7(t,n)}function kA(e,t,n){return Mw(e,t,n)||Y5(e,t,n)}function Zce(e,t){return!t||!e.head?!1:t.contentHead===e.head||t.at>=e.startedAt}const Z7=["codex","pi","claude"];function fl(e){return Z7.includes(e||"claude")}const Q7={codex:"0.163.0",pi:"1.3.0",claude:"0.3.304"},Qce="2.1.304";function Jce(e,t){if(!e||!fl(e)||!t)return null;const n=e==="claude"?Qce:Q7[e];return n===t?null:{tool:e,cloud:n,local:t}}function J7(e){const t=e.tool||"claude",n=t==="claude"?e.cloudEngine??{}:e;return{tool:t,model:n.model??"",effort:n.effort??""}}const jk=B({runId:Q(),status:jy.shape.status,conclusion:Ve(["success","failure"]).optional(),htmlUrl:N().min(1)}).strict(),eue=B({desired:Q().int().nonnegative().safe(),ready:Q().int().nonnegative().safe(),bound:Q().int().nonnegative().safe(),starting:Q().int().nonnegative().safe(),retiring:Q().int().nonnegative().safe(),observedAt:Q(),error:N().nullable()}).strict(),CA=B({online:Me().optional(),image:gc.optional(),minPods:Q().int().nonnegative().safe().optional(),reservation:eue.nullable().optional(),reservationError:N().optional()}).strict(),eH=B({personaId:N().min(1),engineChannels:G5.optional(),github:mce.optional(),publisherFeishuAuth:B({integration:B({connected:Me(),authUrl:N().optional(),error:N().optional()}).strict(),production:B({connected:Me(),authUrl:N().optional(),error:N().optional()}).strict()}).strict().optional(),repo:Wce.optional(),scans:pe(Y7).default([]),releases:pe(q5).default([]),promotions:pe(K5).optional(),targets:B({integration:CA.extend({run:jy.optional(),secrets:pe(Ny).optional(),unpublish:jk.optional()}).optional(),production:CA.extend({run:jy.optional(),secrets:pe(Ny).optional(),unpublish:jk.optional()}).optional()}).strict().optional(),secrets:pe(Ny).optional(),run:jy.optional(),online:Me().optional(),unpublish:jk.optional(),historyError:N().optional()}).strict();B({before:Q().nullable()}).strict();eH.pick({personaId:!0,github:!0,repo:!0,scans:!0,releases:!0,promotions:!0,engineChannels:!0,historyError:!0});eH.pick({scans:!0});B({environment:Hs,secrets:pe(Ny).optional(),engineChannels:G5.optional()}).strict();const tue=e=>e.includes("minPods")?3:2,jg=1,nue=["engine","model","effort","size","cpu","taskConcurrency","minPods"];function rue(e){const{tool:t,model:n,effort:r}=J7(e),s=(e.size??"").trim()||Ub,i=e.cpu??lj[s]??lj[Ub];return{engine:t,model:n.trim(),effort:r.trim(),size:s,cpu:i,taskConcurrency:e.taskConcurrency??jg,minPods:e.minPods??0}}function tH(e,t){return!e||!t?null:nue.filter(n=>n==="minPods"?(e.minPods??0)!==(t.minPods??0):e[n]!==t[n])}B({sha:N().min(1),actionsUrl:N().min(1),releaseId:N().optional()}).strict();const px=B({personaId:N().min(1)}).strict();px.extend({releaseHead:N().min(1).optional(),releaseId:N().min(1).optional(),environment:Hs.optional()}).strict();px.extend({scanBase:G7.optional()}).strict();px.extend({scanId:N().min(1)}).strict();px.extend({releaseId:N().min(1)}).strict();px.extend({environment:Hs.default("production")}).strict();B({confirmation:q5.shape.confirmation.unwrap()}).strict();B({promotion:K5}).strict();B({personaId:N().min(1),expectedImage:gc}).strict();B({personaId:N().min(1),scanId:N().min(1),patch:B({manifest:U5.optional(),connector:P7.optional()}).strict()}).strict();B({personaId:N().min(1),environment:Hs.default("production"),scanId:N().min(1),name:N().min(1),values:Yi(N(),N())}).strict();B({personaId:N().min(1),environment:Hs.default("production"),channelId:N().min(1).optional(),auth:B({baseUrl:N(),apiKey:N()}).strict().nullable().optional()}).strict().refine(e=>e.channelId!==void 0||e.auth!==void 0,{message:"Either channelId or auth must be provided"});B({personaId:N().min(1),environment:Hs.default("production"),releaseId:N().optional(),jobId:Q()}).strict();const sue="底座已更新,重试仍会用旧底座构建——请重新发布测试环境";B({personaId:N().min(1),kind:Ve(["package","env","connector"]),item:Yi(N(),Za()),evidence:B({reason:N().min(1),file:N().min(1),quote:N().min(1)})}).strict();B({personaId:N().min(1),notes:pe(N()).default([])}).strict();const nH="ottin4ttc";function Uh(e){return e.trim().replace(/^git@[^:]+:/,"").replace(/^https?:\/\/[^/]+\//,"").replace(/\.git$/,"")}B({environment:Hs.default("production")}).strict();const iue="LOGIN_EXPIRED",oue=B({deviceId:N().min(1),name:N().min(1),url:N().min(1)});B({type:he("device:list:ok"),devices:pe(oue)});B({deviceId:N().min(1),url:N().min(1).optional(),name:N().optional()});B({type:he("device:connect:ok"),deviceId:N(),name:N(),url:N()});const rH=B({ownerId:N().min(1),provider:N().min(1),displayName:N().min(1),avatarUrl:N().optional(),unionId:N().optional()});B({type:he("auth:login:start:ok"),environment:Hs.optional(),authUrl:N().min(1),state:N().min(1)});B({type:he("auth:getIdentity:ok"),identity:rH.nullable(),deviceId:N().min(1)});B({type:he("auth:logout:ok")});const sH=N().nullable();B({type:he("auth:apiKey:get:ok"),apiKey:N().nullable(),createdAt:N().nullable(),gatewayUrl:sH});B({type:he("auth:apiKey:regenerate:ok"),apiKey:N().min(1),createdAt:N().min(1),gatewayUrl:sH});B({type:he("auth:apiKey:revoke:ok"),revoked:Me()});B({type:he("auth:login:done"),environment:Hs.optional(),identity:rH});B({type:he("auth:login:failed"),environment:Hs.optional(),reason:N()});B({deviceId:N().min(1),remoteAccessAllowed:Me()}).strict();B({type:he("contact:setRemoteAccess:ok"),deviceId:N().min(1),remoteAccessAllowed:Me()}).strict();B({type:he("contact:remote-access-updated"),deviceId:N().min(1),remoteAccessAllowed:Me()}).strict();B({personaId:N().min(1)}).strict();const aue=["connected","missing","reauth"],lue=["link","fill"],cue=B({name:F5,id:N().min(1),kind:Ve(T7),runner:Ve(R7),auth:Ve(B5),status:Ve(aue),action:Ve(lue),authUrl:N().optional(),fields:pe(Rw)}).strict();B({connectors:pe(cue)}).strict();B({personaId:N().min(1),name:F5,values:Yi(Rw,N().min(1))}).strict();const uue=B({deviceId:N().min(1),ownerId:N().min(1),provider:N().min(1),displayName:N(),remoteUrl:N().min(1),connectToken:N(),grants:pe(L5),addedAt:Q().int().nonnegative(),pinnedAt:Q().int().nullable().default(null),remoteAccessAllowed:Me().default(!1),note:N().default("")}).strict(),iH=uue;B({deviceId:N().min(1)}).strict();B({type:he("contact:remove:ok"),deviceId:N().min(1)}).strict();B({type:he("contact:list:ok"),contacts:pe(iH)}).strict();B({type:he("contact:added"),contact:iH}).strict();B({type:he("contact:removed"),deviceId:N().min(1)}).strict();B({deviceId:N().min(1),pinned:Me()}).strict();B({deviceId:N().min(1),note:N()}).strict();B({type:he("contact:setNote:ok"),deviceId:N().min(1),note:N()}).strict();B({type:he("contact:pin:ok"),deviceId:N().min(1),pinnedAt:Q().int().nullable()}).strict();B({type:he("contact:pinned"),deviceId:N().min(1),pinnedAt:Q().int().nullable()}).strict();const oH=8,due=["submitted","working","input_required","completed","failed","canceled","rejected"],X5=Ve(due),hue=/^[A-Za-z0-9_.-]{1,128}$/,Ek=/^[a-z0-9-]{1,128}$/;function fue(e){if(e.startsWith("cloud:")){const s=e.slice(6);return Ek.test(s)?{kind:"cloud",personaId:s}:null}const t=e.indexOf("@");if(t<0)return Ek.test(e)?{kind:"here",personaId:e}:null;const n=e.slice(0,t),r=e.slice(t+1);return Ek.test(n)&&hue.test(r)?{kind:"device",personaId:n,deviceId:r}:null}const pue=B({target:N().refine(e=>fue(e)!==null,{message:"target must be <personaId>, <personaId>@<deviceId> or cloud:<personaId>"}),text:N().min(1),brief:N().optional(),contextId:N().min(1).optional(),taskId:N().min(1).optional(),sessionLabel:N().min(1).max(60).optional(),model:N().min(1).optional(),tool:N().min(1).optional(),meta:Yi(Za()).optional()}).refine(e=>!(e.contextId&&e.taskId),{message:"contextId (new round) and taskId (answer) are mutually exclusive"}).refine(e=>!((e.contextId||e.taskId)&&(e.model||e.tool)),{message:"a follow-up cannot change engine or model (contextId / taskId exclude model / tool); start a new line instead"});B({calls:pe(pue).min(1).max(oH),sessionId:N().min(1).optional()});const mue=6e4;B({taskIds:pe(N().min(1)).min(1).max(oH),timeoutMs:Q().int().min(0).max(mue)});B({taskId:N().min(1),text:N().trim().min(1)});B({taskId:N().min(1)});B({contextId:N().min(1).optional(),state:X5.optional(),sessionId:N().min(1).optional(),relatedSessionId:N().min(1).optional()});B({contextId:N().min(1),state:Ve(["completed","failed","input_required"]),text:N(),brief:N().optional(),filePaths:pe(N().min(1)).optional()});const Z5=B({taskId:N().min(1),contextId:N().min(1),round:Q().int().positive(),state:X5,stale:Me(),reason:N().nullable(),depth:Q().int().min(0),tenant:N(),targetPersonaId:N(),targetDeviceId:N().nullable(),initiator:B({host:N(),personaId:N(),sessionRef:N().nullable()}),executorSessionRef:N().nullable(),executorThreadId:N().nullable(),workerSessionId:N().optional(),sessionLabel:N().optional(),taskText:N(),brief:N().nullable(),resultText:N().nullable(),filePaths:pe(N()),line:Yi(Za()),deliveredAt:N().nullable(),createdAt:N(),updatedAt:N(),finishedAt:N().nullable()}),gue=Bs("ok",[B({ok:he(!0),task:Z5}),B({ok:he(!1),error:B({code:N(),message:N()})})]);B({results:pe(gue)});B({tasks:pe(Z5)});B({tasks:pe(Z5),done:Me()});const xue=/^[a-z0-9][a-z0-9-]*$/;Ve(["stopped","starting","running","crashed","invalid"]);const vue=new Set(["localhost","127.0.0.1"]);function yue(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&vue.has(t.hostname))}const c0=B({id:N().regex(xue),name:N().min(1),version:N().min(1),apiVersion:he("1"),runtime:B({startCommand:N().min(1)}).passthrough().optional(),entry:B({url:N().url().refine(yue,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var s;const n=!!e.runtime,r=!!((s=e.entry)!=null&&s.url);n&&r&&t.addIssue({code:ke.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:ke.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),bue=Bs("kind",[B({kind:he("local"),port:Q().int().min(1).max(65535)}),B({kind:he("hosted"),url:N().url()})]);Bs("state",[B({extId:N(),manifest:c0,state:he("stopped")}),B({extId:N(),manifest:c0,state:he("starting")}),B({extId:N(),manifest:c0,state:he("running"),target:bue}),B({extId:N(),manifest:c0,state:he("crashed")}),B({extId:N(),manifest:Za().nullable(),state:he("invalid"),invalidReason:N().min(1)})]);B({snapshotHash:N().min(1),version:N().min(1),publishedAt:Q()});const wue=Bs("kind",[B({kind:he("p2p-tunnel"),ownerPrincipalId:N().min(1),extId:N().min(1)})]);Bs("kind",[B({kind:he("p2p-tunnel"),ownerPrincipalId:N().min(1),extId:N().min(1),snapshotHash:N().min(1)})]);B({extId:N().min(1),name:N().min(1),version:N().min(1),contentHash:N().min(1),publishedAt:Q()});const _ue=Bs("kind",[B({kind:he("clean")}),B({kind:he("ready-new-version"),fromVersion:N().min(1),toVersion:N().min(1)}),B({kind:he("error-same-hash"),version:N().min(1)}),B({kind:he("error-version-not-bumped"),localVersion:N().min(1),publishedVersion:N().min(1)}),B({kind:he("error-version-regression"),localVersion:N().min(1),publishedVersion:N().min(1)})]);function Sue(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return(t>>>0).toString(16).padStart(8,"0")}function Q5(e,t){return`${e}-${Sue(t)}`}function J5(e){if(typeof e!="string")return{ok:!1,reason:"version must be a string"};const t=e.split(".");if(t.length!==3)return{ok:!1,reason:`"${e}" — only MAJOR.MINOR.PATCH allowed`};for(const n of t)if(!/^\d+$/.test(n))return{ok:!1,reason:`"${e}" — only numeric segments allowed`};return{ok:!0}}function aH(e,t){const n=NA(e),r=NA(t);for(let s=0;s<3;s++){if(n[s]<r[s])return-1;if(n[s]>r[s])return 1}return 0}function NA(e){const t=J5(e);if(!t.ok)throw new Error(t.reason);const[n,r,s]=e.split(".").map(i=>parseInt(i,10));return[n,r,s]}B({localManifest:B({name:N().min(1),version:N().min(1),contentHash:N().min(1)}),publishState:Bs("kind",[B({kind:he("unpublished")}),B({kind:he("published"),version:N().min(1),contentHash:N().min(1),publishedAt:Q()})]),check:_ue});B({extId:N().min(1),newVersion:N().min(1).nullish()});B({extId:N().min(1)});B({extId:N().min(1),snapshotHash:N().min(1)});B({channelRef:wue,snapshotHash:N().min(1),zipBase64:N().min(1)});B({id:N().min(1),peerDeviceId:N().min(1),senderDeviceId:N().min(1),text:N().min(1),createdAt:Q().int().nonnegative(),readBy:Yi(N().min(1),Q().int().positive()).default({}),origin:B({kind:he("persona"),personaId:N().min(1)}).optional()}).strict();B({peerDeviceId:N().min(1).optional(),id:N().min(1),text:N().min(1),createdAt:Q().int().nonnegative(),origin:B({kind:he("persona"),personaId:N().min(1)}).optional()}).strict();B({peerDeviceId:N().min(1),sinceCreatedAt:Q().int().nonnegative().optional()}).strict();B({peerDeviceId:N().min(1),upToCreatedAt:Q().int().nonnegative()}).strict();B({peerDeviceId:N().min(1).optional(),text:N().min(1)});B({peerDeviceId:N().min(1).optional(),command:N().min(1),timeoutMs:Q().int().positive().optional()}).strict();B({type:he("peerExec:run:ok"),stdout:N(),stderr:N(),exitCode:Q().int().nullable(),timedOut:Me(),stdoutTruncated:Me(),stderrTruncated:Me()}).strict();const lH=Bs("kind",[B({kind:he("at"),at:N().min(1)}),B({kind:he("every"),everyMs:Q().int().positive(),anchorMs:Q().int().nonnegative().optional()}),B({kind:he("cron"),expr:N().min(1),tz:N().min(1).optional()})]),mx=N().trim().min(1);B({personaId:mx,name:N().min(1),schedule:lH,prompt:N().min(1),targetPersona:N().min(1).optional(),timeoutMs:Q().int().positive().optional()});B({personaId:mx,onlyMine:Me().optional()});B({personaId:mx,shiftId:N().min(1)});const kue=B({name:N().min(1).optional(),schedule:lH.optional(),prompt:N().min(1).optional(),targetPersona:N().min(1).optional(),timeoutMs:Q().int().positive().optional(),enabled:Me().optional()});B({personaId:mx,shiftId:N().min(1),patch:kue});B({personaId:mx,shiftId:N().min(1),limit:Q().int().positive().optional()});const Fi="persona-master",eT=B({personaId:N().min(1),deviceId:N().min(1).optional()}),cH=B({id:N().min(1),name:N().min(1),memberPersonas:pe(eT),memberContactDeviceIds:pe(N().min(1)),createdAt:N().min(1),updatedAt:N().min(1)}),uH=N().trim().min(1);B({name:uH,memberPersonas:pe(eT).default([]),memberContactDeviceIds:pe(N().min(1)).default([])});B({channelId:N().min(1),name:uH.optional(),memberPersonas:pe(eT).optional(),memberContactDeviceIds:pe(N().min(1)).optional()});B({channelId:N().min(1)});B({channels:pe(cH)});B({channel:cH});B({ok:he(!0),removedTopics:Q().int().min(0)});const dr=N().trim().min(1),tT=["master-confirmed","owner-needed"],nT=["open","resolved"],Cue=tT[0],dH=tT[1],hH=nT[0],Nue=nT[1],jue=Ve(tT),Eue=Ve(nT),Iue=B({id:dr.optional(),resolves:dr.optional(),type:jue,status:Eue,question:dr,recommendation:dr}).superRefine((e,t)=>{e.type===Cue&&e.status!==Nue&&t.addIssue({code:ke.custom,path:["status"],message:"master-confirmed decisions must be resolved"})}),Tue=["planning","running","done"],Rue=Ve(Tue),fH=B({at:N().min(1),actor:N().min(1),action:N().min(1),target:N().optional(),reason:N().min(1),artifacts:pe(dr).optional(),decision:Iue.optional()}),Mue=B({rejectCount:Q().int().min(0),accepted:Me().default(!1),ordinal:Q().int().min(1).optional(),overrideCount:Q().int().min(0).optional()}),rT=B({id:N().min(1),channelId:N().min(1),title:N(),masterSessionId:N().min(1),goal:N(),boundaries:N(),acceptanceCriteria:pe(N()),activity:pe(fH),lineMeta:Yi(Mue),nextLineOrdinal:Q().int().min(1).optional(),state:Rue,createdAt:N().min(1),updatedAt:N().min(1)}),Pue=B({lineId:N().min(1),contextId:N().min(1),taskId:N().min(1),workerSessionId:N().optional(),assignee:N().min(1),focus:N(),status:X5,acceptance:pe(N()),rejectCount:Q().int().min(0),accepted:Me(),ordinal:Q().int().min(1).nullable()});B({channelId:N().min(1)});B({topicId:N().min(1).optional(),sessionId:N().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});B({channelId:N().min(1),title:dr.optional()});B({topicId:N().min(1),title:dr.optional(),goal:dr,boundaries:N(),acceptanceCriteria:pe(dr).min(1)});B({topicId:N().min(1),action:dr,target:dr.optional(),reason:dr,artifacts:pe(dr).optional(),decision:fH.shape.decision});B({topicId:N().min(1),lineId:dr,reason:dr});B({topicId:N().min(1),lineId:dr,reason:dr,artifacts:pe(dr).optional(),watcherVerdict:Ve(["pass","fail"]),overrideReason:dr.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});B({topicId:N().min(1),state:Ve(["done"])});B({topicId:N().min(1),title:dr});B({topicId:N().min(1)});const Aue=rT.extend({lineCount:Q().int().min(0)});B({topics:pe(Aue)});B({topic:rT,lines:pe(Pue)});B({topicId:N().min(1),masterSessionId:N().min(1)});B({rejectCount:Q().int().min(1),needsOwnerAttention:Me()});B({acceptedLines:Q().int().min(1),totalLines:Q().int().min(1),allAccepted:Me(),overrides:Q().int().min(0),needsOwnerAttention:Me()});B({topic:rT});B({ok:he(!0),removedMasterSessionId:N().min(1).nullable(),removedWorkerSessionIds:pe(N().min(1))});const Oue=["ask","allow","deny"],pH=Ve(Oue),Due=B({id:N().min(1),desc:N().min(1),action:pH});B({rules:pe(Due)});B({ruleId:N().min(1)});B({action:pH,desc:N(),source:N().min(1)});const $ue=["created","review-requested"],mH=/^[A-Za-z0-9._-]+$/,If=N().min(1).regex(mH),Tf=N().min(1).regex(mH),gx=Q().int().positive();B({role:Ve($ue)});B({owner:If,repo:Tf,number:gx});B({owner:If,repo:Tf,number:gx,expectedHeadSha:N().min(1)});B({owner:If,repo:Tf,number:gx,body:N().min(1)});B({owner:If,repo:Tf,number:gx,ready:Me()});B({owner:If,repo:Tf});B({owner:If,repo:Tf,number:gx,reviewers:pe(N().min(1)).min(1)});B({page:Q().int().min(1).max(1e3).optional(),search:N().max(100).optional()});B({personaId:N().min(1)});B({personaId:N().min(1)});const Lue=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],Fue=Ve(Lue);B({personaId:N().min(1),appId:N().min(1),appSecret:N().min(1),botName:N().min(1).optional()});const Bue=B({chatId:N().min(1),chatName:N().optional(),lastActiveAt:Q().int().optional()}),zue=B({state:Ve(["unbound","provisioning","bound","broken"]),appId:N().optional(),botName:N().optional(),brokenReason:N().optional(),qrUrl:N().optional(),provisionId:N().optional(),errorReason:Fue.optional(),groups:pe(Bue),needsUpgrade:Me().optional(),upgradeQrUrl:N().optional()});zue.extend({personaId:N().min(1)});B({});B({onboardingCompletedAt:Q()});const Wh=["claude","codex","pi"];B({});B({tools:pe(B({id:Ve(Wh),available:Me(),version:N().optional(),path:N().optional()}))});B({});const Hue=B({tool:Ve(Wh),cwd:N(),toolSessionId:N(),label:N().optional(),createdAt:N(),updatedAt:N(),turns:Q()});B({candidates:pe(Hue)});B({});B({registered:Me()});const Uue=B({kind:Ve(["rpc","file"]),ref:N().min(1).max(300)});B({question:N().min(1).max(500),status:Ve(["unanswered","answered_unverified"]),answer:N().max(4e3).optional(),resolvedBy:Ve(["rpc","source"]).optional(),evidence:pe(Uue).max(20).optional(),docsChecked:pe(N().max(200)).max(20).optional(),unansweredReason:Ve(["no_source_access","user_declined","not_found"]).optional()}).superRefine((e,t)=>{var n;e.status==="answered_unverified"?(e.answer||t.addIssue({code:"custom",path:["answer"],message:"answered_unverified 需要 answer"}),e.resolvedBy||t.addIssue({code:"custom",path:["resolvedBy"],message:"answered_unverified 需要 resolvedBy"}),(n=e.evidence)!=null&&n.length||t.addIssue({code:"custom",path:["evidence"],message:"answered_unverified 需要至少一项 evidence"})):e.unansweredReason||t.addIssue({code:"custom",path:["unansweredReason"],message:"unanswered 需要 unansweredReason"})});B({id:N()});B({tool:Ve(Wh)});const jA=B({usedPercent:Q(),windowDurationMins:Q().optional(),resetsAt:Q().optional()}).strict(),Wue=Bs("kind",[B({kind:he("claude"),loggedIn:Me(),authMethod:N().optional(),apiProvider:N().optional(),apiKeySource:N().optional(),email:N().optional(),orgName:N().optional(),subscriptionType:N().optional()}).strict(),B({kind:he("codex"),login:Bs("type",[B({type:he("none")}).strict(),B({type:he("apiKey")}).strict(),B({type:he("chatgpt"),email:N(),planType:N()}).strict()]),provider:B({name:N(),baseUrl:N().optional()}).strict(),rateLimits:B({primary:jA.optional(),secondary:jA.optional()}).strict().optional()}).strict(),B({kind:he("pi"),providers:pe(B({id:N(),modelCount:Q(),credential:Ve(["api_key","oauth"]).optional(),oauthExpiresAt:Q().optional()}).strict())}).strict()]);B({tool:Ve(Wh),installed:Me(),version:N().optional(),path:N().optional(),account:Wue.optional(),error:N().optional(),modelsLoadedAt:Q().optional()}).strict();const sT="https://cpa-portal-d417.app.clawos.chat";B({apiKey:N().min(1)}).strict();B({ok:he(!0)}).strict();const gH=["cloud-persona-metrics","cloud-persona-conversations","cloud-persona-schedules"],Vue=Ve(gH);B({page:Vue}).strict();B({url:N(),expiresAt:Q().int()}).strict();const xH=["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","larkBot:state"],que="cloud_history_refresh",iT=["idle","running","running-idle","stopped","error","observing"],Kue=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","a2a-task","a2a-result","dispatch-task","dispatch-result"],Gue=["a2a-task","a2a-result","dispatch-task","dispatch-result"];function Pw(e){return Gue.includes(e??"")}function Yue(e,t){return`${t?"dispatch":"a2a"}-${e}`}const Xue=["builtin","global","project","plugin"],Zue=["builtin","global","project","policy","plugin"],vH=Ve(["owner","guest"]);B({id:N().min(1),kind:vH,displayName:N(),feishuUnionId:N().optional()}).strict();const Que=B({did:N().min(1),displayName:N(),feishuUnionId:N().optional(),principal:vH}).strict(),Jue=Ve(iT),ede=B({inputTokens:Q().int().nonnegative(),outputTokens:Q().int().nonnegative(),cacheReadTokens:Q().int().nonnegative().optional(),cacheCreateTokens:Q().int().nonnegative().optional()}),yH={gitBranch:N().optional(),resolvedModel:N().optional(),resolvedEffort:N().optional(),contextUsage:ede.optional(),contextWindowSize:Q().int().positive().optional(),aiLabel:N().optional()},tde=B(yH),bH=B({value:N(),label:N(),description:N().optional()}),nde=B({id:N().min(1),label:N().min(1),description:N().optional(),contextWindowSize:Q().int().positive().optional(),default:Me().optional(),efforts:pe(bH).optional(),defaultEffort:N().optional(),group:N().optional()}),rde=B({id:N().min(1),label:N().min(1),description:N().optional()}),sde=B({name:N().min(1),type:Ve(["string","select","toggle"]),label:N().min(1),description:N().optional(),options:pe(bH).optional(),default:Za().optional(),scope:Ve(["core","tool-specific"])});B({tool:N().min(1),refresh:Me().optional()});const ide=B({rewind:Me(),subagents:Me(),tui:Me(),observe:Me(),fileSharing:Me(),fork:Me()});B({tool:N().min(1),toolSessionIdLabel:N().optional(),models:pe(nde),permissionModes:pe(rde),configSchema:pe(sde),features:ide});const ode=B({tool:N().min(1),pattern:N().min(1),createdAt:N().min(1).optional()});B({cloudEnvironment:Hs.optional(),cloudExpectedImage:gc.optional(),testReleaseId:N().optional(),sessionId:N().min(1),cloudConversationId:N().min(1).optional(),cloudWorkspace:Tw.optional(),cloudPendingTurns:pe(B({id:N().min(1),text:N(),prepared:Me().optional()})).optional(),cloudBranchIntent:kg.optional(),cwd:N().min(1),tool:he("claude").or(N().min(1)).default("claude"),toolSessionId:N().optional(),label:N().optional(),model:N().optional(),permissionMode:N().optional(),effort:N().optional(),serviceTier:N().optional(),...yH,aiLabelGeneratedAt:N().optional(),permissionRules:pe(ode).optional(),pinnedAt:Q().int().nonnegative().nullable().optional(),archivedAt:Q().int().nonnegative().nullable().optional(),pinSortOrder:Q().int().nullable().optional(),unreadAt:N().min(1).nullable().optional(),iconKey:N().optional(),forkedFromSessionId:N().min(1).optional(),ephemeral:Me().optional(),deployId:N().min(1).optional(),ownerPersonaId:N().min(1).optional(),projectPath:N().min(1).optional(),chatId:N().min(1).optional(),creatorPrincipalId:N().min(1).optional(),creatorDisplayName:N().min(1).optional(),creatorFeishuUnionId:N().min(1).optional(),originOwnerPrincipalId:N().min(1).optional(),originOwnerPersonaId:N().min(1).optional(),dispatchedFromSessionId:N().min(1).optional(),a2aContextId:N().min(1).optional(),shiftFiredFromSessionId:N().min(1).optional(),larkChatId:N().min(1).optional(),larkChatName:N().min(1).optional(),larkChatType:Ve(["p2p","group"]).optional(),createdAt:N().min(1),updatedAt:N().min(1)});const js={turnId:N().min(1).optional(),seq:Q().int().nonnegative().optional(),ts:N().optional(),uuid:N().optional()},ade=Ve(Kue),lde=B({readCount:Q().int().nonnegative().optional(),searchCount:Q().int().nonnegative().optional(),bashCount:Q().int().nonnegative().optional(),editFileCount:Q().int().nonnegative().optional(),linesAdded:Q().int().nonnegative().optional(),linesRemoved:Q().int().nonnegative().optional(),otherToolCount:Q().int().nonnegative().optional()}),cde=B({oldStart:Q().int().nonnegative(),oldLines:Q().int().nonnegative(),newStart:Q().int().nonnegative(),newLines:Q().int().nonnegative(),lines:pe(N())}),ude=B({agentId:N().optional(),agentType:N().optional(),status:N().optional(),prompt:N().optional(),filePath:N().optional(),structuredPatch:pe(cde).optional(),stats:B({durationMs:Q().int().nonnegative().optional(),tokens:Q().int().nonnegative().optional(),toolUseCount:Q().int().nonnegative().optional(),toolStats:lde.optional()}).optional()}),dde=B({path:N(),content:N(),mtimeMs:Q().optional()}),hde=B({label:N().min(1),description:N().optional()}),wH=B({question:N().min(1),multiSelect:Me(),options:pe(hde).min(1)}),fde=["completed","interrupted"];Bs("kind",[B({...js,kind:he("session_init"),toolSessionId:N().optional()}),B({...js,kind:he("thinking"),text:N(),partialId:N().optional()}),B({...js,kind:he("text"),text:N(),partialId:N().optional()}),B({...js,kind:he("user_text"),text:N(),meta:ade.optional(),taskId:N().optional(),parentToolUseId:N().optional(),sender:Que.optional()}),B({...js,kind:he("tool_call"),toolUseId:N(),tool:N(),toolKind:N().optional(),input:Za()}),B({...js,kind:he("tool_result"),toolUseId:N(),output:Za().optional(),error:N().optional(),toolResultExtra:ude.optional(),sourceToolAssistantUUID:N().optional(),askQuestionAnswers:Yi(N(),N()).optional()}),B({...js,kind:he("attachment_memories"),memories:pe(dde)}),B({...js,kind:he("permission_request"),requestId:N(),tool:N(),input:Za(),toolUseId:N().optional()}),B({...js,kind:he("ask_user_question"),toolUseId:N(),questions:pe(wH)}),B({...js,kind:he("turn_end"),durationMs:Q().int().nonnegative().optional(),reason:Ve(fde).optional(),turnId:N().min(1).optional()}),B({...js,kind:he("subagent_progress"),toolUseId:N(),agentId:N(),status:Ve(["started","running","completed","failed"]),description:N().optional(),lastToolName:N().optional(),prompt:N().optional(),stats:B({durationMs:Q().int().nonnegative().optional(),tokens:Q().int().nonnegative().optional(),toolUseCount:Q().int().nonnegative().optional()}).optional()}),B({...js,kind:he("error"),message:N()}),B({...js,kind:he("meta_update"),patch:tde}),B({...js,kind:he("meta-text"),text:N(),metaSource:Ve(["cc","owner"]).optional()})]);B({cwd:N().min(1).optional(),tool:N().optional(),label:N().optional(),aiLabel:N().optional(),model:N().optional(),permissionMode:N().optional(),effort:N().optional(),serviceTier:V7.optional(),iconKey:N().optional(),forkedFromSessionId:N().min(1).optional(),forkAt:nce([B({messageUuid:N().min(1)}).strict(),B({turnId:N().min(1)}).strict()]).optional(),ephemeral:Me().optional(),ownerPersonaId:N().min(1).optional(),projectPath:N().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});B({path:N().min(1),name:N().min(1),createdAt:N().datetime(),pinnedAt:Q().optional()});B({path:N().min(1),pinnedAt:Q().nullable()});B({path:N().min(1)});B({path:N().min(1).optional(),name:N().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});B({cwd:N().min(1),tool:N().min(1),toolSessionId:N().min(1),label:N().optional(),aiLabel:N().optional(),iconKey:N().optional(),createdAt:N().datetime(),updatedAt:N().datetime(),ownerPersonaId:N().min(1).optional()});B({originOnly:Me().optional(),ownerPersonaId:N().min(1).optional(),limit:Q().int().positive().optional(),offset:Q().int().nonnegative().optional()});B({sessionId:N().min(1)});B({sessionId:N().min(1),patch:B({label:N().optional(),tool:N().min(1).optional(),model:N().optional(),permissionMode:N().optional(),effort:N().optional(),cwd:N().optional(),iconKey:N().optional(),ephemeral:he(!1).optional()})});B({id:N().min(1),text:N(),queuedAt:Q(),senderDisplayName:N().optional()});B({sessionId:N().min(1),text:N(),queueWhileRunning:Me().optional()});B({sessionId:N().min(1),id:N().min(1).optional()});B({sessionId:N().min(1),userMessageId:N().min(1),dryRun:Me().optional()});B({canRewind:Me(),error:N().optional(),filesChanged:pe(N()).optional(),insertions:Q().int().nonnegative().optional(),deletions:Q().int().nonnegative().optional()});B({sessionId:N().min(1),userMessageId:N().min(1)});const pde=B({oldStart:Q().int().nonnegative(),oldLines:Q().int().nonnegative(),newStart:Q().int().nonnegative(),newLines:Q().int().nonnegative(),lines:pe(N())}),mde=B({filePath:N().min(1),hunks:pe(pde),insertions:Q().int().nonnegative(),deletions:Q().int().nonnegative(),status:Ve(["modified","added","deleted"]).optional()});B({canRewind:Me(),error:N().optional(),files:pe(mde),totalInsertions:Q().int().nonnegative(),totalDeletions:Q().int().nonnegative()});B({userMessageIds:pe(N())});B({sessionId:N().min(1),toolSessionId:N().min(1)});B({cwd:N().min(1),toolSessionId:N().min(1),messageUuid:N().min(1).optional(),turnId:N().min(1).optional(),sourceSessionId:N().min(1).optional(),targetCwd:N().min(1).optional()}).refine(e=>!!(e.messageUuid||e.turnId),"messageUuid or turnId required");B({forkedToolSessionId:N().min(1),forkedFilePath:N().min(1)});B({sessionId:N().min(1),toolSessionId:N().min(1),jsonlPath:N().optional()});B({sessionId:N().min(1),afterSeq:Q().int().min(-1)});B({sessionId:N().min(1),permissionRequestId:N().min(1),allow:Me(),permanent:Me().optional(),pattern:N().optional()});B({projectPath:N().min(1)});B({sessionId:N().min(1),limit:Q().int().positive().max(5e3).optional(),offset:Q().int().nonnegative().optional(),snapshotId:N().uuid().optional(),slim:Me().optional(),view:Ve(["turns","items"]).optional(),cursor:N().min(1).max(16384).optional(),turnId:N().min(1).max(256).optional()}).superRefine((e,t)=>{e.view==="items"&&!e.turnId&&t.addIssue({code:ke.custom,path:["turnId"],message:"items requires turnId"}),e.view&&(e.offset!==void 0||e.slim!==void 0)&&t.addIssue({code:ke.custom,message:"native views do not accept offset or slim"}),!e.view&&(e.cursor!==void 0||e.turnId!==void 0)&&t.addIssue({code:ke.custom,message:"cursor and turnId require a native view"}),e.view==="turns"&&e.turnId!==void 0&&t.addIssue({code:ke.custom,path:["turnId"],message:"turns does not accept turnId"}),e.view&&e.limit!==void 0&&e.limit>100&&t.addIssue({code:ke.custom,path:["limit"],message:"native page limit is 100"})});B({cwd:N().min(1),toolSessionId:N().min(1)});B({cwd:N().min(1),toolSessionId:N().min(1),subagentId:N().min(1)});B({cwd:N().min(1).optional(),path:N().optional(),showHidden:Me().optional()});B({cwd:N().min(1),path:N().min(1)});B({cwd:N().min(1),tool:N().optional()});B({name:N().min(1),source:Ve(Xue),path:N().optional(),description:N().optional(),plugin:N().optional()});const gde=B({name:N().min(1),source:Ve(Zue),path:N().optional(),description:N().optional(),whenToUse:N().optional(),plugin:N().optional()});B({cwd:N().min(1),tool:N().optional()});B({agents:pe(gde)});B({sessionId:N().optional()});B({sessionId:N().min(1).optional()});B({sessionId:N().min(1),pinned:Me()});B({sessionId:N().min(1),archived:Me()});B({query:N().min(1),sessionIds:pe(N().min(1)),limit:Q().int().positive().max(50).optional()});const xde=B({sessionId:N().min(1),snippet:N()});B({type:he("session:searchContent"),matches:pe(xde)});B({type:he("peerSession:upsert:ok")});B({sessionId:N().min(1)});B({type:he("peerSession:remove:ok")});B({orderedIds:pe(N().min(1)).min(1)});B({cwd:N().min(1)});B({isGitRoot:Me(),gitRoot:N().nullable()});B({cwd:N().min(1)});B({branch:N().nullable()});B({cwd:N().min(1)});B({branches:pe(N()),head:N().nullable()});const vde=B({cwd:N().min(1),updatedAt:N().min(1)});B({dirs:pe(vde)});B({type:he("session:question"),sessionId:N().min(1),toolUseId:N().min(1),requestId:N().min(1),questions:pe(wH).min(1)});B({type:he("session:question:cleared"),sessionId:N().min(1),toolUseId:N().min(1),answers:Yi(N(),N()).optional()});B({sessionId:N().min(1),toolUseId:N().min(1),answers:Yi(N(),N())});B({ok:he(!0)});B({sessionId:N().min(1),toolUseId:N().min(1)});B({ok:he(!0)});const _H=B({name:N().min(1),version:N().min(1),instanceId:N().min(1),deviceLabel:N().transform(e=>e.trim().slice(0,64)).optional()});B({type:he("auth"),token:N().min(1),scheme:he("bearer").optional(),clientInfo:_H.optional()});B({type:he("auth:ok"),version:N().min(1).optional(),protocolVersion:Q().int().nonnegative().optional()});const yde=B({clientId:N().min(1),connectedAt:Q().int().nonnegative(),self:Me(),clientInfo:_H.optional()});B({type:he("device:connections:ok"),connections:pe(yde)});B({type:he("tunnel:ready"),url:N().min(1),subdomain:N().min(1)});B({type:he("tunnel:exited"),code:Q().int().nullable(),subdomain:N().nullable(),url:N().nullable()});B({type:he("tunnel:unavailable"),reason:N().min(1),failedAt:N().min(1)});const bde=B({sessionId:N().min(1),status:Jue,freshSpawn:Me(),pendingPermissionRequestIds:pe(N().min(1)),pendingQuestionToolUseIds:pe(N().min(1))});B({type:he("info"),version:N(),protocolVersion:Q(),hostname:N(),os:N(),tools:pe(B({id:N(),available:Me()})),runningSessions:pe(bde),tokenRole:Ve(lce).optional(),isLoopback:Me().optional(),httpBaseUrl:N().optional(),httpToken:N().optional(),daemonSource:Ve(["ota","packaged"]).optional(),globalCliVersion:N().nullable().optional()});B({});B({method:N().min(1).optional()});const wde=["allowed","conditional","denied"],_de=Ve(wde),Sde=B({name:N().min(1),status:_de,description:N().min(1),args:pe(B({name:N(),required:Me()})).nullable(),argsSchema:Yi(Za()).optional(),reason:N().optional()});B({type:he("meta:methods"),methods:pe(Sde)});const EA=1,kde=B({usedBytes:Q().int().nonnegative(),sizeBytes:Q().int().positive(),measuredAt:Q().int().nonnegative()}).strict();B({volume:kde.nullable()}).strict();const IA=25*1024*1024,oT={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".txt":"text/plain",".md":"text/plain",".markdown":"text/plain",".csv":"text/plain",".log":"text/plain",".json":"application/json",".xml":"application/xml",".yaml":"application/yaml",".yml":"application/yaml",".html":"text/html",".conf":"text/plain",".cfg":"text/plain",".ini":"text/plain",".toml":"text/plain"},SH=new Set([...Object.values(oT),"application/x-yaml"]),kH=[...SH,"text/*",...Object.keys(oT)].join(",");function CH(e,t){const n=t.split(";",1)[0].trim().toLowerCase();if(n===""||n==="application/octet-stream"){const r=e.lastIndexOf("."),s=r>0?e.slice(r).toLowerCase():"";return oT[s]??null}return SH.has(n)||n.startsWith("text/")?n:null}const Cde=["daemon","main","renderer"],Nde=Ve(Cde),jde=["debug","info","warn","error"],Ede=Ve(jde);B({ts:Q().int(),source:Nde,level:Ede,msg:N(),ownerPrincipalId:N(),deviceId:N(),appVersion:N(),daemonVersion:N().optional(),os:N(),meta_json:N().optional(),sessionId:N().optional()});B({v:he(1),visitorId:N().min(1),displayName:N(),provider:N(),iat:Q(),exp:Q()});const Ide=B({visitorId:N(),displayName:N(),avatarUrl:N().optional(),provider:N(),firstSeen:Q(),lastSeen:Q()});B({visitors:pe(Ide)});B({type:he("web:open"),url:N().min(1),expiresAt:Q()});B({ticket:N().min(1)}).strict();B({token:N().min(1),expiresAt:Q()});const Tde=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,NH=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,Rde="clawd-a2a-task",Mde="clawd-a2a-result",Pde="clawd-dispatch-task",Ade="clawd-dispatch-result",Ode=["completed","failed","input_required","canceled","rejected"],TA=120,jH=[{tag:Rde,kind:"task",legacy:!1},{tag:Mde,kind:"result",legacy:!1},{tag:Pde,kind:"task",legacy:!0},{tag:Ade,kind:"result",legacy:!0}];function Dde(e){if(!e)return null;let t=null;for(const n of jH){const r=e.search(Vde(n.tag));r>=0&&(t===null||r<t.at)&&(t={at:r,kind:n.kind,legacy:n.legacy})}return t?{kind:t.kind,legacy:t.legacy}:null}function $de(e){if(!e)return[];const t=[];for(const n of jH){const r=new RegExp(`<${n.tag}\\b([^>]*)>([\\s\\S]*?)</${n.tag}>`,"gi");for(let s=r.exec(e);s!==null;s=r.exec(e))t.push({at:s.index,block:Lde(n.kind,n.legacy,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function Lde(e,t,n,r){var h;const s=qde(n),i=cj(Wde(Ik(r,"detail")??r)),o=(h=Ik(r,"brief"))==null?void 0:h.trim(),l=o&&o.length>0?cj(o):Fde(i),c=s.round!==void 0?Number.parseInt(s.round,10):void 0,u=s.status,d=t?u==="success"?"completed":u==="failure"?"failed":void 0:Ode.find(f=>f===u);return{kind:e,contextId:(t?s["dispatch-id"]:s["context-id"])??"",...!t&&s["task-id"]?{taskId:s["task-id"]}:{},...s.from?{from:s.from}:{},...e==="task"&&c!==void 0&&Number.isFinite(c)?{round:c}:{},...e==="result"&&d?{status:d}:{},brief:l,briefIsDerived:!(o&&o.length>0),detail:i,filePaths:Ude(Ik(r,"files")),legacy:t}}function Fde(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>TA?`${n.slice(0,TA)}…`:n}const Bde="clawd-a2a-task|clawd-a2a-result|clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",zde=new RegExp(`<\\\\(\\\\*)(/?)(${Bde})\\b`,"g");function Hde(e){return cj(e)}function cj(e){return e.replace(zde,"<$1$2$3")}function Ik(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function Ude(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 Wde(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function Vde(e){return new RegExp(`<${e}\\b[^>]*>`,"i")}function qde(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=Kde(r[2]??"");return t}function Kde(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}/**
97
97
  * @license lucide-react v0.577.0 - ISC
98
98
  *
@@ -952,4 +952,4 @@ npx @clawos-dev/clawd@latest --tunnel # 远程(输出 Connect: 一行整粘
952
952
  `;function vot({rows:e,activity:t,ownerName:n,onExit:r,onPick:s}){p.useEffect(()=>{const h=f=>{f.key==="Escape"&&(f.stopPropagation(),r())};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[r]);const i=sot(xot),o=tot(e),{running:l,awaiting:c,unread:u}=o,d=a.jsx("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",children:a.jsx("div",{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto ${i?"":"mx-auto"}`,style:{maxWidth:k2,paddingTop:i?28:void 0},children:e.length===0?a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3",children:[a.jsx("div",{style:{fontSize:22,color:"#8E949B"},children:"今天还没有 agent 干活"}),a.jsx("div",{className:"font-mono",style:{fontSize:13,color:"#4A4F55"},children:"派点活给它们,这里就会热闹起来"})]}):e.map((h,f)=>a.jsx(got,{row:h,activity:t.get(h.sessionId),index:f,onPick:s,maxHeight:i?fot:void 0},h.sessionId))})});return i?a.jsxs("div",{"data-testid":"hive-board",className:"dark relative flex h-full w-full overflow-hidden",style:{background:"#08090A"},children:[a.jsx("style",{children:QB}),a.jsxs("div",{className:"mx-auto flex h-full w-full",style:{maxWidth:Rte+k2},children:[a.jsx(uot,{rows:e,summary:o,ownerName:n,onExit:r}),d]})]}):a.jsxs("div",{"data-testid":"hive-board",className:"dark relative flex h-full w-full flex-col overflow-hidden",style:{background:"#08090A"},children:[a.jsx("style",{children:QB}),a.jsxs("header",{"data-testid":"hive-header",className:"mx-auto flex w-full shrink-0 items-start justify-between px-8 pb-5 pt-7",style:{maxWidth:k2},children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"font-medium leading-none",style:{fontSize:42,letterSpacing:".02em",color:"#F4F6F8"},children:n}),a.jsx("button",{type:"button","data-testid":"hive-exit",onClick:r,"aria-label":"退出 Hive",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-colors",style:{background:"rgb(255 255 255 / .06)",color:"#8E949B"},children:a.jsx(en,{className:"h-4 w-4",strokeWidth:2.25})})]}),a.jsx("div",{className:"mt-3.5 flex items-center gap-2.5",children:l>0?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"h-[10px] w-[10px] shrink-0 rounded-full animate-pulse",style:{background:`rgb(${vo.running.color})`,boxShadow:`0 0 12px rgb(${vo.running.color})`}}),a.jsxs("span",{style:{fontSize:27,color:`rgb(${vo.running.color})`},children:[a.jsx("span",{className:"font-mono tabular-nums font-medium",children:l})," 个 agent 正在运行"]})]}):c>0?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"h-[10px] w-[10px] shrink-0 rounded-full animate-pulse",style:{background:`rgb(${vo.awaiting.color})`}}),a.jsxs("span",{style:{fontSize:27,color:`rgb(${vo.awaiting.color})`},children:[a.jsx("span",{className:"font-mono tabular-nums font-medium",children:c})," 个 agent 在等我"]})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"h-[10px] w-[10px] shrink-0 rounded-full",style:{background:"#4A4F55"}}),a.jsx("span",{style:{fontSize:27,color:"#8E949B"},children:"今天没有 agent 在跑"})]})})]}),a.jsxs("div",{className:"flex items-center gap-10",children:[a.jsxs("div",{className:"text-right",children:[a.jsx("div",{className:"font-mono tabular-nums leading-none",style:{fontSize:44,color:u>0?"rgb(var(--error-color))":"#3A3F45"},children:String(u).padStart(2,"0")}),a.jsx("div",{className:"mt-2 font-mono uppercase",style:{fontSize:10,letterSpacing:".22em",color:u>0?"rgb(var(--error-color) / .75)":"#3A3F45"},children:"unread"})]}),a.jsxs("div",{className:"text-right",children:[a.jsx("div",{className:"font-mono tabular-nums leading-none",style:{fontSize:44,color:c>0?"rgb(var(--warning-color))":"#3A3F45"},children:String(c).padStart(2,"0")}),a.jsx("div",{className:"mt-2 font-mono uppercase",style:{fontSize:10,letterSpacing:".22em",color:c>0?"rgb(var(--warning-color) / .75)":"#3A3F45"},children:"waiting me"})]}),a.jsx(Tte,{rows:e})]})]}),d]})}function yot({sessions:e,pool:t,deviceNames:n,unreadIds:r,ownerName:s,onExit:i,onPick:o}){const l=not(e,t,n,r),c=Git(l,t);return a.jsx(vot,{rows:l,activity:c,ownerName:s,onExit:i,onPick:o})}const bot=3;function cy({text:e,query:t}){const n=t.trim(),r=n===""?-1:e.toLowerCase().indexOf(n.toLowerCase());return r<0?a.jsx(a.Fragment,{children:e}):a.jsxs(a.Fragment,{children:[e.slice(0,r),a.jsx("span",{className:"text-text-100 font-medium",children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}function Ud({children:e}){return a.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded border border-border text-[11px] text-text-400 bg-bg-100",children:e})}function wot(e){const{query:t,focus:n,groups:r,sessions:s,personas:i,contacts:o,sessionsLoading:l}=e,c=p.useRef(null),u=p.useRef(null);p.useEffect(()=>{var g;(g=c.current)==null||g.focus()},[]),p.useEffect(()=>{var g,x;try{(x=(g=u.current)==null?void 0:g.querySelector('[data-active="true"]'))==null||x.scrollIntoView({block:"nearest"})}catch{}},[n.group,n.row]);const d=g=>{if(!(g.metaKey||g.ctrlKey)){if(g.key==="ArrowDown"||g.key==="ArrowUp"){g.preventDefault(),e.onMoveRow(g.key==="ArrowDown"?1:-1);return}if(g.key==="Enter"){g.preventDefault(),e.onOpenFocused();return}g.key==="Escape"&&(g.preventDefault(),e.onClose())}},h=(g,x)=>({"data-active":n.group===g&&n.row===x,"data-testid":`search-row-${g}-${x}`,onMouseEnter:()=>e.onFocusChange({group:g,row:x}),className:`w-full text-left px-3 py-2 rounded-md cursor-pointer ${n.group===g&&n.row===x?"bg-text-100/10":"hover:bg-text-100/5"}`}),f=(g,x)=>n.group===g&&x<9?a.jsxs(Ud,{children:["⌘",x+1]}):null,m=t.trim()!=="";return a.jsx("div",{"data-testid":"search-overlay",className:"fixed inset-0 z-50 flex items-start justify-center pt-[12vh] bg-black/40 backdrop-blur-sm",onClick:e.onClose,children:a.jsxs("div",{role:"dialog","aria-label":"全局搜索",className:"w-[640px] max-w-[92vw] max-h-[70vh] flex flex-col rounded-xl border border-border bg-elevated shadow-2xl overflow-hidden",onClick:g=>g.stopPropagation(),onKeyDown:d,children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-4 h-14 border-b border-border shrink-0",children:[a.jsx(di,{className:"w-4 h-4 text-text-400 shrink-0"}),a.jsx("input",{ref:c,"data-testid":"search-input",value:t,onChange:g=>e.onQueryChange(g.target.value),placeholder:"搜索会话内容、persona、联系人",className:"flex-1 bg-transparent outline-none text-[14px] text-text-100 placeholder:text-text-400"}),a.jsx(Ud,{children:"esc"})]}),r.length>0&&a.jsxs("div",{"data-testid":"search-tabs",className:"flex items-center gap-1 px-3 py-1.5 border-b border-border shrink-0",children:[r.map(g=>a.jsxs("button",{type:"button","data-testid":`search-tab-${g.key}`,onClick:()=>e.onFocusChange({group:g.key,row:0}),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] ${n.group===g.key?"bg-text-100/10 text-text-100":"text-text-400 hover:text-text-200 hover:bg-text-100/5"}`,children:[g.title,a.jsx("span",{className:n.group===g.key?"text-text-300":"text-text-400/70",children:g.count})]},g.key)),a.jsx("div",{className:"flex-1"}),r.length>1&&a.jsx("span",{className:"text-[11px] text-text-400 pr-1",children:"⌘←→ 切换"})]}),a.jsxs("div",{ref:u,className:"flex-1 min-h-0 overflow-y-auto py-2",children:[!m&&a.jsx("div",{className:"px-4 py-8 text-center text-[13px] text-text-400",children:"输入关键词开始搜索"}),m&&n.group==="session"&&a.jsx("div",{className:"px-2",children:l&&s.length===0?Array.from({length:bot},(g,x)=>a.jsxs("div",{"data-testid":"search-session-skeleton",className:"px-3 py-2",children:[a.jsx("div",{className:"h-3.5 w-1/2 rounded bg-text-100/10 mb-1.5"}),a.jsx("div",{className:"h-3 w-4/5 rounded bg-text-100/5"})]},x)):s.map((g,x)=>a.jsxs("div",{...h("session",x),onClick:()=>e.onSelectSession(g),children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("span",{className:"text-[13px] text-text-100 truncate flex-1",children:a.jsx(cy,{text:g.title,query:t})}),a.jsx("span",{className:"text-[11px] text-text-400 truncate max-w-[160px]",children:g.contextLabel}),f("session",x)]}),g.snippet!==""&&a.jsx("div",{className:"mt-0.5 text-[12px] text-text-400 line-clamp-1",children:a.jsx(cy,{text:g.snippet,query:t})})]},g.sessionId))}),m&&n.group==="persona"&&a.jsx("div",{className:"px-2",children:i.map((g,x)=>a.jsx("div",{...h("persona",x),onClick:()=>e.onSelectPersona(g),children:a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx(oa,{className:"w-4 h-4 text-text-300 shrink-0"}),a.jsx("span",{className:"text-[13px] text-text-100 truncate",children:a.jsx(cy,{text:g.name,query:t})}),a.jsx("span",{className:"text-[11px] text-text-400 truncate",children:g.personaId}),a.jsx("div",{className:"flex-1"}),f("persona",x)]})},g.personaId))}),m&&n.group==="contact"&&a.jsx("div",{className:"px-2",children:o.map((g,x)=>a.jsx("div",{...h("contact",x),onClick:()=>e.onSelectContact(g),children:a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx(xT,{className:"w-4 h-4 text-text-300 shrink-0"}),a.jsx("span",{className:"text-[13px] text-text-100 truncate",children:a.jsx(cy,{text:g.name,query:t})}),a.jsx("div",{className:"flex-1"}),g.deviceCount>1&&a.jsxs("span",{className:"text-[11px] text-text-400",children:[g.deviceCount," 台"]}),f("contact",x)]})},g.deviceId))}),m&&!l&&r.length===0&&a.jsx("div",{"data-testid":"search-empty",className:"px-4 py-8 text-center text-[13px] text-text-400",children:"没有匹配"})]}),a.jsxs("div",{className:"flex items-center gap-3 px-4 h-9 border-t border-border shrink-0 text-[11px] text-text-400",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ud,{children:"↑↓"})," 组内移动"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ud,{children:"⌘←→"})," 切换组"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ud,{children:"⌘1-9"})," 打开当前组第 N 条"]}),a.jsx("div",{className:"flex-1"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Ud,{children:"↵"})," 打开"]})]})]})})}const _ot=250;function Sot(e){const{api:t,query:n,enabled:r}=e,[s,i]=p.useState({query:"",matches:[]}),o=p.useRef(e.candidateIds);o.current=e.candidateIds;const l=p.useRef(t);l.current=t;const c=p.useRef(0),u=n.trim(),d=r&&u!=="",h=s.query===u;return p.useEffect(()=>{if(!d){c.current++;return}const f=++c.current,m=setTimeout(()=>{l.current.searchSessionContent({query:u,sessionIds:o.current}).then(g=>{c.current===f&&i({query:u,matches:g.matches})}).catch(()=>{c.current===f&&i({query:u,matches:[]})})},_ot);return()=>clearTimeout(m)},[u,d]),{matches:d&&h?s.matches:[],loading:d&&!h}}const G1=9,j3=e=>e.trim().toLowerCase(),Y1=(e,t)=>e.toLowerCase().includes(t);function kot(e){const{visible:t}=Qm(e.filter(_3));return[...t].sort((n,r)=>(r.updatedAt??"").localeCompare(n.updatedAt??""))}function Cot(e){const t=j3(e.query);if(t==="")return[];const n=new Map(e.candidates.map(l=>[l.sessionId,l])),r=new Map;for(const l of e.contentMatches)n.has(l.sessionId)&&r.set(l.sessionId,l.snippet);const s=l=>{const c=e.topicByMasterSessionId.get(l.sessionId),u=l.ownerPersonaId?e.personaLabelById.get(l.ownerPersonaId):void 0,d=(c==null?void 0:c.title)??u??l.cwd.split("/").filter(Boolean).pop()??"";return{sessionId:l.sessionId,title:_h(l)||l.sessionId,contextLabel:d,snippet:r.get(l.sessionId)??"",...c?{topicId:c.topicId}:{}}},i=[],o=new Set;for(const l of e.candidates){if(i.length>=G1)return i;Y1(_h(l),t)&&(o.add(l.sessionId),i.push(s(l)))}for(const l of e.contentMatches){if(i.length>=G1)break;if(o.has(l.sessionId))continue;const c=n.get(l.sessionId);c&&(o.add(l.sessionId),i.push(s(c)))}return i}function Not(e,t){const n=j3(t);return n===""?[]:e.filter(r=>Y1(r.personaId,n)||Y1(r.label,n)).slice(0,G1).map(r=>({personaId:r.personaId,name:r.label||r.personaId}))}function jot(e,t){const n=j3(t);if(n==="")return[];const r=[];for(const s of e){if(r.length>=G1)break;if(s.disconnected)continue;const i=s.devices[0];i&&Y1(s.displayName,n)&&r.push({deviceId:i.deviceId,name:s.displayName,deviceCount:s.devices.length})}return r}const Eot=[{key:"session",title:"会话"},{key:"persona",title:"persona"},{key:"contact",title:"联系人"}];function Iot(e){return Eot.filter(({key:t})=>e[t]>0).map(({key:t,title:n})=>({key:t,title:n,count:e[t]}))}function Wd(e,t){switch(t.kind){case"query-changed":return{group:"session",row:0};case"results-changed":return t.sessionsLoading||t.groups.length===0||t.groups.includes(e.group)?e:{group:t.groups[0],row:0};case"move-row":{if(t.rowCount<=0)return e;const n=Math.min(Math.max(e.row+t.delta,0),t.rowCount-1);return n===e.row?e:{...e,row:n}}case"move-group":{if(t.groups.length===0)return e;const n=t.groups.indexOf(e.group),r=n<0?0:n+t.delta,s=Math.min(Math.max(r,0),t.groups.length-1);return{group:t.groups[s],row:0}}case"select-group":return{group:t.group,row:0}}}const Tot=1e3;function Rot(e=Tot){const[t,n]=p.useState(!1);return p.useEffect(()=>{const r=uv()?"Meta":"Control";let s=null;const i=()=>{s!=null&&(clearTimeout(s),s=null),n(!1)},o=c=>{c.key===r&&s==null&&(s=setTimeout(()=>n(!0),e))},l=c=>{c.key===r&&i()};return window.addEventListener("keydown",o,!0),window.addEventListener("keyup",l,!0),window.addEventListener("blur",i),()=>{window.removeEventListener("keydown",o,!0),window.removeEventListener("keyup",l,!0),window.removeEventListener("blur",i),s!=null&&clearTimeout(s)}},[e]),t}function Mot({sessionLabel:e,onConfirm:t,onCancel:n}){return p.useEffect(()=>{const r=s=>{s.isComposing||s.keyCode===229||(s.key==="Enter"?(s.preventDefault(),s.stopPropagation(),t()):s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),n()))};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[t,n]),a.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"archive-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:n,children:a.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-border bg-bg-0 p-4 shadow-xl",onClick:r=>r.stopPropagation(),children:[a.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[a.jsx(Iu,{className:"w-5 h-5 text-text-300 shrink-0 mt-0.5"}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"text-[14px] text-text-100",children:["归档「",a.jsx("span",{className:"font-medium break-all",children:e}),"」?"]}),a.jsx("div",{className:"mt-1 text-[12px] text-text-400",children:"可在 设置 → 已归档的聊天 中随时取消归档"})]})]}),a.jsxs("div",{className:"mt-3 flex items-center justify-end gap-2",children:[a.jsxs("button",{type:"button","data-testid":"archive-confirm-cancel",onClick:n,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:["取消 ",a.jsx("span",{className:"text-text-400/70",children:"Esc"})]}),a.jsxs("button",{type:"button","data-testid":"archive-confirm-ok",onClick:t,className:"h-8 px-3 rounded-md bg-accent text-white text-[12px] font-medium hover:opacity-90 cursor-pointer",children:["归档 ",a.jsx("span",{className:"text-white/70",children:"⏎"})]})]})]})})}const C2={},Pot=2e3,Aot="clawd:sidebar:bulk-archive-hint-dismissed",Oot="clawd:session-info:collapsed",Dot=new Map;function $ot(){const e=dl();return a.jsx(Zxe,{host:e,children:a.jsx(Fot,{host:e})})}function Lot(e,t){if(!e)return null;for(const[n,r]of t){const s=r.find(i=>Q5(i.extId,n)===e);if(s&&s.state.kind==="installed-with-update")return{ownerPrincipalId:n,slug:s.extId,localExtId:e,extName:s.name,fromVersion:s.state.installedVersion,toVersion:s.publishedVersion,snapshotHash:s.publishedHash}}return null}function Fot({host:e}){const t=Xn(),n=p.useMemo(()=>fZ(t),[t]),r=(C2==null?void 0:C2.VITE_APP_VERSION)??"dev";return $et(r),a.jsx(mq,{cache:n.cache,children:a.jsx(fG,{children:a.jsx(Bot,{host:e})})})}function Bot({host:e}){var bP,wP;const t=Xn(),n=ZU(),r=p.useMemo(()=>new Kt(t),[t]),s=Ws(),i=Wet(t),{sessions:o,loaded:l,refresh:c}=qet(i),{capabilities:u}=jo("claude"),d=O_("claude"),{ownerPrincipalId:h,ownerId:f,ownerDisplayName:m}=Oee(t),g=hq(t),x=Fet(t,g.identity!==null),b={loggedIn:g.identity!==null,apiKey:x.apiKey,gatewayUrl:x.gatewayUrl,onRegenerate:x.regenerate,onRevoke:x.revoke,loadError:x.loadError,onReload:x.reload},y=Het(g.identity,f),v={identity:g.identity,loading:g.loading,error:g.error,active:y,onLogin:g.login,onLogout:g.logout},w=p.useMemo(()=>{if(!(!y||!g.deviceId))return frt({deviceId:g.deviceId})},[y,g.deviceId]);Vet(t,e);const _=p.useMemo(()=>h&&m?{principalId:h,displayName:m}:void 0,[h,m]),S=p.useMemo(()=>new mrt(t,_),[t,_]);p.useEffect(()=>()=>S.disposeAll(),[S]);const k=rrt(t),C=k.contacts,{visitors:j}=srt(t,y),T=p.useCallback($=>{var U;return(U=C.find(G=>G.deviceId===$))==null?void 0:U.displayName},[C]),E=p.useMemo(()=>AB(C,j),[C,j]),R=p.useCallback($=>E.get($),[E]),[P,A]=p.useState(!1),[O,F]=p.useState(!1),[z,W]=p.useState(!1),L=irt(t),D=art(t,O),I=n.getActive(),V=(I==null?void 0:I.mode)==="localhost",H=Yxe(),[M,Y]=p.useState(!1),X=lrt(t,y),K=p.useMemo(()=>crt(X.devices,h,new Set(C.map($=>$.deviceId))),[X.devices,h,C]),te=p.useMemo(()=>j.map(drt),[j]),ce=p.useMemo(()=>j.map($=>k3($.visitorId)),[j]),ee=Znt(S,C,h??"",ce),de=p.useMemo(()=>te.filter($=>{var U;return(((U=ee.messagesByPeerDeviceId.get($.deviceId))==null?void 0:U.length)??0)>0}),[te,ee.messagesByPeerDeviceId]),{byOwnerId:be,loadingOwnerIds:se,errorByOwnerId:ae,ensureLoaded:Z}=Qnt(C,S),fe=p.useMemo(()=>({spawnableContacts:ETe(C),ensureRemotePersonas:$=>Z($),remotePersonasByDeviceId:ITe(be)}),[C,Z,be]),{byOwnerId:xe,ensureLoaded:Te,upsertSession:Je,removeSession:ve}=trt(C,S),{byOwnerId:Ne,ensureLoaded:Be,refreshLocal:Re}=Jnt(C,S,t),ze=p.useCallback(async $=>{await Promise.all([ee.ensurePeerLoaded($),Z($),Te($),Be($)])},[ee,Z,Te,Be]),wt=p.useCallback($=>{ze($)},[ze]),St=p.useCallback(async $=>{const U=C.find(at=>at.deviceId===$.ownerPrincipalId);if(!(U!=null&&U.remoteUrl)||!U.connectToken)return{kind:"rolled-back",rolledBackTo:$.fromVersion,reason:"owner offline (no remoteUrl/token)"};const G=S.ensureRemoteForDevice($.ownerPrincipalId,U.remoteUrl,U.connectToken);if(!G)return{kind:"rolled-back",rolledBackTo:$.fromVersion,reason:"owner connection not available"};const{zipBase64:ie}=await G.request("extension.fetchBundle",{extId:$.slug,snapshotHash:$.snapshotHash}),He=await t.request("extension.update-from-channel",{channelRef:{kind:"p2p-tunnel",ownerPrincipalId:$.ownerPrincipalId,extId:$.slug},snapshotHash:$.snapshotHash,zipBase64:ie});return await Re(),He.kind==="updated"?{kind:"updated",installedVersion:He.installedVersion}:{kind:"rolled-back",rolledBackTo:He.rolledBackTo,reason:He.reason}},[C,S,t,Re]),oe=p.useCallback(async($,U,G)=>{const ie=C.find(at=>at.deviceId===$);if(!(ie!=null&&ie.remoteUrl)||!ie.connectToken)return;const He=S.ensureRemoteForDevice($,ie.remoteUrl,ie.connectToken);if(He)try{const{zipBase64:at}=await He.request("extension.fetchBundle",{extId:U,snapshotHash:G});await t.request("extension.install-from-channel",{channelRef:{kind:"p2p-tunnel",ownerPrincipalId:$,extId:U},snapshotHash:G,zipBase64:at}),await Re()}catch(at){Ae("app","install remote extension failed",{ownerPrincipalId:$,extId:U,err:at.message})}},[C,S,t,Re]),[le,me]=p.useState(My),Ke=p.useRef(le);p.useEffect(()=>{Ke.current=le},[le]);const Ge=le.tabs[le.focused]??null,ut=(Ge==null?void 0:Ge.kind)==="session"?Ge.sid:null,tn=(Ge==null?void 0:Ge.kind)==="ext"?Ge.extId:null,qe=p.useRef(!1),Zt=p.useRef(new Set),[Se,Pe]=p.useState(!1),[dt,Pt]=p.useState(null),[hn,we]=p.useState({signal:0,sessionId:null}),ne=p.useCallback($=>{we(U=>({signal:U.signal+1,sessionId:$}))},[]),Oe=p.useRef(!1);p.useEffect(()=>{Oe.current=Se},[Se]);const[it,nt]=p.useState(!1),[kt,At]=p.useState(!1),[zt,sn]=p.useState(null),[$n,Lt]=p.useState(!1),[xn,yn]=p.useState(null),[Sn,Qt]=p.useState(0),[_e,vt]=p.useState(!1),[Ct,Ut]=p.useState(!1),[hr,rr]=p.useState(()=>new Set),[fr,eo]=p.useState(null),[wi,to]=p.useState(!1),[ja,no]=p.useState(!1),ro=ZY(),{personas:Wt,refresh:Oc}=j_();p.useEffect(()=>{Ct&&Oc().catch(()=>{})},[Ct,Oc]);const{projects:qs,reload:ye}=bit(r),[Qe,lt]=p.useState(!1),[Vt,qn]=p.useState(!1),[dd,ap]=p.useState(void 0),gS=p.useCallback($=>{r&&(qn(!0),ap(void 0),r.projectCreate({name:$}).then(async()=>{await ye(),lt(!1)}).catch(U=>ap(U instanceof Error?U.message:String(U))).finally(()=>qn(!1)))},[r,ye]),Lo=p.useMemo(()=>qs.map($=>$.path),[qs]),Ea=p.useCallback($=>{var U;return(U=Wt.find(G=>G.personaId===$))==null?void 0:U.label},[Wt]),[dv,yl]=p.useState(!1),[Dc,hv]=p.useState(!1),[fv,_i]=p.useState(!1),[lp,hd]=p.useState(!1),$c=vrt(),fd=mit(),pv=xit(),mv=yit(),[gv,xS]=p.useState(null);p.useEffect(()=>{},[mv]);const xv=XU(),[pd,md]=p.useState(null),[vv,so]=p.useState(null),gd=p.useRef(null),Fo=p.useCallback($=>{so($),gd.current&&clearTimeout(gd.current),!($.kind==="error"&&$.action||$.kind==="progress")&&(gd.current=setTimeout(()=>so(null),5e3))},[]),Ia=p.useCallback(()=>Fo({kind:"archived"}),[Fo]),{channels:io,loading:yv,create:bv,update:wv,remove:cp,error:up}=bnt(t),{topicsByChannel:Ks,linesByTopic:re,loaded:De,reload:ht}=_nt(r,io,o,t),Ot=p.useMemo(()=>ove(re),[re]),Kn=p.useMemo(()=>{if((Ge==null?void 0:Ge.kind)!=="topic")return null;for(const $ of Object.values(Ks)){const U=$.find(G=>G.id===Ge.topicId);if(U)return U.masterSessionId}return null},[Ge,Ks]),pr=!yv&&De;p.useEffect(()=>{if(qe.current||!l)return;const $=G=>!G||G.tabs.some(He=>He.kind==="session")&&o.length===0?!1:(me(G),qe.current=!0,!0);if($(Cit()))return;let U=!1;return(async()=>{const G=await e.kv.get(GB).catch(ln=>(Ae("view-kv","get failed",ln),null));if(Ae("view-kv","get →",G),U)return;const ie=G&&typeof G=="object"&&"value"in G?G.value:G,He=typeof ie=="string"?Cte(ie):null;if($(He)||!pr)return;const at=Qm(o.filter(yB)).visible.find(ln=>!Ot.has(ln.sessionId));at&&me({tabs:[{kind:"session",sid:at.sessionId}],focused:0}),qe.current=!0})(),()=>{U=!0}},[l,o,e,pr,Ot]),p.useEffect(()=>{if(!qe.current)return;Nit(le);const $=Nte(le);Ae("view-kv","set →",$),e.kv.set(GB,$).catch(U=>{Ae("view-kv","set failed",U)})},[le,e]);const Zr=p.useRef("");p.useEffect(()=>{const $=le.tabs.map(Ag).join(" | ");Zr.current!==""&&$!==Zr.current&&console.log(`[tab-debug] tabs changed
953
953
  prev:`,Zr.current,`
954
954
  next:`,$,`
955
- focused:`,le.focused),Zr.current=$},[le]);const Lc=p.useRef(new Set);p.useEffect(()=>{if(!qe.current)return;const $=U=>{Lc.current.has(U)||C.some(G=>G.deviceId===U)&&(Lc.current.add(U),ze(U))};for(const U of le.tabs)if(U.kind==="dm")$(U.peerDeviceId);else if(U.kind==="session"){const G=o.find(ie=>ie.sessionId===U.sid);G!=null&&G.originOwnerPrincipalId&&$(G.originOwnerPrincipalId)}},[le,C,o,ze]),p.useEffect(()=>{if(!qe.current||o.length===0)return;const $=new Set(o.map(G=>G.sessionId));for(const G of $)Zt.current.add(G);const U=Zt.current;me(G=>{const ie=G.tabs.filter(at=>at.kind!=="session"?!0:!U.has(at.sid)||$.has(at.sid));if(ie.length===G.tabs.length)return G;if(ie.length===0)return My;const He=Math.min(G.focused,ie.length-1);return{tabs:ie,focused:Math.max(0,He)}})},[o]);const{prune:_v}=$c;p.useEffect(()=>{l&&_v(new Set(o.map($=>$.sessionId)))},[l,o,_v]);const Qn=ut?o.find($=>$.sessionId===ut)??null:null,{visible:Fc,archivedRoots:Dte,archivedChildrenByRoot:$te}=p.useMemo(()=>Qm(o.filter(yB)),[o]),I3=p.useMemo(()=>new Map(Fc.map($=>[$.sessionId,lv($)])),[Fc]),T3=p.useCallback($=>I3.get($),[I3]),vS=p.useMemo(()=>Qm(o.filter(_3)).visible,[o]),yS=p.useMemo(()=>vS.filter($=>cS($,h??void 0)).map($=>({sid:$.sessionId,originOwnerPrincipalId:$.originOwnerPrincipalId??null})),[vS,h]),R3=$ee(yS,S),oo=p.useCallback(($,U)=>{const G=$.tabs.findIndex(ie=>ie.kind==="session"&&ie.sid===U);return G>=0?am($,G):$},[]),Lte=p.useSyncExternalStore(p.useCallback($=>S.onOwnersChanged($),[S]),()=>S.listRemoteDeviceIds().sort().join("|"),()=>""),M3=!k.loading;p.useEffect(()=>{if(!M3)return;const $=[];for(const U of le.tabs){if(U.kind!=="session")continue;const G=o.find(ln=>ln.sessionId===U.sid);if(!(G!=null&&G.originOwnerPrincipalId))continue;const ie=G.originOwnerPrincipalId,He=S.getRemoteForDevice(ie)!==null,at=C.some(ln=>ln.deviceId===ie);!He&&!at&&$.push(U.sid)}$.length!==0&&me(U=>{let G=U;for(const ie of $)G=oo(G,ie);return G})},[M3,le,o,C,S,Lte,oo]);const bl=Jet({entries:yS,sessions:vS,activeId:ut??Kn,pool:S}),xd=Lee(yS,S),Si=p.useMemo(()=>{const $=new Set;for(const[U,G]of R3)G==="turn-running"&&$.add(U);return $},[R3]),P3=p.useMemo(()=>{let $=0;for(const U of ee.unreadByPeer.values())$+=U;return $},[ee.unreadByPeer]),bS=p.useMemo(()=>{const $=new Set;for(const[U,G]of ee.unreadByPeer)G>0&&$.add(U);return $},[ee.unreadByPeer]),A3=i.kind==="disconnected"||i.kind==="auth-failed"||i.kind==="version-mismatch"||i.kind==="reconnecting",Fte=i.kind==="connecting"||i.kind==="idle",dp=qU(),vd=dp?$xe(i):null,O3=(vd==null?void 0:vd.kind)==="reopen"&&vd.reason==="expired";p.useEffect(()=>{O3&&(dp==null||dp.invalidate())},[O3,dp]);const Ta=p.useCallback($=>{_i(!1);const U=o.find(ie=>ie.sessionId===$);U!=null&&U.originOwnerPrincipalId&&ze(U.originOwnerPrincipalId);const G=U==null?void 0:U.cwd;G&&!(U!=null&&U.originOwnerPrincipalId)?Promise.all([r.getGitRoot(G),r.getGitBranch(G)]).then(([ie,He])=>{Ae("app","selectSession",{sessionId:$,cwd:G,gitRoot:ie.gitRoot,branch:He.branch})}).catch(ie=>{Ae("app","selectSession git probe failed",{sessionId:$,err:ie})}):Ae("app","selectSession",{sessionId:$,cwd:null}),me(ie=>Es(ie,{kind:"session",sid:$})),Oe.current||ne($)},[o,r,ze,ne]),Bc=p.useCallback(async $=>{const U=await r.sessionCreate(oD($));return await c(),Ta(U.sessionId),{sessionId:U.sessionId}},[r,c,Ta]),wS=p.useCallback(async({personaId:$,text:U,config:G})=>{const ie=zq(U)??"新建 session",{sessionId:He}=await Bc({ownerPersonaId:$,aiLabel:ie,...G.model?{model:G.model}:{},...G.effort?{effort:G.effort}:{}});await r.sessionSubscribe(He),await r.sessionSend(He,U),At(!1),me(at=>{const ln=at.tabs.findIndex(Bo=>Bo.kind==="landing");return ln>=0?am(at,ln):at})},[r,Bc]),Bte=p.useCallback(()=>{r.onboardingComplete().catch(()=>{}),nt(!0),At(!0),me($=>Es($,{kind:"landing"}))},[r]),zte=p.useCallback(async $=>{await Bc({cwd:$})},[Bc]),Hte=p.useCallback(async $=>{const U=await r.sessionCreate(oD({cwd:$}));await c(),me(G=>Es(G,{kind:"session",sid:U.sessionId}))},[r,c]),_S=p.useRef(!1),Ute=p.useCallback(async($,U)=>{const G=mu($.tool);if(G){if(_S.current)return;_S.current=!0,Fo({kind:"progress",text:"正在分叉云会话…"})}try{const ie=await Hq(r,$,U);if(G&&so(null),!ie)return;await c(),me(He=>Es(He,{kind:"session",sid:ie.sessionId}))}catch(ie){if(!G)throw ie;Fo({kind:"error",text:ie instanceof Error?ie.message:String(ie)})}finally{G&&(_S.current=!1)}},[r,c,Fo]),SS=p.useCallback(async $=>{const U=ny(o,$);for(const ie of U)await r.sessionDelete(ie);await r.sessionDelete($);const G=new Set([$,...U]);me(ie=>aO(ie,He=>He.kind==="session"&&G.has(He.sid))),await c()},[r,o,c]),D3=p.useCallback(async($,U)=>{U.label&&(await r.sessionUpdate($,{label:U.label}),await c())},[r,c]),Wte=p.useCallback(async($,U)=>{await r.pinSession($,U),await c()},[r,c]),{width:kS,onDragStart:Vte}=krt(),[wl,$3]=bm(Pnt,!1),[qte,CS]=p.useState(!1),hp=p.useRef(null),yd=p.useCallback(($,U)=>{hp.current&&clearTimeout(hp.current),hp.current=setTimeout(()=>CS($),U)},[]);p.useEffect(()=>()=>{hp.current&&clearTimeout(hp.current)},[]);const L3=Ct||_e,F3=p.useCallback(()=>yd(!0,MB),[yd]),B3=p.useCallback(()=>{L3||yd(!1,g2)},[yd,L3]),an=p.useCallback(()=>{Ut(!1),vt(!1),wl&&yd(!1,g2)},[wl,yd]),Kte=p.useMemo(()=>nve({channels:io,topicsByChannel:Ks,linesByTopic:re,sessions:o,runningSessionIds:Si}),[io,Ks,re,o,Si]),Gte=p.useMemo(()=>rve({channels:io,topicsByChannel:Ks,linesByTopic:re,sessions:o,runningSessionIds:Si}),[io,Ks,re,o,Si]),z3=p.useMemo(()=>ive({linesByTopic:re,sessions:o}),[re,o]),Sv=ut??Kn,NS=p.useMemo(()=>Sv?o.find($=>$.sessionId===Sv)??null:null,[Sv,o]),H3=knt(r,Sv,NS==null?void 0:NS.updatedAt),Yte=p.useMemo(()=>({resolve:Snt({records:H3,selfDeviceId:h??void 0,lineIndex:z3,sessions:o,personas:Wt,contacts:C}),onOpenSession:Ta,...r?{onAnswer:async($,U)=>{await r.a2aAnswer({taskId:$,text:U})}}:{}}),[H3,z3,o,Wt,C,Ta,r]),Xte=p.useMemo(()=>sve({channels:io,topicsByChannel:Ks,linesByTopic:re,sessions:o,runningSessionIds:Si}),[io,Ks,re,o,Si]),fp=p.useMemo(()=>Object.values(Ks).flat(),[Ks]),Zte=p.useCallback($=>{rr(U=>{const G=new Set(U);return G.has($)?G.delete($):G.add($),G})},[]),kv=p.useCallback($=>{me(U=>Es(U,{kind:"topic",topicId:$}))},[]),[Qte,U3]=p.useState(null),[Jte,W3]=p.useState(null),[ene,V3]=p.useState(null),tne=Qte??ene??(fr===null?Jte:null),nne=p.useCallback(async $=>{if(r){U3(null);try{const{topicId:U}=await r.topicCreate({channelId:$});ht(),kv(U)}catch(U){Ae("app","topicCreate failed",{channelId:$,err:String(U)}),U3({channelId:$,message:U instanceof Error?U.message:String(U)})}}},[r,kv,ht]),bd=p.useCallback($=>fp.find(U=>U.id===$)??null,[fp]),q3=p.useCallback($=>{var U;return((U=bd($))==null?void 0:U.channelId)??null},[bd]),_l=p.useCallback(async($,U,G)=>{V3(null);try{await G(),ht()}catch(ie){Ae("app",`${U} failed`,{topicId:$,err:String(ie)});const He=q3($);He&&V3({channelId:He,message:ie instanceof Error?ie.message:String(ie)})}},[q3,ht]),rne=p.useCallback($=>{var G;const U=(G=bd($))==null?void 0:G.masterSessionId;U&&_l($,"topicArchive",()=>r.archiveSession(U,!0))},[r,bd,_l]),sne=p.useCallback($=>{r.archiveSession($,!1).then(()=>c())},[r,c]),ine=p.useCallback(($,U)=>void _l($,"topicRename",()=>r.topicRename({topicId:$,title:U})),[r,_l]),K3=p.useCallback($=>void _l($,"topicDelete",async()=>{const U=await r.topicDelete({topicId:$}),G=new Set([...U.removedMasterSessionId?[U.removedMasterSessionId]:[],...U.removedWorkerSessionIds]);me(ie=>aO(ie,He=>He.kind==="topic"&&He.topicId===$||He.kind==="session"&&G.has(He.sid)))}),[r,_l]),one=p.useCallback(($,U)=>{var ie;const G=(ie=bd($))==null?void 0:ie.masterSessionId;G&&_l($,"topicPin",()=>r.pinSession(G,U))},[r,bd,_l]),ane=p.useCallback(async $=>{W3(null);try{await cp($)}catch(U){W3({channelId:$,message:U instanceof Error?U.message:String(U)})}},[cp]),[Ra,jS]=bm(Oot,!0),[Cv,lne]=bm("clawd:workspace-cards-collapsed",!1),[cne,une]=p.useState(null),pp=!!(Qn&&mu(Qn.tool)&&!Qn.larkChatId),ES=!!(Qn&&!Qn.larkChatId&&(pp?!Cv:Ra)),[dne,hne]=p.useState(null),[IS,fne]=p.useState(null),[G3,Nv]=p.useState(!1),mp=p.useRef(null),{initialSize:Y3,setSize:pne}=Uq("clawd:panel:session-info-px",320),jv=p.useCallback(($,U)=>{mp.current&&clearTimeout(mp.current),mp.current=setTimeout(()=>Nv($),U)},[]),Ev=p.useCallback(()=>jv(!0,MB),[jv]),Iv=p.useCallback(()=>jv(!1,g2),[jv]);p.useEffect(()=>()=>{mp.current&&clearTimeout(mp.current)},[]);const wd=["session","topic"].includes(((bP=le.tabs[le.focused])==null?void 0:bP.kind)??""),mne=wd?Ra?G3?IS:null:dne:null;p.useEffect(()=>{wd||Nv(!1)},[wd]),p.useEffect(()=>{const $=IS;if($)return $.addEventListener("mouseenter",Ev),$.addEventListener("mouseleave",Iv),()=>{$.removeEventListener("mouseenter",Ev),$.removeEventListener("mouseleave",Iv)}},[IS,Ev,Iv]);const TS=Rot(),[RS,gne]=wf(Ltt,"priority"),[xne,vne]=wf(Btt,"archive"),MS=p.useMemo(()=>_it(Fc,{ownerPrincipalId:h??void 0,sortMode:RS,attention:{awaitingIds:xd,runningIds:Si,unreadIds:bl},projectPaths:Lo,topicSessionIds:Ot}).slice(0,9),[Fc,h,RS,xd,Si,bl,Lo,Ot]),yne=p.useMemo(()=>({held:TS,indexBySessionId:new Map(MS.map(($,U)=>[$,U+1]))}),[TS,MS]),[PS,X3]=p.useState(null),Tv=p.useRef(null),_d=p.useRef(null),gp=p.useCallback(()=>{_d.current!=null&&(clearTimeout(_d.current),_d.current=null),Tv.current=null,X3(null)},[]);p.useEffect(()=>gp,[gp]);const Sd=p.useCallback(()=>{const $=Tv.current;if(gp(),$==null)return;me(G=>lO(G,$));const U=Ke.current.tabs[$];(U==null?void 0:U.kind)==="session"&&ne(U.sid)},[gp,ne]),Z3=p.useCallback($=>{const U=Ke.current.tabs.length;if(U===0)return;const ie=((Tv.current??Ke.current.focused)+$+U)%U;Tv.current=ie,X3(ie),_d.current!=null&&clearTimeout(_d.current),_d.current=setTimeout(Sd,Pot)},[Sd]);p.useEffect(()=>{if(PS==null)return;const $=U=>{(U.key==="Meta"||U.key==="Control"||U.key==="Shift")&&Sd()};return window.addEventListener("keyup",$,!0),window.addEventListener("blur",Sd),()=>{window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",Sd)}},[PS,Sd]);const[xp,Rv]=p.useState(!1),[Ma,AS]=p.useState(""),[kd,Sl]=p.useState({group:"session",row:0}),[bne,Q3]=p.useState(null),[wne,OS]=p.useState(null),Mv=p.useMemo(()=>kot(o),[o]),_ne=p.useMemo(()=>Mv.map($=>$.sessionId),[Mv]),{matches:J3,loading:DS}=Sot({api:r,query:Ma,candidateIds:_ne,enabled:xp}),eP=p.useMemo(()=>{const $=new Map(o.map(U=>[U.sessionId,U]));return new Map(fp.map(U=>[U.masterSessionId,{topicId:U.id,title:Vw(U.title,$.get(U.masterSessionId)??null)}]))},[fp,o]),tP=p.useMemo(()=>new Map(Wt.map($=>[$.personaId,$.label])),[Wt]),vp=p.useMemo(()=>Cot({candidates:Mv,query:Ma,contentMatches:J3,topicByMasterSessionId:eP,personaLabelById:tP}),[Mv,Ma,J3,eP,tP]),yp=p.useMemo(()=>Not(Wt,Ma),[Wt,Ma]),bp=p.useMemo(()=>{const $=S3(C,Dot);return jot([...$.pinned,...$.main],Ma)},[C,Ma]),$S=p.useMemo(()=>Iot({session:vp.length,persona:yp.length,contact:bp.length}),[vp.length,yp.length,bp.length]),wp=p.useMemo(()=>$S.map($=>$.key),[$S]),Sne=kd.group==="session"?vp.length:kd.group==="persona"?yp.length:bp.length;p.useEffect(()=>{Sl($=>Wd($,{kind:"query-changed"}))},[Ma]),p.useEffect(()=>{Sl($=>Wd($,{kind:"results-changed",groups:wp,sessionsLoading:DS}))},[wp,DS]);const nP=p.useCallback(()=>{an(),AS(""),Sl({group:"session",row:0}),Rv(!0)},[an]),[LS,Pv]=p.useState(!1),rP=p.useCallback(()=>{an(),Rv(!1),Pv(!0)},[an]),kne=p.useMemo(()=>AB(C.map($=>({deviceId:$.deviceId,displayName:$.displayName})),[]),[C]),sP={"toggle-hive":()=>{if(LS){Pv(!1);return}rP()},"new-session":()=>{an(),Pe(!0)},"open-search":()=>{if(xp){Rv(!1);return}nP()},...xp?{"search-tab-prev":()=>Sl($=>Wd($,{kind:"move-group",delta:-1,groups:wp})),"search-tab-next":()=>Sl($=>Wd($,{kind:"move-group",delta:1,groups:wp}))}:{},...Object.fromEntries(Array.from({length:9},($,U)=>[`switch-session-${U+1}`,()=>{if(xp){fP(U);return}const G=MS[U];G&&(an(),Sp(G))}])),"tab-prev":()=>Z3(-1),"tab-next":()=>Z3(1),...le.tabs.length>0?{"close-tab":()=>me($=>am($,$.focused))}:{},"archive-session":()=>{const $=Ke.current.tabs[Ke.current.focused];if(($==null?void 0:$.kind)!=="session")return;const U=o.find(ie=>ie.sessionId===$.sid);if(!U)return;const G=cv(U);G&&o.some(ie=>ie.sessionId===G)||FS($.sid)}};wtt(LS?{"toggle-hive":sP["toggle-hive"]}:sP);const[Av,FS]=p.useState(null),[iP,Cne,oP]=bm(Aot,!1),aP=p.useRef(!1),[Nne,BS]=p.useState(null);p.useEffect(()=>{if(aP.current||!l||h==null||!oP||(aP.current=!0,iP))return;const $=h2(o,h,10,Lo,Ot).length;$>0&&BS($)},[o,l,h,Lo,Ot,iP,oP]);const zS=p.useCallback(async($,U)=>{if(U){const G=[$,...ny(o,$)];me(ie=>G.reduce((He,at)=>oo(He,at),ie))}await r.archiveSession($,U),await c(),U&&Ia()},[r,c,oo,o,Ia]),jne=p.useCallback(async $=>{await r.reorderPins($),await c()},[r,c]),HS=p.useCallback($=>{_i(!1),sn({kind:"config",personaId:$})},[]),Ene=p.useCallback($=>{an(),me(U=>Es(U,{kind:"deploy",personaId:$}))},[an]),Ine=p.useCallback(($,U)=>{an(),me(G=>Es(G,{kind:"deploy-history",personaId:$,head:U}))},[an]),Tne=p.useCallback(async $=>{var G;const U=((G=Wt.find(ie=>ie.personaId===$))==null?void 0:G.label)??$;confirm(`删除 persona "${U}"?`)&&(await ro($),sn(ie=>(ie==null?void 0:ie.personaId)===$?null:ie))},[ro,Wt]),Rne=p.useCallback(async($,U)=>{_i(!1),sn(null);const G={ownerPersonaId:$},ie=U.trim();ie&&(G.label=ie);try{const He=await r.sessionCreate(G);await c(),Ta(He.sessionId)}catch(He){Ae("persona","sessionCreate(ownerPersonaId) failed",He)}},[r,c,Ta,Wt]),Mne=p.useCallback(async($,U,G)=>{try{const{sessionId:ie}=await Bc({ownerPersonaId:$,label:G});await r.sessionSubscribe(ie),await r.sessionSend(ie,U)}catch(ie){throw Ae("pr-inbox","open chat failed",ie),ie}},[r,Bc]),kl=p.useCallback(async($,U)=>{const G=SI(U,$);try{await r.peerSessionUpsert(G)}catch(ie){Ae("mirror","peerSession:upsert failed",G.sessionId,ie)}s.setData("sessions",ie=>{const He=[...ie??[]],at=He.findIndex(ln=>ln.sessionId===G.sessionId);return at>=0?He[at]=G:He.unshift(G),He})},[r,s]),Ov=p.useCallback(async $=>{try{await r.peerSessionRemove($)}catch(U){Ae("mirror","peerSession:remove failed",$,U)}s.setData("sessions",U=>(U??[]).filter(G=>G.sessionId!==$))},[r,s]),Pne=p.useCallback(async($,U,G)=>{await ze($);const ie=S.getRemoteForDevice($);if(!ie)throw new Error("remote daemon unreachable");const He=new Kt(ie),at={ownerPersonaId:U},ln=G.trim();ln&&(at.label=ln);try{const Bo=await He.sessionCreate(at),Lv=Bo;Je($,Lv),me(kp=>Es(kp,{kind:"session",sid:Bo.sessionId})),kl($,Lv).catch(kp=>{Ae("persona","upsertMirrorLocally (remote create) failed",kp)})}catch(Bo){Ae("persona","sessionCreate(remote) failed",{ownerId:$,personaId:U,err:Bo})}},[S,be,ze,Je,kl]),Cl=p.useCallback($=>{const U=S.getRemoteForDevice($);if(U)return U;const G=C.find(ie=>ie.deviceId===$);return!(G!=null&&G.remoteUrl)||!G.connectToken?null:S.ensureRemoteForDevice($,G.remoteUrl,G.connectToken)},[S,C]),ao=p.useCallback(($,U,G,ie)=>{Fo({kind:"error",text:iit(T($),U,G),...ie?{action:ie}:{}})},[Fo,T]),US=p.useCallback(async($,U)=>{const G=async()=>{ve($,U),me(at=>oo(at,U)),await Ov(U)},ie=Cl($);if(!ie){await G();return}const He=new Kt(ie);try{await He.sessionDelete(U),G().catch(at=>{Ae("persona","removeMirrorLocally (remote delete) failed",at)})}catch(at){Ae("persona","sessionDelete(remote) failed",at),ao($,"删除",at,{label:"只从我这儿移除",onClick:()=>{so(null),G().catch(ln=>{Ae("persona","removeMirrorLocally (drop from my side) failed",ln)})}})}},[Cl,ao,ve,Ov,oo]),Ane=p.useCallback(async($,U,G)=>{const ie=G?"置顶":"取消置顶",He=Cl($);if(!He){ao($,ie,null);return}const at=new Kt(He);try{const ln=await at.pinSession(U,G);await kl($,ln),so(null)}catch(ln){Ae("persona","pinSession(remote) failed",ln),ao($,ie,ln)}},[Cl,ao,kl]),_p=p.useCallback(async($,U,G)=>{const ie=G?"归档":"取消归档",He=Cl($);if(!He)return ao($,ie,null),!1;const at=new Kt(He);try{if(G){const Bo=[U,...ny(o,U)];me(Lv=>Bo.reduce((kp,Xne)=>oo(kp,Xne),Lv))}const ln=await at.archiveSession(U,G);return await kl($,ln),G&&Ia(),!0}catch(ln){return Ae("persona","archiveSession(remote) failed",ln),ao($,ie,ln),!1}},[Cl,ao,kl,oo,o,Ia]),One=p.useCallback(async $=>{const U=h2(o,h??void 0,$,Lo,Ot);let G=0;for(const ie of U){if(ie.originOwnerPrincipalId){await _p(ie.originOwnerPrincipalId,ie.sessionId,!0)||(G+=1);continue}const He=[ie.sessionId,...ny(o,ie.sessionId)];me(at=>He.reduce((ln,Bo)=>oo(ln,Bo),at));try{await r.archiveSession(ie.sessionId,!0)}catch(at){Ae("persona","bulkArchive: archiveSession failed",at),G+=1}}await c(),BS(null),U.length>0&&G===0&&Ia()},[o,h,Lo,Ot,r,c,oo,_p,Ia]),Dne=p.useCallback($=>h2(o,h??void 0,$,Lo,Ot).length>0,[o,h,Lo,Ot]),lP=p.useCallback(async($,U,G)=>{if(!G.label)return;const ie=Cl($);if(!ie){ao($,"改名",null);return}const He=new Kt(ie);try{const at=await He.sessionUpdate(U,{label:G.label});await kl($,at),so(null)}catch(at){Ae("persona","sessionUpdate(remote) failed",at),ao($,"改名",at)}},[Cl,ao,kl]),cP=p.useCallback(()=>{_i(!1),yn(null),Lt(!0)},[]),$ne=p.useCallback(async $=>{no(!0),yn(null);try{await wS({personaId:ei,text:Ort($),config:{model:"",effort:"",permissionMode:""}}),Lt(!1),Qt(U=>U+1),an()}catch(U){yn(U.message??String(U))}finally{no(!1)}},[wS,an]),Lne=p.useCallback(async()=>{const $=n.getActive();$&&await n.activate($.id)},[n]),Sp=p.useCallback($=>{sn(null),Ta($)},[Ta]),Dv=()=>{Rv(!1),AS("")},uP=$=>{if(Dv(),$.topicId!==void 0){kv($.topicId);return}Sp($.sessionId)},dP=$=>{Dv(),Q3($),vt(!1),Ut(!0)},Pa=Mnt(),Fne=p.useMemo(()=>{const $=new Map(C.map(U=>[U.deviceId,U]));return Pa.favorites.flatMap(U=>{var He;const G=U.deviceId?$.get(U.deviceId):void 0;if(!U.deviceId||!G)return[];const ie=(He=be.get(U.deviceId))==null?void 0:He.find(at=>at.personaId===U.personaId);return[{deviceId:U.deviceId,personaId:U.personaId,label:(ie==null?void 0:ie.label)??U.label??U.personaId,tool:(ie==null?void 0:ie.tool)??U.tool,contactName:G.displayName||G.deviceId}]})},[Pa.favorites,C,be]),Bne=$=>{OS($),Ut(!1),vt(!0),ze($)},hP=$=>{Dv(),OS($),Ut(!1),vt(!0),ze($)},fP=$=>{if(kd.group==="session"){const G=vp[$];G&&uP(G);return}if(kd.group==="persona"){const G=yp[$];G&&dP(G.personaId);return}const U=bp[$];U&&hP(U.deviceId)},pP=A3||Dc;if(pP&&vd)return a.jsx(KU,{view:vd});if(pP)return a.jsx(Tst,{state:i,onClose:A3?void 0:()=>hv(!1),remoteHosts:H});if(Fte||!l)return a.jsx("div",{"data-testid":"app-bootstrapping",className:"h-screen flex items-center justify-center bg-bg-0",children:a.jsx(st,{className:"w-5 h-5 text-text-400 animate-spin"})});if(i.kind==="connected"&&i.mode!=="remote"&&i.onboardingCompletedAt===null&&!it)return a.jsx(ost,{api:r,feishuIdentity:g.identity,feishuError:g.error,onFeishuLogin:g.login,personas:Wt.map($=>({personaId:$.personaId,label:$.label})),onFinished:Bte});const zne=(Qn==null?void 0:Qn.label)||(Qn==null?void 0:Qn.aiLabel)||(Qn!=null&&Qn.cwd?Qn.cwd.split("/").filter(Boolean).pop()??"Clawd":"Clawd"),mP=wl?nu+kS:kS,gP=wl?x2:0,xP=wl?nu:0,$v=(wP=le.tabs[le.focused])==null?void 0:wP.kind,Hne=_e?"people":Ct?"persona":$v==="exts"||$v==="shift"||$v==="prs"?$v:null,Une=$=>{if(_i(!1),$==="people"){OS(null),Ut(!1),vt(G=>!G);return}if($==="persona"){Q3(null),vt(!1),Ut(G=>!G);return}if(an(),$==="new"){me(G=>Es(G,{kind:"landing"}));return}const U=$==="shift"?{kind:"shift"}:$==="prs"?{kind:"prs"}:{kind:"exts"};me(G=>Es(G,U))},Wne=a.jsxs(a.Fragment,{children:[H,a.jsx(fit,{identity:g.identity,loading:g.loading,error:g.error,onLogin:g.login}),a.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx(dit,{onClick:()=>md("about")})}),a.jsx(hit,{})]})]}),Vne=a.jsx(rb.Provider,{value:$c,children:a.jsx(vnt,{client:t,open:_e,initialSelectedId:wne,onClose:an,sidebarWidth:mP,insetTop:gP,insetBottom:xP,contacts:C,publicDevices:K,onConnectPublicDevice:async $=>{await X.connect($)},remoteGated:!y,onAddContact:()=>A(!0),visitors:de,visitorUnreadIds:bS,unreadDeviceIds:bS,isRemotePersonaFavorite:Pa.isFavorite,onToggleRemotePersonaFavorite:($,U)=>Pa.toggleFavorite({personaId:U.personaId,deviceId:$,label:U.label,tool:U.tool}),onOpenVisitor:$=>{an(),me(U=>Es(U,{kind:"dm",peerDeviceId:$}))},loginCardNode:a.jsx(gB,{...v}),onEnsureContactLoaded:wt,personasByOwnerId:be,personaLoadingOwnerIds:se,personaErrorByOwnerId:ae,onRetryPersonas:wt,onReconnectContact:async $=>{await X.connect({deviceId:$.deviceId,url:$.remoteUrl||void 0})},sessionsByOwnerId:xe,extensionsByOwnerId:Ne,activeSessionId:zt?null:ut,awaitingIds:xd,runningIds:Si,unreadIds:bl,onMessage:$=>{an(),ze($),me(U=>Es(U,{kind:"dm",peerDeviceId:$}))},onPinContact:($,U)=>void k.pin($,U),onSetContactRemoteAccess:($,U)=>k.setRemoteAccess($.deviceId,{remoteAccessAllowed:U}),onSetContactNote:($,U)=>void k.setNote($,U),onRemoveContact:$=>{const U=$.deviceId;for(const G of o)G.originOwnerPrincipalId===U&&Ov(G.sessionId);k.remove(U)},onCreateRemoteSession:($,U)=>(an(),Pne($,U,"")),onSelectSession:$=>{an(),Ta($)},onDeleteRemoteSession:($,U)=>void US($,U),onEditRemoteSession:($,U,G)=>void lP($,U,G),onInstallExtension:($,U,G)=>{G&&oe($,U,G)},onOpenInstalledExtension:($,U)=>{an(),me(G=>Es(G,{kind:"ext",extId:Q5(U,$)}))}})}),qne=a.jsx("div",{className:"h-full w-full overflow-y-auto bg-bg-100",children:a.jsx("div",{className:"max-w-[480px] h-full border-r border-border",children:a.jsx(qnt,{client:t,activeExtId:tn,onOpenInMain:$=>me(U=>Es(U,{kind:"ext",extId:$})),onExtensionsMutated:()=>void Re()})})}),Kne=fr?a.jsx(ynt,{open:!0,submitting:wi,mode:fr.mode,...fr.mode==="edit"?(()=>{const $=io.find(U=>U.id===fr.channelId);return $?{initial:{name:$.name,memberPersonas:[...$.memberPersonas],memberContactDeviceIds:[...$.memberContactDeviceIds]}}:{}})():{},personas:Wt.map($=>({id:$.personaId,label:$.label||$.personaId})),contactGroups:C.map($=>{const U=be.get($.deviceId),G=ae.get($.deviceId);return{deviceId:$.deviceId,displayName:$.displayName,...U?{personas:U.map(ie=>({id:ie.personaId,label:ie.label||ie.personaId}))}:{},...se.has($.deviceId)?{loading:!0}:{},...G?{errorText:G}:{},...zf($)?{}:{brokenLink:!0}}}),onExpandContact:$=>void Z($),...up?{error:up}:{},onCancel:()=>eo(null),onSubmit:$=>{const U=()=>{to(!1),eo(null)},G=()=>to(!1);to(!0),fr.mode==="create"?bv($).then(U).catch(G):wv({channelId:fr.channelId,...$}).then(U).catch(G)}}):null,Gne=a.jsx(rb.Provider,{value:$c,children:a.jsx(Ent,{open:Ct,initialSelectedId:bne,onClose:an,sidebarWidth:mP,insetTop:gP,insetBottom:xP,personas:Wt,sessions:Fc,activeSessionId:zt?null:ut,awaitingIds:xd,runningIds:Si,unreadIds:bl,ownerPrincipalId:h??void 0,getCreatorDisplayName:R,getSessionDisplayName:T3,onNewPersona:cP,onCreateSession:$=>{an(),Rne($,"")},onOpenPersonaSettings:$=>{an(),HS($)},onDeployPersona:Ene,renderDeployStatus:$=>{var U;return a.jsx(xst,{personaId:$,tool:(U=Wt.find(G=>G.personaId===$))==null?void 0:U.tool})},renderDeployHistory:$=>{var U;return a.jsx(yst,{personaId:$,tool:(U=Wt.find(G=>G.personaId===$))==null?void 0:U.tool,onOpenRelease:G=>Ine($,G)})},renderCloudConnectors:($,U)=>a.jsx(Sst,{personaId:$,render:U}),renderCloudApiKey:$=>a.jsx(mB,{...b,personaId:$}),renderCloudLarkBot:$=>a.jsx(pst,{personaId:$}),favorites:{isFavorite:$=>Pa.isFavorite($),onToggle:$=>Pa.toggleFavorite({personaId:$.personaId}),filter:Pa.filter,onFilterChange:Pa.setFilter,contactFavorites:Fne,onToggleContact:$=>Pa.toggleFavorite({personaId:$.personaId,deviceId:$.deviceId}),onOpenContact:Bne},onDeletePersona:$=>void Tne($),renderSettings:$=>a.jsx(fst,{personaId:$,onOpenMore:()=>{an(),HS($)},onOpenLarkBot:()=>{an(),HS($)}}),onSelectSession:$=>{an(),Sp($)},onEditSession:($,U)=>void D3($,U),onDeleteSession:$=>void SS($)})}),vP=$=>a.jsx(rb.Provider,{value:$c,children:a.jsx(Utt,{channelTree:Kte,expandedTopicIds:hr,onToggleTopic:Zte,onSelectTopic:U=>{_i(!1),an(),kv(U)},onCreateChannel:()=>eo({mode:"create"}),onCreateTopic:U=>void nne(U),onEditChannel:U=>eo({mode:"edit",channelId:U}),onDeleteChannel:U=>void ane(U),onArchiveTopic:rne,onRenameTopic:ine,onDeleteTopic:K3,onPinTopic:one,pinnedTopics:Gte,channelError:tne,topicSessionIds:Ot,floating:$,width:kS,onResizeStart:Vte,projects:qs,onNewInProject:U=>{Pt(U),Pe(!0)},onRefreshProjects:()=>void ye(),onCreateProject:()=>{ap(void 0),lt(!0)},onPatchProject:(U,G)=>{r==null||r.projectPatch({path:U,...G}).then(()=>ye()).catch(ie=>Ae("app","projectPatch failed",{path:U,err:String(ie)}))},onRevealProject:U=>{r==null||r.projectReveal(U).catch(G=>Ae("app","projectReveal failed",{path:U,err:String(G)}))},getPersonaDisplayName:Ea,sessions:Fc,activeId:zt?null:ut??Kn,awaitingIds:xd,runningIds:Si,unreadIds:bl,onSelect:U=>{_i(!1),an(),Sp(U)},onEdit:(U,G)=>{const ie=o.find(at=>at.sessionId===U),He=ie==null?void 0:ie.originOwnerPrincipalId;He?lP(He,U,G):D3(U,G)},onDelete:U=>{const G=o.find(He=>He.sessionId===U),ie=G==null?void 0:G.originOwnerPrincipalId;ie?US(ie,U):SS(U)},onPin:(U,G)=>{const ie=o.find(at=>at.sessionId===U),He=ie==null?void 0:ie.originOwnerPrincipalId;He?Ane(He,U,G):Wte(U,G)},sortMode:RS,onChangeSortMode:gne,quickAction:xne,onChangeQuickAction:vne,bulkArchiveHintCount:Nne,onDismissBulkHint:()=>{BS(null),Cne(!0)},onBulkArchive:U=>void One(U),bulkArchiveAvailable:Dne,onArchive:(U,G)=>{const ie=o.find(at=>at.sessionId===U),He=ie==null?void 0:ie.originOwnerPrincipalId;He?_p(He,U,G):zS(U,G)},onReorderPins:U=>void jne(U),ownerPrincipalId:h??void 0,getContactDisplayName:T,getCreatorDisplayName:R,getSessionDisplayName:T3,onNewPersona:cP,onCollapse:()=>{$3(!0),CS(!1),an()},onOpenHive:rP,onOpenSearch:nP,onFixedEntryClick:Une,activeEntry:Hne,peopleUnreadCount:P3,footer:a.jsx("div",{className:"flex flex-col px-2 py-2",children:Wne})})}),yP=vP(!1),Yne=vP(!0);return a.jsx(Pst,{api:fd,children:a.jsx(rTe,{value:hn,children:a.jsx(Vee.Provider,{value:yne,children:a.jsx(tX.Provider,{value:Yte,children:a.jsxs("div",{className:"h-screen flex flex-col bg-bg-100 text-text-100","data-testid":"app-root",children:[LS&&a.jsx("div",{className:"fixed inset-0 z-50","data-testid":"hive-overlay",children:a.jsx(yot,{sessions:Fc,pool:S,deviceNames:kne,unreadIds:bl,ownerName:m??"me",onExit:()=>Pv(!1),onPick:$=>{Pv(!1),an(),Sp($)}})}),a.jsx(Nrt,{state:i,onRetryNow:Lne}),H,a.jsxs("div",{className:"md:hidden flex items-center gap-2 h-11 px-2 border-b border-border shrink-0",style:{paddingTop:"env(safe-area-inset-top)",minHeight:"calc(2.75rem + env(safe-area-inset-top))"},"data-testid":"app-mobile-topbar",children:[a.jsx("button",{type:"button",onClick:()=>_i(!0),className:"flex items-center justify-center w-9 h-9 rounded-md text-text-300 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"Open sessions","data-testid":"app-mobile-nav-trigger",children:a.jsx(Kfe,{className:"w-5 h-5"})}),a.jsx("div",{className:"flex-1 truncate text-sm font-medium text-text-200",children:zne})]}),a.jsxs("div",{className:"relative flex-1 flex min-h-0",children:[!wl&&a.jsx("aside",{className:"hidden md:flex shrink-0 flex-row","data-testid":"app-sidebar",children:yP}),wl&&a.jsxs("div",{className:"hidden md:block",children:[a.jsx(Ont,{hasUnread:P3>0||bl.size>0,onExpand:()=>{$3(!1),CS(!1)},onMouseEnter:F3,onMouseLeave:B3}),qte&&a.jsx("div",{"data-testid":"sidebar-float-layer",className:"absolute z-40 shadow-2xl rounded-xl bg-bg-100",style:{left:nu,top:x2,bottom:nu},onMouseEnter:F3,onMouseLeave:B3,children:Yne})]}),a.jsx(prt,{open:P,onClose:()=>A(!1),connect:X.connect,myDeviceLink:w,onLogin:g.login}),a.jsx(Pit,{open:O,onClose:()=>F(!1),tunnelUrl:L,token:I==null?void 0:I.token,connections:D,onOpenRemoteHosts:void 0}),z&&a.jsx(Ait,{api:r,onClose:()=>W(!1)}),Kne,a.jsx(wit,{open:Qe,submitting:Vt,error:dd,onSubmit:gS,onCancel:()=>lt(!1)}),a.jsx(Ry,{open:fv,onOpenChange:_i,children:a.jsxs(Om,{side:"left",hideBuiltInClose:!0,className:"md:hidden p-0 w-[288px]","data-testid":"app-mobile-nav-drawer","aria-describedby":void 0,children:[a.jsx(Dm,{className:"sr-only",children:"Sessions"}),a.jsx("div",{className:"flex flex-col h-full",children:yP})]})}),a.jsxs(c_,{orientation:"horizontal",className:`flex-1 flex min-w-0${wl?" md:pl-10":""}${pp?" md:[&_.chrome-tab-strip]:pr-20":ES?" md:[&:has(+aside:not(:empty))_[data-cc-chat-root]]:pr-[316px]":wd&&Ra?" md:pr-10":""}`,children:[a.jsx(Jh,{id:"main",children:a.jsx("main",{className:`flex-1 flex min-w-0 flex-col md:flex-row h-full${pp&&!Cv&&Ra?" md:[&_[data-cc-chat-root]]:pr-[316px]":""}`,"data-testid":"app-main",children:a.jsx(LG,{container:mne,workspaceContainer:ES?cne:null,...Ra?{}:{onCollapse:()=>jS(!0)},children:a.jsx(NTe,{value:fe,children:a.jsx(Det,{view:le,sessions:o,topics:fp,contacts:C,visitorContacts:te,remoteSessionsByOwnerId:xe,clientPool:S,client:t,im:ee,api:r,myOwnerPrincipalId:h??"",myOwnerDisplayName:m??"我",cloud:{apiKey:x.apiKey,gatewayUrl:x.gatewayUrl},onFocusTab:$=>{gp(),me(G=>lO(G,$));const U=le.tabs[$];(U==null?void 0:U.kind)==="session"&&ne(U.sid)},onCloseTab:$=>me(U=>am(U,$)),onCloseOtherTabs:$=>me(U=>cve(U,$)),onCloseAllTabs:()=>me(My),onReorderTab:($,U)=>{console.log("[tab-debug] onReorderTab dispatch",{from:$,to:U}),me(G=>uve(G,$,U))},onSelectCwdForNew:zte,onNewSession:Hte,onOpenPrChat:Mne,onFork:Ute,onOpenMobileConfig:()=>yl(!0),onMirrorOrphan:($,U)=>{Ov($),Ae("mirror","orphan auto-cleanup",{sessionId:$,ownerId:U}),me(G=>oo(G,$))},extensionUpdateInfo:Lot(tn,Ne),onApplyExtensionUpdate:St,awaitingIds:xd,runningIds:Si,unreadIds:bl,unreadDmPeerDeviceIds:bS,pendingTabIndex:PS,extensionsListNode:qne,landingNode:a.jsx(Hrt,{firstRun:kt,personas:Wt.filter($=>$.personaId!==Fi).map($=>({personaId:$.personaId,name:$.label,tool:$.tool,...$.cloud?{cloud:!0}:{}})),initialPersonaId:ei,api:r,modelList:d,modes:(u==null?void 0:u.permissionModes)??[],configSchema:(u==null?void 0:u.configSchema)??[],defaultsByPersonaId:Object.fromEntries(Wt.map($=>[$.personaId,{...$.model?{model:$.model}:{},...$.effort?{effort:$.effort}:{}}])),onCreate:$=>void wS($)})})})})})}),wd&&!Ra?a.jsxs(a.Fragment,{children:[a.jsx(xR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),a.jsx(Jh,{id:"session-info",defaultSize:`${Y3}px`,minSize:"280px",maxSize:"480px",onResize:$=>pne($.inPixels),children:a.jsx("div",{ref:hne,"data-testid":"session-info-column",className:"hidden md:flex h-full min-w-0 flex-col"})})]}):null]}),ES&&a.jsx("aside",{ref:une,"aria-label":"工作区卡片",className:"absolute right-0 top-10 z-30 hidden max-h-[calc(100%-2.5rem)] w-[316px] overflow-y-auto p-2 md:flex md:flex-col md:gap-3 md:empty:hidden"}),pp&&a.jsxs("div",{className:"absolute right-2 top-2 z-50 hidden items-center gap-1 rounded-md bg-bg-100 md:flex",children:[a.jsx("button",{"aria-label":"显示或隐藏工作区卡片",title:"工作区卡片","aria-pressed":!Cv,onClick:()=>lne(!Cv),className:"rounded-md p-1.5 text-text-300 hover:bg-text-100/10",children:a.jsx(Afe,{className:"h-4 w-4"})}),a.jsx("button",{"aria-label":"切换会话侧栏",title:"会话侧栏","aria-pressed":!Ra,onClick:()=>{jS(!Ra),Nv(!1)},className:"rounded-md p-1.5 text-text-300 hover:bg-text-100/10",children:a.jsx(Kb,{className:"h-4 w-4"})})]}),wd&&Ra&&!pp&&a.jsxs("div",{className:"hidden md:block",children:[a.jsx(Dnt,{onExpand:()=>{jS(!1),Nv(!1)},onMouseEnter:Ev,onMouseLeave:Iv}),G3&&a.jsx("div",{"data-testid":"session-info-float",className:"absolute z-40 shadow-2xl rounded-xl overflow-hidden",style:{right:nu,top:x2,bottom:nu,width:Y3},ref:fne})]}),Vne,Gne,xp&&a.jsx(wot,{query:Ma,onQueryChange:AS,sessionsLoading:DS,sessions:vp,personas:yp,contacts:bp,groups:$S,focus:kd,onFocusChange:Sl,onMoveRow:$=>Sl(U=>Wd(U,{kind:"move-row",delta:$,rowCount:Sne})),onMoveGroup:$=>Sl(U=>Wd(U,{kind:"move-group",delta:$,groups:wp})),onOpenFocused:()=>fP(kd.row),onSelectSession:uP,onSelectPersona:$=>dP($.personaId),onSelectContact:$=>hP($.deviceId),onClose:Dv}),fd,a.jsx(Lst,{open:TS}),Av?a.jsx(Mot,{sessionLabel:(()=>{const $=o.find(U=>U.sessionId===Av);return($==null?void 0:$.label)||($==null?void 0:$.aiLabel)||($==null?void 0:$.larkChatName)||($==null?void 0:$.larkChatId)||($==null?void 0:$.cwd)||Av.slice(0,8)})(),onConfirm:()=>{const $=Av;FS(null);const U=o.find(G=>G.sessionId===$);U&&(U.originOwnerPrincipalId?_p(U.originOwnerPrincipalId,$,!0):zS($,!0))},onCancel:()=>FS(null)}):null,a.jsx(rit,{toast:vv,onOpenArchived:()=>{so(null),md("archived")},onClose:()=>so(null)}),pd&&a.jsx(Wst,{initialNav:pd,onBack:()=>md(null),api:fd,ownerPrincipalId:h,daemonScanApi:pv,daemonVersion:i.kind==="connected"?i.daemonVersion:null,daemonSource:i.kind==="connected"?i.daemonSource:null,globalCliVersion:i.kind==="connected"?i.globalCliVersion:null,ccMode:gv,effectiveCcMode:xv,onChangeCcMode:void 0,onAddMobile:V?()=>F(!0):void 0,onImportExternalSessions:i.kind==="connected"&&i.mode!=="remote"?()=>W(!0):void 0,feishuSlot:a.jsx(gB,{variant:"settings",...v}),cloudApiKeySlot:a.jsx(mB,{...b}),githubSlot:a.jsx(xI,{}),channelsSlot:a.jsx(nit,{}),engineSlot:a.jsx(Jst,{}),dashboardSlot:a.jsx(zet,{tunnelReady:!!L,onOpen:$=>y_e(async()=>(await r.dashboardOpenUrl($)).url)}),archivedTopicsSlot:a.jsx(uit,{groups:Xte,onUnarchive:sne,onDelete:K3}),archivedSlot:a.jsx(lit,{sessions:Dte,childrenByRoot:$te,personaLabelOf:$=>{var U;return(U=Wt.find(G=>G.personaId===$))==null?void 0:U.label},contactNameOf:$=>T($),onUnarchive:$=>{const U=o.find(ie=>ie.sessionId===$),G=U==null?void 0:U.originOwnerPrincipalId;G?_p(G,$,!1):zS($,!1)},onDelete:$=>{const U=o.find(ie=>ie.sessionId===$),G=U==null?void 0:U.originOwnerPrincipalId;G?US(G,$):SS($)}})},pd),Qn?a.jsx(Ry,{open:dv,onOpenChange:yl,children:a.jsxs(Om,{side:"right",className:"md:hidden p-0 w-[320px] max-w-[85vw]","data-testid":"app-mobile-config-drawer","aria-describedby":void 0,children:[a.jsx(Dm,{className:"sr-only",children:"Session Info"}),a.jsx(Rst,{open:dv,onOpenChange:yl,session:Qn,embedded:!0})]})}):null,(zt==null?void 0:zt.kind)==="config"&&a.jsx(Ry,{open:!0,onOpenChange:$=>{$||lp&&!window.confirm("修改未保存,确定关闭?")||(sn(null),hd(!1))},children:a.jsxs(Om,{side:"right",className:"p-0 w-[420px] max-w-[90vw]","data-testid":"app-persona-config-drawer","aria-describedby":void 0,hideBuiltInClose:!0,children:[a.jsx(Dm,{className:"sr-only",children:"Persona 设置"}),a.jsx(eX,{personaId:zt.personaId,open:!0,onClose:()=>{lp&&!window.confirm("修改未保存,确定关闭?")||(sn(null),hd(!1))},api:r,embedded:!0,onDirtyChange:hd},zt.personaId)]})})]}),a.jsx(Drt,{open:Se,onOpenChange:$=>{Pe($),$||Pt(null),!$&&ut&&ne(ut)},onCreate:Bc,api:r,projects:qs,presetProject:dt,onProjectsChanged:()=>void ye()}),a.jsx(lst,{open:$n,onOpenChange:$=>{Lt($),$||yn(null)},onCreate:$ne,loadRepos:($,U)=>r.githubRepos({page:$,search:U}),githubLink:$=>a.jsx(xI,{compact:!0,onAuthorized:$}),submitting:ja,submitError:xn},Sn)]})})})})})}const Mte="(prefers-color-scheme: dark)",zot=["light","dark","system"],Pte="clawd-standalone:theme-source",Hot="light",Uot={colorPrimary:"#1677ff",colorBgContainer:"#fff",colorText:"#000",colorBorder:"#d9d9d9"};function Wot(){try{const e=localStorage.getItem(Pte);if(e!==null&&zot.includes(e))return e}catch{}return Hot}function Vot(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Mte).matches}function JB(e){return{mode:e==="dark"||e==="system"&&Vot()?"dark":"light",...Uot}}function qot(e){let t=Wot();const n=new Set,r=()=>{const i=JB(t);for(const o of n)o(i)};typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Mte).addEventListener("change",()=>{t==="system"&&r()});const s={gateway:{call:()=>Promise.reject(new Error("standalone-host: gateway.call not supported"))},self:{call:()=>Promise.reject(new Error("standalone-host: self.call removed; use useDaemonClient()"))},kv:{get:async i=>{const o=localStorage.getItem(`clawd-standalone:kv:${i}`);if(o==null)return null;try{return JSON.parse(o)}catch{return null}},set:async(i,o)=>{localStorage.setItem(`clawd-standalone:kv:${i}`,JSON.stringify(o))}},logger:{info:(i,o)=>{var l;console.info("[ext]",i,o??""),(l=e.logClient)==null||l.push({level:"info",msg:String(i),meta:o})},warn:(i,o)=>{var l;console.warn("[ext]",i,o??""),(l=e.logClient)==null||l.push({level:"warn",msg:String(i),meta:o})},error:(i,o)=>{var l;console.error("[ext]",i,o??""),(l=e.logClient)==null||l.push({level:"error",msg:String(i),meta:o})}},get theme(){return JB(t)},on(){return()=>{}},onThemeChange(i){return n.add(i),()=>{n.delete(i)}}};return s.getThemeSource=()=>t,s.setThemeSource=i=>{t=i;try{localStorage.setItem(Pte,i)}catch{}r()},e.notifier&&(s.notifier=e.notifier),s}var Kot={maxRecords:100,maxBytes:512*1024,maxWaitMs:5e3},Got=5e3,Ate={debug:0,info:1,warn:1,error:1},ez=1024,tz=2048,Yot=/token|secret|password|auth(?!or)|apikey|signsecret/i,Xot="[REDACTED]",Ote="…[truncated]";function Zot(e,t){const n=EI(e,t,0),r=Qot(n);return r.length<=tz?n:{__truncated__:r.slice(0,tz)+Ote}}function EI(e,t,n){if(n>10)return"[depth-limit]";if(e==null)return e;if(typeof e=="string")return t?e.split(t).join("~"):e;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>EI(s,t,n+1));const r={};for(const[s,i]of Object.entries(e))Yot.test(s)?r[s]=Xot:r[s]=EI(i,t,n+1);return r}function Qot(e){try{return JSON.stringify(e)??""}catch{return'"[serialize-failed]"'}}function Jot(e){return e.length<=ez?e:e.slice(0,ez)+Ote}function eat(e,t,n){const r=t[e]??Ate[e];return r<=0?!1:r>=1?!0:n()<r}var tat=class{constructor(e){Gs(this,"deps");Gs(this,"queue",[]);Gs(this,"bytes",0);Gs(this,"droppedSinceFlush",0);Gs(this,"identityReady",!1);Gs(this,"timer",null);Gs(this,"disposed",!1);Gs(this,"pendingSends",[]);this.deps=e}enqueue(e){if(this.disposed)return;const t=nat(e);for(;this.queue.length>=this.deps.bufferCap;)this.queue.shift(),this.droppedSinceFlush++;this.queue.push(e),this.bytes+=t,this.identityReady&&this.maybeTrigger()}setIdentityReady(e){this.identityReady=e,e&&this.queue.length>0&&this.maybeTrigger()}async flush(){this.queue.length>0&&this.fire("flush"),await Promise.allSettled(this.pendingSends)}stats(){return{queued:this.queue.length,dropped:this.droppedSinceFlush}}async dispose(){this.disposed||(this.disposed=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),await this.flush())}maybeTrigger(){const{maxRecords:e,maxBytes:t,maxWaitMs:n}=this.deps.batch;if(this.queue.length>=e){this.fire("records");return}if(this.bytes>=t){this.fire("bytes");return}this.timer==null&&(this.timer=setTimeout(()=>{this.timer=null,this.queue.length>0&&this.identityReady&&this.fire("time")},n))}fire(e){this.timer&&(clearTimeout(this.timer),this.timer=null);const t=this.queue,n=this.droppedSinceFlush;this.queue=[],this.bytes=0,this.droppedSinceFlush=0;const r=this.deps.onBatch({reason:e,records:t,droppedCarryover:n}).catch(()=>{});this.pendingSends.push(r),r.finally(()=>{this.pendingSends=this.pendingSends.filter(s=>s!==r)})}};function nat(e){var t,n;return(((t=e.msg)==null?void 0:t.length)??0)+(((n=e.meta_json)==null?void 0:n.length)??0)+200}var nz=[1e3,2e3,4e3];async function rat(e,t){const n=t.records.map(sat),r=JSON.stringify({__topic__:"clawd",__source__:e.source,__logs__:n,...t.droppedCarryover>0?{__tags__:{dropped:String(t.droppedCarryover)}}:{}});for(let s=0;s<nz.length;s++){s>0&&await iat(nz[s-1]);try{const i=await e.fetchImpl(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:r});if(i.status>=200&&i.status<300)return{sent:t.records.length,failed:0};if(i.status>=400&&i.status<500)return{sent:0,failed:t.records.length}}catch{}}return{sent:0,failed:t.records.length}}function sat(e){const t={};for(const[n,r]of Object.entries(e))r!=null&&(t[n]=typeof r=="string"?r:String(r));return t}function iat(e){return new Promise(t=>setTimeout(t,e))}function oat(e){const t={sent:0,dropped:0,queued:0,failed:0},n=e.fetchImpl??globalThis.fetch.bind(globalThis),r=e.now??Date.now,s={...Ate,...e.sampling??{}},i=e.homeDir===void 0?null:e.homeDir,o={...Kot,...e.batch??{}},l=e.bufferCap??Got;let c=e.identity,u=!1;if(e.endpoint==null)return{push:()=>{u||t.dropped++},flush:async()=>{},setIdentity:f=>{c=f},stats:()=>({...t}),dispose:async()=>{u=!0}};const d=e.endpoint,h=new tat({batch:o,bufferCap:l,now:r,onBatch:async f=>{const m=await rat({endpoint:d,source:e.source,fetchImpl:n},f);t.sent+=m.sent,t.failed+=m.failed}});return h.setIdentityReady(c!=null),{push(f){if(!u)try{if(!eat(f.level,s,Math.random)){t.dropped++;return}const m=aat(f,c,e.source,i,r);h.enqueue(m)}catch{}},async flush(){try{await h.flush()}catch{}},setIdentity(f){c=f,h.setIdentityReady(f!=null)},stats(){const f=h.stats();return{...t,queued:f.queued,dropped:t.dropped+f.dropped}},async dispose(){u=!0;try{await h.dispose()}catch{}}}}function aat(e,t,n,r,s){const i=e.meta?Zot(e.meta,r):void 0,o=i?JSON.stringify(i):void 0;return{ts:e.ts??s(),source:n,level:e.level,msg:Jot(e.msg),ownerPrincipalId:(t==null?void 0:t.ownerPrincipalId)??"__pending__",deviceId:(t==null?void 0:t.deviceId)??"__pending__",appVersion:(t==null?void 0:t.appVersion)??"__pending__",daemonVersion:t==null?void 0:t.daemonVersion,os:(t==null?void 0:t.os)??"unknown",meta_json:o,sessionId:e.sessionId}}function lat(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function cat({filePath:e,oldString:t,newString:n,content:r}){const s=p.useMemo(()=>r!=null?r.split(/\r?\n/).map(i=>({type:"add",text:i})):uat(t??"",n??""),[t,n,r]);return a.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:[a.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:a.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),a.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:s.map((i,o)=>a.jsxs("div",{"data-testid":`diff-line-${i.type}`,className:J("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",i.type==="add"?"bg-success/10 text-success":i.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[a.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:i.type==="add"?"+":i.type==="remove"?"-":" "}),a.jsx("span",{className:"flex-1",children:i.text||" "})]},o))})]})}function uat(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),s=n.length,i=r.length,o=Array.from({length:s+1},()=>new Array(i+1).fill(0));for(let d=s-1;d>=0;d--)for(let h=i-1;h>=0;h--)o[d][h]=n[d]===r[h]?o[d+1][h+1]+1:Math.max(o[d+1][h],o[d][h+1]);const l=[];let c=0,u=0;for(;c<s&&u<i;)n[c]===r[u]?(l.push({type:"equal",text:n[c]}),c++,u++):o[c+1][u]>=o[c][u+1]?(l.push({type:"remove",text:n[c]}),c++):(l.push({type:"add",text:r[u]}),u++);for(;c<s;)l.push({type:"remove",text:n[c++]});for(;u<i;)l.push({type:"add",text:r[u++]});return l}function dat({items:e}){return e.length===0?null:a.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),a.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return a.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[a.jsx(hat,{status:t.status}),a.jsx("span",{className:J("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 hat({status:e}){return e==="completed"?a.jsx(ui,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?a.jsx(st,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):a.jsx(OH,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function fat(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,s=typeof r.content=="string"?r.content:"",i=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:s,status:i,activeForm:o}}).filter(n=>n!==null):[]}function pat({description:e,prompt:t,subagentType:n}){return a.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[a.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[a.jsx(oa,{className:"w-3.5 h-3.5 text-accent shrink-0"}),a.jsx("span",{className:"truncate",children:e||"subagent task"}),n?a.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?a.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function mat(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 gat={render:({input:e})=>q.createElement(dat,{items:fat(e)})},xat={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=mat(e);return q.createElement(pat,{description:t,prompt:n,subagentType:r})}},rz={render:({input:e,output:t,error:n,pending:r,fileScope:s,onShareFile:i,onOpenInTab:o,onPreviewMarkdown:l})=>{const c=yat(e),u=c?q.createElement(cat,{filePath:c.filePath,oldString:c.oldString,newString:c.newString,content:c.content}):void 0;return q.createElement(gG,{tool:vat(e),input:e,output:t,error:n,pending:r,expandedBody:u,...s?{fileScope:s}:{},...i?{onShareFile:i}:{},...o?{onOpenInTab:o}:{},...l?{onPreviewMarkdown:l}:{}})}};function vat(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function yat(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,s=typeof t.new_string=="string"?t.new_string:void 0,i=typeof t.content=="string"?t.content:void 0;return r==null&&s==null&&i==null?null:{filePath:n,oldString:r,newString:s,content:i}}for(const e of["claude",Ace])uh.register(e,"TodoWrite",gat),uh.register(e,"Task",xat),uh.register(e,"Edit",rz),uh.register(e,"Write",rz);const N2={};function bat({urlSource:e,hostOverride:t,notifier:n,credentialSource:r}){const[s]=p.useState(()=>{if(t)return null;const d=N2==null?void 0:N2.VITE_CLAWD_LOG_ENDPOINT;return oat({endpoint:d==="off"?null:d??"https://clawd-prod.cn-hangzhou.log.aliyuncs.com/logstores/app-logs/track",identity:null,source:"renderer",homeDir:null})}),[i]=p.useState(()=>t??qot({notifier:n,...s?{logClient:s}:{}})),[o,l]=p.useState(null),[c,u]=p.useState(null);return p.useEffect(()=>{let d=!1;return Promise.resolve(e.getUrl(i)).then(h=>{d||l(h)}).catch(h=>{d||u(h instanceof Error?h.message:String(h))}),()=>{d=!0}},[e,i]),p.useEffect(()=>lat(i),[i]),c?a.jsxs("div",{className:"p-8 max-w-xl font-sans text-text-100","data-testid":"standalone-error",children:[a.jsx("h2",{className:"text-lg font-semibold mb-2",children:"无法发现 daemon"}),a.jsx("p",{className:"text-destructive mb-3",children:c}),a.jsxs("p",{className:"text-text-400 mb-3",children:["请确认 ",a.jsx("code",{className:"font-mono",children:"clawd"})," 已启动 (",a.jsx("code",{className:"font-mono",children:"cd clawd && pnpm dev"}),"),它会写入"," ",a.jsx("code",{className:"font-mono",children:"~/.clawd/state.json"}),"。"]}),a.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-1.5 text-sm rounded-md border border-border bg-elevated hover:bg-bg-100",children:"重试"})]}):o?a.jsx("div",{"data-testid":"standalone-root","data-mode":"url"in o?"has-url":"needs-setup",children:a.jsx(q.StrictMode,{children:a.jsx(VU.Provider,{value:r??null,children:a.jsx(awe,{client:s,children:a.jsx(Nie,{host:i,children:a.jsx(Tle,{children:a.jsx($ot,{})})})})})})}):a.jsx("div",{className:"p-8 font-sans text-text-400","data-testid":"standalone-resolving",children:"正在发现 daemon…"})}function wat(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}const E3="clawd-owner-web:session",sz="owner-web",_at="/app/session",Sat="ticket";class II extends Error{constructor(t){super(t),this.reason=t,this.name="OwnerSessionError"}}function kat(e){const t=e.startsWith("#")?e.slice(1):e,n=new URLSearchParams(t).get(Sat);return n&&n.length>0?n:null}function iz(e){try{const t=JSON.parse(e.storage.getItem(E3)??"null");if(t&&typeof t.token=="string"&&typeof t.expiresAt=="number"&&t.expiresAt>e.now())return{token:t.token,expiresAt:t.expiresAt}}catch{}return null}async function Cat(e,t){try{const n=await e.fetch(_at,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ticket:t}),cache:"no-store",credentials:"omit"});if(!n.ok)return null;const r=await n.json();if(typeof r.token=="string"&&typeof r.expiresAt=="number")return{token:r.token,expiresAt:r.expiresAt}}catch{}return null}async function Nat(e){const t=kat(e.location.hash);if(t){e.history.replaceState(null,"",`${e.location.pathname}${e.location.search}`);const r=await Cat(e,t);if(r)return e.storage.setItem(E3,JSON.stringify(r)),r;const s=iz(e);if(s)return s;throw new II("ticket-invalid")}const n=iz(e);if(n)return n;throw new II("no-session")}function jat(e){let t,n=null;const r=()=>(n??(n=Nat(e).then(s=>(t=s.token,s))),n);return{session:r,credentials:{profileId:sz,getToken:()=>t,invalidate:()=>{t=void 0;try{e.storage.removeItem(E3)}catch{}}},urlSource:{async getUrl(s){await r();const i=wat(e.location);return await GU(s).upsert({id:sz,name:"本机",mode:"localhost",url:i}),{url:i}}}}}function Eat({web:e}){const[t,n]=p.useState({kind:"connecting"});return p.useEffect(()=>{let r=!1;return e.session().then(()=>!r&&n("ready")).catch(s=>{r||n({kind:"reopen",reason:s instanceof II?s.reason:"no-session"})}),()=>{r=!0}},[e]),t!=="ready"?a.jsx(KU,{view:t}):a.jsx(bat,{urlSource:e.urlSource,credentialSource:e.credentials})}const oz=document.getElementById("root");if(oz){Xxe({name:"clawd-web",version:"unknown"});const e=jat({storage:window.sessionStorage,location:window.location,history:window.history,fetch:window.fetch.bind(window),now:()=>Date.now()});j2.createRoot(oz).render(a.jsx(q.StrictMode,{children:a.jsx(Eat,{web:e})}))}
955
+ focused:`,le.focused),Zr.current=$},[le]);const Lc=p.useRef(new Set);p.useEffect(()=>{if(!qe.current)return;const $=U=>{Lc.current.has(U)||C.some(G=>G.deviceId===U)&&(Lc.current.add(U),ze(U))};for(const U of le.tabs)if(U.kind==="dm")$(U.peerDeviceId);else if(U.kind==="session"){const G=o.find(ie=>ie.sessionId===U.sid);G!=null&&G.originOwnerPrincipalId&&$(G.originOwnerPrincipalId)}},[le,C,o,ze]),p.useEffect(()=>{if(!qe.current||o.length===0)return;const $=new Set(o.map(G=>G.sessionId));for(const G of $)Zt.current.add(G);const U=Zt.current;me(G=>{const ie=G.tabs.filter(at=>at.kind!=="session"?!0:!U.has(at.sid)||$.has(at.sid));if(ie.length===G.tabs.length)return G;if(ie.length===0)return My;const He=Math.min(G.focused,ie.length-1);return{tabs:ie,focused:Math.max(0,He)}})},[o]);const{prune:_v}=$c;p.useEffect(()=>{l&&_v(new Set(o.map($=>$.sessionId)))},[l,o,_v]);const Qn=ut?o.find($=>$.sessionId===ut)??null:null,{visible:Fc,archivedRoots:Dte,archivedChildrenByRoot:$te}=p.useMemo(()=>Qm(o.filter(yB)),[o]),I3=p.useMemo(()=>new Map(Fc.map($=>[$.sessionId,lv($)])),[Fc]),T3=p.useCallback($=>I3.get($),[I3]),vS=p.useMemo(()=>Qm(o.filter(_3)).visible,[o]),yS=p.useMemo(()=>vS.filter($=>cS($,h??void 0)).map($=>({sid:$.sessionId,originOwnerPrincipalId:$.originOwnerPrincipalId??null})),[vS,h]),R3=$ee(yS,S),oo=p.useCallback(($,U)=>{const G=$.tabs.findIndex(ie=>ie.kind==="session"&&ie.sid===U);return G>=0?am($,G):$},[]),Lte=p.useSyncExternalStore(p.useCallback($=>S.onOwnersChanged($),[S]),()=>S.listRemoteDeviceIds().sort().join("|"),()=>""),M3=!k.loading;p.useEffect(()=>{if(!M3)return;const $=[];for(const U of le.tabs){if(U.kind!=="session")continue;const G=o.find(ln=>ln.sessionId===U.sid);if(!(G!=null&&G.originOwnerPrincipalId))continue;const ie=G.originOwnerPrincipalId,He=S.getRemoteForDevice(ie)!==null,at=C.some(ln=>ln.deviceId===ie);!He&&!at&&$.push(U.sid)}$.length!==0&&me(U=>{let G=U;for(const ie of $)G=oo(G,ie);return G})},[M3,le,o,C,S,Lte,oo]);const bl=Jet({entries:yS,sessions:vS,activeId:ut??Kn,pool:S}),xd=Lee(yS,S),Si=p.useMemo(()=>{const $=new Set;for(const[U,G]of R3)G==="turn-running"&&$.add(U);return $},[R3]),P3=p.useMemo(()=>{let $=0;for(const U of ee.unreadByPeer.values())$+=U;return $},[ee.unreadByPeer]),bS=p.useMemo(()=>{const $=new Set;for(const[U,G]of ee.unreadByPeer)G>0&&$.add(U);return $},[ee.unreadByPeer]),A3=i.kind==="disconnected"||i.kind==="auth-failed"||i.kind==="version-mismatch"||i.kind==="reconnecting",Fte=i.kind==="connecting"||i.kind==="idle",dp=qU(),vd=dp?$xe(i):null,O3=(vd==null?void 0:vd.kind)==="reopen"&&vd.reason==="expired";p.useEffect(()=>{O3&&(dp==null||dp.invalidate())},[O3,dp]);const Ta=p.useCallback($=>{_i(!1);const U=o.find(ie=>ie.sessionId===$);U!=null&&U.originOwnerPrincipalId&&ze(U.originOwnerPrincipalId);const G=U==null?void 0:U.cwd;G&&!(U!=null&&U.originOwnerPrincipalId)?Promise.all([r.getGitRoot(G),r.getGitBranch(G)]).then(([ie,He])=>{Ae("app","selectSession",{sessionId:$,cwd:G,gitRoot:ie.gitRoot,branch:He.branch})}).catch(ie=>{Ae("app","selectSession git probe failed",{sessionId:$,err:ie})}):Ae("app","selectSession",{sessionId:$,cwd:null}),me(ie=>Es(ie,{kind:"session",sid:$})),Oe.current||ne($)},[o,r,ze,ne]),Bc=p.useCallback(async $=>{const U=await r.sessionCreate(oD($));return await c(),Ta(U.sessionId),{sessionId:U.sessionId}},[r,c,Ta]),wS=p.useCallback(async({personaId:$,text:U,config:G})=>{const ie=zq(U)??"新建 session",{sessionId:He}=await Bc({ownerPersonaId:$,aiLabel:ie,...G.model?{model:G.model}:{},...G.effort?{effort:G.effort}:{}});await r.sessionSubscribe(He),await r.sessionSend(He,U),At(!1),me(at=>{const ln=at.tabs.findIndex(Bo=>Bo.kind==="landing");return ln>=0?am(at,ln):at})},[r,Bc]),Bte=p.useCallback(()=>{r.onboardingComplete().catch(()=>{}),nt(!0),At(!0),me($=>Es($,{kind:"landing"}))},[r]),zte=p.useCallback(async $=>{await Bc({cwd:$})},[Bc]),Hte=p.useCallback(async $=>{const U=await r.sessionCreate(oD({cwd:$}));await c(),me(G=>Es(G,{kind:"session",sid:U.sessionId}))},[r,c]),_S=p.useRef(!1),Ute=p.useCallback(async($,U)=>{const G=mu($.tool);if(G){if(_S.current)return;_S.current=!0,Fo({kind:"progress",text:"正在分叉云会话…"})}try{const ie=await Hq(r,$,U);if(G&&so(null),!ie)return;await c(),me(He=>Es(He,{kind:"session",sid:ie.sessionId}))}catch(ie){if(!G)throw ie;Fo({kind:"error",text:ie instanceof Error?ie.message:String(ie)})}finally{G&&(_S.current=!1)}},[r,c,Fo]),SS=p.useCallback(async $=>{const U=ny(o,$);for(const ie of U)await r.sessionDelete(ie);await r.sessionDelete($);const G=new Set([$,...U]);me(ie=>aO(ie,He=>He.kind==="session"&&G.has(He.sid))),await c()},[r,o,c]),D3=p.useCallback(async($,U)=>{U.label&&(await r.sessionUpdate($,{label:U.label}),await c())},[r,c]),Wte=p.useCallback(async($,U)=>{await r.pinSession($,U),await c()},[r,c]),{width:kS,onDragStart:Vte}=krt(),[wl,$3]=bm(Pnt,!1),[qte,CS]=p.useState(!1),hp=p.useRef(null),yd=p.useCallback(($,U)=>{hp.current&&clearTimeout(hp.current),hp.current=setTimeout(()=>CS($),U)},[]);p.useEffect(()=>()=>{hp.current&&clearTimeout(hp.current)},[]);const L3=Ct||_e,F3=p.useCallback(()=>yd(!0,MB),[yd]),B3=p.useCallback(()=>{L3||yd(!1,g2)},[yd,L3]),an=p.useCallback(()=>{Ut(!1),vt(!1),wl&&yd(!1,g2)},[wl,yd]),Kte=p.useMemo(()=>nve({channels:io,topicsByChannel:Ks,linesByTopic:re,sessions:o,runningSessionIds:Si}),[io,Ks,re,o,Si]),Gte=p.useMemo(()=>rve({channels:io,topicsByChannel:Ks,linesByTopic:re,sessions:o,runningSessionIds:Si}),[io,Ks,re,o,Si]),z3=p.useMemo(()=>ive({linesByTopic:re,sessions:o}),[re,o]),Sv=ut??Kn,NS=p.useMemo(()=>Sv?o.find($=>$.sessionId===Sv)??null:null,[Sv,o]),H3=knt(r,Sv,NS==null?void 0:NS.updatedAt),Yte=p.useMemo(()=>({resolve:Snt({records:H3,selfDeviceId:h??void 0,lineIndex:z3,sessions:o,personas:Wt,contacts:C}),onOpenSession:Ta,...r?{onAnswer:async($,U)=>{await r.a2aAnswer({taskId:$,text:U})}}:{}}),[H3,z3,o,Wt,C,Ta,r]),Xte=p.useMemo(()=>sve({channels:io,topicsByChannel:Ks,linesByTopic:re,sessions:o,runningSessionIds:Si}),[io,Ks,re,o,Si]),fp=p.useMemo(()=>Object.values(Ks).flat(),[Ks]),Zte=p.useCallback($=>{rr(U=>{const G=new Set(U);return G.has($)?G.delete($):G.add($),G})},[]),kv=p.useCallback($=>{me(U=>Es(U,{kind:"topic",topicId:$}))},[]),[Qte,U3]=p.useState(null),[Jte,W3]=p.useState(null),[ene,V3]=p.useState(null),tne=Qte??ene??(fr===null?Jte:null),nne=p.useCallback(async $=>{if(r){U3(null);try{const{topicId:U}=await r.topicCreate({channelId:$});ht(),kv(U)}catch(U){Ae("app","topicCreate failed",{channelId:$,err:String(U)}),U3({channelId:$,message:U instanceof Error?U.message:String(U)})}}},[r,kv,ht]),bd=p.useCallback($=>fp.find(U=>U.id===$)??null,[fp]),q3=p.useCallback($=>{var U;return((U=bd($))==null?void 0:U.channelId)??null},[bd]),_l=p.useCallback(async($,U,G)=>{V3(null);try{await G(),ht()}catch(ie){Ae("app",`${U} failed`,{topicId:$,err:String(ie)});const He=q3($);He&&V3({channelId:He,message:ie instanceof Error?ie.message:String(ie)})}},[q3,ht]),rne=p.useCallback($=>{var G;const U=(G=bd($))==null?void 0:G.masterSessionId;U&&_l($,"topicArchive",()=>r.archiveSession(U,!0))},[r,bd,_l]),sne=p.useCallback($=>{r.archiveSession($,!1).then(()=>c())},[r,c]),ine=p.useCallback(($,U)=>void _l($,"topicRename",()=>r.topicRename({topicId:$,title:U})),[r,_l]),K3=p.useCallback($=>void _l($,"topicDelete",async()=>{const U=await r.topicDelete({topicId:$}),G=new Set([...U.removedMasterSessionId?[U.removedMasterSessionId]:[],...U.removedWorkerSessionIds]);me(ie=>aO(ie,He=>He.kind==="topic"&&He.topicId===$||He.kind==="session"&&G.has(He.sid)))}),[r,_l]),one=p.useCallback(($,U)=>{var ie;const G=(ie=bd($))==null?void 0:ie.masterSessionId;G&&_l($,"topicPin",()=>r.pinSession(G,U))},[r,bd,_l]),ane=p.useCallback(async $=>{W3(null);try{await cp($)}catch(U){W3({channelId:$,message:U instanceof Error?U.message:String(U)})}},[cp]),[Ra,jS]=bm(Oot,!0),[Cv,lne]=bm("clawd:workspace-cards-collapsed",!1),[cne,une]=p.useState(null),pp=!!(Qn&&mu(Qn.tool)&&!Qn.larkChatId),ES=!!(Qn&&!Qn.larkChatId&&(pp?!Cv:Ra)),[dne,hne]=p.useState(null),[IS,fne]=p.useState(null),[G3,Nv]=p.useState(!1),mp=p.useRef(null),{initialSize:Y3,setSize:pne}=Uq("clawd:panel:session-info-px",320),jv=p.useCallback(($,U)=>{mp.current&&clearTimeout(mp.current),mp.current=setTimeout(()=>Nv($),U)},[]),Ev=p.useCallback(()=>jv(!0,MB),[jv]),Iv=p.useCallback(()=>jv(!1,g2),[jv]);p.useEffect(()=>()=>{mp.current&&clearTimeout(mp.current)},[]);const wd=["session","topic"].includes(((bP=le.tabs[le.focused])==null?void 0:bP.kind)??""),mne=wd?Ra?G3?IS:null:dne:null;p.useEffect(()=>{wd||Nv(!1)},[wd]),p.useEffect(()=>{const $=IS;if($)return $.addEventListener("mouseenter",Ev),$.addEventListener("mouseleave",Iv),()=>{$.removeEventListener("mouseenter",Ev),$.removeEventListener("mouseleave",Iv)}},[IS,Ev,Iv]);const TS=Rot(),[RS,gne]=wf(Ltt,"priority"),[xne,vne]=wf(Btt,"archive"),MS=p.useMemo(()=>_it(Fc,{ownerPrincipalId:h??void 0,sortMode:RS,attention:{awaitingIds:xd,runningIds:Si,unreadIds:bl},projectPaths:Lo,topicSessionIds:Ot}).slice(0,9),[Fc,h,RS,xd,Si,bl,Lo,Ot]),yne=p.useMemo(()=>({held:TS,indexBySessionId:new Map(MS.map(($,U)=>[$,U+1]))}),[TS,MS]),[PS,X3]=p.useState(null),Tv=p.useRef(null),_d=p.useRef(null),gp=p.useCallback(()=>{_d.current!=null&&(clearTimeout(_d.current),_d.current=null),Tv.current=null,X3(null)},[]);p.useEffect(()=>gp,[gp]);const Sd=p.useCallback(()=>{const $=Tv.current;if(gp(),$==null)return;me(G=>lO(G,$));const U=Ke.current.tabs[$];(U==null?void 0:U.kind)==="session"&&ne(U.sid)},[gp,ne]),Z3=p.useCallback($=>{const U=Ke.current.tabs.length;if(U===0)return;const ie=((Tv.current??Ke.current.focused)+$+U)%U;Tv.current=ie,X3(ie),_d.current!=null&&clearTimeout(_d.current),_d.current=setTimeout(Sd,Pot)},[Sd]);p.useEffect(()=>{if(PS==null)return;const $=U=>{(U.key==="Meta"||U.key==="Control"||U.key==="Shift")&&Sd()};return window.addEventListener("keyup",$,!0),window.addEventListener("blur",Sd),()=>{window.removeEventListener("keyup",$,!0),window.removeEventListener("blur",Sd)}},[PS,Sd]);const[xp,Rv]=p.useState(!1),[Ma,AS]=p.useState(""),[kd,Sl]=p.useState({group:"session",row:0}),[bne,Q3]=p.useState(null),[wne,OS]=p.useState(null),Mv=p.useMemo(()=>kot(o),[o]),_ne=p.useMemo(()=>Mv.map($=>$.sessionId),[Mv]),{matches:J3,loading:DS}=Sot({api:r,query:Ma,candidateIds:_ne,enabled:xp}),eP=p.useMemo(()=>{const $=new Map(o.map(U=>[U.sessionId,U]));return new Map(fp.map(U=>[U.masterSessionId,{topicId:U.id,title:Vw(U.title,$.get(U.masterSessionId)??null)}]))},[fp,o]),tP=p.useMemo(()=>new Map(Wt.map($=>[$.personaId,$.label])),[Wt]),vp=p.useMemo(()=>Cot({candidates:Mv,query:Ma,contentMatches:J3,topicByMasterSessionId:eP,personaLabelById:tP}),[Mv,Ma,J3,eP,tP]),yp=p.useMemo(()=>Not(Wt,Ma),[Wt,Ma]),bp=p.useMemo(()=>{const $=S3(C,Dot);return jot([...$.pinned,...$.main],Ma)},[C,Ma]),$S=p.useMemo(()=>Iot({session:vp.length,persona:yp.length,contact:bp.length}),[vp.length,yp.length,bp.length]),wp=p.useMemo(()=>$S.map($=>$.key),[$S]),Sne=kd.group==="session"?vp.length:kd.group==="persona"?yp.length:bp.length;p.useEffect(()=>{Sl($=>Wd($,{kind:"query-changed"}))},[Ma]),p.useEffect(()=>{Sl($=>Wd($,{kind:"results-changed",groups:wp,sessionsLoading:DS}))},[wp,DS]);const nP=p.useCallback(()=>{an(),AS(""),Sl({group:"session",row:0}),Rv(!0)},[an]),[LS,Pv]=p.useState(!1),rP=p.useCallback(()=>{an(),Rv(!1),Pv(!0)},[an]),kne=p.useMemo(()=>AB(C.map($=>({deviceId:$.deviceId,displayName:$.displayName})),[]),[C]),sP={"toggle-hive":()=>{if(LS){Pv(!1);return}rP()},"new-session":()=>{an(),Pe(!0)},"open-search":()=>{if(xp){Rv(!1);return}nP()},...xp?{"search-tab-prev":()=>Sl($=>Wd($,{kind:"move-group",delta:-1,groups:wp})),"search-tab-next":()=>Sl($=>Wd($,{kind:"move-group",delta:1,groups:wp}))}:{},...Object.fromEntries(Array.from({length:9},($,U)=>[`switch-session-${U+1}`,()=>{if(xp){fP(U);return}const G=MS[U];G&&(an(),Sp(G))}])),"tab-prev":()=>Z3(-1),"tab-next":()=>Z3(1),...le.tabs.length>0?{"close-tab":()=>me($=>am($,$.focused))}:{},"archive-session":()=>{const $=Ke.current.tabs[Ke.current.focused];if(($==null?void 0:$.kind)!=="session")return;const U=o.find(ie=>ie.sessionId===$.sid);if(!U)return;const G=cv(U);G&&o.some(ie=>ie.sessionId===G)||FS($.sid)}};wtt(LS?{"toggle-hive":sP["toggle-hive"]}:sP);const[Av,FS]=p.useState(null),[iP,Cne,oP]=bm(Aot,!1),aP=p.useRef(!1),[Nne,BS]=p.useState(null);p.useEffect(()=>{if(aP.current||!l||h==null||!oP||(aP.current=!0,iP))return;const $=h2(o,h,10,Lo,Ot).length;$>0&&BS($)},[o,l,h,Lo,Ot,iP,oP]);const zS=p.useCallback(async($,U)=>{if(U){const G=[$,...ny(o,$)];me(ie=>G.reduce((He,at)=>oo(He,at),ie))}await r.archiveSession($,U),await c(),U&&Ia()},[r,c,oo,o,Ia]),jne=p.useCallback(async $=>{await r.reorderPins($),await c()},[r,c]),HS=p.useCallback($=>{_i(!1),sn({kind:"config",personaId:$})},[]),Ene=p.useCallback($=>{an(),me(U=>Es(U,{kind:"deploy",personaId:$}))},[an]),Ine=p.useCallback(($,U)=>{an(),me(G=>Es(G,{kind:"deploy-history",personaId:$,head:U}))},[an]),Tne=p.useCallback(async $=>{var G;const U=((G=Wt.find(ie=>ie.personaId===$))==null?void 0:G.label)??$;confirm(`删除 persona "${U}"?`)&&(await ro($),sn(ie=>(ie==null?void 0:ie.personaId)===$?null:ie))},[ro,Wt]),Rne=p.useCallback(async($,U)=>{_i(!1),sn(null);const G={ownerPersonaId:$},ie=U.trim();ie&&(G.label=ie);try{const He=await r.sessionCreate(G);await c(),Ta(He.sessionId)}catch(He){Ae("persona","sessionCreate(ownerPersonaId) failed",He)}},[r,c,Ta,Wt]),Mne=p.useCallback(async($,U,G)=>{try{const{sessionId:ie}=await Bc({ownerPersonaId:$,label:G});await r.sessionSubscribe(ie),await r.sessionSend(ie,U)}catch(ie){throw Ae("pr-inbox","open chat failed",ie),ie}},[r,Bc]),kl=p.useCallback(async($,U)=>{const G=SI(U,$);try{await r.peerSessionUpsert(G)}catch(ie){Ae("mirror","peerSession:upsert failed",G.sessionId,ie)}s.setData("sessions",ie=>{const He=[...ie??[]],at=He.findIndex(ln=>ln.sessionId===G.sessionId);return at>=0?He[at]=G:He.unshift(G),He})},[r,s]),Ov=p.useCallback(async $=>{try{await r.peerSessionRemove($)}catch(U){Ae("mirror","peerSession:remove failed",$,U)}s.setData("sessions",U=>(U??[]).filter(G=>G.sessionId!==$))},[r,s]),Pne=p.useCallback(async($,U,G)=>{await ze($);const ie=S.getRemoteForDevice($);if(!ie)throw new Error("remote daemon unreachable");const He=new Kt(ie),at={ownerPersonaId:U},ln=G.trim();ln&&(at.label=ln);try{const Bo=await He.sessionCreate(at),Lv=Bo;Je($,Lv),me(kp=>Es(kp,{kind:"session",sid:Bo.sessionId})),kl($,Lv).catch(kp=>{Ae("persona","upsertMirrorLocally (remote create) failed",kp)})}catch(Bo){Ae("persona","sessionCreate(remote) failed",{ownerId:$,personaId:U,err:Bo})}},[S,be,ze,Je,kl]),Cl=p.useCallback($=>{const U=S.getRemoteForDevice($);if(U)return U;const G=C.find(ie=>ie.deviceId===$);return!(G!=null&&G.remoteUrl)||!G.connectToken?null:S.ensureRemoteForDevice($,G.remoteUrl,G.connectToken)},[S,C]),ao=p.useCallback(($,U,G,ie)=>{Fo({kind:"error",text:iit(T($),U,G),...ie?{action:ie}:{}})},[Fo,T]),US=p.useCallback(async($,U)=>{const G=async()=>{ve($,U),me(at=>oo(at,U)),await Ov(U)},ie=Cl($);if(!ie){await G();return}const He=new Kt(ie);try{await He.sessionDelete(U),G().catch(at=>{Ae("persona","removeMirrorLocally (remote delete) failed",at)})}catch(at){Ae("persona","sessionDelete(remote) failed",at),ao($,"删除",at,{label:"只从我这儿移除",onClick:()=>{so(null),G().catch(ln=>{Ae("persona","removeMirrorLocally (drop from my side) failed",ln)})}})}},[Cl,ao,ve,Ov,oo]),Ane=p.useCallback(async($,U,G)=>{const ie=G?"置顶":"取消置顶",He=Cl($);if(!He){ao($,ie,null);return}const at=new Kt(He);try{const ln=await at.pinSession(U,G);await kl($,ln),so(null)}catch(ln){Ae("persona","pinSession(remote) failed",ln),ao($,ie,ln)}},[Cl,ao,kl]),_p=p.useCallback(async($,U,G)=>{const ie=G?"归档":"取消归档",He=Cl($);if(!He)return ao($,ie,null),!1;const at=new Kt(He);try{if(G){const Bo=[U,...ny(o,U)];me(Lv=>Bo.reduce((kp,Xne)=>oo(kp,Xne),Lv))}const ln=await at.archiveSession(U,G);return await kl($,ln),G&&Ia(),!0}catch(ln){return Ae("persona","archiveSession(remote) failed",ln),ao($,ie,ln),!1}},[Cl,ao,kl,oo,o,Ia]),One=p.useCallback(async $=>{const U=h2(o,h??void 0,$,Lo,Ot);let G=0;for(const ie of U){if(ie.originOwnerPrincipalId){await _p(ie.originOwnerPrincipalId,ie.sessionId,!0)||(G+=1);continue}const He=[ie.sessionId,...ny(o,ie.sessionId)];me(at=>He.reduce((ln,Bo)=>oo(ln,Bo),at));try{await r.archiveSession(ie.sessionId,!0)}catch(at){Ae("persona","bulkArchive: archiveSession failed",at),G+=1}}await c(),BS(null),U.length>0&&G===0&&Ia()},[o,h,Lo,Ot,r,c,oo,_p,Ia]),Dne=p.useCallback($=>h2(o,h??void 0,$,Lo,Ot).length>0,[o,h,Lo,Ot]),lP=p.useCallback(async($,U,G)=>{if(!G.label)return;const ie=Cl($);if(!ie){ao($,"改名",null);return}const He=new Kt(ie);try{const at=await He.sessionUpdate(U,{label:G.label});await kl($,at),so(null)}catch(at){Ae("persona","sessionUpdate(remote) failed",at),ao($,"改名",at)}},[Cl,ao,kl]),cP=p.useCallback(()=>{_i(!1),yn(null),Lt(!0)},[]),$ne=p.useCallback(async $=>{no(!0),yn(null);try{await wS({personaId:ei,text:Ort($),config:{model:"",effort:"",permissionMode:""}}),Lt(!1),Qt(U=>U+1),an()}catch(U){yn(U.message??String(U))}finally{no(!1)}},[wS,an]),Lne=p.useCallback(async()=>{const $=n.getActive();$&&await n.activate($.id)},[n]),Sp=p.useCallback($=>{sn(null),Ta($)},[Ta]),Dv=()=>{Rv(!1),AS("")},uP=$=>{if(Dv(),$.topicId!==void 0){kv($.topicId);return}Sp($.sessionId)},dP=$=>{Dv(),Q3($),vt(!1),Ut(!0)},Pa=Mnt(),Fne=p.useMemo(()=>{const $=new Map(C.map(U=>[U.deviceId,U]));return Pa.favorites.flatMap(U=>{var He;const G=U.deviceId?$.get(U.deviceId):void 0;if(!U.deviceId||!G)return[];const ie=(He=be.get(U.deviceId))==null?void 0:He.find(at=>at.personaId===U.personaId);return[{deviceId:U.deviceId,personaId:U.personaId,label:(ie==null?void 0:ie.label)??U.label??U.personaId,tool:(ie==null?void 0:ie.tool)??U.tool,contactName:G.displayName||G.deviceId}]})},[Pa.favorites,C,be]),Bne=$=>{OS($),Ut(!1),vt(!0),ze($)},hP=$=>{Dv(),OS($),Ut(!1),vt(!0),ze($)},fP=$=>{if(kd.group==="session"){const G=vp[$];G&&uP(G);return}if(kd.group==="persona"){const G=yp[$];G&&dP(G.personaId);return}const U=bp[$];U&&hP(U.deviceId)},pP=A3||Dc;if(pP&&vd)return a.jsx(KU,{view:vd});if(pP)return a.jsx(Tst,{state:i,onClose:A3?void 0:()=>hv(!1),remoteHosts:H});if(Fte||!l)return a.jsx("div",{"data-testid":"app-bootstrapping",className:"h-screen flex items-center justify-center bg-bg-0",children:a.jsx(st,{className:"w-5 h-5 text-text-400 animate-spin"})});if(i.kind==="connected"&&i.mode!=="remote"&&i.onboardingCompletedAt===null&&!it)return a.jsx(ost,{api:r,feishuIdentity:g.identity,feishuError:g.error,onFeishuLogin:g.login,personas:Wt.map($=>({personaId:$.personaId,label:$.label})),onFinished:Bte});const zne=(Qn==null?void 0:Qn.label)||(Qn==null?void 0:Qn.aiLabel)||(Qn!=null&&Qn.cwd?Qn.cwd.split("/").filter(Boolean).pop()??"Clawd":"Clawd"),mP=wl?nu+kS:kS,gP=wl?x2:0,xP=wl?nu:0,$v=(wP=le.tabs[le.focused])==null?void 0:wP.kind,Hne=_e?"people":Ct?"persona":$v==="exts"||$v==="shift"||$v==="prs"?$v:null,Une=$=>{if(_i(!1),$==="people"){OS(null),Ut(!1),vt(G=>!G);return}if($==="persona"){Q3(null),vt(!1),Ut(G=>!G);return}if(an(),$==="new"){me(G=>Es(G,{kind:"landing"}));return}const U=$==="shift"?{kind:"shift"}:$==="prs"?{kind:"prs"}:{kind:"exts"};me(G=>Es(G,U))},Wne=a.jsxs(a.Fragment,{children:[H,a.jsx(fit,{identity:g.identity,loading:g.loading,error:g.error,onLogin:g.login}),a.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx(dit,{onClick:()=>md("about")})}),a.jsx(hit,{})]})]}),Vne=a.jsx(rb.Provider,{value:$c,children:a.jsx(vnt,{client:t,open:_e,initialSelectedId:wne,onClose:an,sidebarWidth:mP,insetTop:gP,insetBottom:xP,contacts:C,publicDevices:K,onConnectPublicDevice:async $=>{await X.connect($)},remoteGated:!y,onAddContact:()=>A(!0),visitors:de,visitorUnreadIds:bS,unreadDeviceIds:bS,isRemotePersonaFavorite:($,U)=>Pa.isFavorite(U,$),onToggleRemotePersonaFavorite:($,U)=>Pa.toggleFavorite({personaId:U.personaId,deviceId:$,label:U.label,tool:U.tool}),onOpenVisitor:$=>{an(),me(U=>Es(U,{kind:"dm",peerDeviceId:$}))},loginCardNode:a.jsx(gB,{...v}),onEnsureContactLoaded:wt,personasByOwnerId:be,personaLoadingOwnerIds:se,personaErrorByOwnerId:ae,onRetryPersonas:wt,onReconnectContact:async $=>{await X.connect({deviceId:$.deviceId,url:$.remoteUrl||void 0})},sessionsByOwnerId:xe,extensionsByOwnerId:Ne,activeSessionId:zt?null:ut,awaitingIds:xd,runningIds:Si,unreadIds:bl,onMessage:$=>{an(),ze($),me(U=>Es(U,{kind:"dm",peerDeviceId:$}))},onPinContact:($,U)=>void k.pin($,U),onSetContactRemoteAccess:($,U)=>k.setRemoteAccess($.deviceId,{remoteAccessAllowed:U}),onSetContactNote:($,U)=>void k.setNote($,U),onRemoveContact:$=>{const U=$.deviceId;for(const G of o)G.originOwnerPrincipalId===U&&Ov(G.sessionId);k.remove(U)},onCreateRemoteSession:($,U)=>(an(),Pne($,U,"")),onSelectSession:$=>{an(),Ta($)},onDeleteRemoteSession:($,U)=>void US($,U),onEditRemoteSession:($,U,G)=>void lP($,U,G),onInstallExtension:($,U,G)=>{G&&oe($,U,G)},onOpenInstalledExtension:($,U)=>{an(),me(G=>Es(G,{kind:"ext",extId:Q5(U,$)}))}})}),qne=a.jsx("div",{className:"h-full w-full overflow-y-auto bg-bg-100",children:a.jsx("div",{className:"max-w-[480px] h-full border-r border-border",children:a.jsx(qnt,{client:t,activeExtId:tn,onOpenInMain:$=>me(U=>Es(U,{kind:"ext",extId:$})),onExtensionsMutated:()=>void Re()})})}),Kne=fr?a.jsx(ynt,{open:!0,submitting:wi,mode:fr.mode,...fr.mode==="edit"?(()=>{const $=io.find(U=>U.id===fr.channelId);return $?{initial:{name:$.name,memberPersonas:[...$.memberPersonas],memberContactDeviceIds:[...$.memberContactDeviceIds]}}:{}})():{},personas:Wt.map($=>({id:$.personaId,label:$.label||$.personaId})),contactGroups:C.map($=>{const U=be.get($.deviceId),G=ae.get($.deviceId);return{deviceId:$.deviceId,displayName:$.displayName,...U?{personas:U.map(ie=>({id:ie.personaId,label:ie.label||ie.personaId}))}:{},...se.has($.deviceId)?{loading:!0}:{},...G?{errorText:G}:{},...zf($)?{}:{brokenLink:!0}}}),onExpandContact:$=>void Z($),...up?{error:up}:{},onCancel:()=>eo(null),onSubmit:$=>{const U=()=>{to(!1),eo(null)},G=()=>to(!1);to(!0),fr.mode==="create"?bv($).then(U).catch(G):wv({channelId:fr.channelId,...$}).then(U).catch(G)}}):null,Gne=a.jsx(rb.Provider,{value:$c,children:a.jsx(Ent,{open:Ct,initialSelectedId:bne,onClose:an,sidebarWidth:mP,insetTop:gP,insetBottom:xP,personas:Wt,sessions:Fc,activeSessionId:zt?null:ut,awaitingIds:xd,runningIds:Si,unreadIds:bl,ownerPrincipalId:h??void 0,getCreatorDisplayName:R,getSessionDisplayName:T3,onNewPersona:cP,onCreateSession:$=>{an(),Rne($,"")},onOpenPersonaSettings:$=>{an(),HS($)},onDeployPersona:Ene,renderDeployStatus:$=>{var U;return a.jsx(xst,{personaId:$,tool:(U=Wt.find(G=>G.personaId===$))==null?void 0:U.tool})},renderDeployHistory:$=>{var U;return a.jsx(yst,{personaId:$,tool:(U=Wt.find(G=>G.personaId===$))==null?void 0:U.tool,onOpenRelease:G=>Ine($,G)})},renderCloudConnectors:($,U)=>a.jsx(Sst,{personaId:$,render:U}),renderCloudApiKey:$=>a.jsx(mB,{...b,personaId:$}),renderCloudLarkBot:$=>a.jsx(pst,{personaId:$}),favorites:{isFavorite:$=>Pa.isFavorite($),onToggle:$=>Pa.toggleFavorite({personaId:$.personaId}),filter:Pa.filter,onFilterChange:Pa.setFilter,contactFavorites:Fne,onToggleContact:$=>Pa.toggleFavorite({personaId:$.personaId,deviceId:$.deviceId}),onOpenContact:Bne},onDeletePersona:$=>void Tne($),renderSettings:$=>a.jsx(fst,{personaId:$,onOpenMore:()=>{an(),HS($)},onOpenLarkBot:()=>{an(),HS($)}}),onSelectSession:$=>{an(),Sp($)},onEditSession:($,U)=>void D3($,U),onDeleteSession:$=>void SS($)})}),vP=$=>a.jsx(rb.Provider,{value:$c,children:a.jsx(Utt,{channelTree:Kte,expandedTopicIds:hr,onToggleTopic:Zte,onSelectTopic:U=>{_i(!1),an(),kv(U)},onCreateChannel:()=>eo({mode:"create"}),onCreateTopic:U=>void nne(U),onEditChannel:U=>eo({mode:"edit",channelId:U}),onDeleteChannel:U=>void ane(U),onArchiveTopic:rne,onRenameTopic:ine,onDeleteTopic:K3,onPinTopic:one,pinnedTopics:Gte,channelError:tne,topicSessionIds:Ot,floating:$,width:kS,onResizeStart:Vte,projects:qs,onNewInProject:U=>{Pt(U),Pe(!0)},onRefreshProjects:()=>void ye(),onCreateProject:()=>{ap(void 0),lt(!0)},onPatchProject:(U,G)=>{r==null||r.projectPatch({path:U,...G}).then(()=>ye()).catch(ie=>Ae("app","projectPatch failed",{path:U,err:String(ie)}))},onRevealProject:U=>{r==null||r.projectReveal(U).catch(G=>Ae("app","projectReveal failed",{path:U,err:String(G)}))},getPersonaDisplayName:Ea,sessions:Fc,activeId:zt?null:ut??Kn,awaitingIds:xd,runningIds:Si,unreadIds:bl,onSelect:U=>{_i(!1),an(),Sp(U)},onEdit:(U,G)=>{const ie=o.find(at=>at.sessionId===U),He=ie==null?void 0:ie.originOwnerPrincipalId;He?lP(He,U,G):D3(U,G)},onDelete:U=>{const G=o.find(He=>He.sessionId===U),ie=G==null?void 0:G.originOwnerPrincipalId;ie?US(ie,U):SS(U)},onPin:(U,G)=>{const ie=o.find(at=>at.sessionId===U),He=ie==null?void 0:ie.originOwnerPrincipalId;He?Ane(He,U,G):Wte(U,G)},sortMode:RS,onChangeSortMode:gne,quickAction:xne,onChangeQuickAction:vne,bulkArchiveHintCount:Nne,onDismissBulkHint:()=>{BS(null),Cne(!0)},onBulkArchive:U=>void One(U),bulkArchiveAvailable:Dne,onArchive:(U,G)=>{const ie=o.find(at=>at.sessionId===U),He=ie==null?void 0:ie.originOwnerPrincipalId;He?_p(He,U,G):zS(U,G)},onReorderPins:U=>void jne(U),ownerPrincipalId:h??void 0,getContactDisplayName:T,getCreatorDisplayName:R,getSessionDisplayName:T3,onNewPersona:cP,onCollapse:()=>{$3(!0),CS(!1),an()},onOpenHive:rP,onOpenSearch:nP,onFixedEntryClick:Une,activeEntry:Hne,peopleUnreadCount:P3,footer:a.jsx("div",{className:"flex flex-col px-2 py-2",children:Wne})})}),yP=vP(!1),Yne=vP(!0);return a.jsx(Pst,{api:fd,children:a.jsx(rTe,{value:hn,children:a.jsx(Vee.Provider,{value:yne,children:a.jsx(tX.Provider,{value:Yte,children:a.jsxs("div",{className:"h-screen flex flex-col bg-bg-100 text-text-100","data-testid":"app-root",children:[LS&&a.jsx("div",{className:"fixed inset-0 z-50","data-testid":"hive-overlay",children:a.jsx(yot,{sessions:Fc,pool:S,deviceNames:kne,unreadIds:bl,ownerName:m??"me",onExit:()=>Pv(!1),onPick:$=>{Pv(!1),an(),Sp($)}})}),a.jsx(Nrt,{state:i,onRetryNow:Lne}),H,a.jsxs("div",{className:"md:hidden flex items-center gap-2 h-11 px-2 border-b border-border shrink-0",style:{paddingTop:"env(safe-area-inset-top)",minHeight:"calc(2.75rem + env(safe-area-inset-top))"},"data-testid":"app-mobile-topbar",children:[a.jsx("button",{type:"button",onClick:()=>_i(!0),className:"flex items-center justify-center w-9 h-9 rounded-md text-text-300 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"Open sessions","data-testid":"app-mobile-nav-trigger",children:a.jsx(Kfe,{className:"w-5 h-5"})}),a.jsx("div",{className:"flex-1 truncate text-sm font-medium text-text-200",children:zne})]}),a.jsxs("div",{className:"relative flex-1 flex min-h-0",children:[!wl&&a.jsx("aside",{className:"hidden md:flex shrink-0 flex-row","data-testid":"app-sidebar",children:yP}),wl&&a.jsxs("div",{className:"hidden md:block",children:[a.jsx(Ont,{hasUnread:P3>0||bl.size>0,onExpand:()=>{$3(!1),CS(!1)},onMouseEnter:F3,onMouseLeave:B3}),qte&&a.jsx("div",{"data-testid":"sidebar-float-layer",className:"absolute z-40 shadow-2xl rounded-xl bg-bg-100",style:{left:nu,top:x2,bottom:nu},onMouseEnter:F3,onMouseLeave:B3,children:Yne})]}),a.jsx(prt,{open:P,onClose:()=>A(!1),connect:X.connect,myDeviceLink:w,onLogin:g.login}),a.jsx(Pit,{open:O,onClose:()=>F(!1),tunnelUrl:L,token:I==null?void 0:I.token,connections:D,onOpenRemoteHosts:void 0}),z&&a.jsx(Ait,{api:r,onClose:()=>W(!1)}),Kne,a.jsx(wit,{open:Qe,submitting:Vt,error:dd,onSubmit:gS,onCancel:()=>lt(!1)}),a.jsx(Ry,{open:fv,onOpenChange:_i,children:a.jsxs(Om,{side:"left",hideBuiltInClose:!0,className:"md:hidden p-0 w-[288px]","data-testid":"app-mobile-nav-drawer","aria-describedby":void 0,children:[a.jsx(Dm,{className:"sr-only",children:"Sessions"}),a.jsx("div",{className:"flex flex-col h-full",children:yP})]})}),a.jsxs(c_,{orientation:"horizontal",className:`flex-1 flex min-w-0${wl?" md:pl-10":""}${pp?" md:[&_.chrome-tab-strip]:pr-20":ES?" md:[&:has(+aside:not(:empty))_[data-cc-chat-root]]:pr-[316px]":wd&&Ra?" md:pr-10":""}`,children:[a.jsx(Jh,{id:"main",children:a.jsx("main",{className:`flex-1 flex min-w-0 flex-col md:flex-row h-full${pp&&!Cv&&Ra?" md:[&_[data-cc-chat-root]]:pr-[316px]":""}`,"data-testid":"app-main",children:a.jsx(LG,{container:mne,workspaceContainer:ES?cne:null,...Ra?{}:{onCollapse:()=>jS(!0)},children:a.jsx(NTe,{value:fe,children:a.jsx(Det,{view:le,sessions:o,topics:fp,contacts:C,visitorContacts:te,remoteSessionsByOwnerId:xe,clientPool:S,client:t,im:ee,api:r,myOwnerPrincipalId:h??"",myOwnerDisplayName:m??"我",cloud:{apiKey:x.apiKey,gatewayUrl:x.gatewayUrl},onFocusTab:$=>{gp(),me(G=>lO(G,$));const U=le.tabs[$];(U==null?void 0:U.kind)==="session"&&ne(U.sid)},onCloseTab:$=>me(U=>am(U,$)),onCloseOtherTabs:$=>me(U=>cve(U,$)),onCloseAllTabs:()=>me(My),onReorderTab:($,U)=>{console.log("[tab-debug] onReorderTab dispatch",{from:$,to:U}),me(G=>uve(G,$,U))},onSelectCwdForNew:zte,onNewSession:Hte,onOpenPrChat:Mne,onFork:Ute,onOpenMobileConfig:()=>yl(!0),onMirrorOrphan:($,U)=>{Ov($),Ae("mirror","orphan auto-cleanup",{sessionId:$,ownerId:U}),me(G=>oo(G,$))},extensionUpdateInfo:Lot(tn,Ne),onApplyExtensionUpdate:St,awaitingIds:xd,runningIds:Si,unreadIds:bl,unreadDmPeerDeviceIds:bS,pendingTabIndex:PS,extensionsListNode:qne,landingNode:a.jsx(Hrt,{firstRun:kt,personas:Wt.filter($=>$.personaId!==Fi).map($=>({personaId:$.personaId,name:$.label,tool:$.tool,...$.cloud?{cloud:!0}:{}})),initialPersonaId:ei,api:r,modelList:d,modes:(u==null?void 0:u.permissionModes)??[],configSchema:(u==null?void 0:u.configSchema)??[],defaultsByPersonaId:Object.fromEntries(Wt.map($=>[$.personaId,{...$.model?{model:$.model}:{},...$.effort?{effort:$.effort}:{}}])),onCreate:$=>void wS($)})})})})})}),wd&&!Ra?a.jsxs(a.Fragment,{children:[a.jsx(xR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),a.jsx(Jh,{id:"session-info",defaultSize:`${Y3}px`,minSize:"280px",maxSize:"480px",onResize:$=>pne($.inPixels),children:a.jsx("div",{ref:hne,"data-testid":"session-info-column",className:"hidden md:flex h-full min-w-0 flex-col"})})]}):null]}),ES&&a.jsx("aside",{ref:une,"aria-label":"工作区卡片",className:"absolute right-0 top-10 z-30 hidden max-h-[calc(100%-2.5rem)] w-[316px] overflow-y-auto p-2 md:flex md:flex-col md:gap-3 md:empty:hidden"}),pp&&a.jsxs("div",{className:"absolute right-2 top-2 z-50 hidden items-center gap-1 rounded-md bg-bg-100 md:flex",children:[a.jsx("button",{"aria-label":"显示或隐藏工作区卡片",title:"工作区卡片","aria-pressed":!Cv,onClick:()=>lne(!Cv),className:"rounded-md p-1.5 text-text-300 hover:bg-text-100/10",children:a.jsx(Afe,{className:"h-4 w-4"})}),a.jsx("button",{"aria-label":"切换会话侧栏",title:"会话侧栏","aria-pressed":!Ra,onClick:()=>{jS(!Ra),Nv(!1)},className:"rounded-md p-1.5 text-text-300 hover:bg-text-100/10",children:a.jsx(Kb,{className:"h-4 w-4"})})]}),wd&&Ra&&!pp&&a.jsxs("div",{className:"hidden md:block",children:[a.jsx(Dnt,{onExpand:()=>{jS(!1),Nv(!1)},onMouseEnter:Ev,onMouseLeave:Iv}),G3&&a.jsx("div",{"data-testid":"session-info-float",className:"absolute z-40 shadow-2xl rounded-xl overflow-hidden",style:{right:nu,top:x2,bottom:nu,width:Y3},ref:fne})]}),Vne,Gne,xp&&a.jsx(wot,{query:Ma,onQueryChange:AS,sessionsLoading:DS,sessions:vp,personas:yp,contacts:bp,groups:$S,focus:kd,onFocusChange:Sl,onMoveRow:$=>Sl(U=>Wd(U,{kind:"move-row",delta:$,rowCount:Sne})),onMoveGroup:$=>Sl(U=>Wd(U,{kind:"move-group",delta:$,groups:wp})),onOpenFocused:()=>fP(kd.row),onSelectSession:uP,onSelectPersona:$=>dP($.personaId),onSelectContact:$=>hP($.deviceId),onClose:Dv}),fd,a.jsx(Lst,{open:TS}),Av?a.jsx(Mot,{sessionLabel:(()=>{const $=o.find(U=>U.sessionId===Av);return($==null?void 0:$.label)||($==null?void 0:$.aiLabel)||($==null?void 0:$.larkChatName)||($==null?void 0:$.larkChatId)||($==null?void 0:$.cwd)||Av.slice(0,8)})(),onConfirm:()=>{const $=Av;FS(null);const U=o.find(G=>G.sessionId===$);U&&(U.originOwnerPrincipalId?_p(U.originOwnerPrincipalId,$,!0):zS($,!0))},onCancel:()=>FS(null)}):null,a.jsx(rit,{toast:vv,onOpenArchived:()=>{so(null),md("archived")},onClose:()=>so(null)}),pd&&a.jsx(Wst,{initialNav:pd,onBack:()=>md(null),api:fd,ownerPrincipalId:h,daemonScanApi:pv,daemonVersion:i.kind==="connected"?i.daemonVersion:null,daemonSource:i.kind==="connected"?i.daemonSource:null,globalCliVersion:i.kind==="connected"?i.globalCliVersion:null,ccMode:gv,effectiveCcMode:xv,onChangeCcMode:void 0,onAddMobile:V?()=>F(!0):void 0,onImportExternalSessions:i.kind==="connected"&&i.mode!=="remote"?()=>W(!0):void 0,feishuSlot:a.jsx(gB,{variant:"settings",...v}),cloudApiKeySlot:a.jsx(mB,{...b}),githubSlot:a.jsx(xI,{}),channelsSlot:a.jsx(nit,{}),engineSlot:a.jsx(Jst,{}),dashboardSlot:a.jsx(zet,{tunnelReady:!!L,onOpen:$=>y_e(async()=>(await r.dashboardOpenUrl($)).url)}),archivedTopicsSlot:a.jsx(uit,{groups:Xte,onUnarchive:sne,onDelete:K3}),archivedSlot:a.jsx(lit,{sessions:Dte,childrenByRoot:$te,personaLabelOf:$=>{var U;return(U=Wt.find(G=>G.personaId===$))==null?void 0:U.label},contactNameOf:$=>T($),onUnarchive:$=>{const U=o.find(ie=>ie.sessionId===$),G=U==null?void 0:U.originOwnerPrincipalId;G?_p(G,$,!1):zS($,!1)},onDelete:$=>{const U=o.find(ie=>ie.sessionId===$),G=U==null?void 0:U.originOwnerPrincipalId;G?US(G,$):SS($)}})},pd),Qn?a.jsx(Ry,{open:dv,onOpenChange:yl,children:a.jsxs(Om,{side:"right",className:"md:hidden p-0 w-[320px] max-w-[85vw]","data-testid":"app-mobile-config-drawer","aria-describedby":void 0,children:[a.jsx(Dm,{className:"sr-only",children:"Session Info"}),a.jsx(Rst,{open:dv,onOpenChange:yl,session:Qn,embedded:!0})]})}):null,(zt==null?void 0:zt.kind)==="config"&&a.jsx(Ry,{open:!0,onOpenChange:$=>{$||lp&&!window.confirm("修改未保存,确定关闭?")||(sn(null),hd(!1))},children:a.jsxs(Om,{side:"right",className:"p-0 w-[420px] max-w-[90vw]","data-testid":"app-persona-config-drawer","aria-describedby":void 0,hideBuiltInClose:!0,children:[a.jsx(Dm,{className:"sr-only",children:"Persona 设置"}),a.jsx(eX,{personaId:zt.personaId,open:!0,onClose:()=>{lp&&!window.confirm("修改未保存,确定关闭?")||(sn(null),hd(!1))},api:r,embedded:!0,onDirtyChange:hd},zt.personaId)]})})]}),a.jsx(Drt,{open:Se,onOpenChange:$=>{Pe($),$||Pt(null),!$&&ut&&ne(ut)},onCreate:Bc,api:r,projects:qs,presetProject:dt,onProjectsChanged:()=>void ye()}),a.jsx(lst,{open:$n,onOpenChange:$=>{Lt($),$||yn(null)},onCreate:$ne,loadRepos:($,U)=>r.githubRepos({page:$,search:U}),githubLink:$=>a.jsx(xI,{compact:!0,onAuthorized:$}),submitting:ja,submitError:xn},Sn)]})})})})})}const Mte="(prefers-color-scheme: dark)",zot=["light","dark","system"],Pte="clawd-standalone:theme-source",Hot="light",Uot={colorPrimary:"#1677ff",colorBgContainer:"#fff",colorText:"#000",colorBorder:"#d9d9d9"};function Wot(){try{const e=localStorage.getItem(Pte);if(e!==null&&zot.includes(e))return e}catch{}return Hot}function Vot(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Mte).matches}function JB(e){return{mode:e==="dark"||e==="system"&&Vot()?"dark":"light",...Uot}}function qot(e){let t=Wot();const n=new Set,r=()=>{const i=JB(t);for(const o of n)o(i)};typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(Mte).addEventListener("change",()=>{t==="system"&&r()});const s={gateway:{call:()=>Promise.reject(new Error("standalone-host: gateway.call not supported"))},self:{call:()=>Promise.reject(new Error("standalone-host: self.call removed; use useDaemonClient()"))},kv:{get:async i=>{const o=localStorage.getItem(`clawd-standalone:kv:${i}`);if(o==null)return null;try{return JSON.parse(o)}catch{return null}},set:async(i,o)=>{localStorage.setItem(`clawd-standalone:kv:${i}`,JSON.stringify(o))}},logger:{info:(i,o)=>{var l;console.info("[ext]",i,o??""),(l=e.logClient)==null||l.push({level:"info",msg:String(i),meta:o})},warn:(i,o)=>{var l;console.warn("[ext]",i,o??""),(l=e.logClient)==null||l.push({level:"warn",msg:String(i),meta:o})},error:(i,o)=>{var l;console.error("[ext]",i,o??""),(l=e.logClient)==null||l.push({level:"error",msg:String(i),meta:o})}},get theme(){return JB(t)},on(){return()=>{}},onThemeChange(i){return n.add(i),()=>{n.delete(i)}}};return s.getThemeSource=()=>t,s.setThemeSource=i=>{t=i;try{localStorage.setItem(Pte,i)}catch{}r()},e.notifier&&(s.notifier=e.notifier),s}var Kot={maxRecords:100,maxBytes:512*1024,maxWaitMs:5e3},Got=5e3,Ate={debug:0,info:1,warn:1,error:1},ez=1024,tz=2048,Yot=/token|secret|password|auth(?!or)|apikey|signsecret/i,Xot="[REDACTED]",Ote="…[truncated]";function Zot(e,t){const n=EI(e,t,0),r=Qot(n);return r.length<=tz?n:{__truncated__:r.slice(0,tz)+Ote}}function EI(e,t,n){if(n>10)return"[depth-limit]";if(e==null)return e;if(typeof e=="string")return t?e.split(t).join("~"):e;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>EI(s,t,n+1));const r={};for(const[s,i]of Object.entries(e))Yot.test(s)?r[s]=Xot:r[s]=EI(i,t,n+1);return r}function Qot(e){try{return JSON.stringify(e)??""}catch{return'"[serialize-failed]"'}}function Jot(e){return e.length<=ez?e:e.slice(0,ez)+Ote}function eat(e,t,n){const r=t[e]??Ate[e];return r<=0?!1:r>=1?!0:n()<r}var tat=class{constructor(e){Gs(this,"deps");Gs(this,"queue",[]);Gs(this,"bytes",0);Gs(this,"droppedSinceFlush",0);Gs(this,"identityReady",!1);Gs(this,"timer",null);Gs(this,"disposed",!1);Gs(this,"pendingSends",[]);this.deps=e}enqueue(e){if(this.disposed)return;const t=nat(e);for(;this.queue.length>=this.deps.bufferCap;)this.queue.shift(),this.droppedSinceFlush++;this.queue.push(e),this.bytes+=t,this.identityReady&&this.maybeTrigger()}setIdentityReady(e){this.identityReady=e,e&&this.queue.length>0&&this.maybeTrigger()}async flush(){this.queue.length>0&&this.fire("flush"),await Promise.allSettled(this.pendingSends)}stats(){return{queued:this.queue.length,dropped:this.droppedSinceFlush}}async dispose(){this.disposed||(this.disposed=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),await this.flush())}maybeTrigger(){const{maxRecords:e,maxBytes:t,maxWaitMs:n}=this.deps.batch;if(this.queue.length>=e){this.fire("records");return}if(this.bytes>=t){this.fire("bytes");return}this.timer==null&&(this.timer=setTimeout(()=>{this.timer=null,this.queue.length>0&&this.identityReady&&this.fire("time")},n))}fire(e){this.timer&&(clearTimeout(this.timer),this.timer=null);const t=this.queue,n=this.droppedSinceFlush;this.queue=[],this.bytes=0,this.droppedSinceFlush=0;const r=this.deps.onBatch({reason:e,records:t,droppedCarryover:n}).catch(()=>{});this.pendingSends.push(r),r.finally(()=>{this.pendingSends=this.pendingSends.filter(s=>s!==r)})}};function nat(e){var t,n;return(((t=e.msg)==null?void 0:t.length)??0)+(((n=e.meta_json)==null?void 0:n.length)??0)+200}var nz=[1e3,2e3,4e3];async function rat(e,t){const n=t.records.map(sat),r=JSON.stringify({__topic__:"clawd",__source__:e.source,__logs__:n,...t.droppedCarryover>0?{__tags__:{dropped:String(t.droppedCarryover)}}:{}});for(let s=0;s<nz.length;s++){s>0&&await iat(nz[s-1]);try{const i=await e.fetchImpl(e.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:r});if(i.status>=200&&i.status<300)return{sent:t.records.length,failed:0};if(i.status>=400&&i.status<500)return{sent:0,failed:t.records.length}}catch{}}return{sent:0,failed:t.records.length}}function sat(e){const t={};for(const[n,r]of Object.entries(e))r!=null&&(t[n]=typeof r=="string"?r:String(r));return t}function iat(e){return new Promise(t=>setTimeout(t,e))}function oat(e){const t={sent:0,dropped:0,queued:0,failed:0},n=e.fetchImpl??globalThis.fetch.bind(globalThis),r=e.now??Date.now,s={...Ate,...e.sampling??{}},i=e.homeDir===void 0?null:e.homeDir,o={...Kot,...e.batch??{}},l=e.bufferCap??Got;let c=e.identity,u=!1;if(e.endpoint==null)return{push:()=>{u||t.dropped++},flush:async()=>{},setIdentity:f=>{c=f},stats:()=>({...t}),dispose:async()=>{u=!0}};const d=e.endpoint,h=new tat({batch:o,bufferCap:l,now:r,onBatch:async f=>{const m=await rat({endpoint:d,source:e.source,fetchImpl:n},f);t.sent+=m.sent,t.failed+=m.failed}});return h.setIdentityReady(c!=null),{push(f){if(!u)try{if(!eat(f.level,s,Math.random)){t.dropped++;return}const m=aat(f,c,e.source,i,r);h.enqueue(m)}catch{}},async flush(){try{await h.flush()}catch{}},setIdentity(f){c=f,h.setIdentityReady(f!=null)},stats(){const f=h.stats();return{...t,queued:f.queued,dropped:t.dropped+f.dropped}},async dispose(){u=!0;try{await h.dispose()}catch{}}}}function aat(e,t,n,r,s){const i=e.meta?Zot(e.meta,r):void 0,o=i?JSON.stringify(i):void 0;return{ts:e.ts??s(),source:n,level:e.level,msg:Jot(e.msg),ownerPrincipalId:(t==null?void 0:t.ownerPrincipalId)??"__pending__",deviceId:(t==null?void 0:t.deviceId)??"__pending__",appVersion:(t==null?void 0:t.appVersion)??"__pending__",daemonVersion:t==null?void 0:t.daemonVersion,os:(t==null?void 0:t.os)??"unknown",meta_json:o,sessionId:e.sessionId}}function lat(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function cat({filePath:e,oldString:t,newString:n,content:r}){const s=p.useMemo(()=>r!=null?r.split(/\r?\n/).map(i=>({type:"add",text:i})):uat(t??"",n??""),[t,n,r]);return a.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:[a.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:a.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),a.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:s.map((i,o)=>a.jsxs("div",{"data-testid":`diff-line-${i.type}`,className:J("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",i.type==="add"?"bg-success/10 text-success":i.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[a.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:i.type==="add"?"+":i.type==="remove"?"-":" "}),a.jsx("span",{className:"flex-1",children:i.text||" "})]},o))})]})}function uat(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),s=n.length,i=r.length,o=Array.from({length:s+1},()=>new Array(i+1).fill(0));for(let d=s-1;d>=0;d--)for(let h=i-1;h>=0;h--)o[d][h]=n[d]===r[h]?o[d+1][h+1]+1:Math.max(o[d+1][h],o[d][h+1]);const l=[];let c=0,u=0;for(;c<s&&u<i;)n[c]===r[u]?(l.push({type:"equal",text:n[c]}),c++,u++):o[c+1][u]>=o[c][u+1]?(l.push({type:"remove",text:n[c]}),c++):(l.push({type:"add",text:r[u]}),u++);for(;c<s;)l.push({type:"remove",text:n[c++]});for(;u<i;)l.push({type:"add",text:r[u++]});return l}function dat({items:e}){return e.length===0?null:a.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),a.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return a.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[a.jsx(hat,{status:t.status}),a.jsx("span",{className:J("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 hat({status:e}){return e==="completed"?a.jsx(ui,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?a.jsx(st,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):a.jsx(OH,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function fat(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,s=typeof r.content=="string"?r.content:"",i=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:s,status:i,activeForm:o}}).filter(n=>n!==null):[]}function pat({description:e,prompt:t,subagentType:n}){return a.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[a.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[a.jsx(oa,{className:"w-3.5 h-3.5 text-accent shrink-0"}),a.jsx("span",{className:"truncate",children:e||"subagent task"}),n?a.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?a.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function mat(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 gat={render:({input:e})=>q.createElement(dat,{items:fat(e)})},xat={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=mat(e);return q.createElement(pat,{description:t,prompt:n,subagentType:r})}},rz={render:({input:e,output:t,error:n,pending:r,fileScope:s,onShareFile:i,onOpenInTab:o,onPreviewMarkdown:l})=>{const c=yat(e),u=c?q.createElement(cat,{filePath:c.filePath,oldString:c.oldString,newString:c.newString,content:c.content}):void 0;return q.createElement(gG,{tool:vat(e),input:e,output:t,error:n,pending:r,expandedBody:u,...s?{fileScope:s}:{},...i?{onShareFile:i}:{},...o?{onOpenInTab:o}:{},...l?{onPreviewMarkdown:l}:{}})}};function vat(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function yat(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,s=typeof t.new_string=="string"?t.new_string:void 0,i=typeof t.content=="string"?t.content:void 0;return r==null&&s==null&&i==null?null:{filePath:n,oldString:r,newString:s,content:i}}for(const e of["claude",Ace])uh.register(e,"TodoWrite",gat),uh.register(e,"Task",xat),uh.register(e,"Edit",rz),uh.register(e,"Write",rz);const N2={};function bat({urlSource:e,hostOverride:t,notifier:n,credentialSource:r}){const[s]=p.useState(()=>{if(t)return null;const d=N2==null?void 0:N2.VITE_CLAWD_LOG_ENDPOINT;return oat({endpoint:d==="off"?null:d??"https://clawd-prod.cn-hangzhou.log.aliyuncs.com/logstores/app-logs/track",identity:null,source:"renderer",homeDir:null})}),[i]=p.useState(()=>t??qot({notifier:n,...s?{logClient:s}:{}})),[o,l]=p.useState(null),[c,u]=p.useState(null);return p.useEffect(()=>{let d=!1;return Promise.resolve(e.getUrl(i)).then(h=>{d||l(h)}).catch(h=>{d||u(h instanceof Error?h.message:String(h))}),()=>{d=!0}},[e,i]),p.useEffect(()=>lat(i),[i]),c?a.jsxs("div",{className:"p-8 max-w-xl font-sans text-text-100","data-testid":"standalone-error",children:[a.jsx("h2",{className:"text-lg font-semibold mb-2",children:"无法发现 daemon"}),a.jsx("p",{className:"text-destructive mb-3",children:c}),a.jsxs("p",{className:"text-text-400 mb-3",children:["请确认 ",a.jsx("code",{className:"font-mono",children:"clawd"})," 已启动 (",a.jsx("code",{className:"font-mono",children:"cd clawd && pnpm dev"}),"),它会写入"," ",a.jsx("code",{className:"font-mono",children:"~/.clawd/state.json"}),"。"]}),a.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-1.5 text-sm rounded-md border border-border bg-elevated hover:bg-bg-100",children:"重试"})]}):o?a.jsx("div",{"data-testid":"standalone-root","data-mode":"url"in o?"has-url":"needs-setup",children:a.jsx(q.StrictMode,{children:a.jsx(VU.Provider,{value:r??null,children:a.jsx(awe,{client:s,children:a.jsx(Nie,{host:i,children:a.jsx(Tle,{children:a.jsx($ot,{})})})})})})}):a.jsx("div",{className:"p-8 font-sans text-text-400","data-testid":"standalone-resolving",children:"正在发现 daemon…"})}function wat(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}const E3="clawd-owner-web:session",sz="owner-web",_at="/app/session",Sat="ticket";class II extends Error{constructor(t){super(t),this.reason=t,this.name="OwnerSessionError"}}function kat(e){const t=e.startsWith("#")?e.slice(1):e,n=new URLSearchParams(t).get(Sat);return n&&n.length>0?n:null}function iz(e){try{const t=JSON.parse(e.storage.getItem(E3)??"null");if(t&&typeof t.token=="string"&&typeof t.expiresAt=="number"&&t.expiresAt>e.now())return{token:t.token,expiresAt:t.expiresAt}}catch{}return null}async function Cat(e,t){try{const n=await e.fetch(_at,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ticket:t}),cache:"no-store",credentials:"omit"});if(!n.ok)return null;const r=await n.json();if(typeof r.token=="string"&&typeof r.expiresAt=="number")return{token:r.token,expiresAt:r.expiresAt}}catch{}return null}async function Nat(e){const t=kat(e.location.hash);if(t){e.history.replaceState(null,"",`${e.location.pathname}${e.location.search}`);const r=await Cat(e,t);if(r)return e.storage.setItem(E3,JSON.stringify(r)),r;const s=iz(e);if(s)return s;throw new II("ticket-invalid")}const n=iz(e);if(n)return n;throw new II("no-session")}function jat(e){let t,n=null;const r=()=>(n??(n=Nat(e).then(s=>(t=s.token,s))),n);return{session:r,credentials:{profileId:sz,getToken:()=>t,invalidate:()=>{t=void 0;try{e.storage.removeItem(E3)}catch{}}},urlSource:{async getUrl(s){await r();const i=wat(e.location);return await GU(s).upsert({id:sz,name:"本机",mode:"localhost",url:i}),{url:i}}}}}function Eat({web:e}){const[t,n]=p.useState({kind:"connecting"});return p.useEffect(()=>{let r=!1;return e.session().then(()=>!r&&n("ready")).catch(s=>{r||n({kind:"reopen",reason:s instanceof II?s.reason:"no-session"})}),()=>{r=!0}},[e]),t!=="ready"?a.jsx(KU,{view:t}):a.jsx(bat,{urlSource:e.urlSource,credentialSource:e.credentials})}const oz=document.getElementById("root");if(oz){Xxe({name:"clawd-web",version:"unknown"});const e=jat({storage:window.sessionStorage,location:window.location,history:window.history,fetch:window.fetch.bind(window),now:()=>Date.now()});j2.createRoot(oz).render(a.jsx(q.StrictMode,{children:a.jsx(Eat,{web:e})}))}