@algolia/sitesearch
Version:
Opinionated site search modal for the web. Ships zero-build CDN bundles (JS + CSS) and a one-line init API. Powered by Algolia InstantSearch.
98 lines • 285 kB
JavaScript
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.SiteSearchSidepanelAskAI={}))})(this,function(exports){Object.defineProperty(exports,`__esModule`,{value:!0});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(e&&(t=e(e=0)),t),c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},u=(e,r,i)=>(i=e==null?{}:t(a(e)),l(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e));function d(e,t){for(var n in t)e[n]=t[n];return e}function f(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function p(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?_e.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 m(e,o,r,i,null)}function m(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??++ve,__i:-1,__u:0};return i==null&&x.vnode!=null&&x.vnode(a),a}function h(e){return e.children}function g(e,t){this.props=e,this.context=t}function _(e,t){if(t==null)return e.__?_(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`?_(e):null}function v(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 v(e)}}function y(e){(!e.__d&&(e.__d=!0)&&be.push(e)&&!b.__r++||xe!=x.debounceRendering)&&((xe=x.debounceRendering)||Se)(b)}function b(){for(var e,t,n,r,i,a,o,s=1;be.length;)be.length>s&&be.sort(Ce),e=be.shift(),s=be.length,e.__d&&(n=void 0,r=void 0,i=(r=(t=e).__v).__e,a=[],o=[],t.__P&&((n=d({},r)).__v=r.__v+1,x.vnode&&x.vnode(n),ce(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?[i]:null,a,i??_(r),!!(32&r.__u),o),n.__v=r.__v,n.__.__k[n.__i]=n,ue(a,n,o),r.__e=r.__=null,n.__e!=i&&v(n)));b.__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||Ae,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?ke:v[p.__i]||ke,p.__i=d,g=ce(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&pe(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?m(null,o,null,null,null):Me(o)?m(h,{children:o},null,null,null):o.constructor==null&&o.__b>0?m(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=ie(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=_(s)),me(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=_(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function re(e,t){return t||=[],e==null||typeof e==`boolean`||(Me(e)?e.some(function(e){re(e,t)}):t.push(e)),t}function ie(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 ae(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||je.test(t)?n:n+`px`}function oe(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||ae(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ae(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(we,`$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=Te,e.addEventListener(t,a?De:Ee,a)):e.removeEventListener(t,a?De:Ee,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 se(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Te++;else if(t.t<n.u)return;return n(x.event?x.event(t):t)}}}function ce(e,t,n,r,i,a,o,s,c,l){var u,p,m,_,v,y,b,te,ne,re,ie,ae,oe,se,ce,ue,pe,me=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=x.__b)&&u(t);n:if(typeof me==`function`)try{if(te=t.props,ne=`prototype`in me&&me.prototype.render,re=(u=me.contextType)&&r[u.__c],ie=u?re?re.props.value:u.__:r,n.__c?b=(p=t.__c=n.__c).__=p.__E:(ne?t.__c=p=new me(te,ie):(t.__c=p=new g(te,ie),p.constructor=me,p.render=he),re&&re.sub(p),p.props=te,p.state||={},p.context=ie,p.__n=r,m=p.__d=!0,p.__h=[],p._sb=[]),ne&&p.__s==null&&(p.__s=p.state),ne&&me.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=d({},p.__s)),d(p.__s,me.getDerivedStateFromProps(te,p.__s))),_=p.props,v=p.state,p.__v=t,m)ne&&me.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),ne&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(ne&&me.getDerivedStateFromProps==null&&te!==_&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(te,ie),!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(te,p.__s,ie)||t.__v==n.__v){for(t.__v!=n.__v&&(p.props=te,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(te,p.__s,ie),ne&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(_,v,y)})}if(p.context=ie,p.props=te,p.__P=e,p.__e=!1,oe=x.__r,se=0,ne){for(p.state=p.__s,p.__d=!1,oe&&oe(t),u=p.render(p.props,p.state,p.context),ce=0;ce<p._sb.length;ce++)p.__h.push(p._sb[ce]);p._sb=[]}else do p.__d=!1,oe&&oe(t),u=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=d(d({},r),p.getChildContext())),ne&&!m&&p.getSnapshotBeforeUpdate!=null&&(y=p.getSnapshotBeforeUpdate(_,v)),ue=u,u!=null&&u.type===h&&u.key==null&&(ue=de(u.props.children)),s=ee(e,Me(ue)?ue:[ue],t,n,r,i,a,o,s,c,l),p.base=t.__e,t.__u&=-161,p.__h.length&&o.push(p),b&&(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--;)f(a[pe]);le(t)}else t.__e=n.__e,t.__k=n.__k,e.then||le(t);x.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=fe(n.__e,t,n,r,i,a,o,c,l);return(u=x.diffed)&&u(t),128&t.__u?void 0:s}function le(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(le)}function ue(e,t,n){for(var r=0;r<n.length;r++)pe(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 de(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:Me(e)?e.map(de):d({},e)}function fe(e,t,n,r,i,a,o,s,c){var l,u,d,p,m,h,g,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`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==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[l]=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&(x.__m&&x.__m(t,a),s=!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=_e.call(e.childNodes),v=n.props||ke,!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`)d=m;else if(!(l in y)){if(l==`value`&&`defaultValue`in y||l==`checked`&&`defaultChecked`in y)continue;oe(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`?g=m:s&&typeof m!=`function`||v[l]===m||oe(e,l,m,v[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,Me(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&_(n,0),s,c),a!=null)for(l=a.length;l--;)f(a[l]);s||(l=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h!=null&&(h!==e[l]||b==`progress`&&!h||b==`option`&&h!=v[l])&&oe(e,l,h,v[l],i),l=`checked`,g!=null&&g!=e[l]&&oe(e,l,g,v[l],i))}return e}function pe(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 me(e,t,n){var r,i;if(x.unmount&&x.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||pe(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]&&me(r[i],t,n||typeof e.type!=`function`);n||f(e.__e),e.__c=e.__=e.__e=void 0}function he(e,t,n){return this.constructor(e,n)}function ge(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=[],ce(t,e=(!r&&n||t).__k=p(h,null,[e]),i||ke,ke,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?_e.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ue(a,e,o)}var _e,x,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne=s(()=>{ke={},Ae=[],je=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Me=Array.isArray,_e=Ae.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}},ve=0,ye=function(e){return e!=null&&e.constructor==null},g.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=d({},this.state),typeof e==`function`&&(e=e(d({},n),this.props)),e&&d(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),y(this))},g.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),y(this))},g.prototype.render=h,be=[],Se=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ce=function(e,t){return e.__v.__b-t.__v.__b},b.__r=0,we=/(PointerCapture)$|Capture$/i,Te=0,Ee=se(!1),De=se(!0),Oe=0});function Pe(){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 Fe(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 Ie(){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 Le(e){let t=[...e.caches],n=t.shift();return n===void 0?Ie():{get(e,r,i={miss:()=>Promise.resolve()}){return n.get(e,r,i).catch(()=>Le({caches:t}).get(e,r,i))},set(e,r){return n.set(e,r).catch(()=>Le({caches:t}).set(e,r))},delete(e){return n.delete(e).catch(()=>Le({caches:t}).delete(e))},clear(){return n.clear().catch(()=>Le({caches:t}).clear())}}}function Re(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 ze(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 Be(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 Ve({algoliaAgents:e,client:t,version:n}){let r=ze(n).add({segment:t,version:n});return e.forEach(e=>r.add(e)),r}function He(){return{debug(e,t){return Promise.resolve()},info(e,t){return Promise.resolve()},error(e,t){return Promise.resolve()}}}var Ue=2*60*1e3;function We(e,t=`up`){let n=Date.now();function r(){return t===`up`||Date.now()-n>Ue}function i(){return t===`timed out`&&Date.now()-n<=Ue}return{...e,status:t,lastUpdate:n,isUp:r,isTimedOut:i}}var Ge=class extends Error{name=`AlgoliaError`;constructor(e,t){super(e),t&&(this.name=t)}},Ke=class extends Ge{stackTrace;constructor(e,t,n){super(e,n),this.stackTrace=t}},qe=class extends Ke{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`)}},Je=class extends Ke{status;constructor(e,t,n,r=`ApiError`){super(e,n,r),this.status=t}},Ye=class extends Ge{response;constructor(e,t){super(e,`DeserializationError`),this.response=t}},Xe=class extends Je{error;constructor(e,t,n,r){super(e,t,r,`DetailedApiError`),this.error=n}};function Ze(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 Qe(e,t,n){let r=$e(n),i=`${e.protocol}://${e.url}${e.port?`:${e.port}`:``}/${t.charAt(0)===`/`?t.substring(1):t}`;return r.length&&(i+=`?${r}`),i}function $e(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 et(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 tt(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 nt(e){try{return JSON.parse(e.content)}catch(t){throw new Ye(t.message,e)}}function rt({content:e,status:t},n){try{let r=JSON.parse(e);return`error`in r?new Xe(r.message,t,r.error,n):new Je(r.message,t,n)}catch{}return new Je(e,t,n)}function it({isTimedOut:e,status:t}){return!e&&~~t===0}function at({isTimedOut:e,status:t}){return e||it({isTimedOut:e,status:t})||~~(t/100)!=2&&~~(t/100)!=4}function ot({status:e}){return~~(e/100)==2}function st(e){return e.map(e=>ct(e))}function ct(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 lt({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(We(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=et(c,l),m=tt(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 qe(st(f));let a={...o,...l.timeouts},u={data:p,headers:m,method:c.method,url:Qe(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(at(y)){let a=h(y);return y.isTimedOut&&_++,r.info(`Retryable failure`,ct(a)),await t.set(i,We(i,y.isTimedOut?`timed out`:`down`)),v(e,n)}if(ot(y))return nt(y);throw h(y),rt(y,f)},y=e.filter(e=>e.accept===`readWrite`||(d?e.accept===`read`:e.accept===`write`)),b=await u(y);return v([...b.hosts].reverse(),b.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 ut=`5.40.0`;function dt(e){return[{url:`${e}-dsn.algolia.net`,accept:`read`,protocol:`https`},{url:`${e}.algolia.net`,accept:`write`,protocol:`https`}].concat(Ze([{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 ft({appId:e,apiKey:t,authMode:n,algoliaAgents:r,...i}){let a=Be(e,t,n),o=lt({hosts:dt(e),...i,algoliaAgent:Ve({algoliaAgents:r,client:`Lite`,version:ut}),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 pt(e,t,n){if(!e||typeof e!=`string`)throw Error("`appId` is missing.");if(!t||typeof t!=`string`)throw Error("`apiKey` is missing.");return ft({appId:e,apiKey:t,timeouts:{connect:1e3,read:2e3,write:3e4},logger:He(),requester:Pe(),algoliaAgents:[{segment:`Browser`}],authMode:`WithinQueryParameters`,responsesCache:Re(),requestsCache:Re({serializable:!1}),hostsCache:Le({caches:[Fe({key:`${ut}-${e}`}),Re()]}),...n})}function mt(e,t){C.__h&&C.__h(S,e,jt||t),jt=0;var n=S.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function ht(e){return jt=1,gt(Dt,e)}function gt(e,t,n){var r=mt(Ot++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Dt(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 _t(e,t){var n=mt(Ot++,3);!C.__s&&Et(n.__H,t)&&(n.__=e,n.u=t,S.__H.__h.push(n))}function vt(e,t){var n=mt(Ot++,4);!C.__s&&Et(n.__H,t)&&(n.__=e,n.u=t,S.__h.push(n))}function yt(e){return jt=5,bt(function(){return{current:e}},[])}function bt(e,t){var n=mt(Ot++,7);return Et(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function xt(e,t){return jt=8,bt(function(){return e},t)}function St(){for(var e;e=Mt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(wt),e.__H.__h.forEach(Tt),e.__H.__h=[]}catch(t){e.__H.__h=[],C.__e(t,e.__v)}}function Ct(e){var t,n=function(){clearTimeout(r),zt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);zt&&(t=requestAnimationFrame(n))}function wt(e){var t=S,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),S=t}function Tt(e){var t=S;e.__c=e.__(),S=t}function Et(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Dt(e,t){return typeof t==`function`?t(e):t}var Ot,S,kt,At,jt,Mt,C,Nt,Pt,Ft,It,Lt,Rt,zt,Bt=s(()=>{Ne(),jt=0,Mt=[],C=x,Nt=C.__b,Pt=C.__r,Ft=C.diffed,It=C.__c,Lt=C.unmount,Rt=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),Rt&&Rt(e,t)},C.__r=function(e){Pt&&Pt(e),Ot=0;var t=(S=e.__c).__H;t&&(kt===S?(t.__h=[],S.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(wt),t.__h.forEach(Tt),t.__h=[],Ot=0)),kt=S},C.diffed=function(e){Ft&&Ft(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Mt.push(t)!==1&&At===C.requestAnimationFrame||((At=C.requestAnimationFrame)||Ct)(St)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),kt=S=null},C.__c=function(e,t){t.some(function(e){try{e.__h.forEach(wt),e.__h=e.__h.filter(function(e){return!e.__||Tt(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],C.__e(n,e.__v)}}),It&&It(e,t)},C.unmount=function(e){Lt&&Lt(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{wt(e)}catch(e){t=e}}),n.__H=void 0,t&&C.__e(t,n.__v))},zt=typeof requestAnimationFrame==`function`});function Vt(e,t){for(var n in t)e[n]=t[n];return e}function Ht(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 Ut(e,t){var n=t(),r=ht({t:{__:n,u:t}}),i=r[0].t,a=r[1];return vt(function(){i.__=n,i.u=t,Wt(i)&&a({t:i})},[e,n,t]),_t(function(){return Wt(i)&&a({t:i}),e(function(){Wt(i)&&a({t:i})})},[e]),n}function Wt(e){var t,n,r=e.u,i=e.__;try{var a=r();return!((t=i)===(n=a)&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}}function Gt(e,t){this.props=e,this.context=t}function Kt(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:Ht(this.props,e)}function r(t){return this.shouldComponentUpdate=n,p(e,t)}return r.displayName=`Memo(`+(e.displayName||e.name)+`)`,r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}function qt(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=Vt({},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 qt(e,t,n)})),e}function Jt(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Jt(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 Yt(){this.__u=0,this.o=null,this.__b=null}function Xt(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Zt(){this.i=null,this.l=null}function Qt(e){return this.getChildContext=function(){return e.context},e.children}function $t(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){ge(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)}}}ge(p(Qt,{context:t.context},e.__v),t.v)}function en(e,t){var n=p($t,{__v:e,h:t});return n.containerInfo=t,n}function tn(){}function nn(){return this.cancelBubble}function rn(){return this.defaultPrevented}var an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn=s(()=>{Ne(),Bt(),Bt(),(Gt.prototype=new g).isPureReactComponent=!0,Gt.prototype.shouldComponentUpdate=function(e,t){return Ht(this.props,e)||Ht(this.state,t)},an=x.__b,x.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),an&&an(e)},on=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.forward_ref`)||3911,sn=function(e,t){return e==null?null:re(re(e).map(t))},cn={map:sn,forEach:sn,count:function(e){return e?re(e).length:0},only:function(e){var t=re(e);if(t.length!==1)throw`Children.only`;return t[0]},toArray:re},ln=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)}ln(e,t,n,r)},un=x.unmount,x.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),un&&un(e)},(Yt.prototype=new g).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Xt(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]=Jt(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)},Yt.prototype.componentWillUnmount=function(){this.o=[]},Yt.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]=qt(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&p(h,null,e.fallback);return i&&(i.__u&=-33),[p(h,null,t.__a?null:e.children),i]},dn=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]}},(Zt.prototype=new g).__a=function(e){var t=this,n=Xt(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),dn(t,e,r)):i()};n?n(a):a()}},Zt.prototype.render=function(e){this.i=null,this.l=new Map;var t=re(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},Zt.prototype.componentDidUpdate=Zt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){dn(e,n,t)})},fn=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,pn=/^(?: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]/,mn=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,hn=/[A-Z0-9]/g,gn=typeof document<`u`,_n=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)},g.prototype.isReactComponent={},[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(g.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}),vn=x.event,x.event=function(e){return vn&&(e=vn(e)),e.persist=tn,e.isPropagationStopped=nn,e.isDefaultPrevented=rn,e.nativeEvent=e},bn={enumerable:!1,configurable:!0,get:function(){return this.class}},xn=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||gn&&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`||_n(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:mn.test(a)&&(a=s):s=a=`oninput`:i&&pn.test(a)?a=a.replace(hn,`-$&`).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=re(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),n==`select`&&r.defaultValue!=null&&(r.value=re(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`,bn)):(t.className&&!t.class||t.class&&t.className)&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=fn,xn&&xn(e)},Sn=x.__r,x.__r=function(e){Sn&&Sn(e),yn=e.__c},Cn=x.diffed,x.diffed=function(e){Cn&&Cn(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),yn=null}}),Tn=`vercel.ai.error`,En=Symbol.for(Tn),Dn,On=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Dn]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Tn)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};Dn=En;var kn=On,An=`AI_APICallError`,jn=`vercel.ai.error.${An}`,Mn=Symbol.for(jn),Nn;Nn=Mn;var Pn=`AI_EmptyResponseBodyError`,Fn=`vercel.ai.error.${Pn}`,In=Symbol.for(Fn),Ln;Ln=In;function Rn(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var zn=`AI_InvalidArgumentError`,Bn=`vercel.ai.error.${zn}`,Vn=Symbol.for(Bn),Hn,Un=class extends kn{constructor({message:e,cause:t,argument:n}){super({name:zn,message:e,cause:t}),this[Hn]=!0,this.argument=n}static isInstance(e){return kn.hasMarker(e,Bn)}};Hn=Vn;var Wn=`AI_InvalidPromptError`,Gn=`vercel.ai.error.${Wn}`,Kn=Symbol.for(Gn),qn;qn=Kn;var Jn=`AI_InvalidResponseDataError`,Yn=`vercel.ai.error.${Jn}`,Xn=Symbol.for(Yn),Zn;Zn=Xn;var Qn=`AI_JSONParseError`,$n=`vercel.ai.error.${Qn}`,er=Symbol.for($n),tr,nr=class extends kn{constructor({text:e,cause:t}){super({name:Qn,message:`JSON parsing failed: Text: ${e}.
Error message: ${Rn(t)}`,cause:t}),this[tr]=!0,this.text=e}static isInstance(e){return kn.hasMarker(e,$n)}};tr=er;var rr=`AI_LoadAPIKeyError`,ir=`vercel.ai.error.${rr}`,ar=Symbol.for(ir),or;or=ar;var sr=`AI_LoadSettingError`,cr=`vercel.ai.error.${sr}`,lr=Symbol.for(cr),ur;ur=lr;var dr=`AI_NoContentGeneratedError`,fr=`vercel.ai.error.${dr}`,pr=Symbol.for(fr),mr;mr=pr;var hr=`AI_NoSuchModelError`,gr=`vercel.ai.error.${hr}`,_r=Symbol.for(gr),vr;vr=_r;var yr=`AI_TooManyEmbeddingValuesForCallError`,br=`vercel.ai.error.${yr}`,xr=Symbol.for(br),Sr;Sr=xr;var Cr=`AI_TypeValidationError`,wr=`vercel.ai.error.${Cr}`,Tr=Symbol.for(wr),Er,Dr=class e extends kn{constructor({value:e,cause:t}){super({name:Cr,message:`Type validation failed: Value: ${JSON.stringify(e)}.
Error message: ${Rn(t)}`,cause:t}),this[Er]=!0,this.value=e}static isInstance(e){return kn.hasMarker(e,wr)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}};Er=Tr;var Or=Dr,kr=`AI_UnsupportedFunctionalityError`,Ar=`vercel.ai.error.${kr}`,jr=Symbol.for(Ar),Mr;Mr=jr;var Nr=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 Pr(e){}function Fr(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Pr,onError:n=Pr,onRetry:r=Pr,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=Ir(`${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}
`;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Nr(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Nr(`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(`
`)?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 Ir(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
`,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]===`
`&&r++}}return[t,n]}var Lr=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Fr({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)}})}};let Rr=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}let zr=Symbol(`zod_brand`);var Br=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};let Vr={};function Hr(e){return e&&Object.assign(Vr,e),Vr}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 Wr(e,t){return typeof t==`bigint`?t.toString():t}function Gr(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 Kr(e){return e==null}function qr(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Jr(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 Yr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Xr(e){return JSON.stringify(e)}let Zr=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Qr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let $r=Gr(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{let e=Function;return new e(``),!0}catch{return!1}});function ei(e){if(Qr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(Qr(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}let ti=new Set([`string`,`number`,`symbol`]);function ni(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ri(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 ii(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let ai={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function oi(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 ri(e,{...e._zod.def,shape:n,checks:[]})}function si(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 ri(e,{...e._zod.def,shape:n,checks:[]})}function ci(e,t){if(!ei(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 Yr(this,`shape`,n),n},checks:[]};return ri(e,n)}function li(e,t){return ri(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Yr(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function ui(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 ri(t,{...t._zod.def,shape:i,checks:[]})}function di(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 ri(t,{...t._zod.def,shape:i,checks:[]})}function fi(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pi(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function mi(e){return typeof e==`string`?e:e?.message}function hi(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let i=mi(e.inst?._zod.def?.error?.(e))??mi(t?.error?.(e))??mi(n.customError?.(e))??mi(n.localeError?.(e))??`Invalid input`;r.message=i}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function gi(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function _i(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let vi=(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,Wr,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},yi=w(`$ZodError`,vi),bi=w(`$ZodError`,vi,{Parent:Error});function xi(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 Si(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}let Ci=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 Br;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>hi(e,a,Hr())));throw Zr(t,i?.callee),t}return o.value},wi=Ci(bi),Ti=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=>hi(e,a,Hr())));throw Zr(t,i?.callee),t}return o.value},Ei=Ti(bi),Di=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 Br;return a.issues.length?{success:!1,error:new(e??yi)(a.issues.map(e=>hi(e,i,Hr())))}:{success:!0,data:a.value}},Oi=Di(bi),ki=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=>hi(e,i,Hr())))}:{success:!0,data:a.value}},Ai=ki(bi),ji=/^[cC][^\s-]{8,}$/,Mi=/^[0-9a-z]+$/,Ni=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Pi=/^[0-9a-vA-V]{20}$/,Fi=/^[A-Za-z0-9]{27}$/,Ii=/^[a-zA-Z0-9_-]{21}$/,Li=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ri=/^([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})$/,zi=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)$/,Bi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Vi=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Hi(){return new RegExp(Vi,`u`)}let 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])$/,Wi=/^(([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})$/,Gi=/^((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])$/,Ki=/^(([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])$/,qi=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ji=/^[A-Za-z0-9_-]*$/,Yi=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Xi=/^\+(?:[0-9]){6,14}[0-9]$/,Zi=`(?:(?:\\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])))`,Qi=RegExp(`^${Zi}$`);function $i(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 ea(e){return RegExp(`^${$i(e)}$`)}function ta(e){let t=$i({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Zi}T(?:${r})$`)}let na=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ra=/^\d+$/,ia=/^-?\d+(?:\.\d+)?/i,aa=/true|false/i,oa=/null/i,sa=/^[^A-Z]*$/,ca=/^[^a-z]*$/,la=w(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ua={number:`number`,bigint:`bigint`,object:`date`},da=w(`$ZodCheckLessThan`,(e,t)=>{la.init(e,t);let n=ua[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})}}),fa=w(`$ZodCheckGreaterThan`,(e,t)=>{la.init(e,t);let n=ua[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})}}),pa=w(`$ZodCheckMultipleOf`,(e,t)=>{la.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):Jr(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})}}),ma=w(`$ZodCheckNumberFormat`,(e,t)=>{la.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ai[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=ra)}),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})}}),ha=w(`$ZodCheckMaxLength`,(e,t)=>{var n;la.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Kr(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=gi(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ga=w(`$ZodCheckMinLength`,(e,t)=>{var n;la.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Kr(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=gi(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_a=w(`$ZodCheckLengthEquals`,(e,t)=>{var n;la.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Kr(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=gi(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})}}),va=w(`$ZodCheckStringFormat`,(e,t)=>{var n,r;la.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=()=>{})}),ya=w(`$ZodCheckRegex`,(e,t)=>{va.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})}}),ba=w(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=sa,va.init(e,t)}),xa=w(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ca,va.init(e,t)}),Sa=w(`$ZodCheckIncludes`,(e,t)=>{la.init(e,t);let n=ni(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})}}),Ca=w(`$ZodCheckStartsWith`,(e,t)=>{la.init(e,t);let n=RegExp(`^${ni(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})}}),wa=w(`$ZodCheckEndsWith`,(e,t)=>{la.init(e,t);let n=RegExp(`.*${ni(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})}}),Ta=w(`$ZodCheckOverwrite`,(e,t)=>{la.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ea=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(`
`).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(`
`))}};let Da={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=Da;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=fi(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 Br;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o;let n=e.issues.length;n!==t&&(r||=fi(e,t))});else{let n=e.issues.length;if(n===t)continue;r||=fi(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 Br;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=Oi(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ai(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Oa=w(`$ZodString`,(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??na(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)=>{va.init(e,t),Oa.init(e,t)}),ka=w(`$ZodGUID`,(e,t)=>{t.pattern??=Ri,O.init(e,t)}),Aa=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??=zi(n)}else t.pattern??=zi();O.init(e,t)}),ja=w(`$ZodEmail`,(e,t)=>{t.pattern??=Bi,O.init(e,t)}),Ma=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:Yi.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})}}}),Na=w(`$ZodEmoji`,(e,t)=>{t.pattern??=Hi(),O.init(e,t)}),Pa=w(`$ZodNanoID`,(e,t)=>{t.pattern??=Ii,O.init(e,t)}),Fa=w(`$ZodCUID`,(e,t)=>{t.pattern??=ji,O.init(e,t)}),Ia=w(`$ZodCUID2`,(e,t)=>{t.pattern??=Mi,O.init(e,t)}),La=w(`$ZodULID`,(e,t)=>{t.pattern??=Ni,O.init(e,t)}),Ra=w(`$ZodXID`,(e,t)=>{t.pattern??=Pi,O.init(e,t)}),za=w(`$ZodKSUID`,(e,t)=>{t.pattern??=Fi,O.init(e,t)}),Ba=w(`$ZodISODateTime`,(e,t)=>{t.pattern??=ta(t),O.init(e,t)}),Va=w(`$ZodISODate`,(e,t)=>{t.pattern??=Qi,O.init(e,t)}),Ha=w(`$ZodISOTime`,(e,t)=>{t.pattern??=ea(t),O.init(e,t)}),Ua=w(`$ZodISODuration`,(e,t)=>{t.pattern??=Li,O.init(e,t)}),Wa=w(`$ZodIPv4`,(e,t)=>{t.pattern??=Ui,O.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),Ga=w(`$ZodIPv6`,(e,t)=>{t.pattern??=Wi,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})}}}),Ka=w(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Gi,O.init(e,t)}),qa=w(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ki,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 Ja(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Ya=w(`$ZodBase64`,(e,t)=>{t.pattern??=qi,O.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Ja(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Xa(e){if(!Ji.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`),n=t.padEnd(Math.ceil(t.length/4)*4,`=`);return Ja(n)}let Za=w(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ji,O.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{Xa(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Qa=w(`$ZodE164`,(e,t)=>{t.pattern??=Xi,O.init(e,t)});function $a(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}}let eo=w(`$ZodJWT`,(e,t)=>{O.init(e,t),e._zod.check=n=>{$a(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),to=w(`$ZodNumber`,(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??ia,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}}),no=w(`$ZodNumber`,(e,t)=>{ma.init(e,t),to.init(e,t)}),ro=w(`$ZodBoolean`,(e,t)=>{D.init(e,t),e._zod.pattern=aa,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}}),io=w(`$ZodNull`,(e,t)=>{D.init(e,t),e._zod.pattern=oa,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}}),ao=w(`$ZodUnknown`,(e,t)=>{D.init(e,t),e._zod.parse=e=>e}),oo=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 so(e,t,n){e.issues.length&&t.issues.push(...pi(n,e.issues)),t.value[n]=e.value}let co=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=>so(t,n,e))):so(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function lo(e,t,n){e.issues.length&&t.issues.push(...pi(n,e.issues)),t.value[n]=e.value}function uo(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(...pi(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}let fo=w(`$ZodObject`,(e,t)=>{D.init(e,t);let n=Gr(()=>{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=ii(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 Ea([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=Xr(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=Xr(e);t.write(`
if (${n}.issues.length) {
if (input[${r}] === undefined) {
if (${r} in input) {
newResult[${r}] = undefined;
}
} else {
payload.issues = payload.issues.concat(
${n}.issues.map((iss) => ({
...iss,
path: iss.path ? [${r}, ...iss.path] : [${r}],
}))
);
}
} else if (${n}.value === undefined) {
if (${r} in input) newResult[${r}] = undefined;
} else {
newResult[${r}] = ${n}.value;
}
`)}else{let n=a[e];t.write(`const ${n} = ${i(e)};`),t.write(`
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
...iss,
path: iss.path ? [${Xr(e)}, ...iss.path] : [${Xr(e)}]
})));`),t.write(`newResult[${Xr(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=Qr,o=!Vr.jitless,s=$r,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?uo(e,s,t,f):lo(e,s,t))):i?uo(r,s,t,f):lo(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=>lo(t,s,e))):lo(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 po(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=>hi(e,r,Hr())))}),t}let mo=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=>qr(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=>po(t,n,e,r)):po(a,n,e,r)}}),ho=w(`$ZodDiscriminatedUnion`,(e,t)=>{mo.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=Gr(()=>{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(!Qr(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)}}),go=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])=>vo(e,t,n)):vo(e,i,a)}});function _o(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ei(e)&&ei(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=_o(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=_o(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 vo(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),fi(e))return e;let r=_o(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}let yo=w(`$ZodRecord`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ei(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(...pi(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...pi(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=>hi(e,r,Hr())),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(...pi(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...pi(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),bo=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=>ti.has(typeof e)).map(e=>typeof e==`string`?ni(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}}),xo=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`?ni(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}}),So=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 Br;return e.value=r,e}}),Co=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(`^(${qr(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)}),wo=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(`^(${qr(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)}),To=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=>Eo(e,t)):Eo(r,t)}});function Eo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Do=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))}),Oo=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=>ko(t,e)):ko(i,e)}});function ko(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Ao=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=>hi(e,n,Hr()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>hi(e,n,Hr()))},input:e.value}),e.issues=[]),e)}}),jo=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=>Mo(e,t,n)):Mo(r,t,n)}});function Mo(e,t,n){return fi(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}let No=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(Po):Po(r)}});function Po(e){return e.value=Object.freeze(e.value),e}let Fo=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)}}),Io=w(`$ZodCustom`,(e,t)=>{la.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=>Lo(t,n,r,e));Lo(i,n,r,e)}});function Lo(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(_i(e))}}let Ro=Symbol(`ZodOutput`),zo=Symbol(`ZodInput`);var Bo=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 Vo(){return new Bo}let Ho=Vo();function Uo(e,t){return new e({type:`string`,...E(t)})}function Wo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...E(t)})}function Go(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...E(t)})}function Ko(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...E(t)})}function qo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...E(t)})}function Jo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...E(t)})}function Yo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...E(t)})}function Xo(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...E(t)})}function Zo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...E(t)})}function Qo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...E(t)})}function $o(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...E(t)})}function es(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...E(t)})}function ts(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...E(t)})}function ns(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...E(t)})}function rs(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...E(t)})}function os(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...E(t)})}function ss(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...E(t)})}function cs(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...E(t)})}function ls(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...E(t)})}function us(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...E(t)})}function ds(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...E(t)})}function fs(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...E(t)})}function ps(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...E(t)})}function ms(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...E(t)})}function hs(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...E(t)})}function gs(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...E(t)})}function _s(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...E(t)})}function vs(e,t){return new e({type:`number`,checks:[],...E(t)})}function ys(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...E(t)})}function bs(e,t){return new e({type:`boolean`,...E(t)})}function xs(e,t){return new e({type:`null`,...E(t)})}function Ss(e){return new e({type:`unknown`})}function Cs(e,t){return new e({type:`never`,...E(t)})}function ws(e,t){return new da({check:`less_than`,...E(t),value:e,inclusive:!1})}function Ts(e,t){return new da({check:`less_than`,...E(t),value:e,inclusive:!0})}function Es(e,t){return new fa({check:`greater_than`,...E(t),value:e,inclusive:!1})}function Ds(e,t){return new fa({check:`greater_than`,...E(t),value:e,inclusive:!0})}function Os(e,t){return new pa({check:`multiple_of`,...E(t),value:e})}function ks(e,t){let n=new ha({check:`max_length`,...E(t),maximum:e});return n}function As(e,t){return new ga({check:`min_length`,...E(t),minimum:e})}function js(e,t){return new _a({check:`length_equals`,...E(t),length:e})}function Ms(e,t){return new ya({check:`string_format`,format:`regex`,...E(t),pattern:e})}function Ns(e){return new ba({check:`string_format`,format:`lowercase`,...E(e)})}function Ps(e){return new xa({check:`string_format`,format:`uppercase`,...E(e)})}function Fs(e,t){return new Sa({check:`string_format`,format:`includes`,...E(t),includes:e})}function Is(e,t){return new Ca({check:`string_format`,format:`starts_with`,...E(t),prefix:e})}function Ls(e,t){return new wa({check:`string_format`,format:`ends_with`,...E(t),suffix:e})}function Rs(e){return new Ta({check:`overwrite`,tx:e})}function zs(e){return Rs(t=>t.normalize(e))}function Bs(){return Rs(e=>e.trim())}function Vs(){return Rs(e=>e.toLowerCase())}function Hs(){return Rs(e=>e.toUpperCase())}function Us(e,t,n){return new e({type:`array`,element:t,...E(n)})}function Ws(e,t,n){let r=E(n);r.abort??=!0;let i=new e({type:`custom`,check:`custom`,fn:t,...r});return i}function Gs(e,t,n){let r=new e({type:`custom`,check:`custom`,fn:t,...E(n)});return r}var Ks=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Ho,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`&&k(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>
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 qs(e,t){if(e instanceof Bo){let n=new Ks(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 Ks(t);return n.process(e),n.emit(e,t)}function k(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 k(i.element,n);case`object`:for(let e in i.shape)if(k(i.shape[e],n))return!0;return!1;case`union`:for(let e of i.options)if(k(e,n))return!0;return!1;case`intersection`:return k(i.left,n)||k(i.right,n);case`tuple`:for(let e of i.items)if(k(e,n))return!0;return!!(i.rest&&k(i.rest,n));case`record`:return k(i.keyType,n)||k(i.valueType,n);case`map`:return k(i.keyType,n)||k(i.valueType,n);case`set`:return k(i.valueType,n);case`promise`:case`optional`:case`nonoptional`:case`nullable`:case`readonly`:return k(i.innerType,n);case`lazy`:return k(i.getter(),n);case`default`:return k(i.innerType,n);case`prefault`:return k(i.innerType,n);case`custom`:return!1;case`transform`:return!0;case`pipe`:return k(i.in,n)||k(i.out,n);case`success`:return!1;case`catch`:return!1;default:}throw Error(`Unknown schema type: ${i.type}`)}let Js=w(`ZodISODateTime`,(e,t)=>{Ba.init(e,t),M.init(e,t)});function Ys(e){return ms(Js,e)}let Xs=w(`ZodISODate`,(e,t)=>{Va.init(e,t),M.init(e,t)});function Zs(e){return hs(Xs,e)}let Qs=w(`ZodISOTime`,(e,t)=>{Ha.init(e,t),M.init(e,t)});function $s(e){return gs(Qs,e)}let ec=w(`ZodISODuration`,(e,t)=>{Ua.init(e,t),M.init(e,t)});function tc(e){return _s(ec,e)}let nc=(e,t)=>{yi.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Si(e,t)},flatten:{value:t=>xi(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})},rc=w(`ZodError`,nc),ic=w(`ZodError`,nc,{Parent:Error}),ac=Ci(ic),oc=Ti(ic),sc=Di(ic),cc=ki(ic),A=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)=>ri(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>ac(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>sc(e,t,n),e.parseAsync=async(t,n)=>oc(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>cc(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(Sl(t,n)),e.superRefine=t=>e.check(Cl(t)),e.overwrite=t=>e.check(Rs(t)),e.optional=()=>nl(e),e.nullable=()=>il(e),e.nullish=()=>nl(il(e)),e.nonoptional=t=>ul(e,t),e.array=()=>Bc(e),e.or=t=>Uc([e,t]),e.and=t=>qc(e,t),e.transform=t=>ml(e,el(t)),e.default=t=>ol(e,t),e.prefault=t=>cl(e,t),e.catch=t=>fl(e,t),e.pipe=t=>ml(e,t),e.readonly=()=>gl(e),e.describe=t=>{let n=e.clone();return Ho.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Ho.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Ho.get(e);let n=e.clone();return Ho.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),lc=w(`_ZodString`,(e,t)=>{Oa.init(e,t),A.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(Ms(...t)),e.includes=(...t)=>e.check(Fs(...t)),e.startsWith=(...t)=>e.check(Is(...t)),e.endsWith=(...t)=>e.check(Ls(...t)),e.min=(...t)=>e.check(As(...t)),e.max=(...t)=>e.check(ks(...t)),e.length=(...t)=>e.check(js(...t)),e.nonempty=(...t)=>e.check(As(1,...t)),e.lowercase=t=>e.check(Ns(t)),e.uppercase=t=>e.check(Ps(t)),e.trim=()=>e.check(Bs()),e.normalize=(...t)=>e.check(zs(...t)),e.toLowerCase=()=>e.check(Vs()),e.toUpperCase=()=>e.check(Hs())}),uc=w(`ZodString`,(e,t)=>{Oa.init(e,t),lc.init(e,t),e.email=t=>e.check(Wo(dc,t)),e.url=t=>e.check(Xo(mc,t)),e.jwt=t=>e.check(ps(kc,t)),e.emoji=t=>e.check(Zo(hc,t)),e.guid=t=>e.check(Go(fc,t)),e.uuid=t=>e.check(Ko(pc,t)),e.uuidv4=t=>e.check(qo(pc,t)),e.uuidv6=t=>e.check(Jo(pc,t)),e.uuidv7=t=>e.check(Yo(pc,t)),e.nanoid=t=>e.check(Qo(gc,t)),e.guid=t=>e.check(Go(fc,t)),e.cuid=t=>e.check($o(_c,t)),e.cuid2=t=>e.check(es(vc,t)),e.ulid=t=>e.check(ts(yc,t)),e.base64=t=>e.check(us(Ec,t)),e.base64url=t=>e.check(ds(Dc,t)),e.xid=t=>e.check(ns(bc,t)),e.ksuid=t=>e.check(rs(xc,t)),e.ipv4=t=>e.check(os(Sc,t)),e.ipv6=t=>e.check(ss(Cc,t)),e.cidrv4=t=>e.check(cs(wc,t)),e.cidrv6=t=>e.check(ls(Tc,t)),e.e164=t=>e.check(fs(Oc,t)),e.datetime=t=>e.check(Ys(t)),e.date=t=>e.check(Zs(t)),e.time=t=>e.check($s(t)),e.duration=t=>e.check(tc(t))});function j(e){return Uo(uc,e)}let M=w(`ZodStringFormat`,(e,t)=>{O.init(e,t),lc.init(e,t)}),dc=w(`ZodEmail`,(e,t)=>{ja.init(e,t),M.init(e,t)}),fc=w(`ZodGUID`,(e,t)=>{ka.init(e,t),M.init(e,t)}),pc=w(`ZodUUID`,(e,t)=>{Aa.init(e,t),M.init(e,t)}),mc=w(`ZodURL`,(e,t)=>{Ma.init(e,t),M.init(e,t)}),hc=w(`ZodEmoji`,(e,t)=>{Na.init(e,t),M.init(e,t)}),gc=w(`ZodNanoID`,(e,t)=>{Pa.init(e,t),M.init(e,t)}),_c=w(`ZodCUID`,(e,t)=>{Fa.init(e,t),M.init(e,t)}),vc=w(`ZodCUID2`,(e,t)=>{Ia.init(e,t),M.init(e,t)}),yc=w(`ZodULID`,(e,t)=>{La.init(e,t),M.init(e,t)}),bc=w(`ZodXID`,(e,t)=>{Ra.init(e,t),M.init(e,t)}),xc=w(`ZodKSUID`,(e,t)=>{za.init(e,t),M.init(e,t)}),Sc=w(`ZodIPv4`,(e,t)=>{Wa.init(e,t),M.init(e,t)}),Cc=w(`ZodIPv6`,(e,t)=>{Ga.init(e,t),M.init(e,t)}),wc=w(`ZodCIDRv4`,(e,t)=>{Ka.init(e,t),M.init(e,t)}),Tc=w(`ZodCIDRv6`,(e,t)=>{qa.init(e,t),M.init(e,t)}),Ec=w(`ZodBase64`,(e,t)=>{Ya.init(e,t),M.init(e,t)}),Dc=w(`ZodBase64URL`,(e,t)=>{Za.init(e,t),M.init(e,t)}),Oc=w(`ZodE164`,(e,t)=>{Qa.init(e,t),M.init(e,t)}),kc=w(`ZodJWT`,(e,t)=>{eo.init(e,t),M.init(e,t)}),Ac=w(`ZodNumber`,(e,t)=>{to.init(e,t),A.init(e,t),e.gt=(t,n)=>e.check(Es(t,n)),e.gte=(t,n)=>e.check(Ds(t,n)),e.min=(t,n)=>e.check(Ds(t,n)),e.lt=(t,n)=>e.check(ws(t,n)),e.lte=(t,n)=>e.check(Ts(t,n)),e.max=(t,n)=>e.check(Ts(t,n)),e.int=t=>e.check(Nc(t)),e.safe=t=>e.check(Nc(t)),e.positive=t=>e.check(Es(0,t)),e.nonnegative=t=>e.check(Ds(0,t)),e.negative=t=>e.check(ws(0,t)),e.nonpositive=t=>e.check(Ts(0,t)),e.multipleOf=(t,n)=>e.check(Os(t,n)),e.step=(t,n)=>e.check(Os(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 jc(e){return vs(Ac,e)}let Mc=w(`ZodNumberFormat`,(e,t)=>{no.init(e,t),Ac.init(e,t)});function Nc(e){return ys(Mc,e)}let Pc=w(`ZodBoolean`,(e,t)=>{ro.init(e,t),A.init(e,t)});function N(e){return bs(Pc,e)}let Fc=w(`ZodNull`,(e,t)=>{io.init(e,t),A.init(e,t)});function Ic(e){return xs(Fc,e)}let Lc=w(`ZodUnknown`,(e,t)=>{ao.init(e,t),A.init(e,t)});function P(){return Ss(Lc)}let Rc=w(`ZodNever`,(e,t)=>{oo.init(e,t),A.init(e,t)});function F(e){return Cs(Rc,e)}let zc=w(`ZodArray`,(e,t)=>{co.init(e,t),A.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(As(t,n)),e.nonempty=t=>e.check(As(1,t)),e.max=(t,n)=>e.check(ks(t,n)),e.length=(t,n)=>e.check(js(t,n)),e.unwrap=()=>e.element});function Bc(e,t){return Us(zc,e,t)}let Vc=w(`ZodObject`,(e,t)=>{fo.init(e,t),A.init(e,t),T(e,`shape`,()=>t.shape),e.keyof=()=>Zc(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:P()}),e.loose=()=>e.clone({...e._zod.def,catchall:P()}),e.strict=()=>e.clone({...e._zod.def,catchall:F()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>ci(e,t),e.merge=t=>li(e,t),e.pick=t=>oi(e,t),e.omit=t=>si(e,t),e.partial=(...t)=>ui(tl,e,t[0]),e.required=(...t)=>di(ll,e,t[0])});function I(e,t){let n={type:`object`,get shape(){return Yr(this,`shape`,{...e}),this.shape},...E(t)};return new Vc(n)}function L(e,t){return new Vc({type:`object`,get shape(){return Yr(this,`shape`,{...e}),this.shape},catchall:F(),...E(t)})}let Hc=w(`ZodUnion`,(e,t)=>{mo.init(e,t),A.init(e,t),e.options=t.options});function Uc(e,t){return new Hc({type:`union`,options:e,...E(t)})}let Wc=w(`ZodDiscriminatedUnion`,(e,t)=>{Hc.init(e,t),ho.init(e,t)});function Gc(e,t,n){return new Wc({type:`union`,options:t,discriminator:e,...E(n)})}let Kc=w(`ZodIntersection`,(e,t)=>{go.init(e,t),A.init(e,t)});function qc(e,t){return new Kc({type:`intersection`,left:e,right:t})}let Jc=w(`ZodRecord`,(e,t)=>{yo.init(e,t),A.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Yc(e,t,n){return new Jc({type:`record`,keyType:e,valueType:t,...E(n)})}let Xc=w(`ZodEnum`,(e,t)=>{bo.init(e,t),A.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 Xc({...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 Xc({...t,checks:[],...E(r),entries:i})}});function Zc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Xc({type:`enum`,entries:n,...E(t)})}let Qc=w(`ZodLiteral`,(e,t)=>{xo.init(e,t),A.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 R(e,t){return new Qc({type:`literal`,values:Array.isArray(e)?e:[e],...E(t)})}let $c=w(`ZodTransform`,(e,t)=>{So.init(e,t),A.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(_i(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(_i(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function el(e){return new $c({type:`transform`,transform:e})}let tl=w(`ZodOptional`,(e,t)=>{Co.init(e,t),A.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nl(e){return new tl({type:`optional`,innerType:e})}let rl=w(`ZodNullable`,(e,t)=>{wo.init(e,t),A.init(e,t),e.unwrap=()=>e._zod.def.innerType});function il(e){return new rl({type:`nullable`,innerType:e})}let al=w(`ZodDefault`,(e,t)=>{To.init(e,t),A.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ol(e,t){return new al({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}let sl=w(`ZodPrefault`,(e,t)=>{Do.init(e,t),A.init(e,t),e.unwrap=()=>e._zod.def.innerType});function cl(e,t){return new sl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}let ll=w(`ZodNonOptional`,(e,t)=>{Oo.init(e,t),A.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ul(e,t){return new ll({type:`nonoptional`,innerType:e,...E(t)})}let dl=w(`ZodCatch`,(e,t)=>{Ao.init(e,t),A.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fl(e,t){return new dl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let pl=w(`ZodPipe`,(e,t)=>{jo.init(e,t),A.init(e,t),e.in=t.in,e.out=t.out});function ml(e,t){return new pl({type:`pipe`,in:e,out:t})}let hl=w(`ZodReadonly`,(e,t)=>{No.init(e,t),A.init(e,t)});function gl(e){return new hl({type:`readonly`,innerType:e})}let _l=w(`ZodLazy`,(e,t)=>{Fo.init(e,t),A.init(e,t),e.unwrap=()=>e._zod.def.getter()});function vl(e){return new _l({type:`lazy`,getter:e})}let yl=w(`ZodCustom`,(e,t)=>{Io.init(e,t),A.init(e,t)});function bl(e){let t=new la({check:`custom`});return t._zod.check=e,t}function xl(e,t){return Ws(yl,e??(()=>!0),t)}function Sl(e,t={}){return Gs(yl,e,t)}function Cl(e){let t=bl(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(_i(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(_i(r))}},e(n.value,n)));return t}function wl(e,t={error:`Input not instance of ${e.name}`}){let n=new yl({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 Tl;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Tl||={});let B=z.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),El=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 Dl=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()}};Dl.create=e=>{let t=new Dl(e);return t};let Ol=(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 kl=Ol;let Al=kl;function jl(){return Al}let Ml=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=jl(),r=Ml({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===kl?void 0:kl].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}}};let U=Object.freeze({status:`aborted`}),Pl=e=>({status:`dirty`,value:e}),Fl=e=>({status:`valid`,value:e}),Il=e=>e.status===`aborted`,Ll=e=>e.status===`dirty`,Rl=e=>e.status===`valid`,zl=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 Bl=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}};let Vl=(e,t)=>{if(Rl(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 Dl(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 El(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:El(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:El(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(zl(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:El(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Vl(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:El(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Rl(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=>Rl(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:El(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(zl(r)?r:Promise.resolve(r));return Vl(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 Wu({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 Gu.create(this,this._def)}nullable(){return Ku.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tu.create(this)}promise(){return Uu.create(this,this._def)}or(e){return Ou.create([this,e],this._def)}and(e){return Mu.create(this,e,this._def)}transform(e){return new Wu({...G(this._def),schema:this,typeName:q.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new qu({...G(this._def),innerType:this,defaultValue:t,typeName:q.ZodDefault})}brand(){return new Zu({typeName:q.ZodBranded,type:this,...G(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Ju({...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 Qu.create(this,e)}readonly(){return $u.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let Hl=/^c[^\s-]{8,}$/i,Ul=/^[0-9a-z]+$/,Wl=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Gl=/^[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,Kl=/^[a-z0-9_-]{21}$/i,ql=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Jl=/^[-+]?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)?)??$/,Yl=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xl=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Zl,Ql=/^(?:(?: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])$/,$l=/^(?:(?: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])$/,eu=/^(([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]))$/,tu=/^(([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])$/,nu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ru=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,iu=`((\\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])))`,au=RegExp(`^${iu}$`);function ou(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 su(e){return RegExp(`^${ou(e)}$`)}function cu(e){let t=`${iu}T${ou(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function lu(e,t){return!!((t===`v4`||!t)&&Ql.test(e)||(t===`v6`||!t)&&eu.test(e))}function uu(e,t){if(!ql.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 du(e,t){return!!((t===`v4`||!t)&&$l.test(e)||(t===`v6`||!t)&&tu.test(e))}var fu=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`)Yl.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`)Zl||=new RegExp(Xl,`u`),Zl.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`)Gl.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`)Kl.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`)Hl.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`)Ul.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`)Wl.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=cu(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=au;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=su(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`?Jl.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`duration`,code:V.invalid_string,message:t.message}),n.dirty()):t.kind===`ip`?lu(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`?uu(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`?du(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`?nu.test(e.data)||(r=this._getOrReturnCtx(e,r),H(r,{validation:`base64`,code:V.invalid_string,message:t.message}),n.dirty()):t.kind===`base64url`?ru.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}};fu.create=e=>new fu({checks:[],typeName:q.ZodString,coerce:e?.coerce??!1,...G(e)});function pu(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 mu=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`?pu(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)}};mu.create=e=>new mu({checks:[],typeName:q.ZodNumber,coerce:e?.coerce||!1,...G(e)});var hu=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}};hu.create=e=>new hu({checks:[],typeName:q.ZodBigInt,coerce:e?.coerce??!1,...G(e)});var gu=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 Fl(e.data)}};gu.create=e=>new gu({typeName:q.ZodBoolean,coerce:e?.coerce||!1,...G(e)});var _u=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)}};_u.create=e=>new _u({checks:[],coerce:e?.coerce||!1,typeName:q.ZodDate,...G(e)});var vu=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 Fl(e.data)}};vu.create=e=>new vu({typeName:q.ZodSymbol,...G(e)});var yu=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 Fl(e.data)}};yu.create=e=>new yu({typeName:q.ZodUndefined,...G(e)});var bu=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 Fl(e.data)}};bu.create=e=>new bu({typeName:q.ZodNull,...G(e)});var xu=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Fl(e.data)}};xu.create=e=>new xu({typeName:q.ZodAny,...G(e)});var Su=class extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fl(e.data)}};Su.create=e=>new Su({typeName:q.ZodUnknown,...G(e)});var Cu=class extends K{_parse(e){let t=this._getOrReturnCtx(e);return H(t,{code:V.invalid_type,expected:B.never,received:t.parsedType}),U}};Cu.create=e=>new Cu({typeName:q.ZodNever,...G(e)});var wu=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 Fl(e.data)}};wu.create=e=>new wu({typeName:q.ZodVoid,...G(e)});var Tu=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 Bl(t,e,t.path,n)))).then(e=>Nl.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Bl(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)}};Tu.create=(e,t)=>new Tu({type:e,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...G(t)});function Eu(e){if(e instanceof Du){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Gu.create(Eu(r))}return new Du({...e._def,shape:()=>t})}else if(e instanceof Tu)return new Tu({...e._def,type:Eu(e.element)});else if(e instanceof Gu)return Gu.create(Eu(e.unwrap()));else if(e instanceof Ku)return Ku.create(Eu(e.unwrap()));else if(e instanceof Nu)return Nu.create(e.items.map(e=>Eu(e)));else return e}var Du=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 Cu&&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 Bl(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof Cu){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 Bl(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 Eu(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 Gu;)r=r._def.innerType;n[e]=r}return new e({...this._def,shape:()=>n})}keyof(){return Bu(z.objectKeys(this.shape))}};Du.create=(e,t)=>new Du({shape:()=>e,unknownKeys:`strip`,catchall:Cu.create(),typeName:q.ZodObject,...G(t)}),Du.strictCreate=(e,t)=>new Du({shape:()=>e,unknownKeys:`strict`,catchall:Cu.create(),typeName:q.ZodObject,...G(t)}),Du.lazycreate=(e,t)=>new Du({shape:e,unknownKeys:`strip`,catchall:Cu.create(),typeName:q.ZodObject,...G(t)});var Ou=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 Dl(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 Dl(e));return H(t,{code:V.invalid_union,unionErrors:i}),U}}get options(){return this._def.options}};Ou.create=(e,t)=>new Ou({options:e,typeName:q.ZodUnion,...G(t)});let ku=e=>e instanceof Ru?ku(e.schema):e instanceof Wu?ku(e.innerType()):e instanceof zu?[e.value]:e instanceof Vu?e.options:e instanceof Hu?z.objectValues(e.enum):e instanceof qu?ku(e._def.innerType):e instanceof yu?[void 0]:e instanceof bu?[null]:e instanceof Gu?[void 0,...ku(e.unwrap())]:e instanceof Ku?[null,...ku(e.unwrap())]:e instanceof Zu||e instanceof $u?ku(e.unwrap()):e instanceof Ju?ku(e._def.innerType):[];var Au=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=ku(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 ju(e,t){let n=El(e),r=El(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=ju(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=ju(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 Mu=class extends K{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Il(e)||Il(r))return U;let i=ju(e.value,r.value);return i.valid?((Ll(e)||Ll(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}))}};Mu.create=(e,t,n)=>new Mu({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 Bl(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 Pu=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 Bl(n,e,n.path,e)),value:a._parse(new Bl(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:fu.create(),valueType:t,typeName:q.ZodRecord,...G(n)})}},Fu=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 Bl(n,e,n.path,[a,`key`])),value:i._parse(new Bl(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}}}};Fu.create=(e,t,n)=>new Fu({valueType:t,keyType:e,typeName:q.ZodMap,...G(n)});var Iu=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 Bl(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)}};Iu.create=(e,t)=>new Iu({valueType:e,minSize:null,maxSize:null,typeName:q.ZodSet,...G(t)});var Lu=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 Ml({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,jl(),kl].filter(e=>!!e),issueData:{code:V.invalid_arguments,argumentsError:n}})}function r(e,n){return Ml({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,jl(),kl].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 Uu){let e=this;return Fl(async function(...t){let o=new Dl([]),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 Fl(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Dl([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Dl([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(Su.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(Su.create()),returns:n||Su.create(),typeName:q.ZodFunction,...G(r)})}},Ru=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})}};Ru.create=(e,t)=>new Ru({getter:e,typeName:q.ZodLazy,...G(t)});var zu=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}};zu.create=(e,t)=>new zu({value:e,typeName:q.ZodLiteral,...G(t)});function Bu(e,t){return new Vu({values:e,typeName:q.ZodEnum,...G(t)})}var Vu=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 Fl(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})}};Vu.create=Bu;var Hu=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 Fl(e.data)}get enum(){return this._def.values}};Hu.create=(e,t)=>new Hu({values:e,typeName:q.ZodNativeEnum,...G(t)});var Uu=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 Fl(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Uu.create=(e,t)=>new Uu({type:e,typeName:q.ZodPromise,...G(t)});var Wu=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`?Pl(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`?Pl(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(!Rl(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=>Rl(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):U);z.assertNever(r)}};Wu.create=(e,t,n)=>new Wu({schema:e,typeName:q.ZodEffects,effect:t,...G(n)}),Wu.createWithPreprocess=(e,t,n)=>new Wu({schema:t,effect:{type:`preprocess`,transform:e},typeName:q.ZodEffects,...G(n)});var Gu=class extends K{_parse(e){let t=this._getType(e);return t===B.undefined?Fl(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Gu.create=(e,t)=>new Gu({innerType:e,typeName:q.ZodOptional,...G(t)});var Ku=class extends K{_parse(e){let t=this._getType(e);return t===B.null?Fl(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ku.create=(e,t)=>new Ku({innerType:e,typeName:q.ZodNullable,...G(t)});var qu=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}};qu.create=(e,t)=>new qu({innerType:e,typeName:q.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...G(t)});var Ju=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 zl(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Dl(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Dl(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ju.create=(e,t)=>new Ju({innerType:e,typeName:q.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...G(t)});var Yu=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}}};Yu.create=e=>new Yu({typeName:q.ZodNaN,...G(e)});let Xu=Symbol(`zod_brand`);var Zu=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}},Qu=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(),Pl(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})}},$u=class extends K{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Rl(e)&&(e.value=Object.freeze(e.value)),e);return zl(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};$u.create=(e,t)=>new $u({innerType:e,typeName:q.ZodReadonly,...G(t)});let ed={object:Du.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||={});let td=fu.create,nd=mu.create,rd=Yu.create,id=hu.create,ad=gu.create,od=_u.create,sd=vu.create,cd=yu.create,ld=bu.create,ud=xu.create,dd=Su.create,fd=Cu.create,pd=wu.create,md=Tu.create,hd=Du.create,gd=Du.strictCreate,_d=Ou.create,vd=Au.create,yd=Mu.create,bd=Nu.create,xd=Pu.create,Sd=Fu.create,Cd=Iu.create,wd=Lu.create,Td=Ru.create,Ed=zu.create,Dd=Vu.create,Od=Hu.create,kd=Uu.create,Ad=Wu.create,jd=Gu.create,Md=Ku.create,Nd=Wu.createWithPreprocess,Pd=Qu.create;var Fd=({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()}`},Id=Fd();function Ld(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 Rd(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function zd(e,...t){let n=new Headers(Rd(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var Bd=/"__proto__"\s*:/,Vd=/"constructor"\s*:/;function Hd(e){let t=JSON.parse(e);return typeof t!=`object`||!t||Bd.test(e)===!1&&Vd.test(e)===!1?t:Ud(t)}function Ud(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 Wd(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Hd(e)}try{return Hd(e)}finally{Error.stackTraceLimit=t}}var Gd=Symbol.for(`vercel.ai.validator`);function Kd(e){return{[Gd]:!0,validate:e}}function qd(e){return typeof e==`object`&&!!e&&Gd in e&&e[Gd]===!0&&`validate`in e}function Jd(e){let t;return()=>(t??=e(),t)}function Yd(e){return qd(e)?e:typeof e==`function`?e():Xd(e)}function Xd(e){return Kd(async t=>{let n=await e[`~standard`].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Or({value:t,cause:n.issues})}})}async function Zd({value:e,schema:t}){let n=await Qd({value:e,schema:t});if(!n.success)throw Or.wrap({value:e,cause:n.error});return n.value}async function Qd({value:e,schema:t}){let n=Yd(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:Or.wrap({value:e,cause:t.error}),rawValue:e}}catch(t){return{success:!1,error:Or.wrap({value:e,cause:t}),rawValue:e}}}async function $d({text:e,schema:t}){try{let n=Wd(e);return t==null?{success:!0,value:n,rawValue:n}:await Qd({value:n,schema:t})}catch(t){return{success:!1,error:nr.isInstance(t)?t:new nr({text:e,cause:t}),rawValue:void 0}}}function ef({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Lr).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await $d({text:e,schema:t}))}}))}async function tf(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}function nf(e){if(e.type===`object`){e.additionalProperties=!1;let t=e.properties;if(t!=null)for(let e in t)t[e]=nf(t[e])}return e.type===`array`&&e.items!=null&&(Array.isArray(e.items)?e.items=e.items.map(e=>nf(e)):e.items=nf(e.items)),e}var rf=(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(`/`)},af=Symbol(`Let zodToJsonSchema decide on which parser to use`),sf={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`},cf=e=>typeof e==`string`?{...sf,name:e}:{...sf,...e};function lf(){return{}}function uf(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 df(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 ff(){return{type:`boolean`}}function pf(e,t){return J(e.type._def,t)}var mf=(e,t)=>J(e.innerType._def,t);function hf(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>hf(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 gf(e)}}var gf=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 _f(e,t){return{...J(e.innerType._def,t),default:e.defaultValue()}}function vf(e,t){return t.effectStrategy===`input`?J(e.schema._def,t):lf()}function yf(e){return{type:`string`,enum:Array.from(e.values)}}var bf=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function xf(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(bf(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 Sf(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 Cf=void 0,wf={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:()=>(Cf===void 0&&(Cf=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),Cf),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 Tf(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`:kf(n,`email`,r.message,t);break;case`format:idn-email`:kf(n,`idn-email`,r.message,t);break;case`pattern:zod`:Af(n,wf.email,r.message,t);break}break;case`url`:kf(n,`uri`,r.message,t);break;case`uuid`:kf(n,`uuid`,r.message,t);break;case`regex`:Af(n,r.regex,r.message,t);break;case`cuid`:Af(n,wf.cuid,r.message,t);break;case`cuid2`:Af(n,wf.cuid2,r.message,t);break;case`startsWith`:Af(n,RegExp(`^${Ef(r.value,t)}`),r.message,t);break;case`endsWith`:Af(n,RegExp(`${Ef(r.value,t)}$`),r.message,t);break;case`datetime`:kf(n,`date-time`,r.message,t);break;case`date`:kf(n,`date`,r.message,t);break;case`time`:kf(n,`time`,r.message,t);break;case`duration`:kf(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`:Af(n,RegExp(Ef(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&kf(n,`ipv4`,r.message,t),r.version!==`v4`&&kf(n,`ipv6`,r.message,t);break;case`base64url`:Af(n,wf.base64url,r.message,t);break;case`jwt`:Af(n,wf.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&Af(n,wf.ipv4Cidr,r.message,t),r.version!==`v4`&&Af(n,wf.ipv6Cidr,r.message,t);break;case`emoji`:Af(n,wf.emoji(),r.message,t);break;case`ulid`:Af(n,wf.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:kf(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:Af(n,wf.base64,r.message,t);break}break;case`nanoid`:Af(n,wf.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:}return n}function Ef(e,t){return t.patternStrategy===`escape`?Of(e):e}var Df=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function Of(e){let t=``;for(let n=0;n<e.length;n++)Df.has(e[n])||(t+=`\\`),t+=e[n];return t}function kf(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 Af(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:jf(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=jf(t,r)}function jf(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
]))`;continue}else if(i[e]===`$`){a+=`($|(?=[\r
]))`;continue}}if(r.s&&i[e]===`.`){a+=s?`${i[e]}\r
`:`[${i[e]}\r
]`;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 Mf(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}=Tf(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}=pf(e.keyType._def,t);return{...c,propertyNames:r}}return c}function Nf(e,t){if(t.mapStrategy===`record`)return Mf(e,t);let n=J(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||lf(),r=J(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||lf();return{type:`array`,maxItems:125,items:{type:`array`,items:[n,r],minItems:2,maxItems:2}}}function Pf(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 Ff(){return{not:lf()}}function If(){return{type:`null`}}var Lf={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 Lf&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Lf[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 zf(e,t)}var zf=(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 Bf(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Lf[e.innerType._def.typeName],`null`]};let n=J(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Vf(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 Hf(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=Wf(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 Wf(e){try{return e.isOptional()}catch{return!0}}var Gf=(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:lf()},r]}:lf()},Kf=(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 qf(e,t){return J(e.type._def,t)}function Jf(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 Yf(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 Xf(){return{not:lf()}}function Zf(){return lf()}var Qf=(e,t)=>J(e.innerType._def,t),$f=(e,t,n)=>{switch(t){case q.ZodString:return Tf(e,n);case q.ZodNumber:return Vf(e);case q.ZodObject:return Hf(e,n);case q.ZodBigInt:return df(e);case q.ZodBoolean:return ff();case q.ZodDate:return hf(e,n);case q.ZodUndefined:return Xf();case q.ZodNull:return If();case q.ZodArray:return uf(e,n);case q.ZodUnion:case q.ZodDiscriminatedUnion:return Rf(e,n);case q.ZodIntersection:return xf(e,n);case q.ZodTuple:return Yf(e,n);case q.ZodRecord:return Mf(e,n);case q.ZodLiteral:return Sf(e);case q.ZodEnum:return yf(e);case q.ZodNativeEnum:return Pf(e);case q.ZodNullable:return Bf(e,n);case q.ZodOptional:return Gf(e,n);case q.ZodMap:return Nf(e,n);case q.ZodSet:return Jf(e,n);case q.ZodLazy:return()=>e.getter()._def;case q.ZodPromise:return qf(e,n);case q.ZodNaN:case q.ZodNever:return Ff();case q.ZodEffects:return vf(e,n);case q.ZodAny:return lf();case q.ZodUnknown:return Zf();case q.ZodDefault:return _f(e,n);case q.ZodBranded:return pf(e,n);case q.ZodReadonly:return Qf(e,n);case q.ZodCatch:return mf(e,n);case q.ZodPipeline:return Kf(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!==af)return a}if(i&&!n){let e=ep(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=$f(e,e.typeName,t),s=typeof o==`function`?J(o(),t):o;if(s&&tp(e,t,s),t.postProcess){let n=t.postProcess(s,e,t);return a.jsonSchema=s,n}return a.jsonSchema=s,s}var ep=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:rf(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`),lf()):t.$refStrategy===`seen`?lf():void 0}},tp=(e,t,n)=>(e.description&&(n.description=e.description),n),np=e=>{let t=cf(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}]))}},rp=(e,t)=>{var n;let r=np(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))??lf()}},{}):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))??lf(),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},ip=rp;function ap(e,t){var n;let r=(n=t?.useReferences)??!1;return up(()=>ip(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 op(e,t){var n;let r=(n=t?.useReferences)??!1;return up(()=>nf(qs(e,{target:`draft-7`,io:`input`,reused:r?`ref`:`inline`})),{validate:async t=>{let n=await cc(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function sp(e){return`_zod`in e}function cp(e,t){return sp(e)?op(e,t):ap(e,t)}var lp=Symbol.for(`vercel.ai.schema`);function up(e,{validate:t}={}){return{[lp]:!0,_type:void 0,[Gd]:!0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function dp(e){return typeof e==`object`&&!!e&&lp in e&&e[lp]===!0&&`jsonSchema`in e&&`validate`in e}function fp(e){return e==null?up({properties:{},additionalProperties:!1}):dp(e)?e:typeof e==`function`?e():cp(e)}var{btoa:pp,atob:mp}=globalThis,hp=Object.defineProperty,gp=(e,t)=>{for(var n in t)hp(e,n,{get:t[n],enumerable:!0})},_p=`AI_NoOutputSpecifiedError`,vp=`vercel.ai.error.${_p}`,yp=Symbol.for(vp),bp;bp=yp;var xp=`AI_InvalidArgumentError`,Sp=`vercel.ai.error.${xp}`,Cp=Symbol.for(Sp),wp;wp=Cp;var Tp=`AI_InvalidStreamPartError`,Ep=`vercel.ai.error.${Tp}`,Dp=Symbol.for(Ep),Op;Op=Dp;var kp=`AI_InvalidToolInputError`,Ap=`vercel.ai.error.${kp}`,jp=Symbol.for(Ap),Mp;Mp=jp;var Np=`AI_NoImageGeneratedError`,Pp=`vercel.ai.error.${Np}`,Fp=Symbol.for(Pp),Ip;Ip=Fp;var Lp=`AI_NoObjectGeneratedError`,Rp=`vercel.ai.error.${Lp}`,zp=Symbol.for(Rp),Bp,Vp=class extends kn{constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:Lp,message:e,cause:t}),this[Bp]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return kn.hasMarker(e,Rp)}};Bp=zp;var Hp=`AI_NoOutputGeneratedError`,Up=`vercel.ai.error.${Hp}`,Wp=Symbol.for(Up),Gp;Gp=Wp;var Kp=`AI_NoSuchToolError`,qp=`vercel.ai.error.${Kp}`,Jp=Symbol.for(qp),Yp;Yp=Jp;var Xp=`AI_ToolCallRepairError`,Zp=`vercel.ai.error.${Xp}`,Qp=Symbol.for(Zp),$p;$p=Qp;var em=`AI_InvalidDataContentError`,tm=`vercel.ai.error.${em}`,nm=Symbol.for(tm),rm;rm=nm;var im=`AI_InvalidMessageRoleError`,am=`vercel.ai.error.${im}`,om=Symbol.for(am),sm;sm=om;var cm=`AI_MessageConversionError`,lm=`vercel.ai.error.${cm}`,um=Symbol.for(lm),dm;dm=um;var fm=`AI_DownloadError`,pm=`vercel.ai.error.${fm}`,mm=Symbol.for(pm),hm;hm=mm;var gm=`AI_RetryError`,_m=`vercel.ai.error.${gm}`,vm=Symbol.for(_m),ym;ym=vm;var bm=`5.0.115`,xm=Uc([j(),wl(Uint8Array),wl(ArrayBuffer),xl(e=>{var t,n;return(n=(t=globalThis.Buffer)?.isBuffer(e))??!1},{message:`Must be a Buffer`})]),Sm=vl(()=>Uc([Ic(),j(),jc(),N(),Yc(j(),Sm),Bc(Sm)])),Y=Yc(j(),Yc(j(),Sm)),Cm=I({type:R(`text`),text:j(),providerOptions:Y.optional()}),wm=I({type:R(`image`),image:Uc([xm,wl(URL)]),mediaType:j().optional(),providerOptions:Y.optional()}),Tm=I({type:R(`file`),data:Uc([xm,wl(URL)]),filename:j().optional(),mediaType:j(),providerOptions:Y.optional()}),Em=I({type:R(`reasoning`),text:j(),providerOptions:Y.optional()}),Dm=I({type:R(`tool-call`),toolCallId:j(),toolName:j(),input:P(),providerOptions:Y.optional(),providerExecuted:N().optional()}),Om=Gc(`type`,[I({type:R(`text`),value:j()}),I({type:R(`json`),value:Sm}),I({type:R(`error-text`),value:j()}),I({type:R(`error-json`),value:Sm}),I({type:R(`content`),value:Bc(Uc([I({type:R(`text`),text:j()}),I({type:R(`media`),data:j(),mediaType:j()})]))})]),km=I({type:R(`tool-result`),toolCallId:j(),toolName:j(),output:Om,providerOptions:Y.optional()}),Am=I({role:R(`system`),content:j(),providerOptions:Y.optional()}),jm=I({role:R(`user`),content:Uc([j(),Bc(Uc([Cm,wm,Tm]))]),providerOptions:Y.optional()}),Mm=I({role:R(`assistant`),content:Uc([j(),Bc(Uc([Cm,Tm,Em,Dm,km]))]),providerOptions:Y.optional()}),Nm=I({role:R(`tool`),content:Bc(km),providerOptions:Y.optional()}),Pm=Uc([Am,jm,Mm,Nm]),Fm=Fd({prefix:`aitxt`,size:24}),Im=Jd(()=>cp(Uc([L({type:R(`text-start`),id:j(),providerMetadata:Y.optional()}),L({type:R(`text-delta`),id:j(),delta:j(),providerMetadata:Y.optional()}),L({type:R(`text-end`),id:j(),providerMetadata:Y.optional()}),L({type:R(`error`),errorText:j()}),L({type:R(`tool-input-start`),toolCallId:j(),toolName:j(),providerExecuted:N().optional(),dynamic:N().optional()}),L({type:R(`tool-input-delta`),toolCallId:j(),inputTextDelta:j()}),L({type:R(`tool-input-available`),toolCallId:j(),toolName:j(),input:P(),providerExecuted:N().optional(),providerMetadata:Y.optional(),dynamic:N().optional()}),L({type:R(`tool-input-error`),toolCallId:j(),toolName:j(),input:P(),providerExecuted:N().optional(),providerMetadata:Y.optional(),dynamic:N().optional(),errorText:j()}),L({type:R(`tool-output-available`),toolCallId:j(),output:P(),providerExecuted:N().optional(),dynamic:N().optional(),preliminary:N().optional()}),L({type:R(`tool-output-error`),toolCallId:j(),errorText:j(),providerExecuted:N().optional(),dynamic:N().optional()}),L({type:R(`reasoning-start`),id:j(),providerMetadata:Y.optional()}),L({type:R(`reasoning-delta`),id:j(),delta:j(),providerMetadata:Y.optional()}),L({type:R(`reasoning-end`),id:j(),providerMetadata:Y.optional()}),L({type:R(`source-url`),sourceId:j(),url:j(),title:j().optional(),providerMetadata:Y.optional()}),L({type:R(`source-document`),sourceId:j(),mediaType:j(),title:j(),filename:j().optional(),providerMetadata:Y.optional()}),L({type:R(`file`),url:j(),mediaType:j(),providerMetadata:Y.optional()}),L({type:xl(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:j().optional(),data:P(),transient:N().optional()}),L({type:R(`start-step`)}),L({type:R(`finish-step`)}),L({type:R(`start`),messageId:j().optional(),messageMetadata:P().optional()}),L({type:R(`finish`),finishReason:Zc([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`other`,`unknown`]).optional(),messageMetadata:P().optional()}),L({type:R(`abort`)}),L({type:R(`message-metadata`),messageMetadata:P()})])));function Lm(e){return e.type.startsWith(`data-`)}function Rm(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]=Rm(a,i):n[r]=i}return n}function zm(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 Bm(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await $d({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await $d({text:zm(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}function Vm(e){return e.type.startsWith(`tool-`)}function Hm(e){return e.type===`dynamic-tool`}function Um(e){return Vm(e)||Hm(e)}function Wm(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 Km({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(Vm),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=>Vm(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,n;let i=r.message.parts.find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),a=e,o=i;i==null?r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:a.input,output:a.output,errorText:a.errorText,preliminary:a.preliminary,providerExecuted:a.providerExecuted,...a.providerMetadata==null?{}:{callProviderMetadata:a.providerMetadata}}):(i.state=e.state,o.toolName=e.toolName,o.input=a.input,o.output=a.output,o.errorText=a.errorText,o.rawInput=(t=a.rawInput)??o.rawInput,o.preliminary=a.preliminary,o.providerExecuted=(n=a.providerExecuted)??i.providerExecuted,a.providerMetadata!=null&&i.state===`input-available`&&(i.callProviderMetadata=a.providerMetadata))}async function _(e){if(e!=null){let n=r.message.metadata==null?e:Rm(r.message.metadata,e);t!=null&&await Zd({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(Vm);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,providerExecuted:e.providerExecuted}):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 Bm(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,providerExecuted:e.providerExecuted,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,providerExecuted:e.providerExecuted,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:Wm(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,providerExecuted:e.providerExecuted})}else{let t=p(e.toolCallId);h({toolCallId:e.toolCallId,toolName:Wm(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted})}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`:e.finishReason!=null&&(r.finishReason=e.finishReason),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(Lm(e)){n?.[e.type]!=null&&await Zd({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 qm({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 Jm=Fd({prefix:`aitxt`,size:24}),Ym=Fd({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()})}},Zm=Fd({prefix:`aiobj`,size:24}),Qm={};gp(Qm,{object:()=>eh,text:()=>$m});var $m=()=>({type:`text`,responseFormat:{type:`text`},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),eh=({schema:e})=>{let t=fp(e);return{type:`object`,responseFormat:{type:`json`,schema:t.jsonSchema},async parsePartial({text:e}){let t=await Bm(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 $d({text:e});if(!r.success)throw new Vp({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 Qd({value:r.value,schema:t});if(!i.success)throw new Vp({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}}},th=`AI_NoSuchProviderError`,nh=`vercel.ai.error.${th}`,rh=Symbol.for(nh),ih;ih=rh;async function ah(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 oh=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 tf(this.body),c=await tf(this.headers),l=await tf(this.credentials),u={...Rd(c),...Rd(t.headers)},d=await(n=this.prepareSendMessagesRequest)?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...s,...t.body},headers:u,credentials:l,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),f=(r=d?.api)??this.api,p=d?.headers===void 0?u:Rd(d.headers),m=d?.body===void 0?{...s,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:d.body,h=(i=d?.credentials)??l,g=(a=this.fetch)??globalThis.fetch,_=await g(f,{method:`POST`,headers:zd({"Content-Type":`application/json`,...p},`ai-sdk/${bm}`,Ld()),body:JSON.stringify(m),credentials:h,signal:e});if(!_.ok)throw Error((o=await _.text())??`Failed to fetch the chat response.`);if(!_.body)throw Error(`The response body is empty.`);return this.processResponseStream(_.body)}async reconnectToStream(e){var t,n,r,i,a;let o=await tf(this.body),s=await tf(this.headers),c=await tf(this.credentials),l={...Rd(s),...Rd(e.headers)},u=await(t=this.prepareReconnectToStreamRequest)?.call(this,{api:this.api,id:e.chatId,body:{...o,...e.body},headers:l,credentials:c,requestMetadata:e.metadata}),d=(n=u?.api)??`${this.api}/${e.chatId}/stream`,f=u?.headers===void 0?l:Rd(u.headers),p=(r=u?.credentials)??c,m=(i=this.fetch)??globalThis.fetch,h=await m(d,{method:`GET`,headers:zd(f,`ai-sdk/${bm}`,Ld()),credentials:p});if(h.status===204)return null;if(!h.ok)throw Error((a=await h.text())??`Failed to fetch the chat response.`);if(!h.body)throw Error(`The response body is empty.`);return this.processResponseStream(h.body)}},sh=class extends oh{constructor(e={}){super(e)}processResponseStream(e){return ef({stream:e,schema:Im}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},ch=class{constructor({generateId:e=Id,id:t=e(),transport:n=new sh,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 ah(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.addToolOutput=async({state:e=`output-available`,tool:t,toolCallId:n,output:r,errorText:i})=>this.jobExecutor.run(async()=>{var t,a;let o=this.state.messages,s=o[o.length-1];this.state.replaceMessage(o.length-1,{...s,parts:s.parts.map(t=>Um(t)&&t.toolCallId===n?{...t,state:e,output:r,errorText:i}:t)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(t=>Um(t)&&t.toolCallId===n?{...t,state:e,output:r,errorText:i}:t)),this.status!==`streaming`&&this.status!==`submitted`&&(t=this.sendAutomaticallyWhen)?.call(this,{messages:this.state.messages})&&this.makeRequest({trigger:`submit-message`,messageId:(a=this.lastMessage)?.id})}),this.addToolResult=this.addToolOutput,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,c;this.setStatus({status:`submitted`,error:void 0});let l=this.lastMessage,u=!1,d=!1,f=!1;try{let a={state:Gm({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};a.abortController.signal.addEventListener(`abort`,()=>{u=!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 qm({stream:Km({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(u||e.name===`AbortError`)return u=!0,this.setStatus({status:`ready`}),null;f=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(d=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{(o=this.onFinish)==null||o.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:u,isDisconnect:d,isError:f,finishReason:(a=this.activeResponse)?.state.finishReason})}catch(e){console.error(e)}this.activeResponse=void 0}(s=this.sendAutomaticallyWhen)?.call(this,{messages:this.state.messages})&&!f&&await this.makeRequest({trigger:`submit-message`,messageId:(c=this.lastMessage)?.id,metadata:t,headers:n,body:r})}};function lh({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(Um).filter(e=>!e.providerExecuted);return r.length>0&&r.every(e=>e.state===`output-available`||e.state===`output-error`)}var uh=Jd(()=>cp(Bc(I({id:j(),role:Zc([`system`,`user`,`assistant`]),metadata:P().optional(),parts:Bc(Uc([I({type:R(`text`),text:j(),state:Zc([`streaming`,`done`]).optional(),providerMetadata:Y.optional()}),I({type:R(`reasoning`),text:j(),state:Zc([`streaming`,`done`]).optional(),providerMetadata:Y.optional()}),I({type:R(`source-url`),sourceId:j(),url:j(),title:j().optional(),providerMetadata:Y.optional()}),I({type:R(`source-document`),sourceId:j(),mediaType:j(),title:j(),filename:j().optional(),providerMetadata:Y.optional()}),I({type:R(`file`),mediaType:j(),filename:j().optional(),url:j(),providerMetadata:Y.optional()}),I({type:R(`step-start`)}),I({type:j().startsWith(`data-`),id:j().optional(),data:P()}),I({type:R(`dynamic-tool`),toolName:j(),toolCallId:j(),state:R(`input-streaming`),input:P().optional(),providerExecuted:N().optional(),output:F().optional(),errorText:F().optional()}),I({type:R(`dynamic-tool`),toolName:j(),toolCallId:j(),state:R(`input-available`),input:P(),providerExecuted:N().optional(),output:F().optional(),errorText:F().optional(),callProviderMetadata:Y.optional()}),I({type:R(`dynamic-tool`),toolName:j(),toolCallId:j(),state:R(`output-available`),input:P(),providerExecuted:N().optional(),output:P(),errorText:F().optional(),callProviderMetadata:Y.optional(),preliminary:N().optional()}),I({type:R(`dynamic-tool`),toolName:j(),toolCallId:j(),state:R(`output-error`),input:P(),providerExecuted:N().optional(),output:F().optional(),errorText:j(),callProviderMetadata:Y.optional()}),I({type:j().startsWith(`tool-`),toolCallId:j(),state:R(`input-streaming`),providerExecuted:N().optional(),input:P().optional(),output:F().optional(),errorText:F().optional(),approval:F().optional()}),I({type:j().startsWith(`tool-`),toolCallId:j(),state:R(`input-available`),providerExecuted:N().optional(),input:P(),output:F().optional(),errorText:F().optional(),callProviderMetadata:Y.optional(),approval:F().optional()}),I({type:j().startsWith(`tool-`),toolCallId:j(),state:R(`approval-requested`),input:P(),providerExecuted:N().optional(),output:F().optional(),errorText:F().optional(),callProviderMetadata:Y.optional(),approval:I({id:j(),approved:F().optional(),reason:F().optional()})}),I({type:j().startsWith(`tool-`),toolCallId:j(),state:R(`approval-responded`),input:P(),providerExecuted:N().optional(),output:F().optional(),errorText:F().optional(),callProviderMetadata:Y.optional(),approval:I({id:j(),approved:N(),reason:j().optional()})}),I({type:j().startsWith(`tool-`),toolCallId:j(),state:R(`output-available`),providerExecuted:N().optional(),input:P(),output:P(),errorText:F().optional(),callProviderMetadata:Y.optional(),preliminary:N().optional(),approval:I({id:j(),approved:R(!0),reason:j().optional()}).optional()}),I({type:j().startsWith(`tool-`),toolCallId:j(),state:R(`output-error`),providerExecuted:N().optional(),input:P(),output:F().optional(),errorText:j(),callProviderMetadata:Y.optional(),approval:I({id:j(),approved:R(!0),reason:j().optional()}).optional()}),I({type:j().startsWith(`tool-`),toolCallId:j(),state:R(`output-denied`),providerExecuted:N().optional(),input:P(),output:F().optional(),errorText:F().optional(),callProviderMetadata:Y.optional(),approval:I({id:j(),approved:R(!1),reason:j().optional()})})])).nonempty(`Message must contain at least one part`)})).nonempty(`Messages array must not be empty`))),dh=c((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});wn();var fh=u(dh(),1),ph=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},X=(e,t,n)=>(ph(e,t,`read from private field`),n?n.call(e):t.get(e)),mh=(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)},hh=(e,t,n,r)=>(ph(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n);function gh(e,t){return t==null?e:(0,fh.default)(e,t)}var _h,vh,yh,bh,xh,Sh,Ch,wh,Th,Eh=class{constructor(e=[]){mh(this,_h,void 0),mh(this,vh,`ready`),mh(this,yh,void 0),mh(this,bh,new Set),mh(this,xh,new Set),mh(this,Sh,new Set),this.pushMessage=e=>{hh(this,_h,X(this,_h).concat(e)),X(this,Ch).call(this)},this.popMessage=()=>{hh(this,_h,X(this,_h).slice(0,-1)),X(this,Ch).call(this)},this.replaceMessage=(e,t)=>{hh(this,_h,[...X(this,_h).slice(0,e),this.snapshot(t),...X(this,_h).slice(e+1)]),X(this,Ch).call(this)},this.snapshot=e=>structuredClone(e),this[`~registerMessagesCallback`]=(e,t)=>{let n=t?gh(e,t):e;return X(this,bh).add(n),()=>{X(this,bh).delete(n)}},this[`~registerStatusCallback`]=e=>(X(this,xh).add(e),()=>{X(this,xh).delete(e)}),this[`~registerErrorCallback`]=e=>(X(this,Sh).add(e),()=>{X(this,Sh).delete(e)}),mh(this,Ch,()=>{X(this,bh).forEach(e=>e())}),mh(this,wh,()=>{X(this,xh).forEach(e=>e())}),mh(this,Th,()=>{X(this,Sh).forEach(e=>e())}),hh(this,_h,e)}get status(){return X(this,vh)}set status(e){hh(this,vh,e),X(this,wh).call(this)}get error(){return X(this,yh)}set error(e){hh(this,yh,e),X(this,Th).call(this)}get messages(){return X(this,_h)}set messages(e){hh(this,_h,[...e]),X(this,Ch).call(this)}};_h=new WeakMap,vh=new WeakMap,yh=new WeakMap,bh=new WeakMap,xh=new WeakMap,Sh=new WeakMap,Ch=new WeakMap,wh=new WeakMap,Th=new WeakMap;var Dh,Oh=class extends ch{constructor({messages:e,...t}){let n=new Eh(e);super({...t,state:n}),mh(this,Dh,void 0),this[`~registerMessagesCallback`]=(e,t)=>X(this,Dh)[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>X(this,Dh)[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>X(this,Dh)[`~registerErrorCallback`](e),hh(this,Dh,n)}};Dh=new WeakMap;function kh({experimental_throttle:e,resume:t=!1,...n}={}){let r=yt(`chat`in n?n.chat:new Oh(n)),i=`chat`in n&&n.chat!==r.current||`id`in n&&r.current.id!==n.id;i&&(r.current=`chat`in n?n.chat:new Oh(n));let a=xt(t=>r.current[`~registerMessagesCallback`](t,e),[e,r.current.id]),o=Ut(a,()=>r.current.messages,()=>r.current.messages),s=Ut(r.current[`~registerStatusCallback`],()=>r.current.status,()=>r.current.status),c=Ut(r.current[`~registerErrorCallback`],()=>r.current.error,()=>r.current.error),l=xt(e=>{typeof e==`function`&&(e=e(r.current.messages)),r.current.messages=e},[r]);return _t(()=>{t&&r.current.resumeStream()},[t,r]),{id:r.current.id,messages:o,setMessages:l,sendMessage:r.current.sendMessage,regenerate:r.current.regenerate,clearError:r.current.clearError,stop:r.current.stop,error:c,resumeStream:r.current.resumeStream,status:s,addToolResult:r.current.addToolOutput,addToolOutput:r.current.addToolOutput}}Ne();var Ah=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,jh=0,Mh=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:--jh,__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}let Nh=new Set([`AI-203`,`AI-205`,`AI-224`,`AI-225`]),Ph=`Could not complete response due to token output limits`;function Fh(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 Ih(e,t){for(let[n,r]of Object.entries(e))if(n.toLowerCase()===t.toLowerCase()&&typeof r==`string`&&r.trim()!==``)return r.trim()}function Lh(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 Rh(e){return e?e.toUpperCase().includes(`AI-217`)?!0:/conversation\s+depth/i.test(e):!1}function zh(e){if(Rh(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 Rh(r)}catch{return!1}}function Bh(e){return zh(Fh(e))}function Vh(e){return/\brequest blocked for this domain\b/.test(e)||/\bblocked for this domain\b/.test(e)}function Hh(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 Uh(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 Wh(e){return/\bTokenOutputLimitError\b/i.test(e)}function Gh(e){return/\bwhitelist(ed)?\b/.test(e)||/\bnot\s+allowed\s+for\s+this\s+domain\b/.test(e)}function Kh(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 qh(e){let t=Ih(e,`message`)??``;return Vh(t.toLowerCase())}function Jh(e){let t=typeof e.type==`string`?e.type:``;if(/tokenoutput|outputlimit|steplimit|maxstep|ratelimit|domainnotallowed/i.test(t))return!0;let n=Ih(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=Ih(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 Yh(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:Lh(t)}}let Xh=[{matches:e=>typeof e.extractedCodeUpper==`string`&&Nh.has(e.extractedCodeUpper)},{matches:e=>e.parsedJson!==null&&qh(e.parsedJson),showNewConversationLink:!1},{matches:e=>e.parsedJson!==null&&Jh(e.parsedJson)},{matches:e=>Wh(e.message),showNewConversationLink:!1},{matches:e=>Uh(e.messageLower)},{matches:e=>Vh(e.messageLower),showNewConversationLink:!1},{matches:e=>Gh(e.messageLower)},{matches:e=>Kh(e.messageLower)},{matches:e=>Hh(e.messageLower)}];function Zh(e){let t=Yh(e),n=Xh.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 Qh(e){return Zh(e).blocking}function $h(e,t=!1){return e==null?!1:Bh(e)?!0:t?Qh(Fh(e)):!1}function eg(e){let t=Fh(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 tg(e,t=!1){return e==null?!0:eg(e)?!1:Bh(e)||!t?!0:Zh(Fh(e)).showNewConversationLink}function ng(e){return e.replace(/\s*\(AI-\d{3}\)\s*$/i,``).trim()}function rg(e){let t=e.trim();return t.startsWith(`{`)&&t.endsWith(`}`)}function ig(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=Ih(t,`message`);if(n)return n;let r=Ih(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 ag(e){if(e==null)return!1;let t=Fh(e),n=t.toLowerCase();if(Vh(n))return!0;let r=ig(t.trim());if(r&&Vh(r.toLowerCase()))return!0;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e)&&qh(e))return!0}catch{}return!1}function og(e){if(e==null)return;let t=Fh(e),n=ig(t);if(n)return n;let r=ng(t.trim());return r===``?void 0:r}function sg(e,t=!1){if($h(e,t)){if(eg(e)){let t=og(e);return t&&!rg(t)?t:Ph}return og(e)}}function cg(e,t){if(!t||!$h(e,t))return!1;let n=Fh(e).toLowerCase();if(Hh(n)||eg(e))return!0;let r=sg(e,t);return r&&/could not complete response due to token output limits/i.test(r)||r&&Hh(r.toLowerCase())?!0:!tg(e,t)}let lg=({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]});wn();let ug=`https://askai.algolia.com`,dg=e=>`https://${e}.algolia.net/agent-studio/1`;function fg(e){return e.agentStudio?`${dg(e.applicationId)}/agents/${e.assistantId}/completions?stream=true&compatibilityMode=ai-sdk-5`:`${ug}/chat`}function pg(e){if(!e)throw Error(`config is required for useAskai`);let[t,n]=ht(()=>Id()),r=bt(()=>new sh({api:fg(e),headers:async()=>{if(e.agentStudio)return{"x-algolia-api-key":e.apiKey,"x-algolia-application-id":e.applicationId};let t=await vg({assistantId:e.assistantId});return{"x-algolia-api-key":e.apiKey,"x-algolia-application-id":e.applicationId,"x-algolia-index-name":e.indexName,"x-algolia-assistant-id":e.assistantId,"x-ai-sdk-version":`v5`,authorization:`TOKEN ${t}`}}}),[e.apiKey,e.applicationId,e.indexName,e.assistantId,e.agentStudio,e]),i=kh({id:t,transport:r,sendAutomaticallyWhen:lh}),a=yt(i);a.current=i;let o=xt(()=>{a.current.stop(),a.current.clearError(),n(Id())},[]),s=i.status===`submitted`||i.status===`streaming`,c=!!e.agentStudio,l=bt(()=>i.status===`error`&&$h(i.error,c),[i.status,i.error,c]),u=bt(()=>l&&(Bh(i.error)?i.messages.some(e=>e.role===`assistant`):!0),[l,i.error,i.messages]);return{...i,startNewConversation:o,isGenerating:s,promptBlockingError:l,showPromptBlockingError:u}}let mg=`askai_token`,hg=e=>{let[t]=e.split(`.`);return JSON.parse(atob(t))},gg=e=>{if(!e)return!0;try{let{exp:t}=hg(e);return Date.now()/1e3>t-30}catch{return!0}},_g=null,vg=async({assistantId:e})=>{let t=sessionStorage.getItem(mg);return gg(t)?(_g||=fetch(`${ug}/chat/token`,{method:`POST`,headers:{"x-algolia-assistant-id":e,"content-type":`application/json`}}).then(e=>e.json()).then(({token:e})=>(sessionStorage.setItem(mg,e),e)).finally(()=>{_g=null}),_g):t},yg=({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=`${dg(r)}/feedback`;return fetch(o,{method:`POST`,body:JSON.stringify({messageId:n,agentId:e,vote:t}),headers:a})},bg=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 vg({assistantId:e});return i.set(`authorization`,`TOKEN ${a}`),fetch(`${ug}/chat/feedback`,{method:`POST`,body:JSON.stringify({appId:r,messageId:n,thumbs:t}),headers:i})},xg=({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`})]}),Sg=({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`})]}),Cg=({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`})]}),wg=({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`})]})]})]})},Tg=({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`})]}),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:`M18 6 6 18`}),Z(`path`,{d:`m6 6 12 12`})]}),Dg=({size:e=150})=>Z(`svg`,{width:`80`,height:`24`,"aria-label":`Algolia`,role:`img`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 2196.2 500`,style:{maxWidth:e},children:[Z(`defs`,{children:Z(`style`,{children:`.cls-1,.cls-2{fill:#003dff}.cls-2{fillRule:evenodd}`})}),Z(`path`,{className:`cls-2`,d:`M1070.38,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z`}),Z(`rect`,{className:`cls-1`,x:`1845.88`,y:`104.73`,width:`62.58`,height:`277.9`,rx:`5.9`,ry:`5.9`}),Z(`path`,{className:`cls-2`,d:`M1851.78,71.38h50.77c3.26,0,5.9-2.64,5.9-5.9V5.9c0-3.62-3.24-6.39-6.82-5.83l-50.77,7.95c-2.87,.45-4.99,2.92-4.99,5.83v51.62c0,3.26,2.64,5.9,5.9,5.9Z`}),Z(`path`,{className:`cls-2`,d:`M1764.03,275.3V5.91c0-3.63-3.24-6.39-6.82-5.83l-50.46,7.94c-2.87,.45-4.99,2.93-4.99,5.84l.17,273.22c0,12.92,0,92.7,95.97,95.49,3.33,.1,6.09-2.58,6.09-5.91v-40.78c0-2.96-2.19-5.51-5.12-5.84-34.85-4.01-34.85-47.57-34.85-54.72Z`}),Z(`path`,{className:`cls-2`,d:`M1631.95,142.72c-11.14-12.25-24.83-21.65-40.78-28.31-15.92-6.53-33.26-9.85-52.07-9.85-18.78,0-36.15,3.17-51.92,9.85-15.59,6.66-29.29,16.05-40.76,28.31-11.47,12.23-20.38,26.87-26.76,44.03-6.38,17.17-9.24,37.37-9.24,58.36,0,20.99,3.19,36.87,9.55,54.21,6.38,17.32,15.14,32.11,26.45,44.36,11.29,12.23,24.83,21.62,40.6,28.46,15.77,6.83,40.12,10.33,52.4,10.48,12.25,0,36.78-3.82,52.7-10.48,15.92-6.68,29.46-16.23,40.78-28.46,11.29-12.25,20.05-27.04,26.25-44.36,6.22-17.34,9.24-33.22,9.24-54.21,0-20.99-3.34-41.19-10.03-58.36-6.38-17.17-15.14-31.8-26.43-44.03Zm-44.43,163.75c-11.47,15.75-27.56,23.7-48.09,23.7-20.55,0-36.63-7.8-48.1-23.7-11.47-15.75-17.21-34.01-17.21-61.2,0-26.89,5.59-49.14,17.06-64.87,11.45-15.75,27.54-23.52,48.07-23.52,20.55,0,36.63,7.78,48.09,23.52,11.47,15.57,17.36,37.98,17.36,64.87,0,27.19-5.72,45.3-17.19,61.2Z`}),Z(`path`,{className:`cls-2`,d:`M894.42,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z`}),Z(`path`,{className:`cls-2`,d:`M2133.97,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-14.52,22.58-22.99,49.63-22.99,78.73,0,44.89,20.13,84.92,51.59,111.1,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47,1.23,0,2.46-.03,3.68-.09,.36-.02,.71-.05,1.07-.07,.87-.05,1.75-.11,2.62-.2,.34-.03,.68-.08,1.02-.12,.91-.1,1.82-.21,2.73-.34,.21-.03,.42-.07,.63-.1,32.89-5.07,61.56-30.82,70.9-62.81v57.83c0,3.26,2.64,5.9,5.9,5.9h50.42c3.26,0,5.9-2.64,5.9-5.9V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,206.92c-12.2,10.16-27.97,13.98-44.84,15.12-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-42.24,0-77.12-35.89-77.12-79.37,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33v142.83Z`}),Z(`path`,{className:`cls-2`,d:`M1314.05,104.73h-49.33c-48.36,0-90.91,25.48-115.75,64.1-11.79,18.34-19.6,39.64-22.11,62.59-.58,5.3-.88,10.68-.88,16.14s.31,11.15,.93,16.59c4.28,38.09,23.14,71.61,50.66,94.52,2.93,2.6,6.05,4.98,9.31,7.14,12.86,8.49,28.11,13.47,44.52,13.47h0c17.99,0,34.61-5.93,48.16-15.97,16.29-11.58,28.88-28.54,34.48-47.75v50.26h-.11v11.08c0,21.84-5.71,38.27-17.34,49.36-11.61,11.08-31.04,16.63-58.25,16.63-11.12,0-28.79-.59-46.6-2.41-2.83-.29-5.46,1.5-6.27,4.22l-12.78,43.11c-1.02,3.46,1.27,7.02,4.83,7.53,21.52,3.08,42.52,4.68,54.65,4.68,48.91,0,85.16-10.75,108.89-32.21,21.48-19.41,33.15-48.89,35.2-88.52V110.63c0-3.26-2.64-5.9-5.9-5.9h-56.32Zm0,64.1s.65,139.13,0,143.36c-12.08,9.77-27.11,13.59-43.49,14.7-.16,.01-.33,.03-.49,.04-1.12,.07-2.24,.1-3.36,.1-1.32,0-2.63-.03-3.94-.1-40.41-2.11-74.52-37.26-74.52-79.38,0-10.25,1.96-20.01,5.42-28.98,11.22-29.12,38.77-49.74,71.06-49.74h49.33Z`}),Z(`path`,{className:`cls-1`,d:`M249.83,0C113.3,0,2,110.09,.03,246.16c-2,138.19,110.12,252.7,248.33,253.5,42.68,.25,83.79-10.19,120.3-30.03,3.56-1.93,4.11-6.83,1.08-9.51l-23.38-20.72c-4.75-4.21-11.51-5.4-17.36-2.92-25.48,10.84-53.17,16.38-81.71,16.03-111.68-1.37-201.91-94.29-200.13-205.96,1.76-110.26,92-199.41,202.67-199.41h202.69V407.41l-115-102.18c-3.72-3.31-9.42-2.66-12.42,1.31-18.46,24.44-48.53,39.64-81.93,37.34-46.33-3.2-83.87-40.5-87.34-86.81-4.15-55.24,39.63-101.52,94-101.52,49.18,0,89.68,37.85,93.91,85.95,.38,4.28,2.31,8.27,5.52,11.12l29.95,26.55c3.4,3.01,8.79,1.17,9.63-3.3,2.16-11.55,2.92-23.58,2.07-35.92-4.82-70.34-61.8-126.93-132.17-131.26-80.68-4.97-148.13,58.14-150.27,137.25-2.09,77.1,61.08,143.56,138.19,145.26,32.19,.71,62.03-9.41,86.14-26.95l150.26,133.2c6.44,5.71,16.61,1.14,16.61-7.47V9.48C499.66,4.25,495.42,0,490.18,0H249.83Z`})]}),Og=({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`})}),kg=({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`})}),Ag=({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`})]}),jg=({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 Mg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ng=Mg();function Pg(e){Ng=e}var Fg={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(Ig.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ig={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`)},Lg=/^(?:[ \t]*(?:\n|$))+/,Rg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bg=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Vg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hg=/(?:[*+-]|\d{1,9}[.)])/,Ug=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wg=Q(Ug).replace(/bull/g,Hg).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(),Gg=Q(Ug).replace(/bull/g,Hg).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(),Kg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,qg=/^[^\n]+/,Jg=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yg=Q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Jg).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Xg=Q(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Hg).getRegex(),Zg=`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`,Qg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$g=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`,Qg).replace(`tag`,Zg).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),e_=Q(Kg).replace(`hr`,Bg).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`,Zg).getRegex(),t_=Q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,e_).getRegex(),n_={blockquote:t_,code:Rg,def:Yg,fences:zg,heading:Vg,hr:Bg,html:$g,lheading:Wg,list:Xg,newline:Lg,paragraph:e_,table:Fg,text:qg},r_=Q(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Bg).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`,Zg).getRegex(),i_={...n_,lheading:Gg,table:r_,paragraph:Q(Kg).replace(`hr`,Bg).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,r_).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`,Zg).getRegex()},a_={...n_,html:Q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Qg).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:Fg,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Q(Kg).replace(`hr`,Bg).replace(`heading`,` *#{1,6} *[^
]`).replace(`lheading`,Wg).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},o_=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,s_=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,c_=/^( {2,}|\\)\n(?!\s*$)/,l_=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,u_=/[\p{P}\p{S}]/u,d_=/[\s\p{P}\p{S}]/u,f_=/[^\s\p{P}\p{S}]/u,p_=Q(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,d_).getRegex(),m_=/(?!~)[\p{P}\p{S}]/u,h_=/(?!~)[\s\p{P}\p{S}]/u,g_=/(?:[^\s\p{P}\p{S}]|~)/u,__=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,v_=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,y_=Q(v_,`u`).replace(/punct/g,u_).getRegex(),b_=Q(v_,`u`).replace(/punct/g,m_).getRegex(),x_=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,S_=Q(x_,`gu`).replace(/notPunctSpace/g,f_).replace(/punctSpace/g,d_).replace(/punct/g,u_).getRegex(),C_=Q(x_,`gu`).replace(/notPunctSpace/g,g_).replace(/punctSpace/g,h_).replace(/punct/g,m_).getRegex(),w_=Q(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,f_).replace(/punctSpace/g,d_).replace(/punct/g,u_).getRegex(),T_=Q(/\\(punct)/,`gu`).replace(/punct/g,u_).getRegex(),E_=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(),D_=Q(Qg).replace(`(?:-->|$)`,`-->`).getRegex(),O_=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`,D_).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),k_=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,A_=Q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,k_).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),j_=Q(/^!?\[(label)\]\[(ref)\]/).replace(`label`,k_).replace(`ref`,Jg).getRegex(),M_=Q(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Jg).getRegex(),N_=Q(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,j_).replace(`nolink`,M_).getRegex(),P_=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,F_={_backpedal:Fg,anyPunctuation:T_,autolink:E_,blockSkip:__,br:c_,code:s_,del:Fg,emStrongLDelim:y_,emStrongRDelimAst:S_,emStrongRDelimUnd:w_,escape:o_,link:A_,nolink:M_,punctuation:p_,reflink:j_,reflinkSearch:N_,tag:O_,text:l_,url:Fg},I_={...F_,link:Q(/^!?\[(label)\]\((.*?)\)/).replace(`label`,k_).getRegex(),reflink:Q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,k_).getRegex()},L_={...F_,emStrongRDelimAst:C_,emStrongLDelim:b_,url:Q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,P_).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`,P_).getRegex()},R_={...L_,br:Q(c_).replace(`{2,}`,`*`).getRegex(),text:Q(L_.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},z_={normal:n_,gfm:i_,pedantic:a_},B_={normal:F_,gfm:L_,breaks:R_,pedantic:I_},V_={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},H_=e=>V_[e];function U_(e,t){if(t){if(Ig.escapeTest.test(e))return e.replace(Ig.escapeReplace,H_)}else if(Ig.escapeTestNoEncode.test(e))return e.replace(Ig.escapeReplaceNoEncode,H_);return e}function W_(e){try{e=encodeURI(e).replace(Ig.percentDecode,`%`)}catch{return null}return e}function G_(e,t){let n=e.replace(Ig.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}),r=n.split(Ig.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(Ig.slashPipe,`|`);return r}function K_(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 q_(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 J_(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 Y_(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
`).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(`
`)}var X_=class{options;rules;lexer;constructor(e){this.options=e||Ng}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:K_(e,`
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Y_(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=K_(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:K_(t[0],`
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=K_(t[0],`
`).split(`
`),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(`
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
${s}`:s,r=r?`${r}
${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+`
`+e.join(`
`),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+`
`+e.join(`
`),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(`
`);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(`
`,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(`
`,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+`
`,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(`
`,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+=`
`+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+=`
`+l}!u&&!l.trim()&&(u=!0),r+=f+`
`,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=G_(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
`):[],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(G_(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)===`
`?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=K_(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=q_(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)),J_(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 J_(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}}}},Z_=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ng,this.options.tokenizer=this.options.tokenizer||new X_,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:Ig,block:z_.normal,inline:B_.normal};this.options.pedantic?(t.block=z_.pedantic,t.inline=B_.pedantic):this.options.gfm&&(t.block=z_.gfm,this.options.breaks?t.inline=B_.breaks:t.inline=B_.gfm),this.tokenizer.rules=t}static get rules(){return{block:z_,inline:B_}}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(Ig.carriageReturn,`
`),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(Ig.tabCharGlobal,` `).replace(Ig.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+=`
`: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(`
`)?``:`
`)+r.raw,n.text+=`
`+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(`
`)?``:`
`)+r.raw,n.text+=`
`+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(`
`)?``:`
`)+r.raw,a.text+=`
`+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(`
`)?``:`
`)+r.raw,n.text+=`
`+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}},Q_=class{options;parser;constructor(e){this.options=e||Ng}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Ig.notSpaceStart)?.[0],i=e.replace(Ig.endingNewline,``)+`
`;return r?`<pre><code class="language-`+U_(r)+`">`+(n?i:U_(i,!0))+`</code></pre>
`:`<pre><code>`+(n?i:U_(i,!0))+`</code></pre>
`}blockquote({tokens:e}){return`<blockquote>
${this.parser.parse(e)}</blockquote>
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
`}hr(e){return`<hr>
`}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+`>
`+r+`</`+i+`>
`}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+` `+U_(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>
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
`}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>
<thead>
`+t+`</thead>
`+r+`</table>
`}tablerow({text:e}){return`<tr>
${e}</tr>
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
`}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>${U_(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=W_(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+U_(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=W_(e);if(i===null)return U_(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${U_(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:U_(e.text)}},$_=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``}},ev=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ng,this.options.renderer=this.options.renderer||new Q_,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $_}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+=`
`+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}},tv=class{options;block;constructor(e){this.options=e||Ng}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?Z_.lex:Z_.lexInline}provideParser(){return this.block?ev.parse:ev.parseInline}},nv=class{defaults=Mg();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ev;Renderer=Q_;TextRenderer=$_;Lexer=Z_;Tokenizer=X_;Hooks=tv;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 Q_(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 X_(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 tv;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];tv.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&tv.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 Z_.lex(e,t??this.defaults)}parser(e,t){return ev.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?Z_.lex:Z_.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?ev.parse:ev.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?Z_.lex:Z_.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?ev.parse:ev.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+=`
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+U_(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},rv=new nv;function $(e,t){return rv.parse(e,t)}$.options=$.setOptions=function(e){return rv.setOptions(e),$.defaults=rv.defaults,Pg($.defaults),$},$.getDefaults=Mg,$.defaults=Ng,$.use=function(...e){return rv.use(...e),$.defaults=rv.defaults,Pg($.defaults),$},$.walkTokens=function(e,t){return rv.walkTokens(e,t)},$.parseInline=rv.parseInline,$.Parser=ev,$.parser=ev.parse,$.Renderer=Q_,$.TextRenderer=$_,$.Lexer=Z_,$.lexer=Z_.lex,$.Tokenizer=X_,$.Hooks=tv,$.parse=$;var iv=$.options,av=$.setOptions,ov=$.use,sv=$.walkTokens,cv=$.parseInline,lv=$,uv=ev.parse,dv=Z_.lex;function fv(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function pv(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 mv(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 hv(e){if(!e)return``;let t=e.trim();if(!t)return``;let n=mv(pv(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 gv(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,`�`)}function _v(e){return typeof e==`string`?gv(e):``}function vv(e){let t=gv(e);try{return encodeURIComponent(t)}catch{return``}}let yv=new $.Renderer;yv.code=({text:e,lang:t=``,escaped:n})=>{let r=/^[a-zA-Z0-9_-]+$/.test(t)?t:``,i=r?`language-${r}`:``,a=n?e:fv(e),o=vv(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(``)},yv.link=({href:e,title:t,text:n})=>{let r=fv(hv(e)),i=fv(n);if(!r)return i;let a=t?` title="`+fv(t)+`"`:``;return`<a href="`+r+`" target="_blank" rel="noopener noreferrer"`+a+`>`+i+`</a>`},yv.image=({href:e,title:t,text:n})=>{let r=fv(hv(e));if(!r)return fv(n);let i=t?` title="`+fv(t)+`"`:``;return`<img src="`+r+`" alt="`+fv(n)+`"`+i+` />`},yv.html=({text:e})=>fv(e);function bv(e){let t=_v(e);try{return $.parse(t,{gfm:!0,breaks:!0,renderer:yv})}catch(e){return console.error(`Error parsing markdown:`,e),fv(t)}}wn();let xv=Kt(function({children:e,className:t=``}){let n=yt(null),r=bt(()=>bv(e),[e]);return _t(()=>{let e=n.current;if(!e)return;let t=async e=>{let t=e.target,n=t.closest(`.ss-markdown-copy-button`);if(!n)return;e.preventDefault(),e.stopPropagation();let r=n.getAttribute(`data-code`);if(r)try{let e=decodeURIComponent(r);await navigator.clipboard.writeText(e),n.classList.add(`ss-markdown-copied`),setTimeout(()=>{n.classList.remove(`ss-markdown-copied`)},2e3)}catch(e){console.error(`Failed to copy code:`,e)}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[r]),Z(`div`,{ref:n,className:`ss-markdown-content ${t}`.trim(),dangerouslySetInnerHTML:{__html:r}})});wn();function Sv(){let e=xt(async e=>{try{await navigator.clipboard.writeText(e)}catch{}},[]);return{copyText:e}}let Cv=Kt(function({messages:e,error:t,isGenerating:n,onCopy:r,onThumbsUp:i,onThumbsDown:a,applicationId:o,apiKey:s,assistantId:c,agentStudio:l,suggestedQuestions:u,onSuggestedQuestionClick:d,onNewChat:f,showPromptBlockingError:p=!1,threadDepthBannerInChat:m=!0,showAiDisclaimer:h=!0,newestExchangeFirst:g=!0}){let{copyText:_}=Sv(),v=yt(null),y=yt(!0),[b,ee]=ht(null),te=yt(null),[ne,re]=ht(new Set),[ie,ae]=ht(null),oe=async(e,t)=>{if(!e.assistantMessage)return;let n=t===1?i:a;try{ae(e.id),n?await n(e.userMessage.id):l?s&&await yg({agentId:c,vote:t,messageId:e.assistantMessage.id,appId:o,apiKey:s}):await bg({assistantId:c,appId:o,messageId:e.userMessage.id,thumbs:t}),re(t=>{let n=new Set(t);return n.add(e.id),n})}catch{}finally{ae(null)}},se=bt(()=>{let t=[];for(let n=0;n<e.length;n++){let r=e.at(n);if(r&&r.role===`user`){let i=r,a=e.at(n+1);a?.role===`assistant`?(t.push({id:i.id,userMessage:i,assistantMessage:a}),n++):t.push({id:i.id,userMessage:i,assistantMessage:null})}}return t},[e]),ce=bt(()=>g?[...se].reverse():se,[se,g]),le=xt(()=>{if(g)return;let e=v.current;if(!e)return;let t=80,n=e.scrollHeight-e.scrollTop-e.clientHeight;y.current=n<t},[g]);return vt(()=>{if(g)return;let e=v.current;e&&(y.current&&(e.scrollTop=e.scrollHeight),le())},[g,e,n,ce.length,le]),_t(()=>()=>{te.current&&window.clearTimeout(te.current)},[]),Z(`div`,{className:`ss-chat-root`,ref:v,onScroll:le,children:Z(`div`,{className:`ss-qa-list`,children:[se.length===0?Z(`div`,{className:`ss-chat-welcome`,children:[Z(`h2`,{className:`ss-chat-welcome-title`,children:`How can I help you today?`}),Z(`p`,{className:`ss-chat-welcome-subtitle`,children:`I search through your content to help you find answers to your questions, fast.`}),u&&u.length>0?Z(`div`,{className:`ss-suggested-questions`,children:u.map(e=>Z(`button`,{type:`button`,className:`ss-suggested-question-btn`,disabled:n,onClick:()=>{n||d?.(e.question)},children:e.question},e.objectID))}):null]}):null,m&&p?Z(lg,{onNewChat:f,detailMessage:sg(t,l),showNewConversationLink:tg(t,l)}):null,h?Z(`p`,{className:`ss-hint`,children:`Answers are generated with AI which can make mistakes.`}):null,t&&!$h(t,!!l)&&Z(`div`,{className:`ss-error-banner`,children:t.message}),ce.map((e,t)=>{let i=g?t===0:t===ce.length-1;return Z(`article`,{className:`ss-qa-card`,children:[Z(`div`,{className:`ss-qa-header`,children:Z(`div`,{className:`ss-qa-question`,children:e.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:e.assistantMessage?Z(`div`,{className:`ss-qa-markdown`,children:e.assistantMessage.parts.map((e,t)=>{if(typeof e==`string`)return Z(`p`,{children:e},`${t}`);if(e.type===`text`){let n=typeof e.text==`string`?e.text:``;return Z(xv,{children:n},`${t}`)}else if(e.type===`reasoning`&&e.state===`streaming`)return Z(`p`,{className:`ss-tool-info`,children:[Z(Og,{}),` `,Z(`span`,{className:`ss-shimmer-text`,children:`Reasoning...`})]},`${t}`);else if(e.type===`tool-searchIndex`)return e.state===`input-streaming`?Z(`p`,{className:`ss-tool-info`,children:[Z(Tg,{size:18}),` `,Z(`span`,{className:`ss-shimmer-text`,children:`Searching...`})]},`${t}`):e.state===`input-available`?Z(`p`,{className:`ss-tool-info`,children:[Z(Tg,{size:18}),` `,Z(`span`,{className:`ss-shimmer-text`,children:[`Looking for`,` `,Z(`mark`,{children:[`"`,e.input?.query||``,`"`]})]})]},`${t}`):e.state===`output-available`?Z(`p`,{className:`ss-tool-info`,children:[Z(Tg,{size:18}),` `,Z(`span`,{children:[`Searched for`,` `,Z(`mark`,{children:[`"`,e.output?.query,`"`]}),` `,`found`,` `,Array.isArray(e.output?.hits)?e.output.hits.length:`no`,` `,`results`]})]},`${t}`):e.state===`output-error`?Z(`p`,{className:`ss-tool-info`,children:e.errorText},`${t}`):null;else return null})}):Z(`div`,{className:`ss-qa-markdown ss-qa-generating ss-shimmer-text`,children:n&&i?`Thinking...`:``})})}),Z(`div`,{className:`ss-qa-actions`,children:[e.assistantMessage&&!n?ne.has(e.id)?Z(`span`,{className:`ss-qa-feedback-ack ss-fade`,children:`Thanks for your feedback!`}):ie===e.id?Z(`span`,{className:`ss-qa-feedback-ack ss-shimmer-text`,children:`Submitting...`}):Z(`div`,{className:`ss-qa-actions-group`,children:[Z(`button`,{type:`button`,title:`Like`,"aria-label":`Like`,className:`ss-qa-action-btn`,disabled:!e.assistantMessage||ie===e.id,onClick:()=>oe(e,1),children:Z(xg,{size:18})}),Z(`button`,{type:`button`,title:`Dislike`,"aria-label":`Dislike`,className:`ss-qa-action-btn`,disabled:!e.assistantMessage||ie===e.id,onClick:()=>oe(e,0),children:Z(Sg,{size:18})})]}):null,Z(`button`,{type:`button`,className:`ss-qa-action-btn ${b===e.id?`is-copied`:``}`,"aria-label":b===e.id?`Copied`:`Copy answer`,title:b===e.id?`Copied`:`Copy answer`,disabled:!e.assistantMessage||b===e.id,onClick:async()=>{let t=e.assistantMessage?.parts??[],n=t.flatMap(e=>e.type===`text`&&typeof e.text==`string`?[e.text]:[]).join(``).trim();if(n)try{r?await r(n):await _(n),ee(e.id),te.current&&window.clearTimeout(te.current),te.current=window.setTimeout(()=>{ee(null)},1500)}catch{}},children:b===e.id?Z(kg,{size:18}):Z(Cg,{size:18})})]})]},e.id)})]})})});wn();let wv=`algolia_ask_ai_suggested_questions`,Tv=({assistantId:e,suggestedQuestionsEnabled:t=!1,searchClient:n,isOpen:r=!1})=>{let[i,a]=ht([]),o=yt(!1);return _t(()=>{if(o.current||!r)return;let i=async()=>{if(!(!t||!e||e===``))try{let{results:t}=await n.search({requests:[{indexName:wv,filters:`state:published AND assistantId:${e}`,hitsPerPage:3}]}),r=t[0];a(r.hits),o.current=!0}catch(e){console.error(`Failed to fetch suggested questions:`,e)}};i()},[t,e,r,n]),i};wn();function Ev(e){let t=bt(()=>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]=ht(t);return _t(()=>{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 Dv=Ev;wn();let Ov=`https://www.algolia.com/?utm_medium=website&utm_source=sitesearch&utm_campaign=poweredby`,kv=Kt(function({config:e,onClose:t}){let n=yt(null),[r,i]=ht(``),a=bt(()=>typeof window<`u`?`${Ov}&utm_source=${encodeURIComponent(window.location.hostname)}`:Ov,[]),{messages:o,error:s,isGenerating:c,sendMessage:l,startNewConversation:u,showPromptBlockingError:d}=pg({applicationId:e.applicationId,apiKey:e.apiKey,indexName:e.indexName,assistantId:e.assistantId,agentStudio:e.agentStudio}),f=bt(()=>{let t=pt(e.applicationId,e.apiKey);return t.addAlgoliaAgent(`algolia-sitesearch`),t},[e.applicationId,e.apiKey]),p=Tv({searchClient:f,assistantId:e.assistantId,suggestedQuestionsEnabled:e.suggestedQuestionsEnabled??!1,isOpen:!0}),m=xt(e=>{let t=e.trim();!t||c||l({text:t})},[c,l]),h=xt(()=>{u(),i(``),requestAnimationFrame(()=>n.current?.focus())},[u]),g=bt(()=>d&&(cg(s,!!e.agentStudio)||!!e.agentStudio&&Bh(s)),[d,s,e.agentStudio]),_=ag(s),v=d&&_?``:d&&!_?`Conversation limit reached`:c?`Answering...`:e.placeholder??`Ask AI anything`,y=xt(()=>{let e=r.trim();!e||c||d||(l({text:e}),i(``))},[r,c,d,l]);return _t(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),_t(()=>{requestAnimationFrame(()=>n.current?.focus())},[]),Z(`div`,{className:`ss-sidepanel-inner`,children:[Z(`header`,{className:`ss-sidepanel-header`,children:[Z(`div`,{className:`ss-sidepanel-title-group`,children:[Z(wg,{size:20,gradientIdSuffix:`-sp-hdr`,className:`ss-sidepanel-title-sparkle`}),Z(`h2`,{className:`ss-sidepanel-title`,children:`Ask AI`})]}),Z(`div`,{className:`ss-sidepanel-header-actions`,children:[Z(`button`,{type:`button`,className:`ss-search-new-chat-button`,disabled:c&&!d,title:d?`Start a new conversation`:`New conversation`,"aria-label":d?`Start a new conversation`:`New conversation`,onClick:h,children:Z(Ag,{size:18})}),Z(`button`,{type:`button`,className:`ss-search-close-button`,onClick:t,"aria-label":`Close panel`,title:`Close`,children:Z(Eg,{})})]})]}),Z(`div`,{className:`ss-sidepanel-body`,children:Z(Cv,{messages:o,error:s,isGenerating:c,applicationId:e.applicationId,apiKey:e.apiKey,assistantId:e.assistantId,agentStudio:e.agentStudio,suggestedQuestions:p,onSuggestedQuestionClick:m,onNewChat:h,showPromptBlockingError:d,threadDepthBannerInChat:!1,showAiDisclaimer:!1,newestExchangeFirst:!1})}),Z(`div`,{className:`ss-sidepanel-compose-stack`,children:[d?Z(`div`,{className:`ss-sidepanel-thread-depth-banner`,children:Z(lg,{onNewChat:h,detailMessage:sg(s,e.agentStudio),showNewConversationLink:tg(s,!!e.agentStudio)})}):null,Z(`footer`,{className:`ss-sidepanel-footer`,children:[g?null:Z(`search`,{className:`ss-searchbox-form ss-searchbox-form--chat ss-sidepanel-compose-form`,onSubmit:e=>{e.preventDefault(),y()},children:[Z(`input`,{ref:n,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,maxLength:512,type:`search`,placeholder:v,value:r,disabled:c||d,onChange:e=>i(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),y())}}),Z(`button`,{type:`submit`,className:`ss-search-submit-chat-button`,disabled:c||d||!r.trim(),title:`Send message`,"aria-label":`Send message`,children:Z(jg,{size:22})})]}),Z(`div`,{className:`ss-sidepanel-ai-notice`,children:Z(`p`,{className:`ss-sidepanel-ai-notice-text`,children:`Answers are generated with AI which can make mistakes.`})}),Z(`div`,{className:`ss-sidepanel-powered-by`,children:Z(`a`,{className:`ss-sidepanel-powered-by-link`,href:a,target:`_blank`,rel:`noopener noreferrer`,children:[Z(`span`,{className:`ss-sidepanel-powered-by-label`,children:`Powered by `}),Z(Dg,{size:80})]})})]})]})]})});function Av(e){let[t,n]=ht(!1),r=Dv(e.darkMode),i=e.triggerPosition??`fixed`;return Z(`div`,{className:`ssask-exp ss-sidepanel-root ss-sidepanel-root--${i}${r?` dark`:``}`,children:[Z(`button`,{type:`button`,className:`ss-sidepanel-trigger`,onClick:()=>n(!0),"aria-expanded":t,"aria-haspopup":`dialog`,children:[Z(wg,{size:18}),Z(`span`,{children:e.buttonText??`Ask AI`})]}),t&&typeof document<`u`&&en(Z(h,{children:[Z(`button`,{type:`button`,className:`ss-sidepanel-backdrop`,"aria-label":`Close panel`,onClick:()=>n(!1)}),Z(`div`,{className:`ss-sidepanel-panel ssask-exp${r?` dark`:``}`,role:`dialog`,"aria-modal":`true`,children:Z(kv,{config:e,onClose:()=>n(!1)})})]}),document.body)]})}let jv=/^#[^#\s]+$/;function Mv(e){return typeof e==`string`?jv.test(e)?document.getElementById(e.slice(1)):document.querySelector(e):e}Ne();function Nv({container:e,...t}){let n=Mv(e);if(!n)throw Error(`Container not found`);ge(p(Av,{...t}),n)}function Pv(e){let t=Mv(e);t&&ge(null,t)}var Fv={init:Nv,destroy:Pv};exports.default=Fv,exports.destroy=Pv,exports.init=Nv});
//# sourceMappingURL=sidepanel-askai.min.js.map