diff --git a/404.html b/404.html index 02d41c1..5248905 100644 --- a/404.html +++ b/404.html @@ -1 +1 @@ -404: This page could not be found.ChatGPT Subtitle Translator

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.ChatGPT Subtitle Translator

404

This page could not be found.

\ No newline at end of file diff --git a/_next/static/chunks/189-6ca42e7f5601622c.js b/_next/static/chunks/189-a57e6da36a0024a8.js similarity index 93% rename from _next/static/chunks/189-6ca42e7f5601622c.js rename to _next/static/chunks/189-a57e6da36a0024a8.js index 53fa012..1e93159 100644 --- a/_next/static/chunks/189-6ca42e7f5601622c.js +++ b/_next/static/chunks/189-a57e6da36a0024a8.js @@ -5,9 +5,9 @@ ${rL(e)}`);if(null==a)throw new t_(`missing choices[${n}].tool_calls[${r}].type ${rL(e)}`);if(null==u)throw new t_(`missing choices[${n}].tool_calls[${r}].function.name ${rL(e)}`);if(null==l)throw new t_(`missing choices[${n}].tool_calls[${r}].function.arguments -${rL(e)}`);return{...s,id:o,type:a,function:{...c,name:u,arguments:l}}})}}:{...a,message:{...u,content:o,role:c,refusal:t.refusal??null},finish_reason:r,index:n,logprobs:i}}),created:a,model:o,object:"chat.completion",...s?{system_fingerprint:s}:{}},t&&rT(t)?rA(r,t):{...r,choices:r.choices.map(e=>({...e,message:{...e.message,parsed:null,tool_calls:e.message.tool_calls??[]}}))}}(e,r$(this,q,"f"))},ei=function(){let e=r$(this,q,"f")?.response_format;return rP(e)?e:null},ea=function(e){var t,r,n,i;let a=r$(this,X,"f"),{choices:o,...s}=e;for(let{delta:o,finish_reason:l,index:u,logprobs:c=null,...d}of(a?Object.assign(a,s):a=rO(this,X,{...s,choices:[]},"f"),e.choices)){let e=a.choices[u];if(e||(e=a.choices[u]={finish_reason:l,index:u,message:{},logprobs:c,...d}),c){if(e.logprobs){let{content:n,refusal:i,...a}=c;Object.assign(e.logprobs,a),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),i&&((r=e.logprobs).refusal??(r.refusal=[]),e.logprobs.refusal.push(...i))}else e.logprobs=Object.assign({},c)}if(l&&(e.finish_reason=l,r$(this,q,"f")&&rT(r$(this,q,"f")))){if("length"===l)throw new tK;if("content_filter"===l)throw new tW}if(Object.assign(e,d),!o)continue;let{content:s,refusal:p,function_call:f,role:h,tool_calls:m,...g}=o;if(Object.assign(e.message,g),p&&(e.message.refusal=(e.message.refusal||"")+p),h&&(e.message.role=h),f&&(e.message.function_call?(f.name&&(e.message.function_call.name=f.name),f.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=f.arguments)):e.message.function_call=f),s&&(e.message.content=(e.message.content||"")+s,!e.message.refusal&&r$(this,H,"m",ei).call(this)&&(e.message.parsed=rR(e.message.content))),m)for(let{index:t,id:r,type:n,function:a,...o}of(e.message.tool_calls||(e.message.tool_calls=[]),m)){let s=(i=e.message.tool_calls)[t]??(i[t]={});Object.assign(s,o),r&&(s.id=r),n&&(s.type=n),a&&(s.function??(s.function={name:a.name??"",arguments:""})),a?.name&&(s.function.name=a.name),a?.arguments&&(s.function.arguments+=a.arguments,function(e,t){if(!e)return!1;let r=e.tools?.find(e=>e.function?.name===t.function.name);return rE(r)||r?.function.strict||!1}(r$(this,q,"f"),s)&&(s.function.parsed_arguments=rR(s.function.arguments)))}}return a},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("chunk",r=>{let n=t.shift();n?n.resolve(r):e.push(r)}),this.on("end",()=>{for(let e of(r=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((e,r)=>t.push({resolve:e,reject:r})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new ez(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function rL(e){return JSON.stringify(e)}class rz extends rF{static fromReadableStream(e){let t=new rz(null);return t._run(()=>t._fromReadableStream(e)),t}static runFunctions(e,t,r){let n=new rz(null),i={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return n._run(()=>n._runFunctions(e,t,i)),n}static runTools(e,t,r){let n=new rz(t),i={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,i)),n}}class rK extends t5{parse(e,t){return!function(e){for(let t of e??[]){if("function"!==t.type)throw new t_(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new t_(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap(t=>rA(t,e))}runFunctions(e,t){return e.stream?rz.runFunctions(this._client,e,t):rB.runFunctions(this._client,e,t)}runTools(e,t){return e.stream?rz.runTools(this._client,e,t):rB.runTools(this._client,e,t)}stream(e,t){return rF.createChatCompletion(this._client,e,t)}}class rW extends t5{constructor(){super(...arguments),this.completions=new rK(this._client)}}(rW||(rW={})).Completions=rK;var rV=function(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},rU=function(e,t,r,n,i){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r};class rG extends rS{constructor(){super(...arguments),eo.add(this),es.set(this,[]),el.set(this,{}),eu.set(this,{}),ec.set(this,void 0),ed.set(this,void 0),ep.set(this,void 0),ef.set(this,void 0),eh.set(this,void 0),em.set(this,void 0),eg.set(this,void 0),ev.set(this,void 0),ey.set(this,void 0)}[(es=new WeakMap,el=new WeakMap,eu=new WeakMap,ec=new WeakMap,ed=new WeakMap,ep=new WeakMap,ef=new WeakMap,eh=new WeakMap,em=new WeakMap,eg=new WeakMap,ev=new WeakMap,ey=new WeakMap,eo=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("event",r=>{let n=t.shift();n?n.resolve(r):e.push(r)}),this.on("end",()=>{for(let e of(r=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((e,r)=>t.push({resolve:e,reject:r})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new rG;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let r=t?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),this._connected();let n=ez.fromReadableStream(e,this.controller);for await(let e of n)rV(this,eo,"m",eb).call(this,e);if(n.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}toReadableStream(){return new ez(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,r,n,i){let a=new rG;return a._run(()=>a._runToolAssistantStream(e,t,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),a}async _createToolAssistantStream(e,t,r,n,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener("abort",()=>this.controller.abort()));let o={...n,stream:!0},s=await e.submitToolOutputs(t,r,o,{...i,signal:this.controller.signal});for await(let e of(this._connected(),s))rV(this,eo,"m",eb).call(this,e);if(s.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}static createThreadAssistantStream(e,t,r){let n=new rG;return n._run(()=>n._threadAssistantStream(e,t,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}static createAssistantStream(e,t,r,n){let i=new rG;return i._run(()=>i._runAssistantStream(e,t,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}currentEvent(){return rV(this,eg,"f")}currentRun(){return rV(this,ev,"f")}currentMessageSnapshot(){return rV(this,ec,"f")}currentRunStepSnapshot(){return rV(this,ey,"f")}async finalRunSteps(){return await this.done(),Object.values(rV(this,el,"f"))}async finalMessages(){return await this.done(),Object.values(rV(this,eu,"f"))}async finalRun(){if(await this.done(),!rV(this,ed,"f"))throw Error("Final run was not received.");return rV(this,ed,"f")}async _createThreadAssistantStream(e,t,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort()));let i={...t,stream:!0},a=await e.createAndRun(i,{...r,signal:this.controller.signal});for await(let e of(this._connected(),a))rV(this,eo,"m",eb).call(this,e);if(a.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}async _createAssistantStream(e,t,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let a={...r,stream:!0},o=await e.create(t,a,{...n,signal:this.controller.signal});for await(let e of(this._connected(),o))rV(this,eo,"m",eb).call(this,e);if(o.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}static accumulateDelta(e,t){for(let[r,n]of Object.entries(t)){if(!e.hasOwnProperty(r)){e[r]=n;continue}let t=e[r];if(null==t||"index"===r||"type"===r){e[r]=n;continue}if("string"==typeof t&&"string"==typeof n)t+=n;else if("number"==typeof t&&"number"==typeof n)t+=n;else if(tT(t)&&tT(n))t=this.accumulateDelta(t,n);else if(Array.isArray(t)&&Array.isArray(n)){if(t.every(e=>"string"==typeof e||"number"==typeof e)){t.push(...n);continue}for(let e of n){if(!tT(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let r=e.index;if(null==r)throw console.error(e),Error("Expected array delta entry to have an `index` property");if("number"!=typeof r)throw Error(`Expected array delta entry \`index\` property to be a number but got ${r}`);let n=t[r];null==n?t.push(e):t[r]=this.accumulateDelta(n,e)}continue}else throw Error(`Unhandled record type: ${r}, deltaValue: ${n}, accValue: ${t}`);e[r]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,r){return await this._createThreadAssistantStream(t,e,r)}async _runAssistantStream(e,t,r,n){return await this._createAssistantStream(t,e,r,n)}async _runToolAssistantStream(e,t,r,n,i){return await this._createToolAssistantStream(r,e,t,n,i)}}eb=function(e){if(!this.ended)switch(rU(this,eg,e,"f"),rV(this,eo,"m",ek).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":rV(this,eo,"m",eA).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":rV(this,eo,"m",eC).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":rV(this,eo,"m",ew).call(this,e);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier")}},ex=function(){if(this.ended)throw new t_("stream has ended, this shouldn't happen");if(!rV(this,ed,"f"))throw Error("Final run has not been received");return rV(this,ed,"f")},ew=function(e){let[t,r]=rV(this,eo,"m",eP).call(this,e,rV(this,ec,"f"));for(let e of(rU(this,ec,t,"f"),rV(this,eu,"f")[t.id]=t,r)){let r=t.content[e.index];r?.type=="text"&&this._emit("textCreated",r.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(let r of e.data.delta.content){if("text"==r.type&&r.text){let e=r.text,n=t.content[r.index];if(n&&"text"==n.type)this._emit("textDelta",e,n.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(r.index!=rV(this,ep,"f")){if(rV(this,ef,"f"))switch(rV(this,ef,"f").type){case"text":this._emit("textDone",rV(this,ef,"f").text,rV(this,ec,"f"));break;case"image_file":this._emit("imageFileDone",rV(this,ef,"f").image_file,rV(this,ec,"f"))}rU(this,ep,r.index,"f")}rU(this,ef,t.content[r.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==rV(this,ep,"f")){let t=e.data.content[rV(this,ep,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,rV(this,ec,"f"));break;case"text":this._emit("textDone",t.text,rV(this,ec,"f"))}}rV(this,ec,"f")&&this._emit("messageDone",e.data),rU(this,ec,void 0,"f")}},eC=function(e){let t=rV(this,eo,"m",eS).call(this,e);switch(rU(this,ey,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let r=e.data.delta;if(r.step_details&&"tool_calls"==r.step_details.type&&r.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(let e of r.step_details.tool_calls)e.index==rV(this,eh,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(rV(this,em,"f")&&this._emit("toolCallDone",rV(this,em,"f")),rU(this,eh,e.index,"f"),rU(this,em,t.step_details.tool_calls[e.index],"f"),rV(this,em,"f")&&this._emit("toolCallCreated",rV(this,em,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":rU(this,ey,void 0,"f"),"tool_calls"==e.data.step_details.type&&rV(this,em,"f")&&(this._emit("toolCallDone",rV(this,em,"f")),rU(this,em,void 0,"f")),this._emit("runStepDone",e.data,t)}},ek=function(e){rV(this,es,"f").push(e),this._emit("event",e)},eS=function(e){switch(e.event){case"thread.run.step.created":return rV(this,el,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=rV(this,el,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let r=e.data;if(r.delta){let n=rG.accumulateDelta(t,r.delta);rV(this,el,"f")[e.data.id]=n}return rV(this,el,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":rV(this,el,"f")[e.data.id]=e.data}if(rV(this,el,"f")[e.data.id])return rV(this,el,"f")[e.data.id];throw Error("No snapshot available")},eP=function(e,t){let r=[];switch(e.event){case"thread.message.created":return[e.data,r];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let n=e.data;if(n.delta.content)for(let e of n.delta.content)if(e.index in t.content){let r=t.content[e.index];t.content[e.index]=rV(this,eo,"m",eE).call(this,e,r)}else t.content[e.index]=e,r.push(e);return[t,r];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,r];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},eE=function(e,t){return rG.accumulateDelta(t,e)},eA=function(e){switch(rU(this,ev,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":rU(this,ed,e.data,"f"),rV(this,em,"f")&&(this._emit("toolCallDone",rV(this,em,"f")),rU(this,em,void 0,"f"))}};class rZ extends t5{create(e,t,r){return this._client.post(`/threads/${e}/messages`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}retrieve(e,t,r){return this._client.get(`/threads/${e}/messages/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}update(e,t,r,n){return this._client.post(`/threads/${e}/messages/${t}`,{body:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},r){return tl(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/messages`,rH,{query:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}del(e,t,r){return this._client.delete(`/threads/${e}/messages/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}}class rH extends t2{}(rZ||(rZ={})).MessagesPage=rH;class rq extends t5{retrieve(e,t,r,n={},i){return tl(n)?this.retrieve(e,t,r,{},n):this._client.get(`/threads/${e}/runs/${t}/steps/${r}`,{query:n,...i,headers:{"OpenAI-Beta":"assistants=v2",...i?.headers}})}list(e,t,r={},n){return tl(r)?this.list(e,t,{},r):this._client.getAPIList(`/threads/${e}/runs/${t}/steps`,rJ,{query:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}}class rJ extends t2{}(rq||(rq={})).RunStepsPage=rJ;class rX extends t5{constructor(){super(...arguments),this.steps=new rq(this._client)}create(e,t,r){let{include:n,...i}=t;return this._client.post(`/threads/${e}/runs`,{query:{include:n},body:i,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers},stream:t.stream??!1})}retrieve(e,t,r){return this._client.get(`/threads/${e}/runs/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}update(e,t,r,n){return this._client.post(`/threads/${e}/runs/${t}`,{body:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},r){return tl(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/runs`,rY,{query:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}cancel(e,t,r){return this._client.post(`/threads/${e}/runs/${t}/cancel`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}async createAndPoll(e,t,r){let n=await this.create(e,t,r);return await this.poll(e,n.id,r)}createAndStream(e,t,r){return rG.createAssistantStream(e,this._client.beta.threads.runs,t,r)}async poll(e,t,r){let n={...r?.headers,"X-Stainless-Poll-Helper":"true"};for(r?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=r.pollIntervalMs.toString());;){let{data:i,response:a}=await this.retrieve(e,t,{...r,headers:{...r?.headers,...n}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let e=a.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(o=t)}}await tg(o);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(e,t,r){return rG.createAssistantStream(e,this._client.beta.threads.runs,t,r)}submitToolOutputs(e,t,r,n){return this._client.post(`/threads/${e}/runs/${t}/submit_tool_outputs`,{body:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers},stream:r.stream??!1})}async submitToolOutputsAndPoll(e,t,r,n){let i=await this.submitToolOutputs(e,t,r,n);return await this.poll(e,i.id,n)}submitToolOutputsStream(e,t,r,n){return rG.createToolAssistantStream(e,t,this._client.beta.threads.runs,r,n)}}class rY extends t2{}(y=rX||(rX={})).RunsPage=rY,y.Steps=rq,y.RunStepsPage=rJ;class rQ extends t5{constructor(){super(...arguments),this.runs=new rX(this._client),this.messages=new rZ(this._client)}create(e={},t){return tl(e)?this.create({},e):this._client.post("/threads",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,r){return this._client.post(`/threads/${e}`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}del(e,t){return this._client.delete(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers},stream:e.stream??!1})}async createAndRunPoll(e,t){let r=await this.createAndRun(e,t);return await this.runs.poll(r.thread_id,r.id,t)}createAndRunStream(e,t){return rG.createThreadAssistantStream(e,this._client.beta.threads,t)}}(b=rQ||(rQ={})).Runs=rX,b.RunsPage=rY,b.Messages=rZ,b.MessagesPage=rH;let r0=async e=>{let t=await Promise.allSettled(e),r=t.filter(e=>"rejected"===e.status);if(r.length){for(let e of r)console.error(e.reason);throw Error(`${r.length} promise(s) failed - see the above errors`)}let n=[];for(let e of t)"fulfilled"===e.status&&n.push(e.value);return n};class r1 extends t5{create(e,t,r){return this._client.post(`/vector_stores/${e}/files`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}retrieve(e,t,r){return this._client.get(`/vector_stores/${e}/files/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}list(e,t={},r){return tl(t)?this.list(e,{},t):this._client.getAPIList(`/vector_stores/${e}/files`,r4,{query:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}del(e,t,r){return this._client.delete(`/vector_stores/${e}/files/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}async createAndPoll(e,t,r){let n=await this.create(e,t,r);return await this.poll(e,n.id,r)}async poll(e,t,r){let n={...r?.headers,"X-Stainless-Poll-Helper":"true"};for(r?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=r.pollIntervalMs.toString());;){let i=await this.retrieve(e,t,{...r,headers:n}).withResponse(),a=i.data;switch(a.status){case"in_progress":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let e=i.response.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(o=t)}}await tg(o);break;case"failed":case"completed":return a}}}async upload(e,t,r){let n=await this._client.files.create({file:t,purpose:"assistants"},r);return this.create(e,{file_id:n.id},r)}async uploadAndPoll(e,t,r){let n=await this.upload(e,t,r);return await this.poll(e,n.id,r)}}class r4 extends t2{}(r1||(r1={})).VectorStoreFilesPage=r4;class r3 extends t5{create(e,t,r){return this._client.post(`/vector_stores/${e}/file_batches`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}retrieve(e,t,r){return this._client.get(`/vector_stores/${e}/file_batches/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}cancel(e,t,r){return this._client.post(`/vector_stores/${e}/file_batches/${t}/cancel`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}async createAndPoll(e,t,r){let n=await this.create(e,t);return await this.poll(e,n.id,r)}listFiles(e,t,r={},n){return tl(r)?this.listFiles(e,t,{},r):this._client.getAPIList(`/vector_stores/${e}/file_batches/${t}/files`,r4,{query:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}async poll(e,t,r){let n={...r?.headers,"X-Stainless-Poll-Helper":"true"};for(r?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=r.pollIntervalMs.toString());;){let{data:i,response:a}=await this.retrieve(e,t,{...r,headers:n}).withResponse();switch(i.status){case"in_progress":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let e=a.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(o=t)}}await tg(o);break;case"failed":case"cancelled":case"completed":return i}}}async uploadAndPoll(e,{files:t,fileIds:r=[]},n){if(null==t||0==t.length)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let i=Math.min(n?.maxConcurrency??5,t.length),a=this._client,o=t.values(),s=[...r];async function l(e){for(let t of e){let e=await a.files.create({file:t,purpose:"assistants"},n);s.push(e.id)}}let u=Array(i).fill(o).map(l);return await r0(u),await this.createAndPoll(e,{file_ids:s})}}r3||(r3={});class r2 extends t5{constructor(){super(...arguments),this.files=new r1(this._client),this.fileBatches=new r3(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,r){return this._client.post(`/vector_stores/${e}`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}list(e={},t){return tl(e)?this.list({},e):this._client.getAPIList("/vector_stores",r5,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}del(e,t){return this._client.delete(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}}class r5 extends t2{}(x=r2||(r2={})).VectorStoresPage=r5,x.Files=r1,x.VectorStoreFilesPage=r4,x.FileBatches=r3;class r6 extends t5{constructor(){super(...arguments),this.vectorStores=new r2(this._client),this.chat=new rW(this._client),this.assistants=new rg(this._client),this.threads=new rQ(this._client)}}(w=r6||(r6={})).VectorStores=r2,w.VectorStoresPage=r5,w.Chat=rW,w.Assistants=rg,w.AssistantsPage=rv,w.Threads=rQ;class r9 extends t5{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(`/batches/${e}`,t)}list(e={},t){return tl(e)?this.list({},e):this._client.getAPIList("/batches",r8,{query:e,...t})}cancel(e,t){return this._client.post(`/batches/${e}/cancel`,t)}}class r8 extends t2{}(r9||(r9={})).BatchesPage=r8;class r7 extends t5{create(e,t,r){return this._client.post(`/uploads/${e}/parts`,e4({body:t,...r}))}}r7||(r7={});class ne extends t5{constructor(){super(...arguments),this.parts=new r7(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(`/uploads/${e}/cancel`,t)}complete(e,t,r){return this._client.post(`/uploads/${e}/complete`,{body:t,...r})}}(ne||(ne={})).Parts=r7,r(9752);class nt extends tn{constructor({baseURL:e=tb("OPENAI_BASE_URL"),apiKey:t=tb("OPENAI_API_KEY"),organization:r=tb("OPENAI_ORG_ID")??null,project:n=tb("OPENAI_PROJECT_ID")??null,...i}={}){if(void 0===t)throw new t_("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");let a={apiKey:t,organization:r,project:n,...i,baseURL:e||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&tP())throw new t_("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");super({baseURL:a.baseURL,timeout:a.timeout??6e5,httpAgent:a.httpAgent,maxRetries:a.maxRetries,fetch:a.fetch}),this.completions=new t6(this),this.chat=new t8(this),this.embeddings=new t7(this),this.files=new re(this),this.images=new rr(this),this.audio=new ro(this),this.moderations=new rs(this),this.models=new rl(this),this.fineTuning=new rm(this),this.beta=new r6(this),this.batches=new r9(this),this.uploads=new ne(this),this._options=a,this.apiKey=t,this.organization=r,this.project=n}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders(e){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery(e){return function(e,t={}){let r,n=e,i=function(e=t1){let t;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw TypeError("Encoder has to be a function.");let r=e.charset||t1.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=tV;if(void 0!==e.format){if(!tq.call(tU,e.format))throw TypeError("Unknown format option provided.");n=e.format}let i=tU[n],a=t1.filter;if(("function"==typeof e.filter||tX(e.filter))&&(a=e.filter),t=e.arrayFormat&&e.arrayFormat in tJ?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":t1.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=void 0===e.allowDots?!0==!!e.encodeDotInKeys||t1.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:t1.addQueryPrefix,allowDots:o,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:t1.allowEmptyArrays,arrayFormat:t,charset:r,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:t1.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?t1.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:t1.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:t1.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:t1.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:t1.encodeValuesOnly,filter:a,format:n,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:t1.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:t1.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:t1.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):tX(i.filter)&&(r=i.filter);let a=[];if("object"!=typeof n||null===n)return"";let o=tJ[i.arrayFormat],s="comma"===o&&i.commaRoundTrip;r||(r=Object.keys(n)),i.sort&&r.sort(i.sort);let l=new WeakMap;for(let e=0;e0?C.join(",")||null:void 0}];else if(tX(c))w=c;else{let e=Object.keys(C);w=d?e.sort(d):e}let A=l?String(r).replace(/\./g,"%2E"):String(r),T=i&&tX(C)&&1===C.length?A+"[]":A;if(a&&tX(C)&&0===C.length)return T+"[]";for(let r=0;r0?c+u:""}(e,{arrayFormat:"brackets"})}}eT=nt,nt.OpenAI=eT,nt.DEFAULT_TIMEOUT=6e5,nt.OpenAIError=t_,nt.APIError=tD,nt.APIConnectionError=tM,nt.APIConnectionTimeoutError=tj,nt.APIUserAbortError=tB,nt.NotFoundError=tO,nt.ConflictError=t$,nt.RateLimitError=tL,nt.BadRequestError=tN,nt.AuthenticationError=tI,nt.InternalServerError=tz,nt.PermissionDeniedError=tR,nt.UnprocessableEntityError=tF,nt.toFile=eX,nt.fileFromPath=f;let{OpenAIError:nr,APIError:nn,APIConnectionError:ni,APIConnectionTimeoutError:na,APIUserAbortError:no,NotFoundError:ns,ConflictError:nl,RateLimitError:nu,BadRequestError:nc,AuthenticationError:nd,InternalServerError:np,PermissionDeniedError:nf,UnprocessableEntityError:nh}=eI;(C=nt||(nt={})).Page=t3,C.CursorPage=t2,C.Completions=t6,C.Chat=t8,C.Embeddings=t7,C.Files=re,C.FileObjectsPage=rt,C.Images=rr,C.Audio=ro,C.Moderations=rs,C.Models=rl,C.ModelsPage=ru,C.FineTuning=rm,C.Beta=r6,C.Batches=r9,C.BatchesPage=r8,C.Uploads=ne;var nm=r(7554);async function ng(e){return new Promise(t=>setTimeout(t,e))}async function nv(e,t,r,n){let i={currentTry:1,error:void 0,maxRetries:t};for(;i.currentTry<=i.maxRetries;){try{return await e()}catch(e){i.error=e,r&&await r(i)}i.currentTry++}n&&await n(i)}function ny(e,t){var r=Math.pow(10,t);return Math.round(e*r)/r}let nb={"gpt-3.5-turbo":{prompt:5e-4,completion:.0015},"gpt-3.5-turbo-1106":{prompt:.001,completion:.002},"gpt-4":{prompt:.03,completion:.06},"gpt-4-32k":{prompt:.06,completion:.12},"gpt-4-1106-preview":{prompt:.01,completion:.03},"gpt-4o":{prompt:.005,completion:.015000000000000001},"gpt-4o-mini":{prompt:15e-5,completion:6e-4}},nx={"gpt-3.5-turbo-0301":"gpt-3.5-turbo","gpt-3.5-turbo-0613":"gpt-3.5-turbo","gpt-3.5-turbo-16k":"gpt-3.5-turbo-1106","gpt-3.5-turbo-16k-0613":"gpt-3.5-turbo-1106","gpt-4-0613":"gpt-4","gpt-4o-2024-05-13":"gpt-4o","gpt-4o-mini-2024-07-18":"gpt-4o-mini"};function nw(e,t,r){return new nt({apiKey:e,baseURL:r,dangerouslyAllowBrowser:t,maxRetries:3})}class nC extends SyntaxError{constructor(e,t){super(e,t)}}async function nk(e,t,r){return await nv(e,t,async e=>{let t=e.error,n=1e3*e.currentTry*e.currentTry;if(t instanceof nt.APIError){if(nm.error(`[Error_${r}]`,new Date,"Status",t.status,t.name,t.message,t.error),429===t.status||t.status>=500&&t.status<=599)n*=e.currentTry;else throw`[Error_${r}] ${new Date} ${t.message}`;nm.error(`[Error_${r}]`,"Retries",e.currentTry,"Delay",n),await ng(n)}else if(t instanceof nC)nm.error(`[Error_${r}] ${t.message}`,"Retries",e.currentTry,"Delay",n),await ng(n);else throw`[Error_${r}] [openaiRetryWrapper] ${new Date} unknown error ${t}`},async e=>{throw nm.error(`[Error_${r}] [openaiRetryWrapper] Max Retries Reached`,new Date,e),`[Error_${r}] [openaiRetryWrapper] Max Retries Reached, Error: ${e.error?.message??e.error}`})}async function nS(e,t=e=>{},r=e=>{}){let n="";return await new Promise(async(i,a)=>{try{let a;for await(let r of e){let e=r.choices[0]?.delta?.content;e?(n+=e,t(e)):r.usage&&(a=r.usage)}r(a),i(n)}catch(e){a(new nC(`Could not JSON parse stream message: ${e.message}`,e))}})}class nP{constructor(e,t,r){this.limit=e,this.duration=t,this.description=r,this.baseDelay=1e3,this.requests=[]}cooldown(){let e=Date.now();return(this.requests=this.requests.filter(t=>e-t=this.limit)?this.requests[0]+this.duration-e:0}async cool(){let e=this.cooldown();return 0===e?(this.requests.push(Date.now()),!1):(nm.error("[Cooldown]",this.description,e,"ms"),await ng(e+this.baseDelay),this.requests.push(Date.now()),!0)}}class nE{seperator=",";timestampToSeconds(e){let[t,r]=e.split(","),n=parseInt(r),[i,a,o]=t.split(":").map(e=>parseInt(e));return Math.round(1e3*(.001*n+o+60*a+3600*i))/1e3}correctFormat(e){let t=e.replace(".",",");var r=null,n=null,i=null,a=null,[o,s]=t.split(",");a=this.fixed_str_digit(3,s);var[l,u,c]=o.split(":");return r=this.fixed_str_digit(2,l,!1),n=this.fixed_str_digit(2,u,!1),i=this.fixed_str_digit(2,c,!1),`${r}:${n}:${i},${a}`}fixed_str_digit(e,t,r=!0){return t.length==e?t:t.length>e?t.slice(0,e):t.length (\d{1,2}:\d{2}:\d{2},\d{1,3})/g);return t.shift(),t}tryDot(e){let t=(e=e.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g);return t.shift(),this.seperator=".",t}fromSrt(e){var t=this.tryComma(e);0==t.length&&(t=this.tryDot(e));for(var r=[],n=0;n ")+n.endTime+"\r\n"+n.text.replace("\n","\r\n")+"\r\n\r\n"}return t}}let nA=new nE;async function nT(e,t,r){return await nk(async()=>{await t.cooler?.cool();let n=(await t.openai.moderations.create({input:e,model:r})).results[0];return n.flagged&&nm.debug("[CheckModeration]","flagged",Object.keys(n.categories).filter(e=>n.categories[e]).map(e=>({catergory:e,value:Number(n.category_scores[e])}))),n},3,"CheckModeration")}class n_{constructor(e,t,r,n,i,a=""){this.content=e,this.promptTokens=t??0,this.completionTokens=r??0,this.cachedTokens=n,this.totalTokens=i??this.promptTokens+this.completionTokens,this.refusal=a}}let nD={createChatCompletionRequest:{model:"gpt-4o-mini"},moderationModel:"omni-moderation-latest",initialPrompts:[],useModerator:!0,prefixNumber:!0,lineMatching:!0,historyPromptLength:10,batchSizes:[10,100],structuredMode:!1,max_token:0,inputMultiplier:0,fallbackModel:void 0,logLevel:void 0};class nB{constructor(e,t,r){r.createChatCompletionRequest={...nD.createChatCompletionRequest,...r.createChatCompletionRequest},this.language=e,this.services=t,this.options={...nD,...r},this.systemInstruction=`Translate ${this.language.from?this.language.from+" ":""}to ${this.language.to}`,this.promptContext=[],this.workingProgress=[],this.promptTokensUsed=0,this.promptTokensWasted=0,this.cachedTokens=0,this.completionTokensUsed=0,this.completionTokensWasted=0,this.tokensProcessTimeMs=0,this.offset=0,this.end=void 0,this.workingBatchSizes=[...this.options.batchSizes],this.currentBatchSize=this.workingBatchSizes[this.workingBatchSizes.length-1],this.moderatorFlags=new Map,this.pricingModel=function(e){let t=nb[e];if(!t){let r=nx[e];r&&(t=nb[r])}return t}(this.options.createChatCompletionRequest.model),this.aborted=!1,r.logLevel&&nm.setLevel(r.logLevel)}getMaxToken(e){if(this.options.max_token&&!this.options.inputMultiplier)return this.options.max_token;if(this.options.max_token&&this.options.inputMultiplier){let t=JSON.stringify(e).length*this.options.inputMultiplier;return Math.min(this.options.max_token,t)}}async translatePrompt(e){let t=e.join("\n\n"),r={role:"user",content:`${t}`},n=[...this.systemInstruction?[{role:"system",content:`${this.systemInstruction}`}]:[],...this.options.initialPrompts,...this.promptContext,r],i=this.getMaxToken(e);function a(t){return 1===e.length?[t.split("\n").join(" ")]:t.split("\n").filter(e=>e.trim().length>0)}let o=0,s=0,l=this.options.createChatCompletionRequest.stream,u=await nk(async()=>{if(await this.services.cooler?.cool(),o=Date.now(),l){let e;let t=await this.services.openai.chat.completions.create({messages:n,...this.options.createChatCompletionRequest,stream:!0,stream_options:{include_usage:!0},max_tokens:i});this.streamController=t.controller;let r="",o=await nS(t,e=>{let t=e.includes("\n");0!==r.length||t?t?(r+=e,r=r.replaceAll("\n\n","\n")):(r+=e,this.services.onStreamChunk?.(r),r=""):this.services.onStreamChunk?.(e)},t=>{s=Date.now(),e=t,this.services.onStreamEnd?.()}),l=e?.prompt_tokens,u=e?.completion_tokens,c=e?.prompt_tokens_details?.cached_tokens;return new n_(a(o),l,u,c)}{let e=await this.services.openai.chat.completions.create({messages:n,...this.options.createChatCompletionRequest,stream:!1,max_tokens:i});return s=Date.now(),new n_(a(e.choices[0].message.content),e.usage?.prompt_tokens,e.usage?.completion_tokens,e.usage?.total_tokens)}},3,"TranslationPrompt");return this.promptTokensUsed+=u.promptTokens,this.completionTokensUsed+=u.completionTokens,this.cachedTokens+=u.cachedTokens,this.tokensProcessTimeMs+=s-o,u}async *translateSingle(e){nm.debug("[Translator]","Single line mode"),e=e.slice(-this.currentBatchSize);for(let t=0;tthis.preprocessLine(e,t,r));if(this.options.useModerator&&!this.services.moderationService&&nm.warn("[Translator]","Moderation service requested but not configured, no moderation applied"),this.options.useModerator&&this.services.moderationService){let e=t.join("\n\n");if((await nT(e,this.services.moderationService,this.options.moderationModel)).flagged){this.changeBatchSize("decrease")?r-=this.currentBatchSize:yield*this.translateSingle(t);continue}}this.buildContext();let i=await this.translatePrompt(t);if(this.aborted){nm.debug("[Translator]","Aborted");return}let a=i.content;if(this.options.lineMatching&&t.length!==a.length||t.length>1&&i.refusal?(this.promptTokensWasted+=i.promptTokens,this.completionTokensWasted+=i.completionTokens,i.refusal?nm.debug("[Translator]","Refusal: ",i.refusal):nm.debug("[Translator]","Lines count mismatch",t.length,a.length),nm.debug("[Translator]","batch",t),nm.debug("[Translator]","transformed",a),this.changeBatchSize("decrease")?r-=this.currentBatchSize:yield*this.translateSingle(t)):yield*this.yieldOutput(t,a),this.printUsage(),this.batchSizeThreshold&&n++>=this.batchSizeThreshold){n=0;let e=this.currentBatchSize;this.changeBatchSize("increase"),r-=this.currentBatchSize-e}}}*yieldOutput(e,t){for(let r=0;r ${s} `;else if(this.options.prefixNumber){let e=this.postprocessNumberPrefixedLine(s);s=e.text,l=e.text;let t=a+1;t!==e.number&&(nm.warn("[Translator]","Label mismatch",t,e.number),this.moderatorFlags.set(a,{remarks:"Label Mismatch",outIndex:e.number}),s=`[Flagged][Model] ${o} -> ${s}`)}else s=this.postprocessLine(s);this.workingProgress.push({source:n,transform:i});let u={index:this.workingProgress.length,source:o,transform:l,finalTransform:s};yield u}}preprocessLine(e,t,r){return e=e.replaceAll("\n"," \\N "),this.options.prefixNumber&&(e=`${r+t+1}. ${e}`),e}postprocessNumberPrefixedLine(e){let t=function(e){let t=e.match(/^(\d+\.)?\s*(.*)/);return{number:t[1]?parseInt(t[1]):void 0,text:t[2].trim()}}(e);return t.text=this.postprocessLine(t.text),t}postprocessLine(e){return e=(e=e.replaceAll(" \\N ","\n")).replaceAll("\\N","\n")}changeBatchSize(e){let t=this.currentBatchSize;if("decrease"===e){if(this.currentBatchSize===this.options.batchSizes[0])return!1;this.workingBatchSizes.unshift(this.workingBatchSizes.pop())}else if("increase"===e){if(this.currentBatchSize===this.options.batchSizes[this.options.batchSizes.length-1])return!1;this.workingBatchSizes.push(this.workingBatchSizes.shift())}return this.currentBatchSize=this.workingBatchSizes[this.workingBatchSizes.length-1],this.currentBatchSize===this.options.batchSizes[this.options.batchSizes.length-1]?this.batchSizeThreshold=void 0:this.batchSizeThreshold=Math.floor(Math.max(t,this.currentBatchSize)/Math.min(t,this.currentBatchSize)),nm.debug("[Translator]","BatchSize",e,t,"->",this.currentBatchSize,"SizeThreshold",this.batchSizeThreshold),!0}buildContext(){if(0===this.workingProgress.length||0===this.options.historyPromptLength)return;let e=this.workingProgress.slice(-this.options.historyPromptLength),t=this.workingProgress.length-this.options.historyPromptLength,r=(e,r)=>{let n=r+(t<0?0:t);return this.moderatorFlags.has(n)?this.preprocessLine("-",n,0):e},n=e.map((e,t)=>r(e.source,t)),i=e.map((e,t)=>r(e.transform,t));this.promptContext=this.getContext(n,i)}getContext(e,t){return[{role:"user",content:this.getContextLines(e,"user")},{role:"assistant",content:this.getContextLines(t,"assistant")}]}getContextLines(e,t){return e.join("\n\n")}get usage(){if(!this.pricingModel)return null;let e=this.promptTokensUsed+this.completionTokensUsed,t=this.promptTokensWasted+this.completionTokensWasted,r=ny(this.pricingModel.prompt*(this.promptTokensUsed/1e3)+this.pricingModel.completion*(this.completionTokensUsed/1e3),3),n=ny(this.pricingModel.prompt*(this.promptTokensWasted/1e3)+this.pricingModel.completion*(this.completionTokensWasted/1e3),3),i=ny(e/(this.tokensProcessTimeMs/1e3/60),2),a=(t/e).toLocaleString(void 0,{style:"percent",minimumFractionDigits:0});return{usedTokens:e,wastedTokens:t,usedTokensPricing:r,wastedTokensPricing:n,wastedPercent:a,cachedTokens:this.cachedTokens,rate:i}}async printUsage(){let e=this.usage;if(!e){nm.warn("[Translator]",`Cost computation not supported yet for ${this.options.createChatCompletionRequest.model}`);return}await ng(10);let{usedTokens:t,wastedTokens:r,usedTokensPricing:n,wastedTokensPricing:i,wastedPercent:a,cachedTokens:o,rate:s}=e;nm.debug("[Translator] Estimated Usage -","Tokens:",t,"$",n,"Wasted:",r,"$",i,a,"Cached:",o,"Rate:",s,"TPM",this.services.cooler?.rate,"RPM")}abort(){nm.warn("[Translator]","Aborting"),this.streamController?.abort(),this.aborted=!0}}(k=e_||(e_={})).assertEqual=e=>e,k.assertIs=function(e){},k.assertNever=function(e){throw Error()},k.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},k.getValidEnumValues=e=>{let t=k.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let n of t)r[n]=e[n];return k.objectValues(r)},k.objectValues=e=>k.objectKeys(e).map(function(t){return e[t]}),k.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},k.find=(e,t)=>{for(let r of e)if(t(r))return r},k.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,k.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},k.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(eD||(eD={})).mergeShapes=(e,t)=>({...e,...t});let nM=e_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),nj=e=>{switch(typeof e){case"undefined":return nM.undefined;case"string":return nM.string;case"number":return isNaN(e)?nM.nan:nM.number;case"boolean":return nM.boolean;case"function":return nM.function;case"bigint":return nM.bigint;case"symbol":return nM.symbol;case"object":if(Array.isArray(e))return nM.array;if(null===e)return nM.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return nM.promise;if("undefined"!=typeof Map&&e instanceof Map)return nM.map;if("undefined"!=typeof Set&&e instanceof Set)return nM.set;if("undefined"!=typeof Date&&e instanceof Date)return nM.date;return nM.object;default:return nM.unknown}},nN=e_.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class nI extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(n);else if("invalid_return_type"===i.code)n(i.returnTypeError);else if("invalid_arguments"===i.code)n(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,n=0;for(;ne.message){let t={},r=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}nI.create=e=>new nI(e);let nR=(e,t)=>{let r;switch(e.code){case nN.invalid_type:r=e.received===nM.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case nN.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,e_.jsonStringifyReplacer)}`;break;case nN.unrecognized_keys:r=`Unrecognized key(s) in object: ${e_.joinValues(e.keys,", ")}`;break;case nN.invalid_union:r="Invalid input";break;case nN.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${e_.joinValues(e.options)}`;break;case nN.invalid_enum_value:r=`Invalid enum value. Expected ${e_.joinValues(e.options)}, received '${e.received}'`;break;case nN.invalid_arguments:r="Invalid function arguments";break;case nN.invalid_return_type:r="Invalid function return type";break;case nN.invalid_date:r="Invalid date";break;case nN.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:e_.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case nN.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case nN.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case nN.custom:r="Invalid input";break;case nN.invalid_intersection_types:r="Intersection results could not be merged";break;case nN.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case nN.not_finite:r="Number must be finite";break;default:r=t.defaultError,e_.assertNever(e)}return{message:r}},nO=nR;function n$(){return nO}let nF=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],o={...i,path:a};if(void 0!==i.message)return{...i,path:a,message:i.message};let s="";for(let e of n.filter(e=>!!e).slice().reverse())s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function nL(e,t){let r=n$(),n=nF({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===nR?void 0:nR].filter(e=>!!e)});e.common.issues.push(n)}class nz{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if("aborted"===n.status)return nK;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return nz.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:t,value:i}=n;if("aborted"===t.status||"aborted"===i.status)return nK;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||n.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let nK=Object.freeze({status:"aborted"}),nW=e=>({status:"dirty",value:e}),nV=e=>({status:"valid",value:e}),nU=e=>"aborted"===e.status,nG=e=>"dirty"===e.status,nZ=e=>"valid"===e.status,nH=e=>"undefined"!=typeof Promise&&e instanceof Promise;function nq(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function nJ(e,t,r,n,i){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r}"function"==typeof SuppressedError&&SuppressedError,(S=eB||(eB={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},S.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;class nX{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let nY=(e,t)=>{if(nZ(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new nI(e.common.issues);return this._error=t,this._error}}};function nQ(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{var a,o;let{message:s}=e;return"invalid_enum_value"===t.code?{message:null!=s?s:i.defaultError}:void 0===i.data?{message:null!==(a=null!=s?s:n)&&void 0!==a?a:i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:null!==(o=null!=s?s:r)&&void 0!==o?o:i.defaultError}},description:i}}class n0{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return nj(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:nj(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nz,ctx:{common:e.parent.common,data:e.data,parsedType:nj(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(nH(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;let n={common:{issues:[],async:null!==(r=null==t?void 0:t.async)&&void 0!==r&&r,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:nj(e)},i=this._parseSync({data:e,path:n.path,parent:n});return nY(n,i)}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:nj(e)},n=this._parse({data:e,path:r.path,parent:r});return nY(r,await (nH(n)?n:Promise.resolve(n)))}refine(e,t){let r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,n)=>{let i=e(t),a=()=>n.addIssue({code:nN.custom,...r(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new iR({schema:this,typeName:eN.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return iO.create(this,this._def)}nullable(){return i$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ib.create(this,this._def)}promise(){return iI.create(this,this._def)}or(e){return iw.create([this,e],this._def)}and(e){return iS.create(this,e,this._def)}transform(e){return new iR({...nQ(this._def),schema:this,typeName:eN.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new iF({...nQ(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:eN.ZodDefault})}brand(){return new iW({typeName:eN.ZodBranded,type:this,...nQ(this._def)})}catch(e){return new iL({...nQ(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:eN.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return iV.create(this,e)}readonly(){return iU.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let n1=/^c[^\s-]{8,}$/i,n4=/^[0-9a-z]+$/,n3=/^[0-9A-HJKMNP-TV-Z]{26}$/,n2=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,n5=/^[a-z0-9_-]{21}$/i,n6=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,n9=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,n8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,n7=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ie=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,it="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ir=RegExp(`^${it}$`);function ii(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function ia(e){let t=`${it}T${ii(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class io extends n0{_parse(e){var t,r;let n;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==nM.string){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.string,received:t.parsedType}),nK}let a=new nz;for(let o of this._def.checks)if("min"===o.kind)e.data.lengtho.value&&(nL(n=this._getOrReturnCtx(e,n),{code:nN.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),a.dirty());else if("length"===o.kind){let t=e.data.length>o.value,r=e.data.lengthe.test(t),{validation:t,code:nN.invalid_string,...eB.errToObj(r)})}_addCheck(e){return new io({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...eB.errToObj(e)})}url(e){return this._addCheck({kind:"url",...eB.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...eB.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...eB.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...eB.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...eB.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...eB.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...eB.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...eB.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...eB.errToObj(e)})}datetime(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(r=null==e?void 0:e.local)&&void 0!==r&&r,...eB.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...eB.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...eB.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...eB.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...eB.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...eB.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...eB.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...eB.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...eB.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...eB.errToObj(t)})}nonempty(e){return this.min(1,eB.errToObj(e))}trim(){return new io({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new io({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new io({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value{var t;return new io({checks:[],typeName:eN.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...nQ(e)})};class is extends n0{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==nM.number){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.number,received:t.parsedType}),nK}let r=new nz;for(let n of this._def.checks)"int"===n.kind?e_.isInteger(e.data)||(nL(t=this._getOrReturnCtx(e,t),{code:nN.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.datan.value:e.data>=n.value)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n;return parseInt(e.toFixed(i).replace(".",""))%parseInt(t.toFixed(i).replace(".",""))/Math.pow(10,i)}(e.data,n.value)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(nL(t=this._getOrReturnCtx(e,t),{code:nN.not_finite,message:n.message}),r.dirty()):e_.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,eB.toString(t))}gt(e,t){return this.setLimit("min",e,!1,eB.toString(t))}lte(e,t){return this.setLimit("max",e,!0,eB.toString(t))}lt(e,t){return this.setLimit("max",e,!1,eB.toString(t))}setLimit(e,t,r,n){return new is({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:eB.toString(n)}]})}_addCheck(e){return new is({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:eB.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:eB.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:eB.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:eB.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:eB.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:eB.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:eB.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:eB.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:eB.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value"int"===e.kind||"multipleOf"===e.kind&&e_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.valuenew is({checks:[],typeName:eN.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...nQ(e)});class il extends n0{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==nM.bigint){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.bigint,received:t.parsedType}),nK}let r=new nz;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.datan.value:e.data>=n.value)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):e_.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,eB.toString(t))}gt(e,t){return this.setLimit("min",e,!1,eB.toString(t))}lte(e,t){return this.setLimit("max",e,!0,eB.toString(t))}lt(e,t){return this.setLimit("max",e,!1,eB.toString(t))}setLimit(e,t,r,n){return new il({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:eB.toString(n)}]})}_addCheck(e){return new il({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:eB.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:eB.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:eB.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:eB.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:eB.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value{var t;return new il({checks:[],typeName:eN.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...nQ(e)})};class iu extends n0{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==nM.boolean){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.boolean,received:t.parsedType}),nK}return nV(e.data)}}iu.create=e=>new iu({typeName:eN.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...nQ(e)});class ic extends n0{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==nM.date){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.date,received:t.parsedType}),nK}if(isNaN(e.data.getTime()))return nL(this._getOrReturnCtx(e),{code:nN.invalid_date}),nK;let r=new nz;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()n.value&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):e_.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ic({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:eB.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:eB.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.valuenew ic({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:eN.ZodDate,...nQ(e)});class id extends n0{_parse(e){if(this._getType(e)!==nM.symbol){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.symbol,received:t.parsedType}),nK}return nV(e.data)}}id.create=e=>new id({typeName:eN.ZodSymbol,...nQ(e)});class ip extends n0{_parse(e){if(this._getType(e)!==nM.undefined){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.undefined,received:t.parsedType}),nK}return nV(e.data)}}ip.create=e=>new ip({typeName:eN.ZodUndefined,...nQ(e)});class ih extends n0{_parse(e){if(this._getType(e)!==nM.null){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.null,received:t.parsedType}),nK}return nV(e.data)}}ih.create=e=>new ih({typeName:eN.ZodNull,...nQ(e)});class im extends n0{constructor(){super(...arguments),this._any=!0}_parse(e){return nV(e.data)}}im.create=e=>new im({typeName:eN.ZodAny,...nQ(e)});class ig extends n0{constructor(){super(...arguments),this._unknown=!0}_parse(e){return nV(e.data)}}ig.create=e=>new ig({typeName:eN.ZodUnknown,...nQ(e)});class iv extends n0{_parse(e){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.never,received:t.parsedType}),nK}}iv.create=e=>new iv({typeName:eN.ZodNever,...nQ(e)});class iy extends n0{_parse(e){if(this._getType(e)!==nM.undefined){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.void,received:t.parsedType}),nK}return nV(e.data)}}iy.create=e=>new iy({typeName:eN.ZodVoid,...nQ(e)});class ib extends n0{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==nM.array)return nL(t,{code:nN.invalid_type,expected:nM.array,received:t.parsedType}),nK;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,i=t.data.lengthn.maxLength.value&&(nL(t,{code:nN.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new nX(t,e,t.path,r)))).then(e=>nz.mergeArray(r,e));let i=[...t.data].map((e,r)=>n.type._parseSync(new nX(t,e,t.path,r)));return nz.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new ib({...this._def,minLength:{value:e,message:eB.toString(t)}})}max(e,t){return new ib({...this._def,maxLength:{value:e,message:eB.toString(t)}})}length(e,t){return new ib({...this._def,exactLength:{value:e,message:eB.toString(t)}})}nonempty(e){return this.min(1,e)}}ib.create=(e,t)=>new ib({type:e,minLength:null,maxLength:null,exactLength:null,typeName:eN.ZodArray,...nQ(t)});class ix extends n0{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=e_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==nM.object){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.object,received:t.parsedType}),nK}let{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof iv&&"strip"===this._def.unknownKeys))for(let e in r.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=n[e],i=r.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new nX(r,i,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof iv){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(nL(r,{code:nN.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let n=r.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new nX(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>nz.mergeObjectSync(t,e)):nz.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return eB.errToObj,new ix({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{var n,i,a,o;let s=null!==(a=null===(i=(n=this._def).errorMap)||void 0===i?void 0:i.call(n,t,r).message)&&void 0!==a?a:r.defaultError;return"unrecognized_keys"===t.code?{message:null!==(o=eB.errToObj(e).message)&&void 0!==o?o:s}:{message:s}}}:{}})}strip(){return new ix({...this._def,unknownKeys:"strip"})}passthrough(){return new ix({...this._def,unknownKeys:"passthrough"})}extend(e){return new ix({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ix({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:eN.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ix({...this._def,catchall:e})}pick(e){let t={};return e_.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new ix({...this._def,shape:()=>t})}omit(e){let t={};return e_.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new ix({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ix){let r={};for(let n in t.shape){let i=t.shape[n];r[n]=iO.create(e(i))}return new ix({...t._def,shape:()=>r})}return t instanceof ib?new ib({...t._def,type:e(t.element)}):t instanceof iO?iO.create(e(t.unwrap())):t instanceof i$?i$.create(e(t.unwrap())):t instanceof iP?iP.create(t.items.map(t=>e(t))):t}(this)}partial(e){let t={};return e_.objectKeys(this.shape).forEach(r=>{let n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}),new ix({...this._def,shape:()=>t})}required(e){let t={};return e_.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof iO;)e=e._def.innerType;t[r]=e}}),new ix({...this._def,shape:()=>t})}keyof(){return iM(e_.objectKeys(this.shape))}}ix.create=(e,t)=>new ix({shape:()=>e,unknownKeys:"strip",catchall:iv.create(),typeName:eN.ZodObject,...nQ(t)}),ix.strictCreate=(e,t)=>new ix({shape:()=>e,unknownKeys:"strict",catchall:iv.create(),typeName:eN.ZodObject,...nQ(t)}),ix.lazycreate=(e,t)=>new ix({shape:e,unknownKeys:"strip",catchall:iv.create(),typeName:eN.ZodObject,...nQ(t)});class iw extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new nI(e.ctx.common.issues));return nL(t,{code:nN.invalid_union,unionErrors:r}),nK});{let e;let n=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=n.map(e=>new nI(e));return nL(t,{code:nN.invalid_union,unionErrors:i}),nK}}get options(){return this._def.options}}iw.create=(e,t)=>new iw({options:e,typeName:eN.ZodUnion,...nQ(t)});let iC=e=>{if(e instanceof iD)return iC(e.schema);if(e instanceof iR)return iC(e.innerType());if(e instanceof iB)return[e.value];if(e instanceof ij)return e.options;if(e instanceof iN)return e_.objectValues(e.enum);if(e instanceof iF)return iC(e._def.innerType);if(e instanceof ip)return[void 0];else if(e instanceof ih)return[null];else if(e instanceof iO)return[void 0,...iC(e.unwrap())];else if(e instanceof i$)return[null,...iC(e.unwrap())];else if(e instanceof iW)return iC(e.unwrap());else if(e instanceof iU)return iC(e.unwrap());else if(e instanceof iL)return iC(e._def.innerType);else return[]};class ik extends n0{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==nM.object)return nL(t,{code:nN.invalid_type,expected:nM.object,received:t.parsedType}),nK;let r=this.discriminator,n=t.data[r],i=this.optionsMap.get(n);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(nL(t,{code:nN.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),nK)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let r of t){let t=iC(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,r)}}return new ik({typeName:eN.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...nQ(r)})}}class iS extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(nU(e)||nU(n))return nK;let i=function e(t,r){let n=nj(t),i=nj(r);if(t===r)return{valid:!0,data:t};if(n===nM.object&&i===nM.object){let n=e_.objectKeys(r),i=e_.objectKeys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...r};for(let n of i){let i=e(t[n],r[n]);if(!i.valid)return{valid:!1};a[n]=i.data}return{valid:!0,data:a}}if(n===nM.array&&i===nM.array){if(t.length!==r.length)return{valid:!1};let n=[];for(let i=0;in(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}iS.create=(e,t,r)=>new iS({left:e,right:t,typeName:eN.ZodIntersection,...nQ(r)});class iP extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.array)return nL(r,{code:nN.invalid_type,expected:nM.array,received:r.parsedType}),nK;if(r.data.lengththis._def.items.length&&(nL(r,{code:nN.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new nX(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>nz.mergeArray(t,e)):nz.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new iP({...this._def,rest:e})}}iP.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new iP({items:e,typeName:eN.ZodTuple,rest:null,...nQ(t)})};class iE extends n0{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.object)return nL(r,{code:nN.invalid_type,expected:nM.object,received:r.parsedType}),nK;let n=[],i=this._def.keyType,a=this._def.valueType;for(let e in r.data)n.push({key:i._parse(new nX(r,e,r.path,e)),value:a._parse(new nX(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?nz.mergeObjectAsync(t,n):nz.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return new iE(t instanceof n0?{keyType:e,valueType:t,typeName:eN.ZodRecord,...nQ(r)}:{keyType:io.create(),valueType:e,typeName:eN.ZodRecord,...nQ(t)})}}class iA extends n0{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.map)return nL(r,{code:nN.invalid_type,expected:nM.map,received:r.parsedType}),nK;let n=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new nX(r,e,r.path,[a,"key"])),value:i._parse(new nX(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let n=await r.key,i=await r.value;if("aborted"===n.status||"aborted"===i.status)return nK;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of a){let n=r.key,i=r.value;if("aborted"===n.status||"aborted"===i.status)return nK;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}}}}iA.create=(e,t,r)=>new iA({valueType:t,keyType:e,typeName:eN.ZodMap,...nQ(r)});class iT extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.set)return nL(r,{code:nN.invalid_type,expected:nM.set,received:r.parsedType}),nK;let n=this._def;null!==n.minSize&&r.data.sizen.maxSize.value&&(nL(r,{code:nN.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let r=new Set;for(let n of e){if("aborted"===n.status)return nK;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}let o=[...r.data.values()].map((e,t)=>i._parse(new nX(r,e,r.path,t)));return r.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new iT({...this._def,minSize:{value:e,message:eB.toString(t)}})}max(e,t){return new iT({...this._def,maxSize:{value:e,message:eB.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}iT.create=(e,t)=>new iT({valueType:e,minSize:null,maxSize:null,typeName:eN.ZodSet,...nQ(t)});class i_ extends n0{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==nM.function)return nL(t,{code:nN.invalid_type,expected:nM.function,received:t.parsedType}),nK;function r(e,r){return nF({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n$(),nR].filter(e=>!!e),issueData:{code:nN.invalid_arguments,argumentsError:r}})}function n(e,r){return nF({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n$(),nR].filter(e=>!!e),issueData:{code:nN.invalid_return_type,returnTypeError:r}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof iI){let e=this;return nV(async function(...t){let o=new nI([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(r(t,e)),o}),l=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(l,i).catch(e=>{throw o.addIssue(n(l,e)),o})})}{let e=this;return nV(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new nI([r(t,o.error)]);let s=Reflect.apply(a,this,o.data),l=e._def.returns.safeParse(s,i);if(!l.success)throw new nI([n(s,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new i_({...this._def,args:iP.create(e).rest(ig.create())})}returns(e){return new i_({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new i_({args:e||iP.create([]).rest(ig.create()),returns:t||ig.create(),typeName:eN.ZodFunction,...nQ(r)})}}class iD extends n0{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}iD.create=(e,t)=>new iD({getter:e,typeName:eN.ZodLazy,...nQ(t)});class iB extends n0{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return nL(t,{received:t.data,code:nN.invalid_literal,expected:this._def.value}),nK}return{status:"valid",value:e.data}}get value(){return this._def.value}}function iM(e,t){return new ij({values:e,typeName:eN.ZodEnum,...nQ(t)})}iB.create=(e,t)=>new iB({value:e,typeName:eN.ZodLiteral,...nQ(t)});class ij extends n0{constructor(){super(...arguments),eM.set(this,void 0)}_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return nL(t,{expected:e_.joinValues(r),received:t.parsedType,code:nN.invalid_type}),nK}if(nq(this,eM,"f")||nJ(this,eM,new Set(this._def.values),"f"),!nq(this,eM,"f").has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return nL(t,{received:t.data,code:nN.invalid_enum_value,options:r}),nK}return nV(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ij.create(e,{...this._def,...t})}exclude(e,t=this._def){return ij.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eM=new WeakMap,ij.create=iM;class iN extends n0{constructor(){super(...arguments),ej.set(this,void 0)}_parse(e){let t=e_.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==nM.string&&r.parsedType!==nM.number){let e=e_.objectValues(t);return nL(r,{expected:e_.joinValues(e),received:r.parsedType,code:nN.invalid_type}),nK}if(nq(this,ej,"f")||nJ(this,ej,new Set(e_.getValidEnumValues(this._def.values)),"f"),!nq(this,ej,"f").has(e.data)){let e=e_.objectValues(t);return nL(r,{received:r.data,code:nN.invalid_enum_value,options:e}),nK}return nV(e.data)}get enum(){return this._def.values}}ej=new WeakMap,iN.create=(e,t)=>new iN({values:e,typeName:eN.ZodNativeEnum,...nQ(t)});class iI extends n0{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==nM.promise&&!1===t.common.async?(nL(t,{code:nN.invalid_type,expected:nM.promise,received:t.parsedType}),nK):nV((t.parsedType===nM.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}iI.create=(e,t)=>new iI({type:e,typeName:eN.ZodPromise,...nQ(t)});class iR extends n0{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===eN.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:e=>{nL(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===n.type){let e=n.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return nK;let n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?nK:"dirty"===n.status||"dirty"===t.value?nW(n.value):n});{if("aborted"===t.value)return nK;let n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?nK:"dirty"===n.status||"dirty"===t.value?nW(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?nK:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?nK:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}}if("transform"===n.type){if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>nZ(e)?Promise.resolve(n.transform(e.value,i)).then(e=>({status:t.value,value:e})):e);{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!nZ(e))return e;let a=n.transform(e.value,i);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}}e_.assertNever(n)}}iR.create=(e,t,r)=>new iR({schema:e,typeName:eN.ZodEffects,effect:t,...nQ(r)}),iR.createWithPreprocess=(e,t,r)=>new iR({schema:t,effect:{type:"preprocess",transform:e},typeName:eN.ZodEffects,...nQ(r)});class iO extends n0{_parse(e){return this._getType(e)===nM.undefined?nV(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}iO.create=(e,t)=>new iO({innerType:e,typeName:eN.ZodOptional,...nQ(t)});class i$ extends n0{_parse(e){return this._getType(e)===nM.null?nV(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}i$.create=(e,t)=>new i$({innerType:e,typeName:eN.ZodNullable,...nQ(t)});class iF extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===nM.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}iF.create=(e,t)=>new iF({innerType:e,typeName:eN.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...nQ(t)});class iL extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return nH(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new nI(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new nI(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}iL.create=(e,t)=>new iL({innerType:e,typeName:eN.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...nQ(t)});class iz extends n0{_parse(e){if(this._getType(e)!==nM.nan){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.nan,received:t.parsedType}),nK}return{status:"valid",value:e.data}}}iz.create=e=>new iz({typeName:eN.ZodNaN,...nQ(e)});let iK=Symbol("zod_brand");class iW extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class iV extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?nK:"dirty"===e.status?(t.dirty(),nW(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?nK:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new iV({in:e,out:t,typeName:eN.ZodPipeline})}}class iU extends n0{_parse(e){let t=this._def.innerType._parse(e),r=e=>(nZ(e)&&(e.value=Object.freeze(e.value)),e);return nH(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}function iG(e,t={},r){return e?im.create().superRefine((n,i)=>{var a,o;if(!e(n)){let e="function"==typeof t?t(n):"string"==typeof t?{message:t}:t,s=null===(o=null!==(a=e.fatal)&&void 0!==a?a:r)||void 0===o||o;i.addIssue({code:"custom",..."string"==typeof e?{message:e}:e,fatal:s})}}):im.create()}iU.create=(e,t)=>new iU({innerType:e,typeName:eN.ZodReadonly,...nQ(t)});let iZ={object:ix.lazycreate};(P=eN||(eN={})).ZodString="ZodString",P.ZodNumber="ZodNumber",P.ZodNaN="ZodNaN",P.ZodBigInt="ZodBigInt",P.ZodBoolean="ZodBoolean",P.ZodDate="ZodDate",P.ZodSymbol="ZodSymbol",P.ZodUndefined="ZodUndefined",P.ZodNull="ZodNull",P.ZodAny="ZodAny",P.ZodUnknown="ZodUnknown",P.ZodNever="ZodNever",P.ZodVoid="ZodVoid",P.ZodArray="ZodArray",P.ZodObject="ZodObject",P.ZodUnion="ZodUnion",P.ZodDiscriminatedUnion="ZodDiscriminatedUnion",P.ZodIntersection="ZodIntersection",P.ZodTuple="ZodTuple",P.ZodRecord="ZodRecord",P.ZodMap="ZodMap",P.ZodSet="ZodSet",P.ZodFunction="ZodFunction",P.ZodLazy="ZodLazy",P.ZodLiteral="ZodLiteral",P.ZodEnum="ZodEnum",P.ZodEffects="ZodEffects",P.ZodNativeEnum="ZodNativeEnum",P.ZodOptional="ZodOptional",P.ZodNullable="ZodNullable",P.ZodDefault="ZodDefault",P.ZodCatch="ZodCatch",P.ZodPromise="ZodPromise",P.ZodBranded="ZodBranded",P.ZodPipeline="ZodPipeline",P.ZodReadonly="ZodReadonly";let iH=io.create,iq=is.create,iJ=iz.create,iX=il.create,iY=iu.create,iQ=ic.create,i0=id.create,i1=ip.create,i4=ih.create,i3=im.create,i2=ig.create,i5=iv.create,i6=iy.create,i9=ib.create,i8=ix.create,i7=ix.strictCreate,ae=iw.create,at=ik.create,ar=iS.create,an=iP.create,ai=iE.create,aa=iA.create,ao=iT.create,as=i_.create,al=iD.create,au=iB.create,ac=ij.create,ad=iN.create,ap=iI.create,af=iR.create,ah=iO.create,am=i$.create,ag=iR.createWithPreprocess,av=iV.create;var ay=Object.freeze({__proto__:null,defaultErrorMap:nR,setErrorMap:function(e){nO=e},getErrorMap:n$,makeIssue:nF,EMPTY_PATH:[],addIssueToContext:nL,ParseStatus:nz,INVALID:nK,DIRTY:nW,OK:nV,isAborted:nU,isDirty:nG,isValid:nZ,isAsync:nH,get util(){return e_},get objectUtil(){return eD},ZodParsedType:nM,getParsedType:nj,ZodType:n0,datetimeRegex:ia,ZodString:io,ZodNumber:is,ZodBigInt:il,ZodBoolean:iu,ZodDate:ic,ZodSymbol:id,ZodUndefined:ip,ZodNull:ih,ZodAny:im,ZodUnknown:ig,ZodNever:iv,ZodVoid:iy,ZodArray:ib,ZodObject:ix,ZodUnion:iw,ZodDiscriminatedUnion:ik,ZodIntersection:iS,ZodTuple:iP,ZodRecord:iE,ZodMap:iA,ZodSet:iT,ZodFunction:i_,ZodLazy:iD,ZodLiteral:iB,ZodEnum:ij,ZodNativeEnum:iN,ZodPromise:iI,ZodEffects:iR,ZodTransformer:iR,ZodOptional:iO,ZodNullable:i$,ZodDefault:iF,ZodCatch:iL,ZodNaN:iz,BRAND:iK,ZodBranded:iW,ZodPipeline:iV,ZodReadonly:iU,custom:iG,Schema:n0,ZodSchema:n0,late:iZ,get ZodFirstPartyTypeKind(){return eN},coerce:{string:e=>io.create({...e,coerce:!0}),number:e=>is.create({...e,coerce:!0}),boolean:e=>iu.create({...e,coerce:!0}),bigint:e=>il.create({...e,coerce:!0}),date:e=>ic.create({...e,coerce:!0})},any:i3,array:i9,bigint:iX,boolean:iY,date:iQ,discriminatedUnion:at,effect:af,enum:ac,function:as,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>iG(t=>t instanceof e,t),intersection:ar,lazy:al,literal:au,map:aa,nan:iJ,nativeEnum:ad,never:i5,null:i4,nullable:am,number:iq,object:i8,oboolean:()=>iY().optional(),onumber:()=>iq().optional(),optional:ah,ostring:()=>iH().optional(),pipeline:av,preprocess:ag,promise:ap,record:ai,set:ao,strictObject:i7,string:iH,symbol:i0,transformer:af,tuple:an,undefined:i1,union:ae,unknown:i2,void:i6,NEVER:nK,ZodIssueCode:nN,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:nI});function ab(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function ax(e,t,r,n,i){e[t]=r,ab(e,t,n,i)}let aw=(e,t)=>aF(e.innerType._def,t),aC=(e,t)=>{let r={type:"integer",format:"unix-time"};if("openApi3"===t.target)return r;for(let n of e.checks)switch(n.kind){case"min":ax(r,"minimum",n.value,n.message,t);break;case"max":ax(r,"maximum",n.value,n.message,t)}return r},ak=e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e,aS={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===a&&(a=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),a),base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function aP(e,t){let r={type:"string"};function n(e){return"escape"===t.patternStrategy?aE(e):e}if(e.checks)for(let i of e.checks)switch(i.kind){case"min":ax(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":ax(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":aA(r,"email",i.message,t);break;case"format:idn-email":aA(r,"idn-email",i.message,t);break;case"pattern:zod":aT(r,aS.email,i.message,t)}break;case"url":aA(r,"uri",i.message,t);break;case"uuid":aA(r,"uuid",i.message,t);break;case"regex":aT(r,i.regex,i.message,t);break;case"cuid":aT(r,aS.cuid,i.message,t);break;case"cuid2":aT(r,aS.cuid2,i.message,t);break;case"startsWith":aT(r,RegExp(`^${n(i.value)}`),i.message,t);break;case"endsWith":aT(r,RegExp(`${n(i.value)}$`),i.message,t);break;case"datetime":aA(r,"date-time",i.message,t);break;case"date":aA(r,"date",i.message,t);break;case"time":aA(r,"time",i.message,t);break;case"duration":aA(r,"duration",i.message,t);break;case"length":ax(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t),ax(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":aT(r,RegExp(n(i.value)),i.message,t);break;case"ip":"v6"!==i.version&&aA(r,"ipv4",i.message,t),"v4"!==i.version&&aA(r,"ipv6",i.message,t);break;case"emoji":aT(r,aS.emoji,i.message,t);break;case"ulid":aT(r,aS.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":aA(r,"binary",i.message,t);break;case"contentEncoding:base64":ax(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":aT(r,aS.base64,i.message,t)}break;case"nanoid":aT(r,aS.nanoid,i.message,t)}return r}let aE=e=>Array.from(e).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),aA=(e,t,r,n)=>{e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ax(e,"format",t,r,n)},aT=(e,t,r,n)=>{e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:a_(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ax(e,"pattern",a_(t,n),r,n)},a_=(e,t)=>{let r="function"==typeof e?e():e;if(!t.applyRegexFlags||!r.flags)return r.source;let n={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},i=n.i?r.source.toLowerCase():r.source,a="",o=!1,s=!1,l=!1;for(let e=0;e({...e,message:{...e.message,parsed:null,tool_calls:e.message.tool_calls??[]}}))}}(e,r$(this,q,"f"))},ei=function(){let e=r$(this,q,"f")?.response_format;return rP(e)?e:null},ea=function(e){var t,r,n,i;let a=r$(this,X,"f"),{choices:o,...s}=e;for(let{delta:o,finish_reason:l,index:u,logprobs:c=null,...d}of(a?Object.assign(a,s):a=rO(this,X,{...s,choices:[]},"f"),e.choices)){let e=a.choices[u];if(e||(e=a.choices[u]={finish_reason:l,index:u,message:{},logprobs:c,...d}),c){if(e.logprobs){let{content:n,refusal:i,...a}=c;Object.assign(e.logprobs,a),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),i&&((r=e.logprobs).refusal??(r.refusal=[]),e.logprobs.refusal.push(...i))}else e.logprobs=Object.assign({},c)}if(l&&(e.finish_reason=l,r$(this,q,"f")&&rT(r$(this,q,"f")))){if("length"===l)throw new tK;if("content_filter"===l)throw new tW}if(Object.assign(e,d),!o)continue;let{content:s,refusal:p,function_call:f,role:h,tool_calls:m,...g}=o;if(Object.assign(e.message,g),p&&(e.message.refusal=(e.message.refusal||"")+p),h&&(e.message.role=h),f&&(e.message.function_call?(f.name&&(e.message.function_call.name=f.name),f.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=f.arguments)):e.message.function_call=f),s&&(e.message.content=(e.message.content||"")+s,!e.message.refusal&&r$(this,H,"m",ei).call(this)&&(e.message.parsed=rR(e.message.content))),m)for(let{index:t,id:r,type:n,function:a,...o}of(e.message.tool_calls||(e.message.tool_calls=[]),m)){let s=(i=e.message.tool_calls)[t]??(i[t]={});Object.assign(s,o),r&&(s.id=r),n&&(s.type=n),a&&(s.function??(s.function={name:a.name??"",arguments:""})),a?.name&&(s.function.name=a.name),a?.arguments&&(s.function.arguments+=a.arguments,function(e,t){if(!e)return!1;let r=e.tools?.find(e=>e.function?.name===t.function.name);return rE(r)||r?.function.strict||!1}(r$(this,q,"f"),s)&&(s.function.parsed_arguments=rR(s.function.arguments)))}}return a},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("chunk",r=>{let n=t.shift();n?n.resolve(r):e.push(r)}),this.on("end",()=>{for(let e of(r=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((e,r)=>t.push({resolve:e,reject:r})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new ez(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function rL(e){return JSON.stringify(e)}class rz extends rF{static fromReadableStream(e){let t=new rz(null);return t._run(()=>t._fromReadableStream(e)),t}static runFunctions(e,t,r){let n=new rz(null),i={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return n._run(()=>n._runFunctions(e,t,i)),n}static runTools(e,t,r){let n=new rz(t),i={...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run(()=>n._runTools(e,t,i)),n}}class rK extends t5{parse(e,t){return!function(e){for(let t of e??[]){if("function"!==t.type)throw new t_(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new t_(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap(t=>rA(t,e))}runFunctions(e,t){return e.stream?rz.runFunctions(this._client,e,t):rB.runFunctions(this._client,e,t)}runTools(e,t){return e.stream?rz.runTools(this._client,e,t):rB.runTools(this._client,e,t)}stream(e,t){return rF.createChatCompletion(this._client,e,t)}}class rW extends t5{constructor(){super(...arguments),this.completions=new rK(this._client)}}(rW||(rW={})).Completions=rK;var rV=function(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},rU=function(e,t,r,n,i){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r};class rG extends rS{constructor(){super(...arguments),eo.add(this),es.set(this,[]),el.set(this,{}),eu.set(this,{}),ec.set(this,void 0),ed.set(this,void 0),ep.set(this,void 0),ef.set(this,void 0),eh.set(this,void 0),em.set(this,void 0),eg.set(this,void 0),ev.set(this,void 0),ey.set(this,void 0)}[(es=new WeakMap,el=new WeakMap,eu=new WeakMap,ec=new WeakMap,ed=new WeakMap,ep=new WeakMap,ef=new WeakMap,eh=new WeakMap,em=new WeakMap,eg=new WeakMap,ev=new WeakMap,ey=new WeakMap,eo=new WeakSet,Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("event",r=>{let n=t.shift();n?n.resolve(r):e.push(r)}),this.on("end",()=>{for(let e of(r=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),this.on("error",e=>{for(let n of(r=!0,t))n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((e,r)=>t.push({resolve:e,reject:r})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){let t=new rG;return t._run(()=>t._fromReadableStream(e)),t}async _fromReadableStream(e,t){let r=t?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),this._connected();let n=ez.fromReadableStream(e,this.controller);for await(let e of n)rV(this,eo,"m",eb).call(this,e);if(n.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}toReadableStream(){return new ez(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,r,n,i){let a=new rG;return a._run(()=>a._runToolAssistantStream(e,t,r,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}})),a}async _createToolAssistantStream(e,t,r,n,i){let a=i?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener("abort",()=>this.controller.abort()));let o={...n,stream:!0},s=await e.submitToolOutputs(t,r,o,{...i,signal:this.controller.signal});for await(let e of(this._connected(),s))rV(this,eo,"m",eb).call(this,e);if(s.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}static createThreadAssistantStream(e,t,r){let n=new rG;return n._run(()=>n._threadAssistantStream(e,t,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}static createAssistantStream(e,t,r,n){let i=new rG;return i._run(()=>i._runAssistantStream(e,t,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),i}currentEvent(){return rV(this,eg,"f")}currentRun(){return rV(this,ev,"f")}currentMessageSnapshot(){return rV(this,ec,"f")}currentRunStepSnapshot(){return rV(this,ey,"f")}async finalRunSteps(){return await this.done(),Object.values(rV(this,el,"f"))}async finalMessages(){return await this.done(),Object.values(rV(this,eu,"f"))}async finalRun(){if(await this.done(),!rV(this,ed,"f"))throw Error("Final run was not received.");return rV(this,ed,"f")}async _createThreadAssistantStream(e,t,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort()));let i={...t,stream:!0},a=await e.createAndRun(i,{...r,signal:this.controller.signal});for await(let e of(this._connected(),a))rV(this,eo,"m",eb).call(this,e);if(a.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}async _createAssistantStream(e,t,r,n){let i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));let a={...r,stream:!0},o=await e.create(t,a,{...n,signal:this.controller.signal});for await(let e of(this._connected(),o))rV(this,eo,"m",eb).call(this,e);if(o.controller.signal?.aborted)throw new tB;return this._addRun(rV(this,eo,"m",ex).call(this))}static accumulateDelta(e,t){for(let[r,n]of Object.entries(t)){if(!e.hasOwnProperty(r)){e[r]=n;continue}let t=e[r];if(null==t||"index"===r||"type"===r){e[r]=n;continue}if("string"==typeof t&&"string"==typeof n)t+=n;else if("number"==typeof t&&"number"==typeof n)t+=n;else if(tT(t)&&tT(n))t=this.accumulateDelta(t,n);else if(Array.isArray(t)&&Array.isArray(n)){if(t.every(e=>"string"==typeof e||"number"==typeof e)){t.push(...n);continue}for(let e of n){if(!tT(e))throw Error(`Expected array delta entry to be an object but got: ${e}`);let r=e.index;if(null==r)throw console.error(e),Error("Expected array delta entry to have an `index` property");if("number"!=typeof r)throw Error(`Expected array delta entry \`index\` property to be a number but got ${r}`);let n=t[r];null==n?t.push(e):t[r]=this.accumulateDelta(n,e)}continue}else throw Error(`Unhandled record type: ${r}, deltaValue: ${n}, accValue: ${t}`);e[r]=t}return e}_addRun(e){return e}async _threadAssistantStream(e,t,r){return await this._createThreadAssistantStream(t,e,r)}async _runAssistantStream(e,t,r,n){return await this._createAssistantStream(t,e,r,n)}async _runToolAssistantStream(e,t,r,n,i){return await this._createToolAssistantStream(r,e,t,n,i)}}eb=function(e){if(!this.ended)switch(rU(this,eg,e,"f"),rV(this,eo,"m",ek).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":rV(this,eo,"m",eA).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":rV(this,eo,"m",eC).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":rV(this,eo,"m",ew).call(this,e);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier")}},ex=function(){if(this.ended)throw new t_("stream has ended, this shouldn't happen");if(!rV(this,ed,"f"))throw Error("Final run has not been received");return rV(this,ed,"f")},ew=function(e){let[t,r]=rV(this,eo,"m",eP).call(this,e,rV(this,ec,"f"));for(let e of(rU(this,ec,t,"f"),rV(this,eu,"f")[t.id]=t,r)){let r=t.content[e.index];r?.type=="text"&&this._emit("textCreated",r.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(let r of e.data.delta.content){if("text"==r.type&&r.text){let e=r.text,n=t.content[r.index];if(n&&"text"==n.type)this._emit("textDelta",e,n.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(r.index!=rV(this,ep,"f")){if(rV(this,ef,"f"))switch(rV(this,ef,"f").type){case"text":this._emit("textDone",rV(this,ef,"f").text,rV(this,ec,"f"));break;case"image_file":this._emit("imageFileDone",rV(this,ef,"f").image_file,rV(this,ec,"f"))}rU(this,ep,r.index,"f")}rU(this,ef,t.content[r.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==rV(this,ep,"f")){let t=e.data.content[rV(this,ep,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,rV(this,ec,"f"));break;case"text":this._emit("textDone",t.text,rV(this,ec,"f"))}}rV(this,ec,"f")&&this._emit("messageDone",e.data),rU(this,ec,void 0,"f")}},eC=function(e){let t=rV(this,eo,"m",eS).call(this,e);switch(rU(this,ey,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":let r=e.data.delta;if(r.step_details&&"tool_calls"==r.step_details.type&&r.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(let e of r.step_details.tool_calls)e.index==rV(this,eh,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(rV(this,em,"f")&&this._emit("toolCallDone",rV(this,em,"f")),rU(this,eh,e.index,"f"),rU(this,em,t.step_details.tool_calls[e.index],"f"),rV(this,em,"f")&&this._emit("toolCallCreated",rV(this,em,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":rU(this,ey,void 0,"f"),"tool_calls"==e.data.step_details.type&&rV(this,em,"f")&&(this._emit("toolCallDone",rV(this,em,"f")),rU(this,em,void 0,"f")),this._emit("runStepDone",e.data,t)}},ek=function(e){rV(this,es,"f").push(e),this._emit("event",e)},eS=function(e){switch(e.event){case"thread.run.step.created":return rV(this,el,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=rV(this,el,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let r=e.data;if(r.delta){let n=rG.accumulateDelta(t,r.delta);rV(this,el,"f")[e.data.id]=n}return rV(this,el,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":rV(this,el,"f")[e.data.id]=e.data}if(rV(this,el,"f")[e.data.id])return rV(this,el,"f")[e.data.id];throw Error("No snapshot available")},eP=function(e,t){let r=[];switch(e.event){case"thread.message.created":return[e.data,r];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let n=e.data;if(n.delta.content)for(let e of n.delta.content)if(e.index in t.content){let r=t.content[e.index];t.content[e.index]=rV(this,eo,"m",eE).call(this,e,r)}else t.content[e.index]=e,r.push(e);return[t,r];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,r];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},eE=function(e,t){return rG.accumulateDelta(t,e)},eA=function(e){switch(rU(this,ev,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":rU(this,ed,e.data,"f"),rV(this,em,"f")&&(this._emit("toolCallDone",rV(this,em,"f")),rU(this,em,void 0,"f"))}};class rZ extends t5{create(e,t,r){return this._client.post(`/threads/${e}/messages`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}retrieve(e,t,r){return this._client.get(`/threads/${e}/messages/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}update(e,t,r,n){return this._client.post(`/threads/${e}/messages/${t}`,{body:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},r){return tl(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/messages`,rH,{query:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}del(e,t,r){return this._client.delete(`/threads/${e}/messages/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}}class rH extends t2{}(rZ||(rZ={})).MessagesPage=rH;class rq extends t5{retrieve(e,t,r,n={},i){return tl(n)?this.retrieve(e,t,r,{},n):this._client.get(`/threads/${e}/runs/${t}/steps/${r}`,{query:n,...i,headers:{"OpenAI-Beta":"assistants=v2",...i?.headers}})}list(e,t,r={},n){return tl(r)?this.list(e,t,{},r):this._client.getAPIList(`/threads/${e}/runs/${t}/steps`,rJ,{query:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}}class rJ extends t2{}(rq||(rq={})).RunStepsPage=rJ;class rX extends t5{constructor(){super(...arguments),this.steps=new rq(this._client)}create(e,t,r){let{include:n,...i}=t;return this._client.post(`/threads/${e}/runs`,{query:{include:n},body:i,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers},stream:t.stream??!1})}retrieve(e,t,r){return this._client.get(`/threads/${e}/runs/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}update(e,t,r,n){return this._client.post(`/threads/${e}/runs/${t}`,{body:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},r){return tl(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/runs`,rY,{query:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}cancel(e,t,r){return this._client.post(`/threads/${e}/runs/${t}/cancel`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}async createAndPoll(e,t,r){let n=await this.create(e,t,r);return await this.poll(e,n.id,r)}createAndStream(e,t,r){return rG.createAssistantStream(e,this._client.beta.threads.runs,t,r)}async poll(e,t,r){let n={...r?.headers,"X-Stainless-Poll-Helper":"true"};for(r?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=r.pollIntervalMs.toString());;){let{data:i,response:a}=await this.retrieve(e,t,{...r,headers:{...r?.headers,...n}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let e=a.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(o=t)}}await tg(o);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(e,t,r){return rG.createAssistantStream(e,this._client.beta.threads.runs,t,r)}submitToolOutputs(e,t,r,n){return this._client.post(`/threads/${e}/runs/${t}/submit_tool_outputs`,{body:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers},stream:r.stream??!1})}async submitToolOutputsAndPoll(e,t,r,n){let i=await this.submitToolOutputs(e,t,r,n);return await this.poll(e,i.id,n)}submitToolOutputsStream(e,t,r,n){return rG.createToolAssistantStream(e,t,this._client.beta.threads.runs,r,n)}}class rY extends t2{}(y=rX||(rX={})).RunsPage=rY,y.Steps=rq,y.RunStepsPage=rJ;class rQ extends t5{constructor(){super(...arguments),this.runs=new rX(this._client),this.messages=new rZ(this._client)}create(e={},t){return tl(e)?this.create({},e):this._client.post("/threads",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,r){return this._client.post(`/threads/${e}`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}del(e,t){return this._client.delete(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers},stream:e.stream??!1})}async createAndRunPoll(e,t){let r=await this.createAndRun(e,t);return await this.runs.poll(r.thread_id,r.id,t)}createAndRunStream(e,t){return rG.createThreadAssistantStream(e,this._client.beta.threads,t)}}(b=rQ||(rQ={})).Runs=rX,b.RunsPage=rY,b.Messages=rZ,b.MessagesPage=rH;let r0=async e=>{let t=await Promise.allSettled(e),r=t.filter(e=>"rejected"===e.status);if(r.length){for(let e of r)console.error(e.reason);throw Error(`${r.length} promise(s) failed - see the above errors`)}let n=[];for(let e of t)"fulfilled"===e.status&&n.push(e.value);return n};class r1 extends t5{create(e,t,r){return this._client.post(`/vector_stores/${e}/files`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}retrieve(e,t,r){return this._client.get(`/vector_stores/${e}/files/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}list(e,t={},r){return tl(t)?this.list(e,{},t):this._client.getAPIList(`/vector_stores/${e}/files`,r4,{query:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}del(e,t,r){return this._client.delete(`/vector_stores/${e}/files/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}async createAndPoll(e,t,r){let n=await this.create(e,t,r);return await this.poll(e,n.id,r)}async poll(e,t,r){let n={...r?.headers,"X-Stainless-Poll-Helper":"true"};for(r?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=r.pollIntervalMs.toString());;){let i=await this.retrieve(e,t,{...r,headers:n}).withResponse(),a=i.data;switch(a.status){case"in_progress":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let e=i.response.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(o=t)}}await tg(o);break;case"failed":case"completed":return a}}}async upload(e,t,r){let n=await this._client.files.create({file:t,purpose:"assistants"},r);return this.create(e,{file_id:n.id},r)}async uploadAndPoll(e,t,r){let n=await this.upload(e,t,r);return await this.poll(e,n.id,r)}}class r4 extends t2{}(r1||(r1={})).VectorStoreFilesPage=r4;class r3 extends t5{create(e,t,r){return this._client.post(`/vector_stores/${e}/file_batches`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}retrieve(e,t,r){return this._client.get(`/vector_stores/${e}/file_batches/${t}`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}cancel(e,t,r){return this._client.post(`/vector_stores/${e}/file_batches/${t}/cancel`,{...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}async createAndPoll(e,t,r){let n=await this.create(e,t);return await this.poll(e,n.id,r)}listFiles(e,t,r={},n){return tl(r)?this.listFiles(e,t,{},r):this._client.getAPIList(`/vector_stores/${e}/file_batches/${t}/files`,r4,{query:r,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}async poll(e,t,r){let n={...r?.headers,"X-Stainless-Poll-Helper":"true"};for(r?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=r.pollIntervalMs.toString());;){let{data:i,response:a}=await this.retrieve(e,t,{...r,headers:n}).withResponse();switch(i.status){case"in_progress":let o=5e3;if(r?.pollIntervalMs)o=r.pollIntervalMs;else{let e=a.headers.get("openai-poll-after-ms");if(e){let t=parseInt(e);isNaN(t)||(o=t)}}await tg(o);break;case"failed":case"cancelled":case"completed":return i}}}async uploadAndPoll(e,{files:t,fileIds:r=[]},n){if(null==t||0==t.length)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let i=Math.min(n?.maxConcurrency??5,t.length),a=this._client,o=t.values(),s=[...r];async function l(e){for(let t of e){let e=await a.files.create({file:t,purpose:"assistants"},n);s.push(e.id)}}let u=Array(i).fill(o).map(l);return await r0(u),await this.createAndPoll(e,{file_ids:s})}}r3||(r3={});class r2 extends t5{constructor(){super(...arguments),this.files=new r1(this._client),this.fileBatches=new r3(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,r){return this._client.post(`/vector_stores/${e}`,{body:t,...r,headers:{"OpenAI-Beta":"assistants=v2",...r?.headers}})}list(e={},t){return tl(e)?this.list({},e):this._client.getAPIList("/vector_stores",r5,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}del(e,t){return this._client.delete(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}}class r5 extends t2{}(x=r2||(r2={})).VectorStoresPage=r5,x.Files=r1,x.VectorStoreFilesPage=r4,x.FileBatches=r3;class r6 extends t5{constructor(){super(...arguments),this.vectorStores=new r2(this._client),this.chat=new rW(this._client),this.assistants=new rg(this._client),this.threads=new rQ(this._client)}}(w=r6||(r6={})).VectorStores=r2,w.VectorStoresPage=r5,w.Chat=rW,w.Assistants=rg,w.AssistantsPage=rv,w.Threads=rQ;class r9 extends t5{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(`/batches/${e}`,t)}list(e={},t){return tl(e)?this.list({},e):this._client.getAPIList("/batches",r8,{query:e,...t})}cancel(e,t){return this._client.post(`/batches/${e}/cancel`,t)}}class r8 extends t2{}(r9||(r9={})).BatchesPage=r8;class r7 extends t5{create(e,t,r){return this._client.post(`/uploads/${e}/parts`,e4({body:t,...r}))}}r7||(r7={});class ne extends t5{constructor(){super(...arguments),this.parts=new r7(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(`/uploads/${e}/cancel`,t)}complete(e,t,r){return this._client.post(`/uploads/${e}/complete`,{body:t,...r})}}(ne||(ne={})).Parts=r7,r(9752);class nt extends tn{constructor({baseURL:e=tb("OPENAI_BASE_URL"),apiKey:t=tb("OPENAI_API_KEY"),organization:r=tb("OPENAI_ORG_ID")??null,project:n=tb("OPENAI_PROJECT_ID")??null,...i}={}){if(void 0===t)throw new t_("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");let a={apiKey:t,organization:r,project:n,...i,baseURL:e||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&tP())throw new t_("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");super({baseURL:a.baseURL,timeout:a.timeout??6e5,httpAgent:a.httpAgent,maxRetries:a.maxRetries,fetch:a.fetch}),this.completions=new t6(this),this.chat=new t8(this),this.embeddings=new t7(this),this.files=new re(this),this.images=new rr(this),this.audio=new ro(this),this.moderations=new rs(this),this.models=new rl(this),this.fineTuning=new rm(this),this.beta=new r6(this),this.batches=new r9(this),this.uploads=new ne(this),this._options=a,this.apiKey=t,this.organization=r,this.project=n}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders(e){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery(e){return function(e,t={}){let r,n=e,i=function(e=t1){let t;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw TypeError("Encoder has to be a function.");let r=e.charset||t1.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=tV;if(void 0!==e.format){if(!tq.call(tU,e.format))throw TypeError("Unknown format option provided.");n=e.format}let i=tU[n],a=t1.filter;if(("function"==typeof e.filter||tX(e.filter))&&(a=e.filter),t=e.arrayFormat&&e.arrayFormat in tJ?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":t1.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw TypeError("`commaRoundTrip` must be a boolean, or absent");let o=void 0===e.allowDots?!0==!!e.encodeDotInKeys||t1.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:t1.addQueryPrefix,allowDots:o,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:t1.allowEmptyArrays,arrayFormat:t,charset:r,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:t1.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?t1.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:t1.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:t1.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:t1.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:t1.encodeValuesOnly,filter:a,format:n,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:t1.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:t1.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:t1.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):tX(i.filter)&&(r=i.filter);let a=[];if("object"!=typeof n||null===n)return"";let o=tJ[i.arrayFormat],s="comma"===o&&i.commaRoundTrip;r||(r=Object.keys(n)),i.sort&&r.sort(i.sort);let l=new WeakMap;for(let e=0;e0?C.join(",")||null:void 0}];else if(tX(c))w=c;else{let e=Object.keys(C);w=d?e.sort(d):e}let A=l?String(r).replace(/\./g,"%2E"):String(r),T=i&&tX(C)&&1===C.length?A+"[]":A;if(a&&tX(C)&&0===C.length)return T+"[]";for(let r=0;r0?c+u:""}(e,{arrayFormat:"brackets"})}}eT=nt,nt.OpenAI=eT,nt.DEFAULT_TIMEOUT=6e5,nt.OpenAIError=t_,nt.APIError=tD,nt.APIConnectionError=tM,nt.APIConnectionTimeoutError=tj,nt.APIUserAbortError=tB,nt.NotFoundError=tO,nt.ConflictError=t$,nt.RateLimitError=tL,nt.BadRequestError=tN,nt.AuthenticationError=tI,nt.InternalServerError=tz,nt.PermissionDeniedError=tR,nt.UnprocessableEntityError=tF,nt.toFile=eX,nt.fileFromPath=f;let{OpenAIError:nr,APIError:nn,APIConnectionError:ni,APIConnectionTimeoutError:na,APIUserAbortError:no,NotFoundError:ns,ConflictError:nl,RateLimitError:nu,BadRequestError:nc,AuthenticationError:nd,InternalServerError:np,PermissionDeniedError:nf,UnprocessableEntityError:nh}=eI;(C=nt||(nt={})).Page=t3,C.CursorPage=t2,C.Completions=t6,C.Chat=t8,C.Embeddings=t7,C.Files=re,C.FileObjectsPage=rt,C.Images=rr,C.Audio=ro,C.Moderations=rs,C.Models=rl,C.ModelsPage=ru,C.FineTuning=rm,C.Beta=r6,C.Batches=r9,C.BatchesPage=r8,C.Uploads=ne;var nm=r(7554);async function ng(e){return new Promise(t=>setTimeout(t,e))}async function nv(e,t,r,n){let i={currentTry:1,error:void 0,maxRetries:t};for(;i.currentTry<=i.maxRetries;){try{return await e()}catch(e){i.error=e,r&&await r(i)}i.currentTry++}n&&await n(i)}function ny(e,t){var r=Math.pow(10,t);return Math.round(e*r)/r}let nb={"gpt-3.5-turbo":{prompt:5e-4,completion:.0015},"gpt-3.5-turbo-1106":{prompt:.001,completion:.002},"gpt-4":{prompt:.03,completion:.06},"gpt-4-32k":{prompt:.06,completion:.12},"gpt-4-1106-preview":{prompt:.01,completion:.03},"gpt-4o":{prompt:.005,completion:.015000000000000001},"gpt-4o-mini":{prompt:15e-5,completion:6e-4}},nx={"gpt-3.5-turbo-0301":"gpt-3.5-turbo","gpt-3.5-turbo-0613":"gpt-3.5-turbo","gpt-3.5-turbo-16k":"gpt-3.5-turbo-1106","gpt-3.5-turbo-16k-0613":"gpt-3.5-turbo-1106","gpt-4-0613":"gpt-4","gpt-4o-2024-05-13":"gpt-4o","gpt-4o-mini-2024-07-18":"gpt-4o-mini"};function nw(e,t,r){return new nt({apiKey:e,baseURL:r,dangerouslyAllowBrowser:t,maxRetries:3})}class nC extends SyntaxError{constructor(e,t){super(e,t)}}async function nk(e,t,r){return await nv(e,t,async e=>{let t=e.error,n=1e3*e.currentTry*e.currentTry;if(t instanceof nt.APIError){if(nm.error(`[Error_${r}]`,new Date,"Status",t.status,t.name,t.message,t.error),429===t.status||t.status>=500&&t.status<=599)n*=e.currentTry;else throw`[Error_${r}] ${new Date} ${t.message}`;nm.error(`[Error_${r}]`,"Retries",e.currentTry,"Delay",n),await ng(n)}else if(t instanceof nC)nm.error(`[Error_${r}] ${t.message}`,"Retries",e.currentTry,"Delay",n),await ng(n);else throw`[Error_${r}] [openaiRetryWrapper] ${new Date} unknown error ${t}`},async e=>{throw nm.error(`[Error_${r}] [openaiRetryWrapper] Max Retries Reached`,new Date,e),`[Error_${r}] [openaiRetryWrapper] Max Retries Reached, Error: ${e.error?.message??e.error}`})}async function nS(e,t=e=>{},r=e=>{}){let n="";return await new Promise(async(i,a)=>{try{let a;for await(let r of e){let e=r.choices[0]?.delta?.content;e?(n+=e,t(e)):r.usage&&(a=r.usage)}r(a),i(n)}catch(e){a(new nC(`Could not JSON parse stream message: ${e.message}`,e))}})}class nP{constructor(e,t,r){this.limit=e,this.duration=t,this.description=r,this.baseDelay=1e3,this.requests=[]}cooldown(){let e=Date.now();return(this.requests=this.requests.filter(t=>e-t=this.limit)?this.requests[0]+this.duration-e:0}async cool(){let e=this.cooldown();return 0===e?(this.requests.push(Date.now()),!1):(nm.error("[Cooldown]",this.description,e,"ms"),await ng(e+this.baseDelay),this.requests.push(Date.now()),!0)}}class nE{seperator=",";timestampToSeconds(e){let[t,r]=e.split(","),n=parseInt(r),[i,a,o]=t.split(":").map(e=>parseInt(e));return Math.round(1e3*(.001*n+o+60*a+3600*i))/1e3}correctFormat(e){let t=e.replace(".",",");var r=null,n=null,i=null,a=null,[o,s]=t.split(",");a=this.fixed_str_digit(3,s);var[l,u,c]=o.split(":");return r=this.fixed_str_digit(2,l,!1),n=this.fixed_str_digit(2,u,!1),i=this.fixed_str_digit(2,c,!1),`${r}:${n}:${i},${a}`}fixed_str_digit(e,t,r=!0){return t.length==e?t:t.length>e?t.slice(0,e):t.length (\d{1,2}:\d{2}:\d{2},\d{1,3})/g);return t.shift(),t}tryDot(e){let t=(e=e.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g);return t.shift(),this.seperator=".",t}fromSrt(e){var t=this.tryComma(e);0==t.length&&(t=this.tryDot(e));for(var r=[],n=0;n ")+n.endTime+"\r\n"+n.text.replace("\n","\r\n")+"\r\n\r\n"}return t}}let nA=new nE;async function nT(e,t,r){return await nk(async()=>{await t.cooler?.cool();let n=(await t.openai.moderations.create({input:e,model:r})).results[0];return n.flagged&&nm.debug("[CheckModeration]","flagged",Object.keys(n.categories).filter(e=>n.categories[e]).map(e=>({catergory:e,value:Number(n.category_scores[e])}))),n},3,"CheckModeration")}class n_{constructor(e,t,r,n,i,a=""){this.content=e,this.promptTokens=t??0,this.completionTokens=r??0,this.cachedTokens=n,this.totalTokens=i??this.promptTokens+this.completionTokens,this.refusal=a}}let nD={createChatCompletionRequest:{model:"gpt-4o-mini"},moderationModel:"omni-moderation-latest",initialPrompts:[],useModerator:!0,prefixNumber:!0,lineMatching:!0,historyPromptLength:10,useFullContext:!1,batchSizes:[10,100],structuredMode:!1,max_token:0,inputMultiplier:0,fallbackModel:void 0,logLevel:void 0};class nB{constructor(e,t,r){r.createChatCompletionRequest={...nD.createChatCompletionRequest,...r.createChatCompletionRequest},this.language=e,this.services=t,this.options={...nD,...r},this.systemInstruction=`Translate ${this.language.from?this.language.from+" ":""}to ${this.language.to}`,this.promptContext=[],this.workingProgress=[],this.promptTokensUsed=0,this.promptTokensWasted=0,this.cachedTokens=0,this.completionTokensUsed=0,this.completionTokensWasted=0,this.tokensProcessTimeMs=0,this.offset=0,this.end=void 0,this.workingBatchSizes=[...this.options.batchSizes],this.currentBatchSize=this.workingBatchSizes[this.workingBatchSizes.length-1],this.moderatorFlags=new Map,this.pricingModel=function(e){let t=nb[e];if(!t){let r=nx[e];r&&(t=nb[r])}return t}(this.options.createChatCompletionRequest.model),this.aborted=!1,r.logLevel&&nm.setLevel(r.logLevel)}getMaxToken(e){if(this.options.max_token&&!this.options.inputMultiplier)return this.options.max_token;if(this.options.max_token&&this.options.inputMultiplier){let t=JSON.stringify(e).length*this.options.inputMultiplier;return Math.min(this.options.max_token,t)}}async translatePrompt(e){let t=e.join("\n\n"),r={role:"user",content:`${t}`},n=[...this.systemInstruction?[{role:"system",content:`${this.systemInstruction}`}]:[],...this.options.initialPrompts,...this.promptContext,r],i=this.getMaxToken(e);function a(t){return 1===e.length?[t.split("\n").join(" ")]:t.split("\n").filter(e=>e.trim().length>0)}let o=0,s=0,l=this.options.createChatCompletionRequest.stream,u=await nk(async()=>{if(await this.services.cooler?.cool(),o=Date.now(),l){let e;let t=await this.services.openai.chat.completions.create({messages:n,...this.options.createChatCompletionRequest,stream:!0,stream_options:{include_usage:!0},max_tokens:i});this.streamController=t.controller;let r="",o=await nS(t,e=>{let t=e.includes("\n");0!==r.length||t?t?(r+=e,r=r.replaceAll("\n\n","\n")):(r+=e,this.services.onStreamChunk?.(r),r=""):this.services.onStreamChunk?.(e)},t=>{s=Date.now(),e=t,this.services.onStreamEnd?.()}),l=e?.prompt_tokens,u=e?.completion_tokens,c=e?.prompt_tokens_details?.cached_tokens,d=e?.total_tokens;return new n_(a(o),l,u,c,d)}{let e=await this.services.openai.chat.completions.create({messages:n,...this.options.createChatCompletionRequest,stream:!1,max_tokens:i});return s=Date.now(),new n_(a(e.choices[0].message.content),e.usage?.prompt_tokens,e.usage?.completion_tokens,e.usage?.prompt_tokens_details?.cached_tokens,e.usage?.total_tokens)}},3,"TranslationPrompt");return this.promptTokensUsed+=u.promptTokens,this.completionTokensUsed+=u.completionTokens,this.cachedTokens+=u.cachedTokens,this.tokensProcessTimeMs+=s-o,u}async *translateSingle(e){nm.debug("[Translator]","Single line mode"),e=e.slice(-this.currentBatchSize);for(let t=0;tthis.preprocessLine(e,t,r));if(this.options.useModerator&&!this.services.moderationService&&nm.warn("[Translator]","Moderation service requested but not configured, no moderation applied"),this.options.useModerator&&this.services.moderationService){let e=t.join("\n\n");if((await nT(e,this.services.moderationService,this.options.moderationModel)).flagged){this.changeBatchSize("decrease")?r-=this.currentBatchSize:yield*this.translateSingle(t);continue}}this.buildContext();let i=await this.translatePrompt(t);if(this.aborted){nm.debug("[Translator]","Aborted");return}let a=i.content;if(this.options.lineMatching&&t.length!==a.length||t.length>1&&i.refusal?(this.promptTokensWasted+=i.promptTokens,this.completionTokensWasted+=i.completionTokens,i.refusal?nm.debug("[Translator]","Refusal: ",i.refusal):nm.debug("[Translator]","Lines count mismatch",t.length,a.length),nm.debug("[Translator]","batch",t),nm.debug("[Translator]","transformed",a),this.changeBatchSize("decrease")?r-=this.currentBatchSize:yield*this.translateSingle(t)):yield*this.yieldOutput(t,a),this.printUsage(),this.batchSizeThreshold&&n++>=this.batchSizeThreshold){n=0;let e=this.currentBatchSize;this.changeBatchSize("increase"),r-=this.currentBatchSize-e}}}*yieldOutput(e,t){for(let r=0;r ${s} `;else if(this.options.prefixNumber){let e=this.postprocessNumberPrefixedLine(s);s=e.text,l=e.text;let t=a+1;t!==e.number&&(nm.warn("[Translator]","Label mismatch",t,e.number),this.moderatorFlags.set(a,{remarks:"Label Mismatch",outIndex:e.number}),s=`[Flagged][Model] ${o} -> ${s}`)}else s=this.postprocessLine(s);this.workingProgress.push({source:n,transform:i});let u={index:this.workingProgress.length,source:o,transform:l,finalTransform:s};yield u}}preprocessLine(e,t,r){return e=e.replaceAll("\n"," \\N "),this.options.prefixNumber&&(e=`${r+t+1}. ${e}`),e}postprocessNumberPrefixedLine(e){let t=function(e){let t=e.match(/^(\d+\.)?\s*(.*)/);return{number:t[1]?parseInt(t[1]):void 0,text:t[2].trim()}}(e);return t.text=this.postprocessLine(t.text),t}postprocessLine(e){return e=(e=e.replaceAll(" \\N ","\n")).replaceAll("\\N","\n")}changeBatchSize(e){let t=this.currentBatchSize;if("decrease"===e){if(this.currentBatchSize===this.options.batchSizes[0])return!1;this.workingBatchSizes.unshift(this.workingBatchSizes.pop())}else if("increase"===e){if(this.currentBatchSize===this.options.batchSizes[this.options.batchSizes.length-1])return!1;this.workingBatchSizes.push(this.workingBatchSizes.shift())}return this.currentBatchSize=this.workingBatchSizes[this.workingBatchSizes.length-1],this.currentBatchSize===this.options.batchSizes[this.options.batchSizes.length-1]?this.batchSizeThreshold=void 0:this.batchSizeThreshold=Math.floor(Math.max(t,this.currentBatchSize)/Math.min(t,this.currentBatchSize)),nm.debug("[Translator]","BatchSize",e,t,"->",this.currentBatchSize,"SizeThreshold",this.batchSizeThreshold),!0}buildContext(){let e;if(0===this.workingProgress.length||0===this.options.historyPromptLength)return;e=this.options.useFullContext?this.workingProgress:this.workingProgress.slice(-this.options.historyPromptLength);let t=this.workingProgress.length-e.length,r=(e,r)=>{let n=r+(t<0?0:t);return this.moderatorFlags.has(n)?this.preprocessLine("-",n,0):e},n=e.map((e,t)=>r(e.source,t)),i=e.map((e,t)=>r(e.transform,t));this.promptContext=this.getContext(n,i)}getContext(e,t){let r=[],n=this.options.historyPromptLength;for(let i=0;ie,k.assertIs=function(e){},k.assertNever=function(e){throw Error()},k.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},k.getValidEnumValues=e=>{let t=k.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let n of t)r[n]=e[n];return k.objectValues(r)},k.objectValues=e=>k.objectKeys(e).map(function(t){return e[t]}),k.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},k.find=(e,t)=>{for(let r of e)if(t(r))return r},k.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,k.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},k.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(eD||(eD={})).mergeShapes=(e,t)=>({...e,...t});let nM=e_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),nj=e=>{switch(typeof e){case"undefined":return nM.undefined;case"string":return nM.string;case"number":return isNaN(e)?nM.nan:nM.number;case"boolean":return nM.boolean;case"function":return nM.function;case"bigint":return nM.bigint;case"symbol":return nM.symbol;case"object":if(Array.isArray(e))return nM.array;if(null===e)return nM.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return nM.promise;if("undefined"!=typeof Map&&e instanceof Map)return nM.map;if("undefined"!=typeof Set&&e instanceof Set)return nM.set;if("undefined"!=typeof Date&&e instanceof Date)return nM.date;return nM.object;default:return nM.unknown}},nN=e_.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class nI extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(n);else if("invalid_return_type"===i.code)n(i.returnTypeError);else if("invalid_arguments"===i.code)n(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,n=0;for(;ne.message){let t={},r=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}nI.create=e=>new nI(e);let nR=(e,t)=>{let r;switch(e.code){case nN.invalid_type:r=e.received===nM.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case nN.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,e_.jsonStringifyReplacer)}`;break;case nN.unrecognized_keys:r=`Unrecognized key(s) in object: ${e_.joinValues(e.keys,", ")}`;break;case nN.invalid_union:r="Invalid input";break;case nN.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${e_.joinValues(e.options)}`;break;case nN.invalid_enum_value:r=`Invalid enum value. Expected ${e_.joinValues(e.options)}, received '${e.received}'`;break;case nN.invalid_arguments:r="Invalid function arguments";break;case nN.invalid_return_type:r="Invalid function return type";break;case nN.invalid_date:r="Invalid date";break;case nN.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:e_.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case nN.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case nN.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case nN.custom:r="Invalid input";break;case nN.invalid_intersection_types:r="Intersection results could not be merged";break;case nN.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case nN.not_finite:r="Number must be finite";break;default:r=t.defaultError,e_.assertNever(e)}return{message:r}},nO=nR;function n$(){return nO}let nF=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],o={...i,path:a};if(void 0!==i.message)return{...i,path:a,message:i.message};let s="";for(let e of n.filter(e=>!!e).slice().reverse())s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function nL(e,t){let r=n$(),n=nF({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===nR?void 0:nR].filter(e=>!!e)});e.common.issues.push(n)}class nz{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if("aborted"===n.status)return nK;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return nz.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:t,value:i}=n;if("aborted"===t.status||"aborted"===i.status)return nK;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||n.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let nK=Object.freeze({status:"aborted"}),nW=e=>({status:"dirty",value:e}),nV=e=>({status:"valid",value:e}),nU=e=>"aborted"===e.status,nG=e=>"dirty"===e.status,nZ=e=>"valid"===e.status,nH=e=>"undefined"!=typeof Promise&&e instanceof Promise;function nq(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function nJ(e,t,r,n,i){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r}"function"==typeof SuppressedError&&SuppressedError,(S=eB||(eB={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},S.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;class nX{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let nY=(e,t)=>{if(nZ(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new nI(e.common.issues);return this._error=t,this._error}}};function nQ(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{var a,o;let{message:s}=e;return"invalid_enum_value"===t.code?{message:null!=s?s:i.defaultError}:void 0===i.data?{message:null!==(a=null!=s?s:n)&&void 0!==a?a:i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:null!==(o=null!=s?s:r)&&void 0!==o?o:i.defaultError}},description:i}}class n0{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return nj(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:nj(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nz,ctx:{common:e.parent.common,data:e.data,parsedType:nj(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(nH(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;let n={common:{issues:[],async:null!==(r=null==t?void 0:t.async)&&void 0!==r&&r,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:nj(e)},i=this._parseSync({data:e,path:n.path,parent:n});return nY(n,i)}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:nj(e)},n=this._parse({data:e,path:r.path,parent:r});return nY(r,await (nH(n)?n:Promise.resolve(n)))}refine(e,t){let r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,n)=>{let i=e(t),a=()=>n.addIssue({code:nN.custom,...r(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new iR({schema:this,typeName:eN.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return iO.create(this,this._def)}nullable(){return i$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ib.create(this,this._def)}promise(){return iI.create(this,this._def)}or(e){return iw.create([this,e],this._def)}and(e){return iS.create(this,e,this._def)}transform(e){return new iR({...nQ(this._def),schema:this,typeName:eN.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new iF({...nQ(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:eN.ZodDefault})}brand(){return new iW({typeName:eN.ZodBranded,type:this,...nQ(this._def)})}catch(e){return new iL({...nQ(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:eN.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return iV.create(this,e)}readonly(){return iU.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let n1=/^c[^\s-]{8,}$/i,n4=/^[0-9a-z]+$/,n3=/^[0-9A-HJKMNP-TV-Z]{26}$/,n2=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,n5=/^[a-z0-9_-]{21}$/i,n6=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,n9=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,n8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,n7=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ie=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,it="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ir=RegExp(`^${it}$`);function ii(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function ia(e){let t=`${it}T${ii(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class io extends n0{_parse(e){var t,r;let n;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==nM.string){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.string,received:t.parsedType}),nK}let a=new nz;for(let o of this._def.checks)if("min"===o.kind)e.data.lengtho.value&&(nL(n=this._getOrReturnCtx(e,n),{code:nN.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),a.dirty());else if("length"===o.kind){let t=e.data.length>o.value,r=e.data.lengthe.test(t),{validation:t,code:nN.invalid_string,...eB.errToObj(r)})}_addCheck(e){return new io({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...eB.errToObj(e)})}url(e){return this._addCheck({kind:"url",...eB.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...eB.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...eB.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...eB.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...eB.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...eB.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...eB.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...eB.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...eB.errToObj(e)})}datetime(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(r=null==e?void 0:e.local)&&void 0!==r&&r,...eB.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...eB.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...eB.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...eB.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...eB.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...eB.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...eB.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...eB.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...eB.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...eB.errToObj(t)})}nonempty(e){return this.min(1,eB.errToObj(e))}trim(){return new io({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new io({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new io({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value{var t;return new io({checks:[],typeName:eN.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...nQ(e)})};class is extends n0{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==nM.number){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.number,received:t.parsedType}),nK}let r=new nz;for(let n of this._def.checks)"int"===n.kind?e_.isInteger(e.data)||(nL(t=this._getOrReturnCtx(e,t),{code:nN.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.datan.value:e.data>=n.value)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n;return parseInt(e.toFixed(i).replace(".",""))%parseInt(t.toFixed(i).replace(".",""))/Math.pow(10,i)}(e.data,n.value)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(nL(t=this._getOrReturnCtx(e,t),{code:nN.not_finite,message:n.message}),r.dirty()):e_.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,eB.toString(t))}gt(e,t){return this.setLimit("min",e,!1,eB.toString(t))}lte(e,t){return this.setLimit("max",e,!0,eB.toString(t))}lt(e,t){return this.setLimit("max",e,!1,eB.toString(t))}setLimit(e,t,r,n){return new is({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:eB.toString(n)}]})}_addCheck(e){return new is({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:eB.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:eB.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:eB.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:eB.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:eB.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:eB.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:eB.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:eB.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:eB.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value"int"===e.kind||"multipleOf"===e.kind&&e_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.valuenew is({checks:[],typeName:eN.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...nQ(e)});class il extends n0{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==nM.bigint){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.bigint,received:t.parsedType}),nK}let r=new nz;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.datan.value:e.data>=n.value)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):e_.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,eB.toString(t))}gt(e,t){return this.setLimit("min",e,!1,eB.toString(t))}lte(e,t){return this.setLimit("max",e,!0,eB.toString(t))}lt(e,t){return this.setLimit("max",e,!1,eB.toString(t))}setLimit(e,t,r,n){return new il({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:eB.toString(n)}]})}_addCheck(e){return new il({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:eB.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:eB.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:eB.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:eB.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:eB.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value{var t;return new il({checks:[],typeName:eN.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...nQ(e)})};class iu extends n0{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==nM.boolean){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.boolean,received:t.parsedType}),nK}return nV(e.data)}}iu.create=e=>new iu({typeName:eN.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...nQ(e)});class ic extends n0{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==nM.date){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.date,received:t.parsedType}),nK}if(isNaN(e.data.getTime()))return nL(this._getOrReturnCtx(e),{code:nN.invalid_date}),nK;let r=new nz;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()n.value&&(nL(t=this._getOrReturnCtx(e,t),{code:nN.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):e_.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ic({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:eB.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:eB.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.valuenew ic({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:eN.ZodDate,...nQ(e)});class id extends n0{_parse(e){if(this._getType(e)!==nM.symbol){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.symbol,received:t.parsedType}),nK}return nV(e.data)}}id.create=e=>new id({typeName:eN.ZodSymbol,...nQ(e)});class ip extends n0{_parse(e){if(this._getType(e)!==nM.undefined){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.undefined,received:t.parsedType}),nK}return nV(e.data)}}ip.create=e=>new ip({typeName:eN.ZodUndefined,...nQ(e)});class ih extends n0{_parse(e){if(this._getType(e)!==nM.null){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.null,received:t.parsedType}),nK}return nV(e.data)}}ih.create=e=>new ih({typeName:eN.ZodNull,...nQ(e)});class im extends n0{constructor(){super(...arguments),this._any=!0}_parse(e){return nV(e.data)}}im.create=e=>new im({typeName:eN.ZodAny,...nQ(e)});class ig extends n0{constructor(){super(...arguments),this._unknown=!0}_parse(e){return nV(e.data)}}ig.create=e=>new ig({typeName:eN.ZodUnknown,...nQ(e)});class iv extends n0{_parse(e){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.never,received:t.parsedType}),nK}}iv.create=e=>new iv({typeName:eN.ZodNever,...nQ(e)});class iy extends n0{_parse(e){if(this._getType(e)!==nM.undefined){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.void,received:t.parsedType}),nK}return nV(e.data)}}iy.create=e=>new iy({typeName:eN.ZodVoid,...nQ(e)});class ib extends n0{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==nM.array)return nL(t,{code:nN.invalid_type,expected:nM.array,received:t.parsedType}),nK;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,i=t.data.lengthn.maxLength.value&&(nL(t,{code:nN.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new nX(t,e,t.path,r)))).then(e=>nz.mergeArray(r,e));let i=[...t.data].map((e,r)=>n.type._parseSync(new nX(t,e,t.path,r)));return nz.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new ib({...this._def,minLength:{value:e,message:eB.toString(t)}})}max(e,t){return new ib({...this._def,maxLength:{value:e,message:eB.toString(t)}})}length(e,t){return new ib({...this._def,exactLength:{value:e,message:eB.toString(t)}})}nonempty(e){return this.min(1,e)}}ib.create=(e,t)=>new ib({type:e,minLength:null,maxLength:null,exactLength:null,typeName:eN.ZodArray,...nQ(t)});class ix extends n0{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=e_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==nM.object){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.object,received:t.parsedType}),nK}let{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof iv&&"strip"===this._def.unknownKeys))for(let e in r.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=n[e],i=r.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new nX(r,i,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof iv){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(nL(r,{code:nN.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let n=r.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new nX(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>nz.mergeObjectSync(t,e)):nz.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return eB.errToObj,new ix({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{var n,i,a,o;let s=null!==(a=null===(i=(n=this._def).errorMap)||void 0===i?void 0:i.call(n,t,r).message)&&void 0!==a?a:r.defaultError;return"unrecognized_keys"===t.code?{message:null!==(o=eB.errToObj(e).message)&&void 0!==o?o:s}:{message:s}}}:{}})}strip(){return new ix({...this._def,unknownKeys:"strip"})}passthrough(){return new ix({...this._def,unknownKeys:"passthrough"})}extend(e){return new ix({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ix({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:eN.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ix({...this._def,catchall:e})}pick(e){let t={};return e_.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new ix({...this._def,shape:()=>t})}omit(e){let t={};return e_.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new ix({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof ix){let r={};for(let n in t.shape){let i=t.shape[n];r[n]=iO.create(e(i))}return new ix({...t._def,shape:()=>r})}return t instanceof ib?new ib({...t._def,type:e(t.element)}):t instanceof iO?iO.create(e(t.unwrap())):t instanceof i$?i$.create(e(t.unwrap())):t instanceof iP?iP.create(t.items.map(t=>e(t))):t}(this)}partial(e){let t={};return e_.objectKeys(this.shape).forEach(r=>{let n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}),new ix({...this._def,shape:()=>t})}required(e){let t={};return e_.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof iO;)e=e._def.innerType;t[r]=e}}),new ix({...this._def,shape:()=>t})}keyof(){return iM(e_.objectKeys(this.shape))}}ix.create=(e,t)=>new ix({shape:()=>e,unknownKeys:"strip",catchall:iv.create(),typeName:eN.ZodObject,...nQ(t)}),ix.strictCreate=(e,t)=>new ix({shape:()=>e,unknownKeys:"strict",catchall:iv.create(),typeName:eN.ZodObject,...nQ(t)}),ix.lazycreate=(e,t)=>new ix({shape:e,unknownKeys:"strip",catchall:iv.create(),typeName:eN.ZodObject,...nQ(t)});class iw extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new nI(e.ctx.common.issues));return nL(t,{code:nN.invalid_union,unionErrors:r}),nK});{let e;let n=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=n.map(e=>new nI(e));return nL(t,{code:nN.invalid_union,unionErrors:i}),nK}}get options(){return this._def.options}}iw.create=(e,t)=>new iw({options:e,typeName:eN.ZodUnion,...nQ(t)});let iC=e=>{if(e instanceof iD)return iC(e.schema);if(e instanceof iR)return iC(e.innerType());if(e instanceof iB)return[e.value];if(e instanceof ij)return e.options;if(e instanceof iN)return e_.objectValues(e.enum);if(e instanceof iF)return iC(e._def.innerType);if(e instanceof ip)return[void 0];else if(e instanceof ih)return[null];else if(e instanceof iO)return[void 0,...iC(e.unwrap())];else if(e instanceof i$)return[null,...iC(e.unwrap())];else if(e instanceof iW)return iC(e.unwrap());else if(e instanceof iU)return iC(e.unwrap());else if(e instanceof iL)return iC(e._def.innerType);else return[]};class ik extends n0{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==nM.object)return nL(t,{code:nN.invalid_type,expected:nM.object,received:t.parsedType}),nK;let r=this.discriminator,n=t.data[r],i=this.optionsMap.get(n);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(nL(t,{code:nN.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),nK)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let r of t){let t=iC(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,r)}}return new ik({typeName:eN.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...nQ(r)})}}class iS extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(nU(e)||nU(n))return nK;let i=function e(t,r){let n=nj(t),i=nj(r);if(t===r)return{valid:!0,data:t};if(n===nM.object&&i===nM.object){let n=e_.objectKeys(r),i=e_.objectKeys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...r};for(let n of i){let i=e(t[n],r[n]);if(!i.valid)return{valid:!1};a[n]=i.data}return{valid:!0,data:a}}if(n===nM.array&&i===nM.array){if(t.length!==r.length)return{valid:!1};let n=[];for(let i=0;in(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}iS.create=(e,t,r)=>new iS({left:e,right:t,typeName:eN.ZodIntersection,...nQ(r)});class iP extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.array)return nL(r,{code:nN.invalid_type,expected:nM.array,received:r.parsedType}),nK;if(r.data.lengththis._def.items.length&&(nL(r,{code:nN.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new nX(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>nz.mergeArray(t,e)):nz.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new iP({...this._def,rest:e})}}iP.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new iP({items:e,typeName:eN.ZodTuple,rest:null,...nQ(t)})};class iE extends n0{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.object)return nL(r,{code:nN.invalid_type,expected:nM.object,received:r.parsedType}),nK;let n=[],i=this._def.keyType,a=this._def.valueType;for(let e in r.data)n.push({key:i._parse(new nX(r,e,r.path,e)),value:a._parse(new nX(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?nz.mergeObjectAsync(t,n):nz.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return new iE(t instanceof n0?{keyType:e,valueType:t,typeName:eN.ZodRecord,...nQ(r)}:{keyType:io.create(),valueType:e,typeName:eN.ZodRecord,...nQ(t)})}}class iA extends n0{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.map)return nL(r,{code:nN.invalid_type,expected:nM.map,received:r.parsedType}),nK;let n=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new nX(r,e,r.path,[a,"key"])),value:i._parse(new nX(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let n=await r.key,i=await r.value;if("aborted"===n.status||"aborted"===i.status)return nK;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of a){let n=r.key,i=r.value;if("aborted"===n.status||"aborted"===i.status)return nK;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}}}}iA.create=(e,t,r)=>new iA({valueType:t,keyType:e,typeName:eN.ZodMap,...nQ(r)});class iT extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==nM.set)return nL(r,{code:nN.invalid_type,expected:nM.set,received:r.parsedType}),nK;let n=this._def;null!==n.minSize&&r.data.sizen.maxSize.value&&(nL(r,{code:nN.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let r=new Set;for(let n of e){if("aborted"===n.status)return nK;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}let o=[...r.data.values()].map((e,t)=>i._parse(new nX(r,e,r.path,t)));return r.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new iT({...this._def,minSize:{value:e,message:eB.toString(t)}})}max(e,t){return new iT({...this._def,maxSize:{value:e,message:eB.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}iT.create=(e,t)=>new iT({valueType:e,minSize:null,maxSize:null,typeName:eN.ZodSet,...nQ(t)});class i_ extends n0{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==nM.function)return nL(t,{code:nN.invalid_type,expected:nM.function,received:t.parsedType}),nK;function r(e,r){return nF({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n$(),nR].filter(e=>!!e),issueData:{code:nN.invalid_arguments,argumentsError:r}})}function n(e,r){return nF({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n$(),nR].filter(e=>!!e),issueData:{code:nN.invalid_return_type,returnTypeError:r}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof iI){let e=this;return nV(async function(...t){let o=new nI([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(r(t,e)),o}),l=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(l,i).catch(e=>{throw o.addIssue(n(l,e)),o})})}{let e=this;return nV(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new nI([r(t,o.error)]);let s=Reflect.apply(a,this,o.data),l=e._def.returns.safeParse(s,i);if(!l.success)throw new nI([n(s,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new i_({...this._def,args:iP.create(e).rest(ig.create())})}returns(e){return new i_({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new i_({args:e||iP.create([]).rest(ig.create()),returns:t||ig.create(),typeName:eN.ZodFunction,...nQ(r)})}}class iD extends n0{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}iD.create=(e,t)=>new iD({getter:e,typeName:eN.ZodLazy,...nQ(t)});class iB extends n0{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return nL(t,{received:t.data,code:nN.invalid_literal,expected:this._def.value}),nK}return{status:"valid",value:e.data}}get value(){return this._def.value}}function iM(e,t){return new ij({values:e,typeName:eN.ZodEnum,...nQ(t)})}iB.create=(e,t)=>new iB({value:e,typeName:eN.ZodLiteral,...nQ(t)});class ij extends n0{constructor(){super(...arguments),eM.set(this,void 0)}_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return nL(t,{expected:e_.joinValues(r),received:t.parsedType,code:nN.invalid_type}),nK}if(nq(this,eM,"f")||nJ(this,eM,new Set(this._def.values),"f"),!nq(this,eM,"f").has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return nL(t,{received:t.data,code:nN.invalid_enum_value,options:r}),nK}return nV(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ij.create(e,{...this._def,...t})}exclude(e,t=this._def){return ij.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}eM=new WeakMap,ij.create=iM;class iN extends n0{constructor(){super(...arguments),ej.set(this,void 0)}_parse(e){let t=e_.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==nM.string&&r.parsedType!==nM.number){let e=e_.objectValues(t);return nL(r,{expected:e_.joinValues(e),received:r.parsedType,code:nN.invalid_type}),nK}if(nq(this,ej,"f")||nJ(this,ej,new Set(e_.getValidEnumValues(this._def.values)),"f"),!nq(this,ej,"f").has(e.data)){let e=e_.objectValues(t);return nL(r,{received:r.data,code:nN.invalid_enum_value,options:e}),nK}return nV(e.data)}get enum(){return this._def.values}}ej=new WeakMap,iN.create=(e,t)=>new iN({values:e,typeName:eN.ZodNativeEnum,...nQ(t)});class iI extends n0{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==nM.promise&&!1===t.common.async?(nL(t,{code:nN.invalid_type,expected:nM.promise,received:t.parsedType}),nK):nV((t.parsedType===nM.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}iI.create=(e,t)=>new iI({type:e,typeName:eN.ZodPromise,...nQ(t)});class iR extends n0{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===eN.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:e=>{nL(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===n.type){let e=n.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return nK;let n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?nK:"dirty"===n.status||"dirty"===t.value?nW(n.value):n});{if("aborted"===t.value)return nK;let n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?nK:"dirty"===n.status||"dirty"===t.value?nW(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?nK:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?nK:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}}if("transform"===n.type){if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>nZ(e)?Promise.resolve(n.transform(e.value,i)).then(e=>({status:t.value,value:e})):e);{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!nZ(e))return e;let a=n.transform(e.value,i);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}}e_.assertNever(n)}}iR.create=(e,t,r)=>new iR({schema:e,typeName:eN.ZodEffects,effect:t,...nQ(r)}),iR.createWithPreprocess=(e,t,r)=>new iR({schema:t,effect:{type:"preprocess",transform:e},typeName:eN.ZodEffects,...nQ(r)});class iO extends n0{_parse(e){return this._getType(e)===nM.undefined?nV(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}iO.create=(e,t)=>new iO({innerType:e,typeName:eN.ZodOptional,...nQ(t)});class i$ extends n0{_parse(e){return this._getType(e)===nM.null?nV(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}i$.create=(e,t)=>new i$({innerType:e,typeName:eN.ZodNullable,...nQ(t)});class iF extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===nM.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}iF.create=(e,t)=>new iF({innerType:e,typeName:eN.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...nQ(t)});class iL extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return nH(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new nI(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new nI(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}iL.create=(e,t)=>new iL({innerType:e,typeName:eN.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...nQ(t)});class iz extends n0{_parse(e){if(this._getType(e)!==nM.nan){let t=this._getOrReturnCtx(e);return nL(t,{code:nN.invalid_type,expected:nM.nan,received:t.parsedType}),nK}return{status:"valid",value:e.data}}}iz.create=e=>new iz({typeName:eN.ZodNaN,...nQ(e)});let iK=Symbol("zod_brand");class iW extends n0{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class iV extends n0{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?nK:"dirty"===e.status?(t.dirty(),nW(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?nK:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new iV({in:e,out:t,typeName:eN.ZodPipeline})}}class iU extends n0{_parse(e){let t=this._def.innerType._parse(e),r=e=>(nZ(e)&&(e.value=Object.freeze(e.value)),e);return nH(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}function iG(e,t={},r){return e?im.create().superRefine((n,i)=>{var a,o;if(!e(n)){let e="function"==typeof t?t(n):"string"==typeof t?{message:t}:t,s=null===(o=null!==(a=e.fatal)&&void 0!==a?a:r)||void 0===o||o;i.addIssue({code:"custom",..."string"==typeof e?{message:e}:e,fatal:s})}}):im.create()}iU.create=(e,t)=>new iU({innerType:e,typeName:eN.ZodReadonly,...nQ(t)});let iZ={object:ix.lazycreate};(P=eN||(eN={})).ZodString="ZodString",P.ZodNumber="ZodNumber",P.ZodNaN="ZodNaN",P.ZodBigInt="ZodBigInt",P.ZodBoolean="ZodBoolean",P.ZodDate="ZodDate",P.ZodSymbol="ZodSymbol",P.ZodUndefined="ZodUndefined",P.ZodNull="ZodNull",P.ZodAny="ZodAny",P.ZodUnknown="ZodUnknown",P.ZodNever="ZodNever",P.ZodVoid="ZodVoid",P.ZodArray="ZodArray",P.ZodObject="ZodObject",P.ZodUnion="ZodUnion",P.ZodDiscriminatedUnion="ZodDiscriminatedUnion",P.ZodIntersection="ZodIntersection",P.ZodTuple="ZodTuple",P.ZodRecord="ZodRecord",P.ZodMap="ZodMap",P.ZodSet="ZodSet",P.ZodFunction="ZodFunction",P.ZodLazy="ZodLazy",P.ZodLiteral="ZodLiteral",P.ZodEnum="ZodEnum",P.ZodEffects="ZodEffects",P.ZodNativeEnum="ZodNativeEnum",P.ZodOptional="ZodOptional",P.ZodNullable="ZodNullable",P.ZodDefault="ZodDefault",P.ZodCatch="ZodCatch",P.ZodPromise="ZodPromise",P.ZodBranded="ZodBranded",P.ZodPipeline="ZodPipeline",P.ZodReadonly="ZodReadonly";let iH=io.create,iq=is.create,iJ=iz.create,iX=il.create,iY=iu.create,iQ=ic.create,i0=id.create,i1=ip.create,i4=ih.create,i3=im.create,i2=ig.create,i5=iv.create,i6=iy.create,i9=ib.create,i8=ix.create,i7=ix.strictCreate,ae=iw.create,at=ik.create,ar=iS.create,an=iP.create,ai=iE.create,aa=iA.create,ao=iT.create,as=i_.create,al=iD.create,au=iB.create,ac=ij.create,ad=iN.create,ap=iI.create,af=iR.create,ah=iO.create,am=i$.create,ag=iR.createWithPreprocess,av=iV.create;var ay=Object.freeze({__proto__:null,defaultErrorMap:nR,setErrorMap:function(e){nO=e},getErrorMap:n$,makeIssue:nF,EMPTY_PATH:[],addIssueToContext:nL,ParseStatus:nz,INVALID:nK,DIRTY:nW,OK:nV,isAborted:nU,isDirty:nG,isValid:nZ,isAsync:nH,get util(){return e_},get objectUtil(){return eD},ZodParsedType:nM,getParsedType:nj,ZodType:n0,datetimeRegex:ia,ZodString:io,ZodNumber:is,ZodBigInt:il,ZodBoolean:iu,ZodDate:ic,ZodSymbol:id,ZodUndefined:ip,ZodNull:ih,ZodAny:im,ZodUnknown:ig,ZodNever:iv,ZodVoid:iy,ZodArray:ib,ZodObject:ix,ZodUnion:iw,ZodDiscriminatedUnion:ik,ZodIntersection:iS,ZodTuple:iP,ZodRecord:iE,ZodMap:iA,ZodSet:iT,ZodFunction:i_,ZodLazy:iD,ZodLiteral:iB,ZodEnum:ij,ZodNativeEnum:iN,ZodPromise:iI,ZodEffects:iR,ZodTransformer:iR,ZodOptional:iO,ZodNullable:i$,ZodDefault:iF,ZodCatch:iL,ZodNaN:iz,BRAND:iK,ZodBranded:iW,ZodPipeline:iV,ZodReadonly:iU,custom:iG,Schema:n0,ZodSchema:n0,late:iZ,get ZodFirstPartyTypeKind(){return eN},coerce:{string:e=>io.create({...e,coerce:!0}),number:e=>is.create({...e,coerce:!0}),boolean:e=>iu.create({...e,coerce:!0}),bigint:e=>il.create({...e,coerce:!0}),date:e=>ic.create({...e,coerce:!0})},any:i3,array:i9,bigint:iX,boolean:iY,date:iQ,discriminatedUnion:at,effect:af,enum:ac,function:as,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>iG(t=>t instanceof e,t),intersection:ar,lazy:al,literal:au,map:aa,nan:iJ,nativeEnum:ad,never:i5,null:i4,nullable:am,number:iq,object:i8,oboolean:()=>iY().optional(),onumber:()=>iq().optional(),optional:ah,ostring:()=>iH().optional(),pipeline:av,preprocess:ag,promise:ap,record:ai,set:ao,strictObject:i7,string:iH,symbol:i0,transformer:af,tuple:an,undefined:i1,union:ae,unknown:i2,void:i6,NEVER:nK,ZodIssueCode:nN,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:nI});function ab(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function ax(e,t,r,n,i){e[t]=r,ab(e,t,n,i)}let aw=(e,t)=>aF(e.innerType._def,t),aC=(e,t)=>{let r={type:"integer",format:"unix-time"};if("openApi3"===t.target)return r;for(let n of e.checks)switch(n.kind){case"min":ax(r,"minimum",n.value,n.message,t);break;case"max":ax(r,"maximum",n.value,n.message,t)}return r},ak=e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e,aS={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===a&&(a=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),a),base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function aP(e,t){let r={type:"string"};function n(e){return"escape"===t.patternStrategy?aE(e):e}if(e.checks)for(let i of e.checks)switch(i.kind){case"min":ax(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t);break;case"max":ax(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":aA(r,"email",i.message,t);break;case"format:idn-email":aA(r,"idn-email",i.message,t);break;case"pattern:zod":aT(r,aS.email,i.message,t)}break;case"url":aA(r,"uri",i.message,t);break;case"uuid":aA(r,"uuid",i.message,t);break;case"regex":aT(r,i.regex,i.message,t);break;case"cuid":aT(r,aS.cuid,i.message,t);break;case"cuid2":aT(r,aS.cuid2,i.message,t);break;case"startsWith":aT(r,RegExp(`^${n(i.value)}`),i.message,t);break;case"endsWith":aT(r,RegExp(`${n(i.value)}$`),i.message,t);break;case"datetime":aA(r,"date-time",i.message,t);break;case"date":aA(r,"date",i.message,t);break;case"time":aA(r,"time",i.message,t);break;case"duration":aA(r,"duration",i.message,t);break;case"length":ax(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,i.value):i.value,i.message,t),ax(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,i.value):i.value,i.message,t);break;case"includes":aT(r,RegExp(n(i.value)),i.message,t);break;case"ip":"v6"!==i.version&&aA(r,"ipv4",i.message,t),"v4"!==i.version&&aA(r,"ipv6",i.message,t);break;case"emoji":aT(r,aS.emoji,i.message,t);break;case"ulid":aT(r,aS.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":aA(r,"binary",i.message,t);break;case"contentEncoding:base64":ax(r,"contentEncoding","base64",i.message,t);break;case"pattern:zod":aT(r,aS.base64,i.message,t)}break;case"nanoid":aT(r,aS.nanoid,i.message,t)}return r}let aE=e=>Array.from(e).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),aA=(e,t,r,n)=>{e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ax(e,"format",t,r,n)},aT=(e,t,r,n)=>{e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:a_(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ax(e,"pattern",a_(t,n),r,n)},a_=(e,t)=>{let r="function"==typeof e?e():e;if(!t.applyRegexFlags||!r.flags)return r.source;let n={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},i=n.i?r.source.toLowerCase():r.source,a="",o=!1,s=!1,l=!1;for(let e=0;e({...r,[n]:aF(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??{}}),{}),additionalProperties:!1};let r={type:"object",additionalProperties:aF(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===eN.ZodString&&e.keyType._def.checks?.length){let n=Object.entries(aP(e.keyType._def,t)).reduce((e,[t,r])=>"type"===t?e:{...e,[t]:r},{});return{...r,propertyNames:n}}return e.keyType?._def.typeName===eN.ZodEnum?{...r,propertyNames:{enum:e.keyType._def.values}}:r}let aB={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},aM=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>aF(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0},aj=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return aF(e.innerType._def,t);let r=aF(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:{}},r]}:{}},aN=(e,t)=>{if("input"===t.pipeStrategy)return aF(e.in._def,t);if("output"===t.pipeStrategy)return aF(e.out._def,t);let r=aF(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=aF(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(e=>void 0!==e)}},aI=(e,t)=>aF(e.innerType._def,t),aR=Symbol("Let zodToJsonSchema decide on which parser to use"),aO={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},a$=e=>"string"==typeof e?{...aO,basePath:["#"],definitions:{},name:e}:{...aO,basePath:["#"],definitions:{},...e};function aF(e,t,r=!1){let n=t.seen.get(e);if(t.override){let i=t.override?.(e,t,n,r);if(i!==aR)return i}if(n&&!r){let e=aL(n,t);if(void 0!==e)return"$ref"in e&&t.seenRefs.add(e.$ref),e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=aK(e,e.typeName,t,r);return a&&aW(e,t,a),i.jsonSchema=a,a}let aL=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"extract-to-root":let r=e.path.slice(t.basePath.length+1).join("_");return r!==t.name&&"duplicate-ref"===t.nameStrategy&&(t.definitions[r]=e.def),{$ref:[...t.basePath,t.definitionPath,r].join("/")};case"relative":return{$ref:az(t.currentPath,e.path)};case"none":case"seen":if(e.path.lengtht.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{};return"seen"===t.$refStrategy?{}:void 0}},az=(e,t)=>{let r=0;for(;r{switch(t){case eN.ZodString:return aP(e,r);case eN.ZodNumber:return function(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",ab(r,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?ax(r,"minimum",n.value,n.message,t):ax(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ax(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?ax(r,"maximum",n.value,n.message,t):ax(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ax(r,"maximum",n.value,n.message,t));break;case"multipleOf":ax(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case eN.ZodObject:return function(e,t){let r={type:"object",...Object.entries(e.shape()).reduce((e,[r,n])=>{if(void 0===n||void 0===n._def)return e;let i=aF(n._def,{...t,currentPath:[...t.currentPath,"properties",r],propertyPath:[...t.currentPath,"properties",r]});return void 0===i?e:{properties:{...e.properties,[r]:i},required:n.isOptional()&&!t.openaiStrictMode?e.required:[...e.required,r]}},{properties:{},required:[]}),additionalProperties:"strict"===t.removeAdditionalStrategy?"ZodNever"===e.catchall._def.typeName?"strict"!==e.unknownKeys:aF(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:"ZodNever"===e.catchall._def.typeName?"passthrough"===e.unknownKeys:aF(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0};return r.required.length||delete r.required,r}(e,r);case eN.ZodBigInt:return function(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?ax(r,"minimum",n.value,n.message,t):ax(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ax(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?ax(r,"maximum",n.value,n.message,t):ax(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ax(r,"maximum",n.value,n.message,t));break;case"multipleOf":ax(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case eN.ZodBoolean:return{type:"boolean"};case eN.ZodDate:return function e(t,r,n){let i=n??r.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((n,i)=>e(t,r,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return aC(t,r)}}(e,r);case eN.ZodUndefined:return{not:{}};case eN.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case eN.ZodArray:return function(e,t){let r={type:"array"};return e.type?._def?.typeName!==eN.ZodAny&&(r.items=aF(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&ax(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&ax(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(ax(r,"minItems",e.exactLength.value,e.exactLength.message,t),ax(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}(e,r);case eN.ZodUnion:case eN.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return aM(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in aB&&(!e._def.checks||!e._def.checks.length))){let e=r.reduce((e,t)=>{let r=aB[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(r.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=r.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===r.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:r.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(r.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:r.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return aM(e,t)}(e,r);case eN.ZodIntersection:return function(e,t){let r=[aF(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),aF(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e),n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(e=>{if(ak(e))i.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...n}=e;t=n}else n=void 0;i.push(t)}}),i.length?{allOf:i,...n}:void 0}(e,r);case eN.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>aF(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:aF(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>aF(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case eN.ZodRecord:return aD(e,r);case eN.ZodLiteral:return function(e,t){let r=typeof e.value;return"bigint"!==r&&"number"!==r&&"boolean"!==r&&"string"!==r?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===r?"integer":r,enum:[e.value]}:{type:"bigint"===r?"integer":r,const:e.value}}(e,r);case eN.ZodEnum:return{type:"string",enum:[...e.values]};case eN.ZodNativeEnum:return function(e){let t=e.values,r=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),n=Array.from(new Set(r.map(e=>typeof e)));return{type:1===n.length?"string"===n[0]?"string":"number":["string","number"],enum:r}}(e);case eN.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target||"property"===t.nullableStrategy?{type:aB[e.innerType._def.typeName],nullable:!0}:{type:[aB[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){let r=aF(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let r=aF(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case eN.ZodOptional:return aj(e,r);case eN.ZodMap:return"record"===r.mapStrategy?aD(e,r):{type:"array",maxItems:125,items:{type:"array",items:[aF(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||{},aF(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}};case eN.ZodSet:return function(e,t){let r={type:"array",uniqueItems:!0,items:aF(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ax(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ax(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}(e,r);case eN.ZodLazy:return aF(e.getter()._def,r);case eN.ZodPromise:return aF(e.type._def,r);case eN.ZodNaN:case eN.ZodNever:return{not:{}};case eN.ZodEffects:return"input"===r.effectStrategy?aF(e.schema._def,r,n):{};case eN.ZodAny:case eN.ZodUnknown:return{};case eN.ZodDefault:return{...aF(e.innerType._def,r),default:e.defaultValue()};case eN.ZodBranded:return aF(e.type._def,r);case eN.ZodReadonly:return aI(e,r);case eN.ZodCatch:return aw(e,r);case eN.ZodPipeline:return aN(e,r);case eN.ZodFunction:case eN.ZodVoid:case eN.ZodSymbol:default:return}},aW=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r),aV=e=>"_def"in e?e._def:e,aU=e=>{let t=a$(e),r=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(t.definitions).map(([e,r])=>[aV(r),{def:aV(r),path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},aG=(e,t)=>{let r=aU(t),n="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,i=aF(e._def,void 0===n?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??{},a="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==a&&(i.title=a);let o=(()=>{if(function(e){if(!e)return!0;for(let t in e)return!1;return!0}(r.definitions))return;let e={},t=new Set;for(let n=0;n<500;n++){let n=Object.entries(r.definitions).filter(([e])=>!t.has(e));if(0===n.length)break;for(let[i,a]of n)e[i]=aF(aV(a),{...r,currentPath:[...r.basePath,r.definitionPath,i]},!0)??{},t.add(i)}return e})(),s=void 0===n?o?{...i,[r.definitionPath]:o}:i:"duplicate-ref"===r.nameStrategy?{...i,...o||r.seenRefs.size?{[r.definitionPath]:{...o,...r.seenRefs.size?{[n]:i}:void 0}}:void 0}:{$ref:[..."relative"===r.$refStrategy?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...o,[n]:i}};return"jsonSchema7"===r.target?s.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"===r.target&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),s};function aZ(e,t,r){return function(e,t){let r={...e};return Object.defineProperties(r,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),r}({type:"json_schema",json_schema:{...r,name:t,strict:!0,schema:aG(e,{openaiStrictMode:!0,name:{name:t}.name,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property"})}},t=>e.parse(JSON.parse(t)))}class aH extends nB{constructor(e,t,r){nm.debug("[TranslatorStructuredBase]","Structured Mode:",r.structuredMode);let n={};n.stream=r.createChatCompletionRequest?.stream,r.prefixNumber&&nm.warn("[TranslatorStructuredBase]","--no-prefix-number must be used in structured mode, overriding."),r.prefixNumber=!1,super(e,t,r),this.optionsBackup=n}async translateBaseFallback(e,t){if(!t||!(t instanceof no))return nm.warn("[TranslatorStructuredBase]","Fallback to base mode"),await super.translatePrompt(e)}async streamParse(e,t,r=!1){if(!e.stream)return await this.services.openai.beta.chat.completions.parse({...e,response_format:aZ(t.structure,t.name),stream:!1});{let n=this.services.openai.beta.chat.completions.stream({...e,response_format:aZ(t.structure,t.name),stream:!0,stream_options:{include_usage:!0}});return this.streamController=n.controller,r?this.jsonStreamParse(n):n.on("content.delta",e=>{this.services.onStreamChunk?.(e.delta)}),await n.done(),this.services.onStreamEnd?.(),await n.finalChatCompletion()}}jsonStreamParse(e){}}var aq=r(3090),aJ=r(7617);class aX extends aH{constructor(e,t,r){super(e,t,r)}async translatePrompt(e){let t={role:"user",content:JSON.stringify({inputs:e})},r=[...this.systemInstruction?[{role:"system",content:`${this.systemInstruction}`}]:[],...this.options.initialPrompts,...this.promptContext,t],n=this.getMaxToken(e),i=ay.object({outputs:ay.array(ay.string())});try{let t=0,a=0;t=Date.now(),await this.services.cooler?.cool();let o=await this.streamParse({messages:r,...this.options.createChatCompletionRequest,stream:this.options.createChatCompletionRequest.stream,max_tokens:n},{structure:i,name:"translation_array"},!0);a=Date.now();let s=o.choices[0].message,l=async t=>{if(1===e.length&&t.refusal&&this.options.fallbackModel){nm.debug("[TranslatorStructuredArray] Refusal Fallback",this.options.fallbackModel);let e={...this.options.createChatCompletionRequest};e.model=this.options.fallbackModel,t=(await this.streamParse({messages:r,...e,stream:e.stream,max_tokens:n},{structure:i,name:"translation_array"})).choices[0].message}return t.refusal?[t.refusal]:t.parsed.outputs},u=await l(s),c=new n_(u,o.usage?.prompt_tokens,o.usage?.completion_tokens,o.usage?.total_tokens,o.usage?.prompt_tokens_details?.cached_tokens,o.choices[0].message.refusal);return this.promptTokensUsed+=c.promptTokens,this.completionTokensUsed+=c.completionTokens,this.tokensProcessTimeMs+=a-t,c}catch(t){return nm.error("[TranslatorStructuredArray]",`Error ${t?.constructor?.name}`,t?.message),await this.translateBaseFallback(e,t)}}getContextLines(e,t){return"user"===t?JSON.stringify({inputs:e}):JSON.stringify({outputs:e})}jsonStreamParse(e){this.services.onStreamChunk?.("\n");let t=new aq.PassThrough,r="";e.on("content.delta",e=>{r+=e.delta,t.write(e.delta),r&&(this.services.onStreamChunk?.(r),r="")}),e.on("content.done",()=>{t.end(),this.services.onClearLine?.()});let n=aJ.parse(["outputs",!0]);n.on("data",e=>{try{this.services.onClearLine?.(),r=`${e} +]`;continue}a+=i[e],"\\"===i[e]?o=!0:s&&"]"===i[e]?s=!1:s||"["!==i[e]||(s=!0)}try{new RegExp(a)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),r.source}return a};function aD(e,t){if("openApi3"===t.target&&e.keyType?._def.typeName===eN.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,n)=>({...r,[n]:aF(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??{}}),{}),additionalProperties:!1};let r={type:"object",additionalProperties:aF(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===eN.ZodString&&e.keyType._def.checks?.length){let n=Object.entries(aP(e.keyType._def,t)).reduce((e,[t,r])=>"type"===t?e:{...e,[t]:r},{});return{...r,propertyNames:n}}return e.keyType?._def.typeName===eN.ZodEnum?{...r,propertyNames:{enum:e.keyType._def.values}}:r}let aB={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},aM=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>aF(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0},aj=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return aF(e.innerType._def,t);let r=aF(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:{}},r]}:{}},aN=(e,t)=>{if("input"===t.pipeStrategy)return aF(e.in._def,t);if("output"===t.pipeStrategy)return aF(e.out._def,t);let r=aF(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=aF(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(e=>void 0!==e)}},aI=(e,t)=>aF(e.innerType._def,t),aR=Symbol("Let zodToJsonSchema decide on which parser to use"),aO={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},a$=e=>"string"==typeof e?{...aO,basePath:["#"],definitions:{},name:e}:{...aO,basePath:["#"],definitions:{},...e};function aF(e,t,r=!1){let n=t.seen.get(e);if(t.override){let i=t.override?.(e,t,n,r);if(i!==aR)return i}if(n&&!r){let e=aL(n,t);if(void 0!==e)return"$ref"in e&&t.seenRefs.add(e.$ref),e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=aK(e,e.typeName,t,r);return a&&aW(e,t,a),i.jsonSchema=a,a}let aL=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"extract-to-root":let r=e.path.slice(t.basePath.length+1).join("_");return r!==t.name&&"duplicate-ref"===t.nameStrategy&&(t.definitions[r]=e.def),{$ref:[...t.basePath,t.definitionPath,r].join("/")};case"relative":return{$ref:az(t.currentPath,e.path)};case"none":case"seen":if(e.path.lengtht.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{};return"seen"===t.$refStrategy?{}:void 0}},az=(e,t)=>{let r=0;for(;r{switch(t){case eN.ZodString:return aP(e,r);case eN.ZodNumber:return function(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",ab(r,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?ax(r,"minimum",n.value,n.message,t):ax(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ax(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?ax(r,"maximum",n.value,n.message,t):ax(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ax(r,"maximum",n.value,n.message,t));break;case"multipleOf":ax(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case eN.ZodObject:return function(e,t){let r={type:"object",...Object.entries(e.shape()).reduce((e,[r,n])=>{if(void 0===n||void 0===n._def)return e;let i=aF(n._def,{...t,currentPath:[...t.currentPath,"properties",r],propertyPath:[...t.currentPath,"properties",r]});return void 0===i?e:{properties:{...e.properties,[r]:i},required:n.isOptional()&&!t.openaiStrictMode?e.required:[...e.required,r]}},{properties:{},required:[]}),additionalProperties:"strict"===t.removeAdditionalStrategy?"ZodNever"===e.catchall._def.typeName?"strict"!==e.unknownKeys:aF(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:"ZodNever"===e.catchall._def.typeName?"passthrough"===e.unknownKeys:aF(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0};return r.required.length||delete r.required,r}(e,r);case eN.ZodBigInt:return function(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?ax(r,"minimum",n.value,n.message,t):ax(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),ax(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?ax(r,"maximum",n.value,n.message,t):ax(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),ax(r,"maximum",n.value,n.message,t));break;case"multipleOf":ax(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case eN.ZodBoolean:return{type:"boolean"};case eN.ZodDate:return function e(t,r,n){let i=n??r.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((n,i)=>e(t,r,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return aC(t,r)}}(e,r);case eN.ZodUndefined:return{not:{}};case eN.ZodNull:return"openApi3"===r.target?{enum:["null"],nullable:!0}:{type:"null"};case eN.ZodArray:return function(e,t){let r={type:"array"};return e.type?._def?.typeName!==eN.ZodAny&&(r.items=aF(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&ax(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&ax(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(ax(r,"minItems",e.exactLength.value,e.exactLength.message,t),ax(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}(e,r);case eN.ZodUnion:case eN.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return aM(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in aB&&(!e._def.checks||!e._def.checks.length))){let e=r.reduce((e,t)=>{let r=aB[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(r.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=r.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===r.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:r.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(r.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:r.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return aM(e,t)}(e,r);case eN.ZodIntersection:return function(e,t){let r=[aF(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),aF(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e),n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(e=>{if(ak(e))i.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...n}=e;t=n}else n=void 0;i.push(t)}}),i.length?{allOf:i,...n}:void 0}(e,r);case eN.ZodTuple:return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,t)=>aF(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:aF(e.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,t)=>aF(e._def,{...r,currentPath:[...r.currentPath,"items",`${t}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])};case eN.ZodRecord:return aD(e,r);case eN.ZodLiteral:return function(e,t){let r=typeof e.value;return"bigint"!==r&&"number"!==r&&"boolean"!==r&&"string"!==r?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===r?"integer":r,enum:[e.value]}:{type:"bigint"===r?"integer":r,const:e.value}}(e,r);case eN.ZodEnum:return{type:"string",enum:[...e.values]};case eN.ZodNativeEnum:return function(e){let t=e.values,r=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),n=Array.from(new Set(r.map(e=>typeof e)));return{type:1===n.length?"string"===n[0]?"string":"number":["string","number"],enum:r}}(e);case eN.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target||"property"===t.nullableStrategy?{type:aB[e.innerType._def.typeName],nullable:!0}:{type:[aB[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){let r=aF(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}let r=aF(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case eN.ZodOptional:return aj(e,r);case eN.ZodMap:return"record"===r.mapStrategy?aD(e,r):{type:"array",maxItems:125,items:{type:"array",items:[aF(e.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||{},aF(e.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}};case eN.ZodSet:return function(e,t){let r={type:"array",uniqueItems:!0,items:aF(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ax(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ax(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}(e,r);case eN.ZodLazy:return aF(e.getter()._def,r);case eN.ZodPromise:return aF(e.type._def,r);case eN.ZodNaN:case eN.ZodNever:return{not:{}};case eN.ZodEffects:return"input"===r.effectStrategy?aF(e.schema._def,r,n):{};case eN.ZodAny:case eN.ZodUnknown:return{};case eN.ZodDefault:return{...aF(e.innerType._def,r),default:e.defaultValue()};case eN.ZodBranded:return aF(e.type._def,r);case eN.ZodReadonly:return aI(e,r);case eN.ZodCatch:return aw(e,r);case eN.ZodPipeline:return aN(e,r);case eN.ZodFunction:case eN.ZodVoid:case eN.ZodSymbol:default:return}},aW=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r),aV=e=>"_def"in e?e._def:e,aU=e=>{let t=a$(e),r=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(t.definitions).map(([e,r])=>[aV(r),{def:aV(r),path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},aG=(e,t)=>{let r=aU(t),n="string"==typeof t?t:t?.nameStrategy==="title"?void 0:t?.name,i=aF(e._def,void 0===n?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??{},a="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==a&&(i.title=a);let o=(()=>{if(function(e){if(!e)return!0;for(let t in e)return!1;return!0}(r.definitions))return;let e={},t=new Set;for(let n=0;n<500;n++){let n=Object.entries(r.definitions).filter(([e])=>!t.has(e));if(0===n.length)break;for(let[i,a]of n)e[i]=aF(aV(a),{...r,currentPath:[...r.basePath,r.definitionPath,i]},!0)??{},t.add(i)}return e})(),s=void 0===n?o?{...i,[r.definitionPath]:o}:i:"duplicate-ref"===r.nameStrategy?{...i,...o||r.seenRefs.size?{[r.definitionPath]:{...o,...r.seenRefs.size?{[n]:i}:void 0}}:void 0}:{$ref:[..."relative"===r.$refStrategy?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...o,[n]:i}};return"jsonSchema7"===r.target?s.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"===r.target&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),s};function aZ(e,t,r){return function(e,t){let r={...e};return Object.defineProperties(r,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),r}({type:"json_schema",json_schema:{...r,name:t,strict:!0,schema:aG(e,{openaiStrictMode:!0,name:{name:t}.name,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property"})}},t=>e.parse(JSON.parse(t)))}class aH extends nB{constructor(e,t,r){nm.debug("[TranslatorStructuredBase]","Structured Mode:",r.structuredMode);let n={};n.stream=r.createChatCompletionRequest?.stream,r.prefixNumber&&nm.warn("[TranslatorStructuredBase]","--no-prefix-number must be used in structured mode, overriding."),r.prefixNumber=!1,super(e,t,r),this.optionsBackup=n}async translateBaseFallback(e,t){if(!t||!(t instanceof no))return nm.warn("[TranslatorStructuredBase]","Fallback to base mode"),await super.translatePrompt(e)}async streamParse(e,t,r=!1){if(!e.stream)return await this.services.openai.beta.chat.completions.parse({...e,response_format:aZ(t.structure,t.name),stream:!1});{let n=this.services.openai.beta.chat.completions.stream({...e,response_format:aZ(t.structure,t.name),stream:!0,stream_options:{include_usage:!0}});return this.streamController=n.controller,r?this.jsonStreamParse(n):n.on("content.delta",e=>{this.services.onStreamChunk?.(e.delta)}),await n.done(),this.services.onStreamEnd?.(),await n.finalChatCompletion()}}jsonStreamParse(e){}}var aq=r(3090),aJ=r(7617);class aX extends aH{constructor(e,t,r){super(e,t,r)}async translatePrompt(e){let t={role:"user",content:JSON.stringify({inputs:e})},r=[...this.systemInstruction?[{role:"system",content:`${this.systemInstruction}`}]:[],...this.options.initialPrompts,...this.promptContext,t],n=this.getMaxToken(e),i=ay.object({outputs:ay.array(ay.string())});try{let t=0,a=0;t=Date.now(),await this.services.cooler?.cool();let o=await this.streamParse({messages:r,...this.options.createChatCompletionRequest,stream:this.options.createChatCompletionRequest.stream,max_tokens:n},{structure:i,name:"translation_array"},!0);a=Date.now();let s=o.choices[0].message,l=async t=>{if(1===e.length&&t.refusal&&this.options.fallbackModel){nm.debug("[TranslatorStructuredArray] Refusal Fallback",this.options.fallbackModel);let e={...this.options.createChatCompletionRequest};e.model=this.options.fallbackModel,t=(await this.streamParse({messages:r,...e,stream:e.stream,max_tokens:n},{structure:i,name:"translation_array"})).choices[0].message}return t.refusal?[t.refusal]:t.parsed.outputs},u=await l(s),c=new n_(u,o.usage?.prompt_tokens,o.usage?.completion_tokens,o.usage?.prompt_tokens_details?.cached_tokens,o.usage?.total_tokens,o.choices[0].message.refusal);return this.promptTokensUsed+=c.promptTokens,this.completionTokensUsed+=c.completionTokens,this.cachedTokens+=c.cachedTokens,this.tokensProcessTimeMs+=a-t,c}catch(t){return nm.error("[TranslatorStructuredArray]",`Error ${t?.constructor?.name}`,t?.message),await this.translateBaseFallback(e,t)}}getContextLines(e,t){return"user"===t?JSON.stringify({inputs:e}):JSON.stringify({outputs:e})}jsonStreamParse(e){this.services.onStreamChunk?.("\n");let t=new aq.PassThrough,r="";e.on("content.delta",e=>{r+=e.delta,t.write(e.delta),r&&(this.services.onStreamChunk?.(r),r="")}),e.on("content.done",()=>{t.end(),this.services.onClearLine?.()});let n=aJ.parse(["outputs",!0]);n.on("data",e=>{try{this.services.onClearLine?.(),r=`${e} `}catch(e){nm.error("[TranslatorStructuredBase]","Parsing error:",e)}}),n.on("error",e=>{nm.error("[TranslatorStructuredBase]","JSONStream parsing error:",e)}),t.pipe(n)}}},6323:function(e,t,r){"use strict";r.d(t,{t:function(){return n}});let n=new Set(["opacity","clipPath","filter","transform"])},4446:function(e,t,r){"use strict";r.d(t,{M:function(){return v}});var n=r(7437),i=r(2265),a=r(7797),o=r(458),s=r(9791);class l extends i.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){let e=this.props.sizeRef.current;e.height=t.offsetHeight||0,e.width=t.offsetWidth||0,e.top=t.offsetTop,e.left=t.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function u(e){let{children:t,isPresent:r}=e,a=(0,i.useId)(),o=(0,i.useRef)(null),u=(0,i.useRef)({width:0,height:0,top:0,left:0}),{nonce:c}=(0,i.useContext)(s._);return(0,i.useInsertionEffect)(()=>{let{width:e,height:t,top:n,left:i}=u.current;if(r||!o.current||!e||!t)return;o.current.dataset.motionPopId=a;let s=document.createElement("style");return c&&(s.nonce=c),document.head.appendChild(s),s.sheet&&s.sheet.insertRule('\n [data-motion-pop-id="'.concat(a,'"] {\n position: absolute !important;\n width: ').concat(e,"px !important;\n height: ").concat(t,"px !important;\n top: ").concat(n,"px !important;\n left: ").concat(i,"px !important;\n }\n ")),()=>{document.head.removeChild(s)}},[r]),(0,n.jsx)(l,{isPresent:r,childRef:o,sizeRef:u,children:i.cloneElement(t,{ref:o})})}let c=e=>{let{children:t,initial:r,isPresent:s,onExitComplete:l,custom:c,presenceAffectsLayout:p,mode:f}=e,h=(0,o.h)(d),m=(0,i.useId)(),g=(0,i.useMemo)(()=>({id:m,initial:r,isPresent:s,custom:c,onExitComplete:e=>{for(let t of(h.set(e,!0),h.values()))if(!t)return;l&&l()},register:e=>(h.set(e,!1),()=>h.delete(e))}),p?[Math.random()]:[s]);return(0,i.useMemo)(()=>{h.forEach((e,t)=>h.set(t,!1))},[s]),i.useEffect(()=>{s||h.size||!l||l()},[s]),"popLayout"===f&&(t=(0,n.jsx)(u,{isPresent:s,children:t})),(0,n.jsx)(a.O.Provider,{value:g,children:t})};function d(){return new Map}var p=r(5050),f=r(9047);let h=e=>e.key||"";function m(e){let t=[];return i.Children.forEach(e,e=>{(0,i.isValidElement)(e)&&t.push(e)}),t}var g=r(9033);let v=e=>{let{children:t,exitBeforeEnter:r,custom:a,initial:s=!0,onExitComplete:l,presenceAffectsLayout:u=!0,mode:d="sync"}=e;(0,f.k)(!r,"Replace exitBeforeEnter with mode='wait'");let v=(0,i.useMemo)(()=>m(t),[t]),y=v.map(h),b=(0,i.useRef)(!0),x=(0,i.useRef)(v),w=(0,o.h)(()=>new Map),[C,k]=(0,i.useState)(v),[S,P]=(0,i.useState)(v);(0,g.L)(()=>{b.current=!1,x.current=v;for(let e=0;e{let t=h(e),r=v===S||y.includes(t);return(0,n.jsx)(c,{isPresent:r,initial:(!b.current||!!s)&&void 0,custom:r?void 0:a,presenceAffectsLayout:u,mode:d,onExitComplete:r?void 0:()=>{if(!w.has(t))return;w.set(t,!0);let e=!0;w.forEach(t=>{t||(e=!1)}),e&&(null==A||A(),P(x.current),l&&l())},children:e},t)})})}},7992:function(e,t,r){"use strict";r.d(t,{S:function(){return p}});var n=r(7437),i=r(2265),a=r(5050);let o=(0,i.createContext)(null);var s=r(9033),l=r(6219);let u=e=>!e.isLayoutDirty&&e.willUpdate(!1),c=e=>!0===e,d=e=>c(!0===e)||"id"===e,p=e=>{let{children:t,id:r,inherit:p=!0}=e,f=(0,i.useContext)(a.p),h=(0,i.useContext)(o),[m,g]=function(){let e=function(){let e=(0,i.useRef)(!1);return(0,s.L)(()=>(e.current=!0,()=>{e.current=!1}),[]),e}(),[t,r]=(0,i.useState)(0),n=(0,i.useCallback)(()=>{e.current&&r(t+1)},[t]);return[(0,i.useCallback)(()=>l.Wi.postRender(n),[n]),t]}(),v=(0,i.useRef)(null),y=f.id||h;null===v.current&&(d(p)&&y&&(r=r?y+"-"+r:y),v.current={id:r,group:c(p)&&f.group||function(){let e=new Set,t=new WeakMap,r=()=>e.forEach(u);return{add:n=>{e.add(n),t.set(n,n.addEventListener("willUpdate",r))},remove:n=>{e.delete(n);let i=t.get(n);i&&(i(),t.delete(n)),r()},dirty:r}}()});let b=(0,i.useMemo)(()=>({...v.current,forceRender:m}),[g]);return(0,n.jsx)(a.p.Provider,{value:b,children:t})}},5050:function(e,t,r){"use strict";r.d(t,{p:function(){return n}});let n=(0,r(2265).createContext)({})},9791:function(e,t,r){"use strict";r.d(t,{_:function(){return n}});let n=(0,r(2265).createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"})},7797:function(e,t,r){"use strict";r.d(t,{O:function(){return n}});let n=(0,r(2265).createContext)(null)},2981:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});var n=r(565);let i=["read","resolveKeyframes","update","preRender","render","postRender"];function a(e,t){let r=!1,a=!0,o={delta:0,timestamp:0,isProcessing:!1},s=()=>r=!0,l=i.reduce((e,t)=>(e[t]=function(e){let t=new Set,r=new Set,n=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(l.schedule(t),e()),t(o)}let l={schedule:(e,i=!1,o=!1)=>{let s=o&&n?t:r;return i&&a.add(e),s.has(e)||s.add(e),e},cancel:e=>{r.delete(e),a.delete(e)},process:e=>{if(o=e,n){i=!0;return}n=!0,[t,r]=[r,t],r.clear(),t.forEach(s),n=!1,i&&(i=!1,l.process(e))}};return l}(s),e),{}),{read:u,resolveKeyframes:c,update:d,preRender:p,render:f,postRender:h}=l,m=()=>{let i=n.c.useManualTiming?o.timestamp:performance.now();r=!1,o.delta=a?1e3/60:Math.max(Math.min(i-o.timestamp,40),1),o.timestamp=i,o.isProcessing=!0,u.process(o),c.process(o),d.process(o),p.process(o),f.process(o),h.process(o),o.isProcessing=!1,r&&t&&(a=!1,e(m))},g=()=>{r=!0,a=!0,o.isProcessing||e(m)};return{schedule:i.reduce((e,t)=>{let n=l[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t(void 0===n&&s.set(a.frameData.isProcessing||i.c.useManualTiming?a.frameData.timestamp:performance.now()),n),set:e=>{n=e,queueMicrotask(o)}}},8035:function(e,t,r){"use strict";function n(e){return null!==e&&"object"==typeof e&&"function"==typeof e.start}r.d(t,{E:function(){return ar}});let i=e=>Array.isArray(e);function a(e,t){if(!Array.isArray(t))return!1;let r=t.length;if(r!==e.length)return!1;for(let n=0;n{t[0][r]=e.get(),t[1][r]=e.getVelocity()}),t}function l(e,t,r,n){if("function"==typeof t){let[i,a]=s(n);t=t(void 0!==r?r:e.custom,i,a)}if("string"==typeof t&&(t=e.variants&&e.variants[t]),"function"==typeof t){let[i,a]=s(n);t=t(void 0!==r?r:e.custom,i,a)}return t}function u(e,t,r){let n=e.getProps();return l(n,t,void 0!==r?r:n.custom,e)}let c=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],d=["initial",...c];var p,f,h,m=r(6019);let g=e=>1e3*e,v=e=>e/1e3,y={type:"spring",stiffness:500,damping:25,restSpeed:10},b=e=>({type:"spring",stiffness:550,damping:0===e?2*Math.sqrt(550):30,restSpeed:10}),x={type:"keyframes",duration:.8},w={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},C=(e,{keyframes:t})=>t.length>2?x:m.G.has(e)?e.startsWith("scale")?b(t[1]):y:w;function k(e,t){return e[t]||e.default||e}var S=r(565);let P={current:!1},E=e=>null!==e;function A(e,{repeat:t,repeatType:r="loop"},n){let i=e.filter(E),a=t&&"loop"!==r&&t%2==1?0:i.length-1;return a&&void 0!==n?n:i[a]}var T=r(6219),_=r(9276);let D=(e,t,r)=>(((1-3*r+3*t)*e+(3*r-6*t))*e+3*t)*e;function B(e,t,r,n){if(e===t&&r===n)return _.Z;let i=t=>(function(e,t,r,n,i){let a,o;let s=0;do(a=D(o=t+(r-t)/2,n,i)-e)>0?r=o:t=o;while(Math.abs(a)>1e-7&&++s<12);return o})(t,0,1,e,r);return e=>0===e||1===e?e:D(i(e),t,n)}let M=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,j=e=>t=>1-e(1-t),N=B(.33,1.53,.69,.99),I=j(N),R=M(I),O=e=>(e*=2)<1?.5*I(e):.5*(2-Math.pow(2,-10*(e-1))),$=e=>1-Math.sin(Math.acos(e)),F=j($),L=M($),z=e=>/^0[^.\s]+$/u.test(e);var K=r(9047);let W=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),V=e=>t=>"string"==typeof t&&t.startsWith(e),U=V("--"),G=V("var(--"),Z=e=>!!G(e)&&H.test(e.split("/*")[0].trim()),H=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,q=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u,J=(e,t,r)=>r>t?t:r"number"==typeof e,parse:parseFloat,transform:e=>e},Y={...X,transform:e=>J(0,1,e)},Q={...X,default:1},ee=e=>({test:t=>"string"==typeof t&&t.endsWith(e)&&1===t.split(" ").length,parse:parseFloat,transform:t=>`${t}${e}`}),et=ee("deg"),er=ee("%"),en=ee("px"),ei=ee("vh"),ea=ee("vw"),eo={...er,parse:e=>er.parse(e)/100,transform:e=>er.transform(100*e)},es=new Set(["width","height","top","left","right","bottom","x","y","translateX","translateY"]),el=e=>e===X||e===en,eu=(e,t)=>parseFloat(e.split(", ")[t]),ec=(e,t)=>(r,{transform:n})=>{if("none"===n||!n)return 0;let i=n.match(/^matrix3d\((.+)\)$/u);if(i)return eu(i[1],t);{let t=n.match(/^matrix\((.+)\)$/u);return t?eu(t[1],e):0}},ed=new Set(["x","y","z"]),ep=m._.filter(e=>!ed.has(e)),ef={width:({x:e},{paddingLeft:t="0",paddingRight:r="0"})=>e.max-e.min-parseFloat(t)-parseFloat(r),height:({y:e},{paddingTop:t="0",paddingBottom:r="0"})=>e.max-e.min-parseFloat(t)-parseFloat(r),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:ec(4,13),y:ec(5,14)};ef.translateX=ef.x,ef.translateY=ef.y;let eh=e=>t=>t.test(e),em=[X,en,er,et,ea,ei,{test:e=>"auto"===e,parse:e=>e}],eg=e=>em.find(eh(e)),ev=new Set,ey=!1,eb=!1;function ex(){if(eb){let e=Array.from(ev).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),r=new Map;t.forEach(e=>{let t=function(e){let t=[];return ep.forEach(r=>{let n=e.getValue(r);void 0!==n&&(t.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),t}(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,r])=>{var n;null===(n=e.getValue(t))||void 0===n||n.set(r)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}eb=!1,ey=!1,ev.forEach(e=>e.complete()),ev.clear()}function ew(){ev.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(eb=!0)})}class eC{constructor(e,t,r,n,i,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=r,this.motionValue=n,this.element=i,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(ev.add(this),ey||(ey=!0,T.Wi.read(ew),T.Wi.resolveKeyframes(ex))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:r,motionValue:n}=this;for(let i=0;iMath.round(1e5*e)/1e5,eS=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu,eP=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,eE=(e,t)=>r=>!!("string"==typeof r&&eP.test(r)&&r.startsWith(e)||t&&null!=r&&Object.prototype.hasOwnProperty.call(r,t)),eA=(e,t,r)=>n=>{if("string"!=typeof n)return n;let[i,a,o,s]=n.match(eS);return{[e]:parseFloat(i),[t]:parseFloat(a),[r]:parseFloat(o),alpha:void 0!==s?parseFloat(s):1}},eT=e=>J(0,255,e),e_={...X,transform:e=>Math.round(eT(e))},eD={test:eE("rgb","red"),parse:eA("red","green","blue"),transform:({red:e,green:t,blue:r,alpha:n=1})=>"rgba("+e_.transform(e)+", "+e_.transform(t)+", "+e_.transform(r)+", "+ek(Y.transform(n))+")"},eB={test:eE("#"),parse:function(e){let t="",r="",n="",i="";return e.length>5?(t=e.substring(1,3),r=e.substring(3,5),n=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),r=e.substring(2,3),n=e.substring(3,4),i=e.substring(4,5),t+=t,r+=r,n+=n,i+=i),{red:parseInt(t,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}},transform:eD.transform},eM={test:eE("hsl","hue"),parse:eA("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:r,alpha:n=1})=>"hsla("+Math.round(e)+", "+er.transform(ek(t))+", "+er.transform(ek(r))+", "+ek(Y.transform(n))+")"},ej={test:e=>eD.test(e)||eB.test(e)||eM.test(e),parse:e=>eD.test(e)?eD.parse(e):eM.test(e)?eM.parse(e):eB.parse(e),transform:e=>"string"==typeof e?e:e.hasOwnProperty("red")?eD.transform(e):eM.transform(e)},eN=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,eI="number",eR="color",eO=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function e$(e){let t=e.toString(),r=[],n={color:[],number:[],var:[]},i=[],a=0,o=t.replace(eO,e=>(ej.test(e)?(n.color.push(a),i.push(eR),r.push(ej.parse(e))):e.startsWith("var(")?(n.var.push(a),i.push("var"),r.push(e)):(n.number.push(a),i.push(eI),r.push(parseFloat(e))),++a,"${}")).split("${}");return{values:r,split:o,indexes:n,types:i}}function eF(e){return e$(e).values}function eL(e){let{split:t,types:r}=e$(e),n=t.length;return e=>{let i="";for(let a=0;a"number"==typeof e?0:e,eK={test:function(e){var t,r;return isNaN(e)&&"string"==typeof e&&((null===(t=e.match(eS))||void 0===t?void 0:t.length)||0)+((null===(r=e.match(eN))||void 0===r?void 0:r.length)||0)>0},parse:eF,createTransformer:eL,getAnimatableNone:function(e){let t=eF(e);return eL(e)(t.map(ez))}},eW=new Set(["brightness","contrast","saturate","opacity"]);function eV(e){let[t,r]=e.slice(0,-1).split("(");if("drop-shadow"===t)return e;let[n]=r.match(eS)||[];if(!n)return e;let i=r.replace(n,""),a=eW.has(t)?1:0;return n!==r&&(a*=100),t+"("+a+i+")"}let eU=/\b([a-z-]*)\(.*?\)/gu,eG={...eK,getAnimatableNone:e=>{let t=e.match(eU);return t?t.map(eV).join(" "):e}},eZ={...X,transform:Math.round},eH={borderWidth:en,borderTopWidth:en,borderRightWidth:en,borderBottomWidth:en,borderLeftWidth:en,borderRadius:en,radius:en,borderTopLeftRadius:en,borderTopRightRadius:en,borderBottomRightRadius:en,borderBottomLeftRadius:en,width:en,maxWidth:en,height:en,maxHeight:en,top:en,right:en,bottom:en,left:en,padding:en,paddingTop:en,paddingRight:en,paddingBottom:en,paddingLeft:en,margin:en,marginTop:en,marginRight:en,marginBottom:en,marginLeft:en,backgroundPositionX:en,backgroundPositionY:en,rotate:et,rotateX:et,rotateY:et,rotateZ:et,scale:Q,scaleX:Q,scaleY:Q,scaleZ:Q,skew:et,skewX:et,skewY:et,distance:en,translateX:en,translateY:en,translateZ:en,x:en,y:en,z:en,perspective:en,transformPerspective:en,opacity:Y,originX:eo,originY:eo,originZ:en,zIndex:eZ,size:en,fillOpacity:Y,strokeOpacity:Y,numOctaves:eZ},eq={...eH,color:ej,backgroundColor:ej,outlineColor:ej,fill:ej,stroke:ej,borderColor:ej,borderTopColor:ej,borderRightColor:ej,borderBottomColor:ej,borderLeftColor:ej,filter:eG,WebkitFilter:eG},eJ=e=>eq[e];function eX(e,t){let r=eJ(e);return r!==eG&&(r=eK),r.getAnimatableNone?r.getAnimatableNone(t):void 0}let eY=new Set(["auto","none","0"]);class eQ extends eC{constructor(e,t,r,n,i){super(e,t,r,n,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:r}=this;if(!t||!t.current)return;super.readKeyframes();for(let r=0;r{t.getValue(e).set(r)}),this.resolveNoneKeyframes()}}function e0(e){return"function"==typeof e}var e1=r(9993);let e4=(e,t)=>"zIndex"!==t&&!!("number"==typeof e||Array.isArray(e)||"string"==typeof e&&(eK.test(e)||"0"===e)&&!e.startsWith("url("));class e3{constructor({autoplay:e=!0,delay:t=0,type:r="keyframes",repeat:n=0,repeatDelay:i=0,repeatType:a="loop",...o}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=e1.X.now(),this.options={autoplay:e,delay:t,type:r,repeat:n,repeatDelay:i,repeatType:a,...o},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt}get resolved(){return this._resolved||this.hasAttemptedResolve||(ew(),ex()),this._resolved}onKeyframesResolved(e,t){this.resolvedAt=e1.X.now(),this.hasAttemptedResolve=!0;let{name:r,type:n,velocity:i,delay:a,onComplete:o,onUpdate:s,isGenerator:l}=this.options;if(!l&&!function(e,t,r,n){let i=e[0];if(null===i)return!1;if("display"===t||"visibility"===t)return!0;let a=e[e.length-1],o=e4(i,t),s=e4(a,t);return(0,K.K)(o===s,`You are trying to animate ${t} from "${i}" to "${a}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${a} via the \`style\` property.`),!!o&&!!s&&(function(e){let t=e[0];if(1===e.length)return!0;for(let r=0;r{this.resolveFinishedPromise=e})}}var e2=r(3476);function e5(e,t,r){let n=Math.max(t-5,0);return(0,e2.R)(r-e(n),t-n)}function e6(e,t){return e*Math.sqrt(1-t*t)}let e9=["duration","bounce"],e8=["stiffness","damping","mass"];function e7(e,t){return t.some(t=>void 0!==e[t])}function te({keyframes:e,restDelta:t,restSpeed:r,...n}){let i;let a=e[0],o=e[e.length-1],s={done:!1,value:a},{stiffness:l,damping:u,mass:c,duration:d,velocity:p,isResolvedFromDuration:f}=function(e){let t={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...e};if(!e7(e,e8)&&e7(e,e9)){let r=function({duration:e=800,bounce:t=.25,velocity:r=0,mass:n=1}){let i,a;(0,K.K)(e<=g(10),"Spring duration must be 10 seconds or less");let o=1-t;o=J(.05,1,o),e=J(.01,10,v(e)),o<1?(i=t=>{let n=t*o,i=n*e;return .001-(n-r)/e6(t,o)*Math.exp(-i)},a=t=>{let n=t*o*e,a=Math.pow(o,2)*Math.pow(t,2)*e,s=e6(Math.pow(t,2),o);return(n*r+r-a)*Math.exp(-n)*(-i(t)+.001>0?-1:1)/s}):(i=t=>-.001+Math.exp(-t*e)*((t-r)*e+1),a=t=>e*e*(r-t)*Math.exp(-t*e));let s=function(e,t,r){let n=r;for(let r=1;r<12;r++)n-=e(n)/t(n);return n}(i,a,5/e);if(e=g(e),isNaN(s))return{stiffness:100,damping:10,duration:e};{let t=Math.pow(s,2)*n;return{stiffness:t,damping:2*o*Math.sqrt(n*t),duration:e}}}(e);(t={...t,...r,mass:1}).isResolvedFromDuration=!0}return t}({...n,velocity:-v(n.velocity||0)}),h=p||0,m=u/(2*Math.sqrt(l*c)),y=o-a,b=v(Math.sqrt(l/c)),x=5>Math.abs(y);if(r||(r=x?.01:2),t||(t=x?.005:.5),m<1){let e=e6(b,m);i=t=>o-Math.exp(-m*b*t)*((h+m*b*y)/e*Math.sin(e*t)+y*Math.cos(e*t))}else if(1===m)i=e=>o-Math.exp(-b*e)*(y+(h+b*y)*e);else{let e=b*Math.sqrt(m*m-1);i=t=>{let r=Math.exp(-m*b*t),n=Math.min(e*t,300);return o-r*((h+m*b*y)*Math.sinh(n)+e*y*Math.cosh(n))/e}}return{calculatedDuration:f&&d||null,next:e=>{let n=i(e);if(f)s.done=e>=d;else{let a=0;m<1&&(a=0===e?g(h):e5(i,e,n));let l=Math.abs(a)<=r,u=Math.abs(o-n)<=t;s.done=l&&u}return s.value=s.done?o:n,s}}}function tt({keyframes:e,velocity:t=0,power:r=.8,timeConstant:n=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:l,restDelta:u=.5,restSpeed:c}){let d,p;let f=e[0],h={done:!1,value:f},m=e=>void 0!==s&&el,g=e=>void 0===s?l:void 0===l?s:Math.abs(s-e)-v*Math.exp(-e/n),w=e=>b+x(e),C=e=>{let t=x(e),r=w(e);h.done=Math.abs(t)<=u,h.value=h.done?b:r},k=e=>{m(h.value)&&(d=e,p=te({keyframes:[h.value,g(h.value)],velocity:e5(w,e,h.value),damping:i,stiffness:a,restDelta:u,restSpeed:c}))};return k(0),{calculatedDuration:null,next:e=>{let t=!1;return(p||void 0!==d||(t=!0,C(e),k(e)),void 0!==d&&e>=d)?p.next(e-d):(t||C(e),h)}}}let tr=B(.42,0,1,1),tn=B(0,0,.58,1),ti=B(.42,0,.58,1),ta=e=>Array.isArray(e)&&"number"!=typeof e[0],to={linear:_.Z,easeIn:tr,easeInOut:ti,easeOut:tn,circIn:$,circInOut:L,circOut:F,backIn:I,backInOut:R,backOut:N,anticipate:O},ts=e=>{if(Array.isArray(e)){(0,K.k)(4===e.length,"Cubic bezier arrays must contain four numerical values.");let[t,r,n,i]=e;return B(t,r,n,i)}return"string"==typeof e?((0,K.k)(void 0!==to[e],`Invalid easing type '${e}'`),to[e]):e},tl=(e,t)=>r=>t(e(r)),tu=(...e)=>e.reduce(tl),tc=(e,t,r)=>{let n=t-e;return 0===n?1:(r-e)/n},td=(e,t,r)=>e+(t-e)*r;function tp(e,t,r){return(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function tf(e,t){return r=>r>0?t:e}let th=(e,t,r)=>{let n=e*e,i=r*(t*t-n)+n;return i<0?0:Math.sqrt(i)},tm=[eB,eD,eM],tg=e=>tm.find(t=>t.test(e));function tv(e){let t=tg(e);if((0,K.K)(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let r=t.parse(e);return t===eM&&(r=function({hue:e,saturation:t,lightness:r,alpha:n}){e/=360,r/=100;let i=0,a=0,o=0;if(t/=100){let n=r<.5?r*(1+t):r+t-r*t,s=2*r-n;i=tp(s,n,e+1/3),a=tp(s,n,e),o=tp(s,n,e-1/3)}else i=a=o=r;return{red:Math.round(255*i),green:Math.round(255*a),blue:Math.round(255*o),alpha:n}}(r)),r}let ty=(e,t)=>{let r=tv(e),n=tv(t);if(!r||!n)return tf(e,t);let i={...r};return e=>(i.red=th(r.red,n.red,e),i.green=th(r.green,n.green,e),i.blue=th(r.blue,n.blue,e),i.alpha=td(r.alpha,n.alpha,e),eD.transform(i))},tb=new Set(["none","hidden"]);function tx(e,t){return r=>td(e,t,r)}function tw(e){return"number"==typeof e?tx:"string"==typeof e?Z(e)?tf:ej.test(e)?ty:tS:Array.isArray(e)?tC:"object"==typeof e?ej.test(e)?ty:tk:tf}function tC(e,t){let r=[...e],n=r.length,i=e.map((e,r)=>tw(e)(e,t[r]));return e=>{for(let t=0;t{for(let t in n)r[t]=n[t](e);return r}}let tS=(e,t)=>{let r=eK.createTransformer(t),n=e$(e),i=e$(t);return n.indexes.var.length===i.indexes.var.length&&n.indexes.color.length===i.indexes.color.length&&n.indexes.number.length>=i.indexes.number.length?tb.has(e)&&!i.values.length||tb.has(t)&&!n.values.length?tb.has(e)?r=>r<=0?e:t:r=>r>=1?t:e:tu(tC(function(e,t){var r;let n=[],i={color:0,var:0,number:0};for(let a=0;at[0];if(2===a&&e[0]===e[1])return()=>t[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let o=function(e,t,r){let n=[],i=r||tP,a=e.length-1;for(let r=0;r{let r=0;if(s>1)for(;rl(J(e[0],e[a-1],t)):l}((r&&r.length===t.length?r:function(e){let t=[0];return function(e,t){let r=e[e.length-1];for(let n=1;n<=t;n++){let i=tc(0,t,n);e.push(td(r,1,i))}}(t,e.length-1),t}(t)).map(t=>t*e),t,{ease:Array.isArray(i)?i:t.map(()=>i||ti).splice(0,t.length-1)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}let tA=e=>{let t=({timestamp:t})=>e(t);return{start:()=>T.Wi.update(t,!0),stop:()=>(0,T.Pn)(t),now:()=>T.frameData.isProcessing?T.frameData.timestamp:e1.X.now()}},tT={decay:tt,inertia:tt,tween:tE,keyframes:tE,spring:te},t_=e=>e/100;class tD extends e3{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.teardown();let{onStop:e}=this.options;e&&e()};let{name:t,motionValue:r,element:n,keyframes:i}=this.options,a=(null==n?void 0:n.KeyframeResolver)||eC;this.resolver=new a(i,(e,t)=>this.onKeyframesResolved(e,t),t,r,n),this.resolver.scheduleResolve()}initPlayback(e){let t,r;let{type:n="keyframes",repeat:i=0,repeatDelay:a=0,repeatType:o,velocity:s=0}=this.options,l=e0(n)?n:tT[n]||tE;l!==tE&&"number"!=typeof e[0]&&(t=tu(t_,tP(e[0],e[1])),e=[0,100]);let u=l({...this.options,keyframes:e});"mirror"===o&&(r=l({...this.options,keyframes:[...e].reverse(),velocity:-s})),null===u.calculatedDuration&&(u.calculatedDuration=function(e){let t=0,r=e.next(t);for(;!r.done&&t<2e4;)t+=50,r=e.next(t);return t>=2e4?1/0:t}(u));let{calculatedDuration:c}=u,d=c+a;return{generator:u,mirroredGenerator:r,mapPercentToKeyframes:t,calculatedDuration:c,resolvedDuration:d,totalDuration:d*(i+1)-a}}onPostResolved(){let{autoplay:e=!0}=this.options;this.play(),"paused"!==this.pendingPlayState&&e?this.state=this.pendingPlayState:this.pause()}tick(e,t=!1){let{resolved:r}=this;if(!r){let{keyframes:e}=this.options;return{done:!0,value:e[e.length-1]}}let{finalKeyframe:n,generator:i,mirroredGenerator:a,mapPercentToKeyframes:o,keyframes:s,calculatedDuration:l,totalDuration:u,resolvedDuration:c}=r;if(null===this.startTime)return i.next(0);let{delay:d,repeat:p,repeatType:f,repeatDelay:h,onUpdate:m}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-u/this.speed,this.startTime)),t?this.currentTime=e:null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=Math.round(e-this.startTime)*this.speed;let g=this.currentTime-d*(this.speed>=0?1:-1),v=this.speed>=0?g<0:g>u;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=u);let y=this.currentTime,b=i;if(p){let e=Math.min(this.currentTime,u)/c,t=Math.floor(e),r=e%1;!r&&e>=1&&(r=1),1===r&&t--,(t=Math.min(t,p+1))%2&&("reverse"===f?(r=1-r,h&&(r-=h/c)):"mirror"===f&&(b=a)),y=J(0,1,r)*c}let x=v?{done:!1,value:s[0]}:b.next(y);o&&(x.value=o(x.value));let{done:w}=x;v||null===l||(w=this.speed>=0?this.currentTime>=u:this.currentTime<=0);let C=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return C&&void 0!==n&&(x.value=A(s,this.options,n)),m&&m(x.value),C&&this.finish(),x}get duration(){let{resolved:e}=this;return e?v(e.calculatedDuration):0}get time(){return v(this.currentTime)}set time(e){e=g(e),this.currentTime=e,null!==this.holdTime||0===this.speed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=v(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;let{driver:e=tA,onPlay:t,startTime:r}=this.options;this.driver||(this.driver=e(e=>this.tick(e))),t&&t();let n=this.driver.now();null!==this.holdTime?this.startTime=n-this.holdTime:this.startTime?"finished"===this.state&&(this.startTime=n):this.startTime=null!=r?r:this.calcStartTime(),"finished"===this.state&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var e;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=null!==(e=this.currentTime)&&void 0!==e?e:0}complete(){"running"!==this.state&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";let{onComplete:e}=this.options;e&&e()}cancel(){null!==this.cancelTime&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}}var tB=r(6323);let tM=e=>Array.isArray(e)&&"number"==typeof e[0],tj=(e,t)=>{let r="",n=Math.max(Math.round(t/10),2);for(let t=0;t(void 0===t&&(t=e()),t)}let tI={linearEasing:void 0},tR=function(e,t){let r=tN(e);return()=>{var e;return null!==(e=tI[t])&&void 0!==e?e:r()}}(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0},"linearEasing"),tO=([e,t,r,n])=>`cubic-bezier(${e}, ${t}, ${r}, ${n})`,t$={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:tO([0,.65,.55,1]),circOut:tO([.55,0,1,.45]),backIn:tO([.31,.01,.66,-.59]),backOut:tO([.33,1.53,.69,.99])};function tF(e,t){e.timeline=t,e.onfinish=null}let tL=tN(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),tz={anticipate:O,backInOut:R,circInOut:L};class tK extends e3{constructor(e){super(e);let{name:t,motionValue:r,element:n,keyframes:i}=this.options;this.resolver=new eQ(i,(e,t)=>this.onKeyframesResolved(e,t),t,r,n),this.resolver.scheduleResolve()}initPlayback(e,t){var r,n;let{duration:i=300,times:a,ease:o,type:s,motionValue:l,name:u,startTime:c}=this.options;if(!(null===(r=l.owner)||void 0===r?void 0:r.current))return!1;if("string"==typeof o&&tR()&&o in tz&&(o=tz[o]),e0((n=this.options).type)||"spring"===n.type||!function e(t){return!!("function"==typeof t&&tR()||!t||"string"==typeof t&&(t in t$||tR())||tM(t)||Array.isArray(t)&&t.every(e))}(n.ease)){let{onComplete:t,onUpdate:r,motionValue:n,element:l,...u}=this.options,c=function(e,t){let r=new tD({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0}),n={done:!1,value:e[0]},i=[],a=0;for(;!n.done&&a<2e4;)i.push((n=r.sample(a)).value),a+=10;return{times:void 0,keyframes:i,duration:a-10,ease:"linear"}}(e,u);1===(e=c.keyframes).length&&(e[1]=e[0]),i=c.duration,a=c.times,o=c.ease,s="keyframes"}let d=function(e,t,r,{delay:n=0,duration:i=300,repeat:a=0,repeatType:o="loop",ease:s,times:l}={}){let u={[t]:r};l&&(u.offset=l);let c=function e(t,r){if(t)return"function"==typeof t&&tR()?tj(t,r):tM(t)?tO(t):Array.isArray(t)?t.map(t=>e(t,r)||t$.easeOut):t$[t]}(s,i);return Array.isArray(c)&&(u.easing=c),e.animate(u,{delay:n,duration:i,easing:Array.isArray(c)?"linear":c,fill:"both",iterations:a+1,direction:"reverse"===o?"alternate":"normal"})}(l.owner.current,u,e,{...this.options,duration:i,times:a,ease:o});return d.startTime=null!=c?c:this.calcStartTime(),this.pendingTimeline?(tF(d,this.pendingTimeline),this.pendingTimeline=void 0):d.onfinish=()=>{let{onComplete:r}=this.options;l.set(A(e,this.options,t)),r&&r(),this.cancel(),this.resolveFinishedPromise()},{animation:d,duration:i,times:a,type:s,ease:o,keyframes:e}}get duration(){let{resolved:e}=this;if(!e)return 0;let{duration:t}=e;return v(t)}get time(){let{resolved:e}=this;if(!e)return 0;let{animation:t}=e;return v(t.currentTime||0)}set time(e){let{resolved:t}=this;if(!t)return;let{animation:r}=t;r.currentTime=g(e)}get speed(){let{resolved:e}=this;if(!e)return 1;let{animation:t}=e;return t.playbackRate}set speed(e){let{resolved:t}=this;if(!t)return;let{animation:r}=t;r.playbackRate=e}get state(){let{resolved:e}=this;if(!e)return"idle";let{animation:t}=e;return t.playState}get startTime(){let{resolved:e}=this;if(!e)return null;let{animation:t}=e;return t.startTime}attachTimeline(e){if(this._resolved){let{resolved:t}=this;if(!t)return _.Z;let{animation:r}=t;tF(r,e)}else this.pendingTimeline=e;return _.Z}play(){if(this.isStopped)return;let{resolved:e}=this;if(!e)return;let{animation:t}=e;"finished"===t.playState&&this.updateFinishedPromise(),t.play()}pause(){let{resolved:e}=this;if(!e)return;let{animation:t}=e;t.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,"idle"===this.state)return;this.resolveFinishedPromise(),this.updateFinishedPromise();let{resolved:e}=this;if(!e)return;let{animation:t,keyframes:r,duration:n,type:i,ease:a,times:o}=e;if("idle"===t.playState||"finished"===t.playState)return;if(this.time){let{motionValue:e,onUpdate:t,onComplete:s,element:l,...u}=this.options,c=new tD({...u,keyframes:r,duration:n,type:i,ease:a,times:o,isGenerator:!0}),d=g(this.time);e.setWithVelocity(c.sample(d-10).value,c.sample(d).value,10)}let{onStop:s}=this.options;s&&s(),this.cancel()}complete(){let{resolved:e}=this;e&&e.animation.finish()}cancel(){let{resolved:e}=this;e&&e.animation.cancel()}static supports(e){let{motionValue:t,name:r,repeatDelay:n,repeatType:i,damping:a,type:o}=e;return tL()&&r&&tB.t.has(r)&&t&&t.owner&&t.owner.current instanceof HTMLElement&&!t.owner.getProps().onUpdate&&!n&&"mirror"!==i&&0!==a&&"inertia"!==o}}let tW=tN(()=>void 0!==window.ScrollTimeline);class tV{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}then(e,t){return Promise.all(this.animations).then(e).catch(t)}getAll(e){return this.animations[0][e]}setAll(e,t){for(let r=0;rtW()&&r.attachTimeline?r.attachTimeline(e):t(r));return()=>{r.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let t=0;tt[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}let tU=(e,t,r,n={},i,a)=>o=>{let s=k(n,e)||{},l=s.delay||n.delay||0,{elapsed:u=0}=n;u-=g(l);let c={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:t.getVelocity(),...s,delay:-u,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};!function({when:e,delay:t,delayChildren:r,staggerChildren:n,staggerDirection:i,repeat:a,repeatType:o,repeatDelay:s,from:l,elapsed:u,...c}){return!!Object.keys(c).length}(s)&&(c={...c,...C(e,c)}),c.duration&&(c.duration=g(c.duration)),c.repeatDelay&&(c.repeatDelay=g(c.repeatDelay)),void 0!==c.from&&(c.keyframes[0]=c.from);let d=!1;if(!1!==c.type&&(0!==c.duration||c.repeatDelay)||(c.duration=0,0!==c.delay||(d=!0)),(P.current||S.c.skipAnimations)&&(d=!0,c.duration=0,c.delay=0),d&&!a&&void 0!==t.get()){let e=A(c.keyframes,s);if(void 0!==e)return T.Wi.update(()=>{c.onUpdate(e),c.onComplete()}),new tV([])}return!a&&tK.supports(c)?new tK(c):new tD(c)},tG=e=>!!(e&&"object"==typeof e&&e.mix&&e.toValue),tZ=e=>i(e)?e[e.length-1]||0:e;var tH=r(804),tq=r(1580);let tJ="data-"+(0,tq.D)("framerAppearId");var tX=r(9447);let tY=e=>!!(e&&e.getVelocity);function tQ(e,t){var r,n;if(!e.applyWillChange)return;let i=e.getValue("willChange");if(i||(null===(r=e.props.style)||void 0===r?void 0:r.willChange)||(i=new tX.L("auto"),e.addValue("willChange",i)),tY(n=i)&&n.add)return i.add(t)}function t0(e,t,{delay:r=0,transitionOverride:n,type:i}={}){var a;let{transition:o=e.getDefaultTransition(),transitionEnd:s,...l}=t;n&&(o=n);let c=[],d=i&&e.animationState&&e.animationState.getState()[i];for(let t in l){let n=e.getValue(t,null!==(a=e.latestValues[t])&&void 0!==a?a:null),i=l[t];if(void 0===i||d&&function({protectedKeys:e,needsAnimating:t},r){let n=e.hasOwnProperty(r)&&!0!==t[r];return t[r]=!1,n}(d,t))continue;let s={delay:r,...k(o||{},t)},u=!1;if(window.MotionHandoffAnimation){let r=e.props[tJ];if(r){let e=window.MotionHandoffAnimation(r,t,T.Wi);null!==e&&(s.startTime=e,u=!0)}}tQ(e,t),n.start(tU(t,n,i,e.shouldReduceMotion&&m.G.has(t)?{type:!1}:s,e,u));let p=n.animation;p&&c.push(p)}return s&&Promise.all(c).then(()=>{T.Wi.update(()=>{s&&function(e,t){let{transitionEnd:r={},transition:n={},...i}=u(e,t)||{};for(let t in i={...i,...r}){let r=tZ(i[t]);e.hasValue(t)?e.getValue(t).set(r):e.addValue(t,(0,tH.BX)(r))}}(e,s)})}),c}function t1(e,t,r={}){var n;let i=u(e,t,"exit"===r.type?null===(n=e.presenceContext)||void 0===n?void 0:n.custom:void 0),{transition:a=e.getDefaultTransition()||{}}=i||{};r.transitionOverride&&(a=r.transitionOverride);let o=i?()=>Promise.all(t0(e,i,r)):()=>Promise.resolve(),s=e.variantChildren&&e.variantChildren.size?(n=0)=>{let{delayChildren:i=0,staggerChildren:o,staggerDirection:s}=a;return function(e,t,r=0,n=0,i=1,a){let o=[],s=(e.variantChildren.size-1)*n,l=1===i?(e=0)=>e*n:(e=0)=>s-e*n;return Array.from(e.variantChildren).sort(t4).forEach((e,n)=>{e.notify("AnimationStart",t),o.push(t1(e,t,{...a,delay:r+l(n)}).then(()=>e.notify("AnimationComplete",t)))}),Promise.all(o)}(e,t,i+n,o,s,r)}:()=>Promise.resolve(),{when:l}=a;if(!l)return Promise.all([o(),s(r.delay)]);{let[e,t]="beforeChildren"===l?[o,s]:[s,o];return e().then(()=>t())}}function t4(e,t){return e.sortNodePosition(t)}let t3=d.length,t2=[...c].reverse(),t5=c.length;function t6(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function t9(){return{animate:t6(!0),whileInView:t6(),whileHover:t6(),whileTap:t6(),whileDrag:t6(),whileFocus:t6(),exit:t6()}}class t8{constructor(e){this.isMounted=!1,this.node=e}update(){}}class t7 extends t8{constructor(e){super(e),e.animationState||(e.animationState=function(e){let t=t=>Promise.all(t.map(({animation:t,options:r})=>(function(e,t,r={}){let n;if(e.notify("AnimationStart",t),Array.isArray(t))n=Promise.all(t.map(t=>t1(e,t,r)));else if("string"==typeof t)n=t1(e,t,r);else{let i="function"==typeof t?u(e,t,r.custom):t;n=Promise.all(t0(e,i,r))}return n.then(()=>{e.notify("AnimationComplete",t)})})(e,t,r))),r=t9(),s=!0,l=t=>(r,n)=>{var i;let a=u(e,n,"exit"===t?null===(i=e.presenceContext)||void 0===i?void 0:i.custom:void 0);if(a){let{transition:e,transitionEnd:t,...n}=a;r={...r,...n,...t}}return r};function c(u){let{props:c}=e,p=function e(t){if(!t)return;if(!t.isControllingVariants){let r=t.parent&&e(t.parent)||{};return void 0!==t.props.initial&&(r.initial=t.props.initial),r}let r={};for(let e=0;eg&&x,P=!1,E=Array.isArray(b)?b:[b],A=E.reduce(l(d),{});!1===w&&(A={});let{prevResolvedValues:T={}}=y,_={...T,...A},D=t=>{S=!0,h.has(t)&&(P=!0,h.delete(t)),y.needsAnimating[t]=!0;let r=e.getValue(t);r&&(r.liveStyle=!1)};for(let e in _){let t=A[e],r=T[e];if(!m.hasOwnProperty(e))(i(t)&&i(r)?a(t,r):t===r)?void 0!==t&&h.has(e)?D(e):y.protectedKeys[e]=!0:null!=t?D(e):h.add(e)}y.prevProp=b,y.prevResolvedValues=A,y.isActive&&(m={...m,...A}),s&&e.blockInitialAnimation&&(S=!1);let B=!(C&&k)||P;S&&B&&f.push(...E.map(e=>({animation:e,options:{type:d}})))}if(h.size){let t={};h.forEach(r=>{let n=e.getBaseTarget(r),i=e.getValue(r);i&&(i.liveStyle=!0),t[r]=null!=n?n:null}),f.push({animation:t})}let y=!!f.length;return s&&(!1===c.initial||c.initial===c.animate)&&!e.manuallyAnimateOnMount&&(y=!1),s=!1,y?t(f):Promise.resolve()}return{animateChanges:c,setActive:function(t,n){var i;if(r[t].isActive===n)return Promise.resolve();null===(i=e.variantChildren)||void 0===i||i.forEach(e=>{var r;return null===(r=e.animationState)||void 0===r?void 0:r.setActive(t,n)}),r[t].isActive=n;let a=c(t);for(let e in r)r[e].protectedKeys={};return a},setAnimateFunction:function(r){t=r(e)},getState:()=>r,reset:()=>{r=t9(),s=!0}}}(e))}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();n(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),null===(e=this.unmountControls)||void 0===e||e.call(this)}}let re=0;class rt extends t8{constructor(){super(...arguments),this.id=re++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;let n=this.node.animationState.setActive("exit",!e);t&&!e&&n.then(()=>t(this.id))}mount(){let{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}let rr=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary;function rn(e,t="page"){return{point:{x:e[`${t}X`],y:e[`${t}Y`]}}}let ri=e=>t=>rr(t)&&e(t,rn(t));function ra(e,t,r,n={passive:!0}){return e.addEventListener(t,r,n),()=>e.removeEventListener(t,r)}function ro(e,t,r,n){return ra(e,t,ri(r),n)}let rs=(e,t)=>Math.abs(e-t);class rl{constructor(e,t,{transformPagePoint:r,contextWindow:n,dragSnapToOrigin:i=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{var e,t;if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let r=rd(this.lastMoveEventInfo,this.history),n=null!==this.startEvent,i=(e=r.offset,t={x:0,y:0},Math.sqrt(rs(e.x,t.x)**2+rs(e.y,t.y)**2)>=3);if(!n&&!i)return;let{point:a}=r,{timestamp:o}=T.frameData;this.history.push({...a,timestamp:o});let{onStart:s,onMove:l}=this.handlers;n||(s&&s(this.lastMoveEvent,r),this.startEvent=this.lastMoveEvent),l&&l(this.lastMoveEvent,r)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=ru(t,this.transformPagePoint),T.Wi.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:r,onSessionEnd:n,resumeAnimation:i}=this.handlers;if(this.dragSnapToOrigin&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=rd("pointercancel"===e.type?this.lastMoveEventInfo:ru(t,this.transformPagePoint),this.history);this.startEvent&&r&&r(e,a),n&&n(e,a)},!rr(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=r,this.contextWindow=n||window;let a=ru(rn(e),this.transformPagePoint),{point:o}=a,{timestamp:s}=T.frameData;this.history=[{...o,timestamp:s}];let{onSessionStart:l}=t;l&&l(e,rd(a,this.history)),this.removeListeners=tu(ro(this.contextWindow,"pointermove",this.handlePointerMove),ro(this.contextWindow,"pointerup",this.handlePointerUp),ro(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),(0,T.Pn)(this.updatePoint)}}function ru(e,t){return t?{point:t(e.point)}:e}function rc(e,t){return{x:e.x-t.x,y:e.y-t.y}}function rd({point:e},t){return{point:e,delta:rc(e,rp(t)),offset:rc(e,t[0]),velocity:function(e,t){if(e.length<2)return{x:0,y:0};let r=e.length-1,n=null,i=rp(e);for(;r>=0&&(n=e[r],!(i.timestamp-n.timestamp>g(.1)));)r--;if(!n)return{x:0,y:0};let a=v(i.timestamp-n.timestamp);if(0===a)return{x:0,y:0};let o={x:(i.x-n.x)/a,y:(i.y-n.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}(t,0)}}function rp(e){return e[e.length-1]}function rf(e){let t=null;return()=>null===t&&(t=e,()=>{t=null})}let rh=rf("dragHorizontal"),rm=rf("dragVertical");function rg(e){let t=!1;if("y"===e)t=rm();else if("x"===e)t=rh();else{let e=rh(),r=rm();e&&r?t=()=>{e(),r()}:(e&&e(),r&&r())}return t}function rv(){let e=rg(!0);return!e||(e(),!1)}function ry(e){return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}function rb(e){return e.max-e.min}function rx(e,t,r,n=.5){e.origin=n,e.originPoint=td(t.min,t.max,e.origin),e.scale=rb(r)/rb(t),e.translate=td(r.min,r.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function rw(e,t,r,n){rx(e.x,t.x,r.x,n?n.originX:void 0),rx(e.y,t.y,r.y,n?n.originY:void 0)}function rC(e,t,r){e.min=r.min+t.min,e.max=e.min+rb(t)}function rk(e,t,r){e.min=t.min-r.min,e.max=e.min+rb(t)}function rS(e,t,r){rk(e.x,t.x,r.x),rk(e.y,t.y,r.y)}function rP(e,t,r){return{min:void 0!==t?e.min+t:void 0,max:void 0!==r?e.max+r-(e.max-e.min):void 0}}function rE(e,t){let r=t.min-e.min,n=t.max-e.max;return t.max-t.min({translate:0,scale:1,origin:0,originPoint:0}),rD=()=>({x:r_(),y:r_()}),rB=()=>({min:0,max:0}),rM=()=>({x:rB(),y:rB()});function rj(e){return[e("x"),e("y")]}function rN({top:e,left:t,right:r,bottom:n}){return{x:{min:t,max:r},y:{min:e,max:n}}}function rI(e){return void 0===e||1===e}function rR({scale:e,scaleX:t,scaleY:r}){return!rI(e)||!rI(t)||!rI(r)}function rO(e){return rR(e)||r$(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function r$(e){var t,r;return(t=e.x)&&"0%"!==t||(r=e.y)&&"0%"!==r}function rF(e,t,r,n,i){return void 0!==i&&(e=n+i*(e-n)),n+r*(e-n)+t}function rL(e,t=0,r=1,n,i){e.min=rF(e.min,t,r,n,i),e.max=rF(e.max,t,r,n,i)}function rz(e,{x:t,y:r}){rL(e.x,t.translate,t.scale,t.originPoint),rL(e.y,r.translate,r.scale,r.originPoint)}function rK(e,t){e.min=e.min+t,e.max=e.max+t}function rW(e,t,r,n,i=.5){let a=td(e.min,e.max,i);rL(e,t,r,a,n)}function rV(e,t){rW(e.x,t.x,t.scaleX,t.scale,t.originX),rW(e.y,t.y,t.scaleY,t.scale,t.originY)}function rU(e,t){return rN(function(e,t){if(!t)return e;let r=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}(e.getBoundingClientRect(),t))}let rG=({current:e})=>e?e.ownerDocument.defaultView:null,rZ=new WeakMap;class rH{constructor(e){this.openGlobalLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=rM(),this.visualElement=e}start(e,{snapToCursor:t=!1}={}){let{presenceContext:r}=this.visualElement;if(r&&!1===r.isPresent)return;let{dragSnapToOrigin:n}=this.getProps();this.panSession=new rl(e,{onSessionStart:e=>{let{dragSnapToOrigin:r}=this.getProps();r?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor(rn(e,"page").point)},onStart:(e,t)=>{let{drag:r,dragPropagation:n,onDragStart:i}=this.getProps();if(r&&!n&&(this.openGlobalLock&&this.openGlobalLock(),this.openGlobalLock=rg(r),!this.openGlobalLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),rj(e=>{let t=this.getAxisMotionValue(e).get()||0;if(er.test(t)){let{projection:r}=this.visualElement;if(r&&r.layout){let n=r.layout.layoutBox[e];if(n){let e=rb(n);t=parseFloat(t)/100*e}}}this.originPoint[e]=t}),i&&T.Wi.postRender(()=>i(e,t)),tQ(this.visualElement,"transform");let{animationState:a}=this.visualElement;a&&a.setActive("whileDrag",!0)},onMove:(e,t)=>{let{dragPropagation:r,dragDirectionLock:n,onDirectionLock:i,onDrag:a}=this.getProps();if(!r&&!this.openGlobalLock)return;let{offset:o}=t;if(n&&null===this.currentDirection){this.currentDirection=function(e,t=10){let r=null;return Math.abs(e.y)>t?r="y":Math.abs(e.x)>t&&(r="x"),r}(o),null!==this.currentDirection&&i&&i(this.currentDirection);return}this.updateAxis("x",t.point,o),this.updateAxis("y",t.point,o),this.visualElement.render(),a&&a(e,t)},onSessionEnd:(e,t)=>this.stop(e,t),resumeAnimation:()=>rj(e=>{var t;return"paused"===this.getAnimationState(e)&&(null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.play())})},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:n,contextWindow:rG(this.visualElement)})}stop(e,t){let r=this.isDragging;if(this.cancel(),!r)return;let{velocity:n}=t;this.startAnimation(n);let{onDragEnd:i}=this.getProps();i&&T.Wi.postRender(()=>i(e,t))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;let{dragPropagation:r}=this.getProps();!r&&this.openGlobalLock&&(this.openGlobalLock(),this.openGlobalLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,r){let{drag:n}=this.getProps();if(!r||!rq(e,n,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(a=function(e,{min:t,max:r},n){return void 0!==t&&er&&(e=n?td(r,e,n.max):Math.min(e,r)),e}(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){var e;let{dragConstraints:t,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):null===(e=this.visualElement.projection)||void 0===e?void 0:e.layout,i=this.constraints;t&&ry(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&n?this.constraints=function(e,{top:t,left:r,bottom:n,right:i}){return{x:rP(e.x,r,i),y:rP(e.y,t,n)}}(n.layoutBox,t):this.constraints=!1,this.elastic=function(e=.35){return!1===e?e=0:!0===e&&(e=.35),{x:rA(e,"left","right"),y:rA(e,"top","bottom")}}(r),i!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&rj(e=>{!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=function(e,t){let r={};return void 0!==t.min&&(r.min=t.min-e.min),void 0!==t.max&&(r.max=t.max-e.min),r}(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){var e;let{dragConstraints:t,onMeasureDragConstraints:r}=this.getProps();if(!t||!ry(t))return!1;let n=t.current;(0,K.k)(null!==n,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");let{projection:i}=this.visualElement;if(!i||!i.layout)return!1;let a=function(e,t,r){let n=rU(e,r),{scroll:i}=t;return i&&(rK(n.x,i.offset.x),rK(n.y,i.offset.y)),n}(n,i.root,this.visualElement.getTransformPagePoint()),o={x:rE((e=i.layout.layoutBox).x,a.x),y:rE(e.y,a.y)};if(r){let e=r(function({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}(o));this.hasMutatedConstraints=!!e,e&&(o=rN(e))}return o}startAnimation(e){let{drag:t,dragMomentum:r,dragElastic:n,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{};return Promise.all(rj(o=>{if(!rq(o,t,this.currentDirection))return;let l=s&&s[o]||{};a&&(l={min:0,max:0});let u={type:"inertia",velocity:r?e[o]:0,bounceStiffness:n?200:1e6,bounceDamping:n?40:1e7,timeConstant:750,restDelta:1,restSpeed:10,...i,...l};return this.startAxisValueAnimation(o,u)})).then(o)}startAxisValueAnimation(e,t){let r=this.getAxisMotionValue(e);return tQ(this.visualElement,e),r.start(tU(e,r,0,t,this.visualElement,!1))}stopAnimation(){rj(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){rj(e=>{var t;return null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.pause()})}getAnimationState(e){var t;return null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.state}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps();return r[t]||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){rj(t=>{let{drag:r}=this.getProps();if(!rq(t,r,this.currentDirection))return;let{projection:n}=this.visualElement,i=this.getAxisMotionValue(t);if(n&&n.layout){let{min:r,max:a}=n.layout.layoutBox[t];i.set(e[t]-td(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:r}=this.visualElement;if(!ry(t)||!r||!this.constraints)return;this.stopAnimation();let n={x:0,y:0};rj(e=>{let t=this.getAxisMotionValue(e);if(t&&!1!==this.constraints){let r=t.get();n[e]=function(e,t){let r=.5,n=rb(e),i=rb(t);return i>n?r=tc(t.min,t.max-n,e.min):n>i&&(r=tc(e.min,e.max-i,t.min)),J(0,1,r)}({min:r,max:r},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),rj(t=>{if(!rq(t,e,null))return;let r=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];r.set(td(i,a,n[t]))})}addListeners(){if(!this.visualElement.current)return;rZ.set(this.visualElement,this);let e=ro(this.visualElement.current,"pointerdown",e=>{let{drag:t,dragListener:r=!0}=this.getProps();t&&r&&this.start(e)}),t=()=>{let{dragConstraints:e}=this.getProps();ry(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,n=r.addEventListener("measure",t);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),T.Wi.read(t);let i=ra(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(rj(t=>{let r=this.getAxisMotionValue(t);r&&(this.originPoint[t]+=e[t].translate,r.set(r.get()+e[t].translate))}),this.visualElement.render())});return()=>{i(),e(),n(),a&&a()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:r=!1,dragPropagation:n=!1,dragConstraints:i=!1,dragElastic:a=.35,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:r,dragPropagation:n,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function rq(e,t,r){return(!0===t||t===e)&&(null===r||r===e)}class rJ extends t8{constructor(e){super(e),this.removeGroupControls=_.Z,this.removeListeners=_.Z,this.controls=new rH(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_.Z}unmount(){this.removeGroupControls(),this.removeListeners()}}let rX=e=>(t,r)=>{e&&T.Wi.postRender(()=>e(t,r))};class rY extends t8{constructor(){super(...arguments),this.removePointerDownListener=_.Z}onPointerDown(e){this.session=new rl(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:rG(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:r,onPanEnd:n}=this.node.getProps();return{onSessionStart:rX(e),onStart:rX(t),onMove:r,onEnd:(e,t)=>{delete this.session,n&&T.Wi.postRender(()=>n(e,t))}}}mount(){this.removePointerDownListener=ro(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}var rQ=r(7437),r0=r(2265),r1=r(7797),r4=r(5050);let r3=(0,r0.createContext)({}),r2={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function r5(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}let r6={correct:(e,t)=>{if(!t.target)return e;if("string"==typeof e){if(!en.test(e))return e;e=parseFloat(e)}let r=r5(e,t.target.x),n=r5(e,t.target.y);return`${r}% ${n}%`}},r9={},{schedule:r8,cancel:r7}=(0,r(2981).Z)(queueMicrotask,!1);class ne extends r0.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:r,layoutId:n}=this.props,{projection:i}=e;Object.assign(r9,nr),i&&(t.group&&t.group.add(i),r&&r.register&&n&&r.register(i),i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),r2.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:r,drag:n,isPresent:i}=this.props,a=r.projection;return a&&(a.isPresent=i,n||e.layoutDependency!==t||void 0===t?a.willUpdate():this.safeToRemove(),e.isPresent===i||(i?a.promote():a.relegate()||T.Wi.postRender(()=>{let e=a.getStack();e&&e.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),r8.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:r}=this.props,{projection:n}=e;n&&(n.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(n),r&&r.deregister&&r.deregister(n))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}}function nt(e){let[t,r]=function(){let e=(0,r0.useContext)(r1.O);if(null===e)return[!0,null];let{isPresent:t,onExitComplete:r,register:n}=e,i=(0,r0.useId)();(0,r0.useEffect)(()=>n(i),[]);let a=(0,r0.useCallback)(()=>r&&r(i),[i,r]);return!t&&r?[!1,a]:[!0]}(),n=(0,r0.useContext)(r4.p);return(0,rQ.jsx)(ne,{...e,layoutGroup:n,switchLayoutGroup:(0,r0.useContext)(r3),isPresent:t,safeToRemove:r})}let nr={borderRadius:{...r6,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:r6,borderTopRightRadius:r6,borderBottomLeftRadius:r6,borderBottomRightRadius:r6,boxShadow:{correct:(e,{treeScale:t,projectionDelta:r})=>{let n=eK.parse(e);if(n.length>5)return e;let i=eK.createTransformer(e),a="number"!=typeof n[0]?1:0,o=r.x.scale*t.x,s=r.y.scale*t.y;n[0+a]/=o,n[1+a]/=s;let l=td(o,s,.5);return"number"==typeof n[2+a]&&(n[2+a]/=l),"number"==typeof n[3+a]&&(n[3+a]/=l),i(n)}}};var nn=r(2428);let ni=["TopLeft","TopRight","BottomLeft","BottomRight"],na=ni.length,no=e=>"string"==typeof e?parseFloat(e):e,ns=e=>"number"==typeof e||en.test(e);function nl(e,t){return void 0!==e[t]?e[t]:e.borderRadius}let nu=nd(0,.5,F),nc=nd(.5,.95,_.Z);function nd(e,t,r){return n=>nt?1:r(tc(e,t,n))}function np(e,t){e.min=t.min,e.max=t.max}function nf(e,t){np(e.x,t.x),np(e.y,t.y)}function nh(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function nm(e,t,r,n,i){return e-=t,e=n+1/r*(e-n),void 0!==i&&(e=n+1/i*(e-n)),e}function ng(e,t,[r,n,i],a,o){!function(e,t=0,r=1,n=.5,i,a=e,o=e){if(er.test(t)&&(t=parseFloat(t),t=td(o.min,o.max,t/100)-o.min),"number"!=typeof t)return;let s=td(a.min,a.max,n);e===a&&(s-=t),e.min=nm(e.min,t,r,s,i),e.max=nm(e.max,t,r,s,i)}(e,t[r],t[n],t[i],t.scale,a,o)}let nv=["x","scaleX","originX"],ny=["y","scaleY","originY"];function nb(e,t,r,n){ng(e.x,t,nv,r?r.x:void 0,n?n.x:void 0),ng(e.y,t,ny,r?r.y:void 0,n?n.y:void 0)}function nx(e){return 0===e.translate&&1===e.scale}function nw(e){return nx(e.x)&&nx(e.y)}function nC(e,t){return e.min===t.min&&e.max===t.max}function nk(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function nS(e,t){return nk(e.x,t.x)&&nk(e.y,t.y)}function nP(e){return rb(e.x)/rb(e.y)}function nE(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var nA=r(8746);class nT{constructor(){this.members=[]}add(e){(0,nA.y4)(this.members,e),e.scheduleRender()}remove(e){if((0,nA.cl)(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){let t;let r=this.members.findIndex(t=>e===t);if(0===r)return!1;for(let e=r;e>=0;e--){let r=this.members[e];if(!1!==r.isPresent){t=r;break}}return!!t&&(this.promote(t),!0)}promote(e,t){let r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender(),e.resumeFrom=r,t&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);let{crossfade:n}=e.options;!1===n&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:t,resumingFrom:r}=e;t.onExitComplete&&t.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}let n_=(e,t)=>e.depth-t.depth;class nD{constructor(){this.children=[],this.isDirty=!1}add(e){(0,nA.y4)(this.children,e),this.isDirty=!0}remove(e){(0,nA.cl)(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(n_),this.isDirty=!1,this.children.forEach(e)}}function nB(e){let t=tY(e)?e.get():e;return tG(t)?t.toValue():t}let nM={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},nj="undefined"!=typeof window&&void 0!==window.MotionDebug,nN=["","X","Y","Z"],nI={visibility:"hidden"},nR=0;function nO(e,t,r,n){let{latestValues:i}=t;i[e]&&(r[e]=i[e],t.setStaticValue(e,0),n&&(n[e]=0))}function n$({attachResizeListener:e,defaultParent:t,measureScroll:r,checkIsScrollRoot:n,resetTransform:i}){return class{constructor(e={},r=null==t?void 0:t()){this.id=nR++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,nj&&(nM.totalNodes=nM.resolvedTargetDeltas=nM.recalculatedProjection=0),this.nodes.forEach(nz),this.nodes.forEach(nH),this.nodes.forEach(nq),this.nodes.forEach(nK),nj&&window.MotionDebug.record(nM)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=r?r.root||r:this,this.path=r?[...r.path,r]:[],this.parent=r,this.depth=r?r.depth+1:0;for(let e=0;ethis.root.updateBlockedByResize=!1;e(t,()=>{this.root.updateBlockedByResize=!0,r&&r(),r=function(e,t){let r=e1.X.now(),n=({timestamp:t})=>{let i=t-r;i>=250&&((0,T.Pn)(n),e(i-250))};return T.Wi.read(n,!0),()=>(0,T.Pn)(n)}(n,0),r2.hasAnimatedSinceResize&&(r2.hasAnimatedSinceResize=!1,this.nodes.forEach(nZ))})}n&&this.root.registerSharedNode(n,this),!1!==this.options.animate&&a&&(n||i)&&this.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t,hasRelativeTargetChanged:r,layout:n})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let i=this.options.transition||a.getDefaultTransition()||n1,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=a.getProps(),l=!this.targetLayout||!nS(this.targetLayout,n)||r,u=!t&&r;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||u||t&&(l||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(e,u);let t={...k(i,"layout"),onPlay:o,onComplete:s};(a.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t)}else t||nZ(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=n})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,(0,T.Pn)(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){!this.isUpdateBlocked()&&(this.isUpdating=!0,this.nodes&&this.nodes.forEach(nJ),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&function e(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;let{visualElement:r}=t.options;if(!r)return;let n=r.props[tJ];if(window.MotionHasOptimisedAnimation(n,"transform")){let{layout:e,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",T.Wi,!(e||r))}let{parent:i}=t;i&&!i.hasCheckedOptimisedAppear&&e(i)}(this),this.root.isUpdating||this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e.999999999999&&(t.x=1),t.y<1.0000000000001&&t.y>.999999999999&&(t.y=1)}}(this.layoutCorrected,this.treeScale,this.path,r),t.layout&&!t.target&&(1!==this.treeScale.x||1!==this.treeScale.y)&&(t.target=t.layout.layoutBox,t.targetWithTransforms=rM());let{target:l}=t;if(!l){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}this.projectionDelta&&this.prevProjectionDelta?(nh(this.prevProjectionDelta.x,this.projectionDelta.x),nh(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),rw(this.projectionDelta,this.layoutCorrected,l,this.latestValues),this.treeScale.x===o&&this.treeScale.y===s&&nE(this.projectionDelta.x,this.prevProjectionDelta.x)&&nE(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",l)),nj&&nM.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){var t;if(null===(t=this.options.visualElement)||void 0===t||t.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=rD(),this.projectionDelta=rD(),this.projectionDeltaWithTransform=rD()}setAnimationOrigin(e,t=!1){let r;let n=this.snapshot,i=n?n.latestValues:{},a={...this.latestValues},o=rD();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=rM(),l=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),u=this.getStack(),c=!u||u.members.length<=1,d=!!(l&&!c&&!0===this.options.crossfade&&!this.path.some(n0));this.animationProgress=0,this.mixTargetDelta=t=>{let n=t/1e3;if(nY(o.x,e.x,n),nY(o.y,e.y,n),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout){var u,p,f,h;rS(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox),f=this.relativeTarget,h=this.relativeTargetOrigin,nQ(f.x,h.x,s.x,n),nQ(f.y,h.y,s.y,n),r&&(u=this.relativeTarget,p=r,nC(u.x,p.x)&&nC(u.y,p.y))&&(this.isProjectionDirty=!1),r||(r=rM()),nf(r,this.relativeTarget)}l&&(this.animationValues=a,function(e,t,r,n,i,a){i?(e.opacity=td(0,void 0!==r.opacity?r.opacity:1,nu(n)),e.opacityExit=td(void 0!==t.opacity?t.opacity:1,0,nc(n))):a&&(e.opacity=td(void 0!==t.opacity?t.opacity:1,void 0!==r.opacity?r.opacity:1,n));for(let i=0;i{r2.hasAnimatedSinceResize=!0,this.currentAnimation=function(e,t,r){let n=tY(0)?0:(0,tH.BX)(0);return n.start(tU("",n,1e3,r)),n.animation}(0,0,{...e,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:r,layout:n,latestValues:i}=e;if(t&&r&&n){if(this!==e&&this.layout&&n&&n5(this.options.animationType,this.layout.layoutBox,n.layoutBox)){r=this.target||rM();let t=rb(this.layout.layoutBox.x);r.x.min=e.target.x.min,r.x.max=r.x.min+t;let n=rb(this.layout.layoutBox.y);r.y.min=e.target.y.min,r.y.max=r.y.min+n}nf(t,r),rV(t,i),rw(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new nT),this.sharedNodes.get(e).add(t);let r=t.options.initialPromotionConfig;t.promote({transition:r?r.transition:void 0,preserveFollowOpacity:r&&r.shouldPreserveFollowOpacity?r.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){var e;let{layoutId:t}=this.options;return t&&(null===(e=this.getStack())||void 0===e?void 0:e.lead)||this}getPrevLead(){var e;let{layoutId:t}=this.options;return t?null===(e=this.getStack())||void 0===e?void 0:e.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:r}={}){let n=this.getStack();n&&n.promote(this,r),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:r}=e;if((r.z||r.rotate||r.rotateX||r.rotateY||r.rotateZ||r.skewX||r.skewY)&&(t=!0),!t)return;let n={};r.z&&nO("z",e,n,this.animationValues);for(let t=0;t{var t;return null===(t=e.currentAnimation)||void 0===t?void 0:t.stop()}),this.root.nodes.forEach(nV),this.root.sharedNodes.clear()}}}function nF(e){e.updateLayout()}function nL(e){var t;let r=(null===(t=e.resumeFrom)||void 0===t?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&r&&e.hasListeners("didUpdate")){let{layoutBox:t,measuredBox:n}=e.layout,{animationType:i}=e.options,a=r.source!==e.layout.source;"size"===i?rj(e=>{let n=a?r.measuredBox[e]:r.layoutBox[e],i=rb(n);n.min=t[e].min,n.max=n.min+i}):n5(i,r.layoutBox,t)&&rj(n=>{let i=a?r.measuredBox[n]:r.layoutBox[n],o=rb(t[n]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[n].max=e.relativeTarget[n].min+o)});let o=rD();rw(o,t,r.layoutBox);let s=rD();a?rw(s,e.applyTransform(n,!0),r.measuredBox):rw(s,t,r.layoutBox);let l=!nw(o),u=!1;if(!e.resumeFrom){let n=e.getClosestProjectingParent();if(n&&!n.resumeFrom){let{snapshot:i,layout:a}=n;if(i&&a){let o=rM();rS(o,r.layoutBox,i.layoutBox);let s=rM();rS(s,t,a.layoutBox),nS(o,s)||(u=!0),n.options.layoutRoot&&(e.relativeTarget=s,e.relativeTargetOrigin=o,e.relativeParent=n)}}}e.notifyListeners("didUpdate",{layout:t,snapshot:r,delta:s,layoutDelta:o,hasLayoutChanged:l,hasRelativeTargetChanged:u})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function nz(e){nj&&nM.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function nK(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function nW(e){e.clearSnapshot()}function nV(e){e.clearMeasurements()}function nU(e){e.isLayoutDirty=!1}function nG(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function nZ(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function nH(e){e.resolveTargetDelta()}function nq(e){e.calcProjection()}function nJ(e){e.resetSkewAndRotation()}function nX(e){e.removeLeadSnapshot()}function nY(e,t,r){e.translate=td(t.translate,0,r),e.scale=td(t.scale,1,r),e.origin=t.origin,e.originPoint=t.originPoint}function nQ(e,t,r,n){e.min=td(t.min,r.min,n),e.max=td(t.max,r.max,n)}function n0(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}let n1={duration:.45,ease:[.4,0,.1,1]},n4=e=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),n3=n4("applewebkit/")&&!n4("chrome/")?Math.round:_.Z;function n2(e){e.min=n3(e.min),e.max=n3(e.max)}function n5(e,t,r){return"position"===e||"preserve-aspect"===e&&!(.2>=Math.abs(nP(t)-nP(r)))}function n6(e){var t;return e!==e.root&&(null===(t=e.scroll)||void 0===t?void 0:t.wasRoot)}let n9=n$({attachResizeListener:(e,t)=>ra(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),n8={current:void 0},n7=n$({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!n8.current){let e=new n9({});e.mount(window),e.setOptions({layoutScroll:!0}),n8.current=e}return n8.current},resetTransform:(e,t)=>{e.style.transform=void 0!==t?t:"none"},checkIsScrollRoot:e=>"fixed"===window.getComputedStyle(e).position});function ie(e,t){let r=t?"onHoverStart":"onHoverEnd";return ro(e.current,t?"pointerenter":"pointerleave",(n,i)=>{if("touch"===n.pointerType||rv())return;let a=e.getProps();e.animationState&&a.whileHover&&e.animationState.setActive("whileHover",t);let o=a[r];o&&T.Wi.postRender(()=>o(n,i))},{passive:!e.getProps()[r]})}class it extends t8{mount(){this.unmount=tu(ie(this.node,!0),ie(this.node,!1))}unmount(){}}class ir extends t8{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(t){e=!0}e&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=tu(ra(this.node.current,"focus",()=>this.onFocus()),ra(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}let ii=(e,t)=>!!t&&(e===t||ii(e,t.parentElement));function ia(e,t){if(!t)return;let r=new PointerEvent("pointer"+e);t(r,rn(r))}class io extends t8{constructor(){super(...arguments),this.removeStartListeners=_.Z,this.removeEndListeners=_.Z,this.removeAccessibleListeners=_.Z,this.startPointerPress=(e,t)=>{if(this.isPressing)return;this.removeEndListeners();let r=this.node.getProps(),n=ro(window,"pointerup",(e,t)=>{if(!this.checkPressEnd())return;let{onTap:r,onTapCancel:n,globalTapTarget:i}=this.node.getProps(),a=i||ii(this.node.current,e.target)?r:n;a&&T.Wi.update(()=>a(e,t))},{passive:!(r.onTap||r.onPointerUp)}),i=ro(window,"pointercancel",(e,t)=>this.cancelPress(e,t),{passive:!(r.onTapCancel||r.onPointerCancel)});this.removeEndListeners=tu(n,i),this.startPress(e,t)},this.startAccessiblePress=()=>{let e=ra(this.node.current,"keydown",e=>{"Enter"!==e.key||this.isPressing||(this.removeEndListeners(),this.removeEndListeners=ra(this.node.current,"keyup",e=>{"Enter"===e.key&&this.checkPressEnd()&&ia("up",(e,t)=>{let{onTap:r}=this.node.getProps();r&&T.Wi.postRender(()=>r(e,t))})}),ia("down",(e,t)=>{this.startPress(e,t)}))}),t=ra(this.node.current,"blur",()=>{this.isPressing&&ia("cancel",(e,t)=>this.cancelPress(e,t))});this.removeAccessibleListeners=tu(e,t)}}startPress(e,t){this.isPressing=!0;let{onTapStart:r,whileTap:n}=this.node.getProps();n&&this.node.animationState&&this.node.animationState.setActive("whileTap",!0),r&&T.Wi.postRender(()=>r(e,t))}checkPressEnd(){return this.removeEndListeners(),this.isPressing=!1,this.node.getProps().whileTap&&this.node.animationState&&this.node.animationState.setActive("whileTap",!1),!rv()}cancelPress(e,t){if(!this.checkPressEnd())return;let{onTapCancel:r}=this.node.getProps();r&&T.Wi.postRender(()=>r(e,t))}mount(){let e=this.node.getProps(),t=ro(e.globalTapTarget?window:this.node.current,"pointerdown",this.startPointerPress,{passive:!(e.onTapStart||e.onPointerStart)}),r=ra(this.node.current,"focus",this.startAccessiblePress);this.removeStartListeners=tu(t,r)}unmount(){this.removeStartListeners(),this.removeEndListeners(),this.removeAccessibleListeners()}}let is=new WeakMap,il=new WeakMap,iu=e=>{let t=is.get(e.target);t&&t(e)},ic=e=>{e.forEach(iu)},id={some:0,all:1};class ip extends t8{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();let{viewport:e={}}=this.node.getProps(),{root:t,margin:r,amount:n="some",once:i}=e,a={root:t?t.current:void 0,rootMargin:r,threshold:"number"==typeof n?n:id[n]};return function(e,t,r){let n=function({root:e,...t}){let r=e||document;il.has(r)||il.set(r,{});let n=il.get(r),i=JSON.stringify(t);return n[i]||(n[i]=new IntersectionObserver(ic,{root:e,...t})),n[i]}(t);return is.set(e,r),n.observe(e),()=>{is.delete(e),n.unobserve(e)}}(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",t);let{onViewportEnter:r,onViewportLeave:n}=this.node.getProps(),a=t?r:n;a&&a(e)})}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;let{props:e,prevProps:t}=this.node;["amount","margin","root"].some(function({viewport:e={}},{viewport:t={}}={}){return r=>e[r]!==t[r]}(e,t))&&this.startObserver()}unmount(){}}var ih=r(9791);let im=(0,r0.createContext)({});var ig=r(9033);let iv=(0,r0.createContext)({strict:!1}),iy=!1;function ib(){window.MotionHandoffIsComplete=!0}function ix(e){return n(e.animate)||d.some(t=>o(e[t]))}function iw(e){return!!(ix(e)||e.variants)}function iC(e){return Array.isArray(e)?e.join(" "):e}let ik={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},iS={};for(let e in ik)iS[e]={isEnabled:t=>ik[e].some(e=>!!t[e])};var iP=r(7282);let iE=Symbol.for("motionComponentSymbol"),iA=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function iT(e){if("string"!=typeof e||e.includes("-"));else if(iA.indexOf(e)>-1||/[A-Z]/u.test(e))return!0;return!1}function i_(e,{style:t,vars:r},n,i){for(let a in Object.assign(e.style,t,i&&i.getProjectionStyles(n)),r)e.style.setProperty(a,r[a])}let iD=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function iB(e,t,r,n){for(let r in i_(e,t,void 0,n),t.attrs)e.setAttribute(iD.has(r)?r:(0,tq.D)(r),t.attrs[r])}function iM(e,{layout:t,layoutId:r}){return m.G.has(e)||e.startsWith("origin")||(t||void 0!==r)&&(!!r9[e]||"opacity"===e)}function ij(e,t,r){var n;let{style:i}=e,a={};for(let o in i)(tY(i[o])||t.style&&tY(t.style[o])||iM(o,e)||(null===(n=null==r?void 0:r.getValue(o))||void 0===n?void 0:n.liveStyle)!==void 0)&&(a[o]=i[o]);return r&&i&&"string"==typeof i.willChange&&(r.applyWillChange=!1),a}function iN(e,t,r){let n=ij(e,t,r);for(let r in e)(tY(e[r])||tY(t[r]))&&(n[-1!==m._.indexOf(r)?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r]=e[r]);return n}var iI=r(458),iR=r(5674);let iO=e=>(t,r)=>{let i=(0,r0.useContext)(im),a=(0,r0.useContext)(r1.O),o=()=>(function({applyWillChange:e=!1,scrapeMotionValuesFromProps:t,createRenderState:r,onMount:i},a,o,s,l){let u={latestValues:function(e,t,r,i,a){var o;let s={},l=[],u=i&&(null===(o=e.style)||void 0===o?void 0:o.willChange)===void 0,c=a(e,{});for(let e in c)s[e]=nB(c[e]);let{initial:d,animate:p}=e,f=ix(e),h=iw(e);t&&h&&!f&&!1!==e.inherit&&(void 0===d&&(d=t.initial),void 0===p&&(p=t.animate));let m=!!r&&!1===r.initial,g=(m=m||!1===d)?p:d;return g&&"boolean"!=typeof g&&!n(g)&&i$(e,g,(e,t)=>{for(let t in e){let r=e[t];if(Array.isArray(r)){let e=m?r.length-1:0;r=r[e]}null!==r&&(s[t]=r)}for(let e in t)s[e]=t[e]}),u&&(p&&!1!==d&&!n(p)&&i$(e,p,e=>{for(let t in e)!function(e,t){let r=(0,iR.p)(t);r&&(0,nA.y4)(e,r)}(l,t)}),l.length&&(s.willChange=l.join(","))),s}(a,o,s,!l&&e,t),renderState:r()};return i&&(u.mount=e=>i(a,e,u)),u})(e,t,i,a,r);return r?o():(0,iI.h)(o)};function i$(e,t,r){let n=Array.isArray(t)?t:[t];for(let t=0;t({style:{},transform:{},transformOrigin:{},vars:{}}),iL=()=>({...iF(),attrs:{}}),iz=(e,t)=>t&&"number"==typeof e?t.transform(e):e,iK={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},iW=m._.length;function iV(e,t,r){let{style:n,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let r=t[e];if(m.G.has(e)){o=!0;continue}if(U(e)){i[e]=r;continue}{let t=iz(r,eH[e]);e.startsWith("origin")?(s=!0,a[e]=t):n[e]=t}}if(!t.transform&&(o||r?n.transform=function(e,t,r){let n="",i=!0;for(let a=0;a"string"==typeof e&&"svg"===e.toLowerCase(),iJ={useVisualState:iO({scrapeMotionValuesFromProps:iN,createRenderState:iL,onMount:(e,t,{renderState:r,latestValues:n})=>{T.Wi.read(()=>{try{r.dimensions="function"==typeof t.getBBox?t.getBBox():t.getBoundingClientRect()}catch(e){r.dimensions={x:0,y:0,width:0,height:0}}}),T.Wi.render(()=>{iH(r,n,iq(t.tagName),e.transformTemplate),iB(t,r)})}})},iX={useVisualState:iO({applyWillChange:!0,scrapeMotionValuesFromProps:ij,createRenderState:iF})};function iY(e,t,r){for(let n in t)tY(t[n])||iM(n,r)||(e[n]=t[n])}let iQ=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function i0(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||iQ.has(e)}let i1=e=>!i0(e);try{(p=require("@emotion/is-prop-valid").default)&&(i1=e=>e.startsWith("on")?!i0(e):p(e))}catch(e){}let i4={current:null},i3={current:!1},i2=new WeakMap,i5=[...em,ej,eK],i6=e=>i5.find(eh(e)),i9=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class i8{scrapeMotionValuesFromProps(e,t,r){return{}}constructor({parent:e,props:t,presenceContext:r,reducedMotionConfig:n,blockInitialAnimation:i,visualState:a},o={}){this.applyWillChange=!1,this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=eC,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=e1.X.now();this.renderScheduledAtthis.bindToMotionValue(t,e)),i3.current||function(){if(i3.current=!0,iP.j){if(window.matchMedia){let e=window.matchMedia("(prefers-reduced-motion)"),t=()=>i4.current=e.matches;e.addListener(t),t()}else i4.current=!1}}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||i4.current),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){for(let e in i2.delete(this.current),this.projection&&this.projection.unmount(),(0,T.Pn)(this.notifyUpdate),(0,T.Pn)(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this),this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}bindToMotionValue(e,t){let r;this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();let n=m.G.has(e),i=t.on("change",t=>{this.latestValues[e]=t,this.props.onUpdate&&T.Wi.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),a=t.on("renderRequest",this.scheduleRender);window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{i(),a(),r&&r(),t.owner&&t.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in iS){let t=iS[e];if(!t)continue;let{isEnabled:r,Feature:n}=t;if(!this.features[e]&&n&&r(this.props)&&(this.features[e]=new n(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):rM()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;tt.variantChildren.delete(e)}addValue(e,t){let r=this.values.get(e);t!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return void 0===r&&void 0!==t&&(r=(0,tH.BX)(null===t?void 0:t,{owner:this}),this.addValue(e,r)),r}readValue(e,t){var r;let n=void 0===this.latestValues[e]&&this.current?null!==(r=this.getBaseTargetFromProps(this.props,e))&&void 0!==r?r:this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];return null!=n&&("string"==typeof n&&(W(n)||z(n))?n=parseFloat(n):!i6(n)&&eK.test(t)&&(n=eX(e,t)),this.setBaseTarget(e,tY(n)?n.get():n)),tY(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){var t;let r;let{initial:n}=this.props;if("string"==typeof n||"object"==typeof n){let i=l(this.props,n,null===(t=this.presenceContext)||void 0===t?void 0:t.custom);i&&(r=i[e])}if(n&&void 0!==r)return r;let i=this.getBaseTargetFromProps(this.props,e);return void 0===i||tY(i)?void 0!==this.initialValues[e]&&void 0===r?void 0:this.baseTarget[e]:i}on(e,t){return this.events[e]||(this.events[e]=new nn.L),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}}class i7 extends i8{constructor(){super(...arguments),this.KeyframeResolver=eQ}sortInstanceNodePosition(e,t){return 2&e.compareDocumentPosition(t)?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:r}){delete t[e],delete r[e]}}class ae extends i7{constructor(){super(...arguments),this.type="html",this.applyWillChange=!0,this.renderInstance=i_}readValueFromInstance(e,t){if(m.G.has(t)){let e=eJ(t);return e&&e.default||0}{let r=window.getComputedStyle(e),n=(U(t)?r.getPropertyValue(t):r[t])||0;return"string"==typeof n?n.trim():n}}measureInstanceViewportBox(e,{transformPagePoint:t}){return rU(e,t)}build(e,t,r){iV(e,t,r.transformTemplate)}scrapeMotionValuesFromProps(e,t,r){return ij(e,t,r)}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;tY(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent=`${e}`)}))}}class at extends i7{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=rM}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(m.G.has(t)){let e=eJ(t);return e&&e.default||0}return t=iD.has(t)?t:(0,tq.D)(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,r){return iN(e,t,r)}build(e,t,r){iH(e,t,this.isSVGTag,r.transformTemplate)}renderInstance(e,t,r,n){iB(e,t,r,n)}mount(e){this.isSVGTag=iq(e.tagName),super.mount(e)}}let ar=function(e){if("undefined"==typeof Proxy)return e;let t=new Map;return new Proxy((...t)=>e(...t),{get:(r,n)=>"create"===n?e:(t.has(n)||t.set(n,e(n)),t.get(n))})}((f={animation:{Feature:t7},exit:{Feature:rt},inView:{Feature:ip},tap:{Feature:io},focus:{Feature:ir},hover:{Feature:it},pan:{Feature:rY},drag:{Feature:rJ,ProjectionNode:n7,MeasureLayout:nt},layout:{ProjectionNode:n7,MeasureLayout:nt}},h=(e,t)=>iT(e)?new at(t):new ae(t,{allowProjection:e!==r0.Fragment}),function(e,{forwardMotionProps:t}={forwardMotionProps:!1}){return function(e){let{preloadedFeatures:t,createVisualElement:r,useRender:n,useVisualState:i,Component:a}=e;t&&function(e){for(let t in e)iS[t]={...iS[t],...e[t]}}(t);let s=(0,r0.forwardRef)(function(e,t){var s;let l;let u={...(0,r0.useContext)(ih._),...e,layoutId:function(e){let{layoutId:t}=e,r=(0,r0.useContext)(r4.p).id;return r&&void 0!==t?r+"-"+t:t}(e)},{isStatic:c}=u,d=function(e){let{initial:t,animate:r}=function(e,t){if(ix(e)){let{initial:t,animate:r}=e;return{initial:!1===t||o(t)?t:void 0,animate:o(r)?r:void 0}}return!1!==e.inherit?t:{}}(e,(0,r0.useContext)(im));return(0,r0.useMemo)(()=>({initial:t,animate:r}),[iC(t),iC(r)])}(e),p=i(e,c);if(!c&&iP.j){(0,r0.useContext)(iv).strict;let e=function(e){let{drag:t,layout:r}=iS;if(!t&&!r)return{};let n={...t,...r};return{MeasureLayout:(null==t?void 0:t.isEnabled(e))||(null==r?void 0:r.isEnabled(e))?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}(u);l=e.MeasureLayout,d.visualElement=function(e,t,r,n,i){var a;let{visualElement:o}=(0,r0.useContext)(im),s=(0,r0.useContext)(iv),l=(0,r0.useContext)(r1.O),u=(0,r0.useContext)(ih._).reducedMotion,c=(0,r0.useRef)();n=n||s.renderer,!c.current&&n&&(c.current=n(e,{visualState:t,parent:o,props:r,presenceContext:l,blockInitialAnimation:!!l&&!1===l.initial,reducedMotionConfig:u}));let d=c.current,p=(0,r0.useContext)(r3);d&&!d.projection&&i&&("html"===d.type||"svg"===d.type)&&function(e,t,r,n){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:l,layoutRoot:u}=t;e.projection=new r(e.latestValues,t["data-framer-portal-id"]?void 0:function e(t){if(t)return!1!==t.options.allowProjection?t.projection:e(t.parent)}(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&ry(s),visualElement:e,animationType:"string"==typeof a?a:"both",initialPromotionConfig:n,layoutScroll:l,layoutRoot:u})}(c.current,r,i,p),(0,r0.useInsertionEffect)(()=>{d&&d.update(r,l)});let f=r[tJ],h=(0,r0.useRef)(!!f&&!window.MotionHandoffIsComplete&&(null===(a=window.MotionHasOptimisedAnimation)||void 0===a?void 0:a.call(window,f)));return(0,ig.L)(()=>{d&&(d.updateFeatures(),r8.render(d.render),h.current&&d.animationState&&d.animationState.animateChanges())}),(0,r0.useEffect)(()=>{d&&(!h.current&&d.animationState&&d.animationState.animateChanges(),h.current=!1,iy||(iy=!0,queueMicrotask(ib)))}),d}(a,p,u,r,e.ProjectionNode)}return(0,rQ.jsxs)(im.Provider,{value:d,children:[l&&d.visualElement?(0,rQ.jsx)(l,{visualElement:d.visualElement,...u}):null,n(a,e,(s=d.visualElement,(0,r0.useCallback)(e=>{e&&p.mount&&p.mount(e),s&&(e?s.mount(e):s.unmount()),t&&("function"==typeof t?t(e):ry(t)&&(t.current=e))},[s])),p,c,d.visualElement)]})});return s[iE]=a,s}({...iT(e)?iJ:iX,preloadedFeatures:f,useRender:function(e=!1){return(t,r,n,{latestValues:i},a)=>{let o=(iT(t)?function(e,t,r,n){let i=(0,r0.useMemo)(()=>{let r=iL();return iH(r,t,iq(n),e.transformTemplate),{...r.attrs,style:{...r.style}}},[t]);if(e.style){let t={};iY(t,e.style,e),i.style={...t,...i.style}}return i}:function(e,t){let r={},n=function(e,t){let r=e.style||{},n={};return iY(n,r,e),Object.assign(n,function({transformTemplate:e},t){return(0,r0.useMemo)(()=>{let r=iF();return iV(r,t,e),Object.assign({},r.vars,r.style)},[t])}(e,t)),n}(e,t);return e.drag&&!1!==e.dragListener&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=!0===e.drag?"none":`pan-${"x"===e.drag?"y":"x"}`),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(r.tabIndex=0),r.style=n,r})(r,i,a,t),s=function(e,t,r){let n={};for(let i in e)("values"!==i||"object"!=typeof e.values)&&(i1(i)||!0===r&&i0(i)||!t&&!i0(i)||e.draggable&&i.startsWith("onDrag"))&&(n[i]=e[i]);return n}(r,"string"==typeof t,e),l=t!==r0.Fragment?{...s,...o,ref:n}:{},{children:u}=r,c=(0,r0.useMemo)(()=>tY(u)?u.get():u,[u]);return(0,r0.createElement)(t,{...l,children:c})}}(t),createVisualElement:h,Component:e})}))},1580:function(e,t,r){"use strict";r.d(t,{D:function(){return n}});let n=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase()},6019:function(e,t,r){"use strict";r.d(t,{G:function(){return i},_:function(){return n}});let n=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],i=new Set(n)},565:function(e,t,r){"use strict";r.d(t,{c:function(){return n}});let n={skipAnimations:!1,useManualTiming:!1}},8746:function(e,t,r){"use strict";function n(e,t){-1===e.indexOf(t)&&e.push(t)}function i(e,t){let r=e.indexOf(t);r>-1&&e.splice(r,1)}r.d(t,{cl:function(){return i},y4:function(){return n}})},9047:function(e,t,r){"use strict";r.d(t,{K:function(){return i},k:function(){return a}});var n=r(9276);let i=n.Z,a=n.Z},7282:function(e,t,r){"use strict";r.d(t,{j:function(){return n}});let n="undefined"!=typeof window},9276:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=e=>e},2428:function(e,t,r){"use strict";r.d(t,{L:function(){return i}});var n=r(8746);class i{constructor(){this.subscriptions=[]}add(e){return(0,n.y4)(this.subscriptions,e),()=>(0,n.cl)(this.subscriptions,e)}notify(e,t,r){let n=this.subscriptions.length;if(n){if(1===n)this.subscriptions[0](e,t,r);else for(let i=0;i!isNaN(parseFloat(e)),l={current:void 0};class u{constructor(e,t={}){this.version="11.9.0",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(e,t=!0)=>{let r=a.X.now();this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),t&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=a.X.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=s(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new n.L);let r=this.events[e].add(t);return"change"===e?()=>{r(),o.Wi.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e,t=!0){t&&this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e,t)}setWithVelocity(e,t,r){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return l.current&&l.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=a.X.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||e-this.updatedAt>30)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,30);return(0,i.R)(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function c(e,t){return new u(e,t)}},9447:function(e,t,r){"use strict";r.d(t,{L:function(){return o}});var n=r(804),i=r(5674),a=r(8746);class o extends n.Hg{constructor(){super(...arguments),this.values=[]}add(e){let t=(0,i.p)(e);t&&((0,a.y4)(this.values,t),this.update())}update(){this.set(this.values.length?this.values.join(", "):"auto")}}},5674:function(e,t,r){"use strict";r.d(t,{p:function(){return o}});var n=r(6323),i=r(1580),a=r(6019);function o(e){return a.G.has(e)?"transform":n.t.has(e)?(0,i.D)(e):void 0}},9998:function(e,t,r){"use strict";r.d(t,{Z:function(){return c}});let n=e=>"object"==typeof e&&null!=e&&1===e.nodeType,i=(e,t)=>(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e,a=(e,t)=>{if(e.clientHeight{let t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}})(e);return!!t&&(t.clientHeightat||a>e&&o=t&&s>=r?a-e-n:o>t&&sr?o-t+i:0,s=e=>{let t=e.parentElement;return null==t?e.getRootNode().host||null:t},l=(e,t)=>{var r,i,l,u;if("undefined"==typeof document)return[];let{scrollMode:c,block:d,inline:p,boundary:f,skipOverflowHiddenElements:h}=t,m="function"==typeof f?f:e=>e!==f;if(!n(e))throw TypeError("Invalid target");let g=document.scrollingElement||document.documentElement,v=[],y=e;for(;n(y)&&m(y);){if((y=s(y))===g){v.push(y);break}null!=y&&y===document.body&&a(y)&&!a(document.documentElement)||null!=y&&a(y,h)&&v.push(y)}let b=null!=(i=null==(r=window.visualViewport)?void 0:r.width)?i:innerWidth,x=null!=(u=null==(l=window.visualViewport)?void 0:l.height)?u:innerHeight,{scrollX:w,scrollY:C}=window,{height:k,width:S,top:P,right:E,bottom:A,left:T}=e.getBoundingClientRect(),{top:_,right:D,bottom:B,left:M}=(e=>{let t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e),j="start"===d||"nearest"===d?P-_:"end"===d?A+B:P+k/2-_+B,N="center"===p?T+S/2-M+D:"end"===p?E+D:T-M,I=[];for(let e=0;e=0&&T>=0&&A<=x&&E<=b&&P>=i&&A<=s&&T>=l&&E<=a)break;let u=getComputedStyle(t),f=parseInt(u.borderLeftWidth,10),h=parseInt(u.borderTopWidth,10),m=parseInt(u.borderRightWidth,10),y=parseInt(u.borderBottomWidth,10),_=0,D=0,B="offsetWidth"in t?t.offsetWidth-t.clientWidth-f-m:0,M="offsetHeight"in t?t.offsetHeight-t.clientHeight-h-y:0,R="offsetWidth"in t?0===t.offsetWidth?0:n/t.offsetWidth:0,O="offsetHeight"in t?0===t.offsetHeight?0:r/t.offsetHeight:0;if(g===t)_="start"===d?j:"end"===d?j-x:"nearest"===d?o(C,C+x,x,h,y,C+j,C+j+k,k):j-x/2,D="start"===p?N:"center"===p?N-b/2:"end"===p?N-b:o(w,w+b,b,f,m,w+N,w+N+S,S),_=Math.max(0,_+C),D=Math.max(0,D+w);else{_="start"===d?j-i-h:"end"===d?j-s+y+M:"nearest"===d?o(i,s,r,h,y+M,j,j+k,k):j-(i+r/2)+M/2,D="start"===p?N-l-f:"center"===p?N-(l+n/2)+B/2:"end"===p?N-a+m+B:o(l,a,n,f,m+B,N,N+S,S);let{scrollLeft:e,scrollTop:u}=t;_=0===O?0:Math.max(0,Math.min(u+_/O,t.scrollHeight-r/O+M)),D=0===R?0:Math.max(0,Math.min(e+D/R,t.scrollWidth-n/R+B)),j+=u-_,N+=e-D}I.push({el:t,top:_,left:D})}return I},u=e=>!1===e?{block:"end",inline:"nearest"}:e===Object(e)&&0!==Object.keys(e).length?e:{block:"start",inline:"nearest"};function c(e,t){if(!e.isConnected||!(e=>{let t=e;for(;t&&t.parentNode;){if(t.parentNode===document)return!0;t=t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}return!1})(e))return;if("object"==typeof t&&"function"==typeof t.behavior)return t.behavior(l(e,t));let r="boolean"==typeof t||null==t?void 0:t.behavior;for(let{el:n,top:i,left:a}of l(e,u(t)))n.scroll({top:i,left:a,behavior:r})}}}]); \ No newline at end of file diff --git a/_next/static/Ielt32Zi6peLWXPrery2b/_buildManifest.js b/_next/static/ubxbojYLKv9prwpbB5gUa/_buildManifest.js similarity index 100% rename from _next/static/Ielt32Zi6peLWXPrery2b/_buildManifest.js rename to _next/static/ubxbojYLKv9prwpbB5gUa/_buildManifest.js diff --git a/_next/static/Ielt32Zi6peLWXPrery2b/_ssgManifest.js b/_next/static/ubxbojYLKv9prwpbB5gUa/_ssgManifest.js similarity index 100% rename from _next/static/Ielt32Zi6peLWXPrery2b/_ssgManifest.js rename to _next/static/ubxbojYLKv9prwpbB5gUa/_ssgManifest.js diff --git a/index.html b/index.html index e52d5d4..9612423 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -ChatGPT Subtitle Translator

Configuration

Use Structured Mode

0
10 – 50

Use Moderator

RPM

Input

  1. おはようございます。
  2. お元気ですか?
  3. はい、元気です。
  4. 今日は天気がいいですね。
  5. はい、とてもいい天気です。
  6. 今日は何をしますか?
  7. 午後から
  8. 友達と
  9. 映画を見ます。
  10. いいですね。

Output

ChatGPT Subtitle Translator Web Graphical User Interface

\ No newline at end of file +ChatGPT Subtitle Translator

Configuration

Use Structured Mode

0
10 – 50

Use Moderator

RPM

Input

  1. おはようございます。
  2. お元気ですか?
  3. はい、元気です。
  4. 今日は天気がいいですね。
  5. はい、とてもいい天気です。
  6. 今日は何をしますか?
  7. 午後から
  8. 友達と
  9. 映画を見ます。
  10. いいですね。

Output

ChatGPT Subtitle Translator Web Graphical User Interface

\ No newline at end of file diff --git a/index.txt b/index.txt index 748fd14..3ebdab0 100644 --- a/index.txt +++ b/index.txt @@ -1,7 +1,7 @@ -2:I[2566,["189","static/chunks/189-6ca42e7f5601622c.js","931","static/chunks/app/page-27b9c853ceb3d934.js"],"TranslatorApplication"] -3:I[2770,["189","static/chunks/189-6ca42e7f5601622c.js","931","static/chunks/app/page-27b9c853ceb3d934.js"],"Link"] +2:I[2566,["189","static/chunks/189-a57e6da36a0024a8.js","931","static/chunks/app/page-27b9c853ceb3d934.js"],"TranslatorApplication"] +3:I[2770,["189","static/chunks/189-a57e6da36a0024a8.js","931","static/chunks/app/page-27b9c853ceb3d934.js"],"Link"] 4:I[9275,[],""] 5:I[1343,[],""] -0:["Ielt32Zi6peLWXPrery2b",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","main",null,{"className":"min-h-screen flex flex-col justify-between","children":[["$","$L2",null,{}],["$","footer",null,{"className":"flex w-full my-4","children":["$","div",null,{"className":"mx-auto","children":[["$","h1",null,{"className":"text-center","children":["$","b",null,{"className":"w-full","children":"ChatGPT Subtitle Translator Web Graphical User Interface"}]}],["$","div",null,{"className":"flex flex-wrap items-center justify-center","children":[["$","div",null,{"className":"sm:w-auto text-center","children":["$","$L3",null,{"isExternal":true,"className":"mr-2 text-blue-500","href":"https://github.com/Cerlancism","children":"@Cerlancism"}]}],["$","a",null,{"href":"https://github.com/Cerlancism/chatgpt-subtitle-translator","target":"_blank","rel":"noopener noreferrer","className":"flex items-center justify-center","children":["$","img",null,{"className":"w-8 h-8 mx-auto","src":"/chatgpt-subtitle-translator/github-mark.svg","alt":"GitHub"}]}]]}]]}]}]]}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/chatgpt-subtitle-translator/_next/static/css/1ef80b228c9ead25.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/chatgpt-subtitle-translator/_next/static/css/6d5f83e1909274db.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_4ed10b light","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] +0:["ubxbojYLKv9prwpbB5gUa",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",{"children":["__PAGE__",{},[["$L1",["$","main",null,{"className":"min-h-screen flex flex-col justify-between","children":[["$","$L2",null,{}],["$","footer",null,{"className":"flex w-full my-4","children":["$","div",null,{"className":"mx-auto","children":[["$","h1",null,{"className":"text-center","children":["$","b",null,{"className":"w-full","children":"ChatGPT Subtitle Translator Web Graphical User Interface"}]}],["$","div",null,{"className":"flex flex-wrap items-center justify-center","children":[["$","div",null,{"className":"sm:w-auto text-center","children":["$","$L3",null,{"isExternal":true,"className":"mr-2 text-blue-500","href":"https://github.com/Cerlancism","children":"@Cerlancism"}]}],["$","a",null,{"href":"https://github.com/Cerlancism/chatgpt-subtitle-translator","target":"_blank","rel":"noopener noreferrer","className":"flex items-center justify-center","children":["$","img",null,{"className":"w-8 h-8 mx-auto","src":"/chatgpt-subtitle-translator/github-mark.svg","alt":"GitHub"}]}]]}]]}]}]]}],null],null],null]},[[[["$","link","0",{"rel":"stylesheet","href":"/chatgpt-subtitle-translator/_next/static/css/1ef80b228c9ead25.css","precedence":"next","crossOrigin":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/chatgpt-subtitle-translator/_next/static/css/6d5f83e1909274db.css","precedence":"next","crossOrigin":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_4ed10b light","children":["$","$L4",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L5",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}]}]}]],null],null],["$L6",null]]]] 6:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"charSet":"utf-8"}],["$","title","2",{"children":"ChatGPT Subtitle Translator"}],["$","meta","3",{"name":"description","content":"Web graphical user interface to translate SRT subtitles using OpenAI ChatGPT API"}],["$","link","4",{"rel":"icon","href":"/chatgpt-subtitle-translator/favicon.ico","type":"image/x-icon","sizes":"48x48"}],["$","meta","5",{"name":"next-size-adjust"}]] 1:null