offsite 0.0.85 → 0.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "offsite",
3
- "version": "0.0.85",
3
+ "version": "0.0.86",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,57 +0,0 @@
1
- import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{c as n,l as r,r as i}from"./utils-U6QfaJBO.js";import{A as a,C as o,D as s,E as c,O as l,S as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,g as v,h as y,i as b,k as x,l as S,m as C,n as w,o as ee,p as te,r as ne,s as re,u as ie,v as ae,w as oe,x as se,y as ce}from"./tags-DrTyXsO5.js";function T(e){return e[e.length-1]}function le(e,t){return typeof e==`function`?e(t):e}var ue=Object.prototype.hasOwnProperty;function de(e){for(let t in e)if(ue.call(e,t))return!0;return!1}var fe=()=>Object.create(null),pe=(e,t)=>me(e,t,!0);function me(e,t,n,r=0){if(e===t)return e;if(r++>500)return t;let i=Array.isArray(e)&&Array.isArray(t);if(!i&&!(he(e)&&he(t)))return t;let a=Object.keys(e),o=a.length,s=Object.keys(t),c=s.length;if(i?o!==e.length||c!==t.length||o&&T(a)!==`${o-1}`||c&&T(s)!==`${c-1}`:o!==Object.getOwnPropertyNames(e).length||c!==Object.getOwnPropertyNames(t).length||Object.getOwnPropertySymbols(t).length)return t;let l=0,u,d,f;if(i){for(;l<c&&(f=l,d=e[f],u=t[f],u=d===u?d:typeof d==`object`?me(d,u,n,r):u,u===d);l++);if(l===c&&o===c)return e}else{let i=o===c,p=!0;for(;l<c;l++){f=s[l],d=e[f];let o=t[f];u=d===o?d:typeof d==`object`?me(d,o,n,r):o,i&&=u===d&&(a[l]===f||ue.call(e,f)),p&&=Object.is(u,o),a[l]=u}if(i)return Object.getOwnPropertySymbols(e).length?t:e;if(p)return t}let p=i?s.fill(0):n?fe():{};for(let o=0;o<c;o++)f=i?o:s[o],i?(d=e[f],o>l&&(u=t[f],u=d===u?d:typeof d==`object`?me(d,u,n,r):u),p[f]=o<l?d:u):p[f]=a[o];return p}function he(e){return!e||typeof e!=`object`?!1:(Object.getPrototypeOf(e)?.constructor??Object)===Object}function ge(e,t,n,r){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=t[i];if(a!==o&&!ge(a,o,n,r))return!1}return!0}if(he(e)&&he(t)){if(n){for(let i in t)if((r||t[i]!==void 0)&&!ge(e[i],t[i],n,r))return!1;return!0}let i=0;if(r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;for(let a in t)if((r||t[a]!==void 0)&&(i--===0||!ge(e[a],t[a],n,r)))return!1;return i===0}return!1}var _e=/[\x00-\x1f\x7f"<>`{}]/g;function ve(e){return e.replace(_e,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function ye(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return ve(t)}var be=[`http:`,`https:`,`mailto:`,`tel:`];function xe(e){if(e[0]!==`/`&&e.includes(`:`))return/^[\x00-\x20]*([a-z][a-z\d+.\t\n\r-]*:)/i.exec(e)?.[1]?.replace(/[\t\n\r]/g,``).toLowerCase()}var Se=/^[\x00-\x20]*[\\/][\t\n\r]*[\\/]/;function Ce(e,t){if(!e)return!1;if(Se.test(e))return!0;let n=xe(e);return n?!t.has(n):!1}function we(e){if(!e)return e;let t=e;if(/[%\\\x00-\x1f\x7f]/.test(e)){let n=/%25|%5C/gi,r=0,i;for(t=``;(i=n.exec(e))!==null;)t+=ye(e.slice(r,i.index))+i[0],r=n.lastIndex;t+=ye(r?e.slice(r):e)}return t}function Te(e){return/[\s\u0080-\uFFFF]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Ee(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function De(){throw Error(`Invariant failed`)}function Oe(e){return e.replace(/\/{2,}/g,`/`)}function ke(e){return e===`/`?e:e.replace(/^\/+/,``)}function Ae(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/+$/,``):e}function je(e){return Ae(ke(e))}function Me(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function Ne(e,t,n=`never`,r){if(t.includes(`//`)&&(t=Oe(t)),t.startsWith(`/`))return t.length===1||n===`preserve`?t:n===`always`?t.endsWith(`/`)?t:`${t}/`:t.endsWith(`/`)?t.slice(0,-1):t;let i=t===`.`,a;if(r){a=i?e:e+`\0`+t;let n=r.get(a);if(n)return n}let o;if(i)o=e.split(`/`);else{for(e.includes(`//`)&&(e=Oe(e)),o=e.split(`/`);o.length>1&&T(o)===``;)o.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&o.push(r):o=[r]:r===`..`?o.length>1?o.pop():o=[``]:r===`.`||o.push(r)}}o.length>1&&(T(o)===``?n===`never`&&o.pop():n===`always`&&o.push(``));let s=o.join(`/`),c=(i?Oe(s):s)||`/`;return a&&r&&r.set(a,c),c}function Pe(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=new RegExp([...t.keys()].join(`|`).replace(/[.*()]/g,`\\$&`),`g`);return e=>e.replace(n,e=>t.get(e)??e)}function Fe(e){return e==null||e===``}function Ie(e,t,n){if(typeof t!=`string`)return``+(t??void 0);let r=e===`_splat`;if(r&&(!t||/^[a-zA-Z0-9\-._~!/]*$/.test(t)))return t;let i=encodeURIComponent(t);return r&&(i=i.replaceAll(`%2F`,`/`)),n?n(i):i}function Le(e,t,n,r,i){let a=e.endsWith(`/`)?`/`:``,o=``;for(let e of t){if(typeof e==`string`){o+=e;continue}let[t,s,c,l]=e,u=t===2,d=u&&l!==void 0?l+a:l,f=n[s];if(t!==3||f!=null){if(i&&(i[s]=f,u&&(i[`*`]=f)),u&&Fe(f)){if(c===`/`&&!d)continue;f=``}o+=c+Ie(s,f,r)+(d||``)}}return o+a||`/`}function Re(e){return e?.isNotFound===!0}function ze(){try{return sessionStorage}catch{return}}var Be=`tsr-scroll-restoration-v1_3`,Ve=ze();function He(){try{return JSON.parse(Ve?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}var Ue=He(),We=`data-scroll-restoration-id`,Ge=e=>e.state.__TSR_key||e.href;function Ke(e){let t=e.getAttribute(We);if(t)return`[${We}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var qe=!1,Je=`window`;function Ye(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function Xe(e){let t=new Set;for(let n of e){if(n===Je)continue;let e=Ye(n);e&&t.add(e)}return t}function Ze(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.e=!0);let i=e.options.getScrollRestorationKey||Ge,a=new Set,o=e=>{let t=Ue[e]||={};for(let e of a)e===document?t[Je]={scrollX,scrollY}:e.isConnected&&(t[Ke(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.s&&(r.s=!0,qe=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{qe||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{history.scrollRestoration=`auto`,o(i(e.stores.resolvedLocation.get()??e.stores.location.get()));try{Ve?.setItem(Be,JSON.stringify(Ue))}catch{}}),addEventListener(`pageshow`,e=>{e.persisted&&(history.scrollRestoration=`manual`)})),r.r||(r.r=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.n,c=r.h,l;if(a.clear(),r.n=!0,r.h=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.e&&d&&d!==u){let e=Ue[d];if(e){let t=Ue[u];for(let n in e){if(n===Je){if(s)continue}else{let e=Ye(n);if(!e||s&&o&&(l??=Xe(o),l.has(e)))continue}t||=Ue[u]={},t[n]??=e[n]}}}qe=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=Xe(o));let t=e&&i&&c,s=r.e?Ue[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===Je){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=Ye(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{qe=!1}}))}function Qe(e,t=String){let n;for(let r in e){let i=e[r];i!==void 0&&(n||=new URLSearchParams).set(r,t(i))}return n?n.toString():``}function $e(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function et(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=$e(r):Array.isArray(t)?t.push($e(r)):n[e]=[t,$e(r)]}return n}var tt=/^(?:\s|["[{\d-]|fa|nu|tr)/,nt=it(JSON.parse),rt=at(JSON.stringify,JSON.parse);function it(e){let t=e===JSON.parse;return n=>{n[0]===`?`&&(n=n.slice(1));let r=et(n);for(let n in r){let i=r[n];if(typeof i==`string`){if(t&&!tt.test(i))continue;try{r[n]=e(i)}catch{}}}return r}}function at(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!tt.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=Qe(e,r);return t?`?${t}`:``}}var ot=`__root__`;function st(e){e.statusCode=e.statusCode||e.code||307;let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function ct(e){return e instanceof Response&&!!e.options}function lt(e){let t=new Map,n,r;return{get(e){let n=t.get(e);if(n)return n.visited=!0,n.value},set(i,a){let o=t.get(i);if(o){o.value=a;return}if(t.size>=e){let e=n?.next().value;for(;!e||e.visited;)e?e.visited=!1:n=t.values(),e=n.next().value;e===r&&(n=void 0),t.delete(e.key)}let s={key:i,value:a,visited:!1};r=s,t.set(i,s)},clear(){t.clear(),n=void 0,r=void 0}}}var ut=4,dt=5;function ft(e){let t=e.names;if(t)return t;let n=[];for(let t of e)typeof t!=`string`&&n.push(t[1]);return e.names=n}function pt(e,t,n){let r=e.slice(t,n);if(r.charCodeAt(0)===36)return r.length===1?[2,`_splat`,``,void 0]:[1,r.slice(1),``,``];let i=r.indexOf(`{`);if(i>=0){let a=r.indexOf(`}`,i),o=r.charCodeAt(i+1)===45,s=i+(o?3:2);if(a>=0&&r.charCodeAt(s-1)===36&&(!o||s<a)){let c=r.slice(s,a);return[o?3:c?1:2,c||`_splat`,r.slice(0,i),e.slice(t+a+1,c?n:e.length)]}}return r}function mt(e,t,n,r,i,a){let o=n,s=t.fullPath??t.from,c=t.options,l=s.length,u=s.endsWith(`/`)?l-1:l,d=c?.caseSensitive??e,f=c?.params?.parse??c?.parseParams,p,m=a?n-1:0;if(!r||s.includes(`$`)){p=a?.slice()??[];let e=T(p);e&&typeof e!=`string`&&e[0]===2&&(p[p.length-1]=[e[0],e[1],e[2],e[3]===void 0?void 0:e[3]+s.substring(n-(s[n-2]===`/`?2:1),u)],m=l)}for(;o<l;){let e=o,t=s.indexOf(`/`,e),n=t===-1?l:t,a=pt(s,e,n);o=n+1;let c;if(typeof a==`string`){if(!r)continue;let e=a,t;d?t=r.static??=new Map:(e=a.toLowerCase(),t=r.staticInsensitive??=new Map);let n=t.get(e);if(n)c=n;else{let n=gt(r);c=n,t.set(e,n)}}else{let t=a[0],h=a[2],g=a[3]??``;if(t===2&&(n=l,o=n+1),p&&m<n&&(m<e-1&&p.push(s.slice(m,e-1)),a[2]=`/`+h,t===2&&a[3]!==void 0&&u<l&&(a[3]=g.slice(0,-1)),p.push(a),m=n),!r)continue;let _=d&&!!(h||g);d||(h=h.toLowerCase(),g=g.toLowerCase());let v=t===1?r.dynamic??=[]:t===3?r.optional??=[]:r.wildcard??=[],y=t!==2&&!f&&v.find(e=>!e.parse&&e.caseSensitive===_&&e.prefix===h&&e.suffix===g);if(y)c=y;else{let e=gt(r,t,_,h,g);c=e,v.push(e),v.length===2&&i?.push(v)}}r=c}p&&m<u&&p.push(s.slice(m,u));let h=p?.slice();if(!r)return h;if(f&&t.children&&!t.isRoot&&t.id&&t.id.charCodeAt(t.id.lastIndexOf(`/`)+1)===95){let e=gt(r,dt);(r.pathless??=[]).push(e),r=e}let g=(t.path||!t.children)&&!t.isRoot;if(g&&u<l){let e=gt(r,ut);r.index=e,r=e}return r.parse=f??null,r.priority=c?.params?.priority??0,r.route||(r.data=h,g&&(r.route=t)),[r,o,h]}function ht(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function gt(e,t=0,n,r,i){return{kind:t,depth:e?e.depth+1:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,data:void 0,parent:e,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function _t(e,t){let n=gt(),r=[];function i(e,t,n,a){let[o,s,c]=mt(!1,e,t,n,r,a);if(e.children)for(let t of e.children)i(t,s,o,c)}for(let t of e)i(t,1,n);for(let e of r)e.sort(ht);t.masksTree=n,t.flatCache=lt(1e3)}function vt(e,t){e||=`/`;let n=t.flatCache.get(e);if(n!==void 0)return n;let r=St(e,t.masksTree);return t.flatCache.set(e,r),r}function yt(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=gt(),mt(t,{from:e},1,o),i.singleCache.set(a,o)),St(r,o,n)}function bt(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=St(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=wt(a.route)),t.matchCache.set(r,a),a}function xt(e,t=!1){let n=gt(),r=[],i={},a={},o=0;function s(e,n,c,l){if(e.init(o),e.id in i&&De(),i[e.id]=e,o!==0&&e.path){let t=Ae(e.fullPath);(!a[t]||e.fullPath.endsWith(`/`))&&(a[t]=e)}o++;let[u,d,f]=mt(t,e,n,c,r,l);if(e._interpolation=f,e.children)for(let t of e.children)s(t,d,u,f)}s(e,1,n);for(let e of r)e.sort(ht);return{processedTree:{segmentTree:n,singleCache:lt(1e3),matchCache:lt(1e3),flatCache:null,masksTree:null},routesById:i,routesByPath:a}}function St(e,t,n=!1){let r=e.split(`/`),i=Et(e,r,t,n);if(!i)return null;let[a]=Ct(e,r,i);return{route:i.node.route,rawParams:a}}function Ct(e,t,n){let r=Tt(n.node),i=n.node.data&&ft(n.node.data),a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.param??0;for(;s<r.length;o++,s++,c++){let u=r[s];if(u.kind===ut)break;if(u.kind===dt){o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1||u.kind===3){let e=i[l++];if(u.kind===3&&n.skipped&1<<s){o--,c=f-1;continue}let t=u.suffix||u.prefix?d.substring(u.prefix.length,d.length-u.suffix.length):d;(t||u.kind===1)&&(a[e]=decodeURIComponent(t))}else if(u.kind===2){let t=u,n=e.substring(f+t.prefix.length,e.length-t.suffix.length),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,param:l}]}function wt(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Tt(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function Et(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!T(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,statics:f,dynamics:p,optionals:m}=n,{extract:h,rawParams:g}=n;if(i.kind===2&&i.route&&!At(l,n))continue;if(i.parse){if(!kt(e,t,n))continue;g=n.rawParams,h=n.extract}r&&i.route&&i.kind!==ut&&At(c,n)&&(c=n);let _=u===o;if(_&&(i.route&&(!a||i.kind===ut||i.kind===2)&&At(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let v=_?void 0:t[u],y;if(_&&i.index){let n={node:i.index,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g},r=!0;if(i.index.parse&&(kt(e,t,n)||(r=!1)),r){if(!p&&!m&&!d&&Ot(f,o))return n;At(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!r||!_&&(n.caseSensitive?v:y??=v.toLowerCase()).startsWith(r)){if(a){if(_)continue;let e=t.slice(u).join(`/`),i=e.slice(-a.length);if((n.caseSensitive?i:i.toLowerCase())!==a||e.length-a.length<r.length)continue}s.push({node:n,index:o,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(i.optional){let e=d|1<<i.depth+1;for(let t=i.optional.length-1;t>=0;t--){let n=i.optional[t];s.push({node:n,index:u,skipped:e,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_)for(let e=i.optional.length-1;e>=0;e--){let t=i.optional[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p,optionals:m+Dt(o,u),extract:h,rawParams:g})}}if(!_&&i.dynamic&&v)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?v:y??=v.toLowerCase();if(n&&!e.startsWith(n)||r&&e.indexOf(r,e.length-r.length)<n.length)continue}s.push({node:t,index:u+1,skipped:d,statics:f,dynamics:p+Dt(o,u),optionals:m,extract:h,rawParams:g})}if(!_&&i.staticInsensitive){let e=i.staticInsensitive.get(y??=v.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,statics:f+Dt(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(!_&&i.static){let e=i.static.get(v);e&&s.push({node:e,index:u+1,skipped:d,statics:f+Dt(o,u),dynamics:p,optionals:m,extract:h,rawParams:g})}if(i.pathless)for(let e=i.pathless.length-1;e>=0;e--){let t=i.pathless[e];s.push({node:t,index:u,skipped:d,statics:f,dynamics:p,optionals:m,extract:h,rawParams:g})}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function Dt(e,t){return 2**(e-t-1)}function Ot(e,t){return e===2**(t-1)-1}function kt(e,t,n){let r,i;try{[r,i]=Ct(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function At(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===ut)>(e.node.kind===ut)||t.node.kind===ut==(e.node.kind===ut)&&t.node.depth>e.node.depth)))}function jt(e,t,n){let r=je(e),i=`/${r}`,a=t?i:i.toLowerCase(),o=`${a}/`,s={input:({url:e})=>{let n=t?e.pathname:e.pathname.toLowerCase();return n===a?e.pathname=`/`:n.startsWith(o)&&(e.pathname=e.pathname.slice(i.length)),e},output:({url:e})=>(e.pathname=Oe(`/${r}${e.pathname}`),e)};return n?{input:({url:e})=>Mt(n,s.input({url:e})),output:({url:e})=>s.output({url:Nt(n,e)})}:s}function Mt(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Nt(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Pt(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{Ee(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var Ft=`__TSR_index`,It=`popstate`,Lt=`beforeunload`,Rt=/^[\x00-\x20]*(?:[\\/][\t\n\r]*){2,}/;function zt(e){let t=Rt.exec(e);return t?`/`+e.slice(t[0].length):e}function Bt(e){return/[\x00-\x1f\x7f]/.test(e)&&(e=e.replace(/[\x00-\x1f\x7f]/g,e=>`
2
- \r`.includes(e)?``:encodeURIComponent(e))),zt(e)}function Vt(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async n=>{let r=n.navigateOpts?.ignoreBlocker?void 0:e.getBlockers?.();if(typeof document<`u`&&r?.length&&(n.type===`PUSH`||n.type===`REPLACE`))for(let i of r){let r=Wt(n.path,n.state);if(await i.blockerFn({currentLocation:t,nextLocation:r,action:n.type})){e.onBlocked?.();return}}n.task()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[Ft];i=Ht(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[Ft];i=Ht(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t,n?.ignoreBlocker??!1),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[Ft]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r,_getBlockers:()=>e.getBlockers?.()??[]}}function Ht(e,t){let n=Gt();return{...t,key:n,__TSR_key:n,[Ft]:e}}function Ut(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=t=>Bt(e?.createHref?e.createHref(t):t),c=e?.parseLocation??(()=>Wt(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=Gt();t.history.replaceState({[Ft]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(t,n,r)=>{let i=e?.createHref?s(n):void 0,a=!!g;a||(u=l),l=Wt(n,r),g=[i??l.href,r,g?.[2]||t],a||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(m=!1,f){f=!1;return}let e=c(),n=e.state[Ft]-l.state[Ft],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let r=a();if(typeof document<`u`&&r.length){for(let i of r)if(await i.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(-n),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0||typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=Vt({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0,m=!0),t.history.back()),forward:e=>{e&&(p=!0,m=!0),t.history.forward()},go:(e,n)=>{d=!0,n&&(p=!0,m=!0),t.history.go(e)},createHref:s,flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(Lt,x,{capture:!0}),t.removeEventListener(It,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return S._ignoreNextBeforeUnload=e=>{m=!1;try{e=new URL(e,t.document.baseURI).href,m=/^https?:/.test(e)&&(!e.includes(`#`)||e.split(`#`)[0]!==t.location.href.split(`#`)[0])}catch{}},t.addEventListener(Lt,x,{capture:!0}),t.addEventListener(It,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function Wt(e,t){let n=Bt(e),r=n.indexOf(`#`),i=n.indexOf(`?`);if(!t){let e=Gt();t={[Ft]:0,key:e,__TSR_key:e}}return{href:n,pathname:n.slice(0,r>-1?i>-1?Math.min(r,i):r:i>-1?i:n.length),hash:r>-1?n.slice(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t}}function Gt(){return(Math.random()+1).toString(36).slice(7)}function Kt(e,t){return e.protocol!==`http:`&&e.protocol!==`https:`||e.origin!==t||!!e.username||!!e.password}function qt(e){return e.pathname+e.search+e.hash}function Jt(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function Yt(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function Xt({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function Zt(e){return e.findIndex(e=>e.status===`error`||e.status===`notFound`||e._notFound)+1}function Qt(e,t,n,r,i,a){r&&(t=t.slice(0,r)),i&&(n=n.slice(0,i));for(let r of t){if(a&&e._tx!==a)return;n.some(e=>e.routeId===r.routeId)||e.routesById[r.routeId].options.onLeave?.(r)}for(let r of n){if(a&&e._tx!==a)return;e.routesById[r.routeId].options[t.some(e=>e.routeId===r.routeId)?`onStay`:`onEnter`]?.(r)}}var $t=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={n:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options;this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.staticLocations=new WeakMap,this.protocolAllowlist=new Set(this.options.protocolAllowlist),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:Ut()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`;let n=this.options.basepath??`/`,r=this.options.rewrite,i=this.basepath!==n||t?.rewrite!==r||t?.caseSensitive!==this.options.caseSensitive;if(i&&(this.basepath=n,this.rewrite=n!==`/`&&je(n)?jt(n,this.options.caseSensitive,r):r),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;e=this.buildRouteTree(),this.setRoutes(e)}if(this.stores)i&&this.stores.location.set(this.latestLocation);else if(this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Pt(this.latestLocation,e),Ze(this)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=xt(this.routeTree,this.options.caseSensitive);return this.options.routeMasks&&_t(this.options.routeMasks,e.processedTree),{...e,resolvePathCache:lt(1e3)}},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i},a)=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:we(e),external:!1,searchStr:o,search:pe(t?.search,i),hash:we(r.slice(1)),state:me(t?.state,a)}}let o=Mt(this.rewrite,new URL(i,this.origin)),s=this.options.parseSearch(o.search),c=this.options.stringifySearch(s);return o.search=c,{href:o.href.replace(o.origin,``),publicHref:i,pathname:we(zt(o.pathname)),external:!!this.rewrite&&Kt(o,this.origin),searchStr:c,search:pe(t?.search,s),hash:we(o.hash.slice(1)),state:me(t?.state,a)}},r=n(e,e.state),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i,{...i.state,__tempLocation:void 0,key:r.state.key,__TSR_key:r.state.__TSR_key});return e.maskedLocation=r,e}return r},this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=bt(Ae(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{{let t=this.staticLocations.get(e);if(t)return t}let t=!1,n=(n={})=>{if(n.href){let e=Wt(n.href,{});n={...n,to:Mt(this.rewrite,new URL(e.pathname,this.origin)).pathname,search:this.options.parseSearch(e.search),hash:e.hash.slice(1)}}let r=e._fromLocation||this._pendingLocation||this.latestLocation,i,a=()=>(t=!0,r),o=()=>i??=this.matchRoutesLightweight(a()),s=n.to?`${n.to}`:`.`,c=Ne(s[0]===`/`?``:n.unsafeRelative===`path`?a().pathname:n.from??o()[1],s,this.options.trailingSlash,this.resolvePathCache),l=this.routesByPath[Ae(c)],u=c.includes(`$`),d;if(l)d=l._branch??=wt(l);else if(u)d=[];else{let[e,t,n]=this.getMatchedRoutes(c);d=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(d=[...d,this.options.notFoundRoute])}let f=u?l?._interpolation??mt(!1,{fullPath:c},0):void 0,p;for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t){let e=o()[3];if(p??=an(n.params,e),!de(p))break;p===e&&(p=Object.assign(fe(),p));try{Object.assign(p,t(p))}catch{}}}p??=an(n.params,on(n.params,f)?o()[3]:sn);let m=e.leaveParams?c:zt(we(f?Le(c,f,p,this.pathParamsDecoder):c)),h=cn(d,e._includeValidateSearch),g=()=>{let t=o()[2];if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(n=>{if(n.options.validateSearch)try{Object.assign(e,rn(n.options.validateSearch,{...e,...t}))}catch{}}),t=e}return t},_=h.length?ln(h,g(),n):n.search===!0?g():typeof n.search==`function`?n.search(g()):n.search||sn,v=this.options.stringifySearch(_),y=n.hash===!0?a().hash:typeof n.hash==`function`?n.hash(a().hash):n.hash||void 0,b=y?`#${y}`:``,x=n.state?n.state===!0?a().state:typeof n.state==`function`?n.state(a().state):n.state:sn,S=`${m}${v}${b}`,C,w,ee=!1;if(this.rewrite){let e=new URL(S,this.origin),t=e.origin,n=Nt(this.rewrite,e);C=qt(e),Kt(n,t)?(w=n.href,ee=!0):w=zt(qt(n))}else C=Te(S),w=C;return{publicHref:w,href:C,pathname:m,search:_,searchStr:v,state:x,hash:y??``,external:ee,unmaskOnReload:n.unmaskOnReload}},r=n(e);if(e.mask)r.maskedLocation=n({from:e.from,...e.mask});else if(this.options.routeMasks){let t=vt(r.pathname,this.processedTree);if(t){let i=Object.assign(fe(),t.rawParams),{from:a,params:o,...s}=t.route,c=an(o,i);r.maskedLocation=n({from:e.from,...s,params:c})}}return!t&&e._fromLocation&&this.staticLocations.set(e,r),r},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=n.maskedLocation??n;if(r.external)return en(this,r.publicHref,{replace:n.replace,ignoreBlocker:t});let i,a=Ae(this.latestLocation.href)===Ae(n.href)&&ge(Xt(n.state),Xt(this.latestLocation.state)),o=this._commitPromise,s,c=new Promise(e=>{s=e});if(c.resolve=()=>{s(),o?.resolve()},this._commitPromise=c,a)this.load();else{let{maskedLocation:r,hashScrollIntoView:a,...o}=n;r&&(o={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state={...o.state,__hashScrollIntoViewOptions:a??this.options.defaultHashScrollIntoView??!0},this.shouldViewTransition=e,i=n.replace?`REPLACE`:`PUSH`,this.history[i===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:i}})}return this._scroll.n=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,...a}={})=>{let o=this.buildLocation({...a,_includeValidateSearch:!0});this._pendingLocation=o;let s=this.commitLocation({...o,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===o&&(this._pendingLocation=void 0)}),s},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=n?xe(n):void 0;if(a||t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i}),a=t.maskedLocation??t;n??=a.publicHref,r??=a.publicHref}let t=!a&&r?r:n;return en(this,t,i)}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.h=e.action.type===`PUSH`||e.action.type===`REPLACE`),await $n(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(Yt(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set,a=e=>{(!n||n(e))&&i.add(e.id)};t.forEach(a),this._cache.forEach(a),r?.forEach(e=>e.forEach(a)),this._tx?.[3].forEach(a);let o=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),o.push(e));let s=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&Jt(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(s);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i){let t=this._flights?.get(e);this._flights?.delete(e),t&&!t[2]&&o.push(t[1])}for(let e of o)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.options,n=e.headers.get(`Location`)||t.href;if(!n){let e=this.buildLocation(t);n=(e.maskedLocation??e).publicHref||`/`}let r;if(Se.test(n)||(r=xe(n))&&!this.protocolAllowlist.has(r))throw Error(`Redirect blocked: unsafe protocol`);if(r===`http:`||r===`https:`){let e=new URL(n);e.pathname.startsWith(`//`)?n=e.href:Kt(e,this.origin)||(n=qt(e),r=void 0)}return r&&(t.reloadDocument=!0),t.href=n,e.headers.set(`Location`,n),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=mn,this.preloadRoute=e=>er(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?Ne(e.from||``,e.to,this.options.trailingSlash,this.resolvePathCache):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=yt(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!ge(o.rawParams,e.params,!0)?!1:t?.includeSearch??!0?ge(a.search,r.search,!0)?o.rawParams:!1:o.rawParams},this.getStoreConfig=t,e.pathParamsAllowedCharacters?.length&&(this.pathParamsDecoder=Pe(e.pathParamsAllowedCharacters)),this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??rt,parseSearch:e.parseSearch??nt,protocolAllowlist:e.protocolAllowlist??be}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes(e){Object.assign(this,e),this.lightweightCache=new WeakMap,this.staticLocations=new WeakMap;let t=this.options.notFoundRoute;t&&(t.init(99999999999),this.routesById[t.id]!==t&&(t._interpolation=mt(!1,t,0)),this.routesById[t.id]=t)}matchRoutesInternal(e,t){let[n,r,i]=this.getMatchedRoutes(e.pathname),a=n,o=!1;(i?i.path!==`/`&&r[`**`]:Ae(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?un(this.options.notFoundMode,a):void 0,c=Array(a.length),l=this._committed,u=(e,t)=>{let n=l[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?l.find(t=>t.routeId===e.id):void 0},d;for(let n=0;n<a.length;n++){let i=a[n],o=c[n-1],l,f,p;{let n=o?.search??e.search,r=o?._strictSearch??void 0;try{let e=rn(i.options.validateSearch,{...n})??void 0;l={...n,...e},f={...r,...e}}catch(e){let r=e;if(e instanceof tn||(r=new tn(e.message,{cause:e})),t?.throwOnError)throw r;l=n,f={},p=r}}let m=``,h=``;try{m=i.options.loaderDeps?.({search:l})??``,h=m&&JSON.stringify(m)||``}catch(e){if(t?.throwOnError)throw e;p??=e}let g=fe(),_=i._interpolation?Le(i.fullPath,i._interpolation,r,this.pathParamsDecoder,g):i.fullPath,v=i.id+_+h,y=u(i,n),b=this._cache.get(v)??(y?.id===v?y:void 0);d=b?._strictParams??Object.assign(g,d);let x;if(!b)try{dn(i,d)}catch(e){if(x=Re(e)||ct(e)?e:new nn(e.message,{cause:e}),t?.throwOnError)throw x}let S=y?`stay`:`enter`,C;if(b)C={...b,cause:S,search:pe(y?y.search:b.search,l),_strictSearch:f,searchError:p};else{let e=Jt(i)?`pending`:`success`;C={id:v,ssr:i.options.ssr,index:n,routeId:i.id,params:y?.params??d,_strictParams:d,pathname:_,updatedAt:Date.now(),search:y?pe(y.search,l):l,_strictSearch:f,searchError:p,status:e,isFetching:!1,error:void 0,paramsError:x,context:{},abortController:t?._controller??new AbortController,cause:S,loaderDeps:y?me(y.loaderDeps,m):m,invalid:!1,preload:!1,staticData:i.options.staticData||{},fullPath:i.fullPath}}let w=s===i.id;C._notFound&&!w&&(C.error=void 0),C._notFound=w,c[n]=C}for(let e=0;e<c.length;e++){let n=c[e];n.params=n.cause===`stay`?pe(n.params,d):d,t?._controller&&(n.context={})}return c}matchRoutesLightweight(e){let t=T(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=T(a),c={...e.search};for(let e of a)try{Object.assign(c,rn(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=o;for(let t of a)try{dn(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}};async function en(e,t,{replace:n,ignoreBlocker:r}){if(!Ce(t,e.protocolAllowlist)){if(!r){let t=e.history._getBlockers();for(let r of t)if(r?.blockerFn&&await r.blockerFn({currentLocation:e.history.location,nextLocation:e.history.location,action:n?`REPLACE`:`PUSH`}))return}e.history._ignoreNextBeforeUnload?.(t),n?window.location.replace(t):window.location.href=t}}var tn=class extends Error{},nn=class extends Error{};function rn(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new tn(`Async validation not supported`);if(n.issues)throw new tn(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function an(e,t){if(e===void 0||e===!0)return t;let n=Object.create(null);return e===!1||e===null?n:typeof e==`function`?(Object.assign(n,t),Object.assign(n,e(n))):Object.assign(n,t,e)}function on(e,t){return typeof e==`function`?!0:!t||e===!1||e===null?!1:e===void 0||e===!0||t.some(t=>typeof t!=`string`&&!ue.call(e,t[1]))}var sn=Object.freeze({});function cn(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r].options;`search`in i?i.search?.middlewares&&n.push(...i.search.middlewares):(i.preSearchFilters||i.postSearchFilters)&&n.push(({search:e,next:t})=>{let n=t(i.preSearchFilters?i.preSearchFilters.reduce((e,t)=>t(e),e):e);return i.postSearchFilters?i.postSearchFilters.reduce((e,t)=>t(e),n):n});let a=i.validateSearch;t&&a&&n.push(({search:e,next:t,meta:n})=>{let r=t(e);try{let e=rn(a,r);if(n&&e)for(let t in e)t in r||(n.defaulted||=new Map).set(t,e[t]);return{...r,...e}}catch{}return r})}return n}function ln(e,t,n){let r=(t,i,a)=>{if(t>=e.length){if(!n.search)return{};if(n.search===!0)return i;let e=le(n.search,i);return a&&(a.explicit=e),e}return e[t]({search:i,next:(e,n)=>{if(n){let n=a||{};return{search:r(t+1,e,n),meta:n}}return r(t+1,e,a)},meta:a})};return r(0,t)}function un(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return ot}function dn(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function fn(e,t){return e.options[t]?.preload?.()}function pn(e,t){let n=fn(e,`component`),r=fn(e,`pendingComponent`);return t&&(r?r=r.then(t):t()),n&&r?Promise.all([n,r]).then(()=>{}):n??r}function mn(e,t,n){let r=()=>t===!1?void 0:t?fn(e,t):pn(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function hn(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}function gn(e,t,n){let r=e._tx;return t&&r?.[2]===n&&!r[3].some(e=>e.routeId===t)}var E=0,_n=1,vn=2,D=3,yn=[4];function bn(e){return typeof e[0]==`number`}function xn(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).then(()=>t.removeEventListener(`abort`,i))})}function Sn(e,t){return e.routesById[t.routeId]}function Cn(e,t,n){return ct(e)?[D,e]:Re(e)?(e.routeId||=n,[vn,e]):t?(typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),[_n,e]):[E,e]}function wn(e,t){let n=Cn(t,!0,e.id);if(n[0]!==_n)return n;try{e.options.onError?.(n[1])}catch(t){n=Cn(t,!0,e.id)}return n}function Tn(e,t,n,r,i){return i[0].signal.aborted?yn:Bn(e,t,n,wn(n,r),i)}async function En(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[3];for(let i=n[6]??0;i<r;i++){let r=s[i],u=Sn(e,r);r.abortController=n[0];let d=s[i-1]?.context??e.options.context??{},f={params:r.params,location:o,navigate:t=>e.navigate({...t,_fromLocation:o}),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:u.id};try{let e=r._ctx||=u.options.context?u.options.context({...f,deps:r.loaderDeps,context:d})||{}:void 0;r.context={...d,...e}}catch(a){return On(e,r),[i,Tn(e,t,u,a,n)]}if(c.aborted)return[i,yn];let p=r.paramsError??r.searchError;if(p!==void 0)return On(e,r),[i,Tn(e,t,u,p,n)];let m=u.options.beforeLoad;if(!m)continue;let h=r.status;i>=a&&(r.status=`pending`,n[7]?.());try{An(e,r,`beforeLoad`,n[0]);let a=m({...f,search:r.search,context:r.context,...e.options.additionalContext}),o=await(typeof a?.then==`function`?xn(a,c):a);if(c.aborted)return[i,yn];let s=Bn(e,t,u,Cn(o,!1,u.id),n);if(s[0]!==E)return On(e,r),[i,s];r.context={...r.context,...o}}catch(a){return On(e,r),[i,Tn(e,t,u,a,n)]}finally{r.status=h,An(e,r,!1,n[0])}}i()}function Dn(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function On(e,t){let n=t._flight;t._flight=void 0,Dn(e,t,n)?.abort()}function O(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=Dn(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function kn(e){for(let t of e){let e=t._flight;e&&e[2]++}}function An(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function jn(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:t=>e.navigate({...t,_fromLocation:s}),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function Mn(e,t,n,r,i,a,o){let s=o[0],c=s.signal;if(c.aborted)return yn;if(!i)return[E,void 0];let l=n._flight;An(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(jn(e,t,n,r,s,a,!!o[3]))).then(e=>Cn(e,!1,r.id),e=>Cn(e,!0,r.id)).then(t=>(t[0]!==E&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===_n&&l[2]?wn(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],Bn(e,t,r,await xn(l[0],c),o)}catch(t){if(t!==c||!c.aborted)throw t;return On(e,n),yn}finally{An(e,n,!1,s)}}function Nn(e,t,n){t[0]!==D&&(e.status=`success`,e.error=void 0,t[0]===E?(e.loaderData=t[1],e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):e.invalid=!0)}function Pn(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&On(e,r)}function Fn(e,t){return t[0]===_n||t[0]===vn?{...e,status:t[0]===_n?`error`:`notFound`,error:t[1],_flight:void 0}:e}function In(e,t,n,r,i,a,o){let s=t[1][n],c=Sn(e,s),l=!!a[3],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(jn(e,t,s,c,a[0],i,l))),a[0].signal.aborted&&(p=yn)),!p){if(s.status!==`success`)f=!0;else{let t=l||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[5]||s.cause===`enter`||a[2].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(n){s.invalid=!0,On(e,s),p=Tn(e,t,c,n,a)}let m=c.options.loader,h=typeof m==`function`,g=h?m:m?.handler,_=!l||c.options.preload!==!1,v=_&&m?e._flights?.get(s.id):void 0;v===s._flight||p?v=void 0:v&&!f&&!l&&d===void 0?f=!0:f||(v=void 0);let y=!(!m||!f||s.status!==`success`||l||a[4]||((h?void 0:m.staleReloadMode)??e.options.defaultStaleReloadMode)===`blocking`),b=f&&_,x=b&&!y&&(s.status!==`success`||!!m),S=n>=o?a[7]:void 0,C=c.lazyFn&&c._lazy!==!0?S:void 0;if(b&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),v&&v[2]++,x){let t=s._flight;s._flight=v,Dn(e,s,t)?.abort(),n>=o&&(s.status=`pending`),S?.()}b||(s.isFetching=!1);let w=!p&&x?Mn(e,t,s,c,g,i,a).then(t=>(Nn(s,t,l),t[0]===E&&(m&&!a[0].signal.aborted&&Pn(e,s,u),n>=o&&(s.status=`pending`)),t)):Promise.resolve(p??[E,s.loaderData]),ee=(async()=>{try{let e=mn(c,void 0,C);e&&await xn(e,a[0].signal)}catch(r){if(!t[1].some((e,t)=>t<=n&&(e.status===`error`||e.status===`notFound`||e._notFound)))return[n,Tn(e,t,c,r,a)]}let r=await w;x&&r[0]===E&&s.status===`pending`&&!a[0].signal.aborted&&(s.status=`success`,S?.())})();if(r.push([n,w,ee]),!y)return w.then(e=>Fn(s,e));let te={...s,status:`pending`,preload:!1,_flight:v};s.invalid=!1,s.isFetching=`loader`;let ne=Mn(e,t,te,c,g,i,a).then(e=>(s.isFetching=!1,Nn(te,e,!1),e));return(t[2]??=[]).push([n,ne,ee,te]),ne.then(e=>Fn(te,e))}async function Ln(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=Sn(e,t[n]);try{let e=mn(i,!1);e&&await xn(e,r)}catch(e){if(e===r&&r.aborted)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function Rn(e,t){t[2]&&=(O(e,t[2].map(e=>e[3])),void 0)}async function zn(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=D)throw[a,t];!i&&t[0]!==E&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===D)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}function Bn(e,t,n,r,i,a){for(;r[0]===D;){let o=r[1],s=o.options;try{if((s.href||o.headers.has(`Location`))&&(e.resolveRedirect(o),s.reloadDocument)||(s.reloadDocument?i[3]:i[1]>=20))return r;let n=e.buildLocation({...s,_fromLocation:t[0],_includeValidateSearch:!0}),a=n.maskedLocation??n;if(a.external){let t=o.clone();return t.options={...s},t.headers.set(`Location`,a.publicHref),e.resolveRedirect(t),i[3]?[D,t]:[D,t,a]}return[D,o,n]}catch(e){r=a?[_n,e]:wn(n,e),a=!0}}return r}async function Vn(e,t,n,r,i,a){let o=t[1],s=await i,c=!1,l=o.findIndex(e=>e._notFound),u=t=>t[1][0]===vn?Ln(e,o,t,r.signal):t[0],d=l<0?o.length:l;if((s?.[1][0]??0)>=D)d=0;else if(s){d=s[2]??=await u(s);for(let e of n){if(e[0]>=d)break;let t=await e[1];if(t[0]!==E&&t[0]<D&&!(`loaderData`in o[e[0]])){s=[e[0],t],d=s[2]=await u(s);break}}}for(let e of n){if(e[0]>=d)break;let t=await e[2];if(t){s=t;break}}if((s?.[1][0]??0)>=D){let n=s[1];if(n[0]!==D||n[1].options.reloadDocument||n[2])return Rn(e,t),n;c=!0,s=[0,[_n,Error(`Too many redirects`)]]}let f=s?s[2]??await u(s):l;if(f>=0){let i=s?.[1],l=i?.[0],u=o[f],d=i?.[1],p=()=>{i&&(u._notFound=void 0,l===_n?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};p(),i||a?.();let m=Sn(e,u);try{await xn(i?Promise.resolve().then(()=>mn(m,l===_n?`errorComponent`:`notFoundComponent`)):Promise.all([mn(m),mn(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal&&r.signal.aborted)return Rn(e,t),yn}i?c&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),Rn(e,t),O(e,o),p()):u.status=`success`}return t}async function Hn(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=Sn(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await xn(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n&&n.aborted)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function Un(e,t,n,r){let i=[t,n],a=r[0].signal,o;try{let t=e.stores.matches.get(),s=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&s>=0){let t=await Ln(e,n,void 0,a,s);n[s]._notFound=void 0,n[t]._notFound=!0,s=t}let c=s<0?n.length:s+1,l=0;for(;l<c&&l!==s;){let e=n[l],i=r[2][l],a=t[l];if(i?.id!==e.id||i.status!==`success`||e.preload||a?.id!==e.id||a.status!==`success`||(l++,i._notFound||a._notFound))break}let u=[],d=r[6]??0,f=d?Promise.resolve(n[d-1]):void 0,p=()=>{for(let t=d;t<c&&!a.aborted;t++)f=In(e,i,t,u,f,r,l)},m=await En(e,i,r,c,p,l);if(m){if(r[4]=!0,c=m[0],m[1][0]===vn){let t=await Ln(e,n,m,a);m[2]=t,c=Math.min(c,t+1)}else m[1][0]>=D&&(c=0);p()}if(!a.aborted&&!r[3]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let h=Vn(e,i,u,r[0],zn(u,m,i[2]),r[7]);i[2]?.length&&(i[3]=zn(i[2],void 0,void 0,h.then(e=>bn(e)?0:hn(n).length,()=>0))),o=await h}catch(t){if(Rn(e,i),t===a&&a.aborted)return yn;throw t}return bn(o)?o:Hn(e,o,a,r[6]===n.length?r[6]:0)}function Wn(e,t){if(e._tx!==t)return;let n=t[3],r=e.stores.matches.get(),i=e._pending;for(let a=0;a<n.length;a++){let o=n[a],s=o.status===`success`&&!o._notFound,c=r[a]?.id===o.id&&r[a]?.status===`pending`;if(s&&!c)continue;let l=Sn(e,o),u=s||o.invalid?0:l.options.pendingMs??e.options.defaultPendingMs,d=l.options.pendingComponent??e.options.defaultPendingComponent;if(!d||typeof u!=`number`||u===1/0){i&&(i[0]=t,i[2]=0,i[4]=!0);return}let f=l.options.pendingMinMs??e.options.defaultPendingMinMs??0,p=!1;if(i?.[1]===o.id?(p=i[0]!==t,i[0]=t):(clearTimeout(i?.[3]),e._pending=i=void 0),i||(e._pending=i=[t,o.id,c?Date.now()+f:t[4]+u,void 0,c||void 0,d]),i[4]&&!p&&i[5]===d)return;if(i[5]=d,!i[4]){clearTimeout(i[3]);let n=i[2]-Date.now();if(n>0){i[3]=setTimeout(()=>Wn(e,t),n);return}i[2]=0}let m=n.map(e=>({...e,_flight:void 0}));m[a].status=`pending`;let h=i[4]=e.startTransition(()=>e.stores.setMatches(m),m).then(t=>(t&&e._pending===i&&i[4]===h&&!i[2]&&(i[2]=Date.now()+f),t));return}}function Gn(e,t){let n=e._pending;e._tx!==t&&e._tx?.[3].some(e=>e.id===n?.[1])||(clearTimeout(n?.[3]),e._pending=void 0)}async function Kn(e,t){let n=e._pending;if(!n)return;clearTimeout(n[3]);let r=n[2]-Date.now();if(!n[4]||r<=0||!hn(t[3]).some(e=>e.id===n[1]))return;let i;try{await xn(new Promise(e=>{i=setTimeout(e,r)}),t[0].signal)}catch{}clearTimeout(i)}function qn(e,t){e._committed=t,e.stores.setMatches(t)}function Jn(e,t,n,r){let i=e._committed,a=e._lifecycleEnd,o=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let s=hn(n).length,c=new Map;{let t=Date.now(),r=new Set;for(let e=0;e<n.length;e++){let t=n[e];(e<s||t.status===`success`)&&r.add(t.id)}for(let n of[...i,...o.values()]){if(n.status!==`success`||r.has(n.id))continue;let i=Sn(e,n);!i.options.loader||t-n.updatedAt>=(n.preload?i.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:i.options.gcTime??e.options.defaultGcTime??3e5)||c.set(n.id,o.get(n.id)===n?n:{...n,_flight:void 0,isFetching:!1,context:{}})}}t[3]=[],e._cache=c;let l=e._lifecycleEnd=Zt(n);qn(e,n),O(e,[...o.values(),...i].filter(e=>e._flight&&c.get(e.id)!==e),n),Qt(e,i,n,a,l,t)}async function Yn(e,t){let n=e._tx;for(;n&&n!==t;)t=n,await n[5],n=e._tx}function Xn(e,t,n){let r=n[1].options,i=n[2];if(!i)return e.navigate({...r,replace:!0,ignoreBlocker:!0});if(r.reloadDocument)return e.navigate({href:(i.maskedLocation??i).publicHref,reloadDocument:!0,replace:!0,ignoreBlocker:!0});i._redirects=t[1]+1,e._pendingLocation=i;let a=e.commitLocation({...i,viewTransition:r.viewTransition,replace:!0,resetScroll:r.resetScroll,hashScrollIntoView:r.hashScrollIntoView,ignoreBlocker:!0});return queueMicrotask(()=>{e._pendingLocation===i&&(e._pendingLocation=void 0)}),a}async function Zn(e,t,n,r,i){let a=n.map(e=>({...e}));kn(a);for(let t of r)On(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await Vn(e,o,r,t[0],i)}catch(t){throw O(e,a),t}if(bn(s))O(e,a),s[0]===D&&e._tx===t&&e._committed===n&&await Xn(e,t,s);else if(await Hn(e,s,t[0].signal),e._tx!==t||e._committed!==n)O(e,a);else{for(let t of a){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),On(e,n))}qn(e,a),O(e,n,a)}}async function Qn(e,t,n,r,i,a){let o=await Un(e,t[2],t[3],[t[0],t[1],e._committed,void 0,i,n,a,r]);if(bn(o)){let n=o[0]===D&&e._tx===t;if((!n||o[1].options.reloadDocument)&&Gn(e,t),O(e,t[3]),t[3]=[],!n)return;if(e._tx!==t){Gn(e,t);return}await Xn(e,t,o);return}let s=o[1];if(e._tx===t&&await Kn(e,t),e._tx!==t){Gn(e,t),O(e,s),Rn(e,o);return}let c=t[2],l=Yt(c,e.stores.resolvedLocation.get()),u=o[2];await e.startViewTransition(async()=>{if(e._tx===t&&await Kn(e,t),e._tx!==t){Gn(e,t),O(e,s),Rn(e,o);return}let n=await e.startTransition(()=>{Gn(e,t),Jn(e,t,s,a),e._tx===t&&(e.emit({type:`onLoad`,...l}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...l}))},s);e._tx===t?(u?.length&&Zn(e,t,s,u,o[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(c),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...l}),n&&e._tx===t&&e.emit({type:`onRendered`,...l})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)):Rn(e,o)})}async function $n(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),!u.signal.aborted){let t=Yt(a,r);e.emit({type:`onBeforeNavigate`,...t}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...t})}if(u.signal.aborted){await Yn(e,n);return}let f=i.href===a.href,p=u,m=e.matchRoutes(a,{_controller:u});kn(m);let h=l?c[1](m):void 0;if(h?p=l:l?.abort(),u.signal.aborted){O(e,m),await Yn(e,n);return}e._preflight=void 0;let g,_=()=>Qn(e,y,f,()=>Wn(e,y),t?.sync,h),v=t?.sync?new Promise(e=>g=e):Promise.resolve().then(_),y=[p,s,a,m,Date.now(),v.then(()=>Yn(e,y))];if(e._tx=y,n){for(let t of e.stores.matches.get()){if(e._tx!==y)break;t.isFetching&&An(e,t,!1)}n[0].abort(),O(e,n[3],y[3],!0)}e._tx===y?(e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),(h||!e._committed.length&&m[0]?.status!==`success`&&!m.some(e=>e._notFound))&&Wn(e,y),g?.(_()),await y[5]):(O(e,y[3]),y[3]=[],g?.(),await Yn(e,y))}async function er(e,t){let n=e.buildLocation(t);for(let t=0;;t++){let r=e._committed,i=new AbortController,a,o,s;try{try{a=e.matchRoutes(n,{_controller:i}),kn(a),o=(e._preloads??=new Map).set(i,a),s=await Un(e,n,a,[i,t,r,!0])}finally{o&&(o=o.delete(i),O(e,a)),i.abort()}if(!bn(s))return s[1];if(!o||s.length<3)return;n=s[2]}catch(e){Re(e)||console.error(e);return}}}var tr=`Error preloading route! ☝️`,nr=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e,this._branch=void 0;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=ot:this.parentRoute||De();let r=n?ot:t?.path;r&&r!==`/`&&(r=ke(r));let i=t?.id||r,a=n?ot:Oe((this.parentRoute.id===`__root__`?``:this.parentRoute.id)+`/`+(i??``));r===`__root__`&&(r=`/`);let o=a===`__root__`?`/`:r===void 0?this.parentRoute.fullPath:Oe(this.parentRoute.fullPath+`/`+r);this._path=r,this._id=a,this._fullPath=o,this._to=Ae(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>st({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},rr=class extends nr{constructor(e){super(e)}},k=e(r(),1),ir=k.createContext(null);function ar(e){return k.useContext(ir)}function or(e,t){let n=e.stores.location,r=new Set,i,a,o=n=>{gn(e,t,n)||(i=n,r.forEach(e=>e()))};return[()=>i??n.get(),e=>(r.size||(i=n.get(),a=n.subscribe(o).unsubscribe),r.add(e),()=>{r.delete(e),r.size||(a(),i=void 0)})]}var sr=k.createContext(void 0),cr=k.createContext(void 0);function lr({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0)n=e.nextSub;else{for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function ur(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var dr=[],fr=0,{link:pr,unlink:mr,propagate:hr,checkDirty:gr,shallowPropagate:_r}=lr({update(e){return e._update()},notify(e){dr[yr++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,Sr(e))}}),vr=0,yr=0,A,br=0;function xr(e){try{++br,e()}finally{--br||Cr()}}function Sr(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=mr(n,e)}function Cr(){if(!(br>0)){for(;vr<yr;){let e=dr[vr];dr[vr++]=void 0,e.notify()}vr=0,yr=0}}function wr(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return A!==void 0&&pr(i,A,fr),i._snapshot},subscribe(e){let t=ur(e),n={current:!1},r=Tr(()=>{i.get(),n.current?(A=void 0,t.next?.(i._snapshot)):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=A,o=t?.compare??Object.is;if(n)A=i,++fr,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{A=a,n&&(i.flags&=-5),Sr(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&gr(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&_r(e)}}else e&32&&(i.flags=e&-33);return A!==void 0&&pr(i,A,fr),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(hr(e),_r(e),Cr())}},i}function Tr(e){let t=()=>{let t=A;A=n,++fr,n.depsTail=void 0,n.flags=6;try{return e()}finally{A=t,n.flags&=-5,Sr(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&gr(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,Sr(this)}};return t(),n}var Er=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Dr=t(((e,t)=>{t.exports=Er()})),Or=t((e=>{var t=r(),n=Dr();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),kr=t(((e,t)=>{t.exports=Or()}))();function Ar(e,t){return e===t}function jr(e,t=e=>e,n){let r=n?.compare??Ar,i=(0,k.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,k.useCallback)(()=>e.get(),[e]);return(0,kr.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Mr={};function Nr(e,t){let n=k.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=me(n.current,i):i}}function Pr(e){let t=ar(),n=k.useContext(e.from?cr:sr),r=e.from??n,i=t.stores.getMatchStore(r),a=Nr(e,t),o=jr(i,e=>e?a(e):Mr);if(o!==Mr)return o;(e.shouldThrow??!0)&&De()}function Fr(e){return Pr({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function Ir(e){let{select:t,...n}=e;return Pr({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function Lr(e){return Pr({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function Rr(e){return Pr({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function zr(e){let t=ar();return k.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Br(e){return Pr({...e,select:t=>e.select?e.select(t.context):t.context})}var Vr=n();function Hr(...e){let t=k.useRef(e),n=t.current;return e.forEach((e,t)=>{ge(n[t],e,!1,!0)||(n[t]=e)}),t.current}function Ur(e,t){e.preloadRoute(t).catch(e=>{console.warn(e),console.warn(tr)})}function Wr(e,t){let n=typeof e==`string`&&xe(e);if(n)return t.has(n)?e:null}function Gr(e,t,n,r){let i=Me(e.pathname,r),a=Me(t.pathname,r);return(n?.exact?i!==a:!i.startsWith(a)||i.length!==a.length&&i[a.length]!==`/`)||(n?.includeSearch??!0)&&!ge(e.search,t.search,!n?.exact,n?.explicitUndefined)?!1:!n?.includeHash||e.hash===t.hash}function Kr(e,t,n){let r=ar(),i=k.useRef(null),a=k.useCallback(e=>{if(i.current=e,typeof t==`function`)return t(e);t&&(t.current=e)},[t]),{activeOptions:o,to:s,preload:c,preloadDelay:l,disabled:u,target:d,onClick:f,onBlur:p,onFocus:m,onMouseEnter:h,onMouseLeave:g,onTouchStart:_}=e,[v,y,b]=Hr(e.search,e.params,o),x=k.useContext(sr),S=(r.stores._linkScopes??={})[x]??=or(r,x),[C,w,ee]=k.useMemo(()=>{let t=Wr(s,r.protocolAllowlist);if(t!==void 0){let n=[t??void 0];return[e,()=>n]}let n={...e},i,a,o,c=()=>{let e=S[0]();if(e!==i){n._fromLocation=e;let t=r.buildLocation(n),o=ei(t,r,u),s=u||o&&!xe(o)?Gr(e,t,b,r.basepath):void 0;a&&a[0]===o&&a[1]===s||(a=[o,s]),i=e}return a};return[n,c,b?.includeHash&&(()=>{let e=c();return e[1]?o??=[e[0],!1]:e})]},[r,S,e.from,e.hash,e.href,s,v,y,e.state,e.mask,e.unsafeRelative,b,u]),[te,ne]=k.useSyncExternalStore(S[1],w,ee||w),re=ne===void 0&&te,ie=u||te===void 0,ae=k.useRef(!1),oe=e.reloadDocument||re||ie?!1:c??r.options.defaultPreload,se=l??r.options.defaultPreloadDelay??0,ce=k.useCallback(e=>{let t=e?.isIntersecting;t??oe===`intent`?se?i.t??=setTimeout(()=>{i.t=void 0,Ur(r,C)},se):Ur(r,C):t===!1&&Qr(i)},[r,C,i,oe,se]);k.useEffect(()=>{if(!oe)return;oe===`render`&&!ae.current&&(ae.current=!0,Ur(r,C));let e=!0,t;return oe===`viewport`&&i.current&&typeof IntersectionObserver==`function`&&(t=new IntersectionObserver(t=>{e&&ce(t.pop())},{rootMargin:`100px`}),t.observe(i.current)),()=>{e=!1,t?.disconnect(),Qr(i)}},[r,C,oe,ce,i]);let T=Xr(e,n);if(T.ref=t?a:i,re)return T.href=re,T;let le=t=>{let n=d??t.currentTarget.getAttribute(`target`);ie||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||n&&n!==`_self`||t.button!==0||(t.preventDefault(),Qr(i),r.navigate({...e,_fromLocation:C._fromLocation}))},ue=()=>{oe===`intent`&&Ur(r,C)},de=()=>{oe===`intent`&&Qr(i)};return T.onClick=$r(f,le),T.onBlur=$r(p,de),T.onFocus=$r(m,ce),T.onMouseEnter=$r(h,ce),T.onMouseLeave=$r(g,de),T.onTouchStart=$r(_,ue),Zr(T,e,ne,te,ie,n)}var qr={},Jr={className:`active`},Yr=new Set([`to`,`params`,`search`,`hash`,`state`,`mask`,`from`,`unsafeRelative`,`reloadDocument`,`preload`,`preloadDelay`,`preloadIntentProximity`,`hashScrollIntoView`,`replace`,`startTransition`,`resetScroll`,`viewTransition`,`ignoreBlocker`,`activeProps`,`inactiveProps`,`activeOptions`,`_asChild`]);function Xr(e,t){let n={};for(let r in e)Yr.has(r)||r===`type`&&t!==void 0||r===`disabled`&&t===`a`||(n[r]=e[r]);return n}function Zr(e,t,n,r,i,a){let{activeProps:o,inactiveProps:s,className:c,style:l,target:u}=t,d=le(n?o:s,{})??(n?Jr:qr);Object.assign(e,d),e.href=r,a!==`a`&&(e.disabled=i),e.target=u;let f=d.style;(l||f)&&(e.style=l&&f?{...l,...f}:l||f);let p=d.className;return(c||p)&&(e.className=c?p?`${c} ${p}`:c:p),i&&(e.role=`link`,e[`aria-disabled`]=!0),n&&(e[`data-status`]=`active`,e[`aria-current`]=`page`),e}var Qr=e=>{clearTimeout(e.t),e.t=void 0},$r=(e,t)=>e?n=>n.defaultPrevented||(e(n),n.defaultPrevented||t(n)):t;function ei(e,t,n){if(n)return;let r=e.maskedLocation??e,i=r.external?r.publicHref:t.history.createHref(r.publicHref)||`/`;if(!r.external&&i===r.publicHref||!Ce(i,t.protocolAllowlist))return i}var ti=k.memo(k.forwardRef((e,t)=>{let n=e._asChild||`a`,r=Kr(e,t,n),i=typeof e.children==`function`?e.children({isActive:r[`data-status`]===`active`}):e.children;return k.createElement(n,r,i)}),ni);function ni(e,t){let n=0;for(let r in t)if(n++,e[r]!==t[r]&&(!Yr.has(r)||!ge(e[r],t[r],!1,!0)))return!1;for(let t in e)n--;return n===0}var ri=class extends nr{constructor(e){super(e),this.useMatch=e=>Pr({...e,from:this.id}),this.useRouteContext=e=>Br({...e,from:this.id}),this.useSearch=e=>Rr({...e,from:this.id}),this.useParams=e=>Lr({...e,from:this.id}),this.useLoaderDeps=e=>Ir({...e,from:this.id}),this.useLoaderData=e=>Fr({...e,from:this.id}),this.useNavigate=()=>zr({from:this.fullPath}),this.Link=k.forwardRef((e,t)=>(0,Vr.jsx)(ti,{ref:t,from:this.fullPath,...e}))}};function ii(e){return new ri(e)}var ai=class extends rr{constructor(e){super(e),this.useMatch=e=>Pr({...e,from:this.id}),this.useRouteContext=e=>Br({...e,from:this.id}),this.useSearch=e=>Rr({...e,from:this.id}),this.useParams=e=>Lr({...e,from:this.id}),this.useLoaderDeps=e=>Ir({...e,from:this.id}),this.useLoaderData=e=>Fr({...e,from:this.id}),this.useNavigate=()=>zr({from:this.fullPath}),this.Link=k.forwardRef((e,t)=>(0,Vr.jsx)(ti,{ref:t,from:this.fullPath,...e}))}};function oi(e){return new ai(e)}var si=e=>({createMutableStore:wr,createReadonlyStore:wr,batch:xr}),ci=e=>new li(e),li=class extends $t{constructor(e){super(e,si)}},ui=`global`;function di(e,t,n){let r=new Uint8Array(5+n.length);return r[0]=e,new DataView(r.buffer).setUint32(1,t),r.set(n,5),r}function fi(e){if(e.length<5)throw Error(`terminal frame is too short`);return{kind:e[0],id:new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(1),data:e.subarray(5)}}function pi(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function mi(e,t){let n,r=()=>{if(n)return n;let r=indexedDB.open(e);return r.onupgradeneeded=()=>r.result.createObjectStore(t),n=pi(r),n.then(e=>{e.onclose=()=>n=void 0},()=>{n=void 0}),n};return(e,n)=>r().then(r=>n(r.transaction(t,e).objectStore(t)))}var hi;function gi(){return hi||=mi(`keyval-store`,`keyval`),hi}function _i(e,t=gi()){return t(`readonly`,t=>pi(t.get(e)))}function vi(e,t,n=gi()){return n(`readwrite`,n=>(n.put(t,e),pi(n.transaction)))}function yi(e,t=gi()){return t(`readwrite`,t=>(t.delete(e),pi(t.transaction)))}var bi=mi(`offsite`,`tokens`);function xi(e){return _i(e,bi)}function Si(e,t){return vi(e,t,bi)}function Ci(e){return yi(e,bi)}var wi=1e3,Ti=3e4,Ei=1e4,Di=1e4,Oi=3e3,ki=3e4,Ai=3e5,ji=[`sessions.send`,`sessions.rewind`,`sessions.fork`,`git.commit`,`git.push`,`git.pullRequest`,`git.createPullRequest`],Mi=new Set,j=new Map,Ni=0;function Pi(){window.setInterval(()=>{for(let e of j.keys())Hi(e)},Ei),document.addEventListener(`visibilitychange`,()=>{document.hidden||Fi()}),window.addEventListener(`online`,Fi)}function Fi(){for(let[e,t]of j)t.connected?Hi(e):t.timer!==void 0&&(window.clearTimeout(t.timer),t.timer=void 0,t.failures=0,Ui(e,t,0))}function Ii(e,t){if(j.has(e))return;let n={urls:t,url:t[0],socket:null,connected:!1,ping:null,timer:void 0,failures:0,pending:new Map};j.set(e,n),Ui(e,n,0)}function Li(e){let t=j.get(e);t!==void 0&&(j.delete(e),window.clearTimeout(t.timer),t.socket!==null&&(t.socket.onclose=null,t.socket.close()),qi(e,t))}function Ri(e){Mi.add(e)}function zi(e){return j.get(e)?.connected===!0}function Bi(e){let t=j.get(e);if(t===void 0)throw Error(`This machine is not connected`);return t.url}function M(e,t,n){let r=j.get(e);if(r===void 0||r.socket===null||!r.connected)return Promise.reject(Error(r===void 0?`That machine was removed`:`Not connected to ${new URL(r.url).host}; reconnecting`));Ni+=1;let i=Ni;r.socket.send(JSON.stringify({id:i,method:t,params:n}));let a=ji.includes(t)?Ai:ki;return new Promise((e,n)=>{let o=window.setTimeout(()=>{r.pending.delete(i),n(Error(`${new URL(r.url).host} did not answer ${t} within ${a/1e3} seconds`))},a);r.pending.set(i,{resolve:t=>{window.clearTimeout(o),e(t)},reject:e=>{window.clearTimeout(o),n(e)}})})}function Vi(e,t,n,r){let i=j.get(e);i!==void 0&&i.socket!==null&&i.connected&&i.socket.send(di(t,n,r))}async function Hi(e){let t=j.get(e);return t!==void 0&&(t.ping??=Ji(e,t).finally(()=>{t.ping=null}),await t.ping)}async function Ui(e,t,n){let r=t.urls[n%t.urls.length];t.url=r;let i=await Wi(e,r).catch(()=>void 0);if(j.get(e)!==t)return;if(i===`unpaired`){for(let t of Mi)t.unpaired?.(e);return}if(i===void 0){Gi(e,t,n);return}let a=i===null?``:`?${new URLSearchParams({ticket:i})}`,o=new WebSocket(`${r.replace(/^http/,`ws`)}/ws${a}`);o.binaryType=`arraybuffer`;let s=window.setTimeout(()=>o.close(),Oi);o.onopen=()=>{if(window.clearTimeout(s),t.socket!==o)o.close();else{t.connected=!0,t.failures=0;for(let t of Mi)t.open?.(e,r)}},o.onmessage=n=>{t.socket===o&&Yi(e,t,n.data)},o.onclose=()=>{window.clearTimeout(s),t.socket===o&&(t.connected?(qi(e,t),Ki(e,t,0)):Gi(e,t,n))},t.socket=o}async function Wi(e,t){let n=await xi(e),r=await fetch(`${t}/api/ticket`,{method:`POST`,headers:n===void 0?{}:{authorization:`Bearer ${n}`},signal:AbortSignal.timeout(Oi)});if(r.status===401)return`unpaired`;if(!r.ok)throw Error(await r.text());return(await r.json()).ticket}function Gi(e,t,n){if((n+1)%t.urls.length!==0)Ui(e,t,n+1);else{for(let t of Mi)t.close?.(e);Ki(e,t,n+1)}}function Ki(e,t,n){let r=Math.min(Ti,wi*2**t.failures)*(.8+Math.random()*.4);t.failures+=1,t.timer=window.setTimeout(()=>{t.timer=void 0,Ui(e,t,n)},r)}function qi(e,t){for(let e of t.pending.values())e.reject(Error(`Disconnected from ${new URL(t.url).host}`));t.pending.clear(),t.connected=!1;for(let t of Mi)t.close?.(e)}async function Ji(e,t){let n=t.socket;if(n===null||!t.connected)return!1;let r=await Promise.race([M(e,`ping`,void 0).then(()=>!0,()=>!1),new Promise(e=>window.setTimeout(()=>e(!1),Di))]);return r||t.socket!==n||!t.connected?r:(n.onclose=null,n.close(),qi(e,t),j.get(e)===t&&Ki(e,t,0),!1)}function Yi(e,t,n){if(n instanceof ArrayBuffer){let t=fi(new Uint8Array(n));for(let n of Mi)n.frame?.(e,t);return}let r=JSON.parse(String(n));if(r.type===`reply`)Xi(t,r);else if(r.type===`terminal`)for(let t of Mi)t.terminal?.(e,r.event);else for(let t of Mi)t.event?.(e,r)}function Xi(e,t){let n=e.pending.get(t.id);n!==void 0&&(e.pending.delete(t.id),`error`in t?n.reject(Error(t.error)):n.resolve(t.result))}function Zi(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}function Qi(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function $i(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function ea(e,t,n){return ta(e,t,void 0,void 0,void 0,void 0,n)}function ta(e,t,n,r,i,a,o){let s=o(e,t,n,r,i,a);if(s!==void 0)return s;if(typeof e==typeof t)switch(typeof e){case`bigint`:case`string`:case`boolean`:case`symbol`:case`undefined`:return e===t;case`number`:return e===t||Object.is(e,t);case`function`:return e===t;case`object`:return na(e,t,a,o)}return na(e,t,a,o)}function na(e,t,n,r){if(Object.is(e,t))return!0;let i=s(e),a=s(t);if(i===`[object Arguments]`&&(i=ae),a===`[object Arguments]`&&(a=ae),i!==a)return!1;switch(i){case se:return e.toString()===t.toString();case f:return $i(e.valueOf(),t.valueOf());case ee:case h:case u:return Object.is(e.valueOf(),t.valueOf());case ce:return e.source===t.source&&e.flags===t.flags;case _:return e===t}n??=new Map;let T=n.get(e),le=n.get(t);if(T!=null&&le!=null)return T===t;n.set(e,t),n.set(t,e);try{switch(i){case v:if(e.size!==t.size)return!1;for(let[i,a]of e.entries())if(!t.has(i)||!ta(a,t.get(i),i,e,t,n,r))return!1;return!0;case m:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),a=Array.from(t.values());for(let o=0;o<i.length;o++){let s=i[o],c=a.findIndex(i=>ta(s,i,void 0,e,t,n,r));if(c===-1)return!1;a.splice(c,1)}return!0}case ne:case d:case c:case o:case oe:case p:case y:case te:case C:case b:case ie:case g:if(x(e)!==x(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!ta(e[i],t[i],i,e,t,n,r))return!1;return!0;case w:return e.byteLength===t.byteLength&&na(new Uint8Array(e),new Uint8Array(t),n,r);case re:return e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset?!1:na(new Uint8Array(e),new Uint8Array(t),n,r);case S:return e.name===t.name&&e.message===t.message;case ae:{if(!(na(e.constructor,t.constructor,n,r)||Qi(e)&&Qi(t)))return!1;let i=[...Object.keys(e),...l(e)],a=[...Object.keys(t),...l(t)];if(i.length!==a.length)return!1;for(let a=0;a<i.length;a++){let o=i[a],s=e[o];if(!Object.hasOwn(t,o))return!1;let c=t[o];if(!ta(s,c,o,e,t,n,r))return!1}return!0}default:return!1}}finally{n.delete(e),n.delete(t)}}function ra(e,t){return ea(e,t,a)}var ia=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},aa=(e=>e?ia(e):ia),oa=e=>e;function sa(e,t=oa){let n=k.useSyncExternalStore(e.subscribe,k.useCallback(()=>t(e.getState()),[e,t]),()=>t(e.getInitialState()));return k.useDebugValue(n),n}var ca=e=>{let t=aa(e),n=e=>sa(t,e);return Object.assign(n,t),n},la=(e=>e?ca(e):ca);function ua(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var da=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return da(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return da(t)(e)}}}},fa=(e,t)=>(n,r,i)=>{let a={storage:ua(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(...e)=>(f(...e),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return da(u.getItem.bind(u))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},pa=`composerDrafts`,ma={text:``,images:[],files:[],settings:null},ha=mi(`offsite-drafts`,`drafts`),ga=mi(`offsite-draft-files`,`files`),_a=Zi(e=>void vi(pa,e,ha),300),va={getItem:async e=>await _i(e,ha)??null,setItem:(e,t)=>_a(t),removeItem:e=>yi(e,ha)},ya={drafts:{},stash:[]},N=la()(fa(()=>ya,{name:pa,storage:va,skipHydration:!0,version:1,migrate:()=>ya}));window.addEventListener(`pagehide`,_a.flush);function ba(){return N.persist.rehydrate()}function xa(e){return N(t=>t.drafts[e]??ma)}function Sa(e,t){let n=Ea(e),r=t(n),i=N.getState().stash;for(let e of n.files)!r.files.some(t=>t.id===e.id)&&!i.some(t=>t.files.some(t=>t.id===e.id))&&yi(e.id,ga);N.setState(t=>{let n={...t.drafts,[e]:r};return r.text===``&&r.images.length===0&&r.files.length===0&&r.settings===null&&delete n[e],{drafts:n}})}async function Ca(e){let t=crypto.randomUUID();return await vi(t,e,ga),t}async function wa(e){return await _i(e,ga)}function Ta(e){Sa(e,()=>ma)}function Ea(e){return N.getState().drafts[e]??ma}function Da(e){return N.getState().drafts[e]?.settings??null}function Oa(e,t){Sa(e,e=>({...e,settings:t}))}function ka(){return N(e=>e.stash)}function Aa(){return N.getState().stash}function ja(e){return e.text.trim()!==``||e.images.length>0||e.files.length>0}function Ma(e){let t=Ea(e);N.setState(e=>({stash:[{id:crypto.randomUUID(),createdAt:Date.now(),text:t.text,images:t.images,files:t.files},...e.stash]})),Sa(e,e=>({...e,text:``,images:[],files:[]}))}function Na(e,t,n){let r=N.getState().stash.find(e=>e.id===t);if(r===void 0)throw Error(`This stashed prompt no longer exists`);ja(Ea(e))&&Ma(e),N.setState(e=>({stash:e.stash.filter(e=>e.id!==t)}));let i=r.text.replace(/\[Image #(\d+)\]/g,(e,t)=>{let i=r.images.findIndex(e=>e.number===Number(t));return i===-1?e:`[Image #${n+i+1}]`});return Sa(e,e=>({...e,text:i,images:r.images.map((e,t)=>({...e,number:n+t+1})),files:r.files})),i}function Pa(e){let t=N.getState().stash.find(t=>t.id===e);if(t!==void 0){N.setState(t=>({stash:t.stash.filter(t=>t.id!==e)}));for(let e of t.files)yi(e.id,ga)}}function Fa(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Ia(e,t=`|`){return e.map(e=>oo(e)).join(t)}function La(e,t){return typeof t==`bigint`?t.toString():t}var Ra=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function za(e){return new Ra(e)}function Ba(e){return e==null}function Va(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Ha(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Ua(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wa(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ga(e){return Wa(e._zod.def)??e._zod.def.shape}function Ka(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ua(this,t,e),e},enumerable:!0,configurable:!0})}function qa(e,t,n){t in e?Ua(e,t,n):e[t]=n}function Ja(e,t,n,r){let i=Ga(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Ka(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):qa(e,a,r?r(n.value,a):n.value))}}function Ya(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Ka(e,n,()=>t[n]):qa(e,n,r.value))}}function P(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Xa(e){return JSON.stringify(e)}function Za(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Qa=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function $a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var eo=za(()=>{if(R.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function to(e){if($a(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return $a(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function no(e){return to(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ro=new Set([`string`,`number`,`symbol`]);function io(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ao(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function F(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 oo(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function so(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var co={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},lo={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function uo(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Ja(i,e,fo(e,t)),ao(e,P(n,{shape:i,checks:[]}))}function fo(e,t){let n=Ga(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function po(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(fo(e,t)),a={};return Ja(a,e,Reflect.ownKeys(Ga(e)).filter(e=>!i.has(e))),ao(e,P(n,{shape:a,checks:[]}))}function mo(e,t){if(!to(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ga(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ao(e,P(e._zod.def,{shape:ho(e,t)}))}function ho(e,t){let n={};return Ja(n,e,Reflect.ownKeys(Ga(e))),Ya(n,t),n}function go(e,t){if(!to(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ao(e,P(e._zod.def,{shape:ho(e,t)}))}function _o(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Ja(n,e,Reflect.ownKeys(Ga(e))),Ja(n,t,Reflect.ownKeys(Ga(t))),ao(e,P(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function vo(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(fo(t,n)):void 0,o={};return Ja(o,t,Reflect.ownKeys(Ga(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),ao(t,P(t._zod.def,{shape:o,checks:[]}))}function yo(e,t,n){let r=n?new Set(fo(t,n)):void 0,i={};return Ja(i,t,Reflect.ownKeys(Ga(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),ao(t,P(t._zod.def,{shape:i}))}function bo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function xo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function So(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Co(e){return typeof e==`string`?e:e?.message}function wo(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function To(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Eo(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Co(e.inst?._zod.def?.error?.(e))??Co(a?.(e))??Co(t?.error?.(e))??Co(n.customError?.(e))??Co(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Do=/[\uD800-\uDBFF]/;function Oo(e){let t=e.length;if(!Do.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function ko(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ao(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function jo(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Mo(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Io(e,n,r.value)}}function No(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Po(e,t,n){return No(e,t,n,!1)}function Fo(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return No(this,n,r(this))},set(e){No(this,n,e)}})}return t}function Io(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:No(this,t,n.bind(this))},set(e){No(this,t,e)}})}function Lo(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Ro,zo=!1,Bo={configurable:!0,get(){zo=!0}};function I(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Ro!==e._zod?Ro=void 0:(Ro=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Bo);let e=zo;zo=!1;try{let r=n(this);return zo?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),zo||=e,r}catch(n){throw delete this[t],zo||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Vo(e,t,n,r){let i=Lo(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Ho=`~constantCatch`;function Uo(e){let t=()=>e;return t[Ho]=!0,t}var Wo,Go={value:void 0,enumerable:!1},Ko=`captureStackTrace`in Error?Error:null;function qo(e){let t=Ko;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Ko=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function L(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Go.value=new a(r);try{Object.defineProperty(n,"_zod",Go)}finally{Go.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Mo(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?qo(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Jo=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Yo=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Wo=globalThis).__zod_globalConfig??(Wo.__zod_globalConfig={});var R=globalThis.__zod_globalConfig;function Xo(e){return e&&Object.assign(R,e),R}function Zo(){let e=this._zod;return e.message??=JSON.stringify(e.def,La,2),e.message}function Qo(e){this._zod.message=e}var $o={get:Zo,set:Qo,enumerable:!0,configurable:!0},es={value:void 0,enumerable:!1},ts=new WeakSet([Object.prototype,Error.prototype]),ns=L(`$ZodError`,(e,t)=>{e.name=`$ZodError`,es.value=t,Object.defineProperty(e,"issues",es),es.value=void 0,Object.defineProperty(e,"message",$o);let n=Object.getPrototypeOf(e);ts.has(n)||(ts.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function rs(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function is(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?rs(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function as(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function os(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function ss(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${os(e.path)}`);return t.join(`
3
- `)}function cs(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ls=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Jo;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Eo(e,o,Xo())));throw Qa(n,a?.callee??t),n}return s.value};return t},us=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Eo(e,o,Xo())));throw Qa(n,a?.callee??t),n}return s.value};return t},ds=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 Jo;return a.issues.length?fs(e,a.issues,i):{success:!0,data:a.value}};function fs(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Eo(e,n,Xo()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var ps=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?fs(e,a.issues,i):{success:!0,data:a.value}},ms=Symbol.for(`zod.compile.invalid`),hs=Symbol.for(`zod.compile.fallback`),gs=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ms)return!0;if(r.definite===!0&&n===void 0)return!1}return _s(e,t,n)});function _s(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[hs]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Jo;return a.issues.length===0}var vs=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},ys=e=>{let t=ls(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,cs(n,a))};return n},bs=e=>{let t=ls(e),n=(e,r,i,a)=>t(e,r,i,cs(n,a));return n},xs=e=>{let t=us(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,cs(n,a))};return n},Ss=e=>{let t=us(e),n=async(e,r,i,a)=>await t(e,r,i,cs(n,a));return n},Cs=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ds(e)(t,n,i)},ws=e=>(t,n,r)=>ds(e)(t,n,r),Ts=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ps(e)(t,n,i)},Es=e=>async(t,n,r)=>ps(e)(t,n,r),Ds=/^[cC][0-9a-z]{6,}$/,Os=/^[0-9a-z]+$/,ks=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,As=/^[0-9a-vA-V]{20}$/,js=/^[A-Za-z0-9]{27}$/,Ms=/^[a-zA-Z0-9_-]{21}$/;function Ns(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Ps=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fs=/^([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})$/,Is=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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ls=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rs=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function zs(){return new RegExp(Rs,`u`)}var Bs=/^(?:(?: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])$/,Vs=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,Hs=/^((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])$/,Us=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ws=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gs=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ks=/^https?$/,qs=/^\+[1-9]\d{6,14}$/,Js=`(?:(?:\\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])))`;function Ys(e){return RegExp(`^${e}$`)}var Xs=Ys(Js);function Zs(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Qs(e){return RegExp(`^${Zs(e)}$`)}function $s(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Zs({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Zs({precision:e.precision})}`:n;return RegExp(`^${Js}T(?:${r})$`)}var ec=/^[\s\S]{0,}$/,tc=/^-?\d+(?:\.\d+)?$/,nc=/^(?:true|false)$/i,rc=/^[^A-Z]*$/,ic=/^[^a-z]*$/,z=L(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ac=e=>{let t=e.value;return!Ba(t)&&t.length!==void 0},oc={number:`number`,bigint:`bigint`,object:`date`},sc=L(`$ZodCheckLessThan`,(e,t)=>{z.init(e,t);let n=oc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:oc[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),cc=L(`$ZodCheckGreaterThan`,(e,t)=>{z.init(e,t);let n=oc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:oc[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lc=L(`$ZodCheckMultipleOf`,(e,t)=>{z.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ha(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),uc=L(`$ZodCheckNumberFormat`,(e,t)=>{z.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=co[t.format];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`,continue:!1,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,inclusive:!0,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,inclusive:!0,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,inclusive:!0,inst:e,continue:!t.abort})}}),dc=L(`$ZodCheckMaxLength`,(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=ac),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Oo(r):i)<=t.maximum)return;let a=ko(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),fc=L(`$ZodCheckMinLength`,(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=ac),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Oo(r):i)>=t.minimum)return;let a=ko(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pc=L(`$ZodCheckLengthEquals`,(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=ac),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Oo(r):i;if(a===t.length)return;let o=ko(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),mc=L(`$ZodCheckStringFormat`,(e,t)=>{var n,r;z.init(e,t),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=()=>{})}),hc=L(`$ZodCheckRegex`,(e,t)=>{mc.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})}}),gc=L(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=rc,mc.init(e,t)}),_c=L(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=ic,mc.init(e,t)}),vc=L(`$ZodCheckIncludes`,(e,t)=>{z.init(e,t);let n=io(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),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})}}),yc=L(`$ZodCheckStartsWith`,(e,t)=>{z.init(e,t);let n=RegExp(`^${io(t.prefix)}.*`);t.pattern??=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})}}),bc=L(`$ZodCheckEndsWith`,(e,t)=>{z.init(e,t);let n=RegExp(`.*${io(t.suffix)}$`);t.pattern??=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})}}),xc=L(`$ZodCheckOverwrite`,(e,t)=>{z.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Sc=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
4
- `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
5
- `)}\n};`)(...Object.values(this.closed))}},Cc={major:4,minor:6,patch:7},B=L(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cc;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=bo(t),a;for(let o of n){if(o._zod.def.when){if(xo(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Jo;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(To(t.issues,n,e),i||=bo(t,n))});else{if(t.issues.length===n)continue;To(t.issues,n,e),i||=bo(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(bo(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Jo;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Jo;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Po(this,`~standard`,Ec(this))},set"~standard"(e){No(this,`~standard`,e)}}),wc=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Eo(e,t,Xo()))}:{value:e.value};async function Tc(e,t){let n={async:!0};return wc(await e._zod.run({value:t,issues:[]},n),n)}function Ec(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return wc(r,n)}catch{}return Tc(e,t)},vendor:`zod`,version:1}}var Dc=L(`$ZodString`,(e,t)=>{B.init(e,t),e._zod.pattern=t.pattern??ec,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}}),V=L(`$ZodStringFormat`,(e,t)=>{mc.init(e,t),Dc.init(e,t)}),Oc=L(`$ZodGUID`,(e,t)=>{t.pattern??=Fs,V.init(e,t)}),kc=L(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Is(e)}else t.pattern??=Is();V.init(e,t)}),Ac=L(`$ZodEmail`,(e,t)=>{t.pattern??=Ls,V.init(e,t)});function jc(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Mc(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?jc(e)||2:Nc(e,t)}function Nc(e,t){if(!t.normalize&&t.protocol?.source===Ks.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Pc=/[\t\n\r]/g;function Fc(e){return e.replace(Pc,``)}function Ic(e,t){return t.lastIndex=0,t.test(e.hostname)}function Lc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Rc=L(`$ZodURL`,(e,t)=>{V.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Mc(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Fc(r);return}t.hostname&&!Ic(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Lc(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Fc(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),zc=L(`$ZodEmoji`,(e,t)=>{t.pattern??=zs(),V.init(e,t)}),Bc=L(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Ms:Ns(t.length),V.init(e,t)}),Vc=L(`$ZodCUID`,(e,t)=>{t.pattern??=Ds,V.init(e,t)}),Hc=L(`$ZodCUID2`,(e,t)=>{t.pattern??=Os,V.init(e,t)}),Uc=L(`$ZodULID`,(e,t)=>{t.pattern??=ks,V.init(e,t)}),Wc=L(`$ZodXID`,(e,t)=>{t.pattern??=As,V.init(e,t)}),Gc=L(`$ZodKSUID`,(e,t)=>{t.pattern??=js,V.init(e,t)}),Kc=L(`$ZodISODateTime`,(e,t)=>{t.pattern??=$s(t),V.init(e,t)}),qc=L(`$ZodISODate`,(e,t)=>{t.pattern??=Xs,V.init(e,t)}),Jc=L(`$ZodISOTime`,(e,t)=>{t.pattern??=Qs(t),V.init(e,t)}),Yc=L(`$ZodISODuration`,(e,t)=>{t.pattern??=Ps,V.init(e,t)}),Xc=L(`$ZodIPv4`,(e,t)=>{t.pattern??=Bs,V.init(e,t)}),Zc=/^[0-9a-fA-F:.]+$/;function Qc(e){return Zc.test(e)?jc(`http://[${e}]`):!1}var $c=L(`$ZodIPv6`,(e,t)=>{t.pattern??=Vs,V.init(e,t),e._zod.check=n=>{Qc(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),el=L(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Hs,V.init(e,t)});function tl(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Qc(n)}var nl=L(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Us,V.init(e,t),e._zod.check=n=>{tl(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function rl(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var il=/^[0-9a-zA-Z+/]*={0,2}$/,al=L(`$ZodBase64`,(e,t)=>{t.pattern??=il,V.init(e,t),e._zod.check=n=>{rl(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),ol=/^[A-Za-z0-9_-]*$/;function sl(e){if(!ol.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return rl(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var cl=L(`$ZodBase64URL`,(e,t)=>{t.pattern??=ol,V.init(e,t),e._zod.check=n=>{sl(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ll=L(`$ZodE164`,(e,t)=>{t.pattern??=qs,V.init(e,t)});function ul(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}}var dl=L(`$ZodJWT`,(e,t)=>{V.init(e,t),e._zod.check=n=>{ul(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),fl=L(`$ZodNumber`,(e,t)=>{B.init(e,t),e._zod.pattern=tc,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:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),pl=L(`$ZodNumberFormat`,(e,t)=>{uc.init(e,t),fl.init(e,t)}),ml=L(`$ZodBoolean`,(e,t)=>{B.init(e,t),e._zod.pattern=nc,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}}),hl=L(`$ZodUnknown`,(e,t)=>{B.init(e,t),e._zod.parse=e=>e}),gl=L(`$ZodNever`,(e,t)=>{B.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function _l(e,t){let n=wo(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of wo(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,To(n.issues,t,e),n}}return i(n,a)}}var vl=e=>Array.isArray(e)?e.length:-1;function yl(e,t,n){e.issues.length&&t.issues.push(...So(n,e.issues)),t.value[n]=e.value}var bl=L(`$ZodArray`,(e,t)=>{B.init(e,t);let n=R.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>yl(t,r,e)));else if(yl(c,r,e),s&&c.issues.length!==0&&bo(c))break}return o.length?Promise.all(o).then(()=>r):r},_l(e,vl)});function xl(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...So(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Sl=[];function Cl(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Sl,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=so(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function wl(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(bo(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>xl(e,n,i,t,d,f))):xl(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Tl=L(`$ZodObject`,(e,t)=>{B.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=za(()=>Cl(t));I(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Ua(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=$a,o=t.catchall,s,c=R.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(bo(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>xl(n,t,e,r,a,o))):xl(s,t,e,r,a,o)}return o?wl(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),El=L(`$ZodObjectJIT`,(e,t)=>{Tl.init(e,t);let n=e._zod.parse,r=za(()=>Cl(t)),i=R.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Sc([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
6
- let ${e}_ab = false;
7
- for (let i = 0; i < ${e}.issues.length; i++) {
8
- const iss = ${e}.issues[i];
9
- iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
10
- payload.issues.push(iss);
11
- if (iss.continue !== true) ${e}_ab = true;
12
- }
13
- if (${e}_ab && ctx && ctx.abortEarly) {
14
- payload.value = newResult;
15
- return payload;
16
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Xa(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
17
- const ${n}_present = ${i};
18
- if (!${n}.issues.length || ${n}_present) {
19
- if (${n}.issues.length) {${c(n,r)}
20
- }
21
-
22
- if (${e}) {
23
- newResult[${r}] = ${n}.value;
24
- }
25
- }
26
-
27
- `)}else f?(o.write(`
28
- if (${n}.issues.length) {${c(n,r)}
29
- }
30
- `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
31
- if (${n}.value !== undefined || ${i}) {
32
- newResult[${r}] = ${n}.value;
33
- }
34
- `)):o.write(`
35
- const ${n}_present = ${i};
36
- if (${n}.issues.length) {${c(n,r)}
37
- }
38
- if (!${n}_present && !${n}.issues.length) {
39
- payload.issues.push({
40
- code: "invalid_type",
41
- expected: "nonoptional",
42
- input: undefined,
43
- path: [${r}]
44
- });
45
- if (ctx && ctx.abortEarly) {
46
- payload.value = newResult;
47
- return payload;
48
- }
49
- }
50
-
51
- if (${n}_present) {
52
- newResult[${r}] = ${n}.value;
53
- }
54
-
55
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=$a,c=!R.jitless,l=c&&eo.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?wl([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Dl(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!bo(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Eo(e,r,Xo())))}),t)}var Ol=L(`$ZodUnion`,(e,t)=>{B.init(e,t),I(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),I(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),I(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),I(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Va(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Dl(t,r,e,i)):Dl(o,r,e,i)}});function kl(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Al=L(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ol.init(e,t);let n=e._zod.parse;I(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||Ua(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Wa(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=za(()=>kl(t));e._zod.parse=(i,a)=>{let o=i.value;if(!$a(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),jl=L(`$ZodIntersection`,(e,t)=>{B.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);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Nl(e,t,n)):Nl(e,i,a)}});function Ml(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(to(e)&&to(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ml(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=Ml(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 Nl(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ml(t.value,n.value);if(!c.valid){if(bo(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Pl=L(`$ZodEnum`,(e,t)=>{B.init(e,t);let n=Fa(t.entries),r=new Set(n);e._zod.values=r,I(e,`pattern`,e=>{let t=Fa(e.def.entries).filter(e=>ro.has(typeof e));return RegExp(t.length?`^(${t.map(e=>io(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Fl=L(`$ZodLiteral`,(e,t)=>{B.init(e,t);let n=new Set(t.values);e._zod.values=n,I(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?io(e):e?io(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Il=L(`$ZodTransform`,(e,t)=>{B.init(e,t),e._zod.optin=`optional`,R.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Yo(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Jo;return n.value=i,n}});function Ll(e,t){return e.value=t.issues.length?void 0:t.value,e}var Rl=L(`$ZodOptional`,(e,t)=>{B.init(e,t),I(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,I(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),I(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Va(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ll(e,t)):Ll(e,r)}return t.innerType._zod.run(e,n)}}),zl=L(`$ZodExactOptional`,(e,t)=>{Rl.init(e,t),I(e,`values`,e=>e.def.innerType._zod.values),I(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Bl=L(`$ZodNullable`,(e,t)=>{B.init(e,t),I(e,`optin`,e=>e.def.innerType._zod.optin),I(e,`optout`,e=>e.def.innerType._zod.optout),I(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Va(t.source)}|null)$`):void 0}),I(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Vl=L(`$ZodDefault`,(e,t)=>{B.init(e,t),e._zod.optin=`defaulted`,I(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(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=>Hl(e,t)):Hl(r,t)}});function Hl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ul=L(`$ZodPrefault`,(e,t)=>{B.init(e,t),e._zod.optin=`defaulted`,I(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Wl=L(`$ZodNonOptional`,(e,t)=>{B.init(e,t),I(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].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=>Gl(t,e)):Gl(i,e)}});function Gl(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Kl(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Eo(e,r,Xo()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var ql=L(`$ZodCatch`,(e,t)=>{B.init(e,t),I(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),I(e,`optout`,e=>e.def.innerType._zod.optout),I(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Kl(e,r,t,n)):Kl(e,r,t,n)}}),Jl=L(`$ZodPipe`,(e,t)=>{B.init(e,t),I(e,`values`,e=>e.def.in._zod.values),I(e,`optin`,e=>e.def.in._zod.optin),I(e,`optout`,e=>e.def.out._zod.optout),I(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Yl(e,t.in,n)):Yl(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Yl(e,t.out,n)):Yl(r,t.out,n)}});function Yl(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Xl=L(`$ZodReadonly`,(e,t)=>{B.init(e,t),I(e,`propValues`,e=>e.def.innerType._zod.propValues),I(e,`values`,e=>e.def.innerType._zod.values),I(e,`optin`,e=>e.def.innerType?._zod?.optin),I(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Zl):Zl(r)}});function Zl(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Ql=L(`$ZodCustom`,(e,t)=>{z.init(e,t),B.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=>$l(t,n,r,e));$l(i,n,r,e)}});function $l(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(jo(e))}}var eu=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},tu=`~memo`,nu=[];function ru(e){return typeof e==`object`&&!!e}function iu(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var au=new WeakMap,ou=0,su=1,cu=2;function lu(e,t,n){let r=au.get(e);if(r!==void 0)return r?cu:ou;if(t.has(e))return cu;t.add(e);let i=ou,a=e=>{if(i!==cu&&e?._zod){let r=lu(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=ou;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?su:o.value?._zod?lu(o.value,t,n):ou;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Wa(c);s(e?o(e,!0):su),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?lu(r,t,!1):su);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),uu(e,i)}function uu(e,t){return t!==su&&au.set(e,t===cu),t}function du(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var fu,pu=[],mu={alloc(e,t,n){let r=fu;if(!r)return n;fu=void 0;let i={value:n,issues:null};return r.set(t.value,i),pu.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&gu(n,e.value))throw new eu;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=lu(e,new Set,!1);if(i===ou)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===cu||r?n=!0:r=!0}let l=s.value;if(!ru(l))return t(s,c);let u=c[tu];u||(u={buckets:new WeakMap,backEdges:void 0},c[tu]=u);let d;i===c?d=a:(d=du(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...iu(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;fu=d;let p=pu.length,m=t(s,c);fu=void 0;let h=pu.length>p?pu.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?iu(e.issues):nu),e)):(h&&(h.issues=m.issues.length?iu(m.issues):nu),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function hu(){return mu}function gu(e,t){let n=e[tu]?.backEdges;return n!==void 0&&ru(t)&&n.has(t)}var _u=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Ao(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${oo(e.values[0])}`:`Invalid option: expected one of ${Ia(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Ia(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function vu(){return{localeError:_u()}}var yu,bu=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&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)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function xu(){return new bu}(yu=globalThis).__zod_globalRegistry??(yu.__zod_globalRegistry=xu());var Su=globalThis.__zod_globalRegistry;function Cu(e){return e.checks&&=[...e.checks],e}function wu(e,t){return new e(Cu({type:`string`,...F(t)}))}function Tu(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...F(t)})}function Eu(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...F(t)})}function Du(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...F(t)})}function Ou(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...F(t)})}function ku(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...F(t)})}function Au(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...F(t)})}function ju(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...F(t)})}function Mu(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...F(t)})}function Nu(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...F(t)})}function Pu(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...F(t)})}function Fu(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...F(t)})}function Iu(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...F(t)})}function Lu(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...F(t)})}function Ru(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...F(t)})}function zu(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...F(t)})}function Bu(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...F(t)})}function Vu(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...F(t)})}function Hu(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...F(t)})}function Uu(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...F(t)})}function Wu(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...F(t)})}function Gu(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...F(t)})}function Ku(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...F(t)})}function qu(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...F(t)})}function Ju(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...F(t)})}function Yu(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...F(t)})}function Xu(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...F(t)})}function Zu(e,t){return new e(Cu({type:`number`,checks:[],...F(t)}))}function Qu(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...F(t)})}function $u(e,t){return new e({type:`boolean`,...F(t)})}function ed(e){return new e({type:`unknown`})}function td(e,t){return new e({type:`never`,...F(t)})}function nd(e,t){return new sc({check:`less_than`,...F(t),value:e,inclusive:!1})}function rd(e,t){return new sc({check:`less_than`,...F(t),value:e,inclusive:!0})}function id(e,t){return new cc({check:`greater_than`,...F(t),value:e,inclusive:!1})}function ad(e,t){return new cc({check:`greater_than`,...F(t),value:e,inclusive:!0})}function od(e,t){return new lc({check:`multiple_of`,...F(t),value:e})}function sd(e,t){return new dc({check:`max_length`,...F(t),maximum:e})}function cd(e,t){return new fc({check:`min_length`,...F(t),minimum:e})}function ld(e,t){return new pc({check:`length_equals`,...F(t),length:e})}function ud(e,t){return new hc({check:`string_format`,format:`regex`,...F(t),pattern:e})}function dd(e){return new gc({check:`string_format`,format:`lowercase`,...F(e)})}function fd(e){return new _c({check:`string_format`,format:`uppercase`,...F(e)})}function pd(e,t){return new vc({check:`string_format`,format:`includes`,...F(t),includes:e})}function md(e,t){return new yc({check:`string_format`,format:`starts_with`,...F(t),prefix:e})}function hd(e,t){return new bc({check:`string_format`,format:`ends_with`,...F(t),suffix:e})}function gd(e){return new xc({check:`overwrite`,tx:e})}function _d(e){return gd(t=>t.normalize(e))}function vd(){return gd(e=>e.trim())}function yd(){return gd(e=>e.toLowerCase())}function bd(){return gd(e=>e.toUpperCase())}function xd(){return gd(e=>Za(e))}function Sd(e,t,n){return new e({type:`array`,element:t,...F(n)})}function Cd(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...F(n)})}function wd(e,t){let n=Td(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(jo(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(jo(r))}},e(t.value,t)),t);return n}function Td(e,t){let n=new z({check:`custom`,...F(t)});return n._zod.check=e,n}function Ed(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ua(e,t,n[t]);return e}function Dd(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Su,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Od(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function H(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,H(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ed(o.schema,c),t.io===`input`&&U(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function kd(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ad(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${kd(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+kd(a)}},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(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
56
-
57
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function jd(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;jd(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Md=new Set([`type`,`properties`,`required`,`additionalProperties`]),Nd=[`oneOf`,`anyOf`];function Pd(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Fd(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Md.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Pd(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ua(n,r,e.length===1?e[0]:Fd(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Pd(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Id(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Md)if(t in e)return;let n=t.filter(e=>Nd.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Fd(t);else{let e=n[0],i=Nd.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Fd([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ed(e,r))}function Ld(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ed(i,s),Ed(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())jd(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Id(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Ed(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ua(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:zd(t,`input`,e.processors),output:zd(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function U(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return U(r.element,n);if(r.type===`set`)return U(r.valueType,n);if(r.type===`lazy`)return U(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return U(r.innerType,n);if(r.type===`intersection`)return U(r.left,n)||U(r.right,n);if(r.type===`record`||r.type===`map`)return U(r.keyType,n)||U(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:U(r.in,n)||U(r.out,n);if(r.type===`object`){for(let e in r.shape)if(U(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(U(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(U(e,n))return!0;return!!(r.rest&&U(r.rest,n))}return!1}var Rd=(e,t={})=>n=>{let r=Dd({...n,processors:t});return H(e,r),Ad(r,e),Ld(r,e)},zd=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Dd({...i??{},target:a,io:t,processors:n});return H(e,o),Ad(o,e),Ld(o,e)},Bd=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Vd=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Hd=(e,t)=>{Bd(e,`minimum`,t),Vd(e,`maximum`,t)},Ud=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Wd=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Gd=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Kd=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},qd=(e,t)=>Bd(e,`minimum`,t.minimum),Jd=(e,t)=>Vd(e,`maximum`,t.maximum),Yd=e=>(t,n)=>{Kd(t,n.format);let[r,i]=e[n.format];Bd(t,`minimum`,r),Vd(t,`maximum`,i)},Xd={greater_than:(e,t)=>Bd(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Vd(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ud(e,t.value),number_format:Yd(co),bigint_format:Yd(lo),min_length:qd,max_length:Jd,length_equals:(e,t)=>Hd(e,t.length),min_size:qd,max_size:Jd,size_equals:(e,t)=>Hd(e,t.size),string_format:(e,t)=>{Kd(e,t.format),t.pattern&&Wd(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Gd(e,t.mime)};function Zd(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Xd[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Bd(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Bd(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Vd(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Vd(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ud(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Gd(t,i.mime);for(let e of i.patterns??[])Wd(t,e);return t}var Qd={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},$d=new Map([[il,Ws],[ol,Gs]]),ef=e=>$d.get(e)??e,tf=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Zd(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Qd[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(ef);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},nf=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Zd(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Od(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},rf=(e,t,n,r)=>{n.type=`boolean`},af=(e,t,n,r)=>{n.not={}},of=(e,t,n,r)=>{let i=e._zod.def,a=Fa(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},sf=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Od(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Od(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},cf=(e,t,n,r)=>{Od(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},lf=(e,t,n,r)=>{Od(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},uf=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Zd(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=H(a.element,t,{...r,path:[...r.path,`items`]})};function df(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?df(t.out):t.type===`catch`?df(t.innerType):e._zod.optin}var ff=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Od(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ua(i.properties,e,H(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?df(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=H(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},pf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>H(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},mf=(e,t,n,r)=>{let i=e._zod.def,a=H(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=H(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},hf=(e,t,n,r)=>{let i=e._zod.def,a=H(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},gf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_f=Symbol();function vf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Od(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),_f):JSON.parse(o)}var yf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=vf(i.defaultValue,e,t,n,r);o!==_f&&(n.default=o)},bf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=vf(i.defaultValue,e,t,n,r);o!==_f&&(n._prefault=o)},xf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Od(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Sf=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;H(o,t,r);let s=t.seen.get(e);s.ref=o},Cf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},wf=(e,t,n,r)=>{let i=e._zod.def;H(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Tf=new WeakSet([Object.prototype,Error.prototype]);function Ef(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var W=L(`ZodError`,(e,t)=>{ns.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Tf.has(n)||(Tf.add(n),Ef(n,`format`,e=>t=>as(e,t)),Ef(n,`flatten`,e=>t=>is(e,t)),Ef(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,La,2)}),Ef(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,La,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Df=ls(W),Of=us(W),kf=ds(W),Af=ps(W),jf=ys(W),Mf=bs(W),Nf=xs(W),Pf=Ss(W),Ff=Cs(W),If=ws(W),Lf=Ts(W),Rf=Es(W);function zf(){R.localeError||Xo(vu())}function Bf(){R.memoizer||Xo({memoizer:hu()})}var G=L(`ZodType`,(e,t)=>(zf(),B.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(P(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ao(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(im(e,t))},superRefine(e,t){return this.check(am(e,t))},overwrite(e){return this.check(gd(e))},optional(){return Bp(this)},exactOptional(){return Hp(this)},nullable(){return Wp(this)},nullish(){return Bp(Wp(this))},nonoptional(e){return Xp(this,e)},array(){return Cp(this)},or(e){return Op([this,e])},and(e){return Mp(this,e)},transform(e){return em(this,Rp(e))},default(e){return Kp(this,e)},prefault(e){return Jp(this,e)},catch(e){return Qp(this,e)},pipe(e){return em(this,e)},readonly(){return nm(this)},describe(e){let t=this.clone();return Su.add(t,{description:e}),t},meta(...e){if(e.length===0)return Su.get(this);let t=this.clone();return Su.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Po(this,`~standard`,{...Ec(this),jsonSchema:{input:zd(this,`input`),output:zd(this,`output`)}})},set"~standard"(e){No(this,`~standard`,e)},parse:function e(t,n){return Df(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Of(this,t,n,{callee:e})},safeParse(e,t){return kf(this,e,t)},async safeParseAsync(e,t){return Af(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){No(this,`spa`,e)},validate(e,t){return gs(this,e,t)},validateAsync(e,t){return vs(this,e,t)},encode:function e(t,n){return jf(this,t,n,{callee:e})},decode:function e(t,n){return Mf(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Nf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Pf(this,t,n,{callee:e})},safeEncode(e,t){return Ff(this,e,t)},safeDecode(e,t){return If(this,e,t)},async safeEncodeAsync(e,t){return Lf(this,e,t)},async safeDecodeAsync(e,t){return Rf(this,e,t)},toJSONSchema(e){return Rd(this,{})(e)},get description(){return Su.get(this)?.description},get _def(){return this._zod.def}}),Vf=L(`_ZodString`,(e,t)=>{Dc.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tf(e,t,n,r)},Fo({format:e=>Zd(e).format??null,minLength:e=>Zd(e).minimum??null,maxLength:e=>Zd(e).maximum??null},{regex(...e){return this.check(ud(...e))},includes(...e){return this.check(pd(...e))},startsWith(...e){return this.check(md(...e))},endsWith(...e){return this.check(hd(...e))},min(...e){return this.check(cd(...e))},max(...e){return this.check(sd(...e))},length(...e){return this.check(ld(...e))},nonempty(...e){return this.check(cd(1,...e))},lowercase(e){return this.check(dd(e))},uppercase(e){return this.check(fd(e))},trim(){return this.check(vd())},normalize(...e){return this.check(_d(...e))},toLowerCase(){return this.check(yd())},toUpperCase(){return this.check(bd())},slugify(){return this.check(xd())}})),Hf=L(`ZodString`,(e,t)=>{Dc.init(e,t),Vf.init(e,t)},{email(e){return this.check(Tu(Jf,e))},url(e){return this.check(ju(Zf,e))},jwt(e){return this.check(Ku(fp,e))},emoji(e){return this.check(Mu(Qf,e))},guid(e){return this.check(Eu(Yf,e))},uuid(e){return this.check(Du(Xf,e))},uuidv4(e){return this.check(Ou(Xf,e))},uuidv6(e){return this.check(ku(Xf,e))},uuidv7(e){return this.check(Au(Xf,e))},nanoid(e){return this.check(Nu($f,e))},cuid(e){return this.check(Pu(ep,e))},cuid2(e){return this.check(Fu(tp,e))},ulid(e){return this.check(Iu(np,e))},base64(e){return this.check(Uu(lp,e))},base64url(e){return this.check(Wu(up,e))},xid(e){return this.check(Lu(rp,e))},ksuid(e){return this.check(Ru(ip,e))},ipv4(e){return this.check(zu(ap,e))},ipv6(e){return this.check(Bu(op,e))},cidrv4(e){return this.check(Vu(sp,e))},cidrv6(e){return this.check(Hu(cp,e))},e164(e){return this.check(Gu(dp,e))},datetime(e){return this.check(qu(Wf,e))},date(e){return this.check(Ju(Gf,e))},time(e){return this.check(Yu(Kf,e))},duration(e){return this.check(Xu(qf,e))}});function Uf(e){return wu(Hf,e)}var K=L(`ZodStringFormat`,(e,t)=>{V.init(e,t),Vf.init(e,t)}),Wf=L(`ZodISODateTime`,(e,t)=>{Kc.init(e,t),K.init(e,t)}),Gf=L(`ZodISODate`,(e,t)=>{qc.init(e,t),K.init(e,t)}),Kf=L(`ZodISOTime`,(e,t)=>{Jc.init(e,t),K.init(e,t)}),qf=L(`ZodISODuration`,(e,t)=>{Yc.init(e,t),K.init(e,t)}),Jf=L(`ZodEmail`,(e,t)=>{Ac.init(e,t),K.init(e,t)}),Yf=L(`ZodGUID`,(e,t)=>{Oc.init(e,t),K.init(e,t)}),Xf=L(`ZodUUID`,(e,t)=>{kc.init(e,t),K.init(e,t)}),Zf=L(`ZodURL`,(e,t)=>{Rc.init(e,t),K.init(e,t)}),Qf=L(`ZodEmoji`,(e,t)=>{zc.init(e,t),K.init(e,t)}),$f=L(`ZodNanoID`,(e,t)=>{Bc.init(e,t),K.init(e,t)}),ep=L(`ZodCUID`,(e,t)=>{Vc.init(e,t),K.init(e,t)}),tp=L(`ZodCUID2`,(e,t)=>{Hc.init(e,t),K.init(e,t)}),np=L(`ZodULID`,(e,t)=>{Uc.init(e,t),K.init(e,t)}),rp=L(`ZodXID`,(e,t)=>{Wc.init(e,t),K.init(e,t)}),ip=L(`ZodKSUID`,(e,t)=>{Gc.init(e,t),K.init(e,t)}),ap=L(`ZodIPv4`,(e,t)=>{Xc.init(e,t),K.init(e,t)}),op=L(`ZodIPv6`,(e,t)=>{$c.init(e,t),K.init(e,t)}),sp=L(`ZodCIDRv4`,(e,t)=>{el.init(e,t),K.init(e,t)}),cp=L(`ZodCIDRv6`,(e,t)=>{nl.init(e,t),K.init(e,t)}),lp=L(`ZodBase64`,(e,t)=>{al.init(e,t),K.init(e,t)}),up=L(`ZodBase64URL`,(e,t)=>{cl.init(e,t),K.init(e,t)}),dp=L(`ZodE164`,(e,t)=>{ll.init(e,t),K.init(e,t)}),fp=L(`ZodJWT`,(e,t)=>{dl.init(e,t),K.init(e,t)}),pp=L(`ZodNumber`,(e,t)=>{fl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nf(e,t,n,r),e.isFinite=!0},Fo({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Zd(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Zd(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Zd(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Zd(e).format??null},{gt(e,t){return this.check(id(e,t))},gte(e,t){return this.check(ad(e,t))},min(e,t){return this.check(ad(e,t))},lt(e,t){return this.check(nd(e,t))},lte(e,t){return this.check(rd(e,t))},max(e,t){return this.check(rd(e,t))},int(e){return this.check(gp(e))},safe(e){return this.check(gp(e))},positive(e){return this.check(id(0,e))},nonnegative(e){return this.check(ad(0,e))},negative(e){return this.check(nd(0,e))},nonpositive(e){return this.check(rd(0,e))},multipleOf(e,t){return this.check(od(e,t))},step(e,t){return this.check(od(e,t))},finite(){return this}}));function mp(e){return Zu(pp,e)}var hp=L(`ZodNumberFormat`,(e,t)=>{pl.init(e,t),pp.init(e,t)});function gp(e){return Qu(hp,e)}var _p=L(`ZodBoolean`,(e,t)=>{ml.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rf(e,t,n,r)});function q(e){return $u(_p,e)}var vp=L(`ZodUnknown`,(e,t)=>{hl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function yp(){return ed(vp)}var bp=L(`ZodNever`,(e,t)=>{gl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>af(e,t,n,r)});function xp(e){return td(bp,e)}var Sp=L(`ZodArray`,(e,t)=>{Bf(),bl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uf(e,t,n,r),e.element=t.element},{min(e,t){return this.check(cd(e,t))},nonempty(e){return this.check(cd(1,e))},max(e,t){return this.check(sd(e,t))},length(e,t){return this.check(ld(e,t))},unwrap(){return this.element}});function Cp(e,t){return Sd(Sp,e,t)}var wp=L(`ZodObject`,(e,t)=>{Bf(),El.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ff(e,t,n,r),Vo(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Pp(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(P(this._zod.def,{catchall:e}))},passthrough(){return this.clone(P(this._zod.def,{catchall:yp()}))},loose(){return this.clone(P(this._zod.def,{catchall:yp()}))},strict(){return this.clone(P(this._zod.def,{catchall:xp()}))},strip(){return this.clone(P(this._zod.def,{catchall:void 0}))},extend(e){return mo(this,e)},safeExtend(e){return go(this,e)},merge(e){return _o(this,e)},pick(e){return uo(this,e)},omit(e){return po(this,e)},partial(...e){return vo(zp,this,e[0])},exactPartial(...e){return vo(Vp,this,e[0],`exactPartial`)},required(...e){return yo(Yp,this,e[0])}});function Tp(e,t){return new wp({type:`object`,shape:e??{},...F(t)})}function Ep(e,t){return new wp({type:`object`,shape:e,catchall:xp(),...F(t)})}var Dp=L(`ZodUnion`,(e,t)=>{Ol.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pf(e,t,n,r),e.options=t.options});function Op(e,t){return new Dp({type:`union`,options:e,...F(t)})}var kp=L(`ZodDiscriminatedUnion`,(e,t)=>{Dp.init(e,t),Al.init(e,t)});function Ap(e,t,n){return new kp({type:`union`,options:t,discriminator:e,...F(n)})}var jp=L(`ZodIntersection`,(e,t)=>{jl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mf(e,t,n,r)});function Mp(e,t){return new jp({type:`intersection`,left:e,right:t})}var Np=L(`ZodEnum`,(e,t)=>{Pl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>of(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 Np({...t,checks:[],...F(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 Np({...t,checks:[],...F(r),entries:i})}});function Pp(e,t){return new Np({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...F(t)})}var Fp=L(`ZodLiteral`,(e,t)=>{Fl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sf(e,t,n,r),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 Ip(e,t){return new Fp({type:`literal`,values:Array.isArray(e)?e:[e],...F(t)})}var Lp=L(`ZodTransform`,(e,t)=>{Bf(),Il.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lf(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Yo(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(jo(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(jo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Rp(e){return new Lp({type:`transform`,transform:e})}var zp=L(`ZodOptional`,(e,t)=>{Rl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bp(e){return new zp({type:`optional`,innerType:e})}var Vp=L(`ZodExactOptional`,(e,t)=>{zl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hp(e){return new Vp({type:`optional`,innerType:e})}var Up=L(`ZodNullable`,(e,t)=>{Bl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wp(e){return new Up({type:`nullable`,innerType:e})}var Gp=L(`ZodDefault`,(e,t)=>{Vl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kp(e,t){return new Gp({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():no(t)}})}var qp=L(`ZodPrefault`,(e,t)=>{Ul.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jp(e,t){return new qp({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():no(t)}})}var Yp=L(`ZodNonOptional`,(e,t)=>{Wl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xp(e,t){return new Yp({type:`nonoptional`,innerType:e,...F(t)})}var Zp=L(`ZodCatch`,(e,t)=>{ql.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qp(e,t){return new Zp({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Uo(t)})}var $p=L(`ZodPipe`,(e,t)=>{Jl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sf(e,t,n,r),e.in=t.in,e.out=t.out});function em(e,t){return new $p({type:`pipe`,in:e,out:t})}var tm=L(`ZodReadonly`,(e,t)=>{Xl.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nm(e){return new tm({type:`readonly`,innerType:e})}var rm=L(`ZodCustom`,(e,t)=>{Ql.init(e,t),G.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cf(e,t,n,r)});function im(e,t={}){return Cd(rm,e,t)}function am(e,t){return wd(e,t)}var om=`no-project`;function sm(){return J.parseLocation(J.history.location).search}function cm(){let e=/^\/terminal\/([^/]+)$/.exec(J.history.location.pathname);if(e===null)return null;let t=decodeURIComponent(e[1]);return Y().machines.some(e=>e.id===t)?t:null}function lm(){let e=Lr({strict:!1,select:e=>e.machine??null});return Ih(t=>t.machines.some(t=>t.id===e)?e:null)}function um(){return sm().project??`global`}function dm(){return Rr({strict:!1,select:e=>e.project??`global`})}function fm(e){let t=sm();return t.machine===void 0||t.project===void 0||!e.includes(t.machine)?null:{machine:t.machine,projectId:t.project,sessionId:t.session??null}}function pm(e){Am({...sm(),...e},!0,J.history.location.state.layer)}function mm(e,t){Am({...sm(),...e},!1,t)}function hm(e){let t=Y();if(t.selection===null)throw Error(`no project is open to show the browser in`);if(e.startsWith(`file:`)){pm({panel:`browser`,browse:decodeURIComponent(new URL(e).pathname)});return}if(/^https?:\/\//i.test(e)||e.startsWith(`/`)||/^[a-z]:[\\/]/i.test(e)){pm({panel:`browser`,browse:e});return}let n=Lh(t,t.selection.machine,t.selection.projectId);if(n===void 0)throw Error(`project ${t.selection.projectId} is not listed`);pm({panel:`browser`,browse:`${n.path}/${e}`})}function gm(e,t){J.history.location.state.layer===e?J.history.back():t()}var _m=[],vm=!1,ym=!1,bm=!1;function xm(){return J.history.location.state.guard===!0}function Sm(){return bm}function Cm(){vm||(_m.length>0&&!xm()?J.history.push(J.history.location.href,{guard:!0}):_m.length===0&&xm()&&(vm=!0,J.history.back()))}function wm(){ym=xm(),J.history.subscribe(({action:e})=>{let t=ym;ym=xm(),e.type===`PUSH`||e.type===`REPLACE`?bm=!1:(bm=t,bm&&vm?vm=!1:bm&&_m.at(-1)?.(),setTimeout(Cm))}),setTimeout(Cm)}function Tm(e,t){let n=(0,k.useEffectEvent)(t);(0,k.useEffect)(()=>{if(!e)return;function t(){n()}return _m.push(t),setTimeout(Cm),()=>{_m.splice(_m.indexOf(t),1),setTimeout(Cm)}},[e])}var Em=`terminalProjects`;function Dm(){return JSON.parse(localStorage.getItem(Em)??`[]`)}function Om(){let e=sm();if(cm()!==null||e.machine===void 0||e.project===void 0||e.session===void 0)return;let t=`${e.machine} ${e.project}`,n=Dm().filter(e=>e!==t);localStorage.setItem(Em,JSON.stringify(e.bottom===`terminal`?[...n,t]:n))}function km(e=!1){let t=Y().selection;if(t===null){Am({project:cm()===null?void 0:sm().project},!0,J.history.location.state.layer);return}let n=sm(),r=n.machine===t.machine&&n.project===t.projectId&&n.session===void 0&&(t.sessionId===null||Y().loaded),i=Dm().includes(`${t.machine} ${t.projectId}`),a={machine:t.machine,project:t.projectId,session:t.sessionId??void 0,bottom:r?n.bottom:t.sessionId!==null&&i?`terminal`:void 0};if(cm()!==null){J.navigate({to:`/`,search:a,replace:e||xm(),state:{layer:`chat`},resetScroll:!1});return}let o=n.machine===a.machine&&n.project===a.project&&n.session===a.session,s=n.machine!==void 0&&n.session===void 0&&a.session===void 0;e||o||r||s?pm(a):mm(a,`chat`)}function Am(e,t,n){let r=cm(),i=xm(),a=t&&i?{layer:n,guard:i}:{layer:n};r===null?J.navigate({to:`/`,search:e,replace:t||i,state:a,resetScroll:!1}):J.navigate({to:`/terminal/$machine`,params:{machine:r},search:e,replace:t||i,state:a,resetScroll:!1})}function jm(e,t=null,n=!1){let r=Z(Y(),e.machine),i=Y().selection;localStorage.setItem(`lastProject`,JSON.stringify({machine:e.machine,projectId:e.projectId})),X({selection:e,loaded:e.sessionId===null,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],settings:e.sessionId===null?i?.sessionId===null&&i.machine===e.machine?Y().settings:ug(r):Da(Hh(e))??lg(r.composer,Y().sessions.find(t=>t.machine===e.machine&&t.id===e.sessionId)?.provider??r.composer?.provider??`claude`),context:null,replacing:null,paletteOpen:!1,unseen:Y().unseen.filter(t=>e.sessionId===null||t!==lh(e.machine,e.sessionId))}),km(n),mg(e.machine),e.sessionId!==null&&r.status===`online`&&Mm(e.machine,e.projectId,e.sessionId,!0,t)}function Mm(e,t,n,r,i){M(e,`sessions.open`,{projectId:t,sessionId:n,opened:r,query:i}).then(t=>{t===null||Y().sessions.some(n=>n.machine===e&&n.id===t.id)||X({sessions:[...Y().sessions,{...t,machine:e}]})}).catch($)}function Nm(){X({selection:null,loaded:!1,items:[],earlier:[],before:null,partial:``,requests:[],queue:[],context:null}),km()}function Pm(){let e=Y().machines,t=localStorage.getItem(`lastTerminal`);return t!==null&&e.some(e=>e.id===t)?t:e.at(0)?.id??null}function Fm(e,t,n=!1){jm({machine:e,projectId:Lh(Y(),e,t)?.scratch===!0?om:t,sessionId:null},null,n)}function Im(){let e=Y(),t=localStorage.getItem(`lastProject`),n=t===null?null:JSON.parse(t),r=e.machines.filter(e=>e.system?.scratchAvailable===!0);if(n!==null&&n.projectId===`no-project`&&r.some(e=>e.id===n.machine))return n;let i=(n===null?void 0:e.projects.find(e=>e.machine===n.machine&&e.id===n.projectId))??e.projects.find(e=>!e.scratch);return i===void 0?r.length>0?{machine:r[0].id,projectId:om}:null:{machine:i.machine,projectId:i.id}}function Lm(e,t){let n=cm();(n!==e||um()!==t)&&(J.navigate({to:`/terminal/$machine`,params:{machine:e},search:{project:t===`global`?void 0:t},replace:n!==null||xm(),state:{layer:`chat`},resetScroll:!1}),Nm())}async function Rm(e,t,n,r){if(n===null)throw Error(`no session selected`);`Notification`in window&&Notification.permission==="default"&&Notification.requestPermission(),X({sentAt:Date.now()}),await M(n.machine,`sessions.send`,{sessionId:n.sessionId,projectId:n.projectId,prompt:e,settings:r,delivery:t});let i=Y().replacing;n.sessionId===null&&i!==null&&i.machine===n.machine&&i.sessionId!==null&&(X({replacing:null}),await Xm(i.machine,i.sessionId,i.projectId))}function zm(e){let t=Y().selection;t!==null&&t.sessionId!==null&&M(t.machine,`sessions.unqueue`,{sessionId:t.sessionId,id:e}).catch($)}function Bm(e){let t=Y().selection;t!==null&&t.sessionId!==null&&M(t.machine,`sessions.steer`,{sessionId:t.sessionId,id:e}).catch($)}function Vm(){let e=Y().selection;e!==null&&e.sessionId!==null&&M(e.machine,`sessions.interrupt`,{sessionId:e.sessionId}).catch($)}function Hm(e,t,n){M(e,`sessions.stopTask`,{sessionId:t,taskId:n}).catch($)}function Um(e,t,n){let r=Y().selection;r!==null&&r.sessionId!==null&&M(r.machine,`sessions.respond`,{sessionId:r.sessionId,requestId:e,decision:t,answers:n}).catch($)}async function Wm(e){let t=Y().selection;if(t!==null&&t.sessionId!==null)try{let n=await M(t.machine,`sessions.fork`,{sessionId:t.sessionId,projectId:t.projectId,messageId:e});jm({...t,sessionId:n.sessionId})}catch(e){$(e)}}async function Gm(){let e=Y().selection,t=Y().before;if(e!==null&&e.sessionId!==null&&t!==null)try{let n=await M(e.machine,`sessions.earlier`,{sessionId:e.sessionId,before:t});if(Y().selection!==e||Y().before!==t)return;X({earlier:[...n.items,...Y().earlier],before:n.before})}catch(e){$(e)}}async function Km(e,t){let n=Y().selection;if(n!==null&&n.sessionId!==null)try{let r=await M(n.machine,`sessions.agent`,{sessionId:n.sessionId,projectId:n.projectId,agentId:t,parent:e});if(Y().selection!==n)return;let i=new Set(r.map(e=>e.id)),a=Y().items;X({items:[...a.filter(t=>t.parent!==e),...r,...a.filter(t=>t.parent===e&&!i.has(t.id))]})}catch(e){$(e)}}async function qm(e,t,n){let r=Y();function i(n){return n.machine===e&&n.id===t}let a=[...r.sessions,...r.inactive].find(i);if(a!==void 0){let e={...a,...n};X({sessions:r.sessions.some(i)?r.sessions.map(t=>i(t)?e:t):e.status===`inactive`?r.sessions:[...r.sessions,e],inactive:e.status===`inactive`?r.inactive.some(i)?r.inactive.map(t=>i(t)?e:t):[e,...r.inactive]:r.inactive.filter(e=>!i(e))})}try{await M(e,`sessions.update`,{id:t,patch:n})}catch(e){$(e)}}async function Jm(e){let t=lh(e.machine,e.id);X({generatingTitles:[...Y().generatingTitles,t]});try{await M(e.machine,`sessions.generateTitle`,{id:e.id,projectId:e.projectId})}catch(e){$(e)}finally{X({generatingTitles:Y().generatingTitles.filter(e=>e!==t)})}}async function Ym(e,t,n){let r=Y().selection;if(r?.machine===e&&r.sessionId===t){let i=Y().sessions.filter(r=>(r.status===`pinned`||r.status===`active`||r.status===`snoozed`)&&(r.machine!==e||r.id!==t)&&(n===null||r.machine===n.machine&&(r.projectId===n.projectId||n.projectId===`no-project`&&Lh(Y(),r.machine,r.projectId)?.scratch===!0))).sort((e,t)=>t.updatedAt-e.updatedAt).at(0);i===void 0?Fm(r.machine,r.projectId,!0):jm({machine:i.machine,projectId:i.projectId,sessionId:i.id},null,!0)}await qm(e,t,{status:`inactive`})}async function Xm(e,t,n){X({sessions:Y().sessions.filter(n=>n.machine!==e||n.id!==t),inactive:Y().inactive.filter(n=>n.machine!==e||n.id!==t)}),Ta(lh(e,t));let r=Y().selection;r?.machine===e&&r.sessionId===t&&Fm(e,r.projectId,!0);try{await M(e,`sessions.remove`,{id:t,projectId:n})}catch(e){$(e)}}var Zm=Tp({machine:Uf().optional().catch(void 0),project:Uf().optional().catch(void 0),session:Uf().optional().catch(void 0),panel:Pp([`diff`,`tasks`,`browser`]).optional().catch(void 0),browse:Uf().optional().catch(void 0),bottom:Ip(`terminal`).optional().catch(void 0),terminal:Uf().optional().catch(void 0)}),Qm=oi({validateSearch:Zm}),$m=ii({getParentRoute:()=>Qm,path:`/`}),eh=ii({getParentRoute:()=>Qm,path:`/terminal`,beforeLoad:()=>{let e=Pm();throw st(e===null?{to:`/`,search:{},replace:!0}:{to:`/terminal/$machine`,params:{machine:e},search:{},replace:!0})}}),th=ii({getParentRoute:()=>Qm,path:`/terminal/$machine`});if(window.history.state?.__TSR_index===void 0&&(location.pathname.startsWith(`/terminal`)||new URLSearchParams(location.search).has(`machine`))){let e=`${location.pathname}${location.search}${location.hash}`,t=Math.random().toString(36).slice(2),n=Math.random().toString(36).slice(2);window.history.replaceState({__TSR_index:0,__TSR_key:t,key:t},``,`/`),window.history.pushState({__TSR_index:1,__TSR_key:n,key:n,layer:`chat`},``,e)}var J=ci({routeTree:Qm.addChildren([$m,eh,th]),disableGlobalCatchBoundary:!0,parseSearch:e=>Zm.parse(Object.fromEntries(new URLSearchParams(e))),stringifySearch:e=>{let t=new URLSearchParams;for(let n of Object.entries(e))n[1]!==void 0&&t.set(n[0],String(n[1]));let n=t.toString();return n===``?``:`?${n}`}}),nh=`machines`,rh=document.querySelector(`meta[name="offsite-connect"]`)?.getAttribute(`content`)?.split(` `)??null;function ih(){let e=localStorage.getItem(nh);return e===null?[]:JSON.parse(e)}function ah(e){localStorage.setItem(nh,JSON.stringify(e))}async function oh(e){if(!(`caches`in window))return;let t=e.map(e=>({id:e.id,addresses:e.addresses}));await(await caches.open(`offsite-worker`)).put(`/machines`,new Response(JSON.stringify(t)))}function sh(){if(location.pathname!==`/pair`)return null;let e=new URLSearchParams(location.hash.slice(1));J.navigate({to:`/`,replace:!0});let t=e.get(`machine`);if(t===null)throw Error(`the pairing link has no machine`);return{address:ch(t).address,code:e.get(`code`)}}function ch(e){let t=e.trim(),n=new URL(/^[a-z]+:\/\//i.test(t)?t:`http://${t}`);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw Error(`Use an http:// or https:// address`);let r=new URLSearchParams(n.hash.slice(1)),i=r.get(`machine`);return{address:i===null?n.origin:ch(i).address,code:r.get(`code`)}}function lh(e,t){return`${e} ${t}`}function uh(e){return{id:e.id,addresses:e.addresses,via:null,status:`connecting`,name:e.label??e.name,hostname:e.name,label:e.label,icon:e.icon,pairedAt:e.pairedAt??null,config:null,composer:null,appIcon:null,configError:null,system:null,claudeAccounts:[],codexAccounts:[],openCode:{available:!1},notifier:!1,activity:{},providers:[],terminals:[]}}function dh(e){return e.projects.map(t=>({...t,machine:e.id}))}function fh(){let e=ih(),t=Y().machines;for(let n of t)e.some(e=>e.id===n.id)||xh(n.id);for(let n of e){let e=t.find(e=>e.id===n.id);if(e===void 0){let e=Y();X({machines:[...e.machines,uh(n)],projects:[...e.projects,...dh(n)]}),Ii(n.id,n.addresses)}else Q(n.id,{label:n.label,icon:n.icon,name:n.label??e.hostname}),(n.addresses.join(` `)!==e.addresses.join(` `)||n.pairedAt!==e.pairedAt)&&(Q(n.id,{addresses:n.addresses,pairedAt:n.pairedAt}),yh(n.id))}let n=e.map(e=>e.id);X({machines:[...Y().machines].sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))})}async function ph(e,t){let n=Y().machines.find(t=>t.addresses.some(t=>e.includes(t)));if(n!==void 0)return t!==null&&await mh(n.id,t),n.id;let r=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);return t!==null&&await Si(r,await hh(e,t)),X({machines:[...Y().machines,uh({id:r,addresses:e,name:new URL(e[0]).hostname,label:null,icon:`computer`,pairedAt:t===null?null:Date.now(),projects:[]})]}),Sh(),Ii(r,e),r}async function mh(e,t){await Si(e,await hh(Z(Y(),e).addresses,t)),Q(e,{pairedAt:Date.now()}),Sh(),yh(e)}async function hh(e,t){let n;for(let r of e){let e=await fetch(`${r}/api/pair`,{method:`POST`,headers:{authorization:`Bearer ${t}`}}).catch(e=>(n??=e,null));if(e!==null){if(!e.ok)throw Error(await e.text());return(await e.json()).token}}throw Error(`Could not reach the machine to pair: ${String(n)}`)}function gh(e,t){let n=Z(Y(),e),r={...n,...t};Q(e,{...t,name:r.label??r.hostname}),Sh(),r.addresses.join(` `)!==n.addresses.join(` `)&&yh(e)}function _h(e){X({machines:[...Y().machines].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id))}),Sh()}function vh(e){oh(e).catch(e=>console.error(`could not share the machines with the service worker`,e))}function yh(e){Li(e),Q(e,{status:`connecting`,via:null}),Ii(e,Z(Y(),e).addresses)}function bh(e){xh(e),Sh(),Ci(e).catch(e=>console.error(`could not remove the device token`,e))}function xh(e){Li(e);let t=Y(),n=t.machines.filter(t=>t.id!==e);X({machines:n,projects:t.projects.filter(t=>t.machine!==e),sessions:t.sessions.filter(t=>t.machine!==e),inactive:t.inactive.filter(t=>t.machine!==e),unseen:t.unseen.filter(t=>!t.startsWith(`${e} `)),...t.settingsMachine===e&&{settingsMachine:n.at(0)?.id??null},...t.selection?.machine===e&&{selection:null}}),km()}function Sh(){let e=Y(),t=e.machines.map(t=>({id:t.id,addresses:t.addresses,name:t.hostname,label:t.label,icon:t.icon,pairedAt:t.pairedAt,projects:e.projects.filter(e=>e.machine===t.id).map(e=>({id:e.id,path:e.path,name:e.name,logo:e.logo,hidden:e.hidden,scratch:e.scratch}))}));ah(t),vh(t)}var Ch=[{id:`one-dark-darker`,name:`One Dark Darker`,codeTheme:`one-dark-pro`,background:`#15181C`,foreground:`#ABB2BF`,cursor:`#B3BAC5`,selectionBackground:`#3B414D`,palette:[`#4A4F5A`,`#EE5D69`,`#97C775`,`#B68353`,`#61AFEF`,`#C678DD`,`#56B6C2`,`#CCCCCC`,`#616A7B`,`#FE808A`,`#C2DEAD`,`#D1A47A`,`#93CFFF`,`#E0A8F1`,`#82D2DC`,`#FFFFFF`]},{id:`one-dark-pro`,name:`One Dark Pro`,codeTheme:`one-dark-pro`,background:`#282C34`,foreground:`#ABB2BF`,cursor:`#528BFF`,selectionBackground:`#41454E`,palette:[`#3F4451`,`#E05561`,`#8CC265`,`#D18F52`,`#4AA5F0`,`#C162DE`,`#42B3C2`,`#D7DAE0`,`#4F5666`,`#FF616E`,`#A5E075`,`#F0A45D`,`#4DC4FF`,`#DE73FF`,`#4CD1E0`,`#E6E6E6`]},{id:`dracula`,name:`Dracula`,codeTheme:`dracula`,background:`#282A36`,foreground:`#F8F8F2`,cursor:`#F8F8F2`,selectionBackground:`#44475A`,palette:[`#21222C`,`#FF5555`,`#50FA7B`,`#F1FA8C`,`#BD93F9`,`#FF79C6`,`#8BE9FD`,`#F8F8F2`,`#6272A4`,`#FF6E6E`,`#69FF94`,`#FFFFA5`,`#D6ACFF`,`#FF92DF`,`#A4FFFF`,`#FFFFFF`]},{id:`tokyo-night`,name:`Tokyo Night`,codeTheme:`tokyo-night`,background:`#1A1B26`,foreground:`#C0CAF5`,cursor:`#C0CAF5`,selectionBackground:`#33467C`,palette:[`#15161E`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#A9B1D6`,`#414868`,`#F7768E`,`#9ECE6A`,`#E0AF68`,`#7AA2F7`,`#BB9AF7`,`#7DCFFF`,`#C0CAF5`]},{id:`catppuccin-mocha`,name:`Catppuccin Mocha`,codeTheme:`catppuccin-mocha`,background:`#1E1E2E`,foreground:`#CDD6F4`,cursor:`#F5E0DC`,selectionBackground:`#585B70`,palette:[`#45475A`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#BAC2DE`,`#585B70`,`#F38BA8`,`#A6E3A1`,`#F9E2AF`,`#89B4FA`,`#F5C2E7`,`#94E2D5`,`#A6ADC8`]},{id:`nord`,name:`Nord`,codeTheme:`nord`,background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,selectionBackground:`#434C5E`,palette:[`#3B4252`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#88C0D0`,`#E5E9F0`,`#4C566A`,`#BF616A`,`#A3BE8C`,`#EBCB8B`,`#81A1C1`,`#B48EAD`,`#8FBCBB`,`#ECEFF4`]},{id:`gruvbox-dark`,name:`Gruvbox Dark`,codeTheme:`gruvbox-dark-medium`,background:`#282828`,foreground:`#EBDBB2`,cursor:`#EBDBB2`,selectionBackground:`#504945`,palette:[`#282828`,`#CC241D`,`#98971A`,`#D79921`,`#458588`,`#B16286`,`#689D6A`,`#A89984`,`#928374`,`#FB4934`,`#B8BB26`,`#FABD2F`,`#83A598`,`#D3869B`,`#8EC07C`,`#EBDBB2`]},{id:`solarized-dark`,name:`Solarized Dark`,codeTheme:`solarized-dark`,background:`#002B36`,foreground:`#839496`,cursor:`#839496`,selectionBackground:`#073642`,palette:[`#073642`,`#DC322F`,`#859900`,`#B58900`,`#268BD2`,`#D33682`,`#2AA198`,`#EEE8D5`,`#002B36`,`#CB4B16`,`#586E75`,`#657B83`,`#839496`,`#6C71C4`,`#93A1A1`,`#FDF6E3`]},{id:`github-dark`,name:`GitHub Dark`,codeTheme:`github-dark`,background:`#0D1117`,foreground:`#E6EDF3`,cursor:`#E6EDF3`,selectionBackground:`#264F78`,palette:[`#484F58`,`#FF7B72`,`#3FB950`,`#D29922`,`#58A6FF`,`#BC8CFF`,`#39C5CF`,`#B1BAC4`,`#6E7681`,`#FFA198`,`#56D364`,`#E3B341`,`#79C0FF`,`#D2A8FF`,`#56D4DD`,`#FFFFFF`]},{id:`rose-pine`,name:`Rosé Pine`,codeTheme:`rose-pine`,background:`#191724`,foreground:`#E0DEF4`,cursor:`#E0DEF4`,selectionBackground:`#403D52`,palette:[`#26233A`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`,`#6E6A86`,`#EB6F92`,`#31748F`,`#F6C177`,`#9CCFD8`,`#C4A7E7`,`#EBBCBA`,`#E0DEF4`]}],wh=Ep({theme:Uf().refine(e=>Ch.some(t=>t.id===e)).default(Ch[0].id),terminal:Ep({font:Ep({family:Uf().default(`FiraCode Nerd Font`),size:mp().default(14),lineHeight:mp().default(1.35),ligatures:q().default(!0)}).prefault({}),cursor:Ep({style:Pp([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),padding:Ep({top:mp().default(4),right:mp().default(4),bottom:mp().default(0),left:mp().default(4)}).prefault({}),scrollback:mp().default(1e3),boldIsBright:q().default(!0),behavior:Ep({modernizeShiftEnter:q().default(!0),pasteBrowserImages:q().default(!0),captureShortcuts:q().default(!0),bellFlash:q().default(!0),bellSound:q().default(!0),clickToMoveCursor:q().default(!0),optionAsMeta:Pp([`off`,`left`,`right`,`both`]).default(`off`),windowsCopyPaste:q().default(!0),confirmCloseBusyTab:q().default(!0)}).prefault({})}).prefault({}),editor:Ep({font:Ep({family:Uf().default(`FiraCode Nerd Font`),size:mp().default(15.3),lineHeight:mp().default(1.8),ligatures:q().default(!0),features:Uf().default(`'zero', 'ss02', 'ss06', 'cv02', 'cv14', 'cv26'`)}).prefault({}),cursor:Ep({style:Pp([`block`,`bar`,`underline`]).default(`bar`),blink:q().default(!0)}).prefault({}),tabSize:mp().default(2),wordWrap:q().default(!0),graph:q().default(!0)}).prefault({}),diff:Ep({split:q().default(!1),wrap:q().default(!0),collapsed:q().default(!1)}).prefault({}),rewind:Pp([`all`,`chat`,`code`]).default(`chat`),groupActiveByProject:q().default(!1),toolbar:Cp(Pp([`diff`,`terminal`,`tasks`,`browser`,`editor`])).default([`diff`,`terminal`,`editor`])}),Th=`prefs`,Eh=wh.parse({});function Dh(){let e=localStorage.getItem(Th);if(e===null)return structuredClone(Eh);let t=wh.safeParse(JSON.parse(e));return t.success?t.data:(console.warn(`invalid stored prefs, using the defaults:\n${ss(t.error)}`),structuredClone(Eh))}function Oh(e){localStorage.setItem(Th,JSON.stringify(e))}function kh(){let e=Y().prefs.theme,t=Ch.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t}function Ah(){let e=Ih(e=>e.prefs.theme),t=Ch.find(t=>t.id===e);if(t===void 0)throw Error(`unknown theme ${e}`);return t.codeTheme}function jh(){let e=kh(),t=document.documentElement.style;t.setProperty(`--bg`,e.background),t.setProperty(`--text`,e.foreground),t.setProperty(`--blue`,e.palette[4]),t.setProperty(`--danger`,e.palette[1]),t.setProperty(`--green`,e.palette[2]),t.setProperty(`--yellow`,e.palette[3]),document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.background)}var Mh={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`},Nh;function Ph(e){Nh=aa()(()=>e)}function Fh(e){return Nh.subscribe(e)}function Y(){return Nh.getState()}function Ih(e){return sa(Nh,e)}function X(e){Nh.setState(e)}function Z(e,t){let n=e.machines.find(e=>e.id===t);if(n===void 0)throw Error(`unknown machine ${t}`);return n}function Lh(e,t,n){return e.projects.find(e=>e.machine===t&&e.id===n)}function Rh(e){return e.selection?.machine??e.machines.at(0)?.id??null}function Q(e,t){X({machines:Y().machines.map(n=>n.id===e?{...n,...t}:n)})}function zh(e,t,n){if(n!==null)return e.find(e=>e.id===t)?.activity[n]}function Bh(e){let t=e.selection;if(t!==null)return zh(e.machines,t.machine,t.sessionId)}function Vh(e){return Bh(e)?.running===!0}function Hh(e){return e.sessionId===null?`new`:lh(e.machine,e.sessionId)}function Uh(e){X({draft:e})}function Wh(e){X({paletteOpen:e})}function Gh(e){X({editor:e})}function Kh(e){X({exporting:e})}function qh(e){X({settingsOpen:e,paletteOpen:!1,...e&&{settingsMachine:Rh(Y()),settingsAccount:null,settingsEditedMachine:null,settingsListing:!0}})}function Jh(e){X({usageOpen:e,paletteOpen:!1})}function Yh(e){X({settingsOpen:!0,settingsPage:e,settingsAccount:null,settingsEditedMachine:null,settingsListing:!1,paletteOpen:!1,...!Y().settingsOpen&&{settingsMachine:Rh(Y())}})}function Xh(e){X({prefs:e}),Oh(e),jh()}function $(e){X({errors:[...Y().errors,i(e)]})}function Zh(){X({errors:[]})}function Qh(e){let t=new Map;function n(t,n){Y().machines.some(e=>e.id===t)&&e.apply(t,n)}async function r(r,a){let o=await e.save(r,a),s=t.get(r);s!==void 0&&(--s.writes,s.writes>0||(o===null?await i(r):n(r,o)))}async function i(r){let i=t.get(r)?.version;try{let a=await e.load(r),o=t.get(r);o!==void 0&&o.writes===0&&o.version===i&&n(r,a)}catch(e){$(e)}}return{update(n,i){e.set(n,i);let a=t.get(n)??{writes:0,version:0,timer:void 0};t.set(n,a),a.timer===void 0&&(a.writes+=1),a.version+=1,window.clearTimeout(a.timer),a.timer=window.setTimeout(()=>{a.timer=void 0,r(n,i)},300)},receive(e,r){(t.get(e)?.writes??0)===0&&n(e,r)}}}var $h=Qh({set:ag,save:async(e,t)=>{try{let n=await M(e,`config.save`,t);return Q(e,{configError:null}),n}catch(t){return Q(e,{configError:i(t)}),null}},load:async e=>(await M(e,`config.get`,void 0)).config,apply:ag}),eg=Qh({set:(e,t)=>Q(e,{composer:t}),save:async(e,t)=>{try{return await M(e,`composer.save`,t)}catch(e){return $(e),null}},load:e=>M(e,`composer.get`,void 0),apply:og}),tg=$h.update,ng=$h.receive,rg=eg.update,ig=eg.receive;function ag(e,t){let n=Z(Y(),e).config;Q(e,{config:t}),n!==null&&ra(n.newThreads,t.newThreads)||pg(e)}function og(e,t){let n=Z(Y(),e).composer;Q(e,{composer:t});let r=Y().selection;if(r===null||r.machine!==e)return;if(r.sessionId===null){n===null&&pg(e);return}if(zh(Y().machines,e,r.sessionId)!==void 0)return;let i=Da(Hh(r))??lg(t,Y().settings.provider),a=i.provider!==Y().settings.provider||i.accountId!==Y().settings.accountId;X({settings:i}),a&&gg()}var sg=null,cg={provider:`claude`,accountId:null,model:null,effort:null,mode:null,plan:!1};function lg(e,t){return e===null?{...cg,provider:t}:{provider:t,...e[t]}}function ug(e){if(e.config===null)return cg;let t=e.config.newThreads;return{...lg(e.composer,t.provider),accountId:t.accountId,model:t.models[t.provider],effort:null}}function dg(e){let t={...Y().settings,...e};X({settings:t});let n=Y().selection;if(n===null)return;n.sessionId!==null&&Oa(Hh(n),t);let r=Z(Y(),n.machine).composer;r!==null&&rg(n.machine,{...r,provider:t.provider,[t.provider]:{accountId:t.accountId,model:t.model,effort:t.effort,mode:t.mode,plan:t.plan}}),e.accountId!==void 0&&gg(),n.sessionId!==null&&zh(Y().machines,n.machine,n.sessionId)!==void 0&&e.accountId===void 0&&M(n.machine,`sessions.configure`,{sessionId:n.sessionId,settings:t}).catch($)}function fg(e,t){if(Q(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),Y().selection?.machine!==e)return;let n=Y().settings,r=[...[...t.claudeAccounts,...t.codexAccounts].filter(e=>e.valid).map(e=>({provider:e.provider,accountId:e.id})),...t.openCode.available?[{provider:`opencode`,accountId:null}]:[]];if(r.some(e=>e.provider===n.provider&&e.accountId===n.accountId))return;let i=r.find(e=>e.provider===n.provider),a=Y().selection?.sessionId===null?r.at(0):void 0;if(i!==void 0)dg({accountId:i.accountId});else if(a!==void 0){let t=Z(Y(),e);dg({...lg(t.composer,a.provider),accountId:a.accountId,model:t.config===null?null:t.config.newThreads.models[a.provider],effort:null})}else n.accountId!==null&&dg({accountId:null})}function pg(e){let t=Y().selection;t?.machine===e&&t.sessionId===null&&(X({settings:ug(Z(Y(),e))}),mg(e))}function mg(e){let t=Z(Y(),e);(t.claudeAccounts.length>0||t.codexAccounts.length>0||t.openCode.available)&&fg(e,{claudeAccounts:t.claudeAccounts,codexAccounts:t.codexAccounts,openCode:t.openCode}),gg()}async function hg(e){try{fg(e,await M(e,`accounts.list`,void 0))}catch(e){$(e)}}async function gg(){let e=Y().selection;if(e===null)return;let{provider:t,accountId:n}=Y().settings;if(t!==`opencode`&&n===null)X({capabilities:null});else try{let r=JSON.stringify([e.machine,t,n,e.projectId]);if(sg?.key!==r){let i=M(e.machine,`capabilities`,{provider:t,accountId:n,projectId:e.projectId});function a(){sg?.result===i&&(sg=null)}i.then(a,a),sg={key:r,result:i}}let i=await sg.result;if(Y().selection?.machine!==e.machine||Y().selection?.projectId!==e.projectId||Y().settings.provider!==t||Y().settings.accountId!==n)return;X({capabilities:i});let a=Y().settings;if(a.model!==null){let e=i.models.find(e=>e.value===a.model)?.effort;a.provider!==`opencode`&&a.effort===null&&e!=null&&dg({effort:e});return}let o=i.models.find(e=>!e.hidden&&e.value===i.defaultModel)??i.models.find(e=>!e.hidden);if(o===void 0)return;dg({model:o.value,...o.effort===null?{}:{effort:o.effort}})}catch(e){$(e)}}var _g=[[`path`,{d:`M18 6L12 12M12 12L6 18M12 12L18 18M12 12L6 6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}]];export{_h as $,Ca as $t,Jh as A,fm as At,Ch as B,Ap as Bt,Q as C,Re as Cn,sm as Ct,Wh as D,mm as Dt,Kh as E,hm as Et,jh as F,Tm as Ft,lh as G,Sa as Gt,rh as H,Tp as Ht,kh as I,lm as It,Sh as J,Aa as Jt,mh as K,Ea as Kt,Ah as L,dm as Lt,X as M,km as Mt,Xh as N,cm as Nt,qh as O,Om as Ot,Ih as P,um as Pt,bh as Q,Na as Qt,Eh as R,om as Rt,Uh as S,ot as Sn,zm as St,$ as T,de as Tn,Sm as Tt,gh as U,Uf as Ut,ph as V,Ip as Vt,ih as W,Pa as Wt,fh as X,wa as Xt,ch as Y,ja as Yt,yh as Z,ba as Zt,Z as _,jr as _n,Um as _t,hg as a,M as an,Ym as at,Bh as b,ir as bn,Bm as bt,ig as c,Ri as cn,Vm as ct,zh as d,Pi as dn,Gm as dt,Oa as en,uh as et,Ph as f,mi as fn,Mm as ft,Y as g,Rr as gn,Xm as gt,Hh as h,ui as hn,Jm as ht,lg as i,ra as in,Nm as it,Fh as j,wm as jt,Yh as k,pm as kt,ng as l,Bi as ln,Im as lt,Zh as m,vi as mn,Lm as mt,dg as n,xa as nn,vh as nt,gg as o,Ii as on,qm as ot,Rh as p,_i as pn,jm as pt,sh as q,Da as qt,cg as r,ka as rn,J as rt,fg as s,zi as sn,Wm as st,_g as t,Ma as tn,dh as tt,tg as u,Vi as un,Km as ut,Lh as v,sr as vn,Rm as vt,Gh as w,Ae as wn,gm as wt,Vh as x,Yt as xn,Hm as xt,Mh as y,ar as yn,Fm as yt,Dh as z,q as zt};