@searchia-widget-test/widget 0.0.0-stage → 0.1.0-test.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,157 @@
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));function u(e,t){for(var n in t)e[n]=t[n];return e}function d(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function f(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?ge.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return p(e,o,r,i,null)}function p(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++_e,__i:-1,__u:0};return i==null&&x.vnode!=null&&x.vnode(a),a}function m(e){return e.children}function h(e,t){this.props=e,this.context=t}function g(e,t){if(t==null)return e.__?g(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?g(e):null}function _(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return _(e)}}function v(e){(!e.__d&&(e.__d=!0)&&ye.push(e)&&!y.__r++||be!=x.debounceRendering)&&((be=x.debounceRendering)||xe)(y)}function y(){for(var e,t,n,r,i,a,o,s=1;ye.length;)ye.length>s&&ye.sort(Se),e=ye.shift(),s=ye.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,a=[],o=[],t.__P&&((n=u({},r)).__v=r.__v+1,x.vnode&&x.vnode(n),se(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,a,i??g(r),!!(32&r.__u),o),n.__v=r.__v,n.__.__k[n.__i]=n,le(a,n,o),r.__e=r.__=null,n.__e!=i&&_(n)));y.__r=0}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||ke,y=t.length;for(c=te(n,t,v,c,y),d=0;d<y;d++)(p=n.__k[d])!=null&&(f=p.__i==-1?Oe:v[p.__i]||Oe,p.__i=d,g=se(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&fe(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(_=!!(4&p.__u))||f.__k===p.__k?c=ne(p,c,e,_):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function te(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?p(null,o,null,null,null):je(o)?p(m,{children:o},null,null,null):o.constructor==null&&o.__b>0?p(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=re(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=g(s)),pe(s,s));return r}function ne(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=ne(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=g(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function b(e,t){return t||=[],e==null||typeof e==`boolean`||(je(e)?e.some(function(e){b(e,t)}):t.push(e)),t}function re(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ie(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||Ae.test(t)?n:n+`px`}function ae(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ie(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ie(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(Ce,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n.u=r.u:(n.u=we,e.addEventListener(t,a?Ee:Te,a)):e.removeEventListener(t,a?Ee:Te,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function oe(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=we++;else if(t.t<n.u)return;return n(x.event?x.event(t):t)}}}function se(e,t,n,r,i,a,o,s,c,l){var f,p,g,_,v,y,te,ne,b,re,ie,ae,oe,se,le,fe,pe,he=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=x.__b)&&f(t);n:if(typeof he==`function`)try{if(ne=t.props,b=`prototype`in he&&he.prototype.render,re=(f=he.contextType)&&r[f.__c],ie=f?re?re.props.value:f.__:r,n.__c?te=(p=t.__c=n.__c).__=p.__E:(b?t.__c=p=new he(ne,ie):(t.__c=p=new h(ne,ie),p.constructor=he,p.render=me),re&&re.sub(p),p.props=ne,p.state||={},p.context=ie,p.__n=r,g=p.__d=!0,p.__h=[],p._sb=[]),b&&p.__s==null&&(p.__s=p.state),b&&he.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=u({},p.__s)),u(p.__s,he.getDerivedStateFromProps(ne,p.__s))),_=p.props,v=p.state,p.__v=t,g)b&&he.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),b&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(b&&he.getDerivedStateFromProps==null&&ne!==_&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(ne,ie),!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(ne,p.__s,ie)||t.__v==n.__v){for(t.__v!=n.__v&&(p.props=ne,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),ae=0;ae<p._sb.length;ae++)p.__h.push(p._sb[ae]);p._sb=[],p.__h.length&&o.push(p);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(ne,p.__s,ie),b&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(_,v,y)})}if(p.context=ie,p.props=ne,p.__P=e,p.__e=!1,oe=x.__r,se=0,b){for(p.state=p.__s,p.__d=!1,oe&&oe(t),f=p.render(p.props,p.state,p.context),le=0;le<p._sb.length;le++)p.__h.push(p._sb[le]);p._sb=[]}else do p.__d=!1,oe&&oe(t),f=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++se<25);p.state=p.__s,p.getChildContext!=null&&(r=u(u({},r),p.getChildContext())),b&&!g&&p.getSnapshotBeforeUpdate!=null&&(y=p.getSnapshotBeforeUpdate(_,v)),fe=f,f!=null&&f.type===m&&f.key==null&&(fe=ue(f.props.children)),s=ee(e,je(fe)?fe:[fe],t,n,r,i,a,o,s,c,l),p.base=t.__e,t.__u&=-161,p.__h.length&&o.push(p),te&&(p.__E=p.__=null)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(pe=a.length;pe--;)d(a[pe]);ce(t)}else t.__e=n.__e,t.__k=n.__k,e.then||ce(t);x.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=de(n.__e,t,n,r,i,a,o,c,l);return(f=x.diffed)&&f(t),128&t.__u?void 0:s}function ce(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(ce)}function le(e,t,n){for(var r=0;r<n.length;r++)fe(n[r],n[++r],n[++r]);x.__c&&x.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){x.__e(e,t.__v)}})}function ue(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:je(e)?e.map(ue):u({},e)}function de(e,t,n,r,i,a,o,s,c){var l,u,f,p,m,h,_,v=n.props,y=t.props,te=t.type;if(te==`svg`?i=`http://www.w3.org/2000/svg`:te==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((m=a[l])&&`setAttribute`in m==!!te&&(te?m.localName==te:m.nodeType==3)){e=m,a[l]=null;break}}if(e==null){if(te==null)return document.createTextNode(y);e=document.createElementNS(i,te,y.is&&y),s&&(x.__m&&x.__m(t,a),s=!1),a=null}if(te==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=ge.call(e.childNodes),v=n.props||Oe,!s&&a!=null)for(v={},l=0;l<e.attributes.length;l++)v[(m=e.attributes[l]).name]=m.value;for(l in v)if(m=v[l],l!=`children`){if(l==`dangerouslySetInnerHTML`)f=m;else if(!(l in y)){if(l==`value`&&`defaultValue`in y||l==`checked`&&`defaultChecked`in y)continue;ae(e,l,null,m,i)}}for(l in y)m=y[l],l==`children`?p=m:l==`dangerouslySetInnerHTML`?u=m:l==`value`?h=m:l==`checked`?_=m:s&&typeof m!=`function`||v[l]===m||ae(e,l,m,v[l],i);if(u)s||f&&(u.__html==f.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(f&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,je(p)?p:[p],t,n,r,te==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&g(n,0),s,c),a!=null)for(l=a.length;l--;)d(a[l]);s||(l=`value`,te==`progress`&&h==null?e.removeAttribute(`value`):h!=null&&(h!==e[l]||te==`progress`&&!h||te==`option`&&h!=v[l])&&ae(e,l,h,v[l],i),l=`checked`,_!=null&&_!=e[l]&&ae(e,l,_,v[l],i))}return e}function fe(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){x.__e(e,n)}}function pe(e,t,n){var r,i;if(x.unmount&&x.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||fe(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){x.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&pe(r[i],t,n||typeof e.type!=`function`);n||d(e.__e),e.__c=e.__=e.__e=void 0}function me(e,t,n){return this.constructor(e,n)}function he(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),x.__&&x.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],se(t,e=(!r&&n||t).__k=f(m,null,[e]),i||Oe,Oe,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?ge.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),le(a,e,o)}var ge,x,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me=o(()=>{Oe={},ke=[],Ae=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,je=Array.isArray,ge=ke.slice,x={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},_e=0,ve=function(e){return e!=null&&e.constructor==null},h.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=u({},this.state),typeof e==`function`&&(e=e(u({},n),this.props)),e&&u(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),v(this))},h.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),v(this))},h.prototype.render=m,ye=[],xe=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Se=function(e,t){return e.__v.__b-t.__v.__b},y.__r=0,Ce=/(PointerCapture)$|Capture$/i,we=0,Te=oe(!1),Ee=oe(!0),De=0});function Ne(){return`searchia-${globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`}`}var Pe=class{name=`SearchiaApiAdapter`;isMock=!1;conversationId=Ne();active=null;constructor(e={}){this.config=e}resetConversation(){this.active?.abort(),this.active=null,this.conversationId=Ne()}async sendMessage(e){if(e.signal?.aborted)throw new DOMException(`Aborted`,`AbortError`);if(this.active)throw Error(`A Searchia response is already in progress.`);let t=new AbortController;this.active=t;let n=()=>t.abort();e.signal?.addEventListener(`abort`,n,{once:!0});let r;try{let n=typeof this.config.configuration==`function`?await this.config.configuration():this.config.configuration;if(!n?.id||!Array.isArray(n.tools))throw Error(`Searchia configuration.id and configuration.tools are required.`);if(t.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);let i=e.history.filter(e=>(e.role===`user`||e.role===`assistant`)&&e.content.trim()).map(e=>({id:e.id,role:e.role,parts:[{type:`text`,text:e.content}]})),a=i[i.length-1];(a?.role!==`user`||a.parts[0].text!==e.prompt)&&i.push({id:Ne(),role:`user`,parts:[{type:`text`,text:e.prompt}]});let o={Accept:`text/event-stream`,"Content-Type":`application/json`};this.config.apiKey&&(o[`X-API-Key`]=this.config.apiKey);let s=await fetch(this.config.endpoint??`/api/v1/agents/test/completions`,{method:`POST`,credentials:`omit`,headers:o,signal:t.signal,body:JSON.stringify({id:this.conversationId,messages:i,configuration:n,messageId:i[i.length-1].id})});if(t.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);if(!s.ok)throw Error(`Searchia completion failed (${s.status}).`);if(!s.body)throw Error(`Searchia did not return a response stream.`);r=s.body.getReader();let c=()=>{r?.cancel().catch(()=>void 0)};t.signal.addEventListener(`abort`,c,{once:!0});let l={id:e.assistantMessageId??Ne(),parts:[]},u=new Map,d=``,f=!1,p=n=>{if(f||t.signal.aborted)return;if(n||={type:`finish`},n.type===`error`||n.type===`abort`)throw Error(typeof n.errorText==`string`?n.errorText:`Searchia interrupted the response.`);let r=l.parts.map(e=>({...e}));if(l={...l,parts:r},n.type===`start`&&typeof n.messageId==`string`&&(l.id=n.messageId),n.messageMetadata&&typeof n.messageMetadata==`object`&&(l.metadata={...l.metadata,...n.messageMetadata}),n.type===`start-step`&&r.push({type:`step-start`}),/^(text|reasoning)-(start|delta|end)$/.test(n.type)){let e=n.type.split(`-`)[0],t=`${e}:${n.id}`,i=u.get(t);i===void 0&&(i=r.length,u.set(t,i),r.push({type:e,text:``}));let a=r[i];a.state=n.type.endsWith(`-end`)?`done`:`streaming`,n.type.endsWith(`-delta`)&&typeof n.delta==`string`&&(a.text=(a.text??``)+n.delta)}else if(n.type.startsWith(`tool-`)&&typeof n.toolCallId==`string`){let e=`tool:${n.toolCallId}`,t=u.get(e);t===void 0&&(t=r.length,u.set(e,t),r.push({type:`dynamic-tool`,toolCallId:n.toolCallId}));let i=r[t];typeof n.toolName==`string`&&(i.toolName=n.toolName),(n.type===`tool-input-start`||n.type===`tool-input-delta`)&&(i.state=`input-streaming`),n.type===`tool-input-delta`&&typeof n.inputTextDelta==`string`&&(i.inputText=String(i.inputText??``)+n.inputTextDelta),n.type===`tool-input-available`&&(i.state=`input-available`,i.input=n.input),n.type===`tool-output-available`&&(i.state=`output-available`,i.output=n.output),(n.type===`tool-input-error`||n.type===`tool-output-error`)&&(i.state=`output-error`,i.errorText=n.errorText,n.input!==void 0&&(i.input=n.input))}else n.type.startsWith(`data-`)&&!n.transient&&r.push({type:n.type,data:n.data});if(n.type===`finish`){f=!0;for(let e of r)(e.type===`text`||e.type===`reasoning`)&&(e.state=`done`)}e.onMessage?.(l);let i=r.filter(e=>e.type===`text`).map(e=>e.text??``).join(``);i!==d&&(e.onChunk?.(i.startsWith(d)?i.slice(d.length):i,i),d=i)},m=new TextDecoder,h=new Fe(p);try{for(;!f;){let e=await r.read();if(t.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);if(h.push(e.done?m.decode():m.decode(e.value,{stream:!0}),e.done),e.done){if(!f)throw Error(`Searchia response ended before completion.`);break}}}finally{t.signal.removeEventListener(`abort`,c)}return d}finally{e.signal?.removeEventListener(`abort`,n),await r?.cancel().catch(()=>void 0),r?.releaseLock(),this.active===t&&(this.active=null)}}},Fe=class{buffer=``;data=[];constructor(e){this.emit=e}push(e,t=!1){for(this.buffer+=e;;){let e=/\r\n|\r|\n/.exec(this.buffer);if(!e||!t&&e[0]===`\r`&&e.index===this.buffer.length-1)break;this.line(this.buffer.slice(0,e.index)),this.buffer=this.buffer.slice(e.index+e[0].length)}t&&(this.buffer&&this.line(this.buffer),this.buffer=``,this.dispatch())}line(e){e?(e===`data`||e.startsWith(`data:`))&&this.data.push(e.slice(5).replace(/^ /,``)):this.dispatch()}dispatch(){if(!this.data.length)return;let e=this.data.join(`
2
+ `);if(this.data=[],e===`[DONE]`){this.emit(null);return}let t=JSON.parse(e);if(!t||typeof t!=`object`||!(`type`in t)||typeof t.type!=`string`)throw Error(`Invalid Searchia completion event.`);this.emit(t)}},Ie=class{name=`MockSearchiaAdapter`;isMock=!0;delayMs;constructor(e={}){this.delayMs=e.delayMs??25}async getSuggestedQuestions(e=`fa`){return e===`fa`?[{id:`q1`,question:`سرچیا چیست؟`},{id:`q2`,question:`چطور ویجت را در وب‌سایت قرار دهم؟`},{id:`q3`,question:`آیا پاسخ‌ها از Markdown پشتیبانی می‌کنند؟`}]:[{id:`q1`,question:`What is Searchia Agent Studio?`},{id:`q2`,question:`How do I embed Searchia chat on my website?`},{id:`q3`,question:`Does Searchia support streaming markdown answers?`}]}async sendMessage(e){let{prompt:t,onChunk:n,signal:r}=e,i=this.generateResponse(t,e.language??`fa`);await new Promise(e=>setTimeout(e,this.delayMs*24));let a=i.split(` `),o=``;for(let e=0;e<a.length;e++){if(r?.aborted)throw new DOMException(`Operation aborted by user`,`AbortError`);let t=a[e];o+=(e===0?``:` `)+t,n&&n(t,o),await new Promise(e=>setTimeout(e,this.delayMs))}return o}async sendFeedback(e,t){console.info(`[MockSearchiaAdapter] Feedback recorded: message "${e}" received ${t===1?`👍 (thumbs up)`:`👎 (thumbs down)`}`)}generateResponse(e,t){if(t===`fa`){let t=`
3
+
4
+ *این پاسخ نمایشی است و از API واقعی دریافت نشده است.*`;return/ویجت|وب‌سایت|embed|website/i.test(e)?`برای افزودن ویجت، فایل‌های CSS و JavaScript را بارگذاری و سپس آن را راه‌اندازی کنید:
5
+
6
+ \`\`\`javascript
7
+ SearchiaChat.init({ language: "fa" });
8
+ \`\`\`
9
+
10
+ ویجت بدون iframe اجرا می‌شود.`+t:/markdown|کد|جریان|stream/i.test(e)?`بله، پاسخ‌های نمایشی از **Markdown** پشتیبانی می‌کنند:
11
+
12
+ - متن **پررنگ** و *مورب*
13
+ - فهرست‌ها و کد مانند \`const language = 'fa';\`
14
+ - بلوک کد با دکمهٔ کپی
15
+
16
+ \`\`\`javascript
17
+ SearchiaChat.init({ language: "fa" });
18
+ \`\`\``+t:`**دستیار سرچیا**
19
+
20
+ این نسخه، نمونهٔ نمایشی یک دستیار گفت‌وگویی است. می‌توانید سؤال بپرسید و نمایش تدریجی پاسخ، کپی کد و بازخورد را امتحان کنید.
21
+
22
+ در این حالت پاسخ‌ها شبیه‌سازی می‌شوند.`+t}let n=e.toLowerCase();return n.includes(`what is searchia`)||n.includes(`agent studio`)?`**Searchia Agent Studio** is an AI-powered conversational search platform designed to give your users direct, accurate answers from your organization's content.
23
+
24
+ ### Key Capabilities:
25
+ - **Conversational Search**: Synthesizes results into natural, actionable answers.
26
+ - **Framework Agnostic**: Embeds via vanilla JavaScript without iframes.
27
+ - **Custom Knowledge**: Grounded directly on your indexed documents.
28
+
29
+ *(Note: This response is generated by the \`MockSearchiaAdapter\` for UI verification.)*`:n.includes(`embed`)||n.includes(`website`)||n.includes(`how do i`)?`Embedding the Searchia AI chat widget into any website requires just a script and stylesheet:
30
+
31
+ \`\`\`html
32
+ <!-- 1. Include Searchia styles and script -->
33
+ <link rel="stylesheet" href="searchia-chat.min.css" />
34
+ <script src="searchia-chat.min.js"></script>
35
+
36
+ <!-- 2. Initialize the widget -->
37
+ <script>
38
+ SearchiaChat.init({
39
+ container: "#chat-widget",
40
+ buttonText: "Ask Searchia",
41
+ });
42
+ </script>
43
+ \`\`\`
44
+
45
+ No \`<iframe>\` or heavy frameworks required! It mounts directly to the DOM with its UI runtime bundled.`:n.includes(`markdown`)||n.includes(`streaming`)?`Yes! Searchia renders rich GitHub-flavored Markdown with safe HTML sanitization:
46
+
47
+ 1. **Bold** and *italic* formatting
48
+ 2. Ordered and unordered lists
49
+ 3. Inline code like \`const query = 'search';\`
50
+ 4. Code blocks with one-click copy buttons
51
+ 5. Sanitized links: [Searchia Documentation](https://searchia.ir)
52
+
53
+ \`\`\`javascript
54
+ SearchiaChat.init({ language: "en" });
55
+ \`\`\`
56
+
57
+ All streamed token-by-token in real-time. These are simulated responses.`:`Thank you for asking about **"${e}"**!\n\nI am currently operating with the **MockSearchiaAdapter** in Searchia's proof-of-concept widget.
58
+
59
+ This demo is using simulated responses.
60
+
61
+ > **Mock Adapter Status**: Active • Streaming Verified • Feedback Enabled`}};function Le(e,t){C.__h&&C.__h(S,e,et||t),et=0;var n=S.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function Re(e){return et=1,ze(Xe,e)}function ze(e,t,n){var r=Le(Ze++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Xe(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=S,!S.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};S.__f=!0;var a=S.shouldComponentUpdate,o=S.componentWillUpdate;S.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},S.shouldComponentUpdate=i}return r.__N||r.__}function Be(e,t){var n=Le(Ze++,3);!C.__s&&Ye(n.__H,t)&&(n.__=e,n.u=t,S.__H.__h.push(n))}function Ve(e,t){var n=Le(Ze++,4);!C.__s&&Ye(n.__H,t)&&(n.__=e,n.u=t,S.__h.push(n))}function He(e){return et=5,Ue(function(){return{current:e}},[])}function Ue(e,t){var n=Le(Ze++,7);return Ye(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function We(e,t){return et=8,Ue(function(){return e},t)}function Ge(){for(var e;e=tt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(qe),e.__H.__h.forEach(Je),e.__H.__h=[]}catch(t){e.__H.__h=[],C.__e(t,e.__v)}}function Ke(e){var t,n=function(){clearTimeout(r),ct&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ct&&(t=requestAnimationFrame(n))}function qe(e){var t=S,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),S=t}function Je(e){var t=S;e.__c=e.__(),S=t}function Ye(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Xe(e,t){return typeof t==`function`?t(e):t}var Ze,S,Qe,$e,et,tt,C,nt,rt,it,at,ot,st,ct,lt=o(()=>{Me(),et=0,tt=[],C=x,nt=C.__b,rt=C.__r,it=C.diffed,at=C.__c,ot=C.unmount,st=C.__,C.__b=function(e){S=null,nt&&nt(e)},C.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),st&&st(e,t)},C.__r=function(e){rt&&rt(e),Ze=0;var t=(S=e.__c).__H;t&&(Qe===S?(t.__h=[],S.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(qe),t.__h.forEach(Je),t.__h=[],Ze=0)),Qe=S},C.diffed=function(e){it&&it(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(tt.push(t)!==1&&$e===C.requestAnimationFrame||(($e=C.requestAnimationFrame)||Ke)(Ge)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Qe=S=null},C.__c=function(e,t){t.some(function(e){try{e.__h.forEach(qe),e.__h=e.__h.filter(function(e){return!e.__||Je(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],C.__e(n,e.__v)}}),at&&at(e,t)},C.unmount=function(e){ot&&ot(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{qe(e)}catch(e){t=e}}),n.__H=void 0,t&&C.__e(t,n.__v))},ct=typeof requestAnimationFrame==`function`});function ut(e,t){for(var n in t)e[n]=t[n];return e}function dt(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function ft(e,t){this.props=e,this.context=t}function pt(e,t){function n(e){var n=this.props.ref,r=n==e.ref;return!r&&n&&(n.call?n(null):n.current=null),t?!t(this.props,e)||!r:dt(this.props,e)}function r(t){return this.shouldComponentUpdate=n,f(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}function mt(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=ut({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return mt(e,t,n)})),e}function ht(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return ht(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function gt(){this.__u=0,this.o=null,this.__b=null}function _t(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function vt(){this.i=null,this.l=null}function yt(e){return this.getChildContext=function(){return e.context},e.children}function bt(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){he(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},insertBefore:function(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}he(f(yt,{context:t.context},e.__v),t.v)}function xt(e,t){var n=f(bt,{__v:e,h:t});return n.containerInfo=t,n}function St(){}function Ct(){return this.cancelBubble}function wt(){return this.defaultPrevented}var Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt=o(()=>{Me(),lt(),lt(),(ft.prototype=new h).isPureReactComponent=!0,ft.prototype.shouldComponentUpdate=function(e,t){return dt(this.props,e)||dt(this.state,t)},Tt=x.__b,x.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Tt&&Tt(e)},Et=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.forward_ref`)||3911,Dt=function(e,t){return e==null?null:b(b(e).map(t))},Ot={map:Dt,forEach:Dt,count:function(e){return e?b(e).length:0},only:function(e){var t=b(e);if(t.length!==1)throw`Children.only`;return t[0]},toArray:b},kt=x.__e,x.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}kt(e,t,n,r)},At=x.unmount,x.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),At&&At(e)},(gt.prototype=new h).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=_t(r.__v),a=!1,o=function(){a||(a=!0,n.__R=null,i?i(s):s())};n.__R=o;var s=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=ht(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},gt.prototype.componentWillUnmount=function(){this.o=[]},gt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=mt(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&f(m,null,e.fallback);return i&&(i.__u&=-33),[f(m,null,t.__a?null:e.children),i]},jt=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}},(vt.prototype=new h).__a=function(e){var t=this,n=_t(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),jt(t,e,r)):i()};n?n(a):a()}},vt.prototype.render=function(e){this.i=null,this.l=new Map;var t=b(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},vt.prototype.componentDidUpdate=vt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){jt(e,n,t)})},Mt=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,Nt=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Pt=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ft=/[A-Z0-9]/g,It=typeof document<`u`,Lt=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)},h.prototype.isReactComponent={},[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(h.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}),Rt=x.event,x.event=function(e){return Rt&&(e=Rt(e)),e.persist=St,e.isPropagationStopped=Ct,e.isDefaultPrevented=wt,e.nativeEvent=e},Bt={enumerable:!1,configurable:!0,get:function(){return this.class}},Vt=x.vnode,x.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)===-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||It&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||Lt(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:Pt.test(a)&&(a=s):s=a=`oninput`:i&&Nt.test(a)?a=a.replace(Ft,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&r.multiple&&Array.isArray(r.value)&&(r.value=b(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),n==`select`&&r.defaultValue!=null&&(r.value=b(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value})),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,Bt)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=Mt,Vt&&Vt(e)},Ht=x.__r,x.__r=function(e){Ht&&Ht(e),zt=e.__c},Ut=x.diffed,x.diffed=function(e){Ut&&Ut(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value),zt=null}}),Gt=`vercel.ai.error`,Kt=Symbol.for(Gt),qt,Jt=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[qt]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Gt)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};qt=Kt;var Yt=Jt,Xt=`AI_APICallError`,Zt=`vercel.ai.error.${Xt}`,Qt=Symbol.for(Zt),$t;$t=Qt;var en=`AI_EmptyResponseBodyError`,tn=`vercel.ai.error.${en}`,nn=Symbol.for(tn),rn;rn=nn;function an(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var on=`AI_InvalidArgumentError`,sn=`vercel.ai.error.${on}`,cn=Symbol.for(sn),ln,un=class extends Yt{constructor({message:e,cause:t,argument:n}){super({name:on,message:e,cause:t}),this[ln]=!0,this.argument=n}static isInstance(e){return Yt.hasMarker(e,sn)}};ln=cn;var dn=`AI_InvalidPromptError`,fn=`vercel.ai.error.${dn}`,pn=Symbol.for(fn),mn;mn=pn;var hn=`AI_InvalidResponseDataError`,gn=`vercel.ai.error.${hn}`,_n=Symbol.for(gn),vn;vn=_n;var yn=`AI_JSONParseError`,bn=`vercel.ai.error.${yn}`,xn=Symbol.for(bn),Sn,Cn=class extends Yt{constructor({text:e,cause:t}){super({name:yn,message:`JSON parsing failed: Text: ${e}.
62
+ Error message: ${an(t)}`,cause:t}),this[Sn]=!0,this.text=e}static isInstance(e){return Yt.hasMarker(e,bn)}};Sn=xn;var wn=`AI_LoadAPIKeyError`,Tn=`vercel.ai.error.${wn}`,En=Symbol.for(Tn),Dn;Dn=En;var On=`AI_LoadSettingError`,kn=`vercel.ai.error.${On}`,An=Symbol.for(kn),jn;jn=An;var Mn=`AI_NoContentGeneratedError`,Nn=`vercel.ai.error.${Mn}`,Pn=Symbol.for(Nn),Fn;Fn=Pn;var In=`AI_NoSuchModelError`,Ln=`vercel.ai.error.${In}`,Rn=Symbol.for(Ln),zn;zn=Rn;var Bn=`AI_TooManyEmbeddingValuesForCallError`,Vn=`vercel.ai.error.${Bn}`,Hn=Symbol.for(Vn),Un;Un=Hn;var Wn=`AI_TypeValidationError`,Gn=`vercel.ai.error.${Wn}`,Kn=Symbol.for(Gn),qn,Jn=class e extends Yt{constructor({value:e,cause:t}){super({name:Wn,message:`Type validation failed: Value: ${JSON.stringify(e)}.
63
+ Error message: ${an(t)}`,cause:t}),this[qn]=!0,this.value=e}static isInstance(e){return Yt.hasMarker(e,Gn)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}};qn=Kn;var Yn=Jn,Xn=`AI_UnsupportedFunctionalityError`,Zn=`vercel.ai.error.${Xn}`,Qn=Symbol.for(Zn),$n;$n=Qn;var er=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function tr(e){}function nr(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=tr,onError:n=tr,onRetry:r=tr,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=rr(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1,i=e.slice(t+r);f(n,i,e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
64
+ `;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new er(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new er(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
65
+ `)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function rr(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
66
+ `,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
67
+ `&&r++}}return[t,n]}var ir=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=nr({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};const ar=Object.freeze({status:`aborted`});function w(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}const or=Symbol(`zod_brand`);var sr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const cr={};function lr(e){return e&&Object.assign(cr,e),cr}function ur(e){let t=Object.values(e).filter(e=>typeof e==`number`),n=Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t);return n}function dr(e,t){return typeof t==`bigint`?t.toString():t}function fr(e){let t=!1;return{get value(){if(!t){let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function pr(e){return e==null}function mr(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function hr(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}function T(e,t,n){let r=!1;Object.defineProperty(e,t,{get(){if(!r){let r=n();return e[t]=r,r}throw Error(`cached value already set`)},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function gr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _r(e){return JSON.stringify(e)}const vr=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function yr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const br=fr(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{let e=Function;return new e(``),!0}catch{return!1}});function xr(e){if(yr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(yr(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}const Sr=new Set([`string`,`number`,`symbol`]);function Cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function wr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function E(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Tr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Er={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Dr(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;n[e]=r.shape[e]}return wr(e,{...e._zod.def,shape:n,checks:[]})}function Or(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);if(!t[e])continue;delete n[e]}return wr(e,{...e._zod.def,shape:n,checks:[]})}function kr(e,t){if(!xr(t))throw Error(`Invalid input to extend: expected a plain object`);let n={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return gr(this,`shape`,n),n},checks:[]};return wr(e,n)}function Ar(e,t){return wr(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return gr(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function jr(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t]}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return wr(t,{...t._zod.def,shape:i,checks:[]})}function Mr(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);if(!n[t])continue;i[t]=new e({type:`nonoptional`,innerType:r[t]})}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return wr(t,{...t._zod.def,shape:i,checks:[]})}function Nr(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Pr(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Fr(e){return typeof e==`string`?e:e?.message}function Ir(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let i=Fr(e.inst?._zod.def?.error?.(e))??Fr(t?.error?.(e))??Fr(n.customError?.(e))??Fr(n.localeError?.(e))??`Invalid input`;r.message=i}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Lr(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Rr(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const zr=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),Object.defineProperty(e,`message`,{get(){return JSON.stringify(t,dr,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Br=w(`$ZodError`,zr),Vr=w(`$ZodError`,zr,{Parent:Error});function Hr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ur(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i],a=i===t.path.length-1;a?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}const Wr=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new sr;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Ir(e,a,lr())));throw vr(t,i?.callee),t}return o.value},Gr=Wr(Vr),Kr=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Ir(e,a,lr())));throw vr(t,i?.callee),t}return o.value},qr=Kr(Vr),Jr=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new sr;return a.issues.length?{success:!1,error:new(e??Br)(a.issues.map(e=>Ir(e,i,lr())))}:{success:!0,data:a.value}},Yr=Jr(Vr),Xr=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Ir(e,i,lr())))}:{success:!0,data:a.value}},Zr=Xr(Vr),Qr=/^[cC][^\s-]{8,}$/,$r=/^[0-9a-z]+$/,ei=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ti=/^[0-9a-vA-V]{20}$/,ni=/^[A-Za-z0-9]{27}$/,ri=/^[a-zA-Z0-9_-]{21}$/,ii=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ai=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,oi=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,si=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ci=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function li(){return new RegExp(ci,`u`)}const ui=/^(?:(?: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])$/,di=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,fi=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,pi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mi=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,hi=/^[A-Za-z0-9_-]*$/,gi=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,_i=/^\+(?:[0-9]){6,14}[0-9]$/,vi=`(?:(?:\\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])))`,yi=RegExp(`^${vi}$`);function bi(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`,n=typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;return n}function xi(e){return RegExp(`^${bi(e)}$`)}function Si(e){let t=bi({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${vi}T(?:${r})$`)}const Ci=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},wi=/^\d+$/,Ti=/^-?\d+(?:\.\d+)?/i,Ei=/true|false/i,Di=/null/i,Oi=/^[^A-Z]*$/,ki=/^[^a-z]*$/,Ai=w(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ji={number:`number`,bigint:`bigint`,object:`date`},Mi=w(`$ZodCheckLessThan`,(e,t)=>{Ai.init(e,t);let n=ji[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ni=w(`$ZodCheckGreaterThan`,(e,t)=>{Ai.init(e,t);let n=ji[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pi=w(`$ZodCheckMultipleOf`,(e,t)=>{Ai.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);let r=typeof n.value==`bigint`?n.value%t.value===BigInt(0):hr(n.value,t.value)===0;r||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Fi=w(`$ZodCheckNumberFormat`,(e,t)=>{Ai.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Er[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=wi)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Ii=w(`$ZodCheckMaxLength`,(e,t)=>{var n;Ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!pr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i<=t.maximum)return;let a=Lr(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Li=w(`$ZodCheckMinLength`,(e,t)=>{var n;Ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!pr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if(i>=t.minimum)return;let a=Lr(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ri=w(`$ZodCheckLengthEquals`,(e,t)=>{var n;Ai.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!pr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Lr(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),zi=w(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Ai.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Bi=w(`$ZodCheckRegex`,(e,t)=>{zi.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Vi=w(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Oi,zi.init(e,t)}),Hi=w(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ki,zi.init(e,t)}),Ui=w(`$ZodCheckIncludes`,(e,t)=>{Ai.init(e,t);let n=Cr(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Wi=w(`$ZodCheckStartsWith`,(e,t)=>{Ai.init(e,t);let n=RegExp(`^${Cr(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Gi=w(`$ZodCheckEndsWith`,(e,t)=>{Ai.init(e,t);let n=RegExp(`.*${Cr(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ki=w(`$ZodCheckOverwrite`,(e,t)=>{Ai.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var qi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e,n=t.split(`
68
+ `).filter(e=>e),r=Math.min(...n.map(e=>e.length-e.trimStart().length)),i=n.map(e=>e.slice(r)).map(e=>` `.repeat(this.indent*2)+e);for(let e of i)this.content.push(e)}compile(){let e=Function,t=this?.args,n=this?.content??[``],r=[...n.map(e=>` ${e}`)];return new e(...t,r.join(`
69
+ `))}};const Ji={major:4,minor:0,patch:0},D=w(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ji;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Nr(e),i;for(let a of t){if(a._zod.def.when){let t=a._zod.def.when(e);if(!t)continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new sr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;let n=e.issues.length;n!==t&&(r||=Nr(e,t))});else{let n=e.issues.length;if(n===t)continue;r||=Nr(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new sr;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=Yr(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Zr(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Yi=w(`$ZodString`,(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ci(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),O=w(`$ZodStringFormat`,(e,t)=>{zi.init(e,t),Yi.init(e,t)}),Xi=w(`$ZodGUID`,(e,t)=>{t.pattern??=ai,O.init(e,t)}),Zi=w(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8},n=e[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=oi(n)}else t.pattern??=oi();O.init(e,t)}),Qi=w(`$ZodEmail`,(e,t)=>{t.pattern??=si,O.init(e,t)}),$i=w(`$ZodURL`,(e,t)=>{O.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:gi.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith(`/`)&&a.endsWith(`/`)?n.value=a.slice(0,-1):n.value=a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ea=w(`$ZodEmoji`,(e,t)=>{t.pattern??=li(),O.init(e,t)}),ta=w(`$ZodNanoID`,(e,t)=>{t.pattern??=ri,O.init(e,t)}),na=w(`$ZodCUID`,(e,t)=>{t.pattern??=Qr,O.init(e,t)}),ra=w(`$ZodCUID2`,(e,t)=>{t.pattern??=$r,O.init(e,t)}),ia=w(`$ZodULID`,(e,t)=>{t.pattern??=ei,O.init(e,t)}),aa=w(`$ZodXID`,(e,t)=>{t.pattern??=ti,O.init(e,t)}),oa=w(`$ZodKSUID`,(e,t)=>{t.pattern??=ni,O.init(e,t)}),sa=w(`$ZodISODateTime`,(e,t)=>{t.pattern??=Si(t),O.init(e,t)}),ca=w(`$ZodISODate`,(e,t)=>{t.pattern??=yi,O.init(e,t)}),la=w(`$ZodISOTime`,(e,t)=>{t.pattern??=xi(t),O.init(e,t)}),ua=w(`$ZodISODuration`,(e,t)=>{t.pattern??=ii,O.init(e,t)}),da=w(`$ZodIPv4`,(e,t)=>{t.pattern??=ui,O.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),fa=w(`$ZodIPv6`,(e,t)=>{t.pattern??=di,O.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),pa=w(`$ZodCIDRv4`,(e,t)=>{t.pattern??=fi,O.init(e,t)}),ma=w(`$ZodCIDRv6`,(e,t)=>{t.pattern??=pi,O.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function ha(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ga=w(`$ZodBase64`,(e,t)=>{t.pattern??=mi,O.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{ha(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function _a(e){if(!hi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return ha(n)}const va=w(`$ZodBase64URL`,(e,t)=>{t.pattern??=hi,O.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{_a(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ya=w(`$ZodE164`,(e,t)=>{t.pattern??=_i,O.init(e,t)});function ba(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const xa=w(`$ZodJWT`,(e,t)=>{O.init(e,t),e._zod.check=n=>{ba(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Sa=w(`$ZodNumber`,(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ti,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ca=w(`$ZodNumber`,(e,t)=>{Fi.init(e,t),Sa.init(e,t)}),wa=w(`$ZodBoolean`,(e,t)=>{D.init(e,t),e._zod.pattern=Ei,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Ta=w(`$ZodNull`,(e,t)=>{D.init(e,t),e._zod.pattern=Di,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Ea=w(`$ZodUnknown`,(e,t)=>{D.init(e,t),e._zod.parse=e=>e}),Da=w(`$ZodNever`,(e,t)=>{D.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Oa(e,t,n){e.issues.length&&t.issues.push(...Pr(n,e.issues)),t.value[n]=e.value}const ka=w(`$ZodArray`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Oa(t,n,e))):Oa(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Aa(e,t,n){e.issues.length&&t.issues.push(...Pr(n,e.issues)),t.value[n]=e.value}function ja(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...Pr(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const Ma=w(`$ZodObject`,(e,t)=>{D.init(e,t);let n=fr(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof D))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Tr(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});T(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new qi([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=_r(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=_r(e);t.write(`
70
+ if (${n}.issues.length) {
71
+ if (input[${r}] === undefined) {
72
+ if (${r} in input) {
73
+ newResult[${r}] = undefined;
74
+ }
75
+ } else {
76
+ payload.issues = payload.issues.concat(
77
+ ${n}.issues.map((iss) => ({
78
+ ...iss,
79
+ path: iss.path ? [${r}, ...iss.path] : [${r}],
80
+ }))
81
+ );
82
+ }
83
+ } else if (${n}.value === undefined) {
84
+ if (${r} in input) newResult[${r}] = undefined;
85
+ } else {
86
+ newResult[${r}] = ${n}.value;
87
+ }
88
+ `)}else{let n=a[e];t.write(`const ${n} = ${i(e)};`),t.write(`
89
+ if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
90
+ ...iss,
91
+ path: iss.path ? [${_r(e)}, ...iss.path] : [${_r(e)}]
92
+ })));`),t.write(`newResult[${_r(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=yr,o=!cr.jitless,s=br,c=o&&s.value,l=t.catchall,u;e._zod.parse=(s,d)=>{u??=n.value;let f=s.value;if(!a(f))return s.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),s;let p=[];if(o&&c&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),s=i(s,d);else{s.value={};let e=u.shape;for(let t of u.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?ja(e,s,t,f):Aa(e,s,t))):i?ja(r,s,t,f):Aa(r,s,t)}}if(!l)return p.length?Promise.all(p).then(()=>s):s;let m=[],h=u.keySet,g=l._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>Aa(t,s,e))):Aa(t,s,e)}return m.length&&s.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>s):s}});function Na(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ir(e,r,lr())))}),t}const Pa=w(`$ZodUnion`,(e,t)=>{D.init(e,t),T(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),T(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),T(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),T(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>mr(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>Na(t,n,e,r)):Na(a,n,e,r)}}),Fa=w(`$ZodDiscriminatedUnion`,(e,t)=>{Pa.init(e,t);let n=e._zod.parse;T(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=fr(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!yr(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),Ia=w(`$ZodIntersection`,(e,t)=>{D.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n),o=i instanceof Promise||a instanceof Promise;return o?Promise.all([i,a]).then(([t,n])=>Ra(e,t,n)):Ra(e,i,a)}});function La(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(xr(e)&&xr(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=La(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=La(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ra(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Nr(e))return e;let r=La(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const za=w(`$ZodRecord`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!xr(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Pr(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Pr(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>Ir(e,r,lr())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Pr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Pr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Ba=w(`$ZodEnum`,(e,t)=>{D.init(e,t);let n=ur(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>Sr.has(typeof e)).map(e=>typeof e==`string`?Cr(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),Va=w(`$ZodLiteral`,(e,t)=>{D.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Cr(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),Ha=w(`$ZodTransform`,(e,t)=>{D.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async){let t=r instanceof Promise?r:Promise.resolve(r);return t.then(t=>(e.value=t,e))}if(r instanceof Promise)throw new sr;return e.value=r,e}}),Ua=w(`$ZodOptional`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${mr(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Wa=w(`$ZodNullable`,(e,t)=>{D.init(e,t),T(e._zod,`optin`,()=>t.innerType._zod.optin),T(e._zod,`optout`,()=>t.innerType._zod.optout),T(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${mr(e.source)}|null)$`):void 0}),T(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ga=w(`$ZodDefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ka(e,t)):Ka(r,t)}});function Ka(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const qa=w(`$ZodPrefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ja=w(`$ZodNonOptional`,(e,t)=>{D.init(e,t),T(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ya(t,e)):Ya(i,e)}});function Ya(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Xa=w(`$ZodCatch`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,T(e._zod,`optout`,()=>t.innerType._zod.optout),T(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ir(e,n,lr()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ir(e,n,lr()))},input:e.value}),e.issues=[]),e)}}),Za=w(`$ZodPipe`,(e,t)=>{D.init(e,t),T(e._zod,`values`,()=>t.in._zod.values),T(e._zod,`optin`,()=>t.in._zod.optin),T(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Qa(e,t,n)):Qa(r,t,n)}});function Qa(e,t,n){return Nr(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const $a=w(`$ZodReadonly`,(e,t)=>{D.init(e,t),T(e._zod,`propValues`,()=>t.innerType._zod.propValues),T(e._zod,`values`,()=>t.innerType._zod.values),T(e._zod,`optin`,()=>t.innerType._zod.optin),T(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(eo):eo(r)}});function eo(e){return e.value=Object.freeze(e.value),e}const to=w(`$ZodLazy`,(e,t)=>{D.init(e,t),T(e._zod,`innerType`,()=>t.getter()),T(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),T(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),T(e._zod,`optin`,()=>e._zod.innerType._zod.optin),T(e._zod,`optout`,()=>e._zod.innerType._zod.optout),e._zod.parse=(t,n)=>{let r=e._zod.innerType;return r._zod.run(t,n)}}),no=w(`$ZodCustom`,(e,t)=>{Ai.init(e,t),D.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ro(t,n,r,e));ro(i,n,r,e)}});function ro(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Rr(e))}}const io=Symbol(`ZodOutput`),ao=Symbol(`ZodInput`);var oo=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function so(){return new oo}const co=so();function lo(e,t){return new e({type:`string`,...E(t)})}function uo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...E(t)})}function fo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...E(t)})}function po(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...E(t)})}function mo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...E(t)})}function ho(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...E(t)})}function go(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...E(t)})}function _o(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...E(t)})}function vo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...E(t)})}function yo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...E(t)})}function bo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...E(t)})}function xo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...E(t)})}function So(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...E(t)})}function Co(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...E(t)})}function wo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...E(t)})}function To(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...E(t)})}function Eo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...E(t)})}function Do(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...E(t)})}function Oo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...E(t)})}function ko(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...E(t)})}function Ao(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...E(t)})}function jo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...E(t)})}function Mo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...E(t)})}function No(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...E(t)})}function Po(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...E(t)})}function Fo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...E(t)})}function Io(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...E(t)})}function Lo(e,t){return new e({type:`number`,checks:[],...E(t)})}function Ro(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...E(t)})}function zo(e,t){return new e({type:`boolean`,...E(t)})}function Bo(e,t){return new e({type:`null`,...E(t)})}function Vo(e){return new e({type:`unknown`})}function Ho(e,t){return new e({type:`never`,...E(t)})}function Uo(e,t){return new Mi({check:`less_than`,...E(t),value:e,inclusive:!1})}function Wo(e,t){return new Mi({check:`less_than`,...E(t),value:e,inclusive:!0})}function Go(e,t){return new Ni({check:`greater_than`,...E(t),value:e,inclusive:!1})}function Ko(e,t){return new Ni({check:`greater_than`,...E(t),value:e,inclusive:!0})}function qo(e,t){return new Pi({check:`multiple_of`,...E(t),value:e})}function Jo(e,t){let n=new Ii({check:`max_length`,...E(t),maximum:e});return n}function Yo(e,t){return new Li({check:`min_length`,...E(t),minimum:e})}function Xo(e,t){return new Ri({check:`length_equals`,...E(t),length:e})}function Zo(e,t){return new Bi({check:`string_format`,format:`regex`,...E(t),pattern:e})}function Qo(e){return new Vi({check:`string_format`,format:`lowercase`,...E(e)})}function $o(e){return new Hi({check:`string_format`,format:`uppercase`,...E(e)})}function es(e,t){return new Ui({check:`string_format`,format:`includes`,...E(t),includes:e})}function ts(e,t){return new Wi({check:`string_format`,format:`starts_with`,...E(t),prefix:e})}function ns(e,t){return new Gi({check:`string_format`,format:`ends_with`,...E(t),suffix:e})}function rs(e){return new Ki({check:`overwrite`,tx:e})}function os(e){return rs(t=>t.normalize(e))}function ss(){return rs(e=>e.trim())}function cs(){return rs(e=>e.toLowerCase())}function ls(){return rs(e=>e.toUpperCase())}function us(e,t,n){return new e({type:`array`,element:t,...E(n)})}function ds(e,t,n){let r=E(n);r.abort??=!0;let i=new e({type:`custom`,check:`custom`,fn:t,...r});return i}function fs(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...E(n)});return r}var ps=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??co,this.target=e?.target??`draft-2020-12`,this.unrepresentable=e?.unrepresentable??`throw`,this.override=e?.override??(()=>{}),this.io=e?.io??`output`,this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var n;let r=e._zod.def,i={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},a=this.seen.get(e);if(a){a.count++;let n=t.schemaPath.includes(e);return n&&(a.cycle=t.path),a.schema}let o={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let n={...t,schemaPath:[...t.schemaPath,e],path:t.path},a=e._zod.parent;if(a)o.ref=a,this.process(a,n),this.seen.get(a).isParent=!0;else{let t=o.schema;switch(r.type){case`string`:{let n=t;n.type=`string`;let{minimum:r,maximum:a,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof r==`number`&&(n.minLength=r),typeof a==`number`&&(n.maxLength=a),s&&(n.format=i[s]??s,n.format===``&&delete n.format),l&&(n.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?n.pattern=e[0].source:e.length>1&&(o.schema.allOf=[...e.map(e=>({...this.target===`draft-7`?{type:`string`}:{},pattern:e.source}))])}break}case`number`:{let n=t,{minimum:r,maximum:i,format:a,multipleOf:o,exclusiveMaximum:s,exclusiveMinimum:c}=e._zod.bag;typeof a==`string`&&a.includes(`int`)?n.type=`integer`:n.type=`number`,typeof c==`number`&&(n.exclusiveMinimum=c),typeof r==`number`&&(n.minimum=r,typeof c==`number`&&(c>=r?delete n.minimum:delete n.exclusiveMinimum)),typeof s==`number`&&(n.exclusiveMaximum=s),typeof i==`number`&&(n.maximum=i,typeof s==`number`&&(s<=i?delete n.maximum:delete n.exclusiveMaximum)),typeof o==`number`&&(n.multipleOf=o);break}case`boolean`:{let e=t;e.type=`boolean`;break}case`bigint`:if(this.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`);break;case`symbol`:if(this.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`);break;case`null`:t.type=`null`;break;case`any`:break;case`unknown`:break;case`undefined`:if(this.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`);break;case`void`:if(this.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`);break;case`never`:t.not={};break;case`date`:if(this.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`);break;case`array`:{let i=t,{minimum:a,maximum:o}=e._zod.bag;typeof a==`number`&&(i.minItems=a),typeof o==`number`&&(i.maxItems=o),i.type=`array`,i.items=this.process(r.element,{...n,path:[...n.path,`items`]});break}case`object`:{let e=t;e.type=`object`,e.properties={};let i=r.shape;for(let t in i)e.properties[t]=this.process(i[t],{...n,path:[...n.path,`properties`,t]});let a=new Set(Object.keys(i)),o=new Set([...a].filter(e=>{let t=r.shape[e]._zod;return this.io===`input`?t.optin===void 0:t.optout===void 0}));o.size>0&&(e.required=Array.from(o)),r.catchall?._zod.def.type===`never`?e.additionalProperties=!1:r.catchall?r.catchall&&(e.additionalProperties=this.process(r.catchall,{...n,path:[...n.path,`additionalProperties`]})):this.io===`output`&&(e.additionalProperties=!1);break}case`union`:{let e=t;e.anyOf=r.options.map((e,t)=>this.process(e,{...n,path:[...n.path,`anyOf`,t]}));break}case`intersection`:{let e=t,i=this.process(r.left,{...n,path:[...n.path,`allOf`,0]}),a=this.process(r.right,{...n,path:[...n.path,`allOf`,1]}),o=e=>`allOf`in e&&Object.keys(e).length===1,s=[...o(i)?i.allOf:[i],...o(a)?a.allOf:[a]];e.allOf=s;break}case`tuple`:{let i=t;i.type=`array`;let a=r.items.map((e,t)=>this.process(e,{...n,path:[...n.path,`prefixItems`,t]}));if(this.target===`draft-2020-12`?i.prefixItems=a:i.items=a,r.rest){let e=this.process(r.rest,{...n,path:[...n.path,`items`]});this.target===`draft-2020-12`?i.items=e:i.additionalItems=e}r.rest&&(i.items=this.process(r.rest,{...n,path:[...n.path,`items`]}));let{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s);break}case`record`:{let e=t;e.type=`object`,e.propertyNames=this.process(r.keyType,{...n,path:[...n.path,`propertyNames`]}),e.additionalProperties=this.process(r.valueType,{...n,path:[...n.path,`additionalProperties`]});break}case`map`:if(this.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`);break;case`set`:if(this.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`);break;case`enum`:{let e=t,n=ur(r.entries);n.every(e=>typeof e==`number`)&&(e.type=`number`),n.every(e=>typeof e==`string`)&&(e.type=`string`),e.enum=n;break}case`literal`:{let e=t,n=[];for(let e of r.values)if(e===void 0){if(this.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(this.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);n.push(Number(e))}else n.push(e);if(n.length!==0)if(n.length===1){let t=n[0];e.type=t===null?`null`:typeof t,e.const=t}else n.every(e=>typeof e==`number`)&&(e.type=`number`),n.every(e=>typeof e==`string`)&&(e.type=`string`),n.every(e=>typeof e==`boolean`)&&(e.type=`string`),n.every(e=>e===null)&&(e.type=`null`),e.enum=n;break}case`file`:{let n=t,r={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:i,maximum:a,mime:o}=e._zod.bag;i!==void 0&&(r.minLength=i),a!==void 0&&(r.maxLength=a),o?o.length===1?(r.contentMediaType=o[0],Object.assign(n,r)):n.anyOf=o.map(e=>{let t={...r,contentMediaType:e};return t}):Object.assign(n,r);break}case`transform`:if(this.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`);break;case`nullable`:{let e=this.process(r.innerType,n);t.anyOf=[e,{type:`null`}];break}case`nonoptional`:this.process(r.innerType,n),o.ref=r.innerType;break;case`success`:{let e=t;e.type=`boolean`;break}case`default`:this.process(r.innerType,n),o.ref=r.innerType,t.default=JSON.parse(JSON.stringify(r.defaultValue));break;case`prefault`:this.process(r.innerType,n),o.ref=r.innerType,this.io===`input`&&(t._prefault=JSON.parse(JSON.stringify(r.defaultValue)));break;case`catch`:{this.process(r.innerType,n),o.ref=r.innerType;let e;try{e=r.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}t.default=e;break}case`nan`:if(this.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`);break;case`template_literal`:{let n=t,r=e._zod.pattern;if(!r)throw Error(`Pattern not found in template literal`);n.type=`string`,n.pattern=r.source;break}case`pipe`:{let e=this.io===`input`?r.in._zod.def.type===`transform`?r.out:r.in:r.out;this.process(e,n),o.ref=e;break}case`readonly`:this.process(r.innerType,n),o.ref=r.innerType,t.readOnly=!0;break;case`promise`:this.process(r.innerType,n),o.ref=r.innerType;break;case`optional`:this.process(r.innerType,n),o.ref=r.innerType;break;case`lazy`:{let t=e._zod.innerType;this.process(t,n),o.ref=t;break}case`custom`:if(this.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`);break;default:}}}let c=this.metadataRegistry.get(e);c&&Object.assign(o.schema,c),this.io===`input`&&hs(e)&&(delete o.schema.examples,delete o.schema.default),this.io===`input`&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault;let l=this.seen.get(e);return l.schema}emit(e,t){let n={cycles:t?.cycles??`ref`,reused:t?.reused??`inline`,external:t?.external??void 0},r=this.seen.get(e);if(!r)throw Error(`Unprocessed schema. This is a bug in Zod.`);let i=e=>{let t=this.target===`draft-2020-12`?`$defs`:`definitions`;if(n.external){let r=n.external.registry.get(e[0])?.id,i=n.external.uri??(e=>e);if(r)return{ref:i(r)};let a=e[1].defId??e[1].schema.id??`schema${this.counter++}`;return e[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${t}/${a}`}}if(e[1]===r)return{ref:`#`};let i=`#`,a=`${i}/${t}/`,o=e[1].schema.id??`__schema${this.counter++}`;return{defId:o,ref:a+o}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(n.cycles===`throw`)for(let e of this.seen.entries()){let t=e[1];if(t.cycle)throw Error(`Cycle detected: #/${t.cycle?.join(`/`)}/<root>
93
+
94
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let t of this.seen.entries()){let r=t[1];if(e===t[0]){a(t);continue}if(n.external){let r=n.external.registry.get(t[0])?.id;if(e!==t[0]&&r){a(t);continue}}let i=this.metadataRegistry.get(t[0])?.id;if(i){a(t);continue}if(r.cycle){a(t);continue}if(r.count>1&&n.reused===`ref`){a(t);continue}}let o=(e,t)=>{let n=this.seen.get(e),r=n.def??n.schema,i={...r};if(n.ref===null)return;let a=n.ref;if(n.ref=null,a){o(a,t);let e=this.seen.get(a).schema;e.$ref&&t.target===`draft-7`?(r.allOf=r.allOf??[],r.allOf.push(e)):(Object.assign(r,e),Object.assign(r,i))}n.isParent||this.override({zodSchema:e,jsonSchema:r,path:n.path??[]})};for(let e of[...this.seen.entries()].reverse())o(e[0],{target:this.target});let s={};if(this.target===`draft-2020-12`?s.$schema=`https://json-schema.org/draft/2020-12/schema`:this.target===`draft-7`?s.$schema=`http://json-schema.org/draft-07/schema#`:console.warn(`Invalid target: ${this.target}`),n.external?.uri){let t=n.external.registry.get(e)?.id;if(!t)throw Error("Schema is missing an `id` property");s.$id=n.external.uri(t)}Object.assign(s,r.def);let c=n.external?.defs??{};for(let e of this.seen.entries()){let t=e[1];t.def&&t.defId&&(c[t.defId]=t.def)}n.external||Object.keys(c).length>0&&(this.target===`draft-2020-12`?s.$defs=c:s.definitions=c);try{return JSON.parse(JSON.stringify(s))}catch{throw Error(`Error converting schema to JSON.`)}}};function ms(e,t){if(e instanceof oo){let n=new ps(t),r={};for(let t of e._idmap.entries()){let[e,r]=t;n.process(r)}let i={},a={registry:e,uri:t?.uri,defs:r};for(let r of e._idmap.entries()){let[e,o]=r;i[e]=n.emit(o,{...t,external:a})}if(Object.keys(r).length>0){let e=n.target===`draft-2020-12`?`$defs`:`definitions`;i.__shared={[e]:r}}return{schemas:i}}let n=new ps(t);return n.process(e),n.emit(e,t)}function hs(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e,i=r._zod.def;switch(i.type){case`string`:case`number`:case`bigint`:case`boolean`:case`date`:case`symbol`:case`undefined`:case`null`:case`any`:case`unknown`:case`never`:case`void`:case`literal`:case`enum`:case`nan`:case`file`:case`template_literal`:return!1;case`array`:return hs(i.element,n);case`object`:for(let e in i.shape)if(hs(i.shape[e],n))return!0;return!1;case`union`:for(let e of i.options)if(hs(e,n))return!0;return!1;case`intersection`:return hs(i.left,n)||hs(i.right,n);case`tuple`:for(let e of i.items)if(hs(e,n))return!0;return!!(i.rest&&hs(i.rest,n));case`record`:return hs(i.keyType,n)||hs(i.valueType,n);case`map`:return hs(i.keyType,n)||hs(i.valueType,n);case`set`:return hs(i.valueType,n);case`promise`:case`optional`:case`nonoptional`:case`nullable`:case`readonly`:return hs(i.innerType,n);case`lazy`:return hs(i.getter(),n);case`default`:return hs(i.innerType,n);case`prefault`:return hs(i.innerType,n);case`custom`:return!1;case`transform`:return!0;case`pipe`:return hs(i.in,n)||hs(i.out,n);case`success`:return!1;case`catch`:return!1;default:}throw Error(`Unknown schema type: ${i.type}`)}const gs=w(`ZodISODateTime`,(e,t)=>{sa.init(e,t),j.init(e,t)});function _s(e){return No(gs,e)}const vs=w(`ZodISODate`,(e,t)=>{ca.init(e,t),j.init(e,t)});function ys(e){return Po(vs,e)}const bs=w(`ZodISOTime`,(e,t)=>{la.init(e,t),j.init(e,t)});function xs(e){return Fo(bs,e)}const Ss=w(`ZodISODuration`,(e,t)=>{ua.init(e,t),j.init(e,t)});function Cs(e){return Io(Ss,e)}const ws=(e,t)=>{Br.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ur(e,t)},flatten:{value:t=>Hr(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},Ts=w(`ZodError`,ws),Es=w(`ZodError`,ws,{Parent:Error}),Ds=Wr(Es),Os=Kr(Es),ks=Jr(Es),As=Xr(Es),k=w(`ZodType`,(e,t)=>(D.init(e,t),e.def=t,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>wr(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>Ds(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ks(e,t,n),e.parseAsync=async(t,n)=>Os(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>As(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(Gc(t,n)),e.superRefine=t=>e.check(Kc(t)),e.overwrite=t=>e.check(rs(t)),e.optional=()=>R(e),e.nullable=()=>Dc(e),e.nullish=()=>R(Dc(e)),e.nonoptional=t=>Nc(e,t),e.array=()=>uc(e),e.or=t=>I([e,t]),e.and=t=>_c(e,t),e.transform=t=>Lc(e,wc(t)),e.default=t=>kc(e,t),e.prefault=t=>jc(e,t),e.catch=t=>Fc(e,t),e.pipe=t=>Lc(e,t),e.readonly=()=>zc(e),e.describe=t=>{let n=e.clone();return co.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return co.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return co.get(e);let n=e.clone();return co.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),js=w(`_ZodString`,(e,t)=>{Yi.init(e,t),k.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Zo(...t)),e.includes=(...t)=>e.check(es(...t)),e.startsWith=(...t)=>e.check(ts(...t)),e.endsWith=(...t)=>e.check(ns(...t)),e.min=(...t)=>e.check(Yo(...t)),e.max=(...t)=>e.check(Jo(...t)),e.length=(...t)=>e.check(Xo(...t)),e.nonempty=(...t)=>e.check(Yo(1,...t)),e.lowercase=t=>e.check(Qo(t)),e.uppercase=t=>e.check($o(t)),e.trim=()=>e.check(ss()),e.normalize=(...t)=>e.check(os(...t)),e.toLowerCase=()=>e.check(cs()),e.toUpperCase=()=>e.check(ls())}),Ms=w(`ZodString`,(e,t)=>{Yi.init(e,t),js.init(e,t),e.email=t=>e.check(uo(Ns,t)),e.url=t=>e.check(_o(Is,t)),e.jwt=t=>e.check(Mo(Qs,t)),e.emoji=t=>e.check(vo(Ls,t)),e.guid=t=>e.check(fo(Ps,t)),e.uuid=t=>e.check(po(Fs,t)),e.uuidv4=t=>e.check(mo(Fs,t)),e.uuidv6=t=>e.check(ho(Fs,t)),e.uuidv7=t=>e.check(go(Fs,t)),e.nanoid=t=>e.check(yo(Rs,t)),e.guid=t=>e.check(fo(Ps,t)),e.cuid=t=>e.check(bo(zs,t)),e.cuid2=t=>e.check(xo(Bs,t)),e.ulid=t=>e.check(So(Vs,t)),e.base64=t=>e.check(ko(Js,t)),e.base64url=t=>e.check(Ao(Xs,t)),e.xid=t=>e.check(Co(Hs,t)),e.ksuid=t=>e.check(wo(Us,t)),e.ipv4=t=>e.check(To(Ws,t)),e.ipv6=t=>e.check(Eo(Gs,t)),e.cidrv4=t=>e.check(Do(Ks,t)),e.cidrv6=t=>e.check(Oo(qs,t)),e.e164=t=>e.check(jo(Zs,t)),e.datetime=t=>e.check(_s(t)),e.date=t=>e.check(ys(t)),e.time=t=>e.check(xs(t)),e.duration=t=>e.check(Cs(t))});function A(e){return lo(Ms,e)}const j=w(`ZodStringFormat`,(e,t)=>{O.init(e,t),js.init(e,t)}),Ns=w(`ZodEmail`,(e,t)=>{Qi.init(e,t),j.init(e,t)}),Ps=w(`ZodGUID`,(e,t)=>{Xi.init(e,t),j.init(e,t)}),Fs=w(`ZodUUID`,(e,t)=>{Zi.init(e,t),j.init(e,t)}),Is=w(`ZodURL`,(e,t)=>{$i.init(e,t),j.init(e,t)}),Ls=w(`ZodEmoji`,(e,t)=>{ea.init(e,t),j.init(e,t)}),Rs=w(`ZodNanoID`,(e,t)=>{ta.init(e,t),j.init(e,t)}),zs=w(`ZodCUID`,(e,t)=>{na.init(e,t),j.init(e,t)}),Bs=w(`ZodCUID2`,(e,t)=>{ra.init(e,t),j.init(e,t)}),Vs=w(`ZodULID`,(e,t)=>{ia.init(e,t),j.init(e,t)}),Hs=w(`ZodXID`,(e,t)=>{aa.init(e,t),j.init(e,t)}),Us=w(`ZodKSUID`,(e,t)=>{oa.init(e,t),j.init(e,t)}),Ws=w(`ZodIPv4`,(e,t)=>{da.init(e,t),j.init(e,t)}),Gs=w(`ZodIPv6`,(e,t)=>{fa.init(e,t),j.init(e,t)}),Ks=w(`ZodCIDRv4`,(e,t)=>{pa.init(e,t),j.init(e,t)}),qs=w(`ZodCIDRv6`,(e,t)=>{ma.init(e,t),j.init(e,t)}),Js=w(`ZodBase64`,(e,t)=>{ga.init(e,t),j.init(e,t)});function Ys(e){return ko(Js,e)}const Xs=w(`ZodBase64URL`,(e,t)=>{va.init(e,t),j.init(e,t)}),Zs=w(`ZodE164`,(e,t)=>{ya.init(e,t),j.init(e,t)}),Qs=w(`ZodJWT`,(e,t)=>{xa.init(e,t),j.init(e,t)}),$s=w(`ZodNumber`,(e,t)=>{Sa.init(e,t),k.init(e,t),e.gt=(t,n)=>e.check(Go(t,n)),e.gte=(t,n)=>e.check(Ko(t,n)),e.min=(t,n)=>e.check(Ko(t,n)),e.lt=(t,n)=>e.check(Uo(t,n)),e.lte=(t,n)=>e.check(Wo(t,n)),e.max=(t,n)=>e.check(Wo(t,n)),e.int=t=>e.check(nc(t)),e.safe=t=>e.check(nc(t)),e.positive=t=>e.check(Go(0,t)),e.nonnegative=t=>e.check(Ko(0,t)),e.negative=t=>e.check(Uo(0,t)),e.nonpositive=t=>e.check(Wo(0,t)),e.multipleOf=(t,n)=>e.check(qo(t,n)),e.step=(t,n)=>e.check(qo(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ec(e){return Lo($s,e)}const tc=w(`ZodNumberFormat`,(e,t)=>{Ca.init(e,t),$s.init(e,t)});function nc(e){return Ro(tc,e)}const rc=w(`ZodBoolean`,(e,t)=>{wa.init(e,t),k.init(e,t)});function M(e){return zo(rc,e)}const ic=w(`ZodNull`,(e,t)=>{Ta.init(e,t),k.init(e,t)});function ac(e){return Bo(ic,e)}const oc=w(`ZodUnknown`,(e,t)=>{Ea.init(e,t),k.init(e,t)});function N(){return Vo(oc)}const sc=w(`ZodNever`,(e,t)=>{Da.init(e,t),k.init(e,t)});function cc(e){return Ho(sc,e)}const lc=w(`ZodArray`,(e,t)=>{ka.init(e,t),k.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Yo(t,n)),e.nonempty=t=>e.check(Yo(1,t)),e.max=(t,n)=>e.check(Jo(t,n)),e.length=(t,n)=>e.check(Xo(t,n)),e.unwrap=()=>e.element});function uc(e,t){return us(lc,e,t)}const dc=w(`ZodObject`,(e,t)=>{Ma.init(e,t),k.init(e,t),T(e,`shape`,()=>t.shape),e.keyof=()=>xc(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:N()}),e.loose=()=>e.clone({...e._zod.def,catchall:N()}),e.strict=()=>e.clone({...e._zod.def,catchall:cc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>kr(e,t),e.merge=t=>Ar(e,t),e.pick=t=>Dr(e,t),e.omit=t=>Or(e,t),e.partial=(...t)=>jr(Tc,e,t[0]),e.required=(...t)=>Mr(Mc,e,t[0])});function P(e,t){let n={type:`object`,get shape(){return gr(this,`shape`,{...e}),this.shape},...E(t)};return new dc(n)}function F(e,t){return new dc({type:`object`,get shape(){return gr(this,`shape`,{...e}),this.shape},catchall:cc(),...E(t)})}function fc(e,t){return new dc({type:`object`,get shape(){return gr(this,`shape`,{...e}),this.shape},catchall:N(),...E(t)})}const pc=w(`ZodUnion`,(e,t)=>{Pa.init(e,t),k.init(e,t),e.options=t.options});function I(e,t){return new pc({type:`union`,options:e,...E(t)})}const mc=w(`ZodDiscriminatedUnion`,(e,t)=>{pc.init(e,t),Fa.init(e,t)});function hc(e,t,n){return new mc({type:`union`,options:t,discriminator:e,...E(n)})}const gc=w(`ZodIntersection`,(e,t)=>{Ia.init(e,t),k.init(e,t)});function _c(e,t){return new gc({type:`intersection`,left:e,right:t})}const vc=w(`ZodRecord`,(e,t)=>{za.init(e,t),k.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function yc(e,t,n){return new vc({type:`record`,keyType:e,valueType:t,...E(n)})}const bc=w(`ZodEnum`,(e,t)=>{Ba.init(e,t),k.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new bc({...t,checks:[],...E(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new bc({...t,checks:[],...E(r),entries:i})}});function xc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new bc({type:`enum`,entries:n,...E(t)})}const Sc=w(`ZodLiteral`,(e,t)=>{Va.init(e,t),k.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function L(e,t){return new Sc({type:`literal`,values:Array.isArray(e)?e:[e],...E(t)})}const Cc=w(`ZodTransform`,(e,t)=>{Ha.init(e,t),k.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Rr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(Rr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function wc(e){return new Cc({type:`transform`,transform:e})}const Tc=w(`ZodOptional`,(e,t)=>{Ua.init(e,t),k.init(e,t),e.unwrap=()=>e._zod.def.innerType});function R(e){return new Tc({type:`optional`,innerType:e})}const Ec=w(`ZodNullable`,(e,t)=>{Wa.init(e,t),k.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Dc(e){return new Ec({type:`nullable`,innerType:e})}const Oc=w(`ZodDefault`,(e,t)=>{Ga.init(e,t),k.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function kc(e,t){return new Oc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Ac=w(`ZodPrefault`,(e,t)=>{qa.init(e,t),k.init(e,t),e.unwrap=()=>e._zod.def.innerType});function jc(e,t){return new Ac({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Mc=w(`ZodNonOptional`,(e,t)=>{Ja.init(e,t),k.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Nc(e,t){return new Mc({type:`nonoptional`,innerType:e,...E(t)})}const Pc=w(`ZodCatch`,(e,t)=>{Xa.init(e,t),k.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fc(e,t){return new Pc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Ic=w(`ZodPipe`,(e,t)=>{Za.init(e,t),k.init(e,t),e.in=t.in,e.out=t.out});function Lc(e,t){return new Ic({type:`pipe`,in:e,out:t})}const Rc=w(`ZodReadonly`,(e,t)=>{$a.init(e,t),k.init(e,t)});function zc(e){return new Rc({type:`readonly`,innerType:e})}const Bc=w(`ZodLazy`,(e,t)=>{to.init(e,t),k.init(e,t),e.unwrap=()=>e._zod.def.getter()});function Vc(e){return new Bc({type:`lazy`,getter:e})}const Hc=w(`ZodCustom`,(e,t)=>{no.init(e,t),k.init(e,t)});function Uc(e){let t=new Ai({check:`custom`});return t._zod.check=e,t}function Wc(e,t){return ds(Hc,e??(()=>!0),t)}function Gc(e,t={}){return fs(Hc,e,t)}function Kc(e){let t=Uc(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Rr(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Rr(r))}},e(n.value,n)));return t}function qc(e,t={error:`Input not instance of ${e.name}`}){let n=new Hc({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...E(t)});return n._zod.bag.Class=e,n}var z;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(z||={});var Jc;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Jc||={});const B=z.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Yc=e=>{let t=typeof e;switch(t){case`undefined`:return B.undefined;case`string`:return B.string;case`number`:return Number.isNaN(e)?B.nan:B.number;case`boolean`:return B.boolean;case`function`:return B.function;case`bigint`:return B.bigint;case`symbol`:return B.symbol;case`object`:return Array.isArray(e)?B.array:e===null?B.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?B.promise:typeof Map<`u`&&e instanceof Map?B.map:typeof Set<`u`&&e instanceof Set?B.set:typeof Date<`u`&&e instanceof Date?B.date:B.object;default:return B.unknown}},V=z.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`]);var Xc=class e extends Error{get errors(){return this.issues}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}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r],a=r===i.path.length-1;a?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Xc.create=e=>{let t=new Xc(e);return t};const Zc=(e,t)=>{let n;switch(e.code){case V.invalid_type:n=e.received===B.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case V.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,z.jsonStringifyReplacer)}`;break;case V.unrecognized_keys:n=`Unrecognized key(s) in object: ${z.joinValues(e.keys,`, `)}`;break;case V.invalid_union:n=`Invalid input`;break;case V.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${z.joinValues(e.options)}`;break;case V.invalid_enum_value:n=`Invalid enum value. Expected ${z.joinValues(e.options)}, received '${e.received}'`;break;case V.invalid_arguments:n=`Invalid function arguments`;break;case V.invalid_return_type:n=`Invalid function return type`;break;case V.invalid_date:n=`Invalid date`;break;case V.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:z.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case V.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`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 V.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case V.custom:n=`Invalid input`;break;case V.invalid_intersection_types:n=`Intersection results could not be merged`;break;case V.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case V.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,z.assertNever(e)}return{message:n}};var Qc=Zc;let $c=Qc;function el(){return $c}const tl=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function H(e,t){let n=el(),r=tl({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Qc?void 0:Qc].filter(e=>!!e)});e.common.issues.push(r)}var nl=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return U;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return U;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const U=Object.freeze({status:`aborted`}),rl=e=>({status:`dirty`,value:e}),il=e=>({status:`valid`,value:e}),al=e=>e.status===`aborted`,ol=e=>e.status===`dirty`,sl=e=>e.status===`valid`,cl=e=>typeof Promise<`u`&&e instanceof Promise;var W;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(W||={});var ll=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const ul=(e,t)=>{if(sl(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 Xc(e.common.issues);return this._error=t,this._error}}};function G(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:i};let a=(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}};return{errorMap:a,description:i}}var K=class{get description(){return this._def.description}_getType(e){return Yc(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Yc(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nl,ctx:{common:e.parent.common,data:e.data,parsedType:Yc(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(cl(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yc(e)},r=this._parseSync({data:e,path:n.path,parent:n});return ul(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yc(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return sl(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>sl(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yc(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(cl(r)?r:Promise.resolve(r));return ul(n,i)}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:V.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new pu({schema:this,typeName:q.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}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),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return mu.create(this,this._def)}nullable(){return hu.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Jl.create(this)}promise(){return fu.create(this,this._def)}or(e){return Zl.create([this,e],this._def)}and(e){return tu.create(this,e,this._def)}transform(e){return new pu({...G(this._def),schema:this,typeName:q.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new gu({...G(this._def),innerType:this,defaultValue:t,typeName:q.ZodDefault})}brand(){return new bu({typeName:q.ZodBranded,type:this,...G(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new _u({...G(this._def),innerType:this,catchValue:t,typeName:q.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return xu.create(this,e)}readonly(){return Su.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const dl=/^c[^\s-]{8,}$/i,fl=/^[0-9a-z]+$/,pl=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ml=/^[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,hl=/^[a-z0-9_-]{21}$/i,gl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_l=/^[-+]?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)?)??$/,vl=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yl=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;let bl;const xl=/^(?:(?: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])$/,Sl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Cl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,wl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Tl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,El=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Dl=`((\\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])))`,Ol=RegExp(`^${Dl}$`);function kl(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Al(e){return RegExp(`^${kl(e)}$`)}function jl(e){let t=`${Dl}T${kl(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Ml(e,t){return!!((t===`v4`||!t)&&xl.test(e)||(t===`v6`||!t)&&Cl.test(e))}function Nl(e,t){if(!gl.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Pl(e,t){return!!((t===`v4`||!t)&&Sl.test(e)||(t===`v6`||!t)&&wl.test(e))}var Fl=class e extends K{_parse(e){this._def.coerce&&(e.data=String(e.data));let t=this._getType(e);if(t!==B.string){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.string,received:t.parsedType}),U}let n=new nl,r;for(let t of this._def.checks)if(t.kind===`min`)e.data.length<t.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:V.too_small,minimum:t.value,type:`string`,inclusive:!0,exact:!1,message:t.message}),n.dirty());else if(t.kind===`max`)e.data.length>t.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:V.too_big,maximum:t.value,type:`string`,inclusive:!0,exact:!1,message:t.message}),n.dirty());else if(t.kind===`length`){let i=e.data.length>t.value,a=e.data.length<t.value;(i||a)&&(r=this._getOrReturnCtx(e,r),i?H(r,{code:V.too_big,maximum:t.value,type:`string`,inclusive:!0,exact:!0,message:t.message}):a&&H(r,{code:V.too_small,minimum:t.value,type:`string`,inclusive:!0,exact:!0,message:t.message}),n.dirty())}else if(t.kind===`email`)vl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`email`,code:V.invalid_string,message:t.message}),n.dirty());else if(t.kind===`emoji`)bl||=new RegExp(yl,`u`),bl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`emoji`,code:V.invalid_string,message:t.message}),n.dirty());else if(t.kind===`uuid`)ml.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`uuid`,code:V.invalid_string,message:t.message}),n.dirty());else if(t.kind===`nanoid`)hl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`nanoid`,code:V.invalid_string,message:t.message}),n.dirty());else if(t.kind===`cuid`)dl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`cuid`,code:V.invalid_string,message:t.message}),n.dirty());else if(t.kind===`cuid2`)fl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`cuid2`,code:V.invalid_string,message:t.message}),n.dirty());else if(t.kind===`ulid`)pl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`ulid`,code:V.invalid_string,message:t.message}),n.dirty());else if(t.kind===`url`)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),H(r,{validation:`url`,code:V.invalid_string,message:t.message}),n.dirty()}else if(t.kind===`regex`){t.regex.lastIndex=0;let i=t.regex.test(e.data);i||(r=this._getOrReturnCtx(e,r),H(r,{validation:`regex`,code:V.invalid_string,message:t.message}),n.dirty())}else if(t.kind===`trim`)e.data=e.data.trim();else if(t.kind===`includes`)e.data.includes(t.value,t.position)||(r=this._getOrReturnCtx(e,r),H(r,{code:V.invalid_string,validation:{includes:t.value,position:t.position},message:t.message}),n.dirty());else if(t.kind===`toLowerCase`)e.data=e.data.toLowerCase();else if(t.kind===`toUpperCase`)e.data=e.data.toUpperCase();else if(t.kind===`startsWith`)e.data.startsWith(t.value)||(r=this._getOrReturnCtx(e,r),H(r,{code:V.invalid_string,validation:{startsWith:t.value},message:t.message}),n.dirty());else if(t.kind===`endsWith`)e.data.endsWith(t.value)||(r=this._getOrReturnCtx(e,r),H(r,{code:V.invalid_string,validation:{endsWith:t.value},message:t.message}),n.dirty());else if(t.kind===`datetime`){let i=jl(t);i.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:V.invalid_string,validation:`datetime`,message:t.message}),n.dirty())}else if(t.kind===`date`){let i=Ol;i.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:V.invalid_string,validation:`date`,message:t.message}),n.dirty())}else if(t.kind===`time`){let i=Al(t);i.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{code:V.invalid_string,validation:`time`,message:t.message}),n.dirty())}else t.kind===`duration`?_l.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`duration`,code:V.invalid_string,message:t.message}),n.dirty()):t.kind===`ip`?Ml(e.data,t.version)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`ip`,code:V.invalid_string,message:t.message}),n.dirty()):t.kind===`jwt`?Nl(e.data,t.alg)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`jwt`,code:V.invalid_string,message:t.message}),n.dirty()):t.kind===`cidr`?Pl(e.data,t.version)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`cidr`,code:V.invalid_string,message:t.message}),n.dirty()):t.kind===`base64`?Tl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`base64`,code:V.invalid_string,message:t.message}),n.dirty()):t.kind===`base64url`?El.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`base64url`,code:V.invalid_string,message:t.message}),n.dirty()):z.assertNever(t);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:V.invalid_string,...W.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...W.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...W.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...W.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...W.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...W.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...W.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...W.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...W.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...W.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...W.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...W.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...W.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...W.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...W.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...W.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...W.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...W.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...W.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...W.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...W.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...W.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...W.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...W.errToObj(t)})}nonempty(e){return this.min(1,W.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Fl.create=e=>new Fl({checks:[],typeName:q.ZodString,coerce:e?.coerce??!1,...G(e)});function Il(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}var Ll=class e extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));let t=this._getType(e);if(t!==B.number){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.number,received:t.parsedType}),U}let n,r=new nl;for(let t of this._def.checks)if(t.kind===`int`)z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.invalid_type,expected:`integer`,received:`float`,message:t.message}),r.dirty());else if(t.kind===`min`){let i=t.inclusive?e.data<t.value:e.data<=t.value;i&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_small,minimum:t.value,type:`number`,inclusive:t.inclusive,exact:!1,message:t.message}),r.dirty())}else if(t.kind===`max`){let i=t.inclusive?e.data>t.value:e.data>=t.value;i&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_big,maximum:t.value,type:`number`,inclusive:t.inclusive,exact:!1,message:t.message}),r.dirty())}else t.kind===`multipleOf`?Il(e.data,t.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.not_multiple_of,multipleOf:t.value,message:t.message}),r.dirty()):t.kind===`finite`?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:V.not_finite,message:t.message}),r.dirty()):z.assertNever(t);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,W.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,W.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,W.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,W.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:W.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:W.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:W.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:W.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:W.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:W.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:W.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&z.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Ll.create=e=>new Ll({checks:[],typeName:q.ZodNumber,coerce:e?.coerce||!1,...G(e)});var Rl=class e extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}let t=this._getType(e);if(t!==B.bigint)return this._getInvalidInput(e);let n,r=new nl;for(let t of this._def.checks)if(t.kind===`min`){let i=t.inclusive?e.data<t.value:e.data<=t.value;i&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_small,type:`bigint`,minimum:t.value,inclusive:t.inclusive,message:t.message}),r.dirty())}else if(t.kind===`max`){let i=t.inclusive?e.data>t.value:e.data>=t.value;i&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.too_big,type:`bigint`,maximum:t.value,inclusive:t.inclusive,message:t.message}),r.dirty())}else t.kind===`multipleOf`?e.data%t.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:V.not_multiple_of,multipleOf:t.value,message:t.message}),r.dirty()):z.assertNever(t);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.bigint,received:t.parsedType}),U}gte(e,t){return this.setLimit(`min`,e,!0,W.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,W.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,W.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,W.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:W.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:W.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:W.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Rl.create=e=>new Rl({checks:[],typeName:q.ZodBigInt,coerce:e?.coerce??!1,...G(e)});var zl=class extends K{_parse(e){this._def.coerce&&(e.data=!!e.data);let t=this._getType(e);if(t!==B.boolean){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.boolean,received:t.parsedType}),U}return il(e.data)}};zl.create=e=>new zl({typeName:q.ZodBoolean,coerce:e?.coerce||!1,...G(e)});var Bl=class e extends K{_parse(e){this._def.coerce&&(e.data=new Date(e.data));let t=this._getType(e);if(t!==B.date){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.date,received:t.parsedType}),U}if(Number.isNaN(e.data.getTime())){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_date}),U}let n=new nl,r;for(let t of this._def.checks)t.kind===`min`?e.data.getTime()<t.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:V.too_small,message:t.message,inclusive:!0,exact:!1,minimum:t.value,type:`date`}),n.dirty()):t.kind===`max`?e.data.getTime()>t.value&&(r=this._getOrReturnCtx(e,r),H(r,{code:V.too_big,message:t.message,inclusive:!0,exact:!1,maximum:t.value,type:`date`}),n.dirty()):z.assertNever(t);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:W.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:W.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Bl.create=e=>new Bl({checks:[],coerce:e?.coerce||!1,typeName:q.ZodDate,...G(e)});var Vl=class extends K{_parse(e){let t=this._getType(e);if(t!==B.symbol){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.symbol,received:t.parsedType}),U}return il(e.data)}};Vl.create=e=>new Vl({typeName:q.ZodSymbol,...G(e)});var Hl=class extends K{_parse(e){let t=this._getType(e);if(t!==B.undefined){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.undefined,received:t.parsedType}),U}return il(e.data)}};Hl.create=e=>new Hl({typeName:q.ZodUndefined,...G(e)});var Ul=class extends K{_parse(e){let t=this._getType(e);if(t!==B.null){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.null,received:t.parsedType}),U}return il(e.data)}};Ul.create=e=>new Ul({typeName:q.ZodNull,...G(e)});var Wl=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return il(e.data)}};Wl.create=e=>new Wl({typeName:q.ZodAny,...G(e)});var Gl=class extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return il(e.data)}};Gl.create=e=>new Gl({typeName:q.ZodUnknown,...G(e)});var Kl=class extends K{_parse(e){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.never,received:t.parsedType}),U}};Kl.create=e=>new Kl({typeName:q.ZodNever,...G(e)});var ql=class extends K{_parse(e){let t=this._getType(e);if(t!==B.undefined){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.void,received:t.parsedType}),U}return il(e.data)}};ql.create=e=>new ql({typeName:q.ZodVoid,...G(e)});var Jl=class e extends K{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==B.array)return H(t,{code:V.invalid_type,expected:B.array,received:t.parsedType}),U;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(H(t,{code:e?V.too_big:V.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(H(t,{code:V.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(H(t,{code:V.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ll(t,e,t.path,n)))).then(e=>nl.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new ll(t,e,t.path,n)));return nl.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:W.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:W.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:W.toString(n)}})}nonempty(e){return this.min(1,e)}};Jl.create=(e,t)=>new Jl({type:e,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...G(t)});function Yl(e){if(e instanceof Xl){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=mu.create(Yl(r))}return new Xl({...e._def,shape:()=>t})}else if(e instanceof Jl)return new Jl({...e._def,type:Yl(e.element)});else if(e instanceof mu)return mu.create(Yl(e.unwrap()));else if(e instanceof hu)return hu.create(Yl(e.unwrap()));else if(e instanceof nu)return nu.create(e.items.map(e=>Yl(e)));else return e}var Xl=class e extends K{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=z.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){let t=this._getType(e);if(t!==B.object){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.object,received:t.parsedType}),U}let{status:n,ctx:r}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Kl&&this._def.unknownKeys===`strip`))for(let e in r.data)a.includes(e)||o.push(e);let s=[];for(let e of a){let t=i[e],n=r.data[e];s.push({key:{status:`valid`,value:e},value:t._parse(new ll(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof Kl){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of o)s.push({key:{status:`valid`,value:e},value:{status:`valid`,value:r.data[e]}});else if(e===`strict`)o.length>0&&(H(r,{code:V.unrecognized_keys,keys:o}),n.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of o){let n=r.data[t];s.push({key:{status:`valid`,value:t},value:e._parse(new ll(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of s){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>nl.mergeObjectSync(n,e)):nl.mergeObjectSync(n,s)}get shape(){return this._def.shape()}strict(t){return W.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:W.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){let n=new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:q.ZodObject});return n}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of z.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of z.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Yl(this)}partial(t){let n={};for(let e of z.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of z.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e],r=t;for(;r instanceof mu;)r=r._def.innerType;n[e]=r}return new e({...this._def,shape:()=>n})}keyof(){return lu(z.objectKeys(this.shape))}};Xl.create=(e,t)=>new Xl({shape:()=>e,unknownKeys:`strip`,catchall:Kl.create(),typeName:q.ZodObject,...G(t)}),Xl.strictCreate=(e,t)=>new Xl({shape:()=>e,unknownKeys:`strict`,catchall:Kl.create(),typeName:q.ZodObject,...G(t)}),Xl.lazycreate=(e,t)=>new Xl({shape:e,unknownKeys:`strip`,catchall:Kl.create(),typeName:q.ZodObject,...G(t)});var Zl=class extends K{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Xc(e.ctx.common.issues));return H(t,{code:V.invalid_union,unionErrors:n}),U}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Xc(e));return H(t,{code:V.invalid_union,unionErrors:i}),U}}get options(){return this._def.options}};Zl.create=(e,t)=>new Zl({options:e,typeName:q.ZodUnion,...G(t)});const Ql=e=>e instanceof su?Ql(e.schema):e instanceof pu?Ql(e.innerType()):e instanceof cu?[e.value]:e instanceof uu?e.options:e instanceof du?z.objectValues(e.enum):e instanceof gu?Ql(e._def.innerType):e instanceof Hl?[void 0]:e instanceof Ul?[null]:e instanceof mu?[void 0,...Ql(e.unwrap())]:e instanceof hu?[null,...Ql(e.unwrap())]:e instanceof bu||e instanceof Su?Ql(e.unwrap()):e instanceof _u?Ql(e._def.innerType):[];var $l=class e extends K{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==B.object)return H(t,{code:V.invalid_type,expected:B.object,received:t.parsedType}),U;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);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}):(H(t,{code:V.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),U)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ql(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:q.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...G(r)})}};function eu(e,t){let n=Yc(e),r=Yc(t);if(e===t)return{valid:!0,data:e};if(n===B.object&&r===B.object){let n=z.objectKeys(t),r=z.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=eu(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===B.array&&r===B.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=eu(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===B.date&&r===B.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var tu=class extends K{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(al(e)||al(r))return U;let i=eu(e.value,r.value);return i.valid?((ol(e)||ol(r))&&t.dirty(),{status:t.value,value:i.data}):(H(n,{code:V.invalid_intersection_types}),U)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};tu.create=(e,t,n)=>new tu({left:e,right:t,typeName:q.ZodIntersection,...G(n)});var nu=class e extends K{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.array)return H(n,{code:V.invalid_type,expected:B.array,received:n.parsedType}),U;if(n.data.length<this._def.items.length)return H(n,{code:V.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),U;let r=this._def.rest;!r&&n.data.length>this._def.items.length&&(H(n,{code:V.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let i=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ll(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(i).then(e=>nl.mergeArray(t,e)):nl.mergeArray(t,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};nu.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new nu({items:e,typeName:q.ZodTuple,rest:null,...G(t)})};var ru=class e extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.object)return H(n,{code:V.invalid_type,expected:B.object,received:n.parsedType}),U;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new ll(n,e,n.path,e)),value:a._parse(new ll(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?nl.mergeObjectAsync(t,r):nl.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof K?new e({keyType:t,valueType:n,typeName:q.ZodRecord,...G(r)}):new e({keyType:Fl.create(),valueType:t,typeName:q.ZodRecord,...G(n)})}},iu=class extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.map)return H(n,{code:V.invalid_type,expected:B.map,received:n.parsedType}),U;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new ll(n,e,n.path,[a,`key`])),value:i._parse(new ll(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return U;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return U;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};iu.create=(e,t,n)=>new iu({valueType:t,keyType:e,typeName:q.ZodMap,...G(n)});var au=class e extends K{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.set)return H(n,{code:V.invalid_type,expected:B.set,received:n.parsedType}),U;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(H(n,{code:V.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(H(n,{code:V.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return U;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new ll(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:W.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:W.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};au.create=(e,t)=>new au({valueType:e,minSize:null,maxSize:null,typeName:q.ZodSet,...G(t)});var ou=class e extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==B.function)return H(t,{code:V.invalid_type,expected:B.function,received:t.parsedType}),U;function n(e,n){return tl({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,el(),Qc].filter(e=>!!e),issueData:{code:V.invalid_arguments,argumentsError:n}})}function r(e,n){return tl({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,el(),Qc].filter(e=>!!e),issueData:{code:V.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof fu){let e=this;return il(async function(...t){let o=new Xc([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s),l=await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o});return l})}else{let e=this;return il(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Xc([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Xc([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:nu.create(t).rest(Gl.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){let t=this.parse(e);return t}strictImplement(e){let t=this.parse(e);return t}static create(t,n,r){return new e({args:t||nu.create([]).rest(Gl.create()),returns:n||Gl.create(),typeName:q.ZodFunction,...G(r)})}},su=class extends K{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.getter();return n._parse({data:t.data,path:t.path,parent:t})}};su.create=(e,t)=>new su({getter:e,typeName:q.ZodLazy,...G(t)});var cu=class extends K{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:V.invalid_literal,expected:this._def.value}),U}return{status:`valid`,value:e.data}}get value(){return this._def.value}};cu.create=(e,t)=>new cu({value:e,typeName:q.ZodLiteral,...G(t)});function lu(e,t){return new uu({values:e,typeName:q.ZodEnum,...G(t)})}var uu=class e extends K{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:z.joinValues(n),received:t.parsedType,code:V.invalid_type}),U}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:V.invalid_enum_value,options:n}),U}return il(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(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};uu.create=lu;var du=class extends K{_parse(e){let t=z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==B.string&&n.parsedType!==B.number){let e=z.objectValues(t);return H(n,{expected:z.joinValues(e),received:n.parsedType,code:V.invalid_type}),U}if(this._cache||=new Set(z.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=z.objectValues(t);return H(n,{received:n.data,code:V.invalid_enum_value,options:e}),U}return il(e.data)}get enum(){return this._def.values}};du.create=(e,t)=>new du({values:e,typeName:q.ZodNativeEnum,...G(t)});var fu=class extends K{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==B.promise&&t.common.async===!1)return H(t,{code:V.invalid_type,expected:B.promise,received:t.parsedType}),U;let n=t.parsedType===B.promise?t.data:Promise.resolve(t.data);return il(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};fu.create=(e,t)=>new fu({type:e,typeName:q.ZodPromise,...G(t)});var pu=class extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{H(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return U;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?U:r.status===`dirty`||t.value===`dirty`?rl(r.value):r});{if(t.value===`aborted`)return U;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?U:r.status===`dirty`||t.value===`dirty`?rl(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.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(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?U:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?U:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sl(e))return U;let a=r.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}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>sl(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):U);z.assertNever(r)}};pu.create=(e,t,n)=>new pu({schema:e,typeName:q.ZodEffects,effect:t,...G(n)}),pu.createWithPreprocess=(e,t,n)=>new pu({schema:t,effect:{type:`preprocess`,transform:e},typeName:q.ZodEffects,...G(n)});var mu=class extends K{_parse(e){let t=this._getType(e);return t===B.undefined?il(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};mu.create=(e,t)=>new mu({innerType:e,typeName:q.ZodOptional,...G(t)});var hu=class extends K{_parse(e){let t=this._getType(e);return t===B.null?il(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};hu.create=(e,t)=>new hu({innerType:e,typeName:q.ZodNullable,...G(t)});var gu=class extends K{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===B.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};gu.create=(e,t)=>new gu({innerType:e,typeName:q.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...G(t)});var _u=class extends K{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return cl(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Xc(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Xc(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};_u.create=(e,t)=>new _u({innerType:e,typeName:q.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...G(t)});var vu=class extends K{_parse(e){let t=this._getType(e);if(t!==B.nan){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.nan,received:t.parsedType}),U}return{status:`valid`,value:e.data}}};vu.create=e=>new vu({typeName:q.ZodNaN,...G(e)});const yu=Symbol(`zod_brand`);var bu=class extends K{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},xu=class e extends K{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){let e=async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?U:e.status===`dirty`?(t.dirty(),rl(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})};return e()}else{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?U:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:q.ZodPipeline})}},Su=class extends K{_parse(e){let t=this._def.innerType._parse(e),n=e=>(sl(e)&&(e.value=Object.freeze(e.value)),e);return cl(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Su.create=(e,t)=>new Su({innerType:e,typeName:q.ZodReadonly,...G(t)});const Cu={object:Xl.lazycreate};var q;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(q||={});const wu=Fl.create,Tu=Ll.create,Eu=vu.create,Du=Rl.create,Ou=zl.create,ku=Bl.create,Au=Vl.create,ju=Hl.create,Mu=Ul.create,Nu=Wl.create,Pu=Gl.create,Fu=Kl.create,Iu=ql.create,Lu=Jl.create,Ru=Xl.create,zu=Xl.strictCreate,Bu=Zl.create,Vu=$l.create,Hu=tu.create,Uu=nu.create,Wu=ru.create,Gu=iu.create,Ku=au.create,qu=ou.create,Ju=su.create,Yu=cu.create,Xu=uu.create,Zu=du.create,Qu=fu.create,$u=pu.create,ed=mu.create,td=hu.create,nd=pu.createWithPreprocess,rd=xu.create;function id(e=globalThis){var t,n,r;return e.window?`runtime/browser`:(t=e.navigator)?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(r=(n=e.process)?.versions)?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function ad(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}function od(e,...t){let n=ad(e??{}),r=new Headers(n),i=r.get(`user-agent`)||``;return r.set(`user-agent`,[i,...t].filter(Boolean).join(` `)),Object.fromEntries(r)}var sd=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new un({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},cd=sd(),ld=/"__proto__"\s*:/,ud=/"constructor"\s*:/;function dd(e){let t=JSON.parse(e);return typeof t!=`object`||!t||ld.test(e)===!1&&ud.test(e)===!1?t:fd(t)}function fd(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function pd(e){let{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return dd(e)}finally{Error.stackTraceLimit=t}}var md=Symbol.for(`vercel.ai.validator`);function hd(e){return{[md]:!0,validate:e}}function gd(e){return typeof e==`object`&&!!e&&md in e&&e[md]===!0&&`validate`in e}function _d(e){return gd(e)?e:vd(e)}function vd(e){return hd(async t=>{let n=await e[`~standard`].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Yn({value:t,cause:n.issues})}})}async function yd({value:e,schema:t}){let n=await bd({value:e,schema:t});if(!n.success)throw Yn.wrap({value:e,cause:n.error});return n.value}async function bd({value:e,schema:t}){let n=_d(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};let t=await n.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:Yn.wrap({value:e,cause:t.error}),rawValue:e}}catch(t){return{success:!1,error:Yn.wrap({value:e,cause:t}),rawValue:e}}}async function xd({text:e,schema:t}){try{let n=pd(e);return t==null?{success:!0,value:n,rawValue:n}:await bd({value:n,schema:t})}catch(t){return{success:!1,error:Cn.isInstance(t)?t:new Cn({text:e,cause:t}),rawValue:void 0}}}function Sd({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new ir).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await xd({text:e,schema:t}))}}))}async function Cd(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var wd=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)},Td=Symbol(`Let zodToJsonSchema decide on which parser to use`),Ed={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},Dd=e=>typeof e==`string`?{...Ed,name:e}:{...Ed,...e};function Od(){return{}}function kd(e,t){var n,r,i;let a={type:`array`};return(n=e.type)?._def&&(i=(r=e.type)?._def)?.typeName!==q.ZodAny&&(a.items=J(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(a.minItems=e.minLength.value),e.maxLength&&(a.maxItems=e.maxLength.value),e.exactLength&&(a.minItems=e.exactLength.value,a.maxItems=e.exactLength.value),a}function Ad(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function jd(){return{type:`boolean`}}function Md(e,t){return J(e.type._def,t)}var Nd=(e,t)=>J(e.innerType._def,t);function Pd(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>Pd(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Fd(e)}}var Fd=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value;break}return t};function Id(e,t){return{...J(e.innerType._def,t),default:e.defaultValue()}}function Ld(e,t){return t.effectStrategy===`input`?J(e.schema._def,t):Od()}function Rd(e){return{type:`string`,enum:Array.from(e.values)}}var zd=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function Bd(e,t){let n=[J(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),J(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(zd(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function Vd(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var Hd=void 0,Ud={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:()=>(Hd===void 0&&(Hd=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),Hd),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([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})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Wd(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:Jd(n,`email`,r.message,t);break;case`format:idn-email`:Jd(n,`idn-email`,r.message,t);break;case`pattern:zod`:Yd(n,Ud.email,r.message,t);break}break;case`url`:Jd(n,`uri`,r.message,t);break;case`uuid`:Jd(n,`uuid`,r.message,t);break;case`regex`:Yd(n,r.regex,r.message,t);break;case`cuid`:Yd(n,Ud.cuid,r.message,t);break;case`cuid2`:Yd(n,Ud.cuid2,r.message,t);break;case`startsWith`:Yd(n,RegExp(`^${Gd(r.value,t)}`),r.message,t);break;case`endsWith`:Yd(n,RegExp(`${Gd(r.value,t)}$`),r.message,t);break;case`datetime`:Jd(n,`date-time`,r.message,t);break;case`date`:Jd(n,`date`,r.message,t);break;case`time`:Jd(n,`time`,r.message,t);break;case`duration`:Jd(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:Yd(n,RegExp(Gd(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&Jd(n,`ipv4`,r.message,t),r.version!==`v4`&&Jd(n,`ipv6`,r.message,t);break;case`base64url`:Yd(n,Ud.base64url,r.message,t);break;case`jwt`:Yd(n,Ud.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&Yd(n,Ud.ipv4Cidr,r.message,t),r.version!==`v4`&&Yd(n,Ud.ipv6Cidr,r.message,t);break;case`emoji`:Yd(n,Ud.emoji(),r.message,t);break;case`ulid`:Yd(n,Ud.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:Jd(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:Yd(n,Ud.base64,r.message,t);break}break;case`nanoid`:Yd(n,Ud.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:}return n}function Gd(e,t){return t.patternStrategy===`escape`?qd(e):e}var Kd=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function qd(e){let t=``;for(let n=0;n<e.length;n++)Kd.has(e[n])||(t+=`\\`),t+=e[n];return t}function Jd(e,t,n,r){var i;e.format||(i=e.anyOf)?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Yd(e,t,n,r){var i;e.pattern||(i=e.allOf)?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Xd(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Xd(t,r)}function Xd(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},i=r.i?e.source.toLowerCase():e.source,a=``,o=!1,s=!1,c=!1;for(let e=0;e<i.length;e++){if(o){a+=i[e],o=!1;continue}if(r.i){if(s){if(i[e].match(/[a-z]/)){c?(a+=i[e],a+=`${i[e-2]}-${i[e]}`.toUpperCase(),c=!1):i[e+1]===`-`&&(n=i[e+2])?.match(/[a-z]/)?(a+=i[e],c=!0):a+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){a+=`[${i[e]}${i[e].toUpperCase()}]`;continue}}if(r.m){if(i[e]===`^`){a+=`(^|(?<=[\r
95
+ ]))`;continue}else if(i[e]===`$`){a+=`($|(?=[\r
96
+ ]))`;continue}}if(r.s&&i[e]===`.`){a+=s?`${i[e]}\r
97
+ `:`[${i[e]}\r
98
+ ]`;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`),e.source}return a}function Zd(e,t){var n,r,i,a,o,s;let c={type:`object`,additionalProperties:(n=J(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]}))??t.allowedAdditionalProperties};if((r=e.keyType)?._def.typeName===q.ZodString&&(i=e.keyType._def.checks)?.length){let{type:n,...r}=Wd(e.keyType._def,t);return{...c,propertyNames:r}}else if((a=e.keyType)?._def.typeName===q.ZodEnum)return{...c,propertyNames:{enum:e.keyType._def.values}};else if((o=e.keyType)?._def.typeName===q.ZodBranded&&e.keyType._def.type._def.typeName===q.ZodString&&(s=e.keyType._def.type._def.checks)?.length){let{type:n,...r}=Md(e.keyType._def,t);return{...c,propertyNames:r}}return c}function Qd(e,t){if(t.mapStrategy===`record`)return Zd(e,t);let n=J(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Od(),r=J(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Od();return{type:`array`,maxItems:125,items:{type:`array`,items:[n,r],minItems:2,maxItems:2}}}function $d(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`),r=n.map(e=>t[e]),i=Array.from(new Set(r.map(e=>typeof e)));return{type:i.length===1?i[0]===`string`?`string`:`number`:[`string`,`number`],enum:r}}function ef(){return{not:Od()}}function tf(){return{type:`null`}}var nf={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function rf(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in nf&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=nf[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];case`symbol`:case`undefined`:case`function`:default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return af(e,t)}var af=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>J(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function sf(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[nf[e.innerType._def.typeName],`null`]};let n=J(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function cf(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function lf(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=df(a),s=J(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});if(s===void 0)continue;n.properties[e]=s,o||r.push(e)}r.length&&(n.required=r);let a=uf(e,t);return a!==void 0&&(n.additionalProperties=a),n}function uf(e,t){if(e.catchall._def.typeName!==`ZodNever`)return J(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function df(e){try{return e.isOptional()}catch{return!0}}var ff=(e,t)=>{var n;if(t.currentPath.toString()===(n=t.propertyPath)?.toString())return J(e.innerType._def,t);let r=J(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return r?{anyOf:[{not:Od()},r]}:Od()},pf=(e,t)=>{if(t.pipeStrategy===`input`)return J(e.in._def,t);if(t.pipeStrategy===`output`)return J(e.out._def,t);let n=J(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),r=J(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]});return{allOf:[n,r].filter(e=>e!==void 0)}};function mf(e,t){return J(e.type._def,t)}function hf(e,t){let n=J(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]}),r={type:`array`,uniqueItems:!0,items:n};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}function gf(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>J(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:J(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>J(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function _f(){return{not:Od()}}function vf(){return Od()}var yf=(e,t)=>J(e.innerType._def,t),bf=(e,t,n)=>{switch(t){case q.ZodString:return Wd(e,n);case q.ZodNumber:return cf(e);case q.ZodObject:return lf(e,n);case q.ZodBigInt:return Ad(e);case q.ZodBoolean:return jd();case q.ZodDate:return Pd(e,n);case q.ZodUndefined:return _f();case q.ZodNull:return tf();case q.ZodArray:return kd(e,n);case q.ZodUnion:case q.ZodDiscriminatedUnion:return rf(e,n);case q.ZodIntersection:return Bd(e,n);case q.ZodTuple:return gf(e,n);case q.ZodRecord:return Zd(e,n);case q.ZodLiteral:return Vd(e);case q.ZodEnum:return Rd(e);case q.ZodNativeEnum:return $d(e);case q.ZodNullable:return sf(e,n);case q.ZodOptional:return ff(e,n);case q.ZodMap:return Qd(e,n);case q.ZodSet:return hf(e,n);case q.ZodLazy:return()=>e.getter()._def;case q.ZodPromise:return mf(e,n);case q.ZodNaN:case q.ZodNever:return ef();case q.ZodEffects:return Ld(e,n);case q.ZodAny:return Od();case q.ZodUnknown:return vf();case q.ZodDefault:return Id(e,n);case q.ZodBranded:return Md(e,n);case q.ZodReadonly:return yf(e,n);case q.ZodCatch:return Nd(e,n);case q.ZodPipeline:return pf(e,n);case q.ZodFunction:case q.ZodVoid:case q.ZodSymbol:return;default:return(e=>void 0)(t)}};function J(e,t,n=!1){var r;let i=t.seen.get(e);if(t.override){let a=(r=t.override)?.call(t,e,t,i,n);if(a!==Td)return a}if(i&&!n){let e=xf(i,t);if(e!==void 0)return e}let a={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,a);let o=bf(e,e.typeName,t),s=typeof o==`function`?J(o(),t):o;if(s&&Sf(e,t,s),t.postProcess){let n=t.postProcess(s,e,t);return a.jsonSchema=s,n}return a.jsonSchema=s,s}var xf=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:wd(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Od()):t.$refStrategy===`seen`?Od():void 0}},Sf=(e,t,n)=>(e.description&&(n.description=e.description),n),Cf=e=>{let t=Dd(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},wf=(e,t)=>{var n;let r=Cf(t),i=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,n])=>{var i;return{...e,[t]:(i=J(n._def,{...r,currentPath:[...r.basePath,r.definitionPath,t]},!0))??Od()}},{}):void 0,a=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,o=(n=J(e._def,a===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,a]},!1))??Od(),s=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;s!==void 0&&(o.title=s);let c=a===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy===`relative`?[]:r.basePath,r.definitionPath,a].join(`/`),[r.definitionPath]:{...i,[a]:o}};return c.$schema=`http://json-schema.org/draft-07/schema#`,c},Tf=wf;function Ef(e,t){var n;let r=(n=t?.useReferences)??!1;return jf(Tf(e,{$refStrategy:r?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Df(e,t){var n;let r=(n=t?.useReferences)??!1,i=ms(e,{target:`draft-7`,io:`output`,reused:r?`ref`:`inline`});return jf(i,{validate:async t=>{let n=await As(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Of(e){return`_zod`in e}function kf(e,t){return Of(e)?Df(e,t):Ef(e,t)}var Af=Symbol.for(`vercel.ai.schema`);function jf(e,{validate:t}={}){return{[Af]:!0,_type:void 0,[md]:!0,jsonSchema:e,validate:t}}function Mf(e){return typeof e==`object`&&!!e&&Af in e&&e[Af]===!0&&`jsonSchema`in e&&`validate`in e}function Nf(e){return e==null?jf({properties:{},additionalProperties:!1}):Mf(e)?e:kf(e)}var{btoa:Pf,atob:Ff}=globalThis,If=Object.defineProperty,Lf=(e,t)=>{for(var n in t)If(e,n,{get:t[n],enumerable:!0})},Rf=`AI_NoOutputSpecifiedError`,zf=`vercel.ai.error.${Rf}`,Bf=Symbol.for(zf),Vf;Vf=Bf;var Hf=`AI_InvalidArgumentError`,Uf=`vercel.ai.error.${Hf}`,Wf=Symbol.for(Uf),Gf;Gf=Wf;var Kf=`AI_InvalidStreamPartError`,qf=`vercel.ai.error.${Kf}`,Jf=Symbol.for(qf),Yf;Yf=Jf;var Xf=`AI_InvalidToolInputError`,Zf=`vercel.ai.error.${Xf}`,Qf=Symbol.for(Zf),$f;$f=Qf;var ep=`AI_MCPClientError`,tp=`vercel.ai.error.${ep}`,np=Symbol.for(tp),rp;rp=np;var ip=`AI_NoImageGeneratedError`,ap=`vercel.ai.error.${ip}`,op=Symbol.for(ap),sp;sp=op;var cp=`AI_NoObjectGeneratedError`,lp=`vercel.ai.error.${cp}`,up=Symbol.for(lp),dp,fp=class extends Yt{constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:cp,message:e,cause:t}),this[dp]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return Yt.hasMarker(e,lp)}};dp=up;var pp=`AI_NoOutputGeneratedError`,mp=`vercel.ai.error.${pp}`,hp=Symbol.for(mp),gp;gp=hp;var _p=`AI_NoSuchToolError`,vp=`vercel.ai.error.${_p}`,yp=Symbol.for(vp),bp;bp=yp;var xp=`AI_ToolCallRepairError`,Sp=`vercel.ai.error.${xp}`,Cp=Symbol.for(Sp),wp;wp=Cp;var Tp=`AI_InvalidDataContentError`,Ep=`vercel.ai.error.${Tp}`,Dp=Symbol.for(Ep),Op;Op=Dp;var kp=`AI_InvalidMessageRoleError`,Ap=`vercel.ai.error.${kp}`,jp=Symbol.for(Ap),Mp;Mp=jp;var Np=`AI_MessageConversionError`,Pp=`vercel.ai.error.${Np}`,Fp=Symbol.for(Pp),Ip;Ip=Fp;var Lp=`AI_DownloadError`,Rp=`vercel.ai.error.${Lp}`,zp=Symbol.for(Rp),Bp;Bp=zp;var Vp=`AI_RetryError`,Hp=`vercel.ai.error.${Vp}`,Up=Symbol.for(Hp),Wp;Wp=Up;var Gp=`5.0.48`,Kp=I([A(),qc(Uint8Array),qc(ArrayBuffer),Wc(e=>{var t,n;return(n=(t=globalThis.Buffer)?.isBuffer(e))??!1},{message:`Must be a Buffer`})]),qp=Vc(()=>I([ac(),A(),ec(),M(),yc(A(),qp),uc(qp)])),Y=yc(A(),yc(A(),qp)),Jp=P({type:L(`text`),text:A(),providerOptions:Y.optional()}),Yp=P({type:L(`image`),image:I([Kp,qc(URL)]),mediaType:A().optional(),providerOptions:Y.optional()}),Xp=P({type:L(`file`),data:I([Kp,qc(URL)]),filename:A().optional(),mediaType:A(),providerOptions:Y.optional()}),Zp=P({type:L(`reasoning`),text:A(),providerOptions:Y.optional()}),Qp=P({type:L(`tool-call`),toolCallId:A(),toolName:A(),input:N(),providerOptions:Y.optional(),providerExecuted:M().optional()}),$p=hc(`type`,[P({type:L(`text`),value:A()}),P({type:L(`json`),value:qp}),P({type:L(`error-text`),value:A()}),P({type:L(`error-json`),value:qp}),P({type:L(`content`),value:uc(I([P({type:L(`text`),text:A()}),P({type:L(`media`),data:A(),mediaType:A()})]))})]),em=P({type:L(`tool-result`),toolCallId:A(),toolName:A(),output:$p,providerOptions:Y.optional()}),tm=P({role:L(`system`),content:A(),providerOptions:Y.optional()}),nm=P({role:L(`user`),content:I([A(),uc(I([Jp,Yp,Xp]))]),providerOptions:Y.optional()}),rm=P({role:L(`assistant`),content:I([A(),uc(I([Jp,Xp,Zp,Qp,em]))]),providerOptions:Y.optional()}),im=P({role:L(`tool`),content:uc(em),providerOptions:Y.optional()}),am=I([tm,nm,rm,im]),om=sd({prefix:`aitxt`,size:24}),sm=I([F({type:L(`text-start`),id:A(),providerMetadata:Y.optional()}),F({type:L(`text-delta`),id:A(),delta:A(),providerMetadata:Y.optional()}),F({type:L(`text-end`),id:A(),providerMetadata:Y.optional()}),F({type:L(`error`),errorText:A()}),F({type:L(`tool-input-start`),toolCallId:A(),toolName:A(),providerExecuted:M().optional(),dynamic:M().optional()}),F({type:L(`tool-input-delta`),toolCallId:A(),inputTextDelta:A()}),F({type:L(`tool-input-available`),toolCallId:A(),toolName:A(),input:N(),providerExecuted:M().optional(),providerMetadata:Y.optional(),dynamic:M().optional()}),F({type:L(`tool-input-error`),toolCallId:A(),toolName:A(),input:N(),providerExecuted:M().optional(),providerMetadata:Y.optional(),dynamic:M().optional(),errorText:A()}),F({type:L(`tool-output-available`),toolCallId:A(),output:N(),providerExecuted:M().optional(),dynamic:M().optional(),preliminary:M().optional()}),F({type:L(`tool-output-error`),toolCallId:A(),errorText:A(),providerExecuted:M().optional(),dynamic:M().optional()}),F({type:L(`reasoning`),text:A(),providerMetadata:Y.optional()}),F({type:L(`reasoning-start`),id:A(),providerMetadata:Y.optional()}),F({type:L(`reasoning-delta`),id:A(),delta:A(),providerMetadata:Y.optional()}),F({type:L(`reasoning-end`),id:A(),providerMetadata:Y.optional()}),F({type:L(`reasoning-part-finish`)}),F({type:L(`source-url`),sourceId:A(),url:A(),title:A().optional(),providerMetadata:Y.optional()}),F({type:L(`source-document`),sourceId:A(),mediaType:A(),title:A(),filename:A().optional(),providerMetadata:Y.optional()}),F({type:L(`file`),url:A(),mediaType:A(),providerMetadata:Y.optional()}),F({type:A().startsWith(`data-`),id:A().optional(),data:N(),transient:M().optional()}),F({type:L(`start-step`)}),F({type:L(`finish-step`)}),F({type:L(`start`),messageId:A().optional(),messageMetadata:N().optional()}),F({type:L(`finish`),messageMetadata:N().optional()}),F({type:L(`abort`)}),F({type:L(`message-metadata`),messageMetadata:N()})]);function cm(e){return e.type.startsWith(`data-`)}function lm(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=lm(a,i):n[r]=i}return n}function um(e){let t=[`ROOT`],n=-1,r=null;function i(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`);break}}function a(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop();break}}function o(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop();break}}for(let s=0;s<e.length;s++){let c=e[s],l=t[t.length-1];switch(l){case`ROOT`:i(c,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=s,t.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break}break;case`INSIDE_OBJECT_KEY`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(c){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:i(c,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:a(c,s);break;case`INSIDE_STRING`:switch(c){case`"`:t.pop(),n=s;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(c){case`]`:n=s,t.pop();break;default:n=s,i(c,s,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(c){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=s,t.pop();break;default:n=s;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:i(c,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),n=s;break;case`INSIDE_NUMBER`:switch(c){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&a(c,s);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&a(c,s);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s);break;default:t.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?a(c,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s)):n=s;break}}}let s=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--){let i=t[n];switch(i){case`INSIDE_STRING`:s+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:s+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:s+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?s+=`true`.slice(t.length):`false`.startsWith(t)?s+=`false`.slice(t.length):`null`.startsWith(t)&&(s+=`null`.slice(t.length))}}}return s}async function dm(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await xd({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await xd({text:um(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}function fm(e){return e.type.startsWith(`tool-`)}function pm(e){return e.type===`dynamic-tool`}function mm(e){return fm(e)||pm(e)}function hm(e){return e.type.split(`-`).slice(1).join(`-`)}function gm({lastMessage:e,messageId:t}){return{message:e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function _m({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o}){return e.pipeThrough(new TransformStream({async transform(e,s){await r(async({state:r,write:c})=>{var l,u,d,f;function p(e){let t=r.message.parts.filter(fm),n=t.find(t=>t.toolCallId===e);if(n==null)throw Error(`tool-output-error must be preceded by a tool-input-available`);return n}function m(e){let t=r.message.parts.filter(e=>e.type===`dynamic-tool`),n=t.find(t=>t.toolCallId===e);if(n==null)throw Error(`tool-output-error must be preceded by a tool-input-available`);return n}function h(e){var t;let n=r.message.parts.find(t=>fm(t)&&t.toolCallId===e.toolCallId),i=e,a=n;n==null?r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,input:i.input,output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata==null?{}:{callProviderMetadata:i.providerMetadata}}):(n.state=e.state,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,a.preliminary=i.preliminary,a.providerExecuted=(t=i.providerExecuted)??n.providerExecuted,i.providerMetadata!=null&&n.state===`input-available`&&(n.callProviderMetadata=i.providerMetadata))}function g(e){var t;let n=r.message.parts.find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;n==null?r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,output:i.output,errorText:i.errorText,preliminary:i.preliminary,...i.providerMetadata==null?{}:{callProviderMetadata:i.providerMetadata}}):(n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=(t=i.rawInput)??a.rawInput,a.preliminary=i.preliminary,i.providerMetadata!=null&&n.state===`input-available`&&(n.callProviderMetadata=i.providerMetadata))}async function _(e){if(e!=null){let n=r.message.metadata==null?e:lm(r.message.metadata,e);t!=null&&await yd({value:n,schema:t}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),c();break}case`text-delta`:{let t=r.activeTextParts[e.id];t.text+=e.delta,t.providerMetadata=(l=e.providerMetadata)??t.providerMetadata,c();break}case`text-end`:{let t=r.activeTextParts[e.id];t.state=`done`,t.providerMetadata=(u=e.providerMetadata)??t.providerMetadata,delete r.activeTextParts[e.id],c();break}case`reasoning-start`:{let t={type:`reasoning`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),c();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];t.text+=e.delta,t.providerMetadata=(d=e.providerMetadata)??t.providerMetadata,c();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];t.providerMetadata=(f=e.providerMetadata)??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],c();break}case`file`:r.message.parts.push({type:`file`,mediaType:e.mediaType,url:e.url}),c();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),c();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),c();break;case`tool-input-start`:{let t=r.message.parts.filter(fm);r.partialToolCalls[e.toolCallId]={text:``,toolName:e.toolName,index:t.length,dynamic:e.dynamic},e.dynamic?g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0}):h({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted}),c();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];t.text+=e.inputTextDelta;let{value:n}=await dm(t.text);t.dynamic?g({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n}):h({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n}),c();break}case`tool-input-available`:e.dynamic?g({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerMetadata:e.providerMetadata}):h({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}),c(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:e.dynamic?g({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerMetadata:e.providerMetadata}):h({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:void 0,rawInput:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}),c();break;case`tool-output-available`:if(e.dynamic){let t=m(e.toolCallId);g({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary})}else{let t=p(e.toolCallId);h({toolCallId:e.toolCallId,toolName:hm(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary})}c();break;case`tool-output-error`:if(e.dynamic){let t=m(e.toolCallId);g({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText})}else{let t=p(e.toolCallId);h({toolCallId:e.toolCallId,toolName:hm(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText})}c();break;case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:r.activeTextParts={},r.activeReasoningParts={};break;case`start`:e.messageId!=null&&(r.message.id=e.messageId),await _(e.messageMetadata),(e.messageId!=null||e.messageMetadata!=null)&&c();break;case`finish`:await _(e.messageMetadata),e.messageMetadata!=null&&c();break;case`message-metadata`:await _(e.messageMetadata),e.messageMetadata!=null&&c();break;case`error`:i?.(Error(e.errorText));break;default:if(cm(e)){n?.[e.type]!=null&&await yd({value:e.data,schema:n[e.type]});let t=e;if(t.transient){o?.(t);break}let i=t.id==null?void 0:r.message.parts.find(e=>t.type===e.type&&t.id===e.id);i==null?r.message.parts.push(t):i.data=t.data,o?.(t),c()}}s.enqueue(e)})}}))}async function vm({stream:e,onError:t}){let n=e.getReader();try{for(;;){let{done:e}=await n.read();if(e)break}}catch(e){t?.(e)}finally{n.releaseLock()}}var ym=sd({prefix:`aitxt`,size:24}),bm=sd({prefix:`aiobj`,size:24}),xm=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}},Sm=sd({prefix:`aiobj`,size:24}),Cm={};Lf(Cm,{object:()=>Tm,text:()=>wm});var wm=()=>({type:`text`,responseFormat:{type:`text`},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),Tm=({schema:e})=>{let t=Nf(e);return{type:`object`,responseFormat:{type:`json`,schema:t.jsonSchema},async parsePartial({text:e}){let t=await dm(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return{partial:t.value};default:{let e=t.state;throw Error(`Unsupported parse state: ${e}`)}}},async parseOutput({text:e},n){let r=await xd({text:e});if(!r.success)throw new fp({message:`No object generated: could not parse the response.`,cause:r.error,text:e,response:n.response,usage:n.usage,finishReason:n.finishReason});let i=await bd({value:r.value,schema:t});if(!i.success)throw new fp({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:n.response,usage:n.usage,finishReason:n.finishReason});return i.value}}},Em=`AI_NoSuchProviderError`,Dm=`vercel.ai.error.${Em}`,Om=Symbol.for(Dm),km;km=Om;var Am=fc({name:A(),version:A()}),jm=fc({_meta:R(P({}).loose())}),Mm=jm,Nm=P({method:A(),params:R(jm)}),Pm=fc({experimental:R(P({}).loose()),logging:R(P({}).loose()),prompts:R(fc({listChanged:R(M())})),resources:R(fc({subscribe:R(M()),listChanged:R(M())})),tools:R(fc({listChanged:R(M())}))}),Fm=Mm.extend({protocolVersion:A(),capabilities:Pm,serverInfo:Am,instructions:R(A())}),Im=Mm.extend({nextCursor:R(A())}),Lm=P({name:A(),description:R(A()),inputSchema:P({type:L(`object`),properties:R(P({}).loose())}).loose()}).loose(),Rm=Im.extend({tools:uc(Lm)}),zm=P({type:L(`text`),text:A()}).loose(),Bm=P({type:L(`image`),data:Ys(),mimeType:A()}).loose(),Vm=P({uri:A(),mimeType:R(A())}).loose(),Hm=Vm.extend({text:A()}),Um=Vm.extend({blob:Ys()}),Wm=P({type:L(`resource`),resource:I([Hm,Um])}).loose(),Gm=Mm.extend({content:uc(I([zm,Bm,Wm])),isError:M().default(!1).optional()}).or(Mm.extend({toolResult:N()})),Km=`2.0`,qm=P({jsonrpc:L(Km),id:I([A(),ec().int()])}).merge(Nm).strict(),Jm=P({jsonrpc:L(Km),id:I([A(),ec().int()]),result:Mm}).strict(),Ym=P({jsonrpc:L(Km),id:I([A(),ec().int()]),error:P({code:ec().int(),message:A(),data:R(N())})}).strict(),Xm=P({jsonrpc:L(Km)}).merge(P({method:A(),params:R(jm)})).strict(),Zm=I([qm,Xm,Jm,Ym]);async function Qm(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw Error(`FileList is not supported in the current environment`);return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e,r=await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{var n;t((n=e.target)?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)});return{type:`file`,mediaType:n,filename:t,url:r}}))}var $m=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){var n,r,i,a,o;let s=await Cd(this.body),c=await Cd(this.headers),l=await Cd(this.credentials),u=await(n=this.prepareSendMessagesRequest)?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...s,...t.body},headers:{...c,...t.headers},credentials:l,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),d=(r=u?.api)??this.api,f=u?.headers===void 0?{...c,...t.headers}:u.headers,p=u?.body===void 0?{...s,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:u.body,m=(i=u?.credentials)??l,h=(a=this.fetch)??globalThis.fetch,g=await h(d,{method:`POST`,headers:od({"Content-Type":`application/json`,...f},`ai-sdk/${Gp}`,id()),body:JSON.stringify(p),credentials:m,signal:e});if(!g.ok)throw Error((o=await g.text())??`Failed to fetch the chat response.`);if(!g.body)throw Error(`The response body is empty.`);return this.processResponseStream(g.body)}async reconnectToStream(e){var t,n,r,i,a;let o=await Cd(this.body),s=await Cd(this.headers),c=await Cd(this.credentials),l=await(t=this.prepareReconnectToStreamRequest)?.call(this,{api:this.api,id:e.chatId,body:{...o,...e.body},headers:{...s,...e.headers},credentials:c,requestMetadata:e.metadata}),u=(n=l?.api)??`${this.api}/${e.chatId}/stream`,d=l?.headers===void 0?{...s,...e.headers}:l.headers,f=(r=l?.credentials)??c,p=(i=this.fetch)??globalThis.fetch,m=await p(u,{method:`GET`,headers:od(d,`ai-sdk/${Gp}`,id()),credentials:f});if(m.status===204)return null;if(!m.ok)throw Error((a=await m.text())??`Failed to fetch the chat response.`);if(!m.body)throw Error(`The response body is empty.`);return this.processResponseStream(m.body)}},eh=class extends $m{constructor(e={}){super(e)}processResponseStream(e){return Sd({stream:e,schema:sm}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},th=class{constructor({generateId:e=cd,id:t=e(),transport:n=new eh,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u}){this.activeResponse=void 0,this.jobExecutor=new xm,this.sendMessage=async(e,t)=>{var n,r,i,a;if(e==null){await this.makeRequest({trigger:`submit-message`,messageId:(n=this.lastMessage)?.id,...t});return}let o;if(`text`in e||`files`in e){let t=Array.isArray(e.files)?e.files:await Qm(e.files);o={parts:[...t,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else o=e;if(e.messageId!=null){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw Error(`message with id ${e.messageId} not found`);if(this.state.messages[t].role!==`user`)throw Error(`message with id ${e.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{...o,id:e.messageId,role:(r=o.role)??`user`,metadata:e.metadata})}else this.state.pushMessage({...o,id:(i=o.id)??this.generateId(),role:(a=o.role)??`user`,metadata:e.metadata});await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw Error(`message ${e} not found`);this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolResult=async({tool:e,toolCallId:t,output:n})=>this.jobExecutor.run(async()=>{var e,r;let i=this.state.messages,a=i[i.length-1];this.state.replaceMessage(i.length-1,{...a,parts:a.parts.map(e=>mm(e)&&e.toolCallId===t?{...e,state:`output-available`,output:n}:e)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(e=>mm(e)&&e.toolCallId===t?{...e,state:`output-available`,output:n,errorText:void 0}:e)),this.status!==`streaming`&&this.status!==`submitted`&&(e=this.sendAutomaticallyWhen)?.call(this,{messages:this.state.messages})&&this.makeRequest({trigger:`submit-message`,messageId:(r=this.lastMessage)?.id})}),this.stop=async()=>{var e;this.status!==`streaming`&&this.status!==`submitted`||(e=this.activeResponse)?.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var a,o,s;this.setStatus({status:`submitted`,error:void 0});let c=this.lastMessage,l=!1,u=!1,d=!1;try{let a={state:gm({lastMessage:this.state.snapshot(c),messageId:this.generateId()}),abortController:new AbortController};a.abortController.signal.addEventListener(`abort`,()=>{l=!0}),this.activeResponse=a;let o;if(e===`resume-stream`){let e=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(e==null){this.setStatus({status:`ready`});return}o=e}else o=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:a.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i});let s=e=>this.jobExecutor.run(()=>e({state:a.state,write:()=>{var e;this.setStatus({status:`streaming`});let t=a.state.message.id===(e=this.lastMessage)?.id;t?this.state.replaceMessage(this.state.messages.length-1,a.state.message):this.state.pushMessage(a.state.message)}}));await vm({stream:_m({stream:o,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:s,onError:e=>{throw e}}),onError:e=>{throw e}}),this.setStatus({status:`ready`})}catch(e){if(l||e.name===`AbortError`)return l=!0,this.setStatus({status:`ready`}),null;d=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(u=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:l,isDisconnect:u,isError:d})}catch(e){console.error(e)}this.activeResponse=void 0}(o=this.sendAutomaticallyWhen)?.call(this,{messages:this.state.messages})&&await this.makeRequest({trigger:`submit-message`,messageId:(s=this.lastMessage)?.id,metadata:t,headers:n,body:r})}};function nh({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(mm);return r.length>0&&r.every(e=>e.state===`output-available`)}var rh=P({type:L(`text`),text:A(),state:xc([`streaming`,`done`]).optional(),providerMetadata:Y.optional()}),ih=P({type:L(`reasoning`),text:A(),state:xc([`streaming`,`done`]).optional(),providerMetadata:Y.optional()}),ah=P({type:L(`source-url`),sourceId:A(),url:A(),title:A().optional(),providerMetadata:Y.optional()}),oh=P({type:L(`source-document`),sourceId:A(),mediaType:A(),title:A(),filename:A().optional(),providerMetadata:Y.optional()}),sh=P({type:L(`file`),mediaType:A(),filename:A().optional(),url:A(),providerMetadata:Y.optional()}),ch=P({type:L(`step-start`)}),lh=P({type:A().startsWith(`data-`),id:A().optional(),data:N()}),uh=[P({type:L(`dynamic-tool`),toolName:A(),toolCallId:A(),state:L(`input-streaming`),input:N().optional(),output:cc().optional(),errorText:cc().optional()}),P({type:L(`dynamic-tool`),toolName:A(),toolCallId:A(),state:L(`input-available`),input:N(),output:cc().optional(),errorText:cc().optional(),callProviderMetadata:Y.optional()}),P({type:L(`dynamic-tool`),toolName:A(),toolCallId:A(),state:L(`output-available`),input:N(),output:N(),errorText:cc().optional(),callProviderMetadata:Y.optional(),preliminary:M().optional()}),P({type:L(`dynamic-tool`),toolName:A(),toolCallId:A(),state:L(`output-error`),input:N(),output:cc().optional(),errorText:A(),callProviderMetadata:Y.optional()})],dh=[P({type:A().startsWith(`tool-`),toolCallId:A(),state:L(`input-streaming`),providerExecuted:M().optional(),input:N().optional(),output:cc().optional(),errorText:cc().optional()}),P({type:A().startsWith(`tool-`),toolCallId:A(),state:L(`input-available`),providerExecuted:M().optional(),input:N(),output:cc().optional(),errorText:cc().optional(),callProviderMetadata:Y.optional()}),P({type:A().startsWith(`tool-`),toolCallId:A(),state:L(`output-available`),providerExecuted:M().optional(),input:N(),output:N(),errorText:cc().optional(),callProviderMetadata:Y.optional(),preliminary:M().optional()}),P({type:A().startsWith(`tool-`),toolCallId:A(),state:L(`output-error`),providerExecuted:M().optional(),input:N(),output:cc().optional(),errorText:A(),callProviderMetadata:Y.optional()})],fh=P({id:A(),role:xc([`system`,`user`,`assistant`]),metadata:N().optional(),parts:uc(I([rh,ih,ah,oh,sh,ch,lh,...uh,...dh]))}),ph=s((exports,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=a-r,s=t-o;s<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},s)}}t.exports=n});Wt();var mh=l(ph(),1),hh=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},X=(e,t,n)=>(hh(e,t,`read from private field`),n?n.call(e):t.get(e)),gh=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},_h=(e,t,n,r)=>(hh(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n);function vh(e,t){return t==null?e:(0,mh.default)(e,t)}var yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh=class{constructor(e=[]){gh(this,yh,void 0),gh(this,bh,`ready`),gh(this,xh,void 0),gh(this,Sh,new Set),gh(this,Ch,new Set),gh(this,wh,new Set),this.pushMessage=e=>{_h(this,yh,X(this,yh).concat(e)),X(this,Th).call(this)},this.popMessage=()=>{_h(this,yh,X(this,yh).slice(0,-1)),X(this,Th).call(this)},this.replaceMessage=(e,t)=>{_h(this,yh,[...X(this,yh).slice(0,e),this.snapshot(t),...X(this,yh).slice(e+1)]),X(this,Th).call(this)},this.snapshot=e=>structuredClone(e),this[`~registerMessagesCallback`]=(e,t)=>{let n=t?vh(e,t):e;return X(this,Sh).add(n),()=>{X(this,Sh).delete(n)}},this[`~registerStatusCallback`]=e=>(X(this,Ch).add(e),()=>{X(this,Ch).delete(e)}),this[`~registerErrorCallback`]=e=>(X(this,wh).add(e),()=>{X(this,wh).delete(e)}),gh(this,Th,()=>{X(this,Sh).forEach(e=>e())}),gh(this,Eh,()=>{X(this,Ch).forEach(e=>e())}),gh(this,Dh,()=>{X(this,wh).forEach(e=>e())}),_h(this,yh,e)}get status(){return X(this,bh)}set status(e){_h(this,bh,e),X(this,Eh).call(this)}get error(){return X(this,xh)}set error(e){_h(this,xh,e),X(this,Dh).call(this)}get messages(){return X(this,yh)}set messages(e){_h(this,yh,[...e]),X(this,Th).call(this)}};yh=new WeakMap,bh=new WeakMap,xh=new WeakMap,Sh=new WeakMap,Ch=new WeakMap,wh=new WeakMap,Th=new WeakMap,Eh=new WeakMap,Dh=new WeakMap;var kh,Ah=class extends th{constructor({messages:e,...t}){let n=new Oh(e);super({...t,state:n}),gh(this,kh,void 0),this[`~registerMessagesCallback`]=(e,t)=>X(this,kh)[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>X(this,kh)[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>X(this,kh)[`~registerErrorCallback`](e),_h(this,kh,n)}};kh=new WeakMap,Me();var jh=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Mh=0,Nh=Array.isArray;function Z(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Mh,__i:-1,__u:0,__source:i,__self:a};if(typeof e==`function`&&(o=e.defaultProps))for(s in o)c[s]===void 0&&(c[s]=o[s]);return x.vnode&&x.vnode(l),l}const Ph=new Set([`AI-203`,`AI-205`,`AI-224`,`AI-225`]),Fh=`Could not complete response due to token output limits`;function Ih(e){if(e==null)return``;if(e instanceof Error){let t=e.message??``,n=e.cause;if(n instanceof Error){let e=n.message??``;e&&!t.includes(e)&&(t=t?`${t} ${e}`:e)}else typeof n==`string`&&n&&!t.includes(n)&&(t=t?`${t} ${n}`:n);return t}return typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:``}function Lh(e,t){for(let[n,r]of Object.entries(e))if(n.toLowerCase()===t.toLowerCase()&&typeof r==`string`&&r.trim()!==``)return r.trim()}function Rh(e){let t=/\b(AI-\d{3})\b/i.exec(e);if(t)return t[1].toUpperCase();try{let t=JSON.parse(e),n=t.code??t.errorCode;if(typeof n==`string`&&/AI-\d{3}/i.test(n))return n.trim().toUpperCase()}catch{}}function zh(e){return e?e.toUpperCase().includes(`AI-217`)?!0:/conversation\s+depth/i.test(e):!1}function Bh(e){if(zh(e))return!0;try{let t=JSON.parse(e),n=t.code??t.errorCode;if(typeof n==`string`&&n.toUpperCase()===`AI-217`)return!0;let r=typeof t.message==`string`?t.message:``;return zh(r)}catch{return!1}}function Vh(e){return Bh(Ih(e))}function Hh(e){return/\brequest blocked for this domain\b/.test(e)||/\bblocked for this domain\b/.test(e)}function Uh(e){let t=e;return/\bstep limit\b/.test(t)||/\bmax steps\b/.test(t)||/\bmax step\b/.test(t)||/\bmaximum steps\b/.test(t)||/\bmaximum step\b/.test(t)||/\bmax agent steps\b/.test(t)||/\bmax agent step\b/.test(t)||/\bmaximum agent steps\b/.test(t)||/\bmaximum agent step\b/.test(t)||/\bmax steps per completion\b/.test(t)||/\bsteps per completion limit\b/.test(t)}function Wh(e){return/\b429\b/.test(e)||/\brate\s*limit/i.test(e)||/\btoo\s+many\s+attempts\b/.test(e)||/\btoo_many_requests\b/.test(e)}function Gh(e){return/\bTokenOutputLimitError\b/i.test(e)}function Kh(e){return/\bwhitelist(ed)?\b/.test(e)||/\bnot\s+allowed\s+for\s+this\s+domain\b/.test(e)}function qh(e){let t=e;return/\bcontext\s+length\b/.test(t)||/\bmax tokens\b/.test(t)||/\bmax token\b/.test(t)||/\bmaximum tokens\b/.test(t)||/\bmaximum token\b/.test(t)||/\btoken\s+limit\b/.test(t)||/\btoken\s+output\b/.test(t)||/\boutput\s+limits?\b/.test(t)}function Jh(e){let t=Lh(e,`message`)??``;return Hh(t.toLowerCase())}function Yh(e){let t=typeof e.type==`string`?e.type:``;if(/tokenoutput|outputlimit|steplimit|maxstep|ratelimit|domainnotallowed/i.test(t))return!0;let n=Lh(e,`error`)??``;if(n.toUpperCase()===`TOO_MANY_REQUESTS`||/token output|output limits|token limits|rate limit|whitelist|step limit|max steps|could not complete response due to token/i.test(n))return!0;let r=Lh(e,`message`)??``;if(/rate limit exceeded|retry after \d+/i.test(r)||/whitelist/i.test(r))return!0;let i=r.toLowerCase(),a=i.indexOf(`not allowed`);return a!==-1&&i.indexOf(`domain`,a)!==-1}function Xh(e){let t=e,n=t.toLowerCase(),r=null;try{let e=JSON.parse(t);e&&typeof e==`object`&&!Array.isArray(e)&&(r=e)}catch{}return{message:t,messageLower:n,parsedJson:r,extractedCodeUpper:Rh(t)}}const Zh=[{matches:e=>typeof e.extractedCodeUpper==`string`&&Ph.has(e.extractedCodeUpper)},{matches:e=>e.parsedJson!==null&&Jh(e.parsedJson),showNewConversationLink:!1},{matches:e=>e.parsedJson!==null&&Yh(e.parsedJson)},{matches:e=>Gh(e.message),showNewConversationLink:!1},{matches:e=>Wh(e.messageLower)},{matches:e=>Hh(e.messageLower),showNewConversationLink:!1},{matches:e=>Kh(e.messageLower)},{matches:e=>qh(e.messageLower)},{matches:e=>Uh(e.messageLower)}];function Qh(e){let t=Xh(e),n=Zh.filter(e=>e.matches(t));if(n.length===0)return{blocking:!1,showNewConversationLink:!0};let r=n.every(e=>e.showNewConversationLink!==!1);return{blocking:!0,showNewConversationLink:r}}function $h(e){return Qh(e).blocking}function eg(e,t=!1){return e==null?!1:Vh(e)?!0:t?$h(Ih(e)):!1}function tg(e){let t=Ih(e);if(/TokenOutputLimitError/i.test(t)||/could not complete response due to token output limits/i.test(t))return!0;try{let e=JSON.parse(t);if(typeof e.type==`string`&&/^TokenOutputLimitError$/i.test(e.type.trim())||typeof e.error==`string`&&/token output limits/i.test(e.error))return!0}catch{}return!1}function ng(e,t=!1){return e==null?!0:tg(e)?!1:Vh(e)||!t?!0:Qh(Ih(e)).showNewConversationLink}function rg(e){return e.replace(/\s*\(AI-\d{3}\)\s*$/i,``).trim()}function ig(e){let t=e.trim();return t.startsWith(`{`)&&t.endsWith(`}`)}function ag(e){let t=e.trim();if(!t)return;let n=0;for(;n<10;){n+=1;try{let e=JSON.parse(t);if(typeof e==`string`){let n=e.trim();if(!n)return;t=n}else if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e,n=Lh(t,`message`);if(n)return n;let r=Lh(t,`error`);return r||void 0}else return}catch{if(/\\"/.test(t))t=t.replace(/\\"/g,`"`).replace(/\\\\/g,`\\`).trim();else{let e=/"message"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(t);if(e?.[1])return e[1].replace(/\\"/g,`"`).replace(/\\\\/g,`\\`).trim();let n=/"error"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(t);return n?.[1]?n[1].replace(/\\"/g,`"`).replace(/\\\\/g,`\\`).trim():void 0}}}}function og(e){if(e==null)return;let t=Ih(e),n=ag(t);if(n)return n;let r=rg(t.trim());return r===``?void 0:r}function sg(e,t=!1){if(eg(e,t)){if(tg(e)){let t=og(e);return t&&!ig(t)?t:Fh}return og(e)}}const cg=({onNewChat:e,detailMessage:t,showNewConversationLink:n=!0})=>Z(`div`,{className:`ss-thread-depth-error-banner`,children:[t?Z(`p`,{className:`ss-thread-depth-error-detail`,children:t}):null,n?Z(`p`,{className:`ss-thread-depth-error-main`,children:[e?Z(`button`,{type:`button`,className:`ss-thread-depth-error-link`,onClick:e,children:`Start a new conversation`}):Z(`span`,{className:`ss-thread-depth-error-cta`,children:`Start a new conversation`}),` `,`to continue.`]}):null]});Wt();const lg=`https://askai.algolia.com`,ug=e=>`https://${e}.algolia.net/agent-studio/1`,dg=`askai_token`,fg=e=>{let[t]=e.split(`.`);return JSON.parse(atob(t))},pg=e=>{if(!e)return!0;try{let{exp:t}=fg(e);return Date.now()/1e3>t-30}catch{return!0}};let mg=null;const hg=async({assistantId:e})=>{let t=sessionStorage.getItem(dg);return pg(t)?(mg||=fetch(`${lg}/chat/token`,{method:`POST`,headers:{"x-algolia-assistant-id":e,"content-type":`application/json`}}).then(e=>e.json()).then(({token:e})=>(sessionStorage.setItem(dg,e),e)).finally(()=>{mg=null}),mg):t},gg=({agentId:e,vote:t,messageId:n,appId:r,apiKey:i})=>{let a=new Headers;a.set(`x-algolia-application-id`,r),a.set(`x-algolia-api-key`,i),a.set(`content-type`,`application/json`);let o=`${ug(r)}/feedback`;return fetch(o,{method:`POST`,body:JSON.stringify({messageId:n,agentId:e,vote:t}),headers:a})},_g=async({assistantId:e,thumbs:t,messageId:n,appId:r})=>{let i=new Headers;i.set(`x-algolia-assistant-id`,e),i.set(`content-type`,`application/json`);let a=await hg({assistantId:e});return i.set(`authorization`,`TOKEN ${a}`),fetch(`${lg}/chat/feedback`,{method:`POST`,body:JSON.stringify({appId:r,messageId:n,thumbs:t}),headers:i})},vg=({size:e=24,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Z(`path`,{d:`M7 10v12`}),Z(`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`})]}),yg=({size:e=24,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Z(`path`,{d:`M17 14V2`}),Z(`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`})]}),bg=({size:e=24,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Z(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),Z(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]}),xg=({size:e=24,className:t,gradientIdSuffix:n=``})=>{let r=e=>`${e}${n}`;return Z(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":!0,children:[Z(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M8 1.5a.5.5 0 0 1 .475.344L9.75 5.719a.833.833 0 0 0 .53.531l3.876 1.275a.5.5 0 0 1 0 .95L10.281 9.75a.833.833 0 0 0-.531.53l-1.275 3.876a.5.5 0 0 1-.95 0L6.25 10.281a.833.833 0 0 0-.53-.531L1.843 8.475a.5.5 0 0 1 0-.95L5.719 6.25a.833.833 0 0 0 .531-.53l1.275-3.876A.5.5 0 0 1 8 1.5Zm-.8 4.532A1.833 1.833 0 0 1 6.032 7.2L3.6 8l2.432.8A1.833 1.833 0 0 1 7.2 9.968L8 12.4l.8-2.432A1.833 1.833 0 0 1 9.968 8.8L12.4 8l-2.432-.8A1.833 1.833 0 0 1 8.8 6.032L8 3.6l-.8 2.432Z`,fill:`url(#${r(`8aa5f4b5___a`)})`}),Z(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M3.333 1.5a.5.5 0 0 1 .5.5v2.667a.5.5 0 1 1-1 0V2a.5.5 0 0 1 .5-.5Z`,fill:`url(#${r(`8aa5f4b5___b`)})`}),Z(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.667 10.833a.5.5 0 0 1 .5.5V14a.5.5 0 0 1-1 0v-2.667a.5.5 0 0 1 .5-.5Z`,fill:`url(#${r(`8aa5f4b5___c`)})`}),Z(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M1.5 3.333a.5.5 0 0 1 .5-.5h2.667a.5.5 0 0 1 0 1H2a.5.5 0 0 1-.5-.5Z`,fill:`url(#${r(`8aa5f4b5___d`)})`}),Z(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.833 12.667a.5.5 0 0 1 .5-.5H14a.5.5 0 1 1 0 1h-2.667a.5.5 0 0 1-.5-.5Z`,fill:`url(#${r(`8aa5f4b5___e`)})`}),Z(`defs`,{children:[Z(`linearGradient`,{id:r(`8aa5f4b5___a`),x1:`15.03`,y1:`8`,x2:`2.03`,y2:`8`,gradientUnits:`userSpaceOnUse`,children:[Z(`stop`,{offset:`0.15`,stopColor:`#8E00FC`}),Z(`stop`,{offset:`1`,stopColor:`#003DFF`})]}),Z(`linearGradient`,{id:r(`8aa5f4b5___b`),x1:`15.03`,y1:`8`,x2:`2.03`,y2:`8`,gradientUnits:`userSpaceOnUse`,children:[Z(`stop`,{offset:`0.15`,stopColor:`#8E00FC`}),Z(`stop`,{offset:`1`,stopColor:`#003DFF`})]}),Z(`linearGradient`,{id:r(`8aa5f4b5___c`),x1:`15.03`,y1:`8`,x2:`2.03`,y2:`8`,gradientUnits:`userSpaceOnUse`,children:[Z(`stop`,{offset:`0.15`,stopColor:`#8E00FC`}),Z(`stop`,{offset:`1`,stopColor:`#003DFF`})]}),Z(`linearGradient`,{id:r(`8aa5f4b5___d`),x1:`15.03`,y1:`8`,x2:`2.03`,y2:`8`,gradientUnits:`userSpaceOnUse`,children:[Z(`stop`,{offset:`0.15`,stopColor:`#8E00FC`}),Z(`stop`,{offset:`1`,stopColor:`#003DFF`})]}),Z(`linearGradient`,{id:r(`8aa5f4b5___e`),x1:`15.03`,y1:`8`,x2:`2.03`,y2:`8`,gradientUnits:`userSpaceOnUse`,children:[Z(`stop`,{offset:`0.15`,stopColor:`#8E00FC`}),Z(`stop`,{offset:`1`,stopColor:`#003DFF`})]})]})]})},Sg=({size:e=24,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:t,width:e,height:e,children:[Z(`circle`,{cx:`11`,cy:`11`,r:`8`,stroke:t,fill:`none`,strokeWidth:`1.4`}),Z(`path`,{d:`m21 21-4.3-4.3`,stroke:t,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),Cg=({size:e=24,color:t=`currentColor`,className:n})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:t,width:e,height:e,className:n,children:Z(`path`,{fill:t,d:`M20 11v2H8l5.5 5.5l-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5L8 11z`})}),wg=({size:e=24,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[` `,Z(`path`,{d:`M18 6 6 18`}),Z(`path`,{d:`m6 6 12 12`})]}),Tg=({size:e=20,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 20 20`,children:Z(`path`,{fill:t,d:`m14.878.282l.348 1.071a2.2 2.2 0 0 0 1.399 1.397l1.071.348l.021.006a.423.423 0 0 1 0 .798l-1.071.348a2.2 2.2 0 0 0-1.399 1.397l-.348 1.07a.423.423 0 0 1-.798 0l-.349-1.07a2.2 2.2 0 0 0-.532-.867a2.2 2.2 0 0 0-.866-.536l-1.071-.348a.423.423 0 0 1 0-.798l1.071-.348a2.2 2.2 0 0 0 1.377-1.397l.348-1.07a.423.423 0 0 1 .799 0m4.905 7.931l-.766-.248a1.58 1.58 0 0 1-.998-.999l-.25-.764a.302.302 0 0 0-.57 0l-.248.764a1.58 1.58 0 0 1-.984.999l-.765.248a.303.303 0 0 0 0 .57l.765.249a1.58 1.58 0 0 1 1 1.002l.248.764a.302.302 0 0 0 .57 0l.249-.764a1.58 1.58 0 0 1 .999-.999l.765-.248a.303.303 0 0 0 0-.57zM16.97 11.89a1.46 1.46 0 0 0 1.013.038q.016.158.016.32a3.25 3.25 0 0 1-2.575 3.178l-.037.185A2.973 2.973 0 0 1 10 16.678a2.973 2.973 0 0 1-5.388-1.068l-.037-.185a3.248 3.248 0 0 1-.77-6.088A2.5 2.5 0 0 1 3 7.5v-.198a2.7 2.7 0 0 1 2.169-2.646l.406-.08l.125-.628a2.423 2.423 0 0 1 4.3-1a2.4 2.4 0 0 1 .293-.318l-.033.045c-.17.24-.26.52-.26.821s.09.581.26.821q.104.147.24.265v10.445a1.973 1.973 0 0 0 3.907.387l.103-.512a.5.5 0 0 1 .392-.392l.291-.059a2.25 2.25 0 0 0 1.778-2.562M9.5 15.027V4.423a1.423 1.423 0 0 0-2.819-.279l-.19.954a.5.5 0 0 1-.393.392l-.733.147A1.7 1.7 0 0 0 4 7.302V7.5A1.5 1.5 0 0 0 5.5 9a.5.5 0 0 1 0 1h-.252a2.248 2.248 0 0 0-.441 4.451l.291.059a.5.5 0 0 1 .392.392l.103.512a1.973 1.973 0 0 0 3.907-.387`})}),Eg=({size:e=24,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:Z(`path`,{d:`M20 6 9 17l-5-5`})}),Dg=({size:e=24,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Z(`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`}),Z(`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`})]}),Og=({size:e=22,color:t=`currentColor`})=>Z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:t,strokeWidth:`2.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[Z(`path`,{d:`m5 12 7-7 7 7`}),Z(`path`,{d:`M12 19V5`})]});function kg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ag=kg();function jg(e){Ag=e}var Mg={exec:()=>null};function Q(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Ng.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ng={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},Pg=/^(?:[ \t]*(?:\n|$))+/,Fg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ig=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Lg=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Rg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,zg=/(?:[*+-]|\d{1,9}[.)])/,Bg=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Vg=Q(Bg).replace(/bull/g,zg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Hg=Q(Bg).replace(/bull/g,zg).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ug=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Wg=/^[^\n]+/,Gg=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Kg=Q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Gg).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),qg=Q(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,zg).getRegex(),Jg=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Yg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Xg=Q(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Yg).replace(`tag`,Jg).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Zg=Q(Ug).replace(`hr`,Lg).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Jg).getRegex(),Qg=Q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Zg).getRegex(),$g={blockquote:Qg,code:Fg,def:Kg,fences:Ig,heading:Rg,hr:Lg,html:Xg,lheading:Vg,list:qg,newline:Pg,paragraph:Zg,table:Mg,text:Wg},e_=Q(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Lg).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Jg).getRegex(),t_={...$g,lheading:Hg,table:e_,paragraph:Q(Ug).replace(`hr`,Lg).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,e_).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Jg).getRegex()},n_={...$g,html:Q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Yg).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Mg,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Q(Ug).replace(`hr`,Lg).replace(`heading`,` *#{1,6} *[^
99
+ ]`).replace(`lheading`,Vg).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},r_=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,i_=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,a_=/^( {2,}|\\)\n(?!\s*$)/,o_=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,s_=/[\p{P}\p{S}]/u,c_=/[\s\p{P}\p{S}]/u,l_=/[^\s\p{P}\p{S}]/u,u_=Q(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,c_).getRegex(),d_=/(?!~)[\p{P}\p{S}]/u,f_=/(?!~)[\s\p{P}\p{S}]/u,p_=/(?:[^\s\p{P}\p{S}]|~)/u,m_=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,h_=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,g_=Q(h_,`u`).replace(/punct/g,s_).getRegex(),__=Q(h_,`u`).replace(/punct/g,d_).getRegex(),v_=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,y_=Q(v_,`gu`).replace(/notPunctSpace/g,l_).replace(/punctSpace/g,c_).replace(/punct/g,s_).getRegex(),b_=Q(v_,`gu`).replace(/notPunctSpace/g,p_).replace(/punctSpace/g,f_).replace(/punct/g,d_).getRegex(),x_=Q(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,l_).replace(/punctSpace/g,c_).replace(/punct/g,s_).getRegex(),S_=Q(/\\(punct)/,`gu`).replace(/punct/g,s_).getRegex(),C_=Q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),w_=Q(Yg).replace(`(?:-->|$)`,`-->`).getRegex(),T_=Q(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,w_).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),E_=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,D_=Q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,E_).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),O_=Q(/^!?\[(label)\]\[(ref)\]/).replace(`label`,E_).replace(`ref`,Gg).getRegex(),k_=Q(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Gg).getRegex(),A_=Q(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,O_).replace(`nolink`,k_).getRegex(),j_=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,M_={_backpedal:Mg,anyPunctuation:S_,autolink:C_,blockSkip:m_,br:a_,code:i_,del:Mg,emStrongLDelim:g_,emStrongRDelimAst:y_,emStrongRDelimUnd:x_,escape:r_,link:D_,nolink:k_,punctuation:u_,reflink:O_,reflinkSearch:A_,tag:T_,text:o_,url:Mg},N_={...M_,link:Q(/^!?\[(label)\]\((.*?)\)/).replace(`label`,E_).getRegex(),reflink:Q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,E_).getRegex()},P_={...M_,emStrongRDelimAst:b_,emStrongLDelim:__,url:Q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,j_).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Q(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,j_).getRegex()},F_={...P_,br:Q(a_).replace(`{2,}`,`*`).getRegex(),text:Q(P_.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},I_={normal:$g,gfm:t_,pedantic:n_},L_={normal:M_,gfm:P_,breaks:F_,pedantic:N_},R_={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},z_=e=>R_[e];function B_(e,t){if(t){if(Ng.escapeTest.test(e))return e.replace(Ng.escapeReplace,z_)}else if(Ng.escapeTestNoEncode.test(e))return e.replace(Ng.escapeReplaceNoEncode,z_);return e}function V_(e){try{e=encodeURI(e).replace(Ng.percentDecode,`%`)}catch{return null}return e}function H_(e,t){let n=e.replace(Ng.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}),r=n.split(Ng.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push(``);for(;i<r.length;i++)r[i]=r[i].trim().replace(Ng.slashPipe,`|`);return r}function U_(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function W_(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function G_(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function K_(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
100
+ `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
101
+ `)}var q_=class{options;rules;lexer;constructor(e){this.options=e||Ag}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:U_(e,`
102
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=K_(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=U_(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:U_(t[0],`
103
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=U_(t[0],`
104
+ `).split(`
105
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
106
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
107
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
108
+ ${s}`:s,r=r?`${r}
109
+ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
110
+ `+e.join(`
111
+ `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
112
+ `+e.join(`
113
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
114
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
115
+ `,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(`
116
+ `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
117
+ `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d);for(;e;){let f=e.split(`
118
+ `,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
119
+ `+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
120
+ `+l}!u&&!l.trim()&&(u=!0),r+=f+`
121
+ `,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));i.loose=n}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=H_(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
122
+ `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(H_(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
123
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=U_(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=W_(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),G_(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `),r=t[e.toLowerCase()];if(!r){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return G_(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},J_=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ag,this.options.tokenizer=this.options.tokenizer||new q_,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ng,block:I_.normal,inline:L_.normal};this.options.pedantic?(t.block=I_.pedantic,t.inline=L_.pedantic):this.options.gfm&&(t.block=I_.gfm,this.options.breaks?t.inline=L_.breaks:t.inline=L_.gfm),this.tokenizer.rules=t}static get rules(){return{block:I_,inline:L_}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Ng.carriageReturn,`
124
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(Ng.tabCharGlobal,` `).replace(Ng.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
125
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
126
+ `)?``:`
127
+ `)+r.raw,n.text+=`
128
+ `+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
129
+ `)?``:`
130
+ `)+r.raw,n.text+=`
131
+ `+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=(a.raw.endsWith(`
132
+ `)?``:`
133
+ `)+r.raw,a.text+=`
134
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
135
+ `)?``:`
136
+ `)+r.raw,n.text+=`
137
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,a)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},Y_=class{options;parser;constructor(e){this.options=e||Ag}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Ng.notSpaceStart)?.[0],i=e.replace(Ng.endingNewline,``)+`
138
+ `;return r?`<pre><code class="language-`+B_(r)+`">`+(n?i:B_(i,!0))+`</code></pre>
139
+ `:`<pre><code>`+(n?i:B_(i,!0))+`</code></pre>
140
+ `}blockquote({tokens:e}){return`<blockquote>
141
+ ${this.parser.parse(e)}</blockquote>
142
+ `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
143
+ `}hr(e){return`<hr>
144
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
145
+ `+r+`</`+i+`>
146
+ `}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+B_(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
147
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
148
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
149
+ <thead>
150
+ `+t+`</thead>
151
+ `+r+`</table>
152
+ `}tablerow({text:e}){return`<tr>
153
+ ${e}</tr>
154
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
155
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${B_(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=V_(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+B_(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=V_(e);if(i===null)return B_(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${B_(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:B_(e.text)}},X_=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},Z_=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ag,this.options.renderer=this.options.renderer||new Y_,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new X_}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`def`:n+=this.renderer.def(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
156
+ `+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Q_=class{options;block;constructor(e){this.options=e||Ag}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?J_.lex:J_.lexInline}provideParser(){return this.block?Z_.parse:Z_.parseInline}},$_=class{defaults=kg();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Z_;Renderer=Y_;TextRenderer=X_;Lexer=J_;Tokenizer=q_;Hooks=Q_;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Y_(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new q_(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Q_;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Q_.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Q_.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return J_.lex(e,t??this.defaults)}parser(e,t){return Z_.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?J_.lex:J_.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?Z_.parse:Z_.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?J_.lex:J_.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Z_.parse:Z_.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
157
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+B_(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},ev=new $_;function $(e,t){return ev.parse(e,t)}$.options=$.setOptions=function(e){return ev.setOptions(e),$.defaults=ev.defaults,jg($.defaults),$},$.getDefaults=kg,$.defaults=Ag,$.use=function(...e){return ev.use(...e),$.defaults=ev.defaults,jg($.defaults),$},$.walkTokens=function(e,t){return ev.walkTokens(e,t)},$.parseInline=ev.parseInline,$.Parser=Z_,$.parser=Z_.parse,$.Renderer=Y_,$.TextRenderer=X_,$.Lexer=J_,$.lexer=J_.lex,$.Tokenizer=q_,$.Hooks=Q_,$.parse=$;var tv=$.options,nv=$.setOptions,rv=$.use,iv=$.walkTokens,av=$.parseInline,ov=$,sv=Z_.parse,cv=J_.lex;function lv(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function uv(e){let t=e;for(let e=0;e<3;e+=1)try{let e=decodeURIComponent(t);if(e===t)break;t=e}catch{break}return t}function dv(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>32&&r!==127&&(t+=e.charAt(n))}return t}function fv(e){if(!e)return``;let t=e.trim();if(!t)return``;let n=dv(uv(t)).replace(/\\/g,`/`);if(!n||n.startsWith(`//`))return``;if(!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return t;try{let e=new URL(n);if(e.protocol===`http:`||e.protocol===`https:`||e.protocol===`mailto:`)return t}catch{return``}return``}function pv(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,`�`)}function mv(e){return typeof e==`string`?pv(e):``}function hv(e){let t=pv(e);try{return encodeURIComponent(t)}catch{return``}}const gv=new $.Renderer;gv.code=({text:e,lang:t=``,escaped:n})=>{let r=/^[a-zA-Z0-9_-]+$/.test(t)?t:``,i=r?`language-${r}`:``,a=n?e:lv(e),o=hv(e),s=[`<svg class="ss-markdown-copy-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>`,`<path d="m5 15-4-4 4-4"></path>`,`</svg>`].join(``),c=[`<svg class="ss-markdown-check-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">`,`<polyline points="20,6 9,17 4,12"></polyline>`,`</svg>`].join(``);return[`<div class="ss-markdown-code-snippet">`,`<button class="ss-markdown-copy-button" data-code="`+o+`" aria-label="Copy code to clipboard" title="Copy code">`,s,c,`<span class="ss-markdown-copy-label">Copy</span>`,`</button>`,`<pre><code class="`+i+`">`+a+`</code></pre>`,`</div>`].join(``)},gv.link=({href:e,title:t,text:n})=>{let r=lv(fv(e)),i=lv(n);if(!r)return i;let a=t?` title="`+lv(t)+`"`:``;return`<a href="`+r+`" target="_blank" rel="noopener noreferrer"`+a+`>`+i+`</a>`},gv.image=({href:e,title:t,text:n})=>{let r=lv(fv(e));if(!r)return lv(n);let i=t?` title="`+lv(t)+`"`:``;return`<img src="`+r+`" alt="`+lv(n)+`"`+i+` />`},gv.html=({text:e})=>lv(e);function _v(e){let t=mv(e);try{return $.parse(t,{gfm:!0,breaks:!0,renderer:gv})}catch(e){return console.error(`Error parsing markdown:`,e),lv(t)}}Wt();const vv=pt(function({children:e,labels:t,autoDirection:n=!1,className:r=``}){let i=He(null),a=He(t);a.current=t;let o=Ue(()=>_v(e),[e]);return Be(()=>{let e=i.current;if(!e)return;let t=(e,t=!1)=>{let n=a.current;if(!n)return;e.setAttribute(`aria-label`,t?n.copied:n.copyCode),e.title=t?n.copied:n.copyCode;let r=e.querySelector(`.ss-markdown-copy-label`);r&&(r.textContent=t?n.copied:n.copy)};e.querySelectorAll(`.ss-markdown-copy-button`).forEach(e=>t(e,e.classList.contains(`ss-markdown-copied`))),n&&(e.querySelectorAll(`p, li, h1, h2, h3, h4, h5, h6, td, th, blockquote`).forEach(e=>e.setAttribute(`dir`,`auto`)),e.querySelectorAll(`pre, code`).forEach(e=>e.setAttribute(`dir`,`ltr`)));let r=async e=>{let n=e.target,r=n.closest(`.ss-markdown-copy-button`);if(!r)return;e.preventDefault(),e.stopPropagation();let i=r.getAttribute(`data-code`);if(i)try{let e=decodeURIComponent(i);await navigator.clipboard.writeText(e),r.classList.add(`ss-markdown-copied`),t(r,!0),setTimeout(()=>{r.classList.remove(`ss-markdown-copied`),t(r)},2e3)}catch(e){let t=a.current;t&&(r.title=t.copyError,r.setAttribute(`aria-label`,t.copyError)),console.error(`Failed to copy code:`,e)}};return e.addEventListener(`click`,r),()=>{e.removeEventListener(`click`,r)}},[o,t,n]),Z(`div`,{ref:i,className:`ss-markdown-content ${r}`.trim(),dangerouslySetInnerHTML:{__html:o}})});Wt();function yv(){let e=We(async e=>{await navigator.clipboard.writeText(e)},[]);return{copyText:e}}const bv=pt(function({labels:e,renderToolPart:t,autoDirection:n=!1,messages:r,error:i,isGenerating:a,onCopy:o,onThumbsUp:s,onThumbsDown:c,applicationId:l,apiKey:u,assistantId:d,agentStudio:f,suggestedQuestions:p,onSuggestedQuestionClick:m,onNewChat:h,showPromptBlockingError:g=!1,threadDepthBannerInChat:_=!0,showAiDisclaimer:v=!0,newestExchangeFirst:y=!0}){let{copyText:ee}=yv(),[te,ne]=Re(null),b=He(null),re=He(!0),[ie,ae]=Re(null),oe=He(null),[se,ce]=Re(new Set),[le,ue]=Re(null),de=async(t,n)=>{if(!t.assistantMessage)return;let r=n===1?s:c;try{ne(null),ue(t.id),r?await r(t.userMessage.id):f?u&&await gg({agentId:d,vote:n,messageId:t.assistantMessage.id,appId:l,apiKey:u}):await _g({assistantId:d,appId:l,messageId:t.userMessage.id,thumbs:n}),ce(e=>{let n=new Set(e);return n.add(t.id),n})}catch{e&&ne(`feedbackError`)}finally{ue(null)}},fe=Ue(()=>{let e=[];for(let t=0;t<r.length;t++){let n=r.at(t);if(n&&n.role===`user`){let i=n,a=r.at(t+1);a?.role===`assistant`?(e.push({id:i.id,userMessage:i,assistantMessage:a}),t++):e.push({id:i.id,userMessage:i,assistantMessage:null})}}return e},[r]),pe=Ue(()=>y?[...fe].reverse():fe,[fe,y]),me=We(()=>{if(y)return;let e=b.current;if(!e)return;let t=80,n=e.scrollHeight-e.scrollTop-e.clientHeight;re.current=n<t},[y]);return Ve(()=>{if(y)return;let e=b.current;e&&(re.current&&(e.scrollTop=e.scrollHeight),me())},[y,r,a,pe.length,me]),Be(()=>()=>{oe.current&&window.clearTimeout(oe.current)},[]),Z(`div`,{className:`ss-chat-root`,ref:b,onScroll:me,children:Z(`div`,{className:`ss-qa-list`,children:[fe.length===0?Z(`div`,{className:`ss-chat-welcome`,children:[Z(`h2`,{className:`ss-chat-welcome-title`,children:e?.welcomeTitle??`How can I help you today?`}),Z(`p`,{className:`ss-chat-welcome-subtitle`,children:e?.welcomeSubtitle??`I search through your content to help you find answers to your questions, fast.`}),p&&p.length>0?Z(`div`,{className:`ss-suggested-questions`,children:p.map(e=>Z(`button`,{type:`button`,className:`ss-suggested-question-btn`,disabled:a,onClick:()=>{a||m?.(e.question)},children:e.question},e.objectID))}):null]}):null,_&&g?Z(cg,{onNewChat:h,detailMessage:sg(i,f),showNewConversationLink:ng(i,f)}):null,v?Z(`p`,{className:`ss-hint`,children:`Answers are generated with AI which can make mistakes.`}):null,i&&(e||!eg(i,!!f))&&Z(`div`,{className:`ss-error-banner`,children:e?.error??i.message}),te&&e&&Z(`div`,{className:`ss-error-banner`,role:`alert`,children:e[te]}),pe.map((r,i)=>{let s=y?i===0:i===pe.length-1;return Z(`article`,{className:`ss-qa-card`,children:[Z(`div`,{className:`ss-qa-header`,children:Z(`div`,{className:`ss-qa-question`,dir:n?`auto`:void 0,children:r.userMessage.parts.map((e,t)=>e.type===`text`?Z(`span`,{children:typeof e.text==`string`?e.text:``},t):null)})}),Z(`div`,{className:`ss-qa-answer`,children:Z(`div`,{className:`ss-qa-answer-content`,children:r.assistantMessage?Z(`div`,{className:`ss-qa-markdown`,children:r.assistantMessage.parts.map((r,i)=>{if(typeof r==`string`)return Z(`p`,{children:r},`${i}`);if(r.type===`text`){let t=typeof r.text==`string`?r.text:``;return Z(vv,{labels:e,autoDirection:n,children:t},`${i}`)}else if(r.type===`reasoning`&&r.state===`streaming`)return Z(`p`,{className:`ss-tool-info`,children:[Z(Tg,{}),` `,Z(`span`,{className:`ss-shimmer-text`,children:e?.reasoning??`Reasoning...`})]},`${i}`);else if(r.type===`dynamic-tool`&&t)return t(r);else if(r.type===`tool-searchIndex`)return r.state===`input-streaming`?Z(`p`,{className:`ss-tool-info`,children:[Z(Sg,{size:18}),` `,Z(`span`,{className:`ss-shimmer-text`,children:`Searching...`})]},`${i}`):r.state===`input-available`?Z(`p`,{className:`ss-tool-info`,children:[Z(Sg,{size:18}),` `,Z(`span`,{className:`ss-shimmer-text`,children:[`Looking for`,` `,Z(`mark`,{children:[`"`,r.input?.query||``,`"`]})]})]},`${i}`):r.state===`output-available`?Z(`p`,{className:`ss-tool-info`,children:[Z(Sg,{size:18}),` `,Z(`span`,{children:[`Searched for`,` `,Z(`mark`,{children:[`"`,r.output?.query,`"`]}),` `,`found`,` `,Array.isArray(r.output?.hits)?r.output.hits.length:`no`,` `,`results`]})]},`${i}`):r.state===`output-error`?Z(`p`,{className:`ss-tool-info`,children:r.errorText},`${i}`):null;else return null})}):Z(`div`,{className:`ss-qa-markdown ss-qa-generating ss-shimmer-text`,role:e&&a&&s?`status`:void 0,"aria-live":e?`polite`:void 0,children:[e&&a&&s&&Z(`span`,{className:`searchia-waiting-dots`,"aria-hidden":`true`,children:`•••`}),a&&s?e?.thinking??`Thinking...`:``]})})}),Z(`div`,{className:`ss-qa-actions`,children:[r.assistantMessage&&!a?se.has(r.id)?Z(`span`,{className:`ss-qa-feedback-ack ss-fade`,children:e?.feedbackThanks??`Thanks for your feedback!`}):le===r.id?Z(`span`,{className:`ss-qa-feedback-ack ss-shimmer-text`,children:e?.submitting??`Submitting...`}):Z(`div`,{className:`ss-qa-actions-group`,children:[Z(`button`,{type:`button`,title:e?.like??`Like`,"aria-label":e?.like??`Like`,className:`ss-qa-action-btn`,disabled:!r.assistantMessage||le===r.id,onClick:()=>de(r,1),children:Z(vg,{size:18})}),Z(`button`,{type:`button`,title:e?.dislike??`Dislike`,"aria-label":e?.dislike??`Dislike`,className:`ss-qa-action-btn`,disabled:!r.assistantMessage||le===r.id,onClick:()=>de(r,0),children:Z(yg,{size:18})})]}):null,Z(`button`,{type:`button`,className:`ss-qa-action-btn ${ie===r.id?`is-copied`:``}`,"aria-label":ie===r.id?e?.copied??`Copied`:e?.copyAnswer??`Copy answer`,title:ie===r.id?e?.copied??`Copied`:e?.copyAnswer??`Copy answer`,disabled:!r.assistantMessage||ie===r.id,onClick:async()=>{let t=r.assistantMessage?.parts??[],n=t.flatMap(e=>e.type===`text`&&typeof e.text==`string`?[e.text]:[]).join(``).trim();if(n){ne(null);try{o?await o(n):await ee(n),ae(r.id),oe.current&&window.clearTimeout(oe.current),oe.current=window.setTimeout(()=>{ae(null)},1500)}catch{e&&ne(`copyError`)}}},children:ie===r.id?Z(Eg,{size:18}):Z(bg,{size:18})})]})]},r.id)})]})})});Wt();function xv(e){let t=Ue(()=>e===void 0?typeof document<`u`&&document.documentElement.classList.contains(`dark`)?!0:typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(`(prefers-color-scheme: dark)`).matches:!1:e,[e]),[n,r]=Re(t);return Be(()=>{if(e!==void 0){r(e);return}let t=!1,n=()=>{if(t)return;let e=document.documentElement.classList.contains(`dark`);if(e){r(!0);return}let n=window.matchMedia(`(prefers-color-scheme: dark)`).matches;r(n)},i=new MutationObserver(()=>n());i.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]});let a=window.matchMedia(`(prefers-color-scheme: dark)`),o=()=>n();return typeof a.addEventListener==`function`?a.addEventListener(`change`,o):typeof a.addListener==`function`&&a.addListener(o),n(),()=>{t=!0,i.disconnect(),typeof a.removeEventListener==`function`?a.removeEventListener(`change`,o):typeof a.removeListener==`function`&&a.removeListener(o)}},[e]),n}var Sv=xv;function Cv(){function e(e){return new Promise(t=>{let n=new XMLHttpRequest;n.open(e.method,e.url,!0),Object.keys(e.headers).forEach(t=>n.setRequestHeader(t,e.headers[t]));let r=(e,r)=>setTimeout(()=>{n.abort(),t({status:0,content:r,isTimedOut:!0})},e),i=r(e.connectTimeout,`Connection timeout`),a;n.onreadystatechange=()=>{n.readyState>n.OPENED&&a===void 0&&(clearTimeout(i),a=r(e.responseTimeout,`Socket timeout`))},n.onerror=()=>{n.status===0&&(clearTimeout(i),clearTimeout(a),t({content:n.responseText||`Network request failed`,status:n.status,isTimedOut:!1}))},n.onload=()=>{clearTimeout(i),clearTimeout(a),t({content:n.responseText,status:n.status,isTimedOut:!1})},n.send(e.data)})}return{send:e}}function wv(e){let t,n=`algolia-client-js-${e.key}`;function r(){return t===void 0&&(t=e.localStorage||window.localStorage),t}function i(){return JSON.parse(r().getItem(n)||`{}`)}function a(e){r().setItem(n,JSON.stringify(e))}function o(){let t=e.timeToLive?e.timeToLive*1e3:null,n=i(),r=Object.fromEntries(Object.entries(n).filter(([,e])=>e.timestamp!==void 0));if(a(r),!t)return;let o=Object.fromEntries(Object.entries(r).filter(([,e])=>{let n=new Date().getTime(),r=e.timestamp+t<n;return!r}));a(o)}return{get(e,t,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(o(),i()[JSON.stringify(e)])).then(e=>Promise.all([e?e.value:t(),e!==void 0])).then(([e,t])=>Promise.all([e,t||n.miss(e)])).then(([e])=>e)},set(e,t){return Promise.resolve().then(()=>{let a=i();return a[JSON.stringify(e)]={timestamp:new Date().getTime(),value:t},r().setItem(n,JSON.stringify(a)),t})},delete(e){return Promise.resolve().then(()=>{let t=i();delete t[JSON.stringify(e)],r().setItem(n,JSON.stringify(t))})},clear(){return Promise.resolve().then(()=>{r().removeItem(n)})}}}function Tv(){return{get(e,t,n={miss:()=>Promise.resolve()}){let r=t();return r.then(e=>Promise.all([e,n.miss(e)])).then(([e])=>e)},set(e,t){return Promise.resolve(t)},delete(e){return Promise.resolve()},clear(){return Promise.resolve()}}}function Ev(e){let t=[...e.caches],n=t.shift();return n===void 0?Tv():{get(e,r,i={miss:()=>Promise.resolve()}){return n.get(e,r,i).catch(()=>Ev({caches:t}).get(e,r,i))},set(e,r){return n.set(e,r).catch(()=>Ev({caches:t}).set(e,r))},delete(e){return n.delete(e).catch(()=>Ev({caches:t}).delete(e))},clear(){return n.clear().catch(()=>Ev({caches:t}).clear())}}}function Dv(e={serializable:!0}){let t={};return{get(n,r,i={miss:()=>Promise.resolve()}){let a=JSON.stringify(n);if(a in t)return Promise.resolve(e.serializable?JSON.parse(t[a]):t[a]);let o=r();return o.then(e=>i.miss(e)).then(()=>o)},set(n,r){return t[JSON.stringify(n)]=e.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(e){return delete t[JSON.stringify(e)],Promise.resolve()},clear(){return t={},Promise.resolve()}}}function Ov(e){let t={value:`Algolia for JavaScript (${e})`,add(e){let n=`; ${e.segment}${e.version===void 0?``:` (${e.version})`}`;return t.value.indexOf(n)===-1&&(t.value=`${t.value}${n}`),t}};return t}function kv(e,t,n=`WithinHeaders`){let r={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers(){return n===`WithinHeaders`?r:{}},queryParameters(){return n===`WithinQueryParameters`?r:{}}}}function Av({algoliaAgents:e,client:t,version:n}){let r=Ov(n).add({segment:t,version:n});return e.forEach(e=>r.add(e)),r}function jv(){return{debug(e,t){return Promise.resolve()},info(e,t){return Promise.resolve()},error(e,t){return Promise.resolve()}}}var Mv=2*60*1e3;function Nv(e,t=`up`){let n=Date.now();function r(){return t===`up`||Date.now()-n>Mv}function i(){return t===`timed out`&&Date.now()-n<=Mv}return{...e,status:t,lastUpdate:n,isUp:r,isTimedOut:i}}var Pv=class extends Error{name=`AlgoliaError`;constructor(e,t){super(e),t&&(this.name=t)}},Fv=class extends Pv{stackTrace;constructor(e,t,n){super(e,n),this.stackTrace=t}},Iv=class extends Fv{constructor(e){super(`Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support`,e,`RetryError`)}},Lv=class extends Fv{status;constructor(e,t,n,r=`ApiError`){super(e,n,r),this.status=t}},Rv=class extends Pv{response;constructor(e,t){super(e,`DeserializationError`),this.response=t}},zv=class extends Lv{error;constructor(e,t,n,r){super(e,t,r,`DetailedApiError`),this.error=n}};function Bv(e){let t=e;for(let n=e.length-1;n>0;n--){let r=Math.floor(Math.random()*(n+1)),i=e[n];t[n]=e[r],t[r]=i}return t}function Vv(e,t,n){let r=Hv(n),i=`${e.protocol}://${e.url}${e.port?`:${e.port}`:``}/${t.charAt(0)===`/`?t.substring(1):t}`;return r.length&&(i+=`?${r}`),i}function Hv(e){return Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>`${t}=${encodeURIComponent(Object.prototype.toString.call(e[t])===`[object Array]`?e[t].join(`,`):e[t]).replace(/\+/g,`%20`)}`).join(`&`)}function Uv(e,t){if(e.method===`GET`||e.data===void 0&&t.data===void 0)return;let n=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(n)}function Wv(e,t,n){let r={Accept:`application/json`,...e,...t,...n},i={};return Object.keys(r).forEach(e=>{let t=r[e];i[e.toLowerCase()]=t}),i}function Gv(e){try{return JSON.parse(e.content)}catch(t){throw new Rv(t.message,e)}}function Kv({content:e,status:t},n){try{let r=JSON.parse(e);return`error`in r?new zv(r.message,t,r.error,n):new Lv(r.message,t,n)}catch{}return new Lv(e,t,n)}function qv({isTimedOut:e,status:t}){return!e&&~~t===0}function Jv({isTimedOut:e,status:t}){return e||qv({isTimedOut:e,status:t})||~~(t/100)!=2&&~~(t/100)!=4}function Yv({status:e}){return~~(e/100)==2}function Xv(e){return e.map(e=>Zv(e))}function Zv(e){let t=e.request.headers[`x-algolia-api-key`]?{"x-algolia-api-key":`*****`}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function Qv({hosts:e,hostsCache:t,baseHeaders:n,logger:r,baseQueryParameters:i,algoliaAgent:a,timeouts:o,requester:s,requestsCache:c,responsesCache:l}){async function u(e){let n=await Promise.all(e.map(e=>t.get(e,()=>Promise.resolve(Nv(e))))),r=n.filter(e=>e.isUp()),i=n.filter(e=>e.isTimedOut()),a=[...r,...i],o=a.length>0?a:e;return{hosts:o,getTimeout(e,t){let n=i.length===0&&e===0?1:i.length+3+e;return n*t}}}async function d(c,l,d=!0){let f=[],p=Uv(c,l),m=Wv(n,c.headers,l.headers),h=c.method===`GET`?{...c.data,...l.data}:{},g={...i,...c.queryParameters,...h};if(a.value&&(g[`x-algolia-agent`]=a.value),l&&l.queryParameters)for(let e of Object.keys(l.queryParameters))!l.queryParameters[e]||Object.prototype.toString.call(l.queryParameters[e])===`[object Object]`?g[e]=l.queryParameters[e]:g[e]=l.queryParameters[e].toString();let _=0,v=async(e,n)=>{let i=e.pop();if(i===void 0)throw new Iv(Xv(f));let a={...o,...l.timeouts},u={data:p,headers:m,method:c.method,url:Vv(i,c.path,g),connectTimeout:n(_,a.connect),responseTimeout:n(_,d?a.read:a.write)},h=t=>{let n={request:u,response:t,host:i,triesLeft:e.length};return f.push(n),n},y=await s.send(u);if(Jv(y)){let a=h(y);return y.isTimedOut&&_++,r.info(`Retryable failure`,Zv(a)),await t.set(i,Nv(i,y.isTimedOut?`timed out`:`down`)),v(e,n)}if(Yv(y))return Gv(y);throw h(y),Kv(y,f)},y=e.filter(e=>e.accept===`readWrite`||(d?e.accept===`read`:e.accept===`write`)),ee=await u(y);return v([...ee.hosts].reverse(),ee.getTimeout)}function f(e,t={}){let r=e.useReadTransporter||e.method===`GET`;if(!r)return d(e,t,r);let a=()=>d(e,t),o=t.cacheable||e.cacheable;if(o!==!0)return a();let s={request:e,requestOptions:t,transporter:{queryParameters:i,headers:n}};return l.get(s,()=>c.get(s,()=>c.set(s,a()).then(e=>Promise.all([c.delete(s),e]),e=>Promise.all([c.delete(s),Promise.reject(e)])).then(([e,t])=>t)),{miss:e=>l.set(s,e)})}return{hostsCache:t,requester:s,timeouts:o,logger:r,algoliaAgent:a,baseHeaders:n,baseQueryParameters:i,hosts:e,request:f,requestsCache:c,responsesCache:l}}var $v=`5.40.0`;function ey(e){return[{url:`${e}-dsn.algolia.net`,accept:`read`,protocol:`https`},{url:`${e}.algolia.net`,accept:`write`,protocol:`https`}].concat(Bv([{url:`${e}-1.algolianet.com`,accept:`readWrite`,protocol:`https`},{url:`${e}-2.algolianet.com`,accept:`readWrite`,protocol:`https`},{url:`${e}-3.algolianet.com`,accept:`readWrite`,protocol:`https`}]))}function ty({appId:e,apiKey:t,authMode:n,algoliaAgents:r,...i}){let a=kv(e,t,n),o=Qv({hosts:ey(e),...i,algoliaAgent:Av({algoliaAgents:r,client:`Lite`,version:$v}),baseHeaders:{"content-type":`text/plain`,...a.headers(),...i.baseHeaders},baseQueryParameters:{...a.queryParameters(),...i.baseQueryParameters}});return{transporter:o,appId:e,apiKey:t,clearCache(){return Promise.all([o.requestsCache.clear(),o.responsesCache.clear()]).then(()=>void 0)},get _ua(){return o.algoliaAgent.value},addAlgoliaAgent(e,t){o.algoliaAgent.add({segment:e,version:t})},setClientApiKey({apiKey:e}){!n||n===`WithinHeaders`?o.baseHeaders[`x-algolia-api-key`]=e:o.baseQueryParameters[`x-algolia-api-key`]=e},searchForHits(e,t){return this.search(e,t)},searchForFacets(e,t){return this.search(e,t)},customPost({path:e,parameters:t,body:n},r){if(!e)throw Error("Parameter `path` is required when calling `customPost`.");let i=`/{path}`.replace(`{path}`,e),a={},s=t||{},c={method:`POST`,path:i,queryParameters:s,headers:a,data:n||{}};return o.request(c,r)},getRecommendations(e,t){if(e&&Array.isArray(e)){let t={requests:e};e=t}if(!e)throw Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!e.requests)throw Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");let n=`/1/indexes/*/recommendations`,r={},i={},a={method:`POST`,path:n,queryParameters:i,headers:r,data:e,useReadTransporter:!0,cacheable:!0};return o.request(a,t)},search(e,t){if(e&&Array.isArray(e)){let t={requests:e.map(({params:e,...t})=>t.type===`facet`?{...t,...e,type:`facet`}:{...t,...e,facet:void 0,maxFacetHits:void 0,facetQuery:void 0})};e=t}if(!e)throw Error("Parameter `searchMethodParams` is required when calling `search`.");if(!e.requests)throw Error("Parameter `searchMethodParams.requests` is required when calling `search`.");let n=`/1/indexes/*/queries`,r={},i={},a={method:`POST`,path:n,queryParameters:i,headers:r,data:e,useReadTransporter:!0,cacheable:!0};return o.request(a,t)}}}function ny(e,t,n){if(!e||typeof e!=`string`)throw Error("`appId` is missing.");if(!t||typeof t!=`string`)throw Error("`apiKey` is missing.");return ty({appId:e,apiKey:t,timeouts:{connect:1e3,read:2e3,write:3e4},logger:jv(),requester:Cv(),algoliaAgents:[{segment:`Browser`}],authMode:`WithinQueryParameters`,responsesCache:Dv(),requestsCache:Dv({serializable:!1}),hostsCache:Ev({caches:[wv({key:`${$v}-${e}`}),Dv()]}),...n})}var ry=class{name=`AlgoliaChatAdapter`;isMock=!1;chat;token;tokenExpiresAt=0;tokenRequest;feedbackIds=new Map;askaiUrl;agentUrl;constructor(e){this.config=e;for(let t of[`applicationId`,`apiKey`,`indexName`,`assistantId`])if(!e[t])throw Error(`[AlgoliaChatAdapter] ${t} is required.`);this.askaiUrl=(e.askaiBaseUrl??`https://askai.algolia.com`).replace(/\/$/,``),this.agentUrl=(e.agentStudioBaseUrl??`https://${e.applicationId}.algolia.net/agent-studio/1`).replace(/\/$/,``)}async getToken(){return this.token&&Date.now()<this.tokenExpiresAt-3e4?this.token:(this.tokenRequest||=(async()=>{let e=await fetch(`${this.askaiUrl}/chat/token`,{method:`POST`,headers:{"x-algolia-assistant-id":this.config.assistantId,"content-type":`application/json`}});if(!e.ok)throw Error(`Algolia token request failed (${e.status}).`);let{token:t}=await e.json();if(typeof t!=`string`||!t)throw Error(`Algolia returned an invalid token.`);this.token=t;try{let e=JSON.parse(atob(t.split(`.`)[0].replace(/-/g,`+`).replace(/_/g,`/`)));this.tokenExpiresAt=typeof e.exp==`number`?e.exp*1e3:0}catch{this.tokenExpiresAt=0}return t})().finally(()=>{this.tokenRequest=void 0}),this.tokenRequest)}async headers(){let e={"x-algolia-application-id":this.config.applicationId,"x-algolia-api-key":this.config.apiKey};return this.config.agentStudio||Object.assign(e,{"x-algolia-index-name":this.config.indexName,"x-algolia-assistant-id":this.config.assistantId,"x-ai-sdk-version":`v5`,authorization:`TOKEN ${await this.getToken()}`}),e}resetConversation(){this.chat?.stop(),this.chat=void 0,this.feedbackIds.clear()}async sendMessage(e){if(e.signal?.aborted)throw new DOMException(`Aborted`,`AbortError`);e.history.length<=1&&this.resetConversation(),this.chat??=new Ah({transport:new eh({api:this.config.agentStudio?`${this.agentUrl}/agents/${encodeURIComponent(this.config.assistantId)}/completions?stream=true&compatibilityMode=ai-sdk-5`:`${this.askaiUrl}/chat`,headers:()=>this.headers()}),sendAutomaticallyWhen:nh});let t=this.chat;t.clearError();let n=``,r=()=>{let r=t.lastMessage;if(r?.role!==`assistant`)return;let i=r.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``);i!==n&&(e.onChunk?.(i.startsWith(n)?i.slice(n.length):i,i),n=i)},i=t[`~registerMessagesCallback`](r),a=()=>{t.stop()};e.signal?.addEventListener(`abort`,a,{once:!0});try{if(await t.sendMessage({text:e.prompt}),e.signal?.aborted)throw new DOMException(`Aborted`,`AbortError`);if(t.error)throw t.error;return r(),e.assistantMessageId&&t.lastMessage?.role===`assistant`&&this.feedbackIds.set(e.assistantMessageId,t.lastMessage.id),n}finally{i(),e.signal?.removeEventListener(`abort`,a)}}async getSuggestedQuestions(){let e=ny(this.config.applicationId,this.config.apiKey),{results:t}=await e.search({requests:[{indexName:`algolia_ask_ai_suggested_questions`,filters:`state:published AND assistantId:${JSON.stringify(this.config.assistantId)}`,hitsPerPage:3}]}),n=t[0];return n.hits.map(e=>({id:e.objectID,question:e.question}))}async sendFeedback(e,t){let n=this.feedbackIds.get(e);if(!n)throw Error(`No Algolia response ID is available for this message.`);let r=this.config.agentStudio,i=r?await this.headers():{"x-algolia-assistant-id":this.config.assistantId,authorization:`TOKEN ${await this.getToken()}`},a=await fetch(`${r?this.agentUrl:`${this.askaiUrl}/chat`}/feedback`,{method:`POST`,headers:{...i,"content-type":`application/json`},body:JSON.stringify(r?{agentId:this.config.assistantId,messageId:n,vote:t}:{appId:this.config.applicationId,messageId:n,thumbs:t})});if(!a.ok)throw Error(`Algolia feedback failed (${a.status}).`)}};const iy={en:{searching:`Searching...`,results:`Results`,toolError:`Tool failed`,toolComplete:`Tool completed`,toolDetails:`Tool details (JSON)`,toolInput:`Input`,toolOutput:`Output`,currency:`Toman`,discount:`discount`,searchPlaceholder:`Ask a question about Searchia...`,searchLabel:`Ask the AI assistant`,searchSubmit:`Ask AI`,suggestedLabel:`Suggested prompts`,button:`Ask Searchia`,title:`Searchia AI`,placeholder:`Ask Searchia anything...`,answering:`Answering...`,newChat:`New conversation`,close:`Close`,back:`Back to page`,clear:`Clear`,send:`Send message`,language:`Change language`,mock:`Demo`,mockTitle:`Using simulated responses`,disclaimer:`AI-generated answers may contain mistakes.`,poweredBy:`Powered by`,welcomeTitle:`How can I help you today?`,welcomeSubtitle:`Ask a question to start a conversation with Searchia.`,thinking:`Thinking...`,reasoning:`Reasoning...`,feedbackThanks:`Thanks for your feedback!`,submitting:`Submitting...`,like:`Helpful answer`,dislike:`Unhelpful answer`,copied:`Copied`,copyAnswer:`Copy answer`,copyCode:`Copy code`,copy:`Copy`,error:`Unable to answer. Please try again.`,feedbackError:`Could not send feedback. Please try again.`,copyError:`Could not copy. Please try again.`},fa:{searching:`در حال جست‌وجو...`,results:`نتایج`,toolError:`اجرای ابزار ناموفق بود`,toolComplete:`اجرای ابزار کامل شد`,toolDetails:`جزئیات ابزار (JSON)`,toolInput:`ورودی`,toolOutput:`خروجی`,currency:`تومان`,discount:`تخفیف`,searchPlaceholder:`دربارهٔ سرچیا سؤال بپرسید...`,searchLabel:`پرسش از دستیار هوشمند`,searchSubmit:`پرسش از AI`,suggestedLabel:`پیشنهادهای پرسش`,button:`پرسش از هوش مصنوعی`,title:`دستیار هوشمند سرچیا`,placeholder:`سؤال خود را از سرچیا بپرسید...`,answering:`در حال پاسخ‌گویی...`,newChat:`گفت‌وگوی جدید`,close:`بستن`,back:`بازگشت به صفحه`,clear:`پاک کردن`,send:`ارسال پیام`,language:`تغییر زبان`,mock:`نمایشی`,mockTitle:`پاسخ‌ها شبیه‌سازی شده‌اند`,disclaimer:`پاسخ‌های هوش مصنوعی ممکن است اشتباه باشند.`,poweredBy:`با پشتیبانی`,welcomeTitle:`چطور می‌توانم به شما کمک کنم؟`,welcomeSubtitle:`برای شروع گفت‌وگو با سرچیا، سؤال خود را بپرسید.`,thinking:`در حال فکر کردن...`,reasoning:`در حال بررسی...`,feedbackThanks:`از بازخورد شما سپاسگزاریم!`,submitting:`در حال ارسال...`,like:`پاسخ مفید بود`,dislike:`پاسخ مفید نبود`,copied:`کپی شد`,copyAnswer:`کپی پاسخ`,copyCode:`کپی کد`,copy:`کپی`,error:`دریافت پاسخ ممکن نشد. دوباره تلاش کنید.`,feedbackError:`ارسال بازخورد ممکن نشد. دوباره تلاش کنید.`,copyError:`کپی ممکن نشد. دوباره تلاش کنید.`}},ay={fa:{documentTitle:`سرچیا | تجربه‌های هوشمند`,brand:`سرچیا`,subtitle:`تجربه‌های هوشمند برای وب‌سایت شما`,reference:`نمونه‌های مرجع Algolia`,language:`زبان نمایش`,eyebrow:`تجربه‌های تعبیه‌پذیر سرچیا`,heading:`از یک سؤال، به یک گفت‌وگو برسید.`,intro:`دو حالت پرسش هوشمند و چت‌بات را امتحان کنید؛ هر دو به یک دستیار و یک تاریخچه متصل‌اند.`,experienceLabel:`انتخاب تجربه`,search:`پرسش هوشمند`,chat:`گفت‌وگو`,prompts:`پیشنهادهای پرسش`,searchTitle:`سؤال خود را بپرسید`,searchDescription:`سؤال را بنویسید؛ پاسخ در مودال مستقل پرسش نمایش داده می‌شود و می‌توانید همان‌جا ادامه دهید.`,chatTitle:`گفت‌وگو را ادامه دهید`,chatDescription:`پنل را باز کنید. سؤال‌های قبلی و پاسخ‌ها تا زمانی که این صفحه باز است، همراه شما می‌مانند.`,promptsTitle:`با یک پیشنهاد شروع کنید`,promptsDescription:`یک پیشنهاد را انتخاب کنید؛ این پرسش هم وارد همان گفت‌وگوی مشترک می‌شود.`,openChat:`باز کردن گفت‌وگو`,shared:`یک دستیار، یک گفت‌وگو`,sharedDescription:`بین تجربه‌ها جابه‌جا شوید؛ تاریخچهٔ گفت‌وگو حفظ می‌شود.`,stepOne:`از نوار پرسش یا یک پیشنهاد شروع کنید.`,stepTwo:`پاسخ را ببینید و سؤال بعدی را در همان تجربه بپرسید.`,stepThree:`پنل را ببندید و دوباره باز کنید؛ گفت‌وگو باقی می‌ماند.`,demo:`نسخهٔ نمایشی`,demoNotice:`پاسخ‌ها و پیشنهادها شبیه‌سازی شده‌اند؛ این نسخه به سرویس واقعی سرچیا متصل نیست.`,features:`امکانات این تجربه`,featureOne:`نمایش تدریجی پاسخ‌ها`,featureTwo:`متن، Markdown و کپی کد`,featureThree:`فارسی و انگلیسی، با تاریخچهٔ مشترک`,developer:`راهنمای تعبیه برای توسعه‌دهندگان`,developerIntro:`این دو فایل را روی وب‌سایت خود قرار دهید. زبان را از صفحهٔ میزبان تنظیم کنید.`,embedNote:`بدون iframe یا نیاز به نصب React روی وب‌سایت میزبان. برای نمایش فقط چت، showSearch را حذف کنید.`,footer:`تجربه‌های هوشمند سرچیا`,referenceNote:`نمونه‌های Algolia فقط برای مقایسه‌اند و اتصال سرچیا را نمایش نمی‌دهند.`,loadError:`بارگذاری ویجت ممکن نشد. ابتدا بستهٔ standalone را بسازید و صفحه را دوباره باز کنید.`},en:{documentTitle:`Searchia | AI experiences`,brand:`Searchia`,subtitle:`AI experiences for your website`,reference:`Algolia reference examples`,language:`Display language`,eyebrow:`Embeddable Searchia experiences`,heading:`From a question to a conversation.`,intro:`Try AI Search and the chatbot. Both connect to one assistant and one history.`,experienceLabel:`Choose an experience`,search:`AI Search`,chat:`Conversation`,prompts:`Suggested prompts`,searchTitle:`Ask your question`,searchDescription:`Type a question. The answer opens in its own AI Search modal, where you can keep going.`,chatTitle:`Continue the conversation`,chatDescription:`Open the panel. Your earlier questions and answers stay with you while this page is open.`,promptsTitle:`Start with a suggestion`,promptsDescription:`Choose a prompt. It joins the same shared conversation.`,openChat:`Open conversation`,shared:`One assistant, one conversation`,sharedDescription:`Switch between experiences. Your conversation stays together.`,stepOne:`Start from the question input or a suggested prompt.`,stepTwo:`Read the answer and ask a follow-up in the same experience.`,stepThree:`Close and reopen the panel. Your conversation is still there.`,demo:`Simulated demo`,demoNotice:`Answers and prompts are simulated. This prototype is not connected to a real Searchia service.`,features:`What you can try`,featureOne:`Responses that stream as you read`,featureTwo:`Text, Markdown, and code copying`,featureThree:`Persian and English with shared history`,developer:`Embedding guide for developers`,developerIntro:`Host these two files on your website. Set the language from the host page.`,embedNote:`No iframe or host React installation required. Omit showSearch to display only the chat entry point.`,footer:`Searchia AI experiences`,referenceNote:`Algolia examples are for comparison only. They do not demonstrate a Searchia integration.`,loadError:`The widget could not load. Build the standalone bundle, then reload this page.`}},oy=({size:e=20,className:t=``})=>Z(`svg`,{width:typeof e==`number`?e*4:e,height:e,viewBox:`0 0 120 30`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-label":`Searchia`,role:`img`,direction:`ltr`,children:Z(`text`,{x:`0`,y:`21`,fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`,fontSize:`17`,fontWeight:`700`,fill:`currentColor`,letterSpacing:`-0.3px`,children:`Searchia`})}),sy=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,cy=(...e)=>e.find(e=>typeof e==`string`&&e.trim()),ly=e=>(typeof e==`number`||typeof e==`string`&&e.trim())&&Number.isFinite(Number(e))?Number(e):void 0;function uy(e){if(!(typeof e!=`string`||!e.trim()))try{let t=new URL(e,`https://widget.invalid`);if([`https:`,`http:`].includes(t.protocol))return e}catch{}}function dy(e){let t=sy(e),n=Array.isArray(e)?e:Array.isArray(t?.results)?t.results:[e];return n.flatMap(e=>{let t=sy(e);return Array.isArray(t?.hits)?[{query:cy(t.query),hits:t.hits.flatMap(e=>{let t=sy(e);return t?[t]:[]})}]:[]})}function fy({part:e,language:t}){if(e.type!==`dynamic-tool`)return null;let n=iy[t],r=dy(e.output),i=new Intl.NumberFormat(t===`fa`?`fa-IR`:`en-US`),a=e.state===`output-available`;return Z(`section`,{children:[Z(`p`,{className:`ss-tool-info`,children:[Z(Sg,{size:18}),Z(`span`,{className:a||e.state===`output-error`?void 0:`ss-shimmer-text`,children:e.state===`output-error`?e.errorText||n.toolError:a?r.length?`${n.results}: ${i.format(r.reduce((e,t)=>e+t.hits.length,0))}`:n.toolComplete:n.searching})]}),r.map((e,r)=>Z(`div`,{children:[e.query&&Z(`p`,{dir:`auto`,children:e.query}),e.hits.map((e,r)=>{let a=cy(e.nameFa,e.name,e.title,e.nameEn,e.id)??`${n.results} ${i.format(r+1)}`,o=uy(e.imageUrl??e.image??e.thumbnail),s=uy(e.url??e.productUrl??e.link),c=ly(e.effectivePrice??e.price),l=ly(e.basePrice),u=ly(e.discountPercent),d=Z(m,{children:[o&&Z(`div`,{className:`ss-infinite-hits-item-image-container`,children:Z(`img`,{className:`ss-infinite-hits-item-image`,src:o,alt:a,loading:`lazy`})}),Z(`div`,{children:[Z(`div`,{className:`ss-infinite-hits-item-title`,dir:`auto`,children:a}),Z(`div`,{className:`ss-infinite-hits-item-description`,dir:`auto`,children:cy(sy(e.brand)?.nameFa,sy(e.brand)?.nameEn,e.description,e.overview)}),c!==void 0&&Z(`div`,{className:`ss-infinite-hits-item-tertiary`,children:[l!==void 0&&l>c&&Z(m,{children:[Z(`del`,{children:[i.format(l),` `,n.currency]}),` `]}),i.format(c),` `,n.currency,u!==void 0&&u>0&&Z(m,{children:[` `,`· `,i.format(u),t===`fa`?`٪`:`%`,` `,n.discount]})]})]})]});return Z(`article`,{className:`ss-infinite-hits-item`,children:s?Z(`a`,{className:`ss-infinite-hits-anchor`,href:s,target:`_blank`,rel:`noopener noreferrer`,children:d}):Z(`div`,{className:`ss-infinite-hits-anchor`,children:d})},`${String(e.id??r)}:${r}`)})]},`${r}:${e.query}`)),Z(`details`,{children:[Z(`summary`,{children:[n.toolDetails,` — `,e.toolName]}),Z(`p`,{children:n.toolInput}),Z(`pre`,{dir:`ltr`,children:JSON.stringify(e.input??e.inputText??null,null,2)}),e.output!==void 0&&Z(m,{children:[Z(`p`,{children:n.toolOutput}),Z(`pre`,{dir:`ltr`,children:JSON.stringify(e.output,null,2)})]})]})]})}Wt();function py({adapter:e,language:t,suggestedQuestionsEnabled:n=!0,customSuggestedQuestions:r}){let[i,a]=Re([]),[o,s]=Re(!1),[c,l]=Re(null),[u,d]=Re([]),f=He(null),p=He([]);Be(()=>{let i=!0;if(d([]),!n){d([]);return}if(r&&r.length>0){d(r.map((e,t)=>({objectID:`custom-${t}`,question:e,appId:`searchia`,assistantId:`searchia-agent`,state:`published`,source:`custom`,order:t})));return}return e.getSuggestedQuestions&&e.getSuggestedQuestions(t).then(e=>{i&&d(e.map((e,t)=>({objectID:e.id||`sq-${t}`,question:e.question,appId:`searchia`,assistantId:`searchia-agent`,state:`published`,source:`adapter`,order:t})))}).catch(e=>{console.warn(`[SearchiaChat] Failed to load suggested questions:`,e)}),()=>{i=!1}},[e,t,n,r]),Be(()=>(p.current=[],a([]),l(null),s(!1),()=>{e.resetConversation?.(),f.current?.abort(),f.current=null}),[e]);let m=We(()=>{f.current&&(f.current.abort(),f.current=null),e.resetConversation?.(),p.current=[],a([]),l(null),s(!1)},[e]),h=We(async({text:n})=>{let r=n.trim();if(!r||o||f.current)return;l(null);let i=`user-${Date.now()}`,c=`assistant-${Date.now()}`,u={id:i,role:`user`,parts:[{type:`text`,text:r}]};a(e=>[...e,u]),s(!0);let d=new AbortController;f.current=d,p.current.push({id:i,role:`user`,content:r,createdAt:new Date});let m=!1,h=``,g=!1,_=c,v=(e,t)=>{if(d.signal.aborted)return;let n={id:c,role:`assistant`,parts:e,metadata:t};a(e=>e.some(e=>e.id===c)?e.map(e=>e.id===c?n:e):[...e,n]),m=!0};try{let n=await e.sendMessage({language:t,assistantMessageId:c,prompt:r,history:[...p.current],signal:d.signal,onMessage:e=>{d.signal.aborted||(g=!0,_=e.id,h=e.parts.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),v(e.parts,e.metadata))},onChunk:(e,t)=>{d.signal.aborted||(h=t,g||v([{type:`text`,text:t}]))}});if(d.signal.aborted)return;if(h=n,m&&!g&&a(e=>e.map(e=>e.id===c?{...e,parts:[{type:`text`,text:n}]}:e)),!m&&h){let e={id:c,role:`assistant`,parts:[{type:`text`,text:h}]};a(t=>[...t,e])}h&&p.current.push({id:_,role:`assistant`,content:h,createdAt:new Date})}catch(e){p.current=p.current.filter(e=>e.id!==i),!d.signal.aborted&&e?.name!==`AbortError`&&l(e instanceof Error?e:Error(String(e)))}finally{f.current===d&&(s(!1),f.current=null)}},[e,t,o]),g=We(async(t,n)=>{if(e.sendFeedback)try{let r=p.current.findIndex(e=>e.id===t),i=p.current[r+1]?.id??t;await e.sendFeedback(i,n)}catch(e){throw console.warn(`[SearchiaChat] Feedback failed:`,e),e}},[e]);return{messages:i,isGenerating:o,error:c,suggestedQuestions:u,sendMessage:h,startNewConversation:m,handleFeedback:g}}Wt();const my=pt(function({config:e,adapter:t,onClose:n,language:r,session:i,surface:a}){let o=iy[r],s=He(null),[c,l]=Re(``),{messages:u,isGenerating:d,error:f,suggestedQuestions:p,sendMessage:h,startNewConversation:g,handleFeedback:_}=i,v=We(e=>{let t=e.trim();!t||d||h({text:t})},[d,h]),y=We(()=>{g(),l(``),requestAnimationFrame(()=>s.current?.focus())},[g]),ee=We(()=>{let e=c.trim();!e||d||(h({text:e}),l(``))},[c,d,h]);Be(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),Be(()=>{requestAnimationFrame(()=>s.current?.focus())},[]);let te=d?o.answering:e.placeholder??o.placeholder;return Z(`div`,{className:`ss-sidepanel-inner searchia-surface--${a}`,children:[a===`chat`&&Z(`header`,{className:`ss-sidepanel-header`,children:[Z(`div`,{className:`ss-sidepanel-title-group`,children:[Z(`h2`,{className:`ss-sidepanel-title`,children:e.title??o.title}),t.isMock&&Z(`span`,{className:`searchia-badge-mock`,title:o.mockTitle,children:o.mock})]}),Z(`div`,{className:`ss-sidepanel-header-actions`,children:[Z(`button`,{type:`button`,className:`ss-search-new-chat-button`,disabled:d,title:o.newChat,"aria-label":o.newChat,onClick:y,children:Z(Dg,{size:18})}),Z(`button`,{type:`button`,className:`ss-search-close-button`,onClick:n,"aria-label":o.close,title:o.close,children:Z(wg,{})})]})]}),Z(`div`,{className:`ss-sidepanel-body`,children:Z(bv,{labels:{...o,welcomeTitle:e.welcomeTitle??o.welcomeTitle,welcomeSubtitle:e.welcomeMessage??o.welcomeSubtitle},renderToolPart:e=>Z(fy,{part:e,language:r},e.type===`dynamic-tool`?e.toolCallId:e.type),autoDirection:!0,messages:u,error:f,isGenerating:d,applicationId:`searchia`,assistantId:`searchia-agent`,suggestedQuestions:p,onSuggestedQuestionClick:v,onNewChat:y,onThumbsUp:e=>_(e,1),onThumbsDown:e=>_(e,0),showPromptBlockingError:!1,threadDepthBannerInChat:!1,showAiDisclaimer:!1,newestExchangeFirst:!1})}),Z(`div`,{className:`ss-sidepanel-compose-stack`,children:Z(`footer`,{className:`ss-sidepanel-footer`,children:[Z(`form`,{className:`ss-searchbox-form ss-searchbox-form--chat ss-sidepanel-compose-form`,onSubmit:e=>{e.preventDefault(),ee()},children:[a===`search`&&Z(`button`,{type:`button`,className:`searchia-search-back`,onClick:n,"aria-label":o.back,title:o.back,children:Z(Cg,{size:22})}),Z(`input`,{ref:s,dir:c.trim()?`auto`:r===`fa`?`rtl`:`ltr`,"aria-label":o.placeholder,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,maxLength:512,type:`text`,placeholder:te,value:c,disabled:d,onChange:e=>l(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),ee())}}),a===`search`&&c&&Z(`button`,{type:`button`,className:`searchia-search-clear`,onClick:()=>{l(``),s.current?.focus()},children:o.clear}),a===`search`?Z(m,{children:[Z(`button`,{type:`button`,className:`ss-search-new-chat-button`,title:o.newChat,"aria-label":o.newChat,onClick:y,children:Z(Dg,{size:20})}),Z(`button`,{type:`button`,className:`ss-search-close-button`,onClick:n,"aria-label":o.close,title:o.close,children:Z(wg,{})})]}):Z(`button`,{type:`submit`,className:`ss-search-submit-chat-button`,disabled:d||!c.trim(),title:o.send,"aria-label":o.send,children:Z(Og,{size:22})})]}),Z(`div`,{className:`ss-sidepanel-ai-notice`,children:Z(`p`,{className:`ss-sidepanel-ai-notice-text`,children:o.disclaimer})}),Z(`div`,{className:`ss-sidepanel-powered-by`,children:Z(`span`,{className:`searchia-powered-by-link`,children:[Z(`span`,{className:`ss-sidepanel-powered-by-label`,children:o.poweredBy}),Z(oy,{size:18})]})})]})})]})});function hy(e={}){let t=e.locale??e.language??`fa`,n=iy[t],r=He(null),i=He(null),[a,o]=Re(``),[s,c]=Re(null),l=He(null),u=Sv(e.darkMode),d=e.triggerPosition??`fixed`,f=Ue(()=>e.adapter??(e.searchia?new Pe(e.searchia):e.algolia?new ry(e.algolia):new Ie),[e.adapter,e.searchia,e.algolia]),p=py({adapter:f,language:t,suggestedQuestionsEnabled:e.suggestedQuestionsEnabled??!0,customSuggestedQuestions:e.customSuggestedQuestions}),h=We(()=>{l.current=document.activeElement,c(`chat`)},[]),g=We(()=>{l.current=document.activeElement,c(`search`)},[]),_=We(()=>{c(null),requestAnimationFrame(()=>(l.current??i.current??r.current)?.focus())},[]),v=We(async(e,t=`chat`)=>{!e.trim()||p.isGenerating||(l.current=document.activeElement,c(t),await p.sendMessage({text:e}))},[p.isGenerating,p.sendMessage]);return Ve(()=>(e.onReady?.({open:h,openSearch:g,ask:v}),()=>e.onReady?.(null)),[e.onReady,h,g,v]),Z(`div`,{lang:t,dir:t===`fa`?`rtl`:`ltr`,className:`searchia-widget ssask-exp ss-sidepanel-root ss-sidepanel-root--${d}${u?` dark`:``}`,children:[e.showSearch&&Z(`form`,{className:`searchia-ai-search`,onSubmit:e=>{e.preventDefault(),!(!a.trim()||p.isGenerating)&&(v(a,`search`),o(``))},children:[Z(Sg,{size:22}),Z(`input`,{ref:i,dir:a.trim()?`auto`:t===`fa`?`rtl`:`ltr`,type:`text`,maxLength:512,value:a,placeholder:n.searchPlaceholder,"aria-label":n.searchLabel,onChange:e=>o(e.currentTarget.value),disabled:p.isGenerating}),Z(`button`,{type:`submit`,disabled:!a.trim()||p.isGenerating,children:n.searchSubmit})]}),e.showSuggestedPrompts&&Z(`section`,{className:`searchia-entry-prompts`,"aria-label":n.suggestedLabel,children:p.suggestedQuestions.map(e=>Z(`button`,{type:`button`,disabled:p.isGenerating,onClick:()=>void v(e.question,`search`),dir:`auto`,children:e.question},e.objectID))}),e.showChatTrigger!==!1&&Z(`button`,{type:`button`,ref:r,className:`ss-sidepanel-trigger`,onClick:h,"aria-expanded":s===`chat`,"aria-haspopup":`dialog`,children:[Z(xg,{size:22}),Z(`span`,{children:e.buttonText??n.button})]}),s&&typeof document<`u`&&xt(Z(m,{children:[Z(`button`,{type:`button`,className:`searchia-widget ss-sidepanel-backdrop`,"aria-label":n.close,onClick:_}),Z(`div`,{lang:t,dir:t===`fa`?`rtl`:`ltr`,"aria-label":e.title??n.title,className:`searchia-widget ${s===`search`?`searchia-search-modal`:`ss-sidepanel-panel`} ssask-exp${u?` dark`:``}`,role:`dialog`,"aria-modal":`true`,onKeyDown:e=>{if(e.key!==`Tab`)return;let t=Array.from(e.currentTarget.querySelectorAll(`button:not(:disabled), input:not(:disabled), a[href]`)),n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())},children:Z(my,{config:e,adapter:f,language:t,session:p,surface:s,onClose:_})})]}),document.body)]})}const gy=/^#[^#\s]+$/;function _y(e){return typeof e==`string`?gy.test(e)?document.getElementById(e.slice(1)):document.querySelector(e):e}Me();const vy=new Map;let yy=null;function by(e,t){he(f(hy,{...t.config,onReady:t.onReady}),e)}function xy({container:e,...t}={}){if(typeof document>`u`)throw Error(`[SearchiaChat] DOM not available.`);let n=e?_y(e):yy;if(e&&!n)throw Error(`[SearchiaChat] Container not found.`);if(!e&&(!n||!document.body.contains(n))&&(n=document.createElement(`div`),n.id=`searchia-chat-widget-root`,document.body.appendChild(n),yy=n),!n)throw Error(`[SearchiaChat] DOM not available.`);let r=vy.get(n);if(r)r.config=t;else{let e={config:t,controls:null,onReady:t=>{e.controls=t}};r=e,vy.set(n,r)}by(n,r)}function Sy(e){let t=e?_y(e):yy;if(t)return vy.get(t);if(!e&&vy.size===1)return vy.values().next().value}function Cy(e,t){if(e!==`fa`&&e!==`en`)throw Error(`[SearchiaChat] Supported locales: fa, en.`);let n=t?_y(t):null;for(let[r,i]of vy){if(t&&r!==n)continue;i.config={...i.config,locale:e},by(r,i)}}function wy(e){Sy(e)?.controls?.open()}function Ty(e){Sy(e)?.controls?.openSearch()}async function Ey(e,t){let n=Sy(t)?.controls;if(!n)throw Error(`[SearchiaChat] Initialize the widget before asking a question.`);await n.ask(e)}function Dy(e){let t=e?_y(e):yy;t&&(he(null,t),vy.delete(t),t===yy&&(t.remove(),yy=null))}var Oy={init:xy,destroy:Dy,setLocale:Cy,open:wy,openSearch:Ty,ask:Ey,MockSearchiaAdapter:Ie,SearchiaApiAdapter:Pe};exports.AlgoliaChatAdapter=ry,exports.MockSearchiaAdapter=Ie,exports.SearchiaApiAdapter=Pe,exports.ask=Ey,exports.default=Oy,exports.destroy=Dy,exports.init=xy,exports.open=wy,exports.openSearch=Ty,exports.setLocale=Cy,exports.showcaseTranslations=ay;