@clawos-dev/clawd 0.2.397 → 0.2.399

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -6678,7 +6678,7 @@ var init_topic = __esm({
6678
6678
  init_zod();
6679
6679
  init_dispatch();
6680
6680
  nonBlank2 = external_exports.string().trim().min(1);
6681
- TOPIC_STATES = ["planning", "running", "done", "archived"];
6681
+ TOPIC_STATES = ["planning", "running", "done"];
6682
6682
  TopicStateSchema = external_exports.enum(TOPIC_STATES);
6683
6683
  TopicActivityEntrySchema = external_exports.object({
6684
6684
  at: external_exports.string().min(1),
@@ -6786,7 +6786,9 @@ var init_topic = __esm({
6786
6786
  });
6787
6787
  TopicCloseArgsSchema = external_exports.object({
6788
6788
  topicId: external_exports.string().min(1),
6789
- state: external_exports.enum(["done", "archived"])
6789
+ // 单值 enum 而不是 z.literal:缺字段时 enum 报 invalid_type、literal 报 invalid_literal,
6790
+ // 而 method-args-contract 的必填探测只认前者(literal 会让 state 被判成非必填)。
6791
+ state: external_exports.enum(["done"])
6790
6792
  });
6791
6793
  TopicRenameArgsSchema = external_exports.object({
6792
6794
  topicId: external_exports.string().min(1),
@@ -8539,7 +8541,7 @@ var init_methods = __esm({
8539
8541
  }
8540
8542
  },
8541
8543
  "topic:close": {
8542
- summary: "\u6536\u655B\u8BDD\u9898\uFF1Astate \u7F6E done / archived",
8544
+ summary: "\u6536\u655B\u8BDD\u9898\uFF1Astate \u7F6E done\u3002\u5F52\u6863\u4E0D\u8D70\u8FD9\u91CC\uFF08\u5F52\u6863\u6253\u5728\u8BE5\u8BDD\u9898 Master \u4F1A\u8BDD\u7684 archivedAt \u4E0A\uFF09",
8543
8545
  args: TopicCloseArgsSchema
8544
8546
  },
8545
8547
  "topic:rename": {
@@ -52907,7 +52909,19 @@ function createTopicStore(deps) {
52907
52909
  };
52908
52910
  const lineMetaOf = (t, lineId) => t.lineMeta[lineId] ??= { rejectCount: 0, accepted: false, overrideCount: 0 };
52909
52911
  return {
52910
- load: file.load,
52912
+ /**
52913
+ * 读盘后把存量 `state: 'archived'` 归一成 `'done'`。
52914
+ *
52915
+ * 归档已改由该话题 Master 会话的 `archivedAt` 承载(spec 2026-08-25-topic-archive-and-pin),
52916
+ * `TOPIC_STATES` 随之退掉那一档。json-store 读盘本身不过 zod,但 `topic:list` 的响应要过
52917
+ * `TopicListResultSchema.parse` —— 留着这个值会让**整个频道**的话题列表 parse 失败。
52918
+ */
52919
+ async load() {
52920
+ await file.load();
52921
+ for (const t of file.all()) {
52922
+ if (t.state === "archived") t.state = "done";
52923
+ }
52924
+ },
52911
52925
  flushNow: file.flushNow,
52912
52926
  get,
52913
52927
  getByMasterSession: (masterSessionId) => file.all().find((t) => t.masterSessionId === masterSessionId),
@@ -62099,7 +62113,7 @@ function computeMethodAccess(args) {
62099
62113
  }
62100
62114
 
62101
62115
  // src/version.ts
62102
- var version = "0.2.397".length > 0 ? "0.2.397" : "dev";
62116
+ var version = "0.2.399".length > 0 ? "0.2.399" : "dev";
62103
62117
 
62104
62118
  // src/cli-probe/probe.ts
62105
62119
  var fs66 = __toESM(require("fs"), 1);
@@ -21866,7 +21866,7 @@ var ChannelDeleteResultSchema = external_exports.object({
21866
21866
 
21867
21867
  // ../protocol/src/topic.ts
21868
21868
  var nonBlank2 = external_exports.string().trim().min(1);
21869
- var TOPIC_STATES = ["planning", "running", "done", "archived"];
21869
+ var TOPIC_STATES = ["planning", "running", "done"];
21870
21870
  var TopicStateSchema = external_exports.enum(TOPIC_STATES);
21871
21871
  var TopicActivityEntrySchema = external_exports.object({
21872
21872
  at: external_exports.string().min(1),
@@ -21974,7 +21974,9 @@ var TopicAcceptArgsSchema = external_exports.object({
21974
21974
  });
21975
21975
  var TopicCloseArgsSchema = external_exports.object({
21976
21976
  topicId: external_exports.string().min(1),
21977
- state: external_exports.enum(["done", "archived"])
21977
+ // 单值 enum 而不是 z.literal:缺字段时 enum 报 invalid_type、literal 报 invalid_literal,
21978
+ // 而 method-args-contract 的必填探测只认前者(literal 会让 state 被判成非必填)。
21979
+ state: external_exports.enum(["done"])
21978
21980
  });
21979
21981
  var TopicRenameArgsSchema = external_exports.object({
21980
21982
  topicId: external_exports.string().min(1),
@@ -23599,7 +23601,7 @@ var METHOD_DOCS = {
23599
23601
  }
23600
23602
  },
23601
23603
  "topic:close": {
23602
- summary: "\u6536\u655B\u8BDD\u9898\uFF1Astate \u7F6E done / archived",
23604
+ summary: "\u6536\u655B\u8BDD\u9898\uFF1Astate \u7F6E done\u3002\u5F52\u6863\u4E0D\u8D70\u8FD9\u91CC\uFF08\u5F52\u6863\u6253\u5728\u8BE5\u8BDD\u9898 Master \u4F1A\u8BDD\u7684 archivedAt \u4E0A\uFF09",
23603
23605
  args: TopicCloseArgsSchema
23604
23606
  },
23605
23607
  "topic:rename": {
@@ -151,9 +151,11 @@ worker 干到一半上报「答不了的问题」(它会以回报形式带出
151
151
  `topic:accept` 返回 `allAccepted: true` → 合并 → 自己先验一遍 → 交付。
152
152
  给老板:**结论优先,流水在后**。收敛判据看 daemon 给的 `allAccepted`,不要自己数线。
153
153
 
154
- **话题状态不用你收**:最后一条线判合格时 daemon 自己把话题推到 `done`(老板在频道
155
- flyout 里看到的就是这个状态);已收敛的话题被打回一条线会自动退回 `running`。
156
- `topic:close` 只用于老板要归档(`archived`)的场合。
154
+ **话题状态不用你收**:最后一条线判合格时 daemon 自己把话题推到 `done`(老板在 sidebar
155
+ 频道分区的话题行上看到的就是这个状态);已收敛的话题被打回一条线会自动退回 `running`。
156
+
157
+ **归档不归你管**:归档是老板的显式动作,落在该话题 Master 会话上(`session:archive`),
158
+ 不是话题状态的一档 —— `topic:close` 只收 `done`。你没有归档入口,也不需要有。
157
159
 
158
160
  ## 落账纪律(硬性)
159
161
 
@@ -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 lw=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const UD={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},WD={motionBase:!0,motionUnit:!0},VD={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},oT=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=lw(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=sT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=lw(l,["theme"]);let d=u;c&&(d=oT(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function aT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Qe.useContext(rT),s=`${FD}-${t||""}`,o=n||nT,[a,l,c]=RL(o,[qc,e],{salt:s,override:r,getComputedToken:oT,formatToken:sT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:UD,ignore:WD,preserve:VD}});return[o,c,t?l:"",a,i]}const qD=()=>({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"}}),KD=e=>({[`.${e}`]:Object.assign(Object.assign({},qD()),{[`.${e} .${e}-icon`]:{display:"block"}})}),GD=(e,t)=>{const[n,r]=aT();return sD({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>KD(e))},YD=Object.assign({},rl),{useId:cw}=YD,XD=()=>"",ZD=typeof cw>"u"?XD:cw;function QD(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},Wh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Wh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=ZD();return CN(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!sL(c,d,!0)}))}var JD=["children"],lT=g.createContext({});function eO(e){var t=e.children,n=jv(e,JD);return g.createElement(lT.Provider,{value:n},t)}var tO=function(e){NN(n,e);var t=IN(n);function n(){return al(this,n),t.apply(this,arguments)}return ll(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function nO(e){var t=g.useReducer(function(a){return a+1},0),n=Je(t,2),r=n[1],i=g.useRef(e),s=n0(function(){return i.current}),o=n0(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var is="none",cd="appear",ud="enter",dd="leave",uw="none",Pr="prepare",va="start",xa="active",B_="end",cT="prepared";function dw(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 rO(e,t){var n={animationend:dw("Animation","AnimationEnd"),transitionend:dw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var iO=rO(Ui(),typeof window<"u"?window:{}),uT={};if(Ui()){var sO=document.createElement("div");uT=sO.style}var hd={};function dT(e){if(hd[e])return hd[e];var t=iO[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in uT)return hd[e]=t[s],hd[e]}return""}var hT=dT("animationend"),fT=dT("transitionend"),pT=!!(hT&&fT),hw=hT||"animationend",fw=fT||"transitionend";function pw(e,t){if(!e)return null;if(Nt(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const oO=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(fw,e),i.removeEventListener(hw,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(fw,e),i.addEventListener(hw,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var mT=Ui()?g.useLayoutEffect:g.useEffect;const aO=function(){var e=g.useRef(null);function t(){Mv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Mv(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var lO=[Pr,va,xa,B_],cO=[Pr,cT],gT=!1,uO=!0;function vT(e){return e===xa||e===B_}const dO=function(e,t,n){var r=r0(uw),i=Je(r,2),s=i[0],o=i[1],a=aO(),l=Je(a,2),c=l[0],u=l[1];function d(){o(Pr,!0)}var f=t?cO:lO;return mT(function(){if(s!==uw&&s!==B_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===gT?o(m,!0):m&&c(function(b){function x(){b.isCanceled()||o(m,!0)}v===!0?x():Promise.resolve(v).then(x)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function hO(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,b=r.onEnterStart,x=r.onLeaveStart,_=r.onAppearActive,y=r.onEnterActive,S=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,T=r.onVisibleChanged,z=r0(),I=Je(z,2),M=I[0],L=I[1],R=nO(is),A=Je(R,2),D=A[0],$=A[1],F=r0(null),O=Je(F,2),B=O[0],E=O[1],H=D(),q=g.useRef(!1),j=g.useRef(null);function ne(){return n()}var re=g.useRef(!1);function G(){$(is),E(null,!0)}var ve=n0(function(Xe){var st=D();if(st!==is){var At=ne();if(!(Xe&&!Xe.deadline&&Xe.target!==At)){var Xt=re.current,pn;st===cd&&Xt?pn=C==null?void 0:C(At,Xe):st===ud&&Xt?pn=k==null?void 0:k(At,Xe):st===dd&&Xt&&(pn=N==null?void 0:N(At,Xe)),Xt&&pn!==!1&&G()}}}),ze=oO(ve),he=Je(ze,1),Ie=he[0],Re=function(st){switch(st){case cd:return Ce(Ce(Ce({},Pr,f),va,v),xa,_);case ud:return Ce(Ce(Ce({},Pr,p),va,b),xa,y);case dd:return Ce(Ce(Ce({},Pr,m),va,x),xa,S);default:return{}}},Ve=g.useMemo(function(){return Re(H)},[H]),xe=dO(H,!e,function(Xe){if(Xe===Pr){var st=Ve[Pr];return st?st(ne()):gT}if(it in Ve){var At;E(((At=Ve[it])===null||At===void 0?void 0:At.call(Ve,ne(),null))||null)}return it===xa&&H!==is&&(Ie(ne()),u>0&&(clearTimeout(j.current),j.current=setTimeout(function(){ve({deadline:!0})},u))),it===cT&&G(),uO}),Ke=Je(xe,2),Cn=Ke[0],it=Ke[1],ct=vT(it);re.current=ct;var on=g.useRef(null);mT(function(){if(!(q.current&&on.current===t)){L(t);var Xe=q.current;q.current=!0;var st;!Xe&&t&&a&&(st=cd),Xe&&t&&s&&(st=ud),(Xe&&!t&&c||!Xe&&d&&!t&&c)&&(st=dd);var At=Re(st);st&&(e||At[Pr])?($(st),Cn()):$(is),on.current=t}},[t]),g.useEffect(function(){(H===cd&&!a||H===ud&&!s||H===dd&&!c)&&$(is)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(j.current)}},[]);var gt=g.useRef(!1);g.useEffect(function(){M&&(gt.current=!0),M!==void 0&&H===is&&((gt.current||M)&&(T==null||T(M)),gt.current=!0)},[M,H]);var vt=B;return Ve[Pr]&&it===va&&(vt=$e({transition:"none"},vt)),[H,it,vt,M??t]}function fO(e){var t=e;Nt(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(lT),b=v.motion,x=n(i,b),_=g.useRef(),y=g.useRef();function S(){try{return _.current instanceof HTMLElement?_.current:Hj(y.current)}catch{return null}}var C=hO(x,a,S,i),k=Je(C,4),N=k[0],T=k[1],z=k[2],I=k[3],M=g.useRef(I);I&&(M.current=!0);var L=g.useCallback(function(O){_.current=O,qj(s,O)},[s]),R,A=$e($e({},m),{},{visible:a});if(!d)R=null;else if(N===is)I?R=d($e({},A),L):!c&&M.current&&p?R=d($e($e({},A),{},{className:p}),L):u||!c&&!p?R=d($e($e({},A),{},{style:{display:"none"}}),L):R=null;else{var D;T===Pr?D="prepare":vT(T)?D="active":T===va&&(D="start");var $=pw(f,"".concat(N,"-").concat(D));R=d($e($e({},A),{},{className:Pj(pw(f,N),Ce(Ce({},$,$&&D),f,typeof f=="string")),style:z}),L)}if(g.isValidElement(R)&&Kj(R)){var F=Gj(R);F||(R=g.cloneElement(R,{ref:L}))}return g.createElement(tO,{ref:y},R)});return r.displayName="CSSMotion",r}const pO=fO(pT);var i0="add",s0="keep",o0="remove",Im="removed";function mO(e){var t;return e&&Nt(e)==="object"&&"key"in e?t=e:t={key:e},$e($e({},t),{},{key:String(t.key)})}function a0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(mO)}function gO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=a0(e),o=a0(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return $e($e({},p),{},{status:i0})})),r=d),n.push($e($e({},f),{},{status:s0})),r+=1,u=!0;break}}u||n.push($e($e({},c),{},{status:o0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return $e($e({},c),{},{status:i0})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==o0}),n.forEach(function(u){u.key===c&&(u.status=s0)})}),n}var vO=["component","children","onVisibleChanged","onAllRemoved"],xO=["status"],_O=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function yO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:pO,n=function(r){NN(s,r);var i=IN(s);function s(){var o;al(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),Ce(Pv(o),"state",{keyEntities:[]}),Ce(Pv(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:$e($e({},p),{},{status:Im})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Im}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return ll(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=jv(c,vO),m=u||g.Fragment,v={};return _O.forEach(function(b){v[b]=p[b],delete p[b]}),delete p.keys,g.createElement(m,p,l.map(function(b,x){var _=b.status,y=jv(b,xO),S=_===i0||_===s0;return g.createElement(t,Fh({},v,{key:y.key,visible:S,eventProps:y,onVisibleChanged:function(k){f==null||f(k,{key:y.key}),k||a.removeKey(y.key)}}),function(C,k){return d($e($e({},C),{},{index:x}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=a0(c),f=gO(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var b=v.key;return p.key===b});return!(m&&m.status===Im&&p.status===o0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}yO(pT);const mw=g.createContext(!0);function bO(e){const t=g.useContext(mw),{children:n}=e,[,r]=aT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(mw.Provider,{value:i},g.createElement(eO,{motion:i},n)):n}const wO=()=>null;var SO=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const kO=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let xT;function CO(){return xT||e0}function EO(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const NO=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(xT=t),r&&EO(r)&&LD(CO(),r)},TO=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:b,parentContext:x,iconPrefixCls:_,theme:y,componentDisabled:S,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:I,collapse:M,typography:L,checkbox:R,descriptions:A,divider:D,drawer:$,skeleton:F,steps:O,image:B,layout:E,list:H,mentions:q,modal:j,progress:ne,result:re,slider:G,breadcrumb:ve,menu:ze,pagination:he,input:Ie,textArea:Re,empty:Ve,badge:xe,radio:Ke,rate:Cn,switch:it,transfer:ct,avatar:on,message:gt,tag:vt,table:Xe,card:st,tabs:At,timeline:Xt,timePicker:pn,upload:U,notification:J,tree:ye,colorPicker:ke,datePicker:Ue,rangePicker:kt,flex:an,wave:Ft,dropdown:le,warning:K,tour:we,tooltip:ft,popover:ln,popconfirm:Sl,floatButton:kl,floatButtonGroup:Cl,variant:Vp,inputNumber:qp,treeSelect:Fu}=e,Hu=g.useCallback((Pt,jt)=>{const{prefixCls:Z}=e;if(jt)return jt;const fe=Z||x.getPrefixCls("");return Pt?`${fe}-${Pt}`:fe},[x.getPrefixCls,e.prefixCls]),Ws=_||x.iconPrefixCls||iT,Vs=n||x.csp;GD(Ws,Vs);const El=QD(y,x.theme,{prefixCls:Hu("")}),Ho={csp:Vs,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||b,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Hu,iconPrefixCls:Ws,theme:El,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:I,collapse:M,typography:L,checkbox:R,descriptions:A,divider:D,drawer:$,skeleton:F,steps:O,image:B,input:Ie,textArea:Re,layout:E,list:H,mentions:q,modal:j,progress:ne,result:re,slider:G,breadcrumb:ve,menu:ze,pagination:he,empty:Ve,badge:xe,radio:Ke,rate:Cn,switch:it,transfer:ct,avatar:on,message:gt,tag:vt,table:Xe,card:st,tabs:At,timeline:Xt,timePicker:pn,upload:U,notification:J,tree:ye,colorPicker:ke,datePicker:Ue,rangePicker:kt,flex:an,wave:Ft,dropdown:le,warning:K,tour:we,tooltip:ft,popover:ln,popconfirm:Sl,floatButton:kl,floatButtonGroup:Cl,variant:Vp,inputNumber:qp,treeSelect:Fu},Fr=Object.assign({},x);Object.keys(Ho).forEach(Pt=>{Ho[Pt]!==void 0&&(Fr[Pt]=Ho[Pt])}),kO.forEach(Pt=>{const jt=e[Pt];jt&&(Fr[Pt]=jt)}),typeof r<"u"&&(Fr.button=Object.assign({autoInsertSpace:r},Fr.button));const Xi=CN(()=>Fr,Fr,(Pt,jt)=>{const Z=Object.keys(Pt),fe=Object.keys(jt);return Z.length!==fe.length||Z.some(be=>Pt[be]!==jt[be])}),{layer:qs}=g.useContext(tp),Kp=g.useMemo(()=>({prefixCls:Ws,csp:Vs,layer:qs?"antd":void 0}),[Ws,Vs,qs]);let Ht=g.createElement(g.Fragment,null,g.createElement(wO,{dropdownMatchSelectWidth:p}),t);const Uo=g.useMemo(()=>{var Pt,jt,Z,fe;return fD(((Pt=ip.Form)===null||Pt===void 0?void 0:Pt.defaultValidateMessages)||{},((Z=(jt=Xi.locale)===null||jt===void 0?void 0:jt.Form)===null||Z===void 0?void 0:Z.defaultValidateMessages)||{},((fe=Xi.form)===null||fe===void 0?void 0:fe.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Xi,o==null?void 0:o.validateMessages]);Object.keys(Uo).length>0&&(Ht=g.createElement(mD.Provider,{value:Uo},Ht)),a&&(Ht=g.createElement(xD,{locale:a,_ANT_MARK__:vD},Ht)),Ht=g.createElement(cD.Provider,{value:Kp},Ht),l&&(Ht=g.createElement(OD,{size:l},Ht)),Ht=g.createElement(bO,null,Ht);const Wo=g.useMemo(()=>{const Pt=El||{},{algorithm:jt,token:Z,components:fe,cssVar:be}=Pt,Ze=SO(Pt,["algorithm","token","components","cssVar"]),Cr=jt&&(!Array.isArray(jt)||jt.length>0)?Dv(jt):nT,Vo={};Object.entries(fe||{}).forEach(([YA,XA])=>{const xi=Object.assign({},XA);"algorithm"in xi&&(xi.algorithm===!0?xi.theme=Cr:(Array.isArray(xi.algorithm)||typeof xi.algorithm=="function")&&(xi.theme=Dv(xi.algorithm)),delete xi.algorithm),Vo[YA]=xi});const S1=Object.assign(Object.assign({},qc),Z);return Object.assign(Object.assign({},Ze),{theme:Cr,token:S1,components:Vo,override:Object.assign({override:S1},Vo),cssVar:be})},[El]);return y&&(Ht=g.createElement(rT.Provider,{value:Wo},Ht)),Xi.warning&&(Ht=g.createElement(pD.Provider,{value:Xi.warning},Ht)),S!==void 0&&(Ht=g.createElement(DD,{disabled:S},Ht)),g.createElement(sp.Provider,{value:Xi},Ht)},ul=e=>{const t=g.useContext(sp),n=g.useContext(QN);return g.createElement(TO,Object.assign({parentContext:t,legacyLocale:n},e))};ul.ConfigContext=sp;ul.SizeContext=Kc;ul.config=NO;ul.useConfig=BD;Object.defineProperty(ul,"SizeContext",{get:()=>Kc});const cr=(e,t)=>new bt(e).setA(t).toRgbString(),Go=(e,t)=>new bt(e).lighten(t).toHexString(),IO=e=>{const t=Ha(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]}},PO=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:cr(r,.85),colorTextSecondary:cr(r,.65),colorTextTertiary:cr(r,.45),colorTextQuaternary:cr(r,.25),colorFill:cr(r,.18),colorFillSecondary:cr(r,.12),colorFillTertiary:cr(r,.08),colorFillQuaternary:cr(r,.04),colorBgSolid:cr(r,.95),colorBgSolidHover:cr(r,1),colorBgSolidActive:cr(r,.9),colorBgElevated:Go(n,12),colorBgContainer:Go(n,8),colorBgLayout:Go(n,0),colorBgSpotlight:Go(n,26),colorBgBlur:cr(r,.04),colorBorder:Go(n,26),colorBorderSecondary:Go(n,19)}},RO=(e,t)=>{const n=Object.keys(D_).map(s=>{const o=Ha(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??O_(e),i=tT(e,{generateColorPalettes:IO,generateNeutralColorPalettes:PO});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},gw={defaultSeed:Wh.token,defaultAlgorithm:O_,darkAlgorithm:RO};function vw({children:e}){const t=T_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(ul,{theme:{algorithm:n.mode==="dark"?gw.darkAlgorithm:gw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ge;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ge||(Ge={}));var xw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(xw||(xw={}));const ue=Ge.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ls=e=>{switch(typeof e){case"undefined":return ue.undefined;case"string":return ue.string;case"number":return Number.isNaN(e)?ue.nan:ue.number;case"boolean":return ue.boolean;case"function":return ue.function;case"bigint":return ue.bigint;case"symbol":return ue.symbol;case"object":return Array.isArray(e)?ue.array:e===null?ue.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ue.promise:typeof Map<"u"&&e instanceof Map?ue.map:typeof Set<"u"&&e instanceof Set?ue.set:typeof Date<"u"&&e instanceof Date?ue.date:ue.object;default:return ue.unknown}},Y=Ge.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Bi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Bi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ge.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Bi.create=e=>new Bi(e);const l0=(e,t)=>{let n;switch(e.code){case Y.invalid_type:e.received===ue.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ge.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ge.joinValues(e.keys,", ")}`;break;case Y.invalid_union:n="Invalid input";break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ge.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Ge.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n="Invalid function arguments";break;case Y.invalid_return_type:n="Invalid function return type";break;case Y.invalid_date:n="Invalid date";break;case Y.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ge.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Y.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 Y.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 Y.custom:n="Invalid input";break;case Y.invalid_intersection_types:n="Intersection results could not be merged";break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ge.assertNever(e)}return{message:n}};let MO=l0;function AO(){return MO}const jO=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function ie(e,t){const n=AO(),r=jO({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===l0?void 0:l0].filter(i=>!!i)});e.common.issues.push(r)}class Rn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Ne;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Rn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Ne;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Ne=Object.freeze({status:"aborted"}),Ql=e=>({status:"dirty",value:e}),kr=e=>({status:"valid",value:e}),_w=e=>e.status==="aborted",yw=e=>e.status==="dirty",Ua=e=>e.status==="valid",Vh=e=>typeof Promise<"u"&&e instanceof Promise;var ge;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ge||(ge={}));class li{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const bw=(e,t)=>{if(Ua(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 Bi(e.common.issues);return this._error=n,this._error}}};function je(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class We{get description(){return this._def.description}_getType(t){return ls(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ls(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Rn,ctx:{common:t.parent.common,data:t.data,parsedType:ls(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Vh(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:ls(t)},i=this._parseSync({data:t,path:r.path,parent:r});return bw(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ls(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Ua(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>Ua(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ls(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Vh(i)?i:Promise.resolve(i));return bw(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:Y.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new bo({schema:this,typeName:Te.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 Mi.create(this,this._def)}nullable(){return wo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ii.create(this)}promise(){return Zh.create(this,this._def)}or(t){return Kh.create([this,t],this._def)}and(t){return Gh.create(this,t,this._def)}transform(t){return new bo({...je(this._def),schema:this,typeName:Te.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Qh({...je(this._def),innerType:this,defaultValue:n,typeName:Te.ZodDefault})}brand(){return new wT({typeName:Te.ZodBranded,type:this,...je(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Jh({...je(this._def),innerType:this,catchValue:n,typeName:Te.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return $_.create(this,t)}readonly(){return ef.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const LO=/^c[^\s-]{8,}$/i,DO=/^[0-9a-z]+$/,OO=/^[0-9A-HJKMNP-TV-Z]{26}$/i,BO=/^[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,zO=/^[a-z0-9_-]{21}$/i,$O=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,FO=/^[-+]?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)?)??$/,HO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,UO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pm;const WO=/^(?:(?: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])$/,VO=/^(?:(?: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])$/,qO=/^(([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]))$/,KO=/^(([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])$/,GO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,YO=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_T="((\\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])))",XO=new RegExp(`^${_T}$`);function yT(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 ZO(e){return new RegExp(`^${yT(e)}$`)}function QO(e){let t=`${_T}T${yT(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 JO(e,t){return!!((t==="v4"||!t)&&WO.test(e)||(t==="v6"||!t)&&qO.test(e))}function e6(e,t){if(!$O.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function t6(e,t){return!!((t==="v4"||!t)&&VO.test(e)||(t==="v6"||!t)&&KO.test(e))}class Ti extends We{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ue.string){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.string,received:s.parsedType}),Ne}const r=new Rn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?ie(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ie(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")HO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"email",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Pm||(Pm=new RegExp(UO,"u")),Pm.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"emoji",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")BO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"uuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")zO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"nanoid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")LO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")DO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid2",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")OO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ulid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),ie(i,{validation:"url",code:Y.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"regex",code:Y.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?QO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?XO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?ZO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?FO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"duration",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?JO(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ip",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?e6(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"jwt",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?t6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cidr",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?GO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?YO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64url",code:Y.invalid_string,message:s.message}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Y.invalid_string,...ge.errToObj(r)})}_addCheck(t){return new Ti({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ge.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ge.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ge.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ge.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ge.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ge.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ge.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ge.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ge.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ge.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ge.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ge.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ge.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,...ge.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,...ge.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...ge.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ge.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ge.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ge.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ge.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ge.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ge.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ge.errToObj(n)})}nonempty(t){return this.min(1,ge.errToObj(t))}trim(){return new Ti({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ti({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ti({...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}}Ti.create=e=>new Ti({checks:[],typeName:Te.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});function n6(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class Wa extends We{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)!==ue.number){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.number,received:s.parsedType}),Ne}let r;const i=new Rn;for(const s of this._def.checks)s.kind==="int"?Ge.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?n6(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.not_finite,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new Wa({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Wa({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ge.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ge.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ge.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ge.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ge.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Wa.create=e=>new Wa({checks:[],typeName:Te.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class Gc extends We{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)!==ue.bigint)return this._getInvalidInput(t);let r;const i=new Rn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:ue.bigint,received:n.parsedType}),Ne}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new Gc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Gc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.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}}Gc.create=e=>new Gc({checks:[],typeName:Te.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});class c0 extends We{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ue.boolean){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.boolean,received:r.parsedType}),Ne}return kr(t.data)}}c0.create=e=>new c0({typeName:Te.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class qh extends We{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ue.date){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.date,received:s.parsedType}),Ne}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_date}),Ne}const r=new Rn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new qh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ge.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ge.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}}qh.create=e=>new qh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Te.ZodDate,...je(e)});class ww extends We{_parse(t){if(this._getType(t)!==ue.symbol){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.symbol,received:r.parsedType}),Ne}return kr(t.data)}}ww.create=e=>new ww({typeName:Te.ZodSymbol,...je(e)});class u0 extends We{_parse(t){if(this._getType(t)!==ue.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.undefined,received:r.parsedType}),Ne}return kr(t.data)}}u0.create=e=>new u0({typeName:Te.ZodUndefined,...je(e)});class d0 extends We{_parse(t){if(this._getType(t)!==ue.null){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.null,received:r.parsedType}),Ne}return kr(t.data)}}d0.create=e=>new d0({typeName:Te.ZodNull,...je(e)});class Sw extends We{constructor(){super(...arguments),this._any=!0}_parse(t){return kr(t.data)}}Sw.create=e=>new Sw({typeName:Te.ZodAny,...je(e)});class h0 extends We{constructor(){super(...arguments),this._unknown=!0}_parse(t){return kr(t.data)}}h0.create=e=>new h0({typeName:Te.ZodUnknown,...je(e)});class Rs extends We{_parse(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:ue.never,received:n.parsedType}),Ne}}Rs.create=e=>new Rs({typeName:Te.ZodNever,...je(e)});class kw extends We{_parse(t){if(this._getType(t)!==ue.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.void,received:r.parsedType}),Ne}return kr(t.data)}}kw.create=e=>new kw({typeName:Te.ZodVoid,...je(e)});class ii extends We{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ue.array)return ie(n,{code:Y.invalid_type,expected:ue.array,received:n.parsedType}),Ne;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(ie(n,{code:o?Y.too_big:Y.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(ie(n,{code:Y.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(ie(n,{code:Y.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new li(n,o,n.path,a)))).then(o=>Rn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new li(n,o,n.path,a)));return Rn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ii({...this._def,minLength:{value:t,message:ge.toString(n)}})}max(t,n){return new ii({...this._def,maxLength:{value:t,message:ge.toString(n)}})}length(t,n){return new ii({...this._def,exactLength:{value:t,message:ge.toString(n)}})}nonempty(t){return this.min(1,t)}}ii.create=(e,t)=>new ii({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Te.ZodArray,...je(t)});function ra(e){if(e instanceof Ot){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Mi.create(ra(r))}return new Ot({...e._def,shape:()=>t})}else return e instanceof ii?new ii({...e._def,type:ra(e.element)}):e instanceof Mi?Mi.create(ra(e.unwrap())):e instanceof wo?wo.create(ra(e.unwrap())):e instanceof _o?_o.create(e.items.map(t=>ra(t))):e}class Ot extends We{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ge.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ue.object){const c=this._getOrReturnCtx(t);return ie(c,{code:Y.invalid_type,expected:ue.object,received:c.parsedType}),Ne}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Rs&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new li(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Rs){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(ie(i,{code:Y.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new li(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Rn.mergeObjectSync(r,c)):Rn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return ge.errToObj,new Ot({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:ge.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ot({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ot({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Te.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Ot({...this._def,catchall:t})}pick(t){const n={};for(const r of Ge.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Ot({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ge.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Ot({...this._def,shape:()=>n})}deepPartial(){return ra(this)}partial(t){const n={};for(const r of Ge.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Ot({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ge.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Mi;)s=s._def.innerType;n[r]=s}return new Ot({...this._def,shape:()=>n})}keyof(){return bT(Ge.objectKeys(this.shape))}}Ot.create=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strip",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});Ot.strictCreate=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strict",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});Ot.lazycreate=(e,t)=>new Ot({shape:e,unknownKeys:"strip",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});class Kh extends We{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Bi(a.ctx.common.issues));return ie(n,{code:Y.invalid_union,unionErrors:o}),Ne}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Bi(l));return ie(n,{code:Y.invalid_union,unionErrors:a}),Ne}}get options(){return this._def.options}}Kh.create=(e,t)=>new Kh({options:e,typeName:Te.ZodUnion,...je(t)});const wi=e=>e instanceof p0?wi(e.schema):e instanceof bo?wi(e.innerType()):e instanceof Xh?[e.value]:e instanceof yo?e.options:e instanceof m0?Ge.objectValues(e.enum):e instanceof Qh?wi(e._def.innerType):e instanceof u0?[void 0]:e instanceof d0?[null]:e instanceof Mi?[void 0,...wi(e.unwrap())]:e instanceof wo?[null,...wi(e.unwrap())]:e instanceof wT||e instanceof ef?wi(e.unwrap()):e instanceof Jh?wi(e._def.innerType):[];class z_ extends We{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ue.object)return ie(n,{code:Y.invalid_type,expected:ue.object,received:n.parsedType}),Ne;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(ie(n,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ne)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=wi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new z_({typeName:Te.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...je(r)})}}function f0(e,t){const n=ls(e),r=ls(t);if(e===t)return{valid:!0,data:e};if(n===ue.object&&r===ue.object){const i=Ge.objectKeys(t),s=Ge.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=f0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ue.array&&r===ue.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=f0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ue.date&&r===ue.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Gh extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(_w(s)||_w(o))return Ne;const a=f0(s.value,o.value);return a.valid?((yw(s)||yw(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:Y.invalid_intersection_types}),Ne)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Gh.create=(e,t,n)=>new Gh({left:e,right:t,typeName:Te.ZodIntersection,...je(n)});class _o extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ue.array)return ie(r,{code:Y.invalid_type,expected:ue.array,received:r.parsedType}),Ne;if(r.data.length<this._def.items.length)return ie(r,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ne;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:Y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new li(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Rn.mergeArray(n,o)):Rn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new _o({...this._def,rest:t})}}_o.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _o({items:e,typeName:Te.ZodTuple,rest:null,...je(t)})};class Yh extends We{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!==ue.object)return ie(r,{code:Y.invalid_type,expected:ue.object,received:r.parsedType}),Ne;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new li(r,a,r.path,a)),value:o._parse(new li(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Rn.mergeObjectAsync(n,i):Rn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof We?new Yh({keyType:t,valueType:n,typeName:Te.ZodRecord,...je(r)}):new Yh({keyType:Ti.create(),valueType:t,typeName:Te.ZodRecord,...je(n)})}}class Cw extends We{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!==ue.map)return ie(r,{code:Y.invalid_type,expected:ue.map,received:r.parsedType}),Ne;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new li(r,a,r.path,[c,"key"])),value:s._parse(new li(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Ne;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Ne;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Cw.create=(e,t,n)=>new Cw({valueType:t,keyType:e,typeName:Te.ZodMap,...je(n)});class Yc extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ue.set)return ie(r,{code:Y.invalid_type,expected:ue.set,received:r.parsedType}),Ne;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(ie(r,{code:Y.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(ie(r,{code:Y.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Ne;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new li(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Yc({...this._def,minSize:{value:t,message:ge.toString(n)}})}max(t,n){return new Yc({...this._def,maxSize:{value:t,message:ge.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Yc.create=(e,t)=>new Yc({valueType:e,minSize:null,maxSize:null,typeName:Te.ZodSet,...je(t)});class p0 extends We{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})}}p0.create=(e,t)=>new p0({getter:e,typeName:Te.ZodLazy,...je(t)});class Xh extends We{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ie(n,{received:n.data,code:Y.invalid_literal,expected:this._def.value}),Ne}return{status:"valid",value:t.data}}get value(){return this._def.value}}Xh.create=(e,t)=>new Xh({value:e,typeName:Te.ZodLiteral,...je(t)});function bT(e,t){return new yo({values:e,typeName:Te.ZodEnum,...je(t)})}class yo extends We{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{expected:Ge.joinValues(r),received:n.parsedType,code:Y.invalid_type}),Ne}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 ie(n,{received:n.data,code:Y.invalid_enum_value,options:r}),Ne}return kr(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 yo.create(t,{...this._def,...n})}exclude(t,n=this._def){return yo.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}yo.create=bT;class m0 extends We{_parse(t){const n=Ge.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ue.string&&r.parsedType!==ue.number){const i=Ge.objectValues(n);return ie(r,{expected:Ge.joinValues(i),received:r.parsedType,code:Y.invalid_type}),Ne}if(this._cache||(this._cache=new Set(Ge.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ge.objectValues(n);return ie(r,{received:r.data,code:Y.invalid_enum_value,options:i}),Ne}return kr(t.data)}get enum(){return this._def.values}}m0.create=(e,t)=>new m0({values:e,typeName:Te.ZodNativeEnum,...je(t)});class Zh extends We{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ue.promise&&n.common.async===!1)return ie(n,{code:Y.invalid_type,expected:ue.promise,received:n.parsedType}),Ne;const r=n.parsedType===ue.promise?n.data:Promise.resolve(n.data);return kr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Zh.create=(e,t)=>new Zh({type:e,typeName:Te.ZodPromise,...je(t)});class bo extends We{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{ie(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Ne;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ne:l.status==="dirty"||n.value==="dirty"?Ql(l.value):l});{if(n.value==="aborted")return Ne;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ne:a.status==="dirty"||n.value==="dirty"?Ql(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Ne:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Ne:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ua(o))return Ne;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ua(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Ne);Ge.assertNever(i)}}bo.create=(e,t,n)=>new bo({schema:e,typeName:Te.ZodEffects,effect:t,...je(n)});bo.createWithPreprocess=(e,t,n)=>new bo({schema:t,effect:{type:"preprocess",transform:e},typeName:Te.ZodEffects,...je(n)});class Mi extends We{_parse(t){return this._getType(t)===ue.undefined?kr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Mi.create=(e,t)=>new Mi({innerType:e,typeName:Te.ZodOptional,...je(t)});class wo extends We{_parse(t){return this._getType(t)===ue.null?kr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wo.create=(e,t)=>new wo({innerType:e,typeName:Te.ZodNullable,...je(t)});class Qh extends We{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ue.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Qh.create=(e,t)=>new Qh({innerType:e,typeName:Te.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...je(t)});class Jh extends We{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Vh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Bi(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Bi(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Jh.create=(e,t)=>new Jh({innerType:e,typeName:Te.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...je(t)});class Ew extends We{_parse(t){if(this._getType(t)!==ue.nan){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.nan,received:r.parsedType}),Ne}return{status:"valid",value:t.data}}}Ew.create=e=>new Ew({typeName:Te.ZodNaN,...je(e)});class wT extends We{_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 $_ extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Ne:s.status==="dirty"?(n.dirty(),Ql(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Ne:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new $_({in:t,out:n,typeName:Te.ZodPipeline})}}class ef extends We{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ua(i)&&(i.value=Object.freeze(i.value)),i);return Vh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}ef.create=(e,t)=>new ef({innerType:e,typeName:Te.ZodReadonly,...je(t)});var Te;(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"})(Te||(Te={}));const w=Ti.create,V=Wa.create,_e=c0.create,Es=h0.create;Rs.create;const se=ii.create,P=Ot.create;Kh.create;const fi=z_.create;Gh.create;_o.create;const zs=Yh.create,ee=Xh.create,Le=yo.create;Zh.create;Mi.create;wo.create;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const r6=["owner"],i6=["agent","owner","user-upload"],ST=P({id:w().min(1),relPath:w().min(1),from:Le(i6),label:w().optional(),size:V().int().nonnegative(),mime:w().min(1),addedAt:V().int().nonnegative(),lastEditedAt:V().int().nonnegative().optional(),stale:_e().optional()});P({sessionId:w().min(1),relPath:w().min(1),ttlSeconds:V().int().positive().nullable().optional(),view:Le(["raw","md-rendered"]).optional()});P({url:w().min(1),expiresAt:V().int().nonnegative().nullable()});P({sessionId:w().min(1),relPath:w().min(1),label:w().optional(),origin:ee("agent").optional()});P({entry:ST});P({sessionId:w().min(1),relPath:w().min(1)});P({removed:ee(!0)});P({sessionId:w().min(1)});P({entries:se(ST)});P({attachmentId:w().min(1),url:w().min(1),relPath:w().min(1),sizeBytes:V().int().nonnegative(),mimeType:w().min(1)});const s6=fi("type",[P({type:ee("persona"),id:w().min(1)}).strict(),P({type:ee("chat"),id:w().min(1)}).strict(),P({type:ee("*")}).strict()]),o6=Le(["read","send","admin"]),F_=P({resource:s6,actions:se(o6).min(1)}).strict(),a6=P({id:w().min(1),secretHash:w().regex(/^[a-f0-9]{64}$/),displayName:w(),grants:se(F_),issuedAt:V().int().nonnegative(),expiresAt:V().int().positive().optional(),maxUses:V().int().positive().optional(),usedCount:V().int().nonnegative(),peerOwnerId:w().min(1).optional(),firstUsedByPeerAt:V().int().positive().optional(),peerDisplayName:w().optional()}).strict(),l6=a6.omit({secretHash:!0});P({type:ee("whoami:ok"),owner:P({id:w(),kind:Le(["owner","guest"]),displayName:w(),ownerId:w(),provider:w()}).strict(),capability:l6,grantedPersonas:se(P({id:w().min(1),displayName:w()}).strict())}).strict();P({selfUrl:w().min(1)});P({type:ee("contact:handshake:ok"),owner:P({id:w(),ownerId:w(),provider:w(),displayName:w()}),grants:se(F_)});P({deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();P({type:ee("contact:setRemoteAccess:ok"),deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();P({type:ee("contact:remote-access-updated"),deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();const c6=P({deviceId:w().min(1),ownerId:w().min(1),provider:w().min(1),displayName:w(),remoteUrl:w().min(1),connectToken:w(),grants:se(F_),addedAt:V().int().nonnegative(),pinnedAt:V().int().nullable().default(null),remoteAccessAllowed:_e().default(!1)}).strict(),kT=c6;P({deviceId:w().min(1)}).strict();P({type:ee("contact:remove:ok"),deviceId:w().min(1)}).strict();P({type:ee("contact:list:ok"),contacts:se(kT)}).strict();P({type:ee("contact:added"),contact:kT}).strict();P({type:ee("contact:removed"),deviceId:w().min(1)}).strict();P({deviceId:w().min(1),pinned:_e()}).strict();P({type:ee("contact:pin:ok"),deviceId:w().min(1),pinnedAt:V().int().nullable()}).strict();P({type:ee("contact:pinned"),deviceId:w().min(1),pinnedAt:V().int().nullable()}).strict();const u6=P({deviceId:w().min(1),name:w().min(1),url:w().min(1)});P({type:ee("device:list:ok"),devices:se(u6)});P({deviceId:w().min(1),url:w().min(1).optional(),name:w().optional()});P({type:ee("device:connect:ok"),deviceId:w(),name:w(),url:w()});const CT=P({ownerId:w().min(1),provider:w().min(1),displayName:w().min(1),avatarUrl:w().optional(),unionId:w().optional()});P({type:ee("auth:login:start:ok"),authUrl:w().min(1),state:w().min(1)});P({type:ee("auth:getIdentity:ok"),identity:CT.nullable(),deviceId:w().min(1),ttcTokenExpiresAt:V().nullable().optional()});P({type:ee("auth:logout:ok")});P({type:ee("auth:login:done"),identity:CT});P({type:ee("auth:login:failed"),reason:w()});const H_=fi("kind",[P({kind:ee("success"),text:w(),brief:w().optional(),filePaths:se(w()).optional()}),P({kind:ee("failure"),reason:w(),brief:w().optional()})]);P({targetPersona:w().min(1).optional(),dispatchId:w().min(1).optional(),prompt:w(),brief:w().optional(),targetDeviceId:w().min(1).optional(),model:w().min(1).optional(),tool:w().min(1).optional(),sessionLabel:w().min(1).max(60).optional(),meta:zs(Es()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});P({dispatchId:w().min(1),outcome:H_});const d6=["running","completed","failed"],U_=Le(d6),h6=P({dispatchId:w().min(1),sourceSessionId:w().min(1),sourcePersonaId:w().min(1).optional(),targetPersonaId:w().min(1),workerSessionId:w().min(1).optional(),taskText:w(),taskBrief:w().optional(),round:V().int().positive().optional(),status:U_,outcome:H_.optional(),meta:zs(Es()).optional(),createdAt:w().min(1),completedAt:w().min(1).optional(),deliveredAt:w().min(1).optional()});P({sourceSessionId:w().min(1).optional()});P({records:se(h6)});P({dispatchId:w().min(1)});P({type:ee("personaDispatch:get:ok"),status:U_,outcome:H_.optional()});const f6=/^[a-z0-9][a-z0-9-]*$/;Le(["stopped","starting","running","crashed","invalid"]);const p6=new Set(["localhost","127.0.0.1"]);function m6(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&p6.has(t.hostname))}const fd=P({id:w().regex(f6),name:w().min(1),version:w().min(1),apiVersion:ee("1"),runtime:P({startCommand:w().min(1)}).passthrough().optional(),entry:P({url:w().url().refine(m6,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),g6=fi("kind",[P({kind:ee("local"),port:V().int().min(1).max(65535)}),P({kind:ee("hosted"),url:w().url()})]);fi("state",[P({extId:w(),manifest:fd,state:ee("stopped")}),P({extId:w(),manifest:fd,state:ee("starting")}),P({extId:w(),manifest:fd,state:ee("running"),target:g6}),P({extId:w(),manifest:fd,state:ee("crashed")}),P({extId:w(),manifest:Es().nullable(),state:ee("invalid"),invalidReason:w().min(1)})]);P({snapshotHash:w().min(1),version:w().min(1),publishedAt:V()});const v6=fi("kind",[P({kind:ee("p2p-tunnel"),ownerPrincipalId:w().min(1),extId:w().min(1)})]);fi("kind",[P({kind:ee("p2p-tunnel"),ownerPrincipalId:w().min(1),extId:w().min(1),snapshotHash:w().min(1)})]);P({extId:w().min(1),name:w().min(1),version:w().min(1),contentHash:w().min(1),publishedAt:V()});const x6=fi("kind",[P({kind:ee("clean")}),P({kind:ee("ready-new-version"),fromVersion:w().min(1),toVersion:w().min(1)}),P({kind:ee("error-same-hash"),version:w().min(1)}),P({kind:ee("error-version-not-bumped"),localVersion:w().min(1),publishedVersion:w().min(1)}),P({kind:ee("error-version-regression"),localVersion:w().min(1),publishedVersion:w().min(1)})]);P({localManifest:P({name:w().min(1),version:w().min(1),contentHash:w().min(1)}),publishState:fi("kind",[P({kind:ee("unpublished")}),P({kind:ee("published"),version:w().min(1),contentHash:w().min(1),publishedAt:V()})]),check:x6});P({extId:w().min(1),newVersion:w().min(1).nullish()});P({extId:w().min(1)});P({extId:w().min(1),snapshotHash:w().min(1)});P({channelRef:v6,snapshotHash:w().min(1),zipBase64:w().min(1)});P({id:w().min(1),peerDeviceId:w().min(1),senderDeviceId:w().min(1),text:w().min(1),createdAt:V().int().nonnegative(),readBy:zs(w().min(1),V().int().positive()).default({}),origin:P({kind:ee("persona"),personaId:w().min(1)}).optional()}).strict();P({peerDeviceId:w().min(1).optional(),id:w().min(1),text:w().min(1),createdAt:V().int().nonnegative(),origin:P({kind:ee("persona"),personaId:w().min(1)}).optional()}).strict();P({peerDeviceId:w().min(1),sinceCreatedAt:V().int().nonnegative().optional()}).strict();P({peerDeviceId:w().min(1),upToCreatedAt:V().int().nonnegative()}).strict();P({peerDeviceId:w().min(1).optional(),text:w().min(1)});P({peerDeviceId:w().min(1).optional(),command:w().min(1),timeoutMs:V().int().positive().optional()}).strict();P({type:ee("peerExec:run:ok"),stdout:w(),stderr:w(),exitCode:V().int().nullable(),timedOut:_e(),stdoutTruncated:_e(),stderrTruncated:_e()}).strict();const ET=fi("kind",[P({kind:ee("at"),at:w().min(1)}),P({kind:ee("every"),everyMs:V().int().positive(),anchorMs:V().int().nonnegative().optional()}),P({kind:ee("cron"),expr:w().min(1),tz:w().min(1).optional()})]),vu=w().trim().min(1);P({personaId:vu,name:w().min(1),schedule:ET,prompt:w().min(1),targetPersona:w().min(1).optional(),timeoutMs:V().int().positive().optional()});P({personaId:vu,onlyMine:_e().optional()});P({personaId:vu,shiftId:w().min(1)});const _6=P({name:w().min(1).optional(),schedule:ET.optional(),prompt:w().min(1).optional(),targetPersona:w().min(1).optional(),timeoutMs:V().int().positive().optional(),enabled:_e().optional()});P({personaId:vu,shiftId:w().min(1),patch:_6});P({personaId:vu,shiftId:w().min(1),limit:V().int().positive().optional()});const NT=P({id:w().min(1),name:w().min(1),memberPersonaIds:se(w().min(1)),memberContactDeviceIds:se(w().min(1)),createdAt:w().min(1),updatedAt:w().min(1)}),TT=w().trim().min(1);P({name:TT,memberPersonaIds:se(w().min(1)).default([]),memberContactDeviceIds:se(w().min(1)).default([])});P({channelId:w().min(1),name:TT.optional(),memberPersonaIds:se(w().min(1)).optional(),memberContactDeviceIds:se(w().min(1)).optional()});P({channelId:w().min(1)});P({channels:se(NT)});P({channel:NT});P({ok:ee(!0),removedTopics:V().int().min(0)});const yn=w().trim().min(1),y6=["planning","running","done","archived"],b6=Le(y6),w6=P({at:w().min(1),actor:w().min(1),action:w().min(1),target:w().optional(),reason:w().min(1),artifacts:se(yn).optional()}),S6=P({rejectCount:V().int().min(0),accepted:_e().default(!1),overrideCount:V().int().min(0).optional()}),W_=P({id:w().min(1),channelId:w().min(1),title:w(),masterSessionId:w().min(1),goal:w(),boundaries:w(),acceptanceCriteria:se(w()),activity:se(w6),lineMeta:zs(S6),state:b6,createdAt:w().min(1),updatedAt:w().min(1)}),k6=P({lineId:w().min(1),dispatchId:w().min(1),workerSessionId:w().optional(),assignee:w().min(1),focus:w(),status:U_,acceptance:se(w()),rejectCount:V().int().min(0),accepted:_e()});P({channelId:w().min(1)});P({topicId:w().min(1).optional(),sessionId:w().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});P({channelId:w().min(1),title:yn.optional()});P({topicId:w().min(1),title:yn.optional(),goal:yn,boundaries:w(),acceptanceCriteria:se(yn).min(1)});P({topicId:w().min(1),action:yn,target:yn.optional(),reason:yn,artifacts:se(yn).optional()});P({topicId:w().min(1),lineId:yn,reason:yn});P({topicId:w().min(1),lineId:yn,reason:yn,artifacts:se(yn).optional(),watcherVerdict:Le(["pass","fail"]),overrideReason:yn.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});P({topicId:w().min(1),state:Le(["done","archived"])});P({topicId:w().min(1),title:yn});P({topicId:w().min(1)});const C6=W_.extend({lineCount:V().int().min(0)});P({topics:se(C6)});P({topic:W_,lines:se(k6)});P({topicId:w().min(1),masterSessionId:w().min(1)});P({rejectCount:V().int().min(1),needsOwnerAttention:_e()});P({acceptedLines:V().int().min(1),totalLines:V().int().min(1),allAccepted:_e(),overrides:V().int().min(0),needsOwnerAttention:_e()});P({topic:W_});P({ok:ee(!0),removedMasterSessionId:w().min(1).nullable()});const E6=["ask","allow","deny"],IT=Le(E6),N6=P({id:w().min(1),desc:w().min(1),action:IT});P({rules:se(N6)});P({ruleId:w().min(1)});P({action:IT,desc:w(),source:w().min(1)});const T6=["created","review-requested"],PT=/^[A-Za-z0-9._-]+$/,dl=w().min(1).regex(PT),hl=w().min(1).regex(PT),xu=V().int().positive();P({role:Le(T6)});P({owner:dl,repo:hl,number:xu});P({owner:dl,repo:hl,number:xu,expectedHeadSha:w().min(1)});P({owner:dl,repo:hl,number:xu,body:w().min(1)});P({owner:dl,repo:hl,number:xu,ready:_e()});P({owner:dl,repo:hl});P({owner:dl,repo:hl,number:xu,reviewers:se(w().min(1)).min(1)});P({personaId:w().min(1)});const I6=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],P6=Le(I6);P({personaId:w().min(1),appId:w().min(1),appSecret:w().min(1),botName:w().min(1).optional()});const R6=P({chatId:w().min(1),chatName:w().optional(),lastActiveAt:V().int().optional()}),M6=P({state:Le(["unbound","provisioning","bound","broken"]),appId:w().optional(),botName:w().optional(),brokenReason:w().optional(),qrUrl:w().optional(),errorReason:P6.optional(),groups:se(R6)});M6.extend({personaId:w().min(1)});P({});P({onboardingCompletedAt:V()});P({});P({tools:se(P({id:Le(["claude","codex"]),available:_e(),version:w().optional(),path:w().optional()}))});P({});const A6=P({tool:Le(["claude","codex"]),cwd:w(),toolSessionId:w(),label:w().optional(),createdAt:w(),updatedAt:w(),turns:V()});P({candidates:se(A6)});P({});P({registered:_e()});const j6=P({personaId:w(),label:w(),model:w().optional(),effort:w().optional(),public:_e(),iconKey:w().optional(),tool:w().optional(),createdAt:V(),updatedAt:V()}).strict(),L6=P({name:w().min(1),description:w().optional()}),D6=P({id:w().min(1)}),O6=P({permissions:P({defaultMode:w().optional(),allow:se(w()).optional(),deny:se(w()).optional()}).optional(),sandbox:P({enabled:_e().optional(),autoAllowBashIfSandboxed:_e().optional(),allowUnsandboxedCommands:_e().optional(),excludedCommands:se(w()).optional(),filesystem:P({denyRead:se(w()).optional(),allowRead:se(w()).optional(),denyWrite:se(w()).optional(),allowWrite:se(w()).optional()}).optional(),network:P({allowedDomains:se(w()).optional(),allowLocalBinding:_e().optional()}).optional()}).optional()});j6.extend({personality:w().optional(),skills:se(L6).optional(),plugins:se(D6).optional(),sandboxSettings:O6.nullable().optional()});P({slug:w().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:w().min(1),personality:w(),model:w().optional(),effort:w().optional(),tool:w().optional(),public:_e().optional(),iconKey:w().optional()}).strict();P({personaId:w().min(1)});P({personaId:w().min(1),patch:P({label:w().min(1).optional(),model:w().optional(),effort:w().optional(),tool:w().optional(),personality:w().optional(),public:_e().optional(),iconKey:w().nullable().optional()}).strict()}).strict();P({writableRoots:se(w()).optional(),denyRead:se(w()).optional(),network:_e().optional()}).strict();const RT=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","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","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed","larkBot:state"],MT=["idle","running","running-idle","stopped","error","observing"],B6=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function op(e){return e==="dispatch-task"||e==="dispatch-result"}const z6=["builtin","global","project","plugin"],$6=["builtin","global","project","policy","plugin"],AT=Le(["owner","guest"]);P({id:w().min(1),kind:AT,displayName:w(),feishuUnionId:w().optional()}).strict();const F6=P({did:w().min(1),displayName:w(),feishuUnionId:w().optional(),principal:AT}).strict(),H6=Le(MT),U6=P({input_tokens:V().int().nonnegative().optional(),cache_read_input_tokens:V().int().nonnegative().optional(),cache_creation_input_tokens:V().int().nonnegative().optional(),output_tokens:V().int().nonnegative().optional()}),W6=P({inputTokens:V().int().nonnegative(),outputTokens:V().int().nonnegative(),cacheReadTokens:V().int().nonnegative().optional(),cacheCreateTokens:V().int().nonnegative().optional()}),jT={gitBranch:w().optional(),resolvedModel:w().optional(),resolvedEffort:w().optional(),contextUsage:W6.optional(),contextWindowSize:V().int().positive().optional(),aiLabel:w().optional()},V6=P(jT),LT=P({value:w(),label:w(),description:w().optional()}),q6=P({id:w().min(1),label:w().min(1),description:w().optional(),contextWindowSize:V().int().positive(),default:_e().optional(),efforts:se(LT).optional(),defaultEffort:w().optional()}),K6=P({id:w().min(1),label:w().min(1),description:w().optional()}),G6=P({name:w().min(1),type:Le(["string","select","toggle"]),label:w().min(1),description:w().optional(),options:se(LT).optional(),default:Es().optional(),scope:Le(["core","tool-specific"])});P({tool:w().min(1)});const Y6=P({rewind:_e(),subagents:_e(),tui:_e(),observe:_e(),fileSharing:_e(),fork:_e()});P({tool:w().min(1),toolSessionIdLabel:w().optional(),models:se(q6),permissionModes:se(K6),configSchema:se(G6),features:Y6});const X6=P({tool:w().min(1),pattern:w().min(1),createdAt:w().min(1).optional()});P({sessionId:w().min(1),cwd:w().min(1),tool:ee("claude").or(w().min(1)).default("claude"),toolSessionId:w().optional(),label:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),...jT,aiLabelGeneratedAt:w().optional(),permissionRules:se(X6).optional(),pinnedAt:V().int().nonnegative().nullable().optional(),archivedAt:V().int().nonnegative().nullable().optional(),pinSortOrder:V().int().nullable().optional(),unreadAt:w().min(1).nullable().optional(),iconKey:w().optional(),forkedFromSessionId:w().min(1).optional(),ephemeral:_e().optional(),ownerPersonaId:w().min(1).optional(),projectPath:w().min(1).optional(),appBuilderProject:w().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:w().min(1).optional(),creatorPrincipalId:w().min(1).optional(),creatorDisplayName:w().min(1).optional(),creatorFeishuUnionId:w().min(1).optional(),originOwnerPrincipalId:w().min(1).optional(),originOwnerPersonaId:w().min(1).optional(),dispatchedFromSessionId:w().min(1).optional(),shiftFiredFromSessionId:w().min(1).optional(),larkChatId:w().min(1).optional(),larkChatName:w().min(1).optional(),larkChatType:Le(["p2p","group"]).optional(),createdAt:w().min(1),updatedAt:w().min(1)});const Bn={seq:V().int().nonnegative().optional(),ts:w().optional(),uuid:w().optional()},Z6=Le(B6),Q6=P({readCount:V().int().nonnegative().optional(),searchCount:V().int().nonnegative().optional(),bashCount:V().int().nonnegative().optional(),editFileCount:V().int().nonnegative().optional(),linesAdded:V().int().nonnegative().optional(),linesRemoved:V().int().nonnegative().optional(),otherToolCount:V().int().nonnegative().optional()}),J6=P({oldStart:V().int().nonnegative(),oldLines:V().int().nonnegative(),newStart:V().int().nonnegative(),newLines:V().int().nonnegative(),lines:se(w())}),eB=P({agentId:w().optional(),agentType:w().optional(),status:w().optional(),prompt:w().optional(),filePath:w().optional(),structuredPatch:se(J6).optional(),stats:P({durationMs:V().int().nonnegative().optional(),tokens:V().int().nonnegative().optional(),toolUseCount:V().int().nonnegative().optional(),toolStats:Q6.optional(),usage:U6.optional()}).optional()}),tB=P({path:w(),content:w(),mtimeMs:V().optional()}),nB=P({label:w().min(1),description:w().optional()}),DT=P({question:w().min(1),multiSelect:_e(),options:se(nB).min(1)}),rB=["completed","interrupted"];fi("kind",[P({...Bn,kind:ee("session_init"),toolSessionId:w().optional()}),P({...Bn,kind:ee("thinking"),text:w(),partialId:w().optional()}),P({...Bn,kind:ee("text"),text:w(),partialId:w().optional()}),P({...Bn,kind:ee("user_text"),text:w(),meta:Z6.optional(),taskId:w().optional(),parentToolUseId:w().optional(),sender:F6.optional()}),P({...Bn,kind:ee("tool_call"),toolUseId:w(),tool:w(),toolKind:w().optional(),input:Es()}),P({...Bn,kind:ee("tool_result"),toolUseId:w(),output:Es().optional(),error:w().optional(),toolResultExtra:eB.optional(),sourceToolAssistantUUID:w().optional(),askQuestionAnswers:zs(w(),w()).optional()}),P({...Bn,kind:ee("attachment_memories"),memories:se(tB)}),P({...Bn,kind:ee("permission_request"),requestId:w(),tool:w(),input:Es(),toolUseId:w().optional()}),P({...Bn,kind:ee("ask_user_question"),toolUseId:w(),questions:se(DT)}),P({...Bn,kind:ee("turn_end"),durationMs:V().int().nonnegative().optional(),reason:Le(rB).optional()}),P({...Bn,kind:ee("subagent_progress"),toolUseId:w(),agentId:w(),status:Le(["started","running","completed","failed"]),description:w().optional(),lastToolName:w().optional(),prompt:w().optional(),stats:P({durationMs:V().int().nonnegative().optional(),tokens:V().int().nonnegative().optional(),toolUseCount:V().int().nonnegative().optional()}).optional()}),P({...Bn,kind:ee("error"),message:w()}),P({...Bn,kind:ee("meta_update"),patch:V6}),P({...Bn,kind:ee("meta-text"),text:w(),metaSource:Le(["cc","owner"]).optional()})]);P({cwd:w().min(1).optional(),tool:w().optional(),label:w().optional(),aiLabel:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),iconKey:w().optional(),forkedFromSessionId:w().min(1).optional(),ephemeral:_e().optional(),ownerPersonaId:w().min(1).optional(),projectPath:w().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});P({path:w().min(1),name:w().min(1),createdAt:w().datetime(),pinnedAt:V().optional()});P({path:w().min(1),pinnedAt:V().nullable()});P({path:w().min(1)});P({path:w().min(1).optional(),name:w().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});P({cwd:w().min(1),tool:w().min(1),toolSessionId:w().min(1),label:w().optional(),aiLabel:w().optional(),iconKey:w().optional(),createdAt:w().datetime(),updatedAt:w().datetime(),ownerPersonaId:w().min(1).optional()});P({originOnly:_e().optional(),ownerPersonaId:w().min(1).optional(),limit:V().int().positive().optional(),offset:V().int().nonnegative().optional()});P({sessionId:w().min(1)});P({sessionId:w().min(1),patch:P({label:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),cwd:w().optional(),iconKey:w().optional(),ephemeral:ee(!1).optional()})});P({sessionId:w().min(1),text:w()});P({sessionId:w().min(1),userMessageId:w().min(1),dryRun:_e().optional()});P({canRewind:_e(),error:w().optional(),filesChanged:se(w()).optional(),insertions:V().int().nonnegative().optional(),deletions:V().int().nonnegative().optional()});P({sessionId:w().min(1),userMessageId:w().min(1)});const iB=P({oldStart:V().int().nonnegative(),oldLines:V().int().nonnegative(),newStart:V().int().nonnegative(),newLines:V().int().nonnegative(),lines:se(w())}),sB=P({filePath:w().min(1),hunks:se(iB),insertions:V().int().nonnegative(),deletions:V().int().nonnegative(),status:Le(["modified","added","deleted"]).optional()});P({canRewind:_e(),error:w().optional(),files:se(sB),totalInsertions:V().int().nonnegative(),totalDeletions:V().int().nonnegative()});P({userMessageIds:se(w())});P({sessionId:w().min(1),toolSessionId:w().min(1)});P({cwd:w().min(1),toolSessionId:w().min(1),messageUuid:w().min(1),targetCwd:w().min(1).optional()});P({forkedToolSessionId:w().min(1),forkedFilePath:w().min(1)});P({sessionId:w().min(1),toolSessionId:w().min(1),jsonlPath:w().optional()});P({sessionId:w().min(1),afterSeq:V().int().min(-1)});P({sessionId:w().min(1),permissionRequestId:w().min(1),allow:_e(),permanent:_e().optional(),pattern:w().optional()});P({projectPath:w().min(1)});P({sessionId:w().min(1),limit:V().int().positive().max(5e3).optional(),offset:V().int().nonnegative().optional(),slim:_e().optional()});P({cwd:w().min(1),toolSessionId:w().min(1)});P({cwd:w().min(1),toolSessionId:w().min(1),subagentId:w().min(1)});P({cwd:w().min(1).optional(),path:w().optional(),showHidden:_e().optional()});P({cwd:w().min(1),path:w().min(1)});P({cwd:w().min(1),tool:w().optional()});P({name:w().min(1),source:Le(z6),path:w().optional(),description:w().optional(),plugin:w().optional()});const oB=P({name:w().min(1),source:Le($6),path:w().optional(),description:w().optional(),whenToUse:w().optional(),plugin:w().optional()});P({cwd:w().min(1),tool:w().optional()});P({agents:se(oB)});P({sessionId:w().optional()});P({sessionId:w().min(1).optional()});P({sessionId:w().min(1),pinned:_e()});P({sessionId:w().min(1),archived:_e()});P({type:ee("peerSession:upsert:ok")});P({sessionId:w().min(1)});P({type:ee("peerSession:remove:ok")});P({orderedIds:se(w().min(1)).min(1)});P({cwd:w().min(1)});P({isGitRoot:_e(),gitRoot:w().nullable()});P({cwd:w().min(1)});P({branch:w().nullable()});P({cwd:w().min(1)});P({branches:se(w()),head:w().nullable()});P({}).optional();const aB=P({cwd:w().min(1),updatedAt:w().min(1)});P({dirs:se(aB)});P({type:ee("session:question"),sessionId:w().min(1),toolUseId:w().min(1),requestId:w().min(1),questions:se(DT).min(1)});P({type:ee("session:question:cleared"),sessionId:w().min(1),toolUseId:w().min(1),answers:zs(w(),w()).optional()});P({sessionId:w().min(1),toolUseId:w().min(1),answers:zs(w(),w())});P({ok:ee(!0)});P({sessionId:w().min(1),toolUseId:w().min(1)});P({ok:ee(!0)});const OT=P({name:w().min(1),version:w().min(1),instanceId:w().min(1),deviceLabel:w().transform(e=>e.trim().slice(0,64)).optional()});P({type:ee("auth"),token:w().min(1),scheme:ee("bearer").optional(),clientInfo:OT.optional()});P({type:ee("auth:ok"),version:w().min(1).optional(),protocolVersion:V().int().nonnegative().optional()});const lB=P({clientId:w().min(1),connectedAt:V().int().nonnegative(),self:_e(),clientInfo:OT.optional()});P({type:ee("device:connections:ok"),connections:se(lB)});P({type:ee("tunnel:ready"),url:w().min(1),subdomain:w().min(1)});P({type:ee("tunnel:exited"),code:V().int().nullable(),subdomain:w().nullable(),url:w().nullable()});P({type:ee("tunnel:unavailable"),reason:w().min(1),failedAt:w().min(1)});const cB=P({sessionId:w().min(1),status:H6,freshSpawn:_e(),pendingPermissionRequestIds:se(w().min(1)),pendingQuestionToolUseIds:se(w().min(1))});P({type:ee("info"),version:w(),protocolVersion:V(),hostname:w(),os:w(),tools:se(P({id:w(),available:_e()})),runningSessions:se(cB),tokenRole:Le(r6).optional(),isLoopback:_e().optional(),httpBaseUrl:w().optional(),httpToken:w().optional(),daemonSource:Le(["ota","packaged"]).optional(),globalCliVersion:w().nullable().optional()});const uB=6173,dB=6272,fl=/^[a-z][a-z0-9-]{0,39}$/,_u=P({name:w().regex(fl,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:V().int().min(uB).max(dB),createdAt:w().datetime(),devCommand:w().min(1),prodUrl:w().url().optional(),readyPattern:w().optional(),publishJob:P({jobId:w().min(1),stage:Le(["build","deploy","verify"]),startedAt:V().int().nonnegative()}).optional()}),hB=["install-pending","installing","starting-dev-server","running","stopped","failed"],BT=Le(hB),V_=_u.extend({isRunning:_e(),boundSessionId:w().nullable(),stage:BT.optional(),stageReason:w().optional(),publishJob:P({jobId:w().min(1),stage:Le(["build","deploy","verify"]),startedAt:V().int().nonnegative(),status:Le(["in-flight","interrupted"])}).optional()});P({}).strict();P({projects:se(V_)}).strict();P({sessionId:w().min(1)}).strict();P({project:V_.nullable()}).strict();P({sessionId:w().min(1),name:w().min(1)}).strict();P({project:_u}).strict();P({name:w()}).strict();P({}).strict();P({name:w(),newPort:V().int()}).strict();P({project:_u}).strict();P({name:w().regex(fl),url:w().url()}).strict();P({project:_u}).strict();P({sessionId:w().min(1),force:_e().optional()}).strict();P({project:_u}).strict();const fB=["installing","failed"];P({sessionId:w().min(1),stage:Le(fB),reason:w().optional()}).strict();P({ok:ee(!0)}).strict();P({sessionId:w().min(1)}).strict();P({ok:ee(!0)}).strict();P({type:ee("appBuilder:project-updated"),project:V_,stage:BT,stageReason:w().optional()}).strict();P({name:w().regex(fl)});P({jobId:w().min(1),status:Le(["started","already-publishing"])}).strict();P({name:w().regex(fl)});P({ok:ee(!0)}).strict();P({type:ee("appBuilder:publish-progress"),name:w().regex(fl),jobId:w().min(1),stage:Le(["build","deploy","verify"]),status:Le(["started","completed"])}).strict();P({type:ee("appBuilder:publish-failed"),name:w().regex(fl),jobId:w().min(1),stage:Le(["build","deploy","verify","unknown"]),errorSummary:w()}).strict();P({});P({method:w().min(1).optional()});const pB=["allowed","conditional","denied"],mB=Le(pB),gB=P({name:w().min(1),status:mB,description:w().min(1),args:se(P({name:w(),required:_e()})).nullable(),argsSchema:zs(Es()).optional(),reason:w().optional()});P({type:ee("meta:methods"),methods:se(gB)});const Nw=1,vB=["daemon","main","renderer"],xB=Le(vB),_B=["debug","info","warn","error"],yB=Le(_B);P({ts:V().int(),source:xB,level:yB,msg:w(),ownerPrincipalId:w(),deviceId:w(),appVersion:w(),daemonVersion:w().optional(),os:w(),meta_json:w().optional(),sessionId:w().optional()});P({v:ee(1),visitorId:w().min(1),displayName:w(),provider:w(),iat:V(),exp:V()});const bB=P({visitorId:w(),displayName:w(),avatarUrl:w().optional(),provider:w(),firstSeen:V(),lastSeen:V()});P({visitors:se(bB)});const wB=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,SB=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,kB="clawd-dispatch-task",CB="clawd-dispatch-result",Tw=120;function EB(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?kB:CB,i=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let s=i.exec(e);s!==null;s=i.exec(e))t.push({at:s.index,block:NB(n,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function NB(e,t,n){var c;const r=jB(t),i=g0(AB(Rm(n,"detail")??n)),s=(c=Rm(n,"brief"))==null?void 0:c.trim(),o=s&&s.length>0?g0(s):TB(i),a=r.round!==void 0?Number.parseInt(r.round,10):void 0,l=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&a!==void 0&&Number.isFinite(a)?{round:a}:{},...e==="result"&&(l==="success"||l==="failure")?{status:l}:{},brief:o,briefIsDerived:!(s&&s.length>0),detail:i,filePaths:MB(Rm(n,"files"))}}function TB(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>Tw?`${n.slice(0,Tw)}…`:n}const IB="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",PB=new RegExp(`<\\\\(\\\\*)(/?)(${IB})\\b`,"g");function RB(e){return g0(e)}function g0(e){return e.replace(PB,"<$1$2$3")}function Rm(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function MB(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 lw=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const UD={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},WD={motionBase:!0,motionUnit:!0},VD={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},oT=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=lw(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=sT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=lw(l,["theme"]);let d=u;c&&(d=oT(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function aT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Qe.useContext(rT),s=`${FD}-${t||""}`,o=n||nT,[a,l,c]=RL(o,[qc,e],{salt:s,override:r,getComputedToken:oT,formatToken:sT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:UD,ignore:WD,preserve:VD}});return[o,c,t?l:"",a,i]}const qD=()=>({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"}}),KD=e=>({[`.${e}`]:Object.assign(Object.assign({},qD()),{[`.${e} .${e}-icon`]:{display:"block"}})}),GD=(e,t)=>{const[n,r]=aT();return sD({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>KD(e))},YD=Object.assign({},rl),{useId:cw}=YD,XD=()=>"",ZD=typeof cw>"u"?XD:cw;function QD(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},Wh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Wh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=ZD();return CN(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!sL(c,d,!0)}))}var JD=["children"],lT=g.createContext({});function eO(e){var t=e.children,n=jv(e,JD);return g.createElement(lT.Provider,{value:n},t)}var tO=function(e){NN(n,e);var t=IN(n);function n(){return al(this,n),t.apply(this,arguments)}return ll(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function nO(e){var t=g.useReducer(function(a){return a+1},0),n=Je(t,2),r=n[1],i=g.useRef(e),s=n0(function(){return i.current}),o=n0(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var is="none",cd="appear",ud="enter",dd="leave",uw="none",Pr="prepare",va="start",xa="active",B_="end",cT="prepared";function dw(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 rO(e,t){var n={animationend:dw("Animation","AnimationEnd"),transitionend:dw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var iO=rO(Ui(),typeof window<"u"?window:{}),uT={};if(Ui()){var sO=document.createElement("div");uT=sO.style}var hd={};function dT(e){if(hd[e])return hd[e];var t=iO[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in uT)return hd[e]=t[s],hd[e]}return""}var hT=dT("animationend"),fT=dT("transitionend"),pT=!!(hT&&fT),hw=hT||"animationend",fw=fT||"transitionend";function pw(e,t){if(!e)return null;if(Nt(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const oO=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(fw,e),i.removeEventListener(hw,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(fw,e),i.addEventListener(hw,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var mT=Ui()?g.useLayoutEffect:g.useEffect;const aO=function(){var e=g.useRef(null);function t(){Mv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Mv(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var lO=[Pr,va,xa,B_],cO=[Pr,cT],gT=!1,uO=!0;function vT(e){return e===xa||e===B_}const dO=function(e,t,n){var r=r0(uw),i=Je(r,2),s=i[0],o=i[1],a=aO(),l=Je(a,2),c=l[0],u=l[1];function d(){o(Pr,!0)}var f=t?cO:lO;return mT(function(){if(s!==uw&&s!==B_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===gT?o(m,!0):m&&c(function(b){function x(){b.isCanceled()||o(m,!0)}v===!0?x():Promise.resolve(v).then(x)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function hO(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,b=r.onEnterStart,x=r.onLeaveStart,_=r.onAppearActive,y=r.onEnterActive,S=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,T=r.onVisibleChanged,z=r0(),I=Je(z,2),M=I[0],L=I[1],R=nO(is),A=Je(R,2),D=A[0],$=A[1],F=r0(null),O=Je(F,2),B=O[0],E=O[1],H=D(),q=g.useRef(!1),j=g.useRef(null);function ne(){return n()}var re=g.useRef(!1);function G(){$(is),E(null,!0)}var ve=n0(function(Xe){var st=D();if(st!==is){var At=ne();if(!(Xe&&!Xe.deadline&&Xe.target!==At)){var Xt=re.current,pn;st===cd&&Xt?pn=C==null?void 0:C(At,Xe):st===ud&&Xt?pn=k==null?void 0:k(At,Xe):st===dd&&Xt&&(pn=N==null?void 0:N(At,Xe)),Xt&&pn!==!1&&G()}}}),ze=oO(ve),he=Je(ze,1),Ie=he[0],Re=function(st){switch(st){case cd:return Ce(Ce(Ce({},Pr,f),va,v),xa,_);case ud:return Ce(Ce(Ce({},Pr,p),va,b),xa,y);case dd:return Ce(Ce(Ce({},Pr,m),va,x),xa,S);default:return{}}},Ve=g.useMemo(function(){return Re(H)},[H]),xe=dO(H,!e,function(Xe){if(Xe===Pr){var st=Ve[Pr];return st?st(ne()):gT}if(it in Ve){var At;E(((At=Ve[it])===null||At===void 0?void 0:At.call(Ve,ne(),null))||null)}return it===xa&&H!==is&&(Ie(ne()),u>0&&(clearTimeout(j.current),j.current=setTimeout(function(){ve({deadline:!0})},u))),it===cT&&G(),uO}),Ke=Je(xe,2),Cn=Ke[0],it=Ke[1],ct=vT(it);re.current=ct;var on=g.useRef(null);mT(function(){if(!(q.current&&on.current===t)){L(t);var Xe=q.current;q.current=!0;var st;!Xe&&t&&a&&(st=cd),Xe&&t&&s&&(st=ud),(Xe&&!t&&c||!Xe&&d&&!t&&c)&&(st=dd);var At=Re(st);st&&(e||At[Pr])?($(st),Cn()):$(is),on.current=t}},[t]),g.useEffect(function(){(H===cd&&!a||H===ud&&!s||H===dd&&!c)&&$(is)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(j.current)}},[]);var gt=g.useRef(!1);g.useEffect(function(){M&&(gt.current=!0),M!==void 0&&H===is&&((gt.current||M)&&(T==null||T(M)),gt.current=!0)},[M,H]);var vt=B;return Ve[Pr]&&it===va&&(vt=$e({transition:"none"},vt)),[H,it,vt,M??t]}function fO(e){var t=e;Nt(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(lT),b=v.motion,x=n(i,b),_=g.useRef(),y=g.useRef();function S(){try{return _.current instanceof HTMLElement?_.current:Hj(y.current)}catch{return null}}var C=hO(x,a,S,i),k=Je(C,4),N=k[0],T=k[1],z=k[2],I=k[3],M=g.useRef(I);I&&(M.current=!0);var L=g.useCallback(function(O){_.current=O,qj(s,O)},[s]),R,A=$e($e({},m),{},{visible:a});if(!d)R=null;else if(N===is)I?R=d($e({},A),L):!c&&M.current&&p?R=d($e($e({},A),{},{className:p}),L):u||!c&&!p?R=d($e($e({},A),{},{style:{display:"none"}}),L):R=null;else{var D;T===Pr?D="prepare":vT(T)?D="active":T===va&&(D="start");var $=pw(f,"".concat(N,"-").concat(D));R=d($e($e({},A),{},{className:Pj(pw(f,N),Ce(Ce({},$,$&&D),f,typeof f=="string")),style:z}),L)}if(g.isValidElement(R)&&Kj(R)){var F=Gj(R);F||(R=g.cloneElement(R,{ref:L}))}return g.createElement(tO,{ref:y},R)});return r.displayName="CSSMotion",r}const pO=fO(pT);var i0="add",s0="keep",o0="remove",Im="removed";function mO(e){var t;return e&&Nt(e)==="object"&&"key"in e?t=e:t={key:e},$e($e({},t),{},{key:String(t.key)})}function a0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(mO)}function gO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=a0(e),o=a0(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return $e($e({},p),{},{status:i0})})),r=d),n.push($e($e({},f),{},{status:s0})),r+=1,u=!0;break}}u||n.push($e($e({},c),{},{status:o0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return $e($e({},c),{},{status:i0})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==o0}),n.forEach(function(u){u.key===c&&(u.status=s0)})}),n}var vO=["component","children","onVisibleChanged","onAllRemoved"],xO=["status"],_O=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function yO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:pO,n=function(r){NN(s,r);var i=IN(s);function s(){var o;al(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),Ce(Pv(o),"state",{keyEntities:[]}),Ce(Pv(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:$e($e({},p),{},{status:Im})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Im}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return ll(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=jv(c,vO),m=u||g.Fragment,v={};return _O.forEach(function(b){v[b]=p[b],delete p[b]}),delete p.keys,g.createElement(m,p,l.map(function(b,x){var _=b.status,y=jv(b,xO),S=_===i0||_===s0;return g.createElement(t,Fh({},v,{key:y.key,visible:S,eventProps:y,onVisibleChanged:function(k){f==null||f(k,{key:y.key}),k||a.removeKey(y.key)}}),function(C,k){return d($e($e({},C),{},{index:x}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=a0(c),f=gO(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var b=v.key;return p.key===b});return!(m&&m.status===Im&&p.status===o0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}yO(pT);const mw=g.createContext(!0);function bO(e){const t=g.useContext(mw),{children:n}=e,[,r]=aT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(mw.Provider,{value:i},g.createElement(eO,{motion:i},n)):n}const wO=()=>null;var SO=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const kO=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let xT;function CO(){return xT||e0}function EO(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const NO=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(xT=t),r&&EO(r)&&LD(CO(),r)},TO=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:b,parentContext:x,iconPrefixCls:_,theme:y,componentDisabled:S,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:I,collapse:M,typography:L,checkbox:R,descriptions:A,divider:D,drawer:$,skeleton:F,steps:O,image:B,layout:E,list:H,mentions:q,modal:j,progress:ne,result:re,slider:G,breadcrumb:ve,menu:ze,pagination:he,input:Ie,textArea:Re,empty:Ve,badge:xe,radio:Ke,rate:Cn,switch:it,transfer:ct,avatar:on,message:gt,tag:vt,table:Xe,card:st,tabs:At,timeline:Xt,timePicker:pn,upload:U,notification:J,tree:ye,colorPicker:ke,datePicker:Ue,rangePicker:kt,flex:an,wave:Ft,dropdown:le,warning:K,tour:we,tooltip:ft,popover:ln,popconfirm:Sl,floatButton:kl,floatButtonGroup:Cl,variant:Vp,inputNumber:qp,treeSelect:Fu}=e,Hu=g.useCallback((Pt,jt)=>{const{prefixCls:Z}=e;if(jt)return jt;const fe=Z||x.getPrefixCls("");return Pt?`${fe}-${Pt}`:fe},[x.getPrefixCls,e.prefixCls]),Ws=_||x.iconPrefixCls||iT,Vs=n||x.csp;GD(Ws,Vs);const El=QD(y,x.theme,{prefixCls:Hu("")}),Ho={csp:Vs,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||b,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Hu,iconPrefixCls:Ws,theme:El,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:I,collapse:M,typography:L,checkbox:R,descriptions:A,divider:D,drawer:$,skeleton:F,steps:O,image:B,input:Ie,textArea:Re,layout:E,list:H,mentions:q,modal:j,progress:ne,result:re,slider:G,breadcrumb:ve,menu:ze,pagination:he,empty:Ve,badge:xe,radio:Ke,rate:Cn,switch:it,transfer:ct,avatar:on,message:gt,tag:vt,table:Xe,card:st,tabs:At,timeline:Xt,timePicker:pn,upload:U,notification:J,tree:ye,colorPicker:ke,datePicker:Ue,rangePicker:kt,flex:an,wave:Ft,dropdown:le,warning:K,tour:we,tooltip:ft,popover:ln,popconfirm:Sl,floatButton:kl,floatButtonGroup:Cl,variant:Vp,inputNumber:qp,treeSelect:Fu},Fr=Object.assign({},x);Object.keys(Ho).forEach(Pt=>{Ho[Pt]!==void 0&&(Fr[Pt]=Ho[Pt])}),kO.forEach(Pt=>{const jt=e[Pt];jt&&(Fr[Pt]=jt)}),typeof r<"u"&&(Fr.button=Object.assign({autoInsertSpace:r},Fr.button));const Xi=CN(()=>Fr,Fr,(Pt,jt)=>{const Z=Object.keys(Pt),fe=Object.keys(jt);return Z.length!==fe.length||Z.some(be=>Pt[be]!==jt[be])}),{layer:qs}=g.useContext(tp),Kp=g.useMemo(()=>({prefixCls:Ws,csp:Vs,layer:qs?"antd":void 0}),[Ws,Vs,qs]);let Ht=g.createElement(g.Fragment,null,g.createElement(wO,{dropdownMatchSelectWidth:p}),t);const Uo=g.useMemo(()=>{var Pt,jt,Z,fe;return fD(((Pt=ip.Form)===null||Pt===void 0?void 0:Pt.defaultValidateMessages)||{},((Z=(jt=Xi.locale)===null||jt===void 0?void 0:jt.Form)===null||Z===void 0?void 0:Z.defaultValidateMessages)||{},((fe=Xi.form)===null||fe===void 0?void 0:fe.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Xi,o==null?void 0:o.validateMessages]);Object.keys(Uo).length>0&&(Ht=g.createElement(mD.Provider,{value:Uo},Ht)),a&&(Ht=g.createElement(xD,{locale:a,_ANT_MARK__:vD},Ht)),Ht=g.createElement(cD.Provider,{value:Kp},Ht),l&&(Ht=g.createElement(OD,{size:l},Ht)),Ht=g.createElement(bO,null,Ht);const Wo=g.useMemo(()=>{const Pt=El||{},{algorithm:jt,token:Z,components:fe,cssVar:be}=Pt,Ze=SO(Pt,["algorithm","token","components","cssVar"]),Cr=jt&&(!Array.isArray(jt)||jt.length>0)?Dv(jt):nT,Vo={};Object.entries(fe||{}).forEach(([YA,XA])=>{const xi=Object.assign({},XA);"algorithm"in xi&&(xi.algorithm===!0?xi.theme=Cr:(Array.isArray(xi.algorithm)||typeof xi.algorithm=="function")&&(xi.theme=Dv(xi.algorithm)),delete xi.algorithm),Vo[YA]=xi});const S1=Object.assign(Object.assign({},qc),Z);return Object.assign(Object.assign({},Ze),{theme:Cr,token:S1,components:Vo,override:Object.assign({override:S1},Vo),cssVar:be})},[El]);return y&&(Ht=g.createElement(rT.Provider,{value:Wo},Ht)),Xi.warning&&(Ht=g.createElement(pD.Provider,{value:Xi.warning},Ht)),S!==void 0&&(Ht=g.createElement(DD,{disabled:S},Ht)),g.createElement(sp.Provider,{value:Xi},Ht)},ul=e=>{const t=g.useContext(sp),n=g.useContext(QN);return g.createElement(TO,Object.assign({parentContext:t,legacyLocale:n},e))};ul.ConfigContext=sp;ul.SizeContext=Kc;ul.config=NO;ul.useConfig=BD;Object.defineProperty(ul,"SizeContext",{get:()=>Kc});const cr=(e,t)=>new bt(e).setA(t).toRgbString(),Go=(e,t)=>new bt(e).lighten(t).toHexString(),IO=e=>{const t=Ha(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]}},PO=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:cr(r,.85),colorTextSecondary:cr(r,.65),colorTextTertiary:cr(r,.45),colorTextQuaternary:cr(r,.25),colorFill:cr(r,.18),colorFillSecondary:cr(r,.12),colorFillTertiary:cr(r,.08),colorFillQuaternary:cr(r,.04),colorBgSolid:cr(r,.95),colorBgSolidHover:cr(r,1),colorBgSolidActive:cr(r,.9),colorBgElevated:Go(n,12),colorBgContainer:Go(n,8),colorBgLayout:Go(n,0),colorBgSpotlight:Go(n,26),colorBgBlur:cr(r,.04),colorBorder:Go(n,26),colorBorderSecondary:Go(n,19)}},RO=(e,t)=>{const n=Object.keys(D_).map(s=>{const o=Ha(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??O_(e),i=tT(e,{generateColorPalettes:IO,generateNeutralColorPalettes:PO});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},gw={defaultSeed:Wh.token,defaultAlgorithm:O_,darkAlgorithm:RO};function vw({children:e}){const t=T_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(ul,{theme:{algorithm:n.mode==="dark"?gw.darkAlgorithm:gw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ge;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ge||(Ge={}));var xw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(xw||(xw={}));const ue=Ge.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ls=e=>{switch(typeof e){case"undefined":return ue.undefined;case"string":return ue.string;case"number":return Number.isNaN(e)?ue.nan:ue.number;case"boolean":return ue.boolean;case"function":return ue.function;case"bigint":return ue.bigint;case"symbol":return ue.symbol;case"object":return Array.isArray(e)?ue.array:e===null?ue.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ue.promise:typeof Map<"u"&&e instanceof Map?ue.map:typeof Set<"u"&&e instanceof Set?ue.set:typeof Date<"u"&&e instanceof Date?ue.date:ue.object;default:return ue.unknown}},Y=Ge.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Bi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Bi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ge.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Bi.create=e=>new Bi(e);const l0=(e,t)=>{let n;switch(e.code){case Y.invalid_type:e.received===ue.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ge.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ge.joinValues(e.keys,", ")}`;break;case Y.invalid_union:n="Invalid input";break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ge.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Ge.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n="Invalid function arguments";break;case Y.invalid_return_type:n="Invalid function return type";break;case Y.invalid_date:n="Invalid date";break;case Y.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ge.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Y.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 Y.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 Y.custom:n="Invalid input";break;case Y.invalid_intersection_types:n="Intersection results could not be merged";break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ge.assertNever(e)}return{message:n}};let MO=l0;function AO(){return MO}const jO=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function ie(e,t){const n=AO(),r=jO({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===l0?void 0:l0].filter(i=>!!i)});e.common.issues.push(r)}class Rn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Ne;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Rn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Ne;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Ne=Object.freeze({status:"aborted"}),Ql=e=>({status:"dirty",value:e}),kr=e=>({status:"valid",value:e}),_w=e=>e.status==="aborted",yw=e=>e.status==="dirty",Ua=e=>e.status==="valid",Vh=e=>typeof Promise<"u"&&e instanceof Promise;var ge;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ge||(ge={}));class li{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const bw=(e,t)=>{if(Ua(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 Bi(e.common.issues);return this._error=n,this._error}}};function je(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class We{get description(){return this._def.description}_getType(t){return ls(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ls(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Rn,ctx:{common:t.parent.common,data:t.data,parsedType:ls(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Vh(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:ls(t)},i=this._parseSync({data:t,path:r.path,parent:r});return bw(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ls(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Ua(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>Ua(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ls(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Vh(i)?i:Promise.resolve(i));return bw(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:Y.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new bo({schema:this,typeName:Te.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 Mi.create(this,this._def)}nullable(){return wo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ii.create(this)}promise(){return Zh.create(this,this._def)}or(t){return Kh.create([this,t],this._def)}and(t){return Gh.create(this,t,this._def)}transform(t){return new bo({...je(this._def),schema:this,typeName:Te.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Qh({...je(this._def),innerType:this,defaultValue:n,typeName:Te.ZodDefault})}brand(){return new wT({typeName:Te.ZodBranded,type:this,...je(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Jh({...je(this._def),innerType:this,catchValue:n,typeName:Te.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return $_.create(this,t)}readonly(){return ef.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const LO=/^c[^\s-]{8,}$/i,DO=/^[0-9a-z]+$/,OO=/^[0-9A-HJKMNP-TV-Z]{26}$/i,BO=/^[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,zO=/^[a-z0-9_-]{21}$/i,$O=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,FO=/^[-+]?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)?)??$/,HO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,UO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pm;const WO=/^(?:(?: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])$/,VO=/^(?:(?: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])$/,qO=/^(([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]))$/,KO=/^(([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])$/,GO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,YO=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_T="((\\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])))",XO=new RegExp(`^${_T}$`);function yT(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 ZO(e){return new RegExp(`^${yT(e)}$`)}function QO(e){let t=`${_T}T${yT(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 JO(e,t){return!!((t==="v4"||!t)&&WO.test(e)||(t==="v6"||!t)&&qO.test(e))}function e6(e,t){if(!$O.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function t6(e,t){return!!((t==="v4"||!t)&&VO.test(e)||(t==="v6"||!t)&&KO.test(e))}class Ti extends We{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ue.string){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.string,received:s.parsedType}),Ne}const r=new Rn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?ie(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ie(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")HO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"email",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Pm||(Pm=new RegExp(UO,"u")),Pm.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"emoji",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")BO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"uuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")zO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"nanoid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")LO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")DO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid2",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")OO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ulid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),ie(i,{validation:"url",code:Y.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"regex",code:Y.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?QO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?XO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?ZO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?FO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"duration",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?JO(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ip",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?e6(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"jwt",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?t6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cidr",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?GO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?YO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64url",code:Y.invalid_string,message:s.message}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Y.invalid_string,...ge.errToObj(r)})}_addCheck(t){return new Ti({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ge.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ge.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ge.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ge.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ge.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ge.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ge.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ge.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ge.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ge.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ge.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ge.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ge.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,...ge.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,...ge.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...ge.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ge.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ge.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ge.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ge.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ge.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ge.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ge.errToObj(n)})}nonempty(t){return this.min(1,ge.errToObj(t))}trim(){return new Ti({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ti({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ti({...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}}Ti.create=e=>new Ti({checks:[],typeName:Te.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});function n6(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class Wa extends We{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)!==ue.number){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.number,received:s.parsedType}),Ne}let r;const i=new Rn;for(const s of this._def.checks)s.kind==="int"?Ge.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?n6(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.not_finite,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new Wa({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Wa({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ge.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ge.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ge.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ge.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ge.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}Wa.create=e=>new Wa({checks:[],typeName:Te.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class Gc extends We{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)!==ue.bigint)return this._getInvalidInput(t);let r;const i=new Rn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),ie(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:ue.bigint,received:n.parsedType}),Ne}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new Gc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Gc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.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}}Gc.create=e=>new Gc({checks:[],typeName:Te.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});class c0 extends We{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ue.boolean){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.boolean,received:r.parsedType}),Ne}return kr(t.data)}}c0.create=e=>new c0({typeName:Te.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class qh extends We{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ue.date){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.date,received:s.parsedType}),Ne}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_date}),Ne}const r=new Rn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new qh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ge.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ge.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}}qh.create=e=>new qh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Te.ZodDate,...je(e)});class ww extends We{_parse(t){if(this._getType(t)!==ue.symbol){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.symbol,received:r.parsedType}),Ne}return kr(t.data)}}ww.create=e=>new ww({typeName:Te.ZodSymbol,...je(e)});class u0 extends We{_parse(t){if(this._getType(t)!==ue.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.undefined,received:r.parsedType}),Ne}return kr(t.data)}}u0.create=e=>new u0({typeName:Te.ZodUndefined,...je(e)});class d0 extends We{_parse(t){if(this._getType(t)!==ue.null){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.null,received:r.parsedType}),Ne}return kr(t.data)}}d0.create=e=>new d0({typeName:Te.ZodNull,...je(e)});class Sw extends We{constructor(){super(...arguments),this._any=!0}_parse(t){return kr(t.data)}}Sw.create=e=>new Sw({typeName:Te.ZodAny,...je(e)});class h0 extends We{constructor(){super(...arguments),this._unknown=!0}_parse(t){return kr(t.data)}}h0.create=e=>new h0({typeName:Te.ZodUnknown,...je(e)});class Rs extends We{_parse(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:ue.never,received:n.parsedType}),Ne}}Rs.create=e=>new Rs({typeName:Te.ZodNever,...je(e)});class kw extends We{_parse(t){if(this._getType(t)!==ue.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.void,received:r.parsedType}),Ne}return kr(t.data)}}kw.create=e=>new kw({typeName:Te.ZodVoid,...je(e)});class ii extends We{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ue.array)return ie(n,{code:Y.invalid_type,expected:ue.array,received:n.parsedType}),Ne;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(ie(n,{code:o?Y.too_big:Y.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(ie(n,{code:Y.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(ie(n,{code:Y.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new li(n,o,n.path,a)))).then(o=>Rn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new li(n,o,n.path,a)));return Rn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ii({...this._def,minLength:{value:t,message:ge.toString(n)}})}max(t,n){return new ii({...this._def,maxLength:{value:t,message:ge.toString(n)}})}length(t,n){return new ii({...this._def,exactLength:{value:t,message:ge.toString(n)}})}nonempty(t){return this.min(1,t)}}ii.create=(e,t)=>new ii({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Te.ZodArray,...je(t)});function ra(e){if(e instanceof Ot){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Mi.create(ra(r))}return new Ot({...e._def,shape:()=>t})}else return e instanceof ii?new ii({...e._def,type:ra(e.element)}):e instanceof Mi?Mi.create(ra(e.unwrap())):e instanceof wo?wo.create(ra(e.unwrap())):e instanceof _o?_o.create(e.items.map(t=>ra(t))):e}class Ot extends We{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ge.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ue.object){const c=this._getOrReturnCtx(t);return ie(c,{code:Y.invalid_type,expected:ue.object,received:c.parsedType}),Ne}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Rs&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new li(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Rs){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(ie(i,{code:Y.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new li(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Rn.mergeObjectSync(r,c)):Rn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return ge.errToObj,new Ot({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:ge.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ot({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ot({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Te.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Ot({...this._def,catchall:t})}pick(t){const n={};for(const r of Ge.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Ot({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ge.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Ot({...this._def,shape:()=>n})}deepPartial(){return ra(this)}partial(t){const n={};for(const r of Ge.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Ot({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ge.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Mi;)s=s._def.innerType;n[r]=s}return new Ot({...this._def,shape:()=>n})}keyof(){return bT(Ge.objectKeys(this.shape))}}Ot.create=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strip",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});Ot.strictCreate=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strict",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});Ot.lazycreate=(e,t)=>new Ot({shape:e,unknownKeys:"strip",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});class Kh extends We{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Bi(a.ctx.common.issues));return ie(n,{code:Y.invalid_union,unionErrors:o}),Ne}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Bi(l));return ie(n,{code:Y.invalid_union,unionErrors:a}),Ne}}get options(){return this._def.options}}Kh.create=(e,t)=>new Kh({options:e,typeName:Te.ZodUnion,...je(t)});const wi=e=>e instanceof p0?wi(e.schema):e instanceof bo?wi(e.innerType()):e instanceof Xh?[e.value]:e instanceof yo?e.options:e instanceof m0?Ge.objectValues(e.enum):e instanceof Qh?wi(e._def.innerType):e instanceof u0?[void 0]:e instanceof d0?[null]:e instanceof Mi?[void 0,...wi(e.unwrap())]:e instanceof wo?[null,...wi(e.unwrap())]:e instanceof wT||e instanceof ef?wi(e.unwrap()):e instanceof Jh?wi(e._def.innerType):[];class z_ extends We{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ue.object)return ie(n,{code:Y.invalid_type,expected:ue.object,received:n.parsedType}),Ne;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(ie(n,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ne)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=wi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new z_({typeName:Te.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...je(r)})}}function f0(e,t){const n=ls(e),r=ls(t);if(e===t)return{valid:!0,data:e};if(n===ue.object&&r===ue.object){const i=Ge.objectKeys(t),s=Ge.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=f0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ue.array&&r===ue.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=f0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ue.date&&r===ue.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Gh extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(_w(s)||_w(o))return Ne;const a=f0(s.value,o.value);return a.valid?((yw(s)||yw(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:Y.invalid_intersection_types}),Ne)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Gh.create=(e,t,n)=>new Gh({left:e,right:t,typeName:Te.ZodIntersection,...je(n)});class _o extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ue.array)return ie(r,{code:Y.invalid_type,expected:ue.array,received:r.parsedType}),Ne;if(r.data.length<this._def.items.length)return ie(r,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ne;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:Y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new li(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Rn.mergeArray(n,o)):Rn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new _o({...this._def,rest:t})}}_o.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _o({items:e,typeName:Te.ZodTuple,rest:null,...je(t)})};class Yh extends We{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!==ue.object)return ie(r,{code:Y.invalid_type,expected:ue.object,received:r.parsedType}),Ne;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new li(r,a,r.path,a)),value:o._parse(new li(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Rn.mergeObjectAsync(n,i):Rn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof We?new Yh({keyType:t,valueType:n,typeName:Te.ZodRecord,...je(r)}):new Yh({keyType:Ti.create(),valueType:t,typeName:Te.ZodRecord,...je(n)})}}class Cw extends We{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!==ue.map)return ie(r,{code:Y.invalid_type,expected:ue.map,received:r.parsedType}),Ne;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new li(r,a,r.path,[c,"key"])),value:s._parse(new li(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Ne;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Ne;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Cw.create=(e,t,n)=>new Cw({valueType:t,keyType:e,typeName:Te.ZodMap,...je(n)});class Yc extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ue.set)return ie(r,{code:Y.invalid_type,expected:ue.set,received:r.parsedType}),Ne;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(ie(r,{code:Y.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(ie(r,{code:Y.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Ne;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new li(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Yc({...this._def,minSize:{value:t,message:ge.toString(n)}})}max(t,n){return new Yc({...this._def,maxSize:{value:t,message:ge.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Yc.create=(e,t)=>new Yc({valueType:e,minSize:null,maxSize:null,typeName:Te.ZodSet,...je(t)});class p0 extends We{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})}}p0.create=(e,t)=>new p0({getter:e,typeName:Te.ZodLazy,...je(t)});class Xh extends We{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ie(n,{received:n.data,code:Y.invalid_literal,expected:this._def.value}),Ne}return{status:"valid",value:t.data}}get value(){return this._def.value}}Xh.create=(e,t)=>new Xh({value:e,typeName:Te.ZodLiteral,...je(t)});function bT(e,t){return new yo({values:e,typeName:Te.ZodEnum,...je(t)})}class yo extends We{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{expected:Ge.joinValues(r),received:n.parsedType,code:Y.invalid_type}),Ne}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 ie(n,{received:n.data,code:Y.invalid_enum_value,options:r}),Ne}return kr(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 yo.create(t,{...this._def,...n})}exclude(t,n=this._def){return yo.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}yo.create=bT;class m0 extends We{_parse(t){const n=Ge.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ue.string&&r.parsedType!==ue.number){const i=Ge.objectValues(n);return ie(r,{expected:Ge.joinValues(i),received:r.parsedType,code:Y.invalid_type}),Ne}if(this._cache||(this._cache=new Set(Ge.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ge.objectValues(n);return ie(r,{received:r.data,code:Y.invalid_enum_value,options:i}),Ne}return kr(t.data)}get enum(){return this._def.values}}m0.create=(e,t)=>new m0({values:e,typeName:Te.ZodNativeEnum,...je(t)});class Zh extends We{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ue.promise&&n.common.async===!1)return ie(n,{code:Y.invalid_type,expected:ue.promise,received:n.parsedType}),Ne;const r=n.parsedType===ue.promise?n.data:Promise.resolve(n.data);return kr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Zh.create=(e,t)=>new Zh({type:e,typeName:Te.ZodPromise,...je(t)});class bo extends We{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{ie(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Ne;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ne:l.status==="dirty"||n.value==="dirty"?Ql(l.value):l});{if(n.value==="aborted")return Ne;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ne:a.status==="dirty"||n.value==="dirty"?Ql(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Ne:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Ne:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ua(o))return Ne;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ua(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Ne);Ge.assertNever(i)}}bo.create=(e,t,n)=>new bo({schema:e,typeName:Te.ZodEffects,effect:t,...je(n)});bo.createWithPreprocess=(e,t,n)=>new bo({schema:t,effect:{type:"preprocess",transform:e},typeName:Te.ZodEffects,...je(n)});class Mi extends We{_parse(t){return this._getType(t)===ue.undefined?kr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Mi.create=(e,t)=>new Mi({innerType:e,typeName:Te.ZodOptional,...je(t)});class wo extends We{_parse(t){return this._getType(t)===ue.null?kr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wo.create=(e,t)=>new wo({innerType:e,typeName:Te.ZodNullable,...je(t)});class Qh extends We{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ue.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Qh.create=(e,t)=>new Qh({innerType:e,typeName:Te.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...je(t)});class Jh extends We{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Vh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Bi(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Bi(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Jh.create=(e,t)=>new Jh({innerType:e,typeName:Te.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...je(t)});class Ew extends We{_parse(t){if(this._getType(t)!==ue.nan){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.nan,received:r.parsedType}),Ne}return{status:"valid",value:t.data}}}Ew.create=e=>new Ew({typeName:Te.ZodNaN,...je(e)});class wT extends We{_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 $_ extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Ne:s.status==="dirty"?(n.dirty(),Ql(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Ne:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new $_({in:t,out:n,typeName:Te.ZodPipeline})}}class ef extends We{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ua(i)&&(i.value=Object.freeze(i.value)),i);return Vh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}ef.create=(e,t)=>new ef({innerType:e,typeName:Te.ZodReadonly,...je(t)});var Te;(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"})(Te||(Te={}));const w=Ti.create,V=Wa.create,_e=c0.create,Es=h0.create;Rs.create;const se=ii.create,P=Ot.create;Kh.create;const fi=z_.create;Gh.create;_o.create;const zs=Yh.create,ee=Xh.create,Le=yo.create;Zh.create;Mi.create;wo.create;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const r6=["owner"],i6=["agent","owner","user-upload"],ST=P({id:w().min(1),relPath:w().min(1),from:Le(i6),label:w().optional(),size:V().int().nonnegative(),mime:w().min(1),addedAt:V().int().nonnegative(),lastEditedAt:V().int().nonnegative().optional(),stale:_e().optional()});P({sessionId:w().min(1),relPath:w().min(1),ttlSeconds:V().int().positive().nullable().optional(),view:Le(["raw","md-rendered"]).optional()});P({url:w().min(1),expiresAt:V().int().nonnegative().nullable()});P({sessionId:w().min(1),relPath:w().min(1),label:w().optional(),origin:ee("agent").optional()});P({entry:ST});P({sessionId:w().min(1),relPath:w().min(1)});P({removed:ee(!0)});P({sessionId:w().min(1)});P({entries:se(ST)});P({attachmentId:w().min(1),url:w().min(1),relPath:w().min(1),sizeBytes:V().int().nonnegative(),mimeType:w().min(1)});const s6=fi("type",[P({type:ee("persona"),id:w().min(1)}).strict(),P({type:ee("chat"),id:w().min(1)}).strict(),P({type:ee("*")}).strict()]),o6=Le(["read","send","admin"]),F_=P({resource:s6,actions:se(o6).min(1)}).strict(),a6=P({id:w().min(1),secretHash:w().regex(/^[a-f0-9]{64}$/),displayName:w(),grants:se(F_),issuedAt:V().int().nonnegative(),expiresAt:V().int().positive().optional(),maxUses:V().int().positive().optional(),usedCount:V().int().nonnegative(),peerOwnerId:w().min(1).optional(),firstUsedByPeerAt:V().int().positive().optional(),peerDisplayName:w().optional()}).strict(),l6=a6.omit({secretHash:!0});P({type:ee("whoami:ok"),owner:P({id:w(),kind:Le(["owner","guest"]),displayName:w(),ownerId:w(),provider:w()}).strict(),capability:l6,grantedPersonas:se(P({id:w().min(1),displayName:w()}).strict())}).strict();P({selfUrl:w().min(1)});P({type:ee("contact:handshake:ok"),owner:P({id:w(),ownerId:w(),provider:w(),displayName:w()}),grants:se(F_)});P({deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();P({type:ee("contact:setRemoteAccess:ok"),deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();P({type:ee("contact:remote-access-updated"),deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();const c6=P({deviceId:w().min(1),ownerId:w().min(1),provider:w().min(1),displayName:w(),remoteUrl:w().min(1),connectToken:w(),grants:se(F_),addedAt:V().int().nonnegative(),pinnedAt:V().int().nullable().default(null),remoteAccessAllowed:_e().default(!1)}).strict(),kT=c6;P({deviceId:w().min(1)}).strict();P({type:ee("contact:remove:ok"),deviceId:w().min(1)}).strict();P({type:ee("contact:list:ok"),contacts:se(kT)}).strict();P({type:ee("contact:added"),contact:kT}).strict();P({type:ee("contact:removed"),deviceId:w().min(1)}).strict();P({deviceId:w().min(1),pinned:_e()}).strict();P({type:ee("contact:pin:ok"),deviceId:w().min(1),pinnedAt:V().int().nullable()}).strict();P({type:ee("contact:pinned"),deviceId:w().min(1),pinnedAt:V().int().nullable()}).strict();const u6=P({deviceId:w().min(1),name:w().min(1),url:w().min(1)});P({type:ee("device:list:ok"),devices:se(u6)});P({deviceId:w().min(1),url:w().min(1).optional(),name:w().optional()});P({type:ee("device:connect:ok"),deviceId:w(),name:w(),url:w()});const CT=P({ownerId:w().min(1),provider:w().min(1),displayName:w().min(1),avatarUrl:w().optional(),unionId:w().optional()});P({type:ee("auth:login:start:ok"),authUrl:w().min(1),state:w().min(1)});P({type:ee("auth:getIdentity:ok"),identity:CT.nullable(),deviceId:w().min(1),ttcTokenExpiresAt:V().nullable().optional()});P({type:ee("auth:logout:ok")});P({type:ee("auth:login:done"),identity:CT});P({type:ee("auth:login:failed"),reason:w()});const H_=fi("kind",[P({kind:ee("success"),text:w(),brief:w().optional(),filePaths:se(w()).optional()}),P({kind:ee("failure"),reason:w(),brief:w().optional()})]);P({targetPersona:w().min(1).optional(),dispatchId:w().min(1).optional(),prompt:w(),brief:w().optional(),targetDeviceId:w().min(1).optional(),model:w().min(1).optional(),tool:w().min(1).optional(),sessionLabel:w().min(1).max(60).optional(),meta:zs(Es()).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});P({dispatchId:w().min(1),outcome:H_});const d6=["running","completed","failed"],U_=Le(d6),h6=P({dispatchId:w().min(1),sourceSessionId:w().min(1),sourcePersonaId:w().min(1).optional(),targetPersonaId:w().min(1),workerSessionId:w().min(1).optional(),taskText:w(),taskBrief:w().optional(),round:V().int().positive().optional(),status:U_,outcome:H_.optional(),meta:zs(Es()).optional(),createdAt:w().min(1),completedAt:w().min(1).optional(),deliveredAt:w().min(1).optional()});P({sourceSessionId:w().min(1).optional()});P({records:se(h6)});P({dispatchId:w().min(1)});P({type:ee("personaDispatch:get:ok"),status:U_,outcome:H_.optional()});const f6=/^[a-z0-9][a-z0-9-]*$/;Le(["stopped","starting","running","crashed","invalid"]);const p6=new Set(["localhost","127.0.0.1"]);function m6(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&p6.has(t.hostname))}const fd=P({id:w().regex(f6),name:w().min(1),version:w().min(1),apiVersion:ee("1"),runtime:P({startCommand:w().min(1)}).passthrough().optional(),entry:P({url:w().url().refine(m6,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),g6=fi("kind",[P({kind:ee("local"),port:V().int().min(1).max(65535)}),P({kind:ee("hosted"),url:w().url()})]);fi("state",[P({extId:w(),manifest:fd,state:ee("stopped")}),P({extId:w(),manifest:fd,state:ee("starting")}),P({extId:w(),manifest:fd,state:ee("running"),target:g6}),P({extId:w(),manifest:fd,state:ee("crashed")}),P({extId:w(),manifest:Es().nullable(),state:ee("invalid"),invalidReason:w().min(1)})]);P({snapshotHash:w().min(1),version:w().min(1),publishedAt:V()});const v6=fi("kind",[P({kind:ee("p2p-tunnel"),ownerPrincipalId:w().min(1),extId:w().min(1)})]);fi("kind",[P({kind:ee("p2p-tunnel"),ownerPrincipalId:w().min(1),extId:w().min(1),snapshotHash:w().min(1)})]);P({extId:w().min(1),name:w().min(1),version:w().min(1),contentHash:w().min(1),publishedAt:V()});const x6=fi("kind",[P({kind:ee("clean")}),P({kind:ee("ready-new-version"),fromVersion:w().min(1),toVersion:w().min(1)}),P({kind:ee("error-same-hash"),version:w().min(1)}),P({kind:ee("error-version-not-bumped"),localVersion:w().min(1),publishedVersion:w().min(1)}),P({kind:ee("error-version-regression"),localVersion:w().min(1),publishedVersion:w().min(1)})]);P({localManifest:P({name:w().min(1),version:w().min(1),contentHash:w().min(1)}),publishState:fi("kind",[P({kind:ee("unpublished")}),P({kind:ee("published"),version:w().min(1),contentHash:w().min(1),publishedAt:V()})]),check:x6});P({extId:w().min(1),newVersion:w().min(1).nullish()});P({extId:w().min(1)});P({extId:w().min(1),snapshotHash:w().min(1)});P({channelRef:v6,snapshotHash:w().min(1),zipBase64:w().min(1)});P({id:w().min(1),peerDeviceId:w().min(1),senderDeviceId:w().min(1),text:w().min(1),createdAt:V().int().nonnegative(),readBy:zs(w().min(1),V().int().positive()).default({}),origin:P({kind:ee("persona"),personaId:w().min(1)}).optional()}).strict();P({peerDeviceId:w().min(1).optional(),id:w().min(1),text:w().min(1),createdAt:V().int().nonnegative(),origin:P({kind:ee("persona"),personaId:w().min(1)}).optional()}).strict();P({peerDeviceId:w().min(1),sinceCreatedAt:V().int().nonnegative().optional()}).strict();P({peerDeviceId:w().min(1),upToCreatedAt:V().int().nonnegative()}).strict();P({peerDeviceId:w().min(1).optional(),text:w().min(1)});P({peerDeviceId:w().min(1).optional(),command:w().min(1),timeoutMs:V().int().positive().optional()}).strict();P({type:ee("peerExec:run:ok"),stdout:w(),stderr:w(),exitCode:V().int().nullable(),timedOut:_e(),stdoutTruncated:_e(),stderrTruncated:_e()}).strict();const ET=fi("kind",[P({kind:ee("at"),at:w().min(1)}),P({kind:ee("every"),everyMs:V().int().positive(),anchorMs:V().int().nonnegative().optional()}),P({kind:ee("cron"),expr:w().min(1),tz:w().min(1).optional()})]),vu=w().trim().min(1);P({personaId:vu,name:w().min(1),schedule:ET,prompt:w().min(1),targetPersona:w().min(1).optional(),timeoutMs:V().int().positive().optional()});P({personaId:vu,onlyMine:_e().optional()});P({personaId:vu,shiftId:w().min(1)});const _6=P({name:w().min(1).optional(),schedule:ET.optional(),prompt:w().min(1).optional(),targetPersona:w().min(1).optional(),timeoutMs:V().int().positive().optional(),enabled:_e().optional()});P({personaId:vu,shiftId:w().min(1),patch:_6});P({personaId:vu,shiftId:w().min(1),limit:V().int().positive().optional()});const NT=P({id:w().min(1),name:w().min(1),memberPersonaIds:se(w().min(1)),memberContactDeviceIds:se(w().min(1)),createdAt:w().min(1),updatedAt:w().min(1)}),TT=w().trim().min(1);P({name:TT,memberPersonaIds:se(w().min(1)).default([]),memberContactDeviceIds:se(w().min(1)).default([])});P({channelId:w().min(1),name:TT.optional(),memberPersonaIds:se(w().min(1)).optional(),memberContactDeviceIds:se(w().min(1)).optional()});P({channelId:w().min(1)});P({channels:se(NT)});P({channel:NT});P({ok:ee(!0),removedTopics:V().int().min(0)});const yn=w().trim().min(1),y6=["planning","running","done"],b6=Le(y6),w6=P({at:w().min(1),actor:w().min(1),action:w().min(1),target:w().optional(),reason:w().min(1),artifacts:se(yn).optional()}),S6=P({rejectCount:V().int().min(0),accepted:_e().default(!1),overrideCount:V().int().min(0).optional()}),W_=P({id:w().min(1),channelId:w().min(1),title:w(),masterSessionId:w().min(1),goal:w(),boundaries:w(),acceptanceCriteria:se(w()),activity:se(w6),lineMeta:zs(S6),state:b6,createdAt:w().min(1),updatedAt:w().min(1)}),k6=P({lineId:w().min(1),dispatchId:w().min(1),workerSessionId:w().optional(),assignee:w().min(1),focus:w(),status:U_,acceptance:se(w()),rejectCount:V().int().min(0),accepted:_e()});P({channelId:w().min(1)});P({topicId:w().min(1).optional(),sessionId:w().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});P({channelId:w().min(1),title:yn.optional()});P({topicId:w().min(1),title:yn.optional(),goal:yn,boundaries:w(),acceptanceCriteria:se(yn).min(1)});P({topicId:w().min(1),action:yn,target:yn.optional(),reason:yn,artifacts:se(yn).optional()});P({topicId:w().min(1),lineId:yn,reason:yn});P({topicId:w().min(1),lineId:yn,reason:yn,artifacts:se(yn).optional(),watcherVerdict:Le(["pass","fail"]),overrideReason:yn.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});P({topicId:w().min(1),state:Le(["done"])});P({topicId:w().min(1),title:yn});P({topicId:w().min(1)});const C6=W_.extend({lineCount:V().int().min(0)});P({topics:se(C6)});P({topic:W_,lines:se(k6)});P({topicId:w().min(1),masterSessionId:w().min(1)});P({rejectCount:V().int().min(1),needsOwnerAttention:_e()});P({acceptedLines:V().int().min(1),totalLines:V().int().min(1),allAccepted:_e(),overrides:V().int().min(0),needsOwnerAttention:_e()});P({topic:W_});P({ok:ee(!0),removedMasterSessionId:w().min(1).nullable()});const E6=["ask","allow","deny"],IT=Le(E6),N6=P({id:w().min(1),desc:w().min(1),action:IT});P({rules:se(N6)});P({ruleId:w().min(1)});P({action:IT,desc:w(),source:w().min(1)});const T6=["created","review-requested"],PT=/^[A-Za-z0-9._-]+$/,dl=w().min(1).regex(PT),hl=w().min(1).regex(PT),xu=V().int().positive();P({role:Le(T6)});P({owner:dl,repo:hl,number:xu});P({owner:dl,repo:hl,number:xu,expectedHeadSha:w().min(1)});P({owner:dl,repo:hl,number:xu,body:w().min(1)});P({owner:dl,repo:hl,number:xu,ready:_e()});P({owner:dl,repo:hl});P({owner:dl,repo:hl,number:xu,reviewers:se(w().min(1)).min(1)});P({personaId:w().min(1)});const I6=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],P6=Le(I6);P({personaId:w().min(1),appId:w().min(1),appSecret:w().min(1),botName:w().min(1).optional()});const R6=P({chatId:w().min(1),chatName:w().optional(),lastActiveAt:V().int().optional()}),M6=P({state:Le(["unbound","provisioning","bound","broken"]),appId:w().optional(),botName:w().optional(),brokenReason:w().optional(),qrUrl:w().optional(),errorReason:P6.optional(),groups:se(R6)});M6.extend({personaId:w().min(1)});P({});P({onboardingCompletedAt:V()});P({});P({tools:se(P({id:Le(["claude","codex"]),available:_e(),version:w().optional(),path:w().optional()}))});P({});const A6=P({tool:Le(["claude","codex"]),cwd:w(),toolSessionId:w(),label:w().optional(),createdAt:w(),updatedAt:w(),turns:V()});P({candidates:se(A6)});P({});P({registered:_e()});const j6=P({personaId:w(),label:w(),model:w().optional(),effort:w().optional(),public:_e(),iconKey:w().optional(),tool:w().optional(),createdAt:V(),updatedAt:V()}).strict(),L6=P({name:w().min(1),description:w().optional()}),D6=P({id:w().min(1)}),O6=P({permissions:P({defaultMode:w().optional(),allow:se(w()).optional(),deny:se(w()).optional()}).optional(),sandbox:P({enabled:_e().optional(),autoAllowBashIfSandboxed:_e().optional(),allowUnsandboxedCommands:_e().optional(),excludedCommands:se(w()).optional(),filesystem:P({denyRead:se(w()).optional(),allowRead:se(w()).optional(),denyWrite:se(w()).optional(),allowWrite:se(w()).optional()}).optional(),network:P({allowedDomains:se(w()).optional(),allowLocalBinding:_e().optional()}).optional()}).optional()});j6.extend({personality:w().optional(),skills:se(L6).optional(),plugins:se(D6).optional(),sandboxSettings:O6.nullable().optional()});P({slug:w().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:w().min(1),personality:w(),model:w().optional(),effort:w().optional(),tool:w().optional(),public:_e().optional(),iconKey:w().optional()}).strict();P({personaId:w().min(1)});P({personaId:w().min(1),patch:P({label:w().min(1).optional(),model:w().optional(),effort:w().optional(),tool:w().optional(),personality:w().optional(),public:_e().optional(),iconKey:w().nullable().optional()}).strict()}).strict();P({writableRoots:se(w()).optional(),denyRead:se(w()).optional(),network:_e().optional()}).strict();const RT=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","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","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed","larkBot:state"],MT=["idle","running","running-idle","stopped","error","observing"],B6=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function op(e){return e==="dispatch-task"||e==="dispatch-result"}const z6=["builtin","global","project","plugin"],$6=["builtin","global","project","policy","plugin"],AT=Le(["owner","guest"]);P({id:w().min(1),kind:AT,displayName:w(),feishuUnionId:w().optional()}).strict();const F6=P({did:w().min(1),displayName:w(),feishuUnionId:w().optional(),principal:AT}).strict(),H6=Le(MT),U6=P({input_tokens:V().int().nonnegative().optional(),cache_read_input_tokens:V().int().nonnegative().optional(),cache_creation_input_tokens:V().int().nonnegative().optional(),output_tokens:V().int().nonnegative().optional()}),W6=P({inputTokens:V().int().nonnegative(),outputTokens:V().int().nonnegative(),cacheReadTokens:V().int().nonnegative().optional(),cacheCreateTokens:V().int().nonnegative().optional()}),jT={gitBranch:w().optional(),resolvedModel:w().optional(),resolvedEffort:w().optional(),contextUsage:W6.optional(),contextWindowSize:V().int().positive().optional(),aiLabel:w().optional()},V6=P(jT),LT=P({value:w(),label:w(),description:w().optional()}),q6=P({id:w().min(1),label:w().min(1),description:w().optional(),contextWindowSize:V().int().positive(),default:_e().optional(),efforts:se(LT).optional(),defaultEffort:w().optional()}),K6=P({id:w().min(1),label:w().min(1),description:w().optional()}),G6=P({name:w().min(1),type:Le(["string","select","toggle"]),label:w().min(1),description:w().optional(),options:se(LT).optional(),default:Es().optional(),scope:Le(["core","tool-specific"])});P({tool:w().min(1)});const Y6=P({rewind:_e(),subagents:_e(),tui:_e(),observe:_e(),fileSharing:_e(),fork:_e()});P({tool:w().min(1),toolSessionIdLabel:w().optional(),models:se(q6),permissionModes:se(K6),configSchema:se(G6),features:Y6});const X6=P({tool:w().min(1),pattern:w().min(1),createdAt:w().min(1).optional()});P({sessionId:w().min(1),cwd:w().min(1),tool:ee("claude").or(w().min(1)).default("claude"),toolSessionId:w().optional(),label:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),...jT,aiLabelGeneratedAt:w().optional(),permissionRules:se(X6).optional(),pinnedAt:V().int().nonnegative().nullable().optional(),archivedAt:V().int().nonnegative().nullable().optional(),pinSortOrder:V().int().nullable().optional(),unreadAt:w().min(1).nullable().optional(),iconKey:w().optional(),forkedFromSessionId:w().min(1).optional(),ephemeral:_e().optional(),ownerPersonaId:w().min(1).optional(),projectPath:w().min(1).optional(),appBuilderProject:w().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:w().min(1).optional(),creatorPrincipalId:w().min(1).optional(),creatorDisplayName:w().min(1).optional(),creatorFeishuUnionId:w().min(1).optional(),originOwnerPrincipalId:w().min(1).optional(),originOwnerPersonaId:w().min(1).optional(),dispatchedFromSessionId:w().min(1).optional(),shiftFiredFromSessionId:w().min(1).optional(),larkChatId:w().min(1).optional(),larkChatName:w().min(1).optional(),larkChatType:Le(["p2p","group"]).optional(),createdAt:w().min(1),updatedAt:w().min(1)});const Bn={seq:V().int().nonnegative().optional(),ts:w().optional(),uuid:w().optional()},Z6=Le(B6),Q6=P({readCount:V().int().nonnegative().optional(),searchCount:V().int().nonnegative().optional(),bashCount:V().int().nonnegative().optional(),editFileCount:V().int().nonnegative().optional(),linesAdded:V().int().nonnegative().optional(),linesRemoved:V().int().nonnegative().optional(),otherToolCount:V().int().nonnegative().optional()}),J6=P({oldStart:V().int().nonnegative(),oldLines:V().int().nonnegative(),newStart:V().int().nonnegative(),newLines:V().int().nonnegative(),lines:se(w())}),eB=P({agentId:w().optional(),agentType:w().optional(),status:w().optional(),prompt:w().optional(),filePath:w().optional(),structuredPatch:se(J6).optional(),stats:P({durationMs:V().int().nonnegative().optional(),tokens:V().int().nonnegative().optional(),toolUseCount:V().int().nonnegative().optional(),toolStats:Q6.optional(),usage:U6.optional()}).optional()}),tB=P({path:w(),content:w(),mtimeMs:V().optional()}),nB=P({label:w().min(1),description:w().optional()}),DT=P({question:w().min(1),multiSelect:_e(),options:se(nB).min(1)}),rB=["completed","interrupted"];fi("kind",[P({...Bn,kind:ee("session_init"),toolSessionId:w().optional()}),P({...Bn,kind:ee("thinking"),text:w(),partialId:w().optional()}),P({...Bn,kind:ee("text"),text:w(),partialId:w().optional()}),P({...Bn,kind:ee("user_text"),text:w(),meta:Z6.optional(),taskId:w().optional(),parentToolUseId:w().optional(),sender:F6.optional()}),P({...Bn,kind:ee("tool_call"),toolUseId:w(),tool:w(),toolKind:w().optional(),input:Es()}),P({...Bn,kind:ee("tool_result"),toolUseId:w(),output:Es().optional(),error:w().optional(),toolResultExtra:eB.optional(),sourceToolAssistantUUID:w().optional(),askQuestionAnswers:zs(w(),w()).optional()}),P({...Bn,kind:ee("attachment_memories"),memories:se(tB)}),P({...Bn,kind:ee("permission_request"),requestId:w(),tool:w(),input:Es(),toolUseId:w().optional()}),P({...Bn,kind:ee("ask_user_question"),toolUseId:w(),questions:se(DT)}),P({...Bn,kind:ee("turn_end"),durationMs:V().int().nonnegative().optional(),reason:Le(rB).optional()}),P({...Bn,kind:ee("subagent_progress"),toolUseId:w(),agentId:w(),status:Le(["started","running","completed","failed"]),description:w().optional(),lastToolName:w().optional(),prompt:w().optional(),stats:P({durationMs:V().int().nonnegative().optional(),tokens:V().int().nonnegative().optional(),toolUseCount:V().int().nonnegative().optional()}).optional()}),P({...Bn,kind:ee("error"),message:w()}),P({...Bn,kind:ee("meta_update"),patch:V6}),P({...Bn,kind:ee("meta-text"),text:w(),metaSource:Le(["cc","owner"]).optional()})]);P({cwd:w().min(1).optional(),tool:w().optional(),label:w().optional(),aiLabel:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),iconKey:w().optional(),forkedFromSessionId:w().min(1).optional(),ephemeral:_e().optional(),ownerPersonaId:w().min(1).optional(),projectPath:w().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});P({path:w().min(1),name:w().min(1),createdAt:w().datetime(),pinnedAt:V().optional()});P({path:w().min(1),pinnedAt:V().nullable()});P({path:w().min(1)});P({path:w().min(1).optional(),name:w().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});P({cwd:w().min(1),tool:w().min(1),toolSessionId:w().min(1),label:w().optional(),aiLabel:w().optional(),iconKey:w().optional(),createdAt:w().datetime(),updatedAt:w().datetime(),ownerPersonaId:w().min(1).optional()});P({originOnly:_e().optional(),ownerPersonaId:w().min(1).optional(),limit:V().int().positive().optional(),offset:V().int().nonnegative().optional()});P({sessionId:w().min(1)});P({sessionId:w().min(1),patch:P({label:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),cwd:w().optional(),iconKey:w().optional(),ephemeral:ee(!1).optional()})});P({sessionId:w().min(1),text:w()});P({sessionId:w().min(1),userMessageId:w().min(1),dryRun:_e().optional()});P({canRewind:_e(),error:w().optional(),filesChanged:se(w()).optional(),insertions:V().int().nonnegative().optional(),deletions:V().int().nonnegative().optional()});P({sessionId:w().min(1),userMessageId:w().min(1)});const iB=P({oldStart:V().int().nonnegative(),oldLines:V().int().nonnegative(),newStart:V().int().nonnegative(),newLines:V().int().nonnegative(),lines:se(w())}),sB=P({filePath:w().min(1),hunks:se(iB),insertions:V().int().nonnegative(),deletions:V().int().nonnegative(),status:Le(["modified","added","deleted"]).optional()});P({canRewind:_e(),error:w().optional(),files:se(sB),totalInsertions:V().int().nonnegative(),totalDeletions:V().int().nonnegative()});P({userMessageIds:se(w())});P({sessionId:w().min(1),toolSessionId:w().min(1)});P({cwd:w().min(1),toolSessionId:w().min(1),messageUuid:w().min(1),targetCwd:w().min(1).optional()});P({forkedToolSessionId:w().min(1),forkedFilePath:w().min(1)});P({sessionId:w().min(1),toolSessionId:w().min(1),jsonlPath:w().optional()});P({sessionId:w().min(1),afterSeq:V().int().min(-1)});P({sessionId:w().min(1),permissionRequestId:w().min(1),allow:_e(),permanent:_e().optional(),pattern:w().optional()});P({projectPath:w().min(1)});P({sessionId:w().min(1),limit:V().int().positive().max(5e3).optional(),offset:V().int().nonnegative().optional(),slim:_e().optional()});P({cwd:w().min(1),toolSessionId:w().min(1)});P({cwd:w().min(1),toolSessionId:w().min(1),subagentId:w().min(1)});P({cwd:w().min(1).optional(),path:w().optional(),showHidden:_e().optional()});P({cwd:w().min(1),path:w().min(1)});P({cwd:w().min(1),tool:w().optional()});P({name:w().min(1),source:Le(z6),path:w().optional(),description:w().optional(),plugin:w().optional()});const oB=P({name:w().min(1),source:Le($6),path:w().optional(),description:w().optional(),whenToUse:w().optional(),plugin:w().optional()});P({cwd:w().min(1),tool:w().optional()});P({agents:se(oB)});P({sessionId:w().optional()});P({sessionId:w().min(1).optional()});P({sessionId:w().min(1),pinned:_e()});P({sessionId:w().min(1),archived:_e()});P({type:ee("peerSession:upsert:ok")});P({sessionId:w().min(1)});P({type:ee("peerSession:remove:ok")});P({orderedIds:se(w().min(1)).min(1)});P({cwd:w().min(1)});P({isGitRoot:_e(),gitRoot:w().nullable()});P({cwd:w().min(1)});P({branch:w().nullable()});P({cwd:w().min(1)});P({branches:se(w()),head:w().nullable()});P({}).optional();const aB=P({cwd:w().min(1),updatedAt:w().min(1)});P({dirs:se(aB)});P({type:ee("session:question"),sessionId:w().min(1),toolUseId:w().min(1),requestId:w().min(1),questions:se(DT).min(1)});P({type:ee("session:question:cleared"),sessionId:w().min(1),toolUseId:w().min(1),answers:zs(w(),w()).optional()});P({sessionId:w().min(1),toolUseId:w().min(1),answers:zs(w(),w())});P({ok:ee(!0)});P({sessionId:w().min(1),toolUseId:w().min(1)});P({ok:ee(!0)});const OT=P({name:w().min(1),version:w().min(1),instanceId:w().min(1),deviceLabel:w().transform(e=>e.trim().slice(0,64)).optional()});P({type:ee("auth"),token:w().min(1),scheme:ee("bearer").optional(),clientInfo:OT.optional()});P({type:ee("auth:ok"),version:w().min(1).optional(),protocolVersion:V().int().nonnegative().optional()});const lB=P({clientId:w().min(1),connectedAt:V().int().nonnegative(),self:_e(),clientInfo:OT.optional()});P({type:ee("device:connections:ok"),connections:se(lB)});P({type:ee("tunnel:ready"),url:w().min(1),subdomain:w().min(1)});P({type:ee("tunnel:exited"),code:V().int().nullable(),subdomain:w().nullable(),url:w().nullable()});P({type:ee("tunnel:unavailable"),reason:w().min(1),failedAt:w().min(1)});const cB=P({sessionId:w().min(1),status:H6,freshSpawn:_e(),pendingPermissionRequestIds:se(w().min(1)),pendingQuestionToolUseIds:se(w().min(1))});P({type:ee("info"),version:w(),protocolVersion:V(),hostname:w(),os:w(),tools:se(P({id:w(),available:_e()})),runningSessions:se(cB),tokenRole:Le(r6).optional(),isLoopback:_e().optional(),httpBaseUrl:w().optional(),httpToken:w().optional(),daemonSource:Le(["ota","packaged"]).optional(),globalCliVersion:w().nullable().optional()});const uB=6173,dB=6272,fl=/^[a-z][a-z0-9-]{0,39}$/,_u=P({name:w().regex(fl,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:V().int().min(uB).max(dB),createdAt:w().datetime(),devCommand:w().min(1),prodUrl:w().url().optional(),readyPattern:w().optional(),publishJob:P({jobId:w().min(1),stage:Le(["build","deploy","verify"]),startedAt:V().int().nonnegative()}).optional()}),hB=["install-pending","installing","starting-dev-server","running","stopped","failed"],BT=Le(hB),V_=_u.extend({isRunning:_e(),boundSessionId:w().nullable(),stage:BT.optional(),stageReason:w().optional(),publishJob:P({jobId:w().min(1),stage:Le(["build","deploy","verify"]),startedAt:V().int().nonnegative(),status:Le(["in-flight","interrupted"])}).optional()});P({}).strict();P({projects:se(V_)}).strict();P({sessionId:w().min(1)}).strict();P({project:V_.nullable()}).strict();P({sessionId:w().min(1),name:w().min(1)}).strict();P({project:_u}).strict();P({name:w()}).strict();P({}).strict();P({name:w(),newPort:V().int()}).strict();P({project:_u}).strict();P({name:w().regex(fl),url:w().url()}).strict();P({project:_u}).strict();P({sessionId:w().min(1),force:_e().optional()}).strict();P({project:_u}).strict();const fB=["installing","failed"];P({sessionId:w().min(1),stage:Le(fB),reason:w().optional()}).strict();P({ok:ee(!0)}).strict();P({sessionId:w().min(1)}).strict();P({ok:ee(!0)}).strict();P({type:ee("appBuilder:project-updated"),project:V_,stage:BT,stageReason:w().optional()}).strict();P({name:w().regex(fl)});P({jobId:w().min(1),status:Le(["started","already-publishing"])}).strict();P({name:w().regex(fl)});P({ok:ee(!0)}).strict();P({type:ee("appBuilder:publish-progress"),name:w().regex(fl),jobId:w().min(1),stage:Le(["build","deploy","verify"]),status:Le(["started","completed"])}).strict();P({type:ee("appBuilder:publish-failed"),name:w().regex(fl),jobId:w().min(1),stage:Le(["build","deploy","verify","unknown"]),errorSummary:w()}).strict();P({});P({method:w().min(1).optional()});const pB=["allowed","conditional","denied"],mB=Le(pB),gB=P({name:w().min(1),status:mB,description:w().min(1),args:se(P({name:w(),required:_e()})).nullable(),argsSchema:zs(Es()).optional(),reason:w().optional()});P({type:ee("meta:methods"),methods:se(gB)});const Nw=1,vB=["daemon","main","renderer"],xB=Le(vB),_B=["debug","info","warn","error"],yB=Le(_B);P({ts:V().int(),source:xB,level:yB,msg:w(),ownerPrincipalId:w(),deviceId:w(),appVersion:w(),daemonVersion:w().optional(),os:w(),meta_json:w().optional(),sessionId:w().optional()});P({v:ee(1),visitorId:w().min(1),displayName:w(),provider:w(),iat:V(),exp:V()});const bB=P({visitorId:w(),displayName:w(),avatarUrl:w().optional(),provider:w(),firstSeen:V(),lastSeen:V()});P({visitors:se(bB)});const wB=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,SB=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,kB="clawd-dispatch-task",CB="clawd-dispatch-result",Tw=120;function EB(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?kB:CB,i=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let s=i.exec(e);s!==null;s=i.exec(e))t.push({at:s.index,block:NB(n,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function NB(e,t,n){var c;const r=jB(t),i=g0(AB(Rm(n,"detail")??n)),s=(c=Rm(n,"brief"))==null?void 0:c.trim(),o=s&&s.length>0?g0(s):TB(i),a=r.round!==void 0?Number.parseInt(r.round,10):void 0,l=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&a!==void 0&&Number.isFinite(a)?{round:a}:{},...e==="result"&&(l==="success"||l==="failure")?{status:l}:{},brief:o,briefIsDerived:!(s&&s.length>0),detail:i,filePaths:MB(Rm(n,"files"))}}function TB(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>Tw?`${n.slice(0,Tw)}…`:n}const IB="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",PB=new RegExp(`<\\\\(\\\\*)(/?)(${IB})\\b`,"g");function RB(e){return g0(e)}function g0(e){return e.replace(PB,"<$1$2$3")}function Rm(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function MB(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 AB(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function jB(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=LB(r[2]??"");return t}function LB(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}const DB=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let _i=null;function OB(){if(_i!==null)return _i;if(typeof window>"u")return _i=!1,!1;if(DB.has(window.location.hostname)||window.location.protocol==="file:")return _i=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){_i=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{_i=sessionStorage.getItem("debug")==="1"}catch{_i=!1}return _i}function Me(e,...t){OB()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function pd(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const BB=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},zB=new Set(["auth:ok","pong","error"]),Iw=new Set(RT.filter(e=>!zB.has(e)));let $B=0;const Pw=()=>`r${++$B}`;function FB(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??BB;let u=null,d=!1,f=0,p=null,m=null,v=null,b=null,x=!1,_="disconnected";const y=new Map,S=new Map;let C=null;const k=(B,E)=>{var H;B==="ready"&&(C=E),(H=S.get(B))==null||H.forEach(q=>{try{q(E)}catch{}})},N=B=>{_!==B&&(_=B,k("status",B))},T=(B,E)=>{const H=S.get(B)??new Set;if(H.add(E),S.set(B,H),B==="ready"&&C!==null)try{E(C)}catch{}return()=>H.delete(E)},z=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),b&&(clearTimeout(b),b=null)},I=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},M=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Pw()}))},o),I()},L=B=>{for(const[,E]of y)clearTimeout(E.timer),E.reject(new Error(B));y.clear()},R=[],A=()=>{if(R.length===0)return;const B=R.splice(0);for(const E of B)(u==null?void 0:u.readyState)===1&&!x?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},D=B=>{if(R.length===0)return;const E=R.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(B))},$=()=>{if(d)return;const B=c(f);B<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:B,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,O()},B))},F=B=>{I();const E=String(B.type??"");if(E==="auth:ok"){Me("daemon-client","auth:ok received → connected",{url:t}),b&&(clearTimeout(b),b=null),x=!1,f=0,N("connected"),k("daemon:connected",{url:t}),M(),A();return}if(E==="pong")return;if(E==="ready"){const q=Number(B.protocolVersion??-1);q!==Nw&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:Nw}),k("ready",B);return}const H=B.requestId;if(typeof H=="string"&&y.has(H)){const q=y.get(H);if(y.delete(H),clearTimeout(q.timer),E==="error"){const j=String(B.code??"ERR"),ne=String(B.message??"unknown");q.reject(new Error(`${j}: ${ne}`))}else Iw.has(E)&&k(E,B),q.resolve(B);return}Iw.has(E)&&k(E,B)},O=()=>{p&&(clearTimeout(p),p=null),Me("daemon-client","connect →",{url:t,token:pd(n),attempt:f}),N("connecting");let B;try{B=new WebSocket(t)}catch(E){N("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=B,x=!!n,B.onopen=()=>{if(B!==u){Me("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Me("daemon-client","onopen → send auth frame",{token:pd(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),B.send(JSON.stringify(E)),b=setTimeout(()=>{try{B.close(4001,"auth handshake timeout")}catch{}},l)}else Me("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,N("connected"),k("daemon:connected",{url:t}),M(),A()},B.onclose=E=>{if(B!==u){Me("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Me("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:x,manualStop:d}),z(),L(`connection closed: ${H}`),u=null,E.code===4401?N("revoked"):N("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){D(`connection closed: ${H}`);return}d?D(`connection closed: ${H}`):$()},B.onerror=()=>{},B.onmessage=E=>{if(B!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,O()},stop(){d=!0,p&&(clearTimeout(p),p=null),z();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,L("shutdown"),D("shutdown"),N("disconnected")},switchProfile(B){Me("daemon-client","switchProfile →",{url:B.url,token:pd(B.authToken)},"prev:",{url:t,token:pd(n)}),t=B.url,n=B.authToken,B.selfIdentity!==void 0&&(r=B.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),z(),L("switch profile"),D("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,O()},request(B,E){return new Promise((H,q)=>{const j=Pw(),ne=setTimeout(()=>{y.delete(j);const G=R.findIndex(ve=>ve.timer===ne);G>=0&&R.splice(G,1),q(new Error(`request timeout: ${B}`))},s),re=()=>{y.set(j,{resolve:G=>H(G),reject:q,timer:ne}),u.send(JSON.stringify({...E,type:B,requestId:j}))};(u==null?void 0:u.readyState)===1&&!x?re():d||u==null&&p==null?(clearTimeout(ne),q(new Error("NOT_CONNECTED"))):R.push({doSend:re,reject:q,timer:ne})})},on:T,get isOpen(){return(u==null?void 0:u.readyState)===1&&!x},get url(){return t},getStatus(){return _}}}function HB(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function UB(e){return e?{id:e.id,mode:e.mode,url:e.url,token:HB(e.token),name:e.name}:null}function md(e){return e?Array.isArray(e)?e.map(UB):{_notArray:typeof e,_value:e}:null}function Rw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const WB="ws://127.0.0.1:18790",Mw="daemon:profiles",Aw="daemon:active-profile-id";function VB(){return Math.random().toString(36).slice(2,10)}function qB(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=new URLSearchParams(t.slice(n+1)).get("token")??void 0;return{url:r,token:i}}function KB(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function zT(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Me("profile-store","persist →",md(t.profiles),"active:",t.activeId),await e.kv.set(Mw,t.profiles),await e.kv.set(Aw,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(Mw);c=Rw(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Aw);u=Rw(d)??null}catch{u=null}if(Me("profile-store","ensureLoaded read kv →","profiles:",md(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(KB),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,Me("profile-store","ensureLoaded → use kv profiles",md(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:WB}],activeId:"default"},Me("profile-store","ensureLoaded → fallback synthesized default (NO token)",md(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var b;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const x=qB(c);c=x.url,!u&&x.token&&(u=x.token)}const d=l.id?t.profiles.find(x=>x.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??VB(),m={id:p,name:((b=l.name)==null?void 0:b.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(x=>x.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const jw="clawd.client-instance-id";let GB={name:"clawd-web",version:"unknown"};function YB(){let e=null;try{e=localStorage.getItem(jw),e||(e=crypto.randomUUID(),localStorage.setItem(jw,e))}catch{e=e??crypto.randomUUID()}return{...GB,instanceId:e}}function Lw(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const $T=g.createContext(null);function XB({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=zT(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return Me("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Lw(a.token)}),{client:FB({url:a.url,authToken:a.token,clientInfo:YB()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){Me("daemon-context","subscribe → no active profile, skip switchProfile");return}Me("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Lw(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx($T.Provider,{value:n,children:t}):null}function pi(){const e=g.useContext($T);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function ZB(){const e=pi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Me("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}function QB(){const e=pi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i;s.version!==void 0&&n(s.principalKind==="guest"?"guest":"owner")}),[e]),t}const FT=g.createContext(null);function JB({cache:e,children:t}){return g.createElement(FT.Provider,{value:e},t)}function jo(){const e=g.useContext(FT);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function ci(e){const t=jo(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const HT={actionsLevel:"none",httpBaseUrl:null,httpToken:null},UT=g.createContext(HT);function ap(){return g.useContext(UT)}function ez(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:HT}function tz(){const e=ci("daemon-info");return g.useMemo(()=>ez(e),[e])}function nz({children:e}){const t=tz();return Qe.createElement(UT.Provider,{value:t},e)}function rz(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function iz(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function sz(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function oz(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of RT)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}function WT(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const az=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:WT(e)});function lz(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>az(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function cz(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Xc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Mm(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function VT(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Xc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Mm(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Mm(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Mm(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Xc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const uz="session/";function dz(e){return{sid:e.slice(uz.length)}}const hz=new Set(MT);function qT(e){return hz.has(e)}function Dw(e){return qT(e)?e:"idle"}function fz(e,t){return{start(n){const{sid:r}=dz(n);let i=!1,s=-1;const o=f=>{t(n,p=>VT(p??Xc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],b=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:b}),s=b;else{const x=m.bufferStartSeq??0,_=b<p||x>p+1;o({type:_?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:b}),s=Math.max(s,b)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Dw(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;Me("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!qT(m.status)){Me("session-events","push session:status drop",{sid:r,status:m.status});return}Me("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;Me("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Dw(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const pz=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function mz(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{pz.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function gz(){return{start(){return()=>{}}}}function vz(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function xz(e){const t=oz(e),n=sz();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,lz(t,i)),n.register(/^sessions$/,cz(t,i)),n.register(/^session\//,fz(t,i)),n.register(/^personas$/,vz(t,i)),n.register(/^persona-detail\//,gz()),n.register(/^daemon-info$/,mz(t,i));const s=iz({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class q_{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}projectList(){return this.client.request("project:list")}projectCreate(t){return this.client.request("project:create",{...t.path?{path:t.path}:{},...t.name?{name:t.name}:{}})}projectPatch(t){return this.client.request("project:patch",t)}projectReveal(t){return this.client.request("project:reveal",{path:t})}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n){return this.client.request("session:send",{sessionId:t,text:n})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}archiveSession(t,n){return this.client.request("session:archive",{sessionId:t,archived:n})}markSessionRead(t){return this.client.request("session:markRead",{sessionId:t})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}larkBotBindManual(t,n,r){return this.client.request("larkBot:bindManual",{personaId:t,appId:n,appSecret:r})}larkBotUnbind(t){return this.client.request("larkBot:unbind",{personaId:t})}larkBotStatus(t){return this.client.request("larkBot:status",{personaId:t})}toolsProbe(){return this.client.request("tools:probe",{})}sessionExternalScan(){return this.client.request("session:externalScan",{})}sessionImportExternal(t){return this.client.request("session:importExternal",t)}onboardingComplete(){return this.client.request("onboarding:complete",{})}onboardingIosInterest(){return this.client.request("onboarding:iosInterest",{})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}channelList(){return this.client.request("channel:list")}channelCreate(t){return this.client.request("channel:create",t)}channelUpdate(t){return this.client.request("channel:update",t)}channelDelete(t){return this.client.request("channel:delete",t)}topicList(t){return this.client.request("topic:list",t)}topicGet(t){return this.client.request("topic:get",t)}topicCreate(t){return this.client.request("topic:create",t)}topicClose(t){return this.client.request("topic:close",t)}topicRename(t){return this.client.request("topic:rename",t)}topicDelete(t){return this.client.request("topic:delete",t)}githubStatus(){return this.client.request("github:status")}githubPrList(t){return this.client.request("github:prList",{role:t})}githubPrDetail(t){return this.client.request("github:prDetail",{...t})}githubPrMerge(t){return this.client.request("github:prMerge",{...t})}githubPrComment(t){return this.client.request("github:prComment",{...t})}githubPrSetReady(t){return this.client.request("github:prSetReady",{...t})}githubCollaborators(t){return this.client.request("github:collaborators",{...t})}githubPrRequestReviewers(t){return this.client.request("github:prRequestReviewers",{...t})}}function _z(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion,daemonSource:c.daemonSource,globalCliVersion:c.globalCliVersion,onboardingCompletedAt:c.onboardingCompletedAt}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0,daemonSource:u.kind==="connected"?u.daemonSource:void 0,globalCliVersion:u.kind==="connected"?u.globalCliVersion:void 0,onboardingCompletedAt:u.kind==="connected"?u.onboardingCompletedAt:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function yz(e){const t=jo(),n=ci(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function pl(){const e=pi();return g.useMemo(()=>new q_(e),[e])}function KT(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,tool:e.tool,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt}}function K_(){const e=jo(),t=pl(),n=ci("personas")??[],r=g.useMemo(()=>n.map(s=>KT(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:ci("personas")!==void 0,refresh:i}}function GT(e){const{raw:t}=K_(),n=jo(),r=pl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?KT(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function bz(e){const t=pl(),n=jo(),r=e?`persona-detail/${e}`:"",i=ci(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;let a=null;try{a=await t.personaGet(e)}catch(c){Me("personas","personaGet failed → empty detail",{personaId:e,err:c}),a=null}const l=a?{personality:a.personality??"",skills:a.skills??[],plugins:a.plugins??[],sandboxSettings:a.sandboxSettings??null}:o;return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,loaded:i!==void 0,refresh:s}}function YT(){const e=jo(),t=pl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function wz(){const e=pl(),t=YT();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function Sz(){const e=pl(),t=YT();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Ow="clawd:sidebar:tree-collapsed";function kz(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Cz(e){const t=kz(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function Ez(){const e=T_(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(Ow);if(l)return;n(Cz(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Ow,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const G_=g.createContext(null);function Nz(){const e=g.useContext(G_);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
97
97
  * @license lucide-react v0.577.0 - ISC
98
98
  *
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Clawd 分享</title>
7
- <script type="module" crossorigin src="/share-ui/assets/guest-CkX2tNZF.js"></script>
7
+ <script type="module" crossorigin src="/share-ui/assets/guest-BzNlxM2M.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/share-ui/assets/guest-BHvC4vAI.css">
9
9
  </head>
10
10
  <body style="margin: 0">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.397",
3
+ "version": "0.2.399",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",