@mujian/js-sdk 0.1.0-beta.0 → 0.1.0-beta.1

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/react.js CHANGED
@@ -1291,10 +1291,8 @@ const useChatStreaming = ({ common, setError, setMessages, getMessages, setInput
1291
1291
  if ('object' == typeof error && error && 'message' in error && 'string' == typeof error.message) isNetworkError(error.message) ? setError(new SendMessageError('E_NETWORK_ERROR')) : setError(new SendMessageError(error.message));
1292
1292
  else setError(error);
1293
1293
  } finally{
1294
- console.log('finally');
1295
1294
  setMessages(produce((draft)=>{
1296
1295
  const msg = draft.find((m)=>m.id === messageId);
1297
- console.log('finally', msg);
1298
1296
  if (!msg) return;
1299
1297
  msg.isGenerating = false;
1300
1298
  }));
@@ -1328,7 +1326,6 @@ const useChat = ({ body, onError, onFinish, pageSize = 10 })=>{
1328
1326
  const resp = await mujian.ai.chat.message.getPage(current?.cursor, pageSize);
1329
1327
  conversationVersion.current = resp.conversationVersion;
1330
1328
  const lastMessage = resp.messages.at(-1);
1331
- console.log(lastMessage);
1332
1329
  if (lastMessage?.isGenerating) recoverStreaming(lastMessage.id, conversationVersion.current);
1333
1330
  return {
1334
1331
  cursor: resp.nextCursor,
package/dist/umd/react.js CHANGED
@@ -166,4 +166,4 @@ ${i}
166
166
 
167
167
  `)}t.write("payload.value = newResult;"),t.write("return payload;");let u=t.compile();return(t,n)=>u(e,t,n)})(t.shape)),d=n(d,c),s)?u_([],l,d,c,r,e):d:i(d,c):(d.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),d)}});function uy(e,t,n,r){for(let n of e)if(0===n.issues.length)return t.value=n.value,t;let i=e.filter(e=>!i8(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>i6(e,r,iP())))}),t)}let uv=ix("$ZodUnion",(e,t)=>{aM.init(e,t),iZ(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),iZ(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),iZ(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),iZ(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>iR(e.source)).join("|")})$`)}});let n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return r(i,o);let a=!1,u=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},o);if(t instanceof Promise)u.push(t),a=!0;else{if(0===t.issues.length)return t;u.push(t)}}return a?Promise.all(u).then(t=>uy(t,i,e,o)):uy(u,i,e,o)}});function uw(e,t,n,r){let i=e.filter(e=>0===e.issues.length);return 1===i.length?t.value=i[0].value:0===i.length?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>i6(e,r,iP())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t}let uk=ix("$ZodXor",(e,t)=>{uv.init(e,t),t.inclusive=!1;let n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return r(i,o);let a=!1,u=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},o);t instanceof Promise?(u.push(t),a=!0):u.push(t)}return a?Promise.all(u).then(t=>uw(t,i,e,o)):uw(u,i,e,o)}}),uz=ix("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,uv.init(e,t);let n=e._zod.parse;iZ(e._zod,"propValues",()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r))for(let r of(e[t]||(e[t]=new Set),n))e[t].add(r)}return e});let r=iC(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,o)=>{let a=i.value;if(!iJ(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let u=r.value.get(a?.[t.discriminator]);return u?u._zod.run(i,o):t.unionFallback?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),uS=ix("$ZodIntersection",(e,t)=>{aM.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),o=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,n])=>uE(e,t,n)):uE(e,i,o)}});function uE(e,t,n){let r,i=new Map;for(let n of t.issues)if("unrecognized_keys"===n.code)for(let e of(r??(r=n),n.keys))i.has(e)||i.set(e,{}),i.get(e).l=!0;else e.issues.push(n);for(let t of n.issues)if("unrecognized_keys"===t.code)for(let e of t.keys)i.has(e)||i.set(e,{}),i.get(e).r=!0;else e.issues.push(t);let o=[...i].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(o.length&&r&&e.issues.push({...r,keys:o}),i8(e))return e;let a=function e(t,n){if(t===n||t instanceof Date&&n instanceof Date&&+t==+n)return{valid:!0,data:t};if(iV(t)&&iV(n)){let r=Object.keys(n),i=Object.keys(t).filter(e=>-1!==r.indexOf(e)),o={...t,...n};for(let r of i){let i=e(t[r],n[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};o[r]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<t.length;i++){let o=e(t[i],n[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}(t.value,n.value);if(!a.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}let uA=ix("$ZodTuple",(e,t)=>{aM.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];let a=[],u=[...n].reverse().findIndex(e=>"optional"!==e._zod.optin),s=-1===u?0:n.length-u;if(!t.rest){let t=o.length>n.length,i=o.length<s-1;if(t||i)return r.issues.push({...t?{code:"too_big",maximum:n.length,inclusive:!0}:{code:"too_small",minimum:n.length},input:o,inst:e,origin:"array"}),r}let d=-1;for(let e of n){if(++d>=o.length&&d>=s)continue;let t=e._zod.run({value:o[d],issues:[]},i);t instanceof Promise?a.push(t.then(e=>ux(e,r,d))):ux(t,r,d)}if(t.rest)for(let e of o.slice(n.length)){d++;let n=t.rest._zod.run({value:e,issues:[]},i);n instanceof Promise?a.push(n.then(e=>ux(e,r,d))):ux(n,r,d)}return a.length?Promise.all(a).then(()=>r):r}});function ux(e,t,n){e.issues.length&&t.issues.push(...i1(n,e.issues)),t.value[n]=e.value}let uT=ix("$ZodRecord",(e,t)=>{aM.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!iV(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let o=[],a=t.keyType._zod.values;if(a){let u;n.value={};let s=new Set;for(let e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){s.add("number"==typeof e?e.toString():e);let a=t.valueType._zod.run({value:i[e],issues:[]},r);a instanceof Promise?o.push(a.then(t=>{t.issues.length&&n.issues.push(...i1(e,t.issues)),n.value[e]=t.value})):(a.issues.length&&n.issues.push(...i1(e,a.issues)),n.value[e]=a.value)}for(let e in i)s.has(e)||(u=u??[]).push(e);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u})}else for(let a of(n.value={},Reflect.ownKeys(i))){if("__proto__"===a)continue;let u=t.keyType._zod.run({value:a,issues:[]},r);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof a&&oW.test(a)&&u.issues.length){let e=t.keyType._zod.run({value:Number(a),issues:[]},r);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(u=e)}if(u.issues.length){"loose"===t.mode?n.value[a]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(e=>i6(e,r,iP())),input:a,path:[a],inst:e});continue}let s=t.valueType._zod.run({value:i[a],issues:[]},r);s instanceof Promise?o.push(s.then(e=>{e.issues.length&&n.issues.push(...i1(a,e.issues)),n.value[u.value]=e.value})):(s.issues.length&&n.issues.push(...i1(a,s.issues)),n.value[u.value]=s.value)}return o.length?Promise.all(o).then(()=>n):n}}),uj=ix("$ZodMap",(e,t)=>{aM.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),n;let o=[];for(let[a,u]of(n.value=new Map,i)){let s=t.keyType._zod.run({value:a,issues:[]},r),d=t.valueType._zod.run({value:u,issues:[]},r);s instanceof Promise||d instanceof Promise?o.push(Promise.all([s,d]).then(([t,o])=>{uO(t,o,n,a,i,e,r)})):uO(s,d,n,a,i,e,r)}return o.length?Promise.all(o).then(()=>n):n}});function uO(e,t,n,r,i,o,a){e.issues.length&&(iW.has(typeof r)?n.issues.push(...i1(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(e=>i6(e,a,iP()))})),t.issues.length&&(iW.has(typeof r)?n.issues.push(...i1(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(e=>i6(e,a,iP()))})),n.value.set(e.value,t.value)}let uP=ix("$ZodSet",(e,t)=>{aM.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Set))return n.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),n;let o=[];for(let e of(n.value=new Set,i)){let i=t.valueType._zod.run({value:e,issues:[]},r);i instanceof Promise?o.push(i.then(e=>uI(e,n))):uI(i,n)}return o.length?Promise.all(o).then(()=>n):n}});function uI(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}let u$=ix("$ZodEnum",(e,t)=>{aM.init(e,t);let n=iI(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>iW.has(typeof e)).map(e=>"string"==typeof e?iK(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{let o=t.value;return r.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}}),uM=ix("$ZodLiteral",(e,t)=>{if(aM.init(e,t),0===t.values.length)throw Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>"string"==typeof e?iK(e):e?iK(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,i)=>{let o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),uC=ix("$ZodFile",(e,t)=>{aM.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),t}}),uN=ix("$ZodTransform",(e,t)=>{aM.init(e,t),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new ij(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new iT;return n.value=i,n}});function uR(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}let uL=ix("$ZodOptional",(e,t)=>{aM.init(e,t),e._zod.optin="optional",e._zod.optout="optional",iZ(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),iZ(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${iR(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>uR(t,e.value)):uR(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),uZ=ix("$ZodExactOptional",(e,t)=>{uL.init(e,t),iZ(e._zod,"values",()=>t.innerType._zod.values),iZ(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),uD=ix("$ZodNullable",(e,t)=>{aM.init(e,t),iZ(e._zod,"optin",()=>t.innerType._zod.optin),iZ(e._zod,"optout",()=>t.innerType._zod.optout),iZ(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${iR(e.source)}|null)$`):void 0}),iZ(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),uU=ix("$ZodDefault",(e,t)=>{aM.init(e,t),e._zod.optin="optional",iZ(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>uF(e,t)):uF(r,t)}});function uF(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let uH=ix("$ZodPrefault",(e,t)=>{aM.init(e,t),e._zod.optin="optional",iZ(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),uJ=ix("$ZodNonOptional",(e,t)=>{aM.init(e,t),iZ(e._zod,"values",()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>uB(t,e)):uB(i,e)}});function uB(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}let uV=ix("$ZodSuccess",(e,t)=>{aM.init(e,t),e._zod.parse=(e,n)=>{if("backward"===n.direction)throw new ij("ZodSuccess");let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=0===t.issues.length,e)):(e.value=0===r.issues.length,e)}}),uG=ix("$ZodCatch",(e,t)=>{aM.init(e,t),iZ(e._zod,"optin",()=>t.innerType._zod.optin),iZ(e._zod,"optout",()=>t.innerType._zod.optout),iZ(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>i6(e,n,iP()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>i6(e,n,iP()))},input:e.value}),e.issues=[]),e)}}),uW=ix("$ZodNaN",(e,t)=>{aM.init(e,t),e._zod.parse=(t,n)=>("number"==typeof t.value&&Number.isNaN(t.value)||t.issues.push({input:t.value,inst:e,expected:"nan",code:"invalid_type"}),t)}),uq=ix("$ZodPipe",(e,t)=>{aM.init(e,t),iZ(e._zod,"values",()=>t.in._zod.values),iZ(e._zod,"optin",()=>t.in._zod.optin),iZ(e._zod,"optout",()=>t.out._zod.optout),iZ(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>uK(e,t.in,n)):uK(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>uK(e,t.out,n)):uK(r,t.out,n)}});function uK(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let uX=ix("$ZodCodec",(e,t)=>{aM.init(e,t),iZ(e._zod,"values",()=>t.in._zod.values),iZ(e._zod,"optin",()=>t.in._zod.optin),iZ(e._zod,"optout",()=>t.out._zod.optout),iZ(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("forward"===(n.direction||"forward")){let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>uY(e,t,n)):uY(r,t,n)}{let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>uY(e,t,n)):uY(r,t,n)}}});function uY(e,t,n){if(e.issues.length)return e.aborted=!0,e;if("forward"===(n.direction||"forward")){let r=t.transform(e.value,e);return r instanceof Promise?r.then(r=>uQ(e,r,t.out,n)):uQ(e,r,t.out,n)}{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(r=>uQ(e,r,t.in,n)):uQ(e,r,t.in,n)}}function uQ(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}let u0=ix("$ZodReadonly",(e,t)=>{aM.init(e,t),iZ(e._zod,"propValues",()=>t.innerType._zod.propValues),iZ(e._zod,"values",()=>t.innerType._zod.values),iZ(e._zod,"optin",()=>t.innerType?._zod?.optin),iZ(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(u3):u3(r)}});function u3(e){return e.value=Object.freeze(e.value),e}let u8=ix("$ZodTemplateLiteral",(e,t)=>{aM.init(e,t);let n=[];for(let e of t.parts)if("object"==typeof e&&null!==e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw Error(`Invalid template literal part: ${e._zod.traits}`);let r=+!!t.startsWith("^"),i=t.endsWith("$")?t.length-1:t.length;n.push(t.slice(r,i))}else if(null===e||iq.has(typeof e))n.push(iK(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join("")}$`),e._zod.parse=(n,r)=>("string"!=typeof n.value?n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source})),n)}),u1=ix("$ZodFunction",(e,t)=>(aM.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if("function"!=typeof t)throw Error("implement() must be called with a function");return function(...n){let r=Reflect.apply(t,this,e._def.input?or(e._def.input,n):n);return e._def.output?or(e._def.output,r):r}},e.implementAsync=t=>{if("function"!=typeof t)throw Error("implementAsync() must be called with a function");return async function(...n){let r=e._def.input?await oo(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await oo(e._def.output,i):i}},e._zod.parse=(t,n)=>("function"!=typeof t.value?t.issues.push({code:"invalid_type",expected:"function",input:t.value,inst:e}):e._def.output&&"promise"===e._def.output._zod.def.type?t.value=e.implementAsync(t.value):t.value=e.implement(t.value),t),e.input=(...t)=>{let n=e.constructor;return new n(Array.isArray(t[0])?{type:"function",input:new uA({type:"tuple",items:t[0],rest:t[1]}),output:e._def.output}:{type:"function",input:t[0],output:e._def.output})},e.output=t=>new e.constructor({type:"function",input:e._def.input,output:t}),e)),u2=ix("$ZodPromise",(e,t)=>{aM.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),u6=ix("$ZodLazy",(e,t)=>{aM.init(e,t),iZ(e._zod,"innerType",()=>t.getter()),iZ(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),iZ(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),iZ(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),iZ(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),u4=ix("$ZodCustom",(e,t)=>{as.init(e,t),aM.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>u9(t,n,r,e));u9(i,n,r,e)}});function u9(e,t,n,r){if(!e){let e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(i5(e))}}Symbol("ZodOutput"),Symbol("ZodInput");(S=globalThis).__zod_globalRegistry??(S.__zod_globalRegistry=new class e{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});let u5=globalThis.__zod_globalRegistry;function u7(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...iY(t)})}function se(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...iY(t)})}function st(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...iY(t)})}function sn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...iY(t)})}function sr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...iY(t)})}function si(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...iY(t)})}function so(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...iY(t)})}function sa(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...iY(t)})}function su(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...iY(t)})}function ss(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...iY(t)})}function sd(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...iY(t)})}function sc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...iY(t)})}function sl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...iY(t)})}function sp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...iY(t)})}function sf(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...iY(t)})}function sh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...iY(t)})}function sm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...iY(t)})}function s_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...iY(t)})}function sg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...iY(t)})}function sb(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...iY(t)})}function sy(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...iY(t)})}function sv(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...iY(t)})}function sw(e,t){return new ac({check:"less_than",...iY(t),value:e,inclusive:!1})}function sk(e,t){return new ac({check:"less_than",...iY(t),value:e,inclusive:!0})}function sz(e,t){return new al({check:"greater_than",...iY(t),value:e,inclusive:!1})}function sS(e,t){return new al({check:"greater_than",...iY(t),value:e,inclusive:!0})}function sE(e){return sz(0,e)}function sA(e){return sw(0,e)}function sx(e){return sk(0,e)}function sT(e){return sS(0,e)}function sj(e,t){return new ap({check:"multiple_of",...iY(t),value:e})}function sO(e,t){return new am({check:"max_size",...iY(t),maximum:e})}function sP(e,t){return new a_({check:"min_size",...iY(t),minimum:e})}function sI(e,t){return new ag({check:"size_equals",...iY(t),size:e})}function s$(e,t){return new ab({check:"max_length",...iY(t),maximum:e})}function sM(e,t){return new ay({check:"min_length",...iY(t),minimum:e})}function sC(e,t){return new av({check:"length_equals",...iY(t),length:e})}function sN(e,t){return new ak({check:"string_format",format:"regex",...iY(t),pattern:e})}function sR(e){return new az({check:"string_format",format:"lowercase",...iY(e)})}function sL(e){return new aS({check:"string_format",format:"uppercase",...iY(e)})}function sZ(e,t){return new aE({check:"string_format",format:"includes",...iY(t),includes:e})}function sD(e,t){return new aA({check:"string_format",format:"starts_with",...iY(t),prefix:e})}function sU(e,t){return new ax({check:"string_format",format:"ends_with",...iY(t),suffix:e})}function sF(e,t,n){return new aj({check:"property",property:e,schema:t,...iY(n)})}function sH(e,t){return new aO({check:"mime_type",mime:e,...iY(t)})}function sJ(e){return new aP({check:"overwrite",tx:e})}function sB(e){return sJ(t=>t.normalize(e))}function sV(){return sJ(e=>e.trim())}function sG(){return sJ(e=>e.toLowerCase())}function sW(){return sJ(e=>e.toUpperCase())}function sq(){return sJ(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,""))}function sK(e,t,n,r={}){let i=iY(r),o={...iY(r),check:"string_format",type:"string",format:t,fn:"function"==typeof n?n:e=>n.test(e),...i};return n instanceof RegExp&&(o.pattern=n),new e(o)}function sX(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??u5,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function sY(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);let u=e._zod.toJSONSchema?.();if(u)a.schema=u;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,r);else{let n=a.schema,o=t.processors[i.type];if(!o)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);o(e,t,n,r)}let o=e._zod.parent;o&&(a.ref||(a.ref=o),sY(o,t,r),t.seen.get(o).isParent=!0)}let s=t.metadataRegistry.get(e);return s&&Object.assign(a.schema,s),"input"===t.io&&function e(t,n){let r=n??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let i=t._zod.def;if("transform"===i.type)return!0;if("array"===i.type)return e(i.element,r);if("set"===i.type)return e(i.valueType,r);if("lazy"===i.type)return e(i.getter(),r);if("promise"===i.type||"optional"===i.type||"nonoptional"===i.type||"nullable"===i.type||"readonly"===i.type||"default"===i.type||"prefault"===i.type)return e(i.innerType,r);if("intersection"===i.type)return e(i.left,r)||e(i.right,r);if("record"===i.type||"map"===i.type)return e(i.keyType,r)||e(i.valueType,r);if("pipe"===i.type)return e(i.in,r)||e(i.out,r);if("object"===i.type){for(let t in i.shape)if(e(i.shape[t],r))return!0;return!1}if("union"===i.type){for(let t of i.options)if(e(t,r))return!0;return!1}if("tuple"===i.type){for(let t of i.items)if(e(t,r))return!0;if(i.rest&&e(i.rest,r))return!0}return!1}(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function sQ(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{if(t[1].schema.$ref)return;let r=t[1],{ref:i,defId:o}=(t=>{let r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let o=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=o,{defId:o,ref:`${i("__shared")}#/${r}/${o}`}}if(t[1]===n)return{ref:"#"};let i=`#/${r}/`,o=t[1].schema.id??`__schema${e.counter++}`;return{defId:o,ref:i+o}})(t);r.def={...r.schema},o&&(r.defId=o);let a=r.schema;for(let e in a)delete a[e];a.$ref=i};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
168
168
 
169
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){i(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){i(n);continue}}if(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&"ref"===e.reused){i(n);continue}}}function s0(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=t=>{let n=e.seen.get(t);if(null===n.ref)return;let i=n.def??n.schema,o={...i},a=n.ref;if(n.ref=null,a){r(a);let n=e.seen.get(a),u=n.schema;if(u.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(i.allOf=i.allOf??[],i.allOf.push(u)):Object.assign(i,u),Object.assign(i,o),t._zod.parent===a)for(let e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(u.$ref&&n.def)for(let e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let u=t._zod.parent;if(u&&u!==a){r(u);let t=e.seen.get(u);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:s3(t,"input",e.processors),output:s3(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw Error("Error converting schema to JSON.")}}let s3=(e,t,n={})=>r=>{let{libraryOptions:i,target:o}=r??{},a=sX({...i??{},target:o,io:t,processors:n});return sY(e,a),sQ(a,e),s0(a,e)},s8={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},s1=(e,t,n,r)=>{let i=e._zod.def,o=!1===i.inclusive,a=i.options.map((e,n)=>sY(e,t,{...r,path:[...r.path,o?"oneOf":"anyOf",n]}));o?n.oneOf=a:n.anyOf=a},s2=(e,t,n,r)=>{let i=e._zod.def;sY(i.innerType,t,r),t.seen.get(e).ref=i.innerType},s6=ix("ZodISODateTime",(e,t)=>{aW.init(e,t),dk.init(e,t)});function s4(e){return new s6({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...iY(e)})}let s9=ix("ZodISODate",(e,t)=>{aq.init(e,t),dk.init(e,t)});function s5(e){return new s9({type:"string",format:"date",check:"string_format",...iY(e)})}let s7=ix("ZodISOTime",(e,t)=>{aK.init(e,t),dk.init(e,t)});function de(e){return new s7({type:"string",format:"time",check:"string_format",precision:null,...iY(e)})}let dt=ix("ZodISODuration",(e,t)=>{aX.init(e,t),dk.init(e,t)});function dn(e){return new dt({type:"string",format:"duration",check:"string_format",...iY(e)})}let dr=(e,t)=>{oe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>(function(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>r({issues:e}));else if("invalid_key"===i.code)r({issues:i.issues});else if("invalid_element"===i.code)r({issues:i.issues});else if(0===i.path.length)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n})(e,t)},flatten:{value:t=>(function(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}})(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,iM,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,iM,2)}},isEmpty:{get:()=>0===e.issues.length}})};ix("ZodError",dr);let di=ix("ZodError",dr,{Parent:Error}),da=on(di),du=oi(di),ds=oa(di),dd=os(di),dc=(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return on(di)(e,t,r)},dl=(e,t,n)=>on(di)(e,t,n),dp=async(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return oi(di)(e,t,r)},df=async(e,t,n)=>oi(di)(e,t,n),dh=(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return oa(di)(e,t,r)},dm=(e,t,n)=>oa(di)(e,t,n),d_=async(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return os(di)(e,t,r)},dg=async(e,t,n)=>os(di)(e,t,n),db=ix("ZodType",(e,t)=>(aM.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:s3(e,"input"),output:s3(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{let r=sX({...n,processors:t});return sY(e,r),sQ(r,e),s0(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(iU(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>iX(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>da(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ds(e,t,n),e.parseAsync=async(t,n)=>du(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>dd(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>dc(e,t,n),e.decode=(t,n)=>dl(e,t,n),e.encodeAsync=async(t,n)=>dp(e,t,n),e.decodeAsync=async(t,n)=>df(e,t,n),e.safeEncode=(t,n)=>dh(e,t,n),e.safeDecode=(t,n)=>dm(e,t,n),e.safeEncodeAsync=async(t,n)=>d_(e,t,n),e.safeDecodeAsync=async(t,n)=>dg(e,t,n),e.refine=(t,n)=>e.check(lB(t,n)),e.superRefine=t=>e.check(lV(t)),e.overwrite=t=>e.check(sJ(t)),e.optional=()=>lc(e),e.exactOptional=()=>lp(e),e.nullable=()=>lh(e),e.nullish=()=>lc(lh(e)),e.nonoptional=t=>lw(e,t),e.array=()=>cD(e),e.or=t=>cG([e,t]),e.and=t=>cQ(e,t),e.transform=t=>lj(e,ls(t)),e.default=t=>lg(e,t),e.prefault=t=>ly(e,t),e.catch=t=>lE(e,t),e.pipe=t=>lj(e,t),e.readonly=()=>l$(e),e.describe=t=>{let n=e.clone();return u5.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>u5.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return u5.get(e);let n=e.clone();return u5.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),dy=ix("_ZodString",(e,t)=>{aC.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{n.type="string";let{minimum:i,maximum:o,format:a,patterns:u,contentEncoding:s}=e._zod.bag;if("number"==typeof i&&(n.minLength=i),"number"==typeof o&&(n.maxLength=o),a&&(n.format=s8[a]??a,""===n.format&&delete n.format,"time"===a&&delete n.format),s&&(n.contentEncoding=s),u&&u.size>0){let e=[...u];1===e.length?n.pattern=e[0].source:e.length>1&&(n.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n,0);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(sN(...t)),e.includes=(...t)=>e.check(sZ(...t)),e.startsWith=(...t)=>e.check(sD(...t)),e.endsWith=(...t)=>e.check(sU(...t)),e.min=(...t)=>e.check(sM(...t)),e.max=(...t)=>e.check(s$(...t)),e.length=(...t)=>e.check(sC(...t)),e.nonempty=(...t)=>e.check(sM(1,...t)),e.lowercase=t=>e.check(sR(t)),e.uppercase=t=>e.check(sL(t)),e.trim=()=>e.check(sV()),e.normalize=(...t)=>e.check(sB(...t)),e.toLowerCase=()=>e.check(sG()),e.toUpperCase=()=>e.check(sW()),e.slugify=()=>e.check(sq())}),dv=ix("ZodString",(e,t)=>{aC.init(e,t),dy.init(e,t),e.email=t=>e.check(u7(dz,t)),e.url=t=>e.check(so(dI,t)),e.jwt=t=>e.check(sv(ct,t)),e.emoji=t=>e.check(sa(dC,t)),e.guid=t=>e.check(se(dE,t)),e.uuid=t=>e.check(st(dx,t)),e.uuidv4=t=>e.check(sn(dx,t)),e.uuidv6=t=>e.check(sr(dx,t)),e.uuidv7=t=>e.check(si(dx,t)),e.nanoid=t=>e.check(su(dR,t)),e.guid=t=>e.check(se(dE,t)),e.cuid=t=>e.check(ss(dZ,t)),e.cuid2=t=>e.check(sd(dU,t)),e.ulid=t=>e.check(sc(dH,t)),e.base64=t=>e.check(sg(d6,t)),e.base64url=t=>e.check(sb(d9,t)),e.xid=t=>e.check(sl(dB,t)),e.ksuid=t=>e.check(sp(dG,t)),e.ipv4=t=>e.check(sf(dq,t)),e.ipv6=t=>e.check(sh(dQ,t)),e.cidrv4=t=>e.check(sm(d3,t)),e.cidrv6=t=>e.check(s_(d1,t)),e.e164=t=>e.check(sy(d7,t)),e.datetime=t=>e.check(s4(t)),e.date=t=>e.check(s5(t)),e.time=t=>e.check(de(t)),e.duration=t=>e.check(dn(t))});function dw(e){return new dv({type:"string",...iY(e)})}let dk=ix("ZodStringFormat",(e,t)=>{aN.init(e,t),dy.init(e,t)}),dz=ix("ZodEmail",(e,t)=>{aZ.init(e,t),dk.init(e,t)});function dS(e){return u7(dz,e)}let dE=ix("ZodGUID",(e,t)=>{aR.init(e,t),dk.init(e,t)});function dA(e){return se(dE,e)}let dx=ix("ZodUUID",(e,t)=>{aL.init(e,t),dk.init(e,t)});function dT(e){return st(dx,e)}function dj(e){return sn(dx,e)}function dO(e){return sr(dx,e)}function dP(e){return si(dx,e)}let dI=ix("ZodURL",(e,t)=>{aD.init(e,t),dk.init(e,t)});function d$(e){return so(dI,e)}function dM(e){return so(dI,{protocol:/^https?$/,hostname:oL,...iY(e)})}let dC=ix("ZodEmoji",(e,t)=>{aU.init(e,t),dk.init(e,t)});function dN(e){return sa(dC,e)}let dR=ix("ZodNanoID",(e,t)=>{aF.init(e,t),dk.init(e,t)});function dL(e){return su(dR,e)}let dZ=ix("ZodCUID",(e,t)=>{aH.init(e,t),dk.init(e,t)});function dD(e){return ss(dZ,e)}let dU=ix("ZodCUID2",(e,t)=>{aJ.init(e,t),dk.init(e,t)});function dF(e){return sd(dU,e)}let dH=ix("ZodULID",(e,t)=>{aB.init(e,t),dk.init(e,t)});function dJ(e){return sc(dH,e)}let dB=ix("ZodXID",(e,t)=>{aV.init(e,t),dk.init(e,t)});function dV(e){return sl(dB,e)}let dG=ix("ZodKSUID",(e,t)=>{aG.init(e,t),dk.init(e,t)});function dW(e){return sp(dG,e)}let dq=ix("ZodIPv4",(e,t)=>{aY.init(e,t),dk.init(e,t)});function dK(e){return sf(dq,e)}let dX=ix("ZodMAC",(e,t)=>{a0.init(e,t),dk.init(e,t)});function dY(e){return new dX({type:"string",format:"mac",check:"string_format",abort:!1,...iY(e)})}let dQ=ix("ZodIPv6",(e,t)=>{aQ.init(e,t),dk.init(e,t)});function d0(e){return sh(dQ,e)}let d3=ix("ZodCIDRv4",(e,t)=>{a3.init(e,t),dk.init(e,t)});function d8(e){return sm(d3,e)}let d1=ix("ZodCIDRv6",(e,t)=>{a8.init(e,t),dk.init(e,t)});function d2(e){return s_(d1,e)}let d6=ix("ZodBase64",(e,t)=>{a2.init(e,t),dk.init(e,t)});function d4(e){return sg(d6,e)}let d9=ix("ZodBase64URL",(e,t)=>{a6.init(e,t),dk.init(e,t)});function d5(e){return sb(d9,e)}let d7=ix("ZodE164",(e,t)=>{a4.init(e,t),dk.init(e,t)});function ce(e){return sy(d7,e)}let ct=ix("ZodJWT",(e,t)=>{a9.init(e,t),dk.init(e,t)});function cn(e){return sv(ct,e)}let cr=ix("ZodCustomStringFormat",(e,t)=>{a5.init(e,t),dk.init(e,t)});function ci(e,t,n={}){return sK(cr,e,t,n)}function co(e){return sK(cr,"hostname",oR,e)}function ca(e){return sK(cr,"hex",o0,e)}function cu(e,t){let n=t?.enc??"hex",r=`${e}_${n}`,i=A[r];if(!i)throw Error(`Unrecognized hash format: ${r}`);return sK(cr,r,i,t)}let cs=ix("ZodNumber",(e,t)=>{a7.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let{minimum:i,maximum:o,format:a,multipleOf:u,exclusiveMaximum:s,exclusiveMinimum:d}=e._zod.bag;"string"==typeof a&&a.includes("int")?n.type="integer":n.type="number","number"==typeof d&&("draft-04"===t.target||"openapi-3.0"===t.target?(n.minimum=d,n.exclusiveMinimum=!0):n.exclusiveMinimum=d),"number"==typeof i&&(n.minimum=i,"number"==typeof d&&"draft-04"!==t.target&&(d>=i?delete n.minimum:delete n.exclusiveMinimum)),"number"==typeof s&&("draft-04"===t.target||"openapi-3.0"===t.target?(n.maximum=s,n.exclusiveMaximum=!0):n.exclusiveMaximum=s),"number"==typeof o&&(n.maximum=o,"number"==typeof s&&"draft-04"!==t.target&&(s<=o?delete n.maximum:delete n.exclusiveMaximum)),"number"==typeof u&&(n.multipleOf=u)})(e,t,n,0),e.gt=(t,n)=>e.check(sz(t,n)),e.gte=(t,n)=>e.check(sS(t,n)),e.min=(t,n)=>e.check(sS(t,n)),e.lt=(t,n)=>e.check(sw(t,n)),e.lte=(t,n)=>e.check(sk(t,n)),e.max=(t,n)=>e.check(sk(t,n)),e.int=t=>e.check(cl(t)),e.safe=t=>e.check(cl(t)),e.positive=t=>e.check(sz(0,t)),e.nonnegative=t=>e.check(sS(0,t)),e.negative=t=>e.check(sw(0,t)),e.nonpositive=t=>e.check(sk(0,t)),e.multipleOf=(t,n)=>e.check(sj(t,n)),e.step=(t,n)=>e.check(sj(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function cd(e){return new cs({type:"number",checks:[],...iY(e)})}let cc=ix("ZodNumberFormat",(e,t)=>{ue.init(e,t),cs.init(e,t)});function cl(e){return new cc({type:"number",check:"number_format",abort:!1,format:"safeint",...iY(e)})}function cp(e){return new cc({type:"number",check:"number_format",abort:!1,format:"float32",...iY(e)})}function cf(e){return new cc({type:"number",check:"number_format",abort:!1,format:"float64",...iY(e)})}function ch(e){return new cc({type:"number",check:"number_format",abort:!1,format:"int32",...iY(e)})}function cm(e){return new cc({type:"number",check:"number_format",abort:!1,format:"uint32",...iY(e)})}let c_=ix("ZodBoolean",(e,t)=>{ut.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{t.type="boolean"}});function cg(e){return new c_({type:"boolean",...iY(e)})}let cb=ix("ZodBigInt",(e,t)=>{un.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("BigInt cannot be represented in JSON Schema")})(0,e,0,0),e.gte=(t,n)=>e.check(sS(t,n)),e.min=(t,n)=>e.check(sS(t,n)),e.gt=(t,n)=>e.check(sz(t,n)),e.gte=(t,n)=>e.check(sS(t,n)),e.min=(t,n)=>e.check(sS(t,n)),e.lt=(t,n)=>e.check(sw(t,n)),e.lte=(t,n)=>e.check(sk(t,n)),e.max=(t,n)=>e.check(sk(t,n)),e.positive=t=>e.check(sz(BigInt(0),t)),e.negative=t=>e.check(sw(BigInt(0),t)),e.nonpositive=t=>e.check(sk(BigInt(0),t)),e.nonnegative=t=>e.check(sS(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(sj(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function cy(e){return new cb({type:"bigint",...iY(e)})}let cv=ix("ZodBigIntFormat",(e,t)=>{ur.init(e,t),cb.init(e,t)});function cw(e){return new cv({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...iY(e)})}function ck(e){return new cv({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...iY(e)})}let cz=ix("ZodSymbol",(e,t)=>{ui.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Symbols cannot be represented in JSON Schema")})(0,e,0,0)});function cS(e){return new cz({type:"symbol",...iY(e)})}let cE=ix("ZodUndefined",(e,t)=>{uo.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Undefined cannot be represented in JSON Schema")})(0,e,0,0)});function cA(e){return new cE({type:"undefined",...iY(e)})}let cx=ix("ZodNull",(e,t)=>{ua.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{"openapi-3.0"===e.target?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"}});function cT(e){return new cx({type:"null",...iY(e)})}let cj=ix("ZodAny",(e,t)=>{uu.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function cO(){return new cj({type:"any"})}let cP=ix("ZodUnknown",(e,t)=>{us.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function cI(){return new cP({type:"unknown"})}let c$=ix("ZodNever",(e,t)=>{ud.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{t.not={}}});function cM(e){return new c$({type:"never",...iY(e)})}let cC=ix("ZodVoid",(e,t)=>{uc.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Void cannot be represented in JSON Schema")})(0,e,0,0)});function cN(e){return new cC({type:"void",...iY(e)})}let cR=ix("ZodDate",(e,t)=>{ul.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Date cannot be represented in JSON Schema")})(0,e,0,0),e.min=(t,n)=>e.check(sS(t,n)),e.max=(t,n)=>e.check(sk(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function cL(e){return new cR({type:"date",...iY(e)})}let cZ=ix("ZodArray",(e,t)=>{uf.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(n.minItems=o),"number"==typeof a&&(n.maxItems=a),n.type="array",n.items=sY(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(sM(t,n)),e.nonempty=t=>e.check(sM(1,t)),e.max=(t,n)=>e.check(s$(t,n)),e.length=(t,n)=>e.check(sC(t,n)),e.unwrap=()=>e.element});function cD(e,t){return new cZ({type:"array",element:e,...iY(t)})}function cU(e){return lt(Object.keys(e._zod.def.shape))}let cF=ix("ZodObject",(e,t)=>{ub.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;n.type="object",n.properties={};let o=i.shape;for(let e in o)n.properties[e]=sY(o[e],t,{...r,path:[...r.path,"properties",e]});let a=new Set([...new Set(Object.keys(o))].filter(e=>{let n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));a.size>0&&(n.required=Array.from(a)),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=sY(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(n.additionalProperties=!1)})(e,t,n,r),iZ(e,"shape",()=>t.shape),e.keyof=()=>lt(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:cI()}),e.loose=()=>e.clone({...e._zod.def,catchall:cI()}),e.strict=()=>e.clone({...e._zod.def,catchall:cM()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>(function(e,t){if(!iV(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=iU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return iD(this,"shape",n),n}});return iX(e,r)})(e,t),e.safeExtend=t=>(function(e,t){if(!iV(t))throw Error("Invalid input to safeExtend: expected a plain object");let n=iU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return iD(this,"shape",n),n}});return iX(e,n)})(e,t),e.merge=t=>{let n;return n=iU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return iD(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]}),iX(e,n)},e.pick=t=>(function(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=iU(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return iD(this,"shape",e),e},checks:[]});return iX(e,i)})(e,t),e.omit=t=>(function(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=iU(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return iD(this,"shape",r),r},checks:[]});return iX(e,i)})(e,t),e.partial=(...t)=>(function(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let i=iU(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return iD(this,"shape",i),i},checks:[]});return iX(t,i)})(ld,e,t[0]),e.required=(...t)=>{var n;let r;return n=t[0],r=iU(e._zod.def,{get shape(){let t=e._zod.def.shape,r={...t};if(n)for(let e in n){if(!(e in r))throw Error(`Unrecognized key: "${e}"`);n[e]&&(r[e]=new lv({type:"nonoptional",innerType:t[e]}))}else for(let e in t)r[e]=new lv({type:"nonoptional",innerType:t[e]});return iD(this,"shape",r),r}}),iX(e,r)}});function cH(e,t){return new cF({type:"object",shape:e??{},...iY(t)})}function cJ(e,t){return new cF({type:"object",shape:e,catchall:cM(),...iY(t)})}function cB(e,t){return new cF({type:"object",shape:e,catchall:cI(),...iY(t)})}let cV=ix("ZodUnion",(e,t)=>{uv.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s1(e,t,n,r),e.options=t.options});function cG(e,t){return new cV({type:"union",options:e,...iY(t)})}let cW=ix("ZodXor",(e,t)=>{cV.init(e,t),uk.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s1(e,t,n,r),e.options=t.options});function cq(e,t){return new cW({type:"union",options:e,inclusive:!1,...iY(t)})}let cK=ix("ZodDiscriminatedUnion",(e,t)=>{cV.init(e,t),uz.init(e,t)});function cX(e,t,n){return new cK({type:"union",options:t,discriminator:e,...iY(n)})}let cY=ix("ZodIntersection",(e,t)=>{uS.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i,o,a,u;return o=sY((i=e._zod.def).left,t,{...r,path:[...r.path,"allOf",0]}),a=sY(i.right,t,{...r,path:[...r.path,"allOf",1]}),void(n.allOf=[...(u=e=>"allOf"in e&&1===Object.keys(e).length)(o)?o.allOf:[o],...u(a)?a.allOf:[a]])}});function cQ(e,t){return new cY({type:"intersection",left:e,right:t})}let c0=ix("ZodTuple",(e,t)=>{uA.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;n.type="array";let o="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",u=i.items.map((e,n)=>sY(e,t,{...r,path:[...r.path,o,n]})),s=i.rest?sY(i.rest,t,{...r,path:[...r.path,a,..."openapi-3.0"===t.target?[i.items.length]:[]]}):null;"draft-2020-12"===t.target?(n.prefixItems=u,s&&(n.items=s)):"openapi-3.0"===t.target?(n.items={anyOf:u},s&&n.items.anyOf.push(s),n.minItems=u.length,s||(n.maxItems=u.length)):(n.items=u,s&&(n.additionalItems=s));let{minimum:d,maximum:c}=e._zod.bag;"number"==typeof d&&(n.minItems=d),"number"==typeof c&&(n.maxItems=c)})(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function c3(e,t,n){let r=t instanceof aM,i=r?n:t;return new c0({type:"tuple",items:e,rest:r?t:null,...iY(i)})}let c8=ix("ZodRecord",(e,t)=>{uT.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;n.type="object";let o=i.keyType,a=o._zod.bag,u=a?.patterns;if("loose"===i.mode&&u&&u.size>0){let e=sY(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});for(let t of(n.patternProperties={},u))n.patternProperties[t.source]=e}else("draft-07"===t.target||"draft-2020-12"===t.target)&&(n.propertyNames=sY(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),n.additionalProperties=sY(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});let s=o._zod.values;if(s){let e=[...s].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(n.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function c1(e,t,n){return new c8({type:"record",keyType:e,valueType:t,...iY(n)})}function c2(e,t,n){let r=iX(e);return r._zod.values=void 0,new c8({type:"record",keyType:r,valueType:t,...iY(n)})}function c6(e,t,n){return new c8({type:"record",keyType:e,valueType:t,mode:"loose",...iY(n)})}let c4=ix("ZodMap",(e,t)=>{uj.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Map cannot be represented in JSON Schema")})(0,e,0,0),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(sP(...t)),e.nonempty=t=>e.check(sP(1,t)),e.max=(...t)=>e.check(sO(...t)),e.size=(...t)=>e.check(sI(...t))});function c9(e,t,n){return new c4({type:"map",keyType:e,valueType:t,...iY(n)})}let c5=ix("ZodSet",(e,t)=>{uP.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Set cannot be represented in JSON Schema")})(0,e,0,0),e.min=(...t)=>e.check(sP(...t)),e.nonempty=t=>e.check(sP(1,t)),e.max=(...t)=>e.check(sO(...t)),e.size=(...t)=>e.check(sI(...t))});function c7(e,t){return new c5({type:"set",valueType:e,...iY(t)})}let le=ix("ZodEnum",(e,t)=>{u$.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;(i=iI(e._zod.def.entries)).every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=i},e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new le({...t,checks:[],...iY(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new le({...t,checks:[],...iY(r),entries:i})}});function lt(e,t){return new le({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...iY(t)})}function ln(e,t){return new le({type:"enum",entries:e,...iY(t)})}let lr=ix("ZodLiteral",(e,t)=>{uM.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,o=[];for(let e of i.values)if(void 0===e){if("throw"===t.unrepresentable)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e)if("throw"===t.unrepresentable)throw Error("BigInt literals cannot be represented in JSON Schema");else o.push(Number(e));else o.push(e);if(0===o.length);else if(1===o.length){let e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n,0),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function li(e,t){return new lr({type:"literal",values:Array.isArray(e)?e:[e],...iY(t)})}let lo=ix("ZodFile",(e,t)=>{uC.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:u}=e._zod.bag;void 0!==o&&(i.minLength=o),void 0!==a&&(i.maxLength=a),u?1===u.length?(i.contentMediaType=u[0],Object.assign(n,i)):(Object.assign(n,i),n.anyOf=u.map(e=>({contentMediaType:e}))):Object.assign(n,i)})(e,0,n,0),e.min=(t,n)=>e.check(sP(t,n)),e.max=(t,n)=>e.check(sO(t,n)),e.mime=(t,n)=>e.check(sH(Array.isArray(t)?t:[t],n))});function la(e){return new lo({type:"file",...iY(e)})}let lu=ix("ZodTransform",(e,t)=>{uN.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Transforms cannot be represented in JSON Schema")})(0,e,0,0),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new ij(e.constructor.name);n.addIssue=r=>{"string"==typeof r?n.issues.push(i5(r,n.value,t)):(r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(i5(r)))};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ls(e){return new lu({type:"transform",transform:e})}let ld=ix("ZodOptional",(e,t)=>{uL.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s2(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lc(e){return new ld({type:"optional",innerType:e})}let ll=ix("ZodExactOptional",(e,t)=>{uZ.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s2(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lp(e){return new ll({type:"optional",innerType:e})}let lf=ix("ZodNullable",(e,t)=>{uD.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i,o,a;return o=sY((i=e._zod.def).innerType,t,r),a=t.seen.get(e),void("openapi-3.0"===t.target?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}])},e.unwrap=()=>e._zod.def.innerType});function lh(e){return new lf({type:"nullable",innerType:e})}function lm(e){return lc(lh(e))}let l_=ix("ZodDefault",(e,t)=>{uU.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lg(e,t){return new l_({type:"default",innerType:e,get defaultValue(){return"function"==typeof t?t():iG(t)}})}let lb=ix("ZodPrefault",(e,t)=>{uH.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},e.unwrap=()=>e._zod.def.innerType});function ly(e,t){return new lb({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof t?t():iG(t)}})}let lv=ix("ZodNonOptional",(e,t)=>{uJ.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType},e.unwrap=()=>e._zod.def.innerType});function lw(e,t){return new lv({type:"nonoptional",innerType:e,...iY(t)})}let lk=ix("ZodSuccess",(e,t)=>{uV.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{t.type="boolean"},e.unwrap=()=>e._zod.def.innerType});function lz(e){return new lk({type:"success",innerType:e})}let lS=ix("ZodCatch",(e,t)=>{uG.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i,o=e._zod.def;sY(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lE(e,t){return new lS({type:"catch",innerType:e,catchValue:"function"==typeof t?t:()=>t})}let lA=ix("ZodNaN",(e,t)=>{uW.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("NaN cannot be represented in JSON Schema")})(0,e,0,0)});function lx(e){return new lA({type:"nan",...iY(e)})}let lT=ix("ZodPipe",(e,t)=>{uq.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i,o;return i=e._zod.def,void(sY(o="input"===t.io?"transform"===i.in._zod.def.type?i.out:i.in:i.out,t,r),t.seen.get(e).ref=o)},e.in=t.in,e.out=t.out});function lj(e,t){return new lT({type:"pipe",in:e,out:t})}let lO=ix("ZodCodec",(e,t)=>{lT.init(e,t),uX.init(e,t)});function lP(e,t,n){return new lO({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}let lI=ix("ZodReadonly",(e,t)=>{u0.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0},e.unwrap=()=>e._zod.def.innerType});function l$(e){return new lI({type:"readonly",innerType:e})}let lM=ix("ZodTemplateLiteral",(e,t)=>{u8.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source})(e,0,n,0)});function lC(e,t){return new lM({type:"template_literal",parts:e,...iY(t)})}let lN=ix("ZodLazy",(e,t)=>{u6.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY(i=e._zod.innerType,t,r),t.seen.get(e).ref=i},e.unwrap=()=>e._zod.def.getter()});function lR(e){return new lN({type:"lazy",getter:e})}let lL=ix("ZodPromise",(e,t)=>{u2.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType},e.unwrap=()=>e._zod.def.innerType});function lZ(e){return new lL({type:"promise",innerType:e})}let lD=ix("ZodFunction",(e,t)=>{u1.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Function types cannot be represented in JSON Schema")})(0,e,0,0)});function lU(e){return new lD({type:"function",input:Array.isArray(e?.input)?c3(e?.input):e?.input??cD(cI()),output:e?.output??cI()})}let lF=ix("ZodCustom",(e,t)=>{u4.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Custom types cannot be represented in JSON Schema")})(0,e,0,0)});function lH(e){let t=new as({check:"custom"});return t._zod.check=e,t}function lJ(e,t){var n;let r;return n=e??(()=>!0),(r=iY(t)).abort??(r.abort=!0),new lF({type:"custom",check:"custom",fn:n,...r})}function lB(e,t={}){return new lF({type:"custom",check:"custom",fn:e,...iY(t)})}function lV(e){var t;let n,r;return t=t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(i5(e,t.value,n._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),e.input??(e.input=t.value),e.inst??(e.inst=n),e.continue??(e.continue=!n._zod.def.abort),t.issues.push(i5(e)))},e(t.value,t)),(r=new as({check:"custom",...iY(void 0)}))._zod.check=t,n=r}let lG=function(e){let t=new as({check:"describe"});return t._zod.onattach=[t=>{let n=u5.get(t)??{};u5.add(t,{...n,description:e})}],t._zod.check=()=>{},t},lW=function(e){let t=new as({check:"meta"});return t._zod.onattach=[t=>{let n=u5.get(t)??{};u5.add(t,{...n,...e})}],t._zod.check=()=>{},t};function lq(e,t={}){let n=new lF({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...iY(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:"invalid_type",expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}let lK=(...e)=>(function(e,t){let n=iY(t),r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];"sensitive"!==n.case&&(r=r.map(e=>"string"==typeof e?e.toLowerCase():e),i=i.map(e=>"string"==typeof e?e.toLowerCase():e));let o=new Set(r),a=new Set(i),u=e.Codec??uX,s=e.Boolean??ut,d=new u({type:"pipe",in:new(e.String??aC)({type:"string",error:n.error}),out:new s({type:"boolean",error:n.error}),transform:(e,t)=>{let r=e;return"sensitive"!==n.case&&(r=r.toLowerCase()),!!o.has(r)||!a.has(r)&&(t.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:t.value,inst:d,continue:!1}),{})},reverseTransform:(e,t)=>!0===e?r[0]||"true":i[0]||"false",error:n.error});return d})({Codec:lO,Boolean:c_,String:dv},...e);function lX(e){let t=lR(()=>cG([dw(e),cd(),cg(),cT(),cD(t),c1(dw(),t)]));return t}function lY(e,t){return lj(ls(e),t)}E||(E={}),iP({localeError:(c={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}},l={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},p={nan:"NaN"},e=>{switch(e.code){case"invalid_type":{let t=p[e.expected]??e.expected,n=function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t}(e.input),r=p[n]??n;return`Invalid input: expected ${t}, received ${r}`}case"invalid_value":if(1===e.values.length)return`Invalid input: expected ${iQ(e.values[0])}`;return`Invalid option: expected one of ${i$(e.values,"|")}`;case"too_big":{let t=e.inclusive?"<=":"<",n=c[e.origin]??null;if(n)return`Too big: expected ${e.origin??"value"} to have ${t}${e.maximum.toString()} ${n.unit??"elements"}`;return`Too big: expected ${e.origin??"value"} to be ${t}${e.maximum.toString()}`}case"too_small":{let t=e.inclusive?">=":">",n=c[e.origin]??null;if(n)return`Too small: expected ${e.origin} to have ${t}${e.minimum.toString()} ${n.unit}`;return`Too small: expected ${e.origin} to be ${t}${e.minimum.toString()}`}case"invalid_format":if("starts_with"===e.format)return`Invalid string: must start with "${e.prefix}"`;if("ends_with"===e.format)return`Invalid string: must end with "${e.suffix}"`;if("includes"===e.format)return`Invalid string: must include "${e.includes}"`;if("regex"===e.format)return`Invalid string: must match pattern ${e.pattern}`;return`Invalid ${l[e.format]??e.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${i$(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":default:return"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`}})});let lQ=({body:e,onError:t,onFinish:n,pageSize:r=10})=>{let[i,o]=(0,N.useState)(),[a,u]=(0,N.useState)(""),s=(0,N.useRef)(0),d=nu(),c=e=>{o(e),e&&t?.(e)},l=(0,N.useRef)(!1),{data:p,loadMoreAsync:f,loadingMore:h,loading:m,mutate:_,error:g}=eS(async e=>{if(l.current=!0,e?.noMore)return{noMore:!0,list:[]};try{let t=await d.ai.chat.message.getPage(e?.cursor,r);s.current=t.conversationVersion;let n=t.messages.at(-1);return console.log(n),n?.isGenerating&&E(n.id,s.current),{cursor:t.nextCursor,list:t.messages,noMore:!t.nextCursor}}finally{l.current=!1}},{direction:"top"}),b=async()=>{if(!l.current)try{l.current=!0,await f()}finally{l.current=!1}},y=p?.list??[],v=L(p),w=(0,N.useRef)(y);w.current=y;let k=e=>{let t;t="function"==typeof e?e(w.current):e,w.current=t,_({...v.current,list:t})},{chatStreaming:z,isStreaming:S,recoverStreaming:E}=(({common:e,setError:t,setMessages:n,getMessages:r,setInput:i,mujian:o,conversationVersion:a})=>{let{body:u}=e,[s,d]=(0,N.useState)(!1);return{chatStreaming:(0,N.useCallback)(async({query:e,regenerate:u,is_continue:s,conversationVersion:c})=>{try{t(void 0),d(!0);let l=r(),p={id:`${iA}_user_${Date.now()}`,isUser:!0,swipes:[{content:e??""}],activeSwipeId:0,isGenerating:!1},f={id:`${iA}_assistant_${Date.now()}`,isUser:!1,swipes:[{content:""}],activeSwipeId:0,isGenerating:!0};u?n(iw(e=>{let t=e[e.length-1];t.activeSwipeId=t.swipes.length,t.swipes.push({content:""}),t.isGenerating=!0})):s?n(e=>[...e,f]):n(e=>[...e,p,f]);let h=iE(o,e||"",s?"continue":u?"regenerate":"generate",c);try{for await(let e of h){if(!e)return;"meta"===e.type?(u||n(iw(t=>{s||(t[t.length-2].id=e.userMsgId),t[t.length-1].id=e.assisMsgId})),a.current=e.newConversationVersion):"data"===e.type&&(n(iw(t=>{let n=t[t.length-1];n.swipes[n.activeSwipeId]={content:e.content,mjv:e.mjv},e.finishReason&&(n.finishReason=e.finishReason),e.error&&(n.error=e.error)})),await new Promise(e=>setTimeout(e,10)))}}catch(r){tS.e("Stream error",r),"object"==typeof r&&r&&"message"in r&&"string"==typeof r.message?"code"in r&&0x77dde1f1===r.code?(n(l),u||s||!e||i(e)):iz(r.message)?t(new iS("E_NETWORK_ERROR")):t(new iS(r.message)):t(r)}finally{n(iw(e=>{e[e.length-1].isGenerating=!1}))}}catch(e){console.error("Error:",e),t(new iS("Send message failed",e)),n(e=>e.slice(0,-1))}finally{d(!1)}},[u,o]),isStreaming:s,recoverStreaming:(0,N.useCallback)(async(e,r)=>{let i=iE(o,"","recover",r,e);try{for await(let t of i){if(!t)return;"data"===t.type&&n(iw(n=>{let r=n.find(t=>t.id===e);r&&(r.swipes[r.activeSwipeId]={content:t.content,mjv:t.mjv},t.finishReason&&(r.finishReason=t.finishReason),t.error&&(r.error=t.error))}))}}catch(e){tS.e("Stream error",e),"object"==typeof e&&e&&"message"in e&&"string"==typeof e.message?iz(e.message)?t(new iS("E_NETWORK_ERROR")):t(new iS(e.message)):t(e)}finally{console.log("finally"),n(iw(t=>{let n=t.find(t=>t.id===e);console.log("finally",n),n&&(n.isGenerating=!1)}))}},[o])}})({common:{body:e},setError:c,setMessages:k,getMessages:(0,N.useCallback)(()=>w.current,[w]),setInput:u,mujian:d,conversationVersion:s});G(()=>{if(!S){let e=y[y.length-1];n?.(e)}},[S]);let A=(0,N.useCallback)(async e=>{if(S)throw Error("useChat is streaming already.");try{await z({query:e,conversationVersion:s.current})}catch(e){throw c(e),e}},[S,z]),x=(0,N.useCallback)(async()=>{if(S)throw Error("useChat is streaming already.");let e=y.findLast(e=>e.isUser);try{let t=e?e.swipes[e.activeSwipeId].content:"";await z({query:t,regenerate:!0,conversationVersion:s.current})}catch(e){throw c(e),e}},[S,y,z]),T=(0,N.useCallback)(async()=>{if(S)throw Error("useChat is streaming already.");try{await z({query:"",is_continue:!0,conversationVersion:s.current})}catch(e){throw c(e),e}},[S,z]),j=async(e,t)=>{if(t<0)return;k(n=>n.map(n=>n.id===e&&t<n.swipes.length?{...n,activeSwipeId:t}:n));let n=await d.ai.chat.message.swipe(e,t),{data:r,success:i}=cH({newConversationVersion:cd()}).safeParse(n);i&&r.newConversationVersion&&(s.current=r.newConversationVersion)},O=async(e,t)=>{let n=await d.ai.chat.message.editOne(e,t),{data:r,success:i}=cH({newConversationVersion:cd()}).safeParse(n);i&&r.newConversationVersion&&(s.current=r.newConversationVersion),k(n=>n.map(n=>{let r;return n.id===e?((r={...n,content:t}).isUser||(r.swipes=[...r.swipes],r.swipes[r.activeSwipeId].content=t),r):n}))},P=async e=>{if(!e.startsWith(iA))try{let t=await d.ai.chat.message.deleteOne(e),{data:n,success:r}=cH({newConversationVersion:cd()}).safeParse(t);r&&n.newConversationVersion&&(s.current=n.newConversationVersion)}catch(e){if(e?.code!==0x77dde1f4)throw e}k(t=>t.filter(t=>t.id!==e))};return{append:A,regenerate:x,continueGenerate:T,stop:()=>{let e=y.at(-1)?.id;e&&d.ai.chat.stop(s.current,e)},messages:y,status:i?"error":S?"streaming":"ready",error:i,setMessages:k,input:a,setInput:u,handleSubmit:()=>{A(a)},setSwipe:j,editMessage:O,deleteMessage:P,loadMoreMessage:b,messagesStatus:g?"error":h||m?"loading":p?.noMore?"all-loaded":"has-more"}}})(),i})());
169
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){i(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){i(n);continue}}if(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&"ref"===e.reused){i(n);continue}}}function s0(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=t=>{let n=e.seen.get(t);if(null===n.ref)return;let i=n.def??n.schema,o={...i},a=n.ref;if(n.ref=null,a){r(a);let n=e.seen.get(a),u=n.schema;if(u.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(i.allOf=i.allOf??[],i.allOf.push(u)):Object.assign(i,u),Object.assign(i,o),t._zod.parent===a)for(let e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(u.$ref&&n.def)for(let e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let u=t._zod.parent;if(u&&u!==a){r(u);let t=e.seen.get(u);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&("draft-2020-12"===e.target?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:s3(t,"input",e.processors),output:s3(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw Error("Error converting schema to JSON.")}}let s3=(e,t,n={})=>r=>{let{libraryOptions:i,target:o}=r??{},a=sX({...i??{},target:o,io:t,processors:n});return sY(e,a),sQ(a,e),s0(a,e)},s8={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},s1=(e,t,n,r)=>{let i=e._zod.def,o=!1===i.inclusive,a=i.options.map((e,n)=>sY(e,t,{...r,path:[...r.path,o?"oneOf":"anyOf",n]}));o?n.oneOf=a:n.anyOf=a},s2=(e,t,n,r)=>{let i=e._zod.def;sY(i.innerType,t,r),t.seen.get(e).ref=i.innerType},s6=ix("ZodISODateTime",(e,t)=>{aW.init(e,t),dk.init(e,t)});function s4(e){return new s6({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...iY(e)})}let s9=ix("ZodISODate",(e,t)=>{aq.init(e,t),dk.init(e,t)});function s5(e){return new s9({type:"string",format:"date",check:"string_format",...iY(e)})}let s7=ix("ZodISOTime",(e,t)=>{aK.init(e,t),dk.init(e,t)});function de(e){return new s7({type:"string",format:"time",check:"string_format",precision:null,...iY(e)})}let dt=ix("ZodISODuration",(e,t)=>{aX.init(e,t),dk.init(e,t)});function dn(e){return new dt({type:"string",format:"duration",check:"string_format",...iY(e)})}let dr=(e,t)=>{oe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>(function(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>r({issues:e}));else if("invalid_key"===i.code)r({issues:i.issues});else if("invalid_element"===i.code)r({issues:i.issues});else if(0===i.path.length)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n})(e,t)},flatten:{value:t=>(function(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}})(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,iM,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,iM,2)}},isEmpty:{get:()=>0===e.issues.length}})};ix("ZodError",dr);let di=ix("ZodError",dr,{Parent:Error}),da=on(di),du=oi(di),ds=oa(di),dd=os(di),dc=(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return on(di)(e,t,r)},dl=(e,t,n)=>on(di)(e,t,n),dp=async(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return oi(di)(e,t,r)},df=async(e,t,n)=>oi(di)(e,t,n),dh=(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return oa(di)(e,t,r)},dm=(e,t,n)=>oa(di)(e,t,n),d_=async(e,t,n)=>{let r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return os(di)(e,t,r)},dg=async(e,t,n)=>os(di)(e,t,n),db=ix("ZodType",(e,t)=>(aM.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:s3(e,"input"),output:s3(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{let r=sX({...n,processors:t});return sY(e,r),sQ(r,e),s0(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(iU(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>iX(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>da(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ds(e,t,n),e.parseAsync=async(t,n)=>du(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>dd(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>dc(e,t,n),e.decode=(t,n)=>dl(e,t,n),e.encodeAsync=async(t,n)=>dp(e,t,n),e.decodeAsync=async(t,n)=>df(e,t,n),e.safeEncode=(t,n)=>dh(e,t,n),e.safeDecode=(t,n)=>dm(e,t,n),e.safeEncodeAsync=async(t,n)=>d_(e,t,n),e.safeDecodeAsync=async(t,n)=>dg(e,t,n),e.refine=(t,n)=>e.check(lB(t,n)),e.superRefine=t=>e.check(lV(t)),e.overwrite=t=>e.check(sJ(t)),e.optional=()=>lc(e),e.exactOptional=()=>lp(e),e.nullable=()=>lh(e),e.nullish=()=>lc(lh(e)),e.nonoptional=t=>lw(e,t),e.array=()=>cD(e),e.or=t=>cG([e,t]),e.and=t=>cQ(e,t),e.transform=t=>lj(e,ls(t)),e.default=t=>lg(e,t),e.prefault=t=>ly(e,t),e.catch=t=>lE(e,t),e.pipe=t=>lj(e,t),e.readonly=()=>l$(e),e.describe=t=>{let n=e.clone();return u5.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>u5.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return u5.get(e);let n=e.clone();return u5.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),dy=ix("_ZodString",(e,t)=>{aC.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{n.type="string";let{minimum:i,maximum:o,format:a,patterns:u,contentEncoding:s}=e._zod.bag;if("number"==typeof i&&(n.minLength=i),"number"==typeof o&&(n.maxLength=o),a&&(n.format=s8[a]??a,""===n.format&&delete n.format,"time"===a&&delete n.format),s&&(n.contentEncoding=s),u&&u.size>0){let e=[...u];1===e.length?n.pattern=e[0].source:e.length>1&&(n.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n,0);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(sN(...t)),e.includes=(...t)=>e.check(sZ(...t)),e.startsWith=(...t)=>e.check(sD(...t)),e.endsWith=(...t)=>e.check(sU(...t)),e.min=(...t)=>e.check(sM(...t)),e.max=(...t)=>e.check(s$(...t)),e.length=(...t)=>e.check(sC(...t)),e.nonempty=(...t)=>e.check(sM(1,...t)),e.lowercase=t=>e.check(sR(t)),e.uppercase=t=>e.check(sL(t)),e.trim=()=>e.check(sV()),e.normalize=(...t)=>e.check(sB(...t)),e.toLowerCase=()=>e.check(sG()),e.toUpperCase=()=>e.check(sW()),e.slugify=()=>e.check(sq())}),dv=ix("ZodString",(e,t)=>{aC.init(e,t),dy.init(e,t),e.email=t=>e.check(u7(dz,t)),e.url=t=>e.check(so(dI,t)),e.jwt=t=>e.check(sv(ct,t)),e.emoji=t=>e.check(sa(dC,t)),e.guid=t=>e.check(se(dE,t)),e.uuid=t=>e.check(st(dx,t)),e.uuidv4=t=>e.check(sn(dx,t)),e.uuidv6=t=>e.check(sr(dx,t)),e.uuidv7=t=>e.check(si(dx,t)),e.nanoid=t=>e.check(su(dR,t)),e.guid=t=>e.check(se(dE,t)),e.cuid=t=>e.check(ss(dZ,t)),e.cuid2=t=>e.check(sd(dU,t)),e.ulid=t=>e.check(sc(dH,t)),e.base64=t=>e.check(sg(d6,t)),e.base64url=t=>e.check(sb(d9,t)),e.xid=t=>e.check(sl(dB,t)),e.ksuid=t=>e.check(sp(dG,t)),e.ipv4=t=>e.check(sf(dq,t)),e.ipv6=t=>e.check(sh(dQ,t)),e.cidrv4=t=>e.check(sm(d3,t)),e.cidrv6=t=>e.check(s_(d1,t)),e.e164=t=>e.check(sy(d7,t)),e.datetime=t=>e.check(s4(t)),e.date=t=>e.check(s5(t)),e.time=t=>e.check(de(t)),e.duration=t=>e.check(dn(t))});function dw(e){return new dv({type:"string",...iY(e)})}let dk=ix("ZodStringFormat",(e,t)=>{aN.init(e,t),dy.init(e,t)}),dz=ix("ZodEmail",(e,t)=>{aZ.init(e,t),dk.init(e,t)});function dS(e){return u7(dz,e)}let dE=ix("ZodGUID",(e,t)=>{aR.init(e,t),dk.init(e,t)});function dA(e){return se(dE,e)}let dx=ix("ZodUUID",(e,t)=>{aL.init(e,t),dk.init(e,t)});function dT(e){return st(dx,e)}function dj(e){return sn(dx,e)}function dO(e){return sr(dx,e)}function dP(e){return si(dx,e)}let dI=ix("ZodURL",(e,t)=>{aD.init(e,t),dk.init(e,t)});function d$(e){return so(dI,e)}function dM(e){return so(dI,{protocol:/^https?$/,hostname:oL,...iY(e)})}let dC=ix("ZodEmoji",(e,t)=>{aU.init(e,t),dk.init(e,t)});function dN(e){return sa(dC,e)}let dR=ix("ZodNanoID",(e,t)=>{aF.init(e,t),dk.init(e,t)});function dL(e){return su(dR,e)}let dZ=ix("ZodCUID",(e,t)=>{aH.init(e,t),dk.init(e,t)});function dD(e){return ss(dZ,e)}let dU=ix("ZodCUID2",(e,t)=>{aJ.init(e,t),dk.init(e,t)});function dF(e){return sd(dU,e)}let dH=ix("ZodULID",(e,t)=>{aB.init(e,t),dk.init(e,t)});function dJ(e){return sc(dH,e)}let dB=ix("ZodXID",(e,t)=>{aV.init(e,t),dk.init(e,t)});function dV(e){return sl(dB,e)}let dG=ix("ZodKSUID",(e,t)=>{aG.init(e,t),dk.init(e,t)});function dW(e){return sp(dG,e)}let dq=ix("ZodIPv4",(e,t)=>{aY.init(e,t),dk.init(e,t)});function dK(e){return sf(dq,e)}let dX=ix("ZodMAC",(e,t)=>{a0.init(e,t),dk.init(e,t)});function dY(e){return new dX({type:"string",format:"mac",check:"string_format",abort:!1,...iY(e)})}let dQ=ix("ZodIPv6",(e,t)=>{aQ.init(e,t),dk.init(e,t)});function d0(e){return sh(dQ,e)}let d3=ix("ZodCIDRv4",(e,t)=>{a3.init(e,t),dk.init(e,t)});function d8(e){return sm(d3,e)}let d1=ix("ZodCIDRv6",(e,t)=>{a8.init(e,t),dk.init(e,t)});function d2(e){return s_(d1,e)}let d6=ix("ZodBase64",(e,t)=>{a2.init(e,t),dk.init(e,t)});function d4(e){return sg(d6,e)}let d9=ix("ZodBase64URL",(e,t)=>{a6.init(e,t),dk.init(e,t)});function d5(e){return sb(d9,e)}let d7=ix("ZodE164",(e,t)=>{a4.init(e,t),dk.init(e,t)});function ce(e){return sy(d7,e)}let ct=ix("ZodJWT",(e,t)=>{a9.init(e,t),dk.init(e,t)});function cn(e){return sv(ct,e)}let cr=ix("ZodCustomStringFormat",(e,t)=>{a5.init(e,t),dk.init(e,t)});function ci(e,t,n={}){return sK(cr,e,t,n)}function co(e){return sK(cr,"hostname",oR,e)}function ca(e){return sK(cr,"hex",o0,e)}function cu(e,t){let n=t?.enc??"hex",r=`${e}_${n}`,i=A[r];if(!i)throw Error(`Unrecognized hash format: ${r}`);return sK(cr,r,i,t)}let cs=ix("ZodNumber",(e,t)=>{a7.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let{minimum:i,maximum:o,format:a,multipleOf:u,exclusiveMaximum:s,exclusiveMinimum:d}=e._zod.bag;"string"==typeof a&&a.includes("int")?n.type="integer":n.type="number","number"==typeof d&&("draft-04"===t.target||"openapi-3.0"===t.target?(n.minimum=d,n.exclusiveMinimum=!0):n.exclusiveMinimum=d),"number"==typeof i&&(n.minimum=i,"number"==typeof d&&"draft-04"!==t.target&&(d>=i?delete n.minimum:delete n.exclusiveMinimum)),"number"==typeof s&&("draft-04"===t.target||"openapi-3.0"===t.target?(n.maximum=s,n.exclusiveMaximum=!0):n.exclusiveMaximum=s),"number"==typeof o&&(n.maximum=o,"number"==typeof s&&"draft-04"!==t.target&&(s<=o?delete n.maximum:delete n.exclusiveMaximum)),"number"==typeof u&&(n.multipleOf=u)})(e,t,n,0),e.gt=(t,n)=>e.check(sz(t,n)),e.gte=(t,n)=>e.check(sS(t,n)),e.min=(t,n)=>e.check(sS(t,n)),e.lt=(t,n)=>e.check(sw(t,n)),e.lte=(t,n)=>e.check(sk(t,n)),e.max=(t,n)=>e.check(sk(t,n)),e.int=t=>e.check(cl(t)),e.safe=t=>e.check(cl(t)),e.positive=t=>e.check(sz(0,t)),e.nonnegative=t=>e.check(sS(0,t)),e.negative=t=>e.check(sw(0,t)),e.nonpositive=t=>e.check(sk(0,t)),e.multipleOf=(t,n)=>e.check(sj(t,n)),e.step=(t,n)=>e.check(sj(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function cd(e){return new cs({type:"number",checks:[],...iY(e)})}let cc=ix("ZodNumberFormat",(e,t)=>{ue.init(e,t),cs.init(e,t)});function cl(e){return new cc({type:"number",check:"number_format",abort:!1,format:"safeint",...iY(e)})}function cp(e){return new cc({type:"number",check:"number_format",abort:!1,format:"float32",...iY(e)})}function cf(e){return new cc({type:"number",check:"number_format",abort:!1,format:"float64",...iY(e)})}function ch(e){return new cc({type:"number",check:"number_format",abort:!1,format:"int32",...iY(e)})}function cm(e){return new cc({type:"number",check:"number_format",abort:!1,format:"uint32",...iY(e)})}let c_=ix("ZodBoolean",(e,t)=>{ut.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{t.type="boolean"}});function cg(e){return new c_({type:"boolean",...iY(e)})}let cb=ix("ZodBigInt",(e,t)=>{un.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("BigInt cannot be represented in JSON Schema")})(0,e,0,0),e.gte=(t,n)=>e.check(sS(t,n)),e.min=(t,n)=>e.check(sS(t,n)),e.gt=(t,n)=>e.check(sz(t,n)),e.gte=(t,n)=>e.check(sS(t,n)),e.min=(t,n)=>e.check(sS(t,n)),e.lt=(t,n)=>e.check(sw(t,n)),e.lte=(t,n)=>e.check(sk(t,n)),e.max=(t,n)=>e.check(sk(t,n)),e.positive=t=>e.check(sz(BigInt(0),t)),e.negative=t=>e.check(sw(BigInt(0),t)),e.nonpositive=t=>e.check(sk(BigInt(0),t)),e.nonnegative=t=>e.check(sS(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(sj(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function cy(e){return new cb({type:"bigint",...iY(e)})}let cv=ix("ZodBigIntFormat",(e,t)=>{ur.init(e,t),cb.init(e,t)});function cw(e){return new cv({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...iY(e)})}function ck(e){return new cv({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...iY(e)})}let cz=ix("ZodSymbol",(e,t)=>{ui.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Symbols cannot be represented in JSON Schema")})(0,e,0,0)});function cS(e){return new cz({type:"symbol",...iY(e)})}let cE=ix("ZodUndefined",(e,t)=>{uo.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Undefined cannot be represented in JSON Schema")})(0,e,0,0)});function cA(e){return new cE({type:"undefined",...iY(e)})}let cx=ix("ZodNull",(e,t)=>{ua.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{"openapi-3.0"===e.target?(t.type="string",t.nullable=!0,t.enum=[null]):t.type="null"}});function cT(e){return new cx({type:"null",...iY(e)})}let cj=ix("ZodAny",(e,t)=>{uu.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function cO(){return new cj({type:"any"})}let cP=ix("ZodUnknown",(e,t)=>{us.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function cI(){return new cP({type:"unknown"})}let c$=ix("ZodNever",(e,t)=>{ud.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{t.not={}}});function cM(e){return new c$({type:"never",...iY(e)})}let cC=ix("ZodVoid",(e,t)=>{uc.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Void cannot be represented in JSON Schema")})(0,e,0,0)});function cN(e){return new cC({type:"void",...iY(e)})}let cR=ix("ZodDate",(e,t)=>{ul.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Date cannot be represented in JSON Schema")})(0,e,0,0),e.min=(t,n)=>e.check(sS(t,n)),e.max=(t,n)=>e.check(sk(t,n));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function cL(e){return new cR({type:"date",...iY(e)})}let cZ=ix("ZodArray",(e,t)=>{uf.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(n.minItems=o),"number"==typeof a&&(n.maxItems=a),n.type="array",n.items=sY(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(sM(t,n)),e.nonempty=t=>e.check(sM(1,t)),e.max=(t,n)=>e.check(s$(t,n)),e.length=(t,n)=>e.check(sC(t,n)),e.unwrap=()=>e.element});function cD(e,t){return new cZ({type:"array",element:e,...iY(t)})}function cU(e){return lt(Object.keys(e._zod.def.shape))}let cF=ix("ZodObject",(e,t)=>{ub.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;n.type="object",n.properties={};let o=i.shape;for(let e in o)n.properties[e]=sY(o[e],t,{...r,path:[...r.path,"properties",e]});let a=new Set([...new Set(Object.keys(o))].filter(e=>{let n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));a.size>0&&(n.required=Array.from(a)),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=sY(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(n.additionalProperties=!1)})(e,t,n,r),iZ(e,"shape",()=>t.shape),e.keyof=()=>lt(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:cI()}),e.loose=()=>e.clone({...e._zod.def,catchall:cI()}),e.strict=()=>e.clone({...e._zod.def,catchall:cM()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>(function(e,t){if(!iV(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=iU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return iD(this,"shape",n),n}});return iX(e,r)})(e,t),e.safeExtend=t=>(function(e,t){if(!iV(t))throw Error("Invalid input to safeExtend: expected a plain object");let n=iU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return iD(this,"shape",n),n}});return iX(e,n)})(e,t),e.merge=t=>{let n;return n=iU(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return iD(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]}),iX(e,n)},e.pick=t=>(function(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=iU(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return iD(this,"shape",e),e},checks:[]});return iX(e,i)})(e,t),e.omit=t=>(function(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=iU(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return iD(this,"shape",r),r},checks:[]});return iX(e,i)})(e,t),e.partial=(...t)=>(function(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let i=iU(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return iD(this,"shape",i),i},checks:[]});return iX(t,i)})(ld,e,t[0]),e.required=(...t)=>{var n;let r;return n=t[0],r=iU(e._zod.def,{get shape(){let t=e._zod.def.shape,r={...t};if(n)for(let e in n){if(!(e in r))throw Error(`Unrecognized key: "${e}"`);n[e]&&(r[e]=new lv({type:"nonoptional",innerType:t[e]}))}else for(let e in t)r[e]=new lv({type:"nonoptional",innerType:t[e]});return iD(this,"shape",r),r}}),iX(e,r)}});function cH(e,t){return new cF({type:"object",shape:e??{},...iY(t)})}function cJ(e,t){return new cF({type:"object",shape:e,catchall:cM(),...iY(t)})}function cB(e,t){return new cF({type:"object",shape:e,catchall:cI(),...iY(t)})}let cV=ix("ZodUnion",(e,t)=>{uv.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s1(e,t,n,r),e.options=t.options});function cG(e,t){return new cV({type:"union",options:e,...iY(t)})}let cW=ix("ZodXor",(e,t)=>{cV.init(e,t),uk.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s1(e,t,n,r),e.options=t.options});function cq(e,t){return new cW({type:"union",options:e,inclusive:!1,...iY(t)})}let cK=ix("ZodDiscriminatedUnion",(e,t)=>{cV.init(e,t),uz.init(e,t)});function cX(e,t,n){return new cK({type:"union",options:t,discriminator:e,...iY(n)})}let cY=ix("ZodIntersection",(e,t)=>{uS.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i,o,a,u;return o=sY((i=e._zod.def).left,t,{...r,path:[...r.path,"allOf",0]}),a=sY(i.right,t,{...r,path:[...r.path,"allOf",1]}),void(n.allOf=[...(u=e=>"allOf"in e&&1===Object.keys(e).length)(o)?o.allOf:[o],...u(a)?a.allOf:[a]])}});function cQ(e,t){return new cY({type:"intersection",left:e,right:t})}let c0=ix("ZodTuple",(e,t)=>{uA.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;n.type="array";let o="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",u=i.items.map((e,n)=>sY(e,t,{...r,path:[...r.path,o,n]})),s=i.rest?sY(i.rest,t,{...r,path:[...r.path,a,..."openapi-3.0"===t.target?[i.items.length]:[]]}):null;"draft-2020-12"===t.target?(n.prefixItems=u,s&&(n.items=s)):"openapi-3.0"===t.target?(n.items={anyOf:u},s&&n.items.anyOf.push(s),n.minItems=u.length,s||(n.maxItems=u.length)):(n.items=u,s&&(n.additionalItems=s));let{minimum:d,maximum:c}=e._zod.bag;"number"==typeof d&&(n.minItems=d),"number"==typeof c&&(n.maxItems=c)})(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function c3(e,t,n){let r=t instanceof aM,i=r?n:t;return new c0({type:"tuple",items:e,rest:r?t:null,...iY(i)})}let c8=ix("ZodRecord",(e,t)=>{uT.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;n.type="object";let o=i.keyType,a=o._zod.bag,u=a?.patterns;if("loose"===i.mode&&u&&u.size>0){let e=sY(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});for(let t of(n.patternProperties={},u))n.patternProperties[t.source]=e}else("draft-07"===t.target||"draft-2020-12"===t.target)&&(n.propertyNames=sY(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),n.additionalProperties=sY(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});let s=o._zod.values;if(s){let e=[...s].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(n.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function c1(e,t,n){return new c8({type:"record",keyType:e,valueType:t,...iY(n)})}function c2(e,t,n){let r=iX(e);return r._zod.values=void 0,new c8({type:"record",keyType:r,valueType:t,...iY(n)})}function c6(e,t,n){return new c8({type:"record",keyType:e,valueType:t,mode:"loose",...iY(n)})}let c4=ix("ZodMap",(e,t)=>{uj.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Map cannot be represented in JSON Schema")})(0,e,0,0),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...t)=>e.check(sP(...t)),e.nonempty=t=>e.check(sP(1,t)),e.max=(...t)=>e.check(sO(...t)),e.size=(...t)=>e.check(sI(...t))});function c9(e,t,n){return new c4({type:"map",keyType:e,valueType:t,...iY(n)})}let c5=ix("ZodSet",(e,t)=>{uP.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Set cannot be represented in JSON Schema")})(0,e,0,0),e.min=(...t)=>e.check(sP(...t)),e.nonempty=t=>e.check(sP(1,t)),e.max=(...t)=>e.check(sO(...t)),e.size=(...t)=>e.check(sI(...t))});function c7(e,t){return new c5({type:"set",valueType:e,...iY(t)})}let le=ix("ZodEnum",(e,t)=>{u$.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;(i=iI(e._zod.def.entries)).every(e=>"number"==typeof e)&&(n.type="number"),i.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=i},e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new le({...t,checks:[],...iY(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new le({...t,checks:[],...iY(r),entries:i})}});function lt(e,t){return new le({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...iY(t)})}function ln(e,t){return new le({type:"enum",entries:e,...iY(t)})}let lr=ix("ZodLiteral",(e,t)=>{uM.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,o=[];for(let e of i.values)if(void 0===e){if("throw"===t.unrepresentable)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e)if("throw"===t.unrepresentable)throw Error("BigInt literals cannot be represented in JSON Schema");else o.push(Number(e));else o.push(e);if(0===o.length);else if(1===o.length){let e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n,0),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function li(e,t){return new lr({type:"literal",values:Array.isArray(e)?e:[e],...iY(t)})}let lo=ix("ZodFile",(e,t)=>{uC.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:u}=e._zod.bag;void 0!==o&&(i.minLength=o),void 0!==a&&(i.maxLength=a),u?1===u.length?(i.contentMediaType=u[0],Object.assign(n,i)):(Object.assign(n,i),n.anyOf=u.map(e=>({contentMediaType:e}))):Object.assign(n,i)})(e,0,n,0),e.min=(t,n)=>e.check(sP(t,n)),e.max=(t,n)=>e.check(sO(t,n)),e.mime=(t,n)=>e.check(sH(Array.isArray(t)?t:[t],n))});function la(e){return new lo({type:"file",...iY(e)})}let lu=ix("ZodTransform",(e,t)=>{uN.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Transforms cannot be represented in JSON Schema")})(0,e,0,0),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new ij(e.constructor.name);n.addIssue=r=>{"string"==typeof r?n.issues.push(i5(r,n.value,t)):(r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(i5(r)))};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ls(e){return new lu({type:"transform",transform:e})}let ld=ix("ZodOptional",(e,t)=>{uL.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s2(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lc(e){return new ld({type:"optional",innerType:e})}let ll=ix("ZodExactOptional",(e,t)=>{uZ.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>s2(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lp(e){return new ll({type:"optional",innerType:e})}let lf=ix("ZodNullable",(e,t)=>{uD.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i,o,a;return o=sY((i=e._zod.def).innerType,t,r),a=t.seen.get(e),void("openapi-3.0"===t.target?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}])},e.unwrap=()=>e._zod.def.innerType});function lh(e){return new lf({type:"nullable",innerType:e})}function lm(e){return lc(lh(e))}let l_=ix("ZodDefault",(e,t)=>{uU.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lg(e,t){return new l_({type:"default",innerType:e,get defaultValue(){return"function"==typeof t?t():iG(t)}})}let lb=ix("ZodPrefault",(e,t)=>{uH.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},e.unwrap=()=>e._zod.def.innerType});function ly(e,t){return new lb({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof t?t():iG(t)}})}let lv=ix("ZodNonOptional",(e,t)=>{uJ.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType},e.unwrap=()=>e._zod.def.innerType});function lw(e,t){return new lv({type:"nonoptional",innerType:e,...iY(t)})}let lk=ix("ZodSuccess",(e,t)=>{uV.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{t.type="boolean"},e.unwrap=()=>e._zod.def.innerType});function lz(e){return new lk({type:"success",innerType:e})}let lS=ix("ZodCatch",(e,t)=>{uG.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i,o=e._zod.def;sY(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lE(e,t){return new lS({type:"catch",innerType:e,catchValue:"function"==typeof t?t:()=>t})}let lA=ix("ZodNaN",(e,t)=>{uW.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("NaN cannot be represented in JSON Schema")})(0,e,0,0)});function lx(e){return new lA({type:"nan",...iY(e)})}let lT=ix("ZodPipe",(e,t)=>{uq.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i,o;return i=e._zod.def,void(sY(o="input"===t.io?"transform"===i.in._zod.def.type?i.out:i.in:i.out,t,r),t.seen.get(e).ref=o)},e.in=t.in,e.out=t.out});function lj(e,t){return new lT({type:"pipe",in:e,out:t})}let lO=ix("ZodCodec",(e,t)=>{lT.init(e,t),uX.init(e,t)});function lP(e,t,n){return new lO({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}let lI=ix("ZodReadonly",(e,t)=>{u0.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0},e.unwrap=()=>e._zod.def.innerType});function l$(e){return new lI({type:"readonly",innerType:e})}let lM=ix("ZodTemplateLiteral",(e,t)=>{u8.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source})(e,0,n,0)});function lC(e,t){return new lM({type:"template_literal",parts:e,...iY(t)})}let lN=ix("ZodLazy",(e,t)=>{u6.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY(i=e._zod.innerType,t,r),t.seen.get(e).ref=i},e.unwrap=()=>e._zod.def.getter()});function lR(e){return new lN({type:"lazy",getter:e})}let lL=ix("ZodPromise",(e,t)=>{u2.init(e,t),db.init(e,t),e._zod.processJSONSchema=(t,n,r)=>{let i;sY((i=e._zod.def).innerType,t,r),t.seen.get(e).ref=i.innerType},e.unwrap=()=>e._zod.def.innerType});function lZ(e){return new lL({type:"promise",innerType:e})}let lD=ix("ZodFunction",(e,t)=>{u1.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Function types cannot be represented in JSON Schema")})(0,e,0,0)});function lU(e){return new lD({type:"function",input:Array.isArray(e?.input)?c3(e?.input):e?.input??cD(cI()),output:e?.output??cI()})}let lF=ix("ZodCustom",(e,t)=>{u4.init(e,t),db.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n,r)=>{if("throw"===t.unrepresentable)throw Error("Custom types cannot be represented in JSON Schema")})(0,e,0,0)});function lH(e){let t=new as({check:"custom"});return t._zod.check=e,t}function lJ(e,t){var n;let r;return n=e??(()=>!0),(r=iY(t)).abort??(r.abort=!0),new lF({type:"custom",check:"custom",fn:n,...r})}function lB(e,t={}){return new lF({type:"custom",check:"custom",fn:e,...iY(t)})}function lV(e){var t;let n,r;return t=t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(i5(e,t.value,n._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),e.input??(e.input=t.value),e.inst??(e.inst=n),e.continue??(e.continue=!n._zod.def.abort),t.issues.push(i5(e)))},e(t.value,t)),(r=new as({check:"custom",...iY(void 0)}))._zod.check=t,n=r}let lG=function(e){let t=new as({check:"describe"});return t._zod.onattach=[t=>{let n=u5.get(t)??{};u5.add(t,{...n,description:e})}],t._zod.check=()=>{},t},lW=function(e){let t=new as({check:"meta"});return t._zod.onattach=[t=>{let n=u5.get(t)??{};u5.add(t,{...n,...e})}],t._zod.check=()=>{},t};function lq(e,t={}){let n=new lF({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...iY(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:"invalid_type",expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}let lK=(...e)=>(function(e,t){let n=iY(t),r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];"sensitive"!==n.case&&(r=r.map(e=>"string"==typeof e?e.toLowerCase():e),i=i.map(e=>"string"==typeof e?e.toLowerCase():e));let o=new Set(r),a=new Set(i),u=e.Codec??uX,s=e.Boolean??ut,d=new u({type:"pipe",in:new(e.String??aC)({type:"string",error:n.error}),out:new s({type:"boolean",error:n.error}),transform:(e,t)=>{let r=e;return"sensitive"!==n.case&&(r=r.toLowerCase()),!!o.has(r)||!a.has(r)&&(t.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:t.value,inst:d,continue:!1}),{})},reverseTransform:(e,t)=>!0===e?r[0]||"true":i[0]||"false",error:n.error});return d})({Codec:lO,Boolean:c_,String:dv},...e);function lX(e){let t=lR(()=>cG([dw(e),cd(),cg(),cT(),cD(t),c1(dw(),t)]));return t}function lY(e,t){return lj(ls(e),t)}E||(E={}),iP({localeError:(c={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}},l={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},p={nan:"NaN"},e=>{switch(e.code){case"invalid_type":{let t=p[e.expected]??e.expected,n=function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":if(null===e)return"null";if(Array.isArray(e))return"array";if(e&&Object.getPrototypeOf(e)!==Object.prototype&&"constructor"in e&&e.constructor)return e.constructor.name}return t}(e.input),r=p[n]??n;return`Invalid input: expected ${t}, received ${r}`}case"invalid_value":if(1===e.values.length)return`Invalid input: expected ${iQ(e.values[0])}`;return`Invalid option: expected one of ${i$(e.values,"|")}`;case"too_big":{let t=e.inclusive?"<=":"<",n=c[e.origin]??null;if(n)return`Too big: expected ${e.origin??"value"} to have ${t}${e.maximum.toString()} ${n.unit??"elements"}`;return`Too big: expected ${e.origin??"value"} to be ${t}${e.maximum.toString()}`}case"too_small":{let t=e.inclusive?">=":">",n=c[e.origin]??null;if(n)return`Too small: expected ${e.origin} to have ${t}${e.minimum.toString()} ${n.unit}`;return`Too small: expected ${e.origin} to be ${t}${e.minimum.toString()}`}case"invalid_format":if("starts_with"===e.format)return`Invalid string: must start with "${e.prefix}"`;if("ends_with"===e.format)return`Invalid string: must end with "${e.suffix}"`;if("includes"===e.format)return`Invalid string: must include "${e.includes}"`;if("regex"===e.format)return`Invalid string: must match pattern ${e.pattern}`;return`Invalid ${l[e.format]??e.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${i$(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":default:return"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`}})});let lQ=({body:e,onError:t,onFinish:n,pageSize:r=10})=>{let[i,o]=(0,N.useState)(),[a,u]=(0,N.useState)(""),s=(0,N.useRef)(0),d=nu(),c=e=>{o(e),e&&t?.(e)},l=(0,N.useRef)(!1),{data:p,loadMoreAsync:f,loadingMore:h,loading:m,mutate:_,error:g}=eS(async e=>{if(l.current=!0,e?.noMore)return{noMore:!0,list:[]};try{let t=await d.ai.chat.message.getPage(e?.cursor,r);s.current=t.conversationVersion;let n=t.messages.at(-1);return n?.isGenerating&&E(n.id,s.current),{cursor:t.nextCursor,list:t.messages,noMore:!t.nextCursor}}finally{l.current=!1}},{direction:"top"}),b=async()=>{if(!l.current)try{l.current=!0,await f()}finally{l.current=!1}},y=p?.list??[],v=L(p),w=(0,N.useRef)(y);w.current=y;let k=e=>{let t;t="function"==typeof e?e(w.current):e,w.current=t,_({...v.current,list:t})},{chatStreaming:z,isStreaming:S,recoverStreaming:E}=(({common:e,setError:t,setMessages:n,getMessages:r,setInput:i,mujian:o,conversationVersion:a})=>{let{body:u}=e,[s,d]=(0,N.useState)(!1);return{chatStreaming:(0,N.useCallback)(async({query:e,regenerate:u,is_continue:s,conversationVersion:c})=>{try{t(void 0),d(!0);let l=r(),p={id:`${iA}_user_${Date.now()}`,isUser:!0,swipes:[{content:e??""}],activeSwipeId:0,isGenerating:!1},f={id:`${iA}_assistant_${Date.now()}`,isUser:!1,swipes:[{content:""}],activeSwipeId:0,isGenerating:!0};u?n(iw(e=>{let t=e[e.length-1];t.activeSwipeId=t.swipes.length,t.swipes.push({content:""}),t.isGenerating=!0})):s?n(e=>[...e,f]):n(e=>[...e,p,f]);let h=iE(o,e||"",s?"continue":u?"regenerate":"generate",c);try{for await(let e of h){if(!e)return;"meta"===e.type?(u||n(iw(t=>{s||(t[t.length-2].id=e.userMsgId),t[t.length-1].id=e.assisMsgId})),a.current=e.newConversationVersion):"data"===e.type&&(n(iw(t=>{let n=t[t.length-1];n.swipes[n.activeSwipeId]={content:e.content,mjv:e.mjv},e.finishReason&&(n.finishReason=e.finishReason),e.error&&(n.error=e.error)})),await new Promise(e=>setTimeout(e,10)))}}catch(r){tS.e("Stream error",r),"object"==typeof r&&r&&"message"in r&&"string"==typeof r.message?"code"in r&&0x77dde1f1===r.code?(n(l),u||s||!e||i(e)):iz(r.message)?t(new iS("E_NETWORK_ERROR")):t(new iS(r.message)):t(r)}finally{n(iw(e=>{e[e.length-1].isGenerating=!1}))}}catch(e){console.error("Error:",e),t(new iS("Send message failed",e)),n(e=>e.slice(0,-1))}finally{d(!1)}},[u,o]),isStreaming:s,recoverStreaming:(0,N.useCallback)(async(e,r)=>{let i=iE(o,"","recover",r,e);try{for await(let t of i){if(!t)return;"data"===t.type&&n(iw(n=>{let r=n.find(t=>t.id===e);r&&(r.swipes[r.activeSwipeId]={content:t.content,mjv:t.mjv},t.finishReason&&(r.finishReason=t.finishReason),t.error&&(r.error=t.error))}))}}catch(e){tS.e("Stream error",e),"object"==typeof e&&e&&"message"in e&&"string"==typeof e.message?iz(e.message)?t(new iS("E_NETWORK_ERROR")):t(new iS(e.message)):t(e)}finally{n(iw(t=>{let n=t.find(t=>t.id===e);n&&(n.isGenerating=!1)}))}},[o])}})({common:{body:e},setError:c,setMessages:k,getMessages:(0,N.useCallback)(()=>w.current,[w]),setInput:u,mujian:d,conversationVersion:s});G(()=>{if(!S){let e=y[y.length-1];n?.(e)}},[S]);let A=(0,N.useCallback)(async e=>{if(S)throw Error("useChat is streaming already.");try{await z({query:e,conversationVersion:s.current})}catch(e){throw c(e),e}},[S,z]),x=(0,N.useCallback)(async()=>{if(S)throw Error("useChat is streaming already.");let e=y.findLast(e=>e.isUser);try{let t=e?e.swipes[e.activeSwipeId].content:"";await z({query:t,regenerate:!0,conversationVersion:s.current})}catch(e){throw c(e),e}},[S,y,z]),T=(0,N.useCallback)(async()=>{if(S)throw Error("useChat is streaming already.");try{await z({query:"",is_continue:!0,conversationVersion:s.current})}catch(e){throw c(e),e}},[S,z]),j=async(e,t)=>{if(t<0)return;k(n=>n.map(n=>n.id===e&&t<n.swipes.length?{...n,activeSwipeId:t}:n));let n=await d.ai.chat.message.swipe(e,t),{data:r,success:i}=cH({newConversationVersion:cd()}).safeParse(n);i&&r.newConversationVersion&&(s.current=r.newConversationVersion)},O=async(e,t)=>{let n=await d.ai.chat.message.editOne(e,t),{data:r,success:i}=cH({newConversationVersion:cd()}).safeParse(n);i&&r.newConversationVersion&&(s.current=r.newConversationVersion),k(n=>n.map(n=>{let r;return n.id===e?((r={...n,content:t}).isUser||(r.swipes=[...r.swipes],r.swipes[r.activeSwipeId].content=t),r):n}))},P=async e=>{if(!e.startsWith(iA))try{let t=await d.ai.chat.message.deleteOne(e),{data:n,success:r}=cH({newConversationVersion:cd()}).safeParse(t);r&&n.newConversationVersion&&(s.current=n.newConversationVersion)}catch(e){if(e?.code!==0x77dde1f4)throw e}k(t=>t.filter(t=>t.id!==e))};return{append:A,regenerate:x,continueGenerate:T,stop:()=>{let e=y.at(-1)?.id;e&&d.ai.chat.stop(s.current,e)},messages:y,status:i?"error":S?"streaming":"ready",error:i,setMessages:k,input:a,setInput:u,handleSubmit:()=>{A(a)},setSwipe:j,editMessage:O,deleteMessage:P,loadMoreMessage:b,messagesStatus:g?"error":h||m?"loading":p?.noMore?"all-loaded":"has-more"}}})(),i})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mujian/js-sdk",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {